The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { assert, it } from "@effect/vitest"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Result from "effect/Result"; |
| 4 | |
| 5 | import { checkOutput, outputRequestProblem } from "./runOutput.ts"; |
| 6 | |
| 7 | const open = { type: "object", properties: { verdict: { type: "string" } }, required: ["verdict"] }; |
| 8 | const closed = { ...open, additionalProperties: false }; |
| 9 | |
| 10 | it.effect("a closed schema turns down a key it does not name, and an open one keeps it", () => |
| 11 | Effect.gen(function* () { |
| 12 | const extra = '{"verdict":"merge","note":"kept"}'; |
| 13 | assert.deepStrictEqual(yield* checkOutput(open, extra), Result.succeed(JSON.parse(extra))); |
| 14 | const rejected = yield* checkOutput(closed, extra); |
| 15 | assert.isTrue(Result.isFailure(rejected)); |
| 16 | assert.isTrue(Result.isSuccess(yield* checkOutput(closed, '{"verdict":"merge"}'))); |
| 17 | }), |
| 18 | ); |
| 19 | |
| 20 | it("a command its provider runs itself cannot be asked for a result", () => { |
| 21 | for (const text of ["/compact", "/goal Review the changes"]) { |
| 22 | assert.include(outputRequestProblem(open, { text }) ?? "", "command"); |
| 23 | } |
| 24 | assert.isNull(outputRequestProblem(open, { text: "Review the changes" })); |
| 25 | }); |