Package Exports
- oneagent-cli
- oneagent-cli/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (oneagent-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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)
- Enhanced code graph (5 edge types)
- Incremental indexing (Git-based)
- Parallel embedding generation
- 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: support@oneagent.dev
- π¬ Discord: Join our community
- π Issues: GitHub Issues
- π Docs: Documentation
Made with β€οΈ by the OneAgent Team