@artifactshare/cli 0.11.2 → 0.12.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": "@artifactshare/cli",
3
- "version": "0.11.2",
3
+ "version": "0.12.0",
4
4
  "description": "Upload and share HTML, Markdown, folders, and static sites from terminals, AI agents, automation, and CI.",
5
5
  "homepage": "https://artifactshare.com/connect",
6
6
  "repository": {
@@ -41,14 +41,16 @@
41
41
  "undici": "^8.10.0"
42
42
  },
43
43
  "devDependencies": {
44
+ "@artifactshare/viewer-kit": "0.0.1",
44
45
  "@types/node": "22.20.1",
45
- "tsdown": "0.22.8",
46
- "typescript": "6.0.3",
46
+ "tsdown": "0.22.14",
47
+ "typescript": "7.0.2",
47
48
  "vitest": "4.1.10"
48
49
  },
49
50
  "scripts": {
50
- "build": "tsdown",
51
+ "build": "node scripts/generate-preview-messages.mjs && tsdown",
51
52
  "test": "pnpm run build && vitest run",
52
- "typecheck": "tsc --noEmit"
53
+ "typecheck": "tsc --noEmit",
54
+ "generate:preview-messages": "node scripts/generate-preview-messages.mjs"
53
55
  }
54
56
  }
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  name: artifactshare
3
- description: Share, publish, upload, host, update, open, or read back existing files and Artifact Share URLs. Use when the user wants a browser link for an HTML/Markdown report, folder, static site, or generated file; wants to update the same URL; says Artifact Share, artifactshare, or contextual "as"; or asks to read comments from a shared URL.
3
+ description: Share, publish, upload, host, update, open, or read back existing files and Artifact Share URLs; or show a local file in the browser for review before sharing. Use when the user wants a browser link for an HTML/Markdown report, folder, static site, or generated file; wants to update the same URL; wants to look at, check, preview, or comment on a file you just generated before it is shared; says Artifact Share, artifactshare, or contextual "as"; or asks to read comments from a shared URL.
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 33
7
+ version: 36
8
8
  managed: true
9
9
  -->
10
10
 
@@ -61,18 +61,23 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
61
61
  | Create a project | `projects create 'Name' --json` |
62
62
  | Find an ID from a title | `resolve <value> --json` |
63
63
  | Open a share URL | `open <url> --json` |
64
+ | Preview a local file | `preview <file> --json` (local, no sign-in) |
64
65
  | Log out | `logout --profile <name> --json` |
65
66
 
66
67
  ## Authentication
67
68
 
68
- - `login --profile <name> --preset agent --json` starts device login for a
69
- project-scoped agent profile. Omit `--preset` for unrestricted login. It may
70
- open the OS browser for approval. Use it when a user is present; the pending
71
- event on stderr includes `browser_open`. Do not pass API tokens to `login`.
72
- Profiles created by `login` renew expired CLI sessions automatically.
69
+ - `login --profile <name> --preset agent --json` is for an attended coding
70
+ agent on the user's own machine. It creates a project-scoped profile and may
71
+ open the OS browser. Add `--project <exact-name-or-id>` to confirm one fixed
72
+ eligible project; omit it to select a project in the browser. Omit `--preset`
73
+ for unrestricted personal login. The pending event on stderr includes
74
+ `browser_open`. Do not pass tokens to `login`. Device-login profiles renew
75
+ expired CLI sessions automatically.
73
76
  - In unattended CI or scripts without browser approval, ask the user to issue
74
- an API token at `https://artifactshare.com/settings/tokens`, then use
75
- `ARTIFACTSHARE_TOKEN` or `--token` for normal commands.
77
+ an API token at `https://artifactshare.com/settings/tokens`, then inject it
78
+ with `ARTIFACTSHARE_TOKEN` or `--token`. A shared agent platform uses a
79
+ workspace-managed bot credential in a trusted host service outside the model
80
+ sandbox; never expose it to model shell commands.
76
81
  - `logout --profile <name> --json` revokes a device-login refresh credential
77
82
  before removing it locally and leaves profile metadata in `config.json`.
78
83
  If remote revoke fails, the local credential is kept and logout fails.
@@ -80,10 +85,15 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
80
85
  - To keep using an issued token as a named profile without TTY or browser
81
86
  login, pipe it on standard input:
82
87
  `printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`.
88
+ Bot tokens (`asb_` prefix, issued by a workspace admin) use the same command; the first
89
+ refresh consumes the displayed token, overwriting an existing profile credential requires
90
+ `--force`, and a revoked or superseded bot token fails with `bot_token_invalid` (ask the
91
+ admin to reissue).
83
92
  Imported API-token profiles are not renewed by the CLI.
