engram-mcp-server 1.2.8 → 1.2.9

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.
Files changed (210) hide show
  1. package/README.md +12 -1
  2. package/dist/constants.d.ts +1 -1
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +6 -1
  5. package/dist/constants.js.map +1 -1
  6. package/dist/index.js +7 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/installer/ide-detector.d.ts.map +1 -1
  9. package/dist/installer/ide-detector.js +10 -6
  10. package/dist/installer/ide-detector.js.map +1 -1
  11. package/dist/installer/index.d.ts.map +1 -1
  12. package/dist/installer/index.js +79 -15
  13. package/dist/installer/index.js.map +1 -1
  14. package/package.json +6 -3
  15. package/dist/installer.d.ts +0 -2
  16. package/dist/installer.d.ts.map +0 -1
  17. package/dist/installer.js +0 -315
  18. package/dist/installer.js.map +0 -1
  19. package/dist/src/constants.d.ts +0 -21
  20. package/dist/src/constants.d.ts.map +0 -1
  21. package/dist/src/constants.js +0 -81
  22. package/dist/src/constants.js.map +0 -1
  23. package/dist/src/database.d.ts +0 -32
  24. package/dist/src/database.d.ts.map +0 -1
  25. package/dist/src/database.js +0 -143
  26. package/dist/src/database.js.map +0 -1
  27. package/dist/src/errors.d.ts +0 -40
  28. package/dist/src/errors.d.ts.map +0 -1
  29. package/dist/src/errors.js +0 -63
  30. package/dist/src/errors.js.map +0 -1
  31. package/dist/src/index.d.ts +0 -3
  32. package/dist/src/index.d.ts.map +0 -1
  33. package/dist/src/index.js +0 -89
  34. package/dist/src/index.js.map +0 -1
  35. package/dist/src/installer/config-writer.d.ts +0 -25
  36. package/dist/src/installer/config-writer.d.ts.map +0 -1
  37. package/dist/src/installer/config-writer.js +0 -86
  38. package/dist/src/installer/config-writer.js.map +0 -1
  39. package/dist/src/installer/ide-configs.d.ts +0 -19
  40. package/dist/src/installer/ide-configs.d.ts.map +0 -1
  41. package/dist/src/installer/ide-configs.js +0 -131
  42. package/dist/src/installer/ide-configs.js.map +0 -1
  43. package/dist/src/installer/ide-detector.d.ts +0 -6
  44. package/dist/src/installer/ide-detector.d.ts.map +0 -1
  45. package/dist/src/installer/ide-detector.js +0 -45
  46. package/dist/src/installer/ide-detector.js.map +0 -1
  47. package/dist/src/installer/index.d.ts +0 -2
  48. package/dist/src/installer/index.d.ts.map +0 -1
  49. package/dist/src/installer/index.js +0 -229
  50. package/dist/src/installer/index.js.map +0 -1
  51. package/dist/src/logger.d.ts +0 -10
  52. package/dist/src/logger.d.ts.map +0 -1
  53. package/dist/src/logger.js +0 -51
  54. package/dist/src/logger.js.map +0 -1
  55. package/dist/src/migrations.d.ts +0 -4
  56. package/dist/src/migrations.d.ts.map +0 -1
  57. package/dist/src/migrations.js +0 -343
  58. package/dist/src/migrations.js.map +0 -1
  59. package/dist/src/repositories/changes.repo.d.ts +0 -35
  60. package/dist/src/repositories/changes.repo.d.ts.map +0 -1
  61. package/dist/src/repositories/changes.repo.js +0 -53
  62. package/dist/src/repositories/changes.repo.js.map +0 -1
  63. package/dist/src/repositories/config.repo.d.ts +0 -11
  64. package/dist/src/repositories/config.repo.d.ts.map +0 -1
  65. package/dist/src/repositories/config.repo.js +0 -38
  66. package/dist/src/repositories/config.repo.js.map +0 -1
  67. package/dist/src/repositories/conventions.repo.d.ts +0 -15
  68. package/dist/src/repositories/conventions.repo.d.ts.map +0 -1
  69. package/dist/src/repositories/conventions.repo.js +0 -39
  70. package/dist/src/repositories/conventions.repo.js.map +0 -1
  71. package/dist/src/repositories/decisions.repo.d.ts +0 -19
  72. package/dist/src/repositories/decisions.repo.d.ts.map +0 -1
  73. package/dist/src/repositories/decisions.repo.js +0 -48
  74. package/dist/src/repositories/decisions.repo.js.map +0 -1
  75. package/dist/src/repositories/events.repo.d.ts +0 -34
  76. package/dist/src/repositories/events.repo.d.ts.map +0 -1
  77. package/dist/src/repositories/events.repo.js +0 -71
  78. package/dist/src/repositories/events.repo.js.map +0 -1
  79. package/dist/src/repositories/file-notes.repo.d.ts +0 -26
  80. package/dist/src/repositories/file-notes.repo.d.ts.map +0 -1
  81. package/dist/src/repositories/file-notes.repo.js +0 -55
  82. package/dist/src/repositories/file-notes.repo.js.map +0 -1
  83. package/dist/src/repositories/index.d.ts +0 -38
  84. package/dist/src/repositories/index.d.ts.map +0 -1
  85. package/dist/src/repositories/index.js +0 -41
  86. package/dist/src/repositories/index.js.map +0 -1
  87. package/dist/src/repositories/milestones.repo.d.ts +0 -10
  88. package/dist/src/repositories/milestones.repo.d.ts.map +0 -1
  89. package/dist/src/repositories/milestones.repo.js +0 -20
  90. package/dist/src/repositories/milestones.repo.js.map +0 -1
  91. package/dist/src/repositories/sessions.repo.d.ts +0 -27
  92. package/dist/src/repositories/sessions.repo.d.ts.map +0 -1
  93. package/dist/src/repositories/sessions.repo.js +0 -61
  94. package/dist/src/repositories/sessions.repo.js.map +0 -1
  95. package/dist/src/repositories/snapshot.repo.d.ts +0 -11
  96. package/dist/src/repositories/snapshot.repo.d.ts.map +0 -1
  97. package/dist/src/repositories/snapshot.repo.js +0 -17
  98. package/dist/src/repositories/snapshot.repo.js.map +0 -1
  99. package/dist/src/repositories/tasks.repo.d.ts +0 -40
  100. package/dist/src/repositories/tasks.repo.d.ts.map +0 -1
  101. package/dist/src/repositories/tasks.repo.js +0 -90
  102. package/dist/src/repositories/tasks.repo.js.map +0 -1
  103. package/dist/src/response.d.ts +0 -28
  104. package/dist/src/response.d.ts.map +0 -1
  105. package/dist/src/response.js +0 -38
  106. package/dist/src/response.js.map +0 -1
  107. package/dist/src/scripts/install-hooks.d.ts +0 -3
  108. package/dist/src/scripts/install-hooks.d.ts.map +0 -1
  109. package/dist/src/scripts/install-hooks.js +0 -89
  110. package/dist/src/scripts/install-hooks.js.map +0 -1
  111. package/dist/src/services/compaction.service.d.ts +0 -27
  112. package/dist/src/services/compaction.service.d.ts.map +0 -1
  113. package/dist/src/services/compaction.service.js +0 -93
  114. package/dist/src/services/compaction.service.js.map +0 -1
  115. package/dist/src/services/event-trigger.service.d.ts +0 -24
  116. package/dist/src/services/event-trigger.service.d.ts.map +0 -1
  117. package/dist/src/services/event-trigger.service.js +0 -60
  118. package/dist/src/services/event-trigger.service.js.map +0 -1
  119. package/dist/src/services/git.service.d.ts +0 -20
  120. package/dist/src/services/git.service.d.ts.map +0 -1
  121. package/dist/src/services/git.service.js +0 -88
  122. package/dist/src/services/git.service.js.map +0 -1
  123. package/dist/src/services/index.d.ts +0 -5
  124. package/dist/src/services/index.d.ts.map +0 -1
  125. package/dist/src/services/index.js +0 -8
  126. package/dist/src/services/index.js.map +0 -1
  127. package/dist/src/services/project-scan.service.d.ts +0 -19
  128. package/dist/src/services/project-scan.service.d.ts.map +0 -1
  129. package/dist/src/services/project-scan.service.js +0 -66
  130. package/dist/src/services/project-scan.service.js.map +0 -1
  131. package/dist/src/tools/backup.d.ts +0 -3
  132. package/dist/src/tools/backup.d.ts.map +0 -1
  133. package/dist/src/tools/backup.js +0 -191
  134. package/dist/src/tools/backup.js.map +0 -1
  135. package/dist/src/tools/changes.d.ts +0 -3
  136. package/dist/src/tools/changes.d.ts.map +0 -1
  137. package/dist/src/tools/changes.js +0 -97
  138. package/dist/src/tools/changes.js.map +0 -1
  139. package/dist/src/tools/compaction.d.ts +0 -3
  140. package/dist/src/tools/compaction.d.ts.map +0 -1
  141. package/dist/src/tools/compaction.js +0 -151
  142. package/dist/src/tools/compaction.js.map +0 -1
  143. package/dist/src/tools/conventions.d.ts +0 -3
  144. package/dist/src/tools/conventions.d.ts.map +0 -1
  145. package/dist/src/tools/conventions.js +0 -121
  146. package/dist/src/tools/conventions.js.map +0 -1
  147. package/dist/src/tools/decisions.d.ts +0 -3
  148. package/dist/src/tools/decisions.d.ts.map +0 -1
  149. package/dist/src/tools/decisions.js +0 -136
  150. package/dist/src/tools/decisions.js.map +0 -1
  151. package/dist/src/tools/export-import.d.ts +0 -3
  152. package/dist/src/tools/export-import.d.ts.map +0 -1
  153. package/dist/src/tools/export-import.js +0 -180
  154. package/dist/src/tools/export-import.js.map +0 -1
  155. package/dist/src/tools/file-notes.d.ts +0 -3
  156. package/dist/src/tools/file-notes.d.ts.map +0 -1
  157. package/dist/src/tools/file-notes.js +0 -104
  158. package/dist/src/tools/file-notes.js.map +0 -1
  159. package/dist/src/tools/intelligence.d.ts +0 -3
  160. package/dist/src/tools/intelligence.d.ts.map +0 -1
  161. package/dist/src/tools/intelligence.js +0 -427
  162. package/dist/src/tools/intelligence.js.map +0 -1
  163. package/dist/src/tools/milestones.d.ts +0 -3
  164. package/dist/src/tools/milestones.d.ts.map +0 -1
  165. package/dist/src/tools/milestones.js +0 -71
  166. package/dist/src/tools/milestones.js.map +0 -1
  167. package/dist/src/tools/scheduler.d.ts +0 -3
  168. package/dist/src/tools/scheduler.d.ts.map +0 -1
  169. package/dist/src/tools/scheduler.js +0 -363
  170. package/dist/src/tools/scheduler.js.map +0 -1
  171. package/dist/src/tools/sessions.d.ts +0 -3
  172. package/dist/src/tools/sessions.d.ts.map +0 -1
  173. package/dist/src/tools/sessions.js +0 -356
  174. package/dist/src/tools/sessions.js.map +0 -1
  175. package/dist/src/tools/stats.d.ts +0 -3
  176. package/dist/src/tools/stats.d.ts.map +0 -1
  177. package/dist/src/tools/stats.js +0 -63
  178. package/dist/src/tools/stats.js.map +0 -1
  179. package/dist/src/tools/tasks.d.ts +0 -3
  180. package/dist/src/tools/tasks.d.ts.map +0 -1
  181. package/dist/src/tools/tasks.js +0 -206
  182. package/dist/src/tools/tasks.js.map +0 -1
  183. package/dist/src/types.d.ts +0 -170
  184. package/dist/src/types.d.ts.map +0 -1
  185. package/dist/src/types.js +0 -5
  186. package/dist/src/types.js.map +0 -1
  187. package/dist/src/utils.d.ts +0 -58
  188. package/dist/src/utils.d.ts.map +0 -1
  189. package/dist/src/utils.js +0 -190
  190. package/dist/src/utils.js.map +0 -1
  191. package/dist/tests/helpers/test-db.d.ts +0 -12
  192. package/dist/tests/helpers/test-db.d.ts.map +0 -1
  193. package/dist/tests/helpers/test-db.js +0 -149
  194. package/dist/tests/helpers/test-db.js.map +0 -1
  195. package/dist/tests/installer/installer.test.d.ts +0 -2
  196. package/dist/tests/installer/installer.test.d.ts.map +0 -1
  197. package/dist/tests/installer/installer.test.js +0 -160
  198. package/dist/tests/installer/installer.test.js.map +0 -1
  199. package/dist/tests/repositories/repos.test.d.ts +0 -2
  200. package/dist/tests/repositories/repos.test.d.ts.map +0 -1
  201. package/dist/tests/repositories/repos.test.js +0 -220
  202. package/dist/tests/repositories/repos.test.js.map +0 -1
  203. package/dist/tools/maintenance.d.ts +0 -3
  204. package/dist/tools/maintenance.d.ts.map +0 -1
  205. package/dist/tools/maintenance.js +0 -647
  206. package/dist/tools/maintenance.js.map +0 -1
  207. package/dist/tools/memory.d.ts +0 -3
  208. package/dist/tools/memory.d.ts.map +0 -1
  209. package/dist/tools/memory.js +0 -446
  210. package/dist/tools/memory.js.map +0 -1
