feat(opencode): add interactive visualize command - #48586
Closed
prethiv wants to merge 2 commits into
Closed
Conversation
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Author
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
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.



Issue for this PR
Closes #48585
Type of change
What does this PR do?
Adds a
/visualizecommand andopencode visualizeCLI with an interactive confirmation step.Problem: When agents explain complex architectures, distributed flows, or database schemas, they either dump 150+ lines of raw Mermaid/ASCII markup into the terminal or produce long text explanations that are hard to visualize.
Changes made:
packages/opencode/src/cli/cmd/visualize.tsand registered it insrc/index.ts.@clack/promptsto confirm output destination (browser,terminal,ascii,file, orskip) before rendering, preventing unsolicited terminal clutter.context(System Context & Session Runtime pipeline),architecture(layer topology),flow <module>(sequence diagrams),schema <path>(database ERD),deps(package graph),state(drain lifecycle), and git diff inference.file:///link to the user..opencode/command/visualize.md, onboarded conventions intoAGENTS.md, and added.opencode/command/teach.md.Why it works: Separates diagram generation from terminal printing behind a selection prompt, while generating a standalone HTML canvas with client-side Mermaid rendering for rich visual inspection without external server dependencies.
How did you verify your code works?
Tested locally using Bun:
bun packages/opencode/src/index.ts visualize --helpand verified flags (--dest,--format,--output,--yes).bun packages/opencode/src/index.ts visualize context -t ascii -yand verified clean Unicode box-drawing output in terminal.bun packages/opencode/src/index.ts visualize context -t browser -yand verified it created the.htmlartifact in.opencode/artifacts/and opened it in the default browser.