@pennixrv/trellis 0.7.2-beta.0 → 0.7.2-beta.10

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 (87) hide show
  1. package/dist/commands/teamwork/adapters/acp.d.ts.map +1 -1
  2. package/dist/commands/teamwork/adapters/acp.js +3 -0
  3. package/dist/commands/teamwork/adapters/acp.js.map +1 -1
  4. package/dist/commands/teamwork/adapters/index.d.ts +1 -1
  5. package/dist/commands/teamwork/adapters/index.d.ts.map +1 -1
  6. package/dist/commands/teamwork/artifact.d.ts +9 -4
  7. package/dist/commands/teamwork/artifact.d.ts.map +1 -1
  8. package/dist/commands/teamwork/artifact.js +8 -37
  9. package/dist/commands/teamwork/artifact.js.map +1 -1
  10. package/dist/commands/teamwork/batch.d.ts +1 -0
  11. package/dist/commands/teamwork/batch.d.ts.map +1 -1
  12. package/dist/commands/teamwork/batch.js +24 -3
  13. package/dist/commands/teamwork/batch.js.map +1 -1
  14. package/dist/commands/teamwork/coordinator.d.ts +16 -3
  15. package/dist/commands/teamwork/coordinator.d.ts.map +1 -1
  16. package/dist/commands/teamwork/coordinator.js +209 -86
  17. package/dist/commands/teamwork/coordinator.js.map +1 -1
  18. package/dist/commands/teamwork/guard.js +2 -2
  19. package/dist/commands/teamwork/guard.js.map +1 -1
  20. package/dist/commands/teamwork/index.d.ts.map +1 -1
  21. package/dist/commands/teamwork/index.js +26 -2
  22. package/dist/commands/teamwork/index.js.map +1 -1
  23. package/dist/commands/teamwork/result.d.ts +2 -1
  24. package/dist/commands/teamwork/result.d.ts.map +1 -1
  25. package/dist/commands/teamwork/result.js.map +1 -1
  26. package/dist/commands/teamwork/runtime.d.ts +2 -2
  27. package/dist/commands/teamwork/runtime.d.ts.map +1 -1
  28. package/dist/commands/teamwork/runtime.js +60 -30
  29. package/dist/commands/teamwork/runtime.js.map +1 -1
  30. package/dist/commands/teamwork/spawn.d.ts.map +1 -1
  31. package/dist/commands/teamwork/spawn.js +2 -0
  32. package/dist/commands/teamwork/spawn.js.map +1 -1
  33. package/dist/commands/teamwork/supervisor.d.ts +1 -1
  34. package/dist/commands/teamwork/supervisor.d.ts.map +1 -1
  35. package/dist/commands/teamwork/teammate-adapters.d.ts +3 -0
  36. package/dist/commands/teamwork/teammate-adapters.d.ts.map +1 -1
  37. package/dist/commands/teamwork/teammate-adapters.js +14 -5
  38. package/dist/commands/teamwork/teammate-adapters.js.map +1 -1
  39. package/dist/migrations/manifests/0.7.2-beta.1.json +11 -0
  40. package/dist/migrations/manifests/0.7.2-beta.10.json +9 -0
  41. package/dist/migrations/manifests/0.7.2-beta.2.json +11 -0
  42. package/dist/migrations/manifests/0.7.2-beta.3.json +9 -0
  43. package/dist/migrations/manifests/0.7.2-beta.4.json +9 -0
  44. package/dist/migrations/manifests/0.7.2-beta.5.json +9 -0
  45. package/dist/migrations/manifests/0.7.2-beta.6.json +9 -0
  46. package/dist/migrations/manifests/0.7.2-beta.7.json +9 -0
  47. package/dist/migrations/manifests/0.7.2-beta.8.json +9 -0
  48. package/dist/migrations/manifests/0.7.2-beta.9.json +9 -0
  49. package/dist/templates/codex/hooks/session-start.py +14 -0
  50. package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/SKILL.md +2 -0
  51. package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/workflow.md +7 -3
  52. package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/SKILL.md +2 -0
  53. package/dist/templates/common/bundled-skills/trellis-goal-exploration-and-requirements/SKILL.md +2 -0
  54. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/multi-agent-teamwork.md +6 -0
  55. package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/SKILL.md +2 -0
  56. package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/workflow.md +14 -5
  57. package/dist/templates/common/bundled-skills/trellis-task-implementation/SKILL.md +2 -0
  58. package/dist/templates/common/bundled-skills/trellis-task-implementation/workflow.md +1 -1
  59. package/dist/templates/common/bundled-skills/trellis-teamwork/SKILL.md +7 -0
  60. package/dist/templates/common/bundled-skills/trellis-worktree-delegation/SKILL.md +14 -0
  61. package/dist/templates/common/bundled-skills/trellis-worktree-delegation/workflow.md +17 -0
  62. package/dist/templates/common/commands/continue.md +2 -0
  63. package/dist/templates/common/commands/start.md +2 -0
  64. package/dist/templates/common/skills/request-intake.md +5 -3
  65. package/dist/templates/kiro/agents/trellis.json +1 -1
  66. package/dist/templates/shared-hooks/guard-teamwork-wait.py +5 -0
  67. package/dist/templates/shared-hooks/inject-workflow-state.py +15 -0
  68. package/dist/templates/trellis/agents/delegated-worktree-primary-agent.md +20 -22
  69. package/dist/templates/trellis/agents/teammate.md +4 -2
  70. package/dist/templates/trellis/agents/worktree-delegation-node.md +24 -0
  71. package/dist/templates/trellis/index.d.ts.map +1 -1
  72. package/dist/templates/trellis/index.js +1 -0
  73. package/dist/templates/trellis/index.js.map +1 -1
  74. package/dist/templates/trellis/scripts/common/config.py +5 -0
  75. package/dist/templates/trellis/scripts/common/git_context.py +10 -0
  76. package/dist/templates/trellis/scripts/common/io.py +2 -2
  77. package/dist/templates/trellis/scripts/common/task_continuity.py +73 -0
  78. package/dist/templates/trellis/scripts/common/task_move.py +2 -2
  79. package/dist/templates/trellis/scripts/common/task_store.py +23 -1
  80. package/dist/templates/trellis/scripts/common/task_workflow.py +63 -6
  81. package/dist/templates/trellis/scripts/common/worktree_delegation.py +561 -0
  82. package/dist/templates/trellis/scripts/task.py +39 -1
  83. package/dist/templates/trellis/workflow.md +20 -3
  84. package/dist/utils/asset-backup.d.ts.map +1 -1
  85. package/dist/utils/asset-backup.js +18 -6
  86. package/dist/utils/asset-backup.js.map +1 -1
  87. package/package.json +2 -2
