sharkcode 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +36 -34
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import chalk3 from "chalk";
|
|
5
|
-
import * as readline2 from "readline";
|
|
6
5
|
import { select, input } from "@inquirer/prompts";
|
|
7
6
|
|
|
8
7
|
// src/config.ts
|
|
@@ -200,23 +199,22 @@ import { z as z4 } from "zod";
|
|
|
200
199
|
import { exec } from "child_process";
|
|
201
200
|
|
|
202
201
|
// src/permission.ts
|
|
203
|
-
import * as readline from "readline";
|
|
204
202
|
import chalk from "chalk";
|
|
205
203
|
async function askPermission(command) {
|
|
206
204
|
process.stderr.write(
|
|
207
205
|
chalk.yellow(`
|
|
208
206
|
\u26A0\uFE0F Will execute: `) + chalk.white(command) + "\n"
|
|
209
207
|
);
|
|
210
|
-
|
|
211
|
-
input: process.stdin,
|
|
212
|
-
output: process.stderr
|
|
213
|
-
});
|
|
208
|
+
process.stderr.write(chalk.yellow(" Allow? [y/N] "));
|
|
214
209
|
return new Promise((resolve4) => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
210
|
+
const onData = (chunk) => {
|
|
211
|
+
const ch = chunk.toString("utf8")[0] ?? "";
|
|
212
|
+
process.stdin.removeListener("data", onData);
|
|
213
|
+
const yes = ch.toLowerCase() === "y";
|
|
214
|
+
process.stderr.write(yes ? "y\n" : "N\n");
|
|
215
|
+
resolve4(yes);
|
|
216
|
+
};
|
|
217
|
+
process.stdin.once("data", onData);
|
|
220
218
|
});
|
|
221
219
|
}
|
|
222
220
|
|
|
@@ -522,11 +520,6 @@ async function readLineRaw(promptStr) {
|
|
|
522
520
|
if (finished) return;
|
|
523
521
|
finished = true;
|
|
524
522
|
process.stdin.removeListener("data", onData);
|
|
525
|
-
try {
|
|
526
|
-
process.stdin.setRawMode(false);
|
|
527
|
-
} catch {
|
|
528
|
-
}
|
|
529
|
-
process.stdin.pause();
|
|
530
523
|
resolve4(value);
|
|
531
524
|
};
|
|
532
525
|
const onData = (chunk) => {
|
|
@@ -563,23 +556,7 @@ async function readLineRaw(promptStr) {
|
|
|
563
556
|
process.stdout.write(ch);
|
|
564
557
|
}
|
|
565
558
|
};
|
|
566
|
-
|
|
567
|
-
process.stdin.setRawMode(true);
|
|
568
|
-
process.stdin.resume();
|
|
569
|
-
process.stdin.on("data", onData);
|
|
570
|
-
} catch {
|
|
571
|
-
finished = true;
|
|
572
|
-
const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
|
|
573
|
-
let answered = false;
|
|
574
|
-
rl.question(promptStr, (answer) => {
|
|
575
|
-
answered = true;
|
|
576
|
-
rl.close();
|
|
577
|
-
resolve4(answer);
|
|
578
|
-
});
|
|
579
|
-
rl.on("close", () => {
|
|
580
|
-
if (!answered) resolve4(null);
|
|
581
|
-
});
|
|
582
|
-
}
|
|
559
|
+
process.stdin.on("data", onData);
|
|
583
560
|
});
|
|
584
561
|
}
|
|
585
562
|
function statusLine(config) {
|
|
@@ -597,7 +574,7 @@ async function main() {
|
|
|
597
574
|
return;
|
|
598
575
|
}
|
|
599
576
|
if (args[0] === "--version" || args[0] === "-v") {
|
|
600
|
-
console.log("sharkcode v0.3.
|
|
577
|
+
console.log("sharkcode v0.3.3");
|
|
601
578
|
return;
|
|
602
579
|
}
|
|
603
580
|
if (args.length > 0) {
|
|
@@ -617,6 +594,11 @@ async function main() {
|
|
|
617
594
|
console.log(BANNER);
|
|
618
595
|
let multiConfig = readMultiConfig();
|
|
619
596
|
let config = resolveConfig(multiConfig);
|
|
597
|
+
try {
|
|
598
|
+
process.stdin.setRawMode(true);
|
|
599
|
+
process.stdin.resume();
|
|
600
|
+
} catch {
|
|
601
|
+
}
|
|
620
602
|
console.log(statusLine(config));
|
|
621
603
|
if (!config.apiKey) {
|
|
622
604
|
console.log(
|
|
@@ -642,6 +624,11 @@ async function main() {
|
|
|
642
624
|
config = r.config;
|
|
643
625
|
if (r.clearHistory) messages = [];
|
|
644
626
|
if (r.exit) break;
|
|
627
|
+
try {
|
|
628
|
+
process.stdin.setRawMode(true);
|
|
629
|
+
process.stdin.resume();
|
|
630
|
+
} catch {
|
|
631
|
+
}
|
|
645
632
|
console.log(statusLine(config));
|
|
646
633
|
continue;
|
|
647
634
|
}
|
|
@@ -650,6 +637,11 @@ async function main() {
|
|
|
650
637
|
multiConfig = r.multiConfig;
|
|
651
638
|
config = r.config;
|
|
652
639
|
if (r.exit) break;
|
|
640
|
+
try {
|
|
641
|
+
process.stdin.setRawMode(true);
|
|
642
|
+
process.stdin.resume();
|
|
643
|
+
} catch {
|
|
644
|
+
}
|
|
653
645
|
console.log(statusLine(config));
|
|
654
646
|
continue;
|
|
655
647
|
}
|
|
@@ -664,11 +656,21 @@ async function main() {
|
|
|
664
656
|
messages.push({ role: "user", content: trimmed });
|
|
665
657
|
try {
|
|
666
658
|
messages = await runAgent(messages, config);
|
|
659
|
+
try {
|
|
660
|
+
process.stdin.setRawMode(true);
|
|
661
|
+
process.stdin.resume();
|
|
662
|
+
} catch {
|
|
663
|
+
}
|
|
667
664
|
} catch (err) {
|
|
668
665
|
console.error(RED(`
|
|
669
666
|
\u274C ${String(err)}
|
|
670
667
|
`));
|
|
671
668
|
messages.pop();
|
|
669
|
+
try {
|
|
670
|
+
process.stdin.setRawMode(true);
|
|
671
|
+
process.stdin.resume();
|
|
672
|
+
} catch {
|
|
673
|
+
}
|
|
672
674
|
}
|
|
673
675
|
}
|
|
674
676
|
}
|