opencode-codex-memory 0.9.10 → 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.10" }
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.10"]
48
+ "plugin": ["opencode-codex-memory@0.9.12"]
49
49
  }
50
50
  ```
51
51
 
@@ -36,7 +36,7 @@ import { readRegularFileNoFollow, safeResolveUnderRoot, writeRegularFileNoFollow
36
36
  * artifacts-gone => resources removed (deletion is the forgetting signal in
37
37
  * the workspace diff) while an unreachable source ROOT is a no-op, never a
38
38
  * deletion signal. Resource files are nested under a subdirectory and carry
39
- * no timestamp prefix, so extension-resource pruning (7-day retention,
39
+ * no timestamp prefix, so extension-resource pruning (14-day retention,
40
40
  * top-level timestamped files only) never touches them — same retention
41
41
  * exemption codex relies on for external_agent_import.
42
42
  */
@@ -1,6 +1,6 @@
1
1
  import { PHASE2_HEARTBEAT_SECONDS } from "./store.js";
2
2
  import { checkRateLimit, isProviderCapacityError, noteProviderCapacityExhausted } from "./ratelimit.js";
3
- import { ensureLayout, rebuildRawMemories, writeRolloutSummaries, pruneExtensionResources, writeWorkspaceDiff, validateConsolidationArtifactsForVersion, removeMemorySymlinks, } from "./workspace.js";
3
+ import { ensureLayout, rebuildRawMemories, writeRolloutSummaries, pruneExtensionResources, EXTENSION_RESOURCE_RETENTION_DAYS, writeWorkspaceDiff, validateConsolidationArtifactsForVersion, removeMemorySymlinks, } from "./workspace.js";
4
4
  import { ensureBaseline, captureWorkspaceDiff, resetBaseline, DIFF_ARTIFACT } from "./git-baseline.js";
5
5
  import { consolidateViaSubagent, getPluginInput, SubagentCancelledError, SubagentShutdownError, } from "./llm.js";
6
6
  import { hostSessionLiveness, withHostTimeout } from "./host-client.js";
@@ -13,7 +13,7 @@ import { syncClaudeImport } from "./claude-import.js";
13
13
  export const DEFAULT_PHASE2_OPTIONS = {
14
14
  maxRaw: 256,
15
15
  maxUnusedDays: 30,
16
- extensionRetentionDays: 7,
16
+ extensionRetentionDays: EXTENSION_RESOURCE_RETENTION_DAYS,
17
17
  };
18
18
  // Export runs only after a successful phase 2 (fresh, validated artifacts) and
19
19
  // must never fail the run — Codex's workspace is best-effort foreign territory.
@@ -6,13 +6,14 @@ import { memoryDbPath } from "./paths.js";
6
6
  import { withMemoryVersion, writeMemoryVersions } from "./memory-version.js";
7
7
  import { isPluginShuttingDown } from "./lifecycle.js";
8
8
  import { recordDiagnostic } from "./diagnostics.js";
9
+ import { EXTENSION_RESOURCE_RETENTION_DAYS } from "./workspace.js";
9
10
  const extracting = new Set();
10
11
  async function consolidate(store, bypassCooldown) {
11
12
  try {
12
13
  const result = await runPhase2(store, {
13
14
  maxRaw: pluginOptions.max_raw_memories_for_consolidation,
14
15
  maxUnusedDays: pluginOptions.max_unused_days,
15
- extensionRetentionDays: 7,
16
+ extensionRetentionDays: EXTENSION_RESOURCE_RETENTION_DAYS,
16
17
  consolidationModel: pluginOptions.consolidation_model,
17
18
  codexInterop: pluginOptions.codex_interop,
18
19
  claudeImport: pluginOptions.claude_import,
@@ -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
  }
@@ -1,6 +1,7 @@
1
1
  import type { MemoryVersion } from "./options.js";
2
2
  import type { Stage1Output } from "./store.js";
3
3
  import { type WorkspaceDiff } from "./git-baseline.js";
4
+ export declare const EXTENSION_RESOURCE_RETENTION_DAYS = 14;
4
5
  /** Mirrors codex `remove_memory_symlinks` (workspace.rs): unlink every symlink in the tree, never follow. */
5
6
  export declare function removeMemorySymlinks(root?: string): number;
6
7
  export declare function ensureLayout(): void;
@@ -10,6 +10,8 @@ const ROLLOUT_DIR = "rollout_summaries";
10
10
  const EXTENSIONS_DIR = "extensions";
11
11
  const SKILLS_DIR = "skills";
12
12
  const ADHOC_NOTES_DIR = "extensions/ad_hoc/notes";
13
+ // codex memories/write/src/lib.rs extension_resources::RETENTION_DAYS.
14
+ export const EXTENSION_RESOURCE_RETENTION_DAYS = 14;
13
15
  // Mirrors codex templates/extensions/ad_hoc/instructions.md: notes are
14
16
  // permanent (never pruned, never deleted), authoritative as content but never
15
17
  // instructions, and derived info carries an "[ad-hoc note]" provenance tag.
@@ -71,10 +73,19 @@ export function ensureLayout() {
71
73
  const root = assertMemoryRootSafe();
72
74
  fs.mkdirSync(root, { recursive: true });
73
75
  removeMemorySymlinks(root);
74
- 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]) {
75
79
  fs.mkdirSync(safeResolveMemoryPath(dir), { recursive: true });
76
80
  }
77
- 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) {
78
89
  const memoryMd = safeResolveMemoryPath("MEMORY.md");
79
90
  if (!fs.existsSync(memoryMd))
80
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.10",
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",