feat(repair): regenerator + supplement 防御修复 + 迁移脚本
- 新增 app/tree/repair/regenerator.py(VLM 重生成 + 级联修复) - supplement.py: deduplicate_field str() 防御 + inject_value strip - patch.py: ruff format 格式化 - repair_trees.sh: conda source 激活修复 - 新增 migrate_from_trm4.sh 迁移工具 - enhance/__init__.py → repair/__init__.py 重命名 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+4
-12
@@ -15,9 +15,7 @@ APPENDIX_MAX_CHARS = 2000 # appendix 区软上限(守设计「长度上限+wa
|
||||
MOMENTUM_START = "<!-- MOMENTUM_START -->"
|
||||
MOMENTUM_END = "<!-- MOMENTUM_END -->"
|
||||
MOMENTUM_MAX_CHARS = 2000 # momentum 区软上限(与 appendix 一致:超限 warning 不截断)
|
||||
MOMENTUM_HEADING = (
|
||||
"## 动量指导(每轮重写,勿手改)" # replace_momentum 写入的固定标题行
|
||||
)
|
||||
MOMENTUM_HEADING = "## 动量指导(每轮重写,勿手改)" # replace_momentum 写入的固定标题行
|
||||
|
||||
|
||||
def momentum_region_bounds(text: str) -> tuple[int, int] | None:
|
||||
@@ -303,9 +301,7 @@ def _insert_at(content: str, at: int, payload: str) -> str:
|
||||
return head + "\n\n" + payload + "\n"
|
||||
|
||||
|
||||
def _do_append(
|
||||
content: str, payload: str, ranges: list[tuple[int, int]]
|
||||
) -> tuple[str, str]:
|
||||
def _do_append(content: str, payload: str, ranges: list[tuple[int, int]]) -> tuple[str, str]:
|
||||
"""执行 append 操作,返回更新后内容与状态字符串。"""
|
||||
return _insert_at(content, _append_at(content, ranges), payload), "applied_append"
|
||||
|
||||
@@ -351,9 +347,7 @@ def _do_replace_delete(
|
||||
return new_content, "applied_" + op
|
||||
|
||||
|
||||
def _apply_one(
|
||||
content: str, edit: dict, ranges: list[tuple[int, int]]
|
||||
) -> tuple[str, dict]:
|
||||
def _apply_one(content: str, edit: dict, ranges: list[tuple[int, int]]) -> tuple[str, dict]:
|
||||
"""应用单条 edit,返回 (更新后内容, 状态报告)。"""
|
||||
if not isinstance(edit, dict):
|
||||
return content, {
|
||||
@@ -382,9 +376,7 @@ def _apply_one(
|
||||
return content, report
|
||||
|
||||
if op in ("replace", "delete"):
|
||||
content, report["status"] = _do_replace_delete(
|
||||
op, content, target, payload, ranges
|
||||
)
|
||||
content, report["status"] = _do_replace_delete(op, content, target, payload, ranges)
|
||||
return content, report
|
||||
|
||||
logger.warning("未知 op,跳过: {}", op)
|
||||
|
||||
Reference in New Issue
Block a user