@leing2021/super-pi 0.23.0 → 0.23.2

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.
@@ -17,6 +17,11 @@ export interface ContextHandoffInput {
17
17
  artifacts?: Record<string, string | undefined>
18
18
  handoffMarkdown?: string
19
19
  handoffPath?: string
20
+ currentTruth?: string[]
21
+ invalidatedAssumptions?: string[]
22
+ openDecisions?: string[]
23
+ recentlyAccessedFiles?: string[]
24
+ compressionRisk?: string[]
20
25
  }
21
26
 
22
27
  export interface ContextStateEntry {
@@ -29,6 +34,11 @@ export interface ContextStateEntry {
29
34
  blocker?: string
30
35
  verification?: string
31
36
  artifacts: Record<string, string | undefined>
37
+ currentTruth: string[]
38
+ invalidatedAssumptions: string[]
39
+ openDecisions: string[]
40
+ recentlyAccessedFiles: string[]
41
+ compressionRisk: string[]
32
42
  recommendNewSession: boolean
33
43
  updatedAt: string
34
44
  }
@@ -47,6 +57,11 @@ export interface ContextHandoffResult {
47
57
  artifacts?: Record<string, string | undefined>
48
58
  recommendNewSession?: boolean
49
59
  handoffMarkdown?: string
60
+ currentTruth?: string[]
61
+ invalidatedAssumptions?: string[]
62
+ openDecisions?: string[]
63
+ recentlyAccessedFiles?: string[]
64
+ compressionRisk?: string[]
50
65
  updatedAt?: string
51
66
  }
52
67
 
@@ -112,6 +127,11 @@ function buildDefaultHandoffMarkdown(input: {
112
127
  artifacts: Record<string, string | undefined>
113
128
  blocker?: string
114
129
  verification?: string
130
+ currentTruth: string[]
131
+ invalidatedAssumptions: string[]
132
+ openDecisions: string[]
133
+ recentlyAccessedFiles: string[]
134
+ compressionRisk: string[]
115
135
  }): string {
116
136
  const currentTask = input.nextStage
117
137
  ? `Continue from ${input.currentStage} to ${input.nextStage}.`
@@ -137,12 +157,24 @@ function buildDefaultHandoffMarkdown(input: {
137
157
  "## Hot Context",
138
158
  hotContext,
139
159
  "",
160
+ "## Current Truth",
161
+ formatBullets(input.currentTruth),
162
+ "",
140
163
  "## Verified Facts",
141
164
  verifiedFacts,
142
165
  "",
166
+ "## Invalidated Assumptions",
167
+ formatBullets(input.invalidatedAssumptions),
168
+ "",
169
+ "## Open Decisions",
170
+ formatBullets(input.openDecisions),
171
+ "",
143
172
  "## Active Files",
144
173
  activeFiles,
145
174
  "",
175
+ "## Recently Accessed Files",
176
+ formatBullets(input.recentlyAccessedFiles),
177
+ "",
146
178
  "## Artifacts",
147
179
  artifacts,
148
180
  "",
@@ -152,6 +184,9 @@ function buildDefaultHandoffMarkdown(input: {
152
184
  "## Verification",
153
185
  `- ${verification}`,
154
186
  "",
187
+ "## Compression Risk",
188
+ formatBullets(input.compressionRisk),
189
+ "",
155
190
  "## Do Not Repeat",
156
191
  "- Do not reload full history unless the handoff lacks required evidence.",
157
192
  "",
@@ -161,13 +196,54 @@ function buildDefaultHandoffMarkdown(input: {
161
196
  ].join("\n")
162
197
  }
163
198
 
199
+ function toStringArray(value: unknown): string[] {
200
+ return Array.isArray(value) ? value.filter((item): item is string => typeof item === "string") : []
201
+ }
202
+
203
+ function normalizeStateEntry(raw: unknown): ContextStateEntry | null {
204
+ if (!raw || typeof raw !== "object") return null
205
+
206
+ const state = raw as Record<string, unknown>
207
+ const activeFiles = toStringArray(state.activeFiles)
208
+
209
+ return {
210
+ currentStage: typeof state.currentStage === "string" ? state.currentStage : "unknown",
211
+ nextStage: typeof state.nextStage === "string" ? state.nextStage : undefined,
212
+ contextHealth: isContextHealth(state.contextHealth) ? state.contextHealth : "watch",
213
+ latestHandoffPath: typeof state.latestHandoffPath === "string" ? state.latestHandoffPath : undefined,
214
+ latestDatedHandoffPath: typeof state.latestDatedHandoffPath === "string" ? state.latestDatedHandoffPath : undefined,
215
+ activeFiles,
216
+ blocker: typeof state.blocker === "string" ? state.blocker : undefined,
217
+ verification: typeof state.verification === "string" ? state.verification : undefined,
218
+ artifacts: isStringRecord(state.artifacts) ? state.artifacts : {},
219
+ currentTruth: toStringArray(state.currentTruth),
220
+ invalidatedAssumptions: toStringArray(state.invalidatedAssumptions),
221
+ openDecisions: toStringArray(state.openDecisions),
222
+ recentlyAccessedFiles: toStringArray(state.recentlyAccessedFiles).length > 0
223
+ ? toStringArray(state.recentlyAccessedFiles)
224
+ : activeFiles.slice(0, 5),
225
+ compressionRisk: toStringArray(state.compressionRisk),
226
+ recommendNewSession: typeof state.recommendNewSession === "boolean" ? state.recommendNewSession : false,
227
+ updatedAt: typeof state.updatedAt === "string" ? state.updatedAt : new Date(0).toISOString(),
228
+ }
229
+ }
230
+
231
+ function isContextHealth(value: unknown): value is ContextHealth {
232
+ return value === "good" || value === "watch" || value === "heavy" || value === "critical"
233
+ }
234
+
235
+ function isStringRecord(value: unknown): value is Record<string, string | undefined> {
236
+ if (!value || typeof value !== "object") return false
237
+ return Object.values(value).every(item => item === undefined || typeof item === "string")
238
+ }
239
+
164
240
  async function readState(repoRoot: string): Promise<ContextStateEntry | null> {
165
241
  const filePath = stateFilePath(repoRoot)
166
242
  if (!existsSync(filePath)) return null
167
243
 
168
244
  try {
169
245
  const content = await readFile(filePath, "utf8")
170
- return JSON.parse(content) as ContextStateEntry
246
+ return normalizeStateEntry(JSON.parse(content))
171
247
  } catch {
172
248
  return null
173
249
  }
@@ -207,6 +283,14 @@ async function save(input: ContextHandoffInput): Promise<ContextHandoffResult> {
207
283
  const blocker = input.blocker
208
284
  const verification = input.verification
209
285
  const artifacts = input.artifacts ?? {}
286
+ const currentTruth = input.currentTruth ?? []
287
+ const invalidatedAssumptions = input.invalidatedAssumptions ?? []
288
+ const openDecisions = input.openDecisions ?? []
289
+ const recentlyAccessedFiles = input.recentlyAccessedFiles?.length
290
+ ? input.recentlyAccessedFiles
291
+ : activeFiles.slice(0, 5)
292
+ const compressionRisk = input.compressionRisk ?? []
293
+
210
294
  const handoffMarkdown = input.handoffMarkdown?.trim().length
211
295
  ? input.handoffMarkdown
212
296
  : buildDefaultHandoffMarkdown({
@@ -216,6 +300,11 @@ async function save(input: ContextHandoffInput): Promise<ContextHandoffResult> {
216
300
  artifacts,
217
301
  blocker,
218
302
  verification,
303
+ currentTruth,
304
+ invalidatedAssumptions,
305
+ openDecisions,
306
+ recentlyAccessedFiles,
307
+ compressionRisk,
219
308
  })
220
309
 
221
310
  const recommendNewSession = computeRecommendNewSession(currentStage, nextStage, contextHealth)
@@ -238,6 +327,11 @@ async function save(input: ContextHandoffInput): Promise<ContextHandoffResult> {
238
327
  blocker,
239
328
  verification,
240
329
  artifacts,
330
+ currentTruth,
331
+ invalidatedAssumptions,
332
+ openDecisions,
333
+ recentlyAccessedFiles,
334
+ compressionRisk,
241
335
  recommendNewSession,
242
336
  updatedAt: new Date().toISOString(),
243
337
  }
@@ -256,6 +350,11 @@ async function save(input: ContextHandoffInput): Promise<ContextHandoffResult> {
256
350
  blocker,
257
351
  verification,
258
352
  artifacts,
353
+ currentTruth,
354
+ invalidatedAssumptions,
355
+ openDecisions,
356
+ recentlyAccessedFiles,
357
+ compressionRisk,
259
358
  recommendNewSession,
260
359
  updatedAt: state.updatedAt,
261
360
  }
@@ -291,6 +390,11 @@ async function load(input: ContextHandoffInput): Promise<ContextHandoffResult> {
291
390
  blocker: state.blocker,
292
391
  verification: state.verification,
293
392
  artifacts: state.artifacts,
393
+ currentTruth: state.currentTruth,
394
+ invalidatedAssumptions: state.invalidatedAssumptions,
395
+ openDecisions: state.openDecisions,
396
+ recentlyAccessedFiles: state.recentlyAccessedFiles,
397
+ compressionRisk: state.compressionRisk,
294
398
  recommendNewSession: state.recommendNewSession,
295
399
  handoffMarkdown: markdown,
296
400
  updatedAt: state.updatedAt,
@@ -320,6 +424,11 @@ async function latest(input: ContextHandoffInput): Promise<ContextHandoffResult>
320
424
  blocker: state.blocker,
321
425
  verification: state.verification,
322
426
  artifacts: state.artifacts,
427
+ currentTruth: state.currentTruth,
428
+ invalidatedAssumptions: state.invalidatedAssumptions,
429
+ openDecisions: state.openDecisions,
430
+ recentlyAccessedFiles: state.recentlyAccessedFiles,
431
+ compressionRisk: state.compressionRisk,
323
432
  recommendNewSession: state.recommendNewSession,
324
433
  updatedAt: state.updatedAt,
325
434
  }
@@ -351,6 +460,11 @@ async function status(input: ContextHandoffInput): Promise<ContextHandoffResult>
351
460
  blocker: state.blocker,
352
461
  verification: state.verification,
353
462
  artifacts: state.artifacts,
463
+ currentTruth: state.currentTruth,
464
+ invalidatedAssumptions: state.invalidatedAssumptions,
465
+ openDecisions: state.openDecisions,
466
+ recentlyAccessedFiles: state.recentlyAccessedFiles,
467
+ compressionRisk: state.compressionRisk,
354
468
  recommendNewSession: state.recommendNewSession,
355
469
  updatedAt: state.updatedAt,
356
470
  }
@@ -1,4 +1,4 @@
1
- import { readdirSync, statSync, existsSync } from "node:fs"
1
+ import { readdirSync, existsSync, readFileSync } from "node:fs"
2
2
  import path from "node:path"
3
3
 
4
4
  export interface WorkflowCategoryState {
@@ -6,6 +6,25 @@ export interface WorkflowCategoryState {
6
6
  latest: string | null
7
7
  }
8
8
 
9
+ export interface WorkflowContextState {
10
+ found: boolean
11
+ currentStage?: string
12
+ nextStage?: string
13
+ contextHealth?: string
14
+ latestHandoffPath?: string
15
+ latestDatedHandoffPath?: string
16
+ activeFiles: string[]
17
+ recentlyAccessedFiles: string[]
18
+ blocker?: string
19
+ verification?: string
20
+ currentTruth: string[]
21
+ invalidatedAssumptions: string[]
22
+ openDecisions: string[]
23
+ compressionRisk: string[]
24
+ recommendNewSession?: boolean
25
+ updatedAt?: string
26
+ }
27
+
9
28
  export interface WorkflowStateInput {
10
29
  repoRoot: string
11
30
  }
@@ -15,6 +34,7 @@ export interface WorkflowStateResult {
15
34
  plans: WorkflowCategoryState
16
35
  solutions: WorkflowCategoryState
17
36
  runs: WorkflowCategoryState
37
+ context: WorkflowContextState
18
38
  }
19
39
 
20
40
  function emptyCategory(): WorkflowCategoryState {
@@ -63,6 +83,52 @@ function collectFiles(dirPath: string): string[] {
63
83
  return results
64
84
  }
65
85
 
86
+ function emptyContext(): WorkflowContextState {
87
+ return {
88
+ found: false,
89
+ activeFiles: [],
90
+ recentlyAccessedFiles: [],
91
+ currentTruth: [],
92
+ invalidatedAssumptions: [],
93
+ openDecisions: [],
94
+ compressionRisk: [],
95
+ }
96
+ }
97
+
98
+ function toStringArray(value: unknown): string[] {
99
+ return Array.isArray(value) ? value.filter((item): item is string => typeof item === "string") : []
100
+ }
101
+
102
+ function readContextState(repoRoot: string): WorkflowContextState {
103
+ const statePath = path.join(repoRoot, ".context", "compound-engineering", "context-state.json")
104
+ if (!existsSync(statePath)) return emptyContext()
105
+
106
+ try {
107
+ const raw = readFileSync(statePath, "utf8")
108
+ const state = JSON.parse(raw) as Record<string, unknown>
109
+ return {
110
+ found: true,
111
+ currentStage: typeof state.currentStage === "string" ? state.currentStage : undefined,
112
+ nextStage: typeof state.nextStage === "string" ? state.nextStage : undefined,
113
+ contextHealth: typeof state.contextHealth === "string" ? state.contextHealth : undefined,
114
+ latestHandoffPath: typeof state.latestHandoffPath === "string" ? state.latestHandoffPath : undefined,
115
+ latestDatedHandoffPath: typeof state.latestDatedHandoffPath === "string" ? state.latestDatedHandoffPath : undefined,
116
+ activeFiles: toStringArray(state.activeFiles),
117
+ recentlyAccessedFiles: toStringArray(state.recentlyAccessedFiles),
118
+ blocker: typeof state.blocker === "string" ? state.blocker : undefined,
119
+ verification: typeof state.verification === "string" ? state.verification : undefined,
120
+ currentTruth: toStringArray(state.currentTruth),
121
+ invalidatedAssumptions: toStringArray(state.invalidatedAssumptions),
122
+ openDecisions: toStringArray(state.openDecisions),
123
+ compressionRisk: toStringArray(state.compressionRisk),
124
+ recommendNewSession: typeof state.recommendNewSession === "boolean" ? state.recommendNewSession : undefined,
125
+ updatedAt: typeof state.updatedAt === "string" ? state.updatedAt : undefined,
126
+ }
127
+ } catch {
128
+ return emptyContext()
129
+ }
130
+ }
131
+
66
132
  export function createWorkflowStateTool() {
67
133
  return {
68
134
  name: "workflow_state",
@@ -74,6 +140,7 @@ export function createWorkflowStateTool() {
74
140
  plans: scanDir(path.join(repoRoot, "docs", "plans")),
75
141
  solutions: scanDir(path.join(repoRoot, "docs", "solutions")),
76
142
  runs: scanDir(path.join(repoRoot, ".context", "compound-engineering")),
143
+ context: readContextState(repoRoot),
77
144
  }
78
145
  },
79
146
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.23.0",
3
+ "version": "0.23.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
@@ -5,120 +5,83 @@ description: "Brainstorm requirements with three modes: CE discovery, Startup Di
5
5
 
6
6
  # Brainstorm
7
7
 
8
- Use this skill when the request is ambiguous, needs requirements discovery before planning, or the user describes a new idea/product.
8
+ Use this skill when the request is ambiguous, needs requirements discovery, or the user describes a new idea/product.
9
9
 
10
10
  See [shared pipeline instructions](../references/pipeline-config.md) for model routing and pipeline behavior.
11
11
 
12
12
  ## Core rules
13
13
 
14
- - Use **`brainstorm_dialog`** to manage multi-round conversations.
15
- - Start with `start` operation: present initial analysis and open questions.
16
- - Use `refine` operation: incorporate user responses and produce refined analysis with new questions.
17
- - Repeat refine rounds until all open questions are resolved.
18
- - End with `summarize` operation: finalize into a requirements-ready artifact.
19
- - Ask **one question at a time** within each round.
14
+ - Use **`brainstorm_dialog`** to manage multi-round conversations (`start` → `refine` → `summarize`).
15
+ - Ask **one question at a time**.
20
16
  - Compare **2-3 approaches** when multiple directions are plausible.
21
- - Keep the artifact focused on **what** should be built, not implementation details by default.
22
- - Write the result to `docs/brainstorms/` as a durable requirements document.
23
- - End by recommending `02-plan` when the requirements are ready.
24
- - **Do not proceed to planning without explicit user approval** of the design.
17
+ - Keep focused on **what** to build, not implementation details.
18
+ - **Explicit user approval required** before handoff to `02-plan`.
19
+ - Write result to `docs/brainstorms/` as durable requirements document.
25
20
 
26
21
  ## Mode selection
27
22
 
28
- After initial context gathering, determine which mode to use. Use `ask_user_question`:
23
+ After initial context, determine mode via `ask_user_question`:
29
24
 
30
- > Before we dig in, what's your goal with this?
31
- >
32
- > - **Building a startup** (or thinking about it)
33
- > - **Intrapreneurship** internal project, need to ship fast
34
- > - **Side project / hackathon / learning** building for fun or exploration
35
- > - **Adding a feature** — already have a project, need to design a change
25
+ > What's your goal?
26
+ > - **Building a startup** → Startup Diagnostic
27
+ > - **Intrapreneurship** Startup Diagnostic
28
+ > - **Side project / hackathon** Builder Mode
29
+ > - **Adding a feature** CE Brainstorm
36
30
 
37
- **Mode mapping:**
38
- - Startup, intrapreneurship → **Startup Diagnostic** (see `references/startup-diagnostic.md`)
39
- - Side project, hackathon, learning → **Builder Mode** (see `references/builder-mode.md`)
40
- - Adding a feature → **CE Brainstorm** (the existing requirements discovery flow below)
41
-
42
- If the user's request already makes the mode obvious (e.g., "I have a startup idea"), skip the question and go directly to the matching mode.
43
-
44
- ## Startup Diagnostic mode
45
-
46
- Read `references/startup-diagnostic.md` for the full YC-style forcing questions, pushback patterns, and anti-sycophancy rules.
47
-
48
- Key differences from CE mode:
49
- - **Operating principles:** Specificity is the only currency. Interest is not demand. The status quo is your real competitor. Narrow beats wide, early.
50
- - **Ask the six forcing questions** one at a time, pushing until answers are specific and uncomfortable.
51
- - **Smart routing:** Pre-product (Q1-Q3), Has users (Q2, Q4, Q5), Paying customers (Q4, Q5, Q6).
52
- - **End with the assignment:** One concrete action the founder should take next.
31
+ Skip question if mode is obvious from request.
53
32
 
54
- After the diagnostic, run Premise Challenge (see `references/premise-challenge.md`), then proceed to Alternatives Generation and design checklist.
55
-
56
- ## Builder Mode
57
-
58
- Read `references/builder-mode.md` for the full generative question set and response posture.
59
-
60
- Key differences from CE mode:
61
- - **Operating principles:** Delight is the currency. Ship something you can show. Solve your own problem. Explore before you optimize.
62
- - **Ask generative questions** one at a time (coolest version, who would you show, fastest path, what's different, 10x version).
63
- - **End with concrete build steps**, not business validation tasks.
64
- - **Vibe shift detection:** If the user starts talking about customers/revenue, upgrade to Startup Diagnostic.
65
-
66
- After the questions, run Premise Challenge (see `references/premise-challenge.md`), then proceed to Alternatives Generation and design checklist.
33
+ **Mode mapping:**
34
+ - Startup / intrapreneurship → **Startup Diagnostic** (see `references/startup-diagnostic.md`)
35
+ - Side project / hackathon → **Builder Mode** (see `references/builder-mode.md`)
36
+ - Feature addition → **CE Brainstorm** (see `references/ce-brainstorm-mode.md`)
67
37
 
68
- ## CE Brainstorm mode (existing flow)
38
+ ## Mode summaries
69
39
 
70
- This is the original Compound Engineering brainstorm. Use when adding a feature to an existing project.
40
+ | Mode | Key principle | End goal |
41
+ |---|---|---|
42
+ | Startup Diagnostic | Specificity is currency, narrow beats wide | One concrete next action |
43
+ | Builder Mode | Delight is currency, ship something showable | Concrete build steps |
44
+ | CE Brainstorm | Requirements clarity | Implementation-ready spec |
71
45
 
72
- 1. Scan the repository for nearby context.
73
- 2. Use `brainstorm_dialog` `start` to begin multi-round refinement.
74
- 3. Present initial analysis and open questions to the user.
75
- 4. Use `brainstorm_dialog` `refine` to incorporate user responses and refine analysis.
76
- 5. Repeat step 4 until all questions are resolved.
46
+ See reference files for full question sets and patterns.
77
47
 
78
- ## Premise Challenge (all modes)
48
+ ## Premise Challenge
79
49
 
80
- After the mode-specific questions are complete, run the Premise Challenge. See `references/premise-challenge.md`.
50
+ After mode-specific questions, run Premise Challenge. See `references/premise-challenge.md`.
81
51
 
82
52
  ## Design checklist
83
53
 
84
54
  Before summarizing, ensure the design answers:
85
55
  - What are we building?
86
56
  - Why does it exist?
87
- - What files/modules are likely to change?
88
- - What are the boundaries between responsibilities?
89
- - What can fail, and how should failure be handled?
57
+ - What files/modules will change?
58
+ - What are the responsibility boundaries?
59
+ - What can fail, and how?
90
60
  - How will we verify success?
91
61
 
92
62
  ## Stop conditions
93
63
 
94
- Stop and ask the user instead of guessing when:
95
- - requirements conflict
96
- - success criteria are unclear
97
- - the task spans multiple independent systems
98
- - the user has not approved the design yet
64
+ Stop and ask instead of guessing when: requirements conflict, success criteria unclear, task spans multiple systems, or user hasn't approved design.
99
65
 
100
66
  ## Approval gate
101
67
 
102
- Before handing off to `02-plan`:
103
- 1. Present the final design to the user.
104
- 2. Ask for explicit approval.
105
- 3. Only proceed after the user confirms.
68
+ **Required:** Explicit user approval before handoff to `02-plan`.
106
69
 
107
70
  ## Workflow
108
71
 
109
- 1. Scan the repository for nearby context.
110
- 2. Determine mode (Startup / Builder / CE) via the mode selection step.
111
- 3. Run mode-specific questions using the appropriate reference file.
112
- 4. Run Premise Challenge.
113
- 5. Generate 2-3 alternatives (at least one "minimal viable" and one "ideal architecture").
114
- 6. Validate against the design checklist.
115
- 7. Use `brainstorm_dialog` `summarize` to finalize the conversation.
116
- 8. Capture the agreed direction in a requirements artifact under `docs/brainstorms/`.
117
- 9. Get explicit user approval before handing off.
118
- 10. Hand off to `02-plan` using `references/handoff.md`.
72
+ 1. Scan repository for nearby context
73
+ 2. Determine mode (Startup / Builder / CE)
74
+ 3. Run mode-specific questions (use reference files)
75
+ 4. Run Premise Challenge
76
+ 5. Generate 2-3 alternatives (minimal viable + ideal architecture)
77
+ 6. Validate against design checklist
78
+ 7. Use `brainstorm_dialog` `summarize` to finalize
79
+ 8. Capture requirements in `docs/brainstorms/`
80
+ 9. Get explicit user approval
81
+ 10. Handoff to `02-plan` using `references/handoff.md`
119
82
 
120
83
  ## Artifact contract
121
84
 
122
- Use `references/requirements-template.md` to structure the requirements document. Keep implementation details out unless the brainstorm is specifically about architecture or technical direction.
85
+ Use `references/requirements-template.md` to structure the document. Keep implementation details out unless specifically about architecture.
123
86
 
124
87
  Before finishing this skill, apply the completion checklist in [shared pipeline instructions](../references/pipeline-config.md).
@@ -0,0 +1,47 @@
1
+ # CE Brainstorm Mode
2
+
3
+ Standard requirements discovery flow for feature additions to existing projects.
4
+
5
+ ## When to use
6
+
7
+ - Adding a feature to an existing project
8
+ - User has a project but unclear about what to build
9
+ - Request is somewhat specific but needs elaboration
10
+
11
+ ## Operating principle
12
+
13
+ **Requirements clarity** — the goal is to produce implementation-ready specifications.
14
+
15
+ ## Workflow
16
+
17
+ 1. Scan the repository for nearby context
18
+ 2. Use `brainstorm_dialog` `start` to begin multi-round refinement
19
+ 3. Present initial analysis and open questions to the user
20
+ 4. Use `brainstorm_dialog` `refine` to incorporate user responses and refine analysis
21
+ 5. Repeat step 4 until all questions are resolved
22
+
23
+ ## Key questions
24
+
25
+ Ask one at a time:
26
+ - What problem does this feature solve?
27
+ - Who is the user/consumer?
28
+ - What does success look like?
29
+ - What are the boundaries?
30
+ - What could go wrong?
31
+
32
+ ## End state
33
+
34
+ Requirements document covering:
35
+ - Feature purpose and scope
36
+ - User-facing behavior
37
+ - Edge cases and failure modes
38
+ - Success criteria
39
+ - Likely file changes
40
+
41
+ ## Difference from other modes
42
+
43
+ | Aspect | CE Brainstorm | Startup Diagnostic | Builder Mode |
44
+ |---|---|---|---|
45
+ | Goal | Implementation clarity | Business validation | Buildable prototype |
46
+ | Questions | Requirements-focused | Problem-first | Solution-first |
47
+ | Output | Spec document | One action | Build steps |
@@ -11,77 +11,58 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
11
11
 
12
12
  ## Core rules
13
13
 
14
- - Before planning, load project rules:
15
- 1. `rules/common/development-workflow.md` and `rules/common/testing.md`
16
- 2. Detect the project's primary language using [language detection](../references/language-detection.md)
17
- 3. Load all files in the matching language-specific rules directory (e.g. `rules/typescript/`)
18
- 4. If the task involves frontend/browser concerns, also load `rules/web/` files
19
- - Priority: project-level `{repo-root}/rules/` overrides package-level defaults
20
- - Search `docs/brainstorms/` for a relevant requirements artifact first.
21
- - Search solutions with grep-first strategy: extract keywords from the task → `bash grep -rl "tags:.*keyword" docs/solutions/ ~/.pi/agent/docs/solutions/` → read only frontmatter (first 15 lines) of matching files → score by severity + tag relevance → fully read top 3. Search both project-level (`docs/solutions/`) and global-level (`~/.pi/agent/docs/solutions/`). If no matches, report "No relevant solutions found" and proceed.
22
- - Write the final plan to `docs/plans/`.
23
- - Break the work into implementation units instead of writing an execution script.
24
- - If a plan already exists, use **`plan_diff`** to compare existing units with new requirements and apply incremental changes instead of rewriting.
25
- - End by recommending `03-work` once the plan is ready.
14
+ 1. Load project rules (4 steps):
15
+ - Load `rules/common/development-workflow.md` and `rules/common/testing.md`
16
+ - Detect project language via [language detection](../references/language-detection.md)
17
+ - Load matching language-specific rules (e.g., `rules/typescript/`)
18
+ - If frontend/browser concerns, also load `rules/web/` files
19
+ 2. **Priority:** project-level `{repo-root}/rules/` overrides package defaults
20
+ 3. Search `docs/brainstorms/` for relevant requirements first
21
+ 4. Run solution search (see `references/solution-search.md`):
22
+ - Extract keywords `grep -rl "tags:.*keyword" docs/solutions/ ~/.pi/agent/docs/solutions/`
23
+ - Read **frontmatter** only (first 15 lines) of matches score by severity + tag relevance
24
+ - Fully read top 3 candidates
25
+ 5. Write plan to `docs/plans/`
26
+ 6. If plan exists, use **`plan_diff`** to compare and patch incrementally
27
+ 7. End by recommending `03-work`
26
28
 
27
29
  ## Hard gates — TDD enforcement
28
30
 
29
- Every implementation unit must follow **RED, GREEN, REFACTOR**:
30
- - No production code step may appear before a failing test step.
31
- - Every unit must include exact verification commands.
32
- - No placeholders allowed — replace "handle edge cases" with concrete steps.
31
+ Every unit follows **RED GREEN REFACTOR**:
33
32
 
34
- **TDD violation rejection criteria** — stop and revise the plan if any unit:
35
- - implements code before a failing test
36
- - lacks a command proving the RED step
37
- - lacks a command proving the GREEN step
38
- - skips verification
39
- - relies on unstated tools or assumptions
33
+ **TDD violation rejection criteria** — reject and revise if any unit:
34
+ - Implements code before failing test
35
+ - Lacks RED step verification
36
+ - Lacks GREEN step verification
37
+ - Skips verification
38
+ - Uses placeholders or unstated assumptions
40
39
 
41
40
  ## Planning flow
42
41
 
43
- 1. Read the most relevant brainstorm artifact from `docs/brainstorms/` when one exists.
44
- 2. Execute the solution search strategy: extract keywords → grep frontmatter fields (tags, title) in `docs/solutions/` and `~/.pi/agent/docs/solutions/` → read frontmatter of candidates only → score and rank → fully read top 3.
45
- 3. Gather repository context from the affected areas.
46
- 4. If a plan already exists:
47
- a. Use `plan_diff` `compare` to identify added, removed, modified, and unchanged units.
48
- b. Review the diff with the user.
49
- c. Use `plan_diff` `patch` to apply approved changes.
50
- 5. If no plan exists, write a new plan artifact under `docs/plans/` using `references/plan-template.md`.
51
- 6. Structure the work using `references/implementation-unit-template.md`.
52
- 7. Verify every unit follows strict TDD — reject units that violate the gates above.
42
+ 1. Read relevant brainstorm from `docs/brainstorms/`
43
+ 2. Run solution search (keywords → grep frontmatter → read top 3)
44
+ 3. Gather repository context
45
+ 4. If plan exists: use `plan_diff` `compare` → review with user → `patch`
46
+ 5. If no plan: write new plan under `docs/plans/` using `references/plan-template.md`
47
+ 6. Structure work using `references/implementation-unit-template.md`
48
+ 7. Verify every unit follows TDD gates
53
49
 
54
50
  ## Optional: CEO Review
55
51
 
56
- After the plan artifact is written (step 5 or 6 above), offer the user a strategic review:
57
-
58
- > Plan ready. How do you want to review it?
59
- >
60
- > - **A) Just go** — trust the plan, skip review
61
- > - **B) CEO Review** — challenge premises, check for better alternatives, dream-state mapping
62
- > - **C) Strict Review** — full CEO Review plus error maps, failure modes, test diagrams
63
-
64
- If the user picks A, proceed directly to the `03-work` handoff.
65
- If the user picks B or C, read `references/ceo-review-mode.md` and execute the review flow.
66
-
67
- After CEO/Strict Review:
68
- 1. Update the plan artifact with any changes the user approved.
69
- 2. Note the review mode and key decisions in the plan.
70
- 3. Proceed to the `03-work` handoff.
71
-
72
- ## Implementation unit format
73
-
74
- Every unit must include:
75
- - **Purpose**: what this unit accomplishes
76
- - **Files**: exact paths to create, modify, or test
77
- - **Steps** as checkboxes:
78
- 1. Write or update a failing test
79
- 2. Run the targeted test and confirm it fails for the expected reason (RED)
80
- 3. Write the minimal implementation needed to pass
81
- 4. Run the targeted test and confirm it passes (GREEN)
82
- 5. Refactor if needed while keeping tests green
83
- 6. Run unit-level verification
84
- - **Verification commands**: exact commands to run
85
- - **Expected results**: what success looks like
52
+ After plan is written, offer strategic review:
53
+
54
+ > Plan ready. How to review?
55
+ > - **A) Just go** — trust the plan
56
+ > - **B) CEO Review** — challenge premises, dream-state mapping
57
+ > - **C) Strict Review** — CEO + error maps, failure modes, test diagrams
58
+
59
+ If B or C: read `references/ceo-review-mode.md` and execute review flow.
60
+ After review: update plan artifact, then handoff to `03-work`.
61
+
62
+ ## Artifact output
63
+
64
+ - Plan: `docs/plans/<slug>.md`
65
+ - Use `references/plan-template.md` structure
66
+ - Implementation units follow `references/implementation-unit-template.md`
86
67
 
87
68
  Before finishing this skill, apply the completion checklist in [shared pipeline instructions](../references/pipeline-config.md).