can1357/oh-my-pi · error · CliUsageError

--rounds must be a positive integer

Error message

--rounds must be a positive integer

What it means

The --rounds flag on omp compress controls how many compression iterations run. Zero or negative values are meaningless as an iteration count, so the command validates it and throws a CliUsageError before starting.

Source

Thrown at packages/coding-agent/src/commands/compress.ts:32

		inPlace: Flags.boolean({ char: "i", description: "Overwrite each source file with its approved text" }),
		rounds: Flags.integer({ char: "r", description: "Maximum drafts per file before giving up", default: 3 }),
		agents: Flags.integer({ char: "n", description: "Files compressed concurrently", default: 4 }),
		model: Flags.string({ char: "m", description: "Model selector" }),
	};

	static examples = [
		"omp compress prompts/tools/read.md",
		"omp compress notes.md -o notes.compressed.md",
		"omp compress 'src/prompts/**/*.md' -i",
		"omp compress a.md b.md c.md -i -n 8",
		"omp compress spec.md -r 5 -m opus",
	];

	async run(): Promise<void> {
		const { args, flags } = await this.parse(Compress);
		const files = args.files ?? [];
		if (files.length === 0) throw new CliUsageError("compress requires at least one file or glob pattern");
		if (flags.rounds <= 0) throw new CliUsageError("--rounds must be a positive integer");
		if (flags.agents <= 0) throw new CliUsageError("--agents must be a positive integer");
		if (flags.inPlace && flags.out) throw new CliUsageError("--in-place and --out are mutually exclusive");
		const result = await runCompressCommand({
			files,
			model: flags.model,
			maxRounds: flags.rounds,
			concurrency: flags.agents,
			output: flags.out,
			inPlace: flags.inPlace,
		});
		await postmortem.quit(result.exitCode);
	}
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Use a positive integer, e.g. --rounds 5
  2. Omit --rounds to use the default number of rounds
  3. If the intent was 'do nothing', do not invoke compress at all

Example fix

// before
omp compress spec.md --rounds 0
// after
omp compress spec.md --rounds 5
Defensive patterns

Strategy: validation

Validate before calling

const rounds = Number(rawRounds);
if (!Number.isInteger(rounds) || rounds <= 0) {
  throw new Error(`--rounds must be a positive integer, got: ${rawRounds}`);
}

Type guard

function isPositiveInt(n) { return typeof n === 'number' && Number.isInteger(n) && n > 0; }

Try / catch

try {
  await Compress.run(['--rounds', String(rounds)]);
} catch (err) {
  if (err instanceof CliUsageError && err.message.includes('--rounds')) {
    console.error(`Invalid --rounds: ${rounds}. Omit the flag or use >= 1.`);
    process.exitCode = 1;
  } else throw err;
}

Prevention

When it happens

Trigger: Running 'omp compress spec.md --rounds 0' or '--rounds -2'; passing --rounds from a variable/config that defaults to 0.

Common situations: Automation computing rounds = 0 to mean 'skip rounds' (unsupported); copy-paste from docs with a placeholder; misreading the default behavior and trying to disable rounds via 0.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/0f981a3d5fa907d4. Report an issue: GitHub.