devsmind-mcp 2.0.4 → 2.1.0

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.
@@ -0,0 +1,42 @@
1
+ import { DevMindDatabase } from './database';
2
+ import { MissingRef } from '../utils/ast';
3
+ /** Aggregated missing-node record (deduped by target file + symbol). */
4
+ export interface MissingAgg {
5
+ file: string;
6
+ symbol: string;
7
+ referenced_by: Set<string>;
8
+ }
9
+ /** Builds a MissingRef -> MissingAgg collector (dedupes by target file + symbol). */
10
+ export declare function createMissingCollector(): {
11
+ missing: Map<string, MissingAgg>;
12
+ onMissing: (rec: MissingRef) => void;
13
+ };
14
+ /**
15
+ * Deterministically creates nodes for used-but-unextracted references (Phase-1 gaps) from
16
+ * the AST — no LLM — re-resolves edges for the new nodes and their callers so the edges
17
+ * appear. Returns the number of nodes auto-created. This is inbuilt behaviour of every
18
+ * edge-resolution run.
19
+ *
20
+ * @param opts.writeReport write `missing_nodes_report.json` (CLI indexer wants this; the MCP
21
+ * commit path does not — defaults true).
22
+ * @param opts.quiet suppress console output (MCP path; defaults false).
23
+ */
24
+ export declare function finalizeMissingNodes(resolvedDevmind: string, db: DevMindDatabase, missing: Map<string, MissingAgg>, opts?: {
25
+ writeReport?: boolean;
26
+ quiet?: boolean;
27
+ }): number;
28
+ /**
29
+ * Resolves outgoing connections for a batch of source nodes via the local AST resolver, adding
30
+ * each resolved edge additively (INSERT OR IGNORE), then auto-creating any missing target nodes.
31
+ * Shared by the CLI indexer and the MCP commit_changes flow.
32
+ *
33
+ * @param opts.clearSources delete the source nodes' existing OUTGOING edges before re-resolving
34
+ * (drops edges the code no longer has) while leaving every other node's edges intact. Off by
35
+ * default (pure-additive) to match the CLI's per-node loop.
36
+ */
37
+ export declare function resolveEdgesForNodes(db: DevMindDatabase, devmindPath: string, sourceNodeIds: string[], opts?: {
38
+ clearSources?: boolean;
39
+ }): {
40
+ edgesAdded: number;
41
+ missingFilled: number;
42
+ };
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createMissingCollector = createMissingCollector;
37
+ exports.finalizeMissingNodes = finalizeMissingNodes;
38
+ exports.resolveEdgesForNodes = resolveEdgesForNodes;
39
+ const fs = __importStar(require("fs"));
40
+ const path = __importStar(require("path"));
41
+ const ast_1 = require("../utils/ast");
42
+ /** Builds a MissingRef -> MissingAgg collector (dedupes by target file + symbol). */
43
+ function createMissingCollector() {
44
+ const missing = new Map();
45
+ const onMissing = (rec) => {
46
+ const key = rec.targetFile + ' ' + rec.name;
47
+ let e = missing.get(key);
48
+ if (!e) {
49
+ e = { file: rec.targetFile, symbol: rec.name, referenced_by: new Set() };
50
+ missing.set(key, e);
51
+ }
52
+ e.referenced_by.add(rec.sourceNodeId);
53
+ };
54
+ return { missing, onMissing };
55
+ }
56
+ /**
57
+ * Deterministically creates nodes for used-but-unextracted references (Phase-1 gaps) from
58
+ * the AST — no LLM — re-resolves edges for the new nodes and their callers so the edges
59
+ * appear. Returns the number of nodes auto-created. This is inbuilt behaviour of every
60
+ * edge-resolution run.
61
+ *
62
+ * @param opts.writeReport write `missing_nodes_report.json` (CLI indexer wants this; the MCP
63
+ * commit path does not — defaults true).
64
+ * @param opts.quiet suppress console output (MCP path; defaults false).
65
+ */
66
+ function finalizeMissingNodes(resolvedDevmind, db, missing, opts = {}) {
67
+ const writeReport = opts.writeReport !== false;
68
+ const quiet = opts.quiet === true;
69
+ const filledIds = new Set();
70
+ if (missing.size > 0) {
71
+ const reresolve = new Set();
72
+ for (const e of missing.values()) {
73
+ const derived = (0, ast_1.extractNodeFromFile)(e.file, e.symbol);
74
+ if (!derived)
75
+ continue; // can't locate the declaration — leave in report only
76
+ const id = `${db.toRepoRelativePath(e.file)}#${e.symbol}`;
77
+ db.upsertNode({ id, name: derived.name, type: derived.type, file_path: e.file, signature: derived.signature });
78
+ db.updateHistory({
79
+ node_id: id,
80
+ code_snapshot: derived.codeSnapshot,
81
+ reasoning: {
82
+ what_changed: 'Auto-created from a used-but-unextracted reference (--fill-missing)',
83
+ why: 'Fill a Phase-1 extraction gap detected during edge resolution',
84
+ goal: 'Complete the node graph deterministically from the AST',
85
+ developer: 'devsmind fill-missing',
86
+ model: 'ast'
87
+ }
88
+ });
89
+ filledIds.add(id);
90
+ for (const s of e.referenced_by)
91
+ reresolve.add(s);
92
+ }
93
+ if (filledIds.size > 0) {
94
+ const allNodes = db.listNodes();
95
+ const allIds = new Set(allNodes.map(n => n.id));
96
+ for (const id of new Set([...filledIds, ...reresolve])) {
97
+ const n = db.getNode(id);
98
+ if (!n || !n.file_path)
99
+ continue;
100
+ for (const t of (0, ast_1.resolveConnectionsLocally)(id, n.file_path, allNodes, resolvedDevmind)) {
101
+ if (allIds.has(t))
102
+ db.addConnection(id, t);
103
+ }
104
+ }
105
+ }
106
+ }
107
+ if (writeReport) {
108
+ const report = [...missing.values()].map(e => {
109
+ const id = `${db.toRepoRelativePath(e.file)}#${e.symbol}`;
110
+ return {
111
+ file: db.toRepoRelativePath(e.file),
112
+ symbol: e.symbol,
113
+ count: e.referenced_by.size,
114
+ referenced_by: [...e.referenced_by],
115
+ filled: filledIds.has(id)
116
+ };
117
+ }).sort((a, b) => b.count - a.count);
118
+ try {
119
+ fs.writeFileSync(path.join(resolvedDevmind, 'missing_nodes_report.json'), JSON.stringify({ total: report.length, filled: filledIds.size, missing: report }, null, 2), 'utf-8');
120
+ }
121
+ catch { /* ignore */ }
122
+ if (!quiet) {
123
+ console.log(`\n 🔍 Missing-node references: ${report.length} — auto-created ${filledIds.size}`);
124
+ console.log(` └─ ${path.join(resolvedDevmind, 'missing_nodes_report.json')}`);
125
+ }
126
+ }
127
+ return filledIds.size;
128
+ }
129
+ /**
130
+ * Resolves outgoing connections for a batch of source nodes via the local AST resolver, adding
131
+ * each resolved edge additively (INSERT OR IGNORE), then auto-creating any missing target nodes.
132
+ * Shared by the CLI indexer and the MCP commit_changes flow.
133
+ *
134
+ * @param opts.clearSources delete the source nodes' existing OUTGOING edges before re-resolving
135
+ * (drops edges the code no longer has) while leaving every other node's edges intact. Off by
136
+ * default (pure-additive) to match the CLI's per-node loop.
137
+ */
138
+ function resolveEdgesForNodes(db, devmindPath, sourceNodeIds, opts = {}) {
139
+ if (sourceNodeIds.length === 0)
140
+ return { edgesAdded: 0, missingFilled: 0 };
141
+ if (opts.clearSources) {
142
+ db.clearConnectionsForSources(sourceNodeIds);
143
+ }
144
+ const { missing, onMissing } = createMissingCollector();
145
+ const allNodes = db.listNodes();
146
+ const allIds = new Set(allNodes.map(n => n.id));
147
+ let edgesAdded = 0;
148
+ for (const rawId of sourceNodeIds) {
149
+ const n = db.getNode(rawId);
150
+ if (!n || !n.file_path)
151
+ continue;
152
+ for (const targetId of (0, ast_1.resolveConnectionsLocally)(n.id, n.file_path, allNodes, devmindPath, onMissing)) {
153
+ if (allIds.has(targetId)) {
154
+ db.addConnection(n.id, targetId);
155
+ edgesAdded++;
156
+ }
157
+ }
158
+ }
159
+ const missingFilled = finalizeMissingNodes(devmindPath, db, missing, { writeReport: false, quiet: true });
160
+ return { edgesAdded, missingFilled };
161
+ }
162
+ //# sourceMappingURL=edges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edges.js","sourceRoot":"","sources":["../../src/db/edges.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,wDASC;AAYD,oDAuEC;AAWD,oDA8BC;AA9ID,uCAAyB;AACzB,2CAA6B;AAE7B,sCAA0F;AAK1F,qFAAqF;AACrF,SAAgB,sBAAsB;IACpC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC9C,MAAM,SAAS,GAAG,CAAC,GAAe,EAAE,EAAE;QACpC,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC;QAC5C,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,CAAC,EAAE,CAAC;YAAC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAAC,CAAC;QAC1G,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC;AAED;;;;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0B,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACxD,MAAM,QAAQ,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhD,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;QAClC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YAAE,SAAS;QACjC,KAAK,MAAM,QAAQ,IAAI,IAAA,+BAAyB,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,CAAC;YACtG,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACzB,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;gBACjC,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,aAAa,GAAG,oBAAoB,CAAC,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1G,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AACvC,CAAC"}
@@ -13,8 +13,8 @@ export interface IndexScratchpad {
13
13
  repos_done: string[];
14
14
  current_repo: string | null;
15
15
  }
