Skip to main content
Glama
CODYNEX Engine

CODYNEX Engine

๐Ÿงฌ CODYNEX Engine

Typing SVG

Tests Python License: MIT Dependencies Version

๐Ÿงฌ CODYNEX Engine โ€” codebase intelligence: an engine that reads your entire project and builds a structured model of it โ€” architecture, dependency graph, design decisions, bug history. Blast-radius prediction โ€” ask what breaks if you touch auth.py, and get a ranked impact analysis. Apply a patch in an isolated sandbox and see the test verdict before the change ever lands.

Stdlib-only Python. Zero dependencies.

๐Ÿš€ Quickstart

git clone https://github.com/Thegreatprabh/codynex-engine.git
cd DNA
pip install -e .                 # stdlib only โ€” nothing else to install

dna init ./my-project            # ingest โ†’ build the DNA
dna map                          # architecture: components + dependency stats
dna impact "auth.py"             # blast radius: what breaks if I change this?
dna plan "change the login system"  # predict a natural-language change
dna verify --patch fix.diff      # sandbox: apply patch, run tests, report
dna watch                        # keep the DNA updated as files change

The DNA is saved as JSON at ~/.dna/<project>/dna.json (dir 0700). Run dna watch during development, or re-run dna init after big changes.

Related MCP server: astra-mcp

๐Ÿงช How it works โ€” ingest โ†’ model โ†’ analyze โ†’ verify

 source code โ”€โ”€โ–บ  INGEST  โ”€โ”€โ–บ  MODEL  โ”€โ”€โ–บ  ANALYZE  โ”€โ”€โ–บ  VERIFY
  (.py files)     ast parse      ProjectDNA   blast radius    isolated
                  git log        dep graph    risk report     sandbox
                  mining         reverse      decisions       + pytest
                                 graph
  1. Ingest โ€” stdlib ast parses every Python file: imports (absolute pkg.sub and relative .sib resolved to real files), functions, classes, call edges. git log is mined for architectural decisions, bug history, and churn hotspots. An intent extractor records what each component is for: module docstring, README mentions, and the test_* names of tests importing it. No git? The graph still builds โ€” history is skipped gracefully.

  2. Model โ€” a ProjectDNA: per-file components with one-line purpose summaries, a dependency graph and its reverse graph, decisions, hotspots, test coverage, and per-component intents. Persisted as JSON. dna watch keeps it live: it polls mtimes and re-parses only changed files, so the model never goes stale.

  3. Analyze โ€” dna impact runs reverse-BFS from your target over the dependency graph and scores every affected component. dna plan takes a natural-language change request, resolves it to components with a stated confidence, and returns the blast radius plus suggested tests. dna risks reports circular imports (Tarjan SCC), god-files, dead-code candidates, untested components. dna decisions lists design choices mined from commits.

  4. Verify โ€” dna verify copies the tree to a temp dir, applies your unified diff (context-verified โ€” mismatched hunks are refused, new-file creation rejected), and runs the project's own test suite with a timeout.

๐Ÿ’ฅ Blast-radius prediction

$ dna impact "auth.py"

  target: auth.py  โ†’  auth.py, session.py, api/routes.py
  affected components: 3

  RISK    SCORE DEPTH  COMPONENT
  ------------------------------------------
  high        5     1  session.py
            ยท no test coverage
            ยท churn hotspot
            ยท depth 1
  medium      3     2  api/routes.py
            ยท no test coverage
  low         1     1  auth.py
            ยท target itself

  โ”€โ”€ 3 components ยท 1 high-risk โ”€โ”€

Risk scoring is explicit, not magic: no test coverage +2, circular dependency +2, churn hotspot +1, depth > 3 +1. Labels: 0โ€“1 low, 2โ€“3 medium, 4+ high. Every score comes with its reasons printed.

dna impact checkout --limit 30    # fuzzy match โ€” file, or even a function name

๐Ÿง  Change planning โ€” predict before you change

