@artis-lab/cli 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,7 +48,7 @@ Defaults:
48
48
 
49
49
  ```bash
50
50
  artis artifact feedback artifact-slug
51
- artis revise artifact-slug revised.html --summary "Addressed review feedback"
51
+ artis revise artifact-slug revised.html --summary "Addressed review feedback" --base <revision-id>
52
52
  artis share artifact-slug --email reviewer@example.com --role commenter
53
53
  artis annotate artifact-slug --comment "Tighten this heading" --quote "Checkout latency"
54
54
  artis reply annotation-123 --comment "Fixed in revision 2."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artis-lab/cli",
3
- "version": "0.6.0",
3
+ "version": "0.7.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
@@ -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", "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", "whoami"];
6
6
  export type ArtisCommand = (typeof commands)[number];
7
7
  /**
8
8
  * Mirrors the sdk's `ArtifactVisibility`, deliberately re-declared instead of
@@ -23,6 +23,12 @@ export interface PublishedArtifactResult {
23
23
  url: string;
24
24
  visibility: CliArtifactVisibility;
25
25
  }
26
+ /**
27
+ * Print the server's agent guidelines: the section index by default, or one
28
+ * section (`authoring`, `revising`, …, or `all`). Same content as MCP
29
+ * `get_authoring_guidelines`; served as `/skills.md?section=`.
30
+ */
31
+ export declare function guidelinesFromCli(args: string[]): Promise<void>;
26
32
  /**
27
33
  * Validate a login `verificationUrl` returned by the configured host before it
28
34
  * crosses a local process/shell boundary (Windows `cmd /c start`). A malicious
package/src/lib/cli.js CHANGED
@@ -22,6 +22,7 @@ export const commands = [
22
22
  'annotate',
23
23
  'annotation',
24
24
  'artifact',
25
+ 'guidelines',
25
26
  'help',
26
27
  'install-skill',
27
28
  'login',
@@ -81,6 +82,7 @@ const valueFlags = new Set([
81
82
  '--revision',
82
83
  '--role',
83
84
  '--status',
85
+ '--base',
84
86
  '--summary',
85
87
  '--text-end',
86
88
  '--text-start',
@@ -235,6 +237,24 @@ function resolveOptionalTarget(args) {
235
237
  return { apiKey, apiKeySource, baseUrl };
236
238
  });
237
239
  }
240
+ /**
241
+ * Print the server's agent guidelines: the section index by default, or one
242
+ * section (`authoring`, `revising`, …, or `all`). Same content as MCP
243
+ * `get_authoring_guidelines`; served as `/skills.md?section=`.
244
+ */
245
+ export function guidelinesFromCli(args) {
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ const [section] = getPositionals(args);
248
+ const config = yield readCliConfig();
249
+ const baseUrl = resolveBaseUrl(args, config);
250
+ const response = yield fetch(`${baseUrl}/skills.md?section=${encodeURIComponent(section !== null && section !== void 0 ? section : 'index')}`);
251
+ const text = yield response.text();
252
+ if (!response.ok) {
253
+ throw new Error(text.trim() || `Guidelines request failed with ${response.status}.`);
254
+ }
255
+ process.stdout.write(text.endsWith('\n') ? text : `${text}\n`);
256
+ });
257
+ }
238
258
  function parsePublishOptions(args) {
239
259
  return __awaiter(this, void 0, void 0, function* () {
240
260
  var _a, _b, _c, _d;
@@ -268,7 +288,11 @@ function apiFetch(credentials_1, path_1) {
268
288
  const response = yield fetch(`${credentials.baseUrl}${path}`, Object.assign(Object.assign({}, init), { headers: Object.assign({ authorization: `Bearer ${credentials.apiKey}`, 'content-type': 'application/json' }, init.headers) }));
269
289
  const payload = yield readJsonResponse(response);
270
290
  if (!response.ok) {
271
- throw new Error((_a = payload === null || payload === void 0 ? void 0 : payload.error) !== null && _a !== void 0 ? _a : `Request failed with ${response.status}.`);
291
+ const message = (_a = payload === null || payload === void 0 ? void 0 : payload.error) !== null && _a !== void 0 ? _a : `Request failed with ${response.status}.`;
292
+ // A revise conflict is only recoverable with the current revision id.
293
+ throw new Error((payload === null || payload === void 0 ? void 0 : payload.currentRevisionId)
294
+ ? `${message} Current revision: ${payload.currentRevisionId}.`
295
+ : message);
272
296
  }
273
297
  return payload;
274
298
  });
@@ -368,13 +392,14 @@ Usage:
368
392
  artis --version
369
393
  artis login [--host <url>]
370
394
  artis whoami [--host <url>]
395
+ artis guidelines [section] [--host <url>]
371
396
  artis install-skill [--harness <id>]... [--yes] [--dir <path>] [--force] [--list] [--json]
372
397
  artis publish artifact.html [options]
373
398
  artis artifact get <artifact-id-or-slug> [--json]
374
399
  artis artifact html <artifact-id-or-slug> [--output <path>] [--revision <revision-id>] [--json]
375
400
  artis artifact feedback <artifact-id-or-slug> [--json] [--revision <revision-id>]
376
401
  artis share <artifact-id-or-slug> [--email <email> --role <viewer|commenter>] [--remove]
377
- artis revise <artifact-id-or-slug> artifact.html --summary <text> [--resolve <annotation-id>]
402
+ artis revise <artifact-id-or-slug> artifact.html --summary <text> [--base <revision-id>] [--resolve <annotation-id>]
378
403
  artis annotate <artifact-id-or-slug> --comment <text> [anchor options]
379
404
  artis reply <annotation-id> --comment <text>
380
405
  artis annotation edit <annotation-id> [--comment <text>] [--title <text>] [--requested-change <text>]
@@ -388,7 +413,8 @@ Options:
388
413
  --visibility <value> public, unlisted, or private. Defaults to unlisted.
389
414
  --kind <value> Artifact kind. Defaults to custom-html.
390
415
  --author <name> Artifact author/agent name. Defaults to Artis CLI.
391
- --summary <text> Revision summary.
416
+ --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.
392
418
  --resolve <annotation-id> Mark an annotation resolved when revising. Repeatable.
393
419
  --comment <text> Annotation or reply comment text (annotate, reply).
394
420
  --requested-change <text> Structured change request for the artifact author (annotate).
@@ -425,8 +451,9 @@ Examples (--host is optional; without it commands target https://artis.xiispace.
425
451
  artis reply annotation-123 --host https://artis.example.com --comment "Addressed in the latest revision"
426
452
  artis annotation edit annotation-123 --host https://artis.example.com --comment "Corrected: the latency spike is on checkout, not search"
427
453
  artis annotation retract annotation-123 --host https://artis.example.com
454
+ artis guidelines authoring
428
455
  artis install-skill --yes
429
- artis revise artifact-slug report.html --host https://artis.example.com --summary "Addressed open feedback" --resolve annotation-123`;
456
+ artis revise artifact-slug report.html --host https://artis.example.com --summary "Addressed open feedback" --base revision-abc --resolve annotation-123`;
430
457
  }
