codecruise 0.1.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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/bin/codecruise.js +68 -0
  4. package/config/CLAUDE.md +107 -0
  5. package/config/agents/analyst.md +48 -0
  6. package/config/agents/architect-reviewer.md +161 -0
  7. package/config/agents/architect.md +119 -0
  8. package/config/agents/critic.md +63 -0
  9. package/config/agents/developer.md +96 -0
  10. package/config/agents/devops.md +81 -0
  11. package/config/agents/orchestrator.md +91 -0
  12. package/config/agents/planner.md +139 -0
  13. package/config/agents/retro.md +52 -0
  14. package/config/agents/reviewer.md +101 -0
  15. package/config/agents/security-reviewer.md +57 -0
  16. package/config/agents/stack/expo/AGENT.md +473 -0
  17. package/config/agents/stack/expo/rules/critical.md +427 -0
  18. package/config/agents/stack/expo/rules/native.md +455 -0
  19. package/config/agents/stack/expo/rules/navigation.md +445 -0
  20. package/config/agents/stack/expo/rules/performance.md +415 -0
  21. package/config/agents/stack/fastify/AGENT.md +397 -0
  22. package/config/agents/stack/fastify/rules/api-design.md +283 -0
  23. package/config/agents/stack/fastify/rules/critical.md +232 -0
  24. package/config/agents/stack/fastify/rules/queues.md +303 -0
  25. package/config/agents/stack/fastify/rules/security.md +384 -0
  26. package/config/agents/stack/index.yaml +48 -0
  27. package/config/agents/stack/nextjs/AGENT.md +421 -0
  28. package/config/agents/stack/nextjs/rules/components.md +413 -0
  29. package/config/agents/stack/nextjs/rules/critical.md +391 -0
  30. package/config/agents/stack/nextjs/rules/performance.md +403 -0
  31. package/config/agents/stack/nextjs/rules/styling.md +334 -0
  32. package/config/agents/stack/shared-ts/AGENT.md +384 -0
  33. package/config/agents/stack/shared-ts/rules/critical.md +315 -0
  34. package/config/agents/stack/shared-ts/rules/patterns.md +384 -0
  35. package/config/agents/stack/shared-ts/rules/zod.md +427 -0
  36. package/config/agents/tester.md +79 -0
  37. package/config/commands/architect-discuss.md +366 -0
  38. package/config/commands/architect-list.md +160 -0
  39. package/config/commands/architect-review.md +111 -0
  40. package/config/commands/architect.md +118 -0
  41. package/config/commands/compact.md +118 -0
  42. package/config/commands/companion.md +279 -0
  43. package/config/commands/dashboard.md +152 -0
  44. package/config/commands/doctor.md +227 -0
  45. package/config/commands/dogfood-report.md +101 -0
  46. package/config/commands/flags/run-autonomous.md +110 -0
  47. package/config/commands/flags/run-pause.md +80 -0
  48. package/config/commands/ingest.md +173 -0
  49. package/config/commands/init.md +128 -0
  50. package/config/commands/metrics.md +87 -0
  51. package/config/commands/parallel.md +320 -0
  52. package/config/commands/pause.md +55 -0
  53. package/config/commands/plan-review.md +130 -0
  54. package/config/commands/plan.md +216 -0
  55. package/config/commands/production-check.md +308 -0
  56. package/config/commands/refine.md +323 -0
  57. package/config/commands/resume.md +72 -0
  58. package/config/commands/retro.md +121 -0
  59. package/config/commands/retry.md +75 -0
  60. package/config/commands/role.md +310 -0
  61. package/config/commands/run.md +417 -0
  62. package/config/commands/scope.md +85 -0
  63. package/config/commands/setup-permissions.md +104 -0
  64. package/config/commands/skip.md +75 -0
  65. package/config/commands/spec-forge.md +213 -0
  66. package/config/commands/spec-help.md +194 -0
  67. package/config/commands/spec-patch.md +342 -0
  68. package/config/commands/spec-resolve.md +110 -0
  69. package/config/commands/spec-review.md +153 -0
  70. package/config/commands/status.md +114 -0
  71. package/config/commands/sync.md +131 -0
  72. package/config/commands/task.md +138 -0
  73. package/config/commands/verify.md +124 -0
  74. package/config/hooks/README.md +632 -0
  75. package/config/hooks/activity-log.sh +187 -0
  76. package/config/hooks/anti-rationalize.sh +52 -0
  77. package/config/hooks/capture-verification.sh +112 -0
  78. package/config/hooks/collect-metrics.sh +135 -0
  79. package/config/hooks/enforce-file-scope.sh +75 -0
  80. package/config/hooks/enforce-state-machine.sh +161 -0
  81. package/config/hooks/enforce-tdd.sh +180 -0
  82. package/config/hooks/format.sh +40 -0
  83. package/config/hooks/lib/activity-helpers.sh +162 -0
  84. package/config/hooks/lib/read-settings.sh +71 -0
  85. package/config/hooks/load-context-skills.sh +95 -0
  86. package/config/hooks/notify.sh +81 -0
  87. package/config/hooks/pre-commit.sample +35 -0
  88. package/config/hooks/protect-files.sh +63 -0
  89. package/config/hooks/track-agents.sh +41 -0
  90. package/config/hooks/track-commands.sh +37 -0
  91. package/config/hooks/track-enforcement.sh +44 -0
  92. package/config/hooks/track-ooda.sh +77 -0
  93. package/config/hooks/validate-commit-msg.sh +35 -0
  94. package/config/hooks/validate-plan.sh +213 -0
  95. package/config/hooks/verify-criteria.sh +46 -0
  96. package/config/hooks/verify-todo-completion.sh +140 -0
  97. package/config/rules/comments.md +25 -0
  98. package/config/rules/decision-rules.md +308 -0
  99. package/config/rules/hygiene.md +247 -0
  100. package/config/rules/pattern-detection.md +372 -0
  101. package/config/rules/profiles.md +193 -0
  102. package/config/rules/recovery.md +83 -0
  103. package/config/rules/scope-detection.md +213 -0
  104. package/config/rules/standards.md +127 -0
  105. package/config/rules/workflow.md +121 -0
  106. package/config/schemas.md +767 -0
  107. package/config/settings.json +195 -0
  108. package/config/skills/backend/SKILL.md +734 -0
  109. package/config/skills/database/SKILL.md +426 -0
  110. package/config/skills/frontend/SKILL.md +434 -0
  111. package/config/skills/git/SKILL.md +396 -0
  112. package/config/skills/index.yaml +36 -0
  113. package/config/skills/observability/SKILL.md +430 -0
  114. package/config/skills/package-dev/SKILL.md +498 -0
  115. package/config/skills/performance/SKILL.md +378 -0
  116. package/config/skills/resilience/SKILL.md +573 -0
  117. package/config/skills/testing/SKILL.md +398 -0
  118. package/config/skills/testing-patterns/SKILL.md +276 -0
  119. package/config/skills/typescript/SKILL.md +152 -0
  120. package/config/templates/CLAUDE.md +70 -0
  121. package/config/templates/README.md +117 -0
  122. package/config/templates/steering/adr-template.md +102 -0
  123. package/config/templates/steering/product.md +60 -0
  124. package/config/templates/steering/rfc-template.md +159 -0
  125. package/config/templates/steering/structure.md +146 -0
  126. package/config/templates/steering/tech.md +85 -0
  127. package/package.json +40 -0
  128. package/src/install.js +163 -0
  129. package/src/report.js +310 -0
