cowork-flow 2.4.2 → 2.5.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.en.md +2 -1
  3. package/README.md +2 -1
  4. package/docs/architecture.en.md +2 -0
  5. package/docs/architecture.md +2 -0
  6. package/docs/hosts.en.md +15 -0
  7. package/docs/hosts.md +15 -0
  8. package/package.json +2 -2
  9. package/presets/claude-code/.claude-plugin/plugin.json +1 -1
  10. package/presets/codex/.codex-plugin/plugin.json +1 -1
  11. package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
  12. package/presets/qoder/.qoder-plugin/plugin.json +1 -1
  13. package/presets/zcode/.zcode-plugin/plugin.json +1 -1
  14. package/src/commands/host-inspect.js +86 -0
  15. package/src/commands/host.js +42 -18
  16. package/src/commands/init.js +100 -3
  17. package/src/commands/install-claude-code-plugin.js +53 -2
  18. package/src/commands/install-codex-plugin.js +114 -4
  19. package/src/commands/install-dsh-hook.js +51 -0
  20. package/src/commands/install-dsh-preset.js +46 -4
  21. package/src/commands/install-kimi-code-plugin.js +61 -2
  22. package/src/commands/install-kimi-hook.js +84 -2
  23. package/src/commands/install-opencode-plugin.js +58 -2
  24. package/src/commands/install-qoder-plugin.js +67 -3
  25. package/src/commands/install-zcode-plugin.js +77 -2
  26. package/src/commands/registry.js +20 -5
  27. package/src/lib/dsh-home.js +2 -2
  28. package/template/.cowork-flow/.version +1 -1
  29. package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +4 -0
  30. package/template/.cowork-flow/scripts/adapters/host/workflow_state_hook.py +1 -3
  31. package/template/.cowork-flow/scripts/infra/files.py +0 -13
  32. package/template/.cowork-flow/scripts/services/ac_evidence.py +1 -1
  33. package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +65 -0
  34. package/template/.cowork-flow/scripts/services/fact_view.py +2 -75
  35. package/template/.cowork-flow/scripts/services/lifecycle_checks.py +1 -1
  36. package/template/.cowork-flow/scripts/services/plan_readiness.py +139 -67
  37. package/template/.cowork-flow/spec/contracts/host-install-inspection.md +174 -0
  38. package/template/.cowork-flow/spec/contracts/index.md +1 -0
  39. package/template/.cowork-flow/spec/runtime/contract-registry.json +15 -0
  40. package/template/skills/runtime-health/scripts/doctor.py +538 -489
  41. package/template/skills/task-review/scripts/review_check.py +33 -6
package/CHANGELOG.md CHANGED
@@ -6,6 +6,23 @@
6
6
 
7
7
  ### Changed
8
8
 
9
+ ## [2.5.0] - 2026-10-26
10
+
11
+ ### Added
12
+
13
+ - **`cwf host inspect` 机器级安装态读模型**:新增只读命令 `cwf host inspect [host] [--json]`,按宿主组件输出 `schemaVersion: 1` 的 `status`、`version`、`payloadPath`、`detailPath`、`registeredSource`、`enabled` 与 `reason` 行;各安装器在自身布局内提供 installed-state facts,doctor 的宿主检查改为消费该模型,Python 不再解析宿主注册表、TOML、设置文件或载荷清单。读取不可用时 doctor 报 `HOST-INSPECT-UNAVAILABLE`,不会把“读不到”误判为未安装。
14
+ - **安装前置与实例级测试补齐**:`project init` 探测 Python 3.10+ 并给出缺失或过旧告警;新增 EOL 门禁并重物化 CRLF 工作区文件;补齐 zcode 宿主契约断言、manifest 能力错配测试与安装→doctor→移除的实例级 e2e。
15
+
16
+ ### Changed
17
+
18
+ - **anchor 解析与文档事实收敛**:`parse_decision_anchor` 迁入 `decision_anchor_schema`,`fact_view` 保留 re-export;文档宿主清单从 `host-assets.json` 派生并覆盖中英文;新增 Node/Python 共享语言配置夹具,锁定 YAML 读取事实。
19
+ - **`review-check` 路径解析统一**:复用 `TaskRepository` 的 slug、相对路径与绝对路径解析,不再依赖调用方传入的任务目录形状;统一别名到期口径并删除零引用工具函数。
20
+
21
+ ### Fixed
22
+
23
+ - **inspect 诊断路径与宿主噪音**:inspect 行新增 `detailPath` 并让 doctor 直接消费;codex broken 指向缺失的 `.codex-plugin/plugin.json`,文本输出优先显示 `detailPath`;未选用 DSH/Kimi 的项目不再出现 `HOST-INSPECT-UNAVAILABLE`,无已选平台时跳过 inspect;补齐 zcode/kimi 的路径与版本回归测试。
24
+ - **doctor TOML 行内注释解析**:修正 Codex 配置读取对行内注释的处理,避免带注释的注册值被误读。
25
+
9
26
  ## [2.4.2] - 2026-10-23
10
27
 
