The error for a missing required flag now says where its value can be set. Before, a required setting taken with config.flag() named neither its environment variable nor its config file.
$ cy status # "server" from config.flag(), env CY_SERVER, nothing configured
-Error: Missing required flag "--server"
+Error: Missing required flag "--server": set $CY_SERVER or "server" in /home/me/.config/cy/config.json
dispatch
defaults hooks # config: file values, plus hints for required flags no file gave
collect defaults.hints # only when a hook returns some
preRun hooks # prompts() may still ask for the value
validateParsed(node, bound, hints)
missing required flag -> message + ": set " + env variables + hints
Core: the message names the flag's env variables, for any flag. A defaults hook may return hints: { args?, flags? }; Core uses them only for a required value still missing at validation. A flag with neither keeps its message.
Config: its defaults hook returns "<key>" in <file> for each required config flag no file gave, through one helper shared with config.get(), which now names both files for a key either may hold.
The message is the same under execute(), --json, typed run() and MCP. A check in an onError hook would not be: run() does not call those, and MCP uses run().
Evidence
Before:Missing required flag "--server" (exit 2). After: the messages above; an independent reviewer ran each documented case, including MCP over an in-memory transport (VALIDATION: Missing required flag "--server": set $CY_SERVER or "server" in …) and prompts() asking first on a terminal-like run.
New tests were red against the old sources. The reviewer's mutations (dropping hint collection, dropping config's hint, swapping file order) each fail a test.
pnpm run check 0, pnpm run check:types 0, RUNNER_TEMP=$(mktemp -d) pnpm run test 0 (226 files, 4170 passed).
Cost in every CLI: one check per defaults result on the success path; a minified one-flag CLI grows by 297 bytes (146 gzip).
Review findings fixed in the second commit: no suffix for a required list given empty (--tags ""), which no variable can fill; a required exclusive group names its listed members' variables; config builds hints only for required flags; config.get()'s error loses its trailing period; config's bump is a patch.
Not verified: the docs site build; Windows paths in the hint; MCP over stdio.
Merge Danger
Door: two-way
Blast Radius: messages
Error text changes for every required flag that has env, so a downstream test that asserts the whole message will fail. Missing required flag "--name" stays as the prefix. config.get()'s message changes too (both files, no trailing period). Known gap: a command without an action is validated without running defaults hooks, so it shows only the variables.
Opened by an AI agent on behalf of @chenxin-yan.
Confidence Score: 5/5
The PR appears safe to merge; the previous finding is fixed and no new actionable issues remain.
Summary
Missing required values now name their environment variables and places suggested by defaults hooks. Config errors name each file that may hold the setting.
Missing required-value errors point to places that can supply the value.
Config-backed errors name the files that may hold a missing setting.
Diagram
%%{init: {'theme': 'neutral', 'htmlLabels': false}}%%
flowchart TD
A[defaults hooks] --> B[Collect values and hints]
B --> C[preRun hooks may supply values]
C --> D{Required value missing?}
D -->|No| E[Run action]
D -->|Yes| F{Value explicitly supplied?}
F -->|Yes, empty list| G[Error without hints]
F -->|No| H[Error names variables and hints]