@jeffober/thatch 0.1.8 → 0.1.9

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/bin/release CHANGED
@@ -22,6 +22,27 @@ echo " bump: $v"
22
22
  echo " next: $next"
23
23
  echo
24
24
 
25
+ # Pre-flight: verify the current version is published on npm before allowing a
26
+ # new release. A tagged-but-unpublished version means the prior publish failed;
27
+ # stacking another release on top hides the gap and complicates recovery.
28
+ if git rev-parse -q --verify "refs/tags/v$curr" >/dev/null 2>&1; then
29
+ pub_status=$(npm view "@jeffober/thatch@$curr" version 2>&1 || true)
30
+ if ! echo "$pub_status" | grep -q "^$curr$"; then
31
+ if echo "$pub_status" | grep -q "E404"; then
32
+ echo "ERROR: v$curr is tagged but not published to npm."
33
+ echo " The previous release failed. Check: gh run view --workflow=publish.yml"
34
+ echo " Fix the workflow, delete and re-tag v$curr, push, then re-run this release."
35
+ echo " To re-tag: git tag -d v$curr && git tag v$curr <commit> && git push origin :refs/tags/v$curr && git push origin v$curr"
36
+ exit 1
37
+ else
38
+ echo "WARN: npm registry check failed (not a 404 — may be a network issue or npm outage):"
39
+ echo " $pub_status"
40
+ echo " Proceeding anyway. Verify v$curr is published before relying on this."
41
+ echo
42
+ fi
43
+ fi
44
+ fi
45
+
25
46
  echo "▸ running checks (typecheck + tests + markdown lint)..."
26
47
  mise run check
27
48
  echo " ✓ checks passed"
@@ -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 11 skills
24
+ ## The 12 skills
25
25
 
26
- **Shared (10)** — installed everywhere; no sub-agents required:
26
+ **Shared (11)** — installed everywhere; no sub-agents required:
27
27
 
28
28
  | Skill | Role |
29
29
  |-------|------|
@@ -36,13 +36,14 @@ description: Extract durable project facts ... Use when ...
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
38
  | `thatch-review-synthesizer` | Verify specialist findings against code, dedupe, classify, calibrate severity. |
39
+ | `thatch-review-context` | Gather project/feature context (PR descriptions, git archaeology, ticket references, memory) before fan-out. Prevents false positives about intentionally deferred work. |
39
40
  | `thatch-session-reflection` | End-of-session memory recording (project, user, tools, self). |
40
41
 
41
42
  **opencode-only (1)** — the coordinator needs sub-agent support:
42
43
 
43
44
  | Skill | Role |
44
45
  |-------|------|
45
- | `thatch-code-review` | Resolve review target, estimate complexity, partition, dispatch the 5 specialists in parallel, synthesize. |
46
+ | `thatch-code-review` | Resolve review target, gather context, estimate complexity, partition, dispatch the 5 specialists in parallel, synthesize. |
46
47
 
47
48
  ## REVIEW_COMMON
48
49
 
@@ -57,6 +58,12 @@ The five review specialists share a framework interpolated via `${REVIEW_COMMON}
57
58
  trigger; "the code allows this" is not enough.
58
59
  - **Intent verification** — trace callers, check git history, and `thatch_memory_recall`
59
60
  for design rationale before flagging a behavior as a bug.
61
+ - **Project context awareness** — if a context brief is provided (from the
62
+ coordinator or from loading `thatch-review-context`), use it to avoid false
63
+ positives about intentionally deferred work.
64
+ - **TODO ($ticket) markers** — recognize `TODO ($TICKET-ID): ...` as legitimate
65
+ breadcrumbs for deferred work, not stale artifacts. Flag only if the referenced
66
+ ticket is closed or merged.
60
67
  - **Output format** — `[SEVERITY] [CATEGORY] file:line` with finding, evidence
61
68
  (quoted), trigger, reachability, source of truth, producer chain, provenance.
62
69
 
@@ -66,7 +73,7 @@ The synthesizer reuses the same verification rigor but has its own structure
66
73
  ## The two arrays
67
74
 
68
75
  ```ts
69
- const SHARED_SKILLS: SkillDef[] = [ /* 10 skills above */ ];
76
+ const SHARED_SKILLS: SkillDef[] = [ /* 11 skills above */ ];
70
77
  const OPENCODE_ONLY_SKILLS: SkillDef[] = [ /* code-review coordinator */ ];
