@sakanano-moe/agenthelm 6.12.0 → 6.13.0-rc.1

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 (27) hide show
  1. package/package.json +1 -1
  2. package/runtime/index.json +5 -5
  3. package/runtime/plugins/agent-pack/.codex-plugin/plugin.json +1 -1
  4. package/runtime/plugins/agent-pack/plugin.json +1 -1
  5. package/runtime/plugins/agent-pack/references/capability-config.md +32 -1
  6. package/runtime/plugins/agent-pack/references/nudge.en.md +1 -1
  7. package/runtime/plugins/agent-pack/references/nudge.md +1 -1
  8. package/runtime/plugins/agent-pack/runtime/agent_pack_claude.py +172 -20
  9. package/runtime/plugins/agent-pack/runtime/agent_pack_config.py +286 -35
  10. package/runtime/plugins/agent-pack/runtime/agent_pack_nudge.py +65 -2
  11. package/runtime/plugins/agent-pack/runtime/agenthelm.py +99 -9
  12. package/runtime/plugins/agent-pack/runtime/locale/en.json +15 -1
  13. package/runtime/plugins/agent-pack/runtime/mcp_env_launcher.py +26 -4
  14. package/runtime/plugins/agent-pack/runtime/mcp_server.py +15 -1
  15. package/runtime/plugins/agent-pack/runtime/nudge_text.py +17 -4
  16. package/runtime/plugins/agent-pack/runtime/user_settings.py +25 -6
  17. package/runtime/plugins/agents-init/.codex-plugin/plugin.json +1 -1
  18. package/runtime/plugins/agents-init/plugin.json +1 -1
  19. package/runtime/plugins/agents-init/skills/agents-init/scripts/init_project.py +25 -0
  20. package/runtime/plugins/agents-init/skills/agents-init/skill.json +1 -1
  21. package/runtime/plugins/opinion-manager/.codex-plugin/plugin.json +1 -1
  22. package/runtime/plugins/opinion-manager/plugin.json +1 -1
  23. package/runtime/plugins/opinion-manager/references/inbox.en.md +7 -2
  24. package/runtime/plugins/opinion-manager/references/inbox.md +7 -2
  25. package/runtime/plugins/opinion-manager/runtime/inbox.py +155 -7
  26. package/runtime/plugins/opinion-manager/runtime/inbox_text.py +19 -6
  27. package/runtime/plugins/opinion-manager/skills/opinion-manager/SKILL.md +4 -3
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](inbox.en.md) · **简体中文**
4
4
 
5
- 收件箱保存 Agent 在工作中发现的、尚待用户裁决的观点。它不是规则:不写入 `OPINION.md`、Profile 或锁,也不改变任何已确认内容。暂存无需确认,所有状态变化都需要用户明确表态。
5
+ 收件箱保存 Agent 在工作中发现的、尚待用户裁决的观点。它不是规则:除 `adopt --apply` 外,不写入 `OPINION.md`、Profile 或锁,也不改变任何已确认内容。暂存无需确认,所有状态变化都需要用户明确表态。
6
6
 
7
7
  ## 位置与隐私
8
8
 
@@ -15,7 +15,7 @@
15
15
 
16
16
  - `pending`:待确认,尚未生效。
17
17
  - `trial`:用户同意在本项目试行。hook 会把试行候选的全文随协议注入会话,Agent 按其工作;超过 `nudge.trial_expire_days`(默认 30)未转正回到 `pending`。
18
- - `formal`:用户同意转为正式规则。这里只记录意愿,写入 `OPINION.md` 仍走完整预览与确认。
18
+ - `formal`:用户已批准转为正式规则。**「已批准」不等于「已生效」**:`decide --to formal` 只记录状态,不写入 `OPINION.md`,后续会话不会加载它;输出里 `in_opinion: false`,并给出下一步 `inbox adopt …`。只有 `adopt --apply` 成功写入并读回后,候选才既是 `formal` 又已生效。存储状态名 `formal` 不变(改名会破坏已有收件箱数据)。
19
19
  - `held`:暂缓,不再提示。
20
20
  - `rejected`:丢弃。
21
21
 
