katt 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,393 +1,322 @@
1
- import { r as N, c as I, a as j, p as z, b as C, l as h, d as T, g as D, e as B, f as $, h as H, s as A, i as W, j as L, k as G, m as X, n as Y, o as q, q as K, t as J } from "./runCli-425rgVp8.js";
2
- import { u as jt } from "./runCli-425rgVp8.js";
3
- import { CopilotClient as Q } from "@github/copilot-sdk";
4
- import { mkdtemp as V, rm as Z, readFile as R } from "node:fs/promises";
5
- import { join as S, dirname as v, isAbsolute as tt, resolve as et, basename as nt } from "node:path";
6
- import { spawn as ot } from "node:child_process";
7
- import { tmpdir as rt } from "node:os";
8
- import { readFileSync as st, writeFileSync as M, mkdirSync as it } from "node:fs";
9
- function Pt(t, e) {
10
- N(() => {
11
- j(), z(t);
12
- const n = D(), o = Date.now(), i = () => D() === n, s = () => Date.now() - o;
13
- try {
14
- const r = e();
15
- if (r && typeof r.then == "function") {
16
- C(
17
- r.then(() => {
18
- h(!0, s());
19
- }).catch((a) => {
20
- throw h(!1, s()), a;
21
- }).finally(() => {
22
- T();
23
- })
24
- );
25
- return;
26
- }
27
- } catch (r) {
28
- throw h(!1, s()), T(), r;
29
- }
30
- h(i(), s()), T();
31
- }, I());
1
+ import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _ } from "./runCli-DkkiL_uk.js";
2
+ import { mkdtemp as v, readFile as y, rm as b } from "node:fs/promises";
3
+ import { basename as x, dirname as S, isAbsolute as C, join as w, resolve as T } from "node:path";
4
+ import { mkdirSync as E, readFileSync as D, writeFileSync as O } from "node:fs";
5
+ import { CopilotClient as ee, approveAll as te } from "@github/copilot-sdk";
6
+ import { spawn as ne } from "node:child_process";
7
+ import { tmpdir as k } from "node:os";
8
+ //#region src/lib/describe/describe.ts
9
+ function A(t, r) {
10
+ e(() => {
11
+ l(t);
12
+ try {
13
+ let e = r();
14
+ if (e && typeof e.then == "function") {
15
+ a(e.finally(() => {
16
+ f();
17
+ }));
18
+ return;
19
+ }
20
+ } catch (e) {
21
+ throw f(), e;
22
+ }
23
+ f();
24
+ }, n());
32
25
  }
