Skip to content

Commit 9b8282a

Browse files
committed
feat(plugin): add v2 tui entrypoint
1 parent 2a08cd3 commit 9b8282a

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

packages/plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"./tui": "./src/tui.ts",
1616
"./v2/effect": "./src/v2/effect/index.ts",
1717
"./v2/effect/*": "./src/v2/effect/*.ts",
18-
"./v2/tui/*": "./src/v2/tui/*.ts",
18+
"./v2/tui": "./src/v2/tui/index.ts",
1919
"./v2": "./src/v2/promise/index.ts",
2020
"./v2/*": "./src/v2/promise/*.ts"
2121
},

packages/plugin/src/v2/tui/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export interface UI {
105105
}
106106

107107
export interface Context {
108-
readonly options: Record<string, any>
108+
readonly options: Readonly<Record<string, unknown>>
109109
readonly client: OpenCodeClient
110110
readonly data: Data
111111
readonly ui: UI
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as Plugin from "./plugin.js"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Context } from "./context.js"
2+
3+
export type { Context }
4+
5+
export type Cleanup = () => Promise<void> | void
6+
7+
export interface Definition {
8+
readonly id: string
9+
readonly setup: (context: Context) => Promise<Cleanup | void> | Cleanup | void
10+
}
11+
12+
export function define(plugin: Definition) {
13+
return plugin
14+
}

packages/plugin/test/contract-identity.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Skill } from "@opencode-ai/schema/skill"
1111

1212
const Plugin = await import("../src/v2/effect/index")
1313
const PromisePlugin = await import("../src/v2/promise/index")
14+
const TuiPlugin = await import("../src/v2/tui/index")
1415

1516
test.each([
1617
["effect", Plugin],
@@ -38,3 +39,8 @@ test.each([
3839
"Skill",
3940
])
4041
})
42+
43+
test("tui entrypoint exposes the V2 plugin definition", () => {
44+
const plugin = TuiPlugin.Plugin.define({ id: "demo", setup() {} })
45+
expect(plugin.id).toBe("demo")
46+
})

0 commit comments

Comments
 (0)