@ia-ccun/code-agent-cli 0.0.52 → 0.0.53-beta.2
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/bin/cli.js +97 -69
- package/config/agent/bin/README.md +102 -0
- package/config/agent/extensions/aicode-advisor.ts +197 -61
- package/config/agent/extensions/aicode-banner.ts +101 -0
- package/config/agent/extensions/aicode-btw.ts +677 -183
- package/config/agent/extensions/aicode-cd.ts +1017 -0
- package/config/agent/extensions/aicode-grillMe.ts +198 -0
- package/config/agent/extensions/aicode-pets.ts +351 -0
- package/config/agent/extensions/aicode-plan.ts +2 -0
- package/config/agent/extensions/aicode-safety-guard.ts +555 -0
- package/config/agent/extensions/aicode-tips.ts +69 -30
- package/config/agent/extensions/aicode-todo-progress.ts +547 -0
- package/config/agent/extensions/context-monitor.ts +30 -15
- package/config/agent/extensions/context.ts +132 -60
- package/config/agent/extensions/custom-footer.ts +0 -5
- package/config/agent/extensions/custom.ts +119 -109
- package/config/agent/extensions/error-monitor.ts +38 -51
- package/config/agent/extensions/goal.ts +8 -6
- package/config/agent/extensions/msg-debug.ts +103 -112
- package/config/agent/extensions/ponytail.ts +441 -0
- package/config/agent/extensions/review.ts +365 -164
- package/config/agent/extensions/tps.ts +87 -0
- package/config/agent/extensions/working-msg.ts +164 -51
- package/config/agent/help.md +0 -7
- package/config/agent/models.json +7 -7
- package/config/agent/settings.json +2 -1
- package/config/agent/skills/chroma/LICENSE +21 -0
- package/config/agent/skills/chroma/chroma-local/SKILL.md +165 -0
- package/config/agent/skills/chroma/chroma-local/cli.md +48 -0
- package/config/agent/skills/chroma/chroma-local/data-model.md +103 -0
- package/config/agent/skills/chroma/chroma-local/error-handling/python.md +166 -0
- package/config/agent/skills/chroma/chroma-local/error-handling/typescript.md +231 -0
- package/config/agent/skills/chroma/chroma-local/local-chroma/python.md +95 -0
- package/config/agent/skills/chroma/chroma-local/local-chroma/typescript.md +101 -0
- package/config/agent/skills/chroma/chroma-local/metadata/python.md +154 -0
- package/config/agent/skills/chroma/chroma-local/metadata/typescript.md +153 -0
- package/config/agent/skills/chroma/chroma-local/querying/python.md +147 -0
- package/config/agent/skills/chroma/chroma-local/querying/typescript.md +157 -0
- package/config/agent/skills/chroma/chroma-local/regex/python.md +69 -0
- package/config/agent/skills/chroma/chroma-local/regex/typescript.md +71 -0
- package/config/agent/skills/chroma/chroma-local/understanding-a-codebase.md +80 -0
- package/config/agent/skills/chroma/chroma-local/updating-deleting/python.md +159 -0
- package/config/agent/skills/chroma/chroma-local/updating-deleting/typescript.md +228 -0
- package/config/agent/skills/milvus-skill/LICENSE +202 -0
- package/config/agent/skills/milvus-skill/README.md +37 -0
- package/config/agent/skills/milvus-skill/SKILL.md +259 -0
- package/config/agent/skills/milvus-skill/references/collection.md +86 -0
- package/config/agent/skills/milvus-skill/references/database.md +24 -0
- package/config/agent/skills/milvus-skill/references/index.md +69 -0
- package/config/agent/skills/milvus-skill/references/partition.md +29 -0
- package/config/agent/skills/milvus-skill/references/patterns.md +150 -0
- package/config/agent/skills/milvus-skill/references/user-role.md +90 -0
- package/config/agent/skills/milvus-skill/references/vector.md +247 -0
- package/config/agent/skills/ponytail/SKILL.md +100 -0
- package/config/agent/skills/ponytail-audit/SKILL.md +40 -0
- package/config/agent/skills/ponytail-debt/SKILL.md +44 -0
- package/config/agent/skills/ponytail-help/SKILL.md +68 -0
- package/config/agent/skills/ponytail-review/SKILL.md +56 -0
- package/config/agent/skills/zread/README.md +115 -0
- package/config/agent/skills/zread/SKILL.md +103 -0
- package/config/agent/skills/zread/references/stdio-protocol.md +312 -0
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +8 -1
- package/dist/banner.js.map +1 -1
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/config-loader.js +9 -2
- package/dist/config-loader.js.map +1 -1
- package/package.json +7 -7
- package/scripts/postinstall.js +58 -1
- package/scripts/regression/README.md +224 -0
- package/scripts/regression/cases/01-version-and-deps.sh +94 -0
- package/scripts/regression/cases/02-extension-loading.sh +130 -0
- package/scripts/regression/cases/03-rpc-protocol.sh +259 -0
- package/scripts/regression/cases/04-prompt-stream.sh +130 -0
- package/scripts/regression/cases/05-slash-commands-and-skills.sh +119 -0
- package/scripts/regression/cases/06-tool-execution.sh +115 -0
- package/scripts/regression/cases/07-pi-new-features.sh +141 -0
- package/scripts/regression/lib/common.sh +287 -0
- package/scripts/regression/results/.last_pid +1 -0
- package/scripts/regression/results/.last_workdir +1 -0
- package/scripts/regression/results/02-extension-loading.log +18 -0
- package/scripts/regression/results/03-prompt-stream.log +16 -0
- package/scripts/regression/results/03-rpc-protocol.log +27 -0
- package/scripts/regression/results/04-slash-commands-and-skills.log +11 -0
- package/scripts/regression/results/05-tool-execution.log +8 -0
- package/scripts/regression/results/06-pi-new-features.log +29 -0
- package/scripts/regression/run-all.sh +187 -0
- package/config/agent/dangerous-patterns.json +0 -106
- package/config/agent/extensions/bash-check.ts +0 -227
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# zread `--stdio` protocol
|
|
2
|
+
|
|
3
|
+
Every zread command accepts `--stdio`, switching the process from an interactive
|
|
4
|
+
TUI into a JSON-line machine protocol on stdin/stdout. This is the contract used
|
|
5
|
+
by GUI / programmatic clients to drive zread.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
zread internally uses a Driver / Client split:
|
|
10
|
+
|
|
11
|
+
- **Driver** holds all business logic (loading config, calling LLMs, running the
|
|
12
|
+
doc server, managing drafts). It is framework-agnostic and only talks to a
|
|
13
|
+
`Transport`.
|
|
14
|
+
- **Client** is either a Bubbletea TUI or `StdioClient`. With `--stdio`, the
|
|
15
|
+
cobra command instantiates `transport.NewLocalTransport()` (a channel pair),
|
|
16
|
+
spawns the driver in a goroutine, then runs `StdioClient.Run(ctx)`.
|
|
17
|
+
- `StdioClient` reads JSON lines from `os.Stdin` and forwards them as commands
|
|
18
|
+
to the driver, while encoding `Event`s from the driver to `os.Stdout` (one
|
|
19
|
+
JSON object per line). It returns when an event with `"done": true` is
|
|
20
|
+
received.
|
|
21
|
+
|
|
22
|
+
Result: stdin = command stream, stdout = event stream, both newline-delimited
|
|
23
|
+
JSON. stderr is reserved for logs/errors and should not be parsed.
|
|
24
|
+
|
|
25
|
+
## Event format (driver → client, stdout)
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"vm": { ... },
|
|
30
|
+
"waiting_for": ["..."],
|
|
31
|
+
"done": false,
|
|
32
|
+
"error": ""
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- `vm`: full ViewModel snapshot for the current state (shape varies per command — see below).
|
|
37
|
+
- `waiting_for`: command `type` values the client may legally send right now. `quit` is always accepted regardless.
|
|
38
|
+
- `done`: `true` on the final event; the process will exit on its own.
|
|
39
|
+
- `error`: non-empty when the previous command was rejected; `vm`/`waiting_for` remain unchanged.
|
|
40
|
+
|
|
41
|
+
Rules:
|
|
42
|
+
- An event is emitted after every state transition. Treat `vm` as the full current state (no diffs).
|
|
43
|
+
- `waiting_for: []` with `done: false` means the driver is awaiting an internal async result — do not send any command; just keep reading.
|
|
44
|
+
- The very last event always has `done: true` and an empty `waiting_for`.
|
|
45
|
+
|
|
46
|
+
## Command format (client → driver, stdin)
|
|
47
|
+
|
|
48
|
+
One JSON object per line:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{"type": "<command_type>", "params": { ... }}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- `type` is required. `params` may be omitted (treated as `{}`).
|
|
55
|
+
- Universal command: `{"type":"quit","params":{}}` — every driver handles it and shuts down cleanly.
|
|
56
|
+
- Command types prefixed with `_` are driver-internal. They never appear in `waiting_for`; clients must not send them.
|
|
57
|
+
- Sending a command not in `waiting_for` returns an event with `error` set while `vm`/`waiting_for` remain unchanged.
|
|
58
|
+
- Error message format: `"command \"xxx\" not allowed in state yyy"` / `"invalid params: ..."` / `"invalid JSON: ..."`.
|
|
59
|
+
|
|
60
|
+
## Driving a session
|
|
61
|
+
|
|
62
|
+
1. Spawn `zread <command> --stdio` with piped stdin/stdout.
|
|
63
|
+
2. Read the first event — it carries the initial ViewModel and `waiting_for`.
|
|
64
|
+
3. Render or inspect `vm`; pick a legal command from `waiting_for` and write it as a single JSON line followed by `\n`.
|
|
65
|
+
4. Loop: read next event, react, write next command.
|
|
66
|
+
5. Stop when `done: true` arrives. The process will exit on its own. Sending `quit` at any time triggers the same shutdown.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## `zread browse --stdio`
|
|
71
|
+
|
|
72
|
+
### ViewModel fields
|
|
73
|
+
|
|
74
|
+
| Field | Type | Notes |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `state` | string | `"loading"` `"serving"` `"select_version"` `"no_wiki"` `"error"` |
|
|
77
|
+
| `url` | string | Local server URL; present when `state="serving"` |
|
|
78
|
+
| `browser_opened` | bool | Whether the browser was auto-launched |
|
|
79
|
+
| `has_current` | bool | Whether a "current" wiki version exists |
|
|
80
|
+
| `versions` | array | Present when `state="select_version"` |
|
|
81
|
+
| `versions[].id` | string | Wiki version ID |
|
|
82
|
+
| `versions[].timestamp` | string | Version timestamp |
|
|
83
|
+
| `versions[].is_current` | bool | Whether this is the current version |
|
|
84
|
+
| `error` | string | Present when `state="error"` |
|
|
85
|
+
|
|
86
|
+
### Commands
|
|
87
|
+
|
|
88
|
+
| State | `waiting_for` | Command | Params |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `select_version` | `["select_version","quit"]` | `select_version` | `{"wiki_id":"<id>"}` or `{"current":true}` |
|
|
91
|
+
| `serving` | `["quit"]` | — | — |
|
|
92
|
+
| `no_wiki` | `["quit"]` | — | — |
|
|
93
|
+
| `loading` | `[]` | *(wait for internal event)* | — |
|
|
94
|
+
| `error` | `[]` | — | — |
|
|
95
|
+
|
|
96
|
+
### State machine
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
loading ──(server ok)──────────────────► serving
|
|
100
|
+
loading ──(error)──────────────────────► error (terminal)
|
|
101
|
+
select_version ──(select_version cmd)──► loading ──► serving
|
|
102
|
+
no_wiki ───────────────────────────────► (terminal, done=true)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## `zread generate --stdio`
|
|
108
|
+
|
|
109
|
+
### ViewModel fields
|
|
110
|
+
|
|
111
|
+
| Field | Type | Notes |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `state` | string | `"select_action"` `"running"` `"done"` `"error"` |
|
|
114
|
+
| `max_retries` | int | Configured max retries per page |
|
|
115
|
+
| `select_action.scenario` | string | `"has_wiki"` `"has_draft"` `"empty"` |
|
|
116
|
+
| `select_action.wiki_date` | string | Date of existing wiki (when `scenario="has_wiki"`) |
|
|
117
|
+
| `select_action.draft_done` | int | Pages already done in draft |
|
|
118
|
+
| `select_action.draft_total` | int | Total pages in draft |
|
|
119
|
+
| `select_action.next_action` | string | Pre-suggested action: `"generate"` `"browse"` `""` |
|
|
120
|
+
| `catalog.status` | string | `"idle"` `"running"` `"done"` `"resumed"` `"error"` |
|
|
121
|
+
| `catalog.tool_name` | string | Currently-running LLM tool (if any) |
|
|
122
|
+
| `catalog.error` | string | Catalog error message |
|
|
123
|
+
| `catalog.auto_retry` | int | Auto-retry count so far |
|
|
124
|
+
| `pages.tasks` | array | Per-page task list |
|
|
125
|
+
| `pages.tasks[].id` | int | Task ID (used for `retry` command) |
|
|
126
|
+
| `pages.tasks[].title` | string | Page title |
|
|
127
|
+
| `pages.tasks[].slug` | string | Page slug |
|
|
128
|
+
| `pages.tasks[].state` | string | `"pending"` `"running"` `"retry_pending"` `"done"` `"failed"` `"resumed"` |
|
|
129
|
+
| `pages.tasks[].retry_count` | int | Retries attempted so far |
|
|
130
|
+
| `pages.tasks[].max_retries` | int | Retry limit for this task |
|
|
131
|
+
| `pages.tasks[].error` | string | Error message if failed |
|
|
132
|
+
| `pages.done` | int | Completed page count |
|
|
133
|
+
| `pages.total` | int | Total page count |
|
|
134
|
+
| `pages.waiting_retry` | bool | `true` when driver is paused waiting for retry/skip decision |
|
|
135
|
+
| `done_total` | int | Total pages done (in `state="done"`) |
|
|
136
|
+
| `error` | string | Fatal error message |
|
|
137
|
+
|
|
138
|
+
### Commands
|
|
139
|
+
|
|
140
|
+
| State / condition | `waiting_for` | Command | Params |
|
|
141
|
+
|---|---|---|---|
|
|
142
|
+
| `select_action` | `["select_action","cancel","quit"]` | `select_action` | `{"action":"generate"}` or `"browse"` or `"resume"` or `"clear"` or `"cancel"` |
|
|
143
|
+
| `running` (normal) | `["quit"]` | — | — |
|
|
144
|
+
| `running` (catalog error) | `["quit","retry_catalog"]` | `retry_catalog` | `{}` |
|
|
145
|
+
| `running` (pages waiting retry) | `["quit","retry","skip_all"]` | `retry` | `{"task_id":<int>}` |
|
|
146
|
+
| `running` (pages waiting retry) | `["quit","retry","skip_all"]` | `skip_all` | `{}` |
|
|
147
|
+
| `running` | `["quit","cancel"]` | `cancel` | `{}` |
|
|
148
|
+
|
|
149
|
+
### CLI flags that affect stdio flow
|
|
150
|
+
|
|
151
|
+
- `--yes` / `-y`: skips the `select_action` gate; generation starts immediately.
|
|
152
|
+
- `--draft-action <resume|clear|cancel>`: pre-answers the draft prompt.
|
|
153
|
+
- `--skip-failed`: equivalent to auto-sending `skip_all` when pages fail.
|
|
154
|
+
|
|
155
|
+
### State machine
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
select_action ──(generate/resume)──► running ──(all done, no failures)──► done
|
|
159
|
+
select_action ──(cancel/browse)────► done (immediate)
|
|
160
|
+
running ──(pages failed)───────────► waiting_retry=true, accepts retry/skip_all
|
|
161
|
+
running ──(cancel)─────────────────► done
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## `zread config --stdio`
|
|
167
|
+
|
|
168
|
+
### ViewModel fields
|
|
169
|
+
|
|
170
|
+
| Field | Type | Notes |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `fields` | array (9 items) | Ordered config fields |
|
|
173
|
+
| `fields[].title_key` | string | Display label key |
|
|
174
|
+
| `fields[].json_key` | string | Key to use in `update_fields`; empty = read-only |
|
|
175
|
+
| `fields[].initial` | string | Value at load time |
|
|
176
|
+
| `fields[].value` | string | Current (possibly edited) value |
|
|
177
|
+
| `dirty` | bool | `true` if any field differs from `initial` |
|
|
178
|
+
| `saved` | bool | `true` after successful save |
|
|
179
|
+
| `error` | string | Validation error |
|
|
180
|
+
|
|
181
|
+
Field index → `json_key` mapping:
|
|
182
|
+
|
|
183
|
+
| Index | `json_key` | Notes |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| 0 | `language` | generation language |
|
|
186
|
+
| 1 | `doc_language` | doc language |
|
|
187
|
+
| 2 | *(empty)* | read-only LLM provider display |
|
|
188
|
+
| 3 | `max_concurrent` | int |
|
|
189
|
+
| 4 | `max_retries` | int |
|
|
190
|
+
| 5 | `llm_provider` | editable in stdio mode |
|
|
191
|
+
| 6 | `llm_base_url` | editable in stdio mode |
|
|
192
|
+
| 7 | `llm_model` | editable in stdio mode |
|
|
193
|
+
| 8 | `llm_api_key` | editable in stdio mode |
|
|
194
|
+
|
|
195
|
+
### Commands
|
|
196
|
+
|
|
197
|
+
No state machine. Fixed `waiting_for`: `["update_fields","save","reload_llm","quit"]`.
|
|
198
|
+
|
|
199
|
+
| Command | Params | Effect |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `update_fields` | `{"fields":{"<json_key>": "<value>", ...}}` | Partial update; only listed keys change |
|
|
202
|
+
| `save` | `{}` | Persists config and terminates (`done=true`) |
|
|
203
|
+
| `reload_llm` | `{}` | Re-validates LLM provider settings |
|
|
204
|
+
| `quit` | `{}` | Exits without saving |
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## `zread login --stdio`
|
|
209
|
+
|
|
210
|
+
### ViewModel fields
|
|
211
|
+
|
|
212
|
+
| Field | Type | Notes |
|
|
213
|
+
|---|---|---|
|
|
214
|
+
| `state` | string | See states below |
|
|
215
|
+
| `authorize_url` | string | OAuth URL to open; present in `open_browser` state |
|
|
216
|
+
| `auth_timeout` | int | Nanoseconds until auth expires; present in `waiting` state |
|
|
217
|
+
| `browser_warn` | string | Warning if browser launch failed |
|
|
218
|
+
| `username` | string | Logged-in username; present in `done` state |
|
|
219
|
+
| `avail_models` | array of string | Models to choose from; present in `select_model` state |
|
|
220
|
+
| `selected_model` | string | Currently selected model |
|
|
221
|
+
| `error` | string | Error message in `error` state |
|
|
222
|
+
| `wants_llm_provider_editor` | bool | `true` (with `done=true`) when `--custom` flag was used |
|
|
223
|
+
|
|
224
|
+
States: `"select_region"` → `"init_flow"` → `"open_browser"` → `"waiting"` → `"select_model"` → `"saving"` → `"done"` / `"error"`
|
|
225
|
+
|
|
226
|
+
### Commands
|
|
227
|
+
|
|
228
|
+
| State | `waiting_for` | Command | Params |
|
|
229
|
+
|---|---|---|---|
|
|
230
|
+
| `select_region` | `["select_region","quit"]` | `select_region` | `{"region":"<provider_key>"}` or `{"region":"__use_own_key__"}` |
|
|
231
|
+
| `select_model` | `["select_model","quit"]` | `select_model` | `{"model":"<model_id>"}` |
|
|
232
|
+
| all others | `[]` | *(wait for internal auth events)* | — |
|
|
233
|
+
|
|
234
|
+
### Special cases
|
|
235
|
+
|
|
236
|
+
- `--custom` flag: driver immediately emits `done: true` with `wants_llm_provider_editor: true`. Client should then launch `zread config --stdio` to configure a custom LLM provider.
|
|
237
|
+
|
|
238
|
+
### State machine
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
select_region ──(cmd)──► init_flow ──► open_browser ──► waiting ──► select_model
|
|
242
|
+
select_model ──(cmd)───► saving ──► done
|
|
243
|
+
any ────────────────────────────────────────────────────────────────► error
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## `zread update --stdio`
|
|
249
|
+
|
|
250
|
+
### ViewModel fields
|
|
251
|
+
|
|
252
|
+
| Field | Type | Notes |
|
|
253
|
+
|---|---|---|
|
|
254
|
+
| `state` | string | See states below |
|
|
255
|
+
| `current_version` | string | Installed version |
|
|
256
|
+
| `latest_version` | string | Available version; present in `has_update`+ |
|
|
257
|
+
| `download_url` | string | Asset URL for the update binary |
|
|
258
|
+
| `package_manager` | string | e.g. `"brew"`; present in `package_manager` state |
|
|
259
|
+
| `downloaded_bytes` | int | Bytes downloaded so far |
|
|
260
|
+
| `total_bytes` | int | Total download size |
|
|
261
|
+
| `download_percent` | float | 0–100 |
|
|
262
|
+
| `error` | string | Error message in `error` state |
|
|
263
|
+
|
|
264
|
+
States: `"checking"` → `"up_to_date"` / `"package_manager"` / `"has_update"` → `"downloading"` → `"confirm_restart"` / `"error"`
|
|
265
|
+
|
|
266
|
+
Terminal states (emit `done=true`): `up_to_date`, `package_manager`, `error`, and after restart/skip.
|
|
267
|
+
|
|
268
|
+
### Commands
|
|
269
|
+
|
|
270
|
+
| State | `waiting_for` | Command | Params |
|
|
271
|
+
|---|---|---|---|
|
|
272
|
+
| `has_update` | `["download","quit"]` | `download` | `{}` |
|
|
273
|
+
| `confirm_restart` | `["restart","skip_restart","quit"]` | `restart` | `{}` |
|
|
274
|
+
| `confirm_restart` | `["restart","skip_restart","quit"]` | `skip_restart` | `{}` |
|
|
275
|
+
| all others | `[]` | *(wait for internal events)* | — |
|
|
276
|
+
|
|
277
|
+
### State machine
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
checking ──► up_to_date (terminal)
|
|
281
|
+
──► package_manager (terminal)
|
|
282
|
+
──► has_update ──(download)──► downloading ──► confirm_restart
|
|
283
|
+
──(restart/skip)──► done
|
|
284
|
+
checking / downloading ──(error)──► error (terminal)
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## `zread version --stdio`
|
|
290
|
+
|
|
291
|
+
Emits a single event with `done: true` immediately. No commands are accepted.
|
|
292
|
+
|
|
293
|
+
### ViewModel fields
|
|
294
|
+
|
|
295
|
+
| Field | Type | Notes |
|
|
296
|
+
|---|---|---|
|
|
297
|
+
| `version` | string | e.g. `"1.2.3"` |
|
|
298
|
+
| `channel` | string | Release channel (if set) |
|
|
299
|
+
| `go_version` | string | Go runtime version |
|
|
300
|
+
| `os` | string | OS name |
|
|
301
|
+
| `arch` | string | CPU architecture |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Practical tips
|
|
306
|
+
|
|
307
|
+
- Always flush stdin after writing a command (the driver reads line-by-line).
|
|
308
|
+
- Treat any line on stdout that fails to parse as JSON as a bug — log it but do not crash; zread should not print non-JSON to stdout in `--stdio` mode.
|
|
309
|
+
- When `waiting_for` is `[]` and `done` is `false`, keep reading — the driver is awaiting an internal async result and will emit the next event on its own.
|
|
310
|
+
- For long-running commands (`generate`), keep reading events continuously; there is no heartbeat, but progress events arrive whenever state changes.
|
|
311
|
+
- To cancel cleanly, send `{"type":"quit","params":{}}` and then drain events until `done` rather than killing the process.
|
|
312
|
+
- `done: true` events are always terminal. Do not send further commands.
|
package/dist/banner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,QAAA,IAAI,aAAa,QAAK,CAAC;AAoBvB;;GAEG;AACH,iBAAS,oBAAoB,IAAI,MAAM,CAGtC;AAED,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAC;AAc/C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,GAAE,MAAkB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,QAAA,IAAI,aAAa,QAAK,CAAC;AAoBvB;;GAEG;AACH,iBAAS,oBAAoB,IAAI,MAAM,CAGtC;AAED,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAC;AAc/C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,GAAE,MAAkB,GAAG,MAAM,CAoGrE"}
|
package/dist/banner.js
CHANGED
|
@@ -54,7 +54,14 @@ export function generateBanner(colorTheme = '#49bccf') {
|
|
|
54
54
|
const theme = (colorTheme === 'random' || colorTheme === 'rotate') ? getRotatedColorTheme() : colorTheme;
|
|
55
55
|
const rgb = hexToRgb(theme);
|
|
56
56
|
const version = process.env.AICODE_CLI_VERSION || '';
|
|
57
|
-
|
|
57
|
+
// 防御 CWD 被删除的场景: process.cwd() 会抛 ENOENT
|
|
58
|
+
let cwd;
|
|
59
|
+
try {
|
|
60
|
+
cwd = process.cwd().replace(process.env.HOME || process.env.USERPROFILE || '', '~');
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
cwd = '<unknown>';
|
|
64
|
+
}
|
|
58
65
|
const color = (text) => `\x1b[38;2;${rgb.r};${rgb.g};${rgb.b}m${text}\x1b[0m`;
|
|
59
66
|
const dim = (text) => `\x1b[2m${text}\x1b[0m`;
|
|
60
67
|
const bold = (text) => `\x1b[1m${text}\x1b[0m`;
|
package/dist/banner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,+BAA+B;AAC/B,IAAI,aAAa,GAAG,EAAE,CAAC;AACvB,IAAI,CAAC;IAC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,EAAE;QACF,IAAI,CAAC,QAAQ,CAAC;QACd,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,EAAI,MAAM,EAAU,KAAK,CAAC,OAAO,CAAC,EAAO,QAAQ,CAAC;QACtE,EAAE;QACF,GAAG,CAAC,oDAAoD,CAAC;QACzD,EAAE;QACF,GAAG,CAAC,2FAA2F,CAAC;QAChG,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CA6ErC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,SAAS,CA8CtC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAErC"}
|
package/dist/config-loader.js
CHANGED
|
@@ -28,8 +28,15 @@ export function getConfigDir() {
|
|
|
28
28
|
resolvedPath = configDir;
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
// 相对路径:相对于当前工作目录
|
|
32
|
-
|
|
31
|
+
// 相对路径:相对于当前工作目录 (cwd 不可用时退回 homedir)
|
|
32
|
+
try {
|
|
33
|
+
resolvedPath = resolve(configDir);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// cwd 被删除: process.cwd() throws ENOENT → path.resolve 也炸
|
|
37
|
+
// 退回 homedir, 走默认配置目录分支
|
|
38
|
+
return join(homedir(), defaultConfig.configDir);
|
|
39
|
+
}
|
|
33
40
|
}
|
|
34
41
|
// 🔒 规范化路径(消除 .. 和 .)
|
|
35
42
|
const normalized = normalize(resolvedPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE1F,IAAI,YAAY,GAAqB,IAAI,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,gCAAgC;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAEpD,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,YAAoB,CAAC;QAEzB,aAAa;QACb,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YACtB,YAAY,GAAG,OAAO,EAAE,CAAC;QAC3B,CAAC;aAAM,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;aAAM,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACjC,YAAY,GAAG,SAAS,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,
|
|
1
|
+
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA;;;GAG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AAC,CAAC;YAClB,YAAY,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,eAAe;QACf,WAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE;YACzC,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,sBAAsB;SAC/B,CAAC,CAAC;QACH,YAAY,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;IACtC,CAAC;IAED,qCAAqC;IACrC,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,2BAA2B,GAAG,QAAQ,CAAC;IAEnD,OAAO,YAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,EAAE,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ia-ccun/code-agent-cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "AI Coding Agent CLI - 基于OpenClaw🦞底层Agent(pi)原理封装的编码智能体(供学习使用)。",
|
|
3
|
+
"version": "0.0.53-beta.2",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"main": "./dist/index.js",
|
|
7
6
|
"types": "./dist/index.d.ts",
|
|
@@ -35,10 +34,10 @@
|
|
|
35
34
|
"prepare": "husky"
|
|
36
35
|
},
|
|
37
36
|
"dependencies": {
|
|
38
|
-
"@earendil-works/pi-agent-core": "^
|
|
39
|
-
"@earendil-works/pi-ai": "^
|
|
40
|
-
"@earendil-works/pi-coding-agent": "^
|
|
41
|
-
"@earendil-works/pi-tui": "^
|
|
37
|
+
"@earendil-works/pi-agent-core": "^1.1.0",
|
|
38
|
+
"@earendil-works/pi-ai": "^1.1.0",
|
|
39
|
+
"@earendil-works/pi-coding-agent": "^1.1.0",
|
|
40
|
+
"@earendil-works/pi-tui": "^1.1.0"
|
|
42
41
|
},
|
|
43
42
|
"overrides": {
|
|
44
43
|
"glob": "^11.0.0",
|
|
@@ -60,6 +59,7 @@
|
|
|
60
59
|
"@typescript-eslint/parser": "^8.57.0",
|
|
61
60
|
"eslint": "^10.0.3",
|
|
62
61
|
"husky": "^9.1.7",
|
|
62
|
+
"pi-lean-ctx": "^3.8.11",
|
|
63
63
|
"playwright": "^1.60.0",
|
|
64
64
|
"shx": "^0.4.0",
|
|
65
65
|
"typescript": "^5.7.2",
|
|
@@ -80,6 +80,6 @@
|
|
|
80
80
|
"configDir": ".aicode-cli"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
|
-
"node": ">=
|
|
83
|
+
"node": ">=22.19.0"
|
|
84
84
|
}
|
|
85
85
|
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -6,6 +6,7 @@ import { symlink as fsSymlink } from 'fs/promises';
|
|
|
6
6
|
import { join, dirname, relative } from 'path';
|
|
7
7
|
import { homedir } from 'os';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
|
+
import { spawn } from 'child_process';
|
|
9
10
|
|
|
10
11
|
// Get __dirname equivalent for ES modules
|
|
11
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -240,7 +241,6 @@ const FORCE_OVERWRITE_LIST = [
|
|
|
240
241
|
'APPEND_SYSTEM.md',
|
|
241
242
|
'SYSTEM.md',
|
|
242
243
|
'dangerous-patterns.json',
|
|
243
|
-
'settings.json',
|
|
244
244
|
'help.md',
|
|
245
245
|
'extensions/*.ts',
|
|
246
246
|
'prompts/*.md',
|
|
@@ -463,6 +463,63 @@ logSecurity('install_complete', {
|
|
|
463
463
|
piDir,
|
|
464
464
|
});
|
|
465
465
|
|
|
466
|
+
// ============================================================================
|
|
467
|
+
// Auto-install codegraph (optional dependency)
|
|
468
|
+
// ============================================================================
|
|
469
|
+
|
|
470
|
+
const CODEGRAPH_PKG = '@colbymchenry/codegraph@0.9.7';
|
|
471
|
+
|
|
472
|
+
async function installCodegraph() {
|
|
473
|
+
return new Promise((resolve) => {
|
|
474
|
+
const child = spawn('npm', ['i', '-g', CODEGRAPH_PKG], {
|
|
475
|
+
stdio: 'pipe',
|
|
476
|
+
shell: process.platform === 'win32',
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
let stderr = '';
|
|
480
|
+
|
|
481
|
+
child.stderr.on('data', (data) => {
|
|
482
|
+
stderr += data.toString();
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
child.on('close', (code) => {
|
|
486
|
+
if (code === 0) {
|
|
487
|
+
console.log('✓ Installed codegraph globally,See UniDoc《2026.5 aicode+codegraph 安装与使用》');
|
|
488
|
+
logSecurity('codegraph_install', {
|
|
489
|
+
package: CODEGRAPH_PKG,
|
|
490
|
+
success: true
|
|
491
|
+
});
|
|
492
|
+
} else {
|
|
493
|
+
// 静默失败,不中断主流程
|
|
494
|
+
if (process.env.DEBUG) {
|
|
495
|
+
console.log(`⚠ Could not install codegraph: ${stderr.slice(0, 100)}`);
|
|
496
|
+
}
|
|
497
|
+
logSecurity('codegraph_install', {
|
|
498
|
+
package: CODEGRAPH_PKG,
|
|
499
|
+
success: false,
|
|
500
|
+
error: stderr.slice(0, 200)
|
|
501
|
+
}, 'warn');
|
|
502
|
+
}
|
|
503
|
+
resolve();
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
child.on('error', (err) => {
|
|
507
|
+
if (process.env.DEBUG) {
|
|
508
|
+
console.log(`⚠ Could not install codegraph: ${err.message}`);
|
|
509
|
+
}
|
|
510
|
+
logSecurity('codegraph_install', {
|
|
511
|
+
package: CODEGRAPH_PKG,
|
|
512
|
+
success: false,
|
|
513
|
+
error: err.message
|
|
514
|
+
}, 'warn');
|
|
515
|
+
resolve();
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Execute codegraph installation
|
|
521
|
+
await installCodegraph();
|
|
522
|
+
|
|
466
523
|
console.log('\n✨ Setup complete!');
|
|
467
524
|
console.log('📝 Configuration files are in ~/.aicode-cli/');
|
|
468
525
|
console.log('🔗 ~/.pi is linked to ~/.aicode-cli (ensuring model configs work)');
|