@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.
package/README.md CHANGED
@@ -6,8 +6,8 @@ for what AI agents build.
6
6
 
7
7
  Server commands default to the hosted instance at
8
8
  <https://artis.xiispace.eu.org>. Artis is also self-hostable — point the CLI at
9
- your own deployment with `--host`, `ARTIS_URL`, or a saved login, any of which
10
- takes precedence over the default.
9
+ your own deployment by signing in to it (`artis login --host <url>`); every
10
+ other command then uses that server until you log in to another.
11
11
 
12
12
  ## Install
13
13
 
@@ -30,17 +30,20 @@ artis whoami
30
30
  artis publish artifact.html
31
31
  ```
32
32
 
33
- Against a self-hosted deployment, pass `--host` (or save it once via
34
- `artis login --host https://artis.example.com`):
33
+ Against a self-hosted deployment, sign in to it once; the commands after
34
+ that use it:
35
35
 
36
36
  ```bash
37
- artis publish artifact.html --host https://artis.example.com
37
+ artis login --host https://artis.example.com
38
+ artis publish artifact.html
38
39
  ```
39
40
 
41
+ Only `login` and `whoami` take `--host` (alias `--url`).
42
+
40
43
  Defaults:
41
44
 
42
- - Host: `--host`, then `ARTIS_URL`, then saved config, then
43
- `https://artis.xiispace.eu.org`
45
+ - Host: the server `artis login` saved last, then
46
+ `https://artis.xiispace.eu.org` (`login` and `whoami`: `--host` first)
44
47
  - `visibility=unlisted`
45
48
  - `author=Artis CLI`
46
49
 
@@ -103,9 +106,13 @@ artis -h
103
106
  artis artifact -h
104
107
  artis artifact files -h
105
108
  artis help data set
106
- artis help --all # full legacy reference
109
+ artis help --all # every command and flag on one page
107
110
  ```
108
111
 
112
+ Each command's flags and arguments are declared once, in the command tree
113
+ (`src/lib/commands.ts`): parsing, validation, `-h` at every level and
114
+ `help --all` all come from it.
115
+
109
116
  The CLI prints concise suggested next actions to stderr after publish, revise
110
117
  and feedback when applicable (e.g. inspect files when there are open review
111
118
  threads, or watch from the returned cursor when there are none). They are optional, not executed automatically. Existing
@@ -153,9 +160,6 @@ few trivial helpers are inlined rather than imported so nothing resolves the
153
160
  workspace-only package at runtime. Keep it that way — a runtime import would
154
161
  break every installed copy.
155
162
 
156
- Both halves of that rule are enforced by `npm run test:cli`, not by convention:
157
- it imports from `dist/`, so a runtime import fails immediately, and it asserts
158
- that no emitted `.d.ts` mentions `@artis/sdk`. The second check matters because
159
- declaration emit leaks the specifier as soon as an sdk-typed symbol reaches an
160
- _exported_ declaration — which is why `CliArtifactVisibility` is re-declared
161
- locally and `publishArtifactFromCli` has an explicit return type.
163
+ `npm run test:cli` enforces that rule, not convention: it runs from `dist/`,
164
+ and asserts that no built file imports an `@artis/*` package. The package is
165
+ a command only (`bin`): it exports no library and ships no declarations.
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "@artis-lab/cli",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Agent-first CLI for creating, sharing and maintaining artifacts on Artis, an open-source, self-hostable place for what AI agents build.",
5
5
  "type": "module",
6
- "main": "./src/index.js",
7
- "types": "./src/index.d.ts",
8
6
  "bin": {
9
7
  "artis": "./src/bin.js"
10
8
  },
11
9
  "files": [
12
10
  "src/**/*.js",
13
- "src/**/*.d.ts",
14
11
  "README.md",
15
12
  "LICENSE"
16
13
  ],
@@ -21,7 +18,7 @@
21
18
  "access": "public"
22
19
  },
23
20
  "scripts": {
24
- "prepublishOnly": "node -e \"require('node:fs').existsSync('src/index.js') || (console.error('Publish the build output: npm run publish:cli'), process.exit(1))\""
21
+ "prepublishOnly": "node -e \"require('node:fs').existsSync('src/bin.js') || (console.error('Publish the build output: npm run publish:cli'), process.exit(1))\""
25
22
  },
