@pennixrv/trellis 0.7.2-beta.2 → 0.7.2-beta.20

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 (433) hide show
  1. package/README.md +14 -0
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.js +105 -107
  4. package/dist/commands/init.js.map +1 -1
  5. package/dist/commands/teamwork/adapters/acp.d.ts.map +1 -1
  6. package/dist/commands/teamwork/adapters/acp.js +3 -0
  7. package/dist/commands/teamwork/adapters/acp.js.map +1 -1
  8. package/dist/commands/teamwork/adapters/index.d.ts +1 -1
  9. package/dist/commands/teamwork/adapters/index.d.ts.map +1 -1
  10. package/dist/commands/teamwork/artifact.d.ts +1 -0
  11. package/dist/commands/teamwork/artifact.d.ts.map +1 -1
  12. package/dist/commands/teamwork/artifact.js +1 -1
  13. package/dist/commands/teamwork/artifact.js.map +1 -1
  14. package/dist/commands/teamwork/batch-reservation.d.ts.map +1 -1
  15. package/dist/commands/teamwork/batch-reservation.js +16 -8
  16. package/dist/commands/teamwork/batch-reservation.js.map +1 -1
  17. package/dist/commands/teamwork/batch.d.ts +15 -1
  18. package/dist/commands/teamwork/batch.d.ts.map +1 -1
  19. package/dist/commands/teamwork/batch.js +277 -22
  20. package/dist/commands/teamwork/batch.js.map +1 -1
  21. package/dist/commands/teamwork/coordinator.d.ts +3 -0
  22. package/dist/commands/teamwork/coordinator.d.ts.map +1 -1
  23. package/dist/commands/teamwork/coordinator.js +22 -3
  24. package/dist/commands/teamwork/coordinator.js.map +1 -1
  25. package/dist/commands/teamwork/create.d.ts +1 -0
  26. package/dist/commands/teamwork/create.d.ts.map +1 -1
  27. package/dist/commands/teamwork/create.js +4 -0
  28. package/dist/commands/teamwork/create.js.map +1 -1
  29. package/dist/commands/teamwork/evidence-references.d.ts +19 -0
  30. package/dist/commands/teamwork/evidence-references.d.ts.map +1 -0
  31. package/dist/commands/teamwork/evidence-references.js +249 -0
  32. package/dist/commands/teamwork/evidence-references.js.map +1 -0
  33. package/dist/commands/teamwork/foreground-wait.d.ts +4 -1
  34. package/dist/commands/teamwork/foreground-wait.d.ts.map +1 -1
  35. package/dist/commands/teamwork/foreground-wait.js +15 -1
  36. package/dist/commands/teamwork/foreground-wait.js.map +1 -1
  37. package/dist/commands/teamwork/index.d.ts.map +1 -1
  38. package/dist/commands/teamwork/index.js +46 -4
  39. package/dist/commands/teamwork/index.js.map +1 -1
  40. package/dist/commands/teamwork/list.d.ts +1 -0
  41. package/dist/commands/teamwork/list.d.ts.map +1 -1
  42. package/dist/commands/teamwork/list.js +4 -1
  43. package/dist/commands/teamwork/list.js.map +1 -1
  44. package/dist/commands/teamwork/prompt.js +1 -1
  45. package/dist/commands/teamwork/prompt.js.map +1 -1
  46. package/dist/commands/teamwork/rm.d.ts +27 -4
  47. package/dist/commands/teamwork/rm.d.ts.map +1 -1
  48. package/dist/commands/teamwork/rm.js +155 -51
  49. package/dist/commands/teamwork/rm.js.map +1 -1
  50. package/dist/commands/teamwork/run.d.ts.map +1 -1
  51. package/dist/commands/teamwork/run.js +10 -1
  52. package/dist/commands/teamwork/run.js.map +1 -1
  53. package/dist/commands/teamwork/runtime.d.ts +1 -1
  54. package/dist/commands/teamwork/runtime.d.ts.map +1 -1
  55. package/dist/commands/teamwork/runtime.js +14 -4
  56. package/dist/commands/teamwork/runtime.js.map +1 -1
  57. package/dist/commands/teamwork/spawn.d.ts.map +1 -1
  58. package/dist/commands/teamwork/spawn.js +4 -1
  59. package/dist/commands/teamwork/spawn.js.map +1 -1
  60. package/dist/commands/teamwork/supervisor/stdout.d.ts.map +1 -1
  61. package/dist/commands/teamwork/supervisor/stdout.js +7 -0
  62. package/dist/commands/teamwork/supervisor/stdout.js.map +1 -1
  63. package/dist/commands/teamwork/supervisor.d.ts +1 -1
  64. package/dist/commands/teamwork/supervisor.d.ts.map +1 -1
  65. package/dist/commands/teamwork/teammate-adapters.d.ts +3 -0
  66. package/dist/commands/teamwork/teammate-adapters.d.ts.map +1 -1
  67. package/dist/commands/teamwork/teammate-adapters.js +14 -5
  68. package/dist/commands/teamwork/teammate-adapters.js.map +1 -1
  69. package/dist/commands/teamwork/workers.d.ts +8 -0
  70. package/dist/commands/teamwork/workers.d.ts.map +1 -0
  71. package/dist/commands/teamwork/workers.js +67 -0
  72. package/dist/commands/teamwork/workers.js.map +1 -0
  73. package/dist/commands/update.d.ts.map +1 -1
  74. package/dist/commands/update.js +109 -55
  75. package/dist/commands/update.js.map +1 -1
  76. package/dist/commands/workflow.d.ts.map +1 -1
  77. package/dist/commands/workflow.js +5 -7
  78. package/dist/commands/workflow.js.map +1 -1
  79. package/dist/configurators/codebuddy.d.ts +1 -8
  80. package/dist/configurators/codebuddy.d.ts.map +1 -1
  81. package/dist/configurators/codebuddy.js +2 -12
  82. package/dist/configurators/codebuddy.js.map +1 -1
  83. package/dist/configurators/codex.d.ts +0 -36
  84. package/dist/configurators/codex.d.ts.map +1 -1
  85. package/dist/configurators/codex.js +2 -99
  86. package/dist/configurators/codex.js.map +1 -1
  87. package/dist/configurators/copilot.d.ts +1 -12
  88. package/dist/configurators/copilot.d.ts.map +1 -1
  89. package/dist/configurators/copilot.js +2 -20
  90. package/dist/configurators/copilot.js.map +1 -1
  91. package/dist/configurators/cursor.d.ts +1 -8
  92. package/dist/configurators/cursor.d.ts.map +1 -1
  93. package/dist/configurators/cursor.js +2 -12
  94. package/dist/configurators/cursor.js.map +1 -1
  95. package/dist/configurators/droid.d.ts +1 -8
  96. package/dist/configurators/droid.d.ts.map +1 -1
  97. package/dist/configurators/droid.js +2 -12
  98. package/dist/configurators/droid.js.map +1 -1
  99. package/dist/configurators/dsh.d.ts +1 -21
  100. package/dist/configurators/dsh.d.ts.map +1 -1
  101. package/dist/configurators/dsh.js +4 -37
  102. package/dist/configurators/dsh.js.map +1 -1
  103. package/dist/configurators/gemini.d.ts +1 -16
  104. package/dist/configurators/gemini.d.ts.map +1 -1
  105. package/dist/configurators/gemini.js +3 -21
  106. package/dist/configurators/gemini.js.map +1 -1
  107. package/dist/configurators/grok.d.ts +1 -12
  108. package/dist/configurators/grok.d.ts.map +1 -1
  109. package/dist/configurators/grok.js +2 -18
  110. package/dist/configurators/grok.js.map +1 -1
  111. package/dist/configurators/kimi.d.ts +1 -21
  112. package/dist/configurators/kimi.d.ts.map +1 -1
  113. package/dist/configurators/kimi.js +2 -38
  114. package/dist/configurators/kimi.js.map +1 -1
  115. package/dist/configurators/kiro.d.ts +1 -9
  116. package/dist/configurators/kiro.d.ts.map +1 -1
  117. package/dist/configurators/kiro.js +1 -9
  118. package/dist/configurators/kiro.js.map +1 -1
  119. package/dist/configurators/omp.d.ts.map +1 -1
  120. package/dist/configurators/omp.js +1 -5
  121. package/dist/configurators/omp.js.map +1 -1
  122. package/dist/configurators/pi.d.ts.map +1 -1
  123. package/dist/configurators/pi.js +2 -5
  124. package/dist/configurators/pi.js.map +1 -1
  125. package/dist/configurators/qoder.d.ts +1 -10
  126. package/dist/configurators/qoder.d.ts.map +1 -1
  127. package/dist/configurators/qoder.js +3 -15
  128. package/dist/configurators/qoder.js.map +1 -1
  129. package/dist/configurators/reasonix.d.ts +1 -12
  130. package/dist/configurators/reasonix.d.ts.map +1 -1
  131. package/dist/configurators/reasonix.js +3 -22
  132. package/dist/configurators/reasonix.js.map +1 -1
  133. package/dist/configurators/shared.d.ts +1 -24
  134. package/dist/configurators/shared.d.ts.map +1 -1
  135. package/dist/configurators/shared.js +5 -184
  136. package/dist/configurators/shared.js.map +1 -1
  137. package/dist/configurators/snow.d.ts +1 -20
  138. package/dist/configurators/snow.d.ts.map +1 -1
  139. package/dist/configurators/snow.js +2 -25
  140. package/dist/configurators/snow.js.map +1 -1
  141. package/dist/configurators/trae.d.ts +1 -14
  142. package/dist/configurators/trae.d.ts.map +1 -1
  143. package/dist/configurators/trae.js +3 -19
  144. package/dist/configurators/trae.js.map +1 -1
  145. package/dist/configurators/workflow.d.ts +2 -0
  146. package/dist/configurators/workflow.d.ts.map +1 -1
  147. package/dist/configurators/workflow.js +72 -56
  148. package/dist/configurators/workflow.js.map +1 -1
  149. package/dist/configurators/zcode.d.ts +1 -13
  150. package/dist/configurators/zcode.d.ts.map +1 -1
  151. package/dist/configurators/zcode.js +2 -18
  152. package/dist/configurators/zcode.js.map +1 -1
  153. package/dist/migrations/manifests/0.5.0-beta.5.json +1 -212
  154. package/dist/migrations/manifests/0.7.2-beta.10.json +9 -0
  155. package/dist/migrations/manifests/0.7.2-beta.11.json +9 -0
  156. package/dist/migrations/manifests/0.7.2-beta.12.json +9 -0
  157. package/dist/migrations/manifests/0.7.2-beta.13.json +9 -0
  158. package/dist/migrations/manifests/0.7.2-beta.14.json +9 -0
  159. package/dist/migrations/manifests/0.7.2-beta.15.json +9 -0
  160. package/dist/migrations/manifests/0.7.2-beta.16.json +9 -0
  161. package/dist/migrations/manifests/0.7.2-beta.17.json +9 -0
  162. package/dist/migrations/manifests/0.7.2-beta.18.json +9 -0
  163. package/dist/migrations/manifests/0.7.2-beta.19.json +11 -0
  164. package/dist/migrations/manifests/0.7.2-beta.20.json +9 -0
  165. package/dist/migrations/manifests/0.7.2-beta.3.json +9 -0
  166. package/dist/migrations/manifests/0.7.2-beta.4.json +9 -0
  167. package/dist/migrations/manifests/0.7.2-beta.5.json +9 -0
  168. package/dist/migrations/manifests/0.7.2-beta.6.json +9 -0
  169. package/dist/migrations/manifests/0.7.2-beta.7.json +9 -0
  170. package/dist/migrations/manifests/0.7.2-beta.8.json +9 -0
  171. package/dist/migrations/manifests/0.7.2-beta.9.json +9 -0
  172. package/dist/migrations/retired-native-paths.d.ts +109 -0
  173. package/dist/migrations/retired-native-paths.d.ts.map +1 -0
  174. package/dist/migrations/retired-native-paths.js +263 -0
  175. package/dist/migrations/retired-native-paths.js.map +1 -0
  176. package/dist/templates/claude/index.d.ts +1 -16
  177. package/dist/templates/claude/index.d.ts.map +1 -1
  178. package/dist/templates/claude/index.js +5 -32
  179. package/dist/templates/claude/index.js.map +1 -1
  180. package/dist/templates/claude/settings.json +0 -22
  181. package/dist/templates/codebuddy/index.d.ts +2 -3
  182. package/dist/templates/codebuddy/index.d.ts.map +1 -1
  183. package/dist/templates/codebuddy/index.js +2 -3
  184. package/dist/templates/codebuddy/index.js.map +1 -1
  185. package/dist/templates/codebuddy/settings.json +0 -10
  186. package/dist/templates/codex/config.toml +2 -19
  187. package/dist/templates/codex/hooks/session-start.py +25 -30
  188. package/dist/templates/codex/hooks.json +0 -12
  189. package/dist/templates/codex/index.d.ts +0 -5
  190. package/dist/templates/codex/index.d.ts.map +1 -1
  191. package/dist/templates/codex/index.js +0 -13
  192. package/dist/templates/codex/index.js.map +1 -1
  193. package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/SKILL.md +2 -0
  194. package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/workflow.md +7 -3
  195. package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/SKILL.md +2 -0
  196. package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/workflow.md +2 -0
  197. package/dist/templates/common/bundled-skills/trellis-goal-exploration-and-requirements/SKILL.md +2 -0
  198. package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +7 -7
  199. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +9 -51
  200. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +3 -15
  201. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +1 -2
  202. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +4 -9
  203. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +2 -2
  204. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/multi-agent-teamwork.md +6 -0
  205. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +1 -1
  206. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +10 -8
  207. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +9 -79
  208. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +2 -4
  209. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +3 -6
  210. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +24 -103
  211. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +1 -1
  212. package/dist/templates/common/bundled-skills/trellis-session-insight/SKILL.md +1 -1
  213. package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/SKILL.md +2 -0
  214. package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/workflow.md +14 -5
  215. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/SKILL.md +6 -4
  216. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-task-planning.md +5 -9
  217. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-writing.md +8 -0
  218. package/dist/templates/common/bundled-skills/trellis-task-implementation/SKILL.md +2 -0
  219. package/dist/templates/common/bundled-skills/trellis-task-implementation/workflow.md +1 -1
  220. package/dist/templates/common/bundled-skills/trellis-teamwork/SKILL.md +8 -1
  221. package/dist/templates/common/bundled-skills/trellis-teamwork/references/teammate-processes.md +21 -1
  222. package/dist/templates/common/bundled-skills/trellis-teamwork/references/teamwork-plan-construction.md +13 -2
  223. package/dist/templates/common/bundled-skills/trellis-worktree-delegation/SKILL.md +14 -0
  224. package/dist/templates/common/bundled-skills/trellis-worktree-delegation/workflow.md +17 -0
  225. package/dist/templates/common/commands/continue.md +8 -0
  226. package/dist/templates/common/commands/start.md +2 -0
  227. package/dist/templates/common/skills/before-dev.md +3 -1
  228. package/dist/templates/common/skills/check.md +3 -1
  229. package/dist/templates/common/skills/request-intake.md +5 -3
  230. package/dist/templates/copilot/hooks/session-start.py +11 -30
  231. package/dist/templates/cursor/hooks.json +0 -7
  232. package/dist/templates/cursor/index.d.ts +1 -11
  233. package/dist/templates/cursor/index.d.ts.map +1 -1
  234. package/dist/templates/cursor/index.js +2 -10
  235. package/dist/templates/cursor/index.js.map +1 -1
  236. package/dist/templates/droid/index.d.ts +2 -3
  237. package/dist/templates/droid/index.d.ts.map +1 -1
  238. package/dist/templates/droid/index.js +2 -3
  239. package/dist/templates/droid/index.js.map +1 -1
  240. package/dist/templates/droid/settings.json +0 -10
  241. package/dist/templates/dsh/DSH.md +2 -33
  242. package/dist/templates/dsh/index.d.ts +1 -19
  243. package/dist/templates/dsh/index.d.ts.map +1 -1
  244. package/dist/templates/dsh/index.js +2 -21
  245. package/dist/templates/dsh/index.js.map +1 -1
  246. package/dist/templates/gemini/index.d.ts +1 -11
  247. package/dist/templates/gemini/index.d.ts.map +1 -1
  248. package/dist/templates/gemini/index.js +2 -10
  249. package/dist/templates/gemini/index.js.map +1 -1
  250. package/dist/templates/kiro/agents/trellis.json +1 -1
  251. package/dist/templates/kiro/index.d.ts +1 -13
  252. package/dist/templates/kiro/index.d.ts.map +1 -1
  253. package/dist/templates/kiro/index.js +1 -13
  254. package/dist/templates/kiro/index.js.map +1 -1
  255. package/dist/templates/markdown/agents.md +15 -3
  256. package/dist/templates/markdown/index.d.ts +1 -0
  257. package/dist/templates/markdown/index.d.ts.map +1 -1
  258. package/dist/templates/markdown/index.js +1 -0
  259. package/dist/templates/markdown/index.js.map +1 -1
  260. package/dist/templates/markdown/spec/index.md.txt +20 -0
  261. package/dist/templates/omp/extensions/trellis/index.ts.txt +11 -51
  262. package/dist/templates/omp/index.d.ts +0 -2
  263. package/dist/templates/omp/index.d.ts.map +1 -1
  264. package/dist/templates/omp/index.js +1 -4
  265. package/dist/templates/omp/index.js.map +1 -1
  266. package/dist/templates/opencode/lib/session-utils.js +17 -5
  267. package/dist/templates/opencode/lib/trellis-context.js +12 -321
  268. package/dist/templates/opencode/plugins/inject-shell-session-context.js +93 -0
  269. package/dist/templates/opencode/plugins/inject-workflow-state.js +4 -10
  270. package/dist/templates/opencode/plugins/session-start.js +2 -6
  271. package/dist/templates/pi/extensions/trellis/index.ts.txt +8 -1432
  272. package/dist/templates/pi/index.d.ts +1 -2
  273. package/dist/templates/pi/index.d.ts.map +1 -1
  274. package/dist/templates/pi/index.js +2 -5
  275. package/dist/templates/pi/index.js.map +1 -1
  276. package/dist/templates/qoder/index.d.ts +2 -3
  277. package/dist/templates/qoder/index.d.ts.map +1 -1
  278. package/dist/templates/qoder/index.js +2 -3
  279. package/dist/templates/qoder/index.js.map +1 -1
  280. package/dist/templates/shared-hooks/guard-teamwork-wait.py +118 -12
  281. package/dist/templates/shared-hooks/index.d.ts +2 -56
  282. package/dist/templates/shared-hooks/index.d.ts.map +1 -1
  283. package/dist/templates/shared-hooks/index.js +3 -70
  284. package/dist/templates/shared-hooks/index.js.map +1 -1
  285. package/dist/templates/shared-hooks/inject-spec-context.py +6 -35
  286. package/dist/templates/shared-hooks/inject-workflow-state.py +18 -77
  287. package/dist/templates/shared-hooks/session-start.py +8 -6
  288. package/dist/templates/snow/SNOW.md +6 -18
  289. package/dist/templates/snow/hooks/write-trellis-context.py +51 -133
  290. package/dist/templates/snow/index.d.ts +2 -21
  291. package/dist/templates/snow/index.d.ts.map +1 -1
  292. package/dist/templates/snow/index.js +3 -24
  293. package/dist/templates/snow/index.js.map +1 -1
  294. package/dist/templates/template-utils.d.ts +1 -2
  295. package/dist/templates/template-utils.d.ts.map +1 -1
  296. package/dist/templates/template-utils.js +1 -11
  297. package/dist/templates/template-utils.js.map +1 -1
  298. package/dist/templates/trae/index.d.ts +2 -3
  299. package/dist/templates/trae/index.d.ts.map +1 -1
  300. package/dist/templates/trae/index.js +2 -3
  301. package/dist/templates/trae/index.js.map +1 -1
  302. package/dist/templates/trellis/agents/delegated-worktree-primary-agent.md +20 -22
  303. package/dist/templates/trellis/agents/teammate.md +6 -2
  304. package/dist/templates/trellis/agents/worktree-delegation-node.md +24 -0
  305. package/dist/templates/trellis/config.yaml +7 -36
  306. package/dist/templates/trellis/gitignore.txt +4 -0
  307. package/dist/templates/trellis/index.d.ts +1 -0
  308. package/dist/templates/trellis/index.d.ts.map +1 -1
  309. package/dist/templates/trellis/index.js +3 -0
  310. package/dist/templates/trellis/index.js.map +1 -1
  311. package/dist/templates/trellis/scripts/common/active_task.py +23 -31
  312. package/dist/templates/trellis/scripts/common/config.py +1 -36
  313. package/dist/templates/trellis/scripts/common/git_context.py +13 -4
  314. package/dist/templates/trellis/scripts/common/io.py +2 -2
  315. package/dist/templates/trellis/scripts/common/packages_context.py +29 -1
  316. package/dist/templates/trellis/scripts/common/session_context.py +25 -50
  317. package/dist/templates/trellis/scripts/common/task_context.py +5 -3
  318. package/dist/templates/trellis/scripts/common/task_continuity.py +42 -9
  319. package/dist/templates/trellis/scripts/common/task_move.py +2 -2
  320. package/dist/templates/trellis/scripts/common/task_runtime.py +211 -0
  321. package/dist/templates/trellis/scripts/common/task_store.py +8 -78
  322. package/dist/templates/trellis/scripts/common/task_workflow.py +9 -26
  323. package/dist/templates/trellis/scripts/common/workflow_phase.py +3 -36
  324. package/dist/templates/trellis/scripts/common/workflow_selection.py +12 -2
  325. package/dist/templates/trellis/scripts/common/worktree_delegation.py +570 -0
  326. package/dist/templates/trellis/scripts/task.py +41 -2
  327. package/dist/templates/trellis/workflow.md +25 -10
  328. package/dist/templates/zcode/config.json +0 -10
  329. package/dist/templates/zcode/index.d.ts +3 -22
  330. package/dist/templates/zcode/index.d.ts.map +1 -1
  331. package/dist/templates/zcode/index.js +3 -24
  332. package/dist/templates/zcode/index.js.map +1 -1
  333. package/dist/types/ai-tools.d.ts +0 -4
  334. package/dist/types/ai-tools.d.ts.map +1 -1
  335. package/dist/types/ai-tools.js +4 -109
  336. package/dist/types/ai-tools.js.map +1 -1
  337. package/dist/utils/ablation-store.d.ts.map +1 -1
  338. package/dist/utils/ablation-store.js +24 -0
  339. package/dist/utils/ablation-store.js.map +1 -1
  340. package/dist/utils/asset-backup.d.ts.map +1 -1
  341. package/dist/utils/asset-backup.js +25 -20
  342. package/dist/utils/asset-backup.js.map +1 -1
  343. package/dist/utils/file-writer.d.ts +2 -0
  344. package/dist/utils/file-writer.d.ts.map +1 -1
  345. package/dist/utils/file-writer.js +1 -1
  346. package/dist/utils/file-writer.js.map +1 -1
  347. package/dist/utils/managed-markdown.d.ts +5 -0
  348. package/dist/utils/managed-markdown.d.ts.map +1 -0
  349. package/dist/utils/managed-markdown.js +64 -0
  350. package/dist/utils/managed-markdown.js.map +1 -0
  351. package/dist/utils/managed-removal.d.ts +2 -0
  352. package/dist/utils/managed-removal.d.ts.map +1 -1
  353. package/dist/utils/managed-removal.js +26 -2
  354. package/dist/utils/managed-removal.js.map +1 -1
  355. package/dist/utils/manifest-prune.d.ts.map +1 -1
  356. package/dist/utils/manifest-prune.js +5 -12
  357. package/dist/utils/manifest-prune.js.map +1 -1
  358. package/dist/utils/retired-native-assets.d.ts +17 -0
  359. package/dist/utils/retired-native-assets.d.ts.map +1 -0
  360. package/dist/utils/retired-native-assets.js +235 -0
  361. package/dist/utils/retired-native-assets.js.map +1 -0
  362. package/dist/utils/uninstall-scrubbers.d.ts.map +1 -1
  363. package/dist/utils/uninstall-scrubbers.js +6 -12
  364. package/dist/utils/uninstall-scrubbers.js.map +1 -1
  365. package/package.json +2 -2
  366. package/dist/templates/claude/agents/trellis-check.md +0 -115
  367. package/dist/templates/claude/agents/trellis-implement.md +0 -110
  368. package/dist/templates/claude/agents/trellis-research.md +0 -137
  369. package/dist/templates/codebuddy/agents/trellis-check.md +0 -115
  370. package/dist/templates/codebuddy/agents/trellis-implement.md +0 -110
  371. package/dist/templates/codebuddy/agents/trellis-research.md +0 -137
  372. package/dist/templates/codex/agents/trellis-check.toml +0 -56
  373. package/dist/templates/codex/agents/trellis-implement.toml +0 -37
  374. package/dist/templates/codex/agents/trellis-research.toml +0 -78
  375. package/dist/templates/cursor/agents/trellis-check.md +0 -114
  376. package/dist/templates/cursor/agents/trellis-implement.md +0 -109
  377. package/dist/templates/cursor/agents/trellis-research.md +0 -136
  378. package/dist/templates/droid/droids/trellis-check.md +0 -107
  379. package/dist/templates/droid/droids/trellis-implement.md +0 -102
  380. package/dist/templates/droid/droids/trellis-research.md +0 -137
  381. package/dist/templates/dsh/agents/trellis-check.md +0 -99
  382. package/dist/templates/dsh/agents/trellis-implement.md +0 -106
  383. package/dist/templates/dsh/agents/trellis-research.md +0 -134
  384. package/dist/templates/gemini/agents/trellis-check.md +0 -107
  385. package/dist/templates/gemini/agents/trellis-implement.md +0 -102
  386. package/dist/templates/gemini/agents/trellis-research.md +0 -136
  387. package/dist/templates/grok/agents/trellis-check.md +0 -105
  388. package/dist/templates/grok/agents/trellis-implement.md +0 -116
  389. package/dist/templates/grok/agents/trellis-research.md +0 -146
  390. package/dist/templates/grok/index.d.ts +0 -16
  391. package/dist/templates/grok/index.d.ts.map +0 -1
  392. package/dist/templates/grok/index.js +0 -19
  393. package/dist/templates/grok/index.js.map +0 -1
  394. package/dist/templates/kimi/agents/trellis-check.md +0 -103
  395. package/dist/templates/kimi/agents/trellis-implement.md +0 -115
  396. package/dist/templates/kimi/agents/trellis-research.md +0 -144
  397. package/dist/templates/kimi/index.d.ts +0 -20
  398. package/dist/templates/kimi/index.d.ts.map +0 -1
  399. package/dist/templates/kimi/index.js +0 -23
  400. package/dist/templates/kimi/index.js.map +0 -1
  401. package/dist/templates/kiro/agents/trellis-check.json +0 -26
  402. package/dist/templates/kiro/agents/trellis-implement.json +0 -26
  403. package/dist/templates/kiro/agents/trellis-research.json +0 -30
  404. package/dist/templates/omp/agents/trellis-check.md +0 -41
  405. package/dist/templates/omp/agents/trellis-implement.md +0 -45
  406. package/dist/templates/omp/agents/trellis-research.md +0 -30
  407. package/dist/templates/opencode/agents/trellis-check.md +0 -122
  408. package/dist/templates/opencode/agents/trellis-implement.md +0 -118
  409. package/dist/templates/opencode/agents/trellis-research.md +0 -145
  410. package/dist/templates/opencode/plugins/inject-subagent-context.js +0 -569
  411. package/dist/templates/pi/agents/trellis-check.md +0 -37
  412. package/dist/templates/pi/agents/trellis-implement.md +0 -42
  413. package/dist/templates/pi/agents/trellis-research.md +0 -25
  414. package/dist/templates/qoder/agents/trellis-check.md +0 -108
  415. package/dist/templates/qoder/agents/trellis-implement.md +0 -103
  416. package/dist/templates/qoder/agents/trellis-research.md +0 -137
  417. package/dist/templates/reasonix/agents/trellis-check.md +0 -36
  418. package/dist/templates/reasonix/agents/trellis-implement.md +0 -41
  419. package/dist/templates/reasonix/index.d.ts +0 -13
  420. package/dist/templates/reasonix/index.d.ts.map +0 -1
  421. package/dist/templates/reasonix/index.js +0 -16
  422. package/dist/templates/reasonix/index.js.map +0 -1
  423. package/dist/templates/shared-hooks/inject-subagent-context.py +0 -1217
  424. package/dist/templates/snow/agents/trellis-check.md +0 -135
  425. package/dist/templates/snow/agents/trellis-implement.md +0 -153
  426. package/dist/templates/snow/agents/trellis-research.md +0 -114
  427. package/dist/templates/snow/hooks/beforeSubAgentStart.json +0 -15
  428. package/dist/templates/trae/agents/trellis-check.md +0 -108
  429. package/dist/templates/trae/agents/trellis-implement.md +0 -103
  430. package/dist/templates/trae/agents/trellis-research.md +0 -137
  431. package/dist/templates/zcode/agents/trellis-check.md +0 -109
  432. package/dist/templates/zcode/agents/trellis-implement.md +0 -111
  433. package/dist/templates/zcode/agents/trellis-research.md +0 -133
