gru-ai 0.2.0 → 0.3.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 (128) hide show
  1. package/.claude/hooks/validate-gate.sh +231 -77
  2. package/.claude/hooks/validate-project-json.sh +38 -3
  3. package/.claude/hooks/validate-reviews.sh +50 -11
  4. package/.claude/skills/directive/SKILL.md +31 -18
  5. package/.claude/skills/directive/docs/pipeline/00-delegation-and-triage.md +13 -7
  6. package/.claude/skills/directive/docs/pipeline/01-checkpoint.md +1 -1
  7. package/.claude/skills/directive/docs/pipeline/02-read-directive.md +24 -1
  8. package/.claude/skills/directive/docs/pipeline/03-read-context.md +5 -0
  9. package/.claude/skills/directive/docs/pipeline/04-brainstorm.md +77 -0
  10. package/.claude/skills/directive/docs/pipeline/04b-clarification.md +222 -0
  11. package/.claude/skills/directive/docs/pipeline/05-planning.md +21 -9
  12. package/.claude/skills/directive/docs/pipeline/06-technical-audit.md +32 -23
  13. package/.claude/skills/directive/docs/pipeline/07-plan-approval.md +53 -37
  14. package/.claude/skills/directive/docs/pipeline/07b-project-brainstorm.md +45 -5
  15. package/.claude/skills/directive/docs/pipeline/08-worktree-and-state.md +1 -1
  16. package/.claude/skills/directive/docs/pipeline/09-execute-projects.md +229 -499
  17. package/.claude/skills/directive/docs/pipeline/10-wrapup.md +33 -12
  18. package/.claude/skills/directive/docs/pipeline/11-completion-gate.md +229 -35
  19. package/.claude/skills/directive/docs/reference/rules/failure-handling.md +7 -3
  20. package/.claude/skills/directive/docs/reference/rules/phase-definitions.md +10 -2
  21. package/.claude/skills/directive/docs/reference/rules/scope-and-dod.md +188 -18
  22. package/.claude/skills/directive/docs/reference/schemas/audit-output.md +8 -4
  23. package/.claude/skills/directive/docs/reference/schemas/brainstorm-output.md +2 -1
  24. package/.claude/skills/directive/docs/reference/schemas/checkpoint.md +2 -2
  25. package/.claude/skills/directive/docs/reference/schemas/directive-json.md +95 -21
  26. package/.claude/skills/directive/docs/reference/schemas/investigation-output.md +4 -4
  27. package/.claude/skills/directive/docs/reference/templates/architect-prompt.md +26 -14
  28. package/.claude/skills/directive/docs/reference/templates/brainstorm-prompt.md +23 -10
  29. package/.claude/skills/directive/docs/reference/templates/investigator-prompt.md +6 -6
  30. package/.claude/skills/directive/docs/reference/templates/planner-prompt.md +42 -4
  31. package/.claude/skills/smoke-test/SKILL.md +84 -0
  32. package/.claude/skills/smoke-test/run-smoke-test.sh +590 -0
  33. package/.claude/skills/smoke-test/scenarios.md +34 -0
  34. package/.claude/skills/walkthrough/SKILL.md +96 -0
  35. package/README.md +261 -110
  36. package/cli/templates/gruai.config.json.template +2 -0
  37. package/dist/assets/GamePage-OJgWSZBK.js +49 -0
  38. package/dist/assets/{index-Bh01am7W.js → index-BjwyXPf7.js} +5 -5
  39. package/dist/assets/index-D2wJ_yhU.css +1 -0
  40. package/dist/assets/metrocity/Character Model.png +0 -0
  41. package/dist/assets/metrocity/Hairs.png +0 -0
  42. package/dist/assets/metrocity/Outfit1.png +0 -0
  43. package/dist/assets/metrocity/Outfit2.png +0 -0
  44. package/dist/assets/metrocity/Outfit3.png +0 -0
  45. package/dist/assets/metrocity/Outfit4.png +0 -0
  46. package/dist/assets/metrocity/Outfit5.png +0 -0
  47. package/dist/assets/metrocity/Outfit6.png +0 -0
  48. package/dist/assets/office/anim-bathroom-cabinet.tsx +18 -0
  49. package/dist/assets/office/atlas.png +0 -0
  50. package/dist/assets/office/gruai.tmx +364 -0
  51. package/dist/assets/office/ui.png +0 -0
  52. package/dist/gruai.tmx +104 -0
  53. package/dist/index.html +4 -4
  54. package/dist-cli/commands/init.js +18 -12
  55. package/dist-cli/commands/scaffold.js +6 -1
  56. package/dist-cli/commands/validate-init.d.ts +18 -0
  57. package/dist-cli/commands/validate-init.js +39 -0
  58. package/dist-cli/index.js +1 -1
  59. package/dist-cli/lib/roles.js +15 -0
  60. package/dist-cli/lib/types.d.ts +12 -0
  61. package/dist-server/server/config.js +13 -2
  62. package/dist-server/server/index.js +16 -1
  63. package/dist-server/server/parsers/session-scanner.d.ts +9 -0
  64. package/dist-server/server/parsers/session-scanner.js +36 -0
  65. package/dist-server/server/parsers/session-state.d.ts +13 -4
  66. package/dist-server/server/parsers/session-state.js +24 -55
  67. package/dist-server/server/platform/claude-code-spawn.js +2 -0
  68. package/dist-server/server/platform/claude-code.d.ts +4 -0
  69. package/dist-server/server/platform/claude-code.js +39 -3
  70. package/dist-server/server/platform/types.d.ts +16 -1
  71. package/dist-server/server/platform/types.js +1 -1
  72. package/dist-server/server/types.d.ts +3 -0
  73. package/dist-server/server/watchers/directive-watcher.d.ts +2 -0
  74. package/dist-server/server/watchers/directive-watcher.js +74 -13
  75. package/dist-server/server/watchers/state-watcher.js +3 -0
  76. package/package.json +3 -2
  77. package/.claude/skills/directive/docs/pipeline/04-challenge.md +0 -38
  78. package/.claude/skills/directive/docs/reference/schemas/challenger-output.md +0 -13
  79. package/.claude/skills/directive/docs/reference/templates/challenger-prompt.md +0 -35
  80. package/dist/00_Modern_Office_Singles.tsx +0 -4
  81. package/dist/Game.tiled-project +0 -14
  82. package/dist/Game.tiled-session +0 -90
  83. package/dist/Interiors.tsx +0 -4
  84. package/dist/Interiors_32x32.tsx +0 -4
  85. package/dist/Office_Design_1.tsx +0 -4
  86. package/dist/Office_Design_2.tsx +0 -4
  87. package/dist/assets/GamePage-B2OsBjXm.js +0 -49
  88. package/dist/assets/characters/char_0.png +0 -0
  89. package/dist/assets/characters/char_1.png +0 -0
  90. package/dist/assets/characters/char_10.png +0 -0
  91. package/dist/assets/characters/char_11.png +0 -0
  92. package/dist/assets/characters/char_2.png +0 -0
  93. package/dist/assets/characters/char_3.png +0 -0
  94. package/dist/assets/characters/char_4.png +0 -0
  95. package/dist/assets/characters/char_5.png +0 -0
  96. package/dist/assets/characters/char_6.png +0 -0
  97. package/dist/assets/characters/char_7.png +0 -0
  98. package/dist/assets/characters/char_8.png +0 -0
  99. package/dist/assets/characters/char_9.png +0 -0
  100. package/dist/assets/index-DCNBE1pw.css +0 -1
  101. package/dist/assets/office/Interiors.png +0 -0
  102. package/dist/assets/office/classroom.png +0 -0
  103. package/dist/assets/office/conference.png +0 -0
  104. package/dist/assets/office/furniture.png +0 -0
  105. package/dist/assets/office/generic.png +0 -0
  106. package/dist/assets/office/kitchen.png +0 -0
  107. package/dist/assets/office/livingroom.png +0 -0
  108. package/dist/assets/office/music-sport.png +0 -0
  109. package/dist/assets/office/room-builder.png +0 -0
  110. package/dist/classroom.tsx +0 -4
  111. package/dist/conference.tsx +0 -4
  112. package/dist/furniture.tsx +0 -4
  113. package/dist/generic.tsx +0 -4
  114. package/dist/kitchen.tsx +0 -4
  115. package/dist/livingroom.tsx +0 -4
  116. package/dist/music-sport.tsx +0 -4
  117. package/dist/office.tmx +0 -398
  118. package/dist/room-builder.tsx +0 -4
  119. package/dist-server/scripts/intelligence-trends.d.ts +0 -100
  120. package/dist-server/scripts/intelligence-trends.js +0 -365
  121. package/dist-server/server/actions/cleanup.d.ts +0 -4
  122. package/dist-server/server/actions/cleanup.js +0 -30
  123. package/dist-server/server/parsers/team-parser.d.ts +0 -3
  124. package/dist-server/server/parsers/team-parser.js +0 -67
  125. package/dist-server/server/watchers/claude-watcher.d.ts +0 -17
  126. package/dist-server/server/watchers/claude-watcher.js +0 -130
  127. package/dist-server/server/watchers/context-watcher.d.ts +0 -22
  128. package/dist-server/server/watchers/context-watcher.js +0 -125
