@ai-zen/cli 1.0.0-alpha.2 → 1.0.0-alpha.22
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.
- package/CHANGELOG.md +514 -0
- package/README.md +136 -39
- package/README.zh.md +136 -39
- package/dist/agent-creator.d.ts +11 -0
- package/dist/agent-creator.d.ts.map +1 -1
- package/dist/agent-creator.js +52 -21
- package/dist/agent-creator.js.map +1 -1
- package/dist/agent-switch.d.ts +61 -0
- package/dist/agent-switch.d.ts.map +1 -0
- package/dist/agent-switch.js +83 -0
- package/dist/agent-switch.js.map +1 -0
- package/dist/agents-store.d.ts +6 -1
- package/dist/agents-store.d.ts.map +1 -1
- package/dist/agents-store.js +46 -4
- package/dist/agents-store.js.map +1 -1
- package/dist/auto-migrate-confirm.d.ts +43 -0
- package/dist/auto-migrate-confirm.d.ts.map +1 -0
- package/dist/auto-migrate-confirm.js +47 -0
- package/dist/auto-migrate-confirm.js.map +1 -0
- package/dist/config-editor.d.ts +13 -5
- package/dist/config-editor.d.ts.map +1 -1
- package/dist/config-editor.js +36 -27
- package/dist/config-editor.js.map +1 -1
- package/dist/config.d.ts +24 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +55 -15
- package/dist/config.js.map +1 -1
- package/dist/conversation-commands/registry.d.ts +123 -4
- package/dist/conversation-commands/registry.d.ts.map +1 -1
- package/dist/conversation-commands/registry.js +92 -14
- package/dist/conversation-commands/registry.js.map +1 -1
- package/dist/conversation-persist-plugin.d.ts +0 -1
- package/dist/conversation-persist-plugin.d.ts.map +1 -1
- package/dist/conversation-persist-plugin.js +7 -16
- package/dist/conversation-persist-plugin.js.map +1 -1
- package/dist/conversation-repository.d.ts +71 -13
- package/dist/conversation-repository.d.ts.map +1 -1
- package/dist/conversation-repository.js +81 -24
- package/dist/conversation-repository.js.map +1 -1
- package/dist/cwd-tracker-plugin.d.ts.map +1 -1
- package/dist/cwd-tracker-plugin.js +6 -2
- package/dist/cwd-tracker-plugin.js.map +1 -1
- package/dist/format-time.d.ts +17 -6
- package/dist/format-time.d.ts.map +1 -1
- package/dist/format-time.js +32 -14
- package/dist/format-time.js.map +1 -1
- package/dist/handoff-service.d.ts +19 -0
- package/dist/handoff-service.d.ts.map +1 -0
- package/dist/handoff-service.js +89 -0
- package/dist/handoff-service.js.map +1 -0
- package/dist/hook.d.ts.map +1 -1
- package/dist/hook.js +69 -15
- package/dist/hook.js.map +1 -1
- package/dist/i18n/en-wizard.d.ts +8 -0
- package/dist/i18n/en-wizard.d.ts.map +1 -0
- package/dist/i18n/en-wizard.js +290 -0
- package/dist/i18n/en-wizard.js.map +1 -0
- package/dist/i18n/en.d.ts +7 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +224 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +57 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +109 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/preferences.d.ts +34 -0
- package/dist/i18n/preferences.d.ts.map +1 -0
- package/dist/i18n/preferences.js +69 -0
- package/dist/i18n/preferences.js.map +1 -0
- package/dist/i18n/zh-wizard.d.ts +11 -0
- package/dist/i18n/zh-wizard.d.ts.map +1 -0
- package/dist/i18n/zh-wizard.js +293 -0
- package/dist/i18n/zh-wizard.js.map +1 -0
- package/dist/i18n/zh.d.ts +10 -0
- package/dist/i18n/zh.d.ts.map +1 -0
- package/dist/i18n/zh.js +228 -0
- package/dist/i18n/zh.js.map +1 -0
- package/dist/index.js +61 -25
- package/dist/index.js.map +1 -1
- package/dist/mcp-command.d.ts +32 -0
- package/dist/mcp-command.d.ts.map +1 -0
- package/dist/mcp-command.js +37 -0
- package/dist/mcp-command.js.map +1 -0
- package/dist/mode.d.ts +31 -4
- package/dist/mode.d.ts.map +1 -1
- package/dist/mode.js +42 -7
- package/dist/mode.js.map +1 -1
- package/dist/model-switch.d.ts +58 -0
- package/dist/model-switch.d.ts.map +1 -0
- package/dist/model-switch.js +62 -0
- package/dist/model-switch.js.map +1 -0
- package/dist/reasoning-effort.d.ts +96 -0
- package/dist/reasoning-effort.d.ts.map +1 -0
- package/dist/reasoning-effort.js +164 -0
- package/dist/reasoning-effort.js.map +1 -0
- package/dist/reasoning-presets.d.ts +34 -0
- package/dist/reasoning-presets.d.ts.map +1 -0
- package/dist/reasoning-presets.js +85 -0
- package/dist/reasoning-presets.js.map +1 -0
- package/dist/sdk-log.d.ts +55 -0
- package/dist/sdk-log.d.ts.map +1 -0
- package/dist/sdk-log.js +91 -0
- package/dist/sdk-log.js.map +1 -0
- package/dist/session-pointer.d.ts +22 -9
- package/dist/session-pointer.d.ts.map +1 -1
- package/dist/session-pointer.js +55 -23
- package/dist/session-pointer.js.map +1 -1
- package/dist/stdio-runner.d.ts.map +1 -1
- package/dist/stdio-runner.js +32 -30
- package/dist/stdio-runner.js.map +1 -1
- package/dist/sub-agent-guard-plugin.d.ts +5 -5
- package/dist/sub-agent-guard-plugin.d.ts.map +1 -1
- package/dist/sub-agent-guard-plugin.js +7 -7
- package/dist/sub-agent-guard-plugin.js.map +1 -1
- package/dist/tui/chat-session.d.ts +110 -59
- package/dist/tui/chat-session.d.ts.map +1 -1
- package/dist/tui/chat-session.js +268 -120
- package/dist/tui/chat-session.js.map +1 -1
- package/dist/tui/components.d.ts +48 -2
- package/dist/tui/components.d.ts.map +1 -1
- package/dist/tui/components.js +96 -3
- package/dist/tui/components.js.map +1 -1
- package/dist/tui/config-wizard/detail.d.ts +12 -6
- package/dist/tui/config-wizard/detail.d.ts.map +1 -1
- package/dist/tui/config-wizard/detail.js +33 -32
- package/dist/tui/config-wizard/detail.js.map +1 -1
- package/dist/tui/config-wizard/engine.d.ts.map +1 -1
- package/dist/tui/config-wizard/engine.js +27 -21
- package/dist/tui/config-wizard/engine.js.map +1 -1
- package/dist/tui/config-wizard/fields.d.ts +3 -1
- package/dist/tui/config-wizard/fields.d.ts.map +1 -1
- package/dist/tui/config-wizard/fields.js +216 -152
- package/dist/tui/config-wizard/fields.js.map +1 -1
- package/dist/tui/config-wizard/kv-editor.d.ts.map +1 -1
- package/dist/tui/config-wizard/kv-editor.js +9 -5
- package/dist/tui/config-wizard/kv-editor.js.map +1 -1
- package/dist/tui/config-wizard/list.d.ts.map +1 -1
- package/dist/tui/config-wizard/list.js +2 -1
- package/dist/tui/config-wizard/list.js.map +1 -1
- package/dist/tui/config-wizard/mcp-helpers.d.ts.map +1 -1
- package/dist/tui/config-wizard/mcp-helpers.js +4 -3
- package/dist/tui/config-wizard/mcp-helpers.js.map +1 -1
- package/dist/tui/config-wizard/menu.d.ts.map +1 -1
- package/dist/tui/config-wizard/menu.js +33 -21
- package/dist/tui/config-wizard/menu.js.map +1 -1
- package/dist/tui/config-wizard/prompt-editor.d.ts.map +1 -1
- package/dist/tui/config-wizard/prompt-editor.js +4 -3
- package/dist/tui/config-wizard/prompt-editor.js.map +1 -1
- package/dist/tui/config-wizard/prompt.d.ts.map +1 -1
- package/dist/tui/config-wizard/prompt.js +8 -7
- package/dist/tui/config-wizard/prompt.js.map +1 -1
- package/dist/tui/config-wizard/step-agents.d.ts.map +1 -1
- package/dist/tui/config-wizard/step-agents.js +29 -20
- package/dist/tui/config-wizard/step-agents.js.map +1 -1
- package/dist/tui/config-wizard/step-defaults.d.ts.map +1 -1
- package/dist/tui/config-wizard/step-defaults.js +24 -27
- package/dist/tui/config-wizard/step-defaults.js.map +1 -1
- package/dist/tui/config-wizard/step-endpoints.d.ts.map +1 -1
- package/dist/tui/config-wizard/step-endpoints.js +16 -6
- package/dist/tui/config-wizard/step-endpoints.js.map +1 -1
- package/dist/tui/config-wizard/step-mcp.d.ts.map +1 -1
- package/dist/tui/config-wizard/step-mcp.js +17 -19
- package/dist/tui/config-wizard/step-mcp.js.map +1 -1
- package/dist/tui/config-wizard/step-models.d.ts.map +1 -1
- package/dist/tui/config-wizard/step-models.js +41 -26
- package/dist/tui/config-wizard/step-models.js.map +1 -1
- package/dist/tui/config-wizard/step-new-endpoint.d.ts.map +1 -1
- package/dist/tui/config-wizard/step-new-endpoint.js +16 -12
- package/dist/tui/config-wizard/step-new-endpoint.js.map +1 -1
- package/dist/tui/config-wizard/step-simple.d.ts.map +1 -1
- package/dist/tui/config-wizard/step-simple.js +18 -17
- package/dist/tui/config-wizard/step-simple.js.map +1 -1
- package/dist/tui/config-wizard/types.d.ts +18 -3
- package/dist/tui/config-wizard/types.d.ts.map +1 -1
- package/dist/tui/config-wizard/wizard.d.ts.map +1 -1
- package/dist/tui/config-wizard/wizard.js +4 -3
- package/dist/tui/config-wizard/wizard.js.map +1 -1
- package/dist/tui/highlight.d.ts +3 -2
- package/dist/tui/highlight.d.ts.map +1 -1
- package/dist/tui/highlight.js +3 -2
- package/dist/tui/highlight.js.map +1 -1
- package/dist/tui/index.d.ts +18 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +107 -49
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/input-editing.d.ts +52 -0
- package/dist/tui/input-editing.d.ts.map +1 -0
- package/dist/tui/input-editing.js +91 -0
- package/dist/tui/input-editing.js.map +1 -0
- package/dist/tui/key-debug.d.ts +62 -0
- package/dist/tui/key-debug.d.ts.map +1 -0
- package/dist/tui/key-debug.js +92 -0
- package/dist/tui/key-debug.js.map +1 -0
- package/dist/tui/mouse.d.ts +55 -0
- package/dist/tui/mouse.d.ts.map +1 -0
- package/dist/tui/mouse.js +74 -0
- package/dist/tui/mouse.js.map +1 -0
- package/dist/tui/phase.d.ts +64 -0
- package/dist/tui/phase.d.ts.map +1 -0
- package/dist/tui/phase.js +112 -0
- package/dist/tui/phase.js.map +1 -0
- package/dist/tui/screens/chat-commands.d.ts +64 -3
- package/dist/tui/screens/chat-commands.d.ts.map +1 -1
- package/dist/tui/screens/chat-commands.js +483 -157
- package/dist/tui/screens/chat-commands.js.map +1 -1
- package/dist/tui/screens/chat.d.ts +10 -5
- package/dist/tui/screens/chat.d.ts.map +1 -1
- package/dist/tui/screens/chat.js +464 -301
- package/dist/tui/screens/chat.js.map +1 -1
- package/dist/tui/screens/common-keys.d.ts +36 -0
- package/dist/tui/screens/common-keys.d.ts.map +1 -0
- package/dist/tui/screens/common-keys.js +67 -0
- package/dist/tui/screens/common-keys.js.map +1 -0
- package/dist/tui/screens/frame-buffer.d.ts +47 -0
- package/dist/tui/screens/frame-buffer.d.ts.map +1 -0
- package/dist/tui/screens/frame-buffer.js +78 -0
- package/dist/tui/screens/frame-buffer.js.map +1 -0
- package/dist/tui/screens/handoff-choice.d.ts +37 -0
- package/dist/tui/screens/handoff-choice.d.ts.map +1 -0
- package/dist/tui/screens/handoff-choice.js +42 -0
- package/dist/tui/screens/handoff-choice.js.map +1 -0
- package/dist/tui/screens/index.d.ts +8 -8
- package/dist/tui/screens/index.d.ts.map +1 -1
- package/dist/tui/screens/index.js +7 -7
- package/dist/tui/screens/index.js.map +1 -1
- package/dist/tui/screens/input-row.d.ts +64 -0
- package/dist/tui/screens/input-row.d.ts.map +1 -0
- package/dist/tui/screens/input-row.js +67 -0
- package/dist/tui/screens/input-row.js.map +1 -0
- package/dist/tui/screens/input.d.ts +46 -1
- package/dist/tui/screens/input.d.ts.map +1 -1
- package/dist/tui/screens/input.js +83 -8
- package/dist/tui/screens/input.js.map +1 -1
- package/dist/tui/screens/layout.d.ts +21 -3
- package/dist/tui/screens/layout.d.ts.map +1 -1
- package/dist/tui/screens/layout.js +20 -9
- package/dist/tui/screens/layout.js.map +1 -1
- package/dist/tui/screens/lines.d.ts +12 -41
- package/dist/tui/screens/lines.d.ts.map +1 -1
- package/dist/tui/screens/lines.js +90 -98
- package/dist/tui/screens/lines.js.map +1 -1
- package/dist/tui/screens/messages-view.d.ts +10 -0
- package/dist/tui/screens/messages-view.d.ts.map +1 -0
- package/dist/tui/screens/messages-view.js +116 -0
- package/dist/tui/screens/messages-view.js.map +1 -0
- package/dist/tui/screens/notice-bar.d.ts +5 -0
- package/dist/tui/screens/notice-bar.d.ts.map +1 -0
- package/dist/tui/screens/notice-bar.js +15 -0
- package/dist/tui/screens/notice-bar.js.map +1 -0
- package/dist/tui/screens/notice.d.ts +64 -0
- package/dist/tui/screens/notice.d.ts.map +1 -0
- package/dist/tui/screens/notice.js +106 -0
- package/dist/tui/screens/notice.js.map +1 -0
- package/dist/tui/screens/overlays.d.ts.map +1 -1
- package/dist/tui/screens/overlays.js +3 -2
- package/dist/tui/screens/overlays.js.map +1 -1
- package/dist/tui/screens/render.d.ts +2 -4
- package/dist/tui/screens/render.d.ts.map +1 -1
- package/dist/tui/screens/render.js +7 -43
- package/dist/tui/screens/render.js.map +1 -1
- package/dist/tui/screens/splash.d.ts +1 -1
- package/dist/tui/screens/splash.d.ts.map +1 -1
- package/dist/tui/screens/splash.js +12 -3
- package/dist/tui/screens/splash.js.map +1 -1
- package/dist/tui/screens/use-chat-viewport.d.ts +22 -0
- package/dist/tui/screens/use-chat-viewport.d.ts.map +1 -0
- package/dist/tui/screens/use-chat-viewport.js +50 -0
- package/dist/tui/screens/use-chat-viewport.js.map +1 -0
- package/dist/tui/screens/use-input-editing.d.ts +44 -0
- package/dist/tui/screens/use-input-editing.d.ts.map +1 -0
- package/dist/tui/screens/use-input-editing.js +192 -0
- package/dist/tui/screens/use-input-editing.js.map +1 -0
- package/dist/tui/screens/use-overlays.d.ts +25 -0
- package/dist/tui/screens/use-overlays.d.ts.map +1 -0
- package/dist/tui/screens/use-overlays.js +32 -0
- package/dist/tui/screens/use-overlays.js.map +1 -0
- package/dist/tui/screens/use-wizard-host.d.ts +35 -0
- package/dist/tui/screens/use-wizard-host.d.ts.map +1 -0
- package/dist/tui/screens/use-wizard-host.js +103 -0
- package/dist/tui/screens/use-wizard-host.js.map +1 -0
- package/dist/tui/status-segments.d.ts +37 -0
- package/dist/tui/status-segments.d.ts.map +1 -0
- package/dist/tui/status-segments.js +166 -0
- package/dist/tui/status-segments.js.map +1 -0
- package/dist/tui/text.d.ts +20 -7
- package/dist/tui/text.d.ts.map +1 -1
- package/dist/tui/text.js +111 -37
- package/dist/tui/text.js.map +1 -1
- package/dist/tui/theme.d.ts +7 -1
- package/dist/tui/theme.d.ts.map +1 -1
- package/dist/tui/theme.js +15 -3
- package/dist/tui/theme.js.map +1 -1
- package/dist/tui/token-rate.d.ts +83 -0
- package/dist/tui/token-rate.d.ts.map +1 -0
- package/dist/tui/token-rate.js +195 -0
- package/dist/tui/token-rate.js.map +1 -0
- package/dist/types.d.ts +7 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/auto-migrate-confirm-plugin.d.ts +0 -58
- package/dist/auto-migrate-confirm-plugin.d.ts.map +0 -1
- package/dist/auto-migrate-confirm-plugin.js +0 -61
- package/dist/auto-migrate-confirm-plugin.js.map +0 -1
- package/dist/migration-service.d.ts +0 -15
- package/dist/migration-service.d.ts.map +0 -1
- package/dist/migration-service.js +0 -59
- package/dist/migration-service.js.map +0 -1
- package/dist/tui/screens/state.d.ts +0 -13
- package/dist/tui/screens/state.d.ts.map +0 -1
- package/dist/tui/screens/state.js +0 -75
- package/dist/tui/screens/state.js.map +0 -1
package/README.md
CHANGED
|
@@ -66,12 +66,81 @@ When run with no arguments on an interactive terminal, the CLI opens a full-scre
|
|
|
66
66
|
╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝╚═╝ ╚═══╝
|
|
67
67
|
|
|
68
68
|
AI workbench in your terminal
|
|
69
|
-
v1.0.0-alpha.
|
|
69
|
+
v1.0.0-alpha.21 · sdk x · core y
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
After the splash, you land **directly in the chat screen** (resuming the last session if there is one, otherwise starting a new conversation). The chat screen is **bottom-pinned**: a divider, the input line, and
|
|
72
|
+
After the splash, you land **directly in the chat screen** (resuming the last session if there is one, otherwise starting a new conversation). The chat screen is **bottom-pinned**: a divider, the input line, and a **status bar** (three priority-ordered blocks: model · agent · reasoning effort | this-round / cumulative tokens · generation rate | key hints; a block that does not fit moves to the next line whole, so nothing is truncated and no block gets split) always sit at the bottom of the terminal, while the conversation scrolls above them. While generating, the spinner replaces the input line and its label shows **which phase** the round is in: connecting → queued (waiting for the first token) → thinking → calling a tool → waiting for the tool to return → streaming; the two tool phases include the tool name. The generation rate shows a live value while streaming (2-second sliding window, estimated from output deltas) and switches to this round's average once it finishes (preferring the real `completion_tokens` from the API).
|
|
73
73
|
|
|
74
|
-
The chat screen provides a streaming output area (reasoning / answer / tool calls on separate lines), a multiline input (`Enter` sends; `Ctrl+N` inserts a newline; `← →` move the cursor, `Ctrl+← →` by word), and an inline `/` command menu (↑↓ to choose, `Tab` to complete). Tool calls render as `⚙ name(args)` with **JSON syntax highlighting
|
|
74
|
+
The chat screen provides a streaming output area (reasoning / answer / tool calls on separate lines), a multiline input (`Enter` sends; `Ctrl+N` inserts a newline; `← →` move the cursor, `Ctrl+← →` by word; `Ctrl+W` / `Alt+Backspace` delete the previous word, `Alt+D` / `Ctrl+Delete` the next word; `Ctrl+K` kills to end of line; `Ctrl+U` kills to line start; `PgUp`/`PgDn` (or `Alt+V`/`Ctrl+V`) scroll the transcript, the mouse wheel scrolls by line; on macOS `⌘← →` moves by word, `⌘⌫`/`⌘⌦` deletes by word, `⌘[`/`⌘]` pages and `⌘;`/`⌘'` scrolls by line (depending on whether the terminal reports Cmd — see below)., and an inline `/` command menu (↑↓ to choose, `Tab` to complete). Tool calls render as `⚙ name(args)` with **JSON syntax highlighting**; the answer / reasoning is **Markdown-source-colored** (headings, bold, italic, inline code, lists, quotes, links), and fenced code blocks are **syntax-highlighted by language with the fence markers kept** (highlight data from `highlight.js` via `lowlight`). `Ctrl+C` cancels the current request while generating, and exits when idle.
|
|
75
|
+
|
|
76
|
+
### Keyboard & terminal compatibility (macOS, etc.)
|
|
77
|
+
|
|
78
|
+
The convention for terminal TUIs on macOS is **Option-as-Meta plus readline-style Ctrl keys**: `Cmd` is not part of the terminal protocol (`super` is only reported under the [kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/)), so `⌘` is left to the terminal itself (copy / paste / search). This CLI follows that convention.
|
|
79
|
+
|
|
80
|
+
**Step one: make Option act as Meta.** macOS terminals do not send the Option modifier by default — until you enable it, every `Option+X` shortcut does nothing:
|
|
81
|
+
|
|
82
|
+
| Terminal | Setting |
|
|
83
|
+
|---|---|
|
|
84
|
+
| Apple Terminal | Settings → Profiles → Keyboard → check **Use Option as Meta Key** |
|
|
85
|
+
| iTerm2 | Settings → Profiles → Keys → General → Left/Right Option key = `Esc+` |
|
|
86
|
+
| VS Code / Cursor | add `"terminal.integrated.macOptionIsMeta": true` to settings |
|
|
87
|
+
| Ghostty / kitty / WezTerm | enable Option-as-Alt / Option-as-Meta in the config |
|
|
88
|
+
|
|
89
|
+
Key map (aligned with [Claude Code](https://docs.claude.com/en/docs/claude-code/interactive-mode)):
|
|
90
|
+
|
|
91
|
+
| Keys | Action |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `Enter` | Send |
|
|
94
|
+
| `Ctrl+J`, `Ctrl+Enter`, `Alt+Enter`, `Shift+Enter` | Newline |
|
|
95
|
+
| `Ctrl+C` | While generating: interrupt; when idle: clear the draft, press again to exit |
|
|
96
|
+
| `Ctrl+D` | With a draft: delete the character after the cursor; empty input: press twice to exit |
|
|
97
|
+
| `Esc` | While generating: interrupt; otherwise clear the draft and jump to the bottom |
|
|
98
|
+
| `Ctrl+A` / `Ctrl+E` | Line start / end |
|
|
99
|
+
| `Ctrl+P` / `Ctrl+N` | Previous / next history entry (also moves the slash menu) |
|
|
100
|
+
| `Ctrl+K` / `Ctrl+U` | Kill to line end / line start |
|
|
101
|
+
| `Ctrl+W` | Kill back to the previous whitespace (punctuation does not split: `src/utils/foo.ts` goes in one press) |
|
|
102
|
+
| `Alt+B` / `Alt+F` | Move by word |
|
|
103
|
+
| `Alt+D`, `Alt+Backspace`, `Ctrl+Delete` | Delete by word |
|
|
104
|
+
| `Ctrl+Y` / `Alt+Y` | Yank the last killed text / cycle older entries |
|
|
105
|
+
| `Ctrl+_` | Undo the last input edit |
|
|
106
|
+
| `Ctrl+S` | Stash the draft / press again to restore |
|
|
107
|
+
| `Ctrl+V` | Reserved for image paste (**not implemented yet**; shows a notice) |
|
|
108
|
+
| `Ctrl+L` | Clear the screen (context kept) |
|
|
109
|
+
| `PgUp` / `PgDn` | Page through the transcript |
|
|
110
|
+
| Mouse wheel | Scroll by line (3 lines per notch). With mouse reporting on, text selection needs `Shift` (native terminal selection); `tmux` users need `set -g mouse off`, otherwise the wheel is swallowed by copy-mode |
|
|
111
|
+
| `Shift+↑ ↓`, `Alt+↑ ↓`, `⌘;` / `⌘'`* | Scroll by line |
|
|
112
|
+
| `\` + `Enter` | Newline (works in any terminal) |
|
|
113
|
+
|
|
114
|
+
> After an interrupt (`Ctrl+C` / `Esc`), **the reasoning and content the model already produced stay in the context** — on the next turn it picks up that half-finished sentence instead of pretending it never said it. Use `/new` if you want a clean slate. Tool rounds are still reconciled all-in or all-out: unfinished tools get a reason backfilled, so no illegal "call without result" history is left behind.
|
|
115
|
+
|
|
116
|
+
Not implemented (no counterpart here): `Ctrl+O` transcript viewer, `Ctrl+R` reverse search, `Ctrl+B` background tasks, `Ctrl+T` task list, `Shift+Tab` permission modes.
|
|
117
|
+
|
|
118
|
+
`Ctrl+V` (Claude Code's "paste image") is **not implemented yet** — pressing it shows a notice. It first needs a proper "file → content block" capability probe (Files API upload vs base64 inline) instead of hard-coding a single endpoint. Note that macOS maps `⌘⌫` to `Ctrl+U`, which is why `Ctrl+U` kills to line start here; use `Esc` to clear the draft.
|
|
119
|
+
|
|
120
|
+
\* `⌘` combos only carry the `super` bit when the terminal **enables the kitty keyboard protocol** (and for iTerm2, when Cmd is mapped to Super). Terminals without it (e.g. Apple Terminal) can only map `⌘` to `ESC` sequences (e.g. `⌘←` → `ESC[1;9D`, equivalent to `Alt+←`), or you can use the Alt combos above.
|
|
121
|
+
|
|
122
|
+
> macOS maps `⌘⌫` to `Ctrl+U` in iTerm2 and Terminal.app, which is why `Ctrl+U` here follows readline semantics (delete to line start): making it "clear everything" would throw away the whole draft whenever a Mac user presses `⌘⌫`.
|
|
123
|
+
|
|
124
|
+
> On macOS `Ctrl+← →` is usually swallowed by the system: Mission Control binds it to "Move left/right a space". Uncheck it under System Settings → Keyboard → Keyboard Shortcuts → Mission Control.
|
|
125
|
+
|
|
126
|
+
If a key still does nothing, turn on the key diagnostics and press it once:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
AIZ_DEBUG_KEYS=1 aiz
|
|
130
|
+
# in another shell
|
|
131
|
+
tail -f /tmp/aiz-key-debug.log
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The first line records the terminal environment (`TERM`, `TERM_PROGRAM`, ...); every keypress then appends one line:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
key input="d" flags=[meta] raw=true
|
|
138
|
+
key input="" flags=[pageUp] raw=false
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **No new line after pressing** → the key never reached the app (system shortcut / terminal key mapping)
|
|
142
|
+
- **Line present but `flags` unexpected** → the sequence arrived; the matching logic is at fault (paste that line in a report)
|
|
143
|
+
- **`raw=false`** → stdin was not in raw mode, so the terminal interpreted the key itself (e.g. scrolled its scrollback)
|
|
75
144
|
|
|
76
145
|
### First-run setup (API Key)
|
|
77
146
|
|
|
@@ -92,6 +161,19 @@ On first launch, if the endpoint bound to the selected model has no API Key yet,
|
|
|
92
161
|
|
|
93
162
|
Every conversation is persisted directly as its own file (`cli/conversations/<id>.json`) while you chat — there is no separate draft store. A single pointer (`cli/last-session.json`) remembers the **last session id**; next time you start `ai`, that session is **resumed automatically** so you pick up where you left off.
|
|
94
163
|
|
|
164
|
+
### UI language (Chinese / English)
|
|
165
|
+
|
|
166
|
+
On first launch the language is detected from the system: `LC_ALL` → `LC_MESSAGES` → `LANG` → the system `Intl` locale, **falling back to English**. The result is stored in `~/.ai-zen/cli/preferences.json`; from then on the stored preference wins, so changing the system language will not make the UI drift. `/lang` toggles at any time (no argument flips between the two), and `/lang zh` / `/lang en` select one directly.
|
|
167
|
+
|
|
168
|
+
The preference lives in the CLI's own `preferences.json`, **not in the shared `config.json`** — the latter is the config contract shared by the CLI and the Desktop app.
|
|
169
|
+
|
|
170
|
+
The whole TUI is covered (chat screen, commands and `/help`, every configuration-center screen, the handoff picker, the splash / boot-error screens), plus the terminal output of `ai --help` and `ai hook install / uninstall`. **Deliberately not translated:**
|
|
171
|
+
|
|
172
|
+
- **pipe mode (`ai "prompt"` / piped input) prints and errors in English only** — it is meant for scripts and should not follow a human user's UI language;
|
|
173
|
+
- the working-directory note injected into the model's history: English plus a `[system-injected: …]` marker saying it was not typed by the user. This is the only piece of protocol content left untranslated (the `task` parameter description of a new Sub-agent does follow the UI language);
|
|
174
|
+
- the three code-block markers `ai hook` writes into `~/.bashrc` (`# === ai hook … ===`) — translating them would lose track of the old block;
|
|
175
|
+
- the conversation-id stamp `chat_YYYY_MM_DD_HH_mm_ss` — it doubles as the file name, so following the UI language would interleave old and new files.
|
|
176
|
+
|
|
95
177
|
### Conversation Commands
|
|
96
178
|
|
|
97
179
|
While in a conversation, all commands start with `/`. Typing `/` lists the available commands, with descriptions, right below the input line; typing more characters narrows the candidates by prefix:
|
|
@@ -105,34 +187,39 @@ While in a conversation, all commands start with `/`. Typing `/` lists the avail
|
|
|
105
187
|
|
|
106
188
|
| Command | Description |
|
|
107
189
|
|---------|-------------|
|
|
108
|
-
| `/exit` `/quit` | Exit the conversation |
|
|
109
|
-
| `/save` | Save the
|
|
110
|
-
| `/load` | Load a
|
|
190
|
+
| `/exit` `/quit` | Exit the conversation (offers to save) |
|
|
191
|
+
| `/save` | Save the conversation (already flushed every turn) |
|
|
192
|
+
| `/load` | Load a conversation (replaces this one) |
|
|
111
193
|
| `/new` | Reset the conversation (clear history) |
|
|
112
|
-
| `/back` |
|
|
113
|
-
| `/editor` |
|
|
194
|
+
| `/back` | Retract a message (roll back to a point and resend) |
|
|
195
|
+
| `/editor` | Compose a long message in your editor (vim/nano) |
|
|
114
196
|
| `/clear` | Clear the screen |
|
|
115
|
-
| `/config` | Open the configuration center (endpoints / models / image models / MCP
|
|
116
|
-
| `/
|
|
117
|
-
| `/
|
|
118
|
-
| `/
|
|
197
|
+
| `/config` | Open the configuration center (endpoints / models / image models / MCP / agent definitions / defaults / tool-output cap) |
|
|
198
|
+
| `/model` | Switch model (writes the Agent's `modelId`; thinking level resets to the model default) |
|
|
199
|
+
| `/agent` | Switch the main Agent (writes `defaultAgent` and rebuilds the session; unusable Agents are marked with the reason) |
|
|
200
|
+
| `/reload` | Refresh the runtime (rediscovers tools / MCP; messages and context are kept) |
|
|
201
|
+
| `/mcp` | Manage MCP servers (add / remove / edit / toggle; `/mcp global` and `/mcp project` pick a scope) |
|
|
202
|
+
| `/lang` | Switch the interface language (`/lang zh`, `/lang en` set it explicitly; no argument toggles) |
|
|
203
|
+
| `/think` `/effort` | Switch reasoning effort (`/think default` follows the model default) |
|
|
204
|
+
| `/key` | Set the endpoint API key (rebuilds the session on save) |
|
|
205
|
+
| `/handoff` | Write a handoff document (keeps the session) |
|
|
206
|
+
| `/migrate` | Hand off and start a new session |
|
|
207
|
+
| `/help` | Show help |
|
|
119
208
|
|
|
120
|
-
###
|
|
209
|
+
### Task Handoff & Migration
|
|
121
210
|
|
|
122
|
-
|
|
211
|
+
Two related commands, one pipeline:
|
|
123
212
|
|
|
124
|
-
|
|
213
|
+
- **`/handoff`** — the original agent stops what it is doing and writes a handoff document to `<project>/.ai-zen/handoffs/<timestamp>-<conversation id>.md`, using its own tools to verify the real state (branch, uncommitted changes, tests, ports). The session keeps running, so you can keep refining the document.
|
|
214
|
+
- **`/migrate`** — the same handoff, then history is cleared and a new session starts from the document (the breakpoint message carries only the path; the new agent reads it).
|
|
125
215
|
|
|
126
|
-
|
|
216
|
+
Two executors: `self` (default — the original agent writes it in-session, highest fidelity) and `summary` (a single independent model call, cheap but lossy). `self` degrades to `summary` one-way on failure. Pass it explicitly with `/handoff summary` or `/migrate self`.
|
|
217
|
+
|
|
218
|
+
When `usage.prompt_tokens` exceeds the model's `tokenThresholds.handoff`, an interactive terminal shows a three-way picker (self / summary / skip); non-interactive pipes migrate with the default executor without blocking.
|
|
127
219
|
|
|
128
|
-
The migration
|
|
129
|
-
- **Conversation Breakpoint** — Last user/AI exchange verbatim
|
|
130
|
-
- **Completed Tasks** — Task titles and output paths
|
|
131
|
-
- **Pending Tasks** — Description, progress, next steps
|
|
132
|
-
- **Important Notes** — Technical preferences, lessons learned, architecture decisions
|
|
133
|
-
- **File Index** — Key files with descriptions
|
|
134
|
-
- **Handover Instructions** — SOP for the relay agent (read files first, verify state, then act)
|
|
220
|
+
The document template is not hard-coded: it comes from the `handoff` Skill (`~/.ai-zen/skills/handoff/SKILL.md`, released and synced by the SDK; mark `metadata.custom: "true"` to keep your own version, or override per project). See [Task Handoff & Migration](./docs/en/migration.md) for the full chain, cost notes, and the template sections.
|
|
135
221
|
|
|
222
|
+
The same context guard also applies to **sub-agents**: at each delegation boundary (`onSubAgentStart`) the CLI installs the same `ContextGuardPlugin` (same `maxTokens`) onto the newly built sub-agent, so a delegated sub-agent (including the Skill sub-agent created by `call_skill_sub_agent`) is interrupted as soon as its context exceeds the hard limit. This is transparent — a normally-running sub-agent is unaffected.
|
|
136
223
|
### Shell Fallback Hook
|
|
137
224
|
|
|
138
225
|
When you type an unrecognized command in your terminal, it can be automatically forwarded to AI for processing:
|
|
@@ -149,7 +236,11 @@ ai hook install
|
|
|
149
236
|
ai hook uninstall
|
|
150
237
|
```
|
|
151
238
|
|
|
152
|
-
The hook calls
|
|
239
|
+
The hook calls **`ai --tui --new "$@"`**: it opens the interactive UI and **auto-sends the mistyped command as the first message**. A hook fires when a human at an interactive prompt typed something wrong, so it should open the TUI (you can follow up, and there is history) rather than dump a paragraph to stdout and exit. `--new` additionally makes each hook session a **fresh conversation**, instead of appending the mistyped command to whatever you had been doing in that directory. If you installed an older hook, re-running `ai hook install` upgrades it in place — the installed function body is compared with the current one and overwritten when it differs; you can also `ai hook uninstall` first.
|
|
240
|
+
|
|
241
|
+
`--tui` is usable by hand too: `ai --tui explain this error` opens the TUI and sends it. In a non-TTY environment (a script or a pipe) it fails with an error instead of degrading to pipe mode — otherwise the whole full-screen UI would be written into the pipe.
|
|
242
|
+
|
|
243
|
+
`--new` works on its own as well: `ai --new` starts a fresh conversation instead of resuming the last one in this directory. It only affects the TUI path; in stdio mode it is ignored (a stdio run is always a one-off session).
|
|
153
244
|
|
|
154
245
|
## Configuration
|
|
155
246
|
|
|
@@ -162,7 +253,7 @@ Configuration is stored in `~/.ai-zen/config.json` (or `$AI_ZEN_DIR/config.json`
|
|
|
162
253
|
| Endpoints / models / image models, MCP servers, agent definitions (incl. sub-agents), defaults, tool-output cap | `/config` (the configuration center — full management) |
|
|
163
254
|
| Other advanced fields (skills / user tools, …) | Edit the files under `~/.ai-zen/` manually |
|
|
164
255
|
|
|
165
|
-
The `
|
|
256
|
+
The `tokenThresholds` field on each model sets two usage lines: `handoff` (soft — a handoff is triggered above it) and `guard` (hard — the round is aborted above it, before the request). Both are absolute values; `guard ≈ handoff × 1.5` is recommended (typically ~25% of the model's actual context window for `handoff`, e.g. 250,000 for a 1M-token model).
|
|
166
257
|
|
|
167
258
|
```jsonc
|
|
168
259
|
{
|
|
@@ -180,7 +271,8 @@ The `maxContextTokens` field on each model sets the migration threshold (typical
|
|
|
180
271
|
"name": "GPT-6.1 Sol",
|
|
181
272
|
"endpointId": "openai",
|
|
182
273
|
"modelName": "gpt-6.1-sol",
|
|
183
|
-
"
|
|
274
|
+
"tokenThresholds": { "handoff": 250000, "guard": 375000 },
|
|
275
|
+
"reasoningPreset": "openai",
|
|
184
276
|
"custom": true
|
|
185
277
|
}
|
|
186
278
|
],
|
|
@@ -193,7 +285,6 @@ The `maxContextTokens` field on each model sets the migration threshold (typical
|
|
|
193
285
|
"defaultSize": "1024x1024"
|
|
194
286
|
}
|
|
195
287
|
],
|
|
196
|
-
"defaultModel": "deepseek-flash",
|
|
197
288
|
"defaultImageModel": "cogview-4",
|
|
198
289
|
"defaultAgent": "default",
|
|
199
290
|
"defaultMigrationModel": "deepseek-flash"
|
|
@@ -201,10 +292,14 @@ The `maxContextTokens` field on each model sets the migration threshold (typical
|
|
|
201
292
|
```
|
|
202
293
|
|
|
203
294
|
> Note: entries in `models` / `imageModels` **without `custom: true`** are **factory-managed** — on every launch they are reconciled with (and replaced by) the SDK factory catalog; add `"custom": true` for your own entries. `endpoints` are never managed and always keep your configuration.
|
|
295
|
+
>
|
|
296
|
+
> The model is **not** selected in `config.json`: each Agent binds one in its own definition file (`agents/<id>.json`, field `modelId`), which is the single source of truth at runtime. `/model` writes exactly that field.
|
|
204
297
|
|
|
205
298
|
### Environment Variable
|
|
206
299
|
|
|
207
300
|
- `AI_ZEN_DIR` — Override the shared root directory (default: `~/.ai-zen`). CLI runtime data goes to `$AI_ZEN_DIR/cli/`, and shared resources (agents, skills, tools, MCP, etc.) go to `$AI_ZEN_DIR/`.
|
|
301
|
+
- `AIZ_DEBUG_KEYS=1` — Enables key diagnostics logging (off by default, zero overhead); `AIZ_KEYS_FILE=<path>` overrides the target file (default `/tmp/aiz-key-debug.log`).
|
|
302
|
+
- `AIZ_DEBUG_SDK=0` — Disables SDK global logging. **On by default**: everything is written to `$AI_ZEN_DIR/logs/sdk.log` (no library logs ever reach the screen), rotated to `sdk.log.1` once the file passes 2MB; `AIZ_SDK_LOG_FILE=<path>` overrides the location. Check this file when debugging "MCP won't connect" or "Skill failed to parse".
|
|
208
303
|
|
|
209
304
|
## Filesystem Layout
|
|
210
305
|
|
|
@@ -213,7 +308,8 @@ The `maxContextTokens` field on each model sets the migration threshold (typical
|
|
|
213
308
|
├── config.json ← Endpoints & models (shared with other AI-Zen clients)
|
|
214
309
|
├── cli/ ← CLI runtime data
|
|
215
310
|
│ ├── conversations/ ← CLI conversations
|
|
216
|
-
│
|
|
311
|
+
│ ├── last-session.json ← Pointer to the last session id
|
|
312
|
+
│ └── preferences.json ← CLI-local preferences (interface language, etc.)
|
|
217
313
|
├── agents/ ← Agent definitions (shared)
|
|
218
314
|
│ ├── default.json ← Default agent (created on first run)
|
|
219
315
|
│ └── my-custom-agent.json
|
|
@@ -226,7 +322,8 @@ The `maxContextTokens` field on each model sets the migration threshold (typical
|
|
|
226
322
|
├── tools/ ← User-defined tools (shared)
|
|
227
323
|
│ └── my-tool.js
|
|
228
324
|
├── mcp.json ← MCP config (shared)
|
|
229
|
-
|
|
325
|
+
├── mcp-oauth/ ← MCP OAuth tokens (shared)
|
|
326
|
+
└── logs/ ← Diagnostics (sdk.log: SDK global log, 2MB rotation)
|
|
230
327
|
|
|
231
328
|
/path/to/project/
|
|
232
329
|
├── .mcp.json ← Project-shared MCP config (committable)
|
|
@@ -262,25 +359,25 @@ The CLI provides 20 built-in tools, implemented by `@ai-zen/agents-sdk`. Tool av
|
|
|
262
359
|
| Tool | Description |
|
|
263
360
|
|------|-------------|
|
|
264
361
|
| `cwd` | Get current working directory |
|
|
265
|
-
| `
|
|
266
|
-
| `
|
|
267
|
-
| `
|
|
362
|
+
| `read` | Read file contents (supports `range` for partial reads) |
|
|
363
|
+
| `inspect_file` | Inspect file structure (lines, chars, column widths, line-ending style) without reading content |
|
|
364
|
+
| `write` | Write content to file |
|
|
268
365
|
| `edit` | Replace text in files (single replacement) |
|
|
269
|
-
| `
|
|
366
|
+
| `batch_edit` | Batch replace text in files |
|
|
270
367
|
| `exec` | Execute shell commands |
|
|
271
|
-
| `
|
|
368
|
+
| `spawn` | Execute a shell command asynchronously (returns immediately) |
|
|
272
369
|
| `mkdir` | Create directories |
|
|
273
370
|
| `rm` | Delete files or directories |
|
|
274
371
|
| `glob` | Scan files with glob patterns |
|
|
275
372
|
| `ls` | List directory contents |
|
|
276
373
|
| `exist` | Check if path exists |
|
|
277
|
-
| `
|
|
278
|
-
| `
|
|
374
|
+
| `find_text` | Search text in files |
|
|
375
|
+
| `download_file` | Download file from URL |
|
|
279
376
|
| `rename` | Rename or move files |
|
|
280
377
|
| `copy` | Copy files or directories |
|
|
281
378
|
| `sleep` | Wait for a specified number of milliseconds |
|
|
282
|
-
| `
|
|
283
|
-
| `
|
|
379
|
+
| `view_image` | View/analyze an image — vision models only (`Model.vision`). A network URL is returned as an `image_url` content block; a local path is auto-uploaded via the Files API and returned as a `file` content block |
|
|
380
|
+
| `generate_image` | Generate images from text — requires `defaultImageModel`; always returns a plain string (JSON with the image URLs plus `view_image` / `download_file` hints) instead of forcing image content blocks |
|
|
284
381
|
|
|
285
382
|
### Dynamic Tools
|
|
286
383
|
|
|
@@ -299,7 +396,7 @@ In addition to built-in tools, the SDK provides 5 dynamic loading tools that are
|
|
|
299
396
|
Tools are assembled in three phases by the SDK's `Scope` capability pipeline:
|
|
300
397
|
|
|
301
398
|
1. **Discovery** — Scan filesystem for built-in tools, user tools, SubAgents, Skills, and MCP servers. All 20 built-in tools are discovered unconditionally (no filtering at this stage)
|
|
302
|
-
2. **Filtering** — Apply permissions (`allow`/`deny`), security exclusions (recursion protection), and each tool's self-declared `isAvailable(config, definition)` (availability is decided at build time when the model is known; e.g. `
|
|
399
|
+
2. **Filtering** — Apply permissions (`allow`/`deny`), security exclusions (recursion protection), and each tool's self-declared `isAvailable(config, definition)` (availability is decided at build time when the model is known; e.g. `view_image` only for vision models, `generate_image` requires `defaultImageModel`)
|
|
303
400
|
3. **Instantiation** — Map filtered names to `Tool` instances and register dynamic loaders
|
|
304
401
|
|
|
305
402
|
Each Agent has independent permissions — no inheritance between parent Agent and SubAgent. The only exception is the temporary Skill sub-agent (created by `call_skill_sub_agent`), which reuses the caller's tool set without a second permission pass, as a transient conversation proxy rather than an independent entity.
|
package/README.zh.md
CHANGED
|
@@ -66,12 +66,81 @@ ai --version
|
|
|
66
66
|
╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝╚═╝ ╚═══╝
|
|
67
67
|
|
|
68
68
|
终端里的 AI 协作台
|
|
69
|
-
v1.0.0-alpha.
|
|
69
|
+
v1.0.0-alpha.21 · sdk x · core y
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
启动界面结束后**直接进入对话界面**(若存在「上一轮会话」则自动续接,否则新建对话)。对话界面采用**底部固定**布局:分隔线、输入行与**状态栏**(按优先级分三块:模型 · Agent · 思考强度 | 本轮 / 累计 token 用量 · 生成速率 | 快捷键提示;窄屏时放不下的块整块顺延到下一行,既不截断内容也不劈开单块)始终贴在终端底部,对话内容在其上方滚动;生成中时输入行位置显示**分阶段进度**(连接中 → 排队中(等待首 token)→ 思考中 → 调用工具 → 等待工具返回 → 输出中,工具阶段带上工具名)。生成速率在生成中显示实时值(最近 2 秒滑动窗口,按输出增量估算),一轮结束后换成这一轮的平均值(优先用 API 返回的真实 `completion_tokens`)。
|
|
73
73
|
|
|
74
|
-
对话界面包含:流式输出区(思考过程 / 回答正文 / 工具调用分行展示)、多行输入(`Enter` 发送、`Ctrl+N` 换行、`← →` 移动光标、`Ctrl+← →`
|
|
74
|
+
对话界面包含:流式输出区(思考过程 / 回答正文 / 工具调用分行展示)、多行输入(`Enter` 发送、`Ctrl+N` 换行、`← →` 移动光标、`Ctrl+← →` 跨词、`Ctrl+W` / `Alt+Backspace` 删前一个词、`Alt+D` / `Ctrl+Delete` 删后一个词、`Ctrl+K` 删到行尾、`Ctrl+U` 删到行首、`PgUp`/`PgDn`(或 `Alt+V`/`Ctrl+V`)翻页、鼠标滚轮按行滚动;macOS 上另支持 `⌘← →` 跨词、`⌘⌫`/`⌘⌦` 按词删除、`⌘[`/`⌘]` 翻页、`⌘;`/`⌘'` 按行滚动(取决于终端是否上报 Cmd,见下))与内联 `/` 命令菜单(↑↓ 选择、`Tab` 补全)。工具调用以 `⚙ 名称(参数)` 展示并带 **JSON 语法高亮**,正文与思考按 **Markdown 源码着色**(标题 / 粗体 / 斜体 / 行内代码 / 列表 / 引用 / 链接),**围栏代码块按语言高亮并保留围栏标记**(高亮数据来自 `highlight.js` / `lowlight`)。`Ctrl+C` 在生成中取消本轮请求、空闲时退出。
|
|
75
|
+
|
|
76
|
+
### 键盘与终端兼容(macOS 等)
|
|
77
|
+
|
|
78
|
+
macOS 上终端 TUI 的通行做法是 **Option 当 Meta + readline 系 Ctrl 键**:`Cmd` 不在终端协议里(`super` 只有 kitty 键盘协议才会上报,见 [kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/)),因此 `⌘` 主要留给终端自身(复制 / 粘贴 / 搜索)。本 CLI 的键位与这条路线一致。
|
|
79
|
+
|
|
80
|
+
**第一步:把 Option 设为 Meta**。macOS 终端默认不发送 Option 修饰位,不设则所有 `Option+X` 全部无效:
|
|
81
|
+
|
|
82
|
+
| 终端 | 设置 |
|
|
83
|
+
|------|------|
|
|
84
|
+
| Apple Terminal | 设置 → 描述文件 → 键盘 → 勾选「**将 Option 用作 Meta 键**」 |
|
|
85
|
+
| iTerm2 | Settings → Profiles → Keys → General → Left/Right Option key 设为 `Esc+` |
|
|
86
|
+
| VS Code / Cursor | settings 里加 `"terminal.integrated.macOptionIsMeta": true` |
|
|
87
|
+
| Ghostty / kitty / WezTerm | 配置文件中启用 Option-as-Alt / Option-as-Meta |
|
|
88
|
+
|
|
89
|
+
键位一览(与 [Claude Code](https://docs.claude.com/en/docs/claude-code/interactive-mode) 对齐):
|
|
90
|
+
|
|
91
|
+
| 键位 | 作用 |
|
|
92
|
+
|------|------|
|
|
93
|
+
| `Enter` | 发送 |
|
|
94
|
+
| `Ctrl+J`、`Ctrl+Enter`、`Alt+Enter`、`Shift+Enter` | 换行 |
|
|
95
|
+
| `Ctrl+C` | 生成中:中断本轮;空闲:有草稿先清空,再按退出 |
|
|
96
|
+
| `Ctrl+D` | 有草稿:删光标后一个字符;空输入:连按两次退出 |
|
|
97
|
+
| `Esc` | 生成中:中断;否则清空草稿并回到底部 |
|
|
98
|
+
| `Ctrl+A` / `Ctrl+E` | 行首 / 行尾 |
|
|
99
|
+
| `Ctrl+P` / `Ctrl+N` | 历史上一条 / 下一条(也用于斜杠菜单选择) |
|
|
100
|
+
| `Ctrl+K` / `Ctrl+U` | 删到行尾 / 删到行首 |
|
|
101
|
+
| `Ctrl+W` | 删到前一空白(标点不切分:`src/utils/foo.ts` 一次删完) |
|
|
102
|
+
| `Alt+B` / `Alt+F` | 跨词移动 |
|
|
103
|
+
| `Alt+D`、`Alt+Backspace`、`Ctrl+Delete` | 按词删除(标点算分隔) |
|
|
104
|
+
| `Ctrl+Y` / `Alt+Y` | 取回刚删掉的文本 / 循环取回更早的 |
|
|
105
|
+
| `Ctrl+_` | 撤销上一次输入编辑 |
|
|
106
|
+
| `Ctrl+S` | 暂存当前草稿 / 再按恢复 |
|
|
107
|
+
| `Ctrl+V` | 预留:粘贴图片(**暂未实现**,按下会提示) |
|
|
108
|
+
| `Ctrl+L` | 清屏(保留上下文) |
|
|
109
|
+
| `PgUp` / `PgDn` | 应用内翻页回看 |
|
|
110
|
+
| 鼠标滚轮 | 按行滚动(每格 3 行)。开启鼠标上报后拖选复制需按住 `Shift`(终端原生选择);`tmux` 用户需 `set -g mouse off`,否则滚轮会先被 copy-mode 拦下 |
|
|
111
|
+
| `Shift+↑ ↓`、`Alt+↑ ↓`、`⌘;` / `⌘'`* | 按行滚动 |
|
|
112
|
+
| `\` + `Enter` | 换行(任何终端可用) |
|
|
113
|
+
|
|
114
|
+
> 中断(`Ctrl+C` / `Esc`)后,模型**已经输出的思考与内容会保留在上下文里** —— 下一轮它会接着这半句话往下说,而不是当作自己没说过。想要彻底重置,用 `/new` 开新会话。工具调用轮次仍按「整轮进出」归一:没跑完的工具会补上中断原因,不会留下「有调用无结果」的非法历史。
|
|
115
|
+
|
|
116
|
+
未实现(我们的场景没有对应物):`Ctrl+O` 转录查看器、`Ctrl+R` 反向历史搜索、`Ctrl+B` 后台任务、`Ctrl+T` 任务清单、`Shift+Tab` 权限模式。
|
|
117
|
+
|
|
118
|
+
`Ctrl+V`(Claude Code 的「粘贴图片」)**暂未实现**:按下会提示未支持。原因是它需要先解决「文件 → 内容块」的端点能力探测(Files API 上传 vs base64内联),不能简单硬编码某个端点。⌘⌫ 已被终端映射为 `Ctrl+U`,所以这里删到行首;要清空草稿用 `Esc`。
|
|
119
|
+
|
|
120
|
+
\* `⌘` 组合只有终端**启用 kitty 键盘协议**时才会带上 `super` 位(iTerm2 还需把 Cmd 映射为 Super);不支持的终端(如 Apple Terminal)只能在终端里把 `⌘` 映射成 `ESC` 序列(如 `⌘←` → `ESC[1;9D`,等价于 `Alt+←`),或直接用上表的 Alt 组合。
|
|
121
|
+
|
|
122
|
+
> macOS 的 `⌘⌫` 会被 iTerm2 / Terminal.app 映射为 `Ctrl+U`,因此本 CLI 的 `Ctrl+U` 取 readline 语义「删到行首」——若做成「清空全部」,Mac 用户按 `⌘⌫` 会丢掉整个草稿。
|
|
123
|
+
|
|
124
|
+
> `Ctrl+← →` 无效通常是系统原因:macOS 默认把它绑定给「调度中心 → 向左/向右移动一个空间」,按键在到达终端前就被截走。可在「系统设置 → 键盘 → 键盘快捷键 → 调度中心」取消勾选。
|
|
125
|
+
|
|
126
|
+
若某个键仍然没反应,打开**按键诊断**再按一次:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
AIZ_DEBUG_KEYS=1 aiz
|
|
130
|
+
# 另开一个窗口
|
|
131
|
+
tail -f /tmp/aiz-key-debug.log
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
首行记录终端环境(`TERM` / `TERM_PROGRAM` 等),之后每次按键一行:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
key input="d" flags=[meta] raw=true
|
|
138
|
+
key input="" flags=[pageUp] raw=false
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **按了键却没有新行** → 键被系统 / 终端截走(改系统快捷键或终端键位映射)
|
|
142
|
+
- **有行但 `flags` 与预期不符** → 序列已到达应用,是匹配逻辑问题(反馈时贴这一行)
|
|
143
|
+
- **`raw=false`** → stdin 不在 raw mode,按键被终端自己解释(例如去滚 scrollback)
|
|
75
144
|
|
|
76
145
|
### 首次配置(API Key)
|
|
77
146
|
|
|
@@ -92,6 +161,19 @@ ai --version
|
|
|
92
161
|
|
|
93
162
|
每个会话都会在对话过程中**直接落盘为独立文件**(`cli/conversations/<id>.json`),不再有单独的草稿存储。一个指针文件(`cli/last-session.json`)记录**上一轮会话 id**;下次启动 `ai` 会**自动续接该会话**,接着上次继续。
|
|
94
163
|
|
|
164
|
+
### 界面语言(中文 / English)
|
|
165
|
+
|
|
166
|
+
首次启动按系统语言自动识别:`LC_ALL` → `LC_MESSAGES` → `LANG` → 系统 `Intl` locale,**识别不出来兑底英文**。识别结果写进 `~/.ai-zen/cli/preferences.json`,之后以偏好为准 —— 改了系统语言不会让界面语言漂移。`/lang` 可随时切换(无参在两者间切换),`/lang zh` / `/lang en` 直接指定。
|
|
167
|
+
|
|
168
|
+
偏好存在 CLI 独立的 `preferences.json` 里,**不写共享的 `config.json`** —— 后者是 CLI 与 Desktop 共用的配置契约。
|
|
169
|
+
|
|
170
|
+
覆盖范围:整套 TUI(主对话框、命令与 `/help`、配置中心全部屏幕、交接方式选择器、启动屏与启动错误屏),以及 `ai --help` 与 `ai hook install / uninstall` 的终端输出。**以下刻意不翻**:
|
|
171
|
+
|
|
172
|
+
- **管道模式(`ai "提示词"` / 管道输入)的输出与报错一律英文** —— 它是给脚本用的,不应随人的界面语言变;
|
|
173
|
+
- 注入给模型的工作目录提示:英文 + `[system-injected: …]` 标记(标明不是用户敲的)。这是唯一不翻的协议内容(新建 Sub-agent 的 `task` 参数描述仍随界面语言);
|
|
174
|
+
- `ai hook` 写进 `~/.bashrc` 的三个代码块标记串(`# === ai hook … ===`) —— 翻了就找不到旧块;
|
|
175
|
+
- 会话 id 时间戳 `chat_YYYY_MM_DD_HH_mm_ss` —— 它同时是文件名,跟着语言变会让历史文件与新文件混排。
|
|
176
|
+
|
|
95
177
|
### 对话命令
|
|
96
178
|
|
|
97
179
|
对话中输入的所有命令以 `/` 开头。输入 `/` 会在输入行下方实时列出可用命令及说明,继续输入即按前缀收敛候选:
|
|
@@ -105,34 +187,39 @@ ai --version
|
|
|
105
187
|
|
|
106
188
|
| 命令 | 说明 |
|
|
107
189
|
|------|------|
|
|
108
|
-
| `/exit` `/quit` |
|
|
109
|
-
| `/save` |
|
|
110
|
-
| `/load` |
|
|
190
|
+
| `/exit` `/quit` | 退出对话(提示保存) |
|
|
191
|
+
| `/save` | 保存对话(本就每轮实时落盘) |
|
|
192
|
+
| `/load` | 加载对话(替换当前会话) |
|
|
111
193
|
| `/new` | 重置会话(清空历史) |
|
|
112
|
-
| `/back` |
|
|
113
|
-
| `/editor` |
|
|
194
|
+
| `/back` | 撤回上一条(回退到指定位置并可编辑重发) |
|
|
195
|
+
| `/editor` | 用外部编辑器(vim/nano)写长消息 |
|
|
114
196
|
| `/clear` | 清屏 |
|
|
115
|
-
| `/config` | 打开配置中心(端点 / 模型 / 图片模型 / MCP
|
|
116
|
-
| `/
|
|
117
|
-
| `/
|
|
118
|
-
| `/
|
|
197
|
+
| `/config` | 打开配置中心(端点 / 模型 / 图片模型 / MCP / Agent 定义 / 默认项 / 工具上限) |
|
|
198
|
+
| `/model` | 切换模型(写入 Agent 的 `modelId`,思考强度重置为模型默认) |
|
|
199
|
+
| `/agent` | 切换主 Agent(写入 `defaultAgent` 并重建会话;跑不起来的标为不可用并给出原因) |
|
|
200
|
+
| `/reload` | 刷新运行环境(重新发现工具 / MCP;消息与上下文保留) |
|
|
201
|
+
| `/mcp` | 管理 MCP 服务器(增删改 / 启停;`/mcp global`、`/mcp project` 指定作用域) |
|
|
202
|
+
| `/lang` | 切换界面语言(`/lang zh`、`/lang en` 直指定,不带参数则切换) |
|
|
203
|
+
| `/think` `/effort` | 切换思考强度(`/think default` 跟随模型默认) |
|
|
204
|
+
| `/key` | 设置端点 API Key(保存后重建会话) |
|
|
205
|
+
| `/handoff` | 生成交接文档(不切换会话) |
|
|
206
|
+
| `/migrate` | 交接并开启新会话 |
|
|
207
|
+
| `/help` | 显示帮助 |
|
|
119
208
|
|
|
120
|
-
###
|
|
209
|
+
### 任务交接与迁移
|
|
121
210
|
|
|
122
|
-
|
|
211
|
+
两条命令,同一条管道:
|
|
123
212
|
|
|
124
|
-
|
|
213
|
+
- **`/handoff`** — 原 agent 停下手头工作,用自己的工具核实真实状态(分支、未提交改动、测试、端口),把交接文档写到 `<项目>/.ai-zen/handoffs/<时间戳>-<会话id>.md`。会话照旧运行,因此可以继续打磨这份文档。
|
|
214
|
+
- **`/migrate`** — 同一次交接,然后把历史清空、以该文档开启新会话(断点消息只带路径,由新 agent 自己读取)。
|
|
125
215
|
|
|
126
|
-
|
|
216
|
+
两种执行者:`self`(默认——原 agent 在会话内写,保真度最高)与 `summary`(一次独立模型调用,便宜但有损)。`self` 失败时**单向**降级为 `summary`。可用 `/handoff summary` 或 `/migrate self` 显式指定。
|
|
127
217
|
|
|
128
|
-
|
|
129
|
-
- **对话断点** — 最后一段对话原文引用
|
|
130
|
-
- **已完成的任务** — 任务标题和产出路径
|
|
131
|
-
- **未完成的任务** — 描述、进度、下一步
|
|
132
|
-
- **重要记忆** — 技术偏好、踩坑记录、架构决策
|
|
133
|
-
- **文件索引** — 关键文件及用途说明
|
|
134
|
-
- **接手指令** — 先读文件验真、再对状态、后行动的 SOP
|
|
218
|
+
当 `usage.prompt_tokens` 超过模型的 `tokenThresholds.handoff`,交互式终端会弹出三选一选择器(自交接 / 独立摘要 / 跳过);管道等非交互场景按默认执行者迁移,不阻塞。
|
|
135
219
|
|
|
220
|
+
文档模板不在代码里:来自 `handoff` Skill(`~/.ai-zen/skills/handoff/SKILL.md`,由 SDK 释放并随版本同步;在 frontmatter 写 `metadata.custom: "true"` 可保留你自己的版本,也可在项目内覆盖)。完整链路、成本说明与模板章节见 [任务交接与迁移](./docs/zh/migration.md)。
|
|
221
|
+
|
|
222
|
+
同样的上下文护栏也作用于**子 Agent**:每次委派边界(`onSubAgentStart`)CLI 都会把同一个 `ContextGuardPlugin`(同一 `maxTokens`)安插到新建的子 Agent 上,因此被委派的子 Agent(含 `call_skill_sub_agent` 创建的技能子 Agent)在上下文超出硬上限时同样会被中断。该过程是透明的,正常运行的子 Agent 不受影响。
|
|
136
223
|
### Shell 兜底钩子
|
|
137
224
|
|
|
138
225
|
当你在终端输入一个不存在的命令时,自动转发给 AI 处理:
|
|
@@ -149,7 +236,11 @@ ai hook install
|
|
|
149
236
|
ai hook uninstall
|
|
150
237
|
```
|
|
151
238
|
|
|
152
|
-
钩子函数体调用的是
|
|
239
|
+
钩子函数体调用的是 **`ai --tui --new "$@"`**:进入交互界面,并把摸错的命令**作为首条消息自动发给模型**。钩子的发起场景是「人坐在交互终端前敲错了命令」,所以它应该进 TUI(可以追问、有历史),而不是落到管道模式吐一段字就退出;`--new` 进一步保证钩子会话**总是新开一条对话**,不会把敲错的命令追加进该目录原有的长对话里。已装过旧版钩子的话,重新执行 `ai hook install` 会原地升级(会比较已安装的函数体与当前版本,不一致就覆盖);也可先 `ai hook uninstall` 再安装。
|
|
240
|
+
|
|
241
|
+
`--tui` 也可以手动用:`ai --tui 帮我看看这个报错` 会直接进 TUI 并发送。它在非 TTY 环境(如写进脚本或管道里)会报错退出而不是降级成管道模式 —— 否则整屏界面内容会被写进管道。
|
|
242
|
+
|
|
243
|
+
`--new` 也可以单独用:`ai --new` 直接开新一条对话,不续接该目录的上一轮会话。它只对 TUI 生效,stdio 模式下会被忽略(一次 stdio 调用本就是一次性会话)。
|
|
153
244
|
|
|
154
245
|
## 配置管理
|
|
155
246
|
|
|
@@ -162,7 +253,7 @@ ai hook uninstall
|
|
|
162
253
|
| 端点 / 模型 / 图片模型、MCP 服务器、Agent 定义(含 Sub-agent)、默认项、工具输出上限 | 对话内 `/config`(配置中心,全面管理) |
|
|
163
254
|
| 其它高级项(Skill / 用户工具等) | 手动编辑 `~/.ai-zen/` 下的文件 |
|
|
164
255
|
|
|
165
|
-
其中 `
|
|
256
|
+
其中 `tokenThresholds` 是两条用量线:`handoff`(交接软线,超过它触发任务交接)与 `guard`(强行阻断硬线,请求前超过它中断本轮)。两者都是绝对值,建议 `guard ≈ handoff × 1.5`(`handoff` 通常设为模型实际上下文窗口的约 25%,例如 1M tokens 的模型设为 250,000)。
|
|
166
257
|
|
|
167
258
|
```jsonc
|
|
168
259
|
{
|
|
@@ -180,7 +271,8 @@ ai hook uninstall
|
|
|
180
271
|
"name": "GPT-6.1 Sol",
|
|
181
272
|
"endpointId": "openai",
|
|
182
273
|
"modelName": "gpt-6.1-sol",
|
|
183
|
-
"
|
|
274
|
+
"tokenThresholds": { "handoff": 250000, "guard": 375000 },
|
|
275
|
+
"reasoningPreset": "openai",
|
|
184
276
|
"custom": true
|
|
185
277
|
}
|
|
186
278
|
],
|
|
@@ -193,7 +285,6 @@ ai hook uninstall
|
|
|
193
285
|
"defaultSize": "1024x1024"
|
|
194
286
|
}
|
|
195
287
|
],
|
|
196
|
-
"defaultModel": "deepseek-flash",
|
|
197
288
|
"defaultImageModel": "cogview-4",
|
|
198
289
|
"defaultAgent": "default",
|
|
199
290
|
"defaultMigrationModel": "deepseek-flash"
|
|
@@ -201,10 +292,14 @@ ai hook uninstall
|
|
|
201
292
|
```
|
|
202
293
|
|
|
203
294
|
> 说明:`models` / `imageModels` 中**未标 `custom: true`** 的条目属于**出厂托管**——每次启动会与 SDK 出厂清单对齐、被替换为最新定义;自建模型请加 `"custom": true`。`endpoints` 始终保留用户配置,不受影响。
|
|
295
|
+
>
|
|
296
|
+
> 模型**不在 `config.json` 里指定**:每个 Agent 在自己的定义文件(`agents/<id>.json`)的 `modelId` 字段上绑定模型,这是运行期的唯一真相源;`/model` 切换写的也是它。
|
|
204
297
|
|
|
205
298
|
### 环境变量
|
|
206
299
|
|
|
207
300
|
- `AI_ZEN_DIR` — 覆盖共享根目录(默认 `~/.ai-zen`)。CLI 运行时数据在 `$AI_ZEN_DIR/cli/`,共享资源(agents、skills、tools、MCP 等)在 `$AI_ZEN_DIR/`。
|
|
301
|
+
- `AIZ_DEBUG_KEYS=1` — 开启按键诊断日志(默认关闭,零开销);`AIZ_KEYS_FILE=<路径>` 可改落盘位置(默认 `/tmp/aiz-key-debug.log`)。
|
|
302
|
+
- `AIZ_DEBUG_SDK=0` — 关闭 SDK 全局日志。**默认开启**,一律写入 `$AI_ZEN_DIR/logs/sdk.log`(界面上不显示任何库日志),单文件 2MB 封顶后轮转为 `sdk.log.1`;`AIZ_SDK_LOG_FILE=<路径>` 可改落盘位置。排查「MCP 连不上」「Skill 解析失败」时看这个文件。
|
|
208
303
|
|
|
209
304
|
## 文件系统布局
|
|
210
305
|
|
|
@@ -213,7 +308,8 @@ ai hook uninstall
|
|
|
213
308
|
├── config.json ← 端点与模型配置(与其他 AI-Zen 客户端共享)
|
|
214
309
|
├── cli/ ← CLI 运行时数据
|
|
215
310
|
│ ├── conversations/ ← CLI 对话记录
|
|
216
|
-
│
|
|
311
|
+
│ ├── last-session.json ← 「上一轮会话 id」指针
|
|
312
|
+
│ └── preferences.json ← CLI 本地偏好(界面语言等)
|
|
217
313
|
├── agents/ ← Agent 定义(共享)
|
|
218
314
|
│ ├── default.json ← 默认 Agent(首次运行自动创建)
|
|
219
315
|
│ └── my-custom-agent.json
|
|
@@ -226,7 +322,8 @@ ai hook uninstall
|
|
|
226
322
|
├── tools/ ← 用户自定义工具(共享)
|
|
227
323
|
│ └── my-tool.js
|
|
228
324
|
├── mcp.json ← MCP 配置(共享)
|
|
229
|
-
|
|
325
|
+
├── mcp-oauth/ ← MCP OAuth 令牌(共享)
|
|
326
|
+
└── logs/ ← 诊断日志(sdk.log:SDK 全局日志,2MB 轮转)
|
|
230
327
|
|
|
231
328
|
/path/to/project/
|
|
232
329
|
├── .mcp.json ← 项目共享 MCP 配置(可提交 git)
|
|
@@ -262,25 +359,25 @@ CLI 提供 20 个内置工具,由 `@ai-zen/agents-sdk` 实现。工具可用
|
|
|
262
359
|
| 工具 | 说明 |
|
|
263
360
|
|------|------|
|
|
264
361
|
| `cwd` | 获取当前工作目录 |
|
|
265
|
-
| `
|
|
266
|
-
| `
|
|
267
|
-
| `
|
|
362
|
+
| `read` | 读取文件内容(支持 `range` 分批读取) |
|
|
363
|
+
| `inspect_file` | 勘察文件结构概况(行数、字符数、列宽分布、行尾风格),不读取内容 |
|
|
364
|
+
| `write` | 写入文件 |
|
|
268
365
|
| `edit` | 替换文件中的文本(单次替换) |
|
|
269
|
-
| `
|
|
366
|
+
| `batch_edit` | 批量编辑文本 |
|
|
270
367
|
| `exec` | 执行 shell 命令 |
|
|
271
|
-
| `
|
|
368
|
+
| `spawn` | 异步执行 shell 命令(立即返回,不等待结果) |
|
|
272
369
|
| `mkdir` | 创建目录 |
|
|
273
370
|
| `rm` | 删除文件或目录 |
|
|
274
371
|
| `glob` | 通配符扫描文件 |
|
|
275
372
|
| `ls` | 列出目录 |
|
|
276
373
|
| `exist` | 检查路径是否存在 |
|
|
277
|
-
| `
|
|
278
|
-
| `
|
|
374
|
+
| `find_text` | 在文件中查找文本 |
|
|
375
|
+
| `download_file` | 从 URL 下载文件 |
|
|
279
376
|
| `rename` | 重命名或移动文件 |
|
|
280
377
|
| `copy` | 复制文件或目录 |
|
|
281
378
|
| `sleep` | 等待指定毫秒数 |
|
|
282
|
-
| `
|
|
283
|
-
| `
|
|
379
|
+
| `view_image` | 查看/分析图片 — 仅视觉模型可用(`Model.vision`)。网络图片直接以 `image_url` 内容块返回;本地图片经 Files API 自动上传后以 `file` 内容块返回 |
|
|
380
|
+
| `generate_image` | 根据描述生成图片 — 需配置 `defaultImageModel`;统一返回字符串(含图片 URL 列表与 `view_image` / `download_file` 提示的 JSON),不再强制返回图片内容块 |
|
|
284
381
|
|
|
285
382
|
### 动态工具
|
|
286
383
|
|
|
@@ -299,7 +396,7 @@ CLI 提供 20 个内置工具,由 `@ai-zen/agents-sdk` 实现。工具可用
|
|
|
299
396
|
工具装配由 SDK 的 `Scope` 能力管线管理,分为三个阶段:
|
|
300
397
|
|
|
301
398
|
1. **发现** — 扫描文件系统获取内置工具、用户工具、SubAgent、Skill 和 MCP 服务器。20 个内置工具全部无条件发现(此阶段不做过滤)
|
|
302
|
-
2. **过滤** — 应用权限(`allow`/`deny`)、安全排除(递归保护),以及各工具自声明的 `isAvailable(config, definition)`(在模型已知的构建阶段判断可用性;如 `
|
|
399
|
+
2. **过滤** — 应用权限(`allow`/`deny`)、安全排除(递归保护),以及各工具自声明的 `isAvailable(config, definition)`(在模型已知的构建阶段判断可用性;如 `view_image` 仅视觉模型、`generate_image` 需配置 `defaultImageModel`)
|
|
303
400
|
3. **实例化** — 将过滤后的名称映射为 `Tool` 实例,注册动态加载器
|
|
304
401
|
|
|
305
402
|
每个 Agent 拥有独立的权限配置,父 Agent 与 SubAgent 之间不继承权限。唯一的例外是 `call_skill_sub_agent` 创建的临时 Skill 子 Agent——它是临时的对话分身而非独立实体,因此沿用调用者的工具能力(不再走第二遍权限过滤)。
|
package/dist/agent-creator.d.ts
CHANGED
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Scope, SdkAgent } from "@ai-zen/agents-sdk";
|
|
8
8
|
import type { AgentNS } from "@ai-zen/agents-core";
|
|
9
|
+
/**
|
|
10
|
+
* Skill 目录列表(优先级从高到低):
|
|
11
|
+
* 1. 项目/.ai-zen/skills/
|
|
12
|
+
* 2. 项目/.agents/skills/ ← 业界通用规范
|
|
13
|
+
* 3. ~/.ai-zen/skills/
|
|
14
|
+
* 4. ~/.agents/skills/ ← 业界通用规范
|
|
15
|
+
*
|
|
16
|
+
* 同时供 Scope 装配与交接服务(读取 `handoff` Skill 正文)使用,避免两处各算一遍。
|
|
17
|
+
* 只返回**当前真实存在**的目录,不存在的不参与发现。
|
|
18
|
+
*/
|
|
19
|
+
export declare function listSkillDirs(): string[];
|
|
9
20
|
export declare function getScope(): Promise<Scope>;
|
|
10
21
|
/**
|
|
11
22
|
* 重置 Scope 单例:释放当前 Scope(断开 MCP 连接等),下次 `getScope()` 按磁盘配置重建。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-creator.d.ts","sourceRoot":"","sources":["../src/agent-creator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,KAAK,EAGL,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-creator.d.ts","sourceRoot":"","sources":["../src/agent-creator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,KAAK,EAGL,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAwBnD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAOxC;AAED,wBAAsB,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,CAS/C;AAuCD;;;;;GAKG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAWhD;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmBhF"}
|