@@ -9,21 +9,20 @@ Provides:
9
9
  get_context_text_record - Text for record mode
10
10
  output_json - Print JSON
11
11
  output_text - Print text
12
- get_update_hint - Once-per-session "update available" line
12
+ get_update_hint - Once-per-version-pair "update available" line
13
13
  """
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
17
  import json
18
- import os
19
18
  import re
20
19
  import subprocess
21
20
  import sys
22
21
  from pathlib import Path
23
22
 
24
- from .active_task import resolve_context_key
25
23
  from .config import get_git_packages
26
24
  from .git import run_git
25
+ from .io import read_json, write_json
27
26
  from .packages_context import get_packages_section
28
27
  from .tasks import iter_active_tasks, load_task, get_all_statuses, children_progress
29
28
  from .paths import (
@@ -419,55 +418,17 @@ def _compare_versions(left: str, right: str) -> int | None:
419
418
 
420
419
 
421
420
  def _update_marker_path(repo_root: Path, context_key: str | None = None) -> Path:
422
- """Path of the once-per-session marker that throttles the update check.
423
-
424
- `context_key` lets a caller that already resolved session identity pass it
425
- in — the SessionStart hook reads the session id from hook stdin, which is
426
- more reliable than this function's environment-only fallback chain. Shell
427
- entry points leave it None and keep the previous behavior.
428
- """
429
- if not context_key:
430
- context_key = resolve_context_key()
431
- if not context_key:
432
- terminal_key = os.environ.get("TERM_SESSION_ID", "").strip()
433
- context_key = terminal_key or f"ppid-{os.getppid()}"
434
- safe_key = re.sub(r"[^A-Za-z0-9._-]+", "_", context_key).strip("._-")
435
- if not safe_key:
436
- safe_key = "session"
437
- return (
438
- repo_root
439
- / DIR_WORKFLOW
440
- / ".runtime"
441
- / f"update-check-{safe_key[:160]}.marker"
442
- )
443
-
444
-
445
- def _mark_update_check_attempted(
446
- repo_root: Path,
447
- context_key: str | None = None,
448
- ) -> bool:
449
- marker_path = _update_marker_path(repo_root, context_key)
450
- if marker_path.exists():
451
- return False
452
- try:
453
- marker_path.parent.mkdir(parents=True, exist_ok=True)
454
- marker_path.write_text("checked\n", encoding="utf-8")
455
- except OSError:
456
- pass
457
- return True
421
+ """Keep one advisory record, independent of the number of sessions."""
422
+ return repo_root / DIR_WORKFLOW / ".runtime" / "update-check.json"
458
423
 
459
424
 
460
425
  def get_update_hint(repo_root: Path, context_key: str | None = None) -> str | None:
461
- """Return the "update available" line for this session, at most once.
426
+ """Return the local CLI hint once per project/installed version pair.
462
427
 
463
428
  Public because the SessionStart hook imports it: the text-mode CLI path
464
429
  (`get_context.py`) used to be the only caller, so hook-driven platforms —
465
430
  Claude Code included — never saw the reminder at all.
466
431
  """
467
- marker_path = _update_marker_path(repo_root, context_key)
468
- if marker_path.exists():
469
- return None
470
-
471
432
  current_version = _read_project_version(repo_root)
472
433
  if not current_version:
473
434
  return None
@@ -476,7 +437,19 @@ def get_update_hint(repo_root: Path, context_key: str | None = None) -> str | No
476
437
  if not latest_version:
477
438
  return None
478
439
 
479
- _mark_update_check_attempted(repo_root, context_key)
440
+ from .task_move import layout_lock
441
+
442
+ pair = {"project_version": current_version, "installed_version": latest_version}
443
+ marker_path = _update_marker_path(repo_root, context_key)
444
+ try:
445
+ with layout_lock(repo_root):
446
+ if read_json(marker_path) == pair:
447
+ return None
448
+ marker_path.parent.mkdir(parents=True, exist_ok=True)
449
+ if not write_json(marker_path, pair):
450
+ print("Warning: could not persist the Trellis update hint.", file=sys.stderr)
451
+ except OSError:
452
+ pass
480
453
  comparison = _compare_versions(current_version, latest_version)
481
454
  if comparison is None or comparison >= 0:
482
455
  return None
@@ -527,6 +500,7 @@ def get_context_json(repo_root: Path | None = None) -> dict:
527
500
  "parent": t.parent,
