feat(opencode): add /ctx slash command to TUI for session stats#935
Open
bulutmuf wants to merge 1 commit into
Open
feat(opencode): add /ctx slash command to TUI for session stats#935bulutmuf wants to merge 1 commit into
bulutmuf wants to merge 1 commit into
Conversation
Registers a /ctx slash command (aliases: ctx-stats, context-mode) in the
OpenCode TUI that displays real-time and lifetime context-mode savings.
Implementation details:
- src/adapters/opencode/tui.ts: new TUI module exported as default
{ id: 'context-mode-tui', tui }. Queries SessionDB directly using
bun:sqlite at runtime (since Bun TUI cannot load better-sqlite3).
- Displays a clean key:value layout with total events, estimated USD saved,
and ASCII progress bars for the top 4 categories.
- package.json: added './tui' export pointing to tui.bundle.mjs; added
tui.ts esbuild step to the bundle script (external: better-sqlite3, bun:sqlite).
- README.md: updated OpenCode and KiloCode installation guides to document
registering 'context-mode/tui' in tui.json.
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.
This PR introduces the
/ctxslash command to the OpenCode adapter, allowing users to viewcontext-modeusage statistics directly from the OpenCode TUI interface.What does this PR do?
tui.tsmodule for the OpenCode adapter that exposes a TUI plugin via default export./ctx(with aliasesctx-stats,context-mode) slash command in OpenCode'spalettenamespace.DialogAlertfeaturing:bun:sqlitefor Bun runtime in the TUI, falling back tobetter-sqlite3for Node).README.mdto instruct OpenCode and KiloCode users to register"context-mode/tui"in theirtui.json.Why is this needed?
context-modeMCP server starts correctly viaopencode.json, users had no UI to monitor their token savings. This brings the terminalctx statsfunctionality native to the OpenCode GUI.How to test:
npm run buildnpm link) or run from the source directory."context-mode/tui"to~/.config/opencode/tui.json./ctx, and press Enter.Affected Platforms
Checklist
npm testpasses (or the failure is a known upstream issue).npm run typecheckpasses.\backslashes).README.md/SKILL.md) has been updated if applicable.