src/ai/ module provides AI-powered features using Mastra, an open-source AI agent framework. AI is deeply integrated into wit, not bolted on.
Overview
Key Files
| File | Purpose |
|---|---|
mastra.ts | Mastra configuration and instance management |
agent.ts | Main wit agent definition |
types.ts | Type definitions |
tools/ | 32+ agent tools |
workflows/ | Multi-step AI workflows |
agents/ | Specialized agents (code, PM, triage) |
services/ | AI services (PR review, conversation) |
Mastra Configuration
wit uses Mastra for agent orchestration with support for multiple LLM providers.LLM Provider Configuration
wit Agent
The main agent handles natural language Git operations.Agent Modes
The agent supports different operational modes:Tools
Tools are the building blocks that give agents capabilities. wit provides 32+ tools.Tool Categories
Git Operations
| Tool | Description |
|---|---|
getStatus | Get repository status |
getDiff | Get diff of changes |
stageFiles | Stage files for commit |
createCommit | Create a commit |
getLog | Get commit history |
getBranches | List branches |
createBranch | Create new branch |
switchBranch | Switch to branch |
undo | Undo last operation |
File Operations
| Tool | Description |
|---|---|
readFile | Read file contents |
writeFile | Write file |
editFile | Edit file with diff |
listDirectory | List directory contents |
runCommand | Execute shell command |
Virtual Filesystem (Sandbox)
| Tool | Description |
|---|---|
virtualReadFile | Read from virtual FS |
virtualWriteFile | Write to virtual FS |
virtualEditFile | Edit in virtual FS |
virtualListDirectory | List virtual directory |
virtualStatus | Get virtual FS status |
virtualCommit | Commit virtual changes |
PR & Review
| Tool | Description |
|---|---|
openPullRequest | Create pull request |
generatePRDescription | AI-generate PR description |
reviewPR | AI code review |
getMergeConflicts | List conflicts |
resolveConflict | AI conflict resolution |
Search
| Tool | Description |
|---|---|
search | Text-based code search |
semanticSearch | Vector-based semantic search |
indexRepository | Index repo for search |
getIndexStatus | Check index status |
Tool Implementation
Tools follow the Mastra tool pattern:Tool Registration
All tools are exported fromsrc/ai/tools/index.ts:
Workflows
Workflows are multi-step AI processes for complex tasks.PR Review Workflow
Issue Triage Workflow
Code Generation Workflow
Multi-Agent Planning Workflow
Running Workflows
Specialized Agents
Code Agent
Focused on autonomous code generation and modification:PM Agent
Project management assistance:Triage Agent
Automated issue triage:Semantic Search
Thesrc/search/ module provides vector-based code understanding.