@vaibhav_dangaich/ai-agent
v1.3.0
Published
Context-aware AI CLI agent with persistent memory - your digital cognitive layer that remembers everything you do
Maintainers
Readme
🤖 AI CLI Agent
A persistent, context-aware AI assistant that lives in your terminal
Your digital cognitive layer — remembers everything, works across devices, learns from your code
🎯 The Problem
Every time you ask ChatGPT or Copilot a question, you waste time explaining:
- What project you're working on
- What you've already tried
- What errors you encountered
- What decisions you made
This agent already knows. It watches your terminal, monitors your files, and remembers everything — across ALL your projects and devices.
✨ Key Features
🧠 Three-Layer Memory System
| Layer | Purpose | Persistence | |-------|---------|-------------| | Episodic | Recent terminal commands, file edits | Session | | Working | Current task, context, blockers | Project | | Semantic | Long-term knowledge via Supermemory | Permanent/Cloud |
🔄 Multi-Device Sync
Work on your laptop, continue on your desktop. Your context follows you via Supermemory cloud sync.
🕷️ Proactive "Spidey Sense"
Agent watches your code and interrupts you with suggestions:
- "This function is 50+ lines. Consider refactoring."
- "You've been stuck on this file for 20 min. Need help?"
- "Similar code found in 3 files. Extract to utility?"
🧠 Cross-Project Intelligence
Remembers solutions across ALL your projects:
"I see you solved a similar auth issue in
project-x6 months ago..."
📚 Personal Knowledge Base (Supermemory-Powered)
- Error Solutions — Never solve the same error twice
- Decision Log — Remember WHY you made architectural choices
- Learning Capture — Build your personal programming wiki
- Code Snippets — Reusable patterns across projects
- Smart Reminders — Context-aware notifications
📝 Auto-Documentation
Generates daily journals explaining:
- What you did
- Why you made those changes
- Gotchas for future-you
🚀 Quick Start
Installation
npm install -g @vaibhav_dangaich/ai-agentSetup
ai initThis will:
- Configure your LLM provider (OpenAI or Gemini)
- Optionally set up Supermemory for cloud sync
- Optionally connect your GitHub for knowledge expansion
First Command
ai ask "what can you do?"📖 Commands Reference
Core Commands
| Command | Description |
|---------|-------------|
| ai ask "question" | Ask the AI with full context |
| ai remember "fact" | Store in long-term memory |
| ai task "description" | Set current task context |
| ai status | Show current context and memory |
| ai history | View conversation history |
Agent Commands
| Command | Description |
|---------|-------------|
| ai watch --proactive | Watch files with AI suggestions |
| ai journal | Auto-generate daily development journal |
| ai journal --weekly | Generate weekly summary |
| ai projects --add | Register project for cross-project intel |
| ai projects --index | Index all projects into Supermemory |
| ai projects --search "query" | Search across all projects |
Knowledge Base Commands
| Command | Description |
|---------|-------------|
| ai error "msg" | Find past error solutions |
| ai error "msg" --solve "fix" | Store an error solution |
| ai decide "decision" --reason "why" | Log architectural decisions |
| ai decide --search "keyword" | Search past decisions |
| ai learned "insight" | Capture learnings |
| ai learned --search "keyword" | Search learnings |
| ai snippet save "name" --code "..." | Save code snippet |
| ai snippet find "name" | Find snippets |
| ai remind "msg" --when "context" | Context-aware reminders |
| ai remind --file "pattern" | Remind when editing specific files |
| ai knowledge | View knowledge base stats |
Integration Commands
| Command | Description |
|---------|-------------|
| ai github --repos | List your GitHub repositories |
| ai github --index | Index all repos into memory |
| ai github --repo owner/name | Index specific repo |
| ai sync | Sync context to cloud |
| ai handoff | Prepare for device switch |
Setup Commands
| Command | Description |
|---------|-------------|
| ai init | Setup wizard for API keys |
| ai setup | Show setup instructions |
| ai supermemory | Debug Supermemory connection |
🏗️ Architecture
┌─────────────────────────────────────────────────────────────────┐
│ CLI Interface │
│ (bin/ai.js) │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ LLM │ │ Memory │ │ Agent Modules │ │
│ │ (LangChain)│ │ (3 Layer) │ │ │ │
│ │ │ │ │ │ • Proactive Watcher │ │
│ │ • OpenAI │ │ • Episodic │ │ • Cross-Project Intel │ │
│ │ • Gemini │ │ • Working │ │ • Journal Generator │ │
│ │ │ │ • Semantic │ │ • Knowledge Base │ │
│ └─────────────┘ └──────┬──────┘ │ • Smart Reminders │ │
│ │ └─────────────────────────┘ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ Supermemory SDK ││
│ │ (Cloud Sync, Semantic Search, Knowledge Store) ││
│ └─────────────────────────────────────────────────────────────┘│
│ │
├─────────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ Monitors ││
│ │ ││
│ │ Terminal (zsh hook) │ File Watcher │ Git Monitor ││
│ └─────────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────────┘File Structure
cli_agent/
├── bin/
│ └── ai.js # CLI entry point (Commander.js)
├── core/
│ ├── agent/
│ │ ├── proactive.js # Spidey Sense analyzer
│ │ ├── crossproject.js # Cross-project intelligence
│ │ ├── journal.js # Auto-documentation
│ │ ├── knowledge.js # Error/Decision/Learning/Snippet store
│ │ └── reminders.js # Context-aware reminders
│ ├── memory/
│ │ ├── episodic.js # Recent activity (session)
│ │ ├── working.js # Current task context
│ │ ├── conversation.js # Chat history
│ │ ├── supermemory.js # Supermemory SDK wrapper
│ │ ├── cloudsync.js # Multi-device sync
│ │ └── index.js # Memory orchestrator
│ ├── monitor/
│ │ ├── terminal.js # Terminal command capture
│ │ ├── filewatcher.js # File change detection
│ │ └── gitmonitor.js # Git diff tracking
│ ├── integrations/
│ │ └── github.js # GitHub API integration
│ ├── llm.js # LangChain LLM wrapper
│ ├── prompt.js # Prompt templates
│ └── config.js # Configuration management
└── hooks/
└── zsh-hook.sh # Shell integration🔧 Technical Deep-Dive
Supermemory Integration
The agent uses Supermemory as its semantic memory backbone. This is a key differentiator — Supermemory provides:
- Semantic Search — Find relevant memories by meaning, not just keywords
- Cloud Sync — Access your knowledge from any device
- Persistent Storage — Memories survive across sessions
- Scalable — Handles thousands of memories efficiently
What gets synced to Supermemory:
| Category | Tag | Description |
|----------|-----|-------------|
| Conversations | conversation-{project} | AI chat history |
| Tasks | task-{project} | Current task context |
| Activities | activity-{project} | Important file edits |
| Errors | error-solutions | Error + solution pairs |
| Decisions | decisions | Architectural decisions |
| Learnings | learnings | Programming insights |
| Snippets | snippets | Reusable code patterns |
| Projects | project-{name} | Cross-project code index |
| GitHub | github-{owner}-{repo} | Repository contents |
SDK Usage Example:
const { Supermemory } = require("supermemory");
const client = new Supermemory({ apiKey: process.env.SUPERMEMORY_API_KEY });
// Store with containerTags for organization
await client.add({
content: "[ERROR SOLUTION]\nError: Cannot read property...\nSolution: Check for null...",
metadata: { containerTags: ["error-solutions", "project-name"] }
});
// Semantic search across all memories
const results = await client.search.memories({
query: "authentication error handling",
limit: 10
});LangChain Integration
Uses LangChain for provider-agnostic LLM calls:
const { ChatOpenAI } = require("@langchain/openai");
const { ChatGoogleGenerativeAI } = require("@langchain/google-genai");
const { ChatPromptTemplate } = require("@langchain/core/prompts");
// Switch between providers based on config
const llm = provider === "openai"
? new ChatOpenAI({ openAIApiKey, modelName: "gpt-4o-mini" })
: new ChatGoogleGenerativeAI({ apiKey, modelName: "gemini-pro" });
// Structured prompts with all context layers
const prompt = ChatPromptTemplate.fromMessages([
SystemMessagePromptTemplate.fromTemplate(SYSTEM_TEMPLATE),
HumanMessagePromptTemplate.fromTemplate("{question}")
]);Memory Architecture
Layer 1: Episodic (Session)
- Stores: Terminal commands, file edits, git operations
- Backend: In-memory + JSON file
- Scope: Current session, per project
Layer 2: Working (Project)
- Stores: Current task, blockers, decisions
- Backend: JSON files in
~/.config/ai-agent/working/ - Scope: Persistent per project
Layer 3: Semantic (Cloud)
- Stores: Long-term facts, cross-project knowledge
- Backend: Supermemory cloud
- Scope: Permanent, multi-device
Proactive Agent Architecture
// The proactive watcher analyzes code in real-time
async function analyze(filePath, content, options) {
const issues = [];
// Check for code smells
issues.push(...checkLargeFunctions(content));
issues.push(...checkDeepNesting(content));
issues.push(...checkDuplicateCode(recentChanges));
// Check for stuck developer
if (timeOnFile > 20 minutes) {
issues.push({ type: "stuck", message: "Need help?" });
}
// Get AI-enhanced suggestion
const suggestion = await getAISuggestion(issues);
return { issues, suggestion };
}📊 Resume/LinkedIn Highlights
Project Summary
AI CLI Agent — A context-aware AI assistant with persistent memory, multi-device sync, and proactive code analysis. Built with Node.js, LangChain, and Supermemory.
Key Technical Achievements
Three-Layer Memory System
- Designed and implemented hierarchical memory (episodic, working, semantic)
- Integrated Supermemory SDK for semantic search and cloud persistence
- Achieved sub-second memory recall across 1000+ stored items
Multi-Device Synchronization
- Built seamless handoff between devices using Supermemory cloud
- Implemented conflict-free sync with device-tagged containers
- Zero-config setup — just use same API key on any device
Proactive Code Analysis
- Real-time code smell detection (large functions, deep nesting, duplicates)
- Context-aware suggestions using LLM inference
- Non-intrusive notification system
Personal Knowledge Base
- Error solutions database with semantic search
- Decision log with reasoning capture
- Cross-project code pattern detection
LLM Orchestration
- Provider-agnostic design (OpenAI, Gemini)
- Streaming responses for better UX
- Context-aware prompt engineering
Technologies Used
| Category | Technologies | |----------|-------------| | Runtime | Node.js 18+ | | CLI | Commander.js | | LLM | LangChain, OpenAI, Gemini | | Memory | Supermemory SDK | | Monitoring | Chokidar (file watcher), zsh hooks | | Storage | JSON files, SQLite (planned) | | API Integration | GitHub REST API |
Metrics
- 20+ CLI commands implemented
- 6 memory/knowledge modules integrated with Supermemory
- Real-time file watching across any editor
- Cross-device sync with zero manual intervention
🔑 Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| OPENAI_API_KEY | One of these | OpenAI API key |
| GEMINI_API_KEY | required | Google Gemini API key |
| SUPERMEMORY_API_KEY | Recommended | Enables cloud sync, semantic search, knowledge base |
| GITHUB_TOKEN | Optional | Index GitHub repos for knowledge expansion |
| LLM_PROVIDER | Auto-detected | Force openai or gemini |
🛠️ Local Development
# Clone
git clone https://github.com/VaibhavDangaich/cli_agent.git
cd cli_agent
# Install
npm install
# Link globally
npm link
# Create .env
cp .env.example .env
# Edit .env with your API keys
# Test
ai ask "hello"🚀 Roadmap
- [ ] Ghost Mode — Autonomous background agent that works while you sleep
- [ ] Phone Bridge — Control laptop agent from phone
- [ ] VS Code Extension — Deep IDE integration
- [ ] Team Features — Shared knowledge base across team
- [ ] Voice Interface — Speak to your agent
- [ ] Auto-PR — Agent creates PRs for tasks
📝 License
MIT License — see LICENSE
👨💻 Author
Vaibhav Dangaich
- GitHub: @VaibhavDangaich
- npm: @vaibhav_dangaich
Built with ❤️ for developers who hate repeating themselves
If you find this useful, consider giving it a ⭐ on GitHub!
