trellis-herbivore 0.1.0

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 (629) hide show
  1. package/bin/trellis.js +3 -0
  2. package/dist/cli/index.d.ts +3 -0
  3. package/dist/cli/index.d.ts.map +1 -0
  4. package/dist/cli/index.js +174 -0
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/commands/channel/adapters/claude.d.ts +38 -0
  7. package/dist/commands/channel/adapters/claude.d.ts.map +1 -0
  8. package/dist/commands/channel/adapters/claude.js +209 -0
  9. package/dist/commands/channel/adapters/claude.js.map +1 -0
  10. package/dist/commands/channel/adapters/codex.d.ts +77 -0
  11. package/dist/commands/channel/adapters/codex.d.ts.map +1 -0
  12. package/dist/commands/channel/adapters/codex.js +495 -0
  13. package/dist/commands/channel/adapters/codex.js.map +1 -0
  14. package/dist/commands/channel/adapters/index.d.ts +79 -0
  15. package/dist/commands/channel/adapters/index.d.ts.map +1 -0
  16. package/dist/commands/channel/adapters/index.js +109 -0
  17. package/dist/commands/channel/adapters/index.js.map +1 -0
  18. package/dist/commands/channel/adapters/types.d.ts +33 -0
  19. package/dist/commands/channel/adapters/types.d.ts.map +1 -0
  20. package/dist/commands/channel/adapters/types.js +2 -0
  21. package/dist/commands/channel/adapters/types.js.map +1 -0
  22. package/dist/commands/channel/agent-loader.d.ts +32 -0
  23. package/dist/commands/channel/agent-loader.d.ts.map +1 -0
  24. package/dist/commands/channel/agent-loader.js +154 -0
  25. package/dist/commands/channel/agent-loader.js.map +1 -0
  26. package/dist/commands/channel/context-loader.d.ts +26 -0
  27. package/dist/commands/channel/context-loader.d.ts.map +1 -0
  28. package/dist/commands/channel/context-loader.js +290 -0
  29. package/dist/commands/channel/context-loader.js.map +1 -0
  30. package/dist/commands/channel/context.d.ts +16 -0
  31. package/dist/commands/channel/context.d.ts.map +1 -0
  32. package/dist/commands/channel/context.js +83 -0
  33. package/dist/commands/channel/context.js.map +1 -0
  34. package/dist/commands/channel/create.d.ts +27 -0
  35. package/dist/commands/channel/create.d.ts.map +1 -0
  36. package/dist/commands/channel/create.js +39 -0
  37. package/dist/commands/channel/create.js.map +1 -0
  38. package/dist/commands/channel/dev-parse-trace.d.ts +14 -0
  39. package/dist/commands/channel/dev-parse-trace.d.ts.map +1 -0
  40. package/dist/commands/channel/dev-parse-trace.js +70 -0
  41. package/dist/commands/channel/dev-parse-trace.js.map +1 -0
  42. package/dist/commands/channel/index.d.ts +3 -0
  43. package/dist/commands/channel/index.d.ts.map +1 -0
  44. package/dist/commands/channel/index.js +496 -0
  45. package/dist/commands/channel/index.js.map +1 -0
  46. package/dist/commands/channel/kill.d.ts +7 -0
  47. package/dist/commands/channel/kill.d.ts.map +1 -0
  48. package/dist/commands/channel/kill.js +121 -0
  49. package/dist/commands/channel/kill.js.map +1 -0
  50. package/dist/commands/channel/list.d.ts +17 -0
  51. package/dist/commands/channel/list.d.ts.map +1 -0
  52. package/dist/commands/channel/list.js +233 -0
  53. package/dist/commands/channel/list.js.map +1 -0
  54. package/dist/commands/channel/messages.d.ts +16 -0
  55. package/dist/commands/channel/messages.d.ts.map +1 -0
  56. package/dist/commands/channel/messages.js +237 -0
  57. package/dist/commands/channel/messages.js.map +1 -0
  58. package/dist/commands/channel/rm.d.ts +27 -0
  59. package/dist/commands/channel/rm.d.ts.map +1 -0
  60. package/dist/commands/channel/rm.js +216 -0
  61. package/dist/commands/channel/rm.js.map +1 -0
  62. package/dist/commands/channel/run.d.ts +31 -0
  63. package/dist/commands/channel/run.d.ts.map +1 -0
  64. package/dist/commands/channel/run.js +137 -0
  65. package/dist/commands/channel/run.js.map +1 -0
  66. package/dist/commands/channel/send.d.ts +12 -0
  67. package/dist/commands/channel/send.d.ts.map +1 -0
  68. package/dist/commands/channel/send.js +24 -0
  69. package/dist/commands/channel/send.js.map +1 -0
  70. package/dist/commands/channel/spawn.d.ts +25 -0
  71. package/dist/commands/channel/spawn.d.ts.map +1 -0
  72. package/dist/commands/channel/spawn.js +192 -0
  73. package/dist/commands/channel/spawn.js.map +1 -0
  74. package/dist/commands/channel/store/events.d.ts +39 -0
  75. package/dist/commands/channel/store/events.d.ts.map +1 -0
  76. package/dist/commands/channel/store/events.js +87 -0
  77. package/dist/commands/channel/store/events.js.map +1 -0
  78. package/dist/commands/channel/store/filter.d.ts +3 -0
  79. package/dist/commands/channel/store/filter.d.ts.map +1 -0
  80. package/dist/commands/channel/store/filter.js +2 -0
  81. package/dist/commands/channel/store/filter.js.map +1 -0
  82. package/dist/commands/channel/store/lock.d.ts +23 -0
  83. package/dist/commands/channel/store/lock.d.ts.map +1 -0
  84. package/dist/commands/channel/store/lock.js +99 -0
  85. package/dist/commands/channel/store/lock.js.map +1 -0
  86. package/dist/commands/channel/store/paths.d.ts +63 -0
  87. package/dist/commands/channel/store/paths.d.ts.map +1 -0
  88. package/dist/commands/channel/store/paths.js +246 -0
  89. package/dist/commands/channel/store/paths.js.map +1 -0
  90. package/dist/commands/channel/store/schema.d.ts +27 -0
  91. package/dist/commands/channel/store/schema.d.ts.map +1 -0
  92. package/dist/commands/channel/store/schema.js +34 -0
  93. package/dist/commands/channel/store/schema.js.map +1 -0
  94. package/dist/commands/channel/store/thread-state.d.ts +5 -0
  95. package/dist/commands/channel/store/thread-state.d.ts.map +1 -0
  96. package/dist/commands/channel/store/thread-state.js +16 -0
  97. package/dist/commands/channel/store/thread-state.js.map +1 -0
  98. package/dist/commands/channel/store/watch.d.ts +19 -0
  99. package/dist/commands/channel/store/watch.d.ts.map +1 -0
  100. package/dist/commands/channel/store/watch.js +130 -0
  101. package/dist/commands/channel/store/watch.js.map +1 -0
  102. package/dist/commands/channel/supervisor/inbox.d.ts +25 -0
  103. package/dist/commands/channel/supervisor/inbox.d.ts.map +1 -0
  104. package/dist/commands/channel/supervisor/inbox.js +99 -0
  105. package/dist/commands/channel/supervisor/inbox.js.map +1 -0
  106. package/dist/commands/channel/supervisor/shutdown.d.ts +66 -0
  107. package/dist/commands/channel/supervisor/shutdown.d.ts.map +1 -0
  108. package/dist/commands/channel/supervisor/shutdown.js +143 -0
  109. package/dist/commands/channel/supervisor/shutdown.js.map +1 -0
  110. package/dist/commands/channel/supervisor/stdout.d.ts +49 -0
  111. package/dist/commands/channel/supervisor/stdout.d.ts.map +1 -0
  112. package/dist/commands/channel/supervisor/stdout.js +107 -0
  113. package/dist/commands/channel/supervisor/stdout.js.map +1 -0
  114. package/dist/commands/channel/supervisor.d.ts +47 -0
  115. package/dist/commands/channel/supervisor.d.ts.map +1 -0
  116. package/dist/commands/channel/supervisor.js +283 -0
  117. package/dist/commands/channel/supervisor.js.map +1 -0
  118. package/dist/commands/channel/text-body.d.ts +13 -0
  119. package/dist/commands/channel/text-body.d.ts.map +1 -0
  120. package/dist/commands/channel/text-body.js +47 -0
  121. package/dist/commands/channel/text-body.js.map +1 -0
  122. package/dist/commands/channel/threads.d.ts +39 -0
  123. package/dist/commands/channel/threads.d.ts.map +1 -0
  124. package/dist/commands/channel/threads.js +106 -0
  125. package/dist/commands/channel/threads.js.map +1 -0
  126. package/dist/commands/channel/title.d.ts +12 -0
  127. package/dist/commands/channel/title.d.ts.map +1 -0
  128. package/dist/commands/channel/title.js +24 -0
  129. package/dist/commands/channel/title.js.map +1 -0
  130. package/dist/commands/channel/wait.d.ts +18 -0
  131. package/dist/commands/channel/wait.d.ts.map +1 -0
  132. package/dist/commands/channel/wait.js +76 -0
  133. package/dist/commands/channel/wait.js.map +1 -0
  134. package/dist/commands/init.d.ts +57 -0
  135. package/dist/commands/init.d.ts.map +1 -0
  136. package/dist/commands/init.js +1466 -0
  137. package/dist/commands/init.js.map +1 -0
  138. package/dist/commands/mem.d.ts +234 -0
  139. package/dist/commands/mem.d.ts.map +1 -0
  140. package/dist/commands/mem.js +1869 -0
  141. package/dist/commands/mem.js.map +1 -0
  142. package/dist/commands/uninstall.d.ts +27 -0
  143. package/dist/commands/uninstall.d.ts.map +1 -0
  144. package/dist/commands/uninstall.js +339 -0
  145. package/dist/commands/uninstall.js.map +1 -0
  146. package/dist/commands/update.d.ts +72 -0
  147. package/dist/commands/update.d.ts.map +1 -0
  148. package/dist/commands/update.js +1926 -0
  149. package/dist/commands/update.js.map +1 -0
  150. package/dist/commands/upgrade.d.ts +28 -0
  151. package/dist/commands/upgrade.d.ts.map +1 -0
  152. package/dist/commands/upgrade.js +84 -0
  153. package/dist/commands/upgrade.js.map +1 -0
  154. package/dist/configurators/antigravity.d.ts +7 -0
  155. package/dist/configurators/antigravity.d.ts.map +1 -0
  156. package/dist/configurators/antigravity.js +19 -0
  157. package/dist/configurators/antigravity.js.map +1 -0
  158. package/dist/configurators/claude.d.ts +9 -0
  159. package/dist/configurators/claude.d.ts.map +1 -0
  160. package/dist/configurators/claude.js +72 -0
  161. package/dist/configurators/claude.js.map +1 -0
  162. package/dist/configurators/codebuddy.d.ts +10 -0
  163. package/dist/configurators/codebuddy.d.ts.map +1 -0
  164. package/dist/configurators/codebuddy.js +30 -0
  165. package/dist/configurators/codebuddy.js.map +1 -0
  166. package/dist/configurators/codex.d.ts +8 -0
  167. package/dist/configurators/codex.d.ts.map +1 -0
  168. package/dist/configurators/codex.js +87 -0
  169. package/dist/configurators/codex.js.map +1 -0
  170. package/dist/configurators/copilot.d.ts +10 -0
  171. package/dist/configurators/copilot.d.ts.map +1 -0
  172. package/dist/configurators/copilot.js +51 -0
  173. package/dist/configurators/copilot.js.map +1 -0
  174. package/dist/configurators/cursor.d.ts +10 -0
  175. package/dist/configurators/cursor.d.ts.map +1 -0
  176. package/dist/configurators/cursor.js +29 -0
  177. package/dist/configurators/cursor.js.map +1 -0
  178. package/dist/configurators/droid.d.ts +10 -0
  179. package/dist/configurators/droid.d.ts.map +1 -0
  180. package/dist/configurators/droid.js +30 -0
  181. package/dist/configurators/droid.js.map +1 -0
  182. package/dist/configurators/gemini.d.ts +16 -0
  183. package/dist/configurators/gemini.d.ts.map +1 -0
  184. package/dist/configurators/gemini.js +38 -0
  185. package/dist/configurators/gemini.js.map +1 -0
  186. package/dist/configurators/index.d.ts +65 -0
  187. package/dist/configurators/index.d.ts.map +1 -0
  188. package/dist/configurators/index.js +367 -0
  189. package/dist/configurators/index.js.map +1 -0
  190. package/dist/configurators/kilo.d.ts +7 -0
  191. package/dist/configurators/kilo.d.ts.map +1 -0
  192. package/dist/configurators/kilo.js +19 -0
  193. package/dist/configurators/kilo.js.map +1 -0
  194. package/dist/configurators/kiro.d.ts +8 -0
  195. package/dist/configurators/kiro.d.ts.map +1 -0
  196. package/dist/configurators/kiro.js +24 -0
  197. package/dist/configurators/kiro.js.map +1 -0
  198. package/dist/configurators/opencode.d.ts +14 -0
  199. package/dist/configurators/opencode.d.ts.map +1 -0
  200. package/dist/configurators/opencode.js +96 -0
  201. package/dist/configurators/opencode.js.map +1 -0
  202. package/dist/configurators/pi.d.ts +3 -0
  203. package/dist/configurators/pi.d.ts.map +1 -0
  204. package/dist/configurators/pi.js +45 -0
  205. package/dist/configurators/pi.js.map +1 -0
  206. package/dist/configurators/qoder.d.ts +11 -0
  207. package/dist/configurators/qoder.d.ts.map +1 -0
  208. package/dist/configurators/qoder.js +31 -0
  209. package/dist/configurators/qoder.js.map +1 -0
  210. package/dist/configurators/shared.d.ts +178 -0
  211. package/dist/configurators/shared.d.ts.map +1 -0
  212. package/dist/configurators/shared.js +538 -0
  213. package/dist/configurators/shared.js.map +1 -0
  214. package/dist/configurators/windsurf.d.ts +7 -0
  215. package/dist/configurators/windsurf.d.ts.map +1 -0
  216. package/dist/configurators/windsurf.js +19 -0
  217. package/dist/configurators/windsurf.js.map +1 -0
  218. package/dist/configurators/workflow.d.ts +29 -0
  219. package/dist/configurators/workflow.d.ts.map +1 -0
  220. package/dist/configurators/workflow.js +163 -0
  221. package/dist/configurators/workflow.js.map +1 -0
  222. package/dist/constants/paths.d.ts +70 -0
  223. package/dist/constants/paths.d.ts.map +1 -0
  224. package/dist/constants/paths.js +79 -0
  225. package/dist/constants/paths.js.map +1 -0
  226. package/dist/constants/version.d.ts +9 -0
  227. package/dist/constants/version.d.ts.map +1 -0
  228. package/dist/constants/version.js +15 -0
  229. package/dist/constants/version.js.map +1 -0
  230. package/dist/index.d.ts +9 -0
  231. package/dist/index.d.ts.map +1 -0
  232. package/dist/index.js +9 -0
  233. package/dist/index.js.map +1 -0
  234. package/dist/migrations/index.d.ts +62 -0
  235. package/dist/migrations/index.d.ts.map +1 -0
  236. package/dist/migrations/index.js +187 -0
  237. package/dist/migrations/index.js.map +1 -0
  238. package/dist/migrations/manifests/0.1.9.json +30 -0
  239. package/dist/migrations/manifests/0.2.0.json +49 -0
  240. package/dist/migrations/manifests/0.2.12.json +9 -0
  241. package/dist/migrations/manifests/0.2.13.json +9 -0
  242. package/dist/migrations/manifests/0.2.14.json +175 -0
  243. package/dist/migrations/manifests/0.2.15.json +33 -0
  244. package/dist/migrations/manifests/0.3.0-beta.0.json +297 -0
  245. package/dist/migrations/manifests/0.3.0-beta.1.json +9 -0
  246. package/dist/migrations/manifests/0.3.0-beta.10.json +9 -0
  247. package/dist/migrations/manifests/0.3.0-beta.11.json +9 -0
  248. package/dist/migrations/manifests/0.3.0-beta.12.json +9 -0
  249. package/dist/migrations/manifests/0.3.0-beta.13.json +9 -0
  250. package/dist/migrations/manifests/0.3.0-beta.14.json +9 -0
  251. package/dist/migrations/manifests/0.3.0-beta.15.json +9 -0
  252. package/dist/migrations/manifests/0.3.0-beta.16.json +9 -0
  253. package/dist/migrations/manifests/0.3.0-beta.2.json +9 -0
  254. package/dist/migrations/manifests/0.3.0-beta.3.json +9 -0
  255. package/dist/migrations/manifests/0.3.0-beta.4.json +9 -0
  256. package/dist/migrations/manifests/0.3.0-beta.5.json +9 -0
  257. package/dist/migrations/manifests/0.3.0-beta.6.json +9 -0
  258. package/dist/migrations/manifests/0.3.0-beta.7.json +11 -0
  259. package/dist/migrations/manifests/0.3.0-beta.8.json +9 -0
  260. package/dist/migrations/manifests/0.3.0-beta.9.json +9 -0
  261. package/dist/migrations/manifests/0.3.0-rc.0.json +9 -0
  262. package/dist/migrations/manifests/0.3.0-rc.1.json +9 -0
  263. package/dist/migrations/manifests/0.3.0-rc.2.json +9 -0
  264. package/dist/migrations/manifests/0.3.0-rc.3.json +9 -0
  265. package/dist/migrations/manifests/0.3.0-rc.4.json +9 -0
  266. package/dist/migrations/manifests/0.3.0-rc.5.json +9 -0
  267. package/dist/migrations/manifests/0.3.0-rc.6.json +9 -0
  268. package/dist/migrations/manifests/0.3.0.json +11 -0
  269. package/dist/migrations/manifests/0.3.1.json +9 -0
  270. package/dist/migrations/manifests/0.3.10.json +9 -0
  271. package/dist/migrations/manifests/0.3.2.json +9 -0
  272. package/dist/migrations/manifests/0.3.3.json +9 -0
  273. package/dist/migrations/manifests/0.3.4.json +21 -0
  274. package/dist/migrations/manifests/0.3.5.json +9 -0
  275. package/dist/migrations/manifests/0.3.6.json +9 -0
  276. package/dist/migrations/manifests/0.3.7.json +9 -0
  277. package/dist/migrations/manifests/0.3.8.json +9 -0
  278. package/dist/migrations/manifests/0.3.9.json +9 -0
  279. package/dist/migrations/manifests/0.4.0-beta.1.json +228 -0
  280. package/dist/migrations/manifests/0.4.0-beta.10.json +9 -0
  281. package/dist/migrations/manifests/0.4.0-beta.2.json +9 -0
  282. package/dist/migrations/manifests/0.4.0-beta.3.json +9 -0
  283. package/dist/migrations/manifests/0.4.0-beta.4.json +9 -0
  284. package/dist/migrations/manifests/0.4.0-beta.5.json +9 -0
  285. package/dist/migrations/manifests/0.4.0-beta.6.json +9 -0
  286. package/dist/migrations/manifests/0.4.0-beta.7.json +9 -0
  287. package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
  288. package/dist/migrations/manifests/0.4.0-beta.9.json +9 -0
  289. package/dist/migrations/manifests/0.4.0-rc.0.json +9 -0
  290. package/dist/migrations/manifests/0.4.0-rc.1.json +9 -0
  291. package/dist/migrations/manifests/0.4.0.json +9 -0
  292. package/dist/migrations/manifests/0.5.0-beta.0.json +1646 -0
  293. package/dist/migrations/manifests/0.5.0-beta.1.json +9 -0
  294. package/dist/migrations/manifests/0.5.0-beta.10.json +9 -0
  295. package/dist/migrations/manifests/0.5.0-beta.11.json +9 -0
  296. package/dist/migrations/manifests/0.5.0-beta.12.json +9 -0
  297. package/dist/migrations/manifests/0.5.0-beta.13.json +9 -0
  298. package/dist/migrations/manifests/0.5.0-beta.14.json +9 -0
  299. package/dist/migrations/manifests/0.5.0-beta.15.json +116 -0
  300. package/dist/migrations/manifests/0.5.0-beta.16.json +9 -0
  301. package/dist/migrations/manifests/0.5.0-beta.17.json +9 -0
  302. package/dist/migrations/manifests/0.5.0-beta.18.json +9 -0
  303. package/dist/migrations/manifests/0.5.0-beta.19.json +9 -0
  304. package/dist/migrations/manifests/0.5.0-beta.2.json +9 -0
  305. package/dist/migrations/manifests/0.5.0-beta.3.json +9 -0
  306. package/dist/migrations/manifests/0.5.0-beta.4.json +9 -0
  307. package/dist/migrations/manifests/0.5.0-beta.5.json +222 -0
  308. package/dist/migrations/manifests/0.5.0-beta.6.json +9 -0
  309. package/dist/migrations/manifests/0.5.0-beta.7.json +9 -0
  310. package/dist/migrations/manifests/0.5.0-beta.8.json +9 -0
  311. package/dist/migrations/manifests/0.5.0-beta.9.json +48 -0
  312. package/dist/migrations/manifests/0.5.0-rc.0.json +9 -0
  313. package/dist/migrations/manifests/0.5.0-rc.1.json +9 -0
  314. package/dist/migrations/manifests/0.5.0-rc.2.json +9 -0
  315. package/dist/migrations/manifests/0.5.0-rc.3.json +9 -0
  316. package/dist/migrations/manifests/0.5.0-rc.4.json +9 -0
  317. package/dist/migrations/manifests/0.5.0-rc.5.json +9 -0
  318. package/dist/migrations/manifests/0.5.0-rc.6.json +9 -0
  319. package/dist/migrations/manifests/0.5.0-rc.7.json +9 -0
  320. package/dist/migrations/manifests/0.5.0.json +9 -0
  321. package/dist/migrations/manifests/0.5.1.json +9 -0
  322. package/dist/migrations/manifests/0.5.10.json +9 -0
  323. package/dist/migrations/manifests/0.5.11.json +16 -0
  324. package/dist/migrations/manifests/0.5.12.json +9 -0
  325. package/dist/migrations/manifests/0.5.13.json +9 -0
  326. package/dist/migrations/manifests/0.5.14.json +9 -0
  327. package/dist/migrations/manifests/0.5.15.json +9 -0
  328. package/dist/migrations/manifests/0.5.2.json +9 -0
  329. package/dist/migrations/manifests/0.5.3.json +9 -0
  330. package/dist/migrations/manifests/0.5.4.json +9 -0
  331. package/dist/migrations/manifests/0.5.5.json +9 -0
  332. package/dist/migrations/manifests/0.5.6.json +9 -0
  333. package/dist/migrations/manifests/0.5.7.json +16 -0
  334. package/dist/migrations/manifests/0.5.8.json +9 -0
  335. package/dist/migrations/manifests/0.5.9.json +9 -0
  336. package/dist/migrations/manifests/0.6.0-beta.0.json +16 -0
  337. package/dist/migrations/manifests/0.6.0-beta.1.json +9 -0
  338. package/dist/migrations/manifests/0.6.0-beta.10.json +9 -0
  339. package/dist/migrations/manifests/0.6.0-beta.11.json +9 -0
  340. package/dist/migrations/manifests/0.6.0-beta.12.json +9 -0
  341. package/dist/migrations/manifests/0.6.0-beta.13.json +9 -0
  342. package/dist/migrations/manifests/0.6.0-beta.14.json +9 -0
  343. package/dist/migrations/manifests/0.6.0-beta.2.json +9 -0
  344. package/dist/migrations/manifests/0.6.0-beta.3.json +9 -0
  345. package/dist/migrations/manifests/0.6.0-beta.4.json +9 -0
  346. package/dist/migrations/manifests/0.6.0-beta.5.json +9 -0
  347. package/dist/migrations/manifests/0.6.0-beta.6.json +16 -0
  348. package/dist/migrations/manifests/0.6.0-beta.7.json +9 -0
  349. package/dist/migrations/manifests/0.6.0-beta.8.json +9 -0
  350. package/dist/migrations/manifests/0.6.0-beta.9.json +9 -0
  351. package/dist/templates/claude/agents/trellis-check.md +114 -0
  352. package/dist/templates/claude/agents/trellis-implement.md +113 -0
  353. package/dist/templates/claude/agents/trellis-research.md +137 -0
  354. package/dist/templates/claude/index.d.ts +22 -0
  355. package/dist/templates/claude/index.d.ts.map +1 -0
  356. package/dist/templates/claude/index.js +46 -0
  357. package/dist/templates/claude/index.js.map +1 -0
  358. package/dist/templates/claude/settings.json +73 -0
  359. package/dist/templates/codebuddy/agents/trellis-check.md +109 -0
  360. package/dist/templates/codebuddy/agents/trellis-implement.md +110 -0
  361. package/dist/templates/codebuddy/agents/trellis-research.md +137 -0
  362. package/dist/templates/codebuddy/index.d.ts +15 -0
  363. package/dist/templates/codebuddy/index.d.ts.map +1 -0
  364. package/dist/templates/codebuddy/index.js +15 -0
  365. package/dist/templates/codebuddy/index.js.map +1 -0
  366. package/dist/templates/codebuddy/settings.json +59 -0
  367. package/dist/templates/codex/agents/trellis-check.toml +84 -0
  368. package/dist/templates/codex/agents/trellis-implement.toml +65 -0
  369. package/dist/templates/codex/agents/trellis-research.toml +73 -0
  370. package/dist/templates/codex/config.toml +35 -0
  371. package/dist/templates/codex/hooks/session-start.py +545 -0
  372. package/dist/templates/codex/hooks.json +15 -0
  373. package/dist/templates/codex/index.d.ts +39 -0
  374. package/dist/templates/codex/index.d.ts.map +1 -0
  375. package/dist/templates/codex/index.js +85 -0
  376. package/dist/templates/codex/index.js.map +1 -0
  377. package/dist/templates/codex/skills/before-dev/SKILL.md +40 -0
  378. package/dist/templates/codex/skills/brainstorm/SKILL.md +112 -0
  379. package/dist/templates/codex/skills/break-loop/SKILL.md +130 -0
  380. package/dist/templates/codex/skills/check/SKILL.md +98 -0
  381. package/dist/templates/codex/skills/check-cross-layer/SKILL.md +158 -0
  382. package/dist/templates/codex/skills/create-command/SKILL.md +101 -0
  383. package/dist/templates/codex/skills/finish-work/SKILL.md +90 -0
  384. package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
  385. package/dist/templates/codex/skills/integrate-skill/SKILL.md +221 -0
  386. package/dist/templates/codex/skills/onboard/SKILL.md +363 -0
  387. package/dist/templates/codex/skills/record-session/SKILL.md +67 -0
  388. package/dist/templates/codex/skills/start/SKILL.md +64 -0
  389. package/dist/templates/codex/skills/update-spec/SKILL.md +335 -0
  390. package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +73 -0
  391. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/add-project-local-conventions.md +83 -0
  392. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +54 -0
  393. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +84 -0
  394. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +57 -0
  395. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-skills-or-commands.md +78 -0
  396. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +83 -0
  397. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-task-lifecycle.md +90 -0
  398. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +65 -0
  399. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/overview.md +55 -0
  400. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +68 -0
  401. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +80 -0
  402. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +51 -0
  403. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +102 -0
  404. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +103 -0
  405. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workflow.md +75 -0
  406. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workspace-memory.md +71 -0
  407. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +80 -0
  408. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +69 -0
  409. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +59 -0
  410. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +74 -0
  411. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +83 -0
  412. package/dist/templates/common/commands/continue.md +56 -0
  413. package/dist/templates/common/commands/finish-work.md +66 -0
  414. package/dist/templates/common/commands/start.md +59 -0
  415. package/dist/templates/common/index.d.ts +48 -0
  416. package/dist/templates/common/index.d.ts.map +1 -0
  417. package/dist/templates/common/index.js +104 -0
  418. package/dist/templates/common/index.js.map +1 -0
  419. package/dist/templates/common/skills/before-dev.md +35 -0
  420. package/dist/templates/common/skills/brainstorm.md +112 -0
  421. package/dist/templates/common/skills/break-loop.md +125 -0
  422. package/dist/templates/common/skills/check.md +93 -0
  423. package/dist/templates/common/skills/update-spec.md +351 -0
  424. package/dist/templates/copilot/hooks/session-start.py +547 -0
  425. package/dist/templates/copilot/hooks.json +19 -0
  426. package/dist/templates/copilot/index.d.ts +23 -0
  427. package/dist/templates/copilot/index.d.ts.map +1 -0
  428. package/dist/templates/copilot/index.js +54 -0
  429. package/dist/templates/copilot/index.js.map +1 -0
  430. package/dist/templates/copilot/prompts/before-dev.prompt.md +39 -0
  431. package/dist/templates/copilot/prompts/brainstorm.prompt.md +111 -0
  432. package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
  433. package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +157 -0
  434. package/dist/templates/copilot/prompts/check.prompt.md +97 -0
  435. package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
  436. package/dist/templates/copilot/prompts/finish-work.prompt.md +99 -0
  437. package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
  438. package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
  439. package/dist/templates/copilot/prompts/parallel.prompt.md +204 -0
  440. package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
  441. package/dist/templates/copilot/prompts/start.prompt.md +63 -0
  442. package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
  443. package/dist/templates/cursor/agents/trellis-check.md +108 -0
  444. package/dist/templates/cursor/agents/trellis-implement.md +109 -0
  445. package/dist/templates/cursor/agents/trellis-research.md +136 -0
  446. package/dist/templates/cursor/hooks.json +30 -0
  447. package/dist/templates/cursor/index.d.ts +13 -0
  448. package/dist/templates/cursor/index.d.ts.map +1 -0
  449. package/dist/templates/cursor/index.js +13 -0
  450. package/dist/templates/cursor/index.js.map +1 -0
  451. package/dist/templates/droid/droids/trellis-check.md +101 -0
  452. package/dist/templates/droid/droids/trellis-implement.md +102 -0
  453. package/dist/templates/droid/droids/trellis-research.md +137 -0
  454. package/dist/templates/droid/index.d.ts +15 -0
  455. package/dist/templates/droid/index.d.ts.map +1 -0
  456. package/dist/templates/droid/index.js +15 -0
  457. package/dist/templates/droid/index.js.map +1 -0
  458. package/dist/templates/droid/settings.json +59 -0
  459. package/dist/templates/extract.d.ts +40 -0
  460. package/dist/templates/extract.d.ts.map +1 -0
  461. package/dist/templates/extract.js +106 -0
  462. package/dist/templates/extract.js.map +1 -0
  463. package/dist/templates/gemini/agents/trellis-check.md +101 -0
  464. package/dist/templates/gemini/agents/trellis-implement.md +102 -0
  465. package/dist/templates/gemini/agents/trellis-research.md +136 -0
  466. package/dist/templates/gemini/index.d.ts +13 -0
  467. package/dist/templates/gemini/index.d.ts.map +1 -0
  468. package/dist/templates/gemini/index.js +13 -0
  469. package/dist/templates/gemini/index.js.map +1 -0
  470. package/dist/templates/gemini/settings.json +28 -0
  471. package/dist/templates/kiro/agents/trellis-check.json +26 -0
  472. package/dist/templates/kiro/agents/trellis-implement.json +26 -0
  473. package/dist/templates/kiro/agents/trellis-research.json +30 -0
  474. package/dist/templates/kiro/index.d.ts +18 -0
  475. package/dist/templates/kiro/index.d.ts.map +1 -0
  476. package/dist/templates/kiro/index.js +18 -0
  477. package/dist/templates/kiro/index.js.map +1 -0
  478. package/dist/templates/markdown/agents.md +21 -0
  479. package/dist/templates/markdown/gitignore.txt +15 -0
  480. package/dist/templates/markdown/index.d.ts +27 -0
  481. package/dist/templates/markdown/index.d.ts.map +1 -0
  482. package/dist/templates/markdown/index.js +52 -0
  483. package/dist/templates/markdown/index.js.map +1 -0
  484. package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +51 -0
  485. package/dist/templates/markdown/spec/backend/directory-structure.md.txt +54 -0
  486. package/dist/templates/markdown/spec/backend/error-handling.md.txt +51 -0
  487. package/dist/templates/markdown/spec/backend/index.md.txt +38 -0
  488. package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +51 -0
  489. package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +51 -0
  490. package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +59 -0
  491. package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +54 -0
  492. package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +51 -0
  493. package/dist/templates/markdown/spec/frontend/index.md.txt +39 -0
  494. package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +51 -0
  495. package/dist/templates/markdown/spec/frontend/state-management.md.txt +51 -0
  496. package/dist/templates/markdown/spec/frontend/type-safety.md.txt +51 -0
  497. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +223 -0
  498. package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +259 -0
  499. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +595 -0
  500. package/dist/templates/markdown/spec/guides/index.md.txt +97 -0
  501. package/dist/templates/markdown/workspace-index.md +125 -0
  502. package/dist/templates/markdown/worktree.yaml.txt +58 -0
  503. package/dist/templates/opencode/agents/trellis-check.md +116 -0
  504. package/dist/templates/opencode/agents/trellis-implement.md +118 -0
  505. package/dist/templates/opencode/agents/trellis-research.md +145 -0
  506. package/dist/templates/opencode/lib/session-utils.js +521 -0
  507. package/dist/templates/opencode/lib/trellis-context.js +381 -0
  508. package/dist/templates/opencode/package.json +5 -0
  509. package/dist/templates/opencode/plugins/inject-subagent-context.js +513 -0
  510. package/dist/templates/opencode/plugins/inject-workflow-state.js +159 -0
  511. package/dist/templates/opencode/plugins/session-start.js +101 -0
  512. package/dist/templates/pi/agents/trellis-check.md +36 -0
  513. package/dist/templates/pi/agents/trellis-implement.md +41 -0
  514. package/dist/templates/pi/agents/trellis-research.md +25 -0
  515. package/dist/templates/pi/extensions/trellis/index.ts.txt +1174 -0
  516. package/dist/templates/pi/index.d.ts +5 -0
  517. package/dist/templates/pi/index.d.ts.map +1 -0
  518. package/dist/templates/pi/index.js +12 -0
  519. package/dist/templates/pi/index.js.map +1 -0
  520. package/dist/templates/pi/settings.json +21 -0
  521. package/dist/templates/qoder/agents/trellis-check.md +102 -0
  522. package/dist/templates/qoder/agents/trellis-implement.md +103 -0
  523. package/dist/templates/qoder/agents/trellis-research.md +137 -0
  524. package/dist/templates/qoder/index.d.ts +15 -0
  525. package/dist/templates/qoder/index.d.ts.map +1 -0
  526. package/dist/templates/qoder/index.js +15 -0
  527. package/dist/templates/qoder/index.js.map +1 -0
  528. package/dist/templates/qoder/settings.json +47 -0
  529. package/dist/templates/shared-hooks/index.d.ts +50 -0
  530. package/dist/templates/shared-hooks/index.d.ts.map +1 -0
  531. package/dist/templates/shared-hooks/index.js +89 -0
  532. package/dist/templates/shared-hooks/index.js.map +1 -0
  533. package/dist/templates/shared-hooks/inject-shell-session-context.py +183 -0
  534. package/dist/templates/shared-hooks/inject-subagent-context.py +771 -0
  535. package/dist/templates/shared-hooks/inject-workflow-state.py +363 -0
  536. package/dist/templates/shared-hooks/session-start.py +827 -0
  537. package/dist/templates/template-utils.d.ts +26 -0
  538. package/dist/templates/template-utils.d.ts.map +1 -0
  539. package/dist/templates/template-utils.js +60 -0
  540. package/dist/templates/template-utils.js.map +1 -0
  541. package/dist/templates/trellis/config.yaml +90 -0
  542. package/dist/templates/trellis/gitignore.txt +32 -0
  543. package/dist/templates/trellis/index.d.ts +52 -0
  544. package/dist/templates/trellis/index.d.ts.map +1 -0
  545. package/dist/templates/trellis/index.js +97 -0
  546. package/dist/templates/trellis/index.js.map +1 -0
  547. package/dist/templates/trellis/scripts/__init__.py +5 -0
  548. package/dist/templates/trellis/scripts/add_session.py +547 -0
  549. package/dist/templates/trellis/scripts/common/__init__.py +92 -0
  550. package/dist/templates/trellis/scripts/common/active_task.py +626 -0
  551. package/dist/templates/trellis/scripts/common/cli_adapter.py +811 -0
  552. package/dist/templates/trellis/scripts/common/config.py +445 -0
  553. package/dist/templates/trellis/scripts/common/developer.py +190 -0
  554. package/dist/templates/trellis/scripts/common/git.py +31 -0
  555. package/dist/templates/trellis/scripts/common/git_context.py +106 -0
  556. package/dist/templates/trellis/scripts/common/io.py +37 -0
  557. package/dist/templates/trellis/scripts/common/log.py +45 -0
  558. package/dist/templates/trellis/scripts/common/packages_context.py +238 -0
  559. package/dist/templates/trellis/scripts/common/paths.py +447 -0
  560. package/dist/templates/trellis/scripts/common/safe_commit.py +285 -0
  561. package/dist/templates/trellis/scripts/common/session_context.py +821 -0
  562. package/dist/templates/trellis/scripts/common/task_context.py +223 -0
  563. package/dist/templates/trellis/scripts/common/task_queue.py +188 -0
  564. package/dist/templates/trellis/scripts/common/task_store.py +698 -0
  565. package/dist/templates/trellis/scripts/common/task_utils.py +274 -0
  566. package/dist/templates/trellis/scripts/common/tasks.py +112 -0
  567. package/dist/templates/trellis/scripts/common/trellis_config.py +131 -0
  568. package/dist/templates/trellis/scripts/common/types.py +110 -0
  569. package/dist/templates/trellis/scripts/common/workflow_phase.py +212 -0
  570. package/dist/templates/trellis/scripts/get_context.py +16 -0
  571. package/dist/templates/trellis/scripts/get_developer.py +26 -0
  572. package/dist/templates/trellis/scripts/hooks/linear_sync.py +243 -0
  573. package/dist/templates/trellis/scripts/init_developer.py +51 -0
  574. package/dist/templates/trellis/scripts/task.py +500 -0
  575. package/dist/templates/trellis/tasks/.gitkeep +0 -0
  576. package/dist/templates/trellis/workflow.md +690 -0
  577. package/dist/types/ai-tools.d.ts +95 -0
  578. package/dist/types/ai-tools.d.ts.map +1 -0
  579. package/dist/types/ai-tools.js +280 -0
  580. package/dist/types/ai-tools.js.map +1 -0
  581. package/dist/types/migration.d.ts +125 -0
  582. package/dist/types/migration.d.ts.map +1 -0
  583. package/dist/types/migration.js +8 -0
  584. package/dist/types/migration.js.map +1 -0
  585. package/dist/utils/compare-versions.d.ts +12 -0
  586. package/dist/utils/compare-versions.d.ts.map +1 -0
  587. package/dist/utils/compare-versions.js +86 -0
  588. package/dist/utils/compare-versions.js.map +1 -0
  589. package/dist/utils/cwd-guard.d.ts +38 -0
  590. package/dist/utils/cwd-guard.d.ts.map +1 -0
  591. package/dist/utils/cwd-guard.js +62 -0
  592. package/dist/utils/cwd-guard.js.map +1 -0
  593. package/dist/utils/file-writer.d.ts +36 -0
  594. package/dist/utils/file-writer.d.ts.map +1 -0
  595. package/dist/utils/file-writer.js +203 -0
  596. package/dist/utils/file-writer.js.map +1 -0
  597. package/dist/utils/manifest-prune.d.ts +61 -0
  598. package/dist/utils/manifest-prune.d.ts.map +1 -0
  599. package/dist/utils/manifest-prune.js +136 -0
  600. package/dist/utils/manifest-prune.js.map +1 -0
  601. package/dist/utils/posix.d.ts +13 -0
  602. package/dist/utils/posix.d.ts.map +1 -0
  603. package/dist/utils/posix.js +15 -0
  604. package/dist/utils/posix.js.map +1 -0
  605. package/dist/utils/project-detector.d.ts +46 -0
  606. package/dist/utils/project-detector.d.ts.map +1 -0
  607. package/dist/utils/project-detector.js +666 -0
  608. package/dist/utils/project-detector.js.map +1 -0
  609. package/dist/utils/proxy.d.ts +25 -0
  610. package/dist/utils/proxy.d.ts.map +1 -0
  611. package/dist/utils/proxy.js +60 -0
  612. package/dist/utils/proxy.js.map +1 -0
  613. package/dist/utils/task-json.d.ts +13 -0
  614. package/dist/utils/task-json.d.ts.map +1 -0
  615. package/dist/utils/task-json.js +12 -0
  616. package/dist/utils/task-json.js.map +1 -0
  617. package/dist/utils/template-fetcher.d.ts +150 -0
  618. package/dist/utils/template-fetcher.d.ts.map +1 -0
  619. package/dist/utils/template-fetcher.js +907 -0
  620. package/dist/utils/template-fetcher.js.map +1 -0
  621. package/dist/utils/template-hash.d.ts +123 -0
  622. package/dist/utils/template-hash.d.ts.map +1 -0
  623. package/dist/utils/template-hash.js +334 -0
  624. package/dist/utils/template-hash.js.map +1 -0
  625. package/dist/utils/uninstall-scrubbers.d.ts +66 -0
  626. package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
  627. package/dist/utils/uninstall-scrubbers.js +342 -0
  628. package/dist/utils/uninstall-scrubbers.js.map +1 -0
  629. package/package.json +90 -0
