dual-brain 3.9.0 → 4.0.1

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/CLAUDE.md CHANGED
@@ -64,18 +64,49 @@ Profile persists to `.claude/dual-brain.profile.json` (gitignored).
64
64
  Switch profiles: `npx dual-brain mode cost-saver`
65
65
  Check status: `npx dual-brain status`
66
66
 
67
+ Natural language aliases work everywhere: "go aggressive", "be careful", "cheap mode", "fast", "thorough", "smart". The system strips prefixes like "go"/"be"/"use" and resolves to the canonical profile name.
68
+
67
69
  ## Adaptive Routing (Auto Mode)
68
70
 
69
71
  Auto mode classifies risk from file paths and adjusts routing in real-time:
70
72
 
71
73
  - **Risk classification**: auth/secrets→critical, billing/migrations→high, tests/utils→medium, docs→low
72
- - **Failure detection**: 2+ failures on same prompt in 2 hours → auto-escalate tier or trigger dual-brain
74
+ - **Failure detection**: 2+ failures on same prompt in 2 hours → auto-escalate tier or trigger dual-brain. Uses time-weighted decay (recent failures count more) and ledger pruning for entries >24hrs.
73
75
  - **Provider balance**: Routes to underused provider when one subscription is hot
76
+ - **Burst awareness**: Suppresses duplicate warnings and balance hints during agent waves (3+ agents in 90s)
77
+
78
+ ## Vibe Coding
79
+
80
+ Casual natural language → structured work. The vibe coding system translates informal requests into properly routed, risk-classified, quality-gated work.
81
+
82
+ **Intent compiler** — decompose multi-task requests:
83
+ ```bash
84
+ node .claude/hooks/vibe-router.mjs "fix the login bug and also update the nav"
85
+ ```
86
+ Returns structured tasks with tier/risk classification, complexity level, quality gates, and wave strategy.
87
+
88
+ **Plan generator** — Steve-style 3-part markdown plans:
89
+ ```bash
90
+ node .claude/hooks/plan-generator.mjs --utterance "..." [--write]
91
+ ```
92
+ Generates: (1) dependency-ordered task table, (2) user stories + edge cases, (3) questions with suggested answers. Pass `--write` to save to `.claude/plans/`.
93
+
94
+ **Durable memory** — preferences persist across sessions:
95
+ ```bash
96
+ node .claude/hooks/vibe-memory.mjs # show state
97
+ node .claude/hooks/vibe-memory.mjs --set preferences.risk_tolerance=careful
98
+ node .claude/hooks/vibe-memory.mjs --threads # active work
99
+ node .claude/hooks/vibe-memory.mjs --infer # preference suggestions
100
+ ```
101
+ Tracks preferred profile, risk tolerance, active threads, and learns from usage patterns.
74
102
 
75
103
  ## Available Tools
76
104
 
105
+ - `node .claude/hooks/vibe-router.mjs "..."` — decompose casual requests into structured work
106
+ - `node .claude/hooks/plan-generator.mjs --utterance "..."` — generate execution plans
107
+ - `node .claude/hooks/vibe-memory.mjs` — persistent preferences and work threads
77
108
  - `node .claude/hooks/cost-report.mjs` — activity and cost estimates
78
109
  - `node .claude/hooks/health-check.mjs` — verify system health
79
110
  - `node .claude/hooks/budget-balancer.mjs` — provider balance status
80
111
  - `node .claude/hooks/decision-ledger.mjs` — routing outcome insights
81
- - `node .claude/hooks/test-orchestrator.mjs` — run self-tests
112
+ - `node .claude/hooks/test-orchestrator.mjs` — run self-tests (40 tests)
package/README.md CHANGED
@@ -51,10 +51,35 @@ npx -y dual-brain
51
51
 
52
52
  **Dual-brain** is recommended automatically for high-risk decisions — hooks detect the risk level and suggest dual-brain analysis, where both providers think on the same problem independently.
53
53
 