33
- function Nt(t, e) {
34
- N(() => {
35
- B(t);
36
- try {
37
- const n = e();
38
- if (n && typeof n.then == "function") {
39
- C(
40
- n.finally(() => {
41
- $();
42
- })
43
- );
44
- return;
45
- }
46
- } catch (n) {
47
- throw $(), n;
48
- }
49
- $();
50
- }, I());
26
+ //#endregion
27
+ //#region src/lib/prompt/codex.ts
28
+ var j = "katt-codex-", M = "last-message.txt";
29
+ function N(e, t) {
30
+ return typeof e == "object" && !!e && "code" in e && e.code === t;
51
31
  }
52
- const at = "katt-codex-", ct = "last-message.txt";
53
- function ut(t, e) {
54
- return typeof t == "object" && t !== null && "code" in t && t.code === e;
32
+ function P(e) {
33
+ return typeof e == "string" && e.length > 0;
55
34
  }
56
- function m(t) {
57
- return typeof t == "string" && t.length > 0;
35
+ function F(e) {
36
+ return P(e) ? [e] : Array.isArray(e) ? e.filter(P) : [];
58
37
  }
59
- function dt(t) {
60
- return m(t) ? [t] : Array.isArray(t) ? t.filter(m) : [];
38
+ function I(e, t) {
39
+ let n = t ?? {}, r = [
40
+ "exec",
41
+ "--color",
42
+ "never",
43
+ "--output-last-message",
44
+ e
45
+ ];
46
+ P(n.model) && r.push("--model", n.model), P(n.profile) && r.push("--profile", n.profile), P(n.sandbox) && r.push("--sandbox", n.sandbox), n.fullAuto === !0 && r.push("--full-auto"), n.skipGitRepoCheck === !0 && r.push("--skip-git-repo-check"), n.dangerouslyBypassApprovalsAndSandbox === !0 && r.push("--dangerously-bypass-approvals-and-sandbox");
47
+ for (let e of F(n.config)) r.push("--config", e);
48
+ return r.push("-"), r;
61
49
  }
62
- function lt(t, e) {
63
- const n = e ?? {}, o = [
64
- "exec",
65
- "--color",
66
- "never",
67
- "--output-last-message",
68
- t
69
- ];
70
- m(n.model) && o.push("--model", n.model), m(n.profile) && o.push("--profile", n.profile), m(n.sandbox) && o.push("--sandbox", n.sandbox), n.fullAuto === !0 && o.push("--full-auto"), n.skipGitRepoCheck === !0 && o.push("--skip-git-repo-check"), n.dangerouslyBypassApprovalsAndSandbox === !0 && o.push("--dangerously-bypass-approvals-and-sandbox");
71
- for (const i of dt(n.config))
72
- o.push("--config", i);
73
- return o.push("-"), o;
50
+ function L(e, t, n, r) {
51
+ return new Promise((i, a) => {
52
+ let o = ne("codex", t, {
53
+ cwd: r,
54
+ stdio: [
55
+ "pipe",
56
+ "pipe",
57
+ "pipe"
58
+ ]
59
+ }), s = "", c = "", l = !1;
60
+ o.stdout.setEncoding("utf8"), o.stderr.setEncoding("utf8"), o.stdout.on("data", (e) => {
61
+ s += e;
62
+ }), o.stderr.on("data", (e) => {
63
+ c += e;
64
+ }), o.stdin.on("error", () => {});
65
+ let u = setTimeout(() => {
66
+ l = !0, o.kill("SIGTERM");
67
+ }, n);
68
+ o.once("error", (e) => {
69
+ clearTimeout(u), a(/* @__PURE__ */ Error(`Failed to start Codex CLI. Ensure codex is installed and available on PATH. ${String(e)}`));
70
+ }), o.once("close", (e, t) => {
71
+ clearTimeout(u), i({
72
+ exitCode: e,
73
+ signal: t,
74
+ stdout: s.trim(),
75
+ stderr: c.trim(),
76
+ timedOut: l
77
+ });
78
+ }), o.stdin.end(e);
79
+ });
74
80
  }
75
- function ft(t, e, n, o) {
76
- return new Promise((i, s) => {
77
- const r = ot("codex", e, {
78
- cwd: o,
79
- stdio: ["pipe", "pipe", "pipe"]
80
- });
81
- let a = "", c = "", p = !1;
82
- r.stdout.setEncoding("utf8"), r.stderr.setEncoding("utf8"), r.stdout.on("data", (u) => {
83
- a += u;
84
- }), r.stderr.on("data", (u) => {
85
- c += u;
86
- }), r.stdin.on("error", () => {
87
- });
88
- const g = setTimeout(() => {
89
- p = !0, r.kill("SIGTERM");
90
- }, n);
91
- r.once("error", (u) => {
92
- clearTimeout(g), s(
93
- new Error(
94
- `Failed to start Codex CLI. Ensure codex is installed and available on PATH. ${String(
95
- u
96
- )}`
97
- )
98
- );
99
- }), r.once("close", (u, x) => {
100
- clearTimeout(g), i({
101
- exitCode: u,
102
- signal: x,
103
- stdout: a.trim(),
104
- stderr: c.trim(),
105
- timedOut: p
106
- });
107
- }), r.stdin.end(t);
108
- });
81
+ async function R(e, t) {
82
+ try {
83
+ return await y(e, "utf8");
84
+ } catch (e) {
85
+ if (!N(e, "ENOENT")) throw e;
86
+ return t;
87
+ }
109
88
  }
110
- async function pt(t, e) {
111
- try {
112
- return await R(t, "utf8");
113
- } catch (n) {
114
- if (!ut(n, "ENOENT"))
115
- throw n;
116
- return e;
117
- }
89
+ function z(e) {
90
+ if (e.timedOut) return "Codex timed out before returning a response.";
91
+ if (e.exitCode === null) return `Codex exited due to signal ${e.signal ?? "unknown"}.`;
92
+ let t = e.stderr.length > 0 ? ` ${e.stderr}` : "";
93
+ return `Codex exited with code ${e.exitCode}.${t}`;
118
94
  }
119
- function ht(t) {
120
- if (t.timedOut)
121
- return "Codex timed out before returning a response.";
122
- if (t.exitCode === null)
123
- return `Codex exited due to signal ${t.signal ?? "unknown"}.`;
124
- const e = t.stderr.length > 0 ? ` ${t.stderr}` : "";
125
- return `Codex exited with code ${t.exitCode}.${e}`;
95
+ async function B(e, t, n) {
96
+ let r = n ?? {}, i = P(r.workingDirectory) ? r.workingDirectory : process.cwd(), a = await v(w(k(), j)), o = w(a, M);
97
+ try {
98
+ let r = await L(e, I(o, n), t, i);
99
+ if (r.timedOut) throw Error(`Codex timed out after ${t}ms.`);
100
+ if (r.exitCode !== 0) throw Error(z(r));
101
+ let a = await R(o, r.stdout);
102
+ if (a.length === 0) throw Error("Codex did not return a response.");
103
+ return a;
104
+ } finally {
105
+ await b(a, {
106
+ recursive: !0,
107
+ force: !0
108
+ });
109
+ }
126
110
  }
127
- async function mt(t, e, n) {
128
- const o = n ?? {}, i = m(o.workingDirectory) ? o.workingDirectory : process.cwd(), s = await V(S(rt(), at)), r = S(s, ct);
129
- try {
130
- const a = lt(r, n), c = await ft(
131
- t,
132
- a,
133
- e,
134
- i
135
- );
136
- if (c.timedOut)
137
- throw new Error(`Codex timed out after ${e}ms.`);
138
- if (c.exitCode !== 0)
139
- throw new Error(ht(c));
140
- const p = await pt(r, c.stdout);
141
- if (p.length === 0)
142
- throw new Error("Codex did not return a response.");
143
- return p;
144
- } finally {
145
- await Z(s, { recursive: !0, force: !0 });
146
- }
111
+ function V(e) {
112
+ return typeof e == "string" && e.length > 0 ? e : void 0;
147
113
  }
148
- const gt = 6e5;
149
- function U(t) {
150
- return typeof t == "string" && t.length > 0 ? t : void 0;
114
+ function H(e) {
115
+ if (!e) return;
116
+ let t = { ...e };
117
+ if (t.model !== void 0) {
118
+ let e = V(typeof t.model == "string" ? t.model : void 0);
119
+ e ? t.model = e : delete t.model;
120
+ }
121
+ return Object.keys(t).length > 0 ? t : void 0;
151
122
  }
152
- function E(t) {
153
- if (!t)
154
- return;
155
- const e = { ...t };
156
- if (e.model !== void 0) {
157
- const n = U(
158
- typeof e.model == "string" ? e.model : void 0
159
- );
160
- n ? e.model = n : delete e.model;
161
- }
162
- return Object.keys(e).length > 0 ? e : void 0;
123
+ function U(e) {
124
+ if (!(typeof e != "number" || !Number.isFinite(e)) && !(e <= 0)) return Math.floor(e);
163
125
  }
164
- function O(t) {
165
- if (!(typeof t != "number" || !Number.isFinite(t)) && !(t <= 0))
166
- return Math.floor(t);
126
+ function W(e) {
127
+ return !Number.isFinite(e) || (e ?? 0) <= 0 ? 0 : Math.floor(e ?? 0);
167
128
  }
168
- function y(t) {
169
- return !Number.isFinite(t) || (t ?? 0) <= 0 ? 0 : Math.floor(t ?? 0);
129
+ function G(e) {
130
+ return W(e.inputTokens) + W(e.outputTokens) + W(e.cacheReadTokens) + W(e.cacheWriteTokens);
170
131
  }
171
- function xt(t) {
172
- return y(t.inputTokens) + y(t.outputTokens) + y(t.cacheReadTokens) + y(t.cacheWriteTokens);
132
+ async function K(e, t = {}) {
133
+ let { timeoutMs: n, onPermissionRequest: r, ...i } = t, a = await u(), o = H(a.agentOptions), s = H(i), c = H({
134
+ ...o ?? {},
135
+ ...s ?? {}
136
+ }), l = U(a.promptTimeoutMs), d = U(n) ?? l ?? 6e5, f = V(typeof c?.model == "string" ? c.model : void 0);
137
+ if (a.agent === "codex") {
138
+ let t = await B(e, d, c);
139
+ return f && _(f), t;
140
+ }
141
+ let p = new ee({ useLoggedInUser: !0 }), h, g, v = 0;
142
+ try {
143
+ await p.start(), h = await p.createSession({
144
+ ...c,
145
+ onPermissionRequest: r ?? te
146
+ }), g = h.on("assistant.usage", (e) => {
147
+ v += G(e.data);
148
+ });
149
+ let t = await h.sendAndWait({ prompt: e }, d);
150
+ if (!t?.data?.content) throw Error("Copilot did not return a response.");
151
+ return f && _(f), t.data.content;
152
+ } finally {
153
+ let e = [];
154
+ if (g?.(), v > 0 && m(v), h) try {
155
+ await h.destroy();
156
+ } catch (t) {
157
+ e.push(t);
158
+ }
159
+ try {
160
+ let t = await p.stop();
161
+ e.push(...t);
162
+ } catch (t) {
163
+ e.push(t);
164
+ }
165
+ e.length > 0 && console.error(`Copilot cleanup encountered ${e.length} error(s).`);
166
+ }
173
167
  }
174
- async function F(t, e = {}) {
175
- const { timeoutMs: n, ...o } = e, i = await H(), s = E(i.agentOptions), r = E(
176
- o
177
- ), a = E({
178
- ...s ?? {},
179
- ...r ?? {}
180
- }), c = O(i.promptTimeoutMs), g = O(n) ?? c ?? gt, u = U(
181
- typeof a?.model == "string" ? a.model : void 0
182
- );
183
- if (i.agent === "codex") {
184
- const d = await mt(t, g, a);
185
- return u && A(u), d;
186
- }
187
- const x = new Q({ useLoggedInUser: !0 });
188
- let w, k, b = 0;
189
- try {
190
- await x.start(), w = await x.createSession(a), k = w.on("assistant.usage", (f) => {
191
- b += xt(f.data);
192
- });
193
- const d = await w.sendAndWait({ prompt: t }, g);
194
- if (!d?.data?.content)
195
- throw new Error("Copilot did not return a response.");
196
- return u && A(u), d.data.content;
197
- } finally {
198
- const d = [];
199
- if (k?.(), b > 0 && W(b), w)
200
- try {
201
- await w.destroy();
202
- } catch (f) {
203
- d.push(f);
204
- }
205
- try {
206
- const f = await x.stop();
207
- d.push(...f);
208
- } catch (f) {
209
- d.push(f);
210
- }
211
- d.length > 0 && console.error(
212
- `Copilot cleanup encountered ${d.length} error(s).`
213
- );
214
- }
168
+ async function q(e, t = {}) {
169
+ let n = s.getStore(), r = n?.evalFile ? S(n.evalFile) : process.cwd();
170
+ return K(await y(C(e) ? e : T(r, e), "utf8"), t);
215
171
  }
216
- async function It(t, e = {}) {
217
- const n = L.getStore(), o = n?.evalFile ? v(n.evalFile) : process.cwd(), i = tt(t) ? t : et(o, t), s = await R(i, "utf8");
218
- return F(s, e);
172
+ //#endregion
173
+ //#region src/lib/expect/matcherUtils.ts
174
+ function J(e) {
175
+ o({
176
+ describePath: g(),
177
+ itPath: i(),
178
+ message: e
179
+ });
219
180
  }
220
- function l(t) {
221
- G({
222
- describePath: Y(),
223
- itPath: X(),
224
- message: t
225
- });
226
- }
227
- async function wt(t, e) {
228
- const n = Date.now(), o = `expected '${t}' to satisfy '${e}'`, i = F(`Evaluate if the expectation is fulfiled in by the input.
229
- Expectation: "${e}".
181
+ //#endregion
182
+ //#region src/lib/expect/promptCheck.ts
183
+ async function Y(e, t) {
184
+ let n = Date.now(), r = `expected '${e}' to satisfy '${t}'`, i = K(`Evaluate if the expectation is fulfiled in by the input.
185
+ Expectation: "${t}".
230
186
  Input:
231
187
  ---
232
- ${t}
188
+ ${e}
233
189
  ---
234
190
  Important: Answer with "Yes" or "No" only, without any additional text.
235
- `).then((s) => {
236
- s.includes("Yes") ? h(!0, Date.now() - n, "promptCheck") : s.includes("No") ? l(o) : l(`failed to evaluate expectation '${e}'`);
237
- });
238
- return C(i), i;
191
+ `).then((e) => {
192
+ e.includes("Yes") ? d(Date.now() - n, "promptCheck") : e.includes("No") ? J(r) : J(`failed to evaluate expectation '${t}'`);
193
+ });
194
+ return a(i), i;
239
195
  }
240
- const yt = 3;
241
- function Ct(t) {
242
- const e = t.match(/\b([1-5])\b/);
243
- return !e || !e[1] ? null : Number(e[1]);
196
+ //#endregion
197
+ //#region src/lib/expect/toBeClassifiedAs.ts
198
+ var X = 3;
199
+ function re(e) {
200
+ let t = e.match(/\b([1-5])\b/);
201
+ return !t || !t[1] ? null : Number(t[1]);
244
202
  }
245
- async function bt(t, e, n) {
246
- const o = Date.now(), i = n?.threshold ?? yt, s = F(
247
- `Classify the input by how "${e}" it is on a scale of 1 to 5.
248
- 1 means "not ${e}" and 5 means "very ${e}".
203
+ async function ie(e, t, n) {
204
+ let r = Date.now(), i = n?.threshold ?? X, o = K(`Classify the input by how "${t}" it is on a scale of 1 to 5.
205
+ 1 means "not ${t}" and 5 means "very ${t}".
249
206
  Return only a single number: 1, 2, 3, 4, or 5.
250
207
 
251
208
  Input:
252
209
  ---
253
- ${t}
254
- ---`,
255
- n?.model ? { model: n.model } : void 0
256
- ).then((r) => {
257
- const a = Ct(r);
258
- if (a === null) {
259
- l(
260
- `failed to classify as '${e}'. Evaluator returned '${r}'`
261
- );
262
- return;
263
- }
264
- const c = `expected response to be classified as '${e}' with score >= ${i}, got ${a}`;
265
- if (a < i) {
266
- l(c);
267
- return;
268
- }
269
- h(
270
- !0,
271
- Date.now() - o,
272
- "toBeClassifiedAs"
273
- );
274
- });
275
- return C(s), s;
210
+ ${e}
211
+ ---`, n?.model ? { model: n.model } : void 0).then((e) => {
212
+ let n = re(e);
213
+ if (n === null) {
214
+ J(`failed to classify as '${t}'. Evaluator returned '${e}'`);
215
+ return;
216
+ }
217
+ let a = `expected response to be classified as '${t}' with score >= ${i}, got ${n}`;
218
+ if (n < i) {
219
+ J(a);
220
+ return;
221
+ }
222
+ d(Date.now() - r, "toBeClassifiedAs");
223
+ });
224
+ return a(o), o;
276
225
  }
277
- function Tt(t, e) {
278
- const n = `expected '${t}' to include '${e}'`;
279
- t.includes(e) || l(n);
226
+ //#endregion
227
+ //#region src/lib/expect/toContain.ts
228
+ function ae(e, t) {
229
+ let n = `expected '${e}' to include '${t}'`;
230
+ e.includes(t) || J(n);
280
231
  }
281
- function _(t) {
282
- const e = t.trim().replace(/[<>:"/\\|?*\x00-\x1f]/g, "_").replace(/\s+/g, "_");
283
- return e.length > 0 ? e : "unnamed";
232
+ //#endregion
233
+ //#region src/lib/expect/toMatchSnapshot.ts
234
+ function Z(e) {
235
+ let t = e.trim().replace(/[<>:"/\\|?*\x00-\x1f]/g, "_").replace(/\s+/g, "_");
236
+ return t.length > 0 ? t : "unnamed";
284
237
  }
285
- function $t() {
286
- const t = K().map(
287
- (o) => _(o.description)
288
- ), e = J().map(
289
- (o) => _(o.description)
290
- ), n = [...t, ...e];
291
- return n.length === 0 ? "root" : n.join("__");
238
+ function oe() {
239
+ let e = c().map((e) => Z(e.description)), t = r().map((e) => Z(e.description)), n = [...e, ...t];
240
+ return n.length === 0 ? "root" : n.join("__");
292
241
  }
293
- function Et(t) {
294
- const n = nt(t).replace(/\.eval\.[^./\\]+$/, ""), o = $t();
295
- return S(
296
- v(t),
297
- "__snapshots__",
298
- `${n}__${o}.snap.md`
299
- );
242
+ function se(e) {
243
+ let t = x(e).replace(/\.eval\.[^./\\]+$/, ""), n = oe();
244
+ return w(S(e), "__snapshots__", `${t}__${n}.snap.md`);
300
245
  }
301
- function P(t) {
302
- return t.split(/\r?\n/);
246
+ function Q(e) {
247
+ return e.split(/\r?\n/);
303
248
  }
304
- function St(t, e) {
305
- if (t === e)
306
- return " (no diff)";
307
- const n = P(t), o = P(e), i = Math.max(n.length, o.length), s = [];
308
- for (let r = 0; r < i; r += 1) {
309
- const a = n[r], c = o[r];
310
- if (a !== c) {
311
- if (a === void 0 && c !== void 0) {
312
- s.push(`+ ${c}`);
313
- continue;
314
- }
315
- if (a !== void 0 && c === void 0) {
316
- s.push(`- ${a}`);
317
- continue;
318
- }
319
- s.push(`- ${a ?? ""}`), s.push(`+ ${c ?? ""}`);
320
- }
321
- }
322
- return s.join(`
323
- `);
249
+ function ce(e, t) {
250
+ if (e === t) return " (no diff)";
251
+ let n = Q(e), r = Q(t), i = Math.max(n.length, r.length), a = [];
252
+ for (let e = 0; e < i; e += 1) {
253
+ let t = n[e], i = r[e];
254
+ if (t !== i) {
255
+ if (t === void 0 && i !== void 0) {
256
+ a.push(`+ ${i}`);
257
+ continue;
258
+ }
259
+ if (t !== void 0 && i === void 0) {
260
+ a.push(`- ${t}`);
261
+ continue;
262
+ }
263
+ a.push(`- ${t ?? ""}`), a.push(`+ ${i ?? ""}`);
264
+ }
265
+ }
266
+ return a.join("\n");
324
267
  }
325
- function vt(t) {
326
- const e = L.getStore()?.evalFile;
327
- if (!e) {
328
- l(
329
- "toMatchSnapshot can only be used while running an eval file."
330
- );
331
- return;
332
- }
333
- const n = Et(e);
334
- try {
335
- const o = st(n, "utf8");
336
- if (o === t)
337
- return;
338
- if (q()) {
339
- M(n, t, "utf8");
340
- return;
341
- }
342
- const i = St(o, t);
343
- l(
344
- [
345
- `Snapshot mismatch at ${n}`,
346
- "",
347
- "Diff:",
348
- i,
349
- "",
350
- "Run 'npx katt --update-snapshots' (or -u) to accept this change."
351
- ].join(`
352
- `)
353
- );
354
- } catch (o) {
355
- if (o.code !== "ENOENT") {
356
- l(
357
- `Failed to read snapshot at ${n}: ${String(o)}`
358
- );
359
- return;
360
- }
361
- try {
362
- it(v(n), { recursive: !0 }), M(n, t, "utf8");
363
- } catch (s) {
364
- l(
365
- `Failed to write snapshot at ${n}: ${String(s)}`
366
- );
367
- }
368
- }
268
+ function le(e) {
269
+ let t = s.getStore()?.evalFile;
270
+ if (!t) {
271
+ J("toMatchSnapshot can only be used while running an eval file.");
272
+ return;
273
+ }
274
+ let n = se(t);
275
+ try {
276
+ let t = D(n, "utf8");
277
+ if (t === e) return;
278
+ if (p()) {
279
+ O(n, e, "utf8");
280
+ return;
281
+ }
282
+ let r = ce(t, e);
283
+ J([
284
+ `Snapshot mismatch at ${n}`,
285
+ "",
286
+ "Diff:",
287
+ r,
288
+ "",
289
+ "Run 'npx katt --update-snapshots' (or -u) to accept this change."
290
+ ].join("\n"));
291
+ } catch (t) {
292
+ if (t.code !== "ENOENT") {
293
+ J(`Failed to read snapshot at ${n}: ${String(t)}`);
294
+ return;
295
+ }
296
+ try {
297
+ E(S(n), { recursive: !0 }), O(n, e, "utf8");
298
+ } catch (e) {
299
+ J(`Failed to write snapshot at ${n}: ${String(e)}`);
300
+ }
301
+ }
369
302
  }
370
- function Lt(t) {
371
- return {
372
- toContain: (e) => {
373
- Tt(t, e);
374
- },
375
- toMatchSnapshot: () => {
376
- vt(t);
377
- },
378
- promptCheck: async (e) => {
379
- await wt(t, e);
380
- },
381
- toBeClassifiedAs: async (e, n) => {
382
- await bt(t, e, n);
383
- }
384
- };
303
+ //#endregion
304
+ //#region src/lib/expect/expect.ts
305
+ function $(e) {
306
+ return {
307
+ toContain: (t) => {
308
+ ae(e, t);
309
+ },
310
+ toMatchSnapshot: () => {
311
+ le(e);
312
+ },
313
+ promptCheck: async (t) => {
314
+ await Y(e, t);
315
+ },
316
+ toBeClassifiedAs: async (t, n) => {
317
+ await ie(e, t, n);
318
+ }
319
+ };
385
320
  }
386
- export {
387
- Nt as describe,
388
- Lt as expect,
389
- Pt as it,
390
- F as prompt,
391
- It as promptFile,
392
- jt as runCli
393
- };
321
+ //#endregion
322
+ export { A as describe, $ as expect, t as it, K as prompt, q as promptFile, h as runCli };