refactor: replace Bun APIs with Node.js equivalents
Replace Bun.argv with process.argv, Bun.file() with fs/promises, Bun.stringWidth with string-width package, and Bun.wrapAnsi with wrap-ansi package for better compatibility.
This commit is contained in:
parent
b212fee200
commit
0c71e2cd54
7 changed files with 39 additions and 18 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import type { ModelMessage } from "ai";
|
||||
|
||||
const home = os.homedir();
|
||||
const convoFile = Bun.file(`${home}/.lmc_convo.json`);
|
||||
const convoPath = `${home}/.lmc_convo.json`;
|
||||
|
||||
export interface IConversation {
|
||||
model: string;
|
||||
|
|
@ -16,7 +17,8 @@ export class Conversation implements IConversation {
|
|||
|
||||
async load() {
|
||||
try {
|
||||
const convo: IConversation = await convoFile.json();
|
||||
const text = await fs.readFile(convoPath);
|
||||
const convo: IConversation = JSON.parse(text.toString("utf8"));
|
||||
this.model = convo.model;
|
||||
this.messages = convo.messages;
|
||||
} catch {
|
||||
|
|
@ -25,7 +27,8 @@ export class Conversation implements IConversation {
|
|||
}
|
||||
|
||||
async save() {
|
||||
await convoFile.write(
|
||||
await fs.writeFile(
|
||||
convoPath,
|
||||
JSON.stringify({
|
||||
model: this.model,
|
||||
messages: this.messages,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue