Skip to content

Non-interactive prompt values: --set / --set-env#15

Merged
trick77 merged 4 commits intomasterfrom
feat/install-set-flags
May 11, 2026
Merged

Non-interactive prompt values: --set / --set-env#15
trick77 merged 4 commits intomasterfrom
feat/install-set-flags

Conversation

@trick77
Copy link
Copy Markdown
Owner

@trick77 trick77 commented May 11, 2026

Summary

  • Adds --set NAME=VALUE and --set-env NAME=ENV_VAR to opencode-presets install so presets with @prompt directives can be driven non-interactively. Scope across multi-module installs with --set <preset>.NAME=VALUE.
  • Documents the quoting gotcha in README — values with $, !, *, etc. must be single-quoted or the shell expands them before the CLI sees the value. --set-env is recommended for secrets so tokens don't land in shell history or process listings.
  • Drive-by fix: expandPromptsInValue / expandCacheInValue now substitute object keys too. Before this, mcp-http with 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 new cli-args and distribute-set-values suites)
  • Manual smoke against a throwaway OPENCODE_CONFIG: happy path with all four --set flags
  • --set-env reads from env, value with $ preserved verbatim
  • --set typo=x → clean error, exit 1
  • --set-env headerValue=UNSET_VAR → clean error, exit 1
  • Empty --set name= rejected by the same "cannot be empty" path as interactive
  • Header key substitution now produces {"X-Bitbucket-Token": "<token>"} instead of {"{{prompt:headerName}}": ...}

Example

opencode-presets install mcp-http \
  --set name=openrag \
  --set url=https://openrag.example.internal/mcp \
  --set headerName=X-Bitbucket-Token \
  --set-env headerValue=BITBUCKET_TOKEN

trick77 added 4 commits May 9, 2026 12:19
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
@trick77 trick77 merged commit a4ae8b8 into master May 11, 2026
2 checks passed
@trick77 trick77 deleted the feat/install-set-flags branch May 11, 2026 06:48
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.

1 participant