> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monolex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Monogit

> Git structure cache with freshness-qualified branch/commit relationships, commit-level symbols, diffs, and code/doc snapshots.

Monogit indexes your git repository structure into a per-repo SQLite database. Beyond branch and commit tracking, it extracts code symbols and document headings at each commit — enabling temporal code analysis that knows what changed at each point in history.

*Published contract: `monogit 0.5.1`, OpenCLIs build
`2026-07-18-153030`. The executing binary, installed receipt, and public CDN
pointer agree on this release; per-platform provenance is detailed below.*

The installed CLI exposes **7 operational commands**, the embedded `docs`
reader, and a machine-readable `mcp-schema` endpoint. `--help` and `--version`
are global flags rather than additional operational commands. The typed MCP
surface contains the 6 read commands and deliberately excludes the `index`
writer.

***

## Quick Start

```bash theme={null}
# Install the current public payload
openclis install monogit

# Index repository with symbol extraction
monogit index --symbols -n 5000 --all

# Which branches contain this commit?
monogit query abc123f

# Compare two branches
monogit compare main feature/new-ui

# Show database stats
monogit stats
```

***

## Commands

| Command                       | What it does                                                                    | Main controls                                                                             |
| ----------------------------- | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `index [path]`                | Writes branch, commit, relationship, optional diff, and optional symbol caches. | `-n/--commits`, `--all`, `--diff`, `--symbols`, `--no-prune`, `--gc`, `--verbose`, `--db` |
| `query <commit>`              | Finds every indexed branch that contains a full or prefix commit id.            | `--local`, `--remote`, `--json`, `--db`                                                   |
| `branches [path]`             | Lists indexed local/remote branches.                                            | `--local`, `--remote`, `--json`, `--db`                                                   |
| `compare <a> <b>`             | Computes ahead/behind counts between two branches.                              | `--commits`, `--json`, `--db`                                                             |
| `stats`                       | Reports cache and relationship statistics.                                      | `--detailed`, `--json`, `--db`                                                            |
| `search <query>`              | Searches indexed commit messages.                                               | `-n/--limit` default 10, `--json`, `--db`                                                 |
| `diff <from> <to>`            | Reads a cached parent diff or computes a repository diff.                       | `--path`, `--files`, `--stats`, `--json`, `--db`; `from` may be `parent`                  |
| `docs [topic]`                | Lists or prints embedded reference topics.                                      | The public build currently ships the `index` topic.                                       |
| `mcp-schema` / `--mcp-schema` | Prints the CLI-to-MCP schema without starting a server.                         | 6 read commands; `index` is excluded.                                                     |
| `--help` / `--version`        | Prints the Clap command guide or executing version.                             | Global read-only flags.                                                                   |

`--db <path>` is available on every database-backed command. Passing it selects
an explicit cache and bypasses normal per-project resolution, so use it only
when that ownership is intentional.

### index

Index git structure and optionally extract symbols at each commit.

```bash theme={null}
monogit index                           # Branches + commits
monogit index --symbols                 # + code symbols + doc headings per commit
monogit index --symbols -n 0 --all      # Full reachable history, all branches
monogit index --diff                    # + parent→commit diffs
monogit index --gc -n 0                 # Also remove commits unreachable from any branch
```

`-n 0` is the current default and means all reachable commits. Set an explicit
positive cap for a bounded first index. `--all` widens branch discovery to
remote-tracking refs; a local-only refresh preserves previously indexed remote
rows, while an `--all` refresh reconciles both scopes.

`--symbols` uses tree-sitter to parse changed files at each commit, extracting function/class/struct definitions at their exact line positions. Markdown files are parsed for heading structure.

Symbol extraction is fail-closed: a parse failure returns non-zero and leaves
that commit unstamped so a later run retries it. A successful index commits its
exact `-n`, `--all`, `--diff`, `--symbols`, `--no-prune`, and `--gc` carrier
policy atomically with the rows; NIIA can replay that policy when Git refs
change. `--gc` requires the uncapped `-n 0` history scope.

### query — Core Feature

Query which branches contain a specific commit.

```bash theme={null}
monogit query <commit-hash>
```

Answers "where did this commit end up?" instantly from cache.

