@eleboucher/opencode-memini 0.4.19 → 0.4.21
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 +1 -1
- package/memini.js +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Pass options inline via the `[name, options]` form:
|
|
|
49
49
|
| `namespace` | `MEMINI_NAMESPACE` | git repo basename | tenant the memory is scoped to (`X-Memini-Namespace`) |
|
|
50
50
|
| `recall` | `MEMINI_RECALL` | on | `false` disables recall-before-turn |
|
|
51
51
|
| `capture` | `MEMINI_CAPTURE` | on | `false` disables capture-after-turn |
|
|
52
|
-
| `recall_limit` | `MEMINI_RECALL_LIMIT` | `
|
|
52
|
+
| `recall_limit` | `MEMINI_RECALL_LIMIT` | `3` | max memories injected per turn |
|
|
53
53
|
| `recall_max_tokens` | `MEMINI_INJECT_RECALL_MAX_TOK` | `0` | hard ceiling on the recall-block tokens (`0` = unbounded); the tail is dropped with a `[… N item(s) truncated by token budget]` footer |
|
|
54
54
|
| `recall_min_score` | `MEMINI_INJECT_RECALL_MIN_SCORE` | `0` | fused-score floor (>=) sent as `min_score` to `/v1/search` |
|
|
55
55
|
| `timeout_ms` | `MEMINI_TIMEOUT_MS` | `30000` | per-request timeout |
|
package/memini.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
const DEFAULT_BASE_URL = "http://localhost:8080";
|
|
20
20
|
const DEFAULT_TIMEOUT_MS = 30000;
|
|
21
|
-
const DEFAULT_RECALL_LIMIT =
|
|
21
|
+
const DEFAULT_RECALL_LIMIT = 3;
|
|
22
22
|
const DEFAULT_NAMESPACE = "opencode";
|
|
23
23
|
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
24
24
|
|
|
@@ -327,6 +327,19 @@ export function extractLastTurn(messages) {
|
|
|
327
327
|
return { userText, assistantText, assistantID };
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
// lastAssistantFailed reports whether the latest assistant turn errored, so the
|
|
331
|
+
// capture can flag it (the distiller mines failed→fixed turns into recovery).
|
|
332
|
+
// Exported for testing.
|
|
333
|
+
export function lastAssistantFailed(messages) {
|
|
334
|
+
if (!Array.isArray(messages)) return false;
|
|
335
|
+
for (const entry of [...messages].reverse()) {
|
|
336
|
+
if (entry && entry.info && entry.info.role === "assistant") {
|
|
337
|
+
return !!entry.info.error;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
|
|
330
343
|
export const MeminiPlugin = async ({ client, worktree, directory }, options) => {
|
|
331
344
|
const log = {
|
|
332
345
|
warn: (message) => {
|
|
@@ -420,11 +433,13 @@ export const MeminiPlugin = async ({ client, worktree, directory }, options) =>
|
|
|
420
433
|
const { userText, assistantText, assistantID } = extractLastTurn(res && res.data);
|
|
421
434
|
if (!userText || !assistantText) return;
|
|
422
435
|
if (assistantID && captured.has(assistantID)) return;
|
|
436
|
+
const metadata = { source: "opencode", session_id: sessionID, format: "turn" };
|
|
437
|
+
if (lastAssistantFailed(res && res.data)) metadata.failed = true;
|
|
423
438
|
const stored = await rest.postJson("/v1/memories", {
|
|
424
439
|
content: `${userText.slice(0, 1000)}\n\n${assistantText.slice(0, 3000)}`,
|
|
425
440
|
tier: "episodic",
|
|
426
441
|
tags: ["opencode"],
|
|
427
|
-
metadata
|
|
442
|
+
metadata,
|
|
428
443
|
});
|
|
429
444
|
if (stored !== null && assistantID) captured.add(assistantID);
|
|
430
445
|
}),
|