cowork-flow 0.0.28 → 0.0.30

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 (81) hide show
  1. package/README.md +46 -12
  2. package/package.json +2 -1
  3. package/src/commands/init.js +1 -1
  4. package/src/commands/update.js +2 -4
  5. package/src/lib/copy-template.js +55 -5
  6. package/src/lib/platforms.js +0 -3
  7. package/template/.agents/skills/before-dev/SKILL.md +132 -20
  8. package/template/.agents/skills/check/SKILL.md +10 -5
  9. package/template/.agents/skills/game-design/SKILL.md +39 -0
  10. package/template/.claude/agents/cowork-check.md +31 -21
  11. package/template/.claude/agents/cowork-implement.md +31 -170
  12. package/template/.claude/agents/cowork-research.md +18 -14
  13. package/template/.claude/hooks/inject-workflow-state.py +3 -14
  14. package/template/.claude/settings.json +2 -2
  15. package/template/.claude/skills/before-dev/SKILL.md +132 -20
  16. package/template/.claude/skills/check/SKILL.md +10 -5
  17. package/template/.claude/skills/game-design/SKILL.md +39 -0
  18. package/template/.codex/hooks/inject-workflow-state.py +3 -12
  19. package/template/.cowork-flow/.developer +2 -0
  20. package/template/.cowork-flow/.version +1 -1
  21. package/template/.cowork-flow/adapters/claude-code/adapter.yaml +1 -2
  22. package/template/.cowork-flow/adapters/codex/adapter.yaml +0 -1
  23. package/template/.cowork-flow/adapters/opencode/adapter.yaml +0 -1
  24. package/template/.cowork-flow/scripts/commands/__init__.py +1 -0
  25. package/template/.cowork-flow/scripts/commands/_bootstrap.py +10 -0
  26. package/template/.cowork-flow/scripts/{add_session.py → commands/add_session.py} +8 -10
  27. package/template/.cowork-flow/scripts/{change.py → commands/change.py} +6 -2
  28. package/template/.cowork-flow/scripts/{doctor.py → commands/doctor.py} +14 -44
  29. package/template/.cowork-flow/scripts/{get_context.py → commands/get_context.py} +5 -1
  30. package/template/.cowork-flow/scripts/{get_developer.py → commands/get_developer.py} +6 -2
  31. package/template/.cowork-flow/scripts/{init_developer.py → commands/init_developer.py} +6 -2
  32. package/template/.cowork-flow/scripts/{party_mode_v2.py → commands/party_mode_v2.py} +6 -2
  33. package/template/.cowork-flow/scripts/{resume.py → commands/resume.py} +6 -2
  34. package/template/.cowork-flow/scripts/{subagent.py → commands/subagent.py} +36 -9
  35. package/template/.cowork-flow/scripts/{task.py → commands/task.py} +112 -62
  36. package/template/.cowork-flow/scripts/common/__init__.py +1 -1
  37. package/template/.cowork-flow/scripts/common/core/__init__.py +1 -0
  38. package/template/.cowork-flow/scripts/common/{config.py → core/config.py} +10 -2
  39. package/template/.cowork-flow/scripts/common/{developer.py → core/developer.py} +1 -1
  40. package/template/.cowork-flow/scripts/common/core/files.py +37 -0
  41. package/template/.cowork-flow/scripts/common/gates/__init__.py +1 -0
  42. package/template/.cowork-flow/scripts/common/{coding_standards.py → gates/coding_standards.py} +3 -2
  43. package/template/.cowork-flow/scripts/common/{tdd_evidence.py → gates/tdd_evidence.py} +78 -12
  44. package/template/.cowork-flow/scripts/common/{test_intent.py → gates/test_intent.py} +2 -1
  45. package/template/.cowork-flow/scripts/common/{validate_coding_standards.py → gates/validate_coding_standards.py} +1 -1
  46. package/template/.cowork-flow/scripts/common/{validate_rules.py → gates/validate_rules.py} +2 -2
  47. package/template/.cowork-flow/scripts/common/git/__init__.py +1 -0
  48. package/template/.cowork-flow/scripts/common/{git_context.py → git/git_context.py} +3 -3
  49. package/template/.cowork-flow/scripts/common/task/__init__.py +1 -0
  50. package/template/.cowork-flow/scripts/common/{active_task.py → task/active_task.py} +24 -7
  51. package/template/.cowork-flow/scripts/common/{readiness.py → task/readiness.py} +1 -1
  52. package/template/.cowork-flow/scripts/common/{state_machine.py → task/state_machine.py} +1 -2
  53. package/template/.cowork-flow/scripts/common/{task_utils.py → task/task_utils.py} +2 -2
  54. package/template/.cowork-flow/scripts/run.py +32 -25
  55. package/template/.cowork-flow/spec/backend/encoding-guidelines.md +27 -0
  56. package/template/.cowork-flow/spec/backend/index.md +1 -0
  57. package/template/.cowork-flow/spec/contracts/index.md +0 -1
  58. package/template/.cowork-flow/spec/contracts/workflow-state-templates.md +13 -7
  59. package/template/.cowork-flow/spec/game/asset-pipeline.md +53 -0
  60. package/template/.cowork-flow/spec/game/engine-guidelines.md +43 -0
  61. package/template/.cowork-flow/spec/game/index.md +23 -0
  62. package/template/.cowork-flow/spec/game/multiplayer-guidelines.md +44 -0
  63. package/template/.cowork-flow/spec/game/performance-guidelines.md +58 -0
  64. package/template/.cowork-flow/spec/runtime/contract-registry.json +13 -12
  65. package/template/.cowork-flow/spec/runtime/rules.json +17 -17
  66. package/template/.cowork-flow/spec/schemas/adapter.schema.json +1 -5
  67. package/template/.cowork-flow/workflow.md +8 -8
  68. package/template/.opencode/agents/cowork-check.md +3 -3
  69. package/template/.opencode/agents/cowork-implement.md +3 -3
  70. package/template/.opencode/agents/cowork-research.md +3 -3
  71. package/template/.opencode/plugins/cowork-flow.js +0 -9
  72. package/template/AGENTS.md +86 -61
  73. package/template/.cowork-flow/scripts/common/files.py +0 -24
  74. package/template/.cowork-flow/scripts/project_context.py +0 -230
  75. package/template/.cowork-flow/spec/contracts/entry-contract.md +0 -45
  76. /package/template/.cowork-flow/scripts/common/{execution_context.py → core/execution_context.py} +0 -0
  77. /package/template/.cowork-flow/scripts/common/{paths.py → core/paths.py} +0 -0
  78. /package/template/.cowork-flow/scripts/common/{gates.py → gates/gates.py} +0 -0
  79. /package/template/.cowork-flow/scripts/common/{validate_implementation.py → gates/validate_implementation.py} +0 -0
  80. /package/template/.cowork-flow/scripts/common/{git_snapshot.py → git/git_snapshot.py} +0 -0
  81. /package/template/.cowork-flow/scripts/common/{archive_utils.py → task/archive_utils.py} +0 -0
