Local-first β’ Terminal-first β’ Project-aware AI coding
A coding engine built around project context, hybrid retrieval, agent workflows, provider abstraction, unified model routing, patch workflows, and evidence-driven verification.
Created & Engineered by Sharfuddin Ahmed
AI Vibe Coder β’ Systems Architect β’ Creator of Codemaster-AI
@sharfuddin18
Codemaster-AI is a project-aware AI coding engine designed to help developers understand, generate, review, and modify software safely while keeping the developer in control.
Developer intent
β
Project context + retrieval
β
Task classification
β
Unified model routing
β
Provider / model
β
Result / patch
β
Verification + provenance
β
Developer review
- π§ Project-aware context β repository-level understanding instead of isolated snippets.
- π Hybrid RAG β dense vectors + BM25 with persistent local indexing.
- π§ Unified routing β
TaskClassifier β ModelRouter β LLMFactory β Provider. - π€ Agent workflows β structured generation, fixing, context assembly, and results.
- π©Ή Safe patching β validation, traversal protection, application, and verification.
- π Provenance-aware output β context can be traced back to retrieved sources.
- π REST + CLI/TUI + MCP β multiple interfaces over the same core architecture.
- π Local-first inference β Ollama remains the primary local execution path.
flowchart TD
U[Developer] --> I[CLI / TUI / MCP]
I --> API[FastAPI]
API --> A[Agent / Orchestration]
A --> TC[Task Classifier]
TC --> CX[Task Complexity]
CX --> MP[Model Policy]
MP --> MR[ModelRouter]
MR --> RD[RoutingDecision]
RD --> F[LLMFactory]
F --> P[Selected Provider / Ollama]
A --> R[Hybrid Retrieval]
R --> D[Dense Vectors]
R --> B[BM25]
D --> C[Project Index / Cache]
B --> C
P --> G[Response / Patch]
G --> V[Provenance / Verification]
V --> OUT[Inspectable Output]
Architecture rule:
ModelRouteris the single authoritative production model-routing boundary.LLMFactoryis the single provider-instantiation boundary. Retrieval remains an independent context subsystem.
| Layer | Technology | Purpose |
|---|---|---|
| Runtime | Python 3.12+ | Core implementation |
| API | FastAPI + Pydantic | Application boundary |
| Local AI | Ollama | Local LLM execution |
| Routing | TaskClassifier + ModelPolicy + ModelRouter | Deterministic task/model selection |
| Providers | LLMFactory | Provider-instantiation boundary |
| Retrieval | Dense + BM25 + FAISS | Hybrid project context |
| Embeddings | all-MiniLM-L6-v2 |
Semantic representation |
| Agents | Code Agent | Coding and orchestration |
| Interface | CLI + Textual/Rich TUI | Terminal UX |
| Integration | MCP | Tool/context boundary |
| Changes | Patch + Git | Reviewable modifications |
| Verification | pytest + Flake8 + CodeQL | Automated checks |
User query
β
βββββββββββ΄ββββββββββ
β β
Dense retrieval BM25 retrieval
β β
βββββββββββ¬ββββββββββ
β
Hybrid ranking
β
Relevant context
β
Agent / LLM
Dense retrieval captures semantic similarity while BM25 strengthens exact identifiers, symbols, configuration keys, and terminology. The retrieval layer supports incremental indexing, persistent vector state, deterministic ranking, provenance, and explicit failure handling.
File
β
Hash
β
Previous State
β
Unchanged β Reuse / Skip
Changed β Reprocess
Deleted β Invalidate
New β Process
Request
β
TaskClassifier
β
TaskType + TaskComplexity
β
ModelPolicy
β
ModelRouter
β
RoutingDecision
β
LLMFactory
β
Provider / Ollama
β
AgentResult
Routing is represented through explicit concepts including TaskType, TaskComplexity, AgentRequest, ModelPolicy, RoutingDecision, and AgentResult. Production model selection is centralized in ModelRouter; provider creation is centralized in LLMFactory.
The production architecture no longer relies on duplicate ProviderManager or simulated ModelOrchestrator routing paths. Ollama remains the primary local provider path; live model execution depends on the configured environment.
flowchart LR
C[Context] --> G[Generation]
G --> P[Result / Patch]
P --> V[Verification]
V -->|validated| O[Inspectable Output]
V -->|not validated| R[Developer Review]
Successful generation is not treated as proof of correctness.
βββββββββββββββββββββββ
β Developer β
ββββββββββββ¬βββββββββββ
β
βββββββββββββΌββββββββββββ
β β β
CLI TUI MCP
β β β
βββββββββββββΌββββββββββββ
β
Codemaster-AI
β
Context + Routing + Agents
β
Provider / Model
AI request β Context β Routing β Generation β Patch
β
Developer review
β
Apply safely
β
Repository change
β
Verification
Patch handling includes malformed/empty patch handling, unsafe-path rejection, traversal protection, conflict handling, and post-application verification.
The project uses automated regression testing across retrieval, routing, providers, MCP, patch safety, and application workflows.
Verification focuses on:
- hybrid retrieval and deterministic ranking
- vector persistence and indexing failure handling
- provider and routing behavior
- MCP/runtime paths
- patch security and verification
- structured agent results
- API/application integration
IMPLEMENTED β TESTED β VERIFIED β CI VERIFIED β INTEGRATED β RELEASE READY
A passing test proves tested behavior β not complete system correctness. Live LLM execution remains dependent on the configured provider environment.
git clone https://github.com/sharfuddin18/Codemaster-Ai.git
cd Codemaster-Ai
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python -m pip install -r backend/requirements.txtWindows PowerShell:
.\.venv\Scripts\Activate.ps1cp backend/.env.example backend/.envLLM_PROVIDER=ollama
OLLAMA_ENABLED=true
OLLAMA_BASE_URL=http://localhost:11434
cd backend
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadPYTHONPATH=.:backend pytest --import-mode=importlib backend/ tests/Codemaster-Ai/
βββ backend/ # FastAPI application and core services
βββ cli_tools/ # CLI / terminal workflows
βββ tests/ # Regression and integration tests
βββ data/ # Local runtime and indexing state
βββ ARCHITECTURE.md # Detailed architecture reference
βββ CONTRIBUTING.md # Contribution workflow
βββ SECURITY.md # Security guidance
βββ README.md # Project overview
Codemaster-AI's core architecture is consolidated around a single model-routing and provider-factory design, with hybrid retrieval, agent workflows, safe patching, provenance, MCP, and terminal/API interfaces in place.
The project continues toward stronger end-to-end runtime verification, reproducible environments, and reliable AI-assisted software engineering workflows.
ARCHITECTURE.mdβ detailed architecture and design boundariesCONTRIBUTING.mdβ development workflowSECURITY.mdβ security guidancetests/β automated verification
Contributions and architectural discussions are welcome. Keep changes focused, tested, and aligned with the project's routing, retrieval, provider, and verification boundaries.
MIT License.
Built by Sharfuddin Ahmed
AI Vibe Coder β’ Systems Architect β’ Creator of Codemaster-AI