@artifactshare/cli 0.13.1 → 0.13.3

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/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ For user-facing announcements, see https://artifactshare.com/updates?product=cli
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## 0.13.3 - 2026-09-02
9
+
10
+ - Allow workspace members to update, rename, and move artifacts they can view,
11
+ while preserving owner-only sharing controls and private artifacts.
12
+ - Add `--expected-version <version-id>` to `update` and repeat `share --key`
13
+ operations, returning a recoverable `version_conflict` when another update
14
+ commits first.
15
+ - Include human or agent creator attribution in `versions --json` output.
16
+
17
+ ## 0.13.2 - 2026-08-30
18
+
19
+ - Define preview startup in the bundled agent skill as one owned long-lived
20
+ process with the ready JSON as its handshake, separating server startup from
21
+ comment waiting and avoiding duplicate launches while startup is unverified.
22
+
8
23
  ## 0.13.1 - 2026-08-30
9
24
 
10
25
  - Restore direct `npx @artifactshare/cli ...` invocation after adding the
package/README.md CHANGED
@@ -40,6 +40,9 @@ To keep an existing share URL, update it with
40
40
  sharing again. For CI, scheduled reports, or other repeat jobs, use
41
41
  `share <path> --key <key>`: the first run creates the shared file, and later
42
42
  runs add versions to the same file.
43
+ Pass `--expected-version <version-id>` to reject an update when another version
44
+ became current first. Project-scoped agent profiles must pass it to `update`
45
+ and to repeat `share --key` updates; initial key creation does not require it.
43
46
 
44
47
  ## Authentication
45
48
 
