Repository navigation
Conversation
`enclave secrets set|unset|list <key>` writes the layered secrets files by service (anthropic, openai, gemini, mistral, copilot-github), so a key reaches every tool that declares it; --tool narrows it to one tool's file and --project to the current project. A new shared project layer, projects/<hash>.env, sits beside the per-tool directory so a tool named "global" cannot collide with it. Secret resolution moves to auth.ResolveSecret so list reports the source sessions actually use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EclipseSourceAI
left a comment
There was a problem hiding this comment.
Note
Autonomous AI review. May contain mistakes.
Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.
Agent approval means no blocking issues found. Unrelated and Follow-up comments are non-blocking. A maintainer must still sign off.
Only a maintainer can re-request a review from this agent.
Powered by Eclipse Enclave via review-guard-mcp
This PR adds enclave secrets set|unset|list <key>. It manages API keys by service (anthropic, openai, gemini, mistral, copilot-github) instead of by hand-edited .env files. internal/apikeys builds the key catalog from the tools' provider credentials and groups them by credential id. set and unset write one of four secrets layers, picked by --tool and --project. The file edits are locked, atomic and follow symlinks. Both commands skip variables that another declared credential also uses. unset also removes stored copies of the removed value from each affected tool's env store, in every project unless --project is given.
What a maintainer should focus on:
- New session layer:
secrets/projects/<hash>.envis a new layer that sessions read under--secrets-scope project|both, betweenglobal/<tool>.envandprojects/<hash>/<tool>.env. This changes how sessions resolve secrets, not just the CLI. - Moved resolution logic: secret resolution moved from
runtime/active_secrets.gointoauth.ResolveSecret. The behavior is the same; drift is now returned and logged by the caller instead of inside the resolver. The existing runtime tests still run against the moved code. - Naming: the verb is
secrets, but it only manages API keys.enclave secrets set GH_TOKENfails with "unknown API key". The maintainers should confirm they're happy with that name before it becomes something users rely on. - Known duplication: the PR description already lists the remaining duplication (withheld/prefix rules, env-store helpers, layer labels) as follow-ups, so I haven't commented on it again.
I built the branch and ran go test for app, apikeys, auth, cli, config and runtime; all passed. I also ran secrets set and secrets list against a scratch home, and they behaved as documented. The inline comments are small reuse and docs nits; none of them blocks the merge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@xai Could you have a look this new proposed feature? |
|
I really like the feature! It provides good UX for something that is currently rather annoying for users. Great work, @kocher! I'll do some testing and dig into this deeper and then come back with a review. |
enclave secrets set|unset|list <key>writes the layered secrets files by service (anthropic, openai, gemini, mistral, copilot-github), so a key reaches every tool that declares it; --tool narrows it to one tool's file and --project to the current project. A new shared project layer, projects/.env, sits beside the per-tool directory so a tool named "global" cannot collide with it. Secret resolution moves to auth.ResolveSecret so list reports the source sessions actually use.What it does
Adds
enclave secrets set|unset|list <key>, so you can manage API keys byservice (
anthropic,openai,gemini,mistral,copilot-github) insteadof editing the layered secrets files by hand. A key reaches every tool that
declares it, and only those.
setwrites to the sharedglobal.envby default.--toolwrites onetool's file instead, and
--projectwrites the current project's variant ofeither. The value comes from a no-echo prompt or from stdin, so it never
shows up in argv or shell history.
setalso removes the key's otheraliases from the file it writes, so one file never holds two disagreeing
values. It then warns about anything that would stop a session from using
the new value:
first
secrets_scopenetworking
unsetremoves the key, plus saved copies of the removed value in eachaffected tool's env store. It skips projects whose own secrets files would
restore that value anyway.
listresolves each key the way a session in this project would. It showsthe masked value, where it comes from, and a note when a session would still
not use it (
no_api_key,ephemeralwithoutpass_api_key, or a prefixgateway protection would refuse).
secrets/projects/<hash>.env, read by every tool inone project. It sits between
global/<tool>.envandprojects/<hash>/<tool>.env.--secrets-scope projectandbothinclude it.runtimeintoauth.ResolveSecret, solistand sessions share one implementation.
follow symlinks, so a secrets file kept in a dotfiles repository stays
linked. Variables that another declared credential also uses are left alone,
with a warning. Shared files are not edited while a tool extension fails to
load.
Docs:
docs/auth.md(new "Managing API keys" section, updated layer table),docs/cli-reference.md,docs/ARCHITECTURE.md, gitlab-cli README.How to test
Unit tests cover target selection, claimed-variable handling, symlinked and
locked edits, env-store cleanup, and resolution precedence (
internal/app,internal/apikeys,internal/auth,internal/cli).Follow-ups
no_api_key,ephemeralwithoutpass_api_key) and when gateway protection refuses its prefix are in bothinternal/app/secrets_cmd.goandinternal/runtime/auth_manager.go. Movethem into one shared function so
secrets listcannot drift from whatsessions do.
enclave secretsreads and edits the persisted env store throughhoststoredirectly, alongside the authManager's own store helpers. Shareone env-store helper keyed by
backend.EnvStoreKey.auth.SecretsLayerPaths,resolveSecretsTarget, andsecretsLayerLabel. HaveSecretsLayercarryits label or kind so a new layer needs one change.
Changelog
Breaking changes
Review checklist