Skip to content

refactor(opencode): share preset and installer across OpenCode-family agents; find sessions in channel DBs - #2494

Open
vasiliy-mikhailov wants to merge 2 commits into
git-ai-project:mainfrom
vasiliy-mikhailov:refactor/opencode-family
Open

vasiliy-mikhailov wants to merge 2 commits into
git-ai-project:mainfrom
vasiliy-mikhailov:refactor/opencode-family

Conversation

@vasiliy-mikhailov

@vasiliy-mikhailov vasiliy-mikhailov commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

Prepares the OpenCode integration for OpenCode forks that load the same plugin and use the same SQLite schema under different names (Kilo Code, in the follow-up PR), and fixes model lookup for channel databases. No new agent is added here.

  • Preset (presets/opencode.rs): per-agent names/paths move into an OpenCodeFamily struct (tool, data dir, DB file name, storage env var); OpenCodePreset parses through parse_family(&OPENCODE_FAMILY, …). Behavior for OpenCode is unchanged.
  • Channel DBs: the SQLite lookup now also considers opencode-<channel>.db next to opencode.db and picks the DB that contains the session. Builds that write channel DBs previously resolved to opencode.db, missed the session and recorded the model as unknown.
  • Plugin (agent-support/opencode/git-ai.ts): new __GIT_AI_PRESET__ placeholder next to __GIT_AI_BINARY_PATH__. A copy that only substitutes the binary path (older installs, tests) keeps working as the OpenCode plugin.
  • Installer (mdm/agents/opencode.rs): an OpenCodePluginAgent trait (name, id, process names, detection, legacy plugin paths) with one shared HookInstaller impl, so forks only declare names and detection. OpenCodeInstaller keeps its ~/.config/opencode/plugin/ legacy cleanup.

Performance

No git calls and nothing on the daemon ingestion path. The lookup runs in the checkpoint process: one directory listing plus one indexed EXISTS query per candidate DB (typically 1–3), not per file/commit/ref.

Tests (TDD)

  • test_opencode_preset_reads_model_from_channel_db (integration): opencode.db without the session plus opencode-latest.db with it → model gpt-5, source opencode-latest.db (fails on main).
  • Plugin test: preset defaults to opencode when unsubstituted and follows the installer's substitution (fails on main).
  • Installer unit test asserts const PRESET = "opencode" and no leftover placeholder.

Locally: cargo test --lib (2551 passed), integration opencode + install (108 passed), plugin tests 20/20 + tsc --noEmit, cargo fmt --check, cargo clippy --all-targets -D warnings (Rust 1.93).

Follow-up stacked on this: Kilo Code support.

🤖 Generated with Claude Code


Devin Review

… agents; find sessions in channel DBs

Prepare the OpenCode integration for OpenCode forks (Kilo Code) that load the
same plugin and use the same SQLite schema under different names:

- presets/opencode.rs: per-agent names and paths move into `OpenCodeFamily`
  (tool, data dir, DB file name, storage env var); the preset parses through
  `parse_family`. Behavior for OpenCode is unchanged.
- The SQLite lookup now also considers per-channel DBs (`opencode-<channel>.db`)
  next to `opencode.db` and picks the one containing the session, so builds
  that write channel DBs no longer record the model as "unknown". Cost is one
  directory listing plus one indexed query per candidate DB, in the checkpoint
  process only (no git calls, nothing on the daemon ingestion path).
- agent-support/opencode/git-ai.ts: new `__GIT_AI_PRESET__` placeholder. A copy
  that only substitutes the binary path keeps working as the OpenCode plugin.
- mdm/agents/opencode.rs: `OpenCodePluginAgent` trait (name, id, process names,
  detection, legacy plugin paths) with one shared HookInstaller impl;
  OpenCodeInstaller keeps its legacy ~/.config/opencode/plugin/ cleanup.

Tests: channel-DB model resolution (integration), preset substitution and
default (plugin test), installer placeholder substitution (unit).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CLAassistant

CLAassistant commented Nov 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

A binary path containing the preset token kept its literal text only
if the path is substituted last.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vasiliy-mikhailov

Copy link
Copy Markdown
Author

Could a maintainer approve the workflow runs for this PR (and #2495, which stacks on it)? Both come from a fork, so every workflow shows action_required and CI has not run. #2495 is ready from the code side: Devin threads resolved, local fmt/clippy/tests clean, plus a Docker e2e with real VS Code + Kilo Code. Thanks!

This branch has not been deployed

No deployments
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.

2 participants