artshelf 0.6.0 → 0.7.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.
@@ -1,480 +1,53 @@
1
1
  # Agent Usage
2
2
 
3
3
  Agents that support local skills can copy or reference
4
- [`skills/artshelf/SKILL.md`](../skills/artshelf/SKILL.md). The public docs site at
4
+ the whole [`skills/artshelf`](../skills/artshelf) directory. The public docs site at
5
5
  <https://calvinnwq.github.io/artshelf/> explains the same contract in browsable
6
6
  form.
7
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.
8
+ Artshelf is meant to be operated by agents through a small skill contract and
9
+ read-only scheduled reviews. Agents remember and summarize. Humans approve
10
+ mutation.
11
11
 
12
- ## When To Register
12
+ ## Workflow Summary
13
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.
14
+ Use Artshelf as a four-stage loop around agent work:
18
15
 
19
- Call `artshelf put` immediately after creating an eligible artifact:
16
+ 1. **Create**: register durable temp artifacts with lookup-before-put and
17
+ `artshelf put`, or state the skip reason.
18
+ 2. **Monitor**: run read-only checks for registry health, due records, missing
19
+ paths, and trash state.
20
+ 3. **Review**: turn raw output into an `ArtshelfReviewReport` decision packet
21
+ with exact approval targets.
22
+ 4. **Clean**: execute approved plans, clear trash only from a separate
23
+ reviewed purge plan, resolve confirmed ids, then verify quiet.
20
24
 
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
25
+ This maps to the product loop: **Create -> Monitor -> Review -> Clean**.
29
26
 
30
- Do not register normal source files, committed documentation, package build
31
- outputs that can be regenerated cheaply, or dependency caches.
27
+ ## Child Pages
32
28
 
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.
29
+ The browsable docs split the workflow into focused child pages:
37
30
 
38
- ## Command Shape
31
+ - [Create](agent-create.html): registration triggers, lookup-before-put, skip
32
+ reasons, and Artshelf id footnotes.
33
+ - [Monitor](agent-monitor.html): registry health, scheduled read-only checks,
34
+ and preview plans.
35
+ - [Review](agent-review.html): decision packet schema, classifications, and
36
+ exact approval wording.
37
+ - [Clean](agent-clean.html): approval-only cleanup, trash purge, resolve,
38
+ receipts, and verify-quiet checks.
39
39
 
40
- Use the installed CLI when available:
40
+ ## Operating Principles
41
41
 
42
- ```bash
43
- artshelf put <path> --reason "<why this exists>" --ttl 3d --kind run-artifact --cleanup review --owner agent
44
- ```
42
+ - Agents remember with the portable skill.
43
+ - Scheduled checks read and report only.
44
+ - Review output is a decision packet, not raw counts.
45
+ - Approval names the exact ledger, plan id, or record ids.
46
+ - Every approved action ends with a read-only verification.
45
47
 
