Skip to main content
Glama

lorexplore (lxp)

Local-first codebase intelligence, git archaeology, temporal co-change coupling, and progressive-disclosure MCP/CLI engine.

Single SQLite WAL + FTS5 index per repository. Zero cloud services, zero LLM API calls required for indexing or retrieval, strict token budgets, and real-time dirty working-tree overlay.

Status: Alpha (0.1.0a*). CLI flags and MCP tool schemas may evolve before 0.1.0.

Architecture

Static AST search alone misses why code exists and which files silently break together. lorexplore joins four local layers into one queryable SQLite WAL index:

flowchart LR
    subgraph Inputs["Repository Inputs (Local Only)"]
        SRC["Source Files\n(Python AST + 6 Tree-sitter Grammars)"]
        GIT["Git History\n(Non-Squashed Commits, Renames, Lore Trailers)"]
        DOCS["Plans, ADRs & Runbooks\n(Bi-Temporal Supersession Chains)"]
        DIRTY["Dirty Working Tree\n(Uncommitted Edits Overlay)"]
    end

    subgraph Engine["SQLite WAL + FTS5 Engine (<= 64 MiB Cache, 0-mmap)"]
        AST["Symbols & Static Call Graph\n(EXTRACTED vs HEURISTIC)"]
        PPR["Personalized PageRank\n(Query & Focus-Seeded)"]
        CO["Temporal Co-Change Graph\n(90d Decay, <= 30-File Filter)"]
        FTS["Acronym-Safe FTS5\n(BM25 + RRF Fusion)"]
    end

    subgraph Surface["Progressive-Disclosure Interface"]
        CLI["CLI: lorexplore / lxp\n(Markdown & --json)"]
        MCP["MCP Server (MIT mcp SDK)\n(stdio & Localhost Streamable HTTP)"]
    end

    SRC --> AST
    SRC --> FTS
    AST --> PPR
    GIT --> CO
    GIT --> FTS
    DOCS --> FTS
    DIRTY -. "Live Overlay" .-> FTS
    DIRTY -. "Live Overlay" .-> PPR

    PPR --> CLI
    CO --> CLI
    FTS --> CLI
    PPR --> MCP
    CO --> MCP
    FTS --> MCP
  1. Structural AST & Call Graph: Python stdlib ast (with error-tolerant tree-sitter-python fallback for broken dirty files) + offline official MIT Tree-sitter grammars for TypeScript/TSX, JavaScript, Go, Rust, and Bash.

  2. Git Archaeology & Temporal Coupling: Non-squashed commit mining, Lore commit trailers (Plan:, Directive:, Rejected:), git mv rename lineage, symbol-level diff tracking (-U0), and 90-day time-decayed co-change coupling (excluding bulk >30-file sweeps).

  3. Bi-Temporal Docs & ADRs: Indexes Plans/ADRs/runbooks, resolves Supersedes: chains, and flags drifted docs whose referenced files were deleted or heavily churned.

  4. FTS5 + Personalized PageRank: Acronym-safe BM25 + Reciprocal Rank Fusion (RRF) with live dirty working-tree overlay.

Related MCP server: engram-serve

Progressive-Disclosure Workflow

Instead of dumping full files into an LLM context window, agents orient in bounded hops and check blast radius before editing:

sequenceDiagram
    participant Agent as Coding Agent / Dev
    participant LXP as lorexplore (CLI / MCP)

    Agent->>LXP: 1. repo_map(focus_paths, max_tokens=1024)
    LXP-->>Agent: PageRank-ranked files + top signatures
    Agent->>LXP: 2. locate(query="token_bucket", scope="all")
    LXP-->>Agent: RRF hits across code, commits & ADRs (with cursor)
    Agent->>LXP: 3. read_symbol(targets, mode="skeleton")
    LXP-->>Agent: Compact AST signatures (~70% token savings)
    Agent->>LXP: 4. explain_why(target="src/auth/policy.py")
    LXP-->>Agent: Lore directives, fix/revert history, rename lineage & ADRs
    Agent->>LXP: 5. co_change_impact(target="working_tree")
    LXP-->>Agent: Static callers + implicit temporal co-change companions
    Note over Agent,LXP: Targeted edit -> lxp draft-lore -> commit with Lore trailers

Install

# Run directly via uvx (alpha pre-release)
uvx --prerelease=allow lorexplore --help

# Install into a project environment (alpha pre-release)
uv pip install --prerelease=allow lorexplore

# Local development install
uv sync --group dev

Quickstart

# 1. Build local index (~/.cache/lorexplore/<repo_hash>.db)
lxp sync

# 2. Keep index fresh automatically on commit, merge, and checkout
lxp install-hooks

# 3. Progressive-disclosure queries (add --json for machine output)
lxp map --focus src/auth --max-tokens 1024
lxp locate "token_bucket"
lxp read src/auth/policy.py --mode skeleton
lxp trace src/auth/policy.py --direction callers
lxp why src/auth/policy.py
lxp impact working_tree
lxp history "TOKEN_TTL" --fixes-only
lxp stale
lxp timeline --target src/auth --since 30d
lxp draft-lore

MCP Server

Runs on the official MIT mcp SDK (MCPServer). Defaults to zero-socket stdio; --read-only opens SQLite read-only and omits record_decision.

# Recommended for IDE / agent clients (stdio, zero sockets)
lxp --repo /path/to/repo --read-only serve

# Optional localhost-only stateless Streamable HTTP (DNS-rebinding Host/Origin guard)
lxp --repo /path/to/repo --read-only serve --transport streamable-http --host 127.0.0.1 --port 8770

Example MCP client configuration:

{
  "mcpServers": {
    "lorexplore": {
      "command": "lxp",
      "args": ["--repo", "/path/to/repo", "--read-only", "serve"]
    }
  }
}

Tool Surface

Tool

Purpose

Read-Only

repo_map

Personalized PageRank file/signature skeleton map

Yes

locate

RRF search across symbols, commits, and ADRs

Yes

read_symbol

Batch AST skeletons or exact line/symbol bodies

Yes

trace_graph

N-hop static callers, callees, imports, and tests

Yes

explain_why

Commits, Lore trailers, rename lineage, ADRs, and co-changes

Yes

co_change_impact

Pre-edit blast radius (static callers + temporal co-change)

Yes

search_history

FTS5 search over commits, Lore trailers, and ADRs

Yes

audit_stale_docs

Flags active docs with deleted or heavily churned file refs

Yes

build_timeline

Chronological SHA-anchored feed for onboarding or synthesis

Yes

record_decision

Records a bi-temporal decision and emits Lore trailers

No

Lore Commit Trailers

lorexplore indexes structured commit trailers automatically:

Plan: Plan 02
Directive: Enforce token_bucket bounds; never re-enable legacy fixed fallback.
Rejected: Unbounded burst quota.
Verified-By: pytest tests/test_policy.py

Generate a pre-commit trailer draft and missed-companion check from your staged diff with lxp draft-lore.

Quality & Security Gates

Every commit is verified across Linux, macOS, and Windows (Python 3.11–3.14):

  • Static & Complexity: ruff (lint, format, McCabe C901 <= 12, branches <= 12, statements <= 50) + complexipy (Sonar cognitive complexity <= 15).

  • Type Safety: mypy --strict + Astral ty.

  • Security & Compliance: bandit SAST, pip-audit CVE scan, and automated runtime permissive license allowlist (MIT, Apache-2.0, BSD, ISC, PSF-2.0).

  • Testing & Performance: >= 90% combined line and branch coverage (pytest --cov-branch), Hypothesis property fuzzing, <= 50 ms p95 query latency, <= 150 MB peak RSS, and < 50 ms lazy CLI cold start.

  • Releases: Dynamic hatch-vcs versioning with automated PyPI OIDC Trusted Publishing and CycloneDX SBOM generation on merges to main.

Optional Extras

  • lorexplore[polyglot]: Opt-in tree-sitter-language-pack for long-tail languages beyond the 6 offline core grammars.

  • eval dependency group: Offline agentic evaluation & Pareto prompt optimization (Inspect AI, DSPy + GEPA, local SQLite MLflow).

License

Licensed under Apache-2.0.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI coding agents and IDEs to query a local structural code graph and retrieve focused, token-bounded context on code entities, Git relationships, callers/callees, impact, paths, and recorded mistakes for more efficient sessions.
      24 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI coding agents to retrieve bounded, focused context from a local structural code graph, including source entities, Git relationships, and recorded project memory. It supports exploring structure, inspecting callers, callees, and impact, and carrying prior mistakes into later sessions without reading full files.
      24 npm
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables coding agents to retrieve the most relevant code for a task within a hard token budget by fusing code graph, BM25, local embeddings, and git history, and to navigate symbols, callers, impact, and related files. It runs locally over MCP with no API keys and keeps its index fresh.
      10
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to search and navigate indexed codebases through lexical, semantic, and hybrid queries, with tools for symbols, call graphs, outlines, spans, impact analysis, and recall.
      9
      Apache 2.0