@@ -26,6 +26,11 @@
26
26
  - `add --title --text --scope [--quote] [--client] [--session]`:暂存。标题 ≤120、正文 ≤1200、原话 ≤600 个字符;至少一个 `--scope`。内容相同(忽略空白与大小写)的候选合并,新原话追加为证据。
27
27
  - `list [--status a,b] [--session ID] [--unpresented]`:列出候选。
28
28
  - `decide <编号…> --to pending|trial|formal|held|rejected --confirmed [--note]`:裁决。没有 `--confirmed` 一律拒绝;多个编号要么全部成功,要么都不改。
29
+ - `adopt <编号…> [--apply --confirm SHA256]`:从采纳到写入的一步确认入口。用户在对话里明确说「采纳」时用它,不再单独 `decide`。
30
+ - 不带 `--apply`:只预览,零写入。把候选正文作为个人规则追加到项目现有 Profile 的自定义段(没有 Profile 时新建 `private.my-opinion@1.0.0`),经 `profile` 与 `compose` 同一套预览,返回完整 `content`(将成为 `OPINION.md` 的全文)、`blocked`(已有人工内容等需先处理的情况)和 `confirmation_sha256`。
31
+ - 带 `--apply --confirm <预览的 confirmation_sha256>`:用户确认后一次写入新 Profile 版本、`OPINION.md` 与 `opinion.lock.json`,用 `verify` 读回核对,最后才把候选置为 `formal`。预览之后候选、Profile 或 `OPINION.md` 有变化则指纹不符,拒绝并零写入。不使用 `--confirmed`:确认凭据是预览指纹。
32
+ - 多个编号一次预览、一次确认,全部成功或都不改;不存在的编号、已是 `formal` 的编号整体报错并点名。写入或读回失败时,`OPINION.md`、锁、本次新建的 Profile 文件恢复原状,候选状态不变。
33
+ - 已被 `decide --to formal` 记录、但尚未写入的候选:先 `decide --to pending --confirmed` 退回,再 `adopt`。
29
34
  - `present <编号…>`:记录已向用户展示过(hook 在发出确认请求时调用,避免同一候选反复提示)。
30
35
  - `expire --days N`:把试行超过 N 天的候选退回 `pending`。退回保留 `last_action_at`,因此仍计入“久未处理”。
31
36
  - `pending [--session ID]`:待确认项提供者,见下。
@@ -3,6 +3,8 @@
3
3
  收件箱记录的是“待用户裁决的候选”,不是规则。状态只有五种:pending(待确认)、trial(项目内试行)、
4
4
  formal(用户已同意转正,正文仍须经 opinion-manager 的完整预览与确认写入)、held(暂缓)、rejected(丢弃)。
5
5
  暂存(add)无需确认;任何状态变化(decide)都必须带 ``--confirmed``,表示用户已看过候选全文并明确表态。