54
+ ## Vibe Coding
55
+
56
+ Speak naturally. The orchestrator handles the structure.
57
+
58
+ ```bash
59
+ # Decompose a casual request into structured work
60
+ node .claude/hooks/vibe-router.mjs "fix the login bug and also update the nav"
61
+
62
+ # Generate a Steve-style execution plan
63
+ node .claude/hooks/plan-generator.mjs --utterance "refactor the auth flow" --write
64
+
65
+ # Switch profiles with natural language
66
+ npx dual-brain mode "go aggressive"
67
+ npx dual-brain mode "be careful"
68
+ npx dual-brain mode "cheap"
69
+
70
+ # Check persistent preferences and work threads
71
+ node .claude/hooks/vibe-memory.mjs --threads
72
+ ```
73
+
74
+ The vibe-router splits multi-task requests, classifies risk, assigns tiers, and recommends quality gates. The plan-generator produces 3-part plans (dependency-ordered tasks, user stories, questions with suggested answers). Vibe-memory learns your preferences over time.
75
+
54
76
  ## Scripts
55
77
 
56
78
  | Script | Purpose |
57
79
  |--------|---------|
80
+ | `hooks/vibe-router.mjs` | Decompose casual language into structured work orders |
81
+ | `hooks/plan-generator.mjs` | Generate Steve-style 3-part execution plans |
82
+ | `hooks/vibe-memory.mjs` | Persistent preferences, work threads, preference inference |
58
83
  | `hooks/cost-report.mjs` | Activity & cost estimates by model tier |
59
84
  | `hooks/dual-brain-review.mjs` | Send git diff to GPT for independent review |
60
85
  | `hooks/dual-brain-think.mjs` | Dual-perspective analysis on architecture decisions |
@@ -63,7 +88,7 @@ npx -y dual-brain
63
88
  | `hooks/gpt-work-dispatcher.mjs` | Dispatch execution tasks to GPT via Codex CLI |
64
89
  | `hooks/session-report.mjs` | Session-end summary: activity, compliance, quality |
65
90
  | `hooks/health-check.mjs` | Verify all hooks and dependencies are working |
66
- | `hooks/test-orchestrator.mjs` | Self-test harness (39 tests) |
91
+ | `hooks/test-orchestrator.mjs` | Self-test harness (40 tests) |
67
92
  | `hooks/setup-wizard.mjs` | Interactive config (optional — for custom plans) |
68
93
  | `hooks/install-git-hooks.mjs` | Git pre-commit hook for quality gate |
69
94
 
@@ -226,11 +226,11 @@ try {
226
226
  if (burstMode) {
227
227
  // In burst mode, only warn on exact hash matches (same description+prompt)
228
228
  if (duplicate.prompt_hash === promptHash) {
229
- duplicateWarning = `**[Wave] [Duplicate Warning]** A similar agent task was dispatched ${minutesAgo} minute${minutesAgo !== 1 ? 's' : ''} ago. Reuse the prior result unless the scope changed.`;
229
+ duplicateWarning = `Heads up a similar task ran ${minutesAgo} minute${minutesAgo !== 1 ? 's' : ''} ago (wave detected). Reuse that result if the scope hasn't changed.`;
230
230
  }
231
231
  // Otherwise suppress — similar-but-different agents in a wave are expected
232
232
  } else {
233
- duplicateWarning = `**[Duplicate Warning]** A similar agent task was dispatched ${minutesAgo} minute${minutesAgo !== 1 ? 's' : ''} ago. Reuse the prior result unless the scope changed.`;
233
+ duplicateWarning = `Heads up a similar task ran ${minutesAgo} minute${minutesAgo !== 1 ? 's' : ''} ago. Reuse that result if the scope hasn't changed.`;
234
234
  }
235
235
  }
236
236
 
@@ -278,10 +278,10 @@ try {
278
278
  ].filter(Boolean);
279
279
 
280
280
  if (detectedTiers.length > 1) {
281
- const splitMsg = `**[Tier Enforcer]** This spans **${detectedTiers.join(' + ')}** work. Consider splitting: ` +
281
+ const splitMsg = `This spans ${detectedTiers.join(' + ')} work. Consider splitting: ` +
282
282
  (hasSearch ? 'search first (haiku), ' : '') +
283
283
  (hasExecute ? 'then execute edits (sonnet), ' : '') +
284
- (hasThink ? 'keep planning/review on think tier (opus).' : '');
284
+ (hasThink ? 'keep planning/review on the main session (opus).' : '');
285
285
  const fullMsg = prependWarnings(splitMsg.replace(/, $/, '.'));
286
286
  logRecommendation({
287
287
  tier: detectedTiers.join('+'),
@@ -310,8 +310,8 @@ try {
310
310
  if ((riskResult.level === 'critical' || riskResult.level === 'high') && tier !== 'think') {
311
311
  tier = 'think';
312
312
  autoStatus = riskResult.level === 'critical'
313
- ? `Dual-brain: dual-brain review recommended — ${riskResult.reason.split(':')[0]} detected`
314
- : `Dual-brain: promoting to think tier — ${riskResult.reason.split(':')[0]}`;
313
+ ? `This touches ${riskResult.reason.split(':')[0].toLowerCase()} — recommending dual-brain review for safety.`
314
+ : `Promoting to think tier — this is ${riskResult.reason.split(':')[0].toLowerCase()}.`;
315
315
  }
316
316
 
317
317
  // Failure loop detection
@@ -320,11 +320,11 @@ try {
320
320
  if (failureCheck.isLoop) {
321
321
  if (failureCheck.suggestion === 'promote_tier' && tier === 'execute') {
322
322
  tier = 'think';
323
- autoStatus = 'Dual-brain: escalating to think tier — previous attempt failed';
323
+ autoStatus = 'Escalating to think tier — this has failed before, let\'s take a different approach.';
324
324
  } else if (failureCheck.suggestion === 'escalate_to_dual_brain') {
325
- autoStatus = 'Dual-brain: dual-brain review recommended repeated failures detected';
325
+ autoStatus = 'Repeated failures detected — recommending dual-brain review to diagnose the issue.';
326
326
  }
327
- failureMessage = `**[Failure Loop]** ${failureCheck.count} failed attempts in 2hrs. Consider: \`node .claude/hooks/dual-brain-think.mjs --question "why is this failing?"\``;
327
+ failureMessage = `⚠️ This has failed ${failureCheck.count} times in the last 2 hours. Consider a dual-brain think session to diagnose the root cause.`;
328
328
  }
329
329
 
330
330
  // Apply profile-driven tier adjustments
@@ -344,7 +344,7 @@ try {
344
344
  const biasThreshold = profileSettings.bias >= 0 ? 10 : 20;
345
345
  if (balance && balance.claudeCalls > balance.openaiCalls * 2 && balance.claudeCalls > biasThreshold) {
346
346
  const dispatchModel = tier === 'think' ? 'gpt-5.5' : tier === 'execute' ? 'gpt-5.4' : 'gpt-4.1-mini';
347
- balanceHint = `\n\n💡 **Balance tip:** Claude has ${balance.claudeCalls} ${tier} calls vs OpenAI's ${balance.openaiCalls} in the last 5hrs. Consider dispatching isolated work to GPT: \`node .claude/hooks/gpt-work-dispatcher.mjs --task "..." --model ${dispatchModel}\``;
347
+ balanceHint = `\n\n💡 Claude is handling most work right now (${balance.claudeCalls} ${tier} calls vs ${balance.openaiCalls} GPT). For isolated tasks, consider routing to GPT to balance subscriptions.`;
348
348
  }
349
349
  }
350
350
  }
@@ -374,8 +374,7 @@ try {
374
374
  // If we get here, a non-think model is being used for think work
375
375
  const thinkBestFor = intelligence[expected || 'opus']?.best_for;
376
376
  const thinkBestForSuffix = thinkBestFor ? ` (best for: ${thinkBestFor})` : '';
377
- const msg = `**[Tier Enforcer]** This looks like **think** work (architecture/review/planning). ` +
378
- `Don't send it to "${currentModel}" — keep it on the main session (${expected || 'opus'}${thinkBestForSuffix}) for best results.`;
377
+ const msg = `This looks like think-level work (architecture/review/planning) better kept on the main session (${expected || 'opus'}${thinkBestForSuffix}) rather than delegated to ${currentModel}.`;
379
378
  logRecommendation({
380
379
  tier,
381
380
  recommended: expected,
@@ -406,8 +405,7 @@ try {
406
405
  const savings = tier === 'search' ? 'Haiku is 19x cheaper than Opus for read-only lookups.' : 'Sonnet is 5x cheaper than Opus for implementation work.';
407
406
  const bestFor = intelligence[expected]?.best_for;
408
407
  const bestForSuffix = bestFor ? ` (best for: ${bestFor})` : '';
409
- const msg = `**[Tier Enforcer]** This looks like **${tier}** work. ` +
410
- `Use \`model: "${expected}"\`${bestForSuffix} instead of "${currentModel || 'opus (inherited)'}". ${savings}`;
408
+ const msg = `This looks like ${tier} work — use ${expected}${bestForSuffix} instead of ${currentModel || 'opus (inherited)'}. ${savings}`;
411
409
  logRecommendation({
412
410
  tier,
413
411
  recommended: expected,