brain-dev 2.3.1 → 2.4.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.
package/README.md CHANGED
@@ -30,6 +30,7 @@ Brain adds structure without adding friction:
30
30
  /brain:discuss → Captures architectural decisions before coding
31
31
  /brain:plan → Creates verified execution plans with TDD
32
32
  /brain:execute → Builds with per-task commits and deviation handling
33
+ /brain:review → Mandatory code review before verification
33
34
  /brain:verify → 3-level verification against must-haves
34
35
  /brain:complete → Advances to next phase with audit trail
35
36
  ```
@@ -56,7 +57,7 @@ Brain provides four levels of work, from lightweight to comprehensive:
56
57
 
57
58
  ```
58
59
  quick → plan → execute → commit (minutes)
59
- new-task → discuss → plan → execute → verify (hours)
60
+ new-task → discuss → plan → execute → review → verify (hours)
60
61
  story → research → requirements → roadmap → phases (days/weeks)
61
62
  new-project → detect → map → suggest next step (one-time setup)
62
63
  ```
@@ -94,7 +95,7 @@ For features that need more than a quick fix but less than a full story:
94
95
  /brain:new-task "add payment integration with Stripe"
95
96
  ```
96
97
 
97
- Brain runs the full pipeline: discuss → plan → execute → verify → complete.
98
+ Brain runs the full pipeline: discuss → plan → execute → review → verify → complete.
98
99
 
99
100
  ```bash
100
101
  /brain:new-task --research "add rate limiting" # With light research
@@ -150,7 +151,7 @@ No configuration needed — Brain detects your stack and injects expertise into
150
151
  ## Lifecycle
151
152
 
152
153
  ```
153
- init → new-project → story → discuss → plan → execute → verify → complete
154
+ init → new-project → story → discuss → plan → execute → review → verify → complete
154
155
  ↑ │
155
156
  └──────────── next story/phase ───────────────┘
156
157
  ```
@@ -173,14 +174,14 @@ Run phases autonomously without human intervention:
173
174
  /brain:execute --auto --stop # Stop running auto session
174
175
  ```
175
176
 
176
- Auto mode chains: discuss → plan → execute → verify → complete → next phase, with budget limits, stuck detection, and crash recovery built in.
177
+ Auto mode chains: discuss → plan → execute → review → verify → complete → next phase, with budget limits, stuck detection, and crash recovery built in.
177
178
 
178
179
  ## State Machine
179
180
 
180
181
  Brain tracks progress through a deterministic state machine:
181
182
 
182
183
  ```
183
- pending → discussing → discussed → planning → executing → executed → verifying → verified → complete
184
+ pending → discussing → discussed → planning → executing → executed → reviewing → reviewed → verifying → verified → complete
184
185
  ```
185
186
 
186
187
  Every command knows what comes next. `brain-dev progress` always tells you the right next step.
@@ -223,6 +224,7 @@ No supply chain risk. No transitive vulnerabilities. No `node_modules` bloat.
223
224
  | `/brain:discuss` | Capture architectural decisions |
224
225
  | `/brain:plan` | Create verified execution plans |
225
226
  | `/brain:execute` | Build according to plans with TDD |
227
+ | `/brain:review` | Mandatory code review before verification |
226
228
  | `/brain:verify` | 3-level verification against must-haves |
227
229
  | `/brain:complete` | Mark phase done, advance to next |
228
230
  | `/brain:quick` | Quick task — skip the ceremony |
@@ -6,7 +6,7 @@ const { readState, writeState } = require('../state.cjs');
6
6
  const { loadTemplate, interpolate, loadTemplateWithOverlay } = require('../templates.cjs');
7
7
  const { getAgent, resolveModel } = require('../agents.cjs');
8
8
  const { logEvent } = require('../logger.cjs');
9
- const { output, error } = require('../core.cjs');
9
+ const { output, error, pipelineGate } = require('../core.cjs');
10
10
  const { recordInvocation, estimateTokens } = require('../cost.cjs');
11
11
  const { acquireLock, releaseLock } = require('../lock.cjs');
12
12
  const { generateExpertise, getDetectedFramework } = require('../stack-expert.cjs');
