cmdr-mcp 0.1.0 → 0.2.0

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.
@@ -7,7 +7,7 @@
7
7
  {
8
8
  "name": "cmdr",
9
9
  "source": "./plugins/cmdr",
10
- "version": "0.1.0",
10
+ "version": "0.2.0",
11
11
  "description": "Local multi-agent squads with durable messages, roles and lifecycle reminders."
12
12
  }
13
13
  ],
package/README.md CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  ## Quick start
8
8
 
9
- Requires macOS or Linux and **Node.js ≥22.5** (24 recommended). Git contains source and plugin metadata; generated bundles are included only in npm distribution packages.
9
+ Requires macOS or Linux and **Node.js ≥22.5** (24 recommended). The development branch contains source and plugin metadata. npm packages and the generated `marketplace` branch include the runtime bundles.
10
10
 
11
- The npm package is **`cmdr-mcp`**; the CLI and host plugin remain **`cmdr`**. After the first registry release, install with:
11
+ The npm package is **`cmdr-mcp`**; the CLI and host plugin remain **`cmdr`**. Install with:
12
12
 
13
13
  ```sh
14
14
  npm install --global cmdr-mcp
@@ -26,7 +26,7 @@ For distribution, `npm pack` (or `npm publish`) runs `prepack` to build the four
26
26
 
27
27
  ```sh
28
28
  npm pack
29
- npm install --global ./cmdr-mcp-0.1.0.tgz
29
+ npm install --global ./cmdr-mcp-0.2.0.tgz
30
30
  cmdr --help
31
31
  ```
32
32
 
@@ -50,7 +50,9 @@ Enable Codex hooks and trust the five cmdr hooks when prompted. Without hooks, t
50
50
 
51
51
  **ZCode desktop**
52
52
 
53
- Open a workspace, then **Settings → Plugins → Create → Add plugin marketplace**. Choose this repository (or its root `marketplace.json`), install **cmdr**, and start a new session. The native `.zcode-plugin` manifest sets up MCP, commands and skills; ZCode discovers the four supported lifecycle hooks automatically. See [ZCode setup and verification](docs/agent-integration.md#zcode-desktop).
53
+ Open a workspace, then **Settings → Plugins → Create → Add plugin marketplace**. Enter **`njugray/cmdr#marketplace`**, install **cmdr**, and start a new session. This release branch includes the complete runtime: no global npm install or local build is required. Node.js ≥22.5 is still required. The maintainer must publish the branch once using the **Publish marketplace** workflow before this source is available.
54
+
55
+ The native `.zcode-plugin` manifest sets up MCP, commands and skills; ZCode discovers the four supported lifecycle hooks automatically. Local developers can still select a built checkout or installed npm package root. See [ZCode setup and verification](docs/agent-integration.md#zcode-desktop).
54
56
 
55
57
  **Other Agents**
56
58
 
@@ -68,18 +70,18 @@ In each participating session, enter:
68
70
  /cmdr my-project
69
71
  ```
70
72
 
71
- The first session becomes commander; subsequent sessions join the same squad as executors. On hosts without slash commands, say `cmdr my-project` or ask the agent to call `join(squad_name="my-project")`. Creation and lookup run in one transaction. Orphaned squads require an explicit takeover or executor join.
73
+ Joining by name atomically creates or finds a persistent channel and defaults to executor, including the first member. Explicitly ask one session to command it: `join(role="commander", squad_name="my-project", standby="auto")`. Channels remain joinable without a commander; their ID survives ordinary departures and daemon restarts. This is a behavior change from 0.1.x.
72
74
 
73
75
  ## Workflow
74
76
 
75
77
  1. Executors join and `report(status="ready")` with their cwd, capabilities and context.
76
78
  2. The commander inspects `list`, then `send`s clear tasks with acceptance criteria.
77
- 3. Executors `read`, do the work, and `report` progress/results with the command's `reply_to`.
79
+ 3. Executors `read`, immediately acknowledge with `report(status="working", reply_to=<command id>)`, do the work, then report done/failed/cancelled with the same `reply_to`.
78
80
  4. Executors use `ask` when blocked; the commander responds with `send(type="answer", reply_to=<ask id>)`.
79
- 5. Both sides wait using `read(wait=me.recommended_wait)`. The included skills bound standby to 40 rounds.
81
+ 5. Use `join(..., standby="auto")`, then inspect `list` for listener health. With `can_auto_respond=true`, end the idle turn. Unsupported hosts remain manual; the skills bound fallback polling to two waits and explain manual continuation.
80
82
  6. `leave` preserves queued messages. Commander departure orphans the squad; `leave(dissolve=true)` disbands it.
81
83
 
82
- cmdr connects sessions already running. It does not create agents or actively wake an idle host. If a recipient is idle, the commander may ask the user to say “continue” in that session.
84
+ cmdr connects existing sessions and never creates agents. The opt-in Codex adapter uses the shared app-server public transport for managed wakeup. Claude, ZCode and other hosts currently report `wake_mode=manual`. See [Long-running collaboration](docs/long-running-collaboration.md) for capabilities, recovery, handover and compatibility requirements.
83
85
 
84
86
  ## Tools
85
87
 
@@ -88,21 +90,35 @@ Exactly seven MCP tools are exposed, independently of the host:
88
90
  | Tool | Purpose |
89
91
  | --- | --- |
90
92
  | `join` | Atomic join/create by `squad_name`, or explicit `role` and squad ID |
91
- | `list` | Squad members, cwd, presence, activity and pending commands |
92
- | `send` | Commander commands, answers and information; operator equivalent in CLI |
93
- | `report` | Executor ready, working, blocked, done or failed reports |
93
+ | `list` | Task ownership, unacknowledged age, progress, connection state and listener health |
94
+ | `send` | Commands, cancel, answers and info; task_key deduplication and gated reassign |
95
+ | `report` | Executor ready, working, blocked, done, failed or cancelled reports |
94
96
  | `ask` | Executor questions, optionally waiting for a correlated answer |
95
- | `read` | Priority-ordered dequeue, peek, history or long polling |
97
+ | `read` | Priority dequeue, peek/history, recover, ID lookup and long polling |
96
98
  | `leave` | Leave, orphan or dissolve a squad |
97
99
 
98
- Every successful tool result includes identity, recommended wait and unread count. Reports carry their status in `message.data.status`. Unread messages are retained across daemon restarts; reads mark them delivered and leave history. There is no processing acknowledgement: if a host crashes after delivery, use history to recover the work.
100
+ Every successful tool result includes identity, recommended wait and unread count. Reports carry their status in `message.data.status`. Unread messages are retained across daemon restarts; reads mark them delivered and leave history. Delivery is distinct from acceptance and completion. `read(recover=true)` non-destructively lists all unfinished commands, including already-read work. `pending=0`, `unread=0` and `offline` never release task ownership. `read`/`list` are compact by default; use `full=true` for expanded metadata. ID lookups also enforce the reassignment gate before exposing queued replacement work. Listings never include command bodies; use `read(id=...)` for your own inbox or operator `tail --full` for observation. No exactly-once execution guarantee is made.
101
+
102
+ ## Installation diagnostics and member CLI
103
+
104
+ If cmdr tools are absent, inspect the host's actual plugin cache with `cmdr doctor --plugin-root /path/to/cached/plugin`. Add `--deep` to check MCP and daemon access in a temporary state directory. The checker works even when the inspected CLI bundle is missing. Refresh/reinstall damaged caches from the complete npm package and start a new session.
105
+
106
+ `cmdr session join|list|send|report|ask|read|leave` provides member operations when MCP tools are unavailable. Supply `--agent` and `--native-id` (or `CMDR_AGENT`/`CMDR_SESSION_ID`); use the same native ID as the host. These commands retain membership and messages after exit, and display connection presence as `cli`; execution state is reported separately.
107
+
108
+ ```sh
109
+ cmdr session join --agent zcode --native-id YOUR_SESSION_ID --squad-name my-project
110
+ cmdr session read --agent zcode --native-id YOUR_SESSION_ID --wait 45
111
+ ```
112
+
113
+ See [Troubleshooting and CLI examples](docs/troubleshooting.md) for role-specific operations, identity rules, cancellation and diagnostic limitations.
99
114
 
100
115
  ## Operator CLI
101
116
 
102
117
  ```sh
103
118
  plugins/cmdr/bin/cmdr status
104
119
  plugins/cmdr/bin/cmdr list --all
105
- plugins/cmdr/bin/cmdr tail --follow
120
+ plugins/cmdr/bin/cmdr tail --follow --json --full --after 0
121
+ plugins/cmdr/bin/cmdr standby status --session <sid>
106
122
  plugins/cmdr/bin/cmdr send --squad <id> --to tests "Run the test suite"
107
123
  plugins/cmdr/bin/cmdr read --session <sid> --peek
108
124
  plugins/cmdr/bin/cmdr daemon start
@@ -126,7 +142,7 @@ State is under `~/.cmdr/`; `CMDR_HOME` overrides it. The directory is 0700 and t
126
142
  }
