3zh22 downloadsEmbed the pi coding agent in a sidebar: chat alongside your notes and reference the current note, selection, or pasted image.
English | 中文说明
Run the pi coding agent in an Obsidian sidebar: chat next to your notes, and send the current note, the current selection, or a pasted image to pi with one click. pi reads and writes your vault directly.
Author 3zh | License MIT | Repo https://github.com/zzzzzllllllaaaa/obsidian-pi-panel
From the community directory (recommended)
Manually, from a GitHub release
main.js, manifest.json and styles.css from the latest release<your vault>/.obsidian/plugins/pi-panel/pi --help in a terminal).pi — GUI apps often miss npm's global bin directory — set the absolute path in the plugin settings, for example %APPDATA%\npm\pi.cmd.Pi Panel: Open panel command. Streaming replies with thinking blocks (collapsible) and tool-call cards showing name, arguments, duration and output; failed calls expand automatically.Note sends the note you have open (very long notes are sent as @path only), Selection sends the selected paragraphs with file and line numbers. Images can be pasted or dragged into the panel; other dropped files are inserted as @path.ctx 30% · 59k/200k · 4.9M tok); click it for input / output / cache numbers, tool-call count and cost when pi reports one.~/.pi/agent/sessions/, replay a session, rename it, or start fresh.models.json from the settings page.--tools is what pi gets. Nothing is enabled behind your back.AGENTS.md, while your notes stay in the vault.| Setting | Meaning |
|---|---|
| pi executable | Default pi; an absolute path also works |
| Tool permissions | The --tools allow-list. Empty = pass nothing, i.e. all of pi's default tools (including bash) |
| Session | New session (saved) / Continue last (--continue) / Don't save (--no-session) |
| Inline note limit | Above this size only @path is sent. Default 20000 characters |
| Working directory | pi's cwd. Empty = vault root. May differ from the notes folder |
| Extra system prompt file | Passed to --append-system-prompt, e.g. a project's AGENTS.md |
| Default model | Passed as --model provider/id at startup; the header lets you switch on the fly |
| AI operation log | Turns the operation-log panel on/off |
| Folders to watch | One vault-relative folder per line, e.g. Notes/Drafts. / or * = the whole vault, empty = record nothing |
pi's built-in tools are read, bash, edit, write, grep, find, ls. The plugin turns your checkboxes into --tools <list> — a session without bash has no shell in pi, so it cannot change directories or run commands.
Three presets:
| Preset | Value | Effect |
|---|---|---|
| Read only | read,grep,find,ls |
Can only look |
| Read & write | read,write,edit,grep,find,ls |
Can modify files, cannot run commands |
| Full (with bash) | read,write,edit,grep,find,ls,bash |
Same as pi's own default |
--tools is not passed at all, so pi keeps all of its default tools.bash, the panel says so in the chat and marks no bash in the debug log.At startup pi looks for AGENTS.md / CLAUDE.md in ~/.pi/agent/, then in every parent directory of its working directory, then in the working directory itself.
The panel's working directory defaults to your vault root, so a rules file that lives in some project folder is not read. Two fixes:
@ search change with it).Changing either setting restarts the pi process in the panel; the next message uses it. Remember that a rules file telling pi to run shell commands needs bash in the allow-list.
The History button in the header lists sessions found in ~/.pi/agent/sessions/<cwd slug>/*.jsonl:
--session <file> and replays that session's history.New session and Continue last (--continue).Click the model line in the panel header (for example deepseek-v4-flash · persist · 3 msgs) to open the model picker:
get_available_models (built-in plus your models.json), grouped by provider.☆ pins a model to a "Favorites" section.set_model) and remembers the choice for the next start.provider/id by hand.Manage models… edits ~/.pi/agent/models.json: add or edit providers (name, api type, baseUrl, apiKey, compat.supportsDeveloperRole) and models (id, display name, api, contextWindow, maxTokens, reasoning, image input, cost).Every save is validated locally first — invalid input is rejected, and the previous file is backed up as models.json.bak-<timestamp>. This matters because pi's model registry drops the whole file if any single entry is invalid, and the only symptom is a shorter model list.
Mobile Obsidian has no way to run pi locally, so the plugin can talk to pi on your computer over a WebSocket:
mobile Obsidian ──ws──> bridge on your computer ──spawn──> pi --mode rpc
WS /rpc, GET /sessions?cwd=, POST /sessions/rename, GET/PUT /models, GET /health).ws://<computer-ip>:8770, bridge token = the token that bridge was started with.ws://100.x.x.x:8770), or expose it behind your own TLS relay and use wss://.Limits:
models.json editor is unavailable in remote mode (the file lives on the computer — edit it there).read,grep,find,ls, add write,edit if you need edits). bash means the phone can drive the whole computer.A separate view (Pi Panel: Open AI operation log, or the list icon in the ribbon) that lists vault changes seen while the plugin is running:
/ (or *) there to record the whole vault — .obsidian and the trash are always skipped.Refresh re-renders, Clear empties the list (the notes themselves are never touched).data.json.Note that it records what changed in the watched folders, not which process changed it: an edit you make by hand is listed too. Use it as an activity trail, not as an audit log.
Three entry points: the bug button in the panel header, the Pi Panel: View debug log command, or "Open log" in the settings.
The dialog shows environment details (plugin version, Obsidian version, platform, pi path, working directory, vault root, the actual spawn command line, session mode, tool allow-list, default model, status, log path) plus the raw SEND / RECV JSONL, STDERR, ERROR entries with stack traces, and user actions. Copy all puts environment and log on the clipboard.
The log is also written to <vault>/.obsidian/plugins/pi-panel/pi-panel-debug.log (rotated to .1 past 5 MB). Streaming text deltas are omitted so the file stays readable; other events are stored verbatim, truncated at 6000 characters per line. When reporting a problem, paste Copy all — it usually identifies the cause immediately.
~/.pi/agent/ — pi's own configuration and session records (models.json, sessions/*.jsonl), read and written by the History and model manager features;AGENTS.md or project files there;%APPDATA%\npm\pi.cmd);data.json, when remote mode is enabled.data.json. Only folders you list under Folders to watch are inspected, and nothing is uploaded.pi on your machine (child_process, desktop only and loaded lazily — never on mobile). Closing the panel stops that process.bash grants command execution; judge accordingly.MIT — use it however you like, commercially included.
Bug reports and ideas: GitHub Issues. This is a personal project and I make no promise about a maintenance schedule.
在 Obsidian 侧边栏里跑 pi coding agent:边看笔记边提问,一键把当前笔记、选中段落或粘贴的图片丢给 pi,pi 直接读写你的库。
从社区目录装(推荐)
手动装(从 GitHub Release)
main.js、manifest.json、styles.css<你的库>/.obsidian/plugins/pi-panel/pi --help 能用)。pi(GUI 进程的 PATH 常常没有 npm 全局 bin),在设置里填绝对路径,例如 %APPDATA%\npm\pi.cmd。Pi 面板:打开面板。流式输出,thinking 可折叠,工具调用卡片显示名称、参数、耗时、输出,出错自动展开。笔记 按钮给当前打开的笔记(超长只给 @路径),选区 按钮给选中段落(带文件:行号)。图片可粘贴,也可直接把文件拖进面板;拖进来的其它文件按 @路径 插入。ctx 30% · 59k/200k · 4.9M tok),点开看 input / output / cache 明细、工具调用次数,pi 报了 cost 才有金额。~/.pi/agent/sessions/,列表顶部有搜索框(按名字 / 首条摘要 / 会话 id / 工作目录 / 文件路径过滤),可回放、可重命名、可开新会话。models.json。--tools 传什么就是什么,不会背着你开权限。AGENTS.md 的项目目录,笔记仍在库里。| 项 | 说明 |
|---|---|
| pi 可执行文件 | 默认 pi,也可填绝对路径 |
| 工具权限 | --tools 白名单。留空 = 不传,即 pi 默认的全部工具(含 bash) |
| 会话 | 新会话并存盘 / 继续上次(--continue) / 不保存(--no-session) |
| 内联笔记上限 | 超过则只给 @路径,默认 20000 字符 |
| 工作目录 | pi 的 cwd,留空 = vault 根;可与笔记目录不同 |
| 附加系统提示文件 | 传给 --append-system-prompt,例如项目里的 AGENTS.md |
| 默认模型 | 启动时用 --model provider/id;面板头可即时切换 |
| AI 操作记录 | 开关该面板 |
| 监听目录 | 每行一个 vault 相对路径,例如 笔记/草稿;/ 或 * = 整个库,留空 = 不记 |
pi 内置工具:read bash edit write grep find ls。面板把勾选拼成 --tools <列表> —— 没勾 bash 的会话里 pi 就没有 shell,连列目录、跑命令都做不到。
三个预设:
| 预设 | 值 | 效果 |
|---|---|---|
| 只读 | read,grep,find,ls |
只能看 |
| 读写 | read,write,edit,grep,find,ls |
能改文件,不能跑命令 |
| 全部(含 bash) | read,write,edit,grep,find,ls,bash |
等同 pi 官方默认 |
--tools,即 pi 默认的全部工具。bash 时,面板会在聊天里提示,调试日志里也会标注「无 bash」。pi 启动时按这个顺序找 AGENTS.md / CLAUDE.md:~/.pi/agent/ → cwd 的各级父目录 → cwd 本身。
面板默认 cwd 是 vault 根,所以放在某个项目目录里的规则文件不会被读到。两种修法:
@ 搜索也跟着变)。改完设置会自动重启面板里的 pi 进程,下一条消息生效。另外:规则里若有跑命令的步骤,记得把 bash 加进白名单。
头部 历史 按钮列出 ~/.pi/agent/sessions/<cwd slug>/*.jsonl:
--session <文件> 重启 pi 并回放该会话历史。新会话 / 继续上次(--continue)。面板头那行模型名(如 deepseek-v4-flash · persist · 3 msgs)点一下打开模型选择器:
get_available_models(内置 + models.json 自定义),按 provider 分组。☆ 收藏 → 下次置顶显示。set_model),并记为下次启动的默认值。provider/id。~/.pi/agent/models.json:供应商(名字 / api 类型 / baseUrl / apiKey / compat.supportsDeveloperRole)与模型(id、显示名、api、contextWindow、maxTokens、reasoning、图片输入、cost)。保存前会本地校验:校验不过就拒绝写盘,并把原文件备份成 models.json.bak-<时间戳>。这条很关键 —— pi 的模型注册表遇到任何一个不合法条目就会丢弃整个文件,界面不报错,只表现为模型列表变少。
手机装不了 pi,所以由插件用 WebSocket 连电脑上的桥:
手机 Obsidian ──ws──> 电脑上的桥 ──spawn──> pi --mode rpc
WS /rpc、GET /sessions?cwd=、POST /sessions/rename、GET/PUT /models、GET /health)。ws://<电脑IP>:8770,桥 token = 启动桥时用的那个。ws://100.x.x.x:8770),或者把桥放到自己的 TLS 中继后面用 wss://。限制:
models.json 管理器不可用(文件在电脑上,请在电脑上改)。read,grep,find,ls,要改笔记再加 write,edit)。给了 bash = 手机能操作你整台电脑。独立面板(命令 Pi 面板:打开 AI 操作记录面板,或左侧 ribbon 的列表图标),列出插件运行期间监听到的库内变更:
/(或 *)= 整个库,.obsidian 和回收站永远跳过。刷新 重画,清空 只清列表(不动笔记)。data.json。它记的是「监听目录里变了什么」,不是「谁改的」:你自己手改的也会被列出来。当活动轨迹看,别当审计日志。
三个入口:面板头 🐞 按钮 / 命令 Pi 面板:查看调试日志 / 设置页「打开日志」。
弹窗里有环境信息(插件版本、Obsidian 版本、平台、pi 路径、工作目录、vault 根、实际 spawn 的命令行、会话模式、工具白名单、默认模型、状态、日志路径),以及原始的 SEND / RECV JSONL、STDERR、ERROR(含堆栈)、用户操作。复制全部 会把环境信息与日志一起放进剪贴板。
日志同时落盘到 <vault>/.obsidian/plugins/pi-panel/pi-panel-debug.log(超 5MB 轮转成 .1)。流式文本增量不记录,避免刷爆;其他事件记原文,单行截断 6000 字符。报问题时把「复制全部」的内容贴出来即可,一般一眼能定位。
~/.pi/agent/ —— pi 自己的配置与会话记录(models.json、sessions/*.jsonl),「历史会话」与「模型管理」直接读写这里;AGENTS.md / 项目文件;%APPDATA%\npm\pi.cmd);data.json 里)。data.json —— 相对路径、时间、变更类型、文件前 160 字。只读你填在监听目录里的文件夹,不上传任何内容。pi(child_process,仅桌面端且惰性加载,移动端不加载)。关面板会杀掉这个进程。bash 就是给了命令执行权,请自行评估。MIT —— 随便用,商用也行。
意见与 bug 走 GitHub Issues。本插件为个人项目,不承诺维护节奏。