Version 0.5.1 appends an index-age qualifier to human-readable query output.
An index newer than 24 hours shows `(index written … ago)`; an older index shows
`[WARN]`, states that answers may lag Git, and names `monogit index` as the
recovery. JSON output stays schema-stable and does not append display text.

### branches

List all indexed branches.

```bash theme={null}
monogit branches
```

### compare

Compare two branches (ahead/behind count).

```bash theme={null}
monogit compare <branch-a> <branch-b>
```

### stats

Show database statistics.

```bash theme={null}
monogit stats
```

Human-readable stats now includes `Last indexed`. Freshness is WAL-aware: it
uses the newest mtime across the database, `-wal`, and `-shm` sidecars instead
of treating the bare DB file as the whole truth. Age above 24 hours is marked
`[STALE — run monogit index]`; `unknown` remains explicit when no timestamp can
be established. The JSON stats contract remains unchanged in 0.5.1.

### search

Search indexed commit messages without invoking a live Git history scan.

```bash theme={null}
monogit search "fix session" --limit 20
monogit search "fix session" --json
```

### diff

Read a cached parent-to-commit diff when available or compute the requested
range from the repository.

```bash theme={null}
monogit diff parent abc1234
monogit diff abc1234 def5678 --files
monogit diff abc1234 def5678 --stats --json
```

`--files` suppresses hunks and shows paths; `--stats` shows aggregate change
counts. A successful diff read does not prove that the index contains symbol
snapshots—verify `stats --detailed` or re-index with `--symbols` for that claim.

***

## Commit Symbol Tracking

When `--symbols` is used, monogit stores what each commit touched at the symbol level:

```
Commit abc1234 changed lib.rs lines 3218-3262
  → Symbol: create_session (function, lines 3218-3262)
  → Ref: create_group_session calls create_session

Commit def5678 changed session.md
  → Entry: "Session Recovery" (h2, lines 45-67)
  → Doc ref: session.md mentions lib.rs
```

This data powers monoflow's topic clustering, insights, and temporal analysis.

### Symbol coverage

| Language                     | Extraction                                       |
| ---------------------------- | ------------------------------------------------ |
| Rust, TypeScript, JavaScript | Functions, methods, structs, classes, interfaces |
| CSS                          | Classes, IDs, custom properties, @keyframes      |
| HTML                         | Element IDs                                      |
| Python, Go, Zig              | Functions, classes                               |
| Markdown, MDX                | Headings (h1-h6), document references            |

Code extraction inherits the `lib-monogram` tree-sitter language table bundled
with the executing release, so this table is a practical summary rather than a
closed allowlist. Unsupported code extensions are skipped; Markdown and MDX use
Monomento's document parser.

### Filters

Build artifacts (`dist/`, `.min.js`), lock files, and obfuscated symbols (`_0x*`) are automatically excluded.

***

## Pre-computed Analysis

At index time, monogit computes and stores analysis results for instant reads:

### Temporal Drift

Detects file pairs that used to change together but have diverged.

```
lib.rs ↔ main.ts — 58x together, 87 days apart
  lib.rs: 89 solo commits since, main.ts: 2 solo
```

### Commit Rhythm

Session count, peak hours/days, temporal distribution chaos score.

### Quality Delta (9 signals)

Measures work quality from commit patterns:

| Signal       | What it detects                        |
| ------------ | -------------------------------------- |
| temporal     | Steady 1-10min gaps = managed rhythm   |
| churn        | Same file 3+ times in 1hr = struggling |
| convergence  | Code+doc in same commit = aligned      |
| divergence   | Code changing but docs not following   |
| commit\_type | feat vs fix ratio                      |
| topic\_focus | Topic switching frequency              |
| streak       | Consecutive fix commits = pain         |
| thinking     | 10-30min deliberate gaps               |
| structural   | New files + refactors                  |

Detects scenarios: Struggle, Exploration, ManagedFlow, Convergence, StructuralImprovement.

Weights configurable via `monoflow weights` (saved to `~/.monolex/config/quality-weights.json`).

***

## Per-Repo Database

Each repository gets its own database:

```
~/.monolex/monogit/{name}-{hash}.db
```

A `.registry` file maps project paths to database files for automatic resolution.

## Typed MCP Surface

```bash theme={null}
monogit mcp-schema
```

The schema contains `query`, `branches`, `compare`, `stats`, `search`, and
`diff`. These commands can read an existing cache without taking ownership of
Git indexing. `index` is intentionally CLI-only because it writes branch,
commit, diff, symbol, policy, and registry state.