@@ -0,0 +1,246 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { GLOBAL_PROJECT_KEY, } from "./schema.js";
5
+ /** Top-level Trellis channels directory. */
6
+ export function channelRoot() {
7
+ const env = process.env.TRELLIS_CHANNEL_ROOT;
8
+ if (env && env.length > 0)
9
+ return path.resolve(env);
10
+ return path.join(os.homedir(), ".trellis", "channels");
11
+ }
12
+ /**
13
+ * Derive a per-project bucket name from an absolute cwd, mirroring
14
+ * Claude Code's `~/.claude/projects/<sanitized-cwd>/` convention so
15
+ * users who already work with that layout get a familiar mental model.
16
+ *
17
+ * The transform is irreversible (multiple cwds can collide if they
18
+ * differ only in `/` vs `_` positions) but the collision risk in
19
+ * practice is negligible — Claude Code accepts the same trade-off.
20
+ */
21
+ export function projectKey(cwd) {
22
+ const abs = path.resolve(cwd);
23
+ // Match claude's rule: replace `/`, `_`, `\` with `-`. The leading
24
+ // `-` (from the leading `/` on POSIX paths) is kept so you can spot
25
+ // project buckets at a glance — they always start with `-`.
26
+ //
27
+ // We then sanitise any remaining non-portable bytes (spaces, CJK,
28
+ // `#`, `:` etc.) to `-` as well so the bucket dir name is portable
29
+ // and shell-safe. Modern fs APIs handle exotic chars, but anything
30
+ // that needs quoting in a path is a foot-gun across shells / CI.
31
+ const slashes = abs.replace(/[\\/_]/g, "-");
32
+ return slashes.replace(/[^A-Za-z0-9.-]/g, "-");
33
+ }
34
+ /**
35
+ * Project key for the current CLI invocation. Reads
36
+ * `TRELLIS_CHANNEL_PROJECT` env first (set by the supervisor spawn so
37
+ * detached children land in the same bucket as the spawning CLI), then
38
+ * falls back to deriving from `process.cwd()`.
39
+ */
40
+ export function currentProjectKey() {
41
+ const env = process.env.TRELLIS_CHANNEL_PROJECT;
42
+ if (env && env.length > 0)
43
+ return env;
44
+ return projectKey(process.cwd());
45
+ }
46
+ /** Directory holding all channels for a given project. */
47
+ export function projectDir(project = currentProjectKey()) {
48
+ return path.join(channelRoot(), project);
49
+ }
50
+ /** Marker file that distinguishes a project bucket from a legacy
51
+ * flat-layout channel. New project buckets touch this on first use. */
52
+ const BUCKET_MARKER = ".bucket";
53
+ /**
54
+ * Channel directory inside its project bucket. Defaults to the current
55
+ * project (cwd-derived); pass an explicit project for cross-project
56
+ * addressing.
57
+ */
58
+ export function channelDir(name, project = currentProjectKey()) {
59
+ return path.join(projectDir(project), name);
60
+ }
61
+ export function eventsPath(name, project = currentProjectKey()) {
62
+ return path.join(channelDir(name, project), "events.jsonl");
63
+ }
64
+ export function lockPath(name, project = currentProjectKey()) {
65
+ return path.join(channelDir(name, project), `${name}.lock`);
66
+ }
67
+ export function workerFile(name, worker, suffix, project = currentProjectKey()) {
68
+ return path.join(channelDir(name, project), `${worker}.${suffix}`);
69
+ }
70
+ export function workerLockPath(name, worker, project = currentProjectKey()) {
71
+ return path.join(channelDir(name, project), `${worker}.spawnlock`);
72
+ }
73
+ /**
74
+ * One-shot migration: move legacy flat channels at `<root>/<name>/` into
75
+ * a `_legacy/` bucket so the new project-scoped layout can use the top
76
+ * level. Called lazily by `currentProject*` consumers — safe to invoke
77
+ * multiple times (idempotent).
78
+ *
79
+ * A directory at `<root>/X` is treated as a legacy channel if:
80
+ * - it doesn't have a `.bucket` marker (so it's not a project bucket)
81
+ * - AND it contains an `events.jsonl` directly inside
82
+ *
83
+ * Buckets named `_legacy` and `_default` are reserved and never moved.
84
+ */
85
+ export function migrateLegacyChannels() {
86
+ const root = channelRoot();
87
+ if (!fs.existsSync(root))
88
+ return;
89
+ const legacy = path.join(root, "_legacy");
90
+ let moved = 0;
91
+ let entries;
92
+ try {
93
+ entries = fs.readdirSync(root);
94
+ }
95
+ catch {
96
+ return;
97
+ }
98
+ for (const entry of entries) {
99
+ if (entry === "_legacy" || entry === "_default")
100
+ continue;
101
+ const dir = path.join(root, entry);
102
+ let stat;
103
+ try {
104
+ stat = fs.statSync(dir);
105
+ }
106
+ catch {
107
+ continue;
108
+ }
109
+ if (!stat.isDirectory())
110
+ continue;
111
+ // Project bucket marker → skip.
112
+ if (fs.existsSync(path.join(dir, BUCKET_MARKER)))
113
+ continue;
114
+ // Heuristic: a legacy channel has events.jsonl directly.
115
+ if (!fs.existsSync(path.join(dir, "events.jsonl")))
116
+ continue;
117
+ // It's legacy — move it to _legacy/<name>/.
118
+ fs.mkdirSync(legacy, { recursive: true });
119
+ const target = path.join(legacy, entry);
120
+ try {
121
+ fs.renameSync(dir, target);
122
+ moved++;
123
+ }
124
+ catch (err) {
125
+ process.stderr.write(`[channel migrate] failed to move ${entry} to _legacy/: ${err instanceof Error ? err.message : err}\n`);
126
+ }
127
+ }
128
+ if (moved > 0) {
129
+ fs.mkdirSync(legacy, { recursive: true });
130
+ fs.writeFileSync(path.join(legacy, BUCKET_MARKER), "");
131
+ process.stderr.write(`[channel migrate] moved ${moved} legacy channel(s) to ${legacy}\n`);
132
+ }
133
+ }
134
+ /** Mark a directory as a project bucket so the migrator skips it. */
135
+ export function ensureBucketMarker(project) {
136
+ const dir = projectDir(project);
137
+ fs.mkdirSync(dir, { recursive: true });
138
+ const marker = path.join(dir, BUCKET_MARKER);
139
+ if (!fs.existsSync(marker)) {
140
+ fs.writeFileSync(marker, "");
141
+ }
142
+ }
143
+ /** Enumerate all project buckets currently on disk (excluding legacy). */
144
+ export function listProjects() {
145
+ const root = channelRoot();
146
+ if (!fs.existsSync(root))
147
+ return [];
148
+ const out = [];
149
+ for (const entry of fs.readdirSync(root)) {
150
+ const dir = path.join(root, entry);
151
+ try {
152
+ if (!fs.statSync(dir).isDirectory())
153
+ continue;
154
+ }
155
+ catch {
156
+ continue;
157
+ }
158
+ // A directory is a project bucket if it has the marker OR is
159
+ // _legacy / _default / _global (reserved bucket names).
160
+ if (fs.existsSync(path.join(dir, BUCKET_MARKER)) ||
161
+ entry === "_legacy" ||
162
+ entry === "_default" ||
163
+ entry === GLOBAL_PROJECT_KEY) {
164
+ out.push(entry);
165
+ }
166
+ }
167
+ return out;
168
+ }
169
+ export function resolveChannelProjectForCreate(name, opts = {}) {
170
+ const scope = opts.scope ?? "project";
171
+ const project = scope === "global"
172
+ ? GLOBAL_PROJECT_KEY
173
+ : opts.cwd
174
+ ? projectKey(opts.cwd)
175
+ : currentProjectKey();
176
+ return {
177
+ name,
178
+ scope,
179
+ project,
180
+ dir: channelDir(name, project),
181
+ };
182
+ }
183
+ export function resolveExistingChannelRef(name, opts = {}) {
184
+ migrateLegacyChannels();
185
+ if (opts.scope) {
186
+ const project = opts.scope === "global"
187
+ ? GLOBAL_PROJECT_KEY
188
+ : opts.cwd
189
+ ? projectKey(opts.cwd)
190
+ : currentProjectKey();
191
+ if (!fs.existsSync(eventsPath(name, project))) {
192
+ throw new Error(`Channel '${name}' not found in ${opts.scope} scope (${project})`);
193
+ }
194
+ process.env.TRELLIS_CHANNEL_PROJECT = project;
195
+ return { name, scope: opts.scope, project, dir: channelDir(name, project) };
196
+ }
197
+ const current = currentProjectKey();
198
+ const projectMatches = listProjects()
199
+ .filter((project) => project !== GLOBAL_PROJECT_KEY)
200
+ .filter((project) => fs.existsSync(eventsPath(name, project)));
201
+ const globalExists = fs.existsSync(eventsPath(name, GLOBAL_PROJECT_KEY));
202
+ if (globalExists && projectMatches.length > 0) {
203
+ throw new Error(`Channel '${name}' exists in global and project scopes. Use --scope global or --scope project.`);
204
+ }
205
+ if (globalExists) {
206
+ process.env.TRELLIS_CHANNEL_PROJECT = GLOBAL_PROJECT_KEY;
207
+ return {
208
+ name,
209
+ scope: "global",
210
+ project: GLOBAL_PROJECT_KEY,
211
+ dir: channelDir(name, GLOBAL_PROJECT_KEY),
212
+ };
213
+ }
214
+ if (fs.existsSync(eventsPath(name, current))) {
215
+ process.env.TRELLIS_CHANNEL_PROJECT = current;
216
+ return {
217
+ name,
218
+ scope: "project",
219
+ project: current,
220
+ dir: channelDir(name, current),
221
+ };
222
+ }
223
+ if (projectMatches.length === 1) {
224
+ process.env.TRELLIS_CHANNEL_PROJECT = projectMatches[0];
225
+ return {
226
+ name,
227
+ scope: "project",
228
+ project: projectMatches[0],
229
+ dir: channelDir(name, projectMatches[0]),
230
+ };
231
+ }
232
+ if (projectMatches.length > 1) {
233
+ throw new Error(`Channel '${name}' exists in multiple project buckets: ${projectMatches.join(", ")}. Run from the owning project cwd or use --scope.`);
234
+ }
235
+ throw new Error(`Channel '${name}' not found in current project bucket (${current}) or any known scope`);
236
+ }
237
+ /**
238
+ * Select the project bucket for an existing channel in this CLI process.
239
+ * Current cwd wins. If it is not there, fall back to a unique match across
240
+ * all buckets so users can run `channel send <name>` from a different cwd
241
+ * without silently writing a second event stream.
242
+ */
243
+ export function selectExistingChannelProject(name) {
244
+ return resolveExistingChannelRef(name).project;
245
+ }
246
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../../src/commands/channel/store/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,kBAAkB,GAGnB,MAAM,aAAa,CAAC;AAErB,4CAA4C;AAC5C,MAAM,UAAU,WAAW;IACzB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAC7C,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAED;;;;;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c,CAAC,CAAC,CAAC;YAC1B,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;SACzC,CAAC;IACJ,CAAC;IAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,YAAY,IAAI,yCAAyC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,mDAAmD,CACtI,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CACb,YAAY,IAAI,0CAA0C,OAAO,sBAAsB,CACxF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAAY;IACvD,OAAO,yBAAyB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;AACjD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Channel schema re-exports.
3
+ *
4
+ * Canonical source: `trellis-herbivore-core/channel`. This module is
5
+ * kept as a thin pass-through during the supervisor/wait migration so
6
+ * CLI runtime code (supervisor, spawn, kill, wait) can continue to
7
+ * import from a stable local path while command files migrate to the
8
+ * core public API directly.
9
+ */
10
+ export { GLOBAL_PROJECT_KEY, CHANNEL_TYPES, THREAD_ACTIONS, parseChannelScope, parseChannelType, parseThreadAction, normalizeThreadKey, asStringArray, asContextEntries, buildContextEntries, } from "trellis-herbivore-core/channel";
11
+ export type { ChannelScope, ChannelType, ChannelRef, ChannelMetadata, ContextEntry, FileContextEntry, RawContextEntry, ThreadAction, EventOrigin, } from "trellis-herbivore-core/channel";
12
+ import type { ContextEntry } from "trellis-herbivore-core/channel";
13
+ /**
14
+ * CSV parser kept colocated with the schema for CLI command files that
15
+ * trim comma-separated label / target lists. Pure helper — does not
16
+ * touch the channel store.
17
+ */
18
+ export declare function parseCsv(value: string | undefined): string[] | undefined;
19
+ /**
20
+ * Legacy alias accepted by CLI flag parsers — old code calls this when
21
+ * processing `--linked-context-file` / `--linked-context-raw`. New code
22
+ * uses {@link buildContextEntries} directly.
23
+ *
24
+ * @deprecated Use buildContextEntries.
25
+ */
26
+ export declare function parseLinkedContext(files: string[] | undefined, raw: string[] | undefined): ContextEntry[] | undefined;
27
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/commands/channel/store/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AAExC,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAMxE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAC3B,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,GACxB,YAAY,EAAE,GAAG,SAAS,CAE5B"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Channel schema re-exports.
3
+ *
4
+ * Canonical source: `trellis-herbivore-core/channel`. This module is
5
+ * kept as a thin pass-through during the supervisor/wait migration so
6
+ * CLI runtime code (supervisor, spawn, kill, wait) can continue to
7
+ * import from a stable local path while command files migrate to the
8
+ * core public API directly.
9
+ */
10
+ export { GLOBAL_PROJECT_KEY, CHANNEL_TYPES, THREAD_ACTIONS, parseChannelScope, parseChannelType, parseThreadAction, normalizeThreadKey, asStringArray, asContextEntries, buildContextEntries, } from "trellis-herbivore-core/channel";
11
+ import { buildContextEntries } from "trellis-herbivore-core/channel";
12
+ /**
13
+ * CSV parser kept colocated with the schema for CLI command files that
14
+ * trim comma-separated label / target lists. Pure helper — does not
15
+ * touch the channel store.
16
+ */
17
+ export function parseCsv(value) {
18
+ const out = value
19
+ ?.split(",")
20
+ .map((s) => s.trim())
21
+ .filter(Boolean);
22
+ return out && out.length > 0 ? out : undefined;
23
+ }
24
+ /**
25
+ * Legacy alias accepted by CLI flag parsers — old code calls this when
26
+ * processing `--linked-context-file` / `--linked-context-raw`. New code
27
+ * uses {@link buildContextEntries} directly.
28
+ *
29
+ * @deprecated Use buildContextEntries.
30
+ */
31
+ export function parseLinkedContext(files, raw) {
32
+ return buildContextEntries(files, raw);
33
+ }
34
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/commands/channel/store/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AAcxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAyB;IAChD,MAAM,GAAG,GAAG,KAAK;QACf,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACjD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAA2B,EAC3B,GAAyB;IAEzB,OAAO,mBAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { reduceThreads, buildThreadAliasResolver, collectThreadTimeline, } from "trellis-herbivore-core/channel";
2
+ export type { ThreadState, ThreadAliasResolver, } from "trellis-herbivore-core/channel";
3
+ import type { ThreadState } from "trellis-herbivore-core/channel";
4
+ export declare function formatThreadBoard(states: ThreadState[]): string[];
5
+ //# sourceMappingURL=thread-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-state.d.ts","sourceRoot":"","sources":["../../../../src/commands/channel/store/thread-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AAExC,YAAY,EACV,WAAW,EACX,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CAcjE"}
@@ -0,0 +1,16 @@
1
+ export { reduceThreads, buildThreadAliasResolver, collectThreadTimeline, } from "trellis-herbivore-core/channel";
2
+ export function formatThreadBoard(states) {
3
+ if (states.length === 0)
4
+ return ["(no threads)"];
5
+ return [
6
+ "THREAD STATUS TITLE",
7
+ ...states.map((state) => {
8
+ const labels = state.labels.length > 0 ? ` labels=${state.labels.join(",")}` : "";
9
+ const assignees = state.assignees.length > 0
10
+ ? ` assignees=${state.assignees.join(",")}`
11
+ : "";
12
+ return `${state.thread} [${state.status}] ${state.title ?? ""}${labels}${assignees}`;
13
+ }),
14
+ ];
15
+ }
16
+ //# sourceMappingURL=thread-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-state.js","sourceRoot":"","sources":["../../../../src/commands/channel/store/thread-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AASxC,MAAM,UAAU,iBAAiB,CAAC,MAAqB;IACrD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACjD,OAAO;QACL,uBAAuB;QACvB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACtB,MAAM,MAAM,GACV,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,MAAM,SAAS,GACb,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;gBACxB,CAAC,CAAC,cAAc,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;gBAC3C,CAAC,CAAC,EAAE,CAAC;YACT,OAAO,GAAG,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,KAAK,IAAI,EAAE,GAAG,MAAM,GAAG,SAAS,EAAE,CAAC;QACvF,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ChannelEvent } from "./events.js";
2
+ import { type ChannelEventFilter } from "./filter.js";
3
+ export type WatchFilter = ChannelEventFilter;
4
+ /**
5
+ * Watch the channel events.jsonl for events matching the filter.
6
+ *
7
+ * Yields each matching event as it arrives. Caller may break to stop;
8
+ * the function cleans up on iterator return.
9
+ *
10
+ * Implementation: fs.watch with a 200ms safety poll for platforms where
11
+ * fs.watch is lossy (Windows, NFS, etc.).
12
+ */
13
+ export declare function watchEvents(channelName: string, filter: WatchFilter, opts?: {
14
+ signal?: AbortSignal;
15
+ fromStart?: boolean;
16
+ sinceSeq?: number;
17
+ project?: string;
18
+ }): AsyncGenerator<ChannelEvent, void, unknown>;
19
+ //# sourceMappingURL=watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../../src/commands/channel/store/watch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAqD7C;;;;;;;;GAQG;AACH,wBAAuB,WAAW,CAChC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,EACnB,IAAI,GAAE;IACJ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,CAyE7C"}
@@ -0,0 +1,130 @@
1
+ import fs from "node:fs";
2
+ import { eventsPath, channelDir } from "./paths.js";
3
+ import { matchesEventFilter } from "./filter.js";
4
+ async function readNewEvents(filePath, state) {
5
+ if (!fs.existsSync(filePath)) {
6
+ // File was deleted (e.g. `--force` recreate) — reset offset so when
7
+ // the file reappears we'll re-scan it from byte 0.
8
+ state.byteOffset = 0;
9
+ state.carry = "";
10
+ return [];
11
+ }
12
+ const stat = await fs.promises.stat(filePath);
13
+ if (stat.size < state.byteOffset) {
14
+ // File was truncated / rotated / replaced — re-scan from start so
15
+ // post-truncate events aren't lost forever.
16
+ state.byteOffset = 0;
17
+ state.carry = "";
18
+ }
19
+ if (stat.size <= state.byteOffset)
20
+ return [];
21
+ const fh = await fs.promises.open(filePath, "r");
22
+ try {
23
+ const length = stat.size - state.byteOffset;
24
+ const buf = Buffer.alloc(length);
25
+ await fh.read(buf, 0, length, state.byteOffset);
26
+ state.byteOffset = stat.size;
27
+ const text = state.carry + buf.toString("utf-8");
28
+ const lines = text.split("\n");
29
+ state.carry = lines.pop() ?? "";
30
+ const events = [];
31
+ for (const line of lines) {
32
+ const t = line.trim();
33
+ if (!t)
34
+ continue;
35
+ try {
36
+ events.push(JSON.parse(t));
37
+ }
38
+ catch {
39
+ // corrupted line — skip
40
+ continue;
41
+ }
42
+ }
43
+ return events;
44
+ }
45
+ finally {
46
+ await fh.close();
47
+ }
48
+ }
49
+ /**
50
+ * Watch the channel events.jsonl for events matching the filter.
51
+ *
52
+ * Yields each matching event as it arrives. Caller may break to stop;
53
+ * the function cleans up on iterator return.
54
+ *
55
+ * Implementation: fs.watch with a 200ms safety poll for platforms where
56
+ * fs.watch is lossy (Windows, NFS, etc.).
57
+ */
58
+ export async function* watchEvents(channelName, filter, opts = {}) {
59
+ const file = eventsPath(channelName, opts.project);
60
+ // Ensure channel dir exists so fs.watch on its parent works
61
+ if (!fs.existsSync(channelDir(channelName, opts.project))) {
62
+ await fs.promises.mkdir(channelDir(channelName, opts.project), {
63
+ recursive: true,
64
+ });
65
+ }
66
+ // Three modes:
67
+ // default (from-now): start at EOF. Used by `wait` so a previous
68
+ // turn's `done` doesn't unblock a fresh wait immediately.
69
+ // fromStart=true: start at offset 0 and yield existing events
70
+ // before tailing. Used by first-time supervisor inbox catch-up.
71
+ // sinceSeq=N: like fromStart=true but skip events with seq <= N.
72
+ // Used by supervisor inbox watcher after the first run so a
73
+ // respawn doesn't replay already-processed messages.
74
+ let initialOffset = 0;
75
+ if (!opts.fromStart && opts.sinceSeq === undefined) {
76
+ try {
77
+ if (fs.existsSync(file)) {
78
+ initialOffset = (await fs.promises.stat(file)).size;
79
+ }
80
+ }
81
+ catch {
82
+ initialOffset = 0;
83
+ }
84
+ }
85
+ const state = { byteOffset: initialOffset, carry: "" };
86
+ const sinceSeq = opts.sinceSeq;
87
+ let resolveNext = null;
88
+ const wake = () => {
89
+ if (resolveNext) {
90
+ const r = resolveNext;
91
+ resolveNext = null;
92
+ r();
93
+ }
94
+ };
95
+ let watcher = null;
96
+ try {
97
+ watcher = fs.watch(channelDir(channelName, opts.project), () => wake());
98
+ }
99
+ catch {
100
+ // ignore — fall back to polling
101
+ }
102
+ // 200ms safety polling (Windows / NFS / macOS fs.watch quirks)
103
+ const poll = setInterval(wake, 200);
104
+ const abortHandler = () => wake();
105
+ opts.signal?.addEventListener("abort", abortHandler);
106
+ try {
107
+ while (true) {
108
+ if (opts.signal?.aborted)
109
+ return;
110
+ const fresh = await readNewEvents(file, state);
111
+ for (const ev of fresh) {
112
+ if (sinceSeq !== undefined && ev.seq <= sinceSeq)
113
+ continue;
114
+ if (matchesEventFilter(ev, filter))
115
+ yield ev;
116
+ if (opts.signal?.aborted)
117
+ return;
118
+ }
119
+ await new Promise((resolve) => {
120
+ resolveNext = resolve;
121
+ });
122
+ }
123
+ }
124
+ finally {
125
+ clearInterval(poll);
126
+ watcher?.close();
127
+ opts.signal?.removeEventListener("abort", abortHandler);
128
+ }
129
+ }
130
+ //# sourceMappingURL=watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../../../src/commands/channel/store/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,aAAa,CAAC;AAS1E,KAAK,UAAU,aAAa,CAC1B,QAAgB,EAChB,KAAmB;IAEnB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,oEAAoE;QACpE,mDAAmD;QACnD,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;QACrB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC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AAE;gBAClC,WAAW,GAAG,OAAO,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;YAAS,CAAC;QACT,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,EAAE,KAAK,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Inbox watcher: tails events.jsonl for `kind:message` events addressed
3
+ * to this worker and forwards them into the worker's stdin via the
4
+ * adapter's `encodeUserMessage`. A persisted cursor file keeps respawns
5
+ * from replaying messages the previous supervisor already delivered.
6
+ *
7
+ * Step 3 of the supervisor refactor: pulled out of supervisor.ts so the
8
+ * orchestrator only needs to call `runInboxWatcher(...)`. Cursor
9
+ * read/write helpers stay private to this module.
10
+ */
11
+ import type { ChildProcessByStdio } from "node:child_process";
12
+ import type { Readable, Writable } from "node:stream";
13
+ import type { WorkerAdapter } from "../adapters/index.js";
14
+ type Child = ChildProcessByStdio<Writable, Readable, Readable>;
15
+ export interface InboxWatcherArgs {
16
+ channelName: string;
17
+ workerName: string;
18
+ adapter: WorkerAdapter;
19
+ ctx: unknown;
20
+ child: Child;
21
+ signal: AbortSignal;
22
+ }
23
+ export declare function runInboxWatcher(args: InboxWatcherArgs): Promise<void>;
24
+ export {};
25
+ //# sourceMappingURL=inbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../../../../src/commands/channel/supervisor/inbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,KAAK,KAAK,GAAG,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4D3E"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Inbox watcher: tails events.jsonl for `kind:message` events addressed
3
+ * to this worker and forwards them into the worker's stdin via the
4
+ * adapter's `encodeUserMessage`. A persisted cursor file keeps respawns
5
+ * from replaying messages the previous supervisor already delivered.
6
+ *
7
+ * Step 3 of the supervisor refactor: pulled out of supervisor.ts so the
8
+ * orchestrator only needs to call `runInboxWatcher(...)`. Cursor
9
+ * read/write helpers stay private to this module.
10
+ */
11
+ import fs from "node:fs";
12
+ import { workerFile } from "../store/paths.js";
13
+ import { watchEvents } from "../store/watch.js";
14
+ export async function runInboxWatcher(args) {
15
+ const { channelName, workerName, adapter, ctx, child, signal } = args;
16
+ // Resume from persisted cursor: first-time spawn → 0 (read full backlog);
17
+ // respawn after kill → last forwarded seq (no replay).
18
+ let cursor = readInboxCursor(channelName, workerName);
19
+ for await (const ev of watchEvents(channelName, {
20
+ self: workerName, // ignore our own events
21
+ to: workerName, // workers ONLY consume explicit `to`
22
+ kind: "message",
23
+ },
24
+ // First run with cursor=0 reads backlog from start; subsequent runs
25
+ // use sinceSeq to skip already-processed events. Both cases tail
26
+ // future events normally.
27
+ { signal, sinceSeq: cursor, fromStart: cursor === 0 ? true : undefined })) {
28
+ if (signal.aborted)
29
+ return;
30
+ // Workers must NOT consume each other's broadcast `message` events.
31
+ // Only ingest messages explicitly addressed to this worker via `to`.
32
+ const evTo = ev.to;
33
+ if (!evTo)
34
+ continue;
35
+ const toList = Array.isArray(evTo) ? evTo : [evTo];
36
+ if (!toList.includes(workerName))
37
+ continue;
38
+ const text = (ev.text ?? "").trim();
39
+ if (!text)
40
+ continue;
41
+ const tag = ev.tag;
42
+ // Block until the adapter says it can accept input (e.g. codex
43
+ // thread/start has produced a threadId). Drop the message if we
44
+ // never get ready before being aborted.
45
+ if (!adapter.isReady(ctx)) {
46
+ const deadline = Date.now() + 60_000;
47
+ while (!adapter.isReady(ctx) &&
48
+ Date.now() < deadline &&
49
+ !signal.aborted) {
50
+ await sleep(25);
51
+ }
52
+ if (!adapter.isReady(ctx)) {
53
+ // never became ready; advance the cursor anyway so we don't
54
+ // re-attempt this exact event on next start.
55
+ cursor = ev.seq;
56
+ writeInboxCursor(channelName, workerName, cursor);
57
+ continue;
58
+ }
59
+ }
60
+ try {
61
+ child.stdin.write(adapter.encodeUserMessage(text, tag, ctx));
62
+ cursor = ev.seq;
63
+ writeInboxCursor(channelName, workerName, cursor);
64
+ }
65
+ catch {
66
+ // stdin closed, worker exiting — bail out
67
+ return;
68
+ }
69
+ }
70
+ }
71
+ /**
72
+ * Per-worker inbox consumption cursor. Persisted to
73
+ * `<worker>.inbox-cursor` so a respawn (same worker name) doesn't replay
74
+ * messages that the previous supervisor already forwarded into the worker
75
+ * process. The cursor is the highest seq we've already turned into a
76
+ * worker stdin write.
77
+ */
78
+ function readInboxCursor(channelName, workerName) {
79
+ try {
80
+ const raw = fs.readFileSync(workerFile(channelName, workerName, "inbox-cursor"), "utf-8");
81
+ const n = Number(raw.trim());
82
+ return Number.isFinite(n) && n > 0 ? n : 0;
83
+ }
84
+ catch {
85
+ return 0;
86
+ }
87
+ }
88
+ function writeInboxCursor(channelName, workerName, seq) {
89
+ try {
90
+ fs.writeFileSync(workerFile(channelName, workerName, "inbox-cursor"), String(seq), "utf-8");
91
+ }
92
+ catch {
93
+ // ignore — cursor is best-effort; worst case we replay a message
94
+ }
95
+ }
96
+ function sleep(ms) {
97
+ return new Promise((r) => setTimeout(r, ms));
98
+ }
99
+ //# sourceMappingURL=inbox.js.map