46
- If Artshelf is not installed, use the package-manager install path when
47
- available:
48
+ ## Portable Skill
48
49
 
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
- When `artshelf put --json` succeeds, include a deterministic Artshelf footnote in
96
- the same handoff, status, final response, or run summary that mentions the
97
- artifact:
98
-
99
- ```text
100
- Artshelf footnote: registered <artifact-path> as <artshelf-id>; reason: <short reason>; due: <YYYY-MM-DD|manual-review>; cleanup=<cleanup-mode>.
101
- ```
102
-
103
- ## Idempotent Lookup
104
-
105
- Integrations should check the ledger before creating another record for the
106
- same artifact. Use `find` and `get` for read-only lookup:
107
-
108
- ```bash
109
- artshelf find --path <path> --owner <agent-or-runtime> --label <task-or-run-id> --json
110
- artshelf get <id> --json
111
- ```
112
-
113
- `find` requires at least one selector: `--path`, `--owner`, `--label`, or
114
- `--status`. Multiple labels are an all-label match. If `find` returns an
115
- existing record, report that Artshelf id instead of calling `put` again. If it
116
- returns no entries, call `put` and record the new id.
117
-
118
- ## Ledger Registry
119
-
120
- Artshelf keeps a user-level registry at `~/.artshelf/ledgers.json` so one CLI can
121
- review all known ledgers without moving project records into one global file.
122
- `put` registers the ledger it writes to. Register existing ledgers explicitly
123
- when adopting Artshelf for an existing project:
124
-
125
- ```bash
126
- artshelf ledgers add --ledger <repo>/.artshelf/ledger.jsonl --name <project> --scope repo
127
- artshelf ledgers list --json
128
- ```
129
-
130
- Renamed installs before `0.5.0` used `.shelf` paths. For migration, copy the old
131
- ledger directories into `.artshelf`, rewrite registry entries, validate the new
132
- registry, and keep the `.shelf` copies until rollback is no longer needed.
133
-
134
- `artshelf ledgers list --json` validates each registered ledger and reports
135
- ok/missing/invalid status with entry and warning/error counts, so agents can
136
- detect stale registry entries without a separate validate pass. Add `--plain`
137
- for a fast listing that skips validation.
138
-
139
- Use the registry for read-only review and discovery:
140
-
141
- ```bash
142
- artshelf review --all --json
143
- artshelf status --all --json
144
- artshelf due --all --json
145
- artshelf find --all --owner <agent-or-runtime> --json
146
- artshelf trash list --all --json
147
- ```
148
-
149
- `artshelf review --all --json` returns an aggregate triage summary (affected
150
- ledgers, due, manual-review, missing-path, executable, and skipped counts plus
151
- preview plan ids) alongside the per-ledger detail, and states the next safe
152
- action.
153
-
154
- Use global cleanup dry-run when you want Artshelf to write cleanup plans for
155
- registered ledgers with cleanup entries, without moving files:
156
-
157
- ```bash
158
- artshelf cleanup --dry-run --all --json
159
- ```
160
-
161
- Do not use `--all` as permission to mutate files. Cleanup execution remains
162
- ledger-specific and requires a reviewed plan id for that ledger.
163
- If the executable cleanup entries have not changed, dry-run reuses the existing
164
- plan id and refreshes the same plan file instead of creating duplicate plans.
165
-
166
- ## Daily Review Workflow
167
-
168
- Use this flow when a scheduled review, recurring task, or user request reports
169
- Artshelf cleanup attention:
170
-
171
- 1. Register artifacts early during work, or state why an eligible artifact was
172
- skipped.
173
- 2. Review state with read-only commands first:
174
- `artshelf ledgers list --json`, `artshelf review --all --json`, and
175
- `artshelf trash list --all --json`; for old trash on a selected ledger, run
176
- `artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json`.
177
- 3. Present a decision packet instead of raw counts. Include registry health,
178
- affected ledgers, due/manual-review/missing-path counts, executable entries,
179
- skipped entries, refused entries, trashed record counts and ages, purge
180
- dry-run plan ids/skipped entries, and the next safe action.
181
- 4. Classify each candidate:
182
- - `trash-safe`: disposable after the reviewed plan moves it into Artshelf trash.
183
- - `needs-human-review`: `cleanup=review`, evidence, backups, reports, or
184
- anything that should be inspected before closing.
185
- - `resolve-candidate`: already handled, missing, or no longer needed; use
186
- `artshelf resolve` only after confirmation.
187
- - `registry-problem`: stale, missing, or invalid ledger; fix registry health
188
- before touching artifacts.
189
- 5. If cleanup execution is appropriate, generate or reuse a dry-run plan, then
190
- ask for explicit approval naming the ledger path and reviewed plan id.
191
- 6. For trashed records, require a separate reviewed purge plan before physical
192
- deletion:
193
-
194
- ```bash
195
- artshelf trash list --ledger <ledger-path>
196
- artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
197
- artshelf trash purge --execute --plan-id <purge-plan-id> --ledger <ledger-path> --json
198
- ```
199
-
200
- 7. After approved cleanup execute, trash purge, or resolve, verify quiet with
201
- `artshelf review --all --json`, plus `artshelf trash list --ledger <ledger-path> --json`
202
- and purge receipt evidence after purge, or explain what remains.
203
-
204
- ### Review Plan Report Schema
205
-
206
- When a dry-run creates or reuses a cleanup or trash purge plan, surface the plan
207
- in a compact human-readable report. The report should let the user approve, ask
208
- for changes, or request alternatives without opening the plan file.
209
-
210
- For deterministic agent integrations, construct an `ArtshelfReviewReport` JSON
211
- object first, then render it to text. Use
212
- [`schemas/artshelf-review-report.schema.json`](schemas/artshelf-review-report.schema.json)
213
- for the packet shape and
214
- [`examples/artshelf-review-report.json`](examples/artshelf-review-report.json)
215
- as the canonical example. The schema locks report structure; the CLI output and
216
- approval rules still define cleanup safety.
217
-
218
- Render the JSON packet as a compact decision card using `decisionSummary` and
219
- `decisionGroups`. Lead with counts, then show exactly what is ready for approval
220
- and what needs review first. Emojis are encouraged when the host renders them
221
- well because they make the groups scannable; omit them only for plain-text or
222
- accessibility-constrained surfaces.
223
-
224
- ```text
225
- Artshelf daily review
226
- Status: <ok|attention needed>; registry <ok|attention>
227
-
228
- ✅ Ready for approval: <n>
229
- 👀 Needs review first: <n>
230
- ⚠️ Blocked: <n>
231
-
232
- Recommendation
233
- <one short sentence with the next safest action>.
234
-
235
- Ready for approval
236
- 1. <short item label>
237
- Why: <short reason>
238
- Action: <what approval will do>
239
- approve artshelf cleanup ledger <ledger-path> plan <plan-id>
240
-
241
- 2. <short item label>
242
- Why: <short reason>
243
- Action: <ledger-only update, no file changes>
244
- approve artshelf resolve missing ledger <ledger-path> ids <id...>
245
-
246
- Needs review first
247
- 1. <short item label>
248
- Why: <short reason>
249
- Suggested next step: inspect path, then choose keep, change retention, resolve, or clean up later
250
- Path: <path>
251
-
252
- Blocked
253
- <none, or the registry/refused/missing-path blocker and next repair step>
254
-
255
- Safety
256
- Dry-run only. No execute, resolve, or delete ran.
257
- ```
258
-
259
- Keep the full `ArtshelfReviewReport` JSON as the audit packet and include it as
260
- an attachment, linked file, or expandable detail when the host supports that.
261
- Do not paste the whole packet into chat unless the user asks for it. For long
262
- plans, show only the first 3 to 5 decisions under each visible group, then state
263
- the hidden count by group and classification. Do not hide refused,
264
- registry-problem, or missing-path items.
265
-
266
- If the host supports buttons, menus, or other interactive controls, they should
267
- emit exact text commands such as the approval targets below. Always include the
268
- exact approval target in the message body as a fallback for clients where those
269
- controls do not render.
270
-
271
- Approval wording should be exact:
272
-
273
- ```text
274
- approve artshelf cleanup ledger <ledger-path> plan <plan-id>
275
- approve artshelf trash purge ledger <ledger-path> plan <purge-plan-id>
276
- approve artshelf resolve missing ledger <ledger-path> ids <id...>
277
- ```
278
-
279
- Never execute from a read-only preview id. Never generate a fresh plan and
280
- execute it in the same step. `trash` moves artifacts into Artshelf trash; physical
281
- delete requires a separate reviewed trash purge plan.
282
-
283
- ## Reasons
284
-
285
- Write reasons as small audit notes. A good reason lets a future agent decide
286
- whether the artifact still matters without replaying the whole conversation.
287
-
288
- Good:
289
-
290
- ```text
291
- backup before rewriting migration order for issue-123
292
- ```
293
-
294
- Weak:
295
-
296
- ```text
297
- backup
298
- ```
299
-
300
- Include the source of authority when useful: PR number, issue id, workflow id,
301
- command, failing check, or user request.
302
-
303
- ## Reporting Artshelf IDs
304
-
305
- After registration, include the Artshelf id anywhere future cleanup context will be
306
- read:
307
-
308
- - handoff notes
309
- - PR comments
310
- - issue comments
311
- - daily memory
312
- - task run summaries
313
- - incident or debugging notes
314
-
315
- Example:
316
-
317
- ```text
318
- Temporary parser output registered in Artshelf as shf_20260601_182800_ab12.
319
- Retain until 2026-06-04; cleanup=review.
320
- ```
321
-
322
- ## Cleanup Boundary
323
-
324
- Agents may run non-destructive cleanup checks:
325
-
326
- ```bash
327
- artshelf validate --json
328
- artshelf validate --all --json
329
- artshelf due --json
330
- artshelf due --all --json
331
- artshelf review --all --json
332
- ```
333
-
334
- Cleanup dry-run is safe to run. It writes plan files for later review only when
335
- there are executable cleanup entries:
336
-
337
- ```bash
338
- artshelf cleanup --dry-run --json
339
- artshelf cleanup --dry-run --all --json
340
- ```
341
-
342
- Cleanup execution is approval-only: no daemon, no auto-execute, no global
343
- execute, and no fresh-plan-then-execute shortcut. Agents must not run this
344
- without explicit human approval:
345
-
346
- ```bash
347
- artshelf cleanup --execute --plan-id <id>
348
- ```
349
-
350
- Approval should name the plan id. Do not generate a fresh plan and execute it in
351
- the same breath. Review the dry-run first, then execute the reviewed plan id.
352
- After cleanup execution, agents may inspect trash and create a purge dry-run for
353
- review:
354
-
355
- ```bash
356
- artshelf trash list --ledger <ledger-path> --json
357
- artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
358
- ```
359
-
360
- Trash purge execution is separately approval-only and must name the ledger and
361
- reviewed purge plan id:
362
-
363
- ```bash
364
- artshelf trash purge --execute --plan-id <purge-plan-id> --ledger <ledger-path> --json
365
- ```
366
-
367
- No-op dry-runs report `not-created` and do not write plan files. When dry-run or
368
- execute creates plan or receipt artifacts, Artshelf records those artifacts in the
369
- ledger as `owner=artshelf`.
370
-
371
- `cleanup=delete` stays refused; execution records `cleanup-refused` instead
372
- of silently deleting files. Physical deletion requires a separate reviewed trash
373
- purge plan.
374
-
375
- Execution writes a receipt and updates touched ledger records to `trashed`,
376
- `review-required`, or `cleanup-refused`, so handled artifacts stop reappearing in
377
- future due and dry-run cleanup output.
378
-
379
- Agents may mark a ledger record manually resolved when the user confirms the
380
- artifact was inspected, is already missing, or is no longer needed:
381
-
382
- ```bash
383
- artshelf resolve <id> --status resolved --reason <text>
384
- ```
385
-
386
- Use a specific reason. `resolve` only updates the ledger; it does not move or
387
- delete files. For batches of missing-path records, ask for approval that names
388
- the exact ledger and ids:
389
-
390
- ```text
391
- approve artshelf resolve missing ledger <ledger-path> ids <id...>
392
- ```
393
-
394
- After resolution, verify with `artshelf review --all --json` and report whether
395
- the review is quiet or what remains. Resolved records stop reappearing in future
396
- due and dry-run cleanup output while remaining visible in
397
- `artshelf list --status resolved`.
398
-
399
- ## Scheduled Review
400
-
401
- Agents may schedule routine Artshelf reviews for stale artifacts through their host
402
- runtime, such as an agent cron, CI job, or recurring task. Keep the scheduled
403
- job non-destructive:
404
-
405
- ```bash
406
- artshelf validate --json
407
- artshelf due --json
408
- artshelf review --all --json
409
- ```
410
-
411
- Read-only health and dashboard checks are also safe to schedule. Run
412
- `artshelf review --all --json` for aggregate triage (`summary` and `nextAction`),
413
- `artshelf doctor --json` to catch a broken or stale registry before relying on
414
- cleanup planning, and `artshelf status --all --json` for a compact cron summary:
415
-
416
- ```bash
417
- artshelf doctor --json
418
- artshelf status --all --json
419
- ```
420
-
421
- Scheduled cleanup and trash purge dry-runs may write plan files for later review
422
- when entries exist, but must not move or delete files:
423
-
424
- ```bash
425
- artshelf cleanup --dry-run --json
426
- artshelf trash list --ledger <ledger-path> --json
427
- artshelf trash list --all --json
428
- artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
429
- ```
430
-
431
- The scheduled job should report the ledger path, due/manual-review/missing-path
432
- counts, cleanup dry-run plan id, executable entries, skipped entries, and refused
433
- entries. When reporting trash, `artshelf trash list --all --json` may discover trashed
434
- records across registered ledgers. Include trashed record counts and target ages;
435
- run purge dry-runs only for an explicit ledger and report any plan id, matching
436
- entries, and skipped entries. It should be
437
- quiet when nothing needs attention unless the user asked for a regular summary.
438
-
439
- Use explicit ledger paths when scheduling checks for a known project or user
440
- ledger. Do not scan arbitrary filesystem locations looking for ledgers unless
441
- the user has opted into that discovery scope.
442
-
443
- Scheduled jobs must not run cleanup execution or trash purge execution. They
444
- may only dry-run and report plans for later human review:
445
-
446
- ```bash
447
- artshelf cleanup --execute --plan-id <id>
448
- artshelf trash purge --execute --plan-id <id>
449
- ```
450
-
451
- Any later execution requires a human to review the dry-run output and approve
452
- that specific plan id.
453
-
454
- ## Handoff Pattern
455
-
456
- When a task creates registered artifacts, add a short section like this:
457
-
458
- ```text
459
- Artshelf artifacts:
460
- - shf_20260601_182800_ab12: /tmp/parser-output, debug evidence for issue-123,
461
- retain until 2026-06-04, cleanup=review
462
- ```
463
-
464
- If there are no eligible artifacts, say nothing. If eligible artifacts were
465
- skipped instead of registered, include the brief skip reason from the completion
466
- checklist. Do not invent Artshelf entries after the fact just to make a handoff look
467
- tidy.
468
-
469
- ## Completion Checklist
470
-
471
- Before final response or handoff, agents should review their own file actions
472
- from the current task:
473
-
474
- 1. Did I create, copy, export, quarantine, back up, or preserve any non-source
475
- file or directory?
476
- 2. Will any of those paths outlive this command?
477
- 3. If yes, did I either register them with Artshelf or record a clear skip reason?
478
-
479
- Do not call work done while known eligible artifacts are neither registered nor
480
- explicitly skipped.
50
+ The repo ships a portable skill at
51
+ [`skills/artshelf`](../skills/artshelf). Agents that support local skills can
52
+ copy or reference the whole directory directly, including the bundled
53
+ `scripts/render-review-report.mjs` renderer plus schema and example copies.