$ dna plan "change the login system"

  TARGET: auth.py  (confidence: high)
  request: change the login system
  affected components: 3

  RISK    SCORE DEPTH  COMPONENT
  ------------------------------------------
  high        5     1  session.py
            ยท no test coverage
            ยท churn hotspot
  medium      3     2  api/routes.py
            ยท no test coverage

  SUGGESTED TESTS:
    tests/test_session.py
    tests/test_routes.py

  RISK SUMMARY: high=1 medium=1 low=0
  HOTSPOTS IN BLAST:
    session.py (12 commits)

dna plan resolves your request to components (exact path/basename โ†’ high confidence, fuzzy match โ†’ medium, keyword fallback โ†’ low), reuses the blast-radius engine, and suggests the tests that cover the affected code. Confidence is always shown โ€” a low plan tells you the match was a guess, not a fact.

๐Ÿงซ Sandbox verification

$ dna verify --patch fix.diff --path ./my-project

  verifying patch in sandbox (project: ./my-project) ...
  patched: auth.py
  tests: PASS โ€” 42 passed, 0 failed in 1.8s

The patch is applied to a throwaway copy โ€” your working tree is never touched. Only verify projects you trust: the sandbox runs the project's own test suite, so it inherits your trust in that code.

๐Ÿ‘๏ธ Live watcher โ€” DNA that stays current

$ dna watch --interval 2

  ingesting /home/you/my-project ...
  watching 38 files in /home/you/my-project (every 2s) โ€” Ctrl+C to stop
  update #1: ~1 changed โ†’ DNA saved (38 files)
  update #2: ~1 changed, -1 deleted โ†’ DNA saved (37 files)

dna watch polls file mtimes (stdlib only โ€” no watchdog dependency) and re-parses only the files that changed, then rebuilds and re-saves the DNA. New files, deleted files, and edits are all picked up; Ctrl+C exits cleanly. The DNA stops being a snapshot and becomes a living model.

๐Ÿค– MCP โ€” for AI agents

Four tools over stdio JSON-RPC. Malformed input returns -32600; the server never crashes.

Tool

Args

Returns

dna_map

โ€”

Components, dependency stats

dna_impact

{target}

Ranked blast radius with reasons

dna_plan

{request}

Full change prediction + suggested tests

dna_decisions

{limit}

Decisions mined from git history

{ "project": { "command": "<FULL PYTHON PATH>", "args": ["-m", "dna", "mcp"] } }

๐Ÿ“– Full per-agent setup guide: docs/SETUP_ALL_AGENTS.md โ€” Claude Code, Claude Desktop, Cursor, Codex, ChatGPT Desktop, Gemini CLI, Antigravity, Termux. (Golden rule: GUI apps need the full python path.)

โš ๏ธ Risk report

dna risks
risk report: my-project (38 components, 112 edges)

circular imports: 1
  โ†ป api/routes.py โ†’ db/session.py โ†’ api/routes.py

god-files (>500 lines): 2
  legacy/parser.py (812 lines)

dead-code candidates (no inbound, no tests): 3
  utils/old_helpers.py

๐Ÿงฑ Honest limits โ€” v0.2.0

  • Python only. Other languages are invisible to the parser.

  • Fuzzy target matching is heuristic. Ambiguous names resolve to the first/best match; verify with dna map when unsure. dna plan always shows its confidence โ€” treat low as a guess.

  • Call-graph resolution is best-effort. Dynamic imports, exec, getattr-style dispatch, and method calls on unknown receivers are not tracked. The dependency graph is file-level (imports), which is robust; function-level edges are informational.

  • The sandbox runs the project's own test suite. Only verify projects you trust โ€” same trust level as running their tests locally.

  • Patch applier is minimal. Unified diffs with new-file creation (/dev/null sources) are rejected; complex renames may fail โ€” the tool refuses rather than mis-applying.

  • The watcher polls. It checks mtimes on an interval (default 2s), so sub-second bursts of edits may batch into one update. It does not watch git history โ€” commit, then re-mine decisions with dna init.

  • Intent is extracted, not understood. Summaries come from docstrings, README mentions, and test names โ€” useful signal, not deep comprehension.

