@mmmbuto/qwen-code-termux 0.12.0-termux → 0.14.0-termux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +188 -55
  2. package/bundled/loop/SKILL.md +61 -0
  3. package/bundled/qc-helper/SKILL.md +151 -0
  4. package/bundled/qc-helper/docs/_meta.ts +30 -0
  5. package/bundled/qc-helper/docs/common-workflow.md +571 -0
  6. package/bundled/qc-helper/docs/configuration/_meta.ts +10 -0
  7. package/bundled/qc-helper/docs/configuration/auth.md +366 -0
  8. package/bundled/qc-helper/docs/configuration/memory.md +0 -0
  9. package/bundled/qc-helper/docs/configuration/model-providers.md +542 -0
  10. package/bundled/qc-helper/docs/configuration/qwen-ignore.md +55 -0
  11. package/bundled/qc-helper/docs/configuration/settings.md +655 -0
  12. package/bundled/qc-helper/docs/configuration/themes.md +160 -0
  13. package/bundled/qc-helper/docs/configuration/trusted-folders.md +61 -0
  14. package/bundled/qc-helper/docs/configuration.md +73 -0
  15. package/bundled/qc-helper/docs/extension/_meta.ts +9 -0
  16. package/bundled/qc-helper/docs/extension/extension-releasing.md +204 -0
  17. package/bundled/qc-helper/docs/extension/getting-started-extensions.md +299 -0
  18. package/bundled/qc-helper/docs/extension/introduction.md +338 -0
  19. package/bundled/qc-helper/docs/features/_meta.ts +19 -0
  20. package/bundled/qc-helper/docs/features/approval-mode.md +263 -0
  21. package/bundled/qc-helper/docs/features/arena.md +218 -0
  22. package/bundled/qc-helper/docs/features/channels/_meta.ts +7 -0
  23. package/bundled/qc-helper/docs/features/channels/dingtalk.md +134 -0
  24. package/bundled/qc-helper/docs/features/channels/overview.md +336 -0
  25. package/bundled/qc-helper/docs/features/channels/plugins.md +87 -0
  26. package/bundled/qc-helper/docs/features/channels/telegram.md +120 -0
  27. package/bundled/qc-helper/docs/features/channels/weixin.md +106 -0
  28. package/bundled/qc-helper/docs/features/checkpointing.md +77 -0
  29. package/bundled/qc-helper/docs/features/commands.md +312 -0
  30. package/bundled/qc-helper/docs/features/headless.md +318 -0
  31. package/bundled/qc-helper/docs/features/hooks.md +720 -0
  32. package/bundled/qc-helper/docs/features/language.md +139 -0
  33. package/bundled/qc-helper/docs/features/lsp.md +417 -0
  34. package/bundled/qc-helper/docs/features/mcp.md +281 -0
  35. package/bundled/qc-helper/docs/features/sandbox.md +241 -0
  36. package/bundled/qc-helper/docs/features/scheduled-tasks.md +139 -0
  37. package/bundled/qc-helper/docs/features/skills.md +289 -0
  38. package/bundled/qc-helper/docs/features/sub-agents.md +515 -0
  39. package/bundled/qc-helper/docs/features/token-caching.md +29 -0
  40. package/bundled/qc-helper/docs/ide-integration/_meta.ts +4 -0
  41. package/bundled/qc-helper/docs/ide-integration/ide-companion-spec.md +182 -0
  42. package/bundled/qc-helper/docs/ide-integration/ide-integration.md +144 -0
  43. package/bundled/qc-helper/docs/integration-github-action.md +241 -0
  44. package/bundled/qc-helper/docs/integration-jetbrains.md +81 -0
  45. package/bundled/qc-helper/docs/integration-vscode.md +39 -0
  46. package/bundled/qc-helper/docs/integration-zed.md +72 -0
  47. package/bundled/qc-helper/docs/overview.md +64 -0
  48. package/bundled/qc-helper/docs/quickstart.md +273 -0
  49. package/bundled/qc-helper/docs/reference/_meta.ts +3 -0
  50. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +72 -0
  51. package/bundled/qc-helper/docs/support/Uninstall.md +42 -0
  52. package/bundled/qc-helper/docs/support/_meta.ts +6 -0
  53. package/bundled/qc-helper/docs/support/tos-privacy.md +112 -0
  54. package/bundled/qc-helper/docs/support/troubleshooting.md +123 -0
  55. package/bundled/review/SKILL.md +261 -0
  56. package/cli.js +298314 -244746
  57. package/locales/de.js +358 -7
  58. package/locales/en.js +347 -7
  59. package/locales/ja.js +347 -7
  60. package/locales/pt.js +353 -7
  61. package/locales/ru.js +348 -7
  62. package/locales/zh.js +333 -7
  63. package/package.json +12 -7
  64. package/sandbox-macos-permissive-open.sb +3 -1
  65. package/vendor/tree-sitter/tree-sitter-bash.wasm +0 -0
  66. package/vendor/tree-sitter/tree-sitter.wasm +0 -0
  67. package/CHANGELOG.md +0 -77
