@roodriigoooo/pi-docket 0.4.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 (43) hide show
  1. package/CHANGELOG.md +132 -0
  2. package/LICENSE +21 -0
  3. package/README.md +241 -0
  4. package/assets/docket_logo.jpeg +0 -0
  5. package/docs/adr/0001-bundle-first-checkpoints.md +21 -0
  6. package/docs/adr/0002-rename-to-docket.md +44 -0
  7. package/docs/architecture.md +101 -0
  8. package/docs/bundle-guidelines.md +39 -0
  9. package/docs/configuration.md +191 -0
  10. package/docs/releases/0.4.0.md +93 -0
  11. package/extensions/artifact-catalog.ts +467 -0
  12. package/extensions/background-work.ts +510 -0
  13. package/extensions/checkpoint-commands.ts +147 -0
  14. package/extensions/checkpoint-lifecycle.ts +195 -0
  15. package/extensions/checkpoint-selector.ts +162 -0
  16. package/extensions/checkpoint-store.ts +230 -0
  17. package/extensions/checkpoint-summarizer.ts +141 -0
  18. package/extensions/docket-command-grammar.ts +319 -0
  19. package/extensions/docket-command-router.ts +626 -0
  20. package/extensions/docket-config.ts +88 -0
  21. package/extensions/docket-extension-surface.ts +43 -0
  22. package/extensions/docket-navigator.ts +585 -0
  23. package/extensions/docket.README.md +46 -0
  24. package/extensions/docket.ts +2965 -0
  25. package/extensions/event-log.ts +121 -0
  26. package/extensions/git-context.ts +44 -0
  27. package/extensions/loaded-artifact-context.ts +228 -0
  28. package/extensions/search-index.ts +140 -0
  29. package/extensions/types.ts +40 -0
  30. package/extensions/worker-activity.ts +402 -0
  31. package/extensions/worker-changes.ts +180 -0
  32. package/extensions/worker-commands.ts +251 -0
  33. package/extensions/worker-dock-cache.ts +147 -0
  34. package/extensions/worker-events.ts +87 -0
  35. package/extensions/worker-eviction.ts +55 -0
  36. package/extensions/worker-guardrails.md +125 -0
  37. package/extensions/worker-kinds/patcher.md +23 -0
  38. package/extensions/worker-kinds/scout.md +17 -0
  39. package/extensions/worker-kinds.ts +280 -0
  40. package/extensions/worker-result.ts +193 -0
  41. package/extensions/worker-store.ts +621 -0
  42. package/extensions/worker-summary-embed.ts +98 -0
  43. package/package.json +53 -0
