From 559436c1fcc4c3e2ab62906c5b8cfebeaec12e1d Mon Sep 17 00:00:00 2001 From: Federico Jaramillo Martinez Date: Thu, 14 May 2026 22:52:57 +0200 Subject: [PATCH] fix: use service command shims for pi web install --- ...-service-path-for-pi-web-plugin-install.md | 5 +++++ extensions/pi-web.ts | 21 +------------------ 2 files changed, 6 insertions(+), 20 deletions(-) create mode 100644 .changeset/fix-service-path-for-pi-web-plugin-install.md diff --git a/.changeset/fix-service-path-for-pi-web-plugin-install.md b/.changeset/fix-service-path-for-pi-web-plugin-install.md new file mode 100644 index 0000000..b0c9803 --- /dev/null +++ b/.changeset/fix-service-path-for-pi-web-plugin-install.md @@ -0,0 +1,5 @@ +--- +"@jmfederico/pi-web": patch +--- + +Install Pi Web services from the Pi extension using the normal login-shell command shims instead of hardcoded Node paths, so sessions use the same PATH for node and npm. diff --git a/extensions/pi-web.ts b/extensions/pi-web.ts index b41b704..a860cb8 100644 --- a/extensions/pi-web.ts +++ b/extensions/pi-web.ts @@ -6,8 +6,6 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; const packageRoot = dirname(dirname(fileURLToPath(import.meta.url))); const cliPath = join(packageRoot, "dist", "cli.js"); -const serverPath = join(packageRoot, "dist", "server", "index.js"); -const sessiondPath = join(packageRoot, "dist", "server", "sessiond.js"); const serviceNames = ["pi-web-sessiond.service", "pi-web.service"]; const subcommands = [ @@ -25,14 +23,6 @@ const subcommands = [ type Subcommand = (typeof subcommands)[number]; -function shellSingleQuote(value: string): string { - return `'${value.replaceAll("'", "'\\''")}'`; -} - -function nodeCommand(scriptPath: string): string { - return `${shellSingleQuote(process.execPath)} ${shellSingleQuote(scriptPath)}`; -} - function parseArgs(args: string): string[] { return args.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g)?.map((part) => { if ((part.startsWith('"') && part.endsWith('"')) || (part.startsWith("'") && part.endsWith("'"))) { @@ -85,14 +75,6 @@ function isSubcommand(value: string): value is Subcommand { return subcommands.some((command) => command === value); } -function installEnv(): NodeJS.ProcessEnv { - if (!existsSync(serverPath) || !existsSync(sessiondPath)) return {}; - return { - PI_WEB_SERVER_EXEC: nodeCommand(serverPath), - PI_WEB_SESSIOND_EXEC: nodeCommand(sessiondPath), - }; -} - async function boundedLogs(): Promise<{ code: number; output: string }> { return run("journalctl", ["--user", "-u", serviceNames[0] ?? "", "-u", serviceNames[1] ?? "", "-n", "100", "--no-pager"]); } @@ -137,8 +119,7 @@ export default function piWebExtension(pi: ExtensionAPI): void { return; } - const env = subcommand === "install" ? installEnv() : {}; - showResult(ctx, `pi-web ${subcommand}`, await runPiWeb([subcommand, ...rest], env)); + showResult(ctx, `pi-web ${subcommand}`, await runPiWeb([subcommand, ...rest])); }, }); }