Repository navigation
feat(integrations): two-pass /distill + Claude Code /nt-learn, /nt-distill - #159
Conversation
…still `/distill` gained a second pass over the always-loaded block. Pass 1 is unchanged — `nt_distill`'s near-duplicate note pairs, reviewed to approval. Pass 2 reviews `rules/` + `memory/`, the only notes billed on every request (lessons and notes are free until retrieved), for four things: subsumption, contradiction, dead triggers, and rules that turned out not to be always-relevant. The fix for the last is a demotion to a lesson — still found by recall, no longer injected — not a deletion. Both passes land in one approval list; nothing is written without approval, same as before. Kept as one prompt rather than a second command: the two passes share their write primitives and approval gate, and two skills whose descriptions both mean "tidy the nt store" are a mis-trigger waiting to happen. `/distill rules` runs pass 2 alone for the different cadence. Claude Code had neither prompt — it shipped only the `nt` skill and the MCP server, and `SKILL.md` never mentioned `nt distill` existed. Both are now bundled as skills, picked up by the plugin's existing `.claude/skills` glob. Named `nt-learn`/`nt-distill` rather than matching Pi and OpenCode exactly: `~/.claude/skills/` is a global namespace and bare `learn`/`distill` are too generic to claim there. The prompt bodies are the same file. Pass 2 earns the most on Claude Code, which is the runtime with no injection layer: Pi and OpenCode cap the block at NT_INJECT_MAX and nudge when it's exceeded, while Claude gets it via `nt export --tag rule` into CLAUDE.md with no size signal at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu
|
CI: The scheduled Vulncheck run on Not bundling the One related thing worth flagging, found during the field test below: Generated by Claude Code |
Field test, 5 concurrent agents against one shared store, 44 notes: three of them independently hit the same footgun and two wrote it down as separate lessons. `nt distill` reported "no near-duplicate notes found". Not a bug in the detector — a structural limit. FindSimilar requires a shared NON-structural tag, and `lesson`/`rule`/`memory-core` are excluded on purpose (internal/note/note.go:690) so that every lesson isn't treated as related to every other one. But `--kind lesson` applies only that one tag, so two lessons with no topical tag can never pair on anything but an exact slug match. The class of note the store accumulates fastest is the class dedup can't see. Pass 1 now says so and adds a stub-level sweep of `lessons/` (nt_index returns descriptions without bodies, so it stays cheap) for the semantic overlap the title tokens miss. §1.1 no longer claims an empty result means a clean corpus. Also: pass 2 now exits cleanly on a small or empty rules block instead of hunting for something to prune. Same field test — all five agents correctly declined to create any rule or memory-core note, so pass 2's target set was empty, which is a healthy store rather than a finding. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu
Field test resultsFive agents, real tasks across the repo's separate modules (recall internals, the two TS ports, docs accuracy, CLI destructive-path coverage, the Both passes came back empty. Both for informative reasons.Pass 1 reported "no near-duplicate notes found" — and it was wrong. Three agents independently hit the same footgun; two wrote it up as separate lessons: Same lesson. Not a detector bug — a structural limit. The comment at Pass 2 had an empty target set — because the agents were right. All five declined to create a single Honest read on the designThe strongest argument for pass 2 — that the always-loaded block is where compaction has real token payoff — held up. The weaker part is cadence: on a young store there's nothing there, so Unrelated bugs the test surfacedNot in scope for this PR, but found while agents were using nt in anger. Filing separately unless you want any of them here:
The path-style-title footgun (three agents, independently) is worth a note: Generated by Claude Code |
…ong field The fifth field-test agent benchmarked the ranker directly and found that `Title + tags + Description(240)` is the strong bag, so a demoted note's description is the highest-weighted text it has. Measured: an ordinary preamble line ahead of the substance costs a lesson 43% of its score and its #1 rank; padding a description promotes an unrelated note over the right one (score 0 -> 2218 from filler alone). Pass 2 told the agent to rewrite a demoted rule's description into trigger-form "when X, do Y — not Z" — which spends that field's limited budget on the remedy, while a future session searches with the symptom. Now it says lead with the symptom and keep it tight, which is what the measurements support. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu
…lidates (#162) Two data-integrity bugs found and reproduced during the multi-agent field test in #159. Both silently shrink the store while reporting nothing wrong. **TrashNote overwrote existing .trash/ entries.** It renamed straight onto .trash/<rel with / → _>, and os.Rename overwrites its destination. Two collisions are reachable in ordinary use: trashing the same rel twice (create → delete → recreate → delete), and two distinct notes that flatten to one name (a/b.md and a_b.md). .trash/ is the ONLY recovery path — TrashNote is deliberately not a journaled undo txn — so the overwritten copy was gone for good, and `nt gc --yes` trashes in a loop while printing "collected N note(s) → .trash/ (recoverable)". The new regression test reproduces it: under the old code 1 of 3 notes survived. Destination names are now claimed with O_CREATE|O_EXCL before the rename, so the rename can only land on a name nothing else holds — that also closes the stat-then-rename race rather than narrowing it. Collisions get -2, -3, … . **archiveNotes wrote before validating.** It resolved and saved inside one loop, returning on the first bad handle, so `nt archive good1 good2 typo` archived good1 and good2 — dropping them out of index, search and recall — while the only output was an error and a non-zero exit. Nobody re-checks a command that reported failure. cmdRm already resolves every handle up front for exactly this reason and says so in a comment (commands.go:1186); archive never got the same treatment. It does now. Both regression tests were confirmed to fail against the unfixed code before being committed. Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu Co-authored-by: Claude <noreply@anthropic.com>
What
Extends
/distillwith a second pass over the always-loaded block, and ports both/distilland/learnto Claude Code — the runtime that had neither.Pass 2 —
rules/+memory/Lessons and notes are free until retrieved.
rules/andmemory/are not: they're injected into (Pi, OpenCode) or compiled into (Claude Code, viant export --tag rule) every request, forever. That's where consolidation actually buys something, and nothing looked at it before.Pass 2 reviews that block for four things:
The last one is the common case and the reason this is worth doing: a demoted rule still fires through
nt_recallwhen its situation comes up — it just stops being billed on every unrelated request.nt_mvtolessons/+nt_tag remove:["rule"] add:["lesson"]; the body is untouched.Both passes land in one approval list. Nothing is merged, demoted, or retired without approval — unchanged from before, and consistent with the roadmap's rejection of silent LLM-driven consolidation.
Why one prompt, not a second command
The two passes share their write primitives (
nt_note_edit/nt_archive superseded_by/nt_tag) and their approval gate, so splitting them would duplicate the back half of the file — in a repo whose subject is deduplication. More practically, two skills whose descriptions both amount to "tidy the nt store" are a mis-trigger waiting to happen./distill rulesruns pass 2 alone for its different cadence.Extending
/distillrather than minting a new name keeps the north star intact: one prompt, three runtimes, no muscle memory broken.Claude Code
It shipped only the
ntskill and the MCP server — no/learn, no/distill, andSKILL.mdnever mentionednt distillexisted at all. Both are now bundled as skills, picked up by the plugin's existing.claude/skillsglob (noplugin.jsonchange needed).Named
nt-learn/nt-distillrather than matching Pi and OpenCode exactly, becausedocs/claude-integration.mdtells users to copy skills into~/.claude/skills/— a global namespace shared with every other tool, where barelearnanddistillare too generic to claim. The prompt bodies are the same file.Pass 2 earns the most here, which is the argument for the port: Pi and OpenCode cap the block at
NT_INJECT_MAXand emit an agent-visible over-budget nudge. Claude Code has no injection layer and therefore no size signal at all — a prompt is the only one available.Changed
integrations/pi/prompts/distill.md,integrations/opencode/commands/distill.md— two-pass rewriteintegrations/{pi,opencode}/…/learn.md— cross-link to the reverse pass from the ⚠ always-in-context flag.claude/skills/nt-distill/SKILL.md,.claude/skills/nt-learn/SKILL.md— newdocs/claude-integration.md§2b, both integration READMEsVerification
go build,go vet ./...,go test ./...all clean. Both new skills parse and load (confirmed registered by the harness). No Go code changed — the embed directives already cover whole directories, so the edited prompts need no wiring change.Currently being field-tested: five agents working real tasks across the repo's separate modules against a shared store, after which the two-pass flow runs against whatever duplication and rule bloat they actually produced. Findings to follow in a comment.
Generated by Claude Code