Say what to store, not where it goes - #619
Merged
Merged
Conversation
Storing a value meant knowing the key it lives under, so callers passed
keys around: config.delete('current_workspace_id'), config.set(`${endpoint}.pat`,
token), and a storeEndpoint helper for the three writes that go together.
The config now answers in the CLI's own terms — setWorkspace, unsetWorkspace,
getToken, setToken, unsetToken, setEndpoint — and the keys live in values.ts,
used by that one file. Reading and writing per endpoint, dropping the legacy
key, and clearing what belonged to the previous endpoint are its business
rather than each caller's.
seamPaths moves here too, as rootPaths: where the CLI keeps its files is
config's own business, and the blueprint cache reads it from here rather than
deriving the same root again.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QCJ1v1NFc6b43GooAhij2c
Seam is not said internally unless it has to be, and the keys are read by this one file, so a constant for each was a name to look up rather than a literal to read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QCJ1v1NFc6b43GooAhij2c
main's #618 gives login a token rather than options, and resolves a flag over the environment over what is stored. Both are taken as they are; what changes is that the reads and writes underneath them are method calls. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QCJ1v1NFc6b43GooAhij2c
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.
Summary
Storing a value meant knowing the key it lives under. Callers wrote
config.delete('current_workspace_id')andconfig.set(`${auth.endpoint}.pat`, token), and the three writes that always go together needed astoreEndpointhelper to keep them together.The config now answers in the CLI's own terms:
Every key lives in
config/values.tsand is read byconfig/seam-config.tsalone. Nothing else in the CLI names one.What moved
config/seam-config.ts—SeamConfig, over anyConfigStore. The rules that were spread across callers live here: tokens are keyed per endpoint;getEndpointfalls back to the legacyserverkey;setEndpointdrops that key and the workspace that belonged to the old endpoint;unsetTokenalso drops the un-namespaced token an older CLI wrote.getConfigStore→getConfig— what the CLI holds is its configuration, not a key/value store.ConfigStorestays as the storage underneath, whichPersistentConfigStoreand the memory store implement.context.ts—resolveAuthreads three methods, and itsreadStringmoves into the config, which is the only place that needs it.auth/operations.ts— every write is a method call, andstoreEndpointis gone: what it did belongs tosetEndpoint.rootPaths—seamPathsmoves into the config module. Where the CLI keeps its files is config's business, andblueprint/source-npm.tsreads the cache directory from there rather than deriving the same root a second time.Tests
test/auth/operations.test.tsandtest/context.test.tsbuild acreateMemoryConfig()and assert through the same methods, so they no longer restate the storage layout.Two assertions deliberately still reach for the store, because what they check is invisible above it: that logging out drops an un-namespaced token, and that selecting an endpoint drops the legacy key. Those tests construct
createSeamConfig(createMemoryConfigStore(…))and assert on the store.157 tests pass.
Generated by Claude Code