cowork-flow 0.0.47 → 0.0.49

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 (90) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +102 -23
  3. package/package.json +8 -3
  4. package/src/cli.js +6 -0
  5. package/src/commands/init.js +0 -83
  6. package/src/commands/source-refresh.js +40 -0
  7. package/src/commands/sync.js +6 -0
  8. package/src/commands/update.js +59 -6
  9. package/src/lib/copy-template.js +200 -50
  10. package/src/lib/host-assets.js +367 -64
  11. package/src/lib/plan-applier.js +47 -0
  12. package/template/.claude/hooks/inject-workflow-state.py +7 -0
  13. package/template/.codex/hooks/inject-workflow-state.py +7 -0
  14. package/template/.codex/hooks.json +1 -1
  15. package/template/.cowork-flow/.version +1 -1
  16. package/template/.cowork-flow/config.yaml +0 -11
  17. package/template/.cowork-flow/scripts/adapters/cli/init_developer.py +0 -1
  18. package/template/.cowork-flow/scripts/adapters/cli/subagent.py +7 -4
  19. package/template/.cowork-flow/scripts/adapters/cli/task.py +8 -484
  20. package/template/.cowork-flow/scripts/adapters/cli/task_archive_commands.py +15 -134
  21. package/template/.cowork-flow/scripts/adapters/cli/task_context_commands.py +7 -1
  22. package/template/.cowork-flow/scripts/adapters/cli/task_lifecycle_commands.py +388 -0
  23. package/template/.cowork-flow/scripts/adapters/cli/task_navigation.py +163 -2
  24. package/template/.cowork-flow/scripts/adapters/git/git_context.py +16 -193
  25. package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +170 -84
  26. package/template/.cowork-flow/scripts/infra/config.py +0 -17
  27. package/template/.cowork-flow/scripts/infra/developer_profile.py +0 -95
  28. package/template/.cowork-flow/scripts/infra/paths.py +0 -79
  29. package/template/.cowork-flow/scripts/infra/skill_manifest.py +23 -3
  30. package/template/.cowork-flow/scripts/infra/storage/operation_log.py +40 -0
  31. package/template/.cowork-flow/scripts/infra/storage/state_store.py +356 -1
  32. package/template/.cowork-flow/scripts/kernel/workflow_route.py +15 -15
  33. package/template/.cowork-flow/scripts/run.py +0 -5
  34. package/template/.cowork-flow/scripts/services/context_discovery.py +156 -0
  35. package/template/.cowork-flow/scripts/services/context_jsonl.py +119 -0
  36. package/template/.cowork-flow/scripts/services/context_paths.py +186 -0
  37. package/template/.cowork-flow/scripts/services/lifecycle_checks.py +186 -69
  38. package/template/.cowork-flow/scripts/services/lifecycle_policy.py +128 -0
  39. package/template/.cowork-flow/scripts/services/plan_binding.py +146 -0
  40. package/template/.cowork-flow/scripts/services/readiness.py +3 -170
  41. package/template/.cowork-flow/scripts/services/task_archive.py +115 -24
  42. package/template/.cowork-flow/scripts/services/task_context.py +103 -365
  43. package/template/.cowork-flow/scripts/services/task_creation.py +40 -5
  44. package/template/.cowork-flow/scripts/services/task_lifecycle.py +155 -18
  45. package/template/.cowork-flow/scripts/services/task_routing.py +80 -67
  46. package/template/.cowork-flow/scripts/services/task_utils.py +0 -146
  47. package/template/.cowork-flow/scripts/services/workflow_runtime.py +1 -1
  48. package/template/.cowork-flow/spec/contracts/capabilities.md +23 -0
  49. package/template/.cowork-flow/spec/contracts/decision-anchor.md +2 -2
  50. package/template/.cowork-flow/spec/contracts/error-output-as-data.md +8 -0
  51. package/template/.cowork-flow/spec/contracts/index.md +1 -0
  52. package/template/.cowork-flow/spec/contracts/party-mode-v2-board.md +20 -0
  53. package/template/.cowork-flow/spec/contracts/plan-binding.md +50 -0
  54. package/template/.cowork-flow/spec/contracts/skill-owned-actions.md +31 -7
  55. package/template/.cowork-flow/spec/guides/index.md +3 -1
  56. package/template/.cowork-flow/spec/index.md +5 -4
  57. package/template/.cowork-flow/spec/references/definition-of-done.md +2 -3
  58. package/template/.cowork-flow/spec/references/orchestration-patterns.md +1 -1
  59. package/template/.cowork-flow/spec/runtime/contract-registry.json +14 -0
  60. package/template/.cowork-flow/spec/runtime/host-assets.json +73 -3
  61. package/template/.cowork-flow/spec/runtime/index.md +1 -1
  62. package/template/.cowork-flow/spec/schemas/host-assets.schema.json +150 -8
  63. package/template/.zcode/.zcode-plugin/plugin.json +1 -1
  64. package/template/skills/batch-execution/SKILL.md +37 -3
  65. package/template/skills/batch-execution/scripts/batch_action.py +4 -0
  66. package/template/skills/batch-execution/scripts/batch_execution.py +120 -499
  67. package/template/skills/batch-execution/scripts/batch_recovery.py +94 -0
  68. package/template/skills/batch-execution/scripts/batch_state_machine.py +201 -0
  69. package/template/skills/batch-execution/scripts/batch_verification.py +326 -0
  70. package/template/skills/brainstorming/SKILL.md +8 -7
  71. package/template/skills/cowork-flow/SKILL.md +3 -0
  72. package/template/skills/party-mode/scripts/party_action_contract.py +113 -0
  73. package/template/skills/party-mode/scripts/party_actions.py +95 -0
  74. package/template/skills/party-mode/scripts/party_board_store.py +148 -0
  75. package/template/skills/party-mode/scripts/party_mode_v2.py +345 -317
  76. package/template/skills/party-mode/scripts/party_reports.py +177 -0
  77. package/template/skills/party-mode/scripts/party_state_machine.py +189 -0
  78. package/template/skills/runtime-health/SKILL.md +14 -2
  79. package/template/skills/runtime-health/scripts/doctor.py +278 -41
  80. package/template/skills/task-planning/SKILL.md +105 -61
  81. package/template/skills/task-review/SKILL.md +4 -4
  82. package/template/skills/task-review/scripts/review_check.py +277 -20
  83. package/template/skills/test-first/SKILL.md +18 -3
  84. package/template/skills/test-first/manifest.json +8 -4
  85. package/template/.cowork-flow/changes/archive/.gitkeep +0 -1
  86. package/template/.cowork-flow/scripts/adapters/cli/add_session.py +0 -465
  87. package/template/.cowork-flow/scripts/adapters/cli/change.py +0 -412
  88. package/template/.cowork-flow/workspace/index.md +0 -102
  89. package/template/.zcode/scaffold/AGENTS.md +0 -145
  90. 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,26 @@
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
+ # 维护者:预览本仓库 source checkout live runtime / Skill replica 刷新
50
+ npm run source:refresh:dry-run
51
+
52
+ # 维护者:刷新 ignored root .cowork-flow、.agents/skills、.claude/skills
53
+ npm run source:refresh
54
+
55
+ # 预览 CLI 更新(不安装)
56
+ cowork-flow update --dry-run
57
+
58
+ # 安装 ZCode 插件(可选)
59
+ cowork-flow install-zcode-plugin
60
+
61
+ # 维护者发布前检查
62
+ npm run release:check
28
63
  ```
29
64
 
30
65
  平台选项:`codex` / `opencode` / `claude-code` / `all`(逗号分隔)
@@ -44,20 +79,18 @@ template/
44
79
  ├── config.yaml # 项目配置
45
80
  ├── scripts/ # Python 运行时
46
81
  ├── spec/ # 规范文档(contracts / schemas / guides)
47
- ├── changes/ # 行为变更管理
48
82
  ├── plans/ # 实现计划
49
83
  ├── tasks/ # 任务目录
50
- └── workspace/ # 开发者工作区
51
84
  ```
