qwen-code/AGENTS.md
易良 202be6ec7d
Some checks are pending
Qwen Code CI / Lint (push) Waiting to run
Qwen Code CI / Test (push) Blocked by required conditions
Qwen Code CI / Test-1 (push) Blocked by required conditions
Qwen Code CI / Test-2 (push) Blocked by required conditions
Qwen Code CI / Test-3 (push) Blocked by required conditions
Qwen Code CI / Test-4 (push) Blocked by required conditions
Qwen Code CI / Test-5 (push) Blocked by required conditions
Qwen Code CI / Test-6 (push) Blocked by required conditions
Qwen Code CI / Test-7 (push) Blocked by required conditions
Qwen Code CI / Test-8 (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
feat(vscode): expose /skills as slash command with secondary picker (#2548)
* feat(vscode): expose /skills as slash command with secondary picker

Add a secondary completion picker for the /skills slash command in the
VSCode IDE companion, allowing users to browse and select skills from
a dropdown before sending.

Changes:
- CLI: add 'skills' to ALLOWED_BUILTIN_COMMANDS_NON_INTERACTIVE whitelist
- CLI: send available_skills_update via ACP with skill names/descriptions
- Extension: handle available_skills_update in session update handler
- Webview: implement secondary picker that triggers after selecting /skills
- Webview: allow spaces in completion trigger for /skills sub-queries

Closes #1562

Made-with: Cursor

* feat(vscode-ide-companion): embed skills in commands update metadata

- Move available skills from separate session update to _meta field of
  available_commands_update for more efficient delivery
- Simplify skill data to just skill names (string array)
- Add skillsCompletion utility for secondary picker logic
- Cache available skills in WebViewProvider for replay on webview ready
- Update all related types and handlers to support the new structure

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* refactor(vscode-ide-companion): simplify skills picker flow

* refactor(vscode-ide-companion): extract skills completion utils to shared module

Move `isSkillsSecondaryQuery`, `shouldOpenSkillsSecondaryPicker`, and
`SKILL_ITEM_ID_PREFIX` from App.tsx and useCompletionTrigger.ts into a
shared `completionUtils.ts` file to eliminate duplication.

* fix(vscode-ide-companion): restore skills picker state on reload

Cache and replay available skills when the webview becomes ready again.

Clear stale skills when commands metadata does not include availableSkills.

* fix(vscode-ide-companion): replay slash commands after webview reload

Cache available commands in the webview provider.

Replay them on webviewReady so slash command state survives reloads.

* fix(vscode-ide-companion): import AvailableCommand from ACP SDK

* fix(vscode-ide-companion): fallback /skills to direct command

* test(vscode-ide-companion): cover skills secondary picker flow

* test(vscode-ide-companion): guard App mock initialization

* fix(vscode-ide-companion): remove duplicate AvailableCommand import

The auto-merge introduced a duplicate AvailableCommand in the
@agentclientprotocol/sdk import block, causing TS2300.

* fix(vscode-ide-companion): remove duplicate availableCommands replay in handleWebviewReady

The handleWebviewReady method was sending cachedAvailableCommands twice
on every webview-ready handshake, causing an unnecessary extra state
update in the webview.

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-24 23:28:53 +08:00

176 lines
6.1 KiB
Markdown

# AGENTS.md
This file provides guidance to Qwen Code when working with code in this
repository.
## Common Commands
### Building
```bash
npm install # Install all dependencies
npm run build # Build all packages (TypeScript compilation + asset copying)
npm run build:all # Build everything including sandbox container
npm run bundle # Bundle dist/ into a single dist/cli.js via esbuild
# (requires build first)
```
`npm run build` compiles TS into each package's `dist/`. `npm run bundle`
takes that output and produces a single `dist/cli.js` via esbuild. Bundle
requires build to have run first.
### Development
```bash
npm run dev # Run CLI directly from TypeScript source (no build needed)
```
Runs the CLI via `tsx` with `DEV=true`. Changes to `packages/core` or
`packages/cli` are reflected immediately without rebuilding.
### Unit Testing
Tests must be run from within the specific package directory, not the project
root.
**Run individual test files** (always preferred):
```bash
cd packages/core && npx vitest run src/path/to/file.test.ts
cd packages/cli && npx vitest run src/path/to/file.test.ts
```
**Update snapshots:**
```bash
cd packages/cli && npx vitest run src/path/to/file.test.ts --update
```
**Avoid:**
- `npm run test -- --filter=...` — does NOT filter; runs the entire suite
- `npx vitest` from the project root — fails due to package-specific vitest
configs
- Running the whole test suite unless necessary (e.g., final PR verification)
**Test gotchas:**
- In CLI tests, use `vi.hoisted()` for mocks consumed by `vi.mock()` — the
mock factory runs at module load time, before test execution.
### Integration Testing
Build the bundle first: `npm run build && npm run bundle`
Run from the project root using the dedicated npm scripts:
```bash
npm run test:integration:cli:sandbox:none
npm run test:integration:interactive:sandbox:none
```
Or combined in one command:
```bash
cd integration-tests && \
cross-env QWEN_SANDBOX=false npx vitest run cli interactive
```
**Gotcha:** In interactive tests, always call `session.idle()` between sends —
ANSI output streams asynchronously.
### Linting & Formatting
```bash
npm run lint # ESLint check
npm run lint:fix # Auto-fix lint issues
npm run format # Prettier formatting
npm run typecheck # TypeScript type checking
npm run preflight # Full check: clean → install → format → lint → build
# → typecheck → test
```
## Code Conventions
- **Module system**: ESM throughout (`"type": "module"` in all packages)
- **TypeScript**: Strict mode with `noImplicitAny`, `strictNullChecks`,
`noUnusedLocals`, `verbatimModuleSyntax`
- **Formatting**: Prettier — single quotes, semicolons, trailing commas,
2-space indent, 80-char width
- **Linting**: No `any` types, consistent type imports, no relative imports
between packages
- **Tests**: Collocated with source (`file.test.ts` next to `file.ts`),
vitest framework
- **Commits**: Conventional Commits (e.g., `feat(cli): Add --json flag`)
- **Node.js**: Development requires `~20.19.0`; production requires `>=20`
## Development Guidelines
### General workflow
1. **Design doc for non-trivial work** — write one in `.qwen/design/` if the
change touches multiple files or involves design decisions. Skip for small
bugfixes.
2. **Test plan for behavioral changes** — write an E2E test plan in
`.qwen/e2e-tests/` when the change affects user-observable behavior. Dry-run
against the global `qwen` CLI first to confirm the baseline.
3. **Build + typecheck before declaring done**:
`npm run build && npm run typecheck`.
4. **Code review** — run `/review` when available. Triage each comment:
valid / false positive / overthinking.
### Feature development
Use the `/feat-dev` skill for the full workflow: investigate, design, test plan,
dry-run, implement, verify, code review, and iterate.
### Bugfix
Use the `/bugfix` skill for the reproduce-first workflow: reproduce, fix,
verify, test, and code review.
## GitHub Operations
Use the `gh` CLI for all GitHub-related operations — issues, pull requests,
comments, CI checks, releases, and API calls. Prefer `gh issue view`,
`gh pr view`, `gh pr checks`, `gh run view`, `gh api`, etc. over web fetches
or manual REST calls.
## Testing, Debugging, and Bug Fixes
- **Bug reproduction & verification**: spawn the `test-engineer` agent. It
reads code and docs to understand the bug, then reproduces it via E2E testing
(or a test-script fallback). It also handles post-fix verification. It cannot
edit source code — only observe and report.
- **Hard bugs**: use the `structured-debugging` skill when debugging requires
more than a quick glance — especially when the first attempt at a fix didn't
work or the behavior seems impossible.
- **E2E testing**: the `e2e-testing` skill covers headless mode, interactive
(tmux) mode, MCP server testing, and API traffic inspection. The
`test-engineer` agent invokes this skill internally — you typically don't
need to use it directly.
## Submitting PRs
When creating a PR, follow the template at `.github/pull_request_template.md`.
After the PR is submitted, post a separate comment with the E2E test report if
applicable.
- **PR description**: explain the motivation and changes in prose. Avoid
referencing file names or function names.
- **Reviewer Test Plan**: describe behaviors a reviewer should verify and what
to expect, not scripted test commands.
## Project Directories
Project artifacts live under `.qwen/`:
| Directory | Purpose |
| ----------------------- | ------------------------------------ |
| `.qwen/design/` | Design docs for planned features |
| `.qwen/e2e-tests/` | E2E test plans and results |
| `.qwen/issues/` | Issue drafts before filing on GitHub |
| `.qwen/pr-drafts/` | PR drafts before submitting |
| `.qwen/pr-reviews/` | PR review notes |
| `.qwen/investigations/` | Structured debugging journals |
| `.qwen/scripts/` | Utility scripts |