gru-ai 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 (143) hide show
  1. package/.claude/skills/brainstorm/SKILL.md +340 -0
  2. package/.claude/skills/code-review-excellence/SKILL.md +198 -0
  3. package/.claude/skills/directive/SKILL.md +121 -0
  4. package/.claude/skills/directive/docs/pipeline/00-delegation-and-triage.md +181 -0
  5. package/.claude/skills/directive/docs/pipeline/01-checkpoint.md +34 -0
  6. package/.claude/skills/directive/docs/pipeline/02-read-directive.md +38 -0
  7. package/.claude/skills/directive/docs/pipeline/03-read-context.md +15 -0
  8. package/.claude/skills/directive/docs/pipeline/04-challenge.md +38 -0
  9. package/.claude/skills/directive/docs/pipeline/05-planning.md +64 -0
  10. package/.claude/skills/directive/docs/pipeline/06-technical-audit.md +88 -0
  11. package/.claude/skills/directive/docs/pipeline/07-plan-approval.md +145 -0
  12. package/.claude/skills/directive/docs/pipeline/07b-project-brainstorm.md +85 -0
  13. package/.claude/skills/directive/docs/pipeline/08-worktree-and-state.md +50 -0
  14. package/.claude/skills/directive/docs/pipeline/09-execute-projects.md +709 -0
  15. package/.claude/skills/directive/docs/pipeline/10-wrapup.md +242 -0
  16. package/.claude/skills/directive/docs/pipeline/11-completion-gate.md +75 -0
  17. package/.claude/skills/directive/docs/reference/rules/casting-rules.md +78 -0
  18. package/.claude/skills/directive/docs/reference/rules/failure-handling.md +20 -0
  19. package/.claude/skills/directive/docs/reference/rules/phase-definitions.md +42 -0
  20. package/.claude/skills/directive/docs/reference/rules/scope-and-dod.md +30 -0
  21. package/.claude/skills/directive/docs/reference/schemas/audit-output.md +44 -0
  22. package/.claude/skills/directive/docs/reference/schemas/brainstorm-output.md +52 -0
  23. package/.claude/skills/directive/docs/reference/schemas/challenger-output.md +13 -0
  24. package/.claude/skills/directive/docs/reference/schemas/checkpoint.md +18 -0
  25. package/.claude/skills/directive/docs/reference/schemas/current-json.md +5 -0
  26. package/.claude/skills/directive/docs/reference/schemas/directive-json.md +143 -0
  27. package/.claude/skills/directive/docs/reference/schemas/investigation-output.md +37 -0
  28. package/.claude/skills/directive/docs/reference/schemas/plan-schema.md +103 -0
  29. package/.claude/skills/directive/docs/reference/templates/architect-prompt.md +66 -0
  30. package/.claude/skills/directive/docs/reference/templates/auditor-prompt.md +53 -0
  31. package/.claude/skills/directive/docs/reference/templates/brainstorm-prompt.md +68 -0
  32. package/.claude/skills/directive/docs/reference/templates/challenger-prompt.md +35 -0
  33. package/.claude/skills/directive/docs/reference/templates/digest.md +134 -0
  34. package/.claude/skills/directive/docs/reference/templates/investigator-prompt.md +51 -0
  35. package/.claude/skills/directive/docs/reference/templates/planner-prompt.md +130 -0
  36. package/.claude/skills/frontend-design/SKILL.md +42 -0
  37. package/.claude/skills/gruai-agents/SKILL.md +161 -0
  38. package/.claude/skills/gruai-config/SKILL.md +61 -0
  39. package/.claude/skills/healthcheck/SKILL.md +216 -0
  40. package/.claude/skills/report/SKILL.md +380 -0
  41. package/.claude/skills/scout/SKILL.md +452 -0
  42. package/.claude/skills/seo-audit/SKILL.md +107 -0
  43. package/.claude/skills/walkthrough/SKILL.md +274 -0
  44. package/.claude/skills/webapp-testing/SKILL.md +96 -0
  45. package/LICENSE +21 -0
  46. package/README.md +206 -0
  47. package/cli/templates/CLAUDE.md.template +57 -0
  48. package/cli/templates/agent-roles/backend.md +47 -0
  49. package/cli/templates/agent-roles/cmo.md +52 -0
  50. package/cli/templates/agent-roles/content.md +48 -0
  51. package/cli/templates/agent-roles/coo.md +66 -0
  52. package/cli/templates/agent-roles/cpo.md +52 -0
  53. package/cli/templates/agent-roles/cto.md +63 -0
  54. package/cli/templates/agent-roles/data.md +46 -0
  55. package/cli/templates/agent-roles/design.md +46 -0
  56. package/cli/templates/agent-roles/frontend.md +47 -0
  57. package/cli/templates/agent-roles/fullstack.md +47 -0
  58. package/cli/templates/agent-roles/qa.md +46 -0
  59. package/cli/templates/backlog.json.template +3 -0
  60. package/cli/templates/directive.json.template +9 -0
  61. package/cli/templates/directive.md.template +23 -0
  62. package/cli/templates/goals-index.md +21 -0
  63. package/cli/templates/gruai.config.json.template +12 -0
  64. package/cli/templates/lessons.md +16 -0
  65. package/cli/templates/vision.md +35 -0
  66. package/cli/templates/welcome-directive/directive.json +9 -0
  67. package/cli/templates/welcome-directive/directive.md +53 -0
  68. package/dist/assets/GamePage-C5XQQOQH.js +49 -0
  69. package/dist/assets/README.md +17 -0
  70. package/dist/assets/characters/char_0.png +0 -0
  71. package/dist/assets/characters/char_1.png +0 -0
  72. package/dist/assets/characters/char_10.png +0 -0
  73. package/dist/assets/characters/char_11.png +0 -0
  74. package/dist/assets/characters/char_2.png +0 -0
  75. package/dist/assets/characters/char_3.png +0 -0
  76. package/dist/assets/characters/char_4.png +0 -0
  77. package/dist/assets/characters/char_5.png +0 -0
  78. package/dist/assets/characters/char_6.png +0 -0
  79. package/dist/assets/characters/char_7.png +0 -0
  80. package/dist/assets/characters/char_8.png +0 -0
  81. package/dist/assets/characters/char_9.png +0 -0
  82. package/dist/assets/index-CnTPDqpP.js +12 -0
  83. package/dist/assets/index-gR5q7ikB.css +1 -0
  84. package/dist/assets/office/furniture.png +0 -0
  85. package/dist/assets/office/room-builder.png +0 -0
  86. package/dist/index.html +16 -0
  87. package/dist-server/scripts/intelligence-trends.d.ts +100 -0
  88. package/dist-server/scripts/intelligence-trends.js +365 -0
  89. package/dist-server/server/actions/cleanup.d.ts +4 -0
  90. package/dist-server/server/actions/cleanup.js +30 -0
  91. package/dist-server/server/actions/send-input.d.ts +6 -0
  92. package/dist-server/server/actions/send-input.js +147 -0
  93. package/dist-server/server/actions/terminal.d.ts +4 -0
  94. package/dist-server/server/actions/terminal.js +427 -0
  95. package/dist-server/server/config.d.ts +9 -0
  96. package/dist-server/server/config.js +217 -0
  97. package/dist-server/server/db.d.ts +7 -0
  98. package/dist-server/server/db.js +79 -0
  99. package/dist-server/server/hooks/event-receiver.d.ts +11 -0
  100. package/dist-server/server/hooks/event-receiver.js +36 -0
  101. package/dist-server/server/index.d.ts +1 -0
  102. package/dist-server/server/index.js +552 -0
  103. package/dist-server/server/notifications/macos.d.ts +5 -0
  104. package/dist-server/server/notifications/macos.js +22 -0
  105. package/dist-server/server/notifications/notifier.d.ts +17 -0
  106. package/dist-server/server/notifications/notifier.js +110 -0
  107. package/dist-server/server/parsers/process-discovery.d.ts +39 -0
  108. package/dist-server/server/parsers/process-discovery.js +776 -0
  109. package/dist-server/server/parsers/session-scanner.d.ts +56 -0
  110. package/dist-server/server/parsers/session-scanner.js +390 -0
  111. package/dist-server/server/parsers/session-state.d.ts +68 -0
  112. package/dist-server/server/parsers/session-state.js +696 -0
  113. package/dist-server/server/parsers/session-state.test.d.ts +1 -0
  114. package/dist-server/server/parsers/session-state.test.js +950 -0
  115. package/dist-server/server/parsers/task-parser.d.ts +10 -0
  116. package/dist-server/server/parsers/task-parser.js +97 -0
  117. package/dist-server/server/parsers/team-parser.d.ts +3 -0
  118. package/dist-server/server/parsers/team-parser.js +67 -0
  119. package/dist-server/server/platform/__tests__/claude-code.test.d.ts +1 -0
  120. package/dist-server/server/platform/__tests__/claude-code.test.js +311 -0
  121. package/dist-server/server/platform/claude-code.d.ts +34 -0
  122. package/dist-server/server/platform/claude-code.js +94 -0
  123. package/dist-server/server/platform/index.d.ts +5 -0
  124. package/dist-server/server/platform/index.js +1 -0
  125. package/dist-server/server/platform/types.d.ts +190 -0
  126. package/dist-server/server/platform/types.js +9 -0
  127. package/dist-server/server/state/aggregator.d.ts +42 -0
  128. package/dist-server/server/state/aggregator.js +1080 -0
  129. package/dist-server/server/state/work-item-types.d.ts +555 -0
  130. package/dist-server/server/state/work-item-types.js +168 -0
  131. package/dist-server/server/types.d.ts +237 -0
  132. package/dist-server/server/types.js +1 -0
  133. package/dist-server/server/watchers/claude-watcher.d.ts +17 -0
  134. package/dist-server/server/watchers/claude-watcher.js +130 -0
  135. package/dist-server/server/watchers/context-watcher.d.ts +22 -0
  136. package/dist-server/server/watchers/context-watcher.js +125 -0
  137. package/dist-server/server/watchers/directive-watcher.d.ts +46 -0
  138. package/dist-server/server/watchers/directive-watcher.js +497 -0
  139. package/dist-server/server/watchers/session-watcher.d.ts +18 -0
  140. package/dist-server/server/watchers/session-watcher.js +126 -0
  141. package/dist-server/server/watchers/state-watcher.d.ts +36 -0
  142. package/dist-server/server/watchers/state-watcher.js +369 -0
  143. package/package.json +68 -0
@@ -0,0 +1,242 @@
1
+ <!-- Pipeline doc: 10-wrapup.md | Source: SKILL.md restructure -->
2
+
3
+ ## Step 6: Category Context (if applicable)
4
+
5
+ The directive's category (from directive.json `category` field) provides domain context. No OKR updates needed -- categories are flat labels, not goals with OKRs.
6
+
7
+ ## Step 6b: Process Follow-Up Actions
8
+
9
+ Collect all `follow_ups` from the audit findings (audit step) across all tasks. Process them by risk level:
10
+
11
+ ### Low Risk — Auto-Execute
12
+
13
+ Spawn an engineer agent to execute all low-risk follow-ups in a single batch. The agent receives:
14
+ - The list of low-risk follow-up actions with affected files
15
+ - `.context/preferences.md` and `.context/lessons/*.md` topic files
16
+ - Instruction: "Execute these cleanup actions. They've been classified as low-risk (safe to do without CEO approval). Report what you changed."
17
+
18
+ **Low-risk examples:** Delete dead code files, remove unused imports, delete unused variables, create backlog tickets, update OKR status files, fix typos.
19
+
20
+ ### Medium Risk — Auto-Execute + Report with Revert Commands
21
+
22
+ Medium-risk follow-ups auto-execute without CEO approval, matching the low-risk pattern. The safety net is revert commands in the digest — the CEO can undo any action by copy-pasting the revert command.
23
+
24
+ Spawn an engineer agent to execute all medium-risk follow-ups in a single batch. The agent receives:
25
+ - The list of medium-risk follow-up actions with affected files
26
+ - `.context/preferences.md` and `.context/lessons/*.md` topic files
27
+ - Instruction: "Execute these follow-up actions. They've been classified as medium-risk (auto-executed, CEO can revert). For EACH action: (1) note the current git state before the change, (2) execute the action, (3) capture a revert command. Report what you changed and provide revert commands."
28
+
29
+ **Revert command generation:** After each medium-risk action, the engineer captures the information needed to undo it:
30
+ - For file modifications: `git checkout {commit-hash} -- {file-path}` (using the commit hash or HEAD before the change)
31
+ - For new files: `rm {file-path}`
32
+ - For deleted files: `git checkout {commit-hash} -- {file-path}`
33
+ - For multi-file changes: a combined revert command or script
34
+
35
+ The revert commands are included in the digest (see "Revert Commands" section in digest template).
36
+
37
+ **Medium-risk examples:** Fix auth gaps, add input validation, add middleware, refactor modules, change API behavior, update dependencies.
38
+
39
+ ### High Risk — Write to Backlog
40
+
41
+ For each high-risk follow-up, create a new directive in `.context/directives/{follow-up-id}/directive.json` as a pending directive:
42
+
43
+ ```json
44
+ {
45
+ "id": "{kebab-case-action-slug}",
46
+ "title": "{action title}",
47
+ "status": "pending",
48
+ "priority": "P1",
49
+ "source_directive": "$ARGUMENTS",
50
+ "context": "{what the audit found + risk rationale}",
51
+ "created": "{today YYYY-MM-DD}",
52
+ "updated": "{today YYYY-MM-DD}",
53
+ "promoted_to_feature": null,
54
+ "promoted_at": null
55
+ }
56
+ ```
57
+
58
+ Set `source_directive` to the current directive name so the backlog item is traceable back to this directive. This enables the cross-reference system to answer "which directive created this backlog item?"
59
+
60
+ **High-risk examples:** Schema changes, new API endpoints, infrastructure changes, auth flow changes, anything user-facing, anything that could affect revenue or SEO.
61
+
62
+ ### Skip follow-ups if:
63
+ - The directive is research-only (no code changes expected)
64
+ - No follow-ups were identified in the audit
65
+ - All tasks were skipped or failed (follow-ups may be invalid)
66
+
67
+ ## Step 6c: Detect Potentially Stale Docs
68
+
69
+ Run the stale documentation detection hook to find docs that reference files modified in this directive but were not themselves updated:
70
+
71
+ ```bash
72
+ .claude/hooks/detect-stale-docs.sh --from-diff main
73
+ ```
74
+
75
+ Or, if working in a worktree with a directive branch:
76
+
77
+ ```bash
78
+ .claude/hooks/detect-stale-docs.sh --from-diff directive/$ARGUMENTS
79
+ ```
80
+
81
+ The script scans `.context/` and `.claude/` docs for literal file path references to modified files, excluding docs that were also modified (zero false positives). Runs in <5 seconds.
82
+
83
+ Capture the output — it goes into the "Potentially Stale Docs" section of the digest. If the script outputs "No potentially stale docs detected," include that line in the digest section as-is.
84
+
85
+ ## Step 6d: Generate Digest
86
+
87
+ **This step runs LAST** — after OKRs are updated, follow-ups are processed, and stale docs are detected, so all data is available.
88
+
89
+ Write a digest to `.context/reports/$ARGUMENTS-{date}.md`.
90
+
91
+ **After writing the digest**, update directive.json with the report link:
92
+ - Read `.context/directives/$ARGUMENTS/directive.json`
93
+ - Set `report` to the report filename without extension (e.g., `"improve-security-2026-03-01"`)
94
+ - Also update `produced_features` if any features were registered in the "After Each Task" step but the directive.json wasn't updated yet
95
+
96
+ > See [docs/reference/templates/digest.md](../reference/templates/digest.md) for the full digest report template.
97
+
98
+ ## Step 6e: Update Lessons
99
+
100
+ If the directive produced new learnings, append them to the appropriate topic file:
101
+ - Agent behavior lessons → `.context/lessons/agent-behavior.md`
102
+ - Orchestration/planning lessons → `.context/lessons/orchestration.md`
103
+ - State/checkpoint/dashboard lessons → `.context/lessons/state-management.md`
104
+ - Review/quality lessons → `.context/lessons/review-quality.md`
105
+ - Pipeline/skill/repo lessons → `.context/lessons/skill-design.md`
106
+ - Project/codebase lessons → `.context/lessons/{topic}.md`
107
+
108
+ **Only add if:** something unexpected happened, a pattern emerged that prevents future mistakes, or a workaround was needed. Skip if the directive completed cleanly with no surprises.
109
+
110
+ **Format:** For failure-mode lessons, include what was tried and why it failed — not just the fix. Example: `**The COO produces prose before JSON despite "output ONLY JSON" instructions.** Fix: stronger preamble ("first character must be {") AND parse defensively.` For stable patterns/facts, a single sentence is fine.
111
+
112
+ Read existing topic files first to avoid duplicates.
113
+
114
+ **Consolidation trigger:** After every 10th directive (count reports in `.context/reports/`), re-read all reports and consolidate recurring patterns into the topic files. Remove one-off entries that haven't recurred. This keeps lessons actionable, not bloated.
115
+
116
+ **Personality evolution trigger:** On the same 10th-directive cycle, also update the `## Learned Patterns` section in each agent's personality file (`.claude/agents/*.md`). For each agent, extract lessons from `.context/lessons/` topic files that are relevant to their role:
117
+ - **COO** — operational patterns (sequencing, scoping, casting, compression)
118
+ - **CTO** — technical patterns (audit accuracy, review findings, schema issues, build failures)
119
+ - **CPO** — product patterns (UX verification, user perspective, feature management)
120
+ - **CMO** — growth patterns (content strategy, SEO, browser testing)
121
+
122
+ Replace the contents between `## Learned Patterns` and the next `##` heading. Keep each pattern as a single bullet with bold lead + explanation. Max 8 patterns per agent — keep only the most impactful.
123
+
124
+ ## Step 6f: Re-index State
125
+
126
+ The dashboard reads source files directly via glob + chokidar. No indexer step needed. Changes to project.json, directive.json are picked up automatically.
127
+
128
+ **Update directive.json:** Set `wrapup.digest_path` to the report path. Set `current_step: "wrapup"`. Update `pipeline.wrapup.status` to `"completed"` with output summary.
129
+
130
+ ## Step 6g: Mark Directive Awaiting Completion
131
+
132
+ Update the directive JSON to signal the CEO completion gate. The directive is NOT marked `completed` here -- that happens in the completion step after CEO approval.
133
+
134
+ ### Pre-completion Checks
135
+
136
+ 1. **Browser test check (IC2 fix):** If the directive has `browser_test: true` in any project.json, verify that UI review has been logged. If UI review is pending, do NOT proceed -- log: `[BLOCKED] UI review pending for {project}. Cannot mark awaiting_completion.`
137
+ 2. **Failed tasks check (IC3 fix):** If any tasks have `failed` or `partial` status, include an explanation in the digest. The CEO must be aware of incomplete work before approving completion.
138
+
139
+ ### Directive JSON
140
+ - Read `.context/directives/$ARGUMENTS/directive.json`
141
+ - Set `status` to `"awaiting_completion"`
142
+ - Set `report_summary` to the digest filename
143
+ - Write the updated JSON back
144
+
145
+ ### Project JSON(s)
146
+ - For each project in the directive's `produced_projects` array, read its `project.json`
147
+ - Do NOT set project status to `"completed"` yet -- that happens in the completion step after CEO approval
148
+ - If some tasks are incomplete, note this in the digest with explanations
149
+
150
+ Directives stay in `directives/` -- status is tracked in JSON, not by directory location.
151
+
152
+ **Next step:** Proceed to Report to CEO (below), then [completion gate](11-completion-gate.md) for CEO sign-off.
153
+
154
+ ## Step 7: Report to CEO
155
+
156
+ Show the CEO:
157
+ 1. The digest summary (not the full file — just the key points)
158
+ 2. Run `git diff --stat main..directive/$ARGUMENTS` to show ONLY this directive's changes — not pre-existing uncommitted work
159
+ 3. Any review findings that need attention
160
+ 4. Recommended next steps
161
+ 5. The branch name: "Review with `git log directive/$ARGUMENTS` and merge when ready"
162
+
163
+ ## Failure Handling
164
+
165
+ > See [docs/reference/rules/failure-handling.md](../reference/rules/failure-handling.md) for the full failure handling table.
166
+
167
+ | Situation | Action |
168
+ |-----------|--------|
169
+ | Challenger's output doesn't parse as JSON | Log the error, continue. Challenge is advisory, not blocking. |
170
+ | All challengers endorse | Note in approval presentation, proceed normally. |
171
+ | A challenger challenges the directive | Highlight prominently in approval presentation. CEO decides whether to proceed. |
172
+ | The COO's plan doesn't parse as JSON | Stop, show the raw output, ask CEO to intervene |
173
+ | Worktree creation fails | Warn CEO, work in the main repo instead. All changes are uncommitted, CEO can review with `git diff`. |
174
+ | Audit finds nothing for ALL tasks | Skip to stale doc detection, generate digest noting "no issues found", recommend CEO review the directive scope. |
175
+ | CEO rejects the plan | Stop. CEO can re-run with adjusted directive or manually edit the plan |
176
+ | Agent fails mid-task | Skip remaining phases in that task, continue to next. Log in digest. |
177
+ | Reviewer finds issues | Non-fatal. Include in digest. CEO decides whether to address. |
178
+ | Task is blocked | Skip, note in digest, continue to next task |
179
+ | All tasks fail | Generate digest showing failures, recommend CEO review |
180
+ | Audit finds nothing to fix | Remove task from plan, note in digest |
181
+ | Context exhaustion mid-directive | directive.json preserves state (it IS the checkpoint). Re-run `/directive {name}` to resume. |
182
+ | Brainstorm agents disagree on approach | Present all approaches with trade-offs in clarifying questions. Let CEO pick direction. Don't synthesize conflicting approaches into a compromise. |
183
+
184
+ ## Rules
185
+
186
+ ### NEVER
187
+ - Skip triage — must classify before choosing the process weight
188
+ - Run heavyweight process for lightweight work (wastes tokens and CEO attention)
189
+ - Run lightweight process for heavyweight work (skips critical safety gates)
190
+ - Execute heavyweight directives without CEO approval of the combined plan (COO + audit)
191
+ - Skip the planning phase (COO evaluation)
192
+ - Skip the technical audit (audit step) — always verify scope before CEO approval
193
+ - Skip the challenge step — the COO's inline challenge is always required; separate challengers only for heavyweight/controversial
194
+ - Have the COO scan the codebase (the COO plans strategy, not code)
195
+ - Run tasks in parallel without checking active_files overlap (see Parallelism Analysis in 09-execute-projects.md) -- tasks sharing files MUST be sequential; only non-overlapping tasks in the same priority tier can be parallelized
196
+ - Treat reviewer findings as blockers (they're advisory)
197
+ - Accept a review that only covers code quality without user-perspective evaluation
198
+ - Spawn agents without their personality files (for named agents)
199
+ - Commit, push, checkout, or reset git state (CEO manages git). Note: `git checkout -b` (setup step), `git worktree add` (setup step), and `git diff --stat` (wrapup report) are allowed — they're read-only or isolated operations.
200
+ - Add clarification phase to simple tasks with just ["build", "review"] phases -- tight scope makes it unnecessary token overhead
201
+ - Have the same agent review changes to its own behavior, prompts, or personality (conflict of interest)
202
+ - Run strategic process for directives with a clear prescribed approach (that's heavyweight, not strategic)
203
+ - Mark a directive as awaiting_completion when UI review is pending -- UI checks must pass first
204
+ - Set directive status to `completed` directly -- always go through `awaiting_completion` first (wrapup step), then CEO approves in completion step
205
+
206
+ ### ALWAYS
207
+ - Triage the directive before choosing which process to run
208
+ - Upgrade to heavyweight if ANY guardrail in vision.md could be affected
209
+ - Include the COO's inline challenge analysis in every plan — separate challengers for heavyweight/controversial only
210
+ - Read preferences.md + vision.md guardrails before spawning any agent
211
+ - Run technical audit before CEO approval to verify scope
212
+ - Read .context/lessons/ topic files before spawning any agent
213
+ - Include personality text in named agent prompts
214
+ - Include preferences.md + guardrails in all agent prompts
215
+ - Include audit findings in engineer prompts (active files, recommended approach)
216
+ - Include "propose what's missing" instruction in engineer prompts
217
+ - Log UI verification checks in the digest when tasks touch UI code -- CEO verifies from dashboard or game
218
+ - Include user-perspective evaluation in every reviewer prompt (not just code quality)
219
+ - Require `user_walkthrough` in engineer build reports and `user_perspective` in reviewer output
220
+ - Process follow-ups by risk level after tasks complete
221
+ - Run stale doc detection before generating the digest
222
+ - Include stale doc detection results in the digest
223
+ - Include self-assessment metrics in the digest
224
+ - Include agent-proposed improvements in the digest
225
+ - Include UX verification results in the digest
226
+ - Update lessons if the directive produced new learnings
227
+ - Log task status after each completes
228
+ - ~~Generate a digest even if everything fails~~ _Hook-enforced: stop hook blocks if no digest artifact for medium+ weight_
229
+ - Dashboard reads source files directly — no re-indexing needed
230
+ - Show the CEO what happened at the end
231
+ - Update directive.json after every phase transition (plan, approve, setup, execute phases, wrapup) — it IS the checkpoint
232
+ - Write artifact files after every phase output in execute step
233
+ - Update directive.json status to "awaiting_completion" after digest is written (wrapup) -- CEO approves in completion step
234
+ - Pipeline data stays in directive.json permanently — it's the execution record
235
+ - Include clarification phase before build when task has design/research/product-spec phases (the COO's phase list should already include it)
236
+ - Include task's definition_of_done in every reviewer prompt
237
+ - Include Standing Corrections check in every reviewer prompt
238
+ - Match reviewers to the domain being changed (process→COO, product→CPO, architecture→CTO)
239
+ - Never assign an agent to review changes to its own behavior or prompts
240
+ - Use file-pattern matching (*.tsx, *.jsx, *.css, etc.) to detect UI-touching tasks -- don't rely on subjective judgment
241
+ - Cast multiple reviewers when task crosses domains (UI + backend, process + product)
242
+ - Classify as strategic when the directive states a problem without prescribing an approach AND the work has lasting architectural/process consequences
@@ -0,0 +1,75 @@
1
+ <!-- Pipeline doc: 11-completion-gate.md | Source: pipeline-v2 directive -->
2
+
3
+ ## Completion: CEO Completion Gate
4
+
5
+ After the wrapup step generates the digest and reports to the CEO, the directive enters the completion gate. ALL directives -- including lightweight -- require CEO sign-off before the status changes to `completed`.
6
+
7
+ ### Status Flow
8
+
9
+ ```
10
+ executing -> awaiting_completion -> completed
11
+ -> reopened (CEO provides feedback, new projects added)
12
+ ```
13
+
14
+ ### After Wrapup
15
+
16
+ The wrapup step sets the directive status to `awaiting_completion` (NOT `completed`). This applies to all weight classes:
17
+
18
+ - **Lightweight**: Wrapup produces a short digest. Status becomes `awaiting_completion`. CEO reviews the digest summary and approves.
19
+ - **Medium**: Wrapup produces a full digest. Status becomes `awaiting_completion`. CEO reviews and approves.
20
+ - **Heavyweight/Strategic**: Wrapup produces a full digest. Status becomes `awaiting_completion`. CEO reviews digest + git diff + review findings before approving.
21
+
22
+ ### CEO Actions
23
+
24
+ Present the completion gate to the CEO with:
25
+
26
+ 1. The digest summary (key points, not the full file)
27
+ 2. `git diff --stat main..directive/$ARGUMENTS` showing this directive's changes
28
+ 3. Any review findings that need attention
29
+ 4. Tasks with `failed` or `partial` status (if any) -- with explanations from the digest
30
+
31
+ Then ask the CEO:
32
+
33
+ ```
34
+ Directive {name} is ready for completion review.
35
+
36
+ - Approve: Mark as completed. All work is satisfactory.
37
+ - Reopen: Provide feedback on what's missing. The COO will plan new projects.
38
+ ```
39
+
40
+ ### Approve Flow
41
+
42
+ When the CEO approves:
43
+
44
+ 1. Update `.context/directives/{id}/directive.json`:
45
+ - Set `status` to `"completed"`
46
+ - Set `completed` to today's date (`YYYY-MM-DD`)
47
+ 2. Update all project.json files in the directive's `produced_projects`:
48
+ - If all tasks completed, set project `status` to `"completed"`
49
+ 3. Log: `[COMPLETED] Directive {name} approved by CEO`
50
+
51
+ ### Reject / Reopen Flow
52
+
53
+ When the CEO reopens with feedback:
54
+
55
+ 1. Update `.context/directives/{id}/directive.json`:
56
+ - Set `status` to `"reopened"`
57
+ - Increment `revision` counter
58
+ - Add new entry to `iterations[]` with `opened_at` timestamp and CEO feedback
59
+ 2. Restart the pipeline from the plan step (COO planning) for NEW projects only
60
+ - Existing completed projects are untouched
61
+ - The COO plans additional projects to address CEO feedback
62
+ - Same approval flow applies to new projects
63
+ 3. Log: `[REOPENED] Directive {name} -- CEO feedback: {summary}`
64
+
65
+ ### Non-Interactive Sessions
66
+
67
+ When the directive runs as a CLI session (non-interactive):
68
+ - Write the digest to `.context/reports/`
69
+ - Set status to `awaiting_completion`
70
+ - The CEO reviews and approves via a subsequent session or dashboard action
71
+ - The directive is NOT done until the CEO explicitly approves
72
+
73
+ ### Update directive.json
74
+
75
+ Set `current_step: "completion"`. Set `pipeline.completion.status` to `"awaiting_completion"` with the digest path.
@@ -0,0 +1,78 @@
1
+ <!-- Reference: casting-rules.md | Source: SKILL.md restructure -->
2
+
3
+ # Casting Rules
4
+
5
+ ## Delegation Principle
6
+
7
+ C-suite agents (CTO, CPO, COO, CMO) focus on STRATEGY -- planning, auditing, challenging, and cross-cutting reviews. Specialists (frontend engineer, backend engineer, data engineer, content builder, QA engineer, full-stack engineer, UI/UX designer) handle EXECUTION -- building AND routine domain-specific reviews. Do NOT have C-suite do work that a specialist can handle. The orchestrator (directive session) delegates but does NOT build, review, or audit.
8
+
9
+ ## Auditing
10
+
11
+ - Security/architecture audits → the CTO
12
+ - User-facing/product audits → the CPO or CTO
13
+ - Growth/marketing audits → the CMO
14
+ - Routine codebase audits for simple tasks → specialists can audit their own domain (frontend engineer audits frontend, backend engineer audits backend, data engineer audits data pipelines)
15
+
16
+ ## Reviewing
17
+
18
+ - Simple frontend work → the frontend engineer reviews (not the CTO, unless security-sensitive)
19
+ - Simple backend work → the backend engineer reviews (not the CTO, unless architecture-sensitive)
20
+ - Simple data/pipeline work → the data engineer reviews
21
+ - QA/testing/validation → the QA engineer reviews
22
+ - UI design and visual quality → the UI/UX designer reviews (design review for any UI-touching task)
23
+ - Cross-cutting or architecture-sensitive work → the CTO reviews
24
+ - User-facing product/UX decisions → the CPO reviews
25
+ - Process/pipeline/operational changes → the COO reviews
26
+ - Growth/SEO/content quality → the CMO reviews
27
+ - Complex or risky work → C-suite reviewer + specialist reviewer (dual review)
28
+
29
+ ## General
30
+
31
+ - Simple work (1-2 phases) → specialist builder + specialist reviewer (same domain, different person if possible; same person OK if solo domain)
32
+ - Moderate work (3-4 phases) → specialist builder + C-suite reviewer (for strategic oversight)
33
+ - Complex work (5+ phases) → full team: C-suite designs/audits, specialist builds, C-suite + specialist review
34
+ - Every project MUST have an auditor — this is who scans the codebase in the audit step
35
+ - Match reviewers to the domain being changed -- don't default to the CTO for everything
36
+ - Never have the builder review their own build (conflict of interest)
37
+ - Never have an agent review changes to its own behavior/prompts (conflict of interest)
38
+
39
+ ## Specialist Builder Assignment (file-pattern matching)
40
+
41
+ When the audit reveals which files an task will touch, assign the matching specialist:
42
+ - Files in `src/components/`, `*.tsx`, `*.jsx`, or UI/styling work → the frontend engineer
43
+ - Files in `server/`, API routes, WebSocket, watchers, or backend logic → the backend engineer
44
+ - Files in `scripts/`, `server/parsers/`, `server/state/`, data pipelines, or indexing → the data engineer
45
+ - Files in `.context/`, `*.md`, `*.mdx`, documentation, or content creation → the content builder
46
+ - Testing, verification, type-checking, or QA-focused work → the QA engineer
47
+ - When scope crosses domains, use the DOMINANT domain's specialist
48
+ - When no clear domain match or scope is very broad → the full-stack engineer
49
+ - The full-stack engineer handles cross-domain work that doesn't clearly belong to a single specialist
50
+
51
+ ## Reviewer-Type Definitions
52
+
53
+ When casting reviewers, each type focuses on their domain:
54
+
55
+ ### C-Suite reviewers (strategic/cross-cutting -- use for complex, risky, or multi-domain work):
56
+ - **CTO (architecture/security)**: Code patterns, type safety, security vulnerabilities, performance, schema correctness, dependency risks. Use when work is security-sensitive, touches data models, or crosses system boundaries.
57
+ - **CPO (product/UX)**: User workflow completeness, product spec alignment, dead-end UI, first-impression clarity, CEO-intent match. Use when work affects what the CEO sees or touches.
58
+ - **COO (operations/process)**: Conductor process compliance, operational correctness, sequencing logic, casting rule adherence, checkpoint integrity. Use when work changes how the pipeline operates.
59
+ - **CMO (growth/content)**: SEO preservation, content quality, keyword targeting, internal linking, growth metric impact. Use when work affects public content or growth metrics.
60
+
61
+ ### Specialist reviewers (domain-specific -- use for routine, single-domain work):
62
+ - **Frontend engineer**: Component patterns, Tailwind conventions, state management, UI consistency, responsive behavior, accessibility. Use for routine frontend builds.
63
+ - **UI/UX designer**: Layout fidelity, visual consistency, usability, responsiveness, polish. Use as design reviewer on any UI-touching task. During planning, collaborates with the CTO to produce design prototypes.
64
+ - **Backend engineer**: API patterns, error handling, WebSocket correctness, watcher logic, server performance. Use for routine backend builds.
65
+ - **Data engineer**: Parser correctness, indexer logic, state file integrity, data pipeline accuracy. Use for data/pipeline builds.
66
+ - **QA engineer**: Type safety, build validation, test coverage, verification completeness, regression risk. Use as a second reviewer on any build for quality assurance.
67
+
68
+ ## Multi-Reviewer Casting Guidance
69
+
70
+ - Simple frontend work → the frontend engineer reviews (CTO only if security-sensitive)
71
+ - Simple backend work → the backend engineer reviews (CTO only if architecture-sensitive)
72
+ - Simple data work → the data engineer reviews
73
+ - UI-touching tasks that affect CEO workflow → the frontend engineer builds + UI/UX designer design-reviews + CPO reviews
74
+ - Complex/risky work → specialist builds + C-suite reviews (dual layer)
75
+ - Process/conductor changes → the COO reviews (owns the pipeline)
76
+ - Content/SEO work → the CMO reviews + the content builder builds
77
+ - Any task → optionally add the QA engineer as second reviewer for QA coverage
78
+ - Default: single specialist reviewer is fine for simple, single-domain work. Escalate to C-suite reviewer when the work is risky, cross-cutting, or user-facing.
@@ -0,0 +1,20 @@
1
+ <!-- Reference: failure-handling.md | Source: SKILL.md restructure -->
2
+
3
+ # Failure Handling
4
+
5
+ | Situation | Action |
6
+ |-----------|--------|
7
+ | Challenger's output doesn't parse as JSON | Log the error, continue. Challenge is advisory, not blocking. |
8
+ | All challengers endorse | Note in approval presentation, proceed normally. |
9
+ | A challenger challenges the directive | Highlight prominently in approval presentation. CEO decides whether to proceed. |
10
+ | The COO's plan doesn't parse as JSON | Stop, show the raw output, ask CEO to intervene |
11
+ | Worktree creation fails | Warn CEO, work in the main repo instead. All changes are uncommitted, CEO can review with `git diff`. |
12
+ | Audit finds nothing for ALL tasks | Skip to stale doc detection, generate digest noting "no issues found", recommend CEO review the directive scope. |
13
+ | CEO rejects the plan | Stop. CEO can re-run with adjusted directive or manually edit the plan |
14
+ | Agent fails mid-task | Skip remaining tasks in that task, continue to next. Log in digest. |
15
+ | Reviewer finds issues | Non-fatal. Include in digest. CEO decides whether to address. |
16
+ | Task is blocked | Skip, note in digest, continue to next task |
17
+ | All tasks fail | Generate digest showing failures, recommend CEO review |
18
+ | Audit finds nothing to fix | Remove task from plan, note in digest |
19
+ | Context exhaustion mid-directive | directive.json preserves state. Re-run `/directive {name}` to resume. |
20
+ | Brainstorm agents disagree on approach | Present all approaches with trade-offs in clarifying questions. Let CEO pick direction. Don't synthesize conflicting approaches into a compromise. |
@@ -0,0 +1,42 @@
1
+ <!-- Reference: phase-definitions.md | Source: SKILL.md restructure -->
2
+
3
+ # Phase Definitions — Composable Building Blocks
4
+
5
+ Instead of picking from a fixed process type taxonomy, specify the exact phases each task needs as an ordered array. Available phases:
6
+
7
+ - "research" — investigation, analysis, competitive intel (researcher agent)
8
+ - "product-spec" — product requirements + acceptance criteria (the CPO)
9
+ - "design" — technical approach document (the CTO)
10
+ - "keyword-research" — SEO keyword analysis (the CMO, for content work)
11
+ - "outline" — content structure and plan (the CMO, for content work)
12
+ - "clarification" — pre-build Q&A between engineer and designer/auditor (auto-added for complex work)
13
+ - "build" — implementation (engineer agent)
14
+ - "draft" — content writing (engineer, for content work)
15
+ - "seo-review" — SEO quality review (the CMO, for content work)
16
+ - "code-review" — independent review using cast reviewers with full files + diff but no builder reasoning (fresh eyes catch bugs)
17
+ - "review" — code/quality review (reviewer agents from cast — checks DOD, user perspective, corrections)
18
+ - "tech-review" — architecture review (the CTO, for complex work)
19
+ - "product-review" — product spec verification (the CPO, for complex work)
20
+
21
+ ## Common Phase Patterns (guidance, not rigid rules)
22
+
23
+ - Simple fix: ["build", "review"]
24
+ - Integration-touching fix: ["build", "code-review", "review"]
25
+ - Complex project task: ["design", "clarification", "build", "code-review", "review"] (only within multi-project plans)
26
+ - Research only: ["research"] (no build — produces a report)
27
+ - Migration: ["research", "design", "clarification", "build", "review"] (build is incremental)
28
+ - Content: ["keyword-research", "outline", "draft", "seo-review", "review"]
29
+
30
+ ## Code-Review Phase Rules
31
+
32
+ - Include "code-review" between "build" and "review" when the task touches integration points (data flows between systems, state management, API boundaries) or has >3 DOD criteria
33
+ - Skip for trivial fixes (rename, config change, single-file edit with 1-2 DOD criteria)
34
+ - The code-review phase uses the SAME reviewers from the cast, but with full files + diff and NO builder reasoning/design docs. Fresh eyes catch bugs that contextual reviewers miss.
35
+ - If the builder is also in the reviewers list, they are skipped for code-review (conflict of interest).
36
+ - For moderate/complex tasks inside projects: always include code-review.
37
+
38
+ ## Clarification Phase Rules
39
+
40
+ - Auto-add "clarification" before "build" when the task has "design", "research", or "product-spec" phases
41
+ - Skip clarification for simple ["build", "review"] tasks — scope is tight enough
42
+ - Skip for ["research"] only tasks — no build phase to clarify
@@ -0,0 +1,30 @@
1
+ <!-- Reference: scope-and-dod.md | Source: SKILL.md restructure -->
2
+
3
+ # Scope Format, Definition of Done, and User Scenario Rules
4
+
5
+ ## User Scenario Rules
6
+
7
+ - Every task must include a `user_scenario` — one sentence describing the user experience after this ships
8
+ - Good: "The CEO runs /directive and sees a telemetry summary with token costs and wall times at the end of the digest"
9
+ - Bad: "Improves the system" (too vague — what does the user actually experience?)
10
+ - Reviewers walk this scenario during review to verify the work delivers the promised experience
11
+
12
+ ## Scope Format
13
+
14
+ Write 2-4 sentences describing what needs to happen. Focus on the outcome and approach, not specific files or line numbers. Example: "All API endpoints that accept user input need input validation and parameterized queries. Currently using string interpolation for SQL. Switch to Prisma parameterized queries and add Zod validation schemas."
15
+
16
+ ## Definition of Done Rules
17
+
18
+ - Each task must include 3-5 specific, testable acceptance criteria in `definition_of_done`
19
+ - These are what the reviewer will verify — concrete conditions, not vague outcomes
20
+ - Good DOD: "Every /api/* route has a Zod schema and type-check passes"
21
+ - Bad DOD: "Security is improved" (too vague to verify)
22
+ - DOD should cover: functional correctness, scope completeness, and CEO-intent alignment
23
+ - If the directive has explicit success criteria, each criterion should map to at least one DOD item
24
+
25
+ Also from the first DOD block in the COO's prompt:
26
+ - Every task MUST have a definition_of_done array with 2-5 concrete, testable criteria
27
+ - Each criterion must be verifiable (not vague like "improve quality")
28
+ - DOD is what the CEO reviews to approve/reject the task's result
29
+ - Examples of good DOD: "All directive.json files have category field", "Watcher reads directive.json and populates category field", "Type-check passes"
30
+ - Examples of bad DOD: "Improve goal structure", "Make it work", "Better code quality"
@@ -0,0 +1,44 @@
1
+ <!-- Reference: audit-output.md | Source: SKILL.md restructure, updated by redesign-pipeline-steps -->
2
+
3
+ # Audit Output JSON Schema (Architect)
4
+
5
+ This is the **Architect's** output schema — the second phase of the two-agent audit flow. The Architect receives the Investigator's raw data (see [investigation-output.md](investigation-output.md)) and the COO's plan, then produces design recommendations.
6
+
7
+ For the Investigator's output schema (pure data, no recommendations), see [investigation-output.md](investigation-output.md).
8
+
9
+ ```json
10
+ {
11
+ "projects": [
12
+ {
13
+ "id": "slug matching the COO's project id",
14
+ "baseline": "Carried forward from investigation data",
15
+ "active_files": ["Carried forward from investigation data"],
16
+ "dead_code": ["Carried forward from investigation data"],
17
+ "findings": "Investigation findings + additional design-relevant observations",
18
+ "recommended_approach": "How to implement this, referencing real patterns and files from the investigation",
19
+ "follow_ups": [
20
+ {
21
+ "action": "Short description of what to do",
22
+ "risk": "low | medium | high",
23
+ "rationale": "Why this risk level — what could go wrong?",
24
+ "files": ["affected files, if known"]
25
+ }
26
+ ]
27
+ }
28
+ ]
29
+ }
30
+ ```
31
+
32
+ ## Two-Agent Audit Flow
33
+
34
+ 1. **Investigator** scans the codebase and produces investigation-output.md (pure data)
35
+ 2. **Architect** reads investigation data + the COO's plan and produces this schema (design recommendations)
36
+
37
+ The separation prevents investigation findings from anchoring the design — the Architect sees raw data and forms independent recommendations.
38
+
39
+ ## Field Definitions
40
+
41
+ - **baseline, active_files, dead_code**: Carried forward from the Investigator's output for downstream reference.
42
+ - **findings**: Investigation findings plus any additional observations the Architect makes about design implications.
43
+ - **recommended_approach**: Specific implementation recommendation referencing real files and patterns discovered by the Investigator. This field is passed verbatim to the builder as implementation context and to the code-reviewer for deviation checking. Be concrete — name files, functions, and patterns.
44
+ - **follow_ups**: Actions discovered during design, each with a risk classification (low/medium/high). The Investigator does not produce follow-ups — only the Architect does.
@@ -0,0 +1,52 @@
1
+ <!-- Reference: brainstorm-output.md | Source: SKILL.md restructure -->
2
+
3
+ # Brainstorm Agent Output JSON Schema
4
+
5
+ ## Phase 1: Initial Proposal
6
+
7
+ All brainstorm participants (C-suite + auditor) output this in both heavyweight and strategic directives.
8
+
9
+ ```json
10
+ {
11
+ "agent": "{name}",
12
+ "approach": "Your recommended approach in 3-5 sentences — be specific about what to build/change and in what order",
13
+ "tradeoffs": ["Key trade-off 1", "Key trade-off 2"],
14
+ "avoid": "What approach you'd explicitly NOT take and why",
15
+ "confidence": "high | medium | low — how certain are you this is the right approach?",
16
+ "feasibility_flags": ["Codebase constraints or existing patterns that affect this approach — auditor fills this, others may leave empty"]
17
+ }
18
+ ```
19
+
20
+ ## Phase 2: Rebuttal (Strategic Directives ONLY)
21
+
22
+ Each agent outputs one rebuttal after seeing all proposals. **Not used for heavyweight directives.**
23
+
24
+ ```json
25
+ {
26
+ "agent": "{name}",
27
+ "target_agent": "name of the agent whose proposal is being rebutted",
28
+ "critique": "What's wrong with their approach — specific about what they missed or got wrong",
29
+ "alternative": "What should be done instead, referencing original proposal or a new variation"
30
+ }
31
+ ```
32
+
33
+ ## Collected Output Structure
34
+
35
+ The orchestrator collects all outputs into a single brainstorm artifact:
36
+
37
+ ```json
38
+ {
39
+ "directive": "{directive-name}",
40
+ "weight": "heavyweight | strategic",
41
+ "participants": ["agent names"],
42
+ "proposals": [
43
+ { "agent": "...", "approach": "...", "tradeoffs": [], "avoid": "...", "confidence": "...", "feasibility_flags": [] }
44
+ ],
45
+ "rebuttals": [
46
+ { "agent": "...", "target_agent": "...", "critique": "...", "alternative": "..." }
47
+ ],
48
+ "synthesis": "Synthesis of convergence points, key disagreements, and (for strategic) which critiques landed"
49
+ }
50
+ ```
51
+
52
+ **Note:** `rebuttals` array is empty for heavyweight directives (no deliberation round).
@@ -0,0 +1,13 @@
1
+ <!-- Reference: challenger-output.md | Source: SKILL.md restructure -->
2
+
3
+ # C-Suite Challenger JSON Output Schema
4
+
5
+ ```json
6
+ {
7
+ "agent": "{name}",
8
+ "verdict": "endorse | challenge | flag",
9
+ "reasoning": "Your 3-5 sentence evaluation from your domain perspective",
10
+ "alternative": "If challenging: what would you do instead? If endorsing/flagging: null",
11
+ "risk_flags": ["Short risk statements, if any. Empty array if none."]
12
+ }
13
+ ```
@@ -0,0 +1,18 @@
1
+ <!-- Reference: checkpoint.md — DEPRECATED, merged into directive-json.md -->
2
+
3
+ # Checkpoint Schema — MERGED INTO directive.json
4
+
5
+ **There is no separate checkpoint file.** All checkpoint data lives in `directive.json`.
6
+
7
+ See [directive-json.md](directive-json.md) for the full schema including:
8
+ - `pipeline{}` — per-step status, agent, output, artifacts
9
+ - `current_step` — for resume
10
+ - `tasks[]` — with phases, artifact_paths, dod_verification
11
+ - `planning{}` — plan, ceo_approval, worktree_path
12
+ - `wrapup{}` — digest_path, lessons_updated, follow_ups_processed
13
+
14
+ **Resume:** Read `.context/directives/{name}/directive.json` and check `current_step`.
15
+
16
+ **Write protocol:** Overwrite directive.json at each step transition. Always update `updated_at`.
17
+
18
+ **DOD Verification:** Written by the review phase into `tasks[].dod_verification`. The review-gate checks this field.
@@ -0,0 +1,5 @@
1
+ # DEPRECATED — Use directive-json.md
2
+
3
+ `current.json` is no longer used. The directive-watcher reads pipeline state directly from `.context/directives/{id}/directive.json`.
4
+
5
+ See [directive-json.md](./directive-json.md) for the authoritative schema.