@artis-lab/cli 0.3.0 → 0.4.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
@@ -3,8 +3,10 @@
3
3
  Agent-first CLI for publishing, reviewing, and revising self-contained HTML
4
4
  artifacts on an [Artis](https://github.com/xiispace/artis) server.
5
5
 
6
- Artis is self-hosted, so the CLI has no built-in default host — every server
7
- command needs `--host`, `ARTIS_URL`, or a saved login.
6
+ Server commands default to the hosted instance at
7
+ <https://artis.xiispace.eu.org>. Artis is also self-hostable — point the CLI at
8
+ your own deployment with `--host`, `ARTIS_URL`, or a saved login, any of which
9
+ takes precedence over the default.
8
10
 
9
11
  ## Install
10
12
 
@@ -22,14 +24,22 @@ opens a browser for approval and stores the resulting API key at
22
24
  `~/.artis/config.json`.
23
25
 
24
26
  ```bash
25
- artis login --host https://artis.example.com
27
+ artis login
26
28
  artis whoami
29
+ artis publish artifact.html
30
+ ```
31
+
32
+ Against a self-hosted deployment, pass `--host` (or save it once via
33
+ `artis login --host https://artis.example.com`):
34
+
35
+ ```bash
27
36
  artis publish artifact.html --host https://artis.example.com
28
37
  ```
29
38
 
30
39
  Defaults:
31
40
 
32
- - Host: `--host`, `ARTIS_URL`, or saved config (required — no built-in default)
41
+ - Host: `--host`, then `ARTIS_URL`, then saved config, then
42
+ `https://artis.xiispace.eu.org`
33
43
  - `visibility=unlisted`
34
44
  - `kind=custom-html`
35
45
  - `author=Artis CLI`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artis-lab/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.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.js CHANGED
@@ -12,7 +12,7 @@ function annotationIdFromIri(iri) {
12
12
  function isRootAnnotation(annotation) {
13
13
  return annotation.motivation === 'commenting';
14
14
  }
15
- import { findProfileForHost, getConfigPath, normalizeHost, readCliConfig, saveDefaultProfile, } from './config.js';
15
+ import { ARTIS_DEFAULT_HOST, findProfileForHost, getConfigPath, normalizeHost, readCliConfig, saveDefaultProfile, } from './config.js';
16
16
  import { artisCliVersion } from './version.js';
17
17
  import { hasFlag, parseFlagValue } from './args.js';
18
18
  export { artisCliVersion };
@@ -194,11 +194,14 @@ function buildAnnotationSelectors(args) {
194
194
  return selectors;
195
195
  }
196
196
  function resolveBaseUrl(args, config) {
197
- var _a, _b, _c;
198
- const host = (_c = (_b = (_a = parseFlagValue(args, '--host')) !== null && _a !== void 0 ? _a : parseFlagValue(args, '--url')) !== null && _b !== void 0 ? _b : process.env['ARTIS_URL']) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config.defaultHost;
199
- if (!host) {
200
- throw new Error('No Artis host configured. Pass --host <url>, set ARTIS_URL, or run "artis login --host <url>" to save one.');
201
- }
197
+ // `||` rather than `??` on purpose: an empty value (`--host ""`, `ARTIS_URL=`)
198
+ // means "unset" here. With `??` it would pass through and every request would
199
+ // be built against an empty origin, failing far from the actual mistake.
200
+ const host = parseFlagValue(args, '--host') ||
201
+ parseFlagValue(args, '--url') ||
202
+ process.env['ARTIS_URL'] ||
203
+ (config === null || config === void 0 ? void 0 : config.defaultHost) ||
204
+ ARTIS_DEFAULT_HOST;
202
205
  return normalizeHost(host);
203
206
  }
204
207
  function resolveApiKey(args, config, baseUrl) {
@@ -380,7 +383,7 @@ Usage:
380
383
 
381
384
  Options:
382
385
  --api-key <key> API key. Defaults to ARTIS_API_KEY or ~/.artis/config.json. Run "artis login" to obtain one.
383
- --host, --url <url> Artis server URL (required). Set via --host/--url, ARTIS_URL, or a saved login.
386
+ --host, --url <url> Artis server URL. Falls back to ARTIS_URL, then a saved login, then https://artis.xiispace.eu.org.
384
387
  --title <title> Artifact title. Defaults to the file name.
385
388
  --description <text> Artifact description.
386
389
  --visibility <value> public, unlisted, or private. Defaults to unlisted.
@@ -404,9 +407,9 @@ Options:
404
407
  --remove Remove the email from an artifact share list.
405
408
  --json Print machine-readable JSON for supported commands.
406
409
 
407
- Examples (server commands also need --host, ARTIS_URL, or a saved login):
408
- artis publish report.html --host https://artis.example.com
409
- artis login --host https://artis.example.com
410
+ Examples (--host is optional; without it commands target https://artis.xiispace.eu.org):
411
+ artis publish report.html
412
+ artis login
410
413
  artis publish report.html --host https://artis.example.com --visibility private
411
414
  artis share artifact-slug --host https://artis.example.com --email reviewer@example.com --role commenter
412
415
  artis artifact get artifact-slug --host https://artis.example.com --json
@@ -6,6 +6,13 @@ export interface ArtisCliConfig {
6
6
  defaultHost?: string;
7
7
  profiles: Record<string, ArtisCliProfile>;
8
8
  }
9
+ /**
10
+ * The hosted Artis instance, used only when nothing else supplies a host. It is
11
+ * deliberately the last fallback in `resolveBaseUrl`: an explicit `--host`,
12
+ * `ARTIS_URL`, or a saved login always wins, so a self-hosted user never
13
+ * publishes to this origin by accident.
14
+ */
15
+ export declare const ARTIS_DEFAULT_HOST = "https://artis.xiispace.eu.org";
9
16
  export declare function normalizeHost(value: string): string;
10
17
  export declare function getConfigPath(): string;
11
18
  export declare function readCliConfig(): Promise<ArtisCliConfig | undefined>;
package/src/lib/config.js CHANGED
@@ -2,6 +2,13 @@ import { __awaiter } from "tslib";
2
2
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
4
  import { dirname, join } from 'node:path';
5
+ /**
6
+ * The hosted Artis instance, used only when nothing else supplies a host. It is
7
+ * deliberately the last fallback in `resolveBaseUrl`: an explicit `--host`,
8
+ * `ARTIS_URL`, or a saved login always wins, so a self-hosted user never
9
+ * publishes to this origin by accident.
10
+ */
11
+ export const ARTIS_DEFAULT_HOST = 'https://artis.xiispace.eu.org';
5
12
  export function normalizeHost(value) {
6
13
  return value.replace(/\/+$/, '');
7
14
  }