@series-a/cli 1.2.0 → 1.3.1
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/CHANGELOG.md +175 -39
- package/LICENSE +7 -0
- package/README.md +257 -91
- package/SKILLS.md +344 -0
- package/bin/advisoros.mjs +2 -0
- package/package.json +50 -15
- package/src/api.mjs +102 -0
- package/src/commands/auth.mjs +193 -0
- package/src/commands/brand.mjs +439 -0
- package/src/commands/flow.mjs +175 -0
- package/src/commands/insights.mjs +1813 -0
- package/src/commands/knowledge-sync.mjs +519 -0
- package/src/commands/resources.mjs +2196 -0
- package/src/commands/strategies.mjs +242 -0
- package/src/commands/voice.mjs +212 -0
- package/src/config.mjs +82 -0
- package/src/index.mjs +77 -0
- package/src/ui.mjs +104 -0
- package/bin/setu.mjs +0 -607
- package/lib/api.mjs +0 -84
- package/lib/config.mjs +0 -42
- package/lib/ui.mjs +0 -68
package/src/ui.mjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import Table from "cli-table3";
|
|
3
|
+
|
|
4
|
+
export function isJsonMode(cmd) {
|
|
5
|
+
return Boolean(cmd?.optsWithGlobals?.().json ?? cmd?.opts?.().json);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function emit(cmd, data, renderHuman) {
|
|
9
|
+
if (isJsonMode(cmd)) {
|
|
10
|
+
process.stdout.write(JSON.stringify(data, null, 2) + "\n");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
renderHuman(data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function fail(err) {
|
|
17
|
+
const msg = err?.message ?? String(err);
|
|
18
|
+
process.stderr.write(chalk.red(`✖ ${msg}\n`));
|
|
19
|
+
if (err?.body) {
|
|
20
|
+
try {
|
|
21
|
+
process.stderr.write(chalk.gray(JSON.stringify(err.body, null, 2)) + "\n");
|
|
22
|
+
} catch {}
|
|
23
|
+
}
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function table(headers, rows) {
|
|
28
|
+
const t = new Table({
|
|
29
|
+
head: headers.map((h) => chalk.bold.cyan(h)),
|
|
30
|
+
style: { head: [], border: ["gray"] },
|
|
31
|
+
wordWrap: true,
|
|
32
|
+
});
|
|
33
|
+
for (const row of rows) t.push(row);
|
|
34
|
+
return t.toString();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function truncate(str, n = 40) {
|
|
38
|
+
if (str == null) return "";
|
|
39
|
+
const s = String(str);
|
|
40
|
+
return s.length > n ? s.slice(0, n - 1) + "…" : s;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function withCommonOpts(cmd) {
|
|
44
|
+
return cmd
|
|
45
|
+
.option("--json", "output raw JSON")
|
|
46
|
+
.option("-w, --workspace <id>", "override workspace_id")
|
|
47
|
+
.option("-p, --profile <name>", "use a named profile")
|
|
48
|
+
.option("--api-key <key>", "override API key")
|
|
49
|
+
.option("--as-agent <name>", "caller identity sent as agent_name (audit label)");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function ctxFrom(cmd) {
|
|
53
|
+
const opts = cmd.optsWithGlobals();
|
|
54
|
+
return {
|
|
55
|
+
apiKey: opts.apiKey,
|
|
56
|
+
workspaceId: opts.workspace,
|
|
57
|
+
profile: opts.profile,
|
|
58
|
+
agentName: opts.asAgent,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gate a destructive command. Returns true when it may proceed.
|
|
64
|
+
* Non-interactive shells must pass --yes; --json implies scripted use, so it
|
|
65
|
+
* also requires --yes rather than hanging on a prompt.
|
|
66
|
+
*/
|
|
67
|
+
export async function confirmDestructive(cmd, summary, { expect } = {}) {
|
|
68
|
+
const opts = cmd.optsWithGlobals();
|
|
69
|
+
if (opts.yes) return true;
|
|
70
|
+
if (isJsonMode(cmd) || !process.stdin.isTTY) {
|
|
71
|
+
process.stderr.write(
|
|
72
|
+
chalk.red(`✖ Refusing to run without confirmation.\n`) +
|
|
73
|
+
chalk.gray(` ${summary}\n Re-run with --yes to confirm (or --dry-run to preview).\n`),
|
|
74
|
+
);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
const { default: prompts } = await import("prompts");
|
|
78
|
+
process.stdout.write(chalk.yellow(`\n${summary}\n`));
|
|
79
|
+
if (expect) {
|
|
80
|
+
const r = await prompts({
|
|
81
|
+
type: "text",
|
|
82
|
+
name: "v",
|
|
83
|
+
message: `Type "${expect}" to confirm`,
|
|
84
|
+
});
|
|
85
|
+
if (r.v !== expect) {
|
|
86
|
+
process.stdout.write("Aborted.\n");
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
const r = await prompts({ type: "confirm", name: "v", message: "Proceed?", initial: false });
|
|
92
|
+
if (!r.v) {
|
|
93
|
+
process.stdout.write("Aborted.\n");
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Common flags for destructive commands. */
|
|
100
|
+
export function withDestructiveOpts(cmd) {
|
|
101
|
+
return cmd
|
|
102
|
+
.option("-y, --yes", "skip the confirmation prompt")
|
|
103
|
+
.option("--dry-run", "show what would happen without changing anything");
|
|
104
|
+
}
|