528
501
  }
529
502
  for t in iter_active_tasks(tasks_dir)
503
+ if t.status in {"planning", "in_progress"}
530
504
  ]
531
505
 
532
506
  # Package git repos (independent sub-repositories)
@@ -652,8 +626,9 @@ def get_context_text(repo_root: Path | None = None) -> str:
652
626
  task_count = 0
653
627
 
654
628
  # Collect all task data for hierarchy display
655
- all_tasks = {t.dir_name: t for t in iter_active_tasks(tasks_dir)}
656
- all_statuses = {name: t.status for name, t in all_tasks.items()}
629
+ task_records = {t.dir_name: t for t in iter_active_tasks(tasks_dir)}
630
+ all_statuses = {name: t.status for name, t in task_records.items()}
631
+ all_tasks = {name: t for name, t in task_records.items() if t.status in {"planning", "in_progress"}}
657
632
 
658
633
  def _print_task_tree(name: str, indent: int = 0) -> None:
659
634
  nonlocal task_count
@@ -667,7 +642,7 @@ def get_context_text(repo_root: Path | None = None) -> str:
667
642
  _print_task_tree(child, indent + 1)
668
643
 
669
644
  for dir_name in sorted(all_tasks.keys()):
670
- if not all_tasks[dir_name].parent:
645
+ if all_tasks[dir_name].parent not in all_tasks:
671
646
  _print_task_tree(dir_name)
