fix(cli): refuse csv and tsv formats on --llms, --llms-full, and --schema (#11778)

* fix(cli): refuse csv and tsv formats on --llms, --llms-full, and --schema

* fix(cli): validate discovery row-format refusals at the shared output boundary
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 16:30:51 -05:00
1 parent e44f0077c9
commit ab904c793c
3 files changed
+79 -3

No files matched your search

+24 -1
View File
@@ -221,7 +221,7 @@ export const readCliOutputArguments = (
};
return {
...controls,
validation: validateCliOutputControls(controls, rootVersion),
validation: validateCliOutputControls(controls, rootVersion, global),
versionReportFormat:
rootVersion &&
versionEligible &&
@@ -240,6 +240,20 @@ export const readCliOutputArguments = (
export const missingCliOutputValueMessage = (flag: string): string =>
`${flag} requires a value, as in ${flag} <value> or ${flag}=<value>.`;
const discoveryRowFormatFlag = (
global: CliGlobalArguments,
): "--llms" | "--llms-full" | "--schema" | undefined => {
const { command, flags } = global;
const help = flags.has("--help") || flags.has("-h");
if ((flags.has("--update") && !help) || flags.has("--mcp")) return undefined;
if (flags.has("--llms-full")) return "--llms-full";
if (flags.has("--llms")) return "--llms";
if (flags.has("--version") && !help) return undefined;
if (command.length === 0 || help) return undefined;
if (flags.has("--schema")) return "--schema";
return undefined;
};
/** Reject output controls that cannot safely produce a complete result. */
const validateCliOutputControls = (
{
@@ -253,6 +267,7 @@ const validateCliOutputControls = (
tokenCount,
}: CliOutputControls,
rootVersion: boolean,
global: CliGlobalArguments,
): CliOutputArgumentValidation => {
if (invalidValue !== undefined)
return {
@@ -279,6 +294,14 @@ const validateCliOutputControls = (
code: "MISSING_OUTPUT_VALUE",
message: missingCliOutputValueMessage(missingValue),
};
const discoveryFlag = delimited ? discoveryRowFormatFlag(global) : undefined;
if (delimited && discoveryFlag !== undefined)
return {
ok: false,
format: "json",
code: "UNSUPPORTED_OUTPUT_COMBINATION",
message: `${discoveryFlag} returns a complete document and does not support --format ${format}. Use --format json, yaml, md, toon, or jsonl; CSV/TSV output is available only for selected row collections.`,
};
if (delimited && rootVersion)
return {
ok: false,