@@ -1,427 +0,0 @@
1
- // ============================================================================
2
- // Engram MCP Server — Project Intelligence Tools
3
- // ============================================================================
4
- import { z } from "zod";
5
- import { getDb, now, getProjectRoot } from "../database.js";
6
- import { TOOL_PREFIX, SNAPSHOT_TTL_MINUTES, MAX_SEARCH_RESULTS } from "../constants.js";
7
- import { scanFileTree, detectLayer, isGitRepo, getGitBranch, getGitHead, getGitLogSince, getGitFilesChanged, minutesSince, safeJsonParse } from "../utils.js";
8
- // ─── FTS5 Helpers ────────────────────────────────────────────────────
9
- /**
10
- * Check if FTS5 tables exist (migration v2 applied).
11
- */
12
- function hasFts(db) {
13
- try {
14
- const row = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='fts_sessions'").get();
15
- return !!row;
16
- }
17
- catch {
18
- return false;
19
- }
20
- }
21
- /**
22
- * Escape a user query for FTS5 MATCH syntax.
23
- * Wraps each word in quotes to avoid syntax errors from special chars.
24
- */
25
- function ftsEscape(query) {
26
- return query
27
- .split(/\s+/)
28
- .filter(Boolean)
29
- .map(word => `"${word.replace(/"/g, '""')}"`)
30
- .join(" ");
31
- }
32
- export function registerIntelligenceTools(server) {
33
- // ─── SCAN PROJECT ───────────────────────────────────────────────────
34
- server.registerTool(`${TOOL_PREFIX}_scan_project`, {
35
- title: "Scan Project",
36
- description: `Scan the project filesystem and build a cached snapshot of the structure. Includes file tree, auto-detected architectural layers, existing file notes, active decisions, and conventions. The snapshot is cached and reused — no need to rescan unless files changed significantly.
37
-
38
- Args:
39
- - force_refresh (boolean, optional): Force rescan even if cache is fresh (default: false)
40
- - max_depth (number, optional): Max directory depth to scan (default: 5)
41
-
42
- Returns:
43
- ProjectSnapshot with file tree, layer distribution, and all stored intelligence.`,
44
- inputSchema: {
45
- force_refresh: z.boolean().default(false).describe("Force rescan even if cache is fresh"),
46
- max_depth: z.number().int().min(1).max(10).default(5).describe("Max directory depth"),
47
- },
48
- annotations: {
49
- readOnlyHint: false, // It writes to cache
50
- destructiveHint: false,
51
- idempotentHint: true,
52
- openWorldHint: false,
53
- },
54
- }, async ({ force_refresh, max_depth }) => {
55
- const db = getDb();
56
- const projectRoot = getProjectRoot();
57
- // Check cache freshness
58
- if (!force_refresh) {
59
- const cached = db.prepare("SELECT * FROM snapshot_cache WHERE key = 'project_structure'").get();
60
- if (cached) {
61
- const age = minutesSince(cached.updated_at);
62
- if (age < SNAPSHOT_TTL_MINUTES) {
63
- const snapshot = safeJsonParse(cached.value, null);
64
- if (snapshot) {
65
- return {
66
- content: [{
67
- type: "text",
68
- text: JSON.stringify({
69
- ...snapshot,
70
- _cache_status: `fresh (${age}min old, TTL: ${SNAPSHOT_TTL_MINUTES}min)`,
71
- }, null, 2),
72
- }],
73
- };
74
- }
75
- }
76
- }
77
- }
78
- // Perform full scan
79
- const fileTree = scanFileTree(projectRoot, max_depth);
80
- // Auto-detect layers for each file
81
- const layerDist = {};
82
- for (const f of fileTree) {
83
- if (f.endsWith("/"))
84
- continue; // Skip directories
85
- const layer = detectLayer(f);
86
- layerDist[layer] = (layerDist[layer] || 0) + 1;
87
- }
88
- // Fetch stored intelligence
89
- const fileNotes = db.prepare("SELECT * FROM file_notes ORDER BY file_path").all();
90
- const activeDecisions = db.prepare("SELECT * FROM decisions WHERE status = 'active' ORDER BY timestamp DESC LIMIT 20").all();
91
- const activeConventions = db.prepare("SELECT * FROM conventions WHERE enforced = 1 ORDER BY category").all();
92
- // Git info
93
- let gitInfo = null;
94
- if (isGitRepo(projectRoot)) {
95
- const branch = getGitBranch(projectRoot);
96
- const head = getGitHead(projectRoot);
97
- gitInfo = { branch, head, is_clean: true }; // Simplified
98
- }
99
- const snapshot = {
100
- project_root: projectRoot,
101
- file_tree: fileTree,
102
- total_files: fileTree.filter(f => !f.endsWith("/")).length,
103
- file_notes: fileNotes,
104
- recent_decisions: activeDecisions,
105
- active_conventions: activeConventions,
106
- layer_distribution: layerDist,
107
- generated_at: now(),
108
- git: gitInfo,
109
- };
110
- // Cache the snapshot
111
- db.prepare("INSERT OR REPLACE INTO snapshot_cache (key, value, updated_at, ttl_minutes) VALUES ('project_structure', ?, ?, ?)").run(JSON.stringify(snapshot), now(), SNAPSHOT_TTL_MINUTES);
112
- return {
113
- content: [{
114
- type: "text",
115
- text: JSON.stringify({
116
- ...snapshot,
117
- _cache_status: "freshly scanned",
118
- }, null, 2),
119
- }],
120
- };
121
- });
122
- // ─── SEARCH MEMORY (FTS5-powered) ──────────────────────────────────
123
- server.registerTool(`${TOOL_PREFIX}_search`, {
124
- title: "Search Memory",
125
- description: `Full-text search across ALL memory: sessions, changes, decisions, file notes, conventions, and tasks. Uses FTS5 for high-performance ranked results when available, falls back to LIKE for compatibility.
126
-
127
- Args:
128
- - query (string): Search term(s)
129
- - scope (string, optional): Limit search to a specific table — "sessions", "changes", "decisions", "file_notes", "conventions", "tasks", or "all" (default: "all")
130
- - limit (number, optional): Max total results (default: 20)
131
-
132
- Returns:
133
- Grouped search results with relevance context.`,
134
- inputSchema: {
135
- query: z.string().min(1).describe("Search term(s)"),
136
- scope: z.enum(["all", "sessions", "changes", "decisions", "file_notes", "conventions", "tasks"]).default("all"),
137
- limit: z.number().int().min(1).max(MAX_SEARCH_RESULTS).default(20),
138
- },
139
- annotations: {
140
- readOnlyHint: true,
141
- destructiveHint: false,
142
- idempotentHint: true,
143
- openWorldHint: false,
144
- },
145
- }, async ({ query, scope, limit }) => {
146
- const db = getDb();
147
- const useFts = hasFts(db);
148
- const results = {};
149
- let totalFound = 0;
150
- const perTable = Math.ceil(limit / 6);
151
- if (useFts) {
152
- // ─── FTS5 Path (fast, ranked) ────────────────────────────
153
- const ftsQuery = ftsEscape(query);
154
- if (scope === "all" || scope === "sessions") {
155
- try {
156
- const rows = db.prepare(`SELECT s.*, rank FROM fts_sessions f
157
- JOIN sessions s ON s.id = f.rowid
158
- WHERE fts_sessions MATCH ?
159
- ORDER BY rank LIMIT ?`).all(ftsQuery, perTable);
160
- if (rows.length) {
161
- results.sessions = rows;
162
- totalFound += rows.length;
163
- }
164
- }
165
- catch { /* FTS match failed, skip */ }
166
- }
167
- if (scope === "all" || scope === "changes") {
168
- try {
169
- const rows = db.prepare(`SELECT c.*, rank FROM fts_changes f
170
- JOIN changes c ON c.id = f.rowid
171
- WHERE fts_changes MATCH ?
172
- ORDER BY rank LIMIT ?`).all(ftsQuery, perTable);
173
- if (rows.length) {
174
- results.changes = rows;
175
- totalFound += rows.length;
176
- }
177
- }
178
- catch { /* FTS match failed, skip */ }
179
- }
180
- if (scope === "all" || scope === "decisions") {
181
- try {
182
- const rows = db.prepare(`SELECT d.*, rank FROM fts_decisions f
183
- JOIN decisions d ON d.id = f.rowid
184
- WHERE fts_decisions MATCH ?
185
- ORDER BY rank LIMIT ?`).all(ftsQuery, perTable);
186
- if (rows.length) {
187
- results.decisions = rows;
188
- totalFound += rows.length;
189
- }
190
- }
191
- catch { /* FTS match failed, skip */ }
192
- }
193
- if (scope === "all" || scope === "file_notes") {
194
- try {
195
- const rows = db.prepare(`SELECT * FROM file_notes WHERE file_path IN (
196
- SELECT file_path FROM fts_file_notes WHERE fts_file_notes MATCH ?
197
- ) LIMIT ?`).all(ftsQuery, perTable);
198
- if (rows.length) {
199
- results.file_notes = rows;
200
- totalFound += rows.length;
201
- }
202
- }
203
- catch { /* FTS match failed, skip */ }
204
- }
205
- if (scope === "all" || scope === "conventions") {
206
- try {
207
- const rows = db.prepare(`SELECT c.*, rank FROM fts_conventions f
208
- JOIN conventions c ON c.id = f.rowid
209
- WHERE fts_conventions MATCH ?
210
- ORDER BY rank LIMIT ?`).all(ftsQuery, perTable);
211
- if (rows.length) {
212
- results.conventions = rows;
213
- totalFound += rows.length;
214
- }
215
- }
216
- catch { /* FTS match failed, skip */ }
217
- }
218
- if (scope === "all" || scope === "tasks") {
219
- try {
220
- const rows = db.prepare(`SELECT t.*, rank FROM fts_tasks f
221
- JOIN tasks t ON t.id = f.rowid
222
- WHERE fts_tasks MATCH ?
223
- ORDER BY rank LIMIT ?`).all(ftsQuery, perTable);
224
- if (rows.length) {
225
- results.tasks = rows;
226
- totalFound += rows.length;
227
- }
228
- }
229
- catch { /* FTS match failed, skip */ }
230
- }
231
- }
232
- else {
233
- // ─── LIKE Fallback (slow but compatible) ─────────────────
234
- const term = `%${query}%`;
235
- if (scope === "all" || scope === "sessions") {
236
- const rows = db.prepare("SELECT * FROM sessions WHERE summary LIKE ? OR tags LIKE ? ORDER BY id DESC LIMIT ?").all(term, term, perTable);
237
- if (rows.length) {
238
- results.sessions = rows;
239
- totalFound += rows.length;
240
- }
241
- }
242
- if (scope === "all" || scope === "changes") {
243
- const rows = db.prepare("SELECT * FROM changes WHERE description LIKE ? OR file_path LIKE ? OR diff_summary LIKE ? ORDER BY timestamp DESC LIMIT ?").all(term, term, term, perTable);
244
- if (rows.length) {
245
- results.changes = rows;
246
- totalFound += rows.length;
247
- }
248
- }
249
- if (scope === "all" || scope === "decisions") {
250
- const rows = db.prepare("SELECT * FROM decisions WHERE decision LIKE ? OR rationale LIKE ? OR tags LIKE ? ORDER BY timestamp DESC LIMIT ?").all(term, term, term, perTable);
251
- if (rows.length) {
252
- results.decisions = rows;
253
- totalFound += rows.length;
254
- }
255
- }
256
- if (scope === "all" || scope === "file_notes") {
257
- const rows = db.prepare("SELECT * FROM file_notes WHERE file_path LIKE ? OR purpose LIKE ? OR notes LIKE ? LIMIT ?").all(term, term, term, perTable);
258
- if (rows.length) {
259
- results.file_notes = rows;
260
- totalFound += rows.length;
261
- }
262
- }
263
- if (scope === "all" || scope === "conventions") {
264
- const rows = db.prepare("SELECT * FROM conventions WHERE rule LIKE ? OR examples LIKE ? LIMIT ?").all(term, term, perTable);
265
- if (rows.length) {
266
- results.conventions = rows;
267
- totalFound += rows.length;
268
- }
269
- }
270
- if (scope === "all" || scope === "tasks") {
271
- const rows = db.prepare("SELECT * FROM tasks WHERE title LIKE ? OR description LIKE ? OR tags LIKE ? ORDER BY updated_at DESC LIMIT ?").all(term, term, term, perTable);
272
- if (rows.length) {
273
- results.tasks = rows;
274
- totalFound += rows.length;
275
- }
276
- }
277
- }
278
- return {
279
- content: [{
280
- type: "text",
281
- text: JSON.stringify({
282
- query,
283
- scope,
284
- search_engine: useFts ? "fts5" : "like",
285
- total_results: totalFound,
286
- results,
287
- }, null, 2),
288
- }],
289
- };
290
- });
291
- // ─── WHAT CHANGED ───────────────────────────────────────────────────
292
- server.registerTool(`${TOOL_PREFIX}_what_changed`, {
293
- title: "What Changed",
294
- description: `Comprehensive diff report: what changed since a given time. Combines agent-recorded changes with git history. Use to quickly catch up after being away.
295
-
296
- Args:
297
- - since (string, optional): ISO timestamp or relative like "1h", "24h", "7d" (default: last session end)
298
- - include_git (boolean, optional): Include git log (default: true)
299
-
300
- Returns:
301
- Combined change report from both agent memory and git.`,
302
- inputSchema: {
303
- since: z.string().optional().describe('ISO timestamp or relative: "1h", "24h", "7d"'),
304
- include_git: z.boolean().default(true),
305
- },
306
- annotations: {
307
- readOnlyHint: true,
308
- destructiveHint: false,
309
- idempotentHint: true,
310
- openWorldHint: false,
311
- },
312
- }, async ({ since, include_git }) => {
313
- const db = getDb();
314
- const projectRoot = getProjectRoot();
315
- // Resolve "since" to an ISO timestamp
316
- let sinceTimestamp;
317
- if (!since) {
318
- // Default to last session end
319
- const last = db.prepare("SELECT ended_at FROM sessions WHERE ended_at IS NOT NULL ORDER BY id DESC LIMIT 1").get();
320
- sinceTimestamp = last?.ended_at || new Date(Date.now() - 86400000).toISOString();
321
- }
322
- else if (/^\d+[hdm]$/.test(since)) {
323
- // Relative time
324
- const match = since.match(/^(\d+)([hdm])$/);
325
- if (match) {
326
- const amount = parseInt(match[1]);
327
- const unit = match[2];
328
- const ms = unit === "h" ? amount * 3600000 : unit === "d" ? amount * 86400000 : amount * 60000;
329
- sinceTimestamp = new Date(Date.now() - ms).toISOString();
330
- }
331
- else {
332
- sinceTimestamp = since;
333
- }
334
- }
335
- else {
336
- sinceTimestamp = since;
337
- }
338
- // Agent-recorded changes
339
- const agentChanges = db.prepare("SELECT * FROM changes WHERE timestamp > ? ORDER BY timestamp DESC").all(sinceTimestamp);
340
- // Decisions made since
341
- const newDecisions = db.prepare("SELECT * FROM decisions WHERE timestamp > ? ORDER BY timestamp DESC").all(sinceTimestamp);
342
- // Git changes
343
- let gitLog = "";
344
- let gitFilesChanged = [];
345
- if (include_git && isGitRepo(projectRoot)) {
346
- gitLog = getGitLogSince(projectRoot, sinceTimestamp);
347
- gitFilesChanged = getGitFilesChanged(projectRoot, sinceTimestamp);
348
- }
349
- // Files only in git (not recorded by agent)
350
- const recordedFiles = new Set(agentChanges.map(c => c.file_path));
351
- const unrecordedGitChanges = gitFilesChanged.filter(f => !recordedFiles.has(f));
352
- return {
353
- content: [{
354
- type: "text",
355
- text: JSON.stringify({
356
- since: sinceTimestamp,
357
- agent_recorded: {
358
- count: agentChanges.length,
359
- changes: agentChanges,
360
- },
361
- new_decisions: newDecisions,
362
- git: include_git ? {
363
- log: gitLog,
364
- files_changed: gitFilesChanged.length,
365
- unrecorded_changes: unrecordedGitChanges,
366
- } : null,
367
- summary: `${agentChanges.length} recorded changes, ${newDecisions.length} new decisions, ${gitFilesChanged.length} git file changes (${unrecordedGitChanges.length} unrecorded) since ${sinceTimestamp}.`,
368
- }, null, 2),
369
- }],
370
- };
371
- });
372
- // ─── GET DEPENDENCY MAP ─────────────────────────────────────────────
373
- server.registerTool(`${TOOL_PREFIX}_get_dependency_map`, {
374
- title: "Get Dependency Map",
375
- description: `Get the dependency graph for a file: what it depends on and what depends on it. Built from stored file notes.
376
-
377
- Args:
378
- - file_path (string): File to query
379
- - depth (number, optional): How many levels deep to traverse (default: 1)
380
-
381
- Returns:
382
- Dependency tree with upstream and downstream files.`,
383
- inputSchema: {
384
- file_path: z.string().describe("File to query"),
385
- depth: z.number().int().min(1).max(5).default(1).describe("Traversal depth"),
386
- },
387
- annotations: {
388
- readOnlyHint: true,
389
- destructiveHint: false,
390
- idempotentHint: true,
391
- openWorldHint: false,
392
- },
393
- }, async ({ file_path, depth }) => {
394
- const db = getDb();
395
- function getDeps(fp, dir, currentDepth) {
396
- if (currentDepth > depth)
397
- return {};
398
- const note = db.prepare("SELECT * FROM file_notes WHERE file_path = ?").get(fp);
399
- if (!note)
400
- return {};
401
- const field = dir === "up" ? "dependencies" : "dependents";
402
- const deps = safeJsonParse(note[field], []);
403
- const result = {};
404
- for (const dep of deps) {
405
- result[dep] = getDeps(dep, dir, currentDepth + 1);
406
- }
407
- return result;
408
- }
409
- const upstream = getDeps(file_path, "up", 1);
410
- const downstream = getDeps(file_path, "down", 1);
411
- const note = db.prepare("SELECT * FROM file_notes WHERE file_path = ?").get(file_path);
412
- return {
413
- content: [{
414
- type: "text",
415
- text: JSON.stringify({
416
- file_path,
417
- purpose: note?.purpose || "(no notes recorded)",
418
- layer: note?.layer || detectLayer(file_path),
419
- complexity: note?.complexity || "unknown",
420
- depends_on: upstream,
421
- depended_by: downstream,
422
- }, null, 2),
423
- }],
424
- };
425
- });
426
- }
427
- //# sourceMappingURL=intelligence.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intelligence.js","sourceRoot":"","sources":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AChB,CAAC;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC,GAAG,CAAC,SAAS,CAAuC,CAAC;QAE7H,OAAO;YACL,OAAO,EAAE,CAAC;oBACR,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,SAAS;wBACT,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,qBAAqB;wBAC/C,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC;wBAC5C,UAAU,EAAE,IAAI,EAAE,UAAU,IAAI,SAAS;wBACzC,UAAU,EAAE,QAAQ;wBACpB,WAAW,EAAE,UAAU;qBACxB,EAAE,IAAI,EAAE,CAAC,CAAC;iBACZ,CAAC;SACH,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- export declare function registerMilestoneTools(server: McpServer): void;
3
- //# sourceMappingURL=milestones.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"milestones.d.ts","sourceRoot":"","sources":["../../../src/tools/milestones.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4E9D"}
@@ -1,71 +0,0 @@
1
- // ============================================================================
2
- // Engram MCP Server — Milestone Tools
3
- // ============================================================================
4
- import { z } from "zod";
5
- import { getDb, now, getCurrentSessionId } from "../database.js";
6
- import { TOOL_PREFIX } from "../constants.js";
7
- export function registerMilestoneTools(server) {
8
- server.registerTool(`${TOOL_PREFIX}_record_milestone`, {
9
- title: "Record Milestone",
10
- description: `Record a major project milestone or achievement. Milestones mark significant points in the project timeline — feature completions, releases, major refactors, etc.
11
-
12
- Args:
13
- - title (string): Milestone title
14
- - description (string, optional): What was achieved
15
- - version (string, optional): Version number if applicable
16
- - tags (array, optional): Tags
17
-
18
- Returns:
19
- Milestone ID and confirmation.`,
20
- inputSchema: {
21
- title: z.string().min(3).describe("Milestone title"),
22
- description: z.string().optional().describe("What was achieved"),
23
- version: z.string().optional().describe("Version number"),
24
- tags: z.array(z.string()).optional(),
25
- },
26
- annotations: {
27
- readOnlyHint: false,
28
- destructiveHint: false,
29
- idempotentHint: false,
30
- openWorldHint: false,
31
- },
32
- }, async ({ title, description, version, tags }) => {
33
- const db = getDb();
34
- const timestamp = now();
35
- const sessionId = getCurrentSessionId();
36
- const result = db.prepare("INSERT INTO milestones (session_id, timestamp, title, description, version, tags) VALUES (?, ?, ?, ?, ?, ?)").run(sessionId, timestamp, title, description || null, version || null, tags ? JSON.stringify(tags) : null);
37
- return {
38
- content: [{
39
- type: "text",
40
- text: JSON.stringify({
41
- milestone_id: result.lastInsertRowid,
42
- message: `Milestone #${result.lastInsertRowid} recorded: "${title}"${version ? ` (v${version})` : ""}`,
43
- }, null, 2),
44
- }],
45
- };
46
- });
47
- server.registerTool(`${TOOL_PREFIX}_get_milestones`, {
48
- title: "Get Milestones",
49
- description: `Retrieve project milestones. Shows the project's achievement timeline.
50
-
51
- Args:
52
- - limit (number, optional): Max results (default 20)
53
-
54
- Returns:
55
- Array of milestones in reverse chronological order.`,
56
- inputSchema: {
57
- limit: z.number().int().min(1).max(100).default(20),
58
- },
59
- annotations: {
60
- readOnlyHint: true,
61
- destructiveHint: false,
62
- idempotentHint: true,
63
- openWorldHint: false,
64
- },
65
- }, async ({ limit }) => {
66
- const db = getDb();
67
- const milestones = db.prepare("SELECT * FROM milestones ORDER BY timestamp DESC LIMIT ?").all(limit);
68
- return { content: [{ type: "text", text: JSON.stringify({ milestones }, null, 2) }] };
69
- });
70
- }
71
- //# sourceMappingURL=milestones.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"milestones.js","sourceRoot":"","sources":["../../../src/tools/milestones.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,sCAAsC;AACtC,+EAA+E;AAG/E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACpD,MAAM,CAAC,YAAY,CACf,GAAG,WAAW,mBAAmB,EACjC;QACI,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE;;;;;;;;;iCASQ;QACrB,WAAW,EAAE;YACT,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC;YACpD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;YAChE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YACzD,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;SACvC;QACD,WAAW,EAAE;YACT,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,KAAK;SACvB;KACJ,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5C,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;QACnB,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;QACxB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G,CAAC,KAAK,CAAC,CAAC;QACrG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAC1F,CAAC,CACJ,CAAC;AACN,CAAC"}
@@ -1,3 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- export declare function registerSchedulerTools(server: McpServer): void;
3
- //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../src/tools/scheduler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2X9D"}