Skip to content

feat(agents): add --print-config flag to codemie-opencode - #453

Merged
TarasSpashchenko merged 8 commits into
mainfrom
feat/opencode-print-config
Jul 31, 2026
Merged

feat(agents): add --print-config flag to codemie-opencode#453
TarasSpashchenko merged 8 commits into
mainfrom
feat/opencode-print-config

Conversation

@TarasSpashchenko

Copy link
Copy Markdown
Collaborator

Summary

Adds a --print-config flag to codemie-opencode that prints the actual generated opencode config (secrets redacted) to stdout and exits, instead of starting opencode. Reuses the existing config-generation path (OPENCODE_CONFIG_CONTENT/OPENCODE_CONFIG) — no changes to opencode.plugin.ts.

Changes

  • redactSecrets utility (src/agents/core/config-redaction.ts) — recursively masks any object key matching a secret-like name (apiKey, x-api-key, token, secret, password, privateKey, credentials, authorization, case-insensitive) at any depth.
  • extractGeneratedConfig helper (src/agents/core/print-config.ts) — reads the config opencode's beforeRun already produced, from OPENCODE_CONFIG_CONTENT or the OPENCODE_CONFIG file.
  • BaseAgentAdapter.run() accepts a { dryRun?: boolean } option; when set, it runs the normal beforeRun lifecycle, prints the redacted config, stops any proxy it started (SSO/JWT auth), and returns before spawn().
  • AgentCLI gains --print-config (opencode-only; other agent CLIs reject it) and forwards { dryRun: true } to adapter.run().
  • Code review (via code-review-orchestrator) caught and fixed two issues before merge: a critical proxy-hang (the dry-run path never stopped the SSO/JWT proxy it started, so --print-config would hang forever under opencode's default auth mode) and a security gap in the redaction regex that missed hyphenated/common secret-key spellings (x-api-key, password, privateKey, credentials). Both are fixed with regression tests.

Testing

  • Tests added/updated — unit tests for redactSecrets, extractGeneratedConfig, the CLI flag, and the adapter's dry-run/proxy-stop behavior; a new integration test against the real opencode beforeRun output.
  • npm run ci equivalent gates all green: license, lint, typecheck, build, unit (2536 passed), integration (204 passed), commitlint.

Checklist

  • Code follows project standards
  • CI is green (npm run ci)
  • No merge conflicts with main

…broaden secret redaction

- BaseAgentAdapter.run(): dry-run short-circuit now stops the proxy (if
  setupProxy started one for SSO/JWT-auth profiles) before returning,
  so `--print-config` no longer hangs the process indefinitely.
- config-redaction.ts: SECRET_KEY_PATTERN now also matches hyphenated
  keys (x-api-key), privateKey, password, and credential(s).

Fixes CR-001 and CR-002 from the code-review.final round.
@TarasSpashchenko
TarasSpashchenko merged commit 04f4c45 into main Jul 31, 2026
5 checks passed
@TarasSpashchenko
TarasSpashchenko deleted the feat/opencode-print-config branch July 31, 2026 18:42
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.

2 participants