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

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 (555) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/LICENSE +21 -0
  3. package/README.md +152 -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 +380 -0
  9. package/dist/cjs/Bash.d.ts.map +1 -0
  10. package/dist/cjs/Bash.js +332 -0
  11. package/dist/cjs/Bash.js.map +7 -0
  12. package/dist/cjs/Checkpoints.d.ts +279 -0
  13. package/dist/cjs/Checkpoints.d.ts.map +1 -0
  14. package/dist/cjs/Checkpoints.js +145 -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 +24 -0
  73. package/dist/cjs/PortableSearch.d.ts.map +1 -0
  74. package/dist/cjs/PortableSearch.js +233 -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/Search.d.ts +163 -0
  89. package/dist/cjs/Search.d.ts.map +1 -0
  90. package/dist/cjs/Search.js +51 -0
  91. package/dist/cjs/Search.js.map +7 -0
  92. package/dist/cjs/SearchConformance.d.ts +115 -0
  93. package/dist/cjs/SearchConformance.d.ts.map +1 -0
  94. package/dist/cjs/SearchConformance.js +172 -0
  95. package/dist/cjs/SearchConformance.js.map +7 -0
  96. package/dist/cjs/SearchContract.d.ts +114 -0
  97. package/dist/cjs/SearchContract.d.ts.map +1 -0
  98. package/dist/cjs/SearchContract.js +339 -0
  99. package/dist/cjs/SearchContract.js.map +7 -0
  100. package/dist/cjs/ShellCommand.d.ts +164 -0
  101. package/dist/cjs/ShellCommand.d.ts.map +1 -0
  102. package/dist/cjs/ShellCommand.js +102 -0
  103. package/dist/cjs/ShellCommand.js.map +7 -0
  104. package/dist/cjs/StdError.d.ts +55 -0
  105. package/dist/cjs/StdError.d.ts.map +1 -0
  106. package/dist/cjs/StdError.js +74 -0
  107. package/dist/cjs/StdError.js.map +7 -0
  108. package/dist/cjs/TestRun.d.ts +311 -0
  109. package/dist/cjs/TestRun.d.ts.map +1 -0
  110. package/dist/cjs/TestRun.js +228 -0
  111. package/dist/cjs/TestRun.js.map +7 -0
  112. package/dist/cjs/TestRunner.d.ts +102 -0
  113. package/dist/cjs/TestRunner.d.ts.map +1 -0
  114. package/dist/cjs/TestRunner.js +54 -0
  115. package/dist/cjs/TestRunner.js.map +7 -0
  116. package/dist/cjs/TreeFingerprint.d.ts +140 -0
  117. package/dist/cjs/TreeFingerprint.d.ts.map +1 -0
  118. package/dist/cjs/TreeFingerprint.js +87 -0
  119. package/dist/cjs/TreeFingerprint.js.map +7 -0
  120. package/dist/cjs/UpdatePlan.d.ts +152 -0
  121. package/dist/cjs/UpdatePlan.d.ts.map +1 -0
  122. package/dist/cjs/UpdatePlan.js +87 -0
  123. package/dist/cjs/UpdatePlan.js.map +7 -0
  124. package/dist/cjs/WebFetch.d.ts +134 -0
  125. package/dist/cjs/WebFetch.d.ts.map +1 -0
  126. package/dist/cjs/WebFetch.js +140 -0
  127. package/dist/cjs/WebFetch.js.map +7 -0
  128. package/dist/cjs/WebSearch.d.ts +181 -0
  129. package/dist/cjs/WebSearch.d.ts.map +1 -0
  130. package/dist/cjs/WebSearch.js +86 -0
  131. package/dist/cjs/WebSearch.js.map +7 -0
  132. package/dist/cjs/Write.d.ts +147 -0
  133. package/dist/cjs/Write.d.ts.map +1 -0
  134. package/dist/cjs/Write.js +122 -0
  135. package/dist/cjs/Write.js.map +7 -0
  136. package/dist/cjs/index.d.ts +127 -0
  137. package/dist/cjs/index.d.ts.map +1 -0
  138. package/dist/cjs/index.js +99 -0
  139. package/dist/cjs/index.js.map +7 -0
  140. package/dist/cjs/internal/ApplyPatch.d.ts +145 -0
  141. package/dist/cjs/internal/ApplyPatch.d.ts.map +1 -0
  142. package/dist/cjs/internal/ApplyPatch.js +462 -0
  143. package/dist/cjs/internal/ApplyPatch.js.map +7 -0
  144. package/dist/cjs/internal/CodexText.d.ts +73 -0
  145. package/dist/cjs/internal/CodexText.d.ts.map +1 -0
  146. package/dist/cjs/internal/CodexText.js +108 -0
  147. package/dist/cjs/internal/CodexText.js.map +7 -0
  148. package/dist/cjs/internal/Declaration.d.ts +49 -0
  149. package/dist/cjs/internal/Declaration.d.ts.map +1 -0
  150. package/dist/cjs/internal/Declaration.js +46 -0
  151. package/dist/cjs/internal/Declaration.js.map +7 -0
  152. package/dist/cjs/internal/Diagnostics.d.ts +77 -0
  153. package/dist/cjs/internal/Diagnostics.d.ts.map +1 -0
  154. package/dist/cjs/internal/Diagnostics.js +89 -0
  155. package/dist/cjs/internal/Diagnostics.js.map +7 -0
  156. package/dist/cjs/internal/EnvelopePrecheck.d.ts +67 -0
  157. package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -0
  158. package/dist/cjs/internal/EnvelopePrecheck.js +124 -0
  159. package/dist/cjs/internal/EnvelopePrecheck.js.map +7 -0
  160. package/dist/cjs/internal/Exec.d.ts +139 -0
  161. package/dist/cjs/internal/Exec.d.ts.map +1 -0
  162. package/dist/cjs/internal/Exec.js +158 -0
  163. package/dist/cjs/internal/Exec.js.map +7 -0
  164. package/dist/cjs/internal/FileMutation.d.ts +109 -0
  165. package/dist/cjs/internal/FileMutation.d.ts.map +1 -0
  166. package/dist/cjs/internal/FileMutation.js +116 -0
  167. package/dist/cjs/internal/FileMutation.js.map +7 -0
  168. package/dist/cjs/internal/FsFailure.d.ts +38 -0
  169. package/dist/cjs/internal/FsFailure.d.ts.map +1 -0
  170. package/dist/cjs/internal/FsFailure.js +40 -0
  171. package/dist/cjs/internal/FsFailure.js.map +7 -0
  172. package/dist/cjs/internal/GitWorktree.d.ts +108 -0
  173. package/dist/cjs/internal/GitWorktree.d.ts.map +1 -0
  174. package/dist/cjs/internal/GitWorktree.js +276 -0
  175. package/dist/cjs/internal/GitWorktree.js.map +7 -0
  176. package/dist/cjs/internal/Grouping.d.ts +51 -0
  177. package/dist/cjs/internal/Grouping.d.ts.map +1 -0
  178. package/dist/cjs/internal/Grouping.js +83 -0
  179. package/dist/cjs/internal/Grouping.js.map +7 -0
  180. package/dist/cjs/internal/Html.d.ts +20 -0
  181. package/dist/cjs/internal/Html.d.ts.map +1 -0
  182. package/dist/cjs/internal/Html.js +81 -0
  183. package/dist/cjs/internal/Html.js.map +7 -0
  184. package/dist/cjs/internal/Http.d.ts +95 -0
  185. package/dist/cjs/internal/Http.d.ts.map +1 -0
  186. package/dist/cjs/internal/Http.js +153 -0
  187. package/dist/cjs/internal/Http.js.map +7 -0
  188. package/dist/cjs/internal/HttpNetwork.d.ts +27 -0
  189. package/dist/cjs/internal/HttpNetwork.d.ts.map +1 -0
  190. package/dist/cjs/internal/HttpNetwork.js +146 -0
  191. package/dist/cjs/internal/HttpNetwork.js.map +7 -0
  192. package/dist/cjs/internal/Ignore.d.ts +37 -0
  193. package/dist/cjs/internal/Ignore.d.ts.map +1 -0
  194. package/dist/cjs/internal/Ignore.js +100 -0
  195. package/dist/cjs/internal/Ignore.js.map +7 -0
  196. package/dist/cjs/internal/LinearRegex.d.ts +19 -0
  197. package/dist/cjs/internal/LinearRegex.d.ts.map +1 -0
  198. package/dist/cjs/internal/LinearRegex.js +166 -0
  199. package/dist/cjs/internal/LinearRegex.js.map +7 -0
  200. package/dist/cjs/internal/Match.d.ts +85 -0
  201. package/dist/cjs/internal/Match.d.ts.map +1 -0
  202. package/dist/cjs/internal/Match.js +99 -0
  203. package/dist/cjs/internal/Match.js.map +7 -0
  204. package/dist/cjs/internal/Paths.d.ts +23 -0
  205. package/dist/cjs/internal/Paths.d.ts.map +1 -0
  206. package/dist/cjs/internal/Paths.js +52 -0
  207. package/dist/cjs/internal/Paths.js.map +7 -0
  208. package/dist/cjs/internal/Preserve.d.ts +25 -0
  209. package/dist/cjs/internal/Preserve.d.ts.map +1 -0
  210. package/dist/cjs/internal/Preserve.js +88 -0
  211. package/dist/cjs/internal/Preserve.js.map +7 -0
  212. package/dist/cjs/internal/Prune.d.ts +35 -0
  213. package/dist/cjs/internal/Prune.d.ts.map +1 -0
  214. package/dist/cjs/internal/Prune.js +54 -0
  215. package/dist/cjs/internal/Prune.js.map +7 -0
  216. package/dist/cjs/internal/SearchContract.d.ts +63 -0
  217. package/dist/cjs/internal/SearchContract.d.ts.map +1 -0
  218. package/dist/cjs/internal/SearchContract.js +46 -0
  219. package/dist/cjs/internal/SearchContract.js.map +7 -0
  220. package/dist/cjs/internal/Symbols.d.ts +39 -0
  221. package/dist/cjs/internal/Symbols.d.ts.map +1 -0
  222. package/dist/cjs/internal/Symbols.js +59 -0
  223. package/dist/cjs/internal/Symbols.js.map +7 -0
  224. package/dist/cjs/internal/TestReport.d.ts +52 -0
  225. package/dist/cjs/internal/TestReport.d.ts.map +1 -0
  226. package/dist/cjs/internal/TestReport.js +131 -0
  227. package/dist/cjs/internal/TestReport.js.map +7 -0
  228. package/dist/cjs/internal/Text.d.ts +114 -0
  229. package/dist/cjs/internal/Text.d.ts.map +1 -0
  230. package/dist/cjs/internal/Text.js +82 -0
  231. package/dist/cjs/internal/Text.js.map +7 -0
  232. package/dist/cjs/internal/Url.d.ts +13 -0
  233. package/dist/cjs/internal/Url.d.ts.map +1 -0
  234. package/dist/cjs/internal/Url.js +35 -0
  235. package/dist/cjs/internal/Url.js.map +7 -0
  236. package/dist/cjs/internal/Walk.d.ts +72 -0
  237. package/dist/cjs/internal/Walk.d.ts.map +1 -0
  238. package/dist/cjs/internal/Walk.js +108 -0
  239. package/dist/cjs/internal/Walk.js.map +7 -0
  240. package/dist/cjs/package.json +1 -0
  241. package/dist/esm/ApplyPatch.d.ts +174 -0
  242. package/dist/esm/ApplyPatch.d.ts.map +1 -0
  243. package/dist/esm/ApplyPatch.js +346 -0
  244. package/dist/esm/ApplyPatch.js.map +1 -0
  245. package/dist/esm/Bash.d.ts +380 -0
  246. package/dist/esm/Bash.d.ts.map +1 -0
  247. package/dist/esm/Bash.js +505 -0
  248. package/dist/esm/Bash.js.map +1 -0
  249. package/dist/esm/Checkpoints.d.ts +279 -0
  250. package/dist/esm/Checkpoints.d.ts.map +1 -0
  251. package/dist/esm/Checkpoints.js +298 -0
  252. package/dist/esm/Checkpoints.js.map +1 -0
  253. package/dist/esm/Container.d.ts +132 -0
  254. package/dist/esm/Container.d.ts.map +1 -0
  255. package/dist/esm/Container.js +151 -0
  256. package/dist/esm/Container.js.map +1 -0
  257. package/dist/esm/Edit.d.ts +203 -0
  258. package/dist/esm/Edit.d.ts.map +1 -0
  259. package/dist/esm/Edit.js +296 -0
  260. package/dist/esm/Edit.js.map +1 -0
  261. package/dist/esm/ExaWebSearch.d.ts +22 -0
  262. package/dist/esm/ExaWebSearch.d.ts.map +1 -0
  263. package/dist/esm/ExaWebSearch.js +107 -0
  264. package/dist/esm/ExaWebSearch.js.map +1 -0
  265. package/dist/esm/Explore.d.ts +328 -0
  266. package/dist/esm/Explore.d.ts.map +1 -0
  267. package/dist/esm/Explore.js +106 -0
  268. package/dist/esm/Explore.js.map +1 -0
  269. package/dist/esm/Fetch.d.ts +130 -0
  270. package/dist/esm/Fetch.d.ts.map +1 -0
  271. package/dist/esm/Fetch.js +91 -0
  272. package/dist/esm/Fetch.js.map +1 -0
  273. package/dist/esm/Glob.d.ts +204 -0
  274. package/dist/esm/Glob.d.ts.map +1 -0
  275. package/dist/esm/Glob.js +177 -0
  276. package/dist/esm/Glob.js.map +1 -0
  277. package/dist/esm/Grep.d.ts +347 -0
  278. package/dist/esm/Grep.d.ts.map +1 -0
  279. package/dist/esm/Grep.js +289 -0
  280. package/dist/esm/Grep.js.map +1 -0
  281. package/dist/esm/HttpPost.d.ts +130 -0
  282. package/dist/esm/HttpPost.d.ts.map +1 -0
  283. package/dist/esm/HttpPost.js +89 -0
  284. package/dist/esm/HttpPost.js.map +1 -0
  285. package/dist/esm/LanguageServer.d.ts +90 -0
  286. package/dist/esm/LanguageServer.d.ts.map +1 -0
  287. package/dist/esm/LanguageServer.js +57 -0
  288. package/dist/esm/LanguageServer.js.map +1 -0
  289. package/dist/esm/Ls.d.ts +164 -0
  290. package/dist/esm/Ls.d.ts.map +1 -0
  291. package/dist/esm/Ls.js +178 -0
  292. package/dist/esm/Ls.js.map +1 -0
  293. package/dist/esm/Lsp.d.ts +125 -0
  294. package/dist/esm/Lsp.d.ts.map +1 -0
  295. package/dist/esm/Lsp.js +165 -0
  296. package/dist/esm/Lsp.js.map +1 -0
  297. package/dist/esm/Manifest.d.ts +918 -0
  298. package/dist/esm/Manifest.d.ts.map +1 -0
  299. package/dist/esm/Manifest.js +153 -0
  300. package/dist/esm/Manifest.js.map +1 -0
  301. package/dist/esm/NativeSearch.d.ts +38 -0
  302. package/dist/esm/NativeSearch.d.ts.map +1 -0
  303. package/dist/esm/NativeSearch.js +378 -0
  304. package/dist/esm/NativeSearch.js.map +1 -0
  305. package/dist/esm/NodeLanguageServer.d.ts +128 -0
  306. package/dist/esm/NodeLanguageServer.d.ts.map +1 -0
  307. package/dist/esm/NodeLanguageServer.js +843 -0
  308. package/dist/esm/NodeLanguageServer.js.map +1 -0
  309. package/dist/esm/PortableSearch.d.ts +24 -0
  310. package/dist/esm/PortableSearch.d.ts.map +1 -0
  311. package/dist/esm/PortableSearch.js +240 -0
  312. package/dist/esm/PortableSearch.js.map +1 -0
  313. package/dist/esm/Probe.d.ts +193 -0
  314. package/dist/esm/Probe.d.ts.map +1 -0
  315. package/dist/esm/Probe.js +225 -0
  316. package/dist/esm/Probe.js.map +1 -0
  317. package/dist/esm/Read.d.ts +189 -0
  318. package/dist/esm/Read.d.ts.map +1 -0
  319. package/dist/esm/Read.js +300 -0
  320. package/dist/esm/Read.js.map +1 -0
  321. package/dist/esm/Relocate.d.ts +73 -0
  322. package/dist/esm/Relocate.d.ts.map +1 -0
  323. package/dist/esm/Relocate.js +153 -0
  324. package/dist/esm/Relocate.js.map +1 -0
  325. package/dist/esm/Search.d.ts +163 -0
  326. package/dist/esm/Search.d.ts.map +1 -0
  327. package/dist/esm/Search.js +47 -0
  328. package/dist/esm/Search.js.map +1 -0
  329. package/dist/esm/SearchConformance.d.ts +115 -0
  330. package/dist/esm/SearchConformance.d.ts.map +1 -0
  331. package/dist/esm/SearchConformance.js +193 -0
  332. package/dist/esm/SearchConformance.js.map +1 -0
  333. package/dist/esm/SearchContract.d.ts +114 -0
  334. package/dist/esm/SearchContract.d.ts.map +1 -0
  335. package/dist/esm/SearchContract.js +461 -0
  336. package/dist/esm/SearchContract.js.map +1 -0
  337. package/dist/esm/ShellCommand.d.ts +164 -0
  338. package/dist/esm/ShellCommand.d.ts.map +1 -0
  339. package/dist/esm/ShellCommand.js +159 -0
  340. package/dist/esm/ShellCommand.js.map +1 -0
  341. package/dist/esm/StdError.d.ts +55 -0
  342. package/dist/esm/StdError.d.ts.map +1 -0
  343. package/dist/esm/StdError.js +71 -0
  344. package/dist/esm/StdError.js.map +1 -0
  345. package/dist/esm/TestRun.d.ts +311 -0
  346. package/dist/esm/TestRun.d.ts.map +1 -0
  347. package/dist/esm/TestRun.js +316 -0
  348. package/dist/esm/TestRun.js.map +1 -0
  349. package/dist/esm/TestRunner.d.ts +102 -0
  350. package/dist/esm/TestRunner.d.ts.map +1 -0
  351. package/dist/esm/TestRunner.js +68 -0
  352. package/dist/esm/TestRunner.js.map +1 -0
  353. package/dist/esm/TreeFingerprint.d.ts +140 -0
  354. package/dist/esm/TreeFingerprint.d.ts.map +1 -0
  355. package/dist/esm/TreeFingerprint.js +170 -0
  356. package/dist/esm/TreeFingerprint.js.map +1 -0
  357. package/dist/esm/UpdatePlan.d.ts +152 -0
  358. package/dist/esm/UpdatePlan.d.ts.map +1 -0
  359. package/dist/esm/UpdatePlan.js +129 -0
  360. package/dist/esm/UpdatePlan.js.map +1 -0
  361. package/dist/esm/WebFetch.d.ts +134 -0
  362. package/dist/esm/WebFetch.d.ts.map +1 -0
  363. package/dist/esm/WebFetch.js +151 -0
  364. package/dist/esm/WebFetch.js.map +1 -0
  365. package/dist/esm/WebSearch.d.ts +181 -0
  366. package/dist/esm/WebSearch.d.ts.map +1 -0
  367. package/dist/esm/WebSearch.js +134 -0
  368. package/dist/esm/WebSearch.js.map +1 -0
  369. package/dist/esm/Write.d.ts +147 -0
  370. package/dist/esm/Write.d.ts.map +1 -0
  371. package/dist/esm/Write.js +144 -0
  372. package/dist/esm/Write.js.map +1 -0
  373. package/dist/esm/index.d.ts +127 -0
  374. package/dist/esm/index.d.ts.map +1 -0
  375. package/dist/esm/index.js +127 -0
  376. package/dist/esm/index.js.map +1 -0
  377. package/dist/esm/internal/ApplyPatch.d.ts +145 -0
  378. package/dist/esm/internal/ApplyPatch.d.ts.map +1 -0
  379. package/dist/esm/internal/ApplyPatch.js +489 -0
  380. package/dist/esm/internal/ApplyPatch.js.map +1 -0
  381. package/dist/esm/internal/CodexText.d.ts +73 -0
  382. package/dist/esm/internal/CodexText.d.ts.map +1 -0
  383. package/dist/esm/internal/CodexText.js +156 -0
  384. package/dist/esm/internal/CodexText.js.map +1 -0
  385. package/dist/esm/internal/Declaration.d.ts +49 -0
  386. package/dist/esm/internal/Declaration.d.ts.map +1 -0
  387. package/dist/esm/internal/Declaration.js +42 -0
  388. package/dist/esm/internal/Declaration.js.map +1 -0
  389. package/dist/esm/internal/Diagnostics.d.ts +77 -0
  390. package/dist/esm/internal/Diagnostics.d.ts.map +1 -0
  391. package/dist/esm/internal/Diagnostics.js +99 -0
  392. package/dist/esm/internal/Diagnostics.js.map +1 -0
  393. package/dist/esm/internal/EnvelopePrecheck.d.ts +67 -0
  394. package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -0
  395. package/dist/esm/internal/EnvelopePrecheck.js +167 -0
  396. package/dist/esm/internal/EnvelopePrecheck.js.map +1 -0
  397. package/dist/esm/internal/Exec.d.ts +139 -0
  398. package/dist/esm/internal/Exec.d.ts.map +1 -0
  399. package/dist/esm/internal/Exec.js +193 -0
  400. package/dist/esm/internal/Exec.js.map +1 -0
  401. package/dist/esm/internal/FileMutation.d.ts +109 -0
  402. package/dist/esm/internal/FileMutation.d.ts.map +1 -0
  403. package/dist/esm/internal/FileMutation.js +123 -0
  404. package/dist/esm/internal/FileMutation.js.map +1 -0
  405. package/dist/esm/internal/FsFailure.d.ts +38 -0
  406. package/dist/esm/internal/FsFailure.d.ts.map +1 -0
  407. package/dist/esm/internal/FsFailure.js +39 -0
  408. package/dist/esm/internal/FsFailure.js.map +1 -0
  409. package/dist/esm/internal/GitWorktree.d.ts +108 -0
  410. package/dist/esm/internal/GitWorktree.d.ts.map +1 -0
  411. package/dist/esm/internal/GitWorktree.js +352 -0
  412. package/dist/esm/internal/GitWorktree.js.map +1 -0
  413. package/dist/esm/internal/Grouping.d.ts +51 -0
  414. package/dist/esm/internal/Grouping.d.ts.map +1 -0
  415. package/dist/esm/internal/Grouping.js +99 -0
  416. package/dist/esm/internal/Grouping.js.map +1 -0
  417. package/dist/esm/internal/Html.d.ts +20 -0
  418. package/dist/esm/internal/Html.d.ts.map +1 -0
  419. package/dist/esm/internal/Html.js +70 -0
  420. package/dist/esm/internal/Html.js.map +1 -0
  421. package/dist/esm/internal/Http.d.ts +95 -0
  422. package/dist/esm/internal/Http.d.ts.map +1 -0
  423. package/dist/esm/internal/Http.js +154 -0
  424. package/dist/esm/internal/Http.js.map +1 -0
  425. package/dist/esm/internal/HttpNetwork.d.ts +27 -0
  426. package/dist/esm/internal/HttpNetwork.d.ts.map +1 -0
  427. package/dist/esm/internal/HttpNetwork.js +114 -0
  428. package/dist/esm/internal/HttpNetwork.js.map +1 -0
  429. package/dist/esm/internal/Ignore.d.ts +37 -0
  430. package/dist/esm/internal/Ignore.d.ts.map +1 -0
  431. package/dist/esm/internal/Ignore.js +128 -0
  432. package/dist/esm/internal/Ignore.js.map +1 -0
  433. package/dist/esm/internal/LinearRegex.d.ts +19 -0
  434. package/dist/esm/internal/LinearRegex.d.ts.map +1 -0
  435. package/dist/esm/internal/LinearRegex.js +176 -0
  436. package/dist/esm/internal/LinearRegex.js.map +1 -0
  437. package/dist/esm/internal/Match.d.ts +85 -0
  438. package/dist/esm/internal/Match.d.ts.map +1 -0
  439. package/dist/esm/internal/Match.js +142 -0
  440. package/dist/esm/internal/Match.js.map +1 -0
  441. package/dist/esm/internal/Paths.d.ts +23 -0
  442. package/dist/esm/internal/Paths.d.ts.map +1 -0
  443. package/dist/esm/internal/Paths.js +40 -0
  444. package/dist/esm/internal/Paths.js.map +1 -0
  445. package/dist/esm/internal/Preserve.d.ts +25 -0
  446. package/dist/esm/internal/Preserve.d.ts.map +1 -0
  447. package/dist/esm/internal/Preserve.js +70 -0
  448. package/dist/esm/internal/Preserve.js.map +1 -0
  449. package/dist/esm/internal/Prune.d.ts +35 -0
  450. package/dist/esm/internal/Prune.d.ts.map +1 -0
  451. package/dist/esm/internal/Prune.js +60 -0
  452. package/dist/esm/internal/Prune.js.map +1 -0
  453. package/dist/esm/internal/SearchContract.d.ts +63 -0
  454. package/dist/esm/internal/SearchContract.d.ts.map +1 -0
  455. package/dist/esm/internal/SearchContract.js +66 -0
  456. package/dist/esm/internal/SearchContract.js.map +1 -0
  457. package/dist/esm/internal/Symbols.d.ts +39 -0
  458. package/dist/esm/internal/Symbols.d.ts.map +1 -0
  459. package/dist/esm/internal/Symbols.js +79 -0
  460. package/dist/esm/internal/Symbols.js.map +1 -0
  461. package/dist/esm/internal/TestReport.d.ts +52 -0
  462. package/dist/esm/internal/TestReport.d.ts.map +1 -0
  463. package/dist/esm/internal/TestReport.js +172 -0
  464. package/dist/esm/internal/TestReport.js.map +1 -0
  465. package/dist/esm/internal/Text.d.ts +114 -0
  466. package/dist/esm/internal/Text.d.ts.map +1 -0
  467. package/dist/esm/internal/Text.js +130 -0
  468. package/dist/esm/internal/Text.js.map +1 -0
  469. package/dist/esm/internal/Url.d.ts +13 -0
  470. package/dist/esm/internal/Url.d.ts.map +1 -0
  471. package/dist/esm/internal/Url.js +27 -0
  472. package/dist/esm/internal/Url.js.map +1 -0
  473. package/dist/esm/internal/Walk.d.ts +72 -0
  474. package/dist/esm/internal/Walk.d.ts.map +1 -0
  475. package/dist/esm/internal/Walk.js +126 -0
  476. package/dist/esm/internal/Walk.js.map +1 -0
  477. package/docs/README.md +117 -0
  478. package/docs/api.md +472 -0
  479. package/docs/concepts/effects-and-capabilities.md +136 -0
  480. package/docs/concepts/flows-and-handlers.md +115 -0
  481. package/docs/concepts/limits-and-disclosure.md +102 -0
  482. package/docs/concepts/search-contract.md +182 -0
  483. package/docs/guides/bind-the-standard-flows.md +114 -0
  484. package/docs/guides/implement-a-search-peer.md +133 -0
  485. package/docs/guides/pin-a-checkpoint.md +141 -0
  486. package/docs/guides/query-a-language-server.md +257 -0
  487. package/docs/guides/reach-the-network.md +141 -0
  488. package/docs/guides/read-and-edit-a-file.md +240 -0
  489. package/docs/guides/run-a-shell-command.md +215 -0
  490. package/docs/guides/run-the-test-suite.md +154 -0
  491. package/docs/guides/search-a-workspace.md +148 -0
  492. package/docs/installation.md +111 -0
  493. package/docs/quickstart.md +125 -0
  494. package/docs/reference/flows.md +556 -0
  495. package/docs/troubleshooting.md +322 -0
  496. package/package.json +439 -3
  497. package/src/ApplyPatch.ts +458 -0
  498. package/src/Bash.ts +607 -0
  499. package/src/Checkpoints.ts +422 -0
  500. package/src/Container.ts +212 -0
  501. package/src/Edit.ts +366 -0
  502. package/src/ExaWebSearch.ts +145 -0
  503. package/src/Explore.ts +139 -0
  504. package/src/Fetch.ts +117 -0
  505. package/src/Glob.ts +200 -0
  506. package/src/Grep.ts +320 -0
  507. package/src/HttpPost.ts +120 -0
  508. package/src/LanguageServer.ts +110 -0
  509. package/src/Ls.ts +228 -0
  510. package/src/Lsp.ts +184 -0
  511. package/src/Manifest.ts +162 -0
  512. package/src/NativeSearch.ts +457 -0
  513. package/src/NodeLanguageServer.ts +1148 -0
  514. package/src/PortableSearch.ts +264 -0
  515. package/src/Probe.ts +284 -0
  516. package/src/Read.ts +359 -0
  517. package/src/Relocate.ts +166 -0
  518. package/src/Search.ts +185 -0
  519. package/src/SearchConformance.ts +288 -0
  520. package/src/SearchContract.ts +489 -0
  521. package/src/ShellCommand.ts +201 -0
  522. package/src/StdError.ts +80 -0
  523. package/src/TestRun.ts +401 -0
  524. package/src/TestRunner.ts +119 -0
  525. package/src/TreeFingerprint.ts +200 -0
  526. package/src/UpdatePlan.ts +171 -0
  527. package/src/WebFetch.ts +194 -0
  528. package/src/WebSearch.ts +165 -0
  529. package/src/Write.ts +195 -0
  530. package/src/index.ts +154 -0
  531. package/src/internal/ApplyPatch.ts +601 -0
  532. package/src/internal/CodexText.ts +182 -0
  533. package/src/internal/Declaration.ts +60 -0
  534. package/src/internal/Diagnostics.ts +134 -0
  535. package/src/internal/EnvelopePrecheck.ts +233 -0
  536. package/src/internal/Exec.ts +314 -0
  537. package/src/internal/FileMutation.ts +231 -0
  538. package/src/internal/FsFailure.ts +51 -0
  539. package/src/internal/GitWorktree.ts +491 -0
  540. package/src/internal/Grouping.ts +106 -0
  541. package/src/internal/Html.ts +87 -0
  542. package/src/internal/Http.ts +209 -0
  543. package/src/internal/HttpNetwork.ts +153 -0
  544. package/src/internal/Ignore.ts +135 -0
  545. package/src/internal/LinearRegex.ts +173 -0
  546. package/src/internal/Match.ts +172 -0
  547. package/src/internal/Paths.ts +42 -0
  548. package/src/internal/Preserve.ts +108 -0
  549. package/src/internal/Prune.ts +62 -0
  550. package/src/internal/SearchContract.ts +77 -0
  551. package/src/internal/Symbols.ts +88 -0
  552. package/src/internal/TestReport.ts +194 -0
  553. package/src/internal/Text.ts +170 -0
  554. package/src/internal/Url.ts +23 -0
  555. package/src/internal/Walk.ts +176 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The single typed error returned by every standard flow handler.
3
+ *
4
+ * @since 1.0.0
5
+ */
6
+
7
+ import { Schema } from "effect"
8
+
9
+ /**
10
+ * Stable, model-facing failure codes shared by the standard flows.
11
+ *
12
+ * @category models
13
+ * @since 1.0.0
14
+ */
15
+ export const Code = Schema.Literals([
16
+ "stale_read",
17
+ "not_found",
18
+ "not_a_directory",
19
+ "not_a_file",
20
+ "is_directory",
21
+ "binary_file",
22
+ "offset_out_of_range",
23
+ "invalid_pattern",
24
+ "invalid_input",
25
+ "no_match",
26
+ "not_modified",
27
+ "permission_denied",
28
+ "outside_declared_reads",
29
+ "outside_declared_writes",
30
+ "command_failed",
31
+ "request_failed",
32
+ "timeout",
33
+ "rate_limited",
34
+ "provider_unavailable",
35
+ "moved_off",
36
+ "unsupported",
37
+ "unsupported_content_type",
38
+ "response_too_large",
39
+ "outside_container"
40
+ ])
41
+
42
+ /**
43
+ * Stable, model-facing failure codes shared by the standard flows.
44
+ *
45
+ * @category models
46
+ * @since 1.0.0
47
+ */
48
+ export type Code = typeof Code.Type
49
+
50
+ /**
51
+ * A recoverable standard-flow failure.
52
+ *
53
+ * Handlers keep ordinary outcomes (a non-zero exit code, an empty match set)
54
+ * in the success channel; this error is reserved for failures the model must
55
+ * see as failures.
56
+ *
57
+ * @category errors
58
+ * @since 1.0.0
59
+ */
60
+ export class StdError extends Schema.TaggedError<StdError>()("@smthrs/std/StdError", {
61
+ code: Code,
62
+ message: Schema.String,
63
+ path: Schema.optional(Schema.String),
64
+ /** Full-file base, or unread when this run has not read the existing file. */
65
+ base_digest: Schema.optional(Schema.String),
66
+ /** Full-file current SHA-256, or absent. */
67
+ current_digest: Schema.optional(Schema.String),
68
+ /** Language-server request that failed. */
69
+ method: Schema.optional(Schema.String),
70
+ /** JSON-RPC diagnostics, bounded by the transport's maximum frame size. */
71
+ rpcError: Schema.optional(Schema.Struct({
72
+ code: Schema.Number,
73
+ message: Schema.String,
74
+ data: Schema.optional(Schema.Unknown)
75
+ })),
76
+ /** At most 64 KiB of the language server's most recent stderr. */
77
+ stderr: Schema.optional(Schema.String),
78
+ /** The limit a `timeout` ran past, in milliseconds, when the flow knows it. */
79
+ limitMillis: Schema.optional(Schema.Number)
80
+ }) {}
package/src/TestRun.ts ADDED
@@ -0,0 +1,401 @@
1
+ /**
2
+ * The `test` flow: run the declared suite, and answer with the two facts.
3
+ *
4
+ * Two things this returns that a shell command cannot. First, a *reading*:
5
+ * `{passed, failed}` parsed from the runner's own report, with the raw tail
6
+ * kept for whatever the parse could not carry — a suite's answer is a number
7
+ * and a list of names, not twenty kilobytes of stdout for a model to re-read.
8
+ *
9
+ * Second, `against: "base"`: the same selection also runs against the pristine
10
+ * base commit in a scratch checkout, and the two failure sets are differenced
11
+ * here. That is the whole of attribution, in one call. Without it, agents pay
12
+ * for it in frames — sphinx-8721 spent fourteen frames because a pre-existing
13
+ * failure was never baselined, sympy-13878 spent $0.90 on the same mistake, and
14
+ * django-24970 spent three frames. The rule the harness teaches ("before
15
+ * blaming your own edit, run the same command on the unmodified tree") is only
16
+ * cheap when the tool can do it.
17
+ *
18
+ * A third thing is answered on the way out: whether a non-zero exit is the
19
+ * tree's failure at all, or the command failing to resolve a name. Jev decides
20
+ * it through `Probe.classify`, so the flow needs an `Evaluator` and a host
21
+ * uses its configured subscription seat. A judge that does not answer fails the call with
22
+ * the code `Probe.unjudged` names, because a run nobody judged is not a run
23
+ * this flow can report on.
24
+ *
25
+ * @since 1.0.0
26
+ */
27
+
28
+ import type * as ChildProcessSpawner from "@smthrs/kernel/ChildProcessSpawner"
29
+ import type * as Evaluator from "@smthrs/model/Evaluator"
30
+ import * as Effect from "effect/Effect"
31
+ import * as Option from "effect/Option"
32
+ import * as Schema from "effect/Schema"
33
+ import * as Container from "./Container.ts"
34
+ import { capability, envelope } from "./internal/Declaration.ts"
35
+ import * as Exec from "./internal/Exec.ts"
36
+ import { GitWorktree } from "./internal/GitWorktree.ts"
37
+ import * as Prune from "./internal/Prune.ts"
38
+ import * as TestReport from "./internal/TestReport.ts"
39
+ import { MAX_SHELL_OUTPUT_BYTES, truncateBytes } from "./internal/Text.ts"
40
+ import * as Probe from "./Probe.ts"
41
+ import * as StdError from "./StdError.ts"
42
+ import * as TestRunner from "./TestRunner.ts"
43
+
44
+ /**
45
+ * Registry name for the test flow.
46
+ *
47
+ * @category identifiers
48
+ * @since 1.0.0
49
+ */
50
+ export const name = "test"
51
+
52
+ /**
53
+ * Model-facing description of the test flow.
54
+ *
55
+ * @category descriptions
56
+ * @since 1.0.0
57
+ */
58
+ export const description =
59
+ "Run this repository's declared test runner and get {passed, failed[ids]}, not raw output. against:'base' also runs it on the pristine base commit, so a pre-existing failure is named, not investigated."
60
+
61
+ /**
62
+ * The parent directory baseline checkouts are written into, relative to the
63
+ * repository root, and therefore also relative to the runner's own directory.
64
+ *
65
+ * @category constants
66
+ * @since 1.0.0
67
+ */
68
+ export const scratchDirectory = Prune.testBaseScratch
69
+
70
+ /**
71
+ * Default wall-clock budget for one test run.
72
+ *
73
+ * @category constants
74
+ * @since 1.0.0
75
+ */
76
+ export const DEFAULT_TIMEOUT_MS = 600_000
77
+
78
+ /**
79
+ * Maximum bytes retained from each stream while a test run executes.
80
+ *
81
+ * @category constants
82
+ * @since 1.0.0
83
+ */
84
+ export const MAX_CAPTURE_BYTES = 8_000_000
85
+
86
+ /**
87
+ * Input schema for the test flow.
88
+ *
89
+ * @category schemas
90
+ * @since 1.0.0
91
+ */
92
+ export const Input = Schema.Struct({
93
+ selection: Schema.optional(Schema.Array(Schema.String)).annotate({
94
+ description: "Test ids, paths or selectors passed to the runner as arguments; all tests when omitted"
95
+ }),
96
+ against: Schema.optional(Schema.Literals(["workspace", "base"])).annotate({
97
+ description:
98
+ "workspace (default) runs the tree as it stands; base also runs the pristine base commit and reports which failures are new"
99
+ }),
100
+ timeoutMs: Schema.optional(Schema.Number).annotate({ description: "Wall-clock timeout in milliseconds" })
101
+ })
102
+
103
+ /**
104
+ * Decoded input accepted by the `test` flow.
105
+ *
106
+ * @category models
107
+ * @since 1.0.0
108
+ */
109
+ export type Input = typeof Input.Type
110
+
111
+ /**
112
+ * One run's outcome.
113
+ *
114
+ * @category schemas
115
+ * @since 1.0.0
116
+ */
117
+ export const Outcome = Schema.Struct({
118
+ command: Schema.String.annotate({
119
+ description: "The logical invocation that ran, without container transport arguments"
120
+ }),
121
+ exitCode: Schema.Number,
122
+ passed: Schema.Number.annotate({ description: "Tests reported passing; 0 when parsed is false" }),
123
+ failed: Schema.Array(Schema.String).annotate({ description: "Ids of the tests reported failing or erroring" }),
124
+ parsed: Schema.Boolean.annotate({
125
+ description:
126
+ "Whether the runner's complete report could be read; when false, tail is all there is. Base attribution is omitted unless both reports are complete"
127
+ }),
128
+ tail: Schema.String.annotate({ description: "The end of the runner's combined output" }),
129
+ // `<field>Truncated` beside `<field>` is the wire convention
130
+ // `@smthrs/harness/TruncatedOutput` reads to refuse a later write of these
131
+ // exact bytes. A tail written over a file replaces it with its own end.
132
+ tailTruncated: Schema.Boolean.annotate({
133
+ description: "Whether the runner printed more than tail carries, leaving tail a fragment that must not be written"
134
+ }),
135
+ tailDroppedBytes: Schema.Number.annotate({ description: "UTF-8 bytes omitted from the start of tail" }),
136
+ invalidProbe: Schema.optional(Probe.InvalidProbe)
137
+ })
138
+
139
+ /**
140
+ * Output schema for the test flow.
141
+ *
142
+ * @category schemas
143
+ * @since 1.0.0
144
+ */
145
+ export const Output = Schema.Struct({
146
+ ...Outcome.fields,
147
+ base: Schema.optional(Schema.Struct({
148
+ ...Outcome.fields,
149
+ ref: Schema.String.annotate({ description: "The ref the baseline tree came from" }),
150
+ commit: Schema.String.annotate({ description: "The commit the baseline tree came from" })
151
+ })),
152
+ introduced: Schema.optional(Schema.Array(Schema.String)).annotate({
153
+ description: "Failing here and not on the base tree: the failures this working tree is responsible for"
154
+ }),
155
+ preexisting: Schema.optional(Schema.Array(Schema.String)).annotate({
156
+ description: "Failing on both trees: not yours, and not worth investigating"
157
+ }),
158
+ fixed: Schema.optional(Schema.Array(Schema.String)).annotate({
159
+ description: "Failing on the base tree and passing here"
160
+ })
161
+ })
162
+
163
+ /**
164
+ * Decoded output returned by the `test` flow.
165
+ *
166
+ * @category models
167
+ * @since 1.0.0
168
+ */
169
+ export type Output = typeof Output.Type
170
+
171
+ /**
172
+ * Static conservative effect envelope for the test flow.
173
+ *
174
+ * @category effects
175
+ * @since 1.0.0
176
+ */
177
+ export const effects = envelope({ tier: "irreversible", mode: "expected", reads: [], writes: [] })
178
+
179
+ /**
180
+ * Narrows the effect envelope for a decoded invocation.
181
+ *
182
+ * @category effects
183
+ * @since 1.0.0
184
+ */
185
+ export const effectsFor = (_input: typeof Input.Type) => effects
186
+
187
+ /**
188
+ * Capabilities required by the test flow.
189
+ *
190
+ * @category capabilities
191
+ * @since 1.0.0
192
+ */
193
+ export const capabilities = [capability("proc:spawn", "*")]
194
+
195
+ /**
196
+ * Declaration-only test flow.
197
+ *
198
+ * @category flows
199
+ * @since 1.0.0
200
+ */
201
+ export const flow = { name, description, input: Input, output: Output, capabilities, effects } as const
202
+
203
+ /**
204
+ * What a call to this flow does, for a reader of a run.
205
+ *
206
+ * Display metadata only. `@smthrs/registry` `Descriptor.FlowActivity` is the
207
+ * governing vocabulary and `StandardFlows` binds this value onto the flow's
208
+ * descriptor, where the binding site checks it. `declarationDigest` excludes
209
+ * it, so declaring it cannot invalidate a call identity or a cached prompt.
210
+ *
211
+ * @category presentation
212
+ * @since 1.0.0-rc.0
213
+ */
214
+ export const activity = "tests" as const
215
+
216
+ /**
217
+ * How one recorded call to this flow reads: the verb for each settlement, the
218
+ * input field that is its subject, and the measured output fields a one-line
219
+ * summary may count.
220
+ *
221
+ * Display metadata only, governed by `@smthrs/registry`
222
+ * `Descriptor.CallPresentation` and checked where `StandardFlows` binds it.
223
+ *
224
+ * @category presentation
225
+ * @since 1.0.0-rc.0
226
+ */
227
+ export const presentation = {
228
+ verb: { pending: "running", success: "ran", failure: "failed to run" },
229
+ subject: "selection",
230
+ result: "tests"
231
+ } as const
232
+
233
+ /**
234
+ * The invocation for one run: the declared command line with the selection
235
+ * appended as arguments rather than as text.
236
+ *
237
+ * `bash -c '<command> "$@"' <command> id…` is how a selection reaches a runner
238
+ * without being quoted into it. A test id holds `::`, `[`, `]`, spaces and
239
+ * shell metacharacters routinely, and every one of them is data here.
240
+ */
241
+ const invocation = (
242
+ runner: TestRunner.Runner,
243
+ selection: ReadonlyArray<string>
244
+ ): { readonly file: string; readonly args: ReadonlyArray<string> } => ({
245
+ file: "bash",
246
+ args: ["-c", `${runner.command} "$@"`, runner.command, ...selection]
247
+ })
248
+
249
+ const failed = (message: string, code: StdError.Code = "command_failed"): StdError.StdError =>
250
+ new StdError.StdError({ code, message })
251
+
252
+ /** Runs one invocation, in the container when the declaration names one. */
253
+ const execute = (
254
+ runner: TestRunner.Runner,
255
+ transport: Option.Option<Container.Container>,
256
+ options: {
257
+ readonly selection: ReadonlyArray<string>
258
+ readonly cwd: string | undefined
259
+ readonly timeoutMs: number
260
+ }
261
+ ): Effect.Effect<
262
+ { readonly outcome: typeof Outcome.Type; readonly report: TestReport.Report },
263
+ StdError.StdError,
264
+ ChildProcessSpawner.ChildProcessSpawner | Evaluator.Evaluator
265
+ > =>
266
+ Effect.gen(function*() {
267
+ const plan = invocation(runner, options.selection)
268
+ const routed: Container.Plan = runner.container === undefined ?
269
+ { ...plan, env: runner.env } :
270
+ Option.isNone(transport)
271
+ ? yield* Effect.fail(Container.unavailable(runner.container))
272
+ : yield* transport.value.exec({
273
+ container: runner.container,
274
+ file: plan.file,
275
+ args: plan.args,
276
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
277
+ ...(runner.env === undefined ? {} : { env: runner.env }),
278
+ stdin: false
279
+ })
280
+ // Report the logical invocation, never the transport or its credentials.
281
+ const quoted = [plan.file, ...plan.args].join(" ")
282
+ const result = yield* Exec.exec(routed.file, {
283
+ args: [...routed.args],
284
+ ...(options.cwd === undefined || runner.container !== undefined ? {} : { cwd: options.cwd }),
285
+ ...(routed.env === undefined ? {} : { env: routed.env }),
286
+ timeoutMs: options.timeoutMs,
287
+ maxCaptureBytes: MAX_CAPTURE_BYTES
288
+ }).pipe(
289
+ Effect.mapError((error) =>
290
+ new StdError.StdError({
291
+ code: Exec.toStdErrorCode(error),
292
+ message: `The test runner did not run: ${error.message}`,
293
+ ...(error.limitMillis === undefined ? {} : { limitMillis: error.limitMillis })
294
+ })
295
+ )
296
+ )
297
+ const combined = result.stderr === ""
298
+ ? result.stdout
299
+ : result.stdout === ""
300
+ ? result.stderr
301
+ : `${result.stdout}\n${result.stderr}`
302
+ const tail = truncateBytes(combined, MAX_SHELL_OUTPUT_BYTES, { keep: "tail" })
303
+ const report = TestReport.parse(combined)
304
+ // Judged on the text this call returns rather than the text it captured,
305
+ // so the attribution is made from the output the reader can see. A judge
306
+ // that does not answer fails the call: see `Probe.unjudged`.
307
+ const probe = yield* Probe.classify({
308
+ command: quoted,
309
+ exitCode: result.exitCode,
310
+ output: tail.text
311
+ }).pipe(Effect.mapError(Probe.unjudged))
312
+ const capturedDroppedBytes = result.stdoutDroppedBytes + result.stderrDroppedBytes
313
+ return {
314
+ outcome: {
315
+ command: quoted,
316
+ exitCode: result.exitCode,
317
+ passed: report.passed,
318
+ failed: report.failed,
319
+ parsed: report.parsed,
320
+ tail: tail.text,
321
+ tailTruncated: capturedDroppedBytes > 0 || tail.truncated,
322
+ tailDroppedBytes: capturedDroppedBytes + tail.droppedBytes,
323
+ ...(probe.invalidProbe === undefined ? {} : { invalidProbe: probe.invalidProbe })
324
+ },
325
+ report
326
+ }
327
+ })
328
+
329
+ /**
330
+ * Runs the declared suite, and on request the same suite on the pristine base.
331
+ *
332
+ * Baseline Git and both runners use the caller-provided process service.
333
+ * A host that cannot safely stage the base declares `baseline: false`, which
334
+ * refuses the request before running either suite or Git. Library hosts that
335
+ * support staging remove the detached checkout when the call ends.
336
+ *
337
+ * @category handlers
338
+ * @since 1.0.0
339
+ */
340
+ export const run = Effect.fn("TestRun.run")(function*(
341
+ input: typeof Input.Type
342
+ ): Effect.fn.Return<
343
+ typeof Output.Type,
344
+ StdError.StdError,
345
+ ChildProcessSpawner.ChildProcessSpawner | Evaluator.Evaluator | TestRunner.TestRunner
346
+ > {
347
+ const declaration = yield* TestRunner.TestRunner
348
+ const runner = yield* declaration.declared
349
+ if (input.against === "base" && runner.baseline === false) {
350
+ return yield* Effect.fail(failed(
351
+ "Baseline comparison is unavailable on this host. Run against the workspace.",
352
+ "provider_unavailable"
353
+ ))
354
+ }
355
+ const transport = yield* Effect.serviceOption(Container.Container)
356
+ const selection = input.selection ?? []
357
+ const timeoutMs = input.timeoutMs ?? runner.timeoutMs ?? DEFAULT_TIMEOUT_MS
358
+ const current = yield* execute(runner, transport, {
359
+ selection,
360
+ cwd: runner.cwd,
361
+ timeoutMs
362
+ })
363
+ if (input.against !== "base") return current.outcome
364
+
365
+ const root = runner.root ?? runner.cwd
366
+ if (root === undefined) {
367
+ return yield* Effect.fail(
368
+ failed(
369
+ "The declared runner names no repository directory, so there is no base tree to check out",
370
+ "invalid_input"
371
+ )
372
+ )
373
+ }
374
+ const base = yield* GitWorktree.resolveCommit(
375
+ root,
376
+ runner.baseRef === undefined ? [TestRunner.captureBase, "HEAD"] : [runner.baseRef]
377
+ ).pipe(Effect.mapError((error) =>
378
+ error.code === "not_found"
379
+ ? failed(`No pristine base to compare against: ${error.message} Run against the workspace instead.`, "not_found")
380
+ : error
381
+ ))
382
+ const baseline = yield* GitWorktree.withDetachedWorktree(
383
+ root,
384
+ `${scratchDirectory}/run`,
385
+ base.commit,
386
+ (scratch) =>
387
+ execute(runner, transport, {
388
+ selection,
389
+ cwd: runner.cwd === undefined
390
+ ? scratch
391
+ : `${runner.cwd.replace(/\/+$/, "")}${scratch.slice(root.replace(/\/+$/, "").length)}`,
392
+ timeoutMs
393
+ })
394
+ )
395
+ const difference = TestReport.attribute(current.report, baseline.report)
396
+ return {
397
+ ...current.outcome,
398
+ base: { ...baseline.outcome, ref: base.ref, commit: base.commit },
399
+ ...(difference === undefined ? {} : difference)
400
+ }
401
+ })
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The repository's own test invocation, declared once by the host.
3
+ *
4
+ * Every repository already knows how to run its tests, and the harness is told
5
+ * so at setup. What the measured program shows is what happens when that fact
6
+ * is not a *callable* thing: agents guess labels
7
+ * (`management_commands.test_flush`, `tests/related_lookup`, `test_axis.py` —
8
+ * none of which exist), and a guessed label costs a frame each time. Seven such
9
+ * invocations are documented across the 45 instances.
10
+ *
11
+ * So the invocation is a declaration, not a parameter: a caller of the `test`
12
+ * flow selects *which* tests, never *how* to run them.
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+
17
+ import { Context, Effect, Layer } from "effect"
18
+ import * as StdError from "./StdError.ts"
19
+
20
+ /**
21
+ * The default ref naming a tree as it stood before the agent touched it.
22
+ *
23
+ * The engine records the pristine checkout under this ref, so a baseline run
24
+ * reuses what already exists instead of inventing a second notion of "base".
25
+ *
26
+ * @category constants
27
+ * @since 1.0.0
28
+ */
29
+ export const captureBase = "refs/flows/capture-base"
30
+
31
+ /**
32
+ * How this repository runs its tests.
33
+ *
34
+ * `cwd` is where the runner runs, and `root` is the host directory holding the
35
+ * git repository. They differ exactly when the runner runs in a container: the
36
+ * container sees the repository at `cwd`, the host sees it at `root`, and a
37
+ * baseline checkout created at `<root>/<name>` is visible to the runner at
38
+ * `<cwd>/<name>` because it is the same directory under two names.
39
+ *
40
+ * @category models
41
+ * @since 1.0.0
42
+ */
43
+ export interface Runner {
44
+ /** The runner command line, without any test selection. */
45
+ readonly command: string
46
+ /** Where the runner runs; the container's path when `container` is set. */
47
+ readonly cwd?: string | undefined
48
+ /** The host path of the repository, when it differs from `cwd`. */
49
+ readonly root?: string | undefined
50
+ /** A container to route the run through, via the `Container` transport. */
51
+ readonly container?: string | undefined
52
+ /** Environment the runner needs. */
53
+ readonly env?: Record<string, string> | undefined
54
+ /** The ref whose commit is the pristine base; defaults to {@link captureBase}, then HEAD. */
55
+ readonly baseRef?: string | undefined
56
+ /** False refuses baseline requests before any process runs. */
57
+ readonly baseline?: false | undefined
58
+ /** Default wall-clock budget for one run. */
59
+ readonly timeoutMs?: number | undefined
60
+ }
61
+
62
+ /**
63
+ * The declaration service.
64
+ *
65
+ * @category services
66
+ * @since 1.0.0
67
+ */
68
+ export interface TestRunner {
69
+ readonly declared: Effect.Effect<Runner, StdError.StdError>
70
+ }
71
+
72
+ /**
73
+ * The {@link TestRunner} service tag.
74
+ *
75
+ * @category services
76
+ * @since 1.0.0
77
+ */
78
+ export const TestRunner: Context.Service<TestRunner, TestRunner> = Context.Service("@smthrs/std/TestRunner")
79
+
80
+ /**
81
+ * Declares one repository's runner.
82
+ *
83
+ * @category constructors
84
+ * @since 1.0.0
85
+ */
86
+ export const make = (runner: Runner): TestRunner => TestRunner.of({ declared: Effect.succeed(runner) })
87
+
88
+ /**
89
+ * Declares that this host knows of no runner.
90
+ *
91
+ * @category constructors
92
+ * @since 1.0.0
93
+ */
94
+ export const makeNoop = (): TestRunner =>
95
+ TestRunner.of({
96
+ declared: Effect.fail(
97
+ new StdError.StdError({
98
+ code: "provider_unavailable",
99
+ message:
100
+ "No test runner is declared for this repository, so there is nothing for the test flow to run. Use bash with the command this project's own documentation gives."
101
+ })
102
+ )
103
+ })
104
+
105
+ /**
106
+ * Provides {@link make}.
107
+ *
108
+ * @category layers
109
+ * @since 1.0.0
110
+ */
111
+ export const layer = (runner: Runner): Layer.Layer<TestRunner> => Layer.succeed(TestRunner, make(runner))
112
+
113
+ /**
114
+ * Provides {@link makeNoop}.
115
+ *
116
+ * @category layers
117
+ * @since 1.0.0
118
+ */
119
+ export const layerNoop: Layer.Layer<TestRunner> = Layer.succeed(TestRunner, makeNoop())