@zinn-dev/cli 0.40.0 → 0.41.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.
Files changed (60) hide show
  1. package/README.md +166 -38
  2. package/index.js +24 -13
  3. package/package.json +7 -2
  4. package/skills/zinn/SKILL.md +63 -0
  5. package/src/actor.d.ts +2 -1
  6. package/src/actor.js +78 -11
  7. package/src/capabilities-schema.d.ts +163 -0
  8. package/src/capabilities-schema.js +124 -0
  9. package/src/capabilities.d.ts +21 -0
  10. package/src/capabilities.js +22 -0
  11. package/src/database.d.ts +1 -1
  12. package/src/database.js +4 -4
  13. package/src/errors.d.ts +158 -0
  14. package/src/errors.js +224 -0
  15. package/src/input.d.ts +116 -0
  16. package/src/input.js +119 -0
  17. package/src/lib.d.ts +42 -7
  18. package/src/lib.js +213 -17
  19. package/src/presentation/activity-presentation.js +16 -2
  20. package/src/presentation/column-presentation.d.ts +3 -5
  21. package/src/presentation/info-presentation.d.ts +4 -0
  22. package/src/presentation/info-presentation.js +96 -0
  23. package/src/presentation/task-presentation.d.ts +2 -10
  24. package/src/project.d.ts +6 -0
  25. package/src/project.js +23 -10
  26. package/src/result-schemas.d.ts +987 -0
  27. package/src/result-schemas.js +220 -0
  28. package/src/results.d.ts +23 -0
  29. package/src/results.js +17 -0
  30. package/src/routes/activity-router.d.ts +71 -0
  31. package/src/routes/activity-router.js +59 -11
  32. package/src/routes/backup-router.d.ts +17 -0
  33. package/src/routes/backup-router.js +15 -3
  34. package/src/routes/capabilities-router.d.ts +21 -0
  35. package/src/routes/capabilities-router.js +28 -0
  36. package/src/routes/comment-router.d.ts +183 -4
  37. package/src/routes/comment-router.js +136 -29
  38. package/src/routes/info-router.d.ts +21 -0
  39. package/src/routes/info-router.js +29 -0
  40. package/src/routes/label-router.d.ts +165 -0
  41. package/src/routes/label-router.js +111 -29
  42. package/src/routes/migrate-router.d.ts +17 -0
  43. package/src/routes/migrate-router.js +17 -5
  44. package/src/routes/project-router.d.ts +349 -0
  45. package/src/routes/project-router.js +278 -92
  46. package/src/routes/reindex-router.d.ts +17 -0
  47. package/src/routes/reindex-router.js +15 -3
  48. package/src/routes/relation-router.d.ts +108 -12
  49. package/src/routes/relation-router.js +74 -14
  50. package/src/routes/restore-router.d.ts +29 -0
  51. package/src/routes/restore-router.js +30 -13
  52. package/src/routes/router.d.ts +1 -1
  53. package/src/routes/router.js +44 -25
  54. package/src/routes/routes.d.ts +1565 -0
  55. package/src/routes/routes.js +5 -1
  56. package/src/routes/task-router.d.ts +861 -0
  57. package/src/routes/task-router.js +419 -163
  58. package/src/text-edit.d.ts +20 -2
  59. package/src/text-edit.js +22 -10
  60. package/src/types.d.ts +14 -0
package/README.md CHANGED
@@ -42,7 +42,7 @@ The files are plain JSON, without comments:
42
42
  }
