@artis-lab/cli 0.14.0 → 0.15.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.
@@ -1,2420 +0,0 @@
1
- import {
2
- OAuthError,
3
- pollDeviceToken,
4
- refreshTokens,
5
- revokeToken,
6
- startDeviceAuthorization
7
- } from "./chunk-43WVFZLO.js";
8
- import {
9
- getRememberedBase,
10
- rememberBase
11
- } from "./chunk-JYMG2Y6C.js";
12
- import {
13
- installSkillFromCli
14
- } from "./chunk-CT5TD6L2.js";
15
- import {
16
- VerifyUnavailableError,
17
- formatVerifyReport,
18
- verifyFiles,
19
- verifyTypes
20
- } from "./chunk-QZFIUZXT.js";
21
- import {
22
- artisCliVersion
23
- } from "./chunk-IZYFOV2K.js";
24
- import {
25
- feedbackActions,
26
- publishedActions,
27
- renderNextActions,
28
- renderResult
29
- } from "./chunk-Q5KBGVKT.js";
30
- import {
31
- hasFlag,
32
- parseFlagValue,
33
- valueFlags
34
- } from "./chunk-KJV7R7DE.js";
35
- import {
36
- ARTIS_DEFAULT_HOST,
37
- findProfileForHost,
38
- getConfigPath,
39
- normalizeHost,
40
- readCliConfig,
41
- resolveOrigin,
42
- saveDefaultProfile,
43
- updateProfileTokens,
44
- withConfigLock
45
- } from "./chunk-46DMRA3V.js";
46
- import {
47
- changedFiles,
48
- readFilesDir,
49
- writeFilesDir
50
- } from "./chunk-MEPQKMK5.js";
51
- import {
52
- CliError,
53
- exitCodeForResponse,
54
- exitCodes,
55
- usageError
56
- } from "./chunk-H32QAUSA.js";
57
-
58
- // packages/cli/src/lib/cli.ts
59
- import { spawn } from "node:child_process";
60
- import { readFile, writeFile } from "node:fs/promises";
61
- import { basename, extname } from "node:path";
62
-
63
- // packages/api-contract/src/client.ts
64
- var htmlUploadContentType = "text/html; charset=utf-8";
65
- var ApiError = class extends Error {
66
- constructor(status, code, message, body, headers) {
67
- super(message);
68
- this.status = status;
69
- this.code = code;
70
- this.body = body;
71
- this.name = "ApiError";
72
- const retryAfter = Number(headers?.get("retry-after"));
73
- this.retryAfter = Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter : void 0;
74
- }
75
- };
76
- function appendQuery(query, name, value) {
77
- if (value === void 0 || value === null) {
78
- return;
79
- }
80
- if (Array.isArray(value)) {
81
- for (const item of value) appendQuery(query, name, item);
82
- return;
83
- }
84
- query.append(
85
- name,
86
- typeof value === "object" ? JSON.stringify(value) : String(value)
87
- );
88
- }
89
- function buildRequest(baseUrl, key, input = {}) {
90
- const space = key.indexOf(" ");
91
- const method = key.slice(0, space);
92
- const path = key.slice(space + 1).replace(/\{([^}]+)\}/g, (_, name) => {
93
- const value = input.params?.[name];
94
- if (value === void 0) {
95
- throw new Error(`${key}: missing path parameter ${name}`);
96
- }
97
- return encodeURIComponent(value);
98
- });
99
- const query = new URLSearchParams();
100
- for (const [name, value] of Object.entries(input.query ?? {})) {
101
- appendQuery(query, name, value);
102
- }
103
- const search = query.toString();
104
- const headers = {};
105
- let body;
106
- if (typeof Blob !== "undefined" && input.body instanceof Blob) {
107
- headers["content-type"] = "application/octet-stream";
108
- body = input.body;
109
- } else if (typeof input.body === "string" || input.body instanceof Uint8Array) {
110
- const bytes = typeof input.body === "string" ? new TextEncoder().encode(input.body) : input.body;
111
- headers["content-type"] = htmlUploadContentType;
112
- headers["content-length"] = String(bytes.byteLength);
113
- body = bytes;
114
- } else if (input.body !== void 0) {
115
- headers["content-type"] = "application/json";
116
- body = JSON.stringify(input.body);
117
- }
118
- return {
119
- url: `${baseUrl.replace(/\/+$/, "")}${path}${search ? `?${search}` : ""}`,
120
- init: {
121
- method,
122
- headers: { ...headers, ...input.headers },
123
- ...body === void 0 ? {} : { body }
124
- }
125
- };
126
- }
127
- async function readBody(response) {
128
- if (/^application\/octet-stream\b/i.test(
129
- response.headers.get("content-type") ?? ""
130
- )) {
131
- return new Uint8Array(await response.arrayBuffer());
132
- }
133
- const text = await response.text();
134
- if (!text) {
135
- return void 0;
136
- }
137
- const type = response.headers.get("content-type") ?? "";
138
- if (!/json/i.test(type)) {
139
- return text;
140
- }
141
- try {
142
- return JSON.parse(text);
143
- } catch {
144
- return text;
145
- }
146
- }
147
- function errorOf(response, body) {
148
- const record = body && typeof body === "object" && !Array.isArray(body) ? body : void 0;
149
- const message = typeof record?.["error"] === "string" ? record["error"] : `Request failed with ${response.status}.`;
150
- const code = typeof record?.["code"] === "string" ? record["code"] : "http_error";
151
- return new ApiError(response.status, code, message, record, response.headers);
152
- }
153
- function createApiClient(options) {
154
- const fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);
155
- async function send(key, input = {}) {
156
- const { url, init } = buildRequest(
157
- options.baseUrl,
158
- key,
159
- input
160
- );
161
- const headers = init.headers;
162
- for (const [name, value] of Object.entries(options.headers ?? {})) {
163
- headers[name.toLowerCase()] ??= value;
164
- }
165
- if (options.auth && options.auth !== "cookie") {
166
- headers["authorization"] = `Bearer ${options.auth.bearer}`;
167
- }
168
- const response = await fetchImpl(url, {
169
- ...init,
170
- ...options.auth === "cookie" ? { credentials: "include" } : {},
171
- ...input["signal"] ? { signal: input["signal"] } : {}
172
- });
173
- const body = await readBody(response);
174
- if (!response.ok) {
175
- throw errorOf(response, body);
176
- }
177
- return { status: response.status, body, headers: response.headers };
178
- }
179
- return {
180
- send,
181
- call: (async (key, input) => (await send(key, input)).body),
182
- withAuth: (auth) => createApiClient({ ...options, auth })
183
- };
184
- }
185
-
186
- // packages/sdk/src/lib/annotation.ts
187
- function annotationIdFromIri(iri) {
188
- return iri.replace(/\/+$/, "").split("/").pop() ?? iri;
189
- }
190
-
191
- // packages/sdk/src/lib/agent-handoff.ts
192
- function isReviewClosed(status) {
193
- return status === "resolved";
194
- }
195
-
196
- // packages/sdk/src/lib/sdk.ts
197
- var artifactShareRoles = [
198
- "viewer",
199
- "commenter",
200
- "contributor",
201
- "editor"
202
- ];
203
- var artifactListLimits = { default: 50, max: 100 };
204
- function formatRevisionConflictMessage(message, details) {
205
- if (!details?.currentRevisionId) {
206
- return message;
207
- }
208
- let text = `${message} Current revision: ${details.currentRevisionId}.`;
209
- if (typeof details.currentVersion === "number") {
210
- const [firstLine] = revisionSummaryLines(details.currentSummary ?? "");
211
- text += firstLine ? ` Version ${details.currentVersion}: ${firstLine}` : ` Version ${details.currentVersion}.`;
212
- }
213
- return text;
214
- }
215
- function revisionSummaryLines(summary) {
216
- return summary.split(/\r?\n/).map((line) => line.replace(/^\s*(?:[-*•]\s+)?/, "").trim()).filter(Boolean);
217
- }
218
-
219
- // packages/sdk/src/lib/page-storage.ts
220
- var storageLimits = {
221
- /** One document, serialized as UTF-8 JSON. */
222
- maxDocBytes: 256 * 1024,
223
- /** A document on a `{viewer}` path, unless its rule raises `maxBytes`. */
224
- maxViewerDocBytes: 16 * 1024,
225
- maxDepth: 32,
226
- maxPathBytes: 512,
227
- maxSegments: 16,
228
- maxSegmentBytes: 128,
229
- maxArtifactDocuments: 25e3,
230
- maxArtifactBytes: 16 * 1024 * 1024,
231
- maxOwnerBytes: 256 * 1024 * 1024,
232
- maxRules: 64,
233
- maxBatchOps: 50,
234
- /** Sum of the serialized values and patches in one batch. */
235
- maxBatchBytes: 1024 * 1024,
236
- maxListLimit: 1e3,
237
- idempotencyTtlMs: 24 * 60 * 60 * 1e3
238
- };
239
- var encoder = new TextEncoder();
240
- var storageOnlyCodes = /* @__PURE__ */ new Set([
241
- "version_conflict",
242
- "capability_not_declared",
243
- "rules_changed",
244
- "quota_exceeded",
245
- "too_large",
246
- "invalid_path",
247
- "invalid_value",
248
- "idempotency_in_progress",
249
- "idempotency_key_used",
250
- "idempotency_key_reused"
251
- ]);
252
- function formatStorageErrorMessage(message, body) {
253
- if (!body) return message;
254
- const storageCode = typeof body["code"] === "string" && storageOnlyCodes.has(body["code"]);
255
- const details = [];
256
- if (typeof body["code"] === "string") details.push(`code ${body["code"]}`);
257
- if (typeof body["index"] === "number")
258
- details.push(`write #${body["index"]}`);
259
- if (typeof body["path"] === "string") details.push(`path ${body["path"]}`);
260
- if (body["current"]) {
261
- details.push(`current ${JSON.stringify(body["current"])}`);
262
- }
263
- if (body["quota"]) details.push(`quota ${JSON.stringify(body["quota"])}`);
264
- return storageCode || details.length > 1 ? `${message} (${details.join("; ")})` : message;
265
- }
266
-
267
- // packages/sdk/src/lib/ids.ts
268
- var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
269
- function isUuid(value) {
270
- return typeof value === "string" && UUID_PATTERN.test(value);
271
- }
272
- var BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
273
- var SHORT_ID_LENGTH = 22;
274
- function artifactShortId(id) {
275
- if (!isUuid(id)) throw new Error(`Not a uuid: ${id}`);
276
- const hex = id.replace(/-/g, "");
277
- const bytes = [];
278
- for (let i = 0; i < 32; i += 2) bytes.push(parseInt(hex.slice(i, i + 2), 16));
279
- let out = "";
280
- for (let digit = 0; digit < SHORT_ID_LENGTH; digit += 1) {
281
- let remainder = 0;
282
- for (let i = 0; i < bytes.length; i += 1) {
283
- const value = remainder * 256 + bytes[i];
284
- bytes[i] = Math.floor(value / 62);
285
- remainder = value % 62;
286
- }
287
- out = BASE62[remainder] + out;
288
- }
289
- return out;
290
- }
291
- function artifactIdFromShortId(value) {
292
- if (value.length !== SHORT_ID_LENGTH) return void 0;
293
- const bytes = new Array(16).fill(0);
294
- for (const char of value) {
295
- const digit = BASE62.indexOf(char);
296
- if (digit < 0) return void 0;
297
- let carry = digit;
298
- for (let i = 15; i >= 0; i -= 1) {
299
- const next = bytes[i] * 62 + carry;
300
- bytes[i] = next % 256;
301
- carry = Math.floor(next / 256);
302
- }
303
- if (carry !== 0) return void 0;
304
- }
305
- const hex = bytes.map((byte) => byte.toString(16).padStart(2, "0")).join("");
306
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
307
- }
308
- function artifactIdFromReference(reference) {
309
- const value = reference.trim();
310
- if (isUuid(value)) return value;
311
- const short = artifactIdFromShortId(value);
312
- if (short) return short;
313
- let url;
314
- try {
315
- url = new URL(value);
316
- } catch {
317
- return void 0;
318
- }
319
- const page = /^\/a\/([0-9A-Za-z]+)\/?$/.exec(url.pathname);
320
- if (page) return artifactIdFromShortId(page[1]);
321
- const label = url.hostname.split(".")[0];
322
- return isUuid(label) ? label : void 0;
323
- }
324
-
325
- // packages/cli/src/lib/cli.ts
326
- function isRootAnnotation(annotation) {
327
- return annotation.motivation === "commenting";
328
- }
329
- async function readHtmlUpload(filePath, what) {
330
- const bytes = await readFile(filePath);
331
- if (!/<html/i.test(bytes.toString("latin1"))) {
332
- throw new Error(`${what} must be self-contained HTML including <html>.`);
333
- }
334
- return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
335
- }
336
- var commands = [
337
- "annotate",
338
- "annotation",
339
- "artifact",
340
- "asset",
341
- "capabilities",
342
- "data",
343
- "guidelines",
344
- "help",
345
- "install-skill",
346
- "login",
347
- "publish",
348
- "reply",
349
- "revise",
350
- "share",
351
- "types",
352
- "version",
353
- "watch",
354
- "whoami"
355
- ];
356
- var cliVisibilityOptions = ["public", "unlisted", "private"];
357
- var cliAnnotationStatusOptions = ["open", "resolved"];
358
- function getPositionals(args) {
359
- const positionals = [];
360
- for (let index = 0; index < args.length; index += 1) {
361
- const arg = args[index];
362
- if (arg.startsWith("-")) {
363
- if (valueFlags.has(arg)) {
364
- index += 1;
365
- }
366
- continue;
367
- }
368
- positionals.push(arg);
369
- }
370
- return positionals;
371
- }
372
- function inferTitleFromPath(filePath) {
373
- const fileName = basename(filePath);
374
- const extension = extname(fileName);
375
- return extension ? fileName.slice(0, -extension.length) : fileName;
376
- }
377
- function parseVisibility(value) {
378
- if (cliVisibilityOptions.includes(value)) {
379
- return value;
380
- }
381
- throw usageError(
382
- `Invalid visibility "${value}". Expected one of: ${cliVisibilityOptions.join(", ")}`
383
- );
384
- }
385
- async function parseCapabilitiesFlag(value, flag = "--capabilities") {
386
- if (value === void 0) {
387
- return void 0;
388
- }
389
- let source = value;
390
- if (!value.trim().startsWith("{")) {
391
- try {
392
- source = await readFile(value, "utf8");
393
- } catch {
394
- throw usageError(
395
- `${flag} must be a JSON object or a path to a JSON file; could not read "${value}".`
396
- );
397
- }
398
- }
399
- let parsed;
400
- try {
401
- parsed = JSON.parse(source);
402
- } catch {
403
- throw usageError(`${flag} is not valid JSON.`);
404
- }
405
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
406
- throw usageError(
407
- `${flag} must be a JSON object, e.g. '{"<name>":true}' ({} clears them).`
408
- );
409
- }
410
- return parsed;
411
- }
412
- function rejectRemovedContractFlag(args) {
413
- if (hasFlag(args, "--contract")) {
414
- throw usageError(
415
- "--contract was removed: there is one page contract, and every page gets the `artis` global."
416
- );
417
- }
418
- }
419
- function parseTypeFlag(value) {
420
- if (value === void 0) {
421
- return void 0;
422
- }
423
- if (!value.trim()) {
424
- throw usageError("--type must name a type, e.g. slides.");
425
- }
426
- return value.trim();
427
- }
428
- function describeType(declaration) {
429
- return declaration.type !== "html" ? `${declaration.type} (format ${declaration.typeFormat})` : void 0;
430
- }
431
- function parseAnnotationStatus(value) {
432
- if (cliAnnotationStatusOptions.includes(value)) {
433
- return value;
434
- }
435
- throw usageError(
436
- `Invalid status "${value}". Expected one of: ${cliAnnotationStatusOptions.join(", ")}`
437
- );
438
- }
439
- function parseShareRole(value) {
440
- if (artifactShareRoles.includes(value)) {
441
- return value;
442
- }
443
- throw usageError(
444
- `Invalid role "${value}". Expected one of: ${artifactShareRoles.join(", ")}`
445
- );
446
- }
447
- function parseRectSelector(value) {
448
- if (!value) {
449
- return void 0;
450
- }
451
- const parts = value.split(",").map((part) => Number(part.trim()));
452
- if (parts.length !== 2 && parts.length !== 4 || parts.some((part) => !Number.isFinite(part))) {
453
- throw usageError(
454
- `Invalid --rect "${value}". Expected "x,y" or "x,y,w,h" percentages.`
455
- );
456
- }
457
- const [x, y, width = 0, height = 0] = parts;
458
- return {
459
- type: "FragmentSelector",
460
- conformsTo: "http://www.w3.org/TR/media-frags/",
461
- value: `xywh=percent:${x},${y},${width},${height}`
462
- };
463
- }
464
- function buildAnnotationSelectors(args) {
465
- const selectors = [];
466
- const quote = parseFlagValue(args, "--quote");
467
- if (quote) {
468
- const textQuote = {
469
- type: "TextQuoteSelector",
470
- exact: quote
471
- };
472
- const prefix = parseFlagValue(args, "--quote-prefix");
473
- const suffix = parseFlagValue(args, "--quote-suffix");
474
- if (prefix) {
475
- textQuote.prefix = prefix;
476
- }
477
- if (suffix) {
478
- textQuote.suffix = suffix;
479
- }
480
- selectors.push(textQuote);
481
- }
482
- const textStart = parseFlagValue(args, "--text-start");
483
- const textEnd = parseFlagValue(args, "--text-end");
484
- if (textStart !== void 0 && textEnd !== void 0) {
485
- const start = Number(textStart);
486
- const end = Number(textEnd);
487
- if (!Number.isFinite(start) || !Number.isFinite(end)) {
488
- throw usageError("--text-start and --text-end must be numbers.");
489
- }
490
- selectors.push({ type: "TextPositionSelector", start, end });
491
- }
492
- const css = parseFlagValue(args, "--css");
493
- if (css) {
494
- selectors.push({ type: "CssSelector", value: css });
495
- }
496
- const rect = parseRectSelector(parseFlagValue(args, "--rect"));
497
- if (rect) {
498
- selectors.push(rect);
499
- }
500
- return selectors;
501
- }
502
- function resolveBaseUrl(args, config) {
503
- const host = parseFlagValue(args, "--host") || parseFlagValue(args, "--url") || process.env["ARTIS_URL"] || config?.defaultHost || ARTIS_DEFAULT_HOST;
504
- return normalizeHost(host);
505
- }
506
- var refreshMarginMs = 6e4;
507
- function needsRefresh(profile) {
508
- return profile.expiresAt !== void 0 && profile.expiresAt - refreshMarginMs <= Date.now() && Boolean(profile.refreshToken);
509
- }
510
- async function savedAccessToken(config, baseUrl) {
511
- const saved = findProfileForHost(config, baseUrl);
512
- if (!saved) return void 0;
513
- if (!needsRefresh(saved)) return saved.accessToken;
514
- return withConfigLock(async () => {
515
- const profile = findProfileForHost(await readCliConfig(), baseUrl);
516
- if (!profile) return void 0;
517
- if (!needsRefresh(profile) || !profile.refreshToken) {
518
- return profile.accessToken;
519
- }
520
- try {
521
- const tokens = await refreshTokens(baseUrl, profile.refreshToken);
522
- await updateProfileTokens(baseUrl, {
523
- accessToken: tokens.accessToken,
524
- refreshToken: tokens.refreshToken ?? profile.refreshToken,
525
- expiresAt: tokens.expiresAt
526
- });
527
- return tokens.accessToken;
528
- } catch (error) {
529
- if (error instanceof OAuthError && error.status < 500 && error.status !== 429) {
530
- return void 0;
531
- }
532
- return profile.accessToken;
533
- }
534
- });
535
- }
536
- async function resolveCredentials(args) {
537
- const config = await readCliConfig();
538
- const baseUrl = resolveBaseUrl(args, config);
539
- const accessToken = await savedAccessToken(config, baseUrl);
540
- if (!accessToken) {
541
- throw new CliError(
542
- `Not signed in to ${baseUrl}. Run "artis login --host ${baseUrl}".`,
543
- exitCodes.auth
544
- );
545
- }
546
- return { accessToken, baseUrl, origin: await resolveOrigin() };
547
- }
548
- async function resolveOptionalTarget(args) {
549
- const config = await readCliConfig();
550
- const baseUrl = resolveBaseUrl(args, config);
551
- const accessToken = await savedAccessToken(config, baseUrl);
552
- return {
553
- accessToken,
554
- baseUrl,
555
- origin: accessToken ? await resolveOrigin() : void 0
556
- };
557
- }
558
- async function guidelinesFromCli(args) {
559
- rejectRemovedContractFlag(args);
560
- const [section] = getPositionals(args);
561
- const config = await readCliConfig();
562
- const baseUrl = resolveBaseUrl(args, config);
563
- const query = new URLSearchParams({ section: section ?? "index" });
564
- const response = await fetch(`${baseUrl}/skills.md?${query.toString()}`);
565
- const text = await response.text();
566
- if (!response.ok) {
567
- throw new CliError(
568
- text.trim() || `Guidelines request failed with ${response.status}.`,
569
- exitCodeForResponse(response.status)
570
- );
571
- }
572
- process.stdout.write(text.endsWith("\n") ? text : `${text}
573
- `);
574
- }
575
- function rejectRemovedKindFlag(args) {
576
- if (hasFlag(args, "--kind")) {
577
- throw usageError(
578
- "--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."
579
- );
580
- }
581
- }
582
- function rejectRemovedResolveFlag(args) {
583
- if (hasFlag(args, "--resolve")) {
584
- throw usageError(
585
- '--resolve was removed: a revision no longer changes review status. Reply in each thread you addressed with "artis reply"; the reviewers resolve it.'
586
- );
587
- }
588
- }
589
- async function parsePublishOptions(args) {
590
- rejectRemovedKindFlag(args);
591
- rejectRemovedContractFlag(args);
592
- const [filePath] = getPositionals(args);
593
- const root = parseFlagValue(args, "--root");
594
- if (!filePath && !root) {
595
- throw usageError(
596
- "Missing artifact HTML file path (or --root <dir> for an artifact as a directory of files, e.g. a slides deck)."
597
- );
598
- }
599
- if (filePath && root) {
600
- throw usageError("Pass an HTML file or --root <dir>, not both.");
601
- }
602
- const credentials = await resolveCredentials(args);
603
- const visibility = parseVisibility(
604
- parseFlagValue(args, "--visibility") ?? "unlisted"
605
- );
606
- return {
607
- filePath,
608
- root,
609
- credentials,
610
- baseUrl: credentials.baseUrl,
611
- title: parseFlagValue(args, "--title"),
612
- description: parseFlagValue(args, "--description") ?? "Published from Artis CLI.",
613
- visibility,
614
- authorName: parseFlagValue(args, "--author") ?? "Artis CLI",
615
- capabilities: await parseCapabilitiesFlag(
616
- parseFlagValue(args, "--capabilities")
617
- ),
618
- reloadPages: hasFlag(args, "--reload-pages") || void 0,
619
- type: parseTypeFlag(parseFlagValue(args, "--type")),
620
- json: hasFlag(args, "--json")
621
- };
622
- }
623
- async function apiCallRoot(root, credentials, key, ...input) {
624
- try {
625
- return await apiClient(credentials).call(key, ...input);
626
- } catch (error) {
627
- const cliError = cliErrorOf(error, {
628
- artifact: root.artifact,
629
- root: root.dir
630
- });
631
- const issue = error instanceof ApiError && layoutIssueOf(error);
632
- if (!issue || !(cliError instanceof CliError)) throw cliError;
633
- const stray = /does not take (\S+):/.exec(issue)?.[1];
634
- let hint = stray ? ` Every file under --root is sent (dotfiles and node_modules are skipped): move ${stray} out of ${root.dir}.` : "";
635
- if (root.untyped) {
636
- hint += " Without --type the files are an html artifact; for another type, pass --type <type>, e.g. --type slides.";
637
- }
638
- throw new CliError(`${cliError.message}${hint}`, cliError.exitCode);
639
- }
640
- }
641
- function layoutIssueOf(error) {
642
- if (error.status !== 400 || error.code !== "invalid_request") {
643
- return void 0;
644
- }
645
- const issues = error.body?.["issues"];
646
- if (!Array.isArray(issues)) return void 0;
647
- for (const issue of issues) {
648
- if (!issue || typeof issue !== "object") continue;
649
- const { path, message } = issue;
650
- if ((path === "files" || path === "type") && typeof message === "string") {
651
- return message;
652
- }
653
- }
654
- return void 0;
655
- }
656
- function conflictingPathsHint(body, context = {}) {
657
- const paths = body?.["conflictingPaths"];
658
- if (body?.["code"] !== "revision_conflict" || !Array.isArray(paths) || paths.length === 0) {
659
- return "";
660
- }
661
- const artifact = context.artifact ?? "<artifact>";
662
- const recover = context.root ? `Pull the current revision into a new directory (artis artifact files ${artifact} --output <new-dir>), reapply your change there, and revise with --root <new-dir>.` : `Read the current version (artis artifact files ${artifact} ${paths.length === 1 ? paths[0] : "<path>"}), reapply your change, and revise again.`;
663
- return `Conflicting files: ${paths.join(", ")}. ${recover}`;
664
- }
665
- function cliErrorOf(error, context = {}) {
666
- if (!(error instanceof ApiError)) {
667
- return error;
668
- }
669
- let message = formatStorageErrorMessage(
670
- formatRevisionConflictMessage(error.message, error.body),
671
- error.body
672
- );
673
- const conflict = conflictingPathsHint(error.body, context);
674
- if (conflict) {
675
- message = `${message.replace(/[.\s]*$/, "")}. ${conflict}`;
676
- }
677
- if (error.status === 429 && error.retryAfter) {
678
- message += ` Retry after ${error.retryAfter} s.`;
679
- }
680
- return new CliError(message, exitCodeForResponse(error.status, error.code));
681
- }
682
- function apiClient(target) {
683
- return createApiClient({
684
- baseUrl: target.baseUrl,
685
- auth: target.accessToken ? { bearer: target.accessToken } : void 0,
686
- headers: target.accessToken && target.origin ? { "artis-origin": target.origin } : void 0
687
- });
688
- }
689
- async function apiCall(credentials, key, ...input) {
690
- try {
691
- return await apiClient(credentials).call(key, ...input);
692
- } catch (error) {
693
- throw cliErrorOf(error);
694
- }
695
- }
696
- async function apiCallOptional(target, key, ...input) {
697
- try {
698
- return await apiClient(target).call(key, ...input);
699
- } catch (error) {
700
- if (!(error instanceof ApiError) || error.status !== 401 || !target.accessToken) {
701
- throw cliErrorOf(error);
702
- }
703
- }
704
- try {
705
- const result = await apiClient({ baseUrl: target.baseUrl }).call(
706
- key,
707
- ...input
708
- );
709
- console.warn(
710
- `Saved sign-in was rejected by ${target.baseUrl}; retried without credentials. Run "artis login --host ${target.baseUrl}" to sign in again.`
711
- );
712
- return result;
713
- } catch (error) {
714
- throw cliErrorOf(error);
715
- }
716
- }
717
- function assertSafeLoginUrl(url, baseUrl) {
718
- let parsed;
719
- try {
720
- parsed = new URL(url);
721
- } catch {
722
- throw new Error("Login host returned an invalid verification URL.");
723
- }
724
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
725
- throw new Error("Login host returned an unsafe verification URL scheme.");
726
- }
727
- let expected;
728
- try {
729
- expected = new URL(baseUrl);
730
- } catch {
731
- throw new Error("Configured login host is not a valid URL.");
732
- }
733
- if (parsed.hostname !== expected.hostname || parsed.port !== expected.port) {
734
- throw new Error(
735
- "Login host returned a verification URL that does not match the configured host."
736
- );
737
- }
738
- }
739
- function openBrowser(url) {
740
- let protocol;
741
- try {
742
- protocol = new URL(url).protocol;
743
- } catch {
744
- throw new Error("Refusing to open an invalid URL in the browser.");
745
- }
746
- if (protocol !== "http:" && protocol !== "https:") {
747
- throw new Error("Refusing to open a non-http(s) URL in the browser.");
748
- }
749
- const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
750
- const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
751
- const child = spawn(command, args, {
752
- detached: true,
753
- stdio: "ignore"
754
- });
755
- child.unref();
756
- }
757
- function sleep(ms) {
758
- return new Promise((resolve) => setTimeout(resolve, ms));
759
- }
760
- function buildArtifactUrl(baseUrl, pathOrUrl) {
761
- return pathOrUrl.startsWith("http") ? pathOrUrl : `${baseUrl}${pathOrUrl}`;
762
- }
763
- function getCliHelp() {
764
- return `artis
765
-
766
- Host, share, and collaborate on AI-generated HTML artifacts.
767
-
768
- Usage:
769
- artis --version
770
- artis login [--host <url>]
771
- artis whoami [--host <url>]
772
- artis guidelines [section] [--host <url>]
773
- artis types [name [reference]] [--json] [--host <url>]
774
- artis install-skill [--harness <id>]... [--yes] [--dir <path>] [--force] [--list] [--json]
775
- artis publish artifact.html [options]
776
- artis publish --root <dir> [--type <type>] [options]
777
- artis artifact get <artifact> [--json]
778
- artis artifact files <artifact> [path] [--output <dir>] [--revision <revision-id>] [--json]
779
- artis artifact feedback <artifact> [--json] [--revision <revision-id>]
780
- artis artifact list [--query <text>] [--tag <tag>] [--type <type>] [--limit <n>] [--cursor <cursor>] [--json]
781
- artis artifact visibility <artifact> <public|unlisted|private> [--json]
782
- artis artifact delete <artifact> --yes
783
- artis verify <artifact.html | artifact> [--revision <revision-id>] [--json]
784
- artis verify --root <dir> [--type slides] [--json]
785
- artis share <artifact> [--email <email> --role <viewer|commenter|contributor|editor>] [--remove]
786
- artis revise <artifact> (artifact.html | --root <dir>) --summary <text> [--base <revision-id>] [--capabilities <json|file>] [--reload-pages] [--type <type>]
787
- artis capabilities show <artifact> [--json]
788
- artis capabilities set <artifact> <json|file> [--reload-pages] [--json]
789
- artis annotate <artifact> --comment <text> [anchor options]
790
- artis reply <annotation-id> --comment <text>
791
- artis annotation edit <annotation-id> [--comment <text>] [--title <text>] [--requested-change <text>]
792
- artis annotation retract <annotation-id>
793
- artis watch <artifact> [--since <cursor>] [--once] [--timeout <duration>] [--self origin|client|none] [--types <families>]
794
- artis data get <artifact> <path> [--as-role <role>]
795
- artis data list <artifact> [prefix] [--depth children|all] [--order path|created] [--limit <n>] [--after <next>] [--as-role <role>]
796
- artis data set <artifact> <path> --value <json|file|-> [--if-match <id>@<version> | --if-absent] [--idempotency-key <key>]
797
- artis data update <artifact> <path> --patch <json|file|-> [--if-match <id>@<version> | --if-absent] [--idempotency-key <key>]
798
- artis data delete <artifact> <path> [--if-match <id>@<version>] [--idempotency-key <key>]
799
- artis data batch <artifact> --ops <json|file|-> [--idempotency-key <key>]
800
- artis data export <artifact> [--output <path>] [--as-role <role>]
801
- artis data usage <artifact>
802
- artis asset upload <artifact> <file> [--name <name>] [--content-type <type>]
803
- artis asset list <artifact>
804
- artis asset get <artifact> <asset-id> [--output <path>]
805
- artis asset rm <artifact> <asset-id>
806
-
807
- Options:
808
- --host, --url <url> Artis server URL. Falls back to ARTIS_URL, then a saved login, then https://artis.xiispace.eu.org.
809
- --title <title> Artifact title. Defaults to the file name.
810
- --description <text> Artifact description.
811
- --visibility <value> public, unlisted, or private. Defaults to unlisted.
812
- --type <type> The type the artifact is created with, e.g. slides (publish, revise, verify; artifact list keeps your artifacts of that type). It is fixed at publish: revise keeps it, and may only repeat it. Verify of a published artifact reads it from the revision.
813
- --author <name> Artifact author/agent name. Defaults to Artis CLI.
814
- --summary <text> Revision summary. Write one change per line; they render as a list.
815
- --base <revision-id> Revision the file was edited from. Defaults to the revision this machine last published, read whole (artifact files --output, or an html artifact's index.html), or revised. Refuses the revise if someone revised since.
816
- --capabilities <json|file> Page capabilities as a JSON object or JSON file (publish, revise). They belong to the artifact, not the revision: revise keeps them without it; '{}' clears them.
817
- --reload-pages Make open pages reload (revise, capabilities set), e.g. when stored data changes shape. A revise that leaves the capabilities alone does not interrupt open pages without it.
818
- --comment <text> Annotation or reply comment text (annotate, reply).
819
- --requested-change <text> Structured change request for the artifact author (annotate).
820
- --status <value> Annotation status: open or resolved. Defaults to open.
821
- --quote <text> Exact artifact text to anchor to (annotate, TextQuoteSelector).
822
- --quote-prefix <text> Text just before --quote, to disambiguate repeats.
823
- --quote-suffix <text> Text just after --quote, to disambiguate repeats.
824
- --css <selector> CSS selector to anchor to (annotate, CssSelector).
825
- --text-start <n> Document offset where the quote starts (annotate, TextPositionSelector).
826
- --text-end <n> Document offset where the quote ends (annotate, TextPositionSelector).
827
- --rect <x,y,w,h> Canvas point/rect as percentages (annotate, FragmentSelector). w,h default to 0.
828
- --pin-label <text> Short label shown on the artifact canvas pin (annotate).
829
- --output <path> Write every file of the revision under this directory, downloaded in parallel (artifact files).
830
- --root <dir> An artifact as a directory of files, any type (an html artifact is one file, index.html): publish every file under it, or revise with only the ones that differ from the base revision (files gone from it are removed). The type checks the files, so keep anything else (notes, a README) out of it. Dotfiles and node_modules are skipped. verify serves the files at the paths usercontent serves them at.
831
- --revision <revision-id> Revision to read (artifact files, artifact feedback). Defaults to the current revision.
832
- --query <text> Text to find in your artifacts' titles and descriptions (artifact list).
833
- --tag <tag> Only your artifacts carrying this tag (artifact list).
834
- --limit <n> Artifacts per page, 1-100 (artifact list). Defaults to 50.
835
- --cursor <cursor> Continue after the page that printed it (artifact list).
836
- --email <email> Email address for artis share.
837
- --role <role> Share role: viewer, commenter, contributor or editor. Defaults to viewer.
838
- --remove Remove the email from an artifact share list.
839
- --harness <id> Agent harness to install the artis skill into (install-skill). Repeatable: claude-code, cursor, codex, openclaw, pi, hermes.
840
- --yes Install the skill into every detected harness (install-skill); confirm a delete (artifact delete).
841
- --dir <path> Install the skill into a custom skills directory (install-skill).
842
- --force Overwrite an already-installed skill (install-skill).
843
- --list List harnesses, detection, and install paths (install-skill).
844
- --since <cursor> Feedback cursor to watch from (watch). Defaults to now; 0 replays every event.
845
- --once Exit after the first batch of events, printed as {events, cursor} (watch).
846
- --timeout <duration> Give up after this long, e.g. 30s, 10m (watch). Exits 6 if nothing happened.
847
- --self <scope> Which of your own events to leave out (watch): origin (default) leaves out this machine's, client those of every machine signed in with the CLI, none leaves out nothing. --include-self is --self none. The origin is ARTIS_ORIGIN, else one generated per machine.
848
- --types <families> Only these event families, comma-separated: annotation, revision, page, policy (watch). Defaults to all.
849
- --value <json|file|-> The whole document, a JSON object: inline, a file, or - for stdin (data set).
850
- --patch <json|file|-> A JSON object deep-merged into the document (data update).
851
- --ops <json|file|-> Writes for data batch: [{"op":"set","path":"...","value":{...}}, ...] or {"ops":[...]}.
852
- --if-match <id>@<version> Write only if this document is still at this version (data set, update, delete).
853
- --if-absent Write only if nothing is at the path, a claim (data set, update).
854
- --idempotency-key <key> Make a data write safe to retry: the same key and body within 24 h replays the first result.
855
- --as-role <role> Read data as a lower role (viewer, commenter, contributor) to check your path rules.
856
- --depth <children|all> data list: direct children only, or the whole subtree (default).
857
- --order <path|created> data list order. Defaults to path.
858
- --after <next> data list: continue after the page that printed this next.
859
- --json Print machine-readable JSON for supported commands.
860
-
861
- Exit codes:
862
- 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.
863
-
864
- Examples (--host is optional; without it commands target https://artis.xiispace.eu.org):
865
- artis publish report.html
866
- artis login
867
- artis publish report.html --host https://artis.example.com --visibility private
868
- artis share 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --email reviewer@example.com --role commenter
869
- artis artifact get 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --json
870
- artis artifact files 4kq9Zt2LmX8vRbP3nWc7Hy index.html > report.html
871
- artis publish --root deck --type slides
872
- artis artifact files 4kq9Zt2LmX8vRbP3nWc7Hy --output deck
873
- artis revise 4kq9Zt2LmX8vRbP3nWc7Hy --root deck --summary "Fix the cover slide"
874
- artis verify report.html
875
- artis verify --root deck --type slides
876
- artis artifact feedback 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --json
877
- artis annotate 4kq9Zt2LmX8vRbP3nWc7Hy --host https://artis.example.com --comment "Tighten this heading" --quote "Checkout latency" --requested-change "Add the affected checkout count"
878
- artis reply annotation-123 --host https://artis.example.com --comment "Addressed in the latest revision"
879
- artis annotation edit annotation-123 --host https://artis.example.com --comment "Corrected: the latency spike is on checkout, not search"
880
- artis annotation retract annotation-123 --host https://artis.example.com
881
- artis watch 4kq9Zt2LmX8vRbP3nWc7Hy --since 42
882
- artis guidelines authoring
883
- artis types slides
884
- artis install-skill --yes
885
- artis revise 4kq9Zt2LmX8vRbP3nWc7Hy report.html --host https://artis.example.com --summary "Addressed open feedback" --base <revision-id>`;
886
- }
887
- async function publishArtifactFromCli(args) {
888
- const options = await parsePublishOptions(args);
889
- const credentials = options.credentials;
890
- const source = options.root ?? options.filePath ?? "";
891
- const title = options.title ?? inferTitleFromPath(source);
892
- const query = {
893
- title,
894
- description: options.description,
895
- visibility: options.visibility,
896
- authorName: options.authorName,
897
- source: "cli",
898
- capabilities: options.capabilities,
899
- reloadPages: options.reloadPages,
900
- type: options.type
901
- };
902
- let result;
903
- if (options.root) {
904
- const files = await readFilesDir(options.root);
905
- ({ result } = await apiCallRoot(
906
- { dir: options.root, untyped: !options.type },
907
- credentials,
908
- "POST /api/artifacts",
909
- { query, body: { files } }
910
- ));
911
- } else {
912
- const html = await readHtmlUpload(source, "Artifact file");
913
- ({ result } = await apiCall(credentials, "POST /api/artifacts", {
914
- query,
915
- body: html
916
- }));
917
- }
918
- await rememberBase(options.baseUrl, [result.artifactId], result.revisionId);
919
- return {
920
- artifactId: result.artifactId,
921
- revisionId: result.revisionId,
922
- title,
923
- url: buildArtifactUrl(options.baseUrl, result.url),
924
- visibility: options.visibility,
925
- type: result.type,
926
- typeFormat: result.typeFormat
927
- };
928
- }
929
- async function loginFromCli(args) {
930
- const config = await readCliConfig();
931
- const baseUrl = resolveBaseUrl(args, config);
932
- let login;
933
- try {
934
- login = await startDeviceAuthorization(baseUrl);
935
- } catch (error) {
936
- throw loginErrorOf(error, baseUrl);
937
- }
938
- const verificationUrl = login.verificationUriComplete ?? login.verificationUri;
939
- assertSafeLoginUrl(verificationUrl, baseUrl);
940
- console.log(`Opening ${verificationUrl}`);
941
- console.log(`Code: ${login.userCode}`);
942
- try {
943
- openBrowser(verificationUrl);
944
- } catch {
945
- console.log("Could not open a browser automatically.");
946
- }
947
- let intervalMs = Math.max(login.interval, 1) * 1e3;
948
- const expiresAt = Date.now() + login.expiresIn * 1e3;
949
- while (Date.now() < expiresAt) {
950
- await sleep(intervalMs);
951
- let poll;
952
- try {
953
- poll = await pollDeviceToken(baseUrl, login.deviceCode);
954
- } catch (error) {
955
- throw loginErrorOf(error, baseUrl);
956
- }
957
- if (poll.status === "pending") {
958
- continue;
959
- }
960
- if (poll.status === "slow_down") {
961
- intervalMs += 5e3;
962
- continue;
963
- }
964
- const previous = findProfileForHost(await readCliConfig(), baseUrl);
965
- await saveDefaultProfile({ host: baseUrl, ...poll.tokens });
966
- if (previous?.refreshToken) {
967
- await revokeToken(baseUrl, previous.refreshToken, "refresh_token");
968
- }
969
- if (previous?.accessToken) {
970
- await revokeToken(baseUrl, previous.accessToken, "access_token");
971
- }
972
- await resolveOrigin();
973
- console.log(`Saved artis credentials to ${getConfigPath()}`);
974
- return;
975
- }
976
- throw new CliError("Login expired. Run artis login again.", exitCodes.auth);
977
- }
978
- function loginErrorOf(error, baseUrl) {
979
- if (!(error instanceof OAuthError)) {
980
- return error instanceof Error ? error : new Error(String(error));
981
- }
982
- if (error.code === "access_denied") {
983
- return new CliError("Login was denied in the browser.", exitCodes.auth);
984
- }
985
- if (error.code === "expired_token") {
986
- return new CliError(
987
- "Login expired. Run artis login again.",
988
- exitCodes.auth
989
- );
990
- }
991
- if (error.status === 429) {
992
- return new CliError(
993
- `Too many logins from here; ${baseUrl} asked to slow down. Try again in a minute.`,
994
- exitCodes.rateLimited
995
- );
996
- }
997
- return new CliError(
998
- `Login failed on ${baseUrl}: ${error.message}`,
999
- exitCodeForResponse(error.status, error.code)
1000
- );
1001
- }
1002
- async function typesFromCli(args) {
1003
- const [name, file] = getPositionals(args);
1004
- const config = await readCliConfig();
1005
- const baseUrl = resolveBaseUrl(args, config);
1006
- const json = hasFlag(args, "--json");
1007
- const call = async (key, ...input) => {
1008
- try {
1009
- return await apiClient({ baseUrl }).call(key, ...input);
1010
- } catch (error) {
1011
- throw cliErrorOf(error);
1012
- }
1013
- };
1014
- if (!name) {
1015
- const { types } = await call("GET /api/types");
1016
- if (json) {
1017
- console.log(JSON.stringify(types, null, 2));
1018
- return;
1019
- }
1020
- if (!types.length) {
1021
- console.log("No types are installed on this server.");
1022
- return;
1023
- }
1024
- for (const type2 of types) {
1025
- console.log(
1026
- `${type2.name} format ${type2.format} ${type2.release} ${type2.description}`
1027
- );
1028
- }
1029
- return;
1030
- }
1031
- if (file) {
1032
- const result = await call("GET /api/types/{name}/files/{path}", {
1033
- params: { name, path: file }
1034
- });
1035
- if (json) {
1036
- console.log(JSON.stringify(result, null, 2));
1037
- return;
1038
- }
1039
- process.stdout.write(
1040
- result.content.endsWith("\n") ? result.content : `${result.content}
1041
- `
1042
- );
1043
- return;
1044
- }
1045
- const { type } = await call("GET /api/types/{name}", { params: { name } });
1046
- if (json) {
1047
- console.log(JSON.stringify(type, null, 2));
1048
- return;
1049
- }
1050
- if (type.guidance) {
1051
- process.stdout.write(
1052
- type.guidance.endsWith("\n") ? type.guidance : `${type.guidance}
1053
- `
1054
- );
1055
- } else {
1056
- console.log(`${type.title}: ${type.description}`);
1057
- }
1058
- if (type.references.length) {
1059
- console.log(
1060
- `
1061
- References (artis types ${type.name} <path>):
1062
- ${type.references.map((reference) => ` ${reference}`).join("\n")}`
1063
- );
1064
- }
1065
- }
1066
- async function whoamiFromCli(args) {
1067
- const credentials = await resolveCredentials(args);
1068
- const result = await apiCall(credentials, "GET /api/me");
1069
- console.log(
1070
- `Signed in to ${credentials.baseUrl} as ${result.principal.name ?? result.principal.userId}`
1071
- );
1072
- console.log(`Principal: ${result.principal.kind}`);
1073
- }
1074
- function artifactIdArg(value) {
1075
- return artifactIdFromReference(value) ?? value;
1076
- }
1077
- async function getArtifactFromCli(args) {
1078
- const [artifactRef] = getPositionals(args);
1079
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1080
- if (!artifactId) {
1081
- throw usageError("Missing artifact id or link.");
1082
- }
1083
- const target = await resolveOptionalTarget(args);
1084
- const result = await apiCallOptional(
1085
- target,
1086
- "GET /api/artifacts/{artifactId}",
1087
- { params: { artifactId } }
1088
- );
1089
- if (hasFlag(args, "--json")) {
1090
- console.log(JSON.stringify(result, null, 2));
1091
- return;
1092
- }
1093
- console.log(`${result.artifact.metadata.title}`);
1094
- console.log(`Artifact: ${result.artifact.id}`);
1095
- console.log(`Revision: ${result.artifact.currentRevisionId}`);
1096
- const current = result.artifact.revisions.find(
1097
- (revision) => revision.id === result.artifact.currentRevisionId
1098
- );
1099
- const currentType = current && describeType(current);
1100
- if (currentType) {
1101
- console.log(`Type: ${currentType}`);
1102
- }
1103
- console.log(
1104
- `Open annotations: ${result.annotations.filter((annotation) => isRootAnnotation(annotation) && !isReviewClosed(annotation["artis:status"])).length}`
1105
- );
1106
- }
1107
- var parallelFileReads = 6;
1108
- async function mapConcurrent(items, limit, run) {
1109
- const results = new Array(items.length);
1110
- let next = 0;
1111
- async function worker() {
1112
- while (next < items.length) {
1113
- const index = next++;
1114
- results[index] = await run(items[index]);
1115
- }
1116
- }
1117
- await Promise.all(
1118
- Array.from({ length: Math.min(limit, items.length) }, worker)
1119
- );
1120
- return results;
1121
- }
1122
- function listRevisionFiles(target, artifactId, revisionId) {
1123
- return apiCallOptional(target, "GET /api/artifacts/{artifactId}/files", {
1124
- params: { artifactId },
1125
- query: { revisionId }
1126
- });
1127
- }
1128
- function readListedFiles(target, artifactId, listed) {
1129
- return mapConcurrent(listed.files, parallelFileReads, async (file) => {
1130
- const read = await apiCallOptional(
1131
- target,
1132
- "GET /api/artifacts/{artifactId}/files/{path}",
1133
- {
1134
- params: { artifactId, path: file.path },
1135
- query: { revisionId: listed.revisionId }
1136
- }
1137
- );
1138
- return { path: file.path, content: read.content };
1139
- });
1140
- }
1141
- async function readRevisionFiles(target, artifactId, revisionId) {
1142
- const listed = await listRevisionFiles(target, artifactId, revisionId);
1143
- return { listed, files: await readListedFiles(target, artifactId, listed) };
1144
- }
1145
- async function getArtifactFilesFromCli(args) {
1146
- const [artifactRef, filePath] = getPositionals(args);
1147
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1148
- if (!artifactId) {
1149
- throw usageError(
1150
- "Usage: artis artifact files <artifact> [path] [--output <dir>] [--revision <revision-id>] [--json]"
1151
- );
1152
- }
1153
- const target = await resolveOptionalTarget(args);
1154
- const revisionId = parseFlagValue(args, "--revision");
1155
- const json = hasFlag(args, "--json");
1156
- const output = parseFlagValue(args, "--output");
1157
- if (filePath && output) {
1158
- throw usageError(
1159
- `--output writes every file of the revision under a directory. To save one file, redirect it: artis artifact files ${artifactRef} ${filePath} > <file>.`
1160
- );
1161
- }
1162
- if (filePath) {
1163
- const file = await apiCallOptional(
1164
- target,
1165
- "GET /api/artifacts/{artifactId}/files/{path}",
1166
- { params: { artifactId, path: filePath }, query: { revisionId } }
1167
- );
1168
- const revision = await apiCallOptional(
1169
- target,
1170
- "GET /api/artifacts/{artifactId}/files",
1171
- { params: { artifactId }, query: { revisionId: file.revisionId } }
1172
- );
1173
- if (revision.files.length === 1) {
1174
- await rememberBase(
1175
- target.baseUrl,
1176
- [artifactId, file.artifactId],
1177
- file.revisionId
1178
- );
1179
- }
1180
- if (file.isLatest === false) {
1181
- console.error(
1182
- `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.`
1183
- );
1184
- }
1185
- if (json) {
1186
- console.log(JSON.stringify(file, null, 2));
1187
- return;
1188
- }
1189
- process.stdout.write(file.content);
1190
- return;
1191
- }
1192
- const listed = await listRevisionFiles(target, artifactId, revisionId);
1193
- if (output) {
1194
- const files = await readListedFiles(target, artifactId, listed);
1195
- await writeFilesDir(output, files);
1196
- await rememberBase(
1197
- target.baseUrl,
1198
- [artifactId, listed.artifactId],
1199
- listed.revisionId
1200
- );
1201
- }
1202
- if (json) {
1203
- console.log(JSON.stringify(listed, null, 2));
1204
- return;
1205
- }
1206
- for (const file of listed.files) {
1207
- console.log(`${file.path} ${file.size}`);
1208
- }
1209
- console.log(
1210
- 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"}.`
1211
- );
1212
- }
1213
- function parseVerifyType(value) {
1214
- const type = parseTypeFlag(value);
1215
- if (type === void 0 || type === "html") {
1216
- return void 0;
1217
- }
1218
- if (!verifyTypes.includes(type)) {
1219
- throw usageError(
1220
- `Unknown type "${type}". Expected one of: ${verifyTypes.join(", ")}.`
1221
- );
1222
- }
1223
- return type;
1224
- }
1225
- async function verifyFromCli(args) {
1226
- const [target] = getPositionals(args);
1227
- const root = parseFlagValue(args, "--root");
1228
- if (!target && !root) {
1229
- throw usageError(
1230
- "Usage: artis verify <artifact.html | artifact> [--revision <revision-id>] [--json]\n artis verify --root <dir> [--type slides] [--json]"
1231
- );
1232
- }
1233
- if (root) {
1234
- return verifyFilesDirFromCli(args, root, target);
1235
- }
1236
- let type = parseVerifyType(parseFlagValue(args, "--type"));
1237
- let files;
1238
- let label;
1239
- let loadAsset;
1240
- const referenced = artifactIdFromReference(target);
1241
- const looksLikePath = !referenced && (/[\\/]/.test(target) || /\.html?$/i.test(target));
1242
- const local = await readFile(target, "utf8").catch(
1243
- (error) => error
1244
- );
1245
- if (typeof local === "string" || looksLikePath) {
1246
- if (typeof local !== "string") {
1247
- throw local.code === "ENOENT" ? new CliError(`File not found: ${target}`, exitCodes.notFound) : usageError(`Cannot read ${target}: ${local.message}`);
1248
- }
1249
- if (parseFlagValue(args, "--revision")) {
1250
- throw usageError(
1251
- "--revision applies to a published artifact, not a local file."
1252
- );
1253
- }
1254
- if (type) {
1255
- throw usageError(
1256
- `A ${type} artifact is a directory of files: artis verify --root <dir> --type ${type}.`
1257
- );
1258
- }
1259
- files = { "index.html": local };
1260
- label = target;
1261
- } else {
1262
- const remote = await resolveOptionalTarget(args);
1263
- const artifactId = referenced ?? target;
1264
- const read = await readRevisionFiles(
1265
- remote,
1266
- artifactId,
1267
- parseFlagValue(args, "--revision")
1268
- );
1269
- files = Object.fromEntries(
1270
- read.files.map((file) => [file.path, file.content])
1271
- );
1272
- label = `${target} v${read.listed.version}`;
1273
- if (remote.accessToken) {
1274
- loadAsset = (assetId) => fetchAssetContent(remote, artifactId, assetId).catch((error) => {
1275
- if (error instanceof CliError && error.exitCode === exitCodes.notFound) {
1276
- return void 0;
1277
- }
1278
- throw error;
1279
- });
1280
- }
1281
- if (type === void 0) {
1282
- const { artifact } = await apiCallOptional(
1283
- remote,
1284
- "GET /api/artifacts/{artifactId}",
1285
- { params: { artifactId } }
1286
- );
1287
- const declared = artifact.revisions.find(
1288
- (revision) => revision.id === read.listed.revisionId
1289
- )?.type;
1290
- if (declared !== void 0 && declared !== "html") {
1291
- if (!verifyTypes.includes(declared)) {
1292
- throw new CliError(
1293
- `${label} is of type ${declared}, which this CLI cannot verify. Update the CLI.`,
1294
- exitCodes.error
1295
- );
1296
- }
1297
- type = declared;
1298
- }
1299
- }
1300
- }
1301
- await runVerify(args, files, label, type, loadAsset);
1302
- }
1303
- async function verifyFilesDirFromCli(args, root, target) {
1304
- if (target) {
1305
- throw usageError("--root takes no file or artifact argument.");
1306
- }
1307
- if (parseFlagValue(args, "--revision")) {
1308
- throw usageError("--revision applies to a published artifact.");
1309
- }
1310
- const type = parseVerifyType(parseFlagValue(args, "--type"));
1311
- const files = await readFilesDir(root);
1312
- if (!type && files["index.html"] === void 0) {
1313
- throw usageError(
1314
- `${root} has no index.html: an html artifact is that one file. For a deck, add --type slides.`
1315
- );
1316
- }
1317
- await runVerify(args, files, root, type);
1318
- }
1319
- async function runVerify(args, files, label, type, loadAsset) {
1320
- const json = hasFlag(args, "--json");
1321
- const title = `Verified ${label}${type ? ` (type ${type})` : ""}`;
1322
- let report;
1323
- try {
1324
- report = await verifyFiles(files, { type, loadAsset });
1325
- } catch (error) {
1326
- if (error instanceof VerifyUnavailableError) {
1327
- if (error.partial && !json) {
1328
- console.log(title);
1329
- for (const line of formatVerifyReport(error.partial)) {
1330
- console.log(line);
1331
- }
1332
- }
1333
- throw new CliError(
1334
- error.partial ? `Rendering checks did not run: ${error.message}` : error.message,
1335
- exitCodes.error
1336
- );
1337
- }
1338
- throw error;
1339
- }
1340
- if (json) {
1341
- console.log(JSON.stringify(report, null, 2));
1342
- } else {
1343
- console.log(title);
1344
- for (const line of formatVerifyReport(report)) {
1345
- console.log(line);
1346
- }
1347
- }
1348
- if (!report.ok) {
1349
- throw new CliError("", exitCodes.verifyFailed);
1350
- }
1351
- }
1352
- async function listArtifactsFromCli(args) {
1353
- rejectRemovedKindFlag(args);
1354
- const credentials = await resolveCredentials(args);
1355
- const query = parseFlagValue(args, "--query");
1356
- const tag = parseFlagValue(args, "--tag");
1357
- const type = parseTypeFlag(parseFlagValue(args, "--type"));
1358
- const limit = parseFlagValue(args, "--limit");
1359
- const cursor = parseFlagValue(args, "--cursor");
1360
- if (limit !== void 0 && (!/^\d+$/.test(limit) || Number(limit) < 1 || Number(limit) > artifactListLimits.max)) {
1361
- throw usageError(
1362
- `Invalid --limit "${limit}". Pass a whole number from 1 to ${artifactListLimits.max}.`
1363
- );
1364
- }
1365
- const result = await apiCall(credentials, "GET /api/artifacts", {
1366
- query: {
1367
- owner: "me",
1368
- q: query || void 0,
1369
- tag: tag || void 0,
1370
- type,
1371
- limit: limit ? Number(limit) : void 0,
1372
- cursor: cursor || void 0
1373
- }
1374
- });
1375
- if (hasFlag(args, "--json")) {
1376
- console.log(JSON.stringify(result, null, 2));
1377
- return;
1378
- }
1379
- const { artifacts } = result;
1380
- if (!artifacts.length) {
1381
- console.log(
1382
- cursor ? "No more artifacts." : query || tag ? "No artifacts match." : "You have no artifacts yet."
1383
- );
1384
- return;
1385
- }
1386
- for (const artifact of artifacts) {
1387
- const tags = artifact.metadata.tags?.length ? ` #${artifact.metadata.tags.join(" #")}` : "";
1388
- console.log(
1389
- `${artifactShortId(artifact.id)} ${artifact.metadata.visibility} ${artifact.metadata.title}${tags}`
1390
- );
1391
- }
1392
- if (result.nextCursor) {
1393
- console.log(
1394
- `More artifacts: rerun with --cursor ${result.nextCursor} (same filters).`
1395
- );
1396
- }
1397
- }
1398
- async function getArtifactFeedbackFromCli(args, agent = false) {
1399
- const [artifactRef] = getPositionals(args);
1400
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1401
- if (!artifactId) {
1402
- throw usageError("Missing artifact id or link.");
1403
- }
1404
- const target = await resolveOptionalTarget(args);
1405
- const result = await apiCallOptional(
1406
- target,
1407
- "GET /api/artifacts/{artifactId}/feedback",
1408
- {
1409
- params: { artifactId },
1410
- query: { revisionId: parseFlagValue(args, "--revision") }
1411
- }
1412
- );
1413
- const actions = feedbackActions(
1414
- artifactId,
1415
- result.cursor,
1416
- result.bundle.openAnnotations.length,
1417
- args
1418
- );
1419
- if (renderResult(result, actions, args, agent)) return;
1420
- console.log(result.prompt);
1421
- console.log(
1422
- `
1423
- Feedback cursor: ${result.cursor} (artis watch ${artifactId} --since ${result.cursor})`
1424
- );
1425
- if (agent) renderNextActions(actions);
1426
- }
1427
- async function shareArtifactFromCli(args) {
1428
- const [artifactRef] = getPositionals(args);
1429
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1430
- if (!artifactId) {
1431
- throw usageError(
1432
- "Usage: artis share <artifact> [--email <email> --role <viewer|commenter|contributor|editor>] [--remove]"
1433
- );
1434
- }
1435
- const email = parseFlagValue(args, "--email")?.trim().toLowerCase();
1436
- const credentials = await resolveCredentials(args);
1437
- if (!email) {
1438
- const result2 = await apiCall(
1439
- credentials,
1440
- "GET /api/artifacts/{artifactId}/shares",
1441
- { params: { artifactId } }
1442
- );
1443
- if (hasFlag(args, "--json")) {
1444
- console.log(JSON.stringify(result2, null, 2));
1445
- return;
1446
- }
1447
- const { shares } = result2;
1448
- if (!shares.length) {
1449
- console.log("No invited people yet.");
1450
- return;
1451
- }
1452
- for (const share of shares) {
1453
- console.log(`${share.email} ${share.role}`);
1454
- }
1455
- return;
1456
- }
1457
- if (hasFlag(args, "--remove")) {
1458
- await apiCall(
1459
- credentials,
1460
- "DELETE /api/artifacts/{artifactId}/shares/{email}",
1461
- { params: { artifactId, email } }
1462
- );
1463
- console.log(`Removed ${email}`);
1464
- return;
1465
- }
1466
- const role = parseShareRole(parseFlagValue(args, "--role") ?? "viewer");
1467
- const result = await apiCall(
1468
- credentials,
1469
- "POST /api/artifacts/{artifactId}/shares",
1470
- { params: { artifactId }, body: { email, role } }
1471
- );
1472
- if (hasFlag(args, "--json")) {
1473
- console.log(JSON.stringify(result, null, 2));
1474
- return;
1475
- }
1476
- console.log(`Shared with ${result.share.email} as ${result.share.role}`);
1477
- }
1478
- async function setArtifactVisibilityFromCli(args) {
1479
- const [artifactRef, value] = getPositionals(args);
1480
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1481
- if (!artifactId || !value) {
1482
- throw usageError(
1483
- `Usage: artis artifact visibility <artifact> <${cliVisibilityOptions.join("|")}>`
1484
- );
1485
- }
1486
- const visibility = parseVisibility(value);
1487
- const credentials = await resolveCredentials(args);
1488
- const result = await apiCall(
1489
- credentials,
1490
- "PATCH /api/artifacts/{artifactId}",
1491
- { params: { artifactId }, body: { visibility } }
1492
- );
1493
- if (hasFlag(args, "--json")) {
1494
- console.log(JSON.stringify(result, null, 2));
1495
- return;
1496
- }
1497
- console.log(`Visibility: ${result.artifact.metadata.visibility}`);
1498
- }
1499
- function printPolicy(artifact) {
1500
- console.log(`Declared: ${JSON.stringify(artifact.declaredCapabilities)}`);
1501
- console.log(`Served: ${JSON.stringify(artifact.capabilities)}`);
1502
- console.log(`Page epoch: ${artifact.pageEpoch}`);
1503
- }
1504
- async function capabilitiesFromCli(args) {
1505
- const [subcommand, ...rest] = args;
1506
- const [artifactRef, value] = getPositionals(rest);
1507
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1508
- const usage = "Usage: artis capabilities show <artifact> | artis capabilities set <artifact> <json|file> [--reload-pages]";
1509
- if (subcommand === "show" && artifactId) {
1510
- const credentials = await resolveCredentials(rest);
1511
- const { artifact } = await apiCall(
1512
- credentials,
1513
- "GET /api/artifacts/{artifactId}",
1514
- { params: { artifactId } }
1515
- );
1516
- if (hasFlag(rest, "--json")) {
1517
- const { capabilities, declaredCapabilities, pageEpoch } = artifact;
1518
- console.log(
1519
- JSON.stringify(
1520
- { capabilities, declaredCapabilities, pageEpoch },
1521
- null,
1522
- 2
1523
- )
1524
- );
1525
- return;
1526
- }
1527
- printPolicy(artifact);
1528
- return;
1529
- }
1530
- if (subcommand === "set" && artifactId && value !== void 0) {
1531
- const capabilities = await parseCapabilitiesFlag(value, "capabilities");
1532
- const credentials = await resolveCredentials(rest);
1533
- const { artifact } = await apiCall(
1534
- credentials,
1535
- "PUT /api/artifacts/{artifactId}/capabilities",
1536
- {
1537
- params: { artifactId },
1538
- body: {
1539
- capabilities: capabilities ?? {},
1540
- reloadPages: hasFlag(rest, "--reload-pages") || void 0
1541
- }
1542
- }
1543
- );
1544
- if (hasFlag(rest, "--json")) {
1545
- console.log(JSON.stringify({ artifact }, null, 2));
1546
- return;
1547
- }
1548
- printPolicy(artifact);
1549
- return;
1550
- }
1551
- throw usageError(usage);
1552
- }
1553
- async function deleteArtifactFromCli(args) {
1554
- const [artifactRef] = getPositionals(args);
1555
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1556
- if (!artifactId) {
1557
- throw usageError("Usage: artis artifact delete <artifact> --yes");
1558
- }
1559
- if (!hasFlag(args, "--yes")) {
1560
- throw usageError(
1561
- "Deleting an artifact removes every revision, annotation and share, and cannot be undone. Pass --yes to confirm."
1562
- );
1563
- }
1564
- const credentials = await resolveCredentials(args);
1565
- await apiCall(credentials, "DELETE /api/artifacts/{artifactId}", {
1566
- params: { artifactId }
1567
- });
1568
- console.log(`Deleted ${artifactId}`);
1569
- }
1570
- async function reviseArtifactFromCli(args, agent = false) {
1571
- rejectRemovedResolveFlag(args);
1572
- rejectRemovedContractFlag(args);
1573
- const [artifactRef, filePath] = getPositionals(args);
1574
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1575
- const summary = parseFlagValue(args, "--summary");
1576
- const root = parseFlagValue(args, "--root");
1577
- if (!artifactId || !filePath && !root || filePath && root) {
1578
- throw usageError(
1579
- "Usage: artis revise <artifact> (artifact.html | --root <dir>) --summary <text> [--base <revision-id>]"
1580
- );
1581
- }
1582
- if (!summary) {
1583
- throw usageError("Missing --summary for revision.");
1584
- }
1585
- const capabilities = await parseCapabilitiesFlag(
1586
- parseFlagValue(args, "--capabilities")
1587
- );
1588
- const type = parseTypeFlag(parseFlagValue(args, "--type"));
1589
- const credentials = await resolveCredentials(args);
1590
- const explicitBase = parseFlagValue(args, "--base");
1591
- const baseRevisionId = explicitBase ?? await getRememberedBase(credentials.baseUrl, artifactId);
1592
- const query = {
1593
- authorName: parseFlagValue(args, "--author") ?? "Artis CLI",
1594
- baseRevisionId,
1595
- source: "cli",
1596
- summary,
1597
- capabilities,
1598
- reloadPages: hasFlag(args, "--reload-pages") || void 0,
1599
- type
1600
- };
1601
- let result;
1602
- if (root) {
1603
- const local = await readFilesDir(root);
1604
- const remote = await apiCall(
1605
- credentials,
1606
- "GET /api/artifacts/{artifactId}/files",
1607
- { params: { artifactId }, query: { revisionId: baseRevisionId } }
1608
- );
1609
- const files = changedFiles(local, remote.files);
1610
- if (Object.keys(files).length === 0) {
1611
- if (agent && hasFlag(args, "--json") && hasFlag(args, "--next")) {
1612
- renderResult(
1613
- { revisionId: remote.revisionId, unchanged: true },
1614
- publishedActions(artifactId, args),
1615
- args,
1616
- agent
1617
- );
1618
- return;
1619
- }
1620
- console.log(
1621
- `No files differ from revision ${remote.revisionId}; nothing to revise.`
1622
- );
1623
- return;
1624
- }
1625
- result = await apiCallRoot(
1626
- { dir: root, untyped: false, artifact: artifactRef },
1627
- credentials,
1628
- "POST /api/artifacts/{artifactId}/revisions",
1629
- { params: { artifactId }, query, body: { files } }
1630
- );
1631
- if (!hasFlag(args, "--json")) {
1632
- const removed = Object.values(files).filter(
1633
- (content) => content === null
1634
- );
1635
- console.log(
1636
- `Sent ${Object.keys(files).length - removed.length} changed and ${removed.length} removed of ${Object.keys(local).length} files.`
1637
- );
1638
- }
1639
- } else {
1640
- const html = await readHtmlUpload(filePath ?? "", "Revision file");
1641
- try {
1642
- result = await apiClient(credentials).call(
1643
- "POST /api/artifacts/{artifactId}/revisions",
1644
- { params: { artifactId }, query, body: html }
1645
- );
1646
- } catch (error) {
1647
- throw cliErrorOf(error, { artifact: artifactRef });
1648
- }
1649
- }
1650
- await rememberBase(
1651
- credentials.baseUrl,
1652
- [artifactId],
1653
- result.revision.id,
1654
- baseRevisionId
1655
- );
1656
- const actions = publishedActions(artifactId, args);
1657
- if (renderResult({ revision: result.revision }, actions, args, agent)) return;
1658
- console.log(`Revision ${result.revision.id}`);
1659
- console.log(`Version ${result.revision.version}`);
1660
- const revisionType = describeType(result.revision);
1661
- if (revisionType) {
1662
- console.log(`Type ${revisionType}`);
1663
- }
1664
- if (baseRevisionId && !explicitBase) {
1665
- console.log(`Base ${baseRevisionId} (remembered from this machine)`);
1666
- } else if (!baseRevisionId) {
1667
- console.log(
1668
- "No base revision: pass --base, or read the artifact with publish or artifact files first, so a concurrent revision is refused instead of overwritten."
1669
- );
1670
- }
1671
- if (agent) renderNextActions(actions);
1672
- }
1673
- async function createAnnotationFromCli(args) {
1674
- const [artifactRef] = getPositionals(args);
1675
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1676
- const comment = parseFlagValue(args, "--comment");
1677
- if (!artifactId || !comment) {
1678
- throw usageError(
1679
- "Usage: artis annotate <artifact> --comment <text> [--title <text>] [--quote <text>] [--css <selector>] [--text-start <n> --text-end <n>] [--rect <x,y,w,h>] [--pin-label <text>] [--requested-change <text>] [--status <open|resolved>]"
1680
- );
1681
- }
1682
- const selectors = buildAnnotationSelectors(args);
1683
- const credentials = await resolveCredentials(args);
1684
- const result = await apiCall(
1685
- credentials,
1686
- "POST /api/artifacts/{artifactId}/annotations",
1687
- {
1688
- params: { artifactId },
1689
- body: {
1690
- authorName: parseFlagValue(args, "--author") ?? "Artis CLI",
1691
- comment,
1692
- pinLabel: parseFlagValue(args, "--pin-label"),
1693
- requestedChange: parseFlagValue(args, "--requested-change"),
1694
- selectors: selectors.length ? selectors : void 0,
1695
- status: parseAnnotationStatus(
1696
- parseFlagValue(args, "--status") ?? "open"
1697
- ),
1698
- title: parseFlagValue(args, "--title")
1699
- }
1700
- }
1701
- );
1702
- console.log(`Annotation ${annotationIdFromIri(result.annotation.id)}`);
1703
- console.log(`Status ${result.annotation["artis:status"]}`);
1704
- }
1705
- async function replyFromCli(args) {
1706
- const [annotationId] = getPositionals(args);
1707
- const comment = parseFlagValue(args, "--comment");
1708
- if (!annotationId || !comment) {
1709
- throw usageError("Usage: artis reply <annotation-id> --comment <text>");
1710
- }
1711
- const credentials = await resolveCredentials(args);
1712
- const result = await apiCall(
1713
- credentials,
1714
- "POST /api/annotations/{annotationId}/replies",
1715
- {
1716
- params: { annotationId },
1717
- body: {
1718
- authorName: parseFlagValue(args, "--author") ?? "Artis CLI",
1719
- comment
1720
- }
1721
- }
1722
- );
1723
- console.log(`Reply ${annotationIdFromIri(result.annotation.id)}`);
1724
- }
1725
- async function editAnnotationFromCli(args) {
1726
- const [annotationId] = getPositionals(args);
1727
- const comment = parseFlagValue(args, "--comment");
1728
- const title = parseFlagValue(args, "--title");
1729
- const requestedChange = parseFlagValue(args, "--requested-change");
1730
- if (!annotationId || comment === void 0 && title === void 0 && requestedChange === void 0) {
1731
- throw usageError(
1732
- "Usage: artis annotation edit <annotation-id> [--comment <text>] [--title <text>] [--requested-change <text>]"
1733
- );
1734
- }
1735
- const credentials = await resolveCredentials(args);
1736
- const result = await apiCall(
1737
- credentials,
1738
- "PATCH /api/annotations/{annotationId}",
1739
- { params: { annotationId }, body: { comment, title, requestedChange } }
1740
- );
1741
- console.log(`Annotation ${annotationIdFromIri(result.annotation.id)} edited`);
1742
- }
1743
- async function retractAnnotationFromCli(args) {
1744
- const [annotationId] = getPositionals(args);
1745
- if (!annotationId) {
1746
- throw usageError("Usage: artis annotation retract <annotation-id>");
1747
- }
1748
- const credentials = await resolveCredentials(args);
1749
- const result = await apiCall(
1750
- credentials,
1751
- "DELETE /api/annotations/{annotationId}",
1752
- { params: { annotationId } }
1753
- );
1754
- console.log(
1755
- `Annotation ${annotationIdFromIri(result.annotation.id)} retracted`
1756
- );
1757
- }
1758
- var watchMaxWaitSeconds = 25;
1759
- var watchInitialBackoffMs = 1e3;
1760
- var watchMaxBackoffMs = 6e4;
1761
- function parseDuration(value) {
1762
- const match = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/.exec(value.trim());
1763
- if (!match) {
1764
- throw usageError(
1765
- `Invalid duration "${value}". Use e.g. 30s, 5m, 1h, or 500ms.`
1766
- );
1767
- }
1768
- const unitMs = { ms: 1, s: 1e3, m: 6e4, h: 36e5 }[match[2] ?? "s"];
1769
- return Number(match[1]) * unitMs;
1770
- }
1771
- var watchSelfScopes = ["origin", "client", "none"];
1772
- function parseSelfFlag(args) {
1773
- const value = parseFlagValue(args, "--self");
1774
- if (value === void 0) {
1775
- return hasFlag(args, "--include-self") ? "none" : void 0;
1776
- }
1777
- if (!watchSelfScopes.includes(value)) {
1778
- throw usageError(`Invalid --self "${value}". Use origin, client or none.`);
1779
- }
1780
- return value;
1781
- }
1782
- async function watchArtifactFromCli(args) {
1783
- const [artifactRef] = getPositionals(args);
1784
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1785
- if (!artifactId) {
1786
- throw usageError(
1787
- "Usage: artis watch <artifact> [--since <cursor>] [--once] [--timeout <duration>] [--self origin|client|none] [--types <families>]"
1788
- );
1789
- }
1790
- const typesFlag = parseFlagValue(args, "--types");
1791
- const types = typesFlag?.split(",").map((type) => type.trim()).filter(Boolean);
1792
- let cursor = parseFlagValue(args, "--since");
1793
- if (cursor !== void 0 && !/^\d+$/.test(cursor)) {
1794
- throw usageError(
1795
- `Invalid --since "${cursor}". Pass a cursor from artifact feedback or a previous event.`
1796
- );
1797
- }
1798
- const timeoutFlag = parseFlagValue(args, "--timeout");
1799
- const deadline = timeoutFlag !== void 0 ? Date.now() + parseDuration(timeoutFlag) : void 0;
1800
- const once = hasFlag(args, "--once");
1801
- const self = parseSelfFlag(args);
1802
- let credentials = await resolveCredentials(args);
1803
- let api = apiClient(credentials);
1804
- let reauthorized = false;
1805
- let backoffMs = watchInitialBackoffMs;
1806
- let delivered = false;
1807
- const timedOut = () => new CliError(
1808
- `No feedback events within ${timeoutFlag}.${cursor ? ` Resume with --since ${cursor}.` : ""}`,
1809
- exitCodes.watchTimeout
1810
- );
1811
- const backOff = async () => {
1812
- const remaining = deadline === void 0 ? Infinity : deadline - Date.now();
1813
- if (remaining <= backoffMs) {
1814
- if (delivered) {
1815
- return false;
1816
- }
1817
- throw timedOut();
1818
- }
1819
- await sleep(backoffMs);
1820
- backoffMs = Math.min(backoffMs * 2, watchMaxBackoffMs);
1821
- return true;
1822
- };
1823
- for (let attempt = 0; ; attempt += 1) {
1824
- const remainingMs = deadline === void 0 ? Infinity : deadline - Date.now();
1825
- if (attempt > 0 && remainingMs < 1e3) {
1826
- if (delivered) {
1827
- return;
1828
- }
1829
- throw timedOut();
1830
- }
1831
- let page;
1832
- try {
1833
- page = await api.call("GET /api/artifacts/{artifactId}/events", {
1834
- params: { artifactId },
1835
- query: {
1836
- wait: Math.min(watchMaxWaitSeconds, Math.floor(remainingMs / 1e3)),
1837
- since: cursor,
1838
- self,
1839
- types
1840
- }
1841
- });
1842
- } catch (error) {
1843
- if (!(error instanceof ApiError)) {
1844
- if (await backOff()) {
1845
- continue;
1846
- }
1847
- return;
1848
- }
1849
- if (error.status === 401 && !reauthorized) {
1850
- reauthorized = true;
1851
- const next = await resolveCredentials(args).catch(() => void 0);
1852
- if (next && next.accessToken !== credentials.accessToken) {
1853
- credentials = next;
1854
- api = apiClient(credentials);
1855
- continue;
1856
- }
1857
- }
1858
- if ((error.status === 429 || error.status >= 500) && !once) {
1859
- if (await backOff()) {
1860
- continue;
1861
- }
1862
- return;
1863
- }
1864
- throw new CliError(
1865
- error.status === 410 ? `${error.message} Re-read feedback (artis artifact feedback ${artifactId} --json) and watch from its cursor.` : error.message,
1866
- exitCodeForResponse(error.status, error.code)
1867
- );
1868
- }
1869
- backoffMs = watchInitialBackoffMs;
1870
- reauthorized = false;
1871
- const { events } = page;
1872
- cursor = page.cursor;
1873
- if (events.length === 0) {
1874
- continue;
1875
- }
1876
- if (once) {
1877
- console.log(JSON.stringify({ events, cursor }));
1878
- return;
1879
- }
1880
- for (const event of events) {
1881
- process.stdout.write(`${JSON.stringify(event)}
1882
- `);
1883
- }
1884
- delivered = true;
1885
- }
1886
- }
1887
- var dataActions = [
1888
- "get",
1889
- "list",
1890
- "set",
1891
- "update",
1892
- "delete",
1893
- "batch",
1894
- "export",
1895
- "usage"
1896
- ];
1897
- var dataAsRoles = ["viewer", "commenter", "contributor"];
1898
- var dataUsage = "Usage: artis data <get|list|set|update|delete|batch|export|usage> <artifact> [path] [options]. Run artis help.";
1899
- function parseIfMatchFlag(value) {
1900
- if (value === void 0) return void 0;
1901
- const match = /^([^@\s]+)@([1-9]\d*)$/.exec(value);
1902
- if (!match?.[1] || !match[2]) {
1903
- throw usageError(
1904
- `Invalid --if-match "${value}". Expected <id>@<version>, e.g. doc-abc@3.`
1905
- );
1906
- }
1907
- return { id: match[1], version: Number(match[2]) };
1908
- }
1909
- function parseDataCommand(args) {
1910
- const [action, artifactRef, path, extra] = getPositionals(args);
1911
- const artifactId = artifactRef && artifactIdArg(artifactRef);
1912
- if (!dataActions.includes(action) || !artifactId) {
1913
- throw usageError(dataUsage);
1914
- }
1915
- const command = { action, artifactId };
1916
- const is = (...actions) => actions.includes(command.action);
1917
- if (is("get", "set", "update", "delete") && !path) {
1918
- throw usageError(`Usage: artis data ${command.action} <artifact> <path>`);
1919
- }
1920
- if (extra !== void 0 || path !== void 0 && is("batch", "export", "usage")) {
1921
- throw usageError(dataUsage);
1922
- }
1923
- if (path !== void 0) command.path = path;
1924
- const asRole = parseFlagValue(args, "--as-role");
1925
- if (asRole !== void 0) {
1926
- if (!is("get", "list", "export")) {
1927
- throw usageError("--as-role applies to data get, list and export.");
1928
- }
1929
- if (!dataAsRoles.includes(asRole)) {
1930
- throw usageError(
1931
- `Invalid --as-role "${asRole}". Expected one of: ${dataAsRoles.join(", ")}.`
1932
- );
1933
- }
1934
- command.asRole = asRole;
1935
- }
1936
- const ifMatch = parseIfMatchFlag(parseFlagValue(args, "--if-match"));
1937
- const ifAbsent = hasFlag(args, "--if-absent");
1938
- if (ifMatch && ifAbsent) {
1939
- throw usageError("Pass --if-match or --if-absent, not both.");
1940
- }
1941
- if (ifMatch) {
1942
- if (!is("set", "update", "delete")) {
1943
- throw usageError("--if-match applies to data set, update and delete.");
1944
- }
1945
- command.ifMatch = ifMatch;
1946
- }
1947
- if (ifAbsent) {
1948
- if (!is("set", "update")) {
1949
- throw usageError("--if-absent applies to data set and update.");
1950
- }
1951
- command.ifAbsent = true;
1952
- }
1953
- const key = parseFlagValue(args, "--idempotency-key");
1954
- if (key !== void 0) {
1955
- if (!is("set", "update", "delete", "batch")) {
1956
- throw usageError("--idempotency-key applies to data writes.");
1957
- }
1958
- if (!/^[\x21-\x7e]{1,255}$/.test(key)) {
1959
- throw usageError(
1960
- "--idempotency-key must be 1-255 printable characters without spaces."
1961
- );
1962
- }
1963
- command.idempotencyKey = key;
1964
- }
1965
- return command;
1966
- }
1967
- async function readStdin() {
1968
- const chunks = [];
1969
- for await (const chunk of process.stdin) chunks.push(chunk);
1970
- return Buffer.concat(chunks).toString("utf8");
1971
- }
1972
- async function readJsonFlag(args, flag) {
1973
- const value = parseFlagValue(args, flag);
1974
- if (value === void 0) {
1975
- throw usageError(`Missing ${flag} <json|file|->.`);
1976
- }
1977
- let source = value;
1978
- if (value === "-") {
1979
- source = await readStdin();
1980
- } else if (!/^\s*[[{]/.test(value)) {
1981
- try {
1982
- source = await readFile(value, "utf8");
1983
- } catch {
1984
- throw usageError(
1985
- `${flag} must be JSON, a path to a JSON file, or - for stdin; could not read "${value}".`
1986
- );
1987
- }
1988
- }
1989
- try {
1990
- return JSON.parse(source);
1991
- } catch {
1992
- throw usageError(`${flag} is not valid JSON.`);
1993
- }
1994
- }
1995
- async function readJsonObjectFlag(args, flag) {
1996
- const value = await readJsonFlag(args, flag);
1997
- if (!value || typeof value !== "object" || Array.isArray(value)) {
1998
- throw usageError(`${flag} must be a JSON object.`);
1999
- }
2000
- return value;
2001
- }
2002
- function printJson(value) {
2003
- console.log(JSON.stringify(value, null, 2));
2004
- }
2005
- var assetUsage = `Usage:
2006
- artis asset upload <artifact> <file> [--name <name>] [--content-type <type>]
2007
- artis asset list <artifact>
2008
- artis asset get <artifact> <asset-id> [--output <path>]
2009
- artis asset rm <artifact> <asset-id>`;
2010
- var textAssetTypes = {
2011
- ".json": "application/json",
2012
- ".csv": "text/csv",
2013
- ".txt": "text/plain",
2014
- ".svg": "image/svg+xml"
2015
- };
2016
- async function fetchAssetContent(credentials, artifactId, assetId) {
2017
- const response = await fetch(
2018
- `${credentials.baseUrl.replace(/\/+$/, "")}/api/artifacts/${encodeURIComponent(artifactId)}/assets/${encodeURIComponent(assetId)}/content`,
2019
- {
2020
- headers: credentials.accessToken ? {
2021
- authorization: `Bearer ${credentials.accessToken}`,
2022
- ...credentials.origin ? { "artis-origin": credentials.origin } : {}
2023
- } : {}
2024
- }
2025
- );
2026
- if (!response.ok) {
2027
- let body = {};
2028
- try {
2029
- body = await response.json();
2030
- } catch {
2031
- }
2032
- throw cliErrorOf(
2033
- new ApiError(
2034
- response.status,
2035
- typeof body["code"] === "string" ? body["code"] : "http_error",
2036
- typeof body["error"] === "string" ? body["error"] : `Request failed with ${response.status}.`,
2037
- body,
2038
- response.headers
2039
- )
2040
- );
2041
- }
2042
- return {
2043
- bytes: new Uint8Array(await response.arrayBuffer()),
2044
- contentType: response.headers.get("artis-asset-content-type") ?? "application/octet-stream"
2045
- };
2046
- }
2047
- async function assetFromCli(args) {
2048
- const [action, artifactRef, target, extra] = getPositionals(args);
2049
- const artifactId = artifactRef && artifactIdArg(artifactRef);
2050
- if (!artifactId || extra !== void 0 || !["upload", "list", "get", "rm"].includes(action ?? "") || (action === "list" ? target !== void 0 : target === void 0)) {
2051
- throw usageError(assetUsage);
2052
- }
2053
- const credentials = await resolveCredentials(args);
2054
- switch (action) {
2055
- case "upload": {
2056
- const filePath = target;
2057
- let bytes;
2058
- try {
2059
- bytes = await readFile(filePath);
2060
- } catch {
2061
- throw usageError(`Could not read "${filePath}".`);
2062
- }
2063
- const contentType = parseFlagValue(args, "--content-type") ?? textAssetTypes[extname(filePath).toLowerCase()] ?? "application/octet-stream";
2064
- printJson(
2065
- await apiCall(credentials, "POST /api/artifacts/{artifactId}/assets", {
2066
- params: { artifactId },
2067
- query: { name: parseFlagValue(args, "--name") ?? basename(filePath) },
2068
- body: new Uint8Array(
2069
- bytes.buffer,
2070
- bytes.byteOffset,
2071
- bytes.byteLength
2072
- ),
2073
- headers: { "content-type": contentType }
2074
- })
2075
- );
2076
- return;
2077
- }
2078
- case "list": {
2079
- printJson(
2080
- await apiCall(credentials, "GET /api/artifacts/{artifactId}/assets", {
2081
- params: { artifactId }
2082
- })
2083
- );
2084
- return;
2085
- }
2086
- case "get": {
2087
- const assetId = target;
2088
- const output = parseFlagValue(args, "--output");
2089
- if (!output) {
2090
- printJson(
2091
- await apiCall(
2092
- credentials,
2093
- "GET /api/artifacts/{artifactId}/assets/{assetId}",
2094
- { params: { artifactId, assetId } }
2095
- )
2096
- );
2097
- return;
2098
- }
2099
- const { bytes: data } = await fetchAssetContent(
2100
- credentials,
2101
- artifactId,
2102
- assetId
2103
- );
2104
- await writeFile(output, data);
2105
- console.error(`Wrote ${data.byteLength} bytes to ${output}.`);
2106
- return;
2107
- }
2108
- case "rm": {
2109
- await apiCall(
2110
- credentials,
2111
- "DELETE /api/artifacts/{artifactId}/assets/{assetId}",
2112
- { params: { artifactId, assetId: target } }
2113
- );
2114
- console.error(`Deleted asset ${target}.`);
2115
- return;
2116
- }
2117
- }
2118
- }
2119
- async function dataFromCli(args) {
2120
- const command = parseDataCommand(args);
2121
- const credentials = await resolveCredentials(args);
2122
- const { artifactId } = command;
2123
- const path = command.path ?? "";
2124
- const headers = command.idempotencyKey ? { "idempotency-key": command.idempotencyKey } : void 0;
2125
- const condition = {
2126
- ...command.ifMatch ? { ifMatch: command.ifMatch } : {},
2127
- ...command.ifAbsent ? { ifAbsent: true } : {}
2128
- };
2129
- switch (command.action) {
2130
- case "get": {
2131
- const { document } = await apiCall(
2132
- credentials,
2133
- "GET /api/artifacts/{artifactId}/data/docs/{path}",
2134
- { params: { artifactId, path }, query: { asRole: command.asRole } }
2135
- );
2136
- printJson(document);
2137
- if (!document) {
2138
- throw new CliError(`No document at "${path}".`, exitCodes.notFound);
2139
- }
2140
- return;
2141
- }
2142
- case "list": {
2143
- const limit = parseFlagValue(args, "--limit");
2144
- if (limit !== void 0 && (!/^\d+$/.test(limit) || Number(limit) < 1 || Number(limit) > 1e3)) {
2145
- throw usageError(
2146
- `Invalid --limit "${limit}". Pass a whole number from 1 to 1000.`
2147
- );
2148
- }
2149
- const depth = parseFlagValue(args, "--depth");
2150
- if (depth !== void 0 && depth !== "children" && depth !== "all") {
2151
- throw usageError("--depth must be children or all.");
2152
- }
2153
- const order = parseFlagValue(args, "--order");
2154
- if (order !== void 0 && order !== "path" && order !== "created") {
2155
- throw usageError("--order must be path or created.");
2156
- }
2157
- printJson(
2158
- await apiCall(credentials, "GET /api/artifacts/{artifactId}/data", {
2159
- params: { artifactId },
2160
- query: {
2161
- prefix: command.path,
2162
- depth,
2163
- order,
2164
- limit: limit ? Number(limit) : void 0,
2165
- after: parseFlagValue(args, "--after"),
2166
- asRole: command.asRole
2167
- }
2168
- })
2169
- );
2170
- return;
2171
- }
2172
- case "set": {
2173
- const value = await readJsonObjectFlag(args, "--value");
2174
- const { document } = await apiCall(
2175
- credentials,
2176
- "PUT /api/artifacts/{artifactId}/data/docs/{path}",
2177
- {
2178
- params: { artifactId, path },
2179
- body: { value, ...condition },
2180
- headers
2181
- }
2182
- );
2183
- printJson(document);
2184
- return;
2185
- }
2186
- case "update": {
2187
- const patch = await readJsonObjectFlag(args, "--patch");
2188
- const { document } = await apiCall(
2189
- credentials,
2190
- "PATCH /api/artifacts/{artifactId}/data/docs/{path}",
2191
- {
2192
- params: { artifactId, path },
2193
- body: { patch, ...condition },
2194
- headers
2195
- }
2196
- );
2197
- printJson(document);
2198
- return;
2199
- }
2200
- case "delete": {
2201
- const ifMatch = command.ifMatch ? `${command.ifMatch.id}@${command.ifMatch.version}` : void 0;
2202
- printJson(
2203
- await apiCall(
2204
- credentials,
2205
- "DELETE /api/artifacts/{artifactId}/data/docs/{path}",
2206
- { params: { artifactId, path }, query: { ifMatch }, headers }
2207
- )
2208
- );
2209
- return;
2210
- }
2211
- case "batch": {
2212
- const raw = await readJsonFlag(args, "--ops");
2213
- const ops = Array.isArray(raw) ? raw : raw?.ops;
2214
- if (!Array.isArray(ops)) {
2215
- throw usageError(
2216
- '--ops must be a JSON array of writes, or {"ops": [...]}.'
2217
- );
2218
- }
2219
- printJson(
2220
- await apiCall(
2221
- credentials,
2222
- "POST /api/artifacts/{artifactId}/data/batch",
2223
- // The server checks each write.
2224
- { params: { artifactId }, body: { ops }, headers }
2225
- )
2226
- );
2227
- return;
2228
- }
2229
- case "export": {
2230
- let exported;
2231
- try {
2232
- exported = await apiClient(credentials).send(
2233
- "GET /api/artifacts/{artifactId}/data/export",
2234
- { params: { artifactId }, query: { asRole: command.asRole } }
2235
- );
2236
- } catch (error) {
2237
- throw cliErrorOf(error);
2238
- }
2239
- const text = typeof exported.body === "string" ? exported.body : "";
2240
- const output = parseFlagValue(args, "--output");
2241
- if (output) {
2242
- await writeFile(output, text);
2243
- } else {
2244
- process.stdout.write(text);
2245
- }
2246
- const count = text.split("\n").filter((line) => line.trim()).length;
2247
- const left = exported.headers.get("artis-private-documents");
2248
- console.error(
2249
- `Exported ${count} document${count === 1 ? "" : "s"}${output ? ` to ${output}` : ""}${left === null ? "" : `; ${left} in private subtrees left out`}.`
2250
- );
2251
- return;
2252
- }
2253
- case "usage": {
2254
- printJson(
2255
- await apiCall(
2256
- credentials,
2257
- "GET /api/artifacts/{artifactId}/data/usage",
2258
- { params: { artifactId } }
2259
- )
2260
- );
2261
- return;
2262
- }
2263
- }
2264
- }
2265
- async function runArtisCli(args = process.argv.slice(2)) {
2266
- const { runAgentCli } = await import("./app.js");
2267
- await runAgentCli(args);
2268
- }
2269
- async function executeArtisCommand(args, agent = false) {
2270
- const [command, ...rest] = args;
2271
- if (command === "version" || command === "--version" || command === "-v") {
2272
- console.log(`artis ${artisCliVersion}`);
2273
- return;
2274
- }
2275
- if (!agent && (!command || command === "help" || hasFlag(args, "--help"))) {
2276
- console.log(getCliHelp());
2277
- return;
2278
- }
2279
- if (command === "install-skill") {
2280
- await installSkillFromCli(rest);
2281
- return;
2282
- }
2283
- if (command === "login") {
2284
- await loginFromCli(rest);
2285
- return;
2286
- }
2287
- if (command === "whoami") {
2288
- await whoamiFromCli(rest);
2289
- return;
2290
- }
2291
- if (command === "guidelines") {
2292
- await guidelinesFromCli(rest);
2293
- return;
2294
- }
2295
- if (command === "types") {
2296
- await typesFromCli(rest);
2297
- return;
2298
- }
2299
- if (command === "publish") {
2300
- const published = await publishArtifactFromCli(rest);
2301
- const actions = publishedActions(published.artifactId, rest);
2302
- if (renderResult(published, actions, rest, agent)) return;
2303
- console.log(`Published "${published.title}"`);
2304
- console.log(`Artifact: ${published.artifactId}`);
2305
- console.log(`Revision: ${published.revisionId}`);
2306
- console.log(`Visibility: ${published.visibility}`);
2307
- const publishedType = describeType(published);
2308
- if (publishedType) {
2309
- console.log(`Type: ${publishedType}`);
2310
- }
2311
- console.log(published.url);
2312
- if (agent) renderNextActions(actions);
2313
- return;
2314
- }
2315
- if (command === "artifact" && rest[0] === "get") {
2316
- await getArtifactFromCli(rest.slice(1));
2317
- return;
2318
- }
2319
- if (command === "artifact" && rest[0] === "html") {
2320
- throw usageError(
2321
- "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>)."
2322
- );
2323
- }
2324
- if (command === "artifact" && rest[0] === "files") {
2325
- await getArtifactFilesFromCli(rest.slice(1));
2326
- return;
2327
- }
2328
- if (command === "verify") {
2329
- await verifyFromCli(rest);
2330
- return;
2331
- }
2332
- if (command === "artifact" && rest[0] === "list") {
2333
- await listArtifactsFromCli(rest.slice(1));
2334
- return;
2335
- }
2336
- if (command === "artifact" && rest[0] === "visibility") {
2337
- await setArtifactVisibilityFromCli(rest.slice(1));
2338
- return;
2339
- }
2340
- if (command === "artifact" && rest[0] === "delete") {
2341
- await deleteArtifactFromCli(rest.slice(1));
2342
- return;
2343
- }
2344
- if (command === "artifact" && rest[0] === "feedback") {
2345
- await getArtifactFeedbackFromCli(rest.slice(1), agent);
2346
- return;
2347
- }
2348
- if (command === "share") {
2349
- await shareArtifactFromCli(rest);
2350
- return;
2351
- }
2352
- if (command === "capabilities") {
2353
- await capabilitiesFromCli(rest);
2354
- return;
2355
- }
2356
- if (command === "revise") {
2357
- await reviseArtifactFromCli(rest, agent);
2358
- return;
2359
- }
2360
- if (command === "annotate") {
2361
- await createAnnotationFromCli(rest);
2362
- return;
2363
- }
2364
- if (command === "watch") {
2365
- await watchArtifactFromCli(rest);
2366
- return;
2367
- }
2368
- if (command === "reply") {
2369
- await replyFromCli(rest);
2370
- return;
2371
- }
2372
- if (command === "annotation" && rest[0] === "edit") {
2373
- await editAnnotationFromCli(rest.slice(1));
2374
- return;
2375
- }
2376
- if (command === "annotation" && rest[0] === "retract") {
2377
- await retractAnnotationFromCli(rest.slice(1));
2378
- return;
2379
- }
2380
- if (command === "data") {
2381
- await dataFromCli(rest);
2382
- return;
2383
- }
2384
- if (command === "asset") {
2385
- await assetFromCli(rest);
2386
- return;
2387
- }
2388
- throw usageError(`Unknown command "${args.join(" ")}". Run artis help.`);
2389
- }
2390
-
2391
- export {
2392
- commands,
2393
- guidelinesFromCli,
2394
- assertSafeLoginUrl,
2395
- getCliHelp,
2396
- publishArtifactFromCli,
2397
- loginFromCli,
2398
- typesFromCli,
2399
- whoamiFromCli,
2400
- getArtifactFromCli,
2401
- getArtifactFilesFromCli,
2402
- verifyFromCli,
2403
- listArtifactsFromCli,
2404
- getArtifactFeedbackFromCli,
2405
- shareArtifactFromCli,
2406
- setArtifactVisibilityFromCli,
2407
- capabilitiesFromCli,
2408
- deleteArtifactFromCli,
2409
- reviseArtifactFromCli,
2410
- createAnnotationFromCli,
2411
- replyFromCli,
2412
- editAnnotationFromCli,
2413
- retractAnnotationFromCli,
2414
- watchArtifactFromCli,
2415
- parseDataCommand,
2416
- assetFromCli,
2417
- dataFromCli,
2418
- runArtisCli,
2419
- executeArtisCommand
2420
- };