## Release Platforms

The `0.5.1 / 2026-07-18-153030` metadata now publishes five artifacts. Linux
and macOS use `monogit`; both Windows architectures use `monogit.exe`. No Intel
macOS payload is present in this release path.

| Platform key      | Archive SHA-256                                                    | Extracted payload SHA-256                                          |
| ----------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
| `darwin-aarch64`  | `2ddd0a5250253b6bd16cc0fd2f6898982f18b0c21e804e55826ea8054ce7215f` | `cf86641138a4281b6ea2ba39edbdfc0cba9ebbfb85ee8201fbe0f62a5dc0a330` |
| `linux-x86_64`    | `a3340ffce891adcbc0573c9d6b46c029adb31683e51d3c5d707716c06662bf45` | `e58d866837e4d063ae45a70bc6515223aa94de6be746fc778cb0642d37b45dd2` |
| `linux-aarch64`   | `d28d7627d7379a0f730a5dcc41d22c2a9bba5e2650f47c655f8c58617e61dbd4` | `e4ad2a589fbd3637ed14ac899a030d552a365c555a63d7578b2d8d6d86134932` |
| `windows-x86_64`  | `4a5ae019fa98e5946407425c01101656dbbce0b6cdd912e1f436ec0e3bbb0db5` | `f4ee5cc5b1af7133c6e607919a9de6346cb9548dafbdc2d55a182b9894456aab` |
| `windows-aarch64` | `fb0f440e8bf20e8b0879e7d2367def52303978e58930927fe62a3b5096d00da1` | `cd6e2e5c67552c066e7303f95ccae5674c0bd5605aedd383b68de39de8a8b8e6` |

All five archives and extracted payloads were directly hash-verified. The
macOS payload executed as 0.5.1 and passed strict Developer ID verification.
The Windows archives contain x86-64 and AArch64 PE console executables; both
CRLF guide pairs normalize exactly to the source tree. On the Lenovo Windows host,
`openclis update monogit` upgraded 0.5.0 to 0.5.1, `where.exe monogit`
resolved the OpenCLIs binary, and `--version`, `--help`, and `mcp-schema` all
executed successfully for the native x86-64 artifact. The AArch64 artifact was
format-, hash-, and guide-verified but was not executed on the x86-64 host.

Provenance is not uniform. The two Linux fragments record clean commit
`fd89957b8aef3afc811d0f108475b46d6dde4f2a`. The later Windows fragment and
the mutable `latest.json` pointer record clean commit
`44e4acbb5481a5d56adb6118cd8c0334b75844e3`. The macOS fragment instead
records ancestor commit `163b70a987c74dd052c8fb7276add0e65bad416f` with
`source_dirty: true`. Version/build identity and archive integrity therefore
pass across all five platforms, but neither the pointer nor one clean fragment
can be used as provenance proof for every other fragment.

***

## Design

```
┌──────────────────────────────────────────────────────────────────┐
│  MONOGIT DESIGN                                                  │
├──────────────────────────────────────────────────────────────────┤
│                                                                  │
│  AI Code Context Engine — built on Monotology for AI & Human     │
│                                                                  │
│  Layer 1: Git structure                                          │
│    branches, commits, branch_commits (M:N)                       │
│                                                                  │
│  Layer 2: Symbol snapshots                                       │
│    commit_symbols  — code symbols + doc headings per commit      │
│    commit_refs     — call chain per commit                       │
│    commit_doc_refs — document cross-references per commit        │
│                                                                  │
│  "What was the code structure at this commit?"                   │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘
```

## Relationships

| Tool                                   | Ownership                                                                           |
| -------------------------------------- | ----------------------------------------------------------------------------------- |
| [Monogram](/ai-clis/monogram/overview) | Current-code symbol and call intelligence; Monogit stores commit-time structure     |
| [MonoFlow](/ai-clis/monoflow)          | Composes Monogit history with current code, docs, watcher events, and saved diffs   |
| [Work Wiki](/ai-clis/work-wiki)        | Links work artifacts and saved diffs back to commits; it does not own Git structure |
| [NIIA Watcher](/ai-clis/niia-watcher)  | Detects freshness events and drives stored-policy replay through NIIA               |
