artshelf 0.3.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.
@@ -0,0 +1,392 @@
1
+ # Agent Usage
2
+
3
+ Agents that support local skills can copy or reference
4
+ [`skills/artshelf/SKILL.md`](../skills/artshelf/SKILL.md). The public docs site at
5
+ <https://calvinnwq.github.io/artshelf/> explains the same contract in browsable
6
+ form.
7
+
8
+ Artshelf works best when agents register artifacts at creation time, while the
9
+ reason is still fresh. Do not wait for a cleanup pass to infer intent from file
10
+ age or path names.
11
+
12
+ ## When To Register
13
+
14
+ Treat Artshelf as a finalization trigger, not an optional cleanup habit. Before an
15
+ agent reports a task as done, it must check whether the task created, copied,
16
+ exported, quarantined, backed up, or preserved any non-source file or directory
17
+ that may outlive the current command.
18
+
19
+ Call `artshelf put` immediately after creating an eligible artifact:
20
+
21
+ - config backups
22
+ - rollback copies
23
+ - quarantine folders
24
+ - debug output directories
25
+ - generated reports
26
+ - temporary repo artifacts
27
+ - long-running task evidence
28
+ - copied files kept so a reviewer can inspect them later
29
+
30
+ Do not register normal source files, committed documentation, package build
31
+ outputs that can be regenerated cheaply, or dependency caches.
32
+
33
+ If an eligible artifact is not registered, the agent should state why. Common
34
+ valid reasons are: the artifact is source-controlled, it is a cheap
35
+ regeneratable cache/build output, it contains secrets, it belongs to another
36
+ durable artifact system, or the user explicitly asked not to retain it.
37
+
38
+ ## Command Shape
39
+
40
+ Use the installed CLI when available:
41
+
42
+ ```bash
43
+ artshelf put <path> --reason "<why this exists>" --ttl 3d --kind run-artifact --cleanup review --owner agent
44
+ ```
45
+
46
+ If Artshelf is not installed, use the package-manager install path when
47
+ available:
48
+
49
+ ```bash
50
+ npm install -g artshelf
51
+ artshelf --version
52
+ artshelf doctor
53
+ ```
54
+
55
+ With pnpm:
56
+
57
+ ```bash
58
+ pnpm add -g artshelf
59
+ artshelf --version
60
+ artshelf doctor
61
+ ```
62
+
63
+ For source installs, do not assume a repo path. Ask where the user wants the
64
+ Artshelf repo cloned, then use the supported local path:
65
+
66
+ ```bash
67
+ git clone https://github.com/calvinnwq/artshelf.git "$ARTSHELF_REPO"
68
+ cd "$ARTSHELF_REPO"
69
+ corepack enable
70
+ pnpm install --frozen-lockfile
71
+ pnpm run build
72
+ npm link
73
+ artshelf --version
74
+ artshelf doctor
75
+ ```
76
+
77
+ Do not create a custom shim. Use the published package or `npm link` from a
78
+ local source checkout.
79
+
80
+ Useful defaults for agents:
81
+
82
+ - `--kind scratch` for temporary working directories.
83
+ - `--kind backup` for rollback copies.
84
+ - `--kind run-artifact` for logs, reports, and generated evidence.
85
+ - `--kind quarantine` for files isolated because they may be unsafe or wrong.
86
+ - `--cleanup review` when a human or future agent should inspect before moving.
87
+ - `--cleanup trash` only when the artifact is definitely disposable after the
88
+ retention window.
89
+ - `--owner <agent-or-runtime>` should name the agent, tool, CI job, or human
90
+ process that created the artifact.
91
+ - `--label <project>` and `--label <task-id>` when the artifact relates to a
92
+ repo, PR, issue, workflow id, or run id.
93
+
94
+ Use `--json` when another tool needs to capture the Artshelf entry id.
95
+
96
+ ## Idempotent Lookup
97
+
98
+ Integrations should check the ledger before creating another record for the
99
+ same artifact. Use `find` and `get` for read-only lookup:
100
+
101
+ ```bash
102
+ artshelf find --path <path> --owner <agent-or-runtime> --label <task-or-run-id> --json
103
+ artshelf get <id> --json
104
+ ```
105
+
106
+ `find` requires at least one selector: `--path`, `--owner`, `--label`, or
107
+ `--status`. Multiple labels are an all-label match. If `find` returns an
108
+ existing record, report that Artshelf id instead of calling `put` again. If it
109
+ returns no entries, call `put` and record the new id.
110
+
111
+ ## Ledger Registry
112
+
113
+ Artshelf keeps a user-level registry at `~/.shelf/ledgers.json` so one CLI can
114
+ review all known ledgers without moving project records into one global file.
115
+ `put` registers the ledger it writes to. Register existing ledgers explicitly
116
+ when adopting Artshelf for an existing project:
117
+
118
+ ```bash
119
+ artshelf ledgers add --ledger <repo>/.shelf/ledger.jsonl --name <project> --scope repo
120
+ artshelf ledgers list --json
121
+ ```
122
+
123
+ `artshelf ledgers list --json` validates each registered ledger and reports
124
+ ok/missing/invalid status with entry and warning/error counts, so agents can
125
+ detect stale registry entries without a separate validate pass. Add `--plain`
126
+ for a fast listing that skips validation.
127
+
128
+ Use the registry for read-only review and discovery:
129
+
130
+ ```bash
131
+ artshelf review --all --json
132
+ artshelf status --all --json
133
+ artshelf due --all --json
134
+ artshelf find --all --owner <agent-or-runtime> --json
135
+ artshelf trash list --all --json
136
+ ```
137
+
138
+ `artshelf review --all --json` returns an aggregate triage summary (affected
139
+ ledgers, due, manual-review, missing-path, executable, and skipped counts plus
140
+ preview plan ids) alongside the per-ledger detail, and states the next safe
141
+ action.
142
+
143
+ Use global cleanup dry-run when you want Artshelf to write cleanup plans for
144
+ registered ledgers with cleanup entries, without moving files:
145
+
146
+ ```bash
147
+ artshelf cleanup --dry-run --all --json
148
+ ```
149
+
150
+ Do not use `--all` as permission to mutate files. Cleanup execution remains
151
+ ledger-specific and requires a reviewed plan id for that ledger.
152
+ If the executable cleanup entries have not changed, dry-run reuses the existing
153
+ plan id and refreshes the same plan file instead of creating duplicate plans.
154
+
155
+ ## Daily Review Workflow
156
+
157
+ Use this flow when a scheduled review, recurring task, or user request reports
158
+ Artshelf cleanup attention:
159
+
160
+ 1. Register artifacts early during work, or state why an eligible artifact was
161
+ skipped.
162
+ 2. Review state with read-only commands first:
163
+ `artshelf ledgers list --json`, `artshelf review --all --json`, and
164
+ `artshelf trash list --all --json`; for old trash on a selected ledger, run
165
+ `artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json`.
166
+ 3. Present a decision packet instead of raw counts. Include registry health,
167
+ affected ledgers, due/manual-review/missing-path counts, executable entries,
168
+ skipped entries, refused entries, trashed record counts and ages, purge
169
+ dry-run plan ids/skipped entries, and the next safe action.
170
+ 4. Classify each candidate:
171
+ - `trash-safe`: disposable after the reviewed plan moves it into Artshelf trash.
172
+ - `needs-human-review`: `cleanup=review`, evidence, backups, reports, or
173
+ anything that should be inspected before closing.
174
+ - `resolve-candidate`: already handled, missing, or no longer needed; use
175
+ `artshelf resolve` only after confirmation.
176
+ - `registry-problem`: stale, missing, or invalid ledger; fix registry health
177
+ before touching artifacts.
178
+ 5. If cleanup execution is appropriate, generate or reuse a dry-run plan, then
179
+ ask for explicit approval naming the ledger path and reviewed plan id.
180
+ 6. For trashed records, require a separate reviewed purge plan before physical
181
+ deletion:
182
+
183
+ ```bash
184
+ artshelf trash list --ledger <ledger-path>
185
+ artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
186
+ artshelf trash purge --execute --plan-id <purge-plan-id> --ledger <ledger-path> --json
187
+ ```
188
+
189
+ 7. After approved cleanup execute, trash purge, or resolve, verify quiet with
190
+ `artshelf review --all --json`, plus `artshelf trash list --ledger <ledger-path> --json`
191
+ and purge receipt evidence after purge, or explain what remains.
192
+
193
+ Approval wording should be exact:
194
+
195
+ ```text
196
+ approve artshelf cleanup ledger <ledger-path> plan <plan-id>
197
+ approve artshelf trash purge ledger <ledger-path> plan <purge-plan-id>
198
+ ```
199
+
200
+ Never execute from a read-only preview id. Never generate a fresh plan and
201
+ execute it in the same step. `trash` moves artifacts into Artshelf trash; physical
202
+ delete requires a separate reviewed trash purge plan.
203
+
204
+ ## Reasons
205
+
206
+ Write reasons as small audit notes. A good reason lets a future agent decide
207
+ whether the artifact still matters without replaying the whole conversation.
208
+
209
+ Good:
210
+
211
+ ```text
212
+ backup before rewriting migration order for issue-123
213
+ ```
214
+
215
+ Weak:
216
+
217
+ ```text
218
+ backup
219
+ ```
220
+
221
+ Include the source of authority when useful: PR number, issue id, workflow id,
222
+ command, failing check, or user request.
223
+
224
+ ## Reporting Artshelf IDs
225
+
226
+ After registration, include the Artshelf id anywhere future cleanup context will be
227
+ read:
228
+
229
+ - handoff notes
230
+ - PR comments
231
+ - issue comments
232
+ - daily memory
233
+ - task run summaries
234
+ - incident or debugging notes
235
+
236
+ Example:
237
+
238
+ ```text
239
+ Temporary parser output registered in Artshelf as shf_20260601_182800_ab12.
240
+ Retain until 2026-06-04; cleanup=review.
241
+ ```
242
+
243
+ ## Cleanup Boundary
244
+
245
+ Agents may run non-destructive cleanup checks:
246
+
247
+ ```bash
248
+ artshelf validate --json
249
+ artshelf validate --all --json
250
+ artshelf due --json
251
+ artshelf due --all --json
252
+ artshelf review --all --json
253
+ ```
254
+
255
+ Cleanup dry-run is safe to run. It writes plan files for later review only when
256
+ there are executable cleanup entries:
257
+
258
+ ```bash
259
+ artshelf cleanup --dry-run --json
260
+ artshelf cleanup --dry-run --all --json
261
+ ```
262
+
263
+ Cleanup execution is approval-only: no daemon, no auto-execute, no global
264
+ execute, and no fresh-plan-then-execute shortcut. Agents must not run this
265
+ without explicit human approval:
266
+
267
+ ```bash
268
+ artshelf cleanup --execute --plan-id <id>
269
+ ```
270
+
271
+ Approval should name the plan id. Do not generate a fresh plan and execute it in
272
+ the same breath. Review the dry-run first, then execute the reviewed plan id.
273
+ After cleanup execution, agents may inspect trash and create a purge dry-run for
274
+ review:
275
+
276
+ ```bash
277
+ artshelf trash list --ledger <ledger-path> --json
278
+ artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
279
+ ```
280
+
281
+ Trash purge execution is separately approval-only and must name the ledger and
282
+ reviewed purge plan id:
283
+
284
+ ```bash
285
+ artshelf trash purge --execute --plan-id <purge-plan-id> --ledger <ledger-path> --json
286
+ ```
287
+
288
+ No-op dry-runs report `not-created` and do not write plan files. When dry-run or
289
+ execute creates plan or receipt artifacts, Artshelf records those artifacts in the
290
+ ledger as `owner=artshelf`.
291
+
292
+ `cleanup=delete` stays refused; execution records `cleanup-refused` instead
293
+ of silently deleting files. Physical deletion requires a separate reviewed trash
294
+ purge plan.
295
+
296
+ Execution writes a receipt and updates touched ledger records to `trashed`,
297
+ `review-required`, or `cleanup-refused`, so handled artifacts stop reappearing in
298
+ future due and dry-run cleanup output.
299
+
300
+ Agents may mark a ledger record manually resolved when the user confirms the
301
+ artifact was inspected, is already missing, or is no longer needed:
302
+
303
+ ```bash
304
+ artshelf resolve <id> --status resolved --reason <text>
305
+ ```
306
+
307
+ Use a specific reason. `resolve` only updates the ledger; it does not move or
308
+ delete files. Resolved records stop reappearing in future due and dry-run
309
+ cleanup output while remaining visible in `artshelf list --status resolved`.
310
+
311
+ ## Scheduled Review
312
+
313
+ Agents may schedule routine Artshelf reviews for stale artifacts through their host
314
+ runtime, such as an agent cron, CI job, or recurring task. Keep the scheduled
315
+ job non-destructive:
316
+
317
+ ```bash
318
+ artshelf validate --json
319
+ artshelf due --json
320
+ artshelf review --all --json
321
+ ```
322
+
323
+ Read-only health and dashboard checks are also safe to schedule. Run
324
+ `artshelf review --all --json` for aggregate triage (`summary` and `nextAction`),
325
+ `artshelf doctor --json` to catch a broken or stale registry before relying on
326
+ cleanup planning, and `artshelf status --all --json` for a compact cron summary:
327
+
328
+ ```bash
329
+ artshelf doctor --json
330
+ artshelf status --all --json
331
+ ```
332
+
333
+ Scheduled cleanup and trash purge dry-runs may write plan files for later review
334
+ when entries exist, but must not move or delete files:
335
+
336
+ ```bash
337
+ artshelf cleanup --dry-run --json
338
+ artshelf trash list --ledger <ledger-path> --json
339
+ artshelf trash list --all --json
340
+ artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
341
+ ```
342
+
343
+ The scheduled job should report the ledger path, due/manual-review/missing-path
344
+ counts, cleanup dry-run plan id, executable entries, skipped entries, and refused
345
+ entries. When reporting trash, `artshelf trash list --all --json` may discover trashed
346
+ records across registered ledgers. Include trashed record counts and target ages;
347
+ run purge dry-runs only for an explicit ledger and report any plan id, matching
348
+ entries, and skipped entries. It should be
349
+ quiet when nothing needs attention unless the user asked for a regular summary.
350
+
351
+ Use explicit ledger paths when scheduling checks for a known project or user
352
+ ledger. Do not scan arbitrary filesystem locations looking for ledgers unless
353
+ the user has opted into that discovery scope.
354
+
355
+ Scheduled jobs must not run cleanup execution or trash purge execution. They
356
+ may only dry-run and report plans for later human review:
357
+
358
+ ```bash
359
+ artshelf cleanup --execute --plan-id <id>
360
+ artshelf trash purge --execute --plan-id <id>
361
+ ```
362
+
363
+ Any later execution requires a human to review the dry-run output and approve
364
+ that specific plan id.
365
+
366
+ ## Handoff Pattern
367
+
368
+ When a task creates registered artifacts, add a short section like this:
369
+
370
+ ```text
371
+ Artshelf artifacts:
372
+ - shf_20260601_182800_ab12: /tmp/parser-output, debug evidence for issue-123,
373
+ retain until 2026-06-04, cleanup=review
374
+ ```
375
+
376
+ If there are no eligible artifacts, say nothing. If eligible artifacts were
377
+ skipped instead of registered, include the brief skip reason from the completion
378
+ checklist. Do not invent Artshelf entries after the fact just to make a handoff look
379
+ tidy.
380
+
381
+ ## Completion Checklist
382
+
383
+ Before final response or handoff, agents should review their own file actions
384
+ from the current task:
385
+
386
+ 1. Did I create, copy, export, quarantine, back up, or preserve any non-source
387
+ file or directory?
388
+ 2. Will any of those paths outlive this command?
389
+ 3. If yes, did I either register them with Artshelf or record a clear skip reason?
390
+
391
+ Do not call work done while known eligible artifacts are neither registered nor
392
+ explicitly skipped.
@@ -0,0 +1,172 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Artshelf Docs</title>
7
+ <meta name="description" content="Artshelf is a tiny CLI for accountable temporary artifact retention.">
8
+ <link rel="stylesheet" href="site.css">
9
+ <script src="theme.js" defer></script>
10
+ </head>
11
+ <body>
12
+ <div class="docs-shell">
13
+ <nav class="global-nav" aria-label="Documentation">
14
+ <a class="site-mark" href="index.html" aria-current="page">
15
+ <strong>Artshelf</strong>
16
+ <span>Artifact retention CLI</span>
17
+ </a>
18
+ <button class="theme-toggle" type="button" data-theme-toggle aria-label="Toggle color theme" aria-pressed="false">Dark</button>
19
+ <div class="nav-scroll" aria-label="Documentation sections">
20
+ <div class="nav-section">
21
+ <p class="nav-section-title">Start</p>
22
+ <a href="index.html" aria-current="page">Overview</a>
23
+ <a href="install.html">Install</a>
24
+ <a href="quickstart.html">Quickstart</a>
25
+ </div>
26
+ <div class="nav-section">
27
+ <p class="nav-section-title">Agents</p>
28
+ <a href="agent-usage.html">Agent usage</a>
29
+ <a href="https://github.com/calvinnwq/artshelf/blob/main/skills/artshelf/SKILL.md">Agent skill</a>
30
+ </div>
31
+ <div class="nav-section">
32
+ <p class="nav-section-title">Reference</p>
33
+ <a href="reference.html">CLI reference</a>
34
+ <a href="https://github.com/calvinnwq/artshelf">GitHub</a>
35
+ </div>
36
+ </div>
37
+ </nav>
38
+
39
+ <div class="docs-content">
40
+ <header class="page-top">
41
+ <div class="wrap">
42
+ <nav class="breadcrumbs" aria-label="Breadcrumbs">
43
+ <span>Docs</span>
44
+ </nav>
45
+ <div class="hero">
46
+ <div>
47
+ <p class="eyebrow">Temporary artifacts · Accountable cleanup</p>
48
+ <h1>Put run outputs somewhere accountable.</h1>
49
+ <p class="lede">
50
+ Artshelf records why temporary artifacts, backups, and debug evidence exist,
51
+ then gives humans and agents a reviewable cleanup plan before anything moves.
52
+ </p>
53
+ <div class="actions">
54
+ <a class="button primary" href="install.html">Install from source</a>
55
+ <a class="button" href="quickstart.html">Quickstart</a>
56
+ <a class="button" href="agent-usage.html">Agent usage</a>
57
+ <a class="button" href="https://github.com/calvinnwq/artshelf">GitHub</a>
58
+ </div>
59
+ </div>
60
+ <div class="terminal" aria-label="Artshelf terminal example">
61
+ <div class="terminal-head"><span class="dot"></span><span class="dot"></span><span class="dot"></span><span>artshelf</span></div>
62
+ <pre><code>$ artshelf put /tmp/parser-output \
63
+ --reason "debug evidence for parser fix" \
64
+ --ttl 3d \
65
+ --kind run-artifact \
66
+ --cleanup review
67
+
68
+ recorded shf_20260601_182800_ab12
69
+ retains until: 2026-06-04T08:28:00Z
70
+
71
+ $ artshelf cleanup --dry-run --json
72
+ { "plan": { "planId": "not-created", "planPath": null } }</code></pre>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </header>
77
+
78
+ <main class="wrap">
79
+ <article>
80
+ <section>
81
+ <h2>Why Artshelf Exists</h2>
82
+ <p>
83
+ Agent-heavy projects create a lot of temporary stuff: copied files, rollback
84
+ folders, smoke-test output, reports, and logs. Filesystem age cannot tell a future
85
+ agent whether those artifacts are still useful. Artshelf captures intent at creation
86
+ time, while the reason is still fresh.
87
+ </p>
88
+ <div class="summary-grid">
89
+ <div class="stat"><strong>13</strong><span>small v1 commands</span></div>
90
+ <div class="stat"><strong>0</strong><span>runtime dependencies</span></div>
91
+ <div class="stat"><strong>JSONL</strong><span>plain ledger storage</span></div>
92
+ <div class="stat"><strong>dry-run</strong><span>before mutation</span></div>
93
+ </div>
94
+ </section>
95
+
96
+ <section>
97
+ <h2>What Artshelf Does</h2>
98
+ <div class="grid">
99
+ <div class="card">
100
+ <h3>Register a temp artifact</h3>
101
+ <p>Record path, reason, owner, labels, retention, and cleanup mode with `artshelf put`.</p>
102
+ </div>
103
+ <div class="card">
104
+ <h3>Review everything safely</h3>
105
+ <p>Use `artshelf due` and `artshelf cleanup --dry-run` to inspect what needs attention; no-op previews report `not-created`.</p>
106
+ </div>
107
+ <div class="card">
108
+ <h3>Approve cleanup safely</h3>
109
+ <p>Cleanup execution uses a human-approved plan id, writes a receipt, and updates ledger state.</p>
110
+ </div>
111
+ <div class="card">
112
+ <h3>Purge old trash explicitly</h3>
113
+ <p>Trash purge physically removes only quarantined trash from a separately reviewed purge plan.</p>
114
+ </div>
115
+ </div>
116
+ </section>
117
+
118
+ <section>
119
+ <h2>Pick Your Path</h2>
120
+ <div class="grid">
121
+ <a class="doc-card" href="install.html">
122
+ <strong>Install from source</strong>
123
+ <span>Clone locally, build, link with npm, and smoke-test the CLI.</span>
124
+ </a>
125
+ <a class="doc-card" href="quickstart.html">
126
+ <strong>Try the workflow</strong>
127
+ <span>Register a temp artifact, review safely, approve cleanup, and purge old trash explicitly.</span>
128
+ </a>
129
+ <a class="doc-card" href="agent-usage.html">
130
+ <strong>Wire up agents</strong>
131
+ <span>Teach agents when to call Artshelf and how to report Artshelf ids.</span>
132
+ </a>
133
+ <a class="doc-card" href="reference.html">
134
+ <strong>Look up commands</strong>
135
+ <span>See the v1 command surface and cleanup safety rules.</span>
136
+ </a>
137
+ <a class="doc-card" href="https://github.com/calvinnwq/artshelf/blob/main/SPEC.md">
138
+ <strong>Read the spec</strong>
139
+ <span>Understand the ledger-first contract and v1 non-goals.</span>
140
+ </a>
141
+ <a class="doc-card" href="https://github.com/calvinnwq/artshelf">
142
+ <strong>Open the repo</strong>
143
+ <span>Source, tests, release automation, and the portable agent skill.</span>
144
+ </a>
145
+ </div>
146
+ </section>
147
+
148
+ <section>
149
+ <h2>Safety Model</h2>
150
+ <ul>
151
+ <li>Ledger-first. Artshelf only cleans entries that were registered intentionally.</li>
152
+ <li>Dry-run before mutation. Plans are written before execution.</li>
153
+ <li>No daemon or auto-execute path. Only a human-run command can mutate files.</li>
154
+ <li>No global execute. <code>--all</code> is read-only or dry-run reporting only; trash purge refuses it.</li>
155
+ <li>No fresh-plan-then-execute shortcut. Execute only a reviewed plan id.</li>
156
+ <li>Handled records stop appearing in future due and cleanup dry-run output.</li>
157
+ <li>Cleanup refuses delete actions; physical trash purge needs its own reviewed plan.</li>
158
+ </ul>
159
+ <div class="note">
160
+ Artshelf is an early v1 MVP. Source install and live dogfooding come before npm publishing.
161
+ </div>
162
+ </section>
163
+ </article>
164
+ </main>
165
+
166
+ <footer class="site-footer">
167
+ <div class="wrap">Artshelf docs · MIT · <a href="https://github.com/calvinnwq/artshelf">GitHub</a></div>
168
+ </footer>
169
+ </div>
170
+ </div>
171
+ </body>
172
+ </html>