@jeffober/thatch 0.1.11 → 0.1.12

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.
@@ -21,9 +21,9 @@ description: Extract durable project facts ... Use when ...
21
21
  - `description` drives when the agent loads the skill (both opencode and
22
22
  Cursor auto-discover skills and use the description for relevance).
23
23
 
24
- ## The 13 skills
24
+ ## The 14 skills
25
25
 
26
- **Shared (12)** — installed everywhere; no sub-agents required:
26
+ **Shared (13)** — installed everywhere; no sub-agents required:
27
27
 
28
28
  | Skill | Role |
29
29
  |-------|------|
@@ -35,6 +35,7 @@ description: Extract durable project facts ... Use when ...
35
35
  | `thatch-review-state-flow` | Data flow and contracts: module boundaries, implicit FSMs, error propagation. |
36
36
  | `thatch-review-no-slop` | AI writing anti-patterns: change narration, fourth-wall breaks, em dashes, filler. |
37
37
  | `thatch-review-breadcrumbs` | Comment narrative: do comments form a coherent outline of behavior? |
38
+ | `thatch-review-mark-and-sweep` | Mechanical change completeness: whole-repo sweep for stragglers after renames, flag removals, API substitutions. |
38
39
  | `thatch-review-synthesizer` | Verify specialist findings against code, dedupe, classify, calibrate severity. |
39
40
  | `thatch-review-context` | Gather project/feature context (PR descriptions, git archaeology, ticket references, memory) before fan-out. Prevents false positives about intentionally deferred work. |
40
41
  | `thatch-workflow-research` | Research code workflows/features affected by a change or planned change. Reads code flows, comments, git history, memories, docs. Produces a guide to the code for reviewers or planners. |
@@ -44,11 +45,11 @@ description: Extract durable project facts ... Use when ...
44
45
 
45
46
  | Skill | Role |
46
47
  |-------|------|
47
- | `thatch-code-review` | Resolve review target, gather project context, research affected workflows, estimate complexity, partition, dispatch the 5 specialists in parallel, synthesize. |
48
+ | `thatch-code-review` | Resolve review target, gather project context, research affected workflows, estimate complexity, partition, dispatch the 6 specialists in parallel, synthesize. |
48
49
 
49
50
  ## REVIEW_COMMON
50
51
 
51
- The five review specialists share a framework interpolated via `${REVIEW_COMMON}`:
52
+ The six review specialists share a framework interpolated via `${REVIEW_COMMON}`:
52
53
 
53
54
  - **Static analysis only** — no running tests/linters/compilers.
54
55
  - **Scope gathering** — resolve the git range, `git diff --stat`, read changed
@@ -78,7 +79,7 @@ The synthesizer reuses the same verification rigor but has its own structure
78
79
  ## The two arrays
79
80
 
80
81
  ```ts
81
- const SHARED_SKILLS: SkillDef[] = [ /* 12 skills above */ ];
82
+ const SHARED_SKILLS: SkillDef[] = [ /* 13 skills above */ ];
82
83
  const OPENCODE_ONLY_SKILLS: SkillDef[] = [ /* code-review coordinator */ ];
83
84
  ```
84
85
 
@@ -112,7 +113,7 @@ and `--cursor` pass only the shared set.
112
113
  ## Memory review skills in practice
113
114
 
114
115
  - **Quick single lens**: load any specialist directly and point it at a branch.
115
- - **Full review on opencode**: load `thatch-code-review` — it gathers project context, researches affected workflows, dispatches all 5 specialists in parallel (with both the context brief and workflow guide injected into each briefing), then synthesizes.
116
+ - **Full review on opencode**: load `thatch-code-review` — it gathers project context, researches affected workflows, dispatches all 6 specialists in parallel (with both the context brief and workflow guide injected into each briefing), then synthesizes.
116
117
  - **Full review on Claude Code/Cursor**: run each specialist in sequence, then
117
118
  run `thatch-review-synthesizer` to verify and aggregate.
118
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffober/thatch",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Persistent memory for AI coding agents — local embeddings, SQLite stores, zero config. Works with OpenCode (as a plugin), Claude Code (as an MCP server), and Cursor (as an MCP server).",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/prompts.ts CHANGED
@@ -32,7 +32,7 @@ you're working in. Prior sessions may have already investigated it.
32
32
  Thatch ships skills for code review, project investigation, and memory
33
33
  workflows. The host auto-discovers them, but reach for them proactively:
34
34
 