@@ -306,9 +306,9 @@ async function run(args = [], opts = {}) {
306
306
  if (!targetPlan) {
307
307
  state.phase.status = 'executed';
308
308
  writeState(brainDir, state);
309
- const msg = "All plans executed. Run /brain:verify to check the work.";
310
- output({ action: 'all-executed', message: msg, nextAction: '/brain:verify' }, `[brain] ${msg}`);
311
- return { action: 'all-executed', message: msg, nextAction: '/brain:verify' };
309
+ const msg = "All plans executed. Run /brain:review before verify.";
310
+ output({ action: 'all-executed', message: msg, nextAction: '/brain:review' }, `[brain] ${msg}\n${pipelineGate('npx brain-dev review --phase ' + phaseNumber)}`);
311
+ return { action: 'all-executed', message: msg, nextAction: '/brain:review' };
312
312
  }
313
313
 
314
314
  // Read plan content
@@ -409,10 +409,8 @@ async function run(args = [], opts = {}) {
409
409
  buildDebuggerSpawnInstructions(taskSlug, errorCtx, taskCtx, attemptedFixes, state)
410
410
  };
411
411
 
412
- // Build verify command with optional --auto-recover
413
- const verifyCmd = autoRecover
414
- ? `brain-dev verify --phase ${phaseNumber} --auto-recover`
415
- : `brain-dev verify --phase ${phaseNumber}`;
412
+ // Build review command (review is mandatory before verify)
413
+ const reviewCmd = `brain-dev review --phase ${phaseNumber}`;
416
414
 
417
415
  const humanLines = [
418
416
  `[brain] Executor instructions generated for Plan ${padded} in Phase ${phaseNumber}`,
@@ -425,7 +423,8 @@ async function run(args = [], opts = {}) {
425
423
  if (autoRecover) {
426
424
  humanLines.push('[brain] Auto-recovery: enabled (verify will auto-diagnose failures)');
427
425
  }
428
- humanLines.push(`[brain] Verify with: ${verifyCmd}`);
426
+ humanLines.push(`[brain] After execution, review with: ${reviewCmd}`);
427
+ humanLines.push(pipelineGate(`npx brain-dev review --phase ${phaseNumber}`));
429
428
  humanLines.push('');
430
429
  humanLines.push(fullPrompt);
431
430
  output(result, humanLines.join('\n'));
@@ -5,7 +5,7 @@ const path = require('node:path');
5
5
  const { parseArgs } = require('node:util');
6
6
  const { readState, writeState } = require('../state.cjs');
7
7
  const { logEvent } = require('../logger.cjs');
8
- const { output, error, prefix } = require('../core.cjs');
8
+ const { output, error, prefix, pipelineGate } = require('../core.cjs');
9
9
  const { recordInvocation, estimateTokens } = require('../cost.cjs');
10
10
 
11
11
  async function run(args = [], opts = {}) {
@@ -364,7 +364,8 @@ function handleContinue(brainDir, state) {
364
364
  prefix(`Status: ${newStatus}`),
365
365
  prefix(`Next step: ${nextStep}`),
366
366
  '',
367
- steps[nextStep]
367
+ steps[nextStep],
368
+ nextStep === 'review' ? pipelineGate('npx brain-dev review') : ''
368
369
  ].join('\n');
369
370
 
370
371
  output({
@@ -6,7 +6,7 @@ const { readState, writeState } = require('../state.cjs');
6
6
  const { loadTemplate, interpolate } = require('../templates.cjs');
7
7
  const { resolveModel } = require('../agents.cjs');
8
8
  const { logEvent } = require('../logger.cjs');
9
- const { output, error, success } = require('../core.cjs');
9
+ const { output, error, success, pipelineGate } = require('../core.cjs');
10
10
  const { generateExpertise } = require('../stack-expert.cjs');
11
11
 
12
12
  /**
@@ -265,7 +265,7 @@ function handleExecute(args, brainDir, state) {
265
265
  } catch { /* ignore */ }
266
266
 
267
267
  const nextCmd = isFull
268
- ? `npx brain-dev quick --verify --task ${taskNum}`
268
+ ? `npx brain-dev review`
269
269
  : `npx brain-dev quick --complete --task ${taskNum}`;
270
270
 
271
271
  logEvent(brainDir, 0, { type: 'quick-execute', task: taskNum });
@@ -279,9 +279,10 @@ function handleExecute(args, brainDir, state) {
279
279
  'Do NOT execute the tasks yourself.',
280
280
  '',
281
281
  `After executor completes, run: ${nextCmd}`,
282
+ isFull ? pipelineGate('npx brain-dev review') : '',
282
283
  '',
283
284
  prompt
284
- ].join('\n');
285
+ ].filter(Boolean).join('\n');
285
286
 
286
287
  const result = {
287
288
  action: 'spawn-quick-executor',
@@ -313,6 +314,17 @@ function handleVerify(args, brainDir, state) {
313
314
  return { error: 'task-not-found' };
314
315
  }
315
316
 
317
+ // Hard gate: review must be completed before verify
318
+ const reviewPath = path.join(taskDir, 'REVIEW.md');
319
+ if (!fs.existsSync(reviewPath)) {
320
+ error('Review is mandatory before verify. Run: /brain:review first.');
321
+ output(
322
+ { error: 'review-required', nextAction: '/brain:review' },
323
+ `[brain] BLOCKED: Run /brain:review before quick --verify\n${pipelineGate('npx brain-dev review')}`
324
+ );
325
+ return { error: 'review-required' };
326
+ }
327
+
316
328
  const planPath = path.join(taskDir, 'PLAN-1.md');
317
329
  const verificationPath = path.join(taskDir, 'VERIFICATION-1.md');
318
330
 
@@ -6,7 +6,7 @@ const { readState, writeState, atomicWriteSync } = require('../state.cjs');
6
6
  const { loadTemplate, interpolate, loadTemplateWithOverlay } = require('../templates.cjs');
7
7
  const { getAgent, resolveModel } = require('../agents.cjs');
8
8
  const { logEvent } = require('../logger.cjs');
9
- const { output, error, success } = require('../core.cjs');
9
+ const { output, error, success, pipelineGate } = require('../core.cjs');
10
10
  const antiPatterns = require('../anti-patterns.cjs');
11
11
  const { buildDebuggerSpawnInstructions } = require('./execute.cjs');
12
12
  const { isPathWithinRoot } = require('../security.cjs');
@@ -203,6 +203,17 @@ async function run(args = [], opts = {}) {
203
203
  return { error: 'phase-not-found' };
204
204
  }
205
205
 
206
+ // Hard gate: review must be completed before verify
207
+ const reviewPath = path.join(phaseDir, 'REVIEW.md');
208
+ if (!fs.existsSync(reviewPath)) {
209
+ error('Review is mandatory before verify. Run: /brain:review first.');
210
+ output(
211
+ { error: 'review-required', nextAction: '/brain:review' },
212
+ `[brain] BLOCKED: Run /brain:review before /brain:verify\n${pipelineGate('npx brain-dev review --phase ' + phaseNumber)}`
213
+ );
214
+ return { error: 'review-required' };
215
+ }
216
+
206
217
  // Scan for PLAN-*.md files and extract must_haves from each
207
218
  const files = fs.readdirSync(phaseDir);
208
219
  const planFiles = files.filter(f => /^PLAN-\d+\.md$/.test(f)).sort();
@@ -243,6 +243,13 @@ Include sections:
243
243
  - On failure after retry: `## EXECUTION FAILED`
244
244
  - On checkpoint (user input needed): `## CHECKPOINT REACHED`
245
245
 
246
+ ## After Execution Completes
247
+
248
+ When you output EXECUTION COMPLETE:
249
+ - The orchestrator will run /brain:review BEFORE /brain:verify
250
+ - Review is MANDATORY — it cannot be skipped for any reason
251
+ - Do NOT suggest running verify directly after execution
252
+
246
253
  ## Pipeline Enforcement Reminders
247
254
 
248
255
  **EXECUTION FAILED:** When you output this marker:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brain-dev",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "AI-powered development workflow orchestrator",
5
5
  "author": "halilcosdu",
6
6
  "license": "MIT",