@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/src/Manifest.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in flow declarations and their separately supplied handlers.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as ApplyPatch from "./ApplyPatch.ts"
|
|
8
|
+
import * as Bash from "./Bash.ts"
|
|
9
|
+
import * as Edit from "./Edit.ts"
|
|
10
|
+
import * as Explore from "./Explore.ts"
|
|
11
|
+
import * as Fetch from "./Fetch.ts"
|
|
12
|
+
import * as Glob from "./Glob.ts"
|
|
13
|
+
import * as Grep from "./Grep.ts"
|
|
14
|
+
import * as HttpPost from "./HttpPost.ts"
|
|
15
|
+
import * as Ls from "./Ls.ts"
|
|
16
|
+
import * as Lsp from "./Lsp.ts"
|
|
17
|
+
import * as Read from "./Read.ts"
|
|
18
|
+
import * as ShellCommand from "./ShellCommand.ts"
|
|
19
|
+
import * as TestRun from "./TestRun.ts"
|
|
20
|
+
import * as UpdatePlan from "./UpdatePlan.ts"
|
|
21
|
+
import * as WebFetch from "./WebFetch.ts"
|
|
22
|
+
import * as WebSearch from "./WebSearch.ts"
|
|
23
|
+
import * as Write from "./Write.ts"
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Frozen name-to-declaration registry for every standard flow.
|
|
27
|
+
*
|
|
28
|
+
* @category registries
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
*/
|
|
31
|
+
export const flows = Object.freeze({
|
|
32
|
+
[Read.name]: Read.flow,
|
|
33
|
+
[Write.name]: Write.flow,
|
|
34
|
+
[Edit.name]: Edit.flow,
|
|
35
|
+
[Ls.name]: Ls.flow,
|
|
36
|
+
[Glob.name]: Glob.flow,
|
|
37
|
+
[Grep.name]: Grep.flow,
|
|
38
|
+
[Bash.name]: Bash.flow,
|
|
39
|
+
[TestRun.name]: TestRun.flow,
|
|
40
|
+
[ShellCommand.name]: ShellCommand.flow,
|
|
41
|
+
[ApplyPatch.name]: ApplyPatch.flow,
|
|
42
|
+
[UpdatePlan.name]: UpdatePlan.flow,
|
|
43
|
+
[Fetch.name]: Fetch.flow,
|
|
44
|
+
[HttpPost.name]: HttpPost.flow,
|
|
45
|
+
[Explore.name]: Explore.flow,
|
|
46
|
+
[WebFetch.name]: WebFetch.flow,
|
|
47
|
+
[WebSearch.name]: WebSearch.flow,
|
|
48
|
+
[Lsp.name]: Lsp.flow
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Frozen name-to-handler registry for executable standard flows.
|
|
53
|
+
*
|
|
54
|
+
* Explore is dynamic and therefore has no handler entry.
|
|
55
|
+
*
|
|
56
|
+
* @category registries
|
|
57
|
+
* @since 1.0.0
|
|
58
|
+
*/
|
|
59
|
+
export const handlers = Object.freeze({
|
|
60
|
+
[Read.name]: Read.run,
|
|
61
|
+
[Write.name]: Write.run,
|
|
62
|
+
[Edit.name]: Edit.run,
|
|
63
|
+
[Ls.name]: Ls.run,
|
|
64
|
+
[Glob.name]: Glob.run,
|
|
65
|
+
[Grep.name]: Grep.run,
|
|
66
|
+
[Bash.name]: Bash.run,
|
|
67
|
+
[TestRun.name]: TestRun.run,
|
|
68
|
+
[ShellCommand.name]: ShellCommand.run,
|
|
69
|
+
[ApplyPatch.name]: ApplyPatch.run,
|
|
70
|
+
[UpdatePlan.name]: UpdatePlan.run,
|
|
71
|
+
[Fetch.name]: Fetch.run,
|
|
72
|
+
[HttpPost.name]: HttpPost.run,
|
|
73
|
+
[WebFetch.name]: WebFetch.run,
|
|
74
|
+
[WebSearch.name]: WebSearch.run,
|
|
75
|
+
[Lsp.name]: Lsp.run
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Frozen name-to-narrowing registry: the entry point for `effectsFor`.
|
|
80
|
+
*
|
|
81
|
+
* Every flow declares a registry-time worst case in `flow.effects`, and every
|
|
82
|
+
* module also narrows that declaration for one decoded input. Without this map
|
|
83
|
+
* a host holding a flow name and a decoded input has no generic way to reach
|
|
84
|
+
* the narrowing, so it would have to serialize conflicts against the worst case
|
|
85
|
+
* for every call. Explore is included even though it has no handler entry: it
|
|
86
|
+
* is a declaration a seat can be offered, and its envelope narrows the same way.
|
|
87
|
+
*
|
|
88
|
+
* @category registries
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
*/
|
|
91
|
+
export const effectsFor = Object.freeze({
|
|
92
|
+
[Read.name]: Read.effectsFor,
|
|
93
|
+
[Write.name]: Write.effectsFor,
|
|
94
|
+
[Edit.name]: Edit.effectsFor,
|
|
95
|
+
[Ls.name]: Ls.effectsFor,
|
|
96
|
+
[Glob.name]: Glob.effectsFor,
|
|
97
|
+
[Grep.name]: Grep.effectsFor,
|
|
98
|
+
[Bash.name]: Bash.effectsFor,
|
|
99
|
+
[TestRun.name]: TestRun.effectsFor,
|
|
100
|
+
[ShellCommand.name]: ShellCommand.effectsFor,
|
|
101
|
+
[ApplyPatch.name]: ApplyPatch.effectsFor,
|
|
102
|
+
[UpdatePlan.name]: UpdatePlan.effectsFor,
|
|
103
|
+
[Fetch.name]: Fetch.effectsFor,
|
|
104
|
+
[HttpPost.name]: HttpPost.effectsFor,
|
|
105
|
+
[Explore.name]: Explore.effectsFor,
|
|
106
|
+
[WebFetch.name]: WebFetch.effectsFor,
|
|
107
|
+
[WebSearch.name]: WebSearch.effectsFor,
|
|
108
|
+
[Lsp.name]: Lsp.effectsFor
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Frozen standard flow names in registry order.
|
|
113
|
+
*
|
|
114
|
+
* @category metadata
|
|
115
|
+
* @since 1.0.0
|
|
116
|
+
*/
|
|
117
|
+
export const names = Object.freeze(
|
|
118
|
+
[
|
|
119
|
+
Read.name,
|
|
120
|
+
Write.name,
|
|
121
|
+
Edit.name,
|
|
122
|
+
Ls.name,
|
|
123
|
+
Glob.name,
|
|
124
|
+
Grep.name,
|
|
125
|
+
Bash.name,
|
|
126
|
+
TestRun.name,
|
|
127
|
+
ShellCommand.name,
|
|
128
|
+
ApplyPatch.name,
|
|
129
|
+
UpdatePlan.name,
|
|
130
|
+
Fetch.name,
|
|
131
|
+
HttpPost.name,
|
|
132
|
+
Explore.name,
|
|
133
|
+
WebFetch.name,
|
|
134
|
+
WebSearch.name,
|
|
135
|
+
Lsp.name
|
|
136
|
+
] as const
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Frozen names visible to a seat restricted to read-only flows.
|
|
141
|
+
*
|
|
142
|
+
* Seat policies consume this list instead of duplicating name checks.
|
|
143
|
+
*
|
|
144
|
+
* `websearch` is deliberately absent: its provider contract requires
|
|
145
|
+
* `net:post` authority, which is mutating under the kernel capability
|
|
146
|
+
* taxonomy, so it cannot ride in a read-only seat.
|
|
147
|
+
*
|
|
148
|
+
* @category visibility
|
|
149
|
+
* @since 1.0.0
|
|
150
|
+
*/
|
|
151
|
+
export const readOnly = Object.freeze(
|
|
152
|
+
[
|
|
153
|
+
Read.name,
|
|
154
|
+
Ls.name,
|
|
155
|
+
Glob.name,
|
|
156
|
+
Grep.name,
|
|
157
|
+
Fetch.name,
|
|
158
|
+
Explore.name,
|
|
159
|
+
WebFetch.name,
|
|
160
|
+
Lsp.name
|
|
161
|
+
] as const
|
|
162
|
+
)
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `rg`-process implementation of the ripgrep search contract.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type * as ChildProcessSpawner from "@smthrs/kernel/ChildProcessSpawner"
|
|
8
|
+
import * as Path from "@smthrs/kernel/Path"
|
|
9
|
+
import { type Context, Effect, Layer } from "effect"
|
|
10
|
+
import * as FileSystem from "effect/FileSystem"
|
|
11
|
+
import * as Exec from "./internal/Exec.ts"
|
|
12
|
+
import * as Grouping from "./internal/Grouping.ts"
|
|
13
|
+
import { notice, truncateBytes } from "./internal/Text.ts"
|
|
14
|
+
import * as Walk from "./internal/Walk.ts"
|
|
15
|
+
import * as Search from "./Search.ts"
|
|
16
|
+
import * as Contract from "./SearchContract.ts"
|
|
17
|
+
import * as StdError from "./StdError.ts"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Maximum bytes captured from either stream across one search operation.
|
|
21
|
+
*
|
|
22
|
+
* Native search refuses an overflow instead of truncating because a partial
|
|
23
|
+
* ripgrep stream could make it disagree with the portable peer. The 64 MiB
|
|
24
|
+
* bound is well above real repository listings: 400,000 paths occupy roughly
|
|
25
|
+
* 16 MiB in a typical `rg --files` stream.
|
|
26
|
+
*
|
|
27
|
+
* @category constants
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
export const MAX_CAPTURE_BYTES = 67_108_864
|
|
31
|
+
|
|
32
|
+
interface RgResult {
|
|
33
|
+
readonly stdout: string
|
|
34
|
+
readonly stderr: string
|
|
35
|
+
readonly exitCode: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const execute = (
|
|
39
|
+
cwd: string,
|
|
40
|
+
args: ReadonlyArray<string>,
|
|
41
|
+
environment: Readonly<Record<string, string>> | undefined
|
|
42
|
+
): Effect.Effect<RgResult, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner> =>
|
|
43
|
+
Exec.exec("rg", { args, cwd, env: environment, maxCaptureBytes: MAX_CAPTURE_BYTES, overflow: "refuse" }).pipe(
|
|
44
|
+
Effect.mapError((error) =>
|
|
45
|
+
new StdError.StdError({
|
|
46
|
+
code: error.code === "capture_overflow" ? "command_failed" : "provider_unavailable",
|
|
47
|
+
message: error.code === "capture_overflow"
|
|
48
|
+
? error.message
|
|
49
|
+
: "The native ripgrep implementation could not start rg"
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
// Only .gitignore within the requested root participates. Disable user config,
|
|
55
|
+
// parent/global rules and other ignore sources so the result is host independent.
|
|
56
|
+
const ignoreFlags = (noIgnore: boolean | undefined): ReadonlyArray<string> => [
|
|
57
|
+
"--no-config",
|
|
58
|
+
"--no-require-git",
|
|
59
|
+
"--no-ignore-global",
|
|
60
|
+
"--no-ignore-parent",
|
|
61
|
+
"--no-ignore-exclude",
|
|
62
|
+
"--no-ignore-dot",
|
|
63
|
+
...(noIgnore ? ["--no-ignore"] : [])
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Reports what `rg` rejected, or `undefined` when it produced an answer.
|
|
68
|
+
*
|
|
69
|
+
* Exit status 2 means only "an error occurred", and a walk hits those
|
|
70
|
+
* routinely: a dangling symlink, a symlink loop, a directory the process may
|
|
71
|
+
* not list. `--no-messages` suppresses exactly those, leaving stderr empty and
|
|
72
|
+
* the results on stdout complete for everything `rg` could reach — the same
|
|
73
|
+
* entries the in-process peer skips, so the peers still agree. A fatal error —
|
|
74
|
+
* an unparsable glob, a rejected expression, a killed process — always writes
|
|
75
|
+
* to stderr, which `--no-messages` does not touch. Stderr is therefore the
|
|
76
|
+
* discriminator, and the exit status alone is not.
|
|
77
|
+
*/
|
|
78
|
+
const rejection = (result: RgResult): string | undefined => {
|
|
79
|
+
const message = result.stderr.trim()
|
|
80
|
+
return result.exitCode > 1 && message.length > 0 ? message : undefined
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const nulSeparated = (stdout: string): ReadonlyArray<string> => stdout.split("\0").filter((value) => value.length > 0)
|
|
84
|
+
|
|
85
|
+
const preview = (line: string): string => {
|
|
86
|
+
const withoutTerminator = line.replace(/\r?\n$/, "")
|
|
87
|
+
const characters = Array.from(withoutTerminator)
|
|
88
|
+
return truncateBytes(characters.length > 500 ? characters.slice(0, 500).join("") : withoutTerminator, 500, {
|
|
89
|
+
keep: "head"
|
|
90
|
+
}).text
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const asRecord = (value: unknown): Record<string, unknown> | undefined =>
|
|
94
|
+
typeof value === "object" && value !== null ? value as Record<string, unknown> : undefined
|
|
95
|
+
|
|
96
|
+
const textAt = (record: Record<string, unknown> | undefined, key: string): string | undefined => {
|
|
97
|
+
const nested = asRecord(record?.[key])
|
|
98
|
+
return typeof nested?.text === "string" ? nested.text : undefined
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const malformedJson = (): StdError.StdError =>
|
|
102
|
+
new StdError.StdError({ code: "request_failed", message: "rg returned malformed JSON" })
|
|
103
|
+
|
|
104
|
+
// rg releases differ on some gitignore grammar (for example BOMs and
|
|
105
|
+
// unclosed character classes in 14 versus 15). Select paths through the same
|
|
106
|
+
// walk as portable, then name them explicitly to rg. This also prevents a
|
|
107
|
+
// positive caller glob from overriding ignore rules or scanning unrelated files.
|
|
108
|
+
const resolveRoot = (
|
|
109
|
+
input: Search.GrepInput | Search.GlobInput,
|
|
110
|
+
globs: ReadonlyArray<string>
|
|
111
|
+
): Effect.Effect<
|
|
112
|
+
{
|
|
113
|
+
readonly cwd: string
|
|
114
|
+
readonly targets: ReadonlyArray<string>
|
|
115
|
+
readonly explicitFile: boolean
|
|
116
|
+
readonly ignored: boolean
|
|
117
|
+
readonly absolute: (value: string) => string
|
|
118
|
+
},
|
|
119
|
+
StdError.StdError,
|
|
120
|
+
FileSystem.FileSystem | Path.Path
|
|
121
|
+
> =>
|
|
122
|
+
Effect.gen(function*() {
|
|
123
|
+
const fileSystem = yield* FileSystem.FileSystem
|
|
124
|
+
const path = yield* Path.Path
|
|
125
|
+
const included = (relative: string, basename: string) => Contract.includedByGlobs(globs, relative, basename)
|
|
126
|
+
const walked = yield* Walk.files(fileSystem, path, input.root, input.hidden, input.noIgnore, included)
|
|
127
|
+
const cwd = walked.explicitFile ? path.dirname(input.root) : input.root
|
|
128
|
+
const selected = walked.explicitFile ?
|
|
129
|
+
walked.files :
|
|
130
|
+
walked.files.filter((file) => included(Walk.relativeForPattern(path, input.root, file), path.basename(file)))
|
|
131
|
+
const links = walked.explicitFile ? [] : yield* Walk.symbolicLinks(fileSystem, selected)
|
|
132
|
+
return {
|
|
133
|
+
cwd,
|
|
134
|
+
targets: selected.filter((_, index) => links[index] !== true).map((file) => path.relative(cwd, file)),
|
|
135
|
+
explicitFile: walked.explicitFile,
|
|
136
|
+
ignored: walked.ignored,
|
|
137
|
+
absolute: (value: string) => path.normalize(path.join(cwd, value.replace(/^\.\//, "")))
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
// Stay well below OS argv limits, including on trees with long UTF-8 names.
|
|
142
|
+
// Only one batch per operation is live, and the aggregate capture keeps the
|
|
143
|
+
// same refusal bound as a single invocation.
|
|
144
|
+
const executeFiles = (
|
|
145
|
+
cwd: string,
|
|
146
|
+
args: ReadonlyArray<string>,
|
|
147
|
+
targets: ReadonlyArray<string>,
|
|
148
|
+
environment: Readonly<Record<string, string>> | undefined
|
|
149
|
+
): Effect.Effect<RgResult, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner> =>
|
|
150
|
+
Effect.gen(function*() {
|
|
151
|
+
if (targets.length === 0) {
|
|
152
|
+
return {
|
|
153
|
+
stdout: args.includes("--json")
|
|
154
|
+
? `${JSON.stringify({ type: "summary", data: { stats: { searches: 0 } } })}\n`
|
|
155
|
+
: "",
|
|
156
|
+
stderr: "",
|
|
157
|
+
exitCode: 0
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const encoder = new TextEncoder()
|
|
161
|
+
const batches: Array<Array<string>> = []
|
|
162
|
+
let batch: Array<string> = []
|
|
163
|
+
let size = 0
|
|
164
|
+
for (const target of targets) {
|
|
165
|
+
const bytes = encoder.encode(target).length + 1
|
|
166
|
+
if (batch.length > 0 && (batch.length >= 256 || size + bytes > 32_768)) {
|
|
167
|
+
batches.push(batch)
|
|
168
|
+
batch = []
|
|
169
|
+
size = 0
|
|
170
|
+
}
|
|
171
|
+
batch.push(target)
|
|
172
|
+
size += bytes
|
|
173
|
+
}
|
|
174
|
+
batches.push(batch)
|
|
175
|
+
let stdout = ""
|
|
176
|
+
let stderr = ""
|
|
177
|
+
let stdoutBytes = 0
|
|
178
|
+
let stderrBytes = 0
|
|
179
|
+
let exitCode = 0
|
|
180
|
+
for (const batch of batches) {
|
|
181
|
+
const result = yield* execute(cwd, [...args, ...batch], environment)
|
|
182
|
+
if (rejection(result) !== undefined) return result
|
|
183
|
+
stdoutBytes += encoder.encode(result.stdout).length
|
|
184
|
+
stderrBytes += encoder.encode(result.stderr).length
|
|
185
|
+
if (stdoutBytes > MAX_CAPTURE_BYTES || stderrBytes > MAX_CAPTURE_BYTES) {
|
|
186
|
+
return yield* Effect.fail(
|
|
187
|
+
new StdError.StdError({
|
|
188
|
+
code: "command_failed",
|
|
189
|
+
message: `rg ${
|
|
190
|
+
stdoutBytes > MAX_CAPTURE_BYTES ? "stdout" : "stderr"
|
|
191
|
+
} exceeded the ${MAX_CAPTURE_BYTES}-byte capture cap`
|
|
192
|
+
})
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
stdout += result.stdout
|
|
196
|
+
stderr += result.stderr
|
|
197
|
+
exitCode = Math.max(exitCode, result.exitCode)
|
|
198
|
+
}
|
|
199
|
+
return { stdout, stderr, exitCode }
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
const pathOrder = (left: Search.GrepLine, right: Search.GrepLine): number =>
|
|
203
|
+
left.file < right.file ? -1 : left.file > right.file ? 1 : left.line - right.line
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Holds `maxCount` to the per-file match budget the contract states.
|
|
207
|
+
*
|
|
208
|
+
* `rg` labels an after-context line as a `match` when that line matches too,
|
|
209
|
+
* so `--max-count 2 --after-context 1` over three consecutive matching lines
|
|
210
|
+
* prints three `match` rows — measured against ripgrep 14.1.1. The in-process
|
|
211
|
+
* peer stops counting at the budget and carries the surplus line as context,
|
|
212
|
+
* and the generated conformance run found the two peers answering that call
|
|
213
|
+
* differently on four seeds. The surplus rows are demoted rather than dropped,
|
|
214
|
+
* because the caller asked for that context and `rg` did print it. Rows arrive
|
|
215
|
+
* sorted by file and line, so counting in order is counting per file.
|
|
216
|
+
*/
|
|
217
|
+
const capMatches = (
|
|
218
|
+
lines: ReadonlyArray<Search.GrepLine>,
|
|
219
|
+
maxCount: number | undefined
|
|
220
|
+
): ReadonlyArray<Search.GrepLine> => {
|
|
221
|
+
if (maxCount === undefined) return lines
|
|
222
|
+
const counted = new Map<string, number>()
|
|
223
|
+
return lines.map((line) => {
|
|
224
|
+
if (line.kind !== "match") return line
|
|
225
|
+
const seen = counted.get(line.file) ?? 0
|
|
226
|
+
counted.set(line.file, seen + 1)
|
|
227
|
+
return seen < maxCount ? line : { ...line, kind: "context" as const }
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const grep = (
|
|
232
|
+
input: Search.GrepInput,
|
|
233
|
+
environment: Readonly<Record<string, string>> | undefined
|
|
234
|
+
): Effect.Effect<
|
|
235
|
+
Search.GrepOutput,
|
|
236
|
+
StdError.StdError,
|
|
237
|
+
FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner
|
|
238
|
+
> =>
|
|
239
|
+
Effect.gen(function*() {
|
|
240
|
+
const fileSystem = yield* FileSystem.FileSystem
|
|
241
|
+
const path = yield* Path.Path
|
|
242
|
+
const root = yield* resolveRoot(input, input.globs)
|
|
243
|
+
const args: Array<string> = [
|
|
244
|
+
"--json",
|
|
245
|
+
"--stats",
|
|
246
|
+
...ignoreFlags(input.noIgnore),
|
|
247
|
+
"--no-messages",
|
|
248
|
+
"--sort",
|
|
249
|
+
"path",
|
|
250
|
+
"--encoding=utf-8",
|
|
251
|
+
"--crlf"
|
|
252
|
+
]
|
|
253
|
+
if (input.hidden) args.push("--hidden")
|
|
254
|
+
if (input.fixedStrings) args.push("--fixed-strings")
|
|
255
|
+
// `rg` documents `--smart-case` as overriding `--ignore-case`, so passing
|
|
256
|
+
// both makes an uppercase pattern case-SENSITIVE. The in-process peer reads
|
|
257
|
+
// the pair the other way round — `ignoreCase || (smartCase && no uppercase)`
|
|
258
|
+
// — because an explicit request beats a heuristic. `Grep.run` refuses the
|
|
259
|
+
// combination outright, but a host binding `Search` directly never reaches
|
|
260
|
+
// that check, and the generated conformance run found the two peers
|
|
261
|
+
// answering seven seeds differently through it.
|
|
262
|
+
if (input.ignoreCase) args.push("--ignore-case")
|
|
263
|
+
else if (input.smartCase) args.push("--smart-case")
|
|
264
|
+
if (input.beforeContext > 0) args.push("--before-context", String(input.beforeContext))
|
|
265
|
+
if (input.afterContext > 0) args.push("--after-context", String(input.afterContext))
|
|
266
|
+
if (input.maxCount !== undefined) args.push("--max-count", String(input.maxCount))
|
|
267
|
+
args.push("--", input.pattern)
|
|
268
|
+
|
|
269
|
+
const binaryArgs: Array<string> = [
|
|
270
|
+
"--files-with-matches",
|
|
271
|
+
"--text",
|
|
272
|
+
"--null",
|
|
273
|
+
...ignoreFlags(input.noIgnore),
|
|
274
|
+
"--no-messages",
|
|
275
|
+
"--sort",
|
|
276
|
+
"path"
|
|
277
|
+
]
|
|
278
|
+
if (input.hidden) binaryArgs.push("--hidden")
|
|
279
|
+
binaryArgs.push("--", "\\x00")
|
|
280
|
+
|
|
281
|
+
const [result, binaryResult] = yield* Effect.all(
|
|
282
|
+
[
|
|
283
|
+
executeFiles(root.cwd, args, root.targets, environment),
|
|
284
|
+
executeFiles(root.cwd, binaryArgs, root.targets, environment)
|
|
285
|
+
],
|
|
286
|
+
{ concurrency: "unbounded" }
|
|
287
|
+
)
|
|
288
|
+
for (const outcome of [result, binaryResult]) {
|
|
289
|
+
const message = rejection(outcome)
|
|
290
|
+
if (message !== undefined) {
|
|
291
|
+
return yield* Effect.fail(new StdError.StdError({ code: "request_failed", message }))
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const binaryFiles = new Set(nulSeparated(binaryResult.stdout).map(root.absolute))
|
|
295
|
+
if (root.explicitFile && binaryFiles.size > 0) {
|
|
296
|
+
return yield* Effect.fail(
|
|
297
|
+
new StdError.StdError({
|
|
298
|
+
code: "binary_file",
|
|
299
|
+
message: `Cannot search binary file: ${input.root}`,
|
|
300
|
+
path: input.root
|
|
301
|
+
})
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const lines: Array<Search.GrepLine> = []
|
|
306
|
+
const files = new Set<string>()
|
|
307
|
+
let sawSummary = false
|
|
308
|
+
for (const encoded of result.stdout.split("\n")) {
|
|
309
|
+
if (encoded.length === 0) continue
|
|
310
|
+
let event: Record<string, unknown>
|
|
311
|
+
try {
|
|
312
|
+
const decoded = JSON.parse(encoded) as unknown
|
|
313
|
+
const record = asRecord(decoded)
|
|
314
|
+
if (record === undefined) return yield* Effect.fail(malformedJson())
|
|
315
|
+
event = record
|
|
316
|
+
} catch {
|
|
317
|
+
return yield* Effect.fail(malformedJson())
|
|
318
|
+
}
|
|
319
|
+
const type = event.type
|
|
320
|
+
const data = asRecord(event.data)
|
|
321
|
+
if (type === "match" || type === "context") {
|
|
322
|
+
const file = textAt(data, "path")
|
|
323
|
+
const text = textAt(data, "lines")
|
|
324
|
+
const line = data?.line_number
|
|
325
|
+
if (file === undefined || text === undefined || typeof line !== "number") {
|
|
326
|
+
return yield* Effect.fail(malformedJson())
|
|
327
|
+
}
|
|
328
|
+
const absolute = root.absolute(file)
|
|
329
|
+
files.add(absolute)
|
|
330
|
+
lines.push({ file: absolute, line, text: preview(text), kind: type })
|
|
331
|
+
} else if (type === "begin") {
|
|
332
|
+
if (textAt(data, "path") === undefined) return yield* Effect.fail(malformedJson())
|
|
333
|
+
} else if (type === "end") {
|
|
334
|
+
if (
|
|
335
|
+
textAt(data, "path") === undefined ||
|
|
336
|
+
(data?.binary_offset !== null && typeof data?.binary_offset !== "number")
|
|
337
|
+
) return yield* Effect.fail(malformedJson())
|
|
338
|
+
} else if (type === "summary") {
|
|
339
|
+
const stats = asRecord(data?.stats)
|
|
340
|
+
if (typeof stats?.searches !== "number") return yield* Effect.fail(malformedJson())
|
|
341
|
+
sawSummary = true
|
|
342
|
+
} else return yield* Effect.fail(malformedJson())
|
|
343
|
+
}
|
|
344
|
+
if (!sawSummary) return yield* Effect.fail(malformedJson())
|
|
345
|
+
for (const file of binaryFiles) files.delete(file)
|
|
346
|
+
const visibleLines = capMatches(
|
|
347
|
+
lines.filter((line) => !binaryFiles.has(line.file)).sort(pathOrder),
|
|
348
|
+
input.maxCount
|
|
349
|
+
)
|
|
350
|
+
const grouped = input.filesWithMatches ? [] : Grouping.group(visibleLines)
|
|
351
|
+
const entries = input.filesWithMatches ? [...files].sort() : grouped
|
|
352
|
+
const truncated = entries.length > input.limit
|
|
353
|
+
const shown = grouped.slice(0, input.limit)
|
|
354
|
+
// `rg` reports lines, not files, so the enclosing definition costs one read
|
|
355
|
+
// of each file whose hits survived the limit — never one per file searched.
|
|
356
|
+
const contents = new Map<string, ReadonlyArray<string>>()
|
|
357
|
+
if (input.symbols) {
|
|
358
|
+
for (const file of new Set(shown.map((match) => match.file))) {
|
|
359
|
+
const bytes = yield* Effect.orElseSucceed(fileSystem.readFile(file), () => undefined)
|
|
360
|
+
if (bytes !== undefined) contents.set(file, Grouping.sourceLines(new TextDecoder().decode(bytes)))
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const unsatisfiable = entries.length > 0 ? undefined : yield* Contract.unsatisfiableNotice({
|
|
364
|
+
fileSystem,
|
|
365
|
+
path,
|
|
366
|
+
root: input.root,
|
|
367
|
+
globs: input.globs,
|
|
368
|
+
hidden: input.hidden,
|
|
369
|
+
noIgnore: input.noIgnore,
|
|
370
|
+
ignored: root.ignored
|
|
371
|
+
})
|
|
372
|
+
return {
|
|
373
|
+
matches: Grouping.annotate(shown, contents),
|
|
374
|
+
files: input.filesWithMatches ? [...files].sort().slice(0, input.limit) : [],
|
|
375
|
+
filesSearched: root.targets.length,
|
|
376
|
+
skippedBinary: binaryFiles.size,
|
|
377
|
+
truncated,
|
|
378
|
+
...(truncated
|
|
379
|
+
? { notice: notice(input.filesWithMatches ? "files" : "matches", input.limit, entries.length) }
|
|
380
|
+
: {}),
|
|
381
|
+
...(unsatisfiable === undefined ? {} : { notice: unsatisfiable })
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
const glob = (
|
|
386
|
+
input: Search.GlobInput,
|
|
387
|
+
environment: Readonly<Record<string, string>> | undefined
|
|
388
|
+
): Effect.Effect<
|
|
389
|
+
Search.GlobOutput,
|
|
390
|
+
StdError.StdError,
|
|
391
|
+
FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner
|
|
392
|
+
> =>
|
|
393
|
+
Effect.gen(function*() {
|
|
394
|
+
const fileSystem = yield* FileSystem.FileSystem
|
|
395
|
+
const path = yield* Path.Path
|
|
396
|
+
const root = yield* resolveRoot(input, [input.pattern])
|
|
397
|
+
const args: Array<string> = ["--files", "--null", ...ignoreFlags(input.noIgnore), "--no-messages", "--sort", "path"]
|
|
398
|
+
if (input.hidden) args.push("--hidden")
|
|
399
|
+
args.push("--")
|
|
400
|
+
const result = yield* executeFiles(root.cwd, args, root.targets, environment)
|
|
401
|
+
const rejected = rejection(result)
|
|
402
|
+
if (rejected !== undefined) {
|
|
403
|
+
return yield* Effect.fail(new StdError.StdError({ code: "invalid_pattern", message: rejected }))
|
|
404
|
+
}
|
|
405
|
+
const paths = nulSeparated(result.stdout).map(root.absolute).filter((file) =>
|
|
406
|
+
root.explicitFile ||
|
|
407
|
+
Contract.includedByGlobs([input.pattern], Walk.relativeForPattern(path, input.root, file), path.basename(file))
|
|
408
|
+
).sort()
|
|
409
|
+
const shown = paths.slice(0, input.limit)
|
|
410
|
+
const unsatisfiable = paths.length > 0 ? undefined : yield* Contract.unsatisfiableNotice({
|
|
411
|
+
fileSystem,
|
|
412
|
+
path,
|
|
413
|
+
root: input.root,
|
|
414
|
+
globs: [input.pattern],
|
|
415
|
+
hidden: input.hidden,
|
|
416
|
+
noIgnore: input.noIgnore,
|
|
417
|
+
ignored: root.ignored
|
|
418
|
+
})
|
|
419
|
+
return {
|
|
420
|
+
paths: shown,
|
|
421
|
+
total: paths.length,
|
|
422
|
+
truncated: paths.length > input.limit,
|
|
423
|
+
...(paths.length > input.limit ? { notice: notice("entries", shown.length, paths.length) } : {}),
|
|
424
|
+
...(unsatisfiable === undefined ? {} : { notice: unsatisfiable })
|
|
425
|
+
}
|
|
426
|
+
})
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Captures filesystem, path and process services in the native peer.
|
|
430
|
+
* Optional environment declarations overlay the host child-process allowlist.
|
|
431
|
+
*
|
|
432
|
+
* @category constructors
|
|
433
|
+
* @since 1.0.0
|
|
434
|
+
*/
|
|
435
|
+
export const make = (
|
|
436
|
+
services: Context.Context<FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>,
|
|
437
|
+
environment?: Readonly<Record<string, string>>
|
|
438
|
+
): Search.Search =>
|
|
439
|
+
Search.make({
|
|
440
|
+
grep: (input) => Effect.provide(grep(input, environment), services),
|
|
441
|
+
glob: (input) => Effect.provide(glob(input, environment), services)
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Provides the `rg`-driven peer.
|
|
446
|
+
*
|
|
447
|
+
* @category layers
|
|
448
|
+
* @since 1.0.0
|
|
449
|
+
*/
|
|
450
|
+
export const layer: Layer.Layer<
|
|
451
|
+
Search.Search,
|
|
452
|
+
never,
|
|
453
|
+
FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner
|
|
454
|
+
> = Layer.effect(
|
|
455
|
+
Search.Search,
|
|
456
|
+
Effect.map(Effect.context<FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>(), make)
|
|
457
|
+
)
|