@claude-flow/cli 3.10.12 → 3.10.14
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/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +86 -10
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.d.ts +17 -0
- package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +34 -0
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +3 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -1
- package/dist/src/memory/intelligence.js +29 -0
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +7 -0
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/scripts/benchmark-self-learning.mjs +215 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/hooks-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,YAAY,CAAC;AAiBzD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASzD;AAwqBD,eAAO,MAAM,YAAY,EAAE,OAwC1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OA+C3B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,OA6C7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,OAuD9B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,OAgLxB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OAoE1B,CAAC;AAEF,eAAO,MAAM,S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
|
-
|
|
1534
|
+
// Persist extracted patterns. Two stores get written so the user can find
|
|
1535
|
+
// them where they expect:
|
|
1536
|
+
// 1. memory-bridge `pretrain` namespace — one summary bundle
|
|
1537
|
+
// 2. neural store — one row PER pattern so `neural_patterns list` reflects them
|
|
1538
|
+
// #2245 — without (2), the dashboards reported "0 patterns" after pretrain.
|
|
1539
|
+
let patternsBundled = 0;
|
|
1540
|
+
let patternsIndexed = 0;
|
|
1536
1541
|
try {
|
|
1537
1542
|
const bridge = await import('../memory/memory-bridge.js');
|
|
1538
1543
|
await bridge.bridgeStoreEntry({
|
|
@@ -1541,9 +1546,23 @@ export const hooksPretrain = {
|
|
|
1541
1546
|
namespace: 'pretrain',
|
|
1542
1547
|
tags: ['pretrain', depth],
|
|
1543
1548
|
});
|
|
1544
|
-
|
|
1549
|
+
patternsBundled = patterns.length;
|
|
1545
1550
|
}
|
|
1546
1551
|
catch { /* AgentDB not available */ }
|
|
1552
|
+
try {
|
|
1553
|
+
const neural = await import('./neural-tools.js');
|
|
1554
|
+
const items = patterns.map((p) => ({
|
|
1555
|
+
name: p.length > 200 ? p.slice(0, 200) : p,
|
|
1556
|
+
type: 'import-pattern',
|
|
1557
|
+
content: p,
|
|
1558
|
+
metadata: { source: 'hooks_pretrain', depth },
|
|
1559
|
+
}));
|
|
1560
|
+
const result = await neural.storeNeuralPatterns(items);
|
|
1561
|
+
patternsIndexed = result.stored;
|
|
1562
|
+
}
|
|
1563
|
+
catch { /* neural store unavailable */ }
|
|
1564
|
+
// Back-compat field
|
|
1565
|
+
const patternsStored = patternsBundled;
|
|
1547
1566
|
// #1847: when the corpus contains files but no patterns were extracted
|
|
1548
1567
|
// (typical for Markdown vaults), make the source-code-only extraction
|
|
1549
1568
|
// contract explicit so users don't conclude the hook system is broken.
|
|
@@ -1565,13 +1584,20 @@ export const hooksPretrain = {
|
|
|
1565
1584
|
filesAnalyzed,
|
|
1566
1585
|
totalLines,
|
|
1567
1586
|
patternsExtracted: patterns.length,
|
|
1568
|
-
|
|
1587
|
+
patternsBundled, // #2245: 1 summary row in memory-bridge `pretrain` namespace
|
|
1588
|
+
patternsIndexed, // #2245: per-pattern rows in neural store — surfaced by neural_patterns list
|
|
1589
|
+
patternsStored, // back-compat alias for patternsBundled
|
|
1569
1590
|
fileTypes: Object.entries(extCounts).sort((a, b) => b[1] - a[1]).slice(0, 15).map(([ext, count]) => ({ ext, count })),
|
|
1570
1591
|
// #1847: explicit extraction contract so callers can tell pretrain
|
|
1571
1592
|
// patterns apart from live trajectories and hook statusline state.
|
|
1593
|
+
// #2245: also call out exactly which stores got written.
|
|
1572
1594
|
sources: {
|
|
1573
1595
|
extractedFrom: SUPPORTED_EXTRACTION_EXTS,
|
|
1574
1596
|
scope: 'pretrain-only (live trajectories + statusline are tracked separately)',
|
|
1597
|
+
stores: {
|
|
1598
|
+
'memory-bridge:pretrain': patternsBundled > 0 ? 1 : 0, // one bundle row
|
|
1599
|
+
'neural-store (neural_patterns list)': patternsIndexed,
|
|
1600
|
+
},
|
|
1575
1601
|
},
|
|
1576
1602
|
},
|
|
1577
1603
|
...(note ? { note } : {}),
|
|
@@ -4150,7 +4176,7 @@ export const hooksTeammateIdle = {
|
|
|
4150
4176
|
};
|
|
4151
4177
|
export const hooksTaskCompleted = {
|
|
4152
4178
|
name: 'hooks_task-completed',
|
|
4153
|
-
description: 'Agent Teams hook — fired when a task is marked complete
|
|
4179
|
+
description: 'Agent Teams hook — fired when a task is marked complete. Records the completion and, when `trainPatterns:true`, feeds the outcome to the SONA + EWC++ learning pipeline (the same path used by hooks_intelligence trajectory-*). Multiple ways to drive learning exist: (a) call this with trainPatterns:true for a one-step trajectory, (b) use hooks_intelligence trajectory-start/step/end for richer multi-step learning, (c) just record an episode via memory_store if no learning is needed. Each path is honest about what it persists; check the returned `learningPath` field.',
|
|
4154
4180
|
category: 'hooks',
|
|
4155
4181
|
inputSchema: {
|
|
4156
4182
|
type: 'object',
|
|
@@ -4159,21 +4185,71 @@ export const hooksTaskCompleted = {
|
|
|
4159
4185
|
teammateId: { type: 'string', description: 'Teammate that completed it' },
|
|
4160
4186
|
success: { type: 'boolean', description: 'Whether the task succeeded' },
|
|
4161
4187
|
quality: { type: 'number', description: 'Quality score 0-1' },
|
|
4162
|
-
trainPatterns: { type: 'boolean', description: '
|
|
4188
|
+
trainPatterns: { type: 'boolean', description: 'When true, runs the SONA + EWC++ trajectory pipeline on this completion so globalStats.patternsLearned reflects it. When false (default), only records the completion.' },
|
|
4163
4189
|
notifyLead: { type: 'boolean', description: 'Notify the team lead' },
|
|
4190
|
+
content: { type: 'string', description: 'Optional richer task description; used as the trajectory step content when training. Defaults to the taskId.' },
|
|
4164
4191
|
},
|
|
4165
4192
|
required: ['taskId'],
|
|
4166
4193
|
},
|
|
4167
4194
|
handler: async (input) => {
|
|
4168
4195
|
const taskId = String(input.taskId ?? '');
|
|
4169
|
-
const
|
|
4196
|
+
const success = input.success !== false;
|
|
4197
|
+
const quality = typeof input.quality === 'number' ? input.quality : (success ? 1 : 0);
|
|
4198
|
+
const trainPatterns = input.trainPatterns === true;
|
|
4199
|
+
const teammateId = input.teammateId ? String(input.teammateId) : undefined;
|
|
4200
|
+
// #2241 (OWASP ASI06 Memory/Context Poisoning) — task content is user-
|
|
4201
|
+
// supplied and feeds the SONA learning model. Cap length, strip control
|
|
4202
|
+
// chars, and reject obvious prompt-injection sentinels before training.
|
|
4203
|
+
const rawContent = typeof input.content === 'string' && input.content.trim()
|
|
4204
|
+
? String(input.content)
|
|
4205
|
+
: `Task ${taskId} completed (quality=${quality.toFixed(2)})`;
|
|
4206
|
+
const content = rawContent
|
|
4207
|
+
// Strip ASCII control chars except newline/tab.
|
|
4208
|
+
.replace(/[\x00-\x08\x0B-\x1F\x7F]/g, '')
|
|
4209
|
+
// Cap to 4 KB — way over a typical trajectory step, well under a memory bomb.
|
|
4210
|
+
.slice(0, 4096);
|
|
4211
|
+
let patternsLearned = 0;
|
|
4212
|
+
let trajectoriesRecorded = 0;
|
|
4213
|
+
let learningPath = 'recorded-only';
|
|
4214
|
+
let learningError;
|
|
4215
|
+
if (trainPatterns) {
|
|
4216
|
+
// #2245 — actually feed the learning loop. Synthesize a one-step
|
|
4217
|
+
// trajectory from {taskId, success, quality} and run it through the
|
|
4218
|
+
// same SONA + EWC + globalStats++ path as hooks_intelligence trajectory-end.
|
|
4219
|
+
try {
|
|
4220
|
+
const intel = await import('../memory/intelligence.js');
|
|
4221
|
+
const before = intel.getIntelligenceStats();
|
|
4222
|
+
await intel.recordTrajectory([{
|
|
4223
|
+
type: 'result',
|
|
4224
|
+
content,
|
|
4225
|
+
metadata: { taskId, success, quality, teammateId },
|
|
4226
|
+
timestamp: Date.now(),
|
|
4227
|
+
}], success ? 'success' : 'failure');
|
|
4228
|
+
const after = intel.getIntelligenceStats();
|
|
4229
|
+
patternsLearned = Math.max(0, after.patternsLearned - before.patternsLearned);
|
|
4230
|
+
trajectoriesRecorded = Math.max(0, after.trajectoriesRecorded - before.trajectoriesRecorded);
|
|
4231
|
+
learningPath = 'trajectory-pipeline';
|
|
4232
|
+
}
|
|
4233
|
+
catch (err) {
|
|
4234
|
+
learningError = err.message;
|
|
4235
|
+
// Fall back to recorded-only — be honest about it.
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
const note = trainPatterns
|
|
4239
|
+
? (learningPath === 'trajectory-pipeline'
|
|
4240
|
+
? `Trained via SONA + EWC++ trajectory pipeline (verdict=${success ? 'success' : 'failure'}, patternsLearned=${patternsLearned}, trajectoriesRecorded=${trajectoriesRecorded}).`
|
|
4241
|
+
: `trainPatterns=true but the trajectory pipeline failed (${learningError ?? 'unknown error'}). Completion recorded only.`)
|
|
4242
|
+
: 'Completion recorded only. Pass trainPatterns:true (or use hooks_intelligence trajectory-* directly) to feed the learning loop.';
|
|
4170
4243
|
return {
|
|
4171
4244
|
success: true,
|
|
4172
4245
|
taskId,
|
|
4173
|
-
patternsLearned
|
|
4246
|
+
patternsLearned,
|
|
4247
|
+
trajectoriesRecorded,
|
|
4248
|
+
learningPath, // 'trajectory-pipeline' | 'recorded-only'
|
|
4174
4249
|
leadNotified: input.notifyLead === true,
|
|
4175
|
-
metrics: { duration: 0, quality, learningUpdates:
|
|
4176
|
-
|
|
4250
|
+
metrics: { duration: 0, quality, learningUpdates: patternsLearned },
|
|
4251
|
+
...(learningError ? { learningError } : {}),
|
|
4252
|
+
note,
|
|
4177
4253
|
};
|
|
4178
4254
|
},
|
|
4179
4255
|
};
|