@u007/opencode-advisor
v1.2.3
Published
OpenCode plugins — advisor() tool and /btw command
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
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 advisor # add advisor to opencode.json and clean up legacy local copy
bun run setup btw # add BTW to opencode.json and install its command template
bun run setup --all # install/upgrade everything
bun run setup mempalace # opt-in: install MemPalace CLI, skill, and MCP serverMemPalace is opt-in and not part of bun run setup or bun run setup --all.
Configuring the advisor model
Defaults to deepseek/deepseek-v4-pro. Override via either:
You can also pass providerID and modelID directly to the advisor tool for a single call; blank values keep the configured preset.
1. opencode.json — pass options in the plugin entry:
{
"plugin": [
["@u007/opencode-advisor", { "model": "anthropic/claude-opus-4-7" }]
]
}Or split form: ["@u007/opencode-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 via npm (add as separate plugin):
{
"plugin": ["@u007/opencode-advisor", "@u007/opencode-advisor/btw"]
}Config
Pass options in the plugin entry:
{
"plugin": [
["@u007/opencode-advisor/btw", { "model": "deepseek/deepseek-v4-pro" }]
]
}Or env vars: OPENCODE_BTW_MODEL, OPENCODE_BTW_PROVIDER.
MemPalace
CLI-first memory tooling for durable agent state. The opt-in setup flow does three things:
- Installs
mempalaceglobally via npm. - Copies
skills/mempalace/SKILL.mdinto OpenCode's global skills directory. - Registers an OpenCode MCP server entry that launches
mempalace mcpover stdio.
If MCP is configured, prefer the structured recover and save tools. Use the CLI directly when MCP is unavailable.
Requirements
- OpenCode >= 1.4.x
- DeepSeek API key configured via
/connectin OpenCode
License
MIT
