JuliusBrussee/caveman · warning

usage: [--type <content-type>] [--toon]

Error message

usage: ${invokedCommand("compress")} [--type <content-type>] [--toon]

What it means

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.

Solutions

  1. Provide a value after --type, e.g. --type application/json
  2. Set the variable used in the script (e.g. TYPE=application/json)
  3. Drop --type entirely to rely on --toon or default handling

Example fix

// before
caveman compress --type
// after
caveman compress --type application/json
Defensive patterns

Strategy: validation

Validate before calling

const i = argv.indexOf('--type');
if (i >= 0 && (!argv[i+1] || argv[i+1].startsWith('--'))) throw new Error('--type requires a value');

Prevention

When it happens

Trigger: `caveman compress --type` (missing value) or `caveman compress --type --toon` (next token is a flag).

Common situations: Truncated shell scripts; variable expansion producing an empty value ($TYPE unset); copy-paste dropping the content type.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

  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
    child.stdin.end(input);
  }
}

// compressCatalog is explicit bridge to dedicated tool-catalog product. It
// preserves caveman-shrink's stdin/stdout/report contract and forwards lint /

View on GitHub (pinned to 3ee70a1026)