672
647
 
673
648
  if task_count == 0:
@@ -744,7 +719,7 @@ def get_context_record_json(repo_root: Path | None = None) -> dict:
744
719
 
745
720
  my_tasks = []
746
721
  for t in all_tasks_list:
747
- if t.assignee == developer:
722
+ if t.assignee == developer and t.status in {"planning", "in_progress"}:
748
723
  done = sum(
749
724
  1 for c in t.children
750
725
  if all_statuses.get(c) in ("completed", "done")
@@ -834,7 +809,7 @@ def get_context_text_record(repo_root: Path | None = None) -> str:
834
809
  all_statuses = get_all_statuses(tasks_dir)
835
810
 
836
811
  for t in iter_active_tasks(tasks_dir):
837
- if t.assignee == developer:
812
+ if t.assignee == developer and t.status in {"planning", "in_progress"}:
838
813
  progress = children_progress(t.children, all_statuses)
839
814
  lines.append(f"- [{t.priority}] {t.title} ({t.status}){progress} — {t.dir_name}")
840
815
  my_task_count += 1
@@ -10,7 +10,7 @@ Provides:
10
10
  Note:
11
11
  ``cmd_init_context`` was removed in v0.5.0-beta.12. JSONL context files
12
12
  are created empty at ``task.py create`` time; the AI agent curates real
13
- entries during planning when the task needs sub-agent/spec context. See
13
+ entries during planning when the task needs spec/research context. See
14
14
  ``.trellis/workflow.md`` for the current planning artifact contract.
15
15
 
16
16
  Older Trellis versions seeded those files with a ``{"_example": ...}``
@@ -35,7 +35,7 @@ from .task_utils import resolve_task_dir
35
35
  # Extensions that look like code rather than spec/research docs. Entries with
36
36
  # one of these extensions outside .trellis/spec/, docs/docs-site, or the
37
37
  # task's own directory get a hygiene warning in `task.py validate` — the
38
- # reader is a sub-agent, not a human, so code paths belong in the diff the
38
+ # reader is an AI session, so code paths belong in the diff the
39
39
  # agent reads itself, not in implement.jsonl / check.jsonl.
40
40
  _CODE_FILE_EXTENSIONS = {
41
41
  ".ts",
@@ -153,6 +153,8 @@ def cmd_validate(args: argparse.Namespace) -> int:
153
153
  task_json_path = target_dir / FILE_TASK_JSON
154
154
  if task_json_path.is_file():
155
155
  task_data = read_json(task_json_path)
156
+ if task_data and task_data.get("status") in {"completed", "cancelled"}:
157
+ print("Historical context diagnostic: missing references do not revoke accepted task history or authorize deletion.")
156
158
  stored_branch = task_data.get("branch") if task_data else None
157
159
  if stored_branch and not branch_exists_locally(stored_branch, repo_root):
158
160
  print(
@@ -208,7 +210,7 @@ def _validate_jsonl(jsonl_file: Path, repo_root: Path, task_dir: Path | None = N
208
210
  non-blocking hygiene warnings (never counted in ``errors``, never change
209
211
  the exit code): entries that look like code files rather than
210
212
  spec/research docs, and entries whose file size exceeds the configured
211
- sub-agent context injection cap (``context_injection.max_file_bytes``).
213
+ main-session context injection cap (``context_injection.max_file_bytes``).
212
214
  """
213
215
  file_name = jsonl_file.name
214
216
  errors = 0
@@ -242,8 +242,16 @@ def _projection(root: Path, directory: Path, data: dict, task_id: str) -> dict:
242
242
  evidence_digest = hashlib.sha256(
243
243
  json.dumps(sorted(evidence), ensure_ascii=False, separators=(",", ":")).encode("utf-8")
244
244
  ).hexdigest()
245
+ from .worktree_delegation import runtime_path, read as read_delegation
246
+ delegations = {}
247
+ for task_name in [directory.name, *data.get("children", [])]:
248
+ path = runtime_path(root, task_name)
249
+ if path.exists():
250
+ record = read_delegation(path)
251
+ delegations[task_name] = {"record_digest": _digest(record), "attempt_id": record.get("attempt_id"), "status": record.get("status"), "intent": record.get("intent")}
245
252
  return {
246
253
  "task": {"id": task_id, "path": directory.relative_to(root).as_posix(), "status": data.get("status")},
254
+ "delegations": delegations,
247
255
  "phase": {"current_phase_id": current_phase, "task_route_revision": route_revision, "input_revision": input_revision, "phases": phases},
248
256
  "evidence_digest": evidence_digest,
249
257
  "git": {
@@ -300,6 +308,15 @@ def continuity_show(args: argparse.Namespace) -> int:
300
308
 
301
309
 
302
310
  def continuity_capture(args: argparse.Namespace) -> int:
311
+ from .task_move import layout_lock
312
+
313
+ with layout_lock(get_repo_root()):
314
+ return _continuity_capture_locked(args)
315
+
316
+
317
+ def _continuity_capture_locked(args: argparse.Namespace) -> int:
318
+ from .task_move import layout_lock
319
+
303
320
  root = get_repo_root()
304
321
  try:
305
322
  directory, data, task_id, _ = _task(root)
@@ -307,7 +324,8 @@ def continuity_capture(args: argparse.Namespace) -> int:
307
324
  source_digest = _digest(current)
308
325
  task_path = directory.relative_to(root).as_posix()
309
326
  path = _continuity_path(root, task_path)
310
- with _record_lock(path):
327
+ with layout_lock(root):
328
+ path.parent.mkdir(parents=True, exist_ok=True)
311
329
  record, _ = _read_record(path)
312
330
  actual = record.get("source_digest") if record else "absent"
313
331
  if actual != args.expected_source_digest:
@@ -372,6 +390,15 @@ def _current_projection_digest(root: Path, task_dir: Path, data: dict, task_id:
372
390
 
373
391
 
374
392
  def transfer_task_ownership(args: argparse.Namespace) -> int:
393
+ from .task_move import layout_lock
394
+
395
+ with layout_lock(get_repo_root()):
396
+ return _transfer_task_ownership_locked(args)
397
+
398
+
399
+ def _transfer_task_ownership_locked(args: argparse.Namespace) -> int:
400
+ from .task_move import layout_lock
401
+
375
402
  root = get_repo_root()
376
403
  operation = args.transfer_action
377
404
  try:
@@ -392,7 +419,7 @@ def transfer_task_ownership(args: argparse.Namespace) -> int:
392
419
  if operation != "status" and data.get("status") in {"completed", "cancelled"}:
393
420
  raise ContinuityError("TASK_TRANSFER_WITHHELD", "terminal tasks cannot change ownership")
394
421
  path = _ownership_path(root, task_path)
395
- with _record_lock(path):
422
+ with layout_lock(root):
396
423
  record = _load_owner(path)
397
424
  if record and (record["task_id"] != task_id or record["task_path"] != task_path):
398
425
  raise ContinuityError("TASK_TRANSFER_WITHHELD", "ownership record does not match the requested task")
@@ -409,6 +436,7 @@ def transfer_task_ownership(args: argparse.Namespace) -> int:
409
436
  raise ContinuityError("TASK_TRANSFER_NOT_AUTHORIZED", "ownership changes require an explicit user request")
410
437
  if args.expected_generation is None or args.expected_generation < 0:
411
438
  raise ContinuityError("TASK_TRANSFER_INVALID_INPUT", "a non-negative expected generation is required")
439
+ path.parent.mkdir(parents=True, exist_ok=True)
412
440
  if operation == "quiesce":
413
441
  context_key, current_path = _direct_pointer(root, task_path)
414
442
  if current_path is None:
@@ -598,10 +626,10 @@ def add_continuity_commands(subparsers) -> None:
598
626
 
599
627
  def clear_task_runtime_records(repo_root: Path, task_path: str) -> bool:
600
628
  """Remove only this task's current continuity and ownership projections."""
601
- for path in (_continuity_path(repo_root, task_path), _ownership_path(repo_root, task_path)):
602
- if not path.exists():
603
- continue
604
- with _record_lock(path):
629
+ from .task_move import layout_lock
630
+
631
+ with layout_lock(repo_root):
632
+ for path in (_continuity_path(repo_root, task_path), _ownership_path(repo_root, task_path)):
605
633
  try:
606
634
  path.unlink(missing_ok=True)
607
635
  except OSError:
@@ -622,7 +650,7 @@ def active_task_change_guard(repo_root: Path, context_key: str, task_path: str,
622
650
  return
623
651
  task_path = directory.relative_to(repo_root).as_posix()
624
652
  path = _ownership_path(repo_root, task_path)
625
- with _record_lock(path):
653
+ with layout_lock(repo_root):
626
654
  try:
627
655
  record = _load_owner(path)
628
656
  except ContinuityError:
@@ -656,9 +684,11 @@ def assert_task_mutation_allowed(repo_root: Path, task_dir: Path, data: dict) ->
656
684
 
657
685
  def assert_task_identity_change_allowed(repo_root: Path, task_dir: Path, data: dict) -> None:
658
686
  """Keep an active ownership record addressable while the task ID is fixed."""
687
+ from .task_move import layout_lock
688
+
659
689
  task_path = task_dir.relative_to(repo_root).as_posix()
660
690
  path = _ownership_path(repo_root, task_path)
661
- with _record_lock(path):
691
+ with layout_lock(repo_root):
662
692
  try:
663
693
  record = _load_owner(path)
664
694
  except ContinuityError as error:
@@ -670,13 +700,16 @@ def assert_task_identity_change_allowed(repo_root: Path, task_dir: Path, data: d
670
700
  @contextlib.contextmanager
671
701
  def task_mutation_guard(repo_root: Path, task_dir: Path, data: dict):
672
702
  """Hold the ownership lock across a single task mutation."""
703
+ if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
704
+ yield False
705
+ return
673
706
  from .task_move import layout_lock, require_settled_layout
674
707
 
675
708
  with layout_lock(repo_root):
676
709
  require_settled_layout(repo_root)
677
710
  task_path = task_dir.relative_to(repo_root).as_posix()
678
711
  path = _ownership_path(repo_root, task_path)
679
- with _record_lock(path):
712
+ with layout_lock(repo_root):
680
713
  try:
681
714
  record = _load_owner(path)
682
715
  except ContinuityError:
@@ -107,8 +107,8 @@ def _plan(root: Path, moves: list[tuple[Path, Path]], updates: dict[Path, dict])
107
107
  elif not path.is_dir():
108
108
  raise ValueError(f"Unsupported task content: {path}")
109
109
  data = _read(source / "task.json")
110
- meta = data.get("meta")
111
- delegated = meta.get("delegated_worktree_execution_record") if isinstance(meta, dict) else None
110
+ from .worktree_delegation import resolve_record
111
+ delegated = resolve_record(root, source, data)
112
112
  if delegated is not None:
113
113
  from .task_workflow import _assert_delegated_record_closed
114
114
  _assert_delegated_record_closed(source.name, delegated)
@@ -0,0 +1,211 @@
1
+ """Bounded retirement of Trellis-owned projections; never task evidence."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import ast
7
+ import hashlib
8
+ from itertools import islice
9
+ import json
10
+ import os
11
+ from pathlib import Path
12
+ import re
13
+ import stat
14
+ import sys
15
+
16
+ from .io import read_json_checked
17
+ from .paths import get_repo_root
18
+ from .task_move import layout_lock, require_settled_layout
19
+ from .task_utils import is_within_tasks_dir, resolve_task_dir
20
+
21
+ MAX_FILES = 2048
22
+ MAX_BYTES = 256 * 1024
23
+ SESSION_KEYS = {"current_task", "current_run", "platform", "last_seen_at"}
24
+ MARKER = re.compile(r"update-check-[A-Za-z0-9_.-]+\.marker\Z")
25
+
26
+
27
+ def _fingerprint(path: Path) -> dict:
28
+ info = path.lstat()
29
+ if not stat.S_ISREG(info.st_mode) or info.st_size > MAX_BYTES:
30
+ raise ValueError("not a bounded regular file")
31
+ return {"device": info.st_dev, "inode": info.st_ino, "size": info.st_size,
32
+ "mtime_ns": info.st_mtime_ns, "mode": info.st_mode,
33
+ "sha256": hashlib.sha256(path.read_bytes()).hexdigest()}
34
+
35
+
36
+ def _protocol(root: Path) -> dict:
37
+ """Check the materialized writers, not merely the executing CLI version."""
38
+ scripts = root / ".trellis/scripts"
39
+ result = {}
40
+ checks = {"common/active_task.py": "_session_file_lock",
41
+ "common/task_workflow.py": "_task_lock",
42
+ "common/task_continuity.py": "continuity_capture",
43
+ "task.py": "main"}
44
+ for relative, function in checks.items():
45
+ path = scripts / relative
46
+ try:
47
+ if path.resolve() != path.absolute():
48
+ return {"ready": False, "reason": "redirected native writer"}
49
+ raw = path.read_bytes()
50
+ tree = ast.parse(raw)
51
+ node = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == function)
52
+ calls = {n.func.id for n in ast.walk(node)
53
+ if isinstance(n, ast.Call) and isinstance(n.func, ast.Name)}
54
+ if "layout_lock" not in calls:
55
+ return {"ready": False, "reason": "native writers still use the old protocol"}
56
+ if relative == "common/task_continuity.py" and any(
57
+ isinstance(n, ast.Call) and isinstance(n.func, ast.Name) and n.func.id == "_record_lock"
58
+ for n in ast.walk(tree)
59
+ ):
60
+ return {"ready": False, "reason": "per-record continuity writer remains"}
61
+ result[relative] = hashlib.sha256(raw).hexdigest()
62
+ except (OSError, SyntaxError, StopIteration, ValueError):
63
+ return {"ready": False, "reason": "cannot verify materialized native writers"}
64
+ return {"ready": True, "writers": result}
65
+
66
+
67
+ def _open_anchors(identities: set[tuple[int, int]]) -> tuple[set[tuple[int, int]], str | None]:
68
+ # Open descriptors include flock waiters; an empty /proc/locks snapshot does not.
69
+ if not identities:
70
+ return set(), None
71
+ if sys.platform != "linux":
72
+ return set(), "legacy anchor retirement requires descriptor verification on this platform"
73
+ opened: set[tuple[int, int]] = set()
74
+ inspected = 0
75
+ try:
76
+ processes = list(Path("/proc").iterdir())
77
+ if len(processes) > 8192:
78
+ return opened, "process inspection limit exceeded"
79
+ for process in processes:
80
+ if not process.name.isdigit():
81
+ continue
82
+ try:
83
+ if process.stat().st_uid != os.getuid():
84
+ continue
85
+ for descriptor in (process / "fd").iterdir():
86
+ inspected += 1
87
+ if inspected > 50000:
88
+ return opened, "descriptor inspection limit exceeded"
89
+ try:
90
+ info = descriptor.stat()
91
+ identity = (info.st_dev, info.st_ino)
92
+ if identity in identities:
93
+ opened.add(identity)
94
+ except FileNotFoundError:
95
+ pass
96
+ except FileNotFoundError:
97
+ pass
98
+ except OSError:
99
+ return opened, "cannot completely inspect same-user open descriptors"
100
+ return opened, None
101
+
102
+
103
+ def preview(root: Path, task: str | None = None) -> dict:
104
+ runtime = root / ".trellis/.runtime"
105
+ if runtime.resolve() != runtime.absolute():
106
+ raise ValueError("redirected runtime directory")
107
+ task_dir = resolve_task_dir(task, root) if task else None
108
+ if task and (task_dir is None or not is_within_tasks_dir(task_dir, root)):
109
+ raise ValueError("task scope must resolve to an existing native task")
110
+ task_path = task_dir.relative_to(root).as_posix() if task_dir else None
111
+ task_key = hashlib.sha256(task_path.encode()).hexdigest() if task_path else None
112
+ protocol = _protocol(root)
113
+ items: list[dict] = []
114
+ for family in ("sessions", "task-phase", "task-ownership", "continuity", ""):
115
+ directory = runtime / family
116
+ if not directory.exists():
117
+ continue
118
+ if directory.resolve() != directory.absolute() or not directory.is_dir():
119
+ raise ValueError("redirected or invalid runtime family")
120
+ paths = list(islice(directory.iterdir(), MAX_FILES + 1))
121
+ if len(paths) > MAX_FILES:
122
+ raise ValueError("runtime family scan limit exceeded; nothing may be removed")
123
+ for path in sorted(paths):
124
+ if family == "" and (task or not MARKER.fullmatch(path.name)):
125
+ continue
126
+ if family and path.suffix not in {".json", ".lock"}:
127
+ continue
128
+ if task_dir and not (family == "task-phase" and path.stem == task_dir.name or
129
+ family in {"continuity", "task-ownership"} and path.stem == task_key):
130
+ continue
131
+ if len(items) >= MAX_FILES:
132
+ raise ValueError("runtime preview limit exceeded; nothing may be removed")
133
+ item = {"path": path.relative_to(root).as_posix(), "family": family or "update-hint",
134
+ "eligible": False, "reason": "business record or unknown content"}
135
+ try:
136
+ fingerprint = _fingerprint(path)
137
+ item["fingerprint"] = fingerprint
138
+ if path.suffix == ".lock":
139
+ item["role"] = "retired-anchor"
140
+ if family in {"continuity", "task-ownership"}:
141
+ pattern = r"[0-9a-f]{64}"
142
+ elif family == "task-phase":
143
+ pattern = r"\d{2}-\d{2}-[A-Za-z0-9_.-]+"
144
+ else:
145
+ pattern = r"[A-Za-z0-9_.-]{1,128}"
146
+ known_name = bool(re.fullmatch(pattern, path.stem))
147
+ item["eligible"] = known_name and protocol["ready"] and path.read_bytes() in {b"", b"\0"}
148
+ item["reason"] = "native writers use the fixed layout anchor" if item["eligible"] else "writer protocol or anchor content is not verified"
149
+ elif family == "":
150
+ item["role"] = "obsolete-update-hint"
151
+ item["eligible"] = protocol["ready"] and path.read_bytes() == b"checked\n"
152
+ item["reason"] = "replaced by one version-pair record" if item["eligible"] else "unknown marker or old writer protocol"
153
+ elif family == "sessions":
154
+ data, _ = read_json_checked(path)
155
+ item["role"] = "session-projection"
156
+ item["eligible"] = (
157
+ data is not None and set(data) <= SESSION_KEYS
158
+ and data.get("current_task") in (None, "") and data.get("current_run") is None
159
+ and all(data.get(key) is None or isinstance(data[key], str) for key in ("platform", "last_seen_at"))
160
+ )
161
+ item["reason"] = "known empty business projection" if item["eligible"] else "task, run, unknown field or invalid record is retained"
162
+ else:
163
+ item["role"] = "control-evidence"
164
+ except (OSError, ValueError):
165
+ item["reason"] = "unreadable, redirected, nonregular or oversized object"
166
+ items.append(item)
167
+ anchors = {(i["fingerprint"]["device"], i["fingerprint"]["inode"])
168
+ for i in items if i.get("role") == "retired-anchor" and i["eligible"]}
169
+ opened, error = _open_anchors(anchors)
170
+ for item in items:
171
+ if item.get("role") != "retired-anchor" or not item["eligible"]:
172
+ continue
173
+ info = item["fingerprint"]
174
+ if error or (info["device"], info["inode"]) in opened:
175
+ item.update(eligible=False, reason=error or "an existing writer or waiter has the anchor open")
176
+ result = {"owner": "trellis-task", "scope": task_path or "project-runtime",
177
+ "writer_protocol": protocol, "items": items}
178
+ result["digest"] = hashlib.sha256(json.dumps(result, sort_keys=True, separators=(",", ":")).encode()).hexdigest()
179
+ return result
180
+
181
+
182
+ def cmd_runtime(args: argparse.Namespace) -> int:
183
+ root = get_repo_root()
184
+ with layout_lock(root):
185
+ require_settled_layout(root)
186
+ result = preview(root, args.dir)
187
+ result["dry_run"] = not bool(args.confirm)
188
+ result["removed"] = []
189
+ result["failed"] = []
190
+ if args.confirm:
191
+ if args.confirm != result["digest"]:
192
+ print(json.dumps({"status": "stale", "preview": result}, ensure_ascii=False))
193
+ return 1
194
+ for item in result["items"]:
195
+ if not item["eligible"]:
196
+ continue
197
+ path = root / item["path"]
198
+ try:
199
+ if _fingerprint(path) != item["fingerprint"]:
200
+ raise ValueError("object changed after confirmation")
201
+ if item["role"] == "retired-anchor":
202
+ info = item["fingerprint"]
203
+ opened, error = _open_anchors({(info["device"], info["inode"])})
204
+ if error or opened:
205
+ raise ValueError(error or "anchor became open")
206
+ path.unlink()
207
+ result["removed"].append(item["path"])
208
+ except (OSError, ValueError) as error:
209
+ result["failed"].append({"path": item["path"], "reason": str(error)})
210
+ print(json.dumps(result, ensure_ascii=False, sort_keys=True))
211
+ return 1 if result["failed"] else 0
@@ -25,7 +25,6 @@ from datetime import datetime
25
25
  from pathlib import Path
26
26
 
27
27
  from .config import (
28
- get_codex_dispatch_mode,
29
28
  get_packages,
30
29
  is_monorepo,
31
30
  resolve_package,
@@ -195,52 +194,6 @@ def _task_identity_change_allowed(repo_root: Path, task_dir: Path, data: dict) -
195
194
  return True
196
195
 
197
196
 
198
- # Sub-agent platform detection + JSONL context files
199
- # =============================================================================
200
-
201
- # Config directories of platforms that consume implement.jsonl / check.jsonl.
202
- # Keep in sync with src/types/ai-tools.ts AI_TOOLS entries — these are the
203
- # platforms listed in workflow.md's "agent-capable" Skill Routing block.
204
- # Codex is checked separately because explicit inline mode does not consume
205
- # JSONL. Kilo / Antigravity / Devin are NOT in this list either: they load
206
- # specs through skills instead of JSONL.
207
- _SUBAGENT_CONFIG_DIRS: tuple[str, ...] = (
208
- ".claude",
209
- ".cursor",
210
- ".kiro",
211
- ".gemini",
212
- ".opencode",
213
- ".qoder",
214
- ".codebuddy",
215
- ".factory", # Factory Droid
216
- ".github/copilot",
217
- ".pi", # Pi Agent
218
- ".trae", # Trae IDE
219
- ".omp", # Oh My Pi
220
- ".zcode", # ZCode
221
- ".grok", # Grok Build
222
- ".kimi-code", # Kimi Code
223
- ".dsh", # DeepSeek Harness
224
- )
225
- _CODEX_CONFIG_DIR = ".codex"
226
-
227
-
228
- def _has_subagent_platform(repo_root: Path) -> bool:
229
- """Return True if any sub-agent-capable platform is configured.
230
-
231
- Detected by probing well-known config directories at the repo root. Codex
232
- counts by default through ``codex.dispatch_mode: auto`` (including the
233
- legacy ``sub-agent`` alias); explicit inline mode loads context through
234
- skills, not JSONL.
235
- """
236
- for config_dir in _SUBAGENT_CONFIG_DIRS:
237
- if (repo_root / config_dir).is_dir():
238
- return True
239
- if (repo_root / _CODEX_CONFIG_DIR).is_dir():
240
- return get_codex_dispatch_mode(repo_root) == "auto"
241
- return False
242
-
243
-
244
197
  def _parse_meta_pairs(pairs: list[str] | None) -> dict[str, str] | None:
245
198
  """Parse repeatable ``--meta key=value`` pairs into a dict.
246
199
 
@@ -580,21 +533,6 @@ def cmd_create(args: argparse.Namespace) -> int:
580
533
  encoding="utf-8",
581
534
  )
582
535
 
583
- # Create empty implement.jsonl / check.jsonl for sub-agent-capable
584
- # platforms. They stay empty until the agent curates real entries during
585
- # planning — a placeholder row would read as unresolved scaffolding to
586
- # `task.py validate` and to PR preflight, so the curation instructions go
587
- # to the console below instead of into the files. Agent-less platforms
588
- # (Kilo / Antigravity / Devin) skip this — they load specs via the
589
- # trellis-before-dev skill instead of JSONL.
590
- created_jsonl = False
591
- if _has_subagent_platform(repo_root):
592
- for jsonl_name in ("implement.jsonl", "check.jsonl"):
593
- jsonl_path = task_dir / jsonl_name
594
- if not jsonl_path.exists():
595
- jsonl_path.write_text("", encoding="utf-8")
596
- created_jsonl = True
597
-
598
536
  # Establish the bidirectional link. Both sides were validated above, so a
599
537
  # failure here is a write failure, not a bad argument.
600
538
  if parent_dir is not None and parent_data is not None:
@@ -691,21 +629,7 @@ def cmd_create(args: argparse.Namespace) -> int:
691
629
  print(" - Fill prd.md with requirements and acceptance criteria", file=sys.stderr)
692
630
  print(" - Lightweight task: PRD-only is valid", file=sys.stderr)
693
631
  print(" - Complex task: add design.md and implement.md before task.py start", file=sys.stderr)
694
- if created_jsonl:
695
- print(
696
- " - Curate implement.jsonl / check.jsonl (created empty) as spec/research "
697
- "manifests before task.py start when sub-agents need context:",
698
- file=sys.stderr,
699
- )
700
- print(
701
- ' one JSON object per line — {"file": "<path>", "reason": "<why>"}; '
702
- "spec/research docs only, no code paths",
703
- file=sys.stderr,
704
- )
705
- print(
706
- " list available specs: python3 .trellis/scripts/get_context.py --mode packages",
707
- file=sys.stderr,
708
- )
632
+ print(" - Add optional spec/research context with task.py add-context when needed", file=sys.stderr)
709
633
  print(" - Use /trellis:continue or phase context to decide the next step", file=sys.stderr)
710
634
  print("", file=sys.stderr)
711
635
 
@@ -1019,6 +943,11 @@ def cmd_rename(args: argparse.Namespace) -> int:
1019
943
  print(colored(f"Error: Task not found: {args.name}", Colors.RED), file=sys.stderr)
1020
944
  return 1
1021
945
 
946
+ from .worktree_delegation import runtime_path
947
+ if runtime_path(repo_root, task_dir.name).exists():
948
+ print("Error: preserve delegation identity; a task with delegation runtime cannot be renamed", file=sys.stderr)
949
+ return 1
950
+
1022
951
  # Restrict renames to the prescribed status directory levels.
1023
952
  if not is_within_tasks_dir(task_dir, repo_root):
1024
953
  print(
@@ -1259,7 +1188,8 @@ def cmd_remove_subtask(args: argparse.Namespace) -> int:
1259
1188
 
1260
1189
  if parent_data.get("status") != "cancelled":
1261
1190
  from .task_workflow import _assert_delegated_record_closed
1262
- _assert_delegated_record_closed(child_dir.name, child_data.get("meta", {}).get("delegated_worktree_execution_record"))
1191
+ from .worktree_delegation import resolve_record
1192
+ _assert_delegated_record_closed(child_dir.name, resolve_record(repo_root, child_dir, child_data))
1263
1193
  original_parent = json.loads(json.dumps(parent_data))
1264
1194
  # Remove child from parent's children list
1265
1195
  parent_children = _ensure_children_list(parent_data)