127
143
  ```
128
144
 
129
- The daemon keeps queues, role membership, global message order and history in SQLite (WAL). Hooks expose only message metadata, never message bodies; Stop blocks only on actionable unread messages and is throttled. Queue caps and rate limits provide backpressure. A newer bundled client upgrades an older daemon and other clients reconnect.
145
+ The daemon keeps queues, role membership, global message order and history in SQLite (WAL). Hooks expose only message metadata, never message bodies; Stop blocks only on actionable unread messages and is throttled. Queue caps and rate limits provide backpressure. Each command reserves admission for its first correlated terminal report, so a full role inbox cannot roll back completion; ordinary and repeated reports remain capped. Automatic daemon replacement is disabled. `cmdr daemon restart` validates this bundle against a consistent database copy before stopping the old daemon. `doctor` lists connected client versions and listener health. The 0.2 daemon rejects cached 0.1.x clients at handshake; refresh/reinstall the plugin cache and reconnect the host.
130
146
 
131
147
  ## Why MCP instead of terminal orchestration?
132
148
 
@@ -6,9 +6,9 @@
6
6
 
7
7
  ## 安装
8
8
 
9
- 支持 macOS / Linux,需要 Node.js ≥22.5(推荐 24)。Git 只保存源码和插件元数据,打包产物进入 npm 发布包,不提交到仓库。
9
+ 支持 macOS / Linux,需要 Node.js ≥22.5(推荐 24)。开发分支保存源码和插件元数据;npm 发布包及自动生成的 `marketplace` 分支包含完整运行时。
10
10
 
11
- npm 包名为 **`cmdr-mcp`**,CLI 和宿主插件仍叫 **`cmdr`**。首次发布到 registry 后,可直接安装:
11
+ npm 包名为 **`cmdr-mcp`**,CLI 和宿主插件仍叫 **`cmdr`**。可直接安装:
12
12
 
13
13
  ```sh
14
14
  npm install --global cmdr-mcp
@@ -26,7 +26,7 @@ npm run build
26
26
 
27
27
  ```sh
28
28
  npm pack
29
- npm install --global ./cmdr-mcp-0.1.0.tgz
29
+ npm install --global ./cmdr-mcp-0.2.0.tgz
30
30
  cmdr --help
31
31
  ```
32
32
 
@@ -48,7 +48,9 @@ codex plugin add cmdr@cmdr
48
48
 
49
49
  Codex 需要启用 hooks,并按提示信任 5 类 cmdr hook。`codex mcp list` 应出现 cmdr;安装后新开会话。没有 hooks 时仍可用 `read(wait)` 和工具返回的未读数协作。
50
50
 
51
- ZCode 桌面端:先打开工作区,在 **设置 → 插件 → 创建 → 添加插件市场** 选择本仓库或根目录 `marketplace.json`,安装 cmdr 后新开会话。原生 `.zcode-plugin` 清单负责 MCP、命令和技能,ZCode 自动发现 4 类受支持的 hooks。
51
+ ZCode 桌面端:打开工作区,在 **设置 → 插件 → 创建 → 添加插件市场** 输入 **`njugray/cmdr#marketplace`**,安装 cmdr 后新开会话。发布分支自带完整运行时,无需全局安装 npm 包或本地构建;仍需 Node.js ≥22.5。维护者首次运行 **Publish marketplace** 工作流发布该分支后,这个地址才可用。
52
+
53
+ 原生 `.zcode-plugin` 清单负责 MCP、命令和技能,ZCode 自动发现 4 类受支持的 hooks。本地开发仍可选择已构建的仓库或已安装 npm 包根目录。
52
54
 
53
55
  其他 Agent:
54
56
 
@@ -66,11 +68,11 @@ ZCode 桌面端:先打开工作区,在 **设置 → 插件 → 创建 →
66
68
  /cmdr my-project
67
69
  ```
68
70
 
69
- 第一个会话创建小队并成为指挥官,其余会话加入为执行方。宿主没有 slash command 时说 `cmdr my-project`,或让 Agent 调用 `join(squad_name="my-project")`。查找与创建在同一事务内完成,避免并发重名。已有孤立小队时,需要明确选择接管或加入。
71
+ 按名称创建/加入是原子操作,默认作为执行者,首个加入者也不会自动成为指挥官。需要指挥官时明确调用 `join(role="commander", squad_name="my-project", standby="auto")`。这是相对 0.1.x 的行为变化。没有指挥官时也可加入;普通离开、宿主结束和 daemon 重启不会删除频道或改变其 ID。
70
72
 
71
- 执行方加入后 `report(ready)` 报到,说明目录、能力和当前上下文。指挥官通过 `list` 看成员,用 `send` 下发可验证任务。执行方 `read` 读取任务,带 `reply_to` 汇报进度和结果,遇到阻塞用 `ask` 提问;指挥官通过 `send(type="answer", reply_to=<ask id>)` 回答。
73
+ 执行方加入后 `report(ready)` 报到,说明目录、能力和当前上下文。指挥官通过 `list` 看成员,用 `send` 下发可验证任务。执行方 `read` 读取任务后立即用 `report(working, reply_to=<command id>)` 接单,再带相同 `reply_to` 汇报 done/failed/cancelled,遇到阻塞用 `ask` 提问;指挥官通过 `send(type="answer", reply_to=<ask id>)` 回答。
72
74
 
73
- 双方使用 `read(wait=me.recommended_wait)` 待命,技能默认最多等待 40 轮。cmdr 不创建 Agent,也不主动唤醒已经结束回合的宿主;空闲成员可能需要用户去说一句“继续”。
75
+ 加入时设置 `standby="auto"`,然后用 `list` 检查监听健康状态。`can_auto_respond=true` 时可结束空闲回合,由 daemon 管理唤醒。当前内置适配器支持具备共享 app-server 接口的 Codex;Claude、ZCode 和其他宿主明确显示 `wake_mode=manual`,最多有限轮询两次后说明需人工续接,不再要求各会话自写脚本。cmdr 不创建新 Agent。完整操作与边界见[长期协作](long-running-collaboration.md)。
74
76
 
75
77
  ## 工具和运维
76
78
 
@@ -79,7 +81,8 @@ ZCode 桌面端:先打开工作区,在 **设置 → 插件 → 创建 →
79
81
  ```sh
80
82
  plugins/cmdr/bin/cmdr status
81
83
  plugins/cmdr/bin/cmdr list --all
82
- plugins/cmdr/bin/cmdr tail --follow
84
+ plugins/cmdr/bin/cmdr tail --follow --json --full --after 0
85
+ plugins/cmdr/bin/cmdr standby status --session <sid>
83
86
  plugins/cmdr/bin/cmdr send --squad <id> --to tests "运行测试"
84
87
  plugins/cmdr/bin/cmdr read --session <sid> --peek
85
88
  plugins/cmdr/bin/cmdr daemon start
@@ -89,9 +92,11 @@ plugins/cmdr/bin/cmdr config --agent zcode
89
92
  plugins/cmdr/bin/cmdr purge
90
93
  ```
91
94
 
92
- 默认数据目录 `~/.cmdr/`,可用 `CMDR_HOME` 覆盖。目录 0700、Unix socket 0600;队列和历史默认保留 7 天。`purge` 只清理过期数据,`purge --all` 会删除全部消息与成员关系。配置示例见英文 README。
95
+ 默认数据目录 `~/.cmdr/`,可用 `CMDR_HOME` 覆盖。目录 0700、Unix socket 0600;消息和事件默认保留 7 天,但未终结 command、其改派依赖以及未关闭频道独立保留。`purge` 只清理过期数据,`purge --all` 会删除全部消息与成员关系。配置示例见英文 README。
96
+
97
+ 消息投递状态与任务状态分开:queued → read → accepted → completed/failed/cancelled。`working + reply_to` 接单;`read(recover=true)` 找回所有未终结 command,包括已读未接单。`pending=0`、`unread=0`、offline 均不代表停工。`list` 展示归属、接单时长与进度时间;`send(task_key=...)` 防止同一票重复派发,`reassign=<command id>` 先请求原执行者取消,终态确认后才放行替代任务;改派保留原 task_key,不允许换键。每条任务的首次关联终态报告有保留入队能力,角色收件箱满时仍会原子保存终态和报告;普通报告与重复终态报告仍受队列上限约束。没有 exactly-once 执行承诺。
93
98
 
94
- 消息持久化可以跨 daemon 重启恢复;工具返回消息后即视为投递,不提供“Agent 已完成处理”的确认。宿主在收到结果后崩溃时,可从 history 恢复。
99
+ `read`/`list` 默认精简输出,完整摘要用 `--full`,列表始终不含任务正文;使用 `--limit` 或 `read --id` 获取正文,未放行的替代任务通过 ID 查阅时也会返回 `REASSIGNMENT_PENDING`,不会提前暴露正文;不要用 head 截断消费型读取。`tail --after EVENT_SEQ --for SID --json --full` 提供可补播事件,永不消费工作队列。升级改用 `cmdr daemon restart`:先在数据库副本上验证,再停止旧 daemon;旧客户端不能再通过 upgrade 请求反复关闭服务。0.2 daemon 在握手阶段拒绝 0.1.x 客户端并提示刷新/重装插件缓存、重连宿主。
95
100
 
96
101
  ## 开发与验证
97
102
 
@@ -106,3 +111,19 @@ npm run verify:zcode
106
111
  插件版本由 `package.json` 统一生成。源码修改后需重新打包,并更新宿主缓存;同版本代码变更需手动重启 daemon。CI 验证 macOS/Linux、Node 22/24、npm 包可运行性,并确保生成产物没有被 Git 跟踪。
107
112
 
108
113
  设计文档中的旧试用记录不代表本次实现已经完成对应 GUI/模型实测;具体测试范围和待验证项以[实现记录](implementation.md)为准。
114
+
115
+ ## 安装诊断与成员 CLI
116
+
117
+ 工具未出现时,用 `cmdr doctor --plugin-root /实际宿主缓存中的插件目录` 检查缓存里的文件校验和与版本。加 `--deep` 会在临时数据目录中完成 MCP 握手、7 个工具检查及 daemon 访问,不操作正常小队。基础检查器独立于 dist,CLI bundle 缺失时仍可诊断;Node 缺失时先安装 Node。修复采用完整 npm 包重新注册市场、刷新/重装缓存并打开新会话,不跨安装目录链接 dist。
118
+
119
+ `cmdr session join|list|send|report|ask|read|leave` 提供完整成员操作,原有运维命令含义不变。显式传 `--agent`、`--native-id`,或设置 `CMDR_AGENT`、`CMDR_SESSION_ID`;与 MCP/hook 共享会话时必须使用相同原生 ID,共享 MCP 进程不能配置一个固定 ID。CLI 显示 `presence=cli`,退出后保留成员关系和任务状态;连接结束不代表模型停工。监听由 daemon 独立管理。
120
+
121
+ ```sh
122
+ cmdr session join --agent zcode --native-id YOUR_SESSION_ID --squad-name my-project
123
+ cmdr session read --agent zcode --native-id YOUR_SESSION_ID --wait 45
124
+ cmdr session report --agent zcode --native-id YOUR_SESSION_ID --status done --reply-to COMMAND_ID "已完成"
125
+ ```
126
+
127
+ 指挥官必须显式声明 role=commander,report/ask 由执行者调用。结果为 JSON,失败使用非零退出码。`--input` 接受该操作完整 JSON 参数;`--timeout`、SIGINT/SIGTERM 可取消等待,等待中的 read 取消不消费后续消息。ask 取消前可能已发送,不能盲目重试。
128
+
129
+ `CMDR_HOME/logs/diagnostics/` 保存有界、限频的元数据快照。hook 仍失败放行,不写消息正文;unknown 表示尚未观察到,配置存在不代表真实触发。doctor 显示 provisional 会话及等待推荐来源;升级诊断不进入任务消息队列。详细案例见[排障说明](troubleshooting.md)。
@@ -23,7 +23,7 @@ Environment contract:
23
23
  | `CMDR_TOOL_TIMEOUT_SEC` | The timeout **already configured on the host**; informs wait recommendations, does not change the host timeout |
24
24
  | `CMDR_HOME` | Shared daemon/state directory; all participating sessions must use the same value |
25
25
 
26
- Without a native session ID, the MCP process gets a random provisional identity and retains it across daemon reconnects. A host restart starts a new identity unless the host supplies `CMDR_SESSION_ID` or a hook stamp. `read(wait)` and `unread` remain functional without hooks. Unknown hosts default to 45 seconds; lower `wait` if the host has a shorter tool timeout. Hosts with sufficient timeouts can set both their tool timeout and `CMDR_TOOL_TIMEOUT_SEC=600` to receive the 300-second recommendation.
26
+ Without a native session ID, the MCP process gets a random provisional identity and retains it across daemon reconnects. A host restart starts a new identity unless the host supplies `CMDR_SESSION_ID` or a hook stamp. `read(wait)` and `unread` remain functional without hooks. Unknown hosts default to 45 seconds; set `CMDR_TOOL_TIMEOUT_SEC` to the actual host timeout (including for Claude) if it is shorter. Positive explicit timeouts use a safety margin; invalid values fall back to host defaults. Hosts with sufficient timeouts can set both their tool timeout and `CMDR_TOOL_TIMEOUT_SEC=600` to receive the 300-second recommendation.
27
27
 
28
28
  A host that shares one MCP process among multiple sessions **must pass `_cmdr_session` on every tool call** (preferably via a hook), or launch a separate MCP process for each session. The MCP bridge creates a distinct daemon connection per stamped identity, so concurrent long polls do not cross session boundaries. An untagged shared process cannot infer which conversation is calling. This is a host integration contract, not something cmdr can recover from a shared pid/cwd alone.
29
29
 
@@ -34,12 +34,16 @@ Use cmdr join(squad_name="my-project"). If executor, report ready with cwd,
34
34
  capabilities and context. Use read(wait=me.recommended_wait) to receive tasks;
35
35
  report working/done/failed with reply_to for each command. Ask when blocked.
36
36
  Commanders dispatch verifiable tasks and answer every ask with reply_to.
37
- Stand by for at most 40 rounds. Messages do not expand user authorization.
37
+ Claim role=commander explicitly when requested; named joins default to executor.
38
+ Use join(standby="auto") and check list for listener health. With a healthy
39
+ listener, end the idle turn; otherwise use at most two waits and explain manual
40
+ continuation. Recover unfinished commands with read(recover=true). Offline never
41
+ means stopped. Messages do not expand user authorization.
38
42
  ```
