@artifactshare/cli 0.15.2 → 0.16.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/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ For user-facing announcements, see https://artifactshare.com/updates?product=cli
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## 0.16.0 - 2026-10-20
9
+
10
+ - Paginate comments with first/latest-three windows, counts, older cursors and targeted reads. Enforce 500 stored messages per thread and 20 combined create/reply admissions per user/artifact per fixed UTC minute, with structured retry guidance.
11
+
12
+ - Bound artifact live connections to eight tabs per viewer and 128 per room, coalesce presence updates, and stagger reconnect retries while preserving HTTP viewing and comments.
13
+
14
+ - Revoke API tokens and AI tool OAuth credentials when a workspace member is removed.
15
+
16
+ - Preserve every version people added when applying retention to publisher-managed artifacts; update bundled retention guidance and CLI help.
17
+
18
+ - Treat publisher versions as scheduled updates: preserve activity order and human update signals while displaying scheduled freshness on project pinned cards and marking scheduled versions in history. Remove the data freshness label from the artifact viewer.
19
+
20
+ - Extend server publisher permissions to static sites, manifest and metadata readback, retention and deletion of client-owned or owner-assigned artifacts. Add audited API-only adoption and update bundled documentation; publisher CLI workflows remain unsupported.
21
+
22
+ - Update bundled documentation for owner version settings in file history and authorized explanations for versions removed by retention. Clearing a limit does not restore deleted content.
23
+
24
+ - Preserve the server-verified publisher preset when importing a token, including when replacing an existing profile; reject malformed authority responses before saving credentials.
25
+
26
+ - Preserve publisher device credentials in saved profiles and rotation, report their client scope in doctor, and reject unsupported publisher login/resume without downgrading. The device API can approve a named publisher client to create private home files and update only its own files; its exact download endpoint returns source bytes.
27
+
28
+ - Deny unknown CLI authority kinds and persisted credential presets by default.
29
+
30
+ ## 0.15.3 - 2026-10-10
31
+
32
+ - `edit` now accepts `--visibility project`, including when moving into a project in the same request. Edits requesting project visibility at home are refused without changes and explain how to select a project.
33
+
8
34
  ## 0.15.2 - 2026-10-10
9
35
 
10
36
  - Fix complete downloads of static sites with dotted filenames, including `.data`, and identify the file when a download fails.
package/README.md CHANGED
@@ -183,7 +183,9 @@ npm exec --yes --package=@artifactshare/cli -- artifactshare config get home_aud
183
183
 
184
184
  Use `--scope repository` only for a policy agreed by all repository participants, and pass `--visibility private|workspace|link` for a one-time home override. For link sharing, pass exactly one of `--link-expires-at <RFC3339 UTC>` or `--no-link-expiry`; omit both to use the workspace default. For project creation, pass `projects create <name> --visibility private|workspace`; persistent project defaults are documented in `projects create --help`. Pass `--no-slack-notify` to suppress the project Slack notification for one post.
185
185
 
186
- Owners can run `edit <target> --retain-versions 24 --json` to keep the latest 24 published versions, or `--retain-versions all` to clear the limit. Setting or lowering the limit immediately deletes older versions and releases their storage. The response includes `retain_versions` and `deleted_versions`. Deleted version URLs return 404; comments and surviving version numbers remain. This requires unrestricted owner credentials; agent-preset credentials cannot change retention. The edit API accepts the same setting as `retain_versions` (a positive integer or `null`) at `POST /api/cli/shareables/:id/edit`.
186
+ edit accepts --visibility private|workspace|project|link. Project visibility requires the artifact to be in a project after the edit; use --project-id <id> in the same request if needed. An explicit --visibility project at home (including --home) is refused without changes. Moving a project-visible artifact home makes it private only when project visibility is not explicitly requested.
187
+
188
+ Owners can run `edit <target> --retain-versions 24 --json` to keep the latest 24 eligible published versions, or `--retain-versions all` to clear the limit. For files created by or assigned to a publisher client, this counts only published publisher versions (including earlier clients) and keeps every version people added, even when an unrestricted owner changes the setting. Other files keep counting all published versions. The current version is always kept. Setting or lowering the limit immediately deletes older eligible versions and releases their storage. The response includes `retain_versions` and `deleted_versions`. Owners can also change this setting in the file history panel, with confirmation before removing existing versions. Authorized viewers opening a version removed by retention see an explanation and a latest-version link (HTTP 410); unknown version IDs still return 404 for signed-in viewers. Clearing the limit never restores deleted content. Comments and surviving version numbers remain. Unrestricted owner credentials can edit retention; publisher credentials can edit only retention on artifacts their client created or was assigned through the API. Agent credentials cannot change retention. The edit API accepts the same setting as `retain_versions` (a positive integer or `null`) at `POST /api/cli/shareables/:id/edit`.
187
189
 
188
190
  Link sharing is available on every plan; Team workspaces can turn it off. A workspace policy may allow a finite expiry from 1 to 365 days or no expiration; the initial default is 30 days and the initial maximum is no limit. Share and edit results include the confirmed `link_expires_at` UTC timestamp or `null`. If a link command fails, use `link_sharing_plan_required` as a legacy code (no plan limit applies today), `link_sharing_disabled` to ask the workspace owner or a Team owner or admin to enable the workspace setting, or `link_expiry_invalid` to correct the timestamp or choose `--no-link-expiry` when allowed. Under the default thresholds, `link_publish_rate_limited` means the service observed 20 counted files before a publication in a Free workspace less than 14 days old during its rolling 24-hour window. A file counts once for its most recent change to link visibility, or for creation with link visibility while it remains link-shared. Share with specific people. `error.recovery` indicates `retry_later`; use `error.message` and `error.hint` for when to retry. Retry the link publication later instead of retrying immediately with unchanged input.
189
191
 
@@ -293,3 +295,79 @@ physical objects once across retained versions; only sent files add bytes.
293
295
  Pruning keeps objects referenced by remaining versions. Version URLs retain
294
296
  immutable manifests. This is a REST API feature: there are no CLI `update`
295
297
  flags, MCP inputs, or bridge inputs for inheritance.