6
+ ``formal`` 只表示“用户已批准”,尚未写入 OPINION.md;``adopt`` 把“预览 → 用户确认 → 写入 → 读回 → 置 formal”合成一步确认,
7
+ 内部只调用 versioned 的 profile / compose / verify(含各自的指纹校验),不另开写入路径。
6
8
  """
7
9
 
8
10
  from __future__ import annotations
@@ -16,6 +18,7 @@ import re
16
18
  import shlex
17
19
  import subprocess
18
20
  import tempfile
21
+ from argparse import Namespace
19
22
  from datetime import UTC, datetime
20
23
  from pathlib import Path
21
24
  from typing import Any
@@ -219,9 +222,150 @@ def decide(root: Path, args: argparse.Namespace) -> dict[str, Any]:
219
222
  candidate["history"].append({"at": stamp(moment), "to": args.to, "note": (args.note or "").strip()})
220
223
  changed.append(identity)
221
224
  save(root, data)
222
- reminder = say("formal_reminder") if args.to == "formal" else ""
223
- return {"ok": True, "status": "written", "changed": changed, "to": args.to, "reminder": reminder,
224
- "writes_stable_rules": False}
225
+ result = {"ok": True, "status": "written", "changed": changed, "to": args.to, "reminder": "",
226
+ "writes_stable_rules": False}
227
+ if args.to == "formal":
228
+ result["reminder"] = say("formal_reminder")
229
+ result["in_opinion"] = False
230
+ result["next_step"] = say("formal_next", command=adopt_command(root, list(args.ids)))
231
+ return result
232
+
233
+
234
+ def adopt_command(root: Path, ids: list[str], confirm: str | None = None) -> str:
235
+ tail = f" --apply --confirm {confirm}" if confirm else ""
236
+ return f"python3 {shlex.quote(str(RUNTIME))} inbox adopt {' '.join(shlex.quote(item) for item in ids)} --project {shlex.quote(str(root))}{tail} --lang {LANGUAGE}"
237
+
238
+
239
+ DEFAULT_PROFILE = "private.my-opinion"
240
+
241
+
242
+ def candidate_rule(candidate: dict[str, Any]) -> str:
243
+ return f"- **{candidate['title']}**(适用:{'、'.join(candidate['scopes'])}):{candidate['text']}"
244
+
245
+
246
+ def raw(path: Path) -> bytes | None:
247
+ versioned.safe_path(path)
248
+ return path.read_bytes() if path.exists() else None
249
+
250
+
251
+ def restore(path: Path, content: bytes | None) -> None:
252
+ if content is None:
253
+ path.unlink(missing_ok=True)
254
+ return
255
+ descriptor, name = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent)
256
+ try:
257
+ with os.fdopen(descriptor, "wb") as handle:
258
+ handle.write(content)
259
+ handle.flush()
260
+ os.fsync(handle.fileno())
261
+ os.chmod(name, 0o644)
262
+ os.replace(name, path)
263
+ finally:
264
+ Path(name).unlink(missing_ok=True)
265
+
266
+
267
+ def adoptable(data: dict[str, Any], ids: list[str]) -> list[dict[str, Any]]:
268
+ missing = [item for item in ids if item not in data["candidates"]]
269
+ if missing:
270
+ fail("err_missing", id=say("sep").join(missing))
271
+ done = [item for item in ids if data["candidates"][item]["status"] == "formal"]
272
+ if done:
273
+ fail("err_adopt_formal", ids=say("sep").join(done))
274
+ return [data["candidates"][item] for item in ids]
275
+
276
+
277
+ def adopt_plan(root: Path, items: list[dict[str, Any]], workdir: Path) -> dict[str, Any]:
278
+ """只读:与 profile / compose 的预览同一套函数,返回写入所需的全部输入与各自指纹。"""
279
+ workdir = workdir.resolve() # versioned.safe_path 拒绝含符号链接的路径;macOS 的临时目录在 /var -> /private/var 之下
280
+ lock_path = root / "opinion.lock.json"
281
+ current_lock = versioned.file_state(lock_path)
282
+ previous = versioned.validate_lock(json.loads(current_lock))["profile"] if current_lock is not None else None
283
+ custom = "\n\n".join(part for part in ((previous or {}).get("custom"), "\n".join(candidate_rule(item) for item in items)) if part)
284
+ custom_file = workdir / "custom.md"
285
+ custom_file.write_text(custom + "\n", encoding="utf-8")
286
+ identity, release = (previous["id"], previous["version"]) if previous else (DEFAULT_PROFILE, "0.0.0")
287
+ major, minor, patch = versioned.version(release)
288
+ while True:
289
+ patch += 1
290
+ number = f"{major}.{minor}.{patch}" if previous else "1.0.0"
291
+ target = root / ".opinion" / "profiles" / identity / "versions" / f"{number}.json"
292
+ if not target.exists():
293
+ break
294
+ from_profile = None
295
+ if previous:
296
+ from_profile = workdir / "previous-profile.json"
297
+ from_profile.write_text(versioned.pretty(previous), encoding="utf-8")
298
+ profile_args = Namespace(project=root, id=identity, version=number, template=[], rule=[], remove_template=[], remove_rule=[],
299
+ custom_file=custom_file, from_profile=from_profile, overrides_file=None, resolutions_file=None,
300
+ loading_file=None, remove_loading=False, catalog=versioned.PUBLIC_CATALOG, apply=False, confirm=None)
301
+ drafted = versioned.profile_command(profile_args)
302
+ if drafted["unresolved"]:
303
+ fail("err_adopt_unresolved", ids=say("sep").join(drafted["unresolved"]))
304
+ preview_file = workdir / "profile.json"
305
+ preview_file.write_text(versioned.pretty(drafted["profile"]), encoding="utf-8")
306
+ compose_args = Namespace(project=root, profile=preview_file, template=[], rule=[], custom_file=None, replace=False,
307
+ accept_current=None, apply=False, confirm=None)
308
+ composed = versioned.compose_command(compose_args)
309
+ fingerprint = versioned.digest({"candidates": [[item["id"], versioned.digest([item["title"], item["text"], item["scopes"]])] for item in items],
310
+ "profile": drafted["confirmation_sha256"], "compose": composed["confirmation_sha256"]})
311
+ return {"profile_args": profile_args, "compose_args": compose_args, "drafted": drafted, "composed": composed,
312
+ "fingerprint": fingerprint, "target": target, "profile_id": f"{identity}@{number}", "preview_file": preview_file}
313
+
314
+
315
+ def adopt(root: Path, args: argparse.Namespace) -> dict[str, Any]:
316
+ ids = list(dict.fromkeys(args.ids))
317
+ if not args.apply:
318
+ with tempfile.TemporaryDirectory(prefix="opinion-adopt-") as workdir:
319
+ plan = adopt_plan(root, adoptable(load(root), ids), Path(workdir))
320
+ composed = plan["composed"]
321
+ return {"ok": True, "status": "preview", "ids": ids, "profile": plan["profile_id"], "profile_path": str(plan["target"]),
322
+ "path": composed["path"], "content": composed["content"], "blocked": composed["blocked"],
323
+ "confirmation_sha256": plan["fingerprint"], "writes_stable_rules": False,
324
+ "next_step": say("adopt_next", command=adopt_command(root, ids, plan["fingerprint"]))}
325
+ if not args.confirm:
326
+ fail("err_adopt_confirm")
327
+ destination, lock_path = root / "OPINION.md", root / "opinion.lock.json"
328
+ with Locked(root) as data, tempfile.TemporaryDirectory(prefix="opinion-adopt-") as workdir:
329
+ items = adoptable(data, ids)
330
+ plan = adopt_plan(root, items, Path(workdir))
331
+ if plan["fingerprint"] != args.confirm:
332
+ fail("err_adopt_stale", fingerprint=plan["fingerprint"])
333
+ if plan["composed"]["blocked"]:
334
+ raise InboxError(plan["composed"]["blocked"])
335
+ before = {destination: raw(destination), lock_path: raw(lock_path)}
336
+ target = plan["target"]
337
+ created = []
338
+ for directory in (target.parent, target.parent.parent, target.parent.parent.parent):
339
+ if not directory.exists():
340
+ created.append(directory)
341
+ existed = target.exists()
342
+ try:
343
+ versioned.profile_command(Namespace(**{**vars(plan["profile_args"]), "apply": True, "confirm": plan["drafted"]["confirmation_sha256"]}))
344
+ versioned.compose_command(Namespace(**{**vars(plan["compose_args"]), "profile": target, "apply": True,
345
+ "confirm": plan["composed"]["confirmation_sha256"]}))
346
+ verified = versioned.verify_project(root)
347
+ if destination.read_text(encoding="utf-8") != plan["composed"]["content"]:
348
+ fail("err_adopt_readback")
349
+ moment = now()
350
+ for item in items:
351
+ item["status"] = "formal"
352
+ item["updated_at"] = item["last_action_at"] = stamp(moment)
353
+ item["trial_since"] = None
354
+ item["history"].append({"at": stamp(moment), "to": "formal", "note": f"adopted:{plan['profile_id']}"})
355
+ save(root, data)
356
+ except BaseException:
357
+ for path, content in before.items():
358
+ restore(path, content)
359
+ if not existed:
360
+ target.unlink(missing_ok=True)
361
+ for directory in created:
362
+ try:
363
+ directory.rmdir()
364
+ except OSError:
365
+ pass
366
+ raise
367
+ return {"ok": True, "status": "written", "ids": ids, "changed": ids, "profile": plan["profile_id"], "path": str(destination),
368
+ "verified": verified, "writes_stable_rules": True, "message": say("adopt_done", count=len(ids))}
225
369
 
226
370
 
227
371
  def present(root: Path, args: argparse.Namespace) -> dict[str, Any]:
@@ -340,9 +484,9 @@ def brief(root: Path, args: argparse.Namespace) -> dict[str, Any]:
340
484
 
341
485
 
342
486
  def add_command(subparsers: Any) -> None:
343
- parser = subparsers.add_parser("inbox", help="Project-private candidate inbox: stash, decide and summarize pending items; never writes rules")
344
- parser.add_argument("action", choices=("add", "list", "decide", "present", "expire", "pending", "brief", "exposure"))
345
- parser.add_argument("ids", nargs="*", help="candidate ids for decide / present")
487
+ parser = subparsers.add_parser("inbox", help="Project-private candidate inbox: stash, decide and summarize pending items; only adopt --apply writes OPINION.md, through the full preview and fingerprint")
488
+ parser.add_argument("action", choices=("add", "list", "decide", "adopt", "present", "expire", "pending", "brief", "exposure"))
489
+ parser.add_argument("ids", nargs="*", help="candidate ids for decide / adopt / present")
346
490
  parser.add_argument("--project", type=Path, required=True)
347
491
  parser.add_argument("--title")
348
492
  parser.add_argument("--text")
@@ -355,6 +499,8 @@ def add_command(subparsers: Any) -> None:
355
499
  parser.add_argument("--to", choices=DECIDABLE)
356
500
  parser.add_argument("--confirmed", action="store_true", help="the user has seen the full candidate and stated a decision explicitly")
357
501
  parser.add_argument("--note")
502
+ parser.add_argument("--apply", action="store_true", help="adopt: write OPINION.md and the lock (needs --confirm); without it adopt only previews")
503
+ parser.add_argument("--confirm", help="adopt: the confirmation_sha256 of the preview the user has reviewed")
358
504
  parser.add_argument("--days", type=int, help="expire: revert trials older than this many days to pending")
359
505
  parser.add_argument("--max-chars", type=int, default=6000, help="brief: size limit of the text")
360
506
  parser.add_argument("--output", choices=("json", "markdown"), default="json")
@@ -377,8 +523,10 @@ def run(args: argparse.Namespace) -> dict[str, Any] | str:
377
523
  return brief(root, args)
378
524
  if args.action == "exposure":
379
525
  return exposure(root)
380
- if args.action in ("decide", "present") and not args.ids:
526
+ if args.action in ("decide", "adopt", "present") and not args.ids:
381
527
  fail("err_ids")
528
+ if args.action == "adopt":
529
+ return adopt(root, args)
382
530
  if args.action == "decide":
383
531
  if not args.to:
384
532
  fail("err_need_to")
@@ -26,8 +26,8 @@ MESSAGES: dict[str, dict[str, str]] = {
26
26
  python3 {runtime} inbox add --project {project} --title "<标题>" --text "<完整规则>" --scope "<适用范围>" --quote "<用户原话>"{session} --lang {lang}
27
27
  一次性的任务要求、项目事实和命令不是候选。暂存不需要确认,也不会改变任何规则。
28
28
  3. 任务完成或即将完成时,若本次暂存了候选,用编号列表一次性请用户裁决:正式采纳 / 项目内试行 / 暂缓 / 丢弃。
29
- 用户明确表态后记录:python3 {runtime} inbox decide <编号…> --project {project} --to trial|formal|held|rejected --confirmed --lang {lang}
30
- 采纳为正式只改状态;写入 OPINION.md 须走 opinion-manager 的完整预览与确认。
29
+ 用户明确表态后记录:python3 {runtime} inbox decide <编号…> --project {project} --to trial|held|rejected --confirmed --lang {lang}
30
+ 用户说“采纳”时不要 decide:直接 python3 {runtime} inbox adopt <编号…> --project {project} --lang {lang} 预览(零写入),展示 content,用户确认后加 --apply --confirm <confirmation_sha256> 一次写入并读回。「已批准」不等于「已生效」:只有 adopt --apply 成功才写入 OPINION.md。
31
31
  4. 未经用户确认,不得把候选写入 OPINION.md,也不得把一次出现当作确认。
32
32
  5. inbox add 的结果带 notice(首次暂存时出现)时,用一句话如实转告用户。收件箱保存用户原话,可能含敏感信息;
33
33
  是否公开仓库、是否排除 .opinion/ 由用户决定,不要自行修改 .gitignore、删除或改写内容。
@@ -38,8 +38,8 @@ MESSAGES: dict[str, dict[str, str]] = {
38
38
  python3 {runtime} inbox add --project {project} --title "<title>" --text "<the full rule>" --scope "<where it applies>" --quote "<the user's own words>"{session} --lang {lang}
39
39
  One-off task requirements, project facts and commands are not candidates. Stashing needs no confirmation and changes no rule.
40
40
  3. When the task is done or nearly done and you stashed candidates in this session, ask the user once, as a numbered list: adopt as formal / trial in this project / hold / discard.
41
- After the user states a decision explicitly, record it: python3 {runtime} inbox decide <ids...> --project {project} --to trial|formal|held|rejected --confirmed --lang {lang}
42
- Adopting as formal only records the decision; writing it into OPINION.md goes through opinion-manager's full preview and confirmation.
41
+ After the user states a decision explicitly, record it: python3 {runtime} inbox decide <ids...> --project {project} --to trial|held|rejected --confirmed --lang {lang}
42
+ When the user says "adopt", do not decide: run python3 {runtime} inbox adopt <ids...> --project {project} --lang {lang} to preview (writes nothing), show the content, and once the user confirms add --apply --confirm <confirmation_sha256> to write and read back in one step. "Approved" is not "in effect": OPINION.md is written only when adopt --apply succeeds.
43
43
  4. Never write a candidate into OPINION.md without the user's confirmation, and never treat a single occurrence as confirmation.
44
44
  5. When the result of inbox add carries a notice (shown on the first stash), pass it on to the user in one sentence, as written. The inbox stores the user's own words, which may contain sensitive information; whether to make the repository public or to exclude .opinion/ is the user's decision. Do not edit .gitignore, delete or rewrite anything yourself.
45
45
  6. Relay and confirm in the language the user is using.""",
@@ -79,8 +79,21 @@ MESSAGES: dict[str, dict[str, str]] = {
79
79
  "err_ids": {"zh": "需要至少一个候选编号", "en": "At least one candidate id is required"},
80
80
  "err_need_to": {"zh": "decide 需要 --to", "en": "decide needs --to"},
81
81
  "err_need_days": {"zh": "expire 需要 --days", "en": "expire needs --days"},
82
- "formal_reminder": {"zh": "正式采纳只记录状态;写入 OPINION.md 须经 opinion-manager 的完整预览与确认。",
83
- "en": "Adopting as formal only records the status; writing into OPINION.md needs opinion-manager's full preview and confirmation."},
82
+ "formal_reminder": {"zh": "「已批准」不等于「已生效」:候选只是记为 formal,尚未写入 OPINION.md,后续会话不会加载它;下一步是 inbox adopt。",
83
+ "en": "\"Approved\" is not \"in effect\": the candidate is only recorded as formal and is not in OPINION.md yet, so later sessions do not load it. The next step is inbox adopt."},
84
+ "formal_next": {"zh": "尚未写入 OPINION.md;下一步预览并写入:{command}",
85
+ "en": "Not written to OPINION.md yet; next, preview and write it: {command}"},
86
+ "adopt_next": {"zh": "向用户展示 content 并取得确认后运行:{command}",
87
+ "en": "Show the user the content and, once they confirm, run: {command}"},
88
+ "adopt_done": {"zh": "已写入 OPINION.md 并读回核对;{count} 条候选已生效。", "en": "Written to OPINION.md and read back; {count} candidate(s) now in effect."},
89
+ "err_adopt_formal": {"zh": "候选已是 formal:{ids}(已批准或已写入);若尚未写入 OPINION.md,先用 decide --to pending --confirmed 退回再采纳",
90
+ "en": "Already formal: {ids} (approved or already written). If it is not in OPINION.md yet, move it back with decide --to pending --confirmed, then adopt"},
91
+ "err_adopt_confirm": {"zh": "写入需要先预览并让用户确认:去掉 --apply 预览,用户确认后加 --apply --confirm <confirmation_sha256>",
92
+ "en": "Writing needs a preview the user has confirmed: preview without --apply, then add --apply --confirm <confirmation_sha256> once they agree"},
93
+ "err_adopt_stale": {"zh": "预览之后内容已变化(候选、Profile 或 OPINION.md),未写入;请重新预览。当前指纹:{fingerprint}",
94
+ "en": "The content changed since the preview (candidates, Profile or OPINION.md); nothing was written. Preview again. Current fingerprint: {fingerprint}"},
95
+ "err_adopt_unresolved": {"zh": "Profile 升级存在未确认的冲突:{ids}", "en": "The Profile upgrade has unresolved conflicts: {ids}"},
96
+ "err_adopt_readback": {"zh": "写入后读回的 OPINION.md 与预览不一致,已回滚", "en": "The OPINION.md read back differs from the preview; rolled back"},
84
97
  "list_empty": {"zh": "没有符合条件的候选。", "en": "No matching candidates."},
85
98
  "list_rule": {"zh": " - 规则:{text}", "en": " - Rule: {text}"},
86
99
  "list_scope": {"zh": " - 适用:{scopes}", "en": " - Applies to: {scopes}"},
@@ -59,9 +59,10 @@ description: Generate, compose, review and maintain behavior rules between the u
59
59
 
60
60
  - **暂存**:用户在工作中表达长期偏好、对你行为的纠正或规则(“以后都……”“不要再……”“记住……”)时,立即用 `inbox add` 暂存标题、完整规则、适用范围和用户原话。不打断当前任务,不需要确认。一次性的任务要求、项目事实和命令不是候选。宁可多暂存,裁决环节会过滤。
61
61
  - **匹配**:实施前读取 OPINION.md;用户已同意试行的候选(`inbox list --status trial`,hook 会随协议注入)同样遵循,交付时说明是否适用。
62
- - **确认**:任务完成或即将完成时,把本次会话新增的候选用编号列表一次性交给用户:正式采纳 / 项目内试行 / 暂缓 / 丢弃。用户明确表态后用 `inbox decide … --confirmed` 记录;每个会话集中确认一次,不逐条追问。
63
- - **转正式**:`formal` 只记录用户意愿。写入 OPINION.md 仍走上文的完整预览与确认流程,候选正文作为个人规则输入。
64
- - **边界**:`inbox` 不写 OPINION.md、Profile 或锁;重复出现不等于确认。试行超过设定天数未转正会回到待确认。
62
+ - **确认**:任务完成或即将完成时,把本次会话新增的候选用编号列表一次性交给用户:正式采纳 / 项目内试行 / 暂缓 / 丢弃。用户明确表态后记录:试行 / 暂缓 / 丢弃用 `inbox decide … --confirmed`;用户说「采纳」时直接用 `inbox adopt`,不先 `decide`。每个会话集中确认一次,不逐条追问。
63
+ - **采纳并写入**:用户说「采纳」后,运行 `inbox adopt <编号…>`(不带 `--apply`,零写入)预览:候选正文作为个人规则输入,走与 `profile` / `compose` 相同的完整流程,一次展示 `content`;用户确认后追加 `--apply --confirm <confirmation_sha256>`,一次写入并 `verify` 读回,成功后候选才记为 `formal`。多条候选一次预览、一次确认,全部成功或都不改。
64
+ - **已批准不等于已生效**:`decide --to formal` 只记录状态,输出 `in_opinion: false` 与 `next_step`,`OPINION.md` 未写入,后续会话不会加载;必须继续 `inbox adopt`。
65
+ - **边界**:除 `adopt --apply`(须带预览指纹)外,`inbox` 不写 OPINION.md、Profile 或锁;重复出现不等于确认。试行超过设定天数未转正会回到待确认。
65
66
  - **隐私**:收件箱 `.opinion/inbox.json` 保存用户原话,可能含敏感信息,建议项目保持私有。`inbox add` 返回 `notice` 时如实转告用户;是否公开仓库、是否排除 `.opinion/` 由用户决定,不要替用户决定,也不要自行修改 `.gitignore`。
66
67
  - **语言**:提示与协议有中文、英文两种,命令带 `--lang zh|en`;向用户转告和确认时使用用户正在使用的语言。候选内容是用户自己的话,不翻译。
67
68
  - **未决汇总**:开新会话时 agent-pack 按阈值提示待确认数量与久未处理的天数;用户可在 Project Profile 的 `opinion.nudge` 或 `~/.config/agenthelm/config.json` 的 `nudge` 调整,或用 `AGENTHELM_NO_NUDGE=1` 关闭。