43
43
  ```
44
44
 
45
- `$schema` is optional and lets editors handle autocomplete and check the file, but Zinn itself ignores it. New settings are added to the same number; only a change that would make existing files invalid gets a new number. An unknown key, a value of the wrong type or invalid JSON in a selected settings file stops every command with an error that names the file. Zinn _does not fall back to the defaults_.
45
+ `$schema` is optional and lets editors handle autocomplete and check the file, but Zinn itself ignores it. New settings are added to the same number and is bumped only when changes that would make existing files invalid. An unknown key, a value of the wrong type or invalid JSON in a selected settings file stops commands with an error that names the file, except for the inspection report below. Zinn _does not fall back to the defaults_.
46
46
 
47
47
  `storage.directory` names a Zinn directory with the same layout as `ZINN_DIR`: `data/zinn.sqlite` and `backups/`. The first of these that is set decides the directory: `ZINN_DIR`, `storage.directory` in `zinn.local.json`, `storage.directory` in the global `settings.json`, then `~/.zinn`. A relative path is relative to the folder of the file that sets it. A leading `~` or `~/` means your home folder.
48
48
 
@@ -52,6 +52,57 @@ Without a default, `task list` and `task search` cover every project, and the ot
52
52
 
53
53
  On `task list` and `task search`, `--all-projects` covers every project, overriding the default, and works with `--all` or `--archived`. It cannot be combined with a typed project key. Commands taking a task key use the project named by that key. Column creation, editing, and ordering require an explicit project key.
54
54
 
55
+ ### Inspection
56
+
57
+ ```sh
58
+ zinn info
59
+ zinn info --json
60
+ ```
61
+
62
+ `info` reports the selected store and database path, the settings files and their sources, the configured default project, the database schema state, and CLI, core and runtime versions. Local settings discovery stops at the nearest `zinn.local.json`. With `ZINN_DIR`, home and codebase settings are marked as not read.
63
+
64
+ An unusable settings file displays errors, and a missing store or database and database read errors are reported with exit code 0. Note that SQLite may perform normal file housekeeping and crash recovery when this command is called.
65
+
66
+ With `--json`, the report is one object that always has the same keys:
67
+
68
+ - `settingsFiles` lists each settings file with its `path`, its `source` (`env` for `ZINN_DIR/settings.json`, `global` or `local`) and its `state`: `found` (with the file's `settings`), `missing`, `error` (with an `error` string) or `not-read` (with `reason: "ZINN_DIR"`). With `ZINN_DIR`, the list holds `ZINN_DIR/settings.json` and the home and codebase files marked `not-read`.
69
+ - `storage` holds the store `directory`, its `source` (`env`, `local`, `global` or `default`), the `settingsPath` of the file that chose it (`null` for `env` and `default`), whether the directory `exists`, and an `error`.
70
+ - `defaultProject` holds the `key`, the `settingsPath` of the file that set it, and an `error`. `key` and `settingsPath` are `null` when no default is configured.
71
+ - `database` holds its `path`, its `state`, the schema `version` it has, and the `latestVersion` this CLI reaches. `state` is `absent` (no file), `empty` (a file with no tables), `unmarked` (tables but no schema version), `current`, `older` or `newer` (compared with `latestVersion`), or `unavailable`. `version` is `0` for `absent`, `empty` and `unmarked`.
72
+ - `versions` holds `cli`, `core` and `runtime` (`name` and `version`).
73
+
74
+ `unavailable` means the database could not be inspected: an unusable settings file left the store undecided (`path` and `version` are `null`), or the file could not be read as a database (`path` is set, `version` is `null`, and `error` says why). Every `error` is `null` when there is no problem. A settings file's error is carried on `storage`, `defaultProject` and `database` as well as on its `settingsFiles` entry, so the same string can appear on several fields. With `ZINN_DIR`, an unusable `ZINN_DIR/settings.json` sets only `defaultProject.error`, since the store is already chosen.
75
+
76
+ ```json
77
+ {
78
+ "settingsFiles": [
79
+ {
80
+ "path": "/home/me/.zinn/settings.json",
81
+ "source": "global",
82
+ "state": "found",
83
+ "settings": { "defaultProject": "DEMO" }
84
+ },
85
+ { "path": "/work/app/zinn.local.json", "source": "local", "state": "missing" }
86
+ ],
87
+ "storage": {
88
+ "directory": "/home/me/.zinn",
89
+ "source": "default",
90
+ "settingsPath": null,
91
+ "exists": true,
92
+ "error": null
93
+ },
94
+ "defaultProject": { "key": "DEMO", "settingsPath": "/home/me/.zinn/settings.json", "error": null },
95
+ "database": {
96
+ "path": "/home/me/.zinn/data/zinn.sqlite",
97
+ "state": "current",
98
+ "version": 2,
99
+ "latestVersion": 2,
100
+ "error": null
101
+ },
102
+ "versions": { "cli": "0.41.0", "core": "0.30.0", "runtime": { "name": "Node", "version": "22.0.0" } }
103
+ }
104
+ ```
105
+
55
106
  ## Editing conventions
56
107
 
57
108
  Edit commands change only the fields you supply, whereas omitted fields keep their current values. At least one edit field is required. After input normalization, a valid edit that leaves all values unchanged succeeds without writing changes, updating modification timestamps, or recording activity.
@@ -60,14 +111,14 @@ Move, order, archive, unarchive, and task-label attachment commands also succeed
60
111
 
61
112
  Names and titles are trimmed and cannot be blank or contain line breaks or control characters, such as tabs.
62
113
 
63
- Project, task, and label descriptions may contain multiple lines. Omitted descriptions on creation, empty strings, and whitespace-only strings are stored as `null`. Text containing a non-whitespace character is preserved exactly, including leading and trailing whitespace. Use `--description ""` on an edit to clear a description. JSON returns the full text or `null`.
114
+ Project, task, and label descriptions may contain multiple lines. Omitted descriptions on creation, empty strings, and whitespace-only strings are stored as `null`. Text containing a non-whitespace character is preserved exactly, including leading and trailing whitespace. Use `--description ''` on an edit to clear a description. JSON returns the full text or `null`.
64
115
 
65
116
  To change part of a description, or of a comment's text, `--append` and `--replacing` modify how `--description` (or `--text` on `task comment edit`) is applied to the stored text:
66
117
 
67
118
  ```sh
68
- zinn task edit MDR-1 --description "Bring waffles." --append
69
- zinn task edit MDR-1 --description "new sentence" --replacing "old sentence"
70
- zinn project edit MDR --description "database" --replacing "board" --all
119
+ zinn task edit MDR-1 --description 'Bring waffles.' --append
120
+ zinn task edit MDR-1 --description 'new sentence' --replacing 'old sentence'
121
+ zinn project edit MDR --description database --replacing board --all
71
122
  ```
72
123
 
73
124
  Flags:
@@ -84,7 +135,7 @@ An empty text with `--replacing` deletes the match. `--append` and `--replacing`
84
135
  A value that begins with a dash, such as a Markdown bullet, must be joined to its flag with `=`. Otherwise the command fails without changing anything:
85
136
 
86
137
  ```sh
87
- zinn task edit MDR-1 --description="- Bring waffles." --append
138
+ zinn task edit MDR-1 --description='- Bring waffles.' --append
88
139
  ```
89
140
 
90
141
  For multi-line text, such as Markdown, pass a heredoc with a quoted delimiter (`'EOF'`) in bash or zsh. The shell then passes `$`, backticks, quotes and leading dashes as written:
@@ -136,7 +187,7 @@ Commands on the same machine can share a database on a local filesystem. Zinn wa
136
187
  Create a project with a key and optionally provide a name and description:
137
188
 
138
189
  ```sh
