(dir: string, flags?: Parameters<typeof RuntimeFlags.layer>[0])
| 37 | } |
| 38 | |
| 39 | function load(dir: string, flags?: Parameters<typeof RuntimeFlags.layer>[0]) { |
| 40 | const source = path.join(dir, "opencode.json") |
| 41 | return Effect.gen(function* () { |
| 42 | const config = yield* Effect.promise( |
| 43 | () => Bun.file(source).json() as Promise<{ plugin?: Array<string | [string, Record<string, unknown>]> }>, |
| 44 | ) |
| 45 | const plugins = config.plugin ?? [] |
| 46 | return yield* Effect.gen(function* () { |
| 47 | const plugin = yield* Plugin.Service |
| 48 | yield* plugin.list() |
| 49 | }).pipe( |
| 50 | Effect.provide( |
| 51 | LayerNode.compile(Plugin.node, [ |
| 52 | [ |
| 53 | Config.node, |
| 54 | TestConfig.layer({ |
| 55 | get: () => |
| 56 | Effect.succeed({ |
| 57 | plugin: plugins, |
| 58 | plugin_origins: plugins.map((plugin) => ({ spec: plugin, source, scope: "local" as const })), |
| 59 | }), |
| 60 | directories: () => Effect.succeed([dir]), |
| 61 | }), |
| 62 | ], |
| 63 | [RuntimeFlags.node, RuntimeFlags.layer({ disableDefaultPlugins: true, ...flags })], |
| 64 | ]), |
| 65 | ), |
| 66 | provideInstance(dir), |
| 67 | ) |
| 68 | }) |
| 69 | } |
| 70 | |
| 71 | describe("plugin.loader.shared", () => { |
| 72 | it.live("loads a file:// plugin function export", () => |
no test coverage detected