@eleboucher/opencode-memini 0.4.19 → 0.4.20

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 (2) hide show
  1. package/memini.js +16 -1
  2. package/package.json +1 -1
package/memini.js CHANGED
@@ -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: { source: "opencode", session_id: sessionID, format: "turn" },
442
+ metadata,
428
443
  });
429
444
  if (stored !== null && assistantID) captured.add(assistantID);
430
445
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleboucher/opencode-memini",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "description": "Automatic cross-session memory for opencode via memini — recall before each turn, capture after.",
5
5
  "keywords": [
6
6
  "memini",