diff --git a/index.ts b/index.ts index bff4871..f7068c9 100644 --- a/index.ts +++ b/index.ts @@ -1,3 +1,4 @@ +import os from "node:os"; import { createOpenAICompatible } from "@ai-sdk/openai-compatible"; import { streamText } from "ai"; @@ -17,14 +18,18 @@ const { fullStream, reasoningText, text } = streamText({ renderStream(fullStream); +const home = os.homedir(); +const reasoningPath = `${home}/.aicl_reasoning.md`; +const responsePath = `${home}/.aicl_response.md`; + const reasoning = await reasoningText; -Bun.file("reasoning.md").write(reasoning ?? ""); +await Bun.file(reasoningPath).write(reasoning ?? ""); const response = await text; -Bun.file("response.md").write(response); +await Bun.file(responsePath).write(response); const [numColumns] = process.stdout.getWindowSize(); Bun.spawnSync({ - cmd: ["glow", "-w", `${numColumns}`, "response.md"], + cmd: ["glow", "-w", `${numColumns}`, responsePath], stdio: ["inherit", "inherit", "inherit"], });