claude-artifact-cli 0.3.0__tar.gz → 0.3.1__tar.gz
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.
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/PKG-INFO +30 -2
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/README.md +29 -1
- claude_artifact_cli-0.3.1/src/claude_artifact_cli/__init__.py +1 -0
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/src/claude_artifact_cli/api.py +9 -7
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/src/claude_artifact_cli/cli.py +27 -0
- claude_artifact_cli-0.3.0/src/claude_artifact_cli/__init__.py +0 -1
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/.gitignore +0 -0
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/LICENSE +0 -0
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/pyproject.toml +0 -0
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/src/claude_artifact_cli/__main__.py +0 -0
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/src/claude_artifact_cli/auth.py +0 -0
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/src/claude_artifact_cli/commands.py +0 -0
- {claude_artifact_cli-0.3.0 → claude_artifact_cli-0.3.1}/src/claude_artifact_cli/update.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: claude-artifact-cli
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Publish, update, list and inspect Claude Artifacts from the terminal, using the Claude Code login already on your machine.
|
|
5
5
|
Project-URL: Homepage, https://github.com/nikships/claude-artifact-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/nikships/claude-artifact-cli
|
|
@@ -342,6 +342,31 @@ claude-artifact contract # latest runtime contract and its capabilit
|
|
|
342
342
|
claude-artifact contract --prompt # the guide for page authors: claude.use(...), each capability's config
|
|
343
343
|
```
|
|
344
344
|
|
|
345
|
+
#### Offering a file download
|
|
346
|
+
|
|
347
|
+
claude.ai blocks a plain `<a href="report.pdf" download>` inside an artifact; the viewer sees "File downloads are not available for this artifact". A page offers a file through the `downloads` capability instead, and `publish` warns when the page has an `<a download>` link and neither this publish nor the artifact's stored declaration includes `downloads`.
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
claude-artifact publish ./site --capability downloads
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
```js
|
|
354
|
+
// Ask on the viewer's click; keep the plain link as the fallback outside claude.ai.
|
|
355
|
+
const downloads = await claude.use("downloads"); // null: unavailable
|
|
356
|
+
link.addEventListener("click", async (event) => {
|
|
357
|
+
if (!downloads) return; // let the plain link try
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
const data = await (await fetch("deck.pptx")).blob(); // a file published with the page
|
|
360
|
+
try {
|
|
361
|
+
await downloads.save({ filename: "deck.pptx", data });
|
|
362
|
+
} catch (err) {
|
|
363
|
+
// the viewer cancelled, or the save failed: say so on the page
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
The viewer confirms each save ("Let this artifact download a file?" with the name and size).
|
|
369
|
+
|
|
345
370
|
### Sharing and housekeeping
|
|
346
371
|
|
|
347
372
|
```bash
|
|
@@ -425,6 +450,9 @@ curl -fsSL https://raw.githubusercontent.com/nikships/claude-artifact-cli/main/s
|
|
|
425
450
|
| `… names a document, not a collection` | A collection path needs an odd number of segments. Split off the last segment as the doc id. |
|
|
426
451
|
| `contract … has no capability …` | A misspelled `--capability`. The error lists the valid names. |
|
|
427
452
|
| `deleting … can't be undone; pass --yes` | `delete` needs `--yes`. |
|
|
453
|
+
| `HTTP 413: Request exceeds the maximum size` on `publish` | 0.3.0 and earlier sent files the server already stored inline, so republishing a directory over ~15 MB failed. Upgrade: `claude-artifact update`. |
|
|
454
|
+
| `warning: the page has <a download> links, which claude.ai blocks …` | See [Offering a file download](#offering-a-file-download). |
|
|
455
|
+
| "File downloads are not available for this artifact" on claude.ai | The page uses a plain download link. See [Offering a file download](#offering-a-file-download). |
|
|
428
456
|
|
|
429
457
|
## The protocol
|
|
430
458
|
|
|
@@ -515,7 +543,7 @@ HTTP 409
|
|
|
515
543
|
|
|
516
544
|
### Large publishes
|
|
517
545
|
|
|
518
|
-
Over ~15 MB inline, the client switches to `prepare` → `upload` → `deploy`. `prepare` takes `{slug?, shas:[…]}` and answers `{slug, missing:[…]}`. The missing blobs go to `/upload` in batches of at most 15 MB, and the final deploy references
|
|
546
|
+
Over ~15 MB inline, the client switches to `prepare` → `upload` → `deploy`. `prepare` takes `{slug?, shas:[…]}` and answers `{slug, missing:[…]}`. The missing blobs go to `/upload` in batches of at most 15 MB, and the final deploy references every supporting file by `sha256` (the hex sha256 of the raw file bytes): the ones just uploaded and the ones `prepare` did not list, which the server already stores. The page itself always goes inline. Sending stored files inline instead puts a large republish over the deploy body cap (`HTTP 413: Request exceeds the maximum size`).
|
|
519
547
|
|
|
520
548
|
### Copying files from another artifact
|
|
521
549
|
|
|
@@ -312,6 +312,31 @@ claude-artifact contract # latest runtime contract and its capabilit
|
|
|
312
312
|
claude-artifact contract --prompt # the guide for page authors: claude.use(...), each capability's config
|
|
313
313
|
```
|
|
314
314
|
|
|
315
|
+
#### Offering a file download
|
|
316
|
+
|
|
317
|
+
claude.ai blocks a plain `<a href="report.pdf" download>` inside an artifact; the viewer sees "File downloads are not available for this artifact". A page offers a file through the `downloads` capability instead, and `publish` warns when the page has an `<a download>` link and neither this publish nor the artifact's stored declaration includes `downloads`.
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
claude-artifact publish ./site --capability downloads
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
```js
|
|
324
|
+
// Ask on the viewer's click; keep the plain link as the fallback outside claude.ai.
|
|
325
|
+
const downloads = await claude.use("downloads"); // null: unavailable
|
|
326
|
+
link.addEventListener("click", async (event) => {
|
|
327
|
+
if (!downloads) return; // let the plain link try
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
const data = await (await fetch("deck.pptx")).blob(); // a file published with the page
|
|
330
|
+
try {
|
|
331
|
+
await downloads.save({ filename: "deck.pptx", data });
|
|
332
|
+
} catch (err) {
|
|
333
|
+
// the viewer cancelled, or the save failed: say so on the page
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
The viewer confirms each save ("Let this artifact download a file?" with the name and size).
|
|
339
|
+
|
|
315
340
|
### Sharing and housekeeping
|
|
316
341
|
|
|
317
342
|
```bash
|
|
@@ -395,6 +420,9 @@ curl -fsSL https://raw.githubusercontent.com/nikships/claude-artifact-cli/main/s
|
|
|
395
420
|
| `… names a document, not a collection` | A collection path needs an odd number of segments. Split off the last segment as the doc id. |
|
|
396
421
|
| `contract … has no capability …` | A misspelled `--capability`. The error lists the valid names. |
|
|
397
422
|
| `deleting … can't be undone; pass --yes` | `delete` needs `--yes`. |
|
|
423
|
+
| `HTTP 413: Request exceeds the maximum size` on `publish` | 0.3.0 and earlier sent files the server already stored inline, so republishing a directory over ~15 MB failed. Upgrade: `claude-artifact update`. |
|
|
424
|
+
| `warning: the page has <a download> links, which claude.ai blocks …` | See [Offering a file download](#offering-a-file-download). |
|
|
425
|
+
| "File downloads are not available for this artifact" on claude.ai | The page uses a plain download link. See [Offering a file download](#offering-a-file-download). |
|
|
398
426
|
|
|
399
427
|
## The protocol
|
|
400
428
|
|
|
@@ -485,7 +513,7 @@ HTTP 409
|
|
|
485
513
|
|
|
486
514
|
### Large publishes
|
|
487
515
|
|
|
488
|
-
Over ~15 MB inline, the client switches to `prepare` → `upload` → `deploy`. `prepare` takes `{slug?, shas:[…]}` and answers `{slug, missing:[…]}`. The missing blobs go to `/upload` in batches of at most 15 MB, and the final deploy references
|
|
516
|
+
Over ~15 MB inline, the client switches to `prepare` → `upload` → `deploy`. `prepare` takes `{slug?, shas:[…]}` and answers `{slug, missing:[…]}`. The missing blobs go to `/upload` in batches of at most 15 MB, and the final deploy references every supporting file by `sha256` (the hex sha256 of the raw file bytes): the ones just uploaded and the ones `prepare` did not list, which the server already stores. The page itself always goes inline. Sending stored files inline instead puts a large republish over the deploy body cap (`HTTP 413: Request exceeds the maximum size`).
|
|
489
517
|
|
|
490
518
|
### Copying files from another artifact
|
|
491
519
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.1"
|
|
@@ -708,26 +708,28 @@ class FrameClient:
|
|
|
708
708
|
if slug and reserved != slug:
|
|
709
709
|
raise ApiError("preflight answered for a different artifact - not publishing")
|
|
710
710
|
|
|
711
|
-
|
|
712
|
-
if not
|
|
713
|
-
|
|
711
|
+
answered = prep.get("missing", [])
|
|
712
|
+
if not isinstance(answered, list):
|
|
713
|
+
raise ApiError("malformed preflight answer", body=prep)
|
|
714
|
+
missing = [s for s in answered if s in by_sha]
|
|
714
715
|
|
|
715
716
|
batch: list[Asset] = []
|
|
716
717
|
size = 0
|
|
717
|
-
staged: list[Asset] = []
|
|
718
718
|
for sha in missing:
|
|
719
719
|
asset = by_sha[sha]
|
|
720
720
|
cost = asset.wire_bytes()
|
|
721
721
|
if batch and size + cost > UPLOAD_BATCH:
|
|
722
722
|
self._upload(reserved, batch, on_progress)
|
|
723
|
-
staged.extend(batch)
|
|
724
723
|
batch, size = [], 0
|
|
725
724
|
batch.append(asset)
|
|
726
725
|
size += cost
|
|
727
726
|
if batch:
|
|
728
727
|
self._upload(reserved, batch, on_progress)
|
|
729
|
-
|
|
730
|
-
|
|
728
|
+
# Every hash the preflight didn't ask for is already stored, typically
|
|
729
|
+
# the unchanged files of a republish. Reference those by hash too:
|
|
730
|
+
# sending them inline puts a large republish over the deploy body cap
|
|
731
|
+
# (HTTP 413) even though nothing new needs to travel.
|
|
732
|
+
return reserved, list(assets)
|
|
731
733
|
|
|
732
734
|
def _copy(self, copies: list[Copy], slug: str | None, on_progress) -> str:
|
|
733
735
|
"""Have the server copy files from other artifacts into this one."""
|
|
@@ -206,6 +206,32 @@ def _contract_fields(client: api.FrameClient, slug: str | None, args) -> dict:
|
|
|
206
206
|
return fields
|
|
207
207
|
|
|
208
208
|
|
|
209
|
+
_DOWNLOAD_LINK = re.compile(rb"<a\b[^>]*\sdownload\b", re.IGNORECASE)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def _warn_download_links(client: api.FrameClient, slug: str | None, page, meta: dict) -> None:
|
|
213
|
+
"""Warn when a page offers files through <a download> without the downloads capability.
|
|
214
|
+
|
|
215
|
+
claude.ai blocks a plain download link inside an artifact ("File downloads are
|
|
216
|
+
not available for this artifact"); a page saves files through the downloads
|
|
217
|
+
capability instead.
|
|
218
|
+
"""
|
|
219
|
+
if page is None or not _DOWNLOAD_LINK.search(page.data):
|
|
220
|
+
return
|
|
221
|
+
caps = meta.get("capabilities")
|
|
222
|
+
if caps is None and slug:
|
|
223
|
+
with contextlib.suppress(api.ApiError):
|
|
224
|
+
caps = client.access(slug).get("capabilities")
|
|
225
|
+
if isinstance(caps, dict) and "downloads" in caps:
|
|
226
|
+
return
|
|
227
|
+
_eprint(
|
|
228
|
+
"warning: the page has <a download> links, which claude.ai blocks inside an "
|
|
229
|
+
"artifact (\"File downloads are not available for this artifact\"). Publish with "
|
|
230
|
+
"--capability downloads and save the file from the click handler with "
|
|
231
|
+
"(await claude.use(\"downloads\")).save({filename, data})."
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
|
|
209
235
|
def _copies(client: api.FrameClient, specs: list[list[str]]) -> list[api.Copy]:
|
|
210
236
|
"""--copy SOURCE PUB[=SRC]: files the server copies from another artifact."""
|
|
211
237
|
copies = []
|
|
@@ -329,6 +355,7 @@ def cmd_publish(args) -> int:
|
|
|
329
355
|
|
|
330
356
|
client = _client(args)
|
|
331
357
|
meta.update(_contract_fields(client, slug, args))
|
|
358
|
+
_warn_download_links(client, slug, page, meta)
|
|
332
359
|
copies = _copies(client, args.copy or [])
|
|
333
360
|
result = client.publish(
|
|
334
361
|
page=page,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|