Compare commits

...
1 Commits
Author SHA1 Message Date
Dax Raad 2ada79018e feat(plugin): register command callbacks 2026-08-19 18:19:03 -04:00
2 changed files with 27 additions and 21 deletions
+14 -11
View File
@@ -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>
}
+13 -10
View File
@@ -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>
}