@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,172 @@
1
+ /**
2
+ * Exact block location, and the pre-image reported when it misses.
3
+ *
4
+ * The editing flows locate a caller's block byte-exactly and refuse everything
5
+ * else. The tolerant cascade this module used to apply — trailing-whitespace
6
+ * insensitive, then inner-whitespace collapsed — is gone from the *apply* path,
7
+ * because a match that is not the caller's bytes is an edit the caller never
8
+ * inspected: on django-11490 a sixteen-space anchor matched inside a
9
+ * twenty-space line and silently dedented a guard, and on sympy-15380 a
10
+ * "successful" fuzzy apply corrupted the file it reported editing. Prior art is
11
+ * `reference/opencode`'s replacer cascade (`tool/edit.ts`), and this is where we
12
+ * deviate from it deliberately.
13
+ *
14
+ * The cascade survives as *diagnosis*. A miss is only expensive when it is
15
+ * silent: the agent re-reads, re-guesses, and re-misses. {@link nearest} runs
16
+ * the same loose strategies to find where the caller's block actually sits and
17
+ * returns that region's real bytes and line range, so the failing cell can
18
+ * re-anchor from reality inside the same frame rather than buying another one.
19
+ *
20
+ * @since 1.0.0
21
+ */
22
+
23
+ import { sourceLines } from "./Text.ts"
24
+
25
+ /**
26
+ * One located block: the exact source span the needle matched.
27
+ *
28
+ * @category models
29
+ * @since 1.0.0
30
+ */
31
+ export interface Located {
32
+ readonly start: number
33
+ readonly end: number
34
+ readonly startLine: number
35
+ readonly endLine: number
36
+ }
37
+
38
+ /**
39
+ * The real file region nearest a needle that did not match.
40
+ *
41
+ * `text` is raw file bytes, never line-number prefixed, so a caller can quote it
42
+ * back as an anchor without editing it first.
43
+ *
44
+ * @category models
45
+ * @since 1.0.0
46
+ */
47
+ export interface Nearest {
48
+ readonly startLine: number
49
+ readonly endLine: number
50
+ readonly text: string
51
+ }
52
+
53
+ /**
54
+ * The 1-based line a byte offset falls on.
55
+ *
56
+ * @category matching
57
+ * @since 1.0.0
58
+ */
59
+ export const lineAt = (content: string, offset: number): number => {
60
+ let line = 1
61
+ for (let index = 0; index < offset && index < content.length; index++) {
62
+ if (content[index] === "\n") line++
63
+ }
64
+ return line
65
+ }
66
+
67
+ /**
68
+ * Every byte-exact occurrence of `needle` in `content`.
69
+ *
70
+ * @category matching
71
+ * @since 1.0.0
72
+ */
73
+ export const locate = (content: string, needle: string): ReadonlyArray<Located> => {
74
+ const found: Array<Located> = []
75
+ let cursor = content.indexOf(needle)
76
+ let line = 1
77
+ let scanned = 0
78
+ while (cursor >= 0) {
79
+ for (let index = scanned; index < cursor; index++) {
80
+ if (content[index] === "\n") line++
81
+ }
82
+ scanned = cursor
83
+ const startLine = line
84
+ let endLine = line
85
+ for (let index = 0; index < needle.length - 1; index++) {
86
+ if (needle[index] === "\n") endLine++
87
+ }
88
+ found.push({ start: cursor, end: cursor + needle.length, startLine, endLine })
89
+ // Resume past the match, not one byte into it. A caller replaces these spans
90
+ // in order, so overlapping occurrences are not separately replaceable: in
91
+ // "aaa" the anchor "aa" is reported once, because consuming the first
92
+ // occurrence leaves no second one. Scanning by one byte instead reported
93
+ // both, and the splice wrote the replacement over bytes the first span
94
+ // already owned.
95
+ cursor = content.indexOf(needle, cursor + needle.length)
96
+ }
97
+ return found
98
+ }
99
+
100
+ const trimmedRight = (line: string): string => line.replace(/[ \t]+$/, "")
101
+
102
+ const collapsed = (line: string): string => line.replace(/[ \t]+/g, " ").trim()
103
+
104
+ const matchByLine = (
105
+ haystack: ReadonlyArray<string>,
106
+ wanted: ReadonlyArray<string>,
107
+ normalize: (line: string) => string
108
+ ): number => {
109
+ const target = wanted.map(normalize)
110
+ const normalized = haystack.map(normalize)
111
+ for (let index = 0; index + target.length <= haystack.length; index++) {
112
+ let matched = true
113
+ for (let step = 0; step < target.length; step++) {
114
+ if (normalized[index + step] !== target[step]) {
115
+ matched = false
116
+ break
117
+ }
118
+ }
119
+ if (matched) return index
120
+ }
121
+ return -1
122
+ }
123
+
124
+ /**
125
+ * The real region a failed needle was aiming at, with its line range.
126
+ *
127
+ * The loose strategies run in order — trailing whitespace, then collapsed inner
128
+ * whitespace, then the needle's first non-blank line alone — and the first that
129
+ * locates a region wins. `undefined` means not even one line of the needle
130
+ * occurs in the file, which is itself the answer: this is the wrong file.
131
+ *
132
+ * @category matching
133
+ * @since 1.0.0
134
+ */
135
+ export const nearest = (content: string, needle: string, pad = 3): Nearest | undefined => {
136
+ const haystack = sourceLines(content)
137
+ const wanted = [...sourceLines(needle)]
138
+ while (wanted.length > 0 && wanted[wanted.length - 1] === "") wanted.pop()
139
+ if (wanted.length === 0) return undefined
140
+ let at = matchByLine(haystack, wanted, trimmedRight)
141
+ let span = wanted.length
142
+ if (at < 0) at = matchByLine(haystack, wanted, collapsed)
143
+ if (at < 0) {
144
+ const anchor = wanted.map(collapsed).find((line) => line !== "")
145
+ if (anchor === undefined) return undefined
146
+ at = haystack.findIndex((line) => collapsed(line) === anchor)
147
+ span = 1
148
+ }
149
+ if (at < 0) return undefined
150
+ const from = Math.max(0, at - pad)
151
+ const to = Math.min(haystack.length, at + span + pad)
152
+ return { startLine: from + 1, endLine: to, text: haystack.slice(from, to).join("\n") }
153
+ }
154
+
155
+ /**
156
+ * The applied region rendered back for inspection: raw bytes, plus its range.
157
+ *
158
+ * A bad edit is only expensive when it is invisible. sphinx-7233 lost its
159
+ * verdict to an in-cell string surgery that captured an `else` branch, and the
160
+ * model never saw the hunk it had written.
161
+ *
162
+ * @category matching
163
+ * @since 1.0.0
164
+ */
165
+ export const hunk = (content: string, start: number, end: number, pad = 2): Nearest => {
166
+ const startLine = lineAt(content, start)
167
+ const endLine = startLine + Math.max(0, content.slice(start, end).split("\n").length - 1)
168
+ const haystack = sourceLines(content)
169
+ const from = Math.max(0, startLine - 1 - pad)
170
+ const to = Math.min(haystack.length, endLine + pad)
171
+ return { startLine: from + 1, endLine: to, text: haystack.slice(from, to).join("\n") }
172
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Path containment checks against a declared effect envelope.
3
+ *
4
+ * @since 1.0.0
5
+ */
6
+
7
+ import * as Effects from "@smthrs/core/Effects"
8
+
9
+ const normalize = (path: string): string => {
10
+ const collapsed = path.replace(/\/+/g, "/")
11
+ return collapsed.length > 1 ? collapsed.replace(/\/+$/, "") : collapsed
12
+ }
13
+
14
+ const hasDotSegment = (path: string): boolean => path.split("/").some((segment) => segment === "." || segment === "..")
15
+
16
+ /**
17
+ * Whether a path is covered by any entry of a declared read or write set.
18
+ *
19
+ * An entry covers itself, everything beneath it when it names a directory,
20
+ * and everything matched by the prefix-glob subset `/core` supports.
21
+ *
22
+ * @category predicates
23
+ * @since 1.0.0
24
+ */
25
+ export const withinEnvelope = (declared: ReadonlyArray<string>, path: string): boolean => {
26
+ const candidate = normalize(path)
27
+ if (candidate === "" || hasDotSegment(candidate)) return false
28
+ return declared.some((entry) => {
29
+ const normalized = normalize(entry)
30
+ if (normalized === "") return false
31
+ const envelope = normalized === "/" ? "/**" : normalized
32
+ return Effects.covers(envelope, candidate) || candidate.startsWith(`${normalized}/`)
33
+ })
34
+ }
35
+
36
+ /**
37
+ * A path without its trailing slashes, so a root compares and joins as one name.
38
+ *
39
+ * @category conversions
40
+ * @since 1.0.0
41
+ */
42
+ export const withoutTrailingSlash = (path: string): string => path.replace(/\/+$/, "")
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Per-file atomic replacement that preserves permission bits and ownership.
3
+ * The sibling is complete before rename; no crash-durability guarantee is made.
4
+ * A file whose owner this process cannot assign is rewritten in place instead.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+
9
+ import * as Effect from "effect/Effect"
10
+ import type * as FileSystem from "effect/FileSystem"
11
+ import * as Option from "effect/Option"
12
+ import type * as PlatformError from "effect/PlatformError"
13
+
14
+ const permissions = 0o7777
15
+
16
+ /**
17
+ * Replaces a file's text atomically, preserving its permission bits and owner.
18
+ *
19
+ * @category filesystem
20
+ * @since 1.0.0
21
+ */
22
+ export const writeFileString = (
23
+ fileSystem: FileSystem.FileSystem,
24
+ path: string,
25
+ content: string
26
+ ): Effect.Effect<void, PlatformError.PlatformError> =>
27
+ replace(fileSystem, path, (target, flag, mode) => fileSystem.writeFileString(target, content, { flag, mode }))
28
+
29
+ /**
30
+ * Replaces a file's bytes with the same atomic boundary used for text writes.
31
+ *
32
+ * @category filesystem
33
+ * @since 1.0.0
34
+ */
35
+ export const writeFile = (
36
+ fileSystem: FileSystem.FileSystem,
37
+ path: string,
38
+ content: Uint8Array
39
+ ): Effect.Effect<void, PlatformError.PlatformError> =>
40
+ replace(fileSystem, path, (target, flag, mode) => fileSystem.writeFile(target, content, { flag, mode }))
41
+
42
+ const replace = (
43
+ fileSystem: FileSystem.FileSystem,
44
+ path: string,
45
+ write: (
46
+ target: string,
47
+ flag: "wx" | "w",
48
+ mode: number | undefined
49
+ ) => Effect.Effect<void, PlatformError.PlatformError>
50
+ ): Effect.Effect<void, PlatformError.PlatformError> =>
51
+ Effect.gen(function*() {
52
+ const before = yield* fileSystem.stat(path).pipe(
53
+ Effect.catch((error) => error.reason._tag === "NotFound" ? Effect.succeed(undefined) : Effect.fail(error))
54
+ )
55
+ // Keep following an existing symlink, as an in-place write did.
56
+ const destination = before === undefined ? path : yield* fileSystem.realPath(path)
57
+ const temporary = destination.replace(/[^/\\]+$/, `.smithers-${globalThis.crypto.randomUUID()}.tmp`)
58
+ let owned = true
59
+ // Set when the sibling cannot take the file's owner; see the chown below.
60
+ let inPlace = false
61
+ yield* Effect.uninterruptibleMask((restore) =>
62
+ Effect.gen(function*() {
63
+ // Let the host finish its write before cancellation can unlink the name.
64
+ yield* write(temporary, "wx", before === undefined ? undefined : before.mode & permissions).pipe(
65
+ Effect.tapError((error) =>
66
+ Effect.sync(() => {
67
+ if (error.reason._tag === "AlreadyExists") owned = false
68
+ })
69
+ )
70
+ )
71
+ yield* restore(Effect.gen(function*() {
72
+ if (before === undefined) return
73
+ const after = yield* fileSystem.stat(temporary)
74
+ const uid = Option.getOrUndefined(before.uid)
75
+ const gid = Option.getOrUndefined(before.gid)
76
+ const ownerChanged = (uid !== undefined && uid !== Option.getOrUndefined(after.uid)) ||
77
+ (gid !== undefined && gid !== Option.getOrUndefined(after.gid))
78
+ if (ownerChanged) {
79
+ // Only root may give a file away. A writable file owned by another
80
+ // user (a shared checkout, a bind mount) cannot be replaced by a
81
+ // sibling this process owns without changing its owner, so it is
82
+ // rewritten in place instead: same inode, owner, and mode, at the
83
+ // cost of atomicity.
84
+ const chowned = yield* fileSystem.chown(temporary, uid ?? -1, gid ?? -1).pipe(
85
+ Effect.as(true),
86
+ Effect.catch((error) =>
87
+ error.reason._tag === "PermissionDenied" ? Effect.succeed(false) : Effect.fail(error)
88
+ )
89
+ )
90
+ if (!chowned) {
91
+ inPlace = true
92
+ return
93
+ }
94
+ }
95
+ // chown may clear set-id bits, so permissions are restored last.
96
+ if (ownerChanged || (after.mode & permissions) !== (before.mode & permissions)) {
97
+ yield* fileSystem.chmod(temporary, before.mode & permissions)
98
+ }
99
+ }))
100
+ if (!inPlace) yield* fileSystem.rename(temporary, destination)
101
+ }).pipe(
102
+ Effect.ensuring(
103
+ Effect.suspend(() => owned ? fileSystem.remove(temporary, { force: true }).pipe(Effect.orDie) : Effect.void)
104
+ )
105
+ )
106
+ )
107
+ if (inPlace) yield* write(destination, "w", undefined)
108
+ })
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The one list of directory names a repository walk leaves out.
3
+ *
4
+ * `grep`, `glob` and `ls` walks, the tree fingerprint, and workspace
5
+ * observation all read this list, so a directory one of them skips is never
6
+ * counted, matched, or fingerprinted by another. Every entry is derived state:
7
+ * version-control internals, dependency trees, caches, and the scratch
8
+ * checkouts the checkpoint and test-baseline flows create inside the
9
+ * workspace. A scratch checkout is a full copy of the repository at an older
10
+ * commit, so walking it duplicates every match from a stale tree.
11
+ *
12
+ * @since 1.0.0
13
+ */
14
+
15
+ /**
16
+ * Workspace-relative directory holding checkpoint checkouts.
17
+ *
18
+ * @private
19
+ * @since 1.0.0
20
+ */
21
+ export const checkpointScratch = ".flows-checkpoints"
22
+
23
+ /**
24
+ * Workspace-relative directory holding test-baseline checkouts.
25
+ *
26
+ * @private
27
+ * @since 1.0.0
28
+ */
29
+ export const testBaseScratch = ".flows-test-base"
30
+
31
+ /**
32
+ * Directory basenames no repository walk descends into.
33
+ *
34
+ * @private
35
+ * @since 1.0.0
36
+ */
37
+ export const repositoryDirectories: ReadonlyArray<string> = [
38
+ ".git",
39
+ ".hg",
40
+ ".jj",
41
+ ".svn",
42
+ ".flows",
43
+ ".artifacts",
44
+ ".backend-go-modcache",
45
+ ".pnpm-store",
46
+ ".worktrees",
47
+ "worktrees",
48
+ checkpointScratch,
49
+ testBaseScratch,
50
+ "node_modules",
51
+ "__pycache__",
52
+ ".venv",
53
+ ".tox",
54
+ ".nox",
55
+ ".eggs",
56
+ ".mypy_cache",
57
+ ".pytest_cache",
58
+ ".ruff_cache",
59
+ ".gradle",
60
+ ".turbo",
61
+ ".next"
62
+ ]
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The failure constructors and the literal escape both Search peers share.
3
+ *
4
+ * The validation and matching rules themselves are public, in
5
+ * `../SearchContract.ts`, because an external peer has to build on them. What
6
+ * is left here is what an external peer never calls: the three `StdError`
7
+ * shapes the contract fails with, the root-failure mapping, and the regex escape a fixed-string search
8
+ * applies before compiling.
9
+ *
10
+ * @since 1.0.0
11
+ */
12
+
13
+ import type * as PlatformError from "effect/PlatformError"
14
+ import * as StdError from "../StdError.ts"
15
+
16
+ /**
17
+ * Constructs the common unsupported-pattern failure.
18
+ *
19
+ * @private
20
+ * @since 1.0.0
21
+ */
22
+ export const invalidPattern = (pattern: string, detail: string): StdError.StdError =>
23
+ new StdError.StdError({ code: "invalid_pattern", message: `${rejectionPrefix}"${pattern}": ${detail}` })
24
+
25
+ /**
26
+ * How every rejection {@link invalidPattern} writes begins.
27
+ *
28
+ * @private
29
+ * @since 1.0.0
30
+ */
31
+ export const rejectionPrefix = "Unsupported ripgrep pattern "
32
+
33
+ /**
34
+ * Constructs the common invalid-options failure.
35
+ *
36
+ * @private
37
+ * @since 1.0.0
38
+ */
39
+ export const invalidInput = (detail: string): StdError.StdError =>
40
+ new StdError.StdError({ code: "invalid_input", message: `Invalid ripgrep options: ${detail}` })
41
+
42
+ /**
43
+ * Constructs the common missing-root failure.
44
+ *
45
+ * @private
46
+ * @since 1.0.0
47
+ */
48
+ export const notFound = (path: string): StdError.StdError =>
49
+ new StdError.StdError({ code: "not_found", message: `Path not found: ${path}`, path })
50
+
51
+ /**
52
+ * Maps a failure to inspect the search root onto the contract's failures.
53
+ *
54
+ * Only a root that does not exist is `not_found`. Every other reason a stat
55
+ * or listing can fail (a guarded host that fails closed, a permission the
56
+ * process lacks, an I/O error) is a host operation failing, and it is
57
+ * reported as `command_failed` with the platform's own message, so the
58
+ * caller reads the real cause instead of a missing-path claim about a path
59
+ * that exists.
60
+ *
61
+ * @private
62
+ * @since 1.0.0
63
+ */
64
+ export const rootFailure = (path: string, error: PlatformError.PlatformError): StdError.StdError =>
65
+ error.reason._tag === "NotFound"
66
+ ? notFound(path)
67
+ : error.reason._tag === "PermissionDenied"
68
+ ? new StdError.StdError({ code: "permission_denied", message: `Cannot search ${path}: ${error.message}`, path })
69
+ : new StdError.StdError({ code: "command_failed", message: `Cannot search ${path}: ${error.message}`, path })
70
+
71
+ /**
72
+ * Escapes literal text for JavaScript regular expressions.
73
+ *
74
+ * @private
75
+ * @since 1.0.0
76
+ */
77
+ export const escapeRegex = (value: string): string => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The definition a line sits inside, read off the file's own shape.
3
+ *
4
+ * A search hit is a line number, and a line number is not a read window. Agents
5
+ * guess one: `offset: line - 10, limit: 40`, which lands short (astropy-15569
6
+ * missed `get_lookup` by one line and probed the wrong binding) or long (six
7
+ * blind-offset reads on sympy-13878). The enclosing definition is the window the
8
+ * hit actually belongs to, and for indentation- and brace-structured source it
9
+ * is derivable from the text already in hand.
10
+ *
11
+ * This is a heuristic and reports only what it can see plainly: a declaration
12
+ * keyword, a name, and the block that keyword opens. When the shape is not
13
+ * plain — a match at top level, a language this table does not name, a
14
+ * declaration split across lines — it answers `undefined` rather than guessing,
15
+ * because a wrong window is worse than none.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+
20
+ /**
21
+ * The definition enclosing a line.
22
+ *
23
+ * @category models
24
+ * @since 1.0.0
25
+ */
26
+ export interface Symbol {
27
+ readonly kind: string
28
+ readonly name: string
29
+ readonly startLine: number
30
+ readonly endLine: number
31
+ }
32
+
33
+ /**
34
+ * Declaration keywords this heuristic recognises across the languages the
35
+ * standard flows meet. Modifiers before the keyword are skipped, the name after
36
+ * it is captured, and everything else is left alone.
37
+ */
38
+ const declaration =
39
+ /^([ \t]*)(?:(?:async|export|default|public|private|protected|internal|static|final|abstract|open|pub(?:\([^)]*\))?|unsafe|const|declare)[ \t]+)*(def|class|function|fn|func|struct|impl|interface|trait|enum|module|namespace|type|sub|method)[ \t]+([A-Za-z_$][A-Za-z0-9_$]*)/
40
+
41
+ const closer = /^[ \t]*[)}\]]/
42
+
43
+ const indentOf = (line: string): number => /^[ \t]*/.exec(line)![0].length
44
+
45
+ const blank = (line: string): boolean => line.trim() === ""
46
+
47
+ /**
48
+ * The definition enclosing a 1-based line, or `undefined` when there is none to
49
+ * read plainly.
50
+ *
51
+ * @category navigation
52
+ * @since 1.0.0
53
+ */
54
+ export const enclosing = (lines: ReadonlyArray<string>, line: number): Symbol | undefined => {
55
+ const index = line - 1
56
+ if (index < 0 || index >= lines.length) return undefined
57
+ // A blank match line has no indentation of its own; the nearest text above it
58
+ // does, and that is the block the blank line belongs to.
59
+ let reference = index
60
+ while (reference > 0 && blank(lines[reference]!)) reference--
61
+ const indent = indentOf(lines[reference]!)
62
+ let start = -1
63
+ let parsed: RegExpExecArray | null = null
64
+ for (let candidate = index; candidate >= 0; candidate--) {
65
+ const text = lines[candidate]!
66
+ if (blank(text)) continue
67
+ const found = declaration.exec(text)
68
+ if (found === null) continue
69
+ if (candidate !== index && indentOf(text) >= indent) continue
70
+ start = candidate
71
+ parsed = found
72
+ break
73
+ }
74
+ if (parsed === null) return undefined
75
+ const opening = indentOf(lines[start]!)
76
+ let end = lines.length - 1
77
+ for (let candidate = start + 1; candidate < lines.length; candidate++) {
78
+ const text = lines[candidate]!
79
+ if (blank(text)) continue
80
+ if (indentOf(text) > opening) continue
81
+ // A brace language closes the block at the declaration's own indentation,
82
+ // and that closing line is part of the definition rather than what follows.
83
+ end = closer.test(text) ? candidate : candidate - 1
84
+ break
85
+ }
86
+ while (end > start && blank(lines[end]!)) end--
87
+ return { kind: parsed[2]!, name: parsed[3]!, startLine: start + 1, endLine: end + 1 }
88
+ }