@artis-lab/cli 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artis-lab/cli",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Agent-first CLI for publishing, reviewing, and revising self-contained HTML artifacts on an Artis server.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/bin.js CHANGED
@@ -3,8 +3,9 @@
3
3
  // symlink, so `import.meta.url` (realpath) never equals `process.argv[1]` (the
4
4
  // symlink) and any main-module guard here would silently do nothing.
5
5
  import { runArtisCli } from './lib/cli.js';
6
+ import { exitCodeFor } from './lib/exit-codes.js';
6
7
  runArtisCli().catch((error) => {
7
8
  console.error(error instanceof Error ? error.message : String(error));
8
- process.exitCode = 1;
9
+ process.exitCode = exitCodeFor(error);
9
10
  });
10
11
  //# sourceMappingURL=bin.js.map
package/src/lib/cli.d.ts CHANGED
@@ -2,7 +2,7 @@ import { installSkillFromCli } from './skill-install.js';
2
2
  import { artisCliVersion } from './version.js';
3
3
  export { artisCliVersion };
4
4
  export { installSkillFromCli };
5
- export declare const commands: readonly ["annotate", "annotation", "artifact", "guidelines", "help", "install-skill", "login", "publish", "reply", "revise", "share", "version", "whoami"];
5
+ export declare const commands: readonly ["annotate", "annotation", "artifact", "guidelines", "help", "install-skill", "login", "publish", "reply", "revise", "share", "version", "watch", "whoami"];
6
6
  export type ArtisCommand = (typeof commands)[number];
7
7
  /**
8
8
  * Mirrors the sdk's `ArtifactVisibility`, deliberately re-declared instead of
@@ -54,4 +54,12 @@ export declare function createAnnotationFromCli(args: string[]): Promise<void>;
54
54
  export declare function replyFromCli(args: string[]): Promise<void>;
55
55
  export declare function editAnnotationFromCli(args: string[]): Promise<void>;
56
56
  export declare function retractAnnotationFromCli(args: string[]): Promise<void>;
57
+ /**
58
+ * Wait for annotation events on one artifact caused by anyone but this API
59
+ * key, by long-polling `GET /api/artifacts/:id/events` from a feedback
60
+ * cursor. Streams one JSON line per event until stopped; `--once` prints the
61
+ * first batch as `{events, cursor}` and exits 0. Network drops and rate
62
+ * limits are retried from the last cursor, so no event is lost or repeated.
63
+ */
64
+ export declare function watchArtifactFromCli(args: string[]): Promise<void>;
57
65
  export declare function runArtisCli(args?: string[]): Promise<void>;
package/src/lib/cli.js CHANGED
@@ -13,9 +13,11 @@ function isRootAnnotation(annotation) {
13
13
  return annotation.motivation === 'commenting';
14
14
  }
15
15
  import { ARTIS_DEFAULT_HOST, findProfileForHost, getConfigPath, normalizeHost, readCliConfig, saveDefaultProfile, } from './config.js';
16
+ import { getRememberedBase, rememberBase } from './revision-bases.js';
16
17
  import { installSkillFromCli } from './skill-install.js';
17
18
  import { artisCliVersion } from './version.js';
18
19
  import { collectFlagValues, hasFlag, parseFlagValue } from './args.js';
20
+ import { CliError, exitCodeForResponse, exitCodes, usageError, } from './exit-codes.js';
19
21
  export { artisCliVersion };
20
22
  export { installSkillFromCli };