52
85
 
53
86
  ## 架构与扩展点
54
87
 
55
- - **应用服务层**:任务创建、生命周期、归档、上下文、任务树和 runtime context 编排位于 `scripts/application/`;命令层只负责参数和输出适配。
56
- - **状态存储层**:`scripts/common/storage/` 提供显式 UTF-8、修订检查、操作日志和可恢复 Unit of Work;任务与会话写入不再直接散落在命令函数中。
88
+ - **服务层**:任务创建、生命周期、归档、上下文、任务树和 runtime context 编排位于 `scripts/services/`;命令层只负责参数和输出适配。
89
+ - **状态存储层**:`scripts/infra/storage/` 提供显式 UTF-8、修订检查、操作日志和可恢复 Unit of Work;任务与会话写入不再直接散落在命令函数中。
57
90
  - **Host Asset Manifest**:`spec/runtime/host-assets.json` 是宿主资产、平台识别、同步策略和 obsolete 迁移清单的权威来源。新增平台或资产时更新 Manifest 与 schema,不在 CLI 中新增硬编码集合。
58
91
  - **事务式 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 注册控制面。
92
+ - **共享 Hook 核心**:Codex 与 Claude Code Hook 只做宿主输入适配,工作流状态解析由 `scripts/adapters/host/workflow_state_hook.py` 统一实现。
93
+ - **流程内核**:公开任务入口只有 `task next`;kernel 只解析状态事实和 action,Skill 所有权由 manifest loader 注入,硬门禁由 runtime gate 执行,不再分发独立流程中枢文件或 Skill 注册控制面。
61
94
  - **Skill 自带脚本**:只服务单个 Skill 的控制器或辅助脚本放在 `template/skills/<skill-id>/scripts/`,由 `.cowork-flow/run` 薄分发;`scripts/` 内核只保留任务导航、生命周期、gate、host/runtime、存储和分发所需代码。
