From c443d041cfb1c3213cd9dff4fe34f2c3c7035e67 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Fri, 6 Nov 2026 17:10:27 -0800 Subject: [PATCH] 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. --- packages/core/src/plugin/module.ts | 14 +++++++++----- packages/core/test/plugin/module.test.ts | 11 +++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/core/src/plugin/module.ts b/packages/core/src/plugin/module.ts index e450290f2cf..84ab55e2ac1 100644 --- a/packages/core/src/plugin/module.ts +++ b/packages/core/src/plugin/module.ts @@ -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 diff --git a/packages/core/test/plugin/module.test.ts b/packages/core/test/plugin/module.test.ts index ca2fde92ded..992743ae4ce 100644 --- a/packages/core/test/plugin/module.test.ts +++ b/packages/core/test/plugin/module.test.ts @@ -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()