From 13db93656680a9a135c420eed2dd03b34244b006 Mon Sep 17 00:00:00 2001 From: snomiao Date: Thu, 23 Nov 2023 09:25:17 +0900 Subject: [PATCH] fix(capslockx): dep dep --- DevTools/Chat.ts | 12 +++++++----- Modules/CLX-Reload.ahk | 3 +-- package.json | 15 +++++---------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/DevTools/Chat.ts b/DevTools/Chat.ts index fd01558..1419084 100644 --- a/DevTools/Chat.ts +++ b/DevTools/Chat.ts @@ -3,7 +3,7 @@ import "dotenv/config"; import { readFile } from "fs/promises"; import OpenAI from "openai"; import { createInterface } from "readline/promises"; -// import { WritableStream } from "stream/web"; +import { ReadableStream, WritableStream } from "stream/web"; const apiKey = process.env.OPENAI_API_KEY; const base = process.env.OPENAI_BASE ?? undefined; @@ -98,6 +98,8 @@ const indicatorMapping = { "--chat": (e = "") => e, "--code": codeCompletorPrompt, }; +main(); + async function main() { await scanClipboardFile(); // for await (const event of watch(clipFile)) { @@ -130,8 +132,6 @@ async function main() { // console.log('clipboard appended') } -main(); - async function scanClipboardFile() { console.clear(); @@ -149,6 +149,7 @@ async function scanClipboardFile() { // todo: implement appendToClipboard(token) here let cp = ""; async function appendToken(token: string) { + if(!token ) return; cp += token; process.stdout.write(token); // await clipboard.write(cp).catch(() => null); @@ -156,8 +157,9 @@ async function scanClipboardFile() { console.clear(); await ( - await completion2(question) + await completion(question) ).pipeTo(new WritableStream({ write: (token) => appendToken(token) })); + console.log("✅ clipboard written"); process.stdout.write("\n"); @@ -186,7 +188,7 @@ async function scanClipboardFile() { // await completion(prompt, question); // } // -async function completion2(content = "") { +async function completion(content = "") { ac?.abort?.(); ac = new AbortController(); const signal = ac.signal; diff --git a/Modules/CLX-Reload.ahk b/Modules/CLX-Reload.ahk index 91f9e2e..ecbf922 100644 --- a/Modules/CLX-Reload.ahk +++ b/Modules/CLX-Reload.ahk @@ -69,9 +69,8 @@ CapsLockX_FolderChanged(Folder, Changes) } MsgBox, 4, CapsLockX 重载模块, 检测到配置更改,是否重载? IfMsgBox Yes - reload + Reload ; CapsLockX_Reload() - } } diff --git a/package.json b/package.json index 2d3c335..4b3382d 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,6 @@ "*.txt", "*.md" ], - "workspaces": [ - "DevTools/CLXConfig.js" - ], "scripts": { "build": "CapsLockX.exe CapsLockX.ahk /CI_TEST", "build-tauri": "cd DevTools/CLXConfig.js && npm run build", @@ -75,17 +72,15 @@ "sno-utils": "^0.3.16", "standard-version": "^9.5.0", "tsx": "^3.12.7", - "typescript": "^4.9.5" + "typescript": "^4.9.5", + "@types/inquirer": "^9.0.3", + "@types/node": "^20.5.6", + "enquirer": "^2.4.1", + "glob": "^10.3.3" }, "standard-version": { "scripts": { "precommit": "node DevTools/versioning.node.mjs && git add ." } - }, - "dependencies": { - "@types/inquirer": "^9.0.3", - "@types/node": "^20.5.6", - "enquirer": "^2.4.1", - "glob": "^10.3.3" } }