mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-19 07:54:38 +00:00
* chore(deps): upgrade ink 6.2.3 -> 7.0.2 + bump Node engine to 22
ink 7 requires Node >=22 and react-reconciler 0.33 with React >=19.2,
so this PR also bumps:
- Node engines (root + cli + core) 20 -> 22
- React/react-dom 19.1 -> 19.2.4 (pinned exact via overrides to keep
the transitive React graph deduped to a single instance)
- @types/node pinned to 20.19.1 via overrides to avoid an unrelated
Dirent NonSharedBuffer regression in sessionService tests
- @vitest/eslint-plugin pinned to 1.3.4 to avoid an unrelated lint
regression introduced by the 1.6.x rule additions
- react-devtools-core 4.28 -> 6.1 (ink 7 peerOptional requires >=6.1.2)
- ink hoisted to root devDeps so workspace-private peer-dep contention
doesn't push ink-link/spinner/gradient into nested workspace
installs (which would skip transitive resolution for terminal-link)
Workflow + image + installer alignment:
- .nvmrc 20 -> 22
- Dockerfile node:20-slim -> node:22-slim
- CI test matrix drops 20.x (keeps 22.x + 24.x)
- terminal-bench workflow Node 20 -> 22
- Linux/Windows install scripts upgrade their Node version targets
Documentation alignment:
- README.md badge + prerequisites
- AGENTS.md, CONTRIBUTING.md, docs/users/quickstart.md,
docs/users/configuration/settings.md, docs/developers/contributing.md,
docs/developers/sdk-typescript.md, docs/users/extension/extension-releasing.md,
packages/sdk-typescript/README.md, packages/zed-extension/README.md,
scripts/installation/INSTALLATION_GUIDE.md
Test gating:
- Two AuthDialog/AskUserQuestionDialog tests that drive <SelectInput>
through ink-testing-library now race ink 7's frame-throttled input
delivery and land on the wrong option. The maintainers had already
marked one of them unreliable (skip on Win32 + CI+Node20). Extend
that gate to cover all environments until upstream
ink-testing-library ships an ink-7-compatible release that flushes
input deterministically. The other test now uses it.skip with the
same comment. No business code changes.
Verified locally:
- npm run typecheck across all workspaces: clean
- npm run lint (root): clean
- npm run test --workspaces:
cli 312/312 files, 4918 passed, 9 skipped
core 266/266 files, 6836 passed, 3 skipped
webui 6/6, 201 passed
sdk 40/40, 283 passed, 1 skipped
- npm ls ink: single ink@7.0.2 instance across all peer deps
- single react@19.2.4 instance
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* chore: align Node 22 floor across all shipping artifacts
Reviewer (tanzhenxin) flagged five surfaces where the >=22 engine bump
leaked: SDK package metadata, web-templates engines, /doctor runtime
check, main bundler target, and SDK bundler target. Each was a separate
escape hatch letting Node 18/20 consumers install or run the artifact
on an unsupported runtime.
- packages/sdk-typescript/package.json: engines.node >=18.0.0 -> >=22.0.0
- packages/web-templates/package.json: engines.node >=20 -> >=22
- packages/cli/src/utils/doctorChecks.ts: MIN_NODE_MAJOR 20 -> 22
- esbuild.config.js: target node20 -> node22 (main CLI bundle)
- packages/sdk-typescript/scripts/build.js: target node18 -> node22 (esm + cjs)
- packages/cli/src/utils/doctorChecks.test.ts: rename test label to v22+
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* ci(e2e): bump E2E workflow Node matrix to 22.x
Reviewer (tanzhenxin) flagged that e2e.yml still pinned node-version
20.x while root engines is now >=22, so every E2E run on push would
either fail at npm ci with engine error or silently exercise the bundle
on a runtime that's no longer in ci.yml's test matrix.
The macOS job in the same workflow already reads .nvmrc (which is 22)
so this only updates the Linux matrix.
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(deps): drop root wrap-ansi override so ink 7 gets its declared dep
Reviewer (tanzhenxin) flagged that the root overrides.wrap-ansi: 9.0.2
predates this upgrade and forces every consumer (including ink) to v9,
while ink 7 declares wrap-ansi: ^10.0.0. The lockfile had no nested
install under node_modules/ink/, so ink 7 was running with a transitive
dep one major below its declared minimum.
Dropping the global override lets ink resolve its own wrap-ansi 10
nested install (now visible in the lockfile under
node_modules/ink/node_modules/wrap-ansi), while the cli package's own
direct `wrap-ansi: 9.0.2` dependency keeps the cli code path
(TableRenderer.tsx) on the version it has been tested against. The
nested cliui override is preserved for yargs which still needs v7.
Verified via `npm ls wrap-ansi`:
- ink@7.0.2 -> wrap-ansi@10.0.0 (newly nested)
- @qwen-code/qwen-code -> wrap-ansi@9.0.2 (unchanged)
- yargs/cliui -> wrap-ansi@7.0.0 (unchanged)
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* test(InputPrompt): un-skip placeholder ID reuse after deletion
Reviewer (tanzhenxin) flagged that the new it.skip on the
'should reuse placeholder ID after deletion' test was undisclosed in
the PR description and removed coverage of real product behavior
(freePlaceholderId / bracketed-paste backspace path) without a
TODO(#NNNN) link.
Their argument was sound: the skip rationale pointed at ink 7's input
throttle, but this same file just bumped the wait helper from 50ms to
150ms specifically to give ink 7 frame time. Re-running the test under
the bumped wait shows it passes reliably (5/5 runs in the full-file
context, 9/10 alone), so the skip was masking the throttle-flake that
the wait bump already addresses, not a real product bug.
Drop the it.skip and the now-stale comment so coverage of the
freePlaceholderId reuse logic is restored.
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* test(InputPrompt): bump first prompt-suggestion test wait to 350ms
The "accepts and submits the prompt suggestion on Enter when the buffer
is empty" test is the first in its describe block, so it pays the
renderer cold-start cost. On macOS-22.x CI runners that pushes the
Enter → onSubmit microtask past the default 150ms post-Enter wait. Match
the 350ms initial render wait used immediately above to absorb the cold
start.
* Revert "test(InputPrompt): bump first prompt-suggestion test wait to 350ms"
This reverts commit 6add83b62e.
* test(InputPrompt): wait for followup suggestion debounce before pressing Enter
Root cause of the failing prompt-suggestion tests on macOS and Windows
CI is not flaky timing of the test post-Enter wait — it's the 300ms
debounce inside createFollowupController.setSuggestion (shared core).
The Enter handler reads followup.state.isVisible synchronously, so if
the debounce timer has not fired before stdin.write('\\r'), the
suggestion path is skipped and onSubmit never runs. No amount of
post-Enter wait can recover from that — the keypress was already
processed against stale state.
The original wait(350) only left ~50ms margin over the 300ms debounce,
which ink 7 / React 19.2 mount overhead consumed on slow Windows
runners. Bump the initial wait to 700ms (named SUGGESTION_VISIBLE_WAIT_MS)
to give the debounce timer + cold-start render a generous buffer.
Apply to the two sibling tests too — without the wait their "does not
accept" assertions pass trivially when suggestion is never visible,
which is a false green that hides regressions in the actual reject path.
* fix(deps): align cli wrap-ansi with ink 7 (9.0.2 -> ^10.0.0)
Ink 7 ships its own wrap-ansi@10. CLI's direct dep was pinned to 9.0.2,
causing two copies of wrap-ansi in node_modules and a potential drift in
CJK width / ANSI handling between ink's internal text wrapping and our
TableRenderer.
Upgrading the CLI's direct dep to ^10.0.0 lets npm dedupe to a single
wrap-ansi@10 used by both ink and TableRenderer. API surface is
identical; the only documented behaviour change is that tabs are
expanded to 8-column tab stops before wrapping, which TableRenderer
doesn't feed in.
TableRenderer test suite (43 tests) passes against wrap-ansi@10.
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* chore(deps): document @types/node 20.x pin in overrides
The override pinning @types/node to 20.19.1 (while engines require
Node >=22) is intentional: bumping to @types/node@22.x re-introduces
a Dirent<NonSharedBuffer> type regression that breaks
@qwen-code/qwen-code-core/sessionService tests.
Add a sibling "//@types/node" note inside `overrides` so future
maintainers see the rationale and know when to revisit the pin
without having to dig through PR #3860 history.
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* test(AskUserQuestionDialog): link skipped Submit-tab test to tracking issue
The 'shows unanswered questions as (not answered) in Submit tab' test
was switched to `it.skip` in the ink 7 upgrade because
`ink-testing-library@4.0.0` doesn't flush input deterministically
through ink 7's 30fps throttle.
Add a `// TODO(#4036):` marker so the skip is greppable and can be
re-enabled once upstream ships an ink-7-compatible release.
Refs #4036
Generated with AI
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(deps): move @types/node pin comment out of overrides block
npm's `overrides` field requires every key to be a real package name —
the `"//@types/node"` comment-key added in 205855875 trips Arborist with
"Override without name" and breaks `npm ci` across all CI jobs.
Move the explanation to a sibling top-level `"//overrides"` key, which
npm ignores at the document root. Same documentation value, no
override-parser collateral damage.
---------
Co-authored-by: 秦奇 <gary.gq@alibaba-inc.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
303 lines
9.7 KiB
Markdown
303 lines
9.7 KiB
Markdown
# How to Contribute
|
|
|
|
We would love to accept your patches and contributions to this project.
|
|
|
|
## Contribution Process
|
|
|
|
### Code Reviews
|
|
|
|
All submissions, including submissions by project members, require review. We
|
|
use [GitHub pull requests](https://docs.github.com/articles/about-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.
|
|
|
|
If an issue for your change doesn't exist, please **open one first** and wait for feedback before you start coding.
|
|
|
|
#### 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.
|
|
|
|
Large changes should be broken down into a series of smaller, logical PRs that can be reviewed and merged independently.
|
|
|
|
#### 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 `npm run preflight`. This command runs all tests, linting, and other style checks.
|
|
|
|
#### 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](https://www.conventionalcommits.org/) standard for your commit messages.
|
|
|
|
- **Good PR Title:** `feat(cli): Add --json flag to 'config get' command`
|
|
- **Bad PR Title:** `Made some changes`
|
|
|
|
In the PR description, explain the "why" behind your changes and link to the relevant issue (e.g., `Fixes #123`).
|
|
|
|
## Development Setup and Workflow
|
|
|
|
This section guides contributors on how to build, modify, and understand the development setup of this project.
|
|
|
|
### Setting Up the Development Environment
|
|
|
|
**Prerequisites:**
|
|
|
|
1. **Node.js**:
|
|
- **Development:** Please use Node.js `>=22`. Ink 7 (used by the TUI) requires Node 22, and `react@^19.2.0` is the matching peer. You can use a tool like [nvm](https://github.com/nvm-sh/nvm) to manage Node.js versions.
|
|
- **Production:** For running the CLI in a production environment, any version of Node.js `>=22` is acceptable.
|
|
2. **Git**
|
|
|
|
### Build Process
|
|
|
|
To clone the repository:
|
|
|
|
```bash
|
|
git clone https://github.com/QwenLM/qwen-code.git # Or your fork's URL
|
|
cd qwen-code
|
|
```
|
|
|
|
To install dependencies defined in `package.json` as well as root dependencies:
|
|
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
To build the entire project (all packages):
|
|
|
|
```bash
|
|
npm run build
|
|
```
|
|
|
|
This command typically compiles TypeScript to JavaScript, bundles assets, and prepares the packages for execution. Refer to `scripts/build.js` and `package.json` scripts for more details on what happens during the build.
|
|
|
|
### Enabling Sandboxing
|
|
|
|
[Sandboxing](#sandboxing) is highly recommended and requires, at a minimum, setting `QWEN_SANDBOX=true` in your `~/.env` and ensuring a sandboxing provider (e.g. `macOS Seatbelt`, `docker`, or `podman`) is available. See [Sandboxing](#sandboxing) for details.
|
|
|
|
To build both the `qwen-code` CLI utility and the sandbox container, run `build:all` from the root directory:
|
|
|
|
```bash
|
|
npm run build:all
|
|
```
|
|
|
|
To skip building the sandbox container, you can use `npm run build` instead.
|
|
|
|
### Running
|
|
|
|
To start the Qwen Code application from the source code (after building), run the following command from the root directory:
|
|
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
If you'd like to run the source build outside of the qwen-code folder, you can utilize `npm link path/to/qwen-code/packages/cli` (see: [docs](https://docs.npmjs.com/cli/v9/commands/npm-link)) to run with `qwen-code`
|
|
|
|
### Running Tests
|
|
|
|
This project contains two types of tests: unit tests and integration tests.
|
|
|
|
#### Unit Tests
|
|
|
|
To execute the unit test suite for the project:
|
|
|
|
```bash
|
|
npm run test
|
|
```
|
|
|
|
This will run tests located in the `packages/core` and `packages/cli` directories. Ensure tests pass before submitting any changes. For a more comprehensive check, it is recommended to run `npm run preflight`.
|
|
|
|
#### Integration Tests
|
|
|
|
The integration tests are designed to validate the end-to-end functionality of Qwen Code. They are not run as part of the default `npm run test` command.
|
|
|
|
To run the integration tests, use the following command:
|
|
|
|
```bash
|
|
npm run test:e2e
|
|
```
|
|
|
|
For more detailed information on the integration testing framework, please see the [Integration Tests documentation](./docs/integration-tests.md).
|
|
|
|
### Linting and Preflight Checks
|
|
|
|
To ensure code quality and formatting consistency, run the preflight check:
|
|
|
|
```bash
|
|
npm run preflight
|
|
```
|
|
|
|
This command will run ESLint, Prettier, all tests, and other checks as defined in the project's `package.json`.
|
|
|
|
_ProTip_
|
|
|
|
after cloning create a git precommit hook file to ensure your commits are always clean.
|
|
|
|
```bash
|
|
echo "
|
|
# Run npm build and check for errors
|
|
if ! npm run preflight; then
|
|
echo "npm build failed. Commit aborted."
|
|
exit 1
|
|
fi
|
|
" > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
|
|
```
|
|
|
|
#### Formatting
|
|
|
|
To separately format the code in this project by running the following command from the root directory:
|
|
|
|
```bash
|
|
npm run format
|
|
```
|
|
|
|
This command uses Prettier to format the code according to the project's style guidelines.
|
|
|
|
#### Linting
|
|
|
|
To separately lint the code in this project, run the following command from the root directory:
|
|
|
|
```bash
|
|
npm run lint
|
|
```
|
|
|
|
### Coding Conventions
|
|
|
|
- Please adhere to the coding style, patterns, and conventions used throughout the existing codebase.
|
|
- **Imports:** Pay special attention to import paths. The project uses ESLint to enforce restrictions on relative imports between packages.
|
|
|
|
### Project Structure
|
|
|
|
- `packages/`: Contains the individual sub-packages of the project.
|
|
- `cli/`: The command-line interface.
|
|
- `core/`: The core backend logic for Qwen Code.
|
|
- `docs/`: Contains all project documentation.
|
|
- `scripts/`: Utility scripts for building, testing, and development tasks.
|
|
|
|
For more detailed architecture, see `docs/architecture.md`.
|
|
|
|
## Documentation Development
|
|
|
|
This section describes how to develop and preview the documentation locally.
|
|
|
|
### Prerequisites
|
|
|
|
1. Ensure you have Node.js (version 18+) installed
|
|
2. Have npm or yarn available
|
|
|
|
### Setup Documentation Site Locally
|
|
|
|
To work on the documentation and preview changes locally:
|
|
|
|
1. Navigate to the `docs-site` directory:
|
|
|
|
```bash
|
|
cd docs-site
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
3. Link the documentation content from the main `docs` directory:
|
|
|
|
```bash
|
|
npm run link
|
|
```
|
|
|
|
This creates a symbolic link from `../docs` to `content` in the docs-site project, allowing the documentation content to be served by the Next.js site.
|
|
|
|
4. Start the development server:
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
5. Open [http://localhost:3000](http://localhost:3000) in your browser to see the documentation site with live updates as you make changes.
|
|
|
|
Any changes made to the documentation files in the main `docs` directory will be reflected immediately in the documentation site.
|
|
|
|
## Debugging
|
|
|
|
### VS Code:
|
|
|
|
0. Run the CLI to interactively debug in VS Code with `F5`
|
|
1. Start the CLI in debug mode from the root directory:
|
|
```bash
|
|
npm run debug
|
|
```
|
|
This command runs `node --inspect-brk dist/index.js` within the `packages/cli` directory, pausing execution until a debugger attaches. You can then open `chrome://inspect` in your Chrome browser to connect to the debugger.
|
|
2. In VS Code, use the "Attach" launch configuration (found in `.vscode/launch.json`).
|
|
|
|
Alternatively, you can use the "Launch Program" configuration in VS Code if you prefer to launch the currently open file directly, but 'F5' is generally recommended.
|
|
|
|
To hit a breakpoint inside the sandbox container run:
|
|
|
|
```bash
|
|
DEBUG=1 qwen-code
|
|
```
|
|
|
|
**Note:** If you have `DEBUG=true` in a project's `.env` file, it won't affect qwen-code due to automatic exclusion. Use `.qwen-code/.env` files for qwen-code specific debug settings.
|
|
|
|
### React DevTools
|
|
|
|
To debug the CLI's React-based UI, you can use React DevTools. Ink, the library used for the CLI's interface, is compatible with React DevTools version 4.x.
|
|
|
|
1. **Start the Qwen Code application in development mode:**
|
|
|
|
```bash
|
|
DEV=true npm start
|
|
```
|
|
|
|
2. **Install and run React DevTools version 4.28.5 (or the latest compatible 4.x version):**
|
|
|
|
You can either install it globally:
|
|
|
|
```bash
|
|
npm install -g react-devtools@4.28.5
|
|
react-devtools
|
|
```
|
|
|
|
Or run it directly using npx:
|
|
|
|
```bash
|
|
npx react-devtools@4.28.5
|
|
```
|
|
|
|
Your running CLI application should then connect to React DevTools.
|
|
|
|
## Sandboxing
|
|
|
|
> TBD
|
|
|
|
## Manual Publish
|
|
|
|
We publish an artifact for each commit to our internal registry. But if you need to manually cut a local build, then run the following commands:
|
|
|
|
```
|
|
npm run clean
|
|
npm install
|
|
npm run auth
|
|
npm run prerelease:dev
|
|
npm publish --workspaces
|
|
```
|