@sakanano-moe/agenthelm 6.8.0 → 6.11.0-rc.2

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.
Files changed (90) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +2 -0
  3. package/package.json +1 -1
  4. package/runtime/index.json +6 -6
  5. package/runtime/plugins/agent-pack/.codex-plugin/plugin.json +1 -1
  6. package/runtime/plugins/agent-pack/hooks/hooks.json +32 -0
  7. package/runtime/plugins/agent-pack/plugin.json +1 -1
  8. package/runtime/plugins/agent-pack/references/local-only.md +126 -0
  9. package/runtime/plugins/agent-pack/references/nudge.en.md +58 -0
  10. package/runtime/plugins/agent-pack/references/nudge.md +58 -0
  11. package/runtime/plugins/agent-pack/runtime/agent_pack_nudge.py +613 -0
  12. package/runtime/plugins/agent-pack/runtime/agenthelm.py +1271 -221
  13. package/runtime/plugins/agent-pack/runtime/agenthelm_runtime.py +114 -65
  14. package/runtime/plugins/agent-pack/runtime/i18n_agent_pack.py +78 -0
  15. package/runtime/plugins/agent-pack/runtime/local_only.py +1132 -0
  16. package/runtime/plugins/agent-pack/runtime/locale/en.json +569 -0
  17. package/runtime/plugins/agent-pack/runtime/mcp_server.py +25 -0
  18. package/runtime/plugins/agent-pack/runtime/nudge_text.py +127 -0
  19. package/runtime/plugins/agent-pack/runtime/user_settings.py +275 -0
  20. package/runtime/plugins/agent-pack/skills/agent-pack/SKILL.md +11 -1
  21. package/runtime/plugins/agents-init/.codex-plugin/plugin.json +1 -1
  22. package/runtime/plugins/agents-init/content.json +4 -4
  23. package/runtime/plugins/agents-init/plugin.json +1 -1
  24. package/runtime/plugins/agents-init/skills/agents-init/AGENT.template.md +141 -5
  25. package/runtime/plugins/agents-init/skills/agents-init/SKILL.md +41 -8
  26. package/runtime/plugins/agents-init/skills/agents-init/project.schema.json +408 -80
  27. package/runtime/plugins/agents-init/skills/agents-init/scripts/adopt.py +615 -0
  28. package/runtime/plugins/agents-init/skills/agents-init/scripts/baseline.py +221 -0
  29. package/runtime/plugins/agents-init/skills/agents-init/scripts/i18n_init.py +78 -0
  30. package/runtime/plugins/agents-init/skills/agents-init/scripts/init_project.py +748 -159
  31. package/runtime/plugins/agents-init/skills/agents-init/scripts/locale/en.json +289 -0
  32. package/runtime/plugins/agents-init/skills/agents-init/scripts/merge3.py +149 -0
  33. package/runtime/plugins/agents-init/skills/agents-init/scripts/regions.py +99 -0
  34. package/runtime/plugins/agents-init/skills/agents-init/scripts/scaffold.py +594 -90
  35. package/runtime/plugins/agents-init/skills/agents-init/skeleton.json +2 -0
  36. package/runtime/plugins/agents-init/skills/agents-init/skill.json +1 -1
  37. package/runtime/plugins/opinion-manager/.codex-plugin/plugin.json +1 -1
  38. package/runtime/plugins/opinion-manager/plugin.json +1 -1
  39. package/runtime/plugins/opinion-manager/references/inbox.en.md +48 -0
  40. package/runtime/plugins/opinion-manager/references/inbox.md +48 -0
  41. package/runtime/plugins/opinion-manager/runtime/context.py +31 -26
  42. package/runtime/plugins/opinion-manager/runtime/i18n_opinion.py +78 -0
  43. package/runtime/plugins/opinion-manager/runtime/inbox.py +398 -0
  44. package/runtime/plugins/opinion-manager/runtime/inbox_text.py +114 -0
  45. package/runtime/plugins/opinion-manager/runtime/lifecycle.py +45 -44
  46. package/runtime/plugins/opinion-manager/runtime/locale/en.json +193 -0
  47. package/runtime/plugins/opinion-manager/runtime/opinion_manager.py +55 -50
  48. package/runtime/plugins/opinion-manager/runtime/versioned.py +90 -85
  49. package/runtime/plugins/opinion-manager/skills/opinion-manager/SKILL.md +15 -2
  50. package/runtime/plugins/project-orchestrator/.codex-plugin/plugin.json +1 -1
  51. package/runtime/plugins/project-orchestrator/content.json +30 -3
  52. package/runtime/plugins/project-orchestrator/plugin.json +1 -1
  53. package/runtime/plugins/project-orchestrator/references/case-workspaces.md +9 -1
  54. package/runtime/plugins/project-orchestrator/references/case.schema.json +1 -0
  55. package/runtime/plugins/project-orchestrator/references/sop-interview.md +83 -0
  56. package/runtime/plugins/project-orchestrator/references/sop.md +156 -0
  57. package/runtime/plugins/project-orchestrator/runtime/assets.py +52 -57
  58. package/runtime/plugins/project-orchestrator/runtime/case.py +139 -80
  59. package/runtime/plugins/project-orchestrator/runtime/case_structure.py +71 -0
  60. package/runtime/plugins/project-orchestrator/runtime/case_workspace.py +47 -46
  61. package/runtime/plugins/project-orchestrator/runtime/i18n_orchestrator.py +78 -0
  62. package/runtime/plugins/project-orchestrator/runtime/locale/en.json +1450 -0
  63. package/runtime/plugins/project-orchestrator/runtime/memory.py +45 -45
  64. package/runtime/plugins/project-orchestrator/runtime/private_paths.py +119 -0
  65. package/runtime/plugins/project-orchestrator/runtime/project_base.py +37 -19
  66. package/runtime/plugins/project-orchestrator/runtime/project_cli.py +307 -195
  67. package/runtime/plugins/project-orchestrator/runtime/project_demo.py +130 -48
  68. package/runtime/plugins/project-orchestrator/runtime/project_maintain.py +328 -221
  69. package/runtime/plugins/project-orchestrator/runtime/project_menu.py +167 -89
  70. package/runtime/plugins/project-orchestrator/runtime/project_real.py +187 -105
  71. package/runtime/plugins/project-orchestrator/runtime/project_write.py +58 -55
  72. package/runtime/plugins/project-orchestrator/runtime/sop.py +1670 -0
  73. package/runtime/plugins/project-orchestrator/runtime/sop_structure.py +226 -0
  74. package/runtime/plugins/project-orchestrator/runtime/wf.py +74 -70
  75. package/runtime/plugins/project-orchestrator/skills/project-orchestrator/SKILL.md +22 -0
  76. package/runtime/plugins/project-orchestrator/sop-templates/blank/SOP.en.md +57 -0
  77. package/runtime/plugins/project-orchestrator/sop-templates/blank/SOP.md +57 -0
  78. package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/SOP.en.md +77 -0
  79. package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/SOP.md +77 -0
  80. package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/templates/digest.en.md +11 -0
  81. package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/templates/digest.md +11 -0
  82. package/runtime/plugins/project-orchestrator/sop-templates/video-to-transcript/SOP.en.md +87 -0
  83. package/runtime/plugins/project-orchestrator/sop-templates/video-to-transcript/SOP.md +87 -0
  84. package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/SOP.en.md +75 -0
  85. package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/SOP.md +75 -0
  86. package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/templates/review.en.md +11 -0
  87. package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/templates/review.md +12 -0
  88. package/runtime/plugins/project-orchestrator/templates/CASE.en.md +39 -0
  89. package/runtime/plugins/agents-init/skills/agents-init/scripts/test_init_project.py +0 -678
  90. package/runtime/plugins/agents-init/skills/agents-init/scripts/test_scaffold.py +0 -551
