refactor(core): defer mcp prompt commands
This commit is contained in:
parent
14dc46f0d0
commit
e1fa90e514
2 changed files with 0 additions and 39 deletions
|
|
@ -20,7 +20,6 @@ import { FSUtil } from "../fs-util"
|
||||||
import { Global } from "../global"
|
import { Global } from "../global"
|
||||||
import { Integration } from "../integration"
|
import { Integration } from "../integration"
|
||||||
import { Location } from "../location"
|
import { Location } from "../location"
|
||||||
import { MCP } from "../mcp"
|
|
||||||
import { ModelsDev } from "../models-dev"
|
import { ModelsDev } from "../models-dev"
|
||||||
import { Npm } from "../npm"
|
import { Npm } from "../npm"
|
||||||
import { PluginV2 } from "../plugin"
|
import { PluginV2 } from "../plugin"
|
||||||
|
|
@ -30,7 +29,6 @@ import { State } from "../state"
|
||||||
import { FetchHttpClient, HttpClient } from "effect/unstable/http"
|
import { FetchHttpClient, HttpClient } from "effect/unstable/http"
|
||||||
import { AgentPlugin } from "./agent"
|
import { AgentPlugin } from "./agent"
|
||||||
import { CommandPlugin } from "./command"
|
import { CommandPlugin } from "./command"
|
||||||
import { McpCommandPlugin } from "./mcp-command"
|
|
||||||
import { ModelsDevPlugin } from "./models-dev"
|
import { ModelsDevPlugin } from "./models-dev"
|
||||||
import { ProviderPlugins } from "./provider"
|
import { ProviderPlugins } from "./provider"
|
||||||
import { SdkPlugins } from "./sdk"
|
import { SdkPlugins } from "./sdk"
|
||||||
|
|
@ -49,7 +47,6 @@ export type Requirements =
|
||||||
| HttpClient.HttpClient
|
| HttpClient.HttpClient
|
||||||
| Integration.Service
|
| Integration.Service
|
||||||
| Location.Service
|
| Location.Service
|
||||||
| MCP.Service
|
|
||||||
| ModelsDev.Service
|
| ModelsDev.Service
|
||||||
| Npm.Service
|
| Npm.Service
|
||||||
| Reference.Service
|
| Reference.Service
|
||||||
|
|
@ -74,7 +71,6 @@ const layer = Layer.effectDiscard(
|
||||||
const agents = yield* AgentV2.Service
|
const agents = yield* AgentV2.Service
|
||||||
const config = yield* Config.Service
|
const config = yield* Config.Service
|
||||||
const location = yield* Location.Service
|
const location = yield* Location.Service
|
||||||
const mcp = yield* MCP.Service
|
|
||||||
const modelsDev = yield* ModelsDev.Service
|
const modelsDev = yield* ModelsDev.Service
|
||||||
const npm = yield* Npm.Service
|
const npm = yield* Npm.Service
|
||||||
const events = yield* EventV2.Service
|
const events = yield* EventV2.Service
|
||||||
|
|
@ -97,7 +93,6 @@ const layer = Layer.effectDiscard(
|
||||||
Effect.provideService(AgentV2.Service, agents),
|
Effect.provideService(AgentV2.Service, agents),
|
||||||
Effect.provideService(Config.Service, config),
|
Effect.provideService(Config.Service, config),
|
||||||
Effect.provideService(Location.Service, location),
|
Effect.provideService(Location.Service, location),
|
||||||
Effect.provideService(MCP.Service, mcp),
|
|
||||||
Effect.provideService(ModelsDev.Service, modelsDev),
|
Effect.provideService(ModelsDev.Service, modelsDev),
|
||||||
Effect.provideService(Npm.Service, npm),
|
Effect.provideService(Npm.Service, npm),
|
||||||
Effect.provideService(EventV2.Service, events),
|
Effect.provideService(EventV2.Service, events),
|
||||||
|
|
@ -121,7 +116,6 @@ const layer = Layer.effectDiscard(
|
||||||
yield* add(ModelsDevPlugin)
|
yield* add(ModelsDevPlugin)
|
||||||
yield* add(ConfigAgentPlugin.Plugin)
|
yield* add(ConfigAgentPlugin.Plugin)
|
||||||
yield* add(ConfigCommandPlugin.Plugin)
|
yield* add(ConfigCommandPlugin.Plugin)
|
||||||
yield* add(McpCommandPlugin.Plugin)
|
|
||||||
yield* add(ConfigSkillPlugin.Plugin)
|
yield* add(ConfigSkillPlugin.Plugin)
|
||||||
for (const item of ProviderPlugins) yield* add(item)
|
for (const item of ProviderPlugins) yield* add(item)
|
||||||
yield* add(ConfigExternalPlugin.Plugin)
|
yield* add(ConfigExternalPlugin.Plugin)
|
||||||
|
|
@ -152,7 +146,6 @@ export const node = makeLocationNode({
|
||||||
AgentV2.node,
|
AgentV2.node,
|
||||||
Config.node,
|
Config.node,
|
||||||
Location.node,
|
Location.node,
|
||||||
MCP.node,
|
|
||||||
ModelsDev.node,
|
ModelsDev.node,
|
||||||
Npm.node,
|
Npm.node,
|
||||||
EventV2.node,
|
EventV2.node,
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
export * as McpCommandPlugin from "./mcp-command"
|
|
||||||
|
|
||||||
import { McpEvent } from "@opencode-ai/schema/mcp-event"
|
|
||||||
import { Effect, Stream } from "effect"
|
|
||||||
import { EventV2 } from "../event"
|
|
||||||
import { MCP } from "../mcp"
|
|
||||||
import { define } from "./internal"
|
|
||||||
|
|
||||||
export const Plugin = define({
|
|
||||||
id: "mcp-command",
|
|
||||||
effect: Effect.fn(function* (ctx) {
|
|
||||||
const mcp = yield* MCP.Service
|
|
||||||
const events = yield* EventV2.Service
|
|
||||||
yield* ctx.command.transform(
|
|
||||||
Effect.fn(function* (draft) {
|
|
||||||
for (const prompt of yield* mcp.prompts()) {
|
|
||||||
draft.update(commandName(prompt), (command) => {
|
|
||||||
command.template = ""
|
|
||||||
command.description = prompt.description
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
yield* events
|
|
||||||
.subscribe(McpEvent.PromptsChanged)
|
|
||||||
.pipe(Stream.runForEach(() => ctx.command.reload()), Effect.forkScoped({ startImmediately: true }))
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
const commandName = (prompt: MCP.Prompt) => `${sanitize(prompt.server)}:${sanitize(prompt.name)}`
|
|
||||||
|
|
||||||
const sanitize = (value: string) => value.replace(/[^a-zA-Z0-9_-]/g, "_")
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue