local-agent-memory 1.0.5 → 1.0.6
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/dist/cli/commands/list.js +6 -2
- package/dist/core/parser.js +10 -8
- package/dist/core/sync.js +2 -0
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.js +29 -0
- package/package.json +1 -1
|
@@ -57,7 +57,9 @@ async function listProjects() {
|
|
|
57
57
|
.filter((f) => f.endsWith(".md"));
|
|
58
58
|
if (decisions.length > 0) {
|
|
59
59
|
console.log(`\nDecisiones Arquitectónicas (ADRs):`);
|
|
60
|
-
|
|
60
|
+
for (const d of decisions) {
|
|
61
|
+
console.log(` - decisions/${d}`);
|
|
62
|
+
}
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
const ledgerDir = node_path_1.default.join(memoryDir, "ledger");
|
|
@@ -67,7 +69,9 @@ async function listProjects() {
|
|
|
67
69
|
.filter((f) => f.endsWith(".md"));
|
|
68
70
|
if (ledgers.length > 0) {
|
|
69
71
|
console.log(`\nRegistros de Sesión (Ledger):`);
|
|
70
|
-
|
|
72
|
+
for (const l of ledgers) {
|
|
73
|
+
console.log(` - ledger/${l}`);
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
console.log("\n==============================");
|
package/dist/core/parser.js
CHANGED
|
@@ -76,13 +76,15 @@ async function parseMarkdown(content, path, maxTokens = 450, overlapTokens = 50)
|
|
|
76
76
|
if (currentBlocks.length > 0) {
|
|
77
77
|
const first = currentBlocks[0];
|
|
78
78
|
const last = currentBlocks[currentBlocks.length - 1];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
if (first && last) {
|
|
80
|
+
chunks.push({
|
|
81
|
+
path,
|
|
82
|
+
text: currentBlocks.map((b) => b.text).join("\n\n"),
|
|
83
|
+
breadcrumbs: first.breadcrumb,
|
|
84
|
+
startLine: first.startLine,
|
|
85
|
+
endLine: last.endLine,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
if (ast?.children) {
|
|
@@ -131,7 +133,7 @@ async function parseMarkdown(content, path, maxTokens = 450, overlapTokens = 50)
|
|
|
131
133
|
let overlapTokensCount = 0;
|
|
132
134
|
for (let i = currentBlocks.length - 1; i >= 0; i--) {
|
|
133
135
|
const b = currentBlocks[i];
|
|
134
|
-
if (overlapTokensCount + b.tokens <= overlapTokens) {
|
|
136
|
+
if (b && overlapTokensCount + b.tokens <= overlapTokens) {
|
|
135
137
|
overlapBlocks.unshift(b);
|
|
136
138
|
overlapTokensCount += b.tokens;
|
|
137
139
|
}
|
package/dist/core/sync.js
CHANGED
|
@@ -113,6 +113,8 @@ async function syncFile(path, content, db) {
|
|
|
113
113
|
for (let j = 0; j < batch.length; j++) {
|
|
114
114
|
const chunk = batch[j];
|
|
115
115
|
const embedding = embeddings[j];
|
|
116
|
+
if (!chunk || !embedding)
|
|
117
|
+
continue;
|
|
116
118
|
// Store in main table
|
|
117
119
|
await asyncDb.run("INSERT INTO chunks (path, text, breadcrumbs, startLine, endLine) VALUES (?, ?, ?, ?, ?)", [
|
|
118
120
|
chunk.path,
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
3
|
export declare function setupMCPServer(): Promise<McpServer>;
|
|
4
|
+
export declare function setupProcessLifecycle(transport: StdioServerTransport, log?: (msg: string) => void): void;
|
package/dist/mcp/server.js
CHANGED
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.setupMCPServer = setupMCPServer;
|
|
37
|
+
exports.setupProcessLifecycle = setupProcessLifecycle;
|
|
37
38
|
const fs = __importStar(require("node:fs"));
|
|
38
39
|
const path = __importStar(require("node:path"));
|
|
39
40
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
@@ -99,9 +100,37 @@ async function setupMCPServer() {
|
|
|
99
100
|
transport.onerror = (err) => {
|
|
100
101
|
log(`Transport error: ${err}`);
|
|
101
102
|
};
|
|
103
|
+
setupProcessLifecycle(transport, log);
|
|
102
104
|
await server.connect(transport);
|
|
103
105
|
log("MCP Server connected via stdio");
|
|
104
106
|
// Opcionalmente podemos exponer log para ser usado por tools si se lo pasamos,
|
|
105
107
|
// pero el servidor ya está funcionando y registrando arranque y errores.
|
|
106
108
|
return server;
|
|
107
109
|
}
|
|
110
|
+
function setupProcessLifecycle(transport, log = () => { }) {
|
|
111
|
+
let isExiting = false;
|
|
112
|
+
const exitHandler = (reason) => {
|
|
113
|
+
if (isExiting)
|
|
114
|
+
return;
|
|
115
|
+
isExiting = true;
|
|
116
|
+
log(`Shutting down MCP server: ${reason}`);
|
|
117
|
+
process.exit(0);
|
|
118
|
+
};
|
|
119
|
+
process.stdin.on("close", () => exitHandler("stdin closed"));
|
|
120
|
+
process.stdin.on("end", () => exitHandler("stdin ended"));
|
|
121
|
+
transport.onclose = () => exitHandler("transport closed");
|
|
122
|
+
process.on("SIGINT", () => exitHandler("SIGINT received"));
|
|
123
|
+
process.on("SIGTERM", () => exitHandler("SIGTERM received"));
|
|
124
|
+
if (process.ppid && process.ppid !== 1) {
|
|
125
|
+
const parentCheckInterval = setInterval(() => {
|
|
126
|
+
try {
|
|
127
|
+
process.kill(process.ppid, 0);
|
|
128
|
+
}
|
|
129
|
+
catch (_e) {
|
|
130
|
+
clearInterval(parentCheckInterval);
|
|
131
|
+
exitHandler(`parent process ${process.ppid} exited`);
|
|
132
|
+
}
|
|
133
|
+
}, 2000);
|
|
134
|
+
parentCheckInterval.unref();
|
|
135
|
+
}
|
|
136
|
+
}
|