Non-interactive prompt values: --set / --set-env#15
Merged
Conversation
Presets with @prompt directives can now be driven from the command line via --set NAME=VALUE (or --set-env NAME=ENV_VAR for secrets). Scope across multi-module installs with --set <preset>.NAME=VALUE. Also fixes a pre-existing bug in expandPromptsInValue and expandCacheInValue where object keys weren't being substituted — mcp-http with a custom header name was writing the literal "{{prompt:headerName}}" as the header key.
- CliArgsError.name set so stack traces identify the class - drop unused SetValue.fromEnv field - --set-env rejects empty env-var values at parse time - install: show printUsage() after CLI arg errors (restores pre-PR UX) - test: cover --set-env with empty env-var value
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
--set NAME=VALUEand--set-env NAME=ENV_VARtoopencode-presets installso presets with@promptdirectives can be driven non-interactively. Scope across multi-module installs with--set <preset>.NAME=VALUE.$,!,*, etc. must be single-quoted or the shell expands them before the CLI sees the value.--set-envis recommended for secrets so tokens don't land in shell history or process listings.expandPromptsInValue/expandCacheInValuenow substitute object keys too. Before this,mcp-httpwith a custom header name wrote the literal"{{prompt:headerName}}"as the JSON key — broken for the headline use case.Test plan
npm test(73 tests pass, including newcli-argsanddistribute-set-valuessuites)OPENCODE_CONFIG: happy path with all four--setflags--set-envreads from env, value with$preserved verbatim--set typo=x→ clean error, exit 1--set-env headerValue=UNSET_VAR→ clean error, exit 1--set name=rejected by the same "cannot be empty" path as interactive{"X-Bitbucket-Token": "<token>"}instead of{"{{prompt:headerName}}": ...}Example