35
- - \`thatch-code-review\` — full multi-agent code review (dispatches 5 specialists + synthesizer). Requires sub-agent support.
35
+ - \`thatch-code-review\` — full multi-agent code review (dispatches 6 specialists + synthesizer). Requires sub-agent support.
36
36
  - \`thatch-workflow-research\` — research code workflows affected by a change or planned change, before reviewing or planning.
37
37
  - \`thatch-review-context\` — gather project context (PRs, tickets, TODOs, deferred work) before a review.
38
38
  - \`thatch-project-primer\` — investigate a new project and write foundational memories.
@@ -165,7 +165,7 @@ workflows. The host auto-discovers them, but reach for them proactively:
165
165
 
166
166
  - \`thatch-workflow-research\` — research code workflows affected by a change or planned change, before reviewing or planning.
167
167
  - \`thatch-review-context\` — gather project context (PRs, tickets, TODOs, deferred work) before a review.
168
- - \`thatch-review-pedantic\` / \`-acceptance\` / \`-state-flow\` / \`-no-slop\` / \`-breadcrumbs\` — five specialist review lenses. Run individually, then \`thatch-review-synthesizer\` to verify and aggregate.
168
+ - \`thatch-review-pedantic\` / \`-acceptance\` / \`-state-flow\` / \`-no-slop\` / \`-breadcrumbs\` / \`-mark-and-sweep\` — six specialist review lenses. Run individually, then \`thatch-review-synthesizer\` to verify and aggregate.
169
169
  - \`thatch-project-primer\` — investigate a new project and write foundational memories.
170
170
  - \`thatch-session-reflection\` — record what you learned at end of session.
171
171
  - \`thatch-fact-extractor\` — extract durable facts from recent tool interactions (auto-triggered by the extraction pipeline).
@@ -312,7 +312,7 @@ workflows. The host auto-discovers them, but reach for them proactively:
312
312
 
313
313
  - \`thatch-workflow-research\` — research code workflows affected by a change or planned change, before reviewing or planning.
314
314
  - \`thatch-review-context\` — gather project context (PRs, tickets, TODOs, deferred work) before a review.
315
- - \`thatch-review-pedantic\` / \`-acceptance\` / \`-state-flow\` / \`-no-slop\` / \`-breadcrumbs\` — five specialist review lenses. Run individually, then \`thatch-review-synthesizer\` to verify and aggregate.
315
+ - \`thatch-review-pedantic\` / \`-acceptance\` / \`-state-flow\` / \`-no-slop\` / \`-breadcrumbs\` / \`-mark-and-sweep\` — six specialist review lenses. Run individually, then \`thatch-review-synthesizer\` to verify and aggregate.
316
316
  - \`thatch-project-primer\` — investigate a new project and write foundational memories.
317
317
  - \`thatch-session-reflection\` — record what you learned at end of session.
318
318
  - \`thatch-fact-extractor\` — extract durable facts from recent tool interactions (auto-triggered by the extraction pipeline).
package/src/skills.ts CHANGED
@@ -652,6 +652,133 @@ Good section headers create a table of contents:
652
652
  Do NOT report on files you did not actually read.
653
653
  `;
654
654
 
