{"id":46250393,"url":"https://github.com/mmnto-ai/totem","last_synced_at":"2026-07-07T02:00:40.888Z","repository":{"id":341159017,"uuid":"1168851303","full_name":"mmnto-ai/totem","owner":"mmnto-ai","description":"Deterministic, file-anchored toolkit for AI-agent work — context you can query, rules you can enforce, state you can derive.","archived":false,"fork":false,"pushed_at":"2026-07-04T18:13:42.000Z","size":12943,"stargazers_count":15,"open_issues_count":352,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-04T20:07:41.005Z","etag":null,"topics":["agents-md","ai-agents","ast-grep","claude-code","cli","code-review","codebase-governance","deterministic","developer-tools","git-hooks","human-in-the-loop","linting","mcp-server","monorepo","pnpm","rule-engine","static-analysis","typescript","vector-database"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmnto-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":".github/CLA.md"}},"created_at":"2026-02-27T21:46:24.000Z","updated_at":"2026-07-04T18:13:03.000Z","dependencies_parsed_at":"2026-05-16T20:01:25.153Z","dependency_job_id":null,"html_url":"https://github.com/mmnto-ai/totem","commit_stats":null,"previous_names":["mmnto-ai/totem"],"tags_count":872,"template":false,"template_full_name":null,"purl":"pkg:github/mmnto-ai/totem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnto-ai%2Ftotem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnto-ai%2Ftotem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnto-ai%2Ftotem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnto-ai%2Ftotem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmnto-ai","download_url":"https://codeload.github.com/mmnto-ai/totem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnto-ai%2Ftotem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35209350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents-md","ai-agents","ast-grep","claude-code","cli","code-review","codebase-governance","deterministic","developer-tools","git-hooks","human-in-the-loop","linting","mcp-server","monorepo","pnpm","rule-engine","static-analysis","typescript","vector-database"],"created_at":"2026-03-03T22:05:43.814Z","updated_at":"2026-07-07T02:00:40.794Z","avatar_url":"https://github.com/mmnto-ai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Totem\n\n[![npm version](https://img.shields.io/npm/v/@mmnto/totem.svg)](https://www.npmjs.com/package/@mmnto/totem)\n[![CI](https://github.com/mmnto-ai/totem/actions/workflows/ci.yml/badge.svg)](https://github.com/mmnto-ai/totem/actions/workflows/ci.yml)\n[![MCP Server](https://img.shields.io/badge/MCP-Server-1f6feb)](https://github.com/mmnto-ai/totem/tree/main/packages/mcp)\n[![License: Apache-2.0](https://img.shields.io/github/license/mmnto-ai/totem)](LICENSE)\n[![Node](https://img.shields.io/badge/node-%3E%3D20-339933?logo=nodedotjs\u0026logoColor=white)](https://nodejs.org)\n[![pnpm](https://img.shields.io/badge/pnpm-managed-F69220?logo=pnpm\u0026logoColor=white)](https://pnpm.io)\n\n**Editor integrations:** [Claude Code](.claude/) · [Gemini CLI](.gemini/) · [GitHub Copilot](.github/copilot-instructions.md) · [JetBrains Junie](.junie/) · others in progress. See [`AGENTS.md`](AGENTS.md) for how integration works.\n\n_AI coding agents are brilliant goldfish. Totem is the file-based substrate they read from and write to. It keeps architectural context durable across sessions._\n\n\u003e `totem lint` runs entirely offline and completes in under 2 seconds. No LLMs in the loop.\n\nWhen using LLMs on projects, I found that agents kept making the same architectural mistakes. They forgot context and reinvented helpers that already existed. The velocity was great, but the architectural integrity degraded quickly. Every PR became an exhausting back-and-forth with review bots over the same nits.\n\nThey can make the wrong way look brilliant (until you realize what happened). They'll rarely ask: _\"doesn't a shared helper already exist for this?\"_\n\nTotem is what I extracted to solve that friction. It's a file-based toolkit. The lint engine, substrate, and knowledge index are deterministic; the compiler and review commands are LLM-powered. Agents read from and write to a substrate of plain markdown lessons, a queryable knowledge index, compiled lint rules, and CLI primitives — so context stays queryable, rules stay enforceable, and state stays derivable. The structural pieces (the substrate, the index, the compiled-rule lint engine) ship today. The discipline and telemetry layers (whether agents consistently query the index, whether compliance gets measured end-to-end) are in active development; see [What Works and What Doesn't](#what-works-and-what-doesnt) for the honest split.\n\n---\n\n- [Documentation is merely a suggestion](#documentation-is-merely-a-suggestion)\n- [How Mistakes Become Rules](#how-mistakes-become-rules)\n- [The Queryable Knowledge Index](#the-queryable-knowledge-index)\n- [What's in the Box](#whats-in-the-box)\n- [What Works and What Doesn't](#what-works-and-what-doesnt)\n- [Quickstart](#quickstart)\n- [Documentation \u0026 Workflows](#documentation--workflows)\n\n---\n\n## Documentation is merely a suggestion\n\nI tried the heavy orchestration approach that dictates every step of the agent's workflow, and found it rigid and disruptive to the human-in-the-loop dynamic. Totem is built on a different philosophy: **Tripwires, Not Tracks.**\n\nYou provide an open field surrounded by electric fences. The LLM is free to code however it wants, but when it attempts to alter the permanent state of the world (e.g., `git push`), it hits a deterministic tripwire.\n\nTotem turns a plain-English markdown lesson into a physical constraint that a local, zero-LLM linter enforces:\n\n**Input:** (`.totem/lessons/no-child-process.md`)\n\n```markdown\n## Lesson - Never use native child_process\n\nTags: architecture\nDirect use of `node:child_process` is forbidden outside `core/src/sys/`. Use the `safeExec` shared helper instead.\n```\n\n**Output:** (`git push` blocked on the agent's machine)\n\n```bash\n$ git push\n[Lint] Running compiled rules (zero LLM)...\n### Warnings\n- **packages/cli/src/git.ts:22** - Never use native child_process\n  Pattern: `import { execSync } from 'node:child_process'`\n  Lesson: \"Direct use of `node:child_process` is forbidden outside `core/src/sys/`. Use the `safeExec` shared helper instead.\"\n[Lint] Verdict: FAIL - Fix violations before pushing.\n```\n\nThe \"wrong\" way becomes the \"loud\" way. No LLM in the loop at runtime. Just sub-second, offline enforcement.\n\n## How Mistakes Become Rules\n\nThe core loop is simple. A mistake gets caught in a PR review, a bot nit, or a production bug. I write a plain-English lesson that explains what went wrong. `totem lesson compile` turns the lesson into an AST or regex rule, and `totem lint` enforces it on every push from that point forward. The same compiled pattern can't ship past the linter again once the pre-push hook or CI runs and the rule matches.\n\n```mermaid\ngraph LR\n    Catch[\"Catch a mistake\"] --\u003e|write a lesson| Compile[\"totem lesson compile\"]\n    Compile --\u003e|generates rule| Enforce[\"totem lint\"]\n    Enforce --\u003e|catches next attempt| Catch\n\n    style Catch fill:#4b3a75,stroke:#9b72cf,color:#fff\n    style Compile fill:#5e3a24,stroke:#e67c3b,color:#fff\n    style Enforce fill:#1a4d2e,stroke:#34a853,color:#fff\n```\n\nWhen a rule matches comments or string literals instead of actual code, `totem doctor` flags it as noisy, and `totem lesson compile --upgrade` re-runs the compiler with a precision-targeted prompt. I'd rather have 300 precise rules than 1,000 noisy ones.\n\n## The Queryable Knowledge Index\n\nAI agents are stateless by default. Every new session starts from zero, with no record of prior incidents or the shared helpers you've already written. You end up re-explaining the same context over and over.\n\nTotem's approach is to ship a queryable knowledge index that holds your lessons and ADRs in a local semantic store (Tree-sitter + LanceDB). The index lives in your repo as plain files, so there's no cloud dependency and no vendor lock-in.\n\nAny MCP-compatible agent can query it. Before your agent writes a line of code, it can ask \"what patterns are banned in this codebase?\" or \"what's the architecture of the auth system?\" and get a real set of ranked candidates from your project's actual history (the agent still has to read them and synthesize — a queryable index returns candidates, not pre-synthesized answers). Whether an agent actually issues that query before deriving from scratch is currently an agent-discipline question — see [What Works and What Doesn't](#what-works-and-what-doesnt).\n\nWith [Cross-Repo Mesh](docs/wiki/cross-repo-mesh.md), federation across sibling repos is supported via the opt-in `linkedIndexes` config — one repo's lessons become queryable from all linked repos when cohorts opt in, so context doesn't stop at the repo boundary.\n\n## What's in the Box\n\nTotem is a set of CLI tools, not a framework. Building blocks you wire into whatever CI and workflow you already have. Several commands support `--json` or `--format json` for scripting; check `totem \u003ccommand\u003e --help` for the format options on a specific command.\n\n| Command                | What it does                                                                                                   |\n| ---------------------- | -------------------------------------------------------------------------------------------------------------- |\n| `totem lint`           | Run all compiled rules against your code. Zero LLM, offline, sub-second.                                       |\n| `totem lesson compile` | Turn plain-English lessons into AST or regex rules.                                                            |\n| `totem lesson extract` | Pull lessons from PR reviews and bot comments.                                                                 |\n| `totem doctor`         | Flag locally noisy rules via Trap Ledger telemetry, suggest upgrades.                                          |\n| `totem spec`           | Generate an implementation spec from a GitHub issue before you touch any code (LLM-powered, requires API key). |\n| `totem review`         | LLM-powered architectural review on an uncommitted diff (requires API key).                                    |\n| `totem sync`           | Rebuild the semantic index from your lessons and docs.                                                         |\n| `totem hook install`   | Install Git hooks (`pre-push` lint gate).                                                                      |\n\nThe built-in MCP server exposes the knowledge base to any compatible agent. It's the same index, with no extra setup.\n\n## CI/CD and GitHub Integration\n\nBecause `totem lint` is deterministic and runs in under two seconds, it drops cleanly into a CI pipeline. The three output formats are `text` (default), `json` (for scripting), and `sarif` (for security dashboards):\n\n```bash\ntotem lint --format sarif --out totem.sarif\n```\n\nPipe the SARIF file into GitHub Code Scanning (via the standard `github/codeql-action/upload-sarif` action) or any SARIF-compliant tool, and Totem's tripwires show up as inline PR annotations right where the developer wrote the code that violated a rule. The stream is deliberately scoped to error-severity findings so PR reviews don't drown in probationary warnings. Warnings stay as local telemetry until a rule has enough signal to graduate.\n\nThe same `--format sarif` flag works on the standalone `totem-lite` binary for CI environments without Node.js. See [CI/CD Integration](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/ci-integration.md) for pipeline recipes.\n\n## What Works and What Doesn't\n\nTotem has three layers, and I want to be honest about where each one stands:\n\n1. **The enforcement layer works.** Compiled rules and Git hooks catch violations mechanically and offline, in under 2 seconds. This is the load-bearing floor that everything else stands on. Nothing on that floor touches the network, so it runs natively in air-gapped environments. No source code leaves your machine.\n2. **The planning layer works too, to my surprise.** Before the agent writes any code, `totem spec` pulls the GitHub issue body and queries the knowledge base for relevant lessons and ADRs. It writes a structured implementation spec to `.totem/specs/\u003cissue\u003e.md`. The spec includes architectural context, files to examine, edge cases the issue description missed, and task-by-task TDD directives with retrieved lessons injected inline as invariants. None of this is a hard tripwire. The agent could write a vague spec and ignore the retrieved context. But in practice the structured prompt reliably catches \"I'm about to reinvent a helper that already exists\" before the agent commits to an approach. A meaningful chunk of the velocity and architectural consistency I've been getting comes from this upstream gate, more than I expected when I first added it.\n3. **The knowledge index is real infrastructure.** The index exists. It's portable across repos, and any MCP agent can query it. But whether an agent _consistently acts_ on the context it retrieves is an open question I'm actively working through. Availability is deterministic. The agent's discipline is not.\n\nI built the enforcement layer because the upstream layers aren't enough on their own. An agent can have a clean spec, relevant lessons in context, and still drift when it gets deep into a task. The tripwires catch what the planning layer and the knowledge index miss. That's the whole point of keeping them as three distinct layers rather than one: each catches a different class of failure, at a different stage of the workflow.\n\n## Changelog\n\nSee [Releases](https://github.com/mmnto-ai/totem/releases) for recent updates.\n\n## Quickstart\n\nInitialize Totem in any project (Node, Python, Go, Rust):\n\n```bash\npnpm dlx @mmnto/cli init\n```\n\nThis scaffolds `totem.config.ts` and wires up the `pre-push` git hook. It also installs the baseline rule pack.\n\nRun the linter (zero setup, offline):\n\n```bash\npnpm dlx @mmnto/cli lint\n```\n\n### Standalone Binary (No Node.js Required)\n\nIf you are working in a non-JavaScript ecosystem (Rust, Go, Python) and don't want to install Node.js, you can download the **Totem Lite** standalone binary from the [GitHub Releases](https://github.com/mmnto-ai/totem/releases) page.\n\n```bash\n# Linux (x64)\ncurl -L https://github.com/mmnto-ai/totem/releases/latest/download/totem-lite-linux-x64 -o totem\nchmod +x totem \u0026\u0026 sudo mv totem /usr/local/bin/\n\n# macOS (Apple Silicon)\ncurl -L https://github.com/mmnto-ai/totem/releases/latest/download/totem-lite-darwin-arm64 -o totem\nchmod +x totem \u0026\u0026 sudo mv totem /usr/local/bin/\n```\n\nThe Lite binary includes the full AST engine and can run `totem init`, `totem lint`, and `totem hook install` completely offline. For Windows and other platforms, see the [Installation Guide](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/installation.md).\n\n## Documentation \u0026 Workflows\n\nSee the Wiki for how to use Totem to govern your workflows:\n\n- [**It Never Happens Again:**](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/it-never-happens-again.md) How to turn a PR mistake into a permanent project law in 60 seconds.\n- [**Governing AI Agents:**](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/governing-ai-agents.md) How to use hooks and MCP tools to enforce project rules on Claude and Gemini from Turn 1.\n- [**It Stops Crying Wolf:**](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/it-stops-crying-wolf.md) How the Self-Healing Loop automatically downgrades noisy rules based on developer frustration.\n\n### Deep Dives\n\n- [CLI Reference](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/cli-reference.md)\n- [Architecture \u0026 Workflows](https://github.com/mmnto-ai/totem/blob/main/docs/reference/architecture.md)\n- [MCP Server Setup](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/mcp-setup.md)\n- [CI/CD Integration](https://github.com/mmnto-ai/totem/blob/main/docs/wiki/ci-integration.md)\n\n## Open Source Commitment\n\nThe core toolkit (enforcement engine, `totem lesson compile`, MCP server, and self-healing loop) is Apache 2.0. If federation, hosted services, or centralized telemetry are introduced later, they are intended to be separate products, while the local toolkit remains Apache 2.0.\n\nSee [`COVENANT.md`](https://github.com/mmnto-ai/totem/blob/main/COVENANT.md) for details.\n\n## License\n\nApache 2.0 License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmnto-ai%2Ftotem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmnto-ai%2Ftotem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmnto-ai%2Ftotem/lists"}