{"record":{"id":"3cc4b38bdbb17f1c","repo":"JuliusBrussee/caveman","slug":"caveman-compress-toon-stats-is-unavailable-use","errorCode":null,"errorMessage":"caveman compress --toon-stats is unavailable; use --toon to force TOON compression","messagePattern":"caveman compress --toon-stats is unavailable; use --toon to force TOON compression","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/index.ts","lineNumber":13293,"sourceCode":"\nfunction writeMcpMarker(agentId: string, mcp: { command: string; args: string[] }): void {\n  writeMcpServerMarker(agentId, \"caveman\", mcp, \"caveman_retrieve\");\n}\n\nfunction writeMcpServerMarker(agentId: string, serverName: string, mcp: { command: string; args: string[] }, tool: string): void {\n  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","sourceCodeStart":13275,"sourceCodeEnd":13311,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L13275-L13311","documentation":"CLI argument error in the compress command: --toon-stats was passed without --toon. Standalone TOON statistics are not a supported mode; stats are only produced as part of an actual TOON compression pass, so the command tells you to force compression with --toon.","triggerScenarios":"Running `caveman compress --toon-stats` (with or without other flags) piping payload via stdin.","commonSituations":"Scripts or docs written against an older CLI version that supported --toon-stats; muscle-memory from other TOON tooling.","solutions":["Replace --toon-stats with --toon to force TOON compression","Pipe the engine's stderr JSON ratio report to capture stats (the engine emits the ratio report on stderr)","Update the calling script to drop --toon-stats"],"exampleFix":"// before\ncat payload.json | caveman compress --toon-stats\n// after\ncat payload.json | caveman compress --toon","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(3);\nif (args.includes('--toon-stats')) throw new Error('use --toon instead of removed --toon-stats');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit scripts for the removed --toon-stats flag","Read engine stderr for ratio stats instead of a CLI stats flag"],"tags":["cli","compress","deprecated-flag"],"backgroundTag":"invalid-flag-value","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"}