alchemy 2.0.0-beta.37 → 2.0.0-beta.39
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/bin/exec.js +488 -69
- package/bin/exec.js.map +1 -1
- package/lib/AWS/AutoScaling/LaunchTemplate.d.ts +1 -1
- package/lib/AWS/CloudWatch/common.d.ts +1 -1
- package/lib/AWS/Credentials.d.ts.map +1 -1
- package/lib/AWS/Credentials.js +1 -2
- package/lib/AWS/Credentials.js.map +1 -1
- package/lib/AWS/DynamoDB/Stream.d.ts.map +1 -1
- package/lib/AWS/DynamoDB/Stream.js +1 -1
- package/lib/AWS/DynamoDB/Stream.js.map +1 -1
- package/lib/AWS/EC2/Instance.d.ts +1 -1
- package/lib/AWS/EC2/hosted.d.ts +1 -1
- package/lib/AWS/EC2/hosted.d.ts.map +1 -1
- package/lib/AWS/EC2/hosted.js +3 -5
- package/lib/AWS/EC2/hosted.js.map +1 -1
- package/lib/AWS/ECS/Task.d.ts +1 -1
- package/lib/AWS/ECS/Task.d.ts.map +1 -1
- package/lib/AWS/ECS/Task.js +3 -5
- package/lib/AWS/ECS/Task.js.map +1 -1
- package/lib/AWS/Endpoint.d.ts.map +1 -1
- package/lib/AWS/Endpoint.js +1 -2
- package/lib/AWS/Endpoint.js.map +1 -1
- package/lib/AWS/Environment.d.ts +2 -2
- package/lib/AWS/EventBridge/EventSource.d.ts.map +1 -1
- package/lib/AWS/EventBridge/EventSource.js +1 -1
- package/lib/AWS/EventBridge/EventSource.js.map +1 -1
- package/lib/AWS/Kinesis/StreamEventSource.d.ts.map +1 -1
- package/lib/AWS/Kinesis/StreamEventSource.js +1 -1
- package/lib/AWS/Kinesis/StreamEventSource.js.map +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/Function.d.ts +1 -1
- package/lib/AWS/Lambda/Function.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.js +7 -11
- package/lib/AWS/Lambda/Function.js.map +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
- package/lib/AWS/Organizations/common.d.ts +1 -1
- package/lib/AWS/Providers.d.ts.map +1 -1
- package/lib/AWS/Providers.js +21 -3
- package/lib/AWS/Providers.js.map +1 -1
- package/lib/AWS/Region.d.ts +1 -1
- package/lib/AWS/Region.d.ts.map +1 -1
- package/lib/AWS/Region.js +2 -3
- package/lib/AWS/Region.js.map +1 -1
- package/lib/AWS/S3/Bucket.d.ts.map +1 -1
- package/lib/AWS/S3/Bucket.js +5 -2
- package/lib/AWS/S3/Bucket.js.map +1 -1
- package/lib/AWS/S3/BucketNotifications.d.ts.map +1 -1
- package/lib/AWS/S3/BucketNotifications.js +1 -1
- package/lib/AWS/S3/BucketNotifications.js.map +1 -1
- package/lib/AWS/SNS/TopicEventSource.d.ts.map +1 -1
- package/lib/AWS/SNS/TopicEventSource.js +1 -1
- package/lib/AWS/SNS/TopicEventSource.js.map +1 -1
- package/lib/AWS/SQS/Queue.d.ts.map +1 -1
- package/lib/AWS/SQS/Queue.js +23 -5
- package/lib/AWS/SQS/Queue.js.map +1 -1
- package/lib/Action.d.ts +77 -0
- package/lib/Action.d.ts.map +1 -0
- package/lib/Action.js +89 -0
- package/lib/Action.js.map +1 -0
- package/lib/AlchemyContext.d.ts +1 -1
- package/lib/Apply.d.ts.map +1 -1
- package/lib/Apply.js +222 -3
- package/lib/Apply.js.map +1 -1
- package/lib/Artifacts.d.ts +1 -1
- package/lib/Artifacts.d.ts.map +1 -1
- package/lib/Artifacts.js +1 -1
- package/lib/Artifacts.js.map +1 -1
- package/lib/Auth/AuthProvider.js +1 -1
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/Env.d.ts.map +1 -1
- package/lib/Auth/Env.js +4 -12
- package/lib/Auth/Env.js.map +1 -1
- package/lib/Binding.d.ts.map +1 -1
- package/lib/Binding.js +5 -5
- package/lib/Binding.js.map +1 -1
- package/lib/Build/Command.d.ts +1 -1
- package/lib/Build/Memo.d.ts +1 -1
- package/lib/Bundle/Docker.d.ts +3 -3
- package/lib/Bundle/Docker.js +1 -1
- package/lib/Bundle/Docker.js.map +1 -1
- package/lib/Bundle/TempRoot.d.ts +3 -3
- package/lib/Cli/Event.d.ts +1 -1
- package/lib/Cli/Event.d.ts.map +1 -1
- package/lib/Cli/NamespaceTree.d.ts +11 -5
- package/lib/Cli/NamespaceTree.d.ts.map +1 -1
- package/lib/Cli/NamespaceTree.js +28 -1
- package/lib/Cli/NamespaceTree.js.map +1 -1
- package/lib/Cli/commands/_shared.d.ts +1 -1
- package/lib/Cli/commands/_shared.js +2 -2
- package/lib/Cli/commands/_shared.js.map +1 -1
- package/lib/Cli/commands/aws.d.ts +1 -1
- package/lib/Cli/commands/cloudflare.d.ts +2 -2
- package/lib/Cli/commands/cloudflare.d.ts.map +1 -1
- package/lib/Cli/commands/deploy.d.ts +9 -9
- package/lib/Cli/commands/deploy.js +1 -1
- package/lib/Cli/commands/deploy.js.map +1 -1
- package/lib/Cli/commands/login.d.ts +1 -1
- package/lib/Cli/commands/logs.d.ts +1 -1
- package/lib/Cli/commands/logs.js.map +1 -1
- package/lib/Cli/commands/profile.d.ts +1 -3
- package/lib/Cli/commands/profile.d.ts.map +1 -1
- package/lib/Cli/commands/state.d.ts +1 -1
- package/lib/Cli/commands/state.d.ts.map +1 -1
- package/lib/Cli/commands/tail.d.ts +1 -1
- package/lib/Cli/commands/tail.js.map +1 -1
- package/lib/Cli/tui/components/Plan.d.ts.map +1 -1
- package/lib/Cli/tui/components/Plan.js +27 -13
- package/lib/Cli/tui/components/Plan.js.map +1 -1
- package/lib/Cli/tui/components/PlanProgress.d.ts +8 -1
- package/lib/Cli/tui/components/PlanProgress.d.ts.map +1 -1
- package/lib/Cli/tui/components/PlanProgress.js +95 -16
- package/lib/Cli/tui/components/PlanProgress.js.map +1 -1
- package/lib/Cloudflare/Access.js +0 -1
- package/lib/Cloudflare/Access.js.map +1 -1
- package/lib/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.js +1 -1
- package/lib/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.js.map +1 -1
- package/lib/Cloudflare/Artifacts/ArtifactsBinding.js +1 -1
- package/lib/Cloudflare/Artifacts/ArtifactsBinding.js.map +1 -1
- package/lib/Cloudflare/CloudflareEnvironment.d.ts +1 -1
- package/lib/Cloudflare/Container/Container.js +0 -1
- package/lib/Cloudflare/Container/Container.js.map +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.d.ts +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.d.ts.map +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.js +4 -6
- package/lib/Cloudflare/Container/ContainerApplication.js.map +1 -1
- package/lib/Cloudflare/Container/ContainerBinding.js +2 -2
- package/lib/Cloudflare/Container/ContainerBinding.js.map +1 -1
- package/lib/Cloudflare/D1/D1Database.d.ts +1 -1
- package/lib/Cloudflare/D1/D1SqlFile.d.ts +2 -2
- package/lib/Cloudflare/Email/EmailAddress.d.ts +45 -0
- package/lib/Cloudflare/Email/EmailAddress.d.ts.map +1 -0
- package/lib/Cloudflare/Email/EmailAddress.js +99 -0
- package/lib/Cloudflare/Email/EmailAddress.js.map +1 -0
- package/lib/Cloudflare/Email/EmailRouting.d.ts +42 -0
- package/lib/Cloudflare/Email/EmailRouting.d.ts.map +1 -0
- package/lib/Cloudflare/Email/EmailRouting.js +89 -0
- package/lib/Cloudflare/Email/EmailRouting.js.map +1 -0
- package/lib/Cloudflare/Email/EmailRule.d.ts +80 -0
- package/lib/Cloudflare/Email/EmailRule.d.ts.map +1 -0
- package/lib/Cloudflare/Email/EmailRule.js +110 -0
- package/lib/Cloudflare/Email/EmailRule.js.map +1 -0
- package/lib/Cloudflare/Email/SendEmail.d.ts +74 -0
- package/lib/Cloudflare/Email/SendEmail.d.ts.map +1 -0
- package/lib/Cloudflare/Email/SendEmail.js +19 -0
- package/lib/Cloudflare/Email/SendEmail.js.map +1 -0
- package/lib/Cloudflare/Email/SendEmailBinding.d.ts +64 -0
- package/lib/Cloudflare/Email/SendEmailBinding.d.ts.map +1 -0
- package/lib/Cloudflare/Email/SendEmailBinding.js +54 -0
- package/lib/Cloudflare/Email/SendEmailBinding.js.map +1 -0
- package/lib/Cloudflare/Email/index.d.ts +6 -0
- package/lib/Cloudflare/Email/index.d.ts.map +1 -0
- package/lib/Cloudflare/Email/index.js +6 -0
- package/lib/Cloudflare/Email/index.js.map +1 -0
- package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts +1 -1
- package/lib/Cloudflare/Images/ImagesBinding.js +1 -1
- package/lib/Cloudflare/Images/ImagesBinding.js.map +1 -1
- package/lib/Cloudflare/KV/KVNamespaceBinding.js +1 -1
- package/lib/Cloudflare/KV/KVNamespaceBinding.js.map +1 -1
- package/lib/Cloudflare/Local/Sidecar.d.ts +1 -1
- package/lib/Cloudflare/Local/SidecarHandlers.d.ts +1 -1
- package/lib/Cloudflare/Local/SidecarServer.js +1 -1
- package/lib/Cloudflare/Local/SidecarServer.js.map +1 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/Providers.js +6 -1
- package/lib/Cloudflare/Providers.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueBinding.js +1 -1
- package/lib/Cloudflare/Queue/QueueBinding.js.map +1 -1
- package/lib/Cloudflare/R2/R2BucketBinding.js +1 -1
- package/lib/Cloudflare/R2/R2BucketBinding.js.map +1 -1
- package/lib/Cloudflare/SecretsStore/SecretBinding.js +1 -1
- package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -1
- package/lib/Cloudflare/StateStore/Api.d.ts +1 -1
- package/lib/Cloudflare/StateStore/State.d.ts +2 -2
- package/lib/Cloudflare/Workers/Assets.d.ts +2 -2
- package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Assets.js +5 -4
- package/lib/Cloudflare/Workers/Assets.js.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.js +25 -3
- package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
- package/lib/Cloudflare/Workers/InferEnv.d.ts +1 -1
- package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +4 -3
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +67 -32
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBundle.js +4 -6
- package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerName.d.ts +1 -1
- package/lib/Cloudflare/Workers/Workflow.js +2 -2
- package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
- package/lib/Cloudflare/index.d.ts +1 -0
- package/lib/Cloudflare/index.d.ts.map +1 -1
- package/lib/Cloudflare/index.js +1 -0
- package/lib/Cloudflare/index.js.map +1 -1
- package/lib/Construct.d.ts +3 -3
- package/lib/Construct.d.ts.map +1 -1
- package/lib/Construct.js.map +1 -1
- package/lib/Deploy.d.ts +1 -1
- package/lib/Destroy.d.ts +1 -1
- package/lib/Destroy.d.ts.map +1 -1
- package/lib/Destroy.js +1 -0
- package/lib/Destroy.js.map +1 -1
- package/lib/Drizzle/Providers.d.ts +1 -1
- package/lib/Drizzle/Schema.d.ts +1 -1
- package/lib/GitHub/Providers.d.ts +1 -1
- package/lib/Http.d.ts +1 -1
- package/lib/Http.d.ts.map +1 -1
- package/lib/Http.js +1 -1
- package/lib/Http.js.map +1 -1
- package/lib/Namespace.d.ts.map +1 -1
- package/lib/Namespace.js +3 -4
- package/lib/Namespace.js.map +1 -1
- package/lib/Neon/Branch.d.ts +2 -2
- package/lib/Neon/Branch.d.ts.map +1 -1
- package/lib/Neon/Branch.js +59 -27
- package/lib/Neon/Branch.js.map +1 -1
- package/lib/Neon/Credentials.d.ts +2 -2
- package/lib/Neon/Credentials.d.ts.map +1 -1
- package/lib/Neon/Credentials.js +2 -2
- package/lib/Neon/Credentials.js.map +1 -1
- package/lib/Neon/NeonEnvironment.d.ts +1 -1
- package/lib/Neon/Project.d.ts +25 -1
- package/lib/Neon/Project.d.ts.map +1 -1
- package/lib/Neon/Project.js +121 -42
- package/lib/Neon/Project.js.map +1 -1
- package/lib/Neon/Providers.d.ts +1 -1
- package/lib/Neon/SqlFile.d.ts +2 -2
- package/lib/Output.d.ts +3 -4
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +7 -4
- package/lib/Output.js.map +1 -1
- package/lib/PhysicalName.d.ts +1 -1
- package/lib/Plan.d.ts +36 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +197 -31
- package/lib/Plan.js.map +1 -1
- package/lib/Platform.js +6 -6
- package/lib/Platform.js.map +1 -1
- package/lib/Provider.d.ts +1 -1
- package/lib/Provider.d.ts.map +1 -1
- package/lib/Provider.js +1 -1
- package/lib/Provider.js.map +1 -1
- package/lib/Random.d.ts +1 -1
- package/lib/Random.d.ts.map +1 -1
- package/lib/Random.js +1 -1
- package/lib/Random.js.map +1 -1
- package/lib/Resource.d.ts.map +1 -1
- package/lib/Resource.js +2 -25
- package/lib/Resource.js.map +1 -1
- package/lib/Runtime.d.ts +24 -0
- package/lib/Runtime.d.ts.map +1 -0
- package/lib/Runtime.js +31 -0
- package/lib/Runtime.js.map +1 -0
- package/lib/Secret.js +1 -1
- package/lib/Secret.js.map +1 -1
- package/lib/Sidecar/RpcClient.d.ts +1 -1
- package/lib/Sidecar/RpcPaths.d.ts +1 -1
- package/lib/Sidecar/RpcServer.d.ts +1 -1
- package/lib/Sidecar/RpcServices.d.ts +1 -1
- package/lib/Stack.d.ts +7 -2
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +4 -4
- package/lib/Stack.js.map +1 -1
- package/lib/State/ActionState.d.ts +48 -0
- package/lib/State/ActionState.d.ts.map +1 -0
- package/lib/State/ActionState.js +1 -0
- package/lib/State/ActionState.js.map +1 -0
- package/lib/State/HttpStateStore.d.ts.map +1 -1
- package/lib/State/HttpStateStore.js +1 -1
- package/lib/State/HttpStateStore.js.map +1 -1
- package/lib/State/InMemoryState.d.ts.map +1 -1
- package/lib/State/InMemoryState.js.map +1 -1
- package/lib/State/LocalState.d.ts +2 -2
- package/lib/State/ResourceState.d.ts +5 -0
- package/lib/State/ResourceState.d.ts.map +1 -1
- package/lib/State/State.d.ts +10 -2
- package/lib/State/State.d.ts.map +1 -1
- package/lib/State/State.js +2 -0
- package/lib/State/State.js.map +1 -1
- package/lib/State/index.d.ts +1 -0
- package/lib/State/index.d.ts.map +1 -1
- package/lib/State/index.js +1 -0
- package/lib/State/index.js.map +1 -1
- package/lib/Test/Core.d.ts +2 -2
- package/lib/Test/Core.d.ts.map +1 -1
- package/lib/Test/Core.js +4 -1
- package/lib/Test/Core.js.map +1 -1
- package/lib/Util/FileLogger.d.ts +1 -1
- package/lib/Util/effect.js +4 -4
- package/lib/Util/effect.js.map +1 -1
- package/lib/Util/exec.d.ts.map +1 -0
- package/lib/Util/exec.js.map +1 -0
- package/lib/Util/hash.d.ts +8 -0
- package/lib/Util/hash.d.ts.map +1 -0
- package/lib/Util/hash.js +11 -0
- package/lib/Util/hash.js.map +1 -0
- package/lib/Util/ignore.d.ts +40 -0
- package/lib/Util/ignore.d.ts.map +1 -0
- package/lib/Util/ignore.js +591 -0
- package/lib/Util/ignore.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +22 -28
- package/src/AWS/Credentials.ts +1 -2
- package/src/AWS/DynamoDB/Stream.ts +1 -4
- package/src/AWS/EC2/hosted.ts +14 -16
- package/src/AWS/ECS/Task.ts +14 -16
- package/src/AWS/Endpoint.ts +2 -5
- package/src/AWS/EventBridge/EventSource.ts +1 -4
- package/src/AWS/Kinesis/StreamEventSource.ts +1 -4
- package/src/AWS/Lambda/Function.ts +31 -35
- package/src/AWS/Providers.ts +22 -3
- package/src/AWS/Region.ts +2 -3
- package/src/AWS/S3/Bucket.ts +7 -2
- package/src/AWS/S3/BucketNotifications.ts +1 -4
- package/src/AWS/SNS/TopicEventSource.ts +1 -4
- package/src/AWS/SQS/Queue.ts +40 -6
- package/src/Action.ts +280 -0
- package/src/Apply.ts +351 -23
- package/src/Artifacts.ts +2 -4
- package/src/Auth/AuthProvider.ts +1 -1
- package/src/Auth/Env.ts +12 -20
- package/src/Binding.ts +5 -9
- package/src/Bundle/Docker.ts +1 -1
- package/src/Cli/Event.ts +4 -0
- package/src/Cli/NamespaceTree.ts +52 -5
- package/src/Cli/commands/_shared.ts +2 -2
- package/src/Cli/commands/deploy.ts +1 -1
- package/src/Cli/commands/logs.ts +4 -4
- package/src/Cli/commands/tail.ts +4 -4
- package/src/Cli/tui/components/Plan.tsx +65 -17
- package/src/Cli/tui/components/PlanProgress.tsx +142 -32
- package/src/Cloudflare/Access.ts +1 -1
- package/src/Cloudflare/AnalyticsEngine/AnalyticsEngineDatasetBinding.ts +1 -1
- package/src/Cloudflare/Artifacts/ArtifactsBinding.ts +1 -1
- package/src/Cloudflare/Container/Container.ts +1 -1
- package/src/Cloudflare/Container/ContainerApplication.ts +4 -6
- package/src/Cloudflare/Container/ContainerBinding.ts +2 -2
- package/src/Cloudflare/Email/EmailAddress.ts +155 -0
- package/src/Cloudflare/Email/EmailRouting.ts +138 -0
- package/src/Cloudflare/Email/EmailRule.ts +210 -0
- package/src/Cloudflare/Email/SendEmail.ts +95 -0
- package/src/Cloudflare/Email/SendEmailBinding.ts +124 -0
- package/src/Cloudflare/Email/index.ts +5 -0
- package/src/Cloudflare/Images/ImagesBinding.ts +1 -1
- package/src/Cloudflare/KV/KVNamespaceBinding.ts +1 -1
- package/src/Cloudflare/Local/SidecarServer.ts +1 -1
- package/src/Cloudflare/Providers.ts +9 -0
- package/src/Cloudflare/Queue/QueueBinding.ts +1 -1
- package/src/Cloudflare/R2/R2BucketBinding.ts +1 -1
- package/src/Cloudflare/SecretsStore/SecretBinding.ts +1 -1
- package/src/Cloudflare/Workers/Assets.ts +5 -6
- package/src/Cloudflare/Workers/HttpServer.ts +37 -5
- package/src/Cloudflare/Workers/InferEnv.ts +15 -11
- package/src/Cloudflare/Workers/Worker.ts +78 -36
- package/src/Cloudflare/Workers/WorkerBundle.ts +4 -6
- package/src/Cloudflare/Workers/Workflow.ts +2 -2
- package/src/Cloudflare/index.ts +1 -0
- package/src/Construct.ts +3 -7
- package/src/Destroy.ts +1 -0
- package/src/Http.ts +1 -1
- package/src/Namespace.ts +4 -4
- package/src/Neon/Branch.ts +93 -59
- package/src/Neon/Credentials.ts +2 -2
- package/src/Neon/Project.ts +193 -64
- package/src/Output.ts +9 -7
- package/src/Plan.ts +303 -53
- package/src/Platform.ts +7 -7
- package/src/Provider.ts +8 -3
- package/src/Random.ts +1 -1
- package/src/Resource.ts +2 -25
- package/src/Runtime.ts +38 -0
- package/src/Secret.ts +1 -1
- package/src/Stack.ts +10 -6
- package/src/State/ActionState.ts +51 -0
- package/src/State/HttpStateStore.ts +6 -2
- package/src/State/InMemoryState.ts +3 -3
- package/src/State/ResourceState.ts +5 -0
- package/src/State/State.ts +17 -2
- package/src/State/index.ts +1 -0
- package/src/Test/Core.ts +4 -3
- package/src/Util/effect.ts +4 -4
- package/src/Util/hash.ts +14 -0
- package/src/Util/ignore.ts +815 -0
- package/src/index.ts +6 -0
- package/lib/Agent/Agent.d.ts +0 -9
- package/lib/Agent/Agent.d.ts.map +0 -1
- package/lib/Agent/Agent.js +0 -10
- package/lib/Agent/Agent.js.map +0 -1
- package/lib/Agent/Aspect.d.ts +0 -51
- package/lib/Agent/Aspect.d.ts.map +0 -1
- package/lib/Agent/Aspect.js +0 -45
- package/lib/Agent/Aspect.js.map +0 -1
- package/lib/Agent/AspectGraph.d.ts +0 -45
- package/lib/Agent/AspectGraph.d.ts.map +0 -1
- package/lib/Agent/AspectGraph.js +0 -39
- package/lib/Agent/AspectGraph.js.map +0 -1
- package/lib/Agent/ContextPlugin.d.ts +0 -8
- package/lib/Agent/ContextPlugin.d.ts.map +0 -1
- package/lib/Agent/ContextPlugin.js +0 -3
- package/lib/Agent/ContextPlugin.js.map +0 -1
- package/lib/Agent/Plugin.d.ts +0 -18
- package/lib/Agent/Plugin.d.ts.map +0 -1
- package/lib/Agent/Plugin.js +0 -8
- package/lib/Agent/Plugin.js.map +0 -1
- package/lib/Agent/chat/channel.d.ts +0 -9
- package/lib/Agent/chat/channel.d.ts.map +0 -1
- package/lib/Agent/chat/channel.js +0 -10
- package/lib/Agent/chat/channel.js.map +0 -1
- package/lib/Agent/chat/event.d.ts +0 -32
- package/lib/Agent/chat/event.d.ts.map +0 -1
- package/lib/Agent/chat/event.js +0 -32
- package/lib/Agent/chat/event.js.map +0 -1
- package/lib/Agent/chat/message.d.ts +0 -22
- package/lib/Agent/chat/message.d.ts.map +0 -1
- package/lib/Agent/chat/message.js +0 -31
- package/lib/Agent/chat/message.js.map +0 -1
- package/lib/Agent/chat/service.d.ts +0 -102
- package/lib/Agent/chat/service.d.ts.map +0 -1
- package/lib/Agent/chat/service.js +0 -79
- package/lib/Agent/chat/service.js.map +0 -1
- package/lib/Agent/chat/thread.d.ts +0 -13
- package/lib/Agent/chat/thread.d.ts.map +0 -1
- package/lib/Agent/chat/thread.js +0 -16
- package/lib/Agent/chat/thread.js.map +0 -1
- package/lib/Agent/coding/bash.d.ts +0 -36
- package/lib/Agent/coding/bash.d.ts.map +0 -1
- package/lib/Agent/coding/bash.js +0 -170
- package/lib/Agent/coding/bash.js.map +0 -1
- package/lib/Agent/coding/edit.d.ts +0 -31
- package/lib/Agent/coding/edit.d.ts.map +0 -1
- package/lib/Agent/coding/edit.js +0 -90
- package/lib/Agent/coding/edit.js.map +0 -1
- package/lib/Agent/coding/glob.d.ts +0 -23
- package/lib/Agent/coding/glob.d.ts.map +0 -1
- package/lib/Agent/coding/glob.js +0 -78
- package/lib/Agent/coding/glob.js.map +0 -1
- package/lib/Agent/coding/grep.d.ts +0 -26
- package/lib/Agent/coding/grep.d.ts.map +0 -1
- package/lib/Agent/coding/grep.js +0 -105
- package/lib/Agent/coding/grep.js.map +0 -1
- package/lib/Agent/coding/index.d.ts +0 -8
- package/lib/Agent/coding/index.d.ts.map +0 -1
- package/lib/Agent/coding/index.js +0 -8
- package/lib/Agent/coding/index.js.map +0 -1
- package/lib/Agent/coding/read.d.ts +0 -27
- package/lib/Agent/coding/read.d.ts.map +0 -1
- package/lib/Agent/coding/read.js +0 -89
- package/lib/Agent/coding/read.js.map +0 -1
- package/lib/Agent/coding/readlints.d.ts +0 -19
- package/lib/Agent/coding/readlints.d.ts.map +0 -1
- package/lib/Agent/coding/readlints.js +0 -53
- package/lib/Agent/coding/readlints.js.map +0 -1
- package/lib/Agent/coding/write.d.ts +0 -22
- package/lib/Agent/coding/write.d.ts.map +0 -1
- package/lib/Agent/coding/write.js +0 -53
- package/lib/Agent/coding/write.js.map +0 -1
- package/lib/Agent/fs/file.d.ts +0 -12
- package/lib/Agent/fs/file.d.ts.map +0 -1
- package/lib/Agent/fs/file.js +0 -8
- package/lib/Agent/fs/file.js.map +0 -1
- package/lib/Agent/fs/folder.d.ts +0 -5
- package/lib/Agent/fs/folder.d.ts.map +0 -1
- package/lib/Agent/fs/folder.js +0 -3
- package/lib/Agent/fs/folder.js.map +0 -1
- package/lib/Agent/index.d.ts +0 -9
- package/lib/Agent/index.d.ts.map +0 -1
- package/lib/Agent/index.js +0 -9
- package/lib/Agent/index.js.map +0 -1
- package/lib/Agent/llm/error.d.ts +0 -208
- package/lib/Agent/llm/error.d.ts.map +0 -1
- package/lib/Agent/llm/error.js +0 -209
- package/lib/Agent/llm/error.js.map +0 -1
- package/lib/Agent/llm/index.d.ts +0 -5
- package/lib/Agent/llm/index.d.ts.map +0 -1
- package/lib/Agent/llm/index.js +0 -5
- package/lib/Agent/llm/index.js.map +0 -1
- package/lib/Agent/llm/llm.d.ts +0 -32
- package/lib/Agent/llm/llm.d.ts.map +0 -1
- package/lib/Agent/llm/llm.js +0 -74
- package/lib/Agent/llm/llm.js.map +0 -1
- package/lib/Agent/llm/stream-collectors.d.ts +0 -46
- package/lib/Agent/llm/stream-collectors.d.ts.map +0 -1
- package/lib/Agent/llm/stream-collectors.js +0 -33
- package/lib/Agent/llm/stream-collectors.js.map +0 -1
- package/lib/Agent/llm/stream-text-part.d.ts +0 -5
- package/lib/Agent/llm/stream-text-part.d.ts.map +0 -1
- package/lib/Agent/llm/stream-text-part.js +0 -4
- package/lib/Agent/llm/stream-text-part.js.map +0 -1
- package/lib/Agent/lsp/client.d.ts +0 -122
- package/lib/Agent/lsp/client.d.ts.map +0 -1
- package/lib/Agent/lsp/client.js +0 -180
- package/lib/Agent/lsp/client.js.map +0 -1
- package/lib/Agent/lsp/diagnostics.d.ts +0 -16
- package/lib/Agent/lsp/diagnostics.d.ts.map +0 -1
- package/lib/Agent/lsp/diagnostics.js +0 -48
- package/lib/Agent/lsp/diagnostics.js.map +0 -1
- package/lib/Agent/lsp/jsonrpc.d.ts +0 -90
- package/lib/Agent/lsp/jsonrpc.d.ts.map +0 -1
- package/lib/Agent/lsp/jsonrpc.js +0 -178
- package/lib/Agent/lsp/jsonrpc.js.map +0 -1
- package/lib/Agent/lsp/manager.d.ts +0 -38
- package/lib/Agent/lsp/manager.d.ts.map +0 -1
- package/lib/Agent/lsp/manager.js +0 -98
- package/lib/Agent/lsp/manager.js.map +0 -1
- package/lib/Agent/lsp/servers.d.ts +0 -28
- package/lib/Agent/lsp/servers.d.ts.map +0 -1
- package/lib/Agent/lsp/servers.js +0 -21
- package/lib/Agent/lsp/servers.js.map +0 -1
- package/lib/Agent/process/driver.d.ts +0 -10
- package/lib/Agent/process/driver.d.ts.map +0 -1
- package/lib/Agent/process/driver.js +0 -153
- package/lib/Agent/process/driver.js.map +0 -1
- package/lib/Agent/process/issue-service.d.ts +0 -44
- package/lib/Agent/process/issue-service.d.ts.map +0 -1
- package/lib/Agent/process/issue-service.js +0 -28
- package/lib/Agent/process/issue-service.js.map +0 -1
- package/lib/Agent/process/issue-tools.d.ts +0 -28
- package/lib/Agent/process/issue-tools.d.ts.map +0 -1
- package/lib/Agent/process/issue-tools.js +0 -28
- package/lib/Agent/process/issue-tools.js.map +0 -1
- package/lib/Agent/process/issue.d.ts +0 -16
- package/lib/Agent/process/issue.d.ts.map +0 -1
- package/lib/Agent/process/issue.js +0 -17
- package/lib/Agent/process/issue.js.map +0 -1
- package/lib/Agent/process/organization.d.ts +0 -4
- package/lib/Agent/process/organization.d.ts.map +0 -1
- package/lib/Agent/process/organization.js +0 -3
- package/lib/Agent/process/organization.js.map +0 -1
- package/lib/Agent/process/process.d.ts +0 -5
- package/lib/Agent/process/process.d.ts.map +0 -1
- package/lib/Agent/process/process.js +0 -3
- package/lib/Agent/process/process.js.map +0 -1
- package/lib/Agent/process/reply.d.ts +0 -16
- package/lib/Agent/process/reply.d.ts.map +0 -1
- package/lib/Agent/process/reply.js +0 -18
- package/lib/Agent/process/reply.js.map +0 -1
- package/lib/Agent/process/task.d.ts +0 -25
- package/lib/Agent/process/task.d.ts.map +0 -1
- package/lib/Agent/process/task.js +0 -26
- package/lib/Agent/process/task.js.map +0 -1
- package/lib/Agent/tool/index.d.ts +0 -4
- package/lib/Agent/tool/index.d.ts.map +0 -1
- package/lib/Agent/tool/index.js +0 -4
- package/lib/Agent/tool/index.js.map +0 -1
- package/lib/Agent/tool/parameter.d.ts +0 -12
- package/lib/Agent/tool/parameter.d.ts.map +0 -1
- package/lib/Agent/tool/parameter.js +0 -6
- package/lib/Agent/tool/parameter.js.map +0 -1
- package/lib/Agent/tool/result.d.ts +0 -17
- package/lib/Agent/tool/result.d.ts.map +0 -1
- package/lib/Agent/tool/result.js +0 -6
- package/lib/Agent/tool/result.js.map +0 -1
- package/lib/Agent/tool/tool.d.ts +0 -32
- package/lib/Agent/tool/tool.d.ts.map +0 -1
- package/lib/Agent/tool/tool.js +0 -16
- package/lib/Agent/tool/tool.js.map +0 -1
- package/lib/Agent/util/command-validator.d.ts +0 -12
- package/lib/Agent/util/command-validator.d.ts.map +0 -1
- package/lib/Agent/util/command-validator.js +0 -74
- package/lib/Agent/util/command-validator.js.map +0 -1
- package/lib/Agent/util/exec.d.ts.map +0 -1
- package/lib/Agent/util/exec.js.map +0 -1
- package/lib/Agent/util/parser.d.ts +0 -5
- package/lib/Agent/util/parser.d.ts.map +0 -1
- package/lib/Agent/util/parser.js +0 -41
- package/lib/Agent/util/parser.js.map +0 -1
- package/lib/Agent/util/replace.d.ts +0 -38
- package/lib/Agent/util/replace.d.ts.map +0 -1
- package/lib/Agent/util/replace.js +0 -458
- package/lib/Agent/util/replace.js.map +0 -1
- package/lib/Agent/util/ripgrep.d.ts +0 -109
- package/lib/Agent/util/ripgrep.d.ts.map +0 -1
- package/lib/Agent/util/ripgrep.js +0 -221
- package/lib/Agent/util/ripgrep.js.map +0 -1
- package/lib/Neon/api.d.ts +0 -258
- package/lib/Neon/api.d.ts.map +0 -1
- package/lib/Neon/api.js +0 -215
- package/lib/Neon/api.js.map +0 -1
- package/src/Agent/Agent.ts +0 -26
- package/src/Agent/Aspect.ts +0 -173
- package/src/Agent/AspectGraph.ts +0 -98
- package/src/Agent/ContextPlugin.ts +0 -18
- package/src/Agent/Plugin.ts +0 -29
- package/src/Agent/chat/channel.ts +0 -26
- package/src/Agent/chat/event.ts +0 -43
- package/src/Agent/chat/message.ts +0 -35
- package/src/Agent/chat/service.ts +0 -133
- package/src/Agent/chat/thread.ts +0 -17
- package/src/Agent/coding/bash.ts +0 -197
- package/src/Agent/coding/edit.ts +0 -152
- package/src/Agent/coding/glob.ts +0 -96
- package/src/Agent/coding/grep.ts +0 -143
- package/src/Agent/coding/index.ts +0 -7
- package/src/Agent/coding/read.ts +0 -119
- package/src/Agent/coding/readlints.ts +0 -78
- package/src/Agent/coding/write.ts +0 -79
- package/src/Agent/fs/file.ts +0 -22
- package/src/Agent/fs/folder.ts +0 -16
- package/src/Agent/index.ts +0 -9
- package/src/Agent/llm/error.ts +0 -330
- package/src/Agent/llm/index.ts +0 -4
- package/src/Agent/llm/llm.ts +0 -131
- package/src/Agent/llm/stream-collectors.ts +0 -58
- package/src/Agent/llm/stream-text-part.ts +0 -7
- package/src/Agent/lsp/client.ts +0 -293
- package/src/Agent/lsp/diagnostics.ts +0 -64
- package/src/Agent/lsp/jsonrpc.ts +0 -317
- package/src/Agent/lsp/manager.ts +0 -213
- package/src/Agent/lsp/servers.ts +0 -37
- package/src/Agent/process/driver.ts +0 -168
- package/src/Agent/process/issue-service.ts +0 -48
- package/src/Agent/process/issue-tools.ts +0 -33
- package/src/Agent/process/issue.ts +0 -22
- package/src/Agent/process/organization.ts +0 -16
- package/src/Agent/process/process.ts +0 -16
- package/src/Agent/process/reply.ts +0 -21
- package/src/Agent/process/task.ts +0 -34
- package/src/Agent/tool/index.ts +0 -3
- package/src/Agent/tool/parameter.ts +0 -35
- package/src/Agent/tool/result.ts +0 -51
- package/src/Agent/tool/tool.ts +0 -74
- package/src/Agent/util/command-validator.ts +0 -98
- package/src/Agent/util/parser.ts +0 -39
- package/src/Agent/util/replace.ts +0 -559
- package/src/Agent/util/ripgrep.ts +0 -256
- package/src/Neon/api.ts +0 -579
- /package/lib/{Agent/util → Util}/exec.d.ts +0 -0
- /package/lib/{Agent/util → Util}/exec.js +0 -0
- /package/src/{Agent/util → Util}/exec.ts +0 -0
|
@@ -1,559 +0,0 @@
|
|
|
1
|
-
// copied from https://github.com/sst/opencode/blob/dev/packages/opencode/src/tool/edit.ts#L1
|
|
2
|
-
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import * as S from "effect/Schema";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Error when oldString is not found in the content.
|
|
8
|
-
*/
|
|
9
|
-
export class ReplaceNotFoundError extends S.TaggedErrorClass<ReplaceNotFoundError>()(
|
|
10
|
-
"ReplaceNotFoundError",
|
|
11
|
-
{
|
|
12
|
-
oldString: S.String,
|
|
13
|
-
},
|
|
14
|
-
) {}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Error when oldString matches multiple locations and replaceAll is not set.
|
|
18
|
-
*/
|
|
19
|
-
export class ReplaceMultipleMatchesError extends S.TaggedErrorClass<ReplaceMultipleMatchesError>()(
|
|
20
|
-
"ReplaceMultipleMatchesError",
|
|
21
|
-
{
|
|
22
|
-
oldString: S.String,
|
|
23
|
-
},
|
|
24
|
-
) {}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Error when oldString equals newString.
|
|
28
|
-
*/
|
|
29
|
-
export class ReplaceSameStringError extends S.TaggedErrorClass<ReplaceSameStringError>()(
|
|
30
|
-
"ReplaceSameStringError",
|
|
31
|
-
{},
|
|
32
|
-
) {}
|
|
33
|
-
|
|
34
|
-
export type Replacer = (
|
|
35
|
-
content: string,
|
|
36
|
-
find: string,
|
|
37
|
-
) => Generator<string, void, unknown>;
|
|
38
|
-
|
|
39
|
-
// Similarity thresholds for block anchor fallback matching
|
|
40
|
-
const SINGLE_CANDIDATE_SIMILARITY_THRESHOLD = 0.0;
|
|
41
|
-
const MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD = 0.3;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Levenshtein distance algorithm implementation
|
|
45
|
-
*/
|
|
46
|
-
function levenshtein(a: string, b: string): number {
|
|
47
|
-
// Handle empty strings
|
|
48
|
-
if (a === "" || b === "") {
|
|
49
|
-
return Math.max(a.length, b.length);
|
|
50
|
-
}
|
|
51
|
-
const matrix = Array.from({ length: a.length + 1 }, (_, i) =>
|
|
52
|
-
Array.from({ length: b.length + 1 }, (_, j) =>
|
|
53
|
-
i === 0 ? j : j === 0 ? i : 0,
|
|
54
|
-
),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
for (let i = 1; i <= a.length; i++) {
|
|
58
|
-
for (let j = 1; j <= b.length; j++) {
|
|
59
|
-
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
60
|
-
matrix[i][j] = Math.min(
|
|
61
|
-
matrix[i - 1][j] + 1,
|
|
62
|
-
matrix[i][j - 1] + 1,
|
|
63
|
-
matrix[i - 1][j - 1] + cost,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return matrix[a.length][b.length];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const SimpleReplacer: Replacer = function* (_content, find) {
|
|
71
|
-
yield find;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const LineTrimmedReplacer: Replacer = function* (content, find) {
|
|
75
|
-
const originalLines = content.split("\n");
|
|
76
|
-
const searchLines = find.split("\n");
|
|
77
|
-
|
|
78
|
-
if (searchLines[searchLines.length - 1] === "") {
|
|
79
|
-
searchLines.pop();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
for (let i = 0; i <= originalLines.length - searchLines.length; i++) {
|
|
83
|
-
let matches = true;
|
|
84
|
-
|
|
85
|
-
for (let j = 0; j < searchLines.length; j++) {
|
|
86
|
-
const originalTrimmed = originalLines[i + j].trim();
|
|
87
|
-
const searchTrimmed = searchLines[j].trim();
|
|
88
|
-
|
|
89
|
-
if (originalTrimmed !== searchTrimmed) {
|
|
90
|
-
matches = false;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (matches) {
|
|
96
|
-
let matchStartIndex = 0;
|
|
97
|
-
for (let k = 0; k < i; k++) {
|
|
98
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
let matchEndIndex = matchStartIndex;
|
|
102
|
-
for (let k = 0; k < searchLines.length; k++) {
|
|
103
|
-
matchEndIndex += originalLines[i + k].length;
|
|
104
|
-
if (k < searchLines.length - 1) {
|
|
105
|
-
matchEndIndex += 1; // Add newline character except for the last line
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const BlockAnchorReplacer: Replacer = function* (content, find) {
|
|
115
|
-
const originalLines = content.split("\n");
|
|
116
|
-
const searchLines = find.split("\n");
|
|
117
|
-
|
|
118
|
-
if (searchLines.length < 3) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (searchLines[searchLines.length - 1] === "") {
|
|
123
|
-
searchLines.pop();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const firstLineSearch = searchLines[0].trim();
|
|
127
|
-
const lastLineSearch = searchLines[searchLines.length - 1].trim();
|
|
128
|
-
const searchBlockSize = searchLines.length;
|
|
129
|
-
|
|
130
|
-
// Collect all candidate positions where both anchors match
|
|
131
|
-
const candidates: Array<{ startLine: number; endLine: number }> = [];
|
|
132
|
-
for (let i = 0; i < originalLines.length; i++) {
|
|
133
|
-
if (originalLines[i].trim() !== firstLineSearch) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Look for the matching last line after this first line
|
|
138
|
-
for (let j = i + 2; j < originalLines.length; j++) {
|
|
139
|
-
if (originalLines[j].trim() === lastLineSearch) {
|
|
140
|
-
candidates.push({ startLine: i, endLine: j });
|
|
141
|
-
break; // Only match the first occurrence of the last line
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Return immediately if no candidates
|
|
147
|
-
if (candidates.length === 0) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Handle single candidate scenario (using relaxed threshold)
|
|
152
|
-
if (candidates.length === 1) {
|
|
153
|
-
const { startLine, endLine } = candidates[0];
|
|
154
|
-
const actualBlockSize = endLine - startLine + 1;
|
|
155
|
-
|
|
156
|
-
let similarity = 0;
|
|
157
|
-
let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2); // Middle lines only
|
|
158
|
-
|
|
159
|
-
if (linesToCheck > 0) {
|
|
160
|
-
for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
|
|
161
|
-
const originalLine = originalLines[startLine + j].trim();
|
|
162
|
-
const searchLine = searchLines[j].trim();
|
|
163
|
-
const maxLen = Math.max(originalLine.length, searchLine.length);
|
|
164
|
-
if (maxLen === 0) {
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
const distance = levenshtein(originalLine, searchLine);
|
|
168
|
-
similarity += (1 - distance / maxLen) / linesToCheck;
|
|
169
|
-
|
|
170
|
-
// Exit early when threshold is reached
|
|
171
|
-
if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) {
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
// No middle lines to compare, just accept based on anchors
|
|
177
|
-
similarity = 1.0;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) {
|
|
181
|
-
let matchStartIndex = 0;
|
|
182
|
-
for (let k = 0; k < startLine; k++) {
|
|
183
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
184
|
-
}
|
|
185
|
-
let matchEndIndex = matchStartIndex;
|
|
186
|
-
for (let k = startLine; k <= endLine; k++) {
|
|
187
|
-
matchEndIndex += originalLines[k].length;
|
|
188
|
-
if (k < endLine) {
|
|
189
|
-
matchEndIndex += 1; // Add newline character except for the last line
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
193
|
-
}
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Calculate similarity for multiple candidates
|
|
198
|
-
let bestMatch: { startLine: number; endLine: number } | null = null;
|
|
199
|
-
let maxSimilarity = -1;
|
|
200
|
-
|
|
201
|
-
for (const candidate of candidates) {
|
|
202
|
-
const { startLine, endLine } = candidate;
|
|
203
|
-
const actualBlockSize = endLine - startLine + 1;
|
|
204
|
-
|
|
205
|
-
let similarity = 0;
|
|
206
|
-
let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2); // Middle lines only
|
|
207
|
-
|
|
208
|
-
if (linesToCheck > 0) {
|
|
209
|
-
for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
|
|
210
|
-
const originalLine = originalLines[startLine + j].trim();
|
|
211
|
-
const searchLine = searchLines[j].trim();
|
|
212
|
-
const maxLen = Math.max(originalLine.length, searchLine.length);
|
|
213
|
-
if (maxLen === 0) {
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
const distance = levenshtein(originalLine, searchLine);
|
|
217
|
-
similarity += 1 - distance / maxLen;
|
|
218
|
-
}
|
|
219
|
-
similarity /= linesToCheck; // Average similarity
|
|
220
|
-
} else {
|
|
221
|
-
// No middle lines to compare, just accept based on anchors
|
|
222
|
-
similarity = 1.0;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (similarity > maxSimilarity) {
|
|
226
|
-
maxSimilarity = similarity;
|
|
227
|
-
bestMatch = candidate;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Threshold judgment
|
|
232
|
-
if (maxSimilarity >= MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD && bestMatch) {
|
|
233
|
-
const { startLine, endLine } = bestMatch;
|
|
234
|
-
let matchStartIndex = 0;
|
|
235
|
-
for (let k = 0; k < startLine; k++) {
|
|
236
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
237
|
-
}
|
|
238
|
-
let matchEndIndex = matchStartIndex;
|
|
239
|
-
for (let k = startLine; k <= endLine; k++) {
|
|
240
|
-
matchEndIndex += originalLines[k].length;
|
|
241
|
-
if (k < endLine) {
|
|
242
|
-
matchEndIndex += 1;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export const WhitespaceNormalizedReplacer: Replacer = function* (
|
|
250
|
-
content,
|
|
251
|
-
find,
|
|
252
|
-
) {
|
|
253
|
-
const normalizeWhitespace = (text: string) =>
|
|
254
|
-
text.replace(/\s+/g, " ").trim();
|
|
255
|
-
const normalizedFind = normalizeWhitespace(find);
|
|
256
|
-
|
|
257
|
-
// Handle single line matches
|
|
258
|
-
const lines = content.split("\n");
|
|
259
|
-
for (let i = 0; i < lines.length; i++) {
|
|
260
|
-
const line = lines[i];
|
|
261
|
-
if (normalizeWhitespace(line) === normalizedFind) {
|
|
262
|
-
yield line;
|
|
263
|
-
} else {
|
|
264
|
-
// Only check for substring matches if the full line doesn't match
|
|
265
|
-
const normalizedLine = normalizeWhitespace(line);
|
|
266
|
-
if (normalizedLine.includes(normalizedFind)) {
|
|
267
|
-
// Find the actual substring in the original line that matches
|
|
268
|
-
const words = find.trim().split(/\s+/);
|
|
269
|
-
if (words.length > 0) {
|
|
270
|
-
const pattern = words
|
|
271
|
-
.map((word) => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
272
|
-
.join("\\s+");
|
|
273
|
-
try {
|
|
274
|
-
const regex = new RegExp(pattern);
|
|
275
|
-
const match = line.match(regex);
|
|
276
|
-
if (match) {
|
|
277
|
-
yield match[0];
|
|
278
|
-
}
|
|
279
|
-
} catch {
|
|
280
|
-
// Invalid regex pattern, skip
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Handle multi-line matches
|
|
288
|
-
const findLines = find.split("\n");
|
|
289
|
-
if (findLines.length > 1) {
|
|
290
|
-
for (let i = 0; i <= lines.length - findLines.length; i++) {
|
|
291
|
-
const block = lines.slice(i, i + findLines.length);
|
|
292
|
-
if (normalizeWhitespace(block.join("\n")) === normalizedFind) {
|
|
293
|
-
yield block.join("\n");
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
export const IndentationFlexibleReplacer: Replacer = function* (content, find) {
|
|
300
|
-
const removeIndentation = (text: string) => {
|
|
301
|
-
const lines = text.split("\n");
|
|
302
|
-
const nonEmptyLines = lines.filter((line) => line.trim().length > 0);
|
|
303
|
-
if (nonEmptyLines.length === 0) return text;
|
|
304
|
-
|
|
305
|
-
const minIndent = Math.min(
|
|
306
|
-
...nonEmptyLines.map((line) => {
|
|
307
|
-
const match = line.match(/^(\s*)/);
|
|
308
|
-
return match ? match[1].length : 0;
|
|
309
|
-
}),
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
return lines
|
|
313
|
-
.map((line) => (line.trim().length === 0 ? line : line.slice(minIndent)))
|
|
314
|
-
.join("\n");
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
const normalizedFind = removeIndentation(find);
|
|
318
|
-
const contentLines = content.split("\n");
|
|
319
|
-
const findLines = find.split("\n");
|
|
320
|
-
|
|
321
|
-
for (let i = 0; i <= contentLines.length - findLines.length; i++) {
|
|
322
|
-
const block = contentLines.slice(i, i + findLines.length).join("\n");
|
|
323
|
-
if (removeIndentation(block) === normalizedFind) {
|
|
324
|
-
yield block;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
export const EscapeNormalizedReplacer: Replacer = function* (content, find) {
|
|
330
|
-
const unescapeString = (str: string): string => {
|
|
331
|
-
return str.replace(/\\(n|t|r|'|"|`|\\|\n|\$)/g, (match, capturedChar) => {
|
|
332
|
-
switch (capturedChar) {
|
|
333
|
-
case "n":
|
|
334
|
-
return "\n";
|
|
335
|
-
case "t":
|
|
336
|
-
return "\t";
|
|
337
|
-
case "r":
|
|
338
|
-
return "\r";
|
|
339
|
-
case "'":
|
|
340
|
-
return "'";
|
|
341
|
-
case '"':
|
|
342
|
-
return '"';
|
|
343
|
-
case "`":
|
|
344
|
-
return "`";
|
|
345
|
-
case "\\":
|
|
346
|
-
return "\\";
|
|
347
|
-
case "\n":
|
|
348
|
-
return "\n";
|
|
349
|
-
case "$":
|
|
350
|
-
return "$";
|
|
351
|
-
default:
|
|
352
|
-
return match;
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
const unescapedFind = unescapeString(find);
|
|
358
|
-
|
|
359
|
-
// Try direct match with unescaped find string
|
|
360
|
-
if (content.includes(unescapedFind)) {
|
|
361
|
-
yield unescapedFind;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// Also try finding escaped versions in content that match unescaped find
|
|
365
|
-
const lines = content.split("\n");
|
|
366
|
-
const findLines = unescapedFind.split("\n");
|
|
367
|
-
|
|
368
|
-
for (let i = 0; i <= lines.length - findLines.length; i++) {
|
|
369
|
-
const block = lines.slice(i, i + findLines.length).join("\n");
|
|
370
|
-
const unescapedBlock = unescapeString(block);
|
|
371
|
-
|
|
372
|
-
if (unescapedBlock === unescapedFind) {
|
|
373
|
-
yield block;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
export const MultiOccurrenceReplacer: Replacer = function* (content, find) {
|
|
379
|
-
// This replacer yields all exact matches, allowing the replace function
|
|
380
|
-
// to handle multiple occurrences based on replaceAll parameter
|
|
381
|
-
let startIndex = 0;
|
|
382
|
-
|
|
383
|
-
while (true) {
|
|
384
|
-
const index = content.indexOf(find, startIndex);
|
|
385
|
-
if (index === -1) break;
|
|
386
|
-
|
|
387
|
-
yield find;
|
|
388
|
-
startIndex = index + find.length;
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
export const TrimmedBoundaryReplacer: Replacer = function* (content, find) {
|
|
393
|
-
const trimmedFind = find.trim();
|
|
394
|
-
|
|
395
|
-
if (trimmedFind === find) {
|
|
396
|
-
// Already trimmed, no point in trying
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// Try to find the trimmed version
|
|
401
|
-
if (content.includes(trimmedFind)) {
|
|
402
|
-
yield trimmedFind;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Also try finding blocks where trimmed content matches
|
|
406
|
-
const lines = content.split("\n");
|
|
407
|
-
const findLines = find.split("\n");
|
|
408
|
-
|
|
409
|
-
for (let i = 0; i <= lines.length - findLines.length; i++) {
|
|
410
|
-
const block = lines.slice(i, i + findLines.length).join("\n");
|
|
411
|
-
|
|
412
|
-
if (block.trim() === trimmedFind) {
|
|
413
|
-
yield block;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
export const ContextAwareReplacer: Replacer = function* (content, find) {
|
|
419
|
-
const findLines = find.split("\n");
|
|
420
|
-
if (findLines.length < 3) {
|
|
421
|
-
// Need at least 3 lines to have meaningful context
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// Remove trailing empty line if present
|
|
426
|
-
if (findLines[findLines.length - 1] === "") {
|
|
427
|
-
findLines.pop();
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
const contentLines = content.split("\n");
|
|
431
|
-
|
|
432
|
-
// Extract first and last lines as context anchors
|
|
433
|
-
const firstLine = findLines[0].trim();
|
|
434
|
-
const lastLine = findLines[findLines.length - 1].trim();
|
|
435
|
-
|
|
436
|
-
// Find blocks that start and end with the context anchors
|
|
437
|
-
for (let i = 0; i < contentLines.length; i++) {
|
|
438
|
-
if (contentLines[i].trim() !== firstLine) continue;
|
|
439
|
-
|
|
440
|
-
// Look for the matching last line
|
|
441
|
-
for (let j = i + 2; j < contentLines.length; j++) {
|
|
442
|
-
if (contentLines[j].trim() === lastLine) {
|
|
443
|
-
// Found a potential context block
|
|
444
|
-
const blockLines = contentLines.slice(i, j + 1);
|
|
445
|
-
const block = blockLines.join("\n");
|
|
446
|
-
|
|
447
|
-
// Check if the middle content has reasonable similarity
|
|
448
|
-
// (simple heuristic: at least 50% of non-empty lines should match when trimmed)
|
|
449
|
-
if (blockLines.length === findLines.length) {
|
|
450
|
-
let matchingLines = 0;
|
|
451
|
-
let totalNonEmptyLines = 0;
|
|
452
|
-
|
|
453
|
-
for (let k = 1; k < blockLines.length - 1; k++) {
|
|
454
|
-
const blockLine = blockLines[k].trim();
|
|
455
|
-
const findLine = findLines[k].trim();
|
|
456
|
-
|
|
457
|
-
if (blockLine.length > 0 || findLine.length > 0) {
|
|
458
|
-
totalNonEmptyLines++;
|
|
459
|
-
if (blockLine === findLine) {
|
|
460
|
-
matchingLines++;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if (
|
|
466
|
-
totalNonEmptyLines === 0 ||
|
|
467
|
-
matchingLines / totalNonEmptyLines >= 0.5
|
|
468
|
-
) {
|
|
469
|
-
yield block;
|
|
470
|
-
break; // Only match the first occurrence
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
export function trimDiff(diff: string): string {
|
|
480
|
-
const lines = diff.split("\n");
|
|
481
|
-
const contentLines = lines.filter(
|
|
482
|
-
(line) =>
|
|
483
|
-
(line.startsWith("+") || line.startsWith("-") || line.startsWith(" ")) &&
|
|
484
|
-
!line.startsWith("---") &&
|
|
485
|
-
!line.startsWith("+++"),
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
if (contentLines.length === 0) return diff;
|
|
489
|
-
|
|
490
|
-
let min = Infinity;
|
|
491
|
-
for (const line of contentLines) {
|
|
492
|
-
const content = line.slice(1);
|
|
493
|
-
if (content.trim().length > 0) {
|
|
494
|
-
const match = content.match(/^(\s*)/);
|
|
495
|
-
if (match) min = Math.min(min, match[1].length);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (min === Infinity || min === 0) return diff;
|
|
499
|
-
const trimmedLines = lines.map((line) => {
|
|
500
|
-
if (
|
|
501
|
-
(line.startsWith("+") || line.startsWith("-") || line.startsWith(" ")) &&
|
|
502
|
-
!line.startsWith("---") &&
|
|
503
|
-
!line.startsWith("+++")
|
|
504
|
-
) {
|
|
505
|
-
const prefix = line[0];
|
|
506
|
-
const content = line.slice(1);
|
|
507
|
-
return prefix + content.slice(min);
|
|
508
|
-
}
|
|
509
|
-
return line;
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
return trimmedLines.join("\n");
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
export const replace = Effect.fn(function* (
|
|
516
|
-
content: string,
|
|
517
|
-
oldString: string,
|
|
518
|
-
newString: string,
|
|
519
|
-
replaceAll = false,
|
|
520
|
-
) {
|
|
521
|
-
if (oldString === newString) {
|
|
522
|
-
return yield* new ReplaceSameStringError();
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
let notFound = true;
|
|
526
|
-
|
|
527
|
-
for (const replacer of [
|
|
528
|
-
SimpleReplacer,
|
|
529
|
-
LineTrimmedReplacer,
|
|
530
|
-
BlockAnchorReplacer,
|
|
531
|
-
WhitespaceNormalizedReplacer,
|
|
532
|
-
IndentationFlexibleReplacer,
|
|
533
|
-
EscapeNormalizedReplacer,
|
|
534
|
-
TrimmedBoundaryReplacer,
|
|
535
|
-
ContextAwareReplacer,
|
|
536
|
-
MultiOccurrenceReplacer,
|
|
537
|
-
]) {
|
|
538
|
-
for (const search of replacer(content, oldString)) {
|
|
539
|
-
const index = content.indexOf(search);
|
|
540
|
-
if (index === -1) continue;
|
|
541
|
-
notFound = false;
|
|
542
|
-
if (replaceAll) {
|
|
543
|
-
return content.replaceAll(search, newString);
|
|
544
|
-
}
|
|
545
|
-
const lastIndex = content.lastIndexOf(search);
|
|
546
|
-
if (index !== lastIndex) continue;
|
|
547
|
-
return (
|
|
548
|
-
content.substring(0, index) +
|
|
549
|
-
newString +
|
|
550
|
-
content.substring(index + search.length)
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if (notFound) {
|
|
556
|
-
return yield* new ReplaceNotFoundError({ oldString });
|
|
557
|
-
}
|
|
558
|
-
return yield* new ReplaceMultipleMatchesError({ oldString });
|
|
559
|
-
});
|