
CodeClone
io.github.orenlab由 GitHub 帳號 orenlab 發布v2.0.3更新於 Oct 30, 2026
A structural review layer for Python — baseline-aware, deterministic, built for CI and AI agents
概覽
CodeClone 為 AI 程式助理提供針對 Python 儲存庫的確定性、基線感知結構審查層,並透過唯讀 MCP 控制面管理受控變更。
- 可以做什麼
- 分析儲存庫並產生單一標準結構報告:複製碼、複雜度、耦合、內聚、死碼、模組圖、API 清單與覆蓋率關聯
- 記錄並比對已提交的結構基線,區分既有債務與本次變更引入的迴歸
- 執行受控變更:記錄意圖、對應影響範圍、劃定可編輯邊界並給出 edit_allowed 結論,之後驗證實際補丁並產生審查回執
- 依目前分析執行提供有界、任務範圍內的實作脈絡與呼叫關係
- 檢索並保存本機工程記憶,包括筆記、風險、測試錨點與先前的變更軌跡
- 提供分析與控制器狀態的診斷與可觀測性資訊
- 適用情境
- 適用於 AI 助理修改 Python 程式碼庫、且希望在變更前後以確定性方式檢查結構範圍與迴歸的情況;也適合在不必先清理歷史債務的前提下,對複製碼、指標、API 破壞與覆蓋率設定 CI 關卡。
- 執行需求
- 以本機 stdio 程序執行,需要 Python 3.10 或更新版本。MCP 控制面需從 codeclone 套件加上 mcp 附加元件安裝,並以 codeclone-mcp 指令啟動;README 將控制器、記憶與脈絡功能標為 2.1 alpha 預發布。不需託管服務、雲端帳號、API 金鑰或環境變數。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 CodeClone,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Deterministic Structural Change Controller for AI-assisted Python development
Let agents move fast.
Keep structural change explicit, bounded, and verifiable.
[!IMPORTANT] Sections marked
2.1 alpharequire the CodeClone 2.1 prerelease. Everything else works with the current stable release, CodeClone 2.0.2.
What is CodeClone?
CodeClone helps developers use AI coding agents without losing control of structural change.
Before an agent edits code, CodeClone records the intended change, maps the structural blast radius, and establishes explicit edit boundaries. After the edit, it compares the real patch with the declared scope, verifies structural regressions, and leaves an auditable review receipt.
CodeClone does not generate or rewrite source files, and it does not ask an LLM to decide whether a structural change is safe. Every finding and every gate comes from deterministic repository facts shared across agents, human reviewers, IDEs, reports, and CI.
CodeClone requires no hosted service or cloud account. Analysis state, controller state, Engineering Memory, and trajectories are stored locally.
Why intent comes before the diff
Most review tools begin after the patch already exists. CodeClone begins earlier:
Agent scope expansion can look reasonable in the final diff. A narrow task may quietly spread into shared helpers, tests, configuration, public APIs, or unrelated modules.
By the time that expansion reaches the final diff, it already looks intentional. CodeClone catches it at the declared boundary instead — by comparing what the agent said it would change with what it actually changed.
Quick start
Requires Python 3.10 or newer.
1. Analyze a repository
Run the stable release without installing anything:
Prefer a browsable report? Generate the HTML view and open it:
Once you use it regularly, install it as a local tool:
2. Record the current structural baseline
Before asking an agent to change the repository, capture the accepted state once:
The baseline records the structural debt that already exists. Future analysis can then separate new regressions from findings that were already present, so agents and reviewers can focus on what the current change introduced.
Updating the baseline is an explicit governance action. Do not regenerate it merely to make a failing check pass.
3. Connect your AI agent — 2.1 alpha
Continue to Agent change control below to install the MCP control surface and wire CodeClone into Claude Code, Cursor, VS Code, Codex, or Claude Desktop.
One canonical structural report
CodeClone runs one deterministic analysis and renders the same canonical report through every supported surface.
The report covers:
- function, block, and segment clones;
- clone drift and duplicated branch families;
- complexity, coupling, cohesion, dependency cycles, and dead code;
- Module Map — a package/module dependency graph with cycle, hub, overloaded-module, and unwind-candidate views;
- Guided Finding Review — a prioritized review queue with shared finding cards, filters, and progress tracking;
- public API inventory and baseline-aware API break detection;
- external coverage joined with structural hotspots;
- deterministic structural health and review priorities.
How CodeClone works · Canonical report contract
Baseline-aware governance and CI
The baseline is a versioned, integrity-checked contract that records the accepted structural state of the repository.
It lets CodeClone and connected agents distinguish:
- findings that already existed;
- regressions introduced by the current change;
- deliberate baseline updates approved by the user.
Check future changes against the committed baseline:
Use CodeClone in GitHub Actions:
CI can reject newly introduced clones, metric regressions, API breaks, and coverage regressions without requiring the existing repository to be clean first.
Baseline contract · CI integration and quality gates
How CodeClone differs
Linters check style and correctness file by file. Clone detectors report duplication and stop there. Hosted review bots ask a model for an opinion about a finished diff.
CodeClone combines CFG-based clone detection, multi-metric baseline governance, and a read-only MCP control surface in one local-first, open-source package — and applies them before the edit happens, not only after. Structural facts are computed deterministically, so the same input always produces the same verdict, in the terminal, in CI, and inside your agent's loop.
Agent change control — 2.1 alpha
Install the MCP control surface
The server exposes 38 MCP tools covering analysis, change control, blast radius, memory, and diagnostics. Responses
are built for agent loops: deterministic next_tool guidance, token-budget-aware payloads, and replies that keep
mandatory control facts inline while linking full evidence for drill-down.
Before gating agents or CI, confirm [tool.codeclone] and local gitignore hygiene:
See Repository setup and readiness.
Wire it into your client
Every client uses the same MCP interface and the same canonical structural facts.
The controlled-change workflow
For an agent, the normal workflow is:
Analyze. CodeClone builds one canonical structural report for the repository and compares it with the accepted baseline.
Start. start_controlled_change:
- records the agent's intent;
- maps structural blast radius;
- separates editable paths from review context and do-not-touch boundaries;
- exposes the regression budget relative to the accepted baseline;
- returns the authoritative
edit_allowedresult.
Edit. The agent writes the code. CodeClone does not generate or rewrite source files. Where the host supports
hooks, integrations can stop edits unless edit_allowed=true. While editing, the agent stays oriented through
Live Implementation Context instead of rediscovering the repository with broad
searches.
Finish. finish_controlled_change:
- resolves the actual changed files;
- checks declared scope against the real patch;
- verifies structural changes;
- validates optional review claims;
- records Patch Trail evidence;
- produces an auditable review receipt.
If the patch crosses the declared boundary or introduces regressions beyond the budget, verification fails — and the receipt records exactly where and why. The result is not an AI opinion about the patch. It is a deterministic comparison between declared intent, repository structure, the accepted baseline, and the actual change.
Read the Structural Change Controller guide
Live Implementation Context
get_implementation_context serves the agent bounded, task-scoped context directly from the current analysis run:
- structural context and call relationships for the declared edit scope;
- contract-oriented truth maps and test anchors;
- freshness signals and active intent boundaries.
There is no separate vector database drifting behind the code, and no watcher daemon re-indexing the tree. Context comes from the same analysis that produces findings and gates — so what the agent reads is what the verifier will check. Context is read-only: it informs edits but never authorizes them.
Also in the 2.1 line
- Platform Observability — development-time tracing of CLI, MCP, analysis phases, database activity, and payload pressure, so you can see what CodeClone itself is doing and what it costs.
- Corpus Analytics — offline intent clustering and interpretability over recorded controlled changes, with versioned profiles and inspectable JSON/HTML outputs.
Engineering Memory — 2.1 alpha
Engineering Memory gives agents durable, repository-specific context without treating model output as project truth.
The local SQLite store can contain:
- architecture and contract notes;
- risks, test anchors, and public surfaces;
- git and change-control provenance;
- prior trajectories and Patch Trail evidence;
- recurring advisory patterns called Experiences.
Agent-created records remain drafts until a human approves them.
Retrieval is hybrid — FTS5/BM25 lexical search, optional LanceDB vector search, and Reciprocal Rank Fusion combining the two — with fully reproducible ranking.
Memory can guide an agent. It cannot authorize edits, override blast radius, change a gate, or replace canonical report facts.
Engineering Memory documentation · Trajectories and Experiences
Trust boundaries
- Structural findings and gates come from deterministic analysis, not LLM judgment.
edit_allowedis an explicit controller result; status or advisory ownership does not grant permission.- Read-only analysis commands do not modify source code or project governance state.
- Baseline updates are explicit user-approved governance actions.
- Controller and memory operations write only to their explicit local state stores.
- Memory, trajectory, and implementation-context evidence remain advisory.
stdiois the recommended transport for local clients.- Remote HTTP exposure requires explicit
--allow-remote.
Contributing
Bug reports, feature discussions, and pull requests are welcome — start with Issues or Discussions, or join the Discord.
Run the repository version from source:
Documentation
License
- Code: MPL-2.0
- Documentation: MIT
See LICENSES.md for the license scope map.
Links
來源:README.md,提交 51a59ca
工具
0版本歷史
1- v2.0.3最新Oct 29, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分