@artis-lab/cli 0.4.1 → 0.5.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.4.1",
3
+ "version": "0.5.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/lib/cli.d.ts CHANGED
@@ -33,6 +33,12 @@ export declare function publishArtifactFromCli(args: string[]): Promise<Publishe
33
33
  export declare function loginFromCli(args: string[]): Promise<void>;
34
34
  export declare function whoamiFromCli(args: string[]): Promise<void>;
35
35
  export declare function getArtifactFromCli(args: string[]): Promise<void>;
36
+ /**
37
+ * Read a revision's stored HTML back. `revise` takes a complete replacement
38
+ * document, so this is the way to edit an artifact that is no longer on disk:
39
+ * `artis artifact html <id> --output report.html`, edit, then `artis revise`.
40
+ */
41
+ export declare function getArtifactHtmlFromCli(args: string[]): Promise<void>;
36
42
  export declare function getArtifactFeedbackFromCli(args: string[]): Promise<void>;
37
43
  export declare function shareArtifactFromCli(args: string[]): Promise<void>;
38
44
  export declare function reviseArtifactFromCli(args: string[]): Promise<void>;
package/src/lib/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { spawn } from 'node:child_process';
3
- import { readFile } from 'node:fs/promises';
3
+ import { readFile, writeFile } from 'node:fs/promises';
4
4
  import { basename, extname } from 'node:path';
5
5
  // `@artis/sdk` is a type-only dependency here: the CLI's tsc output can't
6
6
  // resolve the package specifier at runtime, so these two trivial helpers are
@@ -373,6 +373,7 @@ Usage:
373
373
  artis whoami [--host <url>]
374
374
  artis publish artifact.html [options]
375
375
  artis artifact get <artifact-id-or-slug> [--json]
376
+ artis artifact html <artifact-id-or-slug> [--output <path>] [--revision <revision-id>] [--json]
376
377
  artis artifact feedback <artifact-id-or-slug> [--json] [--revision <revision-id>]
377
378
  artis share <artifact-id-or-slug> [--email <email> --role <viewer|commenter>] [--remove]
378
379
  artis revise <artifact-id-or-slug> artifact.html --summary <text> [--resolve <annotation-id>]
@@ -402,6 +403,8 @@ Options:
402
403
  --text-end <n> Document offset where the quote ends (annotate, TextPositionSelector).
403
404
  --rect <x,y,w,h> Canvas point/rect as percentages (annotate, FragmentSelector). w,h default to 0.
404
405
  --pin-label <text> Short label shown on the artifact canvas pin (annotate).
406
+ --output <path> Write the artifact HTML to this file (artifact html). Without it, the document goes to stdout.
407
+ --revision <revision-id> Revision to read (artifact html, artifact feedback). Defaults to the current revision.
405
408
  --email <email> Email address for artis share.
406
409
  --role <role> Share role: viewer or commenter. Defaults to viewer.
407
410
  --remove Remove the email from an artifact share list.
@@ -413,6 +416,7 @@ Examples (--host is optional; without it commands target https://artis.xiispace.
413
416
  artis publish report.html --host https://artis.example.com --visibility private
414
417
  artis share artifact-slug --host https://artis.example.com --email reviewer@example.com --role commenter
415
418
  artis artifact get artifact-slug --host https://artis.example.com --json
419
+ artis artifact html artifact-slug --output report.html
416
420
  artis artifact feedback artifact-slug --host https://artis.example.com --json
417
421
  artis annotate artifact-slug --host https://artis.example.com --comment "Tighten this heading" --quote "Checkout latency" --requested-change "Add the affected checkout count"
418
422
  artis reply annotation-123 --host https://artis.example.com --comment "Addressed in the latest revision"
@@ -539,6 +543,43 @@ export function getArtifactFromCli(args) {
539
543
  console.log(`Open annotations: ${((_a = result.annotations) !== null && _a !== void 0 ? _a : []).filter((annotation) => isRootAnnotation(annotation) && annotation['artis:status'] !== 'resolved').length}`);
540
544
  });
541
545
  }
546
+ /**
547
+ * Read a revision's stored HTML back. `revise` takes a complete replacement
548
+ * document, so this is the way to edit an artifact that is no longer on disk:
549
+ * `artis artifact html <id> --output report.html`, edit, then `artis revise`.
550
+ */
551
+ export function getArtifactHtmlFromCli(args) {
552
+ return __awaiter(this, void 0, void 0, function* () {
553
+ const [artifactId] = getPositionals(args);
554
+ if (!artifactId) {
555
+ throw new Error('Usage: artis artifact html <artifact-id-or-slug> [--output <path>] [--revision <revision-id>]');
556
+ }
557
+ const target = yield resolveOptionalTarget(args);
558
+ const revisionId = parseFlagValue(args, '--revision');
559
+ const query = revisionId
560
+ ? `?revisionId=${encodeURIComponent(revisionId)}`
561
+ : '';
562
+ const result = yield apiFetchOptional(target, `/api/artifacts/${encodeURIComponent(artifactId)}/html${query}`);
563
+ if (hasFlag(args, '--json')) {
564
+ console.log(JSON.stringify(result, null, 2));
565
+ return;
566
+ }
567
+ if (!(result === null || result === void 0 ? void 0 : result.html)) {
568
+ throw new Error('Artifact response did not include revision HTML.');
569
+ }
570
+ const outputPath = parseFlagValue(args, '--output');
571
+ if (!outputPath) {
572
+ // No --output: the document goes to stdout so it can be piped or
573
+ // redirected. Progress lines would corrupt that, so print nothing else.
574
+ process.stdout.write(result.html);
575
+ return;
576
+ }
577
+ yield writeFile(outputPath, result.html, 'utf8');
578
+ console.log(`Wrote ${outputPath}`);
579
+ console.log(`Revision: ${result.revisionId}`);
580
+ console.log(`Version: ${result.version}`);
581
+ });
582
+ }
542
583
  export function getArtifactFeedbackFromCli(args) {
543
584
  return __awaiter(this, void 0, void 0, function* () {
544
585
  const [artifactId] = getPositionals(args);
@@ -775,6 +816,10 @@ export function runArtisCli() {
775
816
  yield getArtifactFromCli(rest.slice(1));
776
817
  return;
777
818
  }
819
+ if (command === 'artifact' && rest[0] === 'html') {
820
+ yield getArtifactHtmlFromCli(rest.slice(1));
821
+ return;
822
+ }
778
823
  if (command === 'artifact' && rest[0] === 'feedback') {
779
824
  yield getArtifactFeedbackFromCli(rest.slice(1));
780
825
  return;