298
+
299
+ ### Publisher device credentials (API only)
300
+
301
+ Versions added with publisher credentials are scheduled updates: content and live viewers refresh, but list order, feeds, unread indicators, and human update labels do not change. Browser history marks Scheduled update without exposing client names. API `updated_at` remains the actual mutation time; internal `activity_at` controls human activity ordering. Initial creation and versions published through other credentials keep their existing behavior.
302
+
303
+ The device API accepts `preset: "publisher"` with a required `device_name`.
304
+ Names are trimmed, NFC-normalized, case-sensitive, and limited to 1–100 Unicode
305
+ letters, marks, numbers, ASCII spaces, or `._-()`. The browser approver explicitly
306
+ creates a new client or continues one of their existing clients in that workspace.
307
+ Names cannot be edited on the approval screen: if a name already exists, continue
308
+ that client or request login again with a different name. Only explicit continuation
309
+ restores access to earlier files; `device_id` never selects a client.
310
+
311
+ A publisher can create private HTML, Markdown, or static-site artifacts in the
312
+ approver's home. Static sites use `POST /api/shareables/uploads?artifact_kind=static_site`.
313
+ It can manage only artifacts created by or assigned to its client, still owned by
314
+ that approver in the same workspace, including after the owner shares or moves them.
315
+ Single-file versions require `expected_version`. Static-site versions accept
316
+ `artifact_kind=static_site` with either `expected_version` for replacement or
317
+ `base_version` for changed-files uploads and repeated `delete_path` removals.
318
+ The base must be current. Version uploads preserve audience, location and retention.
319
+
320
+ On artifacts created by or assigned to a publisher client, retention counts only published versions added with publisher credentials, including earlier clients, and keeps every other version. This also applies to unrestricted owner edits. The newest N publisher versions and every current version are kept; drafts do not count. Unmanaged artifacts continue to count all published versions.
321
+
322
+ The exact `GET /api/cli/artifacts/:id/download` returns raw source bytes for
323
+ single files and a JSON manifest with version id, paths and SHA-256 hashes for
324
+ static sites. Individual `download/*` requests are denied. `GET /api/cli/artifacts/:id`
325
+ includes visibility; static-site readback contains metadata only. No `include`
326
+ expansions are allowed. `DELETE /api/cli/artifacts/:id` deletes the artifact.
327
+ POST or PATCH `/api/cli/shareables/:id/edit` accepts only `retain_versions`, a
328
+ positive integer or null. Setting a limit prunes older versions immediately;
329
+ clearing it never restores deleted content. Other presets remain POST-only.
330
+
331
+ The owner can assign an existing artifact using an unrestricted credential or
332
+ browser session: `POST /api/cli/artifacts/:id/adopt` with
333
+ `{"publisher_client_id":"client1"}`. Obtain the verified client id from whoami or
334
+ doctor. Assignment replaces the previous client's access and is audited even when
335
+ repeated; historical creation attribution stays unchanged. Publisher credentials
336
+ cannot adopt. There is no adoption UI or CLI command.
337
+
338
+ Other clients' artifacts, list, resolve, comments, audience/title/expiry edits,
339
+ move, projects, append and upsert remain denied. Existing presets' download and
340
+ readback responses are unchanged. CLI publisher login/resume and publishing/download
341
+ workflows remain unsupported; use the API. Credentials retain their client across
342
+ rotation and can be revoked from Settings → CLI sessions.
343
+
344
+ ## Comment windows and posting limits
345
+
346
+ `comments list <target> --json` returns at most 50 threads, open first. Each
347
+ thread contains its current first message and latest three replies, plus
348
+ `message_count`, `reply_count` and `older_cursor`. These are partial histories.
349
+ Use `comments list <target> --thread-id <id> --before <older_cursor> --limit 50
350
+ --json` for older replies. Repeat with the returned cursor until it is null;
351
+ merge by message ID and display in `(created_at, message_id)` order. Each page
352
+ also includes the current first message. Cursors remain usable after their
353
+ boundary message is deleted. `--around-message-id <id>` selects a bounded page
354
+ containing a message; do not combine it with `--before`.
355
+
356
+ A thread holds 500 currently stored messages, including its first message.
357
+ `thread_capacity` means start a new thread. Existing excess messages are kept;
358
+ deletions can restore space. Deleting the first message promotes the next
359
+ earliest message; deleting the last removes the thread and anchor. Resolved
360
+ threads still refuse replies.
361
+
362
+ Creation and replies share 20 admissions per authenticated user and artifact
363
+ per fixed UTC minute across browser, CLI, MCP and API tokens. Adjacent minute
364
+ boundaries can admit 40 posts within a sliding 60 seconds. `rate_limited`
365
+ includes `retry_after_seconds` and UTC `retry_at`; HTTP also sends `Retry-After`.
366
+ Keep unsent content and retry after that time. Invalid requests, capacity refusals
367
+ and closed-thread refusals observed before admission consume nothing. Rate
368
+ refusals do not increment the counter; quota storage failures refuse the post.
369
+ Once admitted, commit failures and status/version/capacity races consume the admission without a
370
+ refund. Edits, deletions, resolve/reopen and anchor reports consume nothing.
371
+ Mutation readback contains only the affected thread window and changed message.
372
+ `refresh_required: true` means the write committed but advisory readback failed:
373
+ read that thread by ID; do not replay the write automatically.
package/dist/index.js CHANGED
@@ -101,16 +101,34 @@ const CliAuthRefreshCredentialsResponseSchema = z.object({
101
101
  });
102
102
  z.object({ refresh_token: z.string().min(1).max(256) });
103
103
  z.object({ revoked: z.literal(true) });
