refactor: migrate from bun to node types and fix discrepancies

This commit is contained in:
mitchell 2026-06-08 20:17:22 -04:00
parent a03e6e94a9
commit 21dac683a2
7 changed files with 18 additions and 31 deletions

View file

@ -8,7 +8,7 @@
"ttsc": "dist/tts.js" "ttsc": "dist/tts.js"
}, },
"scripts": { "scripts": {
"dev": "pnpm run bundle &>/dev/null && node dist/index.js", "dev": "pnpm run bundle index.ts &>/dev/null && node dist/index.js",
"check": "biome check --write && pnpm run tc", "check": "biome check --write && pnpm run tc",
"clean": "rm -rf dist", "clean": "rm -rf dist",
"build": "pnpm run check && pnpm run bundle --minify index.ts && pnpm run bundle --minify tts.ts", "build": "pnpm run check && pnpm run bundle --minify index.ts && pnpm run bundle --minify tts.ts",
@ -24,7 +24,7 @@
"@clack/prompts": "^1.3.0", "@clack/prompts": "^1.3.0",
"@cliffy/table": "npm:@jsr/cliffy__table", "@cliffy/table": "npm:@jsr/cliffy__table",
"@mozilla/readability": "^0.6.0", "@mozilla/readability": "^0.6.0",
"@types/bun": "^1.3.14", "@types/node": "^25.9.2",
"ai": "^6.0.161", "ai": "^6.0.161",
"ansi-styles": "^6.2.3", "ansi-styles": "^6.2.3",
"chalk": "^5.6.2", "chalk": "^5.6.2",

27
pnpm-lock.yaml generated
View file

@ -23,9 +23,9 @@ importers:
'@mozilla/readability': '@mozilla/readability':
specifier: ^0.6.0 specifier: ^0.6.0
version: 0.6.0 version: 0.6.0
'@types/bun': '@types/node':
specifier: ^1.3.14 specifier: ^25.9.2
version: 1.3.14 version: 25.9.2
ai: ai:
specifier: ^6.0.161 specifier: ^6.0.161
version: 6.0.191(zod@4.4.3) version: 6.0.191(zod@4.4.3)
@ -326,9 +326,6 @@ packages:
'@tybys/wasm-util@0.10.2': '@tybys/wasm-util@0.10.2':
resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==} resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==}
'@types/bun@1.3.14':
resolution: {integrity: sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw==}
'@types/hast@3.0.4': '@types/hast@3.0.4':
resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==}
@ -338,6 +335,9 @@ packages:
'@types/node@25.9.1': '@types/node@25.9.1':
resolution: {integrity: sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg==} resolution: {integrity: sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg==}
'@types/node@25.9.2':
resolution: {integrity: sha512-G05zqtJhcDLb8uslf5EjCxXg9G1KQxiV8OS0R26IC//Eoyitzqe8z37I7cqvnZlrlSfgocQRfSn/AHBZJJFyGw==}
'@types/unist@3.0.3': '@types/unist@3.0.3':
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
@ -376,9 +376,6 @@ packages:
resolution: {integrity: sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==} resolution: {integrity: sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==}
engines: {node: '>=4.0'} engines: {node: '>=4.0'}
bun-types@1.3.14:
resolution: {integrity: sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ==}
ccount@2.0.1: ccount@2.0.1:
resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
@ -881,10 +878,6 @@ snapshots:
tslib: 2.8.1 tslib: 2.8.1
optional: true optional: true
'@types/bun@1.3.14':
dependencies:
bun-types: 1.3.14
'@types/hast@3.0.4': '@types/hast@3.0.4':
dependencies: dependencies:
'@types/unist': 3.0.3 '@types/unist': 3.0.3
@ -897,6 +890,10 @@ snapshots:
dependencies: dependencies:
undici-types: 7.24.6 undici-types: 7.24.6
'@types/node@25.9.2':
dependencies:
undici-types: 7.24.6
'@types/unist@3.0.3': {} '@types/unist@3.0.3': {}
'@types/whatwg-mimetype@3.0.2': {} '@types/whatwg-mimetype@3.0.2': {}
@ -929,10 +926,6 @@ snapshots:
dependencies: dependencies:
'@types/node': 25.9.1 '@types/node': 25.9.1
bun-types@1.3.14:
dependencies:
'@types/node': 25.9.1
ccount@2.0.1: {} ccount@2.0.1: {}
chalk@5.6.2: {} chalk@5.6.2: {}

View file

@ -67,8 +67,8 @@ export async function loadConfig(
): Promise<AppConfig | null> { ): Promise<AppConfig | null> {
let config: AppConfig; let config: AppConfig;
try { try {
const text = await fs.readFile(configPath); const text = await fs.readFile(configPath, "utf8");
config = JSON.parse(text.toString("utf8")); config = JSON.parse(text);
} catch { } catch {
if (configFlag) return null; if (configFlag) return null;
console.error(`Config not found at ${configPath}`); console.error(`Config not found at ${configPath}`);

View file

@ -17,8 +17,8 @@ export class Conversation implements IConversation {
async load() { async load() {
try { try {
const text = await fs.readFile(convoPath); const text = await fs.readFile(convoPath, "utf8");
const convo: IConversation = JSON.parse(text.toString("utf8")); const convo: IConversation = JSON.parse(text);
this.model = convo.model; this.model = convo.model;
this.messages = convo.messages; this.messages = convo.messages;
} catch { } catch {

View file

@ -1,6 +0,0 @@
import { renderMarkdown } from "./src/render/markdown";
const text = await Bun.file("README.md").text();
const [columns] = process.stdout.getWindowSize();
process.stdout.write(await renderMarkdown(text, columns));

View file

@ -10,7 +10,7 @@
"noEmit": true, "noEmit": true,
// For nodejs: // For nodejs:
"lib": ["esnext"], "lib": ["esnext"],
"types": ["bun"], "types": ["node"],
// and npm install -D @types/node // and npm install -D @types/node
// Stricter Typechecking Options // Stricter Typechecking Options

2
tts.ts
View file

@ -126,7 +126,7 @@ async function main() {
const file = `${home}/.ttsc/${info.file}.wav`; const file = `${home}/.ttsc/${info.file}.wav`;
if (wait) { if (wait) {
console.write("."); process.stdout.write(".");
} else { } else {
console.log(`\n${chalk.blue(file)}\n${text}\n`); console.log(`\n${chalk.blue(file)}\n${text}\n`);
await execa({ await execa({