cowork-flow 0.0.47 → 0.0.48

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 (67) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +86 -22
  3. package/package.json +3 -1
  4. package/src/commands/init.js +0 -83
  5. package/src/commands/sync.js +6 -0
  6. package/src/commands/update.js +59 -6
  7. package/src/lib/copy-template.js +70 -49
  8. package/src/lib/host-assets.js +185 -27
  9. package/src/lib/plan-applier.js +47 -0
  10. package/template/.claude/hooks/inject-workflow-state.py +7 -0
  11. package/template/.codex/hooks/inject-workflow-state.py +7 -0
  12. package/template/.cowork-flow/.version +1 -1
  13. package/template/.cowork-flow/config.yaml +0 -11
  14. package/template/.cowork-flow/scripts/adapters/cli/init_developer.py +0 -1
  15. package/template/.cowork-flow/scripts/adapters/cli/subagent.py +7 -4
  16. package/template/.cowork-flow/scripts/adapters/cli/task.py +10 -484
  17. package/template/.cowork-flow/scripts/adapters/cli/task_archive_commands.py +3 -134
  18. package/template/.cowork-flow/scripts/adapters/cli/task_context_commands.py +7 -1
  19. package/template/.cowork-flow/scripts/adapters/cli/task_lifecycle_commands.py +503 -0
  20. package/template/.cowork-flow/scripts/adapters/cli/task_navigation.py +81 -1
  21. package/template/.cowork-flow/scripts/adapters/git/git_context.py +16 -193
  22. package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +102 -0
  23. package/template/.cowork-flow/scripts/infra/config.py +0 -17
  24. package/template/.cowork-flow/scripts/infra/developer_profile.py +0 -95
  25. package/template/.cowork-flow/scripts/infra/paths.py +0 -79
  26. package/template/.cowork-flow/scripts/kernel/workflow_route.py +15 -15
  27. package/template/.cowork-flow/scripts/run.py +0 -5
  28. package/template/.cowork-flow/scripts/services/lifecycle_checks.py +163 -65
  29. package/template/.cowork-flow/scripts/services/readiness.py +3 -170
  30. package/template/.cowork-flow/scripts/services/task_archive.py +16 -11
  31. package/template/.cowork-flow/scripts/services/task_context.py +208 -40
  32. package/template/.cowork-flow/scripts/services/task_creation.py +32 -1
  33. package/template/.cowork-flow/scripts/services/task_routing.py +80 -67
  34. package/template/.cowork-flow/scripts/services/task_utils.py +0 -146
  35. package/template/.cowork-flow/scripts/services/workflow_runtime.py +1 -1
  36. package/template/.cowork-flow/spec/contracts/capabilities.md +23 -0
  37. package/template/.cowork-flow/spec/contracts/decision-anchor.md +2 -2
  38. package/template/.cowork-flow/spec/contracts/index.md +1 -0
  39. package/template/.cowork-flow/spec/contracts/party-mode-v2-board.md +20 -0
  40. package/template/.cowork-flow/spec/contracts/plan-binding.md +50 -0
  41. package/template/.cowork-flow/spec/contracts/skill-owned-actions.md +31 -7
  42. package/template/.cowork-flow/spec/guides/index.md +3 -1
  43. package/template/.cowork-flow/spec/index.md +5 -4
  44. package/template/.cowork-flow/spec/references/definition-of-done.md +2 -3
  45. package/template/.cowork-flow/spec/references/orchestration-patterns.md +1 -1
  46. package/template/.cowork-flow/spec/runtime/contract-registry.json +14 -0
  47. package/template/.cowork-flow/spec/runtime/host-assets.json +73 -3
  48. package/template/.cowork-flow/spec/schemas/host-assets.schema.json +119 -3
  49. package/template/.zcode/.zcode-plugin/plugin.json +1 -1
  50. package/template/skills/batch-execution/SKILL.md +37 -3
  51. package/template/skills/batch-execution/scripts/batch_action.py +4 -0
  52. package/template/skills/batch-execution/scripts/batch_execution.py +154 -15
  53. package/template/skills/brainstorming/SKILL.md +8 -7
  54. package/template/skills/party-mode/scripts/party_action_contract.py +113 -0
  55. package/template/skills/party-mode/scripts/party_board_store.py +148 -0
  56. package/template/skills/party-mode/scripts/party_mode_v2.py +246 -142
  57. package/template/skills/runtime-health/SKILL.md +14 -2
  58. package/template/skills/runtime-health/scripts/doctor.py +74 -26
  59. package/template/skills/task-planning/SKILL.md +105 -61
  60. package/template/skills/task-review/SKILL.md +4 -4
  61. package/template/skills/task-review/scripts/review_check.py +142 -18
  62. package/template/.cowork-flow/changes/archive/.gitkeep +0 -1
  63. package/template/.cowork-flow/scripts/adapters/cli/add_session.py +0 -465
  64. package/template/.cowork-flow/scripts/adapters/cli/change.py +0 -412
  65. package/template/.cowork-flow/workspace/index.md +0 -102
  66. package/template/.zcode/scaffold/AGENTS.md +0 -145
  67. package/template/.zcode/scaffold/CLAUDE.md +0 -5
package/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ ## 0.0.47 - 2026-08-05
4
+
5
+ ### Release readiness
6
+
7
+ - Added `npm run release:check` as the documented local release confidence gate. It currently delegates to `npm run test:all`, which runs Node full tests, template full tests, and `pack:check`.
8
+ - Added this changelog to summarize release highlights and publish-time verification notes.
9
+
10
+ ### Runtime and workflow hardening
11
+
12
+ - Hardened runtime context lifecycle, recovery observability, and fixed-subagent binding diagnostics.
13
+ - Added Batch execution inspect facts, stronger Host action result validation, and documented Batch recovery behavior.
14
+ - Normalized runtime-health and task-review issue facts so review output is easier to consume.
15
+
16
+ ### Host assets and integrations
17
+
18
+ - Centralized Host Asset Manifest sync policy helpers and added a Host capability matrix contract.
19
+ - Protected the ZCode multi-module scaffold boundary so plugin scaffolding does not vendor `.cowork-flow/` runtime files into module directories.
20
+
21
+ ### Party Mode
22
+
23
+ - Extracted Party Mode board storage, enriched final report facts, and aligned Host action fallbacks with the capability matrix boundary.
24
+ - Preserved the advisory-only contract: Party Mode does not advance task lifecycle state and does not replace implement/check review.
25
+
26
+ ### Sync, update, and support UX
27
+
28
+ - Added `sync --dry-run` readiness reports covering would-copy, protected skips, obsolete removals, Host asset refresh, pending recovery, and warnings.
29
+ - Added `update --dry-run` readiness output so CLI updates can be previewed without installing.
30
+ - Added the product support and troubleshooting playbook for task routing, runtime binding, Batch, Host asset drift, Party Mode, and release checks.
31
+
32
+ ### Verification
33
+
34
+ - Release gate: `npm run release:check`
35
+ - Formatting gate: `git diff --check`
36
+ - Windows note: POSIX-shell-only release tests may be reported as skipped when POSIX shell is unavailable; skips must remain visible and must not be reported as passes.
37
+
38
+ ### Publish notes
39
+
40
+ - This entry documents the current `0.0.47` release candidate. It does not tag, publish, or bump the package version by itself.
41
+ - Before publishing, confirm the version in `package.json`, `package-lock.json`, `template/.cowork-flow/.version`, and `template/.zcode/.zcode-plugin/plugin.json` matches the intended release.
package/README.md CHANGED
@@ -6,6 +6,26 @@
6
6
 
7
7
  **cowork-flow 不写代码,它帮你建流程。** 把 `template/` 复制到目标项目,立刻获得任务流、规格治理、开发计划和会话记录骨架。
8
8
 
