refactor: unify tool reason requirements
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { optionalToolReason, toolReason } from "../../.opencode/tool-reason.js";
|
||||
|
||||
describe("tool reason contract", () => {
|
||||
it("allows omitted purpose but requires a nonblank business reason", () => {
|
||||
expect(optionalToolReason.parse(undefined)).toBeUndefined();
|
||||
expect(toolReason.safeParse(undefined).success).toBeFalse();
|
||||
for (const schema of [optionalToolReason, toolReason]) {
|
||||
expect(schema.parse(" 核验压力异常 ")).toBe("核验压力异常");
|
||||
expect(schema.safeParse(" ").success).toBeFalse();
|
||||
expect(schema.safeParse("x".repeat(2001)).success).toBeFalse();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user