{"slug": "i-built-an-ai-reading-companion-with-tree-structured-conversations", "title": "I Built an AI Reading Companion with Tree-Structured Conversations", "summary": "A developer built pi-tree, a self-hosted AI reading companion that uses tree-structured conversations to allow branching and backtracking during reading sessions. Unlike typical RAG-based tools, pi-tree gives the AI precise, on-demand access to content via tools like process_book and search_papers, and supports customization through skills, session profiles, and plugins.", "body_md": "**AI makes you productive where you already understand. It confuses you where you don't.**\n\nI've been reading non-fiction with AI assistants for a while, and I kept hitting the same wall: 30 messages into a conversation about a dense book chapter, the AI starts losing the thread. I'd branch into a tangent — \"how does this connect to what Kahneman said about System 1?\" — and suddenly the entire chat context is polluted. No way to get back to where I was.\n\nSo I built [ pi-tree](https://github.com/shuowu/pi-tree) — a self-hosted AI reading companion where the conversation\n\nWhen you think through complex material, your mind doesn't work linearly. You branch — *\"wait, how does this relate to X?\"* — explore for a bit, then come back. But every AI chat tool forces you into a flat thread where everything piles up.\n\nTree-structured conversations fix this at the architecture level:\n\nHere's what a reading session looks like:\n\n```\n📖 Reading: Thinking, Fast and Slow (Kahneman)\n\nRoot\n├── What is System 1 vs System 2?\n│   ├── How does this relate to cognitive biases?\n│   │   └── Anchoring bias deep-dive\n│   └── Real-world examples in decision making\n├── Chapter 3: The Lazy Controller\n│   └── Why do we avoid effortful thinking?\n└── Comparison with Nassim Taleb's ideas\n    ├── Black Swan connection\n    └── Antifragility and heuristics\n```\n\nAnd here's the actual UI — tree sidebar on the left, conversation in the center, table of contents on the right:\n\nMost \"chat with your documents\" tools use RAG — chunk your content into embeddings, then retrieve what *seems* relevant. The problem: retrieval is approximate. The AI gets semantically similar chunks, not necessarily the *right* context.\n\nPi-tree takes an agentic approach: the AI has **tools** that give it precise, on-demand access to your content — more like `grep`\n\nthan vector search. It can look up a specific chapter, fetch a paper's methodology section, or scan today's RSS feeds. The context is exact, structural, and requested when needed — not pre-computed and hoped for.\n\nEach source type gets purpose-built tools:\n\n`process_book`\n\nparses EPUB/MOBI/PDF, extracts chapter structure, builds a navigable outline`get_latest_rss`\n\n, `search_rss`\n\ncrawl your feeds, find trends across sources`search_papers`\n\n, `get_paper_info`\n\nquery arXiv, fetch and contextualize research`get_youtube_transcript`\n\nextracts transcripts for segment-level discussionThe AI's behavior is then shaped by **skills** — markdown instruction files that define *how* to read, not just what to retrieve.\n\nHere's a news session — the AI scanned RSS feeds and produced a digest with trends:\n\nEverything is customizable at three levels:\n\n**1. Skills (Markdown files)** — Change how the AI reads by editing a `.md`\n\nfile. No code.\n\n**2. Session Profiles (YAML)** — Map source types to different skills, extensions, and models:\n\n```\nname: book.reading\nskills:\n  - interactive-reading\nextensions:\n  - book\nexclude_tools:\n  - bash\n  - edit\n```\n\n**3. Full Plugins (TypeScript)** — Build new source types with the plugin SDK:\n\n``` js\nimport { definePiTreeExtension } from \"@pi-tree/plugin-sdk\";\n\nexport default definePiTreeExtension((pi, services) => {\n  pi.registerTool({\n    name: \"my_custom_tool\",\n    description: \"Does something useful\",\n    execute: async (args) => {\n      const source = await services.sources.get(args.sourceId);\n      // your logic here\n    }\n  });\n});\n```\n\nThere's also an **MCP bridge** — connect external MCP servers (web search, academic databases, translation APIs) by dropping a JSON config file. Same format as Claude Desktop.\n\n```\ncp .env.example .env   # add your API key\n\ndocker run -d --name pi-tree \\\n  --env-file .env \\\n  -p 3847:3847 \\\n  -v ~/.local/share/pi-tree:/data \\\n  ghcr.io/shuowu/pi-tree:latest\n```\n\nOpen [http://localhost:3847](http://localhost:3847). That's it.\n\nWorks with any OpenAI-compatible API — cloud providers (DeepSeek, Gemini, Claude, OpenAI) or fully offline with Ollama / LM Studio. Reading doesn't need frontier models — a 12B parameter model works well.\n\n| Pi-tree | ChatGPT / Claude | NotebookLM | Obsidian + AI | |\n|---|---|---|---|---|\nFocus |\nComprehension & exploration | General-purpose Q&A | Document Q&A | Note-taking |\nConversations |\n🌳 Tree — branch, explore, return | Linear chat | Linear chat | Linear chat |\nAI approach |\nAgentic — tools & skills over local data | Prompt + context window | RAG over uploads | Plugins over local vault |\nSources |\nBooks, papers, news feeds, YouTube | File uploads, web | Multi-doc notebooks | Markdown vault |\nExtensibility |\nSkills, plugins, MCP bridge | GPTs (cloud-hosted) | None | Community plugins |\nModel choice |\nBYOK — any provider or local | Vendor-locked | Google only | Plugin-dependent |\nData |\nLocal-first, self-hosted | Cloud | Cloud | Local |\n\n**License:** AGPL-3.0 — fully open source.\n\nI'd love feedback on:\n\nBuilt on the [Pi SDK](https://pi.dev/docs/latest/sdk) for tree-structured agent sessions.", "url": "https://wpnews.pro/news/i-built-an-ai-reading-companion-with-tree-structured-conversations", "canonical_source": "https://dev.to/shuo_wu_00d47f641aed077d6/i-built-an-ai-reading-companion-with-tree-structured-conversations-3n4i", "published_at": "2026-06-24 01:51:13+00:00", "updated_at": "2026-06-24 02:13:20.455365+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-tools", "ai-products", "developer-tools", "large-language-models"], "entities": ["pi-tree", "Kahneman", "Nassim Taleb", "arXiv", "Ollama", "LM Studio", "DeepSeek", "Claude"], "alternates": {"html": "https://wpnews.pro/news/i-built-an-ai-reading-companion-with-tree-structured-conversations", "markdown": "https://wpnews.pro/news/i-built-an-ai-reading-companion-with-tree-structured-conversations.md", "text": "https://wpnews.pro/news/i-built-an-ai-reading-companion-with-tree-structured-conversations.txt", "jsonld": "https://wpnews.pro/news/i-built-an-ai-reading-companion-with-tree-structured-conversations.jsonld"}}