JuliusBrussee/caveman · warning

caveman compress --toon-stats is unavailable; use --toon to…

Error message

caveman compress --toon-stats is unavailable; use --toon to force TOON compression

What it means

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.

Solutions

  1. Replace --toon-stats with --toon to force TOON compression
  2. Pipe the engine's stderr JSON ratio report to capture stats (the engine emits the ratio report on stderr)
  3. Update the calling script to drop --toon-stats

Example fix

// before
cat payload.json | caveman compress --toon-stats
// after
cat payload.json | caveman compress --toon
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(3);
if (args.includes('--toon-stats')) throw new Error('use --toon instead of removed --toon-stats');

Prevention

When it happens

Trigger: Running `caveman compress --toon-stats` (with or without other flags) piping payload via stdin.

Common situations: Scripts or docs written against an older CLI version that supported --toon-stats; muscle-memory from other TOON tooling.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/3cc4b38bdbb17f1c. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/index.ts:13293

function writeMcpMarker(agentId: string, mcp: { command: string; args: string[] }): void {
  writeMcpServerMarker(agentId, "caveman", mcp, "caveman_retrieve");
}

function writeMcpServerMarker(agentId: string, serverName: string, mcp: { command: string; args: string[] }, tool: string): void {
  const path = mcpServerMarkerPath(agentId, serverName);
  durableAtomicWriteFile(path, mcpMarkerBytes(mcp, tool));
}

// compress streams stdin through the caveman-engine binary (resolved via
// CAVEMAN_ENGINE_BIN, default `caveman-engine` on PATH) and writes the compressed
// payload to stdout, forwarding the engine's JSON ratio report to stderr. The
// engine is fail-closed; if its binary is unavailable the CLI falls back to a
// pass-through that claims a 0 ratio, so `compress` never breaks a pipe.
async function compress(argv: string[]) {
  if (argv[0] === "catalog") return compressCatalog(argv.slice(1));
  if (argv.includes("--toon-stats")) {
    throw new Error("caveman compress --toon-stats is unavailable; use --toon to force TOON compression");
  }
  const input = await readStdin();
  const bin = cavemanBin("caveman-engine", "CAVEMAN_ENGINE_BIN");
  const typeIndex = argv.indexOf("--type");
  if (typeIndex >= 0 && (argv[typeIndex + 1] === undefined || argv[typeIndex + 1]!.startsWith("--"))) {
    throw new Error(`usage: ${invokedCommand("compress")} [--type <content-type>] [--toon]`);
  }
  let forcedType = argv.includes("--toon") ? "toon" : flagFrom(argv, "--type", "");
  if (forcedType === "auto") forcedType = "";
  const engineArgs = ["compress"];
  if (forcedType) engineArgs.push("--type", forcedType);
  let handled = false;
  const child = spawn(bin, engineArgs, { stdio: ["pipe", "inherit", "inherit"] });
  emitCommandRunOnce("ok"); // exit handler below hard-exits; never returns to main()
  child.on("error", () => { if (!handled) { handled = true; compressFallback(input, forcedType); } });
  child.on("exit", (code) => { if (!handled) { handled = true; process.exit(code ?? 0); } });
  if (child.stdin) {
    child.stdin.on("error", () => {}); // ignore broken pipe; the child 'error' drives the fallback

View on GitHub (pinned to 3ee70a1026)