cowork-flow 2.7.1 → 2.7.2

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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@
6
6
 
7
7
  ### Changed
8
8
 
9
+ ## [2.7.2] - 2026-11-13
10
+
11
+ ### Added
12
+
13
+ - **GitHub Release 自动化**:推送 `v*` tag 且 npm 发布成功后,`publish.yml` 新增 `github-release` job 自动创建以 tag 命名的 GitHub Release;release notes 由 `scripts/release-notes.js` 从 CHANGELOG.md 对应版本段落提取(版本号精确匹配,止于下一版本标题或尾部链接引用),Release 已存在时幂等跳过;既有 verify/publish job、触发器与 concurrency 不变。
14
+ - **运行时状态自忽略与 Git 卫生检查**:首次写入 `.cowork-flow/.runtime/` 时自动创建自忽略文件(`*` 与 `!.gitignore`),锁、会话绑定、操作日志与状态快照不再进入 git;`doctor --all` 新增 `RUNTIME-GIT-HYGIENE-UNIGNORED` / `RUNTIME-GIT-HYGIENE-TRACKED` 告警与清理提示。
15
+ - **团队协作文档**:新增 `docs/team.md` 与英文对页,覆盖提交范围、分支与 worktree、executor 与 assignee、跨机器交接、合并冲突修复与 `.runtime` 清理。
16
+
17
+ ### Changed
18
+
19
+ - **悬空绑定降级语义统一**:绑定任务目录因切分支或 worktree 消失时,hook 注入与 CLI `task next` 共用同一消息源,提示切回原分支或显式重新绑定,不再默认引导创建重复任务。
20
+
9
21
  ## [2.7.1] - 2026-11-05
10
22
 
11
23
  ### Fixed
@@ -508,7 +520,8 @@
508
520
 