@@ -21,11 +21,16 @@ from pathlib import Path
21
21
  from typing import Any
22
22
 
23
23
  import assets
24
+ import case_structure as structure
24
25
  import case as case_tool
25
26
  import project_maintain
27
+ import private_paths
26
28
  import project_write
29
+ import sop as sop_tool
27
30
  from project_base import (GROUP_KEYS, LAUNCHER_API, EntryError, entry_section, find_profile_root, inside,
28
- read_profile)
31
+ read_profile, sop_call)
32
+ from i18n_orchestrator import _ # noqa: E402
33
+ from i18n_orchestrator import _ # noqa: E402
29
34
 
30
35
  RECORD_STAMP = re.compile(r"^(\d{4}-\d{2}-\d{2}T[0-9:]{5,8}(?:Z|[+-]\d{2}:\d{2})?)\s+(.*)$")
31
36
  TOOL_TIMEOUT_SECONDS = 30
@@ -36,11 +41,12 @@ def now_iso() -> str:
36
41
 
37
42
 
38
43
  def last_record(body: str) -> dict | None:
39
- """The newest bullet under ``## 工作记录`` (records are appended, so the last one)."""
40
- marker = "## 工作记录\n"
41
- start = body.find(marker)
42
- if start < 0:
44
+ """The newest bullet under the work-log section, in either language (records are appended, so the last one)."""
45
+ name = structure.existing_heading(body, "work_log")
46
+ if name is None:
43
47
  return None
48
+ marker = f"## {name}\n"
49
+ start = body.find(marker)
44
50
  end = body.find("\n## ", start + len(marker))
45
51
  lines = [line[2:].strip() for line in body[start + len(marker):None if end < 0 else end].splitlines()
46
52
  if line.startswith("- ")]
@@ -78,8 +84,8 @@ class RealProvider:
78
84
  try:
79
85
  return assets.Project(self.root)
80
86
  except assets.AssetError as exc:
81
- raise EntryError(f"资料扫描范围配置有误:{exc}", "profile-invalid",
82
- ["检查 Profile 的 work.case.root 与 work.assets.roots"]) from exc
87
+ raise EntryError(_("资料扫描范围配置有误:{0}").format(exc), "profile-invalid",
88
+ [_("检查 Profile 的 work.case.root 与 work.assets.roots")]) from exc
83
89
 
84
90
  def index_state(self) -> dict:
85
91
  try:
@@ -109,8 +115,8 @@ class RealProvider:
109
115
  for finding in (self._health or {}).get("findings", []):
110
116
  levels[finding["level"]] = levels.get(finding["level"], 0) + 1
111
117
  tools = project_write.load_tools(self)
