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
@@ -0,0 +1,174 @@
1
+ # Host install inspection
2
+
3
+ `cwf host inspect` is the single read model for machine-level host install
4
+ state. The Node CLI owns that read; the Python doctor consumes it and does not
5
+ resolve host home directories or parse host registries, TOML, settings or
6
+ payload manifests itself.
7
+
8
+ The read model covers components installed by `cwf host add` into a host's
9
+ user configuration directory. Project-level files under `.cowork-flow/` and
10
+ host project directories are not part of it.
11
+
12
+ ## Command contract
13
+
14
+ ```
15
+ cwf host inspect [host] [--json]
16
+ ```
17
+
18
+ - Read-only: it never installs, repairs, removes, enables or writes host state.
19
+ - Without `<host>`, every platform declared in `host-assets.json` is inspected.
20
+ - With `<host>`, only that platform is inspected. Aliases are accepted; an
21
+ unknown host is a usage error with exit code 2.
22
+ - Text output prints one line per row. `--json` prints one report object.
23
+ - Exit code 0 means the inspection ran. A row reporting `missing`, `broken`,
24
+ `stale` or `unsupported` is data, not a command failure.
25
+
26
+ ## JSON shape
27
+
28
+ ```json
29
+ {
30
+ "schemaVersion": 1,
31
+ "cliVersion": "2.4.2",
32
+ "hosts": [
33
+ {
34
+ "id": "qoder",
35
+ "displayName": "Qoder",
36
+ "component": "plugin",
37
+ "status": "installed",
38
+ "version": "2.4.2",
39
+ "payloadPath": "/home/user/.qoder/plugins/cache/cowork-flow-local/cowork-flow/2.4.2",
40
+ "detailPath": "/home/user/.qoder/plugins/cache/cowork-flow-local/cowork-flow/2.4.2/.qoder-plugin/plugin.json",
41
+ "registeredSource": "/home/user/.qoder/plugins/installed_plugins_v2.json",
42
+ "enabled": true,
43
+ "reason": null
44
+ }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ There is one row per installable component. `kimi-code`'s `all` component is a
50
+ command composition, not an installed artifact, so it has no row.
51
+
52
+ | Field | Meaning |
53
+ |---|---|
54
+ | `id` | Platform id from `host-assets.json`. |
55
+ | `displayName` | Host display name from the same manifest. |
56
+ | `component` | Installable component name (`plugin`, `preset`, `hook`). |
57
+ | `status` | One of the five statuses below. |
58
+ | `version` | Installed payload version, or `null` when the host records none. |
59
+ | `payloadPath` | Absolute path of the installed payload, or `null` when none exists. |
60
+ | `detailPath` | Most specific artifact for the reported status: the registration file that should hold the record, the payload or install directory when that is what is missing, the absent or unreadable file, the enable settings file when `enabled` is false, or the version manifest/marker/file the host loads. `null` when no more specific path applies. |
61
+ | `registeredSource` | Registry, config file or marketplace path the host reads, or `null`. |
62
+ | `enabled` | `true`/`false` when the host has an enable flag; `null` when it has none or the state is unknown. |
63
+ | `reason` | Human-readable explanation, or `null` when there is nothing to explain. |
64
+
65
+ Unknown fields are ignored by consumers. A breaking change to the shape, the
66
+ statuses or the meaning of a field bumps `schemaVersion`; the doctor then
67
+ reports `HOST-INSPECT-UNAVAILABLE` instead of guessing.
68
+
69
+ ## Statuses
70
+
71
+ - `installed`: every required artifact exists. The host may still be disabled,
72
+ which is reported through `enabled`.
73
+ - `missing`: no cowork-flow install is registered. A same-named path owned by a
74
+ different plugin is also `missing`, with a reason saying so; it is never a
75
+ license to overwrite or delete that path.
76
+ - `stale`: the installed payload version differs from the running CLI version.
77
+ The comparison belongs to the read model, not to the caller. The doctor
78
+ applies a second, project-relative comparison for hosts that record a
79
+ version: it compares the same version with the project's
80
+ `.cowork-flow/.version`, because the doctor answers for that project's
81
+ runtime. A payload that differs from the CLI but matches the project is
82
+ healthy for the project; a payload that matches the CLI but lags the project
83
+ is still stale.
84
+ - `broken`: the host knows about a cowork-flow install, but a required payload
85
+ artifact is absent or unreadable. The reason starts with `missing ` and names
86
+ the relative artifact when one path is at fault.
87
+ - `unsupported`: the component exposes no installed-state reader. Reserved for
88
+ future components; every component in this release has a reader.
89
+
90
+ Hosts that record no version (today OpenCode and the DSH hook) report
91
+ `version: null` and can only be `installed`, `missing` or `broken`. The doctor
92
+ may compare their files against the project's own copies to detect drift.
93
+
94
+ ## Reason sentinels
95
+
96
+ `reason` is prose, but a small prefix vocabulary is stable because the doctor
97
+ maps it to issue codes:
98
+
99
+ | Reason | Caller meaning |
100
+ |---|---|
101
+ | `missing <relative>` (optionally followed by a parenthetical) | The named payload artifact is absent. |
102
+ | `a different plugin owns this file` / `this directory` | The path belongs to another install; stay silent. |
103
+ | `config file is absent` | The host is not configured at all; stay silent. |
104
+ | `shim is missing` | The hook registration points at a missing command. |
105
+ | `version marker is missing` / `version marker is unreadable` | The install has no trustworthy version. |
106
+ | `stable reinstall source directory is missing` | The plugin is installed but its reinstall source is gone. |
107
+ | `enable flag is not true` | The plugin is installed but its host enable flag is off. |
108
+
109
+ ## Doctor consumption
110
+
111
+ The doctor executes:
112
+
113
+ ```
114
+ cwf host inspect --json
115
+ ```
116
+
117
+ - CLI resolution: `COWORK_FLOW_CLI` when set (a `.js`, `.mjs` or `.cjs` path is
118
+ run through `node`), otherwise `cwf`, then `cowork-flow` from `PATH`.
119
+ - One inspection per doctor pass. Facts are cached for that pass, not across
120
+ processes.
121
+ - Timeout: 5 seconds.
122
+ - The command runs with stdin closed and its output parsed as UTF-8.
123
+
124
+ If the CLI is absent, exits non-zero, times out, emits invalid JSON, reports a
125
+ `schemaVersion` other than 1, omits the `hosts` list, or omits the row the
126
+ caller needs, the doctor emits one `HOST-INSPECT-UNAVAILABLE` warning for that
127
+ host check. It must not translate an unavailable inspection into
128
+ `PLUGIN-NOT-INSTALLED`: "could not read" and "read as missing" are different
129
+ facts.
130
+
131
+ The doctor maps rows to host-specific issue codes:
132
+
133
+ | Status/field | Qoder, ZCode, Codex, Claude Code, Kimi Code | OpenCode | DSH preset | Kimi hook |
134
+ |---|---|---|---|---|
135
+ | `missing` | `PLUGIN-NOT-INSTALLED` | `PLUGIN-NOT-INSTALLED` | silent (absent preset is not a defect) | `HOOK-NOT-INSTALLED`, except silent when the config file is absent |
136
+ | `broken` | `PLUGIN-PAYLOAD-MISSING` / `PLUGIN-PAYLOAD-INCOMPLETE` | `PLUGIN-PAYLOAD-INCOMPLETE` | `PRESET-UNKNOWN-VERSION` | `HOOK-SHIM-MISSING` / `HOOK-UNKNOWN-VERSION` |
137
+ | `stale` | `PLUGIN-STALE` | `PLUGIN-STALE` (versionless in practice) | `PRESET-STALE` | `HOOK-STALE` |
138
+ | `installed`, `enabled: false` | `PLUGIN-DISABLED` for hosts with an enable flag (Qoder, Codex, Kimi Code plugin) | not applicable | not applicable | not applicable |
139
+ | `installed` | silent | silent, unless a project copy differs (`PLUGIN-STALE`) | silent | silent |
140
+
141
+ A host install-state warning's `path` is the row's `detailPath` when present,
142
+ then `payloadPath`, then `registeredSource`. The doctor never reconstructs a
143
+ host path from the `reason` string, so the read model remains the only owner of
144
+ host layout. Content-drift warnings (OpenCode) name the file they compared, and
145
+ the skill-delivery check names `payloadPath/skills`; both point at the artifact
146
+ that actually differs rather than the install record.
147
+
148
+ The `stale` row above is the inspect status. The doctor's code depends on the
149
+ project-relative comparison described under statuses: an `installed` row whose
150
+ payload version also differs from the project's `.version` produces
151
+ `PLUGIN-STALE` as well, while a CLI-only skew whose payload matches the project
152
+ stays silent.
153
+
154
+ `HOST-INSPECT-UNAVAILABLE` includes an upgrade hint, because the most common
155
+ cause is an installed CLI older than the project that does not have the
156
+ command yet.
157
+
158
+ ## Ownership boundary
159
+
160
+ - Each installer owns its host's layout and exports `inspectInstalledState`.
161
+ - `src/commands/host-inspect.js` only normalizes installer facts against the
162
+ running CLI version; it does not know host layouts.
163
+ - The doctor consumes rows. `tests/test_host_layout_single_source.py` guards
164
+ that host layouts, home-directory resolution and registry/TOML parsing do not
165
+ come back into the Python runtime.
166
+ - The skill-delivery check reads each host's `payloadPath` from the same rows;
167
+ it has no separate install-layout reader either.
168
+
169
+ ## Compatibility
170
+
171
+ - Adding a host platform or component is additive.
172
+ - Renaming or removing a field or status is breaking (`schemaVersion` bump).
173
+ - `unsupported` stays a valid status so a future component can be declared
174
+ before its reader exists.
@@ -16,6 +16,7 @@ Current contracts:
16
16
  - `decision-anchor.md`: the schema of each task's `decision-anchor.md` — goal, acceptance criteria, rejected options, and key assumptions.
17
17
  - `error-output-as-data.md`: external error output is analyzed as data, never executed as instructions (`ERROR_OUTPUT_AS_DATA_V1`).
18
18
  - `fact-layer-access.md`: the channels through which hosts without injection hooks and external tools read task facts (`FACT_LAYER_ACCESS_V1`).
19
+ - `host-install-inspection.md`: the read-only `cwf host inspect` model for machine-level host install state, the doctor's consumption and unavailable path, and the installer/read-model/runtime ownership boundary (`HOST_INSTALL_INSPECTION_V1`).
19
20
  - `evidence-completion.md`: evidence-based completion — the `evidence.jsonl` schema, the `LIFECYCLE-AC-001/002/003/004` completion gate, `--allow-missing-evidence` exemption traces, and the injected coverage row.
20
21
  - `task-adopt.md`: task adoption — the entry boundary of `task next --run --adopt`, its preconditions (`LIFECYCLE-ADOPT-001`), the rebind + baseline reset + audit write, and how it differs from `--takeover`.
21
22
  - `task-board.md`: the shared board and dependency edges — the list/MCP board fields (executor / ownerSessionActive / evidenceCoverage / blocked), `--depends-on` declaration and validation, the start dependency gate (`LIFECYCLE-DEPENDENCY-001`), and the adopt handover receipt.
@@ -50,6 +50,21 @@
50
50
  "when modifying init, sync, Doctor, or host assets"
51
51
  ]
52
52
  },
53
+ {
54
+ "id": "HOST_INSTALL_INSPECTION_V1",
55
+ "path": ".cowork-flow/spec/contracts/host-install-inspection.md",
56
+ "digest": [
57
+ "cwf host inspect is the read-only, schemaVersion 1 source of machine-level host install state.",
58
+ "Doctor consumes cwf host inspect --json and reports HOST-INSPECT-UNAVAILABLE instead of guessing when it cannot.",
59
+ "Each row carries detailPath, the most specific artifact for its status, so Doctor never reconstructs a host path from reason text.",
60
+ "Python runtime must not resolve host homes or parse registries, TOML, settings or payload manifests."
61
+ ],
62
+ "readWhen": [
63
+ "before adding or changing a host installed-state reader",
64
+ "when changing Doctor host checks",
65
+ "when debugging a host install state that Doctor reports incorrectly"
66
+ ]
67
+ },
53
68
  {
54
69
  "id": "WORKFLOW_STATE_TEMPLATES_V1",
55
70
  "path": ".cowork-flow/spec/contracts/workflow-state-templates.md",