@cursor/bdk 0.2.9 → 0.2.10
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/dist/artifacts.js +3 -5
- package/dist/bin/agent-serve.js +803 -812
- package/dist/channels/bitbucket/api.js +305 -321
- package/dist/channels/bitbucket/binding.js +97 -61
- package/dist/channels/bitbucket/bitbucket-channel.d.ts +15 -1
- package/dist/channels/bitbucket/bitbucket-channel.d.ts.map +1 -1
- package/dist/channels/bitbucket/bitbucket-channel.js +95 -42
- package/dist/channels/bitbucket/bitbucket-webhook.d.ts +11 -0
- package/dist/channels/bitbucket/bitbucket-webhook.d.ts.map +1 -1
- package/dist/channels/bitbucket/bitbucket-webhook.js +214 -204
- package/dist/channels/bitbucket/checks.js +9 -21
- package/dist/channels/bitbucket/cursor-account.js +1 -1
- package/dist/channels/bitbucket/defaults.js +14 -4
- package/dist/channels/bitbucket/events.js +1 -2
- package/dist/channels/bitbucket/index.d.ts +6 -2
- package/dist/channels/bitbucket/index.d.ts.map +1 -1
- package/dist/channels/bitbucket/index.js +6 -2
- package/dist/channels/bitbucket/replay.js +80 -56
- package/dist/channels/bitbucket/state.js +16 -7
- package/dist/channels/bitbucket/types.d.ts +11 -2
- package/dist/channels/bitbucket/types.d.ts.map +1 -1
- package/dist/channels/checks.js +18 -28
- package/dist/channels/deployments/deployments-channel.js +26 -34
- package/dist/channels/github/api.js +216 -210
- package/dist/channels/github/auth.d.ts +5 -1
- package/dist/channels/github/auth.d.ts.map +1 -1
- package/dist/channels/github/auth.js +157 -174
- package/dist/channels/github/binding.js +48 -39
- package/dist/channels/github/checks.js +9 -14
- package/dist/channels/github/cursor-account.js +6 -11
- package/dist/channels/github/defaults.js +105 -130
- package/dist/channels/github/forward.js +13 -17
- package/dist/channels/github/github-channel.d.ts +43 -2
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +1228 -958
- package/dist/channels/github/progress.js +145 -146
- package/dist/channels/github/replay.js +30 -39
- package/dist/channels/github/state.js +40 -16
- package/dist/channels/github/types.d.ts +30 -6
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/gitlab/api.js +100 -114
- package/dist/channels/gitlab/binding.js +52 -33
- package/dist/channels/gitlab/checks.js +28 -29
- package/dist/channels/gitlab/cursor-account.js +1 -1
- package/dist/channels/gitlab/defaults.js +9 -3
- package/dist/channels/gitlab/gitlab-channel.d.ts +16 -1
- package/dist/channels/gitlab/gitlab-channel.d.ts.map +1 -1
- package/dist/channels/gitlab/gitlab-channel.js +95 -42
- package/dist/channels/gitlab/gitlab-webhook.d.ts +10 -1
- package/dist/channels/gitlab/gitlab-webhook.d.ts.map +1 -1
- package/dist/channels/gitlab/gitlab-webhook.js +282 -249
- package/dist/channels/gitlab/index.d.ts +6 -2
- package/dist/channels/gitlab/index.d.ts.map +1 -1
- package/dist/channels/gitlab/index.js +6 -2
- package/dist/channels/gitlab/replay.js +50 -27
- package/dist/channels/gitlab/state.js +14 -6
- package/dist/channels/gitlab/types.d.ts +13 -2
- package/dist/channels/gitlab/types.d.ts.map +1 -1
- package/dist/channels/origin/api.js +100 -116
- package/dist/channels/origin/binding.js +15 -16
- package/dist/channels/origin/checks.js +30 -28
- package/dist/channels/origin/defaults.js +50 -65
- package/dist/channels/origin/origin-channel.js +266 -272
- package/dist/channels/origin/origin-webhook.js +70 -88
- package/dist/channels/origin/reactions.js +9 -21
- package/dist/channels/origin/state.js +13 -5
- package/dist/channels/slack/agentic-delivery.js +426 -478
- package/dist/channels/slack/agentic-posted.js +9 -10
- package/dist/channels/slack/agentic-signals.js +2 -3
- package/dist/channels/slack/api.js +417 -427
- package/dist/channels/slack/approvals.js +1 -1
- package/dist/channels/slack/assistant.js +37 -47
- package/dist/channels/slack/attachments.js +188 -206
- package/dist/channels/slack/auth.js +8 -6
- package/dist/channels/slack/bot-mentions.js +31 -45
- package/dist/channels/slack/channel-watch.js +42 -48
- package/dist/channels/slack/cli-project.js +112 -137
- package/dist/channels/slack/code-fences.js +3 -5
- package/dist/channels/slack/constants.js +2 -2
- package/dist/channels/slack/credentials.js +23 -38
- package/dist/channels/slack/defaults.js +292 -331
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +533 -460
- package/dist/channels/slack/doctor.js +200 -214
- package/dist/channels/slack/eval-directive.js +79 -96
- package/dist/channels/slack/event-id-dedupe.js +1 -1
- package/dist/channels/slack/external-policy.js +26 -39
- package/dist/channels/slack/footer.js +28 -41
- package/dist/channels/slack/inbound.d.ts +1 -0
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +50 -31
- package/dist/channels/slack/init.d.ts +1 -5
- package/dist/channels/slack/init.d.ts.map +1 -1
- package/dist/channels/slack/init.js +42 -59
- package/dist/channels/slack/interactive.d.ts +9 -3
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +160 -162
- package/dist/channels/slack/links.js +1 -2
- package/dist/channels/slack/live-delivery.js +172 -190
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +44 -23
- package/dist/channels/slack/message-body.js +2 -2
- package/dist/channels/slack/nudge-carrier.js +30 -42
- package/dist/channels/slack/nudge-store.js +164 -191
- package/dist/channels/slack/paint-start.js +66 -81
- package/dist/channels/slack/placeholder.js +123 -152
- package/dist/channels/slack/pr-ref.js +1 -1
- package/dist/channels/slack/progress-delivery.js +65 -78
- package/dist/channels/slack/reasoning-card.js +36 -49
- package/dist/channels/slack/recording-sink.js +12 -24
- package/dist/channels/slack/reply-options.js +7 -12
- package/dist/channels/slack/self-identity.js +27 -35
- package/dist/channels/slack/sender-name.d.ts +12 -3
- package/dist/channels/slack/sender-name.d.ts.map +1 -1
- package/dist/channels/slack/sender-name.js +57 -61
- package/dist/channels/slack/setup.js +2 -4
- package/dist/channels/slack/slack-channel.d.ts +6 -4
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +441 -308
- package/dist/channels/slack/socket-mode.js +38 -52
- package/dist/channels/slack/thread-context.js +143 -160
- package/dist/channels/slack/tool-approval-events.js +149 -166
- package/dist/channels/slack/tool-cards.js +6 -11
- package/dist/channels/slack/tool-chip.js +1 -2
- package/dist/channels/slack/types.d.ts +15 -17
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/channels/slack/upload.js +84 -97
- package/dist/channels/slack/user-info.js +27 -41
- package/dist/channels.js +9 -20
- package/dist/dashboard-session-url.js +3 -4
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.BNhEdGa8.js → app.DXI7bwox.js} +4 -4
- package/dist/docs/assets/{building-with-agents.md.BPjPFxFg.js → building-with-agents.md.Df87rAe1.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.CtLtpWcx.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.DIdUV1Ph.js → VPLocalSearchBox.BrbO5mEe.js} +1 -1
- package/dist/docs/assets/chunks/{arc.lELI4_SR.js → arc.BOG1yms8.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.iCMdvuoM.js → architectureDiagram-Q4EWVU46.C0hsMZnZ.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.C1-nDJBf.js → baseUniq.H044KjKs.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.ClemzBox.js → blockDiagram-DXYQGD6D.BsRW6GoB.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.BqTak6cR.js → c4Diagram-AHTNJAMY.B9HV5PFR.js} +1 -1
- package/dist/docs/assets/chunks/channel.CBwrU9rP.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.CUS3qs_R.js → chunk-4BX2VUAB.CPoT_ajl.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.dz5fdHcl.js → chunk-4TB4RGXK.DZBwWuCL.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.D6BEBmve.js → chunk-55IACEB6.CZ3yTiyq.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.B5uK4ID9.js → chunk-EDXVE4YY.6DfvHSd8.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.PgOJgNQs.js → chunk-FMBD7UC4.CpBj8HfK.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.CvkTrCii.js → chunk-OYMX7WX6.BdKo8YqS.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.BnSfKYsB.js → chunk-QZHKN3VN.BnXNyxJx.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.MZH6v5UC.js → chunk-YZCP3GAM.Cg1OcF8G.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CbC_mrvB.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CbC_mrvB.js +1 -0
- package/dist/docs/assets/chunks/clone.BTvFyY1a.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.BBbw_YZi.js → cose-bilkent-S5V4N54A.1SP8al9c.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.CNJB2l7E.js → dagre-KV5264BT.DS1L6hJt.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.BQzlnFfq.js → diagram-5BDNPKRD.ChsausbG.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.DkgqqZMz.js → diagram-G4DWMVQ6.3XsptNWj.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.DIT8L7H_.js → diagram-MMDJMWI5.DPA9Dk_P.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.3xLPZWGJ.js → diagram-TYMM5635.BVswXWrB.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.5_IHz8jF.js → erDiagram-SMLLAGMA.BSak5OSP.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.BGUCXz8A.js → flowDiagram-DWJPFMVM.CQgN4TTz.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.DbfFavS1.js → ganttDiagram-T4ZO3ILL.GrT0kA4a.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.D2yKdeNW.js → gitGraphDiagram-UUTBAWPF.CdS7Ucll.js} +1 -1
- package/dist/docs/assets/chunks/{graph.CSCxwHba.js → graph.BVqKRmRo.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.FDeb6xHY.js → infoDiagram-42DDH7IO.C3C9FRto.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.DbeYs9VL.js → ishikawaDiagram-UXIWVN3A.2FuAh_Zj.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.CWjKINpx.js → journeyDiagram-VCZTEJTY.CaHMfK4b.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.B4FrAlwz.js → kanban-definition-6JOO6SKY.CjhIUwcA.js} +1 -1
- package/dist/docs/assets/chunks/{layout.DFGxQ9ab.js → layout.CGU3gfSf.js} +1 -1
- package/dist/docs/assets/chunks/{linear.BmjZ-G59.js → linear.DaihpW_n.js} +1 -1
- package/dist/docs/assets/chunks/{min.DZSxulMW.js → min.BS-j8kHQ.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.CHLi3-aN.js → mindmap-definition-QFDTVHPH.BVJ1Bbnk.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.DteG-CkU.js → pieDiagram-DEJITSTG.Cz1WIv9r.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.D458ipN3.js → quadrantDiagram-34T5L4WZ.DKLFxcjy.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DcFgUxst.js → requirementDiagram-MS252O5E.BHegiK7x.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.BwQAMmSA.js → sankeyDiagram-XADWPNL6.DYkY6yPc.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.B_Xdsrh9.js → sequenceDiagram-FGHM5R23.DYQ1QUrI.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.CdfDW6-C.js → stateDiagram-FHFEXIEX.Iru8BsFo.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.BYXl4LW6.js +1 -0
- package/dist/docs/assets/chunks/{theme.sfdL3srp.js → theme.DaplWQhQ.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.56-4hXaC.js → timeline-definition-GMOUNBTQ.BwFA8hiX.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.CvZSQBO7.js → vennDiagram-DHZGUBPP.CZ60W1C_.js} +1 -1
- package/dist/docs/assets/chunks/{wardley-RL74JXVD.C9qc8k39.js → wardley-RL74JXVD.iXazD3Z7.js} +1 -1
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.D9s0nihi.js → wardleyDiagram-NUSXRM2D.B69D2r8-.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.BVJSpYrC.js → xychartDiagram-5P7HB3ND.CLPZEIU9.js} +1 -1
- package/dist/docs/assets/{deployment.md.BdqTiGdc.js → deployment.md.BYuEcDBv.js} +2 -2
- package/dist/docs/assets/{guides_bitbucket.md.BB6fqD-M.js → guides_bitbucket.md.CKUayYtD.js} +3 -3
- package/dist/docs/assets/{guides_bitbucket.md.BB6fqD-M.lean.js → guides_bitbucket.md.CKUayYtD.lean.js} +1 -1
- package/dist/docs/assets/{guides_github.md.Cr1Xlf-m.js → guides_github.md.TuNiZAOQ.js} +4 -4
- package/dist/docs/assets/{guides_github.md.Cr1Xlf-m.lean.js → guides_github.md.TuNiZAOQ.lean.js} +1 -1
- package/dist/docs/assets/{guides_gitlab.md.CMpmFi4M.js → guides_gitlab.md.CtNI4fSH.js} +4 -4
- package/dist/docs/assets/{guides_gitlab.md.CMpmFi4M.lean.js → guides_gitlab.md.CtNI4fSH.lean.js} +1 -1
- package/dist/docs/assets/guides_migrate.md.sCAvvlC6.js +7 -0
- package/dist/docs/assets/guides_migrate.md.sCAvvlC6.lean.js +1 -0
- package/dist/docs/assets/{reference_cli.md.GwugN3n-.js → reference_cli.md.dYCAL2lB.js} +4 -3
- package/dist/docs/assets/reference_cli.md.dYCAL2lB.lean.js +1 -0
- package/dist/docs/assets/{reference_skills.md.ClkMoQsV.js → reference_skills.md.C0guGcH0.js} +3 -3
- package/dist/docs/assets/troubleshooting.md.x-GBa7wN.js +1 -0
- package/dist/docs/assets/{troubleshooting.md.Bscj6ODe.lean.js → troubleshooting.md.x-GBa7wN.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +37 -37
- package/dist/docs/building-with-agents.md +2 -0
- package/dist/docs/deployment.html +38 -38
- package/dist/docs/deployment.md +7 -0
- package/dist/docs/evals.html +36 -36
- package/dist/docs/guides/agent-to-agent.html +35 -35
- package/dist/docs/guides/bitbucket.html +38 -38
- package/dist/docs/guides/bitbucket.md +9 -1
- package/dist/docs/guides/cloud-agents.html +35 -35
- package/dist/docs/guides/convert-automation.html +35 -35
- package/dist/docs/guides/github.html +39 -39
- package/dist/docs/guides/github.md +20 -4
- package/dist/docs/guides/gitlab.html +38 -38
- package/dist/docs/guides/gitlab.md +9 -1
- package/dist/docs/guides/grokbot-agents.html +35 -35
- package/dist/docs/guides/hooks.html +35 -35
- package/dist/docs/guides/improve.html +35 -35
- package/dist/docs/guides/jev.html +35 -35
- package/dist/docs/guides/mcp-oauth.html +35 -35
- package/dist/docs/guides/migrate.html +66 -0
- package/dist/docs/guides/migrate.md +122 -0
- package/dist/docs/guides/opentelemetry.html +35 -35
- package/dist/docs/guides/slack.html +35 -35
- package/dist/docs/guides/webhooks.html +35 -35
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +35 -35
- package/dist/docs/index.html +35 -35
- package/dist/docs/llms-full.txt +214 -6
- package/dist/docs/llms.txt +1 -0
- package/dist/docs/quickstart.html +35 -35
- package/dist/docs/reference/agent-config.html +35 -35
- package/dist/docs/reference/artifacts.html +35 -35
- package/dist/docs/reference/channels.html +35 -35
- package/dist/docs/reference/cli.html +39 -38
- package/dist/docs/reference/cli.md +39 -0
- package/dist/docs/reference/connections.html +35 -35
- package/dist/docs/reference/evals.html +35 -35
- package/dist/docs/reference/extensions.html +35 -35
- package/dist/docs/reference/hooks.html +35 -35
- package/dist/docs/reference/http-api.html +35 -35
- package/dist/docs/reference/instructions.html +35 -35
- package/dist/docs/reference/playground.html +35 -35
- package/dist/docs/reference/project-layout.html +35 -35
- package/dist/docs/reference/prompt.html +35 -35
- package/dist/docs/reference/schedules.html +35 -35
- package/dist/docs/reference/sessions.html +35 -35
- package/dist/docs/reference/skills.html +38 -38
- package/dist/docs/reference/subagents.html +35 -35
- package/dist/docs/reference/tools.html +35 -35
- package/dist/docs/templates/agentic-owners.html +35 -35
- package/dist/docs/templates/grokbot-agents.html +35 -35
- package/dist/docs/templates/security-reviewer.html +35 -35
- package/dist/docs/templates/thermo-quality-review.html +35 -35
- package/dist/docs/templates/thermo-review.html +35 -35
- package/dist/docs/templates/triage.html +35 -35
- package/dist/docs/troubleshooting.html +36 -36
- package/dist/docs/troubleshooting.md +1 -0
- package/dist/evals/assertions.js +20 -34
- package/dist/evals/expect.js +3 -6
- package/dist/evals/judge.js +5 -8
- package/dist/evals/loaders.js +45 -62
- package/dist/evals/matchers.js +2 -3
- package/dist/evals/reporters.js +43 -67
- package/dist/evals/results.js +1 -1
- package/dist/evals/run-facts.js +5 -6
- package/dist/evals.js +27 -15
- package/dist/extensions/cursor-cloud-agents/extension.js +4 -1
- package/dist/extensions/cursor-cloud-agents/lib/backend.js +100 -126
- package/dist/extensions/cursor-cloud-agents/lib/fleet.js +22 -38
- package/dist/extensions/cursor-cloud-agents/lib/repos.js +8 -10
- package/dist/extensions/cursor-cloud-agents/lib/transcript.js +2 -3
- package/dist/extensions/cursor-cloud-agents/lib/watch.js +52 -66
- package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.js +29 -40
- package/dist/extensions/cursor-cloud-agents/tools/cancel.js +6 -17
- package/dist/extensions/cursor-cloud-agents/tools/dump.js +25 -36
- package/dist/extensions/cursor-cloud-agents/tools/get.js +3 -14
- package/dist/extensions/cursor-cloud-agents/tools/launch.js +13 -21
- package/dist/extensions/cursor-cloud-agents/tools/list.js +8 -19
- package/dist/extensions/cursor-cloud-agents/tools/reply.js +5 -16
- package/dist/extensions/cursor-grokbot-agents/extension.js +4 -1
- package/dist/extensions/cursor-grokbot-agents/lib/agents.js +3 -3
- package/dist/extensions/cursor-grokbot-agents/lib/backend.js +53 -73
- package/dist/extensions/cursor-grokbot-agents/lib/contacts.js +10 -23
- package/dist/extensions/cursor-grokbot-agents/lib/conversation.js +112 -132
- package/dist/extensions/cursor-grokbot-agents/lib/lock.js +1 -2
- package/dist/extensions/cursor-grokbot-agents/tools/ask.js +5 -16
- package/dist/extensions/cursor-grokbot-agents/tools/check.js +4 -15
- package/dist/extensions/cursor-grokbot-agents/tools/interrupt.js +2 -13
- package/dist/extensions/cursor-grokbot-agents/tools/list.js +11 -23
- package/dist/extensions/jev/extension.js +3 -3
- package/dist/extensions/jev/lib/evaluate.js +43 -60
- package/dist/extensions/jev/tools/evaluate.js +6 -17
- package/dist/extensions/slack-communication/tools/post-file.js +1 -1
- package/dist/extensions.js +3 -5
- package/dist/files-backends/cursor-hosted.js +504 -523
- package/dist/files-backends/local-fs.js +72 -134
- package/dist/files.js +3 -3
- package/dist/filesystem.js +562 -861
- package/dist/index.js +16 -35
- package/dist/internal/advertise-tools.js +74 -86
- package/dist/internal/artifacts-store.js +298 -361
- package/dist/internal/as-of.js +2 -4
- package/dist/internal/authored-alias-hooks.js +6 -4
- package/dist/internal/authored-loaders.js +37 -52
- package/dist/internal/bounded-int.js +1 -2
- package/dist/internal/bounded.js +13 -24
- package/dist/internal/brand.js +1 -1
- package/dist/internal/browser-origin-guard.js +4 -4
- package/dist/internal/builtin-tools/artifacts.js +15 -27
- package/dist/internal/builtin-tools/index.js +2 -3
- package/dist/internal/builtin-tools/reminders.js +33 -52
- package/dist/internal/channel-architecture.d.ts +21 -0
- package/dist/internal/channel-architecture.d.ts.map +1 -0
- package/dist/internal/channel-architecture.js +41 -0
- package/dist/internal/channel-dispatch.js +3 -4
- package/dist/internal/channel-route-dispatch.js +40 -51
- package/dist/internal/channel-state.js +1 -1
- package/dist/internal/chat-client.js +319 -340
- package/dist/internal/cli-ax.js +1262 -1294
- package/dist/internal/cli-bitbucket.js +244 -272
- package/dist/internal/cli-convert-automation.js +137 -151
- package/dist/internal/cli-cursor.js +126 -147
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +1457 -1507
- package/dist/internal/cli-docs.js +130 -147
- package/dist/internal/cli-github.js +437 -476
- package/dist/internal/cli-gitlab.js +259 -288
- package/dist/internal/cli-images.js +266 -334
- package/dist/internal/cli-manifest.js +25 -37
- package/dist/internal/cli-mcp-oauth.js +228 -247
- package/dist/internal/cli-mcp.js +358 -383
- package/dist/internal/cli-migrate.js +73 -90
- package/dist/internal/cli-skills.js +35 -47
- package/dist/internal/cli-slack-manual.d.ts +0 -1
- package/dist/internal/cli-slack-manual.d.ts.map +1 -1
- package/dist/internal/cli-slack-manual.js +175 -204
- package/dist/internal/cli-slack.d.ts +1 -1
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +416 -456
- package/dist/internal/cloud-merge.js +7 -3
- package/dist/internal/cloud-turn-cost.js +8 -1
- package/dist/internal/connection-env.js +5 -6
- package/dist/internal/continuation-channel.js +10 -7
- package/dist/internal/continuation-identity.js +85 -67
- package/dist/internal/conversation-mirror.js +112 -131
- package/dist/internal/convert-automation/convert-workflow.js +21 -31
- package/dist/internal/cron.js +3 -3
- package/dist/internal/cursor/account-mcp.js +147 -146
- package/dist/internal/cursor/backend-client.js +290 -320
- package/dist/internal/cursor/bound-secret-file.js +3 -3
- package/dist/internal/cursor/credentials.js +127 -142
- package/dist/internal/cursor/cursor-api-transport.js +4 -8
- package/dist/internal/cursor/github-credentials.js +91 -108
- package/dist/internal/cursor/hosted-bound-secrets.js +3 -4
- package/dist/internal/cursor/hosted-deployment-secrets.js +1 -1
- package/dist/internal/cursor/hosted-store-secrets.js +5 -9
- package/dist/internal/cursor/session-token.js +36 -48
- package/dist/internal/cursor/store-api-client.js +77 -92
- package/dist/internal/cursor-account-mcp-auth.js +132 -149
- package/dist/internal/cursor-agent-template.js +1 -1
- package/dist/internal/cursor-deployment-relay.js +33 -54
- package/dist/internal/cursor-event-relay.js +65 -59
- package/dist/internal/cursor-relay-core.js +258 -286
- package/dist/internal/deferred-channel-session.js +3 -12
- package/dist/internal/deploy-client.js +410 -475
- package/dist/internal/deploy-manifest.d.ts +17 -0
- package/dist/internal/deploy-manifest.d.ts.map +1 -1
- package/dist/internal/deploy-manifest.js +71 -21
- package/dist/internal/deploy-source.js +31 -43
- package/dist/internal/discovery/agent-config.js +45 -59
- package/dist/internal/discovery/agent.js +276 -280
- package/dist/internal/discovery/channels.js +67 -80
- package/dist/internal/discovery/connections.js +286 -296
- package/dist/internal/discovery/context.js +2 -13
- package/dist/internal/discovery/cursor-plugin.js +223 -259
- package/dist/internal/discovery/extension-overlay.js +104 -131
- package/dist/internal/discovery/extensions.js +276 -281
- package/dist/internal/discovery/fs.js +56 -79
- package/dist/internal/discovery/hooks.js +39 -50
- package/dist/internal/discovery/info.js +17 -19
- package/dist/internal/discovery/instructions.js +58 -71
- package/dist/internal/discovery/modules.js +45 -58
- package/dist/internal/discovery/project.d.ts.map +1 -1
- package/dist/internal/discovery/project.js +192 -215
- package/dist/internal/discovery/reminders.js +41 -52
- package/dist/internal/discovery/runtime.js +1 -1
- package/dist/internal/discovery/schedules.js +71 -82
- package/dist/internal/discovery/seed-files.js +21 -32
- package/dist/internal/discovery/services.js +74 -96
- package/dist/internal/discovery/skills.js +77 -94
- package/dist/internal/discovery/subagent.js +79 -95
- package/dist/internal/discovery/tools.js +12 -23
- package/dist/internal/distribution.js +2 -2
- package/dist/internal/docs-site.js +30 -45
- package/dist/internal/duration.js +1 -1
- package/dist/internal/env-file.js +48 -64
- package/dist/internal/eval-judge-model.js +17 -28
- package/dist/internal/eval-run-store.js +265 -254
- package/dist/internal/eval-runner.d.ts +8 -0
- package/dist/internal/eval-runner.d.ts.map +1 -1
- package/dist/internal/eval-runner.js +406 -408
- package/dist/internal/eval-transport.d.ts +24 -0
- package/dist/internal/eval-transport.d.ts.map +1 -0
- package/dist/internal/eval-transport.js +22 -0
- package/dist/internal/evals-client.js +242 -246
- package/dist/internal/event-log.js +72 -120
- package/dist/internal/event-mapper.js +30 -31
- package/dist/internal/factory-resource-channel.js +16 -30
- package/dist/internal/filesystem/errors.js +6 -6
- package/dist/internal/filesystem/format.js +10 -13
- package/dist/internal/filesystem/merge.js +52 -94
- package/dist/internal/filesystem/nearest.js +15 -27
- package/dist/internal/filesystem/scratch.js +65 -85
- package/dist/internal/filesystem/tools.js +221 -241
- package/dist/internal/filesystem/walk.js +76 -143
- package/dist/internal/framework-file-storage.js +118 -139
- package/dist/internal/framework-storage-selection.js +21 -13
- package/dist/internal/frontmatter.js +4 -6
- package/dist/internal/github-fanout.js +50 -64
- package/dist/internal/guest-network.js +96 -109
- package/dist/internal/handleAgentServeTrigger.js +121 -126
- package/dist/internal/host-files.js +73 -88
- package/dist/internal/host-kv.js +21 -36
- package/dist/internal/host-otel.js +22 -19
- package/dist/internal/host-platforms.js +49 -63
- package/dist/internal/hosted-catch-protocol.d.ts +1 -0
- package/dist/internal/hosted-catch-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-catch-protocol.js +1 -0
- package/dist/internal/hosted-catch.d.ts +5 -3
- package/dist/internal/hosted-catch.d.ts.map +1 -1
- package/dist/internal/hosted-catch.js +84 -93
- package/dist/internal/hosted-delivery-protocol.js +32 -8
- package/dist/internal/hosted-delivery.d.ts +13 -1
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +614 -584
- package/dist/internal/hosted-eval-cases.d.ts +21 -0
- package/dist/internal/hosted-eval-cases.d.ts.map +1 -0
- package/dist/internal/hosted-eval-cases.js +162 -0
- package/dist/internal/hosted-execution-diag.js +38 -30
- package/dist/internal/hosted-execution-flush.js +75 -66
- package/dist/internal/hosted-execution-latency.js +16 -8
- package/dist/internal/hosted-managed-automation.js +2 -2
- package/dist/internal/hosting.js +2 -3
- package/dist/internal/http-channel-define.js +4 -1
- package/dist/internal/http-channel.js +101 -112
- package/dist/internal/http-control-plane-session.d.ts +18 -1
- package/dist/internal/http-control-plane-session.d.ts.map +1 -1
- package/dist/internal/http-control-plane-session.js +66 -32
- package/dist/internal/incoming-headers-to-fetch.js +1 -2
- package/dist/internal/init-interview.js +73 -93
- package/dist/internal/init-project.js +182 -214
- package/dist/internal/init-scaffold.js +10 -21
- package/dist/internal/inline-stdio-mcp.js +80 -86
- package/dist/internal/install-cursor-skills.js +231 -273
- package/dist/internal/legacy-command-guard.js +18 -31
- package/dist/internal/listen-port.js +34 -45
- package/dist/internal/local-control-plane.js +293 -307
- package/dist/internal/local-env.js +1 -1
- package/dist/internal/local-ingress.js +15 -9
- package/dist/internal/log-ring.js +1 -2
- package/dist/internal/logs-client.js +207 -227
- package/dist/internal/map-pool.js +24 -38
- package/dist/internal/mcp-endpoint.js +204 -180
- package/dist/internal/mcp-host.js +165 -168
- package/dist/internal/mcp-oauth-on-demand.js +170 -207
- package/dist/internal/mcp-oauth-persist.js +15 -29
- package/dist/internal/mcp-oauth.js +209 -266
- package/dist/internal/named-webhook-secret.d.ts +39 -0
- package/dist/internal/named-webhook-secret.d.ts.map +1 -0
- package/dist/internal/named-webhook-secret.js +47 -0
- package/dist/internal/open-browser.js +2 -3
- package/dist/internal/otel/collector.js +104 -68
- package/dist/internal/otel/config.js +24 -37
- package/dist/internal/otel/http.js +5 -7
- package/dist/internal/otel/mcp.js +3 -12
- package/dist/internal/otel/runtime.js +69 -83
- package/dist/internal/package-inline-stdio.js +57 -65
- package/dist/internal/peer-connections.js +9 -5
- package/dist/internal/platform-schedule-sync.js +39 -54
- package/dist/internal/platform-timers.js +176 -210
- package/dist/internal/playground/static.js +1 -2
- package/dist/internal/playground/toolchain.js +37 -53
- package/dist/internal/playground-proxy.js +230 -270
- package/dist/internal/process-memory-telemetry.js +33 -51
- package/dist/internal/prompt-context.js +3 -6
- package/dist/internal/reminder-control-plane-protocol.js +46 -13
- package/dist/internal/reminder-runner.js +770 -785
- package/dist/internal/reminder-schedule.js +1 -1
- package/dist/internal/reminder-store.js +57 -78
- package/dist/internal/request-error-status.js +1 -3
- package/dist/internal/request-headers.js +2 -2
- package/dist/internal/resolve-prod-target.js +119 -135
- package/dist/internal/resolved-connections.js +16 -6
- package/dist/internal/run-client.js +221 -229
- package/dist/internal/runtime-dispatch-runner.js +18 -43
- package/dist/internal/schedule-runner.js +49 -58
- package/dist/internal/scm/pr-url.js +7 -6
- package/dist/internal/sdk-runner.js +388 -363
- package/dist/internal/serve-restart.js +26 -39
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +1283 -1244
- package/dist/internal/session-cost.js +7 -9
- package/dist/internal/session-engine.d.ts +3 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +2801 -2777
- package/dist/internal/session-links.js +12 -16
- package/dist/internal/session-run-log.js +134 -82
- package/dist/internal/session-store.js +133 -164
- package/dist/internal/sessions-client.js +97 -118
- package/dist/internal/skill-catalog.js +18 -23
- package/dist/internal/skills-sync.js +16 -30
- package/dist/internal/slack-provision-client.js +90 -116
- package/dist/internal/start-log-store.js +48 -67
- package/dist/internal/steering.js +1 -2
- package/dist/internal/storage-coordinator.js +160 -196
- package/dist/internal/store-mirror.js +16 -30
- package/dist/internal/stream-progress.js +6 -8
- package/dist/internal/terminal-style.js +3 -4
- package/dist/internal/testing/scm-continuation-fixtures.js +6 -2
- package/dist/internal/testing/slack-continuation-fixtures.d.ts +26 -0
- package/dist/internal/testing/slack-continuation-fixtures.d.ts.map +1 -0
- package/dist/internal/testing/slack-continuation-fixtures.js +136 -0
- package/dist/internal/tool-catalog.js +11 -5
- package/dist/internal/tool-result.js +1 -1
- package/dist/internal/trajectory.js +19 -22
- package/dist/internal/turn-cost.js +52 -62
- package/dist/internal/turn-governor.js +5 -8
- package/dist/internal/turn-lease-store.js +85 -105
- package/dist/internal/turn-outbox.js +28 -43
- package/dist/internal/update-check.js +231 -259
- package/dist/internal/v2-hosting.js +1 -2
- package/dist/internal/workspace-sync.js +25 -41
- package/dist/internal/workspace.js +111 -139
- package/dist/kv/memory-kv.js +27 -51
- package/dist/memory.js +106 -148
- package/dist/otel.js +5 -8
- package/dist/playground/assets/index-DXm_VXAQ.css +1 -0
- package/dist/playground/assets/{index-Co4CUVTQ.js → index-JekUQERK.js} +45 -45
- package/dist/playground/index.html +2 -2
- package/dist/prompt.js +2 -4
- package/dist/storage-backends/cursor-hosted-v2.js +53 -83
- package/dist/storage-backends/cursor-hosted.js +105 -145
- package/dist/storage-backends/file-kv.js +100 -128
- package/dist/storage-protocol.js +3 -5
- package/dist/storage.js +17 -26
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +20 -18
- package/docs/building-with-agents.md +2 -0
- package/docs/deployment.md +7 -0
- package/docs/guides/bitbucket.md +9 -1
- package/docs/guides/github.md +20 -4
- package/docs/guides/gitlab.md +9 -1
- package/docs/guides/migrate.md +127 -0
- package/docs/reference/cli.md +39 -0
- package/docs/troubleshooting.md +1 -0
- package/package.json +1 -1
- package/skills/debug/SKILL.md +1 -0
- package/skills/github/SKILL.md +23 -0
- package/skills/migrate-v2/SKILL.md +51 -10
- package/dist/docs/assets/chunks/@localSearchIndexroot.BJ8UZggu.js +0 -1
- package/dist/docs/assets/chunks/channel.BTJ5J9FI.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.D4BZ3cVV.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.D4BZ3cVV.js +0 -1
- package/dist/docs/assets/chunks/clone.62tX-O-1.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.DkTs1aEU.js +0 -1
- package/dist/docs/assets/reference_cli.md.GwugN3n-.lean.js +0 -1
- package/dist/docs/assets/troubleshooting.md.Bscj6ODe.js +0 -1
- package/dist/playground/assets/index-C1g_PTTZ.css +0 -1
- /package/dist/docs/assets/{building-with-agents.md.BPjPFxFg.lean.js → building-with-agents.md.Df87rAe1.lean.js} +0 -0
- /package/dist/docs/assets/{deployment.md.BdqTiGdc.lean.js → deployment.md.BYuEcDBv.lean.js} +0 -0
- /package/dist/docs/assets/{reference_skills.md.ClkMoQsV.lean.js → reference_skills.md.C0guGcH0.lean.js} +0 -0
package/dist/filesystem.js
CHANGED
|
@@ -1,48 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
22
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
23
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
24
|
-
var m = o[Symbol.asyncIterator], i;
|
|
25
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
26
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
27
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
28
|
-
};
|
|
29
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
30
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
31
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
32
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
33
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
34
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
35
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
36
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
37
|
-
function fulfill(value) { resume("next", value); }
|
|
38
|
-
function reject(value) { resume("throw", value); }
|
|
39
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
40
|
-
};
|
|
41
|
-
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
42
|
-
var i, p;
|
|
43
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
44
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
45
|
-
};
|
|
46
1
|
import { Buffer } from "node:buffer";
|
|
47
2
|
import { mkdir, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
48
3
|
import path from "node:path";
|
|
@@ -58,7 +13,7 @@ import { isExcludedPath, listFilesFromPaths, mergeSortedByPath, statFromFilePath
|
|
|
58
13
|
* `ListRepoPaths` from `/repo`. Smaller than Origin's 10k default
|
|
59
14
|
* so a recursive listing does not materialize a huge response.
|
|
60
15
|
*/
|
|
61
|
-
export const FILE_SYSTEM_SCAN_LIMIT =
|
|
16
|
+
export const FILE_SYSTEM_SCAN_LIMIT = 1_000;
|
|
62
17
|
export const FILE_SYSTEM_TOOL_NAMES = [
|
|
63
18
|
"Read",
|
|
64
19
|
"LS",
|
|
@@ -300,7 +255,7 @@ function compileGrepPattern(pattern, caseInsensitive, path = "/") {
|
|
|
300
255
|
try {
|
|
301
256
|
return new RegExp(pattern, caseInsensitive === true ? "i" : undefined);
|
|
302
257
|
}
|
|
303
|
-
catch
|
|
258
|
+
catch {
|
|
304
259
|
throw new InvalidGrepPatternError(pattern, path);
|
|
305
260
|
}
|
|
306
261
|
}
|
|
@@ -319,34 +274,19 @@ function normalizeMaxResults(maxResults) {
|
|
|
319
274
|
}
|
|
320
275
|
return Math.max(0, Math.floor(maxResults));
|
|
321
276
|
}
|
|
322
|
-
function limitResults(source, maxResults) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
_d = false;
|
|
334
|
-
const item = _c;
|
|
335
|
-
yield yield __await(item);
|
|
336
|
-
n++;
|
|
337
|
-
if (cap !== undefined && n >= cap) {
|
|
338
|
-
return yield __await(void 0);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
343
|
-
finally {
|
|
344
|
-
try {
|
|
345
|
-
if (!_d && !_a && (_b = source_1.return)) yield __await(_b.call(source_1));
|
|
346
|
-
}
|
|
347
|
-
finally { if (e_1) throw e_1.error; }
|
|
277
|
+
async function* limitResults(source, maxResults) {
|
|
278
|
+
const cap = normalizeMaxResults(maxResults);
|
|
279
|
+
if (cap === 0) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
let n = 0;
|
|
283
|
+
for await (const item of source) {
|
|
284
|
+
yield item;
|
|
285
|
+
n++;
|
|
286
|
+
if (cap !== undefined && n >= cap) {
|
|
287
|
+
return;
|
|
348
288
|
}
|
|
349
|
-
}
|
|
289
|
+
}
|
|
350
290
|
}
|
|
351
291
|
function grepPushdownLimit(query, opts) {
|
|
352
292
|
// Count and files_with_matches paginate after grouping by file.
|
|
@@ -374,65 +314,53 @@ function compareSearchResult(left, right) {
|
|
|
374
314
|
}
|
|
375
315
|
return left.path < right.path ? -1 : left.path > right.path ? 1 : 0;
|
|
376
316
|
}
|
|
377
|
-
export function collectGrepMatches(root, query, opts) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
skippedItems++;
|
|
397
|
-
continue;
|
|
398
|
-
}
|
|
399
|
-
matches.push(match);
|
|
400
|
-
takenItems++;
|
|
401
|
-
if (headLimit !== undefined && takenItems >= headLimit) {
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
if (skippedFiles.has(match.path)) {
|
|
407
|
-
continue;
|
|
408
|
-
}
|
|
409
|
-
if (!acceptedFiles.has(match.path)) {
|
|
410
|
-
if (skippedItems < offset) {
|
|
411
|
-
skippedFiles.add(match.path);
|
|
412
|
-
skippedItems++;
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
if (headLimit !== undefined && takenItems >= headLimit) {
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
acceptedFiles.add(match.path);
|
|
419
|
-
takenItems++;
|
|
420
|
-
}
|
|
421
|
-
matches.push(match);
|
|
317
|
+
export async function collectGrepMatches(root, query, opts) {
|
|
318
|
+
const matches = [];
|
|
319
|
+
const offset = opts.offset !== undefined && opts.offset > 0 ? opts.offset : 0;
|
|
320
|
+
const headLimit = opts.headLimit !== undefined && opts.headLimit > 0 ? opts.headLimit : undefined;
|
|
321
|
+
const skippedFiles = new Set();
|
|
322
|
+
const acceptedFiles = new Set();
|
|
323
|
+
let skippedItems = 0;
|
|
324
|
+
let takenItems = 0;
|
|
325
|
+
const pushdown = grepPushdownLimit(query, {
|
|
326
|
+
outputMode: opts.outputMode,
|
|
327
|
+
offset,
|
|
328
|
+
...(opts.headLimit === undefined ? {} : { headLimit: opts.headLimit }),
|
|
329
|
+
});
|
|
330
|
+
const grepQuery = pushdown === undefined ? query : { ...query, maxResults: pushdown };
|
|
331
|
+
for await (const match of root.grep(grepQuery)) {
|
|
332
|
+
if (opts.outputMode === "content") {
|
|
333
|
+
if (skippedItems < offset) {
|
|
334
|
+
skippedItems++;
|
|
335
|
+
continue;
|
|
422
336
|
}
|
|
337
|
+
matches.push(match);
|
|
338
|
+
takenItems++;
|
|
339
|
+
if (headLimit !== undefined && takenItems >= headLimit) {
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
continue;
|
|
423
343
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
344
|
+
if (skippedFiles.has(match.path)) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (!acceptedFiles.has(match.path)) {
|
|
348
|
+
if (skippedItems < offset) {
|
|
349
|
+
skippedFiles.add(match.path);
|
|
350
|
+
skippedItems++;
|
|
351
|
+
continue;
|
|
428
352
|
}
|
|
429
|
-
|
|
353
|
+
if (headLimit !== undefined && takenItems >= headLimit) {
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
acceptedFiles.add(match.path);
|
|
357
|
+
takenItems++;
|
|
430
358
|
}
|
|
431
|
-
|
|
432
|
-
}
|
|
359
|
+
matches.push(match);
|
|
360
|
+
}
|
|
361
|
+
return matches;
|
|
433
362
|
}
|
|
434
363
|
export function shapeGrepUnion(matches, outputMode) {
|
|
435
|
-
var _a;
|
|
436
364
|
if (outputMode === "files_with_matches") {
|
|
437
365
|
const files = [...new Set(matches.map(match => match.path))];
|
|
438
366
|
return { type: "files", output: { files, count: files.length } };
|
|
@@ -440,7 +368,7 @@ export function shapeGrepUnion(matches, outputMode) {
|
|
|
440
368
|
if (outputMode === "count") {
|
|
441
369
|
const counts = new Map();
|
|
442
370
|
for (const match of matches) {
|
|
443
|
-
counts.set(match.path, (
|
|
371
|
+
counts.set(match.path, (counts.get(match.path) ?? 0) + 1);
|
|
444
372
|
}
|
|
445
373
|
return {
|
|
446
374
|
type: "count",
|
|
@@ -453,7 +381,13 @@ export function shapeGrepUnion(matches, outputMode) {
|
|
|
453
381
|
return {
|
|
454
382
|
type: "content",
|
|
455
383
|
output: {
|
|
456
|
-
matches: matches.map(match => (
|
|
384
|
+
matches: matches.map(match => ({
|
|
385
|
+
file: match.path,
|
|
386
|
+
lineNumber: match.lineNumber,
|
|
387
|
+
line: match.line,
|
|
388
|
+
...(match.beforeContext === undefined ? {} : { beforeContext: match.beforeContext }),
|
|
389
|
+
...(match.afterContext === undefined ? {} : { afterContext: match.afterContext }),
|
|
390
|
+
})),
|
|
457
391
|
totalMatches: matches.length,
|
|
458
392
|
},
|
|
459
393
|
};
|
|
@@ -528,28 +462,26 @@ export function virtualWorkspaceWritePath(relativePath) {
|
|
|
528
462
|
}
|
|
529
463
|
return dest;
|
|
530
464
|
}
|
|
531
|
-
export function writeWorkspaceFilesToRoot(root, files) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
throw new FileSystemConfigError(`Refusing to write the virtual root: ${relativePath}`);
|
|
541
|
-
}
|
|
542
|
-
const fileText = typeof contents === "string"
|
|
543
|
-
? contents
|
|
544
|
-
: Buffer.from(contents.data, "base64").toString("utf8");
|
|
545
|
-
try {
|
|
546
|
-
yield root.write(relativeDest, fileText);
|
|
547
|
-
}
|
|
548
|
-
catch (error) {
|
|
549
|
-
throw new FileSystemConfigError(`workspaceFiles failed to write ${relativePath}: ${error instanceof Error ? error.message : "write failed"}`);
|
|
550
|
-
}
|
|
465
|
+
export async function writeWorkspaceFilesToRoot(root, files) {
|
|
466
|
+
for (const [relativePath, contents] of Object.entries(files)) {
|
|
467
|
+
// Refuse escapes, then write the sanitized relative dest so
|
|
468
|
+
// `localFileSystem` joins against cwd and `tempFs` still normalizes
|
|
469
|
+
// `a.txt` → `/a.txt`. Never forward an absolute host path.
|
|
470
|
+
const dest = virtualWorkspaceWritePath(relativePath);
|
|
471
|
+
const relativeDest = dest.replace(/^\//, "");
|
|
472
|
+
if (relativeDest === "") {
|
|
473
|
+
throw new FileSystemConfigError(`Refusing to write the virtual root: ${relativePath}`);
|
|
551
474
|
}
|
|
552
|
-
|
|
475
|
+
const fileText = typeof contents === "string"
|
|
476
|
+
? contents
|
|
477
|
+
: Buffer.from(contents.data, "base64").toString("utf8");
|
|
478
|
+
try {
|
|
479
|
+
await root.write(relativeDest, fileText);
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
throw new FileSystemConfigError(`workspaceFiles failed to write ${relativePath}: ${error instanceof Error ? error.message : "write failed"}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
553
485
|
}
|
|
554
486
|
function replaceLiteral(args) {
|
|
555
487
|
if (args.replaceAll) {
|
|
@@ -607,22 +539,20 @@ function applyExactEdit(args) {
|
|
|
607
539
|
* this helper's contract; FileSystem implementations do not
|
|
608
540
|
* implement edit. Native StrReplace calls this.
|
|
609
541
|
*/
|
|
610
|
-
export function strReplaceOnFileSystem(root, query) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
path: query.path,
|
|
622
|
-
});
|
|
623
|
-
yield root.write(query.path, applied.contents);
|
|
624
|
-
return { occurrencesModified: applied.occurrencesModified };
|
|
542
|
+
export async function strReplaceOnFileSystem(root, query) {
|
|
543
|
+
const existing = await root.read(query.path);
|
|
544
|
+
if (typeof existing !== "string") {
|
|
545
|
+
throw new EditError(query.path, `${query.path} is not text`);
|
|
546
|
+
}
|
|
547
|
+
const applied = applyExactEdit({
|
|
548
|
+
existing,
|
|
549
|
+
oldText: query.oldText,
|
|
550
|
+
newText: query.newText,
|
|
551
|
+
replaceAll: query.replaceAll === true,
|
|
552
|
+
path: query.path,
|
|
625
553
|
});
|
|
554
|
+
await root.write(query.path, applied.contents);
|
|
555
|
+
return { occurrencesModified: applied.occurrencesModified };
|
|
626
556
|
}
|
|
627
557
|
/** Native Read offset/limit: 1-indexed, negative offset counts from the end. */
|
|
628
558
|
export function sliceReadContent(content, offset, limit) {
|
|
@@ -631,14 +561,14 @@ export function sliceReadContent(content, offset, limit) {
|
|
|
631
561
|
}
|
|
632
562
|
const lines = content === "" ? [] : content.split("\n");
|
|
633
563
|
const total = lines.length;
|
|
634
|
-
const effectiveOffset = offset
|
|
635
|
-
const effectiveLimit = limit
|
|
564
|
+
const effectiveOffset = offset ?? 1;
|
|
565
|
+
const effectiveLimit = limit ?? (effectiveOffset < 0 ? Math.abs(effectiveOffset) : total);
|
|
636
566
|
const startIndex = effectiveOffset < 0 ? Math.max(0, total + effectiveOffset) : Math.max(0, effectiveOffset - 1);
|
|
637
567
|
const endIndex = Math.min(total, startIndex + effectiveLimit);
|
|
638
568
|
return lines.slice(startIndex, endIndex).join("\n");
|
|
639
569
|
}
|
|
640
|
-
function emptySearch(_query) {
|
|
641
|
-
|
|
570
|
+
async function* emptySearch(_query) { }
|
|
571
|
+
async function* emptyStream() { }
|
|
642
572
|
/**
|
|
643
573
|
* A FileSystem with no files. Use as an overlay leaf or a missing
|
|
644
574
|
* catalog so a miss stays {@link FileNotFoundError} instead of
|
|
@@ -649,32 +579,22 @@ export function emptyFs() {
|
|
|
649
579
|
return {
|
|
650
580
|
list: () => emptyStream(),
|
|
651
581
|
glob: () => emptyStream(),
|
|
652
|
-
grep(query) {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
yield __await(yield* __asyncDelegator(__asyncValues(emptyStream())));
|
|
656
|
-
});
|
|
582
|
+
async *grep(query) {
|
|
583
|
+
compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
|
|
584
|
+
yield* emptyStream();
|
|
657
585
|
},
|
|
658
586
|
search: emptySearch,
|
|
659
|
-
stat(path) {
|
|
660
|
-
return
|
|
661
|
-
return statFromFilePaths([], path);
|
|
662
|
-
});
|
|
587
|
+
async stat(path) {
|
|
588
|
+
return statFromFilePaths([], path);
|
|
663
589
|
},
|
|
664
|
-
read(path) {
|
|
665
|
-
|
|
666
|
-
throw new FileNotFoundError(normalizeFsPath(path));
|
|
667
|
-
});
|
|
590
|
+
async read(path) {
|
|
591
|
+
throw new FileNotFoundError(normalizeFsPath(path));
|
|
668
592
|
},
|
|
669
|
-
write(path) {
|
|
670
|
-
|
|
671
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
672
|
-
});
|
|
593
|
+
async write(path) {
|
|
594
|
+
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
673
595
|
},
|
|
674
|
-
delete(path) {
|
|
675
|
-
|
|
676
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
677
|
-
});
|
|
596
|
+
async delete(path) {
|
|
597
|
+
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
678
598
|
},
|
|
679
599
|
};
|
|
680
600
|
}
|
|
@@ -697,109 +617,84 @@ export function tempFs(files = {}) {
|
|
|
697
617
|
size: typeof content === "string" ? content.length : content.byteLength,
|
|
698
618
|
})), prefix, options);
|
|
699
619
|
},
|
|
700
|
-
stat(path) {
|
|
701
|
-
return
|
|
702
|
-
return statFromFilePaths(store.keys(), path);
|
|
703
|
-
});
|
|
620
|
+
async stat(path) {
|
|
621
|
+
return statFromFilePaths(store.keys(), path);
|
|
704
622
|
},
|
|
705
623
|
};
|
|
706
624
|
return {
|
|
707
625
|
list(prefix, options) {
|
|
708
626
|
return listed.list(prefix, options);
|
|
709
627
|
},
|
|
710
|
-
stat(path) {
|
|
711
|
-
return
|
|
712
|
-
return listed.stat(path);
|
|
713
|
-
});
|
|
628
|
+
async stat(path) {
|
|
629
|
+
return listed.stat(path);
|
|
714
630
|
},
|
|
715
|
-
read(inputPath) {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
return content;
|
|
723
|
-
});
|
|
631
|
+
async read(inputPath) {
|
|
632
|
+
const path = normalizeFsPath(inputPath);
|
|
633
|
+
const content = store.get(path);
|
|
634
|
+
if (content === undefined) {
|
|
635
|
+
throw new FileNotFoundError(path);
|
|
636
|
+
}
|
|
637
|
+
return content;
|
|
724
638
|
},
|
|
725
|
-
grep(query) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
path: scope,
|
|
746
|
-
content: fileSystemText(exact),
|
|
747
|
-
regex,
|
|
748
|
-
}))));
|
|
749
|
-
return yield __await(void 0);
|
|
750
|
-
}
|
|
751
|
-
try {
|
|
752
|
-
for (var _d = true, _e = __asyncValues(listed.list(scope === "/" ? undefined : scope, query.excludes === undefined ? undefined : { excludes: query.excludes })), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
753
|
-
_c = _f.value;
|
|
754
|
-
_d = false;
|
|
755
|
-
const entry = _c;
|
|
756
|
-
if (query.glob !== undefined &&
|
|
757
|
-
!pathMatchesGlob(entry.path, scope, query.glob, {
|
|
758
|
-
matchBasename: true,
|
|
759
|
-
})) {
|
|
760
|
-
continue;
|
|
761
|
-
}
|
|
762
|
-
const content = store.get(entry.path);
|
|
763
|
-
if (content === undefined) {
|
|
764
|
-
continue;
|
|
765
|
-
}
|
|
766
|
-
yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({
|
|
767
|
-
path: entry.path,
|
|
768
|
-
content: fileSystemText(content),
|
|
769
|
-
regex,
|
|
770
|
-
}))));
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
774
|
-
finally {
|
|
775
|
-
try {
|
|
776
|
-
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
777
|
-
}
|
|
778
|
-
finally { if (e_3) throw e_3.error; }
|
|
779
|
-
}
|
|
639
|
+
async *grep(query) {
|
|
640
|
+
yield* limitResults(uncapped(), query.maxResults);
|
|
641
|
+
async function* uncapped() {
|
|
642
|
+
const regex = compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
|
|
643
|
+
const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
|
|
644
|
+
const exact = store.get(scope);
|
|
645
|
+
if (scope !== "/" && exact !== undefined) {
|
|
646
|
+
if (query.glob !== undefined &&
|
|
647
|
+
!pathMatchesGlob(scope, scope, query.glob, {
|
|
648
|
+
matchBasename: true,
|
|
649
|
+
})) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (isExcludedPath(scope, query.excludes)) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
yield* grepFileContent({
|
|
656
|
+
path: scope,
|
|
657
|
+
content: fileSystemText(exact),
|
|
658
|
+
regex,
|
|
780
659
|
});
|
|
660
|
+
return;
|
|
781
661
|
}
|
|
782
|
-
|
|
662
|
+
for await (const entry of listed.list(scope === "/" ? undefined : scope, query.excludes === undefined ? undefined : { excludes: query.excludes })) {
|
|
663
|
+
if (query.glob !== undefined &&
|
|
664
|
+
!pathMatchesGlob(entry.path, scope, query.glob, {
|
|
665
|
+
matchBasename: true,
|
|
666
|
+
})) {
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
const content = store.get(entry.path);
|
|
670
|
+
if (content === undefined) {
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
yield* grepFileContent({
|
|
674
|
+
path: entry.path,
|
|
675
|
+
content: fileSystemText(content),
|
|
676
|
+
regex,
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
}
|
|
783
680
|
},
|
|
784
|
-
glob(pattern, dir, options) {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
681
|
+
async *glob(pattern, dir, options) {
|
|
682
|
+
const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
|
|
683
|
+
yield* globFromList(listed.list(scope === "/" ? undefined : scope), {
|
|
684
|
+
pattern,
|
|
685
|
+
dir: scope,
|
|
686
|
+
...(options?.limit === undefined ? {} : { limit: options.limit }),
|
|
788
687
|
});
|
|
789
688
|
},
|
|
790
|
-
write(inputPath, contents) {
|
|
791
|
-
|
|
792
|
-
store.set(normalizeFsPath(inputPath), contents);
|
|
793
|
-
});
|
|
689
|
+
async write(inputPath, contents) {
|
|
690
|
+
store.set(normalizeFsPath(inputPath), contents);
|
|
794
691
|
},
|
|
795
|
-
delete(inputPath) {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
store.delete(path);
|
|
802
|
-
});
|
|
692
|
+
async delete(inputPath) {
|
|
693
|
+
const path = normalizeFsPath(inputPath);
|
|
694
|
+
if (!store.has(path)) {
|
|
695
|
+
throw new FileNotFoundError(path);
|
|
696
|
+
}
|
|
697
|
+
store.delete(path);
|
|
803
698
|
},
|
|
804
699
|
search: emptySearch,
|
|
805
700
|
};
|
|
@@ -813,48 +708,44 @@ function throwLocalReadError(error, filePath) {
|
|
|
813
708
|
function skipWalkDir(name) {
|
|
814
709
|
return name === ".git" || name === "node_modules";
|
|
815
710
|
}
|
|
816
|
-
function walkLocalFiles(rootDir) {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
if (entry.
|
|
839
|
-
|
|
840
|
-
stack.push(full);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
else if (entry.isFile()) {
|
|
844
|
-
found.push(full);
|
|
711
|
+
async function walkLocalFiles(rootDir) {
|
|
712
|
+
const found = [];
|
|
713
|
+
const stack = [rootDir];
|
|
714
|
+
while (stack.length > 0) {
|
|
715
|
+
const current = stack.pop();
|
|
716
|
+
if (current === undefined) {
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
let entries;
|
|
720
|
+
try {
|
|
721
|
+
entries = await readdir(current, { withFileTypes: true });
|
|
722
|
+
}
|
|
723
|
+
catch {
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
for (const entry of entries) {
|
|
727
|
+
const full = path.join(current, entry.name);
|
|
728
|
+
// Same as the pre-root host walk and native LS/Glob/Grep: Dirent
|
|
729
|
+
// isDirectory/isFile do not follow links, so workspace `memory/`
|
|
730
|
+
// and other symlinks are not enumerated. Exact-path read/stat still
|
|
731
|
+
// follow.
|
|
732
|
+
if (entry.isDirectory()) {
|
|
733
|
+
if (!skipWalkDir(entry.name)) {
|
|
734
|
+
stack.push(full);
|
|
845
735
|
}
|
|
846
736
|
}
|
|
737
|
+
else if (entry.isFile()) {
|
|
738
|
+
found.push(full);
|
|
739
|
+
}
|
|
847
740
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
741
|
+
}
|
|
742
|
+
found.sort((left, right) => left.localeCompare(right));
|
|
743
|
+
return found;
|
|
851
744
|
}
|
|
852
|
-
function listLocalFiles(rootDir) {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
});
|
|
745
|
+
async function* listLocalFiles(rootDir) {
|
|
746
|
+
for (const filePath of await walkLocalFiles(rootDir)) {
|
|
747
|
+
yield { path: filePath };
|
|
748
|
+
}
|
|
858
749
|
}
|
|
859
750
|
/**
|
|
860
751
|
* Host-disk FileSystem. Relative paths resolve against `cwd`; absolute
|
|
@@ -867,128 +758,100 @@ export function localFileSystem(options) {
|
|
|
867
758
|
const cwd = path.resolve(options.cwd);
|
|
868
759
|
const resolvePath = (input) => path.isAbsolute(input) ? path.resolve(input) : path.resolve(cwd, input);
|
|
869
760
|
return {
|
|
870
|
-
list(prefix, options) {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
for (var _d = true, _e = __asyncValues(listLocalFiles(dirPath)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
879
|
-
_c = _f.value;
|
|
880
|
-
_d = false;
|
|
881
|
-
const entry = _c;
|
|
882
|
-
if (!isExcludedPath(entry.path, options === null || options === void 0 ? void 0 : options.excludes)) {
|
|
883
|
-
yield yield __await(entry);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
888
|
-
finally {
|
|
889
|
-
try {
|
|
890
|
-
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
891
|
-
}
|
|
892
|
-
finally { if (e_4) throw e_4.error; }
|
|
893
|
-
}
|
|
894
|
-
});
|
|
761
|
+
async *list(prefix, options) {
|
|
762
|
+
yield* limitResults(uncapped(), options?.limit);
|
|
763
|
+
async function* uncapped() {
|
|
764
|
+
const dirPath = prefix === undefined || prefix === "" || prefix === "." ? cwd : resolvePath(prefix);
|
|
765
|
+
for await (const entry of listLocalFiles(dirPath)) {
|
|
766
|
+
if (!isExcludedPath(entry.path, options?.excludes)) {
|
|
767
|
+
yield entry;
|
|
768
|
+
}
|
|
895
769
|
}
|
|
896
|
-
}
|
|
770
|
+
}
|
|
897
771
|
},
|
|
898
|
-
stat(probePath) {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
772
|
+
async stat(probePath) {
|
|
773
|
+
const filePath = resolvePath(probePath);
|
|
774
|
+
try {
|
|
775
|
+
const info = await stat(filePath);
|
|
776
|
+
return { kind: info.isDirectory() ? "directory" : "file" };
|
|
777
|
+
}
|
|
778
|
+
catch {
|
|
779
|
+
return { kind: "missing" };
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
async read(inputPath) {
|
|
783
|
+
const filePath = resolvePath(inputPath);
|
|
784
|
+
try {
|
|
785
|
+
const bytes = await readFile(filePath);
|
|
786
|
+
if (detectImageMimeType(bytes, filePath) !== undefined) {
|
|
787
|
+
return new Uint8Array(bytes);
|
|
907
788
|
}
|
|
908
|
-
|
|
789
|
+
return bytes.toString("utf8");
|
|
790
|
+
}
|
|
791
|
+
catch (error) {
|
|
792
|
+
throwLocalReadError(error, filePath);
|
|
793
|
+
}
|
|
909
794
|
},
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
795
|
+
async *grep(query) {
|
|
796
|
+
yield* limitResults(uncapped(), query.maxResults);
|
|
797
|
+
async function* uncapped() {
|
|
798
|
+
const searchRoot = resolvePath(query.path ?? cwd);
|
|
799
|
+
const regex = compileGrepPattern(query.pattern, query.caseInsensitive, searchRoot);
|
|
800
|
+
let filesToSearch;
|
|
913
801
|
try {
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
return new Uint8Array(bytes);
|
|
917
|
-
}
|
|
918
|
-
return bytes.toString("utf8");
|
|
802
|
+
const info = await stat(searchRoot);
|
|
803
|
+
filesToSearch = info.isFile() ? [searchRoot] : await walkLocalFiles(searchRoot);
|
|
919
804
|
}
|
|
920
805
|
catch (error) {
|
|
921
|
-
throwLocalReadError(error,
|
|
806
|
+
throwLocalReadError(error, searchRoot);
|
|
922
807
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
for (const filePath of filesToSearch) {
|
|
942
|
-
if (query.glob !== undefined &&
|
|
943
|
-
!pathMatchesGlob(filePath, searchRoot, query.glob, {
|
|
944
|
-
matchBasename: true,
|
|
945
|
-
})) {
|
|
946
|
-
continue;
|
|
947
|
-
}
|
|
948
|
-
if (isExcludedPath(filePath, query.excludes)) {
|
|
949
|
-
continue;
|
|
950
|
-
}
|
|
951
|
-
let content;
|
|
952
|
-
try {
|
|
953
|
-
content = yield __await(readFile(filePath, "utf8"));
|
|
954
|
-
}
|
|
955
|
-
catch (_b) {
|
|
956
|
-
continue;
|
|
957
|
-
}
|
|
958
|
-
yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({ path: filePath, content, regex }))));
|
|
959
|
-
}
|
|
960
|
-
});
|
|
808
|
+
for (const filePath of filesToSearch) {
|
|
809
|
+
if (query.glob !== undefined &&
|
|
810
|
+
!pathMatchesGlob(filePath, searchRoot, query.glob, {
|
|
811
|
+
matchBasename: true,
|
|
812
|
+
})) {
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
if (isExcludedPath(filePath, query.excludes)) {
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
let content;
|
|
819
|
+
try {
|
|
820
|
+
content = await readFile(filePath, "utf8");
|
|
821
|
+
}
|
|
822
|
+
catch {
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
yield* grepFileContent({ path: filePath, content, regex });
|
|
961
826
|
}
|
|
962
|
-
}
|
|
827
|
+
}
|
|
963
828
|
},
|
|
964
|
-
glob(pattern, dir, options) {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
829
|
+
async *glob(pattern, dir, options) {
|
|
830
|
+
const dirPath = dir === undefined || dir === "" || dir === "." ? cwd : resolvePath(dir);
|
|
831
|
+
yield* globFromList(listLocalFiles(dirPath), {
|
|
832
|
+
pattern,
|
|
833
|
+
dir: dirPath,
|
|
834
|
+
...(options?.limit === undefined ? {} : { limit: options.limit }),
|
|
968
835
|
});
|
|
969
836
|
},
|
|
970
|
-
write(inputPath, contents) {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
});
|
|
837
|
+
async write(inputPath, contents) {
|
|
838
|
+
const filePath = resolvePath(inputPath);
|
|
839
|
+
try {
|
|
840
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
841
|
+
await writeFile(filePath, contents, "utf8");
|
|
842
|
+
}
|
|
843
|
+
catch (error) {
|
|
844
|
+
throw new WriteFailedError(filePath, fsErrorMessage(error, `write failed: ${filePath}`));
|
|
845
|
+
}
|
|
981
846
|
},
|
|
982
|
-
delete(inputPath) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
});
|
|
847
|
+
async delete(inputPath) {
|
|
848
|
+
const filePath = resolvePath(inputPath);
|
|
849
|
+
try {
|
|
850
|
+
await rm(filePath);
|
|
851
|
+
}
|
|
852
|
+
catch (error) {
|
|
853
|
+
throwLocalReadError(error, filePath);
|
|
854
|
+
}
|
|
992
855
|
},
|
|
993
856
|
search: emptySearch,
|
|
994
857
|
};
|
|
@@ -1028,80 +891,35 @@ function toParentPath(path, prefix) {
|
|
|
1028
891
|
}
|
|
1029
892
|
return path.startsWith("/") ? `${prefix}${path}` : `${prefix}/${path}`;
|
|
1030
893
|
}
|
|
1031
|
-
function mapMountEntries(source, prefix) {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
try {
|
|
1036
|
-
for (var _d = true, source_2 = __asyncValues(source), source_2_1; source_2_1 = yield __await(source_2.next()), _a = source_2_1.done, !_a; _d = true) {
|
|
1037
|
-
_c = source_2_1.value;
|
|
1038
|
-
_d = false;
|
|
1039
|
-
const entry = _c;
|
|
1040
|
-
yield yield __await(Object.assign(Object.assign({}, entry), { path: toParentPath(entry.path, prefix) }));
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1044
|
-
finally {
|
|
1045
|
-
try {
|
|
1046
|
-
if (!_d && !_a && (_b = source_2.return)) yield __await(_b.call(source_2));
|
|
1047
|
-
}
|
|
1048
|
-
finally { if (e_5) throw e_5.error; }
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
catch (error) {
|
|
1052
|
-
throw remapPathError(error, prefix);
|
|
894
|
+
async function* mapMountEntries(source, prefix) {
|
|
895
|
+
try {
|
|
896
|
+
for await (const entry of source) {
|
|
897
|
+
yield { ...entry, path: toParentPath(entry.path, prefix) };
|
|
1053
898
|
}
|
|
1054
|
-
}
|
|
899
|
+
}
|
|
900
|
+
catch (error) {
|
|
901
|
+
throw remapPathError(error, prefix);
|
|
902
|
+
}
|
|
1055
903
|
}
|
|
1056
|
-
function mapMountGrep(source, prefix) {
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
try {
|
|
1061
|
-
for (var _d = true, source_3 = __asyncValues(source), source_3_1; source_3_1 = yield __await(source_3.next()), _a = source_3_1.done, !_a; _d = true) {
|
|
1062
|
-
_c = source_3_1.value;
|
|
1063
|
-
_d = false;
|
|
1064
|
-
const hit = _c;
|
|
1065
|
-
yield yield __await(Object.assign(Object.assign({}, hit), { path: toParentPath(hit.path, prefix) }));
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1069
|
-
finally {
|
|
1070
|
-
try {
|
|
1071
|
-
if (!_d && !_a && (_b = source_3.return)) yield __await(_b.call(source_3));
|
|
1072
|
-
}
|
|
1073
|
-
finally { if (e_6) throw e_6.error; }
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
catch (error) {
|
|
1077
|
-
throw remapPathError(error, prefix);
|
|
904
|
+
async function* mapMountGrep(source, prefix) {
|
|
905
|
+
try {
|
|
906
|
+
for await (const hit of source) {
|
|
907
|
+
yield { ...hit, path: toParentPath(hit.path, prefix) };
|
|
1078
908
|
}
|
|
1079
|
-
}
|
|
909
|
+
}
|
|
910
|
+
catch (error) {
|
|
911
|
+
throw remapPathError(error, prefix);
|
|
912
|
+
}
|
|
1080
913
|
}
|
|
1081
|
-
function mapMountSearch(source, prefix) {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
try {
|
|
1086
|
-
for (var _d = true, source_4 = __asyncValues(source), source_4_1; source_4_1 = yield __await(source_4.next()), _a = source_4_1.done, !_a; _d = true) {
|
|
1087
|
-
_c = source_4_1.value;
|
|
1088
|
-
_d = false;
|
|
1089
|
-
const hit = _c;
|
|
1090
|
-
yield yield __await(Object.assign(Object.assign({}, hit), { path: toParentPath(hit.path, prefix) }));
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1094
|
-
finally {
|
|
1095
|
-
try {
|
|
1096
|
-
if (!_d && !_a && (_b = source_4.return)) yield __await(_b.call(source_4));
|
|
1097
|
-
}
|
|
1098
|
-
finally { if (e_7) throw e_7.error; }
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
catch (error) {
|
|
1102
|
-
throw remapPathError(error, prefix);
|
|
914
|
+
async function* mapMountSearch(source, prefix) {
|
|
915
|
+
try {
|
|
916
|
+
for await (const hit of source) {
|
|
917
|
+
yield { ...hit, path: toParentPath(hit.path, prefix) };
|
|
1103
918
|
}
|
|
1104
|
-
}
|
|
919
|
+
}
|
|
920
|
+
catch (error) {
|
|
921
|
+
throw remapPathError(error, prefix);
|
|
922
|
+
}
|
|
1105
923
|
}
|
|
1106
924
|
function childSearchQuery(query, prefix) {
|
|
1107
925
|
if (query.targetDirectories === undefined || query.targetDirectories.length === 0) {
|
|
@@ -1112,21 +930,21 @@ function childSearchQuery(query, prefix) {
|
|
|
1112
930
|
const normalized = normalizeFsPath(dir);
|
|
1113
931
|
// `/` is every mount, the same way grep at `/` fans out.
|
|
1114
932
|
if (normalized === "/") {
|
|
1115
|
-
return
|
|
933
|
+
return { ...query, targetDirectories: undefined };
|
|
1116
934
|
}
|
|
1117
935
|
if (!pathHasSegmentPrefix({ path: normalized, prefix })) {
|
|
1118
936
|
continue;
|
|
1119
937
|
}
|
|
1120
938
|
const child = toChildPath(normalized, prefix);
|
|
1121
939
|
if (child === "/") {
|
|
1122
|
-
return
|
|
940
|
+
return { ...query, targetDirectories: undefined };
|
|
1123
941
|
}
|
|
1124
942
|
dirs.push(child);
|
|
1125
943
|
}
|
|
1126
944
|
if (dirs.length === 0) {
|
|
1127
945
|
return undefined;
|
|
1128
946
|
}
|
|
1129
|
-
return
|
|
947
|
+
return { ...query, targetDirectories: dirs };
|
|
1130
948
|
}
|
|
1131
949
|
/**
|
|
1132
950
|
* Longest-prefix compose, path-segment match. Every verb is
|
|
@@ -1159,161 +977,125 @@ export function unionFs(mounts) {
|
|
|
1159
977
|
const noMount = (path) => {
|
|
1160
978
|
throw new NoMountError(path);
|
|
1161
979
|
};
|
|
1162
|
-
const forward = (path, run) =>
|
|
980
|
+
const forward = async (path, run) => {
|
|
1163
981
|
const mount = longestMount(path, entries);
|
|
1164
982
|
if (mount === undefined) {
|
|
1165
983
|
return noMount(path);
|
|
1166
984
|
}
|
|
1167
985
|
const childPath = toChildPath(path, mount.prefix);
|
|
1168
986
|
try {
|
|
1169
|
-
return
|
|
987
|
+
return await run(mount.fs, childPath);
|
|
1170
988
|
}
|
|
1171
989
|
catch (error) {
|
|
1172
990
|
throw remapPathError(error, mount.prefix);
|
|
1173
991
|
}
|
|
1174
|
-
}
|
|
992
|
+
};
|
|
1175
993
|
const isRootPath = (value) => value === undefined || value === "" || value === "/";
|
|
1176
994
|
return {
|
|
1177
|
-
list(prefix, options) {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
yield __await(yield* __asyncDelegator(__asyncValues(mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.list(undefined, options), mount.prefix)), { unique: true }))));
|
|
1184
|
-
return yield __await(void 0);
|
|
1185
|
-
}
|
|
1186
|
-
const path = normalizeFsPath(prefix !== null && prefix !== void 0 ? prefix : "/");
|
|
1187
|
-
const mount = longestMount(path, entries);
|
|
1188
|
-
if (mount === undefined) {
|
|
1189
|
-
return yield __await(void 0);
|
|
1190
|
-
}
|
|
1191
|
-
const childPath = toChildPath(path, mount.prefix);
|
|
1192
|
-
yield __await(yield* __asyncDelegator(__asyncValues(mapMountEntries(mount.fs.list(childPath === "/" ? undefined : childPath, options), mount.prefix))));
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
});
|
|
1196
|
-
},
|
|
1197
|
-
stat(path) {
|
|
1198
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1199
|
-
const normalized = normalizeFsPath(path);
|
|
1200
|
-
if (normalized === "/") {
|
|
1201
|
-
return { kind: "directory" };
|
|
995
|
+
async *list(prefix, options) {
|
|
996
|
+
yield* limitResults(uncapped(), options?.limit);
|
|
997
|
+
async function* uncapped() {
|
|
998
|
+
if (isRootPath(prefix)) {
|
|
999
|
+
yield* mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.list(undefined, options), mount.prefix)), { unique: true });
|
|
1000
|
+
return;
|
|
1202
1001
|
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
}
|
|
1206
|
-
const mount = longestMount(normalized, entries);
|
|
1002
|
+
const path = normalizeFsPath(prefix ?? "/");
|
|
1003
|
+
const mount = longestMount(path, entries);
|
|
1207
1004
|
if (mount === undefined) {
|
|
1208
|
-
return
|
|
1005
|
+
return;
|
|
1209
1006
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1007
|
+
const childPath = toChildPath(path, mount.prefix);
|
|
1008
|
+
yield* mapMountEntries(mount.fs.list(childPath === "/" ? undefined : childPath, options), mount.prefix);
|
|
1009
|
+
}
|
|
1212
1010
|
},
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
return
|
|
1217
|
-
}
|
|
1011
|
+
async stat(path) {
|
|
1012
|
+
const normalized = normalizeFsPath(path);
|
|
1013
|
+
if (normalized === "/") {
|
|
1014
|
+
return { kind: "directory" };
|
|
1015
|
+
}
|
|
1016
|
+
if (entries.some(entry => entry.prefix === normalized)) {
|
|
1017
|
+
return { kind: "directory" };
|
|
1018
|
+
}
|
|
1019
|
+
const mount = longestMount(normalized, entries);
|
|
1020
|
+
if (mount === undefined) {
|
|
1021
|
+
return { kind: "missing" };
|
|
1022
|
+
}
|
|
1023
|
+
return mount.fs.stat(toChildPath(normalized, mount.prefix));
|
|
1218
1024
|
},
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
return forward(normalized, (fs, childPath) => fs.write(childPath, contents));
|
|
1223
|
-
});
|
|
1025
|
+
async read(path) {
|
|
1026
|
+
const normalized = normalizeFsPath(path);
|
|
1027
|
+
return forward(normalized, (fs, childPath) => fs.read(childPath));
|
|
1224
1028
|
},
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
return forward(normalized, (fs, childPath) => fs.delete(childPath));
|
|
1229
|
-
});
|
|
1029
|
+
async write(path, contents) {
|
|
1030
|
+
const normalized = normalizeFsPath(path);
|
|
1031
|
+
return forward(normalized, (fs, childPath) => fs.write(childPath, contents));
|
|
1230
1032
|
},
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
function uncapped() {
|
|
1235
|
-
return __asyncGenerator(this, arguments, function* uncapped_5() {
|
|
1236
|
-
const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
|
|
1237
|
-
if (scope === "/") {
|
|
1238
|
-
yield __await(yield* __asyncDelegator(__asyncValues(mergeSorted(entries.map(mount => mapMountGrep(mount.fs.grep(Object.assign(Object.assign({}, query), { path: undefined })), mount.prefix)), { compare: compareGrepResult }))));
|
|
1239
|
-
return yield __await(void 0);
|
|
1240
|
-
}
|
|
1241
|
-
const mount = longestMount(scope, entries);
|
|
1242
|
-
if (mount === undefined) {
|
|
1243
|
-
return yield __await(void 0);
|
|
1244
|
-
}
|
|
1245
|
-
const childPath = toChildPath(scope, mount.prefix);
|
|
1246
|
-
yield __await(yield* __asyncDelegator(__asyncValues(mapMountGrep(mount.fs.grep(Object.assign(Object.assign({}, query), { path: childPath === "/" ? undefined : childPath })), mount.prefix))));
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
});
|
|
1033
|
+
async delete(path) {
|
|
1034
|
+
const normalized = normalizeFsPath(path);
|
|
1035
|
+
return forward(normalized, (fs, childPath) => fs.delete(childPath));
|
|
1250
1036
|
},
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
const childQuery = childSearchQuery(query, mount.prefix);
|
|
1259
|
-
if (childQuery === undefined) {
|
|
1260
|
-
continue;
|
|
1261
|
-
}
|
|
1262
|
-
sources.push(mapMountSearch(mount.fs.search(childQuery), mount.prefix));
|
|
1263
|
-
}
|
|
1264
|
-
yield __await(yield* __asyncDelegator(__asyncValues(mergeSorted(sources, { compare: compareSearchResult }))));
|
|
1265
|
-
});
|
|
1037
|
+
async *grep(query) {
|
|
1038
|
+
yield* limitResults(uncapped(), query.maxResults);
|
|
1039
|
+
async function* uncapped() {
|
|
1040
|
+
const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
|
|
1041
|
+
if (scope === "/") {
|
|
1042
|
+
yield* mergeSorted(entries.map(mount => mapMountGrep(mount.fs.grep({ ...query, path: undefined }), mount.prefix)), { compare: compareGrepResult });
|
|
1043
|
+
return;
|
|
1266
1044
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
return __asyncGenerator(this, arguments, function* glob_3() {
|
|
1271
|
-
yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), options === null || options === void 0 ? void 0 : options.limit))));
|
|
1272
|
-
function uncapped() {
|
|
1273
|
-
return __asyncGenerator(this, arguments, function* uncapped_7() {
|
|
1274
|
-
const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
|
|
1275
|
-
if (scope === "/") {
|
|
1276
|
-
yield __await(yield* __asyncDelegator(__asyncValues(mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.glob(pattern, undefined, options), mount.prefix)), { unique: true }))));
|
|
1277
|
-
return yield __await(void 0);
|
|
1278
|
-
}
|
|
1279
|
-
const mount = longestMount(scope, entries);
|
|
1280
|
-
if (mount === undefined) {
|
|
1281
|
-
return yield __await(void 0);
|
|
1282
|
-
}
|
|
1283
|
-
const childPath = toChildPath(scope, mount.prefix);
|
|
1284
|
-
yield __await(yield* __asyncDelegator(__asyncValues(mapMountEntries(mount.fs.glob(pattern, childPath === "/" ? undefined : childPath, options), mount.prefix))));
|
|
1285
|
-
});
|
|
1045
|
+
const mount = longestMount(scope, entries);
|
|
1046
|
+
if (mount === undefined) {
|
|
1047
|
+
return;
|
|
1286
1048
|
}
|
|
1287
|
-
|
|
1049
|
+
const childPath = toChildPath(scope, mount.prefix);
|
|
1050
|
+
yield* mapMountGrep(mount.fs.grep({
|
|
1051
|
+
...query,
|
|
1052
|
+
path: childPath === "/" ? undefined : childPath,
|
|
1053
|
+
}), mount.prefix);
|
|
1054
|
+
}
|
|
1288
1055
|
},
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
function
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
_d = false;
|
|
1300
|
-
const entry = _c;
|
|
1301
|
-
paths.push(entry.path);
|
|
1056
|
+
async *search(query) {
|
|
1057
|
+
yield* limitResults(uncapped(), query.maxResults);
|
|
1058
|
+
async function* uncapped() {
|
|
1059
|
+
const sources = [];
|
|
1060
|
+
for (const mount of entries) {
|
|
1061
|
+
const childQuery = childSearchQuery(query, mount.prefix);
|
|
1062
|
+
if (childQuery === undefined) {
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
sources.push(mapMountSearch(mount.fs.search(childQuery), mount.prefix));
|
|
1302
1066
|
}
|
|
1067
|
+
yield* mergeSorted(sources, { compare: compareSearchResult });
|
|
1303
1068
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1069
|
+
},
|
|
1070
|
+
async *glob(pattern, dir, options) {
|
|
1071
|
+
yield* limitResults(uncapped(), options?.limit);
|
|
1072
|
+
async function* uncapped() {
|
|
1073
|
+
const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
|
|
1074
|
+
if (scope === "/") {
|
|
1075
|
+
yield* mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.glob(pattern, undefined, options), mount.prefix)), { unique: true });
|
|
1076
|
+
return;
|
|
1308
1077
|
}
|
|
1309
|
-
|
|
1078
|
+
const mount = longestMount(scope, entries);
|
|
1079
|
+
if (mount === undefined) {
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const childPath = toChildPath(scope, mount.prefix);
|
|
1083
|
+
yield* mapMountEntries(mount.fs.glob(pattern, childPath === "/" ? undefined : childPath, options), mount.prefix);
|
|
1310
1084
|
}
|
|
1085
|
+
},
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
async function collectLayerPaths(layer) {
|
|
1089
|
+
const paths = [];
|
|
1090
|
+
try {
|
|
1091
|
+
for await (const entry of layer.list()) {
|
|
1092
|
+
paths.push(entry.path);
|
|
1311
1093
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1094
|
+
}
|
|
1095
|
+
catch {
|
|
1096
|
+
// A layer that cannot list also cannot own paths.
|
|
1097
|
+
}
|
|
1098
|
+
return paths;
|
|
1317
1099
|
}
|
|
1318
1100
|
/**
|
|
1319
1101
|
* Same-root overlay: earlier layers win. Read-only.
|
|
@@ -1326,41 +1108,27 @@ export function overlayFs(layers) {
|
|
|
1326
1108
|
if (layers.length === 0) {
|
|
1327
1109
|
throw new Error("overlayFs needs at least one layer.");
|
|
1328
1110
|
}
|
|
1329
|
-
const walkLayers = (collect) =>
|
|
1330
|
-
var _a, e_9, _b, _c;
|
|
1111
|
+
const walkLayers = async (collect) => {
|
|
1331
1112
|
const streams = [];
|
|
1332
1113
|
let failure;
|
|
1333
1114
|
let served = false;
|
|
1334
1115
|
for (const layer of layers) {
|
|
1335
1116
|
const collected = [];
|
|
1336
1117
|
try {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
_c = _f.value;
|
|
1340
|
-
_d = false;
|
|
1341
|
-
const entry = _c;
|
|
1342
|
-
collected.push(entry);
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1346
|
-
finally {
|
|
1347
|
-
try {
|
|
1348
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
1349
|
-
}
|
|
1350
|
-
finally { if (e_9) throw e_9.error; }
|
|
1118
|
+
for await (const entry of await collect(layer)) {
|
|
1119
|
+
collected.push(entry);
|
|
1351
1120
|
}
|
|
1352
1121
|
}
|
|
1353
1122
|
catch (error) {
|
|
1354
|
-
failure
|
|
1123
|
+
failure ??= error;
|
|
1355
1124
|
continue;
|
|
1356
1125
|
}
|
|
1357
1126
|
served = true;
|
|
1358
1127
|
streams.push(collected);
|
|
1359
1128
|
}
|
|
1360
1129
|
return { streams, failure, served };
|
|
1361
|
-
}
|
|
1362
|
-
const collectOverlayHits = (queryFn, rethrow) =>
|
|
1363
|
-
var _a, e_10, _b, _c;
|
|
1130
|
+
};
|
|
1131
|
+
const collectOverlayHits = async (queryFn, rethrow) => {
|
|
1364
1132
|
const streams = [];
|
|
1365
1133
|
const shadowed = new Set();
|
|
1366
1134
|
let failure;
|
|
@@ -1368,34 +1136,22 @@ export function overlayFs(layers) {
|
|
|
1368
1136
|
for (const layer of layers) {
|
|
1369
1137
|
const collected = [];
|
|
1370
1138
|
try {
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
_d = false;
|
|
1375
|
-
const hit = _c;
|
|
1376
|
-
if (!shadowed.has(hit.path)) {
|
|
1377
|
-
collected.push(hit);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1382
|
-
finally {
|
|
1383
|
-
try {
|
|
1384
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
1139
|
+
for await (const hit of queryFn(layer)) {
|
|
1140
|
+
if (!shadowed.has(hit.path)) {
|
|
1141
|
+
collected.push(hit);
|
|
1385
1142
|
}
|
|
1386
|
-
finally { if (e_10) throw e_10.error; }
|
|
1387
1143
|
}
|
|
1388
1144
|
served = true;
|
|
1389
1145
|
}
|
|
1390
1146
|
catch (error) {
|
|
1391
|
-
if (
|
|
1147
|
+
if (rethrow?.(error) === true) {
|
|
1392
1148
|
throw error;
|
|
1393
1149
|
}
|
|
1394
|
-
failure
|
|
1150
|
+
failure ??= error;
|
|
1395
1151
|
continue;
|
|
1396
1152
|
}
|
|
1397
1153
|
streams.push(collected);
|
|
1398
|
-
for (const path of
|
|
1154
|
+
for (const path of await collectLayerPaths(layer)) {
|
|
1399
1155
|
shadowed.add(path);
|
|
1400
1156
|
}
|
|
1401
1157
|
}
|
|
@@ -1403,91 +1159,75 @@ export function overlayFs(layers) {
|
|
|
1403
1159
|
throw failure;
|
|
1404
1160
|
}
|
|
1405
1161
|
return streams;
|
|
1406
|
-
}
|
|
1162
|
+
};
|
|
1407
1163
|
return {
|
|
1408
|
-
list(prefix, options) {
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
yield __await(yield* __asyncDelegator(__asyncValues(limitResults(mergeSortedByPath(streams, { unique: true }), options === null || options === void 0 ? void 0 : options.limit))));
|
|
1415
|
-
});
|
|
1164
|
+
async *list(prefix, options) {
|
|
1165
|
+
const { streams, failure, served } = await walkLayers(layer => layer.list(prefix, options));
|
|
1166
|
+
if (!served && failure !== undefined) {
|
|
1167
|
+
throw failure;
|
|
1168
|
+
}
|
|
1169
|
+
yield* limitResults(mergeSortedByPath(streams, { unique: true }), options?.limit);
|
|
1416
1170
|
},
|
|
1417
|
-
stat(path) {
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
return info;
|
|
1426
|
-
}
|
|
1427
|
-
sawMissing = true;
|
|
1428
|
-
}
|
|
1429
|
-
catch (error) {
|
|
1430
|
-
failure !== null && failure !== void 0 ? failure : (failure = error);
|
|
1171
|
+
async stat(path) {
|
|
1172
|
+
let failure;
|
|
1173
|
+
let sawMissing = false;
|
|
1174
|
+
for (const layer of layers) {
|
|
1175
|
+
try {
|
|
1176
|
+
const info = await layer.stat(path);
|
|
1177
|
+
if (info.kind !== "missing") {
|
|
1178
|
+
return info;
|
|
1431
1179
|
}
|
|
1180
|
+
sawMissing = true;
|
|
1432
1181
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1182
|
+
catch (error) {
|
|
1183
|
+
failure ??= error;
|
|
1435
1184
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1185
|
+
}
|
|
1186
|
+
if (!sawMissing && failure !== undefined) {
|
|
1187
|
+
throw failure;
|
|
1188
|
+
}
|
|
1189
|
+
return { kind: "missing" };
|
|
1438
1190
|
},
|
|
1439
|
-
glob(pattern, dir, options) {
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
yield __await(yield* __asyncDelegator(__asyncValues(limitResults(mergeSortedByPath(streams, { unique: true }), options === null || options === void 0 ? void 0 : options.limit))));
|
|
1446
|
-
});
|
|
1191
|
+
async *glob(pattern, dir, options) {
|
|
1192
|
+
const { streams, failure, served } = await walkLayers(layer => layer.glob(pattern, dir, options));
|
|
1193
|
+
if (!served && failure !== undefined) {
|
|
1194
|
+
throw failure;
|
|
1195
|
+
}
|
|
1196
|
+
yield* limitResults(mergeSortedByPath(streams, { unique: true }), options?.limit);
|
|
1447
1197
|
},
|
|
1448
|
-
read(path) {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
return yield layer.read(path);
|
|
1454
|
-
}
|
|
1455
|
-
catch (error) {
|
|
1456
|
-
if (isFileNotFoundError(error)) {
|
|
1457
|
-
continue;
|
|
1458
|
-
}
|
|
1459
|
-
failure !== null && failure !== void 0 ? failure : (failure = error);
|
|
1460
|
-
}
|
|
1198
|
+
async read(path) {
|
|
1199
|
+
let failure;
|
|
1200
|
+
for (const layer of layers) {
|
|
1201
|
+
try {
|
|
1202
|
+
return await layer.read(path);
|
|
1461
1203
|
}
|
|
1462
|
-
|
|
1463
|
-
|
|
1204
|
+
catch (error) {
|
|
1205
|
+
if (isFileNotFoundError(error)) {
|
|
1206
|
+
continue;
|
|
1207
|
+
}
|
|
1208
|
+
failure ??= error;
|
|
1464
1209
|
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1210
|
+
}
|
|
1211
|
+
if (failure !== undefined) {
|
|
1212
|
+
throw failure;
|
|
1213
|
+
}
|
|
1214
|
+
throw new FileNotFoundError(path);
|
|
1467
1215
|
},
|
|
1468
|
-
grep(query) {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
yield __await(yield* __asyncDelegator(__asyncValues(limitResults(mergeSorted(yield __await(collectOverlayHits(layer => layer.grep(uncappedQuery), error => isInvalidGrepPatternError(error))), { compare: compareGrepResult }), maxResults))));
|
|
1472
|
-
});
|
|
1216
|
+
async *grep(query) {
|
|
1217
|
+
const { maxResults, ...uncappedQuery } = query;
|
|
1218
|
+
yield* limitResults(mergeSorted(await collectOverlayHits(layer => layer.grep(uncappedQuery), error => isInvalidGrepPatternError(error)), { compare: compareGrepResult }), maxResults);
|
|
1473
1219
|
},
|
|
1474
|
-
write(path) {
|
|
1475
|
-
|
|
1476
|
-
throw new ReadOnlyMountError(path);
|
|
1477
|
-
});
|
|
1220
|
+
async write(path) {
|
|
1221
|
+
throw new ReadOnlyMountError(path);
|
|
1478
1222
|
},
|
|
1479
|
-
delete(path) {
|
|
1480
|
-
|
|
1481
|
-
throw new ReadOnlyMountError(path);
|
|
1482
|
-
});
|
|
1223
|
+
async delete(path) {
|
|
1224
|
+
throw new ReadOnlyMountError(path);
|
|
1483
1225
|
},
|
|
1484
|
-
search(query) {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
}), maxResults))));
|
|
1490
|
-
});
|
|
1226
|
+
async *search(query) {
|
|
1227
|
+
const { maxResults, ...uncappedQuery } = query;
|
|
1228
|
+
yield* limitResults(mergeSorted(await collectOverlayHits(layer => layer.search(uncappedQuery)), {
|
|
1229
|
+
compare: compareSearchResult,
|
|
1230
|
+
}), maxResults);
|
|
1491
1231
|
},
|
|
1492
1232
|
};
|
|
1493
1233
|
}
|
|
@@ -1512,41 +1252,37 @@ export function hostFs(files, scope) {
|
|
|
1512
1252
|
const callOptions = { scope };
|
|
1513
1253
|
const readEtags = new Map();
|
|
1514
1254
|
const listed = {
|
|
1515
|
-
list(prefix, options) {
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
})), prefix, options))));
|
|
1522
|
-
});
|
|
1255
|
+
async *list(prefix, options) {
|
|
1256
|
+
const entries = await files.list(undefined, callOptions);
|
|
1257
|
+
yield* listFilesFromPaths(entries.map(entry => ({
|
|
1258
|
+
path: normalizeFsPath(entry.path),
|
|
1259
|
+
size: entry.size,
|
|
1260
|
+
})), prefix, options);
|
|
1523
1261
|
},
|
|
1524
|
-
stat(path) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
return statFromFilePaths(entries.map(entry => normalizeFsPath(entry.path)), path);
|
|
1528
|
-
});
|
|
1262
|
+
async stat(path) {
|
|
1263
|
+
const entries = await files.list(undefined, callOptions);
|
|
1264
|
+
return statFromFilePaths(entries.map(entry => normalizeFsPath(entry.path)), path);
|
|
1529
1265
|
},
|
|
1530
1266
|
};
|
|
1531
|
-
const readText = (inputPath) =>
|
|
1267
|
+
const readText = async (inputPath) => {
|
|
1532
1268
|
const path = normalizeFsPath(inputPath);
|
|
1533
1269
|
const key = hostKey(path);
|
|
1534
1270
|
if (key === "") {
|
|
1535
1271
|
throw new FileNotFoundError(path);
|
|
1536
1272
|
}
|
|
1537
|
-
const [content, stat] =
|
|
1273
|
+
const [content, stat] = await Promise.all([
|
|
1538
1274
|
files.read(key, callOptions),
|
|
1539
1275
|
files.stat(key, callOptions),
|
|
1540
1276
|
]);
|
|
1541
1277
|
if (content === undefined) {
|
|
1542
1278
|
throw new FileNotFoundError(path);
|
|
1543
1279
|
}
|
|
1544
|
-
if (
|
|
1280
|
+
if (stat?.etag !== undefined) {
|
|
1545
1281
|
readEtags.set(key, stat.etag);
|
|
1546
1282
|
}
|
|
1547
1283
|
return content;
|
|
1548
|
-
}
|
|
1549
|
-
const writeHost = (inputPath, contents) =>
|
|
1284
|
+
};
|
|
1285
|
+
const writeHost = async (inputPath, contents) => {
|
|
1550
1286
|
const path = normalizeFsPath(inputPath);
|
|
1551
1287
|
const key = hostKey(path);
|
|
1552
1288
|
if (key === "") {
|
|
@@ -1555,10 +1291,15 @@ export function hostFs(files, scope) {
|
|
|
1555
1291
|
try {
|
|
1556
1292
|
if (files.capabilities.conflictDetection) {
|
|
1557
1293
|
const etag = readEtags.get(key);
|
|
1558
|
-
|
|
1294
|
+
await files.write(key, contents, {
|
|
1295
|
+
...callOptions,
|
|
1296
|
+
// No cached etag: unconditional create/overwrite. After a
|
|
1297
|
+
// successful read or write, CAS on that etag.
|
|
1298
|
+
...(etag === undefined ? {} : { ifMatch: etag }),
|
|
1299
|
+
});
|
|
1559
1300
|
}
|
|
1560
1301
|
else {
|
|
1561
|
-
|
|
1302
|
+
await files.write(key, contents, callOptions);
|
|
1562
1303
|
}
|
|
1563
1304
|
}
|
|
1564
1305
|
catch (error) {
|
|
@@ -1567,132 +1308,92 @@ export function hostFs(files, scope) {
|
|
|
1567
1308
|
}
|
|
1568
1309
|
throw error;
|
|
1569
1310
|
}
|
|
1570
|
-
const stat =
|
|
1571
|
-
if (
|
|
1311
|
+
const stat = await files.stat(key, callOptions);
|
|
1312
|
+
if (stat?.etag !== undefined) {
|
|
1572
1313
|
readEtags.set(key, stat.etag);
|
|
1573
1314
|
}
|
|
1574
1315
|
else {
|
|
1575
1316
|
readEtags.delete(key);
|
|
1576
1317
|
}
|
|
1577
|
-
}
|
|
1318
|
+
};
|
|
1578
1319
|
return {
|
|
1579
1320
|
list(prefix, options) {
|
|
1580
1321
|
return listed.list(prefix, options);
|
|
1581
1322
|
},
|
|
1582
|
-
stat(path) {
|
|
1583
|
-
return
|
|
1584
|
-
return listed.stat(path);
|
|
1585
|
-
});
|
|
1323
|
+
async stat(path) {
|
|
1324
|
+
return listed.stat(path);
|
|
1586
1325
|
},
|
|
1587
|
-
read(path) {
|
|
1588
|
-
return
|
|
1589
|
-
return readText(path);
|
|
1590
|
-
});
|
|
1326
|
+
async read(path) {
|
|
1327
|
+
return readText(path);
|
|
1591
1328
|
},
|
|
1592
|
-
grep(query) {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
path: scopePath,
|
|
1613
|
-
content: yield __await(readText(scopePath)),
|
|
1614
|
-
regex,
|
|
1615
|
-
}))));
|
|
1616
|
-
return yield __await(void 0);
|
|
1617
|
-
}
|
|
1618
|
-
try {
|
|
1619
|
-
for (var _d = true, _e = __asyncValues(listed.list(scopePath === "/" ? undefined : scopePath, query.excludes === undefined ? undefined : { excludes: query.excludes })), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
1620
|
-
_c = _f.value;
|
|
1621
|
-
_d = false;
|
|
1622
|
-
const entry = _c;
|
|
1623
|
-
if (query.glob !== undefined &&
|
|
1624
|
-
!pathMatchesGlob(entry.path, scopePath, query.glob, {
|
|
1625
|
-
matchBasename: true,
|
|
1626
|
-
})) {
|
|
1627
|
-
continue;
|
|
1628
|
-
}
|
|
1629
|
-
yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({
|
|
1630
|
-
path: entry.path,
|
|
1631
|
-
content: yield __await(readText(entry.path)),
|
|
1632
|
-
regex,
|
|
1633
|
-
}))));
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1637
|
-
finally {
|
|
1638
|
-
try {
|
|
1639
|
-
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
1640
|
-
}
|
|
1641
|
-
finally { if (e_11) throw e_11.error; }
|
|
1642
|
-
}
|
|
1329
|
+
async *grep(query) {
|
|
1330
|
+
yield* limitResults(uncapped(), query.maxResults);
|
|
1331
|
+
async function* uncapped() {
|
|
1332
|
+
const scopePath = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
|
|
1333
|
+
const regex = compileGrepPattern(query.pattern, query.caseInsensitive, scopePath);
|
|
1334
|
+
const info = await listed.stat(scopePath);
|
|
1335
|
+
if (scopePath !== "/" && info.kind === "file") {
|
|
1336
|
+
if (query.glob !== undefined &&
|
|
1337
|
+
!pathMatchesGlob(scopePath, scopePath, query.glob, {
|
|
1338
|
+
matchBasename: true,
|
|
1339
|
+
})) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
if (isExcludedPath(scopePath, query.excludes)) {
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
yield* grepFileContent({
|
|
1346
|
+
path: scopePath,
|
|
1347
|
+
content: await readText(scopePath),
|
|
1348
|
+
regex,
|
|
1643
1349
|
});
|
|
1350
|
+
return;
|
|
1644
1351
|
}
|
|
1645
|
-
|
|
1352
|
+
for await (const entry of listed.list(scopePath === "/" ? undefined : scopePath, query.excludes === undefined ? undefined : { excludes: query.excludes })) {
|
|
1353
|
+
if (query.glob !== undefined &&
|
|
1354
|
+
!pathMatchesGlob(entry.path, scopePath, query.glob, {
|
|
1355
|
+
matchBasename: true,
|
|
1356
|
+
})) {
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
yield* grepFileContent({
|
|
1360
|
+
path: entry.path,
|
|
1361
|
+
content: await readText(entry.path),
|
|
1362
|
+
regex,
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1646
1366
|
},
|
|
1647
|
-
glob(pattern, dir, options) {
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1367
|
+
async *glob(pattern, dir, options) {
|
|
1368
|
+
const dirPath = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
|
|
1369
|
+
yield* globFromList(listed.list(dirPath === "/" ? undefined : dirPath), {
|
|
1370
|
+
pattern,
|
|
1371
|
+
dir: dirPath,
|
|
1372
|
+
...(options?.limit === undefined ? {} : { limit: options.limit }),
|
|
1651
1373
|
});
|
|
1652
1374
|
},
|
|
1653
|
-
write(inputPath, contents) {
|
|
1654
|
-
|
|
1655
|
-
yield writeHost(inputPath, contents);
|
|
1656
|
-
});
|
|
1375
|
+
async write(inputPath, contents) {
|
|
1376
|
+
await writeHost(inputPath, contents);
|
|
1657
1377
|
},
|
|
1658
|
-
delete(inputPath) {
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
readEtags.delete(key);
|
|
1667
|
-
});
|
|
1378
|
+
async delete(inputPath) {
|
|
1379
|
+
const path = normalizeFsPath(inputPath);
|
|
1380
|
+
const key = hostKey(path);
|
|
1381
|
+
if (key === "" || !(await files.exists(key, callOptions))) {
|
|
1382
|
+
throw new FileNotFoundError(path);
|
|
1383
|
+
}
|
|
1384
|
+
await files.remove(key, callOptions);
|
|
1385
|
+
readEtags.delete(key);
|
|
1668
1386
|
},
|
|
1669
1387
|
search: emptySearch,
|
|
1670
1388
|
};
|
|
1671
1389
|
}
|
|
1672
|
-
function globFromList(source, options) {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
for (var _d = true, source_5 = __asyncValues(source), source_5_1; source_5_1 = yield __await(source_5.next()), _a = source_5_1.done, !_a; _d = true) {
|
|
1680
|
-
_c = source_5_1.value;
|
|
1681
|
-
_d = false;
|
|
1682
|
-
const entry = _c;
|
|
1683
|
-
if (pathMatchesGlob(entry.path, options.dir, options.pattern)) {
|
|
1684
|
-
yield yield __await(entry);
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1689
|
-
finally {
|
|
1690
|
-
try {
|
|
1691
|
-
if (!_d && !_a && (_b = source_5.return)) yield __await(_b.call(source_5));
|
|
1692
|
-
}
|
|
1693
|
-
finally { if (e_12) throw e_12.error; }
|
|
1694
|
-
}
|
|
1695
|
-
});
|
|
1390
|
+
async function* globFromList(source, options) {
|
|
1391
|
+
yield* limitResults(uncapped(), options.limit);
|
|
1392
|
+
async function* uncapped() {
|
|
1393
|
+
for await (const entry of source) {
|
|
1394
|
+
if (pathMatchesGlob(entry.path, options.dir, options.pattern)) {
|
|
1395
|
+
yield entry;
|
|
1396
|
+
}
|
|
1696
1397
|
}
|
|
1697
|
-
}
|
|
1398
|
+
}
|
|
1698
1399
|
}
|