refactor(core): select system prompts through plugins (#37181) · argszero/opencode@720f062 · GitHub
Skip to content

Commit 720f062

Browse files
authored
refactor(core): select system prompts through plugins (anomalyco#37181)
1 parent b5177ad commit 720f062

29 files changed

Lines changed: 447 additions & 263 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions

bun.lock

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

packages/core/src/plugin/host.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const make = Effect.fn("PluginHost.make")(function* (plugin: PluginV2.Int
6363
return {
6464
options: {},
6565
agent: {
66+
get: (id) => agents.get(AgentV2.ID.make(id)),
6667
list: (input) => {
6768
const ref = locationRef(input)
6869
if (ref && !isCurrentLocation(ref)) return runtime.location.agent.list(ref)
@@ -123,6 +124,8 @@ export const make = Effect.fn("PluginHost.make")(function* (plugin: PluginV2.Int
123124
),
124125
},
125126
model: {
127+
get: (providerID, modelID) =>
128+
catalog.model.get(ProviderV2.ID.make(providerID), ModelV2.ID.make(modelID)),
126129
list: () => response(catalog.model.available()),
127130
default: () => response(catalog.model.default()),
128131
},

packages/core/src/plugin/internal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { ModelsDevPlugin } from "./models-dev"
5050
import { ProviderPlugins } from "./provider"
5151
import { PluginRuntime } from "./runtime"
5252
import { SkillPlugin } from "./skill"
53+
import { SystemPromptPlugin } from "./system-prompt"
5354
import { VariantPlugin } from "./variant"
5455

5556
const services = Effect.fn("PluginInternal.services")(function* () {
@@ -121,6 +122,7 @@ const pre = [
121122
AgentPlugin.Plugin,
122123
CommandPlugin.Plugin,
123124
SkillPlugin.Plugin,
125+
...SystemPromptPlugin.Plugins,
124126
ModelsDevPlugin,
125127
...ProviderPlugins,
126128
PatchTool.Plugin,

packages/core/src/plugin/promise.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function fromPromise(plugin: Plugin) {
5959
const context2: Context = {
6060
options: host.options,
6161
agent: {
62+
get: (id) => run(host.agent.get(id)),
6263
list: (input) => run(host.agent.list(input)),
6364
transform: transform(host.agent),
6465
reload: () => run(host.agent.reload()),
@@ -74,6 +75,7 @@ export function fromPromise(plugin: Plugin) {
7475
run(host.catalog.provider.get({ ...input, providerID: Provider.ID.make(input.providerID) })),
7576
},
7677
model: {
78+
get: (providerID, modelID) => run(host.catalog.model.get(providerID, modelID)),
7779
list: (input) => run(host.catalog.model.list(input)),
7880
default: (input) =>
7981
run(host.catalog.model.default(input)).then((result) => ({ ...result, data: result.data ?? null })),
Lines changed: 47 additions & 0 deletions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)