feat: add CLI flags support to attach command#4787
Open
simondmorias wants to merge 6 commits intoanomalyco:devfrom
Open
feat: add CLI flags support to attach command#4787simondmorias wants to merge 6 commits intoanomalyco:devfrom
simondmorias wants to merge 6 commits intoanomalyco:devfrom
Conversation
Add support for --model, --session, --continue, --prompt, --agent, --title, and --command flags to the 'opencode attach' command, bringing feature parity with the main TUI and run commands. Changes: - Added all missing CLI flags to AttachCommand builder - Updated Args interface to include title and command properties - Implemented stdin piping support for prompts - Added command pre-fill support (prepends / to command name) - Updated documentation with complete flag reference and examples This allows users to attach to a running server with pre-configured settings like: opencode attach http://localhost:4096 --model anthropic/claude-3-5-sonnet --agent build opencode attach http://localhost:4096 --command commit --prompt 'with conventional format'
f8ee907 to
6a9856d
Compare
Collaborator
|
/review |
1 task
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Collaborator
|
/review |
Contributor
|
lgtm |
These flags don't make sense in the TUI context: - title: was never used in the TUI flow - command: pre-filling slash commands is unusual for interactive TUI Also resolves merge conflict with upstream dev branch.
Contributor
Author
|
Agreed - removed
Also resolved merge conflicts with upstream dev. |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
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.
Summary
Add support for
--model,--session,--continue,--prompt,--agent,--title, and--commandflags to theopencode attachcommand, bringing feature parity with the main TUI and run commands.Changes
Added CLI flags to AttachCommand builder:
--model/-m- Model to use (format: provider/model)--session/-s- Session ID to continue--continue/-c- Continue the last session--prompt/-p- Prompt to use--agent- Agent to use--title- Title for the session--command- Command to run (uses prompt for args)Updated Args interface to include
titleandcommandpropertiesImplemented stdin piping support for prompts in attach command
Added command pre-fill support in home route - prepends
/to command name and combines with promptUpdated documentation with complete flag reference and usage examples
Usage Examples
Files Changed
packages/opencode/src/cli/cmd/tui/attach.ts- Added flag definitions and argument passingpackages/opencode/src/cli/cmd/tui/context/args.tsx- Extended Args interfacepackages/opencode/src/cli/cmd/tui/routes/home.tsx- Added command pre-fill logicpackages/web/src/content/docs/cli.mdx- Added attach command documentationTesting
bun typecheck)threadcommand for consistencybun run --cwd packages/opencode --conditions=browser src/index.ts \ attach http://localhost:4096 --agent planNotes
--formatflag was intentionally not added as it's only relevant for non-interactive output (like theruncommand), not for the TUIscript/build.tsandsrc/mcp/index.tsare unrelated to these changes