104
- const DeviceAuthorizationPresetSchema = z.enum(["unrestricted", "agent"]);
104
+ const DeviceAuthorizationPresetSchema = z.enum([
105
+ "unrestricted",
106
+ "agent",
107
+ "publisher"
108
+ ]);
109
+ const PublisherClientNameSchema = z.string().transform((value) => value.trim().normalize("NFC")).refine((value) => Array.from(value).length >= 1 && Array.from(value).length <= 100 && /^[\p{L}\p{M}\p{N} ._()-]+$/u.test(value) && !/\p{Default_Ignorable_Code_Point}/u.test(value) && /[\p{L}\p{N}._()-]/u.test(value), "Use 1–100 letters, marks, numbers, spaces, or ._-()");
105
110
  z.object({
106
111
  client_id: z.literal(CLI_DEVICE_CLIENT_ID),
107
112
  preset: DeviceAuthorizationPresetSchema.optional(),
108
- device_name: z.string().max(100).nullable().optional(),
113
+ device_name: z.string().nullable().optional(),
109
114
  project_selector: z.string().refine((value) => {
110
115
  const size = Array.from(value.trim()).length;
111
116
  return size >= 1 && size <= 120;
112
117
  }, "project_selector must contain 1 to 120 Unicode code points after trimming").optional()
113
118
  }).superRefine((value, context) => {
119
+ if (value.preset === "publisher") {
120
+ const name = PublisherClientNameSchema.safeParse(value.device_name);
121
+ if (!name.success) context.addIssue({
122
+ code: "custom",
123
+ path: ["device_name"],
124
+ message: "A valid publisher client name is required"
125
+ });
126
+ else value.device_name = name.data;
127
+ } else if (value.device_name != null && value.device_name.length > 100) context.addIssue({
128
+ code: "custom",
129
+ path: ["device_name"],
130
+ message: "device_name must contain at most 100 characters"
131
+ });
114
132
  if (value.preset !== "agent" && value.project_selector !== void 0) context.addIssue({
115
133
  code: "custom",
116
134
  path: ["project_selector"],
@@ -136,7 +154,12 @@ const DeviceTokenResponseSchema = z.object({
136
154
  token_type: z.string().min(1).refine((value) => value.toLowerCase() === "bearer", { message: "token_type must be Bearer" }),
137
155
  expires_in: z.number().int().nonnegative().optional()
138
156
  });
157
+ const PublisherApprovalChoiceSchema = z.discriminatedUnion("mode", [z.object({ mode: z.literal("create-new") }).strict(), z.object({
158
+ mode: z.literal("continue-existing"),
159
+ client_id: stringId
160
+ }).strict()]);
139
161
  z.object({
162
+ publisher: PublisherApprovalChoiceSchema.optional(),
140
163
  userCode: stringId,
141
164
  project_id: stringId.optional()
142
165
  });
@@ -157,7 +180,18 @@ const AgentApprovalSchema = z.object({
157
180
  fixedProject: FixedAgentApprovalProjectSchema.nullable(),
158
181
  fixedProjectError: z.boolean()
159
182
  });
160
- z.object({ agentApproval: AgentApprovalSchema.nullable() });
183
+ const PublisherApprovalSchema = z.object({
184
+ preset: z.literal("publisher"),
185
+ requestedName: PublisherClientNameSchema,
186
+ clients: z.array(z.object({
187
+ id: stringId,
188
+ name: PublisherClientNameSchema
189
+ }))
190
+ });
191
+ z.object({
192
+ publisherApproval: PublisherApprovalSchema.nullable().optional(),
193
+ agentApproval: AgentApprovalSchema.nullable()
194
+ });
161
195
  const CliUserSchema = z.object({
162
196
  id: stringId,
163
197
  email: z.string()
@@ -166,14 +200,28 @@ const CliWorkspaceSchema = z.object({
166
200
  id: stringId,
167
201
  hosted_domain: z.string().nullable()
168
202
  });
203
+ const DoctorAuthoritySchema = z.object({
204
+ preset: DeviceAuthorizationPresetSchema,
205
+ project_id: stringId.nullable(),
206
+ publisher_client_id: stringId.optional(),
207
+ publisher_client_name: PublisherClientNameSchema.optional()
208
+ }).superRefine((value, context) => {
209
+ if (value.preset === "publisher" && (value.project_id !== null || !value.publisher_client_id || !value.publisher_client_name)) context.addIssue({
210
+ code: "custom",
211
+ message: "Publisher diagnostics require a client and no project"
212
+ });
213
+ if (value.preset !== "publisher" && (value.publisher_client_id !== void 0 || value.publisher_client_name !== void 0)) context.addIssue({
214
+ code: "custom",
215
+ message: "Client attribution requires the publisher preset"
216
+ });
217
+ });
169
218
  const CliWhoamiResponseSchema = z.object({
170
219
  user: CliUserSchema,
171
220
  workspace: CliWorkspaceSchema,
172
- auth: z.object({ kind: z.literal("bearer_or_session") }).optional()
173
- });
174
- const DoctorAuthoritySchema = z.object({
175
- preset: DeviceAuthorizationPresetSchema,
176
- project_id: stringId.nullable()
221
+ auth: z.object({
222
+ kind: z.literal("bearer_or_session"),
223
+ authority: DoctorAuthoritySchema.optional()
224
+ }).optional()
177
225
  });
178
226
  const DoctorUploadSchema = z.union([z.object({ ok: z.literal(true) }), z.object({
179
227
  ok: z.literal(false),
@@ -316,6 +364,24 @@ const ArtifactReadResponseSchema = z.object({
316
364
  comments: z.array(z.lazy(() => CommentThreadSchema)).optional(),
317
365
  comments_has_more: z.boolean().optional()
318
366
  });
367
+ const PublisherSingleFileReadResponseSchema = ArtifactReadResponseSchema.extend({ visibility: VisibilitySchema });
368
+ const PublisherStaticSiteReadResponseSchema = z.object({
369
+ id: stringId,
370
+ share_url: url,
371
+ version_id: stringId,
372
+ artifact_kind: z.literal("static_site"),
373
+ visibility: VisibilitySchema,
374
+ project_id: stringId.nullable(),
375
+ link_expires_at: nullableTimestamp,
376
+ retain_versions: z.number().int().min(1).nullable()
377
+ });
378
+ z.union([PublisherSingleFileReadResponseSchema, PublisherStaticSiteReadResponseSchema]);
379
+ z.object({ retain_versions: z.number().int().min(1).nullable() }).strict();
380
+ z.object({ publisher_client_id: stringId }).strict();
381
+ z.object({
382
+ id: stringId,
383
+ publisher_client_id: stringId
384
+ }).strict();
319
385
  const ArtifactDeleteResponseSchema = z.object({
320
386
  id: stringId,
321
387
  deleted: z.literal(true)
@@ -383,13 +449,16 @@ const CommentMessageSchema = z.object({
383
449
  updated_at: timestamp
384
450
  });
385
451
  const CommentThreadSchema = z.object({
452
+ message_count: z.number().int().nonnegative(),
453
+ reply_count: z.number().int().nonnegative(),
454
+ older_cursor: z.string().nullable(),
386
455
  id: stringId,
387
456
  status: z.enum(["open", "resolved"]),
388
457
  resolved_at: nullableTimestamp,
389
458
  created_at: timestamp,
390
459
  updated_at: timestamp,
391
460
  anchor: CommentAnchorSchema,
392
- messages: z.array(CommentMessageSchema)
461
+ messages: z.array(CommentMessageSchema).max(51)
393
462
  });
394
463
  const CommentPostRequestSchema = z.object({
395
464
  action: z.never().optional(),
@@ -447,13 +516,17 @@ const CommentPostResponseSchema = z.object({
447
516
  share_url: url.nullable().optional(),
448
517
  thread_id: stringId,
449
518
  reply: z.boolean(),
450
- thread: CommentThreadSchema
519
+ thread: CommentThreadSchema.optional(),
520
+ changed_message: CommentMessageSchema.optional(),
521
+ refresh_required: z.boolean().optional()
451
522
  });
452
523
  const CommentActionResponseSchema = z.object({
453
524
  artifact_id: stringId,
454
525
  share_url: url.nullable().optional(),
455
526
  thread_id: stringId,
456
- thread: CommentThreadSchema
527
+ thread: CommentThreadSchema.optional(),
528
+ changed_message: CommentMessageSchema.optional(),
529
+ refresh_required: z.boolean().optional()
457
530
  });
458
531
  const CommentDeleteResponseSchema = z.object({
459
532
  artifact_id: stringId,
@@ -461,6 +534,8 @@ const CommentDeleteResponseSchema = z.object({
461
534
  thread_id: stringId,
462
535
  deleted: z.literal(true),
463
536
  thread_deleted: z.boolean(),
537
+ deleted_message_id: stringId.optional(),
538
+ refresh_required: z.boolean().optional(),
464
539
  thread: CommentThreadSchema.optional()
465
540
  });
466
541
  const ProjectListEntrySchema = z.object({
@@ -505,6 +580,7 @@ const ProjectEditResponseSchema = z.object({
505
580
  const CliEditableVisibilitySchema = z.enum([
506
581
  "private",
507
582
  "workspace",
583
+ "project",
508
584
  "link"
509
585
  ]);
510
586
  const CliDestinationSchema = z.union([z.literal("home"), z.object({ project_id: stringId })]);
@@ -664,6 +740,9 @@ const BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
664
740
  "unarchive"
665
741
  ]);
666
742
  const VALUE_FLAGS = /* @__PURE__ */ new Set([
743
+ "before",
744
+ "limit",
745
+ "around-message-id",
667
746
  "add-email",
668
747
  "agent",
669
748
  "base-url",
@@ -827,6 +906,20 @@ function apiError(body) {
827
906
  }
828
907
  function mapApiError(status, body, options = {}) {
829
908
  const { code: apiCode, message: apiMessage } = apiError(body);
909
+ if (apiCode === "rate-limited" || apiCode === "thread-capacity") {
910
+ const raw = isRecord$1(body) && isRecord$1(body.error) ? body.error : void 0;
911
+ const details = raw && isRecord$1(raw.details) ? raw.details : void 0;
912
+ return cliError({
913
+ code: apiCode === "rate-limited" ? "rate_limited" : "thread_capacity",
914
+ message: apiMessage ?? "Comment posting refused.",
915
+ why: apiCode === "rate-limited" ? "The comment posting limit for this minute was reached." : "This thread has reached its capacity of 500 stored messages.",
916
+ hint: apiCode === "rate-limited" ? "Wait until retry_at before retrying the unsent comment." : "Start a new thread, or delete messages from this thread before replying.",
917
+ agentRecoverable: true,
918
+ requiresHuman: false,
919
+ recovery: { kind: apiCode === "rate-limited" ? "retry_later" : "change_input" },
920
+ ...details ? { details } : {}
921
+ });
922
+ }
830
923
  if (status === 401) {
831
924
  if (!options.authenticated) return authRequiredError(options.baseUrl ?? "https://artifactshare.com");
832
925
  const source = options.credentialSource;
@@ -1104,6 +1197,15 @@ function mapApiError(status, body, options = {}) {
1104
1197
  command: PROJECTS_LIST_COMMAND
1105
1198
  }
1106
1199
  });
1200
+ if (options.editSettings && apiCode === "invalid-visibility") return cliError({
1201
+ code: "validation_failed",
1202
+ message: apiMessage ?? "Project visibility requires the artifact to be in a project.",
1203
+ why: "Project visibility requires project placement after the edit.",
1204
+ hint: "Use edit <id> --project-id <id> --visibility project, or move <id> --project-id <id> and retry --visibility project.",
1205
+ agentRecoverable: true,
1206
+ requiresHuman: false,
1207
+ recovery: { kind: "change_input" }
1208
+ });
1107
1209
  if (options.editSettings && apiCode === "workspace-unavailable") return cliError({
1108
1210
  code: "workspace_unavailable",
1109
1211
  message: apiMessage ?? "Workspace visibility is unavailable for this account.",
@@ -2058,8 +2160,10 @@ function isLocalHostname(hostname) {
2058
2160
  }
2059
2161
  function apiUrl(path, baseUrl) {
2060
2162
  const url = new URL(baseUrl);
2061
- url.pathname = `${url.pathname.replace(/\/$/, "")}${path}`;
2062
- url.search = "";
2163
+ const basePath = url.pathname.replace(/\/$/, "");
2164
+ const queryStart = path.indexOf("?");
2165
+ url.pathname = `${basePath}${queryStart < 0 ? path : path.slice(0, queryStart)}`;
2166
+ url.search = queryStart < 0 ? "" : path.slice(queryStart);
2063
2167
  url.hash = "";
2064
2168
  return url;
2065
2169
  }
@@ -3109,7 +3213,7 @@ async function clearPendingDeviceAuth(baseUrl, profile) {
3109
3213
  }
3110
3214
  function isPendingDeviceAuth(value) {
3111
3215
  if (!isRecord$1(value)) return false;
3112
- return typeof value.base_url === "string" && typeof value.profile === "string" && (value.preset === void 0 || value.preset === "unrestricted" || value.preset === "agent") && typeof value.device_code === "string" && typeof value.verification_uri === "string" && (typeof value.verification_uri_complete === "string" || value.verification_uri_complete === null) && typeof value.user_code === "string" && typeof value.expires_at === "string" && typeof value.interval_seconds === "number" && typeof value.created_at === "string";
3216
+ return typeof value.base_url === "string" && typeof value.profile === "string" && (value.preset === void 0 || value.preset === "unrestricted" || value.preset === "agent" || value.preset === "publisher") && typeof value.device_code === "string" && typeof value.verification_uri === "string" && (typeof value.verification_uri_complete === "string" || value.verification_uri_complete === null) && typeof value.user_code === "string" && typeof value.expires_at === "string" && typeof value.interval_seconds === "number" && typeof value.created_at === "string";
3113
3217
  }
3114
3218
  function resolveConfigHome(env, fallbackHome = homedir, platform = process.platform) {
3115
3219
  const override = nonEmpty(env.ARTIFACTSHARE_CONFIG_HOME);
@@ -3467,7 +3571,7 @@ function pendingDeviceAuthFromCode(profile, options, code) {
3467
3571
  return {
3468
3572
  base_url: baseUrlOf(options),
3469
3573
  profile,
3470
- preset: options.preset === "agent" ? "agent" : "unrestricted",
3574
+ preset: options.preset === "publisher" ? "publisher" : options.preset === "agent" ? "agent" : "unrestricted",
3471
3575
  device_code: code.device_code,
3472
3576
  verification_uri: code.verification_uri,
3473
3577
  verification_uri_complete: code.verification_uri_complete ?? null,
@@ -3587,6 +3691,11 @@ async function verifyProfileTokenAccount(profile, token, options, init) {
3587
3691
  ok: false,
3588
3692
  error: whoamiResult.error
3589
3693
  };
3694
+ const auth = isRecord$1(whoamiResult.body) && isRecord$1(whoamiResult.body.auth) ? whoamiResult.body.auth : null;
3695
+ if (auth?.authority !== void 0 && !DoctorAuthoritySchema.safeParse(auth.authority).success) return {
3696
+ ok: false,
3697
+ error: validationError("Token authority response was invalid.", "Retry with a supported credential. The token has not been saved.", "service_error")
3698
+ };
3590
3699
  const whoami = whoamiProfile(whoamiResult.body);
3591
3700
  const profiles = config.profiles ?? {};
3592
3701
  const expectedEmail = nonEmpty((Object.hasOwn(profiles, profile) ? profiles[profile] : void 0)?.email);
@@ -3630,7 +3739,7 @@ async function writeProfileConfig(profile, options, tokenStore, whoami) {
3630
3739
  email: whoami.email ?? currentProfile?.email ?? null,
3631
3740
  workspace_id: whoami.workspace_id,
3632
3741
  token_store: tokenStore,
3633
- preset: options.preset === "agent" || options.preset === "unrestricted" ? options.preset : currentProfile?.preset ?? "unrestricted",
3742
+ preset: whoami.preset ?? (options.preset === "publisher" || options.preset === "agent" || options.preset === "unrestricted" ? options.preset : currentProfile?.preset ?? "unrestricted"),
3634
3743
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3635
3744
  }
3636
3745
  }
@@ -3638,9 +3747,12 @@ async function writeProfileConfig(profile, options, tokenStore, whoami) {
3638
3747
  }
3639
3748
  async function resolveAuthorizationPreset(profile, options) {
3640
3749
  const requested = nonEmpty(options.preset);
3750
+ const stored = (await readGlobalConfig())?.profiles?.[profile]?.preset;
3751
+ if (requested === "publisher" || !requested && stored === "publisher") return { error: validationError("Publisher login is not supported by this CLI.", "Use the device API and explicitly continue your existing publisher client in the browser.") };
3641
3752
  if (requested && requested !== "agent" && requested !== "unrestricted") return { error: validationError(`Unknown authorization preset: ${requested}`, "Use --preset agent or --preset unrestricted.") };
3642
3753
  if (requested === "agent" || requested === "unrestricted") return { value: requested };
3643
- return { value: (await readGlobalConfig())?.profiles?.[profile]?.preset ?? "unrestricted" };
3754
+ if (stored !== void 0 && stored !== "agent" && stored !== "unrestricted") return { error: validationError("Unknown stored authorization preset.", "Select a supported preset explicitly.") };
3755
+ return { value: stored ?? "unrestricted" };
3644
3756
  }
3645
3757
  function deviceNameForProfile(profile) {
3646
3758
  const prefix = `Artifact Share CLI on ${platform()} ${arch()} (`;
@@ -3668,6 +3780,7 @@ function deviceTokenError(body) {
3668
3780
  function whoamiProfile(body) {
3669
3781
  const contracted = CliWhoamiResponseSchema.safeParse(body);
3670
3782
  if (contracted.success) return {
3783
+ ...contracted.data.auth?.authority ? { preset: contracted.data.auth.authority.preset } : {},
3671
3784
  email: contracted.data.user.email,
3672
3785
  workspace_id: contracted.data.workspace.id,
3673
3786
  hosted_domain: contracted.data.workspace.hosted_domain
@@ -3675,7 +3788,10 @@ function whoamiProfile(body) {
3675
3788
  const record = isRecord$1(body) ? body : null;
3676
3789
  const user = record && isRecord$1(record.user) ? record.user : null;
3677
3790
  const workspace = record && isRecord$1(record.workspace) ? record.workspace : null;
3791
+ const auth = record && isRecord$1(record.auth) ? record.auth : null;
3792
+ const preset = (auth && isRecord$1(auth.authority) ? auth.authority : null)?.preset;
3678
3793
  return {
3794
+ ...preset === "publisher" || preset === "agent" || preset === "unrestricted" ? { preset } : {},
3679
3795
  email: typeof user?.email === "string" ? user.email : null,
3680
3796
  workspace_id: typeof workspace?.id === "string" ? workspace.id : null,
3681
3797
  hosted_domain: typeof workspace?.hosted_domain === "string" ? workspace.hosted_domain : null
@@ -3835,6 +3951,7 @@ async function handleJsonPendingAuth(command, credential, options, mode, rerun)
3835
3951
  if (!configHome()) return writeFailure(command, configHomeUnavailableError(profile), mode, 1);
3836
3952
  if (!await canAttemptProfileTokenSave(profile, options)) return writeFailure(command, tokenStoreUnavailableError(profile, "native_store_unavailable"), mode, 1);
3837
3953
  const existing = await readPendingDeviceAuth(baseUrl, profile);
3954
+ if (existing?.preset === "publisher") return writeFailure(command, validationError("Publisher login cannot be resumed by this CLI.", "Use the device API and approve an existing or new publisher client in the browser."), mode, 1);
3838
3955
  if (existing && !isPendingExpired(existing)) {
3839
3956
  const exchange = await exchangeDeviceTokenOnce(options, existing.device_code, request.init);
3840
3957
  if ("error" in exchange) {
@@ -3859,6 +3976,7 @@ async function handleJsonPendingAuth(command, credential, options, mode, rerun)
3859
3976
  else return writeFailure(command, authRequiredWithDeviceAuthError(baseUrl, existing, extraDetails), mode, 1);
3860
3977
  } else if (existing) await clearPendingDeviceAuth(baseUrl, profile);
3861
3978
  const preset = (await readGlobalConfig())?.profiles?.[profile]?.preset ?? "unrestricted";
3979
+ if (preset !== "agent" && preset !== "unrestricted") return writeFailure(command, validationError("This preset cannot log in through the CLI.", "Use the device API to approve or continue the publisher client."), mode, 1);
3862
3980
  const code = await requestDeviceCode(options, request.init, {
3863
3981
  preset,
3864
3982
  deviceName: deviceNameForProfile(profile)
@@ -11094,12 +11212,20 @@ async function runCommentsList(parsed, mode) {
11094
11212
  const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL.");
11095
11213
  if (target.error) return writeFailure(command, target.error, mode, 1);
11096
11214
  const artifactId = target.artifactId;
11215
+ const page = new URLSearchParams();
11216
+ for (const [key, value] of Object.entries({
11217
+ thread_id: parsed.options.threadId,
11218
+ before: parsed.options.before,
11219
+ limit: parsed.options.limit,
11220
+ around_message_id: parsed.options.aroundMessageId
11221
+ })) if (value !== void 0) page.set(key, value);
11222
+ if ([...page.values()].some((value) => value.length === 0) || page.size > 0 && !parsed.options.threadId || parsed.options.before !== void 0 && parsed.options.aroundMessageId !== void 0 || parsed.options.limit !== void 0 && (!/^[1-9]\d*$/.test(parsed.options.limit) || Number(parsed.options.limit) > 50 || !parsed.options.before && !parsed.options.aroundMessageId)) return writeFailure(command, validationError("Invalid comment page options.", "Use --thread-id with --before or --around-message-id and a limit from 1 to 50."), mode, 1);
11097
11223
  const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
11098
11224
  if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
11099
11225
  const request = await requestConfig(parsed.options);
11100
11226
  if (request.error) return writeFailure(command, request.error, mode, 1);
11101
11227
  const result = await runAuthenticatedApi(credential, parsed.options, async (current) => {
11102
- const comments = await apiGet(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments`, current.token, parsed.options, request.init, {
11228
+ const comments = await apiGet(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments${page.size ? `?${page}` : ""}`, current.token, parsed.options, request.init, {
11103
11229
  artifactTarget: true,
11104
11230
  credentialSource: current.source,
11105
11231
  profile: current.profile,
@@ -11163,7 +11289,9 @@ async function runCommentsPost(parsed, mode) {
11163
11289
  share_url: configString(postedResponse?.share_url ?? postedRaw?.share_url),
11164
11290
  thread_id: threadId,
11165
11291
  reply: (postedResponse?.reply ?? postedRaw?.reply) === true,
11166
- thread: postedResponse?.thread ?? postedRaw?.thread ?? null
11292
+ thread: postedResponse?.thread ?? postedRaw?.thread ?? null,
11293
+ changed_message: postedResponse?.changed_message ?? postedRaw?.changed_message,
11294
+ refresh_required: postedResponse?.refresh_required ?? postedRaw?.refresh_required
11167
11295
  }, mode);
11168
11296
  }
11169
11297
  async function runCommentsEdit(parsed, mode) {
@@ -11184,12 +11312,14 @@ async function runCommentsEdit(parsed, mode) {
11184
11312
  const actionRaw = isRecord$1(result) ? result : null;
11185
11313
  const threadId = configString(actionResponse?.thread_id ?? actionRaw?.thread_id);
11186
11314
  const thread = actionResponse?.thread ?? actionRaw?.thread;
11187
- if (!threadId || thread === void 0) return writeFailure(command, serviceError("Comment was changed but the response had no thread."), mode, 1);
11315
+ if (!threadId) return writeFailure(command, serviceError("Comment was changed but the response had no thread."), mode, 1);
11188
11316
  writeSuccess(command, {
11189
11317
  artifact_id: target.artifactId,
11190
11318
  share_url: configString(actionResponse?.share_url ?? actionRaw?.share_url),
11191
11319
  thread_id: threadId,
11192
- thread
11320
+ thread,
11321
+ changed_message: actionResponse?.changed_message ?? actionRaw?.changed_message,
11322
+ refresh_required: actionResponse?.refresh_required ?? actionRaw?.refresh_required
11193
11323
  }, mode);
11194
11324
  }
11195
11325
  async function runCommentsResolve(parsed, mode) {
@@ -11226,6 +11356,8 @@ async function runCommentsDelete(parsed, mode) {
11226
11356
  share_url: configString(deleteResponse?.share_url ?? deleteRaw?.share_url),
11227
11357
  thread_id: responseThreadId,
11228
11358
  deleted: true,
11359
+ deleted_message_id: deleteResponse?.deleted_message_id ?? deleteRaw?.deleted_message_id,
11360
+ refresh_required: deleteResponse?.refresh_required ?? deleteRaw?.refresh_required,
11229
11361
  thread_deleted: (deleteResponse?.thread_deleted ?? deleteRaw?.thread_deleted) === true,
11230
11362
  ...(deleteResponse?.thread ?? deleteRaw?.thread) !== void 0 ? { thread: deleteResponse?.thread ?? deleteRaw?.thread } : {}
11231
11363
  }, mode);
@@ -11247,12 +11379,14 @@ async function runCommentsStatus(parsed, mode, command, action) {
11247
11379
  const actionRaw = isRecord$1(result) ? result : null;
11248
11380
  const responseThreadId = configString(actionResponse?.thread_id ?? actionRaw?.thread_id);
11249
11381
  const thread = actionResponse?.thread ?? actionRaw?.thread;
11250
- if (!responseThreadId || thread === void 0) return writeFailure(command, serviceError("Comment was changed but the response had no thread."), mode, 1);
11382
+ if (!responseThreadId) return writeFailure(command, serviceError("Comment was changed but the response had no thread."), mode, 1);
11251
11383
  writeSuccess(command, {
11252
11384
  artifact_id: target.artifactId,
11253
11385
  share_url: configString(actionResponse?.share_url ?? actionRaw?.share_url),
11254
11386
  thread_id: responseThreadId,
11255
- thread
11387
+ thread,
11388
+ changed_message: actionResponse?.changed_message ?? actionRaw?.changed_message,
11389
+ refresh_required: actionResponse?.refresh_required ?? actionRaw?.refresh_required
11256
11390
  }, mode);
11257
11391
  }
11258
11392
  async function postCommentAction(parsed, command, artifactId, payload, mode) {
@@ -11448,6 +11582,13 @@ async function runDoctor(parsed, mode) {
11448
11582
  const authority = doctorAuthority(auth?.authority);
11449
11583
  if (authority) data.auth.authority = authority;
11450
11584
  applyAgentDestinationDiagnostic(data, authority);
11585
+ if (authority?.preset === "publisher") data.destination = {
11586
+ ok: true,
11587
+ type: "home",
11588
+ project_id: null,
11589
+ code: "publisher_scope",
11590
+ hint: `Publisher ${authority.publisher_client_name}: create private files or static sites in home; read, update, prune versions and delete artifacts created by or assigned to this client. Use the API; publisher CLI login and publishing workflows are not supported.`
11591
+ };
11451
11592
  data.upload.checked = true;
11452
11593
  data.upload.ok = upload?.ok === true;
11453
11594
  if (!data.upload.ok) {
@@ -11459,6 +11600,12 @@ async function runDoctor(parsed, mode) {
11459
11600
  function doctorAuthority(value) {
11460
11601
  if (!value || typeof value !== "object") return null;
11461
11602
  const authority = value;
11603
+ if (authority.preset === "publisher" && authority.project_id === null && typeof authority.publisher_client_id === "string" && typeof authority.publisher_client_name === "string") return {
11604
+ preset: "publisher",
11605
+ project_id: null,
11606
+ publisher_client_id: authority.publisher_client_id,
11607
+ publisher_client_name: authority.publisher_client_name
11608
+ };
11462
11609
  if (authority.preset === "agent" && typeof authority.project_id === "string" && authority.project_id) return {
11463
11610
  preset: "agent",
11464
11611
  project_id: authority.project_id
@@ -12152,7 +12299,7 @@ function buildEditPayload(parsed) {
12152
12299
  }
12153
12300
  if (parsed.options.visibility !== void 0) {
12154
12301
  const visibility = parsed.options.visibility.trim();
12155
- if (visibility !== "private" && visibility !== "workspace" && visibility !== "link") return { error: validationError("--visibility must be private, workspace, or link.", "Retry with --visibility private, --visibility workspace, or --visibility link.") };
12302
+ if (visibility !== "private" && visibility !== "workspace" && visibility !== "project" && visibility !== "link") return { error: validationError("--visibility must be private, workspace, project, or link.", "Retry with --visibility private, --visibility workspace, --visibility project, or --visibility link.") };
12156
12303
  body.visibility = visibility;
12157
12304
  hasChange = true;
12158
12305
  }
@@ -13785,7 +13932,7 @@ const editDefinition = define({
13785
13932
  visibility: {
13786
13933
  type: "string",
13787
13934
  toKebab: true,
13788
- description: "private, workspace, or link"
13935
+ description: "private, workspace, project, or link (project requires placement in a project)"
13789
13936
  },
13790
13937
  linkExpiresAt: {
13791
13938
  type: "string",
@@ -13795,7 +13942,7 @@ const editDefinition = define({
13795
13942
  retainVersions: {
13796
13943
  type: "string",
13797
13944
  toKebab: true,
13798
- description: "Keep the latest N versions; use all to clear retention (owner only)"
13945
+ description: "N or all (owner only). Keeps the latest N versions; publisher-managed artifacts count only publisher versions and keep all versions people added. Older eligible versions are permanently deleted; all clears the limit."
13799
13946
  },
13800
13947
  noLinkExpiry: {
13801
13948
  type: "boolean",
@@ -13828,6 +13975,7 @@ const editDefinition = define({
13828
13975
  examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare edit abc123def4 --title "Launch plan" --json
13829
13976
  npm exec --yes --package=@artifactshare/cli -- artifactshare edit abc123def4 --visibility private --grant-email viewer@example.com --json
13830
13977
  npm exec --yes --package=@artifactshare/cli -- artifactshare edit https://artifactshare.com/a/abc123def4 --project-id prj123 --json
13978
+ npm exec --yes --package=@artifactshare/cli -- artifactshare edit abc123def4 --project-id prj1 --visibility project --json
13831
13979
  npm exec --yes --package=@artifactshare/cli -- artifactshare edit abc123def4 --home --json
13832
13980
 
13833
13981
  Link sharing accepts --visibility link with either --link-expires-at <RFC3339 UTC> or --no-link-expiry. These expiry options are mutually exclusive.
@@ -14094,6 +14242,24 @@ const commentsListDefinition = define({
14094
14242
  toKebab: true,
14095
14243
  args: {
14096
14244
  ...commonArgs,
14245
+ threadId: {
14246
+ type: "string",
14247
+ toKebab: true,
14248
+ description: "Read one thread, including threads outside the panel"
14249
+ },
14250
+ before: {
14251
+ type: "string",
14252
+ description: "Read older replies using older_cursor; requires --thread-id"
14253
+ },
14254
+ limit: {
14255
+ type: "string",
14256
+ description: "Replies per page (1–50, default 50); requires --before or --around-message-id"
14257
+ },
14258
+ aroundMessageId: {
14259
+ type: "string",
14260
+ toKebab: true,
14261
+ description: "Read a bounded page containing this message; requires --thread-id"
14262
+ },
14097
14263
  artifactIdOrUrl: {
14098
14264
  type: "positional",
14099
14265
  toKebab: true,
@@ -14103,7 +14269,11 @@ const commentsListDefinition = define({
14103
14269
  examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments list abc123def4 --json
14104
14270
 
14105
14271
  Returns up to 50 threads (open threads first); has_more reports whether more exist.
14106
- Each thread carries its messages, status, and quoted-text anchor when present.
14272
+ Each thread carries its first message and latest three replies, message_count,
14273
+ reply_count, older_cursor, status, and quoted-text anchor when present.
14274
+ Read older replies with --thread-id <id> --before <older_cursor> --limit 50.
14275
+ Repeat with the returned older_cursor until null. --around-message-id <id>
14276
+ loads a target-containing page; do not combine it with --before.
14107
14277
 
14108
14278
  Common failures:
14109
14279
  auth_required Set ARTIFACTSHARE_TOKEN before comments list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.15.2",
3
+ "version": "0.16.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": {
@@ -46,25 +46,26 @@ The browser share page opens HTML, Markdown, and static sites with its URL fragm
46
46
 
47
47
  ## Quick reference
48
48
 
49
- | Task | Command |
50
- | ------------------------ | ------------------------------------------------------------------------- |
51
- | Share a file or folder | `share <path> --json` |
52
- | Share a link with expiry | `share <path> --visibility link --link-expires-at '<RFC3339 UTC>' --json` |
53
- | Replace with same URL | `update <target> <path> --json` |
54
- | Append to same URL | `append <target> <path> --json` |
55
- | Read back source | `artifacts get <target> --json` |
56
- | Download a site bundle | `download <target> --output ./out --json` |
57
- | Download a whole project | `download --project-id <id> --output ./out --json` |
58
- | List your artifacts | `artifacts list --json` |
59
- | Post a comment | `comments post <target> --body '<text>' --json` |
60
- | Read comments | `comments list <target> --json` |
61
- | Change title or sharing | `edit <target> --title 'New' --json` |
62
- | Move to a project | `edit <target> --project-id <id> --json` |
63
- | Create a project | `projects create 'Name' --json` |
64
- | Find an ID from a title | `resolve <value> --json` |
65
- | Open a share URL | `open <url> --json` |
66
- | Preview a local file | `preview <file> --json` (local, no sign-in) |
67
- | Log out | `logout --profile <name> --json` |
49
+ | Task | Command |
50
+ | ------------------------ | ----------------------------------------------------------------------------------- |
51
+ | Share a file or folder | `share <path> --json` |
52
+ | Share a link with expiry | `share <path> --visibility link --link-expires-at '<RFC3339 UTC>' --json` |
53
+ | Replace with same URL | `update <target> <path> --json` |
54
+ | Append to same URL | `append <target> <path> --json` |
55
+ | Read back source | `artifacts get <target> --json` |
56
+ | Download a site bundle | `download <target> --output ./out --json` |
57
+ | Download a whole project | `download --project-id <id> --output ./out --json` |
58
+ | List your artifacts | `artifacts list --json` |
59
+ | Post a comment | `comments post <target> --body '<text>' --json` |
60
+ | Read comments | `comments list <target> --json` |
61
+ | Read older replies | `comments list <target> --thread-id <id> --before <older_cursor> --limit 50 --json` |
62
+ | Change title or sharing | `edit <target> --title 'New' --json` |
63
+ | Move to a project | `edit <target> --project-id <id> --json` |
64
+ | Create a project | `projects create 'Name' --json` |
65
+ | Find an ID from a title | `resolve <value> --json` |
66
+ | Open a share URL | `open <url> --json` |
67
+ | Preview a local file | `preview <file> --json` (local, no sign-in) |
68
+ | Log out | `logout --profile <name> --json` |
68
69
 
69
70
  ## Authentication
70
71
 
@@ -279,16 +280,20 @@ project management.
279
280
  npm exec --yes --package=@artifactshare/cli -- artifactshare edit <artifact-id-or-url> --title 'New title' --json
280
281
  npm exec --yes --package=@artifactshare/cli -- artifactshare edit <artifact-id-or-url> --visibility private --grant-email viewer@example.com --json
281
282
  npm exec --yes --package=@artifactshare/cli -- artifactshare edit <artifact-id-or-url> --project-id <id> --json
283
+ npm exec --yes --package=@artifactshare/cli -- artifactshare edit <artifact-id-or-url> --visibility project --json
282
284
  npm exec --yes --package=@artifactshare/cli -- artifactshare edit <artifact-id-or-url> --home --json
283
285
  npm exec --yes --package=@artifactshare/cli -- artifactshare delete <artifact-id-or-url> --json
284
286
  ```
285
287
 
286
288
  - Owners with unrestricted credentials can set `edit <target> --retain-versions N`
287
- to keep the latest N published versions, or `--retain-versions all` to keep all
288
- future versions. Setting or lowering retention immediately deletes older
289
+ to keep the latest N eligible published versions, or `--retain-versions all` to keep all
290
+ future versions. For files created by or assigned to a publisher client, this counts only published publisher versions (including earlier clients) and keeps every version people added, even when an unrestricted owner changes the setting. Other files keep counting all published versions. The current version is always kept. Setting or lowering retention immediately deletes older eligible
289
291
  versions; the response reports `retain_versions` and `deleted_versions`.
290
- Deleted version links return 404, while comments and surviving version numbers
291
- remain. Agent-preset credentials cannot change retention.
292
+ Owners can also use the file history panel, which confirms existing removals.
293
+ Authorized viewers of versions removed by retention see an explanation and
294
+ a latest-version link (HTTP 410). Unknown IDs still return 404 for signed-in
295
+ viewers. Clearing the limit never restores deleted content. Comments and
296
+ surviving version numbers remain. Agent-preset credentials cannot change retention.
292
297
  - `edit` changes title, visibility, explicit viewers, or project placement
293
298
  without adding a new version.
294
299
  - Set `--visibility link` with `--link-expires-at <RFC3339 UTC>` for a finite
@@ -312,8 +317,7 @@ npm exec --yes --package=@artifactshare/cli -- artifactshare delete <artifact-id
312
317
  `error.hint` for when to retry, and honor the returned retry duration. Retry
313
318
  the link publication later instead of retrying immediately with unchanged
314
319
  input.
315
- - Moving a `project` visibility artifact home makes it `private`, because home
316
- has no project audience.
320
+ - edit accepts --visibility private|workspace|project|link. Project visibility requires the artifact to be in a project after the edit; use --project-id <id> in the same request if needed. An explicit --visibility project at home (including --home) is refused without changes. Moving a project-visible artifact home makes it private only when project visibility is not explicitly requested.
317
321
  - The older `move` command remains available for placement-only automation, but
318
322
  prefer `edit` for new flows.
319
323
  - `artifacts delete <artifact-id-or-url>` is an alias of `delete`; both return JSON `command: "delete"`. Keep using top-level `delete` in deletion workflows.
@@ -628,3 +632,79 @@ physical objects once across retained versions; only sent files add bytes.
628
632
  Pruning keeps objects referenced by remaining versions. Version URLs retain
629
633
  immutable manifests. This is a REST API feature: there are no CLI `update`
630
634
  flags, MCP inputs, or bridge inputs for inheritance.
635
+
636
+ ### Publisher device credentials (API only)
637
+
638
+ Versions added with publisher credentials are scheduled updates: content and live viewers refresh, but list order, feeds, unread indicators, and human update labels do not change. Browser history marks Scheduled update without exposing client names. API `updated_at` remains the actual mutation time; internal `activity_at` controls human activity ordering. Initial creation and versions published through other credentials keep their existing behavior.
639
+
640
+ The device API accepts `preset: "publisher"` with a required `device_name`.
641
+ Names are trimmed, NFC-normalized, case-sensitive, and limited to 1–100 Unicode
642
+ letters, marks, numbers, ASCII spaces, or `._-()`. The browser approver explicitly
643
+ creates a new client or continues one of their existing clients in that workspace.
644
+ Names cannot be edited on the approval screen: if a name already exists, continue
645
+ that client or request login again with a different name. Only explicit continuation
646
+ restores access to earlier files; `device_id` never selects a client.
647
+
648
+ A publisher can create private HTML, Markdown, or static-site artifacts in the
649
+ approver's home. Static sites use `POST /api/shareables/uploads?artifact_kind=static_site`.
650
+ It can manage only artifacts created by or assigned to its client, still owned by
651
+ that approver in the same workspace, including after the owner shares or moves them.
652
+ Single-file versions require `expected_version`. Static-site versions accept
653
+ `artifact_kind=static_site` with either `expected_version` for replacement or
654
+ `base_version` for changed-files uploads and repeated `delete_path` removals.
655
+ The base must be current. Version uploads preserve audience, location and retention.
656
+
657
+ On artifacts created by or assigned to a publisher client, retention counts only published versions added with publisher credentials, including earlier clients, and keeps every other version. This also applies to unrestricted owner edits. The newest N publisher versions and every current version are kept; drafts do not count. Unmanaged artifacts continue to count all published versions.
658
+
659
+ The exact `GET /api/cli/artifacts/:id/download` returns raw source bytes for
660
+ single files and a JSON manifest with version id, paths and SHA-256 hashes for
661
+ static sites. Individual `download/*` requests are denied. `GET /api/cli/artifacts/:id`
662
+ includes visibility; static-site readback contains metadata only. No `include`
663
+ expansions are allowed. `DELETE /api/cli/artifacts/:id` deletes the artifact.
664
+ POST or PATCH `/api/cli/shareables/:id/edit` accepts only `retain_versions`, a
665
+ positive integer or null. Setting a limit prunes older versions immediately;
666
+ clearing it never restores deleted content. Other presets remain POST-only.
667
+
668
+ The owner can assign an existing artifact using an unrestricted credential or
669
+ browser session: `POST /api/cli/artifacts/:id/adopt` with
670
+ `{"publisher_client_id":"client1"}`. Obtain the verified client id from whoami or
671
+ doctor. Assignment replaces the previous client's access and is audited even when
672
+ repeated; historical creation attribution stays unchanged. Publisher credentials
673
+ cannot adopt. There is no adoption UI or CLI command.
674
+
675
+ Other clients' artifacts, list, resolve, comments, audience/title/expiry edits,
676
+ move, projects, append and upsert remain denied. Existing presets' download and
677
+ readback responses are unchanged. CLI publisher login/resume and publishing/download
678
+ workflows remain unsupported; use the API. Credentials retain their client across
679
+ rotation and can be revoked from Settings → CLI sessions.
680
+
681
+ ## Comment windows and posting limits
682
+
683
+ `comments list <target> --json` returns at most 50 threads, open first. Each
684
+ thread contains its current first message and latest three replies, plus
685
+ `message_count`, `reply_count` and `older_cursor`. These are partial histories.
686
+ Use `comments list <target> --thread-id <id> --before <older_cursor> --limit 50
687
+ --json` for older replies. Repeat with the returned cursor until it is null;
688
+ merge by message ID and display in `(created_at, message_id)` order. Each page
689
+ also includes the current first message. Cursors remain usable after their
690
+ boundary message is deleted. `--around-message-id <id>` selects a bounded page
691
+ containing a message; do not combine it with `--before`.
692
+
693
+ A thread holds 500 currently stored messages, including its first message.
694
+ `thread_capacity` means start a new thread. Existing excess messages are kept;
695
+ deletions can restore space. Deleting the first message promotes the next
696
+ earliest message; deleting the last removes the thread and anchor. Resolved
697
+ threads still refuse replies.
698
+
699
+ Creation and replies share 20 admissions per authenticated user and artifact
700
+ per fixed UTC minute across browser, CLI, MCP and API tokens. Adjacent minute
701
+ boundaries can admit 40 posts within a sliding 60 seconds. `rate_limited`
702
+ includes `retry_after_seconds` and UTC `retry_at`; HTTP also sends `Retry-After`.
703
+ Keep unsent content and retry after that time. Invalid requests, capacity refusals
704
+ and closed-thread refusals observed before admission consume nothing. Rate
705
+ refusals do not increment the counter; quota storage failures refuse the post.
706
+ Once admitted, commit failures and status/version/capacity races consume the admission without a
707
+ refund. Edits, deletions, resolve/reopen and anchor reports consume nothing.
708
+ Mutation readback contains only the affected thread window and changed message.
709
+ `refresh_required: true` means the write committed but advisory readback failed:
710
+ read that thread by ID; do not replay the write automatically.
@@ -73,7 +73,7 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
73
73
  Quoted comments are resolved in the viewer using the exact quote and surrounding context, never the nearest repeated words. `--quote-before` and `--quote-after` accept up to 400 characters per side; preserve spaces next to the quote. Creation does not search the artifact. Optional `anchor.position_state` is `unchecked` until that version is viewed, then `attached` or `needs-check`. Only `attached` maps to `anchor.state: attached`; both other states map to `orphaned`. Older responses may omit `position_state`. Local preview uses the same strict resolution on every reload and preserves the original quote when its position needs checking.
74
74
 
75
75
  - Edit, resolve, reopen, and delete comments with `comments edit`, `comments resolve`, `comments reopen`, and `comments delete` using IDs from `comments list`. Comment deletion cannot be undone; omit `--message-id` from `comments delete` only when the user wants the whole thread deleted.
76
- - Change post-share settings with `edit <target>`: `--title`, `--visibility private|workspace|link`, `--link-expires-at <RFC3339 UTC>`, `--no-link-expiry`, `--grant-email`, `--revoke-email`, `--project-id`, `--home`. The expiry options are mutually exclusive; omit both to preserve an existing link expiry. Moving a `project` visibility file home makes it `private`. `move` remains for placement-only automation; prefer `edit`.
76
+ - Change post-share settings with `edit <target>`: `--title`, `--visibility private|workspace|project|link`, `--link-expires-at <RFC3339 UTC>`, `--no-link-expiry`, `--grant-email`, `--revoke-email`, `--project-id`, `--home`. The expiry options are mutually exclusive; omit both to preserve an existing link expiry. Project visibility requires the artifact to be in a project after the edit; use --project-id <id> in the same request if needed. An explicit --visibility project at home (including --home) is refused without changes. Moving a project-visible artifact home makes it private only when project visibility is not explicitly requested. `move` remains for placement-only automation; prefer `edit`.
77
77
  - For link errors, `link_sharing_plan_required` is a legacy code (Free can use link sharing now),
78
78
  `link_sharing_disabled` means the workspace owner (or a Team admin) must resume the workspace
79
79
  setting, and `link_expiry_invalid` means the timestamp must be future and
@@ -126,7 +126,7 @@ version menu and full history show the label as plain text.
126
126
  Labels are update-only: initial uploads, `share --key`, `append`, preview,
127
127
  bridge publishing, and MCP update inputs do not accept them.
128
128
 
129
- Owners with unrestricted credentials can use `edit <target> --retain-versions N` to keep the latest N versions, or `--retain-versions all` to clear the limit. Setting or lowering retention prunes older published versions immediately; the response includes `retain_versions` and `deleted_versions`. Comments and surviving version numbers remain. Agent-preset credentials cannot change retention.
129
+ Owners with unrestricted credentials can use `edit <target> --retain-versions N` to keep the latest N eligible published versions, or `--retain-versions all` to clear the limit. For files created by or assigned to a publisher client, this counts only published publisher versions (including earlier clients) and keeps every version people added, even when an unrestricted owner changes the setting. Other files keep counting all published versions. The current version is always kept. Setting or lowering retention prunes older eligible published versions immediately; the response includes `retain_versions` and `deleted_versions`. Owners can also change this setting in file history, with confirmation before existing versions are removed. Authorized viewers of removed versions see an explanation and a latest-version link (HTTP 410). Clearing never restores deleted content. Comments and surviving version numbers remain. Agent-preset credentials cannot change retention.
130
130
 
131
131
  The browser share page opens HTML, Markdown, and static sites with its URL fragment (`#…`) and follows fragment changes inside the frame. Copy link includes the current fragment, so filtered views and Markdown headings can be shared. For static sites, only the entrypoint updates the share fragment; subpages leave it unchanged. This does not change CLI local preview.
132
132
 
@@ -191,3 +191,79 @@ physical objects once across retained versions; only sent files add bytes.
191
191
  Pruning keeps objects referenced by remaining versions. Version URLs retain
192
192
  immutable manifests. This is a REST API feature: there are no CLI `update`
193
193
  flags, MCP inputs, or bridge inputs for inheritance.
194
+
195
+ ### Publisher device credentials (API only)
196
+
197
+ Versions added with publisher credentials are scheduled updates: content and live viewers refresh, but list order, feeds, unread indicators, and human update labels do not change. Browser history marks Scheduled update without exposing client names. API `updated_at` remains the actual mutation time; internal `activity_at` controls human activity ordering. Initial creation and versions published through other credentials keep their existing behavior.
198
+
199
+ The device API accepts `preset: "publisher"` with a required `device_name`.
200
+ Names are trimmed, NFC-normalized, case-sensitive, and limited to 1–100 Unicode
201
+ letters, marks, numbers, ASCII spaces, or `._-()`. The browser approver explicitly
202
+ creates a new client or continues one of their existing clients in that workspace.
203
+ Names cannot be edited on the approval screen: if a name already exists, continue
204
+ that client or request login again with a different name. Only explicit continuation
205
+ restores access to earlier files; `device_id` never selects a client.
206
+
207
+ A publisher can create private HTML, Markdown, or static-site artifacts in the
208
+ approver's home. Static sites use `POST /api/shareables/uploads?artifact_kind=static_site`.
209
+ It can manage only artifacts created by or assigned to its client, still owned by
210
+ that approver in the same workspace, including after the owner shares or moves them.
211
+ Single-file versions require `expected_version`. Static-site versions accept
212
+ `artifact_kind=static_site` with either `expected_version` for replacement or
213
+ `base_version` for changed-files uploads and repeated `delete_path` removals.
214
+ The base must be current. Version uploads preserve audience, location and retention.
215
+
216
+ On artifacts created by or assigned to a publisher client, retention counts only published versions added with publisher credentials, including earlier clients, and keeps every other version. This also applies to unrestricted owner edits. The newest N publisher versions and every current version are kept; drafts do not count. Unmanaged artifacts continue to count all published versions.
217
+
218
+ The exact `GET /api/cli/artifacts/:id/download` returns raw source bytes for
219
+ single files and a JSON manifest with version id, paths and SHA-256 hashes for
220
+ static sites. Individual `download/*` requests are denied. `GET /api/cli/artifacts/:id`
221
+ includes visibility; static-site readback contains metadata only. No `include`
222
+ expansions are allowed. `DELETE /api/cli/artifacts/:id` deletes the artifact.
223
+ POST or PATCH `/api/cli/shareables/:id/edit` accepts only `retain_versions`, a
224
+ positive integer or null. Setting a limit prunes older versions immediately;
225
+ clearing it never restores deleted content. Other presets remain POST-only.
226
+
227
+ The owner can assign an existing artifact using an unrestricted credential or
228
+ browser session: `POST /api/cli/artifacts/:id/adopt` with
229
+ `{"publisher_client_id":"client1"}`. Obtain the verified client id from whoami or
230
+ doctor. Assignment replaces the previous client's access and is audited even when
231
+ repeated; historical creation attribution stays unchanged. Publisher credentials
232
+ cannot adopt. There is no adoption UI or CLI command.
233
+
234
+ Other clients' artifacts, list, resolve, comments, audience/title/expiry edits,
235
+ move, projects, append and upsert remain denied. Existing presets' download and
236
+ readback responses are unchanged. CLI publisher login/resume and publishing/download
237
+ workflows remain unsupported; use the API. Credentials retain their client across
238
+ rotation and can be revoked from Settings → CLI sessions.
239
+
240
+ ## Comment windows and posting limits
241
+
242
+ `comments list <target> --json` returns at most 50 threads, open first. Each
243
+ thread contains its current first message and latest three replies, plus
244
+ `message_count`, `reply_count` and `older_cursor`. These are partial histories.
245
+ Use `comments list <target> --thread-id <id> --before <older_cursor> --limit 50
246
+ --json` for older replies. Repeat with the returned cursor until it is null;
247
+ merge by message ID and display in `(created_at, message_id)` order. Each page
248
+ also includes the current first message. Cursors remain usable after their
249
+ boundary message is deleted. `--around-message-id <id>` selects a bounded page
250
+ containing a message; do not combine it with `--before`.
251
+
252
+ A thread holds 500 currently stored messages, including its first message.
253
+ `thread_capacity` means start a new thread. Existing excess messages are kept;
254
+ deletions can restore space. Deleting the first message promotes the next
255
+ earliest message; deleting the last removes the thread and anchor. Resolved
256
+ threads still refuse replies.
257
+
258
+ Creation and replies share 20 admissions per authenticated user and artifact
259
+ per fixed UTC minute across browser, CLI, MCP and API tokens. Adjacent minute
260
+ boundaries can admit 40 posts within a sliding 60 seconds. `rate_limited`
261
+ includes `retry_after_seconds` and UTC `retry_at`; HTTP also sends `Retry-After`.
262
+ Keep unsent content and retry after that time. Invalid requests, capacity refusals
263
+ and closed-thread refusals observed before admission consume nothing. Rate
264
+ refusals do not increment the counter; quota storage failures refuse the post.
265
+ Once admitted, commit failures and status/version/capacity races consume the admission without a
266
+ refund. Edits, deletions, resolve/reopen and anchor reports consume nothing.
267
+ Mutation readback contains only the affected thread window and changed message.
268
+ `refresh_required: true` means the write committed but advisory readback failed:
269
+ read that thread by ID; do not replay the write automatically.