From 9b4e808a27aecb013dfbc4f7503e081026a09dd7 Mon Sep 17 00:00:00 2001 From: Dotta Date: Tue, 3 Mar 2026 11:01:45 -0600 Subject: [PATCH] cli: enable ui dev middleware for source server entrypoint --- cli/src/commands/run.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cli/src/commands/run.ts b/cli/src/commands/run.ts index d96b010c..4657ac89 100644 --- a/cli/src/commands/run.ts +++ b/cli/src/commands/run.ts @@ -84,6 +84,14 @@ function isModuleNotFoundError(err: unknown): boolean { return err.message.includes("Cannot find module"); } +function maybeEnableUiDevMiddleware(entrypoint: string): void { + if (process.env.PAPERCLIP_UI_DEV_MIDDLEWARE !== undefined) return; + const normalized = entrypoint.replaceAll("\\", "/"); + if (normalized.endsWith("/server/src/index.ts") || normalized.endsWith("@paperclipai/server/src/index.ts")) { + process.env.PAPERCLIP_UI_DEV_MIDDLEWARE = "true"; + } +} + async function importServerEntry(): Promise { const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../.."); const fileCandidates = [ @@ -94,6 +102,7 @@ async function importServerEntry(): Promise { if (existingFileCandidates.length > 0) { for (const filePath of existingFileCandidates) { try { + maybeEnableUiDevMiddleware(filePath); await import(pathToFileURL(filePath).href); return; } catch (err) { @@ -106,6 +115,7 @@ async function importServerEntry(): Promise { const missingErrors: string[] = []; for (const specifier of specifierCandidates) { try { + maybeEnableUiDevMiddleware(specifier); await import(specifier); return; } catch (err) {