claude-flow 3.5.54 → 3.5.56
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/package.json +1 -1
- package/v3/@claude-flow/cli/dist/src/benchmarks/pretrain/index.js +1 -1
- package/v3/@claude-flow/cli/dist/src/commands/config.js +92 -20
- package/v3/@claude-flow/cli/dist/src/commands/process.js +117 -63
- package/v3/@claude-flow/cli/dist/src/commands/status.js +2 -2
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +4 -8
- package/v3/@claude-flow/cli/dist/src/mcp-tools/claims-tools.js +15 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/coordination-tools.js +15 -8
- package/v3/@claude-flow/cli/dist/src/mcp-tools/github-tools.js +35 -93
- package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +154 -62
- package/v3/@claude-flow/cli/dist/src/mcp-tools/neural-tools.d.ts +4 -4
- package/v3/@claude-flow/cli/dist/src/mcp-tools/neural-tools.js +13 -45
- package/v3/@claude-flow/cli/dist/src/mcp-tools/performance-tools.js +15 -110
- package/v3/@claude-flow/cli/dist/src/mcp-tools/session-tools.js +23 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/system-tools.js +76 -30
- package/v3/@claude-flow/cli/dist/src/mcp-tools/task-tools.js +3 -3
- package/v3/@claude-flow/cli/dist/src/mcp-tools/workflow-tools.js +20 -31
- package/v3/@claude-flow/cli/package.json +1 -1
|
@@ -68,30 +68,19 @@ export const githubTools = [
|
|
|
68
68
|
name: repo,
|
|
69
69
|
branch,
|
|
70
70
|
lastAnalyzed: new Date().toISOString(),
|
|
71
|
-
metrics: {
|
|
72
|
-
commits: Math.floor(Math.random() * 1000) + 100,
|
|
73
|
-
branches: Math.floor(Math.random() * 20) + 1,
|
|
74
|
-
contributors: Math.floor(Math.random() * 50) + 1,
|
|
75
|
-
openIssues: Math.floor(Math.random() * 30),
|
|
76
|
-
openPRs: Math.floor(Math.random() * 10),
|
|
77
|
-
},
|
|
78
71
|
};
|
|
79
72
|
store.repos[repoKey] = repoInfo;
|
|
80
73
|
saveGitHubStore(store);
|
|
81
74
|
return {
|
|
82
|
-
success:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
testCoverage: `${Math.floor(Math.random() * 30) + 70}%`,
|
|
91
|
-
dependencies: Math.floor(Math.random() * 50) + 20,
|
|
92
|
-
securityIssues: Math.floor(Math.random() * 3),
|
|
75
|
+
success: false,
|
|
76
|
+
_stub: true,
|
|
77
|
+
message: 'GitHub tools are local-only stubs. For real GitHub operations, use the gh CLI or GitHub MCP server directly.',
|
|
78
|
+
localData: {
|
|
79
|
+
repository: repoKey,
|
|
80
|
+
branch,
|
|
81
|
+
lastAnalyzed: repoInfo.lastAnalyzed,
|
|
82
|
+
storedRepos: Object.keys(store.repos),
|
|
93
83
|
},
|
|
94
|
-
lastAnalyzed: repoInfo.lastAnalyzed,
|
|
95
84
|
};
|
|
96
85
|
},
|
|
97
86
|
},
|
|
@@ -147,13 +136,11 @@ export const githubTools = [
|
|
|
147
136
|
}
|
|
148
137
|
if (action === 'review') {
|
|
149
138
|
return {
|
|
150
|
-
success:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
comments: [],
|
|
156
|
-
suggestion: 'LGTM',
|
|
139
|
+
success: false,
|
|
140
|
+
_stub: true,
|
|
141
|
+
message: 'GitHub tools are local-only stubs. PR review requires actual GitHub API access. Use the gh CLI or GitHub MCP server directly.',
|
|
142
|
+
localData: {
|
|
143
|
+
prNumber: input.prNumber,
|
|
157
144
|
},
|
|
158
145
|
};
|
|
159
146
|
}
|
|
@@ -283,44 +270,16 @@ export const githubTools = [
|
|
|
283
270
|
},
|
|
284
271
|
handler: async (input) => {
|
|
285
272
|
const action = input.action || 'list';
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
if (action === 'trigger') {
|
|
297
|
-
return {
|
|
298
|
-
success: true,
|
|
299
|
-
action: 'triggered',
|
|
300
|
-
workflowId: input.workflowId,
|
|
301
|
-
ref: input.ref || 'main',
|
|
302
|
-
runId: `run-${Date.now()}`,
|
|
303
|
-
triggeredAt: new Date().toISOString(),
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
if (action === 'status') {
|
|
307
|
-
return {
|
|
308
|
-
success: true,
|
|
309
|
-
workflowId: input.workflowId,
|
|
310
|
-
status: 'completed',
|
|
311
|
-
conclusion: 'success',
|
|
312
|
-
duration: '2m 35s',
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
if (action === 'cancel') {
|
|
316
|
-
return {
|
|
317
|
-
success: true,
|
|
318
|
-
action: 'cancelled',
|
|
319
|
-
workflowId: input.workflowId,
|
|
320
|
-
cancelledAt: new Date().toISOString(),
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return { success: false, error: 'Unknown action' };
|
|
273
|
+
return {
|
|
274
|
+
success: false,
|
|
275
|
+
_stub: true,
|
|
276
|
+
message: 'GitHub tools are local-only stubs. Workflow operations require actual GitHub API access. Use the gh CLI or GitHub MCP server directly.',
|
|
277
|
+
localData: {
|
|
278
|
+
requestedAction: action,
|
|
279
|
+
workflowId: input.workflowId || null,
|
|
280
|
+
ref: input.ref || null,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
324
283
|
},
|
|
325
284
|
},
|
|
326
285
|
{
|
|
@@ -337,36 +296,19 @@ export const githubTools = [
|
|
|
337
296
|
},
|
|
338
297
|
},
|
|
339
298
|
handler: async (input) => {
|
|
340
|
-
const
|
|
341
|
-
const metrics = {
|
|
342
|
-
commits: {
|
|
343
|
-
total: Math.floor(Math.random() * 1000) + 500,
|
|
344
|
-
lastWeek: Math.floor(Math.random() * 50) + 10,
|
|
345
|
-
lastMonth: Math.floor(Math.random() * 200) + 50,
|
|
346
|
-
},
|
|
347
|
-
contributors: {
|
|
348
|
-
total: Math.floor(Math.random() * 50) + 5,
|
|
349
|
-
active: Math.floor(Math.random() * 20) + 3,
|
|
350
|
-
new: Math.floor(Math.random() * 5),
|
|
351
|
-
},
|
|
352
|
-
traffic: {
|
|
353
|
-
views: Math.floor(Math.random() * 5000) + 1000,
|
|
354
|
-
uniqueVisitors: Math.floor(Math.random() * 1000) + 200,
|
|
355
|
-
clones: Math.floor(Math.random() * 500) + 50,
|
|
356
|
-
},
|
|
357
|
-
releases: {
|
|
358
|
-
total: Math.floor(Math.random() * 20) + 5,
|
|
359
|
-
latest: '3.0.0-alpha.86',
|
|
360
|
-
downloads: Math.floor(Math.random() * 10000) + 1000,
|
|
361
|
-
},
|
|
362
|
-
};
|
|
363
|
-
if (metric === 'all') {
|
|
364
|
-
return { success: true, metrics };
|
|
365
|
-
}
|
|
299
|
+
const store = loadGitHubStore();
|
|
366
300
|
return {
|
|
367
|
-
success:
|
|
368
|
-
|
|
369
|
-
|
|
301
|
+
success: false,
|
|
302
|
+
_stub: true,
|
|
303
|
+
message: 'GitHub tools are local-only stubs. Repository metrics require actual GitHub API access. Use the gh CLI or GitHub MCP server directly.',
|
|
304
|
+
localData: {
|
|
305
|
+
owner: input.owner || 'owner',
|
|
306
|
+
repo: input.repo || 'repo',
|
|
307
|
+
requestedMetric: input.metric || 'all',
|
|
308
|
+
storedRepos: Object.keys(store.repos),
|
|
309
|
+
localIssueCount: Object.keys(store.issues).length,
|
|
310
|
+
localPrCount: Object.keys(store.prs).length,
|
|
311
|
+
},
|
|
370
312
|
};
|
|
371
313
|
},
|
|
372
314
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Hooks MCP Tools
|
|
3
3
|
* Provides intelligent hooks functionality via MCP protocol
|
|
4
4
|
*/
|
|
5
|
-
import { mkdirSync, writeFileSync, existsSync, readFileSync, statSync } from 'fs';
|
|
5
|
+
import { mkdirSync, writeFileSync, existsSync, readFileSync, statSync, unlinkSync, readdirSync } from 'fs';
|
|
6
6
|
import { dirname, join, resolve } from 'path';
|
|
7
7
|
import { getProjectCwd } from './types.js';
|
|
8
8
|
// Real vector search functions - lazy loaded to avoid circular imports
|
|
@@ -878,31 +878,44 @@ export const hooksMetrics = {
|
|
|
878
878
|
},
|
|
879
879
|
handler: async (params) => {
|
|
880
880
|
const period = params.period || '24h';
|
|
881
|
+
// Try to read real counts from memory store
|
|
882
|
+
const store = loadMemoryStore();
|
|
883
|
+
const entries = Object.values(store.entries);
|
|
884
|
+
// Count patterns by looking at stored pattern entries
|
|
885
|
+
const patternEntries = entries.filter(e => e.key.includes('pattern'));
|
|
886
|
+
const routingEntries = entries.filter(e => e.key.includes('route') || e.key.includes('routing'));
|
|
887
|
+
const taskEntries = entries.filter(e => e.key.includes('task'));
|
|
888
|
+
if (entries.length === 0) {
|
|
889
|
+
return {
|
|
890
|
+
_stub: true,
|
|
891
|
+
message: 'No metrics data available. Metrics are collected from hooks_post-task and hooks_route calls.',
|
|
892
|
+
period,
|
|
893
|
+
patterns: { total: 0, successful: 0, failed: 0, avgConfidence: null },
|
|
894
|
+
agents: { routingAccuracy: null, totalRoutes: 0, topAgent: null },
|
|
895
|
+
commands: { totalExecuted: 0, successRate: null, avgRiskScore: null },
|
|
896
|
+
lastUpdated: new Date().toISOString(),
|
|
897
|
+
};
|
|
898
|
+
}
|
|
881
899
|
return {
|
|
882
900
|
period,
|
|
883
901
|
patterns: {
|
|
884
|
-
total:
|
|
885
|
-
successful:
|
|
886
|
-
failed:
|
|
887
|
-
avgConfidence:
|
|
902
|
+
total: patternEntries.length,
|
|
903
|
+
successful: null,
|
|
904
|
+
failed: null,
|
|
905
|
+
avgConfidence: null,
|
|
888
906
|
},
|
|
889
907
|
agents: {
|
|
890
|
-
routingAccuracy:
|
|
891
|
-
totalRoutes:
|
|
892
|
-
topAgent:
|
|
908
|
+
routingAccuracy: null,
|
|
909
|
+
totalRoutes: routingEntries.length,
|
|
910
|
+
topAgent: null,
|
|
893
911
|
},
|
|
894
912
|
commands: {
|
|
895
|
-
totalExecuted:
|
|
896
|
-
successRate:
|
|
897
|
-
avgRiskScore:
|
|
898
|
-
},
|
|
899
|
-
performance: {
|
|
900
|
-
flashAttention: '2.49x-7.47x speedup',
|
|
901
|
-
memoryReduction: '50-75% reduction',
|
|
902
|
-
searchImprovement: '150x-12,500x faster',
|
|
903
|
-
tokenReduction: '32.3% fewer tokens',
|
|
913
|
+
totalExecuted: taskEntries.length,
|
|
914
|
+
successRate: null,
|
|
915
|
+
avgRiskScore: null,
|
|
904
916
|
},
|
|
905
|
-
|
|
917
|
+
dataSource: 'memory-store',
|
|
918
|
+
entriesFound: entries.length,
|
|
906
919
|
lastUpdated: new Date().toISOString(),
|
|
907
920
|
};
|
|
908
921
|
},
|
|
@@ -1167,19 +1180,36 @@ export const hooksExplain = {
|
|
|
1167
1180
|
if (taskLower.includes(pattern)) {
|
|
1168
1181
|
matchedPatterns.push({
|
|
1169
1182
|
pattern,
|
|
1170
|
-
matchScore:
|
|
1171
|
-
examples: [`
|
|
1183
|
+
matchScore: pattern.length / Math.max(taskLower.length, 1), // real ratio: pattern length vs task length
|
|
1184
|
+
examples: [`Keyword "${pattern}" matched in task description`],
|
|
1172
1185
|
});
|
|
1173
1186
|
}
|
|
1174
1187
|
}
|
|
1188
|
+
// Calculate real historical success rate from routing outcomes file
|
|
1189
|
+
let historicalSuccess = null;
|
|
1190
|
+
let historicalNote = 'No historical data yet';
|
|
1191
|
+
try {
|
|
1192
|
+
const outcomesPath = join(resolve('.'), '.claude-flow/routing-outcomes.json');
|
|
1193
|
+
if (existsSync(outcomesPath)) {
|
|
1194
|
+
const data = JSON.parse(readFileSync(outcomesPath, 'utf-8'));
|
|
1195
|
+
const outcomes = data.outcomes || [];
|
|
1196
|
+
if (outcomes.length > 0) {
|
|
1197
|
+
historicalSuccess = outcomes.filter(o => o.success).length / outcomes.length;
|
|
1198
|
+
historicalNote = `Calculated from ${outcomes.length} recorded outcomes`;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
catch {
|
|
1203
|
+
// File unreadable; leave as null
|
|
1204
|
+
}
|
|
1175
1205
|
return {
|
|
1176
1206
|
task,
|
|
1177
1207
|
explanation: `The routing decision was made based on keyword analysis of the task description. ` +
|
|
1178
1208
|
`The task contains keywords that match the "${suggestion.agents[0]}" specialization with ${(suggestion.confidence * 100).toFixed(0)}% confidence.`,
|
|
1179
1209
|
factors: [
|
|
1180
1210
|
{ factor: 'Keyword Match', weight: 0.4, value: suggestion.confidence, impact: 'Primary routing signal' },
|
|
1181
|
-
{ factor: 'Historical Success', weight: 0.3, value:
|
|
1182
|
-
{ factor: 'Agent Availability', weight: 0.2, value:
|
|
1211
|
+
{ factor: 'Historical Success', weight: 0.3, value: historicalSuccess, impact: historicalNote },
|
|
1212
|
+
{ factor: 'Agent Availability', weight: 0.2, value: null, impact: 'Agent availability tracking not implemented' },
|
|
1183
1213
|
{ factor: 'Task Complexity', weight: 0.1, value: task.length > 100 ? 0.8 : 0.3, impact: 'Complexity assessment' },
|
|
1184
1214
|
],
|
|
1185
1215
|
patterns: matchedPatterns.length > 0 ? matchedPatterns : [
|
|
@@ -1191,7 +1221,9 @@ export const hooksExplain = {
|
|
|
1191
1221
|
reasoning: [
|
|
1192
1222
|
`Task analysis identified ${matchedPatterns.length || 1} relevant patterns`,
|
|
1193
1223
|
`"${suggestion.agents[0]}" has highest capability match for this task type`,
|
|
1194
|
-
|
|
1224
|
+
historicalSuccess !== null
|
|
1225
|
+
? `Historical success rate for similar tasks: ${(historicalSuccess * 100).toFixed(0)}%`
|
|
1226
|
+
: `No historical outcome data available yet`,
|
|
1195
1227
|
`Confidence threshold met (${(suggestion.confidence * 100).toFixed(0)}% >= 70%)`,
|
|
1196
1228
|
],
|
|
1197
1229
|
},
|
|
@@ -1211,28 +1243,21 @@ export const hooksPretrain = {
|
|
|
1211
1243
|
},
|
|
1212
1244
|
},
|
|
1213
1245
|
handler: async (params) => {
|
|
1214
|
-
const
|
|
1246
|
+
const repoPath = params.path || '.';
|
|
1215
1247
|
const depth = params.depth || 'medium';
|
|
1216
|
-
const startTime = Date.now();
|
|
1217
|
-
// Scale analysis results by depth level
|
|
1218
|
-
const multiplier = depth === 'deep' ? 3 : depth === 'shallow' ? 1 : 2;
|
|
1219
1248
|
return {
|
|
1220
|
-
|
|
1249
|
+
success: true,
|
|
1250
|
+
_stub: true,
|
|
1251
|
+
message: 'Pre-training requires running the pretrain CLI command. This hook provides status only.',
|
|
1252
|
+
path: repoPath,
|
|
1221
1253
|
depth,
|
|
1222
1254
|
stats: {
|
|
1223
|
-
filesAnalyzed:
|
|
1224
|
-
patternsExtracted:
|
|
1225
|
-
strategiesLearned:
|
|
1226
|
-
trajectoriesEvaluated:
|
|
1227
|
-
contradictionsResolved:
|
|
1228
|
-
},
|
|
1229
|
-
pipeline: {
|
|
1230
|
-
retrieve: { status: 'completed', duration: 120 * multiplier },
|
|
1231
|
-
judge: { status: 'completed', duration: 180 * multiplier },
|
|
1232
|
-
distill: { status: 'completed', duration: 90 * multiplier },
|
|
1233
|
-
consolidate: { status: 'completed', duration: 60 * multiplier },
|
|
1255
|
+
filesAnalyzed: null,
|
|
1256
|
+
patternsExtracted: null,
|
|
1257
|
+
strategiesLearned: null,
|
|
1258
|
+
trajectoriesEvaluated: null,
|
|
1259
|
+
contradictionsResolved: null,
|
|
1234
1260
|
},
|
|
1235
|
-
duration: Date.now() - startTime + (500 * multiplier),
|
|
1236
1261
|
};
|
|
1237
1262
|
},
|
|
1238
1263
|
};
|
|
@@ -1335,12 +1360,14 @@ export const hooksTransfer = {
|
|
|
1335
1360
|
'command-risk': sourceEntries.filter(e => e.key.includes('command') || e.metadata?.type === 'command-risk').length,
|
|
1336
1361
|
'agent-success': sourceEntries.filter(e => e.key.includes('agent') || e.metadata?.type === 'agent-success').length,
|
|
1337
1362
|
};
|
|
1338
|
-
// If source has no patterns,
|
|
1363
|
+
// If source has no patterns, report honestly instead of substituting demo data
|
|
1339
1364
|
if (Object.values(byType).every(v => v === 0)) {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1365
|
+
return {
|
|
1366
|
+
success: false,
|
|
1367
|
+
message: 'No patterns found in source project',
|
|
1368
|
+
sourcePath,
|
|
1369
|
+
transferred: 0,
|
|
1370
|
+
};
|
|
1344
1371
|
}
|
|
1345
1372
|
if (filter) {
|
|
1346
1373
|
Object.keys(byType).forEach(key => {
|
|
@@ -1350,6 +1377,7 @@ export const hooksTransfer = {
|
|
|
1350
1377
|
}
|
|
1351
1378
|
const total = Object.values(byType).reduce((a, b) => a + b, 0);
|
|
1352
1379
|
return {
|
|
1380
|
+
success: true,
|
|
1353
1381
|
sourcePath,
|
|
1354
1382
|
transferred: {
|
|
1355
1383
|
total,
|
|
@@ -1364,7 +1392,7 @@ export const hooksTransfer = {
|
|
|
1364
1392
|
avgConfidence: 0.82 + (minConfidence > 0.8 ? 0.1 : 0),
|
|
1365
1393
|
avgAge: '3 days',
|
|
1366
1394
|
},
|
|
1367
|
-
dataSource:
|
|
1395
|
+
dataSource: 'source-project',
|
|
1368
1396
|
};
|
|
1369
1397
|
},
|
|
1370
1398
|
};
|
|
@@ -1470,6 +1498,25 @@ export const hooksSessionEnd = {
|
|
|
1470
1498
|
// Daemon may not be running
|
|
1471
1499
|
}
|
|
1472
1500
|
}
|
|
1501
|
+
// Read actual counts from stores
|
|
1502
|
+
const store = loadMemoryStore();
|
|
1503
|
+
const allEntries = Object.values(store.entries);
|
|
1504
|
+
const taskCount = allEntries.filter(e => e.key.includes('task')).length;
|
|
1505
|
+
const agentCount = allEntries.filter(e => e.key.includes('agent')).length;
|
|
1506
|
+
const patternCount = allEntries.filter(e => e.key.includes('pattern')).length;
|
|
1507
|
+
const trajectoryCount = activeTrajectories.size;
|
|
1508
|
+
// Check for pending-insights.jsonl
|
|
1509
|
+
let insightCount = 0;
|
|
1510
|
+
try {
|
|
1511
|
+
const insightsPath = resolve(join('.claude-flow', 'data', 'pending-insights.jsonl'));
|
|
1512
|
+
if (existsSync(insightsPath)) {
|
|
1513
|
+
const content = readFileSync(insightsPath, 'utf-8').trim();
|
|
1514
|
+
insightCount = content ? content.split('\n').length : 0;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
catch {
|
|
1518
|
+
// File not available
|
|
1519
|
+
}
|
|
1473
1520
|
// Phase 5: Wire ReflexionMemory session end + NightlyLearner consolidation via bridge
|
|
1474
1521
|
let sessionPersistence = null;
|
|
1475
1522
|
try {
|
|
@@ -1477,8 +1524,8 @@ export const hooksSessionEnd = {
|
|
|
1477
1524
|
const result = await bridge.bridgeSessionEnd({
|
|
1478
1525
|
sessionId,
|
|
1479
1526
|
summary: saveState ? 'Session ended with state saved' : 'Session ended',
|
|
1480
|
-
tasksCompleted:
|
|
1481
|
-
patternsLearned:
|
|
1527
|
+
tasksCompleted: taskCount,
|
|
1528
|
+
patternsLearned: patternCount,
|
|
1482
1529
|
});
|
|
1483
1530
|
if (result) {
|
|
1484
1531
|
sessionPersistence = {
|
|
@@ -1497,17 +1544,15 @@ export const hooksSessionEnd = {
|
|
|
1497
1544
|
daemon: { stopped: daemonStopped },
|
|
1498
1545
|
sessionPersistence: sessionPersistence || { controller: 'none', persisted: false },
|
|
1499
1546
|
summary: {
|
|
1500
|
-
tasksExecuted:
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
agentsSpawned: 5,
|
|
1547
|
+
tasksExecuted: taskCount,
|
|
1548
|
+
filesModified: 0,
|
|
1549
|
+
agentsSpawned: agentCount,
|
|
1550
|
+
pendingInsights: insightCount,
|
|
1551
|
+
memoryEntries: allEntries.length,
|
|
1506
1552
|
},
|
|
1507
1553
|
learningUpdates: {
|
|
1508
|
-
patternsLearned:
|
|
1509
|
-
trajectoriesRecorded:
|
|
1510
|
-
confidenceImproved: 0.05,
|
|
1554
|
+
patternsLearned: patternCount,
|
|
1555
|
+
trajectoriesRecorded: trajectoryCount,
|
|
1511
1556
|
},
|
|
1512
1557
|
};
|
|
1513
1558
|
},
|
|
@@ -1726,13 +1771,60 @@ export const hooksIntelligenceReset = {
|
|
|
1726
1771
|
properties: {},
|
|
1727
1772
|
},
|
|
1728
1773
|
handler: async () => {
|
|
1774
|
+
const cwd = getProjectCwd();
|
|
1775
|
+
const cleared = {
|
|
1776
|
+
trajectories: 0,
|
|
1777
|
+
patterns: 0,
|
|
1778
|
+
dataFiles: 0,
|
|
1779
|
+
neuralFiles: 0,
|
|
1780
|
+
};
|
|
1781
|
+
const deletedFiles = [];
|
|
1782
|
+
// Clear intelligence data files if they exist
|
|
1783
|
+
const dataFiles = [
|
|
1784
|
+
join(cwd, '.claude-flow', 'data', 'auto-memory-store.json'),
|
|
1785
|
+
join(cwd, '.claude-flow', 'data', 'graph-state.json'),
|
|
1786
|
+
join(cwd, '.claude-flow', 'data', 'ranked-context.json'),
|
|
1787
|
+
];
|
|
1788
|
+
for (const filePath of dataFiles) {
|
|
1789
|
+
if (existsSync(filePath)) {
|
|
1790
|
+
try {
|
|
1791
|
+
unlinkSync(filePath);
|
|
1792
|
+
cleared.dataFiles++;
|
|
1793
|
+
deletedFiles.push(filePath);
|
|
1794
|
+
}
|
|
1795
|
+
catch {
|
|
1796
|
+
// Skip files that cannot be deleted
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
// Clear neural directory if it exists
|
|
1801
|
+
const neuralDir = join(cwd, '.claude-flow', 'neural');
|
|
1802
|
+
if (existsSync(neuralDir)) {
|
|
1803
|
+
try {
|
|
1804
|
+
const files = readdirSync(neuralDir);
|
|
1805
|
+
for (const file of files) {
|
|
1806
|
+
try {
|
|
1807
|
+
const filePath = join(neuralDir, file);
|
|
1808
|
+
unlinkSync(filePath);
|
|
1809
|
+
cleared.neuralFiles++;
|
|
1810
|
+
deletedFiles.push(filePath);
|
|
1811
|
+
}
|
|
1812
|
+
catch {
|
|
1813
|
+
// Skip files that cannot be deleted
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
catch {
|
|
1818
|
+
// Directory read failed
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
// Clear in-memory trajectories
|
|
1822
|
+
cleared.trajectories = activeTrajectories.size;
|
|
1823
|
+
activeTrajectories.clear();
|
|
1729
1824
|
return {
|
|
1730
1825
|
reset: true,
|
|
1731
|
-
cleared
|
|
1732
|
-
|
|
1733
|
-
patterns: 89,
|
|
1734
|
-
hnswIndex: 12500,
|
|
1735
|
-
},
|
|
1826
|
+
cleared,
|
|
1827
|
+
deletedFiles,
|
|
1736
1828
|
timestamp: new Date().toISOString(),
|
|
1737
1829
|
};
|
|
1738
1830
|
},
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* V2 Compatibility - Neural network and ML tools
|
|
5
5
|
*
|
|
6
6
|
* ✅ HYBRID Implementation:
|
|
7
|
-
* - Uses @claude-flow/embeddings for REAL embeddings when available
|
|
8
|
-
* - Falls back to
|
|
9
|
-
* - Pattern storage and search with cosine similarity
|
|
10
|
-
* - Training
|
|
7
|
+
* - Uses @claude-flow/embeddings for REAL ML embeddings when available
|
|
8
|
+
* - Falls back to deterministic hash-based embeddings when ML model not installed
|
|
9
|
+
* - Pattern storage and search with cosine similarity (real math in all tiers)
|
|
10
|
+
* - Training stores patterns as searchable embeddings (not simulated)
|
|
11
11
|
*
|
|
12
12
|
* Note: For production neural features, use @claude-flow/neural module
|
|
13
13
|
*/
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* V2 Compatibility - Neural network and ML tools
|
|
5
5
|
*
|
|
6
6
|
* ✅ HYBRID Implementation:
|
|
7
|
-
* - Uses @claude-flow/embeddings for REAL embeddings when available
|
|
8
|
-
* - Falls back to
|
|
9
|
-
* - Pattern storage and search with cosine similarity
|
|
10
|
-
* - Training
|
|
7
|
+
* - Uses @claude-flow/embeddings for REAL ML embeddings when available
|
|
8
|
+
* - Falls back to deterministic hash-based embeddings when ML model not installed
|
|
9
|
+
* - Pattern storage and search with cosine similarity (real math in all tiers)
|
|
10
|
+
* - Training stores patterns as searchable embeddings (not simulated)
|
|
11
11
|
*
|
|
12
12
|
* Note: For production neural features, use @claude-flow/neural module
|
|
13
13
|
*/
|
|
@@ -87,7 +87,7 @@ function saveNeuralStore(store) {
|
|
|
87
87
|
ensureNeuralDir();
|
|
88
88
|
writeFileSync(getNeuralPath(), JSON.stringify(store, null, 2), 'utf-8');
|
|
89
89
|
}
|
|
90
|
-
// Generate embedding - uses real embeddings if available, falls back to hash
|
|
90
|
+
// Generate embedding - uses real ML embeddings if available, falls back to deterministic hash
|
|
91
91
|
async function generateEmbedding(text, dims = 384) {
|
|
92
92
|
// If real embeddings available and text provided, use them
|
|
93
93
|
if (realEmbeddings && text) {
|
|
@@ -113,8 +113,8 @@ async function generateEmbedding(text, dims = 384) {
|
|
|
113
113
|
}
|
|
114
114
|
return embedding;
|
|
115
115
|
}
|
|
116
|
-
//
|
|
117
|
-
return Array
|
|
116
|
+
// No text provided — return zero vector (callers should always provide text)
|
|
117
|
+
return new Array(dims).fill(0);
|
|
118
118
|
}
|
|
119
119
|
// Cosine similarity for pattern search
|
|
120
120
|
function cosineSimilarity(a, b) {
|
|
@@ -385,23 +385,12 @@ export const neuralTools = [
|
|
|
385
385
|
},
|
|
386
386
|
},
|
|
387
387
|
handler: async (input) => {
|
|
388
|
-
const method = input.method || '
|
|
389
|
-
const targetSize = input.targetSize || 0.25;
|
|
390
|
-
const compressionResults = {
|
|
391
|
-
quantize: { ratio: 3.92, method: 'Int8', memory: '75% reduction' },
|
|
392
|
-
prune: { ratio: 2.5, method: 'Magnitude pruning', memory: '60% reduction' },
|
|
393
|
-
distill: { ratio: 4.0, method: 'Knowledge distillation', memory: '75% reduction' },
|
|
394
|
-
};
|
|
395
|
-
const result = compressionResults[method] || compressionResults.quantize;
|
|
388
|
+
const method = input.method || 'quantization';
|
|
396
389
|
return {
|
|
397
390
|
success: true,
|
|
391
|
+
_stub: true,
|
|
392
|
+
message: 'Compression not yet implemented. No data was modified.',
|
|
398
393
|
method,
|
|
399
|
-
originalSize: '1536 dims',
|
|
400
|
-
compressedSize: `${Math.floor(1536 * targetSize)} dims`,
|
|
401
|
-
compressionRatio: result.ratio,
|
|
402
|
-
memoryReduction: result.memory,
|
|
403
|
-
qualityRetention: 0.98,
|
|
404
|
-
latencyImprovement: '2.5x faster',
|
|
405
394
|
};
|
|
406
395
|
},
|
|
407
396
|
},
|
|
@@ -467,33 +456,12 @@ export const neuralTools = [
|
|
|
467
456
|
},
|
|
468
457
|
},
|
|
469
458
|
handler: async (input) => {
|
|
470
|
-
const target = input.target || '
|
|
471
|
-
const optimizations = {
|
|
472
|
-
speed: {
|
|
473
|
-
applied: ['Flash Attention', 'Batch processing', 'SIMD vectorization'],
|
|
474
|
-
improvement: '2.49x-7.47x faster inference',
|
|
475
|
-
},
|
|
476
|
-
memory: {
|
|
477
|
-
applied: ['Int8 quantization', 'Gradient checkpointing', 'Memory pooling'],
|
|
478
|
-
improvement: '50-75% memory reduction',
|
|
479
|
-
},
|
|
480
|
-
accuracy: {
|
|
481
|
-
applied: ['EWC++ regularization', 'Ensemble averaging', 'Data augmentation'],
|
|
482
|
-
improvement: '3-5% accuracy boost',
|
|
483
|
-
},
|
|
484
|
-
balanced: {
|
|
485
|
-
applied: ['HNSW indexing', 'Smart caching', 'Adaptive batch size'],
|
|
486
|
-
improvement: 'Balanced 30% improvement across metrics',
|
|
487
|
-
},
|
|
488
|
-
};
|
|
489
|
-
const result = optimizations[target] || optimizations.balanced;
|
|
459
|
+
const target = input.target || 'general';
|
|
490
460
|
return {
|
|
491
461
|
success: true,
|
|
462
|
+
_stub: true,
|
|
463
|
+
message: 'Optimization not yet implemented. No data was modified.',
|
|
492
464
|
target,
|
|
493
|
-
optimizations: result.applied,
|
|
494
|
-
improvement: result.improvement,
|
|
495
|
-
status: 'applied',
|
|
496
|
-
timestamp: new Date().toISOString(),
|
|
497
465
|
};
|
|
498
466
|
},
|
|
499
467
|
},
|