@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Walk.d.ts","sourceRoot":"","sources":["../../../src/internal/Walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,KAAK,UAAU,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAK/C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAwC,CAAA;AAa3F;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,MAAM,EAAE,IAAI,MAAM,KAAG,MAG9E,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACxB,YAAY,UAAU,CAAC,UAAU,EACjC,YAAY,aAAa,CAAC,MAAM,CAAC,KAChC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAKpC,CAAA;AAEH;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,GAChB,YAAY,UAAU,CAAC,UAAU,EACjC,MAAM,IAAI,CAAC,IAAI,EACf,MAAM,MAAM,EACZ,QAAQ,OAAO,EACf,kBAAgB,EAChB,WAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAoB,KACrE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAmEtC,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], 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 Walk_exports = {};
|
|
30
|
+
__export(Walk_exports, {
|
|
31
|
+
files: () => files,
|
|
32
|
+
relativeForPattern: () => relativeForPattern,
|
|
33
|
+
skippedDirectories: () => skippedDirectories,
|
|
34
|
+
symbolicLinks: () => symbolicLinks
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(Walk_exports);
|
|
37
|
+
var import_effect = require("effect");
|
|
38
|
+
var Ignore = __toESM(require("./Ignore.js"), 1);
|
|
39
|
+
var Prune = __toESM(require("./Prune.js"), 1);
|
|
40
|
+
var import_SearchContract = require("./SearchContract.js");
|
|
41
|
+
const skippedDirectories = new Set(Prune.repositoryDirectories);
|
|
42
|
+
const concurrency = 16;
|
|
43
|
+
const relativeForPattern = (path, from, to) => {
|
|
44
|
+
const relative = path.relative(from, to);
|
|
45
|
+
return path.sep === "\\" ? relative.replaceAll("\\", "/") : relative;
|
|
46
|
+
};
|
|
47
|
+
const symbolicLinks = (fileSystem, candidates) => import_effect.Effect.forEach(
|
|
48
|
+
candidates,
|
|
49
|
+
(candidate) => fileSystem.readLink(candidate).pipe(import_effect.Effect.as(true), import_effect.Effect.orElseSucceed(() => false)),
|
|
50
|
+
{ concurrency }
|
|
51
|
+
);
|
|
52
|
+
const files = (fileSystem, path, root, hidden, noIgnore = false, included = () => true) => import_effect.Effect.gen(function* () {
|
|
53
|
+
const info = yield* fileSystem.stat(root).pipe(import_effect.Effect.mapError((error) => (0, import_SearchContract.rootFailure)(root, error)));
|
|
54
|
+
if (info.type === "File") return { explicitFile: true, files: [path.normalize(root)], ignored: false };
|
|
55
|
+
const files2 = [];
|
|
56
|
+
let excluded = false;
|
|
57
|
+
const directories = [{
|
|
58
|
+
directory: root,
|
|
59
|
+
scopes: []
|
|
60
|
+
}];
|
|
61
|
+
while (directories.length > 0) {
|
|
62
|
+
const next = directories.pop();
|
|
63
|
+
const { directory } = next;
|
|
64
|
+
let scopes = next.scopes;
|
|
65
|
+
const children = yield* fileSystem.readDirectory(directory).pipe(
|
|
66
|
+
import_effect.Effect.catch(
|
|
67
|
+
(error) => directory === root ? import_effect.Effect.fail((0, import_SearchContract.rootFailure)(directory, error)) : import_effect.Effect.succeed([])
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
if (!noIgnore && children.includes(".gitignore")) {
|
|
71
|
+
const content = yield* fileSystem.readFileString(path.join(directory, ".gitignore")).pipe(
|
|
72
|
+
import_effect.Effect.orElseSucceed(() => "")
|
|
73
|
+
);
|
|
74
|
+
const scope = Ignore.parse(directory, content);
|
|
75
|
+
if (scope.rules.length > 0) scopes = [...scopes, scope];
|
|
76
|
+
}
|
|
77
|
+
const candidates = children.filter((child) => !skippedDirectories.has(child) && (hidden || !child.startsWith("."))).map((child) => path.join(directory, child));
|
|
78
|
+
const entries = yield* import_effect.Effect.forEach(candidates, (candidate) => fileSystem.stat(candidate).pipe(
|
|
79
|
+
import_effect.Effect.map((candidateInfo) => ({
|
|
80
|
+
candidate,
|
|
81
|
+
type: candidateInfo.type
|
|
82
|
+
})),
|
|
83
|
+
import_effect.Effect.orElseSucceed(() => ({ candidate, type: void 0 }))
|
|
84
|
+
), { concurrency });
|
|
85
|
+
const nested = [];
|
|
86
|
+
for (const entry of entries) {
|
|
87
|
+
if (entry.type !== void 0 && Ignore.ignored(
|
|
88
|
+
scopes,
|
|
89
|
+
entry.candidate,
|
|
90
|
+
path.basename(entry.candidate),
|
|
91
|
+
entry.type === "Directory",
|
|
92
|
+
(from, to) => relativeForPattern(path, from, to)
|
|
93
|
+
)) {
|
|
94
|
+
if (entry.type === "Directory" || included(relativeForPattern(path, root, entry.candidate), path.basename(entry.candidate))) excluded = true;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (entry.type === "Directory") nested.push(entry.candidate);
|
|
98
|
+
else if (entry.type === "File") files2.push(path.normalize(entry.candidate));
|
|
99
|
+
}
|
|
100
|
+
const links = yield* symbolicLinks(fileSystem, nested);
|
|
101
|
+
for (let index = 0; index < nested.length; index++) {
|
|
102
|
+
const candidate = nested[index];
|
|
103
|
+
if (links[index] !== true) directories.push({ directory: candidate, scopes });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { explicitFile: false, files: files2.sort(), ignored: excluded };
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=Walk.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/Walk.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The directory names a repository walk never descends into.\n *\n * `grep` and `glob` walk with the kernel filesystem, and every entry costs a\n * guarded stat. A walk rooted at \".\" that descends into `.git` visits tens of\n * thousands of object files no search wants: one such `grep` held a benchmark\n * frame for its entire fifteen-minute ceiling. The skip set is the same\n * convention ripgrep ships \u2014 version control, dependency trees, and caches \u2014\n * and an explicit root inside a skipped directory still walks, because\n * skipping applies to descent, never to what the caller named.\n *\n * @since 1.0.0\n */\n\nimport type * as Path from \"@smthrs/kernel/Path\"\nimport { Effect } from \"effect\"\nimport type * as FileSystem from \"effect/FileSystem\"\nimport type * as StdError from \"../StdError.ts\"\nimport * as Ignore from \"./Ignore.ts\"\nimport * as Prune from \"./Prune.ts\"\nimport { rootFailure } from \"./SearchContract.ts\"\n\n/**\n * Directory basenames excluded from recursive descent.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const skippedDirectories: ReadonlySet<string> = new Set(Prune.repositoryDirectories)\n\n/**\n * How many filesystem questions one directory level asks at a time.\n *\n * A metadata call through the layer costs far more in fiber scheduling than in\n * kernel time, so asking one entry at a time is what makes a walk slow: the\n * same probe measured 28.8 \u00B5s sequentially and 6.0 \u00B5s at this width on the\n * SWE-bench pytest tree. The bound keeps the file-descriptor and thread-pool\n * pressure of a wide directory predictable.\n */\nconst concurrency = 16\n\n/**\n * Separates pattern path segments with slashes while preserving POSIX filenames.\n *\n * @private\n * @since 1.0.0\n */\nexport const relativeForPattern = (path: Path.Path, from: string, to: string): string => {\n const relative = path.relative(from, to)\n return path.sep === \"\\\\\" ? relative.replaceAll(\"\\\\\", \"/\") : relative\n}\n\n/**\n * Answers whether each path is a symbolic link, which neither peer follows.\n *\n * `FileSystem.stat` resolves links, so the only probe available is `readLink`,\n * and every probe is one more call in a loop that already makes one per entry.\n * The walk therefore probes directories, where following a link would duplicate\n * a subtree or loop forever, and the callers probe the far smaller set of files\n * they are about to report \u2014 batched, never one at a time.\n *\n * @private\n * @since 1.0.0\n */\nexport const symbolicLinks = (\n fileSystem: FileSystem.FileSystem,\n candidates: ReadonlyArray<string>\n): Effect.Effect<ReadonlyArray<boolean>> =>\n Effect.forEach(\n candidates,\n (candidate) => fileSystem.readLink(candidate).pipe(Effect.as(true), Effect.orElseSucceed(() => false)),\n { concurrency }\n )\n\n/**\n * One walk: admitted files, explicit-root status, and ignore exclusions.\n *\n * @private\n * @since 1.0.0\n */\nexport interface Walked {\n readonly ignored: boolean\n readonly explicitFile: boolean\n readonly files: ReadonlyArray<string>\n}\n\n/**\n * Lists the files a search under `root` reaches.\n *\n * Only the root the caller named is allowed to fail the walk. Every entry\n * below it that the process cannot inspect \u2014 a dangling symlink, a symlink\n * loop, a directory it may not list \u2014 is skipped and the walk continues, which\n * is what `rg --no-messages` does with the same tree. Turning one of those into\n * a typed failure would make a whole repository unsearchable because of one\n * link, and would answer differently from the native peer. Only .gitignore\n * files within this root are read; ignored directories are never descended.\n * `included` narrows the empty-result diagnostic without changing descent.\n *\n * @private\n * @since 1.0.0\n */\nexport const files = (\n fileSystem: FileSystem.FileSystem,\n path: Path.Path,\n root: string,\n hidden: boolean,\n noIgnore = false,\n included: (relative: string, basename: string) => boolean = () => true\n): Effect.Effect<Walked, StdError.StdError> =>\n Effect.gen(function*() {\n const info = yield* fileSystem.stat(root).pipe(Effect.mapError((error) => rootFailure(root, error)))\n if (info.type === \"File\") return { explicitFile: true, files: [path.normalize(root)], ignored: false }\n const files: Array<string> = []\n let excluded = false\n const directories: Array<{ directory: string; scopes: ReadonlyArray<Ignore.Scope> }> = [{\n directory: root,\n scopes: []\n }]\n while (directories.length > 0) {\n const next = directories.pop()!\n const { directory } = next\n let scopes = next.scopes\n const children: ReadonlyArray<string> = yield* fileSystem.readDirectory(directory).pipe(\n Effect.catch((error) =>\n directory === root\n ? Effect.fail(rootFailure(directory, error))\n : Effect.succeed<ReadonlyArray<string>>([])\n )\n )\n if (!noIgnore && children.includes(\".gitignore\")) {\n const content = yield* fileSystem.readFileString(path.join(directory, \".gitignore\")).pipe(\n Effect.orElseSucceed(() => \"\")\n )\n const scope = Ignore.parse(directory, content)\n if (scope.rules.length > 0) scopes = [...scopes, scope]\n }\n const candidates = children\n .filter((child) => !skippedDirectories.has(child) && (hidden || !child.startsWith(\".\")))\n .map((child) => path.join(directory, child))\n const entries = yield* Effect.forEach(candidates, (candidate) =>\n fileSystem.stat(candidate).pipe(\n Effect.map((candidateInfo): { readonly candidate: string; readonly type: string | undefined } => ({\n candidate,\n type: candidateInfo.type\n })),\n Effect.orElseSucceed(() => ({ candidate, type: undefined }))\n ), { concurrency })\n const nested: Array<string> = []\n for (const entry of entries) {\n if (\n entry.type !== undefined &&\n Ignore.ignored(\n scopes,\n entry.candidate,\n path.basename(entry.candidate),\n entry.type === \"Directory\",\n (from, to) => relativeForPattern(path, from, to)\n )\n ) {\n if (\n entry.type === \"Directory\" ||\n included(relativeForPattern(path, root, entry.candidate), path.basename(entry.candidate))\n ) excluded = true\n continue\n }\n if (entry.type === \"Directory\") nested.push(entry.candidate)\n else if (entry.type === \"File\") files.push(path.normalize(entry.candidate))\n }\n const links = yield* symbolicLinks(fileSystem, nested)\n for (let index = 0; index < nested.length; index++) {\n const candidate = nested[index]!\n if (links[index] !== true) directories.push({ directory: candidate, scopes })\n }\n }\n return { explicitFile: false, files: files.sort(), ignored: excluded }\n })\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,oBAAuB;AAGvB,aAAwB;AACxB,YAAuB;AACvB,4BAA4B;AAQrB,MAAM,qBAA0C,IAAI,IAAI,MAAM,qBAAqB;AAW1F,MAAM,cAAc;AAQb,MAAM,qBAAqB,CAAC,MAAiB,MAAc,OAAuB;AACvF,QAAM,WAAW,KAAK,SAAS,MAAM,EAAE;AACvC,SAAO,KAAK,QAAQ,OAAO,SAAS,WAAW,MAAM,GAAG,IAAI;AAC9D;AAcO,MAAM,gBAAgB,CAC3B,YACA,eAEA,qBAAO;AAAA,EACL;AAAA,EACA,CAAC,cAAc,WAAW,SAAS,SAAS,EAAE,KAAK,qBAAO,GAAG,IAAI,GAAG,qBAAO,cAAc,MAAM,KAAK,CAAC;AAAA,EACrG,EAAE,YAAY;AAChB;AA6BK,MAAM,QAAQ,CACnB,YACA,MACA,MACA,QACA,WAAW,OACX,WAA4D,MAAM,SAElE,qBAAO,IAAI,aAAY;AACrB,QAAM,OAAO,OAAO,WAAW,KAAK,IAAI,EAAE,KAAK,qBAAO,SAAS,CAAC,cAAU,mCAAY,MAAM,KAAK,CAAC,CAAC;AACnG,MAAI,KAAK,SAAS,OAAQ,QAAO,EAAE,cAAc,MAAM,OAAO,CAAC,KAAK,UAAU,IAAI,CAAC,GAAG,SAAS,MAAM;AACrG,QAAMA,SAAuB,CAAC;AAC9B,MAAI,WAAW;AACf,QAAM,cAAiF,CAAC;AAAA,IACtF,WAAW;AAAA,IACX,QAAQ,CAAC;AAAA,EACX,CAAC;AACD,SAAO,YAAY,SAAS,GAAG;AAC7B,UAAM,OAAO,YAAY,IAAI;AAC7B,UAAM,EAAE,UAAU,IAAI;AACtB,QAAI,SAAS,KAAK;AAClB,UAAM,WAAkC,OAAO,WAAW,cAAc,SAAS,EAAE;AAAA,MACjF,qBAAO;AAAA,QAAM,CAAC,UACZ,cAAc,OACV,qBAAO,SAAK,mCAAY,WAAW,KAAK,CAAC,IACzC,qBAAO,QAA+B,CAAC,CAAC;AAAA,MAC9C;AAAA,IACF;AACA,QAAI,CAAC,YAAY,SAAS,SAAS,YAAY,GAAG;AAChD,YAAM,UAAU,OAAO,WAAW,eAAe,KAAK,KAAK,WAAW,YAAY,CAAC,EAAE;AAAA,QACnF,qBAAO,cAAc,MAAM,EAAE;AAAA,MAC/B;AACA,YAAM,QAAQ,OAAO,MAAM,WAAW,OAAO;AAC7C,UAAI,MAAM,MAAM,SAAS,EAAG,UAAS,CAAC,GAAG,QAAQ,KAAK;AAAA,IACxD;AACA,UAAM,aAAa,SAChB,OAAO,CAAC,UAAU,CAAC,mBAAmB,IAAI,KAAK,MAAM,UAAU,CAAC,MAAM,WAAW,GAAG,EAAE,EACtF,IAAI,CAAC,UAAU,KAAK,KAAK,WAAW,KAAK,CAAC;AAC7C,UAAM,UAAU,OAAO,qBAAO,QAAQ,YAAY,CAAC,cACjD,WAAW,KAAK,SAAS,EAAE;AAAA,MACzB,qBAAO,IAAI,CAAC,mBAAsF;AAAA,QAChG;AAAA,QACA,MAAM,cAAc;AAAA,MACtB,EAAE;AAAA,MACF,qBAAO,cAAc,OAAO,EAAE,WAAW,MAAM,OAAU,EAAE;AAAA,IAC7D,GAAG,EAAE,YAAY,CAAC;AACpB,UAAM,SAAwB,CAAC;AAC/B,eAAW,SAAS,SAAS;AAC3B,UACE,MAAM,SAAS,UACf,OAAO;AAAA,QACL;AAAA,QACA,MAAM;AAAA,QACN,KAAK,SAAS,MAAM,SAAS;AAAA,QAC7B,MAAM,SAAS;AAAA,QACf,CAAC,MAAM,OAAO,mBAAmB,MAAM,MAAM,EAAE;AAAA,MACjD,GACA;AACA,YACE,MAAM,SAAS,eACf,SAAS,mBAAmB,MAAM,MAAM,MAAM,SAAS,GAAG,KAAK,SAAS,MAAM,SAAS,CAAC,EACxF,YAAW;AACb;AAAA,MACF;AACA,UAAI,MAAM,SAAS,YAAa,QAAO,KAAK,MAAM,SAAS;AAAA,eAClD,MAAM,SAAS,OAAQ,CAAAA,OAAM,KAAK,KAAK,UAAU,MAAM,SAAS,CAAC;AAAA,IAC5E;AACA,UAAM,QAAQ,OAAO,cAAc,YAAY,MAAM;AACrD,aAAS,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;AAClD,YAAM,YAAY,OAAO,KAAK;AAC9B,UAAI,MAAM,KAAK,MAAM,KAAM,aAAY,KAAK,EAAE,WAAW,WAAW,OAAO,CAAC;AAAA,IAC9E;AAAA,EACF;AACA,SAAO,EAAE,cAAc,OAAO,OAAOA,OAAM,KAAK,GAAG,SAAS,SAAS;AACvE,CAAC;",
|
|
6
|
+
"names": ["files"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* apply_patch flow declaration and portable handler.
|
|
3
|
+
*
|
|
4
|
+
* A Codex CLI clone: the V4A patch grammar (`*** Begin Patch` /
|
|
5
|
+
* `*** Add File:` / `*** Update File:` / `*** Delete File:` /
|
|
6
|
+
* `*** End Patch`), the fuzzy context-matching applier, and Codex's error
|
|
7
|
+
* and summary text, expressed as a flow over the kernel filesystem.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as FileSystem from "effect/FileSystem";
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
|
+
import * as StdError from "./StdError.ts";
|
|
15
|
+
/**
|
|
16
|
+
* Registry name for the apply_patch flow. Matches the Codex CLI tool name.
|
|
17
|
+
*
|
|
18
|
+
* @category identifiers
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
*/
|
|
21
|
+
export declare const name = "apply_patch";
|
|
22
|
+
/**
|
|
23
|
+
* Model-facing description of the apply_patch flow. Matches the Codex CLI
|
|
24
|
+
* freeform tool description.
|
|
25
|
+
*
|
|
26
|
+
* @category descriptions
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
*/
|
|
29
|
+
export declare const description = "The `apply_patch` tool can be used to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.";
|
|
30
|
+
/**
|
|
31
|
+
* Input schema for the apply_patch flow.
|
|
32
|
+
*
|
|
33
|
+
* Codex delivers the patch as freeform text; the JSON function fallback uses
|
|
34
|
+
* a single `input` field, which is the shape cloned here.
|
|
35
|
+
*
|
|
36
|
+
* @category schemas
|
|
37
|
+
* @since 1.0.0
|
|
38
|
+
*/
|
|
39
|
+
export declare const Input: Schema.Struct<{
|
|
40
|
+
readonly input: Schema.String;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Decoded input accepted by the `apply_patch` flow.
|
|
44
|
+
*
|
|
45
|
+
* @category models
|
|
46
|
+
* @since 1.0.0
|
|
47
|
+
*/
|
|
48
|
+
export type Input = typeof Input.Type;
|
|
49
|
+
/**
|
|
50
|
+
* Output schema for the apply_patch flow.
|
|
51
|
+
*
|
|
52
|
+
* @category schemas
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*/
|
|
55
|
+
export declare const Output: Schema.Struct<{
|
|
56
|
+
readonly output: Schema.String;
|
|
57
|
+
readonly added: Schema.$Array<Schema.String>;
|
|
58
|
+
readonly modified: Schema.$Array<Schema.String>;
|
|
59
|
+
readonly deleted: Schema.$Array<Schema.String>;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Decoded output returned by the `apply_patch` flow.
|
|
63
|
+
*
|
|
64
|
+
* @category models
|
|
65
|
+
* @since 1.0.0
|
|
66
|
+
*/
|
|
67
|
+
export type Output = typeof Output.Type;
|
|
68
|
+
/**
|
|
69
|
+
* Static conservative effect envelope for the apply_patch flow.
|
|
70
|
+
*
|
|
71
|
+
* @category effects
|
|
72
|
+
* @since 1.0.0
|
|
73
|
+
*/
|
|
74
|
+
export declare const effects: import("@smthrs/plan/Effects").Declaration;
|
|
75
|
+
/**
|
|
76
|
+
* Narrows the effect envelope for a decoded invocation.
|
|
77
|
+
*
|
|
78
|
+
* A patch names its files inside its own text rather than in a decoded field,
|
|
79
|
+
* and the parse that finds them is the same parse that can fail, so there is
|
|
80
|
+
* nothing here to narrow before the handler runs: the static envelope is the
|
|
81
|
+
* honest answer.
|
|
82
|
+
*
|
|
83
|
+
* @category effects
|
|
84
|
+
* @since 1.0.0
|
|
85
|
+
*/
|
|
86
|
+
export declare const effectsFor: (_input: typeof Input.Type) => import("@smthrs/plan/Effects").Declaration;
|
|
87
|
+
/**
|
|
88
|
+
* Capabilities required by the apply_patch flow.
|
|
89
|
+
*
|
|
90
|
+
* @category capabilities
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
*/
|
|
93
|
+
export declare const capabilities: string[];
|
|
94
|
+
/**
|
|
95
|
+
* Declaration-only apply_patch flow.
|
|
96
|
+
*
|
|
97
|
+
* @category flows
|
|
98
|
+
* @since 1.0.0
|
|
99
|
+
*/
|
|
100
|
+
export declare const flow: {
|
|
101
|
+
readonly name: "apply_patch";
|
|
102
|
+
readonly description: "The `apply_patch` tool can be used to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.";
|
|
103
|
+
readonly input: Schema.Struct<{
|
|
104
|
+
readonly input: Schema.String;
|
|
105
|
+
}>;
|
|
106
|
+
readonly output: Schema.Struct<{
|
|
107
|
+
readonly output: Schema.String;
|
|
108
|
+
readonly added: Schema.$Array<Schema.String>;
|
|
109
|
+
readonly modified: Schema.$Array<Schema.String>;
|
|
110
|
+
readonly deleted: Schema.$Array<Schema.String>;
|
|
111
|
+
}>;
|
|
112
|
+
readonly capabilities: string[];
|
|
113
|
+
readonly effects: import("@smthrs/plan/Effects").Declaration;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* What a call to this flow does, for a reader of a run.
|
|
117
|
+
*
|
|
118
|
+
* Display metadata only. `@smthrs/registry` `Descriptor.FlowActivity` is the
|
|
119
|
+
* governing vocabulary and `StandardFlows` binds this value onto the flow's
|
|
120
|
+
* descriptor, where the binding site checks it. `declarationDigest` excludes
|
|
121
|
+
* it, so declaring it cannot invalidate a call identity or a cached prompt.
|
|
122
|
+
*
|
|
123
|
+
* @category presentation
|
|
124
|
+
* @since 1.0.0-rc.0
|
|
125
|
+
*/
|
|
126
|
+
export declare const activity: "writes";
|
|
127
|
+
/**
|
|
128
|
+
* How one recorded call to this flow reads: the verb for each settlement, the
|
|
129
|
+
* input field that is its subject, and the measured output fields a one-line
|
|
130
|
+
* summary may count.
|
|
131
|
+
*
|
|
132
|
+
* Display metadata only, governed by `@smthrs/registry`
|
|
133
|
+
* `Descriptor.CallPresentation` and checked where `StandardFlows` binds it.
|
|
134
|
+
*
|
|
135
|
+
* @category presentation
|
|
136
|
+
* @since 1.0.0-rc.0
|
|
137
|
+
*/
|
|
138
|
+
export declare const presentation: {
|
|
139
|
+
readonly verb: {
|
|
140
|
+
readonly pending: "patching";
|
|
141
|
+
readonly success: "patched";
|
|
142
|
+
readonly failure: "failed to patch";
|
|
143
|
+
};
|
|
144
|
+
readonly subject: "patch";
|
|
145
|
+
readonly result: "patch";
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Every path a patch writes, in the order it names them, including a move's
|
|
149
|
+
* destination. The patch is read by the parser {@link run} uses, so a header
|
|
150
|
+
* `run` accepts is never missed.
|
|
151
|
+
*
|
|
152
|
+
* Returns `undefined` when `run` would refuse the patch. A caller asking
|
|
153
|
+
* permission for the call then asks for everything the flow declares.
|
|
154
|
+
*
|
|
155
|
+
* @category parsing
|
|
156
|
+
* @since 1.0.0-rc.1
|
|
157
|
+
*/
|
|
158
|
+
export declare const paths: (patch: string) => ReadonlyArray<string> | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Parses and applies a V4A patch through the permission-aware kernel
|
|
161
|
+
* filesystem, preserving Codex error text.
|
|
162
|
+
*
|
|
163
|
+
* @category handlers
|
|
164
|
+
* @since 1.0.0
|
|
165
|
+
*/
|
|
166
|
+
export declare const run: (input: {
|
|
167
|
+
readonly input: string;
|
|
168
|
+
}) => Effect.Effect<{
|
|
169
|
+
readonly output: string;
|
|
170
|
+
readonly added: readonly string[];
|
|
171
|
+
readonly modified: readonly string[];
|
|
172
|
+
readonly deleted: readonly string[];
|
|
173
|
+
}, StdError.StdError, import("effect/Path").Path | FileSystem.FileSystem>;
|
|
174
|
+
//# sourceMappingURL=ApplyPatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplyPatch.d.ts","sourceRoot":"","sources":["../../src/ApplyPatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAOvC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,gBAAgB,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,iHACwF,CAAA;AAEhH;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK;;EAEhB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;EAOjB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,OAAO,4CAAuF,CAAA;AAE3G;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAK,CAAC,IAAI,+CAAY,CAAA;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAgE,CAAA;AAEzF;;;;;GAKG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;CAAsF,CAAA;AAEvG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAAG,QAAiB,CAAA;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY;;;;;;;;CAIf,CAAA;AAEV;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAc7D,CAAA;AAsBD;;;;;;GAMG;AACH,eAAO,MAAM,GAAG;;;;;;;yEA0Pd,CAAA"}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* apply_patch flow declaration and portable handler.
|
|
3
|
+
*
|
|
4
|
+
* A Codex CLI clone: the V4A patch grammar (`*** Begin Patch` /
|
|
5
|
+
* `*** Add File:` / `*** Update File:` / `*** Delete File:` /
|
|
6
|
+
* `*** End Patch`), the fuzzy context-matching applier, and Codex's error
|
|
7
|
+
* and summary text, expressed as a flow over the kernel filesystem.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
import * as Path from "@smthrs/kernel/Path";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as FileSystem from "effect/FileSystem";
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import * as ApplyPatchText from "./internal/ApplyPatch.js";
|
|
16
|
+
import { capability, envelope } from "./internal/Declaration.js";
|
|
17
|
+
import * as Diagnostics from "./internal/Diagnostics.js";
|
|
18
|
+
import * as FileMutation from "./internal/FileMutation.js";
|
|
19
|
+
import * as FsFailure from "./internal/FsFailure.js";
|
|
20
|
+
import * as Preserve from "./internal/Preserve.js";
|
|
21
|
+
import * as StdError from "./StdError.js";
|
|
22
|
+
/**
|
|
23
|
+
* Registry name for the apply_patch flow. Matches the Codex CLI tool name.
|
|
24
|
+
*
|
|
25
|
+
* @category identifiers
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
*/
|
|
28
|
+
export const name = "apply_patch";
|
|
29
|
+
/**
|
|
30
|
+
* Model-facing description of the apply_patch flow. Matches the Codex CLI
|
|
31
|
+
* freeform tool description.
|
|
32
|
+
*
|
|
33
|
+
* @category descriptions
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
export const description = "The `apply_patch` tool can be used to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.";
|
|
37
|
+
/**
|
|
38
|
+
* Input schema for the apply_patch flow.
|
|
39
|
+
*
|
|
40
|
+
* Codex delivers the patch as freeform text; the JSON function fallback uses
|
|
41
|
+
* a single `input` field, which is the shape cloned here.
|
|
42
|
+
*
|
|
43
|
+
* @category schemas
|
|
44
|
+
* @since 1.0.0
|
|
45
|
+
*/
|
|
46
|
+
export const Input = Schema.Struct({
|
|
47
|
+
input: Schema.String.annotate({ description: "The entire contents of the apply_patch command" })
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Output schema for the apply_patch flow.
|
|
51
|
+
*
|
|
52
|
+
* @category schemas
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*/
|
|
55
|
+
export const Output = Schema.Struct({
|
|
56
|
+
output: Schema.String.annotate({
|
|
57
|
+
description: "Codex-style summary: 'Success. Updated the following files:' with A/M/D lines"
|
|
58
|
+
}),
|
|
59
|
+
added: Schema.Array(Schema.String).annotate({ description: "Paths of files created by the patch" }),
|
|
60
|
+
modified: Schema.Array(Schema.String).annotate({ description: "Paths of files updated by the patch" }),
|
|
61
|
+
deleted: Schema.Array(Schema.String).annotate({ description: "Paths of files deleted by the patch" })
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Static conservative effect envelope for the apply_patch flow.
|
|
65
|
+
*
|
|
66
|
+
* @category effects
|
|
67
|
+
* @since 1.0.0
|
|
68
|
+
*/
|
|
69
|
+
export const effects = envelope({ tier: "compensable", mode: "hermetic", reads: ["/**"], writes: ["/**"] });
|
|
70
|
+
/**
|
|
71
|
+
* Narrows the effect envelope for a decoded invocation.
|
|
72
|
+
*
|
|
73
|
+
* A patch names its files inside its own text rather than in a decoded field,
|
|
74
|
+
* and the parse that finds them is the same parse that can fail, so there is
|
|
75
|
+
* nothing here to narrow before the handler runs: the static envelope is the
|
|
76
|
+
* honest answer.
|
|
77
|
+
*
|
|
78
|
+
* @category effects
|
|
79
|
+
* @since 1.0.0
|
|
80
|
+
*/
|
|
81
|
+
export const effectsFor = (_input) => effects;
|
|
82
|
+
/**
|
|
83
|
+
* Capabilities required by the apply_patch flow.
|
|
84
|
+
*
|
|
85
|
+
* @category capabilities
|
|
86
|
+
* @since 1.0.0
|
|
87
|
+
*/
|
|
88
|
+
export const capabilities = [capability("fs:read", "/**"), capability("fs:write", "/**")];
|
|
89
|
+
/**
|
|
90
|
+
* Declaration-only apply_patch flow.
|
|
91
|
+
*
|
|
92
|
+
* @category flows
|
|
93
|
+
* @since 1.0.0
|
|
94
|
+
*/
|
|
95
|
+
export const flow = { name, description, input: Input, output: Output, capabilities, effects };
|
|
96
|
+
/**
|
|
97
|
+
* What a call to this flow does, for a reader of a run.
|
|
98
|
+
*
|
|
99
|
+
* Display metadata only. `@smthrs/registry` `Descriptor.FlowActivity` is the
|
|
100
|
+
* governing vocabulary and `StandardFlows` binds this value onto the flow's
|
|
101
|
+
* descriptor, where the binding site checks it. `declarationDigest` excludes
|
|
102
|
+
* it, so declaring it cannot invalidate a call identity or a cached prompt.
|
|
103
|
+
*
|
|
104
|
+
* @category presentation
|
|
105
|
+
* @since 1.0.0-rc.0
|
|
106
|
+
*/
|
|
107
|
+
export const activity = "writes";
|
|
108
|
+
/**
|
|
109
|
+
* How one recorded call to this flow reads: the verb for each settlement, the
|
|
110
|
+
* input field that is its subject, and the measured output fields a one-line
|
|
111
|
+
* summary may count.
|
|
112
|
+
*
|
|
113
|
+
* Display metadata only, governed by `@smthrs/registry`
|
|
114
|
+
* `Descriptor.CallPresentation` and checked where `StandardFlows` binds it.
|
|
115
|
+
*
|
|
116
|
+
* @category presentation
|
|
117
|
+
* @since 1.0.0-rc.0
|
|
118
|
+
*/
|
|
119
|
+
export const presentation = {
|
|
120
|
+
verb: { pending: "patching", success: "patched", failure: "failed to patch" },
|
|
121
|
+
subject: "patch",
|
|
122
|
+
result: "patch"
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Every path a patch writes, in the order it names them, including a move's
|
|
126
|
+
* destination. The patch is read by the parser {@link run} uses, so a header
|
|
127
|
+
* `run` accepts is never missed.
|
|
128
|
+
*
|
|
129
|
+
* Returns `undefined` when `run` would refuse the patch. A caller asking
|
|
130
|
+
* permission for the call then asks for everything the flow declares.
|
|
131
|
+
*
|
|
132
|
+
* @category parsing
|
|
133
|
+
* @since 1.0.0-rc.1
|
|
134
|
+
*/
|
|
135
|
+
export const paths = (patch) => {
|
|
136
|
+
let parsed;
|
|
137
|
+
try {
|
|
138
|
+
parsed = ApplyPatchText.parsePatch(patch);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
return [
|
|
144
|
+
...new Set(parsed.hunks.flatMap((hunk) => hunk.kind === "update" && hunk.movePath !== undefined ? [hunk.path, hunk.movePath] : [hunk.path]))
|
|
145
|
+
];
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* The one sentence a model sees for a failure this handler did not design.
|
|
149
|
+
* The raw failure goes to the log, never into the tool result.
|
|
150
|
+
*/
|
|
151
|
+
const unknownFailureSentence = "Something went wrong on our side. Not your fault.";
|
|
152
|
+
const unknownFailure = (error, path) => Effect.logError("apply_patch failed unexpectedly", error).pipe(Effect.andThen(Effect.fail(new StdError.StdError(path === undefined
|
|
153
|
+
? { code: "command_failed", message: unknownFailureSentence }
|
|
154
|
+
: { code: "command_failed", message: unknownFailureSentence, path }))));
|
|
155
|
+
const encoder = new TextEncoder();
|
|
156
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
157
|
+
/**
|
|
158
|
+
* Parses and applies a V4A patch through the permission-aware kernel
|
|
159
|
+
* filesystem, preserving Codex error text.
|
|
160
|
+
*
|
|
161
|
+
* @category handlers
|
|
162
|
+
* @since 1.0.0
|
|
163
|
+
*/
|
|
164
|
+
export const run = Effect.fn("ApplyPatch.run")(function* (input) {
|
|
165
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
166
|
+
const path = yield* Path.Path;
|
|
167
|
+
let parsed;
|
|
168
|
+
try {
|
|
169
|
+
parsed = ApplyPatchText.parsePatch(input.input);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (error instanceof ApplyPatchText.ParseError) {
|
|
173
|
+
return yield* Effect.fail(new StdError.StdError({ code: "invalid_input", message: error.message }));
|
|
174
|
+
}
|
|
175
|
+
return yield* unknownFailure(error);
|
|
176
|
+
}
|
|
177
|
+
// Every update hunk is derived from the file as it is on disk, so two
|
|
178
|
+
// sections naming one path both start from the same original and the second
|
|
179
|
+
// write erases the first — while the summary reports two modifications.
|
|
180
|
+
// The preflight cannot honestly validate the second section against a file
|
|
181
|
+
// the first has not written yet, so the patch is refused whole rather than
|
|
182
|
+
// applied by halves. A file needing several edits carries several `@@`
|
|
183
|
+
// chunks inside one section, which is the shape the parser already accepts.
|
|
184
|
+
// Resolve against the injected workspace, then follow existing filesystem
|
|
185
|
+
// aliases. For a new file, resolve its parent (which may be a symlink).
|
|
186
|
+
const identity = (value) => {
|
|
187
|
+
const resolved = path.resolve(value);
|
|
188
|
+
return fileSystem.realPath(resolved).pipe(Effect.catch((error) => error.reason._tag === "NotFound"
|
|
189
|
+
? fileSystem.realPath(path.dirname(resolved)).pipe(Effect.map((parent) => path.resolve(parent, path.basename(resolved))), Effect.catch((parentError) => parentError.reason._tag === "NotFound"
|
|
190
|
+
? Effect.succeed(resolved)
|
|
191
|
+
: Effect.fail(parentError)))
|
|
192
|
+
: Effect.fail(error)), Effect.mapError(FsFailure.denied(value, () => new StdError.StdError({
|
|
193
|
+
code: "command_failed",
|
|
194
|
+
message: `Failed to resolve patch path ${value}`,
|
|
195
|
+
path: value
|
|
196
|
+
}))));
|
|
197
|
+
};
|
|
198
|
+
const touched = new Set();
|
|
199
|
+
for (const hunk of parsed.hunks) {
|
|
200
|
+
const source = yield* identity(hunk.path);
|
|
201
|
+
const destination = hunk.kind === "update" && hunk.movePath !== undefined
|
|
202
|
+
? yield* identity(hunk.movePath)
|
|
203
|
+
: undefined;
|
|
204
|
+
const claims = [[hunk.path, source]];
|
|
205
|
+
if (hunk.kind === "update" && hunk.movePath !== undefined && destination !== source) {
|
|
206
|
+
claims.push([hunk.movePath, destination]);
|
|
207
|
+
}
|
|
208
|
+
for (const [claimed, key] of claims) {
|
|
209
|
+
if (touched.has(key)) {
|
|
210
|
+
return yield* Effect.fail(new StdError.StdError({
|
|
211
|
+
code: "invalid_input",
|
|
212
|
+
message: `The patch names ${claimed} in more than one section; give one section per path`,
|
|
213
|
+
path: claimed
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
touched.add(key);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
yield* FileMutation.validate(fileSystem, parsed.hunks.flatMap((hunk) => hunk.kind === "update" && hunk.movePath !== undefined ? [hunk.path, hunk.movePath] : [hunk.path]));
|
|
220
|
+
// Create only parents the patch already intends to create, before taking
|
|
221
|
+
// stable sibling locks for new destinations as well as existing sources.
|
|
222
|
+
for (const hunk of parsed.hunks) {
|
|
223
|
+
const destination = hunk.kind === "add" ? hunk.path : hunk.kind === "update" ? hunk.movePath : undefined;
|
|
224
|
+
if (destination !== undefined && !FileMutation.isVersioned(fileSystem)) {
|
|
225
|
+
yield* fileSystem.makeDirectory(path.dirname(destination), { recursive: true }).pipe(Effect.mapError(FsFailure.denied(destination, () => new StdError.StdError({
|
|
226
|
+
code: "command_failed",
|
|
227
|
+
message: `Failed to create parent directories for ${destination}`,
|
|
228
|
+
path: destination
|
|
229
|
+
}))));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
233
|
+
const mutation = yield* FileMutation.acquire(fileSystem, parsed.hunks.flatMap((hunk) => hunk.kind === "update" && hunk.movePath !== undefined ? [hunk.path, hunk.movePath] : [hunk.path]), path);
|
|
234
|
+
const added = [];
|
|
235
|
+
const modified = [];
|
|
236
|
+
const deleted = [];
|
|
237
|
+
const prepared = new Map();
|
|
238
|
+
for (const hunk of parsed.hunks) {
|
|
239
|
+
if (hunk.kind !== "update")
|
|
240
|
+
continue;
|
|
241
|
+
const bytes = yield* mutation.read(hunk.path, fileSystem.readFile(hunk.path).pipe(Effect.mapError(FsFailure.reading(hunk.path, `Failed to read file to update ${hunk.path}`))));
|
|
242
|
+
if (bytes.includes(0)) {
|
|
243
|
+
return yield* Effect.fail(new StdError.StdError({
|
|
244
|
+
code: "binary_file",
|
|
245
|
+
message: `Cannot read binary file: ${hunk.path}`,
|
|
246
|
+
path: hunk.path
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
const original = yield* Effect.try({
|
|
250
|
+
try: () => decoder.decode(bytes),
|
|
251
|
+
catch: () => new StdError.StdError({
|
|
252
|
+
code: "binary_file",
|
|
253
|
+
message: `File is not valid UTF-8: ${hunk.path}`,
|
|
254
|
+
path: hunk.path
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
let contents;
|
|
258
|
+
try {
|
|
259
|
+
contents = ApplyPatchText.deriveNewContents(original, hunk.path, hunk.chunks);
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
if (error instanceof ApplyPatchText.ComputeReplacementsError) {
|
|
263
|
+
return yield* Effect.fail(new StdError.StdError({ code: "no_match", message: error.message, path: hunk.path }));
|
|
264
|
+
}
|
|
265
|
+
return yield* unknownFailure(error, hunk.path);
|
|
266
|
+
}
|
|
267
|
+
prepared.set(hunk, contents);
|
|
268
|
+
}
|
|
269
|
+
// Prepare one complete provider request before touching any file. A move
|
|
270
|
+
// carries both its destination write and source removal in the same commit.
|
|
271
|
+
const changes = [];
|
|
272
|
+
const moves = new Set();
|
|
273
|
+
for (const hunk of parsed.hunks) {
|
|
274
|
+
if (hunk.kind === "delete") {
|
|
275
|
+
changes.push({ path: hunk.path, content: null });
|
|
276
|
+
}
|
|
277
|
+
else if (hunk.kind === "add") {
|
|
278
|
+
changes.push({ path: hunk.path, content: encoder.encode(hunk.contents) });
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
changes.push({
|
|
282
|
+
path: hunk.movePath ?? hunk.path,
|
|
283
|
+
content: encoder.encode(prepared.get(hunk))
|
|
284
|
+
});
|
|
285
|
+
if (hunk.movePath !== undefined && (yield* identity(hunk.movePath)) !== (yield* identity(hunk.path))) {
|
|
286
|
+
moves.add(hunk);
|
|
287
|
+
changes.push({ path: hunk.path, content: null });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// A denial names itself, so the model does not retry a write the host refuses.
|
|
292
|
+
const mutationFailure = (code, message, offendingPath) => (error) => error.reason._tag === "PermissionDenied"
|
|
293
|
+
? mutationError("permission_denied", `Permission denied: ${offendingPath}`, offendingPath)
|
|
294
|
+
: mutationError(code, message, offendingPath);
|
|
295
|
+
const mutationError = (code, message, offendingPath) => new StdError.StdError({
|
|
296
|
+
code,
|
|
297
|
+
message: `${message}; applied before failure: added=${JSON.stringify(added)}, modified=${JSON.stringify(modified)}, deleted=${JSON.stringify(deleted)}`,
|
|
298
|
+
path: offendingPath
|
|
299
|
+
});
|
|
300
|
+
yield* mutation.commit(changes, Effect.gen(function* () {
|
|
301
|
+
for (const hunk of parsed.hunks) {
|
|
302
|
+
switch (hunk.kind) {
|
|
303
|
+
case "add": {
|
|
304
|
+
yield* fileSystem.writeFile(hunk.path, encoder.encode(hunk.contents)).pipe(Effect.mapError(mutationFailure("command_failed", `Failed to write file ${hunk.path}`, hunk.path)));
|
|
305
|
+
added.push(hunk.path);
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
case "delete": {
|
|
309
|
+
yield* fileSystem.remove(hunk.path).pipe(Effect.mapError(mutationFailure("not_found", `Failed to delete file ${hunk.path}`, hunk.path)));
|
|
310
|
+
deleted.push(hunk.path);
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case "update": {
|
|
314
|
+
const contents = prepared.get(hunk);
|
|
315
|
+
const destination = hunk.movePath ?? hunk.path;
|
|
316
|
+
yield* Preserve.writeFile(fileSystem, destination, encoder.encode(contents)).pipe(Effect.mapError((error) => error.reason.method === "chmod"
|
|
317
|
+
? mutationError("command_failed", `Could not preserve the mode of ${destination} before replacement by chmod`, destination)
|
|
318
|
+
: mutationFailure("command_failed", `Failed to write file ${destination}`, destination)(error)));
|
|
319
|
+
modified.push(destination);
|
|
320
|
+
if (moves.has(hunk)) {
|
|
321
|
+
yield* fileSystem.remove(hunk.path).pipe(Effect.mapError(mutationFailure("command_failed", `Failed to remove original ${hunk.path}`, hunk.path)));
|
|
322
|
+
}
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}));
|
|
328
|
+
// Publish diagnostics only after the whole provider operation succeeds.
|
|
329
|
+
for (const change of changes) {
|
|
330
|
+
if (change.content === null)
|
|
331
|
+
yield* Diagnostics.close(path.resolve(change.path));
|
|
332
|
+
else
|
|
333
|
+
yield* Diagnostics.sync(path.resolve(change.path), decoder.decode(change.content));
|
|
334
|
+
}
|
|
335
|
+
const summary = {
|
|
336
|
+
added: parsed.hunks.filter((hunk) => hunk.kind === "add").map((hunk) => hunk.path),
|
|
337
|
+
deleted: parsed.hunks.filter((hunk) => hunk.kind === "delete").map((hunk) => hunk.path),
|
|
338
|
+
modified: parsed.hunks.filter((hunk) => hunk.kind === "update").map((hunk) => hunk.movePath ?? hunk.path)
|
|
339
|
+
};
|
|
340
|
+
return {
|
|
341
|
+
output: ApplyPatchText.printSummary(summary),
|
|
342
|
+
...summary
|
|
343
|
+
};
|
|
344
|
+
}));
|
|
345
|
+
});
|
|
346
|
+
//# sourceMappingURL=ApplyPatch.js.map
|