@firstpick/pi-package-webui 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/pi-webui.mjs CHANGED
@@ -4369,6 +4369,22 @@ function isNodeScriptCommand(command) {
4369
4369
  return [".cjs", ".js", ".mjs"].includes(path.extname(String(command || "")).toLowerCase());
4370
4370
  }
4371
4371
 
4372
+ async function resolvedPiCliScript() {
4373
+ const packagePathParts = PI_CODING_AGENT_PACKAGE.split("/").filter(Boolean);
4374
+ const searchRoots = require.resolve.paths(PI_CODING_AGENT_PACKAGE) || [];
4375
+ for (const nodeModulesRoot of searchRoots) {
4376
+ const cliPath = path.join(nodeModulesRoot, ...packagePathParts, "dist", "cli.js");
4377
+ try {
4378
+ await access(cliPath);
4379
+ return cliPath;
4380
+ } catch {
4381
+ // Continue through Node's resolution roots; global npm installs can hoist
4382
+ // pi-coding-agent beside pi-package-webui instead of nesting it.
4383
+ }
4384
+ }
4385
+ return "";
4386
+ }
4387
+
4372
4388
  async function resolvePiCommand(piArgs) {
4373
4389
  if (options.piBinExplicit) {
4374
4390
  if (isNodeScriptCommand(options.piBin)) {
@@ -4381,17 +4397,16 @@ async function resolvePiCommand(piArgs) {
4381
4397
  return { command: options.piBin, args: piArgs, displayCommand: `${options.piBin} ${piArgs.join(" ")}` };
4382
4398
  }
4383
4399
 
4384
- const bundledCli = path.join(packageRoot, "node_modules", "@earendil-works", "pi-coding-agent", "dist", "cli.js");
4385
- try {
4386
- await access(bundledCli);
4400
+ const bundledCli = await resolvedPiCliScript();
4401
+ if (bundledCli) {
4387
4402
  return {
4388
4403
  command: process.execPath,
4389
4404
  args: [bundledCli, ...piArgs],
4390
4405
  displayCommand: `${process.execPath} ${bundledCli} ${piArgs.join(" ")}`,
4391
4406
  };
4392
- } catch {
4393
- return { command: options.piBin, args: piArgs, displayCommand: `${options.piBin} ${piArgs.join(" ")}` };
4394
4407
  }
4408
+
4409
+ return { command: options.piBin, args: piArgs, displayCommand: `${options.piBin} ${piArgs.join(" ")}` };
4395
4410
  }
4396
4411
 
4397
4412
  const tabs = new Map();
@@ -5079,7 +5094,8 @@ async function getUpdateStatus({ force = false } = {}) {
5079
5094
 
5080
5095
  async function resolvePiUpdateCommand() {
5081
5096
  if (options.piBinExplicit) {
5082
- return { label: "Pi CLI and configured packages", command: options.piBin, args: ["update"], displayCommand: formatCommandForDisplay(options.piBin, ["update"]) };
5097
+ const command = await resolvePiCommand(["update"]);
5098
+ return { ...command, label: "Pi CLI and configured packages" };
5083
5099
  }
5084
5100
 
5085
5101
  const pathPi = await runCommand(options.piBin, ["--version"], { timeoutMs: 3000, maxOutputLength: 4000 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firstpick/pi-package-webui",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/Firstp1ck/npm-packages/tree/main/pi-package-webui#readme",
@@ -60,12 +60,12 @@
60
60
  "@firstpick/pi-extension-git-footer-status": "^0.3.3",
61
61
  "@firstpick/pi-extension-release-aur": "^0.1.6",
62
62
  "@firstpick/pi-extension-release-npm": "^0.4.0",
63
- "@firstpick/pi-extension-workflows": "^0.1.0",
64
63
  "@firstpick/pi-extension-safety-guard": "^0.2.3",
65
64
  "@firstpick/pi-extension-setup-skills": "^0.1.8",
66
65
  "@firstpick/pi-extension-stats": "^0.2.6",
67
66
  "@firstpick/pi-extension-todo-progress": "^0.2.4",
68
67
  "@firstpick/pi-extension-tools": "^0.1.6",
68
+ "@firstpick/pi-extension-workflows": "^0.1.0",
69
69
  "@firstpick/pi-package-remote-webui": "^0.1.0",
70
70
  "@firstpick/pi-prompts-git-pr": "^0.1.2",
71
71
  "@firstpick/pi-themes-bundle": "^0.1.4"
File without changes
@@ -450,6 +450,9 @@ assert.match(server, /--cwd does not exist:/, "server should report nonexistent
450
450
  assert.match(server, /options\.cwd = await validateStartupCwd\(options\.cwd\)/, "server should fail fast for invalid startup cwd paths");
451
451
  assert.match(server, /cwdExplicit: false/, "server should track whether startup cwd was explicitly requested");
452
452
  assert.match(server, /return options\.cwdExplicit \? \[await createTab\(\)\] : \[\]/, "server should wait for UI cwd selection when no --cwd is supplied");
453
+ assert.match(server, /async function resolvedPiCliScript\(\)[\s\S]*require\.resolve\.paths\(PI_CODING_AGENT_PACKAGE\)[\s\S]*nodeModulesRoot[\s\S]*dist[\s\S]*cli\.js/, "server should resolve the bundled Pi CLI through Node resolution roots so hoisted global installs can spawn RPC tabs");
454
+ assert.match(server, /const bundledCli = await resolvedPiCliScript\(\)/, "standalone server should prefer the resolved Pi CLI script before falling back to PATH pi");
455
+ assert.match(server, /if \(options\.piBinExplicit\) \{\n\s+const command = await resolvePiCommand\(\["update"\]\)/, "explicit --pi JavaScript launchers should also work for update commands");
453
456
  assert.match(app, /serverActionSelect\.addEventListener\("change", updateServerActionButton\)/, "Server action dropdown should control the guarded run button");
454
457
  assert.match(app, /runServerActionButton\.addEventListener\("click"[\s\S]*runSelectedServerAction/, "Server action run button should execute the selected action");
455
458
  assert.match(app, /api\("\/api\/restart", \{ method: "POST", scoped: false \}\)/, "Restart Server action should call the unscoped restart endpoint");