@claude-flow/cli 3.1.0-alpha.25 → 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/hook-handler.cjs +9 -1
- package/.claude/helpers/intelligence.cjs +267 -1
- package/.claude/helpers/statusline.cjs +96 -28
- package/README.md +113 -2
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +9 -1
- package/dist/src/init/helpers-generator.js.map +1 -1
- 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
|
@@ -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"],"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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