opencode-codex-memory 0.9.11 → 0.9.12

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 CHANGED
@@ -35,7 +35,7 @@ to your existing global `~/.config/opencode/opencode.jsonc` or `opencode.json`
35
35
  {
36
36
  "$schema": "https://opencode.ai/config.json",
37
37
  "plugins": [
38
- { "package": "opencode-codex-memory@0.9.11" }
38
+ { "package": "opencode-codex-memory@0.9.12" }
39
39
  ]
40
40
  }
41
41
  ```
@@ -45,7 +45,7 @@ to your existing global `~/.config/opencode/opencode.jsonc` or `opencode.json`
45
45
  ```json
46
46
  {
47
47
  "$schema": "https://opencode.ai/config.json",
48
- "plugin": ["opencode-codex-memory@0.9.11"]
48
+ "plugin": ["opencode-codex-memory@0.9.12"]
49
49
  }
50
50
  ```
51
51
 
@@ -26,6 +26,15 @@ Search {{ base_path }}/rollout_summaries/ with the \`memory_search\`
26
26
  pass \`since\`/\`until\` to \`memory_search\` — with a query it searches only that
27
27
  period's sessions/notes; without a query it lists them chronologically.`;
28
28
  const SEARCH_STEP_FILES_V2 = `Search {{ base_path }}/rollout_summaries/ using those keywords when a needed route is missing.`;
29
+ // OpenCode has a native `skill` tool; codex does not. Memory skills are plain
30
+ // files, so a `skill` call by their name fails before the runbook is read.
31
+ const SKILL_STEP_TOOLS = ` Files under {{ base_path }}/skills/ are memory runbooks, not OpenCode skills:
32
+ open \`SKILL.md\` with memory_read (or a file read), never with the \`skill\` tool.`;
33
+ const SKILL_STEP_FILES = ` Files under {{ base_path }}/skills/ are memory runbooks, not OpenCode skills:
34
+ open \`SKILL.md\` with a file read, never with the \`skill\` tool.`;
35
+ // Consolidated summaries link skills as `[skill](skills/…)`, which models read
36
+ // as a `skill` tool handle. Inject them as plain runbook paths instead.
37
+ const SKILL_LINK = /\[skill\]\((skills\/[^)\s]+)\)/g;
29
38
  const UPDATE_INSTRUCTIONS_TOOLS = `Use the \`memory_add_note\` tool, which writes
30
39
  one small note file under \`extensions/ad_hoc/notes/\` describing what to
31
40
  add/delete/update. Do not edit the memory files yourself; the consolidation
@@ -58,7 +67,7 @@ function readMemorySummary() {
58
67
  if (cached && cached.identity === identity) {
59
68
  return cached.content;
60
69
  }
61
- const raw = fs.readFileSync(fd, "utf8").trim();
70
+ const raw = fs.readFileSync(fd, "utf8").trim().replace(SKILL_LINK, "runbook `$1`");
62
71
  if (!raw)
63
72
  return null;
64
73
  const truncated = currentMemoryVersion() === "v2"
@@ -86,6 +95,7 @@ export function buildMemorySystemPrompt(dedicatedTools) {
86
95
  : (v2 ? SEARCH_STEP_FILES_V2 : SEARCH_STEP_FILES);
87
96
  return fillTemplate(template, {
88
97
  search_step: searchStep,
98
+ skill_step: dedicatedTools ? SKILL_STEP_TOOLS : SKILL_STEP_FILES,
89
99
  update_instructions: dedicatedTools ? UPDATE_INSTRUCTIONS_TOOLS : UPDATE_INSTRUCTIONS_FILES,
90
100
  // Filled last so {{ base_path }} nested inside the snippets above resolves.
91
101
  base_path: memoryRoot(),
@@ -38,6 +38,7 @@ Quick memory pass (when applicable):
38
38
  3. Only if MEMORY.md directly points to rollout summaries/skills, open the 1-2
39
39
  most relevant files under {{ base_path }}/rollout_summaries/ or
40
40
  {{ base_path }}/skills/.
41
+ {{ skill_step }}
41
42
  4. If the above are not clear and you need exact commands, error text, or precise
42
43
  evidence, read the most relevant rollout summary files for more evidence.
43
44
  5. If there are no relevant hits, stop memory lookup and continue normally.
@@ -2,7 +2,7 @@ type ModelRef = {
2
2
  providerID: string;
3
3
  id: string;
4
4
  };
5
- /** Only retry host selection failures: these occur before any inference. */
5
+ /** Only retry host startup failures: these occur before any inference. */
6
6
  export declare function isModelSelectionUnavailable(error: unknown, model?: ModelRef): boolean;
7
7
  export declare function retryModelSelection<T>(request: () => Promise<T>, model?: ModelRef, signal?: AbortSignal, delays?: readonly number[]): Promise<T>;
8
8
  export {};
@@ -3,7 +3,10 @@ import { recordDiagnostic } from "../diagnostics.js";
3
3
  // Startup provider registrations can lag service health. Bound the wait rather
4
4
  // than silently changing models or indefinitely hiding a configuration error.
5
5
  const RETRY_DELAYS_MS = [250, 500, 1_000, 2_000, 4_000, 8_000, 15_000, 15_000];
6
- /** Only retry host selection failures: these occur before any inference. */
6
+ // OpenCode 2.1+ holds model requests until location plugins activate, then
7
+ // fails after 5s; provider plugins may still be registering at that point.
8
+ const PLUGIN_ACTIVATION_PENDING = "Location plugins did not finish activating";
9
+ /** Only retry host startup failures: these occur before any inference. */
7
10
  export function isModelSelectionUnavailable(error, model) {
8
11
  const message = model
9
12
  ? `Model unavailable: ${model.providerID}/${model.id}`
@@ -14,6 +17,8 @@ export function isModelSelectionUnavailable(error, model) {
14
17
  const tag = current._tag ?? current.name;
15
18
  if (["InvalidRequestError", "Generate.ModelSelectionError"].includes(tag) && current.message === message)
16
19
  return true;
20
+ if (tag === "ServiceUnavailableError" && current.service === "plugin" && current.message === PLUGIN_ACTIVATION_PENDING)
21
+ return true;
17
22
  }
18
23
  return false;
19
24
  }
@@ -73,10 +73,19 @@ export function ensureLayout() {
73
73
  const root = assertMemoryRootSafe();
74
74
  fs.mkdirSync(root, { recursive: true });
75
75
  removeMemorySymlinks(root);
76
- for (const dir of [ROLLOUT_DIR, SKILLS_DIR, EXTENSIONS_DIR, ADHOC_NOTES_DIR]) {
76
+ const v1 = currentMemoryVersion() === "v1";
77
+ // Codex V2 consolidates into memory_summary.md only; it has no skills/.
78
+ for (const dir of v1 ? [ROLLOUT_DIR, SKILLS_DIR, EXTENSIONS_DIR, ADHOC_NOTES_DIR] : [ROLLOUT_DIR, EXTENSIONS_DIR, ADHOC_NOTES_DIR]) {
77
79
  fs.mkdirSync(safeResolveMemoryPath(dir), { recursive: true });
78
80
  }
79
- if (currentMemoryVersion() === "v1") {
81
+ if (!v1) {
82
+ // Older releases created an empty one; never remove content.
83
+ try {
84
+ fs.rmdirSync(safeResolveMemoryPath(SKILLS_DIR));
85
+ }
86
+ catch { }
87
+ }
88
+ if (v1) {
80
89
  const memoryMd = safeResolveMemoryPath("MEMORY.md");
81
90
  if (!fs.existsSync(memoryMd))
82
91
  writeRegularFileNoFollow(memoryMd, "# MEMORY.md\n\n_Searchable index of memories._\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codex-memory",
3
- "version": "0.9.11",
3
+ "version": "0.9.12",
4
4
  "description": "Persistent memory plugin for opencode — ports codex's two-phase memory system (extraction → consolidation → injection → citation feedback)",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",