@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.
@@ -102,6 +102,22 @@ def _local_only_finding(item: dict) -> dict:
102
102
  "decision": {"id": item["id"], "fingerprint": item["fingerprint"], "scope": "machine"}}
103
103
 
104
104
 
105
+ def _merge_sync_findings(findings: list[dict]) -> None:
106
+ """“项目位于同步盘”与其中的“本机专属目录”指向同一批可重建目录:有两条以上时在文本里合并为一行。
107
+ findings 本身(id、level、decision)不变,只在条目上加 group,--details 与 JSON 仍逐项。"""
108
+ head = next((item for item in findings if item["id"] == "sync-folder"), None)
109
+ members = [item for item in findings if item["id"].startswith("local:real:")]
110
+ if len(members) + (1 if head else 0) < 2:
111
+ return
112
+ label = (_("{0},连同 {1} 个本机专属目录").format(head["title"], len(members)) if head
113
+ else _("同步目录里有 {0} 个本机专属目录").format(len(members)))
114
+ group = {"id": "sync-local-only", "kind": "machine", "count": len(members) + (1 if head else 0), "label": label}
115
+ for item in ([head] if head else []) + members:
116
+ item["group"] = {**group, "member": "" if item is head else item["id"].split(":", 2)[-1]}
117
+ if item is not head:
118
+ item["group"]["next_label"] = _("外置本机专属目录:agenthelm local-only fix --apply(先预览;单个目录的命令见 --details)")
119
+
120
+
105
121
  def check_updates(provider: Any, findings: list[dict], ok: list[str]) -> dict:
106
122
  host = provider.host
107
123
  if host is None:
@@ -121,6 +137,7 @@ def check_updates(provider: Any, findings: list[dict], ok: list[str]) -> dict:
121
137
  "decision": {"id": item["id"], "fingerprint": item["fingerprint"], "scope": "machine"}})
122
138
  elif item.get("fix") == "local-only" or item.get("kind") == "error":
123
139
  findings.append(_local_only_finding(item))
140
+ _merge_sync_findings(findings)
124
141
  try:
125
142
  report = host.run_check(env, provider.root, offline=provider.offline)
126
143
  except (host.CheckError, OSError, ValueError) as exc:
