@jeffober/thatch 0.1.19 → 0.1.21

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 CHANGED
@@ -2,24 +2,14 @@
2
2
 
3
3
  [![CI](https://github.com/sysread/thatch/actions/workflows/ci.yml/badge.svg)](https://github.com/sysread/thatch/actions/workflows/ci.yml)
4
4
 
5
- ## Synopsis
5
+ Persistent memory and useful dev skills for AI coding agents. Works with
6
+ **OpenCode** (as a plugin), **Claude Code** (as a local MCP server), and
7
+ **Cursor** (as a local MCP server).
6
8
 
7
- Persistent memory and useful dev skills for AI coding agents that requires zero
8
- manual config.
9
-
10
- Works with **OpenCode** (as a plugin), **Claude Code** (as a local `stdio` MCP
11
- server), and **Cursor** (as a local `stdio` MCP server).
12
-
13
- Each session inherits the accumulated knowledge of every session before it —
14
- project architecture, conventions, gotchas, user preferences — so your agent
15
- starts with context instead of a blank slate. Stores are per-repo with a shared
16
- `global` store.
17
-
18
- On top of the memory layer, thatch ships a suite of skills for managing
19
- memories, performing in-depth, structured code reviews, managing the software
20
- development life cycle, and researching your code base.
21
-
22
- No API keys, no cloud services; everything runs on your machine.
9
+ Each session inherits the accumulated knowledge of every session before it:
10
+ project architecture, conventions, gotchas, user preferences. Your agent
11
+ starts with context instead of a blank slate. No API keys, no cloud services;
12
+ everything runs on your machine.
23
13
 
24
14
  ## Quick start
25
15
 
@@ -30,304 +20,86 @@ No API keys, no cloud services; everything runs on your machine.
30
20
  { "plugin": ["@jeffober/thatch"] }
31
21
  ```
32
22
 
33
- On next start, OpenCode npm-installs thatch (putting the `thatch` CLI on your
34
- PATH as a side effect) and its tools are available immediately.
35
-
36
- Set this environment variable so the extraction nudge can run the fact-extractor
37
- as a **background** sub-agent instead of blocking your turn:
23
+ On next start, OpenCode npm-installs thatch and its tools are available
24
+ immediately. For background extraction sub-agents:
38
25
 
39
26
  ```bash
40
27
  export OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
41
28
  ```
42
29
 
43
- Without it, opencode hides the task tool's `background` parameter and every
44
- extraction nudge runs synchronously. Put it in your shell rc, `mise.toml`
45
- `[env]`, or `.envrc`.
46
-
47
- **Self-hosting** (local development):
48
-
49
- ```jsonc
50
- { "plugin": ["./path/to/thatch/src/index.ts"] }
51
- ```
52
-
53
- Or place the repo under `.opencode/plugins/` and OpenCode auto-loads it.
30
+ Then **prime your project memory** with by running `thatch prime` in your project directory.
31
+ This will launch an `opencode` session to build an initial map of the code base and its architecture to seed the memory.
54
32
 
55
- ### Claude Code
33
+ ### Claude Code and Cursor
56
34
 
57
- **Install thatch globally:**
35
+ Install globally, then run setup in your project:
58
36
 
59
37
  ```bash
60
38
  npm install -g @jeffober/thatch
61
- ```
62
-
63
- This puts the `thatch` binary on your PATH. It requires [Bun] to be installed
64
- (`curl -fsSL https://bun.sh/install | bash` if you don't have it).
65
-
66
- **Set up Claude Code in your project:**
67
-
68
- ```bash
69
39
  cd /path/to/your/project
70
- thatch setup --claude
71
- ```
72
-
73
- `setup` does four things:
74
- 1. Writes `.mcp.json` — registers the MCP server (Claude Code spawns `thatch mcp` as a stdio process)
75
- 2. Appends instructions to `CLAUDE.md` — session startup, when to write, what to store
76
- 3. Installs hooks in `.claude/settings.json` — `SessionStart` runs `thatch reminder` (recall nudge + hygiene), `PostToolBatch` feeds the extraction queue, `UserPromptSubmit` peeks the queue and nudges you to save new knowledge
77
- 4. Installs skill files to `~/.claude/skills/` — memory workflow skills (project primer, fact extractor, dedup classifier, session reflection), code review skills (6 review specialists + synthesizer + context + workflow research), walkthrough skills, and writing skills. See [Skills](#skills) below.
78
-
79
- Restart Claude Code and thatch's tools are available as `mcp__thatch__*`.
40
+ thatch setup --claude # or --cursor
80
41
 
81
- **Global setup** (all projects at once, no per-project config):
82
-
83
- ```bash
84
- thatch setup --claude --global
42
+ # set up in your global config for all projects
43
+ thatch setup --claude --global # or --cursor --global
85
44
  ```
86
45
 
87
- This writes to `~/.claude/CLAUDE.md` and `~/.claude/settings.json`, then prints
88
- the `claude mcp add` command to register the MCP server at user scope.
89
-
90
- **Local development** (from a thatch repo checkout):
91
-
92
- ```bash
93
- cd /path/to/thatch
94
- bun run bin/thatch setup --claude
95
- ```
96
-
97
- When `thatch` is not on PATH, setup uses the absolute path to `bin/thatch` in
98
- the hooks and MCP config. When it is on PATH (npm global install), setup uses
99
- the bare `thatch` command so the config survives updates.
46
+ `setup` installs the MCP server config, hooks, instructions, and skills.
47
+ Restart your editor and thatch's tools are available as `mcp__thatch__*`.
48
+ Requires [Bun] on PATH.
100
49
 
101
50
  ### Other MCP-compatible harnesses
102
51
 
103
- Thatch works as a `stdio` MCP server with any MCP client. Register it in your
104
- harness's MCP config by pointing to the `thatch` binary:
105
-
106
52
  ```json
107
53
  {
108
54
  "mcpServers": {
109
- "thatch": {
110
- "command": "thatch",
111
- "args": ["mcp"]
112
- }
55
+ "thatch": { "command": "thatch", "args": ["mcp"] }
113
56
  }
114
57
  }
115
58
  ```
116
59
 
117
- No `setup` step is needed for bare MCP usage; `setup` installs hooks and
118
- instructions specific to Claude Code and Cursor. For other harnesses, add the
119
- MCP server config above and include thatch's tools/instructions in your agent's
120
- system prompt manually (see [docs/dev/mcp-parity.md](docs/dev/mcp-parity.md)
121
- for the prompt text). [Bun] must be on PATH.
122
-
123
- ## Tools
124
-
125
- | Tool (opencode) | Tool (MCP) | What it does |
126
- |------------------|------------|-------------|
127
- | `thatch_memory_remember` | `mcp__thatch__memory_remember` | Save a memory with an embedding for later recall |
128
- | `thatch_memory_recall` | `mcp__thatch__memory_recall` | Semantic search across project + global stores |
129
- | `thatch_memory_list` | `mcp__thatch__memory_list` | List labels and metadata in a store |
130
- | `thatch_memory_show` | `mcp__thatch__memory_show` | Read full content by exact label |
131
- | `thatch_memory_forget` | `mcp__thatch__memory_forget` | Delete a memory |
132
- | `thatch_store_list` | `mcp__thatch__store_list` | List all stores |
133
- | `thatch_find_duplicates` | `mcp__thatch__find_duplicates` | Surface pairs of suspiciously similar memories |
134
- | `thatch_dedup_mark_checked` | `mcp__thatch__dedup_mark_checked` | Record a reviewed pair so it stops being re-reported |
135
- | `thatch_extraction_done` | `mcp__thatch__extraction_done` | Acknowledge extraction nudge was dispatched to a sub-agent; drains the buffer |
136
- | `thatch_prediction_query` | `mcp__thatch__prediction_query` | Query the user decision model for scored predictions matching a context |
137
- | `thatch_prediction_update` | `mcp__thatch__prediction_update` | Create, reinforce, or weaken a prediction about user preferences |
138
- | `thatch_prediction_list` | `mcp__thatch__prediction_list` | List all predictions with matchers, confidence, evidence, and provenance |
139
- | `thatch_prediction_delete` | `mcp__thatch__prediction_delete` | Delete a prediction created in error (cascades to edges and provenance) |
140
-
141
- ## Prediction engine
142
-
143
- Thatch maintains a statistical model of the user's decision-making preferences.
144
- When the user sends a prompt, the engine embeds it (sharing the embedding
145
- already computed for memory recall) and searches for **matchers** — context
146
- patterns that describe situations where the user has expressed preferences.
147
- Matching matchers fire linked **predictions** (scored by cosine similarity,
148
- edge weight, and Bayesian confidence), and a nudge is injected alongside the
149
- recall nudge:
150
-
151
- ```text
152
- [thatch] User decision model
153
- - [0.72 conf, 4 tests] When X: you tend to Y
154
- - [0.50 conf, 0 tests] When Z: you may prefer W
155
- ```
156
-
157
- The nudge is descriptive, not directive. The system prompt instructions tell
158
- the agent to follow strong predictions, surface uncertainty when confidence is
159
- thin, and update the model when the user responds. Predictions use a Bayesian
160
- posterior with a Beta prior (K=5, P0=0.5); signals are `confirm`,
161
- `disconfirm`, `soft` (weak disconfirm, weight 0.25), and `create`.
162
-
163
- The MCP path (Claude Code, Cursor) fires predictions via the same sideband
164
- socket used for recall nudges. The `flush-predictions` CLI subcommand provides
165
- standalone prediction-only output for testing.
166
-
167
- ## Skills
168
-
169
- Thatch ships skills that encode operational methodology — practices your
170
- agent follows to maintain its own memory and review code systematically.
171
-
172
- ### Memory workflows
173
-
174
- | Skill | What it does |
175
- |-------|-------------|
176
- | `thatch-project-primer` | Bootstrap a project's memory store by investigating the codebase and writing foundational memories |
177
- | `thatch-fact-extractor` | Extract durable facts from recent tool interactions and persist them to memory |
178
- | `thatch-dedup-classifier` | Classify and consolidate similar memories surfaced by `thatch_find_duplicates` |
179
- | `thatch-session-reflection` | Record what was learned during a session — project facts, user preferences, tool tips |
180
-
181
- ### Code review
182
-
183
- | Skill | What it does |
184
- |-------|-------------|
185
- | `thatch-review-pedantic` | Mechanical correctness — spelling, naming, doc accuracy, specs, stale artifacts |
186
- | `thatch-review-acceptance` | Behavioral and product review — UX coherency, behavioral delta, integration effects |
187
- | `thatch-review-state-flow` | Data flow and contracts — module boundaries, implicit state machines, error propagation |
188
- | `thatch-review-no-slop` | AI writing anti-pattern detection — change narration, fourth wall breaks, hedging |
189
- | `thatch-review-breadcrumbs` | Comment narrative — do comments form a coherent outline of the code's behavior? |
190
- | `thatch-review-mark-and-sweep` | Mechanical change completeness — whole-repo sweep for stragglers after renames, flag removals, API substitutions |
191
- | `thatch-review-synthesizer` | Verify specialist findings against actual code, deduplicate, produce severity-grouped report |
192
- | `thatch-review-context` | Gather project/feature context (PRs, tickets, TODOs, deferred work) before a review |
193
- | `thatch-workflow-research` | Research code workflows affected by a change or planned change, before reviewing or planning |
194
- | `thatch-change-walkthrough` | Explain a change as a teaching walkthrough with file:line citations |
195
- | `thatch-code-walkthrough` | Explain a feature, module, or workflow as a teaching walkthrough; also drafts high-level docs |
196
-
197
- ### Writing
198
-
199
- | Skill | What it does |
200
- |-------|-------------|
201
- | `pr-description` | Draft PR descriptions using instructional-design scaffolding with bold/italic emphasis for scanning |
202
- | `ticket-description` | Draft ticket or issue descriptions (Linear or Jira) with instructional-design scaffolding |
203
- | `split-overlarge-pr` | Split already-completed work from an overlarge PR into human-reviewable, release-safe PRs |
204
-
205
- ### opencode-only
206
-
207
- | Skill | What it does |
208
- |-------|-------------|
209
- | `thatch-code-review` | Multi-agent review coordinator — triage, partition, dispatch specialists in parallel |
210
-
211
- The six review specialists run independently and can be used standalone. The
212
- synthesizer verifies their findings against the actual code — reading each
213
- cited location to confirm the evidence matches — before producing a final
214
- report. The coordinator (opencode only) orchestrates the full pipeline by
215
- dispatching specialist sub-agents in parallel.
216
-
217
- ## CLI
218
-
219
- The `thatch` CLI ships with the package (installed to your npm global bin by
220
- `npm install -g`). It requires [Bun] on your PATH — the bin script uses
221
- `#!/usr/bin/env bun` and all internal modules depend on `bun:sqlite`.
222
-
223
- ```bash
224
- thatch stores List all stores
225
- thatch list [store] List memory labels in a store
226
- thatch show <label> [store] Display a memory by label
227
- thatch forget <label> [store] Remove a memory by label
228
- thatch search <query> [store] Semantic search (cosine similarity)
229
- thatch prime Prime project memory (runs via opencode, Cursor, or claude)
230
- thatch mcp Start the stdio MCP server (for Claude Code and Cursor)
231
- thatch reminder [--json] Print session-start reminder (for hooks)
232
- thatch hygiene Print the hygiene report (standalone)
233
- thatch buffer-batch Append Claude Code PostToolBatch output to extraction queue
234
- thatch buffer-tool Append Cursor postToolUse output to extraction queue
235
- thatch flush-tools [--json] Peek extraction queue; print extraction + recall nudges
236
- thatch flush-predictions [--json] Query predictions for the prompt (hook or standalone)
237
- thatch setup --claude [--cursor] [--global] Install config + instructions + hooks + skills
238
- ```
239
-
240
- Stores default to the repo detected from `git remote`. Use `global` for the
241
- global store. Use `all` with `search` to search project + global together.
60
+ Include thatch's instructions in your agent's system prompt manually; see
61
+ [docs/dev/mcp-parity.md](docs/dev/mcp-parity.md) for the prompt text.
242
62
 
243
- ### Priming a new project
63
+ ## What's inside
244
64
 
245
- `thatch prime` bootstraps your project's memory store by having the agent
246
- investigate the codebase and write foundational memories:
65
+ - **Memory tools**: save, search, list, show, and forget memories with
66
+ semantic search (local embeddings, SQLite, brute-force cosine).
67
+ - **Prediction engine**: a statistical model of user decision-making
68
+ preferences. When a prompt matches learned contexts, predictions fire
69
+ alongside the recall nudge.
70
+ - **Skills**: 19 skills for memory workflows, structured multi-specialist
71
+ code review, change walkthroughs, and writing tasks (PR descriptions,
72
+ tickets, PR splitting).
247
73
 
248
- ```bash
249
- cd /path/to/your/project
250
- thatch prime
251
- ```
252
-
253
- This detects `opencode`, Cursor, or `claude` on your PATH and runs the
254
- `thatch-project-primer` skill, which guides the agent to:
255
-
256
- 1. Recall any existing project memories
257
- 2. Investigate docs, layout, architecture, commands, and conventions
258
- 3. Write focused memories with clear labels
259
- 4. Reconcile contradictions with existing knowledge
260
- 5. Run dedup to check for overlap
261
-
262
- After priming, your agent has context about the project's purpose, structure,
263
- tech stack, development commands, and conventions — reducing the need to
264
- re-research these topics in future sessions.
265
-
266
- ## How it works
267
-
268
- Thatch auto-detects your repo identity from `git remote get-url origin`
269
- (e.g., `sysread/thatch`). Memories are embedded with
270
- [bge-small-en-v1.5][bge] (384-dimensional vectors, ~34 MB model, cached
271
- locally) and stored in `~/.config/thatch/thatch.db` (SQLite, WAL mode).
272
- Search is brute-force cosine similarity — fast enough for thousands of entries.
273
-
274
- ### Memory capture
275
-
276
- Thatch doesn't call an LLM to extract facts. Instead, it buffers recent tool
277
- interactions and nudges the host agent to persist durable knowledge itself,
278
- using the `thatch-fact-extractor` skill. The agent's own model decides what's
279
- worth remembering — keeping thatch dependency-free and the agent in control.
280
- On OpenCode, the plugin hooks `tool.execute.after` and `chat.message` to
281
- buffer and peek (the buffer persists until the agent writes a memory). On
282
- Claude Code, `PostToolBatch` and `UserPromptSubmit` hooks drive a file-backed
283
- queue with the same peek-not-drain semantics. Both paths produce the same
284
- payload for the fact-extractor skill.
285
-
286
- ## OpenCode vs Claude Code vs Cursor parity
287
-
288
- | Feature | OpenCode (plugin) | Claude Code (MCP + hooks) | Cursor (MCP + hooks) |
289
- |---------|-------------------|--------------------------|---------------------|
290
- | Tools | Plugin tool registration | MCP `tools/list` + `tools/call` | MCP `tools/list` + `tools/call` |
291
- | System prompt | Injected at runtime with repo name | Static CLAUDE.md (repo auto-detected by MCP server) | Static AGENTS.md (repo auto-detected at startup) |
292
- | Session-start reminder | `session.created` event | `SessionStart` hook → `thatch reminder` | `sessionStart` hook → `thatch reminder --json` |
293
- | Compaction context | `experimental.session.compacting` hook | **Gap**: no equivalent (CLAUDE.md persists) | **Gap**: no equivalent |
294
- | Extraction nudge | `tool.execute.after` + `chat.message` | `PostToolBatch` + `UserPromptSubmit` (file-backed queue) | `postToolUse` + `beforeSubmitPrompt` (file-backed queue) |
295
- | Prediction auto-fire | `chat.message` hook, separate try/catch from recall | `flush-tools` tier 2 (sideband socket) | `flush-tools` tier 2 (sideband socket) |
296
- | Setup detection at startup | n/a (plugin auto-installs) | `checkSetup` in MCP server: detects missing/broken instructions | Same as Claude Code |
297
- | Skills | 19 (18 shared + coordinator) | 18 (shared only) | 18 (shared only) |
298
- | Store detection | `worktree` param from plugin | `CLAUDE_PROJECT_DIR` env var | `CURSOR_PROJECT_DIR` then `CLAUDE_PROJECT_DIR` |
299
-
300
- See [docs/dev/mcp-parity.md](docs/dev/mcp-parity.md) for the full analysis.
74
+ See the [user guide](docs/user/README.md) for the full tool list, CLI
75
+ commands, configuration, environment variables, and detailed setup for each
76
+ host.
301
77
 
302
78
  ## Privacy
303
79
 
304
80
  Everything is local. The embedding model downloads once from Hugging Face Hub
305
81
  and is cached. No data leaves your machine.
306
82
 
307
- ## Docs
308
-
309
- - [User guide](docs/user/README.md) — setup, tools, configuration
310
- - [Development](docs/dev/README.md) — architecture, module responsibilities, data flow
311
- - [MCP parity](docs/dev/mcp-parity.md) — OpenCode plugin vs Claude Code MCP feature comparison
312
- - [QA & tests](docs/qa/README.md) — test conventions, categories, use case format
313
- - [Plans](docs/plans/) — numbered design documents capturing decisions
314
-
315
83
  ## Development
316
84
 
317
85
  ```bash
318
- bun install # deps
319
- bun test # full suite: zero network, zero external deps
320
- bun test --watch # watch mode
86
+ bun install
321
87
  mise run check # typecheck + bun test + markdownlint (the CI gate)
322
88
  ```
323
89
 
324
90
  Tests never reach outside the sandbox: temp-directory SQLite files, mock
325
- embeddings, no network. `mise run check` is the full quality gate; `mise run
326
- typecheck` or `mise run lint-md` run those alone.
91
+ embeddings, no network.
92
+
93
+ ## Docs
94
+
95
+ - [User guide](docs/user/README.md) -- setup, tools, configuration, CLI
96
+ - [Development](docs/dev/README.md) -- architecture, module responsibilities
97
+ - [MCP parity](docs/dev/mcp-parity.md) -- OpenCode plugin vs MCP feature comparison
98
+ - [QA & tests](docs/qa/README.md) -- test conventions, use cases
99
+ - [Design docs](docs/in-progress/) -- in-progress design notes
327
100
 
328
101
  ## License
329
102
 
330
103
  MIT
331
104
 
332
105
  [Bun]: https://bun.sh
333
- [bge]: https://huggingface.co/BAAI/bge-small-en-v1.5