@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,591 +0,0 @@
1
- import {
2
- recoveryActions,
3
- renderNextActions
4
- } from "./chunk-Q5KBGVKT.js";
5
- import {
6
- valueFlags
7
- } from "./chunk-KJV7R7DE.js";
8
- import {
9
- exitCodeFor,
10
- exitCodes,
11
- usageError
12
- } from "./chunk-H32QAUSA.js";
13
-
14
- // packages/cli/src/lib/app.ts
15
- import {
16
- buildApplication,
17
- buildCommand,
18
- buildRouteMap,
19
- run
20
- } from "@stricli/core";
21
- var identity = (input) => input;
22
- var parseFlagInput = (input) => input.slice(1);
23
- var value = (placeholder, brief, hidden = false) => ({
24
- kind: "parsed",
25
- parse: parseFlagInput,
26
- optional: true,
27
- placeholder,
28
- brief,
29
- hidden
30
- });
31
- var bool = (brief, hidden = false) => ({
32
- kind: "boolean",
33
- optional: true,
34
- withNegated: false,
35
- brief,
36
- hidden
37
- });
38
- var repeat = (placeholder, brief) => ({
39
- kind: "parsed",
40
- parse: parseFlagInput,
41
- optional: true,
42
- variadic: true,
43
- placeholder,
44
- brief
45
- });
46
- var flags = {
47
- host: value(
48
- "url",
49
- "Server URL; otherwise ARTIS_URL, saved login, or hosted Artis."
50
- ),
51
- url: value("url", "Alias for --host.", true),
52
- json: bool("Print machine-readable JSON."),
53
- next: bool("With --json, return data and suggested nextActions."),
54
- title: value("text", "Artifact title; defaults to the file name."),
55
- description: value("text", "Artifact description."),
56
- visibility: value(
57
- "public|unlisted|private",
58
- "Visibility; defaults to unlisted."
59
- ),
60
- type: value("type", "Artifact type; defaults to html on publish."),
61
- author: value("name", "Author name; defaults to Artis CLI."),
62
- summary: value("text", "Revision summary; one change per line."),
63
- base: value(
64
- "revision-id",
65
- "Base revision; defaults to remembered base. Protects against conflicts."
66
- ),
67
- capabilities: value("json|file", "Page capabilities JSON; {} clears them."),
68
- "reload-pages": bool("Reload open pages."),
69
- comment: value("text", "Comment text."),
70
- "requested-change": value("text", "Requested change."),
71
- status: value("open|resolved", "Review status; defaults to open."),
72
- quote: value("text", "Exact text to anchor to."),
73
- "quote-prefix": value("text", "Text immediately before the quote."),
74
- "quote-suffix": value("text", "Text immediately after the quote."),
75
- css: value("selector", "CSS selector to anchor to."),
76
- "text-start": value("n", "Start document offset."),
77
- "text-end": value("n", "End document offset."),
78
- rect: value("x,y,w,h", "Canvas point or rectangle in percentages."),
79
- "pin-label": value("text", "Short pin label."),
80
- output: value("path", "Write output to this path."),
81
- root: value("dir", "Source directory containing only artifact files."),
82
- revision: value("revision-id", "Revision to read; defaults to current."),
83
- query: value("text", "Search artifact titles and descriptions."),
84
- tag: value("tag", "Filter by tag."),
85
- limit: value("n", "Page size."),
86
- cursor: value("cursor", "Continue a previous artifact list page."),
87
- email: value("email", "Share recipient."),
88
- role: value(
89
- "role",
90
- "viewer, commenter, contributor or editor; defaults to viewer."
91
- ),
92
- remove: bool("Remove recipient access."),
93
- harness: repeat(
94
- "id",
95
- "Harness ID; repeatable (claude-code, codex, cursor, openclaw, pi, hermes)."
96
- ),
97
- yes: bool("Confirm the requested operation."),
98
- dir: value("path", "Custom skills directory."),
99
- force: bool("Overwrite existing skill."),
100
- list: bool("List supported harnesses."),
101
- since: value("cursor", "Event cursor; defaults to now. 0 replays events."),
102
- once: bool("Exit after first batch of events."),
103
- timeout: value("duration", "Timeout, e.g. 30s or 10m."),
104
- self: value(
105
- "origin|client|none",
106
- "Exclude own events at origin or client scope; default origin."
107
- ),
108
- "include-self": bool("Alias for --self none.", true),
109
- types: value(
110
- "families",
111
- "Comma-separated event families: annotation, revision, page, policy."
112
- ),
113
- value: value("json|file|-", "Whole document JSON, file, or stdin."),
114
- patch: value("json|file|-", "JSON object deep-merged into document."),
115
- ops: value("json|file|-", "Batch operations JSON, file, or stdin."),
116
- "if-match": value("id@version", "Write only at this document version."),
117
- "if-absent": bool("Write only if the path has no document."),
118
- "idempotency-key": value(
119
- "key",
120
- "Make a data write safe to retry within 24 hours."
121
- ),
122
- "as-role": value("role", "Read as viewer, commenter or contributor."),
123
- depth: value("children|all", "Subtree depth; default all."),
124
- order: value("path|created", "List ordering; default path."),
125
- after: value("next", "Continue after a prior page."),
126
- name: value("name", "Asset name; defaults to file name."),
127
- "content-type": value("type", "Asset MIME type."),
128
- kind: value("value", "Removed; use --type.", true),
129
- contract: value("value", "Removed; page contract is fixed.", true),
130
- resolve: value(
131
- "value",
132
- "Removed; revisions no longer resolve feedback.",
133
- true
134
- )
135
- };
136
- var paths = /* @__PURE__ */ new Set();
137
- function leaf(route, brief, usage, minimum, maximum, names, fullDescription) {
138
- paths.add(route);
139
- const selected = Object.fromEntries(
140
- names.split(" ").filter(Boolean).map((name) => [name, flags[name]])
141
- );
142
- return buildCommand({
143
- func(parsed, ...positionals) {
144
- return this.invoke(route, parsed, positionals);
145
- },
146
- parameters: {
147
- // This is a heterogeneous dictionary selected at runtime. Each entry
148
- // is independently checked above against its Stricli flag type.
149
- flags: selected,
150
- ...maximum > 0 ? {
151
- positional: {
152
- kind: "array",
153
- parameter: {
154
- parse: identity,
155
- brief: "See usage.",
156
- placeholder: "arg"
157
- },
158
- minimum,
159
- maximum
160
- }
161
- } : {}
162
- },
163
- docs: { brief, fullDescription, customUsage: usage }
164
- });
165
- }
166
- var root = buildRouteMap({
167
- routes: {
168
- login: leaf(
169
- "login",
170
- "Authenticate using browser approval",
171
- [""],
172
- 0,
173
- 0,
174
- "host url"
175
- ),
176
- whoami: leaf("whoami", "Show signed-in identity", [""], 0, 0, "host url"),
177
- guidelines: leaf(
178
- "guidelines",
179
- "Read current authoring guidelines",
180
- ["[section]"],
181
- 0,
182
- 1,
183
- "host url"
184
- ),
185
- types: leaf(
186
- "types",
187
- "Discover artifact types and references",
188
- ["[name [reference]]"],
189
- 0,
190
- 2,
191
- "host url json"
192
- ),
193
- "install-skill": leaf(
194
- "install-skill",
195
- "Install or list agent skills",
196
- ["[--harness <id>] [--yes] [--dir <path>]"],
197
- 0,
198
- 0,
199
- "harness yes dir force list json"
200
- ),
201
- publish: leaf(
202
- "publish",
203
- "Publish a new artifact",
204
- ["<file> [options]", "--root <dir> [--type <type>] [options]"],
205
- 0,
206
- 1,
207
- "host url json next title description visibility type author capabilities reload-pages root kind contract"
208
- ),
209
- revise: leaf(
210
- "revise",
211
- "Create a revision from edited source",
212
- [
213
- "<artifact> <file> --summary <text>",
214
- "<artifact> --root <dir> --summary <text>"
215
- ],
216
- 1,
217
- 2,
218
- "host url json next summary base root type author capabilities reload-pages resolve contract",
219
- "Re-read and reconcile changes on exit 5; do not simply replace the base."
220
- ),
221
- verify: leaf(
222
- "verify",
223
- "Validate rendered artifact or local source",
224
- ["<file-or-artifact> [options]", "--root <dir> [--type <type>]"],
225
- 0,
226
- 1,
227
- "host url json root type revision",
228
- "Exit 8 means verification found problems."
229
- ),
230
- share: leaf(
231
- "share",
232
- "List or manage artifact access",
233
- ["<artifact> [--email <email> --role <role>] [--remove]"],
234
- 1,
235
- 1,
236
- "host url json email role remove"
237
- ),
238
- annotate: leaf(
239
- "annotate",
240
- "Create a feedback annotation",
241
- ["<artifact> --comment <text> [anchor options]"],
242
- 1,
243
- 1,
244
- "host url comment author title requested-change status quote quote-prefix quote-suffix css text-start text-end rect pin-label"
245
- ),
246
- reply: leaf(
247
- "reply",
248
- "Reply to feedback",
249
- ["<annotation-id> --comment <text>"],
250
- 1,
251
- 1,
252
- "host url comment author"
253
- ),
254
- watch: leaf(
255
- "watch",
256
- "Watch artifact events",
257
- ["<artifact> [options]"],
258
- 1,
259
- 1,
260
- "host url since once timeout self include-self types"
261
- ),
262
- version: leaf("version", "Show CLI version", [""], 0, 0, ""),
263
- artifact: buildRouteMap({
264
- routes: {
265
- get: leaf(
266
- "artifact get",
267
- "Read artifact metadata",
268
- ["<artifact>"],
269
- 1,
270
- 1,
271
- "host url json"
272
- ),
273
- files: leaf(
274
- "artifact files",
275
- "Read or download revision files",
276
- ["<artifact> [path] [--output <dir>]"],
277
- 1,
278
- 2,
279
- "host url json output revision"
280
- ),
281
- feedback: leaf(
282
- "artifact feedback",
283
- "Read review feedback and event cursor",
284
- ["<artifact>"],
285
- 1,
286
- 1,
287
- "host url json next revision"
288
- ),
289
- list: leaf(
290
- "artifact list",
291
- "Search your artifacts",
292
- ["[options]"],
293
- 0,
294
- 0,
295
- "host url json query tag type limit cursor kind"
296
- ),
297
- visibility: leaf(
298
- "artifact visibility",
299
- "Change artifact visibility",
300
- ["<artifact> <public|unlisted|private>"],
301
- 2,
302
- 2,
303
- "host url json"
304
- ),
305
- delete: leaf(
306
- "artifact delete",
307
- "Permanently delete an artifact",
308
- ["<artifact> --yes"],
309
- 1,
310
- 1,
311
- "host url yes"
312
- ),
313
- html: leaf(
314
- "artifact html",
315
- "Removed; use artifact files",
316
- ["<artifact>"],
317
- 0,
318
- 2,
319
- "host url"
320
- )
321
- },
322
- docs: {
323
- brief: "List, read and manage artifacts",
324
- hideRoute: { html: true }
325
- }
326
- }),
327
- capabilities: buildRouteMap({
328
- routes: {
329
- show: leaf(
330
- "capabilities show",
331
- "Read page capability policy",
332
- ["<artifact>"],
333
- 1,
334
- 1,
335
- "host url json"
336
- ),
337
- set: leaf(
338
- "capabilities set",
339
- "Replace page capability policy",
340
- ["<artifact> <json|file>"],
341
- 2,
342
- 2,
343
- "host url json reload-pages"
344
- )
345
- },
346
- docs: { brief: "Manage page capability policy" }
347
- }),
348
- annotation: buildRouteMap({
349
- routes: {
350
- edit: leaf(
351
- "annotation edit",
352
- "Edit feedback",
353
- ["<annotation-id> [options]"],
354
- 1,
355
- 1,
356
- "host url comment title requested-change"
357
- ),
358
- retract: leaf(
359
- "annotation retract",
360
- "Retract feedback",
361
- ["<annotation-id>"],
362
- 1,
363
- 1,
364
- "host url"
365
- )
366
- },
367
- docs: { brief: "Manage feedback annotations" }
368
- }),
369
- data: buildRouteMap({
370
- routes: {
371
- get: leaf(
372
- "data get",
373
- "Read a stored document",
374
- ["<artifact> <path>"],
375
- 2,
376
- 2,
377
- "host url as-role"
378
- ),
379
- list: leaf(
380
- "data list",
381
- "List stored documents",
382
- ["<artifact> [prefix]"],
383
- 1,
384
- 2,
385
- "host url depth order limit after as-role"
386
- ),
387
- set: leaf(
388
- "data set",
389
- "Replace or create a stored document",
390
- ["<artifact> <path> --value <json|file|->"],
391
- 2,
392
- 2,
393
- "host url value if-match if-absent idempotency-key"
394
- ),
395
- update: leaf(
396
- "data update",
397
- "Deep-merge a stored document",
398
- ["<artifact> <path> --patch <json|file|->"],
399
- 2,
400
- 2,
401
- "host url patch if-match if-absent idempotency-key"
402
- ),
403
- delete: leaf(
404
- "data delete",
405
- "Delete a stored document",
406
- ["<artifact> <path>"],
407
- 2,
408
- 2,
409
- "host url if-match idempotency-key"
410
- ),
411
- batch: leaf(
412
- "data batch",
413
- "Apply document writes atomically",
414
- ["<artifact> --ops <json|file|->"],
415
- 1,
416
- 1,
417
- "host url ops idempotency-key"
418
- ),
419
- export: leaf(
420
- "data export",
421
- "Export stored documents",
422
- ["<artifact> [--output <path>]"],
423
- 1,
424
- 1,
425
- "host url output as-role"
426
- ),
427
- usage: leaf(
428
- "data usage",
429
- "Show document storage usage",
430
- ["<artifact>"],
431
- 1,
432
- 1,
433
- "host url"
434
- )
435
- },
436
- docs: { brief: "Manage stored documents" }
437
- }),
438
- asset: buildRouteMap({
439
- routes: {
440
- upload: leaf(
441
- "asset upload",
442
- "Upload an asset",
443
- ["<artifact> <file>"],
444
- 2,
445
- 2,
446
- "host url name content-type"
447
- ),
448
- list: leaf(
449
- "asset list",
450
- "List assets",
451
- ["<artifact>"],
452
- 1,
453
- 1,
454
- "host url"
455
- ),
456
- get: leaf(
457
- "asset get",
458
- "Read asset metadata or download bytes",
459
- ["<artifact> <asset-id> [--output <path>]"],
460
- 2,
461
- 2,
462
- "host url output"
463
- ),
464
- rm: leaf(
465
- "asset rm",
466
- "Remove an asset",
467
- ["<artifact> <asset-id>"],
468
- 2,
469
- 2,
470
- "host url"
471
- )
472
- },
473
- docs: { brief: "Manage artifact assets" }
474
- })
475
- },
476
- docs: {
477
- brief: "Host, share, and collaborate on AI-generated artifacts. Run artis <command> -h for details; artis help --all for the full reference."
478
- }
479
- });
480
- var app = buildApplication(root, {
481
- name: "artis",
482
- documentation: { onlyRequiredInUsageLine: true, disableAnsiColor: true }
483
- });
484
- function protectFlagValues(inputs) {
485
- const argv = [];
486
- for (let i = 0; i < inputs.length; i += 1) {
487
- const input = inputs[i];
488
- const separator = input.indexOf("=");
489
- const name = separator < 0 ? input : input.slice(0, separator);
490
- if (!valueFlags.has(name)) {
491
- argv.push(input);
492
- continue;
493
- }
494
- argv.push(name);
495
- if (separator >= 0) {
496
- argv.push(" " + input.slice(separator + 1));
497
- } else if (i + 1 < inputs.length) {
498
- i += 1;
499
- argv.push(" " + inputs[i]);
500
- }
501
- }
502
- return argv;
503
- }
504
- function canonicalArgs(route, flags2, positionals) {
505
- if (positionals.some((arg) => arg.startsWith("-"))) {
506
- throw usageError(
507
- "Positional arguments cannot start with a dash; use a relative path such as ./-file."
508
- );
509
- }
510
- const args = [...route.split(" "), ...positionals];
511
- for (const [name, input] of Object.entries(flags2)) {
512
- if (input === true) args.push("--" + name);
513
- else if (typeof input === "string") args.push("--" + name, input);
514
- else if (Array.isArray(input)) {
515
- for (const item of input) args.push("--" + name, String(item));
516
- }
517
- }
518
- return args;
519
- }
520
- function helpRoute(inputs) {
521
- const first = inputs[0];
522
- const second = inputs[1];
523
- const pair = first + " " + second;
524
- if (paths.has(pair)) return [first, second];
525
- if (paths.has(first) || [...paths].some((path) => path.startsWith(first + " "))) {
526
- return [first];
527
- }
528
- return [];
529
- }
530
- async function runAgentCli(args = process.argv.slice(2)) {
531
- if (args.length === 2 && args[0] === "help" && args[1] === "--all") {
532
- const { getCliHelp } = await import("./cli.js");
533
- console.log(getCliHelp());
534
- return;
535
- }
536
- if (args.length === 1 && root.getRoutingTargetForInput(args[0])?.kind === root.kind) {
537
- throw usageError(`Missing subcommand. Run artis ${args[0]} -h.`);
538
- }
539
- const inputs = args[0] === "help" ? [...protectFlagValues(args.slice(1)), "--help"] : args.length === 1 && (args[0] === "-v" || args[0] === "--version") ? ["version"] : protectFlagValues(args);
540
- let diagnostic = "";
541
- let stdout = "";
542
- let failure;
543
- let failed = false;
544
- let invoked = false;
545
- let executionArgs = [];
546
- const runtime = {
547
- stdout: {
548
- write: (message) => {
549
- stdout += message;
550
- }
551
- },
552
- stderr: {
553
- write: (message) => {
554
- diagnostic += message;
555
- }
556
- },
557
- env: process.env,
558
- // Stricli only assigns its exit code when the existing value is nullish.
559
- exitCode: void 0
560
- };
561
- await run(app, inputs, {
562
- process: runtime,
563
- async invoke(route, parsed, positionals) {
564
- invoked = true;
565
- try {
566
- executionArgs = canonicalArgs(route, parsed, positionals);
567
- const { executeArtisCommand } = await import("./cli.js");
568
- await executeArtisCommand(executionArgs, true);
569
- } catch (error) {
570
- failed = true;
571
- failure = error;
572
- }
573
- }
574
- });
575
- if (failed) {
576
- renderNextActions(
577
- recoveryActions(exitCodeFor(failure), executionArgs, helpRoute(inputs))
578
- );
579
- throw failure;
580
- }
581
- if (runtime.exitCode !== void 0 && runtime.exitCode !== 0) {
582
- renderNextActions(recoveryActions(exitCodes.usage, [], helpRoute(inputs)));
583
- throw usageError(diagnostic.trim() || "Invalid command. Run artis -h.");
584
- }
585
- if (stdout) console.log(stdout.trimEnd());
586
- if (diagnostic && !invoked) console.error(diagnostic.trimEnd());
587
- }
588
-
589
- export {
590
- runAgentCli
591
- };
@@ -1,82 +0,0 @@
1
- // packages/cli/src/lib/args.ts
2
- var valueFlags = /* @__PURE__ */ new Set([
3
- "--after",
4
- "--as-role",
5
- "--depth",
6
- "--idempotency-key",
7
- "--if-match",
8
- "--ops",
9
- "--order",
10
- "--patch",
11
- "--self",
12
- "--value",
13
- "--author",
14
- "--comment",
15
- "--content-type",
16
- "--css",
17
- "--cursor",
18
- "--description",
19
- "--dir",
20
- "--email",
21
- "--harness",
22
- "--host",
23
- // Removed (ADR 0015); still a value flag so its value is not read as a
24
- // positional before rejectRemovedKindFlag() refuses it.
25
- "--kind",
26
- "--limit",
27
- "--name",
28
- "--output",
29
- "--pin-label",
30
- "--quote",
31
- "--quote-prefix",
32
- "--quote-suffix",
33
- "--query",
34
- "--rect",
35
- "--requested-change",
36
- // Removed; still a value flag so its value is not read as a positional
37
- // before rejectRemovedResolveFlag() refuses it.
38
- "--resolve",
39
- "--revision",
40
- "--role",
41
- "--root",
42
- "--since",
43
- "--status",
44
- "--base",
45
- "--capabilities",
46
- // Removed (ADR 0025); still a value flag so its value is not read as a
47
- // positional before rejectRemovedContractFlag() refuses it.
48
- "--contract",
49
- "--summary",
50
- "--tag",
51
- "--text-end",
52
- "--text-start",
53
- "--timeout",
54
- "--title",
55
- "--type",
56
- "--types",
57
- "--url",
58
- "--visibility"
59
- ]);
60
- function* flagIndices(args, name) {
61
- for (let i = 0; i < args.length; i += 1) {
62
- if (args[i] === name) yield i;
63
- if (valueFlags.has(args[i])) i += 1;
64
- }
65
- }
66
- function parseFlagValue(args, name) {
67
- const index = flagIndices(args, name).next().value;
68
- return index === void 0 ? void 0 : args[index + 1];
69
- }
70
- function hasFlag(args, name) {
71
- return !flagIndices(args, name).next().done;
72
- }
73
- function collectFlagValues(args, name) {
74
- return [...flagIndices(args, name)].map((index) => args[index + 1]).filter((value) => Boolean(value));
75
- }
76
-
77
- export {
78
- valueFlags,
79
- parseFlagValue,
80
- hasFlag,
81
- collectFlagValues
82
- };