feat: add CLI flags support to attach command #4787
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