@artis-lab/cli 0.14.0 → 0.16.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 +28 -21
- package/package.json +3 -7
- package/src/bin.js +13 -4
- package/src/lib/app.js +13 -4
- package/src/lib/chunk-2GXGXTAO.js +1229 -0
- package/src/lib/{chunk-CT5TD6L2.js → chunk-2LRPXCLL.js} +24 -47
- package/src/lib/chunk-4O5BCFCD.js +60 -0
- package/src/lib/chunk-6PK46UOP.js +1804 -0
- package/src/lib/{chunk-MEPQKMK5.js → chunk-FSJVBXCW.js} +4 -32
- package/src/lib/{chunk-H32QAUSA.js → chunk-HUWOFEEU.js} +7 -0
- package/src/lib/chunk-I5P3FLKO.js +929 -0
- package/src/lib/chunk-IKQ5U3DH.js +146 -0
- package/src/lib/chunk-XZYT3B5O.js +113 -0
- package/src/lib/cli.js +87 -61
- package/src/lib/commands.js +25 -0
- package/src/lib/exit-codes.js +5 -3
- package/src/lib/files.js +3 -2
- package/src/lib/next-actions.js +12 -5
- package/src/lib/skill-install.js +9 -4
- package/src/lib/verify.js +2 -3
- package/src/bin.d.ts +0 -2
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -76
- package/src/lib/app.d.ts +0 -3
- package/src/lib/args.d.ts +0 -4
- package/src/lib/args.js +0 -12
- package/src/lib/chunk-CCCATRMP.js +0 -591
- package/src/lib/chunk-KJV7R7DE.js +0 -82
- package/src/lib/chunk-PG7WDW5F.js +0 -2420
- package/src/lib/chunk-Q5KBGVKT.js +0 -155
- package/src/lib/chunk-QZFIUZXT.js +0 -10954
- package/src/lib/cli.d.ts +0 -147
- package/src/lib/config.d.ts +0 -50
- package/src/lib/exit-codes.d.ts +0 -28
- package/src/lib/files.d.ts +0 -19
- package/src/lib/next-actions.d.ts +0 -13
- package/src/lib/oauth.d.ts +0 -45
- package/src/lib/revision-bases.d.ts +0 -9
- package/src/lib/skill-install.d.ts +0 -50
- package/src/lib/verify.d.ts +0 -152
- package/src/lib/version.d.ts +0 -9
|
@@ -0,0 +1,1229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VerifyUnavailableError,
|
|
3
|
+
formatVerifyReport,
|
|
4
|
+
verifyFiles
|
|
5
|
+
} from "./chunk-I5P3FLKO.js";
|
|
6
|
+
import {
|
|
7
|
+
artifactShortId,
|
|
8
|
+
batchDocuments,
|
|
9
|
+
createAnnotation,
|
|
10
|
+
deleteArtifact,
|
|
11
|
+
deleteDocument,
|
|
12
|
+
describeType,
|
|
13
|
+
downloadAsset,
|
|
14
|
+
editAnnotation,
|
|
15
|
+
exportDocuments,
|
|
16
|
+
getArtifact,
|
|
17
|
+
getAsset,
|
|
18
|
+
getDataUsage,
|
|
19
|
+
getDocument,
|
|
20
|
+
listArtifactFiles,
|
|
21
|
+
listArtifacts,
|
|
22
|
+
listAssets,
|
|
23
|
+
listDocuments,
|
|
24
|
+
listTypes,
|
|
25
|
+
login,
|
|
26
|
+
prepareVerify,
|
|
27
|
+
publishArtifact,
|
|
28
|
+
readArtifactFile,
|
|
29
|
+
readCapabilities,
|
|
30
|
+
readFeedback,
|
|
31
|
+
readGuidelines,
|
|
32
|
+
readType,
|
|
33
|
+
readTypeReference,
|
|
34
|
+
removeAsset,
|
|
35
|
+
replyToAnnotation,
|
|
36
|
+
retractAnnotation,
|
|
37
|
+
reviseArtifact,
|
|
38
|
+
setArtifactVisibility,
|
|
39
|
+
setCapabilities,
|
|
40
|
+
setDocument,
|
|
41
|
+
shareArtifact,
|
|
42
|
+
updateDocument,
|
|
43
|
+
uploadAsset,
|
|
44
|
+
watchArtifact,
|
|
45
|
+
whoami
|
|
46
|
+
} from "./chunk-6PK46UOP.js";
|
|
47
|
+
import {
|
|
48
|
+
installSkill,
|
|
49
|
+
listSkillHarnesses,
|
|
50
|
+
printHarnessTable,
|
|
51
|
+
printInstallResults
|
|
52
|
+
} from "./chunk-2LRPXCLL.js";
|
|
53
|
+
import {
|
|
54
|
+
artisCliVersion
|
|
55
|
+
} from "./chunk-IZYFOV2K.js";
|
|
56
|
+
import {
|
|
57
|
+
ARTIS_DEFAULT_HOST
|
|
58
|
+
} from "./chunk-46DMRA3V.js";
|
|
59
|
+
import {
|
|
60
|
+
dataConflictActions,
|
|
61
|
+
emit,
|
|
62
|
+
feedbackActions,
|
|
63
|
+
printJson,
|
|
64
|
+
publishedActions,
|
|
65
|
+
reviseConflictActions,
|
|
66
|
+
signInActions
|
|
67
|
+
} from "./chunk-IKQ5U3DH.js";
|
|
68
|
+
import {
|
|
69
|
+
CliError,
|
|
70
|
+
exitCodes,
|
|
71
|
+
usageError,
|
|
72
|
+
withRecovery
|
|
73
|
+
} from "./chunk-HUWOFEEU.js";
|
|
74
|
+
|
|
75
|
+
// packages/cli/src/lib/commands.ts
|
|
76
|
+
import { writeFile } from "node:fs/promises";
|
|
77
|
+
import {
|
|
78
|
+
buildCommand,
|
|
79
|
+
buildRouteMap
|
|
80
|
+
} from "@stricli/core";
|
|
81
|
+
var unprotect = (input) => input.slice(1);
|
|
82
|
+
var value = (placeholder, brief, hidden = false) => ({
|
|
83
|
+
kind: "parsed",
|
|
84
|
+
parse: unprotect,
|
|
85
|
+
optional: true,
|
|
86
|
+
placeholder,
|
|
87
|
+
brief,
|
|
88
|
+
hidden
|
|
89
|
+
});
|
|
90
|
+
var bool = (brief, hidden = false) => ({
|
|
91
|
+
kind: "boolean",
|
|
92
|
+
optional: true,
|
|
93
|
+
withNegated: false,
|
|
94
|
+
brief,
|
|
95
|
+
hidden
|
|
96
|
+
});
|
|
97
|
+
var repeated = (placeholder, brief) => ({
|
|
98
|
+
kind: "parsed",
|
|
99
|
+
parse: unprotect,
|
|
100
|
+
optional: true,
|
|
101
|
+
variadic: true,
|
|
102
|
+
placeholder,
|
|
103
|
+
brief,
|
|
104
|
+
hidden: false
|
|
105
|
+
});
|
|
106
|
+
var flagCatalog = {
|
|
107
|
+
// Only the sign-in commands name a server. Every other command uses the
|
|
108
|
+
// server `artis login` saved last.
|
|
109
|
+
host: value(
|
|
110
|
+
"url",
|
|
111
|
+
`Server to sign in to; otherwise the saved login, or ${ARTIS_DEFAULT_HOST}.`
|
|
112
|
+
),
|
|
113
|
+
url: value("url", "Alias for --host.", true),
|
|
114
|
+
json: bool("Print machine-readable JSON."),
|
|
115
|
+
next: bool("With --json, return data and suggested nextActions."),
|
|
116
|
+
title: value("text", "Artifact title; defaults to the file name."),
|
|
117
|
+
description: value("text", "Artifact description."),
|
|
118
|
+
visibility: value(
|
|
119
|
+
"public|unlisted|private",
|
|
120
|
+
"Visibility; defaults to unlisted."
|
|
121
|
+
),
|
|
122
|
+
type: value("type", "Artifact type; defaults to html on publish."),
|
|
123
|
+
author: value("name", "Author name; defaults to Artis CLI."),
|
|
124
|
+
summary: value("text", "Revision summary; one change per line."),
|
|
125
|
+
base: value(
|
|
126
|
+
"revision-id",
|
|
127
|
+
"Base revision; defaults to remembered base. Protects against conflicts."
|
|
128
|
+
),
|
|
129
|
+
capabilities: value("json|file", "Page capabilities JSON; {} clears them."),
|
|
130
|
+
"reload-pages": bool("Reload open pages."),
|
|
131
|
+
comment: value("text", "Comment text."),
|
|
132
|
+
"requested-change": value("text", "Requested change."),
|
|
133
|
+
status: value("open|resolved", "Review status; defaults to open."),
|
|
134
|
+
quote: value("text", "Exact text to anchor to."),
|
|
135
|
+
"quote-prefix": value("text", "Text immediately before the quote."),
|
|
136
|
+
"quote-suffix": value("text", "Text immediately after the quote."),
|
|
137
|
+
css: value("selector", "CSS selector to anchor to."),
|
|
138
|
+
"text-start": value("n", "Start document offset."),
|
|
139
|
+
"text-end": value("n", "End document offset."),
|
|
140
|
+
rect: value("x,y,w,h", "Canvas point or rectangle in percentages."),
|
|
141
|
+
"pin-label": value("text", "Short pin label."),
|
|
142
|
+
output: value("path", "Write output to this path."),
|
|
143
|
+
root: value("dir", "Source directory containing only artifact files."),
|
|
144
|
+
revision: value("revision-id", "Revision to read; defaults to current."),
|
|
145
|
+
query: value("text", "Search artifact titles and descriptions."),
|
|
146
|
+
tag: value("tag", "Filter by tag."),
|
|
147
|
+
limit: value("n", "Page size."),
|
|
148
|
+
cursor: value("cursor", "Continue a previous artifact list page."),
|
|
149
|
+
email: value("email", "Share recipient."),
|
|
150
|
+
role: value(
|
|
151
|
+
"role",
|
|
152
|
+
"viewer, commenter, contributor or editor; defaults to viewer."
|
|
153
|
+
),
|
|
154
|
+
remove: bool("Remove recipient access."),
|
|
155
|
+
harness: repeated(
|
|
156
|
+
"id",
|
|
157
|
+
"Harness ID; repeatable (claude-code, codex, cursor, openclaw, pi, hermes)."
|
|
158
|
+
),
|
|
159
|
+
yes: bool("Confirm the requested operation."),
|
|
160
|
+
dir: value("path", "Custom skills directory."),
|
|
161
|
+
force: bool("Overwrite existing skill."),
|
|
162
|
+
list: bool("List supported harnesses."),
|
|
163
|
+
since: value("cursor", "Event cursor; defaults to now. 0 replays events."),
|
|
164
|
+
once: bool("Exit after first batch of events."),
|
|
165
|
+
timeout: value("duration", "Timeout, e.g. 30s or 10m."),
|
|
166
|
+
self: value(
|
|
167
|
+
"origin|client|none",
|
|
168
|
+
"Exclude own events at origin or client scope; default origin."
|
|
169
|
+
),
|
|
170
|
+
"include-self": bool("Alias for --self none.", true),
|
|
171
|
+
types: value(
|
|
172
|
+
"families",
|
|
173
|
+
"Comma-separated event families: annotation, revision, page, policy."
|
|
174
|
+
),
|
|
175
|
+
value: value("json|file|-", "Whole document JSON, file, or stdin."),
|
|
176
|
+
patch: value("json|file|-", "JSON object deep-merged into document."),
|
|
177
|
+
ops: value("json|file|-", "Batch operations JSON, file, or stdin."),
|
|
178
|
+
"if-match": value("id@version", "Write only at this document version."),
|
|
179
|
+
"if-absent": bool("Write only if the path has no document."),
|
|
180
|
+
"idempotency-key": value(
|
|
181
|
+
"key",
|
|
182
|
+
"Make a data write safe to retry within 24 hours."
|
|
183
|
+
),
|
|
184
|
+
"as-role": value("role", "Read as viewer, commenter or contributor."),
|
|
185
|
+
depth: value("children|all", "Subtree depth; default all."),
|
|
186
|
+
order: value("path|created", "List ordering; default path."),
|
|
187
|
+
after: value("next", "Continue after a prior page."),
|
|
188
|
+
name: value("name", "Asset name; defaults to file name."),
|
|
189
|
+
"content-type": value("type", "Asset MIME type."),
|
|
190
|
+
// Removed flags: every command declares them (hidden) so their use is
|
|
191
|
+
// explained instead of refused as unknown. See rejectRefusedFlags.
|
|
192
|
+
kind: value("value", "Removed; use --type.", true),
|
|
193
|
+
contract: value("value", "Removed; page contract is fixed.", true),
|
|
194
|
+
resolve: value(
|
|
195
|
+
"value",
|
|
196
|
+
"Removed; revisions no longer resolve feedback.",
|
|
197
|
+
true
|
|
198
|
+
)
|
|
199
|
+
};
|
|
200
|
+
var removedFlags = ["kind", "contract", "resolve"];
|
|
201
|
+
var valueFlags = new Set(
|
|
202
|
+
Object.entries(flagCatalog).filter(([, flag]) => flag.kind === "parsed").map(([name]) => `--${name}`)
|
|
203
|
+
);
|
|
204
|
+
function hostOf(flags) {
|
|
205
|
+
return flags.host || flags.url || void 0;
|
|
206
|
+
}
|
|
207
|
+
function rejectRefusedFlags(flags, takesHost) {
|
|
208
|
+
if (!takesHost && (flags.host !== void 0 || flags.url !== void 0)) {
|
|
209
|
+
throw usageError(
|
|
210
|
+
"Only artis login and artis whoami take --host: every other command uses the server artis login signed in to. Run artis login --host <url> to switch to another server."
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (flags.kind !== void 0) {
|
|
214
|
+
throw usageError(
|
|
215
|
+
"--kind was removed: artifacts no longer have a kind. Use --type for the type an artifact is written in (html by default), or tags to group artifacts."
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
if (flags.resolve !== void 0) {
|
|
219
|
+
throw usageError(
|
|
220
|
+
'--resolve was removed: a revision no longer changes review status. Reply in each thread you addressed with "artis reply"; the reviewers resolve it.'
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
if (flags.contract !== void 0) {
|
|
224
|
+
throw usageError(
|
|
225
|
+
"--contract was removed: there is one page contract, and every page gets the `artis` global."
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
var arg = (placeholder, brief) => ({
|
|
230
|
+
placeholder,
|
|
231
|
+
brief
|
|
232
|
+
});
|
|
233
|
+
var optionalArg = (placeholder, brief) => ({ placeholder, brief, optional: true });
|
|
234
|
+
var artifactArg = arg("artifact", "Artifact id, short id or link.");
|
|
235
|
+
function command(spec) {
|
|
236
|
+
return (route) => {
|
|
237
|
+
const path = route.split(" ");
|
|
238
|
+
const positionals = spec.args ?? [];
|
|
239
|
+
const takesHost = spec.flags.includes("host");
|
|
240
|
+
const refused = (name) => ({
|
|
241
|
+
...flagCatalog[name],
|
|
242
|
+
hidden: true
|
|
243
|
+
});
|
|
244
|
+
const parameters = {
|
|
245
|
+
flags: {
|
|
246
|
+
...takesHost ? {} : { host: refused("host"), url: refused("url") },
|
|
247
|
+
...Object.fromEntries(
|
|
248
|
+
[...spec.flags, ...removedFlags].map((name) => [
|
|
249
|
+
name,
|
|
250
|
+
flagCatalog[name]
|
|
251
|
+
])
|
|
252
|
+
)
|
|
253
|
+
},
|
|
254
|
+
...positionals.length ? {
|
|
255
|
+
positional: {
|
|
256
|
+
kind: "tuple",
|
|
257
|
+
parameters: positionals.map((positional) => ({
|
|
258
|
+
...positional,
|
|
259
|
+
parse: String
|
|
260
|
+
}))
|
|
261
|
+
}
|
|
262
|
+
} : {}
|
|
263
|
+
};
|
|
264
|
+
const command2 = buildCommand({
|
|
265
|
+
func(flags, ...args) {
|
|
266
|
+
return this.execute(path, async () => {
|
|
267
|
+
rejectRefusedFlags(flags, takesHost);
|
|
268
|
+
await spec.run(flags, ...args);
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
// Built from the catalog at run time, so TypeScript cannot follow it;
|
|
272
|
+
// Parsed and ArgsOf<P> are derived from the same catalog and
|
|
273
|
+
// positionals, so the two agree by construction.
|
|
274
|
+
parameters,
|
|
275
|
+
docs: {
|
|
276
|
+
brief: spec.brief,
|
|
277
|
+
fullDescription: spec.fullDescription,
|
|
278
|
+
customUsage: spec.usage
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
return {
|
|
282
|
+
route,
|
|
283
|
+
usage: spec.usage,
|
|
284
|
+
brief: spec.brief,
|
|
285
|
+
flags: spec.flags,
|
|
286
|
+
hidden: spec.hidden ?? false,
|
|
287
|
+
command: command2
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function writeText(text) {
|
|
292
|
+
process.stdout.write(text.endsWith("\n") ? text : `${text}
|
|
293
|
+
`);
|
|
294
|
+
}
|
|
295
|
+
var commandSpecs = {
|
|
296
|
+
login: command({
|
|
297
|
+
brief: "Authenticate using browser approval",
|
|
298
|
+
usage: ["[--host <url>]"],
|
|
299
|
+
flags: ["host", "url"],
|
|
300
|
+
async run(flags) {
|
|
301
|
+
const host = hostOf(flags);
|
|
302
|
+
const { configPath } = await onAuthFailure(
|
|
303
|
+
host,
|
|
304
|
+
() => login(
|
|
305
|
+
{ host },
|
|
306
|
+
{
|
|
307
|
+
onCode(verificationUrl, userCode) {
|
|
308
|
+
console.log(`Opening ${verificationUrl}`);
|
|
309
|
+
console.log(`Code: ${userCode}`);
|
|
310
|
+
},
|
|
311
|
+
onBrowserFailure() {
|
|
312
|
+
console.log("Could not open a browser automatically.");
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
)
|
|
316
|
+
);
|
|
317
|
+
console.log(`Saved artis credentials to ${configPath}`);
|
|
318
|
+
}
|
|
319
|
+
}),
|
|
320
|
+
whoami: command({
|
|
321
|
+
brief: "Show signed-in identity",
|
|
322
|
+
usage: ["[--host <url>]"],
|
|
323
|
+
flags: ["host", "url"],
|
|
324
|
+
async run(flags) {
|
|
325
|
+
const host = hostOf(flags);
|
|
326
|
+
const { baseUrl, principal } = await onAuthFailure(
|
|
327
|
+
host,
|
|
328
|
+
() => whoami({ host })
|
|
329
|
+
);
|
|
330
|
+
console.log(
|
|
331
|
+
`Signed in to ${baseUrl} as ${principal.name ?? principal.userId}`
|
|
332
|
+
);
|
|
333
|
+
console.log(`Principal: ${principal.kind}`);
|
|
334
|
+
}
|
|
335
|
+
}),
|
|
336
|
+
guidelines: command({
|
|
337
|
+
brief: "Read current authoring guidelines",
|
|
338
|
+
usage: ["[section]"],
|
|
339
|
+
flags: ["contract"],
|
|
340
|
+
args: [optionalArg("section", "Section name, or all.")],
|
|
341
|
+
async run(flags, section) {
|
|
342
|
+
writeText(await readGuidelines({ section }));
|
|
343
|
+
}
|
|
344
|
+
}),
|
|
345
|
+
types: command({
|
|
346
|
+
brief: "Discover artifact types and references",
|
|
347
|
+
usage: ["[name [reference]]"],
|
|
348
|
+
flags: ["json"],
|
|
349
|
+
args: [
|
|
350
|
+
optionalArg("name", "Type name."),
|
|
351
|
+
optionalArg("reference", "Reference path of the type.")
|
|
352
|
+
],
|
|
353
|
+
async run(flags, name, reference) {
|
|
354
|
+
if (!name) {
|
|
355
|
+
const types = await listTypes({});
|
|
356
|
+
if (flags.json) return printJson(types);
|
|
357
|
+
if (!types.length) {
|
|
358
|
+
console.log("No types are installed on this server.");
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
for (const type2 of types) {
|
|
362
|
+
console.log(
|
|
363
|
+
`${type2.name} format ${type2.format} ${type2.release} ${type2.description}`
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (reference) {
|
|
369
|
+
const result = await readTypeReference({
|
|
370
|
+
name,
|
|
371
|
+
path: reference
|
|
372
|
+
});
|
|
373
|
+
if (flags.json) return printJson(result);
|
|
374
|
+
writeText(result.content);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const type = await readType({ name });
|
|
378
|
+
if (flags.json) return printJson(type);
|
|
379
|
+
if (type.guidance) {
|
|
380
|
+
writeText(type.guidance);
|
|
381
|
+
} else {
|
|
382
|
+
console.log(`${type.title}: ${type.description}`);
|
|
383
|
+
}
|
|
384
|
+
if (type.references.length) {
|
|
385
|
+
console.log(
|
|
386
|
+
`
|
|
387
|
+
References (artis types ${type.name} <path>):
|
|
388
|
+
${type.references.map((path) => ` ${path}`).join("\n")}`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}),
|
|
393
|
+
"install-skill": command({
|
|
394
|
+
brief: "Install or list agent skills",
|
|
395
|
+
usage: ["[--harness <id>] [--yes] [--dir <path>]"],
|
|
396
|
+
flags: ["harness", "yes", "dir", "force", "list", "json"],
|
|
397
|
+
async run(flags) {
|
|
398
|
+
if (flags.list) {
|
|
399
|
+
const harnesses = await listSkillHarnesses();
|
|
400
|
+
if (flags.json) printJson({ harnesses });
|
|
401
|
+
else printHarnessTable(harnesses);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const report = await installSkill(flags);
|
|
405
|
+
if (flags.json) printJson(report);
|
|
406
|
+
else printInstallResults(report.results);
|
|
407
|
+
if (report.errors.length > 0) {
|
|
408
|
+
for (const failure of report.errors) {
|
|
409
|
+
console.error(
|
|
410
|
+
`install-skill failed for ${failure.target}: ${failure.error}`
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
throw new Error(
|
|
414
|
+
`install-skill completed with errors (${report.errors.map((failure) => failure.target).join(", ")}).`
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}),
|
|
419
|
+
publish: command({
|
|
420
|
+
brief: "Publish a new artifact",
|
|
421
|
+
usage: ["<file> [options]", "--root <dir> [--type <type>] [options]"],
|
|
422
|
+
flags: [
|
|
423
|
+
"json",
|
|
424
|
+
"next",
|
|
425
|
+
"title",
|
|
426
|
+
"description",
|
|
427
|
+
"visibility",
|
|
428
|
+
"type",
|
|
429
|
+
"author",
|
|
430
|
+
"capabilities",
|
|
431
|
+
"reload-pages",
|
|
432
|
+
"root"
|
|
433
|
+
],
|
|
434
|
+
args: [optionalArg("file", "Self-contained HTML file.")],
|
|
435
|
+
async run(flags, file) {
|
|
436
|
+
const published = await publishArtifact({
|
|
437
|
+
file,
|
|
438
|
+
root: flags.root,
|
|
439
|
+
title: flags.title,
|
|
440
|
+
description: flags.description,
|
|
441
|
+
visibility: flags.visibility,
|
|
442
|
+
type: flags.type,
|
|
443
|
+
author: flags.author,
|
|
444
|
+
capabilities: flags.capabilities,
|
|
445
|
+
reloadPages: flags["reload-pages"]
|
|
446
|
+
});
|
|
447
|
+
emit(flags, {
|
|
448
|
+
data: published,
|
|
449
|
+
actions: publishedActions(published.artifactId),
|
|
450
|
+
text() {
|
|
451
|
+
console.log(`Published "${published.title}"`);
|
|
452
|
+
console.log(`Artifact: ${published.artifactId}`);
|
|
453
|
+
console.log(`Revision: ${published.revisionId}`);
|
|
454
|
+
console.log(`Visibility: ${published.visibility}`);
|
|
455
|
+
const type = describeType(published);
|
|
456
|
+
if (type) console.log(`Type: ${type}`);
|
|
457
|
+
console.log(published.url);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}),
|
|
462
|
+
revise: command({
|
|
463
|
+
brief: "Create a revision from edited source",
|
|
464
|
+
usage: [
|
|
465
|
+
"<artifact> <file> --summary <text>",
|
|
466
|
+
"<artifact> --root <dir> --summary <text>"
|
|
467
|
+
],
|
|
468
|
+
fullDescription: "Re-read and reconcile changes on exit 5; do not simply replace the base.",
|
|
469
|
+
flags: [
|
|
470
|
+
"json",
|
|
471
|
+
"next",
|
|
472
|
+
"summary",
|
|
473
|
+
"base",
|
|
474
|
+
"root",
|
|
475
|
+
"type",
|
|
476
|
+
"author",
|
|
477
|
+
"capabilities",
|
|
478
|
+
"reload-pages"
|
|
479
|
+
],
|
|
480
|
+
args: [artifactArg, optionalArg("file", "Edited HTML file.")],
|
|
481
|
+
async run(flags, artifact, file) {
|
|
482
|
+
const result = await onConflict(
|
|
483
|
+
() => reviseArtifact({
|
|
484
|
+
artifact,
|
|
485
|
+
file,
|
|
486
|
+
root: flags.root,
|
|
487
|
+
summary: flags.summary,
|
|
488
|
+
base: flags.base,
|
|
489
|
+
type: flags.type,
|
|
490
|
+
author: flags.author,
|
|
491
|
+
capabilities: flags.capabilities,
|
|
492
|
+
reloadPages: flags["reload-pages"]
|
|
493
|
+
}),
|
|
494
|
+
() => reviseConflictActions(artifact)
|
|
495
|
+
);
|
|
496
|
+
const actions = publishedActions(result.artifactId);
|
|
497
|
+
if (result.unchanged) {
|
|
498
|
+
if (flags.json && flags.next) {
|
|
499
|
+
const { revisionId } = result;
|
|
500
|
+
emit(flags, { data: { revisionId, unchanged: true }, actions });
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
console.log(
|
|
504
|
+
`No files differ from revision ${result.revisionId}; nothing to revise.`
|
|
505
|
+
);
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const { revision, sent, baseRevisionId, baseRemembered } = result;
|
|
509
|
+
if (sent && !flags.json) {
|
|
510
|
+
console.log(
|
|
511
|
+
`Sent ${sent.changed} changed and ${sent.removed} removed of ${sent.total} files.`
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
emit(flags, {
|
|
515
|
+
data: { revision },
|
|
516
|
+
actions,
|
|
517
|
+
text() {
|
|
518
|
+
console.log(`Revision ${revision.id}`);
|
|
519
|
+
console.log(`Version ${revision.version}`);
|
|
520
|
+
const type = describeType(revision);
|
|
521
|
+
if (type) console.log(`Type ${type}`);
|
|
522
|
+
if (baseRemembered) {
|
|
523
|
+
console.log(
|
|
524
|
+
`Base ${baseRevisionId} (remembered from this machine)`
|
|
525
|
+
);
|
|
526
|
+
} else if (!baseRevisionId) {
|
|
527
|
+
console.log(
|
|
528
|
+
"No base revision: pass --base, or read the artifact with publish or artifact files first, so a concurrent revision is refused instead of overwritten."
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}),
|
|
535
|
+
verify: command({
|
|
536
|
+
brief: "Validate rendered artifact or local source",
|
|
537
|
+
usage: ["<file-or-artifact> [options]", "--root <dir> [--type <type>]"],
|
|
538
|
+
fullDescription: "Exit 8 means verification found problems.",
|
|
539
|
+
flags: ["json", "root", "type", "revision"],
|
|
540
|
+
args: [optionalArg("file-or-artifact", "Local HTML file or artifact.")],
|
|
541
|
+
async run(flags, target) {
|
|
542
|
+
const job = await prepareVerify({
|
|
543
|
+
target,
|
|
544
|
+
root: flags.root,
|
|
545
|
+
type: flags.type,
|
|
546
|
+
revision: flags.revision
|
|
547
|
+
});
|
|
548
|
+
const title = `Verified ${job.label}${job.type ? ` (type ${job.type.name})` : ""}`;
|
|
549
|
+
let report;
|
|
550
|
+
try {
|
|
551
|
+
report = await verifyFiles(job.files, {
|
|
552
|
+
type: job.type,
|
|
553
|
+
loadAsset: job.loadAsset
|
|
554
|
+
});
|
|
555
|
+
} catch (error) {
|
|
556
|
+
if (error instanceof VerifyUnavailableError) {
|
|
557
|
+
throw new CliError(error.message, exitCodes.error);
|
|
558
|
+
}
|
|
559
|
+
throw error;
|
|
560
|
+
}
|
|
561
|
+
if (flags.json) {
|
|
562
|
+
printJson(report);
|
|
563
|
+
} else {
|
|
564
|
+
console.log(title);
|
|
565
|
+
for (const line of formatVerifyReport(report)) console.log(line);
|
|
566
|
+
}
|
|
567
|
+
if (!report.ok) {
|
|
568
|
+
throw new CliError("", exitCodes.verifyFailed);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}),
|
|
572
|
+
share: command({
|
|
573
|
+
brief: "List or manage artifact access",
|
|
574
|
+
usage: ["<artifact> [--email <email> --role <role>] [--remove]"],
|
|
575
|
+
flags: ["json", "email", "role", "remove"],
|
|
576
|
+
args: [artifactArg],
|
|
577
|
+
async run(flags, artifact) {
|
|
578
|
+
const shared = await shareArtifact({
|
|
579
|
+
artifact,
|
|
580
|
+
email: flags.email,
|
|
581
|
+
role: flags.role,
|
|
582
|
+
remove: flags.remove
|
|
583
|
+
});
|
|
584
|
+
switch (shared.action) {
|
|
585
|
+
case "list": {
|
|
586
|
+
if (flags.json) return printJson(shared.result);
|
|
587
|
+
const { shares } = shared.result;
|
|
588
|
+
if (!shares.length) {
|
|
589
|
+
console.log("No invited people yet.");
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
for (const share of shares) {
|
|
593
|
+
console.log(`${share.email} ${share.role}`);
|
|
594
|
+
}
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
case "remove":
|
|
598
|
+
console.log(`Removed ${shared.email}`);
|
|
599
|
+
return;
|
|
600
|
+
case "add":
|
|
601
|
+
if (flags.json) return printJson(shared.result);
|
|
602
|
+
console.log(
|
|
603
|
+
`Shared with ${shared.result.share.email} as ${shared.result.share.role}`
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}),
|
|
608
|
+
annotate: command({
|
|
609
|
+
brief: "Create a feedback annotation",
|
|
610
|
+
usage: ["<artifact> --comment <text> [anchor options]"],
|
|
611
|
+
flags: [
|
|
612
|
+
"comment",
|
|
613
|
+
"author",
|
|
614
|
+
"title",
|
|
615
|
+
"requested-change",
|
|
616
|
+
"status",
|
|
617
|
+
"quote",
|
|
618
|
+
"quote-prefix",
|
|
619
|
+
"quote-suffix",
|
|
620
|
+
"css",
|
|
621
|
+
"text-start",
|
|
622
|
+
"text-end",
|
|
623
|
+
"rect",
|
|
624
|
+
"pin-label"
|
|
625
|
+
],
|
|
626
|
+
args: [artifactArg],
|
|
627
|
+
async run(flags, artifact) {
|
|
628
|
+
const created = await createAnnotation({
|
|
629
|
+
artifact,
|
|
630
|
+
comment: flags.comment,
|
|
631
|
+
author: flags.author,
|
|
632
|
+
title: flags.title,
|
|
633
|
+
requestedChange: flags["requested-change"],
|
|
634
|
+
status: flags.status,
|
|
635
|
+
pinLabel: flags["pin-label"],
|
|
636
|
+
quote: flags.quote,
|
|
637
|
+
quotePrefix: flags["quote-prefix"],
|
|
638
|
+
quoteSuffix: flags["quote-suffix"],
|
|
639
|
+
css: flags.css,
|
|
640
|
+
textStart: flags["text-start"],
|
|
641
|
+
textEnd: flags["text-end"],
|
|
642
|
+
rect: flags.rect
|
|
643
|
+
});
|
|
644
|
+
console.log(`Annotation ${created.annotationId}`);
|
|
645
|
+
console.log(`Status ${created.status}`);
|
|
646
|
+
}
|
|
647
|
+
}),
|
|
648
|
+
reply: command({
|
|
649
|
+
brief: "Reply to feedback",
|
|
650
|
+
usage: ["<annotation-id> --comment <text>"],
|
|
651
|
+
flags: ["comment", "author"],
|
|
652
|
+
args: [arg("annotation-id", "Annotation to reply to.")],
|
|
653
|
+
async run(flags, annotationId) {
|
|
654
|
+
const reply = await replyToAnnotation({
|
|
655
|
+
annotationId,
|
|
656
|
+
comment: flags.comment,
|
|
657
|
+
author: flags.author
|
|
658
|
+
});
|
|
659
|
+
console.log(`Reply ${reply.annotationId}`);
|
|
660
|
+
}
|
|
661
|
+
}),
|
|
662
|
+
watch: command({
|
|
663
|
+
brief: "Watch artifact events",
|
|
664
|
+
usage: ["<artifact> [options]"],
|
|
665
|
+
flags: ["since", "once", "timeout", "self", "include-self", "types"],
|
|
666
|
+
args: [artifactArg],
|
|
667
|
+
async run(flags, artifact) {
|
|
668
|
+
await watchArtifact(
|
|
669
|
+
{
|
|
670
|
+
artifact,
|
|
671
|
+
since: flags.since,
|
|
672
|
+
once: flags.once,
|
|
673
|
+
timeout: flags.timeout,
|
|
674
|
+
self: flags.self,
|
|
675
|
+
includeSelf: flags["include-self"],
|
|
676
|
+
types: flags.types
|
|
677
|
+
},
|
|
678
|
+
(events, cursor) => {
|
|
679
|
+
if (flags.once) {
|
|
680
|
+
console.log(JSON.stringify({ events, cursor }));
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
for (const event of events) {
|
|
684
|
+
process.stdout.write(`${JSON.stringify(event)}
|
|
685
|
+
`);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
}),
|
|
691
|
+
version: command({
|
|
692
|
+
brief: "Show CLI version",
|
|
693
|
+
usage: [""],
|
|
694
|
+
flags: [],
|
|
695
|
+
async run() {
|
|
696
|
+
console.log(`artis ${artisCliVersion}`);
|
|
697
|
+
}
|
|
698
|
+
}),
|
|
699
|
+
"artifact get": command({
|
|
700
|
+
brief: "Read artifact metadata",
|
|
701
|
+
usage: ["<artifact>"],
|
|
702
|
+
flags: ["json"],
|
|
703
|
+
args: [artifactArg],
|
|
704
|
+
async run(flags, artifact) {
|
|
705
|
+
const { details, openAnnotations } = await getArtifact({
|
|
706
|
+
artifact
|
|
707
|
+
});
|
|
708
|
+
emit(flags, {
|
|
709
|
+
data: details,
|
|
710
|
+
text() {
|
|
711
|
+
const { artifact: read } = details;
|
|
712
|
+
console.log(read.metadata.title);
|
|
713
|
+
console.log(`Artifact: ${read.id}`);
|
|
714
|
+
console.log(`Revision: ${read.currentRevisionId}`);
|
|
715
|
+
const current = read.revisions.find(
|
|
716
|
+
(revision) => revision.id === read.currentRevisionId
|
|
717
|
+
);
|
|
718
|
+
const type = current && describeType(current);
|
|
719
|
+
if (type) console.log(`Type: ${type}`);
|
|
720
|
+
console.log(`Open annotations: ${openAnnotations}`);
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
}),
|
|
725
|
+
"artifact files": command({
|
|
726
|
+
brief: "Read or download revision files",
|
|
727
|
+
usage: ["<artifact> [path] [--output <dir>]"],
|
|
728
|
+
flags: ["json", "output", "revision"],
|
|
729
|
+
args: [artifactArg, optionalArg("path", "One file of the revision.")],
|
|
730
|
+
async run(flags, artifact, path) {
|
|
731
|
+
const input = {
|
|
732
|
+
artifact,
|
|
733
|
+
revision: flags.revision
|
|
734
|
+
};
|
|
735
|
+
if (path) {
|
|
736
|
+
if (flags.output) {
|
|
737
|
+
throw usageError(
|
|
738
|
+
`--output writes every file of the revision under a directory. To save one file, redirect it: artis artifact files ${artifact} ${path} > <file>.`
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
const file = await readArtifactFile({ ...input, path });
|
|
742
|
+
if (file.isLatest === false) {
|
|
743
|
+
console.error(
|
|
744
|
+
`Note: version ${file.version} is not the latest. The latest is version ${file.latestVersion} (revision ${file.latestRevisionId}); a revise based on this one will be refused if it changes a file changed since.`
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
if (flags.json) return printJson(file);
|
|
748
|
+
process.stdout.write(file.content);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
const output = flags.output;
|
|
752
|
+
const listed = await listArtifactFiles({ ...input, output });
|
|
753
|
+
if (flags.json) return printJson(listed);
|
|
754
|
+
for (const file of listed.files) {
|
|
755
|
+
console.log(`${file.path} ${file.size}`);
|
|
756
|
+
}
|
|
757
|
+
console.log(
|
|
758
|
+
output ? `Wrote ${listed.files.length} files of revision ${listed.revisionId} (v${listed.version}) to ${output}.` : `Revision ${listed.revisionId} (v${listed.version})${listed.isLatest ? "" : ", not the latest"}.`
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
}),
|
|
762
|
+
"artifact feedback": command({
|
|
763
|
+
brief: "Read review feedback and event cursor",
|
|
764
|
+
usage: ["<artifact>"],
|
|
765
|
+
flags: ["json", "next", "revision"],
|
|
766
|
+
args: [artifactArg],
|
|
767
|
+
async run(flags, artifact) {
|
|
768
|
+
const { artifactId, feedback } = await readFeedback({
|
|
769
|
+
artifact,
|
|
770
|
+
revision: flags.revision
|
|
771
|
+
});
|
|
772
|
+
emit(flags, {
|
|
773
|
+
data: feedback,
|
|
774
|
+
actions: feedbackActions(
|
|
775
|
+
artifactId,
|
|
776
|
+
feedback.cursor,
|
|
777
|
+
feedback.bundle.openAnnotations.length
|
|
778
|
+
),
|
|
779
|
+
text() {
|
|
780
|
+
console.log(feedback.prompt);
|
|
781
|
+
console.log(
|
|
782
|
+
`
|
|
783
|
+
Feedback cursor: ${feedback.cursor} (artis watch ${artifactId} --since ${feedback.cursor})`
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
}),
|
|
789
|
+
"artifact list": command({
|
|
790
|
+
brief: "Search your artifacts",
|
|
791
|
+
usage: ["[options]"],
|
|
792
|
+
flags: ["json", "query", "tag", "type", "limit", "cursor"],
|
|
793
|
+
async run(flags) {
|
|
794
|
+
const result = await listArtifacts({
|
|
795
|
+
query: flags.query,
|
|
796
|
+
tag: flags.tag,
|
|
797
|
+
type: flags.type,
|
|
798
|
+
limit: flags.limit,
|
|
799
|
+
cursor: flags.cursor
|
|
800
|
+
});
|
|
801
|
+
if (flags.json) return printJson(result);
|
|
802
|
+
const { artifacts } = result;
|
|
803
|
+
if (!artifacts.length) {
|
|
804
|
+
console.log(
|
|
805
|
+
flags.cursor ? "No more artifacts." : flags.query || flags.tag ? "No artifacts match." : "You have no artifacts yet."
|
|
806
|
+
);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
for (const artifact of artifacts) {
|
|
810
|
+
const tags = artifact.metadata.tags?.length ? ` #${artifact.metadata.tags.join(" #")}` : "";
|
|
811
|
+
console.log(
|
|
812
|
+
`${artifactShortId(artifact.id)} ${artifact.metadata.visibility} ${artifact.metadata.title}${tags}`
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
if (result.nextCursor) {
|
|
816
|
+
console.log(
|
|
817
|
+
`More artifacts: rerun with --cursor ${result.nextCursor} (same filters).`
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}),
|
|
822
|
+
"artifact visibility": command({
|
|
823
|
+
brief: "Change artifact visibility",
|
|
824
|
+
usage: ["<artifact> <public|unlisted|private>"],
|
|
825
|
+
flags: ["json"],
|
|
826
|
+
args: [artifactArg, arg("visibility", "public, unlisted or private.")],
|
|
827
|
+
async run(flags, artifact, visibility) {
|
|
828
|
+
const result = await setArtifactVisibility({
|
|
829
|
+
artifact,
|
|
830
|
+
visibility
|
|
831
|
+
});
|
|
832
|
+
if (flags.json) return printJson(result);
|
|
833
|
+
console.log(`Visibility: ${result.artifact.metadata.visibility}`);
|
|
834
|
+
}
|
|
835
|
+
}),
|
|
836
|
+
"artifact delete": command({
|
|
837
|
+
brief: "Permanently delete an artifact",
|
|
838
|
+
usage: ["<artifact> --yes"],
|
|
839
|
+
flags: ["yes"],
|
|
840
|
+
args: [artifactArg],
|
|
841
|
+
async run(flags, artifact) {
|
|
842
|
+
const { artifactId } = await deleteArtifact({
|
|
843
|
+
artifact,
|
|
844
|
+
yes: flags.yes
|
|
845
|
+
});
|
|
846
|
+
console.log(`Deleted ${artifactId}`);
|
|
847
|
+
}
|
|
848
|
+
}),
|
|
849
|
+
"artifact html": command({
|
|
850
|
+
brief: "Removed; use artifact files",
|
|
851
|
+
usage: ["<artifact>"],
|
|
852
|
+
hidden: true,
|
|
853
|
+
flags: [],
|
|
854
|
+
args: [optionalArg("artifact", "Artifact."), optionalArg("path", "Path.")],
|
|
855
|
+
async run() {
|
|
856
|
+
throw usageError(
|
|
857
|
+
"artifact html was removed: every artifact is a set of files, and an html artifact is one, index.html. Use artis artifact files <artifact> index.html (or --output <dir>)."
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
}),
|
|
861
|
+
"capabilities show": command({
|
|
862
|
+
brief: "Read page capability policy",
|
|
863
|
+
usage: ["<artifact>"],
|
|
864
|
+
flags: ["json"],
|
|
865
|
+
args: [artifactArg],
|
|
866
|
+
async run(flags, artifact) {
|
|
867
|
+
const policy = await readCapabilities({ artifact });
|
|
868
|
+
if (flags.json) return printJson(policy);
|
|
869
|
+
printPolicy(policy);
|
|
870
|
+
}
|
|
871
|
+
}),
|
|
872
|
+
"capabilities set": command({
|
|
873
|
+
brief: "Replace page capability policy",
|
|
874
|
+
usage: ["<artifact> <json|file>"],
|
|
875
|
+
flags: ["json", "reload-pages"],
|
|
876
|
+
args: [artifactArg, arg("json|file", "Capabilities JSON or JSON file.")],
|
|
877
|
+
async run(flags, artifact, capabilities) {
|
|
878
|
+
const { artifact: policy } = await setCapabilities({
|
|
879
|
+
artifact,
|
|
880
|
+
capabilities,
|
|
881
|
+
reloadPages: flags["reload-pages"]
|
|
882
|
+
});
|
|
883
|
+
if (flags.json) return printJson({ artifact: policy });
|
|
884
|
+
printPolicy(policy);
|
|
885
|
+
}
|
|
886
|
+
}),
|
|
887
|
+
"annotation edit": command({
|
|
888
|
+
brief: "Edit feedback",
|
|
889
|
+
usage: ["<annotation-id> [options]"],
|
|
890
|
+
flags: ["comment", "title", "requested-change"],
|
|
891
|
+
args: [arg("annotation-id", "Annotation to edit.")],
|
|
892
|
+
async run(flags, annotationId) {
|
|
893
|
+
const edited = await editAnnotation({
|
|
894
|
+
annotationId,
|
|
895
|
+
comment: flags.comment,
|
|
896
|
+
title: flags.title,
|
|
897
|
+
requestedChange: flags["requested-change"]
|
|
898
|
+
});
|
|
899
|
+
console.log(`Annotation ${edited.annotationId} edited`);
|
|
900
|
+
}
|
|
901
|
+
}),
|
|
902
|
+
"annotation retract": command({
|
|
903
|
+
brief: "Retract feedback",
|
|
904
|
+
usage: ["<annotation-id>"],
|
|
905
|
+
flags: [],
|
|
906
|
+
args: [arg("annotation-id", "Annotation to retract.")],
|
|
907
|
+
async run(flags, annotationId) {
|
|
908
|
+
const retracted = await retractAnnotation({
|
|
909
|
+
annotationId
|
|
910
|
+
});
|
|
911
|
+
console.log(`Annotation ${retracted.annotationId} retracted`);
|
|
912
|
+
}
|
|
913
|
+
}),
|
|
914
|
+
"data get": command({
|
|
915
|
+
brief: "Read a stored document",
|
|
916
|
+
usage: ["<artifact> <path>"],
|
|
917
|
+
flags: ["as-role"],
|
|
918
|
+
args: [artifactArg, arg("path", "Document path.")],
|
|
919
|
+
async run(flags, artifact, path) {
|
|
920
|
+
const { document } = await getDocument({
|
|
921
|
+
artifact,
|
|
922
|
+
path,
|
|
923
|
+
asRole: flags["as-role"]
|
|
924
|
+
});
|
|
925
|
+
printJson(document);
|
|
926
|
+
if (!document) {
|
|
927
|
+
throw new CliError(`No document at "${path}".`, exitCodes.notFound);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}),
|
|
931
|
+
"data list": command({
|
|
932
|
+
brief: "List stored documents",
|
|
933
|
+
usage: ["<artifact> [prefix]"],
|
|
934
|
+
flags: ["depth", "order", "limit", "after", "as-role"],
|
|
935
|
+
args: [artifactArg, optionalArg("prefix", "Path prefix.")],
|
|
936
|
+
async run(flags, artifact, prefix) {
|
|
937
|
+
printJson(
|
|
938
|
+
await listDocuments({
|
|
939
|
+
artifact,
|
|
940
|
+
prefix,
|
|
941
|
+
depth: flags.depth,
|
|
942
|
+
order: flags.order,
|
|
943
|
+
limit: flags.limit,
|
|
944
|
+
after: flags.after,
|
|
945
|
+
asRole: flags["as-role"]
|
|
946
|
+
})
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
}),
|
|
950
|
+
"data set": command({
|
|
951
|
+
brief: "Replace or create a stored document",
|
|
952
|
+
usage: ["<artifact> <path> --value <json|file|->"],
|
|
953
|
+
flags: ["value", "if-match", "if-absent", "idempotency-key"],
|
|
954
|
+
args: [artifactArg, arg("path", "Document path.")],
|
|
955
|
+
async run(flags, artifact, path) {
|
|
956
|
+
printJson(
|
|
957
|
+
await onConflict(
|
|
958
|
+
() => setDocument({
|
|
959
|
+
artifact,
|
|
960
|
+
path,
|
|
961
|
+
value: flags.value,
|
|
962
|
+
ifMatch: flags["if-match"],
|
|
963
|
+
ifAbsent: flags["if-absent"],
|
|
964
|
+
idempotencyKey: flags["idempotency-key"]
|
|
965
|
+
}),
|
|
966
|
+
() => dataConflictActions(artifact, path)
|
|
967
|
+
)
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
}),
|
|
971
|
+
"data update": command({
|
|
972
|
+
brief: "Deep-merge a stored document",
|
|
973
|
+
usage: ["<artifact> <path> --patch <json|file|->"],
|
|
974
|
+
flags: ["patch", "if-match", "if-absent", "idempotency-key"],
|
|
975
|
+
args: [artifactArg, arg("path", "Document path.")],
|
|
976
|
+
async run(flags, artifact, path) {
|
|
977
|
+
printJson(
|
|
978
|
+
await onConflict(
|
|
979
|
+
() => updateDocument({
|
|
980
|
+
artifact,
|
|
981
|
+
path,
|
|
982
|
+
patch: flags.patch,
|
|
983
|
+
ifMatch: flags["if-match"],
|
|
984
|
+
ifAbsent: flags["if-absent"],
|
|
985
|
+
idempotencyKey: flags["idempotency-key"]
|
|
986
|
+
}),
|
|
987
|
+
() => dataConflictActions(artifact, path)
|
|
988
|
+
)
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
}),
|
|
992
|
+
"data delete": command({
|
|
993
|
+
brief: "Delete a stored document",
|
|
994
|
+
usage: ["<artifact> <path>"],
|
|
995
|
+
flags: ["if-match", "idempotency-key"],
|
|
996
|
+
args: [artifactArg, arg("path", "Document path.")],
|
|
997
|
+
async run(flags, artifact, path) {
|
|
998
|
+
printJson(
|
|
999
|
+
await onConflict(
|
|
1000
|
+
() => deleteDocument({
|
|
1001
|
+
artifact,
|
|
1002
|
+
path,
|
|
1003
|
+
ifMatch: flags["if-match"],
|
|
1004
|
+
idempotencyKey: flags["idempotency-key"]
|
|
1005
|
+
}),
|
|
1006
|
+
() => dataConflictActions(artifact, path)
|
|
1007
|
+
)
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
}),
|
|
1011
|
+
"data batch": command({
|
|
1012
|
+
brief: "Apply document writes atomically",
|
|
1013
|
+
usage: ["<artifact> --ops <json|file|->"],
|
|
1014
|
+
flags: ["ops", "idempotency-key"],
|
|
1015
|
+
args: [artifactArg],
|
|
1016
|
+
async run(flags, artifact) {
|
|
1017
|
+
printJson(
|
|
1018
|
+
await batchDocuments({
|
|
1019
|
+
artifact,
|
|
1020
|
+
ops: flags.ops,
|
|
1021
|
+
idempotencyKey: flags["idempotency-key"]
|
|
1022
|
+
})
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
}),
|
|
1026
|
+
"data export": command({
|
|
1027
|
+
brief: "Export stored documents",
|
|
1028
|
+
usage: ["<artifact> [--output <path>]"],
|
|
1029
|
+
flags: ["output", "as-role"],
|
|
1030
|
+
args: [artifactArg],
|
|
1031
|
+
async run(flags, artifact) {
|
|
1032
|
+
const exported = await exportDocuments({
|
|
1033
|
+
artifact,
|
|
1034
|
+
asRole: flags["as-role"]
|
|
1035
|
+
});
|
|
1036
|
+
const output = flags.output;
|
|
1037
|
+
if (output) {
|
|
1038
|
+
await writeFile(output, exported.ndjson);
|
|
1039
|
+
} else {
|
|
1040
|
+
process.stdout.write(exported.ndjson);
|
|
1041
|
+
}
|
|
1042
|
+
const { count, privateLeftOut } = exported;
|
|
1043
|
+
console.error(
|
|
1044
|
+
`Exported ${count} document${count === 1 ? "" : "s"}${output ? ` to ${output}` : ""}${privateLeftOut === null ? "" : `; ${privateLeftOut} in private subtrees left out`}.`
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
}),
|
|
1048
|
+
"data usage": command({
|
|
1049
|
+
brief: "Show document storage usage",
|
|
1050
|
+
usage: ["<artifact>"],
|
|
1051
|
+
flags: [],
|
|
1052
|
+
args: [artifactArg],
|
|
1053
|
+
async run(flags, artifact) {
|
|
1054
|
+
printJson(await getDataUsage({ artifact }));
|
|
1055
|
+
}
|
|
1056
|
+
}),
|
|
1057
|
+
"asset upload": command({
|
|
1058
|
+
brief: "Upload an asset",
|
|
1059
|
+
usage: ["<artifact> <file>"],
|
|
1060
|
+
flags: ["name", "content-type"],
|
|
1061
|
+
args: [artifactArg, arg("file", "File to upload.")],
|
|
1062
|
+
async run(flags, artifact, file) {
|
|
1063
|
+
printJson(
|
|
1064
|
+
await uploadAsset({
|
|
1065
|
+
artifact,
|
|
1066
|
+
file,
|
|
1067
|
+
name: flags.name,
|
|
1068
|
+
contentType: flags["content-type"]
|
|
1069
|
+
})
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
}),
|
|
1073
|
+
"asset list": command({
|
|
1074
|
+
brief: "List assets",
|
|
1075
|
+
usage: ["<artifact>"],
|
|
1076
|
+
flags: [],
|
|
1077
|
+
args: [artifactArg],
|
|
1078
|
+
async run(flags, artifact) {
|
|
1079
|
+
printJson(await listAssets({ artifact }));
|
|
1080
|
+
}
|
|
1081
|
+
}),
|
|
1082
|
+
"asset get": command({
|
|
1083
|
+
brief: "Read asset metadata or download bytes",
|
|
1084
|
+
usage: ["<artifact> <asset-id> [--output <path>]"],
|
|
1085
|
+
flags: ["output"],
|
|
1086
|
+
args: [artifactArg, arg("asset-id", "Asset id.")],
|
|
1087
|
+
async run(flags, artifact, assetId) {
|
|
1088
|
+
const input = { artifact, assetId };
|
|
1089
|
+
const output = flags.output;
|
|
1090
|
+
if (!output) return printJson(await getAsset(input));
|
|
1091
|
+
const { bytes } = await downloadAsset({ ...input, output });
|
|
1092
|
+
console.error(`Wrote ${bytes} bytes to ${output}.`);
|
|
1093
|
+
}
|
|
1094
|
+
}),
|
|
1095
|
+
"asset rm": command({
|
|
1096
|
+
brief: "Remove an asset",
|
|
1097
|
+
usage: ["<artifact> <asset-id>"],
|
|
1098
|
+
flags: [],
|
|
1099
|
+
args: [artifactArg, arg("asset-id", "Asset id.")],
|
|
1100
|
+
async run(flags, artifact, assetId) {
|
|
1101
|
+
await removeAsset({ artifact, assetId });
|
|
1102
|
+
console.error(`Deleted asset ${assetId}.`);
|
|
1103
|
+
}
|
|
1104
|
+
})
|
|
1105
|
+
};
|
|
1106
|
+
function onAuthFailure(host, run) {
|
|
1107
|
+
return run().catch((error) => {
|
|
1108
|
+
throw withRecovery(error, exitCodes.auth, () => signInActions(host));
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
async function onConflict(write, recovery) {
|
|
1112
|
+
try {
|
|
1113
|
+
return await write();
|
|
1114
|
+
} catch (error) {
|
|
1115
|
+
throw withRecovery(error, exitCodes.revisionConflict, recovery);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
function printPolicy(policy) {
|
|
1119
|
+
console.log(`Declared: ${JSON.stringify(policy.declaredCapabilities)}`);
|
|
1120
|
+
console.log(`Served: ${JSON.stringify(policy.capabilities)}`);
|
|
1121
|
+
console.log(`Page epoch: ${policy.pageEpoch}`);
|
|
1122
|
+
}
|
|
1123
|
+
var groupDocs = {
|
|
1124
|
+
artifact: "List, read and manage artifacts",
|
|
1125
|
+
capabilities: "Manage page capability policy",
|
|
1126
|
+
annotation: "Manage feedback annotations",
|
|
1127
|
+
data: "Manage stored documents",
|
|
1128
|
+
asset: "Manage artifact assets"
|
|
1129
|
+
};
|
|
1130
|
+
var commandEntries = Object.entries(
|
|
1131
|
+
commandSpecs
|
|
1132
|
+
).map(([route, build]) => build(route));
|
|
1133
|
+
var commandRoutes = new Set(
|
|
1134
|
+
commandEntries.map((entry) => entry.route)
|
|
1135
|
+
);
|
|
1136
|
+
function buildTree() {
|
|
1137
|
+
const top = {};
|
|
1138
|
+
const groups = {};
|
|
1139
|
+
for (const entry of commandEntries) {
|
|
1140
|
+
const [group, leaf] = entry.route.split(" ");
|
|
1141
|
+
if (leaf === void 0) top[group] = entry.command;
|
|
1142
|
+
else (groups[group] ??= []).push(entry);
|
|
1143
|
+
}
|
|
1144
|
+
for (const [group, entries] of Object.entries(groups)) {
|
|
1145
|
+
const brief = groupDocs[group];
|
|
1146
|
+
if (!brief) throw new Error(`No docs for command group ${group}.`);
|
|
1147
|
+
top[group] = buildRouteMap({
|
|
1148
|
+
routes: Object.fromEntries(
|
|
1149
|
+
entries.map((entry) => [entry.route.split(" ")[1], entry.command])
|
|
1150
|
+
),
|
|
1151
|
+
docs: {
|
|
1152
|
+
brief,
|
|
1153
|
+
hideRoute: Object.fromEntries(
|
|
1154
|
+
entries.filter((entry) => entry.hidden).map((entry) => [entry.route.split(" ")[1], true])
|
|
1155
|
+
)
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
return buildRouteMap({
|
|
1160
|
+
routes: top,
|
|
1161
|
+
docs: {
|
|
1162
|
+
brief: "Host, share, and collaborate on AI-generated artifacts. Run artis <command> -h for details; artis help --all for the full reference."
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
var commandTree = buildTree();
|
|
1167
|
+
var exitCodesHelp = `Exit codes:
|
|
1168
|
+
0 success, 1 error, 2 usage, 3 auth, 4 not found (data get: no document at the path), 5 conflict (a revision, or a data document's version: re-read, reapply, retry), 6 watch timeout, 7 rate limited, 8 verify found problems.`;
|
|
1169
|
+
var examplesHelp = `Server: commands use the one \`artis login\` signed in to last (${ARTIS_DEFAULT_HOST} by default); \`artis login --host <url>\` switches.
|
|
1170
|
+
|
|
1171
|
+
Examples:
|
|
1172
|
+
|
|
1173
|
+
artis login
|
|
1174
|
+
artis login --host https://artis.example.com
|
|
1175
|
+
artis publish report.html --visibility private
|
|
1176
|
+
artis share 4kq9Zt2LmX8vRbP3nWc7Hy --email reviewer@example.com --role commenter
|
|
1177
|
+
artis artifact get 4kq9Zt2LmX8vRbP3nWc7Hy --json
|
|
1178
|
+
artis artifact files 4kq9Zt2LmX8vRbP3nWc7Hy index.html > report.html
|
|
1179
|
+
artis publish --root deck --type slides
|
|
1180
|
+
artis artifact files 4kq9Zt2LmX8vRbP3nWc7Hy --output deck
|
|
1181
|
+
artis revise 4kq9Zt2LmX8vRbP3nWc7Hy --root deck --summary "Fix the cover slide"
|
|
1182
|
+
artis verify report.html
|
|
1183
|
+
artis verify --root deck --type slides
|
|
1184
|
+
artis artifact feedback 4kq9Zt2LmX8vRbP3nWc7Hy --json
|
|
1185
|
+
artis annotate 4kq9Zt2LmX8vRbP3nWc7Hy --comment "Tighten this heading" --quote "Checkout latency" --requested-change "Add the affected checkout count"
|
|
1186
|
+
artis reply annotation-123 --comment "Addressed in the latest revision"
|
|
1187
|
+
artis watch 4kq9Zt2LmX8vRbP3nWc7Hy --since 42
|
|
1188
|
+
artis guidelines authoring
|
|
1189
|
+
artis types slides
|
|
1190
|
+
artis install-skill --yes`;
|
|
1191
|
+
function getCliHelp() {
|
|
1192
|
+
const visible = commandEntries.filter((entry) => !entry.hidden);
|
|
1193
|
+
const usage = visible.flatMap(
|
|
1194
|
+
(entry) => entry.usage.map((line, index) => {
|
|
1195
|
+
const command2 = ` artis ${entry.route} ${line}`.trimEnd();
|
|
1196
|
+
return index === 0 ? `${command2.padEnd(56)} ${entry.brief}` : command2;
|
|
1197
|
+
})
|
|
1198
|
+
);
|
|
1199
|
+
const names = [...new Set(visible.flatMap((entry) => entry.flags))];
|
|
1200
|
+
const options = names.filter((name) => !flagCatalog[name].hidden).map((name) => {
|
|
1201
|
+
const flag = flagCatalog[name];
|
|
1202
|
+
const label = flag.kind === "parsed" ? `--${name} <${flag.placeholder}>` : `--${name}`;
|
|
1203
|
+
return ` ${label.padEnd(36)} ${flag.brief}`;
|
|
1204
|
+
});
|
|
1205
|
+
return [
|
|
1206
|
+
"artis",
|
|
1207
|
+
"",
|
|
1208
|
+
"Host, share, and collaborate on AI-generated artifacts.",
|
|
1209
|
+
"",
|
|
1210
|
+
"Usage:",
|
|
1211
|
+
" artis --version",
|
|
1212
|
+
...usage,
|
|
1213
|
+
"",
|
|
1214
|
+
"Options:",
|
|
1215
|
+
...options,
|
|
1216
|
+
"",
|
|
1217
|
+
exitCodesHelp,
|
|
1218
|
+
"",
|
|
1219
|
+
examplesHelp
|
|
1220
|
+
].join("\n");
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
export {
|
|
1224
|
+
valueFlags,
|
|
1225
|
+
commandEntries,
|
|
1226
|
+
commandRoutes,
|
|
1227
|
+
commandTree,
|
|
1228
|
+
getCliHelp
|
|
1229
|
+
};
|