@jeffober/thatch 0.1.18 → 0.1.20
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 +50 -224
- package/artifacts/skills/pr-description.md +140 -62
- package/artifacts/skills/thatch-code-review.md +10 -2
- package/artifacts/skills/thatch-review-synthesizer.md +29 -0
- package/artifacts/skills/ticket-description.md +53 -23
- package/bin/thatch +73 -7
- package/docs/dev/skills.md +5 -5
- package/docs/in-progress/prediction-engine.md +404 -0
- package/docs/qa/README.md +33 -1
- package/docs/qa/use-cases/README.md +4 -0
- package/docs/qa/use-cases/UC-021-prediction-autofire.md +21 -0
- package/docs/qa/use-cases/UC-022-prediction-dedup.md +19 -0
- package/docs/qa/use-cases/UC-023-prediction-confidence-model.md +23 -0
- package/docs/qa/use-cases/UC-024-prediction-delete.md +20 -0
- package/docs/user/README.md +6 -5
- package/package.json +1 -1
- package/src/db.ts +480 -0
- package/src/index.ts +54 -18
- package/src/prompts.ts +119 -11
- package/src/sideband.ts +51 -13
- package/src/tool-defs.ts +203 -0
package/README.md
CHANGED
|
@@ -2,24 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/sysread/thatch/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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,250 +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
|
|
34
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
`[env]`, or `.envrc`.
|
|
46
|
-
|
|
47
|
-
**Self-hosting** (local development):
|
|
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.
|
|
48
32
|
|
|
49
|
-
|
|
50
|
-
{ "plugin": ["./path/to/thatch/src/index.ts"] }
|
|
51
|
-
```
|
|
33
|
+
### Claude Code and Cursor
|
|
52
34
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### Claude Code
|
|
56
|
-
|
|
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__*`.
|
|
80
|
-
|
|
81
|
-
**Global setup** (all projects at once, no per-project config):
|
|
40
|
+
thatch setup --claude # or --cursor
|
|
82
41
|
|
|
83
|
-
|
|
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
|
-
|
|
88
|
-
|
|
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.
|
|
89
49
|
|
|
90
|
-
|
|
50
|
+
### Other MCP-compatible harnesses
|
|
91
51
|
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"thatch": { "command": "thatch", "args": ["mcp"] }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
95
58
|
```
|
|
96
59
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
the bare `thatch` command so the config survives updates.
|
|
100
|
-
|
|
101
|
-
## Tools
|
|
102
|
-
|
|
103
|
-
| Tool (opencode) | Tool (MCP) | What it does |
|
|
104
|
-
|------------------|------------|-------------|
|
|
105
|
-
| `thatch_memory_remember` | `mcp__thatch__memory_remember` | Save a memory with an embedding for later recall |
|
|
106
|
-
| `thatch_memory_recall` | `mcp__thatch__memory_recall` | Semantic search across project + global stores |
|
|
107
|
-
| `thatch_memory_list` | `mcp__thatch__memory_list` | List labels and metadata in a store |
|
|
108
|
-
| `thatch_memory_show` | `mcp__thatch__memory_show` | Read full content by exact label |
|
|
109
|
-
| `thatch_memory_forget` | `mcp__thatch__memory_forget` | Delete a memory |
|
|
110
|
-
| `thatch_store_list` | `mcp__thatch__store_list` | List all stores |
|
|
111
|
-
| `thatch_find_duplicates` | `mcp__thatch__find_duplicates` | Surface pairs of suspiciously similar memories |
|
|
112
|
-
| `thatch_dedup_mark_checked` | `mcp__thatch__dedup_mark_checked` | Record a reviewed pair so it stops being re-reported |
|
|
113
|
-
| `thatch_extraction_done` | `mcp__thatch__extraction_done` | Acknowledge extraction nudge was dispatched to a sub-agent; drains the buffer |
|
|
114
|
-
|
|
115
|
-
## Skills
|
|
116
|
-
|
|
117
|
-
Thatch ships skills that encode operational methodology — practices your
|
|
118
|
-
agent follows to maintain its own memory and review code systematically.
|
|
119
|
-
|
|
120
|
-
### Memory workflows
|
|
121
|
-
|
|
122
|
-
| Skill | What it does |
|
|
123
|
-
|-------|-------------|
|
|
124
|
-
| `thatch-project-primer` | Bootstrap a project's memory store by investigating the codebase and writing foundational memories |
|
|
125
|
-
| `thatch-fact-extractor` | Extract durable facts from recent tool interactions and persist them to memory |
|
|
126
|
-
| `thatch-dedup-classifier` | Classify and consolidate similar memories surfaced by `thatch_find_duplicates` |
|
|
127
|
-
| `thatch-session-reflection` | Record what was learned during a session — project facts, user preferences, tool tips |
|
|
128
|
-
|
|
129
|
-
### Code review
|
|
130
|
-
|
|
131
|
-
| Skill | What it does |
|
|
132
|
-
|-------|-------------|
|
|
133
|
-
| `thatch-review-pedantic` | Mechanical correctness — spelling, naming, doc accuracy, specs, stale artifacts |
|
|
134
|
-
| `thatch-review-acceptance` | Behavioral and product review — UX coherency, behavioral delta, integration effects |
|
|
135
|
-
| `thatch-review-state-flow` | Data flow and contracts — module boundaries, implicit state machines, error propagation |
|
|
136
|
-
| `thatch-review-no-slop` | AI writing anti-pattern detection — change narration, fourth wall breaks, hedging |
|
|
137
|
-
| `thatch-review-breadcrumbs` | Comment narrative — do comments form a coherent outline of the code's behavior? |
|
|
138
|
-
| `thatch-review-mark-and-sweep` | Mechanical change completeness — whole-repo sweep for stragglers after renames, flag removals, API substitutions |
|
|
139
|
-
| `thatch-review-synthesizer` | Verify specialist findings against actual code, deduplicate, produce severity-grouped report |
|
|
140
|
-
| `thatch-review-context` | Gather project/feature context (PRs, tickets, TODOs, deferred work) before a review |
|
|
141
|
-
| `thatch-workflow-research` | Research code workflows affected by a change or planned change, before reviewing or planning |
|
|
142
|
-
| `thatch-change-walkthrough` | Explain a change as a teaching walkthrough with file:line citations |
|
|
143
|
-
| `thatch-code-walkthrough` | Explain a feature, module, or workflow as a teaching walkthrough; also drafts high-level docs |
|
|
144
|
-
|
|
145
|
-
### Writing
|
|
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.
|
|
146
62
|
|
|
147
|
-
|
|
148
|
-
|-------|-------------|
|
|
149
|
-
| `pr-description` | Draft PR descriptions using instructional-design scaffolding with bold/italic emphasis for scanning |
|
|
150
|
-
| `ticket-description` | Draft ticket or issue descriptions (Linear or Jira) with instructional-design scaffolding |
|
|
151
|
-
| `split-overlarge-pr` | Split already-completed work from an overlarge PR into human-reviewable, release-safe PRs |
|
|
63
|
+
## What's inside
|
|
152
64
|
|
|
153
|
-
|
|
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**: 20 skills for memory workflows, structured multi-specialist
|
|
71
|
+
code review, change walkthroughs, and writing tasks (PR descriptions,
|
|
72
|
+
tickets, PR splitting).
|
|
154
73
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
The six review specialists run independently and can be used standalone. The
|
|
160
|
-
synthesizer verifies their findings against the actual code — reading each
|
|
161
|
-
cited location to confirm the evidence matches — before producing a final
|
|
162
|
-
report. The coordinator (opencode only) orchestrates the full pipeline by
|
|
163
|
-
dispatching specialist sub-agents in parallel.
|
|
164
|
-
|
|
165
|
-
## CLI
|
|
166
|
-
|
|
167
|
-
The `thatch` CLI ships with the package (installed to your npm global bin by
|
|
168
|
-
`npm install -g`). It requires [Bun] on your PATH — the bin script uses
|
|
169
|
-
`#!/usr/bin/env bun` and all internal modules depend on `bun:sqlite`.
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
thatch stores List all stores
|
|
173
|
-
thatch list [store] List memory labels in a store
|
|
174
|
-
thatch show <label> [store] Display a memory by label
|
|
175
|
-
thatch forget <label> [store] Remove a memory by label
|
|
176
|
-
thatch search <query> [store] Semantic search (cosine similarity)
|
|
177
|
-
thatch prime Prime project memory (runs via opencode, Cursor, or claude)
|
|
178
|
-
thatch mcp Start the stdio MCP server (for Claude Code and Cursor)
|
|
179
|
-
thatch reminder [--json] Print session-start reminder (for hooks)
|
|
180
|
-
thatch hygiene Print the hygiene report (standalone)
|
|
181
|
-
thatch buffer-batch Append Claude Code PostToolBatch output to extraction queue
|
|
182
|
-
thatch buffer-tool Append Cursor postToolUse output to extraction queue
|
|
183
|
-
thatch flush-tools [--json] Peek extraction queue; print extraction + recall nudges
|
|
184
|
-
thatch setup --claude [--cursor] [--global] Install config + instructions + hooks + skills
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Stores default to the repo detected from `git remote`. Use `global` for the
|
|
188
|
-
global store. Use `all` with `search` to search project + global together.
|
|
189
|
-
|
|
190
|
-
### Priming a new project
|
|
191
|
-
|
|
192
|
-
`thatch prime` bootstraps your project's memory store by having the agent
|
|
193
|
-
investigate the codebase and write foundational memories:
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
cd /path/to/your/project
|
|
197
|
-
thatch prime
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
This detects `opencode`, Cursor, or `claude` on your PATH and runs the
|
|
201
|
-
`thatch-project-primer` skill, which guides the agent to:
|
|
202
|
-
|
|
203
|
-
1. Recall any existing project memories
|
|
204
|
-
2. Investigate docs, layout, architecture, commands, and conventions
|
|
205
|
-
3. Write focused memories with clear labels
|
|
206
|
-
4. Reconcile contradictions with existing knowledge
|
|
207
|
-
5. Run dedup to check for overlap
|
|
208
|
-
|
|
209
|
-
After priming, your agent has context about the project's purpose, structure,
|
|
210
|
-
tech stack, development commands, and conventions — reducing the need to
|
|
211
|
-
re-research these topics in future sessions.
|
|
212
|
-
|
|
213
|
-
## How it works
|
|
214
|
-
|
|
215
|
-
Thatch auto-detects your repo identity from `git remote get-url origin`
|
|
216
|
-
(e.g., `sysread/thatch`). Memories are embedded with
|
|
217
|
-
[bge-small-en-v1.5][bge] (384-dimensional vectors, ~34 MB model, cached
|
|
218
|
-
locally) and stored in `~/.config/thatch/thatch.db` (SQLite, WAL mode).
|
|
219
|
-
Search is brute-force cosine similarity — fast enough for thousands of entries.
|
|
220
|
-
|
|
221
|
-
### Memory capture
|
|
222
|
-
|
|
223
|
-
Thatch doesn't call an LLM to extract facts. Instead, it buffers recent tool
|
|
224
|
-
interactions and nudges the host agent to persist durable knowledge itself,
|
|
225
|
-
using the `thatch-fact-extractor` skill. The agent's own model decides what's
|
|
226
|
-
worth remembering — keeping thatch dependency-free and the agent in control.
|
|
227
|
-
On OpenCode, the plugin hooks `tool.execute.after` and `chat.message` to
|
|
228
|
-
buffer and peek (the buffer persists until the agent writes a memory). On
|
|
229
|
-
Claude Code, `PostToolBatch` and `UserPromptSubmit` hooks drive a file-backed
|
|
230
|
-
queue with the same peek-not-drain semantics. Both paths produce the same
|
|
231
|
-
payload for the fact-extractor skill.
|
|
232
|
-
|
|
233
|
-
## OpenCode vs Claude Code vs Cursor parity
|
|
234
|
-
|
|
235
|
-
| Feature | OpenCode (plugin) | Claude Code (MCP + hooks) | Cursor (MCP + hooks) |
|
|
236
|
-
|---------|-------------------|--------------------------|---------------------|
|
|
237
|
-
| Tools | Plugin tool registration | MCP `tools/list` + `tools/call` | MCP `tools/list` + `tools/call` |
|
|
238
|
-
| 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) |
|
|
239
|
-
| Session-start reminder | `session.created` event | `SessionStart` hook → `thatch reminder` | `sessionStart` hook → `thatch reminder --json` |
|
|
240
|
-
| Compaction context | `experimental.session.compacting` hook | **Gap**: no equivalent (CLAUDE.md persists) | **Gap**: no equivalent |
|
|
241
|
-
| Extraction nudge | `tool.execute.after` + `chat.message` | `PostToolBatch` + `UserPromptSubmit` (file-backed queue) | `postToolUse` + `beforeSubmitPrompt` (file-backed queue) |
|
|
242
|
-
| Setup detection at startup | n/a (plugin auto-installs) | `checkSetup` in MCP server: detects missing/broken instructions | Same as Claude Code |
|
|
243
|
-
| Skills | 19 (18 shared + coordinator) | 18 (shared only) | 18 (shared only) |
|
|
244
|
-
| Store detection | `worktree` param from plugin | `CLAUDE_PROJECT_DIR` env var | `CURSOR_PROJECT_DIR` then `CLAUDE_PROJECT_DIR` |
|
|
245
|
-
|
|
246
|
-
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.
|
|
247
77
|
|
|
248
78
|
## Privacy
|
|
249
79
|
|
|
250
80
|
Everything is local. The embedding model downloads once from Hugging Face Hub
|
|
251
81
|
and is cached. No data leaves your machine.
|
|
252
82
|
|
|
253
|
-
## Docs
|
|
254
|
-
|
|
255
|
-
- [User guide](docs/user/README.md) — setup, tools, configuration
|
|
256
|
-
- [Development](docs/dev/README.md) — architecture, module responsibilities, data flow
|
|
257
|
-
- [MCP parity](docs/dev/mcp-parity.md) — OpenCode plugin vs Claude Code MCP feature comparison
|
|
258
|
-
- [QA & tests](docs/qa/README.md) — test conventions, categories, use case format
|
|
259
|
-
- [Plans](docs/plans/) — numbered design documents capturing decisions
|
|
260
|
-
|
|
261
83
|
## Development
|
|
262
84
|
|
|
263
85
|
```bash
|
|
264
|
-
bun install
|
|
265
|
-
bun test # full suite: zero network, zero external deps
|
|
266
|
-
bun test --watch # watch mode
|
|
86
|
+
bun install
|
|
267
87
|
mise run check # typecheck + bun test + markdownlint (the CI gate)
|
|
268
88
|
```
|
|
269
89
|
|
|
270
90
|
Tests never reach outside the sandbox: temp-directory SQLite files, mock
|
|
271
|
-
embeddings, no network.
|
|
272
|
-
|
|
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
|
|
273
100
|
|
|
274
101
|
## License
|
|
275
102
|
|
|
276
103
|
MIT
|
|
277
104
|
|
|
278
105
|
[Bun]: https://bun.sh
|
|
279
|
-
[bge]: https://huggingface.co/BAAI/bge-small-en-v1.5
|