@firstpick/pi-package-webui 0.8.6 → 0.8.8

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.
Files changed (90) hide show
  1. package/README.md +18 -606
  2. package/bin/pi-webui-launcher.mjs +22 -0
  3. package/bin/pi-webui-update-supervisor.mjs +86 -0
  4. package/bin/pi-webui.mjs +562 -524
  5. package/index.ts +8 -5
  6. package/lib/component-update-state.mjs +21 -0
  7. package/lib/git-workflow-preferences.mjs +17 -2
  8. package/lib/optional-feature-catalog.mjs +1 -0
  9. package/lib/sampling-parameter-capabilities.mjs +160 -0
  10. package/lib/session-summary-preferences.mjs +16 -1
  11. package/lib/subagent-launch-slots.mjs +14 -2
  12. package/lib/trust-boundaries.mjs +3 -0
  13. package/lib/update/executor.mjs +99 -0
  14. package/lib/update/journal.mjs +175 -0
  15. package/lib/update/owners.mjs +70 -0
  16. package/lib/update/plan.mjs +134 -0
  17. package/lib/update/resolver.mjs +168 -0
  18. package/lib/update/supervisor.mjs +238 -0
  19. package/lib/update/verify.mjs +52 -0
  20. package/lib/update-commands.mjs +25 -13
  21. package/lib/webui-workspaces.mjs +17 -1
  22. package/package.json +4 -4
  23. package/public/app.js +1543 -109
  24. package/public/index.html +146 -48
  25. package/public/middle-button-drag-scroll.mjs +154 -0
  26. package/public/sampling-parameter-controls.mjs +361 -0
  27. package/public/service-worker.js +3 -1
  28. package/public/styles.css +512 -1
  29. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  30. package/tests/browser/control-deck-component-updates.spec.mjs +20 -22
  31. package/tests/browser/middle-button-drag-scroll.spec.mjs +145 -0
  32. package/tests/browser/persistent-ui-layout.spec.mjs +68 -23
  33. package/tests/browser/sampling-tooltip.spec.mjs +228 -0
  34. package/tests/browser/update-reconnect.spec.mjs +92 -0
  35. package/tests/codex-fast-mode-static.test.mjs +2 -2
  36. package/tests/common-options-submenus-interaction-static.test.mjs +172 -0
  37. package/tests/common-options-submenus-markup-static.test.mjs +152 -0
  38. package/tests/component-update-api-static.test.mjs +22 -61
  39. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  40. package/tests/control-deck-component-updates-static.test.mjs +13 -237
  41. package/tests/durable-rpc-supervisor-harness.test.mjs +3 -1
  42. package/tests/fast-mode-client-static.test.mjs +1 -1
  43. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  44. package/tests/feature-system-prompt-optional-feature-static.test.mjs +49 -0
  45. package/tests/fixtures/fake-pi.mjs +68 -1
  46. package/tests/fixtures/update/tree-timeout-descendant.mjs +6 -0
  47. package/tests/fixtures/update/tree-timeout-parent.mjs +11 -0
  48. package/tests/git-footer-context-menu-static.test.mjs +58 -0
  49. package/tests/http-endpoints-harness.test.mjs +68 -18
  50. package/tests/middle-button-drag-scroll-static.test.mjs +24 -0
  51. package/tests/middle-button-drag-scroll.test.mjs +170 -0
  52. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  53. package/tests/mobile-foundation-static.test.mjs +4 -4
  54. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  55. package/tests/mobile-static.test.mjs +217 -24
  56. package/tests/open-issue-wizard-static.test.mjs +1 -1
  57. package/tests/optional-feature-migration-frontend.test.mjs +13 -5
  58. package/tests/persistent-ui-layout-static.test.mjs +13 -2
  59. package/tests/prompt-routing-tab-status.test.mjs +8 -0
  60. package/tests/questionnaire-dialog.test.mjs +3 -3
  61. package/tests/remote-auth-settings-harness.test.mjs +34 -0
  62. package/tests/rpc-supervisor-host.test.mjs +11 -2
  63. package/tests/safety-guard-auto-review-harness.test.mjs +117 -0
  64. package/tests/safety-guard-auto-review-static.test.mjs +34 -0
  65. package/tests/sampling-native-controls-user-flow.test.mjs +752 -0
  66. package/tests/sampling-parameter-capabilities.test.mjs +167 -0
  67. package/tests/sampling-parameter-controls.test.mjs +241 -0
  68. package/tests/session-sampling-helper.test.mjs +228 -0
  69. package/tests/session-sampling-http.test.mjs +168 -0
  70. package/tests/session-sampling-ui-static.test.mjs +370 -0
  71. package/tests/session-summary-core.test.mjs +24 -11
  72. package/tests/side-panel-section-height-removal-static.test.mjs +34 -0
  73. package/tests/side-panel-section-reorder-static.test.mjs +3 -3
  74. package/tests/staged-content-hash-contract.test.mjs +52 -11
  75. package/tests/subagent-launch-slots.test.mjs +18 -1
  76. package/tests/theme-customizer-static.test.mjs +1 -1
  77. package/tests/ui-layout-settings.test.mjs +18 -1
  78. package/tests/update-api-harness.test.mjs +111 -0
  79. package/tests/update-commands.test.mjs +15 -45
  80. package/tests/update-executor-process-tree-harness.test.mjs +22 -0
  81. package/tests/update-journal-harness.test.mjs +59 -0
  82. package/tests/update-lock-multiprocess-harness.test.mjs +46 -0
  83. package/tests/update-owners.test.mjs +27 -0
  84. package/tests/update-plan.test.mjs +58 -0
  85. package/tests/update-resolver.test.mjs +56 -0
  86. package/tests/update-supervisor-harness.test.mjs +57 -0
  87. package/tests/update-tab-restore-harness.test.mjs +24 -0
  88. package/tests/update-verify.test.mjs +31 -0
  89. package/tests/workspace-files-live-updates-static.test.mjs +13 -4
  90. package/webui-rpc-helper.mjs +119 -0