71
78
  ```
72
79
 
@@ -100,8 +107,8 @@ and `--cursor` pass only the shared set.
100
107
  ## Memory review skills in practice
101
108
 
102
109
  - **Quick single lens**: load any specialist directly and point it at a branch.
103
- - **Full review on opencode**: load `thatch-code-review` — it dispatches all 5
104
- specialists in parallel, then synthesizes.
110
+ - **Full review on opencode**: load `thatch-code-review` — it gathers project context, dispatches all 5
111
+ specialists in parallel (with context injected into each briefing), then synthesizes.
105
112
  - **Full review on Claude Code/Cursor**: run each specialist in sequence, then
106
113
  run `thatch-review-synthesizer` to verify and aggregate.
107
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffober/thatch",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
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/skills.ts CHANGED
@@ -82,6 +82,18 @@ Before flagging behavior as a bug, verify intent:
82
82
 
83
83
  If any of these reveals the behavior is intentional, it is not a finding. If you cannot determine intent after all three steps, you may report it — but note that you could not confirm whether the behavior is intentional.
84
84
 
85
+ ## Project context awareness
86
+ If your briefing includes a project context brief (from the coordinator or from loading thatch-review-context), use it to calibrate your findings:
87
+ - **Deferred work** listed in the brief is intentionally excluded from this PR. Do not flag the absence of deferred pieces as bugs, inconsistencies, or missing functionality.
88
+ - **Dependencies** in the brief tell you whether base-branch behavior is expected to be present or not. Do not assert that base-branch behavior exists without verifying it landed.
89
+ - **Relevant constraints** may explain why code is structured a certain way. Consider them before flagging design choices.
90
+
91
+ ## TODO ($ticket) markers
92
+ Code may contain \`TODO ($TICKET-ID): description\` comments that mark intentionally deferred work: temporary code, placeholders for future tickets, or planned cleanups. These are legitimate breadcrumbs, not stale artifacts.
93
+ - Do NOT flag a TODO ($ticket) marker as a stale artifact if the ticket it references is still open or future work.
94
+ - DO flag it if you can verify the referenced ticket is closed or merged (the TODO is now stale).
95
+ - If your briefing includes a context brief that lists the deferred work, use it to determine whether the ticket is still pending.
96
+
85
97
  ## Output format
86
98
  Produce findings as markdown. For each finding:
87
99
 
@@ -733,6 +745,122 @@ Findings you verified as real but pre-existing, with a one-line note on the issu
733
745
  Note which files or areas were NOT covered by any specialist.
734
746
  `;
735
747
 
