@sakanano-moe/agenthelm 6.11.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/runtime/index.json +6 -6
- package/runtime/plugins/agent-pack/.codex-plugin/plugin.json +1 -1
- package/runtime/plugins/agent-pack/plugin.json +1 -1
- package/runtime/plugins/agent-pack/references/capability-config.md +11 -1
- package/runtime/plugins/agent-pack/runtime/agent_pack_codex_mcp.py +161 -0
- package/runtime/plugins/agent-pack/runtime/agent_pack_config.py +232 -53
- package/runtime/plugins/agent-pack/runtime/agenthelm.py +171 -23
- package/runtime/plugins/agent-pack/runtime/agenthelm_runtime.py +1 -1
- package/runtime/plugins/agent-pack/runtime/locale/en.json +13 -1
- package/runtime/plugins/agent-pack/runtime/mcp_server.py +5 -1
- package/runtime/plugins/agents-init/.codex-plugin/plugin.json +1 -1
- package/runtime/plugins/agents-init/content.json +2 -2
- package/runtime/plugins/agents-init/plugin.json +1 -1
- package/runtime/plugins/agents-init/skills/agents-init/AGENT.template.md +169 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/adopt.py +9 -1
- package/runtime/plugins/agents-init/skills/agents-init/scripts/init_project.py +74 -20
- package/runtime/plugins/agents-init/skills/agents-init/scripts/locale/en.json +7 -2
- package/runtime/plugins/agents-init/skills/agents-init/scripts/scaffold.py +5 -2
- package/runtime/plugins/agents-init/skills/agents-init/skill.json +1 -1
- package/runtime/plugins/opinion-manager/.codex-plugin/plugin.json +1 -1
- package/runtime/plugins/opinion-manager/plugin.json +1 -1
- package/runtime/plugins/opinion-manager/runtime/constants.py +3 -0
- package/runtime/plugins/project-orchestrator/.codex-plugin/plugin.json +1 -1
- package/runtime/plugins/project-orchestrator/plugin.json +1 -1
- package/runtime/plugins/project-orchestrator/references/case-workspaces.md +4 -0
- package/runtime/plugins/project-orchestrator/runtime/case.py +20 -2
- package/runtime/plugins/project-orchestrator/runtime/locale/en.json +5 -1
- package/runtime/plugins/project-orchestrator/runtime/memory.py +25 -8
- package/runtime/plugins/project-orchestrator/runtime/project_cli.py +4 -2
- package/runtime/plugins/project-orchestrator/runtime/project_maintain.py +6 -1
|
@@ -486,7 +486,7 @@ def run(args: Any, root: Path, inputs: Any) -> tuple[int, dict]:
|
|
|
486
486
|
notes.append(_("--agents-policy {0} 没有生效:AGENTS.md 不存在、不可读,或已与模板一致").format(policy))
|
|
487
487
|
elif policy != "keep":
|
|
488
488
|
agents_plan = _plan_agents(agents_text, policy, init_routes(args, agents_text), pristine[AGENTS],
|
|
489
|
-
templates
|
|
489
|
+
init.localized(templates, "region/agents-contract", inputs.language), inputs.language,
|
|
490
490
|
init.localized(templates, "region/privacy-contract", inputs.language)
|
|
491
491
|
if inputs.privacy_declared else None)
|
|
492
492
|
if agents_plan["replace"]:
|
|
@@ -592,6 +592,14 @@ def run(args: Any, root: Path, inputs: Any) -> tuple[int, dict]:
|
|
|
592
592
|
decided = []
|
|
593
593
|
# A file that gained a managed region is "kept and appended to"; only untouched files are "kept as they were".
|
|
594
594
|
appended = {str(m["path"]) for m in modifications if m["kind"] == "modify" and m.get("region")}
|
|
595
|
+
# Region-owned files have no whole-file finding anymore. Keep the adoption decision as an audit record,
|
|
596
|
+
# compatible with existing locks and refresh --keep decisions, without using it to compare user text later.
|
|
597
|
+
for name in sorted(appended):
|
|
598
|
+
scaffold.decide(root, f"content:{name}", "keep",
|
|
599
|
+
reason="adopt: kept the file that existed before adoption and appended a managed region",
|
|
600
|
+
fingerprint=scaffold.sha(files[Path(name)]), scope="project", apply=True,
|
|
601
|
+
state_dir=getattr(args, "state_dir", None))
|
|
602
|
+
decided.append(f"content:{name}")
|
|
595
603
|
after = scaffold.check(root, state_dir=getattr(args, "state_dir", None), reprompt=True)
|
|
596
604
|
for finding in after["findings"]:
|
|
597
605
|
if finding["kind"] == "content-differs" or finding["kind"].startswith("privacy-contract-"):
|
|
@@ -22,8 +22,8 @@ if str(Path(__file__).resolve().parent) not in sys.path: # also loaded by path
|
|
|
22
22
|
from i18n_init import N_, _, resolve_language # noqa: E402
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
INITIALIZER_VERSION = "6.8.1"
|
|
26
25
|
PLUGIN_ROOT = Path(__file__).resolve().parents[3]
|
|
26
|
+
INITIALIZER_VERSION = json.loads((PLUGIN_ROOT / "plugin.json").read_text(encoding="utf-8"))["version"]
|
|
27
27
|
PROFILE_SCHEMA = "https://skill.sakanano.moe/skills/agents-init/project.schema.json"
|
|
28
28
|
PROFILE_PATH = Path(".agents/moe.sakanano.agent-pack/project.json")
|
|
29
29
|
# Baseline of the template-derived files this initializer wrote; `check`
|
|
@@ -531,19 +531,19 @@ def files_for(inputs: Inputs, templates: dict[str, str] | None = None, launcher:
|
|
|
531
531
|
}
|
|
532
532
|
replacements["PRIVACY_SECTION"] = privacy_section(templates, inputs.language, inputs.privacy_declared)
|
|
533
533
|
replacements["PRIVACY_RULES_LINE"] = localized(templates, "privacy/rules-line", inputs.language).rstrip("\n")
|
|
534
|
-
agents = render_template(templates
|
|
535
|
-
route = render_template(templates
|
|
534
|
+
agents = render_template(localized(templates, "AGENTS.md", inputs.language), replacements)
|
|
535
|
+
route = render_template(localized(templates, "ROUTE.md", inputs.language), replacements)
|
|
536
536
|
files = {
|
|
537
537
|
Path("AGENTS.md"): agents,
|
|
538
|
-
Path("AGENT.RULES.md"): render_template(templates
|
|
539
|
-
Path("OPINION.md"): render_template(templates
|
|
540
|
-
Path("CLAUDE.md"): render_template(templates
|
|
538
|
+
Path("AGENT.RULES.md"): render_template(localized(templates, "AGENT.RULES.md", inputs.language), replacements),
|
|
539
|
+
Path("OPINION.md"): render_template(localized(templates, "OPINION.md", inputs.language), replacements),
|
|
540
|
+
Path("CLAUDE.md"): render_template(localized(templates, "CLAUDE.md", inputs.language), replacements),
|
|
541
541
|
Path("AGENT.md"): route,
|
|
542
542
|
Path(".agents/plugin.json"): json_text({
|
|
543
543
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
544
544
|
"name": inputs.slug,
|
|
545
545
|
"version": "0.1.0",
|
|
546
|
-
"description": "项目本地的可移植 Agent 能力包。",
|
|
546
|
+
"description": "Portable Agent capabilities local to this project." if inputs.language == "en" else "项目本地的可移植 Agent 能力包。",
|
|
547
547
|
}),
|
|
548
548
|
Path(".agents/mcp.json"): json_text({
|
|
549
549
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
|
|
@@ -551,13 +551,13 @@ def files_for(inputs: Inputs, templates: dict[str, str] | None = None, launcher:
|
|
|
551
551
|
}),
|
|
552
552
|
PROFILE_PATH: json_text(profile),
|
|
553
553
|
Path(".agents/skills/.gitkeep"): "",
|
|
554
|
-
Path(".agent-doc/plan.md"): render_template(templates
|
|
555
|
-
Path(".agent-doc/progress.md"): render_template(templates
|
|
556
|
-
Path(".agent-doc/chat-summary.md"): render_template(templates
|
|
554
|
+
Path(".agent-doc/plan.md"): render_template(localized(templates, ".agent-doc/plan.md", inputs.language), replacements),
|
|
555
|
+
Path(".agent-doc/progress.md"): render_template(localized(templates, ".agent-doc/progress.md", inputs.language), replacements),
|
|
556
|
+
Path(".agent-doc/chat-summary.md"): render_template(localized(templates, ".agent-doc/chat-summary.md", inputs.language), replacements),
|
|
557
557
|
Path("memory/.gitkeep"): "",
|
|
558
558
|
Path("sops/.gitkeep"): "",
|
|
559
559
|
Path("private/.gitignore"): PRIVATE_IGNORE,
|
|
560
|
-
Path("docs/refs/README.md"): render_template(templates
|
|
560
|
+
Path("docs/refs/README.md"): render_template(localized(templates, "docs/refs/README.md", inputs.language), replacements),
|
|
561
561
|
Path("docs/drafts/.gitkeep"): "",
|
|
562
562
|
}
|
|
563
563
|
if inputs.work_mode == "case-workspace":
|
|
@@ -827,6 +827,11 @@ def write_content_lock(root: Path, pack: dict, baseline: dict[str, str], *, inpu
|
|
|
827
827
|
for path_, ids in regions.items():
|
|
828
828
|
merged[path_] = {**merged.get(path_, {}), **ids}
|
|
829
829
|
updated["regions"] = dict(sorted(merged.items()))
|
|
830
|
+
# Whole-file baselines cannot describe a file owned only through regions. Older locks may contain both.
|
|
831
|
+
for region_path, ids in updated.get("regions", {}).items():
|
|
832
|
+
if ids:
|
|
833
|
+
updated["files"].pop(region_path, None)
|
|
834
|
+
updated.get("file_versions", {}).pop(region_path, None)
|
|
830
835
|
lock["packs"][pack["id"]] = updated
|
|
831
836
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
832
837
|
_atomic_write(path, json_text(lock))
|
|
@@ -960,11 +965,12 @@ def _inputs_from_lock(root: Path, recorded: object, fallback: Inputs) -> Inputs:
|
|
|
960
965
|
|
|
961
966
|
|
|
962
967
|
def find_baseline(root: Path, relative: Path, digest: str, versions: list[str], recorded: object, current: Inputs,
|
|
963
|
-
providers: list, pack_id: str) -> dict | None:
|
|
968
|
+
providers: list, pack_id: str, diagnostics: dict | None = None) -> dict | None:
|
|
964
969
|
"""Re-render ``relative`` as an earlier content pack did and return it only if it hashes to ``digest``.
|
|
965
970
|
|
|
966
971
|
``digest`` is what the content lock recorded when the file was written, so a match proves the text is exactly the
|
|
967
|
-
baseline; a wrong guess (another pack version, other inputs) never matches and is skipped.
|
|
972
|
+
baseline; a wrong guess (another pack version, other inputs) never matches and is skipped. Optional diagnostics
|
|
973
|
+
distinguish a known historical pack the current renderer cannot handle from sources that yielded no matching text.
|
|
968
974
|
"""
|
|
969
975
|
start = _inputs_from_lock(root, recorded, current)
|
|
970
976
|
variants = [start, dataclasses.replace(start, privacy_declared=not start.privacy_declared)]
|
|
@@ -981,7 +987,11 @@ def find_baseline(root: Path, relative: Path, digest: str, versions: list[str],
|
|
|
981
987
|
text = files_for(variant, templates, source.launcher).get(relative)
|
|
982
988
|
if text is not None and hashlib.sha256(text.encode("utf-8")).hexdigest() == digest:
|
|
983
989
|
return {"text": text, "source": source.label, "kind": source.kind, "version": source.version}
|
|
990
|
+
if text is not None and diagnostics is not None and (not versions or source.version in versions):
|
|
991
|
+
diagnostics["rendered"] = True # 来源可用、模板可渲染,只是结果与内容锁摘要对不上
|
|
984
992
|
except (InitError, KeyError, ValueError):
|
|
993
|
+
if diagnostics is not None and (not versions or source.version in versions):
|
|
994
|
+
diagnostics["reason"] = "baseline-template-incompatible"
|
|
985
995
|
continue
|
|
986
996
|
except (OSError, ValueError):
|
|
987
997
|
continue
|
|
@@ -1026,14 +1036,22 @@ def _refresh_notes(item: dict) -> list[str]:
|
|
|
1026
1036
|
"""Human lines for a file refresh cannot silently decide: why, what each choice costs, what to type."""
|
|
1027
1037
|
path, reason = item["path"], item.get("reason")
|
|
1028
1038
|
notes: list[str] = []
|
|
1039
|
+
if item.get("comparison") == "regions":
|
|
1040
|
+
return [_("只比较已登记的受管区块,区块外内容属于你;用 --mode region 查看并更新区块,整文件模板变化不再追问")]
|
|
1029
1041
|
if reason == "baseline-unavailable":
|
|
1030
|
-
notes.append(_("
|
|
1042
|
+
notes.append(_("历史来源未能提供与内容锁摘要一致的基线(本机缓存、本地 git tag 或 GitHub Release;联网可能已关闭,或下载与校验未成功),无法三方合并;"
|
|
1031
1043
|
"没有改动任何文件,请改用 --keep / --append / --accept 选择"))
|
|
1044
|
+
elif reason == "baseline-digest-mismatch":
|
|
1045
|
+
notes.append(_("历史来源可用,模板也能渲染,但渲染结果与内容锁记录的摘要不一致(渲染输入或文件基线不同),无法确认你的起点,不能三方合并;"
|
|
1046
|
+
"没有改动任何文件,请改用 --keep / --append / --accept 选择"))
|
|
1047
|
+
elif reason == "baseline-template-incompatible":
|
|
1048
|
+
notes.append(_("内容锁里有基线摘要,但对应的历史模板缺少当前渲染所需的区块,无法重新渲染,不能三方合并;"
|
|
1049
|
+
"没有改动任何文件,此类项目请用 --keep / --append / --accept 选择"))
|
|
1032
1050
|
elif reason == "merge-conflict":
|
|
1033
1051
|
numbers = ", ".join(str(number) for number in item["merge"]["unresolved"])
|
|
1034
1052
|
notes.append(_("有 {0} 处冲突需要你选择(第 {1} 块):--pick {2}#<序号>=mine|theirs|both"
|
|
1035
1053
|
"(mine 保留你的、theirs 取新模板、both 两边都留)").format(len(item["merge"]["unresolved"]), numbers, path))
|
|
1036
|
-
elif reason == "no-baseline" and item.get("merge_requested"):
|
|
1054
|
+
elif reason == "no-baseline" and item.get("merge_requested") and item["state"] != "kept-by-decision":
|
|
1037
1055
|
notes.append(_("内容锁里没有 {0} 的基线摘要,无法三方合并:确认不了哪个历史版本是你的起点,也不猜基线(猜错会让合并悄悄吞掉改动);"
|
|
1038
1056
|
"没有改动任何文件。请改选:--keep {0} / --append {0} / --accept {0}").format(path))
|
|
1039
1057
|
if item["action"] == "merge":
|
|
@@ -1135,6 +1153,7 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1135
1153
|
# every file that differs from the new render counts as locally modified.
|
|
1136
1154
|
entry = (lock.get("packs") or {}).get(pack["id"]) or {}
|
|
1137
1155
|
baseline: dict[str, str] = dict(entry.get("files") or {})
|
|
1156
|
+
region_paths = {path for path, ids in (entry.get("regions") or {}).items() if ids}
|
|
1138
1157
|
file_versions: dict[str, str] = dict(entry.get("file_versions") or {}) # 文件基线是哪个内容包版本渲染的(未更新的文件仍是旧版本)
|
|
1139
1158
|
inputs = inputs_from_profile(root)
|
|
1140
1159
|
rendered = files_for(inputs)
|
|
@@ -1157,6 +1176,10 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1157
1176
|
raise InitError(_("只有 AGENTS.md 和 CLAUDE.md 可以追加受管区块:") + ", ".join(sorted(map(str, not_appendable))))
|
|
1158
1177
|
if show_diff and args.apply:
|
|
1159
1178
|
raise InitError(_("--diff 只用于查看,不能与 --apply 同用"))
|
|
1179
|
+
# 区块归属的文件被删除后不再有"用户正文"可保护:--accept 走原来的缺失文件逻辑重建,不在这里拒绝。
|
|
1180
|
+
whole_file_picks = {path.as_posix() for path in (accept | merge) if (root / path).exists() or (root / path).is_symlink()} & region_paths
|
|
1181
|
+
if whole_file_picks:
|
|
1182
|
+
raise InitError(_("这些文件只管理已登记的区块,请用 --mode region 处理,不能替换或合并整文件:{0}").format(", ".join(sorted(whole_file_picks))))
|
|
1160
1183
|
templates = load_templates()
|
|
1161
1184
|
regions = _regions()
|
|
1162
1185
|
merge3 = _merge3() if merge else None
|
|
@@ -1181,6 +1204,24 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1181
1204
|
continue
|
|
1182
1205
|
current = path.read_text(encoding="utf-8") if path.is_file() else None
|
|
1183
1206
|
current_digest = hashlib.sha256(current.encode("utf-8")).hexdigest() if current is not None else None
|
|
1207
|
+
if relative.as_posix() in region_paths and relative not in append and current is not None:
|
|
1208
|
+
# Keep existing whole-file decisions without renewing their template fingerprints. The region table
|
|
1209
|
+
# owns future comparisons; even a changed full template must never prompt about the user's text.
|
|
1210
|
+
item = {"path": relative.as_posix(), "state": "kept-by-decision" if relative.as_posix() in kept_before else "local-only",
|
|
1211
|
+
"action": "keep", "comparison": "regions"}
|
|
1212
|
+
if relative in show_diff:
|
|
1213
|
+
diffs = []
|
|
1214
|
+
for region_id in sorted(entry["regions"][relative.as_posix()]):
|
|
1215
|
+
key = f"region/{region_id}"
|
|
1216
|
+
if key not in templates:
|
|
1217
|
+
continue
|
|
1218
|
+
existing = regions.get(current, region_id) if current is not None else None
|
|
1219
|
+
diffs.append(_unified_diff(f"{relative.as_posix()}#{region_id}", existing.body if existing else "",
|
|
1220
|
+
regions.normalize(localized(templates, key, inputs.language))))
|
|
1221
|
+
item["diff"] = "".join(diffs)
|
|
1222
|
+
item["note"] = _refresh_notes(item)
|
|
1223
|
+
plan.append(item)
|
|
1224
|
+
continue
|
|
1184
1225
|
added, lost = line_delta(current or "", new)
|
|
1185
1226
|
reason = None
|
|
1186
1227
|
merge_info = None
|
|
@@ -1205,10 +1246,12 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1205
1246
|
if reason == "edited":
|
|
1206
1247
|
wanted = [version for version in (file_versions.get(relative.as_posix()), entry.get("version"))
|
|
1207
1248
|
if version and version != UNKNOWN_PACK_VERSION]
|
|
1249
|
+
diagnostics: dict = {}
|
|
1208
1250
|
found = find_baseline(root, relative, baseline[relative.as_posix()], list(dict.fromkeys(wanted)),
|
|
1209
|
-
entry.get("render_inputs"), inputs, providers, pack["id"])
|
|
1251
|
+
entry.get("render_inputs"), inputs, providers, pack["id"], diagnostics)
|
|
1210
1252
|
if found is None:
|
|
1211
|
-
reason = "
|
|
1253
|
+
reason = diagnostics.get("reason") or (
|
|
1254
|
+
"baseline-digest-mismatch" if diagnostics.get("rendered") else "baseline-unavailable")
|
|
1212
1255
|
if found is not None:
|
|
1213
1256
|
merged = merge3.merge_text(found["text"], current, new)
|
|
1214
1257
|
chosen = picks.get(relative, {})
|
|
@@ -1233,7 +1276,7 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1233
1276
|
action = "keep"
|
|
1234
1277
|
else:
|
|
1235
1278
|
action = "blocked"
|
|
1236
|
-
if decided and relative not in accept
|
|
1279
|
+
if decided and relative not in accept:
|
|
1237
1280
|
state = "kept-by-decision"
|
|
1238
1281
|
item = {"path": relative.as_posix(), "state": state, "action": action, "new_sha256": new_digest}
|
|
1239
1282
|
if reason:
|
|
@@ -1287,7 +1330,7 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1287
1330
|
unmet = sorted(path.as_posix() for path in append if path.as_posix() not in satisfied)
|
|
1288
1331
|
if unmet:
|
|
1289
1332
|
raise InitError(_("没有本地改动,不需要追加区块:") + ", ".join(unmet))
|
|
1290
|
-
not_modified = sorted(item["path"] for item in plan if Path(item["path"]) in merge and item["state"]
|
|
1333
|
+
not_modified = sorted(item["path"] for item in plan if Path(item["path"]) in merge and item["state"] not in {"modified", "kept-by-decision"})
|
|
1291
1334
|
if not_modified:
|
|
1292
1335
|
raise InitError(_("没有需要合并的本地改动(文件没改过,或已与新模板一致):") + ", ".join(not_modified))
|
|
1293
1336
|
blocked = [item["path"] for item in plan if item["action"] == "blocked"]
|
|
@@ -1315,7 +1358,8 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1315
1358
|
if blocked:
|
|
1316
1359
|
hints = []
|
|
1317
1360
|
needs_choice = [item["path"] for item in plan
|
|
1318
|
-
if item["action"] == "blocked" and item
|
|
1361
|
+
if item["action"] == "blocked" and item["state"] != "kept-by-decision"
|
|
1362
|
+
and item.get("reason") in {"no-baseline", "edited", "baseline-unavailable", "baseline-template-incompatible", "baseline-digest-mismatch", "symlink"}]
|
|
1319
1363
|
if needs_choice:
|
|
1320
1364
|
hints.append(_("本地已改动的文件需逐个选择:"))
|
|
1321
1365
|
hints += [_(" {0}:{1}").format(path, file_choices(path) if path not in symlinks else _("--keep {0} 保留链接原样(建议)").format(path))
|
|
@@ -1352,6 +1396,10 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1352
1396
|
_atomic_write(target, text, os.stat(target).st_mode & 0o7777)
|
|
1353
1397
|
files = dict(baseline)
|
|
1354
1398
|
for item in plan:
|
|
1399
|
+
if item.get("comparison") == "regions":
|
|
1400
|
+
files.pop(item["path"], None)
|
|
1401
|
+
file_versions.pop(item["path"], None)
|
|
1402
|
+
continue
|
|
1355
1403
|
if item["action"] in {"replace", "create", "merge"} or item["state"] == "unchanged":
|
|
1356
1404
|
files[item["path"]] = item["new_sha256"]
|
|
1357
1405
|
file_versions[item["path"]] = pack["version"]
|
|
@@ -1369,12 +1417,18 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1369
1417
|
for path, ids in new_regions.items():
|
|
1370
1418
|
merged.setdefault(path, {}).update(ids)
|
|
1371
1419
|
new_entry["regions"] = dict(sorted(merged.items()))
|
|
1420
|
+
for region_path, ids in new_entry.get("regions", {}).items():
|
|
1421
|
+
if ids:
|
|
1422
|
+
new_entry["files"].pop(region_path, None)
|
|
1423
|
+
new_entry.get("file_versions", {}).pop(region_path, None)
|
|
1372
1424
|
lock.setdefault("packs", {})[pack["id"]] = new_entry
|
|
1373
1425
|
lock_path = root / CONTENT_LOCK_PATH
|
|
1374
1426
|
lock_path.parent.mkdir(parents=True, exist_ok=True)
|
|
1375
1427
|
_atomic_write(lock_path, json_text(lock))
|
|
1376
1428
|
# 显式 --keep / --append 的选择记入决定文件:同样的模板内容以后不再追问,模板实质变化时才再问。
|
|
1377
1429
|
for item in plan:
|
|
1430
|
+
if item.get("comparison") == "regions":
|
|
1431
|
+
continue
|
|
1378
1432
|
chosen_keep = Path(item["path"]) in (keep | append) or item["action"] in {"append", "merge"}
|
|
1379
1433
|
if chosen_keep and item["state"] in {"modified", "local-only", "kept-by-decision", "symlink"}:
|
|
1380
1434
|
_scaffold().decide(root, f"content:{item['path']}", "keep",
|
|
@@ -313,5 +313,10 @@
|
|
|
313
313
|
"--keep {0} 保留链接原样(建议)": "--keep {0} leaves the link as it is (recommended)",
|
|
314
314
|
" {0}:{1}": " {0}: {1}",
|
|
315
315
|
";": "; ",
|
|
316
|
-
"未声明私有路径,不追加隐私约定(privacy.forbidden_default_reads 为空)": "No private paths declared, so the privacy convention is not appended (privacy.forbidden_default_reads is empty)"
|
|
317
|
-
|
|
316
|
+
"未声明私有路径,不追加隐私约定(privacy.forbidden_default_reads 为空)": "No private paths declared, so the privacy convention is not appended (privacy.forbidden_default_reads is empty)",
|
|
317
|
+
"只比较已登记的受管区块,区块外内容属于你;用 --mode region 查看并更新区块,整文件模板变化不再追问": "Only recorded managed regions are compared; text outside them belongs to you. Use --mode region to inspect and update the regions; whole-file template changes will not prompt again.",
|
|
318
|
+
"这些文件只管理已登记的区块,请用 --mode region 处理,不能替换或合并整文件:{0}": "Only recorded regions are managed in these files. Use --mode region; whole-file replacement or merge is unavailable: {0}",
|
|
319
|
+
"历史来源未能提供与内容锁摘要一致的基线(本机缓存、本地 git tag 或 GitHub Release;联网可能已关闭,或下载与校验未成功),无法三方合并;没有改动任何文件,请改用 --keep / --append / --accept 选择": "Historical sources could not provide a baseline matching the content lock digest (runtime cache, local git tags or GitHub Release; networking may be disabled, or download and verification did not succeed). A three-way merge is unavailable; no files changed. Choose --keep / --append / --accept instead",
|
|
320
|
+
"内容锁里有基线摘要,但对应的历史模板缺少当前渲染所需的区块,无法重新渲染,不能三方合并;没有改动任何文件,此类项目请用 --keep / --append / --accept 选择": "The content lock has a baseline digest, but the corresponding historical template lacks blocks required by the current renderer. It cannot be re-rendered for a three-way merge; no files changed. For these projects, choose --keep / --append / --accept",
|
|
321
|
+
"历史来源可用,模板也能渲染,但渲染结果与内容锁记录的摘要不一致(渲染输入或文件基线不同),无法确认你的起点,不能三方合并;没有改动任何文件,请改用 --keep / --append / --accept 选择": "A historical source is available and its template renders, but the result does not match the digest recorded in the content lock (different render inputs or file baseline). Your starting point cannot be confirmed, so a three-way merge is unavailable; no files changed. Choose --keep / --append / --accept instead"
|
|
322
|
+
}
|
|
@@ -255,7 +255,7 @@ def read_lock(root: Path) -> tuple[dict | None, str | None]:
|
|
|
255
255
|
return None, None if exc.code == "refresh-unavailable" else str(exc)
|
|
256
256
|
|
|
257
257
|
|
|
258
|
-
def _skeleton_state(ctx: Context, entry: dict, baseline: dict[str, str]) -> str:
|
|
258
|
+
def _skeleton_state(ctx: Context, entry: dict, baseline: dict[str, str], region_paths: set[str] | None = None) -> str:
|
|
259
259
|
target = ctx.root / entry["path"]
|
|
260
260
|
compare = entry["compare"]
|
|
261
261
|
if compare == "opinion":
|
|
@@ -266,6 +266,9 @@ def _skeleton_state(ctx: Context, entry: dict, baseline: dict[str, str]) -> str:
|
|
|
266
266
|
return "missing"
|
|
267
267
|
if _lstat(target) is None:
|
|
268
268
|
return "missing"
|
|
269
|
+
# A region-owned file belongs to the user outside its recorded blocks. Region rows below compare those blocks.
|
|
270
|
+
if entry["path"] in (region_paths or set()):
|
|
271
|
+
return "ok"
|
|
269
272
|
if compare == "lock" and entry["path"] in ctx.tracked and entry["path"] not in baseline:
|
|
270
273
|
current = _file_digest(target)
|
|
271
274
|
expected = ctx.expected_text(entry["path"])
|
|
@@ -890,7 +893,7 @@ def check(root: Path, *, state_dir: Path | None = None, reprompt: bool = False)
|
|
|
890
893
|
|
|
891
894
|
skeleton = []
|
|
892
895
|
for entry in ctx.entries():
|
|
893
|
-
state = _skeleton_state(ctx, entry, baseline)
|
|
896
|
+
state = _skeleton_state(ctx, entry, baseline, {path for path, ids in (pack_entry or {}).get("regions", {}).items() if ids})
|
|
894
897
|
skeleton.append({"path": entry["path"], "compare": entry["compare"], "required": entry["required"],
|
|
895
898
|
"state": state, "fingerprint": entry["fingerprint"]})
|
|
896
899
|
if state == "missing" and entry["required"]:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "agents-init v6 / Project Profile initialization and migration",
|
|
4
4
|
"description": "Create or migrate a general project skeleton and Project Profile; the bundled opinion-manager manages user-confirmed Agent behavior rules.",
|
|
5
5
|
"schema_version": "1.0",
|
|
6
|
-
"version": "6.
|
|
6
|
+
"version": "6.9.0",
|
|
7
7
|
"status": "stable",
|
|
8
8
|
"language": "zh-CN",
|
|
9
9
|
"license": "MIT",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "opinion-manager",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"description": "Manage Agent behavior rules through templates, partial selection, blank iteration, and authorized-memory candidates, with complete previews and exact version locks.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "lc4t"
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
KNOWN_PLACEHOLDERS = (
|
|
2
|
+
"# Project Opinion overlay\n\nOpinion is not configured yet.\n\n"
|
|
3
|
+
"Use `opinion-manager` to apply a template, select individual rules, or start from scratch; candidates can also be proposed from authorized memories. "
|
|
4
|
+
"A complete preview takes effect after user confirmation. Personal content belongs only in this project.\n",
|
|
2
5
|
'# 项目 Opinion 覆盖层\n\n尚未配置 Opinion。\n\n使用 `opinion-manager` 选择直接用模板、选择部分条目或从空白开始;也可基于已授权记忆提出候选。完整预览经用户确认后生效,个人内容只写入当前项目。\n',
|
|
3
6
|
"# 项目 Opinion 覆盖层\n\n尚未配置 Opinion。\n\n"
|
|
4
7
|
"使用 `opinion-manager` 选择自定义生成、已批准模板组合、逐条引导或跳过。"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "project-orchestrator",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.4",
|
|
5
5
|
"description": "Portable lifecycle orchestration with Case workspaces, legacy Task/Case compatibility, verified migrations, discovery and scoped Git delivery.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "lc4t"
|
|
@@ -165,3 +165,7 @@ python3 runtime/wf.py 笔记 9月1号 # 在项
|
|
|
165
165
|
## 初始化器升级
|
|
166
166
|
|
|
167
167
|
新项目默认 Case 工作目录;既有项目的模式默认保留。显式使用 `init_project.py --mode migrate --work-mode case-workspace --replace .agents/moe.sakanano.agent-pack/project.json --recovery-dir <项目外目录>` 更新 Profile。原 task 配置保留为 `legacy_task`,初始化器不搬业务文件;原数据迁移由本工具的已审阅映射单独执行。私有路径、业务内容和映射只保存于目标项目,不进入公共分发包。
|
|
168
|
+
|
|
169
|
+
## Case CLI 写入预览
|
|
170
|
+
|
|
171
|
+
`case.py new` / `case.py update` 可加 `--dry-run`,运行同样的校验并返回目标路径与 unified diff,不建立目录也不改文件。省略该参数保持原来的直接写入方式,旧脚本无需迁移。执行更新时可用 `--expect-sha256` 防止覆盖并发修改。完整命令盘点、兼容策略与 hook 例外见仓库的 [写操作预览策略](../../../docs/write-commands.md)。
|
|
@@ -9,6 +9,7 @@ Case 根目录与 CASE.md 拒绝符号链接。
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
import argparse
|
|
12
|
+
import difflib
|
|
12
13
|
import hashlib
|
|
13
14
|
import json
|
|
14
15
|
import os
|
|
@@ -523,6 +524,7 @@ def parser() -> argparse.ArgumentParser:
|
|
|
523
524
|
return sub.add_parser(name, parents=[shared], help=help_text)
|
|
524
525
|
|
|
525
526
|
new = command("new", _("新建 Case 目录与 CASE.md"))
|
|
527
|
+
new.add_argument("--dry-run", action="store_true", help=_("只预览,不写入(省略时保持直接写入)"))
|
|
526
528
|
new.add_argument("--title", required=True)
|
|
527
529
|
new.add_argument("--slug", required=True, help=_("目录名后缀:小写字母、数字与连字符"))
|
|
528
530
|
new.add_argument("--goal", required=True)
|
|
@@ -541,6 +543,7 @@ def parser() -> argparse.ArgumentParser:
|
|
|
541
543
|
show = command("show", _("查看一个 Case 的字段与正文"))
|
|
542
544
|
show.add_argument("case")
|
|
543
545
|
change = command("update", _("更新状态、下一动作,追加工作记录、决策、交付物与证据"))
|
|
546
|
+
change.add_argument("--dry-run", action="store_true", help=_("只预览,不写入(省略时保持直接写入)"))
|
|
544
547
|
change.add_argument("case")
|
|
545
548
|
change.add_argument("--status", choices=tuple(STATUS_ORDER))
|
|
546
549
|
change.add_argument("--title")
|
|
@@ -588,7 +591,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
588
591
|
try:
|
|
589
592
|
project = Project(args.project)
|
|
590
593
|
if args.command == "new":
|
|
591
|
-
|
|
594
|
+
if args.dry_run:
|
|
595
|
+
case_id, content = plan_create(project, args)
|
|
596
|
+
path = project.relative(project.case_root / case_id / "CASE.md")
|
|
597
|
+
result = {"ok": True, "applied": False, "status": "preview", "id": case_id, "path": path,
|
|
598
|
+
"diff": "".join(difflib.unified_diff([], content.splitlines(keepends=True),
|
|
599
|
+
fromfile="/dev/null", tofile=path))}
|
|
600
|
+
else:
|
|
601
|
+
result = create(project, args)
|
|
592
602
|
elif args.command == "list":
|
|
593
603
|
result = list_cases(project, args)
|
|
594
604
|
elif args.command == "show":
|
|
@@ -597,7 +607,15 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
597
607
|
result = {"ok": True, "case": data, "path": project.relative(directory / "CASE.md"),
|
|
598
608
|
"content": (directory / "CASE.md").read_text(encoding="utf-8")}
|
|
599
609
|
elif args.command == "update":
|
|
600
|
-
|
|
610
|
+
if args.dry_run:
|
|
611
|
+
path, current, content, result = plan_update(project, args)
|
|
612
|
+
result.update({"applied": False, "status": "preview",
|
|
613
|
+
"diff": "".join(difflib.unified_diff(current.splitlines(keepends=True),
|
|
614
|
+
content.splitlines(keepends=True),
|
|
615
|
+
fromfile=project.relative(path),
|
|
616
|
+
tofile=project.relative(path)))})
|
|
617
|
+
else:
|
|
618
|
+
result = update(project, args)
|
|
601
619
|
else:
|
|
602
620
|
result = validate(project, args)
|
|
603
621
|
except CaseError as exc:
|
|
@@ -1460,5 +1460,9 @@
|
|
|
1460
1460
|
"暂不能给出差异:{0}": "Cannot show the difference yet: {0}",
|
|
1461
1461
|
"定制文件逐个处理,例如 {0}:--keep {0} 保留你的版本;--accept {0} 用新模板替换(会丢弃本地内容时再加 --confirm-discard {0});--merge {0} 三方合并(冲突块用 --pick {0}#<序号>=mine|theirs|both);--diff {0} 只看差异。": "Customized files are handled one by one, for example {0}: --keep {0} keeps your version; --accept {0} replaces it with the new template (when that drops local content also add --confirm-discard {0}); --merge {0} three-way merges (resolve conflict blocks with --pick {0}#<number>=mine|theirs|both); --diff {0} shows only the difference.",
|
|
1462
1462
|
"({0} 与新模板没有差异)": "({0} has no difference from the new template)",
|
|
1463
|
-
"AGENTS.md / CLAUDE.md 也可用 --append {0} 保留原文、只追加带标记的区块。": " For AGENTS.md / CLAUDE.md, --append {0} also keeps your text and only appends a marked region."
|
|
1463
|
+
"AGENTS.md / CLAUDE.md 也可用 --append {0} 保留原文、只追加带标记的区块。": " For AGENTS.md / CLAUDE.md, --append {0} also keeps your text and only appends a marked region.",
|
|
1464
|
+
"只预览,不写入(省略时保持直接写入)": "Preview without writing (omitting this keeps the existing immediate-write behavior)",
|
|
1465
|
+
"(要求了三方合并,但历史模板无法按当前方式重新渲染,无法合并;没有改动任何文件,请改选保留 / 追加 / 采用新模板)": " (a three-way merge was requested, but the historical template cannot be re-rendered the current way; no files changed. Choose keep / append / accept the new template instead)",
|
|
1466
|
+
"(要求了三方合并,但历史模板渲染结果与内容锁摘要不一致,无法合并;没有改动任何文件,请改选保留 / 追加 / 采用新模板)": " (a three-way merge was requested, but the historical template's render does not match the content-lock digest; no files changed. Choose keep / append / accept the new template instead)",
|
|
1467
|
+
"{0}({1} 项,展开 {2} 项)": "{0} ({1} shown, {2} expanded)"
|
|
1464
1468
|
}
|
|
@@ -21,6 +21,7 @@ STATUSES = ("active", "retired")
|
|
|
21
21
|
SCALARS = ("schema_version", "id", "type", "status", "description", "created", "verified_at", "review_after", "supersedes", "promoted_to")
|
|
22
22
|
REQUIRED = ("schema_version", "id", "type", "status", "description", "created", "verified_at")
|
|
23
23
|
SUMMARY_SECTIONS = ("待确认假设", "未解决冲突", "Opinion 演化候选")
|
|
24
|
+
SUMMARY_SECTION_PAIRS = dict(zip(SUMMARY_SECTIONS, ("Assumptions to confirm", "Unresolved conflicts", "Opinion evolution candidates")))
|
|
24
25
|
IDENTITY = re.compile(r"MEM-\d{8}-\d{3}-[a-z0-9]+(?:-[a-z0-9]+)*\Z")
|
|
25
26
|
SLUG = re.compile(r"[a-z0-9]+(?:-[a-z0-9]+)*\Z")
|
|
26
27
|
|
|
@@ -71,6 +72,13 @@ def settings(args: argparse.Namespace) -> tuple[Path, Path, dict[str, Any]]:
|
|
|
71
72
|
return project, root, policy
|
|
72
73
|
|
|
73
74
|
|
|
75
|
+
def file_language(project: Path) -> str:
|
|
76
|
+
"""Generated file language belongs to the project, independently of UI settings."""
|
|
77
|
+
path = project / PROJECT_PROFILE
|
|
78
|
+
profile = read_json(path) if path.is_file() else {}
|
|
79
|
+
return "en" if profile.get("language") == "en" else "zh"
|
|
80
|
+
|
|
81
|
+
|
|
74
82
|
def parse_entry(text: str) -> tuple[dict[str, Any], str]:
|
|
75
83
|
"""解析受限的 frontmatter:标量为 JSON 字符串,sources 为字符串列表。"""
|
|
76
84
|
if not text.startswith("---\n") or "\n---\n" not in text[4:]:
|
|
@@ -136,17 +144,20 @@ def is_due(meta: dict[str, Any], policy: dict[str, Any], today: date) -> bool:
|
|
|
136
144
|
return deadline is not None and deadline < today
|
|
137
145
|
|
|
138
146
|
|
|
139
|
-
def index_lines(entries: list[dict[str, Any]], policy: dict[str, Any], today: date) -> list[str]:
|
|
147
|
+
def index_lines(entries: list[dict[str, Any]], policy: dict[str, Any], today: date, language: str = "zh") -> list[str]:
|
|
140
148
|
lines = []
|
|
141
149
|
for entry in entries:
|
|
142
150
|
meta = entry["meta"]
|
|
143
151
|
if meta.get("status") != "active":
|
|
144
152
|
continue
|
|
145
153
|
try:
|
|
146
|
-
mark =
|
|
154
|
+
mark = (" | Possibly stale" if language == "en" else "|可能过期") if is_due(meta, policy, today) else ""
|
|
147
155
|
except EntryError:
|
|
148
156
|
mark = ""
|
|
149
|
-
|
|
157
|
+
if language == "en":
|
|
158
|
+
lines.append(f"- `{meta.get('id', entry['path'].stem)}` ({meta.get('type', '?')}): {meta.get('description', '')}{mark}")
|
|
159
|
+
else:
|
|
160
|
+
lines.append(f"- `{meta.get('id', entry['path'].stem)}`({meta.get('type', '?')}):{meta.get('description', '')}{mark}")
|
|
150
161
|
return lines
|
|
151
162
|
|
|
152
163
|
|
|
@@ -213,9 +224,12 @@ def check_budgets(project: Path, lines: list[str], policy: dict[str, Any]) -> li
|
|
|
213
224
|
if path.is_file():
|
|
214
225
|
text = path.read_text(encoding="utf-8")
|
|
215
226
|
headings = [line[3:].strip() for line in text.splitlines() if line.startswith("## ")]
|
|
216
|
-
|
|
227
|
+
default_sections = tuple(SUMMARY_SECTION_PAIRS.values()) if file_language(project) == "en" else SUMMARY_SECTIONS
|
|
228
|
+
for section in summary.get("required_sections", default_sections):
|
|
217
229
|
# 按前缀匹配,项目可以在固定小节名之后补充说明。
|
|
218
|
-
|
|
230
|
+
# Default section names accept either file language, including files kept after a language switch.
|
|
231
|
+
variants = next(((zh, en) for zh, en in SUMMARY_SECTION_PAIRS.items() if section in (zh, en)), (section,))
|
|
232
|
+
if not any(heading.startswith(variant) for heading in headings for variant in variants):
|
|
219
233
|
found.append({"code": "summary-section-missing", "entry": path.name, "message": _("缺少小节:{0}").format(section)})
|
|
220
234
|
if summary.get("max_bytes") and len(text.encode("utf-8")) > int(summary["max_bytes"]):
|
|
221
235
|
found.append({"code": "summary-too-large", "entry": path.name, "message": _("超过 {0} 字节").format(summary['max_bytes'])})
|
|
@@ -231,7 +245,7 @@ def command_check(project: Path, root: Path, policy: dict[str, Any], today: date
|
|
|
231
245
|
if identity in seen:
|
|
232
246
|
problems.append({"code": "duplicate-id", "entry": entry["path"].name, "message": _("与 {0} 编号重复").format(seen[identity])})
|
|
233
247
|
seen.setdefault(identity, entry["path"].name)
|
|
234
|
-
lines = index_lines(entries, policy, today)
|
|
248
|
+
lines = index_lines(entries, policy, today, file_language(project))
|
|
235
249
|
problems.extend(check_budgets(project, lines, policy))
|
|
236
250
|
active = [entry["meta"] for entry in entries if entry["meta"].get("status") == "active"]
|
|
237
251
|
due = []
|
|
@@ -289,7 +303,10 @@ def command_update(args: argparse.Namespace, project: Path, root: Path, today: d
|
|
|
289
303
|
fail(_("retire 需要 --reason 或 --promoted-to"))
|
|
290
304
|
meta["status"] = "retired"
|
|
291
305
|
meta["promoted_to"] = args.promoted_to or meta.get("promoted_to", "")
|
|
292
|
-
|
|
306
|
+
if file_language(project) == "en":
|
|
307
|
+
body = body.rstrip() + f"\n\n**Retired**: {today.isoformat()}, {args.reason or 'Promoted to ' + args.promoted_to}\n"
|
|
308
|
+
else:
|
|
309
|
+
body = body.rstrip() + f"\n\n**退役**:{today.isoformat()},{args.reason or '已晋升到 ' + args.promoted_to}\n"
|
|
293
310
|
else:
|
|
294
311
|
meta["verified_at"] = today.isoformat()
|
|
295
312
|
if args.review_after:
|
|
@@ -331,7 +348,7 @@ def run(args: argparse.Namespace) -> tuple[int, str]:
|
|
|
331
348
|
today = parse_date(args.today, "--today") if args.today else date.today()
|
|
332
349
|
if args.action == "index":
|
|
333
350
|
entries, _problems = load_entries(root)
|
|
334
|
-
lines = index_lines(entries, policy, today)
|
|
351
|
+
lines = index_lines(entries, policy, today, file_language(project))
|
|
335
352
|
if args.output == "json":
|
|
336
353
|
return 0, json.dumps({"ok": True, "lines": lines}, ensure_ascii=False, indent=2) + "\n"
|
|
337
354
|
return 0, "\n".join(lines) + ("\n" if lines else "")
|
|
@@ -264,8 +264,7 @@ def render_health(health: dict, show_skipped: bool = False, details: bool = Fals
|
|
|
264
264
|
if not members:
|
|
265
265
|
continue
|
|
266
266
|
colour = S.red if key == "must" else S.yellow if key in ("suggest", "update") else S.dim
|
|
267
|
-
|
|
268
|
-
# 同类项合并为一行(统计数字取实际成员数);--details 或 --output json 看逐项明细,JSON 里的 findings 不变。
|
|
267
|
+
# Count the numbered rows the user can actually see; JSON keeps the full finding count.
|
|
269
268
|
shown: list[tuple[dict, list[dict]]] = []
|
|
270
269
|
index: dict[str, int] = {}
|
|
271
270
|
for finding in members:
|
|
@@ -276,6 +275,9 @@ def render_health(health: dict, show_skipped: bool = False, details: bool = Fals
|
|
|
276
275
|
continue
|
|
277
276
|
index[group["id"]] = len(shown)
|
|
278
277
|
shown.append((finding, [finding]))
|
|
278
|
+
count = (_("{0}({1} 项,展开 {2} 项)").format(_(label), len(shown), len(members))
|
|
279
|
+
if len(shown) != len(members) else _("{0}({1})").format(_(label), len(members)))
|
|
280
|
+
lines.append(colour(S.bold(count)))
|
|
279
281
|
for finding, merged in shown:
|
|
280
282
|
numbered.append(finding)
|
|
281
283
|
number = S.bold(S.cyan(f'{len(numbered):>2}'))
|
|
@@ -425,7 +425,10 @@ def _content_preview(provider: Any, env: Any, report: dict | None, accept: list[
|
|
|
425
425
|
except EntryError as exc:
|
|
426
426
|
return _("项目模板/样例"), [], str(exc), True
|
|
427
427
|
files = result.get("files") or []
|
|
428
|
-
|
|
428
|
+
# A prior keep decision does not cancel an explicit per-file request. In particular,
|
|
429
|
+
# --merge must retain its blocked reason and --diff must retain the requested diff.
|
|
430
|
+
named = bool(accept or keep or append or confirm or merge or pick or diff)
|
|
431
|
+
if not files or (not named and all(item["state"] in ("unchanged", "kept-by-decision") for item in files)):
|
|
429
432
|
return _("项目模板/样例"), [], _("没有需要更新的模板"), True
|
|
430
433
|
return _("按当前模板对比项目契约文件"), files, "", True
|
|
431
434
|
|
|
@@ -500,6 +503,8 @@ def _content_change(item: dict, effective: dict[str, str]) -> str:
|
|
|
500
503
|
reason = item.get("reason")
|
|
501
504
|
note += {"no-baseline": _("(要求了三方合并,但内容锁里没有它的基线摘要,无法合并;没有改动任何文件,请改选保留 / 追加 / 采用新模板)"),
|
|
502
505
|
"baseline-unavailable": _("(要求了三方合并,但找不到升级前的基线,无法合并;没有改动任何文件)"),
|
|
506
|
+
"baseline-template-incompatible": _("(要求了三方合并,但历史模板无法按当前方式重新渲染,无法合并;没有改动任何文件,请改选保留 / 追加 / 采用新模板)"),
|
|
507
|
+
"baseline-digest-mismatch": _("(要求了三方合并,但历史模板渲染结果与内容锁摘要不一致,无法合并;没有改动任何文件,请改选保留 / 追加 / 采用新模板)"),
|
|
503
508
|
"merge-conflict": _("(三方合并有冲突块未选择:用 --pick {0}#<序号>=mine|theirs|both 逐块选择)").format(item["path"])}.get(reason, "")
|
|
504
509
|
elif item.get("reason") == "no-baseline" and item["state"] == "modified":
|
|
505
510
|
note += _("(内容锁里没有它的基线,无法判断是你改过还是模板变了)")
|