kimaki 0.30.1 → 1.0.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 (987) hide show
  1. package/dist/agent-ui.d.ts +33 -0
  2. package/dist/agent-ui.e2e.test.d.ts +1 -0
  3. package/dist/agent-ui.e2e.test.js +140 -0
  4. package/dist/agent-ui.e2e.test.js.map +1 -0
  5. package/dist/agent-ui.js +199 -0
  6. package/dist/agent-ui.js.map +1 -0
  7. package/dist/analytics.d.ts +42 -0
  8. package/dist/analytics.e2e.test.d.ts +1 -0
  9. package/dist/analytics.e2e.test.js +112 -0
  10. package/dist/analytics.e2e.test.js.map +1 -0
  11. package/dist/analytics.js +162 -221
  12. package/dist/analytics.js.map +1 -0
  13. package/dist/analytics.test.d.ts +1 -0
  14. package/dist/analytics.test.js +121 -157
  15. package/dist/analytics.test.js.map +1 -0
  16. package/dist/autostart.d.ts +7 -0
  17. package/dist/autostart.js +75 -0
  18. package/dist/autostart.js.map +1 -0
  19. package/dist/bot.d.ts +90 -0
  20. package/dist/bot.js +120 -0
  21. package/dist/bot.js.map +1 -0
  22. package/dist/btw.e2e.test.d.ts +1 -0
  23. package/dist/btw.e2e.test.js +102 -0
  24. package/dist/btw.e2e.test.js.map +1 -0
  25. package/dist/catalog-refresh.e2e.test.d.ts +1 -0
  26. package/dist/catalog-refresh.e2e.test.js +90 -0
  27. package/dist/catalog-refresh.e2e.test.js.map +1 -0
  28. package/dist/cli/bot.d.ts +5 -0
  29. package/dist/cli/bot.js +427 -0
  30. package/dist/cli/bot.js.map +1 -0
  31. package/dist/cli/discord.d.ts +3 -0
  32. package/dist/cli/discord.js +118 -0
  33. package/dist/cli/discord.js.map +1 -0
  34. package/dist/cli/project.d.ts +5 -0
  35. package/dist/cli/project.js +143 -0
  36. package/dist/cli/project.js.map +1 -0
  37. package/dist/cli/schedule.d.ts +3 -0
  38. package/dist/cli/schedule.js +156 -0
  39. package/dist/cli/schedule.js.map +1 -0
  40. package/dist/cli/session.d.ts +4 -0
  41. package/dist/cli/session.js +281 -0
  42. package/dist/cli/session.js.map +1 -0
  43. package/dist/cli/shared.d.ts +55 -0
  44. package/dist/cli/shared.js +138 -0
  45. package/dist/cli/shared.js.map +1 -0
  46. package/dist/cli-discord.e2e.test.d.ts +1 -0
  47. package/dist/cli-discord.e2e.test.js +64 -0
  48. package/dist/cli-discord.e2e.test.js.map +1 -0
  49. package/dist/cli-lock.e2e.test.d.ts +1 -0
  50. package/dist/cli-lock.e2e.test.js +520 -0
  51. package/dist/cli-lock.e2e.test.js.map +1 -0
  52. package/dist/cli-read.e2e.test.d.ts +1 -0
  53. package/dist/cli-read.e2e.test.js +81 -0
  54. package/dist/cli-read.e2e.test.js.map +1 -0
  55. package/dist/cli-sessions.e2e.test.d.ts +1 -0
  56. package/dist/cli-sessions.e2e.test.js +116 -0
  57. package/dist/cli-sessions.e2e.test.js.map +1 -0
  58. package/dist/cli.d.ts +2 -0
  59. package/dist/cli.js +34 -263
  60. package/dist/cli.js.map +1 -0
  61. package/dist/commands/login-commands.d.ts +59 -0
  62. package/dist/commands/login-commands.js +341 -0
  63. package/dist/commands/login-commands.js.map +1 -0
  64. package/dist/commands/preference-commands.d.ts +44 -0
  65. package/dist/commands/preference-commands.js +551 -0
  66. package/dist/commands/preference-commands.js.map +1 -0
  67. package/dist/commands/session-commands.d.ts +8 -0
  68. package/dist/commands/session-commands.js +267 -0
  69. package/dist/commands/session-commands.js.map +1 -0
  70. package/dist/commands/thread-commands.d.ts +16 -0
  71. package/dist/commands/thread-commands.js +285 -0
  72. package/dist/commands/thread-commands.js.map +1 -0
  73. package/dist/commands/worktree-commands.d.ts +41 -0
  74. package/dist/commands/worktree-commands.js +279 -0
  75. package/dist/commands/worktree-commands.js.map +1 -0
  76. package/dist/commands.e2e.test.d.ts +1 -0
  77. package/dist/commands.e2e.test.js +255 -0
  78. package/dist/commands.e2e.test.js.map +1 -0
  79. package/dist/credentials.d.ts +84 -0
  80. package/dist/credentials.js +320 -0
  81. package/dist/credentials.js.map +1 -0
  82. package/dist/db.d.ts +1532 -0
  83. package/dist/db.js +57 -245
  84. package/dist/db.js.map +1 -0
  85. package/dist/db.test.d.ts +1 -0
  86. package/dist/db.test.js +352 -673
  87. package/dist/db.test.js.map +1 -0
  88. package/dist/duration.d.ts +2 -0
  89. package/dist/duration.js +18 -0
  90. package/dist/duration.js.map +1 -0
  91. package/dist/effects.d.ts +15 -0
  92. package/dist/effects.js +291 -0
  93. package/dist/effects.js.map +1 -0
  94. package/dist/errors.d.ts +38 -0
  95. package/dist/errors.js +40 -170
  96. package/dist/errors.js.map +1 -0
  97. package/dist/event-loop.d.ts +40 -0
  98. package/dist/event-loop.js +414 -0
  99. package/dist/event-loop.js.map +1 -0
  100. package/dist/file-edit-log.d.ts +41 -0
  101. package/dist/file-edit-log.js +122 -164
  102. package/dist/file-edit-log.js.map +1 -0
  103. package/dist/file-edit-log.test.d.ts +1 -0
  104. package/dist/file-edit-log.test.js +68 -244
  105. package/dist/file-edit-log.test.js.map +1 -0
  106. package/dist/format-parts.d.ts +137 -0
  107. package/dist/format-parts.js +300 -0
  108. package/dist/format-parts.js.map +1 -0
  109. package/dist/format-parts.test.d.ts +1 -0
  110. package/dist/format-parts.test.js +144 -0
  111. package/dist/format-parts.test.js.map +1 -0
  112. package/dist/gateway-replay.e2e.test.d.ts +1 -0
  113. package/dist/gateway-replay.e2e.test.js +95 -0
  114. package/dist/gateway-replay.e2e.test.js.map +1 -0
  115. package/dist/harness.e2e.test.d.ts +1 -0
  116. package/dist/harness.e2e.test.js +107 -0
  117. package/dist/harness.e2e.test.js.map +1 -0
  118. package/dist/hello-thread.e2e.test.d.ts +1 -0
  119. package/dist/hello-thread.e2e.test.js +194 -0
  120. package/dist/hello-thread.e2e.test.js.map +1 -0
  121. package/dist/ingress.d.ts +7 -0
  122. package/dist/ingress.js +337 -0
  123. package/dist/ingress.js.map +1 -0
  124. package/dist/interaction-context.d.ts +45 -0
  125. package/dist/interaction-context.js +77 -0
  126. package/dist/interaction-context.js.map +1 -0
  127. package/dist/interrupt.e2e.test.d.ts +1 -0
  128. package/dist/interrupt.e2e.test.js +124 -0
  129. package/dist/interrupt.e2e.test.js.map +1 -0
  130. package/dist/legacy.e2e.test.d.ts +1 -0
  131. package/dist/legacy.e2e.test.js +85 -0
  132. package/dist/legacy.e2e.test.js.map +1 -0
  133. package/dist/live-call.d.ts +51 -0
  134. package/dist/live-call.js +207 -0
  135. package/dist/live-call.js.map +1 -0
  136. package/dist/lock-routes.d.ts +812 -0
  137. package/dist/lock-routes.js +635 -0
  138. package/dist/lock-routes.js.map +1 -0
  139. package/dist/lock-server.d.ts +36 -0
  140. package/dist/lock-server.js +223 -0
  141. package/dist/lock-server.js.map +1 -0
  142. package/dist/logger.d.ts +13 -0
  143. package/dist/logger.js +112 -162
  144. package/dist/logger.js.map +1 -0
  145. package/dist/login.e2e.test.d.ts +1 -0
  146. package/dist/login.e2e.test.js +83 -0
  147. package/dist/login.e2e.test.js.map +1 -0
  148. package/dist/main.d.ts +32 -0
  149. package/dist/main.js +190 -0
  150. package/dist/main.js.map +1 -0
  151. package/dist/markdown/components.d.ts +10 -0
  152. package/dist/markdown/components.js +77 -0
  153. package/dist/markdown/components.js.map +1 -0
  154. package/dist/markdown/markdown.test.d.ts +1 -0
  155. package/dist/markdown/markdown.test.js +393 -0
  156. package/dist/markdown/markdown.test.js.map +1 -0
  157. package/dist/markdown/render-markdown.d.ts +30 -0
  158. package/dist/markdown/render-markdown.js +265 -0
  159. package/dist/markdown/render-markdown.js.map +1 -0
  160. package/dist/message-tool.e2e.test.d.ts +1 -0
  161. package/dist/message-tool.e2e.test.js +39 -0
  162. package/dist/message-tool.e2e.test.js.map +1 -0
  163. package/dist/migrations.d.ts +8 -0
  164. package/dist/migrations.js +187 -0
  165. package/dist/migrations.js.map +1 -0
  166. package/dist/onboarding-cli.e2e.test.d.ts +1 -0
  167. package/dist/onboarding-cli.e2e.test.js +178 -0
  168. package/dist/onboarding-cli.e2e.test.js.map +1 -0
  169. package/dist/onboarding.d.ts +36 -0
  170. package/dist/onboarding.e2e.test.d.ts +1 -0
  171. package/dist/onboarding.e2e.test.js +148 -0
  172. package/dist/onboarding.e2e.test.js.map +1 -0
  173. package/dist/onboarding.js +261 -0
  174. package/dist/onboarding.js.map +1 -0
  175. package/dist/opencode-server.d.ts +54 -0
  176. package/dist/opencode-server.js +413 -0
  177. package/dist/opencode-server.js.map +1 -0
  178. package/dist/opencode-server.test.d.ts +1 -0
  179. package/dist/opencode-server.test.js +21 -0
  180. package/dist/opencode-server.test.js.map +1 -0
  181. package/dist/permissions.d.ts +31 -0
  182. package/dist/permissions.e2e.test.d.ts +1 -0
  183. package/dist/permissions.e2e.test.js +166 -0
  184. package/dist/permissions.e2e.test.js.map +1 -0
  185. package/dist/permissions.js +95 -0
  186. package/dist/permissions.js.map +1 -0
  187. package/dist/plugin/anthropic/index.d.ts +13 -0
  188. package/dist/plugin/anthropic/index.js +201 -0
  189. package/dist/plugin/anthropic/index.js.map +1 -0
  190. package/dist/plugin/anthropic/index.test.d.ts +1 -0
  191. package/dist/plugin/anthropic/index.test.js +39 -0
  192. package/dist/plugin/anthropic/index.test.js.map +1 -0
  193. package/dist/plugin/index.d.ts +3 -0
  194. package/dist/plugin/index.js +106 -0
  195. package/dist/plugin/index.js.map +1 -0
  196. package/dist/plugin/session-id/index.d.ts +3 -0
  197. package/dist/plugin/session-id/index.js +18 -0
  198. package/dist/plugin/session-id/index.js.map +1 -0
  199. package/dist/plugin.e2e.test.d.ts +1 -0
  200. package/dist/plugin.e2e.test.js +87 -0
  201. package/dist/plugin.e2e.test.js.map +1 -0
  202. package/dist/preference-commands.e2e.test.d.ts +1 -0
  203. package/dist/preference-commands.e2e.test.js +555 -0
  204. package/dist/preference-commands.e2e.test.js.map +1 -0
  205. package/dist/probe-live.tmp.d.ts +1 -0
  206. package/dist/probe-live.tmp.js +82 -0
  207. package/dist/probe-live.tmp.js.map +1 -0
  208. package/dist/project.d.ts +58 -0
  209. package/dist/project.js +169 -0
  210. package/dist/project.js.map +1 -0
  211. package/dist/prompt.d.ts +112 -0
  212. package/dist/prompt.js +578 -0
  213. package/dist/prompt.js.map +1 -0
  214. package/dist/questions.d.ts +59 -0
  215. package/dist/questions.e2e.test.d.ts +1 -0
  216. package/dist/questions.e2e.test.js +290 -0
  217. package/dist/questions.e2e.test.js.map +1 -0
  218. package/dist/questions.js +231 -0
  219. package/dist/questions.js.map +1 -0
  220. package/dist/queue.d.ts +45 -0
  221. package/dist/queue.e2e.test.d.ts +1 -0
  222. package/dist/queue.e2e.test.js +220 -0
  223. package/dist/queue.e2e.test.js.map +1 -0
  224. package/dist/queue.js +132 -0
  225. package/dist/queue.js.map +1 -0
  226. package/dist/remote-send.d.ts +32 -0
  227. package/dist/remote-send.e2e.test.d.ts +1 -0
  228. package/dist/remote-send.e2e.test.js +89 -0
  229. package/dist/remote-send.e2e.test.js.map +1 -0
  230. package/dist/remote-send.js +105 -0
  231. package/dist/remote-send.js.map +1 -0
  232. package/dist/renderer.e2e.test.d.ts +1 -0
  233. package/dist/renderer.e2e.test.js +357 -0
  234. package/dist/renderer.e2e.test.js.map +1 -0
  235. package/dist/restart.e2e.test.d.ts +1 -0
  236. package/dist/restart.e2e.test.js +68 -0
  237. package/dist/restart.e2e.test.js.map +1 -0
  238. package/dist/routes.d.ts +24 -0
  239. package/dist/routes.js +42 -0
  240. package/dist/routes.js.map +1 -0
  241. package/dist/routes.test.d.ts +1 -0
  242. package/dist/routes.test.js +79 -0
  243. package/dist/routes.test.js.map +1 -0
  244. package/dist/routines.e2e.test.d.ts +1 -0
  245. package/dist/routines.e2e.test.js +188 -0
  246. package/dist/routines.e2e.test.js.map +1 -0
  247. package/dist/scheduler.d.ts +116 -0
  248. package/dist/scheduler.e2e.test.d.ts +1 -0
  249. package/dist/scheduler.e2e.test.js +163 -0
  250. package/dist/scheduler.e2e.test.js.map +1 -0
  251. package/dist/scheduler.js +602 -0
  252. package/dist/scheduler.js.map +1 -0
  253. package/dist/scheduler.test.d.ts +1 -0
  254. package/dist/scheduler.test.js +180 -0
  255. package/dist/scheduler.test.js.map +1 -0
  256. package/dist/schema-sql.d.ts +1 -0
  257. package/dist/schema-sql.js +3 -0
  258. package/dist/schema-sql.js.map +1 -0
  259. package/dist/schema.d.ts +2968 -0
  260. package/dist/schema.js +95 -252
  261. package/dist/schema.js.map +1 -0
  262. package/dist/session-commands.e2e.test.d.ts +1 -0
  263. package/dist/session-commands.e2e.test.js +285 -0
  264. package/dist/session-commands.e2e.test.js.map +1 -0
  265. package/dist/session-events.d.ts +55 -0
  266. package/dist/session-events.js +190 -0
  267. package/dist/session-events.js.map +1 -0
  268. package/dist/session-ops.e2e.test.d.ts +1 -0
  269. package/dist/session-ops.e2e.test.js +114 -0
  270. package/dist/session-ops.e2e.test.js.map +1 -0
  271. package/dist/sessions.d.ts +121 -0
  272. package/dist/sessions.js +662 -0
  273. package/dist/sessions.js.map +1 -0
  274. package/dist/shell.e2e.test.d.ts +1 -0
  275. package/dist/shell.e2e.test.js +147 -0
  276. package/dist/shell.e2e.test.js.map +1 -0
  277. package/dist/slash-commands.d.ts +62 -0
  278. package/dist/slash-commands.js +475 -0
  279. package/dist/slash-commands.js.map +1 -0
  280. package/dist/slash-commands.test.d.ts +1 -0
  281. package/dist/slash-commands.test.js +87 -0
  282. package/dist/slash-commands.test.js.map +1 -0
  283. package/dist/sleep.e2e.test.d.ts +1 -0
  284. package/dist/sleep.e2e.test.js +115 -487
  285. package/dist/sleep.e2e.test.js.map +1 -0
  286. package/dist/sleeps.d.ts +37 -0
  287. package/dist/sleeps.js +220 -0
  288. package/dist/sleeps.js.map +1 -0
  289. package/dist/store.d.ts +10 -0
  290. package/dist/store.js +8 -28
  291. package/dist/store.js.map +1 -0
  292. package/dist/system-prompt.d.ts +65 -0
  293. package/dist/system-prompt.js +875 -0
  294. package/dist/system-prompt.js.map +1 -0
  295. package/dist/tasks.e2e.test.d.ts +1 -0
  296. package/dist/tasks.e2e.test.js +173 -0
  297. package/dist/tasks.e2e.test.js.map +1 -0
  298. package/dist/test/auth-plugin/index.d.ts +3 -0
  299. package/dist/test/auth-plugin/index.js +18 -0
  300. package/dist/test/auth-plugin/index.js.map +1 -0
  301. package/dist/test/fake-mcp-server.d.ts +1 -0
  302. package/dist/test/fake-mcp-server.js +45 -0
  303. package/dist/test/fake-mcp-server.js.map +1 -0
  304. package/dist/test/harness.d.ts +246 -0
  305. package/dist/test/harness.js +704 -0
  306. package/dist/test/harness.js.map +1 -0
  307. package/dist/test/replay.d.ts +14 -0
  308. package/dist/test/replay.js +75 -0
  309. package/dist/test/replay.js.map +1 -0
  310. package/dist/thread-reducer.d.ts +172 -0
  311. package/dist/thread-reducer.fixtures.test.d.ts +1 -0
  312. package/dist/thread-reducer.fixtures.test.js +360 -0
  313. package/dist/thread-reducer.fixtures.test.js.map +1 -0
  314. package/dist/thread-reducer.js +497 -0
  315. package/dist/thread-reducer.js.map +1 -0
  316. package/dist/thread-reducer.test.d.ts +1 -0
  317. package/dist/thread-reducer.test.js +369 -0
  318. package/dist/thread-reducer.test.js.map +1 -0
  319. package/dist/tts.test.d.ts +1 -0
  320. package/dist/tts.test.js +147 -0
  321. package/dist/tts.test.js.map +1 -0
  322. package/dist/voice-agent.d.ts +33 -0
  323. package/dist/voice-agent.js +159 -0
  324. package/dist/voice-agent.js.map +1 -0
  325. package/dist/voice-attachments.e2e.test.d.ts +1 -0
  326. package/dist/voice-attachments.e2e.test.js +253 -0
  327. package/dist/voice-attachments.e2e.test.js.map +1 -0
  328. package/dist/voice-call.d.ts +59 -0
  329. package/dist/voice-call.e2e.test.d.ts +1 -0
  330. package/dist/voice-call.e2e.test.js +259 -0
  331. package/dist/voice-call.e2e.test.js.map +1 -0
  332. package/dist/voice-call.js +760 -0
  333. package/dist/voice-call.js.map +1 -0
  334. package/dist/voice-openai.e2e.test.d.ts +1 -0
  335. package/dist/voice-openai.e2e.test.js +161 -0
  336. package/dist/voice-openai.e2e.test.js.map +1 -0
  337. package/dist/voice.d.ts +116 -0
  338. package/dist/voice.js +648 -646
  339. package/dist/voice.js.map +1 -0
  340. package/dist/working-directory.e2e.test.d.ts +1 -0
  341. package/dist/working-directory.e2e.test.js +231 -0
  342. package/dist/working-directory.e2e.test.js.map +1 -0
  343. package/dist/worktrees.d.ts +54 -0
  344. package/dist/worktrees.js +247 -709
  345. package/dist/worktrees.js.map +1 -0
  346. package/dist/worktrees.test.d.ts +1 -0
  347. package/dist/worktrees.test.js +97 -952
  348. package/dist/worktrees.test.js.map +1 -0
  349. package/package.json +40 -79
  350. package/src/agent-ui.e2e.test.ts +134 -0
  351. package/src/agent-ui.ts +216 -0
  352. package/src/analytics.e2e.test.ts +138 -0
  353. package/src/analytics.test.ts +122 -182
  354. package/src/analytics.ts +206 -256
  355. package/src/autostart.ts +78 -0
  356. package/src/bot.ts +194 -0
  357. package/src/btw.e2e.test.ts +130 -0
  358. package/src/catalog-refresh.e2e.test.ts +112 -0
  359. package/src/cli/bot.ts +419 -0
  360. package/src/cli/discord.ts +116 -0
  361. package/src/cli/project.ts +147 -0
  362. package/src/cli/schedule.ts +151 -0
  363. package/src/cli/session.ts +285 -0
  364. package/src/cli/shared.ts +139 -0
  365. package/src/cli-discord.e2e.test.ts +62 -0
  366. package/src/cli-lock.e2e.test.ts +530 -0
  367. package/src/cli-read.e2e.test.ts +78 -0
  368. package/src/cli-sessions.e2e.test.ts +122 -0
  369. package/src/cli.ts +35 -418
  370. package/src/commands/login-commands.ts +360 -0
  371. package/src/commands/preference-commands.ts +586 -0
  372. package/src/commands/session-commands.ts +289 -0
  373. package/src/commands/thread-commands.ts +324 -0
  374. package/src/commands/worktree-commands.ts +288 -0
  375. package/src/commands.e2e.test.ts +290 -0
  376. package/src/credentials.ts +425 -0
  377. package/src/db.test.ts +345 -748
  378. package/src/db.ts +66 -284
  379. package/src/duration.ts +18 -0
  380. package/src/effects.ts +303 -0
  381. package/src/errors.ts +39 -222
  382. package/src/event-loop.ts +462 -0
  383. package/src/file-edit-log.test.ts +68 -272
  384. package/src/file-edit-log.ts +108 -231
  385. package/src/fixtures/v1-schema.sql +241 -0
  386. package/src/fixtures/voice.ogg +0 -0
  387. package/src/format-parts.test.ts +150 -0
  388. package/src/format-parts.ts +405 -0
  389. package/src/gateway-replay.e2e.test.ts +116 -0
  390. package/src/harness.e2e.test.ts +124 -0
  391. package/src/hello-thread.e2e.test.ts +223 -0
  392. package/src/ingress.ts +334 -0
  393. package/src/interaction-context.ts +131 -0
  394. package/src/interrupt.e2e.test.ts +151 -0
  395. package/src/legacy.e2e.test.ts +105 -0
  396. package/src/live-call.ts +249 -0
  397. package/src/lock-routes.ts +625 -0
  398. package/src/lock-server.ts +233 -0
  399. package/src/logger.ts +120 -207
  400. package/src/login.e2e.test.ts +86 -0
  401. package/src/main.ts +230 -0
  402. package/src/markdown/components.ts +102 -0
  403. package/src/markdown/markdown.test.ts +414 -0
  404. package/src/markdown/render-markdown.ts +288 -0
  405. package/src/migrations.ts +198 -0
  406. package/src/onboarding-cli.e2e.test.ts +215 -0
  407. package/src/onboarding.e2e.test.ts +171 -0
  408. package/src/onboarding.ts +297 -0
  409. package/src/opencode-server.test.ts +24 -0
  410. package/src/opencode-server.ts +461 -0
  411. package/src/permissions.e2e.test.ts +191 -0
  412. package/src/permissions.ts +121 -0
  413. package/src/plugin/anthropic/index.test.ts +39 -0
  414. package/src/plugin/anthropic/index.ts +213 -0
  415. package/src/plugin/index.ts +93 -0
  416. package/src/plugin/session-id/index.ts +19 -0
  417. package/src/plugin.e2e.test.ts +112 -0
  418. package/src/preference-commands.e2e.test.ts +597 -0
  419. package/src/project.ts +216 -0
  420. package/src/prompt.ts +664 -0
  421. package/src/questions.e2e.test.ts +328 -0
  422. package/src/questions.ts +322 -0
  423. package/src/queue.e2e.test.ts +253 -0
  424. package/src/queue.ts +158 -0
  425. package/src/remote-send.e2e.test.ts +91 -0
  426. package/src/remote-send.ts +110 -0
  427. package/src/renderer.e2e.test.ts +390 -0
  428. package/src/restart.e2e.test.ts +90 -0
  429. package/src/routes.test.ts +81 -0
  430. package/src/routes.ts +48 -0
  431. package/src/routines.e2e.test.ts +210 -0
  432. package/src/scheduler.e2e.test.ts +182 -0
  433. package/src/scheduler.test.ts +183 -0
  434. package/src/scheduler.ts +648 -0
  435. package/src/schema-sql.ts +3 -0
  436. package/src/schema.ts +95 -271
  437. package/src/session-commands.e2e.test.ts +326 -0
  438. package/src/session-events.ts +218 -0
  439. package/src/session-ops.e2e.test.ts +141 -0
  440. package/src/sessions.ts +803 -0
  441. package/src/shell.e2e.test.ts +173 -0
  442. package/src/slash-commands.test.ts +89 -0
  443. package/src/slash-commands.ts +539 -0
  444. package/src/sleep.e2e.test.ts +135 -552
  445. package/src/sleeps.ts +230 -0
  446. package/src/store.ts +19 -217
  447. package/src/system-prompt.ts +944 -0
  448. package/src/test/auth-plugin/index.ts +17 -0
  449. package/src/test/fake-mcp-server.ts +49 -0
  450. package/src/test/harness.ts +957 -0
  451. package/src/test/replay.ts +90 -0
  452. package/src/thread-reducer.fixtures.test.ts +374 -0
  453. package/src/thread-reducer.test.ts +380 -0
  454. package/src/thread-reducer.ts +671 -0
  455. package/src/tts.test.ts +150 -0
  456. package/src/voice-agent.ts +196 -0
  457. package/src/voice-attachments.e2e.test.ts +298 -0
  458. package/src/voice-call.e2e.test.ts +293 -0
  459. package/src/voice-call.ts +764 -0
  460. package/src/voice-openai.e2e.test.ts +191 -0
  461. package/src/voice.ts +691 -890
  462. package/src/working-directory.e2e.test.ts +226 -0
  463. package/src/worktrees.test.ts +89 -1115
  464. package/src/worktrees.ts +195 -957
  465. package/bin.js +0 -2
  466. package/dist/agent-model.e2e.test.js +0 -1215
  467. package/dist/ai-tool-to-genai.js +0 -233
  468. package/dist/ai-tool-to-genai.test.js +0 -267
  469. package/dist/ai-tool.js +0 -6
  470. package/dist/anthropic-account-identity.js +0 -70
  471. package/dist/anthropic-account-identity.test.js +0 -38
  472. package/dist/anthropic-auth-plugin.js +0 -958
  473. package/dist/anthropic-auth-plugin.test.js +0 -115
  474. package/dist/anthropic-auth-state.js +0 -186
  475. package/dist/anthropic-auth-state.test.js +0 -203
  476. package/dist/bash-tool-schema-plugin.js +0 -50
  477. package/dist/bash-tool-schema-plugin.test.js +0 -68
  478. package/dist/bin.js +0 -151
  479. package/dist/bot-lifecycle.test.js +0 -206
  480. package/dist/btw-prefix-detection.js +0 -15
  481. package/dist/btw-prefix-detection.test.js +0 -93
  482. package/dist/cache-drift-plugin.js +0 -183
  483. package/dist/cache-rewrite.js +0 -39
  484. package/dist/cache-rewrite.test.js +0 -41
  485. package/dist/channel-management.js +0 -347
  486. package/dist/cli-commands/bot.js +0 -254
  487. package/dist/cli-commands/maintenance.js +0 -171
  488. package/dist/cli-commands/misc.js +0 -153
  489. package/dist/cli-commands/project.js +0 -510
  490. package/dist/cli-commands/send.js +0 -659
  491. package/dist/cli-commands/session.js +0 -889
  492. package/dist/cli-commands/task.js +0 -277
  493. package/dist/cli-commands/thread.js +0 -63
  494. package/dist/cli-commands/user.js +0 -145
  495. package/dist/cli-parsing.test.js +0 -226
  496. package/dist/cli-runner.js +0 -1579
  497. package/dist/cli-runner.test.js +0 -86
  498. package/dist/cli-send-thread.e2e.test.js +0 -470
  499. package/dist/cloudflare-transcription.js +0 -56
  500. package/dist/commands/abort.js +0 -84
  501. package/dist/commands/action-buttons.js +0 -248
  502. package/dist/commands/add-project.js +0 -111
  503. package/dist/commands/agent.js +0 -658
  504. package/dist/commands/ask-question.js +0 -371
  505. package/dist/commands/ask-question.test.js +0 -150
  506. package/dist/commands/btw.js +0 -167
  507. package/dist/commands/compact.js +0 -117
  508. package/dist/commands/context-usage.js +0 -147
  509. package/dist/commands/create-new-project.js +0 -138
  510. package/dist/commands/diff.js +0 -63
  511. package/dist/commands/file-upload.js +0 -280
  512. package/dist/commands/fork-subagent.js +0 -175
  513. package/dist/commands/fork.js +0 -260
  514. package/dist/commands/gemini-apikey.js +0 -123
  515. package/dist/commands/last-sessions.js +0 -129
  516. package/dist/commands/login.js +0 -893
  517. package/dist/commands/mcp.js +0 -239
  518. package/dist/commands/memory-snapshot.js +0 -24
  519. package/dist/commands/mention-mode.js +0 -42
  520. package/dist/commands/merge-worktree.js +0 -205
  521. package/dist/commands/model-variant.js +0 -390
  522. package/dist/commands/model.js +0 -957
  523. package/dist/commands/multioauth.js +0 -425
  524. package/dist/commands/new-worktree.js +0 -622
  525. package/dist/commands/paginated-select.js +0 -57
  526. package/dist/commands/permissions.js +0 -327
  527. package/dist/commands/queue.js +0 -340
  528. package/dist/commands/queue.test.js +0 -15
  529. package/dist/commands/remove-project.js +0 -111
  530. package/dist/commands/restart-opencode-server.js +0 -133
  531. package/dist/commands/resume.js +0 -148
  532. package/dist/commands/run-command.js +0 -79
  533. package/dist/commands/screenshare.js +0 -307
  534. package/dist/commands/screenshare.test.js +0 -20
  535. package/dist/commands/session-id.js +0 -78
  536. package/dist/commands/session.js +0 -243
  537. package/dist/commands/share.js +0 -80
  538. package/dist/commands/tasks.js +0 -296
  539. package/dist/commands/types.js +0 -2
  540. package/dist/commands/undo-redo.js +0 -313
  541. package/dist/commands/unset-model.js +0 -116
  542. package/dist/commands/upgrade.js +0 -41
  543. package/dist/commands/user-command.js +0 -196
  544. package/dist/commands/verbosity.js +0 -124
  545. package/dist/commands/vscode.js +0 -295
  546. package/dist/commands/worktrees.js +0 -548
  547. package/dist/condense-memory.js +0 -33
  548. package/dist/config.js +0 -126
  549. package/dist/context-awareness-plugin.js +0 -357
  550. package/dist/context-awareness-plugin.test.js +0 -126
  551. package/dist/cpu-profiler.js +0 -211
  552. package/dist/cpu-profiler.test.js +0 -160
  553. package/dist/critique-utils.js +0 -95
  554. package/dist/database.js +0 -1074
  555. package/dist/debounce-timeout.js +0 -28
  556. package/dist/debounced-process-flush.js +0 -77
  557. package/dist/default-channel-provisioning.test.js +0 -149
  558. package/dist/discord-bot.js +0 -1409
  559. package/dist/discord-command-registration.js +0 -519
  560. package/dist/discord-command-registration.test.js +0 -17
  561. package/dist/discord-urls.js +0 -81
  562. package/dist/discord-utils.js +0 -789
  563. package/dist/discord-utils.test.js +0 -400
  564. package/dist/escape-backticks.test.js +0 -429
  565. package/dist/event-stream-real-capture.e2e.test.js +0 -533
  566. package/dist/eventsource-parser.test.js +0 -327
  567. package/dist/exec-async.js +0 -38
  568. package/dist/external-directory-permissions.e2e.test.js +0 -86
  569. package/dist/external-directory-project-deny.e2e.test.js +0 -70
  570. package/dist/external-opencode-sync.js +0 -620
  571. package/dist/external-opencode-sync.test.js +0 -206
  572. package/dist/extract-sdk-error-message.test.js +0 -13
  573. package/dist/format-tables.js +0 -728
  574. package/dist/format-tables.test.js +0 -915
  575. package/dist/forum-sync/config.js +0 -79
  576. package/dist/forum-sync/discord-operations.js +0 -157
  577. package/dist/forum-sync/index.js +0 -5
  578. package/dist/forum-sync/markdown.js +0 -110
  579. package/dist/forum-sync/sync-to-discord.js +0 -417
  580. package/dist/forum-sync/sync-to-files.js +0 -190
  581. package/dist/forum-sync/types.js +0 -53
  582. package/dist/forum-sync/watchers.js +0 -322
  583. package/dist/gateway-proxy-reconnect.e2e.test.js +0 -414
  584. package/dist/gateway-proxy.e2e.test.js +0 -488
  585. package/dist/genai-worker-wrapper.js +0 -111
  586. package/dist/genai-worker.js +0 -309
  587. package/dist/genai.js +0 -232
  588. package/dist/git-worktree-core.js +0 -461
  589. package/dist/guild-categories.test.js +0 -225
  590. package/dist/heap-monitor.js +0 -122
  591. package/dist/hrana-server.js +0 -322
  592. package/dist/hrana-server.test.js +0 -99
  593. package/dist/html-actions.js +0 -123
  594. package/dist/html-actions.test.js +0 -70
  595. package/dist/html-components.js +0 -115
  596. package/dist/html-components.test.js +0 -34
  597. package/dist/image-optimizer-plugin.js +0 -153
  598. package/dist/image-utils.js +0 -112
  599. package/dist/interaction-handler.js +0 -578
  600. package/dist/ipc-polling.js +0 -245
  601. package/dist/ipc-tools-plugin.js +0 -251
  602. package/dist/kimaki-digital-twin.e2e.test.js +0 -161
  603. package/dist/kimaki-opencode-plugin-loading.e2e.test.js +0 -158
  604. package/dist/kimaki-opencode-plugin.js +0 -33
  605. package/dist/kimaki-opencode-plugin.test.js +0 -126
  606. package/dist/kimaki-workspace-adaptor.js +0 -118
  607. package/dist/limit-heading-depth.js +0 -25
  608. package/dist/limit-heading-depth.test.js +0 -105
  609. package/dist/list-channel-threads.js +0 -163
  610. package/dist/list-channel-threads.test.js +0 -80
  611. package/dist/markdown.js +0 -455
  612. package/dist/markdown.test.js +0 -411
  613. package/dist/memory-overview-plugin.js +0 -123
  614. package/dist/message-formatting.js +0 -763
  615. package/dist/message-formatting.test.js +0 -1132
  616. package/dist/message-preprocessing.js +0 -441
  617. package/dist/oauth-rotation-shared.js +0 -253
  618. package/dist/onboarding-tutorial.js +0 -163
  619. package/dist/onboarding-welcome.js +0 -37
  620. package/dist/openai-auth-plugin.js +0 -125
  621. package/dist/openai-auth-state.js +0 -237
  622. package/dist/openai-realtime.js +0 -224
  623. package/dist/opencode-command-detection.js +0 -65
  624. package/dist/opencode-command-detection.test.js +0 -240
  625. package/dist/opencode-command.js +0 -181
  626. package/dist/opencode-command.test.js +0 -218
  627. package/dist/opencode-interrupt-plugin.js +0 -253
  628. package/dist/opencode-interrupt-plugin.test.js +0 -293
  629. package/dist/opencode.js +0 -1217
  630. package/dist/parse-permission-rules.test.js +0 -117
  631. package/dist/patch-text-parser.js +0 -97
  632. package/dist/plugin-logger.js +0 -105
  633. package/dist/plugin-opencode-client.js +0 -54
  634. package/dist/privacy-sanitizer.js +0 -105
  635. package/dist/project-add.test.js +0 -62
  636. package/dist/question-abort-clears-dropdown.e2e.test.js +0 -89
  637. package/dist/question-abort-resume.e2e.test.js +0 -100
  638. package/dist/question-abort-retry-text-before-dropdown.e2e.test.js +0 -150
  639. package/dist/question-text-before-dropdown.e2e.test.js +0 -52
  640. package/dist/queue-advanced-abort.e2e.test.js +0 -348
  641. package/dist/queue-advanced-action-buttons.e2e.test.js +0 -209
  642. package/dist/queue-advanced-e2e-setup.js +0 -1043
  643. package/dist/queue-advanced-footer.e2e.test.js +0 -286
  644. package/dist/queue-advanced-model-switch.e2e.test.js +0 -297
  645. package/dist/queue-advanced-permissions-typing.e2e.test.js +0 -189
  646. package/dist/queue-advanced-question.e2e.test.js +0 -266
  647. package/dist/queue-advanced-typing-interrupt.e2e.test.js +0 -113
  648. package/dist/queue-advanced-typing.e2e.test.js +0 -151
  649. package/dist/queue-delete-message.e2e.test.js +0 -75
  650. package/dist/queue-drain-after-interactive-ui.e2e.test.js +0 -120
  651. package/dist/queue-interrupt-drain.e2e.test.js +0 -246
  652. package/dist/queue-question-select-drain.e2e.test.js +0 -162
  653. package/dist/runtime-idle-sweeper.js +0 -52
  654. package/dist/runtime-lifecycle.e2e.test.js +0 -570
  655. package/dist/sentry.js +0 -23
  656. package/dist/session-handler/agent-utils.js +0 -66
  657. package/dist/session-handler/event-stream-state.js +0 -1217
  658. package/dist/session-handler/event-stream-state.test.js +0 -3034
  659. package/dist/session-handler/global-event-listener.js +0 -212
  660. package/dist/session-handler/model-utils.js +0 -311
  661. package/dist/session-handler/model-utils.test.js +0 -445
  662. package/dist/session-handler/opencode-session-event-log.js +0 -121
  663. package/dist/session-handler/thread-ingress.test.js +0 -41
  664. package/dist/session-handler/thread-runtime-state.js +0 -209
  665. package/dist/session-handler/thread-session-runtime-summary.test.js +0 -121
  666. package/dist/session-handler/thread-session-runtime.js +0 -4252
  667. package/dist/session-handler.js +0 -9
  668. package/dist/session-search.js +0 -219
  669. package/dist/session-search.test.js +0 -287
  670. package/dist/session-sleep.test.js +0 -224
  671. package/dist/session-title-rename.test.js +0 -128
  672. package/dist/skill-filter.js +0 -43
  673. package/dist/skill-filter.test.js +0 -86
  674. package/dist/startup-service.js +0 -153
  675. package/dist/startup-time.e2e.test.js +0 -297
  676. package/dist/system-message.js +0 -984
  677. package/dist/system-message.test.js +0 -1093
  678. package/dist/task-id-plugin.js +0 -16
  679. package/dist/task-runner.js +0 -554
  680. package/dist/task-schedule.js +0 -298
  681. package/dist/task-schedule.test.js +0 -366
  682. package/dist/test-utils.js +0 -359
  683. package/dist/thinking-utils.js +0 -45
  684. package/dist/thinking-utils.test.js +0 -35
  685. package/dist/thread-message-queue.e2e.test.js +0 -1155
  686. package/dist/tools.js +0 -357
  687. package/dist/undo-redo.e2e.test.js +0 -171
  688. package/dist/unnest-code-blocks.js +0 -146
  689. package/dist/unnest-code-blocks.test.js +0 -673
  690. package/dist/upgrade.js +0 -114
  691. package/dist/utils.js +0 -148
  692. package/dist/voice-attachment.js +0 -56
  693. package/dist/voice-handler.js +0 -726
  694. package/dist/voice-message.e2e.test.js +0 -1263
  695. package/dist/voice-routing-input.e2e.test.js +0 -195
  696. package/dist/voice-routing-question.e2e.test.js +0 -125
  697. package/dist/voice.test.js +0 -352
  698. package/dist/wait-session.js +0 -193
  699. package/dist/websockify.js +0 -69
  700. package/dist/worker-types.js +0 -4
  701. package/dist/worktree-clone-isolation.e2e.test.js +0 -188
  702. package/dist/worktree-lifecycle.e2e.test.js +0 -735
  703. package/dist/worktree-utils.js +0 -3
  704. package/dist/xai-auth-plugin.js +0 -238
  705. package/dist/xai-auth-state.js +0 -234
  706. package/dist/xai-auth-state.test.js +0 -183
  707. package/dist/xml.js +0 -92
  708. package/dist/xml.test.js +0 -32
  709. package/skills/bump-holocron-consumers/SKILL.md +0 -137
  710. package/skills/critique/SKILL.md +0 -112
  711. package/skills/egaki/SKILL.md +0 -86
  712. package/skills/errore/SKILL.md +0 -501
  713. package/skills/goke/SKILL.md +0 -695
  714. package/skills/holocron/SKILL.md +0 -942
  715. package/skills/lintcn/SKILL.md +0 -873
  716. package/skills/new-skill/SKILL.md +0 -339
  717. package/skills/npm-package/SKILL.md +0 -692
  718. package/skills/opensrc/SKILL.md +0 -95
  719. package/skills/playwriter/SKILL.md +0 -35
  720. package/skills/profano/SKILL.md +0 -33
  721. package/skills/readme.md +0 -20
  722. package/skills/sigillo/SKILL.md +0 -370
  723. package/skills/spiceflow/SKILL.md +0 -80
  724. package/skills/strada/SKILL.md +0 -104
  725. package/skills/termcast/SKILL.md +0 -133
  726. package/skills/tuistory/SKILL.md +0 -237
  727. package/skills/usecomputer/SKILL.md +0 -264
  728. package/skills/zele/SKILL.md +0 -81
  729. package/src/agent-model.e2e.test.ts +0 -1548
  730. package/src/ai-tool-to-genai.test.ts +0 -296
  731. package/src/ai-tool-to-genai.ts +0 -283
  732. package/src/ai-tool.ts +0 -39
  733. package/src/anthropic-account-identity.test.ts +0 -52
  734. package/src/anthropic-account-identity.ts +0 -96
  735. package/src/anthropic-auth-plugin.test.ts +0 -135
  736. package/src/anthropic-auth-plugin.ts +0 -1180
  737. package/src/anthropic-auth-state.test.ts +0 -259
  738. package/src/anthropic-auth-state.ts +0 -272
  739. package/src/bash-tool-schema-plugin.test.ts +0 -84
  740. package/src/bash-tool-schema-plugin.ts +0 -77
  741. package/src/bin.ts +0 -173
  742. package/src/bot-lifecycle.test.ts +0 -252
  743. package/src/btw-prefix-detection.test.ts +0 -104
  744. package/src/btw-prefix-detection.ts +0 -19
  745. package/src/cache-drift-plugin.ts +0 -249
  746. package/src/cache-rewrite.test.ts +0 -49
  747. package/src/cache-rewrite.ts +0 -96
  748. package/src/channel-management.ts +0 -494
  749. package/src/cli-commands/bot.ts +0 -374
  750. package/src/cli-commands/maintenance.ts +0 -237
  751. package/src/cli-commands/misc.ts +0 -208
  752. package/src/cli-commands/project.ts +0 -680
  753. package/src/cli-commands/send.ts +0 -879
  754. package/src/cli-commands/session.ts +0 -1181
  755. package/src/cli-commands/task.ts +0 -358
  756. package/src/cli-commands/thread.ts +0 -86
  757. package/src/cli-commands/user.ts +0 -195
  758. package/src/cli-parsing.test.ts +0 -305
  759. package/src/cli-runner.test.ts +0 -129
  760. package/src/cli-runner.ts +0 -2141
  761. package/src/cli-send-thread.e2e.test.ts +0 -609
  762. package/src/cloudflare-transcription.ts +0 -76
  763. package/src/commands/abort.ts +0 -113
  764. package/src/commands/action-buttons.ts +0 -371
  765. package/src/commands/add-project.ts +0 -146
  766. package/src/commands/agent.ts +0 -911
  767. package/src/commands/ask-question.test.ts +0 -177
  768. package/src/commands/ask-question.ts +0 -532
  769. package/src/commands/btw.ts +0 -246
  770. package/src/commands/compact.ts +0 -154
  771. package/src/commands/context-usage.ts +0 -208
  772. package/src/commands/create-new-project.ts +0 -203
  773. package/src/commands/diff.ts +0 -91
  774. package/src/commands/file-upload.ts +0 -398
  775. package/src/commands/fork-subagent.ts +0 -262
  776. package/src/commands/fork.ts +0 -388
  777. package/src/commands/gemini-apikey.ts +0 -205
  778. package/src/commands/last-sessions.ts +0 -176
  779. package/src/commands/login.ts +0 -1182
  780. package/src/commands/mcp.ts +0 -307
  781. package/src/commands/memory-snapshot.ts +0 -30
  782. package/src/commands/mention-mode.ts +0 -66
  783. package/src/commands/merge-worktree.ts +0 -282
  784. package/src/commands/model-variant.ts +0 -522
  785. package/src/commands/model.ts +0 -1310
  786. package/src/commands/multioauth.ts +0 -508
  787. package/src/commands/new-worktree.ts +0 -832
  788. package/src/commands/paginated-select.ts +0 -81
  789. package/src/commands/permissions.ts +0 -458
  790. package/src/commands/queue.test.ts +0 -19
  791. package/src/commands/queue.ts +0 -455
  792. package/src/commands/remove-project.ts +0 -152
  793. package/src/commands/restart-opencode-server.ts +0 -173
  794. package/src/commands/resume.ts +0 -229
  795. package/src/commands/run-command.ts +0 -123
  796. package/src/commands/screenshare.test.ts +0 -30
  797. package/src/commands/screenshare.ts +0 -388
  798. package/src/commands/session-id.ts +0 -109
  799. package/src/commands/session.ts +0 -311
  800. package/src/commands/share.ts +0 -106
  801. package/src/commands/tasks.ts +0 -399
  802. package/src/commands/types.ts +0 -25
  803. package/src/commands/undo-redo.ts +0 -394
  804. package/src/commands/unset-model.ts +0 -152
  805. package/src/commands/upgrade.ts +0 -51
  806. package/src/commands/user-command.ts +0 -260
  807. package/src/commands/verbosity.ts +0 -172
  808. package/src/commands/vscode.ts +0 -378
  809. package/src/commands/worktrees.ts +0 -762
  810. package/src/condense-memory.ts +0 -36
  811. package/src/config.ts +0 -147
  812. package/src/context-awareness-plugin.test.ts +0 -144
  813. package/src/context-awareness-plugin.ts +0 -508
  814. package/src/cpu-profiler.test.ts +0 -183
  815. package/src/cpu-profiler.ts +0 -293
  816. package/src/critique-utils.ts +0 -139
  817. package/src/database.ts +0 -1484
  818. package/src/debounce-timeout.ts +0 -43
  819. package/src/debounced-process-flush.ts +0 -104
  820. package/src/default-channel-provisioning.test.ts +0 -156
  821. package/src/discord-bot.ts +0 -1836
  822. package/src/discord-command-registration.test.ts +0 -20
  823. package/src/discord-command-registration.ts +0 -704
  824. package/src/discord-urls.ts +0 -88
  825. package/src/discord-utils.test.ts +0 -470
  826. package/src/discord-utils.ts +0 -1079
  827. package/src/escape-backticks.test.ts +0 -469
  828. package/src/event-stream-real-capture.e2e.test.ts +0 -692
  829. package/src/eventsource-parser.test.ts +0 -351
  830. package/src/exec-async.ts +0 -44
  831. package/src/external-directory-permissions.e2e.test.ts +0 -103
  832. package/src/external-directory-project-deny.e2e.test.ts +0 -84
  833. package/src/external-opencode-sync.test.ts +0 -248
  834. package/src/external-opencode-sync.ts +0 -867
  835. package/src/extract-sdk-error-message.test.ts +0 -18
  836. package/src/format-tables.test.ts +0 -988
  837. package/src/format-tables.ts +0 -1031
  838. package/src/forum-sync/config.ts +0 -92
  839. package/src/forum-sync/discord-operations.ts +0 -245
  840. package/src/forum-sync/index.ts +0 -9
  841. package/src/forum-sync/markdown.ts +0 -172
  842. package/src/forum-sync/sync-to-discord.ts +0 -595
  843. package/src/forum-sync/sync-to-files.ts +0 -294
  844. package/src/forum-sync/types.ts +0 -175
  845. package/src/forum-sync/watchers.ts +0 -474
  846. package/src/gateway-proxy-reconnect.e2e.test.ts +0 -553
  847. package/src/gateway-proxy.e2e.test.ts +0 -648
  848. package/src/genai-worker-wrapper.ts +0 -164
  849. package/src/genai-worker.ts +0 -385
  850. package/src/genai.ts +0 -318
  851. package/src/git-worktree-core.ts +0 -616
  852. package/src/guild-categories.test.ts +0 -260
  853. package/src/heap-monitor.ts +0 -152
  854. package/src/hrana-server.test.ts +0 -130
  855. package/src/hrana-server.ts +0 -399
  856. package/src/html-actions.test.ts +0 -87
  857. package/src/html-actions.ts +0 -174
  858. package/src/html-components.test.ts +0 -38
  859. package/src/html-components.ts +0 -177
  860. package/src/image-optimizer-plugin.ts +0 -194
  861. package/src/image-utils.ts +0 -150
  862. package/src/interaction-handler.ts +0 -775
  863. package/src/ipc-polling.ts +0 -325
  864. package/src/ipc-tools-plugin.ts +0 -306
  865. package/src/kimaki-digital-twin.e2e.test.ts +0 -199
  866. package/src/kimaki-opencode-plugin-loading.e2e.test.ts +0 -208
  867. package/src/kimaki-opencode-plugin.test.ts +0 -142
  868. package/src/kimaki-opencode-plugin.ts +0 -34
  869. package/src/kimaki-workspace-adaptor.ts +0 -144
  870. package/src/limit-heading-depth.test.ts +0 -116
  871. package/src/limit-heading-depth.ts +0 -26
  872. package/src/list-channel-threads.test.ts +0 -90
  873. package/src/list-channel-threads.ts +0 -252
  874. package/src/markdown.test.ts +0 -498
  875. package/src/markdown.ts +0 -577
  876. package/src/memory-overview-plugin.ts +0 -159
  877. package/src/message-formatting.test.ts +0 -1401
  878. package/src/message-formatting.ts +0 -972
  879. package/src/message-preprocessing.ts +0 -579
  880. package/src/oauth-rotation-shared.ts +0 -332
  881. package/src/onboarding-tutorial.ts +0 -167
  882. package/src/onboarding-welcome.ts +0 -49
  883. package/src/openai-auth-plugin.ts +0 -158
  884. package/src/openai-auth-state.ts +0 -297
  885. package/src/openai-realtime.ts +0 -358
  886. package/src/opencode-command-detection.test.ts +0 -307
  887. package/src/opencode-command-detection.ts +0 -76
  888. package/src/opencode-command.test.ts +0 -290
  889. package/src/opencode-command.ts +0 -251
  890. package/src/opencode-interrupt-plugin.test.ts +0 -419
  891. package/src/opencode-interrupt-plugin.ts +0 -306
  892. package/src/opencode.ts +0 -1590
  893. package/src/parse-permission-rules.test.ts +0 -127
  894. package/src/patch-text-parser.ts +0 -107
  895. package/src/plugin-logger.ts +0 -139
  896. package/src/plugin-opencode-client.ts +0 -71
  897. package/src/privacy-sanitizer.ts +0 -142
  898. package/src/project-add.test.ts +0 -80
  899. package/src/question-abort-clears-dropdown.e2e.test.ts +0 -109
  900. package/src/question-abort-resume.e2e.test.ts +0 -121
  901. package/src/question-abort-retry-text-before-dropdown.e2e.test.ts +0 -172
  902. package/src/question-text-before-dropdown.e2e.test.ts +0 -67
  903. package/src/queue-advanced-abort.e2e.test.ts +0 -449
  904. package/src/queue-advanced-action-buttons.e2e.test.ts +0 -271
  905. package/src/queue-advanced-e2e-setup.ts +0 -1164
  906. package/src/queue-advanced-footer.e2e.test.ts +0 -357
  907. package/src/queue-advanced-model-switch.e2e.test.ts +0 -382
  908. package/src/queue-advanced-permissions-typing.e2e.test.ts +0 -256
  909. package/src/queue-advanced-question.e2e.test.ts +0 -322
  910. package/src/queue-advanced-typing-interrupt.e2e.test.ts +0 -147
  911. package/src/queue-advanced-typing.e2e.test.ts +0 -199
  912. package/src/queue-delete-message.e2e.test.ts +0 -102
  913. package/src/queue-drain-after-interactive-ui.e2e.test.ts +0 -152
  914. package/src/queue-interrupt-drain.e2e.test.ts +0 -288
  915. package/src/queue-question-select-drain.e2e.test.ts +0 -206
  916. package/src/runtime-idle-sweeper.ts +0 -76
  917. package/src/runtime-lifecycle.e2e.test.ts +0 -714
  918. package/src/schema.sql +0 -251
  919. package/src/sentry.ts +0 -26
  920. package/src/session-handler/agent-utils.ts +0 -99
  921. package/src/session-handler/event-stream-fixtures/real-session-action-buttons.jsonl +0 -45
  922. package/src/session-handler/event-stream-fixtures/real-session-footer-suppressed-on-pre-idle-interrupt.jsonl +0 -40
  923. package/src/session-handler/event-stream-fixtures/real-session-permission-external-file.jsonl +0 -23
  924. package/src/session-handler/event-stream-fixtures/real-session-task-normal.jsonl +0 -22
  925. package/src/session-handler/event-stream-fixtures/real-session-task-three-parallel-sleeps.jsonl +0 -277
  926. package/src/session-handler/event-stream-fixtures/real-session-task-user-interruption.jsonl +0 -46
  927. package/src/session-handler/event-stream-fixtures/session-abort-after-idle-race.jsonl +0 -21
  928. package/src/session-handler/event-stream-fixtures/session-concurrent-messages-serialized.jsonl +0 -56
  929. package/src/session-handler/event-stream-fixtures/session-explicit-abort.jsonl +0 -44
  930. package/src/session-handler/event-stream-fixtures/session-normal-completion.jsonl +0 -29
  931. package/src/session-handler/event-stream-fixtures/session-tool-call-noisy-stream.jsonl +0 -29
  932. package/src/session-handler/event-stream-fixtures/session-two-completions-same-session.jsonl +0 -50
  933. package/src/session-handler/event-stream-fixtures/session-user-interruption.jsonl +0 -59
  934. package/src/session-handler/event-stream-fixtures/session-voice-queued-followup.jsonl +0 -52
  935. package/src/session-handler/event-stream-state.test.ts +0 -3304
  936. package/src/session-handler/event-stream-state.ts +0 -1773
  937. package/src/session-handler/global-event-listener.ts +0 -258
  938. package/src/session-handler/model-utils.test.ts +0 -537
  939. package/src/session-handler/model-utils.ts +0 -489
  940. package/src/session-handler/opencode-session-event-log.ts +0 -159
  941. package/src/session-handler/thread-ingress.test.ts +0 -54
  942. package/src/session-handler/thread-runtime-state.ts +0 -351
  943. package/src/session-handler/thread-session-runtime-summary.test.ts +0 -169
  944. package/src/session-handler/thread-session-runtime.ts +0 -5608
  945. package/src/session-handler.ts +0 -15
  946. package/src/session-search.test.ts +0 -331
  947. package/src/session-search.ts +0 -382
  948. package/src/session-sleep.test.ts +0 -294
  949. package/src/session-title-rename.test.ts +0 -186
  950. package/src/skill-filter.test.ts +0 -110
  951. package/src/skill-filter.ts +0 -63
  952. package/src/startup-service.ts +0 -200
  953. package/src/startup-time.e2e.test.ts +0 -377
  954. package/src/system-message.test.ts +0 -1176
  955. package/src/system-message.ts +0 -1179
  956. package/src/task-id-plugin.ts +0 -17
  957. package/src/task-runner.ts +0 -768
  958. package/src/task-schedule.test.ts +0 -424
  959. package/src/task-schedule.ts +0 -470
  960. package/src/test-utils.ts +0 -506
  961. package/src/thinking-utils.test.ts +0 -46
  962. package/src/thinking-utils.ts +0 -82
  963. package/src/thread-message-queue.e2e.test.ts +0 -1395
  964. package/src/tools.ts +0 -430
  965. package/src/undici.d.ts +0 -12
  966. package/src/undo-redo.e2e.test.ts +0 -219
  967. package/src/unnest-code-blocks.test.ts +0 -713
  968. package/src/unnest-code-blocks.ts +0 -185
  969. package/src/upgrade.ts +0 -127
  970. package/src/utils.ts +0 -216
  971. package/src/voice-attachment.ts +0 -79
  972. package/src/voice-handler.ts +0 -999
  973. package/src/voice-message.e2e.test.ts +0 -1524
  974. package/src/voice-routing-input.e2e.test.ts +0 -203
  975. package/src/voice-routing-question.e2e.test.ts +0 -131
  976. package/src/voice.test.ts +0 -415
  977. package/src/wait-session.ts +0 -291
  978. package/src/websockify.ts +0 -101
  979. package/src/worker-types.ts +0 -64
  980. package/src/worktree-clone-isolation.e2e.test.ts +0 -213
  981. package/src/worktree-lifecycle.e2e.test.ts +0 -900
  982. package/src/worktree-utils.ts +0 -4
  983. package/src/xai-auth-plugin.ts +0 -303
  984. package/src/xai-auth-state.test.ts +0 -224
  985. package/src/xai-auth-state.ts +0 -294
  986. package/src/xml.test.ts +0 -38
  987. package/src/xml.ts +0 -121
