feat(mcp): 基座换行分帧与 isError 映射;新增 dwg_review 审查 Agent

基座(cad_mcp_frame):
- 新增 RecvOneFrame: 以 '\n' 为消息边界分帧,去掉单次 recv(2048) 限制(上限 8MB);
  用 select 短探测兼容不发 '\n' 的旧客户端;clientSocket 设 SO_RCVTIMEO 防卸载卡死
- JSON-RPC id 支持 string/number;无 id 的通知不回包
- isError 映射: 协议级错误保留顶层 error,工具执行错误转 result.isError=true
- 响应补 '\n' 作为消息边界

Agent(新增 dwg_review 包):
- mcp_client: 唯一 TCP/JSON-RPC 封装(单飞锁/分帧/重试/兼容 error 与 isError)
- cad_tools: 从 tools/list 动态建表,含 15 个只读白名单
- phases: planning -> evidence -> review(受控只读取证子循环)-> report
- annotator: 批注回写 AI_REVIEW 层,支持 dry-run 与撤销
- config: 配置全部走环境变量;Windows 下回退读注册表以读到新设的系统变量

其它: 新增 verify_mcp_frame.py 验证脚本;.gitignore 补 Python/AutoCAD 锁文件规则;
ai.memory 记录架构决策与实测结论
This commit is contained in:
gjm committed 2026-10-13 23:44:11 +08:00
1 parent 3b1cc88262
commit ec5292debe
20 files changed
+1502 -20

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
"""审查运行的共享上下文。"""
from dataclasses import dataclass
from . import config
from .cad_tools import CadTools
from .checklist import load_checklist
from .llm_client import LlmClient
from .mcp_client import McpClient
@dataclass
class ReviewContext:
client: McpClient
tools: CadTools
llm: LlmClient
checklist: dict
max_frames: int = 0
frame_limit: int = 200
max_iters: int = 4
annotate: bool = False
dry_run: bool = False
@classmethod
def create(cls, *, need_llm=True, **overrides):
client = McpClient()
tools = CadTools(client)
llm = LlmClient() if need_llm else None
checklist = load_checklist()
params = dict(
client=client,
tools=tools,
llm=llm,
checklist=checklist,
max_frames=config.MAX_FRAMES,
frame_limit=config.FRAME_ENTITY_LIMIT,
max_iters=config.REVIEW_MAX_ITERS,
)
params.update(overrides)
return cls(**params)