
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 分