@aivax/cli 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +114 -2
- package/package.json +31 -5
- package/src/args.js +84 -0
- package/src/cli.js +116 -0
- package/src/commands/account.js +132 -0
- package/src/commands/analytics.js +30 -0
- package/src/commands/api.js +37 -0
- package/src/commands/auth.js +124 -0
- package/src/commands/batch.js +191 -0
- package/src/commands/chat-clients.js +157 -0
- package/src/commands/conversations.js +92 -0
- package/src/commands/crud.js +68 -0
- package/src/commands/docs.js +91 -0
- package/src/commands/gateways.js +85 -0
- package/src/commands/generate.js +195 -0
- package/src/commands/logs.js +41 -0
- package/src/commands/models.js +38 -0
- package/src/commands/ocr.js +366 -0
- package/src/commands/rag.js +451 -0
- package/src/commands/shell.js +46 -0
- package/src/commands/skills.js +48 -0
- package/src/commands/tests.js +83 -0
- package/src/commands/web.js +68 -0
- package/src/errors.js +19 -0
- package/src/http.js +161 -0
- package/src/input.js +116 -0
- package/src/pdf.js +208 -0
- package/src/profiles.js +64 -0
- package/src/prompt.js +67 -0
package/src/prompt.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { UsageError } from "./errors.js";
|
|
2
|
+
|
|
3
|
+
export function ask(question, { hidden = false } = {}) {
|
|
4
|
+
if (!process.stdin.isTTY) {
|
|
5
|
+
throw new UsageError(`"${question.trim()}" requires an interactive terminal. Provide the value through its flag.`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
process.stderr.write(question);
|
|
9
|
+
|
|
10
|
+
return new Promise(resolve => {
|
|
11
|
+
const stdin = process.stdin;
|
|
12
|
+
let value = "";
|
|
13
|
+
|
|
14
|
+
const finish = () => {
|
|
15
|
+
stdin.setRawMode(false);
|
|
16
|
+
stdin.pause();
|
|
17
|
+
stdin.off("data", onData);
|
|
18
|
+
process.stderr.write("\n");
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const onData = chunk => {
|
|
22
|
+
for (const char of chunk) {
|
|
23
|
+
if (char === "\r" || char === "\n") {
|
|
24
|
+
finish();
|
|
25
|
+
resolve(value.trim());
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (char === "\u0003") {
|
|
30
|
+
finish();
|
|
31
|
+
process.exit(130);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (char === "\u007f" || char === "\b") {
|
|
35
|
+
if (value) {
|
|
36
|
+
value = value.slice(0, -1);
|
|
37
|
+
if (!hidden) process.stderr.write("\b \b");
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
value += char;
|
|
43
|
+
if (!hidden) process.stderr.write(char);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
stdin.setRawMode(true);
|
|
48
|
+
stdin.setEncoding("utf8");
|
|
49
|
+
stdin.on("data", onData);
|
|
50
|
+
stdin.resume();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function confirm(ctx, message) {
|
|
55
|
+
if (ctx.options.yes) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!process.stdin.isTTY) {
|
|
60
|
+
throw new UsageError(`${message} Pass --yes to confirm in non-interactive sessions.`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const answer = await ask(`${message} [y/N] `);
|
|
64
|
+
if (!/^y(es)?$/i.test(answer)) {
|
|
65
|
+
throw new UsageError("Operation cancelled.");
|
|
66
|
+
}
|
|
67
|
+
}
|