Home
Relevant source files
The following files were used as context for generating this wiki page:- AGENTS.md
- packages/mom/src/agent.ts
- packages/web-ui/src/utils/test-sessions.ts
- packages/tui/test/markdown.test.ts
- packages/web-ui/src/prompts/prompts.ts
- packages/coding-agent/src/main.ts
- packages/mom/README.md
- packages/web-ui/example/src/test-sessions.ts
- packages/coding-agent/src/tui/tui-renderer.ts
- README.md
- packages/web-ui/example/README.md
- package.json
- packages/coding-agent/src/tools-manager.ts
- packages/mom/CHANGELOG.md
- packages/web-ui/src/tools/artifacts/artifacts-tool-renderer.ts
The Pi Monorepo is a collection of tools and libraries for building AI agents and managing Large Language Model (LLM) deployments. The project is structured as a monorepo containing several distinct npm packages, each serving a specific purpose within the ecosystem, from providing a unified LLM API to offering interactive CLI and web-based chat interfaces.
The architecture emphasizes modularity, allowing components like the agent runtime to be used across different frontends, such as the command-line coding agent or a Slack bot. The project includes development guidelines, a lockstep versioning system, and a structured release process to maintain consistency and quality across all packages.
Sources: README.md:3-4, package.json:4-7
Packages
The monorepo is organized into several packages, each with a specific role.
| Package | Description |
|---|---|
@mariozechner/pi-ai | Unified multi-provider LLM API (OpenAI, Anthropic, Google, etc.) |
@mariozechner/pi-agent | Agent runtime with tool calling and state management |
@mariozechner/pi-coding-agent | Interactive coding agent CLI |
@mariozechner/pi-mom | Slack bot that delegates messages to the pi coding agent |
@mariozechner/pi-tui | Terminal UI library with differential rendering |
@mariozechner/pi-web-ui | Web components for AI chat interfaces |
@mariozechner/pi-proxy | CORS proxy for browser-based LLM API calls |
@mariozechner/pi | CLI for managing vLLM deployments on GPU pods |
Sources: README.md:7-18
Architecture Overview
The following diagram illustrates the relationships between the main packages in the monorepo.
This diagram shows how different user-facing applications (pi-coding-agent, pi-web-ui, pi-mom) are built on top of the core pi-agent and pi-ai libraries.
Sources: README.md:7-18
Key Components
@mariozechner/pi-coding-agent
This is an interactive coding assistant for the command line. It supports various tools for file system operations and command execution.
Features:
- Interactive & Non-interactive Modes: Can be run as a persistent TUI application or in a "single-shot" mode that processes a prompt and exits (
--print). - Session Management: Supports continuing previous sessions (
--continue) or resuming a selected session (--resume). - File Context: Users can include file contents in the prompt using the
@filesyntax. - Tool Selection: The set of available tools can be configured via the
--toolsflag. - System Prompt Customization: The system prompt can be replaced (
--system-prompt) or appended to (--append-system-prompt).
Sources: packages/coding-agent/src/main.ts:80-165
The agent's behavior is configured through a system prompt that outlines its capabilities, available tools, and operational guidelines.
This flow shows the initialization process of the coding agent, from parsing arguments to selecting the execution mode.
Sources: packages/coding-agent/src/main.ts:1145-1393
@mariozechner/pi-mom
mom is a self-managing Slack bot that uses the agent core to interact with a development environment. It responds to @mentions, executes commands, and manages its own workspace.
Workspace Structure:
mom maintains a persistent data directory with a specific structure to manage memory, logs, and custom tools (skills) for each Slack channel.
This diagram shows the hierarchical structure of mom's data directory, separating global and channel-specific resources.
Sources: packages/mom/README.md:120-132
Message Handling Flow:
When mom is mentioned in a Slack channel, it triggers a sequence of actions to generate a response.
This sequence illustrates how a user mention in Slack is processed, leading to tool execution in a sandbox and a final response.
Sources: packages/mom/src/agent.ts:403-596, packages/mom/README.md:65-74
@mariozechner/pi-web-ui
This package provides web components for building AI chat interfaces. The example application demonstrates how to use the ChatPanel component.
Key Features:
- Direct API Calls: The example operates in "Direct Mode," where API calls to LLM providers are made directly from the browser.
- Local API Key Storage: API keys are managed in the UI and stored in the browser's
localStorage. - Tool Support: The web UI integrates with tools like a JavaScript REPL and an "artifacts" tool for creating and managing files.
Sources: packages/web-ui/example/README.md:13-31
The artifacts tool is a core feature, allowing the agent to create, update, and manage persistent files. The UI provides a specialized renderer for this tool.
This diagram shows the ArtifactsToolRenderer class and its relationship with the parameters it receives and the result it produces for rendering.
Sources: packages/web-ui/src/tools/artifacts/artifacts-tool-renderer.ts:38-44
Development Process
The repository defines a standardized development and release workflow to ensure consistency.
Versioning and Publishing
All packages in the monorepo use lockstep versioning, meaning they share the same version number. Version bumps are handled by npm scripts.
| Command | Effect |
|---|---|
npm run version:patch | Bumps the patch version (e.g., 0.7.5 -> 0.7.6) |
npm run version:minor | Bumps the minor version (e.g., 0.7.5 -> 0.8.0) |
npm run version:major | Bumps the major version (e.g., 0.7.5 -> 1.0.0) |
Sources: README.md:50-54
The release process is a multi-step procedure:
- Update
CHANGELOG.mdin the[Unreleased]section. - Run the appropriate
npm run version:*command. - Finalize
CHANGELOG.mdby renaming[Unreleased]to the new version. - Commit the changes and create a git tag.
- Push the commit and tag to the remote repository.
- Publish all packages to npm using
npm run publish. - Add a new
[Unreleased]section toCHANGELOG.mdfor the next cycle.
Sources: README.md:60-88, AGENTS.md:76-101
Agent Development Rules
A set of rules guides the development of AI agents within the project to ensure code quality and consistent behavior.
- Code Quality:
anytypes are forbidden unless strictly necessary. - Commands:
npm run checkmust be run after code changes.npm run devandnpm run buildshould never be run by the agent. - GitHub Issues: Issues must be labeled with
pkg:*tags. Commits that close issues must usefixes #<number>syntax. - Style: Communication should be concise and technical, without emojis or filler text.
- Changelogs: New entries are always added to the
[Unreleased]section. Released sections are immutable.
Sources: AGENTS.md:9-74