@u007/opencode-advisor
v1.2.0
Published
OpenCode plugins — advisor() tool and /btw command
Downloads
759
Maintainers
Readme
OpenCode Advisor Plugin
First-class advisor() tool for OpenCode. The executor model (any provider) can consult DeepSeek V4 Pro for strategic guidance mid-task — before writing code, when stuck, or before declaring done.
How it works
The advisor tool appears in the executor's tool list alongside bash, read, edit, etc. The executor decides autonomously when to call it based on the tool description's timing guidance — exactly like Claude Code's native advisor tool.
Executor: "I need to plan this implementation → calls advisor()"
↓
Plugin intercepts, fetches session transcript via SDK
↓
Creates ephemeral session, prompts deepseek-v4-pro with transcript
↓
Returns <300 word guidance → injected as tool result
↓
Executor continues with advice integratedInstall
```bash
npm install -g @u007/opencode-advisorThen add to opencode.json:
{
"plugin": ["@u007/opencode-advisor"]
}Or use the setup script for interactive toggle:
bun run setup # interactive — shows status, prompts actions
bun run setup btw # install/upgrade a specific plugin
bun run setup --all # install/upgrade everythingOr drop plugin .ts files into ~/.config/opencode/plugins/ for zero-config setup.
Configuring the advisor model
Defaults to deepseek/deepseek-v4-pro. Override via either:
1. opencode.json — add an advisor block:
{
"plugin": ["@u007/opencode-advisor"],
"advisor": {
"model": "anthropic/claude-opus-4-7"
}
}Or split form: "advisor": { "providerID": "anthropic", "modelID": "claude-opus-4-7" }.
2. Environment variables (override config):
export OPENCODE_ADVISOR_MODEL="anthropic/claude-opus-4-7"
# or split:
export OPENCODE_ADVISOR_PROVIDER="anthropic"
export OPENCODE_ADVISOR_MODEL="claude-opus-4-7"The chosen provider must be authenticated in OpenCode (/connect).
How the executor knows when to call it
The tool description tells the model:
- Call before substantive work — after reading/discovery, before writing code
- Call when stuck — errors recurring, approach not converging
- Call before declaring done — after deliverable is durable
- On long tasks: at least once before approach + once before done
- Give advice serious weight; surface conflicts rather than silently switching
BTW Command
A /btw (by-the-way) slash command that spawns a fully ephemeral sub-session to answer your question independently. The BTW answer appears as a card in the main session without interrupting the currently running agent.
User: /btw what is the capital of France?
↓
Acknowledged immediately — agent continues working
↓
Ephemeral session investigates in background, reads files, answers
↓
Answer card appears in session — main conversation uninterruptedHow it works
- User types
/btw <question> - Plugin intercepts via
command.execute.beforehook, acknowledges immediately - Background process creates an ephemeral session via SDK (no parentID — fully independent)
- Feeds it the main session transcript + the question
- Ephemeral session runs, reads files, investigates
- Captures the single response
- Deletes the ephemeral session
- Appends answer as a card to main session via
session.prompt({ noReply: true })— no AI response triggered /btwmessage stays visible; current agent unaffected
Install
bun run setup btw # install/upgrade via setup script
bun run setup # interactive mode, select BTWOr drop src/btw.ts into ~/.config/opencode/plugins/ and commands/btw.md into ~/.config/opencode/commands/.
Or via npm (add as separate plugin):
{
"plugin": ["@u007/opencode-advisor", "@u007/opencode-advisor/btw"]
}Config
Same pattern as advisor — opencode.json:
{
"btw": {
"model": "deepseek/deepseek-v4-pro"
}
}Or env vars: OPENCODE_BTW_MODEL, OPENCODE_BTW_PROVIDER.
Requirements
- OpenCode >= 1.4.x
- DeepSeek API key configured via
/connectin OpenCode
License
MIT