509
521
  此版本未保留本地条目正文,详情见 [GitHub Release](https://github.com/fishlikewater/cowork-flow/releases/tag/v0.0.47)。
510
522
 
511
- [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.1...HEAD
523
+ [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.2...HEAD
524
+ [2.7.2]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.1...v2.7.2
512
525
  [2.7.1]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.0...v2.7.1
513
526
  [2.7.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.6.0...v2.7.0
514
527
  [2.6.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.5.2...v2.6.0
package/README.en.md CHANGED
@@ -204,6 +204,7 @@ counterpart at the top.
204
204
  |---|---|
205
205
  | [Documentation index](docs/index.en.md) | Entry point for every document |
206
206
  | [Architecture and extension](docs/architecture.en.md) | How the project files are organized, how the sync policy and protected files work |
207
+ | [Team collaboration](docs/team.en.md) | Commit scope, ownership handover, and runtime cleanup across people, branches, and worktrees |
207
208
  | [Host integration](docs/hosts.en.md) | Install, restart, troubleshoot, and uninstall for each host |
208
209
  | [Release and maintenance](docs/release.en.md) | Tests, CI, and maintainer commands |
209
210
  | [Direction](docs/direction.en.md) | Positioning, settled trade-offs, version line, and open items |
package/README.md CHANGED
@@ -160,6 +160,7 @@ cwf project sync .
160
160
  |---|---|
161
161
  | [文档索引](docs/index.md) | 全部文档入口 |
162
162
  | [架构与扩展](docs/architecture.md) | 项目文件如何组织、同步策略与受保护文件 |
163
+ | [团队协作](docs/team.md) | 多人、多分支与 worktree 下的提交范围、所有权交接和运行时清理 |
163
164
  | [宿主接入](docs/hosts.md) | 各宿主的安装、重启、排障和卸载方式 |
164
165
  | [发布与维护](docs/release.md) | 测试、CI 和维护者命令 |
165
166
  | [方向规划](docs/direction.md) | 项目定位、已定取舍、版本主线与待决项 |
@@ -2,7 +2,7 @@
2
2
 
3
3
  [中文](direction.md) | English
4
4
 
5
- > Status: **approved** · Created: 2026-08-27 · Last updated: 2026-10-19
5
+ > Status: **approved** · Created: 2026-08-27 · Last updated: 2026-11-10
6
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
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
8
 
@@ -50,6 +50,7 @@ The test: a project's consumer is an agent, not a person. So injection formats,
50
50
  - **1.8.x released**: evidence-based completion (ACs as facts, `evidence.jsonl`, completion gates).
51
51
  - **1.9.x released**: collaboration facts for multiple executors — visible board ownership, dependency edges, handoff records.
52
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
+ - **2.8.x in planning**: team collaboration baseline — runtime ignore hygiene (`.runtime` stays out of the repository), unified degradation semantics for dangling bindings, and team collaboration documentation.
53
54
  - Per-version delivery details always follow the CHANGELOG; this document does not repeat them.
54
55
 
55
56
  ## 6. Open items and deferred work
@@ -59,6 +60,7 @@ The test: a project's consumer is an agent, not a person. So injection formats,
59
60
  - 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
61
  - 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
62
  - 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.
63
+ - **Started (2026-11-10): team collaboration baseline.** 1.9.x addressed single-machine multi-executor facts; git-level fact consistency across multiple developers, branches, and worktrees becomes the next version line, limited to runtime ignore hygiene, dangling-binding degradation semantics, and team collaboration documentation; cross-branch boards and git hosting are out of scope.
62
64
  - **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
65
  - **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
66
 
package/docs/direction.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](direction.en.md) | 中文
4
4
 
5
- > 状态:**已批准** · 创建:2026-08-27 · 最近更新:2026-10-19
5
+ > 状态:**已批准** · 创建:2026-08-27 · 最近更新:2026-11-10
6
6
  > 本文档是后续阶段立项的权威输入。任何方向的修订必须先更新本文档,再立项。
7
7
  > 已完成阶段的实施细节与提交记录见 [CHANGELOG](../CHANGELOG.md);本文只保留仍然生效的定位、取舍、边界和待决项。
8
8
 
@@ -50,6 +50,7 @@
50
50
  - **1.8.x 已发布**:证据化完成(AC 事实化、`evidence.jsonl`、完成门禁)。
51
51
  - **1.9.x 已发布**:多执行者协作事实——看板归属可见、依赖边、交接凭证。
52
52
  - **2.0.0 已发布**:spec-check 机制破坏性删除、编辑期越界警告覆盖各宿主、注入容量放宽(Verify 10 条 / 块预算 3400)。详见 [CHANGELOG](../CHANGELOG.md) 的 `[2.0.0]` 段。
53
+ - **2.8.x 规划中**:团队协作基线——运行时忽略卫生(`.runtime` 不入库)、悬空绑定降级语义统一、团队协作文档。
53
54
  - 各版本的交付明细一律以 CHANGELOG 为准,本文不重复。
54
55
 
55
56
  ## 6. 待决项与缓行
@@ -59,6 +60,7 @@
59
60
  - 2026-10-13 澄清:「文档语言:中文」约束的是下游宿主工作时**产出文档**的语言,不要求把随包分发的产品载荷(`template/skills/`、`template/.cowork-flow/spec/contracts/`、`presets/`)翻译成中文。
60
61
  - 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
62
  - 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/` 仍受项目同步保护,已装项目需手动刷新才能拿到英文副本。
63
+ - **已立项(2026-11-10):团队协作基线。** 1.9.x 解决了单机多执行者事实;多开发者、多分支与 worktree 场景下 git 层的事实一致性作为下一版本线,范围限定为运行时忽略卫生、悬空绑定降级语义与团队协作文档;跨分支看板与 git 托管不做。
62
64
  - **维持缓行**:MCP 写工具(须先重开 `fact-layer-access` 契约)、新宿主接入、自创跨 agent 协议。
63
65
  - **观察项(触发条件已到)**:机器可解析 AC 是与 Spec Kit / OpenSpec 互操作的第一块砖(spec 制品 ↔ decision-anchor 映射),符合「SDD 工具之下的状态层」定位。原定「待 agent-teams 排期落定后议」,而 1.9.0 多执行者协作主线已实现,可排入讨论。
64
66
 
package/docs/index.en.md CHANGED
@@ -11,6 +11,7 @@ If this is your first time installing and using cowork-flow, read [README](../RE
11
11
  | Install, initialize a project, or start a task | [README](../README.en.md) | The shortest path to get started, day-to-day commands, and common questions |
12
12
  | Connect cowork-flow to an AI coding host | [Host integration](hosts.en.md) | Installation components, restart requirements, upgrades, uninstallation, and troubleshooting for each host |
13
13
  | Understand how project files are organized | [Architecture and extension](architecture.en.md) | The runtime, `template/`, `presets/`, sync policy, and extension boundaries |
14
+ | Collaborate across people, branches, or worktrees | [Team collaboration](team.en.md) | Commit scope, branches and worktrees, executor vs assignee, cross-machine handover, and runtime state cleanup |
14
15
  | Contribute to project development | [Contributing](../CONTRIBUTING.en.md) | Local setup, code conventions, tests, and PR checks |
15
16
  | Understand the test and release process | [Release and maintenance](release.en.md) | Test layers, CI, version releases, and maintainer commands |
16
17
  | Understand project direction and version planning | [Direction](direction.en.md) | The positioning statement, settled trade-offs, the version mainline, and open items |
package/docs/index.md CHANGED
@@ -11,6 +11,7 @@
11
11
  | 安装、初始化项目或开始一个任务 | [README](../README.md) | 最短使用路径、日常命令和常见问题 |
12
12
  | 把 cowork-flow 接到某个 AI 编码宿主 | [宿主接入](hosts.md) | 各宿主的安装组件、重启要求、升级、卸载和排障方式 |
13
13
  | 了解项目文件如何组织 | [架构与扩展](architecture.md) | 运行时、`template/`、`presets/`、同步策略和扩展边界 |
14
+ | 多人、多分支或多 worktree 协作 | [团队协作](team.md) | 提交范围、分支与 worktree、executor 与 assignee、跨机器交接和运行时状态清理 |
14
15
  | 参与项目开发 | [参与开发](../CONTRIBUTING.md) | 本地环境、代码约定、测试和 PR 检查 |
15
16
  | 了解测试与发布流程 | [发布与维护](release.md) | 测试分层、CI、版本发布和维护者命令 |
16
17
  | 了解项目方向与版本规划 | [方向规划](direction.md) | 定位声明、已拍板取舍、版本主线与待决项 |
@@ -0,0 +1,46 @@
1
+ # Team collaboration
2
+
3
+ [中文](team.md) | English
4
+
5
+ When several people, branches, or worktrees use cowork-flow together, task state lives in the repository while runtime state lives locally. This page covers what to commit, why a binding stops resolving after a branch switch, what executor and assignee each mean, and how to repair conflicts.
6
+
7
+ ## What to commit, what to ignore
8
+
9
+ - Commit: `.cowork-flow/tasks/`, `.cowork-flow/plans/`, the project-owned directories under `.cowork-flow/spec/` (`backend/`, `frontend/`, `guides/`, `references/`), `.cowork-flow/config.yaml`, and `AGENTS.md`.
10
+ - Ignore: `.cowork-flow/.runtime/`. On the first runtime write, cowork-flow creates `.runtime/.gitignore` automatically (containing `*` and `!.gitignore`), so locks, session bindings, operation logs, and state snapshots stay out of git.
11
+ - Do not commit `.runtime` by hand; if an earlier version already committed it, see the cleanup section below.
12
+ - `project sync` only updates framework-managed files; tasks, plans, and project-owned specs are preserved by default.
13
+
14
+ ## Branches and worktrees
15
+
16
+ - Tasks and plans follow the branch. After switching to a branch that does not contain the current task, the session binding still points at the old path but the directory is gone; the hook and CLI report "task directory not found" and suggest switching back or rebinding explicitly instead of creating a duplicate task.
17
+ - Rebind: after returning to the branch that contains the task, run `./.cowork-flow/run task next <task-dir>`; or pick an existing task with `task next --list`.
18
+ - Each worktree has its own `.runtime/`, so session bindings, locks, and state snapshots are not shared; task files follow each worktree's checked-out branch.
19
+ - Do not advance the same task in parallel worktrees: different checkouts hold different copies of `task.json`, and runtime locks only protect a single working tree.
20
+ - To advance several tasks in parallel, coordinate through the task board (`task next --list --json`) and dependencies (`--depends-on`), then converge after merging.
21
+
22
+ ## executor vs assignee
23
+
24
+ - `assignee` is the person: `--assignee` at task creation, used for board ownership and filtering (`task next --list --mine`).
25
+ - `executor` is the session identity that currently holds the task: written when `task next <dir> --run` starts it. To continue from another machine or session, take over explicitly with `--adopt`; adoption resets the review baseline and keeps the former executor's audit fields.
26
+ - `ownerSessionActive` is only a binding hint: `false` does not mean the task is unowned, and sessions working with an explicit directory or in another worktree never show up as bindings here.
27
+ - Hand ownership over with `--adopt`; `--takeover` only applies at start and does not reset the baseline.
28
+
29
+ ## Cross-machine handover
30
+
31
+ 1. The original executor commits and pushes the task directory (`task.json`, `decision-anchor.md`, `implement.jsonl`, and so on).
32
+ 2. The new executor pulls the branch and runs `./.cowork-flow/run task next <task-dir> --run --adopt`.
33
+ 3. The handover output lists the former executor, the former baseline, remaining unchecked ACs, and evidence coverage, so work can continue directly.
34
+
35
+ ## Merge conflicts and manual repair
36
+
37
+ - `task.json` is a fact file, and hand-editing it is a legitimate repair path; after resolving a merge conflict, `task next --validate` and `doctor --all` should report no new errors.
38
+ - Cycles, dependencies on missing tasks, empty executors, and similar anomalies fail closed at the start / review gates instead of passing silently.
39
+ - Do not hand-edit `_state`: `revision` and `operation_id` are concurrency-control and idempotency metadata.
40
+ - After a merge, run `./.cowork-flow/run doctor --all` before continuing.
41
+
42
+ ## Cleaning up a committed .runtime
43
+
44
+ - `doctor --all` reports `RUNTIME-GIT-HYGIENE-UNIGNORED` (runtime files are not ignored) or `RUNTIME-GIT-HYGIENE-TRACKED` (runtime files are tracked).
45
+ - Clean up with `git rm -r --cached .cowork-flow/.runtime`; after committing, the next runtime write creates `.runtime/.gitignore` automatically.
46
+ - Cleanup does not delete local files; locks, bindings, and snapshots stay in the working tree.
package/docs/team.md ADDED
@@ -0,0 +1,46 @@
1
+ # 团队协作
2
+
3
+ [English](team.en.md) | 中文
4
+
5
+ 多人、多分支、多 worktree 使用 cowork-flow 时,任务状态保存在仓库里,运行时状态保存在本地。本篇说明哪些文件该提交、切换分支后绑定为什么会失效、executor 和 assignee 各自代表什么,以及出现冲突时怎么修。
6
+
7
+ ## 提交什么、忽略什么
8
+
9
+ - 提交:`.cowork-flow/tasks/`、`.cowork-flow/plans/`、`.cowork-flow/spec/` 中的项目自有目录(`backend/`、`frontend/`、`guides/`、`references/`)、`.cowork-flow/config.yaml` 与 `AGENTS.md`。
10
+ - 忽略:`.cowork-flow/.runtime/`。首次写入运行时状态时,cowork-flow 会自动创建 `.runtime/.gitignore`(内容为 `*` 与 `!.gitignore`),锁、会话绑定、操作日志与状态快照不会进入 git。
11
+ - 不要手工提交 `.runtime`;如果早期版本已经提交过,见文末清理。
12
+ - `project sync` 只更新框架管理的文件;任务、计划和项目自有 spec 默认保留。
13
+
14
+ ## 分支与 worktree
15
+
16
+ - 任务和计划随分支走。切换到不包含当前任务的分支后,会话绑定仍指向原路径,但目录不存在;hook 与 CLI 会报告“任务目录不存在”,并提示切回原分支或显式重新绑定,而不是让你创建重复任务。
17
+ - 重新绑定:回到包含任务的分支后运行 `./.cowork-flow/run task next <task-dir>`;或用 `task next --list` 选一个已存在的任务。
18
+ - 每个 worktree 有独立的 `.runtime/`,会话绑定、锁与状态快照不共享;任务文件随各 worktree 的检出分支变化。
19
+ - 同一任务不要在多个 worktree 并行推进:不同检出的 `task.json` 是不同副本,运行时锁只保护单个工作区。
20
+ - 需要并行推进多个任务时,用任务看板(`task next --list --json`)和依赖(`--depends-on`)协调,合并后再统一推进。
21
+
22
+ ## executor 与 assignee
23
+
24
+ - `assignee` 是人:任务创建时的 `--assignee`,用于看板归属和筛选(`task next --list --mine`)。
25
+ - `executor` 是当前持有任务的会话身份:`task next <dir> --run` 启动时写入;跨机器或跨会话续做时通过 `--adopt` 显式接管,接管会重置 review 基线并保留前任 executor 的审计字段。
26
+ - `ownerSessionActive` 只是绑定提示:`false` 不代表任务无人负责,显式目录工作或另一个工作区的会话不会出现在这里的绑定中。
27
+ - 所有权交接用 `--adopt`;`--takeover` 只在 start 时生效,不重置基线。
28
+
29
+ ## 跨机器交接
30
+
31
+ 1. 原执行者提交并推送任务目录(`task.json`、`decision-anchor.md`、`implement.jsonl` 等)。
32
+ 2. 新执行者拉取分支后运行 `./.cowork-flow/run task next <task-dir> --run --adopt`。
33
+ 3. 接手输出包含前任 executor、原基线、未完成 AC 和证据覆盖,可直接继续。
34
+
35
+ ## 合并冲突与手工修复
36
+
37
+ - `task.json` 是事实文件,手工编辑是合法修复路径;合并冲突解决后,`task next --validate` 与 `doctor --all` 应无新增错误。
38
+ - 循环依赖、指向不存在任务的依赖、空 executor 等异常由 start / review 门禁失败关闭处理,不会静默通过。
39
+ - 不要手工修改 `_state`:`revision` 与 `operation_id` 是并发控制和幂等元数据。
40
+ - 合并后先跑 `./.cowork-flow/run doctor --all`,再继续推进。
41
+
42
+ ## 已提交 .runtime 的清理
43
+
44
+ - `doctor --all` 会报告 `RUNTIME-GIT-HYGIENE-UNIGNORED`(运行时文件未被忽略)或 `RUNTIME-GIT-HYGIENE-TRACKED`(运行时文件已被跟踪)。
45
+ - 清理:`git rm -r --cached .cowork-flow/.runtime`,提交后由下一次状态写入自动生成 `.runtime/.gitignore`。
46
+ - 清理不会删除本地文件;锁、绑定和快照仍保留在工作区。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "CLI for installing and maintaining cowork-flow collaboration templates.",
5
5
  "keywords": [
6
6
  "ai-agent",
@@ -50,7 +50,7 @@
50
50
  "scripts": {
51
51
  "test": "npm run test:fast",
52
52
  "test:smoke": "node --test --test-timeout=600000 test/smoke.test.js test/tarball-install.test.js",
53
- "test:fast": "node --test --test-timeout=600000 test/asset-plan.test.js test/cli.test.js test/cli-registry.test.js test/claude-code-plugin.test.js test/codex-plugin.test.js test/compliance-e2e.test.js test/contract-fingerprint.test.js test/copy-template.obsolete-safety.test.js test/docs.test.js test/eol.test.js test/host-assets.test.js test/host-command.test.js test/host-inspect.test.js test/installed-state-e2e.test.js test/kimi-hook.test.js test/localization.test.js test/kimi-installed-registry.test.js test/kimi-plugin.test.js test/opencode-plugin-installer.test.js test/opencode-plugin.test.js test/package.test.js test/plugin-metadata.test.js test/plugin-payload.test.js test/qoder-plugin.test.js test/smoke.test.js test/stage-contract.test.js test/template-runner.test.js test/update.test.js test/zcode-plugin.test.js",
53
+ "test:fast": "node --test --test-timeout=600000 test/asset-plan.test.js test/cli.test.js test/cli-registry.test.js test/claude-code-plugin.test.js test/codex-plugin.test.js test/compliance-e2e.test.js test/contract-fingerprint.test.js test/copy-template.obsolete-safety.test.js test/docs.test.js test/eol.test.js test/host-assets.test.js test/host-command.test.js test/host-inspect.test.js test/installed-state-e2e.test.js test/kimi-hook.test.js test/localization.test.js test/kimi-installed-registry.test.js test/kimi-plugin.test.js test/opencode-plugin-installer.test.js test/opencode-plugin.test.js test/package.test.js test/plugin-metadata.test.js test/plugin-payload.test.js test/qoder-plugin.test.js test/release-notes.test.js test/smoke.test.js test/stage-contract.test.js test/template-runner.test.js test/update.test.js test/zcode-plugin.test.js",
54
54
  "test:integration": "node --test --test-timeout=600000 --test-name-pattern=\"^(init copies the template into a new target directory|sync updates safe template files and preserves protected files)$\" test/init.test.js test/sync.test.js",
55
55
  "test:node:full": "node --test --test-timeout=600000",
56
56
  "test:template": "node scripts/run-template-tests.js --suite core",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Claude Code。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Codex。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Kimi Code。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Qoder。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 ZCode。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
@@ -19,6 +19,7 @@ from runtime.session_state import (
19
19
  is_delegated_session,
20
20
  )
21
21
  from services.task_repository import TaskRepository, TaskRepositoryError
22
+ from services.task_presence import missing_task_blockers
22
23
 
23
24
 
24
25
  from services.task_routing import _default_intent
@@ -411,7 +412,7 @@ def _navigation_target(args, repo_root: Path, structured: bool):
411
412
 
412
413
 
413
414
  def _print_stale_route(args, task_path: str, source: str, active_target: bool) -> None:
414
- blockers = [f"task directory not found: {task_path}"]
415
+ blockers = missing_task_blockers(task_path)
415
416
  if bool(getattr(args, "json", False)):
416
417
  _print_json_route(
417
418
  args=args,
@@ -20,6 +20,7 @@ from runtime.session_state import (
20
20
  from services.plan_binding import PlanBindingError, bind_task_plan
21
21
  from services.task_creation import TaskCreationError, set_task_dev_type
22
22
  from services.task_lifecycle import ADOPTABLE_STATUSES
23
+ from services.task_presence import missing_task_blockers, missing_task_fact
23
24
 
24
25
 
25
26
  LifecycleCommand = Callable[[argparse.Namespace], int]
@@ -89,7 +90,7 @@ def _next_payload_for_run(args: argparse.Namespace, repo_root: Path) -> dict[str
89
90
  return task_navigation.build_navigation_payload(
90
91
  args=args,
91
92
  status="stale",
92
- blockers=[f"task directory not found: {task_path}"],
93
+ blockers=missing_task_blockers(task_path),
93
94
  active_target=active_target,
94
95
  task_path=task_path,
95
96
  )
@@ -337,7 +338,7 @@ def _run_adopt_action(
337
338
  return 1
338
339
  if not task_dir.is_dir():
339
340
  print(
340
- colored(f"Error: task directory not found: {task_path}", Colors.RED),
341
+ colored(f"Error: {missing_task_fact(task_path)}", Colors.RED),
341
342
  file=sys.stderr,
342
343
  )
343
344
  return 1
@@ -21,6 +21,7 @@ from typing import Any, NamedTuple
21
21
 
22
22
  from adapters.host.policy_base import DEFAULT_DIGEST_POLICY, HostPolicy, default_policy
23
23
  from services.decision_anchor_schema import parse_decision_anchor
24
+ from services.task_presence import missing_task_body
24
25
 
25
26
 
26
27
  TAG_RE = re.compile(
@@ -216,7 +217,7 @@ def _render_state_body(
216
217
  policy: HostPolicy,
217
218
  ) -> str:
218
219
  if state.missing_task:
219
- body = MISSING_TASK_BODY.format(task_path=state.task_path)
220
+ body = missing_task_body(state.task_path)
220
221
  else:
221
222
  body = (
222
223
  breadcrumbs.get(state.status)
@@ -592,13 +593,6 @@ def _get_active_task(
592
593
  return active.task_path, status.strip(), active.source
593
594
 
594
595
 
595
- MISSING_TASK_BODY = (
596
- "Session 指向的任务目录不存在({task_path})。\n"
597
- "当前项目无有效任务。请运行 ./.cowork-flow/run task next --run "
598
- '--title "<title>" --slug <task-name> --assignee <name> 创建新任务。'
599
- )
600
-
601
-
602
596
  def _get_active_task_with_fallback(
603
597
  root: Path,
604
598
  hook_input: dict[str, Any],
@@ -20,6 +20,7 @@ DIR_SCRIPTS = "scripts"
20
20
  # File names
21
21
  FILE_DEVELOPER = ".developer"
22
22
  FILE_TASK_JSON = "task.json"
23
+ RUNTIME_IGNORE_TEXT = "*\n!.gitignore\n"
23
24
  TASK_DATE_PREFIX_PATTERN = re.compile(r"^\d{2}-\d{2}-")
24
25
  FULL_DATE_PREFIX_PATTERN = re.compile(r"^\d{4}-(\d{2}-\d{2}-)")
25
26
 
@@ -77,6 +78,30 @@ def get_tasks_dir(repo_root: Path | None = None) -> Path:
77
78
  return repo_root / DIR_WORKFLOW / DIR_TASKS
78
79
 
79
80
 
81
+ def runtime_root_for(path: Path) -> Path | None:
82
+ """The `.cowork-flow/.runtime` root containing path, if any."""
83
+ for parent in Path(path).absolute().parents:
84
+ if parent.name == ".runtime" and parent.parent.name == DIR_WORKFLOW:
85
+ return parent
86
+ return None
87
+
88
+
89
+ def ensure_runtime_gitignore(path: Path) -> None:
90
+ """Create the runtime self-ignore file once; never overwrite it."""
91
+ runtime_root = runtime_root_for(path)
92
+ if runtime_root is None:
93
+ return
94
+ ignore = runtime_root / ".gitignore"
95
+ if ignore.exists():
96
+ return
97
+ try:
98
+ runtime_root.mkdir(parents=True, exist_ok=True)
99
+ with ignore.open("x", encoding="utf-8", newline="\n") as handle:
100
+ handle.write(RUNTIME_IGNORE_TEXT)
101
+ except OSError:
102
+ return
103
+
104
+
80
105
  def generate_task_date_prefix() -> str:
81
106
  """Today's MM-DD task-directory prefix."""
82
107
  return datetime.now().strftime("%m-%d")
@@ -14,6 +14,8 @@ from datetime import datetime, timezone
14
14
  from pathlib import Path
15
15
  from typing import Iterator
16
16
 
17
+ from infra.paths import ensure_runtime_gitignore
18
+
17
19
 
18
20
  STATE_METADATA_KEY = "_state"
19
21
  LOCK_METADATA_SCHEMA_VERSION = 1
@@ -110,6 +112,7 @@ class StateStore:
110
112
  operation_id: str,
111
113
  ) -> StateSnapshot:
112
114
  target = Path(path)
115
+ ensure_runtime_gitignore(target)
113
116
  with self._lock(target):
114
117
  current = self._load_unlocked(target, missing_ok=True)
115
118
  if current.operation_id == operation_id:
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env python3
2
+ """Facts and guidance for a binding whose task directory vanished.
3
+
4
+ Both the host injection body and the CLI blockers render from this module so
5
+ a branch or worktree switch cannot describe the same fact two different ways.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+
11
+ MISSING_TASK_FACT = "task directory not found: {task_path}"
12
+ MISSING_TASK_NEXT_STEP = (
13
+ "the bound task may live on another branch or worktree; switch back to "
14
+ "that branch or rebind explicitly — do not create a duplicate task"
15
+ )
16
+
17
+
18
+ def missing_task_fact(task_path: str) -> str:
19
+ return MISSING_TASK_FACT.format(task_path=task_path)
20
+
21
+
22
+ def missing_task_blockers(task_path: str) -> list[str]:
23
+ return [missing_task_fact(task_path), MISSING_TASK_NEXT_STEP]
24
+
25
+
26
+ def missing_task_body(task_path: str) -> str:
27
+ return "\n".join(
28
+ [
29
+ f"Session 指向的任务目录不存在({task_path})。",
30
+ "不要自动创建重复任务:该任务可能在其他分支或 worktree;"
31
+ "先切回原分支,或显式重新绑定后再继续。",
32
+ ]
33
+ )
@@ -604,6 +604,102 @@ def _diagnostic_path(repo_root: Path, path: Path) -> str:
604
604
  return str(path)
605
605
 
606
606
 
607
+ def _git_path_list(repo_root: Path, args: list[str]) -> list[str] | None:
608
+ try:
609
+ result = subprocess.run(
610
+ ["git", *args],
611
+ cwd=repo_root,
612
+ capture_output=True,
613
+ text=True,
614
+ encoding="utf-8",
615
+ )
616
+ except OSError:
617
+ return None
618
+ if result.returncode != 0:
619
+ return None
620
+ return [line.strip() for line in result.stdout.splitlines() if line.strip()]
621
+
622
+
623
+ def _runtime_git_hygiene_issue(
624
+ *,
625
+ kind: str,
626
+ path: str,
627
+ message: str,
628
+ hint: str,
629
+ ) -> dict[str, str]:
630
+ return _issue(
631
+ code=f"RUNTIME-GIT-HYGIENE-{kind}",
632
+ severity="warning",
633
+ path=path,
634
+ message=message,
635
+ command_hint=hint,
636
+ contract="runtime-health:runtime-git-hygiene",
637
+ kind=kind.lower(),
638
+ hint=hint,
639
+ )
640
+
641
+
642
+ def check_runtime_git_hygiene(repo_root: Path) -> list[dict[str, str]]:
643
+ """Warn when runtime state is unignored or tracked by git."""
644
+ runtime = repo_root / ".cowork-flow" / ".runtime"
645
+ if not runtime.is_dir() or shutil.which("git") is None:
646
+ return []
647
+ pathspec = ["--", ".cowork-flow/.runtime"]
648
+ tracked = _git_path_list(repo_root, ["ls-files", *pathspec])
649
+ untracked = _git_path_list(
650
+ repo_root,
651
+ ["ls-files", "--others", "--exclude-standard", *pathspec],
652
+ )
653
+ if tracked is None or untracked is None:
654
+ return []
655
+
656
+ def state_files(paths: list[str]) -> list[str]:
657
+ return [p for p in paths if not p.endswith(".runtime/.gitignore")]
658
+
659
+ tracked = state_files(tracked)
660
+ untracked = state_files(untracked)
661
+ diagnostic = _diagnostic_path(repo_root, runtime)
662
+ issues: list[dict[str, str]] = []
663
+ if untracked:
664
+ issues.append(
665
+ _runtime_git_hygiene_issue(
666
+ kind="UNIGNORED",
667
+ path=diagnostic,
668
+ message=(
669
+ f"{len(untracked)} runtime state file(s) are not "
670
+ "git-ignored"
671
+ ),
672
+ hint=(
673
+ "run any lifecycle command to create "
674
+ ".cowork-flow/.runtime/.gitignore, or add "
675
+ ".cowork-flow/.runtime/ to .gitignore"
676
+ ),
677
+ )
678
+ )
679
+ if tracked:
680
+ issues.append(
681
+ _runtime_git_hygiene_issue(
682
+ kind="TRACKED",
683
+ path=diagnostic,
684
+ message=(
685
+ f"{len(tracked)} runtime state file(s) are tracked by git"
686
+ ),
687
+ hint="git rm -r --cached .cowork-flow/.runtime",
688
+ )
689
+ )
690
+ return issues
691
+
692
+
693
+ def _print_runtime_git_hygiene_issues(issues: list[dict[str, str]]) -> None:
694
+ for issue in issues:
695
+ print(
696
+ f"WARNING: runtime git hygiene: {issue['path']}: "
697
+ f"{issue['message']}",
698
+ file=sys.stderr,
699
+ )
700
+ print(f"Hint: {issue['hint']}", file=sys.stderr)
701
+
702
+
607
703
  def _state_lock_code(status: str) -> str:
608
704
  return f"STATE-RECOVERY-LOCK-{status.upper().replace('_', '-')}"
609
705
 
@@ -1852,6 +1948,7 @@ def _all_check_result(repo_root: Path) -> dict[str, object]:
1852
1948
  task_hygiene_issues = check_task_hygiene(repo_root)
1853
1949
  state_recovery_issues = check_state_recovery(repo_root)
1854
1950
  session_hygiene_issues = check_session_hygiene(repo_root)
1951
+ runtime_git_hygiene_issues = check_runtime_git_hygiene(repo_root)
1855
1952
  mcp_issues = check_mcp_registration(repo_root)
1856
1953
  dsh_preset_issues = check_dsh_preset(repo_root)
1857
1954
  kimi_hook_issues = check_kimi_hook(repo_root)
@@ -1887,6 +1984,7 @@ def _all_check_result(repo_root: Path) -> dict[str, object]:
1887
1984
  "taskHygiene": task_hygiene_issues,
1888
1985
  "stateRecovery": state_recovery_issues,
1889
1986
  "sessionHygiene": session_hygiene_issues,
1987
+ "runtimeGitHygiene": runtime_git_hygiene_issues,
1890
1988
  "mcpRegistration": mcp_issues,
1891
1989
  "dshPreset": dsh_preset_issues,
1892
1990
  "kimiHook": kimi_hook_issues,
@@ -1916,6 +2014,7 @@ def _run_checks(repo_root: Path, *, structured: bool = False) -> int:
1916
2014
  _print_task_hygiene_issues(result["issues"]["taskHygiene"])
1917
2015
  _print_state_recovery_issues(result["issues"]["stateRecovery"])
1918
2016
  _print_session_hygiene_issues(result["issues"]["sessionHygiene"])
2017
+ _print_runtime_git_hygiene_issues(result["issues"]["runtimeGitHygiene"])
1919
2018
  for issue in result["issues"]["mcpRegistration"]:
1920
2019
  print(f"MCP ({issue['status']}): {issue['message']}")
1921
2020
  for issue in result["issues"]["dshPreset"]: