@opencode/plugin 0.0.0-dev-51 → 0.0.0-dev-56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/effect/integration.d.ts +5 -2
  2. package/dist/gui/browser.d.ts +36 -0
  3. package/dist/gui/browser.js +3 -0
  4. package/dist/gui/context.d.ts +223 -0
  5. package/dist/gui/context.js +0 -0
  6. package/dist/gui/core.d.ts +560 -0
  7. package/dist/gui/core.js +86 -0
  8. package/dist/gui/declarations.d.ts +24 -0
  9. package/dist/gui/declarations.js +0 -0
  10. package/dist/gui/file.d.ts +122 -0
  11. package/dist/gui/file.js +7 -0
  12. package/dist/gui/host-apis.d.ts +1109 -0
  13. package/dist/gui/host-apis.js +0 -0
  14. package/dist/gui/icon-name.d.ts +2 -0
  15. package/dist/gui/icon-name.js +1 -0
  16. package/dist/gui/index.d.ts +7 -0
  17. package/dist/gui/index.js +6 -0
  18. package/dist/gui/internal.d.ts +44 -0
  19. package/dist/gui/internal.js +33 -0
  20. package/dist/gui/main.d.ts +279 -0
  21. package/dist/gui/main.js +20 -0
  22. package/dist/gui/modules.d.ts +15 -0
  23. package/dist/gui/modules.js +30 -0
  24. package/dist/gui/plugin.d.ts +86 -0
  25. package/dist/gui/plugin.js +9 -0
  26. package/dist/gui/reactive.d.ts +93 -0
  27. package/dist/gui/reactive.js +130 -0
  28. package/dist/gui/registries.d.ts +770 -0
  29. package/dist/gui/registries.js +110 -0
  30. package/dist/gui/review.d.ts +73 -0
  31. package/dist/gui/review.js +3 -0
  32. package/dist/gui/scope.d.ts +64 -0
  33. package/dist/gui/scope.js +85 -0
  34. package/dist/gui/solid.d.ts +99 -0
  35. package/dist/gui/solid.js +74 -0
  36. package/dist/gui/vite.d.ts +24 -0
  37. package/dist/gui/vite.js +49 -0
  38. package/dist/host.d.ts +12 -1
  39. package/dist/host.js +34 -2
  40. package/dist/promise/integration.d.ts +5 -2
  41. package/dist/runtime-modules.js +3 -1
  42. package/package.json +54 -10
@@ -1,11 +1,14 @@
1
- import type { ConnectionInfo, IntegrationInfo } from "@opencode/client";
1
+ import type { ConnectionInfo } from "@opencode/client";
2
2
  import type { IntegrationApi } from "@opencode/client/effect/api";
3
3
  import { Connection } from "@opencode/schema/connection";
4
4
  import { Credential } from "@opencode/schema/credential";
5
5
  import { Form } from "@opencode/schema/form";
6
6
  import type { Effect, Scope } from "effect";
7
7
  import type { Transform } from "./registration.js";