9
+ ## 当前能力
10
+
11
+ | 领域 | 当前能力 |
12
+ |---|---|
13
+ | 任务流程 | `task next --json` 给出下一步 action,`task next --run` 只执行当前 action。 |
14
+ | 运行健康 | `doctor` 诊断 runtime、host assets、Skill replica 和任务 hygiene,不推进生命周期。 |
15
+ | Host 分发 | Host Asset Manifest 驱动 Codex / OpenCode / Claude Code / ZCode 资产和 obsolete 清理。 |
16
+ | 批处理与讨论 | Batch 发布 Host action;Party Mode 只输出 advisory final facts。 |
17
+ | 发布准备 | `release:check`、`CHANGELOG.md`、`pack:check` 固定发布前证据。 |
18
+
19
+ ## 阅读导航
20
+
21
+ | 想做什么 | 建议先看 |
22
+ |---|---|
23
+ | 快速安装或同步 | [快速开始](#快速开始)、[CLI 命令](#cli-命令) |
24
+ | 理解任务如何流转 | [任务流程](#任务流程) |
25
+ | 处理故障或漂移 | [支持与故障诊断](#支持与故障诊断) |
26
+ | 做发布前检查 | [发布](#发布)、[`CHANGELOG.md`](CHANGELOG.md) |
27
+ | 接入到自己项目 | [接入原则](#接入原则) |
28
+
9
29
  ## 适用 / 不适用
10
30
 
11
31
  | ✅ 适用 | ❌ 不适用 |
@@ -20,11 +40,20 @@
20
40
  # 初始化到新项目
21
41
  npx cowork-flow init ./my-project --platform codex --developer <your-name>
22
42
 
23
- # 安装 ZCode 插件
24
- cowork-flow install-zcode-plugin
43
+ # 预览同步计划(不写文件)
44
+ cowork-flow sync ./my-project --dry-run
25
45
 
26
46
  # 同步已初始化项目
27
- cowork-flow sync .
47
+ cowork-flow sync ./my-project
48
+
49
+ # 预览 CLI 更新(不安装)
50
+ cowork-flow update --dry-run
51
+
52
+ # 安装 ZCode 插件(可选)
53
+ cowork-flow install-zcode-plugin
54
+
55
+ # 维护者发布前检查
56
+ npm run release:check
28
57
  ```
29
58
 
30
59
  平台选项:`codex` / `opencode` / `claude-code` / `all`(逗号分隔)
@@ -44,20 +73,18 @@ template/
44
73
  ├── config.yaml # 项目配置
45
74
  ├── scripts/ # Python 运行时
46
75
  ├── spec/ # 规范文档(contracts / schemas / guides)
47
- ├── changes/ # 行为变更管理
48
76
  ├── plans/ # 实现计划
49
77
  ├── tasks/ # 任务目录
50
- └── workspace/ # 开发者工作区
51
78
  ```
52
79
 
53
80
  ## 架构与扩展点
54
81
 
55
- - **应用服务层**:任务创建、生命周期、归档、上下文、任务树和 runtime context 编排位于 `scripts/application/`;命令层只负责参数和输出适配。
56
- - **状态存储层**:`scripts/common/storage/` 提供显式 UTF-8、修订检查、操作日志和可恢复 Unit of Work;任务与会话写入不再直接散落在命令函数中。
82
+ - **服务层**:任务创建、生命周期、归档、上下文、任务树和 runtime context 编排位于 `scripts/services/`;命令层只负责参数和输出适配。
83
+ - **状态存储层**:`scripts/infra/storage/` 提供显式 UTF-8、修订检查、操作日志和可恢复 Unit of Work;任务与会话写入不再直接散落在命令函数中。
57
84
  - **Host Asset Manifest**:`spec/runtime/host-assets.json` 是宿主资产、平台识别、同步策略和 obsolete 迁移清单的权威来源。新增平台或资产时更新 Manifest 与 schema,不在 CLI 中新增硬编码集合。
58
85
  - **事务式 init/sync**:CLI 先构建不可变 Asset Plan,在同文件系统 staging 中校验 hash/权限,再按备份清单提交;失败时逆序回滚,`.cowork-flow/.version` 最后更新。
59
- - **共享 Hook 核心**:Codex 与 Claude Code Hook 只做宿主输入适配,工作流状态解析由 `scripts/common/host/workflow_state_hook.py` 统一实现。
60
- - **流程内核**:公开任务入口只有 `task next`;阶段动作由内核动作表推荐对应 Skill,硬门禁由 runtime gate 执行,不再分发独立流程中枢文件或 Skill 注册控制面。
86
+ - **共享 Hook 核心**:Codex 与 Claude Code Hook 只做宿主输入适配,工作流状态解析由 `scripts/adapters/host/workflow_state_hook.py` 统一实现。
87
+ - **流程内核**:公开任务入口只有 `task next`;kernel 只解析状态事实和 action,Skill 所有权由 manifest loader 注入,硬门禁由 runtime gate 执行,不再分发独立流程中枢文件或 Skill 注册控制面。
61
88
  - **Skill 自带脚本**:只服务单个 Skill 的控制器或辅助脚本放在 `template/skills/<skill-id>/scripts/`,由 `.cowork-flow/run` 薄分发;`scripts/` 内核只保留任务导航、生命周期、gate、host/runtime、存储和分发所需代码。
62
89
 
63
90
  ## Skills 分发机制
@@ -76,9 +103,9 @@ Skills 维护在 `template/skills/` 唯一源码,`init` / `sync` 时按目录
76
103
  | 命令 | 说明 |
77
104
  |---|---|
78
105
  | `init <path>` | 初始化项目模板 |
79
- | `sync <path>` | 同步已初始化项目的模板和技能 |
106
+ | `sync <path> [--dry-run]` | 同步已初始化项目的模板和技能 |
80
107
  | `install-zcode-plugin` | 安装 ZCode 插件到全局缓存 |
81
- | `update` | 升级 CLI 本身 |
108
+ | `update [--dry-run]` | 升级 CLI 本身 |
82
109
 
83
110
  ### init 选项
84
111
 
@@ -93,11 +120,17 @@ Skills 维护在 `template/skills/` 唯一源码,`init` / `sync` 时按目录
93
120
 
94
121
  - **自动识别**已安装 host 目录,只同步对应平台资产
95
122
  - **Skills** 从 `template/skills/` 按平台分发
96
- - **保护文件**:`config.yaml`、`spec/`(除 `workflow-state-templates.md`)、任务、计划、变更、workspace
123
+ - **保护文件**:`config.yaml`、`spec/`(除 `workflow-state-templates.md`)、任务、计划、变更
97
124
  - **正式版旧资产清理**:旧脚本位置、旧 adapter 资产和已废弃文件按 Host Asset Manifest 的 `obsoleteFiles` 清理;用户保护文件保持不变
98
125
  - **事务恢复**:上次未完成事务会在新一轮 sync 前恢复;事务元数据缺失或损坏时 fail-closed,不在未知状态上继续写入
126
+ - **Dry-run readiness**:`sync --dry-run` 只构建计划并输出 `readiness=<json>`,不写文件或事务状态;字段包含 `wouldCopy`、`wouldSkipProtected`、`wouldRemoveObsolete`、`hostAssetRefresh`、`pendingRecovery`、`warnings`
99
127
  - `--force` 整文件覆盖保护文件
100
128
 
129
+ ### update 行为
130
+
131
+ - 默认查询 npm latest,发现新版本时执行 `npm install -g cowork-flow@latest`
132
+ - `--dry-run` 只输出当前版本、最新版本和 `readiness=<json>`,其中 `update.wouldInstall` 表示是否会执行全局安装,不调用安装命令
133
+
101
134
  ## ZCode 插件
102
135
 
103
136
  ```bash
@@ -125,11 +158,30 @@ ZCode 插件只安装 hook、skills、agents 和轻量说明文件;`.cowork-fl
125
158
  ## 任务流程
126
159
 
127
160
  ```
128
- changes → brainstorming → read spec → plan → tasks → implement → check → complete
161
+ brainstorming → read spec/guides → plan → tasks → implement → check → complete
129
162
  ```
130
163
 
131
164
  `./.cowork-flow/run task next` 是唯一公开任务流程入口。它读取当前状态,输出下一步 action、激活 Skill、runtime gate、blocker,以及可执行时的 `task next --run` 命令。
132
165
 
166
+ `task next --json` 负责判定下一步;`task next --run` 只执行当前 action。任务主线如下:
167
+
168
+ ```mermaid
169
+ flowchart TD
170
+ A["无活动任务\nstatus: no_task"] -->|"create_task\ntask next --run --title ..."| B["规划中\nstatus: planning"]
171
+ B -->|"补齐 decision-anchor.md\n和 implement.jsonl"| B
172
+ B -->|"start_task\ntask next <dir> --run"| C["实现中\nstatus: in_progress"]
173
+ C -->|"request_review\ntask next <dir> --run --intent review"| D["检查/Review\nstatus: review"]
174
+ D -->|"apply_review_fix"| C
175
+ D -->|"complete_task\ntask next <dir> --run --intent review"| E["已完成\nstatus: completed"]
176
+ E -->|"archive_task\ntask next <dir> --run --intent archive"| F["已归档\narchive/YYYY-MM/"]
177
+
178
+ C -.-> G["Batch runtime\n发布一个 Host action\n不暴露独立 batch 子命令"]
179
+ C -.-> H["runtime-health\n诊断/命令提示\n不推进生命周期"]
180
+ C -.-> I["Party Mode\nadvisory final facts\n不替代 implement/check"]
181
+ ```
182
+
183
+ 说明:Batch、doctor、Party Mode 都是任务主线旁路能力;它们可以提供事实、建议或下一步 Host action,但不能绕过 `task next` 的生命周期判定。
184
+
133
185
  | action | 入口 | status 结果 |
134
186
  |---|---|---|
135
187
  | `create_task` | `task next --run --title "<title>" --slug <name> --assignee <name>` | `planning` |
@@ -154,10 +206,6 @@ Batch 使用任务图和持久化 Host action:运行 `task next <parent-task>
154
206
  ./.cowork-flow/run task next --list
155
207
  ./.cowork-flow/run task next <dir> --validate
156
208
 
157
- # 变更
158
- ./.cowork-flow/run change create <slug>
159
- ./.cowork-flow/run change validate <slug>
160
-
161
209
  # 任务
162
210
  ./.cowork-flow/run task next --run --title "<title>" --slug <name> --assignee <name>
163
211
  ./.cowork-flow/run task next <dir> --run
@@ -168,11 +216,24 @@ Batch 使用任务图和持久化 Host action:运行 `task next <parent-task>
168
216
  ./.cowork-flow/run subagent init --role implement --agent-type cowork-implement --execution-task-dir <dir> --title "<title>"
169
217
  ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
170
218
 
171
- # Session
172
- ./.cowork-flow/run get-context --mode record
173
- ./.cowork-flow/run add-session --title "<title>" --commit "<ref>" --summary "<summary>"
174
219
  ```
175
220
 
221
+ ## 支持与故障诊断
222
+
223
+ 按症状先定位到现有入口,再根据输出中的 action 或 blocker 处理;不要把 README 当作流程权威,实际可执行下一步始终以 `./.cowork-flow/run task next --json` 为准。
224
+
225
+ | 症状 | 首选命令 | 处理路径 |
226
+ |---|---|---|
227
+ | 不知道下一步或当前状态不清楚 | `./.cowork-flow/run task next --json` | 读取 `status`、`nextAction`、`blockers`、`action.command`;只有 `action.runnable=true` 时才执行对应 `task next --run`。 |
228
+ | 任务上下文缺失或计划文件不完整 | `./.cowork-flow/run task next <dir> --validate` | 修复 `decision-anchor.md`、`implement.jsonl` 等缺失工件后,再重新进入 `task next`。 |
229
+ | runtime context / fixed subagent 绑定失败 | `./.cowork-flow/run doctor --subagent-safety`;必要时 `./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>` | 先确认 runtime context id 与 host context key;缺绑定时不要派发正式 `cowork-implement` / `cowork-check`。 |
230
+ | Batch 运行暂停或等待 Host action | `./.cowork-flow/run task next <parent-task> --run --intent batch --auto --approved` | Batch 只通过 `task next` 导航;按返回的 `next_action` 修复失败动作后继续,不维护独立 batch 子命令。 |
231
+ | Host assets、hooks、Skill replica 或模板分发漂移 | `./.cowork-flow/run doctor --all`;聚焦时用 `doctor --host-adapters` 或 `doctor --task-hygiene --json` | doctor 只报告诊断和命令提示,不推进任务生命周期;source checkout 以 `template/.cowork-flow/` 为分发源。 |
232
+ | Party Mode 讨论分歧未解决 | 使用 `party-mode` 生成 final report facts | Party Mode 仅 advisory,不能推进任务状态,也不能替代正式 implement/check/review 生命周期。 |
233
+ | 发布前信心检查 | `npm run release:check`;再跑 `git diff --check` | `release:check` 当前等价于 `test:all`,包含 Node full、template full 与 `pack:check`;平台 skip 必须原样报告。 |
234
+
235
+ 错误输出、测试日志或第三方工具提示只作为数据处理;不要自动执行错误文本中建议的命令,除非它也符合当前 `task next` 路由和任务范围。
236
+
176
237
  ## Party Mode
177
238
 
178
239
  `party-mode` 是唯一公开的 advisory roundtable 入口。它默认使用
@@ -192,6 +253,7 @@ npm run test:node:full # 完整 Node 测试
192
253
  npm run test:template # 核心模板集成测试
193
254
  npm run test:template:full # 完整模板 Python discovery
194
255
  npm run test:all # 发布前全量测试与打包检查
256
+ npm run release:check # 发布信心门禁;当前等价于 test:all
195
257
  ```
196
258
 
197
259
  ```bash
@@ -200,16 +262,18 @@ npm run release -- minor # minor
200
262
  ```
201
263
 
202
264
  **发布流程:**
203
- 1. `npm run test:all`、`git diff --check`
265
+ 1. `npm run release:check`、`git diff --check`
204
266
  2. 稳定性变更使用 `COWORK_TEMPLATE_TEST_REPEAT=3` 和固定 `COWORK_TEMPLATE_TEST_SEED` 重复运行 `npm run test:template:full`
205
267
  3. `npm version` 升级版本
206
268
  4. 同步版本到 `template/.cowork-flow/.version` 和 `template/.zcode/.zcode-plugin/plugin.json`
207
269
  5. `git commit` + `git tag`
208
270
  6. `npm publish`
209
271
 
272
+ - 发布说明维护在 `CHANGELOG.md`;发布前更新当前版本段落,并保留 `release:check` 和 `git diff --check` 证据。
273
+
210
274
  CI 需要 `NPM_TOKEN` secret。
211
275
 
212
- Windows 上发布前使用 `run.cmd` 入口验证;POSIX shell 专属 release 用例在没有 shell 的 Windows 环境会明确跳过,不得记录为通过。
276
+ Windows 上发布前使用 `run.cmd` 入口验证;POSIX shell 专属 release 用例在没有 shell 的 Windows 环境会明确跳过,不得记录为通过。`release:check` 会保留这些 skip 报告,不把 skip 伪装成 pass。
213
277
 
214
278
  ## 接入原则
215
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "description": "CLI for installing and maintaining cowork-flow collaboration templates.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,7 @@
12
12
  "template",
13
13
  "template/.zcode",
14
14
  "README.md",
15
+ "CHANGELOG.md",
15
16
  "!template/**/__pycache__/**",
16
17
  "!template/**/*.pyc"
17
18
  ],
@@ -24,6 +25,7 @@
24
25
  "test:template:full": "node scripts/run-template-tests.js --suite full",
25
26
  "pack:check": "node scripts/pack-check.js",
26
27
  "test:all": "npm run test:node:full && npm run test:template:full && npm run pack:check",
28
+ "release:check": "npm run test:all",
27
29
  "release": "sh scripts/release.sh"
28
30
  },
29
31
  "engines": {
@@ -127,72 +127,10 @@ async function resolvePlatforms(options, selectPlatforms) {
127
127
  return parsePlatformSelection(selected);
128
128
  }
129
129
 
130
- function todayIsoDate() {
131
- return new Date().toISOString().slice(0, 10);
132
- }
133
-
134
- function initialJournalContent(name) {
135
- return `# Development Journal - ${name} (Part 1)
136
-
137
- > AI development session journal
138
- > Start date: ${todayIsoDate()}
139
-
140
- ---
141
-
142
- `;
143
- }
144
-
145
- function initialIndexContent(name) {
146
- return `# Workspace Index - ${name}
147
-
148
- > Tracks AI development session records.
149
-
150
- ---
151
-
152
- ## Current Status
153
-
154
- <!-- @@@auto:current-status -->
155
- - **Current file**: \`journal-1.md\`
156
- - **Total Sessions**: 0
157
- - **Last Active**: -
158
- <!-- @@@/auto:current-status -->
159
-
160
- ---
161
-
162
- ## Active Documents
163
-
164
- <!-- @@@auto:active-documents -->
165
- | File | Lines | Status |
166
- |------|------|------|
167
- | \`journal-1.md\` | ~0 | Current |
168
- <!-- @@@/auto:active-documents -->
169
-
170
- ---
171
-
172
- ## Session History
173
-
174
- <!-- @@@auto:session-history -->
175
- | # | Date | Title | Commit |
176
- |---|------|------|------|
177
- <!-- @@@/auto:session-history -->
178
-
179
- ---
180
-
181
- ## Notes
182
-
183
- - Sessions are appended to the journal file
184
- - A new journal file is created automatically after the current file exceeds 2000 lines
185
- - Use \`add_session.py\` to record sessions
186
- - New records use English text; existing records can remain as they are
187
- `;
188
- }
189
130
 
190
131
  async function buildDeveloperActions(target, developer) {
191
132
  const workflowDir = join(target, '.cowork-flow');
192
133
  const developerFile = join(workflowDir, '.developer');
193
- const workspaceDir = join(workflowDir, 'workspace', developer.name);
194
- const journalFile = join(workspaceDir, 'journal-1.md');
195
- const indexFile = join(workspaceDir, 'index.md');
196
134
  const actions = [];
197
135
 
198
136
  if (!developer.existing) {
@@ -206,26 +144,6 @@ async function buildDeveloperActions(target, developer) {
206
144
  });
207
145
  }
208
146
 
209
- if (!await pathExists(journalFile)) {
210
- actions.push({
211
- action: 'create',
212
- source: null,
213
- destination: journalFile,
214
- relativePath: `.cowork-flow/workspace/${developer.name}/journal-1.md`,
215
- content: initialJournalContent(developer.name),
216
- targetExists: false
217
- });
218
- }
219
- if (!await pathExists(indexFile)) {
220
- actions.push({
221
- action: 'create',
222
- source: null,
223
- destination: indexFile,
224
- relativePath: `.cowork-flow/workspace/${developer.name}/index.md`,
225
- content: initialIndexContent(developer.name),
226
- targetExists: false
227
- });
228
- }
229
147
  return actions;
230
148
  }
231
149
 
@@ -260,7 +178,6 @@ export async function runInitWithOptions(
260
178
  io.writeOut(`dry-run preserve-existing=.cowork-flow/.developer for developer ${developer.name}\n`);
261
179
  } else if (developer.name) {
262
180
  io.writeOut(`dry-run would-create=.cowork-flow/.developer for developer ${developer.name}\n`);
263
- io.writeOut(`dry-run would-create=.cowork-flow/workspace/${developer.name}/\n`);
264
181
  }
265
182
  io.writeOut('Next: update AGENTS.md and .cowork-flow/config.yaml for this project.\n');
266
183
  return 0;
@@ -2,8 +2,10 @@ import { resolve } from 'node:path';
2
2
 
3
3
  import {
4
4
  applyPlan,
5
+ buildReadinessReport,
5
6
  buildSyncPlan,
6
7
  detectInstalledPlatforms,
8
+ formatReadinessReport,
7
9
  summarizePlan
8
10
  } from '../lib/copy-template.js';
9
11
  import { readPackageInfo } from '../lib/package-info.js';
@@ -37,6 +39,10 @@ export async function runSync(args, { io, fileSystem }) {
37
39
 
38
40
  await applyPlan(plan, { dryRun: options.dryRun, fileSystem });
39
41
  io.writeOut(summarizePlan(plan, options.dryRun));
42
+ if (options.dryRun) {
43
+ const readiness = await buildReadinessReport(plan, { fileSystem });
44
+ io.writeOut(formatReadinessReport(readiness));
45
+ }
40
46
  io.writeOut(`Platforms: ${platforms.length > 0 ? formatPlatformList(platforms) : 'none'}\n`);
41
47
  return 0;
42
48
  }
@@ -5,10 +5,37 @@ import {
5
5
  runGlobalInstall
6
6
  } from '../lib/package-info.js';
7
7
 
8
- function validateUpdateArgs(args) {
9
- if (args.length > 0) {
10
- throw new Error(`Unknown update option: ${args[0]}`);
8
+ function parseUpdateArgs(args) {
9
+ const options = { dryRun: false };
10
+ for (const arg of args) {
11
+ if (arg === '--dry-run') {
12
+ options.dryRun = true;
13
+ } else {
14
+ throw new Error(`Unknown update option: ${arg}`);
15
+ }
11
16
  }
17
+ return options;
18
+ }
19
+
20
+ function buildUpdateReadinessReport({ current, latest, installCommand, wouldInstall, warnings = [] }) {
21
+ return {
22
+ wouldCopy: [],
23
+ wouldSkipProtected: [],
24
+ wouldRemoveObsolete: [],
25
+ hostAssetRefresh: [],
26
+ pendingRecovery: [],
27
+ warnings,
28
+ update: {
29
+ current,
30
+ latest,
31
+ wouldInstall,
32
+ installCommand
33
+ }
34
+ };
35
+ }
36
+
37
+ function formatReadinessReport(report) {
38
+ return `readiness=${JSON.stringify(report)}\n`;
12
39
  }
13
40
 
14
41
  export async function runUpdate(args, deps = {}) {
@@ -16,7 +43,7 @@ export async function runUpdate(args, deps = {}) {
16
43
  const readInfo = deps.readPackageInfo ?? readPackageInfo;
17
44
  const fetchLatest = deps.fetchLatestVersion ?? fetchLatestVersion;
18
45
  const installGlobal = deps.runGlobalInstall ?? runGlobalInstall;
19
- validateUpdateArgs(args);
46
+ const options = parseUpdateArgs(args);
20
47
  const packageInfo = await readInfo();
21
48
  const current = packageInfo.version;
22
49
  const installCommand = 'npm install -g cowork-flow@latest';
@@ -25,8 +52,18 @@ export async function runUpdate(args, deps = {}) {
25
52
  try {
26
53
  latest = await fetchLatest('cowork-flow');
27
54
  } catch (error) {
28
- io.writeErr(`${error instanceof Error ? error.message : String(error)}\n`);
55
+ const warning = error instanceof Error ? error.message : String(error);
56
+ io.writeErr(`${warning}\n`);
29
57
  io.writeOut(`current=${current}\n`);
58
+ if (options.dryRun) {
59
+ io.writeOut(formatReadinessReport(buildUpdateReadinessReport({
60
+ current,
61
+ latest,
62
+ installCommand,
63
+ wouldInstall: false,
64
+ warnings: [warning]
65
+ })));
66
+ }
30
67
  io.writeOut(`Unable to query npm latest. Run: ${installCommand}\n`);
31
68
  return 0;
32
69
  }
@@ -34,7 +71,23 @@ export async function runUpdate(args, deps = {}) {
34
71
  io.writeOut(`current=${current}\n`);
35
72
  io.writeOut(`latest=${latest}\n`);
36
73
 
37
- if (compareVersions(current, latest) >= 0) {
74
+ const wouldInstall = compareVersions(current, latest) < 0;
75
+ if (options.dryRun) {
76
+ io.writeOut(formatReadinessReport(buildUpdateReadinessReport({
77
+ current,
78
+ latest,
79
+ installCommand,
80
+ wouldInstall
81
+ })));
82
+ if (!wouldInstall) {
83
+ io.writeOut('cowork-flow is already up to date.\n');
84
+ } else {
85
+ io.writeOut(`dry-run would-run: ${installCommand}\n`);
86
+ }
87
+ return 0;
88
+ }
89
+
90
+ if (!wouldInstall) {
38
91
  io.writeOut('cowork-flow is already up to date.\n');
39
92
  return 0;
40
93
  }
@@ -4,9 +4,8 @@ import { join, relative } from 'node:path';
4
4
 
5
5
  import { createAssetPlan, planActions } from './asset-plan.js';
6
6
  import { hostRegistry } from './host-assets.js';
7
- import { applyAssetPlan } from './plan-applier.js';
7
+ import { applyAssetPlan, inspectAssetTransactions } from './plan-applier.js';
8
8
  import { templateRoot } from './paths.js';
9
- import { shouldIncludeForPlatforms, skillDestinationForPlatform } from './platforms.js';
10
9
 
11
10
  async function pathExists(path) {
12
11
  try {
@@ -91,7 +90,7 @@ async function appendSkillFileActions(actions, {
91
90
  for (const skill of await listSkillDirs()) {
92
91
  const skillFiles = await listSkillFiles(skill);
93
92
  for (const platform of platforms) {
94
- const destBase = skillDestinationForPlatform(platform);
93
+ const destBase = hostRegistry.skillDestination(platform);
95
94
  if (!destBase) continue;
96
95
  for (const skillFile of skillFiles) {
97
96
  const destination = join(
@@ -124,7 +123,7 @@ export async function buildInitPlan(targetDir, options = {}) {
124
123
  const seen = new Set();
125
124
 
126
125
  for (const file of files) {
127
- if (!shouldIncludeForPlatforms(file, platforms)) {
126
+ if (!hostRegistry.shouldInclude(file, platforms)) {
128
127
  continue;
129
128
  }
130
129
 
@@ -169,43 +168,9 @@ export async function buildInitPlan(targetDir, options = {}) {
169
168
  });
170
169
  }
171
170
 
172
- const PROTECTED_SYNC_FILES = new Set(
173
- hostRegistry.syncPolicy.protectedFiles
174
- );
175
- const PROTECTED_SYNC_PREFIXES = hostRegistry.syncPolicy.protectedPrefixes;
176
- const SAFE_SYNC_FILES = new Set(hostRegistry.syncPolicy.safeFiles);
177
- const SAFE_SYNC_PREFIXES = [
178
- ...hostRegistry.syncPolicy.safePrefixes,
179
- ...hostRegistry.assetPrefixes,
180
- ...hostRegistry.skillTargets.map((target) => `${target}/`)
181
- ];
182
- const MANAGED_BLOCK_FILES = new Set(
183
- hostRegistry.syncPolicy.managedBlockFiles
184
- );
185
- const OBSOLETE_SYNC_FILES = new Set(
186
- hostRegistry.syncPolicy.obsoleteFiles
187
- );
188
-
189
171
  const COWORK_FLOW_START = '<!-- COWORK-FLOW:START -->';
190
172
  const COWORK_FLOW_END = '<!-- COWORK-FLOW:END -->';
191
173
 
192
- function isProtectedSyncFile(relativePath) {
193
- const templatePath = toTemplatePath(relativePath);
194
- if (SAFE_SYNC_FILES.has(templatePath)) {
195
- return false;
196
- }
197
- return PROTECTED_SYNC_FILES.has(templatePath)
198
- || PROTECTED_SYNC_PREFIXES.some((prefix) => templatePath.startsWith(prefix));
199
- }
200
-
201
- function isSafeSyncFile(relativePath) {
202
- const templatePath = toTemplatePath(relativePath);
203
- return SAFE_SYNC_FILES.has(templatePath)
204
- || SAFE_SYNC_PREFIXES.some((prefix) => templatePath.startsWith(prefix))
205
- || hostRegistry.isKnownPlatformAsset(templatePath)
206
- || templatePath.endsWith('/.gitkeep');
207
- }
208
-
209
174
  function isCoveredByDeletedParent(relativePath, deletedParents) {
210
175
  return deletedParents.some((parent) => relativePath.startsWith(`${parent}/`));
211
176
  }
@@ -276,7 +241,7 @@ export async function buildSyncPlan(targetDir, options = {}) {
276
241
  const seen = new Set();
277
242
 
278
243
  for (const file of files) {
279
- if (!shouldIncludeForPlatforms(file, platforms)) {
244
+ if (!hostRegistry.shouldInclude(file, platforms)) {
280
245
  continue;
281
246
  }
282
247
 
@@ -289,13 +254,13 @@ export async function buildSyncPlan(targetDir, options = {}) {
289
254
 
290
255
  const source = join(templateRoot, file);
291
256
  const exists = await pathExists(destination);
292
- if (MANAGED_BLOCK_FILES.has(toTemplatePath(file))) {
257
+ if (hostRegistry.isManagedBlockFile(file)) {
293
258
  actions.push(await buildManagedBlockSyncAction({ source, destination, exists, options, relativePath: file }));
294
259
  continue;
295
260
  }
296
261
 
297
- const protectedFile = isProtectedSyncFile(file) && !options.force && exists;
298
- const safeFile = isSafeSyncFile(file);
262
+ const protectedFile = hostRegistry.isProtectedSyncFile(file) && !options.force && exists;
263
+ const safeFile = hostRegistry.isSafeSyncFile(file);
299
264
 
300
265
  if (protectedFile) {
301
266
  actions.push({ action: 'protected', source, destination, relativePath: file });
@@ -315,13 +280,7 @@ export async function buildSyncPlan(targetDir, options = {}) {
315
280
  await appendSkillFileActions(actions, { targetDir, platforms, seen, sync: true });
316
281
 
317
282
  const deletedObsoleteParents = [];
318
- const obsoleteFiles = [...OBSOLETE_SYNC_FILES].sort((left, right) => {
319
- if (left.length !== right.length) {
320
- return left.length - right.length;
321
- }
322
- return left.localeCompare(right);
323
- });
324
- for (const file of obsoleteFiles) {
283
+ for (const file of hostRegistry.obsoleteSyncFiles()) {
325
284
  if (isCoveredByDeletedParent(file, deletedObsoleteParents)) {
326
285
  continue;
327
286
  }
@@ -355,6 +314,68 @@ export async function detectInstalledPlatforms(targetDir) {
355
314
  return hostRegistry.detectInstalledPlatforms(targetDir, pathExists);
356
315
  }
357
316
 
317
+ function normalizeReportPath(value) {
318
+ return String(value).replaceAll('\\', '/');
319
+ }
320
+
321
+ function hostAssetOwners(relativePath) {
322
+ const normalized = normalizeReportPath(relativePath);
323
+ const owners = new Set(hostRegistry.assetOwners(normalized));
324
+ for (const platform of hostRegistry.platforms) {
325
+ const skillTarget = platform.skillTarget ? normalizeReportPath(platform.skillTarget) : null;
326
+ if (skillTarget && normalized.startsWith(`${skillTarget}/`)) {
327
+ owners.add(platform.id);
328
+ }
329
+ }
330
+ return [...owners];
331
+ }
332
+
333
+ function readinessAction(action) {
334
+ const item = { path: action.relativePath, action: action.action };
335
+ const platforms = hostAssetOwners(action.relativePath);
336
+ if (platforms.length > 0) {
337
+ item.platforms = platforms;
338
+ }
339
+ return item;
340
+ }
341
+
342
+ function recoveryWarning(transaction) {
343
+ if (transaction.error) {
344
+ return `pending recovery metadata unreadable at ${transaction.path}: ${transaction.error}`;
345
+ }
346
+ if (transaction.status === 'committed') {
347
+ return `stale committed transaction cleanup pending at ${transaction.path}`;
348
+ }
349
+ return `pending ${transaction.status} transaction recovery at ${transaction.path}`;
350
+ }
351
+
352
+ export async function buildReadinessReport(plan, options = {}) {
353
+ const actions = planActions(plan);
354
+ const pendingRecovery = await inspectAssetTransactions(plan.targetDir, {
355
+ fileSystem: options.fileSystem
356
+ });
357
+ return {
358
+ wouldCopy: actions
359
+ .filter((action) => action.action === 'create' || action.action === 'update')
360
+ .map(readinessAction),
361
+ wouldSkipProtected: actions
362
+ .filter((action) => action.action === 'protected')
363
+ .map(readinessAction),
364
+ wouldRemoveObsolete: actions
365
+ .filter((action) => action.action === 'delete')
366
+ .map(readinessAction),
367
+ hostAssetRefresh: actions
368
+ .filter((action) => action.action !== 'skip' && hostAssetOwners(action.relativePath).length > 0)
369
+ .map(readinessAction),
370
+ pendingRecovery,
371
+ warnings: pendingRecovery.map(recoveryWarning)
372
+ };
373
+ }
374
+
375
+ export function formatReadinessReport(report) {
376
+ return `readiness=${JSON.stringify(report)}\n`;
377
+ }
378
+
358
379
  export function summarizePlan(plan, dryRun = false) {
359
380
  const actions = planActions(plan);
360
381
  const counts = { create: 0, update: 0, skip: 0, protected: 0, delete: 0 };