@yargote/artifacts-cli 0.0.0-stage → 0.1.0-beta.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yerson Argote
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,217 @@
1
- # Temporary Holding Version
1
+ # Artifacts CLI reference
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The `artifacts` Node CLI reads and writes retained artifacts through REST. It prints JSON results to stdout and diagnostics to stderr. Offline skills commands print plain text. Node 24 or later is required. Its private credential database uses Node's experimental built-in SQLite API.
4
+
5
+ The `@yargote/artifacts-cli` package exposes the `artifacts` binary as compiled ESM JavaScript. Its client and contracts dependencies install automatically. Repository development uses `pnpm artifacts` with the same command syntax.
6
+
7
+ ## Install the beta
8
+
9
+ Use Node 24 or later. The beta targets macOS and Linux. Windows has not been verified.
10
+
11
+ Choose one persistent installation:
12
+
13
+ ```sh
14
+ npm install --global @yargote/artifacts-cli@0.1.0-beta.2
15
+ # Or, with pnpm and an existing global bin directory on PATH:
16
+ pnpm add --global @yargote/artifacts-cli@0.1.0-beta.2
17
+ artifacts --version
18
+ ```
19
+
20
+ If pnpm reports that no global bin directory exists, run `pnpm setup` and reopen your shell before installation.
21
+
22
+ For one-off execution, pin the same version:
23
+
24
+ ```sh
25
+ npx --yes @yargote/artifacts-cli@0.1.0-beta.2 --help
26
+ pnpm dlx @yargote/artifacts-cli@0.1.0-beta.2 --help
27
+ ```
28
+
29
+ `@beta` follows future prereleases. Exact versions remain reproducible. No stable `latest` release is part of this beta. An organization's pnpm minimum release age or trust policy can delay a new release. Follow that policy rather than disabling it globally.
30
+
31
+ ## Complete first use
32
+
33
+ An existing Artifacts account is required. Select the complete OAuth resource, including `/mcp`:
34
+
35
+ ```sh
36
+ export ARTIFACTS_SERVER='https://artifacts-mcp.yersonargotev.workers.dev/mcp'
37
+ artifacts login
38
+ artifacts whoami
39
+ ```
40
+
41
+ Login opens browser authorization. After you approve access, `whoami` prints JSON with your user ID and scopes. Use `artifacts login --no-browser` to open the printed authorization URL yourself on the same machine.
42
+
43
+ Create `snapshot.json`:
44
+
45
+ ```json
46
+ {
47
+ "metadata": { "title": "My first CLI artifact", "description": "Created through REST" },
48
+ "content": { "kind": "text", "text": "Hello from the Artifacts CLI." },
49
+ "files": []
50
+ }
51
+ ```
52
+
53
+ ```sh
54
+ artifacts create --snapshot snapshot.json
55
+ artifacts list --limit 5
56
+ ```
57
+
58
+ The create result contains `artifactId` and `headRevisionId`. Use those values to read, publish, and export the exact revision:
59
+
60
+ ```sh
61
+ artifacts read ARTIFACT_ID
62
+ artifacts publish ARTIFACT_ID --revision REVISION_ID --expected-version 0
63
+ artifacts export ARTIFACT_ID --revision REVISION_ID --out artifact.zip
64
+ artifacts logout
65
+ ```
66
+
67
+ Publication URLs require authenticated owner access. A retained request ID appears on stderr before each mutation. If the response is lost, run `artifacts retry REQUEST_ID` with the same server and state directory. Keep that state directory when upgrading, reinstalling, or switching between global and one-off execution.
68
+
69
+ ## Upgrade or uninstall
70
+
71
+ Install another exact version with the same package manager to change the executable version. Credentials and retained operation files live outside the package installation and remain available.
72
+
73
+ ```sh
74
+ npm uninstall --global @yargote/artifacts-cli
75
+ # Or:
76
+ pnpm remove --global @yargote/artifacts-cli
77
+ ```
78
+
79
+ Run `artifacts logout` before uninstalling if you want to clear credentials. Uninstalling does not delete retained operations.
80
+
81
+ ## Server and local state
82
+
83
+ Skills, help, and version commands work without a server or login. Skills commands do not read credentials or create private state. They accept and ignore global `--server` and `--state-dir` values, including their environment defaults.
84
+
85
+ `--server RESOURCE` selects the exact canonical OAuth resource. `ARTIFACTS_SERVER` supplies the same value. A resource ending in `/mcp` uses REST under `/mcp/v1`. The CLI has no production default.
86
+
87
+ `--state-dir DIR` overrides `ARTIFACTS_STATE_DIR`. The default is `~/.local/state/artifacts`. The state directory must be private and owned by the current user. Credentials are separate from operation files. Profiles bind credentials to the exact resource. Retained operation paths hash the resource and request ID, so request IDs cannot select filesystem paths.
88
+
89
+ HTTPS is required except for HTTP on the exact loopback hosts `localhost`, `127.0.0.1`, and `[::1]`. Server URLs cannot contain credentials, a query, or a fragment.
90
+
91
+ ## Authentication
92
+
93
+ `artifacts login --server RESOURCE` verifies protected-resource metadata, registers a public native OAuth client, and opens browser authorization with PKCE. `--no-browser` prints the authorization URL for manual navigation. The loopback callback listener starts before browser navigation. Login requests read, write, and publication scopes. Client registration is reused for the profile.
94
+
95
+ `artifacts whoami` returns the verified user, session, OAuth client, and scopes.
96
+
97
+ `artifacts logout` clears local credentials and attempts to revoke the refresh token. Its JSON contains `signedOut: true` and `remoteRevocation` with `confirmed`, `unconfirmed`, or `not-needed`. Issued access JWTs can remain valid until expiry or central-session revocation.
98
+
99
+ `ARTIFACTS_ACCESS_TOKEN` supplies an access token for automation. It does not require local login. Tokens are never command arguments or retained operation fields.
100
+
101
+ The private `credentials.sqlite` file stores credentials. The separate `credentials-lock.sqlite` file contains no credentials and holds a SQLite write lock to serialize refresh and logout across processes. A committed uncertainty marker in the data file survives process death, while SQLite releases the lock. Login and logout generations prevent a late browser callback from restoring signed-out credentials. An uncertain refresh requires login.
102
+
103
+ ## Command syntax
104
+
105
+ `artifacts --help` prints this command reference. `artifacts --version` prints the installed package version without requiring a server or login.
106
+
107
+ ```text
108
+ artifacts login [--no-browser]
109
+ artifacts logout
110
+ artifacts whoami
111
+ artifacts create --snapshot FILE [--request-id ID] [--response full|compact]
112
+ artifacts create --command FILE
113
+ artifacts list [--limit N] [--cursor CURSOR]
114
+ artifacts read ID [--revision REV] [--response full|compact] [--out FILE [--quiet]]
115
+ artifacts update ID --snapshot FILE --expected-revision REV [--request-id ID]
116
+ [--response full|compact]
117
+ artifacts update [ID] --command FILE
118
+ artifacts edit ID --changes FILE [--request-id ID]
119
+ artifacts history ID [--limit N] [--before-sequence N] [--summary]
120
+ artifacts publish ID --revision REV --expected-version N [--request-id ID]
121
+ artifacts publish [ID] --command FILE
122
+ artifacts export ID --revision REV --out FILE
123
+ artifacts retry REQUEST_ID
124
+ artifacts skills [list]
125
+ artifacts skills get NAME [--full]
126
+ artifacts skills get --all [--full]
127
+ artifacts skills path [NAME]
128
+ artifacts skills install [NAME] [--agent claude] [--global] [--force]
129
+ ```
130
+
131
+ Global `--server RESOURCE` and `--state-dir DIR` options can appear before or after the command. Options cannot be repeated. Unknown options and options for another command fail before submission.
132
+
133
+ ## Bundled skills
134
+
135
+ Check `artifacts --help` for `skills` support. The published `0.1.0-beta.1` package predates this command group. These commands describe the current source and packages built from it.
136
+
137
+ `artifacts skills` and `artifacts skills list` print each bundled skill's name and description, separated by a tab. The initial catalog contains `artifacts-cli`. Its complete source directory is bundled with the CLI, so the instructions match the installed version and work offline.
138
+
139
+ `artifacts skills get artifacts-cli` prints the complete `SKILL.md` without headers or changes to its bytes. `--full` includes every bundled reference and template. Each file starts with a catalog-relative marker such as `=== artifacts-cli/references/commands.md ===`. `artifacts skills get --all` prints every `SKILL.md` with these markers. Add `--full` to include every skill's support files.
140
+
141
+ `artifacts skills path` prints the absolute bundled catalog directory. Add a skill name to print that skill's directory. These paths belong to the CLI package and do not depend on the current directory.
142
+
143
+ Install a discovery skill for an agent with one of these commands.
144
+
145
+ | Command | Destination |
146
+ | --- | --- |
147
+ | `artifacts skills install` | `./.agents/skills/artifacts-cli/SKILL.md` |
148
+ | `artifacts skills install --agent claude` | `./.claude/skills/artifacts-cli/SKILL.md` |
149
+ | `artifacts skills install --global` | `~/.agents/skills/artifacts-cli/SKILL.md` |
150
+ | `artifacts skills install --agent claude --global` | `~/.claude/skills/artifacts-cli/SKILL.md` |
151
+
152
+ The optional name defaults to `artifacts-cli`. The default destination always uses `.agents`, even if `.claude` already exists. Only explicit `--agent claude` selects `.claude`. Local paths resolve from the current directory. Global paths resolve from the user's home directory.
153
+
154
+ The command prints the absolute destination. It leaves identical files unchanged, including their modification time. A differing file requires `--force`. Forced installation replaces only `SKILL.md` and preserves neighboring files. A directory or symbolic link at `SKILL.md` is rejected.
155
+
156
+ The discovery file instructs the agent to run `artifacts skills get artifacts-cli --full` and follow the returned instructions. It contains no copied workflow or fixed package path. After a CLI upgrade, the same discovery command loads that installed version's skill.
157
+
158
+ ## Artifact input and output
159
+
160
+ Create and update snapshot files contain the complete domain snapshot.
161
+
162
+ ```json
163
+ {
164
+ "metadata": { "title": "Example", "description": "A retained document", "custom": { "team": "design" } },
165
+ "content": { "kind": "html", "text": "<h1>Example</h1>" },
166
+ "files": [{ "path": "data.txt", "mediaType": "text/plain", "encoding": "utf8", "data": "retained attachment" }]
167
+ }
168
+ ```
169
+
170
+ `read --out FILE` saves the returned artifact JSON and also prints it to stdout. Add `--quiet` to suppress successful stdout while saving the same bytes for the selected response mode. `--quiet` is available only for `read` and requires a nonempty `--out FILE`. Errors still go to stderr and exit with code `1`.
171
+
172
+ Check installed help for `--quiet` support. Version `0.1.0-beta.1` predates this option. With that version, `artifacts read ARTIFACT_ID --out saved.json > /dev/null` suppresses stdout while preserving stderr and the exit status.
173
+
174
+ A default full read contains the complete snapshot under `revision.snapshot`. `export --out FILE` saves the exact ZIP and prints its filename, local path, media type, SHA-256, and byte count. Output files use exclusive creation and never overwrite an existing path.
175
+
176
+ History defaults to complete revisions. `--summary` returns revision metadata and attachment summaries. `--before-sequence` continues a page. `list --cursor` continues an artifact list.
177
+
178
+ ## Complete commands and edits
179
+
180
+ `--command FILE` accepts a complete create, update, or publish command. It cannot be combined with other mutation options. For update and publish, an optional positional artifact ID must equal the command's `artifactId`. Every field, including the omission of `response`, is retained.
181
+
182
+ A complete update command has this shape.
183
+
184
+ ```json
185
+ {
186
+ "requestId": "reviewed-update-001",
187
+ "artifactId": "artifact-id",
188
+ "expectedRevisionId": "reviewed-revision-id",
189
+ "snapshot": {
190
+ "metadata": { "title": "Reviewed title", "description": "Complete replacement" },
191
+ "content": { "kind": "text", "text": "Reviewed text" },
192
+ "files": []
193
+ }
194
+ }
195
+ ```
196
+
197
+ `edit ID --changes FILE` reads the current snapshot, merges partial `metadata` and `content` changes, and retains the resulting complete update. An explicit `files` array replaces the attachments. Omitted fields and attachments are preserved.
198
+
199
+ ```json
200
+ { "metadata": { "title": "Changed title" }, "content": { "text": "Changed text" } }
201
+ ```
202
+
203
+ Publish always selects an immutable revision. `--expected-version 0` expects no existing publication. Later publication commands require the current publication version.
204
+
205
+ ## Recovery
206
+
207
+ Each invocation resolves one access token for its reads, owner check, and submission. A concurrent login cannot change the command owner between these requests. Every mutation verifies the owner and retains an exclusive private operation file before submission. Missing request IDs default to random UUIDs. The operation stores its exact command, owner, and resource. It contains no credentials. Existing operation files require explicit `retry` and are never replaced by another preparation.
208
+
209
+ `retry REQUEST_ID` verifies the current resource and owner, then sends the unchanged command once. Retry does not read a new head, change expected versions, add a response projection, or rebase a conflict. Its diagnostic identifies the result as a retained receipt. A fresh `read` returns current state.
210
+
211
+ If a response is lost after commit, retry recovers the original receipt. If a conflict occurs, the retained operation remains available for inspection. A new read and a deliberate new command with a new request ID are required to incorporate another writer's changes.
212
+
213
+ Commands exit with code `1` on failure and print a JSON error to stderr. Server errors preserve their HTTP status, code, and conflict details. Successful JSON stdout contains no progress messages or credentials.
214
+
215
+ ## License and support
216
+
217
+ This package is MIT licensed. The client and contracts packages have their own MIT licenses. This does not license the private Artifacts application repository. Contact your Artifacts service administrator with `artifacts --version`, Node and package-manager versions, and a redacted error. Never include credentials or the contents of `credentials.sqlite`.
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@yargote/artifacts-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.2",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Command-line client for the Artifacts REST API.",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/yersonargotev/artifacts.git",
11
+ "directory": "apps/cli"
12
+ },
13
+ "homepage": "https://github.com/yersonargotev",
14
+ "bugs": {
15
+ "url": "https://github.com/yersonargotev"
16
+ },
17
+ "engines": {
18
+ "node": ">=24"
19
+ },
20
+ "bin": {
21
+ "artifacts": "./src/index.js"
22
+ },
23
+ "files": [
24
+ "src",
25
+ "README.md",
26
+ "LICENSE",
27
+ "skills"
28
+ ],
29
+ "dependencies": {
30
+ "@yargote/artifacts-contracts": "0.1.0-beta.2",
31
+ "@yargote/artifacts-client": "0.1.0-beta.2",
32
+ "openid-client": "6.8.8",
33
+ "zod": "4.6.5"
34
+ },
35
+ "artifactsSkills": [
36
+ "artifacts-cli"
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "tag": "beta",
41
+ "provenance": false
42
+ }
43
+ }
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: artifacts-cli
3
+ description: Create, revise, inspect, publish, and export retained Artifacts through the artifacts CLI and REST API. Use when the user chooses the CLI or a terminal workflow for Artifacts. Exclude generic build artifacts and unrelated local files.
4
+ ---
5
+
6
+ # Manage retained Artifacts with the CLI
7
+
8
+ Use the installed `artifacts` executable. Run `artifacts --help` and read [the command workflow](references/commands.md) before the first operation. With bundled skills support, `artifacts skills get artifacts-cli --full` returns this skill and its complete command reference. If the executable is unavailable, report that prerequisite. Do not substitute database writes or invent CLI results.
9
+
10
+ ## Select the account and resource
11
+
12
+ Use the resource selected by the user or the existing `ARTIFACTS_SERVER` environment value. Pass `--server RESOURCE` or set `ARTIFACTS_SERVER` for service commands. Skills, help, and version commands work offline without a server or login. Login does not set an implicit default. A resource is the canonical OAuth URL, such as `https://artifacts.example.test/mcp`. REST routes are below that resource at `/v1`. Do not infer a production connection from an example or silently switch to a local server.
13
+
14
+ Run `artifacts whoami` before the first mutation when the current identity is not established. Keep the selected resource and owner consistent throughout one operation. If login is needed, use `artifacts login --server RESOURCE`. The user authenticates in the browser. Do not collect their password or read another application's credentials. Never put tokens in command arguments, operation files, logs, or the final reply.
15
+
16
+ ## Prepare retained content
17
+
18
+ A revision is a complete snapshot with `metadata`, `content`, and `files`. The command reference contains its JSON shape. Use the requested title, language, content, and attachments. Do not include unrelated files or credentials.
19
+
20
+ Use self-contained HTML for interactive content. Inline styles and scripts and embed required assets as data URLs. External requests, CDN dependencies, relative executable assets, forms, browser storage, and multi-file websites are unsupported. Attachments are downloads, not importable website resources. Markdown and text display inertly.
21
+
22
+ Keep the whole revision within 1 MiB of decoded content, metadata, attachment paths, media types, and attachment bytes. At most 32 attachments are accepted. Base64 changes wire size, not the decoded limit. If required content exceeds a limit, explain the constraint without silently removing it.
23
+
24
+ Finish requested visual and interaction checks before saving when browser tools are available. A successful CLI write proves persistence, not visual quality or browser compatibility. Interactive HTML follows the server's Chrome policy; do not promise it in every browser.
25
+
26
+ ## Create or revise
27
+
28
+ Create a draft when the user asks to save new content. Use a complete snapshot file and retain the CLI's request ID and operation record until the result is verified.
29
+
30
+ Resolve an existing artifact by its supplied ID, an observed publication URL, or a paginated list. If several results match, ask which one the user means. Read its current full snapshot before editing. Preserve metadata, custom JSON, content fields, and attachments the user did not ask to change.
31
+
32
+ Use `edit` for partial changes that preserve omitted fields. Use `update` for a complete next snapshot with the observed `headRevisionId` as its expected revision. Changing the attachment list replaces that inventory; an empty list removes all attachments. An update creates a retained revision and does not change the published revision.
33
+
34
+ ## Publish deliberately
35
+
36
+ Publish when the user requests publication, a shareable artifact URL, or a change to the live artifact. Use the exact saved revision selected by the user or returned by the edit. Read the current publication version before preparing publication. Use zero only when the artifact is unpublished.
37
+
38
+ A published URL still requires its owner's Artifacts login. Publishing a historical revision leaves the draft head unchanged. Report the returned protected URL only after the publication succeeds and its current state is verified.
39
+
40
+ ## Recover an uncertain write
41
+
42
+ The CLI retains complete mutations before sending them. After a connection failure or uncertain result, use `retry` with that retained request ID once. Keep the same resource, owner, request ID, response mode, snapshot, and expected versions. Do not rerun a convenience edit or generate a new ID to repeat an operation whose outcome is unknown.
43
+
44
+ If the retry remains unavailable, report the uncertainty and retain the recovery record. A conflict stops the failed operation. Read the current state and report the concurrent change. Do not replace expected versions to force a write. A changed operation needs a deliberate new command and request ID.
45
+
46
+ A `request_conflict` means the ID was used with different arguments. Do not describe it as success. Authentication, validation, missing-artifact, and service failures likewise remain failures.
47
+
48
+ ## Verify and deliver
49
+
50
+ After create or update, read the explicit returned revision. Use `read ARTIFACT_ID --revision REVISION_ID --out FILE --quiet` to retain the full response without printing its snapshot. Check that the installed `--help` supports `--quiet` first. For older versions, use the command workflow's stdout redirection fallback. Compare the saved complete metadata, content, and decoded attachment bytes with the intended snapshot. For an update, check that its parent is the head used for preparation. Compact responses cannot verify omitted content.
51
+
52
+ After publication, read current publication and compare revision, version, and URL with the committed result. A replayed receipt describes the original commit; another writer may have changed the current publication afterward. Report that difference.
53
+
54
+ Follow list and history cursors when the request needs more than the first page. Export an explicit retained revision to the requested destination. The CLI checks the archive digest. Confirm that the file exists and inspect its manifest and relevant content before linking it.
55
+
56
+ Report the title, saved revision, and draft or published state in the user's language. Link the actual export or returned protected publication URL. Distinguish persistence from any visual or browser checks that did not run. Keep local credential and session identifiers private.
@@ -0,0 +1,156 @@
1
+ # Command workflow
2
+
3
+ Check the installed `artifacts --help` before use. These examples use the canonical resource selected for the task. `ARTIFACT_ID` and `REVISION_ID` stand for IDs observed in actual command output.
4
+
5
+ ## Inspect and install bundled skills
6
+
7
+ When installed help lists `skills`, use these commands without a server or login.
8
+
9
+ ```sh
10
+ artifacts skills
11
+ artifacts skills get artifacts-cli --full
12
+ artifacts skills get --all --full
13
+ artifacts skills path artifacts-cli
14
+ artifacts skills install
15
+ artifacts skills install --agent claude --global
16
+ ```
17
+
18
+ `skills` and `skills list` list names and descriptions. Plain `skills get artifacts-cli` returns the complete `SKILL.md`. `--full` includes references and templates with relative file paths. `skills path` without a name returns the catalog directory.
19
+
20
+ Installation defaults to `artifacts-cli` in `.agents/skills` under the current directory. `--agent claude` selects `.claude/skills`. `--global` selects the user's home directory. Existing agent directories do not affect the default. The discovery file instructs the agent to load the installed CLI's complete instructions with `artifacts skills get artifacts-cli --full`. Installation reports the absolute path, leaves identical files unchanged, and requires `--force` to replace differing files.
21
+
22
+ The published `0.1.0-beta.1` package predates skills commands. Do not assume support without checking help.
23
+
24
+ ## Authenticate
25
+
26
+ ```sh
27
+ export ARTIFACTS_SERVER=https://artifacts.example.test/mcp
28
+ artifacts login
29
+ artifacts whoami
30
+ ```
31
+
32
+ Replace the example with the selected resource before executing it. Service commands read `ARTIFACTS_SERVER` or an explicit `--server RESOURCE`. Login does not save a default resource. `--state-dir DIR` or `ARTIFACTS_STATE_DIR` selects an isolated private state directory. For automation, `ARTIFACTS_ACCESS_TOKEN` supplies an already authorized bearer token. Do not echo it or put it in an argument.
33
+
34
+ Use `--no-browser` when the environment cannot open a browser automatically. Open the printed authorization URL and keep the CLI running for its loopback callback. A remote machine's loopback callback must be reachable by the browser used for login. Do not replace the callback with an arbitrary public listener.
35
+
36
+ `logout` clears local credentials and attempts refresh-token revocation. Copied access JWTs can remain valid until expiry. The existing account page's global session revocation stops access across CLI, REST, MCP, and panel. Local logout does not claim to perform that global action.
37
+
38
+ ## Create a complete snapshot
39
+
40
+ Save this JSON as `snapshot.json`, replacing its content with the requested artifact.
41
+
42
+ ```json
43
+ {
44
+ "metadata": {
45
+ "title": "Project note",
46
+ "description": "A retained note",
47
+ "custom": { "source": "requested content" }
48
+ },
49
+ "content": {
50
+ "kind": "html",
51
+ "text": "<!doctype html><html lang=\"en\"><meta charset=\"utf-8\"><title>Project note</title><main><h1>Project note</h1><p>Retained content.</p></main></html>"
52
+ },
53
+ "files": [
54
+ {
55
+ "path": "notes.txt",
56
+ "mediaType": "text/plain",
57
+ "encoding": "utf8",
58
+ "data": "Retained attachment.\n"
59
+ }
60
+ ]
61
+ }
62
+ ```
63
+
64
+ `metadata.description` and `files` are required even when empty. Content kind is `html`, `markdown`, or `text`. Binary files use `encoding: "base64"` and canonical padded base64. Paths are unique normalized relative paths. Do not use empty, dot, parent, absolute, backslash, percent, or colon path segments. A file cannot also be another file's directory.
65
+
66
+ ```sh
67
+ artifacts create --snapshot snapshot.json
68
+ artifacts list --limit 25
69
+ artifacts read ARTIFACT_ID --out saved.json --quiet
70
+ ```
71
+
72
+ Keep the request ID printed for the mutation. Successful JSON goes to stdout; diagnostics and recovery instructions go to stderr. Exit zero indicates command success. A nonzero exit must be inspected before claiming completion.
73
+
74
+ For `read`, `--out FILE --quiet` saves the returned response without printing successful JSON. It requires a nonempty output path. It preserves the selected response mode, so use the default full response for snapshot verification. Errors still go to stderr and exit nonzero. Without `--quiet`, `read --out FILE` also prints the response to stdout.
75
+
76
+ Check installed help for `--quiet` support before running these examples. Older versions, including `0.1.0-beta.1`, can suppress stdout with `artifacts read ARTIFACT_ID --out saved.json > /dev/null`. This redirection preserves stderr and the command's exit status. Use the same fallback for the revision reads below.
77
+
78
+ ## Edit without losing retained data
79
+
80
+ For a title change, save `changes.json` with only the requested field.
81
+
82
+ ```json
83
+ { "metadata": { "title": "Reviewed project note" } }
84
+ ```
85
+
86
+ ```sh
87
+ artifacts edit ARTIFACT_ID --changes changes.json
88
+ artifacts read ARTIFACT_ID --out current.json --quiet
89
+ ```
90
+
91
+ For a complete replacement, read the current head, preserve untouched data in `next-snapshot.json`, and use that observed revision.
92
+
93
+ ```sh
94
+ artifacts update ARTIFACT_ID --snapshot next-snapshot.json --expected-revision REVISION_ID
95
+ ```
96
+
97
+ A complete command file can preserve a caller-owned request ID, snapshot, and expected revision. Use `artifacts create --command create.json`, `artifacts update --command update.json`, or `artifacts publish --command publish.json`. Do not add `response: "full"` to an existing command that omitted it. Optional response modes affect exact mutation identity.
98
+
99
+ Command files contain the command itself, without the CLI's retained-operation wrapper.
100
+
101
+ | Command | Required JSON fields |
102
+ | --- | --- |
103
+ | `create` | `requestId`, `snapshot` |
104
+ | `update` | `requestId`, `artifactId`, `expectedRevisionId`, `snapshot` |
105
+ | `publish` | `requestId`, `artifactId`, `revisionId`, `expectedPublicationVersion` |
106
+
107
+ `requestId` is a caller-chosen string of 8 to 128 characters. Create and update also accept optional `response` with value `full` or `compact`. This complete update example replaces a snapshot. Substitute the observed IDs and preserve all required content and attachments in its `snapshot`.
108
+
109
+ ```json
110
+ {
111
+ "requestId": "reviewed-update-001",
112
+ "artifactId": "OBSERVED_ARTIFACT_ID",
113
+ "expectedRevisionId": "OBSERVED_HEAD_REVISION_ID",
114
+ "snapshot": {
115
+ "metadata": { "title": "Reviewed project note", "description": "A retained note" },
116
+ "content": { "kind": "text", "text": "Reviewed content." },
117
+ "files": []
118
+ }
119
+ }
120
+ ```
121
+
122
+ Create uses the same `requestId` and complete `snapshot` fields without artifact or expected-revision IDs. A complete publication command has this shape. Replace zero with the observed publication version when already published.
123
+
124
+ ```json
125
+ {
126
+ "requestId": "reviewed-publish-001",
127
+ "artifactId": "OBSERVED_ARTIFACT_ID",
128
+ "revisionId": "SELECTED_REVISION_ID",
129
+ "expectedPublicationVersion": 0
130
+ }
131
+ ```
132
+
133
+ ## Inspect history and publish
134
+
135
+ ```sh
136
+ artifacts history ARTIFACT_ID --summary
137
+ artifacts read ARTIFACT_ID --revision REVISION_ID --out historical.json --quiet
138
+ artifacts publish ARTIFACT_ID --revision REVISION_ID --expected-version 0
139
+ ```
140
+
141
+ The publication example applies only to an unpublished artifact. For an existing publication, replace zero with the `publication.version` observed in a current read. After publishing, read again and compare current publication with the returned receipt.
142
+
143
+ History returns `nextBeforeSequence`; pass it as `--before-sequence N` to continue. List returns `nextCursor`; pass it as `--cursor CURSOR`. Do not substitute an offset or assume that one page contains everything.
144
+
145
+ ## Retry and export
146
+
147
+ ```sh
148
+ artifacts retry REQUEST_ID
149
+ artifacts export ARTIFACT_ID --revision REVISION_ID --out artifact.zip
150
+ ```
151
+
152
+ `retry` loads the saved complete operation. It does not prepare a new edit or change expected versions. Keep the record after an uncertain result. The server checks current authority before replaying an original receipt.
153
+
154
+ `read --out` and `export --out` create files exclusively. Use a new destination if one already exists. Do not delete an existing output merely to rerun an example.
155
+
156
+ The archive contains `artifact.json`, `content.html`, `content.md`, or `content.txt`, and attachments under `files/`. Inspect the manifest's artifact and revision IDs, content, and required attachment bytes. Exporting the same retained revision through REST, MCP, or the panel must yield identical ZIP bytes.
package/src/auth.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { type Identity } from '@yargote/artifacts-contracts/http';
2
+ export declare function login(options: {
3
+ resource: string;
4
+ stateDir: string;
5
+ noBrowser: boolean;
6
+ onAuthorizationUrl: (url: string) => void;
7
+ }): Promise<Identity>;
8
+ export declare function accessToken(options: {
9
+ resource: string;
10
+ stateDir: string;
11
+ }): Promise<string>;
12
+ export declare function logout(options: {
13
+ resource: string;
14
+ stateDir: string;
15
+ }): Promise<{
16
+ signedOut: true;
17
+ remoteRevocation: 'confirmed' | 'unconfirmed' | 'not-needed';
18
+ }>;