@mrc2204/agent-smart-memo 5.1.16 → 5.1.19
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/platform-installers.d.ts.map +1 -1
- package/dist/cli/platform-installers.js +259 -56
- package/dist/cli/platform-installers.js.map +1 -1
- package/dist/core/migrations/memory-foundation-migration.d.ts +33 -0
- package/dist/core/migrations/memory-foundation-migration.d.ts.map +1 -0
- package/dist/core/migrations/memory-foundation-migration.js +67 -0
- package/dist/core/migrations/memory-foundation-migration.js.map +1 -0
- package/dist/core/precedence/recall-precedence.d.ts +20 -0
- package/dist/core/precedence/recall-precedence.d.ts.map +1 -0
- package/dist/core/precedence/recall-precedence.js +36 -0
- package/dist/core/precedence/recall-precedence.js.map +1 -0
- package/dist/core/promotion/promotion-lifecycle.d.ts +20 -0
- package/dist/core/promotion/promotion-lifecycle.d.ts.map +1 -0
- package/dist/core/promotion/promotion-lifecycle.js +46 -0
- package/dist/core/promotion/promotion-lifecycle.js.map +1 -0
- package/dist/core/retrieval-policy.d.ts +26 -0
- package/dist/core/retrieval-policy.d.ts.map +1 -0
- package/dist/core/retrieval-policy.js +44 -0
- package/dist/core/retrieval-policy.js.map +1 -0
- package/dist/core/usecases/semantic-memory-usecase.d.ts +4 -3
- package/dist/core/usecases/semantic-memory-usecase.d.ts.map +1 -1
- package/dist/core/usecases/semantic-memory-usecase.js +56 -16
- package/dist/core/usecases/semantic-memory-usecase.js.map +1 -1
- package/dist/db/slot-db.d.ts +25 -1
- package/dist/db/slot-db.d.ts.map +1 -1
- package/dist/db/slot-db.js +391 -167
- package/dist/db/slot-db.js.map +1 -1
- package/dist/hooks/auto-capture.d.ts +4 -4
- package/dist/hooks/auto-capture.d.ts.map +1 -1
- package/dist/hooks/auto-capture.js +96 -26
- package/dist/hooks/auto-capture.js.map +1 -1
- package/dist/hooks/auto-recall.d.ts +3 -3
- package/dist/hooks/auto-recall.d.ts.map +1 -1
- package/dist/hooks/auto-recall.js +91 -49
- package/dist/hooks/auto-recall.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/services/qdrant.d.ts +3 -2
- package/dist/services/qdrant.d.ts.map +1 -1
- package/dist/services/qdrant.js +24 -7
- package/dist/services/qdrant.js.map +1 -1
- package/dist/shared/memory-config.d.ts +7 -0
- package/dist/shared/memory-config.d.ts.map +1 -1
- package/dist/shared/memory-config.js +67 -16
- package/dist/shared/memory-config.js.map +1 -1
- package/dist/types.d.ts +13 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -62
- package/bin/asm.mjs +0 -450
- package/bin/opencode-mcp-server.mjs +0 -318
- package/scripts/init-openclaw.mjs +0 -721
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import process from "node:process";
|
|
3
|
-
|
|
4
|
-
const PROTOCOL_VERSION = "2024-11-05";
|
|
5
|
-
|
|
6
|
-
function makeTool(name, description, inputSchema) {
|
|
7
|
-
return { name, description, inputSchema };
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function buildOpencodeMcpToolDescriptors() {
|
|
11
|
-
return [
|
|
12
|
-
makeTool(
|
|
13
|
-
"asm_project_binding_preview",
|
|
14
|
-
"Resolve ASM active project binding in read-only mode using project_id/project_alias/repo_root/session_project_alias selectors.",
|
|
15
|
-
{
|
|
16
|
-
type: "object",
|
|
17
|
-
properties: {
|
|
18
|
-
project_id: { type: "string" },
|
|
19
|
-
project_alias: { type: "string" },
|
|
20
|
-
repo_root: { type: "string" },
|
|
21
|
-
session_project_alias: { type: "string" },
|
|
22
|
-
allow_cross_project: { type: "boolean" },
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
makeTool(
|
|
27
|
-
"asm_project_opencode_search",
|
|
28
|
-
"Run ASM read-only project-scoped retrieval for OpenCode after resolving project binding.",
|
|
29
|
-
{
|
|
30
|
-
type: "object",
|
|
31
|
-
properties: {
|
|
32
|
-
query: { type: "string" },
|
|
33
|
-
limit: { type: "number" },
|
|
34
|
-
project_id: { type: "string" },
|
|
35
|
-
project_alias: { type: "string" },
|
|
36
|
-
repo_root: { type: "string" },
|
|
37
|
-
session_project_alias: { type: "string" },
|
|
38
|
-
explicit_project_id: { type: "string" },
|
|
39
|
-
explicit_project_alias: { type: "string" },
|
|
40
|
-
explicit_cross_project: { type: "boolean" },
|
|
41
|
-
},
|
|
42
|
-
required: ["query"],
|
|
43
|
-
},
|
|
44
|
-
),
|
|
45
|
-
makeTool(
|
|
46
|
-
"asm_project_coding_packet",
|
|
47
|
-
"Build coding packet (foundation lane) for OpenCode using ASM project-aware/code-aware retrieval context.",
|
|
48
|
-
{
|
|
49
|
-
type: "object",
|
|
50
|
-
properties: {
|
|
51
|
-
project_id: { type: "string" },
|
|
52
|
-
project_alias: { type: "string" },
|
|
53
|
-
query: { type: "string" },
|
|
54
|
-
objective: { type: "string" },
|
|
55
|
-
task_id: { type: "string" },
|
|
56
|
-
tracker_issue_key: { type: "string" },
|
|
57
|
-
task_title: { type: "string" },
|
|
58
|
-
symbol_name: { type: "string" },
|
|
59
|
-
relative_path: { type: "string" },
|
|
60
|
-
route_path: { type: "string" },
|
|
61
|
-
limit: { type: "number" },
|
|
62
|
-
acceptance_criteria: { type: "array", items: { type: "string" } },
|
|
63
|
-
constraints: { type: "array", items: { type: "string" } },
|
|
64
|
-
out_of_scope: { type: "array", items: { type: "string" } },
|
|
65
|
-
validation_commands: { type: "array", items: { type: "string" } },
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
),
|
|
69
|
-
];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let usecasePortPromise = null;
|
|
73
|
-
async function getUseCasePort() {
|
|
74
|
-
if (!usecasePortPromise) {
|
|
75
|
-
usecasePortPromise = (async () => {
|
|
76
|
-
const { resolveAsmRuntimeConfig } = await import(new URL("../dist/shared/asm-config.js", import.meta.url));
|
|
77
|
-
const { SlotDB } = await import(new URL("../dist/db/slot-db.js", import.meta.url));
|
|
78
|
-
const { DefaultMemoryUseCasePort } = await import(new URL("../dist/core/usecases/default-memory-usecase-port.js", import.meta.url));
|
|
79
|
-
const runtimeConfig = resolveAsmRuntimeConfig({ env: process.env, homeDir: process.env.HOME });
|
|
80
|
-
const slotDbDir = runtimeConfig.slotDbDir;
|
|
81
|
-
const db = new SlotDB(slotDbDir);
|
|
82
|
-
return { db, usecase: new DefaultMemoryUseCasePort(db) };
|
|
83
|
-
})();
|
|
84
|
-
}
|
|
85
|
-
return usecasePortPromise;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function response(id, result) {
|
|
89
|
-
return { jsonrpc: "2.0", id, result };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function errorResponse(id, code, message) {
|
|
93
|
-
return { jsonrpc: "2.0", id, error: { code, message } };
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let outputTransportMode = "content-length";
|
|
97
|
-
|
|
98
|
-
function setOutputTransportMode(mode) {
|
|
99
|
-
if (mode === "json-line" || mode === "content-length") {
|
|
100
|
-
outputTransportMode = mode;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function writeMessage(message) {
|
|
105
|
-
const encoded = JSON.stringify(message);
|
|
106
|
-
if (outputTransportMode === "json-line") {
|
|
107
|
-
process.stdout.write(`${encoded}\n`);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const body = Buffer.from(encoded, "utf8");
|
|
112
|
-
const header = Buffer.from(`Content-Length: ${body.length}\r\n\r\n`, "utf8");
|
|
113
|
-
process.stdout.write(Buffer.concat([header, body]));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function handleToolCall(name, args) {
|
|
117
|
-
const { usecase } = await getUseCasePort();
|
|
118
|
-
const context = {
|
|
119
|
-
userId: process.env.ASM_MCP_USER_ID || "default",
|
|
120
|
-
agentId: process.env.ASM_MCP_AGENT_ID || "opencode",
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
if (name === "asm_project_binding_preview") {
|
|
124
|
-
const data = await usecase.run("project.binding_preview", {
|
|
125
|
-
context,
|
|
126
|
-
meta: { source: "cli", toolName: "asm.mcp.opencode.binding_preview" },
|
|
127
|
-
payload: args || {},
|
|
128
|
-
});
|
|
129
|
-
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (name === "asm_project_opencode_search") {
|
|
133
|
-
const data = await usecase.run("project.opencode_search", {
|
|
134
|
-
context,
|
|
135
|
-
meta: { source: "cli", toolName: "asm.mcp.opencode.search" },
|
|
136
|
-
payload: args || {},
|
|
137
|
-
});
|
|
138
|
-
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (name === "asm_project_coding_packet") {
|
|
142
|
-
const data = await usecase.run("project.coding_packet", {
|
|
143
|
-
context,
|
|
144
|
-
meta: { source: "cli", toolName: "asm.mcp.opencode.coding_packet" },
|
|
145
|
-
payload: args || {},
|
|
146
|
-
});
|
|
147
|
-
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async function processRpcMessage(message) {
|
|
154
|
-
const { id, method, params } = message || {};
|
|
155
|
-
const hasId = id !== undefined && id !== null;
|
|
156
|
-
|
|
157
|
-
if (method === "initialize") {
|
|
158
|
-
if (!hasId) return;
|
|
159
|
-
writeMessage(response(id, {
|
|
160
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
161
|
-
serverInfo: { name: "asm-opencode-mcp", version: "1.0.0" },
|
|
162
|
-
capabilities: { tools: { listChanged: false } },
|
|
163
|
-
}));
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (method === "notifications/initialized") {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (method === "tools/list") {
|
|
172
|
-
if (!hasId) return;
|
|
173
|
-
writeMessage(response(id, { tools: buildOpencodeMcpToolDescriptors() }));
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (method === "tools/call") {
|
|
178
|
-
if (!hasId) return;
|
|
179
|
-
try {
|
|
180
|
-
const result = await handleToolCall(params?.name, params?.arguments || {});
|
|
181
|
-
writeMessage(response(id, result));
|
|
182
|
-
} catch (error) {
|
|
183
|
-
writeMessage(response(id, {
|
|
184
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
185
|
-
isError: true,
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (!hasId) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
writeMessage(errorResponse(id, -32601, `Method not found: ${method}`));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function findHeaderBoundary(buffer) {
|
|
199
|
-
const crlf = buffer.indexOf("\r\n\r\n");
|
|
200
|
-
if (crlf !== -1) {
|
|
201
|
-
return { headerEnd: crlf, separatorLength: 4 };
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const lf = buffer.indexOf("\n\n");
|
|
205
|
-
if (lf !== -1) {
|
|
206
|
-
return { headerEnd: lf, separatorLength: 2 };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function takeJsonLineMessage(buffer) {
|
|
213
|
-
if (!buffer.length) return null;
|
|
214
|
-
const first = String.fromCharCode(buffer[0]);
|
|
215
|
-
if (first !== "{" && first !== "[") return null;
|
|
216
|
-
|
|
217
|
-
const newlineIndex = buffer.indexOf("\n");
|
|
218
|
-
if (newlineIndex === -1) return null;
|
|
219
|
-
|
|
220
|
-
const line = buffer.slice(0, newlineIndex).toString("utf8").trim();
|
|
221
|
-
if (!line) {
|
|
222
|
-
return { consumed: newlineIndex + 1, message: null };
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return { consumed: newlineIndex + 1, message: line };
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export async function runOpencodeMcpServer() {
|
|
229
|
-
let buffer = Buffer.alloc(0);
|
|
230
|
-
let requestChain = Promise.resolve();
|
|
231
|
-
|
|
232
|
-
const enqueue = (message) => {
|
|
233
|
-
requestChain = requestChain
|
|
234
|
-
.then(() => processRpcMessage(message))
|
|
235
|
-
.catch((error) => {
|
|
236
|
-
writeMessage(errorResponse(null, -32603, error instanceof Error ? error.message : String(error)));
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
const onData = (chunk) => {
|
|
241
|
-
buffer = Buffer.concat([buffer, chunk]);
|
|
242
|
-
|
|
243
|
-
while (true) {
|
|
244
|
-
const boundary = findHeaderBoundary(buffer);
|
|
245
|
-
if (boundary) {
|
|
246
|
-
const { headerEnd, separatorLength } = boundary;
|
|
247
|
-
const headerText = buffer.slice(0, headerEnd).toString("utf8");
|
|
248
|
-
const match = headerText.match(/Content-Length:\s*(\d+)/i);
|
|
249
|
-
if (!match) {
|
|
250
|
-
buffer = buffer.slice(headerEnd + separatorLength);
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const contentLength = Number(match[1]);
|
|
255
|
-
const totalLength = headerEnd + separatorLength + contentLength;
|
|
256
|
-
if (!Number.isFinite(contentLength) || contentLength < 0) {
|
|
257
|
-
buffer = buffer.slice(headerEnd + separatorLength);
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
if (buffer.length < totalLength) break;
|
|
261
|
-
|
|
262
|
-
const body = buffer.slice(headerEnd + separatorLength, totalLength).toString("utf8");
|
|
263
|
-
buffer = buffer.slice(totalLength);
|
|
264
|
-
setOutputTransportMode("content-length");
|
|
265
|
-
|
|
266
|
-
try {
|
|
267
|
-
const message = JSON.parse(body);
|
|
268
|
-
enqueue(message);
|
|
269
|
-
} catch (error) {
|
|
270
|
-
writeMessage(errorResponse(null, -32700, error instanceof Error ? error.message : String(error)));
|
|
271
|
-
}
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const jsonLine = takeJsonLineMessage(buffer);
|
|
276
|
-
if (!jsonLine) {
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
buffer = buffer.slice(jsonLine.consumed);
|
|
281
|
-
if (!jsonLine.message) {
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
setOutputTransportMode("json-line");
|
|
285
|
-
|
|
286
|
-
try {
|
|
287
|
-
const message = JSON.parse(jsonLine.message);
|
|
288
|
-
enqueue(message);
|
|
289
|
-
} catch (error) {
|
|
290
|
-
writeMessage(errorResponse(null, -32700, error instanceof Error ? error.message : String(error)));
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
if (typeof process.stdin.resume === "function") {
|
|
296
|
-
process.stdin.resume();
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
process.stdin.on("data", onData);
|
|
300
|
-
|
|
301
|
-
await new Promise((resolve) => {
|
|
302
|
-
let closed = false;
|
|
303
|
-
const finish = () => {
|
|
304
|
-
if (closed) return;
|
|
305
|
-
closed = true;
|
|
306
|
-
resolve(undefined);
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
process.stdin.on("end", finish);
|
|
310
|
-
process.stdin.on("close", finish);
|
|
311
|
-
process.on("SIGINT", finish);
|
|
312
|
-
process.on("SIGTERM", finish);
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
317
|
-
runOpencodeMcpServer();
|
|
318
|
-
}
|