feat(plugin): add v2 tui entrypoint
This commit is contained in:
parent
2a08cd3b96
commit
9b8282ad3d
5 changed files with 23 additions and 2 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
"./tui": "./src/tui.ts",
|
"./tui": "./src/tui.ts",
|
||||||
"./v2/effect": "./src/v2/effect/index.ts",
|
"./v2/effect": "./src/v2/effect/index.ts",
|
||||||
"./v2/effect/*": "./src/v2/effect/*.ts",
|
"./v2/effect/*": "./src/v2/effect/*.ts",
|
||||||
"./v2/tui/*": "./src/v2/tui/*.ts",
|
"./v2/tui": "./src/v2/tui/index.ts",
|
||||||
"./v2": "./src/v2/promise/index.ts",
|
"./v2": "./src/v2/promise/index.ts",
|
||||||
"./v2/*": "./src/v2/promise/*.ts"
|
"./v2/*": "./src/v2/promise/*.ts"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ export interface UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Context {
|
export interface Context {
|
||||||
readonly options: Record<string, any>
|
readonly options: Readonly<Record<string, unknown>>
|
||||||
readonly client: OpenCodeClient
|
readonly client: OpenCodeClient
|
||||||
readonly data: Data
|
readonly data: Data
|
||||||
readonly ui: UI
|
readonly ui: UI
|
||||||
|
|
|
||||||
1
packages/plugin/src/v2/tui/index.ts
Normal file
1
packages/plugin/src/v2/tui/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * as Plugin from "./plugin.js"
|
||||||
14
packages/plugin/src/v2/tui/plugin.ts
Normal file
14
packages/plugin/src/v2/tui/plugin.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import type { Context } from "./context.js"
|
||||||
|
|
||||||
|
export type { Context }
|
||||||
|
|
||||||
|
export type Cleanup = () => Promise<void> | void
|
||||||
|
|
||||||
|
export interface Definition {
|
||||||
|
readonly id: string
|
||||||
|
readonly setup: (context: Context) => Promise<Cleanup | void> | Cleanup | void
|
||||||
|
}
|
||||||
|
|
||||||
|
export function define(plugin: Definition) {
|
||||||
|
return plugin
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import { Skill } from "@opencode-ai/schema/skill"
|
||||||
|
|
||||||
const Plugin = await import("../src/v2/effect/index")
|
const Plugin = await import("../src/v2/effect/index")
|
||||||
const PromisePlugin = await import("../src/v2/promise/index")
|
const PromisePlugin = await import("../src/v2/promise/index")
|
||||||
|
const TuiPlugin = await import("../src/v2/tui/index")
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
["effect", Plugin],
|
["effect", Plugin],
|
||||||
|
|
@ -38,3 +39,8 @@ test.each([
|
||||||
"Skill",
|
"Skill",
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("tui entrypoint exposes the V2 plugin definition", () => {
|
||||||
|
const plugin = TuiPlugin.Plugin.define({ id: "demo", setup() {} })
|
||||||
|
expect(plugin.id).toBe("demo")
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue