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

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 (476) hide show
  1. package/README.md +14 -0
  2. package/dist/cli/index.js +4 -0
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/commands/ablate.d.ts.map +1 -1
  5. package/dist/commands/ablate.js +13 -0
  6. package/dist/commands/ablate.js.map +1 -1
  7. package/dist/commands/init.d.ts +2 -0
  8. package/dist/commands/init.d.ts.map +1 -1
  9. package/dist/commands/init.js +138 -120
  10. package/dist/commands/init.js.map +1 -1
  11. package/dist/commands/teamwork/adapters/acp.d.ts.map +1 -1
  12. package/dist/commands/teamwork/adapters/acp.js +3 -0
  13. package/dist/commands/teamwork/adapters/acp.js.map +1 -1
  14. package/dist/commands/teamwork/adapters/index.d.ts +1 -1
  15. package/dist/commands/teamwork/adapters/index.d.ts.map +1 -1
  16. package/dist/commands/teamwork/artifact.d.ts +2 -0
  17. package/dist/commands/teamwork/artifact.d.ts.map +1 -1
  18. package/dist/commands/teamwork/artifact.js +4 -2
  19. package/dist/commands/teamwork/artifact.js.map +1 -1
  20. package/dist/commands/teamwork/batch-reservation.d.ts.map +1 -1
  21. package/dist/commands/teamwork/batch-reservation.js +16 -8
  22. package/dist/commands/teamwork/batch-reservation.js.map +1 -1
  23. package/dist/commands/teamwork/batch.d.ts +15 -1
  24. package/dist/commands/teamwork/batch.d.ts.map +1 -1
  25. package/dist/commands/teamwork/batch.js +279 -24
  26. package/dist/commands/teamwork/batch.js.map +1 -1
  27. package/dist/commands/teamwork/coordinator.d.ts +3 -0
  28. package/dist/commands/teamwork/coordinator.d.ts.map +1 -1
  29. package/dist/commands/teamwork/coordinator.js +22 -3
  30. package/dist/commands/teamwork/coordinator.js.map +1 -1
  31. package/dist/commands/teamwork/create.d.ts +1 -0
  32. package/dist/commands/teamwork/create.d.ts.map +1 -1
  33. package/dist/commands/teamwork/create.js +4 -0
  34. package/dist/commands/teamwork/create.js.map +1 -1
  35. package/dist/commands/teamwork/evidence-references.d.ts +19 -0
  36. package/dist/commands/teamwork/evidence-references.d.ts.map +1 -0
  37. package/dist/commands/teamwork/evidence-references.js +249 -0
  38. package/dist/commands/teamwork/evidence-references.js.map +1 -0
  39. package/dist/commands/teamwork/foreground-wait.d.ts +4 -1
  40. package/dist/commands/teamwork/foreground-wait.d.ts.map +1 -1
  41. package/dist/commands/teamwork/foreground-wait.js +15 -1
  42. package/dist/commands/teamwork/foreground-wait.js.map +1 -1
  43. package/dist/commands/teamwork/index.d.ts.map +1 -1
  44. package/dist/commands/teamwork/index.js +47 -5
  45. package/dist/commands/teamwork/index.js.map +1 -1
  46. package/dist/commands/teamwork/list.d.ts +1 -0
  47. package/dist/commands/teamwork/list.d.ts.map +1 -1
  48. package/dist/commands/teamwork/list.js +4 -1
  49. package/dist/commands/teamwork/list.js.map +1 -1
  50. package/dist/commands/teamwork/prompt.js +1 -1
  51. package/dist/commands/teamwork/prompt.js.map +1 -1
  52. package/dist/commands/teamwork/rm.d.ts +27 -4
  53. package/dist/commands/teamwork/rm.d.ts.map +1 -1
  54. package/dist/commands/teamwork/rm.js +155 -51
  55. package/dist/commands/teamwork/rm.js.map +1 -1
  56. package/dist/commands/teamwork/run.d.ts.map +1 -1
  57. package/dist/commands/teamwork/run.js +10 -1
  58. package/dist/commands/teamwork/run.js.map +1 -1
  59. package/dist/commands/teamwork/runtime.d.ts +1 -1
  60. package/dist/commands/teamwork/runtime.d.ts.map +1 -1
  61. package/dist/commands/teamwork/runtime.js +14 -4
  62. package/dist/commands/teamwork/runtime.js.map +1 -1
  63. package/dist/commands/teamwork/spawn.d.ts.map +1 -1
  64. package/dist/commands/teamwork/spawn.js +4 -1
  65. package/dist/commands/teamwork/spawn.js.map +1 -1
  66. package/dist/commands/teamwork/supervisor/stdout.d.ts.map +1 -1
  67. package/dist/commands/teamwork/supervisor/stdout.js +7 -0
  68. package/dist/commands/teamwork/supervisor/stdout.js.map +1 -1
  69. package/dist/commands/teamwork/supervisor.d.ts +1 -1
  70. package/dist/commands/teamwork/supervisor.d.ts.map +1 -1
  71. package/dist/commands/teamwork/teammate-adapters.d.ts +3 -0
  72. package/dist/commands/teamwork/teammate-adapters.d.ts.map +1 -1
  73. package/dist/commands/teamwork/teammate-adapters.js +14 -5
  74. package/dist/commands/teamwork/teammate-adapters.js.map +1 -1
  75. package/dist/commands/teamwork/teammate-launch.d.ts +3 -1
  76. package/dist/commands/teamwork/teammate-launch.d.ts.map +1 -1
  77. package/dist/commands/teamwork/teammate-launch.js +7 -5
  78. package/dist/commands/teamwork/teammate-launch.js.map +1 -1
  79. package/dist/commands/teamwork/workers.d.ts +8 -0
  80. package/dist/commands/teamwork/workers.d.ts.map +1 -0
  81. package/dist/commands/teamwork/workers.js +67 -0
  82. package/dist/commands/teamwork/workers.js.map +1 -0
  83. package/dist/commands/update.d.ts.map +1 -1
  84. package/dist/commands/update.js +188 -59
  85. package/dist/commands/update.js.map +1 -1
  86. package/dist/commands/workflow.d.ts.map +1 -1
  87. package/dist/commands/workflow.js +5 -7
  88. package/dist/commands/workflow.js.map +1 -1
  89. package/dist/configurators/codebuddy.d.ts +1 -8
  90. package/dist/configurators/codebuddy.d.ts.map +1 -1
  91. package/dist/configurators/codebuddy.js +2 -12
  92. package/dist/configurators/codebuddy.js.map +1 -1
  93. package/dist/configurators/codex.d.ts +0 -36
  94. package/dist/configurators/codex.d.ts.map +1 -1
  95. package/dist/configurators/codex.js +13 -106
  96. package/dist/configurators/codex.js.map +1 -1
  97. package/dist/configurators/copilot.d.ts +1 -12
  98. package/dist/configurators/copilot.d.ts.map +1 -1
  99. package/dist/configurators/copilot.js +2 -20
  100. package/dist/configurators/copilot.js.map +1 -1
  101. package/dist/configurators/cursor.d.ts +1 -8
  102. package/dist/configurators/cursor.d.ts.map +1 -1
  103. package/dist/configurators/cursor.js +2 -12
  104. package/dist/configurators/cursor.js.map +1 -1
  105. package/dist/configurators/droid.d.ts +1 -8
  106. package/dist/configurators/droid.d.ts.map +1 -1
  107. package/dist/configurators/droid.js +2 -12
  108. package/dist/configurators/droid.js.map +1 -1
  109. package/dist/configurators/dsh.d.ts +1 -21
  110. package/dist/configurators/dsh.d.ts.map +1 -1
  111. package/dist/configurators/dsh.js +4 -37
  112. package/dist/configurators/dsh.js.map +1 -1
  113. package/dist/configurators/gemini.d.ts +1 -16
  114. package/dist/configurators/gemini.d.ts.map +1 -1
  115. package/dist/configurators/gemini.js +3 -21
  116. package/dist/configurators/gemini.js.map +1 -1
  117. package/dist/configurators/grok.d.ts +1 -12
  118. package/dist/configurators/grok.d.ts.map +1 -1
  119. package/dist/configurators/grok.js +2 -18
  120. package/dist/configurators/grok.js.map +1 -1
  121. package/dist/configurators/kimi.d.ts +1 -21
  122. package/dist/configurators/kimi.d.ts.map +1 -1
  123. package/dist/configurators/kimi.js +2 -38
  124. package/dist/configurators/kimi.js.map +1 -1
  125. package/dist/configurators/kiro.d.ts +1 -9
  126. package/dist/configurators/kiro.d.ts.map +1 -1
  127. package/dist/configurators/kiro.js +1 -9
  128. package/dist/configurators/kiro.js.map +1 -1
  129. package/dist/configurators/omp.d.ts.map +1 -1
  130. package/dist/configurators/omp.js +1 -5
  131. package/dist/configurators/omp.js.map +1 -1
  132. package/dist/configurators/pi.d.ts.map +1 -1
  133. package/dist/configurators/pi.js +2 -5
  134. package/dist/configurators/pi.js.map +1 -1
  135. package/dist/configurators/qoder.d.ts +1 -10
  136. package/dist/configurators/qoder.d.ts.map +1 -1
  137. package/dist/configurators/qoder.js +3 -15
  138. package/dist/configurators/qoder.js.map +1 -1
  139. package/dist/configurators/reasonix.d.ts +1 -12
  140. package/dist/configurators/reasonix.d.ts.map +1 -1
  141. package/dist/configurators/reasonix.js +3 -22
  142. package/dist/configurators/reasonix.js.map +1 -1
  143. package/dist/configurators/shared.d.ts +1 -24
  144. package/dist/configurators/shared.d.ts.map +1 -1
  145. package/dist/configurators/shared.js +5 -184
  146. package/dist/configurators/shared.js.map +1 -1
  147. package/dist/configurators/snow.d.ts +1 -20
  148. package/dist/configurators/snow.d.ts.map +1 -1
  149. package/dist/configurators/snow.js +2 -25
  150. package/dist/configurators/snow.js.map +1 -1
  151. package/dist/configurators/trae.d.ts +1 -14
  152. package/dist/configurators/trae.d.ts.map +1 -1
  153. package/dist/configurators/trae.js +3 -19
  154. package/dist/configurators/trae.js.map +1 -1
  155. package/dist/configurators/workflow.d.ts +5 -0
  156. package/dist/configurators/workflow.d.ts.map +1 -1
  157. package/dist/configurators/workflow.js +85 -57
  158. package/dist/configurators/workflow.js.map +1 -1
  159. package/dist/configurators/zcode.d.ts +1 -13
  160. package/dist/configurators/zcode.d.ts.map +1 -1
  161. package/dist/configurators/zcode.js +2 -18
  162. package/dist/configurators/zcode.js.map +1 -1
  163. package/dist/migrations/manifests/0.5.0-beta.5.json +1 -212
  164. package/dist/migrations/manifests/0.7.2-beta.10.json +9 -0
  165. package/dist/migrations/manifests/0.7.2-beta.11.json +9 -0
  166. package/dist/migrations/manifests/0.7.2-beta.12.json +9 -0
  167. package/dist/migrations/manifests/0.7.2-beta.13.json +9 -0
  168. package/dist/migrations/manifests/0.7.2-beta.14.json +9 -0
  169. package/dist/migrations/manifests/0.7.2-beta.15.json +9 -0
  170. package/dist/migrations/manifests/0.7.2-beta.16.json +9 -0
  171. package/dist/migrations/manifests/0.7.2-beta.17.json +9 -0
  172. package/dist/migrations/manifests/0.7.2-beta.18.json +9 -0
  173. package/dist/migrations/manifests/0.7.2-beta.19.json +11 -0
  174. package/dist/migrations/manifests/0.7.2-beta.20.json +9 -0
  175. package/dist/migrations/manifests/0.7.2-beta.21.json +9 -0
  176. package/dist/migrations/manifests/0.7.2-beta.22.json +9 -0
  177. package/dist/migrations/manifests/0.7.2-beta.23.json +9 -0
  178. package/dist/migrations/manifests/0.7.2-beta.24.json +8 -0
  179. package/dist/migrations/manifests/0.7.2-beta.25.json +8 -0
  180. package/dist/migrations/manifests/0.7.2-beta.26.json +8 -0
  181. package/dist/migrations/manifests/0.7.2-beta.27.json +8 -0
  182. package/dist/migrations/manifests/0.7.2-beta.28.json +8 -0
  183. package/dist/migrations/manifests/0.7.2-beta.29.json +8 -0
  184. package/dist/migrations/manifests/0.7.2-beta.30.json +10 -0
  185. package/dist/migrations/manifests/0.7.2-beta.4.json +9 -0
  186. package/dist/migrations/manifests/0.7.2-beta.5.json +9 -0
  187. package/dist/migrations/manifests/0.7.2-beta.6.json +9 -0
  188. package/dist/migrations/manifests/0.7.2-beta.7.json +9 -0
  189. package/dist/migrations/manifests/0.7.2-beta.8.json +9 -0
  190. package/dist/migrations/manifests/0.7.2-beta.9.json +9 -0
  191. package/dist/migrations/retired-native-paths.d.ts +109 -0
  192. package/dist/migrations/retired-native-paths.d.ts.map +1 -0
  193. package/dist/migrations/retired-native-paths.js +263 -0
  194. package/dist/migrations/retired-native-paths.js.map +1 -0
  195. package/dist/templates/claude/index.d.ts +1 -16
  196. package/dist/templates/claude/index.d.ts.map +1 -1
  197. package/dist/templates/claude/index.js +5 -32
  198. package/dist/templates/claude/index.js.map +1 -1
  199. package/dist/templates/claude/settings.json +0 -22
  200. package/dist/templates/codebuddy/index.d.ts +2 -3
  201. package/dist/templates/codebuddy/index.d.ts.map +1 -1
  202. package/dist/templates/codebuddy/index.js +2 -3
  203. package/dist/templates/codebuddy/index.js.map +1 -1
  204. package/dist/templates/codebuddy/settings.json +0 -10
  205. package/dist/templates/codex/config.toml +4 -19
  206. package/dist/templates/codex/hooks/session-start.py +25 -30
  207. package/dist/templates/codex/hooks/turn-guard.py +67 -0
  208. package/dist/templates/codex/hooks.json +57 -6
  209. package/dist/templates/codex/index.d.ts +0 -5
  210. package/dist/templates/codex/index.d.ts.map +1 -1
  211. package/dist/templates/codex/index.js +0 -13
  212. package/dist/templates/codex/index.js.map +1 -1
  213. package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/SKILL.md +2 -0
  214. package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/workflow.md +13 -3
  215. package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/SKILL.md +2 -0
  216. package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/workflow.md +17 -9
  217. package/dist/templates/common/bundled-skills/trellis-goal-exploration-and-requirements/SKILL.md +2 -0
  218. package/dist/templates/common/bundled-skills/trellis-goal-exploration-and-requirements/workflow.md +7 -3
  219. package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +7 -7
  220. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +9 -51
  221. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +3 -15
  222. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +1 -2
  223. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/bundled-skills.md +1 -1
  224. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +4 -9
  225. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +2 -2
  226. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/multi-agent-teamwork.md +6 -0
  227. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +1 -1
  228. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +10 -8
  229. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +9 -79
  230. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +2 -4
  231. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +3 -6
  232. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +24 -103
  233. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +1 -1
  234. package/dist/templates/common/bundled-skills/trellis-session-insight/SKILL.md +1 -1
  235. package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/SKILL.md +2 -0
  236. package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/workflow.md +27 -6
  237. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/SKILL.md +9 -7
  238. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/mcp-setup.md +12 -84
  239. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/repository-analysis.md +5 -25
  240. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-task-planning.md +5 -9
  241. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-writing.md +8 -0
  242. package/dist/templates/common/bundled-skills/trellis-task-implementation/SKILL.md +2 -0
  243. package/dist/templates/common/bundled-skills/trellis-task-implementation/workflow.md +5 -3
  244. package/dist/templates/common/bundled-skills/trellis-teamwork/SKILL.md +8 -1
  245. package/dist/templates/common/bundled-skills/trellis-teamwork/references/teammate-processes.md +21 -1
  246. package/dist/templates/common/bundled-skills/trellis-teamwork/references/teamwork-plan-construction.md +13 -2
  247. package/dist/templates/common/bundled-skills/trellis-worktree-delegation/SKILL.md +14 -0
  248. package/dist/templates/common/bundled-skills/trellis-worktree-delegation/workflow.md +82 -0
  249. package/dist/templates/common/commands/continue.md +16 -1
  250. package/dist/templates/common/commands/start.md +2 -0
  251. package/dist/templates/common/skills/before-dev.md +3 -1
  252. package/dist/templates/common/skills/check.md +3 -1
  253. package/dist/templates/common/skills/request-intake.md +14 -1
  254. package/dist/templates/copilot/hooks/session-start.py +11 -30
  255. package/dist/templates/cursor/hooks.json +0 -7
  256. package/dist/templates/cursor/index.d.ts +1 -11
  257. package/dist/templates/cursor/index.d.ts.map +1 -1
  258. package/dist/templates/cursor/index.js +2 -10
  259. package/dist/templates/cursor/index.js.map +1 -1
  260. package/dist/templates/droid/index.d.ts +2 -3
  261. package/dist/templates/droid/index.d.ts.map +1 -1
  262. package/dist/templates/droid/index.js +2 -3
  263. package/dist/templates/droid/index.js.map +1 -1
  264. package/dist/templates/droid/settings.json +0 -10
  265. package/dist/templates/dsh/DSH.md +2 -33
  266. package/dist/templates/dsh/index.d.ts +1 -19
  267. package/dist/templates/dsh/index.d.ts.map +1 -1
  268. package/dist/templates/dsh/index.js +2 -21
  269. package/dist/templates/dsh/index.js.map +1 -1
  270. package/dist/templates/gemini/index.d.ts +1 -11
  271. package/dist/templates/gemini/index.d.ts.map +1 -1
  272. package/dist/templates/gemini/index.js +2 -10
  273. package/dist/templates/gemini/index.js.map +1 -1
  274. package/dist/templates/kiro/index.d.ts +1 -13
  275. package/dist/templates/kiro/index.d.ts.map +1 -1
  276. package/dist/templates/kiro/index.js +1 -13
  277. package/dist/templates/kiro/index.js.map +1 -1
  278. package/dist/templates/markdown/agents.md +9 -14
  279. package/dist/templates/markdown/index.d.ts +1 -0
  280. package/dist/templates/markdown/index.d.ts.map +1 -1
  281. package/dist/templates/markdown/index.js +1 -0
  282. package/dist/templates/markdown/index.js.map +1 -1
  283. package/dist/templates/markdown/spec/index.md.txt +20 -0
  284. package/dist/templates/omp/extensions/trellis/index.ts.txt +27 -60
  285. package/dist/templates/omp/index.d.ts +0 -2
  286. package/dist/templates/omp/index.d.ts.map +1 -1
  287. package/dist/templates/omp/index.js +1 -4
  288. package/dist/templates/omp/index.js.map +1 -1
  289. package/dist/templates/opencode/lib/session-utils.js +17 -5
  290. package/dist/templates/opencode/lib/trellis-context.js +12 -321
  291. package/dist/templates/opencode/plugins/inject-shell-session-context.js +93 -0
  292. package/dist/templates/opencode/plugins/inject-workflow-state.js +19 -17
  293. package/dist/templates/opencode/plugins/session-start.js +2 -6
  294. package/dist/templates/pi/extensions/trellis/index.ts.txt +17 -1436
  295. package/dist/templates/pi/index.d.ts +1 -2
  296. package/dist/templates/pi/index.d.ts.map +1 -1
  297. package/dist/templates/pi/index.js +2 -5
  298. package/dist/templates/pi/index.js.map +1 -1
  299. package/dist/templates/qoder/index.d.ts +2 -3
  300. package/dist/templates/qoder/index.d.ts.map +1 -1
  301. package/dist/templates/qoder/index.js +2 -3
  302. package/dist/templates/qoder/index.js.map +1 -1
  303. package/dist/templates/shared-hooks/guard-teamwork-wait.py +118 -12
  304. package/dist/templates/shared-hooks/index.d.ts +2 -56
  305. package/dist/templates/shared-hooks/index.d.ts.map +1 -1
  306. package/dist/templates/shared-hooks/index.js +4 -70
  307. package/dist/templates/shared-hooks/index.js.map +1 -1
  308. package/dist/templates/shared-hooks/inject-shell-session-context.py +27 -1
  309. package/dist/templates/shared-hooks/inject-spec-context.py +6 -35
  310. package/dist/templates/shared-hooks/inject-workflow-state.py +62 -104
  311. package/dist/templates/shared-hooks/session-start.py +8 -6
  312. package/dist/templates/snow/SNOW.md +6 -18
  313. package/dist/templates/snow/hooks/write-trellis-context.py +51 -133
  314. package/dist/templates/snow/index.d.ts +2 -21
  315. package/dist/templates/snow/index.d.ts.map +1 -1
  316. package/dist/templates/snow/index.js +3 -24
  317. package/dist/templates/snow/index.js.map +1 -1
  318. package/dist/templates/template-utils.d.ts +1 -2
  319. package/dist/templates/template-utils.d.ts.map +1 -1
  320. package/dist/templates/template-utils.js +1 -11
  321. package/dist/templates/template-utils.js.map +1 -1
  322. package/dist/templates/trae/index.d.ts +2 -3
  323. package/dist/templates/trae/index.d.ts.map +1 -1
  324. package/dist/templates/trae/index.js +2 -3
  325. package/dist/templates/trae/index.js.map +1 -1
  326. package/dist/templates/trellis/agents/delegated-worktree-primary-agent.md +22 -22
  327. package/dist/templates/trellis/agents/teammate.md +6 -2
  328. package/dist/templates/trellis/agents/worktree-delegation-node.md +30 -0
  329. package/dist/templates/trellis/config.yaml +7 -36
  330. package/dist/templates/trellis/gitignore.txt +4 -0
  331. package/dist/templates/trellis/index.d.ts +1 -0
  332. package/dist/templates/trellis/index.d.ts.map +1 -1
  333. package/dist/templates/trellis/index.js +9 -0
  334. package/dist/templates/trellis/index.js.map +1 -1
  335. package/dist/templates/trellis/scripts/common/active_task.py +23 -31
  336. package/dist/templates/trellis/scripts/common/config.py +16 -36
  337. package/dist/templates/trellis/scripts/common/git_context.py +13 -4
  338. package/dist/templates/trellis/scripts/common/io.py +2 -2
  339. package/dist/templates/trellis/scripts/common/markdown_format.py +107 -0
  340. package/dist/templates/trellis/scripts/common/packages_context.py +29 -1
  341. package/dist/templates/trellis/scripts/common/session_context.py +25 -50
  342. package/dist/templates/trellis/scripts/common/task_context.py +5 -3
  343. package/dist/templates/trellis/scripts/common/task_continuity.py +66 -9
  344. package/dist/templates/trellis/scripts/common/task_move.py +11 -5
  345. package/dist/templates/trellis/scripts/common/task_runtime.py +211 -0
  346. package/dist/templates/trellis/scripts/common/task_store.py +8 -78
  347. package/dist/templates/trellis/scripts/common/task_turn.py +514 -0
  348. package/dist/templates/trellis/scripts/common/task_workflow.py +380 -395
  349. package/dist/templates/trellis/scripts/common/workflow_phase.py +3 -36
  350. package/dist/templates/trellis/scripts/common/workflow_selection.py +35 -40
  351. package/dist/templates/trellis/scripts/common/worktree_delegation.py +690 -0
  352. package/dist/templates/trellis/scripts/common/worktree_delegation_contract.py +446 -0
  353. package/dist/templates/trellis/scripts/common/worktree_delegation_messages.py +376 -0
  354. package/dist/templates/trellis/scripts/common/worktree_delegation_transport.py +57 -0
  355. package/dist/templates/trellis/scripts/markdown_format.py +40 -0
  356. package/dist/templates/trellis/scripts/task.py +73 -10
  357. package/dist/templates/trellis/workflow.md +48 -9
  358. package/dist/templates/zcode/config.json +0 -10
  359. package/dist/templates/zcode/index.d.ts +3 -22
  360. package/dist/templates/zcode/index.d.ts.map +1 -1
  361. package/dist/templates/zcode/index.js +3 -24
  362. package/dist/templates/zcode/index.js.map +1 -1
  363. package/dist/types/ai-tools.d.ts +0 -4
  364. package/dist/types/ai-tools.d.ts.map +1 -1
  365. package/dist/types/ai-tools.js +4 -109
  366. package/dist/types/ai-tools.js.map +1 -1
  367. package/dist/utils/ablation-store.d.ts.map +1 -1
  368. package/dist/utils/ablation-store.js +41 -1
  369. package/dist/utils/ablation-store.js.map +1 -1
  370. package/dist/utils/asset-backup.d.ts +1 -0
  371. package/dist/utils/asset-backup.d.ts.map +1 -1
  372. package/dist/utils/asset-backup.js +131 -31
  373. package/dist/utils/asset-backup.js.map +1 -1
  374. package/dist/utils/atomic-write.d.ts +1 -1
  375. package/dist/utils/atomic-write.d.ts.map +1 -1
  376. package/dist/utils/atomic-write.js +8 -2
  377. package/dist/utils/atomic-write.js.map +1 -1
  378. package/dist/utils/codex-config-ownership.d.ts +13 -0
  379. package/dist/utils/codex-config-ownership.d.ts.map +1 -0
  380. package/dist/utils/codex-config-ownership.js +64 -0
  381. package/dist/utils/codex-config-ownership.js.map +1 -0
  382. package/dist/utils/file-writer.d.ts +2 -0
  383. package/dist/utils/file-writer.d.ts.map +1 -1
  384. package/dist/utils/file-writer.js +1 -1
  385. package/dist/utils/file-writer.js.map +1 -1
  386. package/dist/utils/managed-markdown.d.ts +5 -0
  387. package/dist/utils/managed-markdown.d.ts.map +1 -0
  388. package/dist/utils/managed-markdown.js +64 -0
  389. package/dist/utils/managed-markdown.js.map +1 -0
  390. package/dist/utils/managed-removal.d.ts +2 -0
  391. package/dist/utils/managed-removal.d.ts.map +1 -1
  392. package/dist/utils/managed-removal.js +62 -8
  393. package/dist/utils/managed-removal.js.map +1 -1
  394. package/dist/utils/manifest-prune.d.ts.map +1 -1
  395. package/dist/utils/manifest-prune.js +5 -12
  396. package/dist/utils/manifest-prune.js.map +1 -1
  397. package/dist/utils/project-init.d.ts +26 -0
  398. package/dist/utils/project-init.d.ts.map +1 -0
  399. package/dist/utils/project-init.js +484 -0
  400. package/dist/utils/project-init.js.map +1 -0
  401. package/dist/utils/retired-native-assets.d.ts +17 -0
  402. package/dist/utils/retired-native-assets.d.ts.map +1 -0
  403. package/dist/utils/retired-native-assets.js +221 -0
  404. package/dist/utils/retired-native-assets.js.map +1 -0
  405. package/dist/utils/uninstall-scrubbers.d.ts.map +1 -1
  406. package/dist/utils/uninstall-scrubbers.js +6 -12
  407. package/dist/utils/uninstall-scrubbers.js.map +1 -1
  408. package/package.json +2 -2
  409. package/dist/templates/claude/agents/trellis-check.md +0 -115
  410. package/dist/templates/claude/agents/trellis-implement.md +0 -110
  411. package/dist/templates/claude/agents/trellis-research.md +0 -137
  412. package/dist/templates/codebuddy/agents/trellis-check.md +0 -115
  413. package/dist/templates/codebuddy/agents/trellis-implement.md +0 -110
  414. package/dist/templates/codebuddy/agents/trellis-research.md +0 -137
  415. package/dist/templates/codex/agents/trellis-check.toml +0 -56
  416. package/dist/templates/codex/agents/trellis-implement.toml +0 -37
  417. package/dist/templates/codex/agents/trellis-research.toml +0 -78
  418. package/dist/templates/cursor/agents/trellis-check.md +0 -114
  419. package/dist/templates/cursor/agents/trellis-implement.md +0 -109
  420. package/dist/templates/cursor/agents/trellis-research.md +0 -136
  421. package/dist/templates/droid/droids/trellis-check.md +0 -107
  422. package/dist/templates/droid/droids/trellis-implement.md +0 -102
  423. package/dist/templates/droid/droids/trellis-research.md +0 -137
  424. package/dist/templates/dsh/agents/trellis-check.md +0 -99
  425. package/dist/templates/dsh/agents/trellis-implement.md +0 -106
  426. package/dist/templates/dsh/agents/trellis-research.md +0 -134
  427. package/dist/templates/gemini/agents/trellis-check.md +0 -107
  428. package/dist/templates/gemini/agents/trellis-implement.md +0 -102
  429. package/dist/templates/gemini/agents/trellis-research.md +0 -136
  430. package/dist/templates/grok/agents/trellis-check.md +0 -105
  431. package/dist/templates/grok/agents/trellis-implement.md +0 -116
  432. package/dist/templates/grok/agents/trellis-research.md +0 -146
  433. package/dist/templates/grok/index.d.ts +0 -16
  434. package/dist/templates/grok/index.d.ts.map +0 -1
  435. package/dist/templates/grok/index.js +0 -19
  436. package/dist/templates/grok/index.js.map +0 -1
  437. package/dist/templates/kimi/agents/trellis-check.md +0 -103
  438. package/dist/templates/kimi/agents/trellis-implement.md +0 -115
  439. package/dist/templates/kimi/agents/trellis-research.md +0 -144
  440. package/dist/templates/kimi/index.d.ts +0 -20
  441. package/dist/templates/kimi/index.d.ts.map +0 -1
  442. package/dist/templates/kimi/index.js +0 -23
  443. package/dist/templates/kimi/index.js.map +0 -1
  444. package/dist/templates/kiro/agents/trellis-check.json +0 -26
  445. package/dist/templates/kiro/agents/trellis-implement.json +0 -26
  446. package/dist/templates/kiro/agents/trellis-research.json +0 -30
  447. package/dist/templates/omp/agents/trellis-check.md +0 -41
  448. package/dist/templates/omp/agents/trellis-implement.md +0 -45
  449. package/dist/templates/omp/agents/trellis-research.md +0 -30
  450. package/dist/templates/opencode/agents/trellis-check.md +0 -122
  451. package/dist/templates/opencode/agents/trellis-implement.md +0 -118
  452. package/dist/templates/opencode/agents/trellis-research.md +0 -145
  453. package/dist/templates/opencode/plugins/inject-subagent-context.js +0 -569
  454. package/dist/templates/pi/agents/trellis-check.md +0 -37
  455. package/dist/templates/pi/agents/trellis-implement.md +0 -42
  456. package/dist/templates/pi/agents/trellis-research.md +0 -25
  457. package/dist/templates/qoder/agents/trellis-check.md +0 -108
  458. package/dist/templates/qoder/agents/trellis-implement.md +0 -103
  459. package/dist/templates/qoder/agents/trellis-research.md +0 -137
  460. package/dist/templates/reasonix/agents/trellis-check.md +0 -36
  461. package/dist/templates/reasonix/agents/trellis-implement.md +0 -41
  462. package/dist/templates/reasonix/index.d.ts +0 -13
  463. package/dist/templates/reasonix/index.d.ts.map +0 -1
  464. package/dist/templates/reasonix/index.js +0 -16
  465. package/dist/templates/reasonix/index.js.map +0 -1
  466. package/dist/templates/shared-hooks/inject-subagent-context.py +0 -1217
  467. package/dist/templates/snow/agents/trellis-check.md +0 -135
  468. package/dist/templates/snow/agents/trellis-implement.md +0 -153
  469. package/dist/templates/snow/agents/trellis-research.md +0 -114
  470. package/dist/templates/snow/hooks/beforeSubAgentStart.json +0 -15
  471. package/dist/templates/trae/agents/trellis-check.md +0 -108
  472. package/dist/templates/trae/agents/trellis-implement.md +0 -103
  473. package/dist/templates/trae/agents/trellis-research.md +0 -137
  474. package/dist/templates/zcode/agents/trellis-check.md +0 -109
  475. package/dist/templates/zcode/agents/trellis-implement.md +0 -111
  476. package/dist/templates/zcode/agents/trellis-research.md +0 -133
@@ -1,22 +1,30 @@
1
- import { execSync } from "node:child_process";
1
+ import { execFileSync, execSync } from "node:child_process";
2
2
  import fs from "node:fs";
3
+ import { assertCurrentExecutionTree } from "../utils/retired-native-assets.js";
3
4
  import path from "node:path";
4
5
  import readline from "node:readline";
5
6
  import chalk from "chalk";
6
7
  import figlet from "figlet";
7
8
  import inquirer from "inquirer";
8
- import { createWorkflowStructure } from "../configurators/workflow.js";
9
+ import { createWorkflowStructure, ensureSpecIndex, } from "../configurators/workflow.js";
9
10
  import { withAssetMaintenance } from "../utils/asset-backup.js";
11
+ import { resolveProjectPolicy, preflightProjectInit, completeProjectInit, } from "../utils/project-init.js";
12
+ import { writeFileAtomic } from "../utils/atomic-write.js";
13
+ import { CODEX_CONFIG_PATH } from "../utils/codex-config-ownership.js";
14
+ import { getConfigTemplate as getCodexConfigTemplate } from "../templates/codex/index.js";
15
+ import { managedBlock, mergeManagedMarkdown, readManagedMarkdown, } from "../utils/managed-markdown.js";
16
+ import { TRELLIS_BLOCK_START, TRELLIS_BLOCK_END, } from "../utils/managed-paths.js";
17
+ import { recordWrite } from "../utils/file-writer.js";
10
18
  import { getInitToolChoices, resolveCliFlag, configurePlatform, getConfiguredPlatforms, getPlatformsWithPythonHooks, } from "../configurators/index.js";
