diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d46997d..b0f8855 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: actions/setup-node@v7 + with: + node-version: 24 + cache: npm + # deno fmt until the switch to oxfmt - uses: denoland/setup-deno@v2 with: deno-version: v2.x - - run: deno task ci + - run: npm ci + - run: npm run ci diff --git a/.gitignore b/.gitignore index 3c30c24..e627478 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .env.* .helix +node_modules diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..f42cb34 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "rules": { + "no-control-regex": "off", + "typescript/no-explicit-any": "error" + } +} diff --git a/README.md b/README.md index 9d8ed71..57785e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # llm-cli -A simple but full-featured CLI powered by Deno for chatting with LLMs. +A simple but full-featured CLI for chatting with LLMs, written in TypeScript. Thanks to [Justin Bennett](https://github.com/zephraph) for the [script](https://github.com/zephraph/deno.run/blob/0972d0cd3d8f050cb11c3a6d1c1c201608d100a9/chat-gpt.ts) @@ -21,7 +21,7 @@ And it's easy to add more. image Equations render as images in Ghostty and Kitty, with raw TeX elsewhere. Try -`deno task math-demo` for examples. +`npm run math-demo` for examples. ### Continue chat with replies @@ -85,7 +85,7 @@ environment. ### Dependencies -- [Deno](https://docs.deno.com/runtime/manual) (essential) +- [Node](https://nodejs.org/) 24 or later (essential) - [`gh`](https://cli.github.com/) (GitHub CLI, optional) - Only needed if you want to upload chats as GitHub gists - You'll need to be logged in @@ -93,8 +93,8 @@ environment. ### Installation -Clone the repo. Then you just need a way to run `main.ts`. I use this function in my -`.zprofile`: +Clone the repo and run `npm install` in it. Then you just need a way to run `main.ts`. I use +this function in my `.zprofile`: ```bash function ai() { @@ -103,11 +103,8 @@ function ai() { } ``` -The `"$@"` passes all command-line arguments to `main.ts`. - -You'll need to `chmod +x` the script in order to be able to execute it directly like above. -Otherwise, you could run it with `deno run path/to/main.ts`, but that is less convenient -because you'll have to set all the permissions I've set in the shebang line. +The `"$@"` passes all command-line arguments to `main.ts`, which runs with `node` through +its shebang line. You could also run it with `node path/to/main.ts`. ## Contributions diff --git a/adapters/claude.ts b/adapters/claude.ts index 9a01f8a..cbe41c3 100644 --- a/adapters/claude.ts +++ b/adapters/claude.ts @@ -1,10 +1,10 @@ import Anthropic from "@anthropic-ai/sdk" -import * as R from "remeda" import { match } from "ts-pattern" import { postprocessSchemaContent, prepareSchema } from "../schema.ts" import { getCost } from "../models.ts" -import { parseDataUrl } from "../utils.ts" +import { parseDataUrl } from "../image-input.ts" +import { uniqueBy } from "../utils.ts" import type { ThinkLevel } from "../types.ts" import type { ChatInput } from "./types.ts" import { validateClaudeImageSize, validateRequestSize } from "./request_size.ts" @@ -34,7 +34,7 @@ function renderClaudeContentBlock(msg: Anthropic.Beta.Messages.BetaContentBlock) const citations = (msg.citations || []) .filter((c) => c.type === "web_search_result_location") if (citations.length === 0) return msg.text - const unique = R.uniqueBy(citations, (c) => c.url) + const unique = uniqueBy(citations, (c) => c.url) const sources = unique.map((c) => `[${c.title || c.url}](${c.url})`).join(" · ") return msg.text + " (" + sources + ")" } else if (msg.type === "server_tool_use" && msg.name === "web_search") { diff --git a/adapters/claude_test.ts b/adapters/claude_test.ts index 1ae1ae8..df51554 100644 --- a/adapters/claude_test.ts +++ b/adapters/claude_test.ts @@ -1,18 +1,19 @@ -import { assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" import { claudeThinkParams } from "./claude.ts" -Deno.test("Claude uses adaptive thinking with effort levels", () => { +test("Claude uses adaptive thinking with effort levels", () => { const params = claudeThinkParams("high") - assertEquals(params.thinking?.type, "adaptive") - assertEquals(params.output_config?.effort, "xhigh") - assertEquals(params.effort, "xhigh") + assert.deepEqual(params.thinking?.type, "adaptive") + assert.deepEqual(params.output_config?.effort, "xhigh") + assert.deepEqual(params.effort, "xhigh") }) -Deno.test("Claude leaves effort at the API default unless asked", () => { +test("Claude leaves effort at the API default unless asked", () => { const params = claudeThinkParams(undefined) - assertEquals(params.thinking.type, "adaptive") - assertEquals(params.output_config, undefined) - assertEquals(params.max_tokens, 20_000) - assertEquals(claudeThinkParams("off").max_tokens, 8_000) + assert.deepEqual(params.thinking.type, "adaptive") + assert.deepEqual(params.output_config, undefined) + assert.deepEqual(params.max_tokens, 20_000) + assert.deepEqual(claudeThinkParams("off").max_tokens, 8_000) }) diff --git a/adapters/gemini.ts b/adapters/gemini.ts index 2da520c..d7c981f 100644 --- a/adapters/gemini.ts +++ b/adapters/gemini.ts @@ -1,9 +1,10 @@ import { GoogleGenAI, type Part, ThinkingLevel } from "@google/genai" -import { encodeBase64 } from "@std/encoding/base64" +import { Buffer } from "node:buffer" +import process from "node:process" import { postprocessSchemaContent, prepareSchema } from "../schema.ts" import { getCost } from "../models.ts" -import { parseDataUrl } from "../utils.ts" +import { parseDataUrl } from "../image-input.ts" import type { ThinkLevel } from "../types.ts" import type { ChatInput } from "./types.ts" import { validateRequestSize } from "./request_size.ts" @@ -18,7 +19,7 @@ async function imageToInlinePart(image_url: string): Promise { if (!res.ok) throw new Error(`Failed to fetch image: ${res.status}`) const buf = new Uint8Array(await res.arrayBuffer()) const mimeType = res.headers.get("content-type")?.split(";")[0] || "image/png" - return { inlineData: { mimeType, data: encodeBase64(buf) } } + return { inlineData: { mimeType, data: Buffer.from(buf).toString("base64") } } } export function geminiThinkParams(key: string, think: ThinkLevel | undefined) { @@ -42,7 +43,7 @@ export function geminiThinkParams(key: string, think: ThinkLevel | undefined) { export async function geminiCreateMessage( { chat, model, config, signal, outputSchema }: ChatInput, ) { - const apiKey = Deno.env.get("GEMINI_API_KEY") + const apiKey = process.env.GEMINI_API_KEY if (!apiKey) throw Error("GEMINI_API_KEY missing") const { thinkingLevel, effort } = geminiThinkParams(model.key, config.think) diff --git a/adapters/gemini_test.ts b/adapters/gemini_test.ts index 7f8779d..e7e5b0b 100644 --- a/adapters/gemini_test.ts +++ b/adapters/gemini_test.ts @@ -1,25 +1,23 @@ -import { assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" import { ThinkingLevel } from "@google/genai" import { geminiThinkParams } from "./gemini.ts" -Deno.test("Gemini default sends MEDIUM, or MINIMAL on flash-lite", () => { - assertEquals(geminiThinkParams("gemini-4-argon", undefined), { +test("Gemini default sends MEDIUM, or MINIMAL on flash-lite", () => { + assert.deepEqual(geminiThinkParams("gemini-4-argon", undefined), { thinkingLevel: ThinkingLevel.MEDIUM, effort: "medium", }) - assertEquals(geminiThinkParams("gemini-3.5-flash-lite", undefined), { + assert.deepEqual(geminiThinkParams("gemini-3.5-flash-lite", undefined), { thinkingLevel: ThinkingLevel.MINIMAL, effort: "minimal", }) }) -Deno.test("--quick only uses MINIMAL on flash-lite", () => { - assertEquals(geminiThinkParams("gemini-3.7-flash", "off").effort, "low") - assertEquals(geminiThinkParams("gemini-3.1-pro-preview", "off").effort, "low") - assertEquals( - geminiThinkParams("gemini-3.5-flash-lite", "off").effort, - "minimal", - ) +test("--quick only uses MINIMAL on flash-lite", () => { + assert.deepEqual(geminiThinkParams("gemini-3.7-flash", "off").effort, "low") + assert.deepEqual(geminiThinkParams("gemini-3.1-pro-preview", "off").effort, "low") + assert.deepEqual(geminiThinkParams("gemini-3.5-flash-lite", "off").effort, "minimal") }) diff --git a/adapters/images_test.ts b/adapters/images_test.ts index ff2cbfa..3bee72c 100644 --- a/adapters/images_test.ts +++ b/adapters/images_test.ts @@ -1,4 +1,7 @@ -import { assertEquals, assertRejects } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" +import { errorIncluding } from "../testing.ts" +import process from "node:process" import { ValidationError } from "../errors.ts" import { type } from "arktype" @@ -82,7 +85,7 @@ const cases = [ ] for (const testCase of cases) { - Deno.test(`${testCase.env} sends all images in order, including history and image-only turns`, async () => { + test(`${testCase.env} sends all images in order, including history and image-only turns`, async () => { const chat: Chat = { id: "test", createdAt: new Date(0), @@ -107,10 +110,10 @@ for (const testCase of cases) { { role: "user", content: "", createdAt: new Date(0), image_urls: [imageUrl] }, ], } - const oldKey = Deno.env.get(testCase.env) + const oldKey = process.env[testCase.env] const originalFetch = globalThis.fetch let requestBody: Record | undefined - Deno.env.set(testCase.env, "test-key") + process.env[testCase.env] = "test-key" globalThis.fetch = async (input, init) => { const request = new Request(input, init) if (request.url === imageUrl) { @@ -118,7 +121,7 @@ for (const testCase of cases) { headers: { "content-type": "image/webp; charset=binary" }, }) } - requestBody = await request.json() + requestBody = await request.json() as Record return Response.json(testCase.response) } try { @@ -127,27 +130,27 @@ for (const testCase of cases) { model: resolveModel(testCase.model), config: { search: false, think: undefined }, }) - assertEquals( + assert.deepEqual( requestBody?.messages ?? requestBody?.input ?? requestBody?.contents, testCase.messages, ) } finally { globalThis.fetch = originalFetch - if (oldKey === undefined) Deno.env.delete(testCase.env) - else Deno.env.set(testCase.env, oldKey) + if (oldKey === undefined) delete process.env[testCase.env] + else process.env[testCase.env] = oldKey } }) } -Deno.test("Claude's per-image base64 limit accepts the boundary", () => { +test("Claude's per-image base64 limit accepts the boundary", () => { validateClaudeImageSize("A".repeat(10_000_000)) }) -Deno.test("Gemini size validation matches the SDK's wire body including schema and tools", async () => { +test("Gemini size validation matches the SDK's wire body including schema and tools", async () => { const originalFetch = globalThis.fetch - const oldKey = Deno.env.get("GEMINI_API_KEY") + const oldKey = process.env["GEMINI_API_KEY"] const wireSizes: number[] = [] - Deno.env.set("GEMINI_API_KEY", "test-key") + process.env["GEMINI_API_KEY"] = "test-key" globalThis.fetch = async (input, init) => { const request = new Request(input, init) wireSizes.push((await request.arrayBuffer()).byteLength) @@ -174,28 +177,27 @@ Deno.test("Gemini size validation matches the SDK's wire body including schema a await createMessage(input) message.content = "x".repeat(20_000_000 - wireSizes[0] + 1) await createMessage(input) - assertEquals(wireSizes[1], 20_000_000) + assert.deepEqual(wireSizes[1], 20_000_000) message.content += "x" - await assertRejects( + await assert.rejects( () => createMessage(input), - ValidationError, - "Gemini request is larger than the 20 MB limit", + errorIncluding(ValidationError, "Gemini request is larger than the 20 MB limit"), ) - assertEquals(wireSizes.length, 2) + assert.deepEqual(wireSizes.length, 2) } finally { globalThis.fetch = originalFetch - if (oldKey === undefined) Deno.env.delete("GEMINI_API_KEY") - else Deno.env.set("GEMINI_API_KEY", oldKey) + if (oldKey === undefined) delete process.env["GEMINI_API_KEY"] + else process.env["GEMINI_API_KEY"] = oldKey } }) -Deno.test("OpenAI background requests use high image detail and send only the chained turn", async () => { +test("OpenAI background requests use high image detail and send only the chained turn", async () => { const originalFetch = globalThis.fetch - const oldKey = Deno.env.get("OPENAI_API_KEY") + const oldKey = process.env["OPENAI_API_KEY"] let requestBody: Record | undefined - Deno.env.set("OPENAI_API_KEY", "test-key") + process.env["OPENAI_API_KEY"] = "test-key" globalThis.fetch = async (input, init) => { - requestBody = await new Request(input, init).json() + requestBody = await new Request(input, init).json() as Record return Response.json({ id: "new-response", output: [], status: "queued" }) } try { @@ -233,20 +235,20 @@ Deno.test("OpenAI background requests use high image detail and send only the ch ], }, }) - assertEquals(requestBody?.input, [{ + assert.deepEqual(requestBody?.input, [{ role: "user", content: [ { type: "input_image", image_url: secondImage, detail: "high" }, { type: "input_image", image_url: imageUrl, detail: "high" }, ], }]) - assertEquals(requestBody?.previous_response_id, "previous-response") - assertEquals(requestBody?.background, true) - assertEquals(requestBody?.store, true) + assert.deepEqual(requestBody?.previous_response_id, "previous-response") + assert.deepEqual(requestBody?.background, true) + assert.deepEqual(requestBody?.store, true) } finally { globalThis.fetch = originalFetch - if (oldKey === undefined) Deno.env.delete("OPENAI_API_KEY") - else Deno.env.set("OPENAI_API_KEY", oldKey) + if (oldKey === undefined) delete process.env["OPENAI_API_KEY"] + else process.env["OPENAI_API_KEY"] = oldKey } }) @@ -286,11 +288,11 @@ for ( }, ] ) { - Deno.test(`${testCase.model} rejects oversized encoded images and requests before sending: ${testCase.error}`, async () => { + test(`${testCase.model} rejects oversized encoded images and requests before sending: ${testCase.error}`, async () => { const originalFetch = globalThis.fetch - const oldKey = Deno.env.get(testCase.env) + const oldKey = process.env[testCase.env] let apiCalls = 0 - Deno.env.set(testCase.env, "test-key") + process.env[testCase.env] = "test-key" globalThis.fetch = (input, init) => { const request = new Request(input, init) if (request.url === imageUrl) { @@ -305,34 +307,30 @@ for ( return Promise.resolve(Response.json(response)) } try { - await assertRejects( - () => - createMessage({ - model: resolveModel(testCase.model), - config: { search: false, think: undefined }, - chat: { - id: "test", - createdAt: new Date(0), - systemPrompt: "test", - messages: [ - { - role: "user", - content: testCase.prompt, - image_urls: testCase.images, - createdAt: new Date(0), - }, - { role: "user", content: "Follow up", createdAt: new Date(0) }, - ], - }, - }), - ValidationError, - testCase.error, - ) - assertEquals(apiCalls, 0) + await assert.rejects(() => + createMessage({ + model: resolveModel(testCase.model), + config: { search: false, think: undefined }, + chat: { + id: "test", + createdAt: new Date(0), + systemPrompt: "test", + messages: [ + { + role: "user", + content: testCase.prompt, + image_urls: testCase.images, + createdAt: new Date(0), + }, + { role: "user", content: "Follow up", createdAt: new Date(0) }, + ], + }, + }), errorIncluding(ValidationError, testCase.error)) + assert.deepEqual(apiCalls, 0) } finally { globalThis.fetch = originalFetch - if (oldKey === undefined) Deno.env.delete(testCase.env) - else Deno.env.set(testCase.env, oldKey) + if (oldKey === undefined) delete process.env[testCase.env] + else process.env[testCase.env] = oldKey } }) } diff --git a/adapters/mod.ts b/adapters/mod.ts index 7e297e0..b894b61 100644 --- a/adapters/mod.ts +++ b/adapters/mod.ts @@ -1,26 +1,33 @@ import type { ChatInput, ModelResponse } from "./types.ts" -import { - gptCreateMessage, - gptImageCreateMessage, - openrouterCreateMessage, -} from "./openai.ts" -import { claudeCreateMessage } from "./claude.ts" -import { geminiCreateMessage } from "./gemini.ts" export type { ChatInput, ImageOptions, ModelResponse, ToolConfig } from "./types.ts" export { imageQualities } from "./types.ts" export type { ThinkLevel } from "../types.ts" -export { gptBg } from "./openai.ts" export const searchProviders = new Set(["anthropic", "openai", "google"]) export const thinkProviders = new Set(["anthropic", "openai", "google", "baseten"]) export const imageInputProviders = new Set(["anthropic", "openai", "google"]) -export function createMessage(input: ChatInput): Promise { +// The provider SDKs are a few hundred modules together, so load each adapter +// on first use rather than on every startup +const openai = () => import("./openai.ts") + +export async function createMessage(input: ChatInput): Promise { const { provider } = input.model - if (input.model.kind === "image") return gptImageCreateMessage(input) - if (provider === "anthropic") return claudeCreateMessage(input) - if (provider === "google") return geminiCreateMessage(input) - if (provider === "openrouter") return openrouterCreateMessage(input) - return gptCreateMessage(input) + if (input.model.kind === "image") return (await openai()).gptImageCreateMessage(input) + if (provider === "anthropic") { + return (await import("./claude.ts")).claudeCreateMessage(input) + } + if (provider === "google") return (await import("./gemini.ts")).geminiCreateMessage(input) + if (provider === "openrouter") return (await openai()).openrouterCreateMessage(input) + return (await openai()).gptCreateMessage(input) +} + +type GptBg = typeof import("./openai.ts").gptBg + +export const gptBg: GptBg = { + initiate: async (...args) => (await openai()).gptBg.initiate(...args), + retrieve: async (...args) => (await openai()).gptBg.retrieve(...args), + status: async (...args) => (await openai()).gptBg.status(...args), + cancel: async (...args) => (await openai()).gptBg.cancel(...args), } diff --git a/adapters/openai.ts b/adapters/openai.ts index fa71af7..d938e59 100644 --- a/adapters/openai.ts +++ b/adapters/openai.ts @@ -1,7 +1,8 @@ import OpenAI from "openai" import type { ResponseCreateParamsNonStreaming } from "openai/resources/responses/responses" import type { ImageGenerateParamsNonStreaming } from "openai/resources/images" -import { decodeBase64 } from "@std/encoding/base64" +import { Buffer } from "node:buffer" +import process from "node:process" import { ValidationError } from "../errors.ts" import { match, P } from "ts-pattern" @@ -196,7 +197,7 @@ export function processGptImageResponse( save: (bytes: Uint8Array, index: number) => string, ): ModelResponse { const images = (response.data ?? []).flatMap((d, i) => - d.b64_json ? [save(decodeBase64(d.b64_json), i)] : [] + d.b64_json ? [save(Buffer.from(d.b64_json, "base64"), i)] : [] ) if (images.length === 0) throw new Error("No image in response") // Image models don't report cached input, and we don't send input images @@ -230,7 +231,7 @@ const makeOpenAIFunc = (baseURL: string, envVarName: string, opts: { think?: boolean } = {}) => async ({ chat, model, signal, outputSchema, config }: ChatInput) => { // without this check the SDK would fall back to OPENAI_API_KEY - const apiKey = Deno.env.get(envVarName) + const apiKey = process.env[envVarName] if (!apiKey) throw new Error(`${envVarName} missing`) const client = new OpenAI({ baseURL, apiKey }) const systemMsg = chat.systemPrompt diff --git a/adapters/openai_test.ts b/adapters/openai_test.ts index e29ac6e..5b6432f 100644 --- a/adapters/openai_test.ts +++ b/adapters/openai_test.ts @@ -1,24 +1,26 @@ -import { assertAlmostEquals, assertEquals, assertThrows } from "@std/assert" -import { encodeBase64 } from "@std/encoding/base64" +import assert from "node:assert/strict" +import { test } from "node:test" +import { assertAlmostEqual, errorIncluding } from "../testing.ts" +import { Buffer } from "node:buffer" import { resolveModel } from "../models.ts" import { gptImageParams, openAIEffort, processGptImageResponse } from "./openai.ts" import type { ChatInput } from "./types.ts" -Deno.test("OpenAI reasoning intent resolves to native effort", () => { - assertEquals(openAIEffort(undefined), "medium") - assertEquals(openAIEffort("high"), "high") - assertEquals(openAIEffort("off"), "none") +test("OpenAI reasoning intent resolves to native effort", () => { + assert.deepEqual(openAIEffort(undefined), "medium") + assert.deepEqual(openAIEffort("high"), "high") + assert.deepEqual(openAIEffort("off"), "none") }) -Deno.test("image response saves each image and prices usage", () => { +test("image response saves each image and prices usage", () => { const model = resolveModel("flare") const saved: [number, number][] = [] const response = processGptImageResponse( { created: 0, quality: "low", - data: [{ b64_json: encodeBase64(new Uint8Array([1, 2, 3])) }], + data: [{ b64_json: Buffer.from([1, 2, 3]).toString("base64") }], usage: { input_tokens: 20, input_tokens_details: { text_tokens: 20, image_tokens: 0 }, @@ -32,22 +34,22 @@ Deno.test("image response saves each image and prices usage", () => { return `/images/${i}.png` }, ) - assertEquals(saved, [[3, 0]]) - assertEquals(response.images, ["/images/0.png"]) - assertEquals(response.content, "/images/0.png") - assertEquals(response.effort, "low") + assert.deepEqual(saved, [[3, 0]]) + assert.deepEqual(response.images, ["/images/0.png"]) + assert.deepEqual(response.content, "/images/0.png") + assert.deepEqual(response.effort, "low") // (20 * 5 + 200 * 30) / 1_000_000 - assertAlmostEquals(response.cost, 0.0061) + assertAlmostEqual(response.cost, 0.0061) }) -Deno.test("image generation rejects history and input images before requesting", () => { +test("image generation rejects history and input images before requesting", () => { const user = { role: "user" as const, content: "a cat", createdAt: new Date() } const input: ChatInput = { chat: { id: "test", createdAt: new Date(), systemPrompt: "", messages: [user] }, model: resolveModel("flare"), config: { search: false, think: undefined }, } - assertEquals(gptImageParams(input).prompt, "a cat") + assert.deepEqual(gptImageParams(input).prompt, "a cat") for ( const messages of [ [user, { ...user, content: "make it blue" }], @@ -59,6 +61,9 @@ Deno.test("image generation rejects history and input images before requesting", ] ) { input.chat.messages = messages - assertThrows(() => gptImageParams(input), Error, "fresh text-only prompt") + assert.throws( + () => gptImageParams(input), + errorIncluding(Error, "fresh text-only prompt"), + ) } }) diff --git a/deno.jsonc b/deno.jsonc index 23f64cc..dc8fc9d 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,39 +1,9 @@ +// Only `deno fmt` still uses Deno, until it's replaced by oxfmt. { - "tasks": { - "ci": "deno fmt --check && deno lint && deno check && deno task test", - "test": "deno test --allow-env --allow-read --allow-write=/tmp", - "math-demo": "deno run --allow-env --allow-read math-demo.ts" - }, "fmt": { // Preserve math delimiters and TeX lines that look like Markdown syntax. - "exclude": ["fixtures/terminal-math.md"], + "exclude": ["fixtures/terminal-math.md", "package-lock.json", ".claude"], "lineWidth": 92, "semiColons": false - }, - "imports": { - "@commander-js/extra-typings": "npm:@commander-js/extra-typings@^15.0.0", - "commander": "npm:commander@^15.0.0", - "@inquirer/core": "npm:@inquirer/core@^12", - "@david/dax": "jsr:@david/dax@^0.49.0", - "@mathjax/src": "npm:@mathjax/src@4.1.3", - "@resvg/resvg-wasm": "npm:@resvg/resvg-wasm@2.6.2", - "@std/assert": "jsr:@std/assert@^1.0.19", - "@std/encoding": "jsr:@std/encoding@^1.0.11", - "@std/io": "jsr:@std/io@^0.225.3", - "@std/path": "jsr:@std/path@^1.1.6", - "@shikijs/cli": "npm:@shikijs/cli@^4.4.3", - "ansis": "npm:ansis@^4.3.1", - "markdown-exit": "npm:markdown-exit@^1.3.0", - "markdown-table": "https://esm.sh/markdown-table@3.0.4", - "openai": "npm:openai@7.21.0", - "@anthropic-ai/sdk": "npm:@anthropic-ai/sdk@0.123.0", - "arktype": "npm:arktype@^2.2.3", - "json5": "npm:json5@^2.2.3", - "@google/genai": "npm:@google/genai@2.21.0", - "remeda": "npm:remeda@^2.45.0", - "ts-pattern": "npm:ts-pattern@^5.9.0", - "string-width": "https://esm.sh/string-width@7.2.0", - "supports-hyperlinks": "npm:supports-hyperlinks@^4.5.0", - "wrap-ansi": "https://esm.sh/wrap-ansi@9.0.0" } } diff --git a/deno.lock b/deno.lock deleted file mode 100644 index de7e056..0000000 --- a/deno.lock +++ /dev/null @@ -1,923 +0,0 @@ -{ - "version": "5", - "specifiers": { - "jsr:@david/console-static-text@~0.3.4": "0.3.5", - "jsr:@david/dax@0.49": "0.49.0", - "jsr:@david/path@0.3": "0.3.4", - "jsr:@david/path@~0.3.2": "0.3.4", - "jsr:@david/shell@0.6": "0.6.0", - "jsr:@david/which@0.7": "0.7.4", - "jsr:@david/which@~0.7.1": "0.7.4", - "jsr:@std/assert@^1.0.19": "1.0.19", - "jsr:@std/bytes@^1.0.6": "1.0.6", - "jsr:@std/encoding@^1.0.11": "1.0.11", - "jsr:@std/fmt@1": "1.0.10", - "jsr:@std/internal@^1.0.12": "1.0.14", - "jsr:@std/internal@^1.0.14": "1.0.14", - "jsr:@std/io@0.225": "0.225.3", - "jsr:@std/io@~0.225.3": "0.225.3", - "jsr:@std/path@*": "1.0.8", - "jsr:@std/path@1": "1.1.6", - "jsr:@std/path@^1.1.6": "1.1.6", - "npm:@anthropic-ai/sdk@0.123.0": "0.123.0", - "npm:@commander-js/extra-typings@15": "15.0.0_commander@15.0.0", - "npm:@google/genai@2.21.0": "2.21.0", - "npm:@inquirer/core@12": "12.0.4", - "npm:@mathjax/src@4.1.3": "4.1.3", - "npm:@resvg/resvg-wasm@2.6.2": "2.6.2", - "npm:@shikijs/cli@^4.4.3": "4.4.3", - "npm:ansis@^4.3.1": "4.3.1", - "npm:arktype@^2.2.3": "2.2.3", - "npm:commander@15": "15.0.0", - "npm:json5@^2.2.3": "2.2.3", - "npm:markdown-exit@^1.3.0": "1.3.0", - "npm:openai@7.21.0": "7.21.0", - "npm:remeda@^2.45.0": "2.45.0", - "npm:supports-hyperlinks@^4.5.0": "4.5.0", - "npm:ts-pattern@^5.9.0": "5.9.0" - }, - "jsr": { - "@david/console-static-text@0.3.5": { - "integrity": "7a6ab3610e6f0fa5743d56f7a05347a96afa9fae19de2d84ff964f09de441101" - }, - "@david/dax@0.44.1": { - "integrity": "200cbb2f85d833e657acd50dfceb92aa6c5330a48dd36e85e4e9f6a3a457609c" - }, - "@david/dax@0.49.0": { - "integrity": "9876274ff7cffd4d91c5e4bd362e55330bcecd3df8c4450d7c3db46e50e83111", - "dependencies": [ - "jsr:@david/console-static-text", - "jsr:@david/path@~0.3.2", - "jsr:@david/shell", - "jsr:@david/which@0.7", - "jsr:@std/fmt" - ] - }, - "@david/path@0.3.4": { - "integrity": "6e9c8e8914401fa7489c50cc9214d5593229bdeb96b23c494f43ed2a518cbf67", - "dependencies": [ - "jsr:@std/path@^1.1.6" - ] - }, - "@david/shell@0.6.0": { - "integrity": "c58b1005b95ea16195d437cccebae3cd939c7b242a12067f37943b3d114dbf17", - "dependencies": [ - "jsr:@david/console-static-text", - "jsr:@david/path@0.3", - "jsr:@david/which@~0.7.1", - "jsr:@std/fmt", - "jsr:@std/io@0.225", - "jsr:@std/path@1" - ] - }, - "@david/which@0.7.4": { - "integrity": "b4ed8e7f489b3689afb4b8315944211c807f91c03229e48ab888e55336c73087" - }, - "@std/assert@1.0.16": { - "integrity": "6a7272ed1eaa77defe76e5ff63ca705d9c495077e2d5fd0126d2b53fc5bd6532" - }, - "@std/assert@1.0.19": { - "integrity": "eaada96ee120cb980bc47e040f82814d786fe8162ecc53c91d8df60b8755991e", - "dependencies": [ - "jsr:@std/internal@^1.0.12" - ] - }, - "@std/bytes@1.0.6": { - "integrity": "f6ac6adbd8ccd99314045f5703e23af0a68d7f7e58364b47d2c7f408aeb5820a" - }, - "@std/encoding@1.0.11": { - "integrity": "e7cef2f0b3153bccc17431e7c864a1de03a4b6d9647389c43e08aaa775d37385" - }, - "@std/fmt@1.0.10": { - "integrity": "90dfba288802ac6de82fb31d0917eb9e4450b9925b954d5e51fc29ac07419db5" - }, - "@std/internal@1.0.10": { - "integrity": "e3be62ce42cab0e177c27698e5d9800122f67b766a0bea6ca4867886cbde8cf7" - }, - "@std/internal@1.0.14": { - "integrity": "291516b3d4c35024d6ffbc0a9df5bf4c64116e05b50012cf846710152d2ffdf7" - }, - "@std/io@0.225.2": { - "integrity": "3c740cd4ee4c082e6cfc86458f47e2ab7cb353dc6234d5e9b1f91a2de5f4d6c7" - }, - "@std/io@0.225.3": { - "integrity": "27b07b591384d12d7b568f39e61dff966b8230559122df1e9fd11cc068f7ddd1", - "dependencies": [ - "jsr:@std/bytes" - ] - }, - "@std/path@1.0.8": { - "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" - }, - "@std/path@1.1.3": { - "integrity": "b015962d82a5e6daea980c32b82d2c40142149639968549c649031a230b1afb3" - }, - "@std/path@1.1.6": { - "integrity": "c68485c2a4dfbb5ae3cc74fae4e8c4e5d874cf8a8ed12927917235c758b46cbe", - "dependencies": [ - "jsr:@std/internal@^1.0.14" - ] - } - }, - "npm": { - "@anthropic-ai/sdk@0.123.0": { - "integrity": "sha512-Y9oX9mPNGZClHQOFqrWRk43Srcu/UHuPq3rfxxOq7JgW0gi+lJA2MAOK4Ul3k/+AUrwRWFJvd0tK3oC0Pw25dw==", - "dependencies": [ - "json-schema-to-ts", - "standardwebhooks" - ], - "bin": true - }, - "@ark/schema@0.56.2": { - "integrity": "sha512-Qx4D2JFbBWpntiHZaTv7bGG4H/M2rigiknezKg/WVyDSaLdE4YCcWAOoFB7pjjDqHbbV2OqRfntm1nnXvwMexg==", - "dependencies": [ - "@ark/util" - ] - }, - "@ark/util@0.56.2": { - "integrity": "sha512-9kU2sUE38FZEGG7l3hamYMBieLYEJh2L1mrYD2eXpT+78EnQSV1bhjxJhnxGBMSTbtwpBSDNSK+K60WvaI/DTQ==" - }, - "@babel/runtime@7.29.7": { - "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==" - }, - "@commander-js/extra-typings@15.0.0_commander@15.0.0": { - "integrity": "sha512-yeJlba62xqmkgELUsn7356MEnzLLu/fw2x4lofFqGnXh6YysRdEs2BaLeLtg1+KU0AXvMeqQvTTp+3hBEBK+EA==", - "dependencies": [ - "commander@15.0.0" - ] - }, - "@google/genai@2.21.0": { - "integrity": "sha512-+PDtco2/Z0ONdzCGekCoCT+O1VJS9xJQNN4XzQpXG/t3El/SWWMkCWlFRO1KmivOHPa4Q0VjUYu1HBKCZ/v33Q==", - "dependencies": [ - "google-auth-library", - "p-retry", - "protobufjs", - "ws" - ], - "scripts": true - }, - "@inquirer/ansi@2.0.9": { - "integrity": "sha512-0Ywt3S8tqM6TWUcsRlBFQ1x+X3/o8kktX0ZiKAnByYb9GFDknnOhse1PVtfiD2BXPI8ar+BWx9PV9R0lQIcygw==" - }, - "@inquirer/core@12.0.4": { - "integrity": "sha512-M5fB67y7jPObI45vhD82RskWwCSm0scOvenV/I6K8tIi2gfr9DXqQqJ+iw+Wi6SgapikdOiJibYzz1gW47fsDg==", - "dependencies": [ - "@inquirer/ansi", - "@inquirer/figures", - "@inquirer/type", - "cli-width", - "fast-wrap-ansi", - "mute-stream", - "signal-exit" - ] - }, - "@inquirer/figures@2.0.9": { - "integrity": "sha512-EAWgUTGQ/Umgga51dE3B2PUHbufuXarDfg86uVgoSgNHNNQnyFKcOrQLWVqYMghuSyHh8+2HUH0Js9cTC1WAdg==" - }, - "@inquirer/type@4.2.0": { - "integrity": "sha512-2rnHX8RPo4glJYqnFc/v3nQeIhDcjyRRyaT7MGcfL/8xv/8K03SXYoA2tX06WVSKywWOE/ncbG3dtuzLjR5TCQ==" - }, - "@mathjax/mathjax-newcm-font@4.1.3": { - "integrity": "sha512-gzAB3dFHilHX1l5x2xUqRL+1jDQt3Fyza1DkEMVXWC4E8SvsGdlgEza47HYi2WhVcgfkvf4zgUGzuhbq3Pjlew==" - }, - "@mathjax/src@4.1.3": { - "integrity": "sha512-rIrWquuBSoJuoMBdC/1qD+AUHTorlccPicoVy6P2xbUgnuDBpCcpbHtOAsB8L3hdCHtNBg92lF8e3Fz+pkcQbw==", - "dependencies": [ - "@mathjax/mathjax-newcm-font", - "mhchemparser", - "mj-context-menu", - "speech-rule-engine" - ] - }, - "@protobufjs/aspromise@1.1.2": { - "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" - }, - "@protobufjs/base64@1.1.2": { - "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" - }, - "@protobufjs/codegen@2.0.5": { - "integrity": "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==" - }, - "@protobufjs/eventemitter@1.1.1": { - "integrity": "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==" - }, - "@protobufjs/fetch@1.1.1": { - "integrity": "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==", - "dependencies": [ - "@protobufjs/aspromise" - ] - }, - "@protobufjs/float@1.0.2": { - "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" - }, - "@protobufjs/path@1.1.2": { - "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" - }, - "@protobufjs/pool@1.1.0": { - "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" - }, - "@protobufjs/utf8@1.1.2": { - "integrity": "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==" - }, - "@resvg/resvg-wasm@2.6.2": { - "integrity": "sha512-FqALmHI8D4o6lk/LRWDnhw95z5eO+eAa6ORjVg09YRR7BkcM6oPHU9uyC0gtQG5vpFLvgpeU4+zEAz2H8APHNw==" - }, - "@shikijs/cli@4.4.3": { - "integrity": "sha512-rBlT7EG70MxFLZZ+w3IPmzRz46U+L0HEF+ASmDbQmFMVj9AjkPvlM+uhVkXFODWyOaNXAveqzo6WDGh4saktPw==", - "dependencies": [ - "@shikijs/vscode-textmate", - "ansis", - "cac", - "shiki" - ], - "bin": true - }, - "@shikijs/core@4.4.3": { - "integrity": "sha512-QCR4q2ZO/ILJEuwiBMel4wdcTDb1JGwfjKTxPDF6x8ixOaluPrVqIn06C99AcRPhmYlBR56d/Fb+GN58GzExpg==", - "dependencies": [ - "@shikijs/primitive", - "@shikijs/types", - "@shikijs/vscode-textmate", - "@types/hast", - "hast-util-to-html" - ] - }, - "@shikijs/engine-javascript@4.4.3": { - "integrity": "sha512-FbOjFJp9VLdo1Wevs10BBtVxiTWwNLqZh5Gkhjgda/ioL15YOgeSl9n+6XMa3qRlPQzfhFNe641SrynFHYG0nQ==", - "dependencies": [ - "@shikijs/types", - "@shikijs/vscode-textmate", - "oniguruma-to-es" - ] - }, - "@shikijs/engine-oniguruma@4.4.3": { - "integrity": "sha512-EcOQkxdxGQrc1Row/cC2c96/v1dbZqGnEVu1qTuT/MJmp6+cXCvQussowVmCv5Tqr3KuY3c7IbM6HTW3LJ1k9w==", - "dependencies": [ - "@shikijs/types", - "@shikijs/vscode-textmate" - ] - }, - "@shikijs/langs@4.4.3": { - "integrity": "sha512-ePic0yfAJGOF83D5wBHK/00EjK65oahBYxFk5epgq33WRv7X9UuxLEV8PtR0szC0z8dl7INIpIodB99JRFlR+A==", - "dependencies": [ - "@shikijs/types" - ] - }, - "@shikijs/primitive@4.4.3": { - "integrity": "sha512-m0wBeLDQDeIxRdUmrCPdQqfuUamDwRL5isCfYbguKD6NiaKpVbsv+3J81DyIKgNW5h4WAIIr8T4EkgQrBBxvaQ==", - "dependencies": [ - "@shikijs/types", - "@shikijs/vscode-textmate", - "@types/hast" - ] - }, - "@shikijs/themes@4.4.3": { - "integrity": "sha512-w8UHjeUnIR965KMWJHUPXOc2mNJUnK3vpVLYLvw5IYU2mnTTJ89E24OrJDBNiJDQ0qzb0tc4l7mrIXx5cFeIyw==", - "dependencies": [ - "@shikijs/types" - ] - }, - "@shikijs/types@4.4.3": { - "integrity": "sha512-UEJxmRR++MAGR6hugn0vgVS2W/6lWAts84FFSrnlH9sP0LNol7E5+NQ792pH8liWUhyMyjhTgSUH3k7iD7tc5g==", - "dependencies": [ - "@shikijs/vscode-textmate", - "@types/hast" - ] - }, - "@shikijs/vscode-textmate@10.0.2": { - "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==" - }, - "@stablelib/base64@1.0.1": { - "integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==" - }, - "@types/hast@3.0.5": { - "integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==", - "dependencies": [ - "@types/unist" - ] - }, - "@types/linkify-it@5.0.0": { - "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==" - }, - "@types/mdast@4.0.4": { - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", - "dependencies": [ - "@types/unist" - ] - }, - "@types/mdurl@2.0.0": { - "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==" - }, - "@types/node@26.4.1": { - "integrity": "sha512-k97ENvZWtvA6yqz5/FS6a7duDgOPEeOQOc2iKS/nY6mX6qJUKtLnWzQS+Xj6tXweyj6ZcTAK2Qecetnvi9nCLA==", - "dependencies": [ - "undici-types" - ] - }, - "@types/retry@0.12.0": { - "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" - }, - "@types/unist@3.0.3": { - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==" - }, - "@ungap/structured-clone@1.4.0": { - "integrity": "sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==" - }, - "@xmldom/xmldom@0.9.12": { - "integrity": "sha512-5AXjrcMClTryPe9LgZrygpB1lj7s0S9E0+W+AHaVKAVyHanafK86iPSvG5xHVSp/jC+VH1UXu0TAEmY279xH7A==" - }, - "agent-base@7.1.4": { - "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==" - }, - "ansis@4.3.1": { - "integrity": "sha512-BJ8/l4R5LRE7hW9WdSuGYrLSHi2ynxeFpDFbH0K/CgNeY/tyhk+vO6TYxXC5r5CpUhNVX310xzPsN/H9lCdfOA==" - }, - "arkregex@0.0.8": { - "integrity": "sha512-PJcx6G1kQTgLKPUbeYlYecDRaKq15AMSGVajlKFYWlPeJRQL+j3dKE6tyMs40HZ99djS1l9Vhl3ezAHy9JBIqQ==", - "dependencies": [ - "@ark/util" - ] - }, - "arktype@2.2.3": { - "integrity": "sha512-7W+0RLTUNJiBFIIZXwOQxSR8Z273IAd6IvqBeG9+gHnQKFsIx2C0iOtGTmMrPnlX4qLXyc5+ll7A0BIj9WrbTg==", - "dependencies": [ - "@ark/schema", - "@ark/util", - "arkregex" - ] - }, - "balanced-match@4.0.4": { - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==" - }, - "base64-js@1.5.1": { - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" - }, - "bignumber.js@9.3.1": { - "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==" - }, - "brace-expansion@5.0.9": { - "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", - "dependencies": [ - "balanced-match" - ] - }, - "buffer-equal-constant-time@1.0.1": { - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" - }, - "cac@7.0.0": { - "integrity": "sha512-tixWYgm5ZoOD+3g6UTea91eow5z6AAHaho3g0V9CNSNb45gM8SmflpAc+GRd1InC4AqN/07Unrgp56Y94N9hJQ==" - }, - "ccount@2.0.1": { - "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==" - }, - "character-entities-html4@2.1.0": { - "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==" - }, - "character-entities-legacy@3.0.0": { - "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==" - }, - "cli-width@4.1.0": { - "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==" - }, - "comma-separated-tokens@2.0.3": { - "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==" - }, - "commander@14.0.3": { - "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==" - }, - "commander@15.0.0": { - "integrity": "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==" - }, - "data-uri-to-buffer@4.0.1": { - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==" - }, - "debug@4.4.3": { - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dependencies": [ - "ms" - ] - }, - "dequal@2.0.3": { - "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==" - }, - "devlop@1.1.0": { - "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", - "dependencies": [ - "dequal" - ] - }, - "ecdsa-sig-formatter@1.0.11": { - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "dependencies": [ - "safe-buffer" - ] - }, - "entities@7.0.1": { - "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==" - }, - "extend@3.0.2": { - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "fast-sha256@1.3.0": { - "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==" - }, - "fast-string-truncated-width@3.0.3": { - "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==" - }, - "fast-string-width@3.0.2": { - "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==", - "dependencies": [ - "fast-string-truncated-width" - ] - }, - "fast-wrap-ansi@0.2.2": { - "integrity": "sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==", - "dependencies": [ - "fast-string-width" - ] - }, - "fetch-blob@3.2.0": { - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "dependencies": [ - "node-domexception", - "web-streams-polyfill" - ] - }, - "formdata-polyfill@4.0.10": { - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "dependencies": [ - "fetch-blob" - ] - }, - "gaxios@7.3.1": { - "integrity": "sha512-kB3rzJV7d9juLZh8/56QTXCwQfxyhdOMdyYk1HdQKFtF8TJTDTZQJtixWIwXdE9Jji91mC41DUNpjleo4L4eAQ==", - "dependencies": [ - "extend", - "https-proxy-agent", - "node-fetch" - ] - }, - "gcp-metadata@8.1.2": { - "integrity": "sha512-zV/5HKTfCeKWnxG0Dmrw51hEWFGfcF2xiXqcA3+J90WDuP0SvoiSO5ORvcBsifmx/FoIjgQN3oNOGaQ5PhLFkg==", - "dependencies": [ - "gaxios", - "google-logging-utils", - "json-bigint" - ] - }, - "glob@13.0.6": { - "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", - "dependencies": [ - "minimatch", - "minipass", - "path-scurry" - ] - }, - "google-auth-library@10.9.1": { - "integrity": "sha512-i1ydyHrqcIxXkWh/uBmVkzCvIuq5yiK2ATndIe5XxKholrG/MTYP9xGYka4sQhrbIAgGjL2B6NOE7rFaiF3fXw==", - "dependencies": [ - "base64-js", - "ecdsa-sig-formatter", - "gaxios", - "gcp-metadata", - "google-logging-utils", - "jws" - ] - }, - "google-logging-utils@1.1.3": { - "integrity": "sha512-eAmLkjDjAFCVXg7A1unxHsLf961m6y17QFqXqAXGj/gVkKFrEICfStRfwUlGNfeCEjNRa32JEWOUTlYXPyyKvA==" - }, - "has-flag@5.0.1": { - "integrity": "sha512-CsNUt5x9LUdx6hnk/E2SZLsDyvfqANZSUq4+D3D8RzDJ2M+HDTIkF60ibS1vHaK55vzgiZw1bEPFG9yH7l33wA==" - }, - "hast-util-to-html@9.0.5": { - "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==", - "dependencies": [ - "@types/hast", - "@types/unist", - "ccount", - "comma-separated-tokens", - "hast-util-whitespace", - "html-void-elements", - "mdast-util-to-hast", - "property-information", - "space-separated-tokens", - "stringify-entities", - "zwitch" - ] - }, - "hast-util-whitespace@3.0.0": { - "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", - "dependencies": [ - "@types/hast" - ] - }, - "html-void-elements@3.0.0": { - "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==" - }, - "https-proxy-agent@7.0.6": { - "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "dependencies": [ - "agent-base", - "debug" - ] - }, - "json-bigint@1.0.0": { - "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", - "dependencies": [ - "bignumber.js" - ] - }, - "json-schema-to-ts@3.1.1": { - "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==", - "dependencies": [ - "@babel/runtime", - "ts-algebra" - ] - }, - "json5@2.2.3": { - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "bin": true - }, - "jwa@2.0.1": { - "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", - "dependencies": [ - "buffer-equal-constant-time", - "ecdsa-sig-formatter", - "safe-buffer" - ] - }, - "jws@4.0.1": { - "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", - "dependencies": [ - "jwa", - "safe-buffer" - ] - }, - "linkify-it@5.0.2": { - "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", - "dependencies": [ - "uc.micro" - ] - }, - "long@5.3.2": { - "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==" - }, - "lru-cache@11.5.2": { - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==" - }, - "markdown-exit@1.3.0": { - "integrity": "sha512-bsqlcm3Hk1ukcG1Al83pp3JjVobu4w1mpZz47OzLw8bCY8XchkCX+PXC32l2TH4nZ7p5WFg2NwpnLDXkY1X7Yw==", - "dependencies": [ - "@types/linkify-it", - "@types/mdurl", - "entities", - "linkify-it", - "mdurl", - "punycode.js", - "uc.micro" - ] - }, - "mdast-util-to-hast@13.2.1": { - "integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==", - "dependencies": [ - "@types/hast", - "@types/mdast", - "@ungap/structured-clone", - "devlop", - "micromark-util-sanitize-uri", - "trim-lines", - "unist-util-position", - "unist-util-visit", - "vfile" - ] - }, - "mdurl@2.1.0": { - "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==" - }, - "mhchemparser@4.2.1": { - "integrity": "sha512-kYmyrCirqJf3zZ9t/0wGgRZ4/ZJw//VwaRVGA75C4nhE60vtnIzhl9J9ndkX/h6hxSN7pjg/cE0VxbnNM+bnDQ==" - }, - "micromark-util-character@2.1.1": { - "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", - "dependencies": [ - "micromark-util-symbol", - "micromark-util-types" - ] - }, - "micromark-util-encode@2.0.1": { - "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==" - }, - "micromark-util-sanitize-uri@2.0.1": { - "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", - "dependencies": [ - "micromark-util-character", - "micromark-util-encode", - "micromark-util-symbol" - ] - }, - "micromark-util-symbol@2.0.1": { - "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==" - }, - "micromark-util-types@2.0.2": { - "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==" - }, - "minimatch@10.2.6": { - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", - "dependencies": [ - "brace-expansion" - ] - }, - "minipass@7.1.3": { - "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==" - }, - "mj-context-menu@1.0.0": { - "integrity": "sha512-OSgBFQRCVhrZwRa9lhqnKcJU92dd/YXgBjup0uyeuj9bOaVsf4myOyrjU4PfhYkdDk6AqVUTov7v5uFMvIbduA==", - "dependencies": [ - "rimraf" - ] - }, - "ms@2.1.3": { - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, - "mute-stream@3.0.0": { - "integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==" - }, - "node-domexception@1.0.0": { - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "deprecated": true - }, - "node-fetch@3.3.2": { - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "dependencies": [ - "data-uri-to-buffer", - "fetch-blob", - "formdata-polyfill" - ] - }, - "oniguruma-parser@0.12.2": { - "integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==" - }, - "oniguruma-to-es@4.3.6": { - "integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==", - "dependencies": [ - "oniguruma-parser", - "regex", - "regex-recursion" - ] - }, - "openai@7.21.0": { - "integrity": "sha512-APwDcMhduWCSkKDLF4VZtAC5MGLRdJ0l+PUirz2fuSPXo/LNfEe8OuJVWOk8iJbO55sd8F5aOXvx8cfR5Eax1g==" - }, - "p-retry@4.6.2": { - "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", - "dependencies": [ - "@types/retry", - "retry" - ] - }, - "package-json-from-dist@1.0.1": { - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==" - }, - "path-scurry@2.0.2": { - "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", - "dependencies": [ - "lru-cache", - "minipass" - ] - }, - "property-information@7.2.0": { - "integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==" - }, - "protobufjs@7.6.6": { - "integrity": "sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg==", - "dependencies": [ - "@protobufjs/aspromise", - "@protobufjs/base64", - "@protobufjs/codegen", - "@protobufjs/eventemitter", - "@protobufjs/fetch", - "@protobufjs/float", - "@protobufjs/path", - "@protobufjs/pool", - "@protobufjs/utf8", - "@types/node", - "long" - ], - "scripts": true - }, - "punycode.js@2.3.1": { - "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==" - }, - "regex-recursion@6.0.2": { - "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==", - "dependencies": [ - "regex-utilities" - ] - }, - "regex-utilities@2.3.0": { - "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==" - }, - "regex@6.1.0": { - "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==", - "dependencies": [ - "regex-utilities" - ] - }, - "remeda@2.45.0": { - "integrity": "sha512-CTftZ0GJSox3CH77OhJemj20sXXUScH/kpkExD6t2LP3IG+mPKASBMFkbvWtsvzhU+54gKcgH38WWVihfr7bCA==" - }, - "retry@0.13.1": { - "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==" - }, - "rimraf@6.1.3": { - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", - "dependencies": [ - "glob", - "package-json-from-dist" - ], - "bin": true - }, - "safe-buffer@5.2.1": { - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - }, - "shiki@4.4.3": { - "integrity": "sha512-Mb/GvXPHBAXdgGIcnfU5L3ldpn1XcxrGkPHwqgRx17/I2XRfqlFKk2vGkHWINn1kdXvzJZeuO3is6I9KLPFm0g==", - "dependencies": [ - "@shikijs/core", - "@shikijs/engine-javascript", - "@shikijs/engine-oniguruma", - "@shikijs/langs", - "@shikijs/themes", - "@shikijs/types", - "@shikijs/vscode-textmate", - "@types/hast" - ] - }, - "signal-exit@4.1.0": { - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==" - }, - "space-separated-tokens@2.0.2": { - "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==" - }, - "speech-rule-engine@5.0.0-rc.4": { - "integrity": "sha512-3dFcH2QtQNhtvUUc09TxoaEK4WG03B9Z57krFG9jocrKykKGu35BhIkWr0vgEAxZZomEWkeluff69y/EbYzP4Q==", - "dependencies": [ - "@xmldom/xmldom", - "commander@14.0.3", - "wicked-good-xpath" - ], - "bin": true - }, - "standardwebhooks@1.1.1": { - "integrity": "sha512-bCbX9ZEyFkWPsRz7Bl3NuQUJohmwGSev/yhr7vhaGPlc4AfIrspIRa6cPTBuI1ItmrTDJ4d/S2hCsfe4+vQGnQ==", - "dependencies": [ - "@stablelib/base64", - "fast-sha256" - ] - }, - "stringify-entities@4.0.4": { - "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", - "dependencies": [ - "character-entities-html4", - "character-entities-legacy" - ] - }, - "supports-color@10.2.2": { - "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==" - }, - "supports-hyperlinks@4.5.0": { - "integrity": "sha512-ZW2OvfeCXrNTbLakPUzjQG922EeGCOteFSVoek5DKStTh898wf7zgtuFlzQN8HfZCxC3Eh02yJVrRW51hADf+w==", - "dependencies": [ - "has-flag", - "supports-color" - ] - }, - "trim-lines@3.0.1": { - "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==" - }, - "ts-algebra@2.0.0": { - "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==" - }, - "ts-pattern@5.9.0": { - "integrity": "sha512-6s5V71mX8qBUmlgbrfL33xDUwO0fq48rxAu2LBE11WBeGdpCPOsXksQbZJHvHwhrd3QjUusd3mAOM5Gg0mFBLg==" - }, - "uc.micro@2.1.0": { - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==" - }, - "undici-types@8.3.0": { - "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==" - }, - "unist-util-is@6.0.1": { - "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==", - "dependencies": [ - "@types/unist" - ] - }, - "unist-util-position@5.0.0": { - "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", - "dependencies": [ - "@types/unist" - ] - }, - "unist-util-stringify-position@4.0.0": { - "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", - "dependencies": [ - "@types/unist" - ] - }, - "unist-util-visit-parents@6.0.2": { - "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==", - "dependencies": [ - "@types/unist", - "unist-util-is" - ] - }, - "unist-util-visit@5.1.0": { - "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==", - "dependencies": [ - "@types/unist", - "unist-util-is", - "unist-util-visit-parents" - ] - }, - "vfile-message@4.0.3": { - "integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==", - "dependencies": [ - "@types/unist", - "unist-util-stringify-position" - ] - }, - "vfile@6.0.3": { - "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", - "dependencies": [ - "@types/unist", - "vfile-message" - ] - }, - "web-streams-polyfill@3.3.3": { - "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==" - }, - "wicked-good-xpath@1.3.0": { - "integrity": "sha512-Gd9+TUn5nXdwj/hFsPVx5cuHHiF5Bwuc30jZ4+ronF1qHK5O7HD0sgmXWSEgwKquT3ClLoKPVbO6qGwVwLzvAw==" - }, - "ws@8.21.3": { - "integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==" - }, - "zwitch@2.0.4": { - "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==" - } - }, - "redirects": { - "https://esm.sh/ansi-regex@^6.2.2?target=denonext": "https://esm.sh/ansi-regex@6.2.2?target=denonext", - "https://esm.sh/ansi-styles@^6.2.1?target=denonext": "https://esm.sh/ansi-styles@6.2.3?target=denonext", - "https://esm.sh/emoji-regex@^10.3.0?target=denonext": "https://esm.sh/emoji-regex@10.6.0?target=denonext", - "https://esm.sh/get-east-asian-width@^1.0.0?target=denonext": "https://esm.sh/get-east-asian-width@1.5.0?target=denonext", - "https://esm.sh/string-width@^7.0.0?target=denonext": "https://esm.sh/string-width@7.2.0?target=denonext", - "https://esm.sh/strip-ansi@^7.1.0?target=denonext": "https://esm.sh/strip-ansi@7.2.0?target=denonext" - }, - "remote": { - "https://esm.sh/ansi-regex@6.2.2/denonext/ansi-regex.mjs": "12f0f0a97b9a2404badfe1012dd335741d0951875ca8c307952dc04c3eafb9df", - "https://esm.sh/ansi-regex@6.2.2?target=denonext": "11b2548258056b692770f9f515af0fb3bffac490258721a8024550308c00787d", - "https://esm.sh/ansi-styles@6.2.3/denonext/ansi-styles.mjs": "56a9ffc05be307f2fee9bbd0511c6788d2e2fcf488397499a244faaff22885e5", - "https://esm.sh/ansi-styles@6.2.3?target=denonext": "f39a6f5f58e408d33514205e0cb6e0867492890acce62aa5f4b8ca9b30bda654", - "https://esm.sh/emoji-regex@10.6.0/denonext/emoji-regex.mjs": "bec0264591b37a7132b080ed5586e3fc577392b1444230d973d7209d04f4f6e5", - "https://esm.sh/emoji-regex@10.6.0?target=denonext": "0b0ed0e68f224d09d771339aaf83dd19d31c149e6fb1213ea3a12ef8ee977188", - "https://esm.sh/get-east-asian-width@1.5.0/denonext/get-east-asian-width.mjs": "21fed07d6e32091da454a333694a73b3f9a8e0297dbe392d9ce5f7445ef5b941", - "https://esm.sh/get-east-asian-width@1.5.0?target=denonext": "9566eef7b4212a84122c03cee07803667214a62ffa381b97ed5470430ee88d20", - "https://esm.sh/markdown-table@3.0.4": "118bbe611f9ab1c3f771d089fb05118ab3a863a9f860a5bdaccb508301b65cea", - "https://esm.sh/markdown-table@3.0.4/denonext/markdown-table.mjs": "c7d81a7a273381ec526b7c49ca14dc5955143cd62c3b5771eb46b9a19ba58d15", - "https://esm.sh/string-width@7.2.0": "288b87103bb29550239fb06990b1a8081101083e1f5715b28ce93efc4b8f732a", - "https://esm.sh/string-width@7.2.0/denonext/string-width.mjs": "329caba194cd7e62a0d893c070d9a88bbc5123e70e7d4076dbf6b0e4a7b925ce", - "https://esm.sh/string-width@7.2.0?target=denonext": "288b87103bb29550239fb06990b1a8081101083e1f5715b28ce93efc4b8f732a", - "https://esm.sh/strip-ansi@7.2.0/denonext/strip-ansi.mjs": "d68c51feeffe74fb5cc50e2e213ff3a32bf1cd1b0ffeb137c88084f0522668d2", - "https://esm.sh/strip-ansi@7.2.0?target=denonext": "ee5a42ccb2d030ee8cc73bd3eb5ab01d535acc5db7adcc4a13a1e757b04a4ee6", - "https://esm.sh/wrap-ansi@9.0.0": "7ee14b566cbc88d323870003beca627583e72b028219f9cd251f5717c4ddc307", - "https://esm.sh/wrap-ansi@9.0.0/denonext/wrap-ansi.mjs": "214f0bc950fb6a2649f886018557a840a7c95be36edccc9c37c9813445e02f43" - }, - "workspace": { - "dependencies": [ - "jsr:@david/dax@0.49", - "jsr:@std/assert@^1.0.19", - "jsr:@std/encoding@^1.0.11", - "jsr:@std/io@~0.225.3", - "jsr:@std/path@^1.1.6", - "npm:@anthropic-ai/sdk@0.123.0", - "npm:@commander-js/extra-typings@15", - "npm:@google/genai@2.21.0", - "npm:@inquirer/core@12", - "npm:@mathjax/src@4.1.3", - "npm:@resvg/resvg-wasm@2.6.2", - "npm:@shikijs/cli@^4.4.3", - "npm:ansis@^4.3.1", - "npm:arktype@^2.2.3", - "npm:commander@15", - "npm:json5@^2.2.3", - "npm:markdown-exit@^1.3.0", - "npm:openai@7.21.0", - "npm:remeda@^2.45.0", - "npm:supports-hyperlinks@^4.5.0", - "npm:ts-pattern@^5.9.0" - ] - } -} diff --git a/display.ts b/display.ts index 71f3a67..fa41a37 100644 --- a/display.ts +++ b/display.ts @@ -1,13 +1,14 @@ import { markdownTable } from "markdown-table" -import { writeAll } from "@std/io" +import { readFile } from "node:fs/promises" +import process from "node:process" -import { Chat, type ChatMessage } from "./types.ts" +import type { Chat, ChatMessage } from "./types.ts" import { models, systemBase } from "./models.ts" import { renderMarkdown } from "./md-render.ts" import { imageColumns, kittyPng, supportsKittyGraphics } from "./terminal-image.ts" export async function renderMd(md: string, raw = false) { - if (Deno.stdout.isTerminal() && !raw) { + if (process.stdout.isTTY && !raw) { console.log(await renderMarkdown(md)) } else { console.log(md) @@ -123,7 +124,7 @@ export function metaLineMd(msg: ChatMessage): string { export async function renderMetaToStderr(msg: ChatMessage) { const meta = metaLineMd(msg) if (!meta) return - const text = Deno.stderr.isTerminal() ? await renderMarkdown(meta) : meta + const text = process.stderr.isTTY ? await renderMarkdown(meta) : meta console.error() console.error(text) console.error() @@ -265,11 +266,10 @@ export async function renderResponse(msg: ChatMessage, opts: DisplayOpts) { await renderMd(messageContentMd(msg, getMode(opts)), false) if (msg.role === "assistant" && msg.images && supportsKittyGraphics()) { for (const path of msg.images) { - const png = await Deno.readFile(path) - await writeAll( - Deno.stdout, - new TextEncoder().encode(kittyPng(png, imageColumns(png, Deno.consoleSize()))), - ) + const png = await readFile(path) + const { columns, rows } = process.stdout + const data = kittyPng(png, imageColumns(png, { columns, rows })) + await new Promise((resolve) => process.stdout.write(data, resolve)) } } } diff --git a/display_test.ts b/display_test.ts index 2501752..c76432d 100644 --- a/display_test.ts +++ b/display_test.ts @@ -1,4 +1,5 @@ -import { assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" import { chatToMd, formatElapsed, metaLineMd } from "./display.ts" import { systemBase } from "./models.ts" import type { Chat, ChatMessage } from "./types.ts" @@ -15,7 +16,7 @@ const assistantMessage = (effort?: string): ChatMessage => ({ effort, }) -Deno.test("chatToMd includes every attached image in order", () => { +test("chatToMd includes every attached image in order", () => { const chat: Chat = { id: "images", createdAt: new Date(0), @@ -28,60 +29,60 @@ Deno.test("chatToMd includes every attached image in order", () => { }], } const md = chatToMd({ chat }) - assertEquals( + assert.deepEqual( md.includes("[Image 1 (inline)]\n\n[Image 2](https://example.com/second.jpg)"), true, ) }) -Deno.test("formatElapsed - seconds only", () => { - assertEquals(formatElapsed(5000), "5s") - assertEquals(formatElapsed(30000), "30s") +test("formatElapsed - seconds only", () => { + assert.deepEqual(formatElapsed(5000), "5s") + assert.deepEqual(formatElapsed(30000), "30s") }) -Deno.test("formatElapsed - minutes and seconds", () => { - assertEquals(formatElapsed(65000), "1m5s") - assertEquals(formatElapsed(125000), "2m5s") +test("formatElapsed - minutes and seconds", () => { + assert.deepEqual(formatElapsed(65000), "1m5s") + assert.deepEqual(formatElapsed(125000), "2m5s") }) -Deno.test("formatElapsed - fractional seconds", () => { - assertEquals(formatElapsed(1500), "1.5s") - assertEquals(formatElapsed(2750), "2.75s") +test("formatElapsed - fractional seconds", () => { + assert.deepEqual(formatElapsed(1500), "1.5s") + assert.deepEqual(formatElapsed(2750), "2.75s") }) -Deno.test("formatElapsed - fractional seconds truncated in minutes", () => { +test("formatElapsed - fractional seconds truncated in minutes", () => { // 90.5 seconds = 1m30s (seconds truncated to integer when minutes > 0) - assertEquals(formatElapsed(90500), "1m30s") + assert.deepEqual(formatElapsed(90500), "1m30s") }) -Deno.test("formatElapsed - zero", () => { - assertEquals(formatElapsed(0), "0s") +test("formatElapsed - zero", () => { + assert.deepEqual(formatElapsed(0), "0s") }) -Deno.test("formatElapsed - large values", () => { - assertEquals(formatElapsed(3600000), "60m0s") // 1 hour +test("formatElapsed - large values", () => { + assert.deepEqual(formatElapsed(3600000), "60m0s") // 1 hour }) -Deno.test("metaLineMd abbreviates known reasoning efforts", () => { - assertEquals( +test("metaLineMd abbreviates known reasoning efforts", () => { + assert.deepEqual( metaLineMd(assistantMessage("minimal")).startsWith("`gpt-5.6-sol` (min) |"), true, ) - assertEquals( + assert.deepEqual( metaLineMd(assistantMessage("medium")).startsWith("`gpt-5.6-sol` (med) |"), true, ) }) -Deno.test("metaLineMd passes through unknown efforts and preserves legacy output", () => { - assertEquals( +test("metaLineMd passes through unknown efforts and preserves legacy output", () => { + assert.deepEqual( metaLineMd(assistantMessage("future")), "`gpt-5.6-sol` (future) | 1s | $0 | 1 -> 2", ) - assertEquals(metaLineMd(assistantMessage()), "`gpt-5.6-sol` | 1s | $0 | 1 -> 2") + assert.deepEqual(metaLineMd(assistantMessage()), "`gpt-5.6-sol` | 1s | $0 | 1 -> 2") }) -Deno.test("chatToMd ignores date differences in the default system prompt", () => { +test("chatToMd ignores date differences in the default system prompt", () => { // Simulate a chat created on a previous day: same default prompt but with a // stale date baked in. It should still be treated as the default prompt. const stalePrompt = systemBase.replace( @@ -94,9 +95,9 @@ Deno.test("chatToMd ignores date differences in the default system prompt", () = messages: [assistantMessage()], createdAt: new Date(0), } - assertEquals(chatToMd({ chat }).includes("**System prompt:**"), false) + assert.deepEqual(chatToMd({ chat }).includes("**System prompt:**"), false) // A genuinely customized prompt is still reported. const chatCustom: Chat = { ...chat, systemPrompt: stalePrompt + "\n- extra" } - assertEquals(chatToMd({ chat: chatCustom }).includes("**System prompt:**"), true) + assert.deepEqual(chatToMd({ chat: chatCustom }).includes("**System prompt:**"), true) }) diff --git a/errors.ts b/errors.ts index d4b3bc5..15ef348 100644 --- a/errors.ts +++ b/errors.ts @@ -3,3 +3,8 @@ * error message instead of a stack trace. */ export class ValidationError extends Error {} + +/** Whether `e` is a Node system error with the given code, like `ENOENT`. */ +export function isErrno(e: unknown, code: string): boolean { + return e instanceof Error && (e as { code?: unknown }).code === code +} diff --git a/image-input.ts b/image-input.ts new file mode 100644 index 0000000..fa4ce0d --- /dev/null +++ b/image-input.ts @@ -0,0 +1,193 @@ +import { Buffer } from "node:buffer" +import { execFile } from "node:child_process" +import { mkdtemp, readFile, realpath, rm } from "node:fs/promises" +import { tmpdir } from "node:os" +import { join } from "node:path" +import process from "node:process" +import $ from "dax" + +import { isErrno, ValidationError } from "./errors.ts" + +const IMAGE_MIME_TYPES = [ + "image/png", + "image/jpeg", + "image/gif", + "image/webp", +] as const +export type ImageMimeType = typeof IMAGE_MIME_TYPES[number] + +function isImageMimeType(s: string): s is ImageMimeType { + return (IMAGE_MIME_TYPES as readonly string[]).includes(s) +} + +const EXT_MIME: Record = { + png: "image/png", + jpg: "image/jpeg", + jpeg: "image/jpeg", + gif: "image/gif", + webp: "image/webp", +} + +/** Parse a data URL into image media type and raw base64 payload, or null. + * Returns null for non-data URLs or unsupported media types. */ +export function parseDataUrl( + url: string, +): { mediaType: ImageMimeType; data: string } | null { + const m = /^data:([^;]+);base64,(.+)$/s.exec(url) + if (!m || !isImageMimeType(m[1])) return null + return { mediaType: m[1], data: m[2] } +} + +/** + * Read a PNG image from the macOS clipboard via `osascript`. The clipboard + * lives in NSPasteboard, so we have to go through an OS-level helper; we use + * osascript because it ships with macOS (no install step). Returns the raw + * bytes; only PNG is supported, which covers screenshots and browser + * "copy image" out of the box. + */ +async function readClipboardImage(): Promise { + if (process.platform !== "darwin") { + throw new ValidationError( + "Clipboard image paste is only supported on macOS", + ) + } + const tmpPath = join(tmpdir(), `llm-clipboard-${crypto.randomUUID()}.png`) + try { + const result = await $`osascript \ + -e ${`set png_data to (the clipboard as «class PNGf»)`} \ + -e ${`set f to open for access POSIX file ${ + JSON.stringify(tmpPath) + } with write permission`} \ + -e ${`set eof f to 0`} \ + -e ${`write png_data to f`} \ + -e ${`close access f`}` + .stderr("piped").noThrow() + if (result.code !== 0) { + // osascript -1700 = "can't make ... into type PNGf" → no image on clipboard + const noImage = /-1700|class PNGf/.test(result.stderr) + throw new ValidationError( + noImage + ? "No image found in clipboard" + : `osascript failed: ${result.stderr.trim()}`, + ) + } + return await readFile(tmpPath) + } finally { + await rm(tmpPath, { force: true }) + } +} + +/** Runs `sips` with the given args. Rejects only if it can't be started. */ +export type SipsRunner = (args: string[]) => Promise<{ code: number; stderr: string }> + +const execSips: SipsRunner = (args) => + new Promise((resolve, reject) => { + execFile("sips", args, (error, _stdout, stderr) => { + // A string code like ENOENT means the process never ran. + if (typeof error?.code === "string") reject(error) + else resolve({ code: error ? error.code ?? 1 : 0, stderr }) + }) + }) + +/** Convert a local HEIC/HEIF through macOS's optional image converter. */ +async function convertHeicImage(value: string, runSips: SipsRunner): Promise { + let sourcePath: string + try { + sourcePath = await realpath(value) + } catch (e) { + const msg = e instanceof Error ? e.message : String(e) + throw new ValidationError(`Could not read image at '${value}': ${msg}`) + } + const tmpDir = await mkdtemp(join(tmpdir(), "llm-heic-")) + try { + const outputPath = join(tmpDir, "converted.jpg") + let result: Awaited> + try { + result = await runSips([ + "--setProperty", + "format", + "jpeg", + "--setProperty", + "formatOptions", + "90", + sourcePath, + "--out", + outputPath, + ]) + } catch (e) { + if (isErrno(e, "ENOENT")) { + throw new ValidationError( + "HEIC conversion requires macOS's 'sips'. Convert the image to JPEG or PNG first.", + ) + } + throw e + } + if (result.code !== 0) { + const error = result.stderr.trim() || `exit ${result.code}` + throw new ValidationError(`Could not convert HEIC image at '${value}': ${error}`) + } + let bytes: Uint8Array + try { + bytes = await readFile(outputPath) + } catch (e) { + if (isErrno(e, "ENOENT")) { + throw new ValidationError( + `Could not convert HEIC image at '${value}': sips did not produce a JPEG`, + ) + } + throw e + } + // sips can exit successfully after writing only JPEG headers if encoding fails. + if ( + bytes.length < 4 || bytes[0] !== 0xff || bytes[1] !== 0xd8 || + bytes.at(-2) !== 0xff || bytes.at(-1) !== 0xd9 + ) { + throw new ValidationError( + `Could not convert HEIC image at '${value}': incomplete JPEG`, + ) + } + return bytes + } finally { + await rm(tmpDir, { recursive: true }) + } +} + +/** + * Resolve `--image ` to a URL string. The sentinel `clipboard` pulls a + * PNG from the macOS clipboard. `http(s)` URLs pass through. Any other value + * is treated as a local file path, read, base64-encoded, and returned as a + * `data:` URL. Local HEIC/HEIF files are converted to JPEG through `sips`. + */ +export async function resolveImage( + value: string, + runSips: SipsRunner = execSips, +): Promise { + if (value === "clipboard") { + const bytes = await readClipboardImage() + return `data:image/png;base64,${Buffer.from(bytes).toString("base64")}` + } + if (/^https?:\/\//i.test(value)) return value + + const ext = value.split(".").pop()?.toLowerCase() ?? "" + if (ext === "heic" || ext === "heif") { + const bytes = await convertHeicImage(value, runSips) + return `data:image/jpeg;base64,${Buffer.from(bytes).toString("base64")}` + } + + let bytes: Uint8Array + try { + bytes = await readFile(value) + } catch (e) { + const msg = e instanceof Error ? e.message : String(e) + throw new ValidationError(`Could not read image at '${value}': ${msg}`) + } + const mediaType = EXT_MIME[ext] + if (!mediaType) { + throw new ValidationError( + `Unsupported image extension '.${ext}'. Supported: ${ + [...Object.keys(EXT_MIME), "heic/heif (requires sips)"].join(", ") + }`, + ) + } + return `data:${mediaType};base64,${Buffer.from(bytes).toString("base64")}` +} diff --git a/image-input_test.ts b/image-input_test.ts new file mode 100644 index 0000000..7d2cfde --- /dev/null +++ b/image-input_test.ts @@ -0,0 +1,160 @@ +import assert from "node:assert/strict" +import { existsSync } from "node:fs" +import { mkdtemp, readFile, realpath, rm, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { dirname, join } from "node:path" +import { test } from "node:test" + +import { ValidationError } from "./errors.ts" +import { parseDataUrl, resolveImage, type SipsRunner } from "./image-input.ts" +import { errorIncluding } from "./testing.ts" + +test("parseDataUrl - valid png data URL", () => { + assert.deepEqual(parseDataUrl("data:image/png;base64,iVBORw0KGgo="), { + mediaType: "image/png", + data: "iVBORw0KGgo=", + }) +}) + +test("parseDataUrl - base64 payload with newlines", () => { + // /s flag must be set on the regex so . matches newlines + assert.deepEqual(parseDataUrl("data:image/jpeg;base64,AAAA\nBBBB\nCCCC"), { + mediaType: "image/jpeg", + data: "AAAA\nBBBB\nCCCC", + }) +}) + +test("parseDataUrl - non-data URL returns null", () => { + assert.deepEqual(parseDataUrl("https://example.com/foo.png"), null) +}) + +test("parseDataUrl - missing base64 marker returns null", () => { + assert.deepEqual(parseDataUrl("data:image/png,iVBORw0KGgo="), null) +}) + +test("parseDataUrl - empty string returns null", () => { + assert.deepEqual(parseDataUrl(""), null) +}) + +test("resolveImage - http URL passes through", async () => { + const url = "http://example.com/cat.png" + assert.deepEqual(await resolveImage(url), url) +}) + +test("resolveImage - https URL passes through", async () => { + const url = "https://example.com/cat.png" + assert.deepEqual(await resolveImage(url), url) +}) + +async function withFakeSips( + convert: SipsRunner, + test: (input: string, calls: string[][], sips: SipsRunner) => Promise, + extension = "HEIC", +) { + const dir = await mkdtemp(join(tmpdir(), "llm-sips-test-")) + const input = join(dir, `phone photo.${extension}`) + const calls: string[][] = [] + await writeFile(input, new Uint8Array([1, 2, 3])) + const sips: SipsRunner = (args) => { + calls.push(args) + return convert(args) + } + try { + await test(input, calls, sips) + } finally { + await rm(dir, { recursive: true }) + } +} + +const commandOutput = (code = 0, stderr = "") => ({ code, stderr }) + +for (const extension of ["HEIC", "heif"]) { + test(`resolveImage converts ${extension} to JPEG and cleans up without changing the original`, async () => { + await withFakeSips(async (args) => { + await writeFile(args.at(-1)!, new Uint8Array([0xff, 0xd8, 0xff, 0xd9])) + return commandOutput() + }, async (input, calls, sips) => { + assert.deepEqual(await resolveImage(input, sips), "data:image/jpeg;base64,/9j/2Q==") + assert.deepEqual(calls.length, 1) + assert.deepEqual(calls[0].slice(0, -2), [ + "--setProperty", + "format", + "jpeg", + "--setProperty", + "formatOptions", + "90", + await realpath(input), + ]) + assert.deepEqual(calls[0].at(-2), "--out") + assert.deepEqual([...await readFile(input)], [1, 2, 3]) + assert.deepEqual(existsSync(dirname(calls[0].at(-1)!)), false) + }, extension) + }) +} + +test("resolveImage explains missing sips and cleans up", async () => { + await withFakeSips( + () => Promise.reject(Object.assign(new Error("spawn sips ENOENT"), { code: "ENOENT" })), + async (input, calls, sips) => { + await assert.rejects( + () => resolveImage(input, sips), + errorIncluding( + ValidationError, + "HEIC conversion requires macOS's 'sips'. Convert the image to JPEG or PNG first.", + ), + ) + assert.deepEqual(calls.length, 1) + assert.deepEqual(existsSync(dirname(calls[0].at(-1)!)), false) + }, + ) +}) + +test("resolveImage reports conversion failure and cleans up", async () => { + await withFakeSips( + () => Promise.resolve(commandOutput(13, "Invalid HEIC")), + async (input, calls, sips) => { + await assert.rejects( + () => resolveImage(input, sips), + errorIncluding(ValidationError, "Invalid HEIC"), + ) + assert.deepEqual(calls.length, 1) + assert.deepEqual(existsSync(dirname(calls[0].at(-1)!)), false) + }, + ) +}) + +test("resolveImage rejects incomplete sips output even when the process succeeds", async () => { + await withFakeSips(async (args) => { + await writeFile(args.at(-1)!, new Uint8Array([0xff, 0xd8, 0xff, 0xe0])) + return commandOutput() + }, async (input, calls, sips) => { + await assert.rejects( + () => resolveImage(input, sips), + errorIncluding(ValidationError, "incomplete JPEG"), + ) + assert.deepEqual(calls.length, 1) + assert.deepEqual(existsSync(dirname(calls[0].at(-1)!)), false) + }) +}) + +test("resolveImage reports missing converter output and cleans up", async () => { + await withFakeSips(() => Promise.resolve(commandOutput()), async (input, calls, sips) => { + await assert.rejects( + () => resolveImage(input, sips), + errorIncluding(ValidationError, "did not produce a JPEG"), + ) + assert.deepEqual(calls.length, 1) + assert.deepEqual(existsSync(dirname(calls[0].at(-1)!)), false) + }) +}) + +test("resolveImage leaves ordinary local images unchanged without invoking sips", async () => { + await withFakeSips( + () => Promise.reject(new Error("Should not run sips")), + async (input, calls, sips) => { + assert.deepEqual(await resolveImage(input, sips), "data:image/png;base64,AQID") + assert.deepEqual(calls.length, 0) + }, + "png", + ) +}) diff --git a/main.ts b/main.ts index 1a3cc4f..140ed6c 100755 --- a/main.ts +++ b/main.ts @@ -1,12 +1,11 @@ -#! /usr/bin/env -S deno run --allow-env --allow-read --allow-write --allow-net --allow-run=gh,osascript,sips +#!/usr/bin/env node -import { readAll } from "@std/io" +import process from "node:process" +import { text } from "node:stream/consumers" import { Command, InvalidArgumentError, Option } from "@commander-js/extra-typings" -import $ from "@david/dax" +import $ from "dax" import { blueBright, bold, magentaBright, red } from "ansis" -import * as R from "remeda" - import { type Model, models, resolveModel, systemBase } from "./models.ts" import { chatToMd, @@ -20,7 +19,9 @@ import { renderResponse, shortDateFmt, } from "./display.ts" -import { parseMessageSpec, resolveImage } from "./utils.ts" +import { resolveImage } from "./image-input.ts" +import { parseMessageSpec } from "./message-spec.ts" +import { pick } from "./utils.ts" import { ValidationError } from "./errors.ts" import { type Chat, resolveThink, type ThinkOverride } from "./types.ts" import { @@ -34,9 +35,16 @@ import { } from "./adapters/mod.ts" import { History } from "./storage.ts" import { genMissingSummaries } from "./summarize.ts" -import { parseType } from "./schema.ts" import { requestProblems, usesBackground } from "./validate.ts" -import { alignColumns, formatPickerOptions, pickWithAction, singleLine } from "./picker.ts" +import { + alignColumns, + confirmed, + formatPickerOptions, + pickWithAction, + selectIndex, + selectIndexes, + singleLine, +} from "./picker.ts" const getLastModelId = (chat: Chat) => chat.messages.findLast((m) => m.role === "assistant")?.model @@ -65,7 +73,7 @@ function messagePickerOptions(messages: Chat["messages"]) { })) } -const bell = () => Deno.stdout.write(new TextEncoder().encode("\x07")) +const bell = () => new Promise((resolve) => process.stdout.write("\x07", resolve)) const makeAssMsg = (modelId: string, startTime: number, response: ModelResponse) => ({ role: "assistant" as const, @@ -82,9 +90,9 @@ const createChat = (systemPrompt: string): Chat => ({ messages: [], }) -// deno-lint-ignore no-explicit-any +// oxlint-disable-next-line typescript/no-explicit-any function renderError(e: any, opts: DisplayOpts = {}) { - Deno.exitCode = 1 + process.exitCode = 1 // keep stdout clean for scripts: JSON mode reports errors on stderr only if (opts.json) { const detail = e.response?.data ?? e.response?.error @@ -106,7 +114,7 @@ async function pollBackgroundResponse( if (!chat.background) throw new Error("No background response to poll") const { id, startedAt, modelId, effort } = chat.background - const showProgress = Deno.stdout.isTerminal() && !displayOpts.raw && !displayOpts.json + const showProgress = process.stdout.isTTY && !displayOpts.raw && !displayOpts.json const pb = showProgress ? $.progress("Waiting...") : null try { @@ -137,7 +145,7 @@ async function pollBackgroundResponse( } else { const { status } = chat.background delete chat.background - Deno.exitCode = 1 + process.exitCode = 1 console.log(`Background response ${status}`) } } finally { @@ -154,7 +162,7 @@ async function genResponse( displayOpts: DisplayOpts = {}, ) { // don't want progress spinner when piping output - const showProgress = Deno.stdout.isTerminal() && !displayOpts.raw && !displayOpts.json + const showProgress = process.stdout.isTTY && !displayOpts.raw && !displayOpts.json const label = chatInput.model.kind === "image" ? "Generating image..." : "Thinking..." const pb = showProgress ? $.progress(label) : null @@ -163,8 +171,8 @@ async function genResponse( const abortController = new AbortController() const sigintHandler = () => abortController.abort() const sigtermHandler = () => abortController.abort() - Deno.addSignalListener("SIGINT", sigintHandler) - Deno.addSignalListener("SIGTERM", sigtermHandler) + process.on("SIGINT", sigintHandler) + process.on("SIGTERM", sigtermHandler) try { const startTime = Date.now() @@ -179,8 +187,8 @@ async function genResponse( } catch (e: unknown) { renderError(e, displayOpts) } finally { - Deno.removeSignalListener("SIGINT", sigintHandler) - Deno.removeSignalListener("SIGTERM", sigtermHandler) + process.off("SIGINT", sigintHandler) + process.off("SIGTERM", sigtermHandler) if (pb) pb.finish() // otherwise it hangs around // terminal bell to indicate it's done if (showProgress) await bell() @@ -215,11 +223,10 @@ function promptTarget( /** Pick a model for forking from a user message, starting on `defaultId` if given */ async function pickModel(defaultId: string | undefined) { const textModels = models.filter((m) => m.kind !== "image") - const { index } = await $.select({ + const index = await selectIndex({ message: "Pick a model to answer", options: textModels.map((m) => m.id), initialIndex: Math.max(0, textModels.findIndex((m) => m.id === defaultId)), - noClear: true, }) return textModels[index] } @@ -228,12 +235,11 @@ async function pickModel(defaultId: string | undefined) { async function forkChat(chat: Chat) { if (chat.messages.length === 0) throw new ValidationError("Chat has no messages") - const { index: selectedIdx } = await $.select({ + const selectedIdx = await selectIndex({ message: "Pick a message to fork from", options: messagePickerOptions(chat.messages), // start on the latest answer so Enter continues it without asking for a model initialIndex: chat.messages.length - 1, - noClear: true, }) const selectedMessage = chat.messages[selectedIdx] @@ -272,7 +278,7 @@ async function historyPicker() { } await genMissingSummaries(history) - const chats = R.reverse(history) + const chats = history.toReversed() const picked = await pickWithAction({ message: "Chat history", options: chatPickerOptions(chats), @@ -298,7 +304,7 @@ async function historyPicker() { return case "delete": { const label = truncate(singleLine(chat.summary || "chat"), 60) - if (await $.maybeConfirm(`Delete "${label}"?`)) { + if (await confirmed(`Delete "${label}"?`, { clear: true })) { History.delete([chat.id]) console.log(`Deleted "${label}"`) } @@ -344,7 +350,7 @@ function modelInfoMd(modelArg: string) { function exit(msg: string): never { console.log(msg) - Deno.exit() + process.exit() } /** Commander option parser for integer values */ @@ -417,21 +423,23 @@ Examples: .action(async (message, opts) => { let outputSchema if (opts.outputSchema) { + // arktype takes ~70 ms to load, so only load it when it's needed + const { parseType } = await import("./schema.ts") try { outputSchema = parseType(opts.outputSchema) } catch (e) { console.error(e instanceof Error ? e.message : String(e)) - Deno.exit(1) + process.exit(1) } } const imageInputs = opts.image ?? [] const hasImages = imageInputs.length > 0 const msg = message.join(" ") - const piped = !Deno.stdin.isTerminal() + const piped = !process.stdin.isTTY const stdin = piped // read stdin to end - ? new TextDecoder().decode(await readAll(Deno.stdin)).trim() + ? (await text(process.stdin)).trim() : null // Input was piped but arrived empty — the upstream command likely failed or @@ -448,7 +456,7 @@ Examples: } const input = [stdin, msg].filter(Boolean).join("\n\n") - const displayOpts = R.pick(opts, ["raw", "verbose", "json"]) + const displayOpts = pick(opts, ["raw", "verbose", "json"]) const { chat, model } = promptTarget( !!opts.reply, opts.model, @@ -492,7 +500,7 @@ Examples: if (problems.length > 0) throw new ValidationError(problems.join("\n")) const image_urls = hasImages - ? await Promise.all(imageInputs.map(resolveImage)) + ? await Promise.all(imageInputs.map((value) => resolveImage(value))) : undefined chat.messages.push({ @@ -516,7 +524,7 @@ Examples: } if (!opts.ephemeral) History.save(chat, { current: true, touch: true }) await pollBackgroundResponse(chat, model, displayOpts) - // deno-lint-ignore no-explicit-any + // oxlint-disable-next-line typescript/no-explicit-any } catch (e: any) { renderError(e, displayOpts) } @@ -561,17 +569,15 @@ historyCmd await genMissingSummaries(history) if (history.length === 0) throw new ValidationError("No chat history") - const reversed = R.reverse(history) - const selected = await $.multiSelect({ + const reversed = history.toReversed() + const selected = await selectIndexes({ message: "Pick chats to delete", options: chatPickerOptions(reversed), - noClear: true, }) if (selected.length === 0) return const label = `${selected.length} chat${selected.length === 1 ? "" : "s"}` - const yes = await $.maybeConfirm(`Delete ${label}?`, { noClear: true }) - if (!yes) return - History.delete(selected.map((s) => reversed[s.index].id)) + if (!await confirmed(`Delete ${label}?`)) return + History.delete(selected.map((i) => reversed[i].id)) console.log(`Deleted ${label}`) }) @@ -581,8 +587,7 @@ historyCmd .action(async () => { const history = History.list() const n = history.length - const yes = await $.maybeConfirm(`Delete ${n} chats?`, { noClear: true }) - if (!yes) return + if (!await confirmed(`Delete ${n} chats?`)) return History.clear() console.log("Deleted chat history") }) @@ -677,7 +682,7 @@ bgCmd }) try { - await program.parseAsync(Deno.args, { from: "user" }) + await program.parseAsync() } catch (e) { if (e instanceof ValidationError) program.error(`error: ${e.message}`) throw e diff --git a/markdown-exit-terminal.ts b/markdown-exit-terminal.ts index 11b32d1..c8c4d70 100644 --- a/markdown-exit-terminal.ts +++ b/markdown-exit-terminal.ts @@ -1,4 +1,3 @@ -// deno-lint-ignore-file no-control-regex // // markdown-exit plugin that renders to ANSI-styled terminal output. // Install with md.use(terminalPlugin), then call md.renderAsync(src, env). @@ -6,6 +5,7 @@ // automatically by wrapping renderAsync. import type { MarkdownExit, RenderRule } from "markdown-exit" +import process from "node:process" import ansis, { blue, bold, cyan, dim, gray, italic, strikethrough, white } from "ansis" import stringWidth from "string-width" import supportsHyperlinks from "supports-hyperlinks" @@ -18,7 +18,7 @@ const { fg } = ansis const h1 = white.bg(63).bold const h2 = blue.bold -const codespan = fg(203).bg(236) +export const codespan = fg(203).bg(236) const tableBorder = gray const tableHeader = cyan.bold @@ -93,7 +93,7 @@ function freshState(): RenderState { } } -// deno-lint-ignore no-explicit-any +// oxlint-disable-next-line typescript/no-explicit-any function getState(env: any): RenderState { if (!env._termState) env._termState = freshState() return env._termState @@ -173,7 +173,7 @@ function postProcessTables(text: string): string { function reflowParagraphs(text: string, width: number): string { return text.replace(/^([^\n]+)\n\n/gm, (match, para) => { - if (/^(\s*(#|[*\-]|\d+\.)|│|╭|├|╰| {4})/.test(stripAnsi(para))) { + if (/^(\s*(#|[*-]|\d+\.)|│|╭|├|╰| {4})/.test(stripAnsi(para))) { return match } return reflowText(para, width) + "\n\n" @@ -185,7 +185,7 @@ function reflowParagraphs(text: string, width: number): string { export type TerminalEnv = MathEnv & { codeTheme?: string } function getColumns(): number { - return Deno.stdout.isTerminal() ? Deno.consoleSize().columns : 80 + return process.stdout.columns ?? 80 } function getWidth(): number { diff --git a/math-demo.ts b/math-demo.ts index a212f95..e1b2217 100644 --- a/math-demo.ts +++ b/math-demo.ts @@ -1,5 +1,6 @@ import { renderMd } from "./display.ts" +import { readFile } from "node:fs/promises" await renderMd( - await Deno.readTextFile(new URL("./fixtures/terminal-math.md", import.meta.url)), + await readFile(new URL("./fixtures/terminal-math.md", import.meta.url), "utf8"), ) diff --git a/math-image.ts b/math-image.ts index 0bd165d..d85ff64 100644 --- a/math-image.ts +++ b/math-image.ts @@ -8,6 +8,7 @@ import "@mathjax/src/js/input/tex/base/BaseConfiguration.js" import "@mathjax/src/js/input/tex/ams/AmsConfiguration.js" import "@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js" import { initWasm, Resvg } from "@resvg/resvg-wasm" +import { readFile } from "node:fs/promises" const adaptor = liteAdaptor() RegisterHTMLHandler(adaptor) @@ -28,7 +29,7 @@ export async function renderMathImage( color: string, ): Promise { await (wasm ??= initWasm( - Deno.readFile(new URL(import.meta.resolve("@resvg/resvg-wasm/index_bg.wasm"))), + readFile(new URL(import.meta.resolve("@resvg/resvg-wasm/index_bg.wasm"))), )) // A document per expression prevents user-defined macros leaking between messages. const doc = mathjax.document("", { diff --git a/md-render_test.ts b/md-render_test.ts index 3399538..d9c7273 100644 --- a/md-render_test.ts +++ b/md-render_test.ts @@ -1,6 +1,8 @@ -// deno-lint-ignore-file no-control-regex -import { assert, assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" +import process from "node:process" +import { codespan } from "./markdown-exit-terminal.ts" import { renderMarkdown } from "./md-render.ts" const ANSI_RE = new RegExp("\\x1b\\[[0-9;]*m|\\x1b\\]8;;[^\\x07]*\\x07", "g") @@ -8,7 +10,7 @@ const ANSI_RE = new RegExp("\\x1b\\[[0-9;]*m|\\x1b\\]8;;[^\\x07]*\\x07", "g") // unbreakable; normalize to regular spaces for visual-equality assertions. const stripAnsi = (s: string) => s.replace(ANSI_RE, "").replaceAll(" ", " ") -Deno.test("renderMarkdown reflows long blockquote text", async () => { +test("renderMarkdown reflows long blockquote text", async () => { const long = "word ".repeat(30).trim() // 149 chars, well over 77-char blockquote width const output = stripAnsi(await renderMarkdown(`> ${long}`)) const lines = output.split("\n") @@ -19,18 +21,18 @@ Deno.test("renderMarkdown reflows long blockquote text", async () => { ) }) -Deno.test("renderMarkdown handles nested blockquotes", async () => { +test("renderMarkdown handles nested blockquotes", async () => { const output = await renderMarkdown("> outer\n> > inner\n> back") assert(!output.includes("\x00")) - assertEquals(stripAnsi(output), " │ outer\n │\n │ │ inner\n │ │ back") + assert.deepEqual(stripAnsi(output), " │ outer\n │\n │ │ inner\n │ │ back") }) -Deno.test("renderMarkdown preserves list item paragraph breaks", async () => { +test("renderMarkdown preserves list item paragraph breaks", async () => { const output = await renderMarkdown("- first paragraph\n\n second paragraph") - assertEquals(stripAnsi(output), "* first paragraph\n second paragraph") + assert.deepEqual(stripAnsi(output), "* first paragraph\n second paragraph") }) -Deno.test("renderMarkdown sizes tables from visible link text", async () => { +test("renderMarkdown sizes tables from visible link text", async () => { const output = stripAnsi( await renderMarkdown("| h |\n| - |\n| [x](https://example.com) |"), ) @@ -39,15 +41,15 @@ Deno.test("renderMarkdown sizes tables from visible link text", async () => { const headerWidth = lines[1].slice(2, -2).trimEnd().length const bodyWidth = lines[3].slice(2, -2).trimEnd().length - assertEquals(paddedWidth, Math.max(3, headerWidth, bodyWidth)) + assert.deepEqual(paddedWidth, Math.max(3, headerWidth, bodyWidth)) }) -Deno.test("renderMarkdown sizes emoji grapheme clusters as width 2 in tables", async () => { +test("renderMarkdown sizes emoji grapheme clusters as width 2 in tables", async () => { const output = stripAnsi( await renderMarkdown("| x |\n| - |\n| 👨‍👩‍👧‍👦 |\n| 🇯🇵 |\n| 🏴‍☠️ |"), ) - assertEquals( + assert.deepEqual( output, [ "╭─────╮", @@ -61,14 +63,14 @@ Deno.test("renderMarkdown sizes emoji grapheme clusters as width 2 in tables", a ) }) -Deno.test("renderMarkdown keeps mixed-width emoji columns aligned", async () => { +test("renderMarkdown keeps mixed-width emoji columns aligned", async () => { const output = stripAnsi( await renderMarkdown( "| kind | value |\n| --- | --- |\n| family | 👨‍👩‍👧‍👦 |\n| flag | 🇯🇵 |\n| pirate | 🏴‍☠️ |", ), ) - assertEquals( + assert.deepEqual( output, [ "╭────────┬───────╮", @@ -82,36 +84,39 @@ Deno.test("renderMarkdown keeps mixed-width emoji columns aligned", async () => ) }) -Deno.test("renderMarkdown handles common inline markdown", async () => { +test("renderMarkdown handles common inline markdown", async () => { const output = stripAnsi( await renderMarkdown( "# Title\n\nParagraph with **bold**, *italic*, ~~strike~~, `code`, and [link](https://example.com).", ), ) - assertEquals( + assert.deepEqual( output, "# Title\n\nParagraph with bold, italic, strike, code , and link (https://example.com).", ) }) -Deno.test("renderMarkdown handles basic lists", async () => { +test("renderMarkdown handles basic lists", async () => { const output = stripAnsi( await renderMarkdown("- first\n- second\n - nested\n\n1. one\n2. two"), ) - assertEquals(output, "* first\n* second\n * nested\n\n1. one\n2. two") + assert.deepEqual(output, "* first\n* second\n * nested\n\n1. one\n2. two") }) -Deno.test("renderMarkdown handles basic fenced code blocks", async () => { +test("renderMarkdown handles basic fenced code blocks", async () => { const output = stripAnsi( await renderMarkdown("```ts\nconst x = 1\nconsole.log(x)\n```"), ) - assertEquals(output, " const x = 1\n console.log(x)") + assert.deepEqual(output, " const x = 1\n console.log(x)") }) -Deno.test("renderMarkdown keeps codespans on a single line when wrapped", async () => { +test("renderMarkdown keeps codespans on a single line when wrapped", { + // Without colors there is no styled span to split + skip: !codespan.open && "colors are disabled", +}, async () => { // wrap-ansi will split a styled codespan if it contains breakable spaces, // which either leaks bg color to end-of-line (BCE) or strands a lone styled // space at the line edge. Codespans pad with NBSP and replace internal @@ -121,29 +126,30 @@ Deno.test("renderMarkdown keeps codespans on a single line when wrapped", async "The type parameter `K extends PropertyKey` constrains keys to `string | number | symbol` — the only types JavaScript allows as object keys. This lets the return type be a precise `Record` rather than a loose `Record`.\n\n" + "Inside the loop, `result[key] ??= []` uses the operator: if `result[key]` is `undefined`, more text. The classic `if (!result[key]) result[key] = []; result[key].push(item);` form." - const origIsTerminal = Deno.stdout.isTerminal.bind(Deno.stdout) - const origConsoleSize = Deno.consoleSize - Deno.stdout.isTerminal = () => true + // The escape codes depend on the color level: `node --test` sets + // FORCE_COLOR=1 for test files when its own output is a terminal. + const { open, close } = codespan + // A codespan whose visible content is only whitespace means wrap-ansi sliced one out + const lone = new RegExp(`${RegExp.escape(open)}\\s*${RegExp.escape(close)}`) + + const { stdout } = process + const original = Object.getOwnPropertyDescriptors(stdout) + stdout.isTTY = true try { for (const columns of [50, 62, 70, 80, 85, 88, 90, 92, 95, 100, 120]) { - Deno.consoleSize = () => ({ columns, rows: 40 }) + stdout.columns = columns const out = await renderMarkdown(text) for (const [i, line] of out.split("\n").entries()) { - const opens = (line.match(/\x1b\[38;5;203m\x1b\[48;5;236m/g) ?? []).length - const closes = (line.match(/\x1b\[49m\x1b\[39m/g) ?? []).length - assertEquals( + const opens = line.split(open).length - 1 + const closes = line.split(close).length - 1 + assert.deepEqual( opens, closes, `columns=${columns} line ${i} has unbalanced codespan SGR: ${ JSON.stringify(line) }`, ) - // Catch the lone-styled-space artifact: a codespan whose visible - // content is only whitespace means wrap-ansi sliced one out. - const lone = new RegExp( - "\\x1b\\[38;5;203m\\x1b\\[48;5;236m\\s*\\x1b\\[49m\\x1b\\[39m", - ) - assertEquals( + assert.deepEqual( lone.test(line), false, `columns=${columns} line ${i} contains a whitespace-only codespan: ${ @@ -153,15 +159,17 @@ Deno.test("renderMarkdown keeps codespans on a single line when wrapped", async } } } finally { - Deno.stdout.isTerminal = origIsTerminal - Deno.consoleSize = origConsoleSize + for (const key of ["isTTY", "columns"] as const) { + if (original[key]) Object.defineProperty(stdout, key, original[key]) + else delete stdout[key] + } } }) -Deno.test("renderMarkdown handles simple tables", async () => { +test("renderMarkdown handles simple tables", async () => { const output = stripAnsi(await renderMarkdown("| a | b |\n| - | - |\n| 1 | 2 |")) - assertEquals( + assert.deepEqual( output, [ "╭─────┬─────╮", diff --git a/message-spec.ts b/message-spec.ts new file mode 100644 index 0000000..009cee9 --- /dev/null +++ b/message-spec.ts @@ -0,0 +1,49 @@ +import { ValidationError } from "./errors.ts" +import { range } from "./utils.ts" + +const parsePart = (part: string, msgCount: number): number[] => { + if (part === "even" || part === "odd") { + const start = part === "even" ? 2 : 1 + return range(start, msgCount + 1).filter((n) => n % 2 === (part === "even" ? 0 : 1)) + } + + if (/^\d+-\d+$/.test(part)) { + const [startStr, endStr] = part.split("-") + const start = Number(startStr) + const end = Number(endStr) + if (start > end) { + throw new ValidationError(`Invalid range: start > end in "${part}"`) + } + return range(start, end + 1) + } + + if (/^\d+$/.test(part)) { + return [Number(part)] + } + + throw new ValidationError( + part.includes("-") ? `Invalid range: "${part}"` : `Invalid message number: "${part}"`, + ) +} + +/** + * Parse a message spec like "1,3-4,7" into a sorted array of 0-based indices. + * Message numbers in the spec are 1-based (user-facing). The keywords "even" + * and "odd" expand to all even/odd message numbers. + * Throws if a range has start > end or if any number is out of bounds. + */ +export function parseMessageSpec(spec: string, msgCount: number): number[] { + const parts = spec.replaceAll(" ", "").split(",").filter((p) => p.length > 0) + const numbers = parts.flatMap((part) => parsePart(part, msgCount)) + const indices = [...new Set(numbers)].sort((a, b) => a - b) + + for (const num of indices) { + if (num < 1 || num > msgCount) { + throw new ValidationError( + `Message ${num} does not exist (chat has ${msgCount} messages)`, + ) + } + } + + return indices.map((n) => n - 1) // make 0-indexed +} diff --git a/message-spec_test.ts b/message-spec_test.ts new file mode 100644 index 0000000..53f2d79 --- /dev/null +++ b/message-spec_test.ts @@ -0,0 +1,104 @@ +import assert from "node:assert/strict" +import { test } from "node:test" + +import { ValidationError } from "./errors.ts" +import { parseMessageSpec } from "./message-spec.ts" +import { errorIncluding } from "./testing.ts" + +test("parseMessageSpec - single number", () => { + assert.deepEqual(parseMessageSpec("3", 5), [2]) +}) + +test("parseMessageSpec - multiple numbers", () => { + assert.deepEqual(parseMessageSpec("1,3,5", 5), [0, 2, 4]) +}) + +test("parseMessageSpec - range", () => { + assert.deepEqual(parseMessageSpec("2-4", 5), [1, 2, 3]) +}) + +test("parseMessageSpec - mixed numbers and ranges", () => { + assert.deepEqual(parseMessageSpec("1,3-4,7", 10), [0, 2, 3, 6]) +}) + +test("parseMessageSpec - even keyword", () => { + // 1-based even message numbers 2,4,6 -> 0-based + assert.deepEqual(parseMessageSpec("even", 6), [1, 3, 5]) +}) + +test("parseMessageSpec - odd keyword", () => { + // 1-based odd message numbers 1,3,5 -> 0-based + assert.deepEqual(parseMessageSpec("odd", 6), [0, 2, 4]) +}) + +test("parseMessageSpec - even/odd combine with numbers and dedupe", () => { + assert.deepEqual(parseMessageSpec("odd,2", 5), [0, 1, 2, 4]) +}) + +test("parseMessageSpec - out of order input returns sorted", () => { + assert.deepEqual(parseMessageSpec("7,1,3-4", 10), [0, 2, 3, 6]) +}) + +test("parseMessageSpec - duplicates are deduplicated", () => { + assert.deepEqual(parseMessageSpec("1,1,2-3,3", 5), [0, 1, 2]) +}) + +test("parseMessageSpec - whitespace is tolerated", () => { + assert.deepEqual(parseMessageSpec(" 1 , 3 - 4 , 7 ", 10), [0, 2, 3, 6]) +}) + +test("parseMessageSpec - range start > end throws", () => { + assert.throws( + () => parseMessageSpec("4-2", 5), + errorIncluding(ValidationError, "Invalid range: start > end"), + ) +}) + +test("parseMessageSpec - message number too high throws", () => { + assert.throws( + () => parseMessageSpec("1,10", 5), + errorIncluding(ValidationError, "Message 10 does not exist (chat has 5 messages)"), + ) +}) + +test("parseMessageSpec - message number 0 throws", () => { + assert.throws( + () => parseMessageSpec("0", 5), + errorIncluding(ValidationError, "Message 0 does not exist"), + ) +}) + +test("parseMessageSpec - invalid number throws", () => { + assert.throws( + () => parseMessageSpec("abc", 5), + errorIncluding(ValidationError, "Invalid message number"), + ) +}) + +test("parseMessageSpec - invalid number suffix throws", () => { + assert.throws( + () => parseMessageSpec("1abc", 5), + errorIncluding(ValidationError, 'Invalid message number: "1abc"'), + ) +}) + +test("parseMessageSpec - decimal number throws", () => { + assert.throws( + () => parseMessageSpec("1.5", 5), + errorIncluding(ValidationError, 'Invalid message number: "1.5"'), + ) +}) + +test("parseMessageSpec - invalid range throws", () => { + assert.throws( + () => parseMessageSpec("a-b", 5), + errorIncluding(ValidationError, "Invalid range"), + ) +}) + +test("parseMessageSpec - invalid range suffix throws", () => { + assert.throws( + () => parseMessageSpec("1-2-3", 5), + errorIncluding(ValidationError, 'Invalid range: "1-2-3"'), + ) +}) diff --git a/models.ts b/models.ts index 174fdfc..cfc2dbc 100644 --- a/models.ts +++ b/models.ts @@ -1,6 +1,6 @@ import { ValidationError } from "./errors.ts" import { type TokenCounts } from "./types.ts" -import $ from "@david/dax" +import $ from "dax" // prices are per million tokens export type Model = { diff --git a/models_test.ts b/models_test.ts index 5b1385d..eea3075 100644 --- a/models_test.ts +++ b/models_test.ts @@ -1,4 +1,6 @@ -import { assertAlmostEquals, assertEquals, assertThrows } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" +import { assertAlmostEqual, errorIncluding } from "./testing.ts" import { ValidationError } from "./errors.ts" import { getCost, type Model, models, resolveModel } from "./models.ts" @@ -33,7 +35,7 @@ function resolveTestModel(modelArg: string | undefined) { // getCost tests -Deno.test("getCost - basic calculation without caching", () => { +test("getCost - basic calculation without caching", () => { const model: Model = { provider: "test", key: "test-model", @@ -43,10 +45,10 @@ Deno.test("getCost - basic calculation without caching", () => { } const tokens = { input: 1000, output: 500 } // (3 * 1000 + 15 * 500) / 1_000_000 = 10500 / 1_000_000 = 0.0105 - assertEquals(getCost(model, tokens), 0.0105) + assert.deepEqual(getCost(model, tokens), 0.0105) }) -Deno.test("getCost - with cache hit pricing", () => { +test("getCost - with cache hit pricing", () => { const model: Model = { provider: "test", key: "test-model", @@ -60,10 +62,10 @@ Deno.test("getCost - with cache hit pricing", () => { // uncached: 3 * (1000 - 800) = 600 // output: 15 * 500 = 7500 // total: (240 + 600 + 7500) / 1_000_000 = 0.00834 - assertEquals(getCost(model, tokens), 0.00834) + assert.deepEqual(getCost(model, tokens), 0.00834) }) -Deno.test("getCost - cache hit but no cached pricing uses regular input price", () => { +test("getCost - cache hit but no cached pricing uses regular input price", () => { const model: Model = { provider: "test", key: "test-model", @@ -75,10 +77,10 @@ Deno.test("getCost - cache hit but no cached pricing uses regular input price", const tokens = { input: 1000, input_cache_hit: 800, output: 500 } // Falls back to regular calculation since no input_cached price // (3 * 1000 + 15 * 500) / 1_000_000 = 0.0105 - assertEquals(getCost(model, tokens), 0.0105) + assert.deepEqual(getCost(model, tokens), 0.0105) }) -Deno.test("getCost - cache writes priced at write rate", () => { +test("getCost - cache writes priced at write rate", () => { const model: Model = { provider: "test", key: "test-model", @@ -94,10 +96,10 @@ Deno.test("getCost - cache writes priced at write rate", () => { // uncached: 4 * (1000 - 600 - 300) = 400 // output: 20 * 100 = 2000 // total: (240 + 1500 + 400 + 2000) / 1_000_000 = 0.00414 - assertEquals(getCost(model, tokens), 0.00414) + assert.deepEqual(getCost(model, tokens), 0.00414) }) -Deno.test("getCost - cache writes without write pricing use input price", () => { +test("getCost - cache writes without write pricing use input price", () => { const model: Model = { provider: "test", key: "test-model", @@ -107,20 +109,20 @@ Deno.test("getCost - cache writes without write pricing use input price", () => } const tokens = { input: 1000, input_cache_write: 300, output: 100 } // (4 * 1000 + 20 * 100) / 1_000_000 = 0.006 - assertEquals(getCost(model, tokens), 0.006) + assert.deepEqual(getCost(model, tokens), 0.006) }) -Deno.test("getCost - long context prices apply over threshold", () => { +test("getCost - long context prices apply over threshold", () => { const model = resolveModel("haiku-5.5") const short = { input: 100_000, input_cache_hit: 50_000, output: 1000 } // (0.01 * 50_000 + 0.10 * 50_000 + 0.50 * 1000) / 1_000_000 - assertAlmostEquals(getCost(model, short), 0.006) + assertAlmostEqual(getCost(model, short), 0.006) const long = { input: 100_001, input_cache_hit: 50_000, output: 1000 } // (0.05 * 50_000 + 0.50 * 50_001 + 2.50 * 1000) / 1_000_000 - assertAlmostEquals(getCost(model, long), 0.0300005) + assertAlmostEqual(getCost(model, long), 0.0300005) }) -Deno.test("getCost - zero tokens", () => { +test("getCost - zero tokens", () => { const model: Model = { provider: "test", key: "test-model", @@ -129,56 +131,55 @@ Deno.test("getCost - zero tokens", () => { output: 15, } const tokens = { input: 0, output: 0 } - assertEquals(getCost(model, tokens), 0) + assert.deepEqual(getCost(model, tokens), 0) }) // resolveModel tests -Deno.test("resolveModel - returns default when undefined", () => { - assertEquals(resolveTestModel(undefined), testModels[2]) +test("resolveModel - returns default when undefined", () => { + assert.deepEqual(resolveTestModel(undefined), testModels[2]) }) -Deno.test("resolveModel - exact match on id", () => { - assertEquals(resolveTestModel("alpha"), testModels[2]) +test("resolveModel - exact match on id", () => { + assert.deepEqual(resolveTestModel("alpha"), testModels[2]) }) -Deno.test("resolveModel - exact match on key", () => { - assertEquals(resolveTestModel("vendor-alpha"), testModels[2]) +test("resolveModel - exact match on key", () => { + assert.deepEqual(resolveTestModel("vendor-alpha"), testModels[2]) }) -Deno.test("resolveModel - substring match on id", () => { - assertEquals(resolveTestModel("alpha-"), testModels[0]) +test("resolveModel - substring match on id", () => { + assert.deepEqual(resolveTestModel("alpha-"), testModels[0]) }) -Deno.test("resolveModel - substring match on key", () => { - assertEquals(resolveTestModel("vendor-alpha-"), testModels[0]) +test("resolveModel - substring match on key", () => { + assert.deepEqual(resolveTestModel("vendor-alpha-"), testModels[0]) }) -Deno.test("resolveModel - case insensitive", () => { - assertEquals(resolveTestModel("ALPHA-"), testModels[0]) +test("resolveModel - case insensitive", () => { + assert.deepEqual(resolveTestModel("ALPHA-"), testModels[0]) }) -Deno.test("resolveModel - throws on unknown model", () => { - assertThrows( +test("resolveModel - throws on unknown model", () => { + assert.throws( () => resolveTestModel("nonexistent-model-xyz"), - ValidationError, - "not found", + errorIncluding(ValidationError, "not found"), ) }) -Deno.test("Must have exactly one default model", () => { - assertEquals(models.filter((m) => m.default).length, 1) +test("Must have exactly one default model", () => { + assert.deepEqual(models.filter((m) => m.default).length, 1) }) // Modules that resolve hard-coded aliases at module scope (like // resolveModel("flash") in summarize.ts) throw on import if catalog churn // makes the alias stop matching. Importing them here catches that. -Deno.test("modules with hard-coded model aliases import cleanly", async () => { +test("modules with hard-coded model aliases import cleanly", async () => { await import("./summarize.ts") }) -Deno.test("image models resolve by nickname without shadowing text models", () => { - assertEquals(resolveModel("flare").key, "gpt-image-2.5-flare") - assertEquals(resolveModel("sunburst").key, "gpt-image-2.5-sunburst") - assertEquals(resolveModel("gpt").kind, undefined) +test("image models resolve by nickname without shadowing text models", () => { + assert.deepEqual(resolveModel("flare").key, "gpt-image-2.5-flare") + assert.deepEqual(resolveModel("sunburst").key, "gpt-image-2.5-sunburst") + assert.deepEqual(resolveModel("gpt").kind, undefined) }) diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4f2478b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2914 @@ +{ + "name": "llm-cli", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "llm-cli", + "dependencies": { + "@anthropic-ai/sdk": "0.123.0", + "@commander-js/extra-typings": "^15.0.0", + "@google/genai": "2.21.0", + "@inquirer/core": "^12", + "@inquirer/prompts": "^8.7.4", + "@mathjax/src": "4.1.3", + "@resvg/resvg-wasm": "2.6.2", + "@shikijs/cli": "^4.4.3", + "ansis": "^4.3.1", + "arktype": "^2.2.3", + "commander": "^15.0.0", + "dax": "^0.50.1", + "json5": "^2.2.3", + "markdown-exit": "^1.3.0", + "markdown-table": "3.0.4", + "openai": "7.21.0", + "string-width": "7.2.0", + "supports-hyperlinks": "^4.5.0", + "ts-pattern": "^5.9.0", + "wrap-ansi": "9.0.0" + }, + "bin": { + "ai": "main.ts" + }, + "devDependencies": { + "@types/node": "^24.19.2", + "oxlint": "^1.89.0", + "typescript": "^7.0.2" + }, + "engines": { + "node": ">=24" + } + }, + "node_modules/@anthropic-ai/sdk": { + "version": "0.123.0", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.123.0.tgz", + "integrity": "sha512-Y9oX9mPNGZClHQOFqrWRk43Srcu/UHuPq3rfxxOq7JgW0gi+lJA2MAOK4Ul3k/+AUrwRWFJvd0tK3oC0Pw25dw==", + "license": "MIT", + "dependencies": { + "json-schema-to-ts": "^3.1.1", + "standardwebhooks": "^1.0.0" + }, + "bin": { + "anthropic-ai-sdk": "bin/cli" + }, + "peerDependencies": { + "zod": "^3.25.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "zod": { + "optional": true + } + } + }, + "node_modules/@ark/schema": { + "version": "0.56.8", + "resolved": "https://registry.npmjs.org/@ark/schema/-/schema-0.56.8.tgz", + "integrity": "sha512-R05TOe85oQBGFFw2zKMuZpqkXibLKuC/aJt6VwFn5Cjc4x3NkWfhvGRpRDycNkj3ddcHnOPtIsmjVowJO9Yxdw==", + "license": "MIT", + "dependencies": { + "@ark/util": "0.56.8" + } + }, + "node_modules/@ark/util": { + "version": "0.56.8", + "resolved": "https://registry.npmjs.org/@ark/util/-/util-0.56.8.tgz", + "integrity": "sha512-XLiQyGfpJcws1zCtp2Cva8s1oheCdFn1Rt6JSyC4NnkDrpwCJnlaiawuuOc1Z97vMH+jEzW5vyyf0xOju5wUQA==", + "license": "MIT" + }, + "node_modules/@babel/runtime": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.10.tgz", + "integrity": "sha512-NpugTzbKgGrNe45Ui32cN8vCFFMxVtP/9rtfwv0nP5FRDAjvYBxJcLVpYA9mr1jxP6cnIT7x9LUzuDTbWYYNRA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@commander-js/extra-typings": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/@commander-js/extra-typings/-/extra-typings-15.0.0.tgz", + "integrity": "sha512-yeJlba62xqmkgELUsn7356MEnzLLu/fw2x4lofFqGnXh6YysRdEs2BaLeLtg1+KU0AXvMeqQvTTp+3hBEBK+EA==", + "license": "MIT", + "peerDependencies": { + "commander": "~15.0.0" + } + }, + "node_modules/@dsherret/path": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@dsherret/path/-/path-0.3.4.tgz", + "integrity": "sha512-eQ4QXKedvwYFUeLhGSjDzJVuwaTlGNQzZ5S0n9YdRRc9TSRbx5BSNNPzVz+sJUKlm/69zpg7XfckukJz4JiKEQ==", + "license": "MIT" + }, + "node_modules/@dsherret/shell": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@dsherret/shell/-/shell-0.7.2.tgz", + "integrity": "sha512-TF3ktaulZtO25WeAyG0sc23RFgyJKsYaQTKjvfavke6U4cPM9Hh6szpRUpcJNoQacqI7ZW0GvrhsmZE/dUf9Tw==", + "license": "MIT", + "dependencies": { + "@dsherret/path": "^0.3.4", + "console-static-text": "^0.3.5" + } + }, + "node_modules/@google/genai": { + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/@google/genai/-/genai-2.21.0.tgz", + "integrity": "sha512-+PDtco2/Z0ONdzCGekCoCT+O1VJS9xJQNN4XzQpXG/t3El/SWWMkCWlFRO1KmivOHPa4Q0VjUYu1HBKCZ/v33Q==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "google-auth-library": "^10.3.0", + "p-retry": "^4.6.2", + "protobufjs": "^7.5.4", + "ws": "^8.18.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": "^1.25.2" + }, + "peerDependenciesMeta": { + "@modelcontextprotocol/sdk": { + "optional": true + } + } + }, + "node_modules/@inquirer/ansi": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.9.tgz", + "integrity": "sha512-0Ywt3S8tqM6TWUcsRlBFQ1x+X3/o8kktX0ZiKAnByYb9GFDknnOhse1PVtfiD2BXPI8ar+BWx9PV9R0lQIcygw==", + "license": "MIT", + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + } + }, + "node_modules/@inquirer/checkbox": { + "version": "5.2.7", + "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-5.2.7.tgz", + "integrity": "sha512-/+QmGE/9bvE/EobaZDnzYe+T+QWoJrnmxwBQNtoi2OVSUR9d1znYsNyEoUrOZvFSxDYttrhzRIpXpaLkN+iIsg==", + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^2.0.9", + "@inquirer/core": "^12.0.5", + "@inquirer/figures": "^2.0.9", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/confirm": { + "version": "6.3.4", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.3.4.tgz", + "integrity": "sha512-ZwnaZZDa1zxsyVrN32s447ydMnKcw7e8WWNT+R+Qsu0zAn8Rs6yi9d1B80Kob1Ul2cfUi7t8JD2t4/K7uEZpqA==", + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.0.5", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/core": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-12.0.5.tgz", + "integrity": "sha512-c0ZSnO9oVk/IlEGoZK3u8b3IZQeu9I6jUkXJSQnQEVRXsjKvtAq3AGqFL2LgfJhlzMZne08pZHWRWasIcI3Rew==", + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^2.0.9", + "@inquirer/figures": "^2.0.9", + "@inquirer/type": "4.2.0", + "cli-width": "^4.1.0", + "fast-wrap-ansi": "^0.2.0", + "mute-stream": "^3.0.0", + "signal-exit": "^4.1.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/editor": { + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-5.3.5.tgz", + "integrity": "sha512-6lU3/pPx5z3lHWejFW061MV4qZooBQYv/+EeGhNOPiP/i+hrYsHfxxBnnDGsAfg8YdLUd69YckoeOjtr3QuAUg==", + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.0.5", + "@inquirer/external-editor": "^3.0.6", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/expand": { + "version": "5.1.7", + "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-5.1.7.tgz", + "integrity": "sha512-eiJ31YFCaB6fLoJCqLIn8S6eqUyME6vwr8KcP5h8cxmA+bV9RRVPO+kywoxb7G63HduDXV6sN/SM7o2R+ahEcQ==", + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.0.5", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/external-editor": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@inquirer/external-editor/-/external-editor-3.0.6.tgz", + "integrity": "sha512-rWmw6WG8JZ7LMn/srXEylYGhL6EXXJeROE7/4x4GREh6NgzqJBDbIgpNGsYoLPfobeb4VZtEYzPGnT5EFNYhiQ==", + "license": "MIT", + "dependencies": { + "chardet": "^2.1.1", + "iconv-lite": "^0.7.2" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/figures": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.0.9.tgz", + "integrity": "sha512-EAWgUTGQ/Umgga51dE3B2PUHbufuXarDfg86uVgoSgNHNNQnyFKcOrQLWVqYMghuSyHh8+2HUH0Js9cTC1WAdg==", + "license": "MIT", + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + } + }, + "node_modules/@inquirer/input": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-5.1.8.tgz", + "integrity": "sha512-psOSTgkL8y/OtgJJYbqJ0oISr2QBE0U1Ro/qQdA/EKjeJiwiUTQgQmq8o4ESNzVOWthIeh3YLD7BCUR9dKnR5g==", + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.0.5", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/number": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-4.2.5.tgz", + "integrity": "sha512-lEy7LWsdF5qHx5QjHZqabUqM9P7i5uTMCt8GRzqxmwXXKbapKJDA+ucVflVVPAyj4snD5DTAD4L+sct85XOlOQ==", + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.0.5", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/password": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-5.2.4.tgz", + "integrity": "sha512-T7ir3fflSSVCYEVqNyMBq+pIMsilQRtbZcD5gxn6Ewsin5TJWBxrGBdXveWtmeXVAeoInfhS+BhBUZaL4sFSDg==", + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^2.0.9", + "@inquirer/core": "^12.0.5", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/prompts": { + "version": "8.7.4", + "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-8.7.4.tgz", + "integrity": "sha512-SAJt+QhY5rOJAIgZBw9TrHWfgrp6wsb9cqRCyqax+Hl6EiFfRXmD9EsIWkST8yq/dQ8H46Is2Sr/JG7Ls/LQ+Q==", + "license": "MIT", + "dependencies": { + "@inquirer/checkbox": "^5.2.7", + "@inquirer/confirm": "^6.3.4", + "@inquirer/editor": "^5.3.5", + "@inquirer/expand": "^5.1.7", + "@inquirer/input": "^5.1.8", + "@inquirer/number": "^4.2.5", + "@inquirer/password": "^5.2.4", + "@inquirer/rawlist": "^5.3.7", + "@inquirer/search": "^4.3.5", + "@inquirer/select": "^5.2.7" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/rawlist": { + "version": "5.3.7", + "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-5.3.7.tgz", + "integrity": "sha512-XveEe8v3BHj9ec00n+9i8FHjWhXjS6+jCTizYvXCqKUKtgkrq9xid8S5j3mYGW96qfxG3mwNoud3m3v8GDk9Pw==", + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.0.5", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/search": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-4.3.5.tgz", + "integrity": "sha512-kIUecMugEN2YTvTmff+uYz0nAE0f9RFNDVZknfrh264vAQM9P8tnsXiUp7z8XbGuNIBEtFMJhvc9QquawpC46A==", + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.0.5", + "@inquirer/figures": "^2.0.9", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/select": { + "version": "5.2.7", + "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-5.2.7.tgz", + "integrity": "sha512-pRDWO4dTqSAvFQdO8yclKMtXNDm9K9HmvWB5UZmT3clw2OlOBNXveHzhyFmO/0d0yJMqlPcNITus1Jtpm6t8VQ==", + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^2.0.9", + "@inquirer/core": "^12.0.5", + "@inquirer/figures": "^2.0.9", + "@inquirer/type": "4.2.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/type": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.2.0.tgz", + "integrity": "sha512-2rnHX8RPo4glJYqnFc/v3nQeIhDcjyRRyaT7MGcfL/8xv/8K03SXYoA2tX06WVSKywWOE/ncbG3dtuzLjR5TCQ==", + "license": "MIT", + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@mathjax/mathjax-newcm-font": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@mathjax/mathjax-newcm-font/-/mathjax-newcm-font-4.1.3.tgz", + "integrity": "sha512-gzAB3dFHilHX1l5x2xUqRL+1jDQt3Fyza1DkEMVXWC4E8SvsGdlgEza47HYi2WhVcgfkvf4zgUGzuhbq3Pjlew==", + "license": "Apache-2.0" + }, + "node_modules/@mathjax/src": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@mathjax/src/-/src-4.1.3.tgz", + "integrity": "sha512-rIrWquuBSoJuoMBdC/1qD+AUHTorlccPicoVy6P2xbUgnuDBpCcpbHtOAsB8L3hdCHtNBg92lF8e3Fz+pkcQbw==", + "license": "Apache-2.0", + "dependencies": { + "@mathjax/mathjax-newcm-font": "4.1.3", + "mhchemparser": "^4.2.1", + "mj-context-menu": "^1.0.0", + "speech-rule-engine": "5.0.0-rc.4" + } + }, + "node_modules/@oxlint/binding-android-arm-eabi": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.89.0.tgz", + "integrity": "sha512-Pflpba5F3gRAQ12sWglRxvWTHEdAusNDvmi4Y5N1T5SY1AGkM7AixOnET8qkrnLJ/F32qAlNokO6eCknT8tmnw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm64": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm64/-/binding-android-arm64-1.89.0.tgz", + "integrity": "sha512-dYmyD1x7LaPlb79vZWUcpTShk8dI9z1I+IubtqrBxWNJaDhQdPHwcsvg7q5StTU4xWyd9AwPfLaTYFZY8NZgtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-arm64": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.89.0.tgz", + "integrity": "sha512-Z/oxOPiIqiS7fItRdxaaOEC+6GD3OpGi0IxoR0dMefzQHolsKLzScw2DNcu/5gUPok3tv+G9mslvYB5bo3i0qg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-x64": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.89.0.tgz", + "integrity": "sha512-eAjTkHSjAxrdCPJxO6y5sPQL5pYLKb2kvxZz9UU7tXnOZk9I/HLtkvx9S7GHY883k+AmL/eC7mqFt+w7WCwk0w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-freebsd-x64": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.89.0.tgz", + "integrity": "sha512-0lNCA9Tl1n1FKpqy2/9ckp0kIuSrtJ/l9bMRgaEhOtM7TsOHshFuwOcvW8oA9teXLMOJT61LjEKWiaHDFGxF/w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-gnueabihf": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.89.0.tgz", + "integrity": "sha512-OTFEvi9W+JczaZD1Caj17SGCoW8H7TE+fvx0D7ATEWa1Lohn91UMxFQ6r145SiGy/yCxeIwptMys/RAM7gSVSQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-musleabihf": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.89.0.tgz", + "integrity": "sha512-fRxgNHvBLswj6MrhW2uBq5UDhPRQlCbHeq/Nf8yuG9zOxhDsXqX/mi2PX1axgsQxMm88el7HLiJAzglAnflYxw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-gnu": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.89.0.tgz", + "integrity": "sha512-v9ENzHvwrQoYSWTtviH1pOYc7R9UovDxVofnck50cNmPihRRTcrg5X0UlRbLOZ7IVtxPOlh2hb7kDO+FpE8SfQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-musl": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.89.0.tgz", + "integrity": "sha512-vfffe8mQ484AzVadlUOFpgL+JDwhvs9hrzxTgQP1FVfi4ZEUUYeffXlzC9dFV7Dgnu5s/KrNKvfmG6HxBd/ISQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-ppc64-gnu": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.89.0.tgz", + "integrity": "sha512-Buonlp4hVS7RGNP5M7bPpGNQrenyzA2C64JcO/oz9C1c6dGOXJ7VEAnaiAMY7voou0JYyCJdvDVlFQc5DZX3DQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-gnu": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.89.0.tgz", + "integrity": "sha512-1eVwJJrJ3lYIPT+cm7BcBBZZXY6IQZP/oyonaruTor/MrVyWOpvnwt1oD5CLdsHg5aVBIxXodQSvt+1gK6ck5w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-musl": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.89.0.tgz", + "integrity": "sha512-fRQQsKUGShdEL5Fl9o9uhj3grkZbeXKLv0icQ5tspUCNYSDy8wzzEcP1WC2bKdTQ0rSszbKlO3iiHORxV22DLg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-s390x-gnu": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.89.0.tgz", + "integrity": "sha512-dEtYjIy6+fHcjKklsmtmMkZRhwHr2UbzjmpvuPtQYSeN9awQ2hx5JLms5Wvri+8P/NZtD8v5hfgHALUql+/Ycg==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-gnu": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.89.0.tgz", + "integrity": "sha512-hqjwIj5KOYM8Wjef/p7IruNi1iByLhSzbMBk62y22P/E8q7Jj0Pp+DeUTKTRYyZYCDtU1wEGlnWOnttHbyNIww==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-musl": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.89.0.tgz", + "integrity": "sha512-iAQN3e6o9UgUCcdGwqRx/jYcKbG3HK7ur3rH6lTqVcQeNGZ85AeWIg6cgn/edwFQ0ofEZZItMwkzyCVTahnvEA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-openharmony-arm64": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.89.0.tgz", + "integrity": "sha512-MNxjEByz3N/7Q4qFQuPWvc14TpN9LoD3pECEDsJTZbP/wyB7U+hduUXEl7QAbbgVezFwsb9sWtNUO6XVBndOhg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-arm64-msvc": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.89.0.tgz", + "integrity": "sha512-xxe+i9wfuFso/VnoL4mfj0UlzE+cfCFiUB06vkXCMyQdgVVmItF5FfAF4tATAktSU6uHruWR+FjqvAT9cHZZzg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-ia32-msvc": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.89.0.tgz", + "integrity": "sha512-saFy07cO94E664glwgLmKLI40HgTL1PY86y4T6+ud4niX4H0Kdqjcmqmjps7mQNdBytV5guGbXDdyQtRfeLbLA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-x64-msvc": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.89.0.tgz", + "integrity": "sha512-hLFJ/o0f/dTJh/EW0vmcbREYSQO9tYgfiAAlsOkiLFiJuRRWvYtFELUXN5o2ijpSo/tlO1n+YlWN58tZwPG18A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.5.tgz", + "integrity": "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.1.tgz", + "integrity": "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.1.tgz", + "integrity": "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==", + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.1" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.2.tgz", + "integrity": "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==", + "license": "BSD-3-Clause" + }, + "node_modules/@resvg/resvg-wasm": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/@resvg/resvg-wasm/-/resvg-wasm-2.6.2.tgz", + "integrity": "sha512-FqALmHI8D4o6lk/LRWDnhw95z5eO+eAa6ORjVg09YRR7BkcM6oPHU9uyC0gtQG5vpFLvgpeU4+zEAz2H8APHNw==", + "license": "MPL-2.0", + "engines": { + "node": ">= 10" + } + }, + "node_modules/@shikijs/cli": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/cli/-/cli-4.5.0.tgz", + "integrity": "sha512-zas7qVanoL30c0LNeU5SHJKrYOrb/13/wXe0NLWfvc8GpnaDrUHuLG5I9wfHYdhVa+R71VH5IiwsM8aZ2akoNw==", + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "ansis": "^4.4.0", + "cac": "^7.0.0", + "shiki": "4.5.0" + }, + "bin": { + "cli": "bin.mjs", + "shiki": "bin.mjs", + "shiki-cli": "bin.mjs", + "skat": "bin.mjs" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/core": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.5.0.tgz", + "integrity": "sha512-6CIgwq+bt2JZ3OSjb/nBkkwEf/CfpHcbam+Mg5Pllco7HAGRQ2/EFhZrrJtbyNTgKwknfVS+llsXGygiDGwJWw==", + "license": "MIT", + "dependencies": { + "@shikijs/primitive": "4.5.0", + "@shikijs/types": "4.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.5", + "hast-util-to-html": "^9.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/engine-javascript": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.5.0.tgz", + "integrity": "sha512-Ed6UdEj84LyYkwnxM5CvSMWAD+id9ExTYri0/+x41U9zrgNifPSS9lZm0JqBP0VfYI8yr8tY5nbNq9+p9R0kFA==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "oniguruma-to-es": "^4.3.6" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/engine-oniguruma": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.5.0.tgz", + "integrity": "sha512-dKVmbJecVdB9recl8a/CU4jdpNXyjJQrIcesIkpS70s5HS02ohpnCSpMUbotPnEUzbAcLQ+S4hwZYbkBBiTcJw==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.5.0", + "@shikijs/vscode-textmate": "^10.0.2" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/langs": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.5.0.tgz", + "integrity": "sha512-wwBTqwduXSz0X4v9Qa2EWeFaYJEw1clCncWjoRNQRbVDu3SPRTRWucnouYapKj3b8Q+sk/41Vbc4B5c8nuYzLA==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.5.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/primitive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.5.0.tgz", + "integrity": "sha512-UM7ShlA8oz0OWxLLO8BmO9Ip6fVqdkt8yF0EH7nOCqHfrx1eEAzF0ZUVK7L+I8NEgeu1PEWSRlxaiPPeCb4iDg==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/themes": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.5.0.tgz", + "integrity": "sha512-zGb87H3UBbpuI4yoh5UguB1XbU+2BDU3kflM7UfZ+Cy2hWo9lBtqjSVK20gmLY6ukYl040hAypGXMgud9vul8Q==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.5.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/types": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.5.0.tgz", + "integrity": "sha512-drtPrtD8N0DENyD2cyt6Ajy+IWsiCLgMxODwLTpvH1UsN6a9jf90tNTPjqwHvA+0Lzu9e0txk8DjfqH1p9UJRw==", + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.1.0.tgz", + "integrity": "sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ==", + "license": "MIT" + }, + "node_modules/@stablelib/base64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-1.0.1.tgz", + "integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==", + "license": "MIT" + }, + "node_modules/@types/hast": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz", + "integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==", + "license": "MIT" + }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==", + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "24.19.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz", + "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==", + "license": "MIT", + "dependencies": { + "undici-types": ">=7.24.0 <7.24.7" + } + }, + "node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", + "license": "MIT" + }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz", + "integrity": "sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==", + "license": "ISC" + }, + "node_modules/@xmldom/xmldom": { + "version": "0.9.12", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.12.tgz", + "integrity": "sha512-5AXjrcMClTryPe9LgZrygpB1lj7s0S9E0+W+AHaVKAVyHanafK86iPSvG5xHVSp/jC+VH1UXu0TAEmY279xH7A==", + "license": "MIT", + "engines": { + "node": ">=14.6" + } + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ansis": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-4.4.0.tgz", + "integrity": "sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==", + "license": "ISC", + "engines": { + "node": ">=14" + } + }, + "node_modules/arkregex": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/arkregex/-/arkregex-0.0.14.tgz", + "integrity": "sha512-G3I/uCtWE0IKQiPh0qqmmAFDdtjZKZQ5mNPR6gJBeAMZ7VqYCpoaDeXnLju2Zo6ywExtmxZJELeVFb0MPDjPyA==", + "license": "MIT", + "dependencies": { + "@ark/util": "0.56.8" + } + }, + "node_modules/arktype": { + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/arktype/-/arktype-2.2.9.tgz", + "integrity": "sha512-Cja0IMEn19rB35on9da1i1z6QMasuS7ULffXbetCry09jvCGYT8Bi1KgYiqri5FymF4nQAXkM90yksYkgSK2EA==", + "license": "MIT", + "dependencies": { + "@ark/schema": "0.56.8", + "@ark/util": "0.56.8", + "arkregex": "0.0.14" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/bignumber.js": { + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", + "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==", + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/cac": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/cac/-/cac-7.1.0.tgz", + "integrity": "sha512-LMDU/U2yA4IPIY8KT0NsNPWEYZvAMkbgyspxJ6btJaYV+WMDOHAZCmB0lsTObiHaRS1V/ztKAl7+TSkTqXyeoA==", + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/ccount": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-html4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/chardet": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-2.2.0.tgz", + "integrity": "sha512-rddelWYNPRrXq6PtNEN2S3f6t9ILzvqaN5pVgi4kqt9jHQaXIial9PznB5iSPVlQSLNaaH22ItWz3EJtQ10+OA==", + "license": "MIT" + }, + "node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "license": "ISC", + "engines": { + "node": ">= 12" + } + }, + "node_modules/comma-separated-tokens": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", + "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/commander": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-15.0.0.tgz", + "integrity": "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==", + "license": "MIT", + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/console-static-text": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/console-static-text/-/console-static-text-0.3.5.tgz", + "integrity": "sha512-/iyYUmmAGDUQXbDA3drgIUmOEi0FB2TxfmcFt24YhWQaEsaWh3Cf+30vdS4lhQTX2713EdxQljRqoETLkzPk3w==", + "license": "MIT" + }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/dax": { + "version": "0.50.1", + "resolved": "https://registry.npmjs.org/dax/-/dax-0.50.1.tgz", + "integrity": "sha512-UiW+746eOlqlgxYEHG20jV41Mm8gu366UXdGvPlXmjrdG9xJrlm6RZLvOhfOlEnSX/1p8XyK6cj1IC68hdCLiA==", + "license": "MIT", + "dependencies": { + "@dsherret/shell": "^0.7.2", + "undici-types": "^5.26" + } + }, + "node_modules/dax/node_modules/undici-types": { + "version": "5.28.4", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.28.4.tgz", + "integrity": "sha512-3OeMF5Lyowe8VW0skf5qaIE7Or3yS9LS7fvMUI0gg4YxpIBVg0L8BxCmROw2CcYhSkpR68Epz7CGc8MPj94Uww==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "license": "MIT" + }, + "node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "license": "MIT" + }, + "node_modules/fast-sha256": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", + "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==", + "license": "Unlicense" + }, + "node_modules/fast-string-truncated-width": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz", + "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==", + "license": "MIT" + }, + "node_modules/fast-string-width": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fast-string-width/-/fast-string-width-3.0.2.tgz", + "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==", + "license": "MIT", + "dependencies": { + "fast-string-truncated-width": "^3.0.2" + } + }, + "node_modules/fast-wrap-ansi": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/fast-wrap-ansi/-/fast-wrap-ansi-0.2.2.tgz", + "integrity": "sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==", + "license": "MIT", + "dependencies": { + "fast-string-width": "^3.0.2" + } + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/gaxios": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.3.1.tgz", + "integrity": "sha512-kB3rzJV7d9juLZh8/56QTXCwQfxyhdOMdyYk1HdQKFtF8TJTDTZQJtixWIwXdE9Jji91mC41DUNpjleo4L4eAQ==", + "license": "Apache-2.0", + "dependencies": { + "extend": "^3.0.2", + "https-proxy-agent": "^7.0.1", + "node-fetch": "^3.3.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/gcp-metadata": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-8.1.2.tgz", + "integrity": "sha512-zV/5HKTfCeKWnxG0Dmrw51hEWFGfcF2xiXqcA3+J90WDuP0SvoiSO5ORvcBsifmx/FoIjgQN3oNOGaQ5PhLFkg==", + "license": "Apache-2.0", + "dependencies": { + "gaxios": "^7.0.0", + "google-logging-utils": "^1.0.0", + "json-bigint": "^1.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "13.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", + "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "license": "BlueOak-1.0.0", + "dependencies": { + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/google-auth-library": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.9.1.tgz", + "integrity": "sha512-i1ydyHrqcIxXkWh/uBmVkzCvIuq5yiK2ATndIe5XxKholrG/MTYP9xGYka4sQhrbIAgGjL2B6NOE7rFaiF3fXw==", + "license": "Apache-2.0", + "dependencies": { + "base64-js": "^1.3.0", + "ecdsa-sig-formatter": "^1.0.11", + "gaxios": "^7.1.4", + "gcp-metadata": "8.1.2", + "google-logging-utils": "1.1.3", + "jws": "^4.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/google-logging-utils": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-1.1.3.tgz", + "integrity": "sha512-eAmLkjDjAFCVXg7A1unxHsLf961m6y17QFqXqAXGj/gVkKFrEICfStRfwUlGNfeCEjNRa32JEWOUTlYXPyyKvA==", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + } + }, + "node_modules/has-flag": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-5.0.1.tgz", + "integrity": "sha512-CsNUt5x9LUdx6hnk/E2SZLsDyvfqANZSUq4+D3D8RzDJ2M+HDTIkF60ibS1vHaK55vzgiZw1bEPFG9yH7l33wA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hast-util-to-html": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz", + "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-whitespace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", + "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/html-void-elements": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", + "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "license": "MIT", + "dependencies": { + "bignumber.js": "^9.0.0" + } + }, + "node_modules/json-schema-to-ts": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-3.1.1.tgz", + "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.18.3", + "ts-algebra": "^2.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/linkify-it": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", + "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/long": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", + "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", + "license": "Apache-2.0" + }, + "node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/markdown-exit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/markdown-exit/-/markdown-exit-1.3.0.tgz", + "integrity": "sha512-bsqlcm3Hk1ukcG1Al83pp3JjVobu4w1mpZz47OzLw8bCY8XchkCX+PXC32l2TH4nZ7p5WFg2NwpnLDXkY1X7Yw==", + "license": "MIT", + "dependencies": { + "@types/linkify-it": "^5.0.0", + "@types/mdurl": "^2.0.0", + "entities": "^7.0.0", + "linkify-it": "^5.0.1", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + } + }, + "node_modules/markdown-table": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz", + "integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz", + "integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", + "devlop": "^1.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "trim-lines": "^3.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdurl": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz", + "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==", + "license": "MIT" + }, + "node_modules/mhchemparser": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/mhchemparser/-/mhchemparser-4.2.1.tgz", + "integrity": "sha512-kYmyrCirqJf3zZ9t/0wGgRZ4/ZJw//VwaRVGA75C4nhE60vtnIzhl9J9ndkX/h6hxSN7pjg/cE0VxbnNM+bnDQ==", + "license": "Apache-2.0" + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.3.tgz", + "integrity": "sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/mj-context-menu": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mj-context-menu/-/mj-context-menu-1.0.0.tgz", + "integrity": "sha512-OSgBFQRCVhrZwRa9lhqnKcJU92dd/YXgBjup0uyeuj9bOaVsf4myOyrjU4PfhYkdDk6AqVUTov7v5uFMvIbduA==", + "license": "Apache-2.0", + "dependencies": { + "rimraf": "^6.0.1" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/mute-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-3.0.0.tgz", + "integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==", + "license": "ISC", + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "deprecated": "Use your platform's native DOMException instead", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/oniguruma-parser": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.2.tgz", + "integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==", + "license": "MIT" + }, + "node_modules/oniguruma-to-es": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.6.tgz", + "integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==", + "license": "MIT", + "dependencies": { + "oniguruma-parser": "^0.12.2", + "regex": "^6.1.0", + "regex-recursion": "^6.0.2" + } + }, + "node_modules/openai": { + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-7.21.0.tgz", + "integrity": "sha512-APwDcMhduWCSkKDLF4VZtAC5MGLRdJ0l+PUirz2fuSPXo/LNfEe8OuJVWOk8iJbO55sd8F5aOXvx8cfR5Eax1g==", + "license": "Apache-2.0", + "engines": { + "node": ">=22.0.0" + }, + "peerDependencies": { + "@aws-sdk/credential-provider-node": ">=3.972.0 <4", + "@smithy/hash-node": ">=4.3.0 <5", + "@smithy/signature-v4": ">=5.4.0 <6", + "undici": ">=5 <9", + "ws": "^8.21.0", + "zod": "^3.25 || ^4.0" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-provider-node": { + "optional": true + }, + "@smithy/hash-node": { + "optional": true + }, + "@smithy/signature-v4": { + "optional": true + }, + "undici": { + "optional": true + }, + "ws": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, + "node_modules/oxlint": { + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.89.0.tgz", + "integrity": "sha512-a25hkfo61okGPvJz432fRIPoxlKtNnOVy9w4rzrmGgNm4iVTPwpSQlmdqNWnp6p9QyyPVfAZRgnf5XvSBZFk/A==", + "dev": true, + "license": "MIT", + "bin": { + "oxlint": "bin/oxlint" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/oxc-project" + }, + "optionalDependencies": { + "@oxlint/binding-android-arm-eabi": "1.89.0", + "@oxlint/binding-android-arm64": "1.89.0", + "@oxlint/binding-darwin-arm64": "1.89.0", + "@oxlint/binding-darwin-x64": "1.89.0", + "@oxlint/binding-freebsd-x64": "1.89.0", + "@oxlint/binding-linux-arm-gnueabihf": "1.89.0", + "@oxlint/binding-linux-arm-musleabihf": "1.89.0", + "@oxlint/binding-linux-arm64-gnu": "1.89.0", + "@oxlint/binding-linux-arm64-musl": "1.89.0", + "@oxlint/binding-linux-ppc64-gnu": "1.89.0", + "@oxlint/binding-linux-riscv64-gnu": "1.89.0", + "@oxlint/binding-linux-riscv64-musl": "1.89.0", + "@oxlint/binding-linux-s390x-gnu": "1.89.0", + "@oxlint/binding-linux-x64-gnu": "1.89.0", + "@oxlint/binding-linux-x64-musl": "1.89.0", + "@oxlint/binding-openharmony-arm64": "1.89.0", + "@oxlint/binding-win32-arm64-msvc": "1.89.0", + "@oxlint/binding-win32-ia32-msvc": "1.89.0", + "@oxlint/binding-win32-x64-msvc": "1.89.0" + }, + "peerDependencies": { + "oxlint-tsgolint": ">=7.0.2003", + "vite-plus": "*" + }, + "peerDependenciesMeta": { + "oxlint-tsgolint": { + "optional": true + }, + "vite-plus": { + "optional": true + } + } + }, + "node_modules/p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "license": "MIT", + "dependencies": { + "@types/retry": "0.12.0", + "retry": "^0.13.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "license": "BlueOak-1.0.0" + }, + "node_modules/path-scurry": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/property-information": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz", + "integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/protobufjs": { + "version": "7.6.6", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.6.6.tgz", + "integrity": "sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg==", + "hasInstallScript": true, + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.5", + "@protobufjs/eventemitter": "^1.1.1", + "@protobufjs/fetch": "^1.1.1", + "@protobufjs/float": "^1.0.2", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.1", + "@types/node": ">=13.7.0", + "long": "^5.3.2" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz", + "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==", + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-recursion": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz", + "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==", + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-utilities": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz", + "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==", + "license": "MIT" + }, + "node_modules/retry": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", + "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/rimraf": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", + "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", + "license": "BlueOak-1.0.0", + "dependencies": { + "glob": "^13.0.3", + "package-json-from-dist": "^1.0.1" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/shiki": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-4.5.0.tgz", + "integrity": "sha512-OcRW72ngQvc+MSVWBRIovC/BTW589iUE/Vxav7VeM4RcY9MUjqB+IR6ILG1k9nuW6LiG/nct9uma4/MBtnZbmQ==", + "license": "MIT", + "dependencies": { + "@shikijs/core": "4.5.0", + "@shikijs/engine-javascript": "4.5.0", + "@shikijs/engine-oniguruma": "4.5.0", + "@shikijs/langs": "4.5.0", + "@shikijs/themes": "4.5.0", + "@shikijs/types": "4.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/space-separated-tokens": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", + "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/speech-rule-engine": { + "version": "5.0.0-rc.4", + "resolved": "https://registry.npmjs.org/speech-rule-engine/-/speech-rule-engine-5.0.0-rc.4.tgz", + "integrity": "sha512-3dFcH2QtQNhtvUUc09TxoaEK4WG03B9Z57krFG9jocrKykKGu35BhIkWr0vgEAxZZomEWkeluff69y/EbYzP4Q==", + "license": "Apache-2.0", + "dependencies": { + "@xmldom/xmldom": "^0.9.10", + "commander": "^14.0.3", + "wicked-good-xpath": "^1.3.0" + }, + "bin": { + "sre": "bin/sre" + } + }, + "node_modules/speech-rule-engine/node_modules/commander": { + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/standardwebhooks": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.1.1.tgz", + "integrity": "sha512-bCbX9ZEyFkWPsRz7Bl3NuQUJohmwGSev/yhr7vhaGPlc4AfIrspIRa6cPTBuI1ItmrTDJ4d/S2hCsfe4+vQGnQ==", + "license": "MIT", + "dependencies": { + "@stablelib/base64": "^1.0.0", + "fast-sha256": "^1.3.0" + } + }, + "node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/stringify-entities": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", + "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", + "license": "MIT", + "dependencies": { + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/supports-color": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", + "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/supports-hyperlinks": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-4.6.0.tgz", + "integrity": "sha512-FL/q/YePS4tFFTNiBOR+zPk2ZrKheqNtmTJ/9OUZ4e1wKHJofDbGQSmSsxS0XNnabSkqexryCaXGvEKz1vf9UQ==", + "license": "MIT", + "dependencies": { + "has-flag": "^5.0.1", + "supports-color": "^10.2.2" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/chalk/supports-hyperlinks?sponsor=1" + } + }, + "node_modules/trim-lines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/ts-algebra": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz", + "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==", + "license": "MIT" + }, + "node_modules/ts-pattern": { + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-5.9.2.tgz", + "integrity": "sha512-qAf+7M7Jjk7uebZeIo9uEzyintfuRtgHdzM9dqxRKcMi2dt76Ec+FH2wW3bnU9TuGLkZIJLoLs7cCQnU7Tu8ig==", + "license": "MIT" + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.24.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz", + "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==", + "license": "MIT" + }, + "node_modules/unist-util-is": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz", + "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", + "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz", + "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit-parents": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz", + "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", + "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-message": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz", + "integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/wicked-good-xpath": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/wicked-good-xpath/-/wicked-good-xpath-1.3.0.tgz", + "integrity": "sha512-Gd9+TUn5nXdwj/hFsPVx5cuHHiF5Bwuc30jZ4+ronF1qHK5O7HD0sgmXWSEgwKquT3ClLoKPVbO6qGwVwLzvAw==", + "license": "MIT" + }, + "node_modules/wrap-ansi": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", + "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/ws": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", + "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/zwitch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", + "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d4ffdf2 --- /dev/null +++ b/package.json @@ -0,0 +1,47 @@ +{ + "name": "llm-cli", + "private": true, + "type": "module", + "bin": { + "ai": "./main.ts" + }, + "engines": { + "node": ">=24" + }, + "scripts": { + "ci": "npm run fmt:check && npm run lint && npm run check && npm test", + "fmt": "deno fmt", + "fmt:check": "deno fmt --check", + "lint": "oxlint --deny-warnings", + "check": "tsc", + "test": "node --test '**/*_test.ts'", + "math-demo": "node math-demo.ts" + }, + "dependencies": { + "@anthropic-ai/sdk": "0.123.0", + "@commander-js/extra-typings": "^15.0.0", + "@google/genai": "2.21.0", + "@inquirer/core": "^12", + "@inquirer/prompts": "^8.7.4", + "@mathjax/src": "4.1.3", + "@resvg/resvg-wasm": "2.6.2", + "@shikijs/cli": "^4.4.3", + "ansis": "^4.3.1", + "arktype": "^2.2.3", + "commander": "^15.0.0", + "dax": "^0.50.1", + "json5": "^2.2.3", + "markdown-exit": "^1.3.0", + "markdown-table": "3.0.4", + "openai": "7.21.0", + "string-width": "7.2.0", + "supports-hyperlinks": "^4.5.0", + "ts-pattern": "^5.9.0", + "wrap-ansi": "9.0.0" + }, + "devDependencies": { + "@types/node": "^24.19.2", + "oxlint": "^1.89.0", + "typescript": "^7.0.2" + } +} diff --git a/picker.ts b/picker.ts index adc173d..885f5fe 100644 --- a/picker.ts +++ b/picker.ts @@ -1,3 +1,4 @@ +import process from "node:process" import stringWidth from "string-width" import { createPrompt, @@ -11,6 +12,7 @@ import { usePrefix, useState, } from "@inquirer/core" +import { checkbox, confirm, select } from "@inquirer/prompts" const COLUMN_GAP = 3 const SELECT_PREFIX_WIDTH = 2 @@ -23,13 +25,8 @@ export interface PickerRow { } function terminalColumns(): number { - try { - return Deno.consoleSize().columns - } catch { - // The selector will report the non-TTY error; this only keeps formatting - // from replacing it with a console-size error first. - return 120 - } + // Undefined when stdout isn't a TTY. The selector reports that error itself. + return process.stdout.columns ?? 120 } export function singleLine(text: string): string { @@ -170,11 +167,7 @@ const actionSelect = createPrompt< }) function terminalRows(): number { - try { - return Deno.consoleSize().rows - } catch { - return 24 - } + return process.stdout.rows ?? 24 } /** @@ -200,3 +193,50 @@ export async function pickWithAction(opts: { throw e } } + +/** Ctrl+C exits with 130, as dax's prompts did, instead of throwing. */ +async function exitOnCancel(prompt: Promise): Promise { + try { + return await prompt + } catch (e) { + if (e instanceof ExitPromptError) process.exit(130) + throw e + } +} + +const indexChoices = (options: string[]) => options.map((name, value) => ({ name, value })) + +/** Pick one of `options` and return its index. */ +export function selectIndex(opts: { + message: string + options: string[] + initialIndex?: number +}): Promise { + return exitOnCancel(select({ + message: opts.message, + choices: indexChoices(opts.options), + default: opts.initialIndex, + pageSize: Math.max(3, terminalRows() - 2), + })) +} + +/** Pick any number of `options` and return their indexes. */ +export function selectIndexes( + opts: { message: string; options: string[] }, +): Promise { + return exitOnCancel(checkbox({ + message: opts.message, + choices: indexChoices(opts.options), + pageSize: Math.max(3, terminalRows() - 3), + })) +} + +/** A yes/no question that defaults to no. Ctrl+C also counts as no. */ +export async function confirmed(message: string, opts: { clear?: boolean } = {}) { + try { + return await confirm({ message, default: false }, { clearPromptOnDone: opts.clear }) + } catch (e) { + if (e instanceof ExitPromptError) return false + throw e + } +} diff --git a/picker_test.ts b/picker_test.ts index 3714aee..d0e617d 100644 --- a/picker_test.ts +++ b/picker_test.ts @@ -1,8 +1,9 @@ -import { assert, assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" import stringWidth from "string-width" import { alignColumns, formatPickerOptions, keyAction } from "./picker.ts" -Deno.test("picker options stay single-line and preserve their row mapping", () => { +test("picker options stay single-line and preserve their row mapping", () => { const options = formatPickerOptions([ { summary: "A summary with an embedded newline\nand a long second thought", @@ -16,7 +17,7 @@ Deno.test("picker options stay single-line and preserve their row mapping", () = }, ], 60) - assertEquals(options.length, 2) + assert.deepEqual(options.length, 2) assert(options.every((option) => !option.includes("\n"))) assert(options.every((option) => stringWidth(option) <= 58)) assert(options[0].includes("…")) @@ -24,7 +25,7 @@ Deno.test("picker options stay single-line and preserve their row mapping", () = assert(options[1].endsWith("8/27 09:24 (4)")) }) -Deno.test("picker options retain full summaries when they fit", () => { +test("picker options retain full summaries when they fit", () => { const [option] = formatPickerOptions([{ summary: " Emoji 🦀 summary ", model: "opus-5", @@ -35,22 +36,22 @@ Deno.test("picker options retain full summaries when they fit", () => { assert(!option.includes("…")) }) -Deno.test("picker keys map to actions and leave navigation alone", () => { - assertEquals(keyAction({ name: "r" }), "resume") - assertEquals(keyAction({ name: "s" }), "show") - assertEquals(keyAction({ name: "s", shift: true }), "showAll") - assertEquals(keyAction({ name: "f" }), "fork") - assertEquals(keyAction({ name: "d" }), "delete") - assertEquals(keyAction({ name: "q" }), "quit") - assertEquals(keyAction({ name: "escape" }), "quit") - assertEquals(keyAction({ name: "j" }), undefined) - assertEquals(keyAction({ name: "return" }), undefined) - assertEquals(keyAction({ name: "d", ctrl: true }), undefined) - assertEquals(keyAction({ name: "c", ctrl: true }), undefined) +test("picker keys map to actions and leave navigation alone", () => { + assert.deepEqual(keyAction({ name: "r" }), "resume") + assert.deepEqual(keyAction({ name: "s" }), "show") + assert.deepEqual(keyAction({ name: "s", shift: true }), "showAll") + assert.deepEqual(keyAction({ name: "f" }), "fork") + assert.deepEqual(keyAction({ name: "d" }), "delete") + assert.deepEqual(keyAction({ name: "q" }), "quit") + assert.deepEqual(keyAction({ name: "escape" }), "quit") + assert.deepEqual(keyAction({ name: "j" }), undefined) + assert.deepEqual(keyAction({ name: "return" }), undefined) + assert.deepEqual(keyAction({ name: "d", ctrl: true }), undefined) + assert.deepEqual(keyAction({ name: "c", ctrl: true }), undefined) }) -Deno.test("alignColumns pads every column but the last to its widest cell", () => { - assertEquals( +test("alignColumns pads every column but the last to its widest cell", () => { + assert.deepEqual( alignColumns([ ["1", "user", "hello"], ["10", "opus-5 🦀", "hi"], @@ -60,5 +61,5 @@ Deno.test("alignColumns pads every column but the last to its widest cell", () = "10 opus-5 🦀 hi", ], ) - assertEquals(alignColumns([]), []) + assert.deepEqual(alignColumns([]), []) }) diff --git a/schema_test.ts b/schema_test.ts index 0b7ec4b..c5b1306 100644 --- a/schema_test.ts +++ b/schema_test.ts @@ -1,4 +1,6 @@ -import { assertEquals, assertThrows } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" +import { errorIncluding } from "./testing.ts" import { parseType, postprocessSchemaContent, prepareSchema } from "./schema.ts" function schema(input: string): Record { @@ -9,7 +11,7 @@ function schema(input: string): Record { return rest } -Deno.test("parseType - string DSL schemas", () => { +test("parseType - string DSL schemas", () => { const cases: Array<[string, Record]> = [ ["boolean", { type: "boolean" }], ["string", { type: "string" }], @@ -19,12 +21,12 @@ Deno.test("parseType - string DSL schemas", () => { ] for (const [input, expected] of cases) { - assertEquals(schema(input), expected) + assert.deepEqual(schema(input), expected) } }) -Deno.test("parseType - object with optional field", () => { - assertEquals(schema("{ urgent: 'boolean', 'reason?': 'string' }"), { +test("parseType - object with optional field", () => { + assert.deepEqual(schema("{ urgent: 'boolean', 'reason?': 'string' }"), { type: "object", properties: { urgent: { type: "boolean" }, @@ -34,8 +36,8 @@ Deno.test("parseType - object with optional field", () => { }) }) -Deno.test("parseType - union inside object (nested-quote form)", () => { - assertEquals(schema(`{ answer: "'yes'|'no'" }`), { +test("parseType - union inside object (nested-quote form)", () => { + assert.deepEqual(schema(`{ answer: "'yes'|'no'" }`), { type: "object", properties: { answer: { enum: ["no", "yes"] }, @@ -44,38 +46,35 @@ Deno.test("parseType - union inside object (nested-quote form)", () => { }) }) -Deno.test("parseType - nested object", () => { - assertEquals( - schema("{ user: { name: 'string', age: 'number' } }"), - { - type: "object", - properties: { - user: { - type: "object", - properties: { - name: { type: "string" }, - age: { type: "number" }, - }, - required: ["age", "name"], +test("parseType - nested object", () => { + assert.deepEqual(schema("{ user: { name: 'string', age: 'number' } }"), { + type: "object", + properties: { + user: { + type: "object", + properties: { + name: { type: "string" }, + age: { type: "number" }, }, + required: ["age", "name"], }, - required: ["user"], }, - ) + required: ["user"], + }) }) -Deno.test("parseType - leading/trailing whitespace is fine", () => { - assertEquals(schema(" boolean "), { type: "boolean" }) - assertEquals((schema(" { x: 'number' }") as { type: string }).type, "object") +test("parseType - leading/trailing whitespace is fine", () => { + assert.deepEqual(schema(" boolean "), { type: "boolean" }) + assert.deepEqual((schema(" { x: 'number' }") as { type: string }).type, "object") }) -Deno.test("parseType - refinement (number > 0)", () => { +test("parseType - refinement (number > 0)", () => { const s = schema("number > 0") as { type: string; exclusiveMinimum: number } - assertEquals(s.type, "number") - assertEquals(s.exclusiveMinimum, 0) + assert.deepEqual(s.type, "number") + assert.deepEqual(s.exclusiveMinimum, 0) }) -Deno.test("parseType - parse errors", () => { +test("parseType - parse errors", () => { const cases = [ ["blargh", "'blargh' is unresolvable"], ["'yes' |", "Token '|' requires a right operand"], @@ -86,14 +85,14 @@ Deno.test("parseType - parse errors", () => { ] as const for (const [input, expectedError] of cases) { - assertThrows(() => parseType(input), Error, expectedError) + assert.throws(() => parseType(input), errorIncluding(Error, expectedError)) } }) // Red-team: things `new Function` / eval would have accepted must now be // rejected by JSON5. All of these should fail before arktype ever sees them. -Deno.test("red-team - object literal expressions are rejected", () => { +test("red-team - object literal expressions are rejected", () => { const cases = [ "{ x: Date.now() }", "{ x: Deno }", @@ -107,20 +106,19 @@ Deno.test("red-team - object literal expressions are rejected", () => { ] for (const input of cases) { - assertThrows( + assert.throws( () => parseType(input), - Error, - "Failed to parse output schema as JSON5", + errorIncluding(Error, "Failed to parse output schema as JSON5"), ) } }) -Deno.test("prepareSchema - closes nested objects", () => { +test("prepareSchema - closes nested objects", () => { const { schema, wrapped } = prepareSchema( parseType("{ user: { name: 'string', age: 'number' }, tags: 'string[]' }"), ) - assertEquals(wrapped, false) - assertEquals(schema, { + assert.deepEqual(wrapped, false) + assert.deepEqual(schema, { type: "object", properties: { user: { @@ -142,13 +140,13 @@ Deno.test("prepareSchema - closes nested objects", () => { }) }) -Deno.test("prepareSchema - wraps primitive roots", () => { +test("prepareSchema - wraps primitive roots", () => { const { schema, wrapped } = prepareSchema(parseType("'yes' | 'no'"), { wrapPrimitives: true, allRequired: true, }) - assertEquals(wrapped, true) - assertEquals(schema, { + assert.deepEqual(wrapped, true) + assert.deepEqual(schema, { type: "object", properties: { value: { enum: ["no", "yes"] }, @@ -158,20 +156,20 @@ Deno.test("prepareSchema - wraps primitive roots", () => { }) }) -Deno.test("prepareSchema - can force all properties required", () => { +test("prepareSchema - can force all properties required", () => { const { schema } = prepareSchema( parseType("{ urgent: 'boolean', 'reason?': 'string' }"), { allRequired: true }, ) - assertEquals(schema.required, ["urgent", "reason"]) + assert.deepEqual(schema.required, ["urgent", "reason"]) }) -Deno.test("prepareSchema - normalizes objects inside arrays", () => { +test("prepareSchema - normalizes objects inside arrays", () => { const { schema } = prepareSchema( parseType("{ users: [{ name: 'string', 'age?': 'number' }, '[]'] }"), { allRequired: true }, ) - assertEquals(schema, { + assert.deepEqual(schema, { type: "object", properties: { users: { @@ -192,28 +190,28 @@ Deno.test("prepareSchema - normalizes objects inside arrays", () => { }) }) -Deno.test("postprocessSchemaContent - unwraps primitive wrapper", () => { - assertEquals(postprocessSchemaContent(`{"value":"hello"}`, true), "hello") - assertEquals(postprocessSchemaContent(`{"value":3}`, true), "3") - assertEquals(postprocessSchemaContent(`{"value":["a","b"]}`, true), `["a","b"]`) +test("postprocessSchemaContent - unwraps primitive wrapper", () => { + assert.deepEqual(postprocessSchemaContent(`{"value":"hello"}`, true), "hello") + assert.deepEqual(postprocessSchemaContent(`{"value":3}`, true), "3") + assert.deepEqual(postprocessSchemaContent(`{"value":["a","b"]}`, true), `["a","b"]`) }) -Deno.test("postprocessSchemaContent - removes bare string quotes", () => { - assertEquals(postprocessSchemaContent(`"hello"`, false), "hello") +test("postprocessSchemaContent - removes bare string quotes", () => { + assert.deepEqual(postprocessSchemaContent(`"hello"`, false), "hello") }) -Deno.test("postprocessSchemaContent - preserves non-wrapped JSON formatting", () => { +test("postprocessSchemaContent - preserves non-wrapped JSON formatting", () => { const content = `{ "answer": "yes" }` - assertEquals(postprocessSchemaContent(content, false), content) + assert.deepEqual(postprocessSchemaContent(content, false), content) }) -Deno.test("postprocessSchemaContent - preserves non-wrapped value property", () => { +test("postprocessSchemaContent - preserves non-wrapped value property", () => { const content = `{"value":"hello"}` - assertEquals(postprocessSchemaContent(content, false), content) + assert.deepEqual(postprocessSchemaContent(content, false), content) }) -Deno.test("postprocessSchemaContent - preserves malformed JSON", () => { - assertEquals(postprocessSchemaContent("not json", true), "not json") +test("postprocessSchemaContent - preserves malformed JSON", () => { + assert.deepEqual(postprocessSchemaContent("not json", true), "not json") }) diff --git a/storage.ts b/storage.ts index 70d69c6..af2e79b 100644 --- a/storage.ts +++ b/storage.ts @@ -1,7 +1,16 @@ -import { dirname, join } from "@std/path" +import { + mkdirSync, + readdirSync, + readFileSync, + renameSync, + rmSync, + writeFileSync, +} from "node:fs" +import { dirname, join } from "node:path" +import process from "node:process" +import { isErrno } from "./errors.ts" import { type Chat } from "./types.ts" -const HISTORY_KEY = "llm-cli" const HISTORY_LENGTH = 30 export type StoredChat = Chat & { @@ -11,8 +20,8 @@ export type StoredChat = Chat & { } function stateRoot(): string { - const stateHome = Deno.env.get("XDG_STATE_HOME") || - join(Deno.env.get("HOME")!, ".local", "state") + const stateHome = process.env.XDG_STATE_HOME || + join(process.env.HOME!, ".local", "state") return join(stateHome, "llm-cli") } @@ -44,18 +53,23 @@ export function imageFilename(prompt: string, date: Date, ext: string, index = 0 * Save a generated image under the state dir and return its absolute path. * Images are not pruned along with chat history. */ -export function saveImage(bytes: Uint8Array, prompt: string, ext: string, index = 0) { +export function saveImage( + bytes: Uint8Array, + prompt: string, + ext: string, + index = 0, + date = new Date(), +) { const dir = imagesPath() - Deno.mkdirSync(dir, { recursive: true }) - const date = new Date() + mkdirSync(dir, { recursive: true }) for (let i = index;; i++) { const path = join(dir, imageFilename(prompt, date, ext, i)) try { - Deno.writeFileSync(path, bytes, { createNew: true }) + writeFileSync(path, bytes, { flag: "wx" }) return path } catch (e) { // Another generation may have finished in the same second with the same slug. - if (!(e instanceof Deno.errors.AlreadyExists)) throw e + if (!isErrno(e, "EEXIST")) throw e } } } @@ -81,25 +95,6 @@ function date(value: Date | string): Date { return value instanceof Date ? value : new Date(value) } -function backfillLegacyMessageTimes(chats: Chat[], baseTime = Date.now()): Chat[] { - const totalTicks = chats.reduce( - (sum, chat) => sum + Math.max(1, chat.messages.length), - 0, - ) - const startTime = baseTime - totalTicks - let i = 0 - - for (const chat of chats) { - for (const message of chat.messages) { - message.createdAt ??= new Date(startTime + i) - i++ - } - if (chat.messages.length === 0) i++ - } - - return chats -} - function normalizeChat(chat: Chat): Chat { chat.createdAt = date(chat.createdAt) for (const message of chat.messages) { @@ -119,15 +114,6 @@ function lastMessageTime(chat: Chat): Date | undefined { return chat.messages.at(-1)?.createdAt } -function parseHistory(contents: string): Chat[] { - const chats = parseJson(contents) - for (const chat of chats) { - if (!chat.id) chat.id = crypto.randomUUID() - normalizeChat(chat) - } - return backfillLegacyMessageTimes(chats) -} - function toStoredChat(chat: Chat | StoredChat): StoredChat { const now = new Date() const maybeStored = chat as Partial @@ -142,22 +128,14 @@ function toStoredChat(chat: Chat | StoredChat): StoredChat { } function writeJsonAtomic(path: string, value: unknown) { - Deno.mkdirSync(dirname(path), { recursive: true }) + mkdirSync(dirname(path), { recursive: true }) const tmp = `${path}.tmp.${crypto.randomUUID()}` - Deno.writeTextFileSync(tmp, JSON.stringify(value)) - Deno.renameSync(tmp, path) -} - -function removeLegacyHistory() { - try { - localStorage.removeItem(HISTORY_KEY) - } catch { - // Legacy cleanup is best-effort once the file store is authoritative. - } + writeFileSync(tmp, JSON.stringify(value)) + renameSync(tmp, path) } function readChatFile(path: string): StoredChat { - return toStoredChat(parseJson(Deno.readTextFileSync(path))) + return toStoredChat(parseJson(readFileSync(path, "utf8"))) } function writeChatFile(chat: StoredChat): StoredChat { @@ -179,7 +157,7 @@ function assertCurrentRevision(chat: StoredChat) { ) } } catch (e) { - if (e instanceof Deno.errors.NotFound) return + if (isErrno(e, "ENOENT")) return throw e } } @@ -188,75 +166,20 @@ function writeCurrent(id: string | undefined) { if (id) { writeJsonAtomic(currentPath(), { id }) } else { - try { - Deno.removeSync(currentPath()) - } catch (e) { - if (!(e instanceof Deno.errors.NotFound)) throw e - } + rmSync(currentPath(), { force: true }) } } function readCurrentId(): string | undefined { try { - const current = parseJson<{ id?: string }>(Deno.readTextFileSync(currentPath())) + const current = parseJson<{ id?: string }>(readFileSync(currentPath(), "utf8")) return current.id } catch (e) { - if (e instanceof Deno.errors.NotFound) return undefined - throw e - } -} - -function removeIfExists(path: string, options?: Deno.RemoveOptions) { - try { - Deno.removeSync(path, options) - } catch (e) { - if (!(e instanceof Deno.errors.NotFound)) throw e - } -} - -function chatsDirExists(): boolean { - try { - return Deno.statSync(chatsPath()).isDirectory - } catch (e) { - if (e instanceof Deno.errors.NotFound) return false + if (isErrno(e, "ENOENT")) return undefined throw e } } -function migrateFromHistory(history: Chat[]) { - const truncated = history.slice(-HISTORY_LENGTH) - for (const chat of truncated) normalizeChat(chat) - backfillLegacyMessageTimes(truncated) - const activeBase = Date.now() - truncated.length - const storedChats = truncated.map((chat, index) => ({ - ...toStoredChat(chat), - lastActiveAt: lastMessageTime(chat) ?? new Date(activeBase + index), - })) - Deno.mkdirSync(chatsPath(), { recursive: true }) - for (const chat of storedChats) { - writeJsonAtomic(chatPath(chat.id), chat) - } - writeCurrent(storedChats.at(-1)?.id) - removeLegacyHistory() -} - -function migrateIfNeeded() { - if (chatsDirExists()) return - - let contents: string | null = null - try { - contents = localStorage.getItem(HISTORY_KEY) - } catch { - contents = null - } - if (contents) { - migrateFromHistory(parseHistory(contents)) - return - } - - Deno.mkdirSync(chatsPath(), { recursive: true }) -} - function sortChats(chats: StoredChat[]): StoredChat[] { return chats.sort((a, b) => { const active = a.lastActiveAt.getTime() - b.lastActiveAt.getTime() @@ -267,33 +190,28 @@ function sortChats(chats: StoredChat[]): StoredChat[] { function prune(chats: StoredChat[]) { const toDelete = sortChats([...chats]).slice(0, -HISTORY_LENGTH) for (const chat of toDelete) { - Deno.removeSync(chatPath(chat.id)) + rmSync(chatPath(chat.id)) } } export const History = { list(): StoredChat[] { - migrateIfNeeded() + mkdirSync(chatsPath(), { recursive: true }) const chats: StoredChat[] = [] - for (const entry of Deno.readDirSync(chatsPath())) { - if (!entry.isFile || !entry.name.endsWith(".json")) continue + for (const entry of readdirSync(chatsPath(), { withFileTypes: true })) { + if (!entry.isFile() || !entry.name.endsWith(".json")) continue chats.push(readChatFile(join(chatsPath(), entry.name))) } return sortChats(chats) }, - read(): StoredChat[] { - return this.list() - }, - current(): StoredChat | undefined { - migrateIfNeeded() const id = readCurrentId() if (id) { try { return readChatFile(chatPath(id)) } catch (e) { - if (!(e instanceof Deno.errors.NotFound)) throw e + if (!isErrno(e, "ENOENT")) throw e } } return undefined @@ -304,7 +222,6 @@ export const History = { }, save(chat: Chat | StoredChat, opts: { current?: boolean; touch?: boolean } = {}) { - migrateIfNeeded() const stored = toStoredChat(chat) if ("revision" in chat) assertCurrentRevision(stored) if (opts.touch) stored.lastActiveAt = new Date() @@ -324,34 +241,21 @@ export const History = { }, get(id: string): StoredChat { - migrateIfNeeded() return readChatFile(chatPath(id)) }, delete(ids: string[]) { - migrateIfNeeded() const idSet = new Set(ids) for (const id of idSet) { - try { - Deno.removeSync(chatPath(id)) - } catch (e) { - if (!(e instanceof Deno.errors.NotFound)) throw e - } + rmSync(chatPath(id), { force: true }) } if (idSet.has(readCurrentId() ?? "")) { writeCurrent(this.list().at(-1)?.id) } }, - write(history: Chat[]) { - removeIfExists(chatsPath(), { recursive: true }) - migrateFromHistory(history) - }, - clear() { - removeIfExists(chatsPath(), { recursive: true }) - Deno.mkdirSync(chatsPath(), { recursive: true }) - removeIfExists(currentPath()) - removeLegacyHistory() + rmSync(chatsPath(), { recursive: true, force: true }) + rmSync(currentPath(), { force: true }) }, } diff --git a/storage_test.ts b/storage_test.ts index 3874aab..220ab17 100644 --- a/storage_test.ts +++ b/storage_test.ts @@ -1,5 +1,10 @@ -import { assertEquals, assertThrows } from "@std/assert" -import { join } from "@std/path" +import assert from "node:assert/strict" +import { test } from "node:test" +import { errorIncluding } from "./testing.ts" +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" +import process from "node:process" import { History, imageFilename, saveImage } from "./storage.ts" import type { Chat } from "./types.ts" @@ -13,32 +18,32 @@ function chat(id: string, createdAt: string): Chat { } function withTempState(fn: (stateHome: string) => void) { - const oldStateHome = Deno.env.get("XDG_STATE_HOME") - const stateHome = Deno.makeTempDirSync({ dir: "/tmp" }) - Deno.env.set("XDG_STATE_HOME", stateHome) + const oldStateHome = process.env.XDG_STATE_HOME + const stateHome = mkdtempSync(join(tmpdir(), "llm-storage-test-")) + process.env.XDG_STATE_HOME = stateHome try { fn(stateHome) } finally { if (oldStateHome === undefined) { - Deno.env.delete("XDG_STATE_HOME") + delete process.env.XDG_STATE_HOME } else { - Deno.env.set("XDG_STATE_HOME", oldStateHome) + process.env.XDG_STATE_HOME = oldStateHome } - Deno.removeSync(stateHome, { recursive: true }) + rmSync(stateHome, { recursive: true }) } } -Deno.test("History.save stores chats independently and tracks current", () => { +test("History.save stores chats independently and tracks current", () => { withTempState(() => { History.save(chat("one", "2026-01-01T00:00:00Z"), { current: true }) History.save(chat("two", "2026-01-02T00:00:00Z"), { current: true }) - assertEquals(History.read().map((c) => c.id), ["one", "two"]) - assertEquals(History.current()?.id, "two") + assert.deepEqual(History.list().map((c) => c.id), ["one", "two"]) + assert.deepEqual(History.current()?.id, "two") }) }) -Deno.test("History preserves multiple images and loads legacy single-image messages", () => { +test("History preserves multiple images and loads legacy single-image messages", () => { withTempState((stateHome) => { const images = ["data:image/png;base64,AQID", "https://example.com/second.jpg"] const saved = chat("images", "2026-01-01T00:00:00Z") @@ -49,104 +54,55 @@ Deno.test("History preserves multiple images and loads legacy single-image messa image_urls: images, }) History.save(saved, { current: true }) - assertEquals(History.current()?.messages[0], saved.messages[0]) + assert.deepEqual(History.current()?.messages[0], saved.messages[0]) const path = join(stateHome, "llm-cli", "chats", "images.json") - const legacy = JSON.parse(Deno.readTextFileSync(path)) + const legacy = JSON.parse(readFileSync(path, "utf8")) delete legacy.messages[0].image_urls legacy.messages[0].image_url = images[0] - Deno.writeTextFileSync(path, JSON.stringify(legacy)) + writeFileSync(path, JSON.stringify(legacy)) const loaded = History.current()! - assertEquals(loaded.messages[0], { + assert.deepEqual(loaded.messages[0], { role: "user", content: "Compare these", createdAt: saved.createdAt, image_urls: [images[0]], }) - assertEquals(JSON.parse(Deno.readTextFileSync(path)).messages[0].image_url, images[0]) + assert.deepEqual( + JSON.parse(readFileSync(path, "utf8")).messages[0].image_url, + images[0], + ) History.save(loaded) - const persisted = JSON.parse(Deno.readTextFileSync(path)).messages[0] - assertEquals(persisted.image_urls, [images[0]]) - assertEquals("image_url" in persisted, false) + const persisted = JSON.parse(readFileSync(path, "utf8")).messages[0] + assert.deepEqual(persisted.image_urls, [images[0]]) + assert.deepEqual("image_url" in persisted, false) }) }) -Deno.test("History.delete removes selected chat without rewriting others", () => { +test("History.delete removes selected chat without rewriting others", () => { withTempState(() => { History.save(chat("one", "2026-01-01T00:00:00Z"), { current: true }) History.save(chat("two", "2026-01-02T00:00:00Z"), { current: true }) History.delete(["one"]) - assertEquals(History.read().map((c) => c.id), ["two"]) - assertEquals(History.current()?.id, "two") + assert.deepEqual(History.list().map((c) => c.id), ["two"]) + assert.deepEqual(History.current()?.id, "two") }) }) -Deno.test("History.clear leaves empty per-chat store tombstone", () => { +test("History.clear removes every chat", () => { withTempState(() => { History.save(chat("one", "2026-01-01T00:00:00Z"), { current: true }) History.clear() - assertEquals(History.read(), []) - }) -}) - -Deno.test("History.write preserves legacy history recency order", () => { - withTempState((stateHome) => { - const root = join(stateHome, "llm-cli") - History.write([ - chat("one", "2026-01-02T00:00:00Z"), - chat("two", "2026-01-01T00:00:00Z"), - ]) - - assertEquals(History.read().map((c) => c.id), ["one", "two"]) - assertEquals(History.current()?.id, "two") - assertEquals(Deno.statSync(join(root, "chats", "one.json")).isFile, true) - assertEquals(Deno.statSync(join(root, "chats", "two.json")).isFile, true) - }) -}) - -Deno.test("History.write backfills unique message timestamps", () => { - withTempState(() => { - History.write(JSON.parse(JSON.stringify([ - { - id: "one", - createdAt: "2026-01-02T00:00:00Z", - systemPrompt: "test", - messages: [ - { role: "user", content: "one" }, - { - role: "assistant", - model: "test", - content: "two", - tokens: { input: 1, output: 1 }, - stop_reason: "stop", - cost: 0, - timeMs: 1, - }, - ], - }, - { - id: "two", - createdAt: "2026-01-01T00:00:00Z", - systemPrompt: "test", - messages: [{ role: "user", content: "three" }], - }, - ]))) - - const messages = History.read().flatMap((c) => c.messages) - const times = messages.map((m) => m.createdAt.getTime()) - - assertEquals(new Set(times).size, 3) - assertEquals([...times].sort((a, b) => a - b), times) - assertEquals(History.current()?.lastActiveAt, messages.at(-1)?.createdAt) + assert.deepEqual(History.list(), []) }) }) -Deno.test("History.save rejects stale same-chat writes", () => { +test("History.save rejects stale same-chat writes", () => { withTempState(() => { History.save(chat("one", "2026-01-01T00:00:00Z"), { current: true }) const first = History.current()! @@ -156,45 +112,33 @@ Deno.test("History.save rejects stale same-chat writes", () => { History.save(first) second.summary = "second" - assertThrows( - () => History.save(second), - Error, - "changed concurrently", - ) - assertEquals(History.current()?.summary, "first") + assert.throws(() => History.save(second), errorIncluding(Error, "changed concurrently")) + assert.deepEqual(History.current()?.summary, "first") }) }) -Deno.test("imageFilename uses local timestamp and prompt slug", () => { +test("imageFilename uses local timestamp and prompt slug", () => { const date = new Date(2026, 8, 23, 14, 5, 9) - assertEquals( + assert.deepEqual( imageFilename("A cat, in a hat!", date, "png"), "20260923-140509-a-cat-in-a-hat.png", ) - assertEquals(imageFilename("", date, "png", 1), "20260923-140509-2.png") - assertEquals( + assert.deepEqual(imageFilename("", date, "png", 1), "20260923-140509-2.png") + assert.deepEqual( imageFilename("x".repeat(50) + " tail", date, "png"), `20260923-140509-${"x".repeat(40)}.png`, ) }) -Deno.test("saveImage preserves a file created concurrently at the same path", () => { - withTempState(() => { - const write = Deno.writeFileSync - let existing: string | URL | undefined - Deno.writeFileSync = (path, bytes, options) => { - if (!existing) { - existing = path - write(path, new Uint8Array([1])) - } - write(path, bytes, options) - } - try { - const saved = saveImage(new Uint8Array([2]), "same prompt", "png") - assertEquals([...Deno.readFileSync(existing!)], [1]) - assertEquals([...Deno.readFileSync(saved)], [2]) - } finally { - Deno.writeFileSync = write - } +test("saveImage keeps an existing file with the same name", () => { + withTempState((stateHome) => { + const date = new Date(2026, 8, 23, 14, 5, 9) + const dir = join(stateHome, "llm-cli", "images") + const existing = join(dir, imageFilename("same prompt", date, "png")) + mkdirSync(dir, { recursive: true }) + writeFileSync(existing, new Uint8Array([1])) + const saved = saveImage(new Uint8Array([2]), "same prompt", "png", 0, date) + assert.deepEqual([...readFileSync(existing)], [1]) + assert.deepEqual([...readFileSync(saved)], [2]) }) }) diff --git a/summarize.ts b/summarize.ts index 37d25c2..f73755e 100644 --- a/summarize.ts +++ b/summarize.ts @@ -1,4 +1,4 @@ -import $ from "@david/dax" +import $ from "dax" import { createMessage } from "./adapters/mod.ts" import { type Chat } from "./types.ts" diff --git a/terminal-image.ts b/terminal-image.ts index c777cd2..5687eec 100644 --- a/terminal-image.ts +++ b/terminal-image.ts @@ -1,8 +1,9 @@ -import { encodeBase64 } from "@std/encoding/base64" +import { Buffer } from "node:buffer" +import process from "node:process" export function supportsKittyGraphics( - isTerminal = Deno.stdout.isTerminal(), - env: (key: string) => string | undefined = (key) => Deno.env.get(key), + isTerminal = process.stdout.isTTY ?? false, + env: (key: string) => string | undefined = (key) => process.env[key], ): boolean { if (!isTerminal || env("TMUX") || env("STY") || env("TERM") === "dumb") return false return env("TERM_PROGRAM") === "ghostty" || @@ -16,7 +17,7 @@ export function supportsKittyGraphics( * also works over SSH. */ export function kittyTransmit(png: Uint8Array, control: string): string { - const payload = encodeBase64(png) + const payload = Buffer.from(png).toString("base64") let out = "" for (let offset = 0; offset < payload.length; offset += 4096) { const more = offset + 4096 < payload.length ? 1 : 0 diff --git a/terminal-image_test.ts b/terminal-image_test.ts index 752957a..8d3d54f 100644 --- a/terminal-image_test.ts +++ b/terminal-image_test.ts @@ -1,5 +1,5 @@ -// deno-lint-ignore-file no-control-regex -import { assert, assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" import { imageColumns, kittyPng, @@ -16,30 +16,30 @@ function fakePng(width: number, height: number, extra = 0) { return bytes } -Deno.test("pngDimensions reads IHDR", () => { - assertEquals(pngDimensions(fakePng(1536, 1024)), { width: 1536, height: 1024 }) +test("pngDimensions reads IHDR", () => { + assert.deepEqual(pngDimensions(fakePng(1536, 1024)), { width: 1536, height: 1024 }) }) -Deno.test("imageColumns caps at 80 and fits the screen height", () => { +test("imageColumns caps at 80 and fits the screen height", () => { const term = { columns: 200, rows: 100 } - assertEquals(imageColumns(fakePng(1024, 1024), term), 80) + assert.deepEqual(imageColumns(fakePng(1024, 1024), term), 80) // 44 usable rows × 2 cells tall per column → 88 columns for a square image - assertEquals(imageColumns(fakePng(1024, 1024), { columns: 200, rows: 48 }), 80) - assertEquals(imageColumns(fakePng(1024, 1024), { columns: 200, rows: 24 }), 40) - assertEquals(imageColumns(fakePng(1024, 1024), { columns: 30, rows: 100 }), 30) + assert.deepEqual(imageColumns(fakePng(1024, 1024), { columns: 200, rows: 48 }), 80) + assert.deepEqual(imageColumns(fakePng(1024, 1024), { columns: 200, rows: 24 }), 40) + assert.deepEqual(imageColumns(fakePng(1024, 1024), { columns: 30, rows: 100 }), 30) // portrait: 20 rows × 2 × (1024/1536) = 26.67 - assertEquals(imageColumns(fakePng(1024, 1536), { columns: 200, rows: 24 }), 26) + assert.deepEqual(imageColumns(fakePng(1024, 1536), { columns: 200, rows: 24 }), 26) }) -Deno.test("kittyPng places in one command with chunked payload", () => { +test("kittyPng places in one command with chunked payload", () => { const out = kittyPng(fakePng(10, 10, 9000), 40) const chunks = [...out.matchAll(/\x1b_G([^;]*);/g)].map((m) => m[1]) - assertEquals(chunks[0], "a=T,f=100,t=d,q=2,c=40,m=1") - assertEquals(chunks.slice(1), ["q=2,m=1", "q=2,m=0"]) - assertEquals(out.at(-1), "\n") + assert.deepEqual(chunks[0], "a=T,f=100,t=d,q=2,c=40,m=1") + assert.deepEqual(chunks.slice(1), ["q=2,m=1", "q=2,m=0"]) + assert.deepEqual(out.at(-1), "\n") }) -Deno.test("Kitty detection requires a supported terminal outside multiplexers", () => { +test("Kitty detection requires a supported terminal outside multiplexers", () => { for ( const env of [{ TERM_PROGRAM: "ghostty" }, { TERM: "xterm-ghostty" }, { TERM: "xterm-kitty", diff --git a/terminal-math.ts b/terminal-math.ts index 9df828d..d9df91f 100644 --- a/terminal-math.ts +++ b/terminal-math.ts @@ -1,4 +1,5 @@ import type { MarkdownExit, RenderRule } from "markdown-exit" +import process from "node:process" import { kittyTransmit } from "./terminal-image.ts" import type { MathImage } from "./math-image.ts" @@ -102,9 +103,7 @@ export default function mathPlugin(md: MarkdownExit): void { if (!env.math) return token.markup + suffix try { const { renderMathImage } = await import("./math-image.ts") - const width = Deno.stdout.isTerminal() - ? Math.min(Deno.consoleSize().columns, 100) - : 80 + const width = process.stdout.isTTY ? Math.min(process.stdout.columns, 100) : 80 const image = await renderMathImage( token.content, block, diff --git a/terminal-math_test.ts b/terminal-math_test.ts index 6a052b6..c16b44b 100644 --- a/terminal-math_test.ts +++ b/terminal-math_test.ts @@ -1,6 +1,7 @@ -// deno-lint-ignore-file no-control-regex -import { assert, assertEquals, assertRejects } from "@std/assert" -import { decodeBase64, encodeBase64 } from "@std/encoding/base64" +import assert from "node:assert/strict" +import { test } from "node:test" +import { Buffer } from "node:buffer" +import { readFile } from "node:fs/promises" import { Resvg } from "@resvg/resvg-wasm" import { renderMarkdown } from "./md-render.ts" import { kittyImage } from "./terminal-math.ts" @@ -9,14 +10,14 @@ import { renderMathImage } from "./math-image.ts" const strip = (s: string) => s.replace(/\x1b\[[0-9;]*m/g, "").replaceAll(" ", " ") const imageCount = (s: string) => [...s.matchAll(/\x1b_Ga=t,/g)].length -Deno.test("short inline symbols occupy one terminal cell", async () => { +test("short inline symbols occupy one terminal cell", async () => { for (const tex of [String.raw`\nu`, "f", "x"]) { const image = await renderMathImage(tex, false, 80, "#c8c8c8") - assertEquals(image.columns, 1, tex) + assert.deepEqual(image.columns, 1, tex) } }) -Deno.test("inline glyphs share a baseline regardless of their height", async () => { +test("inline glyphs share a baseline regardless of their height", async () => { const bottoms: number[] = [] for (const tex of [String.raw`\nu`, "H", "x^2"]) { const image = await renderMathImage(tex, false, 80, "#c8c8c8") @@ -25,7 +26,7 @@ Deno.test("inline glyphs share a baseline regardless of their height", async () const height = header.getUint32(20) const decoder = new Resvg( ``, ) try { @@ -48,7 +49,7 @@ Deno.test("inline glyphs share a baseline regardless of their height", async () assert(Math.max(...bottoms) - Math.min(...bottoms) <= 1, `Ink bottoms: ${bottoms}`) }) -Deno.test("math delimiters render inside prose without consuming punctuation", async () => { +test("math delimiters render inside prose without consuming punctuation", async () => { for ( const math of [ String.raw`$\nu>0$`, @@ -60,14 +61,14 @@ Deno.test("math delimiters render inside prose without consuming punctuation", a ] ) { const out = await renderMarkdown(`Before **${math}**, after.`, { math: true }) - assertEquals(imageCount(out), 1, math) + assert.deepEqual(imageCount(out), 1, math) assert(strip(out).startsWith("Before ")) assert(strip(out).endsWith(", after.")) assert(!/[\ue000-\uf8ff]/.test(out)) } }) -Deno.test("math leaves currency, escaped dollars, and code alone", async () => { +test("math leaves currency, escaped dollars, and code alone", async () => { for ( const text of [ "between $50 to $100", @@ -84,11 +85,11 @@ Deno.test("math leaves currency, escaped dollars, and code alone", async () => { "[link](https://example.com/$x$)", ] ) { - assertEquals(imageCount(await renderMarkdown(text, { math: true })), 0, text) + assert.deepEqual(imageCount(await renderMarkdown(text, { math: true })), 0, text) } }) -Deno.test("disabled and invalid math preserve the raw TeX", async () => { +test("disabled and invalid math preserve the raw TeX", async () => { for ( const text of [ String.raw`With $x_i^2$ and \(\nu>0\).`, @@ -96,20 +97,20 @@ Deno.test("disabled and invalid math preserve the raw TeX", async () => { String.raw`\[x_i^2\]`, ] ) { - assertEquals(strip(await renderMarkdown(text, { math: false })), text) + assert.deepEqual(strip(await renderMarkdown(text, { math: false })), text) } const invalid = String.raw`$\notARealCommand{$` - assertEquals(strip(await renderMarkdown(invalid, { math: true })), invalid) + assert.deepEqual(strip(await renderMarkdown(invalid, { math: true })), invalid) }) -Deno.test("display math interrupts paragraphs and retains following text", async () => { +test("display math interrupts paragraphs and retains following text", async () => { const out = await renderMarkdown("Before\n$$\nx^2\n$$\nAfter", { math: true }) - assertEquals(imageCount(out), 1) + assert.deepEqual(imageCount(out), 1) assert(out.startsWith("Before\n\n")) assert(out.endsWith("\n\nAfter")) }) -Deno.test("math graphics survive wrapping, blockquotes, lists, and tables", async () => { +test("math graphics survive wrapping, blockquotes, lists, and tables", async () => { for ( const text of [ "word ".repeat(20) + "$x^2$ after", @@ -131,7 +132,7 @@ Deno.test("math graphics survive wrapping, blockquotes, lists, and tables", asyn } }) -Deno.test("PNG chunks roundtrip and row placements reserve the correct cells", () => { +test("PNG chunks roundtrip and row placements reserve the correct cells", () => { const png = new Uint8Array(12000).map((_, i) => i % 256) const rows = kittyImage({ png, columns: 12, rows: 3, rowPixels: 60 }, 42) const chunks = [...rows[0].matchAll(/\x1b_G([^;]+);([^\x1b]*)\x1b\\/g)] @@ -139,23 +140,26 @@ Deno.test("PNG chunks roundtrip and row placements reserve the correct cells", ( assert(chunks.every((c) => c[2].length <= 4096 && c[2].length % 4 === 0)) assert(chunks.slice(0, -1).every((c) => c[1].endsWith("m=1"))) assert(chunks.at(-1)![1].endsWith("m=0")) - assertEquals(decodeBase64(chunks.map((c) => c[2]).join("")), png) + assert.deepEqual( + new Uint8Array(Buffer.from(chunks.map((c) => c[2]).join(""), "base64")), + png, + ) for (let row = 0; row < 3; row++) { assert(rows[row].includes(`C=1,y=${row * 60},h=60,c=12,r=1`)) assert(rows[row].endsWith(" ".repeat(12))) } }) -Deno.test("MathJax rasterizes the example and constrains narrow/tall equations", async () => { +test("MathJax rasterizes the example and constrains narrow/tall equations", async () => { const tex = String .raw`\partial_t u + (u\cdot\nabla)u = -\nabla p + \nu\Delta u + f, \qquad \nabla\cdot u = 0` for (const width of [20, 80]) { const image = await renderMathImage(tex, true, width, "#c8c8c8") - assertEquals([...image.png.slice(0, 8)], [137, 80, 78, 71, 13, 10, 26, 10]) + assert.deepEqual(Array.from(image.png.slice(0, 8)), [137, 80, 78, 71, 13, 10, 26, 10]) assert(image.columns <= width) const header = new DataView(image.png.buffer, image.png.byteOffset) - assertEquals(header.getUint32(16), image.columns * 30) - assertEquals(header.getUint32(20), image.rows * image.rowPixels) + assert.deepEqual(header.getUint32(16), image.columns * 30) + assert.deepEqual(header.getUint32(20), image.rows * image.rowPixels) } const tall = await renderMathImage( String.raw`\frac{\frac{a}{b}}{\frac{c}{d}}`, @@ -163,23 +167,24 @@ Deno.test("MathJax rasterizes the example and constrains narrow/tall equations", 80, "#c8c8c8", ) - assertEquals(tall.rows, 1) - await assertRejects(() => renderMathImage(String.raw`\invalid{`, false, 80, "#c8c8c8")) + assert.deepEqual(tall.rows, 1) + await assert.rejects(() => renderMathImage(String.raw`\invalid{`, false, 80, "#c8c8c8")) }) -Deno.test("SVG serialization escapes inequalities in MathJax attributes", async () => { +test("SVG serialization escapes inequalities in MathJax attributes", async () => { const tex = String.raw`|x|=\begin{cases}-x & x<0\\x & x\geq0\end{cases}` const image = await renderMathImage(tex, true, 80, "#c8c8c8") assert(image.rows > 1) - assertEquals(imageCount(await renderMarkdown(`$$\n${tex}\n$$`, { math: true })), 1) + assert.deepEqual(imageCount(await renderMarkdown(`$$\n${tex}\n$$`, { math: true })), 1) }) -Deno.test("the complete demo renders every valid equation", async () => { - const text = await Deno.readTextFile( +test("the complete demo renders every valid equation", async () => { + const text = await readFile( new URL("./fixtures/terminal-math.md", import.meta.url), + "utf8", ) const output = await renderMarkdown(text, { math: true }) - assertEquals(imageCount(output), 31) + assert.deepEqual(imageCount(output), 31) assert(!output.includes(String.raw`\begin{bmatrix}`)) assert(!output.includes(String.raw`\begin{cases}`)) assert(!output.includes(String.raw`\begin{aligned}`)) diff --git a/testing.ts b/testing.ts new file mode 100644 index 0000000..8c5b095 --- /dev/null +++ b/testing.ts @@ -0,0 +1,21 @@ +import assert from "node:assert/strict" + +/** + * An `assert.throws`/`assert.rejects` validator for an instance of `type` whose + * message includes `text`. Node's own third argument is the failure message, + * not a substring to match. + */ +export function errorIncluding(type: abstract new (...args: never) => Error, text: string) { + return (e: unknown) => { + assert(e instanceof type, `Expected ${type.name}, got ${e}`) + assert(e.message.includes(text), `Expected "${e.message}" to include "${text}"`) + return true + } +} + +export function assertAlmostEqual(actual: number, expected: number, tolerance = 1e-7) { + assert( + Math.abs(actual - expected) < tolerance, + `Expected ${actual} to be within ${tolerance} of ${expected}`, + ) +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ecce2f9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "nodenext", + "lib": ["esnext"], + "types": ["node"], + "noEmit": true, + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "erasableSyntaxOnly": true, + "strict": true, + "noImplicitOverride": true, + "skipLibCheck": true + }, + "exclude": ["node_modules"] +} diff --git a/types_test.ts b/types_test.ts index 8c1c9b0..2b5668c 100644 --- a/types_test.ts +++ b/types_test.ts @@ -1,9 +1,10 @@ -import { assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" import { resolveThink } from "./types.ts" -Deno.test("resolveThink inherits, replaces, and clears sticky state", () => { - assertEquals(resolveThink(undefined, "high"), "high") - assertEquals(resolveThink("off", "high"), "off") - assertEquals(resolveThink("default", "high"), undefined) +test("resolveThink inherits, replaces, and clears sticky state", () => { + assert.deepEqual(resolveThink(undefined, "high"), "high") + assert.deepEqual(resolveThink("off", "high"), "off") + assert.deepEqual(resolveThink("default", "high"), undefined) }) diff --git a/utils.ts b/utils.ts index 7139a72..6157dd5 100644 --- a/utils.ts +++ b/utils.ts @@ -1,235 +1,19 @@ -import { ValidationError } from "./errors.ts" -import { encodeBase64 } from "@std/encoding/base64" -import { join } from "@std/path" -import $ from "@david/dax" -import * as R from "remeda" - -const parsePart = (part: string, msgCount: number): number[] => { - if (part === "even" || part === "odd") { - const start = part === "even" ? 2 : 1 - return R.range(start, msgCount + 1).filter((n) => n % 2 === (part === "even" ? 0 : 1)) - } - - if (/^\d+-\d+$/.test(part)) { - const [startStr, endStr] = part.split("-") - const start = Number(startStr) - const end = Number(endStr) - if (start > end) { - throw new ValidationError(`Invalid range: start > end in "${part}"`) - } - return R.range(start, end + 1) - } - - if (/^\d+$/.test(part)) { - return [Number(part)] - } - - throw new ValidationError( - part.includes("-") ? `Invalid range: "${part}"` : `Invalid message number: "${part}"`, - ) -} - -/** - * Parse a message spec like "1,3-4,7" into a sorted array of 0-based indices. - * Message numbers in the spec are 1-based (user-facing). The keywords "even" - * and "odd" expand to all even/odd message numbers. - * Throws if a range has start > end or if any number is out of bounds. - */ -export function parseMessageSpec(spec: string, msgCount: number): number[] { - const indices = R.pipe( - spec.replaceAll(" ", "").split(","), - R.filter((p) => p.length > 0), - R.flatMap((part) => parsePart(part, msgCount)), - R.unique(), - R.sortBy(R.identity()), - ) - - for (const num of indices) { - if (num < 1 || num > msgCount) { - throw new ValidationError( - `Message ${num} does not exist (chat has ${msgCount} messages)`, - ) - } - } - - return R.map(indices, (n) => n - 1) // make 0-indexed -} - -const IMAGE_MIME_TYPES = [ - "image/png", - "image/jpeg", - "image/gif", - "image/webp", -] as const -export type ImageMimeType = typeof IMAGE_MIME_TYPES[number] - -function isImageMimeType(s: string): s is ImageMimeType { - return (IMAGE_MIME_TYPES as readonly string[]).includes(s) -} - -const EXT_MIME: Record = { - png: "image/png", - jpg: "image/jpeg", - jpeg: "image/jpeg", - gif: "image/gif", - webp: "image/webp", -} - -/** Parse a data URL into image media type and raw base64 payload, or null. - * Returns null for non-data URLs or unsupported media types. */ -export function parseDataUrl( - url: string, -): { mediaType: ImageMimeType; data: string } | null { - const m = /^data:([^;]+);base64,(.+)$/s.exec(url) - if (!m || !isImageMimeType(m[1])) return null - return { mediaType: m[1], data: m[2] } -} - -/** - * Read a PNG image from the macOS clipboard via `osascript`. The clipboard - * lives in NSPasteboard, so we have to go through an OS-level helper; we use - * osascript because it ships with macOS (no install step). Returns the raw - * bytes; only PNG is supported, which covers screenshots and browser - * "copy image" out of the box. - */ -async function readClipboardImage(): Promise { - if (Deno.build.os !== "darwin") { - throw new ValidationError( - "Clipboard image paste is only supported on macOS", - ) - } - // Pinned to /tmp so the shebang can scope --allow-write narrowly. Deno's - // default temp dir on macOS is $TMPDIR (/var/folders/...), which can't be - // expressed statically in a shebang. - const tmpPath = await Deno.makeTempFile({ dir: "/tmp", suffix: ".png" }) - try { - const result = await $`osascript \ - -e ${`set png_data to (the clipboard as «class PNGf»)`} \ - -e ${`set f to open for access POSIX file ${ - JSON.stringify(tmpPath) - } with write permission`} \ - -e ${`set eof f to 0`} \ - -e ${`write png_data to f`} \ - -e ${`close access f`}` - .stderr("piped").noThrow() - if (result.code !== 0) { - // osascript -1700 = "can't make ... into type PNGf" → no image on clipboard - const noImage = /-1700|class PNGf/.test(result.stderr) - throw new ValidationError( - noImage - ? "No image found in clipboard" - : `osascript failed: ${result.stderr.trim()}`, - ) - } - return await Deno.readFile(tmpPath) - } finally { - await Deno.remove(tmpPath).catch(() => {}) - } -} - -/** Convert a local HEIC/HEIF through macOS's optional image converter. */ -async function convertHeicImage(value: string): Promise { - let sourcePath: string - try { - sourcePath = await Deno.realPath(value) - } catch (e) { - const msg = e instanceof Error ? e.message : String(e) - throw new ValidationError(`Could not read image at '${value}': ${msg}`) - } - const tmpDir = await Deno.makeTempDir({ - dir: Deno.build.os === "darwin" ? "/tmp" : undefined, - prefix: "llm-heic-", +/** Integers from `start` up to but not including `end`. */ +export function range(start: number, end: number): number[] { + return Array.from({ length: Math.max(0, end - start) }, (_, i) => start + i) +} + +/** Keep the first item for each key, in order. */ +export function uniqueBy(items: T[], key: (item: T) => unknown): T[] { + const seen = new Set() + return items.filter((item) => { + const k = key(item) + if (seen.has(k)) return false + seen.add(k) + return true }) - try { - const outputPath = join(tmpDir, "converted.jpg") - let result: Deno.CommandOutput - try { - result = await new Deno.Command("sips", { - args: [ - "--setProperty", - "format", - "jpeg", - "--setProperty", - "formatOptions", - "90", - sourcePath, - "--out", - outputPath, - ], - stdout: "null", - stderr: "piped", - }).output() - } catch (e) { - if (e instanceof Deno.errors.NotFound) { - throw new ValidationError( - "HEIC conversion requires macOS's 'sips'. Convert the image to JPEG or PNG first.", - ) - } - throw e - } - if (!result.success) { - const error = new TextDecoder().decode(result.stderr).trim() || `exit ${result.code}` - throw new ValidationError(`Could not convert HEIC image at '${value}': ${error}`) - } - let bytes: Uint8Array - try { - bytes = await Deno.readFile(outputPath) - } catch (e) { - if (e instanceof Deno.errors.NotFound) { - throw new ValidationError( - `Could not convert HEIC image at '${value}': sips did not produce a JPEG`, - ) - } - throw e - } - // sips can exit successfully after writing only JPEG headers if encoding fails. - if ( - bytes.length < 4 || bytes[0] !== 0xff || bytes[1] !== 0xd8 || - bytes.at(-2) !== 0xff || bytes.at(-1) !== 0xd9 - ) { - throw new ValidationError( - `Could not convert HEIC image at '${value}': incomplete JPEG`, - ) - } - return bytes - } finally { - await Deno.remove(tmpDir, { recursive: true }) - } } -/** - * Resolve `--image ` to a URL string. The sentinel `clipboard` pulls a - * PNG from the macOS clipboard. `http(s)` URLs pass through. Any other value - * is treated as a local file path, read, base64-encoded, and returned as a - * `data:` URL. Local HEIC/HEIF files are converted to JPEG through `sips`. - */ -export async function resolveImage(value: string): Promise { - if (value === "clipboard") { - const bytes = await readClipboardImage() - return `data:image/png;base64,${encodeBase64(bytes)}` - } - if (/^https?:\/\//i.test(value)) return value - - const ext = value.split(".").pop()?.toLowerCase() ?? "" - if (ext === "heic" || ext === "heif") { - const bytes = await convertHeicImage(value) - return `data:image/jpeg;base64,${encodeBase64(bytes)}` - } - - let bytes: Uint8Array - try { - bytes = await Deno.readFile(value) - } catch (e) { - const msg = e instanceof Error ? e.message : String(e) - throw new ValidationError(`Could not read image at '${value}': ${msg}`) - } - const mediaType = EXT_MIME[ext] - if (!mediaType) { - throw new ValidationError( - `Unsupported image extension '.${ext}'. Supported: ${ - [...Object.keys(EXT_MIME), "heic/heif (requires sips)"].join(", ") - }`, - ) - } - return `data:${mediaType};base64,${encodeBase64(bytes)}` +export function pick(obj: T, keys: K[]): Pick { + return Object.fromEntries(keys.map((k) => [k, obj[k]])) as Pick } diff --git a/utils_test.ts b/utils_test.ts index a0365f3..b4f5087 100644 --- a/utils_test.ts +++ b/utils_test.ts @@ -1,269 +1,19 @@ -import { assertEquals, assertRejects, assertThrows } from "@std/assert" -import { ValidationError } from "./errors.ts" -import { dirname, join } from "@std/path" -import { parseDataUrl, parseMessageSpec, resolveImage } from "./utils.ts" +import assert from "node:assert/strict" +import { test } from "node:test" -Deno.test("parseMessageSpec - single number", () => { - assertEquals(parseMessageSpec("3", 5), [2]) -}) - -Deno.test("parseMessageSpec - multiple numbers", () => { - assertEquals(parseMessageSpec("1,3,5", 5), [0, 2, 4]) -}) - -Deno.test("parseMessageSpec - range", () => { - assertEquals(parseMessageSpec("2-4", 5), [1, 2, 3]) -}) - -Deno.test("parseMessageSpec - mixed numbers and ranges", () => { - assertEquals(parseMessageSpec("1,3-4,7", 10), [0, 2, 3, 6]) -}) - -Deno.test("parseMessageSpec - even keyword", () => { - // 1-based even message numbers 2,4,6 -> 0-based - assertEquals(parseMessageSpec("even", 6), [1, 3, 5]) -}) - -Deno.test("parseMessageSpec - odd keyword", () => { - // 1-based odd message numbers 1,3,5 -> 0-based - assertEquals(parseMessageSpec("odd", 6), [0, 2, 4]) -}) - -Deno.test("parseMessageSpec - even/odd combine with numbers and dedupe", () => { - assertEquals(parseMessageSpec("odd,2", 5), [0, 1, 2, 4]) -}) - -Deno.test("parseMessageSpec - out of order input returns sorted", () => { - assertEquals(parseMessageSpec("7,1,3-4", 10), [0, 2, 3, 6]) -}) - -Deno.test("parseMessageSpec - duplicates are deduplicated", () => { - assertEquals(parseMessageSpec("1,1,2-3,3", 5), [0, 1, 2]) -}) - -Deno.test("parseMessageSpec - whitespace is tolerated", () => { - assertEquals(parseMessageSpec(" 1 , 3 - 4 , 7 ", 10), [0, 2, 3, 6]) -}) - -Deno.test("parseMessageSpec - range start > end throws", () => { - assertThrows( - () => parseMessageSpec("4-2", 5), - ValidationError, - "Invalid range: start > end", - ) -}) - -Deno.test("parseMessageSpec - message number too high throws", () => { - assertThrows( - () => parseMessageSpec("1,10", 5), - ValidationError, - "Message 10 does not exist (chat has 5 messages)", - ) -}) - -Deno.test("parseMessageSpec - message number 0 throws", () => { - assertThrows( - () => parseMessageSpec("0", 5), - ValidationError, - "Message 0 does not exist", - ) -}) - -Deno.test("parseMessageSpec - invalid number throws", () => { - assertThrows( - () => parseMessageSpec("abc", 5), - ValidationError, - "Invalid message number", - ) -}) - -Deno.test("parseMessageSpec - invalid number suffix throws", () => { - assertThrows( - () => parseMessageSpec("1abc", 5), - ValidationError, - 'Invalid message number: "1abc"', - ) -}) - -Deno.test("parseMessageSpec - decimal number throws", () => { - assertThrows( - () => parseMessageSpec("1.5", 5), - ValidationError, - 'Invalid message number: "1.5"', - ) -}) - -Deno.test("parseMessageSpec - invalid range throws", () => { - assertThrows( - () => parseMessageSpec("a-b", 5), - ValidationError, - "Invalid range", - ) -}) - -Deno.test("parseMessageSpec - invalid range suffix throws", () => { - assertThrows( - () => parseMessageSpec("1-2-3", 5), - ValidationError, - 'Invalid range: "1-2-3"', - ) -}) - -Deno.test("parseDataUrl - valid png data URL", () => { - assertEquals( - parseDataUrl("data:image/png;base64,iVBORw0KGgo="), - { mediaType: "image/png", data: "iVBORw0KGgo=" }, - ) -}) - -Deno.test("parseDataUrl - base64 payload with newlines", () => { - // /s flag must be set on the regex so . matches newlines - assertEquals( - parseDataUrl("data:image/jpeg;base64,AAAA\nBBBB\nCCCC"), - { mediaType: "image/jpeg", data: "AAAA\nBBBB\nCCCC" }, - ) -}) - -Deno.test("parseDataUrl - non-data URL returns null", () => { - assertEquals(parseDataUrl("https://example.com/foo.png"), null) -}) - -Deno.test("parseDataUrl - missing base64 marker returns null", () => { - assertEquals(parseDataUrl("data:image/png,iVBORw0KGgo="), null) -}) - -Deno.test("parseDataUrl - empty string returns null", () => { - assertEquals(parseDataUrl(""), null) -}) - -Deno.test("resolveImage - http URL passes through", async () => { - const url = "http://example.com/cat.png" - assertEquals(await resolveImage(url), url) -}) - -Deno.test("resolveImage - https URL passes through", async () => { - const url = "https://example.com/cat.png" - assertEquals(await resolveImage(url), url) -}) - -async function withFakeSips( - convert: (args: string[]) => Promise, - test: (input: string, calls: string[][]) => Promise, - extension = "HEIC", -) { - const dir = await Deno.makeTempDir({ dir: "/tmp" }) - const input = join(dir, `phone photo.${extension}`) - const originalCommand = Deno.Command - const calls: string[][] = [] - await Deno.writeFile(input, new Uint8Array([1, 2, 3])) - Deno.Command = class extends originalCommand { - #args: string[] - constructor(command: string | URL, options: Deno.CommandOptions = {}) { - super(command, options) - assertEquals(command, "sips") - this.#args = options.args ?? [] - calls.push(this.#args) - } - override output() { - return convert(this.#args) - } - } - try { - await test(input, calls) - } finally { - Deno.Command = originalCommand - await Deno.remove(dir, { recursive: true }) - } -} - -const commandOutput = (code = 0, stderr = ""): Deno.CommandOutput => ({ - success: code === 0, - code, - signal: null, - stdout: new Uint8Array(), - stderr: new TextEncoder().encode(stderr), -}) - -for (const extension of ["HEIC", "heif"]) { - Deno.test(`resolveImage converts ${extension} to JPEG and cleans up without changing the original`, async () => { - await withFakeSips(async (args) => { - await Deno.writeFile(args.at(-1)!, new Uint8Array([0xff, 0xd8, 0xff, 0xd9])) - return commandOutput() - }, async (input, calls) => { - assertEquals(await resolveImage(input), "data:image/jpeg;base64,/9j/2Q==") - assertEquals(calls.length, 1) - assertEquals(calls[0].slice(0, -2), [ - "--setProperty", - "format", - "jpeg", - "--setProperty", - "formatOptions", - "90", - await Deno.realPath(input), - ]) - assertEquals(calls[0].at(-2), "--out") - assertEquals([...await Deno.readFile(input)], [1, 2, 3]) - await assertRejects(() => Deno.stat(dirname(calls[0].at(-1)!)), Deno.errors.NotFound) - }, extension) - }) -} - -Deno.test("resolveImage explains missing sips and cleans up", async () => { - await withFakeSips( - () => Promise.reject(new Deno.errors.NotFound("sips")), - async (input, calls) => { - await assertRejects( - () => resolveImage(input), - ValidationError, - "HEIC conversion requires macOS's 'sips'. Convert the image to JPEG or PNG first.", - ) - assertEquals(calls.length, 1) - await assertRejects(() => Deno.stat(dirname(calls[0].at(-1)!)), Deno.errors.NotFound) - }, - ) -}) - -Deno.test("resolveImage reports conversion failure and cleans up", async () => { - await withFakeSips( - () => Promise.resolve(commandOutput(13, "Invalid HEIC")), - async (input, calls) => { - await assertRejects(() => resolveImage(input), ValidationError, "Invalid HEIC") - assertEquals(calls.length, 1) - await assertRejects(() => Deno.stat(dirname(calls[0].at(-1)!)), Deno.errors.NotFound) - }, - ) -}) +import { pick, range, uniqueBy } from "./utils.ts" -Deno.test("resolveImage rejects incomplete sips output even when the process succeeds", async () => { - await withFakeSips(async (args) => { - await Deno.writeFile(args.at(-1)!, new Uint8Array([0xff, 0xd8, 0xff, 0xe0])) - return commandOutput() - }, async (input, calls) => { - await assertRejects(() => resolveImage(input), ValidationError, "incomplete JPEG") - assertEquals(calls.length, 1) - await assertRejects(() => Deno.stat(dirname(calls[0].at(-1)!)), Deno.errors.NotFound) - }) +test("range excludes the end and is empty when end <= start", () => { + assert.deepEqual(range(2, 5), [2, 3, 4]) + assert.deepEqual(range(3, 3), []) + assert.deepEqual(range(4, 1), []) }) -Deno.test("resolveImage reports missing converter output and cleans up", async () => { - await withFakeSips(() => Promise.resolve(commandOutput()), async (input, calls) => { - await assertRejects( - () => resolveImage(input), - ValidationError, - "did not produce a JPEG", - ) - assertEquals(calls.length, 1) - await assertRejects(() => Deno.stat(dirname(calls[0].at(-1)!)), Deno.errors.NotFound) - }) +test("uniqueBy keeps the first item for each key", () => { + const items = [{ k: "a", n: 1 }, { k: "b", n: 2 }, { k: "a", n: 3 }] + assert.deepEqual(uniqueBy(items, (i) => i.k), [{ k: "a", n: 1 }, { k: "b", n: 2 }]) }) -Deno.test("resolveImage leaves ordinary local images unchanged without invoking sips", async () => { - await withFakeSips( - () => Promise.reject(new Error("Should not run sips")), - async (input, calls) => { - assertEquals(await resolveImage(input), "data:image/png;base64,AQID") - assertEquals(calls.length, 0) - }, - "png", - ) +test("pick copies only the given keys", () => { + assert.deepEqual(pick({ a: 1, b: 2, c: 3 }, ["a", "c"]), { a: 1, c: 3 }) }) diff --git a/validate_test.ts b/validate_test.ts index 4b64e1d..e10fc64 100644 --- a/validate_test.ts +++ b/validate_test.ts @@ -1,4 +1,5 @@ -import { assertEquals } from "@std/assert" +import assert from "node:assert/strict" +import { test } from "node:test" import { resolveModel } from "./models.ts" import { type RequestFlags, requestProblems } from "./validate.ts" @@ -13,36 +14,36 @@ const flags = (overrides: Partial = {}): RequestFlags => ({ ...overrides, }) -Deno.test("plain prompt is fine for every model", () => { +test("plain prompt is fine for every model", () => { for (const m of ["opus", "gpt-6.1-sol", "gemini-3.8-flash", "flare"]) { - assertEquals(requestProblems(resolveModel(m), flags()), []) + assert.deepEqual(requestProblems(resolveModel(m), flags()), []) } }) -Deno.test("image models list every unsupported flag in one problem", () => { +test("image models list every unsupported flag in one problem", () => { const req = flags({ config: { search: true, think: "high" }, images: true }) - assertEquals(requestProblems(resolveModel("flare"), req), [ + assert.deepEqual(requestProblems(resolveModel("flare"), req), [ "Not supported for image models: --image, --search, thinking flags", ]) }) -Deno.test("image options only apply to image models", () => { - assertEquals(requestProblems(resolveModel("flare"), flags({ quality: "low" })), []) - assertEquals(requestProblems(resolveModel("opus"), flags({ size: "auto" })), [ +test("image options only apply to image models", () => { + assert.deepEqual(requestProblems(resolveModel("flare"), flags({ quality: "low" })), []) + assert.deepEqual(requestProblems(resolveModel("opus"), flags({ size: "auto" })), [ "--quality and --size only apply to image models", ]) - assertEquals(requestProblems(resolveModel("flare"), flags({ size: "big" })), [ + assert.deepEqual(requestProblems(resolveModel("flare"), flags({ size: "big" })), [ "Invalid size 'big'. Use WIDTHxHEIGHT or auto", ]) }) -Deno.test("background reports every problem", () => { +test("background reports every problem", () => { const req = flags({ background: true, outputSchema: true }) - assertEquals(requestProblems(resolveModel("opus"), req), [ + assert.deepEqual(requestProblems(resolveModel("opus"), req), [ "Background mode only works with OpenAI models", "Structured output is not supported in background mode", ]) - assertEquals(requestProblems(resolveModel("gpt-6.1-sol"), req), [ + assert.deepEqual(requestProblems(resolveModel("gpt-6.1-sol"), req), [ "Structured output is not supported in background mode", ]) })