@@ -176,13 +193,22 @@ def _plugin_findings(provider: Any, env: Any, report: dict, findings: list[dict]
176
193
  findings.append({"id": "legacy", "level": "suggest", "area": _("插件"), "title": _("有旧方式安装待迁移"),
177
194
  "reason": _("旧的复制 + 软链安装与市场安装并存会重复"), "impact": _("Agent 里可能看到重复的 Skill"),
178
195
  "next": [{"label": _("运行 agenthelm migrate --install 预览迁移"), "action": ""}]})
179
- for issue in host.doctor(env, report)["issues"]:
196
+ issues = host.doctor(env, report)["issues"]
197
+ skewed = [issue for issue in issues if issue["issue"] == "version-skew"]
198
+ for issue in issues:
180
199
  if issue["issue"] in ("version-skew", "duplicate", "incomplete"):
181
- findings.append({"id": f"doctor-{issue['issue']}", "level": "suggest", "area": _("插件"),
182
- "title": {"version-skew": _("各客户端插件版本不一致"), "duplicate": _("插件重复安装"),
183
- "incomplete": _("插件没有装全")}[issue["issue"]],
184
- "reason": issue["detail"], "impact": _("只影响 AI Agent 使用"),
185
- "next": [{"label": _("运行 agenthelm doctor 查看"), "action": ""}]})
200
+ title = {"version-skew": _("各客户端插件版本不一致"), "duplicate": _("插件重复安装"),
201
+ "incomplete": _("插件没有装全")}[issue["issue"]]
202
+ entry = {"id": f"doctor-{issue['issue']}", "level": "suggest", "area": _("插件"), "title": title,
203
+ "reason": issue["detail"], "impact": _("只影响 AI Agent 使用"),
204
+ "next": [{"label": _("运行 agenthelm doctor 查看"), "action": ""}]}
205
+ if issue["issue"] == "version-skew" and len(skewed) > 1:
206
+ # 多个插件各有一条:id 带插件名保持唯一,文本默认合并为一行(--details 逐项)。
207
+ entry["id"] += f":{issue['plugin']}"
208
+ entry["title"] = _("{0}:{1}").format(title, issue["plugin"])
209
+ entry["group"] = {"id": "plugins:version-skew", "kind": "plain", "count": len(skewed),
210
+ "label": _("{0} 个插件在各客户端的版本不一致").format(len(skewed)), "member": issue["plugin"]}
211
+ findings.append(entry)
186
212
 
187
213
 
188
214
  def _content_findings(report: dict, findings: list[dict], ok: list[str]) -> None:
@@ -320,8 +346,10 @@ def _plan_step(provider: Any, fix_id: str, choices: dict[str, str]) -> dict:
320
346
  if fix_id == "update-plugins":
321
347
  steps = host.update_steps(env, report, None, None, env.home, [], [], None, "plugins")
322
348
  behind = [item for item in report["plugins"] if item["status"] == "behind"]
323
- changes = [_("{0} → {1}:{2}").format(item['plugin'], step['to'], step['summary']) for item in behind for step in item["steps"]]
324
- actions = [action for item in behind for step in item["steps"] for action in step["actions"]]
349
+ # 同一插件同一版本的迁移说明在每个客户端下都一样:只列一次(JSON 的逐客户端明细在 check 里不变)。
350
+ changes = list(dict.fromkeys(_("{0} → {1}:{2}").format(item['plugin'], step['to'], step['summary'])
351
+ for item in behind for step in item["steps"]))
352
+ actions = list(dict.fromkeys(action for item in behind for step in item["steps"] for action in step["actions"]))
325
353
  blocked = next((step.blocked for step in steps if step.blocked), "") or \
326
354
  (_("当前离线:需要联网,只能预览") if provider.offline else "")
327
355
  return _step(fix_id, _("更新客户端里的插件"), network=True, changes=changes + [_("需要的动作:{0}").format(a) for a in actions],
@@ -451,7 +479,7 @@ def _plan_content(provider: Any, env: Any, report: dict | None, choices: dict[st
451
479
 
452
480
 
453
481
  CONTENT_STATE = {"unchanged": N_("与新模板相同"), "clean": N_("没改过"), "modified": N_("你改过"), "missing": N_("目前不存在"),
454
- "local-only": N_("只有你的改动,新模板没变"), "kept-by-decision": N_("你已决定保留")}
482
+ "local-only": N_("只有你的改动,新模板没变"), "kept-by-decision": N_("你已决定保留"), "symlink": N_("符号链接(不跟随改写)")}
455
483
  CONTENT_ACTION = {"keep": N_("保留"), "replace": N_("换成新模板(先备份)"), "create": N_("新建"), "skip": N_("不新建"),
456
484
  "blocked": N_("需要你选择"), "merge": N_("三方合并(先备份)"), "append": N_("保留原文,末尾追加带标记的区块(先备份)")}
457
485
 
@@ -468,7 +496,12 @@ def _content_change(item: dict, effective: dict[str, str]) -> str:
468
496
  if item["state"] == "modified" and "local_lines" in item and action != "merge":
469
497
  note += _("(本地 {0} 行,新模板 {1} 行;采用新模板会丢弃 {2} 行本地内容)").format(
470
498
  item["local_lines"], item["template_lines"], item["lines_lost"])
471
- if item.get("reason") == "no-baseline" and item["state"] == "modified":
499
+ if item.get("merge_requested") and item["action"] == "blocked":
500
+ reason = item.get("reason")
501
+ note += {"no-baseline": _("(要求了三方合并,但内容锁里没有它的基线摘要,无法合并;没有改动任何文件,请改选保留 / 追加 / 采用新模板)"),
502
+ "baseline-unavailable": _("(要求了三方合并,但找不到升级前的基线,无法合并;没有改动任何文件)"),
503
+ "merge-conflict": _("(三方合并有冲突块未选择:用 --pick {0}#<序号>=mine|theirs|both 逐块选择)").format(item["path"])}.get(reason, "")
504
+ elif item.get("reason") == "no-baseline" and item["state"] == "modified":
472
505
  note += _("(内容锁里没有它的基线,无法判断是你改过还是模板变了)")
473
506
  return _("{0}:{1} → {2}{3}").format(item['path'], _(CONTENT_STATE.get(item['state'], item['state'])), _(CONTENT_ACTION.get(action, action)), note)
474
507