๐Ÿ” Verify it yourself

python -m pytest tests/ -q    # 56 tests โ€” should all pass

Tests are fully mocked โ€” zero network, zero real git, under a second. Every badge above is checkable in this repo.

๐Ÿ—๏ธ Architecture

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚        ๐Ÿงฌ DNA CORE        โ”‚
                    โ”‚  ingest ยท model ยท analyze โ”‚
                    โ”‚        ยท verify           โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ                    โ–ผ                    โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚     INGEST     โ”‚  โ”‚      MODEL      โ”‚  โ”‚     ANALYZE      โ”‚
     โ”‚ ast parser     โ”‚  โ”‚ ProjectDNA      โ”‚  โ”‚ reverse-BFS      โ”‚
     โ”‚ import resolve โ”‚  โ”‚ dep + reverse   โ”‚  โ”‚ risk scoring     โ”‚
     โ”‚ git log miner  โ”‚  โ”‚ decisions       โ”‚  โ”‚ Tarjan cycles    โ”‚
     โ”‚ degrades w/o   โ”‚  โ”‚ hotspots        โ”‚  โ”‚ god-files        โ”‚
     โ”‚ git            โ”‚  โ”‚ JSON @ ~/.dna   โ”‚  โ”‚ dead code        โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ–ผ
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚              VERIFY + MCP              โ”‚
              โ”‚  temp-dir sandbox ยท context-verified   โ”‚
              โ”‚  patch applier ยท pytest ยท 3 MCP tools  โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

~2,000 lines of Python. No frameworks. No dependencies. The whole model fits in one JSON file you can open and read.

๐Ÿค Contributing

New analyzers are the best contribution:

  1. Fork โ†’ branch โ†’ add your analyzer under dna/analysis/

  2. Add a test in tests/ (mocked โ€” no network, no real git)

  3. pytest tests/ -q must stay green

  4. Open a PR explaining what it detects and why it matters

๐Ÿ“„ License

MIT ยฉ 2026 Prabhjot Singh. Know your codebase's genome before you edit it. ๐Ÿงฌ

Available Tools

4 tools
dna_decisionsC

Architectural decisions mined from git history.

Inputs: limit, project.

dna_impactC

Predict blast radius of changing a component.

Inputs: target (required), project.

dna_mapC

Architecture summary of the ingested project.

Inputs: project.

dna_planC

Full change prediction for a natural-language request.

Inputs: request (required), project.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    B3/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool targets a distinct capability: architecture summary, component impact, historical decisions, and request-level change planning. No two tools overlap in input or output scope, so an agent can easily select the right one.

    Naming Consistency5/5

    All four tools use the dna_ prefix followed by a single noun (map, impact, decisions, plan), forming a consistent and predictable naming convention.

    Tool Count5/5

    Four tools are well-suited for a focused architecture analysis engine; each covers a unique analysis dimension without redundancy.

    Completeness4/5

    The set covers key analysis outputs (summary, impact, decisions, plan) but lacks a tool to ingest/refresh the project or drill into specific components/decisions, leaving minor workflow gaps.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Live codebase intelligence for AI agents. Import graph PageRank for file importance, git forensics for co-change coupling and fragile code, convention detection across 16 domains, and blast radius analysis.
      21 npm
      3
      Business Source 1.1
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to index local Python repositories and retrieve code intelligence through semantic search, caller lookups, hybrid context expansion, and visualization.
      5
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Indexes a Python/JS/TS repository into a local SQLite knowledge graph so agents can trace callers, callees, imports, subclasses and covering tests, measure impact radius, rank diff risk, and summarize architecture without grepping files. Exposes these queries as MCP tools alongside an equivalent CLI, with no daemon, embeddings, or network access.
      10
      MIT