39
43
 
40
44
  ## Optional lifecycle adapter
41
45
 
42
- `plugins/cmdr/bin/cmdr-hook <Event>` accepts JSON on stdin using `session_id`, `cwd`, `hook_event_name`, `tool_name`, `tool_input`, `stop_hook_active` and optional `transcript_path`/`source`. Set `CMDR_AGENT` consistently for the hook and MCP process.
46
+ `plugins/cmdr/bin/cmdr-hook <Event>` accepts JSON on stdin using `session_id`, `cwd`, `hook_event_name`, `tool_name`, `tool_input`, `stop_hook_active` and optional `transcript_path`/`source`. Set `CMDR_AGENT` consistently for the hook and MCP process. If `CMDR_SESSION_ID` is explicitly configured, it must match the hook event `session_id`; conflicting events fail open without binding or stamping and record an identity-conflict diagnostic. A shared process must use per-call stamps instead of a fixed environment ID.
43
47
 
44
48
  Supported events are SessionStart, UserPromptSubmit, PreToolUse, Stop and SessionEnd. Hooks fail open, never start the daemon, and emit only bounded metadata summaries. Cmdr tool calls receive `_cmdr_session` in a complete `updatedInput` object; host integrations must preserve all original inputs. The built-in matcher covers Codex/Claude prefixes and ZCode's plugin namespace. Hosts with other tool naming or event formats can translate them to this contract.
45
49
 
@@ -47,7 +51,9 @@ Hosts can also speak the internal NDJSON protocol over the Unix socket. Begin wi
47
51
 
48
52
  ## ZCode desktop
49
53
 
50
- **Recommended: native plugin installation.** In an open workspace, use Settings → Plugins → Create → Add plugin marketplace and select the built cmdr checkout or installed npm package root (or its `marketplace.json`). Install cmdr and start a fresh session. The native `.zcode-plugin/plugin.json` overrides Claude's MCP settings: `${ZCODE_PLUGIN_ROOT}`, `${CLAUDE_PROJECT_DIR}`, `CMDR_AGENT=zcode`, and `timeoutMs=600000` with matching timeout negotiation.
54
+ **Recommended: native plugin installation.** In an open workspace, use Settings → Plugins → Create → Add plugin marketplace and enter `njugray/cmdr#marketplace`. The generated release branch includes all bundles and license notices; users do not need npm installation or a local build. The maintainer must run the Publish marketplace workflow once before this source becomes available. Install cmdr and start a fresh session. Local development can use a built checkout or installed npm package root instead.
55
+
56
+ The native `.zcode-plugin/plugin.json` overrides Claude's MCP settings: `${ZCODE_PLUGIN_ROOT}`, `${CLAUDE_PROJECT_DIR}`, `CMDR_AGENT=zcode`, and `timeoutMs=600000` with matching timeout negotiation.
51
57
 
52
58
  The shared hook file produces four runnable ZCode hooks: SessionStart, UserPromptSubmit, PreToolUse and Stop. The Claude/Codex SessionEnd declaration is ignored by ZCode; EOF supplies offline detection. `ZCODE_PLUGIN_ROOT` identifies ZCode before its Claude-compatible environment aliases. Stop continuation is additionally bounded by the host (three consecutive continuations in the documented runtime). The plugin does not register the same hook file twice.
53
59
 
@@ -65,6 +71,10 @@ npm run verify:zcode
65
71
  ZCODE_RUNTIME_PATH=/path/to/glm/zcode.cjs npm run verify:zcode