11
19
  import { getPythonCommandForPlatform, setResolvedPythonCommand, } from "../configurators/shared.js";
12
20
  import { AI_TOOLS } from "../types/ai-tools.js";
13
21
  import { DIR_NAMES, FILE_NAMES, PATHS } from "../constants/paths.js";
14
22
  import { VERSION } from "../constants/version.js";
15
23
  import { agentsMdContent } from "../templates/markdown/index.js";
16
- import { setWriteMode, startRecordingWrites, stopRecordingWrites, writeFile, } from "../utils/file-writer.js";
24
+ import { setWriteMode, startRecordingWrites, stopRecordingWrites, } from "../utils/file-writer.js";
17
25
  import { emptyTaskJson } from "../utils/task-json.js";
18
26
  import { detectProjectType, detectMonorepo, sanitizePkgName, } from "../utils/project-detector.js";
19
- import { initializeHashes, removeHash } from "../utils/template-hash.js";
27
+ import { computeHash, initializeHashes, loadHashes, removeHash, saveHashes, } from "../utils/template-hash.js";
20
28
  import { NATIVE_WORKFLOW_ID, resolveWorkflowTemplate, } from "../utils/workflow-resolver.js";
21
29
  import { isCwdHomedir, homedirGuardMessage, homedirBypassEnabled, } from "../utils/cwd-guard.js";
