Skip to content

Commit

Permalink
fix(capslockx): dep
Browse files Browse the repository at this point in the history
dep
  • Loading branch information
snomiao committed Nov 23, 2023
1 parent 484dc9f commit 13db936
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
12 changes: 7 additions & 5 deletions DevTools/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -98,6 +98,8 @@ const indicatorMapping = {
"--chat": (e = "") => e,
"--code": codeCompletorPrompt,
};
main();

async function main() {
await scanClipboardFile();
// for await (const event of watch(clipFile)) {
Expand Down Expand Up @@ -130,8 +132,6 @@ async function main() {
// console.log('clipboard appended')
}

main();

async function scanClipboardFile() {
console.clear();

Expand All @@ -149,15 +149,17 @@ 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);
}

console.clear();
await (
await completion2(question)
await completion(question)
).pipeTo(new WritableStream({ write: (token) => appendToken(token) }));

console.log("✅ clipboard written");
process.stdout.write("\n");

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions Modules/CLX-Reload.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ CapsLockX_FolderChanged(Folder, Changes)
}
MsgBox, 4, CapsLockX 重载模块, 检测到配置更改,是否重载?
IfMsgBox Yes
reload
Reload
; CapsLockX_Reload()

}
}

Expand Down
15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}

0 comments on commit 13db936

Please sign in to comment.