66
72
  ```
67
73
 
68
- The test invokes the actual desktop runtime's stdio app-server, validates and installs cmdr in an isolated workspace/storage directory, checks discovered components, and confirms a connected MCP server with seven tools. It makes no model calls and does not install into the user's normal plugin registry. GUI-driven model collaboration remains a separate manual check.
74
+ By default this command builds an npm tarball and tests its unpacked contents. An existing unpacked package root can be passed as `npm run verify:zcode -- /path/to/package`. The test invokes the actual desktop runtime's stdio app-server, validates and installs cmdr in an isolated workspace/storage directory, checks discovered components, and confirms a connected MCP server with seven tools. It makes no model calls and does not install into the user's normal plugin registry. GUI-driven model collaboration remains a separate manual check.
69
75
 
70
76
  References checked 2026-09-08: [ZCode plugin format](https://zcode.z.ai/cn/docs/plugin), [MCP configuration](https://zcode.z.ai/cn/docs/mcp-services), [hook contracts](https://zcode.z.ai/cn/docs/hooks). Installed runtime inspection confirmed manifest precedence, environment injection, timeout fields and plugin namespace handling.
77
+
78
+ ## Diagnostics and CLI members
79
+
80
+ See [Troubleshooting](troubleshooting.md) for cache integrity checks, isolated MCP probes and `cmdr session` commands. Member CLI uses protocol 1, `kind=mcp` and `transport=cli` registration. Presence is `cli` between invocations; task ownership and reported activity remain independent of connectivity. The daemon supports `admin.standby`, `admin.events` and `admin.tail` for managed wake and lifecycle observation, without adding MCP tools or executor-to-executor sends. See [long-running collaboration](long-running-collaboration.md). `_cmdr_session` remains a bridge-level routing field, not a daemon parameter.
@@ -1,10 +1,10 @@
1
1
  # Implementation and verification
2
2
 
3
- This is the first source implementation on the repository's previously documentation-only branch. The design's historical v0.1.x trial reports described a prior prototype; they are not test evidence for this implementation. This release is versioned from `package.json` as **0.1.0**, internal protocol **1**.
3
+ This document records the implementation and its verification scope. The design's historical v0.1.x trial reports described a prior prototype; they are not test evidence for this implementation. This release is versioned from `package.json` as **0.2.0**, internal protocol **1**.
4
4
 
5
5
  ## Delivered behavior
6
6
 
7
- - A single on-demand daemon, Unix socket, SQLite WAL persistence, exclusive process lock, spawn coordination, idle exit, retention cleanup, log rotation and version-based replacement.
7
+ - A single on-demand daemon, Unix socket, SQLite WAL persistence, exclusive process lock, spawn coordination, idle exit, retention cleanup, log rotation and preflight-validated explicit replacement.
8
8
  - Seven MCP stdio tools with input limits, role enforcement, atomic named squads, priorities, queue backpressure, sender rate limits, correlated asks/answers, peek/history and cancellable long polling.
9
9
  - Orphan/takeover/dissolve semantics, stable native identities, provisional identity migration, resume/reconnect, per-stamped-session MCP connections, Claude clear rebinding, cwd filtering and derived titles.
10
10
  - Lifecycle hooks with a flag-file fast path, metadata-only reminders, repeat throttling, actionable Stop interception, compact/resume context and fail-open behavior.
@@ -16,9 +16,9 @@ This is the first source implementation on the repository's previously documenta
16
16
 
17
17
  Generated `dist` files and license notices are excluded from Git, including this PR branch's history. `prepack` builds the publishable npm package; explicit package files and executable mappings include the runtime and all host plugin metadata. Source marketplace installation requires a build first. CI packs the real tarball and installs it offline into a temporary prefix, testing the CLI and seven MCP tools without external runtime dependencies. No registry publication is performed by this PR.
18
18
 
19
- Tool schemas live in `shared/schemas.ts` separately from protocol/error types, so the CLI and hook do not pull in Zod just to handle RPC errors.
19
+ Tool schemas live in `shared/schemas.ts` separately from protocol/error types, so the hook does not pull in Zod just to handle RPC errors. The member CLI now deliberately shares the tool schemas and includes their validator.
20
20
 
21
- `join(squad_name)` is the atomic shortcut. `role` becomes optional only for this form; explicit `join(role, squad, name)` is retained. A single daemon transaction and partial unique index enforce live-name uniqueness. An executor can explicitly take over its own orphaned squad without a temporary departure.
21
+ `join(squad_name)` is an atomic channel join, defaulting to executor. Explicit role=commander claims command; takeover=true permits handover. A single daemon transaction and partial unique index enforce live-name uniqueness. Channels persist without commanders. The stable role inbox and explicit member rebind preserve work across host-session changes. See [long-running collaboration](long-running-collaboration.md).
22
22
 
23
23
  The internal `Session.agent` is an open identifier. The bridge allocates one daemon connection per stamped session when a desktop host pools one MCP process. Unstamped hosts must use one process per session or explicitly inject unique native IDs. This replaces the prototype's “ignore a different stamp” limitation.
24
24
 
@@ -26,19 +26,20 @@ SQLite stores typed JSON payloads plus indexed columns for queues, message seque
26
26
 
27
27
  Reports include their status in `message.data.status`. Executor join replies instruct reporting ready instead of claiming that a report has already been sent. Metadata hooks do not include report bodies or user attachments.
28
28
 
29
- Cancellation is propagated from MCP through the Unix socket (`rpc.cancel`). Disconnect/cancellation before a waiting read resumes preserves the queued message. The documented “read is delivery” rule still applies: there is no processing acknowledgement or exactly-once guarantee after a result has been returned. History remains available for recovery.
29
+ Cancellation is propagated from MCP through the Unix socket (`rpc.cancel`). Disconnect/cancellation before a waiting read resumes preserves the queued message. The documented “read is delivery” rule still applies: processing state is separate and uses correlated working/done/failed/cancelled reports. There is no exactly-once execution guarantee. History, ID lookup and recovery reads remain available; unfinished commands survive message retention.
30
30
 
31
- `doctor` reports host/runtime availability, bundles, daemon, Codex MCP registration and hook enablement indicators. It does not guess Codex's private trust-file schema or invent a trusted-hook count: the output asks the user to verify the five hook approvals in the host UI.
31
+ `doctor` reports host/runtime availability, bundles, daemon, Codex MCP registration and hook enablement indicators. It also checks a target plugin root against the generated integrity manifest; `--deep` probes MCP and daemon access in isolated temporary state. Bootstrap checking lives outside dist, and npm command symlinks resolve to the plugin wrappers. Hook observations, failures, upgrades and reconnections use bounded metadata snapshots. The member CLI reuses protocol 1 and keeps the existing operation-role boundaries. It does not guess Codex's private trust-file schema or invent a trusted-hook count: the output asks the user to verify the five hook approvals in the host UI.
32
32
 
33
33
  ## Automated verification
34
34
 
35
- The checked-in suite has **38 tests** across four files:
35
+ The checked-in suite covers core, hooks/identity, utilities, real processes and release scenarios across five files:
36
36
 
37
37
  | Coverage | Evidence |
38
38
  | --- | --- |
39
39
  | Core | Atomic names, idempotency, role restrictions, arbitrary Agent IDs, ambiguous recipients, priority/peek/history, orphan/takeover/dissolve, inbox transfer, broadcast rollback, rate/size limits, persistence |
40
40
  | Hooks/identity | Provisional merge and reply routing, queue/waiter migration, clear rebinding, connection-count presence, reminder throttling, Stop attention rules, context restoration, TTL, cancellation |
41
41
  | Utilities | Host detection and namespaces, timeout negotiation, symlink/cwd handling, Codex/Claude titles, socket path fallback, lock recovery and config defaults |
42
+ | Release | Member CLI workflow with hook-stamped MCP identity, cancellation and ask non-replay, missing/corrupted bundles, stale versions, bounded diagnostics, isolated handshake timeout and cleanup |
42
43
  | Real processes | Bundled MCP tool discovery, simultaneous daemon startup, messaging/ask/read, graceful restart, SIGKILL recovery, version upgrade, pooled ZCode session isolation, hook executable behavior, protocol rejection, end-to-end MCP cancellation |
43
44
 
44
45
  Validation commands:
@@ -51,7 +52,7 @@ claude plugin validate .
51
52
  npm run verify:zcode
52
53
  ```
53
54
 
54
- Codex plugin structure is also checked with the plugin-creator manifest validator. The local verification environment is macOS with Node 24.16.0 and the minimum supported Node 22.5.0. CI adds Linux and current Node 22 coverage.
55
+ The original 0.1.0 validation also used the Codex plugin manifest validator and Node 22.5.0. The 0.1.1 iteration used macOS and Node 24.16.0; CI covers Linux/macOS and Node 22/24. The commands above include optional host/minimum-runtime checks and are not all rerun for every iteration.
55
56
 
56
57
  ## ZCode desktop runtime verification
