Repository navigation
feat(core,config): name where a missing required flag can be set - #811
chenxin-yan wants to merge 3 commits into
Conversation
`Missing required flag "--server"` named neither the environment variable
nor the config file a person would set it in.
- core: the message is followed by the flag's `env` variables:
`Missing required flag "--token": set $APP_TOKEN`.
- core: a `defaults` hook may return `hints: { args?, flags? }`, places
where a value it could not supply may be set. Core names them only in
the error for a required argument or flag still missing at validation,
after the variables. Hints bind nothing and leave `sources` unchanged.
- config: the `defaults` hook returns `"<key>" in <file>` for each config
flag no file gave, naming every file that may hold the key. `get()`'s
error is built by the same helper, so a `both` setting now names the
project file as well as the user's.
The text is in the error itself, so it is the same under `execute()`,
`--json`, typed `run()` and MCP.
…up's variables Review findings: - A required list flag given empty on argv or through run() kept the suffix, though no variable or stored value applies to a flag that was given. - A required exclusive group named none of its members' variables. - config hints only for required flags; config.get()'s error loses its trailing period, as the flag's error has none; config's bump is a patch. - Tests for the prototype-member guard; the json() duplicate is dropped.
🧠 Consumer type performanceBase: 9598b12 · PR merge: 91c7cb4
Check-time scaling (400 ÷ 200 commands): base 2.19× · PR merge 2.17× TypeScript 7.0.2 · |
📦 Package sizeBundle cost (per entrypoint, minified + gzip)
Consumer bundles (minified + gzip)Fixture apps from
Install size (
|
| Package | Tarball | Unpacked | Δ unpacked | Runtime footprint | Δ footprint |
|---|---|---|---|---|---|
@crustjs/auth |
42.70 KB | 152.46 KB | ±0 | 317.84 KB | ±0 |
@crustjs/completion |
25.70 KB | 82.86 KB | ±0 | 82.86 KB | ±0 |
@crustjs/config |
10.31 KB | 31.45 KB | +0.40 KB (+1.3%) | 196.84 KB | +0.40 KB (+0.2%) |
@crustjs/core |
117.92 KB | 438.12 KB | +1.90 KB (+0.4%) | 512.31 KB | +1.90 KB (+0.4%) |
@crustjs/create |
9.29 KB | 29.95 KB | ±0 | 104.14 KB | ±0 |
@crustjs/effect |
5.55 KB | 16.06 KB | ±0 | 16.06 KB | ±0 |
@crustjs/env |
4.03 KB | 9.67 KB | ±0 | 9.67 KB | ±0 |
@crustjs/extensions |
31.06 KB | 99.77 KB | ±0 | 444.66 KB | ±0 |
@crustjs/man |
4.51 KB | 11.33 KB | ±0 | 11.33 KB | ±0 |
@crustjs/mcp |
10.05 KB | 32.13 KB | ±0 | 106.32 KB | ±0 |
@crustjs/openapi |
45.77 KB | 151.15 KB | ±0 | 225.34 KB | ±0 |
@crustjs/progress |
7.50 KB | 21.91 KB | ±0 | 164.08 KB | ±0 |
@crustjs/prompts |
30.13 KB | 111.54 KB | ±0 | 253.70 KB | ±0 |
@crustjs/skills |
22.36 KB | 77.13 KB | ±0 | 352.75 KB | ±0 |
@crustjs/store |
25.03 KB | 91.19 KB | ±0 | 165.39 KB | ±0 |
@crustjs/style |
19.84 KB | 67.97 KB | ±0 | 67.97 KB | ±0 |
@crustjs/testing |
5.64 KB | 15.64 KB | ±0 | 15.64 KB | ±0 |
@crustjs/tui |
2.97 KB | 6.90 KB | ±0 | 6.90 KB | ±0 |
@crustjs/utils |
26.69 KB | 74.19 KB | ±0 | 74.19 KB | ±0 |
There was a problem hiding this comment.
ℹ️ Approved with three non-blocking findings about empty lists and input precedence.
Approach: Formatting hints during required-value validation lets prompts and later defaults satisfy the value before Core reports an error.
Reviewed changes cover the extension contract, parser, config integration, docs, and changeset. All 321 tests across the three affected test files passed.
- Core collects hints in extension order and adds them to missing-value errors alongside applicable environment variable names, including those of visible exclusive-group members.
- Config shares the file-location formatter between
config.flag()andconfig.get(), preserving the setting’s file key when the CLI flag has a different name.
Non-blocking
- An explicit empty variadic argument advertises an ineffective fix. With
run([], { args: { files: [] } }), the error suggests setting the saved profile. I populated the profile and reran the same call. It still failed because the explicit array wins. Suppress the stored hint when the caller supplied the empty argument, and keep it when the caller omittedfiles. Argument validation - An empty extension default hides a working environment override. With a required repeatable
tagsflag and a defaults hook returningflags: { tags: [] }, the error omits$TAGS. SettingTAGS=validmakes the same invocation succeed. Keep the environment hint when the defaults hook supplied the empty list. Flag source check - An empty first environment variable can mask an advertised fallback. For a comma-delimited required list with
env: ["PRIMARY", "SECONDARY"],PRIMARY="" SECONDARY=validstill reportsset $PRIMARY or $SECONDARY. The resolver selectsPRIMARYbefore splitting it. In this case the diagnostic should tell the user to populatePRIMARYor unset it to useSECONDARY. Environment hint formatting
gpt-6.2-astra | 𝕏
There was a problem hiding this comment.
All reported issues were addressed across 12 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Bot review findings (Greptile, cubic, Pullfrog): run([], { args: { files: [] } })
still suggested a stored value, which cannot replace a supplied one. The
argument check now reads its source as the flag check does. Docs: the hints
example states the flag's env, and config says an actionless command names
only the variables.
|
Review findings handled in commit
Opened by an AI agent on behalf of @chenxin-yan. |
There was a problem hiding this comment.
ℹ️ No blocking issues. One case still hides a working profile hint.
Reviewed changes since 82535c3 cover required variadic arguments and the documentation for missing-value hints. All 265 tests in the command and parser suites passed.
- Distinguished omitted arguments from explicit empty lists. The regression test confirms that
run([])shows the stored-value hint andrun([], { args: { files: [] } })suppresses it. - Clarified the documentation. The extension example identifies where
$ACME_REGIONcomes from, and the config guide explains why commands without an action show only environment variables.
Non-blocking
- An empty list from a later defaults hook hides an effective hint. With a profile hook first and a fallback hook returning
args: { files: [] }second,run([])reported onlyMissing required argument "<files>". Populating the profile with["a.txt"]made the same invocation succeed. Preserve hints from earlier hooks that can supply the argument while keeping them suppressed for an explicit caller-supplied[]. Argument validation
gpt-6.2-astra | 𝕏

Summary
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.envvariables, for any flag. Adefaultshook may returnhints: { args?, flags? }; Core uses them only for a required value still missing at validation. A flag with neither keeps its message.defaultshook returns"<key>" in <file>for each required config flag no file gave, through one helper shared withconfig.get(), which now names both files for a key either may hold.execute(),--json, typedrun()and MCP. A check in anonErrorhook would not be:run()does not call those, and MCP usesrun().Evidence
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 …) andprompts()asking first on a terminal-like run.pnpm run check0,pnpm run check:types0,RUNNER_TEMP=$(mktemp -d) pnpm run test0 (226 files, 4170 passed).defaultsresult 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 runningdefaultshooks, 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
defaultshooks. Config errors name each file that may hold the 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]Reviews (2) · Last reviewed commit: "fix(core): name no place for a required ..." · Reviewed by Greptile