112
- return {"name": self.name, "kind": "、".join(map(str, types)) or "通用",
113
- "kind_label": ("、".join(map(str, types)) + " 项目") if types else "项目",
118
+ return {"name": self.name, "kind": _("、").join(map(str, types)) or _("通用"),
119
+ "kind_label": (_("、").join(map(str, types)) + _(" 项目")) if types else _("项目"),
114
120
  "launcher": self.launcher(), "index": self.index_state(), "items": counts,
115
121
  "health": levels, "health_checked": self._health is not None, "read_at": now_iso(),
116
122
  "tools": {"declared": len(tools["tools"]),
@@ -124,25 +130,25 @@ class RealProvider:
124
130
  try:
125
131
  result = assets.find(project, terms, ext=ext, container=container, limit=limit)
126
132
  except assets.AssetError as exc:
127
- raise EntryError(f"查找失败:{exc}", "index-broken",
128
- ["重建资料索引(只改用户缓存):fix rebuild-index --apply"]) from exc
133
+ raise EntryError(_("查找失败:{0}").format(exc), "index-broken",
134
+ [_("重建资料索引(只改用户缓存):fix rebuild-index --apply")]) from exc
129
135
  return {**result, "index": self.index_state()}
130
136
 
131
137
  def refs(self, path: str) -> dict:
132
138
  try:
133
139
  result = assets.refs(self.assets_project(), path)
134
140
  except assets.AssetError as exc:
135
- raise EntryError(f"查不到引用关系:{exc}", "index-broken") from exc
141
+ raise EntryError(_("查不到引用关系:{0}").format(exc), "index-broken") from exc
136
142
  return {"path": result["path"], "inbound": [item["src"] for item in result["inbound"]],
137
143
  "outbound": [item["dst"] for item in result["outbound"]],
138
144
  "affected": result.get("affected_containers", [])}
139
145
 
140
146
  def act(self, action: str, path: str) -> dict:
141
- target = inside(self.root, path, "路径")
147
+ target = inside(self.root, path, _("路径"))
142
148
  if not target.exists():
143
- raise EntryError(f"文件不存在:{path}", "not-found", ["索引可能过期:重新查找一次"])
149
+ raise EntryError(_("文件不存在:{0}").format(path), "not-found", [_("索引可能过期:重新查找一次")])
144
150
  absolute = str(target)
145
- verbs = {"open": "打开", "reveal": "显示所在目录", "copy": "复制路径"}
151
+ verbs = {"open": _("打开"), "reveal": _("显示所在目录"), "copy": _("复制路径")}
146
152
  command = None if os.environ.get("AGENTHELM_OPEN") == "print" else _open_command(action, target)
147
153
  if command and shutil.which(command[0]):
148
154
  completed = subprocess.run(command, input=absolute.encode("utf-8") if action == "copy" else None,
@@ -150,17 +156,17 @@ class RealProvider:
150
156
  timeout=15)
151
157
  if completed.returncode == 0:
152
158
  return {"action": action, "path": path, "executed": True, "absolute": absolute,
153
- "message": f"已{verbs[action]}:{path}"}
159
+ "message": _("已{0}:{1}").format(verbs[action], path)}
154
160
  return {"action": action, "path": path, "executed": False, "absolute": absolute,
155
- "message": f"这台机器不能直接{verbs[action]},绝对路径:{absolute}"}
161
+ "message": _("这台机器不能直接{0},绝对路径:{1}").format(verbs[action], absolute)}
156
162
 
157
163
  # -------------------------------------------------------------- progress
158
164
 
159
165
  def items_source(self) -> str:
160
166
  items = self.entry["items"]
161
167
  if items:
162
- return f"项目工具 {' '.join(items['command'])}(只读接口 list)"
163
- return f"{self._case_root_text()}/*/CASE.md(默认 Case 工具)"
168
+ return _("项目工具 {0}(只读接口 list)").format(' '.join(items['command']))
169
+ return _("{0}/*/CASE.md(默认 Case 工具)").format(self._case_root_text())
164
170
 
165
171
  def _case_root_text(self) -> str:
166
172
  work = self.profile.get("work") or {}
@@ -181,13 +187,13 @@ class RealProvider:
181
187
  rows = [self._normalize(item, status_map) for item in raw]
182
188
  return {"items": rows, "invalid": [], "source": self.items_source(), "read_at": now_iso()}
183
189
  if self.work_mode != "case-workspace":
184
- raise EntryError("这个项目没有使用 Case 工作目录,也没有声明事项工具", "unavailable",
185
- ["work.mode 为 legacy:事项由项目自己的方式管理",
186
- "如需在本入口查看,可在 Profile 的 entry.items 声明事项工具(见 case-workspaces.md「项目入口适配」)"])
190
+ raise EntryError(_("这个项目没有使用 Case 工作目录,也没有声明事项工具"), "unavailable",
191
+ [_("work.mode 为 legacy:事项由项目自己的方式管理"),
192
+ _("如需在本入口查看,可在 Profile 的 entry.items 声明事项工具(见 case-workspaces.md「项目入口适配」)")])
187
193
  try:
188
194
  project = case_tool.Project(self.root)
189
195
  except case_tool.CaseError as exc:
190
- raise EntryError(f"读不了事项:{exc}", "profile-invalid") from exc
196
+ raise EntryError(_("读不了事项:{0}").format(exc), "profile-invalid") from exc
191
197
  rows, invalid = [], []
192
198
  for directory in project.case_dirs():
193
199
  path = directory / "CASE.md"
@@ -217,18 +223,18 @@ class RealProvider:
217
223
  completed = subprocess.run(command, cwd=self.root, capture_output=True, text=True, check=False,
218
224
  timeout=TOOL_TIMEOUT_SECONDS)
219
225
  except (OSError, subprocess.TimeoutExpired) as exc:
220
- raise EntryError(f"项目事项工具无法运行:{exc}", "unavailable",
221
- [f"命令:{' '.join(command)}", "检查 Profile 的 entry.items.command"]) from exc
226
+ raise EntryError(_("项目事项工具无法运行:{0}").format(exc), "unavailable",
227
+ [_("命令:{0}").format(' '.join(command)), _("检查 Profile 的 entry.items.command")]) from exc
222
228
  try:
223
229
  data = json.loads(completed.stdout)
224
230
  except ValueError as exc:
225
231
  detail = (completed.stderr or completed.stdout).strip()[:200]
226
- raise EntryError("项目事项工具的 list 没有返回 JSON", "unavailable",
227
- [f"命令:{' '.join(command)}", detail or "(无输出)"]) from exc
232
+ raise EntryError(_("项目事项工具的 list 没有返回 JSON"), "unavailable",
233
+ [_("命令:{0}").format(' '.join(command)), detail or _("(无输出)")]) from exc
228
234
  rows = data.get("items", data.get("cases")) if isinstance(data, dict) else data
229
235
  if completed.returncode != 0 or not isinstance(rows, list):
230
- raise EntryError("项目事项工具的 list 返回格式不符合约定", "unavailable",
231
- ["约定:list --all --output json 返回 {\"items\": [...]},见 case-workspaces.md"])
236
+ raise EntryError(_("项目事项工具的 list 返回格式不符合约定"), "unavailable",
237
+ [_("约定:list --all --output json 返回 {\"items\": [...]},见 case-workspaces.md")])
232
238
  return [row for row in rows if isinstance(row, dict)]
233
239
 
234
240
  @staticmethod
@@ -256,9 +262,9 @@ class RealProvider:
256
262
  exact = [item for item in rows if token in (item["id"], *item["legacy_ids"], *item["aliases"])]
257
263
  matches = exact or [item for item in rows if _item_hits(token, item)]
258
264
  if not matches:
259
- raise EntryError(f"没有找到事项:{token}", "not-found", ["试试更短的词,或在「看进展」里浏览全部"])
265
+ raise EntryError(_("没有找到事项:{0}").format(token), "not-found", [_("试试更短的词,或在「看进展」里浏览全部")])
260
266
  if len(matches) > 1:
261
- raise EntryError(f"有 {len(matches)} 个事项都匹配“{token}”", "ambiguous",
267
+ raise EntryError(_("有 {0} 个事项都匹配“{1}”").format(len(matches), token), "ambiguous",
262
268
  [f"{item['id']} {item['title']}" for item in matches[:10]])
263
269
  return {**matches[0], "source": self.items_source()}
264
270
 
@@ -267,28 +273,28 @@ class RealProvider:
267
273
  def guide(self) -> dict:
268
274
  prefix = self.command_prefix()
269
275
  about = self.entry["about"] or _readme_intro(self.root) or \
270
- "(项目还没有写简介:可以在 README.md 开头写一段,或在 Profile 的 entry.about 写一句话)"
276
+ _("(项目还没有写简介:可以在 README.md 开头写一段,或在 Profile 的 entry.about 写一句话)")
271
277
  where = [(item["label"], item["path"]) for item in self.entry["where"]]
272
278
  if not where:
273
279
  work = self.profile.get("work") or {}
274
280
  if self.work_mode == "case-workspace":
275
- where.append(("事项与各自资料", f"{self._case_root_text()}/"))
281
+ where.append((_("事项与各自资料"), f"{self._case_root_text()}/"))
276
282
  for root in ((work.get("assets") or {}).get("roots") or []):
277
- where.append(("资料", f"{root}/"))
278
- for label, relative in (("参考资料", "docs/refs"), ("草稿", "docs/drafts"), ("记忆", "memory")):
283
+ where.append((_("资料"), f"{root}/"))
284
+ for label, relative in ((_("参考资料"), "docs/refs"), (_("草稿"), "docs/drafts"), (_("记忆"), "memory"), (_("流程(SOP)"), "sops")):
279
285
  if (self.root / relative).is_dir():
280
286
  where.append((label, f"{relative}/"))
281
- start = self.entry["start"] or ["「看进展」先看进行中和等待中的事项", "需要哪份资料,用「找资料」输入关键词",
282
- "做完一步,用「记录事项」追加一条记录"]
287
+ start = self.entry["start"] or [_("「看进展」先看进行中和等待中的事项"), _("需要哪份资料,用「找资料」输入关键词"),
288
+ _("做完一步,用「记录事项」追加一条记录")]
283
289
  guide_file = self.entry["guide"]
284
290
  if guide_file:
285
- where.insert(0, ("项目首页", guide_file))
291
+ where.insert(0, (_("项目首页"), guide_file))
286
292
  return {"name": self.name, "kind": self.overview()["kind"], "about": about,
287
293
  "launcher": self.launcher(), "command": prefix, "where": where, "start": start,
288
- "examples": [("按关键词和日期找资料", "1 → 关键词 2026-10", "find 关键词 2026-10"),
289
- ("看某个事项现在到哪了", "2 → 输入事项名称或旧编号", "show 名称"),
290
- ("检查项目和环境", "4", "health"),
291
- ("不进菜单、给脚本用", "—", "progress --output json")],
294
+ "examples": [(_("按关键词和日期找资料"), _("1 → 关键词 2026-10"), _("find 关键词 2026-10")),
295
+ (_("看某个事项现在到哪了"), _("2 → 输入事项名称或旧编号"), _("show 名称")),
296
+ (_("检查项目和环境"), "4", "health"),
297
+ (_("不进菜单、给脚本用"), "—", "progress --output json")],
292
298
  "capabilities": self.capabilities(), "readme_mentions_entry": _readme_mentions(self)}
293
299
 
294
300
  def capabilities(self) -> list[dict]:
@@ -303,21 +309,24 @@ class RealProvider:
303
309
  if tools["error"]:
304
310
  tools_state = ("unavailable", tools["error"])
305
311
  elif tools["tools"]:
306
- tools_state = ("available", f"{len(tools['tools'])} 个已声明")
312
+ tools_state = ("available", _("{0} 个已声明").format(len(tools['tools'])))
307
313
  else:
308
- tools_state = ("unavailable", "项目没有声明专用工具")
309
- index_reason = {"missing": "首次查找时建立索引", "stale": "查找时自动更新索引",
310
- "broken": "索引损坏:查找时会尝试重建,也可在「修复与更新」里重建"}.get(index, "")
314
+ tools_state = ("unavailable", _("项目没有声明专用工具"))
315
+ index_reason = {"missing": _("首次查找时建立索引"), "stale": _("查找时自动更新索引"),
316
+ "broken": _("索引损坏:查找时会尝试重建,也可在「修复与更新」里重建")}.get(index, "")
317
+ sops = {"id": "sop", "title": _("流程(SOP)"), "state": "available", "offline": True,
318
+ "reason": "" if any(True for _unused in sop_tool.load_all(self.root)) else _("还没有流程:sop new 创建,或让 Agent 带你谈清")}
311
319
  return [
312
- {"id": "find", "title": "找资料", "state": "available", "reason": index_reason, "offline": True},
313
- {"id": "progress", "title": "看进展", "state": progress[0], "reason": progress[1], "offline": True},
314
- {"id": "guide", "title": "项目指南", "state": "available", "reason": "", "offline": True},
315
- {"id": "health", "title": "检查项目与环境", "state": "available",
316
- "reason": "联网检查使用缓存" if self.offline else "", "offline": True},
317
- {"id": "fix", "title": "修复与更新", "state": "available",
318
- "reason": "需要联网的项离线时只能预览", "offline": False},
319
- {"id": "record", "title": "记录事项", "state": record[0], "reason": record[1], "offline": True},
320
- {"id": "tools", "title": "项目工具", "state": tools_state[0], "reason": tools_state[1], "offline": True},
320
+ {"id": "find", "title": _("找资料"), "state": "available", "reason": index_reason, "offline": True},
321
+ {"id": "progress", "title": _("看进展"), "state": progress[0], "reason": progress[1], "offline": True},
322
+ {"id": "guide", "title": _("项目指南"), "state": "available", "reason": "", "offline": True},
323
+ {"id": "health", "title": _("检查项目与环境"), "state": "available",
324
+ "reason": _("联网检查使用缓存") if self.offline else "", "offline": True},
325
+ {"id": "fix", "title": _("修复与更新"), "state": "available",
326
+ "reason": _("需要联网的项离线时只能预览"), "offline": False},
327
+ {"id": "record", "title": _("记录事项"), "state": record[0], "reason": record[1], "offline": True},
328
+ {"id": "tools", "title": _("项目工具"), "state": tools_state[0], "reason": tools_state[1], "offline": True},
329
+ sops,
321
330
  ]
322
331
 
323
332
  # -------------------------------------------------------------- health
@@ -330,6 +339,8 @@ class RealProvider:
330
339
  self._check_index(findings, ok)
331
340
  self._check_items(findings, ok)
332
341
  self._check_memory(findings, ok)
342
+ self._check_sop(findings, ok)
343
+ self._check_private(findings, ok)
333
344
  project_write.check_tools(self, findings, ok)
334
345
  source = project_maintain.check_updates(self, findings, ok)
335
346
  self._health = {"findings": findings, "ok": ok, "read_at": now_iso(), "update_source": source,
@@ -337,92 +348,91 @@ class RealProvider:
337
348
  return self._health
338
349
 
339
350
  def _check_environment(self, findings: list[dict], ok: list[str]) -> None:
340
- ok.append(f"运行环境(Python {platform.python_version()},{platform.system() or sys.platform})")
351
+ ok.append(_("运行环境(Python {0},{1})").format(platform.python_version(), platform.system() or sys.platform))
341
352
  if self.host is None:
342
- findings.append({"id": "no-agent-pack", "level": "unavailable", "area": "环境",
343
- "title": "找不到 agent-pack,插件、模板与运行时状态无法检查",
344
- "reason": "当前运行方式没有携带 agent-pack", "impact": "找资料、看进展、指南不受影响",
345
- "next": [{"label": "用 agenthelm 运行时打开(agenthelm runtime install)", "action": ""}]})
353
+ findings.append({"id": "no-agent-pack", "level": "unavailable", "area": _("环境"),
354
+ "title": _("找不到 agent-pack,插件、模板与运行时状态无法检查"),
355
+ "reason": _("当前运行方式没有携带 agent-pack"), "impact": _("找资料、看进展、指南不受影响"),
356
+ "next": [{"label": _("用 agenthelm 运行时打开(agenthelm runtime install)"), "action": ""}]})
346
357
 
347
358
  def _check_entry(self, findings: list[dict], ok: list[str]) -> None:
348
359
  launcher = self.launcher()
349
360
  if not self.entry["declared"] or not launcher:
350
- findings.append({"id": "add-entry", "level": "suggest", "area": "入口", "title": "项目根目录还没有人用入口",
351
- "reason": "Profile 没有 entry.launcher", "impact": "不知道命令的人不容易发现本菜单",
352
- "next": [{"label": "生成根目录启动器(默认名 menu,可改)", "action": "fix:add-entry"}]})
361
+ findings.append({"id": "add-entry", "level": "suggest", "area": _("入口"), "title": _("项目根目录还没有人用入口"),
362
+ "reason": _("Profile 没有 entry.launcher"), "impact": _("不知道命令的人不容易发现本菜单"),
363
+ "next": [{"label": _("生成根目录启动器(默认名 menu,可改)"), "action": "fix:add-entry"}]})
353
364
  return
354
365
  path = self.root / launcher
355
366
  if not path.is_file():
356
- findings.append({"id": "update-content", "level": "suggest", "area": "入口",
357
- "title": f"启动器 {launcher} 不存在", "reason": "Profile 声明了它,但根目录没有这个文件",
358
- "impact": "只能用 agenthelm project 打开",
359
- "next": [{"label": "按模板重新生成", "action": "fix:update-content"}]})
367
+ findings.append({"id": "update-content", "level": "suggest", "area": _("入口"),
368
+ "title": _("启动器 {0} 不存在").format(launcher), "reason": _("Profile 声明了它,但根目录没有这个文件"),
369
+ "impact": _("只能用 agenthelm project 打开"),
370
+ "next": [{"label": _("按模板重新生成"), "action": "fix:update-content"}]})
360
371
  elif not os.access(path, os.X_OK):
361
- findings.append({"id": "launcher-mode", "level": "suggest", "area": "入口",
362
- "title": f"启动器 {launcher} 没有执行权限", "reason": "可能是复制或解压时丢了权限",
363
- "impact": f"需要用 sh {launcher} 运行", "next": [{"label": f"运行 chmod +x {launcher}", "action": ""}]})
372
+ findings.append({"id": "launcher-mode", "level": "suggest", "area": _("入口"),
373
+ "title": _("启动器 {0} 没有执行权限").format(launcher), "reason": _("可能是复制或解压时丢了权限"),
374
+ "impact": _("需要用 sh {0} 运行").format(launcher), "next": [{"label": _("运行 chmod +x {0}").format(launcher), "action": ""}]})
364
375
  elif "agenthelm" not in path.read_text(encoding="utf-8", errors="replace"):
365
- findings.append({"id": "launcher-custom", "level": "suggest", "area": "入口",
366
- "title": f"./{launcher} 是项目自己的脚本", "reason": "文件里没有调用 agenthelm",
367
- "impact": f"运行 ./{launcher} 可能打不开本菜单",
368
- "next": [{"label": f"在脚本里调用 agenthelm project --project <项目根目录> \"$@\","
369
- f"或用 fix add-entry --accept {launcher} 换成模板(先备份)", "action": ""}]})
376
+ findings.append({"id": "launcher-custom", "level": "suggest", "area": _("入口"),
377
+ "title": _("./{0} 是项目自己的脚本").format(launcher), "reason": _("文件里没有调用 agenthelm"),
378
+ "impact": _("运行 ./{0} 可能打不开本菜单").format(launcher),
379
+ "next": [{"label": _("在脚本里调用 agenthelm project --project <项目根目录> \"$@\",或用 fix add-entry --accept {0} 换成模板(先备份)").format(launcher), "action": ""}]})
370
380
  elif self.via_launcher is not None and self.via_launcher < LAUNCHER_API:
371
- findings.append({"id": "update-content", "level": "update", "area": "入口", "title": "启动器有新版本",
372
- "reason": f"当前启动器接口 {self.via_launcher},模板为 {LAUNCHER_API}",
373
- "impact": "旧启动器仍能用", "next": [{"label": "更新项目模板", "action": "fix:update-content"}]})
381
+ findings.append({"id": "update-content", "level": "update", "area": _("入口"), "title": _("启动器有新版本"),
382
+ "reason": _("当前启动器接口 {0},模板为 {1}").format(self.via_launcher, LAUNCHER_API),
383
+ "impact": _("旧启动器仍能用"), "next": [{"label": _("更新项目模板"), "action": "fix:update-content"}]})
374
384
  else:
375
- ok.append(f"项目入口 ./{launcher}")
385
+ ok.append(_("项目入口 ./{0}").format(launcher))
376
386
  if not _readme_mentions(self):
377
- findings.append({"id": "readme-entry", "level": "suggest", "area": "入口", "title": "README 没有提到人用入口",
378
- "reason": f"README.md 里没有 ./{launcher}", "impact": "新接手的人可能不知道有这个菜单",
379
- "next": [{"label": "在 README 末尾追加「怎样使用」(带标记,可删)", "action": "fix:add-entry"}]})
387
+ findings.append({"id": "readme-entry", "level": "suggest", "area": _("入口"), "title": _("README 没有提到人用入口"),
388
+ "reason": _("README.md 里没有 ./{0}").format(launcher), "impact": _("新接手的人可能不知道有这个菜单"),
389
+ "next": [{"label": _("在 README 末尾追加「怎样使用」(带标记,可删)"), "action": "fix:add-entry"}]})
380
390
 
381
391
  def _check_index(self, findings: list[dict], ok: list[str]) -> None:
382
392
  state = self.index_state()
383
393
  if state["status"] == "broken":
384
- findings.append({"id": "rebuild-index", "level": "must", "area": "资料", "title": "资料索引损坏",
385
- "reason": "用户缓存里的索引无法读取或格式不符", "impact": "找资料会先尝试重建;项目文件没有受影响",
386
- "next": [{"label": "重建索引(只改用户缓存)", "action": "fix:rebuild-index"}]})
394
+ findings.append({"id": "rebuild-index", "level": "must", "area": _("资料"), "title": _("资料索引损坏"),
395
+ "reason": _("用户缓存里的索引无法读取或格式不符"), "impact": _("找资料会先尝试重建;项目文件没有受影响"),
396
+ "next": [{"label": _("重建索引(只改用户缓存)"), "action": "fix:rebuild-index"}]})
387
397
  return
388
398
  if state["status"] == "missing":
389
- ok.append("资料索引(尚未建立,首次查找时建立)")
399
+ ok.append(_("资料索引(尚未建立,首次查找时建立)"))
390
400
  return
391
401
  try:
392
402
  report = assets.check(self.assets_project(), limit=5)
393
403
  except (assets.AssetError, EntryError) as exc:
394
- findings.append({"id": "rebuild-index", "level": "must", "area": "资料", "title": "资料巡检失败",
395
- "reason": str(exc), "impact": "找资料可能不完整",
396
- "next": [{"label": "重建索引(只改用户缓存)", "action": "fix:rebuild-index"}]})
404
+ findings.append({"id": "rebuild-index", "level": "must", "area": _("资料"), "title": _("资料巡检失败"),
405
+ "reason": str(exc), "impact": _("找资料可能不完整"),
406
+ "next": [{"label": _("重建索引(只改用户缓存)"), "action": "fix:rebuild-index"}]})
397
407
  return
398
408
  broken = report["broken"].get("real-broken", [])
399
409
  count = report["broken_counts"].get("real-broken", 0)
400
410
  if count:
401
411
  first = broken[0]
402
- findings.append({"id": "broken-links", "level": "suggest", "area": "资料", "title": f"资料里有 {count} 处断链",
403
- "reason": f"例如 {first['src']} 引用的 {first['raw']} 不存在",
404
- "impact": "打开这些文件时链接失效;不影响其他资料",
405
- "next": [{"label": "打开第一处修正", "action": f"open:{first['src']}"}]})
412
+ findings.append({"id": "broken-links", "level": "suggest", "area": _("资料"), "title": _("资料里有 {0} 处断链").format(count),
413
+ "reason": _("例如 {0} 引用的 {1} 不存在").format(first['src'], first['raw']),
414
+ "impact": _("打开这些文件时链接失效;不影响其他资料"),
415
+ "next": [{"label": _("打开第一处修正"), "action": f"open:{first['src']}"}]})
406
416
  unclaimed = sum(len(paths) for paths in report["unclaimed"].values())
407
- ok.append(f"资料索引({report['totals']['files']} 个文件,{hhmm(report['built_at'])} 更新"
408
- + (f";{unclaimed} 份交付物未被事项引用" if unclaimed else "") + ")")
417
+ ok.append(_("资料索引({0} 个文件,{1} 更新").format(report['totals']['files'], hhmm(report['built_at']))
418
+ + (_(";{0} 份交付物未被事项引用").format(unclaimed) if unclaimed else "") + _(")"))
409
419
 
410
420
  def _check_items(self, findings: list[dict], ok: list[str]) -> None:
411
421
  try:
412
422
  data = self.items()
413
423
  except EntryError as exc:
414
- findings.append({"id": "items-unavailable", "level": "unavailable", "area": "事项", "title": "看进展不可用",
415
- "reason": str(exc), "impact": "其他功能不受影响",
424
+ findings.append({"id": "items-unavailable", "level": "unavailable", "area": _("事项"), "title": _("看进展不可用"),
425
+ "reason": str(exc), "impact": _("其他功能不受影响"),
416
426
  "next": [{"label": step, "action": ""} for step in exc.next_steps[:1]]})
417
427
  return
418
428
  if data["invalid"]:
419
429
  first = data["invalid"][0]
420
- findings.append({"id": "invalid-items", "level": "suggest", "area": "事项",
421
- "title": f"{len(data['invalid'])} 个事项记录读不出来",
422
- "reason": f"{first['path']}:{first['error']}", "impact": "这些事项不会出现在「看进展」里",
423
- "next": [{"label": "打开记录修正格式", "action": f"open:{first['path']}"}]})
430
+ findings.append({"id": "invalid-items", "level": "suggest", "area": _("事项"),
431
+ "title": _("{0} 个事项记录读不出来").format(len(data['invalid'])),
432
+ "reason": _("{0}:{1}").format(first['path'], first['error']), "impact": _("这些事项不会出现在「看进展」里"),
433
+ "next": [{"label": _("打开记录修正格式"), "action": f"open:{first['path']}"}]})
424
434
  else:
425
- ok.append(f"事项记录({len(data['items'])} 个)")
435
+ ok.append(_("事项记录({0} 个)").format(len(data['items'])))
426
436
 
427
437
  def _check_memory(self, findings: list[dict], ok: list[str]) -> None:
428
438
  memory = self.profile.get("memory")
@@ -441,11 +451,80 @@ class RealProvider:
441
451
  problems = report.get("problems") or report.get("issues") or []
442
452
  if problems:
443
453
  first = problems[0]
444
- findings.append({"id": "memory", "level": "suggest", "area": "记忆", "title": f"记忆条目有 {len(problems)} 个问题",
454
+ findings.append({"id": "memory", "level": "suggest", "area": _("记忆"), "title": _("记忆条目有 {0} 个问题").format(len(problems)),
445
455
  "reason": str(first.get("message") or first.get("detail") or first)[:160],
446
- "impact": "只影响 AI Agent 召回记忆", "next": [{"label": "在 Agent 会话中运行记忆检查并处理", "action": ""}]})
456
+ "impact": _("只影响 AI Agent 召回记忆"), "next": [{"label": _("在 Agent 会话中运行记忆检查并处理"), "action": ""}]})
447
457
  else:
448
- ok.append("记忆条目")
458
+ ok.append(_("记忆条目"))
459
+
460
+ def _check_sop(self, findings: list[dict], ok: list[str]) -> None:
461
+ try:
462
+ sops = sop_tool.load_all(self.root)
463
+ if not sops:
464
+ return
465
+ defaults = sop_tool.read_defaults(self.root)
466
+ results = sop_tool.check_all(sops, defaults, self.root)
467
+ runs, _unused = sop_tool.last_runs(self.root)
468
+ due = [info for sop in sops if not sop["shadowed"] and (info := sop_tool.due_info(sop, runs, sop_tool.today())) and info["due"]]
469
+ except (sop_tool.SopError, OSError) as exc:
470
+ findings.append({"id": "sop", "level": "suggest", "area": _("流程"), "title": _("流程(SOP)读取失败"),
471
+ "reason": str(exc)[:160], "impact": _("AI Agent 和本入口都读不到流程"),
472
+ "next": [{"label": _("运行 sop validate 查看原因"), "action": ""}]})
473
+ return
474
+ broken = [result for result in results if not result["valid"]]
475
+ if broken:
476
+ first = next(item for result in broken for item in result["issues"] if item["level"] == "error")
477
+ findings.append({"id": "sop", "level": "suggest", "area": _("流程"), "title": _("{0} 个流程有错误").format(len(broken)),
478
+ "reason": _("{0}:{1}").format(broken[0]['id'], first['message'])[:160],
479
+ "impact": _("有错误的 active 流程仍会被索引,Agent 可能照着不完整的步骤执行"),
480
+ "next": [{"label": _("运行 sop validate 查看全部问题"), "action": ""}]})
481
+ else:
482
+ active = sum(1 for sop in sops if sop["meta"].get("status") == "active" and not sop["shadowed"])
483
+ ok.append(_("流程({0} 个,{1} 个已启用)").format(len(sops), active))
484
+ if due:
485
+ names = _("、").join(_("{0}({1},上次 {2})").format(info['id'], info['schedule'], info['last_run'] or _('从未')) for info in due)
486
+ findings.append({"id": "sop-due", "level": "suggest", "area": _("流程"), "title": _("{0} 个流程已到期").format(len(due)),
487
+ "reason": names[:160], "impact": _("只是提醒:到期不会自动执行"),
488
+ "next": [{"label": _("让 Agent 按它执行,或运行 sop run <id>"), "action": ""}]})
489
+
490
+ def _check_private(self, findings: list[dict], ok: list[str]) -> None:
491
+ """私有目录:内容默认不进 git;用到它的事项应标为 private。"""
492
+ dirs = private_paths.declared(self.root)
493
+ if not dirs:
494
+ return
495
+ for item in dirs:
496
+ state = private_paths.git_state(self.root, item)
497
+ if state["ignored"] is False:
498
+ findings.append({"id": f"private-ignore:{item}", "level": "suggest", "area": _("私有目录"),
499
+ "title": _("{0}/ 没有被 git 忽略").format(item), "reason": _("私有目录的内容默认不应进入 git"),
500
+ "impact": _("git add 时可能把私有内容一起提交"),
501
+ "next": [{"label": _("运行 sop private --apply,在 {0}/ 里创建 .gitignore(先预览)").format(item), "action": ""}]})
502
+ elif state["tracked"]:
503
+ findings.append({"id": f"private-tracked:{item}", "level": "suggest", "area": _("私有目录"),
504
+ "title": _("{0}/ 下有 {1} 个文件已被 git 跟踪").format(item, len(state['tracked'])),
505
+ "reason": _("例如 {0}").format(state['tracked'][0]), "impact": _("它们会随提交一起上传;.gitignore 对已跟踪的文件无效"),
506
+ "next": [{"label": _("确认后运行 git rm -r --cached {0} 取消跟踪(历史里的内容仍在)").format(item), "action": ""}]})
507
+ else:
508
+ ok.append(_("私有目录 {0}/(").format(item) + (_("已被 git 忽略") if state["ignored"] else _("不在 git 仓库里")) + _(";读取前须经你确认)"))
509
+ loose = []
510
+ try:
511
+ for directory in case_tool.Project(self.root).case_dirs():
512
+ data, _unused = case_tool.read_case(directory / "CASE.md")
513
+ refs = [*(data.get("deliverables") or []), *(data.get("evidence") or [])]
514
+ if data.get("sensitivity") != "private" and any(
515
+ private_paths.is_private(self.root, value, dirs) or private_paths.is_private(self.root, str(directory / value), dirs)
516
+ for value in refs):
517
+ loose.append(data.get("id", directory.name))
518
+ except (case_tool.CaseError, OSError, UnicodeDecodeError):
519
+ return
520
+ if loose:
521
+ findings.append({"id": "private-cases", "level": "suggest", "area": _("私有目录"),
522
+ "title": _("{0} 个事项用到了私有目录,但没有标为 private").format(len(loose)), "reason": _("、").join(loose[:3]),
523
+ "impact": _("按约定,用到私有目录的事项应标为 private"),
524
+ "next": [{"label": _("运行 case.py update <事项> --sensitivity private"), "action": ""}]})
525
+
526
+ def sop(self, argv: list[str]) -> tuple[int, dict, list[str]]:
527
+ return sop_call(argv, self.root)
449
528
 
450
529
  # -------------------------------------------------------------- maintenance and writes
451
530
 
@@ -455,6 +534,9 @@ class RealProvider:
455
534
  def apply_fix(self, plan: dict, choices: dict[str, str]) -> dict:
456
535
  return project_maintain.apply(self, plan, choices)
457
536
 
537
+ def accept_current(self, reason: str, apply: bool) -> dict:
538
+ return project_maintain.accept_current(self, reason, apply)
539
+
458
540
  def decide(self, skip: list[str], unskip: list[str], reason: str, apply: bool) -> dict:
459
541
  return project_maintain.decide_ids(self, skip, unskip, reason, apply)
460
542