Summary
The global --output flag is validated inconsistently across command groups. test and project reject an unrecognised value with a typed VALIDATION_ERROR (exit 5), but auth, usage, agent, and init silently coerce anything that isn't json/text to text mode via globals.output ?? 'text'.
Why it matters
The CLI's primary consumer is a coding agent. If an agent asks for --output json but mistypes it (--output josn), four of the six command groups hand back a human-readable text payload, exit 0, and the agent's JSON.parse fails downstream with no signal as to the cause.
Reproduction
$ testsprite --output josn agent list # silently prints a text table, exits 0
$ testsprite --output josn test list ... # correctly exits 5 with a clear error
Expected: every command group rejects an invalid --output value with exit 5 and an actionable message.
Secondary issue
Even among the commands that do validate, the wording diverges:
test: Flag `--output` is invalid: must be one of: json, text.
project: --output must be one of: json, text
These should be unified.
Suggested fix
Extract a shared resolveOutputMode(raw): OutputMode helper in src/lib/output.ts that returns 'text' for an omitted flag and throws localValidationError('output', 'must be one of: json, text', ['json','text']) otherwise, then route every command group's resolveCommonOptions through it.
I have a PR ready for this.
Summary
The global
--outputflag is validated inconsistently across command groups.testandprojectreject an unrecognised value with a typedVALIDATION_ERROR(exit 5), butauth,usage,agent, andinitsilently coerce anything that isn'tjson/textto text mode viaglobals.output ?? 'text'.Why it matters
The CLI's primary consumer is a coding agent. If an agent asks for
--output jsonbut mistypes it (--output josn), four of the six command groups hand back a human-readable text payload, exit0, and the agent'sJSON.parsefails downstream with no signal as to the cause.Reproduction
Expected: every command group rejects an invalid
--outputvalue with exit 5 and an actionable message.Secondary issue
Even among the commands that do validate, the wording diverges:
test:Flag `--output` is invalid: must be one of: json, text.project:--output must be one of: json, textThese should be unified.
Suggested fix
Extract a shared
resolveOutputMode(raw): OutputModehelper insrc/lib/output.tsthat returns'text'for an omitted flag and throwslocalValidationError('output', 'must be one of: json, text', ['json','text'])otherwise, then route every command group'sresolveCommonOptionsthrough it.I have a PR ready for this.