139
- zinn project create MDR --name "Macrodata Refinement" --description "Refine macrodata"
190
+ zinn project create MDR --name 'Macrodata Refinement' --description 'Refine macrodata'
140
191
  ```
141
192
 
142
193
  Project keys are stored in uppercase. An omitted name defaults to the key.
@@ -162,9 +213,9 @@ zinn project column list MDR
162
213
  Edit a project:
163
214
 
164
215
  ```sh
165
- zinn project edit MDR --name "Macrodata Refinement (Morning Shift)"
166
- zinn project edit MDR --description "Meet the quarterly quota"
167
- zinn project edit MDR --description ""
216
+ zinn project edit MDR --name 'Macrodata Refinement (Morning Shift)'
217
+ zinn project edit MDR --description 'Meet the quarterly quota'
218
+ zinn project edit MDR --description ''
168
219
  ```
169
220
 
170
221
  Provide `--name`, `--description`, or both.
@@ -174,13 +225,13 @@ See [Text values](#text-values) for values that begin with a dash and multi-line
174
225
  Add another column at the end of the board:
175
226
 
176
227
  ```sh
177
- zinn project column create MDR "Boardlog"
228
+ zinn project column create MDR Boardlog
178
229
  ```
179
230
 
180
231
  Rename a column:
181
232
 
182
233
  ```sh
183
- zinn project column edit MDR "In Progress" --name "Refining"
234
+ zinn project column edit MDR 'In Progress' --name Refining
184
235
  ```
185
236
 
186
237
  Column names follow the shared [name and title rules](#editing-conventions) and match case-insensitively. Names must be unique within the project; changing only the casing is allowed. Renaming keeps tasks in the column.
@@ -192,7 +243,7 @@ zinn project column order MDR Review first
192
243
  zinn project column order MDR Review previous
193
244
  zinn project column order MDR Review next
194
245
  zinn project column order MDR Review last
195
- zinn project column order MDR Review before "In Progress"
246
+ zinn project column order MDR Review before 'In Progress'
196
247
  zinn project column order MDR Review after Done
197
248
  ```
198
249
 