84
93
  Use `--allow-plaintext-token-store` only on a trusted machine without a native token store.
85
- - Check the current state with `whoami --json`, or `doctor --json` for
86
- authentication, destination, network, upload access, and skill update status.
94
+ That fallback is mode `0600` on POSIX and unavailable on Windows, where saved profiles require Credential Manager.
95
+ - Check the current state with `whoami --json`, or `doctor --json` for token
96
+ storage, authentication, destination, network, upload access, and skill update status.
87
97
 
88
98
  ## Share
89
99
 
@@ -99,6 +109,9 @@ npx --yes @artifactshare/cli share ./site-dir --project-id <id> --json
99
109
  ```
100
110
 
101
111
  - `share` accepts a single `.html` / `.md` file or a static-site directory.
112
+ If a successful result contains `data.warnings`, tell the user each warning
113
+ explicitly. `slack_reauthorization_required` means project Slack
114
+ notifications are not being delivered until the channel is reauthorized.
102
115
  In JSON output, give the user `data.artifact.url`; the artifact ID is
103
116
  `data.artifact.id`.
104
117
  Do not rerun `share` just to inspect the JSON shape: without `--key`, each
@@ -332,6 +345,89 @@ npx --yes @artifactshare/cli skills list --json
332
345
  - `--force` overwrites an unmanaged file on install.
333
346
  - Run `skills --help` for all subcommands.
334
347
 
348
+ ## Preview (local annotate-and-fix loop)
349
+
350
+ `preview` is a local, unauthenticated feature: it serves one local `.md` or
351
+ `.html` file with the same rendering as the product viewer, the user annotates
352
+ elements or text selections in the browser and submits them as an explicit
353
+ batch, and the agent fixes the file. Nothing is uploaded by previewing;
354
+ an upload happens only if the user opens the share dialog from the page.
355
+
356
+ ```bash
357
+ npx --yes @artifactshare/cli preview ./lp.html
358
+ npx --yes @artifactshare/cli preview start ./lp.html --no-open
359
+ ```
360
+
361
+ - Internally this runs the `preview start` subcommand (bare `preview <file>`
362
+ is rewritten to it). It prints a single ready JSON line with `url` (the
363
+ local page), `session` (id for `--session`), `share_origin`, and `reused`
364
+ (`true` means an already-live session for the same file was picked up
365
+ instead of starting a new server), then keeps running until stopped.
366
+ `--no-open` skips opening the browser.
367
+ - Editing and saving the file reloads the page automatically; annotations
368
+ stay anchored where possible.
369
+ - `preview next` returns every batch the user has submitted; it is
370
+ non-claiming (calling it again returns the same open items) and with
371
+ `--wait <sec>` it long-polls. `timed_out: true` and `session_ended: true`
372
+ are normal empty results, not errors. The error
373
+ `preview_session_not_found` means no live session exists; ask the user to
374
+ start one. `preview_request_failed` means the session is alive but rejected
375
+ the request, so fix the payload (thread id, generation, size) and retry.
376
+ `preview_session_unverified` on startup means a recorded session did not
377
+ answer: retry shortly. If it stays unverified, ask the user to stop that preview
378
+ process; `preview stop <file> --force` clears the record only once the
379
+ process is gone.
380
+ - Report outcomes with `preview done --stdin`; reply into a thread with
381
+ `preview reply --thread <id> --body <text>` (state unchanged); end the
382
+ session with `preview stop` (annotations stay saved on disk).
383
+
384
+ ### Waking up when the user submits a batch
385
+
386
+ Pick the first mode your environment supports:
387
+
388
+ 1. In Claude Code, arm `preview next --wait 3600` as a background task
389
+ (run_in_background) and end your turn. When the user presses the request
390
+ button in the browser, the command exits, the background completion
391
+ notification resumes you: fix the file, report with `preview done`, then
392
+ re-arm the next `preview next --wait 3600` background call. If two
393
+ consecutive calls come back with `timed_out: true`, stop re-arming and
394
+ wait for the user to speak up.
395
+ 2. In other agents (Codex, Cursor, and similar), block in the foreground on
396
+ `preview next --wait 90` and repeat.
397
+ 3. Fallback: run `preview next` only when the user tells you a batch is
398
+ ready.
399
+
400
+ If `preview next` immediately returns the same item set as the previous
401
+ call, do not re-arm; report the situation to the user instead.
402
+
403
+ ### Working through a batch
404
+
405
+ ```bash
406
+ npx --yes @artifactshare/cli preview next ./lp.html --wait 90
407
+ npx --yes @artifactshare/cli preview next --session 0123456789abcdef
408
+ ```
409
+
410
+ - Read the whole batch first, then fix everything in one editing pass and
411
+ save once, then report the whole batch with a single `preview done` call.
412
+ - Each done item is `{thread, generation, outcome, note}` with outcome
413
+ `fixed` (you changed the file) or `skipped` (`note` explaining why is
414
+ required). The `note` is shown to the user as the thread summary, so
415
+ write it for them.
416
+ - An item whose `anchor.state` is `orphaned` lost its place in the document;
417
+ do not try to re-fix it — report it as `skipped` with a note.
418
+ - `done` is idempotent per generation: each item comes back as `accepted`,
419
+ `stale` (the thread was reopened with a newer generation), or
420
+ `already_reported`, plus `unknown_thread` for ids the session does not
421
+ know.
422
+
423
+ ```bash
424
+ printf '%s' '{"items":[{"thread":"t1","generation":1,"outcome":"fixed","note":"Tightened the headline"}]}' | npx --yes @artifactshare/cli preview done ./lp.html --stdin
425
+ ```
426
+
427
+ Sharing is user-driven: the page's share button opens a separate-origin
428
+ dialog that publishes the snapshot bytes; local annotations are never
429
+ carried into the shared copy.
430
+
335
431
  ## Output contract
336
432
 
337
433
  - Always pass `--json`. Success prints
@@ -1,10 +1,10 @@
1
1
  ---
2
- description: Share, publish, upload, host, update, open, or read back existing files and Artifact Share URLs.
2
+ description: Share, publish, upload, host, update, open, or read back existing files and Artifact Share URLs; or show a local file in the browser for review before sharing.
3
3
  alwaysApply: false
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 33
7
+ version: 36
8
8
  managed: true
9
9
  -->
10
10
 
@@ -49,13 +49,16 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
49
49
  exactly one of `--link-expires-at <RFC3339 UTC>` or `--no-link-expiry`; omit
50
50
  both to use the workspace default on share or preserve the current expiry on
51
51
  edit. Results expose `link_expires_at` as a UTC timestamp or `null`.
52
- - For an agent with a user present, use `login --preset agent --profile <name> --json` and let the user select one project during browser approval. In unattended CI or scripts without browser approval, ask the user to issue an API token at `https://artifactshare.com/settings/tokens`, then run normal commands with `ARTIFACTSHARE_TOKEN` or `--token`; do not pass API tokens to `login`.
53
- - To save that token as a named profile without TTY or browser login, pipe it on standard input: `printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`. Imported API-token profiles are not renewed by the CLI. Add `--allow-plaintext-token-store` only on a trusted machine without a native token store.
52
+ - For an attended coding agent on the user's own machine, use `login --preset agent --profile <name> --json`; add `--project <exact-name-or-id>` to confirm a fixed project or omit it to use the browser picker. In CI, issue an API token at `https://artifactshare.com/settings/tokens` and inject it with `ARTIFACTSHARE_TOKEN` or `--token`. A shared agent platform uses a workspace-managed bot credential in a trusted host outside the model sandbox; never expose it to model shell commands. Do not pass tokens to `login`.
53
+ - To save that token as a named profile without TTY or browser login, pipe it on standard input: `printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`. Imported API-token profiles are not renewed by the CLI. Bot tokens (`asb_` prefix) import through the same command as rotating refresh credentials; overwriting an existing profile credential needs `--force`, and a rejected bot token reports `bot_token_invalid` (recovery is an admin reissue). Add `--allow-plaintext-token-store` only on a trusted machine without a native token store. That fallback is mode `0600` on POSIX and unavailable on Windows, where saved profiles require Credential Manager.
54
54
  - Use `login --profile <name> --json` when a user is present for browser approval. The pending event on stderr includes `browser_open`. Profiles created by `login` renew expired CLI sessions automatically.