748
+ // ---------------------------------------------------------------------------
749
+ // Review context builder — gathers project/feature context before fan-out
750
+ // ---------------------------------------------------------------------------
751
+
752
+ const REVIEW_CONTEXT = `---
753
+ name: thatch-review-context
754
+ description: Gather project and feature context before a code review. Investigates PR descriptions, git history, ticket references, docs, and memory to build a context brief that prevents false positives about intentionally deferred work. Use before dispatching review specialists or running a solo review.
755
+ ---
756
+
757
+ You are a review context builder. Your job is to gather project context that gives reviewers the background they need to avoid false positives about intentionally deferred work, incomplete features, and multi-ticket dependencies.
758
+
759
+ ## Why this matters
760
+
761
+ A specialist reviewer without project context will flag missing pieces of a feature as bugs or inconsistencies. If the PR is one ticket in a multi-ticket effort, the "missing" piece may be scheduled for the next ticket. Context prevents these false positives.
762
+
763
+ ## Sources to investigate
764
+
765
+ Work through these sources in order. Not every source will yield information for every change. Skip sources that produce nothing rather than forcing a narrative.
766
+
767
+ ### 1. PR description
768
+ If reviewing a PR, read the description:
769
+ - \`gh pr view N --json title,body,labels,milestone\` (or the local branch's PR if detected)
770
+ - Extract: stated scope, what is intentionally excluded, ticket references, linked PRs
771
+
772
+ ### 2. Branch name
773
+ Branch names often contain ticket identifiers. Look for patterns:
774
+ - \`user/ticket-123\`, \`user/plat-122\`, \`feature/PROJ-456\`
775
+ - Extract the ticket ID and use it to search other sources
776
+
777
+ ### 3. Git archaeology
778
+ - \`git log --oneline merge-base..HEAD\` — commit messages may reference tickets, describe scope, or mention future work
779
+ - \`git log --all --oneline --grep="TICKET-ID"\` — find related commits on other branches
780
+ - \`git log -S "TODO (TICKET"\` — find TODO markers that reference this or related tickets
781
+ - \`git branch -a\` — other branches may show planned or in-progress related work
782
+
783
+ ### 4. TODO ($ticket) markers in the diff
784
+ Scan the diff for TODO markers that reference ticket identifiers:
785
+ - Pattern: \`TODO ($TICKET-ID): description\`
786
+ - Example: \`// TODO (PLAT-123): replace this temporary flag with the real config loader\`
787
+ - Example: \`// TODO (PLAT-124): this fallback will be removed when the new API lands\`
788
+ - These mark intentionally deferred work: cleanups, temporary code, or pieces to be introduced later
789
+ - Each marker tells a reviewer "this is known and scheduled, not missing"
790
+ - Extract the ticket IDs and note what is deferred
791
+
792
+ ### 5. Thatch memories (RAG)
793
+ Call \`thatch_memory_recall\` with queries like:
794
+ - The feature or project name (if known from the PR or branch)
795
+ - The ticket identifier
796
+ - "feature status" or "milestone" or "roadmap"
797
+ - Any architectural decisions or design docs related to the changed area
798
+
799
+ ### 6. Project documentation
800
+ - README, docs/, design docs, ADRs
801
+ - CONTRIBUTING.md or equivalent for conventions
802
+ - Any roadmap, milestone, or project plan documents
803
+
804
+ ### 7. Issue tracker (if accessible)
805
+ If ticket IDs were found:
806
+ - \`gh issue list --search "TICKET-ID"\` or \`gh issue view N\`
807
+ - Look for milestone assignments, dependencies, and blocking relationships
808
+ - Check for epic or parent issues that describe the overall feature
809
+
810
+ ## Context brief format
811
+
812
+ Produce a structured brief:
813
+
814
+ ### Project context
815
+ - What larger initiative or feature this change is part of
816
+ - The ticket or milestone this PR implements
817
+
818
+ ### This change's scope
819
+ - What this PR is scoped to deliver (from PR description, commit messages, diff analysis)
820
+ - What is explicitly excluded or deferred
821
+
822
+ ### Deferred work
823
+ List each deferred piece:
824
+ - What is deferred
825
+ - Which ticket will deliver it (if known)
826
+ - Any TODO ($ticket) markers in the code that annotate it
827
+
828
+ ### Dependencies
829
+ - What other tickets or PRs this depends on (must merge first)
830
+ - What tickets or PRs depend on this (are blocked by it)
831
+ - Whether base branches have landed (for stacked PRs)
832
+
833
+ ### Relevant constraints
834
+ - Design decisions or architectural constraints from memories or docs
835
+ - Conventions that reviewers should be aware of
836
+
837
+ ## If context is sparse
838
+
839
+ Not every PR will have rich context. If you find minimal context:
840
+ - State what you looked for and what you found
841
+ - Note that the change appears to be standalone (no multi-ticket dependencies detected)
842
+ - Flag any TODO ($ticket) markers in the diff even if you could not resolve the ticket
843
+
844
+ ## The TODO ($ticket) convention
845
+
846
+ When code is intentionally temporary or incomplete because work is split across tickets, mark it with a TODO that references the ticket that will resolve it:
847
+
848
+ \`\`\`
849
+ // TODO ($TICKET-ID): description of what will be done or removed here
850
+ \`\`\`
851
+
852
+ Examples:
853
+ - \`// TODO (PLAT-123): replace this temporary flag with the real config loader\`
854
+ - \`// TODO (PLAT-124): this fallback will be removed when the new API lands\`
855
+ - \`# TODO (INFRA-456): delete this compatibility shim once all callers migrate\`
856
+
857
+ These markers serve as breadcrumbs for reviewers (human and LLM) who lack project context:
858
+ - They signal "this is known and scheduled, not a bug or oversight"
859
+ - They link the code to the ticket that will resolve it
860
+ - They should NOT be flagged as stale artifacts (the work is not yet completed)
861
+ - They SHOULD be flagged if the referenced ticket is closed or merged (the TODO is now stale)
862
+ `;
863
+
736
864
  // ---------------------------------------------------------------------------
737
865
  // Session reflection — end-of-session memory recording guidance
738
866
  // ---------------------------------------------------------------------------
@@ -833,7 +961,22 @@ Fetch any refs not locally reachable so branches and PRs that were never checked
833
961
 
834
962
  Run git diff --stat on the resolved range and git log --oneline to understand the change.
835
963
 
836
- ## Step 2: Estimate complexity
964
+ ## Step 2: Gather project context
965
+
966
+ Load the thatch-review-context skill and follow its methodology to build a context brief for this change. Investigate:
967
+ - PR description (if a PR was specified or detected via the branch)
968
+ - Branch name for ticket identifiers
969
+ - Git log for commit messages referencing tickets or describing scope
970
+ - TODO ($ticket) markers in the diff
971
+ - thatch_memory_recall for feature/project status, design decisions, ticket dependencies
972
+ - Project docs, READMEs, design docs
973
+ - Issue tracker (gh issue/view) if ticket IDs are found
974
+
975
+ Produce the context brief in the format the skill prescribes (project context, this change's scope, deferred work, dependencies, relevant constraints).
976
+
977
+ If context is sparse (no PR description, no ticket references, no relevant memories), note that the change appears standalone. Even a sparse brief is valuable: it tells specialists you looked and found nothing, so they do not need to repeat the search.
978
+
979
+ ## Step 3: Estimate complexity
837
980
 
838
981
  Estimate the review effort in scrum points (1-13 scale):
839
982
  - **1**: Trivial — typo fix, config tweak, single-line change.
@@ -847,7 +990,7 @@ Points reflect *review complexity*, not implementation effort.
847
990
 
848
991
  Identify files to exclude from review: vendored dependencies, generated files, lockfiles, compiled assets.
849
992
 
850
- ## Step 3: Partition (if > 3 points)
993
+ ## Step 4: Partition (if > 3 points)
851
994
 
852
995
  For changes estimated at more than 3 points, partition into review units of approximately 3 points each:
853
996
  - Group files by logical component or feature, not by directory.
@@ -857,7 +1000,7 @@ For changes estimated at more than 3 points, partition into review units of appr
857
1000
 
858
1001
  For changes estimated at 3 points or fewer, skip partitioning — dispatch one set of specialists covering the full scope. A single 3-point unit is not large enough to warrant decomposition.
859
1002
 
860
- ## Step 4: Dispatch specialist sub-agents
1003
+ ## Step 5: Dispatch specialist sub-agents
861
1004
 
862
1005
  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:
863
1006
 
@@ -876,7 +1019,7 @@ For the integration review unit (5+ points), dispatch a sub-agent focused on:
876
1019
  - Boundary correctness — race conditions, ordering dependencies, shared state issues at boundaries.
877
1020
  - Top-level coherence — does the overall change make sense as a unit?
878
1021
 
879
- ## Step 5: Synthesize
1022
+ ## Step 6: Synthesize
880
1023
 
881
1024
  After all sub-agents complete, load the thatch-review-synthesizer skill to verify findings, deduplicate across specialists, classify (CONFIRMED/REJECTED/UNVERIFIABLE), and produce the final severity-grouped report.
882
1025
 
@@ -897,10 +1040,12 @@ When dispatching each sub-agent, include in the prompt:
897
1040
  - The specific files in this unit's scope
898
1041
  - The specialist focus (from the five specialists above)
899
1042
  - The diff stat for this unit's files
1043
+ - **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.
900
1044
  - Any design context or specific concerns
901
1045
  - Explicit scope boundaries ("your scope is X; do NOT review Y")
902
1046
  - Instruction to produce markdown findings with: severity, category, file:line, finding, evidence, trigger scenario, reachability, source of truth, producer chain, provenance
903
1047
  - Instruction to apply the reachability gate (including reading and citing governing constraints for data-state claims) and intent verification before reporting
1048
+ - Instruction to respect the project context brief: do not flag deferred work as bugs or inconsistencies, and recognize TODO ($ticket) markers as intentional breadcrumbs
904
1049
  `;
905
1050
 
906
1051
  // ---------------------------------------------------------------------------
@@ -918,6 +1063,7 @@ const SHARED_SKILLS: SkillDef[] = [
918
1063
  { name: "thatch-review-no-slop", content: REVIEW_NO_SLOP },
919
1064
  { name: "thatch-review-breadcrumbs", content: REVIEW_BREADCRUMBS },
920
1065
  { name: "thatch-review-synthesizer", content: REVIEW_SYNTHESIZER },
1066
+ { name: "thatch-review-context", content: REVIEW_CONTEXT },
921
1067
  { name: "thatch-session-reflection", content: SESSION_REFLECTION },
922
1068
  ];
923
1069