claude-flow 3.72.0 → 3.72.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.
Files changed (52) hide show
  1. package/node_modules/@claude-flow/codex/.agents/skills/fast-code-edits/SKILL.md +42 -0
  2. package/node_modules/@claude-flow/codex/.agents/skills/graph-mincut/SKILL.md +42 -0
  3. package/node_modules/@claude-flow/codex/.agents/skills/injection-defense/SKILL.md +45 -0
  4. package/node_modules/@claude-flow/codex/.agents/skills/lora-learning/SKILL.md +39 -0
  5. package/node_modules/@claude-flow/codex/.agents/skills/sublinear-solver/SKILL.md +38 -0
  6. package/node_modules/@claude-flow/codex/.agents/skills/vector-quantization/SKILL.md +49 -0
  7. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -1
  8. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +6 -0
  9. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -1
  10. package/node_modules/@claude-flow/codex/dist/index.d.ts +3 -3
  11. package/node_modules/@claude-flow/codex/dist/index.js +1 -1
  12. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -1
  13. package/node_modules/@claude-flow/codex/dist/templates/index.js +37 -0
  14. package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -1
  15. package/node_modules/@claude-flow/codex/dist/types.d.ts +1 -1
  16. package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -1
  17. package/node_modules/@claude-flow/codex/package.json +1 -1
  18. package/package.json +9 -6
  19. package/v3/@claude-flow/cli/catalog-manifest.json +4 -4
  20. package/v3/@claude-flow/cli/dist/src/appliance/ruvllm-bridge.d.ts +6 -2
  21. package/v3/@claude-flow/cli/dist/src/appliance/ruvllm-bridge.js +13 -8
  22. package/v3/@claude-flow/cli/dist/src/commands/init.js +2 -0
  23. package/v3/@claude-flow/cli/dist/src/commands/neural.js +79 -71
  24. package/v3/@claude-flow/cli/dist/src/init/executor.js +13 -0
  25. package/v3/@claude-flow/cli/dist/src/init/types.d.ts +6 -0
  26. package/v3/@claude-flow/cli/dist/src/init/types.js +3 -0
  27. package/v3/@claude-flow/cli/dist/src/mcp-client.js +2 -0
  28. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +34 -2
  29. package/v3/@claude-flow/cli/dist/src/mcp-tools/fast-apply-tools.d.ts +4 -0
  30. package/v3/@claude-flow/cli/dist/src/mcp-tools/fast-apply-tools.js +85 -0
  31. package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +2 -33
  32. package/v3/@claude-flow/cli/dist/src/mcp-tools/metaharness-tools.js +1 -1
  33. package/v3/@claude-flow/cli/dist/src/mcp-tools/realpath-containment.d.ts +3 -0
  34. package/v3/@claude-flow/cli/dist/src/mcp-tools/realpath-containment.js +39 -0
  35. package/v3/@claude-flow/cli/dist/src/mods/command-registry/schema.d.ts +12 -12
  36. package/v3/@claude-flow/cli/dist/src/ruvector/ast-analyzer.d.ts +1 -2
  37. package/v3/@claude-flow/cli/dist/src/ruvector/ast-analyzer.js +4 -12
  38. package/v3/@claude-flow/cli/dist/src/ruvector/coverage-router.d.ts +1 -2
  39. package/v3/@claude-flow/cli/dist/src/ruvector/coverage-router.js +4 -12
  40. package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.d.ts +1 -2
  41. package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.js +3 -12
  42. package/v3/@claude-flow/cli/dist/src/ruvector/fast-apply.d.ts +46 -0
  43. package/v3/@claude-flow/cli/dist/src/ruvector/fast-apply.js +73 -0
  44. package/v3/@claude-flow/cli/dist/src/ruvector/graph-analyzer.d.ts +11 -1
  45. package/v3/@claude-flow/cli/dist/src/ruvector/graph-analyzer.js +22 -36
  46. package/v3/@claude-flow/cli/dist/src/ruvector/mincut-bridge.d.ts +70 -0
  47. package/v3/@claude-flow/cli/dist/src/ruvector/mincut-bridge.js +172 -0
  48. package/v3/@claude-flow/cli/dist/src/services/distill-oracle.d.ts +1 -1
  49. package/v3/@claude-flow/cli/dist/src/services/distill-oracle.js +2 -2
  50. package/v3/@claude-flow/cli/package.json +11 -9
  51. package/.claude/.proven-config-version +0 -1
  52. package/.claude/proven-config.json +0 -42
