@artis-lab/cli 0.12.0 → 0.14.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 +40 -11
- package/package.json +4 -1
- package/src/bin.js +5 -10
- package/src/index.js +15 -9
- package/src/lib/app.d.ts +3 -0
- package/src/lib/app.js +9 -0
- package/src/lib/args.d.ts +1 -0
- package/src/lib/args.js +5 -3
- package/src/lib/chunk-43WVFZLO.js +104 -0
- package/src/lib/chunk-46DMRA3V.js +141 -0
- package/src/lib/chunk-CCCATRMP.js +591 -0
- package/src/lib/{chunk-OBEJTKCR.js → chunk-CT5TD6L2.js} +9 -5
- package/src/lib/{chunk-KY47KP5E.js → chunk-JYMG2Y6C.js} +1 -1
- package/src/lib/chunk-KJV7R7DE.js +82 -0
- package/src/lib/{chunk-YXGHBN47.js → chunk-PG7WDW5F.js} +599 -305
- package/src/lib/chunk-Q5KBGVKT.js +155 -0
- package/src/lib/{chunk-YAZGW7Y4.js → chunk-QZFIUZXT.js} +256 -83
- package/src/lib/cli.d.ts +44 -23
- package/src/lib/cli.js +15 -9
- package/src/lib/config.d.ts +31 -1
- package/src/lib/config.js +11 -3
- package/src/lib/files.js +1 -1
- package/src/lib/next-actions.d.ts +13 -0
- package/src/lib/next-actions.js +16 -0
- package/src/lib/oauth.d.ts +45 -0
- package/src/lib/oauth.js +18 -0
- package/src/lib/revision-bases.js +2 -2
- package/src/lib/skill-install.d.ts +1 -1
- package/src/lib/skill-install.js +2 -2
- package/src/lib/verify.d.ts +27 -10
- package/src/lib/verify.js +3 -3
- package/src/lib/chunk-QNS7GLAA.js +0 -63
- package/src/lib/chunk-U3ZF6SRR.js +0 -25
- /package/src/lib/{chunk-QDQQASRY.js → chunk-MEPQKMK5.js} +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasFlag,
|
|
3
|
+
parseFlagValue
|
|
4
|
+
} from "./chunk-KJV7R7DE.js";
|
|
5
|
+
import {
|
|
6
|
+
exitCodes
|
|
7
|
+
} from "./chunk-H32QAUSA.js";
|
|
8
|
+
|
|
9
|
+
// packages/cli/src/lib/next-actions.ts
|
|
10
|
+
function action(id, description, argv, args, kind = "suggestion", effect = "read") {
|
|
11
|
+
const host = parseFlagValue(args, "--host") ?? parseFlagValue(args, "--url");
|
|
12
|
+
return {
|
|
13
|
+
id,
|
|
14
|
+
description,
|
|
15
|
+
argv: host ? [...argv, "--host", host] : argv,
|
|
16
|
+
kind,
|
|
17
|
+
effect
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function publishedActions(artifactId, args) {
|
|
21
|
+
return [
|
|
22
|
+
action(
|
|
23
|
+
"read-feedback",
|
|
24
|
+
"Read review feedback",
|
|
25
|
+
["artifact", "feedback", artifactId],
|
|
26
|
+
args
|
|
27
|
+
)
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
function feedbackActions(artifactId, cursor, openThreads, args) {
|
|
31
|
+
const actions = [];
|
|
32
|
+
if (openThreads > 0) {
|
|
33
|
+
actions.push(
|
|
34
|
+
action(
|
|
35
|
+
"read-source",
|
|
36
|
+
"List the current revision files before editing",
|
|
37
|
+
["artifact", "files", artifactId],
|
|
38
|
+
args
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
} else if (cursor !== void 0 && /^\d+$/.test(String(cursor))) {
|
|
42
|
+
actions.push(
|
|
43
|
+
action(
|
|
44
|
+
"watch-feedback",
|
|
45
|
+
"Wait up to 30s for new feedback",
|
|
46
|
+
[
|
|
47
|
+
"watch",
|
|
48
|
+
artifactId,
|
|
49
|
+
"--since",
|
|
50
|
+
String(cursor),
|
|
51
|
+
"--once",
|
|
52
|
+
"--timeout",
|
|
53
|
+
"30s"
|
|
54
|
+
],
|
|
55
|
+
args
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return actions;
|
|
60
|
+
}
|
|
61
|
+
function recoveryActions(code, args, route) {
|
|
62
|
+
const help = (id, description, argv) => action(id, description, [...argv, "-h"], [], "recovery");
|
|
63
|
+
switch (code) {
|
|
64
|
+
case exitCodes.usage:
|
|
65
|
+
return [help("usage", "Read the relevant command help", route)];
|
|
66
|
+
case exitCodes.auth:
|
|
67
|
+
return [
|
|
68
|
+
action(
|
|
69
|
+
"check-identity",
|
|
70
|
+
"Check identity and permissions; login if credentials expired",
|
|
71
|
+
["whoami"],
|
|
72
|
+
args,
|
|
73
|
+
"recovery"
|
|
74
|
+
)
|
|
75
|
+
];
|
|
76
|
+
case exitCodes.revisionConflict:
|
|
77
|
+
if (route[0] === "revise" && args[1]) {
|
|
78
|
+
return [
|
|
79
|
+
action(
|
|
80
|
+
"read-latest",
|
|
81
|
+
"Inspect latest files, download to a new path and reconcile before revising",
|
|
82
|
+
["artifact", "files", args[1]],
|
|
83
|
+
args,
|
|
84
|
+
"recovery"
|
|
85
|
+
)
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
if (route[0] === "data" && args[2] && args[3] && ["set", "update", "delete"].includes(route[1])) {
|
|
89
|
+
return [
|
|
90
|
+
action(
|
|
91
|
+
"read-latest",
|
|
92
|
+
"Re-read the document and reapply the intended change before retrying",
|
|
93
|
+
["data", "get", args[2], args[3]],
|
|
94
|
+
args,
|
|
95
|
+
"recovery"
|
|
96
|
+
)
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
return [
|
|
100
|
+
help(
|
|
101
|
+
"read-latest",
|
|
102
|
+
"Re-read and reconcile the latest state before retrying",
|
|
103
|
+
route
|
|
104
|
+
)
|
|
105
|
+
];
|
|
106
|
+
case exitCodes.notFound:
|
|
107
|
+
return [
|
|
108
|
+
help(
|
|
109
|
+
"find-resource",
|
|
110
|
+
"Check the resource ID and command arguments",
|
|
111
|
+
route
|
|
112
|
+
)
|
|
113
|
+
];
|
|
114
|
+
case exitCodes.verifyFailed:
|
|
115
|
+
return [
|
|
116
|
+
help("verify", "Fix reported findings before publishing or revising", [
|
|
117
|
+
"verify"
|
|
118
|
+
])
|
|
119
|
+
];
|
|
120
|
+
default:
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function displayArg(arg) {
|
|
125
|
+
return /^[a-zA-Z0-9_./:@%+=,-]+$/.test(arg) ? arg : "'" + arg.replace(/'/g, "'\\''") + "'";
|
|
126
|
+
}
|
|
127
|
+
function renderNextActions(actions) {
|
|
128
|
+
for (const item of actions) {
|
|
129
|
+
console.error(
|
|
130
|
+
`Next: artis ${item.argv.map(displayArg).join(" ")} \u2014 ${item.description}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function renderResult(data, actions, args, agent) {
|
|
135
|
+
const json = hasFlag(args, "--json");
|
|
136
|
+
if (json) {
|
|
137
|
+
console.log(
|
|
138
|
+
JSON.stringify(
|
|
139
|
+
agent && hasFlag(args, "--next") ? { data, nextActions: actions } : data,
|
|
140
|
+
null,
|
|
141
|
+
2
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
publishedActions,
|
|
151
|
+
feedbackActions,
|
|
152
|
+
recoveryActions,
|
|
153
|
+
renderNextActions,
|
|
154
|
+
renderResult
|
|
155
|
+
};
|