Skip to content

Latest commit

Β 

History

337 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Codemaster-AI πŸš€

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

CI/CD CodeQL Python 3.12+ FastAPI Ollama MIT License


🎯 What is Codemaster-AI?

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

Core capabilities

  • 🧠 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.

πŸ—οΈ Architecture

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]
Loading

Architecture rule: ModelRouter is the single authoritative production model-routing boundary. LLMFactory is the single provider-instantiation boundary. Retrieval remains an independent context subsystem.

Architecture details β†’


🧱 Technical Stack

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

🧠 Core Systems

πŸ”Ž Hybrid RAG

                    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.

⚑ Incremental indexing

File
 ↓
Hash
 ↓
Previous State
 ↓
Unchanged β†’ Reuse / Skip
Changed   β†’ Reprocess
Deleted   β†’ Invalidate
New       β†’ Process

🧭 Unified model routing

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.

πŸ“š Provenance & verification

flowchart LR
    C[Context] --> G[Generation]
    G --> P[Result / Patch]
    P --> V[Verification]
    V -->|validated| O[Inspectable Output]
    V -->|not validated| R[Developer Review]
Loading

Successful generation is not treated as proof of correctness.


πŸ–₯️ Developer Workflow

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚     Developer       β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                ↓           ↓           ↓
              CLI         TUI          MCP
                β”‚           β”‚           β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                     Codemaster-AI
                            ↓
              Context + Routing + Agents
                            ↓
                     Provider / Model

🩹 Patch workflow

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.


πŸ§ͺ Engineering & 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.


πŸš€ Getting Started

Install

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.txt

Windows PowerShell:

.\.venv\Scripts\Activate.ps1

Configure local inference

cp backend/.env.example backend/.env
LLM_PROVIDER=ollama
OLLAMA_ENABLED=true
OLLAMA_BASE_URL=http://localhost:11434

Run

cd backend
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

Run tests

PYTHONPATH=.:backend pytest --import-mode=importlib backend/ tests/

πŸ“ Project Structure

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

πŸ“Œ Current Status

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.

πŸ“„ Documentation

🀝 Contributing

Contributions and architectural discussions are welcome. Keep changes focused, tested, and aligned with the project's routing, retrieval, provider, and verification boundaries.

πŸ“œ License

MIT License.


Built by Sharfuddin Ahmed
AI Vibe Coder β€’ Systems Architect β€’ Creator of Codemaster-AI

About

Codemaster-AI is a powerful, local-first coding assistant designed to live directly within your terminal, ensuring your codebase remains secure and private. By leveraging a modular, agent-based architecture and a local vector engine, it provides context-aware code generation, explanation, and debugging without ever leaving your machine.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Sponsor this project

Packages

Used by

Contributors

Languages