55
55
  - Use `logout --profile <name> --json` to revoke a device-login credential before removing it locally; this keeps profile metadata. API-token profiles are removed locally only and their server token is not revoked.
56
56
  - Switch profiles with `profiles use <name> --json`; list with `profiles list --json`; remove a profile entry and its credential with `profiles delete <name> --json`.
57
57
  - When the user gives an Artifact Share URL, start with `open <artifact-id-or-url> --json`. It ensures this rule is installed or updated, then reads single-file artifacts or returns a `download` next command for static sites and multi-file artifacts.
58
58
  - Share with `share <path> --json`. In JSON output, give the user `data.artifact.url`; the artifact ID is `data.artifact.id`. Do not rerun `share` just to inspect the JSON shape: without `--key`, each successful run creates a new artifact. Posting to a project delivers to the audience defined by that project. Pick it with `--project-id <id>` or `--project <name>` (by exact name), or use the saved default. With no destination, share posts to home. Choose `home_audience` by purpose: use `config set home_audience private --scope user --json` for a personal safe default in this CLI environment, use `--scope repository` only for a policy agreed by all participants, and use `--visibility private|workspace|link` for one home post. For link sharing, pass exactly one of `--link-expires-at <RFC3339 UTC>` or `--no-link-expiry`; omit both to use the workspace default. Confirm the resolved audience with `config get home_audience --scope effective --json`; `--grant-email` does not change the resolved default.
