Skip to content

Fix the single-dash -force flag the README documents - #12

Merged
g4lb merged 2 commits into
mainfrom
fix/force-flag-parse
Sep 15, 2026
Merged

g4lb merged 2 commits into
mainfrom
fix/force-flag-parse

Conversation

@g4lb

@g4lb g4lb commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

README.md's agent prompt says "I may run autor3search-javascript stop -force myself". It failed with Unknown option '-f' — in 0.2.2 and every release before it. baseline -force was broken the same way, and nothing had noticed either.

Root cause

Node's parseArgs accepts a single dash only for a single-character name, so this harness rewrites the documented spellings before parsing. That rewrite was driven by a list of names written out by hand beside the declaration, and the list had drifted: cmd-stop.js passed ['tag'] and never mentioned force.

Why the obvious fix is wrong

Adding 'force' to the list trades the bug for a quieter one. expandSingleDashFlags set expectingValue = true after every match, because it was built for value-taking flags:

naive fix, force alone:      ["--force"]                 ok
naive fix, force then tag:   ["--force","-tag","t"]      -tag swallowed as force's "value"

So stop -force -tag t would have died on Unknown option '-t'.

The fix

Derive the expandable set from the parseArgs options the command already declares, and consume a following token only when type !== 'boolean'. The four call sites hoist options to a const and pass it to both the expander and the parser, so the two can no longer disagree — a flag cannot be documented, declared, and still unparseable.

Every single-dash spelling in README.md and templates/program.md was enumerated and checked to parse: stop -force, stop -tag, eval -desc, baseline -tag, status -tag, and baseline -force -tag.

Worth knowing

-force was inert in an agent's hands before this, because it simply errored. It works now, so program.md's standing rule against passing it is load-bearing where it previously guarded nothing.

485/485 passing locally (480 + 5 new: two unit tests covering the boolean-ordering trap, two CLI tests covering the spelling a human types, one for -tag/-force in either order).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FV5Usy3xLiz4ngEp6zPC5L

g4lb and others added 2 commits September 15, 2026 11:27
The README's agent prompt says "I may run `autor3search-javascript stop
-force` myself". That failed with "Unknown option '-f'". parseArgs takes a
single dash only for a single-character name, so the harness rewrites the
documented spellings first — but the rewrite was driven by a list of names
written out by hand next to the declaration, and that list had drifted:
`stop` passed ['tag'] and never mentioned force. `baseline -force` was
broken the same way, and nothing had noticed either.

Passing the parseArgs options themselves removes the gap a hand-kept list
leaves open. A flag can no longer be documented, declared, and still
unparseable, because the thing that expands it and the thing that parses it
are now one object.

Consuming the following token is decided by the declared type rather than
assumed. Booleans take no value, so the token after one is another flag and
must still be expanded: adding 'force' to the old list would have made
`stop -force -tag t` fail on "Unknown option '-t'" instead, trading the bug
for a quieter one. Single-character names are left alone, since parseArgs
already accepts `-C`.

Worth knowing: -force was inert in an agent's hands before this, because it
simply errored. It works now, so program.md's standing rule against passing
it is load-bearing where it previously guarded nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FV5Usy3xLiz4ngEp6zPC5L
`stop -force`, which the README's agent prompt tells you to run, failed with
"Unknown option '-f'" in 0.2.2 and every release before it. So did
`baseline -force`. Both parse now, and the single-dash spellings are derived
from the option declarations rather than a list kept by hand beside them, so
a documented flag cannot go unparseable again without a test noticing.

No behaviour changes anywhere else. Windows support and the marker-based
stop path shipped in 0.2.2 are untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FV5Usy3xLiz4ngEp6zPC5L
@g4lb
g4lb merged commit 11c43af into main Sep 15, 2026
6 checks passed
@g4lb
g4lb deleted the fix/force-flag-parse branch September 15, 2026 10:17
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