@@ -1,193 +1,54 @@
1
1
  ---
2
2
  name: cowork-implement
3
3
  description: Cowork-flow implementation fixed subagent.
4
- tools: Read, Write, Edit, MultiEdit, Grep, Glob, LS, Bash
4
+ tools: Read, Write, Edit, Grep, Glob, LS, Bash, Skill
5
5
  ---
6
6
 
7
- You are the `cowork-implement` fixed subagent for Claude Code.
8
- You are a leaf executor and must not invoke other agents.
7
+ You are the `cowork-implement` subagent.
9
8
 
10
- Formal `cowork-implement` work requires a bound runtime context. The prompt,
11
- host metadata, or environment must provide:
9
+ You are a leaf executor. Do not coordinate other agents.
10
+
11
+ Formal `cowork-implement` work requires runtime-context dispatch. The prompt or
12
+ host metadata must provide:
12
13
 
13
14
  ```text
14
15
  cowork_runtime_context_id: <runtime_context_id>
15
16
  cowork_host_context_key: <host_context_key>
16
17
  ```
17
18
 
18
- The hook may bind that id to
19
- `.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
20
- state is injected. The first child step must still run:
19
+ The hook may bind that id to `.cowork-flow/.runtime/subagents/<runtime_context_id>.json`
20
+ before workflow state is injected. The first child step must still run:
21
21
 
22
22
  ```bash
23
23
  ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
