How pulseaiclub/phi works
Phi is a terminal coding-agent harness. A user starts an interactive or headless run; the TUI controller or CLI run path drives an agent loop, which streams model responses, executes permitted tools, and records the conversation. The graph also shows sub-agents, MCP, extensions, configuration, session persistence, and the documented diff-review and code-view features. README capabilities guide the unsampled branches; arrows are limited to documented behavior and sampled wiring.
Main entry points: engine.go Agent engine · controller.go TUI controller · main.go CLI commands · executor.go Tool executor
Components 22
User interaction
- CLI commands
cmd/main.go - Terminal UI
internal/components/app/app.go - TUI controller
internal/tui/controller/controller.go - Diff review
internal/util/diffreview - Code viewer
internal/components/codeview - Config editor
internal/tui/configui
Agent runtime
- Agent engine
internal/agent/engine.go - Tool executor
internal/agent/executor.go - Sub-agent jobs
internal/job/manager.go - Child agent runner
internal/agent/engine_runner.go
Models and tools
- Provider client
internal/llm/client/client.go - Built-in tools
internal/tools/tools.go - Permission gate
internal/permission/gate.go
Project integrations
- MCP clients
internal/mcp/client.go - Extension runner
internal/extension/runner.go - Skills catalog
internal/llm/skills/skills.go
Configuration and state
- Project config
internal/project/project.go - Session manager
internal/session/manager.go - Session files
internal/session/manager.go - Job store
internal/job/store.go
Other components
- User
- Model providers
Connections 26
- User → CLI commands: runs command
- CLI commands → Terminal UI: starts TUI
- CLI commands → TUI controller: starts headless run
- User → Terminal UI: interacts
- Terminal UI → TUI controller: dispatches input
- TUI controller → Agent engine: starts prompt loop
- Agent engine → Provider client: requests completion
- Provider client → Model providers: sends request
- Model providers → Provider client: streams response
- Agent engine → Tool executor: runs tool calls
- Tool executor → Built-in tools: dispatches tools
- Tool executor → Permission gate: checks policy
- Agent engine → Session manager: reads and appends
- Session manager → Session files: persists entries
- Agent engine → Sub-agent jobs: spawns sub-agents
- Sub-agent jobs → Child agent runner: runs job
- Child agent runner → Agent engine: runs child loop
- Sub-agent jobs → Job store: persists job data
- Agent engine → MCP clients: uses MCP tools
- Agent engine → Extension runner: runs extension hooks
- TUI controller → Project config: loads project config
- Agent engine → Skills catalog: loads skill instructions
- User → Config editor: edits settings
- Config editor → Project config: updates config
- User → Diff review: reviews changes
- User → Code viewer: views source