Skip to content

feat(cli): add /env to list agent-code-relevant environment variables#168

Merged
emal-avala merged 1 commit intomainfrom
feat/cmd-env
Apr 23, 2026
Merged

feat(cli): add /env to list agent-code-relevant environment variables#168
emal-avala merged 1 commit intomainfrom
feat/cmd-env

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

Adds `/env` — shows only the environment variables agent-code actually reads.

  • Config overrides: `AGENT_CODE_API_BASE_URL`, `AGENT_CODE_MODEL`, `AGENT_CODE_CONFIG`
  • Provider API keys: `AGENT_CODE_API_KEY` + 12 provider-native keys (Anthropic, OpenAI, xAI, Google, DeepSeek, Groq, Mistral, Zhipu, Together, OpenRouter, Cohere, Perplexity)
  • Runtime / logging: `RUST_LOG`, `RUST_BACKTRACE`, `NO_COLOR`, `CLICOLOR_FORCE`
  • Shell context: `SHELL`, `TERM`, `EDITOR`

Masking: anything ending `_API_KEY`, `_TOKEN`, or `_SECRET` is displayed as `(N chars, ends in …xxxx)` — enough to confirm the right key is set without leaking it into a screenshare or transcript. Values ≤4 chars are fully masked.

Variables that aren't set are omitted. Tail note tells users "set but not listed variables are not read by agent-code" — important for troubleshooting.

Why

Two common troubleshooting questions this answers:

  1. "Is my API key actually set in the env this process sees?" (masking confirms length + suffix)
  2. "Why is this config value being overridden?" (shows the AGENT_CODE_* overrides in one place)

Previously these required `env | grep ANTHROPIC` / mental model of which vars matter.

Test plan

  • `cargo fmt --all` clean
  • `cargo check` passes
  • `cargo clippy --no-deps` clean
  • `cargo test --bin agent commands::tests` (12 tests total; 3 new for is_secret_var classification + mask_secret length/tail guarantees + short-value safety)
  • Manual: `ANTHROPIC_API_KEY=sk-abc123... /env` shows `(N chars, ends in …c123)`, not the raw key
  • Manual: `/env` with nothing set prints "none of the tracked variables are set"

Shows only the env vars agent-code actually reads — config overrides
(AGENT_CODE_API_BASE_URL, AGENT_CODE_MODEL, AGENT_CODE_CONFIG), the
provider API keys (AGENT_CODE_API_KEY plus the 12 provider-native
keys), runtime/logging (RUST_LOG, RUST_BACKTRACE, NO_COLOR,
CLICOLOR_FORCE), and shell context (SHELL, TERM, EDITOR).

Secrets (anything ending _API_KEY / _TOKEN / _SECRET) are masked to
`(N chars, ends in …xxxx)` — enough to confirm the right key is set
without leaking it into a screenshare or transcript.

Variables that aren't set are omitted from the output, and the tail
note clarifies: "set but not listed variables are not read by
agent-code" — so stale env is visible when troubleshooting.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit b4594c6 into main Apr 23, 2026
13 of 14 checks passed
@emal-avala emal-avala deleted the feat/cmd-env branch April 23, 2026 00:34
@emal-avala emal-avala mentioned this pull request Apr 23, 2026
4 tasks
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