@@ -1,20 +1,32 @@
1
- export function piUpdateHelpSupportsAll(output) {
2
- return /(?:^|[^A-Za-z0-9_-])--all(?:$|[^A-Za-z0-9_-])/.test(String(output || ""));
3
- }
1
+ const EXACT_VERSION = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
4
2
 
5
- export function piUpdateCommandSteps({ all = false, supportsAll = false } = {}) {
6
- if (!all) return [{ label: "Pi CLI", args: ["update", "--self"] }];
7
- if (supportsAll) return [{ label: "Pi CLI and configured packages", args: ["update", "--all"] }];
3
+ export function exactPackageSpec(packageName, version) {
4
+ const name = String(packageName || "").trim();
5
+ const exact = String(version || "").trim().replace(/^v/i, "");
6
+ if (!name || !EXACT_VERSION.test(exact)) throw new TypeError("packageName and an exact version are required");
7
+ return `${name}@${exact}`;
8
+ }
8
9
 
9
- // Explicit flags remain compatible with Pi releases that predate `--all`.
10
+ export function exactNpmInstallArgs({ installRoot, packageName, version, registry } = {}) {
11
+ const root = String(installRoot || "").trim();
12
+ const registryUrl = new URL(String(registry || ""));
13
+ if (!root) throw new TypeError("installRoot is required");
14
+ if (!/^https?:$/.test(registryUrl.protocol) || registryUrl.username || registryUrl.password || registryUrl.hash) {
15
+ throw new TypeError("registry must be a credential-free HTTP(S) URL");
16
+ }
10
17
  return [
11
- { label: "Pi CLI", args: ["update", "--self"] },
12
- { label: "configured Pi packages", args: ["update", "--extensions"] },
18
+ "install", "--prefix", root, "--ignore-scripts", "--no-save", "--package-lock=false",
19
+ "--registry", registryUrl.href, exactPackageSpec(packageName, version),
13
20
  ];
14
21
  }
15
22
 
16
- export function piUpdateCommandText(options = {}) {
17
- return piUpdateCommandSteps(options)
18
- .map((step) => `pi ${step.args.join(" ")}`)
19
- .join(" && ");
23
+ export function updatePlanConfirmationText(plan) {
24
+ if (!plan?.transactionId || !/^[a-f0-9]{64}$/.test(String(plan.digest || ""))) throw new TypeError("persisted update plan is required");
25
+ const targets = (plan.targets || []).map((target) => `${target.id} ${target.currentVersion} → ${target.targetVersion}`);
26
+ const refusals = (plan.refusals || []).map((item) => `${item.id}: ${item.guidance}`);
27
+ return [
28
+ targets.length ? `Exact targets: ${targets.join(" · ")}` : "No automatic targets were accepted.",
29
+ refusals.length ? `Refused: ${refusals.join(" · ")}` : "",
30
+ `Plan digest: ${plan.digest}`,
31
+ ].filter(Boolean).join("\n");
20
32
  }
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import path from "node:path";
5
+ import { setTimeout as delay } from "node:timers/promises";
5
6
 
6
7
  export const WEBUI_WORKSPACES_VERSION = 1;
7
8
  export const WEBUI_WORKSPACE_LIMIT = 20;
@@ -152,13 +153,28 @@ export async function listWebuiWorkspaces(storageFile = webuiWorkspacesFile(), o
152
153
  return document.workspaces.slice().reverse().map(workspaceMetadata).filter(Boolean);
153
154
  }
154
155
 
156
+ async function renameWithWindowsRetry(source, target) {
157
+ let lastError;
158
+ for (let attempt = 0; attempt < 12; attempt += 1) {
159
+ try {
160
+ await rename(source, target);
161
+ return;
162
+ } catch (error) {
163
+ lastError = error;
164
+ if (process.platform !== "win32" || !["EACCES", "EBUSY", "EPERM"].includes(error?.code)) throw error;
165
+ await delay(25 * (attempt + 1));
166
+ }
167
+ }
168
+ throw lastError;
169
+ }
170
+
155
171
  async function writeWorkspaceDocument(document, storageFile) {
156
172
  const normalized = normalizeWebuiWorkspaces(document);
157
173
  await mkdir(path.dirname(storageFile), { recursive: true });
158
174
  const temporaryFile = `${storageFile}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;
159
175
  try {
160
176
  await writeFile(temporaryFile, `${JSON.stringify(normalized, null, 2)}\n`, { mode: 0o600 });
161
- await rename(temporaryFile, storageFile);
177
+ await renameWithWindowsRetry(temporaryFile, storageFile);
162
178
  } catch (error) {
163
179
  await rm(temporaryFile, { force: true }).catch(() => {});
164
180
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firstpick/pi-package-webui",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
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/pi-coding-agent-forge/tree/main/pi-package-webui#readme",
@@ -27,16 +27,16 @@
27
27
  ]
28
28
  },
29
29
  "bin": {
30
- "pi-webui": "./bin/pi-webui.mjs"
30
+ "pi-webui": "./bin/pi-webui-launcher.mjs"
31
31
  },
32
32
  "scripts": {
33
- "check": "node --check public/app.js && node --check public/stream-output-controller.mjs && node --check public/theme-contract.mjs && node --check public/transcript-renderer.mjs && node --check public/mobile-shell-state.mjs && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/workspace-files-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
33
+ "check": "node --check public/app.js && node --check public/middle-button-drag-scroll.mjs && node --check public/stream-output-controller.mjs && node --check public/theme-contract.mjs && node --check public/transcript-renderer.mjs && node --check public/mobile-shell-state.mjs && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-launcher.mjs && node --check bin/pi-webui-update-supervisor.mjs && node --check lib/update/supervisor.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/workspace-files-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
34
34
  "test": "node tests/run-all.mjs",
35
35
  "test:browser": "playwright test"
36
36
  },
37
37
  "dependencies": {
38
38
  "@earendil-works/pi-ai": "^0.83.0",
39
- "@earendil-works/pi-coding-agent": "^0.83.0",
39
+ "@earendil-works/pi-coding-agent": "^0.84.0",
40
40
  "@earendil-works/pi-tui": "^0.83.0",
41
41
  "@firstpick/pi-utils": "^0.2.5",
42
42
  "mermaid": "^11.15.0",