Skip to content

refactor(cli): a --token travels as an argument, never through the process environment - #802

Merged
blafourcade merged 1 commit into
nextfrom
refactor/token-as-argument
Sep 9, 2026
Merged

refactor(cli): a --token travels as an argument, never through the process environment#802
blafourcade merged 1 commit into
nextfrom
refactor/token-as-argument

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

plugin install --token and marketplace add --token used to publish the flag by writing AIDD_TOKEN into the process environment, which the auth reader then read back from the global. #795 had routed that write through an Environment port, 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

  • Both commands hand token to createDeps, which composes it into AuthReaderAdapter as an explicit token, consulted before AIDD_TOKEN and before the stored credentials. Every fetcher already resolves through that reader.
  • The install use case loses its Environment and its token option; the port loses set; the adapter and the in-memory double follow.
  • createDeps caches per project root and token, so a second call with another token is not served the first reader.
  • Two reads of the user's own AIDD_TOKEN remain, both in runtime/auth, both reads. The issue's grep line wanted one; the second is AuthStorage.readActive, which auth status uses, 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.ts
  • grep -rn "process.env.AIDD_TOKEN\|environment.set(" cli/src → two reads in runtime/auth, no write.
  • 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: [ …(3) ].
  • Locally green: typecheck, lint, arch (126), knip, unit+integration (4282), e2e (297), build, smoke (FAIL 0), type honesty.

⚠️ Heads-up

  • presentation/ and kernel/paths.ts still read process.platform, process.cwd() and process.exit directly. Allowed by the layer rule, out of this change.

🔗 Linked issue

Closes #797

✅ I certify

  • I DO CERTIFY I READ EACH LINE OF THE PULL REQUEST BECAUSE I AM A SOFTWARE ENGINEER, NOT A AI PUPPY.

🤖 Generated with Claude Code

https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb

…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
blafourcade requested a review from a team as a code owner September 9, 2026 17:05
@blafourcade
blafourcade merged commit 0affca5 into next Sep 9, 2026
36 checks passed
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
@aidd-bot aidd-bot Bot mentioned this pull request Sep 9, 2026
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