Repository navigation
Conversation
hey kept one sign-in per server, so a second HEY account, staging or a beta could not sit beside the account you use every day without swapping HEY_BASE_URL and signing in again. Profiles are basecamp-cli's at 48b01aaf: profiles and default_profile in the global config; -P/--profile, HEY_PROFILE and resolveProfile's order and words (flag, env, default_profile, a lone profile, a picker at a terminal, else "multiple profiles configured but none selected"); credentials keyed profile:<name>, and hey mcp's mcp:profile:<name>; a cache per profile; and hey profile list|show|create|delete|set-default with basecamp-cli's fields and messages. JSON answers carry meta.profile, and auth status, config show and doctor name the profile. A repository's .hey/config.json sets the profile keys only once hey config trust-local trusts them: they join the digest trusted_local_configs already records, which is unchanged for a config without them. With no profiles configured nothing reads differently. Adapted for hey: a profile that names no account takes All Accounts, not the top-level account default, which belongs to the top-level sign-in, and hey account use under a profile saves to the profile; profile and version-like commands run with no profile selected, so the remedy the refusal names can be taken; a sign-in hint names -P. Verified by make check. The selection, credential-keying and repository-trust tests failed on the tree before this commit; a test pins that with no profiles the config reads, the credential key and the answers are as before, and root help differs only by -P and the profile command. Not ported: --scope and client_id on a profile (hey's CLI client holds only full, and a read sign-in against it is unverified), the auth-login-creates-a-profile path, --expect-identity and the per-field origin bookkeeping. The HEY app endpoint is a later change.
There was a problem hiding this comment.
5 issues found across 23 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/cmd/profile.go">
<violation number="1" location="internal/cmd/profile.go:356">
P2: Profile deletion can send revocation to the wrong server because `Manager.Revoke` ignores the credential’s `TokenEndpoint`. Make revocation use the stored endpoint, falling back to the manager base URL like refresh does.</violation>
<violation number="2" location="internal/cmd/profile.go:364">
P1: Profile deletion can remove a refreshed token without revoking it because revocation and deletion use separate cross-process lock scopes. Keep credential load, revocation, and deletion under one store lock or add an atomic manager operation.
(Based on your team's feedback about serialized logout revocation.) [e28f5d24-4cad-4a96-b372-94072401a059].</violation>
<violation number="3" location="internal/cmd/profile.go:391">
P2: Profile listing reports `authenticated: false` when the credential store is inaccessible, masking keyring and storage failures as a sign-out. Propagate non-`ErrCredentialsNotFound` errors instead of collapsing them into the unauthenticated state.</violation>
</file>
<file name="internal/config/profiles.go">
<violation number="1" location="internal/config/profiles.go:192">
P2: `ApplyProfile` rejects the profile URL before honoring higher-precedence overrides. A malformed or HTTP profile therefore makes `HEY_BASE_URL` and `--base-url` fail instead of using their safe URL; validate after the override is known.</violation>
</file>
<file name="internal/auth/mcp.go">
<violation number="1" location="internal/auth/mcp.go:49">
P2: MCP profile deletion can delete a credential without revoking its grant because `Revoke` ignores the stored credential's `TokenEndpoint`. Use `creds.TokenEndpoint`, falling back to `m.baseURL + "/oauth/tokens"`, for the DELETE URL so migrated or non-default grants are revoked at their issuing endpoint.
(Based on your team's feedback about using the stored OAuth token endpoint for revocation.) [e23596d0-4cad-4f93-ac20-e04bcd88950d]</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Review found that a profile's credential, keyed by its name, went to whatever server HEY_BASE_URL or --base-url named, a lone profile being chosen by itself; that a trusted repository entry could move a global profile to another server and take its sign-in there; and that profile delete sent the refresh token to the profile's base_url unchecked, plain HTTP or a server that never issued it. Now an override naming another server is refused, naming both; a repository entry that would move a global profile is ignored with a warning, and the trust prompt shows each local profile's server; delete revokes only at a server hey sends credentials to whose token endpoint issued the sign-in. A repository's account_id no longer follows a profile to another server, and shell completion offers -P's names with several profiles and none selected. Verified by make check; each new test fails with its guard removed.
There was a problem hiding this comment.
1 existing issue remains and 1 new issue found across 8 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/config/profiles.go">
<violation number="1" location="internal/config/profiles.go:211">
P2: `filesOrigin` can be the environment-overridden server rather than the repository file's `base_url`. With a trusted local account for app, `HEY_BASE_URL=staging`, and an account-less staging profile, this preserves the local account on staging; compare against the local file's server when it is set.</violation>
</file>
Requires human review: Auto-approval blocked because this review re-detected 3 unresolved issues already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
The second review and cubic's found ways a profile's sign-in could still reach the wrong server or be lost: a stored token followed an edited base_url, a repository's account followed a profile to another server, a repository-only profile could be "deleted" and come straight back, delete revoked at whatever server the config named, an access-only sign-in was never revoked, a bad account_id read as none, and the guard on --base-url also refused `hey config set base_url`. Now a profile's stored sign-in is refused when its token endpoint is on another server, and a pasted token records its server. A repository's account_id applies only on the files' own server. Delete refuses a profile set only by a repository config, builds the MCP manager even when the client id is unreadable, and revokes only at the server that issued the sign-in, access-only ones included, warning otherwise. The --base-url check moved to root, so config set works under a profile. account_id must be a string or number. A new profile becomes the default only when no other entry with a base_url exists. Completion survives a refused profile, the config subcommands but show run with none selected, doctor's profile line is sanitized, the trust prompt lists each local profile's server and account, and status hints name `-P <profile>`. Verified: each new test fails with its guard disabled and passes with it; make check passes. Rejected: re-reading the credential under a lock across revoke and delete. `hey auth logout --mcp` has the same shape, and the worst interleaving leaves one rotated grant unrevoked at its own server.
The third review found that `hey auth logout --mcp -P <profile>` still sent a profile's refresh token to whatever server its base_url named now: the issuer check ran on reload, but Revoke loaded the credential itself. It also found that delete reported success for a profile a trusted repository config also sets, which then came back signed out; that a failed `profile create` forgot its sign-in without revoking it; that the trust prompt printed a numeric account as 4.56789e+06; and that an empty account_id stopped every command from loading. Now Revoke refuses a profile credential whose token endpoint is on another server or not recorded, so every caller is covered. Delete refuses a profile a trusted repository config also sets, naming the file. A failed create revokes before it forgets. The trust prompt prints the account whole, and an empty account_id reads as none. Verified: each new test fails with its fix disabled and passes with it; make check passes.
The fourth review found that delete refused a profile whenever a trusted repository config had a key of its name, even one with no base_url, which the loader skips and so can't bring the profile back; and that the trust prompt printed ", mail account " for an empty account_id, which now reads as none. Now delete refuses only for a repository entry with a base_url, and the prompt leaves an empty account out. Verified: both tests fail with the old checks and pass with the new; make check passes.
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
A trusted repository entry with no base_url is no profile, so it does not block a delete; the docs said any entry did. Docs only.
There was a problem hiding this comment.
🟡 Changes recommended
The credential refresh path can adopt another server’s token without validating its issuer and send it to the original server, creating a critical credential-leak risk.
4 open issues
What changed in this PR
Adds named profiles to hey-cli so users can keep multiple HEY sign-ins and server configurations on one computer, while preserving behavior when no profiles are configured.
Changes:
- Adds profile management commands and selection through
-P,HEY_PROFILE, and defaults. - Separates profile credentials and caches, with server-binding checks and repository-config trust controls.
- Adds profile-aware output, documentation, help, and regression tests.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
internal/config/profiles.go |
Implements profile parsing, merging, selection, and persistence. |
internal/config/profiles_test.go |
Tests profile configuration and compatibility. |
internal/config/local_trust.go |
Includes profile settings in local trust fingerprints. |
internal/config/config.go |
Integrates profiles into configuration loading and saving. |
internal/cmd/sdk.go |
Separates HTTP caches by profile. |
internal/cmd/root.go |
Integrates profile selection, authentication, and response metadata. |
internal/cmd/profile.go |
Adds profile management commands and credential cleanup. |
internal/cmd/profile_test.go |
Tests profile commands, isolation, trust, and recovery. |
internal/cmd/profile_select.go |
Implements selection precedence, picker, completion, and login hints. |
internal/cmd/mcp_auth.go |
Selects profile-specific MCP credentials. |
internal/cmd/local_config_trust.go |
Displays profile settings in trust prompts. |
internal/cmd/help.go |
Adds profiles to command and flag help. |
internal/cmd/help_topics.go |
Documents profile environment and account precedence. |
internal/cmd/help_test.go |
Updates expected root help. |
internal/cmd/doctor.go |
Reports the active profile in diagnostics. |
internal/cmd/config.go |
Shows the active profile and selection source. |
internal/cmd/auth.go |
Adds profile-aware status and login guidance. |
internal/cmd/accounts.go |
Explains profile-specific account overrides. |
internal/auth/mcp.go |
Guards profile credential revocation by issuer. |
internal/auth/auth.go |
Adds profile credential keys, issuer validation, and login commands. |
docs/cli.md |
Documents profile workflows and safeguards. |
AGENTS.md |
Records profile architecture and isolation requirements. |
.surface |
Adds profile commands and flags to the CLI snapshot. |
Review effort: Balanced
Copilot and Greptile found that a running manager, a TUI or a watch, adopted whatever its profile's key held when it refreshed, so a profile signed in again at another server by another process had that token sent to the old one. They also found that version, upgrade, commands and completion still selected a profile and failed on a refused or unknown one; that a failed answer carried no meta.profile; that delete dropped a profile whose credential the store could not read or clear, leaving it unreachable; and that `hey account use` under a repository-only profile said "not found", and under a repository entry that sets an account gave no word that the entry still wins. Now the refresh path checks the stored credential's issuer before it caches or uses it. Commands that read no server skip profile selection. A failed JSON answer names the active profile, on a copy of the error. Delete stops before unregistering when the credential can't be removed. `hey account use` names the repository file for a repository-only profile, and says when that file's entry remains higher precedence. Verified: each new test fails with its fix disabled and passes with it; make check passes.
The fifth review found the completion people run is shell-completion, not Cobra's hidden completion, so a broken or unchosen profile still broke the line a shell's rc sources at every start. It now skips selection with the other commands that read no server. The account notice sanitizes the repository path, and a delete stopped by the credential store says how to check it. Verified: the shell-completion case fails without the fix and passes with it; make check passes.
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
hey doctor checks the selected profile's credential store, so the hint names it. The comment on commands that skip selection says what they skip. Verified: make check passes.
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 3 unresolved issues already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
cubic found that a credential store failure during delete came back as an auth error with the sign-in hint, that the doctor hint dropped a profile name the creation pattern refuses, and that one repository path in an account error went unsanitized. Now delete returns the store's own error, a refused keyring's hint included, and otherwise names the profile for hey doctor, quoted where it needs it; the path is sanitized. The refresh test primes the manager's cache first, so it also fails if a refused record leaves the cached token usable. Verified: the refresh test fails with the cache left in place; make check passes.
|
Review state at 9abec28: CI green, 38 review threads answered and resolved, none open. Fresh review. Six rounds: the first over the whole diff, each later one over the fixes since. Rounds 1, 2, 3 and 5 found a High or a Medium, all fixed; rounds 4 and 6 found none, and their Lows are fixed too. Declined, with reasons in each thread:
Reviewers. Copilot and Greptile reported on 5a8fd09, the head marked ready; their 8 findings are fixed. cubic reported through e1bbba6 but not yet on 9abec28, the last push, which fixes its findings from e1bbba6. |


What it lets people do
Keep more than one HEY sign-in on one computer: a second HEY account, or staging or a beta beside the account you use every day. Each is a named profile with its own server, mail account and credential, chosen per command with
-P/--profileorHEY_PROFILE, or bydefault_profile.With no profiles configured nothing changes: the same config reads, the same credential key, the same answers.
What it ports
basecamp-cli's profiles at 48b01aaf, adapted to hey's names:
profilesanddefault_profilein the global config (internal/config/config.go'sProfileConfig:base_url,account_id), merged across files bymergeProfile's rule.-P/--profile,HEY_PROFILE, andresolveProfile(internal/cli/root.go) with its order and its error words: flag, env,default_profile, a lone profile, a picker at a terminal (never underHEY_NONINTERACTIVEor machine output), elsemultiple profiles configured but none selected; use --profile or set default_profile (available: …).profile:<name>(ProfileCredentialKey);hey mcp's apart asmcp:profile:<name>. A response cache per profile.hey profile list|show|create|delete|set-default(internal/commands/profile.go) with its fields and messages.createsigns in before it writes anything and the first profile becomes the default;deleterevokes the profile's sign-ins at its own server, removes them and clearsdefault_profile.hey-specific:
.hey/config.jsonsetsprofiles/default_profileonly oncehey config trust-localtrusts them: they join the digesttrusted_local_configsalready records, so a change needs trust again, and a config trusted before profiles keeps its digest. Untrusted, they are ignored with basecamp-cli's warning.meta.profileon every JSON answer while a profile is active;hey auth status,hey config showandhey doctorname it.hey account useunder a profile saves the account on the profile.hey profile …and the commands that read no server (version,upgrade,skill,setupsubcommands) run with no profile selected, sohey profile set-defaultcan answer the refusal that names it. A profile hey would refuse (plain HTTP to a remote host) doesn't lock outprofile delete/set-default.Run: hey auth login -P <name>.--base-urlorBASECAMP_BASE_URLoverride a profile's server; hey refuses an override naming another server (HEY_BASE_URL https://… is not profile "work"'s server (…)), and refuses a stored sign-in whose token endpoint is on another server, so an editedbase_urlnever carries the old token over.account_idfollows a profile only on the files' own server.deleterefuses a profile a repository config sets, alone or beside the global entry, and revokes only at the server that issued the sign-in, warning where it can't;hey auth logout --mcp -P <name>revokes only there too, and aprofile createwhose config write fails revokes the new sign-in.Verification
make checkpasses.origin/main(e6d5bcb) with the new tests:TestProfilesConfiguredButNoneSelectedRefuses,TestProfileSelectionNamesWhatIsConfigured,TestProfileResolutionOrder,TestEnvironmentAndFlagsOverrideTheProfile,TestAProfilesCredentialIsNeverReadByAnotherandTestRepositoryLocalProfilesNeedTrustfailed;TestNoProfilesChangesNothingpassed there and passes here.TestNoProfilesChangesNothingpins the no-profile path: the token is stored under the origin,mcp::<origin>stays hey mcp's key,auth statusandconfig showanswer as before, and no answer names a profile.TestLocalConfigDigestWithoutProfilesIsUnchangedpins the trust digest.hey --helpagainst a build oforigin/maindiffers only byprofile Manage named profilesand-P, --profile Use a named profile; each subcommand's help only by the inherited-Pflag..surfacegains the profile commands and--profile, nothing else.Left out on purpose
endpoint: app, the gate, the per-endpoint checks) is the next PR, A, built on this one.--scopeandclient_idon a profile. hey's CLI client holds onlyfull, and a read-only sign-in against it is unverified; basecamp-cli's own profile scope is a record of the grant, not used at sign-in.--expect-identity,auth logincreating a profile (AnnotationProfileMayCreate), and the per-field origin bookkeeping basecamp-cli keeps for its account-binding hints.hey setupcreating profiles: a later PR, C.Fix the refresh issuer check and repository profile account saves before merging.
Findings
Fix with agent prompt
Summary
Adds named profiles with separate credentials and caches, trusted repository configuration, profile selection, and management commands.
hey profilecommands manage named sign-ins and their settings.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Load global and repository config] --> B[Trust repository profile keys] B --> C[Choose profile] C --> D[Apply server and account] D --> E[Use profile credential key] E --> F[Check stored credential issuer] F --> G[Make requests] G --> H[Refresh rereads shared credential key] H --> I[Cache replacement without issuer check] I --> GReviews (1) · Last reviewed commit: "The docs say which repository entry hold..." · Reviewed by Greptile