Repository navigation
cmd: aipocket config add prints a config entry instead of writing one - #35
Merged
Merged
Conversation
The natural request is a command that saves your key. Two decisions refuse exactly that, and this is the half that survives both — which is worth having, because what it removes is not typing but two ways of being wrong. It does not write the file. Loading that YAML and marshalling it back drops its comments, and the comments are where the reason for each entry lives; appending is not an escape hatch, because strict loading refuses a second `providers:` key, so an append is a merge and a merge is an edit. So the output is text to paste, and the printed tail says that nothing was written and where the entry goes if a `providers:` block already exists. It never asks for the key. A key given as an argument is in the shell history and in the process arguments before it reaches any file, and a key stored under `key:` would turn the one file that promises to hold no secrets into one that does — with `providers`, `--json`, `audit` and every MCP result printing a value that was never resolved as a secret and so was never registered with the redactor. What it adds over typing two lines by hand: the provider id comes from the registry, so it cannot be the typo `ValidateAgainst` exists to catch, and the spec is checked by the same `secret.Parse` the loader applies, so a spec accepted at the prompt is one the next run accepts. A pasted key is refused at the prompt rather than on the next load, and `Parse`'s refusals already explain themselves without reproducing what was typed — which is what a prompt that may have just received a key needs. It is the ending of `aipocket probe` moved to the front of the job: probe prints a manifest block to paste, this prints a config block. Every prompt is bounded and an exhausted stdin ends the run. The command reads a pipe as readily as a terminal, so a wrong answer in a script has to become an exit code rather than a loop nothing will answer. No request is made, no credential resolved and no `command:` helper run, so `aipocket audit` is unchanged: the rule that every new network call appears in audit is met by there being none. Closes #34. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #34.
aipocket config add [provider]lists the providers this build knows, asks which of thethree credential forms the key comes from, and prints the config entry to paste. It writes
nothing, and it never receives the key — the two restrictions are the design, not an
unfinished first version.
Why it prints rather than writes. Marshalling that YAML back would drop its comments,
and the comments are where the reason for each entry lives. Appending is not an escape
hatch: strict loading refuses a second
providers:key, so an append is a merge and a mergeis an edit.
Why it never asks for the key. A key given as an argument is in the shell history and in
the process arguments before it reaches any file, and a key under
key:would turn the onefile that promises to hold no secrets into one that does — with
providers,--json,auditand every MCP result printing a value that was never resolved as a secret and so wasnever registered with the redactor.
What it adds over typing two lines by hand is the part worth having: the provider id comes
from the registry, so it cannot be the typo
ValidateAgainstexists to catch, and the specis checked by the same
secret.Parsethe loader applies — so a spec accepted at the promptis one the next run accepts, and a pasted key is refused at the prompt instead of on the
next load.
aipocket auditis unchanged: this makes no request, resolves no credential and runs nocommand:helper.Also updated: the non-goal paragraph in CLAUDE.md (so this does not read as contradicting
it), the README configuration section, and
config.example.yaml.Tests
cmd/aipocket/configadd_test.go, all four verified to fail before the change:TestConfigAddPrintsAnEntryToPasteAndWritesNothing— the config file is byte-identicalafter the run, comments included.
TestConfigAddPicksTheProviderTheRegistryLists— number and id reach the same provider,an empty answer at the
env:prompt means the conventional variable, unknown id exits 2.TestConfigAddRefusesAPastedKeyWithoutEchoingIt— exits 2, the key appears nowhere in theoutput, and no block is printed anyway.
TestConfigAddWithNoAnswersIsAUsageErrorNotAHang— every prompt is bounded, so a pipecannot hang it.
🤖 Generated with Claude Code