innocode 1.0.0 → 1.0.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +17 -118
  3. package/AGENTS.md +0 -27
  4. package/Dockerfile +0 -18
  5. package/README.md +0 -15
  6. package/bunfig.toml +0 -5
  7. package/parsers-config.ts +0 -253
  8. package/script/build.ts +0 -198
  9. package/script/publish.ts +0 -186
  10. package/script/schema.ts +0 -47
  11. package/script/seed-e2e.ts +0 -50
  12. package/src/acp/README.md +0 -164
  13. package/src/acp/agent.ts +0 -1676
  14. package/src/acp/session.ts +0 -117
  15. package/src/acp/types.ts +0 -23
  16. package/src/agent/agent.ts +0 -338
  17. package/src/agent/generate.txt +0 -75
  18. package/src/agent/prompt/compaction.txt +0 -14
  19. package/src/agent/prompt/explore.txt +0 -18
  20. package/src/agent/prompt/summary.txt +0 -11
  21. package/src/agent/prompt/title.txt +0 -44
  22. package/src/auth/index.ts +0 -70
  23. package/src/bun/index.ts +0 -137
  24. package/src/bun/registry.ts +0 -48
  25. package/src/bus/bus-event.ts +0 -43
  26. package/src/bus/global.ts +0 -10
  27. package/src/bus/index.ts +0 -105
  28. package/src/cli/bootstrap.ts +0 -17
  29. package/src/cli/cmd/acp.ts +0 -70
  30. package/src/cli/cmd/agent.ts +0 -257
  31. package/src/cli/cmd/auth.ts +0 -400
  32. package/src/cli/cmd/cmd.ts +0 -7
  33. package/src/cli/cmd/debug/agent.ts +0 -167
  34. package/src/cli/cmd/debug/config.ts +0 -16
  35. package/src/cli/cmd/debug/file.ts +0 -97
  36. package/src/cli/cmd/debug/index.ts +0 -48
  37. package/src/cli/cmd/debug/lsp.ts +0 -52
  38. package/src/cli/cmd/debug/ripgrep.ts +0 -87
  39. package/src/cli/cmd/debug/scrap.ts +0 -16
  40. package/src/cli/cmd/debug/skill.ts +0 -16
  41. package/src/cli/cmd/debug/snapshot.ts +0 -52
  42. package/src/cli/cmd/export.ts +0 -88
  43. package/src/cli/cmd/generate.ts +0 -38
  44. package/src/cli/cmd/github.ts +0 -1540
  45. package/src/cli/cmd/import.ts +0 -147
  46. package/src/cli/cmd/mcp.ts +0 -765
  47. package/src/cli/cmd/models.ts +0 -77
  48. package/src/cli/cmd/pr.ts +0 -113
  49. package/src/cli/cmd/run.ts +0 -598
  50. package/src/cli/cmd/serve.ts +0 -20
  51. package/src/cli/cmd/session.ts +0 -135
  52. package/src/cli/cmd/stats.ts +0 -426
  53. package/src/cli/cmd/tui/app.tsx +0 -812
  54. package/src/cli/cmd/tui/attach.ts +0 -60
  55. package/src/cli/cmd/tui/component/border.tsx +0 -21
  56. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  57. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -148
  58. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  59. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -165
  60. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -243
  61. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -108
  62. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  63. package/src/cli/cmd/tui/component/dialog-skill.tsx +0 -36
  64. package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
  65. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -167
  66. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  67. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  68. package/src/cli/cmd/tui/component/logo.tsx +0 -85
  69. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -666
  70. package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -89
  71. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
  72. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1153
  73. package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  74. package/src/cli/cmd/tui/component/spinner.tsx +0 -24
  75. package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  76. package/src/cli/cmd/tui/component/tips.tsx +0 -153
  77. package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  78. package/src/cli/cmd/tui/context/args.tsx +0 -15
  79. package/src/cli/cmd/tui/context/directory.ts +0 -13
  80. package/src/cli/cmd/tui/context/exit.tsx +0 -54
  81. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  82. package/src/cli/cmd/tui/context/keybind.tsx +0 -100
  83. package/src/cli/cmd/tui/context/kv.tsx +0 -52
  84. package/src/cli/cmd/tui/context/local.tsx +0 -409
  85. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  86. package/src/cli/cmd/tui/context/route.tsx +0 -46
  87. package/src/cli/cmd/tui/context/sdk.tsx +0 -101
  88. package/src/cli/cmd/tui/context/sync.tsx +0 -470
  89. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  90. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  91. package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
  92. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  93. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  94. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  95. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  96. package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  97. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  98. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  99. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  100. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  101. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
  102. package/src/cli/cmd/tui/context/theme/innocode.json +0 -245
  103. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  104. package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
  105. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  106. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  107. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  108. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  109. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  110. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  111. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  112. package/src/cli/cmd/tui/context/theme/orng.json +0 -249
  113. package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  114. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  115. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  116. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  117. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  118. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  119. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  120. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  121. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  122. package/src/cli/cmd/tui/context/theme.tsx +0 -1154
  123. package/src/cli/cmd/tui/event.ts +0 -48
  124. package/src/cli/cmd/tui/routes/home.tsx +0 -145
  125. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
  126. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
  127. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  128. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  129. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
  130. package/src/cli/cmd/tui/routes/session/header.tsx +0 -135
  131. package/src/cli/cmd/tui/routes/session/index.tsx +0 -2139
  132. package/src/cli/cmd/tui/routes/session/permission.tsx +0 -508
  133. package/src/cli/cmd/tui/routes/session/question.tsx +0 -466
  134. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -313
  135. package/src/cli/cmd/tui/thread.ts +0 -188
  136. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -59
  137. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -85
  138. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -207
  139. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -40
  140. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -80
  141. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -401
  142. package/src/cli/cmd/tui/ui/dialog.tsx +0 -167
  143. package/src/cli/cmd/tui/ui/link.tsx +0 -28
  144. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  145. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  146. package/src/cli/cmd/tui/util/clipboard.ts +0 -159
  147. package/src/cli/cmd/tui/util/editor.ts +0 -32
  148. package/src/cli/cmd/tui/util/signal.ts +0 -7
  149. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  150. package/src/cli/cmd/tui/util/transcript.ts +0 -98
  151. package/src/cli/cmd/tui/win32.ts +0 -129
  152. package/src/cli/cmd/tui/worker.ts +0 -152
  153. package/src/cli/cmd/uninstall.ts +0 -363
  154. package/src/cli/cmd/upgrade.ts +0 -73
  155. package/src/cli/cmd/web.ts +0 -81
  156. package/src/cli/error.ts +0 -57
  157. package/src/cli/logo.ts +0 -6
  158. package/src/cli/network.ts +0 -60
  159. package/src/cli/ui.ts +0 -113
  160. package/src/cli/upgrade.ts +0 -25
  161. package/src/command/index.ts +0 -150
  162. package/src/command/template/initialize.txt +0 -10
  163. package/src/command/template/review.txt +0 -101
  164. package/src/config/config.ts +0 -1517
  165. package/src/config/markdown.ts +0 -98
  166. package/src/env/index.ts +0 -28
  167. package/src/file/ignore.ts +0 -83
  168. package/src/file/index.ts +0 -583
  169. package/src/file/ripgrep.ts +0 -375
  170. package/src/file/time.ts +0 -69
  171. package/src/file/watcher.ts +0 -127
  172. package/src/flag/flag.ts +0 -148
  173. package/src/format/formatter.ts +0 -366
  174. package/src/format/index.ts +0 -137
  175. package/src/global/index.ts +0 -80
  176. package/src/id/id.ts +0 -83
  177. package/src/ide/index.ts +0 -76
  178. package/src/index.ts +0 -160
  179. package/src/installation/index.ts +0 -268
  180. package/src/lsp/client.ts +0 -252
  181. package/src/lsp/index.ts +0 -485
  182. package/src/lsp/language.ts +0 -119
  183. package/src/lsp/server.ts +0 -2046
  184. package/src/mcp/auth.ts +0 -132
  185. package/src/mcp/index.ts +0 -937
  186. package/src/mcp/oauth-callback.ts +0 -200
  187. package/src/mcp/oauth-provider.ts +0 -154
  188. package/src/patch/index.ts +0 -680
  189. package/src/permission/arity.ts +0 -163
  190. package/src/permission/index.ts +0 -210
  191. package/src/permission/next.ts +0 -280
  192. package/src/plugin/codex.ts +0 -624
  193. package/src/plugin/copilot.ts +0 -327
  194. package/src/plugin/index.ts +0 -138
  195. package/src/project/bootstrap.ts +0 -35
  196. package/src/project/instance.ts +0 -114
  197. package/src/project/project.ts +0 -371
  198. package/src/project/state.ts +0 -70
  199. package/src/project/vcs.ts +0 -76
  200. package/src/provider/auth.ts +0 -147
  201. package/src/provider/error.ts +0 -189
  202. package/src/provider/models.ts +0 -133
  203. package/src/provider/provider.ts +0 -1370
  204. package/src/provider/sdk/copilot/README.md +0 -5
  205. package/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -164
  206. package/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
  207. package/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -17
  208. package/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
  209. package/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -780
  210. package/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
  211. package/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
  212. package/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -87
  213. package/src/provider/sdk/copilot/copilot-provider.ts +0 -100
  214. package/src/provider/sdk/copilot/index.ts +0 -2
  215. package/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
  216. package/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -303
  217. package/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
  218. package/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
  219. package/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
  220. package/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -207
  221. package/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1732
  222. package/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -177
  223. package/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
  224. package/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -88
  225. package/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -128
  226. package/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -115
  227. package/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -65
  228. package/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -104
  229. package/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -103
  230. package/src/provider/transform.ts +0 -806
  231. package/src/pty/index.ts +0 -286
  232. package/src/question/index.ts +0 -171
  233. package/src/scheduler/index.ts +0 -61
  234. package/src/server/error.ts +0 -36
  235. package/src/server/event.ts +0 -7
  236. package/src/server/mdns.ts +0 -60
  237. package/src/server/routes/config.ts +0 -92
  238. package/src/server/routes/experimental.ts +0 -208
  239. package/src/server/routes/file.ts +0 -197
  240. package/src/server/routes/global.ts +0 -183
  241. package/src/server/routes/mcp.ts +0 -225
  242. package/src/server/routes/permission.ts +0 -68
  243. package/src/server/routes/project.ts +0 -82
  244. package/src/server/routes/provider.ts +0 -179
  245. package/src/server/routes/pty.ts +0 -176
  246. package/src/server/routes/question.ts +0 -98
  247. package/src/server/routes/session.ts +0 -939
  248. package/src/server/routes/tui.ts +0 -379
  249. package/src/server/server.ts +0 -621
  250. package/src/session/compaction.ts +0 -261
  251. package/src/session/index.ts +0 -543
  252. package/src/session/instruction.ts +0 -197
  253. package/src/session/llm.ts +0 -283
  254. package/src/session/message-v2.ts +0 -841
  255. package/src/session/message.ts +0 -189
  256. package/src/session/processor.ts +0 -410
  257. package/src/session/prompt/anthropic-20250930.txt +0 -166
  258. package/src/session/prompt/anthropic.txt +0 -105
  259. package/src/session/prompt/beast.txt +0 -147
  260. package/src/session/prompt/build-switch.txt +0 -5
  261. package/src/session/prompt/codex_header.txt +0 -79
  262. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  263. package/src/session/prompt/gemini.txt +0 -155
  264. package/src/session/prompt/max-steps.txt +0 -16
  265. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  266. package/src/session/prompt/plan.txt +0 -26
  267. package/src/session/prompt/qwen.txt +0 -109
  268. package/src/session/prompt/trinity.txt +0 -97
  269. package/src/session/prompt.ts +0 -1964
  270. package/src/session/retry.ts +0 -101
  271. package/src/session/revert.ts +0 -121
  272. package/src/session/status.ts +0 -76
  273. package/src/session/summary.ts +0 -203
  274. package/src/session/system.ts +0 -54
  275. package/src/session/todo.ts +0 -37
  276. package/src/share/share-next.ts +0 -200
  277. package/src/share/share.ts +0 -92
  278. package/src/shell/shell.ts +0 -67
  279. package/src/skill/discovery.ts +0 -97
  280. package/src/skill/index.ts +0 -1
  281. package/src/skill/skill.ts +0 -188
  282. package/src/snapshot/index.ts +0 -255
  283. package/src/storage/storage.ts +0 -227
  284. package/src/tool/apply_patch.ts +0 -281
  285. package/src/tool/apply_patch.txt +0 -33
  286. package/src/tool/bash.ts +0 -269
  287. package/src/tool/bash.txt +0 -115
  288. package/src/tool/batch.ts +0 -175
  289. package/src/tool/batch.txt +0 -24
  290. package/src/tool/codesearch.ts +0 -132
  291. package/src/tool/codesearch.txt +0 -12
  292. package/src/tool/edit.ts +0 -655
  293. package/src/tool/edit.txt +0 -10
  294. package/src/tool/external-directory.ts +0 -32
  295. package/src/tool/glob.ts +0 -80
  296. package/src/tool/glob.txt +0 -6
  297. package/src/tool/grep.ts +0 -150
  298. package/src/tool/grep.txt +0 -8
  299. package/src/tool/invalid.ts +0 -17
  300. package/src/tool/ls.ts +0 -121
  301. package/src/tool/ls.txt +0 -1
  302. package/src/tool/lsp.ts +0 -96
  303. package/src/tool/lsp.txt +0 -19
  304. package/src/tool/multiedit.ts +0 -46
  305. package/src/tool/multiedit.txt +0 -41
  306. package/src/tool/plan-enter.txt +0 -14
  307. package/src/tool/plan-exit.txt +0 -13
  308. package/src/tool/plan.ts +0 -130
  309. package/src/tool/question.ts +0 -33
  310. package/src/tool/question.txt +0 -10
  311. package/src/tool/read.ts +0 -261
  312. package/src/tool/read.txt +0 -14
  313. package/src/tool/registry.ts +0 -160
  314. package/src/tool/skill.ts +0 -123
  315. package/src/tool/task.ts +0 -165
  316. package/src/tool/task.txt +0 -60
  317. package/src/tool/todo.ts +0 -53
  318. package/src/tool/todoread.txt +0 -14
  319. package/src/tool/todowrite.txt +0 -167
  320. package/src/tool/tool.ts +0 -89
  321. package/src/tool/truncation.ts +0 -106
  322. package/src/tool/webfetch.ts +0 -186
  323. package/src/tool/webfetch.txt +0 -13
  324. package/src/tool/websearch.ts +0 -150
  325. package/src/tool/websearch.txt +0 -14
  326. package/src/tool/write.ts +0 -85
  327. package/src/tool/write.txt +0 -8
  328. package/src/util/abort.ts +0 -35
  329. package/src/util/archive.ts +0 -16
  330. package/src/util/color.ts +0 -19
  331. package/src/util/context.ts +0 -25
  332. package/src/util/defer.ts +0 -12
  333. package/src/util/eventloop.ts +0 -20
  334. package/src/util/filesystem.ts +0 -93
  335. package/src/util/fn.ts +0 -11
  336. package/src/util/format.ts +0 -20
  337. package/src/util/iife.ts +0 -3
  338. package/src/util/keybind.ts +0 -103
  339. package/src/util/lazy.ts +0 -18
  340. package/src/util/locale.ts +0 -81
  341. package/src/util/lock.ts +0 -98
  342. package/src/util/log.ts +0 -180
  343. package/src/util/proxied.ts +0 -3
  344. package/src/util/queue.ts +0 -32
  345. package/src/util/rpc.ts +0 -66
  346. package/src/util/scrap.ts +0 -10
  347. package/src/util/signal.ts +0 -12
  348. package/src/util/timeout.ts +0 -14
  349. package/src/util/token.ts +0 -7
  350. package/src/util/wildcard.ts +0 -56
  351. package/src/worktree/index.ts +0 -612
  352. package/sst-env.d.ts +0 -9
  353. package/test/acp/agent-interface.test.ts +0 -51
  354. package/test/acp/event-subscription.test.ts +0 -436
  355. package/test/agent/agent.test.ts +0 -675
  356. package/test/bun.test.ts +0 -53
  357. package/test/cli/github-action.test.ts +0 -161
  358. package/test/cli/github-remote.test.ts +0 -80
  359. package/test/cli/import.test.ts +0 -38
  360. package/test/cli/tui/transcript.test.ts +0 -322
  361. package/test/config/agent-color.test.ts +0 -71
  362. package/test/config/config.test.ts +0 -1802
  363. package/test/config/fixtures/empty-frontmatter.md +0 -4
  364. package/test/config/fixtures/frontmatter.md +0 -28
  365. package/test/config/fixtures/markdown-header.md +0 -11
  366. package/test/config/fixtures/no-frontmatter.md +0 -1
  367. package/test/config/fixtures/weird-model-id.md +0 -13
  368. package/test/config/markdown.test.ts +0 -228
  369. package/test/file/ignore.test.ts +0 -10
  370. package/test/file/path-traversal.test.ts +0 -198
  371. package/test/file/ripgrep.test.ts +0 -39
  372. package/test/fixture/fixture.ts +0 -45
  373. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  374. package/test/ide/ide.test.ts +0 -82
  375. package/test/keybind.test.ts +0 -421
  376. package/test/lsp/client.test.ts +0 -95
  377. package/test/mcp/headers.test.ts +0 -153
  378. package/test/mcp/oauth-browser.test.ts +0 -249
  379. package/test/memory/abort-leak.test.ts +0 -136
  380. package/test/patch/patch.test.ts +0 -348
  381. package/test/permission/arity.test.ts +0 -33
  382. package/test/permission/next.test.ts +0 -690
  383. package/test/permission-task.test.ts +0 -319
  384. package/test/plugin/auth-override.test.ts +0 -44
  385. package/test/plugin/codex.test.ts +0 -123
  386. package/test/preload.ts +0 -63
  387. package/test/project/project.test.ts +0 -120
  388. package/test/provider/amazon-bedrock.test.ts +0 -445
  389. package/test/provider/copilot/convert-to-copilot-messages.test.ts +0 -523
  390. package/test/provider/copilot/copilot-chat-model.test.ts +0 -592
  391. package/test/provider/gitlab-duo.test.ts +0 -262
  392. package/test/provider/provider.test.ts +0 -2129
  393. package/test/provider/transform.test.ts +0 -1928
  394. package/test/question/question.test.ts +0 -300
  395. package/test/scheduler.test.ts +0 -73
  396. package/test/server/session-list.test.ts +0 -39
  397. package/test/server/session-select.test.ts +0 -78
  398. package/test/session/compaction.test.ts +0 -423
  399. package/test/session/instruction.test.ts +0 -170
  400. package/test/session/llm.test.ts +0 -667
  401. package/test/session/message-v2.test.ts +0 -924
  402. package/test/session/prompt-missing-file.test.ts +0 -53
  403. package/test/session/prompt-special-chars.test.ts +0 -56
  404. package/test/session/prompt-variant.test.ts +0 -68
  405. package/test/session/retry.test.ts +0 -188
  406. package/test/session/revert-compact.test.ts +0 -285
  407. package/test/session/session.test.ts +0 -71
  408. package/test/session/structured-output-integration.test.ts +0 -233
  409. package/test/session/structured-output.test.ts +0 -385
  410. package/test/skill/discovery.test.ts +0 -60
  411. package/test/skill/skill.test.ts +0 -388
  412. package/test/snapshot/snapshot.test.ts +0 -1040
  413. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  414. package/test/tool/apply_patch.test.ts +0 -559
  415. package/test/tool/bash.test.ts +0 -399
  416. package/test/tool/external-directory.test.ts +0 -127
  417. package/test/tool/fixtures/large-image.png +0 -0
  418. package/test/tool/fixtures/models-api.json +0 -38413
  419. package/test/tool/grep.test.ts +0 -110
  420. package/test/tool/question.test.ts +0 -107
  421. package/test/tool/read.test.ts +0 -421
  422. package/test/tool/registry.test.ts +0 -122
  423. package/test/tool/skill.test.ts +0 -112
  424. package/test/tool/truncation.test.ts +0 -159
  425. package/test/util/filesystem.test.ts +0 -39
  426. package/test/util/format.test.ts +0 -59
  427. package/test/util/iife.test.ts +0 -36
  428. package/test/util/lazy.test.ts +0 -50
  429. package/test/util/lock.test.ts +0 -72
  430. package/test/util/timeout.test.ts +0 -21
  431. package/test/util/wildcard.test.ts +0 -75
  432. package/tsconfig.json +0 -16
  433. /package/{script/postinstall.mjs → postinstall.mjs} +0 -0
