@monoes/monomindcli 1.10.27 → 1.10.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoes/monomindcli",
3
- "version": "1.10.27",
3
+ "version": "1.10.29",
4
4
  "type": "module",
5
5
  "description": "Monomind 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",
@@ -654,32 +654,65 @@ async function main() {
654
654
  mg.closeDb(db);
655
655
  process.exit(1);
656
656
  }
657
- const updateNode = db.prepare(`UPDATE nodes SET properties = ? WHERE id = ?`);
657
+ // Resolve each analysis item to a DB integer node id.
658
+ // graph.json nodes have id='file:<path>' (synthetic); the real PK is an integer.
659
+ // Accept: analysis.dbId (integer), analysis.filePath, or derive path from analysis.id.
660
+ const lookupByPath = db.prepare(`SELECT id, properties FROM nodes WHERE file_path=? OR file_path=? LIMIT 1`);
661
+ const lookupById = db.prepare(`SELECT id, properties FROM nodes WHERE id=? LIMIT 1`);
662
+ const updateNode = db.prepare(`UPDATE nodes SET properties = ? WHERE id = ?`);
658
663
  let written = 0;
659
664
  const tx = db.transaction(() => {
660
665
  for (const analysis of analyses) {
661
- if (!analysis || !analysis.id) continue;
662
- const existing = (() => {
663
- try { const row = db.prepare('SELECT properties FROM nodes WHERE id=?').get(analysis.id); return row?.properties ? JSON.parse(row.properties) : {}; } catch { return {}; }
664
- })();
666
+ if (!analysis) continue;
667
+ let nodeRow = null;
668
+ // 1. Prefer explicit integer dbId (added by newer graph.json emitter)
669
+ if (analysis.dbId != null) {
670
+ nodeRow = lookupById.get(analysis.dbId);
671
+ }
672
+ // 2. Fall back to filePath from graph.json node
673
+ if (!nodeRow && analysis.filePath) {
674
+ const rel = analysis.filePath.startsWith('/') ? relative(projectDir, analysis.filePath) : analysis.filePath;
675
+ nodeRow = lookupByPath.get(analysis.filePath, rel);
676
+ }
677
+ // 3. Derive path from synthetic id ('file:<path>')
678
+ if (!nodeRow && analysis.id && String(analysis.id).startsWith('file:')) {
679
+ const derivedPath = String(analysis.id).slice(5);
680
+ const rel = derivedPath.startsWith('/') ? relative(projectDir, derivedPath) : derivedPath;
681
+ nodeRow = lookupByPath.get(derivedPath, rel);
682
+ }
683
+ if (!nodeRow) continue;
684
+ const existing = (() => { try { return nodeRow.properties ? JSON.parse(nodeRow.properties) : {}; } catch { return {}; } })();
665
685
  const merged = {
666
686
  ...existing,
667
- ...(analysis.fileSummary ? { summary: analysis.fileSummary } : {}),
668
- ...(analysis.tags ? { tags: analysis.tags } : {}),
669
- ...(analysis.complexity ? { complexity: analysis.complexity } : {}),
670
- ...(analysis.functionSummaries ? { functionSummaries: analysis.functionSummaries } : {}),
671
- ...(analysis.classSummaries ? { classSummaries: analysis.classSummaries } : {}),
687
+ ...(analysis.fileSummary ? { summary: analysis.fileSummary } : {}),
688
+ ...(analysis.tags ? { tags: analysis.tags } : {}),
689
+ ...(analysis.complexity ? { complexity: analysis.complexity } : {}),
690
+ ...(analysis.functionSummaries ? { functionSummaries: analysis.functionSummaries } : {}),
691
+ ...(analysis.classSummaries ? { classSummaries: analysis.classSummaries } : {}),
672
692
  ua_analyzed_at: new Date().toISOString(),
673
693
  };
674
- updateNode.run(JSON.stringify(merged), analysis.id);
694
+ updateNode.run(JSON.stringify(merged), nodeRow.id);
675
695
  written++;
676
696
  }
677
697
  });
678
698
  tx();
679
699
  // Rebuild FTS so summaries are immediately searchable
680
700
  try { db.prepare(`INSERT INTO nodes_fts(nodes_fts) VALUES('rebuild')`).run(); } catch {}
681
- mg.closeDb(db);
701
+
702
+ // Validate write-back: count nodes that now have a readable summary in properties
703
+ let enrichedCount = 0;
704
+ try {
705
+ const row = db.prepare(
706
+ `SELECT COUNT(*) AS c FROM nodes WHERE json_extract(properties, '$.summary') IS NOT NULL AND length(json_extract(properties, '$.summary')) > 5`
707
+ ).get();
708
+ enrichedCount = row ? row.c : 0;
709
+ } catch (_) {}
682
710
  console.log(`[understand] Imported ${written} analyses from stdin. FTS rebuilt.`);
711
+ console.log(`[understand] Validation: ${enrichedCount} node(s) now have LLM summaries readable via json_extract.`);
712
+ if (written > 0 && enrichedCount < written) {
713
+ console.warn(`[understand] WARNING: only ${enrichedCount} of ${written} imported analyses are queryable. Some properties may not have committed — check if properties column is TEXT.`);
714
+ }
715
+ mg.closeDb(db);
683
716
  return;
684
717
  }
685
718
 
@@ -1001,6 +1034,7 @@ function buildGraphJson(dir, fileNodes, analysisMap, layers) {
1001
1034
  const a = analysisMap[n.file_path] || {};
1002
1035
  return {
1003
1036
  id: 'file:' + (n.file_path || n.name),
1037
+ dbId: n.id, // integer PK — use this in --import-analyses-stdin payloads
1004
1038
  type: 'file',
1005
1039
  name: n.name,
1006
1040
  filePath: n.file_path,