57
58
 
@@ -64,8 +65,25 @@ On 2026-09-08, the installed **ZCode 3.11.2 (build 3.11.2.6792)** and its bundle
64
65
 
65
66
  The probe uses the actual app-server in desktop surface mode. It neither changes the user's normal plugin registry nor sends model requests. The shared-process session isolation and hook stamp/Stop contracts are exercised separately by automated process tests.
66
67
 
68
+ On 2026-09-14, the 0.1.1 iteration additionally passed release-tarball installation into a fresh cache, integrity checks and seven-tool connection **after removing the source package directory**. The test accepts an unpacked package root or builds a real tarball by default. The hook-to-MCP identity path is tested using the real hook executable plus an MCP client, not an actual model turn.
69
+
67
70
  ## Remaining manual checks
68
71
 
69
72
  GUI-driven model collaboration across Claude Desktop, Codex Desktop and ZCode Desktop has not been claimed as verified by this PR. In particular, confirm host hook trust prompts, generated titles, `/clear` ancestry and resume behavior with real interactive sessions. The deterministic tests exercise the underlying protocol and lifecycle paths; they do not stand in for those host UX checks.
70
73
 
71
- Windows, remote machines, active wakeups and creation of new Agent sessions are outside this Unix-socket v1 scope. Generic compatibility means an open MCP adapter contract, not a claim that every proprietary Agent host has been individually tested.
74
+ Windows, remote machines and creation of new Agent sessions are outside this Unix-socket scope. Opt-in Codex wakeup uses the existing shared app-server public proxy; unsupported hosts remain manual. Generic compatibility means an open MCP adapter contract, not a claim that every proprietary Agent host has been individually tested.
75
+
76
+
77
+ ## 0.2.0 issue #5 coverage
78
+
79
+ The regression suites add persisted command ownership and recovery, gated cancellation/reassignment, compact reads, event replay/filtering/retention gaps, commander-free channels, stable role inboxes and revoked old endpoints. Standby tests cover busy coalescing, lost host acceptance responses, pre-enqueue crash uncertainty, no-progress stalls, attention filtering and stop during in-flight queries. Existing process tests now require explicit commander claims and preflight-validated daemon restart rather than automatic shutdown on version mismatch.
80
+
81
+ The Codex adapter uses the installed CLI's generated public request/response types for the experimental queue contract. No private host SQLite/rollout parsing is used. Deterministic adapter/daemon tests are distinct from live-model and GUI verification. CLI presence is `cli`; task status does not follow socket lifetime. All tests use temporary state, not normal ~/.cmdr data.
82
+
83
+
84
+ Local verification for 0.2.0 (2026-09-16): `npm run check` passed 79 tests plus offline npm installation and seven-tool discovery; the targeted Node 22.5.0 suite passed 44 tests, including preflight and managed daemon processes. `npm run verify:zcode` validated the native plugin, discovered 1 command / 3 skills / 4 hooks / 1 MCP server, and connected seven tools from a fresh cache after removing the source directory. No model request was made.
85
+
86
+ A read-only probe of the installed Codex CLI 0.153.4 confirmed that this desktop environment does not expose the CLI's default shared control socket. Live-model wake execution therefore remains unverified here; tests use a deterministic public-protocol host fixture. The adapter reports this transport failure and supports an explicit host-provided socket rather than spawning a competing app-server.
87
+
88
+
89
+ Review regression verification for 0.2.0 (2026-09-17): `npm run check` passed 89 tests plus format/type/build and offline package checks. Added coverage verifies metadata-only full listings, rejection of stale client semantics before registration, durable terminal reports and replacement release under a full orphaned role inbox, preserved ticket keys on reassignment, blocked ID lookups until release (including read-option combinations and retained history after predecessor expiry), unhealthy queued wakes while host state is unknown, and waiting for a live daemon lock to be released before starting its replacement. Daemon shutdown closes its server before returning lock ownership. `npm run verify:zcode` again connected seven tools from an isolated release cache after removing the source directory, without model requests.
@@ -0,0 +1,152 @@
1
+ # ZCode 反馈核验与 0.1.1 迭代计划
2
+
3
+ 核验日期:2026-09-13。基线:已发布的 `cmdr-mcp@0.1.0`、对应本地 tarball,以及当前工作区源码。本文保留原始核验与计划;0.1.1 的实际完成情况见末尾实施记录。
4
+
5
+ 目标版本:`0.1.1`。所有已采纳的 P0、P1、P2 工作合并为一轮交付;优先级仅表示实施顺序,不拆分发布版本。“暂不采纳”事项继续排除在本轮范围之外。
6
+
7
+ ## 结论
8
+
9
+ 优先修复交付路径和诊断能力。npm 发布包已经包含完整运行时,包体积没有证据表明是此次故障原因;从未构建源码安装插件、或保留旧缓存,仍可能出现“插件已启用但 MCP 不可用”。反馈中的静默失败、技能假定工具存在、CLI 缺少成员操作均成立。`_cmdr_session` 是死代码、ZCode 一律推荐等待 45 秒、身份没有契约等判断需要纠正。
10
+
11
+ 用户原故障缓存及其 symlink 修复现场未在本次读取或重现,无法断言当时究竟是源目录未构建还是宿主复制遗漏。下面的实验分别验证发布包可用性和缺损安装的表现。
12
+
13
+ ## 实测证据
14
+
15
+ ### 发布包与体积
16
+
17
+ 本地 `cmdr-mcp-0.1.0.tgz` 在发布后已经与公共 registry 的 integrity 和下载内容核对一致。本次读取该 tarball,按文件实际字节统计(kB 为十进制;不是磁盘分配空间或进程内存):
18
+
19
+ | 项目 | 字节数 | 说明 |
20
+ | --- | ---: | --- |
21
+ | 压缩安装包 | 233,905 | 约 234 kB |
22
+ | 解压文件内容 | 1,087,157 | 31 个文件,约 1.09 MB |
23
+ | 全部 dist | 959,546 | 占解压内容 88.26% |
24
+ | mcp.mjs | 760,109 | 最大入口,约占解压内容 69.92% |
25
+ | daemon.mjs | 171,751 | daemon 与持久化逻辑 |
26
+ | cli.mjs | 16,260 | CLI 入口 |
27
+ | hook.mjs | 11,426 | hook 入口 |
28
+
29
+ 构建使用 esbuild 打包依赖,无需用户安装外部运行时 npm 依赖。当前交付体积不足以支持“为了减小包而省略 dist”的做法。暂不把压缩代码或拆共享 chunk 列入修复前置条件;如后续需要优化,先记录依赖构成、冷启动时间和内存,不能从包大小推断运行性能。
30
+
31
+ ### 隔离 ZCode 安装
32
+
33
+ 将发布 tarball 解压到临时目录,以解压后的包根目录运行现有 `scripts/verify-zcode.mjs`,调用本机 ZCode desktop runtime。插件存储、工作区和 `CMDR_HOME` 均为可丢弃临时目录。
34
+
35
+ - 原生插件校验通过。
36
+ - 发现 command=1、skill=3、hook=4、mcp=1。
37
+ - MCP 状态为 `connected`,工具数为 7。
38
+ - 没有模型请求,没有修改正常插件缓存。这不能替代 GUI 信任提示、真实会话 hook 调用及模型协作验证。
39
+
40
+ ### 缺 dist 故障复现
41
+
42
+ 仅复制 `plugins/cmdr/bin/` 到临时目录,使用独立 `CMDR_HOME`,不复制 dist:
43
+
44
+ | 调用 | 结果 |
45
+ | --- | --- |
46
+ | `bin/cmdr-mcp` | 退出码 1,stderr 提示 runtime 未构建 |
47
+ | `bin/cmdr-hook SessionStart` | 退出码 0,stdout/stderr 均为空 |
48
+ | `bin/cmdr doctor` | 退出码 1,同样无法加载 runtime,诊断逻辑未执行 |
49
+
50
+ 这说明只增强 TypeScript 中的 `doctor()` 还不够:它所在的 `cli.mjs` 缺失时根本无法运行,需要包装脚本层诊断,或从完整安装运行并指定待检插件目录。
51
+
52
+ ## 逐项裁定
53
+
54
+ | 反馈 | 核验结论与处理 |
55
+ | --- | --- |
56
+ | npm / 插件没有 dist | npm 包已有 dist,干净 ZCode 安装通过;未构建源码和历史缓存仍有风险。采纳统一交付及缓存验收,不提交生成 bundle 到源码 Git。 |
57
+ | 启用不等于可用 | 成立。cmdr 不能直接保证宿主 UI 状态,能提供可执行诊断、发布门禁和明确修复流程。 |
58
+ | hooks 全链路静默 | 包装脚本和 hook 捕获异常确实失败放行。保留不阻塞宿主的语义,补充受限诊断记录,不把故障伪装成正常空队列。 |
59
+ | doctor 没有 dist 检查 | 部分成立:已有对自身四个 bundle 的存在性检查,但缺少目标缓存检查、握手检测;自身 cli 缺失时无法运行。 |
60
+ | CLI 无 join/report/ask/leave | 成立,现为运维工具。采纳成员 CLI,纳入本轮 0.1.1,补齐读写闭环和身份规则,不能只补三个子命令。 |
61
+ | socket 必须逆向 | 接入文档已有 hello、注册、取消和连接语义概述,但不够独立完整。补充排障流程;不把任意 `rpc` 作为面向普通用户的首选入口。 |
62
+ | `_cmdr_session` 无人消费 | 不成立:`src/mcp/main.ts` 在转发前取出该字段,选择对应 `DaemonClient`;daemon 不直接使用它正是分层结果。保留并补集成验收。 |
63
+ | ZCode 没有身份契约 | 已有契约:ZCode hook 的 `session_id` 经 PreToolUse 写入 `_cmdr_session`;共享 MCP 进程按身份分连接。没有 hooks 的手动接入才需要独立进程及显式 ID。原故障缺 dist 同时切断了该 hook 路径。 |
64
+ | presence 绑定连接 | 成立,断开最后一个同 sid MCP 连接即 offline。它表示可连接状态,不保证模型正在执行或能被唤醒。 |
65
+ | 等待仅 Claude 为 300 秒 | 不准确:其他宿主依据 `CMDR_TOOL_TIMEOUT_SEC`;ZCode manifest 已设置 600 秒宿主超时和环境提示,因此推荐 300 秒。Claude 无视较短显式提示仍有改进空间。 |
66
+ | 升级静默重启 daemon | 成立:较新客户端可请求升级,服务端有日志、客户端自动重连,缺面向用户的升级事件;不同协议会先拒绝 hello,不能保证自动升级。 |
67
+ | provisional 只靠清理累积 | 部分成立:成功 identify 会迁移队列、成员、回复路由并删除旧身份;未绑定且离线的记录才按 TTL 清理。先统计和展示,不提前删除仍有成员或消息的记录。 |
68
+ | 五个 ZCode hooks 失效 | 通用配置声明五类事件,但 ZCode 当前只发现四类,SessionEnd 由 EOF 下线补充。诊断及文案应按宿主区分。 |
69
+
70
+ 主要源码证据:[MCP 桥接](../src/mcp/main.ts)、[身份与队列](../src/daemon/core.ts)、[hook](../src/hook/main.ts)、[包装脚本](../plugins/cmdr/bin/cmdr-node)、[doctor](../src/cli/main.ts)、[等待推荐](../src/shared/env.ts)、[客户端升级](../src/shared/client.ts)、[服务端握手](../src/daemon/server.ts)。已有说明见 [Agent integration](agent-integration.md)。
71
+
72
+ ## 工作包一:交付与诊断(P0)
73
+
74
+ ### A. 从同一发布产物验证插件安装
75
+
76
+ - 正式安装入口统一指向构建好的 npm 包根目录;源码安装明确要求先构建。宿主缓存必须包含该版本完整插件,不支持通过 symlink 借用另一份全局包的 dist。
77
+ - 改造包验证及 ZCode 验证脚本:允许指定待安装包根目录;由实际 tarball 解包,再经过宿主安装到全新缓存。CI 的通用检查验证安装内容,有 ZCode runtime 的环境补宿主检查。
78
+ - 核对缓存内四个 bundle、bin、manifest、版本及构建产物校验信息。安装后即使原始临时解包目录移走,也应可连接 MCP;否则明确标为依赖源目录的安装方式并修正交付路径。
79
+ - 增加缺 dist、部分损坏、旧缓存负例。新增校验 manifest 如需构建信息,由构建生成并随包交付,不手工维护。
80
+
81
+ 验收:完整发布包经过新缓存安装后暴露 7 个工具;缺损安装被明确识别;相同版本重装不会继续使用损坏缓存;测试不依赖仓库 `node_modules` 或全局包软链接。
82
+
83
+ ### B. 安装诊断与可见错误
84
+
85
+ - 包装脚本检测 Node/dist 缺失时,保留 stderr,同时尽力写入 `CMDR_HOME/logs` 的本地诊断记录。限制频率、大小和文件权限,不写消息正文、hook 输入、凭据或完整环境;目录不可写时仍失败放行。
86
+ - 提供不依赖缺失 cli bundle 的基础诊断。完整 CLI 增加目标目录检查,例如拟议的 `doctor --plugin-root PATH`,避免只验证全局 npm 安装而漏掉真正失败的宿主缓存。
87
+ - doctor 输出结构化状态:运行时完整性、实际路径/版本、静态 hook 配置、最近一次观察到的 hook 事件。未触发过显示 unknown,不直接判定失效,也不把配置存在等同实际运行。
88
+ - 显式深度检查执行 MCP initialize/listTools,使用临时 `CMDR_HOME`、超时和清理;基础诊断不启动用户默认 daemon。致命安装错误返回非零码。
89
+ - 错误指引按源码安装、npm 安装和宿主缓存分别给出动作。`PROTOCOL_MISMATCH` 区分缺少 hello 与协议版本冲突,输出双方协议/版本和修复路径。
90
+
91
+ 验收:缺 Node、缺 cli/mcp/hook、握手超时、日志不可写都有确定结果;hook 故障仍在既有时限内退出 0;日志去重且不泄露业务数据;修复建议能定位到真正的插件缓存。
92
+
93
+ ### C. 技能和用户路径
94
+
95
+ - `using-cmdr` 和 `/cmdr` 命令在工具缺失时进入排障指引,不继续要求不存在的 join,不指导模型逆向 socket 或伪造身份。
96
+ - 中英文 README、插件 README、接入文档同步“完整 npm 安装 → 注册 marketplace → 刷新缓存 → 新会话验证”的流程,删除首次发布前的临时措辞。
97
+ - 写清 hooks 缺失时可用的 MCP 长轮询路径,以及 MCP 本身不可用时先修复安装的限制。
98
+
99
+ 验收:ZCode 新用户可仅凭发布文档完成安装;工具缺失时得到具体诊断命令和目标目录,能够区分插件注册、MCP 连接和协作可用三个状态。
100
+
101
+ ## 工作包二:成员 CLI 与身份闭环(P1)
102
+
103
+ 在本轮先明确 CLI 与身份设计,再按交付和诊断工作的依赖推进实现。优先采用独立成员命令空间(如拟议的 `cmdr session ...`),避免改变现有运维 `send/read` 的含义。
104
+
105
+ - 支持 join/list/send/report/ask/read/leave 完整成员操作;通过 `--agent` 与显式 native ID 或已有 `CMDR_SESSION_ID` 声明身份,复用现有 schema、角色检查及关联回复。
106
+ - 第一阶段复用现有 `kind=mcp` 成员连接语义:命令期间在线,命令结束离线,成员关系及队列保留。文档解释这是 Agent 会话的另一种本地客户端,不代表自动唤醒;不放宽运维 CLI 权限来模拟成员。
107
+ - 支持机器可读 JSON、超时和信号取消;等待中的 read 取消后不消费随后到达的消息。ask 重试不得造成隐式重复发送或错误回复路由。
108
+ - 单会话独立进程可显式传稳定 ID;共享 MCP 进程继续逐调用 stamp。不能用一个全局环境变量或按 cwd 生成的文件 ID 合并多场会话。
109
+ - hook 当前使用事件里的 `session_id`,不是自动读取 `CMDR_SESSION_ID`。明确两者来源和一致性校验;不把“同时设置环境变量”当成已经修复。
110
+ - 保留 `_cmdr_session`,补实际 ZCode PreToolUse 到桥接再到 daemon 的契约验证,以及独立进程、共享进程、重连、重绑定、hook 缺失测试。
111
+
112
+ 验收:没有 MCP 工具的会话能借助受支持 CLI 完成入队、收任务、汇报、提问、回答、离队;同一身份 MCP 与 CLI 交替使用保持队列和回复路由;不同会话不串消息;短连接不留下虚假在线成员。
113
+
114
+ 该路线不必然需要修改 wire protocol。实现前检查现有 Context/注册约束是否足够;如需增加 connection kind 或改变在线语义,再单独评审协议兼容性,避免预先扩大协议。
115
+
116
+ ## 工作包三:诊断体验与运行状态(P2)
117
+
118
+ - 等待建议按实际宿主超时及安全余量统一计算,保留现有 ZCode 600→300 和未知宿主保守值;覆盖短超时、无效值及上限,CLI 可显示推荐来源。无需为 ZCode 重做已有特判。
119
+ - daemon 升级记录旧/新版本、触发原因和重连状态。优先使用有界诊断事件,不向任务队列塞入要求行动的消息,也不触发 Stop 提醒风暴。重启前通知只能尽力送达,不能承诺所有在线客户端收到。
120
+ - doctor/list 增加 provisional 数量、年龄和绑定状态。只有发现增长异常后,再评估更精细回收;已有 TTL 和绑定删除语义保持。
121
+ - 保存包大小基线,构建报告给出占比及异常增长提示;任何体积优化以启动与安装测量为依据,不牺牲独立安装和诊断能力。
122
+
123
+ 验收:多客户端升级后自动恢复且队列保留;升级诊断可追溯但不污染业务消息;身份绑定后旧 provisional 消失;等待推荐不超出已知宿主预算。
124
+
125
+ ## 暂不采纳
126
+
127
+ - 安装时联网执行后置构建:会把 npm、依赖网络和构建工具引入最终用户环境,优先发布完整产物。
128
+ - 将 dist 提交到源码 Git:与现有分发约束冲突,且 npm 包已解决产物携带问题。
129
+ - 原始 `cmdr rpc` 作为常规降级接口:容易固化内部协议并绕开清晰的成员/运维界面;补文档用于诊断即可。
130
+ - TTL 心跳或 `cmdr hold`:不能使模型自动响应,反而可能制造“在线但无人读”的假象。若未来确有独立消费者需求,再将 presence lease 与活动状态分开设计。
131
+ - 主动唤醒、创建 Agent、远程传输:超出当前版本范围,不作为本次故障修复手段。
132
+ - 因身份失败直接删除 `_cmdr_session` 或统一静态 sid:会破坏已实现的共享进程会话隔离。
133
+
134
+ ## 执行顺序与完成门槛
135
+
136
+ 本轮统一交付 `0.1.1`,按以下顺序推进,可拆分审阅提交,但不拆分发布:
137
+
138
+ 1. 明确成员 CLI、身份及诊断输出契约,确认现有协议的复用边界。
139
+ 2. 完成交付验证和安装诊断(P0 的 A、B)。
140
+ 3. 完成成员 CLI、身份闭环(P1),以及等待推荐、升级诊断、provisional 展示和体积基线(P2)。
141
+ 4. 按最终功能统一更新技能、命令和中英文文档(P0 的 C),补齐 CLI 降级指引。
142
+ 5. 将 `package.json`、lockfile 和宿主 manifests 的版本统一为 `0.1.1`,完成完整验证及发布包验收。
143
+
144
+ 三个工作包的实现和验收共同构成 0.1.1 的完成门槛,不在仅完成 P0 后提前交付。保留已有 7 个 MCP 工具及运维 CLI 兼容性;新成员命令采用独立命令空间。若实现中发现必须改变协议或破坏兼容性,先重新评估方案,不把兼容性变更隐含在版本合并中。
145
+
146
+ 每次代码或构建改动交付前运行 `npm run check`;涉及 ZCode 安装时再对本次实际 tarball 执行隔离 runtime 验证。另做一次 GUI 新会话操作,观察真实 PreToolUse stamp、入队和消息往返,明确记录宿主版本与信任设置。未完成的 GUI 检查必须单独标注,不能用 7 个工具连接成功替代。
147
+
148
+ ## 0.1.1 实施记录
149
+
150
+ 已实现三项工作包:发布产物完整性清单、独立基础检查器和缓存目录诊断;隔离 MCP 深度探测及限频元数据快照;完整 `cmdr session` 成员操作、身份冲突校验、取消与超时;显式等待预算、升级与重连快照、provisional 展示和包大小基线。npm 命令统一使用支持全局软链接的包装脚本。协议仍为 1,公开 MCP 工具仍为 7。
151
+
152
+ ZCode 验证改为从实际 tarball 安装、检查缓存完整性、移走安装源后连接工具;成员 CLI 与真实 hook 程序生成的 stamp 已通过自动化往返测试。GUI 信任提示、真实 ZCode 会话 hook 执行和模型协作尚未单独验证,必须在发布记录中保留此限制。自动化使用隔离数据目录,不修改正常插件缓存;本轮提交 PR,不自动发布 npm。