@@ -0,0 +1,191 @@
1
+ # Configuration
2
+
3
+ Docket reads two files and merges them, project overriding global:
4
+
5
+ 1. `~/.pi/agent/docket.json` — global
6
+ 2. `<project>/.pi/docket.json` — project
7
+
8
+ Both optional. Defaults below.
9
+
10
+ ## Realistic example
11
+
12
+ ```json
13
+ {
14
+ "maxArtifacts": 300,
15
+ "maxBodyChars": 6000,
16
+ "checkpointArtifacts": 24,
17
+ "consumedRetentionDays": 7,
18
+
19
+ "summarizer": {
20
+ "enabled": true,
21
+ "provider": "openai",
22
+ "model": "gpt-5.2",
23
+ "maxOutputTokens": 1200,
24
+ "maxInputChars": 36000,
25
+ "timeoutMs": 120000
26
+ },
27
+
28
+ "worker": {
29
+ "maxActive": 8,
30
+ "maxSpawnDepth": 2,
31
+ "defaultKind": "default",
32
+ "dockIdleHideMinutes": 30,
33
+ "pruneAfterHours": 24,
34
+ "tmuxStatusLine": false,
35
+ "captureTerminal": false,
36
+ "guardrailsPath": "~/.pi/agent/docket/my-worker-rules.md"
37
+ }
38
+ }
39
+ ```
40
+
41
+ ## Core artifact + bundle knobs
42
+
43
+ | key | default | meaning |
44
+ |---|---|---|
45
+ | `maxArtifacts` | 300 | hard cap on artifacts kept per session. older entries fall off. |
46
+ | `maxBodyChars` | 6000 | truncate any single artifact body to this many chars before storing. |
47
+ | `checkpointArtifacts` | 24 | initial artifact pool a saved bundle considers before user prune. Internal key name kept for storage compatibility. |
48
+ | `consumedRetentionDays` | 7 | how long `--once` bundles stay on disk after first use. |
49
+
50
+ ## Summarizer (opt-in)
51
+
52
+ Evidence bundles are bundle-first: by default `/docket save` writes a deterministic orientation header and never calls a model ([ADR-0001](./adr/0001-bundle-first-checkpoints.md)). The summarizer only runs when you pass `--summarize`; these keys tune it when you do.
53
+
54
+ | key | default | meaning |
55
+ |---|---|---|
56
+ | `summarizer.enabled` | true | when false, `--summarize` is ignored and the bundle header is always used. |
57
+ | `summarizer.provider` | — | provider id (`openai`, `anthropic`, …). inferred from `model` when omitted. |
58
+ | `summarizer.model` | active session model | provider/model string used for summarization. |
59
+ | `summarizer.maxOutputTokens` | 1200 | cap summary length. |
60
+ | `summarizer.maxInputChars` | 36000 | cap input fed into summarizer. |
61
+ | `summarizer.timeoutMs` | 120000 | abort summarization after this many ms; fall back to the bundle header. |
62
+
63
+ `/docket save --model <provider/model>` and `--max-output <tokens>` override per call.
64
+
65
+ ## Worker fleet
66
+
67
+ | key | default | meaning |
68
+ |---|---|---|
69
+ | `worker.maxActive` | 8 | reject `/docket spawn` once this many workers are starting/active/idle/needs_input. |
70
+ | `worker.maxSpawnDepth` | 2 | bound `docket_spawn_child` recursion (top-level worker = depth 0). |
71
+ | `worker.defaultKind` | `default` | kind used when `/docket spawn` is invoked without `--as`. |
72
+ | `worker.dockIdleHideMinutes` | 30 | hide `ended` workers from the dock after this many minutes; 0 keeps them. |
73
+ | `worker.pruneAfterHours` | 24 | auto-prune `ended` worker dirs after this many hours; 0 disables. |
74
+ | `worker.tmuxStatusLine` | false | write a compact summary to `docket-workers`' `status-right`. |
75
+ | `worker.captureTerminal` | false | enable `tmux pipe-pane` to `<worker-dir>/pane.log` per worker. |
76
+ | `worker.autoRespawn` | false | reserved; today `/docket respawn` is manual. |
77
+ | `worker.autoEmbedSummary` | true | when a worker reaches `ready`, append a short summary (outcome + 1-line summary + up to 5 recommended bullets) to the parent session. Set false to keep the parent JSONL purely manual — the inbox card still shows up; nothing is auto-injected. |
78
+ | `worker.guardrailsPath` | bundled | absolute or cwd-relative path to a guardrail file appended to every worker prompt. |
79
+
80
+ `worker.guardrailsPath` replaces `extensions/worker-guardrails.md` from this package. Use it to pin team-wide policies into every worker.
81
+
82
+ ## Worker kinds
83
+
84
+ A *kind* is a markdown file with YAML frontmatter. Drop into either:
85
+
86
+ - `~/.pi/agent/docket/worker-kinds/*.md` — user-global
87
+ - `<project>/.pi/docket/worker-kinds/*.md` — project-scoped
88
+
89
+ Bundled kinds (`default`, `scout`, `patcher`) live in `extensions/worker-kinds/` and reload on every command.
90
+
91
+ ### Frontmatter fields
92
+
93
+ | field | default | meaning |
94
+ |---|---|---|
95
+ | `name` | — | required; kebab-case slug used by `--as` |
96
+ | `description` | — | one-line shown in `/docket kinds` |
97
+ | `model` | parent | optional model override (`provider/model` string) |
98
+ | `thinking` | `medium` | `off` / `low` / `medium` / `high` |
99
+ | `read_only` | false | when true, appendix tells the worker not to edit files |
100
+ | `default_worktree` | true | spawn this kind in a detached worktree by default |
101
+ | `parent_seed` | `full` | `full` to seed parent session JSONL; `none` for a fresh worker |
102
+ | `max_artifacts` | — | soft cap surfaced as guidance; not enforced |
103
+ | `max_duration_sec` | — | soft cap surfaced as guidance |
104
+ | `can_spawn` | none | comma-list of kinds this worker may dispatch via `docket_spawn_child` |
105
+ | `layout` | `single` | `split-events` opens a right pane with `tail -F events.ndjson` |
106
+ | `guardrails_append` | — | extra guardrail lines folded into the kind appendix |
107
+
108
+ The MD body is appended to the universal guardrails — it never replaces them. The protocol contract (`docket_wait`/`docket_done`/`docket_fail`/`docket_todos`) is the same for every kind.
109
+
110
+ ### Example: a `reviewer` kind
111
+
112
+ `~/.pi/agent/docket/worker-kinds/reviewer.md`:
113
+
114
+ ```markdown
115
+ ---
116
+ name: reviewer
117
+ description: Read-only diff review against HEAD.
118
+ read_only: true
119
+ default_worktree: false
120
+ parent_seed: full
121
+ max_duration_sec: 180
122
+ thinking: high
123
+ ---
124
+
125
+ You are a code reviewer. Read the diff vs HEAD, then call `docket_done` with:
126
+ - `outcome: findings` (or `no_evidence` when the diff is clean)
127
+ - `summary`: one sentence on what changed and overall risk
128
+ - `evidence`: file:line refs for each concrete finding
129
+ - `recommended`: ordered action bullets for the parent
130
+ ```
131
+
132
+ Spawn it:
133
+
134
+ ```bash
135
+ /docket spawn --as reviewer audit the diff for missing error handling
136
+ ```
137
+
138
+ ### Example: a model + child spawn override
139
+
140
+ `<project>/.pi/docket/worker-kinds/architect.md`:
141
+
142
+ ```markdown
143
+ ---
144
+ name: architect
145
+ description: Plans a multi-file change. Can dispatch scout children for context.
146
+ model: anthropic/claude-opus-4-7
147
+ thinking: high
148
+ read_only: true
149
+ default_worktree: false
150
+ can_spawn: scout
151
+ layout: split-events
152
+ ---
153
+
154
+ You are an architect. Produce an ordered plan: what to change, in which order,
155
+ and which files each step touches. Use `docket_spawn_child` with `--as scout`
156
+ when you need to ground a step in real code instead of guessing.
157
+ ```
158
+
159
+ ### Runtime registration
160
+
161
+ Other pi extensions can contribute kinds at runtime:
162
+
163
+ ```ts
164
+ globalThis.__docket?.registerWorkerKind({
165
+ name: "linkcheck",
166
+ description: "Verify external links in markdown",
167
+ readOnly: true,
168
+ defaultWorktree: false,
169
+ body: "You verify HTTP links in *.md and report broken ones …",
170
+ });
171
+ ```
172
+
173
+ See [architecture.md](./architecture.md) for the full extension surface.
174
+
175
+ ## Storage paths
176
+
177
+ Bundle state:
178
+
179
+ - `~/.pi/agent/docket/checkpoints/<id>.md`
180
+ - `~/.pi/agent/docket/checkpoints/<id>.artifacts.json`
181
+ - `~/.pi/agent/docket/events.ndjson`
182
+ - `~/.pi/agent/docket/index.json` (compatibility snapshot)
183
+
184
+ Worker state:
185
+
186
+ - `~/.pi/agent/docket/workers/<id>/task.md`
187
+ - `~/.pi/agent/docket/workers/<id>/status.json`
188
+ - `~/.pi/agent/docket/workers/<id>/artifacts.json`
189
+ - `~/.pi/agent/docket/workers/<id>/events.ndjson`
190
+ - `~/.pi/agent/docket/workers/<id>/session/` — seeded pi session JSONL
191
+ - `~/.pi/agent/docket/workers/<id>/workspace/` — detached git worktree
@@ -0,0 +1,93 @@
1
+ # pi-docket v0.4.0
2
+
3
+ This is a breaking rename from **Trail** to **Docket**.
4
+
5
+ ## Why rename?
6
+
7
+ Trail sounded like a history log or session-resume system. That framing was wrong for the product direction.
8
+
9
+ Docket is a **decision queue for Pi agent work**:
10
+
11
+ - a worker finding becomes a case,
12
+ - a failed command becomes a case,
13
+ - a proposed patch becomes a case,
14
+ - a saved evidence bundle becomes a case file,
15
+ - the human remains judge.
16
+
17
+ Pi already has strong session tools: `/tree`, `/fork`, `/clone`, `/compact`, `/new`, and `/resume`. Docket now treats those as Pi's domain. Docket's domain is attention, evidence, and worker-parent coordination.
18
+
19
+ ## Breaking changes
20
+
21
+ - Package renamed to `@roodriigoooo/pi-docket`.
22
+ - GitHub repo title should be `pi-docket`.
23
+ - Slash command changed from `/trail` to `/docket`.
24
+ - Old `/trail` commands are not kept as aliases.
25
+ - `/docket checkpoint`, `/docket continue`, `/docket resume`, and short aliases are removed from the public grammar.
26
+ - Evidence preservation is now `/docket save` + `/docket load`.
27
+ - Worker protocol tools are now:
28
+ - `docket_todos`
29
+ - `docket_wait`
30
+ - `docket_done`
31
+ - `docket_fail`
32
+ - `docket_spawn_child`
33
+ - Shared worker tmux session is now `docket-workers`.
34
+ - Extension surface is now `globalThis.__docket`.
35
+ - Config/storage paths now use `docket`.
36
+
37
+ ## New command surface
38
+
39
+ Primary commands:
40
+
41
+ ```text
42
+ /docket
43
+ /docket spawn [--fresh] [--as <kind>] <task>
44
+ /docket tell w<N> [text]
45
+ /docket attach [w<N>]
46
+ /docket save [flags] [note]
47
+ /docket load [id|last|w<N>]
48
+ ```
49
+
50
+ Advanced commands remain available via `/docket help advanced`.
51
+
52
+ ## Evidence bundles replace checkpoint-first language
53
+
54
+ `/docket save` creates a durable evidence bundle and labels the current Pi tree leaf as `docket:<id>`.
55
+
56
+ `/docket load` mounts bundle or worker artifacts at zero model-context cost.
57
+
58
+ Docket no longer presents itself as a continuation mechanism. Use Pi for continuation:
59
+
60
+ - `/tree` for branch navigation,
61
+ - `/fork` or `/clone` for separate sessions,
62
+ - `/compact` for lossy context compression,
63
+ - `/docket save` for durable evidence,
64
+ - `/docket load` when evidence becomes relevant.
65
+
66
+ ## Migration notes
67
+
68
+ Docket uses new paths:
69
+
70
+ ```text
71
+ ~/.pi/agent/docket/
72
+ ~/.pi/agent/docket.json
73
+ <project>/.pi/docket.json
74
+ <project>/.pi/docket/worker-kinds/*.md
75
+ ```
76
+
77
+ If you need old Trail data, copy it manually:
78
+
79
+ ```bash
80
+ cp -R ~/.pi/agent/trail ~/.pi/agent/docket
81
+ cp ~/.pi/agent/trail.json ~/.pi/agent/docket.json 2>/dev/null || true
82
+ cp -R .pi/trail .pi/docket 2>/dev/null || true
83
+ cp .pi/trail.json .pi/docket.json 2>/dev/null || true
84
+ ```
85
+
86
+ ## Repository maintenance checklist
87
+
88
+ After this release:
89
+
90
+ 1. Rename GitHub repository to `pi-docket`.
91
+ 2. Update repository description to “Decision queue and evidence bundles for Pi agent work.”
92
+ 3. Confirm npm package `@roodriigoooo/pi-docket` publishes successfully.
93
+ 4. Keep old `@roodriigoooo/trail` unpublished/deprecated with a pointer to `@roodriigoooo/pi-docket` if needed.