mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-24 06:33:01 -04:00
feat(plugin): register command callbacks
This commit is contained in:
@@ -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<unknown> {
|
||||
readonly transform: Transform<CommandDraft>
|
||||
readonly reload: () => Effect.Effect<void>
|
||||
export interface CommandDefinition {
|
||||
readonly name: string
|
||||
readonly description?: string
|
||||
readonly run: (input: CommandInvocation) => Effect.Effect<void>
|
||||
}
|
||||
|
||||
export interface CommandDomain extends Pick<CommandApi<unknown>, "list"> {
|
||||
readonly register: (definition: CommandDefinition) => Effect.Effect<Registration, never, Scope.Scope>
|
||||
}
|
||||
|
||||
@@ -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<CommandDraft>
|
||||
readonly reload: () => Promise<void>
|
||||
export interface CommandDefinition {
|
||||
readonly name: string
|
||||
readonly description?: string
|
||||
readonly run: (input: CommandInvocation) => Promise<void>
|
||||
}
|
||||
|
||||
export interface CommandDomain extends Pick<CommandApi, "list"> {
|
||||
readonly register: (definition: CommandDefinition) => Promise<Registration>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user