Skip to content

Commit 1d7ad72

Browse files
committed
fix(skill): read plugin-modified config for skills.paths discovery
Plugin config() hooks that mutate cfg.skills.paths (e.g. superpowers) were invisible to skill discovery because each service's makeRuntime creates a separate InstanceState scope. Plugin.config() now exposes the post-hook config as the single source of truth.
1 parent 4961d72 commit 1d7ad72

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

packages/opencode/src/plugin/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export namespace Plugin {
2323

2424
type State = {
2525
hooks: Hooks[]
26+
config: Config.Info
2627
}
2728

2829
// Hook names that follow the (input, output) => Promise<void> trigger pattern
@@ -41,6 +42,7 @@ export namespace Plugin {
4142
output: Output,
4243
) => Effect.Effect<Output>
4344
readonly list: () => Effect.Effect<Hooks[]>
45+
readonly config: () => Effect.Effect<Config.Info>
4446
readonly init: () => Effect.Effect<void>
4547
}
4648

@@ -237,7 +239,7 @@ export namespace Plugin {
237239
Effect.forkScoped,
238240
)
239241

240-
return { hooks }
242+
return { hooks, config: cfg }
241243
}),
242244
)
243245

@@ -261,11 +263,16 @@ export namespace Plugin {
261263
return s.hooks
262264
})
263265

266+
const cfg = Effect.fn("Plugin.config")(function* () {
267+
const s = yield* InstanceState.get(state)
268+
return s.config
269+
})
270+
264271
const init = Effect.fn("Plugin.init")(function* () {
265272
yield* InstanceState.get(state)
266273
})
267274

268-
return Service.of({ trigger, list, init })
275+
return Service.of({ trigger, list, config: cfg, init })
269276
}),
270277
)
271278

@@ -287,4 +294,8 @@ export namespace Plugin {
287294
export async function init() {
288295
return runPromise((svc) => svc.init())
289296
}
297+
298+
export async function config(): Promise<Config.Info> {
299+
return runPromise((svc) => svc.config())
300+
}
290301
}

packages/opencode/src/skill/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ export namespace Skill {
164164
yield* scan(state, bus, dir, OPENCODE_SKILL_PATTERN)
165165
}
166166

167-
const cfg = yield* config.get()
167+
// Read config that includes plugin config() hook mutations.
168+
// Plugin.config() returns the config after all plugins' config() hooks
169+
// have run, so skills.paths includes plugin-registered directories.
170+
const { Plugin } = yield* Effect.promise(() => import("../plugin"))
171+
const cfg = yield* Effect.promise(() => Plugin.config())
168172
for (const item of cfg.skills?.paths ?? []) {
169173
const expanded = item.startsWith("~/") ? path.join(os.homedir(), item.slice(2)) : item
170174
const dir = path.isAbsolute(expanded) ? expanded : path.join(directory, expanded)

0 commit comments

Comments
 (0)