mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-01 18:26:38 +00:00
STASH COMPLEX PLUGIN
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { createOpencodeClient as createOpencodeClientV2, Event as TuiEvent } from "@opencode-ai/sdk/v2"
|
||||
import type { CliRenderer, Plugin as CorePlugin } from "@opentui/core"
|
||||
import type { CliRenderer, ParsedKey, Plugin as CorePlugin } from "@opentui/core"
|
||||
import type { Plugin as ServerPlugin, PluginOptions } from "./index"
|
||||
|
||||
export type { CliRenderer, SlotMode } from "@opentui/core"
|
||||
@@ -22,7 +22,77 @@ export type ThemeJson = {
|
||||
}
|
||||
}
|
||||
|
||||
export type TuiRoute =
|
||||
| {
|
||||
type: "home"
|
||||
}
|
||||
| {
|
||||
type: "session"
|
||||
sessionID: string
|
||||
}
|
||||
| {
|
||||
type: "plugin"
|
||||
id: string
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type TuiCommand = {
|
||||
title: string
|
||||
value: string
|
||||
description?: string
|
||||
category?: string
|
||||
keybind?: string
|
||||
suggested?: boolean
|
||||
hidden?: boolean
|
||||
enabled?: boolean
|
||||
slash?: {
|
||||
name: string
|
||||
aliases?: string[]
|
||||
}
|
||||
onSelect?: () => void
|
||||
}
|
||||
|
||||
export type TuiKeybind = {
|
||||
name: string
|
||||
ctrl: boolean
|
||||
meta: boolean
|
||||
shift: boolean
|
||||
super?: boolean
|
||||
leader: boolean
|
||||
}
|
||||
|
||||
export type TuiApi<Node = unknown> = {
|
||||
command: {
|
||||
register: (cb: () => TuiCommand[]) => void
|
||||
trigger: (value: string) => void
|
||||
}
|
||||
dialog: {
|
||||
clear: () => void
|
||||
replace: (input: Node | (() => Node), onClose?: () => void) => void
|
||||
readonly depth: number
|
||||
}
|
||||
route: {
|
||||
readonly data: TuiRoute
|
||||
navigate: (route: TuiRoute) => void
|
||||
home: () => void
|
||||
plugin: (id: string, data?: Record<string, unknown>) => void
|
||||
}
|
||||
keybind: {
|
||||
parse: (evt: ParsedKey) => TuiKeybind
|
||||
match: (key: string, evt: ParsedKey) => boolean
|
||||
print: (key: string) => string
|
||||
}
|
||||
theme: {
|
||||
readonly current: Record<string, unknown>
|
||||
}
|
||||
}
|
||||
|
||||
export type TuiSlotMap = {
|
||||
app: {}
|
||||
route: {
|
||||
route_id: string
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
home_logo: {}
|
||||
sidebar_top: {
|
||||
session_id: string
|
||||
@@ -44,21 +114,22 @@ export type TuiEventBus = {
|
||||
) => () => void
|
||||
}
|
||||
|
||||
export type TuiPluginInput<Renderer = CliRenderer> = {
|
||||
export type TuiPluginInput<Renderer = CliRenderer, Node = unknown> = {
|
||||
client: ReturnType<typeof createOpencodeClientV2>
|
||||
event: TuiEventBus
|
||||
renderer: Renderer
|
||||
slots: TuiSlots
|
||||
api: TuiApi<Node>
|
||||
}
|
||||
|
||||
export type TuiPlugin<Renderer = CliRenderer> = (
|
||||
input: TuiPluginInput<Renderer>,
|
||||
export type TuiPlugin<Renderer = CliRenderer, Node = unknown> = (
|
||||
input: TuiPluginInput<Renderer, Node>,
|
||||
options?: PluginOptions,
|
||||
) => Promise<void>
|
||||
|
||||
export type TuiPluginModule<Renderer = CliRenderer> = {
|
||||
export type TuiPluginModule<Renderer = CliRenderer, Node = unknown> = {
|
||||
server?: ServerPlugin
|
||||
tui?: TuiPlugin<Renderer>
|
||||
tui?: TuiPlugin<Renderer, Node>
|
||||
slots?: TuiSlotPlugin
|
||||
themes?: Record<string, ThemeJson>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user