diff --git a/bin/tokencut.mjs b/bin/tokencut.mjs index 00ab99b..37a14f1 100644 --- a/bin/tokencut.mjs +++ b/bin/tokencut.mjs @@ -60,6 +60,10 @@ const numericFlag = (name, def) => { return value; }; const price = numericFlag("--price", 3); +if (!has("--compact") && (has("--max") || has("--max-tool"))) { + console.error("--max and --max-tool requires --compact"); + process.exit(1); +} const maxTokens = has("--max") ? numericFlag("--max", null) : null; const maxToolResultTokens = numericFlag("--max-tool", 500); let payload; diff --git a/test/cli.test.mjs b/test/cli.test.mjs index a686546..ebf4f97 100644 --- a/test/cli.test.mjs +++ b/test/cli.test.mjs @@ -67,3 +67,15 @@ test("--version prints package version", () => { const ver = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version; assert.equal(r.stdout.trim(), ver); }); + + +test("rejects compact budget flags without --compact", async (t) => { + for (const flag of ["--max", "--max-tool"]) { + await t.test(flag, () => { + const result = run(flag, "1"); + assert.notEqual(result.status, 0); + assert.match(result.stderr, /requires --compact/); + assert.equal(result.stdout, ""); + }); + } +});