devsmind-mcp 1.0.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.
- package/LICENSE +21 -0
- package/README.md +280 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +105 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +1 -0
- package/dist/cli/init.js +626 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/prune.d.ts +3 -0
- package/dist/cli/prune.js +297 -0
- package/dist/cli/prune.js.map +1 -0
- package/dist/cli/rule.d.ts +3 -0
- package/dist/cli/rule.js +157 -0
- package/dist/cli/rule.js.map +1 -0
- package/dist/cli/view.d.ts +4 -0
- package/dist/cli/view.js +107 -0
- package/dist/cli/view.js.map +1 -0
- package/dist/db/database.d.ts +92 -0
- package/dist/db/database.js +479 -0
- package/dist/db/database.js.map +1 -0
- package/dist/db/indexer.d.ts +17 -0
- package/dist/db/indexer.js +103 -0
- package/dist/db/indexer.js.map +1 -0
- package/dist/db/schema.d.ts +23 -0
- package/dist/db/schema.js +38 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.js +1104 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/visualizer.d.ts +2 -0
- package/dist/mcp/visualizer.js +42 -0
- package/dist/mcp/visualizer.js.map +1 -0
- package/dist/mcp/visualizer_2d.html +635 -0
- package/dist/mcp/visualizer_3d.html +628 -0
- package/dist/utils/config.d.ts +43 -0
- package/dist/utils/config.js +91 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/scanner.d.ts +13 -0
- package/dist/utils/scanner.js +106 -0
- package/dist/utils/scanner.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { DbNode, DbHistory, DbConnection } from './schema';
|
|
2
|
+
export interface ReasoningObject {
|
|
3
|
+
what_changed: string;
|
|
4
|
+
why: string;
|
|
5
|
+
goal: string;
|
|
6
|
+
requirement?: string;
|
|
7
|
+
previous_state?: string;
|
|
8
|
+
decision?: string;
|
|
9
|
+
developer?: string;
|
|
10
|
+
model?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function formatReasoning(r: string | ReasoningObject): string;
|
|
13
|
+
export declare class DevMindDatabase {
|
|
14
|
+
private db;
|
|
15
|
+
constructor(dbPath: string);
|
|
16
|
+
private initSchema;
|
|
17
|
+
close(): void;
|
|
18
|
+
upsertNode(node: {
|
|
19
|
+
id: string;
|
|
20
|
+
type: string;
|
|
21
|
+
name: string;
|
|
22
|
+
file_path: string;
|
|
23
|
+
signature?: string | null;
|
|
24
|
+
}): void;
|
|
25
|
+
getNode(id: string): DbNode | null;
|
|
26
|
+
deleteNode(id: string): void;
|
|
27
|
+
deprecateNode(id: string): void;
|
|
28
|
+
renameNode(oldId: string, newId: string, newName?: string): void;
|
|
29
|
+
addConnection(sourceNodeId: string, targetNodeId: string): void;
|
|
30
|
+
removeConnection(sourceNodeId: string, targetNodeId: string): void;
|
|
31
|
+
getConnections(nodeId: string): {
|
|
32
|
+
uses: DbNode[];
|
|
33
|
+
usedBy: DbNode[];
|
|
34
|
+
};
|
|
35
|
+
getLatestHistory(nodeId: string): DbHistory | null;
|
|
36
|
+
listHistory(nodeId: string): Omit<DbHistory, 'code_snapshot' | 'reasoning'>[];
|
|
37
|
+
getHistoryEntry(id: string): DbHistory | null;
|
|
38
|
+
getFullHistory(nodeId: string): DbHistory[];
|
|
39
|
+
getLatestCode(nodeId: string): {
|
|
40
|
+
code_snapshot: string;
|
|
41
|
+
updated_at: string;
|
|
42
|
+
} | null;
|
|
43
|
+
getGraph(nodeId: string, maxDepth?: number): {
|
|
44
|
+
nodes: DbNode[];
|
|
45
|
+
connections: DbConnection[];
|
|
46
|
+
};
|
|
47
|
+
updateHistory(params: {
|
|
48
|
+
node_id: string;
|
|
49
|
+
code_snapshot: string;
|
|
50
|
+
reasoning: string | ReasoningObject;
|
|
51
|
+
session_id?: string;
|
|
52
|
+
}): DbHistory;
|
|
53
|
+
searchNodes(query: string): DbNode[];
|
|
54
|
+
getRecentChanges(hours?: number): {
|
|
55
|
+
node_id: string;
|
|
56
|
+
node_name: string;
|
|
57
|
+
file_path: string;
|
|
58
|
+
updated_at: string;
|
|
59
|
+
reasoning: string;
|
|
60
|
+
}[];
|
|
61
|
+
getDeveloperActivity(developer: string, limit?: number): {
|
|
62
|
+
node_id: string;
|
|
63
|
+
node_name: string;
|
|
64
|
+
updated_at: string;
|
|
65
|
+
reasoning: string;
|
|
66
|
+
}[];
|
|
67
|
+
getChangesByRequirement(requirementId: string): {
|
|
68
|
+
node_id: string;
|
|
69
|
+
node_name: string;
|
|
70
|
+
updated_at: string;
|
|
71
|
+
reasoning: string;
|
|
72
|
+
}[];
|
|
73
|
+
searchDecisions(query: string): {
|
|
74
|
+
node_id: string;
|
|
75
|
+
node_name: string;
|
|
76
|
+
updated_at: string;
|
|
77
|
+
reasoning: string;
|
|
78
|
+
}[];
|
|
79
|
+
getOrphanedNodes(): DbNode[];
|
|
80
|
+
getAllNodes(): DbNode[];
|
|
81
|
+
listNodes(filter?: {
|
|
82
|
+
type?: string;
|
|
83
|
+
file_path?: string;
|
|
84
|
+
include_deprecated?: boolean;
|
|
85
|
+
}): DbNode[];
|
|
86
|
+
getAllConnections(): DbConnection[];
|
|
87
|
+
getAllHistory(): DbHistory[];
|
|
88
|
+
pruneSpuriousNodes(workspaceRoot: string): {
|
|
89
|
+
prunedCount: number;
|
|
90
|
+
prunedNodes: string[];
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,479 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DevMindDatabase = void 0;
|
|
40
|
+
exports.formatReasoning = formatReasoning;
|
|
41
|
+
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
42
|
+
const crypto = __importStar(require("crypto"));
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const schema_1 = require("./schema");
|
|
46
|
+
function formatReasoning(r) {
|
|
47
|
+
if (typeof r === 'string') {
|
|
48
|
+
return r;
|
|
49
|
+
}
|
|
50
|
+
const lines = [
|
|
51
|
+
`What changed: ${r.what_changed || ''}`,
|
|
52
|
+
`Why: ${r.why || ''}`,
|
|
53
|
+
`Goal: ${r.goal || ''}`,
|
|
54
|
+
`Requirement: ${r.requirement || ''}`,
|
|
55
|
+
`Previous state: ${r.previous_state || ''}`,
|
|
56
|
+
`Decision: ${r.decision || ''}`,
|
|
57
|
+
`Developer: ${r.developer || ''}`,
|
|
58
|
+
`Model: ${r.model || ''}`
|
|
59
|
+
];
|
|
60
|
+
return lines.join('\n');
|
|
61
|
+
}
|
|
62
|
+
class DevMindDatabase {
|
|
63
|
+
db;
|
|
64
|
+
constructor(dbPath) {
|
|
65
|
+
// Open SQLite database
|
|
66
|
+
this.db = new better_sqlite3_1.default(dbPath);
|
|
67
|
+
// Enable foreign keys
|
|
68
|
+
this.db.pragma('foreign_keys = ON');
|
|
69
|
+
// Initialize schema
|
|
70
|
+
this.initSchema();
|
|
71
|
+
}
|
|
72
|
+
initSchema() {
|
|
73
|
+
this.db.exec(schema_1.INIT_SCHEMA_SQL);
|
|
74
|
+
try {
|
|
75
|
+
this.db.exec('ALTER TABLE nodes ADD COLUMN deprecated INTEGER DEFAULT 0');
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Column already exists, ignore
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
close() {
|
|
82
|
+
this.db.close();
|
|
83
|
+
}
|
|
84
|
+
// --- Node Operations ---
|
|
85
|
+
upsertNode(node) {
|
|
86
|
+
const stmt = this.db.prepare(`
|
|
87
|
+
INSERT INTO nodes (id, type, name, file_path, signature)
|
|
88
|
+
VALUES (?, ?, ?, ?, ?)
|
|
89
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
90
|
+
type = excluded.type,
|
|
91
|
+
name = excluded.name,
|
|
92
|
+
file_path = excluded.file_path,
|
|
93
|
+
signature = COALESCE(excluded.signature, nodes.signature),
|
|
94
|
+
deprecated = 0
|
|
95
|
+
`);
|
|
96
|
+
stmt.run(node.id, node.type, node.name, node.file_path, node.signature || null);
|
|
97
|
+
}
|
|
98
|
+
getNode(id) {
|
|
99
|
+
const stmt = this.db.prepare('SELECT * FROM nodes WHERE id = ?');
|
|
100
|
+
return stmt.get(id) || null;
|
|
101
|
+
}
|
|
102
|
+
deleteNode(id) {
|
|
103
|
+
const stmt = this.db.prepare('DELETE FROM nodes WHERE id = ?');
|
|
104
|
+
stmt.run(id);
|
|
105
|
+
}
|
|
106
|
+
deprecateNode(id) {
|
|
107
|
+
const updateStmt = this.db.prepare('UPDATE nodes SET deprecated = 1 WHERE id = ?');
|
|
108
|
+
const deleteConnStmt = this.db.prepare('DELETE FROM node_connections WHERE source_node_id = ? OR target_node_id = ?');
|
|
109
|
+
const tx = this.db.transaction(() => {
|
|
110
|
+
updateStmt.run(id);
|
|
111
|
+
deleteConnStmt.run(id, id);
|
|
112
|
+
});
|
|
113
|
+
tx();
|
|
114
|
+
}
|
|
115
|
+
renameNode(oldId, newId, newName) {
|
|
116
|
+
const node = this.getNode(oldId);
|
|
117
|
+
if (!node) {
|
|
118
|
+
throw new Error(`Node not found: ${oldId}`);
|
|
119
|
+
}
|
|
120
|
+
const name = newName || (node.name === oldId ? newId : node.name);
|
|
121
|
+
this.db.pragma('foreign_keys = OFF');
|
|
122
|
+
try {
|
|
123
|
+
const runTx = this.db.transaction(() => {
|
|
124
|
+
const insertStmt = this.db.prepare(`
|
|
125
|
+
INSERT INTO nodes (id, type, name, file_path, signature, created_at)
|
|
126
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
127
|
+
`);
|
|
128
|
+
insertStmt.run(newId, node.type, name, node.file_path, node.signature, node.created_at);
|
|
129
|
+
const updateSourceStmt = this.db.prepare(`
|
|
130
|
+
UPDATE node_connections SET source_node_id = ? WHERE source_node_id = ?
|
|
131
|
+
`);
|
|
132
|
+
updateSourceStmt.run(newId, oldId);
|
|
133
|
+
const updateTargetStmt = this.db.prepare(`
|
|
134
|
+
UPDATE node_connections SET target_node_id = ? WHERE target_node_id = ?
|
|
135
|
+
`);
|
|
136
|
+
updateTargetStmt.run(newId, oldId);
|
|
137
|
+
const updateHistoryStmt = this.db.prepare(`
|
|
138
|
+
UPDATE history SET node_id = ? WHERE node_id = ?
|
|
139
|
+
`);
|
|
140
|
+
updateHistoryStmt.run(newId, oldId);
|
|
141
|
+
const deleteOldStmt = this.db.prepare('DELETE FROM nodes WHERE id = ?');
|
|
142
|
+
deleteOldStmt.run(oldId);
|
|
143
|
+
});
|
|
144
|
+
runTx();
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
this.db.pragma('foreign_keys = ON');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// --- Connection Operations ---
|
|
151
|
+
addConnection(sourceNodeId, targetNodeId) {
|
|
152
|
+
const stmt = this.db.prepare(`
|
|
153
|
+
INSERT OR IGNORE INTO node_connections (source_node_id, target_node_id)
|
|
154
|
+
VALUES (?, ?)
|
|
155
|
+
`);
|
|
156
|
+
stmt.run(sourceNodeId, targetNodeId);
|
|
157
|
+
}
|
|
158
|
+
removeConnection(sourceNodeId, targetNodeId) {
|
|
159
|
+
const stmt = this.db.prepare(`
|
|
160
|
+
DELETE FROM node_connections
|
|
161
|
+
WHERE source_node_id = ? AND target_node_id = ?
|
|
162
|
+
`);
|
|
163
|
+
stmt.run(sourceNodeId, targetNodeId);
|
|
164
|
+
}
|
|
165
|
+
getConnections(nodeId) {
|
|
166
|
+
const usesStmt = this.db.prepare(`
|
|
167
|
+
SELECT n.* FROM nodes n
|
|
168
|
+
JOIN node_connections c ON n.id = c.target_node_id
|
|
169
|
+
WHERE c.source_node_id = ?
|
|
170
|
+
`);
|
|
171
|
+
const usedByStmt = this.db.prepare(`
|
|
172
|
+
SELECT n.* FROM nodes n
|
|
173
|
+
JOIN node_connections c ON n.id = c.source_node_id
|
|
174
|
+
WHERE c.target_node_id = ?
|
|
175
|
+
`);
|
|
176
|
+
return {
|
|
177
|
+
uses: usesStmt.all(nodeId),
|
|
178
|
+
usedBy: usedByStmt.all(nodeId)
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// --- History Operations ---
|
|
182
|
+
getLatestHistory(nodeId) {
|
|
183
|
+
const stmt = this.db.prepare(`
|
|
184
|
+
SELECT * FROM history
|
|
185
|
+
WHERE node_id = ?
|
|
186
|
+
ORDER BY updated_at DESC
|
|
187
|
+
LIMIT 1
|
|
188
|
+
`);
|
|
189
|
+
return stmt.get(nodeId) || null;
|
|
190
|
+
}
|
|
191
|
+
listHistory(nodeId) {
|
|
192
|
+
const stmt = this.db.prepare(`
|
|
193
|
+
SELECT id, node_id, session_id, created_at, updated_at
|
|
194
|
+
FROM history
|
|
195
|
+
WHERE node_id = ?
|
|
196
|
+
ORDER BY updated_at DESC
|
|
197
|
+
`);
|
|
198
|
+
return stmt.all(nodeId);
|
|
199
|
+
}
|
|
200
|
+
getHistoryEntry(id) {
|
|
201
|
+
const stmt = this.db.prepare('SELECT * FROM history WHERE id = ?');
|
|
202
|
+
return stmt.get(id) || null;
|
|
203
|
+
}
|
|
204
|
+
getFullHistory(nodeId) {
|
|
205
|
+
const stmt = this.db.prepare(`
|
|
206
|
+
SELECT *
|
|
207
|
+
FROM history
|
|
208
|
+
WHERE node_id = ?
|
|
209
|
+
ORDER BY updated_at DESC
|
|
210
|
+
`);
|
|
211
|
+
return stmt.all(nodeId);
|
|
212
|
+
}
|
|
213
|
+
getLatestCode(nodeId) {
|
|
214
|
+
const stmt = this.db.prepare(`
|
|
215
|
+
SELECT code_snapshot, updated_at
|
|
216
|
+
FROM history
|
|
217
|
+
WHERE node_id = ?
|
|
218
|
+
ORDER BY updated_at DESC
|
|
219
|
+
LIMIT 1
|
|
220
|
+
`);
|
|
221
|
+
return stmt.get(nodeId) || null;
|
|
222
|
+
}
|
|
223
|
+
getGraph(nodeId, maxDepth = 6) {
|
|
224
|
+
const maxNodesLimit = 500;
|
|
225
|
+
const visited = new Set();
|
|
226
|
+
const queue = [{ id: nodeId, depth: 0 }];
|
|
227
|
+
const nodes = [];
|
|
228
|
+
const connections = [];
|
|
229
|
+
const connSet = new Set();
|
|
230
|
+
const rootNode = this.getNode(nodeId);
|
|
231
|
+
if (!rootNode) {
|
|
232
|
+
return { nodes, connections };
|
|
233
|
+
}
|
|
234
|
+
visited.add(nodeId);
|
|
235
|
+
nodes.push(rootNode);
|
|
236
|
+
const usesStmt = this.db.prepare(`
|
|
237
|
+
SELECT target_node_id FROM node_connections WHERE source_node_id = ?
|
|
238
|
+
`);
|
|
239
|
+
const usedByStmt = this.db.prepare(`
|
|
240
|
+
SELECT source_node_id FROM node_connections WHERE target_node_id = ?
|
|
241
|
+
`);
|
|
242
|
+
while (queue.length > 0 && nodes.length < maxNodesLimit) {
|
|
243
|
+
const current = queue.shift();
|
|
244
|
+
if (current.depth >= maxDepth) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
// Get outbound connections (what this node uses)
|
|
248
|
+
const outbound = usesStmt.all(current.id);
|
|
249
|
+
for (const row of outbound) {
|
|
250
|
+
const targetId = row.target_node_id;
|
|
251
|
+
const connKey = `${current.id}->${targetId}`;
|
|
252
|
+
if (!connSet.has(connKey)) {
|
|
253
|
+
connSet.add(connKey);
|
|
254
|
+
connections.push({ source_node_id: current.id, target_node_id: targetId });
|
|
255
|
+
}
|
|
256
|
+
if (!visited.has(targetId)) {
|
|
257
|
+
visited.add(targetId);
|
|
258
|
+
const targetNode = this.getNode(targetId);
|
|
259
|
+
if (targetNode) {
|
|
260
|
+
nodes.push(targetNode);
|
|
261
|
+
if (nodes.length >= maxNodesLimit)
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
queue.push({ id: targetId, depth: current.depth + 1 });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (nodes.length >= maxNodesLimit)
|
|
268
|
+
break;
|
|
269
|
+
// Get inbound connections (what uses this node)
|
|
270
|
+
const inbound = usedByStmt.all(current.id);
|
|
271
|
+
for (const row of inbound) {
|
|
272
|
+
const sourceId = row.source_node_id;
|
|
273
|
+
const connKey = `${sourceId}->${current.id}`;
|
|
274
|
+
if (!connSet.has(connKey)) {
|
|
275
|
+
connSet.add(connKey);
|
|
276
|
+
connections.push({ source_node_id: sourceId, target_node_id: current.id });
|
|
277
|
+
}
|
|
278
|
+
if (!visited.has(sourceId)) {
|
|
279
|
+
visited.add(sourceId);
|
|
280
|
+
const sourceNode = this.getNode(sourceId);
|
|
281
|
+
if (sourceNode) {
|
|
282
|
+
nodes.push(sourceNode);
|
|
283
|
+
if (nodes.length >= maxNodesLimit)
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
queue.push({ id: sourceId, depth: current.depth + 1 });
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return { nodes, connections };
|
|
291
|
+
}
|
|
292
|
+
updateHistory(params) {
|
|
293
|
+
const { node_id, code_snapshot, reasoning } = params;
|
|
294
|
+
const formattedReasoning = formatReasoning(reasoning);
|
|
295
|
+
const nowStr = new Date().toISOString();
|
|
296
|
+
// 1-hour session boundary rule check
|
|
297
|
+
const latest = this.getLatestHistory(node_id);
|
|
298
|
+
if (latest) {
|
|
299
|
+
const lastUpdate = new Date(latest.updated_at).getTime();
|
|
300
|
+
const nowTime = new Date(nowStr).getTime();
|
|
301
|
+
const diffMs = nowTime - lastUpdate;
|
|
302
|
+
// If updated < 1 hour ago, update same record
|
|
303
|
+
if (diffMs < 3600000) {
|
|
304
|
+
const updateStmt = this.db.prepare(`
|
|
305
|
+
UPDATE history
|
|
306
|
+
SET code_snapshot = ?, reasoning = ?, updated_at = ?
|
|
307
|
+
WHERE id = ?
|
|
308
|
+
`);
|
|
309
|
+
updateStmt.run(code_snapshot, formattedReasoning, nowStr, latest.id);
|
|
310
|
+
return {
|
|
311
|
+
...latest,
|
|
312
|
+
code_snapshot,
|
|
313
|
+
reasoning: formattedReasoning,
|
|
314
|
+
updated_at: nowStr
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Otherwise (or if no record exists), insert new history block
|
|
319
|
+
const newId = crypto.randomUUID();
|
|
320
|
+
const sessionId = params.session_id || crypto.randomUUID();
|
|
321
|
+
const insertStmt = this.db.prepare(`
|
|
322
|
+
INSERT INTO history (id, node_id, session_id, created_at, updated_at, code_snapshot, reasoning)
|
|
323
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
324
|
+
`);
|
|
325
|
+
insertStmt.run(newId, node_id, sessionId, nowStr, nowStr, code_snapshot, formattedReasoning);
|
|
326
|
+
return {
|
|
327
|
+
id: newId,
|
|
328
|
+
node_id,
|
|
329
|
+
session_id: sessionId,
|
|
330
|
+
created_at: nowStr,
|
|
331
|
+
updated_at: nowStr,
|
|
332
|
+
code_snapshot,
|
|
333
|
+
reasoning: formattedReasoning
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
// --- Search Operations ---
|
|
337
|
+
searchNodes(query) {
|
|
338
|
+
const stmt = this.db.prepare(`
|
|
339
|
+
SELECT DISTINCT n.* FROM nodes n
|
|
340
|
+
LEFT JOIN history h ON n.id = h.node_id
|
|
341
|
+
WHERE n.name LIKE ? OR n.id LIKE ? OR h.reasoning LIKE ?
|
|
342
|
+
LIMIT 50
|
|
343
|
+
`);
|
|
344
|
+
const wildcard = `%${query}%`;
|
|
345
|
+
return stmt.all(wildcard, wildcard, wildcard);
|
|
346
|
+
}
|
|
347
|
+
getRecentChanges(hours = 24) {
|
|
348
|
+
const stmt = this.db.prepare(`
|
|
349
|
+
SELECT h.node_id, n.name as node_name, n.file_path, h.updated_at, h.reasoning
|
|
350
|
+
FROM history h
|
|
351
|
+
JOIN nodes n ON h.node_id = n.id
|
|
352
|
+
WHERE h.updated_at >= datetime('now', ?)
|
|
353
|
+
ORDER BY h.updated_at DESC
|
|
354
|
+
`);
|
|
355
|
+
// SQLite datetime('now', '-24 hours') style modifier
|
|
356
|
+
return stmt.all(`-${hours} hours`);
|
|
357
|
+
}
|
|
358
|
+
getDeveloperActivity(developer, limit = 50) {
|
|
359
|
+
const stmt = this.db.prepare(`
|
|
360
|
+
SELECT h.node_id, n.name as node_name, h.updated_at, h.reasoning
|
|
361
|
+
FROM history h
|
|
362
|
+
JOIN nodes n ON h.node_id = n.id
|
|
363
|
+
WHERE h.reasoning LIKE ?
|
|
364
|
+
ORDER BY h.updated_at DESC
|
|
365
|
+
LIMIT ?
|
|
366
|
+
`);
|
|
367
|
+
const query = `%Developer: %${developer}%`;
|
|
368
|
+
return stmt.all(query, limit);
|
|
369
|
+
}
|
|
370
|
+
getChangesByRequirement(requirementId) {
|
|
371
|
+
const stmt = this.db.prepare(`
|
|
372
|
+
SELECT h.node_id, n.name as node_name, h.updated_at, h.reasoning
|
|
373
|
+
FROM history h
|
|
374
|
+
JOIN nodes n ON h.node_id = n.id
|
|
375
|
+
WHERE h.reasoning LIKE ?
|
|
376
|
+
ORDER BY h.updated_at DESC
|
|
377
|
+
`);
|
|
378
|
+
const query = `%Requirement: %${requirementId}%`;
|
|
379
|
+
return stmt.all(query);
|
|
380
|
+
}
|
|
381
|
+
searchDecisions(query) {
|
|
382
|
+
const stmt = this.db.prepare(`
|
|
383
|
+
SELECT h.node_id, n.name as node_name, h.updated_at, h.reasoning
|
|
384
|
+
FROM history h
|
|
385
|
+
JOIN nodes n ON h.node_id = n.id
|
|
386
|
+
WHERE h.reasoning LIKE ?
|
|
387
|
+
ORDER BY h.updated_at DESC
|
|
388
|
+
`);
|
|
389
|
+
const wildcard = `%Decision: %${query}%`;
|
|
390
|
+
return stmt.all(wildcard);
|
|
391
|
+
}
|
|
392
|
+
getOrphanedNodes() {
|
|
393
|
+
const stmt = this.db.prepare(`
|
|
394
|
+
SELECT * FROM nodes
|
|
395
|
+
WHERE id NOT IN (SELECT DISTINCT source_node_id FROM node_connections)
|
|
396
|
+
AND id NOT IN (SELECT DISTINCT target_node_id FROM node_connections)
|
|
397
|
+
`);
|
|
398
|
+
return stmt.all();
|
|
399
|
+
}
|
|
400
|
+
getAllNodes() {
|
|
401
|
+
const stmt = this.db.prepare('SELECT * FROM nodes');
|
|
402
|
+
return stmt.all();
|
|
403
|
+
}
|
|
404
|
+
listNodes(filter) {
|
|
405
|
+
let sql = 'SELECT * FROM nodes WHERE 1=1';
|
|
406
|
+
const params = [];
|
|
407
|
+
if (filter?.type) {
|
|
408
|
+
sql += ' AND type = ?';
|
|
409
|
+
params.push(filter.type);
|
|
410
|
+
}
|
|
411
|
+
if (filter?.file_path) {
|
|
412
|
+
sql += ' AND file_path LIKE ?';
|
|
413
|
+
params.push(`%${filter.file_path}%`);
|
|
414
|
+
}
|
|
415
|
+
if (!filter?.include_deprecated) {
|
|
416
|
+
sql += ' AND deprecated = 0';
|
|
417
|
+
}
|
|
418
|
+
const stmt = this.db.prepare(sql);
|
|
419
|
+
return stmt.all(...params);
|
|
420
|
+
}
|
|
421
|
+
getAllConnections() {
|
|
422
|
+
const stmt = this.db.prepare('SELECT * FROM node_connections');
|
|
423
|
+
return stmt.all();
|
|
424
|
+
}
|
|
425
|
+
getAllHistory() {
|
|
426
|
+
const stmt = this.db.prepare('SELECT * FROM history ORDER BY updated_at DESC');
|
|
427
|
+
return stmt.all();
|
|
428
|
+
}
|
|
429
|
+
pruneSpuriousNodes(workspaceRoot) {
|
|
430
|
+
const spuriousNames = new Set([
|
|
431
|
+
'promise', 'map', 'set', 'json', 'console', 'error', 'object', 'function', 'array', 'string', 'number', 'boolean', 'regexp', 'date', 'math',
|
|
432
|
+
'any', 'void', 'unknown', 'never', 'null', 'undefined', 'dict', 'list'
|
|
433
|
+
]);
|
|
434
|
+
// Get nodes with 0 history entries that are not already deprecated
|
|
435
|
+
const stmt = this.db.prepare(`
|
|
436
|
+
SELECT id, name, file_path FROM nodes
|
|
437
|
+
WHERE deprecated = 0 AND id NOT IN (SELECT DISTINCT node_id FROM history)
|
|
438
|
+
`);
|
|
439
|
+
const candidates = stmt.all();
|
|
440
|
+
const idsToDelete = [];
|
|
441
|
+
const namesDeleted = [];
|
|
442
|
+
for (const node of candidates) {
|
|
443
|
+
const lowerName = node.name.toLowerCase();
|
|
444
|
+
// 1. Check if name is in the spurious list
|
|
445
|
+
const isSpurious = spuriousNames.has(lowerName);
|
|
446
|
+
// 2. Check if file path does not exist on disk
|
|
447
|
+
let fileMissing = false;
|
|
448
|
+
if (node.file_path) {
|
|
449
|
+
const resolvedPath = path.isAbsolute(node.file_path)
|
|
450
|
+
? node.file_path
|
|
451
|
+
: path.resolve(workspaceRoot, node.file_path);
|
|
452
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
453
|
+
fileMissing = true;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (isSpurious || fileMissing) {
|
|
457
|
+
idsToDelete.push(node.id);
|
|
458
|
+
namesDeleted.push(`${node.name} (${node.id})`);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (idsToDelete.length > 0) {
|
|
462
|
+
const updateStmt = this.db.prepare('UPDATE nodes SET deprecated = 1 WHERE id = ?');
|
|
463
|
+
const deleteConnStmt = this.db.prepare('DELETE FROM node_connections WHERE source_node_id = ? OR target_node_id = ?');
|
|
464
|
+
const deprecateTx = this.db.transaction((ids) => {
|
|
465
|
+
for (const id of ids) {
|
|
466
|
+
updateStmt.run(id);
|
|
467
|
+
deleteConnStmt.run(id, id);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
deprecateTx(idsToDelete);
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
prunedCount: idsToDelete.length,
|
|
474
|
+
prunedNodes: namesDeleted
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
exports.DevMindDatabase = DevMindDatabase;
|
|
479
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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: 'in_progress' | 'complete';
|
|
3
|
+
started_at: string;
|
|
4
|
+
updated_at: string;
|
|
5
|
+
files_done: number;
|
|
6
|
+
files_total: number;
|
|
7
|
+
nodes_created: number;
|
|
8
|
+
connections_created: number;
|
|
9
|
+
last_file_indexed: string | null;
|
|
10
|
+
repos_done: string[];
|
|
11
|
+
current_repo: string | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function readScratchpad(devmindPath: string): IndexScratchpad | null;
|
|
14
|
+
export declare function writeScratchpad(devmindPath: string, data: IndexScratchpad): void;
|
|
15
|
+
export declare function createScratchpad(devmindPath: string, filesTotal: number): IndexScratchpad;
|
|
16
|
+
export declare function updateScratchpad(devmindPath: string, patch: Partial<Omit<IndexScratchpad, 'started_at' | 'status'>>): IndexScratchpad;
|
|
17
|
+
export declare function completeScratchpad(devmindPath: string): IndexScratchpad;
|