feat: enhance distill prompt with _about.md, folder paths, and daily notes - #11
Open
cad0p wants to merge 3 commits into
Open
feat: enhance distill prompt with _about.md, folder paths, and daily notes#11cad0p wants to merge 3 commits into
cad0p wants to merge 3 commits into
Conversation
…notes - Read _about.md files to understand folder purposes - Use relevant folder path when creating notes - Append to today's daily note in the relevant namespace - Minor punctuation cleanup
cad0p
marked this pull request as ready for review
May 4, 2026 03:50
Guide the model on what _about.md files should look like — short folder descriptions explaining what kinds of notes belong there. Points the model at existing examples for style reference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-adds the auto-distill-on-shutdown path that was lost when pi-napkin migrated to the upstream simplified model in commit
42970c3(2026-04-14), and makes concurrent auto-distill safe via per-distill git worktrees.Closes the gap described in cad0p/pi-napkin#1 for pi 0.68.0+ where
session_shutdownnow fires reliably with areasonfield. Ships alongside PR #10 (/distill-auto-this-session) which was merged earlier.What changed
Two config-gated features
distill.onShutdown: boolean(defaulttrue) — fires a final detached distill onsession_shutdownif the session has new content since the last spawn.git worktree add -b distill/<hash>-<ts>, writes there, then merges back to main via a custom LLM merge driver (napkin-distill-merge). Removes the need for any vault-wide lock.Setup path (zero user action)
On first
session_startwithdistill.enabled: truewhere the vault has no.git/:git init.gitignore(.napkin/distill/, Obsidian workspace state, common secret patterns) and.gitattributes(*.md merge=napkin-distill-merge) — idempotent merge with any existing contentObservability
/distill-statusslash command — lists active distill worktrees (pid, elapsed, branch) and unmergeddistill/*branchesnapkin_distill_statuspi tool — same data, agent-callable as JSONbefore_agent_startoverlap injection — when a running distill is writing to files the current session has also touched, the extension injects a one-time notice into the system prompt (not persisted; zero tokens when no overlap)Manual
/distillstays git-optionalManual distill path unchanged — no worktree, no git requirement. Only auto-distill (interval + shutdown) switches to the new architecture.
Concurrency model
Each auto-distill:
pi -pinside the worktree (cwd = worktree root, so napkin resolves vault to the worktree's checkout)git merge <default-branch>with thenapkin-distill-mergedriver handling any.mdconflicts (3-strike LLM retry, pass-by-path with random delimiters for prompt-injection safety, 60s timeout)git merge --squashto main — one clean squash commit per distillgit_retrywraps main-mutating commands (no explicit flock — plays with any concurrent git tooling like Obsidian git plugin or user's own autocommit cron)Failed runs leave a line at
<vault.configPath>/distill/errors/<ISO-timestamp>-<pid>-<branch-hash>.log(branch name, dangling commit SHA, conflicted files, last LLM response). No worktrees or branches linger.Tests
pi-napkin had zero tests. This PR adds bun test infrastructure and 230 tests across 14 files:
shouldDistillOnShutdownpredicate — 41 tests (per-guard isolation + integration scenarios + boundary conditions)loadVaultConfig— 10 testsdistill-workspace— worktree lifecycle, meta.json, cleanupnapkin-distill-mergedriver — 9 modes (happy, empty, tiny, huge, no-frontmatter, 3-strike, etc.) + timeoutgit_retry— realindex.lockcontentionsession-touched-files— tool-output shapes + version-pin check against pi's internalextractFileOpsFromMessageauto-setup— fresh vault, partial setup, secret patterns, idempotent mergepisession_shutdown reason valuesbefore_agent_starthandler — overlap, no-overlap, error-pathDocs restructure
README.mdis now the single source of truth (~700 lines) covering install, extensions, commands, config, auto-distill setup + concurrency, troubleshooting.skills/napkin/SKILL.mdis a thin pointer (~60 lines) preserving the frontmatter pi's skill discovery needs. Eliminates drift between user-facing and agent-facing documentation.Review process
Three parallel fresh reviewers (correctness, coverage+testing, security+cleanness). 37 findings consolidated, 14 fix-now (1 block + 8 high + 5 medium), rest deferred to v0.1.1 with reasoning. See
~/.napkin/features/pi-napkin-distill/reviews/*.mdfor the full audit trail. Key issues caught:autoDistillSuppressedsafety flag was being overwritten by persistence restore — broke setup-failure fail-safemeta.json.pidrecorded parent pi session pid, not wrapper pid — broke/distill-statuslivenessmainwas hardcoded in wrapper — silent failure onmaster-default vaultsspawnDistillusedsh -cwith string interpolation — migrated to argv-based spawn<<<<<<<<delimiters — switched to pass-by-path with random marker IDsDeferred items (in
~/.napkin/features/pi-napkin-distill/reviews/):Known follow-ups (documented for v0.1.1 / future PRs)
supersedes: []convention to the distill prompt as forward-compat, zero behavior change.session_shutdownon SIGHUP in interactive mode (see earendil-works/pi#4144). Worth an upstream pi issue for an extension-safe path; out of scope here.napkin migrate --to-subdir-layoutcommand would move legacy flat vaults to the new.napkin/subdir layout.Checklist
feat/shutdown-distill-worktree— 39 commits, all SSH-signedpnpm install --frozen-lockfileclean (npm → pnpm migration included)pnpm lintgreenpnpm testgreen (230 tests, 0 failures)pnpm/action-setup@v4+pnpm install --frozen-lockfile+bun test)distill.enabled; manual/distillunchangedfeatures/pi-napkin-distill/{shutdown-distill,builder-deleter,auto-this-session}.mdTesting
For manual validation: