AI编码
dev.to ·
@Avinash Amudala
面向编码 Agent 的本地第二大脑:Weftgate 0.2 的上下文、记忆与校验
Weftgate 0.2 是一个本地 Python 包,为编码 Agent 提供三项能力:有界上下文(返回源码位置与声明间静态关系,不加载文件正文)、记忆与验证。支持 codex、claude、cursor 等 Agent 的 setup 与 hooks,默认响应上限为 6000 UTF-8 JSON 字节。作者说明演示使用故意破坏的 fixture,并非现场基准测试。
AI推荐理由 Weftgate 0.2 是本地 Python 包,为编码 Agent 提供有界上下文、记忆与验证三项能力,明确说明不加载文件正文、不伪装成运行时调用图,并给出 CLI 用法与 6000 字节响应上限等具体约束,对 Agent 上下文管理有实际参考价值;但作者自述演示基于故意破坏的 fixture,非现场基准。
68
正文
Coding agents need more than another large context dump. They need a small set of relevant source locations, decisions that are still current, and evidence that their changes connect to the project correctly.
I maintain Weftgate. Version 0.2 puts those three jobs in one local Python package: understand, remember and verify.
Watch the captioned 78-second demo. It uses real CLI output from an intentionally broken fixture, not a field benchmark.
Understand with bounded context
pip install weftgate
cd /path/to/your/repo
weftgate setup --agents codex,claude,cursor,antigravity --hooks --instructions
weftgate card "POST /orders" --budget 1200
Enter fullscreen mode
Exit fullscreen mode
Use a route that exists in your project. The card contains source locations and static relationships between declarations, dependencies, env reads and route handlers. It does not load file bodies or pretend to be a runtime call graph. Ambiguous names and missing capabilities remain visible.
The default response is capped at 6,000 UTF-8 JSON bytes, including its accounting fields. That is an estimate of 1,500 tokens, not a guarantee for every model tokenizer. The ledger records actual payload bytes and omissions. It does not invent a savings percentage.
Remember decisions, then recheck their sources
weftgate remember "Order idempotency" "Keep duplicate requests idempotent." --file app/orders.py
weftgate recall "orders"
Enter fullscreen mode
Exit fullscreen mode
The path must exist. Weftgate stores an explicit note in a repository-scoped local SQLite database. On recall it checks the cited file hashes. If a file changes or vanishes, the note is hidden by default. The original hashes stay intact until you review and explicitly replace the note.
An unchanged file does not prove the saved prose true. Notes are untrusted context, not higher-priority instructions. There is no automatic transcript capture, embedding download or API key. This mnemo-derived lexical notebook is included in the public package; the separate private companion is not required.
Verify connections and hand off evidence
The gate checks env names, Python and Node imports, and static FastAPI or Starlette references. DATABSE_URL can be rejected against a declared DATABASE_URL; os.environ[key] remains advisory when its key cannot be resolved statically.
[weftgate.workflow]
commands = ["python -m pytest -q"]
Enter fullscreen mode
Exit fullscreen mode
weftgate checkpoint --run --require-ready
Enter fullscreen mode
Exit fullscreen mode
A checkpoint checks the current changed code, including staged and untracked source files. With explicit execution enabled it observes configured, allowlisted test commands. It distinguishes a proven failure, incomplete evidence, review findings, and a repository that changed while checking. Ready means these checks and commands passed against an unchanged file fingerprint. It does not certify the entire app.
Use the same tools across editors
CLI and MCP use the same implementation. Setup writes project configuration and workflow rules for Codex, Claude Code, Cursor and Antigravity. Completion hooks request bounded repair passes when a proven failure remains. Claude also has a pre-edit adapter for supported Edit/Write/MultiEdit operations.
Trust and enable hooks in each editor. Codex uses /hooks. The other new adapters run after writes, and no local hook is a complete enforcement boundary. Keep the GitHub Action required in branch protection when merges must be gated.
Validation includes 199 local tests, about 91% line coverage, CLI/MCP parity, stale-memory regressions and isolated package installation. See the validation record and activation guide. Every editor build has not been interactively certified.
Try it on a project you know well. I would value reproducible reports about confusing setup, useful context and false blocks. Source and quickstart.
Disclosure: this article and launch assets were prepared with AI assistance. Code behavior is backed by the linked tests and reproducible fixture evidence.