@@ -35,7 +35,7 @@ DO NOT read source code. DO NOT edit files. DO NOT start solving the problem. Th
35
35
 
36
36
  Your FIRST action must be: Read the triage doc, classify the directive weight, output the triage block, and create directive.json. Only then proceed to the next pipeline step.
37
37
 
38
- If you catch yourself wanting to "just fix it quickly" — STOP. That impulse is exactly what the pipeline prevents. Even lightweight directives have a defined process (triage → context → planaudit → build → review → digest → completion). The COO plans for ALL weights.
38
+ If you catch yourself wanting to "just fix it quickly" — STOP. That impulse is exactly what the pipeline prevents. Even lightweight directives have a defined process (triage → context → auditplan → build → review → digest → completion). The COO plans for ALL weights.
39
39
 
40
40
  ---
41
41
 
@@ -54,12 +54,24 @@ This file is a routing table. Each row points to a modular doc containing full i
54
54
  3. Set `updated_at` to the current ISO timestamp
55
55
  4. Use the Write tool to overwrite the full directive.json
56
56
 
57
- **When starting a step**, set `pipeline.{stepId}.status` to `"active"`.
57
+ **When starting a step**, set `pipeline.{stepId}.status` to `"active"` and `pipeline.{stepId}.agent` to the array of participating agent first names (lowercase, e.g. `["sarah", "marcus", "morgan"]`). This is critical for the dashboard game view — the game reads step agents to route characters to the meeting room during brainstorm/plan/clarification steps. Without this, characters won't move.
58
58
 
59
59
  > **Why output is mandatory:** The dashboard renders pipeline step details directly from directive.json. Without `output.summary`, the UI shows empty steps — the CEO can't see what happened. Every step must leave a trace.
60
60
 
61
61
  The server's directive-watcher reads `directive.json` directly (NOT `current.json`) and pushes pipeline state to the dashboard via WebSocket. Keeping `pipeline` updated is what makes the stepper UI show real-time progress.
62
62
 
63
+ ### Step Execution Loop
64
+
65
+ After completing a step and updating directive.json, **immediately** read the next step's doc from the routing table below and execute it. Do NOT stop, do NOT pause, do NOT ask for confirmation between steps. The pipeline is designed to run end-to-end in a single pass.
66
+
67
+ **STOP gates — the only points where you must stop and wait for the CEO:**
68
+
69
+ 1. **`clarification`** — heavyweight/strategic: STOP and present synthesized intent for CEO verification. Lightweight/medium: **still run the step** (synthesize intent) but auto-approve without stopping. Do NOT skip this step — the verified_intent output feeds the COO planner.
70
+ 2. **`approve`** — heavyweight/strategic: STOP and present plan for CEO approval. Lightweight/medium: auto-approve without stopping.
71
+ 3. **`completion`** — all weights. The CEO must approve, amend, extend, or redirect the directive.
72
+
73
+ At every other step, transition directly to the next step without delay. If a step is skipped for the current weight class (brainstorm for lightweight/medium), set its status to "skipped" in directive.json and advance to the next step.
74
+
63
75
  ### Pipeline Steps
