refactor(cli): a --token travels as an argument, never through the process environment - #802
Merged
Merged
Conversation
…ocess environment `plugin install --token` and `marketplace add --token` hand the flag to `createDeps`, which composes it into the auth reader every fetcher consults, ahead of `AIDD_TOKEN` and the stored credentials. Nothing writes the environment any more: the install use case loses its `Environment` and the port loses `set`. Two reads of the user's own `AIDD_TOKEN` remain, both in `runtime/auth`, both reads. Red first: the auth reader's explicit-token test failed with `expected 'env-token' to be 'flag-token'`, the marketplace wiring test with `expected "spy" to be called with arguments`. Closes #797 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb AIDD-Session-Id: 4acc9a1c-19bc-4468-b8b6-e86644bcba60
blafourcade
added a commit
that referenced
this pull request
Sep 9, 2026
The install use case lost its Environment in #802 (the token now travels as an argument), so the merged test keeps every new case and drops the three that published a token through it, and the adapter test loses the write it no longer has. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb AIDD-Session-Id: 4acc9a1c-19bc-4468-b8b6-e86644bcba60
Merged
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.
🎯 What & why
plugin install --tokenandmarketplace add --tokenused to publish the flag by writingAIDD_TOKENinto the process environment, which the auth reader then read back from the global. #795 had routed that write through anEnvironmentport, but the channel stayed ambient: set in one command, visible to every later read, leaking between tests, invisible in the types. The token now travels as an argument.🛠️ How it works
tokentocreateDeps, which composes it intoAuthReaderAdapteras an explicit token, consulted beforeAIDD_TOKENand before the stored credentials. Every fetcher already resolves through that reader.Environmentand itstokenoption; the port losesset; the adapter and the in-memory double follow.createDepscaches per project root and token, so a second call with another token is not served the first reader.AIDD_TOKENremain, both inruntime/auth, both reads. The issue's grep line wanted one; the second isAuthStorage.readActive, whichauth statususes, and it was left as is.🧪 How to verify
cd cli && pnpm vitest run tests/runtime/auth/auth-reader.integration.test.ts tests/presentation/commands/plugin-wiring.integration.test.ts tests/presentation/commands/marketplace-wiring.integration.test.tsgrep -rn "process.env.AIDD_TOKEN\|environment.set(" cli/src→ two reads inruntime/auth, no write.expected 'env-token' to be 'flag-token'; the marketplace wiring test withexpected "spy" to be called with arguments: [ …(3) ].presentation/andkernel/paths.tsstill readprocess.platform,process.cwd()andprocess.exitdirectly. Allowed by the layer rule, out of this change.🔗 Linked issue
Closes #797
✅ I certify
🤖 Generated with Claude Code
https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb