@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.
- package/CHANGELOG.md +130 -0
- package/LICENSE +21 -0
- package/README.md +152 -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 +380 -0
- package/dist/cjs/Bash.d.ts.map +1 -0
- package/dist/cjs/Bash.js +332 -0
- package/dist/cjs/Bash.js.map +7 -0
- package/dist/cjs/Checkpoints.d.ts +279 -0
- package/dist/cjs/Checkpoints.d.ts.map +1 -0
- package/dist/cjs/Checkpoints.js +145 -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 +24 -0
- package/dist/cjs/PortableSearch.d.ts.map +1 -0
- package/dist/cjs/PortableSearch.js +233 -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/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 +127 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +99 -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 +67 -0
- package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/cjs/internal/EnvelopePrecheck.js +124 -0
- package/dist/cjs/internal/EnvelopePrecheck.js.map +7 -0
- package/dist/cjs/internal/Exec.d.ts +139 -0
- package/dist/cjs/internal/Exec.d.ts.map +1 -0
- package/dist/cjs/internal/Exec.js +158 -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/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/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 +114 -0
- package/dist/cjs/internal/Text.d.ts.map +1 -0
- package/dist/cjs/internal/Text.js +82 -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 +380 -0
- package/dist/esm/Bash.d.ts.map +1 -0
- package/dist/esm/Bash.js +505 -0
- package/dist/esm/Bash.js.map +1 -0
- package/dist/esm/Checkpoints.d.ts +279 -0
- package/dist/esm/Checkpoints.d.ts.map +1 -0
- package/dist/esm/Checkpoints.js +298 -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 +24 -0
- package/dist/esm/PortableSearch.d.ts.map +1 -0
- package/dist/esm/PortableSearch.js +240 -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/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 +127 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +127 -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 +67 -0
- package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/esm/internal/EnvelopePrecheck.js +167 -0
- package/dist/esm/internal/EnvelopePrecheck.js.map +1 -0
- package/dist/esm/internal/Exec.d.ts +139 -0
- package/dist/esm/internal/Exec.d.ts.map +1 -0
- package/dist/esm/internal/Exec.js +193 -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/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/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 +114 -0
- package/dist/esm/internal/Text.d.ts.map +1 -0
- package/dist/esm/internal/Text.js +130 -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 +117 -0
- package/docs/api.md +472 -0
- package/docs/concepts/effects-and-capabilities.md +136 -0
- package/docs/concepts/flows-and-handlers.md +115 -0
- package/docs/concepts/limits-and-disclosure.md +102 -0
- package/docs/concepts/search-contract.md +182 -0
- package/docs/guides/bind-the-standard-flows.md +114 -0
- package/docs/guides/implement-a-search-peer.md +133 -0
- package/docs/guides/pin-a-checkpoint.md +141 -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 +215 -0
- package/docs/guides/run-the-test-suite.md +154 -0
- package/docs/guides/search-a-workspace.md +148 -0
- package/docs/installation.md +111 -0
- package/docs/quickstart.md +125 -0
- package/docs/reference/flows.md +556 -0
- package/docs/troubleshooting.md +322 -0
- package/package.json +439 -3
- package/src/ApplyPatch.ts +458 -0
- package/src/Bash.ts +607 -0
- package/src/Checkpoints.ts +422 -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 +264 -0
- package/src/Probe.ts +284 -0
- package/src/Read.ts +359 -0
- package/src/Relocate.ts +166 -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 +154 -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 +233 -0
- package/src/internal/Exec.ts +314 -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/SearchContract.ts +77 -0
- package/src/internal/Symbols.ts +88 -0
- package/src/internal/TestReport.ts +194 -0
- package/src/internal/Text.ts +170 -0
- package/src/internal/Url.ts +23 -0
- package/src/internal/Walk.ts +176 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutation preparation for versioned hosts and cooperative locks for ordinary hosts.
|
|
3
|
+
* Ordinary locks fail closed after process death; they are never stolen on a timer.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import type * as FileSystem from "effect/FileSystem";
|
|
10
|
+
import type * as Path from "effect/Path";
|
|
11
|
+
import type * as Scope from "effect/Scope";
|
|
12
|
+
import * as StdError from "../StdError.ts";
|
|
13
|
+
/**
|
|
14
|
+
* Authenticated standard-flow call session; absent callers cannot borrow another run's base.
|
|
15
|
+
*
|
|
16
|
+
* @category context
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
export declare const ReadSession: Context.Reference<string | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* The coding host attaches one run-scoped precondition policy to its guarded filesystem.
|
|
22
|
+
*
|
|
23
|
+
* @category identifiers
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
*/
|
|
26
|
+
export declare const Preconditions: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* One prepared file change; moves include a write and a guarded source removal.
|
|
29
|
+
*
|
|
30
|
+
* @category models
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
*/
|
|
33
|
+
export interface Change {
|
|
34
|
+
readonly path: string;
|
|
35
|
+
/** Null removes a file. Writes preserve existing metadata; new files use host defaults. */
|
|
36
|
+
readonly content: Uint8Array | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A per-invocation provider receipt boundary, with immutable captured read bases.
|
|
40
|
+
*
|
|
41
|
+
* @category models
|
|
42
|
+
* @since 1.0.0
|
|
43
|
+
*/
|
|
44
|
+
export interface Prepared {
|
|
45
|
+
/** Return bytes matching the captured base, never an unchecked current read. */
|
|
46
|
+
readonly read: (path: string) => Effect.Effect<Uint8Array, StdError.StdError>;
|
|
47
|
+
readonly commit: (changes: ReadonlyArray<Change>) => Effect.Effect<void, StdError.StdError>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Read records only successful model-facing reads; mutation-internal reads never refresh a base.
|
|
51
|
+
*
|
|
52
|
+
* @category models
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*/
|
|
55
|
+
export interface VersionedFileSystem extends FileSystem.FileSystem {
|
|
56
|
+
readonly [Preconditions]?: {
|
|
57
|
+
readonly record: (path: string, bytes: Uint8Array, session: string | undefined) => Effect.Effect<void, StdError.StdError>;
|
|
58
|
+
readonly validate: (paths: ReadonlyArray<string>, session: string | undefined) => Effect.Effect<void, StdError.StdError>;
|
|
59
|
+
/** Capture this invocation's bases from the existing ledger before tool-internal
|
|
60
|
+
* reads. The returned commit must compare them again inside the provider, then
|
|
61
|
+
* settle the entire batch before advancing the ledger. Concurrent reads or
|
|
62
|
+
* commits must never replace these captured bases. Preparation does not freeze
|
|
63
|
+
* callers; only the complete commit may acquire guest-wide exclusion.
|
|
64
|
+
*/
|
|
65
|
+
readonly prepare?: (paths: ReadonlyArray<string>, session: string | undefined) => Effect.Effect<Prepared, StdError.StdError>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Versioned hosts own parent creation and locking inside their atomic commit.
|
|
70
|
+
*
|
|
71
|
+
* @category guards
|
|
72
|
+
* @since 1.0.0
|
|
73
|
+
*/
|
|
74
|
+
export declare const isVersioned: (fs: FileSystem.FileSystem) => boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Record the entire original file, before pagination, through the host's existing policy.
|
|
77
|
+
*
|
|
78
|
+
* @category filesystem
|
|
79
|
+
* @since 1.0.0
|
|
80
|
+
*/
|
|
81
|
+
export declare const recordRead: (fs: FileSystem.FileSystem, path: string, bytes: Uint8Array) => Effect.Effect<void, StdError.StdError, never>;
|
|
82
|
+
/**
|
|
83
|
+
* Refuse an unqualified provider before creating any parent or lock directories.
|
|
84
|
+
*
|
|
85
|
+
* @category filesystem
|
|
86
|
+
* @since 1.0.0
|
|
87
|
+
*/
|
|
88
|
+
export declare const validate: (fs: FileSystem.FileSystem, paths: ReadonlyArray<string>) => Effect.Effect<undefined, StdError.StdError, never>;
|
|
89
|
+
/**
|
|
90
|
+
* The portable body is used only for an ordinary, unversioned filesystem.
|
|
91
|
+
*
|
|
92
|
+
* @category models
|
|
93
|
+
* @since 1.0.0
|
|
94
|
+
*/
|
|
95
|
+
export interface Mutation {
|
|
96
|
+
readonly read: (path: string, ordinary: Effect.Effect<Uint8Array, StdError.StdError>) => Effect.Effect<Uint8Array, StdError.StdError>;
|
|
97
|
+
readonly commit: (changes: ReadonlyArray<Change>, ordinary: Effect.Effect<void, StdError.StdError>) => Effect.Effect<void, StdError.StdError>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Versioned hosts capture bases under a local semaphore until scope exit.
|
|
101
|
+
* Ordinary hosts hold all named files using exclusive mkdir, so independently
|
|
102
|
+
* composed hosts and processes agree.
|
|
103
|
+
* A hash collision only refuses an unrelated edit; it cannot lose exclusion.
|
|
104
|
+
*
|
|
105
|
+
* @private
|
|
106
|
+
* @since 1.0.0
|
|
107
|
+
*/
|
|
108
|
+
export declare const acquire: (fileSystem: FileSystem.FileSystem, paths: ReadonlyArray<string>, creationPaths?: Path.Path) => Effect.Effect<Mutation, StdError.StdError, Scope.Scope>;
|
|
109
|
+
//# sourceMappingURL=FileMutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileMutation.d.ts","sourceRoot":"","sources":["../../../src/internal/FileMutation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,UAAU,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,KAAK,IAAI,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAG1C;;;;;GAKG;AACH,eAAO,MAAM,WAAW,uCAEtB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,eAA+C,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAA;CACpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ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AEJ;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,KACnD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACjD,QAAQ,CAAC,MAAM,EAAE,CACf,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,EAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAC7C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;CAC5C;AAoBD;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAClB,YAAY,UAAU,CAAC,UAAU,EACjC,OAAO,aAAa,CAAC,MAAM,CAAC,EAC5B,gBAAgB,IAAI,CAAC,IAAI,KACxB,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAkDrD,CAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutation preparation for versioned hosts and cooperative locks for ordinary hosts.
|
|
3
|
+
* Ordinary locks fail closed after process death; they are never stolen on a timer.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Semaphore from "effect/Semaphore";
|
|
10
|
+
import * as StdError from "../StdError.js";
|
|
11
|
+
import * as FsFailure from "./FsFailure.js";
|
|
12
|
+
/**
|
|
13
|
+
* Authenticated standard-flow call session; absent callers cannot borrow another run's base.
|
|
14
|
+
*
|
|
15
|
+
* @category context
|
|
16
|
+
* @since 1.0.0
|
|
17
|
+
*/
|
|
18
|
+
export const ReadSession = Context.Reference("@smthrs/std/ReadSession", {
|
|
19
|
+
defaultValue: () => undefined
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* The coding host attaches one run-scoped precondition policy to its guarded filesystem.
|
|
23
|
+
*
|
|
24
|
+
* @category identifiers
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
*/
|
|
27
|
+
export const Preconditions = Symbol.for("@smthrs/std/file-preconditions");
|
|
28
|
+
const unavailable = () => Effect.fail(new StdError.StdError({
|
|
29
|
+
code: "provider_unavailable",
|
|
30
|
+
message: "Authenticated atomic file mutation provider unavailable"
|
|
31
|
+
}));
|
|
32
|
+
/**
|
|
33
|
+
* Versioned hosts own parent creation and locking inside their atomic commit.
|
|
34
|
+
*
|
|
35
|
+
* @category guards
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
*/
|
|
38
|
+
export const isVersioned = (fs) => fs[Preconditions] !== undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Record the entire original file, before pagination, through the host's existing policy.
|
|
41
|
+
*
|
|
42
|
+
* @category filesystem
|
|
43
|
+
* @since 1.0.0
|
|
44
|
+
*/
|
|
45
|
+
export const recordRead = (fs, path, bytes) => Effect.flatMap(ReadSession, (session) => fs[Preconditions]?.record(path, bytes, session) ?? Effect.void);
|
|
46
|
+
/**
|
|
47
|
+
* Refuse an unqualified provider before creating any parent or lock directories.
|
|
48
|
+
*
|
|
49
|
+
* @category filesystem
|
|
50
|
+
* @since 1.0.0
|
|
51
|
+
*/
|
|
52
|
+
export const validate = (fs, paths) => Effect.gen(function* () {
|
|
53
|
+
const policy = fs[Preconditions];
|
|
54
|
+
if (policy === undefined)
|
|
55
|
+
return;
|
|
56
|
+
const session = yield* ReadSession;
|
|
57
|
+
yield* policy.validate(paths, session);
|
|
58
|
+
if (policy.prepare === undefined)
|
|
59
|
+
return yield* unavailable();
|
|
60
|
+
});
|
|
61
|
+
// This serializes one host's preparation, ledger and diagnostic ordering only.
|
|
62
|
+
// It is NOT the guest's outside-writer exclusion or its atomic commit boundary.
|
|
63
|
+
const hostLocks = new WeakMap();
|
|
64
|
+
// The on-disk lock protocol owns this hash; dependency upgrades must not
|
|
65
|
+
// change the name and let two versions acquire different locks for one file.
|
|
66
|
+
// Case/normalization aliases deliberately share a lock, including on hosts
|
|
67
|
+
// whose realPath preserves caller casing. Case-sensitive hosts may refuse a
|
|
68
|
+
// simultaneous change to a distinct case variant; that is safe contention.
|
|
69
|
+
const lockHash = (value) => {
|
|
70
|
+
value = value.normalize("NFC").toUpperCase();
|
|
71
|
+
let hash = 5381;
|
|
72
|
+
for (let index = 0; index < value.length; index++)
|
|
73
|
+
hash = (hash * 33) ^ value.charCodeAt(index);
|
|
74
|
+
return (hash >>> 0).toString(16);
|
|
75
|
+
};
|
|
76
|
+
const parent = (path) => path.slice(0, path.lastIndexOf(path.startsWith("/") ? "/" : "\\") + 1);
|
|
77
|
+
/**
|
|
78
|
+
* Versioned hosts capture bases under a local semaphore until scope exit.
|
|
79
|
+
* Ordinary hosts hold all named files using exclusive mkdir, so independently
|
|
80
|
+
* composed hosts and processes agree.
|
|
81
|
+
* A hash collision only refuses an unrelated edit; it cannot lose exclusion.
|
|
82
|
+
*
|
|
83
|
+
* @private
|
|
84
|
+
* @since 1.0.0
|
|
85
|
+
*/
|
|
86
|
+
export const acquire = (fileSystem, paths, creationPaths) => Effect.gen(function* () {
|
|
87
|
+
// Unavailable coding providers refuse before acquiring even protocol state.
|
|
88
|
+
// The versioned provider owns exclusion and revalidation at its commit;
|
|
89
|
+
// cooperative caller-side locks cannot exclude terminal or SSH writers.
|
|
90
|
+
yield* validate(fileSystem, paths);
|
|
91
|
+
const policy = fileSystem[Preconditions];
|
|
92
|
+
if (policy !== undefined) {
|
|
93
|
+
let lock = hostLocks.get(policy);
|
|
94
|
+
if (lock === undefined) {
|
|
95
|
+
lock = Semaphore.makeUnsafe(1);
|
|
96
|
+
hostLocks.set(policy, lock);
|
|
97
|
+
}
|
|
98
|
+
const held = lock;
|
|
99
|
+
yield* Effect.acquireRelease(held.take(1), () => held.release(1), { interruptible: true });
|
|
100
|
+
const session = yield* ReadSession;
|
|
101
|
+
const prepared = yield* policy.prepare(paths, session);
|
|
102
|
+
return { read: (path) => prepared.read(path), commit: (changes) => prepared.commit(changes) };
|
|
103
|
+
}
|
|
104
|
+
const locks = new Map();
|
|
105
|
+
for (const path of paths) {
|
|
106
|
+
const destination = yield* fileSystem.realPath(path).pipe(Effect.catch((error) => error.reason._tag === "NotFound" && creationPaths !== undefined
|
|
107
|
+
? fileSystem.realPath(creationPaths.dirname(path)).pipe(Effect.map((directory) => creationPaths.join(directory, creationPaths.basename(path))))
|
|
108
|
+
: Effect.fail(error)), Effect.mapError(FsFailure.reading(path, `File not found: ${path}`)));
|
|
109
|
+
const lock = `${parent(destination)}.smithers-${lockHash(destination)}.lock`;
|
|
110
|
+
locks.set(lock, path);
|
|
111
|
+
}
|
|
112
|
+
for (const [lock, path] of [...locks].sort(([left], [right]) => left.localeCompare(right))) {
|
|
113
|
+
yield* Effect.acquireRelease(fileSystem.makeDirectory(lock, { mode: 0o700 }).pipe(Effect.mapError(FsFailure.denied(path, (error) => new StdError.StdError({
|
|
114
|
+
code: error.reason._tag === "AlreadyExists" ? "no_match" : "command_failed",
|
|
115
|
+
message: error.reason._tag === "AlreadyExists"
|
|
116
|
+
? `Concurrent mutation of ${path}: lock ${lock} is held. Re-read and retry after the other writer finishes; a stopped writer's lock requires explicit recovery.`
|
|
117
|
+
: `Could not lock ${path} for mutation`,
|
|
118
|
+
path
|
|
119
|
+
})))), () => fileSystem.remove(lock, { recursive: true }).pipe(Effect.orDie));
|
|
120
|
+
}
|
|
121
|
+
return { read: (_path, ordinary) => ordinary, commit: (_changes, ordinary) => ordinary };
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=FileMutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileMutation.js","sourceRoot":"","sources":["../../../src/internal/FileMut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C,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAC/C,IAAI,QAAQ,CAAC,QAAQ,CAAC;YACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB;YAC3E,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,eAAe;gBAC5C,CAAC,CAAC,0BAA0B,IAAI,UAAU,IAAI,kHAAkH;gBAChK,CAAC,CAAC,kBAAkB,IAAI,eAAe;YACzC,IAAI;SACL,CAAC,CAAC,CAAC,CACP,EACD,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CACtE,CAAA;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAA;AAC1F,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Mutation preparation for versioned hosts and cooperative locks for ordinary hosts.\n * Ordinary locks fail closed after process death; they are never stolen on a timer.\n *\n * @since 1.0.0\n */\n\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport type * as FileSystem from \"effect/FileSystem\"\nimport type * as Path from \"effect/Path\"\nimport type * as Scope from \"effect/Scope\"\nimport * as Semaphore from \"effect/Semaphore\"\nimport * as StdError from \"../StdError.ts\"\nimport * as FsFailure from \"./FsFailure.ts\"\n\n/**\n * Authenticated standard-flow call session; absent callers cannot borrow another run's base.\n *\n * @category context\n * @since 1.0.0\n */\nexport const ReadSession = Context.Reference<string | undefined>(\"@smthrs/std/ReadSession\", {\n defaultValue: () => undefined\n})\n\n/**\n * The coding host attaches one run-scoped precondition policy to its guarded filesystem.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const Preconditions = Symbol.for(\"@smthrs/std/file-preconditions\")\n\n/**\n * One prepared file change; moves include a write and a guarded source removal.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Change {\n readonly path: string\n /** Null removes a file. Writes preserve existing metadata; new files use host defaults. */\n readonly content: Uint8Array | null\n}\n\n/**\n * A per-invocation provider receipt boundary, with immutable captured read bases.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Prepared {\n /** Return bytes matching the captured base, never an unchecked current read. */\n readonly read: (path: string) => Effect.Effect<Uint8Array, StdError.StdError>\n readonly commit: (changes: ReadonlyArray<Change>) => Effect.Effect<void, StdError.StdError>\n}\n\n/**\n * Read records only successful model-facing reads; mutation-internal reads never refresh a base.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface VersionedFileSystem extends FileSystem.FileSystem {\n readonly [Preconditions]?: {\n readonly record: (\n path: string,\n bytes: Uint8Array,\n session: string | undefined\n ) => Effect.Effect<void, StdError.StdError>\n readonly validate: (\n paths: ReadonlyArray<string>,\n session: string | undefined\n ) => Effect.Effect<void, StdError.StdError>\n /** Capture this invocation's bases from the existing ledger before tool-internal\n * reads. The returned commit must compare them again inside the provider, then\n * settle the entire batch before advancing the ledger. Concurrent reads or\n * commits must never replace these captured bases. Preparation does not freeze\n * callers; only the complete commit may acquire guest-wide exclusion.\n */\n readonly prepare?: (\n paths: ReadonlyArray<string>,\n session: string | undefined\n ) => Effect.Effect<Prepared, StdError.StdError>\n }\n}\n\nconst unavailable = () =>\n Effect.fail(\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: \"Authenticated atomic file mutation provider unavailable\"\n })\n )\n\n/**\n * Versioned hosts own parent creation and locking inside their atomic commit.\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isVersioned = (fs: FileSystem.FileSystem): boolean =>\n (fs as VersionedFileSystem)[Preconditions] !== undefined\n\n/**\n * Record the entire original file, before pagination, through the host's existing policy.\n *\n * @category filesystem\n * @since 1.0.0\n */\nexport const recordRead = (fs: FileSystem.FileSystem, path: string, bytes: Uint8Array) =>\n Effect.flatMap(\n ReadSession,\n (session) => (fs as VersionedFileSystem)[Preconditions]?.record(path, bytes, session) ?? Effect.void\n )\n\n/**\n * Refuse an unqualified provider before creating any parent or lock directories.\n *\n * @category filesystem\n * @since 1.0.0\n */\nexport const validate = (fs: FileSystem.FileSystem, paths: ReadonlyArray<string>) =>\n Effect.gen(function*() {\n const policy = (fs as VersionedFileSystem)[Preconditions]\n if (policy === undefined) return\n const session = yield* ReadSession\n yield* policy.validate(paths, session)\n if (policy.prepare === undefined) return yield* unavailable()\n })\n\n/**\n * The portable body is used only for an ordinary, unversioned filesystem.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Mutation {\n readonly read: (\n path: string,\n ordinary: Effect.Effect<Uint8Array, StdError.StdError>\n ) => Effect.Effect<Uint8Array, StdError.StdError>\n readonly commit: (\n changes: ReadonlyArray<Change>,\n ordinary: Effect.Effect<void, StdError.StdError>\n ) => Effect.Effect<void, StdError.StdError>\n}\n\n// This serializes one host's preparation, ledger and diagnostic ordering only.\n// It is NOT the guest's outside-writer exclusion or its atomic commit boundary.\nconst hostLocks = new WeakMap<object, Semaphore.Semaphore>()\n\n// The on-disk lock protocol owns this hash; dependency upgrades must not\n// change the name and let two versions acquire different locks for one file.\n// Case/normalization aliases deliberately share a lock, including on hosts\n// whose realPath preserves caller casing. Case-sensitive hosts may refuse a\n// simultaneous change to a distinct case variant; that is safe contention.\nconst lockHash = (value: string): string => {\n value = value.normalize(\"NFC\").toUpperCase()\n let hash = 5381\n for (let index = 0; index < value.length; index++) hash = (hash * 33) ^ value.charCodeAt(index)\n return (hash >>> 0).toString(16)\n}\n\nconst parent = (path: string) => path.slice(0, path.lastIndexOf(path.startsWith(\"/\") ? \"/\" : \"\\\\\") + 1)\n\n/**\n * Versioned hosts capture bases under a local semaphore until scope exit.\n * Ordinary hosts hold all named files using exclusive mkdir, so independently\n * composed hosts and processes agree.\n * A hash collision only refuses an unrelated edit; it cannot lose exclusion.\n *\n * @private\n * @since 1.0.0\n */\nexport const acquire = (\n fileSystem: FileSystem.FileSystem,\n paths: ReadonlyArray<string>,\n creationPaths?: Path.Path\n): Effect.Effect<Mutation, StdError.StdError, Scope.Scope> =>\n Effect.gen(function*() {\n // Unavailable coding providers refuse before acquiring even protocol state.\n // The versioned provider owns exclusion and revalidation at its commit;\n // cooperative caller-side locks cannot exclude terminal or SSH writers.\n yield* validate(fileSystem, paths)\n const policy = (fileSystem as VersionedFileSystem)[Preconditions]\n if (policy !== undefined) {\n let lock = hostLocks.get(policy)\n if (lock === undefined) {\n lock = Semaphore.makeUnsafe(1)\n hostLocks.set(policy, lock)\n }\n const held = lock\n yield* Effect.acquireRelease(held.take(1), () => held.release(1), { interruptible: true })\n const session = yield* ReadSession\n const prepared = yield* policy.prepare!(paths, session)\n return { read: (path) => prepared.read(path), commit: (changes) => prepared.commit(changes) }\n }\n const locks = new Map<string, string>()\n for (const path of paths) {\n const destination = yield* fileSystem.realPath(path).pipe(\n Effect.catch((error) =>\n error.reason._tag === \"NotFound\" && creationPaths !== undefined\n ? fileSystem.realPath(creationPaths.dirname(path)).pipe(\n Effect.map((directory) => creationPaths.join(directory, creationPaths.basename(path)))\n )\n : Effect.fail(error)\n ),\n Effect.mapError(FsFailure.reading(path, `File not found: ${path}`))\n )\n const lock = `${parent(destination)}.smithers-${lockHash(destination)}.lock`\n locks.set(lock, path)\n }\n for (const [lock, path] of [...locks].sort(([left], [right]) => left.localeCompare(right))) {\n yield* Effect.acquireRelease(\n fileSystem.makeDirectory(lock, { mode: 0o700 }).pipe(\n Effect.mapError(FsFailure.denied(path, (error) =>\n new StdError.StdError({\n code: error.reason._tag === \"AlreadyExists\" ? \"no_match\" : \"command_failed\",\n message: error.reason._tag === \"AlreadyExists\"\n ? `Concurrent mutation of ${path}: lock ${lock} is held. Re-read and retry after the other writer finishes; a stopped writer's lock requires explicit recovery.`\n : `Could not lock ${path} for mutation`,\n path\n })))\n ),\n () => fileSystem.remove(lock, { recursive: true }).pipe(Effect.orDie)\n )\n }\n return { read: (_path, ordinary) => ordinary, commit: (_changes, ordinary) => ordinary }\n })\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a filesystem failure to the standard-flow code that names its reason.
|
|
3
|
+
*
|
|
4
|
+
* A permission denial is not a missing file. Telling the model a denied path
|
|
5
|
+
* does not exist sends it searching for a file that is right there, and hides
|
|
6
|
+
* the denial from whoever reads the run. Every standard flow that touches the
|
|
7
|
+
* filesystem routes its failures through here so `PermissionDenied` always
|
|
8
|
+
* reaches the model as `permission_denied`.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
import type * as PlatformError from "effect/PlatformError";
|
|
13
|
+
import * as StdError from "../StdError.ts";
|
|
14
|
+
/**
|
|
15
|
+
* The failure for a path the host or the kernel guard refused.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
export declare const permissionDenied: (path: string) => StdError.StdError;
|
|
21
|
+
/**
|
|
22
|
+
* Maps `PermissionDenied` to `permission_denied` and any other reason through
|
|
23
|
+
* `otherwise`.
|
|
24
|
+
*
|
|
25
|
+
* @private
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
*/
|
|
28
|
+
export declare const denied: (path: string, otherwise: (error: PlatformError.PlatformError) => StdError.StdError) => (error: PlatformError.PlatformError) => StdError.StdError;
|
|
29
|
+
/**
|
|
30
|
+
* Maps a read-side failure: `NotFound` to `not_found` with `notFoundMessage`,
|
|
31
|
+
* `PermissionDenied` to `permission_denied`, and anything else to
|
|
32
|
+
* `command_failed` carrying the host's reason.
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
*/
|
|
37
|
+
export declare const reading: (path: string, notFoundMessage: string) => (error: PlatformError.PlatformError) => StdError.StdError;
|
|
38
|
+
//# sourceMappingURL=FsFailure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsFailure.d.ts","sourceRoot":"","sources":["../../../src/internal/FsFailure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,aAAa,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,QAAQ,CAAC,QAC0C,CAAA;AAEnG;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GACjB,MAAM,MAAM,EACZ,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,KAAK,QAAQ,CAAC,QAAQ,MAErE,OAAO,aAAa,CAAC,aAAa,KAAG,QAAQ,CAAC,QACuC,CAAA;AAEtF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,iBAAiB,MAAM,aAXrD,aAAa,CAAC,aAAa,KAAG,QAAQ,CAAC,QAesE,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a filesystem failure to the standard-flow code that names its reason.
|
|
3
|
+
*
|
|
4
|
+
* A permission denial is not a missing file. Telling the model a denied path
|
|
5
|
+
* does not exist sends it searching for a file that is right there, and hides
|
|
6
|
+
* the denial from whoever reads the run. Every standard flow that touches the
|
|
7
|
+
* filesystem routes its failures through here so `PermissionDenied` always
|
|
8
|
+
* reaches the model as `permission_denied`.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
import * as StdError from "../StdError.js";
|
|
13
|
+
/**
|
|
14
|
+
* The failure for a path the host or the kernel guard refused.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
export const permissionDenied = (path) => new StdError.StdError({ code: "permission_denied", message: `Permission denied: ${path}`, path });
|
|
20
|
+
/**
|
|
21
|
+
* Maps `PermissionDenied` to `permission_denied` and any other reason through
|
|
22
|
+
* `otherwise`.
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
*/
|
|
27
|
+
export const denied = (path, otherwise) => (error) => error.reason._tag === "PermissionDenied" ? permissionDenied(path) : otherwise(error);
|
|
28
|
+
/**
|
|
29
|
+
* Maps a read-side failure: `NotFound` to `not_found` with `notFoundMessage`,
|
|
30
|
+
* `PermissionDenied` to `permission_denied`, and anything else to
|
|
31
|
+
* `command_failed` carrying the host's reason.
|
|
32
|
+
*
|
|
33
|
+
* @private
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
export const reading = (path, notFoundMessage) => denied(path, (error) => error.reason._tag === "NotFound"
|
|
37
|
+
? new StdError.StdError({ code: "not_found", message: notFoundMessage, path })
|
|
38
|
+
: new StdError.StdError({ code: "command_failed", message: `Could not read ${path}: ${error.message}`, path }));
|
|
39
|
+
//# sourceMappingURL=FsFailure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsFailure.js","sourceRoot":"","sources":["../../../src/internal/FsFailure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAqB,EAAE,CAClE,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,sBAAsB,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AAEnG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,IAAY,EACZ,SAAoE,EACpE,EAAE,CACJ,CAAC,KAAkC,EAAqB,EAAE,CACxD,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAEtF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,eAAuB,EAAE,EAAE,CAC/D,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACrB,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU;IAC9B,CAAC,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IAC9E,CAAC,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Maps a filesystem failure to the standard-flow code that names its reason.\n *\n * A permission denial is not a missing file. Telling the model a denied path\n * does not exist sends it searching for a file that is right there, and hides\n * the denial from whoever reads the run. Every standard flow that touches the\n * filesystem routes its failures through here so `PermissionDenied` always\n * reaches the model as `permission_denied`.\n *\n * @since 1.0.0\n */\n\nimport type * as PlatformError from \"effect/PlatformError\"\nimport * as StdError from \"../StdError.ts\"\n\n/**\n * The failure for a path the host or the kernel guard refused.\n *\n * @private\n * @since 1.0.0\n */\nexport const permissionDenied = (path: string): StdError.StdError =>\n new StdError.StdError({ code: \"permission_denied\", message: `Permission denied: ${path}`, path })\n\n/**\n * Maps `PermissionDenied` to `permission_denied` and any other reason through\n * `otherwise`.\n *\n * @private\n * @since 1.0.0\n */\nexport const denied = (\n path: string,\n otherwise: (error: PlatformError.PlatformError) => StdError.StdError\n) =>\n(error: PlatformError.PlatformError): StdError.StdError =>\n error.reason._tag === \"PermissionDenied\" ? permissionDenied(path) : otherwise(error)\n\n/**\n * Maps a read-side failure: `NotFound` to `not_found` with `notFoundMessage`,\n * `PermissionDenied` to `permission_denied`, and anything else to\n * `command_failed` carrying the host's reason.\n *\n * @private\n * @since 1.0.0\n */\nexport const reading = (path: string, notFoundMessage: string) =>\n denied(path, (error) =>\n error.reason._tag === \"NotFound\"\n ? new StdError.StdError({ code: \"not_found\", message: notFoundMessage, path })\n : new StdError.StdError({ code: \"command_failed\", message: `Could not read ${path}: ${error.message}`, path }))\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detached checkouts shared by checkpoint reads and baseline test runs.
|
|
3
|
+
*
|
|
4
|
+
* ## Host git never reads a file the agent can write that names a program
|
|
5
|
+
*
|
|
6
|
+
* The repository is the workspace's, and an agent can write its `.git`: a
|
|
7
|
+
* containerised agent writes it through the bind mount. Git reads programs out
|
|
8
|
+
* of that directory in more places than any list of `-c` overrides can close.
|
|
9
|
+
* Hooks and `core.fsmonitor` can be overridden, but a filter driver
|
|
10
|
+
* (`filter.<name>.clean`/`.smudge` in `.git/config`, selected by
|
|
11
|
+
* `.git/info/attributes`) cannot: git has no switch that ignores repository
|
|
12
|
+
* config or `$GIT_DIR/info/attributes`, and overriding each driver by name
|
|
13
|
+
* races an agent that keeps rewriting the file.
|
|
14
|
+
*
|
|
15
|
+
* So the git that records and checks out trees runs against a **shadow**
|
|
16
|
+
* `GIT_DIR`: a bare repository this module creates under the host's temporary
|
|
17
|
+
* directory for one operation and deletes afterwards. Its config, hooks and
|
|
18
|
+
* `info/attributes` are the ones `git init --template=` writes, which is none.
|
|
19
|
+
* `GIT_CONFIG_NOSYSTEM` and `GIT_CONFIG_GLOBAL=/dev/null` drop the host's own
|
|
20
|
+
* config files too, so the only settings are the ones on the command line.
|
|
21
|
+
* `GIT_OBJECT_DIRECTORY` points at the workspace's object store, because objects
|
|
22
|
+
* are data: git hashes and inflates them and never runs anything they say.
|
|
23
|
+
*
|
|
24
|
+
* What still touches the workspace repository is plain data:
|
|
25
|
+
*
|
|
26
|
+
* - `rev-parse` in the workspace, which resolves refs and paths and runs no
|
|
27
|
+
* hook, filter, fsmonitor or other configured program;
|
|
28
|
+
* - `git config --file <workspace config>`, which reads or writes that one file
|
|
29
|
+
* and follows no `include`;
|
|
30
|
+
* - a copy of the workspace index into the shadow, so the recorded tree holds
|
|
31
|
+
* what the agent staged without the harness writing the agent's index; and
|
|
32
|
+
* - a handful of `core.*` settings that change how bytes are hashed
|
|
33
|
+
* ({@link dataSettings}), each accepted only as a bare word.
|
|
34
|
+
*
|
|
35
|
+
* A materialized checkout gets its own standalone `.git`, written by this
|
|
36
|
+
* module as files, so a container can still run git in it: `HEAD` names the
|
|
37
|
+
* commit, `objects/info/alternates` points back at the workspace's objects by a
|
|
38
|
+
* relative path, and `index` is the one the checkout was written from. Host git
|
|
39
|
+
* never uses that directory; it is the container's.
|
|
40
|
+
*
|
|
41
|
+
* @since 1.0.0
|
|
42
|
+
*/
|
|
43
|
+
import type { ChildProcessSpawner } from "@smthrs/kernel/ChildProcessSpawner";
|
|
44
|
+
import { Effect } from "effect";
|
|
45
|
+
import * as StdError from "../StdError.ts";
|
|
46
|
+
import * as Exec from "./Exec.ts";
|
|
47
|
+
/**
|
|
48
|
+
* Where one workspace repository keeps what the shadow needs, as its own git
|
|
49
|
+
* reports it.
|
|
50
|
+
*
|
|
51
|
+
* @category models
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
*/
|
|
54
|
+
export interface Repository {
|
|
55
|
+
/** The root the caller named, without a trailing slash. */
|
|
56
|
+
readonly root: string;
|
|
57
|
+
/** The same directory, as git canonicalizes it. */
|
|
58
|
+
readonly toplevel: string;
|
|
59
|
+
/** The common git directory, which holds config and objects. */
|
|
60
|
+
readonly common: string;
|
|
61
|
+
/** The workspace index. */
|
|
62
|
+
readonly index: string;
|
|
63
|
+
readonly objectFormat: string;
|
|
64
|
+
/** {@link dataSettings} as `-c` arguments. */
|
|
65
|
+
readonly settings: ReadonlyArray<string>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A harness-owned `GIT_DIR` over one workspace's objects.
|
|
69
|
+
*
|
|
70
|
+
* @category models
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
*/
|
|
73
|
+
export interface Shadow {
|
|
74
|
+
readonly path: string;
|
|
75
|
+
readonly repository: Repository;
|
|
76
|
+
/** Runs host git with the shadow as `GIT_DIR`, and `workTree` as its work tree when given. */
|
|
77
|
+
readonly git: (args: ReadonlyArray<string>, workTree?: string) => Effect.Effect<Exec.ExecResult, StdError.StdError, ChildProcessSpawner>;
|
|
78
|
+
/**
|
|
79
|
+
* Copies the workspace index into the shadow, with its modification time, so
|
|
80
|
+
* the shadow never writes the agent's own.
|
|
81
|
+
*
|
|
82
|
+
* The time is part of what git reads. It trusts an entry's recorded stat
|
|
83
|
+
* unless the entry is at least as new as the index file, in whole seconds;
|
|
84
|
+
* a copy stamped at the moment of copying made every entry look older, and a
|
|
85
|
+
* same-size edit from the second the index was written was recorded as the
|
|
86
|
+
* committed bytes (#3431). The time is taken before the bytes are read, so
|
|
87
|
+
* an index rewritten meanwhile leaves the copy looking older, never newer.
|
|
88
|
+
*/
|
|
89
|
+
readonly adoptIndex: Effect.Effect<void, StdError.StdError, ChildProcessSpawner>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Internal Git operations used by both checkpoint and baseline leases.
|
|
93
|
+
*
|
|
94
|
+
* @category utilities
|
|
95
|
+
* @since 1.0.0
|
|
96
|
+
*/
|
|
97
|
+
export declare const GitWorktree: {
|
|
98
|
+
config: (repository: Pick<Repository, "common">, args: ReadonlyArray<string>) => Effect.Effect<Exec.ExecResult, StdError.StdError, ChildProcessSpawner>;
|
|
99
|
+
git: (root: string, args: ReadonlyArray<string>) => Effect.Effect<Exec.ExecResult, StdError.StdError, ChildProcessSpawner>;
|
|
100
|
+
open: (root: string) => Effect.Effect<Repository, StdError.StdError, ChildProcessSpawner>;
|
|
101
|
+
resolveCommit: (root: string, refs: ReadonlyArray<string>) => Effect.Effect<{
|
|
102
|
+
ref: string;
|
|
103
|
+
commit: string;
|
|
104
|
+
}, StdError.StdError, ChildProcessSpawner>;
|
|
105
|
+
withDetachedWorktree: <A, E, R>(root: string, prefix: string, commit: string, use: (host: string) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | StdError.StdError, R | ChildProcessSpawner>;
|
|
106
|
+
withShadow: <A, E, R>(root: string | Repository, use: (shadow: Shadow) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | StdError.StdError, R | ChildProcessSpawner>;
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=GitWorktree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitWorktree.d.ts","sourceRoot":"","sources":["../../../src/internal/GitWorktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AA+CjC;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACzC;AAuDD;;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