21
23
  export const commands = [
@@ -31,6 +33,7 @@ export const commands = [
31
33
  'revise',
32
34
  'share',
33
35
  'version',
36
+ 'watch',
34
37
  'whoami',
35
38
  ];
36
39
  /**
@@ -81,11 +84,13 @@ const valueFlags = new Set([
81
84
  '--resolve',
82
85
  '--revision',
83
86
  '--role',
87
+ '--since',
84
88
  '--status',
85
89
  '--base',
86
90
  '--summary',
87
91
  '--text-end',
88
92
  '--text-start',
93
+ '--timeout',
89
94
  '--title',
90
95
  '--url',
91
96
  '--visibility',
@@ -113,25 +118,25 @@ function parseVisibility(value) {
113
118
  if (cliVisibilityOptions.includes(value)) {
114
119
  return value;
115
120
  }
116
- throw new Error(`Invalid visibility "${value}". Expected one of: ${cliVisibilityOptions.join(', ')}`);
121
+ throw usageError(`Invalid visibility "${value}". Expected one of: ${cliVisibilityOptions.join(', ')}`);
117
122
  }
118
123
  function parseKind(value) {
119
124
  if (cliArtifactKinds.includes(value)) {
120
125
  return value;
121
126
  }
122
- throw new Error(`Invalid kind "${value}". Expected one of: ${cliArtifactKinds.join(', ')}`);
127
+ throw usageError(`Invalid kind "${value}". Expected one of: ${cliArtifactKinds.join(', ')}`);
123
128
  }
124
129
  function parseAnnotationStatus(value) {
125
130
  if (cliAnnotationStatusOptions.includes(value)) {
126
131
  return value;
127
132
  }
128
- throw new Error(`Invalid status "${value}". Expected one of: ${cliAnnotationStatusOptions.join(', ')}`);
133
+ throw usageError(`Invalid status "${value}". Expected one of: ${cliAnnotationStatusOptions.join(', ')}`);
129
134
  }
130
135
  function parseShareRole(value) {
131
136
  if (cliShareRoleOptions.includes(value)) {
132
137
  return value;
133
138
  }
134
- throw new Error(`Invalid role "${value}". Expected one of: ${cliShareRoleOptions.join(', ')}`);
139
+ throw usageError(`Invalid role "${value}". Expected one of: ${cliShareRoleOptions.join(', ')}`);
135
140
  }
136
141
  /** Parse a `--rect x,y,w,h` percentage tuple into a Media Fragments
137
142
  * `xywh=percent:` FragmentSelector. Width/height default to 0 (a point pin). */
@@ -142,7 +147,7 @@ function parseRectSelector(value) {
142
147
  const parts = value.split(',').map((part) => Number(part.trim()));
143
148
  if ((parts.length !== 2 && parts.length !== 4) ||
144
149
  parts.some((part) => !Number.isFinite(part))) {
145
- throw new Error(`Invalid --rect "${value}". Expected "x,y" or "x,y,w,h" percentages.`);
150
+ throw usageError(`Invalid --rect "${value}". Expected "x,y" or "x,y,w,h" percentages.`);
146
151
  }
147
152
  const [x, y, width = 0, height = 0] = parts;
148
153
  return {
@@ -178,7 +183,7 @@ function buildAnnotationSelectors(args) {
178
183
  const start = Number(textStart);
179
184
  const end = Number(textEnd);
180
185
  if (!Number.isFinite(start) || !Number.isFinite(end)) {
181
- throw new Error('--text-start and --text-end must be numbers.');
186
+ throw usageError('--text-start and --text-end must be numbers.');
182
187
  }
183
188
  selectors.push({ type: 'TextPositionSelector', start, end });
184
189
  }
@@ -224,7 +229,7 @@ function resolveCredentials(args) {
224
229
  const baseUrl = resolveBaseUrl(args, config);
225
230
  const { apiKey } = resolveApiKey(args, config, baseUrl);
226
231
  if (!apiKey) {
227
- throw new Error(`Missing API key. Run "artis login --host ${baseUrl}" or set ARTIS_API_KEY.`);
232
+ throw new CliError(`Missing API key. Run "artis login --host ${baseUrl}" or set ARTIS_API_KEY.`, exitCodes.auth);
228
233
  }
229
234
  return { apiKey, baseUrl };
230
235
  });
@@ -250,7 +255,7 @@ export function guidelinesFromCli(args) {
250
255
  const response = yield fetch(`${baseUrl}/skills.md?section=${encodeURIComponent(section !== null && section !== void 0 ? section : 'index')}`);
251
256
  const text = yield response.text();
252
257
  if (!response.ok) {
253
- throw new Error(text.trim() || `Guidelines request failed with ${response.status}.`);
258
+ throw new CliError(text.trim() || `Guidelines request failed with ${response.status}.`, exitCodeForResponse(response.status));
254
259
  }
255
260
  process.stdout.write(text.endsWith('\n') ? text : `${text}\n`);
256
261
  });
@@ -260,7 +265,7 @@ function parsePublishOptions(args) {
260
265
  var _a, _b, _c, _d;
261
266
  const [filePath] = getPositionals(args);
262
267
  if (!filePath) {
263
- throw new Error('Missing artifact HTML file path.');
268
+ throw usageError('Missing artifact HTML file path.');
264
269
  }
265
270
  const credentials = yield resolveCredentials(args);
266
271
  const visibility = parseVisibility((_a = parseFlagValue(args, '--visibility')) !== null && _a !== void 0 ? _a : 'unlisted');
@@ -290,9 +295,9 @@ function apiFetch(credentials_1, path_1) {
290
295
  if (!response.ok) {
291
296
  const message = (_a = payload === null || payload === void 0 ? void 0 : payload.error) !== null && _a !== void 0 ? _a : `Request failed with ${response.status}.`;
292
297
  // A revise conflict is only recoverable with the current revision id.
293
- throw new Error((payload === null || payload === void 0 ? void 0 : payload.currentRevisionId)
298
+ throw new CliError((payload === null || payload === void 0 ? void 0 : payload.currentRevisionId)
294
299
  ? `${message} Current revision: ${payload.currentRevisionId}.`
295
- : message);
300
+ : message, exitCodeForResponse(response.status, payload === null || payload === void 0 ? void 0 : payload.code));
296
301
  }
297
302
  return payload;
298
303
  });
@@ -318,7 +323,7 @@ function apiFetchOptional(target_1, path_1) {
318
323
  status = retryResponse.status;
319
324
  }
320
325
  if (status < 200 || status >= 300) {
321
- throw new Error((_a = payload === null || payload === void 0 ? void 0 : payload.error) !== null && _a !== void 0 ? _a : `Request failed with ${status}.`);
326
+ throw new CliError((_a = payload === null || payload === void 0 ? void 0 : payload.error) !== null && _a !== void 0 ? _a : `Request failed with ${status}.`, exitCodeForResponse(status, payload === null || payload === void 0 ? void 0 : payload.code));
322
327
  }
323
328
  return payload;
324
329
  });
@@ -404,6 +409,7 @@ Usage:
404
409
  artis reply <annotation-id> --comment <text>
405
410
  artis annotation edit <annotation-id> [--comment <text>] [--title <text>] [--requested-change <text>]
406
411
  artis annotation retract <annotation-id>
412
+ artis watch <artifact-id-or-slug> [--since <cursor>] [--once] [--timeout <duration>] [--include-self]
407
413
 
408
414
  Options:
409
415
  --api-key <key> API key. Defaults to ARTIS_API_KEY or ~/.artis/config.json. Run "artis login" to obtain one.
@@ -414,7 +420,7 @@ Options:
414
420
  --kind <value> Artifact kind. Defaults to custom-html.
415
421
  --author <name> Artifact author/agent name. Defaults to Artis CLI.
416
422
  --summary <text> Revision summary. Write one change per line; they render as a list.
417
- --base <revision-id> Revision the file was edited from (printed by publish and artifact html). Refuses the revise if someone revised since.
423
+ --base <revision-id> Revision the file was edited from. Defaults to the revision this machine last published, read (artifact html), or revised. Refuses the revise if someone revised since.
418
424
  --resolve <annotation-id> Mark an annotation resolved when revising. Repeatable.
419
425
  --comment <text> Annotation or reply comment text (annotate, reply).
420
426
  --requested-change <text> Structured change request for the artifact author (annotate).
@@ -437,8 +443,15 @@ Options:
437
443
  --dir <path> Install the skill into a custom skills directory (install-skill).
438
444
  --force Overwrite an already-installed skill (install-skill).
439
445
  --list List harnesses, detection, and install paths (install-skill).
446
+ --since <cursor> Feedback cursor to watch from (watch). Defaults to now; 0 replays every event.
447
+ --once Exit after the first batch of events, printed as {events, cursor} (watch).
448
+ --timeout <duration> Give up after this long, e.g. 30s, 10m (watch). Exits 6 if nothing happened.
449
+ --include-self Also report events caused by this API key (watch).
440
450
  --json Print machine-readable JSON for supported commands.
441
451
 
