dual-brain 0.2.30 → 0.3.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/.dual-brain/docs/claude-code-extension-points.md +32 -0
- package/.dual-brain/docs/data-tools-capabilities.md +181 -0
- package/.dual-brain/docs/ecosystem-tools.md +91 -0
- package/.dual-brain/docs/panel-handoff.md +124 -0
- package/.dual-brain/docs/ruflo-analysis.md +48 -0
- package/bin/dual-brain.mjs +56 -56
- package/dist/mcp-server/index.d.ts +27 -0
- package/dist/mcp-server/index.js +359 -0
- package/dist/mcp-server/index.js.map +1 -0
- package/dist/src/agent-protocol.d.ts +163 -0
- package/dist/src/agent-protocol.js +368 -0
- package/dist/src/agent-protocol.js.map +1 -0
- package/dist/src/agents/registry.d.ts +52 -0
- package/dist/src/agents/registry.js +393 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/awareness.d.ts +93 -0
- package/dist/src/awareness.js +406 -0
- package/dist/src/awareness.js.map +1 -0
- package/dist/src/brief.d.ts +48 -0
- package/dist/src/brief.js +179 -0
- package/dist/src/brief.js.map +1 -0
- package/dist/src/calibration.d.ts +32 -0
- package/dist/src/calibration.js +133 -0
- package/dist/src/calibration.js.map +1 -0
- package/dist/src/checkpoint.d.ts +33 -0
- package/dist/src/checkpoint.js +99 -0
- package/dist/src/checkpoint.js.map +1 -0
- package/dist/src/ci-triage.d.ts +33 -0
- package/dist/src/ci-triage.js +193 -0
- package/dist/src/ci-triage.js.map +1 -0
- package/dist/src/cognitive-loop.d.ts +56 -0
- package/dist/src/cognitive-loop.js +495 -0
- package/dist/src/cognitive-loop.js.map +1 -0
- package/dist/src/collaboration.d.ts +147 -0
- package/dist/src/collaboration.js +438 -0
- package/dist/src/collaboration.js.map +1 -0
- package/dist/src/context-intel.d.ts +47 -0
- package/dist/src/context-intel.js +156 -0
- package/dist/src/context-intel.js.map +1 -0
- package/dist/src/context.d.ts +53 -0
- package/dist/src/context.js +332 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/continuity.d.ts +89 -0
- package/dist/src/continuity.js +230 -0
- package/dist/src/continuity.js.map +1 -0
- package/dist/src/cost-tracker.d.ts +47 -0
- package/dist/src/cost-tracker.js +170 -0
- package/dist/src/cost-tracker.js.map +1 -0
- package/dist/src/debrief.d.ts +53 -0
- package/dist/src/debrief.js +222 -0
- package/dist/src/debrief.js.map +1 -0
- package/dist/src/decide.d.ts +96 -0
- package/dist/src/decide.js +744 -0
- package/dist/src/decide.js.map +1 -0
- package/dist/src/decompose.d.ts +39 -0
- package/dist/src/decompose.js +218 -0
- package/dist/src/decompose.js.map +1 -0
- package/dist/src/detect.d.ts +91 -0
- package/dist/src/detect.js +544 -0
- package/dist/src/detect.js.map +1 -0
- package/dist/src/dispatch.d.ts +154 -0
- package/dist/src/dispatch.js +1306 -0
- package/dist/src/dispatch.js.map +1 -0
- package/dist/src/doctor.d.ts +421 -0
- package/dist/src/doctor.js +1689 -0
- package/dist/src/doctor.js.map +1 -0
- package/dist/src/engine.d.ts +70 -0
- package/dist/src/engine.js +155 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/envelope.d.ts +36 -0
- package/dist/src/envelope.js +80 -0
- package/dist/src/envelope.js.map +1 -0
- package/dist/src/failure-memory.d.ts +55 -0
- package/dist/src/failure-memory.js +175 -0
- package/dist/src/failure-memory.js.map +1 -0
- package/dist/src/fx.d.ts +87 -0
- package/dist/src/fx.js +272 -0
- package/dist/src/fx.js.map +1 -0
- package/dist/src/governance.d.ts +93 -0
- package/dist/src/governance.js +261 -0
- package/dist/src/governance.js.map +1 -0
- package/dist/src/handoff.d.ts +11 -0
- package/dist/src/handoff.js +90 -0
- package/dist/src/handoff.js.map +1 -0
- package/dist/src/head-protocol.d.ts +76 -0
- package/dist/src/head-protocol.js +109 -0
- package/dist/src/head-protocol.js.map +1 -0
- package/dist/src/head.d.ts +222 -0
- package/dist/src/head.js +765 -0
- package/dist/src/head.js.map +1 -0
- package/dist/src/health.d.ts +132 -0
- package/dist/src/health.js +435 -0
- package/dist/src/health.js.map +1 -0
- package/dist/src/inbox.d.ts +70 -0
- package/dist/src/inbox.js +218 -0
- package/dist/src/inbox.js.map +1 -0
- package/dist/src/index.d.ts +33 -0
- package/dist/src/index.js +38 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/install-hooks.d.ts +13 -0
- package/dist/src/install-hooks.js +88 -0
- package/dist/src/install-hooks.js.map +1 -0
- package/dist/src/integrity.d.ts +59 -0
- package/dist/src/integrity.js +206 -0
- package/dist/src/integrity.js.map +1 -0
- package/dist/src/intelligence.d.ts +104 -0
- package/dist/src/intelligence.js +391 -0
- package/dist/src/intelligence.js.map +1 -0
- package/dist/src/ledger.d.ts +54 -0
- package/dist/src/ledger.js +179 -0
- package/dist/src/ledger.js.map +1 -0
- package/dist/src/living-docs.d.ts +14 -0
- package/dist/src/living-docs.js +197 -0
- package/dist/src/living-docs.js.map +1 -0
- package/dist/src/memory-tiers.d.ts +37 -0
- package/dist/src/memory-tiers.js +160 -0
- package/dist/src/memory-tiers.js.map +1 -0
- package/dist/src/model-profiles.d.ts +65 -0
- package/dist/src/model-profiles.js +568 -0
- package/dist/src/model-profiles.js.map +1 -0
- package/dist/src/models.d.ts +58 -0
- package/dist/src/models.js +327 -0
- package/dist/src/models.js.map +1 -0
- package/dist/src/narrative.d.ts +54 -0
- package/dist/src/narrative.js +163 -0
- package/dist/src/narrative.js.map +1 -0
- package/dist/src/nextstep.d.ts +16 -0
- package/dist/src/nextstep.js +103 -0
- package/dist/src/nextstep.js.map +1 -0
- package/dist/src/observer.d.ts +18 -0
- package/dist/src/observer.js +251 -0
- package/dist/src/observer.js.map +1 -0
- package/dist/src/outcome.d.ts +110 -0
- package/dist/src/outcome.js +377 -0
- package/dist/src/outcome.js.map +1 -0
- package/dist/src/pipeline.d.ts +167 -0
- package/dist/src/pipeline.js +1503 -0
- package/dist/src/pipeline.js.map +1 -0
- package/dist/src/playbook.d.ts +59 -0
- package/dist/src/playbook.js +238 -0
- package/dist/src/playbook.js.map +1 -0
- package/dist/src/pr-agent.d.ts +97 -0
- package/dist/src/pr-agent.js +195 -0
- package/dist/src/pr-agent.js.map +1 -0
- package/dist/src/predictive.d.ts +57 -0
- package/dist/src/predictive.js +230 -0
- package/dist/src/predictive.js.map +1 -0
- package/dist/src/profile.d.ts +294 -0
- package/dist/src/profile.js +1347 -0
- package/dist/src/profile.js.map +1 -0
- package/dist/src/prompt-audit.d.ts +22 -0
- package/dist/src/prompt-audit.js +194 -0
- package/dist/src/prompt-audit.js.map +1 -0
- package/dist/src/prompt-intel.d.ts +12 -0
- package/dist/src/prompt-intel.js +321 -0
- package/dist/src/prompt-intel.js.map +1 -0
- package/dist/src/provider-context.d.ts +121 -0
- package/dist/src/provider-context.js +222 -0
- package/dist/src/provider-context.js.map +1 -0
- package/dist/src/provider-manager.d.ts +92 -0
- package/dist/src/provider-manager.js +428 -0
- package/dist/src/provider-manager.js.map +1 -0
- package/dist/src/receipt.d.ts +87 -0
- package/dist/src/receipt.js +326 -0
- package/dist/src/receipt.js.map +1 -0
- package/dist/src/recommendations.d.ts +13 -0
- package/dist/src/recommendations.js +291 -0
- package/dist/src/recommendations.js.map +1 -0
- package/dist/src/redact.d.ts +15 -0
- package/dist/src/redact.js +129 -0
- package/dist/src/redact.js.map +1 -0
- package/dist/src/replit.d.ts +397 -0
- package/dist/src/replit.js +1160 -0
- package/dist/src/replit.js.map +1 -0
- package/dist/src/repo.d.ts +149 -0
- package/dist/src/repo.js +416 -0
- package/dist/src/repo.js.map +1 -0
- package/dist/src/revert.d.ts +30 -0
- package/dist/src/revert.js +166 -0
- package/dist/src/revert.js.map +1 -0
- package/dist/src/room.d.ts +102 -0
- package/dist/src/room.js +212 -0
- package/dist/src/room.js.map +1 -0
- package/dist/src/routing-advisor.d.ts +57 -0
- package/dist/src/routing-advisor.js +221 -0
- package/dist/src/routing-advisor.js.map +1 -0
- package/dist/src/self-correct.d.ts +40 -0
- package/dist/src/self-correct.js +137 -0
- package/dist/src/self-correct.js.map +1 -0
- package/dist/src/session-lock.d.ts +35 -0
- package/dist/src/session-lock.js +134 -0
- package/dist/src/session-lock.js.map +1 -0
- package/dist/src/session.d.ts +267 -0
- package/dist/src/session.js +1660 -0
- package/dist/src/session.js.map +1 -0
- package/dist/src/settings-tui.d.ts +5 -0
- package/dist/src/settings-tui.js +422 -0
- package/dist/src/settings-tui.js.map +1 -0
- package/dist/src/setup-flow.d.ts +63 -0
- package/dist/src/setup-flow.js +233 -0
- package/dist/src/setup-flow.js.map +1 -0
- package/dist/src/signal.d.ts +19 -0
- package/dist/src/signal.js +122 -0
- package/dist/src/signal.js.map +1 -0
- package/dist/src/simmer.d.ts +85 -0
- package/dist/src/simmer.js +224 -0
- package/dist/src/simmer.js.map +1 -0
- package/dist/src/state-export.d.ts +129 -0
- package/dist/src/state-export.js +233 -0
- package/dist/src/state-export.js.map +1 -0
- package/dist/src/strategy.d.ts +54 -0
- package/dist/src/strategy.js +95 -0
- package/dist/src/strategy.js.map +1 -0
- package/dist/src/subscription.d.ts +40 -0
- package/dist/src/subscription.js +189 -0
- package/dist/src/subscription.js.map +1 -0
- package/dist/src/templates.d.ts +208 -0
- package/dist/src/templates.js +238 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/test.d.ts +9 -0
- package/dist/src/test.js +1173 -0
- package/dist/src/test.js.map +1 -0
- package/dist/src/think-engine.d.ts +67 -0
- package/dist/src/think-engine.js +412 -0
- package/dist/src/think-engine.js.map +1 -0
- package/dist/src/tui.d.ts +71 -0
- package/dist/src/tui.js +242 -0
- package/dist/src/tui.js.map +1 -0
- package/dist/src/types.d.ts +177 -0
- package/dist/src/types.js +6 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/update-check.d.ts +7 -0
- package/dist/src/update-check.js +36 -0
- package/dist/src/update-check.js.map +1 -0
- package/dist/src/wave-planner.d.ts +30 -0
- package/dist/src/wave-planner.js +281 -0
- package/dist/src/wave-planner.js.map +1 -0
- package/hooks/head-guard.sh +41 -0
- package/hooks/precompact.mjs +3 -3
- package/hooks/session-end.mjs +3 -3
- package/hooks/task-classifier.mjs +328 -0
- package/hooks/vibe-router.mjs +387 -0
- package/install.mjs +2 -2
- package/package.json +29 -153
- package/src/agents/registry.mjs +0 -405
- package/src/awareness.mjs +0 -425
- package/src/brief.mjs +0 -266
- package/src/calibration.mjs +0 -148
- package/src/checkpoint.mjs +0 -109
- package/src/ci-triage.mjs +0 -191
- package/src/cognitive-loop.mjs +0 -562
- package/src/collaboration.mjs +0 -545
- package/src/context-intel.mjs +0 -158
- package/src/context.mjs +0 -389
- package/src/continuity.mjs +0 -298
- package/src/cost-tracker.mjs +0 -184
- package/src/debrief.mjs +0 -228
- package/src/decide.mjs +0 -1099
- package/src/decompose.mjs +0 -331
- package/src/detect.mjs +0 -702
- package/src/dispatch.mjs +0 -1447
- package/src/doctor.mjs +0 -1607
- package/src/envelope.mjs +0 -139
- package/src/failure-memory.mjs +0 -178
- package/src/fx.mjs +0 -276
- package/src/governance.mjs +0 -279
- package/src/handoff.mjs +0 -87
- package/src/head-protocol.mjs +0 -128
- package/src/head.mjs +0 -952
- package/src/health.mjs +0 -528
- package/src/inbox.mjs +0 -195
- package/src/index.mjs +0 -44
- package/src/install-hooks.mjs +0 -100
- package/src/integrity.mjs +0 -245
- package/src/intelligence.mjs +0 -447
- package/src/ledger.mjs +0 -196
- package/src/living-docs.mjs +0 -210
- package/src/memory-tiers.mjs +0 -193
- package/src/models.mjs +0 -363
- package/src/narrative.mjs +0 -169
- package/src/nextstep.mjs +0 -100
- package/src/observer.mjs +0 -241
- package/src/outcome.mjs +0 -400
- package/src/pipeline.mjs +0 -1711
- package/src/playbook.mjs +0 -257
- package/src/pr-agent.mjs +0 -214
- package/src/predictive.mjs +0 -250
- package/src/profile.mjs +0 -1411
- package/src/prompt-audit.mjs +0 -231
- package/src/prompt-intel.mjs +0 -325
- package/src/provider-context.mjs +0 -257
- package/src/receipt.mjs +0 -344
- package/src/recommendations.mjs +0 -296
- package/src/redact.mjs +0 -192
- package/src/replit.mjs +0 -1210
- package/src/repo.mjs +0 -445
- package/src/revert.mjs +0 -149
- package/src/routing-advisor.mjs +0 -204
- package/src/self-correct.mjs +0 -147
- package/src/session-lock.mjs +0 -160
- package/src/session.mjs +0 -1655
- package/src/settings-tui.mjs +0 -373
- package/src/setup-flow.mjs +0 -223
- package/src/signal.mjs +0 -115
- package/src/simmer.mjs +0 -241
- package/src/strategy.mjs +0 -235
- package/src/subscription.mjs +0 -212
- package/src/templates.mjs +0 -260
- package/src/think-engine.mjs +0 -428
- package/src/tui.mjs +0 -276
- package/src/update-check.mjs +0 -35
- package/src/wave-planner.mjs +0 -294
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
// prompt-intel.mjs — Layer 3 prompt analysis, enrichment, risk detection, and intervention routing.
|
|
2
|
+
// Pure functions only. No I/O, no exec. Caller provides projectBrief and calibration.
|
|
3
|
+
const INTENT_PATTERNS = {
|
|
4
|
+
fix: /\b(?:fix|bug|broken|error|crash|failing|fails|wrong|issue|problem|broken|not\s+working|doesn't\s+work|doesn't\s+work)\b/i,
|
|
5
|
+
feature: /\b(?:add|create|build|implement|new|introduce|support|enable)\b/i,
|
|
6
|
+
refactor: /\b(?:refactor|clean\s+up|reorganize|simplify|extract|restructure|dedup|consolidate|move)\b/i,
|
|
7
|
+
review: /\b(?:review|check|audit|look\s+at|examine|inspect|assess|evaluate)\b/i,
|
|
8
|
+
ship: /\b(?:ship|deploy|publish|release|push|merge|go\s+live|launch)\b/i,
|
|
9
|
+
explore: /\b(?:what|how|why|where|find|search|explain|show\s+me|tell\s+me|list|which)\b/i,
|
|
10
|
+
test: /\b(?:test|spec|coverage|assert|jest|mocha|vitest|unit\s+test|integration)\b/i,
|
|
11
|
+
docs: /\b(?:doc|readme|comment|jsdoc|document|explain|annotate)\b/i,
|
|
12
|
+
deploy: /\b(?:deploy|provision|infrastructure|ci|cd|pipeline|k8s|kubernetes|docker)\b/i,
|
|
13
|
+
};
|
|
14
|
+
const RISK_PATTERNS = [
|
|
15
|
+
{ type: 'destructive', severity: 'block', re: /\b(?:delete\s+all|remove\s+all|drop\s+all|wipe|destroy|rm\s+-rf|truncate\s+all|nuke)\b/i, detail: 'Prompt contains mass-destructive operation' },
|
|
16
|
+
{ type: 'force_push', severity: 'block', re: /(?:force\s+push|--force|-f\s+origin|reset\s+--hard)/i, detail: 'Prompt implies forced git operation' },
|
|
17
|
+
{ type: 'secret', severity: 'warn', re: /\b(?:api\s+key|access\s+token|secret\s+key|\.env|private\s+key|bearer\s+token)\b/i, detail: 'Touches secret or credential material' },
|
|
18
|
+
{ type: 'auth', severity: 'warn', re: /\b(?:auth(?:entication)?|login|logout|password|credential|jwt|oauth|session\s+token)\b/i, detail: 'Touches authentication code' },
|
|
19
|
+
{ type: 'deploy', severity: 'warn', re: /\b(?:ship\s+to|deploy\s+to|release\s+to|push\s+to\s+prod)\b/i, detail: 'Targets a deployment action' },
|
|
20
|
+
{ type: 'data_loss', severity: 'warn', re: /\b(?:drop\s+table|alter\s+table|schema\s+migration|migrate\s+data|database\s+reset)\b/i, detail: 'Touches schema or migration — data loss risk' },
|
|
21
|
+
{ type: 'production', severity: 'warn', re: /\b(?:production|prod\b|live\s+environment|live\s+site)\b/i, detail: 'References production environment' },
|
|
22
|
+
];
|
|
23
|
+
const FILE_REF_RE = /(?:src\/|\.mjs|\.tsx?|\.jsx?|\.json|\.ya?ml|\.sh|line\s+\d+|\bL\d+\b)/i;
|
|
24
|
+
const FUNC_REF_RE = /\b\w+\((?:\)|[^)]{0,40}\))/;
|
|
25
|
+
const STEP_RE = /\b(?:step\s+\d|first[,\s]|then[,\s]|finally[,\s]|must|should\s+(?:use|call|return|handle))\b/i;
|
|
26
|
+
const CRITERIA_RE = /\b(?:accept(?:ance)?\s+criteria|definition\s+of\s+done|constraints?|requirements?|must\s+(?:not|be|have)|should\s+not)\b/i;
|
|
27
|
+
function clamp(v, min = 1, max = 5) {
|
|
28
|
+
return Math.min(max, Math.max(min, v));
|
|
29
|
+
}
|
|
30
|
+
function scoreSpecificity(prompt) {
|
|
31
|
+
const hasFile = FILE_REF_RE.test(prompt);
|
|
32
|
+
const hasFunc = FUNC_REF_RE.test(prompt);
|
|
33
|
+
const hasLine = /\bL\d+\b|\bline\s+\d+/i.test(prompt);
|
|
34
|
+
const words = prompt.trim().split(/\s+/).length;
|
|
35
|
+
if (hasFile && (hasFunc || hasLine))
|
|
36
|
+
return 5;
|
|
37
|
+
if (hasFile || hasFunc)
|
|
38
|
+
return 4;
|
|
39
|
+
if (words >= 10)
|
|
40
|
+
return 3;
|
|
41
|
+
if (words >= 5)
|
|
42
|
+
return 2;
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
function scoreActionability(prompt) {
|
|
46
|
+
const hasStep = STEP_RE.test(prompt);
|
|
47
|
+
const hasVerb = /\b(?:fix|add|remove|refactor|create|update|write|delete|move|rename|replace|ensure|make)\b/i.test(prompt);
|
|
48
|
+
const hasOutcome = /\b(?:so\s+that|in\s+order\s+to|result(?:ing)?\s+in|should\s+(?:return|output|produce|show))\b/i.test(prompt);
|
|
49
|
+
const words = prompt.trim().split(/\s+/).length;
|
|
50
|
+
if (hasStep && hasVerb)
|
|
51
|
+
return 5;
|
|
52
|
+
if (hasOutcome && hasVerb)
|
|
53
|
+
return 4;
|
|
54
|
+
if (hasVerb && words >= 6)
|
|
55
|
+
return 3;
|
|
56
|
+
if (hasVerb)
|
|
57
|
+
return 2;
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
function scoreSafety(risks) {
|
|
61
|
+
if (risks.some(r => r.severity === 'block'))
|
|
62
|
+
return 1;
|
|
63
|
+
if (risks.some(r => r.type === 'auth' || r.type === 'secret' || r.type === 'production'))
|
|
64
|
+
return 2;
|
|
65
|
+
if (risks.some(r => r.type === 'deploy' || r.type === 'data_loss'))
|
|
66
|
+
return 3;
|
|
67
|
+
if (risks.length > 0)
|
|
68
|
+
return 4;
|
|
69
|
+
return 5;
|
|
70
|
+
}
|
|
71
|
+
function scoreCompleteness(prompt) {
|
|
72
|
+
const hasCriteria = CRITERIA_RE.test(prompt);
|
|
73
|
+
const hasContext = /\b(?:because|since|currently|right\s+now|the\s+issue\s+is|error\s+is|it\s+(?:crashes|fails|returns))\b/i.test(prompt);
|
|
74
|
+
const hasScope = FILE_REF_RE.test(prompt);
|
|
75
|
+
const words = prompt.trim().split(/\s+/).length;
|
|
76
|
+
if (hasCriteria && hasContext && hasScope)
|
|
77
|
+
return 5;
|
|
78
|
+
if ((hasCriteria || hasContext) && hasScope)
|
|
79
|
+
return 4;
|
|
80
|
+
if (hasContext || (hasScope && words >= 8))
|
|
81
|
+
return 3;
|
|
82
|
+
if (words >= 6)
|
|
83
|
+
return 2;
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
function detectIntent(prompt) {
|
|
87
|
+
const counts = {};
|
|
88
|
+
for (const [type, re] of Object.entries(INTENT_PATTERNS)) {
|
|
89
|
+
const matches = prompt.match(new RegExp(re.source, 'gi')) ?? [];
|
|
90
|
+
if (matches.length > 0)
|
|
91
|
+
counts[type] = matches.length;
|
|
92
|
+
}
|
|
93
|
+
const entries = Object.entries(counts).sort((a, b) => b[1] - a[1]);
|
|
94
|
+
if (entries.length === 0) {
|
|
95
|
+
return { type: 'unknown', confidence: 0, keywords: [] };
|
|
96
|
+
}
|
|
97
|
+
const [topType, topCount] = entries[0];
|
|
98
|
+
const totalMatches = Object.values(counts).reduce((s, n) => s + n, 0);
|
|
99
|
+
const confidence = Math.min(1, topCount / Math.max(totalMatches, 1) * (entries.length === 1 ? 1.5 : 1));
|
|
100
|
+
const patternRe = INTENT_PATTERNS[topType];
|
|
101
|
+
const allWords = prompt.match(new RegExp(patternRe.source, 'gi')) ?? [];
|
|
102
|
+
const keywords = [...new Set(allWords.map(w => w.toLowerCase().trim()))].slice(0, 5);
|
|
103
|
+
return { type: topType, confidence: Math.round(confidence * 100) / 100, keywords };
|
|
104
|
+
}
|
|
105
|
+
function detectRisks(prompt) {
|
|
106
|
+
const found = [];
|
|
107
|
+
for (const { type, severity, re, detail } of RISK_PATTERNS) {
|
|
108
|
+
if (re.test(prompt)) {
|
|
109
|
+
found.push({ type, severity, detail });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return found;
|
|
113
|
+
}
|
|
114
|
+
function findMissingInfo(prompt, intent, specificity, completeness) {
|
|
115
|
+
const missing = [];
|
|
116
|
+
if (intent.type === 'fix') {
|
|
117
|
+
if (!/error|exception|crash|fail|wrong|issue/i.test(prompt))
|
|
118
|
+
missing.push('error description or failure symptom');
|
|
119
|
+
if (!FILE_REF_RE.test(prompt))
|
|
120
|
+
missing.push('affected file or component');
|
|
121
|
+
if (!/repro|reproduce|steps|trigger|when\s+I/i.test(prompt))
|
|
122
|
+
missing.push('reproduction steps');
|
|
123
|
+
}
|
|
124
|
+
if (intent.type === 'feature') {
|
|
125
|
+
if (!FILE_REF_RE.test(prompt))
|
|
126
|
+
missing.push('target file or module to add feature to');
|
|
127
|
+
if (!/user\s+(?:can|should|will)|should\s+(?:allow|enable|support)/i.test(prompt))
|
|
128
|
+
missing.push('user-facing outcome');
|
|
129
|
+
}
|
|
130
|
+
if (intent.type === 'refactor' && !FILE_REF_RE.test(prompt)) {
|
|
131
|
+
missing.push('which file or function to refactor');
|
|
132
|
+
}
|
|
133
|
+
if (specificity < 2)
|
|
134
|
+
missing.push('file name or component reference');
|
|
135
|
+
if (completeness < 2)
|
|
136
|
+
missing.push('context about current behavior');
|
|
137
|
+
return [...new Set(missing)].slice(0, 3);
|
|
138
|
+
}
|
|
139
|
+
function chooseIntervention(quality, risks, calibration) {
|
|
140
|
+
if (risks.some(r => r.severity === 'block'))
|
|
141
|
+
return 'block';
|
|
142
|
+
const autonomy = calibration?.autonomy ?? 3;
|
|
143
|
+
const specificity = calibration?.specificity ?? 3;
|
|
144
|
+
if (quality.score >= 4 && risks.length === 0 && autonomy > 4)
|
|
145
|
+
return 'pass';
|
|
146
|
+
if (quality.score < 2 && specificity < 3)
|
|
147
|
+
return 'confirm_rewrite';
|
|
148
|
+
if (quality.score < 3 && quality.completeness <= 2)
|
|
149
|
+
return 'clarify_once';
|
|
150
|
+
return 'silent_enrich';
|
|
151
|
+
}
|
|
152
|
+
export function analyzePrompt(prompt, projectBrief, calibration) {
|
|
153
|
+
const risks = detectRisks(prompt);
|
|
154
|
+
const intent = detectIntent(prompt);
|
|
155
|
+
const specificity = scoreSpecificity(prompt);
|
|
156
|
+
const actionability = scoreActionability(prompt);
|
|
157
|
+
const safety = scoreSafety(risks);
|
|
158
|
+
const completeness = scoreCompleteness(prompt);
|
|
159
|
+
const score = Math.round(((specificity + actionability + safety + completeness) / 4) * 10) / 10;
|
|
160
|
+
const quality = { score, specificity, actionability, safety, completeness };
|
|
161
|
+
const missingInfo = findMissingInfo(prompt, intent, specificity, completeness);
|
|
162
|
+
const intervention = chooseIntervention(quality, risks, calibration);
|
|
163
|
+
return {
|
|
164
|
+
original: prompt,
|
|
165
|
+
quality,
|
|
166
|
+
intent,
|
|
167
|
+
risks,
|
|
168
|
+
missingInfo,
|
|
169
|
+
intervention,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function relevantDirtyFiles(dirtyFiles, intent) {
|
|
173
|
+
if (!Array.isArray(dirtyFiles) || dirtyFiles.length === 0)
|
|
174
|
+
return [];
|
|
175
|
+
const INTENT_HINTS = {
|
|
176
|
+
fix: /\bfix|bug|error\b/i,
|
|
177
|
+
ship: /.*/,
|
|
178
|
+
review: /.*/,
|
|
179
|
+
feature: /src\//i,
|
|
180
|
+
refactor: /src\//i,
|
|
181
|
+
test: /test|spec/i,
|
|
182
|
+
docs: /\.md$|readme/i,
|
|
183
|
+
};
|
|
184
|
+
const re = INTENT_HINTS[intent.type] ?? /src\//i;
|
|
185
|
+
return dirtyFiles.filter((f) => re.test(f)).slice(0, 4);
|
|
186
|
+
}
|
|
187
|
+
export function enrichPrompt(prompt, projectBrief, analysis) {
|
|
188
|
+
if (!projectBrief)
|
|
189
|
+
return prompt;
|
|
190
|
+
const lines = [prompt, ''];
|
|
191
|
+
const branch = projectBrief.branch;
|
|
192
|
+
const dirtyFiles = (projectBrief.dirtyFiles ?? []);
|
|
193
|
+
const recentCommits = (projectBrief.recentCommits ?? []);
|
|
194
|
+
const aheadOfRemote = (projectBrief.aheadOfRemote ?? 0);
|
|
195
|
+
const recentFailures = (projectBrief.recentFailures ?? []);
|
|
196
|
+
const intent = analysis.intent;
|
|
197
|
+
const uncommitted = dirtyFiles.length;
|
|
198
|
+
if (branch || uncommitted > 0) {
|
|
199
|
+
const parts = [];
|
|
200
|
+
if (branch)
|
|
201
|
+
parts.push(`${branch} branch`);
|
|
202
|
+
if (uncommitted > 0)
|
|
203
|
+
parts.push(`${uncommitted} uncommitted file${uncommitted !== 1 ? 's' : ''}`);
|
|
204
|
+
if (aheadOfRemote > 0)
|
|
205
|
+
parts.push(`${aheadOfRemote} ahead of remote`);
|
|
206
|
+
lines.push(`[Context: ${parts.join(', ')}]`);
|
|
207
|
+
}
|
|
208
|
+
const relFiles = relevantDirtyFiles(dirtyFiles, intent);
|
|
209
|
+
if (relFiles.length > 0) {
|
|
210
|
+
lines.push(`[Files: ${relFiles.join(', ')}]`);
|
|
211
|
+
}
|
|
212
|
+
if (recentCommits.length > 0 && ['fix', 'review', 'ship'].includes(intent.type)) {
|
|
213
|
+
lines.push(`[Recent: ${recentCommits[0].slice(0, 80)}]`);
|
|
214
|
+
}
|
|
215
|
+
if (recentFailures.length > 0) {
|
|
216
|
+
const related = recentFailures.find((f) => {
|
|
217
|
+
const fp = (f.prompt ?? '').toLowerCase();
|
|
218
|
+
const pp = prompt.toLowerCase();
|
|
219
|
+
const words = pp.split(/\s+/).filter(w => w.length > 3);
|
|
220
|
+
return words.some(w => fp.includes(w));
|
|
221
|
+
});
|
|
222
|
+
if (related) {
|
|
223
|
+
lines.push(`[Failures: previous attempt failed — ${(related.error ?? 'unknown error').slice(0, 80)}]`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return lines.slice(0, lines.length).join('\n');
|
|
227
|
+
}
|
|
228
|
+
export function formatRiskWarning(risks) {
|
|
229
|
+
if (!risks || risks.length === 0)
|
|
230
|
+
return '';
|
|
231
|
+
const lines = ['⚠️ RISK DETECTED'];
|
|
232
|
+
for (const risk of risks) {
|
|
233
|
+
const icon = risk.severity === 'block' ? '🔴' : '🟡';
|
|
234
|
+
const suffix = risk.severity === 'block' ? ' (BLOCKED)' : ' (proceed with caution)';
|
|
235
|
+
lines.push(` ${icon} ${risk.type}: ${risk.detail}${suffix}`);
|
|
236
|
+
}
|
|
237
|
+
return lines.join('\n');
|
|
238
|
+
}
|
|
239
|
+
export function formatQuality(analysis) {
|
|
240
|
+
const quality = analysis.quality;
|
|
241
|
+
const intent = analysis.intent;
|
|
242
|
+
const intervention = analysis.intervention;
|
|
243
|
+
const q = quality;
|
|
244
|
+
return `Quality: ${q.score}/5 (specificity:${q.specificity} action:${q.actionability} safety:${q.safety} complete:${q.completeness})\nIntent: ${intent.type} (${intent.confidence}) | Intervention: ${intervention}`;
|
|
245
|
+
}
|
|
246
|
+
export function suggestImprovement(analysis) {
|
|
247
|
+
const intent = analysis.intent;
|
|
248
|
+
const missingInfo = analysis.missingInfo;
|
|
249
|
+
const templates = {
|
|
250
|
+
fix: `Fix the [specific function or behavior] in [file path] — it [symptom/error], causing [impact]`,
|
|
251
|
+
feature: `Add [feature name] to [file/component] — it should [user outcome] when [condition]`,
|
|
252
|
+
refactor: `Refactor [function/module] in [file] to [desired outcome] — keep [what to preserve]`,
|
|
253
|
+
review: `Review [file or PR] for [concern] — focus on [specific area or risk]`,
|
|
254
|
+
ship: `Ship [branch/feature] — verify [test status], then merge and publish`,
|
|
255
|
+
explore: `Explain how [specific mechanism] works in [file/component]`,
|
|
256
|
+
test: `Write tests for [function/module] in [file] covering [edge cases]`,
|
|
257
|
+
docs: `Document [function or module] in [file] — cover [params, return, examples]`,
|
|
258
|
+
deploy: `Deploy [service] to [environment] — confirm [readiness checks]`,
|
|
259
|
+
unknown: `Describe what you want changed, which file it's in, and what the expected result is`,
|
|
260
|
+
};
|
|
261
|
+
const base = templates[intent.type] ?? templates.unknown;
|
|
262
|
+
const tips = missingInfo.length > 0
|
|
263
|
+
? ` (missing: ${missingInfo.join(', ')})`
|
|
264
|
+
: '';
|
|
265
|
+
return `Try: '${base}'${tips}`;
|
|
266
|
+
}
|
|
267
|
+
export function getTaskTemplate(intentType) {
|
|
268
|
+
const templates = {
|
|
269
|
+
fix: {
|
|
270
|
+
needs: ['error_description', 'affected_files', 'reproduction_steps'],
|
|
271
|
+
auto_add: ['test_expectations', 'rollback_plan'],
|
|
272
|
+
},
|
|
273
|
+
feature: {
|
|
274
|
+
needs: ['feature_description', 'affected_area'],
|
|
275
|
+
auto_add: ['test_plan', 'acceptance_criteria'],
|
|
276
|
+
},
|
|
277
|
+
refactor: {
|
|
278
|
+
needs: ['target_code', 'desired_outcome'],
|
|
279
|
+
auto_add: ['test_preservation', 'scope_boundary'],
|
|
280
|
+
},
|
|
281
|
+
review: {
|
|
282
|
+
needs: ['scope'],
|
|
283
|
+
auto_add: ['recent_changes', 'risk_areas'],
|
|
284
|
+
},
|
|
285
|
+
ship: {
|
|
286
|
+
needs: ['readiness_check'],
|
|
287
|
+
auto_add: ['test_status', 'git_status', 'uncommitted_changes'],
|
|
288
|
+
},
|
|
289
|
+
explore: {
|
|
290
|
+
needs: ['topic'],
|
|
291
|
+
auto_add: ['related_files', 'recent_changes'],
|
|
292
|
+
},
|
|
293
|
+
test: {
|
|
294
|
+
needs: ['target_function', 'test_framework'],
|
|
295
|
+
auto_add: ['edge_cases', 'existing_coverage'],
|
|
296
|
+
},
|
|
297
|
+
docs: {
|
|
298
|
+
needs: ['target_module'],
|
|
299
|
+
auto_add: ['param_descriptions', 'usage_example'],
|
|
300
|
+
},
|
|
301
|
+
deploy: {
|
|
302
|
+
needs: ['target_environment', 'service_name'],
|
|
303
|
+
auto_add: ['pre_deploy_checks', 'rollback_plan'],
|
|
304
|
+
},
|
|
305
|
+
unknown: {
|
|
306
|
+
needs: ['prompt_clarification'],
|
|
307
|
+
auto_add: [],
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
return templates[intentType] ?? templates.unknown;
|
|
311
|
+
}
|
|
312
|
+
export function shouldBlock(analysis) {
|
|
313
|
+
const risks = analysis.risks;
|
|
314
|
+
return risks.some(r => r.severity === 'block');
|
|
315
|
+
}
|
|
316
|
+
export function getBlockReason(analysis) {
|
|
317
|
+
const risks = analysis.risks;
|
|
318
|
+
const blocking = risks.find(r => r.severity === 'block');
|
|
319
|
+
return blocking ? blocking.detail : null;
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=prompt-intel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-intel.js","sourceRoot":"","sources":["../../src/prompt-intel.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,sFAAsF;AAEtF,MAAM,eAAe,GAAG;IACtB,GAAG,EAAO,0HAA0H;IACpI,OAAO,EAAG,kEAAkE;IAC5E,QAAQ,EAAE,6FAA6F;IACvG,MAAM,EAAI,uEAAuE;IACjF,IAAI,EAAM,kEAAkE;IAC5E,OAAO,EAAG,gFAAgF;IAC1F,IAAI,EAAM,8EAA8E;IACxF,IAAI,EAAM,6DAA6D;IACvE,MAAM,EAAI,+EAA+E;CAC1F,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,EAAE,IAAI,EAAE,aAAa,EAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,yFAAyF,EAAE,MAAM,EAAE,4CAA4C,EAAE;IAChM,EAAE,IAAI,EAAE,YAAY,EAAI,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,sDAAsD,EAAuC,MAAM,EAAE,qCAAqC,EAAE;IAC3L,EAAE,IAAI,EAAE,QAAQ,EAAQ,QAAQ,EAAE,MAAM,EAAG,EAAE,EAAE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C,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAiC;IAC9D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAoD,CAAC;IAC5E,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACzD,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export interface ProviderCapabilities {
|
|
2
|
+
name: string;
|
|
3
|
+
cli: string;
|
|
4
|
+
hasNativeCompaction: boolean;
|
|
5
|
+
compactionStrategy: string;
|
|
6
|
+
contextFormat: string;
|
|
7
|
+
supportsSpecialists: boolean;
|
|
8
|
+
supportsSituationBrief: boolean;
|
|
9
|
+
maxContextTokens: number;
|
|
10
|
+
sessionStorage: string;
|
|
11
|
+
authCheck: string;
|
|
12
|
+
resumeSupport: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getProviderCaps(provider: string): ProviderCapabilities;
|
|
15
|
+
/**
|
|
16
|
+
* Build a context block that works for any provider.
|
|
17
|
+
* Adapts format based on provider capabilities.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildContextBlock(provider: string, sections: Record<string, string | object | null | undefined>): string;
|
|
20
|
+
export interface SurvivalState {
|
|
21
|
+
activeTask?: string;
|
|
22
|
+
provider?: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
tier?: string;
|
|
25
|
+
risk?: string;
|
|
26
|
+
filesInProgress?: string[];
|
|
27
|
+
decisions?: string[];
|
|
28
|
+
warnings?: string[];
|
|
29
|
+
routingRules?: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a compaction survival block tuned for the target provider.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildSurvivalBlock(provider: string, state: SurvivalState): string;
|
|
35
|
+
export interface SessionState {
|
|
36
|
+
taskDescription?: string;
|
|
37
|
+
filesChanged?: string[];
|
|
38
|
+
testsRun?: string[];
|
|
39
|
+
decisions?: Array<{
|
|
40
|
+
provider?: string;
|
|
41
|
+
model?: string;
|
|
42
|
+
}>;
|
|
43
|
+
unresolved?: string[];
|
|
44
|
+
routingHistory?: {
|
|
45
|
+
lastProvider?: string;
|
|
46
|
+
lastModel?: string;
|
|
47
|
+
failedProviders?: string[];
|
|
48
|
+
};
|
|
49
|
+
resumeHint?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ProviderHandoff {
|
|
52
|
+
version: number;
|
|
53
|
+
provider: string;
|
|
54
|
+
providerCaps: string;
|
|
55
|
+
timestamp: string;
|
|
56
|
+
task: string | null;
|
|
57
|
+
progress: {
|
|
58
|
+
filesChanged: string[];
|
|
59
|
+
testsRun: string[];
|
|
60
|
+
decisions: Array<{
|
|
61
|
+
provider?: string;
|
|
62
|
+
model?: string;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
unresolved: string[];
|
|
66
|
+
routing: {
|
|
67
|
+
lastProvider: string;
|
|
68
|
+
lastModel: string | null;
|
|
69
|
+
failedProviders: string[];
|
|
70
|
+
};
|
|
71
|
+
resumeHint: string | null;
|
|
72
|
+
resumeStrategy: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Generate a handoff receipt that works for both providers.
|
|
76
|
+
*/
|
|
77
|
+
export declare function generateProviderHandoff(sessionState: SessionState, provider: string): ProviderHandoff;
|
|
78
|
+
/**
|
|
79
|
+
* Build a resume brief from the latest handoff, adapted for the resuming provider.
|
|
80
|
+
*/
|
|
81
|
+
export declare function buildProviderResumeBrief(cwd: string | undefined, targetProvider: string): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Build a capability hint block for the target provider.
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildCapabilityHint(provider: string, prompt: string, cwd?: string): string | null;
|
|
86
|
+
export interface ContextBudget {
|
|
87
|
+
provider: string;
|
|
88
|
+
maxTokens: number;
|
|
89
|
+
usedTokens: number;
|
|
90
|
+
remainingTokens: number;
|
|
91
|
+
utilizationPct: number;
|
|
92
|
+
compactionRisk: 'critical' | 'high' | 'medium' | 'low';
|
|
93
|
+
hasNativeCompaction: boolean;
|
|
94
|
+
action: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Estimate remaining context budget for a provider.
|
|
98
|
+
*/
|
|
99
|
+
export declare function estimateContextBudget(provider: string, usedTokens: number): ContextBudget;
|
|
100
|
+
/**
|
|
101
|
+
* Get the opposite provider for cross-review.
|
|
102
|
+
*/
|
|
103
|
+
export declare function getReviewProvider(workProvider: string, availableProviders?: string[]): string;
|
|
104
|
+
/**
|
|
105
|
+
* Check if both providers are available for true dual-brain operation.
|
|
106
|
+
*/
|
|
107
|
+
export declare function isDualProviderAvailable(profile: {
|
|
108
|
+
providers?: {
|
|
109
|
+
claude?: {
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
};
|
|
112
|
+
openai?: {
|
|
113
|
+
enabled?: boolean;
|
|
114
|
+
plan?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
} | null | undefined): {
|
|
118
|
+
claude: boolean;
|
|
119
|
+
openai: boolean;
|
|
120
|
+
dual: boolean;
|
|
121
|
+
};
|