diff --git a/packages/plugin/src/effect/command.ts b/packages/plugin/src/effect/command.ts index 59be027df91..ce40ff193d1 100644 --- a/packages/plugin/src/effect/command.ts +++ b/packages/plugin/src/effect/command.ts @@ -1,16 +1,19 @@ import type { CommandApi } from "@opencode-ai/client/effect/api" -import type { CommandInfo } from "@opencode-ai/client" -import type { Effect } from "effect" -import type { Transform } from "./registration.js" +import type { Session } from "@opencode-ai/schema/session" +import type { Effect, Scope } from "effect" +import type { Registration } from "./registration.js" -export interface CommandDraft { - list(): readonly CommandInfo[] - get(name: string): CommandInfo | undefined - update(name: string, update: (command: CommandInfo) => void): void - remove(name: string): void +export interface CommandInvocation { + readonly sessionID: Session.ID + readonly arguments: string } -export interface CommandDomain extends CommandApi { - readonly transform: Transform - readonly reload: () => Effect.Effect +export interface CommandDefinition { + readonly name: string + readonly description?: string + readonly run: (input: CommandInvocation) => Effect.Effect +} + +export interface CommandDomain extends Pick, "list"> { + readonly register: (definition: CommandDefinition) => Effect.Effect } diff --git a/packages/plugin/src/promise/command.ts b/packages/plugin/src/promise/command.ts index cc9de3f3cb9..30c879703a8 100644 --- a/packages/plugin/src/promise/command.ts +++ b/packages/plugin/src/promise/command.ts @@ -1,15 +1,18 @@ import type { CommandApi } from "@opencode-ai/client/promise/api" -import type { CommandInfo } from "@opencode-ai/client" -import type { Transform } from "./registration.js" +import type { Session } from "@opencode-ai/schema/session" +import type { Registration } from "./registration.js" -export interface CommandDraft { - list(): readonly CommandInfo[] - get(name: string): CommandInfo | undefined - update(name: string, update: (command: CommandInfo) => void): void - remove(name: string): void +export interface CommandInvocation { + readonly sessionID: Session.ID + readonly arguments: string } -export interface CommandDomain extends CommandApi { - readonly transform: Transform - readonly reload: () => Promise +export interface CommandDefinition { + readonly name: string + readonly description?: string + readonly run: (input: CommandInvocation) => Promise +} + +export interface CommandDomain extends Pick { + readonly register: (definition: CommandDefinition) => Promise }