Skip to content

Conversation

@cameronr
Copy link
Collaborator

Backwards compatibility maintained with config.legacy_commands option.
It's currently true but should be set to false at some point in the
future.

Fixes #82

@sudo-tee
Copy link
Owner

Great work on this.

I found an issue with arguments, but to be honest they were made in a weird way

When I run Opencode run_new hello context.current_file.enabled=false it used to use parse the flags at the end

image

This is in the readme

image

But now it's not working anymore they end up in the prompt.

image

They probably should start with -- instead of relying on the first equal sign something=this but it would make backward compatibility harder.

@cameronr
Copy link
Collaborator Author

Ooh, good catch. I'll take a look. Thanks!

@cameronr cameronr force-pushed the refactor/cmd-overhaul branch 2 times, most recently from 26f8d35 to 6519b59 Compare October 29, 2025 22:43
@cameronr
Copy link
Collaborator Author

I had a few mins to look at this. I agree; I really don't like plucking the extra arguments from the prompt. I propose we break backwards compatibility here (it probably isn't used very often anyway) and do the following:

Format

:OpencodeRun [agent=<name>] [model=<model>] [context=<overrides>] <prompt>
:OpencodeRunNewSession [agent=<name>] [model=<model>] [context=<overrides>] <prompt>

All three are optional, can appear in any order, but must come before the prompt.

Examples

Single prefix:

:OpencodeRun agent=plan what's the architecture here?
:OpencodeRunNewSession model=github-copilot/gpt-4.1 fix this bug
:OpencodeRun context=current_file.enabled=false analyze the project

Multiple prefixes (any order):

:OpencodeRun agent=plan model=github-copilot/claude-sonnet-4 review my code
:OpencodeRunNewSession model=anthropic/claude-3.5 agent=build context=selection.enabled=false refactor this
:OpencodeRun context=diagnostics.error=true,current_file.enabled=false agent=plan model=openai/gpt-4 what are the errors?

No prefixes:

:OpencodeRun Fix the bug in the current file

Complex context with multiple overrides:

:OpencodeRunNewSession agent=plan context=current_file.enabled=false,selection.enabled=true,diagnostics.warn=false help me understand this

Parsing Logic

  1. Scan tokens from left to right
  2. If token matches agent=*, extract agent name
  3. If token matches model=*, extract model
  4. If token matches context=*, pass the value to parse_dot_args()
  5. Everything else (first non-matching token onward) becomes the prompt

Context value format

The context= value would be comma-delimited key=value pairs using dot notation, parsed by parse_dot_args():

  • context=current_file.enabled=false
  • context=current_file.enabled=false,diagnostics.info=true,selection.enabled=false

How's that sound?

@sudo-tee
Copy link
Owner

To.me it sounds pretty reasonable.

I agree that by looking at usage on GitHub it does not seem to be a used feature at the moment.

So I would be ok with your solution.

Backwards compatibility maintained with config.legacy_commands option.
It's currently true but should be set to false at some point in the
future.

Fixes sudo-tee#82
@cameronr cameronr force-pushed the refactor/cmd-overhaul branch from 6519b59 to 46b8469 Compare October 30, 2025 02:40
As discussed in sudo-tee#84, the previous cmd refactor had broken argument
handling for run/run_new.

The old format had an ambiguity between prompt and context args.

This change is breaking because we no longer support the old format. The
new format is:

:OpencodeRun [agent=<name>] [model=<model>] [context=<overrides>] <prompt>
:OpencodeRunNewSession [agent=<name>] [model=<model>] [context=<overrides>] <prompt>
@cameronr
Copy link
Collaborator Author

Ok, I think this is all set. Whenever you have time, let me know if you see any other issues.

@sudo-tee
Copy link
Owner

Looks good to me.

I think there is an issue where the context is not loaded properly whan using the context params, but it's not a bug in your MR.

This should be adressed in the context bar i'm doing.

Thanks a lot for your great PR

@sudo-tee sudo-tee merged commit 19f8941 into sudo-tee:main Oct 30, 2025
5 checks passed
@cameronr cameronr deleted the refactor/cmd-overhaul branch November 6, 2025 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: All cmds should be under a single Opencode cmd

2 participants