cmdr-mcp 0.2.0 → 0.4.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/README.md +21 -5
- package/docs/README.zh-CN.md +19 -3
- package/docs/agent-integration.md +8 -2
- package/docs/cmdr-design-v1.md +2 -0
- package/docs/implementation.md +39 -3
- package/docs/long-running-collaboration.md +53 -14
- package/docs/publishing.md +8 -8
- package/docs/setup.md +45 -0
- package/docs/troubleshooting.md +6 -0
- package/docs/zcode-desktop-session-visibility.md +172 -0
- package/marketplace.json +1 -1
- package/package.json +3 -2
- package/plugins/cmdr/.claude-plugin/plugin.json +1 -1
- package/plugins/cmdr/.codex-plugin/plugin.json +1 -1
- package/plugins/cmdr/.zcode-plugin/plugin.json +1 -1
- package/plugins/cmdr/README.md +3 -1
- package/plugins/cmdr/THIRD_PARTY_NOTICES.txt +29 -0
- package/plugins/cmdr/commands/cmdr.md +2 -2
- package/plugins/cmdr/dist/cli.mjs +1425 -56
- package/plugins/cmdr/dist/daemon.mjs +396 -86
- package/plugins/cmdr/dist/hook.mjs +1 -1
- package/plugins/cmdr/dist/integrity.json +17 -13
- package/plugins/cmdr/dist/mcp.mjs +3 -3
- package/plugins/cmdr/skills/cmdr/SKILL.md +20 -0
- package/plugins/cmdr/skills/cmdr/references/commander.md +12 -0
- package/plugins/cmdr/skills/cmdr/references/executor.md +11 -0
- package/plugins/cmdr/skills/cmdr/references/setup.md +15 -0
- package/plugins/cmdr/skills/cmdr-commander/SKILL.md +1 -1
- package/plugins/cmdr/skills/cmdr-executor/SKILL.md +2 -2
- package/plugins/cmdr/skills/using-cmdr/SKILL.md +3 -3
package/README.md
CHANGED
|
@@ -8,7 +8,23 @@
|
|
|
8
8
|
|
|
9
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
|
-
|
|
11
|
+
**One-command setup (0.4.0):** replace `claude-code` with `codex` or `zcode` for your host.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx -y --package=cmdr-mcp@latest cmdr setup --agent claude-code
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Setup installs the runtime, skill, MCP and hooks while preserving existing settings. Repeat to upgrade; add `--dry-run` to preview. Open a new session and complete any host trust prompts. For a built checkout, use `plugins/cmdr/bin/cmdr setup --agent …`.
|
|
18
|
+
|
|
19
|
+
For skill files only:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npx skills add njugray/cmdr --skill cmdr
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The skill requires a working cmdr runtime and MCP connection. Use setup or the native plugin below for those components. See [installation details](docs/setup.md).
|
|
26
|
+
|
|
27
|
+
The npm package is **`cmdr-mcp`**; the CLI and host plugin remain **`cmdr`**. For a global CLI and native plugin installation:
|
|
12
28
|
|
|
13
29
|
```sh
|
|
14
30
|
npm install --global cmdr-mcp
|
|
@@ -26,7 +42,7 @@ For distribution, `npm pack` (or `npm publish`) runs `prepack` to build the four
|
|
|
26
42
|
|
|
27
43
|
```sh
|
|
28
44
|
npm pack
|
|
29
|
-
npm install --global ./cmdr-mcp-0.
|
|
45
|
+
npm install --global ./cmdr-mcp-0.4.0.tgz
|
|
30
46
|
cmdr --help
|
|
31
47
|
```
|
|
32
48
|
|
|
@@ -78,10 +94,10 @@ Joining by name atomically creates or finds a persistent channel and defaults to
|
|
|
78
94
|
2. The commander inspects `list`, then `send`s clear tasks with acceptance criteria.
|
|
79
95
|
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`.
|
|
80
96
|
4. Executors use `ask` when blocked; the commander responds with `send(type="answer", reply_to=<ask id>)`.
|
|
81
|
-
5. Use `join(..., standby="auto")
|
|
97
|
+
5. Use `join(..., standby="auto")`. Claude/ZCode then arm `listener.arm.command` with its indicated native tool. 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.
|
|
82
98
|
6. `leave` preserves queued messages. Commander departure orphans the squad; `leave(dissolve=true)` disbands it.
|
|
83
99
|
|
|
84
|
-
|
|
100
|
+
Codex wakes through app-server proxy or the `codex queue` fallback. Claude uses Monitor and ZCode uses background Bash completion through the built-in `cmdr standby watch`; re-arm after task termination. See [Long-running collaboration](docs/long-running-collaboration.md) for capabilities, recovery, handover and compatibility requirements.
|
|
85
101
|
|
|
86
102
|
## Tools
|
|
87
103
|
|
|
@@ -160,6 +176,6 @@ npm run verify:zcode # optional: requires the locally installed ZCode desktop
|
|
|
160
176
|
|
|
161
177
|
For development, `claude --plugin-dir ./plugins/cmdr` loads the plugin directly. Installed hosts use cached copies: reinstall/refresh after changing a plugin. Version numbers come from `package.json`; after same-version changes, restart the daemon explicitly. Generated bundles and third-party license notices are ignored by Git and included in the npm package.
|
|
162
178
|
|
|
163
|
-
v1 is single-machine, single-user, Unix-socket-only. There is no network listener, remote transport
|
|
179
|
+
v1 is single-machine, single-user, Unix-socket-only. There is no network listener, remote transport or executor-to-executor messaging. Agent session creation is outside the current scope. Host GUI interaction and live model behavior are distinct from the automated runtime checks; see the [verification record](docs/implementation.md).
|
|
164
180
|
|
|
165
181
|
[MIT](LICENSE)
|
package/docs/README.zh-CN.md
CHANGED
|
@@ -8,7 +8,23 @@
|
|
|
8
8
|
|
|
9
9
|
支持 macOS / Linux,需要 Node.js ≥22.5(推荐 24)。开发分支保存源码和插件元数据;npm 发布包及自动生成的 `marketplace` 分支包含完整运行时。
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
**一条命令完整安装(0.4.0)**,将 `claude-code` 换成实际使用的 `codex` 或 `zcode`:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx -y --package=cmdr-mcp@latest cmdr setup --agent claude-code
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
安装器会安装运行时、技能、MCP 和 hooks,并保留已有配置。重复执行可升级,增加 `--dry-run` 可预览。完成后新开会话并处理宿主信任提示。构建后的源码可直接运行 `plugins/cmdr/bin/cmdr setup --agent …`。
|
|
18
|
+
|
|
19
|
+
只安装技能文件时使用:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npx skills add njugray/cmdr --skill cmdr
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
技能需要可用的 cmdr 运行时和 MCP 连接,可通过 setup 或下面的原生插件方式安装。配置位置、升级和恢复见[安装说明](setup.md)。
|
|
26
|
+
|
|
27
|
+
npm 包名为 **`cmdr-mcp`**,CLI 和宿主插件仍叫 **`cmdr`**。需要全局 CLI 或原生插件时也可安装:
|
|
12
28
|
|
|
13
29
|
```sh
|
|
14
30
|
npm install --global cmdr-mcp
|
|
@@ -26,7 +42,7 @@ npm run build
|
|
|
26
42
|
|
|
27
43
|
```sh
|
|
28
44
|
npm pack
|
|
29
|
-
npm install --global ./cmdr-mcp-0.
|
|
45
|
+
npm install --global ./cmdr-mcp-0.4.0.tgz
|
|
30
46
|
cmdr --help
|
|
31
47
|
```
|
|
32
48
|
|
|
@@ -72,7 +88,7 @@ ZCode 桌面端:打开工作区,在 **设置 → 插件 → 创建 → 添
|
|
|
72
88
|
|
|
73
89
|
执行方加入后 `report(ready)` 报到,说明目录、能力和当前上下文。指挥官通过 `list` 看成员,用 `send` 下发可验证任务。执行方 `read` 读取任务后立即用 `report(working, reply_to=<command id>)` 接单,再带相同 `reply_to` 汇报 done/failed/cancelled,遇到阻塞用 `ask` 提问;指挥官通过 `send(type="answer", reply_to=<ask id>)` 回答。
|
|
74
90
|
|
|
75
|
-
加入时设置 `standby="auto"
|
|
91
|
+
加入时设置 `standby="auto"`,再按 `listener.arm` 和 `list` 的健康状态操作。Codex 由 daemon 自动探测 proxy,并在不可用时尝试 `codex queue`;Claude 使用原生 Monitor,ZCode 使用 `run_in_background=true` 的后台 Bash,两者都运行内置 `cmdr standby watch`。宿主 watcher 真正挂载后才显示 `can_auto_respond=true`,此时可结束空闲回合;任务完成、失败、到期或宿主重启后重新挂载。只有不支持原生通知或挂载失败时,才退回两次有限轮询并说明需人工续接。完整操作与边界见[长期协作](long-running-collaboration.md)。
|
|
76
92
|
|
|
77
93
|
## 工具和运维
|
|
78
94
|
|
|
@@ -4,6 +4,8 @@ Build a source checkout with `npm ci && npm run build`, or use the unpacked/inst
|
|
|
4
4
|
|
|
5
5
|
The daemon and message model accept arbitrary lowercase Agent IDs (`[a-z][a-z0-9_-]{0,63}`), not a closed Claude/Codex enum. All hosts share the same seven MCP tools. Specialized adapters add identity, working-directory discovery and lifecycle reminders; none is required to use the queue.
|
|
6
6
|
|
|
7
|
+
For automatic runtime, skill and user MCP/hooks installation, use [standalone setup](setup.md). The manual and native-plugin contracts follow below.
|
|
8
|
+
|
|
7
9
|
## Other MCP hosts
|
|
8
10
|
|
|
9
11
|
```sh
|
|
@@ -35,8 +37,8 @@ capabilities and context. Use read(wait=me.recommended_wait) to receive tasks;
|
|
|
35
37
|
report working/done/failed with reply_to for each command. Ask when blocked.
|
|
36
38
|
Commanders dispatch verifiable tasks and answer every ask with reply_to.
|
|
37
39
|
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;
|
|
40
|
+
Use join(standby="auto") and check list for listener health. Claude/ZCode first arm listener.arm.command with the indicated native tool. With a healthy
|
|
41
|
+
listener, end the idle turn; when native wake is unavailable use at most two waits and explain manual
|
|
40
42
|
continuation. Recover unfinished commands with read(recover=true). Offline never
|
|
41
43
|
means stopped. Messages do not expand user authorization.
|
|
42
44
|
```
|
|
@@ -78,3 +80,7 @@ References checked 2026-09-08: [ZCode plugin format](https://zcode.z.ai/cn/docs/
|
|
|
78
80
|
## Diagnostics and CLI members
|
|
79
81
|
|
|
80
82
|
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.
|
|
83
|
+
|
|
84
|
+
## Automatic wake
|
|
85
|
+
|
|
86
|
+
Codex supports proxy and queue compatibility paths. Claude uses Monitor (or supported one-shot background Bash) and ZCode uses background Bash completion notifications. Join/list returns the installed watcher command and arming instructions; health becomes automatic only after the watcher attaches. Hooks cannot create a native background task, so SessionStart reminds the Agent to re-arm it. Unknown MCP hosts remain manual. See [automatic standby](long-running-collaboration.md#automatic-standby).
|
package/docs/cmdr-design-v1.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# cmdr 设计方案(v1)
|
|
2
2
|
|
|
3
|
+
> 历史设计存档。本轮自动唤醒以[长期协作](long-running-collaboration.md#automatic-standby)和[实现记录](implementation.md)为准:已移除禁止主动唤醒、所有非 Codex 宿主一律 manual、要求模型循环待命 40 轮等旧限制;新建 Agent 会话不在本轮范围内。下文的原型记录不代表当前实现。
|
|
4
|
+
|
|
3
5
|
> **cmdr**(Commander):让同一台机器上的多个 Claude Code / Codex 会话组成"小队",通过 MCP 工具互相通信。指挥官下发命令、回答询问,执行方报到、汇报、询问;服务端为每个会话维护一个带优先级的消息队列,并通过 hooks 在合适的时机提醒 Agent 读取。
|
|
4
6
|
>
|
|
5
7
|
> **当前实现状态(2026-09-08)**:本仓库已从仅含文档的分支实现 v1 源码、插件与测试,并按新增需求支持 ZCode 桌面端和任意 MCP Agent 接入。本文保留既有设计及原型试用记录;其中历史 v0.1.x 的完成日期、版本号与实测结论不是本次代码的验证凭据。本次具体交付、差异、38 个自动化用例和 ZCode 本机运行时验证见 [实现与验证记录](implementation.md),新增宿主契约见 [Agent 接入指南](agent-integration.md)。
|
package/docs/implementation.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Implementation and verification
|
|
2
2
|
|
|
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.
|
|
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.4.0**, internal protocol **1**.
|
|
4
4
|
|
|
5
5
|
## Delivered behavior
|
|
6
6
|
|
|
@@ -71,19 +71,55 @@ On 2026-09-14, the 0.1.1 iteration additionally passed release-tarball installat
|
|
|
71
71
|
|
|
72
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.
|
|
73
73
|
|
|
74
|
-
Windows, remote machines and creation of new Agent sessions are outside this Unix-socket scope.
|
|
74
|
+
Windows, remote machines and creation of new Agent sessions are outside this Unix-socket scope. Codex uses proxy/queue and Claude/ZCode use native notification watchers. 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
75
|
|
|
76
76
|
|
|
77
77
|
## 0.2.0 issue #5 coverage
|
|
78
78
|
|
|
79
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
80
|
|
|
81
|
-
The Codex adapter uses the installed CLI's generated public request/response types for the experimental queue contract.
|
|
81
|
+
The Codex adapter uses the installed CLI's generated public request/response types for the experimental queue contract. That 0.2.0 proxy-only implementation did not parse private host state; the queue compatibility path below intentionally replaces that restriction. 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
82
|
|
|
83
83
|
|
|
84
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
85
|
|
|
86
|
+
## Standalone setup
|
|
87
|
+
|
|
88
|
+
`cmdr setup` copies a verified runtime to a persistent build directory and installs profile-specific launchers, the `cmdr` skill and user MCP/hooks. Configuration edits preserve unrelated values and support backup/rollback. See [setup](setup.md) for usage and recovery.
|
|
89
|
+
|
|
90
|
+
The standalone skill owns the role references; the build synchronizes the existing role skill entries from them. Setup tests cover all three hosts, upgrades, configuration preservation, failure recovery and profile isolation. Package verification runs the real npx entry point offline and checks it after removing the npx cache. Host GUI trust and live-model collaboration require separate verification.
|
|
91
|
+
|
|
86
92
|
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
93
|
|
|
88
94
|
|
|
89
95
|
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.
|
|
96
|
+
|
|
97
|
+
## 0.3.0 automatic wake iteration — issues #7, #8 and #9
|
|
98
|
+
|
|
99
|
+
This iteration is isolated on `feat/host-auto-wake`, based directly on `main` (`5368e52`). Standalone setup/skills installation remains on its separate branch. The reported host mechanisms are implemented as follows:
|
|
100
|
+
|
|
101
|
+
- [#7 Codex queue feedback](https://github.com/njugray/cmdr/issues/7): the previous proxy-only assumption is removed. Auto mode checks the existing proxy, then queue capability. Its read-only state_5/rollout compatibility reader is explicitly version-coupled, scans complete records incrementally and prevents idle inference from partial writes. Delivery stays with the installed queue CLI. Pending requests pin their transport; actual user-message markers reconcile lost responses after restart. Node >=22.12 is required for the fallback's read-only SQLite option; earlier supported Node versions can still use proxy.
|
|
102
|
+
- [#8 Claude Monitor feedback](https://github.com/njugray/cmdr/issues/8): native Monitor runs the built-in watcher. Actionable filtering is shared with adapters and tail. Follow defaults to now; explicit replay cursors remain available. Role-inbox events, direct info and current unfinished work are included; ready/working reports and quiet broadcast info are excluded.
|
|
103
|
+
- [#9 ZCode background completion feedback](https://github.com/njugray/cmdr/issues/9): native background Bash runs the same watcher in one-shot mode. It remains silent until actionable work, then exits and relies on the host's completion notification. Unlike the supplied consuming-read PoC, the shipped watcher observes metadata; the awakened Agent performs read/acceptance. It has a daemon lease, duplicate protection, startup snapshot, expiry and disconnect handling. Join/list/skills and SessionStart now tell the model to arm/re-arm; the previous blanket manual classification and ban on host-side listening are removed.
|
|
104
|
+
|
|
105
|
+
The [follow-up correction to #8](https://github.com/njugray/cmdr/issues/8#issuecomment-5712342765) identifies report filtering on omitted `data.status` as the cause of missed notifications in the original recipe, rather than a stalled subscription. The shared wake policy now uses the daemon-computed `attn` flag for reports. Default live events and replay both carry `data=null`; `--full` retains the original data. Regression coverage checks all six report statuses with and without data, matching live/replay output, and consecutive actionable reports on the same subscription. No periodic reconnect workaround is added.
|
|
106
|
+
|
|
107
|
+
The [PR #10 review](https://github.com/njugray/cmdr/pull/10#discussion_r4035173370) also identified repeated one-shot wakes when a blocked executor re-arms with an already accepted command. Attach now records accepted commands without pending cancellation as already seen. They remain owned and recoverable; unread messages, unaccepted work and pending cancellation still notify. Process regressions cover ZCode and Claude's one-shot fallback through blocked → re-arm → daemon restart → answer → cancellation, including unread answers at attach and cancellation whose message has already been read.
|
|
108
|
+
|
|
109
|
+
New ZCode session creation is deferred by user decision. The app-server prototype, `cmdr zcode create` / `admin.zcode.create` entry points, owned runtime state and dedicated tests have been removed. No CDP desktop adapter is included. Automatic wake for existing Codex, Claude and ZCode sessions remains. Seven public MCP tools, ownership/report semantics, cancellation and generic host IDs remain intact.
|
|
110
|
+
|
|
111
|
+
**Source-research correction (2026-09-17):** `ZCODE_STORAGE_DIR` does not isolate the session database; the removed prototype and the earlier verification script did not explicitly set `ZCODE_SESSION_DB_PATH`. Earlier descriptions of fully isolated owned storage were too broad. The retained plugin/MCP verification script now explicitly sets a temporary session database and checks that the runtime opened it. A persisted session can be discovered through shared storage when a fresh desktop workspace runtime seeds the task index, but visibility is not ownership transfer. Empty create/read/close does not prove persistence or cross-process recovery. See [ZCode desktop session visibility research](zcode-desktop-session-visibility.md) for source evidence, no-model experiments and the decision to defer creation.
|
|
112
|
+
|
|
113
|
+
**Desktop entry probe (2026-09-17):** an unmodified ZCode 3.11.2 release launched with an explicit loopback CDP endpoint and disposable desktop/runtime databases accepted external Node calls through its Renderer service proxy to the desktop Host's `createTask`. Two real IDs were returned; `listTasks` and `task_created` events reflected the creations, and the visible sidebar grew from one entry to two without a reload. Workspace runtime PID/generation remained unchanged. This is a verified, opt-in, version-coupled route, not a default public task API or an implemented cmdr desktop adapter. No model turn or cloud remote-control pairing was exercised.
|
|
114
|
+
|
|
115
|
+
Verification of the independent branch on 2026-09-17 (macOS, Node 24.16.0):
|
|
116
|
+
|
|
117
|
+
- `npm run check`: **106 tests passed across 12 files**, plus formatting, strict typing, build and offline package/seven-tool discovery. The standalone installation tests belong to the separate setup branch and are not included here.
|
|
118
|
+
- New tests cover proxy→queue selection, conservative busy/partial-record checks, stable request reconciliation, no duplicate submission across daemon restart, host watcher silence/duplicates/re-arming, non-consuming output, role-inbox filtering, manual registration upgrade and broadcast/direct info. The cold-start queue test waits for adapter readiness instead of relying on the test runner's default one-second polling deadline.
|
|
119
|
+
- `npm run verify:zcode`: the installed desktop runtime validated the plugin and cache, discovered 1 command / 3 skills / 4 hooks / 1 MCP server and connected seven tools after source removal. The runtime opened the explicitly configured temporary session database. The script does not create sessions or send model requests.
|
|
120
|
+
- The rebuilt CLI exposes the watcher, omits both standalone setup and new-session creation, and rejects `zcode create` without starting a daemon.
|
|
121
|
+
- Local Codex CLI 0.153.4 exposes queue --thread/--message. The issue's historical end-to-end queue success is retained as field evidence; this iteration did not re-submit into a user's real desktop thread. Claude Monitor and ZCode background-task re-invocation likewise have the issue authors' live PoC evidence; automated watcher tests do not claim a new live-model GUI verification.
|
|
122
|
+
|
|
123
|
+
Outstanding host acceptance is the real idle→notification→read→working→done loop in refreshed Codex, Claude and ZCode sessions, including a busy-turn backlog and watcher re-arm after native task expiry. Use a disposable channel/workspace and inspect tail/list for acceptance; tool/CLI availability alone is not the success criterion. No normal ~/.cmdr state, installed plugin cache or host trust settings were changed during verification.
|
|
124
|
+
|
|
125
|
+
Release preparation for 0.3.0 synchronizes npm and host manifests and injects the package version into Vitest, matching the production build so process tests validate the released version rather than the minimum compatible client version. The release is prepared from merged PR #10 in a clean worktree.
|
|
@@ -53,33 +53,70 @@ On startup or after a wake, use ordinary `read` and `read(recover=true)`. Recove
|
|
|
53
53
|
|
|
54
54
|
`read` omits squad_summary by default; `list` omits repeated member boards and detailed session fields. Listings never include command bodies, including with full=true. Use read(id=...) for your own messages, or operator tail --full for observation. Use `full=true` / `--full` for expanded metadata and `limit` / `--limit` to bound reads. Do not pipe a consuming read into head: output lost after delivery is recoverable through history/ID lookup, but is no longer unread.
|
|
55
55
|
|
|
56
|
-
##
|
|
56
|
+
## Automatic standby
|
|
57
|
+
|
|
58
|
+
`join(standby="auto")` requires a confirmed native identity and channel membership. Inspect `list` afterwards. A successful join registers intent; `can_auto_respond=true` requires a healthy delivery adapter or a live host watcher. Unknown hosts remain manual.
|
|
59
|
+
|
|
60
|
+
| Host | Wake mechanism | What the Agent must do |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| Codex | Daemon attaches through app-server proxy; falls back to `codex queue` when proxy is unavailable | Join with auto, check health, end the idle turn |
|
|
63
|
+
| Claude Code | Native Monitor emits a notification for each watcher output line | Run `listener.arm.command` with Monitor; re-arm on expiry/exit |
|
|
64
|
+
| ZCode desktop | Native background Bash re-invokes its session when the watcher exits | Run `listener.arm.command` with `run_in_background=true`; re-arm after each notification |
|
|
65
|
+
|
|
66
|
+
All paths share the same actionable policy: command, cancel, ask, answer, system, terminal/blocked reports, attention-marked info and direct info. working/ready reports and broadcast info without attention are quiet. Commands gated by reassignment remain blocked. Observation does not consume messages or accept tasks. Every wake must be followed by `read` and `read(recover=true)`, cancellation handling, and correlated working/terminal reports.
|
|
67
|
+
|
|
68
|
+
Report attention comes from the daemon's `attn` flag, computed at enqueue time. Default live and replayed events both omit `message.data`; do not filter those events by `data.status`. Use the built-in `--actionable` filter. `--full` includes the original data when needed. A quiet long-lived subscription does not itself indicate a stalled connection; periodic reconnects are unnecessary.
|
|
57
69
|
|
|
58
70
|
```sh
|
|
59
|
-
cmdr standby start --session
|
|
60
|
-
cmdr standby status --session
|
|
61
|
-
cmdr standby stop --session
|
|
62
|
-
cmdr standby resume --session
|
|
63
|
-
# Optional explicit local host transport:
|
|
64
|
-
cmdr standby start --session codex:REAL_THREAD_ID --adapter codex --executable /absolute/path/to/codex --socket /absolute/path/to/control.sock
|
|
71
|
+
cmdr standby start --session SID
|
|
72
|
+
cmdr standby status --session SID
|
|
73
|
+
cmdr standby stop --session SID
|
|
74
|
+
cmdr standby resume --session SID
|
|
65
75
|
```
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
### Codex: proxy and queue
|
|
68
78
|
|
|
69
|
-
The
|
|
79
|
+
The proxy path connects `codex app-server proxy` to the already running host. It uses thread/read, thread/resume, thread/queue/list, thread/queue/add, thread/queue/start and thread/turns/list. A host that exposes these methods and the control socket can accept a stable client message ID and start that exact queued item. An unloaded thread is resumed in that same host. See the [official app-server reference](https://learn.chatgpt.com/docs/app-server) for the transport and state APIs; experimental queue shapes are checked against the installed CLI, not inferred from this reference.
|
|
70
80
|
|
|
71
|
-
|
|
81
|
+
A missing socket now triggers a capability check for `codex queue --thread ID --message TEXT`. The queue path submits a metadata-only wake to the existing thread, without model, sandbox, approval or remote overrides. It does not explicitly launch a second app-server or call exec/resume to create a competing session. The CLI's internal transport remains host-owned.
|
|
72
82
|
|
|
73
|
-
|
|
83
|
+
The compatibility state reader requires Node >=22.12 (Node 24 recommended), because earlier node:sqlite versions lack the readOnly option. It opens `$CODEX_HOME/state_5.sqlite` read-only, resolves the exact thread's rollout_path and incrementally reads complete JSONL records. task_started means busy; task_complete/turn_aborted means idle. It scans the whole existing log once rather than a fixed tail window. Missing records, incompatible schema and unknown state prevent submission and produce concrete errors. This is a version-coupled fallback, not a stable public state API. The check-to-submit race is not atomic; the queue CLI must arbitrate a concurrent user turn.
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
# Automatic selection (default)
|
|
87
|
+
cmdr standby start --session codex:REAL_ID --transport auto
|
|
88
|
+
# Force a known path when diagnosing host capabilities
|
|
89
|
+
cmdr standby start --session codex:REAL_ID --transport queue --executable /absolute/path/to/codex
|
|
90
|
+
cmdr standby start --session codex:REAL_ID --transport proxy --socket /absolute/path/to/control.sock
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Wake requests are persisted before delivery: requested → accepted → observed. An unresolved request pins its transport across restarts. Proxy reconciliation searches queue/history by client ID; queue reconciliation recognizes the stable `[cmdr wake UUID]` prefix only in user messages in the rollout. Queue exit 0 confirms submission but provides no queued item ID. Timeout/nonzero exit is uncertain, since delivery may already have happened. No cross-transport or automatic blind replay occurs. Accepted wakes with no progress become stalled. After inspecting the host and actual work:
|
|
74
94
|
|
|
75
95
|
```sh
|
|
76
96
|
cmdr standby resume --session SID --resolve accepted
|
|
77
97
|
cmdr standby resume --session SID --resolve retry
|
|
78
98
|
```
|
|
79
99
|
|
|
80
|
-
`retry` explicitly permits a
|
|
100
|
+
`retry` explicitly permits a new submission; it does not establish that the earlier one failed. Busy sessions coalesce backlog. Host acceptance remains separate from the command owner's working report.
|
|
101
|
+
|
|
102
|
+
### Claude and ZCode: native host watchers
|
|
103
|
+
|
|
104
|
+
Join/list returns `listener.arm` with an absolute installed command, the native host tool and re-arm instructions. The standard command is:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
cmdr standby watch --session claude:REAL_ID
|
|
108
|
+
cmdr standby watch --session zcode:REAL_ID
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Claude uses its **Monitor tool**, not foreground Bash or shell `&`. Each stdout line becomes a native notification, queued into an active turn or opening an idle turn. The reporter's Monitor has a 30-minute lifetime; re-arm when the host reports expiry/exit. If Monitor is absent but the host supports background Bash completion notifications, use `--once` with `run_in_background=true`. If neither mechanism exists, explicitly select manual.
|
|
81
112
|
|
|
82
|
-
|
|
113
|
+
ZCode uses **Bash with run_in_background=true**. Its native task survives the current turn and automatically re-invokes the session on completed/failed/killed. The built-in watcher remains silent during idle periods and exits after printing actionable metadata. It never consumes inbox messages, so a lost output notification still leaves the work available for recovery. On notification: inspect task output, read/recover, handle work, and re-arm. An immediate backlog produces an immediate notification; drain/reconcile it before re-arming.
|
|
114
|
+
|
|
115
|
+
The command subscribes before inspecting current work, covering startup races, unread messages and read-but-unaccepted commands. At attach, accepted commands without pending cancellation are treated as already known: a blocked executor can re-arm and wait for an answer without repeatedly waking on its own unfinished task. Ownership and `read(recover=true)` remain unchanged; reconcile accepted work on startup or after context loss before arming. Unread answers, new commands and pending cancellation still notify, including cancellation requested after attach.
|
|
116
|
+
|
|
117
|
+
It renews a 90-second daemon lease every 30 seconds. Exactly one lease owns a member; duplicate watchers are rejected. Only an attached live watcher is healthy. Disconnect removes its lease; a lost heartbeat expires it. A daemon restart closes the command so the host can notify and re-arm. App termination removes the native task; SessionStart reminds the Agent to inspect and re-arm it. A healthy lease establishes that the watcher is running, not that an individual model turn has already started.
|
|
118
|
+
|
|
119
|
+
Check the host task status before re-arming. Stop disables the lease; its process exits at the next event/heartbeat, which itself may produce one last native notification. Skills do not impose the old two-wait limit when a native watcher is available. Bounded manual polling remains only for unsupported tools or failed arming. No repeating cron/model heartbeat is needed, and no PermissionRequest auto-approval is installed.
|
|
83
120
|
|
|
84
121
|
## Lifecycle observation
|
|
85
122
|
|
|
@@ -90,10 +127,12 @@ cmdr tail --for MEMBER_SID --after 123 --follow --json --full
|
|
|
90
127
|
|
|
91
128
|
Events have monotonically increasing `event_seq`, timestamp, channel, kind, sender/recipient, message ID, reply_to and applicable reason/data. The stream covers enqueue/read, command acceptance/progress/terminal state, cancellation/reassignment, membership/role changes, connection/hooks and wake requests/acceptance/errors. `--full` includes complete message bodies/data; default text summarizes bodies. `--json` is one JSON event per line. The cursor is an **event sequence**, not a message seq.
|
|
92
129
|
|
|
130
|
+
Without --after, --follow starts at the current event cursor. `--after now` makes that explicit; non-follow tail still shows recent history. Use `--actionable --for SID --format line` for concise metadata-only wake lines, or --json for structured events. The built-in watcher additionally checks current/recoverable work and tracks health, so prefer it for native host notifications.
|
|
131
|
+
|
|
93
132
|
A follower subscribes before replay, deduplicates by event_seq, and reconnects with its last cursor. Observer calls never dequeue work. `--for` matches the recipient inbox (including its current commander role inbox); it is separate from observing the whole channel. Historical role-inbox events belong to the role, not permanently to a former commander's sid. Expired cursors produce `retention.gap`; observers can rebuild current work from list/recover. Cursors ahead of this database produce CURSOR_AHEAD instead of silently skipping events.
|
|
94
133
|
|
|
95
134
|
## Upgrade and verification boundary
|
|
96
135
|
|
|
97
136
|
Automatic version-triggered shutdown is disabled, including upgrade requests from old clients. A newer client reports UPGRADE_REQUIRED. The 0.2 daemon rejects clients older than 0.2.0 (and missing/invalid versions) with PROTOCOL_MISMATCH before registration, because the tool semantics changed even though the wire protocol remains 1. Refresh/reinstall stale plugin caches and restart their MCP connections. `cmdr daemon restart` first opens a consistent SQLite backup in a temporary directory with the new bundle, exercising its schema and record readers before stopping the live service. A failed check leaves the old daemon running. Doctor lists connected clients and their versions; cached plugins still need refreshing/reinstalling.
|
|
98
137
|
|
|
99
|
-
Tests exercise command recovery, role/member handover, cancellation gates, wake failure/reconciliation and CLI/daemon processes in disposable CMDR_HOME directories. They do not demonstrate that every host GUI grants hook trust or that real model turns will always acknowledge work. Real
|
|
138
|
+
Tests exercise command recovery, role/member handover, cancellation gates, wake failure/reconciliation and CLI/daemon processes in disposable CMDR_HOME directories. They do not demonstrate that every host GUI grants hook trust or that real model turns will always acknowledge work. Real model wake/report cycles remain separate host checks. Windows, remote transport, new-agent creation and executor-to-executor messaging remain outside this implementation.
|
package/docs/publishing.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# npm 发布
|
|
2
2
|
|
|
3
|
-
本次发布版本为 `cmdr-mcp@0.
|
|
3
|
+
本次发布版本为 `cmdr-mcp@0.4.0`。npm 包名是 `cmdr-mcp`,CLI、宿主插件和 marketplace 名称仍为 `cmdr`。全局安装后的包根目录是 `$(npm root -g)/cmdr-mcp`。
|
|
4
4
|
|
|
5
5
|
## 准备与验证
|
|
6
6
|
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
npm ci
|
|
11
11
|
npm run check
|
|
12
12
|
npm pack
|
|
13
|
-
npm publish ./cmdr-mcp-0.
|
|
13
|
+
npm publish ./cmdr-mcp-0.4.0.tgz --dry-run --access public --registry https://registry.npmjs.org/
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
涉及 ZCode 的发布另运行 `npm run verify:zcode`:从实际 tarball 安装到隔离缓存,核对完整性并移走安装源后验证 7 个工具;需要本机 ZCode runtime。
|
|
17
17
|
|
|
18
|
-
`npm run check` 包括格式、类型、构建、测试以及临时目录中的 npm 包离线安装验证:检查发布资源、安装后 marketplace 路径、CLI 和 7 个 MCP 工具。`npm pack` 通过 `prepack` 生成 4 个运行入口及第三方许可证声明,输出 `cmdr-mcp-0.
|
|
18
|
+
`npm run check` 包括格式、类型、构建、测试以及临时目录中的 npm 包离线安装验证:检查发布资源、安装后 marketplace 路径、CLI 和 7 个 MCP 工具。`npm pack` 通过 `prepack` 生成 4 个运行入口及第三方许可证声明,输出 `cmdr-mcp-0.4.0.tgz`。源码、测试和开发依赖不进入发布包。
|
|
19
19
|
|
|
20
20
|
检查 `git diff`,确认版本与预期一致,构建未意外修改宿主 manifests。发布前保留经过验证的源码提交;不要手改或提交 `plugins/cmdr/dist/`、`THIRD_PARTY_NOTICES.txt` 和 `.tgz`。
|
|
21
21
|
|
|
@@ -36,20 +36,20 @@ npm view cmdr-mcp name version --registry https://registry.npmjs.org/
|
|
|
36
36
|
确认发布时,上传已检查的 tarball,并按 npm 提示完成账号验证:
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
|
-
npm publish ./cmdr-mcp-0.
|
|
39
|
+
npm publish ./cmdr-mcp-0.4.0.tgz --access public --registry https://registry.npmjs.org/
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
此命令会公开发布 `0.
|
|
42
|
+
此命令会公开发布 `0.4.0` 并使用默认的 `latest` 标签。相同包名和版本不能重复发布;后续修改需要提升版本并重新构建验证。发布使用 tarball,以保持上传内容与已检查产物一致。
|
|
43
43
|
|
|
44
44
|
## 发布后核对
|
|
45
45
|
|
|
46
46
|
```sh
|
|
47
|
-
npm view cmdr-mcp@0.
|
|
48
|
-
npm install --global cmdr-mcp@0.
|
|
47
|
+
npm view cmdr-mcp@0.4.0 name version dist.integrity --registry https://registry.npmjs.org/
|
|
48
|
+
npm install --global cmdr-mcp@0.4.0 --registry https://registry.npmjs.org/
|
|
49
49
|
cmdr --help
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
按照
|
|
52
|
+
按照[安装说明](README.zh-CN.md#安装)运行 setup 或注册原生插件。原生插件升级后刷新或重装宿主缓存,使用新版本 CLI 执行 `cmdr daemon restart`,再重连 MCP;该命令先做一致性预检,再替换旧 daemon。随后检查监听状态,Claude/ZCode 按 `listener.arm` 重新挂载 watcher。
|
|
53
53
|
|
|
54
54
|
npm 命令行为参考:[npm publish 官方文档](https://docs.npmjs.com/cli/v11/commands/npm-publish/)。
|
|
55
55
|
|
package/docs/setup.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Standalone setup
|
|
2
|
+
|
|
3
|
+
Available from cmdr-mcp 0.4.0. Requires macOS/Linux and Node.js >=22.5 (24 recommended).
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx -y --package=cmdr-mcp@latest cmdr setup --agent claude-code
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Choose `claude-code`, `codex` or `zcode`. Setup installs a persistent runtime, the `cmdr` skill, MCP and user hooks, then checks the seven tools in temporary state. Use the printed CLI path (normally `~/.cmdr/bin/cmdr`), open a new host session and complete any trust prompts. Existing hook opt-outs are preserved. Other MCP hosts use `cmdr config --agent <host-id>`.
|
|
10
|
+
|
|
11
|
+
To install only the self-contained skill and its role/setup references:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx skills add njugray/cmdr --skill cmdr
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Add `-g` for global scope or `--agent <supported-agent>` to select a host. This installs no runtime or MCP configuration; use an existing cmdr integration or run setup. Choose setup or the native plugin for each host to avoid duplicate tools and hooks. Invoke the standalone skill through the host's skill interface or ask “use cmdr to join my-project”.
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
| Host | MCP configuration | User hooks | Skill |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| Claude Code (`claude-code`, alias `claude`) | `~/.claude.json` | `~/.claude/settings.json` | `~/.claude/skills/cmdr` |
|
|
24
|
+
| Codex | `$CODEX_HOME/config.toml`, default `~/.codex/config.toml` | `$CODEX_HOME/hooks.json` | `$CODEX_HOME/skills/cmdr` |
|
|
25
|
+
| ZCode | `~/.zcode/cli/config.json`, `mcp.servers` | Same file, `hooks.events` | `~/.zcode/skills/cmdr` |
|
|
26
|
+
|
|
27
|
+
| Option | Purpose |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `--dry-run` | Preview destinations/conflicts without installing runtime or changing host configuration |
|
|
30
|
+
| `--json` | Return paths, changes, warnings and backup location as JSON |
|
|
31
|
+
| `--config-dir PATH` | Select a custom host **user** profile directory; launch the host with that same profile |
|
|
32
|
+
|
|
33
|
+
`CLAUDE_CONFIG_DIR` is respected; its MCP file is `<CLAUDE_CONFIG_DIR>/.claude.json`. ZCode loads user hooks, not workspace hooks. `CMDR_HOME` selects runtime/state storage (default `~/.cmdr`): build directories live in `runtimes/`, stable profile-specific launchers in `bin/`. They survive npx cache removal and bind the host/state directory, never a fixed session ID. See [host integration](agent-integration.md) for identity and lifecycle contracts.
|
|
34
|
+
|
|
35
|
+
## Upgrade and recovery
|
|
36
|
+
|
|
37
|
+
Repeat setup with the newer package to upgrade. Unchanged files stay unchanged; prior runtime directories remain available to existing processes. Setup does not restart the daemon. If it reports `UPGRADE_REQUIRED`, coordinate active work, run `<printed-cli> daemon restart`, then reconnect sessions.
|
|
38
|
+
|
|
39
|
+
Setup preserves other servers, settings and hooks. Codex retains unrelated TOML text/comments; JSON settings are reformatted without discarding other values. Malformed configuration, an enabled cmdr plugin, an unmanaged cmdr MCP entry or an unrelated skill named `cmdr` stops setup before host changes.
|
|
40
|
+
|
|
41
|
+
Existing copies/symlinks of this repository's skill are backed up and replaced with a link to the persistent runtime. Shared npx-skills sources are left intact; custom files in an adopted copy remain in its backup. Upgrade setup-managed skills through setup.
|
|
42
|
+
|
|
43
|
+
Backups live in `<CMDR_HOME>/setup-backups/<run>/`. `restore.json` maps each changed path to its backup (`null` marks a newly created entry). Failed writes are rolled back; concurrent edits are reported for manual recovery. After a crash, inspect that record before retrying. Remove a stale `setup.lock` only after confirming its recorded process has stopped.
|
|
44
|
+
|
|
45
|
+
For diagnostics, run `<printed-cli> doctor --deep`. Move a damaged runtime directory aside and rerun setup from an intact package. Native plugins require their own cache refresh. For [automatic standby](long-running-collaboration.md#automatic-standby), Claude/ZCode arm `listener.arm.command` with the indicated native host tool; Codex uses daemon-managed proxy/queue delivery. GUI trust, actual hook execution and automatic wake must be verified in the host; setup's isolated MCP check does not establish those capabilities.
|
package/docs/troubleshooting.md
CHANGED
|
@@ -86,3 +86,9 @@ Short-lived commands display cli and retain task ownership after exit. They do n
|
|
|
86
86
|
- Missing runtime or Node now produces one stderr line from the fail-open hook wrapper as well as the bounded diagnostic snapshot.
|
|
87
87
|
|
|
88
88
|
See [long-running collaboration](long-running-collaboration.md) for adapter requirements and recovery examples.
|
|
89
|
+
|
|
90
|
+
## Automatic wake diagnostics
|
|
91
|
+
|
|
92
|
+
- Codex: `standby status --session SID` shows the selected `transport`. Auto mode tries proxy then queue. Missing socket alone no longer establishes that wake is unavailable. Queue compatibility needs Node >=22.12, an available CLI with queue --thread/--message, and readable state_5/rollout lifecycle records in the daemon's CODEX_HOME. Inspect the concrete proxy/queue error before choosing an explicit executable or transport.
|
|
93
|
+
- Claude/ZCode: `wake_mode=claude|zcode` with starting means the native watcher still needs arming. Use the absolute `listener.arm.command` with Monitor or background Bash as specified; shell detachment cannot supply a native completion notification. WATCHER_ACTIVE means inspect/reuse the existing native task. Re-arm after daemon/App restart or native task expiry.
|
|
94
|
+
- `uncertain` is not automatic retry permission. Reconcile host history and cmdr work, then choose standby resume --resolve accepted or retry. CLI acceptance never substitutes for a working report from the member.
|