@@ -1,735 +0,0 @@
1
- // E2e test for worktree lifecycle: /new-worktree inside an existing thread
2
- // creates a separate worktree thread that reuses session context. Each thread
3
- // stays bound to one directory for its whole lifetime.
4
- //
5
- // Uses opencode-deterministic-provider (no real LLM calls).
6
- // Poll timeouts: 4s max, 100ms interval (except worktree creation which
7
- // involves real git operations — 10s timeout there).
8
- import fs from 'node:fs';
9
- import path from 'node:path';
10
- import url from 'node:url';
11
- import { describe, beforeAll, afterAll, test, expect } from 'vitest';
12
- import { ChannelType, Client, GatewayIntentBits, Partials, Routes } from 'discord.js';
13
- import YAML from 'yaml';
14
- import { DigitalDiscord } from 'discord-digital-twin/src';
15
- import { buildDeterministicOpencodeConfig, } from 'opencode-deterministic-provider';
16
- import { setDataDir } from './config.js';
17
- import { store } from './store.js';
18
- import { startDiscordBot } from './discord-bot.js';
19
- import { getRuntime } from './session-handler/thread-session-runtime.js';
20
- import { setBotToken, initDatabase, closeDatabase, setChannelDirectory, setChannelVerbosity, setChannelWorktreesEnabled, getThreadSession, getThreadWorktreeOrWorkspace, getSessionModel, setSessionModel, } from './database.js';
21
- import { startHranaServer, stopHranaServer } from './hrana-server.js';
22
- import { initializeOpencodeForDirectory, stopOpencodeServer, } from './opencode.js';
23
- import { chooseLockPort, cleanupTestSessions, waitForBotMessageContaining, } from './test-utils.js';
24
- import { execAsync } from './worktrees.js';
25
- const TEST_USER_ID = '200000000000000901';
26
- const TEXT_CHANNEL_ID = '200000000000000902';
27
- const NON_GIT_CHANNEL_ID = '200000000000000903';
28
- const AUTO_WORKTREE_CHANNEL_ID = '200000000000000904';
29
- // Unique worktree name per run to avoid collisions with leftover worktrees
30
- const WORKTREE_SUFFIX = Date.now().toString(36).slice(-6);
31
- const WORKTREE_NAME = `wt-e2e-${WORKTREE_SUFFIX}`;
32
- const CHANNEL_WORKTREE_NAME = `wt-chan-${WORKTREE_SUFFIX}`;
33
- const AUTO_WORKTREE_SUFFIX = `wt-auto-${WORKTREE_SUFFIX}`;
34
- const SOURCE_MODEL = 'source-model-v2';
35
- function normalizeWorktreeLifecycleText(text) {
36
- return text
37
- .replaceAll(CHANNEL_WORKTREE_NAME, 'CHANNEL_WORKTREE_NAME')
38
- .replaceAll(AUTO_WORKTREE_SUFFIX, 'AUTO_WORKTREE_NAME')
39
- .replaceAll(WORKTREE_NAME, 'WORKTREE_NAME')
40
- .replace(/opencode\/kimaki-rply-wth-exctly-snd-at-wt-[a-z0-9]+/g, 'AUTO_WORKTREE_BRANCH')
41
- .replaceAll(WORKTREE_SUFFIX, 'SUFFIX')
42
- .replace(/ses_[a-zA-Z0-9]+/g, 'ses_TEST')
43
- .replace(/<#\d+>/g, '<#THREAD_ID>')
44
- .replace(/`[^`\n]*\/worktrees\/[^`\n]*`/g, '`/tmp/worktrees/WORKTREE_NAME`');
45
- }
46
- function createRunDirectories() {
47
- const root = path.resolve(process.cwd(), 'tmp', 'worktree-lifecycle-e2e');
48
- fs.mkdirSync(root, { recursive: true });
49
- const dataDir = fs.mkdtempSync(path.join(root, 'data-'));
50
- const projectDirectory = path.join(root, 'project');
51
- const nonGitDirectory = path.join(root, 'non-git-project');
52
- fs.mkdirSync(projectDirectory, { recursive: true });
53
- fs.mkdirSync(nonGitDirectory, { recursive: true });
54
- return { root, dataDir, projectDirectory, nonGitDirectory };
55
- }
56
- function createDiscordJsClient({ restUrl }) {
57
- return new Client({
58
- intents: [
59
- GatewayIntentBits.Guilds,
60
- GatewayIntentBits.GuildMessages,
61
- GatewayIntentBits.MessageContent,
62
- GatewayIntentBits.GuildVoiceStates,
63
- ],
64
- partials: [
65
- Partials.Channel,
66
- Partials.Message,
67
- Partials.User,
68
- Partials.ThreadMember,
69
- ],
70
- rest: {
71
- api: restUrl,
72
- version: '10',
73
- },
74
- });
75
- }
76
- /** Initialize a git repo with an initial commit so worktrees can be created. */
77
- async function initGitRepo(directory) {
78
- // Check if already a git repo (directory may persist across runs)
79
- const isRepo = fs.existsSync(path.join(directory, '.git'));
80
- if (isRepo) {
81
- // Commit any new/changed files (opencode.json may have been rewritten)
82
- await execAsync('git add -A && git diff --cached --quiet || git commit -m "update"', {
83
- cwd: directory,
84
- }).catch(() => { return; });
85
- return;
86
- }
87
- await execAsync('git init -b main', { cwd: directory });
88
- await execAsync('git config user.email "test@test.com"', { cwd: directory });
89
- await execAsync('git config user.name "Test"', { cwd: directory });
90
- await execAsync('git add -A && git commit -m "initial"', { cwd: directory });
91
- }
92
- function createDeterministicMatchers() {
93
- const userReplyMatcher = {
94
- id: 'user-reply',
95
- priority: 10,
96
- when: {
97
- lastMessageRole: 'user',
98
- latestUserTextIncludes: 'Reply with exactly:',
99
- },
100
- then: {
101
- parts: [
102
- { type: 'stream-start', warnings: [] },
103
- { type: 'text-start', id: 'default-reply' },
104
- { type: 'text-delta', id: 'default-reply', delta: 'ok' },
105
- { type: 'text-end', id: 'default-reply' },
106
- {
107
- type: 'finish',
108
- finishReason: 'stop',
109
- usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
110
- },
111
- ],
112
- partDelaysMs: [0, 100, 0, 0, 0],
113
- },
114
- };
115
- return [userReplyMatcher];
116
- }
117
- describe('worktree lifecycle', () => {
118
- let directories;
119
- let discord;
120
- let botClient;
121
- let previousDefaultVerbosity = null;
122
- let testStartTime = Date.now();
123
- beforeAll(async () => {
124
- testStartTime = Date.now();
125
- directories = createRunDirectories();
126
- const lockPort = chooseLockPort({ key: TEXT_CHANNEL_ID });
127
- process.env['KIMAKI_LOCK_PORT'] = String(lockPort);
128
- setDataDir(directories.dataDir);
129
- previousDefaultVerbosity = store.getState().defaultVerbosity;
130
- store.setState({ defaultVerbosity: 'tools_and_text' });
131
- const digitalDiscordDbPath = path.join(directories.dataDir, 'digital-discord.db');
132
- discord = new DigitalDiscord({
133
- guild: {
134
- name: 'Worktree E2E Guild',
135
- ownerId: TEST_USER_ID,
136
- },
137
- channels: [
138
- {
139
- id: TEXT_CHANNEL_ID,
140
- name: 'worktree-e2e',
141
- type: ChannelType.GuildText,
142
- },
143
- {
144
- id: NON_GIT_CHANNEL_ID,
145
- name: 'non-git-worktree-e2e',
146
- type: ChannelType.GuildText,
147
- },
148
- {
149
- id: AUTO_WORKTREE_CHANNEL_ID,
150
- name: 'auto-worktree-e2e',
151
- type: ChannelType.GuildText,
152
- },
153
- ],
154
- users: [
155
- {
156
- id: TEST_USER_ID,
157
- username: 'worktree-tester',
158
- },
159
- ],
160
- dbUrl: `file:${digitalDiscordDbPath}`,
161
- });
162
- await discord.start();
163
- const providerNpm = url
164
- .pathToFileURL(path.resolve(process.cwd(), '..', 'opencode-deterministic-provider', 'src', 'index.ts'))
165
- .toString();
166
- const opencodeConfig = buildDeterministicOpencodeConfig({
167
- providerName: 'deterministic-provider',
168
- providerNpm,
169
- model: 'deterministic-v2',
170
- smallModel: 'deterministic-v2',
171
- settings: {
172
- strict: false,
173
- matchers: createDeterministicMatchers(),
174
- },
175
- });
176
- const providerConfig = opencodeConfig.provider['deterministic-provider'];
177
- if (!providerConfig)
178
- throw new Error('Missing deterministic provider config');
179
- providerConfig.models[SOURCE_MODEL] = { name: SOURCE_MODEL };
180
- fs.writeFileSync(path.join(directories.projectDirectory, 'opencode.json'), JSON.stringify(opencodeConfig, null, 2));
181
- fs.writeFileSync(path.join(directories.nonGitDirectory, 'opencode.json'), JSON.stringify(opencodeConfig, null, 2));
182
- // Initialize git repo after writing opencode.json so the initial commit
183
- // includes it. Worktrees require at least one commit.
184
- await initGitRepo(directories.projectDirectory);
185
- const dbPath = path.join(directories.dataDir, 'discord-sessions.db');
186
- const hranaResult = await startHranaServer({ dbPath });
187
- if (hranaResult instanceof Error) {
188
- throw hranaResult;
189
- }
190
- process.env['KIMAKI_DB_URL'] = hranaResult;
191
- await initDatabase();
192
- await setBotToken(discord.botUserId, discord.botToken);
193
- await setChannelDirectory({
194
- channelId: TEXT_CHANNEL_ID,
195
- directory: directories.projectDirectory,
196
- channelType: 'text',
197
- });
198
- await setChannelDirectory({
199
- channelId: NON_GIT_CHANNEL_ID,
200
- directory: directories.nonGitDirectory,
201
- channelType: 'text',
202
- });
203
- await setChannelDirectory({
204
- channelId: AUTO_WORKTREE_CHANNEL_ID,
205
- directory: directories.projectDirectory,
206
- channelType: 'text',
207
- });
208
- await setChannelVerbosity(TEXT_CHANNEL_ID, 'tools_and_text');
209
- await setChannelVerbosity(NON_GIT_CHANNEL_ID, 'tools_and_text');
210
- await setChannelVerbosity(AUTO_WORKTREE_CHANNEL_ID, 'tools_and_text');
211
- await setChannelWorktreesEnabled(NON_GIT_CHANNEL_ID, true);
212
- await setChannelWorktreesEnabled(AUTO_WORKTREE_CHANNEL_ID, true);
213
- botClient = createDiscordJsClient({ restUrl: discord.restUrl });
214
- await startDiscordBot({
215
- token: discord.botToken,
216
- appId: discord.botUserId,
217
- discordClient: botClient,
218
- });
219
- // Pre-warm the opencode server
220
- const warmup = await initializeOpencodeForDirectory(directories.projectDirectory);
221
- if (warmup instanceof Error) {
222
- throw warmup;
223
- }
224
- }, 20_000);
225
- afterAll(async () => {
226
- if (directories) {
227
- await cleanupTestSessions({
228
- projectDirectory: directories.projectDirectory,
229
- testStartTime,
230
- });
231
- }
232
- if (botClient) {
233
- void botClient.destroy();
234
- }
235
- await stopOpencodeServer();
236
- await Promise.all([
237
- closeDatabase().catch(() => { return; }),
238
- stopHranaServer().catch(() => { return; }),
239
- discord?.stop().catch(() => { return; }),
240
- ]);
241
- delete process.env['KIMAKI_LOCK_PORT'];
242
- delete process.env['KIMAKI_DB_URL'];
243
- if (previousDefaultVerbosity) {
244
- store.setState({ defaultVerbosity: previousDefaultVerbosity });
245
- }
246
- // Clean up the git worktrees created during the tests
247
- if (directories) {
248
- const branchesToClean = [
249
- `opencode/kimaki-${WORKTREE_NAME}`,
250
- `opencode/kimaki-${CHANNEL_WORKTREE_NAME}`,
251
- ];
252
- await execAsync(`git worktree list --porcelain`, { cwd: directories.projectDirectory }).then(async ({ stdout }) => {
253
- const lines = stdout.split('\n');
254
- let currentPath = '';
255
- for (const line of lines) {
256
- if (line.startsWith('worktree ')) {
257
- currentPath = line.slice('worktree '.length);
258
- }
259
- if (line.startsWith('branch ') && currentPath) {
260
- for (const branch of branchesToClean) {
261
- if (line.includes(branch)) {
262
- await execAsync(`git worktree remove --force ${JSON.stringify(currentPath)}`, { cwd: directories.projectDirectory }).catch(() => { return; });
263
- }
264
- }
265
- }
266
- }
267
- }).catch(() => { return; });
268
- // Also clean up auto-worktree branches (pattern: opencode/kimaki-<suffix>)
269
- await execAsync('git worktree prune', { cwd: directories.projectDirectory }).catch(() => { return; });
270
- for (const branch of branchesToClean) {
271
- await execAsync(`git branch -D ${JSON.stringify(branch)}`, { cwd: directories.projectDirectory }).catch(() => { return; });
272
- }
273
- // Clean auto-worktree branches (auto-derived names contain the suffix)
274
- await execAsync(`git branch --list 'opencode/kimaki-*${WORKTREE_SUFFIX}*'`, { cwd: directories.projectDirectory }).then(async ({ stdout }) => {
275
- for (const branch of stdout.trim().split('\n').filter(Boolean)) {
276
- await execAsync(`git branch -D ${JSON.stringify(branch.trim())}`, { cwd: directories.projectDirectory }).catch(() => { return; });
277
- }
278
- }).catch(() => { return; });
279
- fs.rmSync(directories.dataDir, {
280
- recursive: true,
281
- force: true,
282
- maxRetries: 3,
283
- });
284
- }
285
- }, 5_000);
286
- test('/new-worktree in a session thread forks into a new worktree thread', async () => {
287
- // 1. Send a message to create a thread and establish a session
288
- await discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
289
- content: 'Reply with exactly: before-worktree',
290
- });
291
- const thread = await discord.channel(TEXT_CHANNEL_ID).waitForThread({
292
- timeout: 4_000,
293
- predicate: (t) => {
294
- return t.name === 'Reply with exactly: before-worktree';
295
- },
296
- });
297
- const th = discord.thread(thread.id);
298
- // Wait for the first run to produce visible assistant output before
299
- // running /new-worktree in the same thread.
300
- await waitForBotMessageContaining({
301
- discord,
302
- threadId: thread.id,
303
- userId: TEST_USER_ID,
304
- text: 'ok',
305
- afterUserMessageIncludes: 'before-worktree',
306
- timeout: 10_000,
307
- });
308
- // Capture source runtime — it should stay bound to the base checkout.
309
- const runtimeBefore = getRuntime(thread.id);
310
- expect(runtimeBefore).toBeDefined();
311
- expect(runtimeBefore.sdkDirectory).toBe(directories.projectDirectory);
312
- const sessionBefore = await getThreadSession(thread.id);
313
- expect(sessionBefore).toBeTruthy();
314
- if (!sessionBefore)
315
- throw new Error('Source session was not persisted');
316
- await setSessionModel({
317
- sessionId: sessionBefore,
318
- modelId: `deterministic-provider/${SOURCE_MODEL}`,
319
- });
320
- // 2. Run /new-worktree inside the source thread.
321
- // This should create a new worktree thread instead of switching this one.
322
- const { id: interactionId } = await th
323
- .user(TEST_USER_ID)
324
- .runSlashCommand({
325
- name: 'new-worktree',
326
- options: [{ name: 'name', type: 3, value: WORKTREE_NAME }],
327
- });
328
- // Wait for the slash command ack
329
- await discord
330
- .channel(thread.id)
331
- .waitForInteractionAck({ interactionId, timeout: 4_000 });
332
- const worktreeThread = await discord.channel(TEXT_CHANNEL_ID).waitForThread({
333
- timeout: 4_000,
334
- predicate: (t) => {
335
- if (!t.name) {
336
- return false;
337
- }
338
- return t.id !== thread.id
339
- && t.name.startsWith('⬦ worktree: opencode/kimaki-')
340
- && t.name.includes(WORKTREE_NAME);
341
- },
342
- });
343
- const worktreeTh = discord.thread(worktreeThread.id);
344
- // 3. Wait for worktree to become ready in the new thread — the
345
- // background creation edits the starter message to include the branch.
346
- // Git worktree creation involves real git operations, so allow more time.
347
- await waitForBotMessageContaining({
348
- discord,
349
- threadId: worktreeThread.id,
350
- userId: TEST_USER_ID,
351
- text: 'Branch:',
352
- timeout: 10_000,
353
- });
354
- // Messages sent as soon as the checkout is ready must wait for the
355
- // source session fork and keep its model.
356
- await worktreeTh.user(TEST_USER_ID).sendMessage({
357
- content: 'Reply with exactly: after-worktree-thread',
358
- });
359
- await waitForBotMessageContaining({
360
- discord,
361
- threadId: worktreeThread.id,
362
- userId: TEST_USER_ID,
363
- text: 'Reusing context from',
364
- timeout: 10_000,
365
- });
366
- const sourceSessionAfterFork = await getThreadSession(thread.id);
367
- expect(sourceSessionAfterFork).toBe(sessionBefore);
368
- const worktreeSession = await getThreadSession(worktreeThread.id);
369
- expect(worktreeSession).toBeTruthy();
370
- if (!worktreeSession)
371
- throw new Error('Worktree session was not persisted');
372
- expect(worktreeSession).not.toBe(sessionBefore);
373
- await expect(getSessionModel(worktreeSession)).resolves.toMatchInlineSnapshot(`
374
- {
375
- "modelId": "deterministic-provider/source-model-v2",
376
- "variant": null,
377
- }
378
- `);
379
- await expect(getThreadWorktreeOrWorkspace(thread.id)).resolves.toBeUndefined();
380
- const worktreeInfo = await getThreadWorktreeOrWorkspace(worktreeThread.id);
381
- expect(worktreeInfo?.status).toBe('ready');
382
- expect(worktreeInfo?.workspace_directory).toContain(WORKTREE_NAME);
383
- const worktreeDirectory = worktreeInfo?.workspace_directory;
384
- if (!worktreeDirectory)
385
- throw new Error('Worktree directory was not persisted');
386
- const getWorktreeClient = await initializeOpencodeForDirectory(worktreeDirectory);
387
- if (getWorktreeClient instanceof Error)
388
- throw getWorktreeClient;
389
- const worktreeSessionResponse = await getWorktreeClient().session.get({
390
- sessionID: worktreeSession,
391
- directory: worktreeDirectory,
392
- });
393
- expect(worktreeSessionResponse.data?.directory).toBe(worktreeDirectory);
394
- const runtimeAfter = getRuntime(thread.id);
395
- expect(runtimeAfter).toBe(runtimeBefore);
396
- expect(runtimeAfter.sdkDirectory).toBe(directories.projectDirectory);
397
- const worktreeRuntime = getRuntime(worktreeThread.id);
398
- expect(worktreeRuntime).toBeDefined();
399
- expect(worktreeRuntime.sdkDirectory).toContain(WORKTREE_NAME);
400
- expect(worktreeRuntime.sdkDirectory).toContain(`${path.sep}worktrees${path.sep}`);
401
- // 4. Send messages to both threads. The source continues in the base
402
- // checkout, and the new thread runs in the worktree checkout.
403
- await th.user(TEST_USER_ID).sendMessage({
404
- content: 'Reply with exactly: after-source-thread',
405
- });
406
- await waitForBotMessageContaining({
407
- discord,
408
- threadId: worktreeThread.id,
409
- userId: TEST_USER_ID,
410
- text: 'ok',
411
- afterUserMessageIncludes: 'after-worktree-thread',
412
- timeout: 4_000,
413
- });
414
- await waitForBotMessageContaining({
415
- discord,
416
- threadId: thread.id,
417
- userId: TEST_USER_ID,
418
- text: 'ok',
419
- afterUserMessageIncludes: 'after-source-thread',
420
- timeout: 4_000,
421
- });
422
- // Wait for footers to confirm full completion in both threads.
423
- await waitForBotMessageContaining({
424
- discord,
425
- threadId: worktreeThread.id,
426
- userId: TEST_USER_ID,
427
- text: SOURCE_MODEL,
428
- afterUserMessageIncludes: 'after-worktree-thread',
429
- timeout: 4_000,
430
- });
431
- await waitForBotMessageContaining({
432
- discord,
433
- threadId: thread.id,
434
- userId: TEST_USER_ID,
435
- text: SOURCE_MODEL,
436
- afterUserMessageIncludes: 'after-source-thread',
437
- timeout: 4_000,
438
- });
439
- const sourceText = await th.text();
440
- expect(normalizeWorktreeLifecycleText(sourceText)).toMatchInlineSnapshot(`
441
- "--- from: user (worktree-tester)
442
- Reply with exactly: before-worktree
443
- --- from: assistant (TestBot)
444
- -# *using deterministic-provider/deterministic-v2*
445
- > ok
446
- Creating worktree in <#THREAD_ID>
447
- -# *project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
448
- --- from: user (worktree-tester)
449
- Reply with exactly: after-source-thread
450
- --- from: assistant (TestBot)
451
- > ok
452
- -# *project ⋅ main ⋅ Ns ⋅ N% ⋅ source-model-v2*"
453
- `);
454
- expect(sourceText).toContain('Reply with exactly: before-worktree');
455
- expect(sourceText).toContain('Reply with exactly: after-source-thread');
456
- expect(sourceText).not.toContain('Worktree:');
457
- expect((sourceText.match(/ok/g) || []).length).toBe(2);
458
- const worktreeText = await worktreeTh.text();
459
- expect(normalizeWorktreeLifecycleText(worktreeText)).toMatchInlineSnapshot(`
460
- "--- from: assistant (TestBot)
461
- 🌳 **Worktree: opencode/kimaki-WORKTREE_NAME**
462
- 📁 \`/tmp/worktrees/WORKTREE_NAME\`
463
- 🌿 Branch: \`opencode/kimaki-WORKTREE_NAME\`
464
- Reusing context from <#THREAD_ID> in worktree session \`ses_TEST\`.
465
- --- from: user (worktree-tester)
466
- Reply with exactly: after-worktree-thread
467
- --- from: assistant (TestBot)
468
- > ok
469
- -# *WORKTREE_NAME ⋅ opencode/kimaki-WORKTREE_NAME ⋅ Ns ⋅ N% ⋅ source-model-v2*"
470
- `);
471
- expect(worktreeText).toContain('Worktree:');
472
- expect(worktreeText).toContain('Branch:');
473
- expect(worktreeText).toContain('Reusing context from');
474
- expect(worktreeText).toContain('Reply with exactly: after-worktree-thread');
475
- expect(worktreeText).toContain('ok');
476
- }, 30_000);
477
- test('/new-worktree from a text channel creates a worktree thread that responds to messages', async () => {
478
- // 1. Run /new-worktree from the text channel (not inside a thread)
479
- const { id: interactionId } = await discord
480
- .channel(TEXT_CHANNEL_ID)
481
- .user(TEST_USER_ID)
482
- .runSlashCommand({
483
- name: 'new-worktree',
484
- options: [{ name: 'name', type: 3, value: CHANNEL_WORKTREE_NAME }],
485
- });
486
- await discord
487
- .channel(TEXT_CHANNEL_ID)
488
- .waitForInteractionAck({ interactionId, timeout: 4_000 });
489
- // 2. Wait for the worktree thread to appear in the channel
490
- const worktreeThread = await discord.channel(TEXT_CHANNEL_ID).waitForThread({
491
- timeout: 4_000,
492
- predicate: (t) => {
493
- return Boolean(t.name
494
- && t.name.startsWith('⬦ worktree: opencode/kimaki-')
495
- && t.name.includes(CHANNEL_WORKTREE_NAME));
496
- },
497
- });
498
- const wt = discord.thread(worktreeThread.id);
499
- // 3. Wait for worktree to become ready (status message shows Branch:)
500
- await waitForBotMessageContaining({
501
- discord,
502
- threadId: worktreeThread.id,
503
- userId: TEST_USER_ID,
504
- text: 'Branch:',
505
- timeout: 10_000,
506
- });
507
- // 4. Verify the DB has the worktree info
508
- const worktreeInfo = await getThreadWorktreeOrWorkspace(worktreeThread.id);
509
- expect(worktreeInfo?.status).toBe('ready');
510
- expect(worktreeInfo?.workspace_directory).toContain(CHANNEL_WORKTREE_NAME);
511
- // 5. Send a message in the worktree thread and verify it responds
512
- await wt.user(TEST_USER_ID).sendMessage({
513
- content: 'Reply with exactly: channel-worktree-msg',
514
- });
515
- await waitForBotMessageContaining({
516
- discord,
517
- threadId: worktreeThread.id,
518
- userId: TEST_USER_ID,
519
- text: 'ok',
520
- afterUserMessageIncludes: 'channel-worktree-msg',
521
- timeout: 10_000,
522
- });
523
- // Wait for footer to confirm session completion
524
- await waitForBotMessageContaining({
525
- discord,
526
- threadId: worktreeThread.id,
527
- userId: TEST_USER_ID,
528
- text: 'deterministic-v2',
529
- afterUserMessageIncludes: 'channel-worktree-msg',
530
- timeout: 4_000,
531
- });
532
- // 6. Verify the runtime is using the worktree directory
533
- const runtime = getRuntime(worktreeThread.id);
534
- expect(runtime).toBeDefined();
535
- expect(runtime.sdkDirectory).toContain(CHANNEL_WORKTREE_NAME);
536
- expect(runtime.sdkDirectory).toContain(`${path.sep}worktrees${path.sep}`);
537
- // 7. Snapshot the thread content
538
- const worktreeText = await wt.text();
539
- expect(normalizeWorktreeLifecycleText(worktreeText)).toMatchInlineSnapshot(`
540
- "--- from: assistant (TestBot)
541
- 🌳 **Worktree: opencode/kimaki-CHANNEL_WORKTREE_NAME**
542
- 📁 \`/tmp/worktrees/WORKTREE_NAME\`
543
- 🌿 Branch: \`opencode/kimaki-CHANNEL_WORKTREE_NAME\`
544
- --- from: user (worktree-tester)
545
- Reply with exactly: channel-worktree-msg
546
- --- from: assistant (TestBot)
547
- -# *using deterministic-provider/deterministic-v2*
548
- > ok"
549
- `);
550
- expect(worktreeText).toContain('Branch:');
551
- expect(worktreeText).toContain('ok');
552
- expect(worktreeText).toContain('Reply with exactly: channel-worktree-msg');
553
- }, 30_000);
554
- test('auto-worktree from user message creates worktree thread and responds', async () => {
555
- // Channel AUTO_WORKTREE_CHANNEL_ID has worktrees enabled via toggle.
556
- // Sending a message should auto-create a worktree thread.
557
- // Include WORKTREE_SUFFIX in the message so the auto-derived branch name
558
- // is unique per run and doesn't collide with leftover branches.
559
- const autoMsg = `Reply with exactly: ${AUTO_WORKTREE_SUFFIX}`;
560
- await discord.channel(AUTO_WORKTREE_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
561
- content: autoMsg,
562
- });
563
- // The thread should have the ⬦ prefix indicating a worktree thread
564
- const thread = await discord.channel(AUTO_WORKTREE_CHANNEL_ID).waitForThread({
565
- timeout: 4_000,
566
- predicate: (t) => {
567
- return Boolean(t.name?.startsWith('⬦ '));
568
- },
569
- });
570
- const th = discord.thread(thread.id);
571
- // Wait for the bot reply to the user message. The auto-worktree
572
- // creation runs in the background and the first message awaits it.
573
- // This is the 3rd worktree in the suite, so git can be slow.
574
- await waitForBotMessageContaining({
575
- discord,
576
- threadId: thread.id,
577
- userId: TEST_USER_ID,
578
- text: 'ok',
579
- afterUserMessageIncludes: AUTO_WORKTREE_SUFFIX,
580
- timeout: 25_000,
581
- });
582
- // Verify runtime is in the worktree directory
583
- const runtime = getRuntime(thread.id);
584
- expect(runtime).toBeDefined();
585
- expect(runtime.sdkDirectory).toContain(`${path.sep}worktrees${path.sep}`);
586
- expect(runtime.sdkDirectory).not.toBe(directories.projectDirectory);
587
- // Verify DB has worktree info
588
- const worktreeInfo = await getThreadWorktreeOrWorkspace(thread.id);
589
- expect(worktreeInfo?.status).toBe('ready');
590
- expect(worktreeInfo?.workspace_directory).toBeTruthy();
591
- // Send a follow-up message to verify session works inside worktree
592
- await th.user(TEST_USER_ID).sendMessage({
593
- content: 'Reply with exactly: auto-followup',
594
- });
595
- await waitForBotMessageContaining({
596
- discord,
597
- threadId: thread.id,
598
- userId: TEST_USER_ID,
599
- text: 'ok',
600
- afterUserMessageIncludes: 'auto-followup',
601
- timeout: 4_000,
602
- });
603
- const text = await th.text();
604
- expect(text).toContain('ok');
605
- expect(text).toContain(AUTO_WORKTREE_SUFFIX);
606
- expect(text).toContain('Reply with exactly: auto-followup');
607
- // Should have at least 2 ok replies
608
- expect((text.match(/ok/g) || []).length).toBeGreaterThanOrEqual(2);
609
- }, 35_000);
610
- test('auto-worktrees fall back to normal sessions outside git repositories', async () => {
611
- await discord.channel(NON_GIT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
612
- content: 'Reply with exactly: non-git-first',
613
- });
614
- const thread = await discord.channel(NON_GIT_CHANNEL_ID).waitForThread({
615
- timeout: 4_000,
616
- predicate: (t) => {
617
- return Boolean(t.name?.includes('Reply with exactly: non-git-first'));
618
- },
619
- });
620
- const th = discord.thread(thread.id);
621
- await waitForBotMessageContaining({
622
- discord,
623
- threadId: thread.id,
624
- userId: TEST_USER_ID,
625
- text: 'ok',
626
- afterUserMessageIncludes: 'non-git-first',
627
- timeout: 4_000,
628
- });
629
- await th.user(TEST_USER_ID).sendMessage({
630
- content: 'Reply with exactly: non-git-second',
631
- });
632
- await waitForBotMessageContaining({
633
- discord,
634
- threadId: thread.id,
635
- userId: TEST_USER_ID,
636
- text: 'ok',
637
- afterUserMessageIncludes: 'non-git-second',
638
- timeout: 4_000,
639
- });
640
- // Wait for footer after second reply to stabilize the snapshot
641
- await waitForBotMessageContaining({
642
- discord,
643
- threadId: thread.id,
644
- userId: TEST_USER_ID,
645
- text: 'deterministic-v2',
646
- afterUserMessageIncludes: 'non-git-second',
647
- timeout: 4_000,
648
- });
649
- const text = await th.text();
650
- expect(text).toMatchInlineSnapshot(`
651
- "--- from: user (worktree-tester)
652
- Reply with exactly: non-git-first
653
- --- from: assistant (TestBot)
654
- -# *using deterministic-provider/deterministic-v2*
655
- > ok
656
- --- from: user (worktree-tester)
657
- Reply with exactly: non-git-second
658
- --- from: assistant (TestBot)
659
- -# *non-git-project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
660
- > ok"
661
- `);
662
- expect(text).toContain('Reply with exactly: non-git-first');
663
- expect(text).toContain('Reply with exactly: non-git-second');
664
- expect(text).not.toContain('Worktree creation failed');
665
- const okCount = (text.match(/ok/g) || []).length;
666
- expect(okCount).toBe(2);
667
- }, 20_000);
668
- test('kimaki send --channel auto-creates worktree when channel toggle is enabled', async () => {
669
- // Simulate `kimaki send --channel AUTO_WORKTREE_CHANNEL_ID --prompt '...'`
670
- // WITHOUT --worktree flag. The bot-side ThreadCreate handler should detect
671
- // the channel toggle and auto-create a worktree.
672
- const prompt = `Reply with exactly: send-auto-wt-${WORKTREE_SUFFIX}`;
673
- const embedMarker = {
674
- start: true,
675
- username: 'worktree-tester',
676
- userId: TEST_USER_ID,
677
- };
678
- // Post starter message (what `kimaki send` does)
679
- const starterMessage = await discord
680
- .channel(AUTO_WORKTREE_CHANNEL_ID)
681
- .bot()
682
- .sendMessage({
683
- content: `» **kimaki-cli:**\n${prompt}`,
684
- embeds: [
685
- { color: 0x2b2d31, footer: { text: YAML.stringify(embedMarker) } },
686
- ],
687
- });
688
- // Create thread on that message (what `kimaki send` does via REST)
689
- const threadData = (await botClient.rest.post(Routes.threads(AUTO_WORKTREE_CHANNEL_ID, starterMessage.id), {
690
- body: {
691
- name: prompt.slice(0, 80),
692
- auto_archive_duration: 1440,
693
- },
694
- }));
695
- // Wait for worktree creation status message (Branch:)
696
- await waitForBotMessageContaining({
697
- discord,
698
- threadId: threadData.id,
699
- userId: TEST_USER_ID,
700
- text: 'Branch:',
701
- timeout: 25_000,
702
- });
703
- // Wait for the bot reply to the prompt. The starter message is from
704
- // the bot (kimaki-cli), not a user, so just wait for the text to appear.
705
- await waitForBotMessageContaining({
706
- discord,
707
- threadId: threadData.id,
708
- userId: discord.botUserId,
709
- text: 'ok',
710
- timeout: 10_000,
711
- });
712
- // Snapshot the thread content
713
- const th = discord.thread(threadData.id);
714
- expect(normalizeWorktreeLifecycleText(await th.text())).toMatchInlineSnapshot(`
715
- "--- from: assistant (TestBot)
716
- » **kimaki-cli:**
717
- Reply with exactly: send-auto-wt-SUFFIX
718
- [embed]
719
- 🌳 **Worktree: AUTO_WORKTREE_BRANCH**
720
- 📁 \`/tmp/worktrees/WORKTREE_NAME\`
721
- 🌿 Branch: \`AUTO_WORKTREE_BRANCH\`
722
- -# *using deterministic-provider/deterministic-v2*
723
- > ok"
724
- `);
725
- // Verify DB has worktree info
726
- const worktreeInfo = await getThreadWorktreeOrWorkspace(threadData.id);
727
- expect(worktreeInfo?.status).toBe('ready');
728
- expect(worktreeInfo?.workspace_directory).toBeTruthy();
729
- // Verify runtime is in the worktree directory
730
- const runtime = getRuntime(threadData.id);
731
- expect(runtime).toBeDefined();
732
- expect(runtime.sdkDirectory).toContain(`${path.sep}worktrees${path.sep}`);
733
- expect(runtime.sdkDirectory).not.toBe(directories.projectDirectory);
734
- }, 35_000);
735
- });