@claude-flow/cli 3.1.0-alpha.26 → 3.1.0-alpha.27
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 +96 -28
- package/README.md +113 -2
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +104 -34
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -135,48 +135,104 @@ function getUserInfo() {
|
|
|
135
135
|
return { name, gitBranch, modelName };
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
// Get learning stats from
|
|
138
|
+
// Get learning stats from intelligence loop data (ADR-050)
|
|
139
139
|
function getLearningStats() {
|
|
140
|
-
const memoryPaths = [
|
|
141
|
-
path.join(process.cwd(), '.swarm', 'memory.db'),
|
|
142
|
-
path.join(process.cwd(), '.claude', 'memory.db'),
|
|
143
|
-
path.join(process.cwd(), 'data', 'memory.db'),
|
|
144
|
-
];
|
|
145
|
-
|
|
146
140
|
let patterns = 0;
|
|
147
141
|
let sessions = 0;
|
|
148
142
|
let trajectories = 0;
|
|
143
|
+
let edges = 0;
|
|
144
|
+
let confidenceMean = 0;
|
|
145
|
+
let accessedCount = 0;
|
|
146
|
+
let trend = 'STABLE';
|
|
147
|
+
|
|
148
|
+
// PRIMARY: Read from intelligence loop data files
|
|
149
|
+
const dataDir = path.join(process.cwd(), '.claude-flow', 'data');
|
|
150
|
+
|
|
151
|
+
// 1. graph-state.json — authoritative node/edge counts
|
|
152
|
+
const graphPath = path.join(dataDir, 'graph-state.json');
|
|
153
|
+
if (fs.existsSync(graphPath)) {
|
|
154
|
+
try {
|
|
155
|
+
const graph = JSON.parse(fs.readFileSync(graphPath, 'utf-8'));
|
|
156
|
+
patterns = graph.nodes ? Object.keys(graph.nodes).length : 0;
|
|
157
|
+
edges = Array.isArray(graph.edges) ? graph.edges.length : 0;
|
|
158
|
+
} catch (e) { /* ignore */ }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 2. ranked-context.json — confidence and access data
|
|
162
|
+
const rankedPath = path.join(dataDir, 'ranked-context.json');
|
|
163
|
+
if (fs.existsSync(rankedPath)) {
|
|
164
|
+
try {
|
|
165
|
+
const ranked = JSON.parse(fs.readFileSync(rankedPath, 'utf-8'));
|
|
166
|
+
if (ranked.entries && ranked.entries.length > 0) {
|
|
167
|
+
patterns = Math.max(patterns, ranked.entries.length);
|
|
168
|
+
let confSum = 0;
|
|
169
|
+
let accCount = 0;
|
|
170
|
+
for (let i = 0; i < ranked.entries.length; i++) {
|
|
171
|
+
confSum += (ranked.entries[i].confidence || 0);
|
|
172
|
+
if ((ranked.entries[i].accessCount || 0) > 0) accCount++;
|
|
173
|
+
}
|
|
174
|
+
confidenceMean = confSum / ranked.entries.length;
|
|
175
|
+
accessedCount = accCount;
|
|
176
|
+
}
|
|
177
|
+
} catch (e) { /* ignore */ }
|
|
178
|
+
}
|
|
149
179
|
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
180
|
+
// 3. intelligence-snapshot.json — trend history
|
|
181
|
+
const snapshotPath = path.join(dataDir, 'intelligence-snapshot.json');
|
|
182
|
+
if (fs.existsSync(snapshotPath)) {
|
|
183
|
+
try {
|
|
184
|
+
const snapshot = JSON.parse(fs.readFileSync(snapshotPath, 'utf-8'));
|
|
185
|
+
if (snapshot.history && snapshot.history.length >= 2) {
|
|
186
|
+
const first = snapshot.history[0];
|
|
187
|
+
const last = snapshot.history[snapshot.history.length - 1];
|
|
188
|
+
const confDrift = (last.confidenceMean || 0) - (first.confidenceMean || 0);
|
|
189
|
+
trend = confDrift > 0.01 ? 'IMPROVING' : confDrift < -0.01 ? 'DECLINING' : 'STABLE';
|
|
190
|
+
sessions = Math.max(sessions, snapshot.history.length);
|
|
191
|
+
}
|
|
192
|
+
} catch (e) { /* ignore */ }
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 4. auto-memory-store.json — fallback entry count
|
|
196
|
+
if (patterns === 0) {
|
|
197
|
+
const autoMemPath = path.join(dataDir, 'auto-memory-store.json');
|
|
198
|
+
if (fs.existsSync(autoMemPath)) {
|
|
153
199
|
try {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
200
|
+
const data = JSON.parse(fs.readFileSync(autoMemPath, 'utf-8'));
|
|
201
|
+
patterns = Array.isArray(data) ? data.length : (data.entries ? data.entries.length : 0);
|
|
202
|
+
} catch (e) { /* ignore */ }
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// FALLBACK: Legacy memory.db file-size estimation
|
|
207
|
+
if (patterns === 0) {
|
|
208
|
+
const memoryPaths = [
|
|
209
|
+
path.join(process.cwd(), '.swarm', 'memory.db'),
|
|
210
|
+
path.join(process.cwd(), '.claude', 'memory.db'),
|
|
211
|
+
path.join(process.cwd(), 'data', 'memory.db'),
|
|
212
|
+
];
|
|
213
|
+
for (let j = 0; j < memoryPaths.length; j++) {
|
|
214
|
+
if (fs.existsSync(memoryPaths[j])) {
|
|
215
|
+
try {
|
|
216
|
+
const dbStats = fs.statSync(memoryPaths[j]);
|
|
217
|
+
patterns = Math.floor(dbStats.size / 1024 / 2);
|
|
218
|
+
break;
|
|
219
|
+
} catch (e) { /* ignore */ }
|
|
164
220
|
}
|
|
165
221
|
}
|
|
166
222
|
}
|
|
167
223
|
|
|
168
|
-
//
|
|
224
|
+
// Session count from session files
|
|
169
225
|
const sessionsPath = path.join(process.cwd(), '.claude', 'sessions');
|
|
170
226
|
if (fs.existsSync(sessionsPath)) {
|
|
171
227
|
try {
|
|
172
228
|
const sessionFiles = fs.readdirSync(sessionsPath).filter(f => f.endsWith('.json'));
|
|
173
229
|
sessions = Math.max(sessions, sessionFiles.length);
|
|
174
|
-
} catch (e) {
|
|
175
|
-
// Ignore
|
|
176
|
-
}
|
|
230
|
+
} catch (e) { /* ignore */ }
|
|
177
231
|
}
|
|
178
232
|
|
|
179
|
-
|
|
233
|
+
trajectories = Math.floor(patterns / 5);
|
|
234
|
+
|
|
235
|
+
return { patterns, sessions, trajectories, edges, confidenceMean, accessedCount, trend };
|
|
180
236
|
}
|
|
181
237
|
|
|
182
238
|
// Get V3 progress from learning state (grows as system learns)
|
|
@@ -290,10 +346,22 @@ function getSystemMetrics() {
|
|
|
290
346
|
// Get learning stats for intelligence %
|
|
291
347
|
const learning = getLearningStats();
|
|
292
348
|
|
|
293
|
-
// Intelligence %
|
|
294
|
-
|
|
349
|
+
// Intelligence % from REAL intelligence loop data (ADR-050)
|
|
350
|
+
// Composite: 40% confidence mean + 30% access ratio + 30% pattern density
|
|
351
|
+
let intelligencePct = 0;
|
|
352
|
+
if (learning.confidenceMean > 0 || (learning.patterns > 0 && learning.accessedCount > 0)) {
|
|
353
|
+
const confScore = Math.min(100, Math.floor(learning.confidenceMean * 100));
|
|
354
|
+
const accessRatio = learning.patterns > 0 ? (learning.accessedCount / learning.patterns) : 0;
|
|
355
|
+
const accessScore = Math.min(100, Math.floor(accessRatio * 100));
|
|
356
|
+
const densityScore = Math.min(100, Math.floor(learning.patterns / 5));
|
|
357
|
+
intelligencePct = Math.floor(confScore * 0.4 + accessScore * 0.3 + densityScore * 0.3);
|
|
358
|
+
}
|
|
359
|
+
// Fallback: legacy pattern count
|
|
360
|
+
if (intelligencePct === 0 && learning.patterns > 0) {
|
|
361
|
+
intelligencePct = Math.min(100, Math.floor(learning.patterns / 10));
|
|
362
|
+
}
|
|
295
363
|
|
|
296
|
-
// Context % based on session history
|
|
364
|
+
// Context % based on session history
|
|
297
365
|
const contextPct = Math.min(100, Math.floor(learning.sessions * 5));
|
|
298
366
|
|
|
299
367
|
// Count active sub-agents from process list
|
package/README.md
CHANGED
|
@@ -616,6 +616,13 @@ codex mcp add ruflo -- npx ruflo mcp start
|
|
|
616
616
|
4. REMEMBER: memory_store(key, value, namespace="patterns") → Save for future
|
|
617
617
|
```
|
|
618
618
|
|
|
619
|
+
The **Intelligence Loop** (ADR-050) automates this cycle through hooks. Each session automatically:
|
|
620
|
+
- Builds a knowledge graph from memory entries (PageRank + Jaccard similarity)
|
|
621
|
+
- Injects ranked context into every route decision
|
|
622
|
+
- Tracks edit patterns and generates new insights
|
|
623
|
+
- Boosts confidence for useful patterns, decays unused ones
|
|
624
|
+
- Saves snapshots so you can track improvement with `node .claude/helpers/hook-handler.cjs stats`
|
|
625
|
+
|
|
619
626
|
### MCP Tools for Learning
|
|
620
627
|
|
|
621
628
|
| Tool | Purpose | When to Use |
|
|
@@ -2886,6 +2893,101 @@ Performance: <1ms (352x faster than LLM)
|
|
|
2886
2893
|
Cost: $0
|
|
2887
2894
|
```
|
|
2888
2895
|
|
|
2896
|
+
### Intelligence Loop (ADR-050)
|
|
2897
|
+
|
|
2898
|
+
The intelligence loop wires PageRank-ranked memory into the hook system. Every session builds a knowledge graph that improves over time:
|
|
2899
|
+
|
|
2900
|
+
```
|
|
2901
|
+
SessionStart:
|
|
2902
|
+
session-restore → intelligence.init()
|
|
2903
|
+
→ Read MEMORY.md / auto-memory-store.json
|
|
2904
|
+
→ Build graph (nodes + similarity/temporal edges)
|
|
2905
|
+
→ Compute PageRank
|
|
2906
|
+
→ "[INTELLIGENCE] Loaded 13 patterns, 12 edges"
|
|
2907
|
+
|
|
2908
|
+
UserPrompt:
|
|
2909
|
+
route → intelligence.getContext(prompt)
|
|
2910
|
+
→ Jaccard-match prompt against pre-ranked entries
|
|
2911
|
+
→ Inject top-5 patterns into Claude's context:
|
|
2912
|
+
|
|
2913
|
+
[INTELLIGENCE] Relevant patterns for this task:
|
|
2914
|
+
* (0.95) HNSW gives 150x-12,500x speedup [rank #1, 12x accessed]
|
|
2915
|
+
* (0.88) London School TDD preferred [rank #3, 8x accessed]
|
|
2916
|
+
|
|
2917
|
+
PostEdit:
|
|
2918
|
+
post-edit → intelligence.recordEdit(file)
|
|
2919
|
+
→ Append to pending-insights.jsonl (<2ms)
|
|
2920
|
+
|
|
2921
|
+
SessionEnd:
|
|
2922
|
+
session-end → intelligence.consolidate()
|
|
2923
|
+
→ Process pending insights (3+ edits → new entry)
|
|
2924
|
+
→ Confidence boost for accessed patterns (+0.03)
|
|
2925
|
+
→ Confidence decay for unused patterns (-0.005/day)
|
|
2926
|
+
→ Recompute PageRank, rebuild edges
|
|
2927
|
+
→ Save snapshot for trend tracking
|
|
2928
|
+
```
|
|
2929
|
+
|
|
2930
|
+
**Measuring improvement:**
|
|
2931
|
+
|
|
2932
|
+
```bash
|
|
2933
|
+
# Human-readable diagnostics
|
|
2934
|
+
node .claude/helpers/hook-handler.cjs stats
|
|
2935
|
+
|
|
2936
|
+
# JSON output for scripting
|
|
2937
|
+
node .claude/helpers/hook-handler.cjs stats --json
|
|
2938
|
+
|
|
2939
|
+
# Or via intelligence.cjs directly
|
|
2940
|
+
node .claude/helpers/intelligence.cjs stats
|
|
2941
|
+
```
|
|
2942
|
+
|
|
2943
|
+
The stats command shows:
|
|
2944
|
+
|
|
2945
|
+
| Section | What It Tells You |
|
|
2946
|
+
|---------|-------------------|
|
|
2947
|
+
| **Graph** | Node/edge count, density % |
|
|
2948
|
+
| **Confidence** | Min/max/mean/median across all patterns |
|
|
2949
|
+
| **Access** | Total accesses, patterns used vs never accessed |
|
|
2950
|
+
| **PageRank** | Sum (~1.0), highest-ranked node |
|
|
2951
|
+
| **Top Patterns** | Top 10 by composite score with access counts |
|
|
2952
|
+
| **Last Delta** | Changes since previous session (confidence shift, access delta) |
|
|
2953
|
+
| **Trend** | Over all sessions: IMPROVING / DECLINING / STABLE |
|
|
2954
|
+
|
|
2955
|
+
**Example output:**
|
|
2956
|
+
```
|
|
2957
|
+
+--------------------------------------------------------------+
|
|
2958
|
+
| Intelligence Diagnostics (ADR-050) |
|
|
2959
|
+
+--------------------------------------------------------------+
|
|
2960
|
+
|
|
2961
|
+
Graph
|
|
2962
|
+
Nodes: 9
|
|
2963
|
+
Edges: 8 (7 temporal, 1 similar)
|
|
2964
|
+
Density: 22.2%
|
|
2965
|
+
|
|
2966
|
+
Confidence
|
|
2967
|
+
Min: 0.490 Max: 0.600
|
|
2968
|
+
Mean: 0.556 Median: 0.580
|
|
2969
|
+
|
|
2970
|
+
Access
|
|
2971
|
+
Total accesses: 11
|
|
2972
|
+
Patterns used: 6/9
|
|
2973
|
+
Never accessed: 3
|
|
2974
|
+
|
|
2975
|
+
Top Patterns (by composite score)
|
|
2976
|
+
#1 HNSW gives 150x-12,500x speedup
|
|
2977
|
+
conf=0.600 pr=0.2099 score=0.3659 accessed=2x
|
|
2978
|
+
#2 London School TDD preferred
|
|
2979
|
+
conf=0.600 pr=0.1995 score=0.3597 accessed=2x
|
|
2980
|
+
|
|
2981
|
+
Last Delta (5m ago)
|
|
2982
|
+
Confidence: +0.0300
|
|
2983
|
+
Accesses: +6
|
|
2984
|
+
|
|
2985
|
+
Trend (3 snapshots)
|
|
2986
|
+
Confidence drift: +0.0422
|
|
2987
|
+
Direction: IMPROVING
|
|
2988
|
+
+--------------------------------------------------------------+
|
|
2989
|
+
```
|
|
2990
|
+
|
|
2889
2991
|
### All 27 Hooks by Category
|
|
2890
2992
|
|
|
2891
2993
|
#### 🔧 Tool Lifecycle Hooks (6 hooks)
|
|
@@ -2954,7 +3056,7 @@ npx ruflo@v3alpha hooks session-end --export-metrics --persist-patterns
|
|
|
2954
3056
|
| `trajectory-end` | RL | Finish recording, trigger learning |
|
|
2955
3057
|
| `pattern-store` | Memory | Store a pattern with HNSW indexing |
|
|
2956
3058
|
| `pattern-search` | Memory | Find similar patterns (150x faster) |
|
|
2957
|
-
| `stats` | Analytics |
|
|
3059
|
+
| `stats` | Analytics | Intelligence diagnostics, confidence trends, improvement tracking |
|
|
2958
3060
|
| `attention` | Focus | Compute attention-weighted similarity |
|
|
2959
3061
|
|
|
2960
3062
|
```bash
|
|
@@ -2966,6 +3068,10 @@ npx ruflo@v3alpha hooks intelligence trajectory-step --action "created token ser
|
|
|
2966
3068
|
|
|
2967
3069
|
# End trajectory and trigger learning
|
|
2968
3070
|
npx ruflo@v3alpha hooks intelligence trajectory-end --success true
|
|
3071
|
+
|
|
3072
|
+
# View intelligence diagnostics and improvement trends (ADR-050)
|
|
3073
|
+
node .claude/helpers/hook-handler.cjs stats
|
|
3074
|
+
node .claude/helpers/intelligence.cjs stats --json
|
|
2969
3075
|
```
|
|
2970
3076
|
|
|
2971
3077
|
### 12 Background Workers (Auto-Triggered)
|
|
@@ -3033,7 +3139,7 @@ npx ruflo@v3alpha hooks model-route --task "design distributed consensus system"
|
|
|
3033
3139
|
# MOST COMMON HOOKS
|
|
3034
3140
|
# ══════════════════════════════════════════════════════════════════
|
|
3035
3141
|
|
|
3036
|
-
# Route task to best agent
|
|
3142
|
+
# Route task to best agent (with intelligence context injection)
|
|
3037
3143
|
npx ruflo@v3alpha hooks route "<task>" --include-explanation
|
|
3038
3144
|
|
|
3039
3145
|
# Start/end session with learning
|
|
@@ -3044,6 +3150,11 @@ npx ruflo@v3alpha hooks session-end --persist-patterns
|
|
|
3044
3150
|
npx ruflo@v3alpha hooks metrics
|
|
3045
3151
|
npx ruflo@v3alpha hooks intelligence stats
|
|
3046
3152
|
|
|
3153
|
+
# Intelligence diagnostics — see if intelligence is improving
|
|
3154
|
+
node .claude/helpers/hook-handler.cjs stats # Human-readable
|
|
3155
|
+
node .claude/helpers/hook-handler.cjs stats --json # JSON for scripting
|
|
3156
|
+
node .claude/helpers/intelligence.cjs stats # Direct access
|
|
3157
|
+
|
|
3047
3158
|
# Bootstrap on new project
|
|
3048
3159
|
npx ruflo@v3alpha hooks pretrain --depth deep
|
|
3049
3160
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusline-generator.d.ts","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"statusline-generator.d.ts","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAmvCrE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA2BnE"}
|
|
@@ -147,51 +147,107 @@ function getUserInfo() {
|
|
|
147
147
|
return { name, gitBranch, modelName };
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
// Get learning stats from
|
|
150
|
+
// Get learning stats from intelligence loop data (ADR-050)
|
|
151
151
|
function getLearningStats() {
|
|
152
|
-
const memoryPaths = [
|
|
153
|
-
path.join(process.cwd(), '.swarm', 'memory.db'),
|
|
154
|
-
path.join(process.cwd(), '.claude-flow', 'memory.db'),
|
|
155
|
-
path.join(process.cwd(), '.claude', 'memory.db'),
|
|
156
|
-
path.join(process.cwd(), 'data', 'memory.db'),
|
|
157
|
-
path.join(process.cwd(), 'memory.db'),
|
|
158
|
-
path.join(process.cwd(), '.agentdb', 'memory.db'),
|
|
159
|
-
];
|
|
160
|
-
|
|
161
152
|
let patterns = 0;
|
|
162
153
|
let sessions = 0;
|
|
163
154
|
let trajectories = 0;
|
|
155
|
+
let edges = 0;
|
|
156
|
+
let confidenceMean = 0;
|
|
157
|
+
let accessedCount = 0;
|
|
158
|
+
let trend = 'STABLE';
|
|
159
|
+
|
|
160
|
+
// PRIMARY: Read from intelligence loop data files
|
|
161
|
+
const dataDir = path.join(process.cwd(), '.claude-flow', 'data');
|
|
162
|
+
|
|
163
|
+
// 1. graph-state.json — authoritative node/edge counts
|
|
164
|
+
const graphPath = path.join(dataDir, 'graph-state.json');
|
|
165
|
+
if (fs.existsSync(graphPath)) {
|
|
166
|
+
try {
|
|
167
|
+
const graph = JSON.parse(fs.readFileSync(graphPath, 'utf-8'));
|
|
168
|
+
patterns = graph.nodes ? Object.keys(graph.nodes).length : 0;
|
|
169
|
+
edges = Array.isArray(graph.edges) ? graph.edges.length : 0;
|
|
170
|
+
} catch (e) { /* ignore */ }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 2. ranked-context.json — confidence and access data
|
|
174
|
+
const rankedPath = path.join(dataDir, 'ranked-context.json');
|
|
175
|
+
if (fs.existsSync(rankedPath)) {
|
|
176
|
+
try {
|
|
177
|
+
const ranked = JSON.parse(fs.readFileSync(rankedPath, 'utf-8'));
|
|
178
|
+
if (ranked.entries && ranked.entries.length > 0) {
|
|
179
|
+
patterns = Math.max(patterns, ranked.entries.length);
|
|
180
|
+
let confSum = 0;
|
|
181
|
+
let accCount = 0;
|
|
182
|
+
for (let i = 0; i < ranked.entries.length; i++) {
|
|
183
|
+
confSum += (ranked.entries[i].confidence || 0);
|
|
184
|
+
if ((ranked.entries[i].accessCount || 0) > 0) accCount++;
|
|
185
|
+
}
|
|
186
|
+
confidenceMean = confSum / ranked.entries.length;
|
|
187
|
+
accessedCount = accCount;
|
|
188
|
+
}
|
|
189
|
+
} catch (e) { /* ignore */ }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 3. intelligence-snapshot.json — trend history
|
|
193
|
+
const snapshotPath = path.join(dataDir, 'intelligence-snapshot.json');
|
|
194
|
+
if (fs.existsSync(snapshotPath)) {
|
|
195
|
+
try {
|
|
196
|
+
const snapshot = JSON.parse(fs.readFileSync(snapshotPath, 'utf-8'));
|
|
197
|
+
if (snapshot.history && snapshot.history.length >= 2) {
|
|
198
|
+
const first = snapshot.history[0];
|
|
199
|
+
const last = snapshot.history[snapshot.history.length - 1];
|
|
200
|
+
const confDrift = (last.confidenceMean || 0) - (first.confidenceMean || 0);
|
|
201
|
+
trend = confDrift > 0.01 ? 'IMPROVING' : confDrift < -0.01 ? 'DECLINING' : 'STABLE';
|
|
202
|
+
sessions = Math.max(sessions, snapshot.history.length);
|
|
203
|
+
}
|
|
204
|
+
} catch (e) { /* ignore */ }
|
|
205
|
+
}
|
|
164
206
|
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
|
|
207
|
+
// 4. auto-memory-store.json — fallback entry count
|
|
208
|
+
if (patterns === 0) {
|
|
209
|
+
const autoMemPath = path.join(dataDir, 'auto-memory-store.json');
|
|
210
|
+
if (fs.existsSync(autoMemPath)) {
|
|
168
211
|
try {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
212
|
+
const data = JSON.parse(fs.readFileSync(autoMemPath, 'utf-8'));
|
|
213
|
+
patterns = Array.isArray(data) ? data.length : (data.entries ? data.entries.length : 0);
|
|
214
|
+
} catch (e) { /* ignore */ }
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// FALLBACK: Legacy memory.db file-size estimation
|
|
219
|
+
if (patterns === 0) {
|
|
220
|
+
const memoryPaths = [
|
|
221
|
+
path.join(process.cwd(), '.swarm', 'memory.db'),
|
|
222
|
+
path.join(process.cwd(), '.claude-flow', 'memory.db'),
|
|
223
|
+
path.join(process.cwd(), '.claude', 'memory.db'),
|
|
224
|
+
path.join(process.cwd(), 'data', 'memory.db'),
|
|
225
|
+
path.join(process.cwd(), 'memory.db'),
|
|
226
|
+
path.join(process.cwd(), '.agentdb', 'memory.db'),
|
|
227
|
+
];
|
|
228
|
+
for (let j = 0; j < memoryPaths.length; j++) {
|
|
229
|
+
if (fs.existsSync(memoryPaths[j])) {
|
|
230
|
+
try {
|
|
231
|
+
const dbStats = fs.statSync(memoryPaths[j]);
|
|
232
|
+
patterns = Math.floor(dbStats.size / 1024 / 2);
|
|
233
|
+
break;
|
|
234
|
+
} catch (e) { /* ignore */ }
|
|
179
235
|
}
|
|
180
236
|
}
|
|
181
237
|
}
|
|
182
238
|
|
|
183
|
-
//
|
|
239
|
+
// Session count from session files
|
|
184
240
|
const sessionsPath = path.join(process.cwd(), '.claude', 'sessions');
|
|
185
241
|
if (fs.existsSync(sessionsPath)) {
|
|
186
242
|
try {
|
|
187
243
|
const sessionFiles = fs.readdirSync(sessionsPath).filter(f => f.endsWith('.json'));
|
|
188
244
|
sessions = Math.max(sessions, sessionFiles.length);
|
|
189
|
-
} catch (e) {
|
|
190
|
-
// Ignore
|
|
191
|
-
}
|
|
245
|
+
} catch (e) { /* ignore */ }
|
|
192
246
|
}
|
|
193
247
|
|
|
194
|
-
|
|
248
|
+
trajectories = Math.floor(patterns / 5);
|
|
249
|
+
|
|
250
|
+
return { patterns, sessions, trajectories, edges, confidenceMean, accessedCount, trend };
|
|
195
251
|
}
|
|
196
252
|
|
|
197
253
|
// Get V3 progress from REAL metrics files
|
|
@@ -417,17 +473,31 @@ function getSystemMetrics() {
|
|
|
417
473
|
// Also get AgentDB stats for fallback intelligence calculation
|
|
418
474
|
const agentdbStats = getAgentDBStats();
|
|
419
475
|
|
|
420
|
-
// Intelligence %
|
|
421
|
-
//
|
|
476
|
+
// Intelligence % — priority chain (ADR-050):
|
|
477
|
+
// 1. Intelligence loop data (confidenceMean + accessRatio + density)
|
|
478
|
+
// 2. learning.json file metric
|
|
479
|
+
// 3. Pattern count / vector count fallback
|
|
480
|
+
// 4. Project maturity fallback (below)
|
|
422
481
|
let intelligencePct = 0;
|
|
423
482
|
|
|
424
|
-
|
|
483
|
+
// Priority 1: Intelligence loop real data
|
|
484
|
+
if (learning.confidenceMean > 0 || (learning.patterns > 0 && learning.accessedCount > 0)) {
|
|
485
|
+
const confScore = Math.min(100, Math.floor(learning.confidenceMean * 100));
|
|
486
|
+
const accessRatio = learning.patterns > 0 ? (learning.accessedCount / learning.patterns) : 0;
|
|
487
|
+
const accessScore = Math.min(100, Math.floor(accessRatio * 100));
|
|
488
|
+
const densityScore = Math.min(100, Math.floor(learning.patterns / 5));
|
|
489
|
+
intelligencePct = Math.floor(confScore * 0.4 + accessScore * 0.3 + densityScore * 0.3);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Priority 2: learning.json file metric
|
|
493
|
+
if (intelligencePct === 0 && intelligenceFromFile !== null) {
|
|
425
494
|
intelligencePct = intelligenceFromFile;
|
|
426
|
-
}
|
|
427
|
-
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Priority 3: Pattern/vector count fallback
|
|
498
|
+
if (intelligencePct === 0) {
|
|
428
499
|
const fromPatterns = learning.patterns > 0 ? Math.min(100, Math.floor(learning.patterns / 10)) : 0;
|
|
429
500
|
const fromVectors = agentdbStats.vectorCount > 0 ? Math.min(100, Math.floor(agentdbStats.vectorCount / 100)) : 0;
|
|
430
|
-
|
|
431
501
|
intelligencePct = Math.max(fromPatterns, fromVectors);
|
|
432
502
|
}
|
|
433
503
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusline-generator.js","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAElC,oFAAoF;IACpF,OAAO;;;;;;;;;;;;;;;;;;aAkBI,MAAM,CAAC,OAAO;kBACT,MAAM,CAAC,YAAY;kBACnB,MAAM,CAAC,YAAY;eACtB,MAAM,CAAC,SAAS;eAChB,MAAM,CAAC,SAAS;qBACV,MAAM,CAAC,eAAe;qBACtB,MAAM,CAAC,eAAe;eAC5B,OAAO,CAAC,OAAO,CAAC,SAAS;eACzB,OAAO,CAAC,OAAO,CAAC,QAAQ
|
|
1
|
+
{"version":3,"file":"statusline-generator.js","sourceRoot":"","sources":["../../../src/init/statusline-generator.ts"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