Sharrowkin is an autonomous coding agent that thinks before it acts. It reads your workspace, builds an AST-level understanding of your project, recalls prior solutions from its memory systems, generates code patches via LLM, applies them locally, runs tests, and retries with feedback until the task stabilizes.
Key differentiators:
- 5-phase reasoning cycle: Observe β Recall β Reason β Stabilize β Commit
- 4 memory systems: DSM (semantic), RLD (genetic patterns), MemoryField (Hebbian), TraceMemory (trajectories)
- AST-level code analysis: Semantic graphs, not just text search
- Local-first: Your code never leaves your machine
- Test-driven stabilization: Automatic retry with test feedback
| Feature | Description |
|---|---|
| Hierarchical Planning | Breaks complex tasks into dependency graphs with automatic parallelization |
| Semantic Memory (DSM) | Category trees + vector search + graph associations for context retrieval |
| Genetic Learning (RLD) | Stores successful reasoning patterns as "genes" for future reuse |
| Workspace Caching | 50-100x speedup on repeated scans with smart invalidation |
| Real-time WebSocket | Stream reasoning phases and progress to frontend |
| GitHub Integration | OAuth login, repo analysis, PR context |
| LazyStandup | Auto-generate daily reports from git history + AST changes |
| Multi-LLM Support | Gemini, Claude, or local models via llama-cpp |
User Task
β
[1. OBSERVE] βββββ Parse workspace, build AST, detect dependencies
β
[2. RECALL] ββββββ Query DSM + RLD for relevant context (top-10 nodes)
β
[3. REASON] ββββββ LLM generates plan + code patches with memory context
β
[4. STABILIZE] βββ Apply patches, run tests, retry on failure (max 3 attempts)
β
[5. COMMIT] ββββββ Update memory graphs, strengthen successful patterns
β
Response + Diff
| System | Purpose | Storage | Retrieval |
|---|---|---|---|
| DSM | Semantic project knowledge | Category tree + vector index + graph | Hybrid: category routing + cosine similarity + graph distance |
| RLD | Successful reasoning genes | JSON (pattern β outcome) | Exact match on task signature |
| MemoryField | Hebbian association network | Weighted edges between concepts | Activation spreading (max 2 hops) |
| TraceMemory | Execution trajectories | JSONL logs | Replay for debugging/learning |
sharrowkin/
βββ agent/ # Core reasoning engine
β βββ core.py # 5-phase cycle orchestrator
β βββ planner.py # Hierarchical task decomposition
β βββ stabilizer.py # Test-driven retry logic
βββ memory/
β βββ dsm/ # Dynamic Segmented Memory
β βββ rld/ # Recursive Latent DNA
β βββ memory_field.py # Hebbian network
β βββ trace_memory.py # Trajectory logs
βββ analysis/
β βββ workspace.py # AST parser + caching
β βββ semantic_graph.py # Code relationship graph
β βββ dependency.py # Import/call graph analysis
βββ api/
β βββ main.py # FastAPI app
β βββ routers/ # REST endpoints
β βββ websocket.py # Real-time agent stream
βββ integrations/
β βββ lazystandup/ # Standup report generator
β βββ semanticgit/ # s-git AST-aware VCS
βββ tests/ # Pytest suite
βββ requirements.txt
βββ .env.example
- Python 3.10+
- Node.js 18+ (for frontend)
- Git
- Gemini API key (or Claude/local model)
# Clone the repo
git clone https://github.com/narelabs/sharrowkin.git
cd sharrowkin
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY
# Start backend
python -m uvicorn main:app --reloadBackend runs at http://127.0.0.1:8000
cd ui
npm install
npm run devFrontend runs at http://localhost:3000
GET /api/healthReturns backend status and current cognitive phase.
POST /api/chat
Content-Type: application/json
{
"message": "Add error handling to user login",
"workspace": "/path/to/project"
}WS /api/agent/ws
Send: {"task": "refactor auth module", "workspace": "/path/to/project"}
Receive: {"phase": "observe", "content": "Scanning workspace..."}GET /api/cognitive/stateReturns current memory stats and workspace cache status.
POST /api/standup
Content-Type: application/json
{
"workspace": "/path/to/project",
"since": "2026-05-21"
}| Event Type | Direction | Payload |
|---|---|---|
phase_start |
Server β Client | {"phase": "observe", "timestamp": ...} |
phase_progress |
Server β Client | {"phase": "recall", "content": "Found 8 relevant nodes"} |
phase_complete |
Server β Client | {"phase": "reason", "result": {...}} |
error |
Server β Client | {"error": "Test failed", "retry": 2} |
task_complete |
Server β Client | {"diff": "...", "files_changed": 3} |
# LLM Configuration
GEMINI_API_KEY=your_gemini_api_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here # Optional
ANTHROPIC_MODEL=claude-sonnet-4 # Optional
# Workspace
WORKSPACE_PATH=/path/to/your/workspace
# GitHub OAuth (optional)
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GITHUB_REDIRECT_URI=http://localhost:3000/api/github/callback
# Development
DEV_MODE=true # Bypass GitHub requirement for local testingMemory is stored in .sharrowkin/ inside your workspace:
your-project/
βββ .sharrowkin/
βββ dsm_memory.json # Semantic knowledge graph
βββ rld_genes.json # Successful reasoning patterns
βββ memory_field.json # Hebbian association network
βββ traces/ # Execution logs
Add to your .gitignore:
.sharrowkin/
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Test specific module
pytest tests/test_agent.py -v
# Test WebSocket
python tests/test_ws.py| Metric | Value | Notes |
|---|---|---|
| Workspace scan (cold) | ~2-5s | Depends on project size |
| Workspace scan (cached) | ~20-50ms | 50-100x speedup |
| Memory retrieval | ~100-200ms | DSM hybrid search |
| Cache hit rate | ~67% | After warmup |
| LLM latency | ~1-3s | Gemini 1.5 Flash |
| Test stabilization | 1-3 retries | 85% success rate |
- Local-first: Code never leaves your machine unless you explicitly push
- Test-driven: Every change must pass tests before commit
- Memory-augmented: Learn from past successes, avoid past failures
- Transparent: Stream every reasoning step to the user
- Python: Black formatter, type hints, docstrings
- TypeScript: Prettier, strict mode, functional components
- Commits: Conventional commits (feat/fix/docs/refactor)
- Implement
BaseMemoryinterface inmemory/ - Add retrieval logic to
agent/core.pyrecall phase - Add update logic to
agent/core.pycommit phase - Add tests in
tests/test_memory.py
- Multi-file refactoring with dependency tracking
- Voice input via Whisper
- Collaborative mode (multiple agents on one task)
- Plugin system for custom tools
- Self-hosted model support (Llama 3, Qwen)
- IDE extensions (VS Code, JetBrains)
- Cloud sync for memory (optional, encrypted)
- Advanced planning with MCTS
We welcome contributions! See CONTRIBUTING.md for guidelines.
Quick tips:
- Fork the repo and create a feature branch
- Write tests for new features
- Run
pytestandblack .before committing - Open a PR with a clear description
MIT License - see LICENSE for details.
- Gemini API for fast, high-quality code generation
- FastAPI for elegant async Python APIs
- Next.js for the premium frontend experience
- Tree-sitter for robust AST parsing
Documentation β’ Issues β’ Discussions

