Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/opencode/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export namespace Plugin {

type State = {
hooks: Hooks[]
config: Config.Info
}

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

Expand Down Expand Up @@ -237,7 +239,7 @@ export namespace Plugin {
Effect.forkScoped,
)

return { hooks }
return { hooks, config: cfg }
}),
)

Expand All @@ -261,11 +263,16 @@ export namespace Plugin {
return s.hooks
})

const cfg = Effect.fn("Plugin.config")(function* () {
const s = yield* InstanceState.get(state)
return s.config
})

const init = Effect.fn("Plugin.init")(function* () {
yield* InstanceState.get(state)
})

return Service.of({ trigger, list, init })
return Service.of({ trigger, list, config: cfg, init })
}),
)

Expand All @@ -287,4 +294,8 @@ export namespace Plugin {
export async function init() {
return runPromise((svc) => svc.init())
}

export async function config(): Promise<Config.Info> {
return runPromise((svc) => svc.config())
}
}
6 changes: 5 additions & 1 deletion packages/opencode/src/skill/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ export namespace Skill {
yield* scan(state, bus, dir, OPENCODE_SKILL_PATTERN)
}

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