62
95
 
63
96
  ## Skills 分发机制
@@ -76,9 +109,10 @@ Skills 维护在 `template/skills/` 唯一源码,`init` / `sync` 时按目录
76
109
  | 命令 | 说明 |
77
110
  |---|---|
78
111
  | `init <path>` | 初始化项目模板 |
79
- | `sync <path>` | 同步已初始化项目的模板和技能 |
112
+ | `sync <path> [--dry-run]` | 同步已初始化项目的模板和技能 |
113
+ | `source-refresh [path] [--dry-run]` | 维护者刷新 source checkout 的 ignored live runtime 与 Host Skill replica |
80
114
  | `install-zcode-plugin` | 安装 ZCode 插件到全局缓存 |
81
- | `update` | 升级 CLI 本身 |
115
+ | `update [--dry-run]` | 升级 CLI 本身 |
82
116
 
83
117
  ### init 选项
84
118
 
@@ -93,11 +127,24 @@ Skills 维护在 `template/skills/` 唯一源码,`init` / `sync` 时按目录
93
127
 
94
128
  - **自动识别**已安装 host 目录,只同步对应平台资产
95
129
  - **Skills** 从 `template/skills/` 按平台分发
96
- - **保护文件**:`config.yaml`、`spec/`(除 `workflow-state-templates.md`)、任务、计划、变更、workspace
130
+ - **保护文件**:`config.yaml`、`spec/`(除 `workflow-state-templates.md`)、任务、计划、变更
97
131
  - **正式版旧资产清理**:旧脚本位置、旧 adapter 资产和已废弃文件按 Host Asset Manifest 的 `obsoleteFiles` 清理;用户保护文件保持不变
98
132
  - **事务恢复**:上次未完成事务会在新一轮 sync 前恢复;事务元数据缺失或损坏时 fail-closed,不在未知状态上继续写入
133
+ - **Dry-run readiness**:`sync --dry-run` 只构建计划并输出 `readiness=<json>`,不写文件或事务状态;字段包含 `wouldCopy`、`wouldSkipProtected`、`wouldRemoveObsolete`、`hostAssetRefresh`、`pendingRecovery`、`warnings`
99
134
  - `--force` 整文件覆盖保护文件
100
135
 
136
+ ### source-refresh 行为
137
+
138
+ - **用途**:仅面向 cowork-flow 源码 checkout 维护者;以 `template/.cowork-flow/` 和 `template/skills/` 为唯一 tracked 分发源,刷新 ignored 的根 `.cowork-flow/`、`.agents/skills/`、`.claude/skills/` 受管副本
139
+ - **保护边界**:不覆盖 `.cowork-flow/tasks/`、`.cowork-flow/plans/`、`.cowork-flow/.runtime/`、`.cowork-flow/.developer`、`.cowork-flow/config.yaml` 和自定义 Skill
140
+ - **事务语义**:复用 Asset Plan / plan applier,失败时回滚;`.cowork-flow/.version` 保持 version-last,并复制 template 版本文件的原始内容
141
+ - **常用命令**:`npm run source:refresh:dry-run` 只预览;`npm run source:refresh` 应用后再运行 `./.cowork-flow/run doctor --all --json`
142
+
143
+ ### update 行为
144
+
145
+ - 默认查询 npm latest,发现新版本时执行 `npm install -g cowork-flow@latest`
146
+ - `--dry-run` 只输出当前版本、最新版本和 `readiness=<json>`,其中 `update.wouldInstall` 表示是否会执行全局安装,不调用安装命令
147
+
101
148
  ## ZCode 插件
102
149
 
103
150
  ```bash
@@ -125,11 +172,30 @@ ZCode 插件只安装 hook、skills、agents 和轻量说明文件;`.cowork-fl
125
172
  ## 任务流程
126
173
 
127
174
  ```
128
- changes → brainstorming → read spec → plan → tasks → implement → check → complete
175
+ brainstorming → read spec/guides → plan → tasks → implement → check → complete
129
176
  ```
130
177
 
131
178
  `./.cowork-flow/run task next` 是唯一公开任务流程入口。它读取当前状态,输出下一步 action、激活 Skill、runtime gate、blocker,以及可执行时的 `task next --run` 命令。
132
179
 
180
+ `task next --json` 负责判定下一步;`task next --run` 只执行当前 action。任务主线如下:
181
+
182
+ ```mermaid
183
+ flowchart TD
184
+ A["无活动任务\nstatus: no_task"] -->|"create_task\ntask next --run --title ..."| B["规划中\nstatus: planning"]
185
+ B -->|"补齐 decision-anchor.md\n和 implement.jsonl"| B
186
+ B -->|"start_task\ntask next <dir> --run"| C["实现中\nstatus: in_progress"]
187
+ C -->|"request_review\ntask next <dir> --run --intent review"| D["检查/Review\nstatus: review"]
188
+ D -->|"apply_review_fix"| C
189
+ D -->|"complete_task\ntask next <dir> --run --intent review"| E["已完成\nstatus: completed"]
190
+ E -->|"archive_task\ntask next <dir> --run --intent archive"| F["已归档\narchive/YYYY-MM/"]
191
+
192
+ C -.-> G["Batch runtime\n发布一个 Host action\n不暴露独立 batch 子命令"]
193
+ C -.-> H["runtime-health\n诊断/命令提示\n不推进生命周期"]
194
+ C -.-> I["Party Mode\nadvisory final facts\n不替代 implement/check"]
195
+ ```
196
+
197
+ 说明:Batch、doctor、Party Mode 都是任务主线旁路能力;它们可以提供事实、建议或下一步 Host action,但不能绕过 `task next` 的生命周期判定。
198
+
133
199
  | action | 入口 | status 结果 |
134
200
  |---|---|---|
135
201
  | `create_task` | `task next --run --title "<title>" --slug <name> --assignee <name>` | `planning` |
@@ -154,10 +220,6 @@ Batch 使用任务图和持久化 Host action:运行 `task next <parent-task>
154
220
  ./.cowork-flow/run task next --list
155
221
  ./.cowork-flow/run task next <dir> --validate
156
222
 
157
- # 变更
158
- ./.cowork-flow/run change create <slug>
159
- ./.cowork-flow/run change validate <slug>
160
-
161
223
  # 任务
162
224
  ./.cowork-flow/run task next --run --title "<title>" --slug <name> --assignee <name>
163
225
  ./.cowork-flow/run task next <dir> --run
@@ -168,11 +230,24 @@ Batch 使用任务图和持久化 Host action:运行 `task next <parent-task>
168
230
  ./.cowork-flow/run subagent init --role implement --agent-type cowork-implement --execution-task-dir <dir> --title "<title>"
169
231
  ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
170
232
 