22
30
  import { writeSpecRegistryConfig, } from "../utils/registry-config.js";
@@ -34,6 +42,11 @@ function tasksAreEmpty(cwd) {
34
42
  progress.cancelled ===
35
43
  0);
36
44
  }
45
+ function initializeDeveloper(cwd, pythonCmd, name) {
46
+ const script = path.join(cwd, PATHS.SCRIPTS, "init_developer.py");
47
+ const [command, ...prefix] = pythonCmd === "py -3" ? ["py", "-3"] : [pythonCmd];
48
+ execFileSync(command, [...prefix, script, name], { cwd, stdio: "pipe" });
49
+ }
37
50
  const MIN_PYTHON_MAJOR = 3;
38
51
  const MIN_PYTHON_MINOR = 9;
39
52
  const PYTHON_VERSION_RE = /Python (\d+)\.(\d+)/;
@@ -262,35 +275,22 @@ function writeTaskSkeleton(cwd, taskName, taskJson, prdContent) {
262
275
  * stays canonical with `subtasks: string[]` (child task dir names, same as
263
276
  * task_store.py).
264
277
  */
265
- function getBootstrapChecklistItems(projectType, packages) {
278
+ function getBootstrapChecklistItems(_projectType, packages) {
266
279
  if (packages && packages.length > 0) {
267
280
  const items = packages.map((pkg) => `Fill guidelines for ${pkg.name}`);
268
281
  items.push("Add code examples");
269
282
  return items;
270
283
  }
271
- if (projectType === "frontend") {
272
- return ["Fill frontend guidelines", "Add code examples"];
273
- }
274
- if (projectType === "backend") {
275
- return ["Fill backend guidelines", "Add code examples"];
276
- }
277
284
  return [
278
- "Fill backend guidelines",
279
- "Fill frontend guidelines",
280
- "Add code examples",
285
+ "Establish applicable project guidelines",
286
+ "Add source-backed examples and verification",
281
287
  ];
282
288
  }
283
- function getBootstrapRelatedFiles(projectType, packages) {
289
+ function getBootstrapRelatedFiles(_projectType, packages) {
284
290
  if (packages && packages.length > 0) {
285
291
  return packages.map((pkg) => `.trellis/spec/${sanitizePkgName(pkg.name)}/`);
286
292
  }
287
- if (projectType === "frontend") {
288
- return [".trellis/spec/frontend/"];
289
- }
290
- if (projectType === "backend") {
291
- return [".trellis/spec/backend/"];
292
- }
293
- return [".trellis/spec/backend/", ".trellis/spec/frontend/"];
293
+ return [".trellis/spec/index.md"];
294
294
  }
295
295
  function getBootstrapPrdContent(projectType, pythonCmd, packages) {
296
296
  const checklistItems = getBootstrapChecklistItems(projectType, packages);
@@ -307,10 +307,8 @@ exists under \`.trellis/tasks/\`. When they want to work on it, they should star
307
307
  this task from a session that provides Trellis session identity.
308
308
 
309
309
  **Your job**: help them populate \`.trellis/spec/\` with the team's real
310
- coding conventions. Every future AI session — this project's
311
- \`trellis-implement\` and \`trellis-check\` sub-agents — auto-loads spec files
312
- listed in per-task jsonl manifests. Empty spec = sub-agents write generic
313
- code. Real spec = sub-agents match the team's actual patterns.
310
+ coding conventions. Future AI sessions use these conventions during implementation and review.
311
+ Task JSONL manifests are optional context references, not execution authority.
314
312
 
315
313
  Don't dump instructions. Open with a short greeting, figure out if the repo
316
314
  has any existing convention docs (CLAUDE.md, .cursorrules, etc.), and drive
@@ -325,30 +323,6 @@ ${checklistMarkdown}
325
323
  ---
326
324
 
327
325
  ## Spec files to populate
328
- `;
329
- const backendSection = `
330
-
331
- ### Backend guidelines
332
-
333
- | File | What to document |
334
- |------|------------------|
335
- | \`.trellis/spec/backend/directory-structure.md\` | Where different file types go (routes, services, utils) |
336
- | \`.trellis/spec/backend/error-handling.md\` | How errors are caught, logged, and returned |
337
- | \`.trellis/spec/backend/logging-guidelines.md\` | Log levels, format, what to log |
338
- | \`.trellis/spec/backend/quality-guidelines.md\` | Code review standards, testing requirements |
339
- `;
340
- const frontendSection = `
341
-
342
- ### Frontend guidelines
343
-
344
- | File | What to document |
345
- |------|------------------|
346
- | \`.trellis/spec/frontend/directory-structure.md\` | Component/page/hook organization |
347
- | \`.trellis/spec/frontend/component-guidelines.md\` | Component patterns, props conventions |
348
- | \`.trellis/spec/frontend/hook-guidelines.md\` | Custom hook naming, patterns |
349
- | \`.trellis/spec/frontend/state-management.md\` | State library, patterns, what goes where |
350
- | \`.trellis/spec/frontend/type-safety.md\` | TypeScript conventions, type organization |
351
- | \`.trellis/spec/frontend/quality-guidelines.md\` | Linting, testing, accessibility |
352
326
  `;
353
327
  const footer = `
354
328
 
@@ -400,8 +374,7 @@ Scan real code to discover patterns. Before writing each spec file:
400
374
  ### Step 3: Document reality, not ideals
401
375
 
402
376
  **Critical**: write what the code *actually does*, not what it should do.
403
- Sub-agents match the spec, so aspirational patterns that don't exist in the
404
- codebase will cause sub-agents to write code that looks out of place.
377
+ AI sessions follow the spec, so describe existing patterns accurately.
405
378
 
406
379
  If the team has known tech debt, document the current state — improvement
407
380
  is a separate conversation, not a bootstrap concern.
@@ -410,13 +383,11 @@ is a separate conversation, not a bootstrap concern.
410
383
 
411
384
  ## Quick explainer of the runtime (share when they ask "why do we need spec at all")
412
385
 
413
- - Every AI coding task spawns two sub-agents: \`trellis-implement\` (writes
414
- code) and \`trellis-check\` (verifies quality).
415
- - Each task has \`implement.jsonl\` / \`check.jsonl\` manifests listing which
416
- spec files to load.
417
- - The platform hook auto-injects those spec files + the task's \`prd.md\`
418
- into every sub-agent prompt, so the sub-agent codes/reviews per team
419
- conventions without anyone pasting them manually.
386
+ - The main session implements and verifies the authorized contract.
387
+ - Tasks may have optional \`implement.jsonl\` / \`check.jsonl\` context manifests.
388
+ - Supported hooks inject current task and phase context. Without hook
389
+ context, explicitly read those references and the applicable spec indexes;
390
+ inspect the current phase with \`task.py phase show <task>\`.
420
391
  - Source of truth: \`.trellis/spec/\`. That's why filling it well now pays
421
392
  off forever.
422
393
 
@@ -448,27 +419,13 @@ etc.) I can pull from, or should I scan the codebase from scratch?"
448
419
  if (packages && packages.length > 0) {
449
420
  // Monorepo: generate per-package sections
450
421
  for (const pkg of packages) {
451
- const pkgType = pkg.type === "unknown" ? "fullstack" : pkg.type;
452
422
  const specName = sanitizePkgName(pkg.name);
453
- content += `\n### Package: ${pkg.name} (\`spec/${specName}/\`)\n`;
454
- if (pkgType !== "frontend") {
455
- content += `\n- Backend guidelines: \`.trellis/spec/${specName}/backend/\`\n`;
456
- }
457
- if (pkgType !== "backend") {
458
- content += `\n- Frontend guidelines: \`.trellis/spec/${specName}/frontend/\`\n`;
459
- }
423
+ content += `\n### Package: ${pkg.name}\n\nRead and populate \`.trellis/spec/${specName}/index.md\`.\n`;
460
424
  }
461
425
  }
462
- else if (projectType === "frontend") {
463
- content += frontendSection;
464
- }
465
- else if (projectType === "backend") {
466
- content += backendSection;
467
- }
468
426
  else {
469
- // fullstack
470
- content += backendSection;
471
- content += frontendSection;
427
+ content +=
428
+ "\nRead and populate `.trellis/spec/index.md`; add only evidence-backed topics.\n";
472
429
  }
473
430
  content += footer;
474
431
  return content;
@@ -577,8 +534,8 @@ code every session.
577
534
  carrying the current task + phase hint.
578
535
  - **\`/trellis:continue\`** reads the active phase from the Trellis task record
579
536
  and routes to that phase's Skill.
580
- - Hosts may use \`trellis-implement\` and \`trellis-check\` agents when their
581
- workflow and the authorized contract call for delegated work.
537
+ - Collaboration uses \`trellis teamwork\` for read-only packages or
538
+ \`paseo-based-parallelism\` for authorized implementation packages.
582
539
 
583
540
  File layout (mention when they ask "where does what live"):
584
541
  - \`.trellis/.runtime/sessions/<session>.json\` — session active-task state, gitignored
@@ -663,32 +620,43 @@ async function handleReinit(cwd, options, developerName, pythonCmd) {
663
620
  if (options.yes) {
664
621
  console.log(chalk.gray(`Already initialized with: ${configuredNames}`));
665
622
  console.log(chalk.gray("Use platform flags (e.g., --codex) or -u <name> to add platforms/developer."));
666
- return true;
667
623
  }
668
- console.log(chalk.gray(`\n Already initialized with: ${configuredNames}\n`));
669
- const { action } = await inquirer.prompt([
670
- {
671
- type: "list",
672
- name: "action",
673
- message: "Trellis is already initialized. What would you like to do?",
674
- choices: [
675
- { name: "Add AI platform(s)", value: "add-platform" },
676
- {
677
- name: "Set up developer identity on this device",
678
- value: "add-developer",
679
- },
680
- { name: "Full re-initialize", value: "full" },
681
- ],
682
- },
683
- ]);
684
- if (action === "full") {
685
- return false; // Fall through to full init
624
+ else {
625
+ console.log(chalk.gray(`\n Already initialized with: ${configuredNames}\n`));
626
+ const { action } = await inquirer.prompt([
627
+ {
628
+ type: "list",
629
+ name: "action",
630
+ message: "Trellis is already initialized. What would you like to do?",
631
+ choices: [
632
+ { name: "Add AI platform(s)", value: "add-platform" },
633
+ {
634
+ name: "Set up developer identity on this device",
635
+ value: "add-developer",
636
+ },
637
+ { name: "Full re-initialize", value: "full" },
638
+ ],
639
+ },
640
+ ]);
641
+ if (action === "full") {
642
+ return false; // Fall through to full init
643
+ }
644
+ if (action === "add-platform")
645
+ doAddPlatforms = true;
646
+ if (action === "add-developer")
647
+ doAddDeveloper = true;
686
648
  }
687
- if (action === "add-platform")
688
- doAddPlatforms = true;
689
- if (action === "add-developer")
690
- doAddDeveloper = true;
691
649
  }
650
+ const specResult = ensureSpecIndex(cwd);
651
+ console.log(chalk.gray(`Spec root index: ${specResult}. Source-backed conventions require trellis-spec-bootstrap review.`));
652
+ const rootWritten = startRecordingWrites(cwd);
653
+ try {
654
+ await createRootFiles(cwd, options);
655
+ }
656
+ finally {
657
+ stopRecordingWrites();
658
+ }
659
+ initializeHashes(cwd, { trackedPaths: rootWritten, merge: true });
692
660
  // --- Add platforms ---
693
661
  if (doAddPlatforms) {
694
662
  if (platformsToAdd.length === 0) {
@@ -769,11 +737,7 @@ async function handleReinit(cwd, options, developerName, pythonCmd) {
769
737
  // joiner onboarding onto an existing Trellis project.
770
738
  const hadDeveloperFileBefore = fs.existsSync(path.join(cwd, DIR_NAMES.WORKFLOW, FILE_NAMES.DEVELOPER));
771
739
  try {
772
- const scriptPath = path.join(cwd, PATHS.SCRIPTS, "init_developer.py");
773
- execSync(`${pythonCmd} "${scriptPath}" "${devName}"`, {
774
- cwd,
775
- stdio: "pipe",
776
- });
740
+ initializeDeveloper(cwd, pythonCmd, devName);
777
741
  console.log(chalk.green(`✓ Developer "${devName}" initialized`));
778
742
  }
779
743
  catch {
@@ -850,11 +814,24 @@ function writeMonorepoConfig(cwd, packages) {
850
814
  // Use first non-submodule package as default, fallback to first package
851
815
  const defaultPkg = packages.find((p) => !p.isSubmodule)?.name ?? packages[0]?.name;
852
816
  if (defaultPkg) {
853
- lines.push(`default_package: ${defaultPkg}`);
817
+ lines.push(`default_package: ${sanitizePkgName(defaultPkg)}`);
854
818
  }
855
819
  fs.writeFileSync(configPath, content.trimEnd() + "\n" + lines.join("\n") + "\n", "utf-8");
856
820
  }
857
821
  export async function init(options) {
822
+ // Existing legacy projects must use the ownership-aware update transaction.
823
+ assertCurrentExecutionTree(process.cwd());
824
+ const projectRoot = fs.realpathSync(process.cwd());
825
+ const otherPlatformSelected = !options.codex &&
826
+ Object.values(AI_TOOLS).some((tool) => options[tool.cliFlag] === true);
827
+ if (otherPlatformSelected && (options.trustCodex || options.codegraph))
828
+ throw new Error("Codex project automation requires selecting the Codex platform");
829
+ const projectPlan = otherPlatformSelected
830
+ ? { trustCodex: false, codegraph: false }
831
+ : resolveProjectPolicy(projectRoot, options);
832
+ if (options.codex ||
833
+ fs.existsSync(path.join(projectRoot, ".codex/config.toml")))
834
+ await preflightProjectInit(projectRoot, projectPlan);
858
835
  return withAssetMaintenance(process.cwd(), async () => {
859
836
  // Refuse to run in $HOME — running here would scoop platform runtime data
860
837
  // (Claude/Codex/OpenCode session histories etc.) into the trellis hash
@@ -938,8 +915,10 @@ export async function init(options) {
938
915
  !tasksEmptyEarly &&
939
916
  !hasTemplateRequest) {
940
917
  const reinitDone = await handleReinit(cwd, options, developerName, pythonCmd);
941
- if (reinitDone)
918
+ if (reinitDone) {
919
+ await completeProjectInit(projectRoot, projectPlan);
942
920
  return;
921
+ }
943
922
  // reinitDone === false means user chose "full re-initialize" → fall through
944
923
  }
945
924
  if (!developerName && !options.yes) {
@@ -1053,7 +1032,10 @@ export async function init(options) {
1053
1032
  name: "specSource",
1054
1033
  message: `Spec source for ${pkg.name} (${pkg.path}):`,
1055
1034
  choices: [
1056
- { name: "From scratch (Trellis default)", value: "blank" },
1035
+ {
1036
+ name: "From scratch (Trellis default)",
1037
+ value: "blank",
1038
+ },
1057
1039
  { name: "Download remote template", value: "remote" },
1058
1040
  ],
1059
1041
  default: "blank",
@@ -1480,6 +1462,7 @@ export async function init(options) {
1480
1462
  // platform/root entries — replacing the previous "walk every managed dir"
1481
1463
  // approach that swept user-owned runtime files into the manifest
1482
1464
  // (.codex/sessions/, .claude/projects/, pre-existing AGENTS.md).
1465
+ const previousHashes = loadHashes(cwd);
1483
1466
  const writtenPaths = startRecordingWrites(cwd);
1484
1467
  try {
1485
1468
  // Create workflow structure with project type
@@ -1490,6 +1473,7 @@ export async function init(options) {
1490
1473
  packages: monorepoPackages,
1491
1474
  remoteSpecPackages,
1492
1475
  workflowMdOverride,
1476
+ isFirstInit,
1493
1477
  });
1494
1478
  // Write monorepo packages to config.yaml (non-destructive patch)
1495
1479
  if (monorepoPackages) {
@@ -1518,7 +1502,7 @@ export async function init(options) {
1518
1502
  logPythonAdaptationNotice(pythonCmd);
1519
1503
  }
1520
1504
  // Create root files (skip if exists)
1521
- await createRootFiles(cwd);
1505
+ await createRootFiles(cwd, options);
1522
1506
  }
1523
1507
  finally {
1524
1508
  stopRecordingWrites();
@@ -1528,6 +1512,15 @@ export async function init(options) {
1528
1512
  }
1529
1513
  // Initialize template hashes for modification tracking
1530
1514
  const hashedCount = initializeHashes(cwd, { trackedPaths: writtenPaths });
1515
+ const nextHashes = loadHashes(cwd);
1516
+ if (previousHashes[FILE_NAMES.AGENTS] &&
1517
+ !writtenPaths.has(FILE_NAMES.AGENTS))
1518
+ nextHashes[FILE_NAMES.AGENTS] = previousHashes[FILE_NAMES.AGENTS];
1519
+ if (writtenPaths.has(CODEX_CONFIG_PATH))
1520
+ nextHashes[CODEX_CONFIG_PATH] = computeHash(getCodexConfigTemplate().content);
1521
+ else if (previousHashes[CODEX_CONFIG_PATH])
1522
+ nextHashes[CODEX_CONFIG_PATH] = previousHashes[CODEX_CONFIG_PATH];
1523
+ saveHashes(cwd, nextHashes);
1531
1524
  if (useRemoteTemplate) {
1532
1525
  const specFilesToHash = new Map();
1533
1526
  for (const relativePath of collectSpecPaths(cwd)) {
@@ -1551,11 +1544,7 @@ export async function init(options) {
1551
1544
  // Initialize developer identity (silent - no output)
1552
1545
  if (developerName) {
1553
1546
  try {
1554
- const scriptPath = path.join(cwd, PATHS.SCRIPTS, "init_developer.py");
1555
- execSync(`${pythonCmd} "${scriptPath}" "${developerName}"`, {
1556
- cwd,
1557
- stdio: "pipe", // Silent
1558
- });
1547
+ initializeDeveloper(cwd, pythonCmd, developerName);
1559
1548
  }
1560
1549
  catch {
1561
1550
  // Silent failure - user can run init_developer.py manually
@@ -1590,6 +1579,7 @@ export async function init(options) {
1590
1579
  }
1591
1580
  }
1592
1581
  }
1582
+ await completeProjectInit(projectRoot, projectPlan);
1593
1583
  });
1594
1584
  }
1595
1585
  /**
@@ -1607,12 +1597,40 @@ function askInput(prompt) {
1607
1597
  });
1608
1598
  });
1609
1599
  }
1610
- async function createRootFiles(cwd) {
1600
+ async function createRootFiles(cwd, options) {
1611
1601
  const agentsPath = path.join(cwd, FILE_NAMES.AGENTS);
1612
- // Write AGENTS.md from template
1613
- const agentsWritten = await writeFile(agentsPath, agentsMdContent);
1614
- if (agentsWritten) {
1615
- console.log(chalk.blue("📄 Created AGENTS.md"));
1602
+ const previous = readManagedMarkdown(agentsPath);
1603
+ if (previous !== null) {
1604
+ const block = managedBlock(previous, TRELLIS_BLOCK_START, TRELLIS_BLOCK_END);
1605
+ if (options.skipExisting && !options.force) {
1606
+ console.log(chalk.gray(` ○ Skipped: AGENTS.md${block ? "" : " (Trellis guidance not installed)"}`));
1607
+ return;
1608
+ }
1609
+ if (block && !options.force) {
1610
+ if (options.yes || !process.stdin.isTTY)
1611
+ return;
1612
+ const answer = await inquirer.prompt([
1613
+ {
1614
+ type: "list",
1615
+ name: "action",
1616
+ message: "AGENTS.md already has Trellis guidance.",
1617
+ choices: [
1618
+ { name: "Keep existing Trellis block", value: "skip" },
1619
+ { name: "Update only Trellis block", value: "overwrite" },
1620
+ ],
1621
+ },
1622
+ ]);
1623
+ if (answer.action !== "overwrite")
1624
+ return;
1625
+ }
1616
1626
  }
1627
+ const next = mergeManagedMarkdown(previous ?? "", agentsMdContent, TRELLIS_BLOCK_START, TRELLIS_BLOCK_END);
1628
+ if (next === previous)
1629
+ return;
1630
+ if (readManagedMarkdown(agentsPath) !== previous)
1631
+ throw new Error("AGENTS.md changed before write");
1632
+ writeFileAtomic(agentsPath, next, previous === null ? undefined : fs.statSync(agentsPath).mode);
1633
+ recordWrite(agentsPath);
1634
+ console.log(chalk.blue("📄 Installed Trellis guidance in AGENTS.md"));
1617
1635
  }
1618
1636
  //# sourceMappingURL=init.js.map