@smthrs/std 0.0.0-stage → 1.0.0-rc.3
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 +304 -0
- package/dist/cjs/Bash.d.ts.map +1 -0
- package/dist/cjs/Bash.js +321 -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 +98 -0
- package/dist/cjs/internal/GitWorktree.d.ts.map +1 -0
- package/dist/cjs/internal/GitWorktree.js +270 -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 +304 -0
- package/dist/esm/Bash.d.ts.map +1 -0
- package/dist/esm/Bash.js +469 -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 +98 -0
- package/dist/esm/internal/GitWorktree.d.ts.map +1 -0
- package/dist/esm/internal/GitWorktree.js +345 -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 +549 -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 +473 -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
package/dist/cjs/Read.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name2 in all)
|
|
10
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Read_exports = {};
|
|
30
|
+
__export(Read_exports, {
|
|
31
|
+
Input: () => Input,
|
|
32
|
+
MAX_READ_FILE_BYTES: () => MAX_READ_FILE_BYTES,
|
|
33
|
+
Output: () => Output,
|
|
34
|
+
Preconditions: () => import_FileMutation.Preconditions,
|
|
35
|
+
ReadSession: () => import_FileMutation.ReadSession,
|
|
36
|
+
activity: () => activity,
|
|
37
|
+
capabilities: () => capabilities,
|
|
38
|
+
description: () => description,
|
|
39
|
+
effects: () => effects,
|
|
40
|
+
effectsFor: () => effectsFor,
|
|
41
|
+
flow: () => flow,
|
|
42
|
+
name: () => name,
|
|
43
|
+
presentation: () => presentation,
|
|
44
|
+
run: () => run
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(Read_exports);
|
|
47
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
48
|
+
var FileSystem = __toESM(require("effect/FileSystem"), 1);
|
|
49
|
+
var Option = __toESM(require("effect/Option"), 1);
|
|
50
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
51
|
+
var import_Declaration = require("./internal/Declaration.js");
|
|
52
|
+
var FileMutation = __toESM(require("./internal/FileMutation.js"), 1);
|
|
53
|
+
var FsFailure = __toESM(require("./internal/FsFailure.js"), 1);
|
|
54
|
+
var import_Text = require("./internal/Text.js");
|
|
55
|
+
var StdError = __toESM(require("./StdError.js"), 1);
|
|
56
|
+
var import_FileMutation = require("./internal/FileMutation.js");
|
|
57
|
+
const name = "read";
|
|
58
|
+
const description = "Read a text file by 1-based offset and limit. content is RAW file text with no line-number prefixes, so any line of it is an edit anchor as it stands; the numbers are startLine/endLine.";
|
|
59
|
+
const Input = Schema.Struct({
|
|
60
|
+
path: Schema.String.annotate({ description: "Path of the text file to read" }),
|
|
61
|
+
offset: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1))).annotate({
|
|
62
|
+
description: "1-based line offset"
|
|
63
|
+
}),
|
|
64
|
+
limit: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1))).annotate({
|
|
65
|
+
description: "Maximum number of lines to return"
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
const Output = Schema.Struct({
|
|
69
|
+
content: Schema.String.annotate({
|
|
70
|
+
description: "Raw page text, preserving CR bytes and omitting the final LF; never line-number prefixed"
|
|
71
|
+
}),
|
|
72
|
+
startLine: Schema.Number.annotate({ description: "First returned 1-based line number" }),
|
|
73
|
+
endLine: Schema.Number.annotate({
|
|
74
|
+
description: "Last returned 1-based line number, or startLine - 1 when no lines are returned"
|
|
75
|
+
}),
|
|
76
|
+
totalLines: Schema.Number.annotate({ description: "Total number of source lines" }),
|
|
77
|
+
truncated: Schema.Boolean.annotate({ description: "Whether displayed output was truncated" }),
|
|
78
|
+
notice: Schema.optional(Schema.String.annotate({ description: "Truncation disclosure" }))
|
|
79
|
+
});
|
|
80
|
+
const effects = (0, import_Declaration.envelope)({
|
|
81
|
+
tier: "sealed",
|
|
82
|
+
mode: "hermetic",
|
|
83
|
+
reads: ["/**"],
|
|
84
|
+
writes: []
|
|
85
|
+
});
|
|
86
|
+
const effectsFor = (input) => (0, import_Declaration.envelope)({
|
|
87
|
+
tier: "sealed",
|
|
88
|
+
mode: "hermetic",
|
|
89
|
+
reads: [input.path],
|
|
90
|
+
writes: []
|
|
91
|
+
});
|
|
92
|
+
const capabilities = [(0, import_Declaration.capability)("fs:read", "/**")];
|
|
93
|
+
const flow = { name, description, input: Input, output: Output, capabilities, effects };
|
|
94
|
+
const activity = "reads";
|
|
95
|
+
const presentation = {
|
|
96
|
+
verb: { pending: "reading", success: "read", failure: "failed to read" },
|
|
97
|
+
subject: "path",
|
|
98
|
+
result: "read"
|
|
99
|
+
};
|
|
100
|
+
const clipLine = (line) => {
|
|
101
|
+
let scalars = 0;
|
|
102
|
+
let end = 0;
|
|
103
|
+
for (const scalar of line) {
|
|
104
|
+
if (scalars === import_Text.MAX_LINE_CHARS) return line.slice(0, end);
|
|
105
|
+
scalars++;
|
|
106
|
+
end += scalar.length;
|
|
107
|
+
}
|
|
108
|
+
return line;
|
|
109
|
+
};
|
|
110
|
+
const MAX_READ_FILE_BYTES = 64 * 1024 * 1024;
|
|
111
|
+
const fileError = (path) => FsFailure.reading(path, `File not found: ${path}`);
|
|
112
|
+
const sharedPrefix = (left, right) => {
|
|
113
|
+
let index = 0;
|
|
114
|
+
while (index < left.length && index < right.length && left[index] === right[index]) index++;
|
|
115
|
+
return index;
|
|
116
|
+
};
|
|
117
|
+
const nearest = (fileSystem, path) => Effect.gen(function* () {
|
|
118
|
+
const segments = path.split("/").filter((segment) => segment !== "" && segment !== ".");
|
|
119
|
+
if (path.startsWith("/") || segments.includes("..")) return "";
|
|
120
|
+
for (let depth = segments.length - 1; depth >= 0; depth--) {
|
|
121
|
+
const directory = segments.slice(0, depth).join("/");
|
|
122
|
+
const entries = yield* fileSystem.readDirectory(directory === "" ? "." : directory).pipe(Effect.option);
|
|
123
|
+
if (Option.isNone(entries)) continue;
|
|
124
|
+
const missing = segments[depth].toLowerCase();
|
|
125
|
+
const ranked = entries.value.filter((entry) => !entry.startsWith(".")).map((entry) => ({ entry, score: sharedPrefix(entry.toLowerCase(), missing) })).sort((left, right) => right.score - left.score).map(({ entry }) => entry);
|
|
126
|
+
if (ranked.length === 0) return "";
|
|
127
|
+
const shown = ranked.slice(0, 12).join(", ");
|
|
128
|
+
const more = ranked.length > 12 ? ` and ${ranked.length - 12} more` : "";
|
|
129
|
+
return `. ${directory === "" ? "The working directory" : directory} holds: ${shown}${more}.`;
|
|
130
|
+
}
|
|
131
|
+
return "";
|
|
132
|
+
});
|
|
133
|
+
const missingFile = (fileSystem, path) => Effect.flatMap(nearest(fileSystem, path), (hint) => Effect.fail(
|
|
134
|
+
new StdError.StdError({
|
|
135
|
+
code: "not_found",
|
|
136
|
+
message: `File not found: ${path}${hint}`,
|
|
137
|
+
path
|
|
138
|
+
})
|
|
139
|
+
));
|
|
140
|
+
const run = Effect.fn("Read.run")(function* (input) {
|
|
141
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
142
|
+
const info = yield* fileSystem.stat(input.path).pipe(
|
|
143
|
+
Effect.catchTag(
|
|
144
|
+
"PlatformError",
|
|
145
|
+
(error) => error.reason._tag === "NotFound" ? missingFile(fileSystem, input.path) : Effect.fail(fileError(input.path)(error))
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
if (info.type === "Directory") {
|
|
149
|
+
return yield* Effect.fail(
|
|
150
|
+
new StdError.StdError({
|
|
151
|
+
code: "is_directory",
|
|
152
|
+
message: `Cannot read a directory: ${input.path}`,
|
|
153
|
+
path: input.path
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
if (info.type !== "File") {
|
|
158
|
+
return yield* Effect.fail(
|
|
159
|
+
new StdError.StdError({
|
|
160
|
+
code: "not_found",
|
|
161
|
+
message: `File not found: ${input.path}`,
|
|
162
|
+
path: input.path
|
|
163
|
+
})
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
const size = Number(info.size);
|
|
167
|
+
if (size > MAX_READ_FILE_BYTES) {
|
|
168
|
+
return yield* Effect.fail(
|
|
169
|
+
new StdError.StdError({
|
|
170
|
+
code: "response_too_large",
|
|
171
|
+
message: `${input.path} is ${size} bytes, over the ${MAX_READ_FILE_BYTES}-byte read limit; search it with grep or print a line range with bash`,
|
|
172
|
+
path: input.path
|
|
173
|
+
})
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
const bytes = yield* fileSystem.readFile(input.path).pipe(Effect.mapError(fileError(input.path)));
|
|
177
|
+
if (bytes.includes(0)) {
|
|
178
|
+
return yield* Effect.fail(
|
|
179
|
+
new StdError.StdError({
|
|
180
|
+
code: "binary_file",
|
|
181
|
+
message: `Cannot read binary file: ${input.path}`,
|
|
182
|
+
path: input.path
|
|
183
|
+
})
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const text = yield* Effect.try({
|
|
187
|
+
try: () => new TextDecoder("utf-8", { fatal: true }).decode(bytes),
|
|
188
|
+
catch: () => new StdError.StdError({
|
|
189
|
+
code: "binary_file",
|
|
190
|
+
message: `File is not valid UTF-8: ${input.path}`,
|
|
191
|
+
path: input.path
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
const offset = input.offset ?? 1;
|
|
195
|
+
const page = (0, import_Text.slice)(text, { offset, limit: input.limit ?? import_Text.DEFAULT_READ_LIMIT });
|
|
196
|
+
if (offset > Math.max(page.totalLines, 1)) {
|
|
197
|
+
return yield* Effect.fail(
|
|
198
|
+
new StdError.StdError({
|
|
199
|
+
code: "offset_out_of_range",
|
|
200
|
+
message: `Line offset ${offset} is outside ${input.path}`,
|
|
201
|
+
path: input.path
|
|
202
|
+
})
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const lines = page.lines.map(clipLine);
|
|
206
|
+
const longLinesTruncated = lines.some((line, index) => line !== page.lines[index]);
|
|
207
|
+
const rendered = (0, import_Text.truncateBytes)(lines.join("\n"), import_Text.MAX_OUTPUT_BYTES, { keep: "head" });
|
|
208
|
+
const whole = rendered.truncated ? rendered.text.slice(0, Math.max(0, rendered.text.lastIndexOf("\n"))) : rendered.text;
|
|
209
|
+
const shown = rendered.truncated ? whole.split("\n").length : lines.length;
|
|
210
|
+
const endLine = page.startLine + shown - 1;
|
|
211
|
+
const truncated = longLinesTruncated || rendered.truncated || page.endLine < page.totalLines;
|
|
212
|
+
const clipped = longLinesTruncated ? ` Lines longer than ${import_Text.MAX_LINE_CHARS} Unicode scalar values are clipped, so such a line is not an edit anchor.` : "";
|
|
213
|
+
yield* FileMutation.recordRead(fileSystem, input.path, bytes);
|
|
214
|
+
return {
|
|
215
|
+
content: whole,
|
|
216
|
+
startLine: page.startLine,
|
|
217
|
+
endLine,
|
|
218
|
+
totalLines: page.totalLines,
|
|
219
|
+
truncated,
|
|
220
|
+
...truncated ? { notice: `${(0, import_Text.notice)("lines", shown, page.totalLines)}${clipped}` } : {}
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
//# sourceMappingURL=Read.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Read.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Read flow declaration and portable handler.\n *\n * `content` is raw file text. It used to be rendered as `NNN\\t<line>`, and that\n * rendering was the single most expensive tool defect measured on the 45-instance\n * SWE-bench trace program: an anchor copied out of a read carried the gutter, so\n * every `edit` built from a read missed, and every cell that wanted a literal\n * line had to strip the prefix in JavaScript first. Two instances (django-13346,\n * django-14351) spent whole frames writing string surgery against text the file\n * does not contain. Line numbers are facts about the page, so they are page\n * fields \u2014 `startLine` and `endLine` \u2014 and never bytes inside the text.\n *\n * Every line in `content` is a whole line: a page cut short by the byte budget\n * drops its trailing partial line rather than handing back a fragment that looks\n * like an anchor and is not one. CRLF lines retain their trailing CR; only\n * the page's final LF is omitted.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as FileSystem from \"effect/FileSystem\"\nimport * as Option from \"effect/Option\"\nimport * as Schema from \"effect/Schema\"\nimport { capability, envelope } from \"./internal/Declaration.ts\"\nimport * as FileMutation from \"./internal/FileMutation.ts\"\nimport * as FsFailure from \"./internal/FsFailure.ts\"\nimport { DEFAULT_READ_LIMIT, MAX_LINE_CHARS, MAX_OUTPUT_BYTES, notice, slice, truncateBytes } from \"./internal/Text.ts\"\nimport * as StdError from \"./StdError.ts\"\n\nexport { Preconditions, ReadSession, type VersionedFileSystem } from \"./internal/FileMutation.ts\"\n\n/**\n * Registry name for the read flow.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const name = \"read\"\n\n/**\n * Model-facing description of the read flow.\n *\n * @category descriptions\n * @since 1.0.0\n */\nexport const description =\n \"Read a text file by 1-based offset and limit. content is RAW file text with no line-number prefixes, so any line of it is an edit anchor as it stands; the numbers are startLine/endLine.\"\n\n/**\n * Input schema for the read flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Input = Schema.Struct({\n path: Schema.String.annotate({ description: \"Path of the text file to read\" }),\n offset: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1))).annotate({\n description: \"1-based line offset\"\n }),\n limit: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1))).annotate({\n description: \"Maximum number of lines to return\"\n })\n})\n\n/**\n * Decoded input accepted by the `read` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Input = typeof Input.Type\n\n/**\n * Output schema for the read flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Output = Schema.Struct({\n content: Schema.String.annotate({\n description: \"Raw page text, preserving CR bytes and omitting the final LF; never line-number prefixed\"\n }),\n startLine: Schema.Number.annotate({ description: \"First returned 1-based line number\" }),\n endLine: Schema.Number.annotate({\n description: \"Last returned 1-based line number, or startLine - 1 when no lines are returned\"\n }),\n totalLines: Schema.Number.annotate({ description: \"Total number of source lines\" }),\n truncated: Schema.Boolean.annotate({ description: \"Whether displayed output was truncated\" }),\n notice: Schema.optional(Schema.String.annotate({ description: \"Truncation disclosure\" }))\n})\n\n/**\n * Decoded output returned by the `read` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Output = typeof Output.Type\n\n/**\n * Static conservative effect envelope for the read flow.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effects = envelope({\n tier: \"sealed\",\n mode: \"hermetic\",\n reads: [\"/**\"],\n writes: []\n})\n\n/**\n * Narrows the read effect envelope to one input path.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effectsFor = (input: typeof Input.Type) =>\n envelope({\n tier: \"sealed\",\n mode: \"hermetic\",\n reads: [input.path],\n writes: []\n })\n\n/**\n * Capabilities required by the read flow.\n *\n * @category capabilities\n * @since 1.0.0\n */\nexport const capabilities = [capability(\"fs:read\", \"/**\")]\n\n/**\n * Declaration-only read flow.\n *\n * @category flows\n * @since 1.0.0\n */\nexport const flow = { name, description, input: Input, output: Output, capabilities, effects } as const\n\n/**\n * What a call to this flow does, for a reader of a run.\n *\n * Display metadata only. `@smthrs/registry` `Descriptor.FlowActivity` is the\n * governing vocabulary and `StandardFlows` binds this value onto the flow's\n * descriptor, where the binding site checks it. `declarationDigest` excludes\n * it, so declaring it cannot invalidate a call identity or a cached prompt.\n *\n * @category presentation\n * @since 1.0.0-rc.0\n */\nexport const activity = \"reads\" as const\n\n/**\n * How one recorded call to this flow reads: the verb for each settlement, the\n * input field that is its subject, and the measured output fields a one-line\n * summary may count.\n *\n * Display metadata only, governed by `@smthrs/registry`\n * `Descriptor.CallPresentation` and checked where `StandardFlows` binds it.\n *\n * @category presentation\n * @since 1.0.0-rc.0\n */\nexport const presentation = {\n verb: { pending: \"reading\", success: \"read\", failure: \"failed to read\" },\n subject: \"path\",\n result: \"read\"\n} as const\n\nconst clipLine = (line: string): string => {\n let scalars = 0\n let end = 0\n for (const scalar of line) {\n if (scalars === MAX_LINE_CHARS) return line.slice(0, end)\n scalars++\n end += scalar.length\n }\n return line\n}\n\n/**\n * The largest file `read` loads.\n *\n * `read` decodes the whole file to count its lines, so the file is held in\n * memory twice over: its bytes and a UTF-16 string. Past this bound a page\n * read would cost the host gigabytes for a window of a few thousand lines,\n * and past 2 GiB Node cannot load the file at all.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const MAX_READ_FILE_BYTES = 64 * 1024 * 1024\n\nconst fileError = (path: string) => FsFailure.reading(path, `File not found: ${path}`)\n\nconst sharedPrefix = (left: string, right: string): number => {\n let index = 0\n while (index < left.length && index < right.length && left[index] === right[index]) index++\n return index\n}\n\n/**\n * Where a guessed relative path stops existing, and what is there instead.\n *\n * A worker that guesses `packages/smithers/flow/src/Flow.ts` learns nothing\n * from \"not found\" and guesses again. Naming the nearest directory that exists\n * and its entries, closest name first, turns the next call into a choice.\n * Absolute paths and paths that climb out with `..` get no listing: the call\n * declared one file, and the working tree is the only place a listing is\n * already the caller's to read.\n */\nconst nearest = (\n fileSystem: FileSystem.FileSystem,\n path: string\n): Effect.Effect<string> =>\n Effect.gen(function*() {\n const segments = path.split(\"/\").filter((segment) => segment !== \"\" && segment !== \".\")\n if (path.startsWith(\"/\") || segments.includes(\"..\")) return \"\"\n for (let depth = segments.length - 1; depth >= 0; depth--) {\n const directory = segments.slice(0, depth).join(\"/\")\n const entries = yield* fileSystem.readDirectory(directory === \"\" ? \".\" : directory).pipe(Effect.option)\n if (Option.isNone(entries)) continue\n const missing = segments[depth]!.toLowerCase()\n const ranked = entries.value\n .filter((entry) => !entry.startsWith(\".\"))\n .map((entry) => ({ entry, score: sharedPrefix(entry.toLowerCase(), missing) }))\n .sort((left, right) => right.score - left.score)\n .map(({ entry }) => entry)\n if (ranked.length === 0) return \"\"\n const shown = ranked.slice(0, 12).join(\", \")\n const more = ranked.length > 12 ? ` and ${ranked.length - 12} more` : \"\"\n return `. ${directory === \"\" ? \"The working directory\" : directory} holds: ${shown}${more}.`\n }\n return \"\"\n })\n\nconst missingFile = (fileSystem: FileSystem.FileSystem, path: string) =>\n Effect.flatMap(nearest(fileSystem, path), (hint) =>\n Effect.fail(\n new StdError.StdError({\n code: \"not_found\",\n message: `File not found: ${path}${hint}`,\n path\n })\n ))\n\n/**\n * Reads, validates, and renders one page of a UTF-8 text file.\n *\n * The kernel filesystem exposes bytes rather than a guaranteed UTF-8 string,\n * so decoding is deliberately fatal to keep binary input in the typed channel.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const run = Effect.fn(\"Read.run\")(function*(\n input: typeof Input.Type\n): Effect.fn.Return<typeof Output.Type, StdError.StdError, FileSystem.FileSystem> {\n const fileSystem = yield* FileSystem.FileSystem\n const info = yield* fileSystem.stat(input.path).pipe(\n Effect.catchTag(\n \"PlatformError\",\n (error) =>\n error.reason._tag === \"NotFound\"\n ? missingFile(fileSystem, input.path)\n : Effect.fail(fileError(input.path)(error))\n )\n )\n if (info.type === \"Directory\") {\n return yield* Effect.fail(\n new StdError.StdError({\n code: \"is_directory\",\n message: `Cannot read a directory: ${input.path}`,\n path: input.path\n })\n )\n }\n if (info.type !== \"File\") {\n return yield* Effect.fail(\n new StdError.StdError({\n code: \"not_found\",\n message: `File not found: ${input.path}`,\n path: input.path\n })\n )\n }\n const size = Number(info.size)\n if (size > MAX_READ_FILE_BYTES) {\n return yield* Effect.fail(\n new StdError.StdError({\n code: \"response_too_large\",\n message:\n `${input.path} is ${size} bytes, over the ${MAX_READ_FILE_BYTES}-byte read limit; search it with grep or print a line range with bash`,\n path: input.path\n })\n )\n }\n const bytes = yield* fileSystem.readFile(input.path).pipe(Effect.mapError(fileError(input.path)))\n if (bytes.includes(0)) {\n return yield* Effect.fail(\n new StdError.StdError({\n code: \"binary_file\",\n message: `Cannot read binary file: ${input.path}`,\n path: input.path\n })\n )\n }\n const text = yield* Effect.try({\n try: () => new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes),\n catch: () =>\n new StdError.StdError({\n code: \"binary_file\",\n message: `File is not valid UTF-8: ${input.path}`,\n path: input.path\n })\n })\n const offset = input.offset ?? 1\n const page = slice(text, { offset, limit: input.limit ?? DEFAULT_READ_LIMIT })\n // An empty file has no lines, and reading one is not an out-of-range read:\n // the caller asked for the first page and there is nothing on it. Only an\n // offset past the first line of a file that has none is out of range.\n if (offset > Math.max(page.totalLines, 1)) {\n return yield* Effect.fail(\n new StdError.StdError({\n code: \"offset_out_of_range\",\n message: `Line offset ${offset} is outside ${input.path}`,\n path: input.path\n })\n )\n }\n const lines = page.lines.map(clipLine)\n const longLinesTruncated = lines.some((line, index) => line !== page.lines[index])\n const rendered = truncateBytes(lines.join(\"\\n\"), MAX_OUTPUT_BYTES, { keep: \"head\" })\n // A byte budget cuts mid-line. A partial line reads like an anchor and is not\n // one, so the page ends at the last whole line it could afford.\n const whole = rendered.truncated\n ? rendered.text.slice(0, Math.max(0, rendered.text.lastIndexOf(\"\\n\")))\n : rendered.text\n // Each clipped line fits the byte budget, so a truncated page retains at least one whole line.\n const shown = rendered.truncated ? whole.split(\"\\n\").length : lines.length\n const endLine = page.startLine + shown - 1\n const truncated = longLinesTruncated || rendered.truncated || page.endLine < page.totalLines\n const clipped = longLinesTruncated\n ? ` Lines longer than ${MAX_LINE_CHARS} Unicode scalar values are clipped, so such a line is not an edit anchor.`\n : \"\"\n yield* FileMutation.recordRead(fileSystem, input.path, bytes)\n return {\n content: whole,\n startLine: page.startLine,\n endLine,\n totalLines: page.totalLines,\n truncated,\n ...(truncated ? { notice: `${notice(\"lines\", shown, page.totalLines)}${clipped}` } : {})\n }\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,aAAwB;AACxB,iBAA4B;AAC5B,aAAwB;AACxB,aAAwB;AACxB,yBAAqC;AACrC,mBAA8B;AAC9B,gBAA2B;AAC3B,kBAAmG;AACnG,eAA0B;AAE1B,0BAAqE;AAQ9D,MAAM,OAAO;AAQb,MAAM,cACX;AAQK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;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,QAAQ,KAAK,MAAM,IAAI,QAAQ;AACrC,QAAM,qBAAqB,MAAM,KAAK,CAAC,MAAM,UAAU,SAAS,KAAK,MAAM,KAAK,CAAC;AACjF,QAAM,eAAW,2BAAc,MAAM,KAAK,IAAI,GAAG,8BAAkB,EAAE,MAAM,OAAO,CAAC;AAGnF,QAAM,QAAQ,SAAS,YACnB,SAAS,KAAK,MAAM,GAAG,KAAK,IAAI,GAAG,SAAS,KAAK,YAAY,IAAI,CAAC,CAAC,IACnE,SAAS;AAEb,QAAM,QAAQ,SAAS,YAAY,MAAM,MAAM,IAAI,EAAE,SAAS,MAAM;AACpE,QAAM,UAAU,KAAK,YAAY,QAAQ;AACzC,QAAM,YAAY,sBAAsB,SAAS,aAAa,KAAK,UAAU,KAAK;AAClF,QAAM,UAAU,qBACZ,sBAAsB,0BAAc,8EACpC;AACJ,SAAO,aAAa,WAAW,YAAY,MAAM,MAAM,KAAK;AAC5D,SAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW,KAAK;AAAA,IAChB;AAAA,IACA,YAAY,KAAK;AAAA,IACjB;AAAA,IACA,GAAI,YAAY,EAAE,QAAQ,OAAG,oBAAO,SAAS,OAAO,KAAK,UAAU,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;AAAA,EACxF;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What can be pointed at a checkpoint, and what cannot.
|
|
3
|
+
*
|
|
4
|
+
* {@link relocate} is the closed answer, and it is the half of the checkpoint
|
|
5
|
+
* feature that tracks the flows rather than git: it knows that `bash` carries
|
|
6
|
+
* its working directory in `cwd` and that `read`, `ls`, `grep` and `glob` carry
|
|
7
|
+
* their subject in `path`, `path`, `root` and `root`. `Checkpoints` changes when
|
|
8
|
+
* git does; this changes when one of those five input shapes does, which is why
|
|
9
|
+
* it is a module of its own. `Relocate.test.ts` decodes every rewritten input
|
|
10
|
+
* with the flow's own `Input` schema, so a renamed field fails there rather than
|
|
11
|
+
* silently relocating nothing.
|
|
12
|
+
*
|
|
13
|
+
* `bash` names *where it runs*, so it is relocated by its `cwd` — into the
|
|
14
|
+
* checkpoint, and into the same subdirectory of it the call asked for, because a
|
|
15
|
+
* check declared in `tests/` that silently ran at the top would come back
|
|
16
|
+
* failing for a reason nobody chose. `read`, `ls`, `grep` and `glob` name *what
|
|
17
|
+
* they touch* relative to the workspace root, so they are relocated by prefixing
|
|
18
|
+
* that root — and only when the path they name stays inside the tree, because an
|
|
19
|
+
* absolute path in these runs is a container path the host cannot rebase and a
|
|
20
|
+
* `..` path is the live tree under another name. Every other flow answers
|
|
21
|
+
* `checkpoint_unsupported` through the harness, including `test`, which already
|
|
22
|
+
* has `against: "base"` for exactly this question and would otherwise have two
|
|
23
|
+
* mechanisms that can disagree.
|
|
24
|
+
*
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
*/
|
|
27
|
+
import type { Schema } from "effect";
|
|
28
|
+
import type { Materialized } from "./Checkpoints.ts";
|
|
29
|
+
/**
|
|
30
|
+
* Why one input could not be pointed at a checkpoint.
|
|
31
|
+
*
|
|
32
|
+
* @category models
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
*/
|
|
35
|
+
export type Relocation = {
|
|
36
|
+
readonly _tag: "Relocated";
|
|
37
|
+
readonly input: Schema.Json;
|
|
38
|
+
} | {
|
|
39
|
+
readonly _tag: "UnsupportedFlow";
|
|
40
|
+
} | {
|
|
41
|
+
readonly _tag: "AbsolutePath";
|
|
42
|
+
readonly path: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly _tag: "OutsideTree";
|
|
45
|
+
readonly path: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Rewrites one call's input so the call runs against a materialized checkpoint.
|
|
49
|
+
*
|
|
50
|
+
* Returns the rewritten input, or the reason there is none. A `bash` call runs
|
|
51
|
+
* in the checkpoint's directory — from the *guest* side when it names a
|
|
52
|
+
* container, because that is the path the container will be given — and keeps
|
|
53
|
+
* whatever subdirectory it asked for: a check declared in `tests/` runs in the
|
|
54
|
+
* checkpoint's `tests/`. A working directory the checkpoint holds no copy of,
|
|
55
|
+
* such as somewhere else on the machine, becomes the checkpoint's own top,
|
|
56
|
+
* because a tree is all this can offer and there is no subpath in it to keep.
|
|
57
|
+
*
|
|
58
|
+
* A reader takes the checkpoint's workspace-relative directory as the prefix of
|
|
59
|
+
* what it names, because these flows resolve their subject against the
|
|
60
|
+
* workspace root and the checkpoint is a directory under it.
|
|
61
|
+
*
|
|
62
|
+
* Two paths are refused rather than rewritten, and both for the same reason —
|
|
63
|
+
* the host would otherwise hand back a reading of a tree the cell did not name.
|
|
64
|
+
* An absolute path in these runs is a container path, and the host cannot know
|
|
65
|
+
* which prefix of it names the tree. A relative path that climbs past the
|
|
66
|
+
* checkpoint with `..` names the live tree, exactly the tree the reading was
|
|
67
|
+
* taken to avoid.
|
|
68
|
+
*
|
|
69
|
+
* @category conversions
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
*/
|
|
72
|
+
export declare const relocate: (flow: string, input: Schema.Json, materialized: Materialized) => Relocation;
|
|
73
|
+
//# sourceMappingURL=Relocate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Relocate.d.ts","sourceRoot":"","sources":["../../src/Relocate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA0BpD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACpC;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AA4C3D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,QAAQ,GACnB,MAAM,MAAM,EACZ,OAAO,MAAM,CAAC,IAAI,EAClB,cAAc,YAAY,KACzB,UA4BF,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Relocate_exports = {};
|
|
20
|
+
__export(Relocate_exports, {
|
|
21
|
+
relocate: () => relocate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Relocate_exports);
|
|
24
|
+
var import_Paths = require("./internal/Paths.js");
|
|
25
|
+
const located = {
|
|
26
|
+
bash: { field: "cwd", kind: "cwd" },
|
|
27
|
+
read: { field: "path", kind: "path" },
|
|
28
|
+
ls: { field: "path", kind: "path" },
|
|
29
|
+
grep: { field: "root", kind: "path" },
|
|
30
|
+
glob: { field: "root", kind: "path" }
|
|
31
|
+
};
|
|
32
|
+
const contained = (path) => {
|
|
33
|
+
const parts = [];
|
|
34
|
+
for (const segment of path.split("/")) {
|
|
35
|
+
if (segment === "" || segment === ".") continue;
|
|
36
|
+
if (segment !== "..") {
|
|
37
|
+
parts.push(segment);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (parts.length === 0) return void 0;
|
|
41
|
+
parts.pop();
|
|
42
|
+
}
|
|
43
|
+
return parts.join("/");
|
|
44
|
+
};
|
|
45
|
+
const within = (root, declared) => {
|
|
46
|
+
if (!declared.startsWith("/")) return contained(declared);
|
|
47
|
+
if ((0, import_Paths.withoutTrailingSlash)(declared) === root) return "";
|
|
48
|
+
return declared.startsWith(`${root}/`) ? contained(declared.slice(root.length + 1)) : void 0;
|
|
49
|
+
};
|
|
50
|
+
const relocate = (flow, input, materialized) => {
|
|
51
|
+
const rule = located[flow];
|
|
52
|
+
if (rule === void 0) return { _tag: "UnsupportedFlow" };
|
|
53
|
+
const record = input !== null && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
54
|
+
const declared = record[rule.field];
|
|
55
|
+
if (rule.kind === "cwd") {
|
|
56
|
+
const containerised = typeof record["container"] === "string" && record["container"] !== "";
|
|
57
|
+
const base = containerised ? materialized.guest : materialized.host;
|
|
58
|
+
const kept2 = typeof declared === "string" && declared !== "" ? within(containerised ? materialized.guestRoot : materialized.root, declared) : "";
|
|
59
|
+
return {
|
|
60
|
+
_tag: "Relocated",
|
|
61
|
+
input: { ...record, cwd: kept2 === void 0 || kept2 === "" ? base : `${base}/${kept2}` }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const relative = materialized.host.slice((0, import_Paths.withoutTrailingSlash)(materialized.root).length + 1);
|
|
65
|
+
if (declared === void 0) return { _tag: "Relocated", input: { ...record, [rule.field]: relative } };
|
|
66
|
+
if (typeof declared !== "string") return { _tag: "UnsupportedFlow" };
|
|
67
|
+
if (declared.startsWith("/")) return { _tag: "AbsolutePath", path: declared };
|
|
68
|
+
const kept = contained(declared);
|
|
69
|
+
if (kept === void 0) return { _tag: "OutsideTree", path: declared };
|
|
70
|
+
return { _tag: "Relocated", input: { ...record, [rule.field]: kept === "" ? relative : `${relative}/${kept}` } };
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=Relocate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Relocate.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * What can be pointed at a checkpoint, and what cannot.\n *\n * {@link relocate} is the closed answer, and it is the half of the checkpoint\n * feature that tracks the flows rather than git: it knows that `bash` carries\n * its working directory in `cwd` and that `read`, `ls`, `grep` and `glob` carry\n * their subject in `path`, `path`, `root` and `root`. `Checkpoints` changes when\n * git does; this changes when one of those five input shapes does, which is why\n * it is a module of its own. `Relocate.test.ts` decodes every rewritten input\n * with the flow's own `Input` schema, so a renamed field fails there rather than\n * silently relocating nothing.\n *\n * `bash` names *where it runs*, so it is relocated by its `cwd` \u2014 into the\n * checkpoint, and into the same subdirectory of it the call asked for, because a\n * check declared in `tests/` that silently ran at the top would come back\n * failing for a reason nobody chose. `read`, `ls`, `grep` and `glob` name *what\n * they touch* relative to the workspace root, so they are relocated by prefixing\n * that root \u2014 and only when the path they name stays inside the tree, because an\n * absolute path in these runs is a container path the host cannot rebase and a\n * `..` path is the live tree under another name. Every other flow answers\n * `checkpoint_unsupported` through the harness, including `test`, which already\n * has `against: \"base\"` for exactly this question and would otherwise have two\n * mechanisms that can disagree.\n *\n * @since 1.0.0\n */\n\nimport type { Schema } from \"effect\"\nimport type { Materialized } from \"./Checkpoints.ts\"\nimport { withoutTrailingSlash } from \"./internal/Paths.ts\"\n\n/**\n * The flows whose input names where they run or what they read, and the field\n * that says so.\n *\n * A closed table rather than a per-flow hook, because the set is small and the\n * rule for admitting one is exact: the field has to name a location the whole\n * call is relative to. `bash` runs in a directory; the four readers resolve\n * their subject against the workspace root. Everything else \u2014 an edit, a patch,\n * a web fetch, a memory write \u2014 either names no location or writes, and both\n * are refused above this module.\n *\n * `test` is deliberately absent. It answers this exact question already, with\n * `against: \"base\"`, and a second mechanism pointed at the same tree is a way\n * for two answers to disagree.\n */\nconst located: Readonly<Record<string, { readonly field: string; readonly kind: \"cwd\" | \"path\" }>> = {\n bash: { field: \"cwd\", kind: \"cwd\" },\n read: { field: \"path\", kind: \"path\" },\n ls: { field: \"path\", kind: \"path\" },\n grep: { field: \"root\", kind: \"path\" },\n glob: { field: \"root\", kind: \"path\" }\n}\n\n/**\n * Why one input could not be pointed at a checkpoint.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Relocation =\n | { readonly _tag: \"Relocated\"; readonly input: Schema.Json }\n | { readonly _tag: \"UnsupportedFlow\" }\n | { readonly _tag: \"AbsolutePath\"; readonly path: string }\n | { readonly _tag: \"OutsideTree\"; readonly path: string }\n\n/**\n * Resolves `.` and `..` inside a relative path, or answers `undefined` when the\n * path climbs out of whatever it would be joined under.\n *\n * This is the whole of the isolation the reader rule can enforce, and it is not\n * optional. Prefixing blindly turns `../../mod.py` into\n * `.flows-checkpoints/cp-1-0/../../mod.py`, which is a path back into the live\n * tree \u2014 so the cell would read the work it is trying to take a baseline\n * against, the journal would record that reading under the checkpoint it named,\n * and the call key folds the checkpoint in, so the live reading would replay as\n * a pinned one forever. A proof built on it is a proof of nothing, which is the\n * exact failure this module exists to abolish.\n */\nconst contained = (path: string): string | undefined => {\n const parts: Array<string> = []\n for (const segment of path.split(\"/\")) {\n if (segment === \"\" || segment === \".\") continue\n if (segment !== \"..\") {\n parts.push(segment)\n continue\n }\n if (parts.length === 0) return undefined\n parts.pop()\n }\n return parts.join(\"/\")\n}\n\n/**\n * The part of `declared` that names a place inside `root`, or `undefined` when\n * it names somewhere the checkpoint does not hold a copy of.\n *\n * A relative path is already workspace-relative. An absolute one is compared\n * against the root on the side that issued it \u2014 a container call names the\n * mount, a host call names this machine \u2014 because that is the only prefix the\n * store can strip without guessing.\n */\nconst within = (root: string, declared: string): string | undefined => {\n if (!declared.startsWith(\"/\")) return contained(declared)\n if (withoutTrailingSlash(declared) === root) return \"\"\n return declared.startsWith(`${root}/`) ? contained(declared.slice(root.length + 1)) : undefined\n}\n\n/**\n * Rewrites one call's input so the call runs against a materialized checkpoint.\n *\n * Returns the rewritten input, or the reason there is none. A `bash` call runs\n * in the checkpoint's directory \u2014 from the *guest* side when it names a\n * container, because that is the path the container will be given \u2014 and keeps\n * whatever subdirectory it asked for: a check declared in `tests/` runs in the\n * checkpoint's `tests/`. A working directory the checkpoint holds no copy of,\n * such as somewhere else on the machine, becomes the checkpoint's own top,\n * because a tree is all this can offer and there is no subpath in it to keep.\n *\n * A reader takes the checkpoint's workspace-relative directory as the prefix of\n * what it names, because these flows resolve their subject against the\n * workspace root and the checkpoint is a directory under it.\n *\n * Two paths are refused rather than rewritten, and both for the same reason \u2014\n * the host would otherwise hand back a reading of a tree the cell did not name.\n * An absolute path in these runs is a container path, and the host cannot know\n * which prefix of it names the tree. A relative path that climbs past the\n * checkpoint with `..` names the live tree, exactly the tree the reading was\n * taken to avoid.\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const relocate = (\n flow: string,\n input: Schema.Json,\n materialized: Materialized\n): Relocation => {\n const rule = located[flow]\n if (rule === undefined) return { _tag: \"UnsupportedFlow\" }\n const record = input !== null && typeof input === \"object\" && !Array.isArray(input)\n ? input as Record<string, Schema.Json>\n : {}\n const declared = record[rule.field]\n if (rule.kind === \"cwd\") {\n // A container call is given the path the container will resolve; a host\n // call is given the host's. `bash` chooses which by naming a container, so\n // this reads the same field it does.\n const containerised = typeof record[\"container\"] === \"string\" && record[\"container\"] !== \"\"\n const base = containerised ? materialized.guest : materialized.host\n const kept = typeof declared === \"string\" && declared !== \"\"\n ? within(containerised ? materialized.guestRoot : materialized.root, declared)\n : \"\"\n return {\n _tag: \"Relocated\",\n input: { ...record, cwd: kept === undefined || kept === \"\" ? base : `${base}/${kept}` }\n }\n }\n const relative = materialized.host.slice(withoutTrailingSlash(materialized.root).length + 1)\n if (declared === undefined) return { _tag: \"Relocated\", input: { ...record, [rule.field]: relative } }\n if (typeof declared !== \"string\") return { _tag: \"UnsupportedFlow\" }\n if (declared.startsWith(\"/\")) return { _tag: \"AbsolutePath\", path: declared }\n const kept = contained(declared)\n if (kept === undefined) return { _tag: \"OutsideTree\", path: declared }\n return { _tag: \"Relocated\", input: { ...record, [rule.field]: kept === \"\" ? relative : `${relative}/${kept}` } }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,mBAAqC;AAiBrC,MAAM,UAA+F;AAAA,EACnG,MAAM,EAAE,OAAO,OAAO,MAAM,MAAM;AAAA,EAClC,MAAM,EAAE,OAAO,QAAQ,MAAM,OAAO;AAAA,EACpC,IAAI,EAAE,OAAO,QAAQ,MAAM,OAAO;AAAA,EAClC,MAAM,EAAE,OAAO,QAAQ,MAAM,OAAO;AAAA,EACpC,MAAM,EAAE,OAAO,QAAQ,MAAM,OAAO;AACtC;AA2BA,MAAM,YAAY,CAAC,SAAqC;AACtD,QAAM,QAAuB,CAAC;AAC9B,aAAW,WAAW,KAAK,MAAM,GAAG,GAAG;AACrC,QAAI,YAAY,MAAM,YAAY,IAAK;AACvC,QAAI,YAAY,MAAM;AACpB,YAAM,KAAK,OAAO;AAClB;AAAA,IACF;AACA,QAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,UAAM,IAAI;AAAA,EACZ;AACA,SAAO,MAAM,KAAK,GAAG;AACvB;AAWA,MAAM,SAAS,CAAC,MAAc,aAAyC;AACrE,MAAI,CAAC,SAAS,WAAW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,MAAM,SAAS;AACrE,SAAO,EAAE,MAAM,aAAa,OAAO,EAAE,GAAG,QAAQ,CAAC,KAAK,KAAK,GAAG,SAAS,KAAK,WAAW,GAAG,QAAQ,IAAI,IAAI,GAAG,EAAE;AACjH;",
|
|
6
|
+
"names": ["kept"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The implementation seam for the ripgrep search contract.
|
|
3
|
+
*
|
|
4
|
+
* Both implementations answer the same normalized calls. `PortableSearch`
|
|
5
|
+
* performs the work in-process; `NativeSearch` drives the `rg` executable.
|
|
6
|
+
* Callers select an implementation by Layer and cannot observe which one was
|
|
7
|
+
* selected from the result.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
import { Context, Effect, Layer } from "effect";
|
|
12
|
+
import * as StdError from "./StdError.ts";
|
|
13
|
+
/**
|
|
14
|
+
* Normalized grep input shared by both implementations.
|
|
15
|
+
*
|
|
16
|
+
* @category models
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
export interface GrepInput {
|
|
20
|
+
readonly pattern: string;
|
|
21
|
+
readonly root: string;
|
|
22
|
+
readonly fixedStrings: boolean;
|
|
23
|
+
readonly ignoreCase: boolean;
|
|
24
|
+
readonly smartCase: boolean;
|
|
25
|
+
readonly globs: ReadonlyArray<string>;
|
|
26
|
+
readonly beforeContext: number;
|
|
27
|
+
readonly afterContext: number;
|
|
28
|
+
readonly maxCount?: number | undefined;
|
|
29
|
+
readonly filesWithMatches: boolean;
|
|
30
|
+
/** Opt out of root-scoped .gitignore rules; defaults to false. */
|
|
31
|
+
readonly noIgnore?: boolean | undefined;
|
|
32
|
+
readonly hidden: boolean;
|
|
33
|
+
readonly symbols: boolean;
|
|
34
|
+
readonly limit: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* One matching or context line, as a peer produces it before grouping.
|
|
38
|
+
*
|
|
39
|
+
* @category models
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
*/
|
|
42
|
+
export interface GrepLine {
|
|
43
|
+
readonly file: string;
|
|
44
|
+
readonly line: number;
|
|
45
|
+
readonly text: string;
|
|
46
|
+
readonly kind: "match" | "context";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One context line carried inside the match it belongs to.
|
|
50
|
+
*
|
|
51
|
+
* @category models
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
*/
|
|
54
|
+
export interface ContextLine {
|
|
55
|
+
readonly line: number;
|
|
56
|
+
readonly text: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The definition enclosing a hit, when the file's shape says so plainly.
|
|
60
|
+
*
|
|
61
|
+
* @category models
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
*/
|
|
64
|
+
export interface Symbol {
|
|
65
|
+
readonly kind: string;
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly startLine: number;
|
|
68
|
+
readonly endLine: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* One hit: the matching line, the context that belongs to it, and the
|
|
72
|
+
* definition it sits in.
|
|
73
|
+
*
|
|
74
|
+
* @category models
|
|
75
|
+
* @since 1.0.0
|
|
76
|
+
*/
|
|
77
|
+
export interface GrepMatch {
|
|
78
|
+
readonly file: string;
|
|
79
|
+
readonly line: number;
|
|
80
|
+
readonly text: string;
|
|
81
|
+
readonly before: ReadonlyArray<ContextLine>;
|
|
82
|
+
readonly after: ReadonlyArray<ContextLine>;
|
|
83
|
+
readonly symbol?: Symbol | undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Normalized grep output.
|
|
87
|
+
*
|
|
88
|
+
* @category models
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
*/
|
|
91
|
+
export interface GrepOutput {
|
|
92
|
+
readonly matches: ReadonlyArray<GrepMatch>;
|
|
93
|
+
readonly files: ReadonlyArray<string>;
|
|
94
|
+
readonly filesSearched: number;
|
|
95
|
+
readonly skippedBinary: number;
|
|
96
|
+
readonly truncated: boolean;
|
|
97
|
+
readonly notice?: string | undefined;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Normalized glob input.
|
|
101
|
+
*
|
|
102
|
+
* @category models
|
|
103
|
+
* @since 1.0.0
|
|
104
|
+
*/
|
|
105
|
+
export interface GlobInput {
|
|
106
|
+
readonly pattern: string;
|
|
107
|
+
readonly root: string;
|
|
108
|
+
/** Opt out of root-scoped .gitignore rules; defaults to false. */
|
|
109
|
+
readonly noIgnore?: boolean | undefined;
|
|
110
|
+
readonly hidden: boolean;
|
|
111
|
+
readonly limit: number;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Normalized glob output.
|
|
115
|
+
*
|
|
116
|
+
* @category models
|
|
117
|
+
* @since 1.0.0
|
|
118
|
+
*/
|
|
119
|
+
export interface GlobOutput {
|
|
120
|
+
readonly paths: ReadonlyArray<string>;
|
|
121
|
+
readonly total: number;
|
|
122
|
+
readonly truncated: boolean;
|
|
123
|
+
readonly notice?: string | undefined;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The one search contract implemented by native and portable peers.
|
|
127
|
+
*
|
|
128
|
+
* @category services
|
|
129
|
+
* @since 1.0.0
|
|
130
|
+
*/
|
|
131
|
+
export interface Search {
|
|
132
|
+
readonly grep: (input: GrepInput) => Effect.Effect<GrepOutput, StdError.StdError>;
|
|
133
|
+
readonly glob: (input: GlobInput) => Effect.Effect<GlobOutput, StdError.StdError>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The {@link Search} service tag.
|
|
137
|
+
*
|
|
138
|
+
* @category services
|
|
139
|
+
* @since 1.0.0
|
|
140
|
+
*/
|
|
141
|
+
export declare const Search: Context.Service<Search, Search>;
|
|
142
|
+
/**
|
|
143
|
+
* Builds a search service from its two operations.
|
|
144
|
+
*
|
|
145
|
+
* @category constructors
|
|
146
|
+
* @since 1.0.0
|
|
147
|
+
*/
|
|
148
|
+
export declare const make: (service: Search) => Search;
|
|
149
|
+
/**
|
|
150
|
+
* Builds an unavailable search service for compositions that deliberately omit search.
|
|
151
|
+
*
|
|
152
|
+
* @category constructors
|
|
153
|
+
* @since 1.0.0
|
|
154
|
+
*/
|
|
155
|
+
export declare const makeNoop: () => Search;
|
|
156
|
+
/**
|
|
157
|
+
* Provides {@link makeNoop}.
|
|
158
|
+
*
|
|
159
|
+
* @category layers
|
|
160
|
+
* @since 1.0.0
|
|
161
|
+
*/
|
|
162
|
+
export declare const layerNoop: Layer.Layer<Search>;
|
|
163
|
+
//# sourceMappingURL=Search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../src/Search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;IAClC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAA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