claude-flow 3.10.40 → 3.10.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/statusline.cjs +693 -644
- package/.claude/scheduled_tasks.lock +1 -0
- package/package.json +1 -1
- package/v3/@claude-flow/cli/dist/src/commands/hive-mind.js +14 -1
- package/v3/@claude-flow/cli/dist/src/commands/hooks.js +28 -1
- package/v3/@claude-flow/cli/dist/src/commands/init.js +7 -1
- package/v3/@claude-flow/cli/dist/src/init/statusline-generator.js +53 -4
- package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +101 -1
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.d.ts +2 -0
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +2 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/neural-router.d.ts +49 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/neural-router.js +132 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/router-trajectory.d.ts +69 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/router-trajectory.js +87 -0
- package/v3/@claude-flow/cli/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router trajectory collection (#2334 Phase 1)
|
|
3
|
+
*
|
|
4
|
+
* Opt-in per-decision dataset collection for the model router. The persisted
|
|
5
|
+
* bandit state (`.swarm/model-router-state.json`) keeps only aggregates —
|
|
6
|
+
* 9 Beta(α,β) cells and a capped/truncated history — which is not trainable
|
|
7
|
+
* material for the Phase 2 FastGRNN tier-classifier. This sidecar captures
|
|
8
|
+
* the per-example rows that training needs:
|
|
9
|
+
*
|
|
10
|
+
* decision rows: { taskHash, task, embedding?, complexity, features,
|
|
11
|
+
* model, confidence, uncertainty, routedBy, ts }
|
|
12
|
+
* outcome rows: { taskHash, model, outcome, ts }
|
|
13
|
+
*
|
|
14
|
+
* joined offline on `taskHash` (sha256-16 of the task text).
|
|
15
|
+
*
|
|
16
|
+
* OFF by default. Enable with CLAUDE_FLOW_ROUTER_TRAJECTORY=1. Rows append to
|
|
17
|
+
* `.swarm/model-router-trajectories.jsonl` — local-only, same trust domain as
|
|
18
|
+
* the existing state file, but unlike it the rows contain full task text (up
|
|
19
|
+
* to 500 chars) and raw embeddings, which is why this is opt-in rather than
|
|
20
|
+
* always-on.
|
|
21
|
+
*
|
|
22
|
+
* Writes are best-effort: any fs error is swallowed (collection must never
|
|
23
|
+
* break routing), matching the state-file behavior in model-router.ts.
|
|
24
|
+
*
|
|
25
|
+
* @module router-trajectory
|
|
26
|
+
*/
|
|
27
|
+
import { createHash } from 'crypto';
|
|
28
|
+
import { appendFileSync, existsSync, mkdirSync } from 'fs';
|
|
29
|
+
import { dirname, join } from 'path';
|
|
30
|
+
export const TRAJECTORY_FILE = '.swarm/model-router-trajectories.jsonl';
|
|
31
|
+
/** Schema version stamped on every row so offline training can dispatch. */
|
|
32
|
+
const ROW_VERSION = 1;
|
|
33
|
+
export function trajectoryCollectionEnabled() {
|
|
34
|
+
return process.env.CLAUDE_FLOW_ROUTER_TRAJECTORY === '1';
|
|
35
|
+
}
|
|
36
|
+
/** Join key: first 16 hex chars of sha256(task). */
|
|
37
|
+
export function taskHash(task) {
|
|
38
|
+
return createHash('sha256').update(task).digest('hex').slice(0, 16);
|
|
39
|
+
}
|
|
40
|
+
function appendRow(row) {
|
|
41
|
+
try {
|
|
42
|
+
const fullPath = join(process.cwd(), TRAJECTORY_FILE);
|
|
43
|
+
const dir = dirname(fullPath);
|
|
44
|
+
if (!existsSync(dir))
|
|
45
|
+
mkdirSync(dir, { recursive: true });
|
|
46
|
+
appendFileSync(fullPath, JSON.stringify(row) + '\n');
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Best-effort: collection must never break routing.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function recordTrajectoryDecision(task, embedding, complexity, decision) {
|
|
53
|
+
if (!trajectoryCollectionEnabled())
|
|
54
|
+
return;
|
|
55
|
+
appendRow({
|
|
56
|
+
v: ROW_VERSION,
|
|
57
|
+
type: 'decision',
|
|
58
|
+
ts: new Date().toISOString(),
|
|
59
|
+
taskHash: taskHash(task),
|
|
60
|
+
task: task.slice(0, 500),
|
|
61
|
+
...(embedding && embedding.length > 0 ? { embedding } : {}),
|
|
62
|
+
complexity: complexity.score,
|
|
63
|
+
features: {
|
|
64
|
+
lexicalComplexity: complexity.lexicalComplexity,
|
|
65
|
+
semanticDepth: complexity.semanticDepth,
|
|
66
|
+
taskScope: complexity.taskScope,
|
|
67
|
+
uncertaintyLevel: complexity.uncertaintyLevel,
|
|
68
|
+
},
|
|
69
|
+
model: decision.model,
|
|
70
|
+
confidence: decision.confidence,
|
|
71
|
+
uncertainty: decision.uncertainty,
|
|
72
|
+
routedBy: decision.routedBy,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function recordTrajectoryOutcome(task, model, outcome) {
|
|
76
|
+
if (!trajectoryCollectionEnabled())
|
|
77
|
+
return;
|
|
78
|
+
appendRow({
|
|
79
|
+
v: ROW_VERSION,
|
|
80
|
+
type: 'outcome',
|
|
81
|
+
ts: new Date().toISOString(),
|
|
82
|
+
taskHash: taskHash(task),
|
|
83
|
+
model,
|
|
84
|
+
outcome,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=router-trajectory.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.42",
|
|
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",
|