fix(core): name a missing local plugin path instead of failing with ENOENT

A configured plugin directory is scanned before it is loaded, so a path deleted or misspelled after config was read reached stat() and died with a raw ENOENT. The supervisor reports such a defect as a generic failure, losing the path. Treat a missing path like a directory without a server part, so the load fails with Plugin entrypoint not found and names the plugin.
This commit is contained in:
Kit Langton
2026-11-06 17:10:27 -08:00
Unverified
parent d2b3ae09b2
commit c443d041cf
2 changed files with 20 additions and 5 deletions
+9 -5
View File
@@ -112,11 +112,15 @@ const load = Effect.fn("PluginModule.load")(function* (
? yield* npm.resolve(operation.target)
: yield* npm.add(operation.target)
// Legacy auto-discovery still admits standalone server sources. Configured
// local plugins always arrive here as directories.
const entrypoints: Host.Entrypoints =
local && (yield* Effect.promise(() => stat(operation.target))).isFile()
? { server: pathToFileURL(operation.target).href }
: yield* Effect.sync(() => Host.resolve(installed ?? { directory: operation.target }))
// local plugins always arrive here as directories. A configured path can be gone
// by now (deleted or misspelled), which is a plugin failure like any other, so a
// missing path falls through to the entrypoint check that names the plugin.
const standalone =
local &&
(yield* Effect.promise(() => stat(operation.target).then((info) => info.isFile(), () => false)))
const entrypoints: Host.Entrypoints = standalone
? { server: pathToFileURL(operation.target).href }
: yield* Effect.sync(() => Host.resolve(installed ?? { directory: operation.target }))
const entrypoint = entrypoints.server
// A TUI-only package is not the server's to list; the TUI loads it from its own config.
const found = entrypoint || entrypoints.gui
+11
View File
@@ -426,6 +426,17 @@ it.live("blocks a local plugin before module initialization and honors replaceme
}),
)
it.live("names a configured local plugin path that no longer exists instead of dying on it", () =>
Effect.gen(function* () {
const directory = yield* tmpdirScoped()
const missing = path.join(directory.path, "missing-plugin")
const modules = yield* PluginModule.make()
// A deleted or misspelled configured path is the same failure as a directory without an entrypoint.
const error = yield* modules.load({ type: "add", target: missing, options: {} }).pipe(Effect.flip)
expect(error.message).toBe(`Plugin entrypoint not found: ${missing}`)
}),
)
it.live("loads a GUI-only package under its package name without running it, and leaves a TUI-only one to the TUI", () =>
Effect.gen(function* () {
const directory = yield* tmpdirScoped()