Skip to content

cmd: aipocket config add prints a config entry instead of writing one - #35

Merged
naturalmoods merged 1 commit into
mainfrom
config-add
Aug 18, 2026
Merged

naturalmoods merged 1 commit into
mainfrom
config-add

Conversation

@naturalmoods

Copy link
Copy Markdown
Owner

Closes #34.

aipocket config add [provider] lists the providers this build knows, asks which of the
three 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.

$ aipocket config add deepseek

  deepseek — where should AIPocket read the key from, at every run?

   1) env      an environment variable (conventional name: DEEPSEEK_API_KEY)
   2) command  ask a secret manager you already have: op, pass, bw, security…
   3) file     a file holding the key, which must be chmod 600

  source (1-3): 2
  command (e.g. op read op://Private/deepseek/credential): op read op://Private/DeepSeek/credential

  Add this to /home/…/.config/aipocket/config.yaml:

    providers:
      deepseek:
        key: command:op read op://Private/DeepSeek/credential

  Nothing was written — AIPocket does not edit your config. If that file
  already has a `providers:` block, put the entry under it: YAML refuses the
  same key twice, and a duplicate is a load error rather than a merge.

  The key itself is not stored anywhere by AIPocket: it is resolved at every
  run from command op.

  Then: aipocket deepseek
  By hand: https://platform.deepseek.com/usage

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 merge
is 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 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 is the part worth having: 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, and a pasted key is refused at the prompt instead of on the
next load.

aipocket audit is unchanged: this makes no request, resolves no credential and runs no
command: 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-identical
    after 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 the
    output, and no block is printed anyway.
  • TestConfigAddWithNoAnswersIsAUsageErrorNotAHang — every prompt is bounded, so a pipe
    cannot hang it.

🤖 Generated with Claude Code

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>
@naturalmoods
naturalmoods merged commit c3dc088 into main Aug 18, 2026
5 checks passed
@naturalmoods
naturalmoods deleted the config-add branch August 18, 2026 18:55
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.

aipocket config add: pick a provider, name a credential source, print the entry to paste

1 participant