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.
- package/README.md +12 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/installer/ide-detector.d.ts.map +1 -1
- package/dist/installer/ide-detector.js +10 -6
- package/dist/installer/ide-detector.js.map +1 -1
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +79 -15
- package/dist/installer/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/installer.d.ts +0 -2
- package/dist/installer.d.ts.map +0 -1
- package/dist/installer.js +0 -315
- package/dist/installer.js.map +0 -1
- package/dist/src/constants.d.ts +0 -21
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -81
- package/dist/src/constants.js.map +0 -1
- package/dist/src/database.d.ts +0 -32
- package/dist/src/database.d.ts.map +0 -1
- package/dist/src/database.js +0 -143
- package/dist/src/database.js.map +0 -1
- package/dist/src/errors.d.ts +0 -40
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js +0 -63
- package/dist/src/errors.js.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -89
- package/dist/src/index.js.map +0 -1
- package/dist/src/installer/config-writer.d.ts +0 -25
- package/dist/src/installer/config-writer.d.ts.map +0 -1
- package/dist/src/installer/config-writer.js +0 -86
- package/dist/src/installer/config-writer.js.map +0 -1
- package/dist/src/installer/ide-configs.d.ts +0 -19
- package/dist/src/installer/ide-configs.d.ts.map +0 -1
- package/dist/src/installer/ide-configs.js +0 -131
- package/dist/src/installer/ide-configs.js.map +0 -1
- package/dist/src/installer/ide-detector.d.ts +0 -6
- package/dist/src/installer/ide-detector.d.ts.map +0 -1
- package/dist/src/installer/ide-detector.js +0 -45
- package/dist/src/installer/ide-detector.js.map +0 -1
- package/dist/src/installer/index.d.ts +0 -2
- package/dist/src/installer/index.d.ts.map +0 -1
- package/dist/src/installer/index.js +0 -229
- package/dist/src/installer/index.js.map +0 -1
- package/dist/src/logger.d.ts +0 -10
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/logger.js +0 -51
- package/dist/src/logger.js.map +0 -1
- package/dist/src/migrations.d.ts +0 -4
- package/dist/src/migrations.d.ts.map +0 -1
- package/dist/src/migrations.js +0 -343
- package/dist/src/migrations.js.map +0 -1
- package/dist/src/repositories/changes.repo.d.ts +0 -35
- package/dist/src/repositories/changes.repo.d.ts.map +0 -1
- package/dist/src/repositories/changes.repo.js +0 -53
- package/dist/src/repositories/changes.repo.js.map +0 -1
- package/dist/src/repositories/config.repo.d.ts +0 -11
- package/dist/src/repositories/config.repo.d.ts.map +0 -1
- package/dist/src/repositories/config.repo.js +0 -38
- package/dist/src/repositories/config.repo.js.map +0 -1
- package/dist/src/repositories/conventions.repo.d.ts +0 -15
- package/dist/src/repositories/conventions.repo.d.ts.map +0 -1
- package/dist/src/repositories/conventions.repo.js +0 -39
- package/dist/src/repositories/conventions.repo.js.map +0 -1
- package/dist/src/repositories/decisions.repo.d.ts +0 -19
- package/dist/src/repositories/decisions.repo.d.ts.map +0 -1
- package/dist/src/repositories/decisions.repo.js +0 -48
- package/dist/src/repositories/decisions.repo.js.map +0 -1
- package/dist/src/repositories/events.repo.d.ts +0 -34
- package/dist/src/repositories/events.repo.d.ts.map +0 -1
- package/dist/src/repositories/events.repo.js +0 -71
- package/dist/src/repositories/events.repo.js.map +0 -1
- package/dist/src/repositories/file-notes.repo.d.ts +0 -26
- package/dist/src/repositories/file-notes.repo.d.ts.map +0 -1
- package/dist/src/repositories/file-notes.repo.js +0 -55
- package/dist/src/repositories/file-notes.repo.js.map +0 -1
- package/dist/src/repositories/index.d.ts +0 -38
- package/dist/src/repositories/index.d.ts.map +0 -1
- package/dist/src/repositories/index.js +0 -41
- package/dist/src/repositories/index.js.map +0 -1
- package/dist/src/repositories/milestones.repo.d.ts +0 -10
- package/dist/src/repositories/milestones.repo.d.ts.map +0 -1
- package/dist/src/repositories/milestones.repo.js +0 -20
- package/dist/src/repositories/milestones.repo.js.map +0 -1
- package/dist/src/repositories/sessions.repo.d.ts +0 -27
- package/dist/src/repositories/sessions.repo.d.ts.map +0 -1
- package/dist/src/repositories/sessions.repo.js +0 -61
- package/dist/src/repositories/sessions.repo.js.map +0 -1
- package/dist/src/repositories/snapshot.repo.d.ts +0 -11
- package/dist/src/repositories/snapshot.repo.d.ts.map +0 -1
- package/dist/src/repositories/snapshot.repo.js +0 -17
- package/dist/src/repositories/snapshot.repo.js.map +0 -1
- package/dist/src/repositories/tasks.repo.d.ts +0 -40
- package/dist/src/repositories/tasks.repo.d.ts.map +0 -1
- package/dist/src/repositories/tasks.repo.js +0 -90
- package/dist/src/repositories/tasks.repo.js.map +0 -1
- package/dist/src/response.d.ts +0 -28
- package/dist/src/response.d.ts.map +0 -1
- package/dist/src/response.js +0 -38
- package/dist/src/response.js.map +0 -1
- package/dist/src/scripts/install-hooks.d.ts +0 -3
- package/dist/src/scripts/install-hooks.d.ts.map +0 -1
- package/dist/src/scripts/install-hooks.js +0 -89
- package/dist/src/scripts/install-hooks.js.map +0 -1
- package/dist/src/services/compaction.service.d.ts +0 -27
- package/dist/src/services/compaction.service.d.ts.map +0 -1
- package/dist/src/services/compaction.service.js +0 -93
- package/dist/src/services/compaction.service.js.map +0 -1
- package/dist/src/services/event-trigger.service.d.ts +0 -24
- package/dist/src/services/event-trigger.service.d.ts.map +0 -1
- package/dist/src/services/event-trigger.service.js +0 -60
- package/dist/src/services/event-trigger.service.js.map +0 -1
- package/dist/src/services/git.service.d.ts +0 -20
- package/dist/src/services/git.service.d.ts.map +0 -1
- package/dist/src/services/git.service.js +0 -88
- package/dist/src/services/git.service.js.map +0 -1
- package/dist/src/services/index.d.ts +0 -5
- package/dist/src/services/index.d.ts.map +0 -1
- package/dist/src/services/index.js +0 -8
- package/dist/src/services/index.js.map +0 -1
- package/dist/src/services/project-scan.service.d.ts +0 -19
- package/dist/src/services/project-scan.service.d.ts.map +0 -1
- package/dist/src/services/project-scan.service.js +0 -66
- package/dist/src/services/project-scan.service.js.map +0 -1
- package/dist/src/tools/backup.d.ts +0 -3
- package/dist/src/tools/backup.d.ts.map +0 -1
- package/dist/src/tools/backup.js +0 -191
- package/dist/src/tools/backup.js.map +0 -1
- package/dist/src/tools/changes.d.ts +0 -3
- package/dist/src/tools/changes.d.ts.map +0 -1
- package/dist/src/tools/changes.js +0 -97
- package/dist/src/tools/changes.js.map +0 -1
- package/dist/src/tools/compaction.d.ts +0 -3
- package/dist/src/tools/compaction.d.ts.map +0 -1
- package/dist/src/tools/compaction.js +0 -151
- package/dist/src/tools/compaction.js.map +0 -1
- package/dist/src/tools/conventions.d.ts +0 -3
- package/dist/src/tools/conventions.d.ts.map +0 -1
- package/dist/src/tools/conventions.js +0 -121
- package/dist/src/tools/conventions.js.map +0 -1
- package/dist/src/tools/decisions.d.ts +0 -3
- package/dist/src/tools/decisions.d.ts.map +0 -1
- package/dist/src/tools/decisions.js +0 -136
- package/dist/src/tools/decisions.js.map +0 -1
- package/dist/src/tools/export-import.d.ts +0 -3
- package/dist/src/tools/export-import.d.ts.map +0 -1
- package/dist/src/tools/export-import.js +0 -180
- package/dist/src/tools/export-import.js.map +0 -1
- package/dist/src/tools/file-notes.d.ts +0 -3
- package/dist/src/tools/file-notes.d.ts.map +0 -1
- package/dist/src/tools/file-notes.js +0 -104
- package/dist/src/tools/file-notes.js.map +0 -1
- package/dist/src/tools/intelligence.d.ts +0 -3
- package/dist/src/tools/intelligence.d.ts.map +0 -1
- package/dist/src/tools/intelligence.js +0 -427
- package/dist/src/tools/intelligence.js.map +0 -1
- package/dist/src/tools/milestones.d.ts +0 -3
- package/dist/src/tools/milestones.d.ts.map +0 -1
- package/dist/src/tools/milestones.js +0 -71
- package/dist/src/tools/milestones.js.map +0 -1
- package/dist/src/tools/scheduler.d.ts +0 -3
- package/dist/src/tools/scheduler.d.ts.map +0 -1
- package/dist/src/tools/scheduler.js +0 -363
- package/dist/src/tools/scheduler.js.map +0 -1
- package/dist/src/tools/sessions.d.ts +0 -3
- package/dist/src/tools/sessions.d.ts.map +0 -1
- package/dist/src/tools/sessions.js +0 -356
- package/dist/src/tools/sessions.js.map +0 -1
- package/dist/src/tools/stats.d.ts +0 -3
- package/dist/src/tools/stats.d.ts.map +0 -1
- package/dist/src/tools/stats.js +0 -63
- package/dist/src/tools/stats.js.map +0 -1
- package/dist/src/tools/tasks.d.ts +0 -3
- package/dist/src/tools/tasks.d.ts.map +0 -1
- package/dist/src/tools/tasks.js +0 -206
- package/dist/src/tools/tasks.js.map +0 -1
- package/dist/src/types.d.ts +0 -170
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -5
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.d.ts +0 -58
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -190
- package/dist/src/utils.js.map +0 -1
- package/dist/tests/helpers/test-db.d.ts +0 -12
- package/dist/tests/helpers/test-db.d.ts.map +0 -1
- package/dist/tests/helpers/test-db.js +0 -149
- package/dist/tests/helpers/test-db.js.map +0 -1
- package/dist/tests/installer/installer.test.d.ts +0 -2
- package/dist/tests/installer/installer.test.d.ts.map +0 -1
- package/dist/tests/installer/installer.test.js +0 -160
- package/dist/tests/installer/installer.test.js.map +0 -1
- package/dist/tests/repositories/repos.test.d.ts +0 -2
- package/dist/tests/repositories/repos.test.d.ts.map +0 -1
- package/dist/tests/repositories/repos.test.js +0 -220
- package/dist/tests/repositories/repos.test.js.map +0 -1
- package/dist/tools/maintenance.d.ts +0 -3
- package/dist/tools/maintenance.d.ts.map +0 -1
- package/dist/tools/maintenance.js +0 -647
- package/dist/tools/maintenance.js.map +0 -1
- package/dist/tools/memory.d.ts +0 -3
- package/dist/tools/memory.d.ts.map +0 -1
- package/dist/tools/memory.js +0 -446
- package/dist/tools/memory.js.map +0 -1
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Engram MCP Server — Convention 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 registerConventionTools(server) {
|
|
8
|
-
server.registerTool(`${TOOL_PREFIX}_add_convention`, {
|
|
9
|
-
title: "Add Convention",
|
|
10
|
-
description: `Record a project convention that the agent should always follow. Conventions are surfaced during start_session and serve as persistent rules.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
- category: "naming" | "architecture" | "styling" | "testing" | "git" | "documentation" | "error_handling" | "performance" | "security" | "other"
|
|
14
|
-
- rule (string): The convention rule in clear, actionable language
|
|
15
|
-
- examples (array of strings, optional): Code or usage examples
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
Convention ID and confirmation.`,
|
|
19
|
-
inputSchema: {
|
|
20
|
-
category: z.enum(["naming", "architecture", "styling", "testing", "git", "documentation", "error_handling", "performance", "security", "other"]),
|
|
21
|
-
rule: z.string().min(5).describe("The convention rule"),
|
|
22
|
-
examples: z.array(z.string()).optional().describe("Examples of the convention in use"),
|
|
23
|
-
},
|
|
24
|
-
annotations: {
|
|
25
|
-
readOnlyHint: false,
|
|
26
|
-
destructiveHint: false,
|
|
27
|
-
idempotentHint: false,
|
|
28
|
-
openWorldHint: false,
|
|
29
|
-
},
|
|
30
|
-
}, async ({ category, rule, examples }) => {
|
|
31
|
-
const db = getDb();
|
|
32
|
-
const timestamp = now();
|
|
33
|
-
const sessionId = getCurrentSessionId();
|
|
34
|
-
const result = db.prepare("INSERT INTO conventions (session_id, timestamp, category, rule, examples) VALUES (?, ?, ?, ?, ?)").run(sessionId, timestamp, category, rule, examples ? JSON.stringify(examples) : null);
|
|
35
|
-
return {
|
|
36
|
-
content: [{
|
|
37
|
-
type: "text",
|
|
38
|
-
text: JSON.stringify({
|
|
39
|
-
convention_id: result.lastInsertRowid,
|
|
40
|
-
message: `Convention #${result.lastInsertRowid} added to [${category}].`,
|
|
41
|
-
rule,
|
|
42
|
-
}, null, 2),
|
|
43
|
-
}],
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
server.registerTool(`${TOOL_PREFIX}_get_conventions`, {
|
|
47
|
-
title: "Get Conventions",
|
|
48
|
-
description: `Retrieve all active project conventions. Optionally filter by category.
|
|
49
|
-
|
|
50
|
-
Args:
|
|
51
|
-
- category (string, optional): Filter by convention category
|
|
52
|
-
- include_disabled (boolean, optional): Include unenforced conventions (default: false)
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
Array of conventions grouped by category.`,
|
|
56
|
-
inputSchema: {
|
|
57
|
-
category: z.enum(["naming", "architecture", "styling", "testing", "git", "documentation", "error_handling", "performance", "security", "other"]).optional(),
|
|
58
|
-
include_disabled: z.boolean().default(false),
|
|
59
|
-
},
|
|
60
|
-
annotations: {
|
|
61
|
-
readOnlyHint: true,
|
|
62
|
-
destructiveHint: false,
|
|
63
|
-
idempotentHint: true,
|
|
64
|
-
openWorldHint: false,
|
|
65
|
-
},
|
|
66
|
-
}, async ({ category, include_disabled }) => {
|
|
67
|
-
const db = getDb();
|
|
68
|
-
let query = "SELECT * FROM conventions WHERE 1=1";
|
|
69
|
-
const params = [];
|
|
70
|
-
if (!include_disabled) {
|
|
71
|
-
query += " AND enforced = 1";
|
|
72
|
-
}
|
|
73
|
-
if (category) {
|
|
74
|
-
query += " AND category = ?";
|
|
75
|
-
params.push(category);
|
|
76
|
-
}
|
|
77
|
-
query += " ORDER BY category, id";
|
|
78
|
-
const conventions = db.prepare(query).all(...params);
|
|
79
|
-
const grouped = {};
|
|
80
|
-
for (const c of conventions) {
|
|
81
|
-
if (!grouped[c.category])
|
|
82
|
-
grouped[c.category] = [];
|
|
83
|
-
grouped[c.category].push(c);
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
content: [{
|
|
87
|
-
type: "text",
|
|
88
|
-
text: JSON.stringify({ total: conventions.length, by_category: grouped }, null, 2),
|
|
89
|
-
}],
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
server.registerTool(`${TOOL_PREFIX}_toggle_convention`, {
|
|
93
|
-
title: "Toggle Convention",
|
|
94
|
-
description: `Enable or disable a convention. Disabled conventions are not surfaced during start_session.
|
|
95
|
-
|
|
96
|
-
Args:
|
|
97
|
-
- id (number): Convention ID
|
|
98
|
-
- enforced (boolean): Whether the convention should be enforced
|
|
99
|
-
|
|
100
|
-
Returns:
|
|
101
|
-
Confirmation.`,
|
|
102
|
-
inputSchema: {
|
|
103
|
-
id: z.number().int().describe("Convention ID"),
|
|
104
|
-
enforced: z.boolean().describe("Enable or disable"),
|
|
105
|
-
},
|
|
106
|
-
annotations: {
|
|
107
|
-
readOnlyHint: false,
|
|
108
|
-
destructiveHint: false,
|
|
109
|
-
idempotentHint: true,
|
|
110
|
-
openWorldHint: false,
|
|
111
|
-
},
|
|
112
|
-
}, async ({ id, enforced }) => {
|
|
113
|
-
const db = getDb();
|
|
114
|
-
const result = db.prepare("UPDATE conventions SET enforced = ? WHERE id = ?").run(enforced ? 1 : 0, id);
|
|
115
|
-
if (result.changes === 0) {
|
|
116
|
-
return { isError: true, content: [{ type: "text", text: `Convention #${id} not found.` }] };
|
|
117
|
-
}
|
|
118
|
-
return { content: [{ type: "text", text: `Convention #${id} ${enforced ? "enabled" : "disabled"}.` }] };
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=conventions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conventions.js","sourceRoot":"","sources":["../../../src/tools/conventions.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,uCAAuC;AACvC,+EAA+E;AAG/E,OAAO,EAAE,CAAC,EAAE,MAAM,KA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,KAAK,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,kDAAkD,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxG,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QAChG,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC;IAC5G,CAAC,CACJ,CAAC;AACN,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decisions.d.ts","sourceRoot":"","sources":["../../../src/tools/decisions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsJ7D"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Engram MCP Server — Architectural Decision 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 registerDecisionTools(server) {
|
|
8
|
-
server.registerTool(`${TOOL_PREFIX}_record_decision`, {
|
|
9
|
-
title: "Record Decision",
|
|
10
|
-
description: `Record an architectural or design decision with its rationale. These persist across all future sessions and are surfaced during start_session. Use this for any choice that future agents or sessions need to respect.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
- decision (string): The decision that was made
|
|
14
|
-
- rationale (string, optional): Why this decision was made — context, tradeoffs, alternatives considered
|
|
15
|
-
- affected_files (array of strings, optional): Files impacted by this decision
|
|
16
|
-
- tags (array of strings, optional): Categorization tags (e.g., "architecture", "database", "ui", "api")
|
|
17
|
-
- status: "active" | "experimental" (default: "active")
|
|
18
|
-
- supersedes (number, optional): ID of a previous decision this replaces
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
Decision ID and confirmation.`,
|
|
22
|
-
inputSchema: {
|
|
23
|
-
decision: z.string().min(5).describe("The decision that was made"),
|
|
24
|
-
rationale: z.string().optional().describe("Why — context, tradeoffs, alternatives considered"),
|
|
25
|
-
affected_files: z.array(z.string()).optional().describe("Files impacted by this decision"),
|
|
26
|
-
tags: z.array(z.string()).optional().describe("Tags for categorization"),
|
|
27
|
-
status: z.enum(["active", "experimental"]).default("active"),
|
|
28
|
-
supersedes: z.number().int().optional().describe("ID of a previous decision this replaces"),
|
|
29
|
-
},
|
|
30
|
-
annotations: {
|
|
31
|
-
readOnlyHint: false,
|
|
32
|
-
destructiveHint: false,
|
|
33
|
-
idempotentHint: false,
|
|
34
|
-
openWorldHint: false,
|
|
35
|
-
},
|
|
36
|
-
}, async ({ decision, rationale, affected_files, tags, status, supersedes }) => {
|
|
37
|
-
const db = getDb();
|
|
38
|
-
const timestamp = now();
|
|
39
|
-
const sessionId = getCurrentSessionId();
|
|
40
|
-
const result = db.prepare("INSERT INTO decisions (session_id, timestamp, decision, rationale, affected_files, tags, status, superseded_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(sessionId, timestamp, decision, rationale || null, affected_files ? JSON.stringify(affected_files) : null, tags ? JSON.stringify(tags) : null, status, supersedes || null);
|
|
41
|
-
const newDecisionId = result.lastInsertRowid;
|
|
42
|
-
if (supersedes) {
|
|
43
|
-
db.prepare("UPDATE decisions SET status = 'superseded', superseded_by = ? WHERE id = ?")
|
|
44
|
-
.run(newDecisionId, supersedes);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
content: [{
|
|
48
|
-
type: "text",
|
|
49
|
-
text: JSON.stringify({
|
|
50
|
-
decision_id: newDecisionId,
|
|
51
|
-
message: `Decision #${newDecisionId} recorded${supersedes ? ` (supersedes #${supersedes})` : ""}.`,
|
|
52
|
-
decision,
|
|
53
|
-
}, null, 2),
|
|
54
|
-
}],
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
server.registerTool(`${TOOL_PREFIX}_get_decisions`, {
|
|
58
|
-
title: "Get Decisions",
|
|
59
|
-
description: `Retrieve recorded architectural decisions. Filter by status, tags, or affected files.
|
|
60
|
-
|
|
61
|
-
Args:
|
|
62
|
-
- status (string, optional): Filter by status — "active", "superseded", "deprecated", "experimental"
|
|
63
|
-
- tag (string, optional): Filter by tag
|
|
64
|
-
- file_path (string, optional): Find decisions affecting a specific file
|
|
65
|
-
- limit (number, optional): Max results (default 20)
|
|
66
|
-
|
|
67
|
-
Returns:
|
|
68
|
-
Array of decisions with rationale and metadata.`,
|
|
69
|
-
inputSchema: {
|
|
70
|
-
status: z.enum(["active", "superseded", "deprecated", "experimental"]).optional(),
|
|
71
|
-
tag: z.string().optional().describe("Filter by tag"),
|
|
72
|
-
file_path: z.string().optional().describe("Find decisions affecting this file"),
|
|
73
|
-
limit: z.number().int().min(1).max(100).default(20),
|
|
74
|
-
},
|
|
75
|
-
annotations: {
|
|
76
|
-
readOnlyHint: true,
|
|
77
|
-
destructiveHint: false,
|
|
78
|
-
idempotentHint: true,
|
|
79
|
-
openWorldHint: false,
|
|
80
|
-
},
|
|
81
|
-
}, async ({ status, tag, file_path, limit }) => {
|
|
82
|
-
const db = getDb();
|
|
83
|
-
let query = "SELECT * FROM decisions WHERE 1=1";
|
|
84
|
-
const params = [];
|
|
85
|
-
if (status) {
|
|
86
|
-
query += " AND status = ?";
|
|
87
|
-
params.push(status);
|
|
88
|
-
}
|
|
89
|
-
if (tag) {
|
|
90
|
-
query += " AND EXISTS (SELECT 1 FROM json_each(tags) WHERE value = ?)";
|
|
91
|
-
params.push(tag);
|
|
92
|
-
}
|
|
93
|
-
if (file_path) {
|
|
94
|
-
query += " AND EXISTS (SELECT 1 FROM json_each(affected_files) WHERE value = ?)";
|
|
95
|
-
params.push(file_path);
|
|
96
|
-
}
|
|
97
|
-
query += " ORDER BY timestamp DESC LIMIT ?";
|
|
98
|
-
params.push(limit);
|
|
99
|
-
const decisions = db.prepare(query).all(...params);
|
|
100
|
-
return {
|
|
101
|
-
content: [{
|
|
102
|
-
type: "text",
|
|
103
|
-
text: JSON.stringify({ count: decisions.length, decisions }, null, 2),
|
|
104
|
-
}],
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
server.registerTool(`${TOOL_PREFIX}_update_decision`, {
|
|
108
|
-
title: "Update Decision Status",
|
|
109
|
-
description: `Update the status of an existing decision. Use to deprecate, supersede, or reactivate decisions.
|
|
110
|
-
|
|
111
|
-
Args:
|
|
112
|
-
- id (number): Decision ID to update
|
|
113
|
-
- status: "active" | "superseded" | "deprecated" | "experimental"
|
|
114
|
-
|
|
115
|
-
Returns:
|
|
116
|
-
Confirmation.`,
|
|
117
|
-
inputSchema: {
|
|
118
|
-
id: z.number().int().describe("Decision ID"),
|
|
119
|
-
status: z.enum(["active", "superseded", "deprecated", "experimental"]),
|
|
120
|
-
},
|
|
121
|
-
annotations: {
|
|
122
|
-
readOnlyHint: false,
|
|
123
|
-
destructiveHint: false,
|
|
124
|
-
idempotentHint: true,
|
|
125
|
-
openWorldHint: false,
|
|
126
|
-
},
|
|
127
|
-
}, async ({ id, status }) => {
|
|
128
|
-
const db = getDb();
|
|
129
|
-
const result = db.prepare("UPDATE decisions SET status = ? WHERE id = ?").run(status, id);
|
|
130
|
-
if (result.changes === 0) {
|
|
131
|
-
return { isError: true, content: [{ type: "text", text: `Decision #${id} not found.` }] };
|
|
132
|
-
}
|
|
133
|
-
return { content: [{ type: "text", text: `Decision #${id} status updated to "${status}".` }] };
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=decisions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decisions.js","sourceRoot":"","sources":["../../../src/tools/decisions.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,mDAAmD;AACnD,+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;AAG9C,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CACf,GAAG,WAAW,kBAAkB,EAChC;QACI,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE;;;;;;;;;;;gCAWO;QACpB,WAAW,EAAE;YACT,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,4BAA4B,CAAC;YAClE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mDAAmD,CAAC;YAC9F,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;YAC1F,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;YACxE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;YAC5D,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC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AI,MAAM,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QAC9F,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,uBAAuB,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;IACnG,CAAC,CACJ,CAAC;AACN,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-import.d.ts","sourceRoot":"","sources":["../../../src/tools/export-import.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOpE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA+MjE"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Engram MCP Server — Export & Import Tools
|
|
3
|
-
// ============================================================================
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import * as fs from "fs";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import { getDb, now, getProjectRoot } from "../database.js";
|
|
8
|
-
import { TOOL_PREFIX, DB_DIR_NAME, SERVER_VERSION } from "../constants.js";
|
|
9
|
-
export function registerExportImportTools(server) {
|
|
10
|
-
// ─── EXPORT MEMORY ──────────────────────────────────────────────────
|
|
11
|
-
server.registerTool(`${TOOL_PREFIX}_export`, {
|
|
12
|
-
title: "Export Memory",
|
|
13
|
-
description: `Export the entire memory database as a portable JSON file. Useful for backup, migration, or sharing project knowledge with teammates.
|
|
14
|
-
|
|
15
|
-
Args:
|
|
16
|
-
- output_path (string, optional): Where to save the export (default: .engram/export.json)
|
|
17
|
-
|
|
18
|
-
Returns:
|
|
19
|
-
Export file path and summary.`,
|
|
20
|
-
inputSchema: {
|
|
21
|
-
output_path: z.string().optional().describe("Export file path"),
|
|
22
|
-
},
|
|
23
|
-
annotations: {
|
|
24
|
-
readOnlyHint: true,
|
|
25
|
-
destructiveHint: false,
|
|
26
|
-
idempotentHint: true,
|
|
27
|
-
openWorldHint: true,
|
|
28
|
-
},
|
|
29
|
-
}, async ({ output_path }) => {
|
|
30
|
-
const db = getDb();
|
|
31
|
-
const projectRoot = getProjectRoot();
|
|
32
|
-
const exportData = {
|
|
33
|
-
engram_version: SERVER_VERSION,
|
|
34
|
-
exported_at: now(),
|
|
35
|
-
project_root: projectRoot,
|
|
36
|
-
sessions: db.prepare("SELECT * FROM sessions ORDER BY id").all(),
|
|
37
|
-
changes: db.prepare("SELECT * FROM changes ORDER BY id").all(),
|
|
38
|
-
decisions: db.prepare("SELECT * FROM decisions ORDER BY id").all(),
|
|
39
|
-
file_notes: db.prepare("SELECT * FROM file_notes ORDER BY file_path").all(),
|
|
40
|
-
conventions: db.prepare("SELECT * FROM conventions ORDER BY id").all(),
|
|
41
|
-
tasks: db.prepare("SELECT * FROM tasks ORDER BY id").all(),
|
|
42
|
-
milestones: db.prepare("SELECT * FROM milestones ORDER BY id").all(),
|
|
43
|
-
};
|
|
44
|
-
const filePath = output_path || path.join(projectRoot, DB_DIR_NAME, "export.json");
|
|
45
|
-
fs.writeFileSync(filePath, JSON.stringify(exportData, null, 2));
|
|
46
|
-
return {
|
|
47
|
-
content: [{
|
|
48
|
-
type: "text",
|
|
49
|
-
text: JSON.stringify({
|
|
50
|
-
exported_to: filePath,
|
|
51
|
-
counts: {
|
|
52
|
-
sessions: exportData.sessions.length,
|
|
53
|
-
changes: exportData.changes.length,
|
|
54
|
-
decisions: exportData.decisions.length,
|
|
55
|
-
file_notes: exportData.file_notes.length,
|
|
56
|
-
conventions: exportData.conventions.length,
|
|
57
|
-
tasks: exportData.tasks.length,
|
|
58
|
-
milestones: exportData.milestones.length,
|
|
59
|
-
},
|
|
60
|
-
}, null, 2),
|
|
61
|
-
}],
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
// ─── IMPORT MEMORY ──────────────────────────────────────────────────
|
|
65
|
-
server.registerTool(`${TOOL_PREFIX}_import`, {
|
|
66
|
-
title: "Import Memory",
|
|
67
|
-
description: `Import memory from a previously exported JSON file. Merges data into the existing database without duplicating existing records.
|
|
68
|
-
|
|
69
|
-
Args:
|
|
70
|
-
- input_path (string): Path to the export JSON file
|
|
71
|
-
- dry_run (boolean, optional): Preview import without writing (default: true)
|
|
72
|
-
|
|
73
|
-
Returns:
|
|
74
|
-
Import summary with counts.`,
|
|
75
|
-
inputSchema: {
|
|
76
|
-
input_path: z.string().describe("Path to export JSON file"),
|
|
77
|
-
dry_run: z.boolean().default(true).describe("Preview mode"),
|
|
78
|
-
},
|
|
79
|
-
annotations: {
|
|
80
|
-
readOnlyHint: false,
|
|
81
|
-
destructiveHint: false,
|
|
82
|
-
idempotentHint: true,
|
|
83
|
-
openWorldHint: true,
|
|
84
|
-
},
|
|
85
|
-
}, async ({ input_path, dry_run }) => {
|
|
86
|
-
const projectRoot = getProjectRoot();
|
|
87
|
-
const filePath = path.isAbsolute(input_path) ? input_path : path.join(projectRoot, input_path);
|
|
88
|
-
if (!fs.existsSync(filePath)) {
|
|
89
|
-
return { isError: true, content: [{ type: "text", text: `File not found: ${filePath}` }] };
|
|
90
|
-
}
|
|
91
|
-
let importData;
|
|
92
|
-
try {
|
|
93
|
-
importData = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
94
|
-
}
|
|
95
|
-
catch (e) {
|
|
96
|
-
return { isError: true, content: [{ type: "text", text: `Invalid JSON: ${e}` }] };
|
|
97
|
-
}
|
|
98
|
-
const counts = {};
|
|
99
|
-
for (const key of ["sessions", "changes", "decisions", "file_notes", "conventions", "tasks", "milestones"]) {
|
|
100
|
-
counts[key] = Array.isArray(importData[key]) ? importData[key].length : 0;
|
|
101
|
-
}
|
|
102
|
-
if (dry_run) {
|
|
103
|
-
return {
|
|
104
|
-
content: [{
|
|
105
|
-
type: "text",
|
|
106
|
-
text: JSON.stringify({
|
|
107
|
-
dry_run: true,
|
|
108
|
-
would_import: counts,
|
|
109
|
-
message: "Run with dry_run=false to execute the import.",
|
|
110
|
-
}, null, 2),
|
|
111
|
-
}],
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
const db = getDb();
|
|
115
|
-
const importTransaction = db.transaction(() => {
|
|
116
|
-
const sessionIdMap = new Map();
|
|
117
|
-
if (Array.isArray(importData.sessions)) {
|
|
118
|
-
for (const s of importData.sessions) {
|
|
119
|
-
const exists = db.prepare("SELECT id FROM sessions WHERE started_at = ? AND agent_name = ?").get(s.started_at, s.agent_name || "unknown");
|
|
120
|
-
if (!exists) {
|
|
121
|
-
const result = db.prepare("INSERT INTO sessions (started_at, ended_at, summary, agent_name, project_root, tags) VALUES (?, ?, ?, ?, ?, ?)").run(s.started_at, s.ended_at || null, s.summary || null, s.agent_name || "unknown", s.project_root || "", s.tags || null);
|
|
122
|
-
sessionIdMap.set(s.id, result.lastInsertRowid);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
sessionIdMap.set(s.id, exists.id);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (Array.isArray(importData.changes)) {
|
|
130
|
-
for (const c of importData.changes) {
|
|
131
|
-
const exists = db.prepare("SELECT id FROM changes WHERE file_path = ? AND timestamp = ? AND description = ?").get(c.file_path, c.timestamp, c.description);
|
|
132
|
-
if (!exists) {
|
|
133
|
-
const mappedSessionId = c.session_id ? (sessionIdMap.get(c.session_id) ?? c.session_id) : null;
|
|
134
|
-
db.prepare("INSERT INTO changes (session_id, timestamp, file_path, change_type, description, diff_summary, impact_scope) VALUES (?, ?, ?, ?, ?, ?, ?)").run(mappedSessionId, c.timestamp, c.file_path, c.change_type, c.description, c.diff_summary || null, c.impact_scope || "local");
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (Array.isArray(importData.conventions)) {
|
|
139
|
-
for (const c of importData.conventions) {
|
|
140
|
-
const exists = db.prepare("SELECT id FROM conventions WHERE rule = ?").get(c.rule);
|
|
141
|
-
if (!exists) {
|
|
142
|
-
db.prepare("INSERT INTO conventions (timestamp, category, rule, examples, enforced) VALUES (?, ?, ?, ?, ?)").run(c.timestamp || now(), c.category, c.rule, c.examples || null, c.enforced ?? 1);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (Array.isArray(importData.decisions)) {
|
|
147
|
-
for (const d of importData.decisions) {
|
|
148
|
-
const exists = db.prepare("SELECT id FROM decisions WHERE decision = ?").get(d.decision);
|
|
149
|
-
if (!exists) {
|
|
150
|
-
db.prepare("INSERT INTO decisions (timestamp, decision, rationale, affected_files, tags, status) VALUES (?, ?, ?, ?, ?, ?)").run(d.timestamp || now(), d.decision, d.rationale || null, d.affected_files || null, d.tags || null, d.status || "active");
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (Array.isArray(importData.file_notes)) {
|
|
155
|
-
for (const f of importData.file_notes) {
|
|
156
|
-
db.prepare(`
|
|
157
|
-
INSERT OR REPLACE INTO file_notes (file_path, purpose, dependencies, dependents, layer, last_reviewed, notes, complexity)
|
|
158
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
159
|
-
`).run(f.file_path, f.purpose || null, f.dependencies || null, f.dependents || null, f.layer || null, f.last_reviewed || now(), f.notes || null, f.complexity || null);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (Array.isArray(importData.milestones)) {
|
|
163
|
-
for (const m of importData.milestones) {
|
|
164
|
-
const exists = db.prepare("SELECT id FROM milestones WHERE title = ? AND timestamp = ?").get(m.title, m.timestamp);
|
|
165
|
-
if (!exists) {
|
|
166
|
-
db.prepare("INSERT INTO milestones (timestamp, title, description, version, tags) VALUES (?, ?, ?, ?, ?)").run(m.timestamp || now(), m.title, m.description || null, m.version || null, m.tags || null);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
importTransaction();
|
|
172
|
-
return {
|
|
173
|
-
content: [{
|
|
174
|
-
type: "text",
|
|
175
|
-
text: JSON.stringify({ imported: counts, message: "Import complete. Duplicates were skipped." }, null, 2),
|
|
176
|
-
}],
|
|
177
|
-
};
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
//# sourceMappingURL=export-import.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-import.js","sourceRoot":"","sources":["../../../src/tools/export-import.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4CAA4C;AAC5C,+EAA+E;AAG/E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE3E,MAAM,UAAU,yBAAyB,CAAC,MAAiB;IACvD,uEAAuE;IACvE,MAAM,CAAC,YAAY,CACf,GAAG,WAAW,SAAS,EACvB;QACI,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE;;;;;;gCAMO;QACpB,WAAW,EAAE;YACT,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;SAClE;QACD,WAAW,EAAE;YACT,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACtB;KACJ,EACD,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;QACtB,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC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,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;oBACnG,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,iBAAiB,EAAE,CAAC;QAEpB,OAAO;YACH,OAAO,EAAE,CAAC;oBACN,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,2CAA2C,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC5G,CAAC;SACL,CAAC;IACN,CAAC,CACJ,CAAC;AACN,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-notes.d.ts","sourceRoot":"","sources":["../../../src/tools/file-notes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAyH7D"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Engram MCP Server — File Notes 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 registerFileNoteTools(server) {
|
|
8
|
-
server.registerTool(`${TOOL_PREFIX}_set_file_notes`, {
|
|
9
|
-
title: "Set File Notes",
|
|
10
|
-
description: `Store persistent notes about a file: its purpose, dependencies, architectural layer, complexity, and any important details. This creates a knowledge base that eliminates the need to re-read and re-analyze files across sessions.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
- file_path (string): Relative path to the file
|
|
14
|
-
- purpose (string, optional): What this file does — its responsibility
|
|
15
|
-
- dependencies (array, optional): Files this file depends on
|
|
16
|
-
- dependents (array, optional): Files that depend on this file
|
|
17
|
-
- layer: "ui" | "viewmodel" | "domain" | "data" | "network" | "database" | "di" | "util" | "test" | "config" | "build" | "other"
|
|
18
|
-
- complexity: "trivial" | "simple" | "moderate" | "complex" | "critical"
|
|
19
|
-
- notes (string, optional): Any important context, gotchas, or warnings
|
|
20
|
-
|
|
21
|
-
Returns:
|
|
22
|
-
Confirmation.`,
|
|
23
|
-
inputSchema: {
|
|
24
|
-
file_path: z.string().describe("Relative path to the file"),
|
|
25
|
-
purpose: z.string().optional().describe("What this file does"),
|
|
26
|
-
dependencies: z.array(z.string()).optional().describe("Files this depends on"),
|
|
27
|
-
dependents: z.array(z.string()).optional().describe("Files that depend on this"),
|
|
28
|
-
layer: z.enum(["ui", "viewmodel", "domain", "data", "network", "database", "di", "util", "test", "config", "build", "other"]).optional(),
|
|
29
|
-
complexity: z.enum(["trivial", "simple", "moderate", "complex", "critical"]).optional(),
|
|
30
|
-
notes: z.string().optional().describe("Important context, gotchas, warnings"),
|
|
31
|
-
},
|
|
32
|
-
annotations: {
|
|
33
|
-
readOnlyHint: false,
|
|
34
|
-
destructiveHint: false,
|
|
35
|
-
idempotentHint: true,
|
|
36
|
-
openWorldHint: false,
|
|
37
|
-
},
|
|
38
|
-
}, async ({ file_path, purpose, dependencies, dependents, layer, complexity, notes }) => {
|
|
39
|
-
const db = getDb();
|
|
40
|
-
const timestamp = now();
|
|
41
|
-
const sessionId = getCurrentSessionId();
|
|
42
|
-
db.prepare(`
|
|
43
|
-
INSERT INTO file_notes (file_path, purpose, dependencies, dependents, layer, last_reviewed, last_modified_session, notes, complexity)
|
|
44
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
45
|
-
ON CONFLICT(file_path) DO UPDATE SET
|
|
46
|
-
purpose = COALESCE(?, purpose),
|
|
47
|
-
dependencies = COALESCE(?, dependencies),
|
|
48
|
-
dependents = COALESCE(?, dependents),
|
|
49
|
-
layer = COALESCE(?, layer),
|
|
50
|
-
last_reviewed = ?,
|
|
51
|
-
last_modified_session = COALESCE(?, last_modified_session),
|
|
52
|
-
notes = COALESCE(?, notes),
|
|
53
|
-
complexity = COALESCE(?, complexity)
|
|
54
|
-
`).run(file_path, purpose || null, dependencies ? JSON.stringify(dependencies) : null, dependents ? JSON.stringify(dependents) : null, layer || null, timestamp, sessionId, notes || null, complexity || null,
|
|
55
|
-
// Update values
|
|
56
|
-
purpose || null, dependencies ? JSON.stringify(dependencies) : null, dependents ? JSON.stringify(dependents) : null, layer || null, timestamp, sessionId, notes || null, complexity || null);
|
|
57
|
-
return {
|
|
58
|
-
content: [{ type: "text", text: `File notes saved for ${file_path}.` }],
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
server.registerTool(`${TOOL_PREFIX}_get_file_notes`, {
|
|
62
|
-
title: "Get File Notes",
|
|
63
|
-
description: `Retrieve stored notes for one or more files. Use to quickly understand a file's purpose and context without reading it.
|
|
64
|
-
|
|
65
|
-
Args:
|
|
66
|
-
- file_path (string, optional): Specific file to query
|
|
67
|
-
- layer (string, optional): Filter by architectural layer
|
|
68
|
-
- complexity (string, optional): Filter by complexity level
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
File notes with purpose, dependencies, layer, and complexity.`,
|
|
72
|
-
inputSchema: {
|
|
73
|
-
file_path: z.string().optional().describe("Specific file to query"),
|
|
74
|
-
layer: z.enum(["ui", "viewmodel", "domain", "data", "network", "database", "di", "util", "test", "config", "build", "other"]).optional(),
|
|
75
|
-
complexity: z.enum(["trivial", "simple", "moderate", "complex", "critical"]).optional(),
|
|
76
|
-
},
|
|
77
|
-
annotations: {
|
|
78
|
-
readOnlyHint: true,
|
|
79
|
-
destructiveHint: false,
|
|
80
|
-
idempotentHint: true,
|
|
81
|
-
openWorldHint: false,
|
|
82
|
-
},
|
|
83
|
-
}, async ({ file_path, layer, complexity }) => {
|
|
84
|
-
const db = getDb();
|
|
85
|
-
if (file_path) {
|
|
86
|
-
const note = db.prepare("SELECT * FROM file_notes WHERE file_path = ?").get(file_path);
|
|
87
|
-
return { content: [{ type: "text", text: JSON.stringify(note || { message: "No notes found for this file." }, null, 2) }] };
|
|
88
|
-
}
|
|
89
|
-
let query = "SELECT * FROM file_notes WHERE 1=1";
|
|
90
|
-
const params = [];
|
|
91
|
-
if (layer) {
|
|
92
|
-
query += " AND layer = ?";
|
|
93
|
-
params.push(layer);
|
|
94
|
-
}
|
|
95
|
-
if (complexity) {
|
|
96
|
-
query += " AND complexity = ?";
|
|
97
|
-
params.push(complexity);
|
|
98
|
-
}
|
|
99
|
-
query += " ORDER BY file_path";
|
|
100
|
-
const notes = db.prepare(query).all(...params);
|
|
101
|
-
return { content: [{ type: "text", text: JSON.stringify({ count: notes.length, files: notes }, null, 2) }] };
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=file-notes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-notes.js","sourceRoot":"","sources":["../../../src/tools/file-notes.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,uCAAuC;AACvC,+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;AAG9C,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CACf,GAAG,WAAW,iBAAiB,EAC/B;QACI,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE;;;;;;;;;;;;gBAYT;QACJ,WAAW,EAAE;YACT,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YAC3D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;YAC9D,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAA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