flower-trellis 0.6.12-beta.3 → 0.6.12-beta.5

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.
@@ -50,8 +50,8 @@
50
50
 
51
51
  ## 共用展示规则
52
52
 
53
- - 计划与结果模板中的字段行必须使用 `- **字段**:值` 列表项。这些行在 Markdown 段落内会被折叠成一段,不得改回裸段落行,也不得依赖行尾空格换行。
54
- - 计划中的「任务记录」是与各仓库区平级的独立 `###` 小节,仅普通模式且存在活动任务时整节展示;不再用方括号条件行代替小节标题。
53
+ - 计划与结果须保留模板标题层级、字段顺序及 `- **字段**:值` 列表格式,仅替换占位内容、按条件省略;不得改成摘要表格、裸段落或依赖行尾空格换行,简洁要求不适用于模板结构。
54
+ - 「任务记录」仅普通模式有活动任务时展示,须用与仓库区平级的 `###` 小节,不用方括号条件行代替标题。
55
55
  - 计划中单仓 `planned` 不超过 8 个文件时完整列出。
56
56
  - 超过 8 个时按目录归组,最多 12 行;用户要求展开时展示同一 exact set。
57
57
  - 顶部仓库/commit/file 总数包含独立任务记录提交所在 Git root、该提交及其 exact files;任务记录文件使用相同的 8 文件展示阈值和展开规则。
@@ -50,8 +50,8 @@
50
50
 
51
51
  ## 共用展示规则
52
52
 
53
- - 计划与结果模板中的字段行必须使用 `- **字段**:值` 列表项。这些行在 Markdown 段落内会被折叠成一段,不得改回裸段落行,也不得依赖行尾空格换行。
54
- - 计划中的「任务记录」是与各仓库区平级的独立 `###` 小节,仅普通模式且存在活动任务时整节展示;不再用方括号条件行代替小节标题。
53
+ - 计划与结果须保留模板标题层级、字段顺序及 `- **字段**:值` 列表格式,仅替换占位内容、按条件省略;不得改成摘要表格、裸段落或依赖行尾空格换行,简洁要求不适用于模板结构。
54
+ - 「任务记录」仅普通模式有活动任务时展示,须用与仓库区平级的 `###` 小节,不用方括号条件行代替标题。
55
55
  - 计划中单仓 `planned` 不超过 8 个文件时完整列出。
56
56
  - 超过 8 个时按目录归组,最多 12 行;用户要求展开时展示同一 exact set。
57
57
  - 顶部仓库/commit/file 总数包含独立任务记录提交所在 Git root、该提交及其 exact files;任务记录文件使用相同的 8 文件展示阈值和展开规则。
@@ -54,7 +54,7 @@ When applicable, also validate indexes/links, code signatures, or project-specif
54
54
  ### Workflow Disposition
55
55
 
56
56
  - Interactive: follow the continuation decision made by Check-All's `Interactive Post-Check Stop Gate`, including strict pass and accepted-risk pass. A passed check defaults to this skill in the same turn after the Check-All report or brief acceptance acknowledgment; an explicit check-only or stop-after-check request keeps the chain stopped. When the user later says “下一步”, “继续”, `next`, `continue`, or an equivalent continuation intent, resume the deliberately stopped chain. Reuse a currently valid `spec_update_result` instead of evaluating again.
57
- - Interactive completion, including direct Git: when the gate permits continuation, a `no-op` or `written` result must load `trellis-push` in the same turn and present its single confirmation plan; if there are no deliverable changes, report that no commit is needed instead of manufacturing an empty commit. Only `no-op` or `written` may proceed to `trellis-push`; `needs-review` stops and must not generate a Push plan. Reuse valid acceptance evidence internally without repeating unchanged risks. Default continuation does not authorize Git writes; do not infer risk acceptance or Git write authorization from unrelated history, summaries, dirty state, or an auto-loop internal `commit-only`.
57
+ - Interactive completion, including direct Git: when the gate permits continuation, a `no-op` or `written` result must load `trellis-push` in the same turn and present its single confirmation plan; if there are no deliverable changes, report that no commit is needed instead of manufacturing an empty commit. Only `no-op` or `written` may proceed to `trellis-push`; `needs-review` stops and must not generate a Push plan. Reuse valid acceptance evidence internally without repeating unchanged risks. Default continuation does not authorize Git writes; do not infer risk acceptance or Git write authorization from unrelated history, summaries, dirty state, or an auto-loop internal `commit-only`. Do not treat an agent-authored "no commit/push" restriction in task artifacts or ordinary implementation-plan approval as an explicit user stop instruction; stopping this handoff requires an explicit user instruction, and pending Git write authorization does not block presenting the Push plan.
58
58
  - Validated auto-loop: for `no-op` or `written`, execute `record --action run_spec_update --result ok`; only after a successful record immediately run `next`. If record returns `status=retryable` with an artifact recovery diagnosis, follow `trellis-auto-loop` recovery instructions in the same turn, then resubmit the original truthful record; do not advance or request user continuation. For `needs-review`, execute `record --action run_spec_update --result blocked --failure-type spec-needs-review`; never disguise it as `no-op`.