16
- export declare function readScratchpad(devmindPath: string): IndexScratchpad | null;
17
- export declare function writeScratchpad(devmindPath: string, data: IndexScratchpad): void;
18
- export declare function createScratchpad(devmindPath: string, filesTotal: number): IndexScratchpad;
16
+ export declare function readScratchpad(devmindPath: string, fileName?: string): IndexScratchpad | null;
17
+ export declare function writeScratchpad(devmindPath: string, data: IndexScratchpad, fileName?: string): void;
18
+ export declare function createScratchpad(devmindPath: string, filesTotal: number, fileName?: string): IndexScratchpad;
19
19
  export declare function updateScratchpad(devmindPath: string, patch: Partial<Omit<IndexScratchpad, 'started_at' | 'status'>>): IndexScratchpad;
20
20
  export declare function completeScratchpad(devmindPath: string): IndexScratchpad;
@@ -41,11 +41,11 @@ exports.completeScratchpad = completeScratchpad;
41
41
  const fs = __importStar(require("fs"));
42
42
  const path = __importStar(require("path"));
43
43
  const SCRATCHPAD_FILE = 'index_scratchpad.json';
44
- function scratchpadPath(devmindPath) {
45
- return path.join(path.resolve(devmindPath), SCRATCHPAD_FILE);
44
+ function scratchpadPath(devmindPath, fileName = SCRATCHPAD_FILE) {
45
+ return path.join(path.resolve(devmindPath), fileName);
46
46
  }
47
- function readScratchpad(devmindPath) {
48
- const p = scratchpadPath(devmindPath);
47
+ function readScratchpad(devmindPath, fileName) {
48
+ const p = scratchpadPath(devmindPath, fileName);
49
49
  if (!fs.existsSync(p))
50
50
  return null;
51
51
  try {
@@ -55,11 +55,11 @@ function readScratchpad(devmindPath) {
55
55
  return null;
56
56
  }
57
57
  }
58
- function writeScratchpad(devmindPath, data) {
59
- const p = scratchpadPath(devmindPath);
58
+ function writeScratchpad(devmindPath, data, fileName) {
59
+ const p = scratchpadPath(devmindPath, fileName);
60
60
  fs.writeFileSync(p, JSON.stringify(data, null, 2), 'utf-8');
61
61
  }
62
- function createScratchpad(devmindPath, filesTotal) {
62
+ function createScratchpad(devmindPath, filesTotal, fileName) {
63
63
  const now = new Date().toISOString();
64
64
  const pad = {
65
65
  status: 'in_progress',
@@ -76,7 +76,7 @@ function createScratchpad(devmindPath, filesTotal) {
76
76
  repos_done: [],
77
77
  current_repo: null
78
78
  };
79
- writeScratchpad(devmindPath, pad);
79
+ writeScratchpad(devmindPath, pad, fileName);
80
80
  return pad;
81
81
  }
82
82
  function updateScratchpad(devmindPath, patch) {
@@ -1 +1 @@
1
- {"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/db/indexer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,wCAQC;AAED,0CAGC;AAED,4CAmBC;AAED,4CAaC;AAED,gDAUC;AAtFD,uCAAyB;AACzB,2CAA6B;AAkB7B,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAEhD,SAAS,cAAc,CAAC,WAAmB;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,CAAC;AAC/D,CAAC;AAED,SAAgB,cAAc,CAAC,WAAmB;IAChD,MAAM,CAAC,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAoB,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAgB,eAAe,CAAC,WAAmB,EAAE,IAAqB;IACxE,MAAM,CAAC,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IACtC,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED,SAAgB,gBAAgB,CAAC,WAAmB,EAAE,UAAkB;IACtE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,GAAG,GAAoB;QAC3B,MAAM,EAAE,aAAa;Q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,EAAE,CAAC;QACb,WAAW,EAAE,UAAU;QACvB,aAAa,EAAE,CAAC;QAChB,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;QACd,mBAAmB,EAAE,CAAC;QACtB,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,IAAI;KACnB,CAAC;IACF,eAAe,CAAC,WAAW,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,gBAAgB,CAC9B,WAAmB,EACnB,KAA8D;IAE9D,MAAM,QAAQ,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACrF,MAAM,OAAO,GAAoB;QAC/B,GAAG,QAAQ;QACX,GAAG,KAAK;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACrC,CAAC;IACF,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,MAAM,QAAQ,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACrF,MAAM,SAAS,GAAoB;QACjC,GAAG,QAAQ;QACX,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACrC,CAAC;IACF,eAAe,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/dist/db/schema.js CHANGED
@@ -1,44 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.INIT_SCHEMA_SQL = void 0;
4
- exports.INIT_SCHEMA_SQL = `
5
- CREATE TABLE IF NOT EXISTS nodes (
6
- id TEXT PRIMARY KEY,
7
- type TEXT NOT NULL,
8
- name TEXT NOT NULL,
9
- file_path TEXT NOT NULL,
10
- signature TEXT,
11
- deprecated INTEGER DEFAULT 0,
12
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
13
- );
14
-
15
- CREATE TABLE IF NOT EXISTS node_connections (
16
- source_node_id TEXT,
17
- target_node_id TEXT,
18
- PRIMARY KEY (source_node_id, target_node_id),
19
- FOREIGN KEY (source_node_id) REFERENCES nodes (id) ON DELETE CASCADE,
20
- FOREIGN KEY (target_node_id) REFERENCES nodes (id) ON DELETE CASCADE
21
- );
22
-
23
- CREATE TABLE IF NOT EXISTS history (
24
- id TEXT PRIMARY KEY,
25
- node_id TEXT NOT NULL,
26
- session_id TEXT NOT NULL,
27
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
28
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
29
- code_snapshot TEXT NOT NULL,
30
- reasoning TEXT NOT NULL,
31
- FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
32
- );
33
-
34
- CREATE TABLE IF NOT EXISTS system_meta (
35
- key TEXT PRIMARY KEY,
36
- value TEXT NOT NULL,
37
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
38
- );
39
-
40
- -- Index for searching nodes by name and type
41
- CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes (name);
42
- CREATE INDEX IF NOT EXISTS idx_history_node_id ON history (node_id);
4
+ exports.INIT_SCHEMA_SQL = `
5
+ CREATE TABLE IF NOT EXISTS nodes (
6
+ id TEXT PRIMARY KEY,
7
+ type TEXT NOT NULL,
8
+ name TEXT NOT NULL,
9
+ file_path TEXT NOT NULL,
10
+ signature TEXT,
11
+ deprecated INTEGER DEFAULT 0,
12
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
13
+ );
14
+
15
+ CREATE TABLE IF NOT EXISTS node_connections (
16
+ source_node_id TEXT,
17
+ target_node_id TEXT,
18
+ PRIMARY KEY (source_node_id, target_node_id),
19
+ FOREIGN KEY (source_node_id) REFERENCES nodes (id) ON DELETE CASCADE,
20
+ FOREIGN KEY (target_node_id) REFERENCES nodes (id) ON DELETE CASCADE
21
+ );
22
+
23
+ CREATE TABLE IF NOT EXISTS history (
24
+ id TEXT PRIMARY KEY,
25
+ node_id TEXT NOT NULL,
26
+ session_id TEXT NOT NULL,
27
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
28
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
29
+ code_snapshot TEXT NOT NULL,
30
+ reasoning TEXT NOT NULL,
31
+ FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
32
+ );
33
+
34
+ CREATE TABLE IF NOT EXISTS system_meta (
35
+ key TEXT PRIMARY KEY,
36
+ value TEXT NOT NULL,
37
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
38
+ );
39
+
40
+ -- Index for searching nodes by name and type
41
+ CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes (name);
42
+ CREATE INDEX IF NOT EXISTS idx_history_node_id ON history (node_id);
43
43
  `;
44
44
  //# sourceMappingURL=schema.js.map
@@ -0,0 +1,39 @@
1
+ import { DevMindDatabase, ReasoningObject } from './database';
2
+ /** One staged change — the same payload as update_history, buffered for a later commit. */
3
+ export interface StagedEntry {
4
+ node_id: string;
5
+ file_path: string;
6
+ code_snapshot: string;
7
+ reasoning: string | ReasoningObject;
8
+ name?: string;
9
+ type?: string;
10
+ signature?: string;
11
+ session_id?: string;
12
+ /** Optional explicit edges to add on top of AST resolution (source defaults to this entry). */
13
+ connections?: {
14
+ source_node_id?: string;
15
+ target_node_id: string;
16
+ }[];
17
+ }
18
+ export declare function readStaged(devmindPath: string): StagedEntry[];
19
+ /** Appends one entry to the buffer and returns the new pending count. */
20
+ export declare function stageEntry(devmindPath: string, entry: StagedEntry): number;
21
+ export declare function clearStaged(devmindPath: string): void;
22
+ export interface CommitSummary {
23
+ nodes: number;
24
+ history_entries: number;
25
+ edges_added: number;
26
+ missing_filled: number;
27
+ }
28
+ /**
29
+ * Two-pass commit of a batch of staged changes:
30
+ * Pass 1 — upsert every node + write its history entry (so all nodes exist before any edge
31
+ * resolution; forward references within the batch resolve regardless of order).
32
+ * Pass 2 — clear-then-resolve each staged node's OUTGOING edges via the local AST resolver,
33
+ * auto-creating any missing target nodes. Only the staged nodes' own outbound edges
34
+ * are recomputed; every other node's edges are left intact.
35
+ *
36
+ * Idempotent: re-running the same batch yields the same graph (upsert + INSERT OR IGNORE +
37
+ * clear-then-resolve). Callers should clear the buffer only after this returns successfully.
38
+ */
39
+ export declare function commitStagedChanges(db: DevMindDatabase, devmindPath: string, entries: StagedEntry[]): CommitSummary;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.readStaged = readStaged;
37
+ exports.stageEntry = stageEntry;
38
+ exports.clearStaged = clearStaged;
39
+ exports.commitStagedChanges = commitStagedChanges;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const edges_1 = require("./edges");
43
+ const STAGING_FILE = 'history_scratchpad.json';
44
+ function stagingPath(devmindPath) {
45
+ return path.join(path.resolve(devmindPath), STAGING_FILE);
46
+ }
47
+ /** Atomic write (temp file + rename) so an accumulating buffer is never left half-written. */
48
+ function writeBuffer(devmindPath, buf) {
49
+ const target = stagingPath(devmindPath);
50
+ const tmp = `${target}.${process.pid}.tmp`;
51
+ fs.writeFileSync(tmp, JSON.stringify(buf, null, 2), 'utf-8');
52
+ fs.renameSync(tmp, target);
53
+ }
54
+ function readStaged(devmindPath) {
55
+ try {
56
+ const raw = fs.readFileSync(stagingPath(devmindPath), 'utf-8');
57
+ const buf = JSON.parse(raw);
58
+ return Array.isArray(buf.entries) ? buf.entries : [];
59
+ }
60
+ catch {
61
+ return [];
62
+ }
63
+ }
64
+ /** Appends one entry to the buffer and returns the new pending count. */
65
+ function stageEntry(devmindPath, entry) {
66
+ const entries = readStaged(devmindPath);
67
+ entries.push(entry);
68
+ writeBuffer(devmindPath, { entries, updated_at: new Date().toISOString() });
69
+ return entries.length;
70
+ }
71
+ function clearStaged(devmindPath) {
72
+ const target = stagingPath(devmindPath);
73
+ try {
74
+ if (fs.existsSync(target))
75
+ fs.unlinkSync(target);
76
+ }
77
+ catch { /* ignore */ }
78
+ }
79
+ /** Resolves an entry's raw node_id to the canonical `{repo}/relpath#symbol` form. */
80
+ function resolveEntryId(db, entry) {
81
+ if (entry.node_id.includes('#'))
82
+ return entry.node_id;
83
+ const repoRelPath = db.toRepoRelativePath(entry.file_path);
84
+ return `${repoRelPath}#${entry.node_id}`;
85
+ }
86
+ /**
87
+ * Two-pass commit of a batch of staged changes:
88
+ * Pass 1 — upsert every node + write its history entry (so all nodes exist before any edge
89
+ * resolution; forward references within the batch resolve regardless of order).
90
+ * Pass 2 — clear-then-resolve each staged node's OUTGOING edges via the local AST resolver,
91
+ * auto-creating any missing target nodes. Only the staged nodes' own outbound edges
92
+ * are recomputed; every other node's edges are left intact.
93
+ *
94
+ * Idempotent: re-running the same batch yields the same graph (upsert + INSERT OR IGNORE +
95
+ * clear-then-resolve). Callers should clear the buffer only after this returns successfully.
96
+ */
97
+ function commitStagedChanges(db, devmindPath, entries) {
98
+ const stagedIds = [];
99
+ // Pass 1 — nodes + history (+ any explicit connections the caller supplied).
100
+ const explicitEdges = [];
101
+ for (const entry of entries) {
102
+ const nodeId = resolveEntryId(db, entry);
103
+ stagedIds.push(nodeId);
104
+ const name = entry.name || (entry.node_id.includes('.') ? entry.node_id.split('.').pop() : entry.node_id);
105
+ const type = entry.type || (entry.node_id.includes('.') ? 'method' : 'function');
106
+ db.upsertNode({
107
+ id: nodeId,
108
+ name,
109
+ type,
110
+ file_path: entry.file_path,
111
+ signature: entry.signature || null
112
+ });
113
+ db.updateHistory({
114
+ node_id: nodeId,
115
+ code_snapshot: entry.code_snapshot,
116
+ reasoning: entry.reasoning,
117
+ session_id: entry.session_id
118
+ });
119
+ for (const c of entry.connections || []) {
120
+ if (c.target_node_id)
121
+ explicitEdges.push({ source: c.source_node_id || nodeId, target: c.target_node_id });
122
+ }
123
+ }
124
+ // Pass 2 — AST edge resolution for the batch (clear stale outbound edges of staged nodes first).
125
+ const { edgesAdded, missingFilled } = (0, edges_1.resolveEdgesForNodes)(db, devmindPath, stagedIds, { clearSources: true });
126
+ // Apply any explicit edges the caller passed, on top of AST resolution (additive).
127
+ for (const e of explicitEdges) {
128
+ db.addConnection(e.source, e.target);
129
+ }
130
+ return {
131
+ nodes: entries.length,
132
+ history_entries: entries.length,
133
+ edges_added: edgesAdded + explicitEdges.length,
134
+ missing_filled: missingFilled
135
+ };
136
+ }
137
+ //# sourceMappingURL=staging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staging.js","sourceRoot":"","sources":["../../src/db/staging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,gCAQC;AAGD,gCAKC;AAED,kCAKC;AA2BD,kDAiDC;AAzID,uCAAyB;AACzB,2CAA6B;AAE7B,mCAA+C;AAE/C,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAqB/C,SAAS,WAAW,CAAC,WAAmB;IACtC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC;AAC5D,CAAC;AAED,8FAA8F;AAC9F,SAAS,WAAW,CAAC,WAAmB,EAAE,GAAkB;IAC1D,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC;IAC3C,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7D,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED,SAAgB,UAAU,CAAC,WAAmB;IAC5C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB,CAAC;QAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAA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