@pennixrv/trellis 0.7.2-beta.30 → 0.7.2-beta.31

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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "0.7.2-beta.31",
3
+ "description": "Delegated Hook actor routing and coherent controller workflow",
4
+ "breaking": false,
5
+ "recommendMigrate": false,
6
+ "changelog": "Validate delegated node context before controller turn/session handling and resolve stable locators through the native validator. Keep readonly turn help/show on ordinary tool permissions without write tickets. Correct target-mode acceptance and proportional task guidance; close complex withdrawal routes without implementation omission approval. Add bilingual beta delegation guidance with centralized parent/child control.",
7
+ "migrations": [],
8
+ "notes": "No persisted delegation-format or task-data migration. Update project assets through the native preview/conflict-review route; do not initialize source submodules for delegation."
9
+ }
@@ -20,12 +20,19 @@ def main() -> int:
20
20
  raise ValueError("invalid hook envelope")
21
21
  if event.get("agent_id") is not None:
22
22
  return 0
23
- root = Path(str(event.get("cwd", os.getcwd()))).resolve()
23
+ cwd = Path(str(event.get("cwd", os.getcwd()))).resolve()
24
+ root = Path(__file__).resolve().parents[2] if os.environ.get("TRELLIS_DELEGATION_CONTEXT") else cwd
24
25
  while not (root / ".trellis").is_dir():
25
26
  if root == root.parent:
26
27
  return 0
27
28
  root = root.parent
28
29
  sys.path.insert(0, str(root / ".trellis/scripts"))
30
+ if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
31
+ from common.worktree_delegation import node_context # type: ignore[import-not-found]
32
+
33
+ os.chdir(cwd)
34
+ node_context()
35
+ return 0
29
36
  from common.task_turn import begin, interrupt, observe, question_started, stop # type: ignore[import-not-found]
30
37
 
31
38
  name = event.get("hook_event_name")
@@ -2,9 +2,11 @@
2
2
 
3
3
  开始前核验当前 `implementation_contract`、实施授权、路线 revision、必要依赖和执行基线。使用 `trellis-before-dev` 读取目标仓库实际适用的规范;按组件 owner 合同选择主工作树或已批准的独立写入路线。调用项目任务 `start` 只在实施授权有效时将任务置为 `in_progress`。
4
4
 
5
+ 跨源码目标实施时,当前控制项目的 Task CLI 持有父子任务、授权和接受;组件仓是准确源码目标,读取其规范不等于切换任务权威。委派按控制根绑定子任务,不因目标是 submodule 而初始化另一套任务治理。
6
+
5
7
  实施阶段为 `blocked` 或 `waiting_user` 时,先记录真实答复或解除证据并经原生 `phase resume` 恢复,再重新核验准入与 revision,不在等待态直接接受结果。答案返回、单项验证通过或进度汇报不等于本轮结束;继续合同内独立且已授权的工作,只暂停依赖未决输入或失败前置的动作。宿主要求普通文本取得必要输入时,直接提出明确问题,不用等待声明代替提问。`delegate-start` 核验父任务已有的 ownership 围栏和子任务状态;存在未消费交接、当前会话不符合已有 ownership 记录,或子任务已完成、取消时,不启动或复用委派执行。没有 ownership 记录的任务不具备默认会话独占保护。
6
8
 
7
- 父授权有效且本轮允许委派写入时,先加载 `trellis-worktree-delegation`,通过其原生新协议入口冻结明确目标、设置与能力要求,再准备、核验 ready、执行和观察。委派节点沿 `TRELLIS_DELEGATION_CONTEXT` 与共享节点方法执行本包,不进入主控阶段或新建任务。输入漂移先保全并核对授权;未知创建或发送只做原生 inspect 和显式 recover,不覆盖映射或重放。结果由 owner 审查并在目标分支 merge/FF,验证 ancestry 后再显式核销;idle/cancel 不替代 writer 停止证据。
9
+ 父授权有效且本轮允许委派写入时,先加载 `trellis-worktree-delegation`,通过原生入口冻结明确目标、设置与能力要求,再准备、核验 ready、执行和观察。directory 复用批准的现有 checkout/submodule;worktree 使用独立执行树。委派节点沿 `TRELLIS_DELEGATION_CONTEXT` 与共享节点方法执行本包,不进入主控阶段、新建任务或登记主控回合退出。输入漂移先保全并核对授权;未知创建或发送只做原生 inspect 和显式 recover,不覆盖映射或重放。结果由 owner 审查:directory 接受批准分支上的准确提交,不假造 merge;worktree 才按实际需要 merge/FF 并验证准确 ancestry。随后显式核销;idle/cancel 不替代 writer 停止证据。
8
10
 
9
11
  按合同的依赖和优先级选取当前工作包,实施满足目标的最小变更,并运行与风险和影响相称的局部验证。主工作树主代理核对来源、revision、Git 基线、差异和结果后接受工作包。多包任务按合同集成;单一交付不人为拆分。Trellis Teamwork 仅用于冻结计划下的只读比较或评议,不能改写任务状态或接受实施结果。实际写入委派依父任务规定使用 Trellis 受控入口与 Paseo;各组件源码仍在 owner 仓库内修改。
10
12
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  在父任务已授权的实施阶段委派完整工作包。使用项目原生 `task.py delegate-* --help` 核对参数;不手改 record、映射、输入或许可。Paseo 拥有原生 Agent、workspace、队列和 turn;Trellis 拥有批准包、目标、Git 校验和成果接受。一个 controller task 是控制权威,节点不创建第二套阶段状态。
4
4
 
5
+ 父任务、子任务及其 PRD/设置/接受记录都位于控制主项目的 `.trellis/tasks/`,由该控制根的 Task CLI 管理;target_repo 只绑定源码位置。组件 owner 负责目标源码和测试,不因此另建组件本地任务。目标可以没有 Trellis,不以初始化 submodule 或写入目标项目治理资产作为委派前置。
6
+
7
+ 目标项目已有 Trellis 时仍按节点职责执行,不重跑目标主控阶段或登记其回合退出。主控的 Hook 退出保护与节点候选报告分别治理不同对象;有效委派上下文负责分流,失效时保全并报告,不回退成普通主控。节点不向用户逐步汇报;准备、队列、结果及真实权限阻断仍通过原生回执和指定候选交回,主控负责对外沟通。
8
+
5
9
  ## 先批准工作包,再绑定目标
6
10
 
7
11
  读取 adapter 的 capability,固定实际支持的 Codex model、effort 和 `full-access` mode。sandbox、approval、reviewer、context 保留 `native_default`。固定角色为 `.trellis/agents/delegated-worktree-primary-agent.md`,节点方法为 `.trellis/agents/worktree-delegation-node.md`。可选 adapter 需要 Node >=22.16.0 和原生 SQLite 能力,基础 Trellis 不因此增加依赖。已安装 Lifecycle 时,写入准入使用 `pennix config paseo --json` 的唯一配置 home;不匹配或配置不可读时走 owner 原生修复,不绕过政策。
@@ -264,6 +264,23 @@ def main() -> int:
264
264
  hook_input = {}
265
265
 
266
266
  command, response = _pending_shell_command(hook_input)
267
+ if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
268
+ # Nodes never receive controller session/turn tickets, even in an initialized target.
269
+ if not _extract_task_subcommands(command) and not re.search(r"\btask\.py[\"']?\s+turn\b", command):
270
+ return 0
271
+ try:
272
+ root = Path(__file__).resolve().parents[2]
273
+ _load_active_task_resolver(root)
274
+ from common.worktree_delegation import node_context # type: ignore[import-not-found]
275
+
276
+ os.chdir(str(hook_input.get("cwd") or os.getcwd()))
277
+ node_context()
278
+ except Exception:
279
+ print(json.dumps({"hookSpecificOutput": {
280
+ "hookEventName": "PreToolUse", "permissionDecision": "deny",
281
+ "permissionDecisionReason": "Delegated node blocked: invalid/stale context; report to controller.",
282
+ }}, ensure_ascii=False))
283
+ return 0
267
284
  platform_name = _host_platform_name()
