@duvoai/cli 0.1.0 → 0.2.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/README.md +71 -11
- package/dist/bin/duvo.js +11726 -6
- package/dist/bin/duvo.js.map +7 -0
- package/package.json +10 -8
- package/dist/api/agent-schemas.d.ts +0 -521
- package/dist/api/agent-schemas.js +0 -36
- package/dist/api/parse-fields.d.ts +0 -25
- package/dist/api/parse-fields.js +0 -86
- package/dist/api/read-input.d.ts +0 -6
- package/dist/api/read-input.js +0 -28
- package/dist/api/run-schemas.d.ts +0 -621
- package/dist/api/run-schemas.js +0 -91
- package/dist/bin/create-program.d.ts +0 -7
- package/dist/bin/create-program.js +0 -34
- package/dist/bin/duvo.d.ts +0 -2
- package/dist/client/client.d.ts +0 -23
- package/dist/client/client.js +0 -96
- package/dist/commands/agents/create.d.ts +0 -2
- package/dist/commands/agents/create.js +0 -182
- package/dist/commands/agents/get.d.ts +0 -2
- package/dist/commands/agents/get.js +0 -36
- package/dist/commands/agents/index.d.ts +0 -2
- package/dist/commands/agents/index.js +0 -11
- package/dist/commands/agents/list.d.ts +0 -2
- package/dist/commands/agents/list.js +0 -61
- package/dist/commands/api-render.d.ts +0 -8
- package/dist/commands/api-render.js +0 -72
- package/dist/commands/api.d.ts +0 -2
- package/dist/commands/api.js +0 -90
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +0 -80
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/logout.js +0 -38
- package/dist/commands/profiles/index.d.ts +0 -2
- package/dist/commands/profiles/index.js +0 -13
- package/dist/commands/profiles/list.d.ts +0 -2
- package/dist/commands/profiles/list.js +0 -22
- package/dist/commands/profiles/remove.d.ts +0 -2
- package/dist/commands/profiles/remove.js +0 -30
- package/dist/commands/profiles/rename.d.ts +0 -2
- package/dist/commands/profiles/rename.js +0 -20
- package/dist/commands/profiles/render-list.d.ts +0 -12
- package/dist/commands/profiles/render-list.js +0 -37
- package/dist/commands/profiles/use.d.ts +0 -2
- package/dist/commands/profiles/use.js +0 -17
- package/dist/commands/runs/get.d.ts +0 -2
- package/dist/commands/runs/get.js +0 -59
- package/dist/commands/runs/index.d.ts +0 -2
- package/dist/commands/runs/index.js +0 -17
- package/dist/commands/runs/messages.d.ts +0 -2
- package/dist/commands/runs/messages.js +0 -80
- package/dist/commands/runs/respond.d.ts +0 -2
- package/dist/commands/runs/respond.js +0 -105
- package/dist/commands/runs/send-message.d.ts +0 -2
- package/dist/commands/runs/send-message.js +0 -41
- package/dist/commands/runs/start.d.ts +0 -2
- package/dist/commands/runs/start.js +0 -54
- package/dist/commands/runs/stop.d.ts +0 -2
- package/dist/commands/runs/stop.js +0 -41
- package/dist/commands/shared/confirm.d.ts +0 -19
- package/dist/commands/shared/confirm.js +0 -28
- package/dist/commands/shared/pagination.d.ts +0 -8
- package/dist/commands/shared/pagination.js +0 -24
- package/dist/commands/shared/profile-flag.d.ts +0 -8
- package/dist/commands/shared/profile-flag.js +0 -17
- package/dist/commands/shared/require-auth.d.ts +0 -12
- package/dist/commands/shared/require-auth.js +0 -18
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/commands/whoami.js +0 -14
- package/dist/config/defaults.d.ts +0 -3
- package/dist/config/defaults.js +0 -4
- package/dist/config/env.d.ts +0 -17
- package/dist/config/env.js +0 -13
- package/dist/config/paths.d.ts +0 -2
- package/dist/config/paths.js +0 -14
- package/dist/config/profiles.d.ts +0 -24
- package/dist/config/profiles.js +0 -78
- package/dist/config/resolve.d.ts +0 -29
- package/dist/config/resolve.js +0 -46
- package/dist/config/store.d.ts +0 -4
- package/dist/config/store.js +0 -94
- package/dist/config/types.d.ts +0 -8
- package/dist/config/types.js +0 -1
- package/dist/errors.d.ts +0 -22
- package/dist/errors.js +0 -42
- package/dist/output/format.d.ts +0 -11
- package/dist/output/format.js +0 -26
- package/dist/output/green.d.ts +0 -5
- package/dist/output/green.js +0 -18
- package/dist/output/json.d.ts +0 -6
- package/dist/output/json.js +0 -8
- package/dist/output/table.d.ts +0 -16
- package/dist/output/table.js +0 -35
- package/dist/output/text.d.ts +0 -9
- package/dist/output/text.js +0 -13
package/dist/api/parse-fields.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
const INTEGER_OR_DECIMAL = /^-?\d+(\.\d+)?$/;
|
|
3
|
-
/**
|
|
4
|
-
* Parses a `-f key=value` pair. The value is always kept as a string,
|
|
5
|
-
* matching the `gh api` convention.
|
|
6
|
-
*/
|
|
7
|
-
export function parseStringField(input) {
|
|
8
|
-
const eq = input.indexOf("=");
|
|
9
|
-
if (eq === -1) {
|
|
10
|
-
throw new Error(`Invalid field "${input}". Expected "key=value" (e.g. -f name="Bot").`);
|
|
11
|
-
}
|
|
12
|
-
const key = input.slice(0, eq);
|
|
13
|
-
if (key.length === 0) {
|
|
14
|
-
throw new Error(`Invalid field "${input}". Key cannot be empty (e.g. -f name="Bot").`);
|
|
15
|
-
}
|
|
16
|
-
return { key, value: input.slice(eq + 1) };
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Parses a `-F key=value` pair. The value is coerced to a typed value
|
|
20
|
-
* when it matches one of: `null`, `true`, `false`, a number, or
|
|
21
|
-
* `@path/to/file.json` (inlines the file's parsed JSON). Anything else
|
|
22
|
-
* falls through as a string.
|
|
23
|
-
*/
|
|
24
|
-
export function parseTypedField(input) {
|
|
25
|
-
const eq = input.indexOf("=");
|
|
26
|
-
if (eq === -1) {
|
|
27
|
-
throw new Error(`Invalid field "${input}". Expected "key=value" (e.g. -F count=42).`);
|
|
28
|
-
}
|
|
29
|
-
const key = input.slice(0, eq);
|
|
30
|
-
if (key.length === 0) {
|
|
31
|
-
throw new Error(`Invalid field "${input}". Key cannot be empty (e.g. -F count=42).`);
|
|
32
|
-
}
|
|
33
|
-
const raw = input.slice(eq + 1);
|
|
34
|
-
if (raw.startsWith("@")) {
|
|
35
|
-
const path = raw.slice(1);
|
|
36
|
-
return { key, value: readJsonFile(path) };
|
|
37
|
-
}
|
|
38
|
-
if (raw === "null") {
|
|
39
|
-
return { key, value: null };
|
|
40
|
-
}
|
|
41
|
-
if (raw === "true") {
|
|
42
|
-
return { key, value: true };
|
|
43
|
-
}
|
|
44
|
-
if (raw === "false") {
|
|
45
|
-
return { key, value: false };
|
|
46
|
-
}
|
|
47
|
-
if (INTEGER_OR_DECIMAL.test(raw)) {
|
|
48
|
-
return { key, value: Number(raw) };
|
|
49
|
-
}
|
|
50
|
-
return { key, value: raw };
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Combines repeated `-f` and `-F` flag values into a single object.
|
|
54
|
-
* String fields (`-f`) are applied first, then typed fields (`-F`), so
|
|
55
|
-
* typed fields win on key collision regardless of CLI argument order.
|
|
56
|
-
* Commander collects the two flags into separate arrays, so the original
|
|
57
|
-
* interleaved order is lost by the time we get here.
|
|
58
|
-
*/
|
|
59
|
-
export function buildFieldObject(stringFields = [], typedFields = []) {
|
|
60
|
-
const result = {};
|
|
61
|
-
for (const input of stringFields) {
|
|
62
|
-
const { key, value } = parseStringField(input);
|
|
63
|
-
result[key] = value;
|
|
64
|
-
}
|
|
65
|
-
for (const input of typedFields) {
|
|
66
|
-
const { key, value } = parseTypedField(input);
|
|
67
|
-
result[key] = value;
|
|
68
|
-
}
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
function readJsonFile(path) {
|
|
72
|
-
let contents;
|
|
73
|
-
try {
|
|
74
|
-
contents = readFileSync(path, "utf8");
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
78
|
-
throw new Error(`Cannot read "${path}": ${message}`);
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
return JSON.parse(contents);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
throw new Error(`File "${path}" is not valid JSON.`);
|
|
85
|
-
}
|
|
86
|
-
}
|
package/dist/api/read-input.d.ts
DELETED
package/dist/api/read-input.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
/**
|
|
3
|
-
* Reads a raw JSON body from a file path or from stdin (when path is
|
|
4
|
-
* `"-"`). Returns the parsed JSON value. Throws if the input is not
|
|
5
|
-
* valid JSON or the file cannot be read.
|
|
6
|
-
*/
|
|
7
|
-
export function readInputJson(path) {
|
|
8
|
-
const contents = path === "-" ? readStdin() : readFile(path);
|
|
9
|
-
try {
|
|
10
|
-
return JSON.parse(contents);
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
const source = path === "-" ? "stdin" : `"${path}"`;
|
|
14
|
-
throw new Error(`Input from ${source} is not valid JSON.`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function readFile(path) {
|
|
18
|
-
try {
|
|
19
|
-
return readFileSync(path, "utf8");
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
23
|
-
throw new Error(`Cannot read "${path}": ${message}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function readStdin() {
|
|
27
|
-
return readFileSync(0, "utf8");
|
|
28
|
-
}
|