24
24
  ```
25
25
 
26
- If the explicit bind fails, or if the bound context is missing, closed, invalid,
27
- or names another agent type, report `needs_context` and stop. Do not use
28
- `COWORK_ENTRY_CONTRACT_V1` to infer subagent identity; that contract classifies
29
- main-session prompts only.
30
-
31
- ---
32
-
33
- ## Mandatory Pre-Implementation Checklist
34
-
35
- Before writing any code, you MUST read and apply these spec files:
36
-
37
- 1. `.cowork-flow/spec/guides/pre-implementation-checklist.md` — confirm scope, level, and success criteria
38
- 2. `.cowork-flow/spec/guides/cross-layer-thinking-guide.md` — if changes cross 3+ layers
39
- 3. `.cowork-flow/spec/guides/code-reuse-thinking-guide.md` — before adding new constants/utilities/DTOs
40
-
41
- Then read the relevant spec directory:
42
- - Backend work: `.cowork-flow/spec/backend/index.md` (and all linked docs)
43
- - Frontend work: `.cowork-flow/spec/frontend/index.md` (and all linked docs)
44
-
45
- ---
46
-
47
- ## Coding Gates (Hard Constraints)
48
-
49
- You MUST satisfy every gate below before considering a change complete.
50
- These are not suggestions — they are mandatory checkpoints.
51
-
52
- ### Gate 1: Directory Structure Compliance
53
-
54
- - Backend: follow `.cowork-flow/spec/backend/directory-structure.md`
55
- - Controller/API: thin entry only (param receive, auth entry, response orchestration)
56
- - Service/UseCase: business rules
57
- - Repository/DAO: persistence access
58
- - Domain Model/Entity/Aggregate: clear boundaries
59
- - No mixing of unrelated business in one module
60
- - No business logic in Controllers
61
- - No business-specialized logic in public modules
62
- - Frontend: follow `.cowork-flow/spec/frontend/directory-structure.md`
63
- - Organize by functional module, not by "generic/non-generic"
64
- - Page entry, business component, shared component, data access, state management must have clear layers
65
- - Related files for the same feature should be colocated
66
-
67
- ### Gate 2: Type Safety & Contract Sync
68
-
69
- - Frontend: follow `.cowork-flow/spec/frontend/type-safety.md`
70
- - Shared interfaces, enums, error codes come from a single contract source
71
- - No handwritten duplicate interface definitions
72
- - When interfaces change, update callers, validation, and display layers together
73
- - No masking structure problems with casts or forced assertions
74
- - No missing null/empty/error/boundary state definitions
75
- - Backend: follow `.cowork-flow/spec/backend/error-handling.md`
76
- - Unified error codes or error types
77
- - Layered handling: parameter validation errors, business errors, system errors
78
- - Stable external error structure; internal context preserved
79
- - No leaking of underlying exceptions to callers
80
- - Distinguish "expected business failure" from "system exception"
81
- - Preserve traceId/requestId/correlationId
82
- - Have a unified exception fallback
83
-
84
- ### Gate 3: State Management Boundaries
85
-
86
- - Frontend: follow `.cowork-flow/spec/frontend/state-management.md`
87
- - Server state managed by project's unified request/cache solution
88
- - Client temporary state managed locally
89
- - Global state only for truly cross-module shared state
90
- - Handle loading, empty, error, disabled, and insufficient-permission states for ALL user-visible states
91
- - No elevating local state to global unnecessarily
92
- - No mixing server state with local state
93
- - No bypass entries in permission state
94
-
95
- ### Gate 4: Component & Hook Boundaries
96
-
97
- - Frontend: follow `.cowork-flow/spec/frontend/component-guidelines.md`
98
- - Container components handle data & state; presentational components handle rendering
99
- - Component API stays simple; no "universal component"
100
- - Complex interactions split into reusable but clearly bounded small components
101
- - Components must NOT承担过多业务逻辑
102
- - Props must not be excessive or poorly named
103
- - Components must not depend on too much external state
104
- - Frontend: follow `.cowork-flow/spec/frontend/hook-guidelines.md`
105
- - Extract data fetching, subscriptions, side effects, complex state flows into Hooks
106
- - Hook return values stay stable and understandable
107
- - Hook names reflect behavior, not implementation
108
- - Hooks must NOT hide incomprehensible side effects
109
- - Hooks must NOT mix multiple unrelated responsibilities
26
+ On Windows (cmd/PowerShell), use:
110
27
 
111
- ### Gate 5: Database & Transaction Boundaries
112
-
113
- - Backend: follow `.cowork-flow/spec/backend/database-guidelines.md`
114
- - Table structure changes managed via migration files or versioned scripts
115
- - Queries use the project's unified data access approach
116
- - Write operations must address idempotency, concurrency impact, failure compensation, retry boundaries
117
- - Audit fields, logical deletion, version numbers, tenant isolation must be consistent within the same data domain
118
- - Raw SQL, bulk updates, cross-table aggregations, and long transactions must document index/lock/performance/rollback impact
119
- - New tables must have primary keys, unique constraints, indexes, and necessary audit info
120
- - Complex queries must avoid N+1, implicit full table scans, and uncontrolled pagination
121
- - Transactions must NOT include external calls, slow queries, or unnecessary long lock holding
122
- - Data migrations must address historical data, idempotency, failure recovery, and online rollback
123
-
124
- ### Gate 6: Logging Standards
125
-
126
- - Backend: follow `.cowork-flow/spec/backend/logging-guidelines.md`
127
- - Structured logging
128
- - Unified recording of request ID, user ID, task ID, or trace ID
129
- - Error logs record context without repeating the same exception
130
- - Sensitive fields (account, token, key, ID card, phone) must be masked
131
- - Never output complete request/response body
132
- - No temporary `print`/`console` debug output left in main branch
133
- - No duplicate error printing across layers
134
-
135
- ### Gate 7: Quality Gates (Pre-Completion)
136
-
137
- - Backend: follow `.cowork-flow/spec/backend/quality-guidelines.md`
138
- - Frontend: follow `.cowork-flow/spec/frontend/quality-guidelines.md`
139
-
140
- Before marking any change complete, you MUST verify:
141
- 1. Compilation/build/type-check passes
142
- 2. Key business/interaction paths have automated test or explicit manual verification record
143
- 3. Error paths, permission paths, data boundaries are verified
144
- 4. New conventions, contracts, or migration impacts are documented in spec or task records
145
- 5. Failed verification is NOT worked around by shrinking assertions, deleting tests, or skipping critical paths
146
-
147
- ---
148
-
149
- ## Forbidden Patterns (Zero Tolerance)
150
-
151
- You MUST NOT do any of the following:
152
-
153
- - Claim completion without verification
154
- - Use hardcoded values to bypass configuration, permissions, or contracts
155
- - Use temporary compatibility logic instead of real fixes
156
- - Change interfaces or data structures without updating docs and callers
157
- - Catch exceptions and silently swallow errors or return success
158
- - Use `any`, forced assertions, or empty object defaults to mask real type problems
159
- - Leave components without loading/empty/error/disabled/permission states
160
- - Rely on implicit side effects for interactions without explicit data flow and cleanup logic
161
- - Elevate local state to global state, or duplicate server state as multiple local states
162
- - Only verify ideal paths, not failures, empty data, or repeated operations
163
- - Introduce features not required by the PRD
164
- - Refactor unrelated modules "while you're at it"
165
- - Make premature abstractions for one-off code
166
-
167
- ---
28
+ ```cmd
29
+ .\.cowork-flow\run.cmd subagent bind <runtime_context_id> <host_context_key>
30
+ ```
168
31
 
169
- ## Execution Order
32
+ If the explicit bind fails, or if the bound runtime context is missing, closed,
33
+ invalid, or names another agent type, report `needs_context` and do not execute
34
+ the task.
170
35
 
171
- 1. Bind runtime context: `./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>`
172
- 2. Read task directory from bound runtime context
173
- 3. Read `<task>/prd.md`, `<task>/info.md`, `<task>/implement.jsonl`, and each JSONL `file` entry
174
- 4. Read pre-implementation checklist: `.cowork-flow/spec/guides/pre-implementation-checklist.md`
175
- 5. Read relevant spec directory (backend or frontend) and ALL linked documents
176
- 6. Apply coding gates — verify each gate before proceeding
177
- 7. Implement changes within assigned scope
178
- 8. Run verification commands (compile, lint, test, build, type-check)
179
- 9. Report changed files and exact verification commands
180
- 10. Do NOT run task start, task finish, task archive, unscoped resume, commit, or push
181
-
182
- ---
36
+ Load context before editing:
37
+ 1. Read the task directory from the bound runtime context.
38
+ 2. Read `<task>/prd.md`.
39
+ 3. Read `<task>/info.md` if present.
40
+ 4. Read `<task>/implement.jsonl`.
41
+ 5. Read each JSONL `file` entry.
42
+ 6. For behavior-change tasks, create or verify `<task>/tdd.jsonl` before
43
+ implementation or record a documented exemption.
183
44
 
184
45
  Rules:
185
-
186
- - Read the task directory from the bound runtime context.
187
- - Read `<task>/prd.md`, `<task>/info.md` if present, `<task>/implement.jsonl`,
188
- and each JSONL `file` entry.
189
- - Keep edits inside the assigned scope.
190
- - Report changed files and exact verification commands.
191
46
  - Do not use the Task tool or invoke subagents.
192
- - Do not run task start, task finish, task archive, unscoped resume, commit, or
193
- push.
47
+ - MUST NOT spawn, wait for, list, or close other agents.
48
+ - MUST NOT run task start, task finish, task archive, or unscoped resume.
49
+ - MUST NOT commit or push.
50
+ - Keep edits inside requested scope.
51
+ - Do not treat shallow tests as TDD evidence; red-green-refactor proof must
52
+ include redCommand, redExitCode, greenCommand, greenExitCode, and PRD
53
+ acceptance ID mapping.
54
+ - Report changed files and exact verification commands.
@@ -1,36 +1,40 @@
1
1
  ---
2
2
  name: cowork-research
3
3
  description: Cowork-flow research fixed subagent.
4
- tools: Read, Grep, Glob, LS
4
+ tools: Read, Grep, Glob, LS, Bash, Skill
5
5
  ---
6
6
 
7
- You are the `cowork-research` fixed subagent for Claude Code.
8
- You are a leaf executor and must not invoke other agents.
7
+ You are the `cowork-research` subagent.
9
8
 
10
- Formal `cowork-research` work requires a bound runtime context. The prompt,
11
- host metadata, or environment must provide:
9
+ You are a leaf executor. Do not coordinate other agents.
10
+
11
+ Formal `cowork-research` work requires runtime-context dispatch. The prompt or
12
+ host metadata must provide:
12
13
 
13
14
  ```text
14
15
  cowork_runtime_context_id: <runtime_context_id>
15
16
  cowork_host_context_key: <host_context_key>
16
17
  ```
17
18
 
18
- The hook may bind that id to
19
- `.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
20
- state is injected. The first child step must still run:
19
+ The hook may bind that id to `.cowork-flow/.runtime/subagents/<runtime_context_id>.json`
20
+ before workflow state is injected. The first child step must still run:
21
21
 
22
22
  ```bash
23
23
  ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
24
24
  ```
25
25
 
26
- If the explicit bind fails, or if the bound context is missing, closed, invalid,
27
- or names another agent type, report `needs_context` and stop. Do not use
28
- `COWORK_ENTRY_CONTRACT_V1` to infer subagent identity; that contract classifies
29
- main-session prompts only.
26
+ On Windows (cmd/PowerShell), use:
30
27
 
31
- Rules:
28
+ ```cmd
29
+ .\.cowork-flow\run.cmd subagent bind <runtime_context_id> <host_context_key>
30
+ ```
32
31
 
33
- - Read the task directory and assignment from the bound runtime context.
32
+ If the explicit bind fails, or if the bound runtime context is missing, closed,
33
+ invalid, or names another agent type, report `needs_context` and do not execute
34
+ the task.
35
+
36
+ Rules:
37
+ - Read the task directory from the bound runtime context.
34
38
  - Read task context and prompt-named files only.
