claude-flow 3.72.0 → 3.72.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/.claude/proven-config.json +1 -1
- package/.claude-plugin/marketplace.json +6 -6
- package/node_modules/@claude-flow/codex/.agents/skills/fast-code-edits/SKILL.md +42 -0
- package/node_modules/@claude-flow/codex/.agents/skills/graph-mincut/SKILL.md +42 -0
- package/node_modules/@claude-flow/codex/.agents/skills/injection-defense/SKILL.md +45 -0
- package/node_modules/@claude-flow/codex/.agents/skills/lora-learning/SKILL.md +39 -0
- package/node_modules/@claude-flow/codex/.agents/skills/sublinear-solver/SKILL.md +38 -0
- package/node_modules/@claude-flow/codex/.agents/skills/vector-quantization/SKILL.md +49 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -1
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +6 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -1
- package/node_modules/@claude-flow/codex/dist/index.d.ts +3 -3
- package/node_modules/@claude-flow/codex/dist/index.js +1 -1
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -1
- package/node_modules/@claude-flow/codex/dist/templates/index.js +37 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -1
- package/node_modules/@claude-flow/codex/dist/types.d.ts +1 -1
- package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -1
- package/node_modules/@claude-flow/codex/package.json +1 -1
- package/package.json +13 -10
- package/v3/@claude-flow/cli/catalog-manifest.json +4 -4
- package/v3/@claude-flow/cli/dist/src/appliance/ruvllm-bridge.d.ts +6 -2
- package/v3/@claude-flow/cli/dist/src/appliance/ruvllm-bridge.js +13 -8
- package/v3/@claude-flow/cli/dist/src/commands/init.js +2 -0
- package/v3/@claude-flow/cli/dist/src/commands/neural.js +81 -71
- package/v3/@claude-flow/cli/dist/src/init/executor.js +13 -0
- package/v3/@claude-flow/cli/dist/src/init/types.d.ts +6 -0
- package/v3/@claude-flow/cli/dist/src/init/types.js +3 -0
- package/v3/@claude-flow/cli/dist/src/mcp-client.js +2 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +34 -2
- package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-session-tools.d.ts +2 -2
- package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-session-tools.js +4 -4
- package/v3/@claude-flow/cli/dist/src/mcp-tools/fast-apply-tools.d.ts +4 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/fast-apply-tools.js +85 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +19 -34
- package/v3/@claude-flow/cli/dist/src/mcp-tools/metaharness-tools.js +1 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/neural-tools.js +3 -3
- package/v3/@claude-flow/cli/dist/src/mcp-tools/realpath-containment.d.ts +3 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/realpath-containment.js +39 -0
- package/v3/@claude-flow/cli/dist/src/mods/command-registry/schema.d.ts +12 -12
- package/v3/@claude-flow/cli/dist/src/ruvector/ast-analyzer.d.ts +1 -2
- package/v3/@claude-flow/cli/dist/src/ruvector/ast-analyzer.js +4 -12
- package/v3/@claude-flow/cli/dist/src/ruvector/coverage-router.d.ts +1 -2
- package/v3/@claude-flow/cli/dist/src/ruvector/coverage-router.js +4 -12
- package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.d.ts +1 -2
- package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.js +3 -12
- package/v3/@claude-flow/cli/dist/src/ruvector/fast-apply.d.ts +46 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/fast-apply.js +73 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/graph-analyzer.d.ts +11 -1
- package/v3/@claude-flow/cli/dist/src/ruvector/graph-analyzer.js +22 -36
- package/v3/@claude-flow/cli/dist/src/ruvector/mincut-bridge.d.ts +70 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/mincut-bridge.js +172 -0
- package/v3/@claude-flow/cli/dist/src/services/distill-oracle.d.ts +1 -1
- package/v3/@claude-flow/cli/dist/src/services/distill-oracle.js +2 -2
- package/v3/@claude-flow/cli/package.json +12 -10
|
@@ -135,10 +135,11 @@ export class RuvllmBridge {
|
|
|
135
135
|
async generate(request) {
|
|
136
136
|
const start = performance.now();
|
|
137
137
|
const modelName = request.model ?? this.config.defaultModel ?? this.activeModel ?? '';
|
|
138
|
-
// Tier 1:
|
|
139
|
-
|
|
138
|
+
// Tier 1: deterministic codemod hint (ADR-143). The prompt carries no code,
|
|
139
|
+
// so nothing can be applied here; this points the caller at hooks_codemod.
|
|
140
|
+
const booster = this.tryCodemodHint(request.prompt);
|
|
140
141
|
if (booster !== null) {
|
|
141
|
-
return { text: booster, model: '
|
|
142
|
+
return { text: booster, model: 'codemod', tokensUsed: 0, latencyMs: performance.now() - start, tier: 1, cached: false };
|
|
142
143
|
}
|
|
143
144
|
// Tier 2: Local model (GGUF engine preferred, then @ruvector/core)
|
|
144
145
|
const info = this.models.get(modelName);
|
|
@@ -183,7 +184,7 @@ export class RuvllmBridge {
|
|
|
183
184
|
const complexity = estimateComplexity(description);
|
|
184
185
|
const words = description.split(/\s+/).length;
|
|
185
186
|
if (words < 15 && complexity < 0.25)
|
|
186
|
-
return { tier: 1, model: '
|
|
187
|
+
return { tier: 1, model: 'codemod', confidence: 0.9 };
|
|
187
188
|
if (complexity < 0.55 && this.activeModel)
|
|
188
189
|
return { tier: 2, model: this.activeModel, confidence: 0.7 };
|
|
189
190
|
return { tier: 3, model: 'cloud', confidence: 0.6 };
|
|
@@ -252,17 +253,21 @@ export class RuvllmBridge {
|
|
|
252
253
|
return null;
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
|
-
/**
|
|
256
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Tier-1 codemod hint for trivial transforms, no LLM. Not agent-booster:
|
|
258
|
+
* that engine merges a code snippet into code (hooks_fast-apply) and cannot
|
|
259
|
+
* act on an instruction alone.
|
|
260
|
+
*/
|
|
261
|
+
tryCodemodHint(prompt) {
|
|
257
262
|
const t = prompt.trim();
|
|
258
263
|
if (t.length > 200)
|
|
259
264
|
return null;
|
|
260
265
|
if (/^(convert|change)\s+(var|let)\s+to\s+const$/i.test(t)) {
|
|
261
|
-
return '
|
|
266
|
+
return 'Call hooks_codemod with intent="var-to-const" (deterministic, $0), or use the Edit tool.';
|
|
262
267
|
}
|
|
263
268
|
if (/^remove\s+console\.(log|warn|error|debug|info)$/i.test(t)) {
|
|
264
269
|
const m = t.toLowerCase().match(/console\.(\w+)/)?.[1] ?? 'log';
|
|
265
|
-
return `
|
|
270
|
+
return `Call hooks_codemod with intent="remove-console" (deterministic, $0), or use the Edit tool to remove all \`console.${m}\` calls.`;
|
|
266
271
|
}
|
|
267
272
|
return null;
|
|
268
273
|
}
|
|
@@ -1355,6 +1355,7 @@ const skillsCommand = {
|
|
|
1355
1355
|
{ name: 'github', description: 'Install GitHub skills', type: 'boolean', default: false },
|
|
1356
1356
|
{ name: 'v3', description: 'Install V3 skills', type: 'boolean', default: false },
|
|
1357
1357
|
{ name: 'legacy', description: 'Install skills that document commands v3 does not ship (stream-chain, sparc)', type: 'boolean', default: false },
|
|
1358
|
+
{ name: 'ecosystem', description: 'Install ecosystem skills (vector quantization, graph min-cut, sublinear solving, injection defense, fast edits, LoRA learning)', type: 'boolean', default: true },
|
|
1358
1359
|
],
|
|
1359
1360
|
action: async (ctx) => {
|
|
1360
1361
|
const options = {
|
|
@@ -1382,6 +1383,7 @@ const skillsCommand = {
|
|
|
1382
1383
|
v3: ctx.flags.v3,
|
|
1383
1384
|
dualMode: false,
|
|
1384
1385
|
legacy: ctx.flags.legacy,
|
|
1386
|
+
ecosystem: ctx.flags.ecosystem,
|
|
1385
1387
|
},
|
|
1386
1388
|
};
|
|
1387
1389
|
const spinner = output.createSpinner({ text: 'Installing skills...' });
|
|
@@ -1516,81 +1516,91 @@ const benchmarkCommand = {
|
|
|
1516
1516
|
const spinner = output.createSpinner({ text: 'Running benchmarks...', spinner: 'dots' });
|
|
1517
1517
|
spinner.start();
|
|
1518
1518
|
try {
|
|
1519
|
-
|
|
1520
|
-
//
|
|
1521
|
-
//
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1519
|
+
const results = [];
|
|
1520
|
+
// The attention and MicroLoRA benchmarks are independent: a missing or
|
|
1521
|
+
// API-incompatible @ruvector/attention must not hide the
|
|
1522
|
+
// @ruvector/learning-wasm MicroLoRA numbers below.
|
|
1523
|
+
try {
|
|
1524
|
+
// Indirect the specifier through a string variable so tsc doesn't
|
|
1525
|
+
// statically resolve this optional dependency at build time (TS2307
|
|
1526
|
+
// when it isn't installed — install-safety / Build V3 pattern from #2586).
|
|
1527
|
+
const attentionPkg = '@ruvector/attention';
|
|
1528
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic import of optional native WASM module with no type declarations
|
|
1529
|
+
// @ruvector/attention is CommonJS: under import() its classes sit on `default`.
|
|
1530
|
+
const attentionMod = await import(attentionPkg);
|
|
1531
|
+
const attention = (attentionMod.default ?? attentionMod);
|
|
1532
|
+
// Manual benchmark since benchmarkAttention has a binding bug
|
|
1533
|
+
const benchmarkMechanism = async (name, mechanism) => {
|
|
1534
|
+
const query = new Float32Array(dim);
|
|
1535
|
+
const keys = [];
|
|
1536
|
+
const values = [];
|
|
1537
|
+
for (let i = 0; i < dim; i++)
|
|
1538
|
+
query[i] = Math.random();
|
|
1539
|
+
for (let k = 0; k < numKeys; k++) {
|
|
1540
|
+
const key = new Float32Array(dim);
|
|
1541
|
+
const val = new Float32Array(dim);
|
|
1542
|
+
for (let i = 0; i < dim; i++) {
|
|
1543
|
+
key[i] = Math.random();
|
|
1544
|
+
val[i] = Math.random();
|
|
1545
|
+
}
|
|
1546
|
+
keys.push(key);
|
|
1547
|
+
values.push(val);
|
|
1538
1548
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
averageTimeMs: elapsed / iterations,
|
|
1553
|
-
opsPerSecond: Math.round((iterations / elapsed) * 1000),
|
|
1549
|
+
// Warmup
|
|
1550
|
+
for (let i = 0; i < 10; i++)
|
|
1551
|
+
mechanism.compute(query, keys, values);
|
|
1552
|
+
const start = performance.now();
|
|
1553
|
+
for (let i = 0; i < iterations; i++) {
|
|
1554
|
+
mechanism.compute(query, keys, values);
|
|
1555
|
+
}
|
|
1556
|
+
const elapsed = performance.now() - start;
|
|
1557
|
+
return {
|
|
1558
|
+
name,
|
|
1559
|
+
averageTimeMs: elapsed / iterations,
|
|
1560
|
+
opsPerSecond: Math.round((iterations / elapsed) * 1000),
|
|
1561
|
+
};
|
|
1554
1562
|
};
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
results.push(await benchmarkMechanism('Linear', linear));
|
|
1569
|
-
spinner.succeed('Benchmark complete');
|
|
1570
|
-
output.writeln();
|
|
1571
|
-
output.printTable({
|
|
1572
|
-
columns: [
|
|
1573
|
-
{ key: 'name', header: 'Mechanism', width: 25 },
|
|
1574
|
-
{ key: 'avgTime', header: 'Avg Time (ms)', width: 15 },
|
|
1575
|
-
{ key: 'opsPerSec', header: 'Ops/sec', width: 15 },
|
|
1576
|
-
],
|
|
1577
|
-
data: results.map(r => ({
|
|
1578
|
-
name: r.name,
|
|
1579
|
-
avgTime: r.averageTimeMs.toFixed(4),
|
|
1580
|
-
opsPerSec: r.opsPerSecond.toLocaleString(),
|
|
1581
|
-
})),
|
|
1582
|
-
});
|
|
1583
|
-
// Show speedup comparisons
|
|
1584
|
-
const dotProductResult = results.find(r => r.name.includes('DotProduct'));
|
|
1585
|
-
const flashResult = results.find(r => r.name.includes('Flash'));
|
|
1586
|
-
const hyperbolicResult = results.find(r => r.name.includes('Hyperbolic'));
|
|
1587
|
-
if (dotProductResult && flashResult) {
|
|
1588
|
-
const speedup = dotProductResult.averageTimeMs / flashResult.averageTimeMs;
|
|
1563
|
+
spinner.setText(`Benchmarking attention mechanisms (dim=${dim}, keys=${numKeys}, iter=${iterations})...`);
|
|
1564
|
+
// Benchmark each mechanism
|
|
1565
|
+
const dotProduct = new attention.DotProductAttention(dim);
|
|
1566
|
+
results.push(await benchmarkMechanism('DotProduct', dotProduct));
|
|
1567
|
+
const flash = new attention.FlashAttention(dim, 64);
|
|
1568
|
+
results.push(await benchmarkMechanism('FlashAttention', flash));
|
|
1569
|
+
const multiHead = new attention.MultiHeadAttention(dim, 4);
|
|
1570
|
+
results.push(await benchmarkMechanism('MultiHead (4 heads)', multiHead));
|
|
1571
|
+
const hyperbolic = new attention.HyperbolicAttention(dim, 1.0);
|
|
1572
|
+
results.push(await benchmarkMechanism('Hyperbolic', hyperbolic));
|
|
1573
|
+
const linear = new attention.LinearAttention(dim, dim);
|
|
1574
|
+
results.push(await benchmarkMechanism('Linear', linear));
|
|
1575
|
+
spinner.succeed('Benchmark complete');
|
|
1589
1576
|
output.writeln();
|
|
1590
|
-
output.
|
|
1577
|
+
output.printTable({
|
|
1578
|
+
columns: [
|
|
1579
|
+
{ key: 'name', header: 'Mechanism', width: 25 },
|
|
1580
|
+
{ key: 'avgTime', header: 'Avg Time (ms)', width: 15 },
|
|
1581
|
+
{ key: 'opsPerSec', header: 'Ops/sec', width: 15 },
|
|
1582
|
+
],
|
|
1583
|
+
data: results.map(r => ({
|
|
1584
|
+
name: r.name,
|
|
1585
|
+
avgTime: r.averageTimeMs.toFixed(4),
|
|
1586
|
+
opsPerSec: r.opsPerSecond.toLocaleString(),
|
|
1587
|
+
})),
|
|
1588
|
+
});
|
|
1589
|
+
// Show speedup comparisons
|
|
1590
|
+
const dotProductResult = results.find(r => r.name.includes('DotProduct'));
|
|
1591
|
+
const flashResult = results.find(r => r.name.includes('Flash'));
|
|
1592
|
+
const hyperbolicResult = results.find(r => r.name.includes('Hyperbolic'));
|
|
1593
|
+
if (dotProductResult && flashResult) {
|
|
1594
|
+
const speedup = dotProductResult.averageTimeMs / flashResult.averageTimeMs;
|
|
1595
|
+
output.writeln();
|
|
1596
|
+
output.writeln(output.highlight(`Flash Attention speedup: ${speedup.toFixed(2)}x faster than DotProduct`));
|
|
1597
|
+
}
|
|
1598
|
+
if (dotProductResult && hyperbolicResult) {
|
|
1599
|
+
output.writeln(output.dim(`Hyperbolic overhead: ${(hyperbolicResult.averageTimeMs / dotProductResult.averageTimeMs).toFixed(2)}x (expected for manifold ops)`));
|
|
1600
|
+
}
|
|
1591
1601
|
}
|
|
1592
|
-
|
|
1593
|
-
|
|
1602
|
+
catch (attentionError) {
|
|
1603
|
+
spinner.fail(`Attention benchmark skipped: ${attentionError instanceof Error ? attentionError.message : String(attentionError)}`);
|
|
1594
1604
|
}
|
|
1595
1605
|
// Also benchmark MicroLoRA
|
|
1596
1606
|
spinner.start();
|
|
@@ -78,6 +78,17 @@ const SKILLS_MAP = {
|
|
|
78
78
|
'sparc-methodology',
|
|
79
79
|
'stream-chain',
|
|
80
80
|
],
|
|
81
|
+
// How and when to use the ecosystem packages ruflo ships or wires in:
|
|
82
|
+
// ruvector + @ruvector/mincut-wasm, @ruvector/rabitq-wasm, sublinear-time-solver,
|
|
83
|
+
// @claude-flow/aidefence, agent-booster, @ruvector/learning-wasm.
|
|
84
|
+
ecosystem: [
|
|
85
|
+
'vector-quantization',
|
|
86
|
+
'graph-mincut',
|
|
87
|
+
'sublinear-solver',
|
|
88
|
+
'injection-defense',
|
|
89
|
+
'fast-code-edits',
|
|
90
|
+
'lora-learning',
|
|
91
|
+
],
|
|
81
92
|
};
|
|
82
93
|
/**
|
|
83
94
|
* Commands to copy based on configuration
|
|
@@ -1087,6 +1098,8 @@ async function copySkills(targetDir, options, result) {
|
|
|
1087
1098
|
skillsToCopy.push(...SKILLS_MAP.dualMode);
|
|
1088
1099
|
if (skillsConfig.legacy)
|
|
1089
1100
|
skillsToCopy.push(...SKILLS_MAP.legacy);
|
|
1101
|
+
if (skillsConfig.ecosystem ?? true)
|
|
1102
|
+
skillsToCopy.push(...SKILLS_MAP.ecosystem);
|
|
1090
1103
|
}
|
|
1091
1104
|
// Find source skills directory
|
|
1092
1105
|
const sourceSkillsDir = findSourceDir('skills', options.sourceBaseDir);
|
|
@@ -78,6 +78,12 @@ export interface SkillsConfig {
|
|
|
78
78
|
dualMode: boolean;
|
|
79
79
|
/** Include legacy skills that document commands v3 does not ship (opt-in) */
|
|
80
80
|
legacy: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Include ecosystem skills (vector quantization, graph min-cut, sublinear
|
|
83
|
+
* solving, injection defense, fast code edits, LoRA learning). Optional so
|
|
84
|
+
* existing SkillsConfig literals stay valid; absent means on.
|
|
85
|
+
*/
|
|
86
|
+
ecosystem?: boolean;
|
|
81
87
|
/** Include all available skills */
|
|
82
88
|
all: boolean;
|
|
83
89
|
}
|
|
@@ -79,6 +79,7 @@ export const DEFAULT_INIT_OPTIONS = {
|
|
|
79
79
|
v3: false, // ADR-128: opt-in like agents.v3; use --full or `init skills --v3`
|
|
80
80
|
dualMode: false, // Optional: enable with --dual flag
|
|
81
81
|
legacy: false, // #4539: stream-chain/sparc document verbs v3 does not ship
|
|
82
|
+
ecosystem: true, // ruvector / agent-booster / aidefence usage skills
|
|
82
83
|
all: false,
|
|
83
84
|
},
|
|
84
85
|
commands: {
|
|
@@ -188,6 +189,7 @@ export const MINIMAL_INIT_OPTIONS = {
|
|
|
188
189
|
v3: false,
|
|
189
190
|
dualMode: false,
|
|
190
191
|
legacy: false,
|
|
192
|
+
ecosystem: false,
|
|
191
193
|
all: false,
|
|
192
194
|
},
|
|
193
195
|
agents: {
|
|
@@ -249,6 +251,7 @@ export const FULL_INIT_OPTIONS = {
|
|
|
249
251
|
v3: true,
|
|
250
252
|
dualMode: true, // Include in full init
|
|
251
253
|
legacy: true, // Include in full init
|
|
254
|
+
ecosystem: true,
|
|
252
255
|
all: true,
|
|
253
256
|
},
|
|
254
257
|
commands: {
|
|
@@ -13,6 +13,7 @@ import { swarmTools } from './mcp-tools/swarm-tools.js';
|
|
|
13
13
|
import { memoryTools } from './mcp-tools/memory-tools.js';
|
|
14
14
|
import { configTools } from './mcp-tools/config-tools.js';
|
|
15
15
|
import { hooksTools } from './mcp-tools/hooks-tools.js';
|
|
16
|
+
import { fastApplyTools } from './mcp-tools/fast-apply-tools.js';
|
|
16
17
|
import { taskTools } from './mcp-tools/task-tools.js';
|
|
17
18
|
import { sessionTools } from './mcp-tools/session-tools.js';
|
|
18
19
|
import { hiveMindTools } from './mcp-tools/hive-mind-tools.js';
|
|
@@ -131,6 +132,7 @@ registerTools([
|
|
|
131
132
|
...memoryTools,
|
|
132
133
|
...configTools,
|
|
133
134
|
...hooksTools,
|
|
135
|
+
...fastApplyTools,
|
|
134
136
|
...taskTools,
|
|
135
137
|
...sessionTools,
|
|
136
138
|
...hiveMindTools,
|
|
@@ -1502,6 +1502,8 @@ export const agentdbGraphPathfinder = {
|
|
|
1502
1502
|
}
|
|
1503
1503
|
const edges = rawEdges;
|
|
1504
1504
|
let paths = [];
|
|
1505
|
+
let mincutInfo;
|
|
1506
|
+
let approximation;
|
|
1505
1507
|
// Check millisecond budget before heavy computation
|
|
1506
1508
|
if (Date.now() - t0 > budget.maxMillis) {
|
|
1507
1509
|
return { success: true, paths: [], count: 0, message: `complexityBudget.maxMillis (${budget.maxMillis}ms) exceeded before solver dispatch`, seedNodeId, algorithm, elapsedMs: Date.now() - t0 };
|
|
@@ -1557,10 +1559,38 @@ export const agentdbGraphPathfinder = {
|
|
|
1557
1559
|
paths = witnessChain.slice(0, topK);
|
|
1558
1560
|
break;
|
|
1559
1561
|
}
|
|
1562
|
+
case 'dynamic-mincut': {
|
|
1563
|
+
// Exact minimum cut of the seed's depth-hop neighbourhood: the
|
|
1564
|
+
// weakest boundary around the seed, and the nodes on its side of it.
|
|
1565
|
+
// Wasm solver via ruvector (@ruvector/mincut-wasm), JS Stoer-Wagner
|
|
1566
|
+
// fallback for small neighbourhoods.
|
|
1567
|
+
const edgeTuples = edges.map(r => [String(r[0]), String(r[1]), Number(r[2]) || 1.0]);
|
|
1568
|
+
const { seedLocalMinCut } = await import('../ruvector/mincut-bridge.js');
|
|
1569
|
+
const { fallbackMinCut } = await import('../ruvector/graph-analyzer.js');
|
|
1570
|
+
const cut = await seedLocalMinCut(seedNodeId, edgeTuples, depth, budget.maxNodesVisited, fallbackMinCut);
|
|
1571
|
+
if (!cut) {
|
|
1572
|
+
mincutInfo = { backend: 'none', message: 'seed neighbourhood too large for the JS fallback and the wasm solver is unavailable (install ruvector)' };
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
paths = cut.seedSide
|
|
1576
|
+
.map(r => ({ nodeId: r.nodeId, score: 1 / (1 + r.depth), depth: r.depth }))
|
|
1577
|
+
.filter(r => r.score >= threshold)
|
|
1578
|
+
.slice(0, topK);
|
|
1579
|
+
mincutInfo = {
|
|
1580
|
+
backend: cut.backend,
|
|
1581
|
+
cutValue: cut.cutValue,
|
|
1582
|
+
seedSideSize: cut.seedSide.length + 1,
|
|
1583
|
+
otherSideSize: cut.otherSide.length,
|
|
1584
|
+
subgraphNodes: cut.subgraphNodes,
|
|
1585
|
+
cutEdges: cut.cutEdges.slice(0, 50),
|
|
1586
|
+
};
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1560
1589
|
case 'connected-component-churn':
|
|
1561
|
-
case 'dynamic-mincut':
|
|
1562
1590
|
case 'spectral-sparsify': {
|
|
1563
|
-
//
|
|
1591
|
+
// Not implemented natively yet: approximated by k-hop neighbours with
|
|
1592
|
+
// a rank-decay score. The response says so via `implementation`.
|
|
1593
|
+
approximation = 'k-hop';
|
|
1564
1594
|
const edgeTuples = edges.map(r => [r[0], r[1], Number(r[2]) || 1.0]);
|
|
1565
1595
|
const khopResult = await agentdbGraphQuery.handler({
|
|
1566
1596
|
nodeId: seedNodeId, mode: 'k-hop', depth, complexityBudget: budget,
|
|
@@ -1582,6 +1612,8 @@ export const agentdbGraphPathfinder = {
|
|
|
1582
1612
|
count: paths.length,
|
|
1583
1613
|
elapsedMs,
|
|
1584
1614
|
budgetUsed: { millis: elapsedMs, nodes: rawEdges.length },
|
|
1615
|
+
...(mincutInfo && { mincut: mincutInfo }),
|
|
1616
|
+
...(approximation && { implementation: `${approximation} approximation` }),
|
|
1585
1617
|
...(depthWarning && { warning: depthWarning }),
|
|
1586
1618
|
};
|
|
1587
1619
|
}
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* AgentDB index). They do not inline a replay engine; replay
|
|
14
14
|
* enumerates trajectory steps and returns them for the caller to dispatch.
|
|
15
15
|
* - ruvector resolution is local-first: if a locally installed `ruvector`
|
|
16
|
-
* package is found (the CLI
|
|
16
|
+
* package is found (the CLI depends on ruvector ^0.3.11), its bin
|
|
17
17
|
* is spawned directly with `node`; otherwise we fall back to
|
|
18
|
-
* `npx -y ruvector@0.
|
|
18
|
+
* `npx -y ruvector@0.3.12`. The previous 0.2.25 pin forced cold npx
|
|
19
19
|
* downloads of a *second* ruvector version — 4 per browser session.
|
|
20
20
|
* - Best-effort: missing dependencies (no `ruvector`, no `agent-browser`,
|
|
21
21
|
* no AgentDB controller) degrade gracefully with a structured error
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* AgentDB index). They do not inline a replay engine; replay
|
|
14
14
|
* enumerates trajectory steps and returns them for the caller to dispatch.
|
|
15
15
|
* - ruvector resolution is local-first: if a locally installed `ruvector`
|
|
16
|
-
* package is found (the CLI
|
|
16
|
+
* package is found (the CLI depends on ruvector ^0.3.11), its bin
|
|
17
17
|
* is spawned directly with `node`; otherwise we fall back to
|
|
18
|
-
* `npx -y ruvector@0.
|
|
18
|
+
* `npx -y ruvector@0.3.12`. The previous 0.2.25 pin forced cold npx
|
|
19
19
|
* downloads of a *second* ruvector version — 4 per browser session.
|
|
20
20
|
* - Best-effort: missing dependencies (no `ruvector`, no `agent-browser`,
|
|
21
21
|
* no AgentDB controller) degrade gracefully with a structured error
|
|
@@ -25,9 +25,9 @@ import { validateIdentifier, validateText } from './validate-input.js';
|
|
|
25
25
|
import { browserUrlError } from './browser-argv.js';
|
|
26
26
|
// Pin matches the version in this package's own dependency tree so the npx
|
|
27
27
|
// fallback never downloads a second ruvector. Subcommand surface verified
|
|
28
|
-
// against ruvector@0.
|
|
28
|
+
// against ruvector@0.3.12 --help (and earlier 0.2.27): `rvf create/compact/status/derive/segments`
|
|
29
29
|
// and `hooks trajectory-begin/step/end` all exist with the flags used below.
|
|
30
|
-
const RUVECTOR_PIN = 'ruvector@0.
|
|
30
|
+
const RUVECTOR_PIN = 'ruvector@0.3.12';
|
|
31
31
|
const RVF_DIR_DEFAULT = '.ruflo/browser-sessions';
|
|
32
32
|
async function shell(cmd, args, opts = {}) {
|
|
33
33
|
const { execFile } = await import('node:child_process');
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hooks_fast-apply — merge a code snippet into a file or string with
|
|
3
|
+
* agent-booster (~ms, no LLM). The caller supplies the target code; for
|
|
4
|
+
* deterministic intents with no snippet use hooks_codemod instead.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
7
|
+
import { resolve, sep } from 'path';
|
|
8
|
+
import { getProjectCwd } from './types.js';
|
|
9
|
+
import { validatePath } from './validate-input.js';
|
|
10
|
+
import { realpathNearest, isInsideRealRoot } from './realpath-containment.js';
|
|
11
|
+
const MAX_INPUT_BYTES = 1_000_000;
|
|
12
|
+
function langForPath(p) {
|
|
13
|
+
const ext = p.slice(p.lastIndexOf('.') + 1).toLowerCase();
|
|
14
|
+
const map = {
|
|
15
|
+
ts: 'typescript', tsx: 'typescript', mts: 'typescript', cts: 'typescript',
|
|
16
|
+
js: 'javascript', jsx: 'javascript', mjs: 'javascript', cjs: 'javascript',
|
|
17
|
+
py: 'python', rs: 'rust', go: 'go', java: 'java', c: 'c', cpp: 'cpp', h: 'c',
|
|
18
|
+
};
|
|
19
|
+
return map[ext];
|
|
20
|
+
}
|
|
21
|
+
export const hooksFastApply = {
|
|
22
|
+
name: 'hooks_fast-apply',
|
|
23
|
+
description: 'Merge an edit SNIPPET (the rewritten code, e.g. a whole new version of one function) into a file or raw code using agent-booster — a local fast-apply engine (~1-10 ms, no LLM, $0). `edit` must be code, not an instruction: "make add typed" fails, "function add(a: number, b: number): number { return a + b; }" works. Use when you already have the replacement code and the surrounding file is large, instead of re-sending the whole file. Deterministic intents (var-to-const, remove-console, add-logging) belong to hooks_codemod. Returns confidence + strategy; below minConfidence nothing is written.',
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
edit: { type: 'string', description: 'Target code snippet to merge (code, not an instruction)' },
|
|
28
|
+
file: { type: 'string', description: 'Existing file inside the project to patch in place' },
|
|
29
|
+
code: { type: 'string', description: 'Raw source to patch instead of a file (returns output, writes nothing)' },
|
|
30
|
+
language: { type: 'string', description: 'Language hint (inferred from the file extension when omitted)' },
|
|
31
|
+
minConfidence: { type: 'number', description: 'Minimum merge confidence 0-1 required to apply (default 0.5)' },
|
|
32
|
+
dryRun: { type: 'boolean', description: 'Report the merge result without writing the file' },
|
|
33
|
+
},
|
|
34
|
+
required: ['edit'],
|
|
35
|
+
},
|
|
36
|
+
handler: async (params) => {
|
|
37
|
+
const edit = params.edit;
|
|
38
|
+
if (typeof edit !== 'string' || edit.trim() === '')
|
|
39
|
+
return { success: false, error: 'edit (non-empty code snippet) is required' };
|
|
40
|
+
if (edit.length > MAX_INPUT_BYTES)
|
|
41
|
+
return { success: false, error: 'edit too large' };
|
|
42
|
+
const minConfidence = typeof params.minConfidence === 'number'
|
|
43
|
+
? Math.min(Math.max(params.minConfidence, 0), 1) : 0.5;
|
|
44
|
+
const dryRun = params.dryRun === true;
|
|
45
|
+
const { fastApply } = await import('../ruvector/fast-apply.js');
|
|
46
|
+
if (typeof params.code === 'string') {
|
|
47
|
+
if (params.code.length > MAX_INPUT_BYTES)
|
|
48
|
+
return { success: false, error: 'code too large' };
|
|
49
|
+
const r = await fastApply({ code: params.code, edit, language: params.language, minConfidence });
|
|
50
|
+
return { ...r, mode: 'code', cost: 0 };
|
|
51
|
+
}
|
|
52
|
+
if (typeof params.file !== 'string')
|
|
53
|
+
return { success: false, error: 'Provide `file` or `code`.' };
|
|
54
|
+
const v = validatePath(params.file, 'file');
|
|
55
|
+
if (!v.valid)
|
|
56
|
+
return { success: false, error: v.error };
|
|
57
|
+
const cwd = getProjectCwd();
|
|
58
|
+
const abs = resolve(cwd, v.sanitized);
|
|
59
|
+
if (abs !== cwd && !abs.startsWith(cwd + sep))
|
|
60
|
+
return { success: false, error: `path escapes project root: ${params.file}` };
|
|
61
|
+
let realRoot;
|
|
62
|
+
try {
|
|
63
|
+
realRoot = realpathNearest(cwd);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return { success: false, error: `cannot resolve project root: ${err.message}` };
|
|
67
|
+
}
|
|
68
|
+
if (!isInsideRealRoot(realRoot, abs))
|
|
69
|
+
return { success: false, error: `path escapes project root via symlink: ${params.file}` };
|
|
70
|
+
if (!existsSync(abs))
|
|
71
|
+
return { success: false, error: `file not found: ${params.file}` };
|
|
72
|
+
const before = readFileSync(abs, 'utf-8');
|
|
73
|
+
if (before.length > MAX_INPUT_BYTES)
|
|
74
|
+
return { success: false, error: 'file too large' };
|
|
75
|
+
const language = params.language ?? langForPath(abs);
|
|
76
|
+
const r = await fastApply({ code: before, edit, language, minConfidence });
|
|
77
|
+
const written = r.success && !dryRun;
|
|
78
|
+
if (written)
|
|
79
|
+
writeFileSync(abs, r.output, 'utf-8');
|
|
80
|
+
const { output, ...meta } = r;
|
|
81
|
+
return { ...meta, mode: dryRun ? 'dry-run' : 'file', file: params.file, written, ...(dryRun && { output }), cost: 0 };
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
export const fastApplyTools = [hooksFastApply];
|
|
85
|
+
//# sourceMappingURL=fast-apply-tools.js.map
|
|
@@ -5,9 +5,10 @@ import { feedbackPatternsSchema, validateFeedbackPatterns } from '../memory/feed
|
|
|
5
5
|
*/
|
|
6
6
|
import { mkdirSync, writeFileSync, existsSync, readFileSync, statSync, unlinkSync, readdirSync } from 'fs';
|
|
7
7
|
import * as nodeFs from 'fs';
|
|
8
|
-
import {
|
|
8
|
+
import { dirname, join, resolve, sep } from 'path';
|
|
9
9
|
import { getProjectCwd } from './types.js';
|
|
10
10
|
import { validateIdentifier, validateText, validatePath } from './validate-input.js';
|
|
11
|
+
import { realpathNearest, isInsideRealRoot } from './realpath-containment.js';
|
|
11
12
|
import { commandRecordingDisabled, redactCommandForStorage } from '../services/command-recording.js';
|
|
12
13
|
import { checkCommandLoop, recordCommandOutcome } from './tool-loop-guardrail.js';
|
|
13
14
|
import { buildLearnedRoutingPatterns, } from '../services/learned-routing.js';
|
|
@@ -2223,8 +2224,24 @@ export const hooksBuildAgents = {
|
|
|
2223
2224
|
return { success: false, error: v.error };
|
|
2224
2225
|
}
|
|
2225
2226
|
const outputDir = resolve(getProjectCwd(), params.outputDir || './agents');
|
|
2227
|
+
// validatePath allows absolute paths, so keep the real output dir inside
|
|
2228
|
+
// the real project root (CWE-22/59): configs are only ever project files.
|
|
2229
|
+
let realProjectRoot;
|
|
2230
|
+
try {
|
|
2231
|
+
realProjectRoot = nodeFs.realpathSync(getProjectCwd());
|
|
2232
|
+
}
|
|
2233
|
+
catch {
|
|
2234
|
+
realProjectRoot = getProjectCwd();
|
|
2235
|
+
}
|
|
2236
|
+
if (!isInsideRealRoot(realProjectRoot, outputDir)) {
|
|
2237
|
+
return { success: false, error: 'outputDir must be inside the project directory' };
|
|
2238
|
+
}
|
|
2226
2239
|
const focus = params.focus || 'all';
|
|
2227
|
-
|
|
2240
|
+
// format is spliced into each file name; only the two supported formats.
|
|
2241
|
+
const format = params.format === undefined ? 'yaml' : params.format;
|
|
2242
|
+
if (format !== 'yaml' && format !== 'json') {
|
|
2243
|
+
return { success: false, error: 'format must be "yaml" or "json"' };
|
|
2244
|
+
}
|
|
2228
2245
|
const persist = params.persist !== false; // Default to true
|
|
2229
2246
|
const agents = [
|
|
2230
2247
|
{ type: 'coder', configFile: join(outputDir, `coder.${format}`), capabilities: ['code-generation', 'refactoring', 'debugging'], optimizations: ['flash-attention', 'token-reduction'] },
|
|
@@ -5126,38 +5143,6 @@ function codemodLangForExt(abs) {
|
|
|
5126
5143
|
return 'javascript';
|
|
5127
5144
|
return 'typescript';
|
|
5128
5145
|
}
|
|
5129
|
-
// Canonicalize a path that may not exist yet: realpath the nearest existing
|
|
5130
|
-
// ancestor and re-attach the missing tail, so a symlinked parent still
|
|
5131
|
-
// resolves to its real location (mirrors @claude-flow/security's
|
|
5132
|
-
// canonicalizeSync, which is not exported).
|
|
5133
|
-
function realpathNearest(p) {
|
|
5134
|
-
try {
|
|
5135
|
-
return nodeFs.realpathSync(p);
|
|
5136
|
-
}
|
|
5137
|
-
catch (err) {
|
|
5138
|
-
if (err?.code !== 'ENOENT')
|
|
5139
|
-
throw err;
|
|
5140
|
-
}
|
|
5141
|
-
const parent = dirname(p);
|
|
5142
|
-
if (parent === p)
|
|
5143
|
-
return p;
|
|
5144
|
-
return join(realpathNearest(parent), basename(p));
|
|
5145
|
-
}
|
|
5146
|
-
// CWE-59 (#4346): containment must compare real paths on BOTH sides — a
|
|
5147
|
-
// symlink inside the project pointing outside it must not pass, and a
|
|
5148
|
-
// symlinked project root (e.g. macOS /var -> /private/var) must not make
|
|
5149
|
-
// every path fail. Fails closed if canonicalization throws (ELOOP, EACCES).
|
|
5150
|
-
function isInsideRealRoot(realRoot, abs) {
|
|
5151
|
-
let real;
|
|
5152
|
-
try {
|
|
5153
|
-
real = realpathNearest(abs);
|
|
5154
|
-
}
|
|
5155
|
-
catch {
|
|
5156
|
-
return false;
|
|
5157
|
-
}
|
|
5158
|
-
const rel = relative(realRoot, real);
|
|
5159
|
-
return rel === '' || (rel !== '..' && !rel.startsWith('..' + sep) && !isAbsolute(rel));
|
|
5160
|
-
}
|
|
5161
5146
|
// Deterministic codemod execution — the real Tier-1 path (ADR-143)
|
|
5162
5147
|
export const hooksCodemod = {
|
|
5163
5148
|
name: 'hooks_codemod',
|
|
@@ -399,7 +399,7 @@ export const metaharnessTools = [
|
|
|
399
399
|
},
|
|
400
400
|
// ───────────────────────────────────────────────────────────────────────
|
|
401
401
|
// ADR-153 — @metaharness/darwin integration (3 tools).
|
|
402
|
-
// Backed by the separate `@metaharness/darwin@~0.
|
|
402
|
+
// Backed by the separate `@metaharness/darwin@~0.13.0` npm package, NOT
|
|
403
403
|
// the umbrella `metaharness`. Plugin scripts shell out via _darwin.mjs.
|
|
404
404
|
// Same {success, data, degraded, exitCode} contract.
|
|
405
405
|
// ───────────────────────────────────────────────────────────────────────
|
|
@@ -72,7 +72,7 @@ function activeChampionParams() {
|
|
|
72
72
|
// command, because mcp-client statically imports this module. ensureEmbeddings()
|
|
73
73
|
// keeps the exact same tier chain and degraded/fallback semantics, but only
|
|
74
74
|
// pays the cost when a handler actually needs an embedding.
|
|
75
|
-
// Tier 0 (ADR-089): ruvector
|
|
75
|
+
// Tier 0 (ADR-089): ruvector bundled ONNX (since 0.2.27) (no sharp dep, fixes ADR-086's
|
|
76
76
|
// silent-fallback bug at source; closes the chain described in ruvnet/ruvector#523).
|
|
77
77
|
// Tier 1: agentic-flow v3 ReasoningBank (was Tier 1 — broken on darwin-arm64 without sharp)
|
|
78
78
|
// Tier 2-3: @claude-flow/embeddings
|
|
@@ -110,7 +110,7 @@ function ensureEmbeddings() {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
catch { /* not configured — fall through */ }
|
|
113
|
-
// Tier 0: ruvector
|
|
113
|
+
// Tier 0: ruvector (CLI dependency) — bundled all-MiniLM-L6-v2 + parallel worker pool.
|
|
114
114
|
// Probe with isOnnxAvailable() and verify an actual embed succeeds (avoids
|
|
115
115
|
// the type-load-success-but-runtime-fails trap from ADR-086). The probe now
|
|
116
116
|
// runs on first embed request instead of at import time.
|
|
@@ -133,7 +133,7 @@ function ensureEmbeddings() {
|
|
|
133
133
|
return Array.isArray(v) ? v : Array.from(v);
|
|
134
134
|
},
|
|
135
135
|
};
|
|
136
|
-
embeddingServiceName = 'ruvector
|
|
136
|
+
embeddingServiceName = 'ruvector (bundled all-MiniLM-L6-v2)';
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
catch {
|