WIP: feat(cli): named credential profiles + --profile (#879 layer 2) - #1161
Closed
asjdf wants to merge 1 commit into
Closed
WIP: feat(cli): named credential profiles + --profile (#879 layer 2)#1161asjdf wants to merge 1 commit into
asjdf wants to merge 1 commit into
Conversation
…erpetualSoftware#879) v2 stored one identity per server URL, so concurrent agents clobbered each other. v3 nests named profiles under each server, selected per invocation by --profile then PAD_PROFILE then default, with transparent v2 migration.
Contributor
Author
|
Closing this draft — we'll use PAD_TOKEN (#1160) for per-agent identity instead of named profiles. |
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 does this PR do?
Layer 2 of #879: named credential profiles in a v3 store, plus a stateless
--profile/PAD_PROFILEselector.This is a draft / WIP. asjdf will review it before it is ready. Please do not merge yet.
Part of #879 (layer 2 of 2). Layer 1 is #1160 (
PAD_TOKENenv override) and is not included here — this branch is independent of #1160 so the two can land in either order. When #1160 merges,PAD_TOKENshould sit above the store lookup inNewClientFromURL(commented at that chokepoint).Store
Bump
~/.pad/credentials.jsonto v3. Each server key holds a map of named profiles;defaultis the implicit profile so single-user v2 files migrate transparently (same probe-and-migrate patternLoadStore()already uses for v1 → v2). Reads stay side-effect-free; Save writes v3.{ "version": 3, "credentials": { "https://app.getpad.dev": { "profiles": { "default": { "token": "...", "user_id": "..." }, "cursor": { "token": "...", "user_id": "..." } } } } }Selection (stateless, per invocation)
--profilepersistent flag >PAD_PROFILEenv >defaultNo persisted "current profile", no
pad auth switch.pad auth login --profile cursor/pad auth logout --profile cursorwhoamiprintsProfile: <name>only when the active profile is notdefaultGetProfile(url, name);Get(url)delegates toGetProfile(url, "default")so existing call sites stayNewClientFromURLuses the resolved profile so every command that goes through the constructor picks the right tokeninitandserver infouse the same resolved profile (they short-circuit the store before the client, same trap xarmian called out for layer 1)Single-profile users see zero behavior change.
How to test
TDD: profile tests were written first and failed on the v2 store (
GetProfileundefined), then the v3 implementation went green. Existing./internal/cli/and./cmd/pad/suites stay green.Manual:
pad auth login— still writesprofiles.default;pad auth whoamihas no Profile linepad auth login --profile cursor— adds a sibling profile; default is untouchedpad --profile cursor auth whoami/PAD_PROFILE=cursor pad auth whoami— reports the cursor identity and printsProfile: cursorpad auth logout --profile cursor— drops only cursor; default remainsTest plan
go test ./internal/cli/ ./cmd/pad/ -count=1--profilebeatsPAD_PROFILEbeats defaultwhoamiomits Profile on default, prints it otherwise--profiledoes not wipe sibling profilesRefs #879. Layer 1 is #1160.