Skip to content

fix(cli): config --help example generated from the live schema, rot-proofed by test - #146

Open
plombeer31 wants to merge 1 commit into
mainfrom
valeryb/config-example-true
Open

fix(cli): config --help example generated from the live schema, rot-proofed by test#146
plombeer31 wants to merge 1 commit into
mainfrom
valeryb/config-example-true

Conversation

@plombeer31

Copy link
Copy Markdown
Collaborator

What

The config --help example was hand-written long ago and no longer runs:
it says "version":1 (supported versions start at 5, so config set rejects it
outright) and configures a llama key that was renamed to localModels back in
config v5. Anyone pasting the official example got a validation error.

The example is now assembled at module load from the live schema constants —
USER_CONFIG_VERSION and a localModels.url override — so it can never say a
version the parser refuses. The help also states the actual set semantics: keys
left out of the payload are filled with defaults, and the result is validated
before anything is written.

Rot-proofing

The new test does not check the example against a copy of itself — it extracts the
payload straight out of the rendered help text with a regex and feeds it through
the real config set path against a temp state dir, then asserts the written
file carries the values the example promises. If the schema moves and the help is
left behind again, this test fails instead of a user's paste.

Verified the test fails against the previous help text (no extractable valid
payload) and passes with the generated one.

Testing

  • npm run lint (tsc) clean
  • npx vitest run src/cli/config-command.test.ts — 9/9 (8 existing + the new rot-proofing test)

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.

1 participant