Repository navigation
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
Conversation
… 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]>
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]>
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 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
presets/opencode.rs): per-agent names/paths move into anOpenCodeFamilystruct (tool, data dir, DB file name, storage env var);OpenCodePresetparses throughparse_family(&OPENCODE_FAMILY, …). Behavior for OpenCode is unchanged.opencode-<channel>.dbnext toopencode.dband picks the DB that contains the session. Builds that write channel DBs previously resolved toopencode.db, missed the session and recorded the model asunknown.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.mdm/agents/opencode.rs): anOpenCodePluginAgenttrait (name, id, process names, detection, legacy plugin paths) with one sharedHookInstallerimpl, so forks only declare names and detection.OpenCodeInstallerkeeps 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
EXISTSquery per candidate DB (typically 1–3), not per file/commit/ref.Tests (TDD)
test_opencode_preset_reads_model_from_channel_db(integration):opencode.dbwithout the session plusopencode-latest.dbwith it → modelgpt-5, sourceopencode-latest.db(fails onmain).opencodewhen unsubstituted and follows the installer's substitution (fails onmain).const PRESET = "opencode"and no leftover placeholder.Locally:
cargo test --lib(2551 passed), integrationopencode+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