Repository navigation
fix(cli): --no-publish stops the auto-publish attempt (#404) - #417
Merged
Merged
Conversation
citty turns --no-publish into publish: false and never sets the declared no-publish arg, so args["no-publish"] was always undefined and a signed-in run published anyway. Read negated flags from rawArgs through new cli/flags.ts helpers (hasNegatedFlag, hasFlag), and refuse --publish/-p next to --no-publish in any order: citty's parsed publish value depends on argv order once both are passed. Tests drive the flags through citty's real parser: a wiring test runs the audit command via runCommand with raw argv against a stubbed API (control publishes, --no-publish makes no /v1/reports call, the pair is refused before any request), and the helpers are checked against citty's own parse of the audit args. Closes #404 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/no-publish-404
branch
from
September 30, 2026 00:42
2c90a65 to
9d25f81
Compare
nc9
marked this pull request as ready for review
September 30, 2026 00:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #404
What was wrong
citty (0.1.6, and 0.2.x) turns any
--no-Xtoken intoX: falseand never sets a declared"no-X"arg.squirrel auditreadargs["no-publish"], which was alwaysundefined, so a signed-in run auto-published anyway (or printed "Could not auto-publish" when the API call failed, as in the issue).Passing both forms was also broken. Once both are in argv, citty's
publishvalue depends on their order:--publish --no-publishgivesfalse,--no-publish --publishgives[false, true], and-p --no-publishgivestrue. None of these hit the "cannot be combined" error, and every one ignored--no-publish.Fix
apps/cli/src/cli/flags.tswithhasNegatedFlag(rawArgs, name)andhasFlag(rawArgs, name, aliases). Both read citty'srawArgsfrom the command context, tokenized the way citty does it (stops at--; dash-led tokens are always flags, never values; single-dash clusters). The header comment covers the citty behaviour. The pattern for any--no-*flag: declare it for help and completions, then read it withhasNegatedFlag, never fromargs.audit.ts:noPublishcomes fromhasNegatedFlag(rawArgs, "publish")and feeds all threeresolvePublishDecisioncalls. When--no-publishis present,validateAuditFlagsalso counts any--publish/-ptoken in argv, so the pair errors in every order. Without--no-publishthe parsed value is used as before, so--offline --publish=falseis still valid.validateAuditFlagstakes onenoPublishkey (theno_publishspelling is gone).Other
no-*flagsrg -n '"no-' apps/cli/srcfinds onlyaudit'sno-publish.--no-incrementalworks: nothing declaresno-incremental, and the code readsargs.incremental.squirrel crawlhas no publish flag and never publishes, so it needs no change.Tests
tests/commands/audit-no-publish-wiring.test.tsruns the realauditcommand throughcitty.runCommandwith raw argv, signed in with a fake token and a stubbed fetch. The control (no flag) sendsPOST /v1/reportsand shows the warning.--no-publishsends no/v1/reportsrequest and shows no warning. All four pair orders exit 1 with the error before any request.--offline --publish=falsestill runs. The test fails onmain: 5 of 6 cases.tests/cli/flags.test.tspins citty's parse (no-publishis never set) and checks everyhasFlagcase against citty's own parse of the audit args.squirrel audit https://example.com/ -m 1with a scratch HOME andSQUIRREL_API_SERVERpointed at a local stub that records requests. Before the fix,--no-publishsentPOST /v1/reports. After it,--no-publishsends onlyGET /v1/creditsandPOST /v1/agent-runs/register: run registration is by design, and the code comments say--no-publishstill registers the run. The control still publishes.Docs already describe the intended behaviour (
--publishand--no-publishcannot be combined), so they are unchanged.