26
23
  "repository": {
27
24
  "type": "git",
package/src/bin.js CHANGED
@@ -1,12 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runAgentCli
4
- } from "./lib/chunk-CCCATRMP.js";
5
- import "./lib/chunk-Q5KBGVKT.js";
6
- import "./lib/chunk-KJV7R7DE.js";
4
+ } from "./lib/chunk-VLYS5R67.js";
5
+ import "./lib/chunk-VBJGJXYL.js";
6
+ import "./lib/chunk-JPCT7RRK.js";
7
+ import "./lib/chunk-43WVFZLO.js";
8
+ import "./lib/chunk-JYMG2Y6C.js";
9
+ import "./lib/chunk-2LRPXCLL.js";
10
+ import "./lib/chunk-QZFIUZXT.js";
11
+ import "./lib/chunk-IZYFOV2K.js";
12
+ import "./lib/chunk-46DMRA3V.js";
13
+ import "./lib/chunk-43EXTJSU.js";
14
+ import "./lib/chunk-IKQ5U3DH.js";
7
15
  import {
8
16
  exitCodeFor
9
- } from "./lib/chunk-H32QAUSA.js";
17
+ } from "./lib/chunk-HUWOFEEU.js";
10
18
 
11
19
  // packages/cli/src/bin.ts
