Mark omittable CLI inputs as optional in structured help - #6960
Conversation
🦋 Changeset detectedLatest commit: 21fadc8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
This PR currently contains only the failing reproduction tests. The title says it should mark omittable inputs as optional, so the implementation fix is still needed before this can merge.
Reviewed changes
packages/effect/test/unstable/cli/Help.test.ts: two new focused tests asserting thatFlagDoc.requiredandArgDoc.requiredarefalsefor an optional flag and a zero-minimum variadic argument.
I ran the reproduction tests locally and they fail as expected (AssertionError: expected true to be false). The failures are caused by packages/effect/src/unstable/cli/internal/command.ts: buildHelpDoc checks metadata.isOptional alone, and toFlagDoc checks single.primitiveType._tag !== "Boolean", both ignoring optionality wrappers and defaults.
⚠️ Implementation fix still missing
A minimal fix should change two locations in packages/effect/src/unstable/cli/internal/command.ts:
- In
buildHelpDoc, derive each positional arg'srequiredfromParam.getParamMetadata(param)(already computed) so that a zero-minimum variadic arg is not required and an optional arg is not required. - In
toFlagDoc, use the flag's metadata instead of the underlyingSingle.paramprimitive type: a flag wrapped inOptional(which includesFlag.withDefault, becausewithDefaultbuilds onoptional) should reportrequired: false.
Since toFlagDoc is only called from buildHelpDoc, passing the metadata alongside the Single is straightforward. If you change its signature, make sure the helper is not left with stale logic.
⚠️ No changeset
This is a user-facing behavior change in the effect package, so a .changeset/ entry should be added alongside the fix.
ℹ️ Nitpick
- Consider adding similar assertions for
Flag.withDefaultandArgument.withDefault; the PR description calls out defaults as another incorrect "required" case, and the same metadata-based fix will cover them.
@v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The follow-up commit 21fadc87 adds the missing implementation fix and changeset requested in the prior review.
- Fixed
ArgDoc.requiredinbuildHelpDocso optional args and zero-minimum variadic args are reported as not required. - Fixed
FlagDoc.requiredby updatingtoFlagDocto accept param metadata and combine the boolean-type exemption withmetadata.isOptional. - Updated shared/global flag help generation in
help.tsto pass metadata totoFlagDoc. - Added the
.changeset/kind-flags-help.mdpatch entry foreffect. - Existing reproduction tests now cover
Flag.withDefaultandArgument.withDefaultas well.
Validation run: focused Help.test.ts, full packages/effect/test/unstable/cli suite (308 tests), pnpm lint-fix, and pnpm check all pass.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
Structured help reports optional non-boolean flags and zero-minimum variadic arguments as required.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Structured help marks omittable inputs required
Module:
cli/internal/commandAudit ID:
unstable-ai-cli-help-omittable-inputs-requiredSeverity / confidence: medium / high
What happens
Structured help reports optional non-boolean flags and zero-minimum variadic arguments as required.
Why it happens
Flag requiredness checks only primitive type, and argument requiredness checks only isOptional while ignoring defaults and repetition minima.
Expected behavior
FlagDoc.required and ArgDoc.required indicate whether the corresponding input must be provided.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/unstable/cli/internal/command.ts:134-167packages/effect/src/unstable/cli/internal/command.ts:236-244View problematic code at
packages/effect/src/unstable/cli/internal/command.ts:134-167View exact lines on GitHub
View problematic code at
packages/effect/src/unstable/cli/internal/command.ts:236-244View exact lines on GitHub
Reproduction
pnpm test --run packages/effect/test/unstable/cli/HelpRequired.audit.test.tsObserved failure: FAIL: both omittable inputs reported required true.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm test --run packages/effect/test/unstable/cli/HelpRequired.audit.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715funstable-ai-cli-help-omittable-inputs-requiredCloses EFF-406