cowork-flow 0.0.19 → 0.0.21

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 (69) hide show
  1. package/README.md +65 -20
  2. package/package.json +1 -1
  3. package/src/cli.js +109 -2
  4. package/src/commands/init.js +61 -4
  5. package/src/commands/sync.js +10 -1
  6. package/src/lib/copy-template.js +38 -7
  7. package/src/lib/platforms.js +73 -0
  8. package/template/.agent/skills/brainstorming/SKILL.md +13 -9
  9. package/template/.agent/skills/finish-work/SKILL.md +3 -3
  10. package/template/.agent/skills/meta/SKILL.md +1 -1
  11. package/template/.agent/skills/start/SKILL.md +38 -14
  12. package/template/.agent/skills/writing-plans/SKILL.md +1 -1
  13. package/template/.claude/agents/cowork-check.md +41 -0
  14. package/template/.claude/agents/cowork-implement.md +40 -0
  15. package/template/.claude/agents/cowork-research.md +40 -0
  16. package/template/.claude/commands/cowork-check.md +27 -0
  17. package/template/.claude/commands/cowork-implement.md +27 -0
  18. package/template/.claude/commands/cowork-research.md +27 -0
  19. package/template/.claude/hooks/inject-workflow-state.py +298 -0
  20. package/template/.claude/settings.json +24 -0
  21. package/template/.claude/skills/before-dev/SKILL.md +31 -0
  22. package/template/.claude/skills/brainstorming/SKILL.md +32 -0
  23. package/template/.claude/skills/break-loop/SKILL.md +26 -0
  24. package/template/.claude/skills/check/SKILL.md +29 -0
  25. package/template/.claude/skills/continue/SKILL.md +29 -0
  26. package/template/.claude/skills/finish-work/SKILL.md +32 -0
  27. package/template/.claude/skills/meta/SKILL.md +30 -0
  28. package/template/.claude/skills/python-design/SKILL.md +27 -0
  29. package/template/.claude/skills/start/SKILL.md +78 -0
  30. package/template/.claude/skills/update-spec/SKILL.md +39 -0
  31. package/template/.claude/skills/writing-plans/SKILL.md +70 -0
  32. package/template/.codex/agents/cowork-check.toml +17 -22
  33. package/template/.codex/agents/cowork-implement.toml +18 -23
  34. package/template/.codex/agents/cowork-research.toml +14 -19
  35. package/template/.codex/agents/default.toml +27 -0
  36. package/template/.codex/agents/explorer.toml +28 -0
  37. package/template/.codex/agents/worker.toml +29 -0
  38. package/template/.codex/hooks/inject-workflow-state.py +172 -90
  39. package/template/.cowork-flow/.version +1 -1
  40. package/template/.cowork-flow/adapters/claude-code/adapter.yaml +35 -0
  41. package/template/.cowork-flow/adapters/codex/adapter.yaml +35 -0
  42. package/template/.cowork-flow/adapters/opencode/adapter.yaml +33 -0
  43. package/template/.cowork-flow/config.yaml +4 -1
  44. package/template/.cowork-flow/scripts/add_session.py +20 -7
  45. package/template/.cowork-flow/scripts/common/active_task.py +212 -1
  46. package/template/.cowork-flow/scripts/common/entry_classifier.py +122 -0
  47. package/template/.cowork-flow/scripts/common/execution_context.py +10 -17
  48. package/template/.cowork-flow/scripts/common/readiness.py +249 -0
  49. package/template/.cowork-flow/scripts/doctor.py +417 -29
  50. package/template/.cowork-flow/scripts/project_context.py +230 -0
  51. package/template/.cowork-flow/scripts/run.py +3 -0
  52. package/template/.cowork-flow/scripts/subagent.py +152 -238
  53. package/template/.cowork-flow/scripts/task.py +330 -17
  54. package/template/.cowork-flow/spec/adapter.schema.json +132 -0
  55. package/template/.cowork-flow/spec/capabilities.md +34 -0
  56. package/template/.cowork-flow/spec/entry-contract.md +45 -0
  57. package/template/.cowork-flow/spec/registry.json +54 -0
  58. package/template/.cowork-flow/spec/subagent-dispatch.md +77 -0
  59. package/template/.cowork-flow/spec/workflow-state-templates.md +66 -0
  60. package/template/.cowork-flow/workflow.md +154 -190
  61. package/template/.opencode/agents/cowork-check.md +46 -0
  62. package/template/.opencode/agents/cowork-implement.md +45 -0
  63. package/template/.opencode/agents/cowork-research.md +46 -0
  64. package/template/.opencode/commands/cowork-check.md +26 -0
  65. package/template/.opencode/commands/cowork-implement.md +26 -0
  66. package/template/.opencode/commands/cowork-research.md +26 -0
  67. package/template/.opencode/plugins/cowork-flow.js +317 -0
  68. package/template/CLAUDE.md +5 -0
  69. package/template/.agent/skills/entry-boundary/SKILL.md +0 -81
