Skip to content

Phase 1: Model portability (tiered presets + token resolver) - #10

Merged
NicoGenti merged 1 commit into
mainfrom
phase1/model-portability
Aug 31, 2026
Merged

NicoGenti merged 1 commit into
mainfrom
phase1/model-portability

Conversation

@NicoGenti

Copy link
Copy Markdown
Owner

Problem

Every agent's frontmatter hardcodes a concrete model: value (e.g. opencode-go/gpt-5.6-luna, ollama/deepseek-v4-flash:cloud, ollama/minimax-m3:cloud). New users without access to those exact providers/models had to hand-edit 15 files before the kit would run.

What this PR adds

  1. .opencode/models.config.json — centralized config mapping three logical tiers to concrete models per preset:

    • TIER_REASONING — orchestrator, oracle, security, planner
    • TIER_CODE — code-reviewer, developer-fixer, test-engineer
    • TIER_FAST — explorer, librarian, pc-doctor, npm-helper, build-helper, deploy-helper, writer, profiler
  2. Four presets:

    • opencode-go (default) — router flagship for reasoning, cloud-hosted specialists for code/fast. Matches current out-of-the-box behavior.
    • local-ollama — fully offline: qwen2.5-coder:32b / qwen2.5-coder:14b / deepseek-coder:6.7b.
    • commercial-api-anthropic — Claude Opus/Sonnet/Haiku via ANTHROPIC_API_KEY.
    • commercial-api-openai — GPT-4o / GPT-4o-mini via OPENAI_API_KEY.
  3. scripts/apply-model-preset.py — resolves {{TIER_REASONING}}, {{TIER_CODE}}, {{TIER_FAST}} tokens in agents/*.md frontmatter to the concrete IDs from a chosen preset. Supports --list, --dry-run, and --restore (revert concrete IDs back to tokens).

  4. scripts/migrate-agents-to-tokens.sh — one-time migration replacing the current hardcoded model values in all 15 agent files with the matching {{TIER_*}} token, using the exact literal values already in each file (idempotent, single-line sed replace, no other frontmatter touched).

Follow-up needed before merge (manual, not included in this PR)

install.sh should call the resolver after copying agents into place. I could not safely retrieve the exact current byte content of install.sh through the tooling available in this session, so rather than risk a blind full-file rewrite of a protected script, here is the exact snippet to add by hand near the end of install_into(), after the link_or_copy "$KIT_DIR/command" "$base/command" line and before its closing }:

  # Phase 1: resolve model tiers for the chosen preset
  local preset="${OPENCODE_MODEL_PRESET:-opencode-go}"
  if [[ -f "$KIT_DIR/scripts/apply-model-preset.py" ]]; then
    echo "Applying model preset: $preset"
    python3 "$KIT_DIR/scripts/apply-model-preset.py" \
      --preset "$preset" \
      --config "$KIT_DIR/.opencode/models.config.json" \
      --agents-dir "$base/agents"
  fi

Usage after wiring:

./install.sh project                                   # default preset: opencode-go
OPENCODE_MODEL_PRESET=local-ollama ./install.sh project
OPENCODE_MODEL_PRESET=commercial-api-anthropic ./install.sh global

Suggested merge order

  1. Review/merge this PR (new config + scripts, zero behavior change on its own).
  2. Run bash scripts/migrate-agents-to-tokens.sh to tokenize agents/*.md.
  3. Run python3 scripts/apply-model-preset.py --preset opencode-go --dry-run to verify round-trip resolves back to the original values.
  4. Wire the install.sh snippet above.
  5. Mention OPENCODE_MODEL_PRESET in README.md / QUICKSTART.md.

@NicoGenti
NicoGenti merged commit 4f2b011 into main Aug 31, 2026
1 check passed
@NicoGenti
NicoGenti deleted the phase1/model-portability branch August 31, 2026 15:16
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