oh-my-claude-sisyphus 1.11.2 → 2.0.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.
- package/README.md +37 -12
- package/dist/__tests__/example.test.d.ts +2 -0
- package/dist/__tests__/example.test.d.ts.map +1 -0
- package/dist/__tests__/example.test.js +20 -0
- package/dist/__tests__/example.test.js.map +1 -0
- package/dist/__tests__/hooks.test.d.ts +2 -0
- package/dist/__tests__/hooks.test.d.ts.map +1 -0
- package/dist/__tests__/hooks.test.js +644 -0
- package/dist/__tests__/hooks.test.js.map +1 -0
- package/dist/__tests__/installer.test.d.ts +2 -0
- package/dist/__tests__/installer.test.d.ts.map +1 -0
- package/dist/__tests__/installer.test.js +369 -0
- package/dist/__tests__/installer.test.js.map +1 -0
- package/dist/__tests__/model-routing.test.d.ts +2 -0
- package/dist/__tests__/model-routing.test.d.ts.map +1 -0
- package/dist/__tests__/model-routing.test.js +814 -0
- package/dist/__tests__/model-routing.test.js.map +1 -0
- package/dist/__tests__/skills.test.d.ts +2 -0
- package/dist/__tests__/skills.test.d.ts.map +1 -0
- package/dist/__tests__/skills.test.js +126 -0
- package/dist/__tests__/skills.test.js.map +1 -0
- package/dist/__tests__/types.test.d.ts +2 -0
- package/dist/__tests__/types.test.d.ts.map +1 -0
- package/dist/__tests__/types.test.js +77 -0
- package/dist/__tests__/types.test.js.map +1 -0
- package/dist/agents/definitions.d.ts +33 -1
- package/dist/agents/definitions.d.ts.map +1 -1
- package/dist/agents/definitions.js +254 -3
- package/dist/agents/definitions.js.map +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +3 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/oracle.d.ts.map +1 -1
- package/dist/agents/oracle.js +43 -1
- package/dist/agents/oracle.js.map +1 -1
- package/dist/agents/orchestrator-sisyphus.js +2 -2
- package/dist/agents/orchestrator-sisyphus.js.map +1 -1
- package/dist/cli/index.js +22 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +49 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/features/auto-update.d.ts.map +1 -1
- package/dist/features/auto-update.js +14 -3
- package/dist/features/auto-update.js.map +1 -1
- package/dist/features/builtin-skills/skills.d.ts.map +1 -1
- package/dist/features/builtin-skills/skills.js +0 -1351
- package/dist/features/builtin-skills/skills.js.map +1 -1
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +14 -0
- package/dist/features/index.js.map +1 -1
- package/dist/features/model-routing/index.d.ts +34 -0
- package/dist/features/model-routing/index.d.ts.map +1 -0
- package/dist/features/model-routing/index.js +48 -0
- package/dist/features/model-routing/index.js.map +1 -0
- package/dist/features/model-routing/prompts/haiku.d.ts +54 -0
- package/dist/features/model-routing/prompts/haiku.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/haiku.js +141 -0
- package/dist/features/model-routing/prompts/haiku.js.map +1 -0
- package/dist/features/model-routing/prompts/index.d.ts +45 -0
- package/dist/features/model-routing/prompts/index.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/index.js +116 -0
- package/dist/features/model-routing/prompts/index.js.map +1 -0
- package/dist/features/model-routing/prompts/opus.d.ts +34 -0
- package/dist/features/model-routing/prompts/opus.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/opus.js +153 -0
- package/dist/features/model-routing/prompts/opus.js.map +1 -0
- package/dist/features/model-routing/prompts/sonnet.d.ts +38 -0
- package/dist/features/model-routing/prompts/sonnet.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/sonnet.js +149 -0
- package/dist/features/model-routing/prompts/sonnet.js.map +1 -0
- package/dist/features/model-routing/router.d.ts +92 -0
- package/dist/features/model-routing/router.d.ts.map +1 -0
- package/dist/features/model-routing/router.js +267 -0
- package/dist/features/model-routing/router.js.map +1 -0
- package/dist/features/model-routing/rules.d.ts +32 -0
- package/dist/features/model-routing/rules.d.ts.map +1 -0
- package/dist/features/model-routing/rules.js +224 -0
- package/dist/features/model-routing/rules.js.map +1 -0
- package/dist/features/model-routing/scorer.d.ts +35 -0
- package/dist/features/model-routing/scorer.d.ts.map +1 -0
- package/dist/features/model-routing/scorer.js +241 -0
- package/dist/features/model-routing/scorer.js.map +1 -0
- package/dist/features/model-routing/signals.d.ts +26 -0
- package/dist/features/model-routing/signals.d.ts.map +1 -0
- package/dist/features/model-routing/signals.js +283 -0
- package/dist/features/model-routing/signals.js.map +1 -0
- package/dist/features/model-routing/types.d.ts +195 -0
- package/dist/features/model-routing/types.d.ts.map +1 -0
- package/dist/features/model-routing/types.js +86 -0
- package/dist/features/model-routing/types.js.map +1 -0
- package/dist/hooks/agent-usage-reminder/index.d.ts +1 -1
- package/dist/hooks/agent-usage-reminder/index.d.ts.map +1 -1
- package/dist/hooks/agent-usage-reminder/index.js +1 -1
- package/dist/hooks/agent-usage-reminder/index.js.map +1 -1
- package/dist/hooks/auto-slash-command/executor.js.map +1 -1
- package/dist/hooks/auto-slash-command/index.d.ts +3 -3
- package/dist/hooks/auto-slash-command/index.d.ts.map +1 -1
- package/dist/hooks/auto-slash-command/index.js.map +1 -1
- package/dist/hooks/background-notification/index.js +1 -1
- package/dist/hooks/background-notification/index.js.map +1 -1
- package/dist/hooks/bridge.d.ts.map +1 -1
- package/dist/hooks/bridge.js.map +1 -1
- package/dist/hooks/comment-checker/filters.d.ts +1 -1
- package/dist/hooks/comment-checker/filters.d.ts.map +1 -1
- package/dist/hooks/comment-checker/filters.js +1 -1
- package/dist/hooks/comment-checker/filters.js.map +1 -1
- package/dist/hooks/comment-checker/index.js +1 -1
- package/dist/hooks/comment-checker/index.js.map +1 -1
- package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -1
- package/dist/hooks/context-window-limit-recovery/index.js.map +1 -1
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -3
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/keyword-detector/index.d.ts +1 -1
- package/dist/hooks/keyword-detector/index.d.ts.map +1 -1
- package/dist/hooks/keyword-detector/index.js +1 -1
- package/dist/hooks/keyword-detector/index.js.map +1 -1
- package/dist/hooks/persistent-mode/index.d.ts.map +1 -1
- package/dist/hooks/persistent-mode/index.js.map +1 -1
- package/dist/hooks/plugin-patterns/index.d.ts.map +1 -1
- package/dist/hooks/plugin-patterns/index.js +12 -22
- package/dist/hooks/plugin-patterns/index.js.map +1 -1
- package/dist/hooks/preemptive-compaction/index.d.ts +2 -2
- package/dist/hooks/preemptive-compaction/index.d.ts.map +1 -1
- package/dist/hooks/preemptive-compaction/index.js +1 -11
- package/dist/hooks/preemptive-compaction/index.js.map +1 -1
- package/dist/hooks/ralph-loop/index.js.map +1 -1
- package/dist/hooks/rules-injector/matcher.js +1 -1
- package/dist/hooks/rules-injector/matcher.js.map +1 -1
- package/dist/hooks/session-recovery/index.d.ts +1 -1
- package/dist/hooks/session-recovery/index.d.ts.map +1 -1
- package/dist/hooks/session-recovery/index.js +1 -1
- package/dist/hooks/session-recovery/index.js.map +1 -1
- package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -1
- package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -1
- package/dist/hooks/ultrawork-state/index.js +1 -1
- package/dist/hooks/ultrawork-state/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/installer/hooks.d.ts +1 -1
- package/dist/installer/hooks.js +1 -1
- package/dist/installer/index.d.ts +8 -7
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +648 -2141
- package/dist/installer/index.js.map +1 -1
- package/dist/shared/types.d.ts +25 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/tools/lsp/servers.d.ts.map +1 -1
- package/dist/tools/lsp/servers.js +2 -14
- package/dist/tools/lsp/servers.js.map +1 -1
- package/package.json +18 -10
- package/scripts/install.sh +236 -260
- package/scripts/test-pr25.sh +525 -0
- package/dist/agents/model-lists.d.ts +0 -26
- package/dist/agents/model-lists.d.ts.map +0 -1
- package/dist/agents/model-lists.js +0 -62
- package/dist/agents/model-lists.js.map +0 -1
- package/dist/auth/index.d.ts +0 -10
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -13
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/manager.d.ts +0 -54
- package/dist/auth/manager.d.ts.map +0 -1
- package/dist/auth/manager.js +0 -248
- package/dist/auth/manager.js.map +0 -1
- package/dist/auth/oauth-google.d.ts +0 -47
- package/dist/auth/oauth-google.d.ts.map +0 -1
- package/dist/auth/oauth-google.js +0 -280
- package/dist/auth/oauth-google.js.map +0 -1
- package/dist/auth/oauth-openai.d.ts +0 -46
- package/dist/auth/oauth-openai.d.ts.map +0 -1
- package/dist/auth/oauth-openai.js +0 -264
- package/dist/auth/oauth-openai.js.map +0 -1
- package/dist/auth/pkce.d.ts +0 -14
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js +0 -35
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/storage.d.ts +0 -52
- package/dist/auth/storage.d.ts.map +0 -1
- package/dist/auth/storage.js +0 -230
- package/dist/auth/storage.js.map +0 -1
- package/dist/auth/types.d.ts +0 -76
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js +0 -5
- package/dist/auth/types.js.map +0 -1
- package/dist/providers/index.d.ts +0 -8
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -10
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/registry.d.ts +0 -29
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js +0 -162
- package/dist/providers/registry.js.map +0 -1
- package/dist/providers/router.d.ts +0 -40
- package/dist/providers/router.d.ts.map +0 -1
- package/dist/providers/router.js +0 -88
- package/dist/providers/router.js.map +0 -1
- package/dist/providers/types.d.ts +0 -92
- package/dist/providers/types.d.ts.map +0 -1
- package/dist/providers/types.js +0 -27
- package/dist/providers/types.js.map +0 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complexity Scorer
|
|
3
|
+
*
|
|
4
|
+
* Calculates complexity tier based on extracted signals.
|
|
5
|
+
* Uses weighted scoring to determine LOW/MEDIUM/HIGH tier.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Score thresholds for tier classification
|
|
9
|
+
*/
|
|
10
|
+
const TIER_THRESHOLDS = {
|
|
11
|
+
HIGH: 8, // Score >= 8 -> HIGH (Opus)
|
|
12
|
+
MEDIUM: 4, // Score >= 4 -> MEDIUM (Sonnet)
|
|
13
|
+
// Score < 4 -> LOW (Haiku)
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Weight configuration for different signal categories
|
|
17
|
+
* Total should roughly sum to enable score range 0-15+
|
|
18
|
+
*/
|
|
19
|
+
const WEIGHTS = {
|
|
20
|
+
lexical: {
|
|
21
|
+
wordCountHigh: 2, // Long prompts (+2)
|
|
22
|
+
wordCountVeryHigh: 1, // Very long prompts (+1 additional)
|
|
23
|
+
filePathsMultiple: 1, // Multiple file paths (+1)
|
|
24
|
+
codeBlocksPresent: 1, // Code blocks (+1)
|
|
25
|
+
architectureKeywords: 3, // Architecture keywords (+3)
|
|
26
|
+
debuggingKeywords: 2, // Debugging keywords (+2)
|
|
27
|
+
simpleKeywords: -2, // Simple keywords (-2)
|
|
28
|
+
riskKeywords: 2, // Risk keywords (+2)
|
|
29
|
+
questionDepthWhy: 2, // 'Why' questions (+2)
|
|
30
|
+
questionDepthHow: 1, // 'How' questions (+1)
|
|
31
|
+
implicitRequirements: 1, // Vague requirements (+1)
|
|
32
|
+
},
|
|
33
|
+
structural: {
|
|
34
|
+
subtasksMany: 3, // Many subtasks (+3)
|
|
35
|
+
subtasksSome: 1, // Some subtasks (+1)
|
|
36
|
+
crossFile: 2, // Cross-file changes (+2)
|
|
37
|
+
testRequired: 1, // Tests required (+1)
|
|
38
|
+
securityDomain: 2, // Security domain (+2)
|
|
39
|
+
infrastructureDomain: 1, // Infrastructure domain (+1)
|
|
40
|
+
externalKnowledge: 1, // External knowledge needed (+1)
|
|
41
|
+
reversibilityDifficult: 2, // Difficult to reverse (+2)
|
|
42
|
+
reversibilityModerate: 1, // Moderate reversibility (+1)
|
|
43
|
+
impactSystemWide: 3, // System-wide impact (+3)
|
|
44
|
+
impactModule: 1, // Module-level impact (+1)
|
|
45
|
+
},
|
|
46
|
+
context: {
|
|
47
|
+
previousFailure: 2, // Per previous failure (+2 each)
|
|
48
|
+
previousFailureMax: 4, // Max from failures
|
|
49
|
+
deepChain: 2, // Deep agent chain (+2)
|
|
50
|
+
complexPlan: 1, // Complex plan (+1)
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Calculate complexity score from lexical signals
|
|
55
|
+
*/
|
|
56
|
+
function scoreLexicalSignals(signals) {
|
|
57
|
+
let score = 0;
|
|
58
|
+
// Word count scoring
|
|
59
|
+
if (signals.wordCount > 200) {
|
|
60
|
+
score += WEIGHTS.lexical.wordCountHigh;
|
|
61
|
+
if (signals.wordCount > 500) {
|
|
62
|
+
score += WEIGHTS.lexical.wordCountVeryHigh;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// File paths
|
|
66
|
+
if (signals.filePathCount >= 2) {
|
|
67
|
+
score += WEIGHTS.lexical.filePathsMultiple;
|
|
68
|
+
}
|
|
69
|
+
// Code blocks
|
|
70
|
+
if (signals.codeBlockCount > 0) {
|
|
71
|
+
score += WEIGHTS.lexical.codeBlocksPresent;
|
|
72
|
+
}
|
|
73
|
+
// Keyword scoring
|
|
74
|
+
if (signals.hasArchitectureKeywords) {
|
|
75
|
+
score += WEIGHTS.lexical.architectureKeywords;
|
|
76
|
+
}
|
|
77
|
+
if (signals.hasDebuggingKeywords) {
|
|
78
|
+
score += WEIGHTS.lexical.debuggingKeywords;
|
|
79
|
+
}
|
|
80
|
+
if (signals.hasSimpleKeywords) {
|
|
81
|
+
score += WEIGHTS.lexical.simpleKeywords; // Negative weight
|
|
82
|
+
}
|
|
83
|
+
if (signals.hasRiskKeywords) {
|
|
84
|
+
score += WEIGHTS.lexical.riskKeywords;
|
|
85
|
+
}
|
|
86
|
+
// Question depth
|
|
87
|
+
switch (signals.questionDepth) {
|
|
88
|
+
case 'why':
|
|
89
|
+
score += WEIGHTS.lexical.questionDepthWhy;
|
|
90
|
+
break;
|
|
91
|
+
case 'how':
|
|
92
|
+
score += WEIGHTS.lexical.questionDepthHow;
|
|
93
|
+
break;
|
|
94
|
+
// 'what', 'where', 'none' add nothing
|
|
95
|
+
}
|
|
96
|
+
// Implicit requirements
|
|
97
|
+
if (signals.hasImplicitRequirements) {
|
|
98
|
+
score += WEIGHTS.lexical.implicitRequirements;
|
|
99
|
+
}
|
|
100
|
+
return score;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Calculate complexity score from structural signals
|
|
104
|
+
*/
|
|
105
|
+
function scoreStructuralSignals(signals) {
|
|
106
|
+
let score = 0;
|
|
107
|
+
// Subtask scoring
|
|
108
|
+
if (signals.estimatedSubtasks > 3) {
|
|
109
|
+
score += WEIGHTS.structural.subtasksMany;
|
|
110
|
+
}
|
|
111
|
+
else if (signals.estimatedSubtasks > 1) {
|
|
112
|
+
score += WEIGHTS.structural.subtasksSome;
|
|
113
|
+
}
|
|
114
|
+
// Cross-file dependencies
|
|
115
|
+
if (signals.crossFileDependencies) {
|
|
116
|
+
score += WEIGHTS.structural.crossFile;
|
|
117
|
+
}
|
|
118
|
+
// Test requirements
|
|
119
|
+
if (signals.hasTestRequirements) {
|
|
120
|
+
score += WEIGHTS.structural.testRequired;
|
|
121
|
+
}
|
|
122
|
+
// Domain specificity
|
|
123
|
+
switch (signals.domainSpecificity) {
|
|
124
|
+
case 'security':
|
|
125
|
+
score += WEIGHTS.structural.securityDomain;
|
|
126
|
+
break;
|
|
127
|
+
case 'infrastructure':
|
|
128
|
+
score += WEIGHTS.structural.infrastructureDomain;
|
|
129
|
+
break;
|
|
130
|
+
// Other domains add nothing
|
|
131
|
+
}
|
|
132
|
+
// External knowledge
|
|
133
|
+
if (signals.requiresExternalKnowledge) {
|
|
134
|
+
score += WEIGHTS.structural.externalKnowledge;
|
|
135
|
+
}
|
|
136
|
+
// Reversibility
|
|
137
|
+
switch (signals.reversibility) {
|
|
138
|
+
case 'difficult':
|
|
139
|
+
score += WEIGHTS.structural.reversibilityDifficult;
|
|
140
|
+
break;
|
|
141
|
+
case 'moderate':
|
|
142
|
+
score += WEIGHTS.structural.reversibilityModerate;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
// Impact scope
|
|
146
|
+
switch (signals.impactScope) {
|
|
147
|
+
case 'system-wide':
|
|
148
|
+
score += WEIGHTS.structural.impactSystemWide;
|
|
149
|
+
break;
|
|
150
|
+
case 'module':
|
|
151
|
+
score += WEIGHTS.structural.impactModule;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
return score;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Calculate complexity score from context signals
|
|
158
|
+
*/
|
|
159
|
+
function scoreContextSignals(signals) {
|
|
160
|
+
let score = 0;
|
|
161
|
+
// Previous failures (capped)
|
|
162
|
+
const failureScore = Math.min(signals.previousFailures * WEIGHTS.context.previousFailure, WEIGHTS.context.previousFailureMax);
|
|
163
|
+
score += failureScore;
|
|
164
|
+
// Deep agent chain (3+ levels)
|
|
165
|
+
if (signals.agentChainDepth >= 3) {
|
|
166
|
+
score += WEIGHTS.context.deepChain;
|
|
167
|
+
}
|
|
168
|
+
// Complex plan (5+ tasks)
|
|
169
|
+
if (signals.planComplexity >= 5) {
|
|
170
|
+
score += WEIGHTS.context.complexPlan;
|
|
171
|
+
}
|
|
172
|
+
return score;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Calculate total complexity score
|
|
176
|
+
*/
|
|
177
|
+
export function calculateComplexityScore(signals) {
|
|
178
|
+
const lexicalScore = scoreLexicalSignals(signals.lexical);
|
|
179
|
+
const structuralScore = scoreStructuralSignals(signals.structural);
|
|
180
|
+
const contextScore = scoreContextSignals(signals.context);
|
|
181
|
+
return lexicalScore + structuralScore + contextScore;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Determine complexity tier from score
|
|
185
|
+
*/
|
|
186
|
+
export function scoreToTier(score) {
|
|
187
|
+
if (score >= TIER_THRESHOLDS.HIGH)
|
|
188
|
+
return 'HIGH';
|
|
189
|
+
if (score >= TIER_THRESHOLDS.MEDIUM)
|
|
190
|
+
return 'MEDIUM';
|
|
191
|
+
return 'LOW';
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Calculate complexity tier from signals
|
|
195
|
+
*/
|
|
196
|
+
export function calculateComplexityTier(signals) {
|
|
197
|
+
const score = calculateComplexityScore(signals);
|
|
198
|
+
return scoreToTier(score);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get detailed score breakdown for debugging/logging
|
|
202
|
+
*/
|
|
203
|
+
export function getScoreBreakdown(signals) {
|
|
204
|
+
const lexical = scoreLexicalSignals(signals.lexical);
|
|
205
|
+
const structural = scoreStructuralSignals(signals.structural);
|
|
206
|
+
const context = scoreContextSignals(signals.context);
|
|
207
|
+
const total = lexical + structural + context;
|
|
208
|
+
return {
|
|
209
|
+
lexical,
|
|
210
|
+
structural,
|
|
211
|
+
context,
|
|
212
|
+
total,
|
|
213
|
+
tier: scoreToTier(total),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Calculate confidence in the tier assignment
|
|
218
|
+
* Higher confidence when score is far from thresholds
|
|
219
|
+
*/
|
|
220
|
+
export function calculateConfidence(score, tier) {
|
|
221
|
+
const distanceFromLow = Math.abs(score - TIER_THRESHOLDS.MEDIUM);
|
|
222
|
+
const distanceFromHigh = Math.abs(score - TIER_THRESHOLDS.HIGH);
|
|
223
|
+
// Minimum distance from any threshold
|
|
224
|
+
let minDistance;
|
|
225
|
+
switch (tier) {
|
|
226
|
+
case 'LOW':
|
|
227
|
+
minDistance = TIER_THRESHOLDS.MEDIUM - score;
|
|
228
|
+
break;
|
|
229
|
+
case 'MEDIUM':
|
|
230
|
+
minDistance = Math.min(distanceFromLow, distanceFromHigh);
|
|
231
|
+
break;
|
|
232
|
+
case 'HIGH':
|
|
233
|
+
minDistance = score - TIER_THRESHOLDS.HIGH;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
// Convert distance to confidence (0-1)
|
|
237
|
+
// Distance of 0 = 0.5 confidence, distance of 4+ = 0.9+ confidence
|
|
238
|
+
const confidence = 0.5 + (Math.min(minDistance, 4) / 4) * 0.4;
|
|
239
|
+
return Math.round(confidence * 100) / 100;
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=scorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorer.js","sourceRoot":"","sources":["../../../src/features/model-routing/scorer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;GAEG;AACH,MAAM,eAAe,GAAG;IACtB,IAAI,EAAE,CAAC,EAAK,4BAA4B;IACxC,MAAM,EAAE,CAAC,EAAG,gCAAgC;IAC5C,2BAA2B;CAC5B,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,GAAG;IACd,OAAO,EAAE;QACP,aAAa,EAAE,CAAC,EAAU,oBAAoB;QAC9C,iBAAiB,EAAE,CAAC,EAAM,oCAAoC;QAC9D,iBAAiB,EAAE,CAAC,EAAM,2BAA2B;QACrD,iBAAiB,EAAE,CAAC,EAAM,mBAAmB;QAC7C,oBAAoB,EAAE,CAAC,EAAG,6BAA6B;QACvD,iBAAiB,EAAE,CAAC,EAAM,0BAA0B;QACpD,cAAc,EAAE,CAAC,CAAC,EAAQ,uBAAuB;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;IACnE,MAAM,UAAU,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complexity Signal Extraction
|
|
3
|
+
*
|
|
4
|
+
* Extracts complexity signals from task prompts to inform routing decisions.
|
|
5
|
+
* Signals are categorized into lexical, structural, and context types.
|
|
6
|
+
*/
|
|
7
|
+
import type { LexicalSignals, StructuralSignals, ContextSignals, ComplexitySignals, RoutingContext } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Extract lexical signals from task prompt
|
|
10
|
+
* These are fast, regex-based extractions that don't require model calls
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractLexicalSignals(prompt: string): LexicalSignals;
|
|
13
|
+
/**
|
|
14
|
+
* Extract structural signals from task prompt
|
|
15
|
+
* These require more sophisticated parsing
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractStructuralSignals(prompt: string): StructuralSignals;
|
|
18
|
+
/**
|
|
19
|
+
* Extract context signals from routing context
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractContextSignals(context: RoutingContext): ContextSignals;
|
|
22
|
+
/**
|
|
23
|
+
* Extract all complexity signals
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractAllSignals(prompt: string, context: RoutingContext): ComplexitySignals;
|
|
26
|
+
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../../src/features/model-routing/signals.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAepE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAY1E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAQ7E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,cAAc,GACtB,iBAAiB,CAMnB"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complexity Signal Extraction
|
|
3
|
+
*
|
|
4
|
+
* Extracts complexity signals from task prompts to inform routing decisions.
|
|
5
|
+
* Signals are categorized into lexical, structural, and context types.
|
|
6
|
+
*/
|
|
7
|
+
import { COMPLEXITY_KEYWORDS } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Extract lexical signals from task prompt
|
|
10
|
+
* These are fast, regex-based extractions that don't require model calls
|
|
11
|
+
*/
|
|
12
|
+
export function extractLexicalSignals(prompt) {
|
|
13
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
14
|
+
const words = prompt.split(/\s+/).filter(w => w.length > 0);
|
|
15
|
+
return {
|
|
16
|
+
wordCount: words.length,
|
|
17
|
+
filePathCount: countFilePaths(prompt),
|
|
18
|
+
codeBlockCount: countCodeBlocks(prompt),
|
|
19
|
+
hasArchitectureKeywords: hasKeywords(lowerPrompt, COMPLEXITY_KEYWORDS.architecture),
|
|
20
|
+
hasDebuggingKeywords: hasKeywords(lowerPrompt, COMPLEXITY_KEYWORDS.debugging),
|
|
21
|
+
hasSimpleKeywords: hasKeywords(lowerPrompt, COMPLEXITY_KEYWORDS.simple),
|
|
22
|
+
hasRiskKeywords: hasKeywords(lowerPrompt, COMPLEXITY_KEYWORDS.risk),
|
|
23
|
+
questionDepth: detectQuestionDepth(lowerPrompt),
|
|
24
|
+
hasImplicitRequirements: detectImplicitRequirements(lowerPrompt),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Extract structural signals from task prompt
|
|
29
|
+
* These require more sophisticated parsing
|
|
30
|
+
*/
|
|
31
|
+
export function extractStructuralSignals(prompt) {
|
|
32
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
33
|
+
return {
|
|
34
|
+
estimatedSubtasks: estimateSubtasks(prompt),
|
|
35
|
+
crossFileDependencies: detectCrossFileDependencies(prompt),
|
|
36
|
+
hasTestRequirements: detectTestRequirements(lowerPrompt),
|
|
37
|
+
domainSpecificity: detectDomain(lowerPrompt),
|
|
38
|
+
requiresExternalKnowledge: detectExternalKnowledge(lowerPrompt),
|
|
39
|
+
reversibility: assessReversibility(lowerPrompt),
|
|
40
|
+
impactScope: assessImpactScope(prompt),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extract context signals from routing context
|
|
45
|
+
*/
|
|
46
|
+
export function extractContextSignals(context) {
|
|
47
|
+
return {
|
|
48
|
+
previousFailures: context.previousFailures ?? 0,
|
|
49
|
+
conversationTurns: context.conversationTurns ?? 0,
|
|
50
|
+
planComplexity: context.planTasks ?? 0,
|
|
51
|
+
remainingTasks: context.remainingTasks ?? 0,
|
|
52
|
+
agentChainDepth: context.agentChainDepth ?? 0,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Extract all complexity signals
|
|
57
|
+
*/
|
|
58
|
+
export function extractAllSignals(prompt, context) {
|
|
59
|
+
return {
|
|
60
|
+
lexical: extractLexicalSignals(prompt),
|
|
61
|
+
structural: extractStructuralSignals(prompt),
|
|
62
|
+
context: extractContextSignals(context),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// ============ Helper Functions ============
|
|
66
|
+
/**
|
|
67
|
+
* Count file paths in prompt
|
|
68
|
+
*/
|
|
69
|
+
function countFilePaths(prompt) {
|
|
70
|
+
// Match common file path patterns
|
|
71
|
+
const patterns = [
|
|
72
|
+
/(?:^|\s)[.\/~]?(?:[\w-]+\/)+[\w.-]+\.\w+/gm, // Unix-style paths
|
|
73
|
+
/`[^`]+\.\w+`/g, // Backtick-quoted files
|
|
74
|
+
/['"][^'"]+\.\w+['"]/g, // Quoted files
|
|
75
|
+
];
|
|
76
|
+
let count = 0;
|
|
77
|
+
for (const pattern of patterns) {
|
|
78
|
+
const matches = prompt.match(pattern);
|
|
79
|
+
if (matches)
|
|
80
|
+
count += matches.length;
|
|
81
|
+
}
|
|
82
|
+
return Math.min(count, 20); // Cap at reasonable max
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Count code blocks in prompt
|
|
86
|
+
*/
|
|
87
|
+
function countCodeBlocks(prompt) {
|
|
88
|
+
const fencedBlocks = (prompt.match(/```[\s\S]*?```/g) || []).length;
|
|
89
|
+
const indentedBlocks = (prompt.match(/(?:^|\n)(?:\s{4}|\t)[^\n]+(?:\n(?:\s{4}|\t)[^\n]+)*/g) || []).length;
|
|
90
|
+
return fencedBlocks + Math.floor(indentedBlocks / 2);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if prompt contains any of the keywords
|
|
94
|
+
*/
|
|
95
|
+
function hasKeywords(prompt, keywords) {
|
|
96
|
+
return keywords.some(kw => prompt.includes(kw));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Detect question depth
|
|
100
|
+
* 'why' questions require deeper reasoning than 'what' or 'where'
|
|
101
|
+
*/
|
|
102
|
+
function detectQuestionDepth(prompt) {
|
|
103
|
+
if (/\bwhy\b.*\?|\bwhy\s+(is|are|does|do|did|would|should|can)/i.test(prompt)) {
|
|
104
|
+
return 'why';
|
|
105
|
+
}
|
|
106
|
+
if (/\bhow\b.*\?|\bhow\s+(do|does|can|should|would|to)/i.test(prompt)) {
|
|
107
|
+
return 'how';
|
|
108
|
+
}
|
|
109
|
+
if (/\bwhat\b.*\?|\bwhat\s+(is|are|does|do)/i.test(prompt)) {
|
|
110
|
+
return 'what';
|
|
111
|
+
}
|
|
112
|
+
if (/\bwhere\b.*\?|\bwhere\s+(is|are|does|do|can)/i.test(prompt)) {
|
|
113
|
+
return 'where';
|
|
114
|
+
}
|
|
115
|
+
return 'none';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Detect implicit requirements (vague statements without clear deliverables)
|
|
119
|
+
*/
|
|
120
|
+
function detectImplicitRequirements(prompt) {
|
|
121
|
+
const vaguePatterns = [
|
|
122
|
+
/\bmake it better\b/,
|
|
123
|
+
/\bimprove\b(?!.*(?:by|to|so that))/,
|
|
124
|
+
/\bfix\b(?!.*(?:the|this|that|in|at))/,
|
|
125
|
+
/\boptimize\b(?!.*(?:by|for|to))/,
|
|
126
|
+
/\bclean up\b/,
|
|
127
|
+
/\brefactor\b(?!.*(?:to|by|into))/,
|
|
128
|
+
];
|
|
129
|
+
return vaguePatterns.some(p => p.test(prompt));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Estimate number of subtasks
|
|
133
|
+
*/
|
|
134
|
+
function estimateSubtasks(prompt) {
|
|
135
|
+
let count = 1;
|
|
136
|
+
// Count explicit list items
|
|
137
|
+
const bulletPoints = (prompt.match(/^[\s]*[-*•]\s/gm) || []).length;
|
|
138
|
+
const numberedItems = (prompt.match(/^[\s]*\d+[.)]\s/gm) || []).length;
|
|
139
|
+
count += bulletPoints + numberedItems;
|
|
140
|
+
// Count 'and' conjunctions that might indicate multiple tasks
|
|
141
|
+
const andCount = (prompt.match(/\band\b/gi) || []).length;
|
|
142
|
+
count += Math.floor(andCount / 2);
|
|
143
|
+
// Count 'then' indicators
|
|
144
|
+
const thenCount = (prompt.match(/\bthen\b/gi) || []).length;
|
|
145
|
+
count += thenCount;
|
|
146
|
+
return Math.min(count, 10);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Detect if task involves changes across multiple files
|
|
150
|
+
*/
|
|
151
|
+
function detectCrossFileDependencies(prompt) {
|
|
152
|
+
const fileCount = countFilePaths(prompt);
|
|
153
|
+
if (fileCount >= 2)
|
|
154
|
+
return true;
|
|
155
|
+
const crossFileIndicators = [
|
|
156
|
+
/multiple files/i,
|
|
157
|
+
/across.*files/i,
|
|
158
|
+
/several.*files/i,
|
|
159
|
+
/all.*files/i,
|
|
160
|
+
/throughout.*codebase/i,
|
|
161
|
+
/entire.*project/i,
|
|
162
|
+
/whole.*system/i,
|
|
163
|
+
];
|
|
164
|
+
return crossFileIndicators.some(p => p.test(prompt));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Detect test requirements
|
|
168
|
+
*/
|
|
169
|
+
function detectTestRequirements(prompt) {
|
|
170
|
+
const testIndicators = [
|
|
171
|
+
/\btest/i,
|
|
172
|
+
/\bspec\b/i,
|
|
173
|
+
/make sure.*work/i,
|
|
174
|
+
/verify/i,
|
|
175
|
+
/ensure.*pass/i,
|
|
176
|
+
/\bTDD\b/,
|
|
177
|
+
/unit test/i,
|
|
178
|
+
/integration test/i,
|
|
179
|
+
];
|
|
180
|
+
return testIndicators.some(p => p.test(prompt));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Detect domain specificity
|
|
184
|
+
*/
|
|
185
|
+
function detectDomain(prompt) {
|
|
186
|
+
const domains = {
|
|
187
|
+
frontend: [
|
|
188
|
+
/\b(react|vue|angular|svelte|css|html|jsx|tsx|component|ui|ux|styling|tailwind|sass|scss)\b/i,
|
|
189
|
+
/\b(button|modal|form|input|layout|responsive|animation)\b/i,
|
|
190
|
+
],
|
|
191
|
+
backend: [
|
|
192
|
+
/\b(api|endpoint|database|query|sql|graphql|rest|server|auth|middleware)\b/i,
|
|
193
|
+
/\b(node|express|fastify|nest|django|flask|rails)\b/i,
|
|
194
|
+
],
|
|
195
|
+
infrastructure: [
|
|
196
|
+
/\b(docker|kubernetes|k8s|terraform|aws|gcp|azure|ci|cd|deploy|container)\b/i,
|
|
197
|
+
/\b(nginx|load.?balancer|scaling|monitoring|logging)\b/i,
|
|
198
|
+
],
|
|
199
|
+
security: [
|
|
200
|
+
/\b(security|auth|oauth|jwt|encryption|vulnerability|xss|csrf|injection)\b/i,
|
|
201
|
+
/\b(password|credential|secret|token|permission)\b/i,
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
for (const [domain, patterns] of Object.entries(domains)) {
|
|
205
|
+
if (patterns.some(p => p.test(prompt))) {
|
|
206
|
+
return domain;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return 'generic';
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Detect if external knowledge is required
|
|
213
|
+
*/
|
|
214
|
+
function detectExternalKnowledge(prompt) {
|
|
215
|
+
const externalIndicators = [
|
|
216
|
+
/\bdocs?\b/i,
|
|
217
|
+
/\bdocumentation\b/i,
|
|
218
|
+
/\bofficial\b/i,
|
|
219
|
+
/\blibrary\b/i,
|
|
220
|
+
/\bpackage\b/i,
|
|
221
|
+
/\bframework\b/i,
|
|
222
|
+
/\bhow does.*work\b/i,
|
|
223
|
+
/\bbest practice/i,
|
|
224
|
+
];
|
|
225
|
+
return externalIndicators.some(p => p.test(prompt));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Assess reversibility of changes
|
|
229
|
+
*/
|
|
230
|
+
function assessReversibility(prompt) {
|
|
231
|
+
const difficultIndicators = [
|
|
232
|
+
/\bmigrat/i,
|
|
233
|
+
/\bproduction\b/i,
|
|
234
|
+
/\bdata.*loss/i,
|
|
235
|
+
/\bdelete.*all/i,
|
|
236
|
+
/\bdrop.*table/i,
|
|
237
|
+
/\birreversible/i,
|
|
238
|
+
/\bpermanent/i,
|
|
239
|
+
];
|
|
240
|
+
const moderateIndicators = [
|
|
241
|
+
/\brefactor/i,
|
|
242
|
+
/\brestructure/i,
|
|
243
|
+
/\brename.*across/i,
|
|
244
|
+
/\bmove.*files/i,
|
|
245
|
+
/\bchange.*schema/i,
|
|
246
|
+
];
|
|
247
|
+
if (difficultIndicators.some(p => p.test(prompt)))
|
|
248
|
+
return 'difficult';
|
|
249
|
+
if (moderateIndicators.some(p => p.test(prompt)))
|
|
250
|
+
return 'moderate';
|
|
251
|
+
return 'easy';
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Assess impact scope of changes
|
|
255
|
+
*/
|
|
256
|
+
function assessImpactScope(prompt) {
|
|
257
|
+
const systemWideIndicators = [
|
|
258
|
+
/\bentire\b/i,
|
|
259
|
+
/\ball\s+(?:files|components|modules)/i,
|
|
260
|
+
/\bwhole\s+(?:project|codebase|system)/i,
|
|
261
|
+
/\bsystem.?wide/i,
|
|
262
|
+
/\bglobal/i,
|
|
263
|
+
/\beverywhere/i,
|
|
264
|
+
/\bthroughout/i,
|
|
265
|
+
];
|
|
266
|
+
const moduleIndicators = [
|
|
267
|
+
/\bmodule/i,
|
|
268
|
+
/\bpackage/i,
|
|
269
|
+
/\bservice/i,
|
|
270
|
+
/\bfeature/i,
|
|
271
|
+
/\bcomponent/i,
|
|
272
|
+
/\blayer/i,
|
|
273
|
+
];
|
|
274
|
+
if (systemWideIndicators.some(p => p.test(prompt)))
|
|
275
|
+
return 'system-wide';
|
|
276
|
+
// Check for multiple files (indicates module-level at least)
|
|
277
|
+
if (countFilePaths(prompt) >= 3)
|
|
278
|
+
return 'module';
|
|
279
|
+
if (moduleIndicators.some(p => p.test(prompt)))
|
|
280
|
+
return 'module';
|
|
281
|
+
return 'local';
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=signals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../../src/features/model-routing/signals.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,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