268
285
  if platform_name == "codex" and re.match(
269
286
  r"""^\s*(?:["']?[^ \t"']*/)?python(?:3)?["']?\s+(?:-X\s+utf8\s+)?(?:"[^"]*task\.py"|'[^']*task\.py'|[^ \t]+task\.py)\s+turn\b""",
@@ -278,6 +295,8 @@ def main() -> int:
278
295
  try:
279
296
  from common.task_turn import ticket_input # type: ignore[import-not-found]
280
297
  updated = ticket_input(root, hook_input)
298
+ if updated is None:
299
+ return 0
281
300
  print(json.dumps({"hookSpecificOutput": {
282
301
  "hookEventName": "PreToolUse", "permissionDecision": "allow",
283
302
  "updatedInput": updated,
@@ -44,7 +44,6 @@ import re
44
44
  import sys
45
45
  import queue
46
46
  import threading
47
- import subprocess
48
47
  from pathlib import Path
49
48
 
50
49
  # Force UTF-8 on stdin/stdout/stderr on Windows. Default codepage there is
@@ -414,15 +413,20 @@ def _load_hook_input() -> dict:
414
413
  def main() -> int:
415
414
  if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
416
415
  try:
417
- locator = Path(os.environ["TRELLIS_DELEGATION_CONTEXT"])
418
- if locator.is_symlink() or locator.stat().st_size > 256 * 1024:
419
- raise ValueError("invalid delegation context")
420
- context = json.loads(locator.read_text(encoding="utf8"))
421
- result = subprocess.run([sys.executable, str(Path(context["control_root"]) / ".trellis/scripts/get_context.py")], capture_output=True, text=True, timeout=15)
422
- message = result.stdout.strip() if result.returncode == 0 else "Delegated node blocked: invalid/stale context; preserve resources and report to controller."
416
+ # Validate stable locators through the same node boundary as get_context.
417
+ root = Path(__file__).resolve().parents[2]
418
+ sys.path.insert(0, str(root / ".trellis/scripts"))
419
+ from common.worktree_delegation import node_context # type: ignore[import-not-found]
420
+
421
+ data = _load_hook_input()
422
+ os.chdir(str(data.get("cwd") or os.getcwd()))
423
+ context = node_context()
424
+ message = json.dumps({"delegated_node": context,
425
+ "instruction": "Read node_method_ref and the current contract; do not enter controller phases or task/turn governance."},
426
+ ensure_ascii=False)
423
427
  if len(message.encode()) > 256 * 1024:
424
428
  raise ValueError("oversized delegation context")
425
- except (OSError, ValueError, KeyError, subprocess.TimeoutExpired):
429
+ except Exception:
426
430
  message = "Delegated node blocked: missing/invalid execution context; do not enter controller workflow."
427
431
  print(json.dumps({"hookSpecificOutput": {"hookEventName": "UserPromptSubmit", "additionalContext": message}}))
428
432
  return 0
@@ -9,6 +9,8 @@ description: Shared preparation, execution and recovery method for delegated nod
9
9
 
10
10
  每次 prepare、execute、followup 和恢复后,重读 `TRELLIS_DELEGATION_CONTEXT`;稳定 locator 的 `context_ref` 指向当前包。再读取本次消息指定的冻结 input context、其 `record_ref`、`contract_ref`、要求的规则及 Skills;核对原生 `PASEO_AGENT_ID`、workspace、实际 Git checkout、branch、base、attempt、binding、模型和 effort。投影与记录不一致时停止受影响动作。主控持有的资料可只读,不修改控制仓库的任务、接受、运行记录或其他包。
11
11
 
12
+ 目标项目即使已有 Trellis 和 Hooks,你仍是本包节点,不成为该项目的主控。主控的 task/turn 退出登记不适用于节点;交付使用指定 ready/result/blocked。上下文失效时报告阻断,不以清除环境、重建任务或绕过 Hook 恢复权限。工作期间不向用户发送进度或提问;真实权限请求保留原样交由主控协调。
13
+
12
14
  准备许可只允许合同明确的准备和候选报告。`role_ref`、`node_method_ref`、`contract_ref` 及可选 `setup_ref` 指向当前 attempt 的冻结快照;只读取这些已验证引用,不改读主控实时文件。`requirements.setup_ref` 有值时,读取投影的 `setup_ref` 快照,只运行其中已批准的原生准备动作。不存在时不能初始化 Trellis、安装依赖、索引或修改共享配置。检查实际 cwd、用户和目录规则、必需 Skill 的准确来源和可读性、工具连接及真实能力。必需 CodeGraph 只能使用本树原生 bound MCP 和本树索引;查询须看到本树 provenance,不能借祖先或兄弟索引。记录观察和缺项,不要求底层权限或上下文窗口默认值的完整回执。
13
15
 
14
16
  ## 当前输入的候选格式
@@ -238,8 +238,8 @@ def _default_prd_content(title: str, description: str | None = None) -> str:
238
238
  ## Notes
239
239
 
240
240
  - Keep `prd.md` focused on requirements, constraints, and acceptance criteria.
241
- - Lightweight tasks can remain PRD-only.
242
- - For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`.
241
+ - Select the applicable native phase route; keep artifacts proportional to the task.
242
+ - Follow the current phase and its actual artifact references; files alone do not establish acceptance or implementation authority.
243
243
  """
244
244
 
245
245
 
@@ -627,8 +627,8 @@ def cmd_create(args: argparse.Namespace) -> int:
627
627
  print("", file=sys.stderr)
628
628
  print(colored("Next steps:", Colors.BLUE), file=sys.stderr)
629
629
  print(" - Fill prd.md with requirements and acceptance criteria", file=sys.stderr)
630
- print(" - Lightweight task: PRD-only is valid", file=sys.stderr)
631
- print(" - Complex task: add design.md and implement.md before task.py start", file=sys.stderr)
630
+ print(" - Select the applicable native phase route; keep artifacts proportional to the task", file=sys.stderr)
631
+ print(" - Follow actual phase artifacts and obtain implementation authorization before starting work", file=sys.stderr)
632
632
  print(" - Add optional spec/research context with task.py add-context when needed", file=sys.stderr)
633
633
  print(" - Use /trellis:continue or phase context to decide the next step", file=sys.stderr)
634
634
  print("", file=sys.stderr)
@@ -186,7 +186,7 @@ def _invocation(root: Path, command: str) -> tuple[list[str], str | None, list[s
186
186
  raise TurnError("TASK_TURN_WITHHELD: use Python directly")
187
187
  index = 3 if tokens[1:3] == ["-X", "utf8"] else 1
188
188
  if (len(tokens) <= index + 2 or (root / tokens[index]).resolve() != (root / ".trellis/scripts/task.py").resolve()
189
- or tokens[index + 1] != "turn" or tokens[index + 2] not in {"show", "record"}):
189
+ or tokens[index + 1] != "turn" or tokens[index + 2] not in {"show", "record", "--help", "-h"}):
190
190
  raise TurnError("TASK_TURN_WITHHELD: not a native turn invocation")
191
191
  argv = tokens[index + 2:]
192
192
  ticket = None
@@ -223,13 +223,17 @@ def _expire_tickets(root: Path) -> None:
223
223
  path.unlink()
224
224
 
225
225
 
226
- def ticket_input(root: Path, event: dict) -> dict:
227
- key, session, turn_id = _identity(event)
226
+ def ticket_input(root: Path, event: dict) -> dict | None:
228
227
  tool_input = event.get("tool_input")
229
228
  if not isinstance(tool_input, dict):
230
229
  raise TurnError("TASK_TURN_WITHHELD: invalid Bash input")
231
230
  command = _text(tool_input.get("command"), "Bash command", 16384)
232
231
  argv, existing, prefix = _invocation(root, command)
232
+ if not existing and (argv == ["show"] or argv in [
233
+ ["--help"], ["-h"], ["record", "--help"], ["record", "-h"],
234
+ ["show", "--help"], ["show", "-h"]]):
235
+ return None
236
+ key, session, turn_id = _identity(event)
233
237
  call_id = _text(event.get("tool_use_id"), "tool_use_id")
234
238
  cwd = Path(_text(event.get("cwd"), "cwd", 4096)).resolve()
235
239
  if cwd != root.resolve():
@@ -604,6 +604,9 @@ def _bind_omissions(task_dir: Path, state: dict) -> None:
604
604
 
605
605
 
606
606
  def _require_current_omissions(task_dir: Path, state: dict) -> None:
607
+ # Withdrawal retires implementation authority; its safe closeout is not an implementation omission.
608
+ if _is_withdrawal_route(state):
609
+ return
607
610
  skipped = state.get("skip_records", {}).get(PHASE_IDS[2], {})
608
611
  if "contract_ref" in skipped and _artifact_digest(task_dir, [skipped["contract_ref"]]) != skipped.get("contract_revision"):
609
612
  raise TaskWorkflowError("TASK_PHASE_STALE_OMISSION", "the contract bound to design omission changed")
@@ -188,7 +188,7 @@ flowchart LR
188
188
 
189
189
  #### 4.1 实施已授权合同
190
190
 
191
- 读取任务实施与测试验证阶段 Skill、源码 owner 仓库适用的 `AGENTS.md` 和规范。按合同顺序推进必要工作包。Teamwork 仅提供只读协作;只有明确授权委派 Git worktree 写入时才使用 Paseo。
191
+ 读取任务实施与测试验证阶段 Skill、源码 owner 仓库适用的 `AGENTS.md` 和规范。按合同顺序推进必要工作包。Teamwork 仅提供只读协作;只有明确授权委派实施包时才使用 Paseo。按批准目标复用现有 checkout/submodule(directory)或使用独立 worktree,不默认创建新树或切换分支。
192
192
 
193
193
  #### 4.2 验证与集成
194
194
 
@@ -218,12 +218,14 @@ Teamwork 的报告、工作日志、事件及诊断先审查用途与引用,
218
218
  | `pennix-decision-grill` | 需要用户决定时同步提问;由 Trellis 记录结果。 |
219
219
  | Trellis Teamwork | 提供可选协作和只读证据;不选择阶段、不接受工作,也不写入产品代码。 |
220
220
  | Pennix Lifecycle | 路线需要时核验组件和 Paseo 的已安装版本及就绪状态。 |
221
- | Paseo | 管理已授权的 Paseo workspace 与委派 Git worktree 运行事实;不管理任务阶段或接受。 |
221
+ | Paseo | 管理已授权的 workspace、Agent、输入队列与 directory/worktree 运行事实;不管理任务阶段或接受。 |
222
222
  | 组件 owner 仓库 | 管理组件源码、测试、文档、原生工作流资产及组件验收。 |
223
223
  | Hooks | 注入当前上下文或运行辅助检查;不构成权限边界。 |
224
224
 
225
225
  根据实际工作选择工具和 Skill。组件已安装或列在阶段表中,不代表必须调用。可选组件缺失时,不阻塞不依赖该组件的路线。
226
226
 
227
+ 主控负责用户决定、阶段及成果接受;只读成员返回证据,委派节点直接完成授权包并交回候选或必要阻断。目标仓库有自己的 Trellis 资产不改变节点角色。Hooks 按原生身份和有效委派上下文分流;环境变量只定位资料,不授予权限,失效上下文不回退成目标主控。主控的回合退出登记不要求节点执行,也不替代包的接受与运行资源关闭。
228
+
227
229
  ## 定制本工作流
228
230
 
229
231
  本文件中的 `[workflow-state:...]` 区块是每轮任务提示的源文本。阶段 ID 必须与 `packages/core/src/task/phase.ts` 一致;修改阶段索引或标题时同步更新宿主解析器。`get_context.py --mode phase` 返回阶段索引;`--step <phase.step>` 返回对应章节。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pennixrv/trellis",
3
- "version": "0.7.2-beta.30",
3
+ "version": "0.7.2-beta.31",
4
4
  "description": "AI capabilities grow like ivy — Trellis provides the structure to guide them along a disciplined path",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "inquirer": "^9.3.7",
36
36
  "undici": "^6.21.0",
37
37
  "zod": "^4.4.2",
38
- "@pennixrv/trellis-core": "0.7.2-beta.30"
38
+ "@pennixrv/trellis-core": "0.7.2-beta.31"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@eslint/js": "^9.18.0",