@@ -55,6 +55,15 @@ from .task_utils import (
55
55
  )
56
56
  from .workflow_selection import DIR_WORKFLOWS, WORKFLOW_ID_RE
57
57
 
58
+ RESERVED_META_KEYS = {
59
+ "task_workflow",
60
+ "delegation_authorizations",
61
+ "delegated_worktree_execution_history",
62
+ "delegated_worktree_execution_record",
63
+ "task_cancellation",
64
+ "task_lifecycle_recoveries",
65
+ }
66
+
58
67
 
59
68
  # =============================================================================
60
69
  # Helper Functions
@@ -248,6 +257,9 @@ def _parse_meta_pairs(pairs: list[str] | None) -> dict[str, str] | None:
248
257
  file=sys.stderr,
249
258
  )
250
259
  return None
260
+ if key in RESERVED_META_KEYS:
261
+ print(colored(f"Error: metadata key is managed by Trellis: {key}", Colors.RED), file=sys.stderr)
262
+ return None
251
263
  meta[key] = value
252
264
  return meta
253
265
 
@@ -1007,6 +1019,11 @@ def cmd_rename(args: argparse.Namespace) -> int:
1007
1019
  print(colored(f"Error: Task not found: {args.name}", Colors.RED), file=sys.stderr)
1008
1020
  return 1
1009
1021
 
1022
+ from .worktree_delegation import runtime_path
1023
+ if runtime_path(repo_root, task_dir.name).exists():
1024
+ print("Error: preserve delegation identity; a task with delegation runtime cannot be renamed", file=sys.stderr)
1025
+ return 1
1026
+
1010
1027
  # Restrict renames to the prescribed status directory levels.
1011
1028
  if not is_within_tasks_dir(task_dir, repo_root):