@@ -22,24 +22,16 @@ const LANGUAGE_PATTERNS = {
22
22
  };
23
23
  export class ASTAnalyzer {
24
24
  config;
25
- ruvectorEngine = null;
26
25
  useNative = false;
27
26
  analysisCache = new Map();
28
27
  constructor(config = {}) {
29
28
  this.config = { ...DEFAULT_CONFIG, ...config };
30
29
  }
31
30
  async initialize() {
32
- try {
33
- // @ruvector/ast is optional - gracefully fallback if not installed
34
- const ruvector = await import('@ruvector/ast').catch(() => null);
35
- if (ruvector) {
36
- this.ruvectorEngine = ruvector.createASTAnalyzer?.(this.config);
37
- this.useNative = !!this.ruvectorEngine;
38
- }
39
- }
40
- catch {
41
- this.useNative = false;
42
- }
31
+ // Pure-JS analysis. This used to try `import('@ruvector/ast')`, a package that has
32
+ // never been published (npm 404), so it always fell through to here. ruvector@0.3's
33
+ // ASTParser needs the native tree-sitter grammars and is async-only, so it cannot
34
+ // back this synchronous analyzer.
43
35
  }
44
36
  analyze(code, filePath = 'unknown') {
45
37
  const startTime = performance.now();
@@ -63,8 +63,7 @@ export interface CoverageRouteResult {
63
63
  }
64
64
  export declare class CoverageRouter {
65
65
  private config;
66
- private ruvectorEngine;
67
- private useNative;
66
+ private readonly useNative;
68
67
  private coverageHistory;
69
68
  constructor(config?: Partial<CoverageRouterConfig>);
70
69
  initialize(): Promise<void>;
@@ -37,24 +37,16 @@ const DEFAULT_CONFIG = {
37
37
  };
38
38
  export class CoverageRouter {
39
39
  config;
40
- ruvectorEngine = null;
41
40
  useNative = false;
42
41
  coverageHistory = [];
43
42
  constructor(config = {}) {
44
43
  this.config = { ...DEFAULT_CONFIG, ...config };
45
44
  }
46
45
  async initialize() {
47
- try {
48
- // @ruvector/coverage is optional - gracefully fallback if not installed
49
- const ruvector = await import('@ruvector/coverage').catch(() => null);
50
- if (ruvector) {
51
- this.ruvectorEngine = ruvector.createCoverageRouter?.(this.config);
52
- this.useNative = !!this.ruvectorEngine;
53
- }
54
- }
55
- catch {
56
- this.useNative = false;
57
- }
46
+ // Pure-JS analysis. This used to try `import('@ruvector/coverage')`, a package that
47
+ // has never been published (npm 404), so it always fell through to here.
48
+ // ruvector@0.3's parseIstanbulCoverage is a plain-JS parser equivalent to the parsers
49
+ // below.
58
50
  }
59
51
  parseCoverage(data, format = 'json') {
60
52
  switch (format) {
@@ -49,8 +49,7 @@ export interface DiffAnalysis {
49
49
  }
50
50
  export declare class DiffClassifier {
51
51
  private config;
52
- private ruvectorEngine;
53
- private useNative;
52
+ private readonly useNative;
54
53
  private classificationCache;
55
54
  constructor(config?: Partial<DiffClassifierConfig>);
56
55
  initialize(): Promise<void>;
@@ -60,24 +60,15 @@ function isSecuritySensitivePath(path) {
60
60
  }
61
61
  export class DiffClassifier {
62
62
  config;
63
- ruvectorEngine = null;
64
63
  useNative = false;
65
64
  classificationCache = new Map();
66
65
  constructor(config = {}) {
67
66
  this.config = { ...DEFAULT_CONFIG, ...config };
68
67
  }
69
68
  async initialize() {
70
- try {
71
- // @ruvector/diff is optional - gracefully fallback if not installed
72
- const ruvector = await import('@ruvector/diff').catch(() => null);
73
- if (ruvector) {
74
- this.ruvectorEngine = ruvector.createDiffClassifier?.(this.config);
75
- this.useNative = !!this.ruvectorEngine;
76
- }
77
- }
78
- catch {
79
- this.useNative = false;
80
- }
69
+ // Pure-JS analysis. This used to try `import('@ruvector/diff')`, a package that has
70
+ // never been published (npm 404), so it always fell through to here. ruvector@0.3's
71
+ // parseDiff is a plain-JS parser equivalent to parseDiff() below.
81
72
  }
82
73
  parseDiff(diffContent) {
83
74
  const files = [];
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Fast-apply: merge an edit snippet into existing code with agent-booster.
3
+ *
4
+ * agent-booster is a Morph/Cursor-style *applier*: `apply({ code, edit })`
5
+ * expects `edit` to be the target code (e.g. the rewritten function), and it
6
+ * locates and splices it into `code` in a few milliseconds with no LLM call.
7
+ * It cannot turn a natural-language instruction into an edit — given one it
8
+ * returns `success: false, strategy: "failed"` (see ADR-143). So this is the
9
+ * path for callers that already hold a snippet (an agent's proposed rewrite),
10
+ * not a Tier-1 intent engine; deterministic intents stay in hooks_codemod.
11
+ */
12
+ export interface FastApplyRequest {
13
+ code: string;
14
+ edit: string;
15
+ language?: string;
16
+ /** Results below this confidence are reported as not applied. Default 0.5. */
17
+ minConfidence?: number;
18
+ }
19
+ export interface FastApplyResult {
20
+ success: boolean;
21
+ output: string;
22
+ confidence: number;
23
+ strategy: string;
24
+ latencyMs: number;
25
+ backend: 'agent-booster' | 'unavailable';
26
+ reason?: string;
27
+ }
28
+ interface BoosterLike {
29
+ apply(req: {
30
+ code: string;
31
+ edit: string;
32
+ language?: string;
33
+ }): Promise<{
34
+ output: string;
35
+ success: boolean;
36
+ confidence: number;
37
+ strategy: string;
38
+ }>;
39
+ }
40
+ /** Lazily construct one AgentBooster. Resolves null when it is not installed. */
41
+ export declare function loadAgentBooster(): Promise<BoosterLike | null>;
42
+ /** Test hook: forget the memoised AgentBooster. */
43
+ export declare function resetAgentBoosterLoader(): void;
44
+ export declare function fastApply(req: FastApplyRequest): Promise<FastApplyResult>;
45
+ export {};
46
+ //# sourceMappingURL=fast-apply.d.ts.map
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Fast-apply: merge an edit snippet into existing code with agent-booster.
3
+ *
4
+ * agent-booster is a Morph/Cursor-style *applier*: `apply({ code, edit })`
5
+ * expects `edit` to be the target code (e.g. the rewritten function), and it
6
+ * locates and splices it into `code` in a few milliseconds with no LLM call.
7
+ * It cannot turn a natural-language instruction into an edit — given one it
8
+ * returns `success: false, strategy: "failed"` (see ADR-143). So this is the
9
+ * path for callers that already hold a snippet (an agent's proposed rewrite),
10
+ * not a Tier-1 intent engine; deterministic intents stay in hooks_codemod.
11
+ */
12
+ let boosterPromise = null;
13
+ /** Lazily construct one AgentBooster. Resolves null when it is not installed. */
14
+ export function loadAgentBooster() {
15
+ if (!boosterPromise) {
16
+ boosterPromise = (async () => {
17
+ try {
18
+ const specifier = 'agent-booster';
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- optional dep
20
+ const mod = await import(specifier);
21
+ const Ctor = mod?.AgentBooster ?? mod?.default?.AgentBooster ?? mod?.default;
22
+ if (typeof Ctor !== 'function')
23
+ return null;
24
+ // Our own threshold is applied below; let the engine report everything.
25
+ return new Ctor({ confidenceThreshold: 0 });
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ })();
31
+ }
32
+ return boosterPromise;
33
+ }
34
+ /** Test hook: forget the memoised AgentBooster. */
35
+ export function resetAgentBoosterLoader() {
36
+ boosterPromise = null;
37
+ }
38
+ export async function fastApply(req) {
39
+ const start = performance.now();
40
+ const minConfidence = req.minConfidence ?? 0.5;
41
+ const booster = await loadAgentBooster();
42
+ if (!booster) {
43
+ return {
44
+ success: false, output: req.code, confidence: 0, strategy: 'none',
45
+ latencyMs: performance.now() - start, backend: 'unavailable',
46
+ reason: 'agent-booster is not installed (npm i agent-booster); apply the edit with the Edit tool instead',
47
+ };
48
+ }
49
+ try {
50
+ const r = await booster.apply({ code: req.code, edit: req.edit, language: req.language });
51
+ const applied = r.success && r.confidence >= minConfidence && r.output !== req.code;
52
+ return {
53
+ success: applied,
54
+ output: applied ? r.output : req.code,
55
+ confidence: r.confidence,
56
+ strategy: r.strategy,
57
+ latencyMs: performance.now() - start,
58
+ backend: 'agent-booster',
59
+ reason: applied ? undefined
60
+ : !r.success ? 'agent-booster could not place the snippet (it must be code, not an instruction)'
61
+ : r.output === req.code ? 'snippet is already present; nothing to change'
62
+ : `confidence ${r.confidence.toFixed(2)} below minConfidence ${minConfidence}`,
63
+ };
64
+ }
65
+ catch (err) {
66
+ return {
67
+ success: false, output: req.code, confidence: 0, strategy: 'error',
68
+ latencyMs: performance.now() - start, backend: 'agent-booster',
69
+ reason: `agent-booster threw: ${err.message}`,
70
+ };
71
+ }
72
+ }
73
+ //# sourceMappingURL=fast-apply.js.map
@@ -121,9 +121,19 @@ interface IRuVectorGraph {
121
121
  };
122
122
  }
123
123
  /**
124
- * Attempt to load ruvector graph algorithms
124
+ * Load the accelerated graph backend.
125
+ *
126
+ * MinCut runs on ruvector's `DynamicMinCut` (the `@ruvector/mincut-wasm`
127
+ * solver ruvector ships as an optional dependency), see mincut-bridge.ts.
128
+ * Inputs the wasm solver cannot describe (isolated nodes, no edges) and
129
+ * Louvain go to the built-in JS implementations — ruvector's own
130
+ * `louvainCommunities` is plain JS too, so there is nothing to gain there.
131
+ * Returns null when the wasm solver is unavailable; callers then use the
132
+ * built-in Stoer-Wagner `fallbackMinCut`.
125
133
  */
126
134
  declare function loadRuVector(): Promise<IRuVectorGraph | null>;
135
+ /** Which MinCut backend `analyzeMinCutBoundaries` will use. */
136
+ export declare function getMinCutBackend(): Promise<'mincut-wasm' | 'stoer-wagner'>;
127
137
  /**
128
138
  * Build dependency graph from source directory (with caching)
129
139
  */
@@ -12,6 +12,7 @@
12
12
  * @module @claude-flow/cli/ruvector/graph-analyzer
13
13
  */
14
14
  import { readFile, readdir, stat } from 'fs/promises';
15
+ import { loadWasmMinCut, minCutWith } from './mincut-bridge.js';
15
16
  import { join, relative, extname, dirname, basename } from 'path';
16
17
  // ============================================================================
17
18
  // Caching for Performance
@@ -45,47 +46,32 @@ export function getGraphCacheStats() {
45
46
  let ruVectorGraph = null;
46
47
  let ruVectorLoadAttempted = false;
47
48
  /**
48
- * Attempt to load ruvector graph algorithms
49
+ * Load the accelerated graph backend.
50
+ *
51
+ * MinCut runs on ruvector's `DynamicMinCut` (the `@ruvector/mincut-wasm`
52
+ * solver ruvector ships as an optional dependency), see mincut-bridge.ts.
53
+ * Inputs the wasm solver cannot describe (isolated nodes, no edges) and
54
+ * Louvain go to the built-in JS implementations — ruvector's own
55
+ * `louvainCommunities` is plain JS too, so there is nothing to gain there.
56
+ * Returns null when the wasm solver is unavailable; callers then use the
57
+ * built-in Stoer-Wagner `fallbackMinCut`.
49
58
  */
50
59
  async function loadRuVector() {
51
60
  if (ruVectorLoadAttempted)
52
61
  return ruVectorGraph;
53
62
  ruVectorLoadAttempted = true;
54
- // Use dynamic module names to bypass TypeScript static analysis
55
- // These modules are optional and may not be installed
56
- const ruvectorModule = 'ruvector';
57
- const wasmModule = '@ruvector/wasm';
58
- try {
59
- // Try to load ruvector's graph module
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- const ruvector = await import(/* webpackIgnore: true */ ruvectorModule).catch(() => null);
62
- if (ruvector && typeof ruvector.hooks_graph_mincut === 'function' && typeof ruvector.hooks_graph_cluster === 'function') {
63
- ruVectorGraph = {
64
- mincut: (nodes, edges) => ruvector.hooks_graph_mincut(nodes, edges),
65
- louvain: (nodes, edges) => ruvector.hooks_graph_cluster(nodes, edges),
66
- };
67
- return ruVectorGraph;
68
- }
69
- }
70
- catch {
71
- // Try alternative import paths
72
- try {
73
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
- const wasm = await import(/* webpackIgnore: true */ wasmModule).catch(() => null);
75
- if (wasm && wasm.GraphAnalyzer) {
76
- const analyzer = new wasm.GraphAnalyzer();
77
- ruVectorGraph = {
78
- mincut: (nodes, edges) => analyzer.mincut(nodes, edges),
79
- louvain: (nodes, edges) => analyzer.louvain(nodes, edges),
80
- };
81
- return ruVectorGraph;
82
- }
83
- }
84
- catch {
85
- // Fallback will be used
86
- }
87
- }
88
- return null;
63
+ const Ctor = await loadWasmMinCut();
64
+ if (!Ctor)
65
+ return null;
66
+ ruVectorGraph = {
67
+ mincut: (nodes, edges) => minCutWith(Ctor, nodes, edges) ?? fallbackMinCut(nodes, edges),
68
+ louvain: (nodes, edges) => fallbackLouvain(nodes, edges),
69
+ };
70
+ return ruVectorGraph;
71
+ }
72
+ /** Which MinCut backend `analyzeMinCutBoundaries` will use. */
73
+ export async function getMinCutBackend() {
74
+ return (await loadRuVector()) ? 'mincut-wasm' : 'stoer-wagner';
89
75
  }
90
76
  // ============================================================================
91
77
  // Import/Require Parser
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Exact global minimum cut over an undirected weighted graph.
3
+ *
4
+ * Fast path: `ruvector`'s `DynamicMinCut`, a wrapper over the
5
+ * `@ruvector/mincut-wasm` solver that ruvector ships as one of its own
6
+ * optional dependencies. Measured on a 1,000-node / 2,000-edge graph it is
7
+ * ~30x faster than a JS Stoer-Wagner (187 ms vs 6 s) and returns the same cut
8
+ * value. When ruvector or its wasm solver is not installed, callers fall back
9
+ * to their own JS implementation (`fallbackMinCut` in graph-analyzer.ts).
10
+ *
11
+ * The wasm solver rejects duplicate edges ("Edge already exists"), so edges are
12
+ * folded into one undirected edge per node pair with summed weight, and
13
+ * self-loops are dropped (they never cross a cut).
14
+ */
15
+ export interface MinCutResult {
16
+ cutValue: number;
17
+ partition1: string[];
18
+ partition2: string[];
19
+ cutEdges: Array<[string, string]>;
20
+ }
21
+ export type MinCutBackend = 'mincut-wasm' | 'js-fallback';
22
+ interface DynamicMinCutLike {
23
+ insertEdge(from: string, to: string, weight?: number): number;
24
+ minCutValue(): number;
25
+ partition(): string[][];
26
+ }
27
+ export type DynamicMinCutCtor = new () => DynamicMinCutLike;
28
+ /**
29
+ * Resolve ruvector's `DynamicMinCut` once. Returns null (never throws) when
30
+ * ruvector is absent or its `@ruvector/mincut-wasm` solver cannot load.
31
+ */
32
+ export declare function loadWasmMinCut(): Promise<DynamicMinCutCtor | null>;
33
+ /** Test hook: forget the memoised loader result. */
34
+ export declare function resetMinCutLoader(): void;
35
+ /**
36
+ * Compute the exact minimum cut with the wasm solver. Returns null when the
37
+ * solver is unavailable or the input is degenerate (fewer than two nodes, no
38
+ * edges, or nodes with no incident edge — an isolated node is a zero-weight
39
+ * cut that the solver never sees, so the JS fallback answers those).
40
+ */
41
+ export declare function wasmMinCut(nodes: string[], edges: Array<[string, string, number]>): Promise<MinCutResult | null>;
42
+ /** Synchronous variant for callers that already hold the loaded solver class. */
43
+ export declare function minCutWith(Ctor: DynamicMinCutCtor, nodes: string[], edges: Array<[string, string, number]>): MinCutResult | null;
44
+ export interface SeedMinCutResult {
45
+ /** Nodes on the seed's side of the cut, nearest (fewest hops) first. */
46
+ seedSide: Array<{
47
+ nodeId: string;
48
+ depth: number;
49
+ }>;
50
+ otherSide: string[];
51
+ cutValue: number;
52
+ cutEdges: Array<[string, string]>;
53
+ backend: MinCutBackend;
54
+ /** Size of the seed's depth-bounded neighbourhood the cut was computed on. */
55
+ subgraphNodes: number;
56
+ }
57
+ /** Above this many nodes the O(n^3) JS fallback is not attempted. */
58
+ export declare const JS_FALLBACK_MAX_NODES = 300;
59
+ /**
60
+ * Minimum cut of the seed's `depth`-hop neighbourhood (edges treated as
61
+ * undirected, at most `maxNodes` nodes). Answers "where is the weakest
62
+ * boundary around this node, and what sits on its side of it?".
63
+ *
64
+ * Uses the wasm solver when available, else `fallback` (a JS exact min cut)
65
+ * for neighbourhoods up to JS_FALLBACK_MAX_NODES nodes. Returns null when the
66
+ * seed has no neighbours or no backend can handle the neighbourhood.
67
+ */
68
+ export declare function seedLocalMinCut(seed: string, edges: Array<[string, string, number]>, depth: number, maxNodes: number, fallback: (nodes: string[], edges: Array<[string, string, number]>) => MinCutResult): Promise<SeedMinCutResult | null>;
69
+ export {};
70
+ //# sourceMappingURL=mincut-bridge.d.ts.map
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Exact global minimum cut over an undirected weighted graph.
3
+ *
4
+ * Fast path: `ruvector`'s `DynamicMinCut`, a wrapper over the
5
+ * `@ruvector/mincut-wasm` solver that ruvector ships as one of its own
6
+ * optional dependencies. Measured on a 1,000-node / 2,000-edge graph it is
7
+ * ~30x faster than a JS Stoer-Wagner (187 ms vs 6 s) and returns the same cut
8
+ * value. When ruvector or its wasm solver is not installed, callers fall back
9
+ * to their own JS implementation (`fallbackMinCut` in graph-analyzer.ts).
10
+ *
11
+ * The wasm solver rejects duplicate edges ("Edge already exists"), so edges are
12
+ * folded into one undirected edge per node pair with summed weight, and
13
+ * self-loops are dropped (they never cross a cut).
14
+ */
15
+ let ctorPromise = null;
16
+ /**
17
+ * Resolve ruvector's `DynamicMinCut` once. Returns null (never throws) when
18
+ * ruvector is absent or its `@ruvector/mincut-wasm` solver cannot load.
19
+ */
20
+ export function loadWasmMinCut() {
21
+ if (!ctorPromise) {
22
+ ctorPromise = (async () => {
23
+ try {
24
+ const specifier = 'ruvector';
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- optional dep
26
+ const mod = await import(specifier);
27
+ const rv = mod?.DynamicMinCut ? mod : mod?.default;
28
+ if (typeof rv?.DynamicMinCut !== 'function')
29
+ return null;
30
+ if (typeof rv.isMinCutWasmAvailable === 'function' && !rv.isMinCutWasmAvailable())
31
+ return null;
32
+ return rv.DynamicMinCut;
33
+ }
34
+ catch {
35
+ return null;
36
+ }
37
+ })();
38
+ }
39
+ return ctorPromise;
40
+ }
41
+ /** Test hook: forget the memoised loader result. */
42
+ export function resetMinCutLoader() {
43
+ ctorPromise = null;
44
+ }
45
+ function foldEdges(edges) {
46
+ const folded = new Map();
47
+ for (const [u, v, rawW] of edges) {
48
+ if (u === v)
49
+ continue;
50
+ const w = Number.isFinite(rawW) && rawW > 0 ? rawW : 1;
51
+ const [a, b] = u < v ? [u, v] : [v, u];
52
+ const key = `${a}\u0000${b}`;
53
+ const prev = folded.get(key);
54
+ if (prev)
55
+ prev[2] += w;
56
+ else
57
+ folded.set(key, [a, b, w]);
58
+ }
59
+ return folded;
60
+ }
61
+ /**
62
+ * Compute the exact minimum cut with the wasm solver. Returns null when the
63
+ * solver is unavailable or the input is degenerate (fewer than two nodes, no
64
+ * edges, or nodes with no incident edge — an isolated node is a zero-weight
65
+ * cut that the solver never sees, so the JS fallback answers those).
66
+ */
67
+ export async function wasmMinCut(nodes, edges) {
68
+ const Ctor = await loadWasmMinCut();
69
+ return Ctor ? minCutWith(Ctor, nodes, edges) : null;
70
+ }
71
+ /** Synchronous variant for callers that already hold the loaded solver class. */
72
+ export function minCutWith(Ctor, nodes, edges) {
73
+ if (nodes.length < 2)
74
+ return null;
75
+ const nodeSet = new Set(nodes);
76
+ const folded = foldEdges(edges.filter(([u, v]) => nodeSet.has(u) && nodeSet.has(v)));
77
+ if (folded.size === 0)
78
+ return null;
79
+ const touched = new Set();
80
+ for (const [a, b] of folded.values()) {
81
+ touched.add(a);
82
+ touched.add(b);
83
+ }
84
+ if (touched.size !== nodeSet.size)
85
+ return null;
86
+ try {
87
+ const solver = new Ctor();
88
+ for (const [a, b, w] of folded.values())
89
+ solver.insertEdge(a, b, w);
90
+ const groups = solver.partition();
91
+ const partition1 = groups[0] ?? [];
92
+ const side = new Set(partition1);
93
+ const partition2 = groups[1] ?? nodes.filter(n => !side.has(n));
94
+ const cutEdges = [];
95
+ for (const [u, v] of edges) {
96
+ if (u !== v && nodeSet.has(u) && nodeSet.has(v) && side.has(u) !== side.has(v))
97
+ cutEdges.push([u, v]);
98
+ }
99
+ return { cutValue: solver.minCutValue(), partition1, partition2, cutEdges };
100
+ }
101
+ catch {
102
+ return null;
103
+ }
104
+ }
105
+ /** Above this many nodes the O(n^3) JS fallback is not attempted. */
106
+ export const JS_FALLBACK_MAX_NODES = 300;
107
+ /**
108
+ * Minimum cut of the seed's `depth`-hop neighbourhood (edges treated as
109
+ * undirected, at most `maxNodes` nodes). Answers "where is the weakest
110
+ * boundary around this node, and what sits on its side of it?".
111
+ *
112
+ * Uses the wasm solver when available, else `fallback` (a JS exact min cut)
113
+ * for neighbourhoods up to JS_FALLBACK_MAX_NODES nodes. Returns null when the
114
+ * seed has no neighbours or no backend can handle the neighbourhood.
115
+ */
116
+ export async function seedLocalMinCut(seed, edges, depth, maxNodes, fallback) {
117
+ const adj = new Map();
118
+ for (const [u, v] of edges) {
119
+ if (u === v)
120
+ continue;
121
+ if (!adj.has(u))
122
+ adj.set(u, new Set());
123
+ if (!adj.has(v))
124
+ adj.set(v, new Set());
125
+ adj.get(u).add(v);
126
+ adj.get(v).add(u);
127
+ }
128
+ if (!adj.has(seed))
129
+ return null;
130
+ const hops = new Map([[seed, 0]]);
131
+ let frontier = [seed];
132
+ for (let d = 1; d <= depth && frontier.length > 0 && hops.size < maxNodes; d++) {
133
+ const next = [];
134
+ for (const n of frontier) {
135
+ for (const m of adj.get(n) ?? []) {
136
+ if (hops.has(m) || hops.size >= maxNodes)
137
+ continue;
138
+ hops.set(m, d);
139
+ next.push(m);
140
+ }
141
+ }
142
+ frontier = next;
143
+ }
144
+ if (hops.size < 2)
145
+ return null;
146
+ const nodes = Array.from(hops.keys());
147
+ const sub = edges.filter(([u, v]) => u !== v && hops.has(u) && hops.has(v));
148
+ let backend = 'mincut-wasm';
149
+ let cut = await wasmMinCut(nodes, sub);
150
+ if (!cut) {
151
+ if (nodes.length > JS_FALLBACK_MAX_NODES)
152
+ return null;
153
+ backend = 'js-fallback';
154
+ cut = fallback(nodes, sub);
155
+ }
156
+ const seedInFirst = cut.partition1.includes(seed);
157
+ const mine = seedInFirst ? cut.partition1 : cut.partition2;
158
+ const other = seedInFirst ? cut.partition2 : cut.partition1;
159
+ const seedSide = mine
160
+ .filter(n => n !== seed)
161
+ .map(n => ({ nodeId: n, depth: hops.get(n) ?? depth }))
162
+ .sort((a, b) => a.depth - b.depth || a.nodeId.localeCompare(b.nodeId));
163
+ return {
164
+ seedSide,
165
+ otherSide: other,
166
+ cutValue: cut.cutValue,
167
+ cutEdges: cut.cutEdges,
168
+ backend,
169
+ subgraphNodes: nodes.length,
170
+ };
171
+ }
172
+ //# sourceMappingURL=mincut-bridge.js.map
@@ -36,7 +36,7 @@
36
36
  */
37
37
  import { type VerifyTaskKind } from '../ruvector/output-verifier.js';
38
38
  import { FableHarness, type ReflectItem, type ReflectResult } from './fable-harness.js';
39
- export declare const MH_DARWIN_PIN = "0.12.0";
39
+ export declare const MH_DARWIN_PIN = "0.13.0";
40
40
  export type ResolvedProvenance = 'oracle:test-exec' | 'judge:fable' | 'proxy:structural';
41
41
  /** SWE-bench-shaped / bench-suite-mapped test spec that Tier 1 can execute. */
42
42
  export interface TestSpec {
@@ -43,9 +43,9 @@ import { FableHarness, } from './fable-harness.js';
43
43
  // behavior mid-run (the #142 pin-drift failure mode). Pin it, and let
44
44
  // scripts/check-metaharness-pins.mjs watch this constant for drift. Kept in
45
45
  // lock-step with the optionalDependencies pin in package.json and the plugin
46
- // darwin cache (versioned by the plugin's own `~0.12.0` pin in _darwin.mjs;
46
+ // darwin cache (versioned by the plugin's own `~0.13.0` pin in _darwin.mjs;
47
47
  // both are checked by scripts/check-metaharness-pins.mjs — #3366).
48
- export const MH_DARWIN_PIN = '0.12.0';
48
+ export const MH_DARWIN_PIN = '0.13.0';
49
49
  // ── Public API ───────────────────────────────────────────────────────────
50
50
  /**
51
51
  * Label each trajectory with `resolved` + honest provenance, trying the tiers
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.72.0",
3
+ "version": "3.72.1",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",
@@ -102,7 +102,7 @@
102
102
  "dependencies": {
103
103
  "@electron/asar": "^4.3.1",
104
104
  "@claude-flow/cli-core": "3.7.5",
105
- "@claude-flow/codex": "3.0.5",
105
+ "@claude-flow/codex": "3.0.6",
106
106
  "@claude-flow/mcp": "3.1.6",
107
107
  "@claude-flow/neural": "3.0.2",
108
108
  "@claude-flow/plugin-agent-federation": "1.0.5",
@@ -110,7 +110,7 @@
110
110
  "@claude-flow/shared": "3.0.7",
111
111
  "@iarna/toml": "^2.2.5",
112
112
  "@noble/ed25519": "2.3.0",
113
- "@ruvector/rabitq-wasm": "0.1.0",
113
+ "@ruvector/rabitq-wasm": "0.1.2",
114
114
  "ajv": "^8.20.0",
115
115
  "bcryptjs": "^3.0.3",
116
116
  "chalk": "^5.3.0",
@@ -128,13 +128,13 @@
128
128
  "ws": "^8.21.0",
129
129
  "yaml": "^2.8.0",
130
130
  "zod": "^3.22.0",
131
- "@claude-flow/memory": "3.2.2"
131
+ "@claude-flow/memory": "3.2.3"
132
132
  },
133
133
  "optionalDependencies": {
134
134
  "@agntcy/slim-bindings": "2.1.1",
135
135
  "@claude-flow/aidefence": "3.1.0",
136
- "@claude-flow/memory": "3.2.2",
137
- "@metaharness/darwin": "~0.12.0",
136
+ "@claude-flow/memory": "3.2.3",
137
+ "@metaharness/darwin": "~0.13.0",
138
138
  "@metaharness/flywheel": "~0.1.10",
139
139
  "@metaharness/radio": "~0.1.0",
140
140
  "@metaharness/turn-credit": "~0.1.0",
@@ -142,13 +142,15 @@
142
142
  "agentdb": "^3.3.0",
143
143
  "agentic-flow": "^3.0.0",
144
144
  "better-sqlite3": "^12.9.0",
145
- "ruvector": "^0.2.27",
146
- "nostr-tools": "^2.7.0"
145
+ "ruvector": "^0.3.11",
146
+ "nostr-tools": "^2.7.0",
147
+ "@ruvector/learning-wasm": "0.1.29",
148
+ "agent-booster": "^0.2.2"
147
149
  },
148
150
  "peerDependencies": {
149
151
  "@metaharness/router": "^0.4.0",
150
152
  "@ruvector/typesafe": "^0.1.0",
151
- "metaharness": "^0.4.1"
153
+ "metaharness": "^0.4.20"
152
154
  },
153
155
  "peerDependenciesMeta": {
154
156
  "@metaharness/router": {
@@ -1 +0,0 @@
1
- sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319