@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.
- package/README.md +1 -1
- package/README.zh-CN.md +2 -0
- 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/hooks/hooks.json +32 -0
- package/runtime/plugins/agent-pack/plugin.json +1 -1
- package/runtime/plugins/agent-pack/references/local-only.md +126 -0
- package/runtime/plugins/agent-pack/references/nudge.en.md +58 -0
- package/runtime/plugins/agent-pack/references/nudge.md +58 -0
- package/runtime/plugins/agent-pack/runtime/agent_pack_nudge.py +613 -0
- package/runtime/plugins/agent-pack/runtime/agenthelm.py +1271 -221
- package/runtime/plugins/agent-pack/runtime/agenthelm_runtime.py +114 -65
- package/runtime/plugins/agent-pack/runtime/i18n_agent_pack.py +78 -0
- package/runtime/plugins/agent-pack/runtime/local_only.py +1132 -0
- package/runtime/plugins/agent-pack/runtime/locale/en.json +569 -0
- package/runtime/plugins/agent-pack/runtime/mcp_server.py +25 -0
- package/runtime/plugins/agent-pack/runtime/nudge_text.py +127 -0
- package/runtime/plugins/agent-pack/runtime/user_settings.py +275 -0
- package/runtime/plugins/agent-pack/skills/agent-pack/SKILL.md +11 -1
- package/runtime/plugins/agents-init/.codex-plugin/plugin.json +1 -1
- package/runtime/plugins/agents-init/content.json +4 -4
- package/runtime/plugins/agents-init/plugin.json +1 -1
- package/runtime/plugins/agents-init/skills/agents-init/AGENT.template.md +141 -5
- package/runtime/plugins/agents-init/skills/agents-init/SKILL.md +41 -8
- package/runtime/plugins/agents-init/skills/agents-init/project.schema.json +408 -80
- package/runtime/plugins/agents-init/skills/agents-init/scripts/adopt.py +615 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/baseline.py +221 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/i18n_init.py +78 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/init_project.py +748 -159
- package/runtime/plugins/agents-init/skills/agents-init/scripts/locale/en.json +289 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/merge3.py +149 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/regions.py +99 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/scaffold.py +594 -90
- package/runtime/plugins/agents-init/skills/agents-init/skeleton.json +2 -0
- 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/references/inbox.en.md +48 -0
- package/runtime/plugins/opinion-manager/references/inbox.md +48 -0
- package/runtime/plugins/opinion-manager/runtime/context.py +31 -26
- package/runtime/plugins/opinion-manager/runtime/i18n_opinion.py +78 -0
- package/runtime/plugins/opinion-manager/runtime/inbox.py +398 -0
- package/runtime/plugins/opinion-manager/runtime/inbox_text.py +114 -0
- package/runtime/plugins/opinion-manager/runtime/lifecycle.py +45 -44
- package/runtime/plugins/opinion-manager/runtime/locale/en.json +193 -0
- package/runtime/plugins/opinion-manager/runtime/opinion_manager.py +55 -50
- package/runtime/plugins/opinion-manager/runtime/versioned.py +90 -85
- package/runtime/plugins/opinion-manager/skills/opinion-manager/SKILL.md +15 -2
- package/runtime/plugins/project-orchestrator/.codex-plugin/plugin.json +1 -1
- package/runtime/plugins/project-orchestrator/content.json +30 -3
- package/runtime/plugins/project-orchestrator/plugin.json +1 -1
- package/runtime/plugins/project-orchestrator/references/case-workspaces.md +9 -1
- package/runtime/plugins/project-orchestrator/references/case.schema.json +1 -0
- package/runtime/plugins/project-orchestrator/references/sop-interview.md +83 -0
- package/runtime/plugins/project-orchestrator/references/sop.md +156 -0
- package/runtime/plugins/project-orchestrator/runtime/assets.py +52 -57
- package/runtime/plugins/project-orchestrator/runtime/case.py +139 -80
- package/runtime/plugins/project-orchestrator/runtime/case_structure.py +71 -0
- package/runtime/plugins/project-orchestrator/runtime/case_workspace.py +47 -46
- package/runtime/plugins/project-orchestrator/runtime/i18n_orchestrator.py +78 -0
- package/runtime/plugins/project-orchestrator/runtime/locale/en.json +1450 -0
- package/runtime/plugins/project-orchestrator/runtime/memory.py +45 -45
- package/runtime/plugins/project-orchestrator/runtime/private_paths.py +119 -0
- package/runtime/plugins/project-orchestrator/runtime/project_base.py +37 -19
- package/runtime/plugins/project-orchestrator/runtime/project_cli.py +307 -195
- package/runtime/plugins/project-orchestrator/runtime/project_demo.py +130 -48
- package/runtime/plugins/project-orchestrator/runtime/project_maintain.py +328 -221
- package/runtime/plugins/project-orchestrator/runtime/project_menu.py +167 -89
- package/runtime/plugins/project-orchestrator/runtime/project_real.py +187 -105
- package/runtime/plugins/project-orchestrator/runtime/project_write.py +58 -55
- package/runtime/plugins/project-orchestrator/runtime/sop.py +1670 -0
- package/runtime/plugins/project-orchestrator/runtime/sop_structure.py +226 -0
- package/runtime/plugins/project-orchestrator/runtime/wf.py +74 -70
- package/runtime/plugins/project-orchestrator/skills/project-orchestrator/SKILL.md +22 -0
- package/runtime/plugins/project-orchestrator/sop-templates/blank/SOP.en.md +57 -0
- package/runtime/plugins/project-orchestrator/sop-templates/blank/SOP.md +57 -0
- package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/SOP.en.md +77 -0
- package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/SOP.md +77 -0
- package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/templates/digest.en.md +11 -0
- package/runtime/plugins/project-orchestrator/sop-templates/knowledge-digest/templates/digest.md +11 -0
- package/runtime/plugins/project-orchestrator/sop-templates/video-to-transcript/SOP.en.md +87 -0
- package/runtime/plugins/project-orchestrator/sop-templates/video-to-transcript/SOP.md +87 -0
- package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/SOP.en.md +75 -0
- package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/SOP.md +75 -0
- package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/templates/review.en.md +11 -0
- package/runtime/plugins/project-orchestrator/sop-templates/weekly-review/templates/review.md +12 -0
- package/runtime/plugins/project-orchestrator/templates/CASE.en.md +39 -0
- package/runtime/plugins/agents-init/skills/agents-init/scripts/test_init_project.py +0 -678
- package/runtime/plugins/agents-init/skills/agents-init/scripts/test_scaffold.py +0 -551
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""项目入口:不需要 AI Agent 的项目自助菜单与命令。
|
|
2
|
+
"""项目入口:不需要 AI Agent 的项目自助菜单与命令。"""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Callable
|
|
10
|
+
|
|
11
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
12
|
+
import project_demo # noqa: E402
|
|
13
|
+
from project_base import LAUNCHER_API, RUNTIME_API, EntryError # noqa: E402
|
|
14
|
+
from project_demo import DemoProvider # noqa: E402
|
|
15
|
+
from wf import S, clip, display_width, term_width # noqa: E402
|
|
16
|
+
from i18n_orchestrator import _, N_ # noqa: E402
|
|
17
|
+
from i18n_orchestrator import _ # noqa: E402
|
|
18
|
+
|
|
19
|
+
USAGE = N_("""项目入口:不需要 AI Agent 的项目自助菜单与命令。
|
|
3
20
|
|
|
4
21
|
agenthelm project 交互菜单(终端里);非终端时打印概览后退出,不等待输入
|
|
5
22
|
agenthelm project find <词…> 找资料:关键词、日期(2025-12、10月)、--type、--in;--open N 打开第 N 项
|
|
@@ -9,12 +26,15 @@
|
|
|
9
26
|
agenthelm project show <事项> 事项详情:编号、旧编号、别名或标题片段都可以
|
|
10
27
|
agenthelm project guide 项目指南
|
|
11
28
|
agenthelm project health 检查项目与环境(含脚手架是否与最新版一致);有必须处理的项时退出码为 1
|
|
12
|
-
agenthelm project fix [项…] 修复与更新:默认只预览,--apply 执行;--keep / --accept 选择定制文件
|
|
29
|
+
agenthelm project fix [项…] 修复与更新:默认只预览,--apply 执行;--keep / --accept / --append 选择定制文件
|
|
13
30
|
agenthelm project fix add-skeleton [路径…] 按模板补上缺少的骨架文件(已有文件不动)
|
|
14
31
|
agenthelm project fix profile [字段…] 只改所选 Profile 字段,预览里有 diff
|
|
32
|
+
agenthelm project fix --accept-current --reason … 把当前全部脚手架差异一次性记为“保留现状”(默认预览,--apply 写入)
|
|
15
33
|
agenthelm project fix --skip <ID> --reason … 永久跳过某个发现(记入随项目同步的决定文件);--unskip <ID> 撤销
|
|
16
34
|
agenthelm project record <事项|new> 记录事项:默认只预览,--apply 写入
|
|
17
35
|
agenthelm project tools [工具] 项目自行声明的工具;--run --apply 执行
|
|
36
|
+
agenthelm project sop <子命令> 流程(SOP):list / index / show / new / interview / defaults / preflight /
|
|
37
|
+
activate / run / step / status / due / validate …;写入默认只预览,--apply 执行
|
|
18
38
|
agenthelm project capabilities 各项能力当前是否可用、为什么
|
|
19
39
|
|
|
20
40
|
项目根目录的启动器(缺省 ./menu)等同于 agenthelm project --project <项目根目录>。
|
|
@@ -25,21 +45,8 @@ index-broken|offline|runtime-old|conflict;演示结果都标注「演示」,
|
|
|
25
45
|
退出码:0 成功;1 没有结果或有必须处理的项;2 用法错误(含 --skip 了现在不存在的发现 ID);
|
|
26
46
|
3 运行时与项目入口不兼容;4 能力当前不可用(含决定文件损坏);5 写入冲突(别人刚改过,
|
|
27
47
|
含决定文件刚被另一台机器同步更新);6 执行失败;130 中断。
|
|
28
|
-
|
|
29
|
-
"""
|
|
30
|
-
from __future__ import annotations
|
|
31
|
-
|
|
32
|
-
import argparse
|
|
33
|
-
import json
|
|
34
|
-
import sys
|
|
35
|
-
from pathlib import Path
|
|
36
|
-
from typing import Any, Callable
|
|
37
|
-
|
|
38
|
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
39
|
-
import project_demo # noqa: E402
|
|
40
|
-
from project_base import LAUNCHER_API, RUNTIME_API, EntryError # noqa: E402
|
|
41
|
-
from project_demo import DemoProvider # noqa: E402
|
|
42
|
-
from wf import S, clip, display_width, term_width # noqa: E402
|
|
48
|
+
脚手架差异只算“建议处理”或“信息”,不会让 health 退出码变成 1(只有“必须处理”的项才会)。
|
|
49
|
+
""")
|
|
43
50
|
|
|
44
51
|
Provider = Any # DemoProvider 或 project_real.RealProvider:方法与返回结构相同
|
|
45
52
|
# 经 ``agenthelm project`` 启动时,agent-pack 把自己的模块放在这里,供检查与更新使用。
|
|
@@ -52,13 +59,13 @@ EXIT_BY_CODE = {"usage": EXIT_USAGE, "not-found": EXIT_ATTENTION, "ambiguous": E
|
|
|
52
59
|
"index-broken": EXIT_UNAVAILABLE, "not-a-project": EXIT_UNAVAILABLE,
|
|
53
60
|
"profile-invalid": EXIT_UNAVAILABLE, "offline": EXIT_UNAVAILABLE,
|
|
54
61
|
"conflict": EXIT_CONFLICT, "failed": EXIT_FAILED}
|
|
55
|
-
GROUPS = (("active", "进行中"), ("waiting", "等待"), ("captured", "待澄清"), ("suspended", "挂起"),
|
|
56
|
-
("done", "已完成"), ("abandoned", "放弃"), ("other", "其他状态"))
|
|
62
|
+
GROUPS = (("active", N_("进行中")), ("waiting", N_("等待")), ("captured", N_("待澄清")), ("suspended", N_("挂起")),
|
|
63
|
+
("done", N_("已完成")), ("abandoned", N_("放弃")), ("other", N_("其他状态")))
|
|
57
64
|
GROUP_LABEL = dict(GROUPS)
|
|
58
65
|
CLOSED = {"done", "abandoned"}
|
|
59
|
-
LEVELS = (("must", "必须处理"), ("suggest", "建议处理"), ("update", "可选更新"), ("unavailable", "当前不可用"))
|
|
66
|
+
LEVELS = (("must", N_("必须处理")), ("suggest", N_("建议处理")), ("update", N_("可选更新")), ("info", N_("信息")), ("unavailable", N_("当前不可用")))
|
|
60
67
|
LEVEL_LABEL = dict(LEVELS)
|
|
61
|
-
DEMO_BANNER = "【演示数据 · 不读写真实文件】"
|
|
68
|
+
DEMO_BANNER = N_("【演示数据 · 不读写真实文件】")
|
|
62
69
|
|
|
63
70
|
|
|
64
71
|
def hhmm(value: str | None) -> str:
|
|
@@ -84,20 +91,20 @@ def open_provider(args: argparse.Namespace) -> Provider:
|
|
|
84
91
|
def check_entry_api(provider: Provider) -> None:
|
|
85
92
|
low, high = RUNTIME_API
|
|
86
93
|
if provider.entry_api > high:
|
|
87
|
-
raise EntryError(
|
|
94
|
+
raise EntryError(_("这个项目的入口需要接口版本 {0},当前 agenthelm 运行时只支持到 {1}").format(provider.entry_api, high),
|
|
88
95
|
"runtime-incompatible",
|
|
89
|
-
["更新运行时:agenthelm runtime update --apply(联网)",
|
|
90
|
-
"离线:agenthelm runtime install --source <新版发布包> --apply,见 INSTALL.md「离线安装」",
|
|
91
|
-
"项目文件没有被改动"])
|
|
96
|
+
[_("更新运行时:agenthelm runtime update --apply(联网)"),
|
|
97
|
+
_("离线:agenthelm runtime install --source <新版发布包> --apply,见 INSTALL.md「离线安装」"),
|
|
98
|
+
_("项目文件没有被改动")])
|
|
92
99
|
if provider.entry_api < low:
|
|
93
|
-
raise EntryError(
|
|
94
|
-
"runtime-incompatible", ["更新项目入口:agenthelm update --only content,按提示保留或采用"])
|
|
100
|
+
raise EntryError(_("这个项目的入口较旧(接口版本 {0}),当前运行时最低支持 {1}").format(provider.entry_api, low),
|
|
101
|
+
"runtime-incompatible", [_("更新项目入口:agenthelm update --only content,按提示保留或采用")])
|
|
95
102
|
|
|
96
103
|
|
|
97
104
|
# ---------------------------------------------------------------- renderers (text)
|
|
98
105
|
|
|
99
106
|
def header(provider: Provider, title: str) -> list[str]:
|
|
100
|
-
banner = S.yellow(DEMO_BANNER) if provider.simulated else ""
|
|
107
|
+
banner = S.yellow(_(DEMO_BANNER)) if provider.simulated else ""
|
|
101
108
|
return [f"{S.bold(provider.name)} · {title} {banner}".rstrip()]
|
|
102
109
|
|
|
103
110
|
|
|
@@ -105,59 +112,61 @@ def render_overview(provider: Provider) -> list[str]:
|
|
|
105
112
|
overview = provider.overview()
|
|
106
113
|
index = overview["index"]
|
|
107
114
|
if index["status"] == "broken":
|
|
108
|
-
index_text = S.red("资料索引损坏(可重建)")
|
|
115
|
+
index_text = S.red(_("资料索引损坏(可重建)"))
|
|
109
116
|
elif index["status"] == "missing":
|
|
110
|
-
index_text = "资料索引尚未建立(首次查找时建立)"
|
|
117
|
+
index_text = _("资料索引尚未建立(首次查找时建立)")
|
|
111
118
|
else:
|
|
112
|
-
index_text =
|
|
119
|
+
index_text = _("资料 {0} 个(索引 {1})").format(index['file_count'], hhmm(index['built_at']))
|
|
113
120
|
counts = overview["items"]
|
|
114
|
-
items_text = " · ".join(f"{label} {counts[key]}" for key, label in GROUPS if counts.get(key) and key not in CLOSED)
|
|
121
|
+
items_text = " · ".join(f"{_(label)} {counts[key]}" for key, label in GROUPS if counts.get(key) and key not in CLOSED)
|
|
115
122
|
health = overview["health"]
|
|
116
|
-
health_text = " · ".join(
|
|
123
|
+
health_text = " · ".join(_("{0} 项{1}").format(health[key], _(label)) for key, label in LEVELS if health.get(key)) or _("未发现问题")
|
|
117
124
|
if not overview.get("health_checked", True):
|
|
118
|
-
health_text = "尚未检查(首页第 4 项)"
|
|
119
|
-
banner = S.yellow(DEMO_BANNER) if provider.simulated else ""
|
|
125
|
+
health_text = _("尚未检查(首页第 4 项)")
|
|
126
|
+
banner = S.yellow(_(DEMO_BANNER)) if provider.simulated else ""
|
|
120
127
|
return [f"{S.bold(S.cyan(overview['name']))} {S.dim(overview['kind_label'])} {banner}".rstrip(),
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
_("{0} · 事项 {1}").format(index_text, items_text or _('暂无')),
|
|
129
|
+
_("检查:{0}").format(health_text)]
|
|
123
130
|
|
|
124
131
|
|
|
125
132
|
def render_find(result: dict) -> list[str]:
|
|
126
133
|
width = term_width()
|
|
127
134
|
lines = []
|
|
128
135
|
if not result["results"]:
|
|
129
|
-
return [S.yellow("没有找到。") + S.dim("试试更短的词、去掉日期,或先在「看进展」里找到事项。")]
|
|
136
|
+
return [S.yellow(_("没有找到。")) + S.dim(_("试试更短的词、去掉日期,或先在「看进展」里找到事项。"))]
|
|
130
137
|
for number, item in enumerate(result["results"], 1):
|
|
131
138
|
label = item["title"] or item["name"]
|
|
132
139
|
date = hhmm(item["modified"])
|
|
133
140
|
left = f" {S.bold(S.cyan(f'{number:>2}'))} {S.bold(clip(label, width - 24))}"
|
|
134
141
|
lines.append(pad(left, width - len(date)) + S.dim(date))
|
|
135
|
-
owner = item["case_title"] or ("项目根目录" if item["container"] == "project" else
|
|
136
|
-
status = GROUP_LABEL.get(item["status"], item["status"]) if item["status"] else ""
|
|
137
|
-
owner_text =
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
owner = item["case_title"] or (_("项目根目录") if item["container"] == "project" else _("目录 {0}/").format(item['container']))
|
|
143
|
+
status = _(GROUP_LABEL.get(item["status"], item["status"])) if item["status"] else ""
|
|
144
|
+
owner_text = _("{0}({1})").format(owner, status) if status else owner
|
|
145
|
+
if item.get("sensitivity", "shared") != "shared":
|
|
146
|
+
owner_text += _("(私密)")
|
|
147
|
+
refs = _(" · 被引用 {0} 处").format(item['referenced_by']) if item["referenced_by"] else ""
|
|
148
|
+
lines.append(_(" 归属:{0}{1}").format(clip(owner_text, width - 30), refs))
|
|
140
149
|
lines.append(S.dim(f" {clip(item['path'], width - 6)}"))
|
|
141
150
|
if item["versions"]:
|
|
142
|
-
lines.append(S.dim(
|
|
151
|
+
lines.append(S.dim(_(" └ 同系列另有 {0} 个版本(v{1} 查看)").format(len(item['versions']), number)))
|
|
143
152
|
index = result["index"]
|
|
144
|
-
lines.append(S.dim(
|
|
153
|
+
lines.append(S.dim(_("共 {0} 项 · 索引 {1},{2} 个文件").format(result['total'], hhmm(index['built_at']), index['file_count'])))
|
|
145
154
|
return lines
|
|
146
155
|
|
|
147
156
|
|
|
148
157
|
def render_versions(item: dict) -> list[str]:
|
|
149
158
|
lines = [S.bold(item["title"] or item["name"]),
|
|
150
|
-
f" {hhmm(item['modified'])} {item['path']} {S.green('最新')}"]
|
|
159
|
+
f" {hhmm(item['modified'])} {item['path']} {S.green(_('最新'))}"]
|
|
151
160
|
lines += [f" {hhmm(version['modified'])} {version['path']}" for version in item["versions"]]
|
|
152
161
|
return lines
|
|
153
162
|
|
|
154
163
|
|
|
155
164
|
def render_refs(result: dict) -> list[str]:
|
|
156
165
|
lines = [S.bold(result["path"])]
|
|
157
|
-
lines += [S.cyan(" 被引用:")] + [f" ← {path}" for path in result["inbound"]] if result["inbound"] \
|
|
158
|
-
else [S.dim(" 没有被其他资料或事项引用")]
|
|
166
|
+
lines += [S.cyan(_(" 被引用:"))] + [f" ← {path}" for path in result["inbound"]] if result["inbound"] \
|
|
167
|
+
else [S.dim(_(" 没有被其他资料或事项引用"))]
|
|
159
168
|
if result["outbound"]:
|
|
160
|
-
lines += [S.cyan(" 引用了:")] + [f" → {path}" for path in result["outbound"]]
|
|
169
|
+
lines += [S.cyan(_(" 引用了:"))] + [f" → {path}" for path in result["outbound"]]
|
|
161
170
|
return lines
|
|
162
171
|
|
|
163
172
|
|
|
@@ -171,24 +180,24 @@ def render_items(result: dict, *, expand_closed: bool = False) -> tuple[list[str
|
|
|
171
180
|
if not members:
|
|
172
181
|
continue
|
|
173
182
|
if key in CLOSED and not expand_closed:
|
|
174
|
-
lines.append(S.dim(
|
|
183
|
+
lines.append(S.dim(_("{0}({1}) 输入 all 展开").format(_(label), len(members))))
|
|
175
184
|
continue
|
|
176
|
-
lines.append(S.bold(
|
|
185
|
+
lines.append(S.bold(_("{0}({1})").format(_(label), len(members))))
|
|
177
186
|
for item in members:
|
|
178
187
|
numbered.append(item)
|
|
179
188
|
date = hhmm(item["updated_at"])
|
|
180
189
|
left = f" {S.bold(S.cyan(f'{len(numbered):>2}'))} {clip(item['title'], 26)}"
|
|
181
190
|
if item["waiting_for"]:
|
|
182
|
-
hint =
|
|
191
|
+
hint = _("等待:{0}").format(item['waiting_for'])
|
|
183
192
|
elif item["next_action"] and key not in CLOSED:
|
|
184
|
-
hint =
|
|
193
|
+
hint = _("下一步:{0}").format(item['next_action'])
|
|
185
194
|
else:
|
|
186
195
|
hint = (item["last_record"] or {}).get("text", "") or item["goal"]
|
|
187
196
|
line = pad(left, 36) + S.dim(clip(hint, width - 52))
|
|
188
197
|
lines.append(pad(line, width - len(date)) + S.dim(date))
|
|
189
198
|
if not rows:
|
|
190
|
-
lines.append(S.yellow("还没有事项。") + S.dim("可以在「记录事项」里新建第一个。"))
|
|
191
|
-
lines.append(S.dim(
|
|
199
|
+
lines.append(S.yellow(_("还没有事项。")) + S.dim(_("可以在「记录事项」里新建第一个。")))
|
|
200
|
+
lines.append(S.dim(_("来源:{0} · 读取于 {1}").format(result['source'], hhmm(result['read_at']))))
|
|
192
201
|
return lines, numbered
|
|
193
202
|
|
|
194
203
|
|
|
@@ -196,174 +205,207 @@ def render_item(item: dict) -> list[str]:
|
|
|
196
205
|
def row(label: str, value: str) -> str:
|
|
197
206
|
return f" {pad(label, 12)}{value or S.dim('—')}"
|
|
198
207
|
|
|
199
|
-
group = GROUP_LABEL.get(item["group"], item["status"])
|
|
208
|
+
group = _(GROUP_LABEL.get(item["group"], item["status"]))
|
|
200
209
|
status = item["status"] if item["status"] != item["group"] else group
|
|
201
210
|
last = item["last_record"]
|
|
202
|
-
lines = [f"{S.bold(item['title'])} [{status}]", row("编号", item["id"]), row("目标", item["goal"]),
|
|
203
|
-
row("最后记录", f"{hhmm(last['at'])} {last['text']}" if last else ""),
|
|
204
|
-
row("下一动作", item["next_action"]), row("等待", item["waiting_for"]),
|
|
205
|
-
row("恢复条件", item["resume_when"])]
|
|
211
|
+
lines = [f"{S.bold(item['title'])} [{status}]", row(_("编号"), item["id"]), row(_("目标"), item["goal"]),
|
|
212
|
+
row(_("最后记录"), f"{hhmm(last['at'])} {last['text']}" if last else ""),
|
|
213
|
+
row(_("下一动作"), item["next_action"]), row(_("等待"), item["waiting_for"]),
|
|
214
|
+
row(_("恢复条件"), item["resume_when"])]
|
|
206
215
|
if item["deliverables"]:
|
|
207
|
-
lines.append(row("交付物", f"d1 {item['deliverables'][0]}"))
|
|
216
|
+
lines.append(row(_("交付物"), f"d1 {item['deliverables'][0]}"))
|
|
208
217
|
lines += [f" {pad('', 12)}d{number} {path}" for number, path in enumerate(item["deliverables"][1:], 2)]
|
|
209
218
|
else:
|
|
210
|
-
lines.append(row("交付物", ""))
|
|
219
|
+
lines.append(row(_("交付物"), ""))
|
|
211
220
|
names = [*item["aliases"], *item["legacy_ids"]]
|
|
212
221
|
if names:
|
|
213
|
-
lines.append(row("别名/旧编号", "、".join(names)))
|
|
214
|
-
lines.append(row("权威记录",
|
|
215
|
-
lines.append(S.dim(" 只显示已记录的内容,不推断优先级、重要性或是否完成。"))
|
|
222
|
+
lines.append(row(_("别名/旧编号"), _("、").join(names)))
|
|
223
|
+
lines.append(row(_("权威记录"), _("{0} · 更新于 {1}").format(item['path'], hhmm(item['updated_at']))))
|
|
224
|
+
lines.append(S.dim(_(" 只显示已记录的内容,不推断优先级、重要性或是否完成。")))
|
|
216
225
|
return lines
|
|
217
226
|
|
|
218
227
|
|
|
219
228
|
def render_guide(guide: dict) -> list[str]:
|
|
220
|
-
lines = [S.bold("这个项目做什么"), f" {guide['about']}", "", S.bold("资料在哪")]
|
|
229
|
+
lines = [S.bold(_("这个项目做什么")), f" {guide['about']}", "", S.bold(_("资料在哪"))]
|
|
221
230
|
lines += [f" {pad(label, 18)}{path}" for label, path in guide["where"]]
|
|
222
|
-
lines += ["", S.bold("怎样开始")] + [f" {number}. {step}" for number, step in enumerate(guide["start"], 1)]
|
|
223
|
-
lines += ["", S.bold("常用操作")]
|
|
231
|
+
lines += ["", S.bold(_("怎样开始"))] + [f" {number}. {step}" for number, step in enumerate(guide["start"], 1)]
|
|
232
|
+
lines += ["", S.bold(_("常用操作"))]
|
|
224
233
|
command = guide.get("command") or f"./{guide['launcher']}"
|
|
225
234
|
for goal, menu, cli in guide["examples"]:
|
|
226
|
-
lines.append(
|
|
227
|
-
lines += ["", S.bold("现在能用的功能")]
|
|
235
|
+
lines.append(_(" · {0}:菜单 {1};命令 {2} {3}").format(goal, menu, command, cli))
|
|
236
|
+
lines += ["", S.bold(_("现在能用的功能"))]
|
|
228
237
|
for capability in guide["capabilities"]:
|
|
229
|
-
mark = S.green("可用") if capability["state"] == "available" else S.yellow("不可用")
|
|
230
|
-
offline = ",断网可用" if capability["offline"] else ",需要联网"
|
|
231
|
-
reason =
|
|
238
|
+
mark = S.green(_("可用")) if capability["state"] == "available" else S.yellow(_("不可用"))
|
|
239
|
+
offline = _(",断网可用") if capability["offline"] else _(",需要联网")
|
|
240
|
+
reason = _(":{0}").format(capability['reason']) if capability["reason"] else ""
|
|
232
241
|
lines.append(f" {pad(capability['title'], 16)}{mark}{reason}{S.dim(offline)}")
|
|
233
|
-
lines += ["", S.dim(
|
|
242
|
+
lines += ["", S.dim(_("这份指南在本地生成,断网可读。随时运行 {0} 打开本菜单。").format(command))]
|
|
234
243
|
if guide.get("readme_mentions_entry") is False:
|
|
235
|
-
lines.append(S.yellow("README 还没有提到这个入口:在 README 写一句“运行 " + command + " 打开项目菜单”,新接手的人就能找到。"))
|
|
244
|
+
lines.append(S.yellow(_("README 还没有提到这个入口:在 README 写一句“运行 ") + command + _(" 打开项目菜单”,新接手的人就能找到。")))
|
|
236
245
|
return lines
|
|
237
246
|
|
|
238
247
|
|
|
239
|
-
def render_health(health: dict, show_skipped: bool = False) -> tuple[list[str], list[dict]]:
|
|
248
|
+
def render_health(health: dict, show_skipped: bool = False, details: bool = False) -> tuple[list[str], list[dict]]:
|
|
240
249
|
lines, numbered = [], []
|
|
241
250
|
source = health["update_source"]
|
|
242
251
|
if source["status"] == "online":
|
|
243
|
-
online = "联网检查:最新"
|
|
252
|
+
online = _("联网检查:最新")
|
|
244
253
|
elif source["status"] == "cache":
|
|
245
|
-
online =
|
|
254
|
+
online = _("联网检查:使用 {0} 的缓存(一天内)").format(hhmm(source['cached_at']))
|
|
246
255
|
elif source["status"] == "unavailable":
|
|
247
|
-
online = S.yellow("联网检查:不可用(没有 agent-pack)")
|
|
256
|
+
online = S.yellow(_("联网检查:不可用(没有 agent-pack)"))
|
|
248
257
|
elif source.get("cached_at"):
|
|
249
|
-
online = S.yellow(
|
|
258
|
+
online = S.yellow(_("联网检查:当前离线,使用 {0} 的缓存").format(hhmm(source['cached_at'])))
|
|
250
259
|
else:
|
|
251
|
-
online = S.yellow("联网检查:当前离线,也没有缓存的版本信息")
|
|
252
|
-
lines.append(S.dim(
|
|
260
|
+
online = S.yellow(_("联网检查:当前离线,也没有缓存的版本信息"))
|
|
261
|
+
lines.append(S.dim(_("读取于 {0} · ").format(hhmm(health['read_at']))) + online)
|
|
253
262
|
for key, label in LEVELS:
|
|
254
263
|
members = [finding for finding in health["findings"] if finding["level"] == key]
|
|
255
264
|
if not members:
|
|
256
265
|
continue
|
|
257
266
|
colour = S.red if key == "must" else S.yellow if key in ("suggest", "update") else S.dim
|
|
258
|
-
lines.append(colour(S.bold(
|
|
267
|
+
lines.append(colour(S.bold(_("{0}({1})").format(_(label), len(members)))))
|
|
268
|
+
# 同类项合并为一行(统计数字取实际成员数);--details 或 --output json 看逐项明细,JSON 里的 findings 不变。
|
|
269
|
+
shown: list[tuple[dict, list[dict]]] = []
|
|
270
|
+
index: dict[str, int] = {}
|
|
259
271
|
for finding in members:
|
|
272
|
+
group = finding.get("group")
|
|
273
|
+
if group and not details:
|
|
274
|
+
if group["id"] in index:
|
|
275
|
+
shown[index[group["id"]]][1].append(finding)
|
|
276
|
+
continue
|
|
277
|
+
index[group["id"]] = len(shown)
|
|
278
|
+
shown.append((finding, [finding]))
|
|
279
|
+
for finding, merged in shown:
|
|
260
280
|
numbered.append(finding)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
281
|
+
number = S.bold(S.cyan(f'{len(numbered):>2}'))
|
|
282
|
+
if len(merged) > 1 or (finding.get("group") and not details):
|
|
283
|
+
lines += _group_lines(number, finding, merged)
|
|
284
|
+
continue
|
|
285
|
+
lines.append(f" {number} [{finding['area']}] {S.bold(finding['title'])}")
|
|
286
|
+
lines.append(_(" 原因:{0}").format(finding['reason']))
|
|
287
|
+
lines.append(_(" 影响:{0}").format(finding['impact']))
|
|
264
288
|
for step in finding["next"]:
|
|
265
|
-
lines.append(
|
|
289
|
+
lines.append(_(" 下一步:{0}").format(step['label']) + S.dim(command_hint(step["action"])))
|
|
266
290
|
if finding.get("decision"):
|
|
267
|
-
where = "只记在这台机器上" if finding["decision"]["scope"] == "machine" else "记入项目,所有机器生效"
|
|
268
|
-
lines.append(S.dim(
|
|
291
|
+
where = _("只记在这台机器上") if finding["decision"]["scope"] == "machine" else _("记入项目,所有机器生效")
|
|
292
|
+
lines.append(S.dim(_(" 不需要?fix --skip {0} --reason …({1})").format(finding['decision']['id'], where)))
|
|
269
293
|
skipped = health.get("skipped") or []
|
|
270
294
|
if show_skipped:
|
|
271
|
-
lines.append(S.bold(
|
|
295
|
+
lines.append(S.bold(_("已跳过({0})").format(len(skipped))) if skipped else S.dim(_("没有被跳过的项。")))
|
|
272
296
|
for item in skipped:
|
|
273
297
|
decision = item["decision"]
|
|
274
|
-
lines.append(
|
|
298
|
+
lines.append(_(" {0}:{1} ").format(item['id'], decision.get('reason') or _('(未写理由)'))
|
|
275
299
|
+ S.dim(f"[{decision['decision']} {decision.get('decided_at', '')}]"))
|
|
276
300
|
elif skipped:
|
|
277
|
-
lines.append(S.dim(
|
|
301
|
+
lines.append(S.dim(_("另有 {0} 项已被跳过:health --show-skipped 查看").format(len(skipped))))
|
|
278
302
|
if health["ok"]:
|
|
279
|
-
lines.append(S.green("正常:") + "、".join(health["ok"]))
|
|
303
|
+
lines.append(S.green(_("正常:")) + _("、").join(health["ok"]))
|
|
280
304
|
return lines, numbered
|
|
281
305
|
|
|
282
306
|
|
|
307
|
+
def _group_lines(number: str, first: dict, members: list[dict]) -> list[str]:
|
|
308
|
+
"""One merged entry for several findings of one category: label with the count, a few names, how to view / handle / accept."""
|
|
309
|
+
names = _("、").join(item["decision"]["id"].split(":", 1)[-1] if item.get("decision") else item["title"] for item in members[:3])
|
|
310
|
+
lines = [f" {number} [{first['area']}] {S.bold(first['group']['label'])}",
|
|
311
|
+
_(" 包含:{0}").format(names + (_("……共 {0} 项").format(len(members)) if len(members) > 3 else ""))]
|
|
312
|
+
for step in first["next"]:
|
|
313
|
+
lines.append(_(" 下一步:{0}").format(step['label']) + S.dim(command_hint(step["action"])))
|
|
314
|
+
lines.append(S.dim(_(" 查看逐项:health --details(或 --output json);这些都不需要:fix --accept-current --reason …;单项:fix --skip <ID> --reason …")))
|
|
315
|
+
return lines
|
|
316
|
+
|
|
317
|
+
|
|
283
318
|
def command_hint(action: str) -> str:
|
|
284
319
|
"""fix:rebuild-index -> (命令:fix rebuild-index); empty for advice-only steps."""
|
|
285
|
-
verb,
|
|
286
|
-
return
|
|
320
|
+
verb, _sep, target = action.partition(":")
|
|
321
|
+
return _("(命令:{0} {1})").format(verb, target) if verb in ("fix", "open") and target else ""
|
|
287
322
|
|
|
288
323
|
|
|
289
324
|
def render_plan(plan: dict, choices: dict[str, str] | None = None) -> list[str]:
|
|
290
325
|
lines = []
|
|
291
326
|
for number, step in enumerate(plan["steps"], 1):
|
|
292
327
|
lines.append(f" {S.bold(S.cyan(str(number)))} {S.bold(step['title'])}"
|
|
293
|
-
+ (S.red(" 含不兼容变更") if step["breaking"] else ""))
|
|
294
|
-
lines += [
|
|
328
|
+
+ (S.red(_(" 含不兼容变更")) if step["breaking"] else ""))
|
|
329
|
+
lines += [_(" 变化:{0}").format(change) for change in step["changes"]]
|
|
295
330
|
for write in step["writes"]:
|
|
296
|
-
lines.append(
|
|
331
|
+
lines.append(_(" 将写入:{0}({1})").format(write['path'], write['scope']))
|
|
297
332
|
for item in step["custom"]:
|
|
298
333
|
chosen = (choices or {}).get(item["path"])
|
|
299
334
|
decision = chosen or item["default"]
|
|
300
335
|
if item.get("options"):
|
|
301
|
-
label = ("" if chosen else "默认") + {"accept": "采用(按模板处理)", "skip": "永久跳过(记入决定文件)",
|
|
302
|
-
"later": "稍后(本次不处理)"}.get(decision, decision)
|
|
336
|
+
label = ("" if chosen else _("默认")) + {"accept": _("采用(按模板处理)"), "skip": _("永久跳过(记入决定文件)"),
|
|
337
|
+
"later": _("稍后(本次不处理)")}.get(decision, decision)
|
|
303
338
|
elif item["path"] == "README.md":
|
|
304
|
-
label = ("" if chosen else "默认") + ("不改" if decision == "keep" else "追加「怎样使用」")
|
|
339
|
+
label = ("" if chosen else _("默认")) + (_("不改") if decision == "keep" else _("追加「怎样使用」"))
|
|
305
340
|
else:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
341
|
+
lost = _("(丢弃 {0} 行本地内容)").format(item["lost"]) if decision == "accept" and item.get("lost") else ""
|
|
342
|
+
label = ("" if chosen else _("默认")) + {"keep": _("保留你的版本"), "append": _("保留你的版本并追加带标记的区块")}.get(
|
|
343
|
+
decision, _("采用新模板") + lost)
|
|
344
|
+
lines.append(S.yellow(_(" 定制文件:{0}({1})→ {2}").format(item['path'], item['state'], label)))
|
|
345
|
+
lines.append(_(" 联网:{0} · 恢复:{1}").format(_('需要') if step['network'] else _('不需要'), step['recovery']))
|
|
309
346
|
if step["blocked"]:
|
|
310
|
-
lines.append(S.yellow(
|
|
347
|
+
lines.append(S.yellow(_(" 暂不能执行:{0}").format(step['blocked'])))
|
|
311
348
|
if not plan["steps"]:
|
|
312
|
-
lines.append(S.green("没有需要处理的项。"))
|
|
349
|
+
lines.append(S.green(_("没有需要处理的项。")))
|
|
313
350
|
return lines
|
|
314
351
|
|
|
315
352
|
|
|
316
353
|
def render_apply(result: dict) -> list[str]:
|
|
317
|
-
prefix = "【演示】" if result.get("simulated") else ""
|
|
354
|
+
prefix = _("【演示】") if result.get("simulated") else ""
|
|
318
355
|
lines = []
|
|
319
356
|
for item in result["results"]:
|
|
320
357
|
if item["status"] == "skipped":
|
|
321
|
-
lines.append(S.yellow(
|
|
358
|
+
lines.append(S.yellow(_(" 跳过 {0}:{1}").format(item['id'], item['detail'])))
|
|
322
359
|
continue
|
|
323
|
-
|
|
360
|
+
if item["status"] == "failed" and "written" not in item:
|
|
361
|
+
lines.append(S.red(_(" 失败 {0}:{1}").format(item['id'], item['detail'])))
|
|
362
|
+
continue
|
|
363
|
+
lines.append(S.green(_(" {0}已处理 {1}").format(prefix, item['id'])))
|
|
324
364
|
if item["written"]:
|
|
325
|
-
lines.append(
|
|
365
|
+
lines.append(_(" 写入:{0}").format(_('、').join(item['written'])))
|
|
326
366
|
if item["kept"]:
|
|
327
|
-
lines.append(
|
|
367
|
+
lines.append(_(" 保留:{0}(未改动)").format(_('、').join(item['kept'])))
|
|
328
368
|
if item["accepted"]:
|
|
329
|
-
lines.append(
|
|
330
|
-
|
|
331
|
-
|
|
369
|
+
lines.append(_(" 采用新模板:{0}").format(_('、').join(item['accepted'])))
|
|
370
|
+
if item.get("appended"):
|
|
371
|
+
lines.append(_(" 保留原文并追加区块:{0}").format(_('、').join(item['appended'])))
|
|
372
|
+
lines.append(_(" 验证:{0}").format(item['verify']))
|
|
373
|
+
lines.append(_(" 恢复位置:{0}").format(item['recovery']))
|
|
332
374
|
return lines
|
|
333
375
|
|
|
334
376
|
|
|
335
377
|
def render_preview(preview: dict) -> list[str]:
|
|
336
|
-
verb = "将新建" if preview.get("kind") == "new" or preview.get("target") is None else "将修改"
|
|
378
|
+
verb = _("将新建") if preview.get("kind") == "new" or preview.get("target") is None else _("将修改")
|
|
337
379
|
lines = [S.bold(f"{verb} {preview['path']}")]
|
|
338
380
|
for line in preview["lines"]:
|
|
339
381
|
lines.append(S.green(line) if line.startswith("+") else S.red(line) if line.startswith("-") else S.dim(line))
|
|
340
382
|
if preview["expect_updated_at"]:
|
|
341
|
-
lines.append(S.dim(
|
|
383
|
+
lines.append(S.dim(_("写入前会核对 updated_at 仍为 {0},别人改过就不写入").format(preview['expect_updated_at'])))
|
|
342
384
|
return lines
|
|
343
385
|
|
|
344
386
|
|
|
345
387
|
def render_tools(tools: list[dict]) -> list[str]:
|
|
346
388
|
if not tools:
|
|
347
|
-
return [S.dim("这个项目没有声明专用工具。项目可在 .agents/moe.sakanano.agent-pack/tools.json 声明。")]
|
|
389
|
+
return [S.dim(_("这个项目没有声明专用工具。项目可在 .agents/moe.sakanano.agent-pack/tools.json 声明。"))]
|
|
348
390
|
lines = []
|
|
349
391
|
for number, tool in enumerate(tools, 1):
|
|
350
|
-
mark = S.green("可用") if tool["state"] == "available" else S.yellow(
|
|
392
|
+
mark = S.green(_("可用")) if tool["state"] == "available" else S.yellow(_("不可用:{0}").format(tool['reason']))
|
|
351
393
|
lines.append(f" {S.bold(S.cyan(str(number)))} {S.bold(tool['title'])} {mark}")
|
|
352
394
|
if tool["description"]:
|
|
353
395
|
lines.append(f" {tool['description']}")
|
|
354
|
-
lines.append(S.dim(
|
|
355
|
-
account =
|
|
356
|
-
lines.append(S.dim(
|
|
396
|
+
lines.append(S.dim(_(" 命令:{0}").format(' '.join(tool['command']))))
|
|
397
|
+
account = _(" · 账号:{0}").format(tool['account']) if tool["account"] else ""
|
|
398
|
+
lines.append(S.dim(_(" 联网:{0}{1} · 写入:{2}").format(_('需要') if tool['network'] else _('不需要'), account, _('、').join(tool['writes']) or _('无'))))
|
|
357
399
|
return lines
|
|
358
400
|
|
|
359
401
|
|
|
360
402
|
def render_capabilities(capabilities: list[dict]) -> list[str]:
|
|
361
|
-
return [f" {pad(item['title'], 16)}{S.green('可用') if item['state'] == 'available' else S.yellow('不可用')}"
|
|
362
|
-
+ (
|
|
403
|
+
return [f" {pad(item['title'], 16)}{S.green(_('可用')) if item['state'] == 'available' else S.yellow(_('不可用'))}"
|
|
404
|
+
+ (_(":{0}").format(item['reason']) if item["reason"] else "") for item in capabilities]
|
|
363
405
|
|
|
364
406
|
|
|
365
407
|
def render_error(error: EntryError) -> list[str]:
|
|
366
|
-
lines = [S.red(
|
|
408
|
+
lines = [S.red(_("出错:{0}").format(error))]
|
|
367
409
|
lines += [f" · {step}" for step in error.next_steps]
|
|
368
410
|
return lines
|
|
369
411
|
|
|
@@ -372,13 +414,13 @@ def render_error(error: EntryError) -> list[str]:
|
|
|
372
414
|
|
|
373
415
|
def _act_target(result: dict, number: int) -> dict:
|
|
374
416
|
if not 1 <= number <= len(result["results"]):
|
|
375
|
-
raise EntryError(
|
|
417
|
+
raise EntryError(_("没有第 {0} 项(共 {1} 项)").format(number, len(result['results'])), "not-found")
|
|
376
418
|
return result["results"][number - 1]
|
|
377
419
|
|
|
378
420
|
|
|
379
421
|
def cmd_find(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
380
422
|
result = provider.find(args.terms, ext=args.type, container=args.container, limit=args.limit)
|
|
381
|
-
lines = header(provider, "找资料") + render_find(result)
|
|
423
|
+
lines = header(provider, _("找资料")) + render_find(result)
|
|
382
424
|
for action in ("open", "reveal", "copy"):
|
|
383
425
|
number = getattr(args, action)
|
|
384
426
|
if number is not None:
|
|
@@ -401,9 +443,9 @@ def cmd_refs(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, li
|
|
|
401
443
|
|
|
402
444
|
def cmd_progress(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
403
445
|
result = provider.items(status=args.status, term=args.term)
|
|
404
|
-
lines,
|
|
446
|
+
lines, _ignored = render_items(result, expand_closed=args.all or args.status in CLOSED)
|
|
405
447
|
return (EXIT_OK if result["items"] or not (args.term or args.status) else EXIT_ATTENTION), result, \
|
|
406
|
-
header(provider, "看进展") + lines
|
|
448
|
+
header(provider, _("看进展")) + lines
|
|
407
449
|
|
|
408
450
|
|
|
409
451
|
def cmd_show(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
@@ -413,21 +455,31 @@ def cmd_show(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, li
|
|
|
413
455
|
|
|
414
456
|
def cmd_guide(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
415
457
|
guide = provider.guide()
|
|
416
|
-
return EXIT_OK, guide, header(provider, "项目指南") + render_guide(guide)
|
|
458
|
+
return EXIT_OK, guide, header(provider, _("项目指南")) + render_guide(guide)
|
|
417
459
|
|
|
418
460
|
|
|
419
461
|
def cmd_health(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
420
462
|
provider.reprompt = bool(getattr(args, "reprompt", False))
|
|
421
463
|
health = provider.health()
|
|
422
|
-
lines,
|
|
464
|
+
lines, _ignored = render_health(health, bool(getattr(args, "show_skipped", False)), bool(getattr(args, "details", False)))
|
|
423
465
|
must = any(finding["level"] == "must" for finding in health["findings"])
|
|
424
|
-
return (EXIT_ATTENTION if must else EXIT_OK), health, header(provider, "检查项目与环境") + lines
|
|
466
|
+
return (EXIT_ATTENTION if must else EXIT_OK), health, header(provider, _("检查项目与环境")) + lines
|
|
425
467
|
|
|
426
468
|
|
|
427
469
|
def cmd_fix(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
470
|
+
if getattr(args, "accept_current", False):
|
|
471
|
+
return _fix_accept_current(provider, args)
|
|
428
472
|
if args.skip or args.unskip:
|
|
429
473
|
return _fix_decisions(provider, args)
|
|
430
|
-
choices = {path: "keep" for path in args.keep} | {path: "accept" for path in args.accept}
|
|
474
|
+
choices = {path: "keep" for path in args.keep} | {path: "accept" for path in args.accept} \
|
|
475
|
+
| {path: "append" for path in args.append}
|
|
476
|
+
if args.confirm_discard:
|
|
477
|
+
choices["_confirm"] = "\n".join(args.confirm_discard)
|
|
478
|
+
for key, values in (("_merge", args.merge), ("_pick", args.pick), ("_diff", args.diff)):
|
|
479
|
+
if values:
|
|
480
|
+
choices[key] = "\n".join(values)
|
|
481
|
+
if args.diff and args.apply:
|
|
482
|
+
raise EntryError(_("--diff 只用于查看,不能与 --apply 同用"), "usage")
|
|
431
483
|
if args.entry_name:
|
|
432
484
|
choices["entry-name"] = args.entry_name
|
|
433
485
|
ids, targets = _split_targets(args.ids)
|
|
@@ -436,14 +488,16 @@ def cmd_fix(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, lis
|
|
|
436
488
|
if args.reason:
|
|
437
489
|
choices["_reason"] = args.reason
|
|
438
490
|
plan = provider.fix_plan(ids, choices)
|
|
439
|
-
lines = header(provider, "修复与更新") + render_plan(plan, choices)
|
|
491
|
+
lines = header(provider, _("修复与更新")) + render_plan(plan, choices)
|
|
440
492
|
if not args.apply:
|
|
441
|
-
lines.append(S.dim("以上为预览,没有写入。确认后加 --apply;定制文件用 --keep / --accept
|
|
493
|
+
lines.append(S.dim(_("以上为预览,没有写入。确认后加 --apply;定制文件用 --keep / --accept 指定;"
|
|
494
|
+
"AGENTS.md / CLAUDE.md 也可用 --append 保留原文、只追加带标记的区块;--accept 会丢弃本地内容时需再加 --confirm-discard <文件>;也可用 --merge <文件> 三方合并(冲突块用 --pick),--diff <文件> 先看差异。")))
|
|
442
495
|
if any(item.get("options") for step in plan["steps"] for item in step["custom"]):
|
|
443
|
-
lines.append(S.dim("不想要其中某项:fix --skip <ID> --reason …(ID 见 health / check);只处理几项:在处理项后列出路径或字段。"))
|
|
496
|
+
lines.append(S.dim(_("不想要其中某项:fix --skip <ID> --reason …(ID 见 health / check);只处理几项:在处理项后列出路径或字段。")))
|
|
444
497
|
return EXIT_OK, {"plan": plan, "applied": False}, lines
|
|
445
498
|
result = provider.apply_fix(plan, choices)
|
|
446
|
-
|
|
499
|
+
failed = any(item["status"] == "failed" for item in result["results"])
|
|
500
|
+
return (EXIT_ATTENTION if failed else EXIT_OK), {"plan": plan, "applied": True, **result}, lines + render_apply(result)
|
|
447
501
|
|
|
448
502
|
|
|
449
503
|
def _split_targets(ids: list[str]) -> tuple[list[str], list[str]]:
|
|
@@ -452,22 +506,45 @@ def _split_targets(ids: list[str]) -> tuple[list[str], list[str]]:
|
|
|
452
506
|
return ids, []
|
|
453
507
|
|
|
454
508
|
|
|
509
|
+
def _fix_accept_current(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
510
|
+
"""--accept-current: one batch of keep decisions in the project decisions file; project files stay untouched."""
|
|
511
|
+
if not hasattr(provider, "accept_current"):
|
|
512
|
+
raise EntryError(_("演示项目没有决定文件"), "usage")
|
|
513
|
+
result = provider.accept_current(args.reason or "", args.apply)
|
|
514
|
+
lines = header(provider, _("接受现状"))
|
|
515
|
+
verb = _("已记录") if result["applied"] else _("将记录")
|
|
516
|
+
if not result["count"]:
|
|
517
|
+
lines.append(_("当前没有需要接受的脚手架差异。"))
|
|
518
|
+
else:
|
|
519
|
+
lines.append(_("{0}:把当前 {1} 项脚手架差异记为“已决定、保留现状”").format(verb, result["count"]))
|
|
520
|
+
lines += [f" {row['label']}" for row in result["categories"]]
|
|
521
|
+
lines.append(_(" 写入 {0}(随项目同步,换一台机器不再提示;理由:{1})").format(result["file"], result["reason"]))
|
|
522
|
+
for item in result["excluded"]:
|
|
523
|
+
lines.append(S.yellow(_(" 未包含(需要处理):[{0}] {1}").format(item["id"], item["title"])))
|
|
524
|
+
if not args.reason:
|
|
525
|
+
lines.append(S.dim(_("没有写理由:建议加 --reason \"<原因>\",以后审阅决定文件时看得懂。")))
|
|
526
|
+
if not args.apply and result["count"]:
|
|
527
|
+
lines.append(S.dim(_("以上为预览,没有写入。确认后加 --apply。之后只有新出现的差异(或模板期望内容变化的项)才会再次提示;"
|
|
528
|
+
"撤销单项:fix --unskip <ID>。")))
|
|
529
|
+
return EXIT_OK, result, lines
|
|
530
|
+
|
|
531
|
+
|
|
455
532
|
def _fix_decisions(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
456
533
|
"""--skip / --unskip: write only the decision file; the check itself stays read-only."""
|
|
457
534
|
if not hasattr(provider, "decide"):
|
|
458
|
-
raise EntryError("演示项目没有决定文件", "usage")
|
|
535
|
+
raise EntryError(_("演示项目没有决定文件"), "usage")
|
|
459
536
|
result = provider.decide(args.skip, args.unskip, args.reason or "", args.apply)
|
|
460
|
-
lines = header(provider, "记录决定")
|
|
537
|
+
lines = header(provider, _("记录决定"))
|
|
461
538
|
for item in result["decisions"]:
|
|
462
539
|
if item["mode"] == "decide":
|
|
463
|
-
verb = "已记录" if item["applied"] else "将记录"
|
|
464
|
-
lines.append(
|
|
465
|
-
+ (
|
|
466
|
-
+
|
|
540
|
+
verb = _("已记录") if item["applied"] else _("将记录")
|
|
541
|
+
lines.append(_(" {0}:{1} → {2}").format(verb, item['id'], item['entry']['decision'])
|
|
542
|
+
+ (_("({0})").format(item['entry']['reason']) if item["entry"].get("reason") else _("(没有写理由)"))
|
|
543
|
+
+ _(",写入 {0}({1})").format(item['file'], _('随项目同步') if item['scope'] == 'project' else _('只在这台机器')))
|
|
467
544
|
else:
|
|
468
|
-
lines.append(
|
|
545
|
+
lines.append(_(" {0}:{1}({2})").format(_('已撤销') if item['applied'] else _('将撤销'), item['id'], item['file']))
|
|
469
546
|
if not args.apply:
|
|
470
|
-
lines.append(S.dim("以上为预览,没有写入。确认后加 --apply。"))
|
|
547
|
+
lines.append(S.dim(_("以上为预览,没有写入。确认后加 --apply。")))
|
|
471
548
|
return EXIT_OK, result, lines
|
|
472
549
|
|
|
473
550
|
|
|
@@ -481,44 +558,68 @@ def _record_change(args: argparse.Namespace) -> dict:
|
|
|
481
558
|
def cmd_record(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
482
559
|
target = None if args.item == "new" else args.item
|
|
483
560
|
if target is None and not (args.title and args.goal):
|
|
484
|
-
raise EntryError("新建事项需要 --title 与 --goal", "usage")
|
|
561
|
+
raise EntryError(_("新建事项需要 --title 与 --goal"), "usage")
|
|
485
562
|
preview = provider.record_preview(target, _record_change(args))
|
|
486
563
|
# 预览与写入分两次运行时,用预览当时的值核对;同一次运行里预览本身就是核对基准。
|
|
487
564
|
for key in ("expect_updated_at", "expect_sha256"):
|
|
488
565
|
if getattr(args, key):
|
|
489
566
|
preview[key] = getattr(args, key)
|
|
490
|
-
lines = header(provider, "记录事项") + render_preview(preview)
|
|
567
|
+
lines = header(provider, _("记录事项")) + render_preview(preview)
|
|
491
568
|
if not args.apply:
|
|
492
|
-
lines.append(S.dim("以上为预览,没有写入。确认后加 --apply。"))
|
|
569
|
+
lines.append(S.dim(_("以上为预览,没有写入。确认后加 --apply。")))
|
|
493
570
|
return EXIT_OK, {"preview": preview, "applied": False}, lines
|
|
494
571
|
result = provider.record_apply(preview)
|
|
495
|
-
|
|
572
|
+
lines += [S.green(result["verify"])]
|
|
573
|
+
events = result.get("sop_events") or []
|
|
574
|
+
if events:
|
|
575
|
+
lines += ["", S.bold(_("命中流程(SOP):"))]
|
|
576
|
+
for event in events:
|
|
577
|
+
lines.append(_(" {0}({1}):{2}").format(event['id'], event['title'], event['trigger']))
|
|
578
|
+
lines.append(S.dim(_(" 是否按它执行由你决定;确认后运行:{0}").format(event['command'])))
|
|
579
|
+
return EXIT_OK, {"preview": preview, "applied": True, **result}, lines
|
|
496
580
|
|
|
497
581
|
|
|
498
582
|
def cmd_tools(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
499
583
|
tools = provider.tools()
|
|
500
584
|
if args.tool is None:
|
|
501
|
-
return EXIT_OK, tools, header(provider, "项目工具") + render_tools(tools)
|
|
585
|
+
return EXIT_OK, tools, header(provider, _("项目工具")) + render_tools(tools)
|
|
502
586
|
tool = next((tool for tool in tools if tool["id"] == args.tool), None)
|
|
503
587
|
if tool is None:
|
|
504
|
-
raise EntryError(
|
|
505
|
-
["已声明:" + ("、".join(tool["id"] for tool in tools) or "(无)")])
|
|
588
|
+
raise EntryError(_("项目没有声明这个工具:{0}").format(args.tool), "not-found",
|
|
589
|
+
[_("已声明:") + (_("、").join(tool["id"] for tool in tools) or _("(无)"))])
|
|
506
590
|
lines = render_tools([tool])
|
|
507
591
|
if not (args.run and args.apply):
|
|
508
|
-
lines.append(S.dim("以上为说明,没有执行。确认后加 --run --apply。"))
|
|
592
|
+
lines.append(S.dim(_("以上为说明,没有执行。确认后加 --run --apply。")))
|
|
509
593
|
return EXIT_OK, tool, lines
|
|
510
594
|
result = provider.run_tool(args.tool)
|
|
511
595
|
return EXIT_OK, result, lines + [result["message"]]
|
|
512
596
|
|
|
513
597
|
|
|
598
|
+
SOP_EXIT_CODES = {"usage": "usage", "invalid": "usage", "not-found": "not-found", "ambiguous": "ambiguous",
|
|
599
|
+
"conflict": "conflict", "unavailable": "unavailable", "failed": "failed"}
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def cmd_sop(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
603
|
+
rest = list(args.sop_args)
|
|
604
|
+
for flag in ("--output",): # 子命令后面的 --output 交给本入口处理,保持与其他子命令一致
|
|
605
|
+
if flag in rest and rest.index(flag) + 1 < len(rest):
|
|
606
|
+
position = rest.index(flag)
|
|
607
|
+
args.output = rest[position + 1]
|
|
608
|
+
del rest[position:position + 2]
|
|
609
|
+
if not rest:
|
|
610
|
+
rest = ["list"]
|
|
611
|
+
code, data, lines = provider.sop(rest)
|
|
612
|
+
return code, data, header(provider, _("流程(SOP)")) + lines
|
|
613
|
+
|
|
614
|
+
|
|
514
615
|
def cmd_capabilities(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
515
616
|
capabilities = provider.capabilities()
|
|
516
|
-
return EXIT_OK, capabilities, header(provider, "能力状态") + render_capabilities(capabilities)
|
|
617
|
+
return EXIT_OK, capabilities, header(provider, _("能力状态")) + render_capabilities(capabilities)
|
|
517
618
|
|
|
518
619
|
|
|
519
620
|
def cmd_scenarios(_provider: Any, args: argparse.Namespace) -> tuple[int, Any, list[str]]:
|
|
520
621
|
items = project_demo.describe()
|
|
521
|
-
lines = [
|
|
622
|
+
lines = [_(" --demo {0}{1}({2})").format(pad(item['id'], 10), item['name'], item['kind']) for item in items]
|
|
522
623
|
lines.append(" --demo-fault " + " | ".join(project_demo.FAULTS))
|
|
523
624
|
return EXIT_OK, {"scenarios": items, "faults": list(project_demo.FAULTS)}, lines
|
|
524
625
|
|
|
@@ -527,34 +628,34 @@ def cmd_home(provider: Provider, args: argparse.Namespace) -> tuple[int, Any, li
|
|
|
527
628
|
if args.output == "text" and not args.no_input and sys.stdin.isatty() and sys.stdout.isatty():
|
|
528
629
|
import project_menu
|
|
529
630
|
return project_menu.run(provider), None, []
|
|
530
|
-
lines = render_overview(provider) + ["", S.bold("可做的事")]
|
|
631
|
+
lines = render_overview(provider) + ["", S.bold(_("可做的事"))]
|
|
531
632
|
lines += render_capabilities(provider.capabilities())
|
|
532
|
-
lines.append(S.dim("在终端里直接运行可进入菜单;脚本中请用子命令,见 --help。"))
|
|
633
|
+
lines.append(S.dim(_("在终端里直接运行可进入菜单;脚本中请用子命令,见 --help。")))
|
|
533
634
|
return EXIT_OK, provider.overview(), lines
|
|
534
635
|
|
|
535
636
|
|
|
536
637
|
COMMANDS: dict[str, Callable[[Any, argparse.Namespace], tuple[int, Any, list[str]]]] = {
|
|
537
638
|
"find": cmd_find, "open": cmd_open, "refs": cmd_refs, "progress": cmd_progress, "show": cmd_show,
|
|
538
639
|
"guide": cmd_guide, "health": cmd_health, "fix": cmd_fix, "record": cmd_record, "tools": cmd_tools,
|
|
539
|
-
"capabilities": cmd_capabilities, "scenarios": cmd_scenarios, "home": cmd_home,
|
|
640
|
+
"sop": cmd_sop, "capabilities": cmd_capabilities, "scenarios": cmd_scenarios, "home": cmd_home,
|
|
540
641
|
}
|
|
541
642
|
|
|
542
643
|
|
|
543
644
|
def parser() -> argparse.ArgumentParser:
|
|
544
645
|
shared = argparse.ArgumentParser(add_help=False)
|
|
545
|
-
result =argparse.ArgumentParser(prog="agenthelm project", description="项目入口:不需要 AI Agent 的项目自助菜单",
|
|
546
|
-
formatter_class=argparse.RawDescriptionHelpFormatter, epilog=
|
|
646
|
+
result =argparse.ArgumentParser(prog="agenthelm project", description=_("项目入口:不需要 AI Agent 的项目自助菜单"),
|
|
647
|
+
formatter_class=argparse.RawDescriptionHelpFormatter, epilog=_(USAGE))
|
|
547
648
|
|
|
548
649
|
def globals_on(target: argparse.ArgumentParser, default: Any) -> None:
|
|
549
650
|
def value(normal: Any) -> Any:
|
|
550
651
|
return argparse.SUPPRESS if default is argparse.SUPPRESS else normal
|
|
551
|
-
target.add_argument("--project", type=Path, default=value(None), help="项目目录;缺省从当前目录向上查找")
|
|
652
|
+
target.add_argument("--project", type=Path, default=value(None), help=_("项目目录;缺省从当前目录向上查找"))
|
|
552
653
|
target.add_argument("--output", choices=("text", "json"), default=value("text"))
|
|
553
|
-
target.add_argument("--no-input", action="store_true", default=value(False), help="不进入交互菜单")
|
|
554
|
-
target.add_argument("--demo", default=value(None), help="演示场景:study / personal / research / blank")
|
|
654
|
+
target.add_argument("--no-input", action="store_true", default=value(False), help=_("不进入交互菜单"))
|
|
655
|
+
target.add_argument("--demo", default=value(None), help=_("演示场景:study / personal / research / blank"))
|
|
555
656
|
target.add_argument("--demo-fault", default=value(None), choices=project_demo.FAULTS)
|
|
556
657
|
target.add_argument("--offline", action="store_true", default=value(False),
|
|
557
|
-
help="不联网:版本检查只用缓存,需要联网的维护只预览")
|
|
658
|
+
help=_("不联网:版本检查只用缓存,需要联网的维护只预览"))
|
|
558
659
|
target.add_argument("--via-launcher", type=int, default=value(None), help=argparse.SUPPRESS)
|
|
559
660
|
|
|
560
661
|
globals_on(result, None)
|
|
@@ -564,54 +665,66 @@ def parser() -> argparse.ArgumentParser:
|
|
|
564
665
|
def add(name: str, help_text: str) -> argparse.ArgumentParser:
|
|
565
666
|
return sub.add_parser(name, parents=[shared], help=help_text)
|
|
566
667
|
|
|
567
|
-
find = add("find", "找资料")
|
|
668
|
+
find = add("find", _("找资料"))
|
|
568
669
|
find.add_argument("terms", nargs="*")
|
|
569
|
-
find.add_argument("--type", help="文件类型,如 pdf、xlsx")
|
|
570
|
-
find.add_argument("--in", dest="container", help="限定事项或目录(片段)")
|
|
670
|
+
find.add_argument("--type", help=_("文件类型,如 pdf、xlsx"))
|
|
671
|
+
find.add_argument("--in", dest="container", help=_("限定事项或目录(片段)"))
|
|
571
672
|
find.add_argument("--limit", type=int, default=10)
|
|
572
673
|
for action in ("open", "reveal", "copy"):
|
|
573
|
-
find.add_argument(f"--{action}", type=int, metavar="N", help=
|
|
574
|
-
opener = add("open", "打开资料")
|
|
674
|
+
find.add_argument(f"--{action}", type=int, metavar="N", help=_("对第 N 项执行 {0}").format(action))
|
|
675
|
+
opener = add("open", _("打开资料"))
|
|
575
676
|
opener.add_argument("path")
|
|
576
677
|
opener.add_argument("--reveal", action="store_true")
|
|
577
678
|
opener.add_argument("--copy", action="store_true")
|
|
578
|
-
add("refs", "引用关系").add_argument("path")
|
|
579
|
-
progress = add("progress", "看进展")
|
|
679
|
+
add("refs", _("引用关系")).add_argument("path")
|
|
680
|
+
progress = add("progress", _("看进展"))
|
|
580
681
|
progress.add_argument("term", nargs="?")
|
|
581
682
|
progress.add_argument("--status", choices=tuple(GROUP_LABEL))
|
|
582
|
-
progress.add_argument("--all", action="store_true", help="同时列出已完成与放弃的事项")
|
|
583
|
-
add("show", "事项详情").add_argument("item")
|
|
584
|
-
add("guide", "项目指南")
|
|
585
|
-
health = add("health", "检查项目与环境")
|
|
586
|
-
health.add_argument("--show-skipped", action="store_true", help="列出被你跳过的项及理由")
|
|
587
|
-
health.add_argument("--
|
|
588
|
-
|
|
589
|
-
fix
|
|
590
|
-
fix.add_argument("
|
|
591
|
-
fix.add_argument("--
|
|
592
|
-
fix.add_argument("--
|
|
683
|
+
progress.add_argument("--all", action="store_true", help=_("同时列出已完成与放弃的事项"))
|
|
684
|
+
add("show", _("事项详情")).add_argument("item")
|
|
685
|
+
add("guide", _("项目指南"))
|
|
686
|
+
health = add("health", _("检查项目与环境"))
|
|
687
|
+
health.add_argument("--show-skipped", action="store_true", help=_("列出被你跳过的项及理由"))
|
|
688
|
+
health.add_argument("--details", action="store_true", help=_("同类建议逐项展开(默认合并为一行)"))
|
|
689
|
+
health.add_argument("--reprompt", action="store_true", help=_("忽略已记录的决定,重新评估全部差异"))
|
|
690
|
+
fix = add("fix", _("修复与更新"))
|
|
691
|
+
fix.add_argument("ids", nargs="*", help=_("处理项;add-skeleton / profile 后可跟路径 / 字段"))
|
|
692
|
+
fix.add_argument("--skip", action="append", default=[], metavar="ID", help=_("永久跳过这个发现(记入决定文件)"))
|
|
693
|
+
fix.add_argument("--unskip", action="append", default=[], metavar="ID", help=_("撤销对这个发现的跳过"))
|
|
694
|
+
fix.add_argument("--accept-current", action="store_true", dest="accept_current",
|
|
695
|
+
help=_("把当前全部脚手架差异一次性记为“已决定、保留现状”(写入随项目同步的决定文件;默认预览,--apply 写入;与 --reason 合用)"))
|
|
696
|
+
fix.add_argument("--reason", help=_("--skip / --accept-current 的理由(建议写;随项目同步,换一台机器也看得到)"))
|
|
593
697
|
fix.add_argument("--apply", action="store_true")
|
|
594
698
|
fix.add_argument("--keep", action="append", default=[])
|
|
595
699
|
fix.add_argument("--accept", action="append", default=[])
|
|
596
|
-
fix.add_argument("--
|
|
597
|
-
|
|
598
|
-
|
|
700
|
+
fix.add_argument("--append", action="append", default=[])
|
|
701
|
+
fix.add_argument("--confirm-discard", action="append", default=[], dest="confirm_discard")
|
|
702
|
+
fix.add_argument("--merge", action="append", default=[], metavar=_("文件"),
|
|
703
|
+
help=_("update-content:三方合并这个文件(还原升级前的基线,保留你的改动并带入新模板的变化;--apply 前先备份)"))
|
|
704
|
+
fix.add_argument("--pick", action="append", default=[], metavar=_("文件#块=mine|theirs|both"),
|
|
705
|
+
help=_("update-content:为 --merge 的冲突块选择 mine(保留你的)/ theirs(取新模板)/ both(两边都留)"))
|
|
706
|
+
fix.add_argument("--diff", action="append", default=[], metavar=_("文件"), help=_("update-content:只查看这个文件与新模板的完整差异,不写入"))
|
|
707
|
+
fix.add_argument("--entry-name", help=_("add-entry:启动器文件名(缺省 menu)"))
|
|
708
|
+
record = add("record", _("记录事项"))
|
|
709
|
+
record.add_argument("item", help=_("事项,或 new 新建"))
|
|
599
710
|
for name in ("title", "goal", "slug", "log", "next", "waiting"):
|
|
600
711
|
record.add_argument(f"--{name}")
|
|
601
|
-
record.add_argument("--add-deliverable", action="append", default=[], metavar="路径",
|
|
602
|
-
help="登记资料或交付物(相对项目根目录,可重复)")
|
|
712
|
+
record.add_argument("--add-deliverable", action="append", default=[], metavar=_("路径"),
|
|
713
|
+
help=_("登记资料或交付物(相对项目根目录,可重复)"))
|
|
603
714
|
record.add_argument("--status", choices=tuple(GROUP_LABEL))
|
|
604
715
|
record.add_argument("--close", action="store_true")
|
|
605
716
|
record.add_argument("--reopen", action="store_true")
|
|
606
|
-
record.add_argument("--expect-updated-at", help="只在事项的 updated_at 仍为这个值时写入(取自预览的 JSON)")
|
|
607
|
-
record.add_argument("--expect-sha256", help="只在权威记录的内容摘要仍为这个值时写入(取自预览的 JSON)")
|
|
717
|
+
record.add_argument("--expect-updated-at", help=_("只在事项的 updated_at 仍为这个值时写入(取自预览的 JSON)"))
|
|
718
|
+
record.add_argument("--expect-sha256", help=_("只在权威记录的内容摘要仍为这个值时写入(取自预览的 JSON)"))
|
|
608
719
|
record.add_argument("--apply", action="store_true")
|
|
609
|
-
tools = add("tools", "项目工具")
|
|
720
|
+
tools = add("tools", _("项目工具"))
|
|
610
721
|
tools.add_argument("tool", nargs="?")
|
|
611
722
|
tools.add_argument("--run", action="store_true")
|
|
612
723
|
tools.add_argument("--apply", action="store_true")
|
|
613
|
-
add("
|
|
614
|
-
|
|
724
|
+
sop_parser = add("sop", _("流程(SOP):用户自己的步骤序列,触发、前置检查、逐步记录"))
|
|
725
|
+
sop_parser.add_argument("sop_args", nargs=argparse.REMAINDER, help=_("子命令与参数,见 agenthelm project sop --help"))
|
|
726
|
+
add("capabilities", _("能力状态"))
|
|
727
|
+
add("scenarios", _("列出演示场景"))
|
|
615
728
|
return result
|
|
616
729
|
|
|
617
730
|
|
|
@@ -630,20 +743,19 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
630
743
|
except SystemExit as exc:
|
|
631
744
|
return EXIT_OK if exc.code in (0, None) else EXIT_USAGE
|
|
632
745
|
command = args.command or "home"
|
|
633
|
-
output = args.output
|
|
634
746
|
try:
|
|
635
747
|
if command == "scenarios":
|
|
636
748
|
code, data, lines = cmd_scenarios(None, args)
|
|
637
|
-
emit(output, code, command, data, lines, True)
|
|
749
|
+
emit(args.output, code, command, data, lines, True)
|
|
638
750
|
return code
|
|
639
751
|
provider = open_provider(args)
|
|
640
752
|
check_entry_api(provider)
|
|
641
753
|
code, data, lines = COMMANDS[command](provider, args)
|
|
642
|
-
emit(output, code, command, data, lines, provider.simulated)
|
|
754
|
+
emit(args.output, code, command, data, lines, provider.simulated)
|
|
643
755
|
return code
|
|
644
756
|
except EntryError as exc:
|
|
645
757
|
code = EXIT_BY_CODE.get(exc.code, EXIT_USAGE)
|
|
646
|
-
if output == "json":
|
|
758
|
+
if args.output == "json":
|
|
647
759
|
print(json.dumps({"ok": False, "exit_code": code, "command": command, "demo": bool(args.demo),
|
|
648
760
|
"error": {"code": exc.code, "message": str(exc), "next": exc.next_steps}},
|
|
649
761
|
ensure_ascii=False, indent=2))
|