@jeffober/thatch 0.2.4 → 0.2.6
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.
- package/README.md +56 -26
- package/artifacts/skills/common.md +1 -0
- package/artifacts/skills/thatch-clear-writing.md +103 -5
- package/artifacts/skills/thatch-code-archaeology.md +9 -0
- package/artifacts/skills/thatch-code-review.md +16 -8
- package/artifacts/skills/thatch-coordination.md +69 -0
- package/artifacts/skills/thatch-plan-refinement.md +33 -4
- package/artifacts/skills/thatch-pr-description.md +21 -13
- package/artifacts/skills/thatch-refine-personal.md +5 -0
- package/artifacts/skills/thatch-refine.md +7 -1
- package/artifacts/skills/thatch-review-context.md +55 -2
- package/artifacts/skills/thatch-review-followup.md +4 -4
- package/artifacts/skills/thatch-review-no-slop.md +15 -0
- package/artifacts/skills/thatch-review-response.md +1 -1
- package/artifacts/skills/thatch-review-synthesizer.md +21 -1
- package/bin/thatch +48 -15
- package/docs/assets/deepwiki-badge.svg +1 -0
- package/docs/dev/README.md +18 -10
- package/docs/dev/features/README.md +1 -1
- package/docs/dev/features/behavior-engine.md +10 -0
- package/docs/dev/features/cli.md +4 -1
- package/docs/dev/features/commands.md +40 -9
- package/docs/dev/features/cross-session-chat.md +194 -23
- package/docs/dev/features/database.md +4 -4
- package/docs/dev/features/notifications.md +1 -2
- package/docs/dev/features/nudge-pipeline.md +14 -0
- package/docs/dev/features/opencode-plugin.md +56 -15
- package/docs/dev/features/prediction-engine.md +71 -6
- package/docs/dev/features/qa-system.md +19 -3
- package/docs/dev/features/session-lifecycle.md +6 -6
- package/docs/dev/features/session-tabs.md +161 -0
- package/docs/dev/features/setup.md +5 -0
- package/docs/dev/features/watchers.md +62 -6
- package/docs/dev/gotchas.md +89 -0
- package/docs/dev/mcp-parity.md +5 -5
- package/docs/dev/setup-and-hooks.md +7 -2
- package/docs/dev/skills.md +12 -9
- package/docs/plans/generalized-session-heartbeat.md +212 -0
- package/docs/plans/prediction-consolidation.md +88 -68
- package/docs/user/README.md +29 -13
- package/docs/user/behavior-engine.md +7 -1
- package/docs/user/cli.md +5 -1
- package/docs/user/code-review.md +43 -2
- package/docs/user/commands.md +37 -10
- package/docs/user/cross-session-chat.md +76 -26
- package/docs/user/prediction-engine.md +23 -1
- package/docs/user/setup.md +16 -0
- package/docs/user/skills.md +9 -7
- package/docs/user/watchers.md +22 -7
- package/package.json +10 -2
- package/src/alerts.ts +1 -1
- package/src/capabilities.ts +20 -6
- package/src/chat.ts +358 -43
- package/src/commands.ts +123 -18
- package/src/db.ts +74 -3
- package/src/git.ts +3 -1
- package/src/hygiene.ts +5 -0
- package/src/mcp.ts +101 -9
- package/src/opencode/tui-plugin.ts +90 -0
- package/src/opencode/v2.ts +440 -66
- package/src/prediction.ts +90 -0
- package/src/prompts.ts +164 -29
- package/src/runtime.ts +298 -15
- package/src/scoring-engine.ts +40 -9
- package/src/session-db.ts +4 -4
- package/src/session-tab-shared.ts +231 -0
- package/src/setup.ts +9 -3
- package/src/skills.ts +6 -9
- package/src/tab-state.ts +125 -0
- package/src/tool-defs.ts +454 -76
- package/src/tools.ts +2 -0
- package/src/watchers.ts +263 -26
- package/docs/plans/intuition-drives.md +0 -147
- package/docs/plans/llm-alerts.md +0 -287
- package/docs/plans/thatch-actions.md +0 -179
- package/docs/plans/worktree-deletion-recovery.md +0 -246
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fire Tracking and Compound Predictions
|
|
2
2
|
|
|
3
3
|
## Synopsis
|
|
4
4
|
|
|
5
|
-
Post-processing layers for the prediction engine: fire tracking
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Post-processing layers for the prediction engine: fire tracking and compound
|
|
6
|
+
(tier-2) predictions minted from co-firing constellations of existing
|
|
7
|
+
predictions. Uses nudge-driven detection and the existing edge model for fire
|
|
8
|
+
behavior. No cron, no separate backend.
|
|
9
|
+
|
|
10
|
+
The consolidation (dedup) half was implemented separately and has graduated —
|
|
11
|
+
the shipped design is documented in
|
|
12
|
+
[../dev/features/prediction-engine.md](../dev/features/prediction-engine.md)
|
|
13
|
+
("Dedup pass"). What remains here is the fire-tracking prerequisite
|
|
14
|
+
and the co-fire refinements (behavioral dedup, compound detection) that
|
|
15
|
+
consume the accumulated data.
|
|
9
16
|
|
|
10
17
|
## Background
|
|
11
18
|
|
|
@@ -14,10 +21,10 @@ auto-fires at chat.message and updates via agent tool calls. What it lacks
|
|
|
14
21
|
relative to nak's samskara system:
|
|
15
22
|
|
|
16
23
|
- **Fire tracking** -- no record of which predictions fire together on the same
|
|
17
|
-
turn. This is the prerequisite for
|
|
18
|
-
- **Consolidation** --
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
turn. This is the prerequisite for co-fire dedup and compound detection.
|
|
25
|
+
- **Consolidation** -- implemented and graduated: a cosine-only dedup pass
|
|
26
|
+
over the prediction corpus, no prerequisites
|
|
27
|
+
([../dev/features/prediction-engine.md](../dev/features/prediction-engine.md)).
|
|
21
28
|
- **Compound predictions** -- no mechanism to mint a higher-order prediction
|
|
22
29
|
from a constellation of predictions that reliably co-fire. Nak's tier-2
|
|
23
30
|
samskaras fire at 77% genuine-engagement vs tier-1's 21% because compound
|
|
@@ -43,10 +50,13 @@ existing edge model.
|
|
|
43
50
|
The co-fire data is for *deciding what to compound*, not for *making the
|
|
44
51
|
compound fire*. This means:
|
|
45
52
|
|
|
46
|
-
1. A compound needs no tier column
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
1. A compound needs no tier column and no fire-path changes. It is a
|
|
54
|
+
prediction with multiple matcher edges. The scoring path does get one
|
|
55
|
+
addition: dynamic child suppression (see the compound-domination risk).
|
|
56
|
+
2. The existing `scoreNudge`/`scoreItems` already follow all edges and
|
|
57
|
+
deduplicate by prediction_id. A compound scores through its children's
|
|
58
|
+
edges. Minting records the compound-to-children relation (Phase 4) so
|
|
59
|
+
suppression can tell parent from child.
|
|
50
60
|
3. The existing `prediction_update` tool already finds existing matchers by
|
|
51
61
|
cosine (0.85 threshold) and creates edges. Calling it multiple times with
|
|
52
62
|
different matcher texts but the same prediction statement creates a
|
|
@@ -111,14 +121,18 @@ pass null or derive from the socket connection.
|
|
|
111
121
|
tables. Same conventions (uuid PK, store column, idempotent CREATE TABLE IF
|
|
112
122
|
NOT EXISTS).
|
|
113
123
|
|
|
114
|
-
### Phase 2:
|
|
115
|
-
|
|
116
|
-
**New DB method: `findPredictionDuplicates(store, threshold)`**
|
|
124
|
+
### Phase 2: Co-fire refinement of dedup
|
|
117
125
|
|
|
118
|
-
|
|
126
|
+
The cosine-only dedup pass (`findPredictionDuplicates`, the
|
|
127
|
+
`prediction_dedup_pairs` table, the hygiene line, the merge flow) is
|
|
128
|
+
IMPLEMENTED and graduated — documented in
|
|
129
|
+
[../dev/features/prediction-engine.md](../dev/features/prediction-engine.md)
|
|
130
|
+
("Dedup pass"). Once
|
|
131
|
+
fire data accumulates, this plan upgrades that same method with behavioral
|
|
132
|
+
evidence, mirroring nak's `samskara_collapse_by_cofiring`:
|
|
119
133
|
|
|
120
|
-
**
|
|
121
|
-
where both have fire_count > 0:
|
|
134
|
+
**Behavioral pass (added to `findPredictionDuplicates`):** For each pair of
|
|
135
|
+
predictions (A, B) in the store where both have fire_count > 0:
|
|
122
136
|
|
|
123
137
|
```
|
|
124
138
|
cofires(A, B) >= 3
|
|
@@ -131,26 +145,11 @@ when either fires are duplicates. Two that co-fire but also fire independently
|
|
|
131
145
|
are adjacent-but-distinct. Cosine is a sanity floor against spurious co-fires.
|
|
132
146
|
|
|
133
147
|
**Safety cap (cosine-only):** If the prediction count exceeds a target (e.g.,
|
|
134
|
-
100),
|
|
135
|
-
|
|
136
|
-
finds nothing but the pool is still growing.
|
|
137
|
-
|
|
138
|
-
**Output:** A list of candidate merge pairs with {predictionA, predictionB,
|
|
139
|
-
cofires, ratio, cosine, firesA, firesB}. Surfaced via the hygiene nudge, not
|
|
140
|
-
auto-merged. The agent reviews and merges via prediction_delete + (optionally)
|
|
141
|
-
prediction_update to fold the loser's matchers into the winner.
|
|
142
|
-
|
|
143
|
-
The merge itself is agent-driven: the agent sees the candidate pair, reads both
|
|
144
|
-
predictions, deletes the weaker one (or uses a future `prediction_merge` tool
|
|
145
|
-
if one is added). This matches the memory dedup pattern
|
|
146
|
-
(`find_duplicates` + `dedup_mark_checked`).
|
|
147
|
-
|
|
148
|
-
**Integration point:** `hygiene.ts` -- add a line to `hygieneReport`:
|
|
149
|
-
`N prediction duplicate pairs pending review` when candidates exist.
|
|
148
|
+
100), the implemented pure cosine pass already covers the pool;
|
|
149
|
+
no behavioral evidence is required to keep dedup moving.
|
|
150
150
|
|
|
151
|
-
**
|
|
152
|
-
|
|
153
|
-
(tens, not hundreds) so the cost is negligible.
|
|
151
|
+
**Output:** the dedup plan's candidate shape extended with {cofires, ratio,
|
|
152
|
+
firesA, firesB} per pair.
|
|
154
153
|
|
|
155
154
|
### Phase 3: Compound Prediction Detection
|
|
156
155
|
|
|
@@ -216,7 +215,14 @@ first child's matcher. Subsequent calls find the existing compound by
|
|
|
216
215
|
`findNearestPrediction` (0.85 store-wide dedup) and add edges from the other
|
|
217
216
|
children's matchers.
|
|
218
217
|
|
|
219
|
-
This works with the existing tool surface.
|
|
218
|
+
This works with the existing tool surface. One addition: minting must also
|
|
219
|
+
record WHICH predictions the compound supersedes, because child suppression
|
|
220
|
+
(see the compound-domination risk) needs the parent-to-children relation at
|
|
221
|
+
scoring time -- shared matcher edges are implicit and cannot distinguish a
|
|
222
|
+
compound from a busy multi-matcher prediction. `prediction_update` gains an
|
|
223
|
+
optional `supersedes` arg (array of prediction ids), carried on the first
|
|
224
|
+
mint call, writing one `prediction_compounds(compound_id, child_id)` row per
|
|
225
|
+
child. No tier column; the compound is still an ordinary prediction.
|
|
220
226
|
|
|
221
227
|
**Prompt instructions addition** (in prompts.ts, all three host variants):
|
|
222
228
|
|
|
@@ -225,8 +231,9 @@ After the existing prediction instructions, add guidance for compounds:
|
|
|
225
231
|
- When the hygiene nudge reports co-fire constellations, consider whether the
|
|
226
232
|
members share a generalizable behavior.
|
|
227
233
|
- If so, synthesize a compound statement and call `prediction_update` once per
|
|
228
|
-
child matcher with the compound statement
|
|
229
|
-
|
|
234
|
+
child matcher with the compound statement, passing the child prediction ids
|
|
235
|
+
as `supersedes` on the first call. The tool handles matcher dedup and edge
|
|
236
|
+
creation.
|
|
230
237
|
- A compound should be strictly more general than any single child. If you
|
|
231
238
|
cannot generalize, do not compound.
|
|
232
239
|
- The compound inherits the fire coverage of its children's matchers. It will
|
|
@@ -258,7 +265,7 @@ chat.message (user text)
|
|
|
258
265
|
session.created (top-level)
|
|
259
266
|
→ hygieneReport
|
|
260
267
|
→ findDuplicates (memories, existing)
|
|
261
|
-
→ findPredictionDuplicates (
|
|
268
|
+
→ findPredictionDuplicates (implemented; co-fire-refined here)
|
|
262
269
|
→ findCoFireConstellations (NEW: compound candidates)
|
|
263
270
|
→ inject hygiene nudge with all signals
|
|
264
271
|
|
|
@@ -276,44 +283,48 @@ computation, same as existing prediction methods.
|
|
|
276
283
|
db.ts.
|
|
277
284
|
|
|
278
285
|
**Code changes by file:**
|
|
279
|
-
- `src/db.ts` -- new table
|
|
280
|
-
cofireCount, totalCohorts,
|
|
286
|
+
- `src/db.ts` -- one new table (`prediction_fires`) + 4 new methods
|
|
287
|
+
(recordFires, fireCount, cofireCount, totalCohorts, findCoFireConstellations);
|
|
288
|
+
the co-fire refinement extends the implemented `findPredictionDuplicates`
|
|
289
|
+
method
|
|
281
290
|
- `src/runtime.ts` -- generate cohort_id, pass to recordFires in auto-fire path
|
|
282
291
|
- `src/sideband.ts` -- same for MCP path
|
|
283
|
-
- `src/hygiene.ts` -- add
|
|
292
|
+
- `src/hygiene.ts` -- add constellation count to report (the dedup count is
|
|
293
|
+
already implemented there)
|
|
284
294
|
- `src/prompts.ts` -- compound minting guidance in all three prompt variants
|
|
285
295
|
- `tests/prediction.test.ts` -- tests for new DB methods
|
|
286
296
|
- `tests/plugin.test.ts` -- test that fire tracking records cohorts
|
|
287
297
|
|
|
288
298
|
## Implementation Order
|
|
289
299
|
|
|
300
|
+
0. **Cosine dedup** -- IMPLEMENTED and graduated (Oct 2026):
|
|
301
|
+
`findPredictionDuplicates` + `prediction_mark_checked`; nothing left to do.
|
|
290
302
|
1. **Fire tracking** (table + recordFires + caller wiring). Foundation for
|
|
291
|
-
everything else. Ship and let fire data accumulate.
|
|
292
|
-
2. **
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
3. **
|
|
296
|
-
findPredictionDuplicates). Needs fire data to accumulate first. Wait a few
|
|
297
|
-
weeks after phase 1 ships.
|
|
298
|
-
4. **Compound detection** (findCoFireConstellations + hygiene integration).
|
|
303
|
+
everything else here. Ship and let fire data accumulate.
|
|
304
|
+
2. **Co-fire dedup** (add the behavioral pass to findPredictionDuplicates).
|
|
305
|
+
Needs fire data only -- the method and pair table already exist. Wait a
|
|
306
|
+
few weeks after fire tracking ships.
|
|
307
|
+
3. **Compound detection** (findCoFireConstellations + hygiene integration).
|
|
299
308
|
Needs more fire data than dedup (p_min_cofires = 10). Wait longer.
|
|
300
|
-
|
|
301
|
-
tools). Ships with
|
|
302
|
-
compounds.
|
|
309
|
+
4. **Compound minting** (prompt instructions + agent-driven via existing
|
|
310
|
+
tools). Ships with compound detection -- the nudge surfaces candidates,
|
|
311
|
+
the agent compounds.
|
|
303
312
|
|
|
304
|
-
|
|
313
|
+
Fire tracking ships immediately; the rest follow once fire data accumulates.
|
|
305
314
|
|
|
306
315
|
## Test Plan
|
|
307
316
|
|
|
308
317
|
- `prediction.test.ts`: test recordFires, fireCount, cofireCount,
|
|
309
|
-
totalCohorts with synthetic cohorts
|
|
310
|
-
known co-firing pairs
|
|
318
|
+
totalCohorts with synthetic cohorts, the co-fire refinement of
|
|
319
|
+
findPredictionDuplicates with known co-firing pairs, and
|
|
320
|
+
findCoFireConstellations with lift thresholds.
|
|
311
321
|
Use the existing `makeEmbed(seed, dim=384)` helper.
|
|
312
322
|
- `plugin.test.ts`: test that chat.message auto-fire records a cohort.
|
|
313
323
|
Follow the recall-nudge test pattern (mock.module transformers + server
|
|
314
324
|
hooks).
|
|
315
325
|
- `hygiene.test.ts` (if exists) or `plugin.test.ts`: test that hygiene report
|
|
316
|
-
includes
|
|
326
|
+
includes the constellation count when candidates exist (the dedup count
|
|
327
|
+
tests are implemented, riding UC-113).
|
|
317
328
|
|
|
318
329
|
## Risks and Mitigations
|
|
319
330
|
|
|
@@ -324,11 +335,18 @@ precondition gate (minimum prediction count, minimum fire count) before running
|
|
|
324
335
|
the analysis.
|
|
325
336
|
|
|
326
337
|
**Risk: Compound predictions fire too much, dominating the nudge.**
|
|
327
|
-
Mitigation:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
338
|
+
Mitigation (nak-proven): dynamic child suppression, not equal-footing
|
|
339
|
+
competition. When a compound and its child both score in the same round and
|
|
340
|
+
the compound's score is higher, the child is skipped. The rule resolves
|
|
341
|
+
during the scoring pass, per query -- not as a stored flag -- so the
|
|
342
|
+
surviving set adjusts as it searches and freed slots refill from the
|
|
343
|
+
remaining scored list. If the child outscores the compound (it matched a
|
|
344
|
+
matcher the compound did not inherit), both surface. Implementation: the
|
|
345
|
+
per-round dedup filter in `scoreItems` (src/scoring-engine.ts:153-178)
|
|
346
|
+
gains the suppression check, using the compound-to-children relation
|
|
347
|
+
recorded at mint time. Plain prediction_id dedup and the limit=5 slice are
|
|
348
|
+
unchanged. Fire rows record post-suppression survivors only, so co-fire
|
|
349
|
+
data means co-surfaced.
|
|
332
350
|
|
|
333
351
|
**Risk: Agent creates poor compounds (too generic, not useful).**
|
|
334
352
|
Mitigation: The prompt instructions include the "strictly more general" guard
|
|
@@ -351,9 +369,11 @@ this becomes a concern. Low priority.
|
|
|
351
369
|
a separate improvement, not part of this plan, but worth doing alongside
|
|
352
370
|
phase 1.
|
|
353
371
|
- The existing write-time dedup (`findNearestPrediction` at 0.85) catches
|
|
354
|
-
near-identical statements at creation. The
|
|
355
|
-
|
|
356
|
-
|
|
372
|
+
near-identical statements at creation. The implemented dedup pass
|
|
373
|
+
(cosine, with its co-fire refinement here) catches
|
|
374
|
+
behavioral duplicates that differ in wording. The layers are
|
|
375
|
+
complementary: write-time catches semantic twins, the dedup passes catch
|
|
376
|
+
behavioral twins.
|
|
357
377
|
- Nak's tier-2 decline ledger (`samskara_tier2_declines`, TTL'd 7 days) prevents
|
|
358
378
|
re-offering a declined constellation every sweep. Thatch's equivalent: a
|
|
359
379
|
`prediction_constellation_declines` table or a `dedup_pairs`-style
|
package/docs/user/README.md
CHANGED
|
@@ -138,6 +138,7 @@ Stores are created automatically. No setup required.
|
|
|
138
138
|
| `thatch_prediction_update` | Create, reinforce, or weaken a prediction. Takes a matcher (context description), a prediction (preference statement), and a signal (confirm/disconfirm/soft/create). |
|
|
139
139
|
| `thatch_prediction_list` | List all predictions in a store with matchers, confidence, and provenance. |
|
|
140
140
|
| `thatch_prediction_delete` | Delete a prediction by semantic match. Edges and provenance are cascade-deleted. |
|
|
141
|
+
| `thatch_prediction_mark_checked` | Record a verdict (duplicate/distinct) on a pair the hygiene nudge flagged, so it stops resurfacing. |
|
|
141
142
|
|
|
142
143
|
### Behavior tools
|
|
143
144
|
|
|
@@ -183,12 +184,19 @@ search` - JSONL output designed for piping to `jq` or `grep`.
|
|
|
183
184
|
| `thatch_watch_create` | Watch a GitHub PR for events (comments, review comments and replies, thread resolutions, commits, status changes, description edits, CI completions). The plugin polls in the background and prompts the session when a watched event happens. |
|
|
184
185
|
| `thatch_watch_branch_create` | Watch a GitHub branch (typically main) for commit landings, CI check-run completions, and workflow runs, with an optional workflow-name filter. |
|
|
185
186
|
| `thatch_watch_command_create` | Wait on any local condition via a shell command that exits 0 when the wait is over. One-shot: one notification on the first exit 0, then it cancels itself. Accepts a `cd` path to run somewhere other than the project directory. |
|
|
186
|
-
| `thatch_watch_list` | List this session's active watchers. |
|
|
187
|
+
| `thatch_watch_list` | List this session's active watchers, plus events waiting for idle delivery. |
|
|
187
188
|
| `thatch_watch_cancel` | Cancel one of this session's watchers by id. |
|
|
188
189
|
|
|
189
190
|
See [watchers.md](watchers.md) for the full behavior, lifetime, and
|
|
190
191
|
requirements.
|
|
191
192
|
|
|
193
|
+
### Session tab tools (opencode v2 only)
|
|
194
|
+
|
|
195
|
+
| Tool | What it does |
|
|
196
|
+
|------|-------------|
|
|
197
|
+
| `thatch_session_tab` | Spawn a detached subordinate LLM session in a new TUI tab: creates the session, pre-assigns its chat name, delivers your task prompt with your coordinator-identity framing, and opens its tab beside yours (unfocused). Takes `prompt` and `title` (required) plus exactly one of `worktree` (a git worktree of the current repository) or `directory` (any existing directory). Requires opencode v2 and the `thatch-coordination` skill describes the supervisor workflow. |
|
|
198
|
+
| `thatch_session_tab_close` | Close a dispatched subordinate's TUI tab when its task is verified and done. Tab-level only: the session survives and the user can reopen the tab; nothing is deleted. Target: the subordinate's chat name or session id. opencode v2 only. |
|
|
199
|
+
|
|
192
200
|
### Chat tools
|
|
193
201
|
|
|
194
202
|
| Tool | What it does |
|
|
@@ -198,7 +206,7 @@ requirements.
|
|
|
198
206
|
| `thatch_chat_send` | Send a message to another registered session, by name or session id. The recipient is nudged when its session is idle. |
|
|
199
207
|
| `thatch_chat_read` | Drain your inbox: all unread messages oldest-first, marked read. Senders identified by display name. |
|
|
200
208
|
| `thatch_chat_unregister` | Leave the chat directory. |
|
|
201
|
-
| `thatch_chat_broadcast` | Send one message to every other live registered session at once.
|
|
209
|
+
| `thatch_chat_broadcast` | Send one message to every other live registered session at once. Opencode sessions without an open tab (stale, or fresh but tab-less) are skipped and reported by name. Use sparingly: every open session pays a model turn for a broadcast. |
|
|
202
210
|
|
|
203
211
|
See [cross-session-chat.md](cross-session-chat.md) for the full behavior,
|
|
204
212
|
liveness model, and limitations.
|
|
@@ -240,15 +248,23 @@ Beyond the tools, thatch hooks into opencode itself:
|
|
|
240
248
|
flushes pending fact extraction, finishes any promised memory writes, and
|
|
241
249
|
surfaces todos or follow-ups it never addressed. The agent ends its
|
|
242
250
|
response with a greenlight token only when the checklist is clean. Thatch
|
|
243
|
-
watches for the token and then runs the compaction or
|
|
251
|
+
watches for the token and then runs the compaction or closes the session
|
|
252
|
+
(opencode 1 exits the whole app; opencode 2 closes the session's own tab.
|
|
253
|
+
Either way the session's watches are cancelled, and reopening or resuming
|
|
254
|
+
the session does not re-arm them - re-create watches you still want with
|
|
255
|
+
`thatch_watch_create`).
|
|
244
256
|
Without the token nothing fires -- a toast points you at the items the
|
|
245
|
-
agent listed, and you re-run the command once they're
|
|
257
|
+
agent listed in its response, and you re-run the command once they're
|
|
258
|
+
addressed. Text typed
|
|
246
259
|
after the command reaches the agent first, labeled as a `User Message`
|
|
247
260
|
section ahead of the checklist (say goodbye or hand off context:
|
|
248
261
|
`/thatch/exit Good work - see you tomorrow`). Alongside the wrap-ups,
|
|
249
|
-
on-demand actions (`/thatch/defrag`,
|
|
250
|
-
`/thatch/reflect`)
|
|
251
|
-
not just when a nudge fires
|
|
262
|
+
on-demand actions cover the memory-maintenance behaviors (`/thatch/defrag`,
|
|
263
|
+
`/thatch/extract`, `/thatch/hygiene`, `/thatch/reflect`) whenever you
|
|
264
|
+
want, not just when a nudge fires, plus the standalone commands: plan
|
|
265
|
+
refinement (`/thatch/refine`), the review modes (`/thatch/self-review`,
|
|
266
|
+
`/thatch/peer-review`), and the chat identity report (`/thatch/whois`)
|
|
267
|
+
-- see [commands.md](commands.md).
|
|
252
268
|
A greenlit `/thatch/exit` also unregisters the session from the chat
|
|
253
269
|
directory, so other sessions stop sending it mail. The commands
|
|
254
270
|
self-install into `~/.config/opencode/command/thatch/` at plugin startup;
|
|
@@ -320,17 +336,17 @@ response, walkthrough, and workflow skills that support the review pipeline:
|
|
|
320
336
|
| `thatch-review-highlights` | Positive finding detection: notably clever solutions, cleanup done along the way, documentation that helps. Medium-high bar against generic praise. |
|
|
321
337
|
| `thatch-review-technique` | Technique lens: teaching-grade notes on unseen helpers/internal packages, companion techniques, house patterns, test-craft, API-shape principles, next-reader discoverability. Informational only, never blocking. |
|
|
322
338
|
| `thatch-review-synthesizer` | Verifies and synthesizes findings from multiple specialists into a report that starts with workflow changes, then highlights, then deduplicated severity-grouped findings. |
|
|
323
|
-
| `thatch-review-context` | Gathers project context (PR descriptions, git archaeology, ticket references, linked docs/tickets, memory) before a review. Prevents false positives about intentionally deferred work. |
|
|
339
|
+
| `thatch-review-context` | Gathers project context (PR descriptions, git archaeology, ticket references, linked docs/tickets, memory, related PRs) before a review. Prevents false positives about intentionally deferred work and about pieces delivered by sibling PRs in a stack or release train. |
|
|
324
340
|
| `thatch-code-archaeology` | Investigates an existing feature, debugs an unfamiliar area, or begins a new ticket. Explores the code base from multiple angles (data model, state flow, git history, sibling features, skeletons) before proposing changes. Pairs with `thatch-coding-workflow`. |
|
|
325
341
|
| `thatch-review-followup` | Alternate entrypoint for follow-up review rounds. Verifies whether the author's responses and code changes since your last review adequately addressed your prior findings, offers to reply on resolved items, then optionally re-runs the full structured review. |
|
|
326
342
|
| `thatch-review-response` | Author-side review response: triage findings on your own PR, fix bugs one by one, reply on each thread, post a top-level summary comment. |
|
|
327
343
|
| `thatch-change-walkthrough` | Explains a change to the user as a teaching walkthrough: researches each affected workflow at the merge-base, teaches current behavior, then overlays the modifications with file:line citations. |
|
|
328
344
|
| `thatch-code-walkthrough` | Explains a feature, module, or workflow to the user as a teaching walkthrough with file:line citations. Also used to draft high-level docs for new or undocumented features. |
|
|
329
345
|
| `thatch-coding-workflow` | Plans and executes code changes with a task-list-driven workflow: complexity triage, milestone planning, research before coding, post-coding verification. Pairs with `thatch-code-archaeology` (research first, then plan). |
|
|
330
|
-
| `thatch-plan-refinement` | Refines a plan before it is implemented: a fresh-context reviewer subagent re-checks the plan each round until consensus; deep mode adds specialist lenses (reuse, alternatives, hidden problems, safe-to-modify, intent archaeology). |
|
|
331
|
-
| `thatch-refine` | Classifies the project (audience, lifecycle, surface) and refines a plan under that type's requirements. The entry point for the `thatch-refine-*` family; also the `/thatch/refine` command. |
|
|
346
|
+
| `thatch-plan-refinement` | Refines a plan before it is implemented: a fresh-context reviewer subagent re-checks the plan each round until consensus; deep mode adds specialist lenses (reuse, alternatives, hidden problems, safe-to-modify, intent archaeology). Plans with UI or session state must include a state-and-transition matrix; a revision self-check runs after each revision; extended runs rotate reviewer lenses and stop on a round with no build-changing findings. |
|
|
347
|
+
| `thatch-refine` | Classifies the project (audience, lifecycle, surface) and refines a plan under that type's requirements. The entry point for the `thatch-refine-*` family; also the `/thatch/refine` command. Deep-mode triggers in the core skill are binding; type deltas relax round counts, never mode selection. |
|
|
332
348
|
| `thatch-refine-team-app` | Team codebases: consistency outranks cleverness, intent breadcrumbs are deliverables, pre-mortem and safe-to-modify lenses dominate. |
|
|
333
|
-
| `thatch-refine-personal` | Solo projects: relaxed coordination, cleverness and experimentation welcome, premise verification stays honest. |
|
|
349
|
+
| `thatch-refine-personal` | Solo projects: relaxed coordination, cleverness and experimentation welcome, premise verification stays honest. Relaxes round counts, never mode selection. |
|
|
334
350
|
| `thatch-refine-shared-lib` | Library API surfaces: flexible on input, strict on output, keep special cases out of the API, never foreclose caller options, docs are a deliverable. |
|
|
335
351
|
| `thatch-refine-spike` | Throwaway prototypes: skip the loop, verify only the premises the experiment's conclusion depends on. |
|
|
336
352
|
| `thatch-refine-infra` | CI, Terraform, and k8s changes: blast radius, mandatory rollback plan and staged verification, pattern-following is near-absolute. |
|
|
@@ -343,13 +359,13 @@ response, walkthrough, and workflow skills that support the review pipeline:
|
|
|
343
359
|
| `thatch-pr-description` | Drafts PR descriptions with SYNOPSIS / PURPOSE / DESCRIPTION / WALK-THROUGH / NOTES, project-context research, clarity checks, and bold/italic emphasis for scanning. |
|
|
344
360
|
| `thatch-ticket-description` | Drafts ticket or issue descriptions (Linear or Jira) with clear sections, project-context research, clarity checks, and bold/italic emphasis for scanning. |
|
|
345
361
|
| `thatch-split-overlarge-pr` | Splits already-completed work from an overlarge PR into human-reviewable, release-safe PRs targeting main. |
|
|
346
|
-
| `thatch-clear-writing` | Prose rules for every human-facing text the dedicated writing skills do not cover: PR and ticket comments, documentation, plans, reports, and
|
|
362
|
+
| `thatch-clear-writing` | Prose rules for every human-facing text the dedicated writing skills do not cover: PR and ticket comments, documentation, plans, reports, chat replies, and code comments. Clarity over compression. |
|
|
347
363
|
|
|
348
364
|
### opencode-only skills
|
|
349
365
|
|
|
350
366
|
| Skill | Purpose |
|
|
351
367
|
|-------|---------|
|
|
352
|
-
| `thatch-code-review` | Multi-agent review coordinator. Dispatches parallel sub-agents for triage, decomposition, specialist fan-out, and synthesis with a workflow-change preface. Not available in Claude Code (requires sub-agent support). |
|
|
368
|
+
| `thatch-code-review` | Multi-agent review coordinator. Dispatches parallel sub-agents for triage, decomposition, specialist fan-out, and synthesis with a workflow-change preface. Not available in Claude Code (requires sub-agent support), though the `/thatch/self-review` and `/thatch/peer-review` commands run the same specialists inline there. |
|
|
353
369
|
|
|
354
370
|
### Host availability
|
|
355
371
|
|
|
@@ -24,13 +24,19 @@ the agent's context. The block looks like:
|
|
|
24
24
|
- [0.58 conf, 1 tests] When about to commit changes to the repo:
|
|
25
25
|
do Run mise run check (tsc + bun test + markdownlint) before
|
|
26
26
|
committing. Never commit code that fails the quality gate.
|
|
27
|
+
Snapshot: these labels reflect the behavior store as of this message's
|
|
28
|
+
submission. Behaviors updated after submission (including during this
|
|
29
|
+
turn) do not refresh it; re-check with thatch_behavior_list before
|
|
30
|
+
relying on them.
|
|
27
31
|
```
|
|
28
32
|
|
|
29
33
|
The agent evaluates each surfaced rule against the current situation.
|
|
30
34
|
If relevant (ham), it follows the rule and calls `behavior_feedback`
|
|
31
35
|
with `relevant: true`. If not relevant (spam), it calls
|
|
32
36
|
`behavior_feedback` with `relevant: false`. This trains the classifier
|
|
33
|
-
so future nudges are more accurate.
|
|
37
|
+
so future nudges are more accurate. On Claude Code and Cursor the
|
|
38
|
+
footer's tool name appears with its MCP spelling
|
|
39
|
+
(`mcp__thatch__behavior_list`).
|
|
34
40
|
|
|
35
41
|
## Default behaviors
|
|
36
42
|
|
package/docs/user/cli.md
CHANGED
|
@@ -57,7 +57,8 @@ thatch chat tail --since 2026-09-12 --until "2026-09-13 09:00" # a window
|
|
|
57
57
|
|
|
58
58
|
`chat list` shows every registered session in two sections, Active and
|
|
59
59
|
Stale, each as aligned columns under a header row: how long since its
|
|
60
|
-
last heartbeat, its status (`
|
|
60
|
+
last heartbeat, its status (`open` - a tab is open now - or `recent` -
|
|
61
|
+
host alive, no open tab - for opencode sessions;
|
|
61
62
|
`active` or `idle` for Claude Code and Cursor sessions, which only beat
|
|
62
63
|
when a prompt runs), its project, and its topic (the session's title) -
|
|
63
64
|
the fastest way to answer "which session should I talk to about X?"
|
|
@@ -163,6 +164,9 @@ thatch setup --claude --skills-only # refresh just the skill files
|
|
|
163
164
|
| `THATCH_BEHAVIOR_THRESHOLD` | `0.60` | Cosine threshold for behavior auto-fire |
|
|
164
165
|
| `CLAUDE_PROJECT_DIR` | `process.cwd()` | Claude Code project directory |
|
|
165
166
|
| `CURSOR_PROJECT_DIR` | (falls through) | Cursor project directory |
|
|
167
|
+
| `THATCH_PROJECT_DIR` | (falls through) | Project dir pinned by project-local MCP configs - first in the server's resolution chain |
|
|
168
|
+
| `THATCH_WATCH_DEATH_MINUTES` | `120` | Pending-age threshold before a dead session's watchers are cancelled and announced |
|
|
169
|
+
| `THATCH_PROJECT_DIR` | (falls through) | Project dir pinned by project-local MCP configs - first in the server's resolution chain |
|
|
166
170
|
| `CLAUDE_CONFIG_DIR` | `~/.claude` | Claude Code config directory |
|
|
167
171
|
| `CURSOR_CONFIG_DIR` | `~/.cursor` | Cursor config directory |
|
|
168
172
|
|
package/docs/user/code-review.md
CHANGED
|
@@ -16,7 +16,10 @@ the review:
|
|
|
16
16
|
2. **Gather project context**: PR descriptions, git archaeology,
|
|
17
17
|
ticket references, links to docs/designs/tickets found in the
|
|
18
18
|
change (followed one hop for scope and design context), TODO
|
|
19
|
-
markers, prior reviews, project memory. Also
|
|
19
|
+
markers, prior reviews, project memory. Also discovers related
|
|
20
|
+
PRs (stacks chained through base branches, release trains
|
|
21
|
+
ordered by ticket relations) and checks consistency between
|
|
22
|
+
them and the change. Also checks whether main
|
|
20
23
|
has moved past the merge-base touching the same paths — a stale
|
|
21
24
|
branch can make findings true only at the merge-base.
|
|
22
25
|
3. **Research affected workflows**: load `thatch-code-archaeology`,
|
|
@@ -30,6 +33,10 @@ the review:
|
|
|
30
33
|
the final report. When the branch is stale relative to main, it
|
|
31
34
|
re-verifies behavioral findings against current main and reports
|
|
32
35
|
merge-base-only findings as rebase notes rather than defects.
|
|
36
|
+
When related PRs were detected, it cross-references findings
|
|
37
|
+
against the sibling register: a missing piece delivered by a
|
|
38
|
+
sibling is not a defect, and inconsistencies between connected
|
|
39
|
+
PRs surface as cross-PR notes.
|
|
33
40
|
|
|
34
41
|
## The nine specialists
|
|
35
42
|
|
|
@@ -48,6 +55,34 @@ the review:
|
|
|
48
55
|
Each specialist is a self-contained static-analysis pass. They can run
|
|
49
56
|
individually or as part of the coordinated review.
|
|
50
57
|
|
|
58
|
+
## Review modes: /thatch/self-review and /thatch/peer-review
|
|
59
|
+
|
|
60
|
+
Two slash commands run the same pipeline with the findings weighted for
|
|
61
|
+
whose work is under review.
|
|
62
|
+
|
|
63
|
+
- `/thatch/self-review` reviews your own completed work before you
|
|
64
|
+
submit it. The slop, technique, and breadcrumbs lenses weigh
|
|
65
|
+
heaviest, simplicity is overweighted on shared projects, and
|
|
66
|
+
technique or highlights findings that would simplify the design are
|
|
67
|
+
surfaced for an adopt-or-dismiss decision rather than left as
|
|
68
|
+
footnotes. The review iterates: after each round you fix or decline
|
|
69
|
+
each finding, and the next round re-reviews the updated state until
|
|
70
|
+
a round produces no meaningful findings (at most three rounds).
|
|
71
|
+
- `/thatch/peer-review` reviews another author's change. Findings are
|
|
72
|
+
weighted for org velocity: simpler ways to the same outcome, existing
|
|
73
|
+
helpers that already do the work, extremely clear documentation, and
|
|
74
|
+
unintended consequences for callers and siblings. The review walks
|
|
75
|
+
the project's persistent memory for incidents, constraints, and
|
|
76
|
+
footguns the author could not have known, and checks them against
|
|
77
|
+
the change. Settled designs are not re-litigated, and "if someone
|
|
78
|
+
changes this later it breaks" findings are never reported; instead
|
|
79
|
+
the review verifies the change leaves a breadcrumb trail to wherever
|
|
80
|
+
the project records how the feature works.
|
|
81
|
+
|
|
82
|
+
Both commands work on every host. On opencode they drive the
|
|
83
|
+
coordinator with sub-agents. On Claude Code and Cursor the same
|
|
84
|
+
procedure runs the specialists inline, in sequence.
|
|
85
|
+
|
|
51
86
|
## Follow-up rounds
|
|
52
87
|
|
|
53
88
|
After the author responds or pushes changes, `thatch-review-followup`
|
|
@@ -55,6 +90,10 @@ verifies whether prior findings were adequately addressed before
|
|
|
55
90
|
deciding whether to re-run the full review. The author must either
|
|
56
91
|
fix the code, prove the finding is not a concern with a checkable
|
|
57
92
|
argument, or file a follow-up ticket with a risk explanation.
|
|
93
|
+
Between rounds the author may merge the default branch — or, on a
|
|
94
|
+
stacked PR, merge or rebase onto the base branch — into the branch;
|
|
95
|
+
the followup excludes those commits so only the author's own changes
|
|
96
|
+
are verified.
|
|
58
97
|
|
|
59
98
|
## Author-side response
|
|
60
99
|
|
|
@@ -67,7 +106,9 @@ one, reply on each thread, and post a top-level summary comment.
|
|
|
67
106
|
|
|
68
107
|
- The coordinator (`thatch-code-review`) is opencode-only. It
|
|
69
108
|
requires sub-agent support to dispatch parallel specialists. On
|
|
70
|
-
Claude Code or Cursor, run specialists individually instead
|
|
109
|
+
Claude Code or Cursor, run specialists individually instead; the
|
|
110
|
+
`/thatch/self-review` and `/thatch/peer-review` commands package
|
|
111
|
+
exactly that inline sequence, with a mode overlay on top.
|
|
71
112
|
- The review quality depends on the model. Weak models may
|
|
72
113
|
hallucinate findings or miss subtle issues.
|
|
73
114
|
- The synthesizer verifies cited text exists, but it does not
|
package/docs/user/commands.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# Slash commands
|
|
2
2
|
|
|
3
3
|
Thatch ships `/thatch/*` commands you run yourself, on top of the nudges the
|
|
4
|
-
plugin fires on its own schedule.
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
plugin fires on its own schedule. The nudge-backed commands (`defrag`,
|
|
5
|
+
`extract`, `hygiene`, `reflect`) share their instruction text with the
|
|
6
|
+
nudges, so a behavior works the same whether it fires automatically or you
|
|
7
|
+
invoke it. The remaining commands (`refine`, `self-review`, `peer-review`,
|
|
8
|
+
`whois`) stand alone.
|
|
7
9
|
|
|
8
10
|
## Commands
|
|
9
11
|
|
|
@@ -17,13 +19,33 @@ or you invoke it.
|
|
|
17
19
|
The agent asks before forgetting anything that may still matter.
|
|
18
20
|
- `/thatch/reflect` — run the session-reflection skill to persist what the
|
|
19
21
|
current session learned.
|
|
22
|
+
- `/thatch/whois` — report the current session's chat identity: its handle,
|
|
23
|
+
topic, project, and whether it runs in the project root or a worktree.
|
|
24
|
+
Text after the command looks up another session instead (by handle or
|
|
25
|
+
session id) — this is how you map a handle from the roster to the tab you
|
|
26
|
+
see: the topic is the session's live title. opencode only.
|
|
20
27
|
- `/thatch/refine` — refine a plan for a code change under the current
|
|
21
28
|
project type's requirements: the agent classifies the project (team,
|
|
22
29
|
personal, shared library, spike, infrastructure, or open source
|
|
23
30
|
contribution), confirms the pick, and runs the refinement loop with
|
|
24
|
-
that type's expectations applied.
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
that type's expectations applied. Project type relaxes round counts
|
|
32
|
+
and documentation bars, never the deep-mode triggers. Text after the
|
|
33
|
+
command can name the type directly (for example, `/thatch/refine
|
|
34
|
+
shared-lib`) to skip classification.
|
|
35
|
+
- `/thatch/peer-review` — review another author's change: the full review
|
|
36
|
+
pipeline with findings weighted for org velocity. Text after the command
|
|
37
|
+
names the review target (for example, `/thatch/peer-review 1234` for a
|
|
38
|
+
PR). The review walks the project's persistent memory for
|
|
39
|
+
incidents, constraints, and footguns the author could not have known,
|
|
40
|
+
and checks them against the change. Settled designs are not
|
|
41
|
+
re-litigated, and "if someone changes this later it breaks" findings
|
|
42
|
+
are never reported. See [code-review.md](code-review.md).
|
|
43
|
+
- `/thatch/self-review` — review your own completed work before
|
|
44
|
+
submitting it: the full review pipeline weighted for reputation and
|
|
45
|
+
simplicity. Takes the same target argument as peer-review. Rounds
|
|
46
|
+
iterate (fix or decline each finding, then re-review the updated
|
|
47
|
+
state) until a round produces no meaningful findings, at most three.
|
|
48
|
+
See [code-review.md](code-review.md).
|
|
27
49
|
- `/thatch/compact` and `/thatch/exit` — the wrap-up commands. They run a
|
|
28
50
|
pre-flight checklist (flush extraction, finish promised memory writes,
|
|
29
51
|
surface loose ends) before a compaction or an exit, gated by a greenlight
|
|
@@ -38,13 +60,18 @@ or you invoke it.
|
|
|
38
60
|
| `/thatch/extract` | yes | no | no |
|
|
39
61
|
| `/thatch/hygiene` | yes | yes | yes (as an MCP prompt) |
|
|
40
62
|
| `/thatch/reflect` | yes | yes | yes (as an MCP prompt) |
|
|
63
|
+
| `/thatch/whois` | yes | no | no |
|
|
41
64
|
| `/thatch/refine` | yes | yes | yes (as an MCP prompt) |
|
|
65
|
+
| `/thatch/peer-review` | yes | yes | yes (as an MCP prompt) |
|
|
66
|
+
| `/thatch/self-review` | yes | yes | yes (as an MCP prompt) |
|
|
42
67
|
| `/thatch/compact`, `/thatch/exit` | yes | no | no |
|
|
43
68
|
|
|
44
|
-
Why the gaps: `/thatch/extract`
|
|
45
|
-
the opencode plugin can supply. The wrap-up
|
|
46
|
-
|
|
47
|
-
the
|
|
69
|
+
Why the gaps: `/thatch/extract` and `/thatch/whois` need the invoking
|
|
70
|
+
session's ID, which only the opencode plugin can supply. The wrap-up
|
|
71
|
+
commands trigger host actions (the compaction and the session close-out)
|
|
72
|
+
through the plugin. Cursor has no file-based
|
|
73
|
+
commands; its prompts come from the MCP server (`prompts/list` and
|
|
74
|
+
`prompts/get`).
|
|
48
75
|
|
|
49
76
|
## Installation
|
|
50
77
|
|