@smthrs/std 0.0.0-stage → 1.0.0-rc.12

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 (582) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/LICENSE +21 -0
  3. package/README.md +156 -2
  4. package/dist/cjs/ApplyPatch.d.ts +174 -0
  5. package/dist/cjs/ApplyPatch.d.ts.map +1 -0
  6. package/dist/cjs/ApplyPatch.js +309 -0
  7. package/dist/cjs/ApplyPatch.js.map +7 -0
  8. package/dist/cjs/Bash.d.ts +390 -0
  9. package/dist/cjs/Bash.d.ts.map +1 -0
  10. package/dist/cjs/Bash.js +333 -0
  11. package/dist/cjs/Bash.js.map +7 -0
  12. package/dist/cjs/Checkpoints.d.ts +322 -0
  13. package/dist/cjs/Checkpoints.d.ts.map +1 -0
  14. package/dist/cjs/Checkpoints.js +233 -0
  15. package/dist/cjs/Checkpoints.js.map +7 -0
  16. package/dist/cjs/Container.d.ts +132 -0
  17. package/dist/cjs/Container.d.ts.map +1 -0
  18. package/dist/cjs/Container.js +113 -0
  19. package/dist/cjs/Container.js.map +7 -0
  20. package/dist/cjs/Edit.d.ts +203 -0
  21. package/dist/cjs/Edit.d.ts.map +1 -0
  22. package/dist/cjs/Edit.js +258 -0
  23. package/dist/cjs/Edit.js.map +7 -0
  24. package/dist/cjs/ExaWebSearch.d.ts +22 -0
  25. package/dist/cjs/ExaWebSearch.d.ts.map +1 -0
  26. package/dist/cjs/ExaWebSearch.js +138 -0
  27. package/dist/cjs/ExaWebSearch.js.map +7 -0
  28. package/dist/cjs/Explore.d.ts +328 -0
  29. package/dist/cjs/Explore.d.ts.map +1 -0
  30. package/dist/cjs/Explore.js +90 -0
  31. package/dist/cjs/Explore.js.map +7 -0
  32. package/dist/cjs/Fetch.d.ts +130 -0
  33. package/dist/cjs/Fetch.d.ts.map +1 -0
  34. package/dist/cjs/Fetch.js +64 -0
  35. package/dist/cjs/Fetch.js.map +7 -0
  36. package/dist/cjs/Glob.d.ts +204 -0
  37. package/dist/cjs/Glob.d.ts.map +1 -0
  38. package/dist/cjs/Glob.js +94 -0
  39. package/dist/cjs/Glob.js.map +7 -0
  40. package/dist/cjs/Grep.d.ts +347 -0
  41. package/dist/cjs/Grep.d.ts.map +1 -0
  42. package/dist/cjs/Grep.js +181 -0
  43. package/dist/cjs/Grep.js.map +7 -0
  44. package/dist/cjs/HttpPost.d.ts +130 -0
  45. package/dist/cjs/HttpPost.d.ts.map +1 -0
  46. package/dist/cjs/HttpPost.js +72 -0
  47. package/dist/cjs/HttpPost.js.map +7 -0
  48. package/dist/cjs/LanguageServer.d.ts +90 -0
  49. package/dist/cjs/LanguageServer.d.ts.map +1 -0
  50. package/dist/cjs/LanguageServer.js +60 -0
  51. package/dist/cjs/LanguageServer.js.map +7 -0
  52. package/dist/cjs/Ls.d.ts +164 -0
  53. package/dist/cjs/Ls.d.ts.map +1 -0
  54. package/dist/cjs/Ls.js +136 -0
  55. package/dist/cjs/Ls.js.map +7 -0
  56. package/dist/cjs/Lsp.d.ts +125 -0
  57. package/dist/cjs/Lsp.d.ts.map +1 -0
  58. package/dist/cjs/Lsp.js +137 -0
  59. package/dist/cjs/Lsp.js.map +7 -0
  60. package/dist/cjs/Manifest.d.ts +918 -0
  61. package/dist/cjs/Manifest.d.ts.map +1 -0
  62. package/dist/cjs/Manifest.js +144 -0
  63. package/dist/cjs/Manifest.js.map +7 -0
  64. package/dist/cjs/NativeSearch.d.ts +38 -0
  65. package/dist/cjs/NativeSearch.d.ts.map +1 -0
  66. package/dist/cjs/NativeSearch.js +326 -0
  67. package/dist/cjs/NativeSearch.js.map +7 -0
  68. package/dist/cjs/NodeLanguageServer.d.ts +128 -0
  69. package/dist/cjs/NodeLanguageServer.d.ts.map +1 -0
  70. package/dist/cjs/NodeLanguageServer.js +796 -0
  71. package/dist/cjs/NodeLanguageServer.js.map +7 -0
  72. package/dist/cjs/PortableSearch.d.ts +36 -0
  73. package/dist/cjs/PortableSearch.d.ts.map +1 -0
  74. package/dist/cjs/PortableSearch.js +240 -0
  75. package/dist/cjs/PortableSearch.js.map +7 -0
  76. package/dist/cjs/Probe.d.ts +193 -0
  77. package/dist/cjs/Probe.d.ts.map +1 -0
  78. package/dist/cjs/Probe.js +134 -0
  79. package/dist/cjs/Probe.js.map +7 -0
  80. package/dist/cjs/Read.d.ts +189 -0
  81. package/dist/cjs/Read.d.ts.map +1 -0
  82. package/dist/cjs/Read.js +223 -0
  83. package/dist/cjs/Read.js.map +7 -0
  84. package/dist/cjs/Relocate.d.ts +73 -0
  85. package/dist/cjs/Relocate.d.ts.map +1 -0
  86. package/dist/cjs/Relocate.js +72 -0
  87. package/dist/cjs/Relocate.js.map +7 -0
  88. package/dist/cjs/RemoteSearch.d.ts +54 -0
  89. package/dist/cjs/RemoteSearch.d.ts.map +1 -0
  90. package/dist/cjs/RemoteSearch.js +134 -0
  91. package/dist/cjs/RemoteSearch.js.map +7 -0
  92. package/dist/cjs/Search.d.ts +163 -0
  93. package/dist/cjs/Search.d.ts.map +1 -0
  94. package/dist/cjs/Search.js +51 -0
  95. package/dist/cjs/Search.js.map +7 -0
  96. package/dist/cjs/SearchConformance.d.ts +115 -0
  97. package/dist/cjs/SearchConformance.d.ts.map +1 -0
  98. package/dist/cjs/SearchConformance.js +172 -0
  99. package/dist/cjs/SearchConformance.js.map +7 -0
  100. package/dist/cjs/SearchContract.d.ts +114 -0
  101. package/dist/cjs/SearchContract.d.ts.map +1 -0
  102. package/dist/cjs/SearchContract.js +339 -0
  103. package/dist/cjs/SearchContract.js.map +7 -0
  104. package/dist/cjs/ShellCommand.d.ts +164 -0
  105. package/dist/cjs/ShellCommand.d.ts.map +1 -0
  106. package/dist/cjs/ShellCommand.js +102 -0
  107. package/dist/cjs/ShellCommand.js.map +7 -0
  108. package/dist/cjs/StdError.d.ts +55 -0
  109. package/dist/cjs/StdError.d.ts.map +1 -0
  110. package/dist/cjs/StdError.js +74 -0
  111. package/dist/cjs/StdError.js.map +7 -0
  112. package/dist/cjs/TestRun.d.ts +311 -0
  113. package/dist/cjs/TestRun.d.ts.map +1 -0
  114. package/dist/cjs/TestRun.js +228 -0
  115. package/dist/cjs/TestRun.js.map +7 -0
  116. package/dist/cjs/TestRunner.d.ts +102 -0
  117. package/dist/cjs/TestRunner.d.ts.map +1 -0
  118. package/dist/cjs/TestRunner.js +54 -0
  119. package/dist/cjs/TestRunner.js.map +7 -0
  120. package/dist/cjs/TreeFingerprint.d.ts +140 -0
  121. package/dist/cjs/TreeFingerprint.d.ts.map +1 -0
  122. package/dist/cjs/TreeFingerprint.js +87 -0
  123. package/dist/cjs/TreeFingerprint.js.map +7 -0
  124. package/dist/cjs/UpdatePlan.d.ts +152 -0
  125. package/dist/cjs/UpdatePlan.d.ts.map +1 -0
  126. package/dist/cjs/UpdatePlan.js +87 -0
  127. package/dist/cjs/UpdatePlan.js.map +7 -0
  128. package/dist/cjs/WebFetch.d.ts +134 -0
  129. package/dist/cjs/WebFetch.d.ts.map +1 -0
  130. package/dist/cjs/WebFetch.js +140 -0
  131. package/dist/cjs/WebFetch.js.map +7 -0
  132. package/dist/cjs/WebSearch.d.ts +181 -0
  133. package/dist/cjs/WebSearch.d.ts.map +1 -0
  134. package/dist/cjs/WebSearch.js +86 -0
  135. package/dist/cjs/WebSearch.js.map +7 -0
  136. package/dist/cjs/Write.d.ts +147 -0
  137. package/dist/cjs/Write.d.ts.map +1 -0
  138. package/dist/cjs/Write.js +122 -0
  139. package/dist/cjs/Write.js.map +7 -0
  140. package/dist/cjs/index.d.ts +129 -0
  141. package/dist/cjs/index.d.ts.map +1 -0
  142. package/dist/cjs/index.js +101 -0
  143. package/dist/cjs/index.js.map +7 -0
  144. package/dist/cjs/internal/ApplyPatch.d.ts +145 -0
  145. package/dist/cjs/internal/ApplyPatch.d.ts.map +1 -0
  146. package/dist/cjs/internal/ApplyPatch.js +462 -0
  147. package/dist/cjs/internal/ApplyPatch.js.map +7 -0
  148. package/dist/cjs/internal/CodexText.d.ts +73 -0
  149. package/dist/cjs/internal/CodexText.d.ts.map +1 -0
  150. package/dist/cjs/internal/CodexText.js +108 -0
  151. package/dist/cjs/internal/CodexText.js.map +7 -0
  152. package/dist/cjs/internal/Declaration.d.ts +49 -0
  153. package/dist/cjs/internal/Declaration.d.ts.map +1 -0
  154. package/dist/cjs/internal/Declaration.js +46 -0
  155. package/dist/cjs/internal/Declaration.js.map +7 -0
  156. package/dist/cjs/internal/Diagnostics.d.ts +77 -0
  157. package/dist/cjs/internal/Diagnostics.d.ts.map +1 -0
  158. package/dist/cjs/internal/Diagnostics.js +89 -0
  159. package/dist/cjs/internal/Diagnostics.js.map +7 -0
  160. package/dist/cjs/internal/EnvelopePrecheck.d.ts +69 -0
  161. package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -0
  162. package/dist/cjs/internal/EnvelopePrecheck.js +323 -0
  163. package/dist/cjs/internal/EnvelopePrecheck.js.map +7 -0
  164. package/dist/cjs/internal/Exec.d.ts +151 -0
  165. package/dist/cjs/internal/Exec.d.ts.map +1 -0
  166. package/dist/cjs/internal/Exec.js +207 -0
  167. package/dist/cjs/internal/Exec.js.map +7 -0
  168. package/dist/cjs/internal/FileMutation.d.ts +109 -0
  169. package/dist/cjs/internal/FileMutation.d.ts.map +1 -0
  170. package/dist/cjs/internal/FileMutation.js +116 -0
  171. package/dist/cjs/internal/FileMutation.js.map +7 -0
  172. package/dist/cjs/internal/FsFailure.d.ts +38 -0
  173. package/dist/cjs/internal/FsFailure.d.ts.map +1 -0
  174. package/dist/cjs/internal/FsFailure.js +40 -0
  175. package/dist/cjs/internal/FsFailure.js.map +7 -0
  176. package/dist/cjs/internal/GitWorktree.d.ts +108 -0
  177. package/dist/cjs/internal/GitWorktree.d.ts.map +1 -0
  178. package/dist/cjs/internal/GitWorktree.js +276 -0
  179. package/dist/cjs/internal/GitWorktree.js.map +7 -0
  180. package/dist/cjs/internal/Grouping.d.ts +51 -0
  181. package/dist/cjs/internal/Grouping.d.ts.map +1 -0
  182. package/dist/cjs/internal/Grouping.js +83 -0
  183. package/dist/cjs/internal/Grouping.js.map +7 -0
  184. package/dist/cjs/internal/Html.d.ts +20 -0
  185. package/dist/cjs/internal/Html.d.ts.map +1 -0
  186. package/dist/cjs/internal/Html.js +81 -0
  187. package/dist/cjs/internal/Html.js.map +7 -0
  188. package/dist/cjs/internal/Http.d.ts +95 -0
  189. package/dist/cjs/internal/Http.d.ts.map +1 -0
  190. package/dist/cjs/internal/Http.js +153 -0
  191. package/dist/cjs/internal/Http.js.map +7 -0
  192. package/dist/cjs/internal/HttpNetwork.d.ts +27 -0
  193. package/dist/cjs/internal/HttpNetwork.d.ts.map +1 -0
  194. package/dist/cjs/internal/HttpNetwork.js +146 -0
  195. package/dist/cjs/internal/HttpNetwork.js.map +7 -0
  196. package/dist/cjs/internal/Ignore.d.ts +37 -0
  197. package/dist/cjs/internal/Ignore.d.ts.map +1 -0
  198. package/dist/cjs/internal/Ignore.js +100 -0
  199. package/dist/cjs/internal/Ignore.js.map +7 -0
  200. package/dist/cjs/internal/LinearRegex.d.ts +19 -0
  201. package/dist/cjs/internal/LinearRegex.d.ts.map +1 -0
  202. package/dist/cjs/internal/LinearRegex.js +166 -0
  203. package/dist/cjs/internal/LinearRegex.js.map +7 -0
  204. package/dist/cjs/internal/Match.d.ts +85 -0
  205. package/dist/cjs/internal/Match.d.ts.map +1 -0
  206. package/dist/cjs/internal/Match.js +99 -0
  207. package/dist/cjs/internal/Match.js.map +7 -0
  208. package/dist/cjs/internal/Paths.d.ts +23 -0
  209. package/dist/cjs/internal/Paths.d.ts.map +1 -0
  210. package/dist/cjs/internal/Paths.js +52 -0
  211. package/dist/cjs/internal/Paths.js.map +7 -0
  212. package/dist/cjs/internal/Preserve.d.ts +25 -0
  213. package/dist/cjs/internal/Preserve.d.ts.map +1 -0
  214. package/dist/cjs/internal/Preserve.js +88 -0
  215. package/dist/cjs/internal/Preserve.js.map +7 -0
  216. package/dist/cjs/internal/Prune.d.ts +35 -0
  217. package/dist/cjs/internal/Prune.d.ts.map +1 -0
  218. package/dist/cjs/internal/Prune.js +54 -0
  219. package/dist/cjs/internal/Prune.js.map +7 -0
  220. package/dist/cjs/internal/RemoteTree.d.ts +60 -0
  221. package/dist/cjs/internal/RemoteTree.d.ts.map +1 -0
  222. package/dist/cjs/internal/RemoteTree.js +123 -0
  223. package/dist/cjs/internal/RemoteTree.js.map +7 -0
  224. package/dist/cjs/internal/SearchContract.d.ts +63 -0
  225. package/dist/cjs/internal/SearchContract.d.ts.map +1 -0
  226. package/dist/cjs/internal/SearchContract.js +46 -0
  227. package/dist/cjs/internal/SearchContract.js.map +7 -0
  228. package/dist/cjs/internal/Symbols.d.ts +39 -0
  229. package/dist/cjs/internal/Symbols.d.ts.map +1 -0
  230. package/dist/cjs/internal/Symbols.js +59 -0
  231. package/dist/cjs/internal/Symbols.js.map +7 -0
  232. package/dist/cjs/internal/Tar.d.ts +23 -0
  233. package/dist/cjs/internal/Tar.d.ts.map +1 -0
  234. package/dist/cjs/internal/Tar.js +86 -0
  235. package/dist/cjs/internal/Tar.js.map +7 -0
  236. package/dist/cjs/internal/TestReport.d.ts +52 -0
  237. package/dist/cjs/internal/TestReport.d.ts.map +1 -0
  238. package/dist/cjs/internal/TestReport.js +131 -0
  239. package/dist/cjs/internal/TestReport.js.map +7 -0
  240. package/dist/cjs/internal/Text.d.ts +125 -0
  241. package/dist/cjs/internal/Text.d.ts.map +1 -0
  242. package/dist/cjs/internal/Text.js +85 -0
  243. package/dist/cjs/internal/Text.js.map +7 -0
  244. package/dist/cjs/internal/Url.d.ts +13 -0
  245. package/dist/cjs/internal/Url.d.ts.map +1 -0
  246. package/dist/cjs/internal/Url.js +35 -0
  247. package/dist/cjs/internal/Url.js.map +7 -0
  248. package/dist/cjs/internal/Walk.d.ts +72 -0
  249. package/dist/cjs/internal/Walk.d.ts.map +1 -0
  250. package/dist/cjs/internal/Walk.js +108 -0
  251. package/dist/cjs/internal/Walk.js.map +7 -0
  252. package/dist/cjs/package.json +1 -0
  253. package/dist/esm/ApplyPatch.d.ts +174 -0
  254. package/dist/esm/ApplyPatch.d.ts.map +1 -0
  255. package/dist/esm/ApplyPatch.js +346 -0
  256. package/dist/esm/ApplyPatch.js.map +1 -0
  257. package/dist/esm/Bash.d.ts +390 -0
  258. package/dist/esm/Bash.d.ts.map +1 -0
  259. package/dist/esm/Bash.js +514 -0
  260. package/dist/esm/Bash.js.map +1 -0
  261. package/dist/esm/Checkpoints.d.ts +322 -0
  262. package/dist/esm/Checkpoints.d.ts.map +1 -0
  263. package/dist/esm/Checkpoints.js +396 -0
  264. package/dist/esm/Checkpoints.js.map +1 -0
  265. package/dist/esm/Container.d.ts +132 -0
  266. package/dist/esm/Container.d.ts.map +1 -0
  267. package/dist/esm/Container.js +151 -0
  268. package/dist/esm/Container.js.map +1 -0
  269. package/dist/esm/Edit.d.ts +203 -0
  270. package/dist/esm/Edit.d.ts.map +1 -0
  271. package/dist/esm/Edit.js +296 -0
  272. package/dist/esm/Edit.js.map +1 -0
  273. package/dist/esm/ExaWebSearch.d.ts +22 -0
  274. package/dist/esm/ExaWebSearch.d.ts.map +1 -0
  275. package/dist/esm/ExaWebSearch.js +107 -0
  276. package/dist/esm/ExaWebSearch.js.map +1 -0
  277. package/dist/esm/Explore.d.ts +328 -0
  278. package/dist/esm/Explore.d.ts.map +1 -0
  279. package/dist/esm/Explore.js +106 -0
  280. package/dist/esm/Explore.js.map +1 -0
  281. package/dist/esm/Fetch.d.ts +130 -0
  282. package/dist/esm/Fetch.d.ts.map +1 -0
  283. package/dist/esm/Fetch.js +91 -0
  284. package/dist/esm/Fetch.js.map +1 -0
  285. package/dist/esm/Glob.d.ts +204 -0
  286. package/dist/esm/Glob.d.ts.map +1 -0
  287. package/dist/esm/Glob.js +177 -0
  288. package/dist/esm/Glob.js.map +1 -0
  289. package/dist/esm/Grep.d.ts +347 -0
  290. package/dist/esm/Grep.d.ts.map +1 -0
  291. package/dist/esm/Grep.js +289 -0
  292. package/dist/esm/Grep.js.map +1 -0
  293. package/dist/esm/HttpPost.d.ts +130 -0
  294. package/dist/esm/HttpPost.d.ts.map +1 -0
  295. package/dist/esm/HttpPost.js +89 -0
  296. package/dist/esm/HttpPost.js.map +1 -0
  297. package/dist/esm/LanguageServer.d.ts +90 -0
  298. package/dist/esm/LanguageServer.d.ts.map +1 -0
  299. package/dist/esm/LanguageServer.js +57 -0
  300. package/dist/esm/LanguageServer.js.map +1 -0
  301. package/dist/esm/Ls.d.ts +164 -0
  302. package/dist/esm/Ls.d.ts.map +1 -0
  303. package/dist/esm/Ls.js +178 -0
  304. package/dist/esm/Ls.js.map +1 -0
  305. package/dist/esm/Lsp.d.ts +125 -0
  306. package/dist/esm/Lsp.d.ts.map +1 -0
  307. package/dist/esm/Lsp.js +165 -0
  308. package/dist/esm/Lsp.js.map +1 -0
  309. package/dist/esm/Manifest.d.ts +918 -0
  310. package/dist/esm/Manifest.d.ts.map +1 -0
  311. package/dist/esm/Manifest.js +153 -0
  312. package/dist/esm/Manifest.js.map +1 -0
  313. package/dist/esm/NativeSearch.d.ts +38 -0
  314. package/dist/esm/NativeSearch.d.ts.map +1 -0
  315. package/dist/esm/NativeSearch.js +378 -0
  316. package/dist/esm/NativeSearch.js.map +1 -0
  317. package/dist/esm/NodeLanguageServer.d.ts +128 -0
  318. package/dist/esm/NodeLanguageServer.d.ts.map +1 -0
  319. package/dist/esm/NodeLanguageServer.js +843 -0
  320. package/dist/esm/NodeLanguageServer.js.map +1 -0
  321. package/dist/esm/PortableSearch.d.ts +36 -0
  322. package/dist/esm/PortableSearch.d.ts.map +1 -0
  323. package/dist/esm/PortableSearch.js +256 -0
  324. package/dist/esm/PortableSearch.js.map +1 -0
  325. package/dist/esm/Probe.d.ts +193 -0
  326. package/dist/esm/Probe.d.ts.map +1 -0
  327. package/dist/esm/Probe.js +225 -0
  328. package/dist/esm/Probe.js.map +1 -0
  329. package/dist/esm/Read.d.ts +189 -0
  330. package/dist/esm/Read.d.ts.map +1 -0
  331. package/dist/esm/Read.js +300 -0
  332. package/dist/esm/Read.js.map +1 -0
  333. package/dist/esm/Relocate.d.ts +73 -0
  334. package/dist/esm/Relocate.d.ts.map +1 -0
  335. package/dist/esm/Relocate.js +153 -0
  336. package/dist/esm/Relocate.js.map +1 -0
  337. package/dist/esm/RemoteSearch.d.ts +54 -0
  338. package/dist/esm/RemoteSearch.d.ts.map +1 -0
  339. package/dist/esm/RemoteSearch.js +162 -0
  340. package/dist/esm/RemoteSearch.js.map +1 -0
  341. package/dist/esm/Search.d.ts +163 -0
  342. package/dist/esm/Search.d.ts.map +1 -0
  343. package/dist/esm/Search.js +47 -0
  344. package/dist/esm/Search.js.map +1 -0
  345. package/dist/esm/SearchConformance.d.ts +115 -0
  346. package/dist/esm/SearchConformance.d.ts.map +1 -0
  347. package/dist/esm/SearchConformance.js +193 -0
  348. package/dist/esm/SearchConformance.js.map +1 -0
  349. package/dist/esm/SearchContract.d.ts +114 -0
  350. package/dist/esm/SearchContract.d.ts.map +1 -0
  351. package/dist/esm/SearchContract.js +461 -0
  352. package/dist/esm/SearchContract.js.map +1 -0
  353. package/dist/esm/ShellCommand.d.ts +164 -0
  354. package/dist/esm/ShellCommand.d.ts.map +1 -0
  355. package/dist/esm/ShellCommand.js +159 -0
  356. package/dist/esm/ShellCommand.js.map +1 -0
  357. package/dist/esm/StdError.d.ts +55 -0
  358. package/dist/esm/StdError.d.ts.map +1 -0
  359. package/dist/esm/StdError.js +71 -0
  360. package/dist/esm/StdError.js.map +1 -0
  361. package/dist/esm/TestRun.d.ts +311 -0
  362. package/dist/esm/TestRun.d.ts.map +1 -0
  363. package/dist/esm/TestRun.js +316 -0
  364. package/dist/esm/TestRun.js.map +1 -0
  365. package/dist/esm/TestRunner.d.ts +102 -0
  366. package/dist/esm/TestRunner.d.ts.map +1 -0
  367. package/dist/esm/TestRunner.js +68 -0
  368. package/dist/esm/TestRunner.js.map +1 -0
  369. package/dist/esm/TreeFingerprint.d.ts +140 -0
  370. package/dist/esm/TreeFingerprint.d.ts.map +1 -0
  371. package/dist/esm/TreeFingerprint.js +170 -0
  372. package/dist/esm/TreeFingerprint.js.map +1 -0
  373. package/dist/esm/UpdatePlan.d.ts +152 -0
  374. package/dist/esm/UpdatePlan.d.ts.map +1 -0
  375. package/dist/esm/UpdatePlan.js +129 -0
  376. package/dist/esm/UpdatePlan.js.map +1 -0
  377. package/dist/esm/WebFetch.d.ts +134 -0
  378. package/dist/esm/WebFetch.d.ts.map +1 -0
  379. package/dist/esm/WebFetch.js +151 -0
  380. package/dist/esm/WebFetch.js.map +1 -0
  381. package/dist/esm/WebSearch.d.ts +181 -0
  382. package/dist/esm/WebSearch.d.ts.map +1 -0
  383. package/dist/esm/WebSearch.js +134 -0
  384. package/dist/esm/WebSearch.js.map +1 -0
  385. package/dist/esm/Write.d.ts +147 -0
  386. package/dist/esm/Write.d.ts.map +1 -0
  387. package/dist/esm/Write.js +144 -0
  388. package/dist/esm/Write.js.map +1 -0
  389. package/dist/esm/index.d.ts +129 -0
  390. package/dist/esm/index.d.ts.map +1 -0
  391. package/dist/esm/index.js +129 -0
  392. package/dist/esm/index.js.map +1 -0
  393. package/dist/esm/internal/ApplyPatch.d.ts +145 -0
  394. package/dist/esm/internal/ApplyPatch.d.ts.map +1 -0
  395. package/dist/esm/internal/ApplyPatch.js +489 -0
  396. package/dist/esm/internal/ApplyPatch.js.map +1 -0
  397. package/dist/esm/internal/CodexText.d.ts +73 -0
  398. package/dist/esm/internal/CodexText.d.ts.map +1 -0
  399. package/dist/esm/internal/CodexText.js +156 -0
  400. package/dist/esm/internal/CodexText.js.map +1 -0
  401. package/dist/esm/internal/Declaration.d.ts +49 -0
  402. package/dist/esm/internal/Declaration.d.ts.map +1 -0
  403. package/dist/esm/internal/Declaration.js +42 -0
  404. package/dist/esm/internal/Declaration.js.map +1 -0
  405. package/dist/esm/internal/Diagnostics.d.ts +77 -0
  406. package/dist/esm/internal/Diagnostics.d.ts.map +1 -0
  407. package/dist/esm/internal/Diagnostics.js +99 -0
  408. package/dist/esm/internal/Diagnostics.js.map +1 -0
  409. package/dist/esm/internal/EnvelopePrecheck.d.ts +69 -0
  410. package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -0
  411. package/dist/esm/internal/EnvelopePrecheck.js +426 -0
  412. package/dist/esm/internal/EnvelopePrecheck.js.map +1 -0
  413. package/dist/esm/internal/Exec.d.ts +151 -0
  414. package/dist/esm/internal/Exec.d.ts.map +1 -0
  415. package/dist/esm/internal/Exec.js +285 -0
  416. package/dist/esm/internal/Exec.js.map +1 -0
  417. package/dist/esm/internal/FileMutation.d.ts +109 -0
  418. package/dist/esm/internal/FileMutation.d.ts.map +1 -0
  419. package/dist/esm/internal/FileMutation.js +123 -0
  420. package/dist/esm/internal/FileMutation.js.map +1 -0
  421. package/dist/esm/internal/FsFailure.d.ts +38 -0
  422. package/dist/esm/internal/FsFailure.d.ts.map +1 -0
  423. package/dist/esm/internal/FsFailure.js +39 -0
  424. package/dist/esm/internal/FsFailure.js.map +1 -0
  425. package/dist/esm/internal/GitWorktree.d.ts +108 -0
  426. package/dist/esm/internal/GitWorktree.d.ts.map +1 -0
  427. package/dist/esm/internal/GitWorktree.js +352 -0
  428. package/dist/esm/internal/GitWorktree.js.map +1 -0
  429. package/dist/esm/internal/Grouping.d.ts +51 -0
  430. package/dist/esm/internal/Grouping.d.ts.map +1 -0
  431. package/dist/esm/internal/Grouping.js +99 -0
  432. package/dist/esm/internal/Grouping.js.map +1 -0
  433. package/dist/esm/internal/Html.d.ts +20 -0
  434. package/dist/esm/internal/Html.d.ts.map +1 -0
  435. package/dist/esm/internal/Html.js +70 -0
  436. package/dist/esm/internal/Html.js.map +1 -0
  437. package/dist/esm/internal/Http.d.ts +95 -0
  438. package/dist/esm/internal/Http.d.ts.map +1 -0
  439. package/dist/esm/internal/Http.js +154 -0
  440. package/dist/esm/internal/Http.js.map +1 -0
  441. package/dist/esm/internal/HttpNetwork.d.ts +27 -0
  442. package/dist/esm/internal/HttpNetwork.d.ts.map +1 -0
  443. package/dist/esm/internal/HttpNetwork.js +114 -0
  444. package/dist/esm/internal/HttpNetwork.js.map +1 -0
  445. package/dist/esm/internal/Ignore.d.ts +37 -0
  446. package/dist/esm/internal/Ignore.d.ts.map +1 -0
  447. package/dist/esm/internal/Ignore.js +128 -0
  448. package/dist/esm/internal/Ignore.js.map +1 -0
  449. package/dist/esm/internal/LinearRegex.d.ts +19 -0
  450. package/dist/esm/internal/LinearRegex.d.ts.map +1 -0
  451. package/dist/esm/internal/LinearRegex.js +176 -0
  452. package/dist/esm/internal/LinearRegex.js.map +1 -0
  453. package/dist/esm/internal/Match.d.ts +85 -0
  454. package/dist/esm/internal/Match.d.ts.map +1 -0
  455. package/dist/esm/internal/Match.js +142 -0
  456. package/dist/esm/internal/Match.js.map +1 -0
  457. package/dist/esm/internal/Paths.d.ts +23 -0
  458. package/dist/esm/internal/Paths.d.ts.map +1 -0
  459. package/dist/esm/internal/Paths.js +40 -0
  460. package/dist/esm/internal/Paths.js.map +1 -0
  461. package/dist/esm/internal/Preserve.d.ts +25 -0
  462. package/dist/esm/internal/Preserve.d.ts.map +1 -0
  463. package/dist/esm/internal/Preserve.js +70 -0
  464. package/dist/esm/internal/Preserve.js.map +1 -0
  465. package/dist/esm/internal/Prune.d.ts +35 -0
  466. package/dist/esm/internal/Prune.d.ts.map +1 -0
  467. package/dist/esm/internal/Prune.js +60 -0
  468. package/dist/esm/internal/Prune.js.map +1 -0
  469. package/dist/esm/internal/RemoteTree.d.ts +60 -0
  470. package/dist/esm/internal/RemoteTree.d.ts.map +1 -0
  471. package/dist/esm/internal/RemoteTree.js +132 -0
  472. package/dist/esm/internal/RemoteTree.js.map +1 -0
  473. package/dist/esm/internal/SearchContract.d.ts +63 -0
  474. package/dist/esm/internal/SearchContract.d.ts.map +1 -0
  475. package/dist/esm/internal/SearchContract.js +66 -0
  476. package/dist/esm/internal/SearchContract.js.map +1 -0
  477. package/dist/esm/internal/Symbols.d.ts +39 -0
  478. package/dist/esm/internal/Symbols.d.ts.map +1 -0
  479. package/dist/esm/internal/Symbols.js +79 -0
  480. package/dist/esm/internal/Symbols.js.map +1 -0
  481. package/dist/esm/internal/Tar.d.ts +23 -0
  482. package/dist/esm/internal/Tar.d.ts.map +1 -0
  483. package/dist/esm/internal/Tar.js +97 -0
  484. package/dist/esm/internal/Tar.js.map +1 -0
  485. package/dist/esm/internal/TestReport.d.ts +52 -0
  486. package/dist/esm/internal/TestReport.d.ts.map +1 -0
  487. package/dist/esm/internal/TestReport.js +172 -0
  488. package/dist/esm/internal/TestReport.js.map +1 -0
  489. package/dist/esm/internal/Text.d.ts +125 -0
  490. package/dist/esm/internal/Text.d.ts.map +1 -0
  491. package/dist/esm/internal/Text.js +141 -0
  492. package/dist/esm/internal/Text.js.map +1 -0
  493. package/dist/esm/internal/Url.d.ts +13 -0
  494. package/dist/esm/internal/Url.d.ts.map +1 -0
  495. package/dist/esm/internal/Url.js +27 -0
  496. package/dist/esm/internal/Url.js.map +1 -0
  497. package/dist/esm/internal/Walk.d.ts +72 -0
  498. package/dist/esm/internal/Walk.d.ts.map +1 -0
  499. package/dist/esm/internal/Walk.js +126 -0
  500. package/dist/esm/internal/Walk.js.map +1 -0
  501. package/docs/README.md +119 -0
  502. package/docs/api.md +499 -0
  503. package/docs/concepts/effects-and-capabilities.md +138 -0
  504. package/docs/concepts/flows-and-handlers.md +115 -0
  505. package/docs/concepts/limits-and-disclosure.md +105 -0
  506. package/docs/concepts/search-contract.md +182 -0
  507. package/docs/guides/bind-the-standard-flows.md +116 -0
  508. package/docs/guides/implement-a-search-peer.md +133 -0
  509. package/docs/guides/pin-a-checkpoint.md +161 -0
  510. package/docs/guides/query-a-language-server.md +257 -0
  511. package/docs/guides/reach-the-network.md +141 -0
  512. package/docs/guides/read-and-edit-a-file.md +240 -0
  513. package/docs/guides/run-a-shell-command.md +236 -0
  514. package/docs/guides/run-the-test-suite.md +154 -0
  515. package/docs/guides/search-a-workspace.md +148 -0
  516. package/docs/installation.md +115 -0
  517. package/docs/quickstart.md +125 -0
  518. package/docs/reference/flows.md +556 -0
  519. package/docs/troubleshooting.md +347 -0
  520. package/package.json +449 -3
  521. package/src/ApplyPatch.ts +458 -0
  522. package/src/Bash.ts +619 -0
  523. package/src/Checkpoints.ts +589 -0
  524. package/src/Container.ts +212 -0
  525. package/src/Edit.ts +366 -0
  526. package/src/ExaWebSearch.ts +145 -0
  527. package/src/Explore.ts +139 -0
  528. package/src/Fetch.ts +117 -0
  529. package/src/Glob.ts +200 -0
  530. package/src/Grep.ts +320 -0
  531. package/src/HttpPost.ts +120 -0
  532. package/src/LanguageServer.ts +110 -0
  533. package/src/Ls.ts +228 -0
  534. package/src/Lsp.ts +184 -0
  535. package/src/Manifest.ts +162 -0
  536. package/src/NativeSearch.ts +457 -0
  537. package/src/NodeLanguageServer.ts +1148 -0
  538. package/src/PortableSearch.ts +284 -0
  539. package/src/Probe.ts +284 -0
  540. package/src/Read.ts +359 -0
  541. package/src/Relocate.ts +166 -0
  542. package/src/RemoteSearch.ts +199 -0
  543. package/src/Search.ts +185 -0
  544. package/src/SearchConformance.ts +288 -0
  545. package/src/SearchContract.ts +489 -0
  546. package/src/ShellCommand.ts +201 -0
  547. package/src/StdError.ts +80 -0
  548. package/src/TestRun.ts +401 -0
  549. package/src/TestRunner.ts +119 -0
  550. package/src/TreeFingerprint.ts +200 -0
  551. package/src/UpdatePlan.ts +171 -0
  552. package/src/WebFetch.ts +194 -0
  553. package/src/WebSearch.ts +165 -0
  554. package/src/Write.ts +195 -0
  555. package/src/index.ts +157 -0
  556. package/src/internal/ApplyPatch.ts +601 -0
  557. package/src/internal/CodexText.ts +182 -0
  558. package/src/internal/Declaration.ts +60 -0
  559. package/src/internal/Diagnostics.ts +134 -0
  560. package/src/internal/EnvelopePrecheck.ts +489 -0
  561. package/src/internal/Exec.ts +427 -0
  562. package/src/internal/FileMutation.ts +231 -0
  563. package/src/internal/FsFailure.ts +51 -0
  564. package/src/internal/GitWorktree.ts +491 -0
  565. package/src/internal/Grouping.ts +106 -0
  566. package/src/internal/Html.ts +87 -0
  567. package/src/internal/Http.ts +209 -0
  568. package/src/internal/HttpNetwork.ts +153 -0
  569. package/src/internal/Ignore.ts +135 -0
  570. package/src/internal/LinearRegex.ts +173 -0
  571. package/src/internal/Match.ts +172 -0
  572. package/src/internal/Paths.ts +42 -0
  573. package/src/internal/Preserve.ts +108 -0
  574. package/src/internal/Prune.ts +62 -0
  575. package/src/internal/RemoteTree.ts +159 -0
  576. package/src/internal/SearchContract.ts +77 -0
  577. package/src/internal/Symbols.ts +88 -0
  578. package/src/internal/Tar.ts +95 -0
  579. package/src/internal/TestReport.ts +194 -0
  580. package/src/internal/Text.ts +185 -0
  581. package/src/internal/Url.ts +23 -0
  582. package/src/internal/Walk.ts +176 -0