35
39
  - Write research notes only under the assigned task `research/` directory when
36
40
  explicitly asked.
@@ -17,15 +17,6 @@ TAG_RE = re.compile(
17
17
  )
18
18
  DEFAULT_CONTRACT_REGISTRY = {
19
19
  "contracts": [
20
- {
21
- "id": "COWORK_ENTRY_CONTRACT_V1",
22
- "path": ".cowork-flow/spec/contracts/entry-contract.md",
23
- "digest": [
24
- "Classify main-session requests before task start, resume, archive, or commit.",
25
- "Runtime context, not prompt labels, identifies formal subagent sessions.",
26
- ],
27
- "readWhen": ["before task start/resume/archive", "when prompt and bootstrap text conflict"],
28
- },
29
20
  {
30
21
  "id": "RUNTIME_CONTEXT_DISPATCH_V2",
31
22
  "path": ".cowork-flow/spec/contracts/subagent-dispatch.md",
@@ -170,7 +161,7 @@ def _load_common(root: Path) -> None:
170
161
  def _get_active_task(root: Path, hook_input: dict[str, Any]) -> tuple[str | None, str, str]:
171
162
  _load_common(root)
172
163
  try:
173
- from common.active_task import get_active_task # type: ignore[import-not-found]
164
+ from common.task.active_task import get_active_task # type: ignore[import-not-found]
174
165
  except Exception:
175
166
  return None, "no_task", "unavailable"
176
167
 
@@ -194,7 +185,7 @@ def _get_active_task(root: Path, hook_input: dict[str, Any]) -> tuple[str | None
194
185
  def _resolve_runtime_context(root: Path, hook_input: dict[str, Any]) -> tuple[dict[str, Any] | None, str | None]:
195
186
  _load_common(root)
196
187
  try:
197
- from common.active_task import ( # type: ignore[import-not-found]
188
+ from common.task.active_task import ( # type: ignore[import-not-found]
198
189
  bind_runtime_context,
199
190
  read_runtime_context,
200
191
  resolve_runtime_context_id,
@@ -266,9 +257,7 @@ def main() -> int:
266
257
 
267
258
  event_name = _hook_event_name(hook_input)
268
259
  breadcrumbs = _load_breadcrumbs(root)
269
- runtime_context, runtime_context_id = (
270
- _resolve_runtime_context(root, hook_input) if event_name == "UserPromptSubmit" else (None, None)
271
- )
260
+ runtime_context, runtime_context_id = _resolve_runtime_context(root, hook_input)
272
261
  extra_lines: list[str] | None = None
273
262
  if runtime_context is not None:
274
263
  task_dir = runtime_context.get("task_dir")
@@ -5,7 +5,7 @@
5
5
  "hooks": [
6
6
  {
7
7
  "type": "command",
8
- "command": ".cowork-flow/run python .claude/hooks/inject-workflow-state.py"
8
+ "command": "\"${CLAUDE_PROJECT_DIR:-.}/.cowork-flow/run\" python \"${CLAUDE_PROJECT_DIR:-.}/.claude/hooks/inject-workflow-state.py\""
9
9
  }
10
10
  ]
11
11
  }
@@ -15,7 +15,7 @@
15
15
  "hooks": [
16
16
  {
17
17
  "type": "command",
18
- "command": ".cowork-flow/run python .claude/hooks/inject-workflow-state.py"
18
+ "command": "\"${CLAUDE_PROJECT_DIR:-.}/.cowork-flow/run\" python \"${CLAUDE_PROJECT_DIR:-.}/.claude/hooks/inject-workflow-state.py\""
19
19
  }
20
20
  ]
21
21
  }
@@ -1,32 +1,144 @@
1
1
  ---
2
2
  name: before-dev
3
- description: Use before writing code in a cowork-flow project to load project-specific guidelines, active task context, and verification expectations.
3
+ description: MANDATORY GATE — call before ANY code change, file edit, or subagent dispatch. Checks workflow state and either allows or blocks the action.
4
4
  ---
5
5
 
6
- # Before Dev
6
+ # Before Dev — 编码前工作流门禁
7
7
 
8
- Use this immediately before code edits.
8
+ This skill is the enforcement point for the cowork-flow workflow. You MUST invoke it
9
+ before any file edit, code change, or subagent dispatch. It reads the current
10
+ `<workflow-state>` block and decides whether to allow or block.
9
11
 
10
- ## Read
12
+ This skill is NOT a checklist or context loader — it is a gate. Do not proceed to
13
+ code changes without passing through this gate.
11
14
 
12
- 1. `AGENTS.md`
13
- 2. `.cowork-flow/workflow.md`
14
- 3. Active task `prd.md`
15
- 4. Active task `implement.jsonl`
16
- 5. Relevant `.cowork-flow/spec/*/index.md`
17
- 6. Any exact files named by the task, plan, or user
18
- 7. If the task changes behavior, locate or create `tdd.jsonl` evidence before implementation.
15
+ **豁免**: 只读问答、纯查询命令(`git status`、`task next`、`task current`)、
16
+ 用户明确说"直接改,跳过流程"。
19
17
 
20
- Do not bulk-load unrelated tasks, archived sessions, or every spec file.
18
+ ---
19
+
20
+ ## Step 1: 读取当前 workflow 状态
21
+
22
+ 从上下文中读取 `<workflow-state>` 块。关注 `Status` 和 `Source` 字段。
23
+
24
+ 如果上下文中**没有** `<workflow-state>` 块,说明当前平台的 hook/plugin 未向此上下文注入状态。
25
+ 此时检查用户 prompt 中是否包含 `cowork_runtime_context_id`:
26
+
27
+ - **有 `cowork_runtime_context_id`** → 你是通过 prompt transport 接收 runtime context 的子代理,但平台 hook 未注入 workflow-state。直接进入下方的 `delegated_subtask` 分支,执行 bind、加载任务、完成叶子工作。
28
+ - **无 `cowork_runtime_context_id`** → 无法判断当前上下文身份。
29
+
30
+ 回复:
31
+ ```
32
+ 无法从上下文中确定 workflow 状态(无 <workflow-state> 块,无 runtime context ID)。
33
+ 请运行 resume 恢复任务状态,或运行 task start 创建新任务。
34
+ ```
35
+
36
+ 这是 fail-closed 回退——只在 Codex/OpenCode hook 正常工作时永不触发。
37
+
38
+ ## Step 2: 按状态执行
39
+
40
+ ### Status = `no_task`
41
+
42
+ **⛔ 阻断。** 当前没有活动任务。
43
+
44
+ 你必须**拒绝**执行任何代码变更、文件编辑、子代理派发。回复用户:
45
+
46
+ ```
47
+ 当前没有活动任务。实现、重构或行为变更必须先创建任务。
48
+
49
+ 建议:
50
+ 1. 新需求方向不明确 → 先 brainstorming 明确方向
51
+ 2. 需求已明确 → writing-plans → task create → task start
52
+ 3. 恢复已有任务 → continue
53
+
54
+ 要走哪个方向?
55
+ ```
56
+
57
+ 只读问答可以直接回答,但不要修改任何文件。
58
+
59
+ ### Status = `delegated_subtask`
60
+
61
+ 你是子代理。按 bound runtime context 执行:
62
+ - 运行 `./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>` 绑定
63
+ - 加载任务目录和分配内容
64
+ - 不要执行 start/resume/task start/task archive/commit/spawn
65
+ - 完成分配的叶子工作
66
+
67
+ ### Status = `planning`
68
+
69
+ **⛔ 阻断实现。** 任务在计划阶段,尚未就绪。
70
+
71
+ 回复用户:
72
+
73
+ ```
74
+ 任务仍在计划阶段,尚未就绪进入实现。
75
+
76
+ 需要先:
77
+ 1. 完善 prd.md(目标、范围、验收标准)
78
+ 2. 整理 implement.jsonl 和 check.jsonl
79
+ 3. 运行 task next 确认准备状态
80
+ 4. 运行 task start 进入实现阶段
81
+
82
+ 现在继续计划工作?
83
+ ```
84
+
85
+ **例外**: 如果用户明确要求做的是"计划工作"(写 prd.md、整理 jsonl),可以继续,
86
+ 但只能编辑任务计划文件,不能开始实现代码。
87
+
88
+ ### Status = `in_progress`
89
+
90
+ **✅ 放行。** 任务正在执行中。
91
+
92
+ 加载任务上下文后继续:
93
+ 1. 读取 `<task>/prd.md`
94
+ 2. 读取 `<task>/implement.jsonl`
95
+ 3. 读取相关 spec 文件
96
+ 4. 行为变更任务:确认 `<task>/tdd.jsonl` red evidence 存在
97
+ 5. 声明确认的假设、成功标准、涉及文件、验证命令
98
+ 6. 继续实现
99
+
100
+ 主会话派发固定代理时,必须使用 runtime context dispatch 协议。
101
+
102
+ ### Status = `review`
103
+
104
+ **⚠️ 任务在检查阶段。** 实现应已完成。
105
+
106
+ 回复用户:
107
+
108
+ ```
109
+ 任务在检查阶段,实现应已完成。
110
+
111
+ 建议:
112
+ 1. 运行 cowork-check 验证
113
+ 2. 检查通过后 task complete
114
+ 3. 如果需要小修复,在 check 范围内直接修
115
+
116
+ 当前需要执行检查还是修复?
117
+ ```
118
+
119
+ 不要开始新的实现工作,除非是小修复。
120
+
121
+ ### Status = `completed`
122
+
123
+ **⛔ 阻断。** 任务已完成。
124
+
125
+ 回复用户:
126
+
127
+ ```
128
+ 任务已完成。不要针对已完成任务派发新的实现工作。
129
+
130
+ 如果发现遗漏:
131
+ 1. task archive 归档旧任务
132
+ 2. 创建新任务
133
+ 3. 走完整流程
21
134
 
22
- ## Confirm
135
+ 需要创建新任务吗?
136
+ ```
23
137
 
24
- State briefly:
138
+ ### Status = `stale` 或 `unknown`
25
139
 
26
- - Assumptions.
27
- - Success criteria.
28
- - Files or modules likely to change.
29
- - Verification command you expect to run.
30
- - Whether fixed agents or inline work are appropriate.
140
+ 任务状态异常。回复用户:
31
141
 
32
- If the task is a bounded subagent prompt, do not convert it into main-session planning.
142
+ ```
143
+ 任务状态异常 (<status>)。请运行 task next 和 resume 确认当前状态后再继续。
144
+ ```
@@ -12,11 +12,16 @@ Use this after implementation and before `finish-work`.
12
12
  1. Read active task PRD, plan, and `check.jsonl`.
13
13
  2. Review `git diff --name-only` and `git diff`.
14
14
  3. Check contracts across caller/callee, command output, persisted state, templates, and docs.
15
- 4. Confirm `.cowork-flow/spec/` is updated or explicitly unchanged.
16
- 5. Review test intent: reject shallow tests that do not fail for meaningful behavior breaks.
17
- 6. Run focused tests that would fail if the changed behavior broke.
18
- 7. Run broader validation when the change touches shared runtime, templates, packaging, or public workflow.
19
- 8. Report `test_intent_review` with the key tests that defend PRD acceptance behavior.
15
+ 4. Verify spec compliance:
16
+ - Read each spec file listed in `check.jsonl`.
17
+ - For each guideline in the spec, check the diff for violations (naming, structure, encoding, error handling, quality gates).
18
+ - Spec files not listed in `check.jsonl` do not apply to this check.
19
+ 5. Confirm `.cowork-flow/spec/` is updated or explicitly unchanged.
20
+ 6. Review test intent: reject shallow tests that do not fail for meaningful behavior breaks.
21
+ 7. Run focused tests that would fail if the changed behavior broke.
22
+ 8. Run broader validation when the change touches shared runtime, templates, packaging, or public workflow.
23
+ 9. Report `test_intent_review` with the key tests that defend PRD acceptance behavior.
24
+ 10. Report spec compliance: for each spec/ file checked, state pass/fail with evidence from the diff.
20
25
 
21
26
  ## Report
22
27
 
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: game-design
3
+ description: Use when working on game development tasks — architecture, engine selection, asset pipelines, performance analysis, or multiplayer networking.
4
+ ---
5
+
6
+ # Game Design
7
+
8
+ Use this skill when the task involves game development: engine selection, game architecture, asset pipeline configuration, performance tuning, or multiplayer networking. It provides domain-specific guidelines that complement the general `cowork-implement` workflow.
9
+
10
+ ## When to use
11
+
12
+ - Engine architecture decisions (ECS vs OOP, scene organization)
13
+ - Asset pipeline setup or optimization
14
+ - Performance profiling and optimization
15
+ - Multiplayer networking and synchronization
16
+ - Any task that references `.cowork-flow/spec/game/` guides
17
+
18
+ ## Domain Guidelines
19
+
20
+ The following guidelines live in `.cowork-flow/spec/game/` and should be read before implementing game-related code:
21
+
22
+ | File | Covers |
23
+ |------|--------|
24
+ | `engine-guidelines.md` | ECS vs OOP, scene/level organization, plugin strategy |
25
+ | `asset-pipeline.md` | Asset directory layout, build stages, LOD policy, Git LFS |
26
+ | `performance-guidelines.md` | FPS targets, memory budgets, GC, draw calls, profiling workflow |
27
+ | `multiplayer-guidelines.md` | Network models, sync strategies, lag compensation, matchmaking |
28
+
29
+ ## Usage
30
+
31
+ 1. Read the relevant spec/game/ guide(s) first.
32
+ 2. Read the task PRD and implement.jsonl context.
33
+ 3. Proceed with implementation through `cowork-implement` or directly (depending on scope).
34
+
35
+ ## When NOT to use
36
+
37
+ - Pure backend/CRUD work with no game domain concerns
38
+ - Frontend UI that doesn't involve game-specific rendering or input
39
+ - General infrastructure tasks
@@ -18,15 +18,6 @@ TAG_RE = re.compile(
18
18
  )
19
19
  DEFAULT_CONTRACT_REGISTRY = {
20
20
  "contracts": [
21
- {
22
- "id": "COWORK_ENTRY_CONTRACT_V1",
23
- "path": ".cowork-flow/spec/contracts/entry-contract.md",
24
- "digest": [
25
- "Classify main-session requests before task start, resume, archive, or commit.",
26
- "Runtime context, not prompt labels, identifies formal subagent sessions.",
27
- ],
28
- "readWhen": ["before task start/resume/archive", "when prompt and bootstrap text conflict"],
29
- },
30
21
  {
31
22
  "id": "RUNTIME_CONTEXT_DISPATCH_V2",
32
23
  "path": ".cowork-flow/spec/contracts/subagent-dispatch.md",
@@ -154,7 +145,7 @@ def _load_common(root: Path) -> None:
154
145
  def _get_dispatch_mode(root: Path) -> str:
155
146
  _load_common(root)
156
147
  try:
157
- from common.config import get_codex_dispatch_mode # type: ignore[import-not-found]
148
+ from common.core.config import get_codex_dispatch_mode # type: ignore[import-not-found]
158
149
  except Exception:
159
150
  return "sub-agent"
160
151
  try:
@@ -166,7 +157,7 @@ def _get_dispatch_mode(root: Path) -> str:
166
157
  def _get_active_task(root: Path, hook_input: dict[str, Any]) -> tuple[str | None, str, str]:
167
158
  _load_common(root)
168
159
  try:
169
- from common.active_task import get_active_task # type: ignore[import-not-found]
160
+ from common.task.active_task import get_active_task # type: ignore[import-not-found]
170
161
  except Exception:
171
162
  return None, "no_task", "unavailable"
172
163
 
@@ -190,7 +181,7 @@ def _get_active_task(root: Path, hook_input: dict[str, Any]) -> tuple[str | None
190
181
  def _resolve_runtime_context(root: Path, hook_input: dict[str, Any]) -> tuple[dict[str, Any] | None, str | None]:
191
182
  _load_common(root)
192
183
  try:
193
- from common.active_task import ( # type: ignore[import-not-found]
184
+ from common.task.active_task import ( # type: ignore[import-not-found]
194
185
  bind_runtime_context,
195
186
  read_runtime_context,
196
187
  resolve_runtime_context_id,
@@ -0,0 +1,2 @@
1
+ name=<your-developer-name>
2
+ initialized_at=<YYYY-MM-DD>
@@ -1 +1 @@
1
- 0.0.28
1
+ 0.0.30
@@ -9,7 +9,7 @@ capabilities:
9
9
  listChildren: native
10
10
  cancelChild: native
11
11
  stateInjection: external
12
- backgroundChild: experimental
12
+ backgroundChild: native
13
13
  runtimeContextDispatch: native
14
14
  runtimeContextBinding: shim
15
15
  runtimeContextCleanup: native
@@ -27,7 +27,6 @@ runtimeContext:
27
27
  envKey: COWORK_FLOW_RUNTIME_CONTEXT_ID
28
28
  metadataKey: cowork_runtime_context_id
29
29
  contracts:
30
- entry: COWORK_ENTRY_CONTRACT_V1
31
30
  dispatch: RUNTIME_CONTEXT_DISPATCH_V2
32
31
  leafExecutor: true
33
32
  fallback:
@@ -27,7 +27,6 @@ runtimeContext:
27
27
  envKey: COWORK_FLOW_RUNTIME_CONTEXT_ID
28
28
  metadataKey: cowork_runtime_context_id
29
29
  contracts:
30
- entry: COWORK_ENTRY_CONTRACT_V1
31
30
  dispatch: RUNTIME_CONTEXT_DISPATCH_V2
32
31
  leafExecutor: true
33
32
  fallback:
@@ -25,7 +25,6 @@ runtimeContext:
25
25
  envKey: COWORK_FLOW_RUNTIME_CONTEXT_ID
26
26
  metadataKey: cowork_runtime_context_id
27
27
  contracts:
28
- entry: COWORK_ENTRY_CONTRACT_V1
29
28
  dispatch: RUNTIME_CONTEXT_DISPATCH_V2
30
29
  leafExecutor: true
31
30
  fallback:
@@ -0,0 +1 @@
1
+ """Command entrypoints for cowork-flow."""