antinomie-lab/pi-book

Source-backed architecture notes on building an agent

What it solves

Reading source code of a real agent framework can be overwhelming: you have to jump between files, trace callbacks, and keep the whole loop in your head. This project turns that journey into a structured, multi-language architecture book. It takes the @earendil-works/pi-agent-core package from the pi repository and explains, step by step, how that agent loop is constructed, what promises it makes, what it deliberately refuses to do, and where the key design fulcrums are.

The book is written against a specific commit of the pi repository (cd20a8d2e), so every claim can be checked against the exact code it refers to. It also embeds every code reference as file:line with a quoted snippet, so you never have to leave the page to verify a statement.

How it works

The book is organized in three parts that mirror a good mental model for understanding a system:

  • Whole — establishes the correct overall picture without implementation details, so you can sketch the system from memory after reading.
  • Parts — goes through each component in dependency order; each chapter only relies on previous ones.
  • Cross-cutting — handles concerns that don't belong to any single component.

The Chinese original lives in agent/ as the single source of truth, with English and Spanish translations in agent/en/ and agent/es/. A web reader (Vite + Vue) renders the content with code-hightlighted citations and a language switcher. A plain Markdown version is also available for local reading or for use with AI tools.

Who it's for

Readers who can read TypeScript and are familiar with basic LLM API concepts (messages, tool calls, streaming), but do not need prior knowledge of the pi repository. It's for developers who want to deeply understand how a production-grade agent loop is built, rather than just use one as a black box.

Highlights

  • Code-first architecture book: every claim is tied to a file:line reference with an inline quote, so you can verify without opening an editor.
  • Written against a fixed commit of the pi repository, ensuring the analysis is reproducible and current.
  • Three-part structure (whole → parts → cross-cutting) that follows dependency order for easy comprehension.
  • Trilingual: Chinese original, English and Spanish translations, switchable in the web reader.
  • Two reading modes: an immersive web version with highlighted citations, or a Markdown download for local and AI-assisted exploration.

Related

  • Project
  • Project
  • Project
  • Project