This file provides guidance to AI agents (Claude, Cursor, etc.) when working with the dev-agent codebase.
⚠️ IMPORTANT: Before starting any implementation work, readWORKFLOW.mdfor the development workflow, including branch naming, commit format, PR process, and testing standards.
Dev-Agent is a local-first repository context provider for AI tools. It provides semantic code search, GitHub integration, and development planning capabilities through the Model Context Protocol (MCP).
Mission: Enable AI tools to understand codebases without hallucinations by providing accurate, semantic context.
Tech Stack:
- Language: TypeScript (strict mode)
- Package Manager: pnpm 8.15.4
- Build System: Turborepo
- Linter/Formatter: Biome
- Testing: Vitest (1500+ tests)
- Vector Storage: LanceDB
- Embeddings: @xenova/transformers (all-MiniLM-L6-v2)
- Parsers: ts-morph (TypeScript/JS), tree-sitter WASM (Go)
- AI Integration: MCP (Model Context Protocol)
- CI/CD: GitHub Actions
- Node.js: >= 22 (LTS)
Supported Languages: TypeScript, JavaScript, Go, Markdown
packages/
├── core/ # Repository scanning, vector storage, GitHub integration
├── cli/ # Command-line interface (Commander.js)
├── subagents/ # Coordinator, planner, explorer, PR agents
├── mcp-server/ # MCP server with built-in adapters
├── integrations/ # Claude Code, VS Code integrations
└── logger/ # Centralized logging (@lytics/kero)
docs/ # Architecture, workflow documentation
examples/ # Real-world usage examples
scripts/ # Development utilities
# Install dependencies (required first step)
pnpm install
# Build all packages (required before typecheck)
pnpm build
# Run all tests (1100+ tests)
pnpm test
pnpm test:watch
pnpm test:coverage
# Linting and formatting
pnpm lint
pnpm format
# Type checking (run AFTER build)
pnpm typecheck
# Development mode (watch)
pnpm dev
# Clean all build outputs
pnpm clean
# Release management
pnpm changeset
pnpm version
pnpm releaseCritical build dependencies (Turborepo handles automatically):
- @lytics/kero (logger) - No dependencies
- @lytics/dev-agent-core - Depends on logger
- @lytics/dev-agent-cli - Depends on core
- @lytics/dev-agent-subagents - Depends on core
- @lytics/dev-agent-mcp - Depends on core, subagents
- @lytics/dev-agent-integrations - Depends on multiple packages
Critical: Always run pnpm build before pnpm typecheck because TypeScript needs built .d.ts files.
Tests use centralized Vitest configuration at root (vitest.config.ts):
- Test Pattern:
packages/**/*.{test,spec}.ts - Run Command:
pnpm test(NOTturbo test) - Coverage: v8 provider with comprehensive reporting
- Test Count: 1100+ tests (unit + integration)
- Package Aliases: Configured in
vitest.config.tsfor cross-package imports
When Adding Tests:
- Place test files next to source files:
src/myModule.test.ts - Import from source:
import { MyClass } from './myModule' - Run
pnpm testfrom root to verify - For integration tests, use descriptive names:
*.integration.test.ts
- TypeScript: Strict mode enabled, no
anytypes (except tests) - Linter: Biome (config in
biome.json) - Formatter: Biome with auto-fix on save
- Commits: Conventional Commits via Commitlint
- Pre-commit: Husky hooks run typecheck
Commit Message Format:
type(scope): description
Examples:
feat(mcp): add health check adapter
fix(core): resolve vector search timeout
docs: update CLAUDE.md with new tools
chore: update dependencies
Allowed Types: feat, fix, docs, style, refactor, perf, test, chore, ci
- Triggers: Push to main OR Pull Request to main
- Node Version: 22.x (LTS)
- Steps: Install → Lint → Build → Typecheck → Test
- Important: Build runs BEFORE typecheck (required for
.d.tsfiles)
- Triggers: After CI succeeds on main branch
- Tool: Changesets for version management
- Status: Currently disabled (packages are private)
- Future: Enable when ready for npm publishing
Repository scanning, vector storage, GitHub integration, utilities.
Key Components:
- Scanner: TypeScript Compiler API for code analysis
- Indexer: Semantic indexing with LanceDB
- Vector Store: @xenova/transformers embeddings
- GitHub: Issue/PR indexing and search
- Utils: Retry logic, circular buffers
Test Coverage: Extensive unit and integration tests
Command-line interface for repository indexing and MCP setup.
Commands:
dev index <path>- Index repositorydev mcp install [--cursor]- Install MCP integrationdev mcp uninstall [--cursor]- Remove MCP integrationdev mcp list [--cursor]- List MCP serversdev github index- Index GitHub issues/PRs
Specialized agents for development tasks.
Agents:
- ExplorerAgent: Code exploration and pattern analysis
- PlannerAgent: Generate implementation plans from GitHub issues
- PrAgent: PR management and review assistance
Coordinator: Routes tasks to appropriate agents with context management.
MCP server with built-in adapters for AI tools.
Adapters (9 tools):
- SearchAdapter: Semantic code search (
dev_search) - RefsAdapter: Relationship queries - callers/callees (
dev_refs) - MapAdapter: Codebase structure with change frequency (
dev_map) - HistoryAdapter: Semantic git commit search (
dev_history) - StatusAdapter: Repository status (
dev_status) - PlanAdapter: Context assembly for issues (
dev_plan) - InspectAdapter: File analysis and pattern checking (
dev_inspect) - GitHubAdapter: Issue/PR search (
dev_gh) - HealthAdapter: Server health checks (
dev_health)
Features:
- Rate limiting (token bucket, 100 req burst)
- Retry logic (exponential backoff with jitter)
- Auto-reload for GitHub index changes
- Graceful shutdown (no zombie processes)
Centralized logging system with multiple transports and formatters.
Features:
- Multiple log levels (debug, info, warn, error)
- Console and file transports
- JSON and pretty formatters
- Structured logging with metadata
Dev-Agent integrates with AI tools via Model Context Protocol:
Supported Tools:
- Claude Code (via
dev mcp install) - Cursor IDE (via
dev mcp install --cursor)
Dynamic Workspace Detection:
- Cursor: Uses
WORKSPACE_FOLDER_PATHSenv var - Single server config works across all projects
- Automatic context switching
Transport:
- STDIO for direct AI tool communication
- Robust stdin closure detection
- Graceful process cleanup
- Circular Buffers: Prevent unbounded growth in history/metrics
- Max History Size: Configurable (default: 1000 messages)
- Event Cleanup: Proper listener removal on shutdown
- Algorithm: Token bucket with refill
- Default: 100 requests burst, configurable per-tool
- Error: Returns HTTP 429 with
retryAfterMs
- Algorithm: Exponential backoff with jitter
- Default Retries: 3 attempts
- Retriable Errors: ETIMEDOUT, ECONNRESET, rate limits
- Jitter: Prevents thundering herd problem
- Tool:
dev_healthavailable to AI assistants - Components: Vector storage, repository, GitHub index
- Status: healthy, degraded, unhealthy
- Granularity: pass/warn/fail per component
- Create adapter in
packages/mcp-server/src/adapters/built-in/ - Extend
ToolAdapterclass - Implement
getToolDefinition()andexecute() - Add comprehensive tests in
__tests__/ - Register in
bin/dev-agent-mcp.ts - Export from
built-in/index.ts - Update documentation (README, CLAUDE.md)
# Build specific package
pnpm -F "@lytics/dev-agent-core" build
# Watch mode for development
pnpm -F "@lytics/dev-agent-core" dev
# Run package tests
cd packages/core && pnpm test:watch# Document changes
pnpm changeset
# Select packages and version bump type
# Commit the changeset file
git add .changeset/*.md
git commit -m "chore: add changeset for feature X"Problem: Missing types for dependencies
Solution:
pnpm build # Generate .d.ts files
pnpm typecheckProblem: Dependency order issues
Solution:
pnpm clean
pnpm install
pnpm buildProblem: Tests not found or failing
Solution:
- Ensure test pattern matches:
**/*.{test,spec}.ts - Run from root:
pnpm test - Check package aliases in
vitest.config.ts
Problem: Server not starting or zombie processes
Solution:
- Check repository is indexed:
dev index . - Verify storage paths:
~/.dev-agent/indexes/ - Restart AI tool (Cursor/Claude Code)
- Check logs: Use
--verboseflag
Problem: Tool returns 429 errors
Solution:
- Wait for
retryAfterMsperiod - Check rate limit status via
dev_health - Adjust limits in
AdapterRegistryconfig if needed
- Local-First: All data stays on your machine
- No Cloud: No data sent to external services
- Secrets: Never commit
.envfiles or tokens - NPM Token: Stored as GitHub secret (not in code)
- Private Packages: All packages default to private
- Follow conventional commit format
- Add tests for new features
- Run
pnpm lintandpnpm typecheckbefore committing - Use
pnpm changesetto document changes - Ensure all 1100+ tests pass
- Update documentation (README, CLAUDE.md, AGENTS.md)
- Architecture: See
ARCHITECTURE.md - Workflow: See
WORKFLOW.md - Examples: See
examples/directory - Troubleshooting: See
TROUBLESHOOTING.md(coming soon) - Contributing: See
CONTRIBUTING.md
- Repository Level: Semantic Versioning 2.0.0
- Current Version: 0.1.0 (pre-release)
- Git Tags:
vMAJOR.MINOR.PATCH - Package Versions: Follow repository version
Version Bumps:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes, documentation updates
# Common workflows
pnpm install && pnpm build && pnpm test # Full setup
pnpm dev # Watch mode
pnpm lint && pnpm typecheck # Quality checks
dev index . # Index repository
dev mcp install --cursor # Install for Cursor
dev github index # Index GitHub
# Debugging
dev mcp start --verbose # Verbose MCP server
pnpm test:coverage # Check test coverage
pnpm clean && pnpm build # Clean rebuild
# Release (when ready)
pnpm changeset # Document changes
pnpm version # Bump versions
pnpm release # Publish packagesLast Updated: 2025-11-26
Codebase Status: Production-ready with comprehensive stability features
Test Coverage: 1100+ tests passing
AI Integration: Claude Code & Cursor via MCP