{"record":{"id":"ab425c5dbe9b13b7","repo":"JuliusBrussee/caveman","slug":"usage-invokedcommand-compress-type-cont","errorCode":null,"errorMessage":"usage: ${invokedCommand(\"compress\")} [--type <content-type>] [--toon]","messagePattern":"usage: (.+?) \\[--type <content-type>\\] \\[--toon\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/index.ts","lineNumber":13299,"sourceCode":"  const path = mcpServerMarkerPath(agentId, serverName);\n  durableAtomicWriteFile(path, mcpMarkerBytes(mcp, tool));\n}\n\n// compress streams stdin through the caveman-engine binary (resolved via\n// CAVEMAN_ENGINE_BIN, default `caveman-engine` on PATH) and writes the compressed\n// payload to stdout, forwarding the engine's JSON ratio report to stderr. The\n// engine is fail-closed; if its binary is unavailable the CLI falls back to a\n// pass-through that claims a 0 ratio, so `compress` never breaks a pipe.\nasync function compress(argv: string[]) {\n  if (argv[0] === \"catalog\") return compressCatalog(argv.slice(1));\n  if (argv.includes(\"--toon-stats\")) {\n    throw new Error(\"caveman compress --toon-stats is unavailable; use --toon to force TOON compression\");\n  }\n  const input = await readStdin();\n  const bin = cavemanBin(\"caveman-engine\", \"CAVEMAN_ENGINE_BIN\");\n  const typeIndex = argv.indexOf(\"--type\");\n  if (typeIndex >= 0 && (argv[typeIndex + 1] === undefined || argv[typeIndex + 1]!.startsWith(\"--\"))) {\n    throw new Error(`usage: ${invokedCommand(\"compress\")} [--type <content-type>] [--toon]`);\n  }\n  let forcedType = argv.includes(\"--toon\") ? \"toon\" : flagFrom(argv, \"--type\", \"\");\n  if (forcedType === \"auto\") forcedType = \"\";\n  const engineArgs = [\"compress\"];\n  if (forcedType) engineArgs.push(\"--type\", forcedType);\n  let handled = false;\n  const child = spawn(bin, engineArgs, { stdio: [\"pipe\", \"inherit\", \"inherit\"] });\n  emitCommandRunOnce(\"ok\"); // exit handler below hard-exits; never returns to main()\n  child.on(\"error\", () => { if (!handled) { handled = true; compressFallback(input, forcedType); } });\n  child.on(\"exit\", (code) => { if (!handled) { handled = true; process.exit(code ?? 0); } });\n  if (child.stdin) {\n    child.stdin.on(\"error\", () => {}); // ignore broken pipe; the child 'error' drives the fallback\n    child.stdin.end(input);\n  }\n}\n\n// compressCatalog is explicit bridge to dedicated tool-catalog product. It\n// preserves caveman-shrink's stdin/stdout/report contract and forwards lint /","sourceCodeStart":13281,"sourceCodeEnd":13317,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L13281-L13317","documentation":"Usage error: the `--type` flag for `caveman compress` was given without a following value (end of argv or another flag). The CLI throws the canonical usage string, including the actual invoked command name.","triggerScenarios":"`caveman compress --type` (missing value) or `caveman compress --type --toon` (next token is a flag).","commonSituations":"Truncated shell scripts; variable expansion producing an empty value ($TYPE unset); copy-paste dropping the content type.","solutions":["Provide a value after --type, e.g. --type application/json","Set the variable used in the script (e.g. TYPE=application/json)","Drop --type entirely to rely on --toon or default handling"],"exampleFix":"// before\ncaveman compress --type\n// after\ncaveman compress --type application/json","handlingStrategy":"validation","validationCode":"const i = argv.indexOf('--type');\nif (i >= 0 && (!argv[i+1] || argv[i+1].startsWith('--'))) throw new Error('--type requires a value');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote and default shell variables used as flag values (${TYPE:?})","Smoke-test compress commands in CI"],"tags":["cli","usage","argument-parsing"],"backgroundTag":"missing-required-argument","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}