@claude-flow/cli 3.1.0-alpha.23 → 3.1.0-alpha.24

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.
@@ -66,7 +66,7 @@ const handlers = {
66
66
  const result = router.routeTask(prompt);
67
67
  // Format output for Claude Code hook consumption
68
68
  const output = [
69
- '[INFO] Routing task: $P$G',
69
+ `[INFO] Routing task: ${prompt.substring(0, 80) || '(no prompt)'}`,
70
70
  '',
71
71
  'Routing Method',
72
72
  ' - Method: keyword',
@@ -212,21 +212,104 @@ function buildEdges(entries) {
212
212
  return edges;
213
213
  }
214
214
 
215
+ // ── Bootstrap from MEMORY.md files ───────────────────────────────────────────
216
+
217
+ /**
218
+ * If auto-memory-store.json is empty, bootstrap by parsing MEMORY.md and
219
+ * topic files from the auto-memory directory. This removes the dependency
220
+ * on @claude-flow/memory for the initial seed.
221
+ */
222
+ function bootstrapFromMemoryFiles() {
223
+ const entries = [];
224
+ const cwd = process.cwd();
225
+
226
+ // Search for auto-memory directories
227
+ const candidates = [
228
+ // Claude Code auto-memory (project-scoped)
229
+ path.join(require('os').homedir(), '.claude', 'projects'),
230
+ // Local project memory
231
+ path.join(cwd, '.claude-flow', 'memory'),
232
+ path.join(cwd, '.claude', 'memory'),
233
+ ];
234
+
235
+ // Find MEMORY.md in project-scoped dirs
236
+ for (const base of candidates) {
237
+ if (!fs.existsSync(base)) continue;
238
+
239
+ // For the projects dir, scan subdirectories for memory/
240
+ if (base.endsWith('projects')) {
241
+ try {
242
+ const projectDirs = fs.readdirSync(base);
243
+ for (const pdir of projectDirs) {
244
+ const memDir = path.join(base, pdir, 'memory');
245
+ if (fs.existsSync(memDir)) {
246
+ parseMemoryDir(memDir, entries);
247
+ }
248
+ }
249
+ } catch { /* skip */ }
250
+ } else if (fs.existsSync(base)) {
251
+ parseMemoryDir(base, entries);
252
+ }
253
+ }
254
+
255
+ return entries;
256
+ }
257
+
258
+ function parseMemoryDir(dir, entries) {
259
+ try {
260
+ const files = fs.readdirSync(dir).filter(f => f.endsWith('.md'));
261
+ for (const file of files) {
262
+ const filePath = path.join(dir, file);
263
+ const content = fs.readFileSync(filePath, 'utf-8');
264
+ if (!content.trim()) continue;
265
+
266
+ // Parse markdown sections as separate entries
267
+ const sections = content.split(/^##?\s+/m).filter(Boolean);
268
+ for (const section of sections) {
269
+ const lines = section.trim().split('\n');
270
+ const title = lines[0].trim();
271
+ const body = lines.slice(1).join('\n').trim();
272
+ if (!body || body.length < 10) continue;
273
+
274
+ const id = `mem-${file.replace('.md', '')}-${title.replace(/[^a-z0-9]/gi, '-').toLowerCase().slice(0, 30)}`;
275
+ entries.push({
276
+ id,
277
+ key: title.toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 50),
278
+ content: body.slice(0, 500),
279
+ summary: title,
280
+ namespace: file === 'MEMORY.md' ? 'core' : file.replace('.md', ''),
281
+ type: 'semantic',
282
+ metadata: { sourceFile: filePath, bootstrapped: true },
283
+ createdAt: Date.now(),
284
+ });
285
+ }
286
+ }
287
+ } catch { /* skip unreadable dirs */ }
288
+ }
289
+
215
290
  // ── Exported functions ───────────────────────────────────────────────────────
216
291
 
217
292
  /**
218
293
  * init() — Called from session-restore. Budget: <200ms.
219
294
  * Reads auto-memory-store.json, builds graph, computes PageRank, writes caches.
295
+ * If store is empty, bootstraps from MEMORY.md files directly.
220
296
  */
221
297
  function init() {
222
298
  ensureDataDir();
223
299
 
224
300
  // Check if graph-state.json is fresh (within 60s of store)
225
301
  const graphState = readJSON(GRAPH_PATH);
226
- const store = readJSON(STORE_PATH);
302
+ let store = readJSON(STORE_PATH);
227
303
 
304
+ // Bootstrap from MEMORY.md files if store is empty
228
305
  if (!store || !Array.isArray(store) || store.length === 0) {
229
- return { nodes: 0, edges: 0, message: 'No memory entries to index' };
306
+ const bootstrapped = bootstrapFromMemoryFiles();
307
+ if (bootstrapped.length > 0) {
308
+ store = bootstrapped;
309
+ writeJSON(STORE_PATH, store);
310
+ } else {
311
+ return { nodes: 0, edges: 0, message: 'No memory entries to index' };
312
+ }
230
313
  }
231
314
 
232
315
  // Skip rebuild if graph is fresh and store hasn't changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.1.0-alpha.23",
3
+ "version": "3.1.0-alpha.24",
4
4
  "type": "module",
5
5
  "description": "Claude Flow 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",