Skip to content

feat: use napkin-ai native global config for vault resolution - #8

Open
cad0p wants to merge 2 commits into
Michaelliv:mainfrom
cad0p:feat/use-napkin-global-config
Open

cad0p wants to merge 2 commits into
Michaelliv:mainfrom
cad0p:feat/use-napkin-global-config

Conversation

@cad0p

@cad0p cad0p commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Remove vault-resolve.ts and use napkin-ai built-in vault resolution directly, which now supports $XDG_CONFIG_HOME/napkin/config.json as a global vault config fallback.

Motivation

pi-napkin currently has its own vault-resolve.ts that duplicates napkin walk-up logic and adds a ~/.pi/agent/napkin.json fallback. With napkin#15, napkin-ai natively supports global config, so this duplication can be eliminated.

Changes

  • Delete extensions/vault-resolve.ts — no longer needed
  • napkin-context/index.ts: Remove findVaultPath import, simplify getNapkin() to return new Napkin(cwd), use n.vault.configPath for config access
  • distill/index.ts: Remove findVaultPath import, use new Napkin(ctx.cwd).vault.configPath for config access
  • README.md: Update vault resolution docs, add migration guide from ~/.pi/agent/napkin.json

Migration

If you previously configured your vault in ~/.pi/agent/napkin.json, move it to:

mkdir -p ~/.config/napkin
cp ~/.pi/agent/napkin.json ~/.config/napkin/config.json

Companion PRs

  • napkin#15 — adds global vault config fallback (merge first)
  • napkin#16 — adds prepare script for git dependency builds
  • pi-napkin#9 — removes napkin-ai version pinning (merge after this PR)

Behavioral note

The old code returned null and bailed when no vault was found. The new code uses napkin findVault() which creates a bare vault as a last resort. This is consistent with napkin behavior — distill defaults to enabled: false, so no unwanted distillation will run. The bare vault only contains an empty NAPKIN.md.

cad0p added 2 commits May 3, 2026 23:00
Remove vault-resolve.ts and use napkin-ai's findVault() directly,
which now supports $XDG_CONFIG_HOME/napkin/config.json as a global
vault config fallback.

This eliminates duplicated vault resolution logic and ensures
consistent behavior between the napkin CLI and pi-napkin extensions.

- Delete extensions/vault-resolve.ts
- napkin-context: use new Napkin(cwd) directly
- distill: use new Napkin(cwd).vault.configPath for config access

Requires napkin-ai >= 0.9.0 (with global config support).
- Update vault resolution section to reflect napkin-ai's native support
- Add migration guide from ~/.pi/agent/napkin.json to ~/.config/napkin/config.json
@cad0p
cad0p force-pushed the feat/use-napkin-global-config branch from b48a8f8 to 3bcd701 Compare May 3, 2026 23:10
@cad0p
cad0p marked this pull request as ready for review May 4, 2026 00:19
Copilot AI review requested due to automatic review settings May 4, 2026 00:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes pi-napkin’s custom vault resolution logic and switches both extensions to rely on napkin-ai’s built-in vault discovery (including global config fallback), updating documentation accordingly.

Changes:

  • Deleted the custom extensions/vault-resolve.ts walk-up + ~/.pi/agent/napkin.json fallback logic.
  • Updated napkin-context and distill to construct Napkin directly from cwd and reference vault config via n.vault.configPath.
  • Updated README vault resolution docs and added a migration guide to $XDG_CONFIG_HOME/napkin/config.json.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
extensions/vault-resolve.ts Removed duplicated vault resolution logic in favor of napkin-ai’s native behavior.
extensions/napkin-context/index.ts Switched to new Napkin(cwd) and attempted to use n.vault.configPath for config/status behavior.
extensions/distill/index.ts Switched to Napkin-derived vault config path rather than local resolver.
README.md Updated vault resolution order and added migration steps for the new global config path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

const { showStatus, distill: config } = loadVaultConfig(vaultPath);
const { showStatus, distill: config } = loadVaultConfig(vaultConfigPath);
}

if (ctx.hasUI && loadShowStatus(vaultPath)) {
if (ctx.hasUI && loadShowStatus(n.vault.configPath)) {
}

const { showStatus, distill: config } = loadVaultConfig(vaultPath);
const { showStatus, distill: config } = loadVaultConfig(vaultConfigPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants