Skip to content

feat: add modelRemap to translate agent and command models per machine - #105

Open
Rahulsharma0810 wants to merge 1 commit into
iHildy:mainfrom
Rahulsharma0810:feat/model-remap
Open

Rahulsharma0810 wants to merge 1 commit into
iHildy:mainfrom
Rahulsharma0810:feat/model-remap

Conversation

@Rahulsharma0810

Copy link
Copy Markdown

Closes #101

What

New modelRemap map in opencode-synced.jsonc that translates model names per machine:

{ "modelRemap": { "some-provider/some-model": "other-provider/other-model" } }
  • Pull: rewrites the model: frontmatter key of markdown files in agent/, agents/, command/, commands/, mode/, modes/, and the model / small_model values in opencode.json(c) (at any depth, so agent.*.model and command.*.model are covered).
  • Push: reverses the mapping so the repo keeps the canonical value and a pull followed by a push produces no diff. If two canonical values map to the same local value, that local value is left unchanged on push (ambiguous).
  • A #variant suffix is kept when only the base model is mapped. Only exact strings are replaced; prompt bodies and other keys are never touched, and an indented model: inside frontmatter is ignored.

Deviation from #101

The issue suggested putting the table in opencode-synced.overrides.jsonc. That file is deep-merged into opencode.json, so an extra top-level key there would end up in the real config and could fail schema validation. I put modelRemap in opencode-synced.jsonc (which is already synced, per machine), and left dropUnknownModels out because the plugin has no reliable list of locally installed providers.

Compatibility

Default is an empty map, which is a no-op. Invalid entries (non-string, empty, identity) are dropped during normalization.

Tests

  • model-remap.test.ts: exact and variant matches, prototype-key safety, ambiguous inversion, frontmatter-only rewriting, quotes and CRLF, no-frontmatter files, nested config keys without mutating the input.
  • apply.test.ts: pull rewrites agent file and opencode.json; a pull then push leaves the repo files unchanged; no remap means no change.
  • config.test.ts: normalization.
  • bun run check, bun run test (219 passing) and bun run build pass.

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.

Per-machine overrides do not cover agent/command frontmatter (e.g. model remap)

1 participant