Skip to content

Commit 5d73a57

Browse files
committed
feat(plugin): support live package updates
1 parent df05945 commit 5d73a57

76 files changed

Lines changed: 1511 additions & 820 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎bun.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/app/e2e/regression/project-extensions.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test("project Extensions stays inside settings while plugins load", async ({ pag
6464
location: project ? { directory: project } : {},
6565
data: (project ? ["shared-plugin", "project-plugin"] : ["shared-plugin"]).map((id) => ({
6666
id,
67-
source: { type: "package", package: id },
67+
source: { type: "package", target: id },
6868
state: { status: "active" },
6969
features: { server: true },
7070
})),

‎packages/app/e2e/regression/settings-loading.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ test("extensions opens without waiting for MCPs or plugins", async ({ page }) =>
8585
data: [
8686
{
8787
id: "demo-plugin",
88-
source: { type: "package", package: "demo-plugin" },
88+
source: { type: "package", target: "demo-plugin" },
8989
state: { status: "active" },
9090
features: { server: true },
9191
},

‎packages/app/src/providers/catalog/plugin.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("pluginLabels", () => {
88
{ id: "opencode.internal", source: { type: "builtin" }, state: { status: "active" }, features: { server: true } },
99
{
1010
id: "package-plugin",
11-
source: { type: "package", package: "example" },
11+
source: { type: "package", target: "example" },
1212
state: { status: "active" },
1313
features: { server: true },
1414
},

‎packages/app/src/providers/catalog/plugin.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { PluginInfo } from "@opencode-ai/client"
22

33
export function pluginLabel(plugin: PluginInfo) {
44
if (plugin.id) return plugin.id
5-
if (plugin.source.type === "package") return plugin.source.package
5+
if (plugin.source.type === "package") return plugin.source.target
66
if (plugin.source.type === "local") return plugin.source.path
77
return plugin.source.type
88
}

‎packages/cli/src/commands/handlers/plugin/list.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function format(
5454
plugin.state.status !== "active" || !plugin.features.tui
5555
? []
5656
: plugin.source.type === "package"
57-
? [{ target: plugin.source.package, source: "advertised" as const }]
57+
? [{ target: plugin.source.target, source: "advertised" as const }]
5858
: plugin.source.type === "local"
5959
? [{ target: path.dirname(plugin.source.path), source: "advertised" as const }]
6060
: [],
@@ -73,7 +73,7 @@ export function format(
7373

7474
function name(plugin: PluginInfo) {
7575
if (plugin.id) return plugin.id
76-
if (plugin.source.type === "package") return plugin.source.package
76+
if (plugin.source.type === "package") return plugin.source.target
7777
if (plugin.source.type === "local") return plugin.source.path
7878
return plugin.source.type
7979
}

‎packages/cli/test/plugin-list.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ test("formats server and TUI plugins in sections without builtins", () => {
99
{ id: "opencode.agent", source: { type: "builtin" }, state: { status: "active" }, features: { server: true } },
1010
{
1111
id: "acme.dual",
12-
source: { type: "package", package: "[email protected]" },
12+
source: { type: "package", target: "[email protected]" },
1313
state: { status: "active" },
1414
features: { server: true, tui: true },
1515
},
1616
{
17-
source: { type: "package", package: "broken-plugin" },
17+
source: { type: "package", target: "broken-plugin" },
1818
state: { status: "failed", error: "broken" },
1919
features: { server: true },
2020
},

‎packages/client/src/effect/api/api.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,16 @@ export type PluginListInput = {
8888
export type PluginListOutput = { readonly location: Location.Info; readonly data: ReadonlyArray<Plugin.Info> }
8989
export type PluginListOperation<E = never> = (input?: PluginListInput) => Effect.Effect<PluginListOutput, E>
9090

91+
export type PluginUpdateInput = {
92+
readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
93+
readonly target: string
94+
}
95+
export type PluginUpdateOutput = void
96+
export type PluginUpdateOperation<E = never> = (input: PluginUpdateInput) => Effect.Effect<PluginUpdateOutput, E>
97+
9198
export interface PluginApi<E = never> {
9299
readonly list: PluginListOperation<E>
100+
readonly update: PluginUpdateOperation<E>
93101
}
94102

95103
export type SessionListInput = {

‎packages/client/src/effect/generated/client.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import type {
1515
AgentGetOutput,
1616
PluginListInput,
1717
PluginListOutput,
18+
PluginUpdateInput,
19+
PluginUpdateOutput,
1820
SessionListInput,
1921
SessionListOutput,
2022
SessionStatsInput,
@@ -322,7 +324,17 @@ const EndpointPluginList = (raw: RawClient["server.plugin"]) => (input?: PluginL
322324
raw["plugin.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
323325
)
324326

325-
const adaptGroupPlugin = (raw: RawClient["server.plugin"]) => ({ list: EndpointPluginList(raw) })
327+
const EndpointPluginUpdate = (raw: RawClient["server.plugin"]) => (input: PluginUpdateInput) =>
328+
preserveEffect<PluginUpdateOutput>()(
329+
raw["plugin.update"]({ query: { location: input["location"] }, payload: { target: input["target"] } }).pipe(
330+
Effect.mapError(mapClientError),
331+
),
332+
)
333+
334+
const adaptGroupPlugin = (raw: RawClient["server.plugin"]) => ({
335+
list: EndpointPluginList(raw),
336+
update: EndpointPluginUpdate(raw),
337+
})
326338

327339
const EndpointSessionList = (raw: RawClient["server.session"]) => (input?: SessionListInput) =>
328340
preserveEffect<SessionListOutput>()(

‎packages/client/src/promise/generated/client.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import type {
99
AgentGetOutput,
1010
PluginListInput,
1111
PluginListOutput,
12+
PluginUpdateInput,
13+
PluginUpdateOutput,
1214
SessionListInput,
1315
SessionListOutput,
1416
SessionStatsInput,
@@ -466,6 +468,19 @@ export function make(options: ClientOptions) {
466468
},
467469
requestOptions,
468470
),
471+
update: (input: PluginUpdateInput, requestOptions?: RequestOptions) =>
472+
request<PluginUpdateOutput>(
473+
{
474+
method: "POST",
475+
path: `/api/plugin/update`,
476+
query: { location: input["location"] },
477+
body: { target: input["target"] },
478+
successStatus: 204,
479+
declaredStatuses: [400, 503, 401],
480+
empty: true,
481+
},
482+
requestOptions,
483+
),
469484
},
470485
session: {
471486
list: (input?: SessionListInput, requestOptions?: RequestOptions) =>

0 commit comments

Comments
 (0)