@@ -0,0 +1,767 @@
1
+ # Schemas — Contract Definitions
2
+
3
+ **CRITICAL**: These schemas are contracts. Commands write → other commands read.
4
+ Changing field names or structures breaks the workflow chain.
5
+
6
+ ## ID Patterns
7
+
8
+ | Type | Pattern | Example |
9
+ |------|---------|---------|
10
+ | Phase | `phase-NN` | `phase-01`, `phase-02` |
11
+ | Feature | `feature-N.N` | `feature-1.2`, `feature-2.5` |
12
+ | Subfeature | `subfeature-N.Na` | `subfeature-1.1a`, `subfeature-2.3b` |
13
+ | TODO | `todo-N.Na-NNN` | `todo-1.1a-001`, `todo-2.3b-015` |
14
+ | Conflict | `conflict-NNN` | `conflict-001` |
15
+ | Open Question | `oq-NNN` | `oq-012` |
16
+ | Assumption | `assumption-NNN` | `assumption-003` |
17
+ | Decision | `D-NNN` | `D-005` |
18
+ | ADR | `ADR-NNN` | `ADR-001` |
19
+ | RFC | `RFC-NNN` | `RFC-001` |
20
+ | Requirement (FR) | `FR-NNN` | `FR-001` |
21
+ | Requirement (NFR) | `NFR-NNN` | `NFR-010` |
22
+ | Workflow | `WF-NNN` | `WF-001` |
23
+ | Use Case | `UC-NNN` | `UC-003` |
24
+
25
+ ---
26
+
27
+ ## Project Structure
28
+
29
+ ```
30
+ {project}/
31
+ ├── CLAUDE.md # Claude Code requirement (root, <100 lines)
32
+
33
+ ├── .claude/
34
+ │ └── settings.json # Claude Code project settings
35
+
36
+ └── .codecruise/ # ALL CodeCruise artifacts
37
+ ├── .codecruise/progress.yaml # Execution state
38
+ ├── steering/ # Context docs
39
+ │ ├── product.md # What: purpose, users, scope
40
+ │ ├── tech.md # How: stack, tools, constraints
41
+ │ └── structure.md # Where: architecture, patterns
42
+ ├── canon/ # Canonical spec (from /spec-forge)
43
+ │ ├── spec.md # FR/NFR requirements
44
+ │ ├── issues.md # Conflicts, OQs, assumptions
45
+ │ ├── decisions.md # ADRs (immutable)
46
+ │ └── changelog.md # Spec version history
47
+ ├── context/ # Per-feature context
48
+ │ └── {feature}.yaml # Sources, decisions, constraints
49
+ ├── roadmap/ # Phase/feature/TODO definitions
50
+ │ └── phase-NN.yaml
51
+ ├── metrics/
52
+ │ ├── events.jsonl # OODA event stream
53
+ │ └── scorecards/ # Per-TODO quality scores
54
+ ├── insights.yaml # Companion state
55
+ └── cache/ # Temp files (gitignored)
56
+ ```
57
+
58
+ ## Steering Docs Structure
59
+
60
+ Minimal, focused context files. CLAUDE.md < 100 lines, details in steering docs.
61
+
62
+ ### CLAUDE.md (Required Sections)
63
+
64
+ ```markdown
65
+ # {Project}
66
+
67
+ ## What
68
+ {one-liner}
69
+
70
+ ## Stack
71
+ {language, runtime, framework, package manager}
72
+
73
+ ## Quality Command
74
+ {single command, <10s}
75
+
76
+ ## Key Commands
77
+ {install, dev, build, test}
78
+
79
+ ## Project Structure
80
+ {key directories}
81
+
82
+ ## Steering Docs
83
+ {links to product.md, tech.md, structure.md}
84
+
85
+ ## Rules
86
+ {max 10, universally applicable}
87
+
88
+ ## Domain Context
89
+ {1-2 sentences of domain expertise}
90
+ ```
91
+
92
+ ### Steering Doc Required Sections
93
+
94
+ **product.md**:
95
+ - One-Liner
96
+ - Problem Statement
97
+ - Target Users
98
+ - Key Features (v1)
99
+ - Out of Scope (v1)
100
+
101
+ **tech.md**:
102
+ - Core Stack (table)
103
+ - Package Manager
104
+ - Quality Command
105
+ - Constraints
106
+
107
+ **structure.md**:
108
+ - System Context (C4 Level 1)
109
+ - Directory Structure
110
+ - Naming Conventions
111
+ - Module Boundaries
112
+
113
+ ---
114
+
115
+ ## .codecruise/progress.yaml (v2 — Current)
116
+
117
+ Simplified schema. Stats and patterns are computed from `.codecruise/metrics/events.jsonl`.
118
+
119
+ ```yaml
120
+ # .codecruise/progress.yaml v2 — Minimal State (~40 lines)
121
+ schema_version: 2
122
+ project: {name}
123
+ generated: {ISO timestamp}
124
+
125
+ # Current position
126
+ current_todo: todo-1.1b-004
127
+
128
+ # Execution state
129
+ execution_state:
130
+ status: running|paused|stopped|completed|error
131
+ tempo: ship-fast|balanced|careful
132
+ on_error: ask|skip|abort|replan
133
+ started_at: {ISO timestamp}
134
+ paused_at: {ISO timestamp|null}
135
+
136
+ # OODA state (confidence computed in ORIENT, stored for display)
137
+ ooda:
138
+ confidence: high|medium|low|{0.0-1.0}
139
+ last_observation: {ISO timestamp|null}
140
+
141
+ # Guardrails
142
+ guardrails:
143
+ max_retries_per_todo: 3
144
+ max_replans_per_module: 2
145
+ on_limit_hit: escalate|abort|skip_module
146
+
147
+ # Queue (simple arrays)
148
+ queue:
149
+ completed: [todo-1.1a-001, todo-1.1a-002]
150
+ pending: [todo-1.1b-004, todo-1.1b-005]
151
+ failed: []
152
+ skipped: []
153
+
154
+ # Human-managed
155
+ blockers: []
156
+ notes: []
157
+
158
+ last_updated: {ISO timestamp}
159
+ ```
160
+
161
+ ### Computed Values (ORIENT Phase)
162
+
163
+ These are computed from `events.jsonl`, not stored:
164
+
165
+ | Field | Source | Calculation |
166
+ |-------|--------|-------------|
167
+ | `stats.todos_completed` | `queue.completed` | Length |
168
+ | `stats.todos_remaining` | `queue.pending` | Length |
169
+ | `stats.total_retries` | `events.jsonl` | Sum retry events |
170
+ | `consecutive_failures` | `events.jsonl` | Count since last success |
171
+ | `patterns_detected` | `events.jsonl` | Analyze last N events |
172
+ | `module_replans` | `events.jsonl` | Group replan events by module |
173
+ | `confidence_factors` | OODA rules | Computed during ORIENT |
174
+
175
+ ### Migration from v1
176
+
177
+ Run `/init --upgrade-schema` or `/doctor --fix` to migrate.
178
+
179
+ ---
180
+
181
+ ## .codecruise/progress.yaml (v1 — Deprecated)
182
+
183
+ > **Deprecated**: Use v2 schema above. v1 support will be removed in future releases.
184
+
185
+ ```yaml
186
+ project: {name}
187
+ generated: {ISO timestamp}
188
+
189
+ # Current position
190
+ current_phase: phase-01
191
+ current_feature: feature-1.1
192
+ current_subfeature: subfeature-1.1b
193
+ current_todo: todo-1.1b-004
194
+
195
+ # Execution state (managed by /run)
196
+ execution_state:
197
+ status: running|paused|stopped|completed|error
198
+ started_at: {ISO timestamp}
199
+ paused_at: {ISO timestamp|null}
200
+ completed_at: {ISO timestamp|null}
201
+
202
+ # Scope being executed
203
+ scope: feature-1.1
204
+ scope_type: phase|feature|subfeature|todo
205
+
206
+ # Settings
207
+ tempo: ship-fast|balanced|careful
208
+ checkpoint_mode: subfeature|feature|none
209
+ on_error: ask|skip|abort|replan
210
+ max_iterations: 3
211
+
212
+ # Autonomous mode
213
+ mode: interactive|autonomous
214
+ max_turns: 100
215
+ current_turn: 0
216
+ notify_channel: slack|webhook|null
217
+
218
+ # OODA Loop State
219
+ ooda:
220
+ last_observation: {ISO timestamp|null}
221
+ confidence: high|medium|low|{0.0-1.0}
222
+ confidence_factors:
223
+ base: 0.8
224
+ retry_penalty: 0.0
225
+ module_penalty: 0.0
226
+ dep_penalty: 0.0
227
+ consecutive_failures: 0
228
+ patterns_detected: [] # [retry_spike, module_failing, error_cluster, external_dep_down]
229
+ skip_count: 0
230
+ replan_count: 0
231
+
232
+ # Guardrails (prevent infinite loops)
233
+ guardrails:
234
+ max_retries_per_todo: 3
235
+ max_replans_per_module: 2
236
+ max_replans_per_feature: 3
237
+ on_limit_hit: escalate|abort|skip_module
238
+ cost_limit: {number|null} # USD, optional
239
+ cost_current: 0.0
240
+
241
+ # Per-module replan tracking
242
+ module_replans:
243
+ auth: 0
244
+ api: 0
245
+ database: 0
246
+
247
+ # Pause state (for /resume)
248
+ pause_phase: observe|orient|decide|act|null
249
+ pause_reason: {string|null}
250
+
251
+ # Promise verification
252
+ promise:
253
+ text: {string|null}
254
+ verified: false
255
+ checks: []
256
+
257
+ # Blockers (autonomous)
258
+ blockers:
259
+ - todo: todo-1.2a-005
260
+ reason: "Redis not running"
261
+ pattern: external_dep_down
262
+ timestamp: {ISO timestamp}
263
+ notified: true
264
+ resolved: false
265
+
266
+ # Queue
267
+ queue:
268
+ total: 14
269
+ completed: [todo-1.1a-001, todo-1.1a-002]
270
+ pending: [todo-1.1b-004, todo-1.1b-005]
271
+ failed: []
272
+ skipped:
273
+ - id: todo-1.1b-003
274
+ reason: "External API not ready"
275
+ skip_source: user_override|ooda_routing|blocker_detected
276
+ skipped_at: {ISO timestamp}
277
+ had_dependents: false
278
+ replanned: []
279
+
280
+ # Stats
281
+ stats:
282
+ todos_completed: 10
283
+ todos_remaining: 4
284
+ todos_failed: 0
285
+ todos_skipped: 0
286
+ total_retries: 2
287
+ total_commits: 5
288
+ total_replans: 0
289
+ avg_confidence: 0.85
290
+ duration_minutes: 45
291
+
292
+ # Last checkpoint
293
+ last_checkpoint:
294
+ type: subfeature
295
+ id: subfeature-1.1a
296
+ timestamp: {ISO timestamp}
297
+ todos_completed: 7
298
+ ooda_summary:
299
+ avg_confidence: 0.87
300
+ patterns: []
301
+ replans: 0
302
+
303
+ # Error tracking
304
+ last_error:
305
+ todo: todo-1.2a-005
306
+ message: "Connection refused"
307
+ error_type: connection|test_failure|lint_error|type_error
308
+ attempts: 3
309
+ timestamp: {ISO timestamp}
310
+ output: "Error: connect ECONNREFUSED..."
311
+
312
+ # Human notes (managed by user)
313
+ blockers:
314
+ - id: blocker-001
315
+ description: "Redis connection failing"
316
+ affects: feature-2.3
317
+ since: {ISO date}
318
+
319
+ notes:
320
+ - "API rate limits hit - added retry"
321
+ - "Need design review before Phase 3"
322
+
323
+ # Session tracking (for /dashboard)
324
+ session:
325
+ started: {ISO timestamp}
326
+ tokens:
327
+ input: 45000
328
+ output: 12000
329
+ estimated_cost: 0.42
330
+
331
+ # Overall stats
332
+ stats:
333
+ total_phases: 2
334
+ completed_phases: 0
335
+ total_features: 10
336
+ completed_features: 1
337
+ total_todos: 164
338
+ completed_todos: 14
339
+ percent_complete: 8
340
+
341
+ last_updated: {ISO timestamp}
342
+ ```
343
+
344
+ ---
345
+
346
+ ## .codecruise/metrics/events.jsonl
347
+
348
+ Append-only event stream. Used by ORIENT phase to compute stats and patterns.
349
+
350
+ ```jsonl
351
+ {"ts":"2026-02-20T10:30:00Z","event":"session_start","data":{}}
352
+ {"ts":"2026-02-20T10:30:15Z","event":"todo_start","data":{"todo":"todo-1.1b-004"}}
353
+ {"ts":"2026-02-20T10:30:16Z","event":"ooda_observe","data":{"todo":"todo-1.1b-004","git":"clean","deps":"ok"}}
354
+ {"ts":"2026-02-20T10:30:17Z","event":"ooda_orient","data":{"todo":"todo-1.1b-004","confidence":0.85,"patterns":[]}}
355
+ {"ts":"2026-02-20T10:30:18Z","event":"ooda_decide","data":{"todo":"todo-1.1b-004","decision":"execute"}}
356
+ {"ts":"2026-02-20T10:30:20Z","event":"ooda_act","data":{"todo":"todo-1.1b-004","phase":"red"}}
357
+ {"ts":"2026-02-20T10:33:45Z","event":"verify","data":{"lint":0,"tsc":0,"test":0}}
358
+ {"ts":"2026-02-20T10:33:50Z","event":"todo_complete","data":{"todo":"todo-1.1b-004","duration_s":210,"commit":"abc123"}}
359
+ {"ts":"2026-02-20T10:35:20Z","event":"todo_fail","data":{"todo":"todo-1.1b-005","error":"connection refused","attempt":1}}
360
+ {"ts":"2026-02-20T10:35:21Z","event":"retry","data":{"todo":"todo-1.1b-005","attempt":2}}
361
+ {"ts":"2026-02-20T10:36:46Z","event":"skip","data":{"todo":"todo-1.1b-005","reason":"external dep","source":"ooda_routing"}}
362
+ {"ts":"2026-02-20T10:36:50Z","event":"replan","data":{"module":"auth","count":1}}
363
+ {"ts":"2026-02-20T11:15:00Z","event":"session_pause","data":{"reason":"user"}}
364
+ ```
365
+
366
+ ### Event Types
367
+
368
+ | Event | Description | Data Fields |
369
+ |-------|-------------|-------------|
370
+ | `session_start` | New execution session | — |
371
+ | `session_pause` | Session paused | `reason` |
372
+ | `todo_start` | TODO execution began | `todo` |
373
+ | `todo_complete` | TODO finished successfully | `todo`, `duration_s`, `commit` |
374
+ | `todo_fail` | TODO attempt failed | `todo`, `error`, `attempt` |
375
+ | `ooda_observe` | OBSERVE phase completed | `todo`, `git`, `deps`, `branch` |
376
+ | `ooda_orient` | ORIENT phase completed | `todo`, `confidence`, `patterns` |
377
+ | `ooda_decide` | DECIDE phase completed | `todo`, `decision` |
378
+ | `ooda_act` | ACT phase update | `todo`, `phase` (red/green/refactor) |
379
+ | `verify` | Quality verification | `lint`, `tsc`, `test` (exit codes) |
380
+ | `retry` | Retry attempt | `todo`, `attempt` |
381
+ | `skip` | TODO skipped | `todo`, `reason`, `source` |
382
+ | `replan` | Module replanned | `module`, `count` |
383
+
384
+ ---
385
+
386
+ ## .codecruise/activity.log
387
+
388
+ Human-readable log for `tail -f`. Plain text with timestamps and emoji.
389
+
390
+ ```
391
+ [2026-02-20 10:30:15] ━━━ SESSION START ━━━
392
+ [2026-02-20 10:30:16] 👁 OBSERVE todo-1.1b-004
393
+ [2026-02-20 10:30:17] ├─ git: clean
394
+ [2026-02-20 10:30:17] └─ branch: feature/auth
395
+ [2026-02-20 10:30:18] 🧭 ORIENT confidence=0.85
396
+ [2026-02-20 10:30:19] ⚡ DECIDE execute
397
+ [2026-02-20 10:30:20] ▶ ACT todo-1.1b-004 "Implement validation"
398
+ [2026-02-20 10:33:45] └─ VERIFY: lint ✓ | tsc ✓ | test ✓
399
+ [2026-02-20 10:33:50] ✓ COMPLETE todo-1.1b-004 (3m 30s) commit:abc123
400
+ [2026-02-20 10:33:51] → NEXT todo-1.1b-005
401
+ [2026-02-20 10:35:20] └─ ✗ TEST FAIL: connection refused
402
+ [2026-02-20 10:35:21] ⚠ RETRY (attempt 2/3)
403
+ [2026-02-20 10:36:46] ⏭ SKIP todo-1.1b-005 (blocker: external dep)
404
+ [2026-02-20 11:15:00] ⏸ PAUSE
405
+ [2026-02-20 11:15:01] ━━━ SESSION PAUSE ━━━
406
+ ```
407
+
408
+ ---
409
+
410
+ ## .codecruise/roadmap/phase-NN.yaml
411
+
412
+ ```yaml
413
+ phase:
414
+ id: phase-01
415
+ name: Alpha Bootstrap
416
+ status: pending|in_progress|completed
417
+ started: {ISO timestamp|null}
418
+ completed: {ISO timestamp|null}
419
+ branch: feature/alpha-bootstrap
420
+
421
+ goals:
422
+ - "Set up monorepo structure"
423
+ - "Implement core infrastructure"
424
+
425
+ success_criteria:
426
+ - "All packages build"
427
+ - "Tests pass"
428
+
429
+ features:
430
+ - id: feature-1.1
431
+ name: Monorepo Foundation
432
+ branch: feature/alpha/monorepo-foundation
433
+ status: pending|in_progress|completed
434
+
435
+ subfeatures:
436
+ - id: subfeature-1.1a
437
+ name: Root Configuration
438
+ status: pending|in_progress|completed
439
+
440
+ todos:
441
+ - id: todo-1.1a-001
442
+ description: Create root package.json
443
+ owner: dev
444
+ status: pending|in_progress|done|blocked|skipped
445
+ files:
446
+ - package.json
447
+ - pnpm-workspace.yaml
448
+ criteria:
449
+ - "package.json has workspace config"
450
+ - "pnpm-workspace.yaml lists all packages"
451
+ tests:
452
+ - "pnpm install succeeds"
453
+ constraints:
454
+ - "Use pnpm 8+"
455
+ depends_on: []
456
+
457
+ - id: todo-1.1a-002
458
+ description: Configure TypeScript
459
+ depends_on: [todo-1.1a-001]
460
+ # ... same structure
461
+ ```
462
+
463
+ ---
464
+
465
+ ## .codecruise/canon/spec.md
466
+
467
+ ```markdown
468
+ ---
469
+ version: 0.1.0
470
+ generated: {ISO timestamp}
471
+ generated_hash: sha256:abc123
472
+ sources_hash: sha256:def456
473
+ sources_count: 12
474
+ last_reviewed: {ISO timestamp|null}
475
+ ---
476
+
477
+ # {Project Name} — Product Specification
478
+
479
+ ## 1. Overview
480
+ ### 1.1 One-Line Pitch
481
+ ### 1.2 Problem Statement
482
+ ### 1.3 Goals
483
+ ### 1.4 Non-Goals (v1)
484
+ ### 1.5 Key Terms
485
+
486
+ ## 2. Users
487
+ ### 2.1 Personas
488
+ ### 2.2 Key Use Cases
489
+
490
+ ## 3. Scope
491
+ ### 3.1 v1 In-Scope
492
+ ### 3.2 Out-of-Scope (v1)
493
+
494
+ ## 4. Requirements
495
+ ### 4.1 Functional Requirements
496
+
497
+ #### FR-001: {Feature Name}
498
+ - **Description**: {what it does}
499
+ - **User Story**: As a {role}, I want {goal}, so that {benefit}
500
+ - **Acceptance Criteria**:
501
+ - [ ] {testable criterion}
502
+ - **Source**: {document}
503
+
504
+ ### 4.2 Non-Functional Requirements
505
+
506
+ #### NFR-001: {Requirement}
507
+ - **Category**: Performance|Security|Reliability|Observability
508
+ - **Requirement**: {specific, measurable}
509
+ - **Threshold**: {number/metric}
510
+ - **Source**: {document}
511
+
512
+ ## 5. Workflows
513
+
514
+ ### WF-001: {Workflow Name}
515
+ - **Trigger**: {what initiates this flow}
516
+ - **Actors**: {user roles involved}
517
+ - **Related**: FR-001, FR-002
518
+
519
+ ```mermaid
520
+ sequenceDiagram
521
+ participant U as User
522
+ participant A as API
523
+ participant D as Database
524
+ participant E as External Service
525
+
526
+ U->>A: Request
527
+ A->>D: Query
528
+ D-->>A: Result
529
+ A-->>U: Response
530
+ ```
531
+
532
+ **Steps:**
533
+ 1. {Step description}
534
+ 2. {Step description}
535
+
536
+ **Error Handling:**
537
+ - {error condition} → {behavior}
538
+
539
+ **Edge Cases:**
540
+ - {edge case} → {handling}
541
+
542
+ ## 6. Data & Integrations
543
+ ### 6.1 Key Entities
544
+ ### 6.2 Integrations
545
+ ### 6.3 Auth Model
546
+
547
+ ## 7. Risks
548
+ ## 8. Links
549
+ ```
550
+
551
+ ---
552
+
553
+ ## .codecruise/canon/issues.md
554
+
555
+ ```yaml
556
+ # Conflicts
557
+ conflicts:
558
+ - id: conflict-001
559
+ description: "Auth timeout: 30min vs 1hr"
560
+ side_a:
561
+ position: "30 minutes for security"
562
+ sources: [security-review.md]
563
+ side_b:
564
+ position: "1 hour for UX"
565
+ sources: [ux-research.pdf]
566
+ severity: P0|P1|P2
567
+ suggested_resolution: "..."
568
+ status: open|resolved
569
+ # User adds for resolution:
570
+ resolution: "Use 1hr with re-auth for sensitive actions"
571
+ rationale: "Balances UX with security"
572
+ apply_to:
573
+ - section: "6.3 Auth Model"
574
+ - requirement: FR-003
575
+ # Added by /spec-resolve:
576
+ resolved_date: {ISO date}
577
+ resolved_by: /spec-resolve
578
+ decision_id: D-005
579
+
580
+ # Open Questions
581
+ open_questions:
582
+ - id: oq-001
583
+ question: "What happens when rate limit exceeded?"
584
+ context: "Behavior undefined"
585
+ impact: "Cannot implement error handling"
586
+ owner: PM|Eng|Security|Legal
587
+ priority: P0|P1|P2
588
+ related_conflicts: []
589
+ status: open|resolved
590
+ # User adds:
591
+ resolution: "Return 429 with Retry-After header"
592
+ apply_to:
593
+ - new_requirement: NFR-010
594
+
595
+ # Assumptions
596
+ assumptions:
597
+ - id: assumption-001
598
+ assumption: "Free tier = no premium API"
599
+ rationale: "Inferred from pricing doc"
600
+ sources: [pricing-draft.md]
601
+ needs_validation: true
602
+ related: [oq-003]
603
+ status: open|resolved
604
+ # User adds:
605
+ resolution: confirmed|"revised: {new assumption}"
606
+ validated_by: "PM confirmed 2024-01-20"
607
+ ```
608
+
609
+ ---
610
+
611
+ ## .codecruise/canon/decisions.md
612
+
613
+ ```markdown
614
+ # Decision Log
615
+
616
+ ## D-001: {Decision Title}
617
+ - **Date**: {ISO date}
618
+ - **Decision**: {what was decided}
619
+ - **Rationale**: {why}
620
+ - **Alternatives Considered**: {options rejected}
621
+ - **Sources**: {documents that informed}
622
+ - **Related**: conflict-001, oq-003
623
+ - **Resolved by**: /spec-resolve|manual
624
+ ```
625
+
626
+ ---
627
+
628
+ ## .codecruise/context/{feature}.yaml
629
+
630
+ ```yaml
631
+ feature: auth
632
+ created: {ISO date}
633
+ updated: {ISO date}
634
+
635
+ sources:
636
+ - file: "Auth Guide.pdf"
637
+ pages: [2, 5-7]
638
+ note: "Session management"
639
+ - file: "Security Review.md"
640
+ sections: ["Authentication"]
641
+
642
+ decisions:
643
+ - id: D-001
644
+ summary: "JWT with refresh tokens"
645
+ source: "Security Review.md"
646
+
647
+ constraints:
648
+ - "httpOnly cookies for web"
649
+ - "Biometric auth optional mobile"
650
+
651
+ open_questions:
652
+ - id: oq-001
653
+ question: "MFA for v1?"
654
+ ```
655
+
656
+ ---
657
+
658
+ ## .codecruise/scorecards/{todo-id}.json
659
+
660
+ ```json
661
+ {
662
+ "todo_id": "todo-1.1b-004",
663
+ "timestamp": "{ISO timestamp}",
664
+ "ooda": {
665
+ "confidence": 0.85,
666
+ "patterns": [],
667
+ "observation_time_ms": 45
668
+ },
669
+ "verification": {
670
+ "lint": { "exit_code": 0, "errors": 0 },
671
+ "typecheck": { "exit_code": 0, "errors": 0 },
672
+ "tests": { "exit_code": 0, "passed": 47, "failed": 0 }
673
+ },
674
+ "scores": {
675
+ "quality": 0.95,
676
+ "alignment": 0.88,
677
+ "overall": 0.91
678
+ },
679
+ "decision": "proceed|proceed_with_comment|retry|replan|flag_for_human"
680
+ }
681
+ ```
682
+
683
+ ---
684
+
685
+ ## .codecruise/insights.yaml (Companion State)
686
+
687
+ ```yaml
688
+ generated: {ISO timestamp}
689
+
690
+ # Real-time pattern state (used by ORIENT phase)
691
+ pattern_state:
692
+ retry_window: [2, 3, 1, 0, 2] # Last 5 TODO retry counts
693
+ error_types:
694
+ auth_error: 3
695
+ type_error: 1
696
+ connection_error: 0
697
+ module_failures:
698
+ auth: 2
699
+ api: 0
700
+ database: 1
701
+ external_deps:
702
+ docker: up|down|unknown
703
+ redis: up|down|unknown
704
+
705
+ # Active insights (for /companion standalone)
706
+ active_insights:
707
+ - id: insight-001
708
+ type: blocker|friction|opportunity|win
709
+ pattern: retry_spike|module_failing|error_cluster|external_dep_down|context_bloat
710
+ category: {module or skill name}
711
+ message: "Auth module averaging 0.52 confidence"
712
+ severity: critical|warning|info
713
+ first_seen: {ISO timestamp}
714
+ occurrences: 4
715
+ status: active|resolved|dismissed
716
+ resolved_at: {ISO timestamp|null}
717
+
718
+ # Dismissed insights (don't re-surface)
719
+ dismissed_insights:
720
+ - id: insight-003
721
+ reason: "User dismissed"
722
+ dismissed_at: {ISO timestamp}
723
+ ```
724
+
725
+ ---
726
+
727
+ ## OODA Values
728
+
729
+ | Field | Valid Values |
730
+ |-------|--------------|
731
+ | `tempo` | `ship-fast`, `balanced`, `careful` |
732
+ | `confidence` | `high`, `medium`, `low` or `0.0` - `1.0` |
733
+ | `pause_phase` | `observe`, `orient`, `decide`, `act`, `null` |
734
+ | `patterns_detected` | `retry_spike`, `module_failing`, `error_cluster`, `external_dep_down`, `context_bloat` |
735
+ | `skip_source` | `user_override`, `ooda_routing`, `blocker_detected` |
736
+ | `on_error` | `ask`, `skip`, `abort`, `replan` |
737
+ | `decision` | `proceed`, `proceed_cautious`, `skip`, `replan`, `escalate` |
738
+ | `on_limit_hit` | `escalate`, `abort`, `skip_module` |
739
+
740
+ ## Guardrail Defaults
741
+
742
+ | Guardrail | Default | Range |
743
+ |-----------|---------|-------|
744
+ | `max_retries_per_todo` | 3 | 1-10 |
745
+ | `max_replans_per_module` | 2 | 1-5 |
746
+ | `max_replans_per_feature` | 3 | 1-10 |
747
+ | `cost_limit` | null | 0.00+ USD |
748
+
749
+ ---
750
+
751
+ ## Status Values
752
+
753
+ | Context | Valid Values |
754
+ |---------|--------------|
755
+ | Phase/Feature/Subfeature | `pending`, `in_progress`, `completed` |
756
+ | TODO | `pending`, `in_progress`, `done`, `blocked`, `skipped` |
757
+ | execution_state.status | `running`, `paused`, `stopped`, `completed`, `error` |
758
+ | Issue status | `open`, `resolved` |
759
+ | Severity | `P0`, `P1`, `P2` |
760
+
761
+ ---
762
+
763
+ ## Timestamps
764
+
765
+ All timestamps use ISO 8601 format: `2026-02-20T14:30:00Z`
766
+
767
+ Dates use: `2026-02-20`