@gemdoq/codi 0.2.0 → 0.2.2
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.js +43 -23
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -883,6 +883,36 @@ function completer(line) {
|
|
|
883
883
|
import { readFileSync as readFileSync4 } from "fs";
|
|
884
884
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
885
885
|
import * as path5 from "path";
|
|
886
|
+
|
|
887
|
+
// src/ui/stdin-prompt.ts
|
|
888
|
+
init_esm_shims();
|
|
889
|
+
var _handler = null;
|
|
890
|
+
function registerPromptHandler(handler) {
|
|
891
|
+
_handler = handler;
|
|
892
|
+
}
|
|
893
|
+
function unregisterPromptHandler() {
|
|
894
|
+
_handler = null;
|
|
895
|
+
}
|
|
896
|
+
async function sharedPrompt(prompt) {
|
|
897
|
+
if (_handler) {
|
|
898
|
+
return _handler(prompt);
|
|
899
|
+
}
|
|
900
|
+
const readline3 = await import("readline/promises");
|
|
901
|
+
const rl = readline3.createInterface({
|
|
902
|
+
input: process.stdin,
|
|
903
|
+
output: process.stdout
|
|
904
|
+
});
|
|
905
|
+
try {
|
|
906
|
+
const answer = await rl.question(prompt);
|
|
907
|
+
return answer;
|
|
908
|
+
} finally {
|
|
909
|
+
rl.removeAllListeners();
|
|
910
|
+
rl.terminal = false;
|
|
911
|
+
rl.close();
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// src/repl.ts
|
|
886
916
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
887
917
|
var __dirname2 = path5.dirname(__filename2);
|
|
888
918
|
var HISTORY_DIR = path5.join(os3.homedir(), ".codi");
|
|
@@ -987,6 +1017,15 @@ var Repl = class {
|
|
|
987
1017
|
}
|
|
988
1018
|
});
|
|
989
1019
|
}
|
|
1020
|
+
registerPromptHandler((prompt) => {
|
|
1021
|
+
if (!this.rl) return Promise.reject(new Error("REPL not running"));
|
|
1022
|
+
process.stdout.write(prompt);
|
|
1023
|
+
return new Promise((resolve11) => {
|
|
1024
|
+
this.rl.once("line", (answer) => {
|
|
1025
|
+
resolve11(answer);
|
|
1026
|
+
});
|
|
1027
|
+
});
|
|
1028
|
+
});
|
|
990
1029
|
this.printWelcome();
|
|
991
1030
|
while (this.running) {
|
|
992
1031
|
try {
|
|
@@ -1164,6 +1203,7 @@ ${content}
|
|
|
1164
1203
|
}
|
|
1165
1204
|
stop() {
|
|
1166
1205
|
this.running = false;
|
|
1206
|
+
unregisterPromptHandler();
|
|
1167
1207
|
if (this.rl) {
|
|
1168
1208
|
this.rl.close();
|
|
1169
1209
|
this.rl = null;
|
|
@@ -1575,7 +1615,6 @@ function validateCommand(command) {
|
|
|
1575
1615
|
|
|
1576
1616
|
// src/security/permission-manager.ts
|
|
1577
1617
|
init_esm_shims();
|
|
1578
|
-
import * as readline3 from "readline/promises";
|
|
1579
1618
|
import chalk6 from "chalk";
|
|
1580
1619
|
|
|
1581
1620
|
// src/config/permissions.ts
|
|
@@ -1657,15 +1696,10 @@ async function promptUser(tool, input3) {
|
|
|
1657
1696
|
console.log(chalk6.dim(` ${key}: `) + displayValue);
|
|
1658
1697
|
}
|
|
1659
1698
|
console.log("");
|
|
1660
|
-
const rl = readline3.createInterface({
|
|
1661
|
-
input: process.stdin,
|
|
1662
|
-
output: process.stdout
|
|
1663
|
-
});
|
|
1664
1699
|
try {
|
|
1665
|
-
const answer = await
|
|
1700
|
+
const answer = await sharedPrompt(
|
|
1666
1701
|
chalk6.yellow(`Allow? [${chalk6.bold("Y")}es / ${chalk6.bold("n")}o / ${chalk6.bold("a")}lways for this tool] `)
|
|
1667
1702
|
);
|
|
1668
|
-
rl.close();
|
|
1669
1703
|
const choice = answer.trim().toLowerCase();
|
|
1670
1704
|
if (choice === "a" || choice === "always") {
|
|
1671
1705
|
sessionAllowed.add(tool.name);
|
|
@@ -1676,7 +1710,6 @@ async function promptUser(tool, input3) {
|
|
|
1676
1710
|
}
|
|
1677
1711
|
return true;
|
|
1678
1712
|
} catch {
|
|
1679
|
-
rl.close();
|
|
1680
1713
|
return false;
|
|
1681
1714
|
}
|
|
1682
1715
|
}
|
|
@@ -5405,7 +5438,6 @@ init_task_tools();
|
|
|
5405
5438
|
// src/tools/ask-user.ts
|
|
5406
5439
|
init_esm_shims();
|
|
5407
5440
|
init_tool();
|
|
5408
|
-
import * as readline4 from "readline/promises";
|
|
5409
5441
|
import chalk13 from "chalk";
|
|
5410
5442
|
var askUserTool = {
|
|
5411
5443
|
name: "ask_user",
|
|
@@ -5446,14 +5478,9 @@ var askUserTool = {
|
|
|
5446
5478
|
}
|
|
5447
5479
|
console.log(chalk13.dim(` ${options.length + 1}. Other (type custom response)`));
|
|
5448
5480
|
console.log("");
|
|
5449
|
-
const rl2 = readline4.createInterface({
|
|
5450
|
-
input: process.stdin,
|
|
5451
|
-
output: process.stdout
|
|
5452
|
-
});
|
|
5453
5481
|
try {
|
|
5454
5482
|
const prompt = multiSelect ? chalk13.dim("Enter numbers separated by commas: ") : chalk13.dim("Enter number or type response: ");
|
|
5455
|
-
const answer = await
|
|
5456
|
-
rl2.close();
|
|
5483
|
+
const answer = await sharedPrompt(prompt);
|
|
5457
5484
|
if (multiSelect) {
|
|
5458
5485
|
const indices = answer.split(",").map((s) => parseInt(s.trim()) - 1);
|
|
5459
5486
|
const selected = indices.filter((i) => i >= 0 && i < options.length).map((i) => options[i].label);
|
|
@@ -5468,20 +5495,13 @@ var askUserTool = {
|
|
|
5468
5495
|
}
|
|
5469
5496
|
return makeToolResult(`User response: ${answer}`);
|
|
5470
5497
|
} catch {
|
|
5471
|
-
rl2.close();
|
|
5472
5498
|
return makeToolError("Failed to get user input");
|
|
5473
5499
|
}
|
|
5474
5500
|
}
|
|
5475
|
-
const rl = readline4.createInterface({
|
|
5476
|
-
input: process.stdin,
|
|
5477
|
-
output: process.stdout
|
|
5478
|
-
});
|
|
5479
5501
|
try {
|
|
5480
|
-
const answer = await
|
|
5481
|
-
rl.close();
|
|
5502
|
+
const answer = await sharedPrompt(chalk13.dim("> "));
|
|
5482
5503
|
return makeToolResult(`User response: ${answer}`);
|
|
5483
5504
|
} catch {
|
|
5484
|
-
rl.close();
|
|
5485
5505
|
return makeToolError("Failed to get user input");
|
|
5486
5506
|
}
|
|
5487
5507
|
}
|