PiChat

approved

by Geng

Forked from sigilmakes/obsidian-pi-plugin

This plugin has not been manually reviewed by Obsidian staff. Chat with Pi coding agent locally.

31 downloadsUpdated 8d agoMIT

PiChat

Chat with the Pi coding agent inside Obsidian. Conversations render as native Obsidian markdown with full support for code highlighting, Mermaid diagrams, callouts, and wiki-links.

Desktop only. Requires Pi installed locally (npm i -g @earendil-works/pi-coding-agent).

System access: This plugin reads ~/.pi/agent/ (Pi's config directory) to discover providers, models, and session history. This requires accessing your home directory path via os.homedir().

English | 中文

Features

Chat View

  • Full streaming with live markdown rendering
  • Thinking blocks (expandable, auto-collapses when response starts)
  • Tool call results in collapsible details
  • Native text selection for chat history
  • Steering messages — send while the agent is working to redirect it
  • Abort button to cancel mid-stream
  • Image paste support (base64)
  • File attachment via @ picker

Session Management

  • Header bar — shows session name (click to rename), model, thinking level, and working directory
  • Session sidebar — browse, search, switch, delete, and export Pi's native .jsonl sessions
  • Message persistence — chat history survives session switches and plugin restarts
  • Auto-save — conversations saved as markdown notes to your vault on close
  • New Session button with auto-save of current conversation

Command Integration

  • / in chat input opens a command picker with Pi's available commands
  • Pi commands registered in Obsidian's command palette (Ctrl+PPi: /command-name)
  • Commands grouped by source (skill, extension, prompt template)
  • Commands re-fetched per connection (project-scoped)

Model Switching

  • Pi: Switch model command to pick from available models
  • Model and thinking level shown in header and status bar

Status Bar

  • Session name, model, token usage, and cost at a glance
  • Streaming indicator

Setup

  1. Install Pi globally
  2. Clone or download this repo
  3. npm install && npm run build
  4. Copy main.js, styles.css, and manifest.json to your vault's .obsidian/plugins/pi-plugin/
  5. Enable "Pi" in Obsidian → Settings → Community Plugins

Settings

SettingDefaultDescription
Pi binary pathpiPath to the Pi executable
Working directoryvault rootWorking directory for Pi
Default provider(Pi default)LLM provider (anthropic, openai, google, etc.)
Default model(Pi default)Model name
Session save directoryPi-SessionsVault directory for saved conversations
Persist sessionstrueAuto-save conversations as vault notes
Thinking levelmediumReasoning level (none, low, medium, high)

Privacy & System Access

This plugin integrates with your existing Pi installation and needs access to:

PathPurpose
~/.pi/agent/models.jsonDiscover available LLM providers and models
~/.pi/agent/sessions/Browse and load your Pi conversation history
~/.pi/agent/prompts/Custom prompt templates

These paths are resolved using os.homedir() to locate Pi's configuration directory. The plugin does not collect, transmit, or store any system identity information — it only uses these paths to read Pi's local config files.

Architecture

The plugin communicates with Pi via its RPC mode — spawns pi --mode rpc --no-session and exchanges JSON lines over stdin/stdout.

graph LR
    subgraph Obsidian
        View[Chat View]
        Header[Header Bar]
        Panel[Session Panel]
        Store[Message Store]
        Commands[Command Palette]
    end

    subgraph Pi Process
        RPC[RPC Server]
        LLM[LLM API]
        Tools[Tools]
        Sessions[Session Files<br/>.jsonl]
    end

    View -- JSON lines<br/>stdin/stdout --> RPC
    RPC -- streaming events --> View
    Panel -- scan .jsonl --> Sessions
    Store -. persist .-> View
    Commands -- get_commands --> RPC
    RPC --> LLM
    RPC --> Tools
    RPC --> Sessions

Key Modules

FilePurpose
src/rpc.tsSpawn Pi process, JSON line protocol, request/response correlation
src/view.tsChat view — header, messages, input, session panel integration
src/stream-handler.tsProcess RPC events into ChatMessages (text deltas, tool calls, thinking)
src/renderer.tsRender messages as Obsidian markdown
src/session-scanner.tsRead Pi's native .jsonl session files
src/session-panel.tsSession browser sidebar
src/session-list.tsSession list modal for browsing saved conversations
src/message-store.tsPersistent message cache for session history
src/commands.ts/ command suggest and palette registration
src/input.tsChat input with auto-resize, paste, attachments
src/sessions.tsSave/load conversations as markdown vault notes
src/statusbar.tsStatus bar with model, tokens, cost
src/settings.tsPlugin settings

Development

npm install
npm run dev    # watch mode
npm run build  # production build with type checking

Build output is main.js in the repo root. Copy it (along with styles.css and manifest.json) to your vault's plugin directory to test.

License

MIT

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.