64
76
 
65
77
  | # | Step ID | Doc | Purpose | Depends On |
@@ -68,16 +80,17 @@ The server's directive-watcher reads `directive.json` directly (NOT `current.jso
68
80
  | 2 | checkpoint | [01-checkpoint.md](docs/pipeline/01-checkpoint.md) | Check for existing checkpoint, resume if found | — |
69
81
  | 3 | read | [02-read-directive.md](docs/pipeline/02-read-directive.md) | Read directive file + create directive.json | triage |
70
82
  | 4 | context | [03-read-context.md](docs/pipeline/03-read-context.md) | Read all context files before planning | read |
71
- | 5 | challenge | [04-challenge.md](docs/pipeline/04-challenge.md) | C-suite challenge (heavyweight only) | context |
72
- | 6 | plan | [05-planning.md](docs/pipeline/05-planning.md) | COO strategic planning | context |
73
- | 7 | audit | [06-technical-audit.md](docs/pipeline/06-technical-audit.md) | Technical codebase audit | plan |
74
- | 8 | approve | [07-plan-approval.md](docs/pipeline/07-plan-approval.md) | Present plan to CEO for approval | audit |
75
- | 9 | project-brainstorm | [07b-project-brainstorm.md](docs/pipeline/07b-project-brainstorm.md) | CTO + builder decompose projects into tasks with DOD | approve |
76
- | 10 | setup | [08-worktree-and-state.md](docs/pipeline/08-worktree-and-state.md) | Worktree isolation + directive state init | project-brainstorm |
77
- | 11 | execute | [09-execute-projects.md](docs/pipeline/09-execute-projects.md) | Execute all tasks (phases, agents, UX) | setup |
78
- | 12 | review-gate | [09-execute-projects.md](docs/pipeline/09-execute-projects.md) | Review verification gate (end of doc) | execute |
79
- | 13 | wrapup | [10-wrapup.md](docs/pipeline/10-wrapup.md) | OKRs, follow-ups, stale doc detection, digest, lessons, report | review-gate |
80
- | 14 | completion | [11-completion-gate.md](docs/pipeline/11-completion-gate.md) | CEO completion gate -- approve or reopen | wrapup |
83
+ | 5 | audit | [06-technical-audit.md](docs/pipeline/06-technical-audit.md) | Technical codebase audit | context |
84
+ | 6 | brainstorm | [04-brainstorm.md](docs/pipeline/04-brainstorm.md) | Approach brainstorm (includes challenge for heavyweight/strategic) | audit |
85
+ | 7 | clarification | [04b-clarification.md](docs/pipeline/04b-clarification.md) | Synthesize verified intent (auto-approve for lightweight/medium) | audit |
86
+ | 8 | plan | [05-planning.md](docs/pipeline/05-planning.md) | COO strategic planning | clarification |
87
+ | 9 | approve | [07-plan-approval.md](docs/pipeline/07-plan-approval.md) | Present plan to CEO for approval | plan |
88
+ | 10 | project-brainstorm | [07b-project-brainstorm.md](docs/pipeline/07b-project-brainstorm.md) | CTO + builder decompose projects into tasks with DOD | approve |
89
+ | 11 | setup | [08-worktree-and-state.md](docs/pipeline/08-worktree-and-state.md) | Worktree isolation + directive state init | project-brainstorm |
90
+ | 12 | execute | [09-execute-projects.md](docs/pipeline/09-execute-projects.md) | Execute all tasks (phases, agents, UX) | setup |
91
+ | 13 | review-gate | [09-execute-projects.md](docs/pipeline/09-execute-projects.md) | Review verification gate (end of doc) | execute |
92
+ | 14 | wrapup | [10-wrapup.md](docs/pipeline/10-wrapup.md) | OKRs, follow-ups, stale doc detection, digest, lessons, report | review-gate |
93
+ | 15 | completion | [11-completion-gate.md](docs/pipeline/11-completion-gate.md) | CEO completion gate -- approve, amend, extend, or redirect | wrapup |
81
94
 
82
95
  ### Reference Docs — Schemas
83
96
 
@@ -86,10 +99,9 @@ The server's directive-watcher reads `directive.json` directly (NOT `current.jso
86
99
  | [plan-schema.md](docs/reference/schemas/plan-schema.md) | COO plan output JSON schema |
87
100
  | [audit-output.md](docs/reference/schemas/audit-output.md) | Architect output JSON schema (design recommendations — second phase of two-agent audit) |
88
101
  | [investigation-output.md](docs/reference/schemas/investigation-output.md) | QA Engineer's investigation output JSON schema (pure data — first phase of two-agent audit) |
89
- | [checkpoint.md](docs/reference/schemas/checkpoint.md) | Checkpoint JSON schema (includes dod_verification field) |
102
+ | [checkpoint.md](docs/reference/schemas/checkpoint.md) | Checkpoint JSON schema (deprecated merged into directive-json.md) |
90
103
  | [directive-json.md](docs/reference/schemas/directive-json.md) | Directive JSON schema (THE source of truth — includes pipeline progress for dashboard) |
91
- | [challenger-output.md](docs/reference/schemas/challenger-output.md) | Challenger output JSON schema |
92
- | [brainstorm-output.md](docs/reference/schemas/brainstorm-output.md) | Brainstorm output JSON schema (proposals + rebuttals) |
104
+ | [brainstorm-output.md](docs/reference/schemas/brainstorm-output.md) | Brainstorm output JSON schema (proposals + rebuttals + challenge) |
93
105
 
94
106
  ### Reference Docs — Templates
95
107
 
@@ -99,8 +111,7 @@ The server's directive-watcher reads `directive.json` directly (NOT `current.jso
99
111
  | [investigator-prompt.md](docs/reference/templates/investigator-prompt.md) | Investigation prompt template for the QA Engineer (pure data gathering — first phase of audit) |
100
112
  | [architect-prompt.md](docs/reference/templates/architect-prompt.md) | Architect prompt template (design recommendations — second phase of audit) |
101
113
  | [auditor-prompt.md](docs/reference/templates/auditor-prompt.md) | Combined audit prompt for the CTO (single-agent path for simple tasks) |
102
- | [challenger-prompt.md](docs/reference/templates/challenger-prompt.md) | Challenger prompt template |
103
- | [brainstorm-prompt.md](docs/reference/templates/brainstorm-prompt.md) | Brainstorm agent prompt template (Phase 1 proposals + Phase 2 deliberation) |
114
+ | [brainstorm-prompt.md](docs/reference/templates/brainstorm-prompt.md) | Brainstorm agent prompt template (Phase 1 proposals + challenge + Phase 2 deliberation) |
104
115
  | [digest.md](docs/reference/templates/digest.md) | Digest report template |
105
116
 
106
117
  ### Reference Docs — Rules
@@ -116,6 +127,8 @@ The server's directive-watcher reads `directive.json` directly (NOT `current.jso
116
127
 
117
128
  | Script | Content |
118
129
  |--------|---------|
119
- | [validate-cast.sh](../../hooks/validate-cast.sh) | Mechanical casting validation — checks auditor present, builder != reviewer, complex has C-suite reviewer |
130
+ | [validate-cast.sh](../../hooks/validate-cast.sh) | Mechanical casting validation — checks reviewer present, builder != reviewer, complex/moderate has C-suite reviewer, no self-review of own prompts, depends_on valid, no circular deps |
120
131
  | [validate-project-json.sh](../../hooks/validate-project-json.sh) | Pre-execution gate — blocks execute step if project.json missing or incomplete (no tasks, no DOD, no scope) |
121
132
  | [detect-stale-docs.sh](../../hooks/detect-stale-docs.sh) | Post-directive — scans docs for references to modified files, flags potentially stale docs |
133
+ | [validate-gate.sh](../../hooks/validate-gate.sh) | Pipeline step gate — validates prerequisites before advancing to next step |
134
+ | [validate-reviews.sh](../../hooks/validate-reviews.sh) | Review-gate hard gate — blocks completion if reviews missing, detects self-review and self-certification |
@@ -8,15 +8,17 @@ Before doing anything else, kill orphaned CLI agents from prior runs. These accu
8
8
 
9
9
  ```bash
10
10
  # Kill orphaned CLI agent processes from prior runs
11
- ps aux | grep "claude.*--agent.*-p" | grep -v grep | awk '{print $2}' | xargs kill 2>/dev/null
12
- # Also kill any orphaned -p (print mode) processes without --agent
13
- ps aux | grep "claude -p" | grep -v grep | awk '{print $2}' | xargs kill 2>/dev/null
14
- # Kill orphaned spawn-agent.ts processes
11
+ # ONLY target --agent processes (spawned workers), NOT plain "claude -p" processes.
12
+ # Reason: this directive session itself runs inside a "claude -p" process.
13
+ # Killing all "claude -p" matches would kill our own parent process (the session
14
+ # running this pipeline). Orphans are always --agent child processes, never the
15
+ # parent session.
16
+ ps aux | grep "claude.*--agent" | grep -v grep | awk '{print $2}' | xargs kill 2>/dev/null
15
17
  ps aux | grep "spawn-agent" | grep -v grep | awk '{print $2}' | xargs kill 2>/dev/null
16
18
  echo "Pre-flight cleanup: killed orphaned agent processes"
17
19
  ```
18
20
 
19
- This is safe — active CLI agents for the current directive haven't been spawned yet, so there's nothing to accidentally kill.
21
+ This is safe — active CLI agents for the current directive haven't been spawned yet, and we only target `--agent` child processes (not the parent `claude -p` session).
20
22
 
21
23
  ### Classify the Directive
22
24
 
@@ -90,7 +92,7 @@ No C-suite challenges. No brainstorm. No plan-approval gate. No worktree (unless
90
92
  ### Medium Process
91
93
 
92
94
  1. Read full context (read + context steps)
93
- 2. Spawn the COO to plan projects (plan) -- the COO's inline challenge is always included, but skip separate C-suite challengers (challenge step)
95
+ 2. Spawn the COO to plan projects (plan) -- the COO's inline challenge is always included, but skip the brainstorm step (no separate brainstorm agents)
94
96
  3. Spawn auditor for technical baseline (audit)
95
97
  4. **No plan-approval gate** -- auto-approve the plan based on directive scope and guardrails
96
98
  5. Create branch (setup) — worktree only if working directory is dirty
@@ -153,7 +155,7 @@ Same as heavyweight but with an additional deliberation round during brainstorm.
153
155
 
154
156
  ### Heavyweight Process
155
157
 
156
- Full pipeline: triage → read → context → challenge → **Brainstorm** → planaudit → approve → project-brainstorm → setup → execute → review-gate → wrapup → completion.
158
+ Full pipeline: triage → checkpoint → read → context → audit → **brainstorm** → clarificationplan → approve → project-brainstorm → setup → execute → review-gate → wrapup → completion.
157
159
 
158
160
  **Brainstorm phase (mandatory for heavyweight):** Before the COO plans, spawn the brainstorm team in parallel using `run_in_background: true`. The brainstorm team includes:
159
161
  - **2-3 relevant C-suite agents** (the CTO for architecture, the CPO for product, the CMO for growth — pick based on directive domain)
@@ -181,3 +183,7 @@ Agent tool call (per brainstorm agent):
181
183
  > See [docs/reference/schemas/brainstorm-output.md](../reference/schemas/brainstorm-output.md) for the brainstorm agent output JSON schema.
182
184
 
183
185
  For the CEO approval gate (approve step): write the plan to `.context/directives/{directive-id}/plan-for-approval.md` and STOP. Output a summary asking the CEO to approve. Include brainstorm synthesis and any clarifying questions alongside the COO's plan. After CEO approval, continue execution from the setup step.
186
+
187
+ ### Test Mode
188
+
189
+ Directives with `test_mode: true` in directive.json are automated smoke tests created by the `/smoke-test` skill. The pipeline runs normally but the completion gate auto-approves instead of waiting for CEO sign-off. Do NOT set `test_mode` on real directives.
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Step 0: Check for Existing Progress
4
4
 
5
- Check if `.context/directives/$ARGUMENTS.json` exists AND has a `current_step` field (indicating previous execution progress).
5
+ Check if `.context/directives/$ARGUMENTS/directive.json` exists AND has a `current_step` field (indicating previous execution progress).
6
6
 
7
7
  **If not found or no `current_step`:** Proceed to the read step normally.
8
8
 
@@ -26,7 +26,30 @@ Create `.context/directives/$ARGUMENTS/directive.json` if it doesn't already exi
26
26
  "weight": "{classification from triage: lightweight | medium | heavyweight | strategic}",
27
27
  "produced_features": [],
28
28
  "report": null,
29
- "backlog_sources": []
29
+ "backlog_sources": [],
30
+ "dod": {
31
+ "success_looks_like": [],
32
+ "failure_looks_like": [],
33
+ "quality_bar": "",
34
+ "examples": []
35
+ }
30
36
  }
