oh-my-claude-sisyphus 1.11.1 → 2.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/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 +1 -1
- package/dist/agents/definitions.d.ts.map +1 -1
- package/dist/agents/definitions.js +35 -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 -9
- 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 -1
- package/dist/tools/lsp/servers.js.map +1 -1
- package/package.json +18 -10
- package/scripts/install.sh +236 -260
- package/scripts/keyword-detector.mjs +209 -0
- package/scripts/persistent-mode.mjs +241 -0
- package/scripts/post-tool-verifier.mjs +217 -0
- package/scripts/pre-tool-enforcer.mjs +99 -0
- 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,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Router
|
|
3
|
+
*
|
|
4
|
+
* Main routing engine that determines which model tier to use for a given task.
|
|
5
|
+
* Combines signal extraction, scoring, and rules evaluation.
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_ROUTING_CONFIG, TIER_MODELS, TIER_TO_MODEL_TYPE, } from './types.js';
|
|
8
|
+
import { extractAllSignals } from './signals.js';
|
|
9
|
+
import { calculateComplexityScore, calculateConfidence, scoreToTier } from './scorer.js';
|
|
10
|
+
import { evaluateRules, DEFAULT_ROUTING_RULES } from './rules.js';
|
|
11
|
+
/**
|
|
12
|
+
* Route a task to the appropriate model tier
|
|
13
|
+
*/
|
|
14
|
+
export function routeTask(context, config = {}) {
|
|
15
|
+
const mergedConfig = { ...DEFAULT_ROUTING_CONFIG, ...config };
|
|
16
|
+
// If routing is disabled, use default tier
|
|
17
|
+
if (!mergedConfig.enabled) {
|
|
18
|
+
return createDecision(mergedConfig.defaultTier, ['Routing disabled, using default tier'], false);
|
|
19
|
+
}
|
|
20
|
+
// If explicit model is specified, respect it
|
|
21
|
+
if (context.explicitModel) {
|
|
22
|
+
const tier = modelTypeToTier(context.explicitModel);
|
|
23
|
+
return createDecision(tier, ['Explicit model specified by user'], false);
|
|
24
|
+
}
|
|
25
|
+
// Check for agent-specific overrides
|
|
26
|
+
if (context.agentType && mergedConfig.agentOverrides?.[context.agentType]) {
|
|
27
|
+
const override = mergedConfig.agentOverrides[context.agentType];
|
|
28
|
+
return createDecision(override.tier, [override.reason], false);
|
|
29
|
+
}
|
|
30
|
+
// Extract signals from the task
|
|
31
|
+
const signals = extractAllSignals(context.taskPrompt, context);
|
|
32
|
+
// Evaluate routing rules
|
|
33
|
+
const ruleResult = evaluateRules(context, signals, DEFAULT_ROUTING_RULES);
|
|
34
|
+
if (ruleResult.tier === 'EXPLICIT') {
|
|
35
|
+
// Explicit model was handled above, this shouldn't happen
|
|
36
|
+
return createDecision('MEDIUM', ['Unexpected EXPLICIT tier'], false);
|
|
37
|
+
}
|
|
38
|
+
// Calculate score for confidence and logging
|
|
39
|
+
const score = calculateComplexityScore(signals);
|
|
40
|
+
const scoreTier = scoreToTier(score);
|
|
41
|
+
const confidence = calculateConfidence(score, ruleResult.tier);
|
|
42
|
+
const reasons = [
|
|
43
|
+
ruleResult.reason,
|
|
44
|
+
`Rule: ${ruleResult.ruleName}`,
|
|
45
|
+
`Score: ${score} (${scoreTier} tier by score)`,
|
|
46
|
+
];
|
|
47
|
+
return {
|
|
48
|
+
model: mergedConfig.tierModels[ruleResult.tier],
|
|
49
|
+
modelType: TIER_TO_MODEL_TYPE[ruleResult.tier],
|
|
50
|
+
tier: ruleResult.tier,
|
|
51
|
+
confidence,
|
|
52
|
+
reasons,
|
|
53
|
+
escalated: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a routing decision for a given tier
|
|
58
|
+
*/
|
|
59
|
+
function createDecision(tier, reasons, escalated, originalTier) {
|
|
60
|
+
return {
|
|
61
|
+
model: TIER_MODELS[tier],
|
|
62
|
+
modelType: TIER_TO_MODEL_TYPE[tier],
|
|
63
|
+
tier,
|
|
64
|
+
confidence: escalated ? 0.9 : 0.7, // Higher confidence after escalation
|
|
65
|
+
reasons,
|
|
66
|
+
escalated,
|
|
67
|
+
originalTier,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Convert ModelType to ComplexityTier
|
|
72
|
+
*/
|
|
73
|
+
function modelTypeToTier(modelType) {
|
|
74
|
+
switch (modelType) {
|
|
75
|
+
case 'opus':
|
|
76
|
+
return 'HIGH';
|
|
77
|
+
case 'haiku':
|
|
78
|
+
return 'LOW';
|
|
79
|
+
case 'sonnet':
|
|
80
|
+
default:
|
|
81
|
+
return 'MEDIUM';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Escalate to a higher tier after failure
|
|
86
|
+
*/
|
|
87
|
+
export function escalateModel(currentTier) {
|
|
88
|
+
switch (currentTier) {
|
|
89
|
+
case 'LOW':
|
|
90
|
+
return 'MEDIUM';
|
|
91
|
+
case 'MEDIUM':
|
|
92
|
+
return 'HIGH';
|
|
93
|
+
case 'HIGH':
|
|
94
|
+
return 'HIGH'; // Already at max
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if we can escalate further
|
|
99
|
+
*/
|
|
100
|
+
export function canEscalate(currentTier) {
|
|
101
|
+
return currentTier !== 'HIGH';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get routing recommendation for orchestrator
|
|
105
|
+
*
|
|
106
|
+
* This is designed for PROACTIVE routing - the orchestrator (Opus) analyzes
|
|
107
|
+
* task complexity BEFORE delegation and chooses the appropriate model tier.
|
|
108
|
+
*
|
|
109
|
+
* NOT reactive escalation - the right model is chosen upfront.
|
|
110
|
+
*/
|
|
111
|
+
export function getRoutingRecommendation(context, config = {}) {
|
|
112
|
+
return routeTask(context, config);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Legacy: Route with escalation support
|
|
116
|
+
* @deprecated Use getRoutingRecommendation for proactive routing instead.
|
|
117
|
+
* The orchestrator should analyze complexity upfront, not escalate reactively.
|
|
118
|
+
*/
|
|
119
|
+
export function routeWithEscalation(context, config = {}) {
|
|
120
|
+
// Simply return the routing recommendation
|
|
121
|
+
// Reactive escalation is deprecated - orchestrator decides upfront
|
|
122
|
+
return routeTask(context, config);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get routing explanation for debugging/logging
|
|
126
|
+
*/
|
|
127
|
+
export function explainRouting(context, config = {}) {
|
|
128
|
+
const decision = routeTask(context, config);
|
|
129
|
+
const signals = extractAllSignals(context.taskPrompt, context);
|
|
130
|
+
const lines = [
|
|
131
|
+
'=== Model Routing Decision ===',
|
|
132
|
+
`Task: ${context.taskPrompt.substring(0, 100)}${context.taskPrompt.length > 100 ? '...' : ''}`,
|
|
133
|
+
`Agent: ${context.agentType ?? 'unspecified'}`,
|
|
134
|
+
'',
|
|
135
|
+
'--- Signals ---',
|
|
136
|
+
`Word count: ${signals.lexical.wordCount}`,
|
|
137
|
+
`File paths: ${signals.lexical.filePathCount}`,
|
|
138
|
+
`Architecture keywords: ${signals.lexical.hasArchitectureKeywords}`,
|
|
139
|
+
`Debugging keywords: ${signals.lexical.hasDebuggingKeywords}`,
|
|
140
|
+
`Simple keywords: ${signals.lexical.hasSimpleKeywords}`,
|
|
141
|
+
`Risk keywords: ${signals.lexical.hasRiskKeywords}`,
|
|
142
|
+
`Question depth: ${signals.lexical.questionDepth}`,
|
|
143
|
+
`Estimated subtasks: ${signals.structural.estimatedSubtasks}`,
|
|
144
|
+
`Cross-file: ${signals.structural.crossFileDependencies}`,
|
|
145
|
+
`Impact scope: ${signals.structural.impactScope}`,
|
|
146
|
+
`Reversibility: ${signals.structural.reversibility}`,
|
|
147
|
+
`Previous failures: ${signals.context.previousFailures}`,
|
|
148
|
+
'',
|
|
149
|
+
'--- Decision ---',
|
|
150
|
+
`Tier: ${decision.tier}`,
|
|
151
|
+
`Model: ${decision.model}`,
|
|
152
|
+
`Confidence: ${decision.confidence}`,
|
|
153
|
+
`Escalated: ${decision.escalated}`,
|
|
154
|
+
'',
|
|
155
|
+
'--- Reasons ---',
|
|
156
|
+
...decision.reasons.map(r => ` - ${r}`),
|
|
157
|
+
];
|
|
158
|
+
return lines.join('\n');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Quick tier lookup for known agent types
|
|
162
|
+
* Useful for cases where we don't need full signal analysis
|
|
163
|
+
*/
|
|
164
|
+
export function quickTierForAgent(agentType) {
|
|
165
|
+
const agentTiers = {
|
|
166
|
+
oracle: 'HIGH',
|
|
167
|
+
prometheus: 'HIGH',
|
|
168
|
+
momus: 'HIGH',
|
|
169
|
+
metis: 'HIGH',
|
|
170
|
+
explore: 'LOW',
|
|
171
|
+
'document-writer': 'LOW',
|
|
172
|
+
librarian: 'MEDIUM',
|
|
173
|
+
'sisyphus-junior': 'MEDIUM',
|
|
174
|
+
'frontend-engineer': 'MEDIUM',
|
|
175
|
+
'multimodal-looker': 'MEDIUM',
|
|
176
|
+
// DEPRECATED: orchestrator-sisyphus merged into default mode (v2.0)
|
|
177
|
+
// Kept for backward compatibility if users still have it installed
|
|
178
|
+
'orchestrator-sisyphus': 'MEDIUM',
|
|
179
|
+
};
|
|
180
|
+
return agentTiers[agentType] ?? null;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Check if an agent has a fixed tier (cannot be overridden)
|
|
184
|
+
*
|
|
185
|
+
* Only ORCHESTRATOR agents are fixed to Opus - they need to analyze
|
|
186
|
+
* complexity and delegate. All other agents are adaptive.
|
|
187
|
+
*
|
|
188
|
+
* NOTE: orchestrator-sisyphus was deprecated in v2.0 (merged into default mode)
|
|
189
|
+
* but kept here for backward compatibility if users still have it installed.
|
|
190
|
+
*/
|
|
191
|
+
export function isFixedTierAgent(agentType) {
|
|
192
|
+
// Only orchestrators are fixed - they need Opus to analyze and delegate
|
|
193
|
+
// DEPRECATED: orchestrator-sisyphus merged into default mode (v2.0)
|
|
194
|
+
const fixedAgents = ['orchestrator-sisyphus'];
|
|
195
|
+
return fixedAgents.includes(agentType);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get recommended model for an agent based on task complexity
|
|
199
|
+
*
|
|
200
|
+
* This is the main entry point for orchestrator model routing.
|
|
201
|
+
* The orchestrator calls this to determine which model to use when delegating.
|
|
202
|
+
*
|
|
203
|
+
* ALL agents are adaptive EXCEPT orchestrators (which need Opus to analyze and delegate).
|
|
204
|
+
*
|
|
205
|
+
* Routing hierarchy:
|
|
206
|
+
* 1. Fixed-tier (orchestrators only) → always Opus (they analyze complexity)
|
|
207
|
+
* 2. All other agents → adaptive based on task complexity
|
|
208
|
+
*
|
|
209
|
+
* @param agentType - The agent to delegate to
|
|
210
|
+
* @param taskPrompt - The task description
|
|
211
|
+
* @returns The recommended model type ('haiku', 'sonnet', or 'opus')
|
|
212
|
+
*/
|
|
213
|
+
export function getModelForTask(agentType, taskPrompt, config = {}) {
|
|
214
|
+
// Fixed-tier agents (orchestrators only) always use Opus
|
|
215
|
+
// They need to analyze complexity and delegate - can't use a simpler model
|
|
216
|
+
if (isFixedTierAgent(agentType)) {
|
|
217
|
+
return {
|
|
218
|
+
model: 'opus',
|
|
219
|
+
tier: 'HIGH',
|
|
220
|
+
reason: `${agentType} is an orchestrator (always Opus - analyzes and delegates)`,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
// All other agents are adaptive based on task complexity
|
|
224
|
+
// Use agent-specific rules for advisory agents, general rules for others
|
|
225
|
+
const decision = routeTask({ taskPrompt, agentType }, config);
|
|
226
|
+
return {
|
|
227
|
+
model: decision.modelType,
|
|
228
|
+
tier: decision.tier,
|
|
229
|
+
reason: decision.reasons[0] ?? 'Complexity analysis',
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Generate a complexity analysis summary for the orchestrator
|
|
234
|
+
*
|
|
235
|
+
* Returns a human-readable analysis explaining the routing recommendation.
|
|
236
|
+
*/
|
|
237
|
+
export function analyzeTaskComplexity(taskPrompt, agentType) {
|
|
238
|
+
const signals = extractAllSignals(taskPrompt, { taskPrompt, agentType });
|
|
239
|
+
const decision = routeTask({ taskPrompt, agentType });
|
|
240
|
+
const analysis = [
|
|
241
|
+
`**Tier: ${decision.tier}** → ${decision.model}`,
|
|
242
|
+
'',
|
|
243
|
+
'**Why:**',
|
|
244
|
+
...decision.reasons.map(r => `- ${r}`),
|
|
245
|
+
'',
|
|
246
|
+
'**Signals detected:**',
|
|
247
|
+
signals.lexical.hasArchitectureKeywords ? '- Architecture keywords (refactor, redesign, etc.)' : null,
|
|
248
|
+
signals.lexical.hasRiskKeywords ? '- Risk keywords (migration, production, critical)' : null,
|
|
249
|
+
signals.lexical.hasDebuggingKeywords ? '- Debugging keywords (root cause, investigate)' : null,
|
|
250
|
+
signals.structural.crossFileDependencies ? '- Cross-file dependencies' : null,
|
|
251
|
+
signals.structural.impactScope === 'system-wide' ? '- System-wide impact' : null,
|
|
252
|
+
signals.structural.reversibility === 'difficult' ? '- Difficult to reverse' : null,
|
|
253
|
+
].filter(Boolean).join('\n');
|
|
254
|
+
return {
|
|
255
|
+
tier: decision.tier,
|
|
256
|
+
model: decision.model,
|
|
257
|
+
analysis,
|
|
258
|
+
signals: {
|
|
259
|
+
wordCount: signals.lexical.wordCount,
|
|
260
|
+
hasArchitectureKeywords: signals.lexical.hasArchitectureKeywords,
|
|
261
|
+
hasRiskKeywords: signals.lexical.hasRiskKeywords,
|
|
262
|
+
estimatedSubtasks: signals.structural.estimatedSubtasks,
|
|
263
|
+
impactScope: signals.structural.impactScope,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/features/model-routing/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAElE;;GAEG;A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rules are evaluated in priority order, and the first matching rule wins.
|
|
6
|
+
*/
|
|
7
|
+
import type { RoutingRule, RoutingContext, ComplexitySignals, ComplexityTier } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Default routing rules, ordered by priority (highest first)
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_ROUTING_RULES: RoutingRule[];
|
|
12
|
+
/**
|
|
13
|
+
* Evaluate routing rules and return the first matching rule's action
|
|
14
|
+
*/
|
|
15
|
+
export declare function evaluateRules(context: RoutingContext, signals: ComplexitySignals, rules?: RoutingRule[]): {
|
|
16
|
+
tier: ComplexityTier | 'EXPLICIT';
|
|
17
|
+
reason: string;
|
|
18
|
+
ruleName: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get all rules that would match for a given context (for debugging)
|
|
22
|
+
*/
|
|
23
|
+
export declare function getMatchingRules(context: RoutingContext, signals: ComplexitySignals, rules?: RoutingRule[]): RoutingRule[];
|
|
24
|
+
/**
|
|
25
|
+
* Create a custom routing rule
|
|
26
|
+
*/
|
|
27
|
+
export declare function createRule(name: string, condition: (context: RoutingContext, signals: ComplexitySignals) => boolean, tier: ComplexityTier, reason: string, priority: number): RoutingRule;
|
|
28
|
+
/**
|
|
29
|
+
* Merge custom rules with default rules
|
|
30
|
+
*/
|
|
31
|
+
export declare function mergeRules(customRules: RoutingRule[]): RoutingRule[];
|
|
32
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/features/model-routing/rules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAAW,EA+M9C,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,GAAE,WAAW,EAA0B,GAC3C;IAAE,IAAI,EAAE,cAAc,GAAG,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAoBzE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,GAAE,WAAW,EAA0B,GAC3C,WAAW,EAAE,CAEf;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,EAC3E,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,WAAW,CAOb;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAOpE"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing Rules
|
|
3
|
+
*
|
|
4
|
+
* Defines the rules engine for model routing decisions.
|
|
5
|
+
* Rules are evaluated in priority order, and the first matching rule wins.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default routing rules, ordered by priority (highest first)
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_ROUTING_RULES = [
|
|
11
|
+
// ============ Override Rules (Highest Priority) ============
|
|
12
|
+
{
|
|
13
|
+
name: 'explicit-model-specified',
|
|
14
|
+
condition: (ctx) => ctx.explicitModel !== undefined,
|
|
15
|
+
action: { tier: 'EXPLICIT', reason: 'User specified model explicitly' },
|
|
16
|
+
priority: 100,
|
|
17
|
+
},
|
|
18
|
+
// NOTE: ALL agents are now ADAPTIVE based on task complexity
|
|
19
|
+
// Only orchestrators (orchestrator-sisyphus) are fixed to Opus
|
|
20
|
+
// This includes: oracle, prometheus, momus, metis, explore, document-writer, etc.
|
|
21
|
+
// ============ Orchestrator Rule (Fixed Tier) ============
|
|
22
|
+
{
|
|
23
|
+
name: 'orchestrator-fixed-opus',
|
|
24
|
+
condition: (ctx) => ctx.agentType === 'orchestrator-sisyphus',
|
|
25
|
+
action: { tier: 'HIGH', reason: 'Orchestrator requires Opus to analyze complexity and delegate' },
|
|
26
|
+
priority: 90,
|
|
27
|
+
},
|
|
28
|
+
// ============ Advisory Agent Adaptive Rules ============
|
|
29
|
+
// Oracle: Simple lookups → LOW, tracing → MEDIUM, debugging/architecture → HIGH
|
|
30
|
+
// Higher priority (85) to override generic rules like short-local-change
|
|
31
|
+
{
|
|
32
|
+
name: 'oracle-complex-debugging',
|
|
33
|
+
condition: (ctx, signals) => ctx.agentType === 'oracle' &&
|
|
34
|
+
(signals.lexical.hasDebuggingKeywords ||
|
|
35
|
+
signals.lexical.hasArchitectureKeywords ||
|
|
36
|
+
signals.lexical.hasRiskKeywords),
|
|
37
|
+
action: { tier: 'HIGH', reason: 'Oracle: Complex debugging/architecture decision' },
|
|
38
|
+
priority: 85,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'oracle-simple-lookup',
|
|
42
|
+
condition: (ctx, signals) => ctx.agentType === 'oracle' &&
|
|
43
|
+
signals.lexical.hasSimpleKeywords &&
|
|
44
|
+
!signals.lexical.hasDebuggingKeywords &&
|
|
45
|
+
!signals.lexical.hasArchitectureKeywords &&
|
|
46
|
+
!signals.lexical.hasRiskKeywords,
|
|
47
|
+
action: { tier: 'LOW', reason: 'Oracle: Simple lookup query' },
|
|
48
|
+
priority: 80,
|
|
49
|
+
},
|
|
50
|
+
// Prometheus: Simple breakdown → LOW, moderate planning → MEDIUM, cross-domain → HIGH
|
|
51
|
+
{
|
|
52
|
+
name: 'prometheus-simple-breakdown',
|
|
53
|
+
condition: (ctx, signals) => ctx.agentType === 'prometheus' &&
|
|
54
|
+
signals.structural.estimatedSubtasks <= 3 &&
|
|
55
|
+
!signals.lexical.hasRiskKeywords &&
|
|
56
|
+
signals.structural.impactScope === 'local',
|
|
57
|
+
action: { tier: 'LOW', reason: 'Prometheus: Simple task breakdown' },
|
|
58
|
+
priority: 75,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'prometheus-strategic-planning',
|
|
62
|
+
condition: (ctx, signals) => ctx.agentType === 'prometheus' &&
|
|
63
|
+
(signals.structural.impactScope === 'system-wide' ||
|
|
64
|
+
signals.lexical.hasArchitectureKeywords ||
|
|
65
|
+
signals.structural.estimatedSubtasks > 10),
|
|
66
|
+
action: { tier: 'HIGH', reason: 'Prometheus: Cross-domain strategic planning' },
|
|
67
|
+
priority: 75,
|
|
68
|
+
},
|
|
69
|
+
// Momus: Checklist → LOW, gap analysis → MEDIUM, adversarial review → HIGH
|
|
70
|
+
{
|
|
71
|
+
name: 'momus-checklist-review',
|
|
72
|
+
condition: (ctx, signals) => ctx.agentType === 'momus' &&
|
|
73
|
+
signals.lexical.wordCount < 30 &&
|
|
74
|
+
!signals.lexical.hasRiskKeywords,
|
|
75
|
+
action: { tier: 'LOW', reason: 'Momus: Checklist verification' },
|
|
76
|
+
priority: 75,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'momus-adversarial-review',
|
|
80
|
+
condition: (ctx, signals) => ctx.agentType === 'momus' &&
|
|
81
|
+
(signals.lexical.hasRiskKeywords || signals.structural.impactScope === 'system-wide'),
|
|
82
|
+
action: { tier: 'HIGH', reason: 'Momus: Adversarial review for critical system' },
|
|
83
|
+
priority: 75,
|
|
84
|
+
},
|
|
85
|
+
// Metis: Simple impact → LOW, dependency mapping → MEDIUM, risk analysis → HIGH
|
|
86
|
+
{
|
|
87
|
+
name: 'metis-simple-impact',
|
|
88
|
+
condition: (ctx, signals) => ctx.agentType === 'metis' &&
|
|
89
|
+
signals.structural.impactScope === 'local' &&
|
|
90
|
+
!signals.lexical.hasRiskKeywords,
|
|
91
|
+
action: { tier: 'LOW', reason: 'Metis: Simple impact analysis' },
|
|
92
|
+
priority: 75,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'metis-risk-analysis',
|
|
96
|
+
condition: (ctx, signals) => ctx.agentType === 'metis' &&
|
|
97
|
+
(signals.lexical.hasRiskKeywords || signals.structural.impactScope === 'system-wide'),
|
|
98
|
+
action: { tier: 'HIGH', reason: 'Metis: Risk analysis and unknown-unknowns detection' },
|
|
99
|
+
priority: 75,
|
|
100
|
+
},
|
|
101
|
+
// ============ Task-Based Rules ============
|
|
102
|
+
{
|
|
103
|
+
name: 'architecture-system-wide',
|
|
104
|
+
condition: (ctx, signals) => signals.lexical.hasArchitectureKeywords &&
|
|
105
|
+
signals.structural.impactScope === 'system-wide',
|
|
106
|
+
action: { tier: 'HIGH', reason: 'Architectural decisions with system-wide impact' },
|
|
107
|
+
priority: 70,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'security-domain',
|
|
111
|
+
condition: (ctx, signals) => signals.structural.domainSpecificity === 'security',
|
|
112
|
+
action: { tier: 'HIGH', reason: 'Security-related tasks require careful reasoning' },
|
|
113
|
+
priority: 70,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'difficult-reversibility-risk',
|
|
117
|
+
condition: (ctx, signals) => signals.structural.reversibility === 'difficult' &&
|
|
118
|
+
signals.lexical.hasRiskKeywords,
|
|
119
|
+
action: { tier: 'HIGH', reason: 'High-risk, difficult-to-reverse changes' },
|
|
120
|
+
priority: 70,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'deep-debugging',
|
|
124
|
+
condition: (ctx, signals) => signals.lexical.hasDebuggingKeywords &&
|
|
125
|
+
signals.lexical.questionDepth === 'why',
|
|
126
|
+
action: { tier: 'HIGH', reason: 'Root cause analysis requires deep reasoning' },
|
|
127
|
+
priority: 65,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'complex-multi-step',
|
|
131
|
+
condition: (ctx, signals) => signals.structural.estimatedSubtasks > 5 &&
|
|
132
|
+
signals.structural.crossFileDependencies,
|
|
133
|
+
action: { tier: 'HIGH', reason: 'Complex multi-step task with cross-file changes' },
|
|
134
|
+
priority: 60,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'simple-search-query',
|
|
138
|
+
condition: (ctx, signals) => signals.lexical.hasSimpleKeywords &&
|
|
139
|
+
signals.structural.estimatedSubtasks <= 1 &&
|
|
140
|
+
signals.structural.impactScope === 'local' &&
|
|
141
|
+
!signals.lexical.hasArchitectureKeywords &&
|
|
142
|
+
!signals.lexical.hasDebuggingKeywords,
|
|
143
|
+
action: { tier: 'LOW', reason: 'Simple search or lookup task' },
|
|
144
|
+
priority: 60,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'short-local-change',
|
|
148
|
+
condition: (ctx, signals) => signals.lexical.wordCount < 50 &&
|
|
149
|
+
signals.structural.impactScope === 'local' &&
|
|
150
|
+
signals.structural.reversibility === 'easy' &&
|
|
151
|
+
!signals.lexical.hasRiskKeywords,
|
|
152
|
+
action: { tier: 'LOW', reason: 'Short, local, easily reversible change' },
|
|
153
|
+
priority: 55,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'moderate-complexity',
|
|
157
|
+
condition: (ctx, signals) => signals.structural.estimatedSubtasks > 1 &&
|
|
158
|
+
signals.structural.estimatedSubtasks <= 5,
|
|
159
|
+
action: { tier: 'MEDIUM', reason: 'Moderate complexity with multiple subtasks' },
|
|
160
|
+
priority: 50,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'module-level-work',
|
|
164
|
+
condition: (ctx, signals) => signals.structural.impactScope === 'module',
|
|
165
|
+
action: { tier: 'MEDIUM', reason: 'Module-level changes' },
|
|
166
|
+
priority: 45,
|
|
167
|
+
},
|
|
168
|
+
// ============ Default Rule ============
|
|
169
|
+
{
|
|
170
|
+
name: 'default-medium',
|
|
171
|
+
condition: () => true,
|
|
172
|
+
action: { tier: 'MEDIUM', reason: 'Default tier for unclassified tasks' },
|
|
173
|
+
priority: 0,
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
/**
|
|
177
|
+
* Evaluate routing rules and return the first matching rule's action
|
|
178
|
+
*/
|
|
179
|
+
export function evaluateRules(context, signals, rules = DEFAULT_ROUTING_RULES) {
|
|
180
|
+
// Sort rules by priority (highest first)
|
|
181
|
+
const sortedRules = [...rules].sort((a, b) => b.priority - a.priority);
|
|
182
|
+
for (const rule of sortedRules) {
|
|
183
|
+
if (rule.condition(context, signals)) {
|
|
184
|
+
return {
|
|
185
|
+
tier: rule.action.tier,
|
|
186
|
+
reason: rule.action.reason,
|
|
187
|
+
ruleName: rule.name,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Should never reach here due to default rule, but just in case
|
|
192
|
+
return {
|
|
193
|
+
tier: 'MEDIUM',
|
|
194
|
+
reason: 'Fallback to medium tier',
|
|
195
|
+
ruleName: 'fallback',
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get all rules that would match for a given context (for debugging)
|
|
200
|
+
*/
|
|
201
|
+
export function getMatchingRules(context, signals, rules = DEFAULT_ROUTING_RULES) {
|
|
202
|
+
return rules.filter(rule => rule.condition(context, signals));
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Create a custom routing rule
|
|
206
|
+
*/
|
|
207
|
+
export function createRule(name, condition, tier, reason, priority) {
|
|
208
|
+
return {
|
|
209
|
+
name,
|
|
210
|
+
condition,
|
|
211
|
+
action: { tier, reason },
|
|
212
|
+
priority,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Merge custom rules with default rules
|
|
217
|
+
*/
|
|
218
|
+
export function mergeRules(customRules) {
|
|
219
|
+
// Custom rules override defaults with the same name
|
|
220
|
+
const customNames = new Set(customRules.map(r => r.name));
|
|
221
|
+
const filteredDefaults = DEFAULT_ROUTING_RULES.filter(r => !customNames.has(r.name));
|
|
222
|
+
return [...customRules, ...filteredDefaults];
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/features/model-routing/rules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAkB;IAClD,8DAA8D;IAE9D;QACE,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS;QACnD,MAAM,EAAE,EAAE,IAAI,EAAE,UAAiB,EAAE,MAAM,EAAE,iCAAiC,EAAE;QAC9E,QAAQ,EAAE,GAAG;KACd;IAED,6DAA6D;IAC7D,+DAA+D;IAC/D,kFAAkF;IAElF,2DAA2D;IAE3D;QACE,IAAI,EAAE,yBAAyB;QAC/B,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,uBAAuB;QAC7D,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,+DAA+D,EAAE;QACjG,QAAQ,EAAE,EAAE;KACb;IAED,0DAA0D;IAE1D,gFAAgF;IAChF,yEAAyE;IACzE;QACE,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAC1B,GAAG,CAAC,SAAS,KAAK,QAAQ;YAC1B,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB;gBACpC,OAAO,CAAC,OAAO,CAAC,uBAAuB;gBACvC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC;QACnC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iDAAiD,EAAE;QACnF,QAAQ,EAAE,EAAE;KACb;IAED;QACE,IA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AAqB;IAE5C,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,SAA2E,EAC3E,IAAoB,EACpB,MAAc,EACd,QAAgB;IAEhB,OAAO;QACL,IAAI;QACJ,SAAS;QACT,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACxB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,WAA0B;IACnD,oDAAoD;IACpD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,MAAM,CACnD,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAC9B,CAAC;IACF,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,gBAAgB,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import type { ComplexitySignals, ComplexityTier } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Calculate total complexity score
|
|
10
|
+
*/
|
|
11
|
+
export declare function calculateComplexityScore(signals: ComplexitySignals): number;
|
|
12
|
+
/**
|
|
13
|
+
* Determine complexity tier from score
|
|
14
|
+
*/
|
|
15
|
+
export declare function scoreToTier(score: number): ComplexityTier;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate complexity tier from signals
|
|
18
|
+
*/
|
|
19
|
+
export declare function calculateComplexityTier(signals: ComplexitySignals): ComplexityTier;
|
|
20
|
+
/**
|
|
21
|
+
* Get detailed score breakdown for debugging/logging
|
|
22
|
+
*/
|
|
23
|
+
export declare function getScoreBreakdown(signals: ComplexitySignals): {
|
|
24
|
+
lexical: number;
|
|
25
|
+
structural: number;
|
|
26
|
+
context: number;
|
|
27
|
+
total: number;
|
|
28
|
+
tier: ComplexityTier;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Calculate confidence in the tier assignment
|
|
32
|
+
* Higher confidence when score is far from thresholds
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateConfidence(score: number, tier: ComplexityTier): number;
|
|
35
|
+
//# sourceMappingURL=scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorer.d.ts","sourceRoot":"","sources":["../../../src/features/model-routing/scorer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAIf,MAAM,YAAY,CAAC;AAmMpB;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAM3E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAIzD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CAGlF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;CACtB,CAaA;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAsB/E"}
|