171
- # Session
172
- ./.cowork-flow/run get-context --mode record
173
- ./.cowork-flow/run add-session --title "<title>" --commit "<ref>" --summary "<summary>"
174
233
  ```
175
234
 
235
+ ## 支持与故障诊断
236
+
237
+ 按症状先定位到现有入口,再根据输出中的 action 或 blocker 处理;不要把 README 当作流程权威,实际可执行下一步始终以 `./.cowork-flow/run task next --json` 为准。
238
+
239
+ | 症状 | 首选命令 | 处理路径 |
240
+ |---|---|---|
241
+ | 不知道下一步或当前状态不清楚 | `./.cowork-flow/run task next --json` | 读取 `status`、`nextAction`、`blockers`、`action.command`;只有 `action.runnable=true` 时才执行对应 `task next --run`。 |
242
+ | 任务上下文缺失或计划文件不完整 | `./.cowork-flow/run task next <dir> --validate` | 修复 `decision-anchor.md`、`implement.jsonl` 等缺失工件后,再重新进入 `task next`。 |
243
+ | 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`。 |
244
+ | Batch 运行暂停或等待 Host action | `./.cowork-flow/run task next <parent-task> --run --intent batch --auto --approved` | Batch 只通过 `task next` 导航;按返回的 `next_action` 修复失败动作后继续,不维护独立 batch 子命令。 |
245
+ | Host assets、hooks、Skill replica 或模板分发漂移 | `./.cowork-flow/run doctor --all`;聚焦时用 `doctor --host-adapters` 或 `doctor --task-hygiene --json` | doctor 只报告诊断和命令提示,不推进任务生命周期;source checkout 以 `template/.cowork-flow/` 为分发源。 |
246
+ | Party Mode 讨论分歧未解决 | 使用 `party-mode` 生成 final report facts | Party Mode 仅 advisory,不能推进任务状态,也不能替代正式 implement/check/review 生命周期。 |
247
+ | 发布前信心检查 | `npm run release:check`;再跑 `git diff --check` | `release:check` 当前等价于 `test:all`,包含 Node full、template full 与 `pack:check`;平台 skip 必须原样报告。 |
248
+
249
+ 错误输出、测试日志或第三方工具提示只作为数据处理;不要自动执行错误文本中建议的命令,除非它也符合当前 `task next` 路由和任务范围。
250
+
176
251
  ## Party Mode
177
252
 
178
253
  `party-mode` 是唯一公开的 advisory roundtable 入口。它默认使用
@@ -190,8 +265,10 @@ npm run test:fast # 快速 Node 测试,等价于 npm test
190
265
  npm run test:integration # init/sync 关键集成路径
191
266
  npm run test:node:full # 完整 Node 测试
192
267
  npm run test:template # 核心模板集成测试
268
+ npm run test:windows:core # Windows core 发布信心门禁(Node/Python/init/sync/pack/模板)
193
269
  npm run test:template:full # 完整模板 Python discovery
194
270
  npm run test:all # 发布前全量测试与打包检查
271
+ npm run release:check # 发布信心门禁;当前等价于 test:all
195
272
  ```
196
273
 
197
274
  ```bash
@@ -200,16 +277,18 @@ npm run release -- minor # minor
200
277
  ```
201
278
 
202
279
  **发布流程:**
203
- 1. `npm run test:all`、`git diff --check`
280
+ 1. `npm run release:check`、`git diff --check`
204
281
  2. 稳定性变更使用 `COWORK_TEMPLATE_TEST_REPEAT=3` 和固定 `COWORK_TEMPLATE_TEST_SEED` 重复运行 `npm run test:template:full`
205
282
  3. `npm version` 升级版本
206
283
  4. 同步版本到 `template/.cowork-flow/.version` 和 `template/.zcode/.zcode-plugin/plugin.json`
207
284
  5. `git commit` + `git tag`
208
285
  6. `npm publish`
209
286
 
210
- CI 需要 `NPM_TOKEN` secret。
287
+ - 发布说明维护在 `CHANGELOG.md`;发布前更新当前版本段落,并保留 `release:check` 和 `git diff --check` 证据。
288
+
289
+ CI 的 PR 同时运行 Ubuntu core 与 Windows core;发布工作流要求 Ubuntu 与 Windows full verification 均成功后才执行 publish。测试 job 不接触 `NPM_TOKEN`,仅 publish job 使用该 secret。
211
290
 
212
- Windows 上发布前使用 `run.cmd` 入口验证;POSIX shell 专属 release 用例在没有 shell 的 Windows 环境会明确跳过,不得记录为通过。
291
+ Windows 上发布前使用 `run.cmd` 入口验证;POSIX shell 专属 release 用例在没有 shell 的 Windows 环境会明确跳过,不得记录为通过。`release:check` 会保留这些 skip 报告,不把 skip 伪装成 pass。
213
292
 
214
293
  ## 接入原则
215
294
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "description": "CLI for installing and maintaining cowork-flow collaboration templates.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,19 +12,24 @@
12
12
  "template",
13
13
  "template/.zcode",
14
14
  "README.md",
15
+ "CHANGELOG.md",
15
16
  "!template/**/__pycache__/**",
16
17
  "!template/**/*.pyc"
17
18
  ],
18
19
  "scripts": {
19
20
  "test": "npm run test:fast",
20
- "test:fast": "node --test test/asset-plan.test.js test/cli.test.js test/host-assets.test.js test/opencode-plugin.test.js test/template-runner.test.js test/update.test.js test/zcode-plugin.test.js",
21
+ "test:fast": "node --test test/asset-plan.test.js test/cli.test.js test/host-assets.test.js test/opencode-plugin.test.js test/package.test.js test/template-runner.test.js test/update.test.js test/zcode-plugin.test.js",
21
22
  "test:integration": "node --test --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",
22
23
  "test:node:full": "node --test",
23
24
  "test:template": "node scripts/run-template-tests.js --suite core",
24
25
  "test:template:full": "node scripts/run-template-tests.js --suite full",
25
26
  "pack:check": "node scripts/pack-check.js",
27
+ "source:refresh:dry-run": "node bin/cowork-flow.js source-refresh --dry-run",
28
+ "source:refresh": "node bin/cowork-flow.js source-refresh",
26
29
  "test:all": "npm run test:node:full && npm run test:template:full && npm run pack:check",
27
- "release": "sh scripts/release.sh"
30
+ "release:check": "npm run test:all",
31
+ "release": "sh scripts/release.sh",
32
+ "test:windows:core": "npm run test:fast && npm run test:integration && npm run pack:check && npm run test:template"
28
33
  },
29
34
  "engines": {
30
35
  "node": ">=20"
package/src/cli.js CHANGED
@@ -4,6 +4,7 @@ import { createInterface } from 'node:readline/promises';
4
4
 
5
5
  import { runInit } from './commands/init.js';
6
6
  import { runInstallZCodePlugin } from './commands/install-zcode-plugin.js';
7
+ import { runSourceRefresh } from './commands/source-refresh.js';
7
8
  import { runSync } from './commands/sync.js';
8
9
  import { runUpdate } from './commands/update.js';
9
10
  import { readPackageInfo } from './lib/package-info.js';
@@ -15,6 +16,7 @@ Usage:
15
16
  cowork-flow install-zcode-plugin [--dry-run] [--force] [--prune-old]
16
17
  cowork-flow update
17
18
  cowork-flow sync [target] [--dry-run] [--force]
19
+ cowork-flow source-refresh [target] [--dry-run]
18
20
  cowork-flow --version
19
21
  cowork-flow --help
20
22
  `;
