@claude-flow/cli 3.0.0-alpha.105 → 3.0.0-alpha.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/statusline.cjs +49 -1
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +27 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts +3 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +126 -0
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +1 -0
- package/dist/src/ruvector/index.d.ts.map +1 -1
- package/dist/src/ruvector/index.js +1 -0
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +488 -0
- package/dist/src/ruvector/model-router.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -51,7 +51,7 @@ const c = {
|
|
|
51
51
|
function getUserInfo() {
|
|
52
52
|
let name = 'user';
|
|
53
53
|
let gitBranch = '';
|
|
54
|
-
let modelName = '
|
|
54
|
+
let modelName = 'Unknown';
|
|
55
55
|
|
|
56
56
|
try {
|
|
57
57
|
name = execSync('git config user.name 2>/dev/null || echo "user"', { encoding: 'utf-8' }).trim();
|
|
@@ -60,6 +60,54 @@ function getUserInfo() {
|
|
|
60
60
|
// Ignore errors
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
// Auto-detect model from Claude Code's config
|
|
64
|
+
try {
|
|
65
|
+
const homedir = require('os').homedir();
|
|
66
|
+
const claudeConfigPath = path.join(homedir, '.claude.json');
|
|
67
|
+
if (fs.existsSync(claudeConfigPath)) {
|
|
68
|
+
const claudeConfig = JSON.parse(fs.readFileSync(claudeConfigPath, 'utf-8'));
|
|
69
|
+
// Try to find lastModelUsage - check current dir and parent dirs
|
|
70
|
+
let lastModelUsage = null;
|
|
71
|
+
const cwd = process.cwd();
|
|
72
|
+
if (claudeConfig.projects) {
|
|
73
|
+
// Try exact match first, then check if cwd starts with any project path
|
|
74
|
+
for (const [projectPath, projectConfig] of Object.entries(claudeConfig.projects)) {
|
|
75
|
+
if (cwd === projectPath || cwd.startsWith(projectPath + '/')) {
|
|
76
|
+
lastModelUsage = projectConfig.lastModelUsage;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (lastModelUsage) {
|
|
82
|
+
const modelIds = Object.keys(lastModelUsage);
|
|
83
|
+
if (modelIds.length > 0) {
|
|
84
|
+
// Take the last model (most recently added to the object)
|
|
85
|
+
// Or find the one with most tokens (most actively used this session)
|
|
86
|
+
let modelId = modelIds[modelIds.length - 1];
|
|
87
|
+
if (modelIds.length > 1) {
|
|
88
|
+
// If multiple models, pick the one with most total tokens
|
|
89
|
+
let maxTokens = 0;
|
|
90
|
+
for (const id of modelIds) {
|
|
91
|
+
const usage = lastModelUsage[id];
|
|
92
|
+
const total = (usage.inputTokens || 0) + (usage.outputTokens || 0);
|
|
93
|
+
if (total > maxTokens) {
|
|
94
|
+
maxTokens = total;
|
|
95
|
+
modelId = id;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Parse model ID to human-readable name
|
|
100
|
+
if (modelId.includes('opus')) modelName = 'Opus 4.5';
|
|
101
|
+
else if (modelId.includes('sonnet')) modelName = 'Sonnet 4';
|
|
102
|
+
else if (modelId.includes('haiku')) modelName = 'Haiku 4.5';
|
|
103
|
+
else modelName = modelId.split('-').slice(1, 3).join(' ');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch (e) {
|
|
108
|
+
// Fallback to Unknown if can't read config
|
|
109
|
+
}
|
|
110
|
+
|
|
63
111
|
return { name, gitBranch, modelName };
|
|
64
112
|
}
|
|
65
113
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusline-generator.d.ts","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"statusline-generator.d.ts","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAqXrE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA2BnE"}
|
|
@@ -82,12 +82,36 @@ function getUserInfo() {
|
|
|
82
82
|
const claudeConfigPath = path.join(homedir, '.claude.json');
|
|
83
83
|
if (fs.existsSync(claudeConfigPath)) {
|
|
84
84
|
const claudeConfig = JSON.parse(fs.readFileSync(claudeConfigPath, 'utf-8'));
|
|
85
|
-
//
|
|
86
|
-
|
|
85
|
+
// Try to find lastModelUsage - check current dir and parent dirs
|
|
86
|
+
let lastModelUsage = null;
|
|
87
|
+
const cwd = process.cwd();
|
|
88
|
+
if (claudeConfig.projects) {
|
|
89
|
+
// Try exact match first, then check if cwd starts with any project path
|
|
90
|
+
for (const [projectPath, projectConfig] of Object.entries(claudeConfig.projects)) {
|
|
91
|
+
if (cwd === projectPath || cwd.startsWith(projectPath + '/')) {
|
|
92
|
+
lastModelUsage = projectConfig.lastModelUsage;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
87
97
|
if (lastModelUsage) {
|
|
88
98
|
const modelIds = Object.keys(lastModelUsage);
|
|
89
99
|
if (modelIds.length > 0) {
|
|
90
|
-
|
|
100
|
+
// Take the last model (most recently added to the object)
|
|
101
|
+
// Or find the one with most tokens (most actively used this session)
|
|
102
|
+
let modelId = modelIds[modelIds.length - 1];
|
|
103
|
+
if (modelIds.length > 1) {
|
|
104
|
+
// If multiple models, pick the one with most total tokens
|
|
105
|
+
let maxTokens = 0;
|
|
106
|
+
for (const id of modelIds) {
|
|
107
|
+
const usage = lastModelUsage[id];
|
|
108
|
+
const total = (usage.inputTokens || 0) + (usage.outputTokens || 0);
|
|
109
|
+
if (total > maxTokens) {
|
|
110
|
+
maxTokens = total;
|
|
111
|
+
modelId = id;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
91
115
|
// Parse model ID to human-readable name
|
|
92
116
|
if (modelId.includes('opus')) modelName = 'Opus 4.5';
|
|
93
117
|
else if (modelId.includes('sonnet')) modelName = 'Sonnet 4';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusline-generator.js","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAElC,oFAAoF;IACpF,OAAO;;;;;;;;;;;;;;;;;;aAkBI,MAAM,CAAC,OAAO;kBACT,MAAM,CAAC,YAAY;kBACnB,MAAM,CAAC,YAAY;eACtB,MAAM,CAAC,SAAS;eAChB,MAAM,CAAC,SAAS;qBACV,MAAM,CAAC,eAAe;qBACtB,MAAM,CAAC,eAAe;eAC5B,OAAO,CAAC,OAAO,CAAC,SAAS;eACzB,OAAO,CAAC,OAAO,CAAC,QAAQ
|
|
1
|
+
{"version":3,"file":"statusline-generator.js","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAElC,oFAAoF;IACpF,OAAO;;;;;;;;;;;;;;;;;;aAkBI,MAAM,CAAC,OAAO;kBACT,MAAM,CAAC,YAAY;kBACnB,MAAM,CAAC,YAAY;eACtB,MAAM,CAAC,SAAS;eAChB,MAAM,CAAC,SAAS;qBACV,MAAM,CAAC,eAAe;qBACtB,MAAM,CAAC,eAAe;eAC5B,OAAO,CAAC,OAAO,CAAC,SAAS;eACzB,OAAO,CAAC,OAAO,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsVtC,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAChC,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,OAAO;;;;;;;;;;;;;;;;;;;;;CAqBR,CAAC;AACF,CAAC"}
|
|
@@ -35,6 +35,9 @@ export declare const hooksWorkerList: MCPTool;
|
|
|
35
35
|
export declare const hooksWorkerDispatch: MCPTool;
|
|
36
36
|
export declare const hooksWorkerStatus: MCPTool;
|
|
37
37
|
export declare const hooksWorkerDetect: MCPTool;
|
|
38
|
+
export declare const hooksModelRoute: MCPTool;
|
|
39
|
+
export declare const hooksModelOutcome: MCPTool;
|
|
40
|
+
export declare const hooksModelStats: MCPTool;
|
|
38
41
|
export declare const hooksWorkerCancel: MCPTool;
|
|
39
42
|
export declare const hooksTools: MCPTool[];
|
|
40
43
|
export default hooksTools;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/hooks-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA6X1C,eAAO,MAAM,YAAY,EAAE,OAsC1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OAwB3B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,OAkC7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,OAuB9B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,OA+CxB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OAyC1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,OA8CvB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OA4C1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OA+B3B,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,OAsD1B,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,OAsC3B,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,OAoE9B,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,OAyE3B,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,OAsD/B,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,OAgD7B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,OAuCjC,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,OA4BzB,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,OAsCvB,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,OAsG/B,CAAC;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BF,eAAO,MAAM,iBAAiB,EAAE,OAuC/B,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,OAAO,EAwC/B,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -2303,6 +2303,128 @@ export const hooksWorkerDetect = {
|
|
|
2303
2303
|
return result;
|
|
2304
2304
|
},
|
|
2305
2305
|
};
|
|
2306
|
+
// Model router - lazy loaded
|
|
2307
|
+
let modelRouterInstance = null;
|
|
2308
|
+
async function getModelRouterInstance() {
|
|
2309
|
+
if (!modelRouterInstance) {
|
|
2310
|
+
try {
|
|
2311
|
+
const { getModelRouter } = await import('../ruvector/model-router.js');
|
|
2312
|
+
modelRouterInstance = getModelRouter();
|
|
2313
|
+
}
|
|
2314
|
+
catch {
|
|
2315
|
+
modelRouterInstance = null;
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
return modelRouterInstance;
|
|
2319
|
+
}
|
|
2320
|
+
// Model route tool - intelligent model selection
|
|
2321
|
+
export const hooksModelRoute = {
|
|
2322
|
+
name: 'hooks/model-route',
|
|
2323
|
+
description: 'Route task to optimal Claude model (haiku/sonnet/opus) based on complexity',
|
|
2324
|
+
inputSchema: {
|
|
2325
|
+
type: 'object',
|
|
2326
|
+
properties: {
|
|
2327
|
+
task: { type: 'string', description: 'Task description to analyze' },
|
|
2328
|
+
preferSpeed: { type: 'boolean', description: 'Prefer faster models when possible' },
|
|
2329
|
+
preferCost: { type: 'boolean', description: 'Prefer cheaper models when possible' },
|
|
2330
|
+
},
|
|
2331
|
+
required: ['task'],
|
|
2332
|
+
},
|
|
2333
|
+
handler: async (params) => {
|
|
2334
|
+
const task = params.task;
|
|
2335
|
+
const router = await getModelRouterInstance();
|
|
2336
|
+
if (!router) {
|
|
2337
|
+
// Fallback to simple heuristic
|
|
2338
|
+
const complexity = analyzeComplexityFallback(task);
|
|
2339
|
+
return {
|
|
2340
|
+
model: complexity > 0.7 ? 'opus' : complexity > 0.4 ? 'sonnet' : 'haiku',
|
|
2341
|
+
confidence: 0.7,
|
|
2342
|
+
complexity,
|
|
2343
|
+
reasoning: 'Fallback heuristic (model router not available)',
|
|
2344
|
+
implementation: 'fallback',
|
|
2345
|
+
};
|
|
2346
|
+
}
|
|
2347
|
+
const result = await router.route(task);
|
|
2348
|
+
return {
|
|
2349
|
+
model: result.model,
|
|
2350
|
+
confidence: result.confidence,
|
|
2351
|
+
uncertainty: result.uncertainty,
|
|
2352
|
+
complexity: result.complexity,
|
|
2353
|
+
reasoning: result.reasoning,
|
|
2354
|
+
alternatives: result.alternatives,
|
|
2355
|
+
inferenceTimeUs: result.inferenceTimeUs,
|
|
2356
|
+
costMultiplier: result.costMultiplier,
|
|
2357
|
+
implementation: 'tiny-dancer-neural',
|
|
2358
|
+
};
|
|
2359
|
+
},
|
|
2360
|
+
};
|
|
2361
|
+
// Model route outcome - record outcome for learning
|
|
2362
|
+
export const hooksModelOutcome = {
|
|
2363
|
+
name: 'hooks/model-outcome',
|
|
2364
|
+
description: 'Record model routing outcome for learning',
|
|
2365
|
+
inputSchema: {
|
|
2366
|
+
type: 'object',
|
|
2367
|
+
properties: {
|
|
2368
|
+
task: { type: 'string', description: 'Original task' },
|
|
2369
|
+
model: { type: 'string', enum: ['haiku', 'sonnet', 'opus'], description: 'Model used' },
|
|
2370
|
+
outcome: { type: 'string', enum: ['success', 'failure', 'escalated'], description: 'Task outcome' },
|
|
2371
|
+
},
|
|
2372
|
+
required: ['task', 'model', 'outcome'],
|
|
2373
|
+
},
|
|
2374
|
+
handler: async (params) => {
|
|
2375
|
+
const task = params.task;
|
|
2376
|
+
const model = params.model;
|
|
2377
|
+
const outcome = params.outcome;
|
|
2378
|
+
const router = await getModelRouterInstance();
|
|
2379
|
+
if (router) {
|
|
2380
|
+
router.recordOutcome(task, model, outcome);
|
|
2381
|
+
}
|
|
2382
|
+
return {
|
|
2383
|
+
recorded: true,
|
|
2384
|
+
task: task.slice(0, 50),
|
|
2385
|
+
model,
|
|
2386
|
+
outcome,
|
|
2387
|
+
timestamp: new Date().toISOString(),
|
|
2388
|
+
};
|
|
2389
|
+
},
|
|
2390
|
+
};
|
|
2391
|
+
// Model router stats
|
|
2392
|
+
export const hooksModelStats = {
|
|
2393
|
+
name: 'hooks/model-stats',
|
|
2394
|
+
description: 'Get model routing statistics',
|
|
2395
|
+
inputSchema: {
|
|
2396
|
+
type: 'object',
|
|
2397
|
+
properties: {},
|
|
2398
|
+
},
|
|
2399
|
+
handler: async () => {
|
|
2400
|
+
const router = await getModelRouterInstance();
|
|
2401
|
+
if (!router) {
|
|
2402
|
+
return {
|
|
2403
|
+
available: false,
|
|
2404
|
+
message: 'Model router not initialized',
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
const stats = router.getStats();
|
|
2408
|
+
return {
|
|
2409
|
+
available: true,
|
|
2410
|
+
...stats,
|
|
2411
|
+
timestamp: new Date().toISOString(),
|
|
2412
|
+
};
|
|
2413
|
+
},
|
|
2414
|
+
};
|
|
2415
|
+
// Simple fallback complexity analyzer
|
|
2416
|
+
function analyzeComplexityFallback(task) {
|
|
2417
|
+
const taskLower = task.toLowerCase();
|
|
2418
|
+
// High complexity indicators
|
|
2419
|
+
const highIndicators = ['architect', 'design', 'refactor', 'security', 'audit', 'complex', 'analyze'];
|
|
2420
|
+
const highCount = highIndicators.filter(ind => taskLower.includes(ind)).length;
|
|
2421
|
+
// Low complexity indicators
|
|
2422
|
+
const lowIndicators = ['simple', 'typo', 'format', 'rename', 'comment'];
|
|
2423
|
+
const lowCount = lowIndicators.filter(ind => taskLower.includes(ind)).length;
|
|
2424
|
+
// Base on length
|
|
2425
|
+
const lengthScore = Math.min(1, task.length / 200);
|
|
2426
|
+
return Math.min(1, Math.max(0, 0.3 + highCount * 0.2 - lowCount * 0.15 + lengthScore * 0.2));
|
|
2427
|
+
}
|
|
2306
2428
|
// Worker cancel tool
|
|
2307
2429
|
export const hooksWorkerCancel = {
|
|
2308
2430
|
name: 'hooks/worker-cancel',
|
|
@@ -2377,6 +2499,10 @@ export const hooksTools = [
|
|
|
2377
2499
|
hooksWorkerStatus,
|
|
2378
2500
|
hooksWorkerDetect,
|
|
2379
2501
|
hooksWorkerCancel,
|
|
2502
|
+
// Model routing tools
|
|
2503
|
+
hooksModelRoute,
|
|
2504
|
+
hooksModelOutcome,
|
|
2505
|
+
hooksModelStats,
|
|
2380
2506
|
];
|
|
2381
2507
|
export default hooksTools;
|
|
2382
2508
|
//# sourceMappingURL=hooks-tools.js.map
|