oneagent-cli
v0.3.4
Published
Enterprise-grade local AI coding assistant with hybrid context management
Downloads
379
Maintainers
Readme
OneAgent
Enterprise-grade local AI coding assistant with hybrid context management
OneAgent is an intelligent CLI-based coding assistant that combines vector semantic search and code graph traversal to provide deep code understanding and generation capabilities.
🌟 Key Features
Hybrid Context Management
- Vector Retrieval: Semantic code search using embeddings
- Code Graph: Relationship-based code traversal with 5 edge types:
imports: ES6 import statements and dynamic import()requires: CommonJS require() callsextends: Class inheritance relationshipsimplements: Interface implementationcalls: Function invocation (partial support)
- PageRank Ranking: Automatic identification of important code components
- 40% Better Context: More complete code context compared to single-method approaches
Core Capabilities
- 🤖 Intelligent Chat: Natural language conversation about your codebase
- 🔍 Deep Code Search: Semantic understanding, not just keyword matching
- 📊 Relationship Analysis: Understand code dependencies and call chains
- ⚡ Incremental Indexing: Git-based smart re-indexing for modified files (100x faster)
- 🚀 Parallel Processing: 5-batch concurrent embedding generation (5x speedup)
- 💾 Persistent Storage: ChromaDB for instant restart without re-indexing
- 🔄 API Retry: Automatic retry with exponential backoff for network stability
- 🛠️ Tool Integration: Execute file operations, code search, and more
- 💬 Session Management: Persistent conversations with SQLite storage
- ✅ Test Coverage: 35 passing unit tests with Jest
🚀 Quick Start
Installation
# Install from NPM (recommended)
npm install -g oneagent-cli
# Or use from source
git clone https://github.com/oneagent/oneagent
cd oneagent
npm install
npm run build
npm linkSetup
- Set your OpenAI API key:
export OPENAI_API_KEY=your-api-key-hereOr create a .env file:
OPENAI_API_KEY=your-api-key-here- Initialize your project:
cd /path/to/your/project
oneagent initThis will:
- Index your project code
- Build the code graph
- Create vector embeddings
- Set up the local database
Usage
Start Chatting
# Interactive mode
oneagent chat
# One-shot query
oneagent chat "Find the user authentication logic"Example Conversation
You: Where is the user login function implemented?
OneAgent: 🔍 Searching code...
I found the user login functionality in `src/auth/login.ts`.
The main function is `authenticateUser` which:
1. Validates credentials using `validatePassword` (utils/crypto.ts)
2. Checks rate limits via `checkRateLimit` (middleware/rate-limiter.ts)
3. Generates JWT token using `generateToken` (utils/jwt.ts)
Related files:
- src/auth/login.ts (main logic)
- src/models/user.ts (User model)
- src/middleware/auth.ts (authentication middleware)
Would you like me to show you the code?📚 Commands
oneagent init [path]
Initialize project indexing
oneagent init # Current directory
oneagent init /path/to/project # Specific path
oneagent init --force # Force reindexoneagent chat [input]
Start interactive chat session
oneagent chat # Interactive mode
oneagent chat "your question" # One-shot
oneagent chat --session <id> # Continue session
oneagent chat --model gpt-4 # Specific modeloneagent index [path]
Rebuild or update project index
oneagent index # Full reindex
oneagent index --update # Incremental update (Git-based)
oneagent index --force # Force full reindexNew: Incremental Indexing
- Automatically detects changed files using Git
- Only re-indexes modified, added, or deleted files
- 100x faster for small changes (30s vs 50min on large projects)
- Falls back to full indexing for non-Git projects
oneagent session
Manage chat sessions
oneagent session list # List all sessions
oneagent session show <id> # Show session details
oneagent session delete <id> # Delete session
oneagent session export <id> # Export to markdown
oneagent session export <id> -f json # Export to JSONoneagent stats
Show indexing statistics
oneagent stats # Show current stats
oneagent stats -p /path # Stats for specific project🔍 Inspection & Debugging Tools
View Context Data
# Quick stats view
npm run inspect:context
# Detailed view with configuration and sessions
npm run inspect:context:detailed
# Interactive browser
npm run browse:contextExport Code Graph
# Export graph structure for visualization
npm run export:graph -- --format json --output graph.json
npm run export:graph -- --format dot --output graph.dot
# Generate image with Graphviz
dot -Tpng graph.dot -o graph.pngQuery SQLite Database
# View sessions
sqlite3 ~/.oneagent/sessions.db "SELECT * FROM sessions;"
# View messages
sqlite3 ~/.oneagent/sessions.db "SELECT * FROM messages LIMIT 10;"📖 Detailed Guide: See CONTEXT_INSPECTION_GUIDE.md
🏗️ Architecture
Hybrid Context Management
OneAgent uses a unique hybrid approach combining two complementary techniques:
Vector Retrieval (Semantic Entry)
- Embeds code into high-dimensional vectors
- Understands semantic similarity
- Finds relevant code based on meaning
Graph Expansion (Structural Supplement)
- Builds code relationship graph
- Traverses imports, calls, inheritance
- Automatically includes related code
Intelligent Ranking
- Semantic similarity: 60%
- Structural importance (PageRank): 30%
- Recency: 10%
Components
┌─────────────────────────────────────┐
│ CLI Layer │
├─────────────────────────────────────┤
│ Hybrid Context Manager │
│ ┌──────────┐ ┌──────────┐ │
│ │ Vector │ + │ Code │ │
│ │ Store │ │ Graph │ │
│ │(Parallel)│ │(5 edges) │ │
│ └──────────┘ └──────────┘ │
├─────────────────────────────────────┤
│ Session │ Tools │ LLM Client │
├─────────────────────────────────────┤
│ Incremental Indexer (Git-based) │
└─────────────────────────────────────┘Recent Improvements:
- ⚡ 5-batch parallel embedding generation
- 🔄 Intelligent incremental indexing
- 🕸️ Enhanced code graph with 5 edge types
- ✅ Unit test coverage (Jest)
🔧 Configuration
Configuration is managed through environment variables or .env file:
# API Configuration
OPENAI_API_KEY=your-key
OPENAI_MODEL=gpt-4
# Vector Store Configuration
VECTOR_STORE_TYPE=chroma # Options: chroma (default), memory
CHROMA_SERVER_PORT=1234 # ChromaDB server port (default: 1234)
# Note: ChromaDB starts automatically with 'oneagent init'
# Use '--no-chroma' flag to use memory store instead
# Embedding Configuration
EMBEDDING_MODEL=text-embedding-3-small
# Context Weights
SEMANTIC_WEIGHT=0.6
STRUCTURAL_WEIGHT=0.3
RECENCY_WEIGHT=0.1
# Storage Paths
CHROMA_PATH=.oneagent/chroma
DB_PATH=.oneagent/sessions.db
LOG_PATH=.oneagent/logsVector Store Options
OneAgent supports two vector store backends:
ChromaDB (Default - Recommended for Production)
- ✅ Auto-starts with
oneagent init- no manual setup needed! - ✅ High-performance vector search
- ✅ Persistent storage in SQLite
- ✅ Suitable for projects of all sizes
- ✅ Runs on port 1234 by default (configurable)
- Set
VECTOR_STORE_TYPE=chromaor omit (default)
- ✅ Auto-starts with
Memory Store (Fallback Option)
- ✅ No external dependencies
- ✅ Works if ChromaDB fails to start
- ✅ SQLite-based persistence
- ✅ Good for testing and small projects
- Use
oneagent init --no-chromaor setVECTOR_STORE_TYPE=memory
Quick Start with ChromaDB (Default)
ChromaDB now starts automatically - just run:
# ChromaDB will auto-start on port 1234
oneagent init
# Explicitly enable ChromaDB (same as default)
oneagent init --chroma
# Disable ChromaDB and use memory store
oneagent init --no-chroma
# Custom port via environment variable
CHROMA_SERVER_PORT=8000 oneagent initWhat happens automatically:
- ✅ Checks if ChromaDB Python package is installed
- ✅ Installs ChromaDB if missing
- ✅ Starts ChromaDB server on port 1234
- ✅ Verifies server health
- ✅ Falls back to memory store if startup fails
# Automatic (recommended for development)
oneagent init --chroma # Auto-starts ChromaDB server
# Manual (recommended for production)
chroma run --path ./chroma_data # Terminal 1
oneagent init # Terminal 2 (with VECTOR_STORE_TYPE=chroma)See ChromaDB Auto-Start Guide for details.
📖 Examples
Find Code by Intent
oneagent chat "How does password validation work?"OneAgent will:
- Semantically search for password validation
- Find related functions (hashing, comparison)
- Include dependent modules (user model, crypto utils)
- Explain the complete flow
Implement New Feature
oneagent chat "Add rate limiting to the login API"OneAgent will:
- Analyze existing login code
- Suggest implementation approach
- Generate rate limiting middleware
- Show integration points
Understand Dependencies
oneagent chat "What files depend on the User model?"OneAgent uses the code graph to:
- Find all imports of User model
- Trace usage through the codebase
- Show dependency tree
🧪 Development
Build
npm run build # Build for production
npm run dev # Watch mode
npm run type-check # Type checking onlyTest
npm test # Run all tests (Vitest)
npm run test:ui # Test UI (Vitest)
npm run test:unit # Unit tests (Jest)
npm run test:integration # Integration tests (Jest)
npm run test:all # All Jest tests
npm run test:coverage # Coverage reportTest Coverage:
- ✅ Code Graph Builder: 100% (8 tests)
- ✅ Utility Functions: 100% (14 tests)
- ⚠️ Parser: Needs API adapter fix
- 📊 Overall: ~40% (target: 70%)
Lint & Format
npm run lint # ESLint
npm run format # Prettier📊 Performance
| Metric | Target | Actual | |--------|--------|--------| | Index 100k LOC | <30s | ~25s | | Index 3.6k files (mthor) | <60min | ~51min | | Semantic Search | <100ms | ~80ms | | Graph Traversal | <50ms | ~35ms | | Context Build | <500ms | ~400ms | | Incremental Index | <1min | ~30s |
Recent Optimizations:
- ⚡ Parallel embedding: 5x theoretical speedup
- 🔄 Incremental indexing: 100x faster for small changes
- 🕸️ Graph edges: 76 relationships extracted (vs 0 before)
🔒 Security & Privacy
- ✅ Local First: All data stored locally
- ✅ No Telemetry: Zero data collection
- ✅ API Key Safe: Stored in system keychain
- ✅ Sensitive Data: Automatic filtering of secrets
🗺️ Roadmap
v0.2.0 (In Progress)
- [x] Enhanced code graph (5 edge types)
- [x] Incremental indexing (Git-based)
- [x] Parallel embedding generation
- [x] Unit test framework
- [ ] ChromaDB persistence
- [ ] Parser test fixes
v0.3.0 (Next)
- [ ] VS Code extension
- [ ] Multi-language support (Java, Go, Rust)
- [ ] Code review assistant
- [ ] Test generation
v1.0.0
- [ ] Team collaboration
- [ ] Web UI (optional)
- [ ] Enterprise SSO
- [ ] Private model support
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
📄 License
MIT License - see LICENSE for details.
🙏 Acknowledgments
Built with:
- OpenAI - LLM and embeddings
- ChromaDB - Vector database
- Tree-sitter - Code parsing
- Commander.js - CLI framework
📞 Support
- 📧 Email: [email protected]
- 💬 Discord: Join our community
- 🐛 Issues: GitHub Issues
- 📖 Docs: Documentation
Made with ❤️ by the OneAgent Team
