How moon-wrecker/tau works
Purpose and Entry Points
Tau is a Python 3.12+ terminal coding agent and reusable agent harness. The installed tau command is implemented by the coding application CLI, supporting interactive Textual TUI and one-shot print mode. Package boundaries are intentional: tau_coding application layer → tau_agent portable orchestration core → tau_ai provider adapters.
• src/tau_coding/cli.py
• src/tau_coding/tui/app.py
• pyproject.toml
Application Composition
tau_coding constructs the coding-specific environment around the generic harness: working directory, system prompt, coding tools, discovered instructions/skills, provider selection, sessions, and frontend choice. CodingSession-oriented modules bridge CLI/TUI commands to the core without making tau_agent depend on filesystem layout or UI.
• src/tau_coding/session.py
• src/tau_coding/system_prompt.py
• src/tau_coding/tools.py
Portable Agent Core
tau_agent defines typed messages, events, tools, provider contracts, and the asynchronous agent loop. AgentHarness accepts a provider, model, system prompt, and typed tools; on each user prompt it streams provider output, executes requested tools, feeds results back into the loop, and emits neutral events to consumers.
• src/tau_agent/harness.py
• src/tau_agent/loop.py
• src/tau_agent/events.py
Provider and Streaming Boundary
tau_ai normalizes Anthropic, Google, Mistral, OpenAI/Codex, and OpenAI-compatible APIs into Tau’s provider-neutral streaming interface. HTTP/retry/error handling and model limits live below the agent boundary, so application code selects providers rather than speaking vendor protocols.
• src/tau_ai/provider.py
• src/tau_ai/stream.py
• src/tau_ai/openai_compatible.py
Provider catalog/config/runtime code resolves configured models and credentials into these adapters. OAuth implementations cover interactive authentication flows, including Anthropic and GitHub Copilot.
• src/tau_coding/provider_catalog.py
• src/tau_coding/provider_runtime.py
• src/tau_coding/oauth_registry.py
Event Consumers and Frontends
Events are the primary integration contract. Print mode renders events as plain text, JSON, or transcript output; the Textual TUI adapts the same stream into state and widgets. This permits custom frontends without modifying the harness.
• src/tau_coding/rendering/base.py
• src/tau_coding/tui/adapter.py
• src/tau_coding/tui/state.py
Material UI runtime dependencies are Textual and Rich; CLI rendering remains outside tau_agent.
Durable Context and Sessions
Session history is append-only JSONL with an in-memory active view and tree/branch semantics. The coding layer manages session discovery, resume, export, statistics, context-window accounting, and compaction, preserving durable history while reducing active model context.
• src/tau_agent/session/jsonl.py
• src/tau_agent/session/tree.py
• src/tau_coding/session_manager.py
Extensibility and Project Context
At startup and during session assembly, Tau discovers project instructions/resources, skills, prompts, configuration, and extensions. Built-in provider/model definitions are data-driven and user overrides can extend the catalog; extensions can register custom behavior such as tools.
• src/tau_coding/resources.py
• src/tau_coding/skills.py
• src/tau_coding/extensions/runtime.py
• src/tau_coding/data/catalog.toml
Main entry points: session.py Coding Session · loop.py Async Agent Loop · provider_runtime.py Provider Runtime · provider.py Provider Interface
Components 19
Coding Application
CLI, sessions, project context, and frontends.
- tau CLI · Selects interactive TUI or one-shot rendering.
src/tau_coding/cli.py - Textual TUI
src/tau_coding/tui/app.py - Coding Session · Bridges coding commands and environment into the portable core.
src/tau_coding/session.py - Prompt & Coding Tools · Builds the system prompt and coding-specific tool set.
src/tau_coding/tools.py - Provider Runtime · Resolves configured models and credentials into adapters.
src/tau_coding/provider_runtime.py - Provider Catalog · Combines data-driven definitions with user overrides.
src/tau_coding/provider_catalog.py - OAuth Registry · Registers interactive provider authentication flows.
src/tau_coding/oauth_registry.py - Project Context · Discovers instructions, resources, skills, and extensions.
src/tau_coding/resources.py - Extension Runtime · Loads extensions that can register custom behavior and tools.
src/tau_coding/extensions/runtime.py - Print Renderers · Renders plain text, JSON, or transcript output.
src/tau_coding/rendering/base.py - TUI Event Adapter · Adapts neutral events into TUI state and widgets.
src/tau_coding/tui/adapter.py
Portable Agent Core
Provider-neutral orchestration and durable context.
- Agent Harness · Accepts model, prompt, provider, and typed tools.
src/tau_agent/harness.py - Async Agent Loop · Streams model output, executes tool calls, and returns results to the model.
src/tau_agent/loop.py - Neutral Events · Provider- and UI-independent stream emitted to consumers.
src/tau_agent/events.py - JSONL Session History · Append-only persisted session history.
src/tau_agent/session/jsonl.py - Session Tree · Maintains active views and branch semantics.
src/tau_agent/session/tree.py
Provider Adapters
Vendor API normalization and streaming.
- Provider Interface · Normalizes provider-neutral model streaming.
src/tau_ai/provider.py - Streaming Layer · Carries normalized provider stream events.
src/tau_ai/stream.py - OpenAI-Compatible Adapter · One adapter family alongside Anthropic, Google, Mistral, and Codex.
src/tau_ai/openai_compatible.py
Connections 24
- tau CLI → Textual TUI: interactive mode
- tau CLI → Print Renderers: print mode
- tau CLI → Coding Session: creates
- Coding Session → Prompt & Coding Tools: assembles
- Coding Session → Project Context: discovers
- Project Context → Extension Runtime: loads
- Extension Runtime → Prompt & Coding Tools: registers tools
- Coding Session → Provider Runtime: selects model
- Provider Catalog → Provider Runtime: definitions
- OAuth Registry → Provider Runtime: credentials
- Provider Runtime → Provider Interface: constructs adapter
- Coding Session → Agent Harness: configures
- Prompt & Coding Tools → Agent Harness: prompt and tools
- Agent Harness → Async Agent Loop: runs
- Async Agent Loop → Provider Interface: streams requests
- Provider Interface → Streaming Layer: normalizes
- OpenAI-Compatible Adapter → Provider Interface: implements
- Streaming Layer → Async Agent Loop: model output
- Async Agent Loop → Neutral Events: emits
- Neutral Events → Print Renderers: renders
- Neutral Events → TUI Event Adapter: adapts
- TUI Event Adapter → Textual TUI: updates
- Coding Session → Session Tree: manages active context
- Session Tree → JSONL Session History: persists branches