655
+ const REVIEW_MARK_AND_SWEEP = `---
656
+ name: thatch-review-mark-and-sweep
657
+ description: Mechanical change completeness audit — verifies that renames, flag removals, API substitutions, and mass replacements left no stragglers. Sweeps the whole repo, not just changed files. Use for post-implementation review of a branch, PR, or commit range.
658
+ ---
659
+
660
+ You are a mark-and-sweep review agent. You verify that mechanical changes — renames, feature flag removals, API/module substitutions, mass replacements — achieved closure: every occurrence of the old identifier was updated, no dead branches or orphaned references remain, and touch points were neatened with appropriate comments.
661
+ ${REVIEW_COMMON}
662
+ ## When to sweep
663
+
664
+ Not every change is a mechanical change. Before sweeping, determine whether the diff shows patterns of mechanical change:
665
+
666
+ **Sweep triggers:**
667
+ - Same identifier removed or replaced across multiple files
668
+ - Import substitution (old module replaced with new module)
669
+ - Renamed function, module, class, or variable (old name to new name)
670
+ - Removed config key, feature flag, or environment variable
671
+ - Deleted function/module/class that may have callers elsewhere
672
+
673
+ **No sweep needed:**
674
+ - Bug fixes (changing logic, not removing identifiers)
675
+ - New features (adding code, not removing identifiers)
676
+ - Behavioral refactors (changing what code does, not what it's called)
677
+
678
+ If no mechanical change is detected, report: "No mechanical change detected — nothing to sweep." Do not force a sweep on a diff that has nothing to mark.
679
+
680
+ ## Your focus
681
+
682
+ You care about:
683
+ - **Stragglers**: Old identifiers still referenced in files the diff did not touch
684
+ - **Dead branches**: Conditional branches now unreachable because their guard or flag was removed but the branch was not collapsed
685
+ - **Stale comments**: Comments that reference the old identifier, old behavior, or old config that no longer exists
686
+ - **Orphaned imports**: Imports of the old module or function that are no longer used after the change
687
+ - **Config residue**: Default values, config schemas, or env var docs for removed identifiers
688
+ - **Test residue**: Test fixtures or test cases that still set removed flags, call removed functions, or import removed modules
689
+
690
+ You do NOT care about:
691
+ - Whether the new code is correct (other reviewers handle logic)
692
+ - UX or behavioral concerns
693
+ - Code style or formatting
694
+ - Comment narrative quality
695
+
696
+ ## The mark-and-sweep method
697
+
698
+ Your scope is NOT limited to changed files. The scope gathering steps above identify what changed and give you the diffs you need to extract old identifiers. The sweep below extends across the entire repository.
699
+
700
+ ### 1. Mark — extract old identifiers from the diff
701
+
702
+ For each changed file, read the diff (\`git diff <range> -- <file>\`). From the removed lines (starting with \`-\`), extract identifiers that were removed, renamed, or replaced:
703
+
704
+ - **Function and method definitions**: \`def old_name\`, \`function old_name\`, \`fn old_name\`, \`const old_name\`, etc.
705
+ - **Imports**: \`import old_module\`, \`from old_module import ...\`, \`require("old_module")\`, \`use old_module\`, etc.
706
+ - **Variables and constants**: \`old_flag = ...\`, \`OLD_CONFIG_KEY = ...\`, etc.
707
+ - **Renames**: If an old name appears on a \`-\` line and a new name on the corresponding \`+\` line, mark the old name. The new name tells you what to expect in updated files.
708
+ - **Config keys and feature flags**: Names of removed flags, config keys, or env vars from deleted lines.
709
+
710
+ Also read commit messages (\`git log --oneline <range>\`) for intent: "remove X", "rename A to B", "replace Y with Z", "delete deprecated Z".
711
+
712
+ Build a mark list: each entry is an old identifier and what replaced it (if anything).
713
+
714
+ ### 2. Sweep — search the entire repository for each marked identifier
715
+
716
+ For each identifier in the mark list, run a whole-repo search:
717
+ - \`git grep -n "<identifier>"\` or \`rg -n "<identifier>"\` across the entire repository
718
+ - Exclude: vendored dependencies, generated files, lockfiles, compiled assets, node_modules, .git
719
+
720
+ For each hit, classify it:
721
+ - **In a changed file, still present**: The old identifier appears in a changed file but was not updated. This is a finding — the change was incomplete even within the files it touched.
722
+ - **In an unchanged file**: This is the primary finding type. The sweep missed this occurrence entirely.
723
+ - **False positive**: Substring match, different namespace, homonym, or unrelated use. Filter these out.
724
+
725
+ For common-word identifiers, use word-boundary patterns or filter by context. A reference to a removed \`process\` function is a straggler; the word "process" in a comment about CPU scheduling is not.
726
+
727
+ ### 3. Touchpoint neatness — verify change sites were cleaned up
728
+
729
+ For each changed file where an old identifier was removed or replaced:
730
+ - **Dead branches**: If a conditional guard was removed (e.g., \`if feature_flag_enabled\`), was the entire conditional collapsed or just the guard line? Is the else branch now dead code that should be removed?
731
+ - **Orphaned imports**: Does the old import still appear even though the imported name is no longer used?
732
+ - **Stale comments**: Do comments near the change site still reference the old name, old behavior, or old config?
733
+ - **Config residue**: Are there default values, schema entries, or env var documentation for the removed identifier?
734
+ - **Test residue**: Do test fixtures still set removed flags, call removed functions, or import removed modules?
735
+
736
+ ### 4. Verify intent for each finding
737
+
738
+ A straggler may be intentional:
739
+ - **Backward compatibility shim**: The old name is kept for external callers. Check git history and comments for evidence.
740
+ - **Deprecated module**: Scheduled for removal in a future PR. Check for TODO ($ticket) markers.
741
+ - **Separate cleanup PR**: The removal was split across PRs. Check the project context brief for deferred work.
742
+
743
+ Use the intent verification steps (trace callers, check git history, check memories) before reporting. If the straggler is intentional or deferred, do not report it as a finding.
744
+
745
+ ## What is NOT a finding
746
+
747
+ - **Substring matches**: \`git grep "config"\` matching \`oldConfigValue\` when the marked identifier was \`Config\` (the class). Use word boundaries.
748
+ - **Homonyms**: The same word used in an unrelated context (e.g., \`process\` the function vs. "process" in documentation prose).
749
+ - **Different namespace**: An identifier with the same name in a different module or package that was not part of the change.
750
+ - **Intentional shims**: Backward compatibility wrappers with documented purpose or comments explaining why the old name is retained.
751
+ - **Deferred cleanup**: Marked with a TODO ($ticket) referencing an open ticket.
752
+ - **Vendored or generated code**: References in third-party or generated files that the project does not maintain.
753
+
754
+ ## Worked example
755
+
756
+ **Change**: PR removes the \`USE_NEW_VALIDATION\` feature flag. The diff shows \`config.ts\` (flag definition deleted) and \`validation.ts\` (conditional \`if USE_NEW_VALIDATION\` removed, new path is now unconditional).
757
+
758
+ **Mark**: \`USE_NEW_VALIDATION\`
759
+
760
+ **Sweep**: \`git grep -n "USE_NEW_VALIDATION"\` returns hits in:
761
+ - \`src/config.ts\` (changed — expected, the diff removed it here)
762
+ - \`tests/validation.test.ts\` (unchanged — STRAGGLER: test still sets the flag in a fixture)
763
+ - \`docs/config.md\` (unchanged — STRAGGLER: docs still describe the flag)
764
+ - \`.env.example\` (unchanged — CONFIG_RESIDUE: env var example still present)
765
+
766
+ **Touchpoint neatness**: In \`validation.ts\`, the diff removed the \`if USE_NEW_VALIDATION { ... } else { oldValidation() }\` conditional, but \`oldValidation()\` was left as a now-unreachable function (DEAD_BRANCH). The comment above it still says "fallback when USE_NEW_VALIDATION is disabled" (STALE_COMMENT).
767
+
768
+ **Findings**: 4 findings (2 STRAGGLER, 1 CONFIG_RESIDUE, 1 DEAD_BRANCH) plus 1 STALE_COMMENT at the touchpoint.
769
+
770
+ ## Category taxonomy
771
+
772
+ - **STRAGGLER**: Old identifier found in a file the diff did not touch — the sweep missed this occurrence
773
+ - **DEAD_BRANCH**: Code path now unreachable because its guard, flag, or condition was removed but the branch was not collapsed
774
+ - **STALE_COMMENT**: Comment references the old identifier, old behavior, or old config that no longer exists
775
+ - **ORPHANED_IMPORT**: Import of the old module or function remains but is no longer used after the change
776
+ - **CONFIG_RESIDUE**: Config keys, defaults, schema entries, or env var docs for a removed identifier
777
+ - **TEST_RESIDUE**: Test fixtures or test cases that reference removed identifiers
778
+
779
+ For straggler findings, the source of truth is the diff (the identifier was removed) and the grep hit (the identifier still exists elsewhere). Use "N/A — mechanical finding" for the producer chain.
780
+ `;
781
+
655
782
  // ---------------------------------------------------------------------------
656
783
  // Review synthesizer — verify, deduplicate, and aggregate specialist findings
657
784
  // ---------------------------------------------------------------------------
@@ -661,7 +788,7 @@ name: thatch-review-synthesizer
661
788
  description: Verify and synthesize findings from multiple review specialist skills into a single deduplicated, severity-grouped report. Use after running one or more thatch-review-* specialist skills.
662
789
  ---
663
790
 
664
- You are a review synthesizer. You have received findings from one or more review specialists (pedantic, acceptance, state-flow, no-slop, breadcrumbs). Your job is to verify their citations against the actual code, deduplicate across specialists, and produce a single, coherent final report.
791
+ You are a review synthesizer. You have received findings from one or more review specialists (pedantic, acceptance, state-flow, no-slop, breadcrumbs, mark-and-sweep). Your job is to verify their citations against the actual code, deduplicate across specialists, and produce a single, coherent final report.
665
792
 
666
793
  ## Static analysis only
667
794
  You review code by reading it. Do NOT run tests, linters, compilers, or any build commands.
@@ -1089,7 +1216,7 @@ Dispatch a sub-agent using the Task tool to research the code workflows affected
1089
1216
 
1090
1217
  The sub-agent produces a code guide with one section per affected workflow or feature. Wait for it to complete and collect the guide.
1091
1218
 
1092
- This guide gives specialists the code-level context (purpose, data flow, evolutions, constraints) they need to avoid false positives about intentional behavior and long-standing design decisions, and reduces duplicate code-tracing across the five specialist lenses.
1219
+ This guide gives specialists the code-level context (purpose, data flow, evolutions, constraints) they need to avoid false positives about intentional behavior and long-standing design decisions, and reduces duplicate code-tracing across the six specialist lenses.
1093
1220
 
1094
1221
  For small changes (a single file or trivial diff), you may do this research inline instead of dispatching a sub-agent. Use your judgment: if the workflow research would require reading more than 3-4 files, dispatch a sub-agent to preserve your context for orchestration.
1095
1222
 
@@ -1119,7 +1246,7 @@ For changes estimated at 3 points or fewer, skip partitioning — dispatch one s
1119
1246
 
1120
1247
  ## Step 6: Dispatch specialist sub-agents
1121
1248
 
1122
- For each review unit, dispatch sub-agents using the Task tool. Each sub-agent runs one specialist lens on one review unit. The five specialists are:
1249
+ For each review unit, dispatch sub-agents using the Task tool. Each sub-agent runs one specialist lens on one review unit. The six specialists are:
1123
1250
 
1124
1251
  1. **Pedantic** — mechanical correctness: spelling, naming, doc accuracy, specs, guidelines, stale artifacts. Dispatch a sub-agent with instructions to: read every changed file in the unit, check comments/docs/naming/specs/style, report findings.
1125
1252
 
@@ -1131,6 +1258,8 @@ For each review unit, dispatch sub-agents using the Task tool. Each sub-agent ru
1131
1258
 
1132
1259
  5. **Breadcrumbs** — comment narrative evaluation: do comments form a coherent outline? Dispatch a sub-agent with instructions to: read every changed file in full, evaluate the comment narrative, flag gaps.
1133
1260
 
1261
+ 6. **MarkAndSweep** — mechanical change completeness: renames, flag removals, API substitutions. Dispatch a sub-agent with instructions to: extract old identifiers from removed diff lines, sweep the whole repo with git grep for stragglers, verify touchpoint neatness (dead branches, orphaned imports, stale comments, config/test residue). Self-selects: if the diff shows no mechanical change patterns, it reports "No mechanical change detected" and produces no findings.
1262
+
1134
1263
  For the integration review unit (5+ points), dispatch a sub-agent focused on:
1135
1264
  - Cross-component contracts — do the interfaces between components match?
1136
1265
  - Boundary correctness — race conditions, ordering dependencies, shared state issues at boundaries.
@@ -1155,7 +1284,7 @@ Alternatively, perform the synthesis yourself:
1155
1284
  When dispatching each sub-agent, include in the prompt:
1156
1285
  - The git range to review
1157
1286
  - The specific files in this unit's scope
1158
- - The specialist focus (from the five specialists above)
1287
+ - The specialist focus (from the six specialists above)
1159
1288
  - The diff stat for this unit's files
1160
1289
  - **The project context brief** from Step 2, filtered to what is relevant to this unit's scope. Explicitly list any deferred work that falls within this unit's files, and call out TODO ($ticket) markers the specialists should recognize as intentional.
1161
1290
  - **The workflow guide** from Step 3, filtered to the workflows relevant to this unit's scope. Use it to understand the purpose and evolution of the code before flagging issues. It provides the code-level context (flows, contracts, history, constraints) that prevents false positives about intentional behavior and long-standing design decisions.
@@ -1180,6 +1309,7 @@ const SHARED_SKILLS: SkillDef[] = [
1180
1309
  { name: "thatch-review-state-flow", content: REVIEW_STATE_FLOW },
1181
1310
  { name: "thatch-review-no-slop", content: REVIEW_NO_SLOP },
1182
1311
  { name: "thatch-review-breadcrumbs", content: REVIEW_BREADCRUMBS },
1312
+ { name: "thatch-review-mark-and-sweep", content: REVIEW_MARK_AND_SWEEP },
1183
1313
  { name: "thatch-review-synthesizer", content: REVIEW_SYNTHESIZER },
1184
1314
  { name: "thatch-review-context", content: REVIEW_CONTEXT },
1185
1315
  { name: "thatch-workflow-research", content: WORKFLOW_RESEARCH },