Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

docs(TUI): add /btw, /review, /simplify, and /security-review to slash command documentation

ldstyle870dff644d634
diff --git a/docs/en/SlashCommands.md b/docs/en/SlashCommands.md
index e2d361532f..d014d02a9c 100644
--- a/docs/en/SlashCommands.md
+++ b/docs/en/SlashCommands.md
@@ -33,9 +33,11 @@ Executed locally in the terminal UI, not through Gateway control pipeline.
| `/evolve_simplify` | Simplify and consolidate one skill's evolution records (see below) |
| `/evolve_rebuild` | Rebuild `SKILL.md` from archives and evolution records (see below) |
| `/hooks` | Browse configured hooks (read-only, see below) |
+| `/simplify` | Code simplify review: checks reuse, quality, efficiency and auto-fixes (`code.*` only, see below) |
| `/sandbox` | Set sandbox mode (see below) |
| `/agents` | Manage Agent configs (list, get, create, update, enable, disable, delete, see below) |
| `/auto-harness` | Auto-Harness task management (`run`/`schedule`/`issue`, see below) |
+| `/btw` | Ask a quick side question without interrupting the main conversation (see below) |
> Note: `/mode` controlled switching logic is primarily on Gateway side, see "`/mode` and `/switch`" below. The TUI local command additionally supports `/mode plan` and `/mode team.normal`; see the TUI guide for details.
@@ -60,6 +62,8 @@ Identified by Gateway and forwarded to AgentServer and other backend capabilitie
| `/rewind` | Rewind conversation to before a specific turn (see below) |
| `/memory` | Memory management (see below) |
| `/cron` | Scheduled task (cron job) management (see below) |
+| `/review` | Code review a pull request (see below) |
+| `/security-review` | Security review of pending changes on the current branch (see below) |
---
@@ -532,6 +536,49 @@ Timestamp format: `YYYY-MM-DD-HHmmss`.
- `/export my-chat` — Save to `my-chat.txt` in workspace
- `/export 2026-05-09-debug-session.txt` — Save with explicit timestamp name
+### `/simplify` (Code Simplify Review)
+
+Parsed **locally by the TUI**, this command sends a dedicated RPC `command.simplify` to get a server-generated three-phase review prompt, then injects it as an Agent message (`logAsUser: false`). The Agent automatically reviews changed code for reuse, quality, and efficiency, and directly fixes issues found.
+
+- **Alias**: None.
+- **Applicable modes**: **`code.*` only**. Non-code mode shows an error prompting `Run /mode code first`.
+- **Parsing location**: TUI local (not a Gateway controlled channel); unavailable in IM.
+
+#### Usage
+
+| Command | Description |
+|---|---|
+| `/simplify` | Review current git changes (or recently edited files) and auto-fix issues |
+| `/simplify <target>` | Add focus: file path, module name, or specific review dimension |
+
+#### Execution Flow
+
+1. **TUI validates**: Confirms current mode starts with `code.`; errors otherwise.
+2. **RPC request**: Calls `command.simplify` (with optional `target`), 30-second timeout.
+3. **Server generates prompt**: Builds a three-phase review instruction from `_SIMPLIFY_PROMPT_TEMPLATE`; appends `## Additional Focus` section if `target` is provided.
+4. **Injects into Agent**: TUI calls `ctx.sendMessage(prompt, ..., { logAsUser: false })` to inject the prompt; the Agent begins execution.
+5. **Offline handling**: Shows a retry message if offline.
+
+#### Three-Phase Review
+
+**Phase 1 — Identify Changes**: Run `git diff` (or `git diff HEAD` for staged changes) to find changed files. If no git changes, review recently edited files from the conversation.
+
+**Phase 2 — Launch Three Review Agents in Parallel** (use sub-agent tools if available; otherwise perform all reviews directly):
+
+| Review Dimension | Focus Areas |
+|---|---|
+| **Code Reuse Review** | Existing utilities/helpers that could replace new code; duplicated functionality; hand-rolled logic that could use an existing utility |
+| **Code Quality Review** | Redundant state; parameter sprawl; copy-paste variations; leaky abstractions; stringly-typed code (use existing constants/enums); unnecessary JSX nesting; unnecessary comments (keep only non-obvious WHY) |
+| **Efficiency Review** | Unnecessary work (redundant computations, repeated I/O, N+1 patterns); missed concurrency; hot-path bloat; recurring no-op updates; TOCTOU anti-patterns; memory leaks / missing cleanup; overly broad operations |
+
+**Phase 3 — Fix Issues**: Aggregate all findings and fix each issue directly. Skip false positives without argument. Briefly summarize what was fixed (or confirm the code was already clean).
+
+#### Examples
+
+- `/simplify` — Review all changes
+- `/simplify src/auth/` — Focus on changes under `src/auth/`
+- `/simplify focus on error handling patterns` — Emphasize error handling
+
### `/sandbox` (Sandbox Mode Management)
Enter / leave jiuwenbox sandbox mode and tune its runtime policy. Calls `command.sandbox` on the agent server.
@@ -1108,13 +1155,120 @@ Requires `git.user_name`, `git.user_email` and `gitcode.access_token` (or `GITCO
- `/auto-harness issue delete 123`
- `/auto-harness issue delete 123 456`
----
+### `/btw` (By-the-way Side Question)
-## Planned Features
+Parsed **locally by the TUI**, this command sends a dedicated RPC `command.btw` to AgentServer to run an isolated, tool-free, single-turn LLM query against the current conversation context. It answers a quick side question **without interrupting the main conversation**.
+
+- **Alias**: None.
+- **Applicable modes**: All.
+- **Constraint**: A question must be provided; returns `no_context` when no conversation context exists yet.
+
+#### Usage
+
+| Command | Description |
+|---|---|
+| `/btw <question>` | Ask a side question based on current conversation context |
+
+#### Behavior Details
+
+- **Required argument**: `/btw` must include a question; otherwise shows `Usage: /btw <your question>`.
+- **Thinking indicator**: Displays `💭 Answering: <question>` (dim style) while the request is in flight.
+- **RPC timeout**: 120 seconds.
+- **Server-side handling**:
+ - Backend receives the request via `command.btw` RPC and obtains the current Agent instance.
+ - Shares the main Agent's system prompt (project context, skills, CLAUDE.md, etc.) and retrieves recent conversation messages as context.
+ - Builds a dedicated btw prompt with a `<system-reminder>` telling the model: no tools available, single response only, main Agent is not interrupted.
+ - Calls the model directly (no tools, single-turn), without modifying conversation history (read-only).
+- **Return statuses**:
+ - `ok`: Displays `💡 /btw <question>` + answer content.
+ - `no_context`: Shows `No conversation context available yet — send a message first.`
+ - `failed`: Shows error message or `Couldn't answer the side question.`
+
+#### Examples
+
+- `/btw what does git status do?`
+- `/btw What is the time complexity of this code?`
+
+### `/review` (Code Review a Pull Request)
+
+When entered in the **TUI**, sends the raw `/review` text as a chat message to the Gateway. The Gateway recognizes it, injects a review prompt, and the Agent uses `gh` CLI to review the PR.
+
+In **IM controlled channels** (Feishu etc.), the Gateway intercepts `/review`, injects the prompt, and forwards to AgentServer for execution.
+
+- **Alias**: None.
+- **Applicable modes**: All (Agent, Code, Team).
+- **Parsing location**: Gateway controlled channel (`scope: "gateway"`); TUI sends as a chat message.
+
+#### Usage
| Command | Description |
|---|---|
-| `/btw` | Ask question |
-| `/memory` | Memory management |
-| `/export` | Export related files |
-| `/permissions` | Permission management |
+| `/review` | Without arguments, the Agent runs `gh pr list` to show open PRs |
+| `/review <PR number or URL>` | Review a specific PR: Agent runs `gh pr view/diff` and analyzes |
+
+#### Behavior Details
+
+- **TUI execution**: Sends `/review [args]` as a user message via `ctx.sendMessage()`; shows `offline: waiting for reconnect before sending review request` if offline.
+- **Gateway interception** (IM side):
+ - Matches exact `/review` or prefix `/review <arg>`.
+ - Argument max 2048 bytes; control characters rejected with an error notice.
+ - Injects the review prompt into `msg.params["query"]` and continues forwarding to AgentServer.
+- **Agent execution**: Upon receiving the review prompt, the Agent uses `gh` CLI:
+ 1. Without arguments: runs `gh pr list` to display open PRs.
+ 2. With arguments: runs `gh pr view <number>` for details and `gh pr diff <number>` for the diff.
+ 3. Analyzes changes and provides a comprehensive review (correctness, conventions, performance, test coverage, security).
+- **No git/gh pre-check**: The Gateway does not check whether `git` or `gh` is installed; the Agent handles missing tools on its own.
+
+#### Examples
+
+- `/review` — List open PRs in the current repo
+- `/review 123` — Review PR #123
+
+### `/security-review` (Security Review)
+
+When entered in the **TUI**, sends the raw `/security-review` text as a chat message to the Gateway. The Gateway recognizes it, injects a security review prompt, and the Agent uses `git` commands to analyze pending changes on the current branch.
+
+In **IM controlled channels** (Feishu etc.), the Gateway intercepts `/security-review`, injects the prompt, and forwards to AgentServer for execution.
+
+- **Alias**: None.
+- **Applicable modes**: All (Agent, Code, Team).
+- **Parsing location**: Gateway controlled channel (`scope: "gateway"`); TUI sends as a chat message.
+
+#### Usage
+
+| Command | Description |
+|---|---|
+| `/security-review` | Review all pending changes on the current branch vs `origin/HEAD` |
+| `/security-review <additional instructions>` | Add focus instructions or constraints (e.g., "focus on auth module") |
+
+#### Behavior Details
+
+- **TUI execution**: Sends `/security-review [args]` as a user message via `ctx.sendMessage()`; shows `offline: waiting for reconnect before sending security review request` if offline.
+- **Gateway interception** (IM side):
+ - Matches exact `/security-review` or prefix `/security-review <arg>`.
+ - Argument max 2048 bytes; control characters rejected with an error notice.
+ - Injects the security review prompt into `msg.params["query"]` and continues forwarding to AgentServer.
+- **Agent execution**: Upon receiving the security review prompt, the Agent performs:
+ 1. **Repository context research**: `git status`, `git diff --name-only origin/HEAD...`, `git log` to understand the change scope.
+ 2. **Comparative analysis**: `git diff origin/HEAD...` to review diffs file by file.
+ 3. **Vulnerability assessment** across these categories:
+ - Input validation vulnerabilities
+ - Authentication and authorization issues
+ - Cryptography and key management
+ - Injection and code execution
+ - Data exposure
+ 4. Uses subtasks to identify vulnerabilities and parallel subtasks for false-positive filtering; only reports findings with >80% confidence.
+ 5. Outputs a structured Markdown report: file, line number, severity, category, description, exploit scenario, fix recommendation.
+- **Hard exclusion list**: Does not report DoS, secret storage, rate limiting, race conditions, and similar issue types.
+- **No git pre-check**: The Gateway does not check whether `git` is installed; the Agent handles this on its own.
+
+#### Examples
+
+- `/security-review` — Review all pending changes on the current branch
+- `/security-review focus on authentication module security` — With additional focus instructions
+
+---
+
+## Planned Features
+
+(None currently)
diff --git "a/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md" "b/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
index ba4b21bf71..44d74a61a4 100644
--- "a/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
+++ "b/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
@@ -33,9 +33,11 @@
| `/evolve_simplify` | 整理、合并某个 Skill 的演进经验(见下文) |
| `/evolve_rebuild` | 基于归档与演进记录重建 `SKILL.md`(见下文) |
| `/hooks` | 浏览已配置的 hooks(只读,见下文) |
+| `/simplify` | 代码精简审查:检查复用性、质量、效率并自动修复(仅 `code.*`,见下文) |
| `/sandbox` | 设置沙箱模式(见下文) |
| `/agents` | 管理 Agent 配置(list, get, create, update, enable, disable, delete,见下文) |
| `/auto-harness` | Auto-Harness 任务管理(`run`/`schedule`/`issue`,见下文) |
+| `/btw` | 旁路快速提问,不中断主对话(见下文) |
> 说明:本页的 `/mode` 与 `/switch` 以 Gateway 受控通道行为为主。TUI 本地命令另支持 `/mode plan`、`/mode team.normal`,详见 [TUI 使用指南](TUI使用指南.md)。
@@ -60,6 +62,8 @@
| `/rewind` | 回退对话到指定轮次之前(见下文) |
| `/memory` | 记忆管理(见下文) |
| `/cron` | 定时任务管理(见下文) |
+| `/review` | 代码审查 PR(见下文) |
+| `/security-review` | 安全审查当前分支待定变更(见下文) |
---
@@ -551,6 +555,49 @@
- `/export my-chat` — 保存到工作空间下的 `my-chat.txt`
- `/export 2026-05-09-debug-session.txt` — 使用显式时间戳文件名保存
+### `/simplify`(代码精简审查)
+
+在 **TUI 本地解析**,通过专用 RPC `command.simplify` 获取服务端生成的三阶段审查 prompt,然后注入为 Agent 消息(`logAsUser: false`)。Agent 自动审查代码变更的复用性、质量与效率,并直接修复发现的问题。
+
+- **别名**:无。
+- **适用模式**:**仅 `code.*`**。非 code 模式下提示先执行 `/mode code`。
+- **解析位置**:TUI 本地(非 Gateway 受控通道),IM 不可用。
+
+#### 用法
+
+| 命令 | 说明 |
+|---|---|
+| `/simplify` | 审查当前 git 变更(或最近编辑的文件),自动修复问题 |
+| `/simplify <target>` | 附加关注点:文件路径、模块名或特定审查维度 |
+
+#### 执行流程
+
+1. **TUI 校验**:确认当前处于 `code.*` 模式,否则返回错误提示。
+2. **RPC 请求**:调用 `command.simplify`(携带可选 `target`),超时 30 秒。
+3. **服务端生成 prompt**:基于 `_SIMPLIFY_PROMPT_TEMPLATE` 构建三阶段审查指令;若有 `target`,追加 `## Additional Focus` 段落。
+4. **注入 Agent**:TUI 通过 `ctx.sendMessage(prompt, ..., { logAsUser: false })` 注入 prompt,Agent 开始执行。
+5. **离线处理**:离线时提示重试。
+
+#### 三阶段审查
+
+**阶段 1 — 识别变更**:执行 `git diff`(或 `git diff HEAD`)获取变更文件列表;无 git 变更时审查对话中最近编辑的文件。
+
+**阶段 2 — 并行启动三个审查 Agent**(若有子 Agent 工具则并发执行;否则自行完成三项审查):
+
+| 审查维度 | 关注点 |
+|---|---|
+| **代码复用审查** | 是否存在可替代新代码的现有工具/工具函数;重复实现已有功能;手写逻辑是否可用已有工具替代 |
+| **代码质量审查** | 冗余状态;参数膨胀;复制粘贴变体;抽象泄漏;字符串硬编码(应用已有常量/枚举);不必要的 JSX 嵌套;不必要的注释(仅保留说明 WHY 的注释) |
+| **效率审查** | 不必要的工作(重复计算/文件读取/N+1);错失并发机会;热路径膨胀;无条件触发的无效更新;TOCTOU 反模式(先检查再操作);内存泄漏/未清理的监听器;过度操作(读取整文件但只需部分) |
+
+**阶段 3 — 修复问题**:汇总所有发现,逐一修复;误报跳过即可,不争论;完成后简要总结修复内容(或确认代码已足够精简)。
+
+#### 示例
+
+- `/simplify` — 审查所有变更
+- `/simplify src/auth/` — 关注 `src/auth/` 目录下的变更
+- `/simplify focus on error handling patterns` — 重点关注错误处理模式
+
### `/sandbox`(沙箱模式管理)
进入/离开 jiuwenbox 沙箱模式,并调整其运行时策略。通过 `command.sandbox` 与 agent-server 交互。
@@ -1121,12 +1168,120 @@ Pipeline 执行过程中,扩展包**默认自动激活生效**,无需用户
- `/auto-harness issue delete 123`
- `/auto-harness issue delete 123 456`
+### `/btw`(旁路提问)
+
+在 **TUI 本地解析**,通过专用 RPC `command.btw` 向 AgentServer 发起一个独立的、无工具的、单轮 LLM 查询,基于当前对话上下文快速回答旁路问题,**不中断主对话**。
+
+- **别名**:无。
+- **适用模式**:全部。
+- **约束**:必须提供问题文本;无对话上下文时返回 `no_context`。
+
+#### 用法
+
+| 命令 | 说明 |
+|---|---|
+| `/btw <question>` | 基于当前对话上下文,发起旁路提问 |
+
+#### 行为细节
+
+- **参数必填**:`/btw` 必须带问题文本,否则提示 `Usage: /btw <your question>`。
+- **思考指示器**:发送请求后显示 `💭 Answering: <question>`(dim 样式)。
+- **RPC 超时**:120 秒。
+- **服务端处理**:
+ - 后端通过 `command.btw` RPC 接收请求,获取当前 Agent 实例。
+ - 与主 Agent 共享 system prompt(项目上下文、技能、CLAUDE.md 等),获取最近对话消息作为上下文。
+ - 构建专用 btw prompt,通过 `<system-reminder>` 告知模型:无工具可用、单次回复、不中断主 Agent。
+ - 直接调用模型(无工具、单轮),不修改对话历史(只读操作)。
+- **返回状态**:
+ - `ok`:显示 `💡 /btw <question>` + 回答内容。
+ - `no_context`:提示 `No conversation context available yet — send a message first.`。
+ - `failed`:显示错误信息或 `Couldn't answer the side question.`。
+
+#### 示例
+
+- `/btw what does git status do?` — 询问 git status 命令的作用
+- `/btw 这段代码的时间复杂度是多少?` — 基于上下文分析算法复杂度
+
+### `/review`(代码审查 PR)
+
+在 **TUI** 中输入时,将原始 `/review` 文本作为聊天消息发送给 Gateway。Gateway 识别后注入 review prompt,由 Agent 使用 `gh` CLI 审查 PR。
+
+在 **IM 受控通道**(飞书等)中,Gateway 拦截 `/review` 并注入 prompt,转发给 AgentServer 执行。
+
+- **别名**:无。
+- **适用模式**:全部(Agent、Code、Team)。
+- **解析位置**:Gateway 受控通道(`scope: "gateway"`),TUI 作为聊天消息发送。
+
+#### 用法
+
+| 命令 | 说明 |
+|---|---|
+| `/review` | 无参数时,Agent 执行 `gh pr list` 展示开放 PR 列表 |
+| `/review <PR 编号或 URL>` | 审查指定 PR:Agent 执行 `gh pr view/diff` 并分析 |
+
+#### 行为细节
+
+- **TUI 执行**:通过 `ctx.sendMessage()` 将 `/review [args]` 作为用户消息发送;离线时提示 `offline: waiting for reconnect before sending review request`。
+- **Gateway 拦截**(IM 侧):
+ - 精确匹配 `/review` 或前缀匹配 `/review <arg>`。
+ - 参数最长 2048 字节;含控制字符返回 `非法指令`。
+ - 注入 review prompt 到 `msg.params["query"]`,继续转发给 AgentServer。
+- **Agent 执行**:收到 review prompt 后,Agent 使用 `gh` CLI:
+ 1. 无参数时运行 `gh pr list` 展示开放 PR 列表。
+ 2. 有参数时运行 `gh pr view <number>` 获取详情、`gh pr diff <number>` 获取 diff。
+ 3. 分析变更并提供全面审查(正确性、约定、性能、测试覆盖、安全)。
+- **无 git/gh 预检**:Gateway 不检查 `git` 或 `gh` 是否安装,由 Agent 自行处理。
+
+#### 示例
+
+- `/review` — 列出当前仓库的开放 PR
+- `/review 123` — 审查 PR #123
+
+### `/security-review`(安全审查)
+
+在 **TUI** 中输入时,将原始 `/security-review` 文本作为聊天消息发送给 Gateway。Gateway 识别后注入安全审查 prompt,由 Agent 使用 `git` 命令分析当前分支的待定变更。
+
+在 **IM 受控通道**(飞书等)中,Gateway 拦截 `/security-review` 并注入 prompt,转发给 AgentServer 执行。
+
+- **别名**:无。
+- **适用模式**:全部(Agent、Code、Team)。
+- **解析位置**:Gateway 受控通道(`scope: "gateway"`),TUI 作为聊天消息发送。
+
+#### 用法
+
+| 命令 | 说明 |
+|---|---|
+| `/security-review` | 审查当前分支相对于 `origin/HEAD` 的所有待定变更 |
+| `/security-review <附加说明>` | 附带焦点说明或约束(如"重点关注认证模块") |
+
+#### 行为细节
+
+- **TUI 执行**:通过 `ctx.sendMessage()` 将 `/security-review [args]` 作为用户消息发送;离线时提示 `offline: waiting for reconnect before sending security review request`。
+- **Gateway 拦截**(IM 侧):
+ - 精确匹配 `/security-review` 或前缀匹配 `/security-review <arg>`。
+ - 参数最长 2048 字节;含控制字符返回 `非法指令`。
+ - 注入安全审查 prompt 到 `msg.params["query"]`,继续转发给 AgentServer。
+- **Agent 执行**:收到安全审查 prompt 后,Agent 执行以下步骤:
+ 1. **仓库上下文研究**:`git status`、`git diff --name-only origin/HEAD...`、`git log` 获取变更概览。
+ 2. **比较分析**:`git diff origin/HEAD...` 逐文件审查 diff。
+ 3. **漏洞评估**:按以下类别审查:
+ - 输入验证漏洞
+ - 身份认证和授权问题
+ - 密码学与密钥管理
+ - 注入与代码执行
+ - 数据暴露
+ 4. 使用子任务识别漏洞、并行子任务进行误报过滤,仅报告置信度 > 80% 的发现。
+ 5. 输出结构化 Markdown 报告:文件、行号、严重级别、类别、描述、利用场景、修复建议。
+- **硬排除列表**:不报告拒绝服务、密钥存储、限速、竞态条件等问题类型。
+- **无 git 预检**:Gateway 不检查 `git` 是否安装,由 Agent 自行处理。
+
+#### 示例
+
+- `/security-review` — 审查当前分支所有待定变更
+- `/security-review 重点关注认证模块的安全性` — 附带焦点说明
+
---
## 待开发
-| 命令 | 说明 |
-|----------------|---------|
-| `/btw` | 提问 |
-| `/export` | 导出相关文件 |
-| `/permissions` | 权限管理 |
+(暂无)
diff --git "a/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md"
index 15fb408c4b..38d47b0959 100644
--- "a/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md"
+++ "b/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md"
@@ -92,6 +92,7 @@
| `/permissions` | - | 设置 `permissions.tools` 中单工具的 allow/ask/deny | `/permissions ask write_file` | 全部 |
| `/plan` | - | 进入 Agent 规划模式,或发送规划请求 | `/plan`、`/plan open`、`/plan 迁移步骤` | 非 `team` |
| `/rename` | - | 查看/重命名/清空当前会话标题 | `/rename`、`/rename 标题`、`/rename clear` | 全部 |
+| `/review` | - | 审查 PR(TUI 发送聊天消息,Gateway 拦截注入 prompt) | `/review`、`/review 123` | 全部 |
| `/resume` | `/continue` | 列出或恢复历史会话;无参 `/resume` 与 `/continue` 在 TUI 中可打开交互列表(见下) | `/resume list`、`/resume <id>` | 全部 |
| `/skills` | - | 技能与市场源管理 | `/skills`、`/skills install ...` | 全部 |
| `/teamskills` | - | TeamSkills Hub(初始化、校验、打包、搜索、安装等) | `/teamskills list` | 全部 |
@@ -101,9 +102,12 @@
| `/status` | - | 查看运行状态概览、用量、配置 | `/status`、`/status usage` | 全部 |
| `/agents` | - | 管理 Agent 配置(list, get, create, update, enable, disable, delete) | `/agents list`、`/agents get Explore` | 全部 |
| `/branch` | `/fork` | 从当前对话点创建分支会话 | `/branch fix-login-bug` | 全部 |
+| `/btw` | - | 旁路快速提问,不中断主对话 | `/btw what does git status do?` | 全部 |
| `/rewind` | `/checkpoint` | 回退对话到指定轮次之前 | `/rewind 2` | 全部 |
| `/memory` | `/mem` | 记忆管理(状态、文件、开关、目录) | `/memory status` | 全部 |
| `/sandbox` | - | 进出沙箱模式 / 管理 excluded_commands / files | `/sandbox enable`、`/sandbox status`、`/sandbox files allow ./tmp/` | 全部 |
+| `/security-review` | - | 安全审查当前分支待定变更 | `/security-review`、`/security-review 重点关注认证` | 全部 |
+| `/simplify` | - | 代码精简审查(复用性、质量、效率),自动修复问题 | `/simplify`、`/simplify src/auth/` | **仅 `code.*`** |
#### `/resume` 与 `/continue` 在 TUI 中的特殊行为
@@ -332,6 +336,20 @@
- 行为:生成新 `session_id` 并调用 `session.fork`;TUI 自动切换到新分支会话,清空 transcript 并恢复分支历史。提示用户可用 `/resume <原会话ID>` 返回原会话。
- 示例:`/branch`、`/branch fix-login-bug`。
+#### `/btw`(旁路提问)
+
+- **别名**:无。
+- **适用模式**:全部。
+- 在 TUI 本地解析,通过专用 RPC `command.btw` 向 AgentServer 发起独立、无工具、单轮 LLM 查询,基于当前对话上下文快速回答旁路问题,**不中断主对话**。
+- **参数必填**:`/btw <question>`,无参数时提示 `Usage: /btw <your question>`。
+- 发送后显示 `💭 Answering: <question>`(dim 样式),RPC 超时 120 秒。
+- 返回状态:
+ - `ok`:显示 `💡 /btw <question>` + 回答。
+ - `no_context`:提示无对话上下文。
+ - `failed`:显示错误信息。
+- 服务端与主 Agent 共享 system prompt,直接调用模型(无工具、单轮),不修改对话历史(只读操作)。
+- 示例:`/btw what does git status do?`、`/btw 这段代码的时间复杂度是多少?`
+
#### `/rewind`(回退对话)
- 别名:`/checkpoint`。
@@ -376,6 +394,41 @@
- 写入策略:`allow` / `deny` 控制写访问(rw/ro),不是 Unix 八进制权限;支持「父 allow + 子 deny」,不支持「子 allow + 父 deny」。
- 示例:`/sandbox enable`、`/sandbox status`、`/sandbox files allow ./tmp/`、`/sandbox exclude add "git *"`。
+#### `/review`(代码审查 PR)
+
+- **别名**:无。
+- **适用模式**:全部。
+- TUI 通过 `ctx.sendMessage()` 将 `/review [args]` 作为聊天消息发送给 Gateway;离线时提示错误。
+- Gateway 识别后注入 review prompt,由 Agent 使用 `gh` CLI 执行审查。
+- 无参数时 Agent 执行 `gh pr list` 展示开放 PR 列表;有参数时执行 `gh pr view/diff` 并分析变更(正确性、约定、性能、测试覆盖、安全)。
+- 无 git/gh 预检,由 Agent 自行处理缺失工具的情况。
+- 示例:`/review`(列出 PR)、`/review 123`(审查 PR #123)。
+
+#### `/security-review`(安全审查)
+
+- **别名**:无。
+- **适用模式**:全部。
+- TUI 通过 `ctx.sendMessage()` 将 `/security-review [args]` 作为聊天消息发送给 Gateway;离线时提示错误。
+- Gateway 识别后注入安全审查 prompt,由 Agent 使用 `git` 命令分析当前分支相对于 `origin/HEAD` 的待定变更。
+- Agent 执行三步分析:仓库上下文研究(`git status`/`diff --name-only`/`log`)→ 比较分析(`git diff`)→ 漏洞评估(输入验证、认证授权、密码学、注入、数据暴露)。
+- 仅报告置信度 > 80% 的发现,输出结构化 Markdown 报告(文件、行号、严重级别、类别、描述、利用场景、修复建议)。
+- `[args]` 可选,用于附加焦点说明(如"重点关注认证模块")。
+- 示例:`/security-review`、`/security-review 重点关注认证模块的安全性`。
+
+#### `/simplify`(代码精简审查)
+
+- **别名**:无。
+- **适用模式**:**仅 `code.*`**。非 code 模式下提示先执行 `/mode code`。
+- TUI 本地解析,调用 `command.simplify` RPC(30 秒超时)获取服务端生成的三阶段审查 prompt,然后通过 `ctx.sendMessage(prompt, ..., { logAsUser: false })` 注入为 Agent 消息。
+- 可选参数 `[target]`:附加关注点(文件路径、模块名或特定审查维度)。
+- **执行流程**:校验 code 模式 → RPC 获取 prompt → 注入 Agent → Agent 执行三阶段审查并自动修复。
+- **三阶段**:
+ 1. **识别变更**:`git diff` 获取变更列表。
+ 2. **并行审查**(三个维度):代码复用(现有工具/重复功能)、代码质量(冗余状态/参数膨胀/复制粘贴/抽象泄漏/字符串硬编码/不必要注释)、效率(不必要工作/错失并发/热路径膨胀/无效更新/TOCTOU/内存泄漏)。
+ 3. **修复问题**:逐一修复,误报跳过,完成后总结。
+- 离线时提示重试。
+- 示例:`/simplify`(审查所有变更)、`/simplify src/auth/`(关注特定目录)、`/simplify focus on error handling`(关注错误处理)。
+
#### `/hooks`(浏览 Hooks 配置)
- 用法:`/hooks`(无参数、无子命令,只读)。