8
- type IntegrationRef = Pick<IntegrationInfo, "id" | "name" | "configured">;
8
+ type IntegrationRef = {
9
+ id: string;
10
+ name: string;
11
+ };
9
12
  export interface IntegrationOAuthMethod {
10
13
  readonly id: string;
11
14
  readonly type: "oauth";
@@ -0,0 +1,36 @@
1
+ import { Contract } from "./core.js";
2
+ import type { SessionRef } from "./host-apis.js";
3
+ /** What the built-in browser offers other plugins: a session's desktop browser pane. Read it with `ctx.use(Browser)`. */
4
+ export interface Browser {
5
+ /**
6
+ * The desktop browser pane exists for this session (the session is attached to a pane).
7
+ *
8
+ * @param session - The session to check.
9
+ * @returns True when the session has a pane.
10
+ */
11
+ attached(session: SessionRef): boolean;
12
+ /**
13
+ * A workspace file (relative path) or http(s) URL can open in the pane for this session.
14
+ *
15
+ * @param session - The session whose pane would open it.
16
+ * @param path - A workspace-relative file path or an http(s) URL; omit it to ask whether the pane can open anything.
17
+ * @returns True when `open` or `openFile` would succeed.
18
+ */
19
+ canOpen(session: SessionRef, path?: string): boolean;
20
+ /**
21
+ * Opens a URL (http(s) or file://) as a browser tab in the session's side panel.
22
+ *
23
+ * @param session - The session whose pane opens it.
24
+ * @param url - The URL to open.
25
+ */
26
+ open(session: SessionRef, url: string): void;
27
+ /**
28
+ * Opens a workspace file (relative path) as a file:// browser tab. Check `canOpen(session, path)` first.
29
+ *
30
+ * @param session - The session whose pane opens it.
31
+ * @param path - The workspace-relative file path.
32
+ */
33
+ openFile(session: SessionRef, path: string): void;
34
+ }
35
+ /** The browser plugin provides this on desktop. Inactive on web or while the plugin is off. */
36
+ export declare const Browser: Contract<Browser, "browser">;
@@ -0,0 +1,3 @@
1
+ import { Contract } from "./core.js";
2
+ /** The browser plugin provides this on desktop. Inactive on web or while the plugin is off. */
3
+ export const Browser = Contract.define("browser");
@@ -0,0 +1,223 @@
1
+ import type { Accessor } from "solid-js";
2
+ import type { BaseContext, App, Cleanup, Contract, DeclaredStores, Ipc, IpcClient, IpcSpec, Live, Persisted, StoreDeclaration, Token, TokenValue } from "./core.js";
3
+ import type { Appearance, Desktop, Dialogs, Embeds, Keybinds, Layout, Links, Locale, Router, Screen, Servers, SessionRef, Sessions, Storage, System, Workspaces } from "./host-apis.js";
4
+ /**
5
+ * What every window entry gets. Contracts are provided and read at runtime: `ctx.provide` for your own, `ctx.use` for
6
+ * other plugins', `ctx.main` for your main process. The APIs the host always provides are properties, each created
7
+ * on first read.
8
+ * Setup runs under the plugin's root owner: Solid's `onCleanup` in setup runs when the plugin goes away.
9
+ * `usePlugin()` returns the same object inside contributions.
10
+ */
11
+ export interface Context extends BaseContext {
12
+ /**
13
+ * Provides an in-process contract. Withdrawn with the current owner, else with the plugin. Throws for a contract
14
+ * whose id is not your plugin's id or under it (`<id>.<name>`), and for an Ipc token: Ipcs are provided by the main
15
+ * entry.
16
+ *
17
+ * @param token - The contract.
18
+ * @param impl - Its implementation.
19
+ * @returns Withdraws the contract early.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * ctx.provide(Changes, { diffs, open })
24
+ * ```
25
+ */
26
+ provide<C extends Contract<unknown>>(token: C, impl: TokenValue<C>): Cleanup;
27
+ /**
28
+ * Follows a contract or an Ipc that another plugin provides. Returns a `Live` accessor: pending while its provider
29
+ * loads, active with its value, inactive while it is turned off or failed. The plugin must keep working while it is
30
+ * inactive. Branch on it, or follow it with `createKeyed`. The provider is the plugin whose id the token's id names.
31
+ *
32
+ * @param token - The contract or Ipc.
33
+ * @returns The provider as a `Live` accessor; the same accessor for every call with the token.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * createKeyed(ctx.use(Changes), (changes) => changes.watch(screen, "files"))
38
+ * ```
39
+ */
40
+ use<T extends Token>(token: T): Accessor<Live<TokenValue<T>>>;
41
+ /**
42
+ * The client of an Ipc your own main entry provides. A call waits while the main entry starts, and rejects when it
43
+ * cannot answer: on the web, while the plugin's main entry is off or failed, or when main throws. A call waits
44
+ * indefinitely when the plugin has no main entry. `state` and `on`
45
+ * follow the main entry across restarts. Throws for an Ipc whose id is not your plugin's id or under it.
46
+ *
47
+ * @param token - The Ipc.
48
+ * @returns Its client; the same client for every call with the token.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const awake = ctx.main(KeepAwake)
53
+ * ctx.add(Command, { id: "awake", title: ctx.t("awake"), run: () => void awake.set(true) })
54
+ * ```
55
+ */
56
+ main<S extends IpcSpec>(token: Ipc<S>): IpcClient<S>;
57
+ /**
58
+ * Side panel tabs, scroll offsets, and the settings and project dialogs.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * ctx.layout.open(`${ctx.id}:main`, session, { background: true })
63
+ * ```
64
+ */
65
+ readonly layout: Layout;
66
+ /**
67
+ * The sessions of open shell tabs, and the mounted one.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const session = ctx.sessions.current()
72
+ * ```
73
+ */
74
+ readonly sessions: Sessions;
75
+ /**
76
+ * The mounted session screen and its route-following files, comments and composer. Read it where you act, so an
77
+ * action targets the session routed at that moment; a `MountedSession` carries no such actions.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const screen = ctx.screen.current()
82
+ * if (screen) screen.composer.attach({ type: "file", path })
83
+ * ```
84
+ */
85
+ readonly screen: Screen;
86
+ /**
87
+ * Stores for keys only known at runtime, and window-local memory. Declare `stores` for keys known up front.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const recent = ctx.storage.store(`recent.${server}`, { schema: Recent, initial: { paths: [] } })
92
+ * ```
93
+ */
94
+ readonly storage: Storage;
95
+ /**
96
+ * The clipboard, saving files, and opening URLs in the system browser. Works on every platform.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * await ctx.system.copy(url)
101
+ * ```
102
+ */
103
+ readonly system: System;
104
+ /**
105
+ * Desktop-only abilities; undefined on the web.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * if (!ctx.desktop) return
110
+ * void ctx.desktop.reveal(path)
111
+ * ```
112
+ */
113
+ readonly desktop: Desktop | undefined;
114
+ /**
115
+ * Dialogs that close with the owner that opened them, else when the plugin goes away.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * ctx.dialogs.open((dialog) => <ConfirmDialog onDone={dialog.close} />)
120
+ * ```
121
+ */
122
+ readonly dialogs: Dialogs;
123
+ /**
124
+ * Routes local links to the plugins that handle them.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * ctx.links.open({ href: path, session, exact: true })
129
+ * ```
130
+ */
131
+ readonly links: Links;
132
+ /**
133
+ * Shows the web pages the main entry created.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * <ctx.embeds.View id={embed()} visible={visible()} />
138
+ * ```
139
+ */
140
+ readonly embeds: Embeds;
141
+ /**
142
+ * The running app: its version, release channel and platform, as `ctx.app` in server and TUI plugins.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * if (ctx.app.channel === "dev") showDebug()
147
+ * ```
148
+ */
149
+ readonly app: App;
150
+ /**
151
+ * The interface language and its writing direction.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * new Intl.NumberFormat(ctx.locale.locale()).format(count)
156
+ * ```
157
+ */
158
+ readonly locale: Locale;
159
+ /**
160
+ * The user's appearance settings.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * terminal.options.fontFamily = ctx.appearance.font("mono")
165
+ * ```
166
+ */
167
+ readonly appearance: Appearance;
168
+ /**
169
+ * The app's route.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * const onSettings = () => ctx.router.path().startsWith("/settings")
174
+ * ```
175
+ */
176
+ readonly router: Router;
177
+ /**
178
+ * The effective keybinds of published commands.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const keys = () => ctx.keybinds.keybind(`${ctx.id}.toggle`)
183
+ * ```
184
+ */
185
+ readonly keybinds: Keybinds;
186
+ /**
187
+ * The servers the app lists: their ids, and each one's live `ServerRef`.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * const known = () => new Set(ctx.servers.list())
192
+ * const server = (id: string) => ctx.servers.get(id)
193
+ * ```
194
+ */
195
+ readonly servers: Servers;
196
+ /**
197
+ * Workspace lifecycle events.
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * ctx.workspaces.on("remove", (value) => forget(value.server, value.directory))
202
+ * ```
203
+ */
204
+ readonly workspaces: Workspaces;
205
+ }
206
+ type Handle<S> = S extends StoreDeclaration<infer Schema, infer Scope> ? Scope extends "global" ? Persisted<Schema["Type"], Schema["Type"]> : (session: SessionRef) => Persisted<Schema["Type"]> : never;
207
+ /** The context `Plugin.Setup<typeof definition>` receives: the host's members, and the definition's declared stores. */
208
+ export interface SetupContext<D> extends Context {
209
+ /**
210
+ * Each declared store, by its name in `stores`. A global store is a `Persisted` that has loaded before setup; a
211
+ * session store is a function of the session whose `value` is undefined until that session's store loads.
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * const shown = () => ctx.stores.prefs.value.shown
216
+ * const open = (session: SessionRef) => ctx.stores.view(session).value?.open ?? []
217
+ * ```
218
+ */
219
+ readonly stores: {
220
+ readonly [K in keyof DeclaredStores<D>]: Handle<DeclaredStores<D>[K]>;
221
+ };
222
+ }
223
+ export {};
File without changes