artshelf 0.5.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,396 +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
-
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 `~/.artshelf/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>/.artshelf/ledger.jsonl --name <project> --scope repo
120
- artshelf ledgers list --json
121
- ```
122
-
123
- Renamed installs before `0.5.0` used `.shelf` paths. For migration, copy the old
124
- ledger directories into `.artshelf`, rewrite registry entries, validate the new
125
- registry, and keep the `.shelf` copies until rollback is no longer needed.
126
-
127
- `artshelf ledgers list --json` validates each registered ledger and reports
128
- ok/missing/invalid status with entry and warning/error counts, so agents can
129
- detect stale registry entries without a separate validate pass. Add `--plain`
130
- for a fast listing that skips validation.
131
-
132
- Use the registry for read-only review and discovery:
133
-
134
- ```bash
135
- artshelf review --all --json
136
- artshelf status --all --json
137
- artshelf due --all --json
138
- artshelf find --all --owner <agent-or-runtime> --json
139
- artshelf trash list --all --json
140
- ```
141
-
142
- `artshelf review --all --json` returns an aggregate triage summary (affected
143
- ledgers, due, manual-review, missing-path, executable, and skipped counts plus
144
- preview plan ids) alongside the per-ledger detail, and states the next safe
145
- action.
146
-
147
- Use global cleanup dry-run when you want Artshelf to write cleanup plans for
148
- registered ledgers with cleanup entries, without moving files:
149
-
150
- ```bash
151
- artshelf cleanup --dry-run --all --json
152
- ```
153
-
154
- Do not use `--all` as permission to mutate files. Cleanup execution remains
155
- ledger-specific and requires a reviewed plan id for that ledger.
156
- If the executable cleanup entries have not changed, dry-run reuses the existing
157
- plan id and refreshes the same plan file instead of creating duplicate plans.
158
-
159
- ## Daily Review Workflow
160
-
161
- Use this flow when a scheduled review, recurring task, or user request reports
162
- Artshelf cleanup attention:
163
-
164
- 1. Register artifacts early during work, or state why an eligible artifact was
165
- skipped.
166
- 2. Review state with read-only commands first:
167
- `artshelf ledgers list --json`, `artshelf review --all --json`, and
168
- `artshelf trash list --all --json`; for old trash on a selected ledger, run
169
- `artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json`.
170
- 3. Present a decision packet instead of raw counts. Include registry health,
171
- affected ledgers, due/manual-review/missing-path counts, executable entries,
172
- skipped entries, refused entries, trashed record counts and ages, purge
173
- dry-run plan ids/skipped entries, and the next safe action.
174
- 4. Classify each candidate:
175
- - `trash-safe`: disposable after the reviewed plan moves it into Artshelf trash.
176
- - `needs-human-review`: `cleanup=review`, evidence, backups, reports, or
177
- anything that should be inspected before closing.
178
- - `resolve-candidate`: already handled, missing, or no longer needed; use
179
- `artshelf resolve` only after confirmation.
180
- - `registry-problem`: stale, missing, or invalid ledger; fix registry health
181
- before touching artifacts.
182
- 5. If cleanup execution is appropriate, generate or reuse a dry-run plan, then
183
- ask for explicit approval naming the ledger path and reviewed plan id.
184
- 6. For trashed records, require a separate reviewed purge plan before physical
185
- deletion:
186
-
187
- ```bash
188
- artshelf trash list --ledger <ledger-path>
189
- artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
190
- artshelf trash purge --execute --plan-id <purge-plan-id> --ledger <ledger-path> --json
191
- ```
192
-
193
- 7. After approved cleanup execute, trash purge, or resolve, verify quiet with
194
- `artshelf review --all --json`, plus `artshelf trash list --ledger <ledger-path> --json`
195
- and purge receipt evidence after purge, or explain what remains.
196
-
197
- Approval wording should be exact:
198
-
199
- ```text
200
- approve artshelf cleanup ledger <ledger-path> plan <plan-id>
201
- approve artshelf trash purge ledger <ledger-path> plan <purge-plan-id>
202
- ```
203
-
204
- Never execute from a read-only preview id. Never generate a fresh plan and
205
- execute it in the same step. `trash` moves artifacts into Artshelf trash; physical
206
- delete requires a separate reviewed trash purge plan.
207
-
208
- ## Reasons
209
-
210
- Write reasons as small audit notes. A good reason lets a future agent decide
211
- whether the artifact still matters without replaying the whole conversation.
212
-
213
- Good:
214
-
215
- ```text
216
- backup before rewriting migration order for issue-123
217
- ```
218
-
219
- Weak:
220
-
221
- ```text
222
- backup
223
- ```
224
-
225
- Include the source of authority when useful: PR number, issue id, workflow id,
226
- command, failing check, or user request.
227
-
228
- ## Reporting Artshelf IDs
229
-
230
- After registration, include the Artshelf id anywhere future cleanup context will be
231
- read:
232
-
233
- - handoff notes
234
- - PR comments
235
- - issue comments
236
- - daily memory
237
- - task run summaries
238
- - incident or debugging notes
239
-
240
- Example:
241
-
242
- ```text
243
- Temporary parser output registered in Artshelf as shf_20260601_182800_ab12.
244
- Retain until 2026-06-04; cleanup=review.
245
- ```
246
-
247
- ## Cleanup Boundary
248
-
249
- Agents may run non-destructive cleanup checks:
250
-
251
- ```bash
252
- artshelf validate --json
253
- artshelf validate --all --json
254
- artshelf due --json
255
- artshelf due --all --json
256
- artshelf review --all --json
257
- ```
258
-
259
- Cleanup dry-run is safe to run. It writes plan files for later review only when
260
- there are executable cleanup entries:
261
-
262
- ```bash
263
- artshelf cleanup --dry-run --json
264
- artshelf cleanup --dry-run --all --json
265
- ```
266
-
267
- Cleanup execution is approval-only: no daemon, no auto-execute, no global
268
- execute, and no fresh-plan-then-execute shortcut. Agents must not run this
269
- without explicit human approval:
270
-
271
- ```bash
272
- artshelf cleanup --execute --plan-id <id>
273
- ```
274
-
275
- Approval should name the plan id. Do not generate a fresh plan and execute it in
276
- the same breath. Review the dry-run first, then execute the reviewed plan id.
277
- After cleanup execution, agents may inspect trash and create a purge dry-run for
278
- review:
279
-
280
- ```bash
281
- artshelf trash list --ledger <ledger-path> --json
282
- artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
283
- ```
284
-
285
- Trash purge execution is separately approval-only and must name the ledger and
286
- reviewed purge plan id:
287
-
288
- ```bash
289
- artshelf trash purge --execute --plan-id <purge-plan-id> --ledger <ledger-path> --json
290
- ```
291
-
292
- No-op dry-runs report `not-created` and do not write plan files. When dry-run or
293
- execute creates plan or receipt artifacts, Artshelf records those artifacts in the
294
- ledger as `owner=artshelf`.
295
-
296
- `cleanup=delete` stays refused; execution records `cleanup-refused` instead
297
- of silently deleting files. Physical deletion requires a separate reviewed trash
298
- purge plan.
299
-
300
- Execution writes a receipt and updates touched ledger records to `trashed`,
301
- `review-required`, or `cleanup-refused`, so handled artifacts stop reappearing in
302
- future due and dry-run cleanup output.
303
-
304
- Agents may mark a ledger record manually resolved when the user confirms the
305
- artifact was inspected, is already missing, or is no longer needed:
306
-
307
- ```bash
308
- artshelf resolve <id> --status resolved --reason <text>
309
- ```
310
-
311
- Use a specific reason. `resolve` only updates the ledger; it does not move or
312
- delete files. Resolved records stop reappearing in future due and dry-run
313
- cleanup output while remaining visible in `artshelf list --status resolved`.
314
-
315
- ## Scheduled Review
316
-
317
- Agents may schedule routine Artshelf reviews for stale artifacts through their host
318
- runtime, such as an agent cron, CI job, or recurring task. Keep the scheduled
319
- job non-destructive:
320
-
321
- ```bash
322
- artshelf validate --json
323
- artshelf due --json
324
- artshelf review --all --json
325
- ```
326
-
327
- Read-only health and dashboard checks are also safe to schedule. Run
328
- `artshelf review --all --json` for aggregate triage (`summary` and `nextAction`),
329
- `artshelf doctor --json` to catch a broken or stale registry before relying on
330
- cleanup planning, and `artshelf status --all --json` for a compact cron summary:
331
-
332
- ```bash
333
- artshelf doctor --json
334
- artshelf status --all --json
335
- ```
336
-
337
- Scheduled cleanup and trash purge dry-runs may write plan files for later review
338
- when entries exist, but must not move or delete files:
339
-
340
- ```bash
341
- artshelf cleanup --dry-run --json
342
- artshelf trash list --ledger <ledger-path> --json
343
- artshelf trash list --all --json
344
- artshelf trash purge --older-than 7d --dry-run --ledger <ledger-path> --json
345
- ```
346
-
347
- The scheduled job should report the ledger path, due/manual-review/missing-path
348
- counts, cleanup dry-run plan id, executable entries, skipped entries, and refused
349
- entries. When reporting trash, `artshelf trash list --all --json` may discover trashed
350
- records across registered ledgers. Include trashed record counts and target ages;
351
- run purge dry-runs only for an explicit ledger and report any plan id, matching
352
- entries, and skipped entries. It should be
353
- quiet when nothing needs attention unless the user asked for a regular summary.
354
-
355
- Use explicit ledger paths when scheduling checks for a known project or user
356
- ledger. Do not scan arbitrary filesystem locations looking for ledgers unless
357
- the user has opted into that discovery scope.
358
-
359
- Scheduled jobs must not run cleanup execution or trash purge execution. They
360
- may only dry-run and report plans for later human review:
361
-
362
- ```bash
363
- artshelf cleanup --execute --plan-id <id>
364
- artshelf trash purge --execute --plan-id <id>
365
- ```
366
-
367
- Any later execution requires a human to review the dry-run output and approve
368
- that specific plan id.
369
-
370
- ## Handoff Pattern
371
-
372
- When a task creates registered artifacts, add a short section like this:
373
-
374
- ```text
375
- Artshelf artifacts:
376
- - shf_20260601_182800_ab12: /tmp/parser-output, debug evidence for issue-123,
377
- retain until 2026-06-04, cleanup=review
378
- ```
379
-
380
- If there are no eligible artifacts, say nothing. If eligible artifacts were
381
- skipped instead of registered, include the brief skip reason from the completion
382
- checklist. Do not invent Artshelf entries after the fact just to make a handoff look
383
- tidy.
384
-
385
- ## Completion Checklist
386
-
387
- Before final response or handoff, agents should review their own file actions
388
- from the current task:
389
-
390
- 1. Did I create, copy, export, quarantine, back up, or preserve any non-source
391
- file or directory?
392
- 2. Will any of those paths outlive this command?
393
- 3. If yes, did I either register them with Artshelf or record a clear skip reason?
394
-
395
- Do not call work done while known eligible artifacts are neither registered nor
396
- 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.
@@ -0,0 +1,116 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "scope": {
4
+ "registryPath": "~/.artshelf/ledgers.json",
5
+ "ledgerCount": 3,
6
+ "health": "attention",
7
+ "registryHealth": "ok",
8
+ "affectedLedgers": [
9
+ {
10
+ "name": "example-project",
11
+ "ledgerPath": "/path/to/example-project/.artshelf/ledger.jsonl",
12
+ "validationStatus": "ok"
13
+ }
14
+ ]
15
+ },
16
+ "plans": [
17
+ {
18
+ "type": "cleanup",
19
+ "ledgerPath": "/path/to/example-project/.artshelf/ledger.jsonl",
20
+ "planId": "plan_20260606_120000_ab12",
21
+ "planPath": "/path/to/example-project/.artshelf/plans/plan_20260606_120000_ab12.json",
22
+ "approvalTarget": "approve artshelf cleanup ledger /path/to/example-project/.artshelf/ledger.jsonl plan plan_20260606_120000_ab12"
23
+ }
24
+ ],
25
+ "summary": {
26
+ "executable": 1,
27
+ "skipped": 2,
28
+ "refused": 0,
29
+ "manualReview": 1,
30
+ "missingPath": 1,
31
+ "trashed": 0
32
+ },
33
+ "decisionSummary": {
34
+ "readyForApproval": 2,
35
+ "needsReviewFirst": 1,
36
+ "blocked": 0
37
+ },
38
+ "decisionGroups": {
39
+ "readyForApproval": [
40
+ {
41
+ "label": "Clean up temp debug output",
42
+ "itemIds": ["shf_20260606_120000_ab12"],
43
+ "actionType": "cleanup",
44
+ "approvalTarget": "approve artshelf cleanup ledger /path/to/example-project/.artshelf/ledger.jsonl plan plan_20260606_120000_ab12",
45
+ "reason": "Disposable temp artifact has a reviewed cleanup plan.",
46
+ "nextStep": "Approve the exact cleanup plan to move the artifact into Artshelf trash."
47
+ },
48
+ {
49
+ "label": "Resolve missing report record",
50
+ "itemIds": ["shf_20260606_120500_cd34"],
51
+ "actionType": "resolve-missing",
52
+ "approvalTarget": "approve artshelf resolve missing ledger /path/to/example-project/.artshelf/ledger.jsonl ids shf_20260606_120500_cd34",
53
+ "reason": "The report path is already missing.",
54
+ "nextStep": "Approve the ledger-only resolve command after confirming the report is no longer needed."
55
+ }
56
+ ],
57
+ "needsReviewFirst": [
58
+ {
59
+ "label": "Inspect lifecycle smoke report",
60
+ "itemIds": ["shf_20260606_121000_ef56"],
61
+ "actionType": "inspect",
62
+ "approvalTarget": null,
63
+ "reason": "cleanup=review means the artifact should be inspected before closing.",
64
+ "nextStep": "Inspect the path, then choose keep, change retention, resolve, or clean up later."
65
+ }
66
+ ],
67
+ "blocked": []
68
+ },
69
+ "recommendation": "Approve the reviewed cleanup plan for the disposable temp directory, then resolve the missing record after confirming it is no longer needed.",
70
+ "items": [
71
+ {
72
+ "id": "shf_20260606_120000_ab12",
73
+ "path": "/tmp/example-debug-output",
74
+ "classification": "trash-safe",
75
+ "proposedAction": "execute reviewed cleanup plan",
76
+ "dueStatus": "due",
77
+ "reason": "temporary debug output retained for 3 days",
78
+ "note": "The path exists, cleanup=trash, and the dry-run plan moves it into Artshelf trash."
79
+ },
80
+ {
81
+ "id": "shf_20260606_120500_cd34",
82
+ "path": "/tmp/missing-report.json",
83
+ "classification": "resolve-candidate",
84
+ "proposedAction": "resolve ledger-only after confirmation",
85
+ "dueStatus": "missing-path",
86
+ "reason": "report path is already missing",
87
+ "note": "Resolution updates only the ledger and does not move or delete files."
88
+ },
89
+ {
90
+ "id": "shf_20260606_121000_ef56",
91
+ "path": "/tmp/lifecycle-smoke-report.json",
92
+ "classification": "needs-human-review",
93
+ "proposedAction": "inspect before choosing cleanup or retention",
94
+ "dueStatus": "manual-review",
95
+ "reason": "cleanup=review artifact retained for manual inspection",
96
+ "note": "No approval target is shown until the review decision is known."
97
+ }
98
+ ],
99
+ "alternatives": [
100
+ "keep the artifact and change retention",
101
+ "inspect the path before approving cleanup",
102
+ "regenerate the plan after edits",
103
+ "resolve missing records ledger-only"
104
+ ],
105
+ "safety": {
106
+ "dryRunOnly": true,
107
+ "executeAllRefused": true,
108
+ "noExecuteRan": true,
109
+ "noResolveRan": true,
110
+ "noDeleteRan": true
111
+ },
112
+ "verification": {
113
+ "command": "artshelf review --all --json",
114
+ "successCondition": "no due, manual-review, missing-path, executable, or refused entries remain unless explicitly reported"
115
+ }
116
+ }