59
59
  - Untracked: keep the cursor at `spec` for `needs-review`. For `no-op` or `written`, run `untracked_flow.py advance --stage push`. Any later product edit returns the cursor to `implement`; the helper does not validate or preserve owner evidence.
60
60
 
@@ -33,6 +33,7 @@ GC_JOURNAL_SCHEMA_VERSION = 1
33
33
  GC_JOURNAL_RELATIVE = ".trellis/.runtime/task-gc-transaction.json"
34
34
  EXACT_COMMIT_JOURNAL_SCHEMA_VERSION = 1
35
35
  EXACT_COMMIT_JOURNAL_RELATIVE = ".trellis/.runtime/task-maintenance-commit.json"
36
+ FILESET_DIAGNOSTIC_RELATIVE = ".trellis/.runtime/task-maintenance-fileset.json"
36
37
  RECOMPUTABLE_BLOCKER_CODES = {
37
38
  "ambiguous-child",
38
39
  "decision-log-invalid",
@@ -647,6 +648,62 @@ def _run_git_with_index(
647
648
  return 1, "", str(error)
648
649
 
649
650
 
651
+ def _stage_exact_paths(
652
+ repo_root: Path,
653
+ index_file: Path,
654
+ paths: list[str],
655
+ expected_files: set[str],
656
+ ) -> tuple[int, str, str]:
657
+ """在隔离 index 中暂存候选,并保留移动后被忽略的预期文件。
658
+
659
+ Args:
660
+ repo_root: Git worktree 根目录。
661
+ index_file: 本次事务的临时 index。
662
+ paths: 允许操作的候选路径。
663
+ expected_files: 已确认应出现在提交中的精确文件集。
664
+
665
+ Returns:
666
+ Git 的退出码、标准输出和错误输出。
667
+ """
668
+ code, tracked, error = _run_git_with_index(["ls-files", "-z", "--", *paths], repo_root, index_file)
669
+ if code != 0:
670
+ return code, tracked, error
671
+ tracked_files = [name for name in tracked.split("\0") if name]
672
+ tracked_paths = [
673
+ path for path in paths
674
+ if any(name == path or name.startswith(path + "/") for name in tracked_files)
675
+ ]
676
+ result = (0, "", "")
677
+ # 新版 Git 拒绝 add -u 中未跟踪的目标路径;全新候选则直接进入下方精确新增。
678
+ if tracked_paths:
679
+ result = _run_git_with_index(["add", "-u", "--", *tracked_paths], repo_root, index_file)
680
+ if result[0] != 0:
681
+ return result
682
+ code, untracked, error = _run_git_with_index(
683
+ ["ls-files", "--others", "--exclude-standard", "-z", "--", *paths], repo_root, index_file,
684
+ )
685
+ if code != 0:
686
+ return code, untracked, error
687
+ existing = sorted({
688
+ path for path in expected_files
689
+ if (repo_root / path).is_file() or (repo_root / path).is_symlink()
690
+ } | {path for path in untracked.split("\0") if path})
691
+ # 原目录的白名单可能在归档后失效;仅对已确认的文件强制暂存,保留额外文件校验。
692
+ # NUL 清单避免大任务超过 argv 限制,literal 模式保留路径中的通配符等字符。
693
+ if existing:
694
+ pathspec = index_file.with_name("expected-paths")
695
+ pathspec.write_bytes(("\0".join(existing) + "\0").encode("utf-8"))
696
+ result = _run_git_with_index(
697
+ ["--literal-pathspecs", "add", "--force", f"--pathspec-from-file={pathspec}", "--pathspec-file-nul"],
698
+ repo_root,
699
+ index_file,
700
+ )
701
+ if result[0] != 0:
702
+ return result
703
+ # 可见的新文件仍纳入暂存,交给原有文件集校验发现并发新增,不能静默忽略。
704
+ return result
705
+
706
+
650
707
  def _exact_commit_journal_path(repo_root: Path) -> Path:
651
708
  """返回共享精确提交收尾记录路径。"""
652
709
  return repo_root / EXACT_COMMIT_JOURNAL_RELATIVE
@@ -777,10 +834,11 @@ def _worktree_matches_exact_commit(repo_root: Path, journal: dict[str, Any]) ->
777
834
  return False
778
835
  # read-tree 生成的临时 index 没有工作树 stat 缓存,直接 diff-files 会把
779
836
  # 内容相同的文件误判为修改;在隔离 index 重加候选后比较整棵 tree。
780
- code, _, _ = _run_git_with_index(
781
- ["add", "-A", "--", *journal["paths"]],
837
+ code, _, _ = _stage_exact_paths(
782
838
  repo_root,
783
839
  index_file,
840
+ journal["paths"],
841
+ set(journal["expectedFiles"]),
784
842
  )
785
843
  if code != 0:
786
844
  return False
@@ -947,10 +1005,11 @@ def _commit_exact_paths(
947
1005
  code, _, error = _run_git_with_index(["read-tree", old_head], repo_root, index_file)
948
1006
  if code != 0:
949
1007
  raise TaskLifecycleError("git-index-init-failed", error.strip() or "无法初始化 maintenance 临时 index")
950
- code, _, error = _run_git_with_index(
951
- ["add", "-A", "--", *unique_paths],
1008
+ code, _, error = _stage_exact_paths(
952
1009
  repo_root,
953
1010
  index_file,
1011
+ unique_paths,
1012
+ expected_files,
954
1013
  )
955
1014
  if code != 0:
956
1015
  raise TaskLifecycleError("git-add-failed", error.strip() or "无法暂存 maintenance 路径")
@@ -961,9 +1020,26 @@ def _commit_exact_paths(
961
1020
  )
962
1021
  staged_files = {path for path in staged.split("\0") if path}
963
1022
  if code != 0 or staged_files != expected_files:
1023
+ missing = sorted(expected_files - staged_files)
1024
+ extra = sorted(staged_files - expected_files)
1025
+ diagnostic = repo_root / FILESET_DIAGNOSTIC_RELATIVE
1026
+ try:
1027
+ diagnostic.parent.mkdir(parents=True, exist_ok=True)
1028
+ _atomic_write_bytes(diagnostic, json.dumps({
1029
+ "expected": sorted(expected_files), "actual": sorted(staged_files),
1030
+ "missing": missing, "extra": extra, "stderr": error,
1031
+ }, ensure_ascii=False, indent=2).encode("utf-8"))
1032
+ detail = f";完整诊断:{FILESET_DIAGNOSTIC_RELATIVE}"
1033
+ except OSError:
1034
+ detail = ";完整诊断保存失败"
1035
+ summary = (
1036
+ f"maintenance staged 文件集不匹配:预期 {len(expected_files)} 项,实际 {len(staged_files)} 项"
1037
+ f";缺失 {len(missing)} 项 {json.dumps([path[:160] for path in missing[:3]], ensure_ascii=False)}"
1038
+ f";多出 {len(extra)} 项 {json.dumps([path[:160] for path in extra[:3]], ensure_ascii=False)}"
1039
+ )
964
1040
  raise TaskLifecycleError(
965
1041
  "git-fileset-mismatch",
966
- error.strip() or f"maintenance staged 文件集不匹配:{sorted(staged_files)}",
1042
+ summary + detail,
967
1043
  )
968
1044
  code, tree, error = _run_git_with_index(["write-tree"], repo_root, index_file)
969
1045
  if code != 0 or not tree.strip():
@@ -1,7 +1,7 @@
1
1
  {
2
- "syncedAt": "2026-10-22T09:39:09.087Z",
2
+ "syncedAt": "2026-10-26T08:14:04.725Z",
3
3
  "syncedFrom": "vendor/skill-garden",
4
- "sourceCommit": "9cbf7989028e4ecfb64753d4616b9dbcb97a1730",
4
+ "sourceCommit": "b8739aad923c36b1897c56ea492a37b2288e7400",
5
5
  "common": {
6
6
  "codexSkills": [
7
7
  "aliyun-ops",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flower-trellis",
3
- "version": "0.6.12-beta.3",
3
+ "version": "0.6.12-beta.5",
4
4
  "description": "一键安装/升级 Trellis 并自动融合 skill-garden 强化包(默认 Claude + agents)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -71,9 +71,9 @@
71
71
  "commit-and-tag-version": "^12.7.3"
72
72
  },
73
73
  "flowerReleaseNotes": {
74
- "version": "0.6.12-beta.3",
74
+ "version": "0.6.12-beta.5",
75
75
  "source": "CHANGELOG.md",
76
- "body": "### ✨ 新功能 Features\n\n* **hooks:** 注入简洁设计原则并精简启动上下文 ([92fb5f0](https://github.com/SilentFlower/flower-trellis/commit/92fb5f06671e17cf41af753f5faa99ba68db183e))\n\n\n### ♻️ 重构 Refactor\n\n* **route:** 同步静默展示规则与快照 ([ff8659d](https://github.com/SilentFlower/flower-trellis/commit/ff8659dcc66789a3f77656167131c7a76b3dd0d0))",
76
+ "body": "### 🐛 修复 Bug Fixes\n\n* **push:** 保留规定的计划与结果模板结构 ([f7346b0](https://github.com/SilentFlower/flower-trellis/commit/f7346b01765c2415555ad7ceae7a8891e7aead04))",
77
77
  "truncated": false
78
78
  },
79
79
  "optionalDependencies": {
@@ -10,6 +10,7 @@ import os
10
10
  import re
11
11
  import subprocess
12
12
  import sys
13
+ import tempfile
13
14
  from importlib.util import module_from_spec, spec_from_file_location
14
15
  from pathlib import Path
15
16
 
@@ -17,6 +18,8 @@ from pathlib import Path
17
18
  PARTS = ("state", "rules", "stages")
18
19
  HOOKS = (".codex/hooks/session-start.py", ".claude/hooks/session-start.py")
19
20
  MAX_PART_CHARS = 8000
21
+ MAINTENANCE_MESSAGE_MAX_CHARS = 600
22
+ MAINTENANCE_DIAGNOSTIC_RELATIVE = ".trellis/.runtime/task-maintenance-hook.json"
20
23
  WORKFLOW_BLOCK = re.compile(r"<trellis-workflow>\n(.*?)\n</trellis-workflow>\n*", re.DOTALL)
21
24
  ASTRA_MODEL = "gpt-6-astra"
22
25
  SOL_MODEL = "gpt-6-sol"
@@ -209,6 +212,40 @@ def _run_workflow_state_refresh(root: Path, hook: str, hook_input: dict) -> str:
209
212
  return context
210
213
 
211
214
 
215
+ def _maintenance_diagnostic(root: Path, message: str, stdout: str = "", stderr: str = "") -> str:
216
+ """保存最后一次完整诊断,并返回有长度上限的单行提示。
217
+
218
+ @param root: 当前部署项目根目录。
219
+ @param message: 面向用户的错误或警告。
220
+ @param stdout: maintenance 子进程的完整标准输出。
221
+ @param stderr: maintenance 子进程的完整错误输出。
222
+ @return: 不超过提示预算的摘要,包含诊断位置或保存失败说明。
223
+ """
224
+ diagnostic = root / MAINTENANCE_DIAGNOSTIC_RELATIVE
225
+ temporary = None
226
+ try:
227
+ diagnostic.parent.mkdir(parents=True, exist_ok=True)
228
+ descriptor, temporary = tempfile.mkstemp(prefix=".maintenance-", dir=str(diagnostic.parent))
229
+ with os.fdopen(descriptor, "w", encoding="utf-8") as handle:
230
+ json.dump({"message": message, "stdout": stdout, "stderr": stderr}, handle, ensure_ascii=False)
231
+ os.replace(temporary, str(diagnostic))
232
+ suffix = f";完整诊断:{MAINTENANCE_DIAGNOSTIC_RELATIVE}"
233
+ except OSError:
234
+ suffix = ";完整诊断保存失败"
235
+ finally:
236
+ if temporary is not None:
237
+ try:
238
+ os.unlink(temporary)
239
+ except OSError:
240
+ pass
241
+ # 原始输出只落盘;systemMessage 和 stderr 都不能再次回显整份文件列表。
242
+ summary = " ".join(message.splitlines())
243
+ budget = MAINTENANCE_MESSAGE_MAX_CHARS - len(suffix)
244
+ if len(summary) > budget:
245
+ summary = summary[:budget - 1] + "…"
246
+ return summary + suffix
247
+
248
+
212
249
  def _run_task_maintenance(root: Path) -> str:
213
250
  """运行旧任务收敛与三天物理 GC,并返回紧凑诊断。
214
251
 
@@ -229,22 +266,26 @@ def _run_task_maintenance(root: Path) -> str:
229
266
  check=False,
230
267
  )
231
268
  except OSError as error:
232
- return f"task maintenance 无法启动:{error}"
233
- stderr = result.stderr.decode("utf-8", errors="replace").strip()
234
- if stderr:
235
- print(stderr, file=sys.stderr)
236
- stdout = result.stdout.decode("utf-8-sig").strip()
269
+ return _maintenance_diagnostic(root, f"task maintenance 无法启动:{error}", stderr=str(error))
270
+ stderr = result.stderr.decode("utf-8", errors="replace")
271
+ stdout = result.stdout.decode("utf-8-sig")
237
272
  if result.returncode != 0:
238
- return f"task maintenance 失败:{stderr or stdout or f'退出码 {result.returncode}'}"
239
- if not stdout:
273
+ return _maintenance_diagnostic(
274
+ root, f"task maintenance 失败(退出码 {result.returncode}):{stderr or stdout}", stdout, stderr,
275
+ )
276
+ if not stdout.strip():
277
+ if stderr:
278
+ return _maintenance_diagnostic(root, "task maintenance:子进程有诊断输出", stdout, stderr)
240
279
  return ""
241
280
  try:
242
281
  payload = json.loads(stdout)
243
282
  except json.JSONDecodeError as error:
244
- return f"task maintenance 输出损坏:{error}"
283
+ return _maintenance_diagnostic(root, f"task maintenance 输出损坏:{error}", stdout, stderr)
245
284
  if not isinstance(payload, dict):
246
- raise ValueError("task maintenance 输出必须为 JSON 对象")
285
+ return _maintenance_diagnostic(root, "task maintenance 输出必须为 JSON 对象", stdout, stderr)
247
286
  if payload.get("status") == "busy":
287
+ if stderr:
288
+ return _maintenance_diagnostic(root, "task maintenance:子进程有诊断输出", stdout, stderr)
248
289
  return ""
249
290
  reconciliation = payload.get("reconciliation") if isinstance(payload.get("reconciliation"), dict) else {}
250
291
  gc_result = payload.get("gc") if isinstance(payload.get("gc"), dict) else {}
@@ -269,7 +310,12 @@ def _run_task_maintenance(root: Path) -> str:
269
310
  for item in (reconciliation, gc_result):
270
311
  if item.get("error"):
271
312
  messages.append(str(item["error"]))
272
- return "task maintenance:" + ";".join(messages) if messages else ""
313
+ message = "task maintenance:" + ";".join(messages) if messages else ""
314
+ if stderr or any(item.get("error") for item in (reconciliation, gc_result)) or len(message) > MAINTENANCE_MESSAGE_MAX_CHARS:
315
+ return _maintenance_diagnostic(root, message or "task maintenance:子进程有诊断输出", stdout, stderr)
316
+ if payload.get("status") == "error":
317
+ return _maintenance_diagnostic(root, f"task maintenance 失败:{payload.get('message') or payload.get('reason')}", stdout, stderr)
318
+ return message
273
319
 
274
320
 
275
321
  def render_part(root: Path, hook: str, part: str, hook_input: dict) -> dict | None: