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
fix(diff): fix --detail has no effect and add docs for /agents & /hooks
ldstyle8b1a5250024c2
diff --git a/docs/en/SlashCommands.md b/docs/en/SlashCommands.mdindex f3f93ba393..e0da477190 100644--- a/docs/en/SlashCommands.md+++ b/docs/en/SlashCommands.md@@ -31,7 +31,9 @@ Executed locally in the terminal UI, not through Gateway control pipeline.| `/evolve_list` | Show one skill's evolution records (see below) || `/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) || `/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`, 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.@@ -506,6 +508,200 @@ Enter / leave jiuwenbox sandbox mode and tune its runtime policy. Calls `command- `/sandbox files allow ./tmp/ 0777` — let the sandbox write into `./tmp/` with mode 0777- `/sandbox exclude add "git *"` — let `git` run on the host instead of inside the sandbox+### `/hooks` (Browse Hooks Configuration)++View a summary of all hooks configured in `config.yaml` (read-only).++#### Usage++- `/hooks` (no parameters, no subcommands)++#### Data Source++The TUI requests the Gateway via the `hooks.list` RPC, which loads the `hooks` section from `config.yaml` and returns a summary.++#### Display Contents++`/hooks` displays hooks configuration in three levels:++1. **Event List (Level 1)**: All events sorted by hook count in descending order. Each row shows event name and hook count; the description column shows hook count distribution per matcher.+2. **Status Panel**:+ - `Source` — Configuration source (`config.yaml`)+ - `Global Status` — Global toggle state (`enabled` / `DISABLED`)+ - `Total Hooks` — Total hook count across all events+ - `Active Events` — Events with at least 1 hook / total events (out of 17)+3. **Hook Detail Cards (Level 2)**: Grouped by `Event > Matcher`, each hook shows:+ - `Type` — `command` (shell command) or `prompt` (LLM review)+ - `Command` / `Prompt` — The hook content+ - `Timeout` — Timeout in seconds+ - `Shell` — Execution shell (command hooks only)+ - `Status` — Status message++#### When No Hooks Are Configured++If `config.yaml` has no hooks configured, displays `No hooks configured.` with a hint to use `/config edit` to configure them.++#### Hooks Concept Overview++Hooks are extension logic that executes automatically when specific events fire. 17 events are supported:++| Event | Execution Layer | Trigger |+|---|---|---|+| `PreToolUse` | Agent Rail | Before a tool call |+| `PostToolUse` | Agent Rail | After a successful tool call |+| `PostToolUseFailure` | Agent Rail | After a failed tool call |+| `Stop` | Agent Rail | After agent response completes |+| `PermissionRequest` | Agent Rail | On permission request |+| `PermissionDenied` | Agent Rail | On permission denied |+| `SubagentStart` | Agent Rail | When a sub-agent starts |+| `SubagentStop` | Agent Rail | When a sub-agent stops |+| `BeforeModelCall` | Agent Rail | Before a model call |+| `AfterModelCall` | Agent Rail | After a model call |+| `UserPromptSubmit` | Gateway | User submits a message |+| `SessionStart` | Gateway | Session starts |+| `SessionEnd` | Gateway | Session ends |+| `Notification` | Gateway | Notification is sent |+| `ConfigChange` | Gateway | Configuration changes |+| `InstructionsLoaded` | Gateway | Instructions are loaded |+| `Setup` | Gateway | Initialization |++Two hook types are supported:++| Type | Description | Key Parameters |+|---|---|---|+| `command` | Executes a shell command (subprocess). Receives JSON context via `$ARGUMENTS` env var. Exit code 0 = success, 2 = block. | `command`, `timeout` (default 30s), `shell` (default bash) |+| `prompt` | Invokes LLM review. `$ARGUMENTS` in the template is replaced with JSON context, `$TOOL_NAME` with the tool name. LLM response JSON with `decision: "block"` blocks the operation. | `prompt`, `timeout` (default 15s), `model` |++- **Blocking**: Exit code 2 (command) or `decision: "block"` (prompt) blocks the current operation (e.g., skip tool call) and feeds the reason back to the model.+- **Input Modification**: PreToolUse hooks can modify tool input parameters via `modifiedInput` in stdout JSON.+- **Additional Context**: Extra information can be injected into tool results or model context via `additionalContext` in stdout JSON.+- **Global Toggle**: `hooks.disable_all_hooks: true` in `config.yaml` disables all hooks.++#### Configuration Example++```yaml+hooks:+ PreToolUse:+ - matcher: "write_file"+ hooks:+ - type: command+ command: "echo 'write_file about to execute' >> /tmp/hooks.log"+ timeout: 10+ - matcher: "bash|run_command"+ hooks:+ - type: prompt+ prompt: "Review if this command is safe: $ARGUMENTS"+ timeout: 20+ SessionStart:+ - matcher: "*"+ hooks:+ - type: command+ command: "echo 'Session started: $ARGUMENTS' >> /tmp/hooks.log"+```++#### Example++- `/hooks` — Browse all current hooks configuration++### `/agents` (Agent Management)++Manage custom agents (subagents) throughout their full lifecycle: view, create, update, enable/disable, and delete. Agent definitions are stored as Markdown files and support four-level source priority merging.++- **Parsing location**: TUI local parsing, calling backend `agents.*` endpoints via RPC.+- **Applicable modes**: All.+- **Note**: This command is registered as hidden (`hidden: true`) and does not appear in `/help` listings but can be used directly.++#### Subcommands++| Command | Description |+|---|---|+| `/agents` or `/agents list` | List all agents (name, source, enabled status, description summary) |+| `/agents get <name>` | View full details of a specific agent (including System Prompt) |+| `/agents create [--project\|--local] <name> <description>` | Create a custom agent; LLM auto-generates the prompt |+| `/agents update <name> [--generate] <new description>` | Update agent description; add `--generate` to have LLM rewrite the prompt |+| `/agents enable <name>` | Enable a custom agent (cannot operate on builtin agents) |+| `/agents disable <name>` | Disable a custom agent (cannot operate on builtin agents) |+| `/agents delete <name>` | Delete a custom agent (cannot operate on builtin agents) |++#### Agent Sources & Storage++| Source | Storage Location | Priority | Manageable |+|--------|-----------------|----------|------------|+| `builtin` | In-code builtins | Lowest | Cannot enable/disable/delete |+| `local` | `<workspace>/.jiuwenswarm/agents-local/` | Local | Full lifecycle management |+| `user` | `~/.jiuwenswarm/agents/` | User | Full lifecycle management (default `create` location) |+| `project` | `<workspace>/.jiuwenswarm/agents/` | Highest | Full lifecycle management |++Agents with the same name are resolved by `project > user > local > builtin` priority; shadowed agents are marked with `shadowed_by`.++#### Agent Definition Fields++| Field | Description |+|------|------|+| `name` | Agent name (unique identifier) |+| `description` | Brief description |+| `prompt` | System Prompt text |+| `source` | Origin (`builtin` / `user` / `project` / `local`) |+| `file_path` | Agent definition file path |+| `model` | Specified model (`null` = use default) |+| `tools` | Available tool list |+| `disallowed_tools` | Disallowed tool list |+| `color` | Display color |+| `permission_mode` | Permission mode |+| `memory_scope` | Memory scope |+| `when_to_use` | When-to-use description |+| `max_iterations` | Max iterations (default 200) |+| `skills` | Associated skill list |+| `enabled` | Enabled status (`true` / `false` / `null`) |+| `shadowed_by` | Which source shadows this agent (`null` = active) |++#### `/agents create` Behavior++- **Argument parsing**: `--project` / `--local` are positional flags and must precede the name (e.g., `/agents create --project my-agent description`).+- **LLM generation**: By default, the current model auto-generates `when_to_use` and `system_prompt`; falls back to a built-in template on failure.+- **Auto-enable**: After creation, automatically writes `react.subagents.<name>.enabled = true` to `config.yaml` and hot-reloads the configuration.+- **Timeout**: 60 seconds.+- **Output**: Displays LLM generation marker, storage location, and file path.++#### `/agents update` Behavior++- **No description**: When no description is provided, shows current agent details (same as `get`) and prints usage.+- **`--generate`**: Explicitly triggers LLM prompt rewriting; without this flag, the request's template values are used.+- **Auto hot-reload**: Configuration is automatically reloaded after update.++#### `/agents enable` / `disable` Constraints++- Builtin agents (`source == "builtin"`) cannot be enabled/disabled; the backend returns an error.+- The operation writes to `config.yaml`'s `react.subagents.<name>.enabled` and hot-reloads.++#### `/agents delete` Constraints++- Builtin agents cannot be deleted.+- After deletion, the entry is automatically removed from `config.yaml`'s `react.subagents` and hot-reloaded.++#### `/agents get` Display++Displays all agent definition fields as key-value pairs, with the full System Prompt text appended at the end.++#### Tab Completion++The `get`, `update`, `enable`, `disable`, and `delete` subcommands support Tab completion on agent names (fetched via the `agents.list` RPC).++#### Examples++```bash+/agents # List all agents+/agents list # Same as above+/agents get Explore # View Explore agent details+/agents create bug-hunter Root cause analysis expert # Create user-level agent+/agents create --project proj-agent Project-level # Create project-level agent+/agents create --local local-agent Local use only # Create local agent+/agents update bug-hunter --generate Better description # Update with LLM prompt rewrite+/agents enable bug-hunter # Enable agent+/agents disable bug-hunter # Disable agent+/agents delete my-agent # Delete agent+```+### `/status` (Show Status)Display jiuwenswarm runtime status: overview, usage statistics, or config editor.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 10f28162b8..0aa2d09b9b 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"@@ -31,7 +31,9 @@| `/evolve_list` | 查看某个 Skill 的演进经验库(见下文) || `/evolve_simplify` | 整理、合并某个 Skill 的演进经验(见下文) || `/evolve_rebuild` | 基于归档与演进记录重建 `SKILL.md`(见下文) |+| `/hooks` | 浏览已配置的 hooks(只读,见下文) || `/sandbox` | 设置沙箱模式(见下文) |+| `/agents` | 管理 Agent 配置(list, get, create, update, enable, disable, delete,见下文) || `/auto-harness` | Auto-Harness 任务管理(`run`/`schedule`,见下文) |> 说明:本页的 `/mode` 与 `/switch` 以 Gateway 受控通道行为为主。TUI 本地命令另支持 `/mode plan`、`/mode team.normal`,详见 [TUI 使用指南](TUI使用指南.md)。@@ -523,6 +525,200 @@- `/sandbox files allow ./tmp/ 0777` — 允许沙箱以 0777 写入 `./tmp/`- `/sandbox exclude add "git *"` — 让 `git` 命令穿透到本地执行,不进沙箱+### `/hooks`(浏览 Hooks 配置)++查看当前 `config.yaml` 中配置的所有 hooks 的摘要信息(只读)。++#### 用法++- `/hooks`(无参数、无子命令)++#### 数据来源++TUI 通过 `hooks.list` RPC 请求 Gateway,Gateway 从 `config.yaml` 的 `hooks` 段加载配置并返回摘要。++#### 展示内容++`/hooks` 分三个层级展示 hooks 配置:++1. **事件列表(Level 1)**:按 hook 数量降序排列所有事件,每行显示事件名与 hook 数量,描述列显示各 matcher 的 hook 数量分布。+2. **状态面板**:+ - `Source` — 配置来源(`config.yaml`)+ - `Global Status` — 全局开关状态(`enabled` / `DISABLED`)+ - `Total Hooks` — 所有事件的 hook 总数+ - `Active Events` — 至少配置了 1 个 hook 的事件数 / 总事件数(共 17 种事件)+3. **Hook 详情卡片(Level 2)**:按 `事件 > matcher` 分组,每个 hook 展示:+ - `Type` — `command`(shell 命令)或 `prompt`(LLM 审查)+ - `Command` / `Prompt` — hook 的具体内容+ - `Timeout` — 超时时间(秒)+ - `Shell` — 执行 shell(command hook 专用)+ - `Status` — 状态消息++#### 无配置时++若 `config.yaml` 中没有配置任何 hooks,显示 `No hooks configured.` 并提示通过 `/config edit` 编辑配置。++#### Hooks 概念速览++Hooks 是在特定事件触发时自动执行的扩展逻辑,支持以下 17 种事件:++| 事件 | 执行层 | 触发时机 |+|---|---|---|+| `PreToolUse` | Agent Rail | 工具调用之前 |+| `PostToolUse` | Agent Rail | 工具调用成功之后 |+| `PostToolUseFailure` | Agent Rail | 工具调用失败之后 |+| `Stop` | Agent Rail | Agent 响应结束 |+| `PermissionRequest` | Agent Rail | 权限请求时 |+| `PermissionDenied` | Agent Rail | 权限被拒绝时 |+| `SubagentStart` | Agent Rail | 子 Agent 启动 |+| `SubagentStop` | Agent Rail | 子 Agent 停止 |+| `BeforeModelCall` | Agent Rail | 模型调用之前 |+| `AfterModelCall` | Agent Rail | 模型调用之后 |+| `UserPromptSubmit` | Gateway | 用户提交消息 |+| `SessionStart` | Gateway | 会话开始 |+| `SessionEnd` | Gateway | 会话结束 |+| `Notification` | Gateway | 通知发送 |+| `ConfigChange` | Gateway | 配置变更 |+| `InstructionsLoaded` | Gateway | 指令加载 |+| `Setup` | Gateway | 初始化 |++支持两种 hook 类型:++| 类型 | 说明 | 关键参数 |+|---|---|---|+| `command` | 执行 shell 命令(子进程)。通过环境变量 `$ARGUMENTS` 接收 JSON 上下文。退出码 0 = 成功,2 = 阻断。 | `command`、`timeout`(默认 30s)、`shell`(默认 bash) |+| `prompt` | 调用 LLM 审查。模板中 `$ARGUMENTS` 替换为 JSON 上下文,`$TOOL_NAME` 替换为工具名。LLM 响应中的 JSON `decision: "block"` 可阻断。 | `prompt`、`timeout`(默认 15s)、`model` |++- **阻断行为**:退出码 2(command)或 `decision: "block"`(prompt)会阻止当前操作(如跳过工具调用),并将原因反馈给模型。+- **输入修改**:PreToolUse hook 可通过 stdout JSON 的 `modifiedInput` 字段修改工具输入参数。+- **附加上下文**:可通过 stdout JSON 的 `additionalContext` 字段注入额外信息到工具结果或模型上下文。+- **全局开关**:`config.yaml` 中 `hooks.disable_all_hooks: true` 可禁用所有 hooks。++#### 配置示例++```yaml+hooks:+ PreToolUse:+ - matcher: "write_file"+ hooks:+ - type: command+ command: "echo 'write_file 即将执行' >> /tmp/hooks.log"+ timeout: 10+ - matcher: "bash|run_command"+ hooks:+ - type: prompt+ prompt: "审查以下命令是否安全: $ARGUMENTS"+ timeout: 20+ SessionStart:+ - matcher: "*"+ hooks:+ - type: command+ command: "echo '会话开始: $ARGUMENTS' >> /tmp/hooks.log"+```++#### 示例++- `/hooks` — 浏览当前所有 hooks 配置++### `/agents`(Agent 管理)++管理自定义 Agent(子代理 / Subagent)的全生命周期:查看、创建、更新、启用/禁用、删除。Agent 定义存储为 Markdown 文件,支持四级来源按优先级覆盖。++- **解析位置**:TUI 本地解析,通过 RPC 调用后端 `agents.*` 端点。+- **适用模式**:全部。+- **注意**:该命令在注册表中标记为隐藏(`hidden: true`),不在 `/help` 中列出,但可直接使用。++#### 子命令++| 命令 | 说明 |+|---|---|+| `/agents` 或 `/agents list` | 列出所有 Agent(名称、来源、启用状态、描述摘要) |+| `/agents get <name>` | 查看指定 Agent 完整详情(含 System Prompt 正文) |+| `/agents create [--project\|--local] <名称> <描述>` | 创建自定义 Agent,LLM 自动生成 prompt |+| `/agents update <name> [--generate] <新描述>` | 更新 Agent 描述;加 `--generate` 由 LLM 重写 prompt |+| `/agents enable <name>` | 启用自定义 Agent(内置 Agent 不可操作) |+| `/agents disable <name>` | 禁用自定义 Agent(内置 Agent 不可操作) |+| `/agents delete <name>` | 删除自定义 Agent(内置 Agent 不可操作) |++#### Agent 来源与存储++| 来源 | 存储位置 | 优先级 | 可管理 |+|------|----------|--------|--------|+| `builtin` | 代码内置 | 最低 | 不可启用/禁用/删除 |+| `local` | `<workspace>/.jiuwenswarm/agents-local/` | 本地 | 可全生命周期管理 |+| `user` | `~/.jiuwenswarm/agents/` | 用户 | 可全生命周期管理(默认 `create` 位置) |+| `project` | `<workspace>/.jiuwenswarm/agents/` | 最高 | 可全生命周期管理 |++同名 Agent 按 `project > user > local > builtin` 优先级覆盖,被覆盖的 Agent 标记 `shadowed_by`。++#### Agent 定义字段++| 字段 | 说明 |+|------|------|+| `name` | Agent 名称(唯一标识) |+| `description` | 简要描述 |+| `prompt` | System Prompt 正文 |+| `source` | 来源(`builtin` / `user` / `project` / `local`) |+| `file_path` | Agent 定义文件路径 |+| `model` | 指定模型(`null` 表示使用默认) |+| `tools` | 可用工具列表 |+| `disallowed_tools` | 禁用工具列表 |+| `color` | 显示颜色 |+| `permission_mode` | 权限模式 |+| `memory_scope` | 记忆范围 |+| `when_to_use` | 调用时机描述 |+| `max_iterations` | 最大迭代次数(默认 200) |+| `skills` | 关联技能列表 |+| `enabled` | 启用状态(`true` / `false` / `null`) |+| `shadowed_by` | 被哪个来源覆盖(`null` 表示活跃) |++#### `/agents create` 行为要点++- **参数解析**:`--project` / `--local` 为位置标志,需放在名称之前(如 `/agents create --project my-agent 描述`)。+- **LLM 生成**:默认调用当前模型自动生成 `when_to_use` 和 `system_prompt`,失败时回退到内置模板。+- **自动启用**:创建成功后自动写入 `config.yaml` 的 `react.subagents.<name>.enabled = true` 并热加载配置。+- **超时**:60 秒。+- **输出**:显示 LLM 生成标记、存储位置、文件路径。++#### `/agents update` 行为要点++- **无参数**:不提供描述时,展示当前 Agent 详情(等同 `get`)并提示用法。+- **`--generate`**:显式触发 LLM 重写 prompt;不加此标志时使用请求中的模板值。+- **自动热加载**:更新后自动重载 Agent 配置。++#### `/agents enable` / `disable` 约束++- 内置 Agent(`source == "builtin"`)无法启用/禁用,后端返回错误。+- 操作会写入 `config.yaml` 的 `react.subagents.<name>.enabled` 并热加载。++#### `/agents delete` 约束++- 内置 Agent 不可删除。+- 删除后自动从 `config.yaml` 的 `react.subagents` 中移除并热加载。++#### `/agents get` 展示内容++以键值对展示所有 Agent 定义字段,并在末尾完整输出 System Prompt 正文。++#### Tab 补全++`get`、`update`、`enable`、`disable`、`delete` 子命令支持按 Agent 名称 Tab 补全(通过 `agents.list` RPC 获取名称列表)。++#### 示例++```bash+/agents # 列出所有 Agent+/agents list # 同上+/agents get Explore # 查看 Explore Agent 详情+/agents create bug-hunter 根因分析专家 # 创建用户级 Agent+/agents create --project proj-agent 项目级 # 创建项目级 Agent+/agents create --local local-agent 本地专用 # 创建本地 Agent+/agents update bug-hunter --generate 更好的描述 # 更新并用 LLM 重写 prompt+/agents enable bug-hunter # 启用 Agent+/agents disable bug-hunter # 禁用 Agent+/agents delete my-agent # 删除 Agent+```+### `/status`(查看运行状态)显示 jiuwenswarm 运行状态概览、用量统计或配置编辑界面。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 f0d34eb50b..52d3f71ae8 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"@@ -57,6 +57,7 @@|------|------|------|------|----------|| `/help` | - | 列出已注册 Slash 命令 | `/help` | 全部 || `/hotkey` | - | 显示快捷键与 `/help` 提示 | `/hotkey` | 全部 |+| `/hooks` | - | 浏览已配置的 hooks(只读) | `/hooks` | 全部 || `/exit` | `/quit` | 退出 TUI | `/exit` | 全部 || `/clear` | `/reset`, `/new` | 新建会话 ID、清空当前 transcript(忙时拒绝) | `/clear` | 全部 || `/copy` | - | 复制最近第 N 条助手回复到剪贴板 | `/copy` 或 `/copy 2` | 全部 |@@ -83,6 +84,7 @@| `/workspace` | `/workspace_dir`, `/workspace-dir` | 管理文件操作可信目录 | `/workspace add .` | 全部 || `/export` | - | 导出当前会话到文件或剪贴板 | `/export`、`/export my-chat` | 全部 || `/status` | - | 查看运行状态概览、用量、配置 | `/status`、`/status usage` | 全部 |+| `/agents` | - | 管理 Agent 配置(list, get, create, update, enable, disable, delete) | `/agents list`、`/agents get Explore` | 全部 || `/branch` | `/fork` | 从当前对话点创建分支会话 | `/branch fix-login-bug` | 全部 || `/rewind` | `/checkpoint` | 回退对话到指定轮次之前 | `/rewind 2` | 全部 || `/memory` | `/mem` | 记忆管理(状态、文件、开关、目录) | `/memory status` | 全部 |@@ -115,6 +117,59 @@- `set`:重置为单个可信目录;若已有列表会二次确认。- 详见 [Slash命令表.md](Slash命令表.md) 的 `/workspace` 小节。+#### `/agents`(Agent 管理)++管理自定义 Agent(子代理)的全生命周期:查看、创建、更新、启用/禁用、删除。Agent 定义支持四级来源,按优先级 project > user > local > builtin 覆盖。++- **解析位置**:TUI 本地解析,通过 RPC 调用后端 `agents.*` 端点。+- **注意**:该命令在注册表中标记为 `hidden: true`,不会出现在 `/help` 列表中,但可以直接使用。++**子命令**:++| 子命令 | 用法 | 说明 |+|--------|------|------|+| `list` | `/agents list` | 列出所有 Agent(名称、来源、启用状态、描述) |+| `get` | `/agents get <name>` | 查看指定 Agent 详细信息(含 System Prompt 正文) |+| `create` | `/agents create [--project\|--local] <名称> <描述>` | 创建自定义 Agent,LLM 自动生成 prompt |+| `update` | `/agents update <name> [--generate] <新描述>` | 更新 Agent 描述;加 `--generate` 由 LLM 重写 prompt |+| `enable` | `/agents enable <name>` | 启用自定义 Agent |+| `disable` | `/agents disable <name>` | 禁用自定义 Agent |+| `delete` | `/agents delete <name>` | 删除自定义 Agent |++**Agent 来源**:++| 来源 | 存储位置 | 说明 |+|------|----------|------|+| `builtin` | 代码内置 | 系统预置 Agent,不可启用/禁用/删除 |+| `user` | `~/.jiuwenswarm/agents/` | 用户级 Agent(默认 `create` 位置) |+| `project` | `<workspace>/.jiuwenswarm/agents/` | 项目级 Agent(`--project`) |+| `local` | `<workspace>/.jiuwenswarm/agents-local/` | 本地 Agent(`--local`) |++**`create` 行为要点**:+- 默认由 LLM 自动生成 `when_to_use` 和 `system_prompt`(失败时回退到内置模板)。+- 创建成功后自动写入 `config.yaml` 的 `react.subagents.<name>.enabled = true` 并热加载。+- 响应面板显示 LLM 生成标记、文件路径。+- 超时:60 秒。++**`update` 行为要点**:+- 无描述参数时展示当前 Agent 详情(同 `get`)。+- `--generate` 标志触发 LLM 重写 prompt(默认不使用 LLM,用请求中的模板值)。+- 更新后自动热加载配置。++**`enable` / `disable` 约束**:+- 不能对内置 Agent(`source: builtin`)执行启用/禁用操作。++**`delete` 约束**:+- 删除后自动从 `config.yaml` 的 `react.subagents` 中移除并热加载。+- 内置 Agent 不可删除。++**`get` 详细信息字段**:+名称、描述、状态、来源、调用时机、模型、颜色、权限模式、记忆范围、最大迭代、工具列表、禁用工具、技能列表、文件路径、System Prompt 正文。++**无参数行为**:`/agents` 无参数时等同 `/agents list`,列出所有 Agent。++**Tab 补全**:`get`、`update`、`enable`、`disable`、`delete` 子命令支持按 Agent 名称 Tab 补全。+#### `/init`(仅 Code 模式)- 必须在 `code.*` 下执行;否则提示先 `/mode code`。@@ -267,6 +322,24 @@- add / remove 严格校验:`exclude add` 已存在 pattern、`exclude remove` 不存在 pattern 都会报错;`files allow|deny` 在同 bucket 已有 path 或对侧 bucket 已有 path(allow/deny 冲突)会报错,先 `files remove` 再 add;`files remove` 没匹配到也会报错。避免"看起来执行了实际什么也没改"。- 示例:`/sandbox enable`、`/sandbox status`、`/sandbox files allow ./tmp/ 0777`、`/sandbox exclude add "git *"`。+#### `/hooks`(浏览 Hooks 配置)++- 用法:`/hooks`(无参数、无子命令,只读)。+- 调用 `hooks.list` RPC 从 Gateway 获取 `config.yaml` 中 `hooks` 段的摘要。+- 展示:+ - **事件列表**:按 hook 数量降序排列,每行显示事件名、hook 数量、matcher 分布。+ - **状态面板**:配置来源(`config.yaml`)、全局开关(`enabled` / `DISABLED`)、Total Hooks、Active Events(有配置的事件数 / 17)。+ - **Hook 详情卡片**:每个 hook 按 Type、Command/Prompt、Timeout、Shell、Status 展示。+- 无配置时:显示 `No hooks configured.`,提示通过 `/config edit` 编辑配置。+- Hooks 概念:+ - **17 种触发事件**:Agent Rail 层(`PreToolUse`、`PostToolUse`、`PostToolUseFailure`、`Stop`、`PermissionRequest`、`PermissionDenied`、`SubagentStart`、`SubagentStop`、`BeforeModelCall`、`AfterModelCall`)和 Gateway 层(`UserPromptSubmit`、`SessionStart`、`SessionEnd`、`Notification`、`ConfigChange`、`InstructionsLoaded`、`Setup`)。+ - **2 种 Hook 类型**:`command`(执行 shell 命令,退出码 0 = 成功、2 = 阻断)和 `prompt`(LLM 审查,响应 JSON `decision: "block"` 阻断)。+ - **阻断行为**:PreToolUse 阻断可跳过工具调用并将原因反馈给模型。+ - **输入修改**:PreToolUse hook 可通过 stdout JSON 的 `modifiedInput` 修改工具参数。+ - **附加上下文**:可通过 stdout JSON 的 `additionalContext` 注入信息到工具结果或模型上下文。+ - **全局开关**:`config.yaml` 中 `hooks.disable_all_hooks: true` 禁用所有 hooks。+- 详见 [Slash命令表.md](Slash命令表.md) 的 `/hooks` 小节。+#### `/clear` 与忙状态- 若 `session is busy`(正在处理),`/clear` 会拒绝执行,需先中断任务(**`Ctrl+C`** 第一次中断;默认构建无 `/cancel` 命令)。diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/diff.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/diff.tsindex 1af4350a55..b7f9aa60e7 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/diff.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/diff.ts@@ -17,7 +17,7 @@ export function createDiffCommand(): SlashCommand {kind: CommandKind.BUILT_IN,action: async (ctx, args) => {try {- const showDetail = /\b--detail\b/.test(args || "");+ const showDetail = (args || "").split(/\s+/).filter(Boolean).includes("--detail");const payload = await ctx.request<DiffPayload>("command.diff", {});const turns = payload.turns || [];