452
+ Exit codes:
453
+ 0 success, 1 error, 2 usage, 3 auth, 4 not found, 5 revision conflict, 6 watch timeout, 7 rate limited.
454
+
442
455
  Examples (--host is optional; without it commands target https://artis.xiispace.eu.org):
443
456
  artis publish report.html
444
457
  artis login
@@ -451,6 +464,7 @@ Examples (--host is optional; without it commands target https://artis.xiispace.
451
464
  artis reply annotation-123 --host https://artis.example.com --comment "Addressed in the latest revision"
452
465
  artis annotation edit annotation-123 --host https://artis.example.com --comment "Corrected: the latency spike is on checkout, not search"
453
466
  artis annotation retract annotation-123 --host https://artis.example.com
467
+ artis watch artifact-slug --since 42
454
468
  artis guidelines authoring
455
469
  artis install-skill --yes
456
470
  artis revise artifact-slug report.html --host https://artis.example.com --summary "Addressed open feedback" --base revision-abc --resolve annotation-123`;
@@ -480,6 +494,7 @@ export function publishArtifactFromCli(args) {
480
494
  if (!(result === null || result === void 0 ? void 0 : result.result)) {
481
495
  throw new Error('Publish response did not include artifact details.');
482
496
  }
497
+ yield rememberBase(options.baseUrl, [result.result.artifactId, result.result.slug], result.result.revisionId);
483
498
  return {
484
499
  artifactId: result.result.artifactId,
485
500
  revisionId: result.result.revisionId,
@@ -503,7 +518,7 @@ export function loginFromCli(args) {
503
518
  !login.userCode ||
504
519
  !login.verificationUrl ||
505
520
  !login.expiresAt) {
506
- throw new Error((_a = login === null || login === void 0 ? void 0 : login.error) !== null && _a !== void 0 ? _a : `Login failed with ${response.status}.`);
521
+ throw new CliError((_a = login === null || login === void 0 ? void 0 : login.error) !== null && _a !== void 0 ? _a : `Login failed with ${response.status}.`, exitCodeForResponse(response.status));
507
522
  }
508
523
  // Validate the host-controlled verification URL before opening a browser.
509
524
  // A non-default or compromised host could otherwise return a crafted URL
@@ -557,7 +572,7 @@ export function getArtifactFromCli(args) {
557
572
  var _a;
558
573
  const [artifactId] = getPositionals(args);
559
574
  if (!artifactId) {
560
- throw new Error('Missing artifact id or slug.');
575
+ throw usageError('Missing artifact id or slug.');
561
576
  }
562
577
  const target = yield resolveOptionalTarget(args);
563
578
  const result = yield apiFetchOptional(target, `/api/artifacts/${encodeURIComponent(artifactId)}`);
@@ -583,7 +598,7 @@ export function getArtifactHtmlFromCli(args) {
583
598
  return __awaiter(this, void 0, void 0, function* () {
584
599
  const [artifactId] = getPositionals(args);
585
600
  if (!artifactId) {
586
- throw new Error('Usage: artis artifact html <artifact-id-or-slug> [--output <path>] [--revision <revision-id>]');
601
+ throw usageError('Usage: artis artifact html <artifact-id-or-slug> [--output <path>] [--revision <revision-id>]');
587
602
  }
588
603
  const target = yield resolveOptionalTarget(args);
589
604
  const revisionId = parseFlagValue(args, '--revision');
@@ -591,6 +606,11 @@ export function getArtifactHtmlFromCli(args) {
591
606
  ? `?revisionId=${encodeURIComponent(revisionId)}`
592
607
  : '';
593
608
  const result = yield apiFetchOptional(target, `/api/artifacts/${encodeURIComponent(artifactId)}/html${query}`);
609
+ // Whatever was read is what an edit of it builds on: `revise` sends it as
610
+ // the base, so a revision landing in between is refused, not overwritten.
611
+ if (result === null || result === void 0 ? void 0 : result.revisionId) {
612
+ yield rememberBase(target.baseUrl, [artifactId, result.artifactId], result.revisionId);
613
+ }
594
614
  if (hasFlag(args, '--json')) {
595
615
  console.log(JSON.stringify(result, null, 2));
596
616
  return;
@@ -615,7 +635,7 @@ export function getArtifactFeedbackFromCli(args) {
615
635
  return __awaiter(this, void 0, void 0, function* () {
616
636
  const [artifactId] = getPositionals(args);
617
637
  if (!artifactId) {
618
- throw new Error('Missing artifact id or slug.');
638
+ throw usageError('Missing artifact id or slug.');
619
639
  }
620
640
  const target = yield resolveOptionalTarget(args);
621
641
  const revisionId = parseFlagValue(args, '--revision');
@@ -631,6 +651,9 @@ export function getArtifactFeedbackFromCli(args) {
631
651
  throw new Error('Feedback response did not include a prompt.');
632
652
  }
633
653
  console.log(result.prompt);
654
+ if (result.cursor !== undefined) {
655
+ console.log(`\nFeedback cursor: ${result.cursor} (artis watch ${artifactId} --since ${result.cursor})`);
656
+ }
634
657
  });
635
658
  }
636
659
  export function shareArtifactFromCli(args) {
@@ -638,7 +661,7 @@ export function shareArtifactFromCli(args) {
638
661
  var _a, _b, _c;
639
662
  const [artifactId] = getPositionals(args);
640
663
  if (!artifactId) {
641
- throw new Error('Usage: artis share <artifact-id-or-slug> [--email <email> --role <viewer|commenter>] [--remove]');
664
+ throw usageError('Usage: artis share <artifact-id-or-slug> [--email <email> --role <viewer|commenter>] [--remove]');
642
665
  }
643
666
  const email = (_a = parseFlagValue(args, '--email')) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase();
644
667
  const credentials = yield resolveCredentials(args);
@@ -688,27 +711,32 @@ export function reviseArtifactFromCli(args) {
688
711
  const [artifactId, filePath] = getPositionals(args);
689
712
  const summary = parseFlagValue(args, '--summary');
690
713
  if (!artifactId || !filePath) {
691
- throw new Error('Usage: artis revise <artifact-id-or-slug> artifact.html --summary <text> [--base <revision-id>]');
714
+ throw usageError('Usage: artis revise <artifact-id-or-slug> artifact.html --summary <text> [--base <revision-id>]');
692
715
  }
693
716
  if (!summary) {
694
- throw new Error('Missing --summary for revision.');
717
+ throw usageError('Missing --summary for revision.');
695
718
  }
696
719
  const credentials = yield resolveCredentials(args);
697
720
  const html = yield readFile(filePath, 'utf8');
698
721
  if (!html.toLowerCase().includes('<html')) {
699
722
  throw new Error('Revision file must be self-contained HTML including <html>.');
700
723
  }
724
+ const explicitBase = parseFlagValue(args, '--base');
725
+ const baseRevisionId = explicitBase !== null && explicitBase !== void 0 ? explicitBase : (yield getRememberedBase(credentials.baseUrl, artifactId));
701
726
  const result = yield apiFetch(credentials, `/api/artifacts/${encodeURIComponent(artifactId)}/revisions`, {
702
727
  method: 'POST',
703
728
  body: JSON.stringify({
704
729
  authorName: (_a = parseFlagValue(args, '--author')) !== null && _a !== void 0 ? _a : 'Artis CLI',
705
730
  html,
706
- baseRevisionId: parseFlagValue(args, '--base'),
731
+ baseRevisionId,
707
732
  resolvedAnnotationIds: collectFlagValues(args, '--resolve'),
708
733
  source: 'cli',
709
734
  summary,
710
735
  }),
711
736
  });
737
+ if (result === null || result === void 0 ? void 0 : result.revision) {
738
+ yield rememberBase(credentials.baseUrl, [artifactId], result.revision.id, baseRevisionId);
739
+ }
712
740
  if (hasFlag(args, '--json')) {
713
741
  console.log(JSON.stringify(result, null, 2));
714
742
  return;
@@ -718,6 +746,12 @@ export function reviseArtifactFromCli(args) {
718
746
  }
719
747
  console.log(`Revision ${result.revision.id}`);
720
748
  console.log(`Version ${result.revision.version}`);
749
+ if (baseRevisionId && !explicitBase) {
750
+ console.log(`Base ${baseRevisionId} (remembered from this machine)`);
751
+ }
752
+ else if (!baseRevisionId) {
753
+ console.log('No base revision: pass --base, or read the artifact with publish or artifact html first, so a concurrent revision is refused instead of overwritten.');
754
+ }
721
755
  });
722
756
  }
723
757
  export function createAnnotationFromCli(args) {
@@ -726,7 +760,7 @@ export function createAnnotationFromCli(args) {
726
760
  const [artifactId] = getPositionals(args);
727
761
  const comment = parseFlagValue(args, '--comment');
728
762
  if (!artifactId || !comment) {
729
- throw new Error('Usage: artis annotate <artifact-id-or-slug> --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|needs-revision|resolved>]');
763
+ throw usageError('Usage: artis annotate <artifact-id-or-slug> --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|needs-revision|resolved>]');
730
764
  }
731
765
  const selectors = buildAnnotationSelectors(args);
732
766
  const credentials = yield resolveCredentials(args);
@@ -756,7 +790,7 @@ export function replyFromCli(args) {
756
790
  const [annotationId] = getPositionals(args);
757
791
  const comment = parseFlagValue(args, '--comment');
758
792
  if (!annotationId || !comment) {
759
- throw new Error('Usage: artis reply <annotation-id> --comment <text>');
793
+ throw usageError('Usage: artis reply <annotation-id> --comment <text>');
760
794
  }
761
795
  const credentials = yield resolveCredentials(args);
762
796
  const result = yield apiFetch(credentials, `/api/annotations/${encodeURIComponent(annotationId)}/replies`, {
@@ -783,7 +817,7 @@ export function editAnnotationFromCli(args) {
783
817
  (comment === undefined &&
784
818
  title === undefined &&
785
819
  requestedChange === undefined)) {
786
- throw new Error('Usage: artis annotation edit <annotation-id> [--comment <text>] [--title <text>] [--requested-change <text>]');
820
+ throw usageError('Usage: artis annotation edit <annotation-id> [--comment <text>] [--title <text>] [--requested-change <text>]');
787
821
  }
788
822
  const credentials = yield resolveCredentials(args);
789
823
  const result = yield apiFetch(credentials, `/api/annotations/${encodeURIComponent(annotationId)}`, {
@@ -800,7 +834,7 @@ export function retractAnnotationFromCli(args) {
800
834
  return __awaiter(this, void 0, void 0, function* () {
801
835
  const [annotationId] = getPositionals(args);
802
836
  if (!annotationId) {
803
- throw new Error('Usage: artis annotation retract <annotation-id>');
837
+ throw usageError('Usage: artis annotation retract <annotation-id>');
804
838
  }
805
839
  const credentials = yield resolveCredentials(args);
806
840
  const result = yield apiFetch(credentials, `/api/annotations/${encodeURIComponent(annotationId)}`, {
@@ -812,6 +846,124 @@ export function retractAnnotationFromCli(args) {
812
846
  console.log(`Annotation ${annotationIdFromIri(result.annotation.id)} retracted`);
813
847
  });
814
848
  }
849
+ const watchMaxWaitSeconds = 25;
850
+ const watchInitialBackoffMs = 1000;
851
+ const watchMaxBackoffMs = 60000;
852
+ /** `30`, `30s`, `500ms`, `5m`, `1h` → milliseconds. A bare number is seconds. */
853
+ function parseDuration(value) {
854
+ var _a;
855
+ const match = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/.exec(value.trim());
856
+ if (!match) {
857
+ throw usageError(`Invalid duration "${value}". Use e.g. 30s, 5m, 1h, or 500ms.`);
858
+ }
859
+ const unitMs = { ms: 1, s: 1000, m: 60000, h: 3600000 }[((_a = match[2]) !== null && _a !== void 0 ? _a : 's')];
860
+ return Number(match[1]) * unitMs;
861
+ }
862
+ /**
863
+ * Wait for annotation events on one artifact caused by anyone but this API
864
+ * key, by long-polling `GET /api/artifacts/:id/events` from a feedback
865
+ * cursor. Streams one JSON line per event until stopped; `--once` prints the
866
+ * first batch as `{events, cursor}` and exits 0. Network drops and rate
867
+ * limits are retried from the last cursor, so no event is lost or repeated.
868
+ */
869
+ export function watchArtifactFromCli(args) {
870
+ return __awaiter(this, void 0, void 0, function* () {
871
+ var _a, _b, _c;
872
+ const [artifactId] = getPositionals(args);
873
+ if (!artifactId) {
874
+ throw usageError('Usage: artis watch <artifact-id-or-slug> [--since <cursor>] [--once] [--timeout <duration>] [--include-self]');
875
+ }
876
+ let cursor = parseFlagValue(args, '--since');
877
+ if (cursor !== undefined && !/^\d+$/.test(cursor)) {
878
+ throw usageError(`Invalid --since "${cursor}". Pass a cursor from artifact feedback or a previous event.`);
879
+ }
880
+ const timeoutFlag = parseFlagValue(args, '--timeout');
881
+ const deadline = timeoutFlag !== undefined
882
+ ? Date.now() + parseDuration(timeoutFlag)
883
+ : undefined;
884
+ const once = hasFlag(args, '--once');
885
+ const includeSelf = hasFlag(args, '--include-self');
886
+ const credentials = yield resolveCredentials(args);
887
+ let backoffMs = watchInitialBackoffMs;
888
+ let delivered = false;
889
+ const timedOut = () => new CliError(`No feedback events within ${timeoutFlag}.${cursor ? ` Resume with --since ${cursor}.` : ''}`, exitCodes.watchTimeout);
890
+ // Sleep before retrying a transient failure. Returns false when the
891
+ // deadline would pass first and the stream already delivered (a clean end).
892
+ const backOff = () => __awaiter(this, void 0, void 0, function* () {
893
+ const remaining = deadline === undefined ? Infinity : deadline - Date.now();
894
+ if (remaining <= backoffMs) {
895
+ if (delivered) {
896
+ return false;
897
+ }
898
+ throw timedOut();
899
+ }
900
+ yield sleep(backoffMs);
901
+ backoffMs = Math.min(backoffMs * 2, watchMaxBackoffMs);
902
+ return true;
903
+ });
904
+ for (let attempt = 0;; attempt += 1) {
905
+ const remainingMs = deadline === undefined ? Infinity : deadline - Date.now();
906
+ // The first request always goes out, so a short --timeout still reports
907
+ // auth or not-found errors. After that, under a second left would only
908
+ // produce wait=0 requests in a tight loop.
909
+ if (attempt > 0 && remainingMs < 1000) {
910
+ // Exit 6 means "nothing happened"; a stream that delivered ends cleanly.
911
+ if (delivered) {
912
+ return;
913
+ }
914
+ throw timedOut();
915
+ }
916
+ const query = new URLSearchParams({
917
+ wait: String(Math.min(watchMaxWaitSeconds, Math.floor(remainingMs / 1000))),
918
+ });
919
+ if (cursor !== undefined) {
920
+ query.set('since', cursor);
921
+ }
922
+ if (includeSelf) {
923
+ query.set('includeSelf', 'true');
924
+ }
925
+ let response;
926
+ try {
927
+ response = yield fetch(`${credentials.baseUrl}/api/artifacts/${encodeURIComponent(artifactId)}/events?${query}`, { headers: { authorization: `Bearer ${credentials.apiKey}` } });
928
+ }
929
+ catch (_d) {
930
+ // Network drop: reconnect from the last cursor.
931
+ if (yield backOff()) {
932
+ continue;
933
+ }
934
+ return;
935
+ }
936
+ const payload = yield readJsonResponse(response);
937
+ // Rate limits and server errors are transient for a long-running stream.
938
+ if ((response.status === 429 || response.status >= 500) && !once) {
939
+ if (yield backOff()) {
940
+ continue;
941
+ }
942
+ return;
943
+ }
944
+ if (!response.ok) {
945
+ const message = (_a = payload === null || payload === void 0 ? void 0 : payload.error) !== null && _a !== void 0 ? _a : `Watch request failed with ${response.status}.`;
946
+ throw new CliError(response.status === 410
947
+ ? `${message} Re-read feedback (artis artifact feedback ${artifactId} --json) and watch from its cursor.`
948
+ : message, exitCodeForResponse(response.status, payload === null || payload === void 0 ? void 0 : payload.code));
949
+ }
950
+ backoffMs = watchInitialBackoffMs;
951
+ const events = (_b = payload === null || payload === void 0 ? void 0 : payload.events) !== null && _b !== void 0 ? _b : [];
952
+ cursor = (_c = payload === null || payload === void 0 ? void 0 : payload.cursor) !== null && _c !== void 0 ? _c : cursor;
953
+ if (events.length === 0) {
954
+ continue;
955
+ }
956
+ if (once) {
957
+ console.log(JSON.stringify({ events, cursor }));
958
+ return;
959
+ }
960
+ for (const event of events) {
961
+ process.stdout.write(`${JSON.stringify(event)}\n`);
962
+ }
963
+ delivered = true;
964
+ }
965
+ });
966
+ }
815
967
  export function runArtisCli() {
816
968
  return __awaiter(this, arguments, void 0, function* (args = process.argv.slice(2)) {
817
969
  const [command, ...rest] = args;
@@ -876,6 +1028,10 @@ export function runArtisCli() {
876
1028
  yield createAnnotationFromCli(rest);
877
1029
  return;
878
1030
  }
1031
+ if (command === 'watch') {
1032
+ yield watchArtifactFromCli(rest);
1033
+ return;
1034
+ }
879
1035
  if (command === 'reply') {
880
1036
  yield replyFromCli(rest);
881
1037
  return;
@@ -888,7 +1044,7 @@ export function runArtisCli() {
888
1044
  yield retractAnnotationFromCli(rest.slice(1));
889
1045
  return;
890
1046
  }
891
- throw new Error(`Unknown command "${args.join(' ')}". Run artis help.`);
1047
+ throw usageError(`Unknown command "${args.join(' ')}". Run artis help.`);
892
1048
  });
893
1049
  }
894
1050
  //# sourceMappingURL=cli.js.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The CLI's process exit codes, one table for every command so an agent can
3
+ * branch on the outcome without parsing messages. Documented in the `cli`
4
+ * guidelines section; keep the two in step.
5
+ */
6
+ export declare const exitCodes: {
7
+ readonly ok: 0;
8
+ readonly error: 1;
9
+ readonly usage: 2;
10
+ readonly auth: 3;
11
+ readonly notFound: 4;
12
+ readonly revisionConflict: 5;
13
+ readonly watchTimeout: 6;
14
+ readonly rateLimited: 7;
15
+ };
16
+ export type ExitCode = (typeof exitCodes)[keyof typeof exitCodes];
17
+ /** An error that knows which exit code it should end the process with. */
18
+ export declare class CliError extends Error {
19
+ readonly exitCode: ExitCode;
20
+ constructor(message: string, exitCode: ExitCode);
21
+ }
22
+ /** Bad or missing arguments: exit 2. */
23
+ export declare function usageError(message: string): CliError;
24
+ /** Exit code for a failed API response. */
25
+ export declare function exitCodeForResponse(status: number, code?: string): ExitCode;
26
+ export declare function exitCodeFor(error: unknown): ExitCode;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The CLI's process exit codes, one table for every command so an agent can
3
+ * branch on the outcome without parsing messages. Documented in the `cli`
4
+ * guidelines section; keep the two in step.
5
+ */
6
+ export const exitCodes = {
7
+ ok: 0,
8
+ error: 1,
9
+ usage: 2,
10
+ auth: 3,
11
+ notFound: 4,
12
+ revisionConflict: 5,
13
+ watchTimeout: 6,
14
+ rateLimited: 7,
15
+ };
16
+ /** An error that knows which exit code it should end the process with. */
17
+ export class CliError extends Error {
18
+ constructor(message, exitCode) {
19
+ super(message);
20
+ this.name = 'CliError';
21
+ this.exitCode = exitCode;
22
+ }
23
+ }
24
+ /** Bad or missing arguments: exit 2. */
25
+ export function usageError(message) {
26
+ return new CliError(message, exitCodes.usage);
27
+ }
28
+ /** Exit code for a failed API response. */
29
+ export function exitCodeForResponse(status, code) {
30
+ if (status === 401 || status === 403) {
31
+ return exitCodes.auth;
32
+ }
33
+ if (status === 404) {
34
+ return exitCodes.notFound;
35
+ }
36
+ if (status === 409 && code === 'revision_conflict') {
37
+ return exitCodes.revisionConflict;
38
+ }
39
+ if (status === 429) {
40
+ return exitCodes.rateLimited;
41
+ }
42
+ return exitCodes.error;
43
+ }
44
+ export function exitCodeFor(error) {
45
+ return error instanceof CliError ? error.exitCode : exitCodes.error;
46
+ }
47
+ //# sourceMappingURL=exit-codes.js.map
@@ -0,0 +1,10 @@
1
+ export declare function getRevisionBasesPath(): string;
2
+ export declare function getRememberedBase(host: string, artifactIdOrSlug: string): Promise<string | undefined>;
3
+ /**
4
+ * Remember `revisionId` as the base for every name in `artifactKeys`. When
5
+ * `supersedes` is given (a revise built on that revision), entries for this
6
+ * host still pointing at it move forward too — the artifact may have been
7
+ * pulled by id and revised by slug. Best-effort: bookkeeping must never fail
8
+ * the command that produced it.
9
+ */
10
+ export declare function rememberBase(host: string, artifactKeys: Array<string | undefined>, revisionId: string, supersedes?: string): Promise<void>;
@@ -0,0 +1,75 @@
1
+ import { __awaiter } from "tslib";
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { dirname, join } from 'node:path';
4
+ import { getConfigPath, normalizeHost } from './config.js';
5
+ /** Oldest entries are dropped past this, so the file cannot grow unbounded. */
6
+ const MAX_ENTRIES = 500;
7
+ export function getRevisionBasesPath() {
8
+ return join(dirname(getConfigPath()), 'revision-bases.json');
9
+ }
10
+ /** Keyed by host + the id or slug, since either can name an artifact. */
11
+ function entryKey(host, artifactIdOrSlug) {
12
+ return `${normalizeHost(host)} ${artifactIdOrSlug}`;
13
+ }
14
+ function readBases() {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ try {
18
+ const parsed = JSON.parse(yield readFile(getRevisionBasesPath(), 'utf8'));
19
+ return { bases: (_a = parsed.bases) !== null && _a !== void 0 ? _a : {} };
20
+ }
21
+ catch (_b) {
22
+ return { bases: {} };
23
+ }
24
+ });
25
+ }
26
+ function writeBases(file) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const entries = Object.entries(file.bases)
29
+ .sort(([, a], [, b]) => b.recordedAt.localeCompare(a.recordedAt))
30
+ .slice(0, MAX_ENTRIES);
31
+ const path = getRevisionBasesPath();
32
+ yield mkdir(dirname(path), { mode: 0o700, recursive: true });
33
+ yield writeFile(path, `${JSON.stringify({ bases: Object.fromEntries(entries) }, null, 2)}\n`, { mode: 0o600 });
34
+ });
35
+ }
36
+ export function getRememberedBase(host, artifactIdOrSlug) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ var _a;
39
+ const file = yield readBases();
40
+ return (_a = file.bases[entryKey(host, artifactIdOrSlug)]) === null || _a === void 0 ? void 0 : _a.revisionId;
41
+ });
42
+ }
43
+ /**
44
+ * Remember `revisionId` as the base for every name in `artifactKeys`. When
45
+ * `supersedes` is given (a revise built on that revision), entries for this
46
+ * host still pointing at it move forward too — the artifact may have been
47
+ * pulled by id and revised by slug. Best-effort: bookkeeping must never fail
48
+ * the command that produced it.
49
+ */
50
+ export function rememberBase(host, artifactKeys, revisionId, supersedes) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ try {
53
+ const file = yield readBases();
54
+ const recordedAt = new Date().toISOString();
55
+ const hostPrefix = `${normalizeHost(host)} `;
56
+ if (supersedes) {
57
+ for (const [key, entry] of Object.entries(file.bases)) {
58
+ if (key.startsWith(hostPrefix) && entry.revisionId === supersedes) {
59
+ file.bases[key] = { revisionId, recordedAt };
60
+ }
61
+ }
62
+ }
63
+ for (const artifactKey of artifactKeys) {
64
+ if (artifactKey) {
65
+ file.bases[entryKey(host, artifactKey)] = { revisionId, recordedAt };
66
+ }
67
+ }
68
+ yield writeBases(file);
69
+ }
70
+ catch (_a) {
71
+ // Without a remembered base, revise still works; the agent passes --base.
72
+ }
73
+ });
74
+ }
75
+ //# sourceMappingURL=revision-bases.js.map
@@ -1,10 +1,12 @@
1
1
  /**
2
- * The agent skill installed by `artis install-skill`: a compact guide to the
3
- * publish → review → revise loop using this CLI. Keep roughly in sync with
4
- * `getCliHelp()` and the server-side agent guidance in
5
- * `apps/app/src/worker/lib/skills.ts`.
2
+ * The agent skill installed by `artis install-skill`. Deliberately a router:
3
+ * it decides when to use Artis and which workflow applies, and defers every
4
+ * authoring rule and command detail to `artis guidelines`, which reads the
5
+ * server's current guidelines (`packages/sdk/src/lib/guidelines.ts`). An
6
+ * installed skill is never updated in place, so anything that changes over
7
+ * time belongs in the guidelines, not here.
6
8
  */
7
- export declare const ARTIS_SKILL_MD = "---\nname: artis\ndescription: >-\n Publish, review, and revise self-contained HTML artifacts on an Artis server\n with the artis CLI. Use when the deliverable should be an interactive page\n humans open in a browser (dashboards, timelines, prototypes, reports) rather\n than a markdown dump.\n---\n\n# Artis\n\nHost, share, and revise **self-contained HTML artifacts** at stable URLs.\n\n**Loop:** publish \u2192 get feedback \u2192 revise (optionally resolving annotations).\n\n## Setup\n\n npm install -g @artis-lab/cli\n artis login --host <url> # required before publishing\n artis whoami # verify credentials\n\n`artis login` opens a browser approval flow and stores the API key in `~/.artis/config.json`; never ask the user for a password. Hosts default to https://artis.xiispace.eu.org. Override with `--host`, `ARTIS_URL`, or a saved login \u2014 a self-hosted user never wants the default.\n\n## Commands\n\n artis publish artifact.html [--visibility unlisted|public|private] [--kind <kind>] [--title <t>] [--author <name>]\n artis artifact get <id-or-slug> [--json]\n artis artifact feedback <id-or-slug> [--json] [--revision <id>]\n artis artifact html <id-or-slug> [--output <path>] [--revision <id>]\n artis revise <id-or-slug> revised.html --summary \"...\" --base <revision-id> [--resolve <annotation-id>]...\n artis guidelines [section]\n artis annotate <id-or-slug> --comment \"...\" [--quote \"...\"] [--requested-change \"...\"] [--status open|needs-revision|resolved]\n artis reply <annotation-id> --comment \"...\"\n artis annotation edit <annotation-id> [--comment \"...\"] [--title \"...\"] [--requested-change \"...\"]\n artis annotation retract <annotation-id>\n artis share <id-or-slug> --email a@b.com --role viewer|commenter [--remove]\n\nRun `artis help` for the full flag reference.\n\n## Workflow\n\n1. Publish with the default `unlisted` visibility unless the user asks for public or private. Return the artifact URL and a short summary.\n2. Gather feedback with `artis artifact feedback <id>`; the printed prompt lists open annotations with their ids.\n3. Revise with a complete replacement document, passing `--base <revision-id>` (the revision you edited, printed by `publish` and `artifact html`) and `--resolve <annotation-id>` for each addressed annotation. If the file is no longer on disk, pull the current source first: `artis artifact html <id> --output revised.html`, edit it, then `artis revise`. A conflict means someone revised since: pull the current revision, reapply your changes, and retry with its id. Write the `--summary` one change per line.\n4. For authoring rules beyond this file, run `artis guidelines` (index) and `artis guidelines <section>`.\n\n## Authoring rules\n\n- Self-contained HTML with inline CSS and small scripts; avoid external dependencies unless asked.\n- Prefer visual structure (cards, timelines, diagrams) over long prose; semantic, responsive markup.\n- Theme via `prefers-color-scheme`; interactive artifacts should offer copy/export so users can paste changes back to you.\n- On failure, show the HTTP status and response body once; do not retry blindly.\n";
9
+ export declare const ARTIS_SKILL_MD = "---\nname: artis\ndescription: >-\n Use for any Artis task: whenever the user mentions Artis, shares an Artis\n artifact link, or asks about an Artis artifact's feedback, annotations,\n revisions, or sharing; and to publish a deliverable that is better as an\n interactive page humans open in a browser (report, dashboard, timeline,\n postmortem, plan, prototype, review) than as a markdown dump.\n---\n\n# Artis\n\nArtis hosts self-contained HTML artifacts at stable URLs for a publish \u2192 review \u2192 revise loop. Use the `artis` CLI for every Artis action. If Artis MCP tools are already available in this session, you may use them instead; they share the same server and guidelines.\n\n## First rule: read the guidelines before authoring\n\nBefore writing, publishing, or revising an artifact in a session, run:\n\n artis guidelines # index of sections\n artis guidelines authoring # what a good artifact looks like\n artis guidelines revising # before any revise\n\nTreat that output as the source of truth for authoring rules and command syntax; it is served by the Artis server and stays current, while this file does not. `artis guidelines cli` and `artis help` give the full command reference.\n\n## Workflows\n\n### Someone shares an Artis link or names an artifact\n\nDo not curl or web-fetch the page: it is an app shell, and private artifacts are served only through signed URLs. Use the CLI with the id or slug from the link (`/artifacts/<slug>`):\n\n1. `artis artifact get <id-or-slug>` for metadata and revisions; `artis artifact feedback <id-or-slug>` for open review threads.\n2. `artis artifact html <id-or-slug> --output <file>` when you need the source.\n3. Do what was asked, then report the result or URL.\n\n### New deliverable\n\n1. Read `artis guidelines authoring` if you have not in this session.\n2. Write one self-contained HTML file and save it locally.\n3. `artis publish <file>` \u2014 `unlisted` unless the user asks for public or private.\n4. Return the printed URL with a one-line summary.\n\n### Revising an existing artifact\n\nRevise it; never publish a second artifact for the same work.\n\n1. Read `artis guidelines revising` if you have not in this session.\n2. `artis artifact feedback <id-or-slug>` for the open annotations and their ids.\n3. If the current source is not on disk, `artis artifact html <id-or-slug> --output <file>`.\n4. Edit the file, then `artis revise <id-or-slug> <file> --summary \"...\" --resolve <annotation-id>` (one change per summary line). The CLI sends the revision it last saw as the base; a conflict means someone revised since \u2014 pull the current source, reapply your changes, and revise again.\n\n## When not to publish\n\nDo not publish to Artis if the user asks for Markdown, plain text, a PDF, an answer in chat, or another destination. You may still use the CLI to read an Artis artifact they mention.\n\n## Setup and auth\n\n npm install -g @artis-lab/cli\n artis login --host <url> # browser approval; stores an API key\n artis whoami\n\nNever ask the user for a password. Hosts default to https://artis.xiispace.eu.org; pass `--host` or set `ARTIS_URL` for a self-hosted server. If a command reports missing or invalid credentials, run `artis login` and retry once; if login cannot complete here, say so and ask the user to authenticate. On any other failure, show the HTTP status and error once; do not retry blindly.\n";
8
10
  export interface SkillHarnessDefinition {
9
11
  /** Canonical id accepted by `--harness` and printed by `--list`. */
10
12
  id: string;
@@ -7,63 +7,74 @@ import { collectFlagValues, hasFlag, parseFlagValue } from './args.js';
7
7
  /** Directory the skill installs under, inside each harness's skills dir. */
8
8
  const SKILL_DIR_NAME = 'artis';
9
9
  /**
10
- * The agent skill installed by `artis install-skill`: a compact guide to the
11
- * publish → review → revise loop using this CLI. Keep roughly in sync with
12
- * `getCliHelp()` and the server-side agent guidance in
13
- * `apps/app/src/worker/lib/skills.ts`.
10
+ * The agent skill installed by `artis install-skill`. Deliberately a router:
11
+ * it decides when to use Artis and which workflow applies, and defers every
12
+ * authoring rule and command detail to `artis guidelines`, which reads the
13
+ * server's current guidelines (`packages/sdk/src/lib/guidelines.ts`). An
14
+ * installed skill is never updated in place, so anything that changes over
15
+ * time belongs in the guidelines, not here.
14
16
  */
15
17
  export const ARTIS_SKILL_MD = `---
16
18
  name: artis
17
19
  description: >-
18
- Publish, review, and revise self-contained HTML artifacts on an Artis server
19
- with the artis CLI. Use when the deliverable should be an interactive page
20
- humans open in a browser (dashboards, timelines, prototypes, reports) rather
21
- than a markdown dump.
20
+ Use for any Artis task: whenever the user mentions Artis, shares an Artis
21
+ artifact link, or asks about an Artis artifact's feedback, annotations,
22
+ revisions, or sharing; and to publish a deliverable that is better as an
23
+ interactive page humans open in a browser (report, dashboard, timeline,
24
+ postmortem, plan, prototype, review) than as a markdown dump.
22
25
  ---
23
26
 
24
27
  # Artis
25
28
 
26
- Host, share, and revise **self-contained HTML artifacts** at stable URLs.
29
+ Artis hosts self-contained HTML artifacts at stable URLs for a publish → review → revise loop. Use the \`artis\` CLI for every Artis action. If Artis MCP tools are already available in this session, you may use them instead; they share the same server and guidelines.
27
30
 
28
- **Loop:** publish → get feedback → revise (optionally resolving annotations).
31
+ ## First rule: read the guidelines before authoring
29
32
 
30
- ## Setup
33
+ Before writing, publishing, or revising an artifact in a session, run:
31
34
 
32
- npm install -g @artis-lab/cli
33
- artis login --host <url> # required before publishing
34
- artis whoami # verify credentials
35
+ artis guidelines # index of sections
36
+ artis guidelines authoring # what a good artifact looks like
37
+ artis guidelines revising # before any revise
38
+
39
+ Treat that output as the source of truth for authoring rules and command syntax; it is served by the Artis server and stays current, while this file does not. \`artis guidelines cli\` and \`artis help\` give the full command reference.
40
+
41
+ ## Workflows
42
+
43
+ ### Someone shares an Artis link or names an artifact
44
+
45
+ Do not curl or web-fetch the page: it is an app shell, and private artifacts are served only through signed URLs. Use the CLI with the id or slug from the link (\`/artifacts/<slug>\`):
35
46
 
36
- \`artis login\` opens a browser approval flow and stores the API key in \`~/.artis/config.json\`; never ask the user for a password. Hosts default to https://artis.xiispace.eu.org. Override with \`--host\`, \`ARTIS_URL\`, or a saved login — a self-hosted user never wants the default.
47
+ 1. \`artis artifact get <id-or-slug>\` for metadata and revisions; \`artis artifact feedback <id-or-slug>\` for open review threads.
48
+ 2. \`artis artifact html <id-or-slug> --output <file>\` when you need the source.
49
+ 3. Do what was asked, then report the result or URL.
37
50
 
38
- ## Commands
51
+ ### New deliverable
39
52
 
40
- artis publish artifact.html [--visibility unlisted|public|private] [--kind <kind>] [--title <t>] [--author <name>]
41
- artis artifact get <id-or-slug> [--json]
42
- artis artifact feedback <id-or-slug> [--json] [--revision <id>]
43
- artis artifact html <id-or-slug> [--output <path>] [--revision <id>]
44
- artis revise <id-or-slug> revised.html --summary "..." --base <revision-id> [--resolve <annotation-id>]...
45
- artis guidelines [section]
46
- artis annotate <id-or-slug> --comment "..." [--quote "..."] [--requested-change "..."] [--status open|needs-revision|resolved]
47
- artis reply <annotation-id> --comment "..."
48
- artis annotation edit <annotation-id> [--comment "..."] [--title "..."] [--requested-change "..."]
49
- artis annotation retract <annotation-id>
50
- artis share <id-or-slug> --email a@b.com --role viewer|commenter [--remove]
53
+ 1. Read \`artis guidelines authoring\` if you have not in this session.
54
+ 2. Write one self-contained HTML file and save it locally.
55
+ 3. \`artis publish <file>\` — \`unlisted\` unless the user asks for public or private.
56
+ 4. Return the printed URL with a one-line summary.
51
57
 
52
- Run \`artis help\` for the full flag reference.
58
+ ### Revising an existing artifact
53
59
 
54
- ## Workflow
60
+ Revise it; never publish a second artifact for the same work.
55
61
 
56
- 1. Publish with the default \`unlisted\` visibility unless the user asks for public or private. Return the artifact URL and a short summary.
57
- 2. Gather feedback with \`artis artifact feedback <id>\`; the printed prompt lists open annotations with their ids.
58
- 3. Revise with a complete replacement document, passing \`--base <revision-id>\` (the revision you edited, printed by \`publish\` and \`artifact html\`) and \`--resolve <annotation-id>\` for each addressed annotation. If the file is no longer on disk, pull the current source first: \`artis artifact html <id> --output revised.html\`, edit it, then \`artis revise\`. A conflict means someone revised since: pull the current revision, reapply your changes, and retry with its id. Write the \`--summary\` one change per line.
59
- 4. For authoring rules beyond this file, run \`artis guidelines\` (index) and \`artis guidelines <section>\`.
62
+ 1. Read \`artis guidelines revising\` if you have not in this session.
63
+ 2. \`artis artifact feedback <id-or-slug>\` for the open annotations and their ids.
64
+ 3. If the current source is not on disk, \`artis artifact html <id-or-slug> --output <file>\`.
65
+ 4. Edit the file, then \`artis revise <id-or-slug> <file> --summary "..." --resolve <annotation-id>\` (one change per summary line). The CLI sends the revision it last saw as the base; a conflict means someone revised since — pull the current source, reapply your changes, and revise again.
60
66
 
61
- ## Authoring rules
67
+ ## When not to publish
68
+
69
+ Do not publish to Artis if the user asks for Markdown, plain text, a PDF, an answer in chat, or another destination. You may still use the CLI to read an Artis artifact they mention.
70
+
71
+ ## Setup and auth
72
+
73
+ npm install -g @artis-lab/cli
74
+ artis login --host <url> # browser approval; stores an API key
75
+ artis whoami
62
76
 
63
- - Self-contained HTML with inline CSS and small scripts; avoid external dependencies unless asked.
64
- - Prefer visual structure (cards, timelines, diagrams) over long prose; semantic, responsive markup.
65
- - Theme via \`prefers-color-scheme\`; interactive artifacts should offer copy/export so users can paste changes back to you.
66
- - On failure, show the HTTP status and response body once; do not retry blindly.
77
+ Never ask the user for a password. Hosts default to https://artis.xiispace.eu.org; pass \`--host\` or set \`ARTIS_URL\` for a self-hosted server. If a command reports missing or invalid credentials, run \`artis login\` and retry once; if login cannot complete here, say so and ask the user to authenticate. On any other failure, show the HTTP status and error once; do not retry blindly.
67
78
  `;
68
79
  /** Hermes keeps its config under $HERMES_HOME when set, otherwise
69
80
  * `%LOCALAPPDATA%\hermes` on Windows and `~/.hermes` elsewhere — mirroring