package/dist/index.js CHANGED
@@ -156,6 +156,7 @@ const SUBCOMMANDS = {
156
156
  const UPDATE_OPTION_KEYS = /* @__PURE__ */ new Set([
157
157
  "allowPlaintextTokenStore",
158
158
  "baseUrl",
159
+ "expectedVersion",
159
160
  "help",
160
161
  "insecureLocalhost",
161
162
  "json",
@@ -382,17 +383,21 @@ function mapApiError(status, body, options = {}) {
382
383
  recovery: { kind: "change_input" }
383
384
  });
384
385
  }
385
- if (options.artifactTarget && options.operation === "append" && apiCode === "version_conflict") {
386
+ if (options.artifactTarget && [
387
+ "append",
388
+ "update",
389
+ "share"
390
+ ].includes(options.operation ?? "") && apiCode === "version_conflict") {
386
391
  const current = typeof body?.error === "object" ? body.error.details : void 0;
387
392
  const currentVersionId = isRecord$1(current) && typeof current.current_version_id === "string" ? current.current_version_id : null;
388
393
  return cliError({
389
394
  code: "version_conflict",
390
- message: apiMessage ?? "The artifact changed before append.",
395
+ message: apiMessage ?? "The artifact changed before the update.",
391
396
  why: currentVersionId ? `The current version is ${currentVersionId}.` : "Another update was committed first.",
392
- hint: "Run the same append command again to append to the latest content.",
397
+ hint: options.operation === "append" ? "Run the same append command again to append to the latest content." : "Read the current version, reapply your changes, and retry with its version id.",
393
398
  agentRecoverable: true,
394
399
  requiresHuman: false,
395
- recovery: { kind: "retry_later" },
400
+ recovery: { kind: options.operation === "append" ? "retry_later" : "change_input" },
396
401
  ...currentVersionId ? { details: { current_version_id: currentVersionId } } : {}
397
402
  });
398
403
  }
@@ -13690,6 +13695,7 @@ async function runShare(parsed, mode, isRetry = false) {
13690
13695
  if (parsed.options.noSlackNotify === true) initialForm.set("slack_notify", "false");
13691
13696
  const uploadUrl = apiUrl("/api/shareables/uploads", baseUrl);
13692
13697
  if (shareKey !== null) uploadUrl.searchParams.set("publish_key", shareKey);
13698
+ if (parsed.options.expectedVersion) uploadUrl.searchParams.set("expected_version", parsed.options.expectedVersion);
13693
13699
  const upload = await prepareUploadPayload(targetPath, fileStat, initialForm);
13694
13700
  if (upload.error) return writeFailure(command, upload.error, mode, 1);
13695
13701
  if (upload.payload.kind === "static_site") {
@@ -13703,6 +13709,10 @@ async function runShare(parsed, mode, isRetry = false) {
13703
13709
  requestInit: request.init,
13704
13710
  errorOptions: {
13705
13711
  authenticated: true,
13712
+ ...shareKey !== null ? {
13713
+ artifactTarget: true,
13714
+ operation: "share"
13715
+ } : {},
13706
13716
  baseUrl,
13707
13717
  credentialSource: credential.source,
13708
13718
  profile: credential.profile,
@@ -13808,6 +13818,7 @@ async function runUpdate(parsed, mode, isRetry = false) {
13808
13818
  if (upload.error) return writeFailure(command, upload.error, mode, 1);
13809
13819
  const updateUrl = apiUrl(`/api/shareables/${encodeURIComponent(artifactId)}/versions`, baseUrl);
13810
13820
  if (upload.payload.kind === "static_site") updateUrl.searchParams.set("artifact_kind", "static_site");
13821
+ if (parsed.options.expectedVersion) updateUrl.searchParams.set("expected_version", parsed.options.expectedVersion);
13811
13822
  const response = await cliFetch(updateUrl, {
13812
13823
  method: "POST",
13813
13824
  headers: { Authorization: `Bearer ${credential.token}` },
@@ -13819,6 +13830,7 @@ async function runUpdate(parsed, mode, isRetry = false) {
13819
13830
  if (!response.ok) return handleAuthenticatedCredentialFailure(command, mapApiError(response.status, body, {
13820
13831
  authenticated: true,
13821
13832
  artifactTarget: true,
13833
+ operation: "update",
13822
13834
  baseUrl,
13823
13835
  credentialSource: credential.source,
13824
13836
  profile: credential.profile,
@@ -14613,6 +14625,11 @@ const shareDefinition = define({
14613
14625
  type: "string",
14614
14626
  toKebab: true,
14615
14627
  description: "Stable key for create-or-update: the first share creates the artifact, repeats add versions. Not a secret; it appears in logs and JSON"
14628
+ },
14629
+ expectedVersion: {
14630
+ type: "string",
14631
+ toKebab: true,
14632
+ description: "Require this current version when --key updates an existing artifact"
14616
14633
  }
14617
14634
  },
14618
14635
  examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare share report.html --project-id <id> --json
@@ -14658,6 +14675,11 @@ const updateDefinition = define({
14658
14675
  path: {
14659
14676
  type: "positional",
14660
14677
  description: "File or directory to add as the new version"
14678
+ },
14679
+ expectedVersion: {
14680
+ type: "string",
14681
+ toKebab: true,
14682
+ description: "Only update when this is still the current version id"
14661
14683
  }
14662
14684
  },
14663
14685
  examples: `Target:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
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": {
@@ -4,7 +4,7 @@ description: Share, publish, upload, host, update, open, or read back existing f
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 36
7
+ version: 37
8
8
  managed: true
9
9
  -->
10
10
 
@@ -180,6 +180,11 @@ Use `update` to add a new version to an existing artifact while keeping its URL.
180
180
  npm exec --yes --package=@artifactshare/cli -- artifactshare update <artifact-id-or-url> ./report.html --json
181
181
  ```
182
182
 
183
+ - Pass `--expected-version <version-id>` to reject an update when another
184
+ version became current first. Project-scoped agent profiles must pass it.
185
+ Repeat `share --key` updates accept the same option; initial creation does
186
+ not require it.
187
+
183
188
  - To keep an existing share URL, do not run `share --artifact-id`; use `update`.
184
189
  - Pass the same kind of input (single file vs directory) it was created with.
185
190
  - `update` does not change title, visibility, viewers, or placement. Use `edit`
@@ -353,18 +358,41 @@ elements or text selections in the browser and submits them as an explicit
353
358
  batch, and the agent fixes the file. Nothing is uploaded by previewing;
354
359
  an upload happens only if the user opens the share dialog from the page.
355
360
 
361
+ ### Start and own one preview
362
+
363
+ `preview` starts a long-lived local service; process exit is not its success
364
+ condition. Start it once for the file using the environment's supported
365
+ long-running or background process mechanism. Keep that process or task handle
366
+ for the lifetime of the preview.
367
+
356
368
  ```bash
357
369
  npm exec --yes --package=@artifactshare/cli -- artifactshare preview ./lp.html
358
370
  npm exec --yes --package=@artifactshare/cli -- artifactshare preview start ./lp.html --no-open
359
371
  ```
360
372
 
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), plus a sanitized `agent` notification
366
- projection, then keeps running until stopped.
373
+ - Run the CLI invocation itself as the long-running task. Do not add shell
374
+ pipelines, redirections, command substitutions, or wrappers that wait for
375
+ output or process exit; output capture managed by the agent's background-task
376
+ tool is part of that tool's contract. Extra shell layers change ownership and
377
+ the service's output contract.
378
+ - Bare `preview <file>` is rewritten to `preview start <file>`. Start prints
379
+ exactly one ready JSON line with `url`, `session`, `share_origin`, `reused`,
380
+ and a sanitized `agent` notification projection, then keeps serving.
367
381
  `--no-open` skips opening the browser.
382
+ - The ready JSON is the startup handshake. A background task id or running PID
383
+ only proves that launch began. Treat the preview as ready, retain its `url`
384
+ and `session`, and tell the user it opened only after reading that line.
385
+ - `session` is generated by start. Use the returned value only with
386
+ `preview next`, `done`, `reply`, or `stop`; do not pass `--session` to start.
387
+ - After one launch begins, do not launch another copy until that attempt either
388
+ returns a CLI failure or exits without a ready line. If the task is still
389
+ running but its ready output cannot be read, the state is indeterminate:
390
+ keep the task, report that startup could not be verified, and ask the user
391
+ how to proceed. Do not infer a preview URL from ports or unrelated processes.
392
+ - A later deliberate start for the same file may return `reused: true`. Its
393
+ ready JSON is a valid handshake, but that invocation exits because the
394
+ original preview process still owns the service. Do not treat the reused
395
+ invocation's task or process handle as the server owner.
368
396
  - Editing and saving the file reloads the page automatically; annotations
369
397
  stay anchored where possible.
370
398
  - `preview next` returns every batch the user has submitted; it is
@@ -397,14 +425,22 @@ Pick the first mode your environment supports:
397
425
  that it started processing. If it remains queued, the session may have
398
426
  ended: use `codex resume`, then run `preview next`. Never copy comments into
399
427
  a queue message; `preview next` is their source of truth.
400
- 2. In Claude Code, use the background-wait path only if
401
- `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` is neither `1` nor `true`, Bash exposes
402
- `run_in_background`, and starting `preview next --wait 3600` in the
403
- background returns a task ID. End your turn. A submitted batch completes the
404
- command and resumes you; fix the file, report with `preview done`, then arm
405
- one new background wait. If the wait returns `timed_out: true`, do not
406
- re-arm it automatically. If background execution is unavailable or
407
- rejected, use manual pickup and do not describe the session as waiting.
428
+ 2. In Claude Code, if `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` is neither `1` nor
429
+ `true` and Bash exposes `run_in_background`, run the preview start command
430
+ itself as one Bash background task and read it through Claude Code's
431
+ task-output mechanism until the ready JSON arrives; add no shell pipeline or
432
+ redirection. Keep a non-reused task alive as the server owner. After the
433
+ handshake,
434
+ use the background-wait path only if starting
435
+ `preview next --wait 3600` in a separate background task returns a task ID.
436
+ End your turn. A submitted batch completes the wait and resumes you; fix the
437
+ file, report with `preview done`, then arm one new wait. If the wait returns
438
+ `timed_out: true`, do not re-arm it automatically. If background waiting is
439
+ unavailable or rejected after start, use manual pickup and do not describe
440
+ the session as waiting. If background Bash tasks are unavailable before
441
+ start, ask the user to run and keep the preview command open in their own
442
+ terminal; that user-owned process is the server owner, and comment pickup is
443
+ manual.
408
444
  3. For an Artifact Share-managed Cursor ACP session, start with
409
445
  `npm exec --yes --package=@artifactshare/cli -- artifactshare-preview-cursor <file>`.
410
446
  Run one managed launcher per workspace. The launcher creates or loads the
@@ -4,7 +4,7 @@ alwaysApply: false
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 36
7
+ version: 37
8
8
  managed: true
9
9
  -->
10
10
 
@@ -79,6 +79,6 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
79
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`).
80
80
  - Save a default project with `init --project-id <id> --json`. Preview setup with `init --dry-run --json`.
81
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.
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` / sanitized `agent`) is printed and the process keeps serving; saving the file reloads the page. A preview started inside Codex registers the trusted thread UUID and uses `codex queue` for a fixed batch-ready notice; `queued` means accepted, while `preview next` is the first proof of processing. If it remains queued, reopen the session with `codex resume`. In Claude Code, if background tasks are enabled (`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` is neither `1` nor `true`), Bash exposes `run_in_background`, and the command returns a task ID, arm one background `preview next --wait 3600`; re-arm after `preview done`, but not after `timed_out: true`. If background execution is disabled or rejected, use manual pickup. In Cursor, keep `preview next --wait 90` in the foreground. 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. Never copy comment content into a provider notification; `preview next` is the source of truth. 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.
82
+ - Preview a local `.md` / `.html` file with `preview <file> --json` (add `--no-open` to keep the browser closed). Preview start is a long-lived service, so run the CLI invocation itself once with the environment's long-running/background process mechanism and retain that task or process as its owner; add no shell pipeline, redirection, command substitution, or wrapper that waits for process exit (tool-managed background output capture is fine). The single ready JSON line (`url` / generated `session` / `share_origin` / `reused` / sanitized `agent`) is the startup handshake: a task id or PID alone is not readiness, and `--session` is only for later `next` / `done` / `reply` / `stop`, never start. While one launch is still running without readable ready output, do not launch a second or infer a URL from listening ports; report that startup is unverified and ask the user how to proceed. A `reused: true` handshake is valid, but that invocation exits because the original process remains the server owner; do not treat the reused invocation's handle as ownership. Saving the file reloads the page. A preview started inside Codex registers the trusted thread UUID and uses `codex queue` for a fixed batch-ready notice; `queued` means accepted, while `preview next` is the first proof of processing. If it remains queued, reopen the session with `codex resume`. In Claude Code, only when background tasks are enabled (`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` is neither `1` nor `true`) and Bash exposes `run_in_background`, run preview start as one Bash background task, read it through Claude Code's task-output mechanism until the ready JSON arrives, and keep a non-reused task alive; then arm `preview next --wait 3600` as a separate background task. Re-arm after `preview done`, but not after `timed_out: true`. If background waiting is disabled or rejected after start, use manual pickup. If background Bash tasks are unavailable before start, ask the user to run and keep preview open in their own terminal; that user-owned process owns the server and pickup is manual. In Cursor, keep `preview next --wait 90` in the foreground. 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. Never copy comment content into a provider notification; `preview next` is the source of truth. 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
83
  - Check the current state with `whoami --json` or `doctor --json` for token storage, authentication, destination, network, upload access, and skill update status.
84
84
  - First-time setup: `npm exec --yes --package=@artifactshare/cli -- artifactshare 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.