feat: write to the same files in homedir everytime
This commit is contained in:
parent
cfc494ba53
commit
1f59cbca7b
1 changed files with 8 additions and 3 deletions
11
index.ts
11
index.ts
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os from "node:os";
|
||||||
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
||||||
import { streamText } from "ai";
|
import { streamText } from "ai";
|
||||||
|
|
||||||
|
|
@ -17,14 +18,18 @@ const { fullStream, reasoningText, text } = streamText({
|
||||||
|
|
||||||
renderStream(fullStream);
|
renderStream(fullStream);
|
||||||
|
|
||||||
|
const home = os.homedir();
|
||||||
|
const reasoningPath = `${home}/.aicl_reasoning.md`;
|
||||||
|
const responsePath = `${home}/.aicl_response.md`;
|
||||||
|
|
||||||
const reasoning = await reasoningText;
|
const reasoning = await reasoningText;
|
||||||
Bun.file("reasoning.md").write(reasoning ?? "");
|
await Bun.file(reasoningPath).write(reasoning ?? "");
|
||||||
|
|
||||||
const response = await text;
|
const response = await text;
|
||||||
Bun.file("response.md").write(response);
|
await Bun.file(responsePath).write(response);
|
||||||
|
|
||||||
const [numColumns] = process.stdout.getWindowSize();
|
const [numColumns] = process.stdout.getWindowSize();
|
||||||
Bun.spawnSync({
|
Bun.spawnSync({
|
||||||
cmd: ["glow", "-w", `${numColumns}`, "response.md"],
|
cmd: ["glow", "-w", `${numColumns}`, responsePath],
|
||||||
stdio: ["inherit", "inherit", "inherit"],
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue