|
| 1 | +# Architecture |
| 2 | + |
| 3 | +dev-agent is built as a TypeScript monorepo with specialized packages for different concerns. |
| 4 | + |
| 5 | +## System Overview |
| 6 | + |
| 7 | +``` |
| 8 | +┌─────────────────────────────────────────────────────────────────────┐ |
| 9 | +│ AI Tools │ |
| 10 | +│ (Cursor / Claude Code / VS Code) │ |
| 11 | +└─────────────────────────┬───────────────────────────────────────────┘ |
| 12 | + │ Model Context Protocol (MCP) |
| 13 | +┌─────────────────────────▼───────────────────────────────────────────┐ |
| 14 | +│ MCP Server │ |
| 15 | +│ ┌─────────────────────────────────────────────────────────────┐ │ |
| 16 | +│ │ Adapter Registry │ │ |
| 17 | +│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ |
| 18 | +│ │ │ Search │ │ Plan │ │ Explore │ │ GitHub │ ... │ │ |
| 19 | +│ │ │ Adapter │ │ Adapter │ │ Adapter │ │ Adapter │ │ │ |
| 20 | +│ │ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │ │ |
| 21 | +│ └───────┼────────────┼────────────┼────────────┼───────────────┘ │ |
| 22 | +│ │ │ │ │ │ |
| 23 | +│ ┌───────▼────────────▼────────────▼────────────▼───────────────┐ │ |
| 24 | +│ │ Subagent Coordinator │ │ |
| 25 | +│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ |
| 26 | +│ │ │ Planner │ │ Explorer │ │ PR Agent │ │ │ |
| 27 | +│ │ └──────────┘ └──────────┘ └──────────┘ │ │ |
| 28 | +│ └──────────────────────────────────────────────────────────────┘ │ |
| 29 | +└─────────────────────────┬───────────────────────────────────────────┘ |
| 30 | + │ |
| 31 | +┌─────────────────────────▼───────────────────────────────────────────┐ |
| 32 | +│ Core │ |
| 33 | +│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ |
| 34 | +│ │ Scanner │ │ Indexer │ │ GitHub │ │ |
| 35 | +│ │ (AST Parse) │ │ (Embeddings)│ │ Integration │ │ |
| 36 | +│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ |
| 37 | +│ │ │ │ │ |
| 38 | +│ ┌──────▼─────────────────▼─────────────────▼───────────────────┐ │ |
| 39 | +│ │ Vector Storage │ │ |
| 40 | +│ │ (LanceDB) │ │ |
| 41 | +│ └──────────────────────────────────────────────────────────────┘ │ |
| 42 | +└─────────────────────────────────────────────────────────────────────┘ |
| 43 | +``` |
| 44 | + |
| 45 | +## Packages |
| 46 | + |
| 47 | +### @lytics/dev-agent-core |
| 48 | + |
| 49 | +The foundation layer providing: |
| 50 | + |
| 51 | +- **Scanner** — Multi-language AST parsing using TypeScript Compiler API and ts-morph |
| 52 | +- **Indexer** — Converts code components to vector embeddings |
| 53 | +- **Vector Storage** — LanceDB for fast similarity search |
| 54 | +- **GitHub Integration** — Fetches and indexes issues/PRs via GitHub CLI |
| 55 | + |
| 56 | +### @lytics/dev-agent-cli |
| 57 | + |
| 58 | +Command-line interface: |
| 59 | + |
| 60 | +```bash |
| 61 | +dev index . # Index repository |
| 62 | +dev mcp install # Install MCP integration |
| 63 | +dev gh index # Index GitHub issues/PRs |
| 64 | +dev status # Check indexing status |
| 65 | +``` |
| 66 | + |
| 67 | +### @lytics/dev-agent-mcp |
| 68 | + |
| 69 | +MCP server with tool adapters: |
| 70 | + |
| 71 | +- **AdapterRegistry** — Manages tool registration and execution |
| 72 | +- **Built-in Adapters** — Search, Plan, Explore, GitHub, Status, Health |
| 73 | +- **Rate Limiting** — Token bucket algorithm (100 req burst) |
| 74 | +- **Retry Logic** — Exponential backoff with jitter |
| 75 | + |
| 76 | +### @lytics/dev-agent-subagents |
| 77 | + |
| 78 | +Specialized AI agents: |
| 79 | + |
| 80 | +- **PlannerAgent** — Generates implementation plans from issues |
| 81 | +- **ExplorerAgent** — Code pattern analysis and relationship mapping |
| 82 | +- **PRAgent** — PR management and review assistance |
| 83 | +- **Coordinator** — Routes tasks to appropriate agents |
| 84 | + |
| 85 | +### @lytics/kero |
| 86 | + |
| 87 | +Centralized logging: |
| 88 | + |
| 89 | +- Multiple log levels (debug, info, warn, error) |
| 90 | +- Console and file transports |
| 91 | +- JSON and pretty formatters |
| 92 | +- Structured metadata |
| 93 | + |
| 94 | +## Key Technologies |
| 95 | + |
| 96 | +| Component | Technology | Purpose | |
| 97 | +|-----------|------------|---------| |
| 98 | +| Language | TypeScript (strict) | Type safety | |
| 99 | +| Build | Turborepo | Monorepo orchestration | |
| 100 | +| Testing | Vitest | 1100+ tests | |
| 101 | +| Linting | Biome | Fast linting/formatting | |
| 102 | +| Vector DB | LanceDB | Embedded vector storage | |
| 103 | +| Embeddings | @xenova/transformers | Local ML inference | |
| 104 | +| Model | all-MiniLM-L6-v2 | Sentence embeddings | |
| 105 | +| Protocol | MCP | AI tool integration | |
| 106 | + |
| 107 | +## Data Flow |
| 108 | + |
| 109 | +### Indexing Flow |
| 110 | + |
| 111 | +``` |
| 112 | +Source Code |
| 113 | + │ |
| 114 | + ▼ |
| 115 | +┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ |
| 116 | +│ Glob │ ──▶ │ Parse │ ──▶ │ Extract │ ──▶ │ Embed │ |
| 117 | +│ Files │ │ AST │ │Components│ │ Vectors │ |
| 118 | +└──────────┘ └──────────┘ └──────────┘ └──────────┘ |
| 119 | + │ |
| 120 | + ▼ |
| 121 | + ┌──────────┐ |
| 122 | + │ LanceDB │ |
| 123 | + └──────────┘ |
| 124 | +``` |
| 125 | + |
| 126 | +### Query Flow |
| 127 | + |
| 128 | +``` |
| 129 | +User Query: "Where is auth handled?" |
| 130 | + │ |
| 131 | + ▼ |
| 132 | +┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ |
| 133 | +│ Embed │ ──▶ │ Vector │ ──▶ │ Rank │ ──▶ │ Format │ |
| 134 | +│ Query │ │ Search │ │ Results │ │ Output │ |
| 135 | +└──────────┘ └──────────┘ └──────────┘ └──────────┘ |
| 136 | +``` |
| 137 | + |
| 138 | +## Storage |
| 139 | + |
| 140 | +All data is stored locally in `~/.dev-agent/`: |
| 141 | + |
| 142 | +``` |
| 143 | +~/.dev-agent/ |
| 144 | +├── indexes/ |
| 145 | +│ └── <repo-hash>/ |
| 146 | +│ ├── code.lance/ # Code vector index |
| 147 | +│ └── metadata.json # Index metadata |
| 148 | +├── github/ |
| 149 | +│ └── <repo-hash>/ |
| 150 | +│ ├── issues.lance/ # Issues vector index |
| 151 | +│ └── prs.lance/ # PRs vector index |
| 152 | +└── config.json # Global config (optional) |
| 153 | +``` |
| 154 | + |
| 155 | +## Security |
| 156 | + |
| 157 | +- **100% Local** — No data sent to external services |
| 158 | +- **No Cloud** — All processing happens on your machine |
| 159 | +- **Embeddings** — Generated locally via @xenova/transformers |
| 160 | +- **GitHub Data** — Fetched via authenticated GitHub CLI |
| 161 | + |
0 commit comments