Contributing Guidelines
We welcome contributions to Qwen Code! This guide will help you get started with contributing to the project.Contribution Process
Code Reviews
All submissions, including those from project members, require review. We use GitHub pull requests for this purpose.Pull Request Guidelines
To help us review and merge your PRs quickly, please follow these guidelines. PRs that do not meet these standards may be closed.1. Link to an Existing Issue
All PRs should be linked to an existing issue in our tracker. This ensures that every change has been discussed and is aligned with the project’s goals before any code is written.- For bug fixes: The PR should be linked to the bug report issue.
- For features: The PR should be linked to the feature request or proposal issue that has been approved by a maintainer.
2. Keep It Small and Focused
We favor small, atomic PRs that address a single issue or add a single, self-contained feature.- Do: Create a PR that fixes one specific bug or adds one specific feature.
- Don’t: Bundle multiple unrelated changes (e.g., a bug fix, a new feature, and a refactor) into a single PR.
3. Use Draft PRs for Work in Progress
If you’d like to get early feedback on your work, please use GitHub’s Draft Pull Request feature. This signals to the maintainers that the PR is not yet ready for a formal review but is open for discussion and initial feedback.4. Ensure All Checks Pass
Before submitting your PR, ensure that all automated checks are passing by running:5. Update Documentation
If your PR introduces a user-facing change (e.g., a new command, a modified flag, or a change in behavior), you must also update the relevant documentation in the/docs directory.
6. Write Clear Commit Messages and a Good PR Description
Your PR should have a clear, descriptive title and a detailed description of the changes. Follow the Conventional Commits standard for your commit messages. Good PR Title Examples:feat(cli): Add --json flag to 'config get' commandfix(tools): Handle ENOENT error in read-file tooldocs: Update architecture documentation
Made some changesFix bugUpdate
Fixes #123).
Development Workflow
Setting Up Your Environment
See the Development Setup guide for detailed instructions on setting up your development environment.Running Tests
Before submitting a PR, make sure all tests pass:Linting and Formatting
We use ESLint and Prettier to maintain code quality:Coding Conventions
Please adhere to these conventions throughout the codebase:TypeScript Style
- Strict Mode: All TypeScript strict flags are enabled
- Type Safety: Avoid
anytypes; use proper type definitions - Module System: ES modules with
.jsextensions in imports - Naming:
camelCasefor variables and functionsPascalCasefor classes and typesUPPER_SNAKE_CASEfor constants
Import Conventions
Testing Patterns
- Unit Tests: Co-located with source files using
.test.tssuffix - Test Framework: Vitest with globals enabled
- Mocking:
- HTTP requests:
msw - File system:
memfsormock-fs - Dependencies: Vitest’s built-in mocking
- HTTP requests:
Documentation
- Code Comments: Use JSDoc for public APIs
- README Files: Update when adding new features
- User Documentation: Update in
/docsfor user-facing changes - Architecture Docs: Update for significant structural changes
Pre-commit Hook
You can set up a pre-commit hook to run checks automatically:Project Structure
Understanding the project structure will help you know where to make changes:Common Contribution Scenarios
Adding a New Tool
- Create a new file in
packages/core/src/tools/ - Extend
BaseDeclarativeTool - Implement required methods
- Add tests in a
.test.tsfile - Register the tool in the tool registry
- Update documentation
Adding a New Command
- Create a command handler in
packages/cli/src/commands/ - Register the command in the command registry
- Add tests
- Update help text and documentation
Fixing a Bug
- Add a test that reproduces the bug
- Fix the bug
- Ensure the test passes
- Add any additional tests for edge cases
- Update documentation if behavior changed
Improving Documentation
- Documentation files are in
/docs - Use MDX format for documentation pages
- Test locally using the docs-site (see below)
- Follow the existing documentation structure
Documentation Development
Prerequisites
- Node.js 18+
- npm or yarn
Local Documentation Preview
/docs directory will be reflected immediately in the documentation site.
Debugging
VS Code Debugging
- Press
F5to launch with debugger attached - Or run:
npm run debug - Use breakpoints in VS Code
React DevTools (for CLI UI)
Sandbox Debugging
Getting Help
If you need help or have questions:- Check the documentation
- Search existing issues
- Ask in discussions
- Open a new issue if needed