59
+ - If a successful `share` result contains `data.warnings`, tell the user each
60
+ warning explicitly. `slack_reauthorization_required` means project Slack
61
+ notifications are not being delivered until the channel is reauthorized.
59
62
  - For new projects, pass `projects create <name> --visibility private|workspace`; persistent project defaults are documented in `projects create --help`. The complete `config --help` reference covers the canonical `home_audience`, user/repository/effective scopes, and resolution. `default_artifact_visibility` is a compatibility alias; `default_project_visibility` is the advanced project-creation default. Home resolution checks repository then user settings, including the alias at each scope, then product default `workspace`. Keyless `config get --json` returns only `home_audience`; pass an explicit key for either other setting. These settings do not change update, edit, Web, or MCP defaults.
60
63
  - For repeat jobs with a stable caller-owned name, use `share <path> --key <key> --json`: the first run creates the artifact, later runs add versions to the same artifact.
61
64
  - To keep an existing share URL, do not use `share --artifact-id`; add a version with `update <artifact-id-or-url> <path> --json`. `update` does not change title, visibility, viewers, or placement.
@@ -76,5 +79,6 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
76
79
  - Manage projects: `projects list --json`, `projects create <name> --json` (uses `default_project_visibility` when saved, otherwise `workspace`; pass `--visibility private` for a confidential project), `projects edit <id>` for name, description, visibility, audience (`--add-email`/`--remove-email`), and archive state (`--archive`/`--unarchive`).
77
80
  - Save a default project with `init --project-id <id> --json`. Preview setup with `init --dry-run --json`.
78
81
  - Manage skills: `skills ensure --tool auto --json` detects Claude Code, Codex, or Cursor and installs or updates user-scope skills; Cursor project scope needs `skills install --tool cursor --scope project --json`. Use `skills install --tool cursor --scope user --json` for the Cursor user-scope skill explicitly. Project scope is opt-in via `skills install --tool <tool> --scope project --json`. `skills update --json` updates installed managed skills; `--force` overwrites unmanaged files on install.
79
- - Check the current state with `whoami --json` or `doctor --json` for authentication, destination, network, upload access, and skill update status.
82
+ - Preview a local `.md` / `.html` file with `preview <file> --json` (add `--no-open` to keep the browser closed). It is local and needs no sign-in: one ready JSON line (`url` / `session` / `share_origin` / `reused`) is printed and the process keeps serving; saving the file reloads the page. The user annotates in the browser and submits batches. Fetch them with `preview next [--wait <sec>] [--session <id>]` — non-claiming long poll where `timed_out` / `session_ended` are normal empty results and `preview_session_not_found` means no live session, `preview_request_failed` means the session is alive and rejected the request, and `preview_session_unverified` means the recorded session went silent — retry, then stop the process before `preview stop <file> --force`. Fix the whole batch in one edit, then pipe `{"items":[{"thread","generation","outcome":"fixed|skipped","note"}]}` to `preview done --stdin` (idempotent per generation; results `accepted|stale|already_reported|unknown_thread`; `skipped` needs a note; items with `anchor.state: "orphaned"` are skipped, not re-fixed; the note becomes the thread summary). `preview reply --thread <id> --body <text>` answers without changing state; `preview stop` ends the session and keeps annotations. If `preview next` immediately returns the same items again, stop polling and tell the user. Nothing is uploaded unless the user shares from the page.
83
+ - Check the current state with `whoami --json` or `doctor --json` for token storage, authentication, destination, network, upload access, and skill update status.
80
84
  - First-time setup: `npx --yes @artifactshare/cli init --json` detects Claude Code, Codex, or Cursor, installs or updates user-scope skills, and reports the next steps (sign in, then share). For Cursor project scope, run `skills install --tool cursor --scope project --json` explicitly.