opencode-bytheway
v0.7.0
Published
OpenCode TUI plugin based on Claude Code's "btw" feature
Readme
opencode-bytheway
OpenCode plugin that adds temporary "by the way" side-session workflows.
A proof-of-concept plugin to implement something like Claude Code's "btw" feature, where you can branch into a temporary side session, then discard it or merge text back into the parent session when you are done.
/btw opens a session that you can exit with /btw-end.
/btw your prompt here opens the temp session and sends that prompt there without adding it to the parent transcript.
/btw-fast opens a temp session with only recent plain-text context when a full fork would be too slow.
/btw-prompt can also be used as /btw-prompt tell me more about foo(); it is experimental.
Typed /btw, /btw-fast, /btw-merge, /btw-end, /btw-status, and /btw-prompt commands are handled by the TUI plugin instead of requiring a model call just to dispatch.
Normal usage:
- run
/btwand then type in the temp session - run
/btw your prompt hereto open the temp session and send an initial prompt there - run
/btw-fastwhen you want a faster side session with only recent plain-text context
Experimental prompt entrypoint:
- run
/btw-prompt your prompt hereto open the temp session and hand that prompt to the TUI plugin - the command is handled in the TUI without an LLM hop
- the TUI plugin forks the current session, switches you into the fork in the same terminal, and sends the initial prompt there without adding it to the parent transcript
No nesting.
name clash
A plugin package opencode-btw already exists. It is not an attempt to emulate Claude Code, it provides persistent steering hints.
Install
Use OpenCode's plugin installer:
opencode plugin opencode-bytheway --globalThe package is a TUI-only plugin. It should be loaded from tui.json[c].
Use --force if you need to replace an existing pinned version:
opencode plugin [email protected] --global --forceOpenCode 1.17.12 loads TUI plugins from tui.json[c]. Do not add this package to opencode.json[c]; it no longer exports a server plugin.
Example tui.jsonc:
{
"plugin": ["opencode-bytheway"]
}Optional version pin:
{
"plugin": ["[email protected]"]
}Restart OpenCode after installing or updating the plugin.
Troubleshooting:
- if
/btwdoes not appear or does not open a side session, confirm the package is loaded intui.json[c] - reload or restart OpenCode after changing TUI config
Optional command-family override:
OPENCODE_BYTHEWAY_COMMAND=asideWith that env var set, the plugin exposes /aside, /aside-fast, /aside-merge, /aside-end, and /aside-status instead of the default /btw command family.
The experimental /btw-prompt command stays fixed.
Optional diagnostic logging:
OPENCODE_BYTHEWAY_DIAGNOSTICS=1When enabled, the plugin writes JSONL diagnostic logs to /tmp/opencode-bytheway-event.log and /tmp/opencode-bytheway-toast.log.
These logs are disabled by default.
Commands
/btw: open a temporary btw side session in the same terminal, preserving context from the current session/btw-fast: open a temporary btw side session with only bounded recent plain-text context, avoiding a full session fork/btw your prompt here: open the temporary side session and send that prompt inside the forked temp session/btw-merge: append plain user/assistant text from the temporary session into the original session as it exists when merge runs, then close the temporary session/btw-end: return to the original session as it exists now and remove the temporary btw session without carrying text back/btw-status: show whether the TUI plugin is loaded/btw-prompt your prompt here: experimental TUI-owned entrypoint that opens a forked temp session and sends the initial prompt there
User experience
/btwis for branching off in the same terminal while keeping your main session intact/btw-mergecarries back only plain user/assistant text from the temporary session; tool calls and subagent details are omitted/btw-mergeasks for confirmation first if the original session continued while the temporary session was active/btw-endis the clear way back when you want to discard the temporary session without merging text back- nested btw sessions are blocked to avoid stacked temporary contexts
Local development
bun install --ignore-scripts
bun run build
bun run test
bun run test:integration
npm pack --dry-runFor local OpenCode testing, point tui.json[c] at this repository path after running bun run build.
After changing tui.tsx, run bun run build again before reopening or reloading OpenCode so the local plugin uses the updated dist/tui.js.
bun run test:integration launches the real installed opencode TUI inside a pseudo-terminal and drives /btw from an isolated temporary config. Use it when developing TUI/session behavior; it is intentionally separate from bun run test because it depends on the local OpenCode binary and runtime environment.
Set OPENCODE_BTW_OPENCODE_BIN=/absolute/path/to/opencode to run the integration suite against a specific OpenCode binary.
OpenCode 1.17.12 loads TUI plugins from tui.json[c].
Example tui.json entry for the slash commands:
{
"plugin": [
"file:///home/{USER}/projects/opencode-btw-plugin"
]
}Point at the package root, not dist/tui.js directly.
Use an absolute file:// path in the config. Do not rely on ~ or $USER expansion inside tui.json, since config values are not shell-expanded.
Local tui.json[c] files are convenient for faster iteration, but keep them untracked in your clone.
Their absolute file:// paths are machine-specific and should not be committed to the package repo.
Investigating /btw-prompt
/btw-prompt is intercepted by the TUI prompt layer, so it does not need a model call just to forward the raw command arguments.
It uses the same TUI-owned fork flow as /btw your prompt here.
Changelog
0.7.0
- Built against OpenCode 1.17.12.
- Add
/btw-fast, which opens a temporary session with only bounded recent plain-text context instead of forking the full source session. - Show immediate startup toasts for
/btwand/btw-fastso long-running opens have visible feedback. - Avoid copying the latest previous session when
/btwor/btw-faststarts without an active session. - Add fork timing diagnostics for
/btwand real-TUI integration coverage for/btw-fast.
0.6.0
- Built against OpenCode 1.17.9.
- Remove the server plugin entry and helper tools; the package is now TUI-only.
- Remove server file-handoff/status compatibility paths from the TUI plugin.
- Update integration smoke tests to load the plugin only through
tui.json[c]. - Fix slash autocomplete selection for
/btw-endand/btw-mergeby letting OpenCode's autocomplete handler own Enter while autocomplete is open. - Clear stale persisted
/btwstate when OpenCode resumes directly into a previously temporary session.
0.5.1
- Built against OpenCode 1.17.8.
- Speed up bare
/btwopens by skipping the source-message pre-scan. - Clarify that
/btw-endreturns to the original session as it exists at return time. - Ask for confirmation before
/btw-mergewhen the original session advanced while the temporary session was active. - Add real-TUI integration coverage for bare
/btwmerge boundaries.
0.5.0
- Built against OpenCode 1.17.8.
- Target OpenCode 1.17.8 command behavior by moving
/btwslash dispatch fully into the TUI plugin. - Stop registering server prompt-command shims for the
/btwcommand family, avoiding duplicate slash autocomplete entries and unsafe display-only server command handling. - Add real-TUI integration coverage for typed bare
/btw.
0.4.1
- Built against OpenCode 1.17.7.
- modernize TUI slash-command registration onto the current keymap layer API
- update session list, fork fallback, temp-session rehydration, and merge tracking for current OpenCode SDK shapes
- tag temporary sessions with plugin metadata and harden prompt/status handoff files
- add TypeScript typecheck coverage and update OpenCode/OpenTUI plugin dependencies
0.4.0
- Built against OpenCode 1.17.7.
- show changelog details in
README.mdso npmjs.com displays release notes - clarify documented
/btw <prompt>support and plugin-hook dispatch behavior
0.3.16
- Built against OpenCode 1.17.7.
- fix typed
/btw <prompt>on OpenCode 1.17.7 without runtime exception flashes or origin transcript pollution - avoid intercepting Enter for unrelated prompt slash commands such as
/sessions - add regression coverage for real TUI prompt handoff and keybinding behavior
0.3.15
- support OpenCode command hooks that mark slash commands handled through the hook output object
0.3.14
- add regression coverage that
/btwcontinues to fork large source sessions without a fork guard
0.3.13
- share bytheway protocol helpers between the server and TUI plugin halves
0.3.12
- clear stale active
/btwstate from another origin session before opening a new side session - add opt-in diagnostics and integration coverage for typed
/btw <prompt>handoff flow
0.3.11
- update the TUI command and session flow to work with OpenCode 1.14.48
- add an opt-in integration test that launches a real OpenCode TUI session for
/btwcoverage
0.3.10
- align CI and release workflows with Bun 1.3.13 to match local verification
- make command-handler tests await command completion instead of depending on scheduler timing
0.3.9
- document
opencode plugin opencode-bytheway --globalas the primary install path because it updates both server and TUI config files - keep manual dual-file config instructions as a fallback for users not using the plugin installer
0.3.8
- report both server and TUI plugin versions from
/btw-statusso mismatched OpenCode config entries are easier to diagnose - document keeping
opencode.jsoncandtui.jsoncpinned to the same plugin version
0.3.7
- restore typed
/btw,/btw-merge, and/btw-enddispatch for current OpenCode by routing server slash shims into the TUI command handlers - avoid duplicate slash autocomplete entries by keeping slash metadata on the server shims only
- make
/btw-statususe the current TUI toast event path - resume or clear stale
/btwstate instead of refusing to open a side session after restart - support
/btw <prompt>by handing the inline prompt to the new temporary session
0.3.6
- keep
/btwand/btw-promptvisible on the origin session even while a temporary/btwsession is active - continue to restrict
/btw-mergeand/btw-endto the active temp session where they actually work
0.3.5
- refine the published package metadata description to better describe the Claude Code-inspired btw workflow
- include the plugin version in
/btw-statusoutput so loaded builds are easier to identify in TUI
0.3.4
- refine the published package metadata description to better describe the Claude Code-inspired btw workflow
0.3.3
- rename the remaining
/btwslash-command family members to hyphenated forms:/btw-mergeand/btw-end - keep command-family overrides consistent with the same hyphenated naming, such as
/aside-mergeand/aside-end
0.3.2
- rename the experimental server-side prompt command to
/btw-prompt - route
/btw-promptthrough the existing TUI-owned/btwopen flow so the initial prompt runs inside the forked session - namespace and scope prompt handoff files to the origin session to avoid cross-session collisions during local testing
0.3.1
- scope
/btwcommand visibility to the current session so unrelated sessions do not incorrectly show/btw-end - handle
/btw-statusdirectly in the TUI with a toast instead of sending it through the agent loop
0.3.0
- add direct non-LLM dispatch for
/btw-promptwhile keeping the proven TUI handoff flow - remove temporary debug slash commands and trim unused server helpers
- improve experimental runtime logging for live debugging and restore the file-based prompt handoff after the parent-linked refactor failed in the live host
0.2.3
- add direct non-LLM dispatch for
/btw-promptwhile keeping the proven TUI handoff flow - remove temporary debug slash commands and trim unused server helpers
- improve experimental runtime logging for live debugging and restore the file-based prompt handoff after the parent-linked refactor failed in the live host
0.2.2
- restore
/btwto TUI-only ownership and move the seeded server-side entrypoint to/btw-prompt
0.2.1
- publish the side-session-only release from the OIDC trusted publishing workflow
0.2.0
- remove
/btw_popupand its popup-dialog runtime so the plugin focuses on temporary side sessions - load active bytheway sessions cleanly, keep the sidebar indicator aligned with the active temp session, and improve command-family overrides for local installs
0.1.5
- align the runtime plugin id with the published package name and add direct server-entry coverage
- harden popup and temp-session cleanup for canceled runs and failed
/btw-enddeletes - add an optional
OPENCODE_BYTHEWAY_COMMANDenv var to rename the/btwslash-command family - pin Bun in CI and release workflows and document local
file://plugin development setup
0.1.4
- publish a clean release from the planner-aligned workflow after the earlier workflow-only tags failed before matching package metadata
0.1.2
- align the standalone release workflow more closely with
opencode-plannerbefore the next publish attempt
0.1.1
- rename the npm package to
opencode-bythewayso the standalone repo can publish under a clean available name
0.1.0
- add
/btwfor same-terminal temporary side sessions - add
/btw-endto return to the original session and close the temp session - add
/btw_popupfor one-off popup questions that preserve the current screen - improve popup rendering, copy feedback, and streaming stability
- publish from the standalone
opencode-btwrepository using a root package and root release workflow
Release
- CI and release publish from repo root.
- The release workflow does not bump
package.json; bump the version and commit it before tagging. - Stable release tags only. Tag format is
v*, and the tag version must matchpackage.jsonexactly. - The workflow runs
bun run test,bun run build, publishes to npm, and creates the GitHub release.
Before tagging:
bun run build
bun run test
bun run test:integration
npm pack --dry-runRelease checklist:
# update package.json version, for example x.y.z
# update CHANGELOG.md, including the OpenCode version the plugin was built against
# update the README.md changelog section with the same release details for npmjs.com
git add package.json CHANGELOG.md README.md
git commit -m "chore: release x.y.z"
git tag vx.y.z
git push origin main
git push origin vx.y.zAfter install, verify the TUI plugin commands load:
/btw,/btw-merge,/btw-end,/btw-status,/btw-prompt