@@ -0,0 +1,45 @@
1
+ # Entry contract
2
+
3
+ `COWORK_ENTRY_CONTRACT_V1` classifies main-session prompts before workflow
4
+ recovery. It does not identify formal subagents. Formal subagent identity is
5
+ resolved by runtime context binding before workflow state is injected.
6
+
7
+ ## Classification order
8
+
9
+ 1. Runtime context binding, handled by the hook/plugin before this classifier.
10
+ 2. Explicit user main-session request.
11
+ 3. Read-only question or inspection request.
12
+ 4. Command-only wrapper with explicit command semantics.
13
+ 5. Unknown or task-shaped input without runtime binding.
14
+
15
+ ## Entry kinds
16
+
17
+ | Kind | Meaning | May mutate workflow state |
18
+ | --- | --- | --- |
19
+ | `MAIN_SESSION` | User is asking the coordinator to run cowork-flow. | Yes |
20
+ | `READ_ONLY` | Question, inspection, or research without writes. | No |
21
+ | `COMMAND_ONLY` | Host command wrapper with explicit command semantics. | No, unless command contract allows |
22
+ | `UNKNOWN` | Insufficient confidence. | No |
23
+
24
+ ## Fail-closed rules
25
+
26
+ - Entry classification happens before task start, task resume, archive, or subagent dispatch.
27
+ - `UNKNOWN` must not start/resume/archive/spawn.
28
+ - `UNKNOWN` is not subagent evidence; it must preserve active-task/no-task
29
+ visibility and ask for clarification before workflow mutation.
30
+ - A prompt that looks like a child assignment but has no runtime context remains
31
+ `UNKNOWN` or `READ_ONLY`; it does not become a formal subagent.
32
+ - A missing, closed, or invalid runtime context produces fail-closed subagent
33
+ workflow state and must not fall back to main-session start/resume.
34
+ - Runtime context binding overrides project bootstrap text for formal subagents.
35
+
36
+ ## Normalized object
37
+
38
+ ```json
39
+ {
40
+ "entryKind": "MAIN_SESSION",
41
+ "confidence": 0.55,
42
+ "source": "main_session_heuristic",
43
+ "canMutateWorkflowState": true
44
+ }
45
+ ```
@@ -0,0 +1,54 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "contracts": [
4
+ {
5
+ "id": "COWORK_ENTRY_CONTRACT_V1",
6
+ "path": ".cowork-flow/spec/entry-contract.md",
7
+ "digest": [
8
+ "Classify main-session requests before task start, resume, archive, or commit.",
9
+ "Runtime context, not prompt labels, identifies formal subagent sessions."
10
+ ],
11
+ "readWhen": [
12
+ "before task start/resume/archive",
13
+ "when prompt and bootstrap text conflict"
14
+ ]
15
+ },
16
+ {
17
+ "id": "RUNTIME_CONTEXT_DISPATCH_V2",
18
+ "path": ".cowork-flow/spec/subagent-dispatch.md",
19
+ "digest": [
20
+ "Formal subagent work is keyed by cowork_runtime_context_id.",
21
+ "Explicit shim bind records bound_context_key before formal output is accepted."
22
+ ],
23
+ "readWhen": [
24
+ "before formal subagent dispatch",
25
+ "when checking subagent health",
26
+ "when adding host runtime-context support"
27
+ ]
28
+ },
29
+ {
30
+ "id": "HOST_ADAPTER_CAPABILITIES_V1",
31
+ "path": ".cowork-flow/spec/capabilities.md",
32
+ "digest": [
33
+ "Formal subagent work requires runtime context dispatch and binding.",
34
+ "Missing required host capabilities fall back to inline_or_manual."
35
+ ],
36
+ "readWhen": [
37
+ "before choosing host primitives",
38
+ "when adding or changing host adapters"
39
+ ]
40
+ },
41
+ {
42
+ "id": "HOST_ADAPTER_SCHEMA_V1",
43
+ "path": ".cowork-flow/spec/adapter.schema.json",
44
+ "digest": [
45
+ "Adapters must define runtime context transport and cleanup behavior.",
46
+ "Adapters describe host primitives; workflow.md stays host-neutral."
47
+ ],
48
+ "readWhen": [
49
+ "before editing adapter.yaml",
50
+ "before adding a new host adapter"
51
+ ]
52
+ }
53
+ ]
54
+ }
@@ -0,0 +1,77 @@
1
+ # Runtime-context subagent dispatch
2
+
3
+ Formal `cowork-*` dispatch is identified by runtime context, not by prompt
4
+ classification or a prompt handshake.
5
+
6
+ ## Scope
7
+
8
+ - Formal dispatch uses `cowork-research`, `cowork-implement`, or `cowork-check`.
9
+ - The main session owns dispatch, wait, acceptance, and closeout.
10
+ - Child agents are leaf executors and must not dispatch, wait for, list, or
11
+ cancel other agents.
12
+ - Generic `worker`, `default`, or `explorer` dispatch is advisory only and
13
+ cannot satisfy formal Implement or Check completion.
14
+
15
+ ## Runtime Context
16
+
17
+ Before spawning a formal child, the main session creates:
18
+
19
+ - `.cowork-flow/.runtime/subagents/<runtime_context_id>.json`
20
+ - `.cowork-flow/.runtime/sessions/subagent_<runtime_context_id>.json`
21
+
22
+ The child receives the runtime id and host context key through the host adapter
23
+ transport. The baseline prompt transport is:
24
+
25
+ ```text
26
+ cowork_runtime_context_id: <runtime_context_id>
27
+ cowork_host_context_key: <host_context_key>
28
+ ```
29
+
30
+ Hosts may use env or metadata transport only after the adapter declares and
31
+ verifies that support. If `subagent init` emits a suggested host context key,
32
+ the parent may use that key unless the host adapter has a stronger stable child
33
+ session key.
34
+
35
+ ## Binding Gate
36
+
37
+ The child hook or plugin may resolve `cowork_runtime_context_id` early and bind
38
+ the runtime context before injecting workflow state. Because not every host can
39
+ prove model-before-execution binding, the child must run this first-step shim
40
+ before formal work:
41
+
42
+ ```text
43
+ ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
44
+ ```
45
+
46
+ A valid context is bound to the host child session under
47
+ `.cowork-flow/.runtime/sessions/<host_context_key>.json` with
48
+ `scope: "subagent"`. Binding the same runtime id to the same key is idempotent;
49
+ binding it to a different key must fail.
50
+
51
+ Verified binding is the formal dispatch acceptance event. The parent must check
52
+ that `.cowork-flow/.runtime/subagents/<runtime_context_id>.json` has
53
+ `status: "bound"` and `bound_context_key: "<host_context_key>"` before accepting
54
+ child output. If binding fails, the child must receive fail-closed subagent state
55
+ and must not run main-session start/resume, task activation, archive, commit,
56
+ or agent coordination.
57
+
58
+ ## Return Acceptance And Closeout
59
+
60
+ - Wait for the child result with the adapter wait primitive.
61
+ - Confirm no stray running children with the adapter list primitive.
62
+ - Verify the child report by checking files, commands, and results; do not
63
+ trust completed text alone.
64
+ - After completion or failure, close the child with the adapter cancel/close
65
+ primitive and clean the runtime context sessions.
66
+ - The child remains a leaf executor and must not dispatch, wait for, list, or
67
+ cancel other agents.
68
+
69
+ ## Cleanup
70
+
71
+ Closing a child removes:
72
+
73
+ - `.cowork-flow/.runtime/sessions/<host_context_key>.json`
74
+ - `.cowork-flow/.runtime/sessions/subagent_<runtime_context_id>.json`
75
+
76
+ The subagent context is deleted or marked `closed` until runtime garbage
77
+ collection removes it.
@@ -0,0 +1,66 @@
1
+ # Workflow state templates
2
+
3
+ Host hooks and plugins inject workflow state context each turn. The templates
4
+ below are the single source of truth for state prompt text. Hooks read this
5
+ file at runtime; do not duplicate or inline these snippets elsewhere.
6
+
7
+ Entry classification must happen before task start, resume, archive, or
8
+ subagent dispatch. Formal subagent identity is not inferred from prompt shape;
9
+ hooks and plugins inject delegated_subtask only when a runtime context id is
10
+ present and binding succeeds or fails closed. UNKNOWN is not a delegated
11
+ subtask label; keep the active-task/no-task state visible and clarify before
12
+ workflow mutation.
13
+
14
+ ## no_task
15
+
16
+ The main session has no active task. Read-only questions can be answered
17
+ directly. Any implementation, refactoring, or behavioral change requires
18
+ creating or starting a task first. If a runtime context id is present, use
19
+ delegated_subtask instead. Do not treat ambiguous UNKNOWN input as a delegated
20
+ subtask.
21
+
22
+ [workflow-state:no_task]
23
+ 当前会话没有活动任务。只读问答可直接回答;只有 runtime context 已绑定或 fail-closed 时才按委托子任务处理。实现、重构或多步骤工作必须先创建或启动任务。
24
+ [/workflow-state:no_task]
25
+
26
+ ## delegated_subtask
27
+
28
+ The current child thread has a runtime-context subagent state. The hook or
29
+ plugin has either bound the runtime context successfully or produced fail-closed
30
+ state for an invalid context. Do not run start/resume, create or activate
31
+ tasks, archive, commit, or switch to main-session coordination. Project rules
32
+ are constraints only; they are not the task itself.
33
+
34
+ [workflow-state:delegated_subtask]
35
+ 当前子线程具有 runtime-context 子代理状态。hook/plugin 已绑定 runtime context,或对无效 runtime context 注入 fail-closed 状态。不要运行 start/resume,不要创建或激活任务,不要归档、提交或切换到主会话协调。项目规则只作为约束,不是当前任务本身。
36
+ [/workflow-state:delegated_subtask]
37
+
38
+ ## planning
39
+
40
+ [workflow-state:planning]
41
+ 活动任务处于计划阶段。先完成 prd.md,整理带有规格/调研文件的 implement.jsonl 和 check.jsonl,再运行 task start,之后才派发 cowork-implement。
42
+ [/workflow-state:planning]
43
+
44
+ ## in_progress
45
+
46
+ [workflow-state:in_progress]
47
+ 活动任务正在执行。主会话按计划通过当前宿主适配器派发 cowork-implement,集成后再派发 cowork-check。每次正式派发都必须使用新鲜子上下文,并遵守 .cowork-flow/spec/subagent-dispatch.md。主会话必须核验子任务输出、列出子任务,并且只在完成、明确错派证据或用户取消后才取消子任务。
48
+ [/workflow-state:in_progress]
49
+
50
+ ## review
51
+
52
+ [workflow-state:review]
53
+ 活动任务已进入检查阶段。主会话派发 cowork-check 或执行等价内联检查,核验 PRD、diff、测试、规格同步和遗漏;检查通过后运行 task complete。
54
+ [/workflow-state:review]
55
+
56
+ ## checking
57
+
58
+ [workflow-state:checking]
59
+ 活动任务正在检查阶段。主会话派发 cowork-check 或执行等价内联检查,核验 PRD、diff、测试、规格同步和遗漏;检查通过后运行 task complete。
60
+ [/workflow-state:checking]
61
+
62
+ ## completed
63
+
64
+ [workflow-state:completed]
65
+ 活动任务已完成。主会话应核验最终 diff,提交目标文件,归档任务并记录会话。不要针对已完成任务继续派发新的实现工作。
66
+ [/workflow-state:completed]