From 95a90f52592a8a35167dead2d326f209647fca69 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 00:42:52 +0000 Subject: [PATCH] fix(cli): restore arguments on the desktop executable (#11363) The bundled CLI build stopped emitting the runCli module that Electron imports for direct CLI calls. Build that module alongside the standalone CLI and include it in the Nix desktop trace. Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> --- packages/cli/scripts/build.mjs | 4 +++- packages/cli/src/startup-boundary.test.ts | 19 ++++++++++++++++++- scripts/trace-daemon.mjs | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/cli/scripts/build.mjs b/packages/cli/scripts/build.mjs index f89693a645..dc10a188e3 100644 --- a/packages/cli/scripts/build.mjs +++ b/packages/cli/scripts/build.mjs @@ -1,4 +1,4 @@ -// Bundles @getpaseo/cli into a thin ESM entrypoint plus lazy code-split command chunks. +// Bundles @getpaseo/cli into thin ESM entrypoints plus lazy code-split command chunks. // Keeps @getpaseo/server/daemon-files bundled for zero-Zod thin RPC startup while leaving // @getpaseo/server and its heavy subpaths external so daemon spawning and heavy commands // resolve from the installed @getpaseo/server package. @@ -29,6 +29,8 @@ await rm(outDir, { recursive: true, force: true }); await build({ entryPoints: { index: path.join(packageRoot, "src/index.ts"), + // Electron imports runCli to supply its own argv and handle the exit code. + run: path.join(packageRoot, "src/run.ts"), }, outdir: outDir, bundle: true, diff --git a/packages/cli/src/startup-boundary.test.ts b/packages/cli/src/startup-boundary.test.ts index edb9a7f8c9..51da14d272 100644 --- a/packages/cli/src/startup-boundary.test.ts +++ b/packages/cli/src/startup-boundary.test.ts @@ -1,7 +1,7 @@ import { existsSync, readFileSync } from "node:fs"; import { spawnSync } from "node:child_process"; import path from "node:path"; -import { fileURLToPath } from "node:url"; +import { fileURLToPath, pathToFileURL } from "node:url"; import { build, type Metafile } from "esbuild"; import { describe, expect, it } from "vitest"; @@ -110,6 +110,23 @@ describe("CLI startup import boundary", () => { const distEntry = path.join(packageRoot, "dist/index.js"); + it.skipIf(!existsSync(distEntry))( + "bundled CLI exposes a programmatic entry for desktop passthrough", + () => { + const runnerUrl = pathToFileURL(path.join(packageRoot, "dist/run.js")).href; + const script = ` + import { runCli } from ${JSON.stringify(runnerUrl)}; + process.exitCode = await runCli(["--help"]); + `; + const run = spawnSync(process.execPath, ["--input-type=module", "-e", script], { + encoding: "utf8", + }); + + expect(run.status, run.stderr).toBe(0); + expect(run.stdout).toContain("Usage: paseo"); + }, + ); + it.skipIf(!existsSync(distEntry))( "bundled dist/index.js serves --version without loading heavy modules at runtime", () => { diff --git a/scripts/trace-daemon.mjs b/scripts/trace-daemon.mjs index 333aabf2ad..8f218cb7ad 100644 --- a/scripts/trace-daemon.mjs +++ b/scripts/trace-daemon.mjs @@ -164,6 +164,7 @@ async function main() { ...(traceDesktop ? [ ["packages/desktop/dist/daemon/runtime-paths.js", ["@getpaseo/server"]], + ["packages/desktop/dist/daemon/cli/entrypoints.js", ["@getpaseo/cli/dist/run.js"]], ["packages/desktop/dist/integrations/cli-install/paths.js", ["@getpaseo/cli/bin/paseo"]], ] : []),