@@ -0,0 +1,589 @@
1
+ /**
2
+ * Pinned trees, and the scratch checkouts a call runs against.
3
+ *
4
+ * A checkpoint is a **value**: minting one changes nothing about the workspace,
5
+ * and running a call against one leaves the live tree exactly as it stands.
6
+ * That is the whole of what it buys. Before it existed, the only way a run
7
+ * could answer "did this command fail before my change" was to undo the change
8
+ * — and the journals price that exactly. On `sympy__sympy-13878` the r95repl
9
+ * lane applied one byte-identical 4,789-character patch **five times**, four of
10
+ * those applications preceded by `git checkout -- sympy/stats/crv_types.py`,
11
+ * because a clean fails-before proof required reverting the very work it was
12
+ * meant to prove.
13
+ *
14
+ * This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and
15
+ * `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,
16
+ * the bound and the refusals; nothing in it knows what a tree is. This owns the
17
+ * two host operations that need one:
18
+ *
19
+ * - {@link Checkpoints.capture} records the working tree under an id, and
20
+ * - {@link Checkpoints.materialize} gives that tree back as a directory for the
21
+ * length of one call.
22
+ *
23
+ * ## The git binding, and the container constraint it is shaped by
24
+ *
25
+ * {@link layerGit} records a checkpoint with `git stash create`, then names the
26
+ * commit it prints in this repository's own git config rather than with a ref —
27
+ * see {@link configSection} for why a ref would hand the agent its own edit back
28
+ * as history. `stash create` is the one git command
29
+ * that records the working tree and changes nothing else: it does not move the
30
+ * worktree and does not touch the stash ref. It runs against a shadow
31
+ * `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),
32
+ * so it never writes the repository's index and never runs a program the
33
+ * workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same
34
+ * workspace and its own `git diff` is the run's evidence, so a capture that
35
+ * staged into the real index would be the harness editing the evidence while
36
+ * recording it. A tree with nothing to record prints nothing, and the
37
+ * checkpoint is then `HEAD` — which is exactly what the tree is.
38
+ *
39
+ * Untracked files are not in the recorded tree, which matches how the rig
40
+ * captures a patch: `capture-patch.sh` drops paths that did not exist when the
41
+ * agent started, so a checkpoint holds what a patch would hold.
42
+ *
43
+ * The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`
44
+ * — **inside** the workspace, which looks wrong and is the only thing that
45
+ * works. A benchmark check runs through `docker exec` inside `/testbed`, and
46
+ * `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere
47
+ * else on the host is simply not visible to the container, so the call would run
48
+ * against a path that does not exist. Placed under the workspace it is visible
49
+ * at the same subpath under the mount, needs no second mount, and needs no
50
+ * change to how the rig starts its container. `TestRun`'s `against: "base"`
51
+ * reached the same conclusion first and this reuses its shape;
52
+ * `evals/swebench/run-instance.sh` excludes the directory from patch capture for
53
+ * the same reason it excludes `.flows-test-base`.
54
+ *
55
+ * The checkout is added and removed around **one call**, which is stricter than
56
+ * the frame lifetime the design asks for and much simpler: there is no cache to
57
+ * invalidate, no id to leak, and a checkpoint used by three calls pays three
58
+ * checkouts rather than risking one stale directory. A run that reuses a
59
+ * checkpoint across frames simply re-materializes it, because the ref is what
60
+ * persists.
61
+ *
62
+ * ## What can be pointed at a checkpoint, and what cannot
63
+ *
64
+ * {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half
65
+ * knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half
66
+ * knows git. They change for different reasons, so they are different modules,
67
+ * and {@link relocate} is re-exported here because the harness reaches the whole
68
+ * feature through this one.
69
+ *
70
+ * @since 1.0.0
71
+ */
72
+
73
+ import { ChildProcessSpawner } from "@smthrs/kernel/ChildProcessSpawner"
74
+ import { Context, Effect, type Exit, Layer, Schema } from "effect"
75
+ import * as Container from "./Container.ts"
76
+ import * as Exec from "./internal/Exec.ts"
77
+ import { GitWorktree, type Repository } from "./internal/GitWorktree.ts"
78
+ import { withoutTrailingSlash } from "./internal/Paths.ts"
79
+ import * as Prune from "./internal/Prune.ts"
80
+ import * as StdError from "./StdError.ts"
81
+ import * as TestRunner from "./TestRunner.ts"
82
+
83
+ /**
84
+ * The id naming the tree a run opened on.
85
+ *
86
+ * It is not minted: the host either recorded one before the agent started or it
87
+ * did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and
88
+ * then to `HEAD`, which is the same precedence `TestRun` uses for the same
89
+ * question — so a workspace that has one answer for a baseline has one answer
90
+ * for both.
91
+ *
92
+ * @category constants
93
+ * @since 1.0.0
94
+ */
95
+ export const baseId = "base"
96
+
97
+ /**
98
+ * The directory checkpoints are materialized into, relative to the repository
99
+ * root and therefore also relative to a container's view of it.
100
+ *
101
+ * @category constants
102
+ * @since 1.0.0
103
+ */
104
+ export const scratchDirectory = Prune.checkpointScratch
105
+
106
+ /**
107
+ * The git-config section {@link layerGit} records minted checkpoints under.
108
+ *
109
+ * Config and **not a ref**, and that is the whole of the decision. A ref is
110
+ * history: `git log --all` lists it, `git show` prints it, and `git log --all
111
+ * -S` searches it — so a checkpoint named by a ref would hand an agent a commit
112
+ * containing its own edit and let it read that back as if it were upstream
113
+ * work. That exact class cost the measured program real money before the rig
114
+ * moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:
115
+ * django-13346 applied two of its own snapshots as a fake fix), and a ref here
116
+ * would reintroduce it one wave later.
117
+ *
118
+ * The commit object itself is unreferenced. It stays alive for the life of the
119
+ * run — nothing in a run prunes — and a checkout by id works perfectly well,
120
+ * which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable
121
+ * by id and no command that walks refs can reach it:
122
+ * `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer
123
+ * exactly as they did before the capture.
124
+ *
125
+ * One command still sees it, measured rather than argued in
126
+ * `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,
127
+ * because that is what an unreferenced commit is. A checkout is a standalone
128
+ * repository, not a worktree of this one, so `git log --all` does not list it
129
+ * even while a call runs in it. It is not reachable by a name that looks like project history, and the cell
130
+ * contract's environment section says outright that a dangling commit is this
131
+ * harness holding the agent's own tree — which is the half of the django-13346
132
+ * lesson that a store cannot enforce.
133
+ *
134
+ * @category constants
135
+ * @since 1.0.0
136
+ */
137
+ export const configSection = "flows-checkpoint"
138
+
139
+ /**
140
+ * One tree this run has pinned.
141
+ *
142
+ * `ref` is the store's own name for it. Nothing above this module interprets
143
+ * it; it travels so the journal says which tree a checkpointed call read.
144
+ *
145
+ * @category models
146
+ * @since 1.0.0
147
+ */
148
+ export class Snapshot extends Schema.Class<Snapshot>("@smthrs/std/Checkpoints/Snapshot")({
149
+ id: Schema.String,
150
+ ref: Schema.String
151
+ }) {}
152
+
153
+ /**
154
+ * A tree handed back as a directory, for the length of one call.
155
+ *
156
+ * `host` is where the process running on this machine finds it. `guest` is
157
+ * where a container finds the same directory, which is the same path when no
158
+ * container is in play. They differ exactly as `TestRunner.Runner`'s `cwd` and
159
+ * `root` differ, and for the same reason: one directory, two names.
160
+ *
161
+ * `root` and `guestRoot` are the workspace itself under those same two names.
162
+ * They travel because a call that named a directory *inside* the workspace has
163
+ * to keep it: a check that runs in `tests/` and is pointed at a checkpoint must
164
+ * run in the checkpoint's `tests/`, not at its top. Silently dropping that
165
+ * subpath is how a baseline comes back failing for a reason nobody chose, which
166
+ * is the one failure a checkpoint exists to make impossible.
167
+ *
168
+ * @category models
169
+ * @since 1.0.0
170
+ */
171
+ export interface Materialized {
172
+ readonly id: string
173
+ readonly host: string
174
+ readonly guest: string
175
+ /** The workspace this checkpoint is a tree of, as this machine names it. */
176
+ readonly root: string
177
+ /** The workspace as a container names it; the same as {@link Materialized.root} when none does. */
178
+ readonly guestRoot: string
179
+ }
180
+
181
+ /**
182
+ * The two host operations a checkpoint needs.
183
+ *
184
+ * @category services
185
+ * @since 1.0.0
186
+ */
187
+ export interface Checkpoints {
188
+ /** Records the working tree as it stands, under `id`. */
189
+ readonly capture: (id: string) => Effect.Effect<Snapshot, StdError.StdError>
190
+ /**
191
+ * Hands `id` back as a directory for the length of the effect it wraps.
192
+ *
193
+ * Scoped rather than returned, because the directory has to be removed
194
+ * however the call ends — a benchmark run killed at its wall-clock budget
195
+ * would otherwise leave a second checkout of the whole repository in a tree
196
+ * whose diff is the run's answer.
197
+ */
198
+ readonly materialize: <A, E, R>(
199
+ id: string,
200
+ use: (materialized: Materialized) => Effect.Effect<A, E, R>
201
+ ) => Effect.Effect<A, E | StdError.StdError, R>
202
+ }
203
+
204
+ /**
205
+ * The {@link Checkpoints} service tag.
206
+ *
207
+ * @category services
208
+ * @since 1.0.0
209
+ */
210
+ export const Checkpoints: Context.Service<Checkpoints, Checkpoints> = Context.Service("@smthrs/std/Checkpoints")
211
+
212
+ /**
213
+ * Builds a store from its two operations.
214
+ *
215
+ * @category constructors
216
+ * @since 1.0.0
217
+ */
218
+ export const make = (service: Checkpoints): Checkpoints => Checkpoints.of(service)
219
+
220
+ /**
221
+ * The refusal a host with nowhere to pin a tree answers with.
222
+ *
223
+ * @category errors
224
+ * @since 1.0.0
225
+ */
226
+ export const unavailable = (id: string): StdError.StdError =>
227
+ new StdError.StdError({
228
+ code: "provider_unavailable",
229
+ message: `This host pins no trees, so it holds no checkpoint "${id}". Take the reading on the live tree instead.`
230
+ })
231
+
232
+ /**
233
+ * Builds a store for a host that pins nothing.
234
+ *
235
+ * @category constructors
236
+ * @since 1.0.0
237
+ */
238
+ export const makeNoop = (): Checkpoints =>
239
+ make({
240
+ capture: (id) => Effect.fail(unavailable(id)),
241
+ materialize: (id) => Effect.fail(unavailable(id))
242
+ })
243
+
244
+ /**
245
+ * Provides {@link makeNoop}.
246
+ *
247
+ * @category layers
248
+ * @since 1.0.0
249
+ */
250
+ export const layerNoop: Layer.Layer<Checkpoints> = Layer.succeed(Checkpoints, makeNoop())
251
+
252
+ /**
253
+ * What {@link layerGit} needs to know about the repository it pins.
254
+ *
255
+ * @category models
256
+ * @since 1.0.0
257
+ */
258
+ export interface GitOptions {
259
+ /**
260
+ * The host path of the git repository whose trees are pinned.
261
+ *
262
+ * It is opened when the store is built. A root that was not a repository
263
+ * then pins nothing, and one whose `.git` later names another repository is
264
+ * refused with `permission_denied`.
265
+ */
266
+ readonly root: string
267
+ /**
268
+ * Where a container sees {@link GitOptions.root}, when one does.
269
+ *
270
+ * Absent means there is no container, and the guest path of a materialized
271
+ * checkpoint is then its host path.
272
+ */
273
+ readonly cwd?: string | undefined
274
+ /**
275
+ * The ref naming the tree the run opened on, for {@link baseId}.
276
+ *
277
+ * Absent takes `TestRunner.captureBase` and then `HEAD`, which is the
278
+ * precedence `TestRun` already uses.
279
+ */
280
+ readonly baseRef?: string | undefined
281
+ }
282
+
283
+ const failed = (message: string, code: StdError.Code = "command_failed"): StdError.StdError =>
284
+ new StdError.StdError({ code, message })
285
+
286
+ /**
287
+ * A checkpoint id, restricted to what can safely become a git-config key and a
288
+ * directory name. No dots: a dot would split the config key into another
289
+ * subsection.
290
+ */
291
+ const namable = /^[A-Za-z0-9][A-Za-z0-9-]*$/
292
+
293
+ /**
294
+ * Builds the git-backed store.
295
+ *
296
+ * Every git command that records or checks out a tree runs against a shadow
297
+ * `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent
298
+ * can write; see `internal/GitWorktree.ts`. The capture reads a copy of the
299
+ * workspace index, so the agent's own index is untouched: its `git diff` is the
300
+ * run's evidence and must not move because the harness recorded something.
301
+ *
302
+ * @category constructors
303
+ * @since 1.0.0
304
+ */
305
+ export const makeGit = (
306
+ options: GitOptions
307
+ ): Effect.Effect<Checkpoints, never, ChildProcessSpawner> =>
308
+ Effect.gen(function*() {
309
+ const spawner = yield* ChildProcessSpawner
310
+ // The host opens the repository before any agent runs. Its `.git` is the
311
+ // agent's to write, so what it names later can never choose another store.
312
+ const opened = yield* Effect.exit(
313
+ GitWorktree.open(withoutTrailingSlash(options.root)).pipe(Effect.provideService(ChildProcessSpawner, spawner))
314
+ )
315
+ return gitStore(options, spawner, opened)
316
+ })
317
+
318
+ /**
319
+ * The store itself, with the spawner it runs git through already resolved.
320
+ *
321
+ * Resolving it here rather than threading it through {@link Checkpoints} keeps
322
+ * the service's own requirement empty, which is what lets a browser host bind
323
+ * {@link layerNoop} against the identical interface — the same shape
324
+ * `TestRunner` and `Container` take.
325
+ */
326
+ const gitStore = (
327
+ options: GitOptions,
328
+ spawner: ChildProcessSpawner["Service"],
329
+ opened: Exit.Exit<Repository, StdError.StdError>
330
+ ): Checkpoints => {
331
+ const spawn = <A, E>(effect: Effect.Effect<A, E, ChildProcessSpawner>): Effect.Effect<A, E> =>
332
+ Effect.provideService(effect, ChildProcessSpawner, spawner)
333
+ const root = withoutTrailingSlash(options.root)
334
+
335
+ /** The repository the host opened, refused once the workspace names another. */
336
+ const repositoryOf = Effect.gen(function*() {
337
+ const bound = yield* opened
338
+ const current = yield* GitWorktree.open(root)
339
+ if (
340
+ current.toplevel !== bound.toplevel || current.common !== bound.common || current.index !== bound.index ||
341
+ current.objectFormat !== bound.objectFormat
342
+ ) {
343
+ return yield* Effect.fail(
344
+ failed(`${root} now names another git repository than the one this run opened.`, "permission_denied")
345
+ )
346
+ }
347
+ return current
348
+ })
349
+ const guestRoot = options.cwd === undefined ? root : withoutTrailingSlash(options.cwd)
350
+ const keyOf = (id: string) => `${configSection}.${id}`
351
+ const baseRefs = options.baseRef === undefined ? [TestRunner.captureBase, "HEAD"] : [options.baseRef]
352
+
353
+ /**
354
+ * The commit one id names.
355
+ *
356
+ * `base` is the one id nobody mints, so it is resolved from refs — the same
357
+ * precedence `TestRun` uses. Every other id was recorded by {@link capture}
358
+ * into this repository's config file, which is where a checkpoint is named
359
+ * *without* becoming history. See {@link configSection}.
360
+ */
361
+ const commitOf = (repository: Repository, id: string) =>
362
+ Effect.gen(function*() {
363
+ if (id === baseId) return (yield* GitWorktree.resolveCommit(root, baseRefs)).commit
364
+ const found = yield* GitWorktree.config(repository, ["--get", keyOf(id)])
365
+ const commit = found.stdout.trim()
366
+ if (found.exitCode !== 0 || commit === "") {
367
+ return yield* Effect.fail(
368
+ failed(
369
+ `No checkpoint is stored under ${id} in ${root}. Take the reading on the live tree instead.`,
370
+ "not_found"
371
+ )
372
+ )
373
+ }
374
+ return commit
375
+ })
376
+
377
+ const capture = (id: string) =>
378
+ spawn(Effect.gen(function*() {
379
+ if (!namable.test(id)) {
380
+ return yield* Effect.fail(
381
+ failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input")
382
+ )
383
+ }
384
+ const repository = yield* repositoryOf
385
+ const commit = yield* GitWorktree.withShadow(repository, (shadow) =>
386
+ Effect.gen(function*() {
387
+ const head = (yield* GitWorktree.resolveCommit(root, ["HEAD"])).commit
388
+ yield* shadow.adoptIndex
389
+ const pinned = yield* shadow.git(["update-ref", "--no-deref", "HEAD", head])
390
+ if (pinned.exitCode !== 0) {
391
+ return yield* Effect.fail(failed(`Could not record the working tree: ${pinned.stderr.trim()}`))
392
+ }
393
+ const recorded = yield* shadow.git(["stash", "create", `flows checkpoint ${id}`], root)
394
+ if (recorded.exitCode !== 0) {
395
+ return yield* Effect.fail(failed(`Could not record the working tree: ${recorded.stderr.trim()}`))
396
+ }
397
+ // Nothing to record means the working tree IS the commit it is on, so
398
+ // that commit is the checkpoint. `stash create` says so by printing
399
+ // nothing, which is not an error and must not be read as one.
400
+ return recorded.stdout.trim() === "" ? head : recorded.stdout.trim()
401
+ }))
402
+ const named = yield* GitWorktree.config(repository, [keyOf(id), commit])
403
+ if (named.exitCode !== 0) {
404
+ return yield* Effect.fail(failed(`Could not name the checkpoint: ${named.stderr.trim()}`))
405
+ }
406
+ return new Snapshot({ id, ref: commit })
407
+ }))
408
+
409
+ const materialize = <A, E, R>(
410
+ id: string,
411
+ use: (materialized: Materialized) => Effect.Effect<A, E, R>
412
+ ): Effect.Effect<A, E | StdError.StdError, R> =>
413
+ Effect.gen(function*() {
414
+ if (!namable.test(id)) {
415
+ return yield* Effect.fail(
416
+ failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input")
417
+ )
418
+ }
419
+ const repository = yield* spawn(repositoryOf)
420
+ const commit = yield* spawn(commitOf(repository, id))
421
+ const context = yield* Effect.context<R>()
422
+ return yield* GitWorktree.withDetachedWorktree(
423
+ repository,
424
+ `${scratchDirectory}/${id}`,
425
+ commit,
426
+ (host) =>
427
+ use({ id, host, guest: `${guestRoot}${host.slice(root.length)}`, root, guestRoot }).pipe(
428
+ Effect.provideContext(context)
429
+ )
430
+ ).pipe(Effect.provideService(ChildProcessSpawner, spawner))
431
+ })
432
+
433
+ return make({ capture, materialize })
434
+ }
435
+
436
+ /**
437
+ * Provides {@link makeGit}.
438
+ *
439
+ * @category layers
440
+ * @since 1.0.0
441
+ */
442
+ export const layerGit = (options: GitOptions): Layer.Layer<Checkpoints, never, ChildProcessSpawner> =>
443
+ Layer.effect(Checkpoints)(makeGit(options))
444
+
445
+ /**
446
+ * What {@link makeContainer} needs to know about the container it pins in.
447
+ *
448
+ * @category models
449
+ * @since 1.0.0-rc.8
450
+ */
451
+ export interface ContainerOptions {
452
+ /** The container `bash` runs in. */
453
+ readonly container: string
454
+ /** A directory of the repository inside it; absent is the container's own working directory. */
455
+ readonly cwd?: string | undefined
456
+ }
457
+
458
+ /**
459
+ * `$1` is the id. Records the working tree with `stash create` over a copy of
460
+ * the index, names the commit in config as {@link makeGit} does, and prints it.
461
+ */
462
+ const pinScript = [
463
+ "set -e",
464
+ "cd \"$(git rev-parse --show-toplevel)\"",
465
+ "copy=$(mktemp -d)",
466
+ "trap 'rm -rf -- \"$copy\"' EXIT",
467
+ "index=$(git rev-parse --git-path index)",
468
+ "if [ -e \"$index\" ]; then cp -p -- \"$index\" \"$copy/index\"; fi",
469
+ "commit=$(GIT_INDEX_FILE=\"$copy/index\" git -c user.name=flows -c user.email=flows@localhost stash create \"flows checkpoint $1\")",
470
+ "[ -n \"$commit\" ] || commit=$(git rev-parse --verify 'HEAD^{commit}')",
471
+ `git config "${configSection}.$1" "$commit"`,
472
+ "printf '%s\\n' \"$commit\""
473
+ ].join("\n")
474
+
475
+ /**
476
+ * `$1` is the id, `$2` the lease. Checks the tree out at
477
+ * `<top>/.flows-checkpoints/<id>-<lease>` in a repository of its own whose
478
+ * objects are the workspace's, and prints the top and the checkout.
479
+ */
480
+ const checkoutScript = [
481
+ "set -e",
482
+ "top=$(git rev-parse --show-toplevel)",
483
+ "cd \"$top\"",
484
+ "common=$(cd \"$(git rev-parse --git-common-dir)\" && pwd -P)",
485
+ `if [ "$1" = ${baseId} ]; then`,
486
+ ` commit=$(git rev-parse --verify --quiet '${TestRunner.captureBase}^{commit}' || git rev-parse --verify --quiet 'HEAD^{commit}') || { echo "No commit resolves from ${TestRunner.captureBase} or HEAD in $top." >&2; exit 1; }`,
487
+ "else",
488
+ ` commit=$(git config --get "${configSection}.$1") || { echo "No checkpoint is stored under $1 in $top. Take the reading on the live tree instead." >&2; exit 1; }`,
489
+ "fi",
490
+ `dir="$top/${scratchDirectory}/$1-$2"`,
491
+ "trap 'rm -rf -- \"$dir\"' EXIT",
492
+ `mkdir -p -- "$top/${scratchDirectory}"`,
493
+ "git init --quiet \"$dir\"",
494
+ "printf '%s/objects\\n' \"$common\" > \"$dir/.git/objects/info/alternates\"",
495
+ "git -C \"$dir\" checkout --quiet --detach \"$commit\"",
496
+ "trap - EXIT",
497
+ "printf '%s\\n%s\\n' \"$top\" \"$dir\""
498
+ ].join("\n")
499
+
500
+ /**
501
+ * Builds the store for a host whose `bash` runs in one container.
502
+ *
503
+ * The repository is the container's, so every git command runs there, through
504
+ * the same {@link Container.Container} transport `bash` takes. The host store
505
+ * looked in the CLI's own directory instead and refused every `at` in 112 of
506
+ * 123 trials of the 2026-10-14 SWE-bench Pro run. This keeps that store's
507
+ * shape: a checkpoint is a `stash create` commit named in config, and a tree
508
+ * is checked out under the repository for one call, so a relocated `bash`
509
+ * call keeps its subdirectory and still finds what the workspace installs
510
+ * beside it. That git may run what the repository configures, but only inside
511
+ * the container the agent already commands.
512
+ *
513
+ * @category constructors
514
+ * @since 1.0.0-rc.8
515
+ */
516
+ export const makeContainer = (
517
+ options: ContainerOptions
518
+ ): Effect.Effect<Checkpoints, never, ChildProcessSpawner | Container.Container> =>
519
+ Effect.gen(function*() {
520
+ const spawner = yield* ChildProcessSpawner
521
+ const transport = yield* Container.Container
522
+ const sh = (script: string, args: ReadonlyArray<string>) =>
523
+ transport.exec({
524
+ container: options.container,
525
+ file: "sh",
526
+ args: ["-c", script, "sh", ...args],
527
+ cwd: options.cwd,
528
+ stdin: false
529
+ }).pipe(
530
+ Effect.flatMap((plan) =>
531
+ Exec.exec(plan.file, { args: plan.args, env: plan.env }).pipe(
532
+ Effect.mapError((error) => Exec.toStdError(plan.file, error))
533
+ )
534
+ ),
535
+ Effect.flatMap((result) =>
536
+ result.exitCode === 0
537
+ ? Effect.succeed(result.stdout.trim().split("\n"))
538
+ : Effect.fail(failed(`git in container ${options.container} failed: ${result.stderr.trim()}`))
539
+ ),
540
+ Effect.provideService(ChildProcessSpawner, spawner)
541
+ )
542
+ const named = (id: string) =>
543
+ namable.test(id)
544
+ ? Effect.void
545
+ : Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input"))
546
+ return make({
547
+ capture: (id) =>
548
+ named(id).pipe(
549
+ Effect.andThen(sh(pinScript, [id])),
550
+ Effect.map(([commit]) => new Snapshot({ id, ref: commit! }))
551
+ ),
552
+ materialize: (id, use) =>
553
+ named(id).pipe(Effect.andThen(Effect.acquireUseRelease(
554
+ sh(checkoutScript, [id, globalThis.crypto.randomUUID()]),
555
+ ([root, checkout]) => use({ id, host: checkout!, guest: checkout!, root: root!, guestRoot: root! }),
556
+ ([, checkout]) =>
557
+ sh("rm -rf -- \"$1\"", [checkout!]).pipe(
558
+ Effect.catch((error) =>
559
+ Effect.logWarning("could not remove a scratch checkout").pipe(
560
+ Effect.annotateLogs({ path: checkout, reason: error.message })
561
+ )
562
+ )
563
+ )
564
+ )))
565
+ })
566
+ })
567
+
568
+ /**
569
+ * Provides {@link makeContainer}.
570
+ *
571
+ * @category layers
572
+ * @since 1.0.0-rc.8
573
+ */
574
+ export const layerContainer = (
575
+ options: ContainerOptions
576
+ ): Layer.Layer<Checkpoints, never, ChildProcessSpawner | Container.Container> =>
577
+ Layer.effect(Checkpoints)(makeContainer(options))
578
+
579
+ /**
580
+ * Rewrites one call's input so the call runs against a materialized checkpoint.
581
+ *
582
+ * Re-exported from {@link Relocate}, which owns the table of flows and fields
583
+ * this rewrite is driven by. It is exported here because the harness reaches the
584
+ * whole checkpoint feature through this module.
585
+ *
586
+ * @category conversions
587
+ * @since 1.0.0
588
+ */
589
+ export { relocate, type Relocation } from "./Relocate.ts"