Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/tokencut.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions test/cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
});
}
});
Loading