1012
1029
  print(
@@ -1247,7 +1264,8 @@ def cmd_remove_subtask(args: argparse.Namespace) -> int:
1247
1264
 
1248
1265
  if parent_data.get("status") != "cancelled":
1249
1266
  from .task_workflow import _assert_delegated_record_closed
1250
- _assert_delegated_record_closed(child_dir.name, child_data.get("meta", {}).get("delegated_worktree_execution_record"))
1267
+ from .worktree_delegation import resolve_record
1268
+ _assert_delegated_record_closed(child_dir.name, resolve_record(repo_root, child_dir, child_data))
1251
1269
  original_parent = json.loads(json.dumps(parent_data))
1252
1270
  # Remove child from parent's children list
1253
1271
  parent_children = _ensure_children_list(parent_data)
@@ -1427,6 +1445,10 @@ def cmd_set_meta(args: argparse.Namespace) -> int:
1427
1445
  key = args.key
1428
1446
  value = args.value
1429
1447
 
1448
+ if key in RESERVED_META_KEYS:
1449
+ print(colored(f"Error: metadata key is managed by Trellis: {key}", Colors.RED), file=sys.stderr)
1450
+ return 1
1451
+
1430
1452
  if not key:
1431
1453
  print(colored("Error: Missing arguments", Colors.RED))
1432
1454
  print("Usage: python3 task.py set-meta <task-dir> <key> <value>")
@@ -110,6 +110,28 @@ def _state(meta: dict) -> dict:
110
110
  raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", "route dependency admission has an invalid shape")
111
111
  if state.get("current_phase_id") is not None and state["current_phase_id"] not in state["phase_ids"]:
112
112
  raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", "current phase is not in the task route")
113
+ skip_records = state.get("skip_records")
114
+ if not isinstance(skip_records, dict):
115
+ raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", "task phase skip records have an invalid shape")
116
+ for phase_id, skip in skip_records.items():
117
+ if (
118
+ phase_id not in PHASE_ID_SET
119
+ or not isinstance(skip, dict)
120
+ or not isinstance(skip.get("reason"), str)
121
+ or not skip["reason"].strip()
122
+ or not isinstance(skip.get("evidence_refs"), list)
123
+ or not skip["evidence_refs"]
124
+ or any(not isinstance(value, str) or not value.strip() for value in skip["evidence_refs"])
125
+ or skip.get("task_route_revision") != state["task_route_revision"]
126
+ or not ROUTE_REVISION.fullmatch(str(skip.get("input_revision", "")))
127
+ or not isinstance(skip.get("artifact_revision"), str)
128
+ or not re.fullmatch(r"[a-f0-9]{64}", skip["artifact_revision"])
129
+ or (
130
+ phase_id in state["phases"]
131
+ and skip["artifact_revision"] != state["phases"][phase_id].get("artifact_revision")
132
+ )
133
+ ):
134
+ raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", f"task phase skip record is invalid: {phase_id}")
113
135
  for phase_id in state["phase_ids"]:
114
136
  record = state["phases"].get(phase_id)
115
137
  if not isinstance(record, dict) or record.get("status") not in {"not_started", "active", "waiting_user", "blocked", "accepted", "skipped"}:
@@ -254,6 +276,7 @@ def _is_withdrawal_route(state: dict) -> bool:
254
276
  and isinstance(withdrawal.get("from"), str)
255
277
  and withdrawal["from"] in PHASE_ID_SET
256
278
  and withdrawal.get("to") == PHASE_IDS[4]
279
+ and withdrawal.get("return_kind") == "withdrawal"
257
280
  and withdrawal.get("task_route_revision") == state.get("task_route_revision")
258
281
  and isinstance(withdrawal.get("evidence_refs"), list)
259
282
  and bool(withdrawal["evidence_refs"])
@@ -389,6 +412,8 @@ def _validate_classification(task_kind: str | None, complexity: str | None, proj
389
412
  raise TaskWorkflowError("TASK_PHASE_INVALID_INPUT", "--project-context must be new or existing")
390
413
  if task_kind == "analysis" and PHASE_IDS[3] in phases:
391
414
  raise TaskWorkflowError("TASK_PHASE_INVALID_ROUTE", "analysis tasks cannot include the Task Implementation and Test Verification Phase")
415
+ if task_kind in {"implementation", "combined"} and PHASE_IDS[3] not in phases:
416
+ raise TaskWorkflowError("TASK_PHASE_INVALID_ROUTE", "implementation and combined tasks must include the Task Implementation and Test Verification Phase")
392
417
 
393
418
 
394
419
  def _increment(value: str, allow_zero: bool = False) -> str:
@@ -441,7 +466,13 @@ def _init(args: argparse.Namespace, task_dir: Path, data: dict, meta: dict) -> i
441
466
  "implementation_authorization": None,
442
467
  "closeout_disposition": None,
443
468
  "skip_records": {
444
- phase: {"reason": route_reason, "evidence_refs": route_evidence, "task_route_revision": "1"}
469
+ phase: {
470
+ "reason": route_reason,
471
+ "evidence_refs": route_evidence,
472
+ "task_route_revision": "1",
473
+ "input_revision": input_revision,
474
+ "artifact_revision": _phase_record(input_revision)["artifact_revision"],
475
+ }
445
476
  for phase in omitted
446
477
  },
447
478
  "return_record": None,
@@ -549,7 +580,13 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
549
580
  if current == PHASE_IDS[0]:
550
581
  raise TaskWorkflowError("TASK_PHASE_INVALID_TRANSITION", "The Goal Exploration and Requirements Confirmation Phase must reach minimum alignment and acceptance and cannot be skipped")
551
582
  record.update({"status": "skipped", "reason": reason, "evidence_refs": evidence})
552
- state["skip_records"][current] = {"reason": reason, "evidence_refs": evidence, "task_route_revision": state["task_route_revision"]}
583
+ state["skip_records"][current] = {
584
+ "reason": reason,
585
+ "evidence_refs": evidence,
586
+ "task_route_revision": state["task_route_revision"],
587
+ "input_revision": state["input_revision"],
588
+ "artifact_revision": record["artifact_revision"],
589
+ }
553
590
  _advance(state, current)
554
591
  elif action == "accept":
555
592
  _require_current_accepted_artifacts(task_dir, state)
@@ -660,6 +697,7 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
660
697
  target == PHASE_IDS[4]
661
698
  and phases == [PHASE_IDS[0], PHASE_IDS[4]]
662
699
  and bool(evidence)
700
+ and args.return_kind == "withdrawal"
663
701
  )
664
702
  if not changed and not classification_changed and target == current and not reviewed_delivery:
665
703
  raise TaskWorkflowError("TASK_PHASE_INVALID_ROUTE", "the updated route and target are unchanged")
@@ -702,12 +740,24 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
702
740
  if phase_id not in old_phases:
703
741
  phase_record["input_revision"] = state["input_revision"]
704
742
  state["skip_records"] = {
705
- phase_id: {**skip, "task_route_revision": state["task_route_revision"]}
743
+ phase_id: {
744
+ **skip,
745
+ "task_route_revision": state["task_route_revision"],
746
+ "input_revision": state["input_revision"],
747
+ "artifact_revision": state["phases"][phase_id]["artifact_revision"],
748
+ }
706
749
  for phase_id, skip in state["skip_records"].items()
707
750
  if phase_id in phases and state["phases"][phase_id].get("status") == "skipped"
708
751
  }
709
752
  for phase_id in omitted:
710
- state["skip_records"][phase_id] = {"reason": reason, "evidence_refs": evidence, "task_route_revision": state["task_route_revision"]}
753
+ phase_record = state["phases"].get(phase_id, old_phases.get(phase_id, _phase_record(state["input_revision"])))
754
+ state["skip_records"][phase_id] = {
755
+ "reason": reason,
756
+ "evidence_refs": evidence,
757
+ "task_route_revision": state["task_route_revision"],
758
+ "input_revision": state["input_revision"],
759
+ "artifact_revision": phase_record["artifact_revision"],
760
+ }
711
761
  if withdrawal_route and state["phases"][PHASE_IDS[0]].get("status") != "accepted":
712
762
  state["phases"][PHASE_IDS[0]].update({
713
763
  "status": "skipped",
@@ -721,6 +771,8 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
721
771
  "reason": reason,
722
772
  "evidence_refs": evidence,
723
773
  "task_route_revision": state["task_route_revision"],
774
+ "input_revision": state["input_revision"],
775
+ "artifact_revision": state["phases"][PHASE_IDS[0]]["artifact_revision"],
724
776
  }
725
777
  state["implementation_authorization"] = None
726
778
  state["closeout_disposition"] = None
@@ -728,6 +780,7 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
728
780
  state["return_record"] = {
729
781
  "from": current,
730
782
  "to": target,
783
+ **({"return_kind": "withdrawal"} if withdrawal_route else {}),
731
784
  "reason": reason,
732
785
  "evidence_refs": evidence,
733
786
  "task_route_revision": state["task_route_revision"],
@@ -1324,8 +1377,10 @@ def _assert_delegated_resources_closed(task_dir: Path, data: dict) -> None:
1324
1377
  if not isinstance(children, list):
1325
1378
  raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", "linked child task list is malformed")
1326
1379
  for task_id in [task_dir.name, *children]:
1327
- _, child_meta = _load(_task_dir(task_id))
1328
- _assert_delegated_record_closed(task_id, child_meta.get("delegated_worktree_execution_record"))
1380
+ child_dir = _task_dir(task_id)
1381
+ child_data, _ = _load(child_dir)
1382
+ from .worktree_delegation import resolve_record
1383
+ _assert_delegated_record_closed(task_id, resolve_record(get_repo_root(), child_dir, child_data))
1329
1384
 
1330
1385
 
1331
1386
  def _assert_delegated_record_closed(task_id: str, record) -> None:
@@ -1333,6 +1388,8 @@ def _assert_delegated_record_closed(task_id: str, record) -> None:
1333
1388
  return
1334
1389
  if isinstance(record, dict) and record.get("status") == "retired" and isinstance(record.get("closure_evidence"), dict):
1335
1390
  return
1391
+ if isinstance(record, dict) and "binding" in record:
1392
+ raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", f"protocol v1 delegation for {task_id} must be explicitly reconciled before closing or moving")
1336
1393
  agent_id = record.get("agent_id") if isinstance(record, dict) else None
1337
1394
  if not isinstance(agent_id, str) or not agent_id.strip():
1338
1395
  raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", f"delegated execution status is unknown for {task_id}; preserve the current state")