Skip to content

feat(core): render CodeMode catalog deltas from structured snapshots - #38183

Merged
rekram1-node merged 8 commits into
v2from
codemode-catalog-diffs
Jul 24, 2026
Merged

rekram1-node merged 8 commits into
v2from
codemode-catalog-diffs

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Follow-up to #38003, part of the CodeMode catalog work (#36196).

What changed

Moves Code Mode catalog prompting out of @opencode-ai/codemode so core owns all model-facing instruction text, and upgrades the core/codemode instruction source from whole-string replacement to skill-style semantic deltas.

codemode package

  • Removed Runtime.instructions(), DiscoveryOptions, and all catalog prose/budgeting; prepare now returns only structured { catalog, searchIndex }
  • Newly exported CodeMode.searchSignature and CodeMode.toolExpression(path) so hosts can render exact callable forms — signature construction stays codemode-owned
  • Search built-in unchanged

core

  • New CodeModeCatalog module (src/codemode/catalog.ts): owns the ported round-robin token budgeting (default 2000), full instruction rendering, and update() semantic diffing via Instructions.diffByKey
  • CodeMode.materialize returns a structured catalog instead of a rendered string; ExecuteTool.instructions becomes ExecuteTool.catalog
  • CodeModeInstructions stores the sorted structured snapshot with a typed codec, so mid-conversation changes render as tool-level deltas:
    • additions render as new signature lines, removals as exact callable expressions (tools.ns["dashed-name"]), changed signatures as superseding lines
    • full restatement only when the diff is empty, the rendering crosses full/compact modes, or the delta is larger than the full catalog
  • Registration order no longer churns durable instruction history (canonical sorted snapshot)
  • Fixed a semantic merge conflict on v2: feat(core): deliver CodeMode catalog through instructions #38003 landed importing ./effect/app-node after upstream moved it to @opencode-ai/util/effect/app-node, breaking core typecheck

Notes

  • This deliberately overrides spec Q13 (codemode owning catalog rendering) per direction: codemode supplies structured descriptors, opencode owns prompting
  • Codemode instruction-prose tests were ported to packages/core/test/codemode/catalog.test.ts, not dropped

Testing

  • packages/core: typecheck clean, 1417 pass (1 pre-existing environmental failure in plugin.test.ts)
  • packages/codemode: typecheck clean, 1022 pass

@rekram1-node
rekram1-node force-pushed the codemode-catalog-diffs branch from bb017e9 to 12c5984 Compare July 23, 2026 21:41
# Conflicts:
#	packages/codemode/src/tool-runtime.ts
#	packages/core/src/codemode/instructions.ts
#	packages/core/test/codemode/instructions.test.ts
@rekram1-node
rekram1-node merged commit 4605308 into v2 Jul 24, 2026
7 checks passed
@rekram1-node
rekram1-node deleted the codemode-catalog-diffs branch July 24, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant