@smthrs/std 0.0.0-stage → 1.0.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +148 -0
- package/LICENSE +21 -0
- package/README.md +156 -2
- package/dist/cjs/ApplyPatch.d.ts +174 -0
- package/dist/cjs/ApplyPatch.d.ts.map +1 -0
- package/dist/cjs/ApplyPatch.js +309 -0
- package/dist/cjs/ApplyPatch.js.map +7 -0
- package/dist/cjs/Bash.d.ts +390 -0
- package/dist/cjs/Bash.d.ts.map +1 -0
- package/dist/cjs/Bash.js +333 -0
- package/dist/cjs/Bash.js.map +7 -0
- package/dist/cjs/Checkpoints.d.ts +322 -0
- package/dist/cjs/Checkpoints.d.ts.map +1 -0
- package/dist/cjs/Checkpoints.js +233 -0
- package/dist/cjs/Checkpoints.js.map +7 -0
- package/dist/cjs/Container.d.ts +132 -0
- package/dist/cjs/Container.d.ts.map +1 -0
- package/dist/cjs/Container.js +113 -0
- package/dist/cjs/Container.js.map +7 -0
- package/dist/cjs/Edit.d.ts +203 -0
- package/dist/cjs/Edit.d.ts.map +1 -0
- package/dist/cjs/Edit.js +258 -0
- package/dist/cjs/Edit.js.map +7 -0
- package/dist/cjs/ExaWebSearch.d.ts +22 -0
- package/dist/cjs/ExaWebSearch.d.ts.map +1 -0
- package/dist/cjs/ExaWebSearch.js +138 -0
- package/dist/cjs/ExaWebSearch.js.map +7 -0
- package/dist/cjs/Explore.d.ts +328 -0
- package/dist/cjs/Explore.d.ts.map +1 -0
- package/dist/cjs/Explore.js +90 -0
- package/dist/cjs/Explore.js.map +7 -0
- package/dist/cjs/Fetch.d.ts +130 -0
- package/dist/cjs/Fetch.d.ts.map +1 -0
- package/dist/cjs/Fetch.js +64 -0
- package/dist/cjs/Fetch.js.map +7 -0
- package/dist/cjs/Glob.d.ts +204 -0
- package/dist/cjs/Glob.d.ts.map +1 -0
- package/dist/cjs/Glob.js +94 -0
- package/dist/cjs/Glob.js.map +7 -0
- package/dist/cjs/Grep.d.ts +347 -0
- package/dist/cjs/Grep.d.ts.map +1 -0
- package/dist/cjs/Grep.js +181 -0
- package/dist/cjs/Grep.js.map +7 -0
- package/dist/cjs/HttpPost.d.ts +130 -0
- package/dist/cjs/HttpPost.d.ts.map +1 -0
- package/dist/cjs/HttpPost.js +72 -0
- package/dist/cjs/HttpPost.js.map +7 -0
- package/dist/cjs/LanguageServer.d.ts +90 -0
- package/dist/cjs/LanguageServer.d.ts.map +1 -0
- package/dist/cjs/LanguageServer.js +60 -0
- package/dist/cjs/LanguageServer.js.map +7 -0
- package/dist/cjs/Ls.d.ts +164 -0
- package/dist/cjs/Ls.d.ts.map +1 -0
- package/dist/cjs/Ls.js +136 -0
- package/dist/cjs/Ls.js.map +7 -0
- package/dist/cjs/Lsp.d.ts +125 -0
- package/dist/cjs/Lsp.d.ts.map +1 -0
- package/dist/cjs/Lsp.js +137 -0
- package/dist/cjs/Lsp.js.map +7 -0
- package/dist/cjs/Manifest.d.ts +918 -0
- package/dist/cjs/Manifest.d.ts.map +1 -0
- package/dist/cjs/Manifest.js +144 -0
- package/dist/cjs/Manifest.js.map +7 -0
- package/dist/cjs/NativeSearch.d.ts +38 -0
- package/dist/cjs/NativeSearch.d.ts.map +1 -0
- package/dist/cjs/NativeSearch.js +326 -0
- package/dist/cjs/NativeSearch.js.map +7 -0
- package/dist/cjs/NodeLanguageServer.d.ts +128 -0
- package/dist/cjs/NodeLanguageServer.d.ts.map +1 -0
- package/dist/cjs/NodeLanguageServer.js +796 -0
- package/dist/cjs/NodeLanguageServer.js.map +7 -0
- package/dist/cjs/PortableSearch.d.ts +36 -0
- package/dist/cjs/PortableSearch.d.ts.map +1 -0
- package/dist/cjs/PortableSearch.js +240 -0
- package/dist/cjs/PortableSearch.js.map +7 -0
- package/dist/cjs/Probe.d.ts +193 -0
- package/dist/cjs/Probe.d.ts.map +1 -0
- package/dist/cjs/Probe.js +134 -0
- package/dist/cjs/Probe.js.map +7 -0
- package/dist/cjs/Read.d.ts +189 -0
- package/dist/cjs/Read.d.ts.map +1 -0
- package/dist/cjs/Read.js +223 -0
- package/dist/cjs/Read.js.map +7 -0
- package/dist/cjs/Relocate.d.ts +73 -0
- package/dist/cjs/Relocate.d.ts.map +1 -0
- package/dist/cjs/Relocate.js +72 -0
- package/dist/cjs/Relocate.js.map +7 -0
- package/dist/cjs/RemoteSearch.d.ts +54 -0
- package/dist/cjs/RemoteSearch.d.ts.map +1 -0
- package/dist/cjs/RemoteSearch.js +134 -0
- package/dist/cjs/RemoteSearch.js.map +7 -0
- package/dist/cjs/Search.d.ts +163 -0
- package/dist/cjs/Search.d.ts.map +1 -0
- package/dist/cjs/Search.js +51 -0
- package/dist/cjs/Search.js.map +7 -0
- package/dist/cjs/SearchConformance.d.ts +115 -0
- package/dist/cjs/SearchConformance.d.ts.map +1 -0
- package/dist/cjs/SearchConformance.js +172 -0
- package/dist/cjs/SearchConformance.js.map +7 -0
- package/dist/cjs/SearchContract.d.ts +114 -0
- package/dist/cjs/SearchContract.d.ts.map +1 -0
- package/dist/cjs/SearchContract.js +339 -0
- package/dist/cjs/SearchContract.js.map +7 -0
- package/dist/cjs/ShellCommand.d.ts +164 -0
- package/dist/cjs/ShellCommand.d.ts.map +1 -0
- package/dist/cjs/ShellCommand.js +102 -0
- package/dist/cjs/ShellCommand.js.map +7 -0
- package/dist/cjs/StdError.d.ts +55 -0
- package/dist/cjs/StdError.d.ts.map +1 -0
- package/dist/cjs/StdError.js +74 -0
- package/dist/cjs/StdError.js.map +7 -0
- package/dist/cjs/TestRun.d.ts +311 -0
- package/dist/cjs/TestRun.d.ts.map +1 -0
- package/dist/cjs/TestRun.js +228 -0
- package/dist/cjs/TestRun.js.map +7 -0
- package/dist/cjs/TestRunner.d.ts +102 -0
- package/dist/cjs/TestRunner.d.ts.map +1 -0
- package/dist/cjs/TestRunner.js +54 -0
- package/dist/cjs/TestRunner.js.map +7 -0
- package/dist/cjs/TreeFingerprint.d.ts +140 -0
- package/dist/cjs/TreeFingerprint.d.ts.map +1 -0
- package/dist/cjs/TreeFingerprint.js +87 -0
- package/dist/cjs/TreeFingerprint.js.map +7 -0
- package/dist/cjs/UpdatePlan.d.ts +152 -0
- package/dist/cjs/UpdatePlan.d.ts.map +1 -0
- package/dist/cjs/UpdatePlan.js +87 -0
- package/dist/cjs/UpdatePlan.js.map +7 -0
- package/dist/cjs/WebFetch.d.ts +134 -0
- package/dist/cjs/WebFetch.d.ts.map +1 -0
- package/dist/cjs/WebFetch.js +140 -0
- package/dist/cjs/WebFetch.js.map +7 -0
- package/dist/cjs/WebSearch.d.ts +181 -0
- package/dist/cjs/WebSearch.d.ts.map +1 -0
- package/dist/cjs/WebSearch.js +86 -0
- package/dist/cjs/WebSearch.js.map +7 -0
- package/dist/cjs/Write.d.ts +147 -0
- package/dist/cjs/Write.d.ts.map +1 -0
- package/dist/cjs/Write.js +122 -0
- package/dist/cjs/Write.js.map +7 -0
- package/dist/cjs/index.d.ts +129 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +101 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/ApplyPatch.d.ts +145 -0
- package/dist/cjs/internal/ApplyPatch.d.ts.map +1 -0
- package/dist/cjs/internal/ApplyPatch.js +462 -0
- package/dist/cjs/internal/ApplyPatch.js.map +7 -0
- package/dist/cjs/internal/CodexText.d.ts +73 -0
- package/dist/cjs/internal/CodexText.d.ts.map +1 -0
- package/dist/cjs/internal/CodexText.js +108 -0
- package/dist/cjs/internal/CodexText.js.map +7 -0
- package/dist/cjs/internal/Declaration.d.ts +49 -0
- package/dist/cjs/internal/Declaration.d.ts.map +1 -0
- package/dist/cjs/internal/Declaration.js +46 -0
- package/dist/cjs/internal/Declaration.js.map +7 -0
- package/dist/cjs/internal/Diagnostics.d.ts +77 -0
- package/dist/cjs/internal/Diagnostics.d.ts.map +1 -0
- package/dist/cjs/internal/Diagnostics.js +89 -0
- package/dist/cjs/internal/Diagnostics.js.map +7 -0
- package/dist/cjs/internal/EnvelopePrecheck.d.ts +69 -0
- package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/cjs/internal/EnvelopePrecheck.js +323 -0
- package/dist/cjs/internal/EnvelopePrecheck.js.map +7 -0
- package/dist/cjs/internal/Exec.d.ts +151 -0
- package/dist/cjs/internal/Exec.d.ts.map +1 -0
- package/dist/cjs/internal/Exec.js +207 -0
- package/dist/cjs/internal/Exec.js.map +7 -0
- package/dist/cjs/internal/FileMutation.d.ts +109 -0
- package/dist/cjs/internal/FileMutation.d.ts.map +1 -0
- package/dist/cjs/internal/FileMutation.js +116 -0
- package/dist/cjs/internal/FileMutation.js.map +7 -0
- package/dist/cjs/internal/FsFailure.d.ts +38 -0
- package/dist/cjs/internal/FsFailure.d.ts.map +1 -0
- package/dist/cjs/internal/FsFailure.js +40 -0
- package/dist/cjs/internal/FsFailure.js.map +7 -0
- package/dist/cjs/internal/GitWorktree.d.ts +108 -0
- package/dist/cjs/internal/GitWorktree.d.ts.map +1 -0
- package/dist/cjs/internal/GitWorktree.js +276 -0
- package/dist/cjs/internal/GitWorktree.js.map +7 -0
- package/dist/cjs/internal/Grouping.d.ts +51 -0
- package/dist/cjs/internal/Grouping.d.ts.map +1 -0
- package/dist/cjs/internal/Grouping.js +83 -0
- package/dist/cjs/internal/Grouping.js.map +7 -0
- package/dist/cjs/internal/Html.d.ts +20 -0
- package/dist/cjs/internal/Html.d.ts.map +1 -0
- package/dist/cjs/internal/Html.js +81 -0
- package/dist/cjs/internal/Html.js.map +7 -0
- package/dist/cjs/internal/Http.d.ts +95 -0
- package/dist/cjs/internal/Http.d.ts.map +1 -0
- package/dist/cjs/internal/Http.js +153 -0
- package/dist/cjs/internal/Http.js.map +7 -0
- package/dist/cjs/internal/HttpNetwork.d.ts +27 -0
- package/dist/cjs/internal/HttpNetwork.d.ts.map +1 -0
- package/dist/cjs/internal/HttpNetwork.js +146 -0
- package/dist/cjs/internal/HttpNetwork.js.map +7 -0
- package/dist/cjs/internal/Ignore.d.ts +37 -0
- package/dist/cjs/internal/Ignore.d.ts.map +1 -0
- package/dist/cjs/internal/Ignore.js +100 -0
- package/dist/cjs/internal/Ignore.js.map +7 -0
- package/dist/cjs/internal/LinearRegex.d.ts +19 -0
- package/dist/cjs/internal/LinearRegex.d.ts.map +1 -0
- package/dist/cjs/internal/LinearRegex.js +166 -0
- package/dist/cjs/internal/LinearRegex.js.map +7 -0
- package/dist/cjs/internal/Match.d.ts +85 -0
- package/dist/cjs/internal/Match.d.ts.map +1 -0
- package/dist/cjs/internal/Match.js +99 -0
- package/dist/cjs/internal/Match.js.map +7 -0
- package/dist/cjs/internal/Paths.d.ts +23 -0
- package/dist/cjs/internal/Paths.d.ts.map +1 -0
- package/dist/cjs/internal/Paths.js +52 -0
- package/dist/cjs/internal/Paths.js.map +7 -0
- package/dist/cjs/internal/Preserve.d.ts +25 -0
- package/dist/cjs/internal/Preserve.d.ts.map +1 -0
- package/dist/cjs/internal/Preserve.js +88 -0
- package/dist/cjs/internal/Preserve.js.map +7 -0
- package/dist/cjs/internal/Prune.d.ts +35 -0
- package/dist/cjs/internal/Prune.d.ts.map +1 -0
- package/dist/cjs/internal/Prune.js +54 -0
- package/dist/cjs/internal/Prune.js.map +7 -0
- package/dist/cjs/internal/RemoteTree.d.ts +60 -0
- package/dist/cjs/internal/RemoteTree.d.ts.map +1 -0
- package/dist/cjs/internal/RemoteTree.js +123 -0
- package/dist/cjs/internal/RemoteTree.js.map +7 -0
- package/dist/cjs/internal/SearchContract.d.ts +63 -0
- package/dist/cjs/internal/SearchContract.d.ts.map +1 -0
- package/dist/cjs/internal/SearchContract.js +46 -0
- package/dist/cjs/internal/SearchContract.js.map +7 -0
- package/dist/cjs/internal/Symbols.d.ts +39 -0
- package/dist/cjs/internal/Symbols.d.ts.map +1 -0
- package/dist/cjs/internal/Symbols.js +59 -0
- package/dist/cjs/internal/Symbols.js.map +7 -0
- package/dist/cjs/internal/Tar.d.ts +23 -0
- package/dist/cjs/internal/Tar.d.ts.map +1 -0
- package/dist/cjs/internal/Tar.js +86 -0
- package/dist/cjs/internal/Tar.js.map +7 -0
- package/dist/cjs/internal/TestReport.d.ts +52 -0
- package/dist/cjs/internal/TestReport.d.ts.map +1 -0
- package/dist/cjs/internal/TestReport.js +131 -0
- package/dist/cjs/internal/TestReport.js.map +7 -0
- package/dist/cjs/internal/Text.d.ts +125 -0
- package/dist/cjs/internal/Text.d.ts.map +1 -0
- package/dist/cjs/internal/Text.js +85 -0
- package/dist/cjs/internal/Text.js.map +7 -0
- package/dist/cjs/internal/Url.d.ts +13 -0
- package/dist/cjs/internal/Url.d.ts.map +1 -0
- package/dist/cjs/internal/Url.js +35 -0
- package/dist/cjs/internal/Url.js.map +7 -0
- package/dist/cjs/internal/Walk.d.ts +72 -0
- package/dist/cjs/internal/Walk.d.ts.map +1 -0
- package/dist/cjs/internal/Walk.js +108 -0
- package/dist/cjs/internal/Walk.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/ApplyPatch.d.ts +174 -0
- package/dist/esm/ApplyPatch.d.ts.map +1 -0
- package/dist/esm/ApplyPatch.js +346 -0
- package/dist/esm/ApplyPatch.js.map +1 -0
- package/dist/esm/Bash.d.ts +390 -0
- package/dist/esm/Bash.d.ts.map +1 -0
- package/dist/esm/Bash.js +514 -0
- package/dist/esm/Bash.js.map +1 -0
- package/dist/esm/Checkpoints.d.ts +322 -0
- package/dist/esm/Checkpoints.d.ts.map +1 -0
- package/dist/esm/Checkpoints.js +396 -0
- package/dist/esm/Checkpoints.js.map +1 -0
- package/dist/esm/Container.d.ts +132 -0
- package/dist/esm/Container.d.ts.map +1 -0
- package/dist/esm/Container.js +151 -0
- package/dist/esm/Container.js.map +1 -0
- package/dist/esm/Edit.d.ts +203 -0
- package/dist/esm/Edit.d.ts.map +1 -0
- package/dist/esm/Edit.js +296 -0
- package/dist/esm/Edit.js.map +1 -0
- package/dist/esm/ExaWebSearch.d.ts +22 -0
- package/dist/esm/ExaWebSearch.d.ts.map +1 -0
- package/dist/esm/ExaWebSearch.js +107 -0
- package/dist/esm/ExaWebSearch.js.map +1 -0
- package/dist/esm/Explore.d.ts +328 -0
- package/dist/esm/Explore.d.ts.map +1 -0
- package/dist/esm/Explore.js +106 -0
- package/dist/esm/Explore.js.map +1 -0
- package/dist/esm/Fetch.d.ts +130 -0
- package/dist/esm/Fetch.d.ts.map +1 -0
- package/dist/esm/Fetch.js +91 -0
- package/dist/esm/Fetch.js.map +1 -0
- package/dist/esm/Glob.d.ts +204 -0
- package/dist/esm/Glob.d.ts.map +1 -0
- package/dist/esm/Glob.js +177 -0
- package/dist/esm/Glob.js.map +1 -0
- package/dist/esm/Grep.d.ts +347 -0
- package/dist/esm/Grep.d.ts.map +1 -0
- package/dist/esm/Grep.js +289 -0
- package/dist/esm/Grep.js.map +1 -0
- package/dist/esm/HttpPost.d.ts +130 -0
- package/dist/esm/HttpPost.d.ts.map +1 -0
- package/dist/esm/HttpPost.js +89 -0
- package/dist/esm/HttpPost.js.map +1 -0
- package/dist/esm/LanguageServer.d.ts +90 -0
- package/dist/esm/LanguageServer.d.ts.map +1 -0
- package/dist/esm/LanguageServer.js +57 -0
- package/dist/esm/LanguageServer.js.map +1 -0
- package/dist/esm/Ls.d.ts +164 -0
- package/dist/esm/Ls.d.ts.map +1 -0
- package/dist/esm/Ls.js +178 -0
- package/dist/esm/Ls.js.map +1 -0
- package/dist/esm/Lsp.d.ts +125 -0
- package/dist/esm/Lsp.d.ts.map +1 -0
- package/dist/esm/Lsp.js +165 -0
- package/dist/esm/Lsp.js.map +1 -0
- package/dist/esm/Manifest.d.ts +918 -0
- package/dist/esm/Manifest.d.ts.map +1 -0
- package/dist/esm/Manifest.js +153 -0
- package/dist/esm/Manifest.js.map +1 -0
- package/dist/esm/NativeSearch.d.ts +38 -0
- package/dist/esm/NativeSearch.d.ts.map +1 -0
- package/dist/esm/NativeSearch.js +378 -0
- package/dist/esm/NativeSearch.js.map +1 -0
- package/dist/esm/NodeLanguageServer.d.ts +128 -0
- package/dist/esm/NodeLanguageServer.d.ts.map +1 -0
- package/dist/esm/NodeLanguageServer.js +843 -0
- package/dist/esm/NodeLanguageServer.js.map +1 -0
- package/dist/esm/PortableSearch.d.ts +36 -0
- package/dist/esm/PortableSearch.d.ts.map +1 -0
- package/dist/esm/PortableSearch.js +256 -0
- package/dist/esm/PortableSearch.js.map +1 -0
- package/dist/esm/Probe.d.ts +193 -0
- package/dist/esm/Probe.d.ts.map +1 -0
- package/dist/esm/Probe.js +225 -0
- package/dist/esm/Probe.js.map +1 -0
- package/dist/esm/Read.d.ts +189 -0
- package/dist/esm/Read.d.ts.map +1 -0
- package/dist/esm/Read.js +300 -0
- package/dist/esm/Read.js.map +1 -0
- package/dist/esm/Relocate.d.ts +73 -0
- package/dist/esm/Relocate.d.ts.map +1 -0
- package/dist/esm/Relocate.js +153 -0
- package/dist/esm/Relocate.js.map +1 -0
- package/dist/esm/RemoteSearch.d.ts +54 -0
- package/dist/esm/RemoteSearch.d.ts.map +1 -0
- package/dist/esm/RemoteSearch.js +162 -0
- package/dist/esm/RemoteSearch.js.map +1 -0
- package/dist/esm/Search.d.ts +163 -0
- package/dist/esm/Search.d.ts.map +1 -0
- package/dist/esm/Search.js +47 -0
- package/dist/esm/Search.js.map +1 -0
- package/dist/esm/SearchConformance.d.ts +115 -0
- package/dist/esm/SearchConformance.d.ts.map +1 -0
- package/dist/esm/SearchConformance.js +193 -0
- package/dist/esm/SearchConformance.js.map +1 -0
- package/dist/esm/SearchContract.d.ts +114 -0
- package/dist/esm/SearchContract.d.ts.map +1 -0
- package/dist/esm/SearchContract.js +461 -0
- package/dist/esm/SearchContract.js.map +1 -0
- package/dist/esm/ShellCommand.d.ts +164 -0
- package/dist/esm/ShellCommand.d.ts.map +1 -0
- package/dist/esm/ShellCommand.js +159 -0
- package/dist/esm/ShellCommand.js.map +1 -0
- package/dist/esm/StdError.d.ts +55 -0
- package/dist/esm/StdError.d.ts.map +1 -0
- package/dist/esm/StdError.js +71 -0
- package/dist/esm/StdError.js.map +1 -0
- package/dist/esm/TestRun.d.ts +311 -0
- package/dist/esm/TestRun.d.ts.map +1 -0
- package/dist/esm/TestRun.js +316 -0
- package/dist/esm/TestRun.js.map +1 -0
- package/dist/esm/TestRunner.d.ts +102 -0
- package/dist/esm/TestRunner.d.ts.map +1 -0
- package/dist/esm/TestRunner.js +68 -0
- package/dist/esm/TestRunner.js.map +1 -0
- package/dist/esm/TreeFingerprint.d.ts +140 -0
- package/dist/esm/TreeFingerprint.d.ts.map +1 -0
- package/dist/esm/TreeFingerprint.js +170 -0
- package/dist/esm/TreeFingerprint.js.map +1 -0
- package/dist/esm/UpdatePlan.d.ts +152 -0
- package/dist/esm/UpdatePlan.d.ts.map +1 -0
- package/dist/esm/UpdatePlan.js +129 -0
- package/dist/esm/UpdatePlan.js.map +1 -0
- package/dist/esm/WebFetch.d.ts +134 -0
- package/dist/esm/WebFetch.d.ts.map +1 -0
- package/dist/esm/WebFetch.js +151 -0
- package/dist/esm/WebFetch.js.map +1 -0
- package/dist/esm/WebSearch.d.ts +181 -0
- package/dist/esm/WebSearch.d.ts.map +1 -0
- package/dist/esm/WebSearch.js +134 -0
- package/dist/esm/WebSearch.js.map +1 -0
- package/dist/esm/Write.d.ts +147 -0
- package/dist/esm/Write.d.ts.map +1 -0
- package/dist/esm/Write.js +144 -0
- package/dist/esm/Write.js.map +1 -0
- package/dist/esm/index.d.ts +129 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +129 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/ApplyPatch.d.ts +145 -0
- package/dist/esm/internal/ApplyPatch.d.ts.map +1 -0
- package/dist/esm/internal/ApplyPatch.js +489 -0
- package/dist/esm/internal/ApplyPatch.js.map +1 -0
- package/dist/esm/internal/CodexText.d.ts +73 -0
- package/dist/esm/internal/CodexText.d.ts.map +1 -0
- package/dist/esm/internal/CodexText.js +156 -0
- package/dist/esm/internal/CodexText.js.map +1 -0
- package/dist/esm/internal/Declaration.d.ts +49 -0
- package/dist/esm/internal/Declaration.d.ts.map +1 -0
- package/dist/esm/internal/Declaration.js +42 -0
- package/dist/esm/internal/Declaration.js.map +1 -0
- package/dist/esm/internal/Diagnostics.d.ts +77 -0
- package/dist/esm/internal/Diagnostics.d.ts.map +1 -0
- package/dist/esm/internal/Diagnostics.js +99 -0
- package/dist/esm/internal/Diagnostics.js.map +1 -0
- package/dist/esm/internal/EnvelopePrecheck.d.ts +69 -0
- package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/esm/internal/EnvelopePrecheck.js +426 -0
- package/dist/esm/internal/EnvelopePrecheck.js.map +1 -0
- package/dist/esm/internal/Exec.d.ts +151 -0
- package/dist/esm/internal/Exec.d.ts.map +1 -0
- package/dist/esm/internal/Exec.js +285 -0
- package/dist/esm/internal/Exec.js.map +1 -0
- package/dist/esm/internal/FileMutation.d.ts +109 -0
- package/dist/esm/internal/FileMutation.d.ts.map +1 -0
- package/dist/esm/internal/FileMutation.js +123 -0
- package/dist/esm/internal/FileMutation.js.map +1 -0
- package/dist/esm/internal/FsFailure.d.ts +38 -0
- package/dist/esm/internal/FsFailure.d.ts.map +1 -0
- package/dist/esm/internal/FsFailure.js +39 -0
- package/dist/esm/internal/FsFailure.js.map +1 -0
- package/dist/esm/internal/GitWorktree.d.ts +108 -0
- package/dist/esm/internal/GitWorktree.d.ts.map +1 -0
- package/dist/esm/internal/GitWorktree.js +352 -0
- package/dist/esm/internal/GitWorktree.js.map +1 -0
- package/dist/esm/internal/Grouping.d.ts +51 -0
- package/dist/esm/internal/Grouping.d.ts.map +1 -0
- package/dist/esm/internal/Grouping.js +99 -0
- package/dist/esm/internal/Grouping.js.map +1 -0
- package/dist/esm/internal/Html.d.ts +20 -0
- package/dist/esm/internal/Html.d.ts.map +1 -0
- package/dist/esm/internal/Html.js +70 -0
- package/dist/esm/internal/Html.js.map +1 -0
- package/dist/esm/internal/Http.d.ts +95 -0
- package/dist/esm/internal/Http.d.ts.map +1 -0
- package/dist/esm/internal/Http.js +154 -0
- package/dist/esm/internal/Http.js.map +1 -0
- package/dist/esm/internal/HttpNetwork.d.ts +27 -0
- package/dist/esm/internal/HttpNetwork.d.ts.map +1 -0
- package/dist/esm/internal/HttpNetwork.js +114 -0
- package/dist/esm/internal/HttpNetwork.js.map +1 -0
- package/dist/esm/internal/Ignore.d.ts +37 -0
- package/dist/esm/internal/Ignore.d.ts.map +1 -0
- package/dist/esm/internal/Ignore.js +128 -0
- package/dist/esm/internal/Ignore.js.map +1 -0
- package/dist/esm/internal/LinearRegex.d.ts +19 -0
- package/dist/esm/internal/LinearRegex.d.ts.map +1 -0
- package/dist/esm/internal/LinearRegex.js +176 -0
- package/dist/esm/internal/LinearRegex.js.map +1 -0
- package/dist/esm/internal/Match.d.ts +85 -0
- package/dist/esm/internal/Match.d.ts.map +1 -0
- package/dist/esm/internal/Match.js +142 -0
- package/dist/esm/internal/Match.js.map +1 -0
- package/dist/esm/internal/Paths.d.ts +23 -0
- package/dist/esm/internal/Paths.d.ts.map +1 -0
- package/dist/esm/internal/Paths.js +40 -0
- package/dist/esm/internal/Paths.js.map +1 -0
- package/dist/esm/internal/Preserve.d.ts +25 -0
- package/dist/esm/internal/Preserve.d.ts.map +1 -0
- package/dist/esm/internal/Preserve.js +70 -0
- package/dist/esm/internal/Preserve.js.map +1 -0
- package/dist/esm/internal/Prune.d.ts +35 -0
- package/dist/esm/internal/Prune.d.ts.map +1 -0
- package/dist/esm/internal/Prune.js +60 -0
- package/dist/esm/internal/Prune.js.map +1 -0
- package/dist/esm/internal/RemoteTree.d.ts +60 -0
- package/dist/esm/internal/RemoteTree.d.ts.map +1 -0
- package/dist/esm/internal/RemoteTree.js +132 -0
- package/dist/esm/internal/RemoteTree.js.map +1 -0
- package/dist/esm/internal/SearchContract.d.ts +63 -0
- package/dist/esm/internal/SearchContract.d.ts.map +1 -0
- package/dist/esm/internal/SearchContract.js +66 -0
- package/dist/esm/internal/SearchContract.js.map +1 -0
- package/dist/esm/internal/Symbols.d.ts +39 -0
- package/dist/esm/internal/Symbols.d.ts.map +1 -0
- package/dist/esm/internal/Symbols.js +79 -0
- package/dist/esm/internal/Symbols.js.map +1 -0
- package/dist/esm/internal/Tar.d.ts +23 -0
- package/dist/esm/internal/Tar.d.ts.map +1 -0
- package/dist/esm/internal/Tar.js +97 -0
- package/dist/esm/internal/Tar.js.map +1 -0
- package/dist/esm/internal/TestReport.d.ts +52 -0
- package/dist/esm/internal/TestReport.d.ts.map +1 -0
- package/dist/esm/internal/TestReport.js +172 -0
- package/dist/esm/internal/TestReport.js.map +1 -0
- package/dist/esm/internal/Text.d.ts +125 -0
- package/dist/esm/internal/Text.d.ts.map +1 -0
- package/dist/esm/internal/Text.js +141 -0
- package/dist/esm/internal/Text.js.map +1 -0
- package/dist/esm/internal/Url.d.ts +13 -0
- package/dist/esm/internal/Url.d.ts.map +1 -0
- package/dist/esm/internal/Url.js +27 -0
- package/dist/esm/internal/Url.js.map +1 -0
- package/dist/esm/internal/Walk.d.ts +72 -0
- package/dist/esm/internal/Walk.d.ts.map +1 -0
- package/dist/esm/internal/Walk.js +126 -0
- package/dist/esm/internal/Walk.js.map +1 -0
- package/docs/README.md +119 -0
- package/docs/api.md +499 -0
- package/docs/concepts/effects-and-capabilities.md +138 -0
- package/docs/concepts/flows-and-handlers.md +115 -0
- package/docs/concepts/limits-and-disclosure.md +105 -0
- package/docs/concepts/search-contract.md +182 -0
- package/docs/guides/bind-the-standard-flows.md +116 -0
- package/docs/guides/implement-a-search-peer.md +133 -0
- package/docs/guides/pin-a-checkpoint.md +161 -0
- package/docs/guides/query-a-language-server.md +257 -0
- package/docs/guides/reach-the-network.md +141 -0
- package/docs/guides/read-and-edit-a-file.md +240 -0
- package/docs/guides/run-a-shell-command.md +236 -0
- package/docs/guides/run-the-test-suite.md +154 -0
- package/docs/guides/search-a-workspace.md +148 -0
- package/docs/installation.md +115 -0
- package/docs/quickstart.md +125 -0
- package/docs/reference/flows.md +556 -0
- package/docs/troubleshooting.md +347 -0
- package/package.json +449 -3
- package/src/ApplyPatch.ts +458 -0
- package/src/Bash.ts +619 -0
- package/src/Checkpoints.ts +589 -0
- package/src/Container.ts +212 -0
- package/src/Edit.ts +366 -0
- package/src/ExaWebSearch.ts +145 -0
- package/src/Explore.ts +139 -0
- package/src/Fetch.ts +117 -0
- package/src/Glob.ts +200 -0
- package/src/Grep.ts +320 -0
- package/src/HttpPost.ts +120 -0
- package/src/LanguageServer.ts +110 -0
- package/src/Ls.ts +228 -0
- package/src/Lsp.ts +184 -0
- package/src/Manifest.ts +162 -0
- package/src/NativeSearch.ts +457 -0
- package/src/NodeLanguageServer.ts +1148 -0
- package/src/PortableSearch.ts +284 -0
- package/src/Probe.ts +284 -0
- package/src/Read.ts +359 -0
- package/src/Relocate.ts +166 -0
- package/src/RemoteSearch.ts +199 -0
- package/src/Search.ts +185 -0
- package/src/SearchConformance.ts +288 -0
- package/src/SearchContract.ts +489 -0
- package/src/ShellCommand.ts +201 -0
- package/src/StdError.ts +80 -0
- package/src/TestRun.ts +401 -0
- package/src/TestRunner.ts +119 -0
- package/src/TreeFingerprint.ts +200 -0
- package/src/UpdatePlan.ts +171 -0
- package/src/WebFetch.ts +194 -0
- package/src/WebSearch.ts +165 -0
- package/src/Write.ts +195 -0
- package/src/index.ts +157 -0
- package/src/internal/ApplyPatch.ts +601 -0
- package/src/internal/CodexText.ts +182 -0
- package/src/internal/Declaration.ts +60 -0
- package/src/internal/Diagnostics.ts +134 -0
- package/src/internal/EnvelopePrecheck.ts +489 -0
- package/src/internal/Exec.ts +427 -0
- package/src/internal/FileMutation.ts +231 -0
- package/src/internal/FsFailure.ts +51 -0
- package/src/internal/GitWorktree.ts +491 -0
- package/src/internal/Grouping.ts +106 -0
- package/src/internal/Html.ts +87 -0
- package/src/internal/Http.ts +209 -0
- package/src/internal/HttpNetwork.ts +153 -0
- package/src/internal/Ignore.ts +135 -0
- package/src/internal/LinearRegex.ts +173 -0
- package/src/internal/Match.ts +172 -0
- package/src/internal/Paths.ts +42 -0
- package/src/internal/Preserve.ts +108 -0
- package/src/internal/Prune.ts +62 -0
- package/src/internal/RemoteTree.ts +159 -0
- package/src/internal/SearchContract.ts +77 -0
- package/src/internal/Symbols.ts +88 -0
- package/src/internal/Tar.ts +95 -0
- package/src/internal/TestReport.ts +194 -0
- package/src/internal/Text.ts +185 -0
- package/src/internal/Url.ts +23 -0
- package/src/internal/Walk.ts +176 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinned trees, and the scratch checkouts a call runs against.
|
|
3
|
+
*
|
|
4
|
+
* A checkpoint is a **value**: minting one changes nothing about the workspace,
|
|
5
|
+
* and running a call against one leaves the live tree exactly as it stands.
|
|
6
|
+
* That is the whole of what it buys. Before it existed, the only way a run
|
|
7
|
+
* could answer "did this command fail before my change" was to undo the change
|
|
8
|
+
* — and the journals price that exactly. On `sympy__sympy-13878` the r95repl
|
|
9
|
+
* lane applied one byte-identical 4,789-character patch **five times**, four of
|
|
10
|
+
* those applications preceded by `git checkout -- sympy/stats/crv_types.py`,
|
|
11
|
+
* because a clean fails-before proof required reverting the very work it was
|
|
12
|
+
* meant to prove.
|
|
13
|
+
*
|
|
14
|
+
* This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and
|
|
15
|
+
* `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,
|
|
16
|
+
* the bound and the refusals; nothing in it knows what a tree is. This owns the
|
|
17
|
+
* two host operations that need one:
|
|
18
|
+
*
|
|
19
|
+
* - {@link Checkpoints.capture} records the working tree under an id, and
|
|
20
|
+
* - {@link Checkpoints.materialize} gives that tree back as a directory for the
|
|
21
|
+
* length of one call.
|
|
22
|
+
*
|
|
23
|
+
* ## The git binding, and the container constraint it is shaped by
|
|
24
|
+
*
|
|
25
|
+
* {@link layerGit} records a checkpoint with `git stash create`, then names the
|
|
26
|
+
* commit it prints in this repository's own git config rather than with a ref —
|
|
27
|
+
* see {@link configSection} for why a ref would hand the agent its own edit back
|
|
28
|
+
* as history. `stash create` is the one git command
|
|
29
|
+
* that records the working tree and changes nothing else: it does not move the
|
|
30
|
+
* worktree and does not touch the stash ref. It runs against a shadow
|
|
31
|
+
* `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),
|
|
32
|
+
* so it never writes the repository's index and never runs a program the
|
|
33
|
+
* workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same
|
|
34
|
+
* workspace and its own `git diff` is the run's evidence, so a capture that
|
|
35
|
+
* staged into the real index would be the harness editing the evidence while
|
|
36
|
+
* recording it. A tree with nothing to record prints nothing, and the
|
|
37
|
+
* checkpoint is then `HEAD` — which is exactly what the tree is.
|
|
38
|
+
*
|
|
39
|
+
* Untracked files are not in the recorded tree, which matches how the rig
|
|
40
|
+
* captures a patch: `capture-patch.sh` drops paths that did not exist when the
|
|
41
|
+
* agent started, so a checkpoint holds what a patch would hold.
|
|
42
|
+
*
|
|
43
|
+
* The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`
|
|
44
|
+
* — **inside** the workspace, which looks wrong and is the only thing that
|
|
45
|
+
* works. A benchmark check runs through `docker exec` inside `/testbed`, and
|
|
46
|
+
* `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere
|
|
47
|
+
* else on the host is simply not visible to the container, so the call would run
|
|
48
|
+
* against a path that does not exist. Placed under the workspace it is visible
|
|
49
|
+
* at the same subpath under the mount, needs no second mount, and needs no
|
|
50
|
+
* change to how the rig starts its container. `TestRun`'s `against: "base"`
|
|
51
|
+
* reached the same conclusion first and this reuses its shape;
|
|
52
|
+
* `evals/swebench/run-instance.sh` excludes the directory from patch capture for
|
|
53
|
+
* the same reason it excludes `.flows-test-base`.
|
|
54
|
+
*
|
|
55
|
+
* The checkout is added and removed around **one call**, which is stricter than
|
|
56
|
+
* the frame lifetime the design asks for and much simpler: there is no cache to
|
|
57
|
+
* invalidate, no id to leak, and a checkpoint used by three calls pays three
|
|
58
|
+
* checkouts rather than risking one stale directory. A run that reuses a
|
|
59
|
+
* checkpoint across frames simply re-materializes it, because the ref is what
|
|
60
|
+
* persists.
|
|
61
|
+
*
|
|
62
|
+
* ## What can be pointed at a checkpoint, and what cannot
|
|
63
|
+
*
|
|
64
|
+
* {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half
|
|
65
|
+
* knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half
|
|
66
|
+
* knows git. They change for different reasons, so they are different modules,
|
|
67
|
+
* and {@link relocate} is re-exported here because the harness reaches the whole
|
|
68
|
+
* feature through this one.
|
|
69
|
+
*
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
*/
|
|
72
|
+
import { ChildProcessSpawner } from "@smthrs/kernel/ChildProcessSpawner";
|
|
73
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
74
|
+
import * as Container from "./Container.js";
|
|
75
|
+
import * as Exec from "./internal/Exec.js";
|
|
76
|
+
import { GitWorktree } from "./internal/GitWorktree.js";
|
|
77
|
+
import { withoutTrailingSlash } from "./internal/Paths.js";
|
|
78
|
+
import * as Prune from "./internal/Prune.js";
|
|
79
|
+
import * as StdError from "./StdError.js";
|
|
80
|
+
import * as TestRunner from "./TestRunner.js";
|
|
81
|
+
/**
|
|
82
|
+
* The id naming the tree a run opened on.
|
|
83
|
+
*
|
|
84
|
+
* It is not minted: the host either recorded one before the agent started or it
|
|
85
|
+
* did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and
|
|
86
|
+
* then to `HEAD`, which is the same precedence `TestRun` uses for the same
|
|
87
|
+
* question — so a workspace that has one answer for a baseline has one answer
|
|
88
|
+
* for both.
|
|
89
|
+
*
|
|
90
|
+
* @category constants
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
*/
|
|
93
|
+
export const baseId = "base";
|
|
94
|
+
/**
|
|
95
|
+
* The directory checkpoints are materialized into, relative to the repository
|
|
96
|
+
* root and therefore also relative to a container's view of it.
|
|
97
|
+
*
|
|
98
|
+
* @category constants
|
|
99
|
+
* @since 1.0.0
|
|
100
|
+
*/
|
|
101
|
+
export const scratchDirectory = Prune.checkpointScratch;
|
|
102
|
+
/**
|
|
103
|
+
* The git-config section {@link layerGit} records minted checkpoints under.
|
|
104
|
+
*
|
|
105
|
+
* Config and **not a ref**, and that is the whole of the decision. A ref is
|
|
106
|
+
* history: `git log --all` lists it, `git show` prints it, and `git log --all
|
|
107
|
+
* -S` searches it — so a checkpoint named by a ref would hand an agent a commit
|
|
108
|
+
* containing its own edit and let it read that back as if it were upstream
|
|
109
|
+
* work. That exact class cost the measured program real money before the rig
|
|
110
|
+
* moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:
|
|
111
|
+
* django-13346 applied two of its own snapshots as a fake fix), and a ref here
|
|
112
|
+
* would reintroduce it one wave later.
|
|
113
|
+
*
|
|
114
|
+
* The commit object itself is unreferenced. It stays alive for the life of the
|
|
115
|
+
* run — nothing in a run prunes — and a checkout by id works perfectly well,
|
|
116
|
+
* which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable
|
|
117
|
+
* by id and no command that walks refs can reach it:
|
|
118
|
+
* `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer
|
|
119
|
+
* exactly as they did before the capture.
|
|
120
|
+
*
|
|
121
|
+
* One command still sees it, measured rather than argued in
|
|
122
|
+
* `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,
|
|
123
|
+
* because that is what an unreferenced commit is. A checkout is a standalone
|
|
124
|
+
* repository, not a worktree of this one, so `git log --all` does not list it
|
|
125
|
+
* even while a call runs in it. It is not reachable by a name that looks like project history, and the cell
|
|
126
|
+
* contract's environment section says outright that a dangling commit is this
|
|
127
|
+
* harness holding the agent's own tree — which is the half of the django-13346
|
|
128
|
+
* lesson that a store cannot enforce.
|
|
129
|
+
*
|
|
130
|
+
* @category constants
|
|
131
|
+
* @since 1.0.0
|
|
132
|
+
*/
|
|
133
|
+
export const configSection = "flows-checkpoint";
|
|
134
|
+
/**
|
|
135
|
+
* One tree this run has pinned.
|
|
136
|
+
*
|
|
137
|
+
* `ref` is the store's own name for it. Nothing above this module interprets
|
|
138
|
+
* it; it travels so the journal says which tree a checkpointed call read.
|
|
139
|
+
*
|
|
140
|
+
* @category models
|
|
141
|
+
* @since 1.0.0
|
|
142
|
+
*/
|
|
143
|
+
export class Snapshot extends Schema.Class("@smthrs/std/Checkpoints/Snapshot")({
|
|
144
|
+
id: Schema.String,
|
|
145
|
+
ref: Schema.String
|
|
146
|
+
}) {
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The {@link Checkpoints} service tag.
|
|
150
|
+
*
|
|
151
|
+
* @category services
|
|
152
|
+
* @since 1.0.0
|
|
153
|
+
*/
|
|
154
|
+
export const Checkpoints = Context.Service("@smthrs/std/Checkpoints");
|
|
155
|
+
/**
|
|
156
|
+
* Builds a store from its two operations.
|
|
157
|
+
*
|
|
158
|
+
* @category constructors
|
|
159
|
+
* @since 1.0.0
|
|
160
|
+
*/
|
|
161
|
+
export const make = (service) => Checkpoints.of(service);
|
|
162
|
+
/**
|
|
163
|
+
* The refusal a host with nowhere to pin a tree answers with.
|
|
164
|
+
*
|
|
165
|
+
* @category errors
|
|
166
|
+
* @since 1.0.0
|
|
167
|
+
*/
|
|
168
|
+
export const unavailable = (id) => new StdError.StdError({
|
|
169
|
+
code: "provider_unavailable",
|
|
170
|
+
message: `This host pins no trees, so it holds no checkpoint "${id}". Take the reading on the live tree instead.`
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Builds a store for a host that pins nothing.
|
|
174
|
+
*
|
|
175
|
+
* @category constructors
|
|
176
|
+
* @since 1.0.0
|
|
177
|
+
*/
|
|
178
|
+
export const makeNoop = () => make({
|
|
179
|
+
capture: (id) => Effect.fail(unavailable(id)),
|
|
180
|
+
materialize: (id) => Effect.fail(unavailable(id))
|
|
181
|
+
});
|
|
182
|
+
/**
|
|
183
|
+
* Provides {@link makeNoop}.
|
|
184
|
+
*
|
|
185
|
+
* @category layers
|
|
186
|
+
* @since 1.0.0
|
|
187
|
+
*/
|
|
188
|
+
export const layerNoop = Layer.succeed(Checkpoints, makeNoop());
|
|
189
|
+
const failed = (message, code = "command_failed") => new StdError.StdError({ code, message });
|
|
190
|
+
/**
|
|
191
|
+
* A checkpoint id, restricted to what can safely become a git-config key and a
|
|
192
|
+
* directory name. No dots: a dot would split the config key into another
|
|
193
|
+
* subsection.
|
|
194
|
+
*/
|
|
195
|
+
const namable = /^[A-Za-z0-9][A-Za-z0-9-]*$/;
|
|
196
|
+
/**
|
|
197
|
+
* Builds the git-backed store.
|
|
198
|
+
*
|
|
199
|
+
* Every git command that records or checks out a tree runs against a shadow
|
|
200
|
+
* `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent
|
|
201
|
+
* can write; see `internal/GitWorktree.ts`. The capture reads a copy of the
|
|
202
|
+
* workspace index, so the agent's own index is untouched: its `git diff` is the
|
|
203
|
+
* run's evidence and must not move because the harness recorded something.
|
|
204
|
+
*
|
|
205
|
+
* @category constructors
|
|
206
|
+
* @since 1.0.0
|
|
207
|
+
*/
|
|
208
|
+
export const makeGit = (options) => Effect.gen(function* () {
|
|
209
|
+
const spawner = yield* ChildProcessSpawner;
|
|
210
|
+
// The host opens the repository before any agent runs. Its `.git` is the
|
|
211
|
+
// agent's to write, so what it names later can never choose another store.
|
|
212
|
+
const opened = yield* Effect.exit(GitWorktree.open(withoutTrailingSlash(options.root)).pipe(Effect.provideService(ChildProcessSpawner, spawner)));
|
|
213
|
+
return gitStore(options, spawner, opened);
|
|
214
|
+
});
|
|
215
|
+
/**
|
|
216
|
+
* The store itself, with the spawner it runs git through already resolved.
|
|
217
|
+
*
|
|
218
|
+
* Resolving it here rather than threading it through {@link Checkpoints} keeps
|
|
219
|
+
* the service's own requirement empty, which is what lets a browser host bind
|
|
220
|
+
* {@link layerNoop} against the identical interface — the same shape
|
|
221
|
+
* `TestRunner` and `Container` take.
|
|
222
|
+
*/
|
|
223
|
+
const gitStore = (options, spawner, opened) => {
|
|
224
|
+
const spawn = (effect) => Effect.provideService(effect, ChildProcessSpawner, spawner);
|
|
225
|
+
const root = withoutTrailingSlash(options.root);
|
|
226
|
+
/** The repository the host opened, refused once the workspace names another. */
|
|
227
|
+
const repositoryOf = Effect.gen(function* () {
|
|
228
|
+
const bound = yield* opened;
|
|
229
|
+
const current = yield* GitWorktree.open(root);
|
|
230
|
+
if (current.toplevel !== bound.toplevel || current.common !== bound.common || current.index !== bound.index ||
|
|
231
|
+
current.objectFormat !== bound.objectFormat) {
|
|
232
|
+
return yield* Effect.fail(failed(`${root} now names another git repository than the one this run opened.`, "permission_denied"));
|
|
233
|
+
}
|
|
234
|
+
return current;
|
|
235
|
+
});
|
|
236
|
+
const guestRoot = options.cwd === undefined ? root : withoutTrailingSlash(options.cwd);
|
|
237
|
+
const keyOf = (id) => `${configSection}.${id}`;
|
|
238
|
+
const baseRefs = options.baseRef === undefined ? [TestRunner.captureBase, "HEAD"] : [options.baseRef];
|
|
239
|
+
/**
|
|
240
|
+
* The commit one id names.
|
|
241
|
+
*
|
|
242
|
+
* `base` is the one id nobody mints, so it is resolved from refs — the same
|
|
243
|
+
* precedence `TestRun` uses. Every other id was recorded by {@link capture}
|
|
244
|
+
* into this repository's config file, which is where a checkpoint is named
|
|
245
|
+
* *without* becoming history. See {@link configSection}.
|
|
246
|
+
*/
|
|
247
|
+
const commitOf = (repository, id) => Effect.gen(function* () {
|
|
248
|
+
if (id === baseId)
|
|
249
|
+
return (yield* GitWorktree.resolveCommit(root, baseRefs)).commit;
|
|
250
|
+
const found = yield* GitWorktree.config(repository, ["--get", keyOf(id)]);
|
|
251
|
+
const commit = found.stdout.trim();
|
|
252
|
+
if (found.exitCode !== 0 || commit === "") {
|
|
253
|
+
return yield* Effect.fail(failed(`No checkpoint is stored under ${id} in ${root}. Take the reading on the live tree instead.`, "not_found"));
|
|
254
|
+
}
|
|
255
|
+
return commit;
|
|
256
|
+
});
|
|
257
|
+
const capture = (id) => spawn(Effect.gen(function* () {
|
|
258
|
+
if (!namable.test(id)) {
|
|
259
|
+
return yield* Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input"));
|
|
260
|
+
}
|
|
261
|
+
const repository = yield* repositoryOf;
|
|
262
|
+
const commit = yield* GitWorktree.withShadow(repository, (shadow) => Effect.gen(function* () {
|
|
263
|
+
const head = (yield* GitWorktree.resolveCommit(root, ["HEAD"])).commit;
|
|
264
|
+
yield* shadow.adoptIndex;
|
|
265
|
+
const pinned = yield* shadow.git(["update-ref", "--no-deref", "HEAD", head]);
|
|
266
|
+
if (pinned.exitCode !== 0) {
|
|
267
|
+
return yield* Effect.fail(failed(`Could not record the working tree: ${pinned.stderr.trim()}`));
|
|
268
|
+
}
|
|
269
|
+
const recorded = yield* shadow.git(["stash", "create", `flows checkpoint ${id}`], root);
|
|
270
|
+
if (recorded.exitCode !== 0) {
|
|
271
|
+
return yield* Effect.fail(failed(`Could not record the working tree: ${recorded.stderr.trim()}`));
|
|
272
|
+
}
|
|
273
|
+
// Nothing to record means the working tree IS the commit it is on, so
|
|
274
|
+
// that commit is the checkpoint. `stash create` says so by printing
|
|
275
|
+
// nothing, which is not an error and must not be read as one.
|
|
276
|
+
return recorded.stdout.trim() === "" ? head : recorded.stdout.trim();
|
|
277
|
+
}));
|
|
278
|
+
const named = yield* GitWorktree.config(repository, [keyOf(id), commit]);
|
|
279
|
+
if (named.exitCode !== 0) {
|
|
280
|
+
return yield* Effect.fail(failed(`Could not name the checkpoint: ${named.stderr.trim()}`));
|
|
281
|
+
}
|
|
282
|
+
return new Snapshot({ id, ref: commit });
|
|
283
|
+
}));
|
|
284
|
+
const materialize = (id, use) => Effect.gen(function* () {
|
|
285
|
+
if (!namable.test(id)) {
|
|
286
|
+
return yield* Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input"));
|
|
287
|
+
}
|
|
288
|
+
const repository = yield* spawn(repositoryOf);
|
|
289
|
+
const commit = yield* spawn(commitOf(repository, id));
|
|
290
|
+
const context = yield* Effect.context();
|
|
291
|
+
return yield* GitWorktree.withDetachedWorktree(repository, `${scratchDirectory}/${id}`, commit, (host) => use({ id, host, guest: `${guestRoot}${host.slice(root.length)}`, root, guestRoot }).pipe(Effect.provideContext(context))).pipe(Effect.provideService(ChildProcessSpawner, spawner));
|
|
292
|
+
});
|
|
293
|
+
return make({ capture, materialize });
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Provides {@link makeGit}.
|
|
297
|
+
*
|
|
298
|
+
* @category layers
|
|
299
|
+
* @since 1.0.0
|
|
300
|
+
*/
|
|
301
|
+
export const layerGit = (options) => Layer.effect(Checkpoints)(makeGit(options));
|
|
302
|
+
/**
|
|
303
|
+
* `$1` is the id. Records the working tree with `stash create` over a copy of
|
|
304
|
+
* the index, names the commit in config as {@link makeGit} does, and prints it.
|
|
305
|
+
*/
|
|
306
|
+
const pinScript = [
|
|
307
|
+
"set -e",
|
|
308
|
+
"cd \"$(git rev-parse --show-toplevel)\"",
|
|
309
|
+
"copy=$(mktemp -d)",
|
|
310
|
+
"trap 'rm -rf -- \"$copy\"' EXIT",
|
|
311
|
+
"index=$(git rev-parse --git-path index)",
|
|
312
|
+
"if [ -e \"$index\" ]; then cp -p -- \"$index\" \"$copy/index\"; fi",
|
|
313
|
+
"commit=$(GIT_INDEX_FILE=\"$copy/index\" git -c user.name=flows -c user.email=flows@localhost stash create \"flows checkpoint $1\")",
|
|
314
|
+
"[ -n \"$commit\" ] || commit=$(git rev-parse --verify 'HEAD^{commit}')",
|
|
315
|
+
`git config "${configSection}.$1" "$commit"`,
|
|
316
|
+
"printf '%s\\n' \"$commit\""
|
|
317
|
+
].join("\n");
|
|
318
|
+
/**
|
|
319
|
+
* `$1` is the id, `$2` the lease. Checks the tree out at
|
|
320
|
+
* `<top>/.flows-checkpoints/<id>-<lease>` in a repository of its own whose
|
|
321
|
+
* objects are the workspace's, and prints the top and the checkout.
|
|
322
|
+
*/
|
|
323
|
+
const checkoutScript = [
|
|
324
|
+
"set -e",
|
|
325
|
+
"top=$(git rev-parse --show-toplevel)",
|
|
326
|
+
"cd \"$top\"",
|
|
327
|
+
"common=$(cd \"$(git rev-parse --git-common-dir)\" && pwd -P)",
|
|
328
|
+
`if [ "$1" = ${baseId} ]; then`,
|
|
329
|
+
` commit=$(git rev-parse --verify --quiet '${TestRunner.captureBase}^{commit}' || git rev-parse --verify --quiet 'HEAD^{commit}') || { echo "No commit resolves from ${TestRunner.captureBase} or HEAD in $top." >&2; exit 1; }`,
|
|
330
|
+
"else",
|
|
331
|
+
` commit=$(git config --get "${configSection}.$1") || { echo "No checkpoint is stored under $1 in $top. Take the reading on the live tree instead." >&2; exit 1; }`,
|
|
332
|
+
"fi",
|
|
333
|
+
`dir="$top/${scratchDirectory}/$1-$2"`,
|
|
334
|
+
"trap 'rm -rf -- \"$dir\"' EXIT",
|
|
335
|
+
`mkdir -p -- "$top/${scratchDirectory}"`,
|
|
336
|
+
"git init --quiet \"$dir\"",
|
|
337
|
+
"printf '%s/objects\\n' \"$common\" > \"$dir/.git/objects/info/alternates\"",
|
|
338
|
+
"git -C \"$dir\" checkout --quiet --detach \"$commit\"",
|
|
339
|
+
"trap - EXIT",
|
|
340
|
+
"printf '%s\\n%s\\n' \"$top\" \"$dir\""
|
|
341
|
+
].join("\n");
|
|
342
|
+
/**
|
|
343
|
+
* Builds the store for a host whose `bash` runs in one container.
|
|
344
|
+
*
|
|
345
|
+
* The repository is the container's, so every git command runs there, through
|
|
346
|
+
* the same {@link Container.Container} transport `bash` takes. The host store
|
|
347
|
+
* looked in the CLI's own directory instead and refused every `at` in 112 of
|
|
348
|
+
* 123 trials of the 2026-10-14 SWE-bench Pro run. This keeps that store's
|
|
349
|
+
* shape: a checkpoint is a `stash create` commit named in config, and a tree
|
|
350
|
+
* is checked out under the repository for one call, so a relocated `bash`
|
|
351
|
+
* call keeps its subdirectory and still finds what the workspace installs
|
|
352
|
+
* beside it. That git may run what the repository configures, but only inside
|
|
353
|
+
* the container the agent already commands.
|
|
354
|
+
*
|
|
355
|
+
* @category constructors
|
|
356
|
+
* @since 1.0.0-rc.8
|
|
357
|
+
*/
|
|
358
|
+
export const makeContainer = (options) => Effect.gen(function* () {
|
|
359
|
+
const spawner = yield* ChildProcessSpawner;
|
|
360
|
+
const transport = yield* Container.Container;
|
|
361
|
+
const sh = (script, args) => transport.exec({
|
|
362
|
+
container: options.container,
|
|
363
|
+
file: "sh",
|
|
364
|
+
args: ["-c", script, "sh", ...args],
|
|
365
|
+
cwd: options.cwd,
|
|
366
|
+
stdin: false
|
|
367
|
+
}).pipe(Effect.flatMap((plan) => Exec.exec(plan.file, { args: plan.args, env: plan.env }).pipe(Effect.mapError((error) => Exec.toStdError(plan.file, error)))), Effect.flatMap((result) => result.exitCode === 0
|
|
368
|
+
? Effect.succeed(result.stdout.trim().split("\n"))
|
|
369
|
+
: Effect.fail(failed(`git in container ${options.container} failed: ${result.stderr.trim()}`))), Effect.provideService(ChildProcessSpawner, spawner));
|
|
370
|
+
const named = (id) => namable.test(id)
|
|
371
|
+
? Effect.void
|
|
372
|
+
: Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input"));
|
|
373
|
+
return make({
|
|
374
|
+
capture: (id) => named(id).pipe(Effect.andThen(sh(pinScript, [id])), Effect.map(([commit]) => new Snapshot({ id, ref: commit }))),
|
|
375
|
+
materialize: (id, use) => named(id).pipe(Effect.andThen(Effect.acquireUseRelease(sh(checkoutScript, [id, globalThis.crypto.randomUUID()]), ([root, checkout]) => use({ id, host: checkout, guest: checkout, root: root, guestRoot: root }), ([, checkout]) => sh("rm -rf -- \"$1\"", [checkout]).pipe(Effect.catch((error) => Effect.logWarning("could not remove a scratch checkout").pipe(Effect.annotateLogs({ path: checkout, reason: error.message })))))))
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
/**
|
|
379
|
+
* Provides {@link makeContainer}.
|
|
380
|
+
*
|
|
381
|
+
* @category layers
|
|
382
|
+
* @since 1.0.0-rc.8
|
|
383
|
+
*/
|
|
384
|
+
export const layerContainer = (options) => Layer.effect(Checkpoints)(makeContainer(options));
|
|
385
|
+
/**
|
|
386
|
+
* Rewrites one call's input so the call runs against a materialized checkpoint.
|
|
387
|
+
*
|
|
388
|
+
* Re-exported from {@link Relocate}, which owns the table of flows and fields
|
|
389
|
+
* this rewrite is driven by. It is exported here because the harness reaches the
|
|
390
|
+
* whole checkpoint feature through this module.
|
|
391
|
+
*
|
|
392
|
+
* @category conversions
|
|
393
|
+
* @since 1.0.0
|
|
394
|
+
*/
|
|
395
|
+
export { relocate } from "./Relocate.js";
|
|
396
|
+
//# sourceMappingURL=Checkpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkpoints.js","sourceRoot":"","sources":["../../src/Checkpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAa,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAClE,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAmB,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAC5C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAA;AAE5B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**value**: minting one changes nothing about the workspace,\n * and running a call against one leaves the live tree exactly as it stands.\n * That is the whole of what it buys. Before it existed, the only way a run\n * could answer \"did this command fail before my change\" was to undo the change\n * — and the journals price that exactly. On `sympy__sympy-13878` the r95repl\n * lane applied one byte-identical 4,789-character patch **five times**, four of\n * those applications preceded by `git checkout -- sympy/stats/crv_types.py`,\n * because a clean fails-before proof required reverting the very work it was\n * meant to prove.\n *\n * This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and\n * `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,\n * the bound and the refusals; nothing in it knows what a tree is. This owns the\n * two host operations that need one:\n *\n * - {@link Checkpoints.capture} records the working tree under an id, and\n * - {@link Checkpoints.materialize} gives that tree back as a directory for the\n * length of one call.\n *\n * ## The git binding, and the container constraint it is shaped by\n *\n * {@link layerGit} records a checkpoint with `git stash create`, then names the\n * commit it prints in this repository's own git config rather than with a ref —\n * see {@link configSection} for why a ref would hand the agent its own edit back\n * as history. `stash create` is the one git command\n * that records the working tree and changes nothing else: it does not move the\n * worktree and does not touch the stash ref. It runs against a shadow\n * `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),\n * so it never writes the repository's index and never runs a program the\n * workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same\n * workspace and its own `git diff` is the run's evidence, so a capture that\n * staged into the real index would be the harness editing the evidence while\n * recording it. A tree with nothing to record prints nothing, and the\n * checkpoint is then `HEAD` — which is exactly what the tree is.\n *\n * Untracked files are not in the recorded tree, which matches how the rig\n * captures a patch: `capture-patch.sh` drops paths that did not exist when the\n * agent started, so a checkpoint holds what a patch would hold.\n *\n * The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`\n * — **inside** the workspace, which looks wrong and is the only thing that\n * works. A benchmark check runs through `docker exec` inside `/testbed`, and\n * `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere\n * else on the host is simply not visible to the container, so the call would run\n * against a path that does not exist. Placed under the workspace it is visible\n * at the same subpath under the mount, needs no second mount, and needs no\n * change to how the rig starts its container. `TestRun`'s `against: \"base\"`\n * reached the same conclusion first and this reuses its shape;\n * `evals/swebench/run-instance.sh` excludes the directory from patch capture for\n * the same reason it excludes `.flows-test-base`.\n *\n * The checkout is added and removed around **one call**, which is stricter than\n * the frame lifetime the design asks for and much simpler: there is no cache to\n * invalidate, no id to leak, and a checkpoint used by three calls pays three\n * checkouts rather than risking one stale directory. A run that reuses a\n * checkpoint across frames simply re-materializes it, because the ref is what\n * persists.\n *\n * ## What can be pointed at a checkpoint, and what cannot\n *\n * {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half\n * knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half\n * knows git. They change for different reasons, so they are different modules,\n * and {@link relocate} is re-exported here because the harness reaches the whole\n * feature through this one.\n *\n * @since 1.0.0\n */\n\nimport { ChildProcessSpawner } from \"@smthrs/kernel/ChildProcessSpawner\"\nimport { Context, Effect, type Exit, Layer, Schema } from \"effect\"\nimport * as Container from \"./Container.ts\"\nimport * as Exec from \"./internal/Exec.ts\"\nimport { GitWorktree, type Repository } from \"./internal/GitWorktree.ts\"\nimport { withoutTrailingSlash } from \"./internal/Paths.ts\"\nimport * as Prune from \"./internal/Prune.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as TestRunner from \"./TestRunner.ts\"\n\n/**\n * The id naming the tree a run opened on.\n *\n * It is not minted: the host either recorded one before the agent started or it\n * did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and\n * then to `HEAD`, which is the same precedence `TestRun` uses for the same\n * question — so a workspace that has one answer for a baseline has one answer\n * for both.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const baseId = \"base\"\n\n/**\n * The directory checkpoints are materialized into, relative to the repository\n * root and therefore also relative to a container's view of it.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const scratchDirectory = Prune.checkpointScratch\n\n/**\n * The git-config section {@link layerGit} records minted checkpoints under.\n *\n * Config and **not a ref**, and that is the whole of the decision. A ref is\n * history: `git log --all` lists it, `git show` prints it, and `git log --all\n * -S` searches it — so a checkpoint named by a ref would hand an agent a commit\n * containing its own edit and let it read that back as if it were upstream\n * work. That exact class cost the measured program real money before the rig\n * moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:\n * django-13346 applied two of its own snapshots as a fake fix), and a ref here\n * would reintroduce it one wave later.\n *\n * The commit object itself is unreferenced. It stays alive for the life of the\n * run — nothing in a run prunes — and a checkout by id works perfectly well,\n * which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable\n * by id and no command that walks refs can reach it:\n * `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer\n * exactly as they did before the capture.\n *\n * One command still sees it, measured rather than argued in\n * `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,\n * because that is what an unreferenced commit is. A checkout is a standalone\n * repository, not a worktree of this one, so `git log --all` does not list it\n * even while a call runs in it. It is not reachable by a name that looks like project history, and the cell\n * contract's environment section says outright that a dangling commit is this\n * harness holding the agent's own tree — which is the half of the django-13346\n * lesson that a store cannot enforce.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const configSection = \"flows-checkpoint\"\n\n/**\n * One tree this run has pinned.\n *\n * `ref` is the store's own name for it. Nothing above this module interprets\n * it; it travels so the journal says which tree a checkpointed call read.\n *\n * @category models\n * @since 1.0.0\n */\nexport class Snapshot extends Schema.Class<Snapshot>(\"@smthrs/std/Checkpoints/Snapshot\")({\n id: Schema.String,\n ref: Schema.String\n}) {}\n\n/**\n * A tree handed back as a directory, for the length of one call.\n *\n * `host` is where the process running on this machine finds it. `guest` is\n * where a container finds the same directory, which is the same path when no\n * container is in play. They differ exactly as `TestRunner.Runner`'s `cwd` and\n * `root` differ, and for the same reason: one directory, two names.\n *\n * `root` and `guestRoot` are the workspace itself under those same two names.\n * They travel because a call that named a directory *inside* the workspace has\n * to keep it: a check that runs in `tests/` and is pointed at a checkpoint must\n * run in the checkpoint's `tests/`, not at its top. Silently dropping that\n * subpath is how a baseline comes back failing for a reason nobody chose, which\n * is the one failure a checkpoint exists to make impossible.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Materialized {\n readonly id: string\n readonly host: string\n readonly guest: string\n /** The workspace this checkpoint is a tree of, as this machine names it. */\n readonly root: string\n /** The workspace as a container names it; the same as {@link Materialized.root} when none does. */\n readonly guestRoot: string\n}\n\n/**\n * The two host operations a checkpoint needs.\n *\n * @category services\n * @since 1.0.0\n */\nexport interface Checkpoints {\n /** Records the working tree as it stands, under `id`. */\n readonly capture: (id: string) => Effect.Effect<Snapshot, StdError.StdError>\n /**\n * Hands `id` back as a directory for the length of the effect it wraps.\n *\n * Scoped rather than returned, because the directory has to be removed\n * however the call ends — a benchmark run killed at its wall-clock budget\n * would otherwise leave a second checkout of the whole repository in a tree\n * whose diff is the run's answer.\n */\n readonly materialize: <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | StdError.StdError, R>\n}\n\n/**\n * The {@link Checkpoints} service tag.\n *\n * @category services\n * @since 1.0.0\n */\nexport const Checkpoints: Context.Service<Checkpoints, Checkpoints> = Context.Service(\"@smthrs/std/Checkpoints\")\n\n/**\n * Builds a store from its two operations.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const make = (service: Checkpoints): Checkpoints => Checkpoints.of(service)\n\n/**\n * The refusal a host with nowhere to pin a tree answers with.\n *\n * @category errors\n * @since 1.0.0\n */\nexport const unavailable = (id: string): StdError.StdError =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: `This host pins no trees, so it holds no checkpoint \"${id}\". Take the reading on the live tree instead.`\n })\n\n/**\n * Builds a store for a host that pins nothing.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeNoop = (): Checkpoints =>\n make({\n capture: (id) => Effect.fail(unavailable(id)),\n materialize: (id) => Effect.fail(unavailable(id))\n })\n\n/**\n * Provides {@link makeNoop}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerNoop: Layer.Layer<Checkpoints> = Layer.succeed(Checkpoints, makeNoop())\n\n/**\n * What {@link layerGit} needs to know about the repository it pins.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface GitOptions {\n /**\n * The host path of the git repository whose trees are pinned.\n *\n * It is opened when the store is built. A root that was not a repository\n * then pins nothing, and one whose `.git` later names another repository is\n * refused with `permission_denied`.\n */\n readonly root: string\n /**\n * Where a container sees {@link GitOptions.root}, when one does.\n *\n * Absent means there is no container, and the guest path of a materialized\n * checkpoint is then its host path.\n */\n readonly cwd?: string | undefined\n /**\n * The ref naming the tree the run opened on, for {@link baseId}.\n *\n * Absent takes `TestRunner.captureBase` and then `HEAD`, which is the\n * precedence `TestRun` already uses.\n */\n readonly baseRef?: string | undefined\n}\n\nconst failed = (message: string, code: StdError.Code = \"command_failed\"): StdError.StdError =>\n new StdError.StdError({ code, message })\n\n/**\n * A checkpoint id, restricted to what can safely become a git-config key and a\n * directory name. No dots: a dot would split the config key into another\n * subsection.\n */\nconst namable = /^[A-Za-z0-9][A-Za-z0-9-]*$/\n\n/**\n * Builds the git-backed store.\n *\n * Every git command that records or checks out a tree runs against a shadow\n * `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent\n * can write; see `internal/GitWorktree.ts`. The capture reads a copy of the\n * workspace index, so the agent's own index is untouched: its `git diff` is the\n * run's evidence and must not move because the harness recorded something.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeGit = (\n options: GitOptions\n): Effect.Effect<Checkpoints, never, ChildProcessSpawner> =>\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n // The host opens the repository before any agent runs. Its `.git` is the\n // agent's to write, so what it names later can never choose another store.\n const opened = yield* Effect.exit(\n GitWorktree.open(withoutTrailingSlash(options.root)).pipe(Effect.provideService(ChildProcessSpawner, spawner))\n )\n return gitStore(options, spawner, opened)\n })\n\n/**\n * The store itself, with the spawner it runs git through already resolved.\n *\n * Resolving it here rather than threading it through {@link Checkpoints} keeps\n * the service's own requirement empty, which is what lets a browser host bind\n * {@link layerNoop} against the identical interface — the same shape\n * `TestRunner` and `Container` take.\n */\nconst gitStore = (\n options: GitOptions,\n spawner: ChildProcessSpawner[\"Service\"],\n opened: Exit.Exit<Repository, StdError.StdError>\n): Checkpoints => {\n const spawn = <A, E>(effect: Effect.Effect<A, E, ChildProcessSpawner>): Effect.Effect<A, E> =>\n Effect.provideService(effect, ChildProcessSpawner, spawner)\n const root = withoutTrailingSlash(options.root)\n\n /** The repository the host opened, refused once the workspace names another. */\n const repositoryOf = Effect.gen(function*() {\n const bound = yield* opened\n const current = yield* GitWorktree.open(root)\n if (\n current.toplevel !== bound.toplevel || current.common !== bound.common || current.index !== bound.index ||\n current.objectFormat !== bound.objectFormat\n ) {\n return yield* Effect.fail(\n failed(`${root} now names another git repository than the one this run opened.`, \"permission_denied\")\n )\n }\n return current\n })\n const guestRoot = options.cwd === undefined ? root : withoutTrailingSlash(options.cwd)\n const keyOf = (id: string) => `${configSection}.${id}`\n const baseRefs = options.baseRef === undefined ? [TestRunner.captureBase, \"HEAD\"] : [options.baseRef]\n\n /**\n * The commit one id names.\n *\n * `base` is the one id nobody mints, so it is resolved from refs — the same\n * precedence `TestRun` uses. Every other id was recorded by {@link capture}\n * into this repository's config file, which is where a checkpoint is named\n * *without* becoming history. See {@link configSection}.\n */\n const commitOf = (repository: Repository, id: string) =>\n Effect.gen(function*() {\n if (id === baseId) return (yield* GitWorktree.resolveCommit(root, baseRefs)).commit\n const found = yield* GitWorktree.config(repository, [\"--get\", keyOf(id)])\n const commit = found.stdout.trim()\n if (found.exitCode !== 0 || commit === \"\") {\n return yield* Effect.fail(\n failed(\n `No checkpoint is stored under ${id} in ${root}. Take the reading on the live tree instead.`,\n \"not_found\"\n )\n )\n }\n return commit\n })\n\n const capture = (id: string) =>\n spawn(Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const repository = yield* repositoryOf\n const commit = yield* GitWorktree.withShadow(repository, (shadow) =>\n Effect.gen(function*() {\n const head = (yield* GitWorktree.resolveCommit(root, [\"HEAD\"])).commit\n yield* shadow.adoptIndex\n const pinned = yield* shadow.git([\"update-ref\", \"--no-deref\", \"HEAD\", head])\n if (pinned.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${pinned.stderr.trim()}`))\n }\n const recorded = yield* shadow.git([\"stash\", \"create\", `flows checkpoint ${id}`], root)\n if (recorded.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${recorded.stderr.trim()}`))\n }\n // Nothing to record means the working tree IS the commit it is on, so\n // that commit is the checkpoint. `stash create` says so by printing\n // nothing, which is not an error and must not be read as one.\n return recorded.stdout.trim() === \"\" ? head : recorded.stdout.trim()\n }))\n const named = yield* GitWorktree.config(repository, [keyOf(id), commit])\n if (named.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not name the checkpoint: ${named.stderr.trim()}`))\n }\n return new Snapshot({ id, ref: commit })\n }))\n\n const materialize = <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ): Effect.Effect<A, E | StdError.StdError, R> =>\n Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const repository = yield* spawn(repositoryOf)\n const commit = yield* spawn(commitOf(repository, id))\n const context = yield* Effect.context<R>()\n return yield* GitWorktree.withDetachedWorktree(\n repository,\n `${scratchDirectory}/${id}`,\n commit,\n (host) =>\n use({ id, host, guest: `${guestRoot}${host.slice(root.length)}`, root, guestRoot }).pipe(\n Effect.provideContext(context)\n )\n ).pipe(Effect.provideService(ChildProcessSpawner, spawner))\n })\n\n return make({ capture, materialize })\n}\n\n/**\n * Provides {@link makeGit}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerGit = (options: GitOptions): Layer.Layer<Checkpoints, never, ChildProcessSpawner> =>\n Layer.effect(Checkpoints)(makeGit(options))\n\n/**\n * What {@link makeContainer} needs to know about the container it pins in.\n *\n * @category models\n * @since 1.0.0-rc.8\n */\nexport interface ContainerOptions {\n /** The container `bash` runs in. */\n readonly container: string\n /** A directory of the repository inside it; absent is the container's own working directory. */\n readonly cwd?: string | undefined\n}\n\n/**\n * `$1` is the id. Records the working tree with `stash create` over a copy of\n * the index, names the commit in config as {@link makeGit} does, and prints it.\n */\nconst pinScript = [\n \"set -e\",\n \"cd \\\"$(git rev-parse --show-toplevel)\\\"\",\n \"copy=$(mktemp -d)\",\n \"trap 'rm -rf -- \\\"$copy\\\"' EXIT\",\n \"index=$(git rev-parse --git-path index)\",\n \"if [ -e \\\"$index\\\" ]; then cp -p -- \\\"$index\\\" \\\"$copy/index\\\"; fi\",\n \"commit=$(GIT_INDEX_FILE=\\\"$copy/index\\\" git -c user.name=flows -c user.email=flows@localhost stash create \\\"flows checkpoint $1\\\")\",\n \"[ -n \\\"$commit\\\" ] || commit=$(git rev-parse --verify 'HEAD^{commit}')\",\n `git config \"${configSection}.$1\" \"$commit\"`,\n \"printf '%s\\\\n' \\\"$commit\\\"\"\n].join(\"\\n\")\n\n/**\n * `$1` is the id, `$2` the lease. Checks the tree out at\n * `<top>/.flows-checkpoints/<id>-<lease>` in a repository of its own whose\n * objects are the workspace's, and prints the top and the checkout.\n */\nconst checkoutScript = [\n \"set -e\",\n \"top=$(git rev-parse --show-toplevel)\",\n \"cd \\\"$top\\\"\",\n \"common=$(cd \\\"$(git rev-parse --git-common-dir)\\\" && pwd -P)\",\n `if [ \"$1\" = ${baseId} ]; then`,\n ` commit=$(git rev-parse --verify --quiet '${TestRunner.captureBase}^{commit}' || git rev-parse --verify --quiet 'HEAD^{commit}') || { echo \"No commit resolves from ${TestRunner.captureBase} or HEAD in $top.\" >&2; exit 1; }`,\n \"else\",\n ` commit=$(git config --get \"${configSection}.$1\") || { echo \"No checkpoint is stored under $1 in $top. Take the reading on the live tree instead.\" >&2; exit 1; }`,\n \"fi\",\n `dir=\"$top/${scratchDirectory}/$1-$2\"`,\n \"trap 'rm -rf -- \\\"$dir\\\"' EXIT\",\n `mkdir -p -- \"$top/${scratchDirectory}\"`,\n \"git init --quiet \\\"$dir\\\"\",\n \"printf '%s/objects\\\\n' \\\"$common\\\" > \\\"$dir/.git/objects/info/alternates\\\"\",\n \"git -C \\\"$dir\\\" checkout --quiet --detach \\\"$commit\\\"\",\n \"trap - EXIT\",\n \"printf '%s\\\\n%s\\\\n' \\\"$top\\\" \\\"$dir\\\"\"\n].join(\"\\n\")\n\n/**\n * Builds the store for a host whose `bash` runs in one container.\n *\n * The repository is the container's, so every git command runs there, through\n * the same {@link Container.Container} transport `bash` takes. The host store\n * looked in the CLI's own directory instead and refused every `at` in 112 of\n * 123 trials of the 2026-10-14 SWE-bench Pro run. This keeps that store's\n * shape: a checkpoint is a `stash create` commit named in config, and a tree\n * is checked out under the repository for one call, so a relocated `bash`\n * call keeps its subdirectory and still finds what the workspace installs\n * beside it. That git may run what the repository configures, but only inside\n * the container the agent already commands.\n *\n * @category constructors\n * @since 1.0.0-rc.8\n */\nexport const makeContainer = (\n options: ContainerOptions\n): Effect.Effect<Checkpoints, never, ChildProcessSpawner | Container.Container> =>\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n const transport = yield* Container.Container\n const sh = (script: string, args: ReadonlyArray<string>) =>\n transport.exec({\n container: options.container,\n file: \"sh\",\n args: [\"-c\", script, \"sh\", ...args],\n cwd: options.cwd,\n stdin: false\n }).pipe(\n Effect.flatMap((plan) =>\n Exec.exec(plan.file, { args: plan.args, env: plan.env }).pipe(\n Effect.mapError((error) => Exec.toStdError(plan.file, error))\n )\n ),\n Effect.flatMap((result) =>\n result.exitCode === 0\n ? Effect.succeed(result.stdout.trim().split(\"\\n\"))\n : Effect.fail(failed(`git in container ${options.container} failed: ${result.stderr.trim()}`))\n ),\n Effect.provideService(ChildProcessSpawner, spawner)\n )\n const named = (id: string) =>\n namable.test(id)\n ? Effect.void\n : Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\"))\n return make({\n capture: (id) =>\n named(id).pipe(\n Effect.andThen(sh(pinScript, [id])),\n Effect.map(([commit]) => new Snapshot({ id, ref: commit! }))\n ),\n materialize: (id, use) =>\n named(id).pipe(Effect.andThen(Effect.acquireUseRelease(\n sh(checkoutScript, [id, globalThis.crypto.randomUUID()]),\n ([root, checkout]) => use({ id, host: checkout!, guest: checkout!, root: root!, guestRoot: root! }),\n ([, checkout]) =>\n sh(\"rm -rf -- \\\"$1\\\"\", [checkout!]).pipe(\n Effect.catch((error) =>\n Effect.logWarning(\"could not remove a scratch checkout\").pipe(\n Effect.annotateLogs({ path: checkout, reason: error.message })\n )\n )\n )\n )))\n })\n })\n\n/**\n * Provides {@link makeContainer}.\n *\n * @category layers\n * @since 1.0.0-rc.8\n */\nexport const layerContainer = (\n options: ContainerOptions\n): Layer.Layer<Checkpoints, never, ChildProcessSpawner | Container.Container> =>\n Layer.effect(Checkpoints)(makeContainer(options))\n\n/**\n * Rewrites one call's input so the call runs against a materialized checkpoint.\n *\n * Re-exported from {@link Relocate}, which owns the table of flows and fields\n * this rewrite is driven by. It is exported here because the harness reaches the\n * whole checkpoint feature through this module.\n *\n * @category conversions\n * @since 1.0.0\n */\nexport { relocate, type Relocation } from \"./Relocate.ts\"\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host's route into a named container, as an injected transport.
|
|
3
|
+
*
|
|
4
|
+
* A task whose interpreter, dependencies, and test runner live in a container
|
|
5
|
+
* makes every command a nested quoting problem: the agent writes
|
|
6
|
+
* `docker exec c bash -lc 'cd /testbed && python - <<EOF … EOF'`, and one layer
|
|
7
|
+
* of that stack eats a quote. The measured cost across the 45-instance program
|
|
8
|
+
* was twelve failed probes, one instance's single most expensive frame
|
|
9
|
+
* (astropy-8707, which produced a probe that never ran), and a class of failure
|
|
10
|
+
* that turns from a broken probe into a broken *edit* the moment the same
|
|
11
|
+
* quoting reaches a writing command.
|
|
12
|
+
*
|
|
13
|
+
* So the transport is the harness's, not the agent's. A caller names the
|
|
14
|
+
* container and passes its program and payload as data; this service turns that
|
|
15
|
+
* into the argv the host actually spawns. `docker` and `podman` share the CLI
|
|
16
|
+
* {@link makeCommand} builds, and a host with a different route supplies its own
|
|
17
|
+
* {@link make} rather than teaching the agent a new incantation.
|
|
18
|
+
*
|
|
19
|
+
* A host that has no container route provides {@link makeNoop}, whose refusal
|
|
20
|
+
* says so plainly. Nothing here shells out on its own: it only decides an argv,
|
|
21
|
+
* and `bash` spawns it through the same permission-aware spawner as everything
|
|
22
|
+
* else.
|
|
23
|
+
*
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
*/
|
|
26
|
+
import { Context, Effect, Layer } from "effect";
|
|
27
|
+
import * as StdError from "./StdError.ts";
|
|
28
|
+
/**
|
|
29
|
+
* One command to run inside a container.
|
|
30
|
+
*
|
|
31
|
+
* @category models
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
*/
|
|
34
|
+
export interface Request {
|
|
35
|
+
readonly container: string;
|
|
36
|
+
readonly file: string;
|
|
37
|
+
readonly args: ReadonlyArray<string>;
|
|
38
|
+
readonly cwd?: string | undefined;
|
|
39
|
+
readonly env?: Record<string, string> | undefined;
|
|
40
|
+
/** Whether the payload arrives on the program's standard input. */
|
|
41
|
+
readonly stdin: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The argv the host spawns to satisfy a {@link Request}.
|
|
45
|
+
*
|
|
46
|
+
* @category models
|
|
47
|
+
* @since 1.0.0
|
|
48
|
+
*/
|
|
49
|
+
export interface Plan {
|
|
50
|
+
readonly file: string;
|
|
51
|
+
readonly args: ReadonlyArray<string>;
|
|
52
|
+
/** Environment overrides for the transport process, never rendered as argv. */
|
|
53
|
+
readonly env?: Record<string, string> | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The one container transport contract.
|
|
57
|
+
*
|
|
58
|
+
* @category services
|
|
59
|
+
* @since 1.0.0
|
|
60
|
+
*/
|
|
61
|
+
export interface Container {
|
|
62
|
+
readonly exec: (request: Request) => Effect.Effect<Plan, StdError.StdError>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The {@link Container} service tag.
|
|
66
|
+
*
|
|
67
|
+
* @category services
|
|
68
|
+
* @since 1.0.0
|
|
69
|
+
*/
|
|
70
|
+
export declare const Container: Context.Service<Container, Container>;
|
|
71
|
+
/**
|
|
72
|
+
* Builds a container transport from its one operation.
|
|
73
|
+
*
|
|
74
|
+
* @category constructors
|
|
75
|
+
* @since 1.0.0
|
|
76
|
+
*/
|
|
77
|
+
export declare const make: (service: Container) => Container;
|
|
78
|
+
/**
|
|
79
|
+
* The refusal a host with no container route answers with.
|
|
80
|
+
*
|
|
81
|
+
* @category errors
|
|
82
|
+
* @since 1.0.0
|
|
83
|
+
*/
|
|
84
|
+
export declare const unavailable: (container: string) => StdError.StdError;
|
|
85
|
+
/**
|
|
86
|
+
* Builds the transport for a host with no container route.
|
|
87
|
+
*
|
|
88
|
+
* @category constructors
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
*/
|
|
91
|
+
export declare const makeNoop: () => Container;
|
|
92
|
+
/**
|
|
93
|
+
* Provides {@link makeNoop}.
|
|
94
|
+
*
|
|
95
|
+
* @category layers
|
|
96
|
+
* @since 1.0.0
|
|
97
|
+
*/
|
|
98
|
+
export declare const layerNoop: Layer.Layer<Container>;
|
|
99
|
+
/**
|
|
100
|
+
* Builds a transport over a `docker exec`-compatible CLI.
|
|
101
|
+
*
|
|
102
|
+
* `-i` is attached only when the payload arrives on standard input, because a
|
|
103
|
+
* container CLI that holds stdin open for a command that never reads it makes
|
|
104
|
+
* that command hang.
|
|
105
|
+
*
|
|
106
|
+
* Requested environment variables never reach the transport process under
|
|
107
|
+
* their own names. The request's `env` is the caller's, and the transport is a
|
|
108
|
+
* host program: `PATH`, `LD_PRELOAD`, `DOCKER_HOST` or `XDG_CONFIG_HOME` set on
|
|
109
|
+
* it would choose what runs on the host. Each value therefore travels in
|
|
110
|
+
* {@link Plan.env} under `SMITHERS_CONTAINER_ENV_`, is forwarded by that name
|
|
111
|
+
* (`-e SMITHERS_CONTAINER_ENV_KEY`), and a `sh` inside the container renames it
|
|
112
|
+
* to `KEY` before `exec`ing the program. Values stay out of the argv. A name
|
|
113
|
+
* must be a POSIX shell name. A request with `env` therefore requires `sh` in
|
|
114
|
+
* the container; one without `env` runs the program directly, so an image
|
|
115
|
+
* without a shell works only for requests that carry no `env`.
|
|
116
|
+
*
|
|
117
|
+
* @category constructors
|
|
118
|
+
* @since 1.0.0
|
|
119
|
+
*/
|
|
120
|
+
export declare const makeCommand: (options?: {
|
|
121
|
+
readonly program?: string | undefined;
|
|
122
|
+
}) => Container;
|
|
123
|
+
/**
|
|
124
|
+
* Provides {@link makeCommand}.
|
|
125
|
+
*
|
|
126
|
+
* @category layers
|
|
127
|
+
* @since 1.0.0
|
|
128
|
+
*/
|
|
129
|
+
export declare const layerCommand: (options?: {
|
|
130
|
+
readonly program?: string | undefined;
|
|
131
|
+
}) => Layer.Layer<Container>;
|
|
132
|
+
//# sourceMappingURL=Container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../src/Container.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACpC,QAAQ,CAAC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