Repotector

io.github.dir-ai由 GitHub 帳號 dir-ai 發布v1.6.0更新於 Oct 24, 2026

The repo guardian AI agents handshake with before they touch your code.

概覽

AI 產生的概覽

為程式碼倉庫提供共享記憶:AI 代理進入時握手,取得地圖、既定決策與前一位代理的交接,離開時登記。

可以做什麼
  • 握手、定位與簽退:handshake、city_map、depart、register、journal、whats_next
  • 檢索與重用:find_existing、atlas_query、dna_query、dna_coverage、dna_diff
  • 評估變更影響:blast_radius、canon_check、merge_check 試合併、claim 宣告工作區
  • 執行品質閘門:quality_gates 與受保護路徑檢查,只依相對於初始基準的迴歸回報
  • 用 declare_mission 把一次造訪綁定到任務契約,並在 depart 時記錄決策
適用情境
適合由多個 AI 代理或工作階段輪流修改的倉庫,避免每個新代理重新摸索結構、推翻前人的修正。也適合希望提交前或 CI 只攔阻新增迴歸、不因既有債務失敗的情境。
執行需求
透過 npx 以 stdio 在本機執行(需要 Node.js,純 ESM)。需在每個倉庫執行初始化指令,掃描倉庫、把 MCP 伺服器寫入 .mcp.json 並寫入入口說明區塊。機器上需要 git;未宣告帳號、API 金鑰或網路存取。
安裝前請注意
初始化會寫入倉庫檔案:.repotector 目錄、JOURNAL.md,以及在既有檔案中寫入帶標記的區塊,並修改 .mcp.json。它可安裝提交前掛鉤,在閘門出現迴歸時阻擋提交,並在登記簿中記錄造訪工作階段、git 變更與決策記錄。鎖被說明為合規訊號而非存取控制,登記簿也不防竄改。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Repotector,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Repotector ⬡

The repo that remembers.

Every AI agent that visits your repo starts from zero: it re-derives the map, re-discovers the conventions, re-breaks the thing the last agent just fixed. Repotector gives the repo itself a memory. An arriving agent knocks at the front door, handshakes, and is handed the map, the standing decisions, and the last visitor's briefing; on the way out it signs the register. The next agent continues in two minutes instead of wandering for an hour — and a refactor doesn't quietly break what already works.

Portable and self-contained: pure Node ESM, two dependencies (@modelcontextprotocol/sdk, zod). Works on any repo — JS/TS deeply, other stacks in honest orientation-lite.

Install into any repo

bash
cd /path/to/your/reponpx repotector init

init scans the repo (never fails you on day one — see grandfathered baseline below), wires the MCP server into .mcp.json, and writes the doorway blocks so every arriving agent knows to handshake. It writes only inside .repotector/ and inside REPOTECTOR:BEGIN/END markers — your prose and config are never overwritten. See SECURITY.md for the exact posture.

Under .repotector/:

FileWhat it is
intent.jsonThe contract: standards, required paths, bounded contexts, canon rules.
atlas.jsonThe map: exports/imports/purpose/kind per file, routes, components, stack, and a deterministic fingerprint.
dna.jsonReverse-engineered entities + API contracts + intent.
baseline.jsonThe grandfathered floor — the debt that existed on day one.
proof.jsonGate verdict, regressions vs grandfathered debt.
register.jsonlThe visitor ledger: who entered, when, what they touched, who's inside.
dna.inferred.jsonReverse-DNA clauses for foreign repos (skipped when a .psx/ mirror exists).

Plus, at the repo root, a regenerated JOURNAL.md — the diario di bordo, newest-first, that handshake serves the tail of so the next agent continues prior work instead of re-deriving it.

The front door (handshake-first)

The MCP server refuses deep tools until an agent calls handshake — and the initialize response already tells the agent to. In return the agent gets oriented in one call, and its exit is recorded for the next one.

  • handshake({ who, model?, purpose? }) — orientation, ground rules, live gate verdict, map freshness, passport. Read-only and fast (no tree walk).
  • city_map() — intent, stack, built-vs-missing, brain pointers. On a non-JS repo it says orientation-lite instead of faking an empty map.
  • find_existing({ intent }) — REUSE: does it already exist? Don't rebuild.
  • blast_radius({ changedFiles? }) — PROTECT: transitive dependents + impacted routes/components. Omit changedFiles to use the git diff.
  • canon_check({ changedFiles? }) — INTEGRATE: the repo's canon rules.
  • atlas_query({ query }) — keyword search across the map.
  • quality_gates() — line-budget / structure / secret-hygiene, reported as regressions vs grandfathered debt.
  • register() — who's inside now and the full crossing log.
  • journal({ limit? }) — the repo's recent story: what prior agents did and left unfinished. whats_next() — the sensible next work, derived from DNA gaps + open threads + TODOs, every suggestion citing its evidence.
  • dna_query({ clause?, topic? }) — what the repo specified (authored from a .psx/ mirror, or inferred, never merged). dna_coverage() — per clause: implemented / partial / missing. dna_diff({ changedFiles? }) — which clauses a change touches.
  • depart({ summary? }) — sign out; the git delta of your visit is recorded even if you forget the summary. Your summary becomes the next agent's briefing.

Grandfathered baseline — never red on day one

A guardian that fails your repo the moment you install it gets uninstalled the moment you install it. So init snapshots the debt that already exists (oversize files, tracked secrets, missing paths). Gates then fail only on regressions against that floor — a new offender, an offender that grew, a new leak. Pre-existing debt is reported loudly, never blocking. repotector baseline re-snapshots after you pay it down.

v1.2 "Gatekeeper" — from advisor to checkpoint

  • Commit guard — repotector hooks installs a pre-commit that runs the gates; gates exits non-zero on regressions, so hooks and CI actually block. Grandfathered baseline means it never blocks day-one debt — only new damage.
  • Protected paths — intent.protect.paths globs (CI workflows, LICENSE…) that agents must not touch: change-based, never grandfathered, overridden only by editing the intent (an explicit, diffable act).
  • Claims — claim({ paths }) declares your work zone; overlapping claims from live sessions answer granted:false with who/why. Advisory by design (blocking would be theater on a filesystem we don't control); claims die with the session.
  • Decision records — depart({ decisions: [{ chose, over, because }] }) writes the why to the register and projects DECISIONS.md; the handshake serves standing decisions and decisions_query answers "was this deliberate?" — so agent 2 doesn't undo agent 1's choice.
  • repotector doctor — one command, semaphore answer to "how protected is this repo, really?", with a fix for every red.

v1.5 "Mission" — the single verifiable chain

The whole visit becomes one auditable contract:

handshake → declare_mission → (auto)claim → work        → off-claim / forbidden reconciliation        → evidence pack (machine-verified vs agent-declared)        → depart → the next agent inherits it all
  • declare_mission({ goal, acceptance, claimPaths?, forbiddenPaths?, risk? }) — bind the visit to a contract: your zone is auto-claimed (conflicts surfaced), and you get a one-shot briefing (gates, merge status, standing decisions, protected paths).
  • Evidence pack at depart — the register records what the MACHINE verified (gates verdict, trial-merge clean/conflicted, files touched, off-claim, forbidden violations) strictly apart from what the AGENT declared (per-criterion self-report); unreported criteria are listed, never assumed. "Done" becomes something the register can check, not a courtesy.
  • Other agents see missions in progress at handshake — what you're doing, not just where.

v1.3 "Merge Guard" — commit without colliding

  • merge_check — a zero-damage TRIAL merge (git merge-tree) of HEAD against the integration base, run BEFORE you commit: reports clean/conflicted with the exact files, each attributed to who holds that zone (live claims — and, in PSX Workbench repos, the Merge Machine's leases via the .psx mirror). CLI: repotector merge-check [target] (exit 1 on conflicts, so hooks/CI can gate on it). Zero network: it trial-merges against your LOCAL refs and says so — fetch first for the freshest truth.

Resilient register — agents die without signing out

Sessions that enter and never leave (the agent was killed, the pipe closed) are auto-departed on the next handshake, with the git delta of what they touched. The ledger never fills with immortal open sessions, and a depart carries real work even when nobody called it.

CLI

bash
npx repotector init          # scan, wire .mcp.json, write the doors — day-one greennpx repotector refresh       # re-derive the map + re-stamp the doorway blocksnpx repotector handshake     # orientation + live gate + passport (logged visit)npx repotector city-map      # built-vs-missing + brain pointersnpx repotector dna-coverage  # per specified clause: implemented / missingnpx repotector whats-next    # the sensible next work, with evidencenpx repotector journal       # the diario di bordo (regenerates JOURNAL.md)npx repotector gates         # regressions vs grandfathered debtnpx repotector baseline      # re-snapshot the grandfathered floornpx repotector register      # the visitor ledgernpx repotector lock <pass>   # optional passphrase gate on the deep mapnpx repotector mcp           # start the stdio MCP server

Docker

The image on GHCR wraps the CLI and the MCP server; the guarded repo is mounted, never baked in:

bash
docker run --rm -v "$PWD:/repo" ghcr.io/dir-ai/repotector initdocker run --rm -v "$PWD:/repo" ghcr.io/dir-ai/repotector gatesdocker run -i --rm -v "$PWD:/repo" ghcr.io/dir-ai/repotector mcp   # stdio MCP

Multi-arch (amd64/arm64), built and smoke-tested by CI on every release tag (see Dockerfile).

GitHub Action

Guard a repo in CI with one step — grandfathered semantics apply, so the job fails only on regressions, never on day-one debt:

yaml
- uses: dir-ai/repotector@main  with:    command: gates     # default; any CLI command works    version: latest    # pin an exact npm version for reproducible CI

Honesty

Repotector guards repos, so it holds itself to its own standard. The lock is a compliance signal, not filesystem access control; the register is append-integrity, not tamper-proof; a static badge is self-reported. It spawns only git, makes no network calls, and pins exact versions in .mcp.json. The full threat model is in SECURITY.md — no security theater.

Determinism

The Atlas fingerprint is a SHA-256 over sorted source contents (16 hex chars), no timestamps — the same tree always fingerprints the same. Large files (>1MB, generated/minified) are marked, never read into the fingerprint. builtAtHead stamps the git sha so freshness can be checked without a walk.

License

MIT © PSX System. The core an agent needs in a repo is free forever; the compounding brain (Genome cloud, authored DNA) is the premium layer.

來源:README.md,提交 384ca96

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.6.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分