@@ -206,8 +257,8 @@ Moving a column to the position it already has, or before or after itself, does
206
257
  Create a task with a title and an optional description. Titles follow the shared [name and title rules](#editing-conventions). New tasks enter the project's first column:
207
258
 
208
259
  ```sh
209
- zinn task create MDR --title "Refine 75% of the numbers"
210
- zinn task create MDR --title "Review the employee handbook" --description "Prepare for a 75% Dance Experience"
260
+ zinn task create MDR --title 'Refine 75% of the numbers'
261
+ zinn task create MDR --title 'Review the employee handbook' --description 'Prepare for a 75% Dance Experience'
211
262
  ```
212
263
 
213
264
  The project key can be omitted when [defaultProject](#settings-files) is configured.
@@ -215,7 +266,7 @@ The project key can be omitted when [defaultProject](#settings-files) is configu
215
266
  `--column <name>` starts the task at the bottom of a specific column. The column name matching is case insensitive:
216
267
 
217
268
  ```sh
218
- zinn task create MDR --title "Compile the Lexington letters" --column "In Progress"
269
+ zinn task create MDR --title 'Compile the Lexington letters' --column 'In Progress'
219
270
  ```
220
271
 
221
272
  Tasks are created with keys such as `MDR-1`. Task numbers increase in creation order within each project. List active tasks, optionally limited to one project, or view one task:
@@ -225,7 +276,7 @@ zinn task list
225
276
  zinn task list MDR
226
277
  zinn task list --all-projects
227
278
  zinn task list MDR --label CLI --label Groom
228
- zinn task list MDR --column "In Progress"
279
+ zinn task list MDR --column 'In Progress'
229
280
  zinn task list --column Done --all
230
281
  zinn task view MDR-1
231
282
  zinn task view MDR-1 --history
@@ -252,7 +303,7 @@ Search task titles, descriptions, and comments, optionally in one project:
252
303
  ```sh
253
304
  zinn task search refine
254
305
  zinn task search refine --all-projects
255
- zinn task search "quarterly quota" MDR
306
+ zinn task search 'quarterly quota' MDR
256
307
  zinn task search MDR-1
257
308
  zinn task search auth --all --limit 5
258
309
  zinn task search auth MDR --label cli
@@ -266,7 +317,7 @@ If the whole query is an existing task key, such as `mdr-1`, that task comes fir
266
317
 
267
318
  An exact task-key query overrides the configured default project. A project key supplied after the query still filters the search.
268
319
 
269
- Search defaults to active tasks. `--archived` searches archived tasks and `--all` searches both. A note on stderr reports hidden archived matches. This is purely a convenience hint and it is _omitted_ from JSON. `--limit <n>` caps the results.
320
+ Search defaults to active tasks. `--archived` searches archived tasks and `--all` searches both. A note on stderr reports hidden archived matches. `--limit <n>` caps the results.
270
321
 
271
322
  `--label` works as it does for `task list`: repeat it to require every specified label. Label filtering happens before `--limit` and before archived matches are counted.
272
323
 
@@ -285,7 +336,7 @@ Only the index changes, completely or not at all, so no backup is saved. With `-
285
336
  Labels are global and reusable across projects.
286
337
 
287
338
  ```sh
288
- zinn label create urgent --color red --description "Needs attention soon"
339
+ zinn label create urgent --color red --description 'Needs attention soon'
289
340
  zinn label create review
290
341
  zinn label edit review --name ready --color green
291
342
  zinn label list
@@ -294,13 +345,13 @@ zinn label list
294
345
  ### Adding to tasks
295
346
 
296
347
  ```sh
297
- zinn task create MDR --title "Check the numbers" --label urgent --label review
348
+ zinn task create MDR --title 'Check the numbers' --label urgent --label review
298
349
  zinn task label add MDR-1 urgent review
299
350
  zinn task label remove MDR-1 review
300
351
  zinn task edit MDR-1 --add-label review --remove-label urgent
301
352
  ```
302
353
 
303
- Repeat `--label`, `--add-label`, or `--remove-label` for several labels. Each value is one name, so commas are part of the name. Quote names containing spaces: `--label "needs review"`.
354
+ Repeat `--label`, `--add-label`, or `--remove-label` for several labels. Each value is one name, so commas are part of the name. Quote names containing spaces: `--label 'needs review'`.
304
355
 
305
356
  Label names follow the shared [name and title rules](#editing-conventions), preserve their stored casing, and match case-insensitively. Changing only the casing is allowed; names that differ only in case _cannot_ coexist.
306
357
 
@@ -332,6 +383,8 @@ zinn task relation list MDR-1
332
383
  Relations do not automatically move, complete, or archive tasks.
333
384
  Tasks from separate projects can be related to each other. Tasks can also be related to archived tasks.
334
385
 
386
+ JSON relation arrays from `task relation list` and `task view` are ordered by creation timestamp ascending, then relation ID ascending for ties.
387
+
335
388
  Use `zinn task relation create APP-2 APP-1 --type subtask` to make APP-2 a child of APP-1. Each task can have one parent and any number of subtasks, including nested subtasks.
336
389
 
337
390
  Remove the existing subtask relation before assigning a different parent. Moving or archiving a parent does not change its children, and deleting a parent removes its child relations while retaining child task data.
@@ -339,7 +392,7 @@ Remove the existing subtask relation before assigning a different parent. Moving
339
392
  `task create` can relate the new task with `--parent`, `--depends-on`, `--duplicate-of` and `--related`. Repeat `--depends-on` and `--related` to relate several tasks:
340
393
 
341
394
  ```sh
342
- zinn task create MDR --title "Sort the files" --parent MDR-1 --depends-on MDR-2
395
+ zinn task create MDR --title 'Sort the files' --parent MDR-1 --depends-on MDR-2
343
396
  ```
344
397
 
345
398
  Remove a relation with `zinn task relation delete MDR-1 MDR-2 --type dependency`, using its original direction for `dependency`, `duplicate`, and `subtask`. For `related`, order does not matter.
@@ -350,19 +403,22 @@ Relation deletion requires no confirmation.
350
403
  Add and list comments on a task:
351
404
 
352
405
  ```sh
353
- zinn task comment create MDR-1 --text "Ready for review"
406
+ zinn task comment create MDR-1 --text 'Ready for review'
354
407
  zinn task comment list MDR-1
355
408
  ```
356
409
 
357
410
  Comments receive keys per task like `MDR-1#1`.
358
411
 
359
- Edit or delete a comment using its key:
412
+ View, edit or delete a comment using its key:
360
413
 
361
414
  ```sh
362
- zinn task comment edit MDR-1#1 --text "Approved"
363
- zinn task comment delete MDR-1#1
415
+ zinn task comment view 'MDR-1#1'
416
+ zinn task comment edit 'MDR-1#1' --text Approved
417
+ zinn task comment delete 'MDR-1#1'
364
418
  ```
365
419
 
420
+ `task comment view` shows the current text in full, keeping its line breaks, including on archived tasks. With `--json`, it returns one object with `key`, `text`, `created_at` and `updated_at`.
421
+
366
422
  Deletion asks for confirmation, unless `--yes` is used (see [Confirmations](#confirmations)). Comments can be added to archived tasks. Comment mutations are recorded in the activity log without changing the task's modification timestamp.
367
423
 
368
424
  ## Edit tasks
@@ -370,9 +426,9 @@ Deletion asks for confirmation, unless `--yes` is used (see [Confirmations](#con
370
426
  Edit a task's title, description, priority, or labels:
371
427
 
372
428
  ```sh
373
- zinn task edit MDR-1 --title "Meet the quarterly refinement quota"
374
- zinn task edit MDR-1 --description "Complete refinement before the waffle party"
375
- zinn task edit MDR-1 --title "Meet the quarterly refinement quota" --description ""
429
+ zinn task edit MDR-1 --title 'Meet the quarterly refinement quota'
430
+ zinn task edit MDR-1 --description 'Complete refinement before the waffle party'
431
+ zinn task edit MDR-1 --title 'Meet the quarterly refinement quota' --description ''
376
432
  ```
377
433
 
378
434
  See [Editing conventions](#editing-conventions) for title validation, partial edits and clearing descriptions.
@@ -385,7 +441,7 @@ See [Text values](#text-values) for values that begin with a dash and multi-line
385
441
  Move a task to another column in its project:
386
442
 
387
443
  ```sh
388
- zinn task move MDR-1 "In Progress"
444
+ zinn task move MDR-1 'In Progress'
389
445
  ```
390
446
 
391
447
  A moved task appears at the bottom of its destination column. Moving it to its current column does nothing. Archived tasks must be unarchived before they can be moved.
@@ -393,7 +449,7 @@ A moved task appears at the bottom of its destination column. Moving it to its c
393
449
  For multiple tasks, give their keys before the column. They move in input order; tasks already in that column retain their positions. Each task's column is looked up in its own project:
394
450
 
395
451
  ```sh
396
- zinn task move MDR-1 MDR-2 APP-4 "In Progress"
452
+ zinn task move MDR-1 MDR-2 APP-4 'In Progress'
397
453
  ```
398
454
 
399
455
  See [Changing tasks in bulk](#changing-tasks-in-bulk).
@@ -439,10 +495,10 @@ Deleting a task does not make its number available again within that project. De
439
495
 
440
496
  ## Task priority
441
497
 
442
- Priority is optional: `low`, `medium`, `high`, or `urgent`. New tasks have no assigned priority by default.
498
+ Priority is optional: `low`, `medium`, `high`, or `urgent`. Priority values, including `none`, are case-insensitive. Stored values and JSON use lowercase. New tasks have no assigned priority by default.
443
499
 
444
500
  ```sh
445
- zinn task create MDR --title "Review the numbers" --priority high
501
+ zinn task create MDR --title 'Review the numbers' --priority high
446
502
  zinn task edit MDR-1 --priority urgent
447
503
  zinn task edit MDR-1 --priority none
448
504
  ```
@@ -459,6 +515,8 @@ Deleting a project records one project deletion rather than separate deletion ac
459
515
  zinn activity list
460
516
  zinn activity list --limit 10
461
517
  zinn activity list --task MDR-1
518
+ zinn activity list --session conversation-id
519
+ zinn activity list --session conversation-id --thread child-thread-id
462
520
  zinn activity view 019abcdf-1234-7
463
521
  ```
464
522
 
@@ -466,18 +524,28 @@ zinn activity view 019abcdf-1234-7
466
524
 
467
525
  `--task` includes active, archived, and deleted tasks by readable key, with history recovered from current tasks and recorded deletion snapshots. A reused key includes all known task lifetimes. A project deletion that removed the task is included as the original project event. A valid key with no recoverable history returns an empty list.
468
526
 
527
+ `--session` and `--thread` match the complete stored IDs exactly, including case and whitespace. All supplied filters must match, and `--limit` applies after filtering. Rows without the requested identity do not match. No matches return empty output, or `[]` with `--json`, and exit successfully. Session activity records committed changes.
528
+
469
529
  `activity view` accepts a full UUID or a unique prefix of at least eight hexadecimal digits for convenience. The match ignores case and accepts both the full hyphenated or compact forms. Prefixes must be unique across all activity. Use a full ID for reliable reference results. Using prefixes may result in unreliable results over time as history grows.
470
530
 
471
531
  `activity view` preserves full recorded text and line breaks, including unknown change fields.
472
532
 
473
- With `--json`, list returns an array and view returns one event object. Both include `id`, `created_at` (epoch milliseconds), `actor_name`, `actor_email`, `actor_kind`, `entity_type`, `entity_id`, `action`, and `changes` (parsed JSON or `null`). Payloads and IDs are preserved in full, including after deletion.
533
+ With `--json`, list returns an array and view returns one event object. Both include `id`, `created_at` (epoch milliseconds), `actor_name`, `actor_email`, `actor_kind`, `actor_source`, `actor_session_id`, `actor_thread_id`, `actor_agent`, `actor_model`, `actor_effort`, `entity_type`, `entity_id`, `action`, and `changes` (parsed JSON or `null`). `actor_name` can be `null` for an unnamed agent. The six additional actor fields are `null` when absent, including on events recorded before schema version 2. Payloads and IDs are preserved in full, including after deletion.
474
534
 
475
535
  > [!WARNING]
476
536
  > A readable task key can identify different tasks after a project is deleted and recreated. Group JSON records by (`entity_type`, `entity_id`) to keep their histories distinct. The `id` identifies the activity event itself. Project deletion events keep the project's `entity_id`, with removed task IDs in `changes.tasks`.
477
537
 
478
538
  When a coding agent performs a mutation with `zinn`, the change is recorded under that agent's name.
479
539
 
480
- Zinn recognizes Claude Code, Codex, OpenCode, Gemini CLI, Cline, Cursor, Copilot's coding agent, Crush, Amp, and any tool that sets `AI_AGENT`. If you are using a tool that Zinn does not recognize, you can set `AI_AGENT` in that tool's environment settings, for example `AI_AGENT=hermes`. Otherwise, Zinn uses your git `user.name` and `user.email`, and if that's also not set, it falls to your system username.
540
+ Zinn recognizes Claude Code, Codex, OpenCode, Gemini CLI, Cline, Cursor, Copilot's coding agent, Crush, Amp, and any tool that sets `AI_AGENT`.
541
+
542
+ It checks `AI_AGENT`, then `AGENT`, then tool markers, taking the first identifying value. You can declare a name through that tool's environment settings, for example `AI_AGENT=hermes`.
543
+
544
+ With no marker, Zinn uses your git `user.name` and `user.email`, then your system username. `actor_source` records the deciding `env:<VARIABLE>`, `git-config` or `os-user`.
545
+
546
+ Integrations can supply `ZINN_SESSION_ID` for the top-level conversation and `ZINN_THREAD_ID` for the execution thread running the command. When either is provided, Zinn uses that pair. Otherwise it uses the first available _native_ pair: `CLAUDE_CODE_SESSION_ID` with a `null` thread, then `CODEX_SESSION_ID` and `CODEX_THREAD_ID`, then OpenCode's `OPENCODE_SESSION_ID` as the thread with a `null` session. If a member is missing, it stays `null` because Zinn never combines pairs. Inherited IDs associate the command with their declared conversation or thread.
547
+
548
+ `ZINN_AGENT`, `ZINN_MODEL` and `ZINN_EFFORT` declare the host agent name, running model and effort for the execution making the change. Zinn trims surrounding whitespace, treats blank declarations as _unset_ and preserves other text. These values are declarations rather than authenticated identities. New changes retain them in activity JSON and earlier events keep their recorded attribution.
481
549
 
482
550
  ## Back up the database
483
551
 
@@ -537,15 +605,75 @@ Add `--json` to any command to get JSON instead of text. The flag can go anywher
537
605
 
538
606
  ```sh
539
607
  zinn task list MDR --json
540
- zinn task create MDR --title "Refine the numbers" --json
608
+ zinn task create MDR --title 'Refine the numbers' --json
541
609
  ```
542
610
 
543
611
  - Read commands print what they list or show. Write commands print the entity they created, changed, or deleted.
544
612
  - Output is a single JSON document on stdout. Empty lists print `[]`.
545
- - Errors go to stderr as `{ "error": { "message": "..." } }`, stdout stays empty, and the command exits with code 1. An error can also carry `"help"`: the command's usage line for a missing or extra word, or the namespace help for a missing command.
613
+ - Handled errors go to stderr as one JSON document, stdout stays empty, and the command exits with code 1: `{ "error": { "code": "not_found", "message": "...", "details": { "entity": "task", "key": "MDR-999", "source": "explicit" } } }`.
614
+ - `error.code` is `invalid_input` for invalid invocation or settings, `not_found` for an absent required entity or requested file, `conflict` for a request blocked by current state or database compatibility, `storage` for filesystem or SQLite operational failures, and `internal` for an unexpected failure.
615
+ - Optional `error.details` carries known facts: `argument`, `field` (a string/number path), `entity`, `key`, `source` (`explicit` or `defaultProject`), `settingsPath`, `reason`, `matchCount`, `candidateIds`, `path`, `databasePath`, `backupDirectory`, `backupPath`, `schemaVersion`, `supportedSchemaVersion`, and `cause` (`message` and optional native `code`/`errcode`). Unknown facts are omitted.
616
+ - Optional `error.help` retains usage guidance. Prior notices are collected in optional `error.diagnostics`, an array of strings. On success, notices print as text on stderr after the command completes. Text-mode notices print immediately. This includes lock waits; JSON commands report their wait only at completion.
617
+
618
+ Check the exit status before parsing stdout for success or stderr for failure. Message, help and diagnostic wording is for people; scripts use the code and details. Signals, runtime loading failures and broken output channels are outside this handled-error contract.
546
619
 
547
620
  Scripts should use `--json`. Text is colored only in a terminal unless `NO_COLOR` disables it. `FORCE_COLOR` overrides both: `0` turns color off and any other nonempty value turns it on, including when piped.
548
621
 
622
+ `ZINN_DEBUG=1` prints routing details on stderr. Other values do nothing. Stdout, including `--json` output, is unchanged.
623
+
624
+ ### Command discovery
625
+
626
+ ```sh
627
+ zinn capabilities --json
628
+ ```
629
+
630
+ `capabilities` describes the installed CLI without reading settings, opening a database, prompting, or using the network. It works with missing stores and invalid settings. Without `--json`, it prints a compact summary and the full-contract command.
631
+
632
+ The JSON document contains `manifestVersion`, `cli` (package `name` and `version`), `invocation`, `commands`, `error`, and `schemas`. Commands follow route order and include capabilities itself. Each command has a token-array `path`, `summary`, `input`, `effects`, `confirmation`, and finite `results`.
633
+
634
+ - `input.options` is keyed by option name. Each option declares its `type`; omitted `required` and `multiple` mean false. String values can carry named placeholders, choices, patterns and descriptions. Positional `forms` declare ordered names, minimum and maximum occurrences (`null` means no upper bound), and value facts. Choose the form that matches the supplied values. `constraints` describes mutual exclusion, requirements and requests needing at least one input. Optional `notes` explain resolver and domain behavior.
635
+ - `invocation` describes router options, help/version precedence and literal values. Build argv from the command path, command options (`--name=value` for strings), `--json`, then `--` and the positional words. Repeat an option only when `multiple` is true. Tokens after `--` are literal words.
636
+ - `results` selects a JSON success schema: `always`, `booleanOption` (an absent boolean is false), or `positionalCount` (inclusive bounds, counting supplied occurrences, including repeated keys). Each result declares its `mode`, `stream` and `exitCode`.
637
+ - A descriptor's `schemaRef`, such as `#/schemas/definitions/TaskList`, resolves against the whole manifest. JSON Schema `$ref` values resolve against the extracted `schemas` document, which uses draft-07. All references are local. The finite `Capabilities` definition describes the manifest without embedding another manifest value.
638
+ - `effects.domain` describes the domain operation. `effects.storage: "normal-open"` can create or upgrade storage under the normal open policy, including for reads. `"none"` performs no storage access. Administrative commands declare their own storage operation. `confirmation` describes the existing prompt and project-deletion rules; see [Confirmations](#confirmations).
639
+
640
+ Check the process exit status before selecting a stream. Successful JSON goes to stdout, and notices may appear as text on stderr. A handled failure exits `1` and emits one error document on stderr, described by root `error.schemaRef`, with no success stdout.
641
+
642
+ See [Scripting and JSON output](#scripting-and-json-output) for error codes, details and exceptions. Help remains text even with `--json`.
643
+
644
+ For example, this Node.js consumer discovers task-list syntax and its result reference, then lists a project in the selected store:
645
+
646
+ ```js
647
+ import { spawnSync } from "node:child_process";
648
+
649
+ function json(args) {
650
+ const result = spawnSync("zinn", args, { encoding: "utf8" });
651
+ if (result.error) {
652
+ throw result.error;
653
+ }
654
+
655
+ if (result.status !== 0) {
656
+ throw new Error(result.stderr);
657
+ }
658
+
659
+ return JSON.parse(result.stdout);
660
+ }
661
+
662
+ const manifest = json(["capabilities", "--json"]);
663
+ const command = manifest.commands.find(({ path }) => path.join(" ") === "task list");
664
+ const form = command.input.forms[0];
665
+ const values = { "project-key": "APP" };
666
+ const words = form.positionals.flatMap(({ name }) => (values[name] === undefined ? [] : [values[name]]));
667
+ const tasks = json([...command.path, "--json", manifest.invocation.optionSeparator, ...words]);
668
+ const result = command.results.find(({ selector }) => selector.kind === "always");
669
+
670
+ console.log({ schemaRef: result.schemaRef, tasks });
671
+ ```
672
+
673
+ Use a JSON Schema validator with `manifest.schemas` to validate successful values against the selected definition. Task lists are arrays, including `[]`. Task details are objects. History selects a detail schema with a required `activity` array. Single and bulk mutations can select different schemas, so select the result before validating it.
674
+
675
+ The CLI release version identifies the command contract. `manifestVersion: 1` identifies how to interpret descriptors and changes only when that interpretation becomes incompatible; it is separate from database and settings versions. Mutable `-dev` builds can change their contract without changing their version, so use the emitted content rather than the version alone as a cache key.
676
+
549
677
  ### Confirmations
550
678
 
551
679
  Project, task, label, and comment deletion ask for confirmation, as does restoring the database. Use `--yes` to skip the prompt:
package/index.js CHANGED
@@ -1,23 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
  import packageJson from "./package.json" with { type: "json" };
3
+ import { versionSpellings } from "./src/input.js";
3
4
  const args = process.argv.slice(2);
4
- const isVersionRequest = args.length === 1 && ["-v", "--version"].includes(args[0]);
5
+ const isVersionRequest = args.length === 1 && versionSpellings.includes(args[0]);
5
6
  if (isVersionRequest) {
6
7
  console.info(packageJson.version);
7
8
  }
8
9
  else {
9
- const { isHelpFlag } = await import("./src/lib.js");
10
- const { createRouter } = await import("./src/routes/router.js");
11
- const { routes } = await import("./src/routes/routes.js");
12
- const router = createRouter(routes);
13
- if (args.length === 0 || isHelpFlag(args[0])) {
14
- console.info(router.help);
10
+ const { isHelpFlag, prepareOutput, flushDiagnostics, renderFailure } = await import("./src/lib.js");
11
+ prepareOutput(args);
12
+ try {
13
+ const { createRouter } = await import("./src/routes/router.js");
14
+ const { routes } = await import("./src/routes/routes.js");
15
+ const router = createRouter(routes, async (command) => {
16
+ if (command.effects.storage === "none") {
17
+ return;
18
+ }
19
+ const { configureDatabase } = await import("@zinn-dev/core");
20
+ const { getCliOpenPolicy } = await import("./src/database.js");
21
+ configureDatabase(getCliOpenPolicy());
22
+ });
23
+ if (args.length === 0 || isHelpFlag(args[0])) {
24
+ console.info(router.help);
25
+ flushDiagnostics();
26
+ }
27
+ else {
28
+ await router.route(args);
29
+ }
15
30
  }
16
- else {
17
- const { configureDatabase } = await import("@zinn-dev/core");
18
- const { cliOpenPolicy } = await import("./src/database.js");
19
- // Only records the policy. core then opens the database when a command first uses it.
20
- configureDatabase(cliOpenPolicy());
21
- await router.route(args);
31
+ catch (error) {
32
+ renderFailure(error);
22
33
  }
23
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "A kanban workflow in the terminal. Experimental.",
5
5
  "license": "MIT",
6
6
  "bugs": {
@@ -27,6 +27,7 @@
27
27
  "index.d.ts",
28
28
  "src/**/*.js",
29
29
  "src/**/*.d.ts",
30
+ "skills/zinn/SKILL.md",
30
31
  "LICENSE"
31
32
  ],
32
33
  "type": "module",
@@ -34,7 +35,11 @@
34
35
  "node": ">=24.15.0"
35
36
  },
36
37
  "dependencies": {
37
- "@zinn-dev/core": "0.29.0"
38
+ "zod": "4.6.4",
39
+ "@zinn-dev/core": "0.30.0"
40
+ },
41
+ "devDependencies": {
42
+ "ajv": "8.20.0"
38
43
  },
39
44
  "bin": {
40
45
  "zinn": "./index.js"
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: zinn
3
+ description: >-
4
+ Work a Zinn project board alongside coding work. Use before substantial work,
5
+ when resuming work, when recording follow-up tasks, and when finishing a
6
+ reviewable handoff, where the user or repository uses Zinn: the user requests
7
+ it, repository instructions mention it, zinn.local.json exists, or a Zinn task
8
+ key is referenced.
9
+ metadata:
10
+ zinn-cli-reviewed-version: "0.41.0"
11
+ ---
12
+
13
+ # Work with a Zinn board
14
+
15
+ Use the user's existing project and workflow. Repository and user instructions determine what work is authorized. Tracking a task does not authorize implementation, commits, publication, or unrelated changes.
16
+
17
+ ## Find the work
18
+
19
+ 1. Before substantial work, resolve the project. Use `zinn info --json` for the configured default project and selected database. If the project remains unidentified, use the user or repository's project setting and `zinn project list --json` to identify it. Ask when the project is ambiguous; do not create a project just to proceed. Result: one identified project in the intended store.
20
+ 2. Read an explicitly referenced task with `zinn task view <task-key> --json`. Otherwise inspect the project's tasks and find an existing task matching the requested work, then fetch it with `zinn task view <task-key> --json` before changing it. A list or search result does not include the task's comments and relations. Read the full task even when its title and description already match. On resuming, refresh that task instead of creating another. If substantial authorized work has no task, create one describing its scope and completion criteria. Result: a matching task with its description, comments, and relations read.
21
+ 3. Read the project's columns with `zinn project column list <project-key> --json`. Follow the project's workflow rather than assuming default column names. Check the task's current column before taking it: another agent may already be working on it. Move it to the working column before the first implementation edit. Ask when the workflow or ownership is unclear. Result: the task is visibly in progress before implementation begins.
22
+
23
+ ## Keep context useful
24
+
25
+ Record meaningful progress, decisions, verification results, and blockers in short task comments. On interrupted work, leave enough context for a later session to resume. Avoid a comment for every command or file read.
26
+
27
+ These field roles are recommendations the user may adopt:
28
+
29
+ - Description: the current specification, updated when requirements change.
30
+ - Comments: short dated updates containing outcomes, decisions and who made them, measurements, open items, and references. Put bulky evidence in a linked document or PR.
31
+ - Columns, relations, and labels: status and structure, rather than repeating that metadata in prose.
32
+
33
+ When follow-up work appears, search for an existing task before creating one. Record a new task's problem and scope, and link it to the current work. A dependency points from the task that needs something to the task it needs; use a related relation when neither must precede the other. Recording follow-up work does not authorize doing it now. Result: follow-up work has a task and a useful link.
34
+
35
+ ## Finish or hand off
36
+
37
+ When implementation and appropriate verification are complete, add a concise outcome comment with checks and any remaining limitations, move the task to the project's review column, and report its key with the reviewable result. Follow explicit user or repository completion rules when they differ. If work remains incomplete or blocked, record that state and the next step rather than moving it to review. Result: the board and final report agree about what is ready.
38
+
39
+ ## Use the installed CLI
40
+
41
+ Discover exact commands and flags with `zinn --help` and `zinn <command> --help`. Follow the installed help if it differs from this skill; the skill and CLI can be updated separately. Use `--json` when consuming results programmatically. Check command exit status: errors go to stderr, and empty stdout from a failed command is not an empty successful result.
42
+
43
+ If a command or option required by this skill is unavailable, or installed help or command results contradict these instructions, check both the CLI and this skill for drift. Do this once per session, and repeat only if either installation changes. Ordinary input, missing-item, permission, and database errors do not trigger this check.
44
+
45
+ Compare `zinn --version` with the latest published `@zinn-dev/cli` version in the npm registry, and compare the skill file loaded by this session with its installation source, respecting any pinned revision. The unpinned source is [Zinn's workflow skill](https://github.com/yethranayeh/zinn/blob/main/packages/cli/skills/zinn/SKILL.md). Use read-only metadata and file reads. A newer release or changed skill is evidence of a difference, not proof that it caused the problem. Report relevant differences or checks you could not complete. If the intended operation remains unclear, ask before proceeding. Update either installation only when authorized; after updating the skill, reload it or use a fresh session.
46
+
47
+ `ZINN_AGENT`, `ZINN_MODEL`, and `ZINN_EFFORT` can declare the agent, model, and effort of the execution making a change when automatic detection or host integration does not provide them. Use only known values; leave unknown values unset.
48
+
49
+ Checking and moving a task is not an atomic claim. Coordinate parallel work with the user or host; task coordination does not isolate a shared working tree.
50
+
51
+ For example, substitute the actual project, task, and observed column names:
52
+
53
+ ```sh
54
+ zinn --help
55
+ zinn info --json
56
+ zinn project list --json
57
+ zinn task list APP --json
58
+ zinn task view APP-1 --json
59
+ zinn project column list APP --json
60
+ zinn task move APP-1 'In Progress' --json
61
+ zinn task comment create APP-1 --text 'Implementation verified; ready for review.' --json
62
+ zinn task move APP-1 Review --json
63
+ ```
package/src/actor.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Actor } from "@zinn-dev/core";
2
2
  type Env = Record<string, string | undefined>;
3
- /** A marker without a fixed name records the variable's own value, e.g. `AI_AGENT=claude-code_2-1-280_agent`. */
3
+ /** Generic flags establish an unnamed agent only when no identifying marker follows. */
4
4
  export declare function detectAgent(env: Env): Actor | null;
5
+ export declare function resolveActor(env: Env): Actor;
5
6
  export declare function currentActor(): Actor;
6
7
  export {};