@@ -0,0 +1,112 @@
1
+ # Qwen Code: Terms of Service and Privacy Notice
2
+
3
+ Qwen Code is an open-source AI coding assistant tool maintained by the Qwen Code team. This document outlines the terms of service and privacy policies that apply when using Qwen Code's authentication methods and AI model services.
4
+
5
+ ## How to determine your authentication method
6
+
7
+ Qwen Code supports three authentication methods to access AI models. Your authentication method determines which terms of service and privacy policies apply to your usage:
8
+
9
+ 1. **Qwen OAuth** — Log in with your qwen.ai account (free daily quota)
10
+ 2. **Alibaba Cloud Coding Plan** — Use an API key from Alibaba Cloud
11
+ 3. **API Key** — Bring your own API key
12
+
13
+ For each authentication method, different Terms of Service and Privacy Notices may apply depending on the underlying service provider.
14
+
15
+ | Authentication Method | Provider | Terms of Service | Privacy Notice |
16
+ | :------------------------ | :---------------- | :----------------------------------------------------------------- | :----------------------------------------------------------------- |
17
+ | Qwen OAuth | Qwen AI | [Qwen Terms of Service](https://qwen.ai/termsservice) | [Qwen Privacy Policy](https://qwen.ai/privacypolicy) |
18
+ | Alibaba Cloud Coding Plan | Alibaba Cloud | See [details below](#2-if-you-are-using-alibaba-cloud-coding-plan) | See [details below](#2-if-you-are-using-alibaba-cloud-coding-plan) |
19
+ | API Key | Various Providers | Depends on your chosen API provider (OpenAI, Anthropic, etc.) | Depends on your chosen API provider |
20
+
21
+ ## 1. If you are using Qwen OAuth Authentication
22
+
23
+ When you authenticate using your qwen.ai account, these Terms of Service and Privacy Notice documents apply:
24
+
25
+ - **Terms of Service:** Your use is governed by the [Qwen Terms of Service](https://qwen.ai/termsservice).
26
+ - **Privacy Notice:** The collection and use of your data is described in the [Qwen Privacy Policy](https://qwen.ai/privacypolicy).
27
+
28
+ For details about authentication setup, quotas, and supported features, see [Authentication Setup](../configuration/settings).
29
+
30
+ ## 2. If you are using Alibaba Cloud Coding Plan
31
+
32
+ When you authenticate using an API key from Alibaba Cloud, the applicable Terms of Service and Privacy Notice from Alibaba Cloud apply.
33
+
34
+ Alibaba Cloud Coding Plan is available in two regions:
35
+
36
+ - **阿里云百炼 (aliyun.com)** — [bailian.console.aliyun.com](https://bailian.console.aliyun.com)
37
+ - **Alibaba Cloud (alibabacloud.com)** — [bailian.console.alibabacloud.com](https://bailian.console.alibabacloud.com)
38
+
39
+ > [!important]
40
+ >
41
+ > When using Alibaba Cloud Coding Plan, you are subject to Alibaba Cloud's terms and privacy policies. Please review their documentation for specific details about data usage, retention, and privacy practices.
42
+
43
+ ## 3. If you are using your own API Key
44
+
45
+ When you authenticate using API keys from other providers, the applicable Terms of Service and Privacy Notice depend on your chosen provider.
46
+
47
+ > [!important]
48
+ >
49
+ > When using your own API key, you are subject to the terms and privacy policies of your chosen API provider, not Qwen Code's terms. Please review your provider's documentation for specific details about data usage, retention, and privacy practices.
50
+
51
+ Qwen Code supports various OpenAI-compatible providers. Please refer to your specific provider's terms of service and privacy policy for detailed information.
52
+
53
+ ## Usage Statistics and Telemetry
54
+
55
+ Qwen Code may collect anonymous usage statistics and [telemetry](../../developers/development/telemetry) data to improve the user experience and product quality. This data collection is optional and can be controlled through configuration settings.
56
+
57
+ ### What Data is Collected
58
+
59
+ When enabled, Qwen Code may collect:
60
+
61
+ - Anonymous usage statistics (commands run, performance metrics)
62
+ - Error reports and crash data
63
+ - Feature usage patterns
64
+
65
+ ### Data Collection by Authentication Method
66
+
67
+ - **Qwen OAuth:** Usage statistics are governed by Qwen's privacy policy. You can opt-out through Qwen Code's configuration settings.
68
+ - **Alibaba Cloud Coding Plan:** Usage statistics are governed by Alibaba Cloud's privacy policy. You can opt-out through Qwen Code's configuration settings.
69
+ - **API Key:** No additional data is collected by Qwen Code beyond what your chosen API provider collects.
70
+
71
+ ## Frequently Asked Questions (FAQ)
72
+
73
+ ### 1. Is my code, including prompts and answers, used to train AI models?
74
+
75
+ Whether your code, including prompts and answers, is used to train AI models depends on your authentication method and the specific AI service provider you use:
76
+
77
+ - **Qwen OAuth**: Data usage is governed by [Qwen's Privacy Policy](https://qwen.ai/privacy). Please refer to their policy for specific details about data collection and model training practices.
78
+
79
+ - **Alibaba Cloud Coding Plan**: Data usage is governed by Alibaba Cloud's privacy policy. Please refer to their policy for specific details about data collection and model training practices.
80
+
81
+ - **API Key**: Data usage depends entirely on your chosen API provider. Each provider has their own data usage policies. Please review the privacy policy and terms of service of your specific provider.
82
+
83
+ **Important**: Qwen Code itself does not use your prompts, code, or responses for model training. Any data usage for training purposes would be governed by the policies of the AI service provider you authenticate with.
84
+
85
+ ### 2. What are Usage Statistics and what does the opt-out control?
86
+
87
+ The **Usage Statistics** setting controls optional data collection by Qwen Code for improving the user experience and product quality.
88
+
89
+ When enabled, Qwen Code may collect:
90
+
91
+ - Anonymous telemetry (commands run, performance metrics, feature usage)
92
+ - Error reports and crash data
93
+ - General usage patterns
94
+
95
+ **What is NOT collected by Qwen Code:**
96
+
97
+ - Your code content
98
+ - Prompts sent to AI models
99
+ - Responses from AI models
100
+ - Personal information
101
+
102
+ The Usage Statistics setting only controls data collection by Qwen Code itself. It does not affect what data your chosen AI service provider (Qwen, OpenAI, etc.) may collect according to their own privacy policies.
103
+
104
+ ### 3. How do I switch between authentication methods?
105
+
106
+ You can switch between Qwen OAuth, Alibaba Cloud Coding Plan, and your own API key at any time:
107
+
108
+ 1. **During startup**: Choose your preferred authentication method when prompted
109
+ 2. **Within the CLI**: Use the `/auth` command to reconfigure your authentication method
110
+ 3. **Environment variables**: Set up `.env` files for automatic API key authentication
111
+
112
+ For detailed instructions, see the [Authentication Setup](../configuration/settings#environment-variables-for-api-access) documentation.
@@ -0,0 +1,123 @@
1
+ # Troubleshooting
2
+
3
+ This guide provides solutions to common issues and debugging tips, including topics on:
4
+
5
+ - Authentication or login errors
6
+ - Frequently asked questions (FAQs)
7
+ - Debugging tips
8
+ - Existing GitHub Issues similar to yours or creating new Issues
9
+
10
+ ## Authentication or login errors
11
+
12
+ - **Error: `UNABLE_TO_GET_ISSUER_CERT_LOCALLY`, `UNABLE_TO_VERIFY_LEAF_SIGNATURE`, or `unable to get local issuer certificate`**
13
+ - **Cause:** You may be on a corporate network with a firewall that intercepts and inspects SSL/TLS traffic. This often requires a custom root CA certificate to be trusted by Node.js.
14
+ - **Solution:** Set the `NODE_EXTRA_CA_CERTS` environment variable to the absolute path of your corporate root CA certificate file.
15
+ - Example: `export NODE_EXTRA_CA_CERTS=/path/to/your/corporate-ca.crt`
16
+
17
+ - **Error: `Device authorization flow failed: fetch failed`**
18
+ - **Cause:** Node.js could not reach Qwen OAuth endpoints (often a proxy or SSL/TLS trust issue). When available, Qwen Code will also print the underlying error cause (for example: `UNABLE_TO_VERIFY_LEAF_SIGNATURE`).
19
+ - **Solution:**
20
+ - Confirm you can access `https://chat.qwen.ai` from the same machine/network.
21
+ - If you are behind a proxy, set it via `qwen --proxy <url>` (or the `proxy` setting in `settings.json`).
22
+ - If your network uses a corporate TLS inspection CA, set `NODE_EXTRA_CA_CERTS` as described above.
23
+
24
+ - **Issue: Unable to display UI after authentication failure**
25
+ - **Cause:** If authentication fails after selecting an authentication type, the `security.auth.selectedType` setting may be persisted in `settings.json`. On restart, the CLI may get stuck trying to authenticate with the failed auth type and fail to display the UI.
26
+ - **Solution:** Clear the `security.auth.selectedType` configuration item in your `settings.json` file:
27
+ - Open `~/.qwen/settings.json` (or `./.qwen/settings.json` for project-specific settings)
28
+ - Remove the `security.auth.selectedType` field
29
+ - Restart the CLI to allow it to prompt for authentication again
30
+
31
+ ## Frequently asked questions (FAQs)
32
+
33
+ - **Q: How do I update Qwen Code to the latest version?**
34
+ - A: If you installed it globally via `npm`, update it using the command `npm install -g @qwen-code/qwen-code@latest`. If you compiled it from source, pull the latest changes from the repository, and then rebuild using the command `npm run build`.
35
+
36
+ - **Q: Where are the Qwen Code configuration or settings files stored?**
37
+ - A: The Qwen Code configuration is stored in two `settings.json` files:
38
+ 1. In your home directory: `~/.qwen/settings.json`.
39
+ 2. In your project's root directory: `./.qwen/settings.json`.
40
+
41
+ Refer to [Qwen Code Configuration](../configuration/settings) for more details.
42
+
43
+ - **Q: Why don't I see cached token counts in my stats output?**
44
+ - A: Cached token information is only displayed when cached tokens are being used. This feature is available for API key users (Qwen API key or Google Cloud Vertex AI) but not for OAuth users (such as Google Personal/Enterprise accounts like Google Gmail or Google Workspace, respectively). This is because the Qwen Code Assist API does not support cached content creation. You can still view your total token usage using the `/stats` command.
45
+
46
+ ## Common error messages and solutions
47
+
48
+ - **Error: `EADDRINUSE` (Address already in use) when starting an MCP server.**
49
+ - **Cause:** Another process is already using the port that the MCP server is trying to bind to.
50
+ - **Solution:**
51
+ Either stop the other process that is using the port or configure the MCP server to use a different port.
52
+
53
+ - **Error: Command not found (when attempting to run Qwen Code with `qwen`).**
54
+ - **Cause:** The CLI is not correctly installed or it is not in your system's `PATH`.
55
+ - **Solution:**
56
+ The update depends on how you installed Qwen Code:
57
+ - If you installed `qwen` globally, check that your `npm` global binary directory is in your `PATH`. You can update using the command `npm install -g @qwen-code/qwen-code@latest`.
58
+ - If you are running `qwen` from source, ensure you are using the correct command to invoke it (e.g. `node packages/cli/dist/index.js ...`). To update, pull the latest changes from the repository, and then rebuild using the command `npm run build`.
59
+
60
+ - **Error: `MODULE_NOT_FOUND` or import errors.**
61
+ - **Cause:** Dependencies are not installed correctly, or the project hasn't been built.
62
+ - **Solution:**
63
+ 1. Run `npm install` to ensure all dependencies are present.
64
+ 2. Run `npm run build` to compile the project.
65
+ 3. Verify that the build completed successfully with `npm run start`.
66
+
67
+ - **Error: "Operation not permitted", "Permission denied", or similar.**
68
+ - **Cause:** When sandboxing is enabled, Qwen Code may attempt operations that are restricted by your sandbox configuration, such as writing outside the project directory or system temp directory.
69
+ - **Solution:** Refer to the [Configuration: Sandboxing](../features/sandbox) documentation for more information, including how to customize your sandbox configuration.
70
+
71
+ - **Qwen Code is not running in interactive mode in "CI" environments**
72
+ - **Issue:** Qwen Code does not enter interactive mode (no prompt appears) if an environment variable starting with `CI_` (e.g. `CI_TOKEN`) is set. This is because the `is-in-ci` package, used by the underlying UI framework, detects these variables and assumes a non-interactive CI environment.
73
+ - **Cause:** The `is-in-ci` package checks for the presence of `CI`, `CONTINUOUS_INTEGRATION`, or any environment variable with a `CI_` prefix. When any of these are found, it signals that the environment is non-interactive, which prevents the CLI from starting in its interactive mode.
74
+ - **Solution:** If the `CI_` prefixed variable is not needed for the CLI to function, you can temporarily unset it for the command. e.g. `env -u CI_TOKEN qwen`
75
+
76
+ - **DEBUG mode not working from project .env file**
77
+ - **Issue:** Setting `DEBUG=true` in a project's `.env` file doesn't enable debug mode for the CLI.
78
+ - **Cause:** The `DEBUG` and `DEBUG_MODE` variables are automatically excluded from project `.env` files to prevent interference with the CLI behavior.
79
+ - **Solution:** Use a `.qwen/.env` file instead, or configure the `advanced.excludedEnvVars` setting in your `settings.json` to exclude fewer variables.
80
+
81
+ ## IDE Companion not connecting
82
+
83
+ - Ensure VS Code has a single workspace folder open.
84
+ - Restart the integrated terminal after installing the extension so it inherits:
85
+ - `QWEN_CODE_IDE_WORKSPACE_PATH`
86
+ - `QWEN_CODE_IDE_SERVER_PORT`
87
+ - If running in a container, verify `host.docker.internal` resolves. Otherwise, map the host appropriately.
88
+ - Reinstall the companion with `/ide install` and use “Qwen Code: Run” in the Command Palette to verify it launches.
89
+
90
+ ## Exit Codes
91
+
92
+ The Qwen Code uses specific exit codes to indicate the reason for termination. This is especially useful for scripting and automation.
93
+
94
+ | Exit Code | Error Type | Description |
95
+ | --------- | -------------------------- | --------------------------------------------------------------------------------------------------- |
96
+ | 41 | `FatalAuthenticationError` | An error occurred during the authentication process. |
97
+ | 42 | `FatalInputError` | Invalid or missing input was provided to the CLI. (non-interactive mode only) |
98
+ | 44 | `FatalSandboxError` | An error occurred with the sandboxing environment (e.g. Docker, Podman, or Seatbelt). |
99
+ | 52 | `FatalConfigError` | A configuration file (`settings.json`) is invalid or contains errors. |
100
+ | 53 | `FatalTurnLimitedError` | The maximum number of conversational turns for the session was reached. (non-interactive mode only) |
101
+
102
+ ## Debugging Tips
103
+
104
+ - **CLI debugging:**
105
+ - Use the `--verbose` flag (if available) with CLI commands for more detailed output.
106
+ - Check the CLI logs, often found in a user-specific configuration or cache directory.
107
+
108
+ - **Core debugging:**
109
+ - Check the server console output for error messages or stack traces.
110
+ - Increase log verbosity if configurable.
111
+ - Use Node.js debugging tools (e.g. `node --inspect`) if you need to step through server-side code.
112
+
113
+ - **Tool issues:**
114
+ - If a specific tool is failing, try to isolate the issue by running the simplest possible version of the command or operation the tool performs.
115
+ - For `run_shell_command`, check that the command works directly in your shell first.
116
+ - For _file system tools_, verify that paths are correct and check the permissions.
117
+
118
+ - **Pre-flight checks:**
119
+ - Always run `npm run preflight` before committing code. This can catch many common issues related to formatting, linting, and type errors.
120
+
121
+ ## Existing GitHub Issues similar to yours or creating new Issues
122
+
123
+ If you encounter an issue that was not covered here in this _Troubleshooting guide_, consider searching the Qwen Code [Issue tracker on GitHub](https://github.com/QwenLM/qwen-code/issues). If you can't find an issue similar to yours, consider creating a new GitHub Issue with a detailed description. Pull requests are also welcome!
@@ -0,0 +1,261 @@
1
+ ---
2
+ name: review
3
+ description: Review changed code for correctness, security, code quality, and performance. Use when the user asks to review code changes, a PR, or specific files. Invoke with `/review`, `/review <pr-number>`, `/review <file-path>`, or `/review <pr-number> --comment` to post inline comments on the PR.
4
+ allowedTools:
5
+ - task
6
+ - run_shell_command
7
+ - grep_search
8
+ - read_file
9
+ - write_file
10
+ - glob
11
+ ---
12
+
13
+ # Code Review
14
+
15
+ You are an expert code reviewer. Your job is to review code changes and provide actionable feedback.
16
+
17
+ ## Step 1: Determine what to review
18
+
19
+ Your goal here is to understand the scope of changes so you can dispatch agents effectively in Step 2.
20
+
21
+ First, parse the `--comment` flag: split the arguments by whitespace, and if any token is exactly `--comment` (not a substring match — ignore tokens like `--commentary`), set the comment flag and remove that token from the argument list. If `--comment` is set but the review target is not a PR, warn the user: "Warning: `--comment` flag is ignored because the review target is not a PR." and continue without it.
22
+
23
+ Based on the remaining arguments:
24
+
25
+ - **No arguments**: Review local uncommitted changes
26
+ - Run `git diff` and `git diff --staged` to get all changes
27
+ - If both diffs are empty, inform the user there are no changes to review and stop here — do not proceed to the review agents
28
+
29
+ - **PR number or URL** (e.g., `123` or `https://github.com/.../pull/123`):
30
+ - Save the current branch name, stash any local changes (`git stash --include-untracked`), then `gh pr checkout <number>`
31
+ - Run `gh pr view <number>` and save the output (title, description, base branch, etc.) to a temp file (e.g., `/tmp/pr-review-context.md`) so agents can read it without you repeating it in each prompt
32
+ - Note the base branch (e.g., `main`) — agents will use `git diff <base>...HEAD` to get the diff and can read files directly
33
+
34
+ - **File path** (e.g., `src/foo.ts`):
35
+ - Run `git diff HEAD -- <file>` to get recent changes
36
+ - If no diff, read the file and review its current state
37
+
38
+ ## Step 2: Parallel multi-dimensional review
39
+
40
+ Launch **four parallel review agents** to analyze the changes from different angles. Each agent should focus exclusively on its dimension.
41
+
42
+ **IMPORTANT**: Do NOT paste the full diff into each agent's prompt — this duplicates it 4x. Instead, give each agent the command to obtain the diff, a concise summary of what the changes are about, and its review focus. Each agent can read files and search the codebase on its own.
43
+
44
+ Apply the **Exclusion Criteria** (defined at the end of this document) — do NOT flag anything that matches those criteria.
45
+
46
+ Each agent must return findings in this structured format (one per issue):
47
+
48
+ ```
49
+ - **File:** <file path>:<line number or range>
50
+ - **Issue:** <clear description of the problem>
51
+ - **Impact:** <why it matters>
52
+ - **Suggested fix:** <concrete code suggestion when possible, or "N/A">
53
+ - **Severity:** Critical | Suggestion | Nice to have
54
+ ```
55
+
56
+ If an agent finds no issues in its dimension, it should explicitly return "No issues found."
57
+
58
+ ### Agent 1: Correctness & Security
59
+
60
+ Focus areas:
61
+
62
+ - Logic errors and edge cases
63
+ - Null/undefined handling
64
+ - Race conditions and concurrency issues
65
+ - Security vulnerabilities (injection, XSS, SSRF, path traversal, etc.)
66
+ - Type safety issues
67
+ - Error handling gaps
68
+
69
+ ### Agent 2: Code Quality
70
+
71
+ Focus areas:
72
+
73
+ - Code style consistency with the surrounding codebase
74
+ - Naming conventions (variables, functions, classes)
75
+ - Code duplication and opportunities for reuse
76
+ - Over-engineering or unnecessary abstraction
77
+ - Missing or misleading comments
78
+ - Dead code
79
+
80
+ ### Agent 3: Performance & Efficiency
81
+
82
+ Focus areas:
83
+
84
+ - Performance bottlenecks (N+1 queries, unnecessary loops, etc.)
85
+ - Memory leaks or excessive memory usage
86
+ - Unnecessary re-renders (for UI code)
87
+ - Inefficient algorithms or data structures
88
+ - Missing caching opportunities
89
+ - Bundle size impact
90
+
91
+ ### Agent 4: Undirected Audit
92
+
93
+ No preset dimension. Review the code with a completely fresh perspective to catch issues the other three agents may miss.
94
+ Focus areas:
95
+
96
+ - Business logic soundness and correctness of assumptions
97
+ - Boundary interactions between modules or services
98
+ - Implicit assumptions that may break under different conditions
99
+ - Unexpected side effects or hidden coupling
100
+ - Anything else that looks off — trust your instincts
101
+
102
+ ## Step 2.5: Deduplicate and verify
103
+
104
+ ### Deduplication
105
+
106
+ Before verification, merge findings that refer to the same issue (same file, same line range, same root cause) even if reported by different agents. Keep the most detailed description and note which agents flagged it.
107
+
108
+ ### Independent verification
109
+
110
+ For each **unique** finding, launch an **independent verification agent**. Run verification agents in parallel, but if there are more than 10 unique findings, batch them in groups of 10 to avoid resource exhaustion.
111
+
112
+ Each verification agent receives:
113
+
114
+ - The finding description (what's wrong, file, line)
115
+ - The command to obtain the diff (as determined in Step 1)
116
+ - Access to read files and search the codebase
117
+
118
+ Each verification agent must **independently** (without seeing other agents' findings):
119
+
120
+ 1. Read the actual code at the referenced file and line
121
+ 2. Check surrounding context — callers, type definitions, tests, related modules
122
+ 3. Verify the issue is not a false positive — reject if it matches any item in the **Exclusion Criteria**
123
+ 4. Return a verdict:
124
+ - **confirmed** — with severity: Critical, Suggestion, or Nice to have
125
+ - **rejected** — with a one-line reason why it's not a real issue
126
+
127
+ **When uncertain, lean toward rejecting.** The goal is high signal, low noise — it's better to miss a minor suggestion than to report a false positive.
128
+
129
+ **After all verification agents complete:** remove all rejected findings. Only confirmed findings proceed to Step 3.
130
+
131
+ ## Step 3: Present findings
132
+
133
+ Present the confirmed findings from Step 2.5 as a single, well-organized review. Use this format:
134
+
135
+ ### Summary
136
+
137
+ A 1-2 sentence overview of the changes and overall assessment. Include verification stats: "X findings reported, Y confirmed after independent verification."
138
+
139
+ ### Findings
140
+
141
+ Use severity levels:
142
+
143
+ - **Critical** — Must fix before merging. Bugs, security issues, data loss risks.
144
+ - **Suggestion** — Recommended improvement. Better patterns, clearer code, potential issues.
145
+ - **Nice to have** — Optional optimization. Minor style tweaks, small performance gains.
146
+
147
+ For each finding, include:
148
+
149
+ 1. **File and line reference** (e.g., `src/foo.ts:42`)
150
+ 2. **What's wrong** — Clear description of the issue
151
+ 3. **Why it matters** — Impact if not addressed
152
+ 4. **Suggested fix** — Concrete code suggestion when possible
153
+
154
+ ### Verdict
155
+
156
+ One of:
157
+
158
+ - **Approve** — No critical issues, good to merge
159
+ - **Request changes** — Has critical issues that need fixing
160
+ - **Comment** — Has suggestions but no blockers
161
+
162
+ ## Step 4: Post PR inline comments (only if `--comment` flag was set)
163
+
164
+ Skip this step if `--comment` was not specified or the review target is not a PR.
165
+
166
+ First, get the repository owner/repo and the PR's HEAD commit SHA:
167
+
168
+ ```bash
169
+ gh repo view --json owner,name --jq '"\(.owner.login)/\(.name)"'
170
+ gh pr view {pr_number} --json headRefOid --jq '.headRefOid'
171
+ ```
172
+
173
+ **Important:** Use `gh pr view --json headRefOid` instead of `git rev-parse HEAD` — the local branch may be behind the remote, and the GitHub API requires the exact remote HEAD SHA. If either command fails, inform the user and skip Step 4.
174
+
175
+ Then, for each confirmed finding, post an **inline comment** on the specific file and line using `gh api`:
176
+
177
+ **Shell safety:** Review content may contain double quotes, `$VAR`, backticks, or other shell-sensitive characters. Do NOT interpolate review text directly into shell arguments. Instead, use a **two-step process**: write the body to a temp file using the `write_file` tool (which bypasses shell interpretation entirely), then reference the file with `-F body=@file` in the shell command.
178
+
179
+ ```
180
+ # Step A: Use write_file tool to create /tmp/pr-comment.txt with content:
181
+ **[{severity}]** {issue description}
182
+
183
+ {suggested fix}
184
+ ```
185
+
186
+ ```bash
187
+ # Step B: Post single-line comment referencing the file:
188
+ gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
189
+ -F body=@/tmp/pr-comment.txt \
190
+ -f commit_id="{commit_sha}" \
191
+ -f path="{file_path}" \
192
+ -F line={line_number} \
193
+ -f side="RIGHT"
194
+
195
+ # For multi-line findings (e.g., line range 42-50), add start_line and start_side:
196
+ gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
197
+ -F body=@/tmp/pr-comment.txt \
198
+ -f commit_id="{commit_sha}" \
199
+ -f path="{file_path}" \
200
+ -F start_line={start_line} \
201
+ -F line={end_line} \
202
+ -f start_side="RIGHT" \
203
+ -f side="RIGHT"
204
+ ```
205
+
206
+ Repeat Steps A-B for each finding, overwriting the temp file each time. Clean up the temp file in Step 5.
207
+
208
+ If posting an inline comment fails (e.g., line not part of the diff, auth error), include the finding in the overall review summary comment instead.
209
+
210
+ **Important rules:**
211
+
212
+ - Only post **ONE comment per unique issue** — do not duplicate across lines
213
+ - Keep each comment concise and actionable
214
+ - Include the severity tag (Critical/Suggestion/Nice to have) at the start of each comment
215
+ - Include the suggested fix in the comment body when available
216
+
217
+ After posting all inline comments, use `write_file` to create `/tmp/pr-review-summary.txt` with the summary text, then submit the review using the action that matches the verdict from Step 3:
218
+
219
+ ```bash
220
+ # Submit review with the matching action:
221
+ # If verdict is "Approve":
222
+ gh pr review {pr_number} --approve --body-file /tmp/pr-review-summary.txt
223
+
224
+ # If verdict is "Request changes":
225
+ gh pr review {pr_number} --request-changes --body-file /tmp/pr-review-summary.txt
226
+
227
+ # If verdict is "Comment":
228
+ gh pr review {pr_number} --comment --body-file /tmp/pr-review-summary.txt
229
+ ```
230
+
231
+ If there are **no confirmed findings**:
232
+
233
+ ```bash
234
+ gh pr review {pr_number} --approve --body "No issues found. LGTM! ✅"
235
+ ```
236
+
237
+ ## Step 5: Restore environment
238
+
239
+ If you checked out a PR branch in Step 1, restore the original state now: check out the original branch, `git stash pop` if changes were stashed, and remove all temp files (`/tmp/pr-review-context.md`, `/tmp/pr-comment.txt`, `/tmp/pr-review-summary.txt`).
240
+
241
+ This step runs **after** Step 4 to ensure the PR branch is still checked out when posting inline comments (Step 4 needs the correct commit SHA from the PR branch).
242
+
243
+ ## Exclusion Criteria
244
+
245
+ These criteria apply to both Step 2 (review agents) and Step 2.5 (verification agents). Do NOT flag or confirm any finding that matches:
246
+
247
+ - Pre-existing issues in unchanged code (focus on the diff only)
248
+ - Style, formatting, or naming that matches surrounding codebase conventions
249
+ - Pedantic nitpicks that a senior engineer would not flag
250
+ - Issues that a linter or type checker would catch automatically
251
+ - Subjective "consider doing X" suggestions that aren't real problems
252
+ - If you're unsure whether something is a problem, do NOT report it
253
+
254
+ ## Guidelines
255
+
256
+ - Be specific and actionable. Avoid vague feedback like "could be improved."
257
+ - Reference the existing codebase conventions — don't impose external style preferences.
258
+ - Focus on the diff, not pre-existing issues in unchanged code.
259
+ - Keep the review concise. Don't repeat the same point for every occurrence.
260
+ - When suggesting a fix, show the actual code change.
261
+ - Flag any exposed secrets, credentials, API keys, or tokens in the diff as **Critical**.