11
28
  ### Added
@@ -445,7 +462,8 @@
445
462
 
446
463
  此版本未保留本地条目正文,详情见 [GitHub Release](https://github.com/fishlikewater/cowork-flow/releases/tag/v0.0.47)。
447
464
 
448
- [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.4.2...HEAD
465
+ [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.5.0...HEAD
466
+ [2.5.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.4.2...v2.5.0
449
467
  [2.4.2]: https://github.com/fishlikewater/cowork-flow/compare/v2.4.1...v2.4.2
450
468
  [2.4.1]: https://github.com/fishlikewater/cowork-flow/compare/v2.4.0...v2.4.1
451
469
  [2.4.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.3.0...v2.4.0
package/README.en.md CHANGED
@@ -33,7 +33,7 @@ system, read up first and decide whether to adopt it.
33
33
 
34
34
  ## Getting started
35
35
 
36
- Node.js 20 or later is required.
36
+ Node.js 20 or later is required. Python 3.10 or later is also required: the generated `./.cowork-flow/run` and its diagnostics run on Python, and `cwf project init` warns when no suitable interpreter is found.
37
37
 
38
38
  ### 1. Install the CLI
39
39
 
@@ -162,6 +162,7 @@ how the project is organized, see [architecture and extension](docs/architecture
162
162
  | `cwf host add <host> [--component <name>] [--dry-run] [--force] [--prune-old] [--uninstall]` | Install a machine-level host component |
163
163
  | `cwf host remove <host> [--component <name>] [--dry-run] [--force]` | Remove a machine-level host component |
164
164
  | `cwf host list [target] [--json]` | List supported hosts and what the project selected |
165
+ | `cwf host inspect [host] [--json]` | Read machine-level host install state (the model doctor consumes) |
165
166
  | `cwf self update [--dry-run]` | Update the globally installed CLI |
166
167
  | `cwf dev refresh [target] [--dry-run]` | Refresh the self-instance while maintaining the cowork-flow repo |
167
168
  | `cwf mcp serve [args...]` | Serve task facts to an MCP client |
package/README.md CHANGED
@@ -28,7 +28,7 @@ cowork-flow 不绑定技术栈,也不会用脚手架改写现有项目。它
28
28
 
29
29
  ## 开始使用
30
30
 
31
- 需要 Node.js 20 或更高版本。
31
+ 需要 Node.js 20 或更高版本。还需要 Python 3.10 或更高版本:项目里的 `./.cowork-flow/run` 与诊断脚本由 Python 运行;`cwf project init` 检测不到合适版本时会给出警告。
32
32
 
33
33
  ### 1. 安装命令
34
34
 
@@ -124,6 +124,7 @@ cwf project sync .
124
124
  | `cwf host add <host> [--component <name>] [--dry-run] [--force] [--prune-old] [--uninstall]` | 安装机器级宿主组件 |
125
125
  | `cwf host remove <host> [--component <name>] [--dry-run] [--force]` | 卸载机器级宿主组件 |
126
126
  | `cwf host list [target] [--json]` | 查看支持的宿主和项目选择情况 |
127
+ | `cwf host inspect [host] [--json]` | 只读查看机器级宿主安装态(doctor 消费同一读模型) |
127
128
  | `cwf self update [--dry-run]` | 更新全局安装的 CLI |
128
129
  | `cwf dev refresh [target] [--dry-run]` | 维护 cowork-flow 仓库时刷新自实例 |
129
130
  | `cwf mcp serve [args...]` | 向 MCP 客户端提供任务事实 |
@@ -44,6 +44,8 @@ The content in `template/` that directly relates to a user project includes:
44
44
 
45
45
  Machine-level installers may write into host configuration directories only through `cwf host add` / `cwf host remove`, and must not hard-code user home directory paths into `template/`.
46
46
 
47
+ Reading machine-level install state has one path too: each installer exports `inspectInstalledState` describing the layout it writes, `cwf host inspect` normalizes those facts into read-only `schemaVersion: 1` rows, and the doctor consumes only that model. The Python runtime does not parse host registries, TOML, settings, or payload manifests; when the read is unavailable the doctor reports `HOST-INSPECT-UNAVAILABLE` instead of mistaking "could not read" for "not installed". See `spec/contracts/host-install-inspection.md`.
48
+
47
49
  ## Runtime layers
48
50
 
49
51
  Runtime code lives in `template/.cowork-flow/scripts/`. The repository root `scripts/` only handles building and releasing.
@@ -44,6 +44,8 @@
44
44
 
45
45
  机器级安装器只能通过 `cwf host add` / `cwf host remove` 写入宿主配置目录,不应把用户主目录路径硬编码到 `template/`。
46
46
 
47
+ 机器级安装态的读取同样只有一条路径:各安装器导出 `inspectInstalledState` 描述自己写下的布局,`cwf host inspect` 把它归一化为 `schemaVersion: 1` 的只读行,`doctor` 只消费这份事实。Python 运行时不解析宿主注册表、TOML、设置文件或载荷清单;读取不可用时 doctor 报 `HOST-INSPECT-UNAVAILABLE`,不会把“读不到”误判为“未安装”。契约见 `spec/contracts/host-install-inspection.md`。
48
+
47
49
  ## 运行时分层
48
50
 
49
51
  运行时代码位于 `template/.cowork-flow/scripts/`。仓库根的 `scripts/` 只负责构建和发布。
package/docs/hosts.en.md CHANGED
@@ -57,6 +57,20 @@ Use `--force` only once you have confirmed that an existing installation needs t
57
57
 
58
58
  Machine-level hooks and the project runtime upgrade independently, yet a machine-level hook fires in any workspace — including projects whose runtime is older than the hook. The four machine-level injection shims (Qoder, ZCode, Kimi Code, OpenCode) are therefore **fail-open**: when the project runtime fails, they only record the reason in the host's run log and return 0; they do not inject, and they never turn "hook failed" into "your input is rejected". The project-level Edit-time hooks (Claude Code / Codex) have likewise stopped returning a non-zero exit since 2.0.0 and are always advisory. In an old project, injection silently has no effect; run `cwf project sync .` once to restore it.
59
59
 
60
+ ## Install-state inspection
61
+
62
+ `cwf host list` only answers "which hosts are declared and which did the project select"; to see what is actually installed on the machine, use the read-only `cwf host inspect`:
63
+
64
+ ```bash
65
+ cwf host inspect
66
+ cwf host inspect qoder
67
+ cwf host inspect --json
68
+ ```
69
+
70
+ One row per installable component, with status `installed`, `missing`, `stale`, `broken`, or `unsupported`. `stale` means the installed payload version differs from the running CLI version; `broken` means the host knows about cowork-flow but a required payload artifact is absent. The doctor then compares that same version with the project's `.cowork-flow/.version`: a CLI newer than the project with a payload that still matches the project's runtime stays silent, while a payload that lags a synced project is still `PLUGIN-STALE`. `kimi-code`'s `all` is only a command composition and never appears as a row. The command is read-only and never repairs, installs, or uninstalls; an unhealthy install is data, not a command failure, and only usage errors such as an unknown host exit with 2.
71
+
72
+ The doctor's host checks consume the same read model (`cwf host inspect --json`) and no longer parse host directories, registries, settings, or TOML themselves. When the CLI is not on `PATH`, exits non-zero, times out, or reports an unexpected `schemaVersion`, the doctor emits `HOST-INSPECT-UNAVAILABLE` with an upgrade hint instead of falsely reporting `PLUGIN-NOT-INSTALLED` — "could not read" and "read as not installed" are different facts. See `spec/contracts/host-install-inspection.md` for the full contract.
73
+
60
74
  ## Codex
61
75
 
62
76
  ```bash
@@ -291,6 +305,7 @@ Hosts support different manifest fields, so do not copy the same set of fields i
291
305
  | `COWORK_FLOW_CONTEXT_ID` | Explicitly set the session identity; use when the host provides no session variable |
292
306
  | `COWORK_FLOW_HOST` | Explicitly set the host id |
293
307
  | `COWORK_FLOW_CODEX` | Set the Codex CLI executable |
308
+ | `COWORK_FLOW_CLI` | Set the cowork-flow CLI the doctor uses to read install state; a `.js`, `.mjs` or `.cjs` path runs through node |
294
309
  | `DSH_HOME` | Override the DeepSeek Harness configuration root |
295
310
  | `KIMI_CODE_HOME` | Override the Kimi Code configuration root |
296
311
  | `CODEX_HOME` | Override the Codex configuration root |
package/docs/hosts.md CHANGED
@@ -57,6 +57,20 @@ cwf host remove <host>
57
57
 
58
58
  机器级 hook 与项目运行时各自升级,而它会在任何工作区触发——包括运行时比它旧的项目。四个机器级注入 shim(Qoder、ZCode、Kimi Code、OpenCode)因此是 **fail-open** 的:项目运行时失败时只在宿主运行日志留原因并返回 0,不注入,也不把「hook 失败」变成「拒绝你的输入」;项目级 Edit 期 hook(Claude Code / Codex)自 2.0.0 起同样不再返回非零退出,一律 advisory。旧项目上注入会静默不生效,跑一次 `cwf project sync .` 即可恢复。
59
59
 
60
+ ## 安装态检查
61
+
62
+ `cwf host list` 只回答“声明了哪些宿主、项目选了哪些”;机器上实际装了什么,用只读的 `cwf host inspect`:
63
+
64
+ ```bash
65
+ cwf host inspect
66
+ cwf host inspect qoder
67
+ cwf host inspect --json
68
+ ```
69
+
70
+ 每个可安装组件一行,状态为 `installed`、`missing`、`stale`、`broken` 或 `unsupported`。`stale` 表示已装载荷版本与当前 CLI 版本不同;`broken` 表示宿主有注册但载荷缺件。doctor 会再拿同一版本与本项目 `.cowork-flow/.version` 比较:CLI 比项目新、但插件仍匹配项目运行时不报;项目已 sync 到新版本、插件落后时仍报 `PLUGIN-STALE`。`kimi-code` 的 `all` 只是命令组合,不会单独出现。命令只读,不修复、不安装、不卸载;安装态异常是数据,不是命令失败,只有未知宿主等用法错误才返回 2。
71
+
72
+ `run doctor` 的宿主检查消费同一份读模型(`cwf host inspect --json`),不再自己解析宿主目录、注册表、设置文件或 TOML。CLI 不在 PATH、退出码非 0、超时或 `schemaVersion` 不匹配时,doctor 报 `HOST-INSPECT-UNAVAILABLE` 并给出升级提示,而不是误报 `PLUGIN-NOT-INSTALLED`——“读不到”和“读到没装”是两件事。完整契约见 `spec/contracts/host-install-inspection.md`。
73
+
60
74
  ## Codex
61
75
 
62
76
  ```bash
@@ -291,6 +305,7 @@ claude mcp add -s user cowork-flow -- cwf mcp serve
291
305
  | `COWORK_FLOW_CONTEXT_ID` | 显式指定会话身份;宿主不提供会话变量时使用 |
292
306
  | `COWORK_FLOW_HOST` | 显式指定宿主 id |
293
307
  | `COWORK_FLOW_CODEX` | 指定 Codex CLI 可执行文件 |
308
+ | `COWORK_FLOW_CLI` | 指定 doctor 读取安装态时调用的 cowork-flow CLI;`.js`/`.mjs`/`.cjs` 路径用 node 执行 |
294
309
  | `DSH_HOME` | 覆盖 DeepSeek Harness 配置根目录 |
295
310
  | `KIMI_CODE_HOME` | 覆盖 Kimi Code 配置根目录 |
296
311
  | `CODEX_HOME` | 覆盖 Codex 配置根目录 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "CLI for installing and maintaining cowork-flow collaboration templates.",
5
5
  "keywords": [
6
6
  "ai-agent",
@@ -49,7 +49,7 @@
49
49
  "scripts": {
50
50
  "test": "npm run test:fast",
51
51
  "test:smoke": "node --test --test-timeout=600000 test/smoke.test.js test/tarball-install.test.js",
52
- "test:fast": "node --test --test-timeout=600000 test/asset-plan.test.js test/cli.test.js test/cli-registry.test.js test/claude-code-plugin.test.js test/codex-plugin.test.js test/compliance-e2e.test.js test/contract-fingerprint.test.js test/copy-template.obsolete-safety.test.js test/docs.test.js test/host-assets.test.js test/host-command.test.js test/kimi-hook.test.js test/localization.test.js test/kimi-installed-registry.test.js test/kimi-plugin.test.js test/opencode-plugin-installer.test.js test/opencode-plugin.test.js test/package.test.js test/plugin-metadata.test.js test/plugin-payload.test.js test/qoder-plugin.test.js test/smoke.test.js test/stage-contract.test.js test/template-runner.test.js test/update.test.js test/zcode-plugin.test.js",
52
+ "test:fast": "node --test --test-timeout=600000 test/asset-plan.test.js test/cli.test.js test/cli-registry.test.js test/claude-code-plugin.test.js test/codex-plugin.test.js test/compliance-e2e.test.js test/contract-fingerprint.test.js test/copy-template.obsolete-safety.test.js test/docs.test.js test/eol.test.js test/host-assets.test.js test/host-command.test.js test/host-inspect.test.js test/installed-state-e2e.test.js test/kimi-hook.test.js test/localization.test.js test/kimi-installed-registry.test.js test/kimi-plugin.test.js test/opencode-plugin-installer.test.js test/opencode-plugin.test.js test/package.test.js test/plugin-metadata.test.js test/plugin-payload.test.js test/qoder-plugin.test.js test/smoke.test.js test/stage-contract.test.js test/template-runner.test.js test/update.test.js test/zcode-plugin.test.js",
53
53
  "test:integration": "node --test --test-timeout=600000 --test-name-pattern=\"^(init copies the template into a new target directory|sync updates safe template files and preserves protected files)$\" test/init.test.js test/sync.test.js",
54
54
  "test:node:full": "node --test --test-timeout=600000",
55
55
  "test:template": "node scripts/run-template-tests.js --suite core",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Claude Code。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Codex。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Kimi Code。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Qoder。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 ZCode。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -0,0 +1,86 @@
1
+ import { hostRegistry } from '../lib/host-assets.js';
2
+ import { readPackageInfo } from '../lib/package-info.js';
3
+
4
+ export const INSPECT_SCHEMA_VERSION = 1;
5
+
6
+ export const INSPECT_STATUSES = Object.freeze([
7
+ 'installed',
8
+ 'missing',
9
+ 'stale',
10
+ 'broken',
11
+ 'unsupported'
12
+ ]);
13
+
14
+
15
+ function normalizedRow(facts, cliVersion) {
16
+ const installed = facts.status === 'installed';
17
+ const stale = installed && facts.version !== null && facts.version !== cliVersion;
18
+ return {
19
+ status: stale ? 'stale' : facts.status,
20
+ version: facts.version ?? null,
21
+ payloadPath: facts.payloadPath ?? null,
22
+ detailPath: facts.detailPath ?? null,
23
+ registeredSource: facts.registeredSource ?? null,
24
+ enabled: facts.enabled ?? null,
25
+ reason: stale
26
+ ? `installed ${facts.version} but the CLI runs ${cliVersion}`
27
+ : facts.reason ?? null
28
+ };
29
+ }
30
+
31
+
32
+ function unsupportedRow(hostId, componentName) {
33
+ return {
34
+ status: 'unsupported',
35
+ version: null,
36
+ payloadPath: null,
37
+ detailPath: null,
38
+ registeredSource: null,
39
+ enabled: null,
40
+ reason: `${hostId} component ${componentName} does not expose an installed-state reader`
41
+ };
42
+ }
43
+
44
+
45
+ // Read-only aggregation. Each component owns its installation layout and
46
+ // exposes the facts; this module only normalizes them against the running CLI.
47
+ export async function inspectHosts(components, hostIds, { env = process.env } = {}) {
48
+ const { version: cliVersion } = await readPackageInfo();
49
+ const hosts = [];
50
+ for (const hostId of hostIds) {
51
+ const platform = hostRegistry.platform(hostId);
52
+ const host = components[hostId];
53
+ for (const [componentName, component] of Object.entries(host.components)) {
54
+ // `all` is a composition of the components below it, not a separate
55
+ // installed artifact.
56
+ if (componentName === 'all') {
57
+ continue;
58
+ }
59
+ const facts = typeof component.inspect === 'function'
60
+ ? await component.inspect({ env })
61
+ : unsupportedRow(hostId, componentName);
62
+ hosts.push({
63
+ id: hostId,
64
+ displayName: platform.displayName,
65
+ component: componentName,
66
+ ...normalizedRow(facts, cliVersion)
67
+ });
68
+ }
69
+ }
70
+ return {
71
+ schemaVersion: INSPECT_SCHEMA_VERSION,
72
+ cliVersion,
73
+ hosts
74
+ };
75
+ }
76
+
77
+
78
+ export function renderInspectLine(row) {
79
+ const detail = [
80
+ row.version ? `version ${row.version}` : null,
81
+ row.detailPath || row.payloadPath,
82
+ row.enabled === false ? 'not enabled' : null,
83
+ row.reason
84
+ ].filter(Boolean).join('; ');
85
+ return `${row.id} (${row.displayName}, ${row.component}): ${row.status}${detail ? ` - ${detail}` : ''}\n`;
86
+ }
@@ -3,15 +3,16 @@ import { join, resolve } from 'node:path';
3
3
  import { UsageError, extractValueFlag, parseFlags } from '../lib/cli-flags.js';
4
4
  import { hostRegistry } from '../lib/host-assets.js';
5
5
  import { pathExists } from '../lib/install-support.js';
6
- import { runInstallCodexPlugin, FLAGS as CODEX_PLUGIN_FLAGS } from './install-codex-plugin.js';
7
- import { runInstallClaudeCodePlugin, FLAGS as CLAUDE_CODE_PLUGIN_FLAGS } from './install-claude-code-plugin.js';
8
- import { runInstallDshHook, FLAGS as DSH_HOOK_FLAGS } from './install-dsh-hook.js';
9
- import { runInstallDshPreset, FLAGS as DSH_PRESET_FLAGS } from './install-dsh-preset.js';
10
- import { runInstallKimiPlugin, FLAGS as KIMI_PLUGIN_FLAGS } from './install-kimi-code-plugin.js';
11
- import { runInstallKimiHook, FLAGS as KIMI_HOOK_FLAGS } from './install-kimi-hook.js';
12
- import { runInstallOpenCodePlugin, FLAGS as OPENCODE_PLUGIN_FLAGS } from './install-opencode-plugin.js';
13
- import { runInstallQoderPlugin, FLAGS as QODER_PLUGIN_FLAGS } from './install-qoder-plugin.js';
14
- import { runInstallZCodePlugin, FLAGS as ZCODE_PLUGIN_FLAGS } from './install-zcode-plugin.js';
6
+ import { runInstallCodexPlugin, inspectInstalledState as inspectCodex, FLAGS as CODEX_PLUGIN_FLAGS } from './install-codex-plugin.js';
7
+ import { runInstallClaudeCodePlugin, inspectInstalledState as inspectClaude, FLAGS as CLAUDE_CODE_PLUGIN_FLAGS } from './install-claude-code-plugin.js';
8
+ import { runInstallDshHook, inspectInstalledState as inspectDshHook, FLAGS as DSH_HOOK_FLAGS } from './install-dsh-hook.js';
9
+ import { runInstallDshPreset, inspectInstalledState as inspectDshPreset, FLAGS as DSH_PRESET_FLAGS } from './install-dsh-preset.js';
10
+ import { runInstallKimiPlugin, inspectInstalledState as inspectKimiPlugin, FLAGS as KIMI_PLUGIN_FLAGS } from './install-kimi-code-plugin.js';
11
+ import { runInstallKimiHook, inspectInstalledState as inspectKimiHook, FLAGS as KIMI_HOOK_FLAGS } from './install-kimi-hook.js';
12
+ import { runInstallOpenCodePlugin, inspectInstalledState as inspectOpenCode, FLAGS as OPENCODE_PLUGIN_FLAGS } from './install-opencode-plugin.js';
13
+ import { runInstallQoderPlugin, inspectInstalledState as inspectQoder, FLAGS as QODER_PLUGIN_FLAGS } from './install-qoder-plugin.js';
14
+ import { runInstallZCodePlugin, inspectInstalledState as inspectZCode, FLAGS as ZCODE_PLUGIN_FLAGS } from './install-zcode-plugin.js';
15
+ import { inspectHosts, renderInspectLine } from './host-inspect.js';
15
16
 
16
17
  const KIMI_ALL_FLAGS = [...new Set([...KIMI_HOOK_FLAGS, ...KIMI_PLUGIN_FLAGS])].sort();
17
18
 
@@ -25,45 +26,45 @@ export const HOST_COMPONENTS = {
25
26
  codex: {
26
27
  default: 'plugin',
27
28
  components: {
28
- plugin: { summary: 'Codex plugin: marketplace source plus the bootstrap skill', flags: CODEX_PLUGIN_FLAGS, run: runInstallCodexPlugin }
29
+ plugin: { summary: 'Codex plugin: marketplace source plus the bootstrap skill', flags: CODEX_PLUGIN_FLAGS, run: runInstallCodexPlugin, inspect: inspectCodex }
29
30
  }
30
31
  },
31
32
  'claude-code': {
32
33
  default: 'plugin',
33
34
  components: {
34
- plugin: { summary: 'Claude Code skills-directory plugin: the bootstrap skill', flags: CLAUDE_CODE_PLUGIN_FLAGS, run: runInstallClaudeCodePlugin }
35
+ plugin: { summary: 'Claude Code skills-directory plugin: the bootstrap skill', flags: CLAUDE_CODE_PLUGIN_FLAGS, run: runInstallClaudeCodePlugin, inspect: inspectClaude }
35
36
  }
36
37
  },
37
38
  opencode: {
38
39
  default: 'plugin',
39
40
  components: {
40
- plugin: { summary: 'OpenCode plugin: the plugin file plus the bootstrap skill it registers', flags: OPENCODE_PLUGIN_FLAGS, run: runInstallOpenCodePlugin }
41
+ plugin: { summary: 'OpenCode plugin: the plugin file plus the bootstrap skill it registers', flags: OPENCODE_PLUGIN_FLAGS, run: runInstallOpenCodePlugin, inspect: inspectOpenCode }
41
42
  }
42
43
  },
43
44
  zcode: {
44
45
  default: 'plugin',
45
46
  components: {
46
- plugin: { summary: 'ZCode plugin: hooks, agents and the bootstrap skill', flags: ZCODE_PLUGIN_FLAGS, run: runInstallZCodePlugin }
47
+ plugin: { summary: 'ZCode plugin: hooks, agents and the bootstrap skill', flags: ZCODE_PLUGIN_FLAGS, run: runInstallZCodePlugin, inspect: inspectZCode }
47
48
  }
48
49
  },
49
50
  qoder: {
50
51
  default: 'plugin',
51
52
  components: {
52
- plugin: { summary: 'Qoder plugin: payload, registry entry and enable flag', flags: QODER_PLUGIN_FLAGS, run: runInstallQoderPlugin }
53
+ plugin: { summary: 'Qoder plugin: payload, registry entry and enable flag', flags: QODER_PLUGIN_FLAGS, run: runInstallQoderPlugin, inspect: inspectQoder }
53
54
  }
54
55
  },
55
56
  dsh: {
56
57
  default: 'preset',
57
58
  components: {
58
- preset: { summary: 'DSH agent preset (bundles the hook, the primary path)', flags: DSH_PRESET_FLAGS, run: runInstallDshPreset },
59
- hook: { summary: 'DSH workflow-state hook as a machine-level patch row', flags: DSH_HOOK_FLAGS, run: runInstallDshHook }
59
+ preset: { summary: 'DSH agent preset (bundles the hook, the primary path)', flags: DSH_PRESET_FLAGS, run: runInstallDshPreset, inspect: inspectDshPreset },
60
+ hook: { summary: 'DSH workflow-state hook as a machine-level patch row', flags: DSH_HOOK_FLAGS, run: runInstallDshHook, inspect: inspectDshHook }
60
61
  }
61
62
  },
62
63
  'kimi-code': {
63
64
  default: 'all',
64
65
  components: {
65
- plugin: { summary: 'Kimi Code plugin: the bootstrap Skill it loads at session start', flags: KIMI_PLUGIN_FLAGS, run: runInstallKimiPlugin },
66
- hook: { summary: 'Kimi Code context-injection hook as a user-level config.toml [[hooks]] row', flags: KIMI_HOOK_FLAGS, run: runInstallKimiHook },
66
+ plugin: { summary: 'Kimi Code plugin: the bootstrap Skill it loads at session start', flags: KIMI_PLUGIN_FLAGS, run: runInstallKimiPlugin, inspect: inspectKimiPlugin },
67
+ hook: { summary: 'Kimi Code context-injection hook as a user-level config.toml [[hooks]] row', flags: KIMI_HOOK_FLAGS, run: runInstallKimiHook, inspect: inspectKimiHook },
67
68
  all: { summary: 'Kimi Code hook plus plugin, installed in one command (the default)', flags: KIMI_ALL_FLAGS, run: runInstallKimiAll }
68
69
  }
69
70
  }
@@ -151,6 +152,29 @@ export async function runHostRemove(args = []) {
151
152
  }
152
153
 
153
154
 
155
+ // Read-only inspection of machine-level installs. The installer for each host
156
+ // owns its layout; this command only asks and renders the normalized facts.
157
+ export async function runHostInspect(args = [], { io, env = process.env } = {}) {
158
+ const { flags, positionals } = parseFlags(args, {
159
+ boolean: ['--json'],
160
+ positional: { max: 1, name: '[host]' }
161
+ });
162
+ const hostIds = positionals[0] === undefined
163
+ ? [...hostRegistry.platformIds]
164
+ : [resolveHost(positionals[0]).id];
165
+
166
+ const report = await inspectHosts(HOST_COMPONENTS, hostIds, { env });
167
+ if (flags['--json']) {
168
+ io.writeOut(`${JSON.stringify(report, null, 2)}\n`);
169
+ return 0;
170
+ }
171
+ for (const row of report.hosts) {
172
+ io.writeOut(renderInspectLine(row));
173
+ }
174
+ return 0;
175
+ }
176
+
177
+
154
178
  export async function runHostList(args = [], { io } = {}) {
155
179
  const { flags, positionals } = parseFlags(args, {
156
180
  boolean: ['--json'],
@@ -109,6 +109,102 @@ async function readGitDeveloper(target) {
109
109
  }
110
110
  }
111
111
 
112
+ // `init` itself only needs Node, but the generated project runs on the
113
+ // Python runner. Probe the same candidate order template/.cowork-flow/run
114
+ // uses so a missing interpreter is reported here instead of at first use.
115
+ const PYTHON_VERSION_PROBE = "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}'); "
116
+ + 'raise SystemExit(0 if sys.version_info >= (3, 10) else 1)';
117
+
118
+ function pythonCandidates(env) {
119
+ for (const name of ['COWORK_FLOW_PYTHON', 'PYTHON']) {
120
+ const value = String(env[name] ?? '').trim();
121
+ if (value) {
122
+ // An explicit override is authoritative: the runner fails instead of
123
+ // falling through to another interpreter.
124
+ return [{ explicit: name, command: value, args: [] }];
125
+ }
126
+ }
127
+ return [
128
+ { explicit: null, command: 'python3', args: [] },
129
+ { explicit: null, command: 'python', args: [] },
130
+ { explicit: null, command: 'py', args: ['-3'] }
131
+ ];
132
+ }
133
+
134
+ function pythonVersionFrom(stdout) {
135
+ const match = /^(\d+\.\d+)/m.exec(String(stdout ?? ''));
136
+ return match ? match[1] : null;
137
+ }
138
+
139
+ async function probePython({ env = process.env } = {}) {
140
+ let older = null;
141
+ for (const candidate of pythonCandidates(env)) {
142
+ try {
143
+ const { stdout } = await execFileAsync(
144
+ candidate.command,
145
+ [...candidate.args, '-c', PYTHON_VERSION_PROBE],
146
+ { timeout: 5000, windowsHide: true }
147
+ );
148
+ return {
149
+ found: true,
150
+ version: pythonVersionFrom(stdout),
151
+ command: candidate.command,
152
+ explicit: candidate.explicit,
153
+ tooOld: false
154
+ };
155
+ } catch (error) {
156
+ if (error && error.code === 1) {
157
+ older = {
158
+ version: pythonVersionFrom(error.stdout),
159
+ command: candidate.command,
160
+ explicit: candidate.explicit
161
+ };
162
+ if (candidate.explicit) {
163
+ break;
164
+ }
165
+ continue;
166
+ }
167
+ if (candidate.explicit) {
168
+ return {
169
+ found: false,
170
+ version: null,
171
+ command: candidate.command,
172
+ explicit: candidate.explicit,
173
+ tooOld: false
174
+ };
175
+ }
176
+ }
177
+ }
178
+ return older
179
+ ? { found: false, ...older, tooOld: true }
180
+ : { found: false, version: null, command: null, explicit: null, tooOld: false };
181
+ }
182
+
183
+ function emitPythonWarning(io, probe) {
184
+ if (!probe || probe.found) {
185
+ return;
186
+ }
187
+ if (probe.tooOld) {
188
+ io.writeErr(
189
+ `Warning: Python ${probe.version ?? ''} (${probe.command}) is older than 3.10; `
190
+ + '.cowork-flow/run needs Python 3.10+. Install a newer interpreter or set COWORK_FLOW_PYTHON.\n'
191
+ );
192
+ return;
193
+ }
194
+ if (probe.explicit) {
195
+ io.writeErr(
196
+ `Warning: ${probe.explicit} does not point to a usable Python 3.10+ interpreter; `
197
+ + '.cowork-flow/run needs Python 3.10+.\n'
198
+ );
199
+ return;
200
+ }
201
+ io.writeErr(
202
+ 'Warning: no usable Python 3.10+ interpreter found '
203
+ + '(tried COWORK_FLOW_PYTHON, PYTHON, python3, python, py -3); '
204
+ + '.cowork-flow/run needs Python 3.10+.\n'
205
+ );
206
+ }
207
+
112
208
  async function readExistingDeveloper(target) {
113
209
  const developerFile = join(target, '.cowork-flow', '.developer');
114
210
  if (!await pathExists(developerFile)) {
@@ -292,13 +388,13 @@ async function buildDeveloperActions(target, developer) {
292
388
  return actions;
293
389
  }
294
390
 
295
- export async function runInit(args, { io, prompt, selectPlatforms }) {
296
- return runInitWithOptions(args, { io, prompt, selectPlatforms });
391
+ export async function runInit(args, { io, prompt, selectPlatforms, pythonProbe }) {
392
+ return runInitWithOptions(args, { io, prompt, selectPlatforms, pythonProbe });
297
393
  }
298
394
 
299
395
  export async function runInitWithOptions(
300
396
  args,
301
- { io, prompt, selectPlatforms, fileSystem }
397
+ { io, prompt, selectPlatforms, fileSystem, pythonProbe }
302
398
  ) {
303
399
  const options = parseInitArgs(args);
304
400
  const platforms = await resolvePlatforms(options, selectPlatforms);
@@ -325,6 +421,7 @@ export async function runInitWithOptions(
325
421
  await applyPlan(plan, { dryRun: options.dryRun, fileSystem });
326
422
  io.writeOut(summarizePlan(plan, options.dryRun));
327
423
  io.writeOut(`Hosts: ${formatPlatformList(platforms)}\n`);
424
+ emitPythonWarning(io, await (pythonProbe ?? probePython)());
328
425
 
329
426
  if (options.dryRun) {
330
427
  if (developer.existing) {
@@ -15,8 +15,8 @@ const LOADS = ' Loads as cowork-flow@skills-dir in the next Claude Code session
15
15
  export const FLAGS = ['--dry-run', '--force', '--uninstall'];
16
16
 
17
17
 
18
- function claudeHome() {
19
- const configured = (process.env.CLAUDE_CONFIG_DIR || '').trim();
18
+ function claudeHome(env = process.env) {
19
+ const configured = (env.CLAUDE_CONFIG_DIR || '').trim();
20
20
  return configured || join(homedir(), '.claude');
21
21
  }
22
22
 
@@ -88,3 +88,54 @@ export async function runInstallClaudeCodePlugin(args = []) {
88
88
  onDone: () => console.log(LOADS)
89
89
  });
90
90
  }
91
+
92
+
93
+ // Read-only installed-state facts for `host inspect`.
94
+ export async function inspectInstalledState({ env = process.env } = {}) {
95
+ const target = installPath(claudeHome(env));
96
+ const { manifest } = pluginPayload('claude-code');
97
+ const installed = await readManifest(target, manifest);
98
+ if (!installed) {
99
+ return {
100
+ status: 'missing',
101
+ version: null,
102
+ payloadPath: target,
103
+ detailPath: target,
104
+ registeredSource: target,
105
+ enabled: null,
106
+ reason: 'no plugin manifest'
107
+ };
108
+ }
109
+ if (installed.name !== PLUGIN_NAME) {
110
+ return {
111
+ status: 'missing',
112
+ version: null,
113
+ payloadPath: target,
114
+ detailPath: target,
115
+ registeredSource: target,
116
+ enabled: null,
117
+ reason: 'a different plugin owns this directory'
118
+ };
119
+ }
120
+ const skill = join(target, 'skills', 'cowork-flow-bootstrap', 'SKILL.md');
121
+ if (!(await pathExists(skill))) {
122
+ return {
123
+ status: 'broken',
124
+ version: typeof installed.version === 'string' ? installed.version : null,
125
+ payloadPath: target,
126
+ detailPath: skill,
127
+ registeredSource: target,
128
+ enabled: true,
129
+ reason: 'missing skills/cowork-flow-bootstrap/SKILL.md'
130
+ };
131
+ }
132
+ return {
133
+ status: 'installed',
134
+ version: typeof installed.version === 'string' ? installed.version : null,
135
+ payloadPath: target,
136
+ detailPath: join(target, ...manifest.split('/')),
137
+ registeredSource: target,
138
+ enabled: true,
139
+ reason: null
140
+ };
141
+ }