31
37
  ```
32
38
 
39
+ ### Extract directive-level DOD from the CEO brief
40
+
41
+ After creating directive.json, scan the CEO brief (directive.md) and extract a best-effort definition of done into `directive.json.dod`. This is the CEO's intent translated into structured acceptance criteria.
42
+
43
+ **How to extract each field:**
44
+
45
+ 1. **success_looks_like** -- Look for phrases describing desired outcomes, goals, or "I want X to happen." Convert each into a concrete, verifiable statement. One array entry per distinct outcome.
46
+ 2. **failure_looks_like** -- Look for complaints about the current state, phrases like "the problem is...", "this doesn't work because...", or "stop doing X." Invert these into failure conditions. If the brief says "agents ignore the brainstorm output", the failure condition is "Builder output diverges from brainstorm without documented rationale."
47
+ 3. **quality_bar** -- Synthesize the brief's overall standard into one sentence. If the brief mentions specific metrics, thresholds, or comparisons ("better than X", "zero regressions", "passes on first review"), use those. If no explicit bar exists, leave empty -- the clarification step will ask.
48
+ 4. **examples** -- Extract any before/after scenarios, reference implementations, or concrete illustrations the CEO provides. Format as "Before: ... / After: ..." strings. If the brief has none, leave the array empty.
49
+
50
+ **Important:** This extraction is best-effort. The clarification step will present the extracted DOD back to the CEO for verification. Do not block on incomplete extraction -- empty fields are acceptable at this stage.
51
+
52
+ ### Update directive.json
53
+
54
+ Set `current_step: "context"` (the next step). Update `pipeline.read.status` to `"completed"` with output summary including the directive title, weight, and DOD extraction status.
55
+
@@ -9,5 +9,10 @@ Read ALL of these before spawning the COO:
9
9
  - `.context/lessons/*.md` — project gotchas and patterns (read topic files as needed per agent role)
10
10
  - `.context/lessons/orchestration.md` — for the COO and orchestration
11
11
  - `.context/lessons/agent-behavior.md` — for all agents
12
+ - `.context/design/*.md` — system design rationale (why the system works the way it does). Read all design docs — they are short and high-signal. Pass relevant ones to agents based on task domain.
12
13
  - All `.context/directives/*/projects/*/project.json` — current project states and task status
13
14
  - The C-suite agent personality files (resolve names from `.claude/agent-registry.json`)
15
+
16
+ ### Update directive.json
17
+
18
+ Set `current_step: "audit"` (the next step). Update `pipeline.context.status` to `"completed"` with output summary listing what was read.
@@ -0,0 +1,77 @@
1
+ <!-- Pipeline doc: 04-brainstorm.md | Step: brainstorm -->
2
+
3
+ ## Brainstorm: Approach Exploration (Heavyweight/Strategic Only)
4
+
5
+ **Lightweight and medium directives skip this step entirely.** Advance to the next step.
6
+
7
+ For heavyweight and strategic directives, this step spawns brainstorm agents to explore approaches before the COO plans. The audit has already run -- audit findings feed into every proposal so approaches are grounded in codebase reality.
8
+
9
+ ### Participants
10
+
11
+ Spawn 2-3 C-suite agents + the auditor (CTO or architect) from the agent registry. Select participants based on the directive's domain:
12
+
13
+ - **Technical / architecture / debt** -- CTO + relevant builder
14
+ - **User-facing / product** -- CPO + CTO
15
+ - **Growth / SEO / marketing** -- CMO + CPO
16
+ - **Cross-domain** -- CTO + CPO + the most relevant third (CMO or a domain specialist)
17
+
18
+ The auditor who ran the technical audit step always participates -- they ground proposals in codebase reality.
19
+
20
+ ### Step Entry — Update directive.json immediately
21
+
22
+ Before spawning any agents, write `pipeline.brainstorm` to directive.json with `"status": "active"` and `"agent"` set to the array of selected participant first names (lowercase). The agent list must match whoever you chose from the Participants section above — it is NOT a fixed set. This update triggers the dashboard game to route those characters to the meeting room.
23
+
24
+ ### Process
25
+
26
+ **Phase 1 -- Proposals (+ Challenge)**
27
+
28
+ Spawn each participant in parallel using `run_in_background: true` with the brainstorm prompt template.
29
+
30
+ > See [brainstorm-prompt.md](../reference/templates/brainstorm-prompt.md) for the full prompt template. The template includes a `{challenge_instruction}` block that fires for heavyweight/strategic -- each agent critically evaluates the directive before proposing their approach.
31
+
32
+ > See [brainstorm-output.md](../reference/schemas/brainstorm-output.md) for the output JSON schema.
33
+
34
+ Each agent produces:
35
+ - A concrete approach proposal (3-5 sentences)
36
+ - Tradeoffs and what to avoid
37
+ - A **challenge assessment** (heavyweight/strategic only) -- risks, scope concerns, alternatives
38
+ - Feasibility flags grounded in audit findings (auditor agent)
39
+
40
+ **Phase 2 -- Deliberation (Strategic ONLY)**
41
+
42
+ For strategic directives only: after collecting all Phase 1 proposals, share them with each agent for one rebuttal round. Each agent sees all proposals and writes one targeted critique. See the brainstorm-prompt.md Phase 2 section for the rebuttal prompt.
43
+
44
+ Heavyweight directives skip Phase 2 -- proposals and challenge assessments are sufficient.
45
+
46
+ **Synthesis**
47
+
48
+ After collecting all outputs, synthesize into a brainstorm artifact:
49
+ - Identify convergence points across proposals
50
+ - Surface key disagreements and unresolved concerns from challenge assessments
51
+ - For strategic: note which critiques landed and which proposals survived challenge
52
+ - Extract 1-3 CEO clarification questions from unresolved concerns (used in the clarification step)
53
+
54
+ Write the synthesis to `.context/directives/{id}/brainstorm.md`.
55
+
56
+ ### Spawn Pattern
57
+
58
+ ```
59
+ Agent tool call (per participant):
60
+ subagent_type: "{agent_id from registry}"
61
+ model: "sonnet"
62
+ run_in_background: true
63
+ prompt: |
64
+ {brainstorm prompt from brainstorm-prompt.md, with challenge_instruction included}
65
+ ```
66
+
67
+ Collect results using TaskOutput for each agent ID. Wait for all to return.
68
+
69
+ ### Error Handling
70
+
71
+ If a background agent fails or times out, log the error and continue. Brainstorm is advisory -- a failed participant does not block the pipeline. If ALL agents fail, note "brainstorm phase unavailable" and proceed.
72
+
73
+ ### Update directive.json
74
+
75
+ Set `current_step: "clarification"` (the next step). Update `pipeline.brainstorm.status` to `"completed"` with `agent` (the participant first names array, same as the step entry), output summary including the brainstorm synthesis and any challenge assessments, and `artifacts: [".context/directives/{id}/brainstorm.md"]` if a brainstorm artifact was written.
76
+
77
+ **Next step:** Proceed to [04b-clarification.md](04b-clarification.md) (clarification) to verify directive intent with the CEO before the COO plans.
@@ -0,0 +1,222 @@
1
+ <!-- Pipeline doc: 04b-clarification.md | Source: enrich-agent-behaviors directive -->
2
+
3
+ ## Clarification: Verify Directive Intent with CEO
4
+
5
+ After the brainstorm completes, the pipeline has three sources of intent:
6
+ the CEO brief (directive.md), audit findings, and brainstorm proposals.
7
+ These sources often conflict or leave gaps. This step synthesizes them
8
+ into a structured intent block and verifies it with the CEO before the
9
+ COO plans against it.
10
+
11
+ **Why this exists:** The COO plans against whatever intent it receives.
12
+ If intent is ambiguous, the COO guesses -- and the entire downstream
13
+ pipeline (tasks, DOD, builds, reviews) inherits that guess. Catching
14
+ misalignment here costs one CEO interaction. Catching it after execution
15
+ costs a full reopen cycle.
16
+
17
+ ---
18
+
19
+ ### Step Entry — Update directive.json immediately
20
+
21
+ Before reading inputs, write `pipeline.clarification` to directive.json with `"status": "active"` and `"agent"` set to the participants. For heavyweight/strategic, include the brainstorm participants who contributed to the synthesis alongside the CEO. For lightweight/medium, set to `["pipeline"]` (auto-approved). This triggers the dashboard game to route characters to the meeting room.
22
+
23
+ ### Inputs
24
+
25
+ | Source | File | What to extract |
26
+ |--------|------|-----------------|
27
+ | CEO brief | `.context/directives/{id}/directive.md` | Original goals, constraints, quality expectations |
28
+ | Directive DOD | `.context/directives/{id}/directive.json` → `dod` | Best-effort DOD extracted in the read step |
29
+ | Audit findings | `.context/directives/{id}/audit.md` | Technical constraints, complexity flags, dead code |
30
+ | Brainstorm output | `.context/directives/{id}/brainstorm.md` | Approach proposals, trade-offs, feasibility flags |
31
+
32
+ Read all four sources. If any file is missing (e.g., audit skipped for
33
+ lightweight), proceed with what is available.
34
+
35
+ ---
36
+
37
+ ### Step 1: Synthesize Intent
38
+
39
+ Extract a `verified_intent` object from the combined sources:
40
+
41
+ ```json
42
+ {
43
+ "goal": "One sentence: what the directive achieves when done",
44
+ "constraints": [
45
+ "Technical or process constraint derived from brief + audit",
46
+ "e.g., 'Must not break existing session scanner detection'",
47
+ "e.g., 'Budget: no new dependencies'"
48
+ ],
49
+ "quality_bar": "The minimum acceptable standard in one sentence -- derived from brief + audit baseline",
50
+ "acceptance_scenarios": [
51
+ {
52
+ "scenario": "Short label for the scenario",
53
+ "given": "Starting state or precondition",
54
+ "when": "Action or trigger",
55
+ "then": "Observable outcome that proves success"
56
+ }
57
+ ],
58
+ "out_of_scope": [
59
+ "Explicitly excluded work -- derived from brief + brainstorm 'avoid' fields",
60
+ "e.g., 'Schema changes in work-item-types.ts (handled by separate directive)'"
61
+ ]
62
+ }
63
+ ```
64
+
65
+ **Extraction rules:**
66
+
67
+ 1. **goal** -- Synthesize from the CEO brief's first paragraph + brainstorm
68
+ convergence points. One sentence, active voice, concrete outcome.
69
+ 2. **constraints** -- Merge technical constraints from the audit (active file
70
+ counts, dependency limits, pattern requirements) with process constraints
71
+ from the brief ("no regressions", "backward compatible"). One entry per
72
+ constraint.
73
+ 3. **quality_bar** -- Use `directive.json.dod.quality_bar` if populated. If
74
+ empty, derive from the brief's language about acceptable outcomes. If the
75
+ brief gives no quality signal, set to `""` and flag for CEO input.
76
+ 4. **acceptance_scenarios** -- Convert `directive.json.dod.success_looks_like`
77
+ entries into given/when/then format. Add scenarios from the brainstorm's
78
+ feasibility flags (negative cases the audit surfaced). Aim for 2-5
79
+ scenarios.
80
+ 5. **out_of_scope** -- Collect from brainstorm `avoid` fields, audit dead code
81
+ flags, and any explicit exclusions in the brief. One entry per exclusion.
82
+
83
+ ---
84
+
85
+ ### Step 2: CEO Verification (weight-dependent)
86
+
87
+ #### Test Mode Auto-Approve
88
+
89
+ If `directive.json` has `test_mode: true`, skip the weight-dependent CEO verification
90
+ and auto-approve immediately:
91
+
92
+ 1. Step 1 (Synthesize Intent) MUST have already run fully -- this is the whole point
93
+ of Option B gate simulation
94
+ 2. Auto-approve the synthesized `verified_intent` as-is, regardless of directive weight
95
+ 3. Log: `[TEST_MODE] Auto-approved clarification for {directive-name}`
96
+ 4. Continue directly to Step 3 (Store Verified Intent) -- set `"agent": "pipeline"`,
97
+ `"auto_approved": true`, `"modifications": []`
98
+
99
+ This is used by the `/smoke-test` skill for pipeline E2E testing. **NEVER** set
100
+ `test_mode: true` on a real directive -- it bypasses the CEO's intent verification.
101
+
102
+ If `test_mode` is not set, proceed to the weight-dependent logic below.
103
+
104
+ #### Heavyweight / Strategic: STOP gate -- CEO must verify
105
+
106
+ Present each field of the `verified_intent` to the CEO for piece-by-piece
107
+ confirmation. Use this format:
108
+
109
+ ```
110
+ ## Intent Verification
111
+
112
+ I've synthesized the directive intent from your brief, the technical
113
+ audit, and the team brainstorm. Please verify each item.
114
+
115
+ ### Goal
116
+ > {goal}
117
+ Confirm / Modify?
118
+
119
+ ### Constraints
120
+ 1. {constraint_1} -- Confirm / Modify / Remove?
121
+ 2. {constraint_2} -- Confirm / Modify / Remove?
122
+ ...
123
+
124
+ ### Quality Bar
125
+ > {quality_bar}
126
+ Confirm / Modify?
127
+
128
+ ### Acceptance Scenarios
129
+ 1. **{scenario}**: Given {given}, when {when}, then {then}
130
+ Confirm / Modify / Remove?
131
+ 2. ...
132
+
133
+ ### Out of Scope
134
+ 1. {item_1} -- Confirm / Modify / Remove?
135
+ 2. ...
136
+
137
+ ### Anything Missing?
138
+ Are there constraints, scenarios, or exclusions not captured above?
139
+ ```
140
+
141
+ Wait for the CEO to respond. Process each response:
142
+
143
+ - **Confirm** -- keep the item as-is
144
+ - **Modify** -- replace with the CEO's revised text
145
+ - **Remove** -- delete from the intent block
146
+ - **Add** -- append new items the CEO provides
147
+
148
+ If the CEO modifies the goal or quality bar, re-check whether existing
149
+ acceptance scenarios still align. Flag any that no longer match.
150
+
151
+ If the quality_bar was empty and the CEO does not provide one, set a
152
+ default: `"All DOD criteria met; code review passes on first cycle"` and
153
+ note it in the output summary.
154
+
155
+ #### Lightweight / Medium: Auto-approve with log
156
+
157
+ Do NOT present to the CEO. Instead:
158
+
159
+ 1. Synthesize the `verified_intent` as described in Step 1
160
+ 2. Log: `[CLARIFICATION] Auto-approved intent for {weight} directive`
161
+ 3. Log the synthesized goal and constraint count for traceability
162
+ 4. Continue to the next step immediately
163
+
164
+ ---
165
+
166
+ ### Step 3: Store Verified Intent
167
+
168
+ Write the verified intent into directive.json at
169
+ `pipeline.clarification.output.verified_intent`:
170
+
171
+ ```json
172
+ {
173
+ "pipeline": {
174
+ "clarification": {
175
+ "status": "completed",
176
+ "agent": "CEO",
177
+ "output": {
178
+ "summary": "CEO verified intent: {1-sentence summary of changes}",
179
+ "verified_intent": {
180
+ "goal": "...",
181
+ "constraints": ["..."],
182
+ "quality_bar": "...",
183
+ "acceptance_scenarios": [
184
+ { "scenario": "...", "given": "...", "when": "...", "then": "..." }
185
+ ],
186
+ "out_of_scope": ["..."]
187
+ },
188
+ "modifications": ["List of items the CEO modified, if any"],
189
+ "auto_approved": false
190
+ }
191
+ }
192
+ }
193
+ }
194
+ ```
195
+
196
+ For auto-approved (lightweight/medium), set `"agent": "pipeline"`,
197
+ `"auto_approved": true`, and `"modifications": []`.
198
+
199
+ Also update `directive.json.dod` with the verified values:
200
+ - `dod.quality_bar` = `verified_intent.quality_bar`
201
+ - `dod.success_looks_like` = one entry per acceptance scenario's `then` field
202
+ - `dod.failure_looks_like` = inverse of each constraint (if constraint is
203
+ "no regressions", failure is "regressions introduced")
204
+
205
+ This keeps `dod` in sync with verified intent for downstream consumers
206
+ (project-brainstorm, review-gate) that read `dod` directly.
207
+
208
+ ---
209
+
210
+ ### Update directive.json
211
+
212
+ Set `current_step: "plan"` (the next step).
213
+
214
+ Set `pipeline.clarification.status` to `"completed"` with the output
215
+ block described above. Include `artifacts: []` (no separate file -- the
216
+ verified intent lives inside directive.json).
217
+
218
+ Update `updated_at` to the current ISO timestamp.
219
+
220
+ **Next step:** Proceed to [05-planning.md](05-planning.md) (plan). The
221
+ COO receives `pipeline.clarification.output.verified_intent` as a
222
+ primary input for planning.
@@ -1,12 +1,19 @@
1
1
  <!-- Pipeline doc: 05-planning.md | Source: SKILL.md restructure -->
2
2
 
3
- ## Step 3: Spawn the COO (Strategic Planning)
3
+ ## Plan: Spawn the COO (Strategic Planning)
4
4
 
5
5
  Spawn the COO as an Agent (model: opus, subagent_type: COO's ID from registry).
6
6
 
7
+ ### Step Entry — Update directive.json immediately
8
+
9
+ Before spawning the COO, write `pipeline.plan` to directive.json with `"status": "active"` and `"agent"` set to the COO's first name (lowercase). This triggers the dashboard game to route the COO character to the meeting room.
10
+
7
11
  **The COO's prompt must include:**
8
12
  - The CEO directive text (personality is auto-loaded via the `subagent_type`)
9
13
  - The goals index, lessons, and agent summaries from the context step
14
+ - **Audit findings** (from the audit step) -- the COO receives these as input. If the audit reveals complexity exceeding the triage estimate, the COO should flag it in `challenges.risks` and adjust project decomposition accordingly.
15
+ - **Brainstorm synthesis** from `.context/directives/{directive-id}/brainstorm.md` -- the team's approach proposals, trade-offs, and (for heavyweight/strategic) challenge critiques. The COO should use this to inform project decomposition rather than re-deriving the approach from scratch.
16
+ - **Verified intent** from the clarification step (`pipeline.clarification.output.verified_intent` in directive.json) -- this is the CEO-confirmed goal, constraints, quality bar, acceptance scenarios, and out-of-scope items. Inject it into the planner prompt at the `{verified_intent}` placeholder. If the clarification step was auto-approved or skipped, pass the synthesized intent (which still contains extracted constraints and scenarios).
10
17
  - These explicit instructions:
11
18
 
12
19
  > See [docs/reference/templates/planner-prompt.md](../reference/templates/planner-prompt.md) for the full COO planning prompt.
@@ -19,10 +26,7 @@ Spawn the COO as an Agent (model: opus, subagent_type: COO's ID from registry).
19
26
 
20
27
  > See [docs/reference/rules/scope-and-dod.md](../reference/rules/scope-and-dod.md) for scope format rules, Definition of Done rules, and user scenario rules.
21
28
 
22
- **If this directive was classified as strategic**, also include in the COO's prompt:
23
- - The brainstorm synthesis from `.context/directives/{directive-id}/brainstorm.md`
24
- - CEO's clarification answers
25
- - Additional instruction to the COO: "The team has brainstormed approach options for this directive. Use the brainstorm synthesis and CEO's answers to inform your plan — you don't need to re-derive the approach from scratch. Focus on execution planning, not strategy."
29
+ **Additional instruction for the COO:** "The team has brainstormed approach options and the CTO has audited the codebase. Use the brainstorm synthesis, CEO's clarification answers, and audit findings to inform your plan -- focus on execution planning, not strategy re-derivation."
26
30
 
27
31
  **Parse the COO's response** as JSON. Extract the JSON object from the response (find the first `{` and last `}`). If it fails to parse, show the error and stop.
28
32
 
@@ -36,7 +40,7 @@ Save the COO's parsed JSON plan to `.context/directives/{directive-id}/plan.json
36
40
 
37
41
  If the COO's plan contains a `projects` array (triggered when genuinely complex work can't be decomposed into simple tasks):
38
42
 
39
- 1. **Verify projects are independent** — if project B depends on project A's output (shared code, shared data structures, one builds on the other), they MUST be merged into a single project with ordered tasks. Task array ordering IS the dependency mechanism. There is no cross-project dependency field.
43
+ 1. **Verify projects are independent or use depends_on** — if project B depends on project A's output (shared code, shared data structures, one builds on the other), either merge into a single project with ordered tasks, or set `depends_on: ["project-a"]` in the COO plan to enforce execution order. For tightly coupled work sharing code dependencies, prefer merging into ONE project.
40
44
  2. **Create a separate project directory and project.json for each independent project** in the approve step (after CEO approval)
41
45
  3. **Each project gets its own brainstorm** (2-3 agents + deliberation) before build
42
46
  4. **Each project gets its own execution cycle** in the execute step: brainstorm -> audit -> build -> review -> verify
@@ -52,13 +56,21 @@ echo "$PLAN_JSON" | .claude/hooks/validate-cast.sh
52
56
  ```
53
57
 
54
58
  The script checks:
55
- 1. Every task has an auditor assigned
56
- 2. Builder is not in the reviewers array (conflict of interest)
57
- 3. Complex tasks (5+ phases) have at least one C-suite reviewer
59
+ 1. Every project has at least one reviewer assigned
60
+ 2. Builder (agent[]) is not in the reviewers array (conflict of interest)
61
+ 3. Complex or moderate projects have at least one C-suite reviewer
58
62
  4. Agents don't review changes to their own behavior/prompts
63
+ 5. `depends_on` references point to existing project IDs
64
+ 6. No circular dependencies in the `depends_on` graph
59
65
 
60
66
  If validation fails (`valid: false`), log the violations and either:
61
67
  - **Auto-fix** if the violation is clear (e.g., swap a conflicting reviewer for the next-best match per casting rules)
62
68
  - **Block** and re-prompt the COO with the violations if auto-fix isn't possible
63
69
 
64
70
  > See `.claude/hooks/validate-cast.sh` for the validation script (copied to consumer project by `/gruai-config`).
71
+
72
+ ### Update directive.json
73
+
74
+ Set `current_step: "approve"` (the next step). Update `pipeline.plan.status` to `"completed"` with `agent: ["morgan"]`, output summary including the plan goal and project count, and `artifacts: [".context/directives/{id}/plan.json"]`.
75
+
76
+ **Next step:** Proceed to [07-plan-approval.md](07-plan-approval.md) (approve) to present the combined plan to the CEO.