@@ -173,6 +175,10 @@ export async function main(argv = process.argv.slice(2), options = {}) {
173
175
  return await runSync(args, { io });
174
176
  }
175
177
 
178
+ if (command === 'source-refresh') {
179
+ return await runSourceRefresh(args, { io });
180
+ }
181
+
176
182
  if (command === 'update') {
177
183
  return await runUpdate(args, { io });
178
184
  }
@@ -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;
@@ -0,0 +1,40 @@
1
+ import { resolve } from 'node:path';
2
+
3
+ import {
4
+ applyPlan,
5
+ buildReadinessReport,
6
+ buildSourceCheckoutRefreshPlan,
7
+ formatReadinessReport,
8
+ summarizePlan
9
+ } from '../lib/copy-template.js';
10
+
11
+ function parseSourceRefreshArgs(args) {
12
+ const options = { dryRun: false, target: process.cwd() };
13
+ for (const arg of args) {
14
+ if (arg === '--dry-run') {
15
+ options.dryRun = true;
16
+ } else if (arg.startsWith('--')) {
17
+ throw new Error(`Unknown source-refresh option: ${arg}`);
18
+ } else {
19
+ options.target = resolve(arg);
20
+ }
21
+ }
22
+ return options;
23
+ }
24
+
25
+ export async function runSourceRefresh(args, { io, fileSystem } = {}) {
26
+ const options = parseSourceRefreshArgs(args);
27
+ const plan = await buildSourceCheckoutRefreshPlan(options.target);
28
+
29
+ await applyPlan(plan, { dryRun: options.dryRun, fileSystem });
30
+ io.writeOut(summarizePlan(plan, options.dryRun));
31
+ if (options.dryRun) {
32
+ const readiness = await buildReadinessReport(plan, { fileSystem });
33
+ io.writeOut(formatReadinessReport(readiness));
34
+ }
35
+ io.writeOut('Source checkout refresh: template/.cowork-flow -> .cowork-flow; template/skills -> host Skill replicas\n');
36
+ if (!options.dryRun) {
37
+ io.writeOut('Next check: ./.cowork-flow/run doctor --all --json\n');
38
+ }
39
+ return 0;
40
+ }
@@ -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
  }