431
458
  // Annotated rather than inferred: the returned `visibility` flows through the
432
459
  // sdk's `CreateArtifactInput`, so declaration emit would otherwise print an
@@ -661,7 +688,7 @@ export function reviseArtifactFromCli(args) {
661
688
  const [artifactId, filePath] = getPositionals(args);
662
689
  const summary = parseFlagValue(args, '--summary');
663
690
  if (!artifactId || !filePath) {
664
- throw new Error('Usage: artis revise <artifact-id-or-slug> artifact.html --summary <text>');
691
+ throw new Error('Usage: artis revise <artifact-id-or-slug> artifact.html --summary <text> [--base <revision-id>]');
665
692
  }
666
693
  if (!summary) {
667
694
  throw new Error('Missing --summary for revision.');
@@ -676,6 +703,7 @@ export function reviseArtifactFromCli(args) {
676
703
  body: JSON.stringify({
677
704
  authorName: (_a = parseFlagValue(args, '--author')) !== null && _a !== void 0 ? _a : 'Artis CLI',
678
705
  html,
706
+ baseRevisionId: parseFlagValue(args, '--base'),
679
707
  resolvedAnnotationIds: collectFlagValues(args, '--resolve'),
680
708
  source: 'cli',
681
709
  summary,
@@ -807,6 +835,10 @@ export function runArtisCli() {
807
835
  yield whoamiFromCli(rest);
808
836
  return;
809
837
  }
838
+ if (command === 'guidelines') {
839
+ yield guidelinesFromCli(rest);
840
+ return;
841
+ }
810
842
  if (command === 'publish') {
811
843
  const published = yield publishArtifactFromCli(rest);
812
844
  if (hasFlag(rest, '--json')) {
@@ -4,7 +4,7 @@
4
4
  * `getCliHelp()` and the server-side agent guidance in
5
5
  * `apps/app/src/worker/lib/skills.ts`.
6
6
  */
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 \"...\" [--resolve <annotation-id>]...\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 `--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`.\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";
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";
8
8
  export interface SkillHarnessDefinition {
9
9
  /** Canonical id accepted by `--harness` and printed by `--list`. */
10
10
  id: string;
@@ -41,7 +41,8 @@ Host, share, and revise **self-contained HTML artifacts** at stable URLs.
41
41
  artis artifact get <id-or-slug> [--json]
42
42
  artis artifact feedback <id-or-slug> [--json] [--revision <id>]
43
43
  artis artifact html <id-or-slug> [--output <path>] [--revision <id>]
44
- artis revise <id-or-slug> revised.html --summary "..." [--resolve <annotation-id>]...
44
+ artis revise <id-or-slug> revised.html --summary "..." --base <revision-id> [--resolve <annotation-id>]...
45
+ artis guidelines [section]
45
46
  artis annotate <id-or-slug> --comment "..." [--quote "..."] [--requested-change "..."] [--status open|needs-revision|resolved]
46
47
  artis reply <annotation-id> --comment "..."
47
48
  artis annotation edit <annotation-id> [--comment "..."] [--title "..."] [--requested-change "..."]
@@ -54,7 +55,8 @@ Run \`artis help\` for the full flag reference.
54
55
 
55
56
  1. Publish with the default \`unlisted\` visibility unless the user asks for public or private. Return the artifact URL and a short summary.
56
57
  2. Gather feedback with \`artis artifact feedback <id>\`; the printed prompt lists open annotations with their ids.
57
- 3. Revise with a complete replacement document, passing \`--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\`.
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>\`.
58
60
 
59
61
  ## Authoring rules
60
62