12
20
  runAgentCli().catch((error) => {
package/src/lib/app.js CHANGED
@@ -1,9 +1,17 @@
1
1
  import {
2
2
  runAgentCli
3
- } from "./chunk-CCCATRMP.js";
4
- import "./chunk-Q5KBGVKT.js";
5
- import "./chunk-KJV7R7DE.js";
6
- import "./chunk-H32QAUSA.js";
3
+ } from "./chunk-VLYS5R67.js";
4
+ import "./chunk-VBJGJXYL.js";
5
+ import "./chunk-JPCT7RRK.js";
6
+ import "./chunk-43WVFZLO.js";
7
+ import "./chunk-JYMG2Y6C.js";
8
+ import "./chunk-2LRPXCLL.js";
9
+ import "./chunk-QZFIUZXT.js";
10
+ import "./chunk-IZYFOV2K.js";
11
+ import "./chunk-46DMRA3V.js";
12
+ import "./chunk-43EXTJSU.js";
13
+ import "./chunk-IKQ5U3DH.js";
14
+ import "./chunk-HUWOFEEU.js";
7
15
  export {
8
16
  runAgentCli
9
17
  };
@@ -1,9 +1,3 @@
1
- import {
2
- collectFlagValues,
3
- hasFlag,
4
- parseFlagValue
5
- } from "./chunk-KJV7R7DE.js";
6
-
7
1
  // packages/cli/src/lib/skill-install.ts
8
2
  import { spawnSync } from "node:child_process";
9
3
  import { mkdir, stat, writeFile } from "node:fs/promises";
@@ -79,7 +73,7 @@ Do not publish to Artis if the user asks for Markdown, plain text, a PDF, an ans
79
73
  artis login --host <url> # browser approval; stores OAuth tokens
80
74
  artis whoami
81
75
 
82
- 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.
76
+ Never ask the user for a password. Hosts default to https://artis.xiispace.eu.org; for a self-hosted server run \`artis login --host <url>\` once, and every command uses it until you log in to another. 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.
83
77
  `;
84
78
  function hermesHomeDir(home) {
85
79
  const fromEnv = process.env["HERMES_HOME"];
@@ -204,7 +198,7 @@ async function getSkillHarnessReports(home) {
204
198
  }
205
199
  return reports;
206
200
  }
207
- async function installSkillFile(skillPath, force) {
201
+ async function installSkillFile(skillPath, force = false) {
208
202
  const existed = await pathExists(skillPath, "file");
209
203
  if (existed && !force) {
210
204
  return "skipped";
@@ -225,22 +219,13 @@ function printHarnessTable(reports) {
225
219
  );
226
220
  }
227
221
  }
228
- async function installSkillFromCli(args, options = {}) {
222
+ async function listSkillHarnesses(options = {}) {
223
+ return getSkillHarnessReports(options.home ?? homedir());
224
+ }
225
+ async function installSkill(input, options = {}) {
229
226
  const home = options.home ?? homedir();
230
- const json = hasFlag(args, "--json");
231
- const force = hasFlag(args, "--force");
232
- if (hasFlag(args, "--list")) {
233
- const reports = await getSkillHarnessReports(home);
234
- if (json) {
235
- console.log(JSON.stringify({ harnesses: reports }, null, 2));
236
- } else {
237
- printHarnessTable(reports);
238
- }
239
- return;
240
- }
241
- const harnessValues = collectFlagValues(args, "--harness");
242
- const dir = parseFlagValue(args, "--dir");
243
- const yes = hasFlag(args, "--yes");
227
+ const harnessValues = (input.harness ?? []).filter(Boolean);
228
+ const { dir, yes } = input;
244
229
  if (dir && (harnessValues.length > 0 || yes)) {
245
230
  throw new Error("Pass either --dir or --harness/--yes, not both.");
246
231
  }
@@ -278,7 +263,7 @@ async function installSkillFromCli(args, options = {}) {
278
263
  const errors = [];
279
264
  for (const target of targets) {
280
265
  try {
281
- const status = await installSkillFile(target.skillPath, force);
266
+ const status = await installSkillFile(target.skillPath, input.force);
282
267
  results.push({ target: target.target, status, path: target.skillPath });
283
268
  } catch (error) {
284
269
  errors.push({
@@ -287,30 +272,19 @@ async function installSkillFromCli(args, options = {}) {
287
272
  });
288
273
  }
289
274
  }
290
- if (json) {
291
- console.log(JSON.stringify({ results, errors }, null, 2));
292
- } else {
293
- for (const result of results) {
294
- if (result.status === "skipped") {
295
- console.log(
296
- `Skipped ${result.target} (already installed; use --force to overwrite): ${result.path}`
297
- );
298
- } else {
299
- console.log(
300
- `${result.status === "updated" ? "Updated" : "Installed"} artis skill for ${result.target}: ${result.path}`
301
- );
302
- }
303
- }
304
- }
305
- if (errors.length > 0) {
306
- for (const failure of errors) {
307
- console.error(
308
- `install-skill failed for ${failure.target}: ${failure.error}`
275
+ return { results, errors };
276
+ }
277
+ function printInstallResults(results) {
278
+ for (const result of results) {
279
+ if (result.status === "skipped") {
280
+ console.log(
281
+ `Skipped ${result.target} (already installed; use --force to overwrite): ${result.path}`
282
+ );
283
+ } else {
284
+ console.log(
285
+ `${result.status === "updated" ? "Updated" : "Installed"} artis skill for ${result.target}: ${result.path}`
309
286
  );
310
287
  }
311
- throw new Error(
312
- `install-skill completed with errors (${errors.map((failure) => failure.target).join(", ")}).`
313
- );
314
288
  }
315
289
  }
316
290
 
@@ -319,5 +293,8 @@ export {
319
293
  skillPathFor,
320
294
  parseHarnessIds,
321
295
  getSkillHarnessReports,
322
- installSkillFromCli
296
+ printHarnessTable,
297
+ listSkillHarnesses,
298
+ installSkill,
299
+ printInstallResults
323
300
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usageError
3
- } from "./chunk-H32QAUSA.js";
3
+ } from "./chunk-HUWOFEEU.js";
4
4
 
5
5
  // packages/cli/src/lib/files.ts
6
6
  import { createHash } from "node:crypto";
@@ -18,6 +18,12 @@ var CliError = class extends Error {
18
18
  this.exitCode = exitCode;
19
19
  }
20
20
  };
21
+ function withRecovery(error, code, recovery) {
22
+ if (error instanceof CliError && error.exitCode === code) {
23
+ error.recovery = recovery();
24
+ }
25
+ return error;
26
+ }
21
27
  function usageError(message) {
22
28
  return new CliError(message, exitCodes.usage);
23
29
  }
@@ -43,6 +49,7 @@ function exitCodeFor(error) {
43
49
  export {
44
50
  exitCodes,
45
51
  CliError,
52
+ withRecovery,
46
53
  usageError,
47
54
  exitCodeForResponse,
48
55
  exitCodeFor
@@ -0,0 +1,146 @@
1
+ import {
2
+ exitCodes
3
+ } from "./chunk-HUWOFEEU.js";
4
+
5
+ // packages/cli/src/lib/next-actions.ts
6
+ function action(id, description, argv, kind = "suggestion", effect = "read") {
7
+ return { id, description, argv, kind, effect };
8
+ }
9
+ function publishedActions(artifactId) {
10
+ return [
11
+ action("read-feedback", "Read review feedback", [
12
+ "artifact",
13
+ "feedback",
14
+ artifactId
15
+ ])
16
+ ];
17
+ }
18
+ function feedbackActions(artifactId, cursor, openThreads) {
19
+ if (openThreads > 0) {
20
+ return [
21
+ action("read-source", "List the current revision files before editing", [
22
+ "artifact",
23
+ "files",
24
+ artifactId
25
+ ])
26
+ ];
27
+ }
28
+ if (cursor !== void 0 && /^\d+$/.test(String(cursor))) {
29
+ return [
30
+ action("watch-feedback", "Wait up to 30s for new feedback", [
31
+ "watch",
32
+ artifactId,
33
+ "--since",
34
+ String(cursor),
35
+ "--once",
36
+ "--timeout",
37
+ "30s"
38
+ ])
39
+ ];
40
+ }
41
+ return [];
42
+ }
43
+ function reviseConflictActions(artifact) {
44
+ return [
45
+ action(
46
+ "read-latest",
47
+ "Inspect latest files, download to a new path and reconcile before revising",
48
+ ["artifact", "files", artifact],
49
+ "recovery"
50
+ )
51
+ ];
52
+ }
53
+ function signInActions(host) {
54
+ return [
55
+ action(
56
+ "sign-in",
57
+ "Sign in to this server in the browser",
58
+ host ? ["login", "--host", host] : ["login"],
59
+ "recovery",
60
+ "write"
61
+ )
62
+ ];
63
+ }
64
+ function dataConflictActions(artifact, path) {
65
+ return [
66
+ action(
67
+ "read-latest",
68
+ "Re-read the document and reapply the intended change before retrying",
69
+ ["data", "get", artifact, path],
70
+ "recovery"
71
+ )
72
+ ];
73
+ }
74
+ function recoveryActions(code, route) {
75
+ const help = (id, description, argv) => action(id, description, [...argv, "-h"], "recovery");
76
+ switch (code) {
77
+ case exitCodes.usage:
78
+ return [help("usage", "Read the relevant command help", route)];
79
+ case exitCodes.auth:
80
+ return [
81
+ action(
82
+ "check-identity",
83
+ "Check identity and permissions; login if credentials expired",
84
+ ["whoami"],
85
+ "recovery"
86
+ )
87
+ ];
88
+ case exitCodes.revisionConflict:
89
+ return [
90
+ help(
91
+ "read-latest",
92
+ "Re-read and reconcile the latest state before retrying",
93
+ route
94
+ )
95
+ ];
96
+ case exitCodes.notFound:
97
+ return [
98
+ help(
99
+ "find-resource",
100
+ "Check the resource ID and command arguments",
101
+ route
102
+ )
103
+ ];
104
+ case exitCodes.verifyFailed:
105
+ return [
106
+ help("verify", "Fix reported findings before publishing or revising", [
107
+ "verify"
108
+ ])
109
+ ];
110
+ default:
111
+ return [];
112
+ }
113
+ }
114
+ function displayArg(arg) {
115
+ return /^[a-zA-Z0-9_./:@%+=,-]+$/.test(arg) ? arg : "'" + arg.replace(/'/g, "'\\''") + "'";
116
+ }
117
+ function renderNextActions(actions) {
118
+ for (const item of actions) {
119
+ console.error(
120
+ `Next: artis ${item.argv.map(displayArg).join(" ")} \u2014 ${item.description}`
121
+ );
122
+ }
123
+ }
124
+ function printJson(value) {
125
+ console.log(JSON.stringify(value, null, 2));
126
+ }
127
+ function emit(flags, { data, actions = [], text }) {
128
+ if (flags.json) {
129
+ printJson(flags.next ? { data, nextActions: actions } : data);
130
+ return;
131
+ }
132
+ text?.();
133
+ renderNextActions(actions);
134
+ }
135
+
136
+ export {
137
+ publishedActions,
138
+ feedbackActions,
139
+ reviseConflictActions,
140
+ signInActions,
141
+ dataConflictActions,
142
+ recoveryActions,
143
+ renderNextActions,
144
+ printJson,
145
+ emit
146
+ };