@@ -1,1040 +0,0 @@
1
- import { test, expect } from "bun:test"
2
- import { $ } from "bun"
3
- import { Snapshot } from "../../src/snapshot"
4
- import { Instance } from "../../src/project/instance"
5
- import { tmpdir } from "../fixture/fixture"
6
-
7
- async function bootstrap() {
8
- return tmpdir({
9
- git: true,
10
- init: async (dir) => {
11
- const unique = Math.random().toString(36).slice(2)
12
- const aContent = `A${unique}`
13
- const bContent = `B${unique}`
14
- await Bun.write(`${dir}/a.txt`, aContent)
15
- await Bun.write(`${dir}/b.txt`, bContent)
16
- await $`git add .`.cwd(dir).quiet()
17
- await $`git commit --no-gpg-sign -m init`.cwd(dir).quiet()
18
- return {
19
- aContent,
20
- bContent,
21
- }
22
- },
23
- })
24
- }
25
-
26
- test("tracks deleted files correctly", async () => {
27
- await using tmp = await bootstrap()
28
- await Instance.provide({
29
- directory: tmp.path,
30
- fn: async () => {
31
- const before = await Snapshot.track()
32
- expect(before).toBeTruthy()
33
-
34
- await $`rm ${tmp.path}/a.txt`.quiet()
35
-
36
- expect((await Snapshot.patch(before!)).files).toContain(`${tmp.path}/a.txt`)
37
- },
38
- })
39
- })
40
-
41
- test("revert should remove new files", async () => {
42
- await using tmp = await bootstrap()
43
- await Instance.provide({
44
- directory: tmp.path,
45
- fn: async () => {
46
- const before = await Snapshot.track()
47
- expect(before).toBeTruthy()
48
-
49
- await Bun.write(`${tmp.path}/new.txt`, "NEW")
50
-
51
- await Snapshot.revert([await Snapshot.patch(before!)])
52
-
53
- expect(await Bun.file(`${tmp.path}/new.txt`).exists()).toBe(false)
54
- },
55
- })
56
- })
57
-
58
- test("revert in subdirectory", async () => {
59
- await using tmp = await bootstrap()
60
- await Instance.provide({
61
- directory: tmp.path,
62
- fn: async () => {
63
- const before = await Snapshot.track()
64
- expect(before).toBeTruthy()
65
-
66
- await $`mkdir -p ${tmp.path}/sub`.quiet()
67
- await Bun.write(`${tmp.path}/sub/file.txt`, "SUB")
68
-
69
- await Snapshot.revert([await Snapshot.patch(before!)])
70
-
71
- expect(await Bun.file(`${tmp.path}/sub/file.txt`).exists()).toBe(false)
72
- // Note: revert currently only removes files, not directories
73
- // The empty subdirectory will remain
74
- },
75
- })
76
- })
77
-
78
- test("multiple file operations", async () => {
79
- await using tmp = await bootstrap()
80
- await Instance.provide({
81
- directory: tmp.path,
82
- fn: async () => {
83
- const before = await Snapshot.track()
84
- expect(before).toBeTruthy()
85
-
86
- await $`rm ${tmp.path}/a.txt`.quiet()
87
- await Bun.write(`${tmp.path}/c.txt`, "C")
88
- await $`mkdir -p ${tmp.path}/dir`.quiet()
89
- await Bun.write(`${tmp.path}/dir/d.txt`, "D")
90
- await Bun.write(`${tmp.path}/b.txt`, "MODIFIED")
91
-
92
- await Snapshot.revert([await Snapshot.patch(before!)])
93
-
94
- expect(await Bun.file(`${tmp.path}/a.txt`).text()).toBe(tmp.extra.aContent)
95
- expect(await Bun.file(`${tmp.path}/c.txt`).exists()).toBe(false)
96
- // Note: revert currently only removes files, not directories
97
- // The empty directory will remain
98
- expect(await Bun.file(`${tmp.path}/b.txt`).text()).toBe(tmp.extra.bContent)
99
- },
100
- })
101
- })
102
-
103
- test("empty directory handling", async () => {
104
- await using tmp = await bootstrap()
105
- await Instance.provide({
106
- directory: tmp.path,
107
- fn: async () => {
108
- const before = await Snapshot.track()
109
- expect(before).toBeTruthy()
110
-
111
- await $`mkdir ${tmp.path}/empty`.quiet()
112
-
113
- expect((await Snapshot.patch(before!)).files.length).toBe(0)
114
- },
115
- })
116
- })
117
-
118
- test("binary file handling", async () => {
119
- await using tmp = await bootstrap()
120
- await Instance.provide({
121
- directory: tmp.path,
122
- fn: async () => {
123
- const before = await Snapshot.track()
124
- expect(before).toBeTruthy()
125
-
126
- await Bun.write(`${tmp.path}/image.png`, new Uint8Array([0x89, 0x50, 0x4e, 0x47]))
127
-
128
- const patch = await Snapshot.patch(before!)
129
- expect(patch.files).toContain(`${tmp.path}/image.png`)
130
-
131
- await Snapshot.revert([patch])
132
- expect(await Bun.file(`${tmp.path}/image.png`).exists()).toBe(false)
133
- },
134
- })
135
- })
136
-
137
- test("symlink handling", async () => {
138
- await using tmp = await bootstrap()
139
- await Instance.provide({
140
- directory: tmp.path,
141
- fn: async () => {
142
- const before = await Snapshot.track()
143
- expect(before).toBeTruthy()
144
-
145
- await $`ln -s ${tmp.path}/a.txt ${tmp.path}/link.txt`.quiet()
146
-
147
- expect((await Snapshot.patch(before!)).files).toContain(`${tmp.path}/link.txt`)
148
- },
149
- })
150
- })
151
-
152
- test("large file handling", async () => {
153
- await using tmp = await bootstrap()
154
- await Instance.provide({
155
- directory: tmp.path,
156
- fn: async () => {
157
- const before = await Snapshot.track()
158
- expect(before).toBeTruthy()
159
-
160
- await Bun.write(`${tmp.path}/large.txt`, "x".repeat(1024 * 1024))
161
-
162
- expect((await Snapshot.patch(before!)).files).toContain(`${tmp.path}/large.txt`)
163
- },
164
- })
165
- })
166
-
167
- test("nested directory revert", async () => {
168
- await using tmp = await bootstrap()
169
- await Instance.provide({
170
- directory: tmp.path,
171
- fn: async () => {
172
- const before = await Snapshot.track()
173
- expect(before).toBeTruthy()
174
-
175
- await $`mkdir -p ${tmp.path}/level1/level2/level3`.quiet()
176
- await Bun.write(`${tmp.path}/level1/level2/level3/deep.txt`, "DEEP")
177
-
178
- await Snapshot.revert([await Snapshot.patch(before!)])
179
-
180
- expect(await Bun.file(`${tmp.path}/level1/level2/level3/deep.txt`).exists()).toBe(false)
181
- },
182
- })
183
- })
184
-
185
- test("special characters in filenames", async () => {
186
- await using tmp = await bootstrap()
187
- await Instance.provide({
188
- directory: tmp.path,
189
- fn: async () => {
190
- const before = await Snapshot.track()
191
- expect(before).toBeTruthy()
192
-
193
- await Bun.write(`${tmp.path}/file with spaces.txt`, "SPACES")
194
- await Bun.write(`${tmp.path}/file-with-dashes.txt`, "DASHES")
195
- await Bun.write(`${tmp.path}/file_with_underscores.txt`, "UNDERSCORES")
196
-
197
- const files = (await Snapshot.patch(before!)).files
198
- expect(files).toContain(`${tmp.path}/file with spaces.txt`)
199
- expect(files).toContain(`${tmp.path}/file-with-dashes.txt`)
200
- expect(files).toContain(`${tmp.path}/file_with_underscores.txt`)
201
- },
202
- })
203
- })
204
-
205
- test("revert with empty patches", async () => {
206
- await using tmp = await bootstrap()
207
- await Instance.provide({
208
- directory: tmp.path,
209
- fn: async () => {
210
- // Should not crash with empty patches
211
- expect(Snapshot.revert([])).resolves.toBeUndefined()
212
-
213
- // Should not crash with patches that have empty file lists
214
- expect(Snapshot.revert([{ hash: "dummy", files: [] }])).resolves.toBeUndefined()
215
- },
216
- })
217
- })
218
-
219
- test("patch with invalid hash", async () => {
220
- await using tmp = await bootstrap()
221
- await Instance.provide({
222
- directory: tmp.path,
223
- fn: async () => {
224
- const before = await Snapshot.track()
225
- expect(before).toBeTruthy()
226
-
227
- // Create a change
228
- await Bun.write(`${tmp.path}/test.txt`, "TEST")
229
-
230
- // Try to patch with invalid hash - should handle gracefully
231
- const patch = await Snapshot.patch("invalid-hash-12345")
232
- expect(patch.files).toEqual([])
233
- expect(patch.hash).toBe("invalid-hash-12345")
234
- },
235
- })
236
- })
237
-
238
- test("revert non-existent file", async () => {
239
- await using tmp = await bootstrap()
240
- await Instance.provide({
241
- directory: tmp.path,
242
- fn: async () => {
243
- const before = await Snapshot.track()
244
- expect(before).toBeTruthy()
245
-
246
- // Try to revert a file that doesn't exist in the snapshot
247
- // This should not crash
248
- expect(
249
- Snapshot.revert([
250
- {
251
- hash: before!,
252
- files: [`${tmp.path}/nonexistent.txt`],
253
- },
254
- ]),
255
- ).resolves.toBeUndefined()
256
- },
257
- })
258
- })
259
-
260
- test("unicode filenames", async () => {
261
- await using tmp = await bootstrap()
262
- await Instance.provide({
263
- directory: tmp.path,
264
- fn: async () => {
265
- const before = await Snapshot.track()
266
- expect(before).toBeTruthy()
267
-
268
- const unicodeFiles = [
269
- { path: `${tmp.path}/文件.txt`, content: "chinese content" },
270
- { path: `${tmp.path}/🚀rocket.txt`, content: "emoji content" },
271
- { path: `${tmp.path}/café.txt`, content: "accented content" },
272
- { path: `${tmp.path}/файл.txt`, content: "cyrillic content" },
273
- ]
274
-
275
- for (const file of unicodeFiles) {
276
- await Bun.write(file.path, file.content)
277
- }
278
-
279
- const patch = await Snapshot.patch(before!)
280
- expect(patch.files.length).toBe(4)
281
-
282
- for (const file of unicodeFiles) {
283
- expect(patch.files).toContain(file.path)
284
- }
285
-
286
- await Snapshot.revert([patch])
287
-
288
- for (const file of unicodeFiles) {
289
- expect(await Bun.file(file.path).exists()).toBe(false)
290
- }
291
- },
292
- })
293
- })
294
-
295
- test.skip("unicode filenames modification and restore", async () => {
296
- await using tmp = await bootstrap()
297
- await Instance.provide({
298
- directory: tmp.path,
299
- fn: async () => {
300
- const chineseFile = `${tmp.path}/文件.txt`
301
- const cyrillicFile = `${tmp.path}/файл.txt`
302
-
303
- await Bun.write(chineseFile, "original chinese")
304
- await Bun.write(cyrillicFile, "original cyrillic")
305
-
306
- const before = await Snapshot.track()
307
- expect(before).toBeTruthy()
308
-
309
- await Bun.write(chineseFile, "modified chinese")
310
- await Bun.write(cyrillicFile, "modified cyrillic")
311
-
312
- const patch = await Snapshot.patch(before!)
313
- expect(patch.files).toContain(chineseFile)
314
- expect(patch.files).toContain(cyrillicFile)
315
-
316
- await Snapshot.revert([patch])
317
-
318
- expect(await Bun.file(chineseFile).text()).toBe("original chinese")
319
- expect(await Bun.file(cyrillicFile).text()).toBe("original cyrillic")
320
- },
321
- })
322
- })
323
-
324
- test("unicode filenames in subdirectories", async () => {
325
- await using tmp = await bootstrap()
326
- await Instance.provide({
327
- directory: tmp.path,
328
- fn: async () => {
329
- const before = await Snapshot.track()
330
- expect(before).toBeTruthy()
331
-
332
- await $`mkdir -p "${tmp.path}/目录/подкаталог"`.quiet()
333
- const deepFile = `${tmp.path}/目录/подкаталог/文件.txt`
334
- await Bun.write(deepFile, "deep unicode content")
335
-
336
- const patch = await Snapshot.patch(before!)
337
- expect(patch.files).toContain(deepFile)
338
-
339
- await Snapshot.revert([patch])
340
- expect(await Bun.file(deepFile).exists()).toBe(false)
341
- },
342
- })
343
- })
344
-
345
- test("very long filenames", async () => {
346
- await using tmp = await bootstrap()
347
- await Instance.provide({
348
- directory: tmp.path,
349
- fn: async () => {
350
- const before = await Snapshot.track()
351
- expect(before).toBeTruthy()
352
-
353
- const longName = "a".repeat(200) + ".txt"
354
- const longFile = `${tmp.path}/${longName}`
355
-
356
- await Bun.write(longFile, "long filename content")
357
-
358
- const patch = await Snapshot.patch(before!)
359
- expect(patch.files).toContain(longFile)
360
-
361
- await Snapshot.revert([patch])
362
- expect(await Bun.file(longFile).exists()).toBe(false)
363
- },
364
- })
365
- })
366
-
367
- test("hidden files", async () => {
368
- await using tmp = await bootstrap()
369
- await Instance.provide({
370
- directory: tmp.path,
371
- fn: async () => {
372
- const before = await Snapshot.track()
373
- expect(before).toBeTruthy()
374
-
375
- await Bun.write(`${tmp.path}/.hidden`, "hidden content")
376
- await Bun.write(`${tmp.path}/.gitignore`, "*.log")
377
- await Bun.write(`${tmp.path}/.config`, "config content")
378
-
379
- const patch = await Snapshot.patch(before!)
380
- expect(patch.files).toContain(`${tmp.path}/.hidden`)
381
- expect(patch.files).toContain(`${tmp.path}/.gitignore`)
382
- expect(patch.files).toContain(`${tmp.path}/.config`)
383
- },
384
- })
385
- })
386
-
387
- test("nested symlinks", async () => {
388
- await using tmp = await bootstrap()
389
- await Instance.provide({
390
- directory: tmp.path,
391
- fn: async () => {
392
- const before = await Snapshot.track()
393
- expect(before).toBeTruthy()
394
-
395
- await $`mkdir -p ${tmp.path}/sub/dir`.quiet()
396
- await Bun.write(`${tmp.path}/sub/dir/target.txt`, "target content")
397
- await $`ln -s ${tmp.path}/sub/dir/target.txt ${tmp.path}/sub/dir/link.txt`.quiet()
398
- await $`ln -s ${tmp.path}/sub ${tmp.path}/sub-link`.quiet()
399
-
400
- const patch = await Snapshot.patch(before!)
401
- expect(patch.files).toContain(`${tmp.path}/sub/dir/link.txt`)
402
- expect(patch.files).toContain(`${tmp.path}/sub-link`)
403
- },
404
- })
405
- })
406
-
407
- test("file permissions and ownership changes", async () => {
408
- await using tmp = await bootstrap()
409
- await Instance.provide({
410
- directory: tmp.path,
411
- fn: async () => {
412
- const before = await Snapshot.track()
413
- expect(before).toBeTruthy()
414
-
415
- // Change permissions multiple times
416
- await $`chmod 600 ${tmp.path}/a.txt`.quiet()
417
- await $`chmod 755 ${tmp.path}/a.txt`.quiet()
418
- await $`chmod 644 ${tmp.path}/a.txt`.quiet()
419
-
420
- const patch = await Snapshot.patch(before!)
421
- // Note: git doesn't track permission changes on existing files by default
422
- // Only tracks executable bit when files are first added
423
- expect(patch.files.length).toBe(0)
424
- },
425
- })
426
- })
427
-
428
- test("circular symlinks", async () => {
429
- await using tmp = await bootstrap()
430
- await Instance.provide({
431
- directory: tmp.path,
432
- fn: async () => {
433
- const before = await Snapshot.track()
434
- expect(before).toBeTruthy()
435
-
436
- // Create circular symlink
437
- await $`ln -s ${tmp.path}/circular ${tmp.path}/circular`.quiet().nothrow()
438
-
439
- const patch = await Snapshot.patch(before!)
440
- expect(patch.files.length).toBeGreaterThanOrEqual(0) // Should not crash
441
- },
442
- })
443
- })
444
-
445
- test("gitignore changes", async () => {
446
- await using tmp = await bootstrap()
447
- await Instance.provide({
448
- directory: tmp.path,
449
- fn: async () => {
450
- const before = await Snapshot.track()
451
- expect(before).toBeTruthy()
452
-
453
- await Bun.write(`${tmp.path}/.gitignore`, "*.ignored")
454
- await Bun.write(`${tmp.path}/test.ignored`, "ignored content")
455
- await Bun.write(`${tmp.path}/normal.txt`, "normal content")
456
-
457
- const patch = await Snapshot.patch(before!)
458
-
459
- // Should track gitignore itself
460
- expect(patch.files).toContain(`${tmp.path}/.gitignore`)
461
- // Should track normal files
462
- expect(patch.files).toContain(`${tmp.path}/normal.txt`)
463
- // Should not track ignored files (git won't see them)
464
- expect(patch.files).not.toContain(`${tmp.path}/test.ignored`)
465
- },
466
- })
467
- })
468
-
469
- test("concurrent file operations during patch", async () => {
470
- await using tmp = await bootstrap()
471
- await Instance.provide({
472
- directory: tmp.path,
473
- fn: async () => {
474
- const before = await Snapshot.track()
475
- expect(before).toBeTruthy()
476
-
477
- // Start creating files
478
- const createPromise = (async () => {
479
- for (let i = 0; i < 10; i++) {
480
- await Bun.write(`${tmp.path}/concurrent${i}.txt`, `concurrent${i}`)
481
- // Small delay to simulate concurrent operations
482
- await new Promise((resolve) => setTimeout(resolve, 1))
483
- }
484
- })()
485
-
486
- // Get patch while files are being created
487
- const patchPromise = Snapshot.patch(before!)
488
-
489
- await createPromise
490
- const patch = await patchPromise
491
-
492
- // Should capture some or all of the concurrent files
493
- expect(patch.files.length).toBeGreaterThanOrEqual(0)
494
- },
495
- })
496
- })
497
-
498
- test("snapshot state isolation between projects", async () => {
499
- // Test that different projects don't interfere with each other
500
- await using tmp1 = await bootstrap()
501
- await using tmp2 = await bootstrap()
502
-
503
- await Instance.provide({
504
- directory: tmp1.path,
505
- fn: async () => {
506
- const before1 = await Snapshot.track()
507
- await Bun.write(`${tmp1.path}/project1.txt`, "project1 content")
508
- const patch1 = await Snapshot.patch(before1!)
509
- expect(patch1.files).toContain(`${tmp1.path}/project1.txt`)
510
- },
511
- })
512
-
513
- await Instance.provide({
514
- directory: tmp2.path,
515
- fn: async () => {
516
- const before2 = await Snapshot.track()
517
- await Bun.write(`${tmp2.path}/project2.txt`, "project2 content")
518
- const patch2 = await Snapshot.patch(before2!)
519
- expect(patch2.files).toContain(`${tmp2.path}/project2.txt`)
520
-
521
- // Ensure project1 files don't appear in project2
522
- expect(patch2.files).not.toContain(`${tmp1?.path}/project1.txt`)
523
- },
524
- })
525
- })
526
-
527
- test("patch detects changes in secondary worktree", async () => {
528
- await using tmp = await bootstrap()
529
- const worktreePath = `${tmp.path}-worktree`
530
- await $`git worktree add ${worktreePath} HEAD`.cwd(tmp.path).quiet()
531
-
532
- try {
533
- await Instance.provide({
534
- directory: tmp.path,
535
- fn: async () => {
536
- expect(await Snapshot.track()).toBeTruthy()
537
- },
538
- })
539
-
540
- await Instance.provide({
541
- directory: worktreePath,
542
- fn: async () => {
543
- const before = await Snapshot.track()
544
- expect(before).toBeTruthy()
545
-
546
- const worktreeFile = `${worktreePath}/worktree.txt`
547
- await Bun.write(worktreeFile, "worktree content")
548
-
549
- const patch = await Snapshot.patch(before!)
550
- expect(patch.files).toContain(worktreeFile)
551
- },
552
- })
553
- } finally {
554
- await $`git worktree remove --force ${worktreePath}`.cwd(tmp.path).quiet().nothrow()
555
- await $`rm -rf ${worktreePath}`.quiet()
556
- }
557
- })
558
-
559
- test("revert only removes files in invoking worktree", async () => {
560
- await using tmp = await bootstrap()
561
- const worktreePath = `${tmp.path}-worktree`
562
- await $`git worktree add ${worktreePath} HEAD`.cwd(tmp.path).quiet()
563
-
564
- try {
565
- await Instance.provide({
566
- directory: tmp.path,
567
- fn: async () => {
568
- expect(await Snapshot.track()).toBeTruthy()
569
- },
570
- })
571
- const primaryFile = `${tmp.path}/worktree.txt`
572
- await Bun.write(primaryFile, "primary content")
573
-
574
- await Instance.provide({
575
- directory: worktreePath,
576
- fn: async () => {
577
- const before = await Snapshot.track()
578
- expect(before).toBeTruthy()
579
-
580
- const worktreeFile = `${worktreePath}/worktree.txt`
581
- await Bun.write(worktreeFile, "worktree content")
582
-
583
- const patch = await Snapshot.patch(before!)
584
- await Snapshot.revert([patch])
585
-
586
- expect(await Bun.file(worktreeFile).exists()).toBe(false)
587
- },
588
- })
589
-
590
- expect(await Bun.file(primaryFile).text()).toBe("primary content")
591
- } finally {
592
- await $`git worktree remove --force ${worktreePath}`.cwd(tmp.path).quiet().nothrow()
593
- await $`rm -rf ${worktreePath}`.quiet()
594
- await $`rm -f ${tmp.path}/worktree.txt`.quiet()
595
- }
596
- })
597
-
598
- test("diff reports worktree-only/shared edits and ignores primary-only", async () => {
599
- await using tmp = await bootstrap()
600
- const worktreePath = `${tmp.path}-worktree`
601
- await $`git worktree add ${worktreePath} HEAD`.cwd(tmp.path).quiet()
602
-
603
- try {
604
- await Instance.provide({
605
- directory: tmp.path,
606
- fn: async () => {
607
- expect(await Snapshot.track()).toBeTruthy()
608
- },
609
- })
610
-
611
- await Instance.provide({
612
- directory: worktreePath,
613
- fn: async () => {
614
- const before = await Snapshot.track()
615
- expect(before).toBeTruthy()
616
-
617
- await Bun.write(`${worktreePath}/worktree-only.txt`, "worktree diff content")
618
- await Bun.write(`${worktreePath}/shared.txt`, "worktree edit")
619
- await Bun.write(`${tmp.path}/shared.txt`, "primary edit")
620
- await Bun.write(`${tmp.path}/primary-only.txt`, "primary change")
621
-
622
- const diff = await Snapshot.diff(before!)
623
- expect(diff).toContain("worktree-only.txt")
624
- expect(diff).toContain("shared.txt")
625
- expect(diff).not.toContain("primary-only.txt")
626
- },
627
- })
628
- } finally {
629
- await $`git worktree remove --force ${worktreePath}`.cwd(tmp.path).quiet().nothrow()
630
- await $`rm -rf ${worktreePath}`.quiet()
631
- await $`rm -f ${tmp.path}/shared.txt`.quiet()
632
- await $`rm -f ${tmp.path}/primary-only.txt`.quiet()
633
- }
634
- })
635
-
636
- test("track with no changes returns same hash", async () => {
637
- await using tmp = await bootstrap()
638
- await Instance.provide({
639
- directory: tmp.path,
640
- fn: async () => {
641
- const hash1 = await Snapshot.track()
642
- expect(hash1).toBeTruthy()
643
-
644
- // Track again with no changes
645
- const hash2 = await Snapshot.track()
646
- expect(hash2).toBe(hash1!)
647
-
648
- // Track again
649
- const hash3 = await Snapshot.track()
650
- expect(hash3).toBe(hash1!)
651
- },
652
- })
653
- })
654
-
655
- test("diff function with various changes", async () => {
656
- await using tmp = await bootstrap()
657
- await Instance.provide({
658
- directory: tmp.path,
659
- fn: async () => {
660
- const before = await Snapshot.track()
661
- expect(before).toBeTruthy()
662
-
663
- // Make various changes
664
- await $`rm ${tmp.path}/a.txt`.quiet()
665
- await Bun.write(`${tmp.path}/new.txt`, "new content")
666
- await Bun.write(`${tmp.path}/b.txt`, "modified content")
667
-
668
- const diff = await Snapshot.diff(before!)
669
- expect(diff).toContain("a.txt")
670
- expect(diff).toContain("b.txt")
671
- expect(diff).toContain("new.txt")
672
- },
673
- })
674
- })
675
-
676
- test("restore function", async () => {
677
- await using tmp = await bootstrap()
678
- await Instance.provide({
679
- directory: tmp.path,
680
- fn: async () => {
681
- const before = await Snapshot.track()
682
- expect(before).toBeTruthy()
683
-
684
- // Make changes
685
- await $`rm ${tmp.path}/a.txt`.quiet()
686
- await Bun.write(`${tmp.path}/new.txt`, "new content")
687
- await Bun.write(`${tmp.path}/b.txt`, "modified")
688
-
689
- // Restore to original state
690
- await Snapshot.restore(before!)
691
-
692
- expect(await Bun.file(`${tmp.path}/a.txt`).exists()).toBe(true)
693
- expect(await Bun.file(`${tmp.path}/a.txt`).text()).toBe(tmp.extra.aContent)
694
- expect(await Bun.file(`${tmp.path}/new.txt`).exists()).toBe(true) // New files should remain
695
- expect(await Bun.file(`${tmp.path}/b.txt`).text()).toBe(tmp.extra.bContent)
696
- },
697
- })
698
- })
699
-
700
- test("revert should not delete files that existed but were deleted in snapshot", async () => {
701
- await using tmp = await bootstrap()
702
- await Instance.provide({
703
- directory: tmp.path,
704
- fn: async () => {
705
- const snapshot1 = await Snapshot.track()
706
- expect(snapshot1).toBeTruthy()
707
-
708
- await $`rm ${tmp.path}/a.txt`.quiet()
709
-
710
- const snapshot2 = await Snapshot.track()
711
- expect(snapshot2).toBeTruthy()
712
-
713
- await Bun.write(`${tmp.path}/a.txt`, "recreated content")
714
-
715
- const patch = await Snapshot.patch(snapshot2!)
716
- expect(patch.files).toContain(`${tmp.path}/a.txt`)
717
-
718
- await Snapshot.revert([patch])
719
-
720
- expect(await Bun.file(`${tmp.path}/a.txt`).exists()).toBe(false)
721
- },
722
- })
723
- })
724
-
725
- test("revert preserves file that existed in snapshot when deleted then recreated", async () => {
726
- await using tmp = await bootstrap()
727
- await Instance.provide({
728
- directory: tmp.path,
729
- fn: async () => {
730
- await Bun.write(`${tmp.path}/existing.txt`, "original content")
731
-
732
- const snapshot = await Snapshot.track()
733
- expect(snapshot).toBeTruthy()
734
-
735
- await $`rm ${tmp.path}/existing.txt`.quiet()
736
- await Bun.write(`${tmp.path}/existing.txt`, "recreated")
737
- await Bun.write(`${tmp.path}/newfile.txt`, "new")
738
-
739
- const patch = await Snapshot.patch(snapshot!)
740
- expect(patch.files).toContain(`${tmp.path}/existing.txt`)
741
- expect(patch.files).toContain(`${tmp.path}/newfile.txt`)
742
-
743
- await Snapshot.revert([patch])
744
-
745
- expect(await Bun.file(`${tmp.path}/newfile.txt`).exists()).toBe(false)
746
- expect(await Bun.file(`${tmp.path}/existing.txt`).exists()).toBe(true)
747
- expect(await Bun.file(`${tmp.path}/existing.txt`).text()).toBe("original content")
748
- },
749
- })
750
- })
751
-
752
- test("diffFull sets status based on git change type", async () => {
753
- await using tmp = await bootstrap()
754
- await Instance.provide({
755
- directory: tmp.path,
756
- fn: async () => {
757
- await Bun.write(`${tmp.path}/grow.txt`, "one\n")
758
- await Bun.write(`${tmp.path}/trim.txt`, "line1\nline2\n")
759
- await Bun.write(`${tmp.path}/delete.txt`, "gone")
760
-
761
- const before = await Snapshot.track()
762
- expect(before).toBeTruthy()
763
-
764
- await Bun.write(`${tmp.path}/grow.txt`, "one\ntwo\n")
765
- await Bun.write(`${tmp.path}/trim.txt`, "line1\n")
766
- await $`rm ${tmp.path}/delete.txt`.quiet()
767
- await Bun.write(`${tmp.path}/added.txt`, "new")
768
-
769
- const after = await Snapshot.track()
770
- expect(after).toBeTruthy()
771
-
772
- const diffs = await Snapshot.diffFull(before!, after!)
773
- expect(diffs.length).toBe(4)
774
-
775
- const added = diffs.find((d) => d.file === "added.txt")
776
- expect(added).toBeDefined()
777
- expect(added!.status).toBe("added")
778
-
779
- const deleted = diffs.find((d) => d.file === "delete.txt")
780
- expect(deleted).toBeDefined()
781
- expect(deleted!.status).toBe("deleted")
782
-
783
- const grow = diffs.find((d) => d.file === "grow.txt")
784
- expect(grow).toBeDefined()
785
- expect(grow!.status).toBe("modified")
786
- expect(grow!.additions).toBeGreaterThan(0)
787
- expect(grow!.deletions).toBe(0)
788
-
789
- const trim = diffs.find((d) => d.file === "trim.txt")
790
- expect(trim).toBeDefined()
791
- expect(trim!.status).toBe("modified")
792
- expect(trim!.additions).toBe(0)
793
- expect(trim!.deletions).toBeGreaterThan(0)
794
- },
795
- })
796
- })
797
-
798
- test("diffFull with new file additions", async () => {
799
- await using tmp = await bootstrap()
800
- await Instance.provide({
801
- directory: tmp.path,
802
- fn: async () => {
803
- const before = await Snapshot.track()
804
- expect(before).toBeTruthy()
805
-
806
- await Bun.write(`${tmp.path}/new.txt`, "new content")
807
-
808
- const after = await Snapshot.track()
809
- expect(after).toBeTruthy()
810
-
811
- const diffs = await Snapshot.diffFull(before!, after!)
812
- expect(diffs.length).toBe(1)
813
-
814
- const newFileDiff = diffs[0]
815
- expect(newFileDiff.file).toBe("new.txt")
816
- expect(newFileDiff.before).toBe("")
817
- expect(newFileDiff.after).toBe("new content")
818
- expect(newFileDiff.additions).toBe(1)
819
- expect(newFileDiff.deletions).toBe(0)
820
- },
821
- })
822
- })
823
-
824
- test("diffFull with file modifications", async () => {
825
- await using tmp = await bootstrap()
826
- await Instance.provide({
827
- directory: tmp.path,
828
- fn: async () => {
829
- const before = await Snapshot.track()
830
- expect(before).toBeTruthy()
831
-
832
- await Bun.write(`${tmp.path}/b.txt`, "modified content")
833
-
834
- const after = await Snapshot.track()
835
- expect(after).toBeTruthy()
836
-
837
- const diffs = await Snapshot.diffFull(before!, after!)
838
- expect(diffs.length).toBe(1)
839
-
840
- const modifiedFileDiff = diffs[0]
841
- expect(modifiedFileDiff.file).toBe("b.txt")
842
- expect(modifiedFileDiff.before).toBe(tmp.extra.bContent)
843
- expect(modifiedFileDiff.after).toBe("modified content")
844
- expect(modifiedFileDiff.additions).toBeGreaterThan(0)
845
- expect(modifiedFileDiff.deletions).toBeGreaterThan(0)
846
- },
847
- })
848
- })
849
-
850
- test("diffFull with file deletions", async () => {
851
- await using tmp = await bootstrap()
852
- await Instance.provide({
853
- directory: tmp.path,
854
- fn: async () => {
855
- const before = await Snapshot.track()
856
- expect(before).toBeTruthy()
857
-
858
- await $`rm ${tmp.path}/a.txt`.quiet()
859
-
860
- const after = await Snapshot.track()
861
- expect(after).toBeTruthy()
862
-
863
- const diffs = await Snapshot.diffFull(before!, after!)
864
- expect(diffs.length).toBe(1)
865
-
866
- const removedFileDiff = diffs[0]
867
- expect(removedFileDiff.file).toBe("a.txt")
868
- expect(removedFileDiff.before).toBe(tmp.extra.aContent)
869
- expect(removedFileDiff.after).toBe("")
870
- expect(removedFileDiff.additions).toBe(0)
871
- expect(removedFileDiff.deletions).toBe(1)
872
- },
873
- })
874
- })
875
-
876
- test("diffFull with multiple line additions", async () => {
877
- await using tmp = await bootstrap()
878
- await Instance.provide({
879
- directory: tmp.path,
880
- fn: async () => {
881
- const before = await Snapshot.track()
882
- expect(before).toBeTruthy()
883
-
884
- await Bun.write(`${tmp.path}/multi.txt`, "line1\nline2\nline3")
885
-
886
- const after = await Snapshot.track()
887
- expect(after).toBeTruthy()
888
-
889
- const diffs = await Snapshot.diffFull(before!, after!)
890
- expect(diffs.length).toBe(1)
891
-
892
- const multiDiff = diffs[0]
893
- expect(multiDiff.file).toBe("multi.txt")
894
- expect(multiDiff.before).toBe("")
895
- expect(multiDiff.after).toBe("line1\nline2\nline3")
896
- expect(multiDiff.additions).toBe(3)
897
- expect(multiDiff.deletions).toBe(0)
898
- },
899
- })
900
- })
901
-
902
- test("diffFull with addition and deletion", async () => {
903
- await using tmp = await bootstrap()
904
- await Instance.provide({
905
- directory: tmp.path,
906
- fn: async () => {
907
- const before = await Snapshot.track()
908
- expect(before).toBeTruthy()
909
-
910
- await Bun.write(`${tmp.path}/added.txt`, "added content")
911
- await $`rm ${tmp.path}/a.txt`.quiet()
912
-
913
- const after = await Snapshot.track()
914
- expect(after).toBeTruthy()
915
-
916
- const diffs = await Snapshot.diffFull(before!, after!)
917
- expect(diffs.length).toBe(2)
918
-
919
- const addedFileDiff = diffs.find((d) => d.file === "added.txt")
920
- expect(addedFileDiff).toBeDefined()
921
- expect(addedFileDiff!.before).toBe("")
922
- expect(addedFileDiff!.after).toBe("added content")
923
- expect(addedFileDiff!.additions).toBe(1)
924
- expect(addedFileDiff!.deletions).toBe(0)
925
-
926
- const removedFileDiff = diffs.find((d) => d.file === "a.txt")
927
- expect(removedFileDiff).toBeDefined()
928
- expect(removedFileDiff!.before).toBe(tmp.extra.aContent)
929
- expect(removedFileDiff!.after).toBe("")
930
- expect(removedFileDiff!.additions).toBe(0)
931
- expect(removedFileDiff!.deletions).toBe(1)
932
- },
933
- })
934
- })
935
-
936
- test("diffFull with multiple additions and deletions", async () => {
937
- await using tmp = await bootstrap()
938
- await Instance.provide({
939
- directory: tmp.path,
940
- fn: async () => {
941
- const before = await Snapshot.track()
942
- expect(before).toBeTruthy()
943
-
944
- await Bun.write(`${tmp.path}/multi1.txt`, "line1\nline2\nline3")
945
- await Bun.write(`${tmp.path}/multi2.txt`, "single line")
946
- await $`rm ${tmp.path}/a.txt`.quiet()
947
- await $`rm ${tmp.path}/b.txt`.quiet()
948
-
949
- const after = await Snapshot.track()
950
- expect(after).toBeTruthy()
951
-
952
- const diffs = await Snapshot.diffFull(before!, after!)
953
- expect(diffs.length).toBe(4)
954
-
955
- const multi1Diff = diffs.find((d) => d.file === "multi1.txt")
956
- expect(multi1Diff).toBeDefined()
957
- expect(multi1Diff!.additions).toBe(3)
958
- expect(multi1Diff!.deletions).toBe(0)
959
-
960
- const multi2Diff = diffs.find((d) => d.file === "multi2.txt")
961
- expect(multi2Diff).toBeDefined()
962
- expect(multi2Diff!.additions).toBe(1)
963
- expect(multi2Diff!.deletions).toBe(0)
964
-
965
- const removedADiff = diffs.find((d) => d.file === "a.txt")
966
- expect(removedADiff).toBeDefined()
967
- expect(removedADiff!.additions).toBe(0)
968
- expect(removedADiff!.deletions).toBe(1)
969
-
970
- const removedBDiff = diffs.find((d) => d.file === "b.txt")
971
- expect(removedBDiff).toBeDefined()
972
- expect(removedBDiff!.additions).toBe(0)
973
- expect(removedBDiff!.deletions).toBe(1)
974
- },
975
- })
976
- })
977
-
978
- test("diffFull with no changes", async () => {
979
- await using tmp = await bootstrap()
980
- await Instance.provide({
981
- directory: tmp.path,
982
- fn: async () => {
983
- const before = await Snapshot.track()
984
- expect(before).toBeTruthy()
985
-
986
- const after = await Snapshot.track()
987
- expect(after).toBeTruthy()
988
-
989
- const diffs = await Snapshot.diffFull(before!, after!)
990
- expect(diffs.length).toBe(0)
991
- },
992
- })
993
- })
994
-
995
- test("diffFull with binary file changes", async () => {
996
- await using tmp = await bootstrap()
997
- await Instance.provide({
998
- directory: tmp.path,
999
- fn: async () => {
1000
- const before = await Snapshot.track()
1001
- expect(before).toBeTruthy()
1002
-
1003
- await Bun.write(`${tmp.path}/binary.bin`, new Uint8Array([0x00, 0x01, 0x02, 0x03]))
1004
-
1005
- const after = await Snapshot.track()
1006
- expect(after).toBeTruthy()
1007
-
1008
- const diffs = await Snapshot.diffFull(before!, after!)
1009
- expect(diffs.length).toBe(1)
1010
-
1011
- const binaryDiff = diffs[0]
1012
- expect(binaryDiff.file).toBe("binary.bin")
1013
- expect(binaryDiff.before).toBe("")
1014
- },
1015
- })
1016
- })
1017
-
1018
- test("diffFull with whitespace changes", async () => {
1019
- await using tmp = await bootstrap()
1020
- await Instance.provide({
1021
- directory: tmp.path,
1022
- fn: async () => {
1023
- await Bun.write(`${tmp.path}/whitespace.txt`, "line1\nline2")
1024
- const before = await Snapshot.track()
1025
- expect(before).toBeTruthy()
1026
-
1027
- await Bun.write(`${tmp.path}/whitespace.txt`, "line1\n\nline2\n")
1028
-
1029
- const after = await Snapshot.track()
1030
- expect(after).toBeTruthy()
1031
-
1032
- const diffs = await Snapshot.diffFull(before!, after!)
1033
- expect(diffs.length).toBe(1)
1034
-
1035
- const whitespaceDiff = diffs[0]
1036
- expect(whitespaceDiff.file).toBe("whitespace.txt")
1037
- expect(whitespaceDiff.additions).toBeGreaterThan(0)
1038
- },
1039
- })
1040
- })