refactor(core): migrate built-in tools to internal plugins (#34956)

This commit is contained in:
Kit Langton 2026-07-03 09:03:53 -04:00 committed by GitHub
commit 88dc960af8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 315 additions and 273 deletions

View file

@ -6,15 +6,13 @@
*/
export * as WriteTool from "./write"
import type { PluginContext } from "@opencode-ai/plugin/v2/effect"
import { ToolFailure } from "@opencode-ai/llm"
import { Effect, Layer, Schema } from "effect"
import { makeLocationNode } from "../effect/app-node"
import { Effect, Schema } from "effect"
import { FileMutation } from "../file-mutation"
import { LocationMutation } from "../location-mutation"
import { PermissionV2 } from "../permission"
import { ToolRegistry } from "./registry"
import { Tool } from "./tool"
import { Tools } from "./tools"
export const name = "write"
@ -44,14 +42,14 @@ export const toModelOutput = (output: Output) =>
// TODO: Add snapshots / undo after design exists.
// TODO: Add LSP notification and diagnostics after V2 LSP runtime exists.
const layer = Layer.effectDiscard(
Effect.gen(function* () {
const tools = yield* Tools.Service
export const Plugin = {
id: "core-write-tool",
effect: Effect.fn("WriteTool.Plugin")(function* (ctx: PluginContext) {
const mutation = yield* LocationMutation.Service
const files = yield* FileMutation.Service
const permission = yield* PermissionV2.Service
yield* tools
yield* ctx.tool
.register({
[name]: Tool.withPermission(
Tool.make({
@ -92,10 +90,4 @@ const layer = Layer.effectDiscard(
})
.pipe(Effect.orDie)
}),
)
export const node = makeLocationNode({
name: "tool/write",
layer,
deps: [ToolRegistry.node, LocationMutation.node, FileMutation.node, PermissionV2.node],
})
}