cowork-flow 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/README.en.md +34 -18
  3. package/README.md +8 -5
  4. package/docs/architecture.en.md +95 -0
  5. package/docs/architecture.md +7 -3
  6. package/docs/direction.en.md +71 -0
  7. package/docs/direction.md +6 -1
  8. package/docs/hosts.en.md +299 -0
  9. package/docs/hosts.md +3 -1
  10. package/docs/index.en.md +30 -0
  11. package/docs/index.md +2 -0
  12. package/docs/release.en.md +108 -0
  13. package/docs/release.md +2 -0
  14. package/package.json +2 -2
  15. package/presets/claude-code/.claude-plugin/plugin.json +1 -1
  16. package/presets/claude-code/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  17. package/presets/codex/.codex-plugin/plugin.json +1 -1
  18. package/presets/codex/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  19. package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
  20. package/presets/kimi-code/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  21. package/presets/opencode/cowork-flow/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  22. package/presets/qoder/.qoder-plugin/plugin.json +1 -1
  23. package/presets/qoder/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  24. package/presets/zcode/.zcode-plugin/plugin.json +1 -1
  25. package/presets/zcode/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  26. package/src/commands/init.js +129 -2
  27. package/src/commands/registry.js +3 -1
  28. package/src/commands/source-refresh.js +5 -1
  29. package/src/commands/sync.js +3 -0
  30. package/src/lib/copy-template.js +23 -5
  31. package/src/lib/host-assets.js +117 -2
  32. package/src/lib/language.js +162 -0
  33. package/template/.cowork-flow/.version +1 -1
  34. package/template/.cowork-flow/config.yaml +8 -0
  35. package/template/.cowork-flow/scripts/adapters/cli/task_create_command.py +5 -3
  36. package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +71 -2
  37. package/template/.cowork-flow/scripts/infra/config.py +85 -0
  38. package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +104 -0
  39. package/template/.cowork-flow/scripts/services/fact_view.py +21 -15
  40. package/template/.cowork-flow/scripts/services/task_context.py +13 -7
  41. package/template/.cowork-flow/scripts/services/task_creation.py +72 -30
  42. package/template/.cowork-flow/scripts/services/task_gate_profiles.py +7 -24
  43. package/template/.cowork-flow/spec/contracts/context-injection.md +5 -4
  44. package/template/.cowork-flow/spec/contracts/decision-anchor.md +21 -14
  45. package/template/.cowork-flow/spec/contracts/plan-binding.md +2 -1
  46. package/template/.cowork-flow/spec/index.md +26 -26
  47. package/template/.cowork-flow/spec/references/definition-of-done.md +26 -26
  48. package/template/.cowork-flow/spec/references/index.md +16 -16
  49. package/template/.cowork-flow/spec/references/orchestration-patterns.md +71 -71
  50. package/template/.cowork-flow/spec/references/security-checklist.md +37 -37
  51. package/template/.cowork-flow/spec/references/testing-checklist.md +32 -32
  52. package/template/.cowork-flow/spec/runtime/host-assets.json +23 -4
  53. package/template/.cowork-flow/spec/runtime/index.md +10 -12
  54. package/template/.cowork-flow/spec/schemas/host-assets.schema.json +31 -0
  55. package/template/.cowork-flow/spec/schemas/index.md +5 -5
  56. package/template/.cowork-flow/templates/plan-template.md +91 -0
  57. package/template/locales/en-US/.cowork-flow/spec/contracts/decision-anchor.md +160 -0
  58. package/template/locales/en-US/.cowork-flow/templates/plan-template.md +91 -0
  59. package/template/skills/runtime-health/scripts/doctor.py +110 -0
  60. package/template/skills/task-planning/SKILL.md +19 -92
package/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@
4
4
 
5
5
  ### Added
6
6
 
7
+ ## [2.4.0] - 2026-10-23
8
+
9
+ ### Added
10
+
11
+ - **`docs/` 五份文档提供并列英文版**:`docs/index.en.md`、`architecture.en.md`、`hosts.en.md`、`release.en.md`、`direction.en.md` 为对应中文文档的完整英文翻译,中英页面顶部互链,`README.en.md` 的文档入口改指英文版。新增文档门禁(`test/docs.test.js`):中英文件成对存在、标题层级序列一致、中英索引各自链接本语言全部文档、双向语言链接与相对链接可解析;任一英文版缺失或标题结构漂移都会失败。`docs/` 本就在 npm 发布清单内,英文版随包分发,不引入文档框架。
12
+ - **安装语言选项与任务/计划产物本地化**:`cwf project init --language zh-CN|en-US`(别名 `zh` / `en`,默认 `zh-CN`)把选择写入 `.cowork-flow/config.yaml` 的 `language`;`decision-anchor.md` 新增英文合同变体,计划结构抽为可分发的 `.cowork-flow/templates/plan-template.md` 并提供英文版本。`init`、`sync` 与 `dev refresh` 按 config 语言选择 locale 源,目标路径不变,`locales/` 不进入项目。任务创建始终生成对应语言的 anchor 骨架,`**Goal:**` / `**目标:**` / 表格行三种计划目标均可提取;中文、英文、混合标题的 anchor 都能被 fact view、启动前置检查、strict gate 与证据完成门禁读取。
13
+ - **doctor 语言一致性检查**:`CONFIG-LANGUAGE-001` 报告非法 `language`(error),`LANGUAGE-DRIFT-001` 报告已安装合同/计划模板与配置语言不一致(warning,提示 `cwf project sync`);缺少 `language` 键或旧安装尚未分发 `plan-template.md` 时保持静默。
14
+
15
+ ### Changed
16
+
17
+ - **`config.yaml` 成为强制保护文件**:Host Asset Manifest 新增 `syncPolicy.forceProtectedFiles`,`.cowork-flow/config.yaml` 首次创建后不再被 `init --force` 或 `sync --force` 覆盖;切换语言需编辑该文件后运行 `sync`。已有配置中的 `language` 优先于 `--language`,冲突时输出警告但不改写配置。
18
+
19
+ - **分发 spec 说明文档英文化(第一步)**:`spec/index.md`、`spec/runtime/index.md`、`spec/schemas/index.md` 与 `spec/references/**` 的说明文字改为英文,保留文件列表、相对链接、DoD 的 G5 标记与协作模式约束编号。`decision-anchor.md` 的六个解析标题、`workflow-state-templates.md` 的注入块、`backend/frontend/guides` 与 `template/AGENTS.md` 本步不动,前两项待双语解析迁移。**可达性**:三个索引随 `project sync` 更新;`references/` 仍受项目同步保护,已装项目不会自动收到英文副本,需手动刷新或重新安装。
20
+
21
+ - **下游 `project sync` 开始同步框架 spec 资产**:`syncPolicy.protectedPrefixes` 从整个 `.cowork-flow/spec/` 收窄为 `spec/backend/`、`spec/frontend/`、`spec/guides/`、`spec/references/`,让 `spec/contracts/`、`spec/runtime/`(含 `contract-registry.json`、`host-assets.json`、`scope-rules.json`)、`spec/schemas/` 与 `spec/index.md` 随普通 `project sync` 更新——下游不再出现“脚本已升级、契约与宿主 manifest 仍停在安装代际”的混合状态,新增契约、宿主与 schema 能到达已装项目。**迁移**:登记在 `obsoleteFiles` 的过期框架 spec(`spec-checks.md`、`entry-contract.md`、`rules.json`、`skill-registry.json` 及对应 schema)会在下一次 sync 被自动删除,不再要求手动清理;本地修改过框架契约或 `scope-rules.json` 的项目会丢失这些改动,项目定制应写入四个受保护的 spec 目录、`AGENTS.md`、`config.yaml` 或项目自有 Skill。`dev refresh`(源码检出刷新)仍镜像整个 `template/.cowork-flow/spec/`:源码检出里的项目自有 spec 目录也是框架模板内容,因此刷新时不受下游保护前缀限制;任务、计划、`config.yaml`、`.developer` 与 `.runtime` 保持受保护。
22
+
7
23
  ## [2.3.0] - 2026-10-21
8
24
 
9
25
  ### Added
@@ -407,7 +423,8 @@
407
423
 
408
424
  此版本未保留本地条目正文,详情见 [GitHub Release](https://github.com/fishlikewater/cowork-flow/releases/tag/v0.0.47)。
409
425
 
410
- [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.3.0...HEAD
426
+ [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.4.0...HEAD
427
+ [2.4.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.3.0...v2.4.0
411
428
  [2.3.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.2.0...v2.3.0
412
429
  [2.2.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.1.0...v2.2.0
413
430
  [2.1.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.0.0...v2.1.0
package/README.en.md CHANGED
@@ -16,7 +16,7 @@ Supports Codex, Claude Code, OpenCode, ZCode, Qoder, Kimi Code, and DeepSeek Har
16
16
  - Keeps requirements, decisions, plans, and the allowed change scope inside the project.
17
17
  - Makes the assistant read the current task before working, instead of continuing from memory.
18
18
  - Separates implementation from checking, so a problem sends the work back to implementation.
19
- - Protects custom configuration, specs, tasks, and plans in an existing project.
19
+ - Protects custom configuration, project-owned specs, tasks, and plans in an existing project.
20
20
 
21
21
  cowork-flow is not tied to a tech stack and does not rewrite an existing project with a
22
22
  scaffold. It only adds a collaboration convention and the files that go with it.
@@ -56,9 +56,15 @@ cwf project init --host codex --developer alice --dry-run
56
56
  Drop `--dry-run` once the list looks right:
57
57
 
58
58
  ```bash
59
- cwf project init --host codex --developer alice
59
+ cwf project init --host codex --developer alice --language en-US
60
60
  ```
61
61
 
62
+ Without `--language` the default is `zh-CN`; an interactive terminal asks, and a
63
+ non-interactive run uses the default. The choice is written to
64
+ `.cowork-flow/config.yaml` and affects only task and plan artifacts
65
+ (`.cowork-flow/spec/contracts/decision-anchor.md` and
66
+ `.cowork-flow/templates/plan-template.md`).
67
+
62
68
  Replace `codex` with the host you use:
63
69
 
64
70
  `codex`, `claude-code`, `opencode`, `zcode`, `qoder`, `kimi-code`, `dsh`.
@@ -76,7 +82,9 @@ not touch application code. An existing `.developer` is never overwritten; on fi
76
82
  initialization an explicit `--developer` wins over `git config user.name`. With no git
77
83
  identity, an interactive terminal prompts and a non-interactive run fails (`--dry-run`
78
84
  only reports `would-skip`). `--platform` / `--platforms` remain accepted aliases of
79
- `--host`. On an existing project, always run `--dry-run` first.
85
+ `--host`. An existing `.cowork-flow/config.yaml` owns its `language`, even under
86
+ `--force`; edit that file and run `cwf project sync .` to switch languages. On an
87
+ existing project, always run `--dry-run` first.
80
88
 
81
89
  ### 3. Finish host setup
82
90
 
@@ -87,7 +95,7 @@ DeepSeek Harness, and Kimi Code also need a machine-level component:
87
95
  cwf host add <host>
88
96
  ```
89
97
 
90
- See [host integration](docs/hosts.md) for each host's exact command, restart
98
+ See [host integration](docs/hosts.en.md) for each host's exact command, restart
91
99
  requirements, and special cases.
92
100
 
93
101
  ### 4. Start inside the host
@@ -120,10 +128,16 @@ cwf project sync . --dry-run
120
128
  cwf project sync .
121
129
  ```
122
130
 
123
- `project sync` only updates files cowork-flow manages. Existing configuration, `spec/`,
124
- tasks, and plans are kept by default; **retired-asset cleanup** deletes obsolete
125
- cowork-flow files listed in the release manifest and touches nothing else. For upgrading
126
- machine-level host components, see [host integration](docs/hosts.md).
131
+ `project sync` only updates files cowork-flow manages. Existing configuration,
132
+ `spec/backend|frontend|guides|references`, tasks, and plans are kept by default;
133
+ framework-managed `spec/contracts|runtime|schemas` and `spec/index.md` follow the
134
+ sync. `.cowork-flow/config.yaml` is project configuration and is never overwritten by
135
+ `sync --force`. Sync reads its `language` and distributes only that language's
136
+ `decision-anchor.md` contract and `.cowork-flow/templates/plan-template.md`; tasks and plans follow that
137
+ language by default, and an explicit user request may override it.
138
+ **Retired-asset cleanup** deletes obsolete cowork-flow files listed in the
139
+ release manifest and touches nothing else. For upgrading machine-level host
140
+ components, see [host integration](docs/hosts.en.md).
127
141
 
128
142
  ## Troubleshooting
129
143
 
@@ -135,15 +149,15 @@ machine-level host components, see [host integration](docs/hosts.md).
135
149
  | Skills, plugins, hooks, or project files look wrong | Run `./.cowork-flow/run doctor --all` |
136
150
  | You are unsure how to write a command or flag | Run `cwf --help` or `cwf <group> <command> --help` |
137
151
 
138
- For host-specific problems, start with [host integration](docs/hosts.md). To understand
139
- how the project is organized, see [architecture and extension](docs/architecture.md).
152
+ For host-specific problems, start with [host integration](docs/hosts.en.md). To understand
153
+ how the project is organized, see [architecture and extension](docs/architecture.en.md).
140
154
 
141
155
  <details>
142
156
  <summary>Command reference</summary>
143
157
 
144
158
  | Command | Purpose |
145
159
  |---|---|
146
- | `cwf project init [target] --host <host> [--developer <name>] [--dry-run] [--force]` | Initialize a project |
160
+ | `cwf project init [target] --host <host> [--developer <name>] [--language zh-CN|en-US] [--dry-run] [--force]` | Initialize a project |
147
161
  | `cwf project sync [target] [--dry-run] [--force]` | Update the cowork-flow-managed files in a project |
148
162
  | `cwf host add <host> [--component <name>] [--dry-run] [--force] [--prune-old] [--uninstall]` | Install a machine-level host component |
149
163
  | `cwf host remove <host> [--component <name>] [--dry-run] [--force]` | Remove a machine-level host component |
@@ -172,16 +186,18 @@ Old command names still work; use the new names in new scripts.
172
186
 
173
187
  ## Documentation
174
188
 
175
- The detailed documentation is written in Chinese.
189
+ The detailed documentation is available in English and Chinese; each page links to its
190
+ counterpart at the top.
176
191
 
177
192
  | Document | Contents |
178
193
  |---|---|
179
- | [Documentation index](docs/index.md) | Entry point for every document |
180
- | [Architecture and extension](docs/architecture.md) | How the project files are organized, how the sync policy and protected files work |
181
- | [Host integration](docs/hosts.md) | Install, restart, troubleshoot, and uninstall for each host |
182
- | [Release and maintenance](docs/release.md) | Tests, CI, and maintainer commands |
183
- | [Contributing](CONTRIBUTING.md) | Local setup, commit conventions, and PR checks |
184
- | [Changelog](CHANGELOG.md) | What changed in each version |
194
+ | [Documentation index](docs/index.en.md) | Entry point for every document |
195
+ | [Architecture and extension](docs/architecture.en.md) | How the project files are organized, how the sync policy and protected files work |
196
+ | [Host integration](docs/hosts.en.md) | Install, restart, troubleshoot, and uninstall for each host |
197
+ | [Release and maintenance](docs/release.en.md) | Tests, CI, and maintainer commands |
198
+ | [Direction](docs/direction.en.md) | Positioning, settled trade-offs, version line, and open items |
199
+ | [Contributing](CONTRIBUTING.md) | Local setup, commit conventions, and PR checks (Chinese) |
200
+ | [Changelog](CHANGELOG.md) | What changed in each version (Chinese) |
185
201
 
186
202
  ## License
187
203
 
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  - 把需求、决定、计划和允许修改的范围留在项目里。
14
14
  - 让助手每次工作前先读取当前任务,不凭印象继续。
15
15
  - 把实现和检查分开,发现问题后再回到实现阶段修正。
16
- - 在已有项目里保护自定义配置、规格、任务和计划。
16
+ - 在已有项目里保护自定义配置、项目自有规格、任务和计划。
17
17
 
18
18
  cowork-flow 不绑定技术栈,也不会用脚手架改写现有项目。它只在项目中加入一层协作约定和配套文件。
19
19
 
@@ -50,16 +50,18 @@ cwf project init --host codex --developer alice --dry-run
50
50
  确认无误后去掉 `--dry-run`:
51
51
 
52
52
  ```bash
53
- cwf project init --host codex --developer alice
53
+ cwf project init --host codex --developer alice --language en-US
54
54
  ```
55
55
 
56
+ 不传 `--language` 时默认 `zh-CN`;交互终端会询问,非交互环境使用默认值。该选择写入 `.cowork-flow/config.yaml`,只影响任务和计划产物(`.cowork-flow/spec/contracts/decision-anchor.md` 与 `.cowork-flow/templates/plan-template.md`)。
57
+
56
58
  把 `codex` 换成你正在使用的宿主:
57
59
 
58
60
  `codex`、`claude-code`、`opencode`、`zcode`、`qoder`、`kimi-code`、`dsh`。
59
61
 
60
62
  命令默认在当前目录初始化;新项目把目标目录作为位置参数传入,例如 `cwf project init ./my-project --host codex`,再进入该目录。省略 `--host` 时,会先按项目里已有的宿主标记(如 `.codex/`、`.claude/`)自动判定;没有标记的交互终端会让你选择,非交互环境则需要显式传入。只有确实会在多个宿主中使用时,才用 `--host all`。
61
63
 
62
- 初始化会加入 `AGENTS.md`、`.cowork-flow/` 和对应的宿主文件,不会修改业务代码。已有 `.developer` 不会被覆盖;首次初始化时显式 `--developer` 优先于 `git config user.name`。git 也没有身份时,交互终端会提示,非交互环境报错(`--dry-run` 只报告 `would-skip`,不失败)。`--platform` / `--platforms` 是 `--host` 的兼容别名。已有项目建议始终先跑 `--dry-run`。
64
+ 初始化会加入 `AGENTS.md`、`.cowork-flow/` 和对应的宿主文件,不会修改业务代码。已有 `.developer` 不会被覆盖;首次初始化时显式 `--developer` 优先于 `git config user.name`。git 也没有身份时,交互终端会提示,非交互环境报错(`--dry-run` 只报告 `would-skip`,不失败)。`--platform` / `--platforms` 是 `--host` 的兼容别名。已有 `.cowork-flow/config.yaml` 时其中的 `language` 优先,`--force` 也不会重写它;要切换语言请直接编辑该文件后运行 `cwf project sync .`。已有项目建议始终先跑 `--dry-run`。
63
65
 
64
66
  ### 3. 完成宿主设置
65
67
 
@@ -98,7 +100,7 @@ cwf project sync . --dry-run
98
100
  cwf project sync .
99
101
  ```
100
102
 
101
- `project sync` 只更新 cowork-flow 管理的文件。已有配置、`spec/`、任务和计划默认保留;**正式版旧资产清理** 会按发布清单删除已废弃的 cowork-flow 文件,不触碰其它内容。机器级宿主组件的升级方式见 [宿主接入](docs/hosts.md)。
103
+ `project sync` 只更新 cowork-flow 管理的文件。已有配置、`spec/backend|frontend|guides|references`、任务和计划默认保留;框架维护的 `spec/contracts|runtime|schemas` 与 `spec/index.md` 随 sync 更新。`.cowork-flow/config.yaml` 是项目配置,`sync --force` 也不会覆盖它。sync 会读取其中的 `language`,只分发对应语言的 `decision-anchor.md` 合同与 `.cowork-flow/templates/plan-template.md`;任务和计划默认跟随该语言,用户明确要求时可以覆盖。**正式版旧资产清理** 会按发布清单删除已废弃的 cowork-flow 文件,不触碰其它内容。机器级宿主组件的升级方式见 [宿主接入](docs/hosts.md)。
102
104
 
103
105
  ## 遇到问题
104
106
 
@@ -117,7 +119,7 @@ cwf project sync .
117
119
 
118
120
  | 命令 | 用途 |
119
121
  |---|---|
120
- | `cwf project init [target] --host <host> [--developer <name>] [--dry-run] [--force]` | 初始化项目 |
122
+ | `cwf project init [target] --host <host> [--developer <name>] [--language zh-CN|en-US] [--dry-run] [--force]` | 初始化项目 |
121
123
  | `cwf project sync [target] [--dry-run] [--force]` | 更新项目内由 cowork-flow 管理的文件 |
122
124
  | `cwf host add <host> [--component <name>] [--dry-run] [--force] [--prune-old] [--uninstall]` | 安装机器级宿主组件 |
123
125
  | `cwf host remove <host> [--component <name>] [--dry-run] [--force]` | 卸载机器级宿主组件 |
@@ -152,6 +154,7 @@ cwf project sync .
152
154
  | [架构与扩展](docs/architecture.md) | 项目文件如何组织、同步策略与受保护文件 |
153
155
  | [宿主接入](docs/hosts.md) | 各宿主的安装、重启、排障和卸载方式 |
154
156
  | [发布与维护](docs/release.md) | 测试、CI 和维护者命令 |
157
+ | [方向规划](docs/direction.md) | 项目定位、已定取舍、版本主线与待决项 |
155
158
  | [参与开发](CONTRIBUTING.md) | 本地开发、提交和 PR 检查 |
156
159
  | [更新日志](CHANGELOG.md) | 版本变化 |
157
160
 
@@ -0,0 +1,95 @@
1
+ # Architecture and extension
2
+
3
+ [中文](architecture.md) | English
4
+
5
+ This document is for developers maintaining cowork-flow. It explains how the project files are layered, where host differences live, and which boundaries to respect when adding capabilities. If you only want to install and use cowork-flow, see [README](../README.en.md); to troubleshoot a specific host, see [Host integration](hosts.en.md).
6
+
7
+ ## Three boundaries to remember first
8
+
9
+ 1. `template/` only holds files that get written into a user project.
10
+ 2. `presets/` only holds machine-level payloads that `cwf host add` installs into host configuration directories.
11
+ 3. Host differences are declared by `template/.cowork-flow/spec/runtime/host-assets.json` and are not written into the shared runtime.
12
+
13
+ ## Repository responsibilities
14
+
15
+ | Location | Responsibility |
16
+ |---|---|
17
+ | `template/` | The single distribution source for `project init` and `project sync` |
18
+ | `presets/` | Payload source for plugins, presets, and machine-level hooks |
19
+ | `src/` | Node CLI: command registration, installers, and file sync plans |
20
+ | `scripts/` | Build, test, packaging, and release scripts |
21
+ | `test/` | Node tests and helper modules |
22
+ | `tests/` | Python repository tests and fixtures |
23
+ | `docs/` | User, host, architecture, and maintenance documentation |
24
+ | `.agents/`, `.claude/`, `.codex/`, `.cowork-flow/` | Runtime copies for this source repository; not a distribution source |
25
+
26
+ ### Project distribution source
27
+
28
+ The content in `template/` that directly relates to a user project includes:
29
+
30
+ - `AGENTS.md`: the project collaboration entry point.
31
+ - `template/skills/`: the single source for project Skills, distributed per host by `init` / `sync`.
32
+ - `template/.cowork-flow/`: project configuration, the Python runtime, specs, plans, and tasks.
33
+ - `template/.<host>/`: host configuration, hooks, or agents that must be stored with the project.
34
+
35
+ `cwf project init` / `cwf project sync` must not read content from the source repository's runtime copies.
36
+
37
+ ### Machine-level payloads
38
+
39
+ `presets/` stores host components that do not belong to a single project:
40
+
41
+ - Codex, Claude Code, OpenCode, ZCode, Qoder, and Kimi Code plugins.
42
+ - DeepSeek Harness presets and hooks.
43
+ - Plugin branding assets and bootstrap Skills.
44
+
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
+
47
+ ## Runtime layers
48
+
49
+ Runtime code lives in `template/.cowork-flow/scripts/`. The repository root `scripts/` only handles building and releasing.
50
+
51
+ | Layer | Location | Responsibility |
52
+ |---|---|---|
53
+ | Command adapters | `scripts/adapters/cli/` | Argument parsing, command output, and CLI exit codes |
54
+ | Task services | `scripts/services/` | Task creation, lifecycle, archiving, context, and the task tree |
55
+ | State storage | `scripts/infra/storage/` | UTF-8 reads and writes, revision checks, operation logs, and recoverable transactions |
56
+ | Host adapters | `scripts/adapters/host/` | Host input, policy differences, and state injection |
57
+ | Shared hook core | `scripts/adapters/host/workflow_state_hook.py` | Workflow state parsing shared by all hosts |
58
+ | Host declarations | `spec/runtime/host-assets.json` | Platforms, assets, sync policy, Skill roots, and the migration manifest |
59
+
60
+ The workflow kernel keeps a narrow responsibility: the kernel only resolves state facts and actions, Skill ownership is injected by the manifest loader, and hard gates are enforced by the runtime gate. The repository no longer maintains a second workflow hub or a separate Skill registration control plane.
61
+
62
+ Scripts needed by an individual Skill live in `template/skills/<skill-id>/scripts/` and do not enter the runtime kernel.
63
+
64
+ ## init and sync
65
+
66
+ Installers and the synchronizer do not read and write incrementally; they execute in the following order:
67
+
68
+ 1. Read the Host Asset Manifest and the sync policy.
69
+ 2. Build an immutable Asset Plan.
70
+ 3. Stage on the same file system, and verify file hashes and permissions.
71
+ 4. Commit according to the backup manifest; on failure, roll back in reverse order.
72
+ 5. Update `.cowork-flow/.version` last.
73
+
74
+ `config.yaml`, `.developer`, specs, tasks, and plans are protected by the sync policy. `--force` widens the overwrite range, but `.cowork-flow/config.yaml` is in `forceProtectedFiles`: once created, neither `init --force` nor `sync --force` overwrites it. For an existing project, run with `--dry-run` first to see the changes.
75
+
76
+ The installation language is written to `language` in `config.yaml` (`zh-CN` by default, or `en-US`). The `localization` field of the Host Asset Manifest declares which assets have language variants; their source files live under `template/locales/<language>/<canonical-path>`. `init`, `sync`, and `dev refresh` choose the source file through `localizedSource()`, while the target path is always the canonical path, and `locales/` is excluded by `excludedPrefixes` so it never enters the project. Currently only `spec/contracts/decision-anchor.md` and `.cowork-flow/templates/plan-template.md` are localized: the former sets the heading language of a new anchor, the latter sets the language of plan artifacts, and parsers always accept both Chinese and English headings.
77
+
78
+ `.cowork-flow/spec/` splits its sync policy by ownership. Framework-maintained `spec/contracts/`, `spec/runtime/`, `spec/schemas/`, and `spec/index.md` follow `sync`: contract errata, `contract-registry.json`, `host-assets.json`, `scope-rules.json`, and schemas therefore reach installed projects in the same generation as the scripts, and obsolete framework spec files registered in `obsoleteFiles` are deleted as well. Project-maintained `spec/backend/`, `spec/frontend/`, `spec/guides/`, and `spec/references/` stay protected, and a normal `sync` never overwrites or deletes files there. The cost is that a project which has locally modified a framework contract or `scope-rules.json` loses those changes on the next `sync`; customizations worth keeping should go into the four project directories, `AGENTS.md`, `config.yaml`, or a project-owned Skill.
79
+
80
+ ## Extension rules
81
+
82
+ - Host specializations may live only in `spec/runtime/host-assets.json`, `scripts/adapters/`, `template/.<host>/`, or an explicit host command module.
83
+ - Plugins provide only fields the host actually supports; do not copy unknown or invalid keys.
84
+ - Project Skills are distributed only from `template/skills/`; machine-level payloads do not copy a project Skill with the same name.
85
+ - Shared planning and copy modules in `scripts/services|runtime|infra` and `src/lib/` must not contain host branches.
86
+ - For a new host, update the Host Asset Manifest and schema first, then add the installer, doctor support, and tests; do not write a separate host list in several files.
87
+ - Write project differences into `AGENTS.md`, `config.yaml`, `spec/backend|frontend|guides|references`, or a project-owned Skill, and do not bring back a second set of workflow documents.
88
+ - When changing a Skill distribution path, update `skillReadRoot`, `skillDiscovery`, and the corresponding host evidence together.
89
+ - When changing a command name, update the command registry, README, doctor hints, Skills, and related tests in one pass.
90
+
91
+ ## Tests and bytecode
92
+
93
+ Tests and Skill scripts must not leave `__pycache__` or `*.pyc` under `template/` or `presets/`. Node tests redirect the cache through `test/helpers/bytecode-isolation.js`; Skill scripts disable bytecode writing through `runtime_pythonpath_env(cache_bytecode=False)`. `tests/test_no_legacy_template_paths.py` guards this boundary.
94
+
95
+ `node --test` loads every `.js` file under `test/`, so helper modules must also be free of side effects; on the Python side, tests are collected according to the default discovery rules of pytest or unittest.
@@ -1,5 +1,7 @@
1
1
  # 架构与扩展
2
2
 
3
+ [English](architecture.en.md) | 中文
4
+
3
5
  本文面向维护 cowork-flow 的开发者,说明项目文件如何分层、宿主差异放在哪里,以及新增能力时应遵守的边界。只想安装和使用时,看 [README](../README.md);排查某个宿主时看 [宿主接入](hosts.md)。
4
6
 
5
7
  ## 先记住三条边界
@@ -69,9 +71,11 @@
69
71
  4. 按备份清单提交;失败时逆序回滚。
70
72
  5. 最后更新 `.cowork-flow/.version`。
71
73
 
72
- `config.yaml`、`.developer`、规范、任务和计划按同步策略保护。`--force` 会扩大覆盖范围,因此已有项目应先用 `--dry-run` 查看变更。
74
+ `config.yaml`、`.developer`、规范、任务和计划按同步策略保护。`--force` 会扩大覆盖范围,但 `.cowork-flow/config.yaml` 是 `forceProtectedFiles`:首次创建后 `init --force` 和 `sync --force` 都不再覆盖它。已有项目应先用 `--dry-run` 查看变更。
75
+
76
+ 安装语言写在 `config.yaml` 的 `language`(`zh-CN` 默认,或 `en-US`)。Host Asset Manifest 的 `localization` 声明哪些资产存在语言变体,源文件位于 `template/locales/<language>/<canonical-path>`;`init`、`sync` 与 `dev refresh` 通过 `localizedSource()` 选择源文件,目标路径始终是 canonical path,`locales/` 被 `excludedPrefixes` 排除,不会进入项目。当前只有 `spec/contracts/decision-anchor.md` 与 `.cowork-flow/templates/plan-template.md` 本地化;前者决定新 anchor 的标题语言,后者决定计划产物语言,解析器始终同时接受中英两套标题。
73
77
 
74
- `.cowork-flow/spec/` 前缀整体受同步保护:既有项目里的规范文件不会被 `sync` 覆盖,模板侧的规范更新只对全新 `init` 生效。具名例外是 `spec/runtime/host-assets.json` 中 `syncPolicy.safeFiles` 列出的文件——`spec/contracts/workflow-state-templates.md` 与 `spec/runtime/scope-rules.json`——它们随 `sync` 更新,使契约勘误与预算默认值能到达已装项目;代价是本地调过 `scope-rules.json` 的项目会在下一次 `sync` 丢掉这些改动。
78
+ `.cowork-flow/spec/` 按归属拆分同步策略。框架维护的 `spec/contracts/`、`spec/runtime/`、`spec/schemas/` 与 `spec/index.md` 随 `sync` 更新:契约勘误、`contract-registry.json`、`host-assets.json`、`scope-rules.json` 和 schema 因此能与脚本同代际到达已装项目,`obsoleteFiles` 中登记的过期框架 spec 文件也会被删除。项目维护的 `spec/backend/`、`spec/frontend/`、`spec/guides/`、`spec/references/` 保持保护,普通 `sync` 不会覆盖或删除其中的文件。代价是本地修改过框架契约或 `scope-rules.json` 的项目会在下一次 `sync` 丢掉这些改动;需要保留的定制应写入四个项目目录、`AGENTS.md`、`config.yaml` 或项目自有 Skill。
75
79
 
76
80
  ## 扩展规则
77
81
 
@@ -80,7 +84,7 @@
80
84
  - 项目技能只由 `template/skills/` 分发;机器级载荷不复制同名项目技能。
81
85
  - `scripts/services|runtime|infra` 和 `src/lib/` 的通用计划、拷贝模块不能出现宿主分支。
82
86
  - 新宿主先更新 Host Asset Manifest 与 schema,再补安装器、doctor 和测试;不要在多个文件各写一份宿主清单。
83
- - 项目差异写入 `AGENTS.md`、`config.yaml`、`spec/` 或项目自有 Skill,不恢复第二套流程文档。
87
+ - 项目差异写入 `AGENTS.md`、`config.yaml`、`spec/backend|frontend|guides|references` 或项目自有 Skill,不恢复第二套流程文档。
84
88
  - 修改 Skill 分发路径时,同时更新 `skillReadRoot`、`skillDiscovery` 和对应宿主证据。
85
89
  - 修改命令名时,一次更新命令注册表、README、doctor 提示、Skill 和相关测试。
86
90
 
@@ -0,0 +1,71 @@
1
+ # cowork-flow direction: agent runtime context and the collaboration fact layer
2
+
3
+ [中文](direction.md) | English
4
+
5
+ > Status: **approved** · Created: 2026-08-27 · Last updated: 2026-10-19
6
+ > This document is the authoritative input for starting later phases. Any revision to the direction must update this document first, then start the phase.
7
+ > Implementation details and commit history for completed phases are in the [CHANGELOG](../CHANGELOG.md) (Chinese); this document keeps only the positioning, trade-offs, boundaries, and open items that still hold.
8
+
9
+ ---
10
+
11
+ ## 1. Positioning
12
+
13
+ > **cowork-flow does not constrain how a model thinks; it guarantees that any agent on any host starts from the same authoritative facts, in any session, at any moment.**
14
+
15
+ | | Previous positioning | New positioning |
16
+ |---|---|---|
17
+ | Narrative | Help you build a process (process templates) | Runtime context and collaboration fact layer |
18
+ | Means | Task flows, gates, spec documents | State injection, fact consistency, cross-host governance |
19
+ | Purpose | Make collaboration "follow the rules" | Make collaboration "start from the correct state" |
20
+ | When model capability rises | Constraint-type value decreases (models follow the rules on their own) | Fact-type value increases (state is something a model cannot invent) |
21
+
22
+ The test: a project's consumer is an agent, not a person. So injection formats, fact output, and contracts always follow "machine-parseable first, human-readable as a fallback".
23
+
24
+ ## 2. Settled trade-offs
25
+
26
+ - **Injection format: option A (structured fact header + human-readable summary body, with graded degradation)** — structured first; when the channel does not allow it, degrade to attribute lines or a plain summary.
27
+ - Rejected "all-JSON injection": the plain-text channels of dsh / codex waste tokens and break the readability of compact prose breadcrumbs.
28
+ - Rejected "keep text and only add a `--json` output": the core value proposition would not land in injection itself.
29
+ - **Fact-layer output**: the CLI + JSON protocol comes first (zero dependencies); MCP follows as a thin adapter.
30
+ - **Three-line convergence**: start with "a single protocol spec + three lines implemented against the spec"; code-level sharing is left for later (high cost, and the benefit has already been delivered through protocol consistency).
31
+
32
+ ## 3. What we explicitly do not do
33
+
34
+ 1. No "smarter prompts / AGENTS.md writing craft" — model capability will catch up, and that leaves no data assets.
35
+ 2. No home-grown cross-agent communication standard — this is a period of protocol competition; wait for the ecosystem to converge.
36
+ 3. No task execution engine — not a substitute for the agent doing the work, only a guarantee that it starts from the correct state.
37
+ 4. No deeper process-only gates — keep them as a safety net and stop investing.
38
+
39
+ ## 4. Rejected candidates
40
+
41
+ | Candidate | Why it was rejected |
42
+ |---|---|
43
+ | AgentOps / observability | No runtime telemetry assets; building from scratch means switching lanes and breaks with the workflow-engine positioning |
44
+ | Task orchestration engine | Overlaps with the orchestration hosts already provide; turning the state model into a distributed system explodes complexity |
45
+ | Pure governance and compliance layer | The value of pure gates decreases as models become more self-directed; no differentiation |
46
+ | ✅ Fact layer + injection | The repository's thickest assets all live here; cross-host consistency is a structural difference no single-host tool can provide |
47
+
48
+ ## 5. Version line
49
+
50
+ - **1.8.x released**: evidence-based completion (ACs as facts, `evidence.jsonl`, completion gates).
51
+ - **1.9.x released**: collaboration facts for multiple executors — visible board ownership, dependency edges, handoff records.
52
+ - **2.0.0 released**: the spec-check mechanism removed in a breaking change, edit-time out-of-scope warnings on every host, and relaxed injection capacity (Verify 10 items / block budget 3400). See the `[2.0.0]` section of the [CHANGELOG](../CHANGELOG.md) (Chinese).
53
+ - Per-version delivery details always follow the CHANGELOG; this document does not repeat them.
54
+
55
+ ## 6. Open items and deferred work
56
+
57
+ - **Settled (2026-10-21): detailed documentation stays Chinese; the README stays bilingual.** The English community is the main venue for spec-driven development discussion, but the detailed documentation is currently about 590 lines and ships in the npm package as plain Markdown, so full bilingual coverage would introduce translation drift and documentation-framework cost. Decision: `docs/`, `template/AGENTS.md`, and `CHANGELOG.md` stay Chinese; `README.md` / `README.en.md` are kept in sync in both languages; no VuePress/mkdocs or directory-based bilingual setup is introduced.
58
+ - **2026-10-22 (step three): English demand confirmed, and `docs/` gains parallel `docs/*.en.md` files.** Five documents (index, architecture, hosts, release, direction) each gain an English version, the Chinese and English pages link to each other at the top, and everything still ships in the npm package as plain Markdown. Translation drift is held down by the pairing and heading-structure gates in `test/docs.test.js`: a missing English file, inconsistent heading levels, or a missing counterpart link all fail.
59
+ - 2026-10-13 clarification: "documentation language: Chinese" constrains the language of **documents produced** while working in a downstream host; it does not require translating the product payloads shipped with the package (`template/skills/`, `template/.cowork-flow/spec/contracts/`, `presets/`) into Chinese.
60
+ - 2026-10-21 (step one): the framework spec documentation shipped with the package is unified in English — `spec/index.md`, `spec/runtime/index.md`, `spec/schemas/index.md`, `spec/references/**`. The six parsed headings in `decision-anchor.md`, the injection block in `workflow-state-templates.md`, `backend/frontend/guides`, and `template/AGENTS.md` stay Chinese.
61
+ - 2026-10-22 (step two): installation can choose `zh-CN` / `en-US`, written to the protected `.cowork-flow/config.yaml` and affecting only `decision-anchor.md` and plan artifacts. The parser permanently accepts both the Chinese and English heading sets; `decision-anchor.md` keeps the Chinese contract and adds an English variant, while `workflow-state-templates.md`, `AGENTS.md`, spec documents, and Skills are not localized by that option. `references/` is still protected by project sync, so an installed project needs a manual refresh to receive the English copies.
62
+ - **Still deferred**: MCP write tools (the `fact-layer-access` contract must be reopened first), new host integrations, and a home-grown cross-agent protocol.
63
+ - **Watch item (trigger reached)**: machine-parseable ACs are the first building block for interoperability with Spec Kit / OpenSpec (spec artifacts ↔ decision-anchor mapping), and fit the "state layer beneath SDD tools" positioning. It was originally "to be discussed once the agent-teams schedule is settled"; since the 1.9.0 multi-executor collaboration mainline is already implemented, it can be put on the discussion schedule.
64
+
65
+ ## 7. Metrics
66
+
67
+ 1. **Cross-host behavioral consistency**: fingerprints and slim triggers on each host are asserted by tests, with 0 drift.
68
+ 2. **Cost of integrating a new host**: from days down to hours (a direct measure of protocol-spec completeness).
69
+ 3. **Injection token cost**: injected volume in long sessions does not grow linearly with the number of messages.
70
+ 4. **Fact freshness incidents**: multi-session task contamination / stomping incidents trend toward zero.
71
+ 5. **Adoption**: weekly npm downloads and the number of activated projects — using numbers to verify whether the "deep route" delivers.
package/docs/direction.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # cowork-flow 方向规划:Agent 运行时上下文与协作事实层
2
2
 
3
+ [English](direction.en.md) | 中文
4
+
3
5
  > 状态:**已批准** · 创建:2026-08-27 · 最近更新:2026-10-19
4
6
  > 本文档是后续阶段立项的权威输入。任何方向的修订必须先更新本文档,再立项。
5
7
  > 已完成阶段的实施细节与提交记录见 [CHANGELOG](../CHANGELOG.md);本文只保留仍然生效的定位、取舍、边界和待决项。
@@ -52,8 +54,11 @@
52
54
 
53
55
  ## 6. 待决项与缓行
54
56
 
55
- - **已拍板(2026-10-21):详细文档维持中文,README 保持中英双语。** 英文社区是 spec-driven development 讨论的主场,但当前详细文档约 590 行、随 npm 以纯 Markdown 发布,全量双语会引入翻译漂移与文档框架成本。决定:`docs/`、`template/AGENTS.md`、`CHANGELOG.md` 维持中文;`README.md` / `README.en.md` 双语同步;不引入 VuePress/mkdocs 或目录式双语。未来若英文需求被证实,采用并列 `docs/*.en.md`,只覆盖安装面文档,并新增“英文文件与中文源文件标题集合一致”的漂移门禁后再落地。
57
+ - **已拍板(2026-10-21):详细文档维持中文,README 保持中英双语。** 英文社区是 spec-driven development 讨论的主场,但当前详细文档约 590 行、随 npm 以纯 Markdown 发布,全量双语会引入翻译漂移与文档框架成本。决定:`docs/`、`template/AGENTS.md`、`CHANGELOG.md` 维持中文;`README.md` / `README.en.md` 双语同步;不引入 VuePress/mkdocs 或目录式双语。
58
+ - **2026-10-22(第三步):英文需求被证实,`docs/` 并入并列 `docs/*.en.md`。** 五份文档(index、architecture、hosts、release、direction)各新增英文版,中英页面顶部互链,仍随 npm 以纯 Markdown 发布。翻译漂移由 `test/docs.test.js` 的成对与标题结构门禁守住:英文文件缺失、标题层级不一致或互链缺失都会失败。
56
59
  - 2026-10-13 澄清:「文档语言:中文」约束的是下游宿主工作时**产出文档**的语言,不要求把随包分发的产品载荷(`template/skills/`、`template/.cowork-flow/spec/contracts/`、`presets/`)翻译成中文。
60
+ - 2026-10-21(第一步):随包分发的框架 spec 说明文档统一为英文——`spec/index.md`、`spec/runtime/index.md`、`spec/schemas/index.md`、`spec/references/**`。`decision-anchor.md` 的六个解析标题、`workflow-state-templates.md` 的注入块、`backend/frontend/guides` 与 `template/AGENTS.md` 仍为中文。
61
+ - 2026-10-22(第二步):安装时可选择 `zh-CN` / `en-US`,写入受保护的 `.cowork-flow/config.yaml`,只影响 `decision-anchor.md` 与计划产物。解析器永久接受中英两套标题;`decision-anchor.md` 保留中文合同并新增英文变体,`workflow-state-templates.md`、`AGENTS.md`、spec 文档与 Skill 不随该选项本地化。`references/` 仍受项目同步保护,已装项目需手动刷新才能拿到英文副本。
57
62
  - **维持缓行**:MCP 写工具(须先重开 `fact-layer-access` 契约)、新宿主接入、自创跨 agent 协议。
58
63
  - **观察项(触发条件已到)**:机器可解析 AC 是与 Spec Kit / OpenSpec 互操作的第一块砖(spec 制品 ↔ decision-anchor 映射),符合「SDD 工具之下的状态层」定位。原定「待 agent-teams 排期落定后议」,而 1.9.0 多执行者协作主线已实现,可排入讨论。
59
64