@sakanano-moe/agenthelm 6.11.0-rc.2 → 6.11.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/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/package.json +1 -1
- package/runtime/index.json +3 -3
- 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/runtime/agenthelm.py +282 -51
- package/runtime/plugins/agent-pack/runtime/agenthelm_runtime.py +65 -8
- package/runtime/plugins/agent-pack/runtime/locale/en.json +41 -1
- package/runtime/plugins/agents-init/.codex-plugin/plugin.json +1 -1
- package/runtime/plugins/agents-init/plugin.json +1 -1
- package/runtime/plugins/agents-init/skills/agents-init/scripts/init_project.py +78 -16
- package/runtime/plugins/agents-init/skills/agents-init/scripts/locale/en.json +31 -3
- package/runtime/plugins/agents-init/skills/agents-init/skill.json +1 -1
- 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/runtime/locale/en.json +15 -1
- package/runtime/plugins/project-orchestrator/runtime/project_cli.py +40 -8
- package/runtime/plugins/project-orchestrator/runtime/project_maintain.py +43 -10
|
@@ -123,10 +123,14 @@ def release_label(root: Path, version: str) -> str:
|
|
|
123
123
|
|
|
124
124
|
index.json carries the release version without the pre-release suffix, so the suffix comes from where the
|
|
125
125
|
content was delivered: the npm package version (root is <package>/runtime), or the tag in the release
|
|
126
|
-
tarball's top directory ``agenthelm-v<version>-rc.N`` (also what a local .tar.gz of it unpacks to)
|
|
127
|
-
plain checkout carries no such name and keeps the
|
|
126
|
+
tarball's top directory ``agenthelm-v<version>-rc.N`` (also what a local .tar.gz of it unpacks to), or the
|
|
127
|
+
``runtime.json`` of an installed user-level runtime. A plain checkout carries no such name and keeps the
|
|
128
|
+
release version.
|
|
128
129
|
"""
|
|
129
130
|
candidates = []
|
|
131
|
+
manifest = _read_manifest(root)
|
|
132
|
+
if manifest and isinstance(manifest.get("version"), str):
|
|
133
|
+
candidates.append(manifest["version"])
|
|
130
134
|
package = root.parent / "package.json"
|
|
131
135
|
if root.name == "runtime" and package.is_file():
|
|
132
136
|
try:
|
|
@@ -144,6 +148,25 @@ def release_label(root: Path, version: str) -> str:
|
|
|
144
148
|
return version
|
|
145
149
|
|
|
146
150
|
|
|
151
|
+
def is_prerelease(version: str | None) -> bool:
|
|
152
|
+
return bool(version) and re.fullmatch(_PRERELEASE, version) is not None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def running_label(root: Path | None = None) -> str | None:
|
|
156
|
+
"""The label (``6.11.0-rc.2``) of the release content this runtime runs from; None when it cannot be told.
|
|
157
|
+
|
|
158
|
+
Only content that names itself is trusted (see :func:`release_label`); a plugin cache, a checkout or anything
|
|
159
|
+
without ``index.json`` gives None.
|
|
160
|
+
"""
|
|
161
|
+
root = root if root is not None else Path(__file__).resolve().parents[3]
|
|
162
|
+
try:
|
|
163
|
+
index = json.loads((root / "index.json").read_text(encoding="utf-8"))
|
|
164
|
+
version = str(index.get("plugin", {}).get("version") or "")
|
|
165
|
+
except (OSError, ValueError, AttributeError):
|
|
166
|
+
return None
|
|
167
|
+
return release_label(root, version) if version else None
|
|
168
|
+
|
|
169
|
+
|
|
147
170
|
def describe(root: Path) -> dict:
|
|
148
171
|
if not _is_release_root(root):
|
|
149
172
|
raise RuntimeInstallError(_("{0} 不是 agenthelm 发布内容(缺少 index.json 或 plugins/<插件>)").format(root),
|
|
@@ -216,7 +239,12 @@ def missing_text(data: dict, commands: dict) -> dict:
|
|
|
216
239
|
def report(env: Any, latest: dict | None = None) -> dict:
|
|
217
240
|
active = current(env)
|
|
218
241
|
newest = release_version(latest)
|
|
219
|
-
|
|
242
|
+
everything = installed(env)
|
|
243
|
+
# Installed beside current but never made current (a candidate installed without --use): easy to forget.
|
|
244
|
+
inactive = [item["version"] for item in everything
|
|
245
|
+
if active and item["version"] != active["version"] and _newer(item["version"], active["version"])]
|
|
246
|
+
return {"current": active, "installed": everything, "data_root": str(data_root(env)),
|
|
247
|
+
"inactive_newer": inactive,
|
|
220
248
|
"running_from": running_from(env), "latest_release": newest,
|
|
221
249
|
"update_available": bool(active and newest and _newer(newest, active["version"]))}
|
|
222
250
|
|
|
@@ -233,7 +261,7 @@ def _newer(candidate: str, existing: str) -> bool:
|
|
|
233
261
|
|
|
234
262
|
# ---------------------------------------------------------------- plan and apply
|
|
235
263
|
|
|
236
|
-
def plan(env: Any, root: Path, origin: str, *, link_bin: Path | None = None) -> dict:
|
|
264
|
+
def plan(env: Any, root: Path, origin: str, *, link_bin: Path | None = None, use: bool = False) -> dict:
|
|
237
265
|
info = describe(root)
|
|
238
266
|
target = runtimes_dir(env) / info["version"]
|
|
239
267
|
existing = _read_manifest(target)
|
|
@@ -246,7 +274,13 @@ def plan(env: Any, root: Path, origin: str, *, link_bin: Path | None = None) ->
|
|
|
246
274
|
writes = []
|
|
247
275
|
if not existing:
|
|
248
276
|
writes.append({"path": str(target), "scope": _("用户数据目录(新版本,旧版本保留)")})
|
|
249
|
-
|
|
277
|
+
prerelease = is_prerelease(info["version"])
|
|
278
|
+
wants = not active or active.get("version") != info["version"]
|
|
279
|
+
# A candidate (-rc.N) installed beside a working runtime does not take over ``current``: the project launchers, hooks and
|
|
280
|
+
# the terminal command keep using what they used until the user asks (--use / runtime use). With no current runtime
|
|
281
|
+
# there is nothing to displace, so the first install is still made current.
|
|
282
|
+
withheld = bool(wants and prerelease and active and not use)
|
|
283
|
+
switch = wants and not withheld
|
|
250
284
|
if switch:
|
|
251
285
|
writes.append({"path": str(current_link(env)), "scope": _("切换当前版本 → {0}").format(info['version'])})
|
|
252
286
|
link = None
|
|
@@ -261,6 +295,8 @@ def plan(env: Any, root: Path, origin: str, *, link_bin: Path | None = None) ->
|
|
|
261
295
|
writes.append({"path": str(link), "scope": _("命令链接(指向当前运行时)")})
|
|
262
296
|
return {"version": info["version"], "plugins": info["plugins"], "digest": info["digest"], "source": origin,
|
|
263
297
|
"target": str(target), "install": not existing, "switch": switch,
|
|
298
|
+
"prerelease": prerelease, "switch_withheld": withheld,
|
|
299
|
+
"use_command": f"agenthelm runtime use {info['version']} --apply" if withheld else None,
|
|
264
300
|
"previous": active.get("version") if active else None, "link": str(link) if link else None,
|
|
265
301
|
"writes": writes, "action": "install" if not existing else ("switch" if switch else "none")}
|
|
266
302
|
|
|
@@ -298,9 +334,18 @@ def apply(env: Any, planned: dict, root: Path) -> dict:
|
|
|
298
334
|
link.parent.mkdir(parents=True, exist_ok=True)
|
|
299
335
|
link.symlink_to(current_link(env) / "bin" / "agenthelm")
|
|
300
336
|
active = current(env)
|
|
337
|
+
if planned.get("switch_withheld"):
|
|
338
|
+
# current stays where it was; what must hold is that the new version is complete and current did not move.
|
|
339
|
+
installed_shim = target / "bin" / "agenthelm"
|
|
340
|
+
verified = bool(_read_manifest(target) and os.access(installed_shim, os.X_OK)
|
|
341
|
+
and (active.get("version") if active else None) == planned["previous"])
|
|
342
|
+
return {"ok": verified, "version": planned["version"], "current": active, "switched": False,
|
|
343
|
+
"verify": (_("重新读取:{0} 已装好({1}),current 仍是 {2}").format(planned['version'], installed_shim, planned['previous'])
|
|
344
|
+
if verified else _("回读不一致:请运行 agenthelm runtime status 查看")),
|
|
345
|
+
"rollback": None}
|
|
301
346
|
shim = current_link(env) / "bin" / "agenthelm"
|
|
302
347
|
verified = bool(active and active["version"] == planned["version"] and os.access(shim, os.X_OK))
|
|
303
|
-
return {"ok": verified, "version": planned["version"], "current": active,
|
|
348
|
+
return {"ok": verified, "version": planned["version"], "current": active, "switched": bool(planned["switch"]),
|
|
304
349
|
"verify": (_("重新读取:当前运行时 {0},命令 {1}").format(planned['version'], shim) if verified
|
|
305
350
|
else _("回读不一致:请运行 agenthelm runtime status 查看")),
|
|
306
351
|
"rollback": f"agenthelm runtime use {planned['previous']} --apply" if planned["previous"]
|
|
@@ -378,6 +423,9 @@ def parser() -> argparse.ArgumentParser:
|
|
|
378
423
|
if name in ("install", "update"):
|
|
379
424
|
command.add_argument("--source", type=Path, help=_("本地目录或 .tar.gz 发布包(离线安装)"))
|
|
380
425
|
command.add_argument("--link-bin", type=Path, help=_("在这个目录建 agenthelm 命令链接(例如 ~/.local/bin)"))
|
|
426
|
+
if name in ("install", "update"):
|
|
427
|
+
command.add_argument("--use", action="store_true",
|
|
428
|
+
help=_("安装候选版(-rc.N)时同时切换 current;默认只装在旁边,current 不变。正式版总是切换"))
|
|
381
429
|
if name == "install":
|
|
382
430
|
command.add_argument("--from-release", action="store_true", help=_("联网下载发布包,而不用随附内容"))
|
|
383
431
|
if name != "status":
|
|
@@ -413,6 +461,9 @@ def main(argv: list[str], host: Any) -> int:
|
|
|
413
461
|
_("本次命令来自:{0}").format(data['running_from'])]
|
|
414
462
|
if latest_origin is not None:
|
|
415
463
|
lines.append(host.origin_line(latest_origin))
|
|
464
|
+
for version in data["inactive_newer"]:
|
|
465
|
+
lines.append(_("已安装但未启用:{0}(current 仍是 {1});启用:agenthelm runtime use {0} --apply").format(
|
|
466
|
+
version, active["version"]))
|
|
416
467
|
if data["update_available"]:
|
|
417
468
|
lines.append(_("有新版本 {0}:agenthelm runtime update 预览").format(data['latest_release']))
|
|
418
469
|
if not active:
|
|
@@ -428,11 +479,17 @@ def main(argv: list[str], host: Any) -> int:
|
|
|
428
479
|
return 0
|
|
429
480
|
with tempfile.TemporaryDirectory(prefix="agenthelm-runtime-") as temporary:
|
|
430
481
|
root, origin, source_line = resolve_source(host, env, args, Path(temporary), prefer_release=args.action == "update")
|
|
431
|
-
planned = plan(env, root, origin, link_bin=args.link_bin)
|
|
482
|
+
planned = plan(env, root, origin, link_bin=args.link_bin, use=args.use)
|
|
432
483
|
lines = [_("运行时 {0}(来源:{1})").format(planned['version'], origin)]
|
|
433
484
|
if source_line:
|
|
434
485
|
lines.append(source_line)
|
|
435
|
-
lines += [_(" 将写入:{0}({1})").format(item['path'], item['scope']) for item in planned["writes"]] or
|
|
486
|
+
lines += [_(" 将写入:{0}({1})").format(item['path'], item['scope']) for item in planned["writes"]] or (
|
|
487
|
+
[] if planned["switch_withheld"] else [_(" 已是当前版本,无需改动。")])
|
|
488
|
+
if planned["switch_withheld"] and not planned["install"]:
|
|
489
|
+
lines.append(_(" {0} 已安装。").format(planned['version']))
|
|
490
|
+
if planned["switch_withheld"]:
|
|
491
|
+
lines.append(_(" 候选版:current {0}(当前 current={1})。要启用它:{2},或重跑本命令加 --use。").format(
|
|
492
|
+
_("不会切换") if not args.apply else _("未切换"), planned["previous"], planned["use_command"]))
|
|
436
493
|
if not args.apply or planned["action"] == "none" and not planned["link"]:
|
|
437
494
|
if args.apply is False and planned["writes"]:
|
|
438
495
|
lines.append(_("以上为预览;加 --apply 执行。"))
|
|
@@ -565,5 +565,45 @@
|
|
|
565
565
|
"有 {0} 项无基线差异(内容与模板不同,内容锁里没有基线),请用 {1} fix update-content(或 update --only content --keep/--append/--accept …)逐个处理。": "Differences with no baseline: {0} (the content differs from the template and the content lock has no baseline). Handle them one by one with {1} fix update-content (or update --only content --keep/--append/--accept …).",
|
|
566
566
|
"无法备份 {0} 到 {1}({2});没有改动任何文件。": "Could not back up {0} to {1} ({2}); nothing was changed.",
|
|
567
567
|
"版本号必须是单个目录名(不能含路径分隔符或 ..):{0}": "The version must be a single directory name (no path separators or ..): {0}",
|
|
568
|
-
"agenthelm runtime status 可以看到已安装的版本": "agenthelm runtime status lists the installed versions"
|
|
568
|
+
"agenthelm runtime status 可以看到已安装的版本": "agenthelm runtime status lists the installed versions",
|
|
569
|
+
"\n {0} 不兼容:同上(见 {1})": "\n {0} is incompatible: same as above (see {1})",
|
|
570
|
+
"提示:Claude 的 settings 把 agenthelm 市场固定在 {0},更新只会跟随这个 ref,版本可能不会变(最新版本 {1})。要让它跟随新版本:把 settings.json 里 agenthelm 市场声明的 ref 改成目标 tag,或去掉 ref 跟随 main(agenthelm 不会替你改 settings.json)。": "Note: Claude's settings pin the agenthelm marketplace to {0}, so an update only follows that ref and the version may not change (latest version: {1}). To follow the new version, change the ref of the agenthelm marketplace declaration in settings.json to the target tag, or remove the ref to follow main (agenthelm does not edit settings.json for you).",
|
|
571
|
+
"Claude 的 settings 把 agenthelm 市场固定在 {0},更新只会跟随这个 ref,所以版本没变;把声明里的 ref 改成目标 tag,或去掉 ref 跟随 main。": "Claude's settings pin the agenthelm marketplace to {0}, and an update only follows that ref, so the version did not change. Change the ref in the declaration to the target tag, or remove the ref to follow main.",
|
|
572
|
+
"Claude Code 还没有登记 agenthelm 市场({0} 里没有它),而 settings.json 已声明 {1}": "Claude Code has not registered the agenthelm marketplace yet ({0} does not list it), but settings.json declares {1}",
|
|
573
|
+
"读不到 Claude Code 的已登记市场({0} 无法解析),而 settings.json 已声明 {1}": "Cannot read the marketplaces Claude Code has registered ({0} cannot be parsed), but settings.json declares {1}",
|
|
574
|
+
"settings.json 声明的市场是 {0},Claude Code 已登记的是 {1}": "settings.json declares the marketplace {0}, but Claude Code has registered {1}",
|
|
575
|
+
"重启 Claude Code 让它按 settings.json 登记市场;或手动执行:claude plugin marketplace add {0}": "restart Claude Code so it registers the marketplace from settings.json; or run: claude plugin marketplace add {0}",
|
|
576
|
+
"目标 tag:{0}。": " Target tag: {0}.",
|
|
577
|
+
"settings 把 agenthelm 市场固定在目标版本 {0},无需改动。": " The settings pin the agenthelm marketplace to the target release {0}; nothing to change.",
|
|
578
|
+
"固定 Codex 市场的方法见 INSTALL.md 第 4 节": "See INSTALL.md, section 4, for how to pin the Codex marketplace",
|
|
579
|
+
"codex plugin marketplace add {0} --ref {1}(若提示该市场已存在,先 codex plugin marketplace remove {2};移除对已装插件的影响未确认);详见 INSTALL.md 第 4 节": "codex plugin marketplace add {0} --ref {1} (if it says the marketplace already exists, run codex plugin marketplace remove {2} first; the effect of removal on installed plugins is unconfirmed); see INSTALL.md, section 4",
|
|
580
|
+
"不可用(需 --source 本地源,不计入“可更新”)": "Unavailable (needs a local source via --source; not counted as updatable)",
|
|
581
|
+
"Cursor 更新用的本地仓库:给出后 Cursor 按可更新计(与 update --source 一致)": "Local repository for Cursor updates: with it, Cursor counts as updatable (same as update --source)",
|
|
582
|
+
",另有 {0} 个不可用(需 --source 本地源)": ", plus {0} unavailable (needs a local source via --source)",
|
|
583
|
+
"{0}:{1} 个不可用,需 --source 本地源": "{0}: {1} unavailable, needs a local source via --source",
|
|
584
|
+
"\n {0}\n 有本地仓库时:{1} update --source <本地仓库>;不使用 Cursor 时:{1} config ignore-client cursor --apply": "\n {0}\n With a local repository: {1} update --source <local repository>; if you do not use Cursor: {1} config ignore-client cursor --apply",
|
|
585
|
+
"安装候选版(-rc.N)时同时切换 current;默认只装在旁边,current 不变。正式版总是切换": "When installing a candidate (-rc.N), also switch current; by default it is installed beside it and current stays. A stable release always switches",
|
|
586
|
+
"重新读取:{0} 已装好({1}),current 仍是 {2}": "Read back: {0} is installed ({1}); current is still {2}",
|
|
587
|
+
"已安装但未启用:{0}(current 仍是 {1});启用:agenthelm runtime use {0} --apply": "Installed but not active: {0} (current is still {1}); activate it: agenthelm runtime use {0} --apply",
|
|
588
|
+
" {0} 已安装。": " {0} is already installed.",
|
|
589
|
+
" 候选版:current {0}(当前 current={1})。要启用它:{2},或重跑本命令加 --use。": " Candidate: current {0} (current={1}). To activate it: {2}, or rerun this command with --use.",
|
|
590
|
+
"不会切换": "will not be switched",
|
|
591
|
+
"未切换": "was not switched",
|
|
592
|
+
"与新模板相同": "same as template",
|
|
593
|
+
"没改过": "untouched",
|
|
594
|
+
"你改过": "edited by you",
|
|
595
|
+
"目前不存在": "missing",
|
|
596
|
+
"只有你的改动": "only your edits",
|
|
597
|
+
"已决定保留": "kept by decision",
|
|
598
|
+
"符号链接": "symlink",
|
|
599
|
+
"保留": "keep",
|
|
600
|
+
"替换": "replace",
|
|
601
|
+
"新建": "create",
|
|
602
|
+
"不新建": "skip",
|
|
603
|
+
"三方合并": "merge",
|
|
604
|
+
"追加区块": "append region",
|
|
605
|
+
"按当前模板处理指定的文件:{0} {1}": "Handle the named files against the current template: {0} {1}",
|
|
606
|
+
"项目没有内容锁(或内容锁里没有可刷新的内容包),--accept / --keep / --append / --diff / --merge 指定的文件没有被处理;没有改动任何文件。没有内容锁的项目用 {0} fix update-content。": "The project has no content lock (or the lock has no refreshable content pack), so the files named by --accept / --keep / --append / --diff / --merge were not handled; no file was changed. For a project without a content lock use {0} fix update-content.",
|
|
607
|
+
"有 {0} 项无基线差异(内容与模板不同,内容锁里没有基线),请用 {1} fix update-content(或 update --only content --keep {2})逐个处理。": "Differences with no baseline: {0} (the content differs from the template and the content lock has no baseline). Handle them one by one with {1} fix update-content (or update --only content --keep {2}).",
|
|
608
|
+
"保持原样": "keep"
|
|
569
609
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "agents-init",
|
|
4
|
-
"version": "6.8.
|
|
4
|
+
"version": "6.8.2",
|
|
5
5
|
"description": "Initialize or migrate an Agent project contract (AGENTS.md, Project Profile, root launcher); ships with project-orchestrator, agent-pack and opinion-manager.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "lc4t"
|
|
@@ -19,7 +19,7 @@ from pathlib import Path
|
|
|
19
19
|
from typing import Iterable
|
|
20
20
|
if str(Path(__file__).resolve().parent) not in sys.path: # also loaded by path from other plugins
|
|
21
21
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
22
|
-
from i18n_init import _, resolve_language # noqa: E402
|
|
22
|
+
from i18n_init import N_, _, resolve_language # noqa: E402
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
INITIALIZER_VERSION = "6.8.1"
|
|
@@ -988,6 +988,40 @@ def find_baseline(root: Path, relative: Path, digest: str, versions: list[str],
|
|
|
988
988
|
return None
|
|
989
989
|
|
|
990
990
|
|
|
991
|
+
# 内容刷新里的状态词与处置词:JSON 字段值保持英文标识,文本输出一律经这两个函数随界面语言显示
|
|
992
|
+
# (agent-pack 的 update --only content 与 project-orchestrator 的 fix update-content 各带一份同样的词表)。
|
|
993
|
+
STATE_LABELS = {"unchanged": N_("与新模板相同"), "clean": N_("没改过"), "modified": N_("你改过"), "missing": N_("目前不存在"),
|
|
994
|
+
"local-only": N_("只有你的改动"), "kept-by-decision": N_("已决定保留"), "symlink": N_("符号链接")}
|
|
995
|
+
ACTION_LABELS = {"keep": N_("保持原样"), "replace": N_("替换"), "create": N_("新建"), "skip": N_("不新建"), "blocked": N_("阻塞"),
|
|
996
|
+
"merge": N_("三方合并"), "append": N_("追加区块")}
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
def state_label(state: str) -> str:
|
|
1000
|
+
return _(STATE_LABELS[state]) if state in STATE_LABELS else state
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
def action_label(action: str) -> str:
|
|
1004
|
+
return _(ACTION_LABELS[action]) if action in ACTION_LABELS else action
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
def display_width(text: str) -> int:
|
|
1008
|
+
return sum(2 if ord(char) > 0x2E7F else 1 for char in text)
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
def pad_label(text: str, width: int = 10) -> str:
|
|
1012
|
+
return text + " " * max(width - display_width(text), 0)
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
def file_choices(path: str) -> str:
|
|
1016
|
+
"""The per-file commands for a file the user must decide on; every suggestion names the file."""
|
|
1017
|
+
options = [_("--keep {0} 保留你的版本(建议)").format(path)]
|
|
1018
|
+
if Path(path) in APPEND_REGIONS:
|
|
1019
|
+
options.append(_("--append {0} 保留并追加带标记的区块").format(path))
|
|
1020
|
+
options.append(_("--accept {0} 用新模板替换(先备份,会丢弃本地内容,需再加 --confirm-discard {0})").format(path))
|
|
1021
|
+
options.append(_("--diff {0} 先看差异").format(path))
|
|
1022
|
+
return _(";").join(options)
|
|
1023
|
+
|
|
1024
|
+
|
|
991
1025
|
def _refresh_notes(item: dict) -> list[str]:
|
|
992
1026
|
"""Human lines for a file refresh cannot silently decide: why, what each choice costs, what to type."""
|
|
993
1027
|
path, reason = item["path"], item.get("reason")
|
|
@@ -1000,7 +1034,8 @@ def _refresh_notes(item: dict) -> list[str]:
|
|
|
1000
1034
|
notes.append(_("有 {0} 处冲突需要你选择(第 {1} 块):--pick {2}#<序号>=mine|theirs|both"
|
|
1001
1035
|
"(mine 保留你的、theirs 取新模板、both 两边都留)").format(len(item["merge"]["unresolved"]), numbers, path))
|
|
1002
1036
|
elif reason == "no-baseline" and item.get("merge_requested"):
|
|
1003
|
-
notes.append(_("
|
|
1037
|
+
notes.append(_("内容锁里没有 {0} 的基线摘要,无法三方合并:确认不了哪个历史版本是你的起点,也不猜基线(猜错会让合并悄悄吞掉改动);"
|
|
1038
|
+
"没有改动任何文件。请改选:--keep {0} / --append {0} / --accept {0}").format(path))
|
|
1004
1039
|
if item["action"] == "merge":
|
|
1005
1040
|
merge = item["merge"]
|
|
1006
1041
|
notes.append(_("三方合并:新模板的变化已并入你的版本(自动合并 {0} 处,冲突 {1} 处均已选择;基线取自 {2});写入前先备份").format(
|
|
@@ -1009,7 +1044,7 @@ def _refresh_notes(item: dict) -> list[str]:
|
|
|
1009
1044
|
notes.append(_("{0} 是指向 {1} 的符号链接,refresh 不跟随链接改写,保留原样").format(path, item.get("link")))
|
|
1010
1045
|
if item["action"] == "blocked":
|
|
1011
1046
|
notes.append(_("确认后用 --keep {0} 记为保留(之后不再追问);要让模板接管请先把它换成普通文件").format(path))
|
|
1012
|
-
elif reason == "no-baseline":
|
|
1047
|
+
elif reason == "no-baseline" and item["action"] == "blocked" and not item.get("merge_requested"):
|
|
1013
1048
|
notes.append(_("内容锁里没有它的基线(早期版本初始化的项目),无法判断是你改过还是模板变了;建议先保留你的版本:--keep {0}").format(path))
|
|
1014
1049
|
elif reason == "edited":
|
|
1015
1050
|
notes.append(_("你改过这个文件,新模板也变了"))
|
|
@@ -1017,17 +1052,30 @@ def _refresh_notes(item: dict) -> list[str]:
|
|
|
1017
1052
|
notes.append(_("也可以三方合并(用旧版本包还原出升级前的基线,保留你的改动并带入新模板的变化):--merge {0}").format(path))
|
|
1018
1053
|
elif reason == "discard-unconfirmed":
|
|
1019
1054
|
notes.append(_("--accept 会丢弃 {0} 行本地内容;确认后追加 --confirm-discard {1}").format(item["lines_lost"], path))
|
|
1055
|
+
if item["state"] == "kept-by-decision":
|
|
1056
|
+
notes.append(_("已按你的决定保留,不再追问。要让模板接管:--accept {0}(先备份,会丢弃本地内容,需再加 --confirm-discard {0});"
|
|
1057
|
+
"要带入新模板的变化:--merge {0}(显式 --merge 是一次新的决定,覆盖此前的保留)").format(path) if reason != "no-baseline" else
|
|
1058
|
+
_("已按你的决定保留,不再追问。内容锁里没有它的基线,无法三方合并;要让模板接管:--accept {0}"
|
|
1059
|
+
"(先备份,会丢弃本地内容,需再加 --confirm-discard {0})").format(path))
|
|
1020
1060
|
if "local_lines" in item and item["action"] in {"blocked", "replace"}:
|
|
1021
1061
|
notes.append(_("本地 {0} 行,新模板 {1} 行;采用新模板会新增 {2} 行、丢弃 {3} 行本地内容").format(
|
|
1022
1062
|
item["local_lines"], item["template_lines"], item["lines_added"], item["lines_lost"]))
|
|
1023
1063
|
if item["action"] == "blocked" and Path(path) in APPEND_REGIONS:
|
|
1024
|
-
notes.append(_("
|
|
1064
|
+
notes.append(_("也可以保留你的内容并追加带标记的区块(原文不动;隐私约定只在项目声明了私有路径、且文件里还没有这条约定时才追加):--append {0}").format(path)
|
|
1065
|
+
if Path(path) == Path("AGENTS.md") else _("也可以保留你的内容并追加带标记的区块(原文不动):--append {0}").format(path))
|
|
1025
1066
|
if item["action"] == "blocked":
|
|
1026
1067
|
notes.append(_("先看差异:--diff {0}").format(path))
|
|
1027
1068
|
if item["action"] == "append":
|
|
1028
|
-
notes.append(_("
|
|
1069
|
+
notes.append(_("保留你的内容,末尾追加带标记的区块:{0}({1} 行,原文不动,先备份)").format(_("、").join(item["regions"]), item["append_lines"]))
|
|
1029
1070
|
if reason == "already-present":
|
|
1030
1071
|
notes.append(_("已经导入或带有这个区块,无需追加"))
|
|
1072
|
+
privacy = item.get("privacy_contract")
|
|
1073
|
+
if privacy == "appended":
|
|
1074
|
+
notes.append(_("项目声明了私有路径,且 {0} 里没有隐私约定:追加隐私约定区块(privacy-contract)").format(path))
|
|
1075
|
+
elif privacy == "undeclared-skipped":
|
|
1076
|
+
notes.append(_("未声明私有路径,不追加隐私约定(privacy.forbidden_default_reads 为空)"))
|
|
1077
|
+
elif privacy == "present-skipped":
|
|
1078
|
+
notes.append(_("{0} 里已有隐私约定(模板原文或你自己写的),不追加").format(path))
|
|
1031
1079
|
return notes
|
|
1032
1080
|
|
|
1033
1081
|
|
|
@@ -1200,19 +1248,28 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1200
1248
|
appended_text = None
|
|
1201
1249
|
if item["action"] == "append":
|
|
1202
1250
|
wanted, appended = [], current or ""
|
|
1251
|
+
privacy = None
|
|
1203
1252
|
for region_id in APPEND_REGIONS[relative]:
|
|
1204
1253
|
if region_id == "privacy-contract" and (
|
|
1205
1254
|
not inputs.privacy_declared or privacy_convention_state(appended, templates) in ("declared", "custom")):
|
|
1206
|
-
|
|
1255
|
+
# 没有声明私有路径,或文件里已有这条约定(模板原文或用户自己写的):不追加
|
|
1256
|
+
privacy = "undeclared-skipped" if not inputs.privacy_declared else "present-skipped"
|
|
1257
|
+
continue
|
|
1207
1258
|
body = localized(templates, f"region/{region_id}", inputs.language)
|
|
1208
1259
|
existing = regions.get(appended, region_id)
|
|
1209
1260
|
if (existing is not None and existing.intact and existing.body == regions.normalize(body)) \
|
|
1210
1261
|
or (region_id == "claude-import" and CLAUDE_IMPORT_RE.search(appended)):
|
|
1262
|
+
if region_id == "privacy-contract":
|
|
1263
|
+
privacy = "present-skipped"
|
|
1211
1264
|
continue
|
|
1212
1265
|
appended, region_state = regions.upsert(appended, region_id, body)
|
|
1213
1266
|
if region_state == "modified":
|
|
1214
1267
|
raise InitError(_("{0} 里的受管区块 {1} 被你改过:用 --mode region 处理").format(relative, region_id))
|
|
1215
1268
|
wanted.append((region_id, body))
|
|
1269
|
+
if region_id == "privacy-contract":
|
|
1270
|
+
privacy = "appended"
|
|
1271
|
+
if privacy:
|
|
1272
|
+
item["privacy_contract"] = privacy
|
|
1216
1273
|
if not wanted:
|
|
1217
1274
|
item["action"], item["reason"] = "keep", "already-present"
|
|
1218
1275
|
else:
|
|
@@ -1234,6 +1291,7 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1234
1291
|
if not_modified:
|
|
1235
1292
|
raise InitError(_("没有需要合并的本地改动(文件没改过,或已与新模板一致):") + ", ".join(not_modified))
|
|
1236
1293
|
blocked = [item["path"] for item in plan if item["action"] == "blocked"]
|
|
1294
|
+
symlinks = {item["path"] for item in plan if item.get("reason") == "symlink"}
|
|
1237
1295
|
replacing = [Path(item["path"]) for item in plan if item["action"] in {"replace", "append", "merge"}]
|
|
1238
1296
|
for relative, chosen in picks.items():
|
|
1239
1297
|
item = next(item for item in plan if item["path"] == relative.as_posix())
|
|
@@ -1256,11 +1314,15 @@ def refresh_project(args: argparse.Namespace, root: Path) -> tuple[int, dict]:
|
|
|
1256
1314
|
result["diffs"] = {path.as_posix(): next(item["diff"] for item in plan if item["path"] == path.as_posix()) for path in sorted(show_diff)}
|
|
1257
1315
|
if blocked:
|
|
1258
1316
|
hints = []
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
hints.
|
|
1317
|
+
needs_choice = [item["path"] for item in plan
|
|
1318
|
+
if item["action"] == "blocked" and item.get("reason") in {"no-baseline", "edited", "baseline-unavailable", "symlink"}]
|
|
1319
|
+
if needs_choice:
|
|
1320
|
+
hints.append(_("本地已改动的文件需逐个选择:"))
|
|
1321
|
+
hints += [_(" {0}:{1}").format(path, file_choices(path) if path not in symlinks else _("--keep {0} 保留链接原样(建议)").format(path))
|
|
1322
|
+
for path in needs_choice]
|
|
1323
|
+
for item in plan:
|
|
1324
|
+
if item.get("reason") == "discard-unconfirmed":
|
|
1325
|
+
hints.append(_("--accept 会丢弃本地内容:确认后追加 --confirm-discard {0}").format(item["path"]))
|
|
1264
1326
|
result["hint"] = "\n".join(hints)
|
|
1265
1327
|
if not args.apply or blocked or show_diff:
|
|
1266
1328
|
return (0 if not blocked else 1), result
|
|
@@ -1618,8 +1680,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1618
1680
|
else:
|
|
1619
1681
|
label = _("已应用") if result["applied"] else (_("已阻塞") if result["blocked"] else _("仅预览"))
|
|
1620
1682
|
print(_("{0}:{1}(来自 {2})").format(label, result["pack"], result["from_version"]))
|
|
1621
|
-
for
|
|
1622
|
-
print(
|
|
1683
|
+
for path, text in result.get("diffs", {}).items(): # --diff:只给差异,不再重复完整预览
|
|
1684
|
+
print(text.rstrip("\n") if text else _("({0} 与新模板没有差异)").format(path))
|
|
1685
|
+
for item in [] if result.get("diffs") else result["files"]:
|
|
1686
|
+
print(f" {pad_label(action_label(item['action']))}{item['path']} [{state_label(item['state'])}]")
|
|
1623
1687
|
for note in item.get("note", []):
|
|
1624
1688
|
print(f" {note}")
|
|
1625
1689
|
for block in (item.get("merge") or {}).get("conflicts", []):
|
|
@@ -1628,9 +1692,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1628
1692
|
for label, key in ((_("你的版本"), "mine"), (_("基线"), "base"), (_("新模板"), "theirs")):
|
|
1629
1693
|
print(f" [{label}]")
|
|
1630
1694
|
print("".join(f" {line}\n" for line in block[key].splitlines()) or " \n", end="")
|
|
1631
|
-
|
|
1632
|
-
print(text.rstrip("\n") if text else _("({0} 与新模板没有差异)").format(path))
|
|
1633
|
-
if result.get("hint"):
|
|
1695
|
+
if result.get("hint") and not result.get("diffs"):
|
|
1634
1696
|
print(result["hint"])
|
|
1635
1697
|
for line in recovery_lines(result):
|
|
1636
1698
|
print(line)
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"原文整体移到 AGENT.USER.md,AGENTS.md 换成模板(AGENTS.md 里会指向 AGENT.USER.md)": "Move the whole original to AGENT.USER.md and replace AGENTS.md with the template (AGENTS.md will point at AGENT.USER.md)",
|
|
171
171
|
"新 Case 改放到另一个目录(如 {0}/),{1}/ 完全不碰": "Put new Cases in another directory (for example {0}/) and leave {1}/ completely alone",
|
|
172
172
|
"记忆条目改放到 {0}/,{1}/ 不碰": "Put memory entries in {0}/ and leave {1}/ alone",
|
|
173
|
-
"保持原样": "
|
|
173
|
+
"保持原样": "keep",
|
|
174
174
|
"原文不动,末尾追加带标记的 @AGENTS.md 导入区块(可随时撤回)": "Keep the original text and append a marked @AGENTS.md import region at the end (can be withdrawn at any time)",
|
|
175
175
|
"Scan(只读)": "Scan (read-only)",
|
|
176
176
|
"adopt:已有 AGENTS.md 怎么处理(缺省 keep,不改动)": "adopt: what to do with an existing AGENTS.md (default keep, no change)",
|
|
@@ -285,5 +285,33 @@
|
|
|
285
285
|
"{0}:{1}(来自 {2})": "{0}: {1} (from {2})",
|
|
286
286
|
"{0}:新建 {1},替换 {2},保留冲突 {3}": "{0}: {1} create, {2} replace, {3} preserved collisions",
|
|
287
287
|
" 跳过 {0}(父目录是符号链接)": " skip {0} (symlinked parent)",
|
|
288
|
-
" 退役 {0}(已升级进 {1})": " retire {0} (upgraded into {1})"
|
|
289
|
-
|
|
288
|
+
" 退役 {0}(已升级进 {1})": " retire {0} (upgraded into {1})",
|
|
289
|
+
"与新模板相同": "same as template",
|
|
290
|
+
"没改过": "untouched",
|
|
291
|
+
"你改过": "edited by you",
|
|
292
|
+
"目前不存在": "missing",
|
|
293
|
+
"只有你的改动": "only your edits",
|
|
294
|
+
"已决定保留": "kept by decision",
|
|
295
|
+
"符号链接": "symlink",
|
|
296
|
+
"不新建": "skip",
|
|
297
|
+
"阻塞": "blocked",
|
|
298
|
+
"三方合并": "merge",
|
|
299
|
+
"追加区块": "append region",
|
|
300
|
+
"--keep {0} 保留你的版本(建议)": "--keep {0} keeps your version (recommended)",
|
|
301
|
+
"--accept {0} 用新模板替换(先备份,会丢弃本地内容,需再加 --confirm-discard {0})": "--accept {0} replaces it with the new template (backed up first; drops your local content, so also add --confirm-discard {0})",
|
|
302
|
+
"--diff {0} 先看差异": "--diff {0} shows the difference first",
|
|
303
|
+
"--append {0} 保留并追加带标记的区块": "--append {0} keeps your text and appends a marked region",
|
|
304
|
+
"本地已改动的文件需逐个选择:": "Files you changed locally need one decision each:",
|
|
305
|
+
"保留你的内容,末尾追加带标记的区块:{0}({1} 行,原文不动,先备份)": "Keeps your text and appends marked regions at the end: {0} ({1} lines; your text untouched, backed up first)",
|
|
306
|
+
"项目声明了私有路径,且 {0} 里没有隐私约定:追加隐私约定区块(privacy-contract)": "The project declares private paths and {0} has no privacy convention: the privacy-contract region is appended",
|
|
307
|
+
"已按你的决定保留,不再追问。要让模板接管:--accept {0}(先备份,会丢弃本地内容,需再加 --confirm-discard {0});要带入新模板的变化:--merge {0}(显式 --merge 是一次新的决定,覆盖此前的保留)": "Kept as you decided; it will not be asked about again. To let the template take over: --accept {0} (backed up first; drops your local content, so also add --confirm-discard {0}). To bring in the new template's changes: --merge {0} (an explicit --merge is a new decision and overrides the earlier keep)",
|
|
308
|
+
"已按你的决定保留,不再追问。内容锁里没有它的基线,无法三方合并;要让模板接管:--accept {0}(先备份,会丢弃本地内容,需再加 --confirm-discard {0})": "Kept as you decided; it will not be asked about again. The content lock has no baseline for it, so a three-way merge is impossible. To let the template take over: --accept {0} (backed up first; drops your local content, so also add --confirm-discard {0})",
|
|
309
|
+
"也可以保留你的内容并追加带标记的区块(原文不动;隐私约定只在项目声明了私有路径、且文件里还没有这条约定时才追加):--append {0}": "You can also keep your text and append marked regions (your text untouched; the privacy convention is appended only when the project declares private paths and the file does not have it yet): --append {0}",
|
|
310
|
+
"内容锁里没有 {0} 的基线摘要,无法三方合并:确认不了哪个历史版本是你的起点,也不猜基线(猜错会让合并悄悄吞掉改动);没有改动任何文件。请改选:--keep {0} / --append {0} / --accept {0}": "The content lock has no baseline digest for {0}, so a three-way merge is impossible: there is no way to confirm which historical version you started from, and no baseline is guessed (a wrong guess would let the merge silently swallow edits). No file was changed. Choose instead: --keep {0} / --append {0} / --accept {0}",
|
|
311
|
+
"{0} 里已有隐私约定(模板原文或你自己写的),不追加": "{0} already has a privacy convention (the template text or your own), so nothing is appended",
|
|
312
|
+
"--accept 会丢弃本地内容:确认后追加 --confirm-discard {0}": "--accept drops local content: after you confirm, add --confirm-discard {0}",
|
|
313
|
+
"--keep {0} 保留链接原样(建议)": "--keep {0} leaves the link as it is (recommended)",
|
|
314
|
+
" {0}:{1}": " {0}: {1}",
|
|
315
|
+
";": "; ",
|
|
316
|
+
"未声明私有路径,不追加隐私约定(privacy.forbidden_default_reads 为空)": "No private paths declared, so the privacy convention is not appended (privacy.forbidden_default_reads is empty)"
|
|
317
|
+
}
|
|
@@ -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.8.
|
|
6
|
+
"version": "6.8.2",
|
|
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": "project-orchestrator",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.3",
|
|
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"
|
|
@@ -1446,5 +1446,19 @@
|
|
|
1446
1446
|
"update-content:三方合并这个文件(还原升级前的基线,保留你的改动并带入新模板的变化;--apply 前先备份)": "update-content: three-way merge this file (restore the pre-upgrade baseline, keep your edits and bring in the template's changes; backed up before --apply)",
|
|
1447
1447
|
"update-content:为 --merge 的冲突块选择 mine(保留你的)/ theirs(取新模板)/ both(两边都留)": "update-content: resolve a --merge conflict block with mine (keep yours) / theirs (take the new template) / both (keep both)",
|
|
1448
1448
|
"update-content:只查看这个文件与新模板的完整差异,不写入": "update-content: only view this file's full difference from the new template; nothing is written",
|
|
1449
|
-
"项目(先备份,三方合并)": "Project (backed up first, three-way merge)"
|
|
1449
|
+
"项目(先备份,三方合并)": "Project (backed up first, three-way merge)",
|
|
1450
|
+
"{0} 个插件在各客户端的版本不一致": "{0} plugins have different versions across clients",
|
|
1451
|
+
"{0},连同 {1} 个本机专属目录": "{0}, plus machine-local directories: {1}",
|
|
1452
|
+
"同步目录里有 {0} 个本机专属目录": "The sync folder contains machine-local directories: {0}",
|
|
1453
|
+
"外置本机专属目录:agenthelm local-only fix --apply(先预览;单个目录的命令见 --details)": "Externalize the machine-local directories: agenthelm local-only fix --apply (preview first; see --details for the command of a single directory)",
|
|
1454
|
+
" 查看逐项:health --details(或 --output json);这些都不需要:fix --skip <ID> --reason …(只记在这台机器上)": " Item by item: health --details (or --output json); need none of these: fix --skip <ID> --reason … (recorded on this machine only)",
|
|
1455
|
+
" 查看逐项:health --details(或 --output json)": " Item by item: health --details (or --output json)",
|
|
1456
|
+
"符号链接(不跟随改写)": "symlink (never written through)",
|
|
1457
|
+
"(要求了三方合并,但内容锁里没有它的基线摘要,无法合并;没有改动任何文件,请改选保留 / 追加 / 采用新模板)": " (a three-way merge was requested, but the content lock has no baseline digest for it, so it cannot be merged; no file was changed. Choose keep / append / the new template instead)",
|
|
1458
|
+
"(要求了三方合并,但找不到升级前的基线,无法合并;没有改动任何文件)": " (a three-way merge was requested, but the pre-upgrade baseline cannot be found, so it cannot be merged; no file was changed)",
|
|
1459
|
+
"(三方合并有冲突块未选择:用 --pick {0}#<序号>=mine|theirs|both 逐块选择)": " (the three-way merge has unresolved conflict blocks: choose each with --pick {0}#<number>=mine|theirs|both)",
|
|
1460
|
+
"暂不能给出差异:{0}": "Cannot show the difference yet: {0}",
|
|
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
|
+
"({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."
|
|
1450
1464
|
}
|
|
@@ -306,12 +306,30 @@ def render_health(health: dict, show_skipped: bool = False, details: bool = Fals
|
|
|
306
306
|
|
|
307
307
|
def _group_lines(number: str, first: dict, members: list[dict]) -> list[str]:
|
|
308
308
|
"""One merged entry for several findings of one category: label with the count, a few names, how to view / handle / accept."""
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
for
|
|
313
|
-
|
|
314
|
-
lines
|
|
309
|
+
group = first["group"]
|
|
310
|
+
names = [item["group"]["member"] if item["group"].get("member") is not None
|
|
311
|
+
else item["decision"]["id"].split(":", 1)[-1] if item.get("decision") else item["title"] for item in members]
|
|
312
|
+
names = _("、").join([name for name in names if name][:3])
|
|
313
|
+
shown = len([name for name in (item["group"].get("member", "x") for item in members) if name])
|
|
314
|
+
lines = [f" {number} [{first['area']}] {S.bold(group['label'])}"]
|
|
315
|
+
if names:
|
|
316
|
+
lines.append(_(" 包含:{0}").format(names + (_("……共 {0} 项").format(shown) if shown > 3 else "")))
|
|
317
|
+
seen: set[str] = set()
|
|
318
|
+
for item in members:
|
|
319
|
+
for step in item["next"]:
|
|
320
|
+
key = step["action"] or step["label"]
|
|
321
|
+
if key in seen:
|
|
322
|
+
continue
|
|
323
|
+
seen.add(key)
|
|
324
|
+
label = item["group"].get("next_label") or step["label"] if item is not first else step["label"]
|
|
325
|
+
lines.append(_(" 下一步:{0}").format(label) + S.dim(command_hint(step["action"])))
|
|
326
|
+
kind = group.get("kind", "scaffold")
|
|
327
|
+
if kind == "machine":
|
|
328
|
+
lines.append(S.dim(_(" 查看逐项:health --details(或 --output json);这些都不需要:fix --skip <ID> --reason …(只记在这台机器上)")))
|
|
329
|
+
elif kind == "plain":
|
|
330
|
+
lines.append(S.dim(_(" 查看逐项:health --details(或 --output json)")))
|
|
331
|
+
else:
|
|
332
|
+
lines.append(S.dim(_(" 查看逐项:health --details(或 --output json);这些都不需要:fix --accept-current --reason …;单项:fix --skip <ID> --reason …")))
|
|
315
333
|
return lines
|
|
316
334
|
|
|
317
335
|
|
|
@@ -488,10 +506,24 @@ def cmd_fix(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, lis
|
|
|
488
506
|
if args.reason:
|
|
489
507
|
choices["_reason"] = args.reason
|
|
490
508
|
plan = provider.fix_plan(ids, choices)
|
|
509
|
+
if args.diff: # --diff:只输出差异,不再重复完整预览
|
|
510
|
+
diffs = {path: text for step in plan["steps"] if step["id"] == "update-content"
|
|
511
|
+
for path, text in (step["payload"].get("diffs") or {}).items()}
|
|
512
|
+
blocked = next((step["blocked"] for step in plan["steps"] if step["id"] == "update-content" and step["blocked"]), "")
|
|
513
|
+
lines = header(provider, _("修复与更新"))
|
|
514
|
+
lines += [S.yellow(_("暂不能给出差异:{0}").format(blocked))] if blocked else \
|
|
515
|
+
["\n".join([diffs[path].rstrip("\n")] if diffs.get(path) else [_("({0} 与新模板没有差异)").format(path)]) for path in args.diff]
|
|
516
|
+
return EXIT_OK, {"plan": plan, "applied": False}, lines
|
|
491
517
|
lines = header(provider, _("修复与更新")) + render_plan(plan, choices)
|
|
492
518
|
if not args.apply:
|
|
493
|
-
|
|
494
|
-
|
|
519
|
+
custom = [item["path"] for step in plan["steps"] for item in step["custom"] if item.get("content")]
|
|
520
|
+
lines.append(S.dim(_("以上为预览,没有写入。确认后加 --apply。")))
|
|
521
|
+
if custom: # 建议命令一律带上文件名(以第一个定制文件为例,其余同理)
|
|
522
|
+
name = custom[0]
|
|
523
|
+
lines.append(S.dim(_("定制文件逐个处理,例如 {0}:--keep {0} 保留你的版本;--accept {0} 用新模板替换(会丢弃本地内容时再加 --confirm-discard {0});"
|
|
524
|
+
"--merge {0} 三方合并(冲突块用 --pick {0}#<序号>=mine|theirs|both);--diff {0} 只看差异。"
|
|
525
|
+
).format(name) + (_("AGENTS.md / CLAUDE.md 也可用 --append {0} 保留原文、只追加带标记的区块。").format(name)
|
|
526
|
+
if name in ("AGENTS.md", "CLAUDE.md") else "")))
|
|
495
527
|
if any(item.get("options") for step in plan["steps"] for item in step["custom"]):
|
|
496
528
|
lines.append(S.dim(_("不想要其中某项:fix --skip <ID> --reason …(ID 见 health / check);只处理几项:在处理项后列出路径或字段。")))
|
|
497
529
|
return EXIT_OK, {"plan": plan, "applied": False}, lines
|