@firstpick/pi-package-webui 0.9.7 → 0.9.9
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/DEVELOPMENT.md +882 -0
- package/README.md +8 -4
- package/TECHNICAL.md +415 -0
- package/bin/pi-webui.mjs +154 -26
- package/index.ts +2 -1
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/windows-drive-roots.mjs +114 -0
- package/package.json +3 -1
- package/public/app.js +683 -115
- package/public/guided-git-command-state.mjs +175 -1
- package/public/index.html +17 -10
- package/public/service-worker.js +1 -1
- package/public/styles.css +146 -32
- package/public/transcript-renderer.mjs +62 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/footer-model-advanced-layout.spec.mjs +512 -0
- package/tests/browser/guided-git-extension-command.spec.mjs +180 -0
- package/tests/browser/guided-git-fallback.spec.mjs +68 -3
- package/tests/browser/interaction-continuity.spec.mjs +33 -0
- package/tests/browser/windows-drive-parent.spec.mjs +198 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/compaction-static.test.mjs +1 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/events-tree-context-menu-static.test.mjs +3 -3
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +34 -3
- package/tests/git-footer-context-menu-static.test.mjs +103 -1
- package/tests/guided-git-activation-http.test.mjs +194 -0
- package/tests/guided-git-activation-static.test.mjs +80 -0
- package/tests/guided-git-activation.test.mjs +244 -0
- package/tests/guided-git-fallback-runtime.test.mjs +1 -0
- package/tests/guided-git-fallback-ui-static.test.mjs +2 -2
- package/tests/guided-git-message-reliability-static.test.mjs +2 -1
- package/tests/guided-git-optional-feature.test.mjs +31 -0
- package/tests/http-endpoints-harness.test.mjs +3 -0
- package/tests/interaction-state-stability-static.test.mjs +1 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- package/tests/main-output-loading-static.test.mjs +11 -9
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +85 -4
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/prompt-input-vertical-scroll-static.test.mjs +6 -6
- package/tests/prompt-routing-input-clear-static.test.mjs +1 -1
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +2 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-block-grouping.test.mjs +79 -0
- package/tests/windows-drive-cwd-picker-static.test.mjs +81 -0
- package/tests/windows-drive-roots.test.mjs +130 -0
package/bin/pi-webui.mjs
CHANGED
|
@@ -59,6 +59,12 @@ import {
|
|
|
59
59
|
findWindowsReservedGitPath,
|
|
60
60
|
windowsReservedGitPathFailure,
|
|
61
61
|
} from "../lib/git-command-errors.mjs";
|
|
62
|
+
import {
|
|
63
|
+
WINDOWS_DRIVES_PICKER_PATH,
|
|
64
|
+
createWindowsDriveRootDiscovery,
|
|
65
|
+
isWindowsDriveRoot,
|
|
66
|
+
windowsDrivesPickerData,
|
|
67
|
+
} from "../lib/windows-drive-roots.mjs";
|
|
62
68
|
import { ComponentUpdateState, sanitizeComponentUpdateError, validateComponentUpdateRequest, validateUpdateApplyRequest, validateUpdatePlanRequest } from "../lib/component-update-state.mjs";
|
|
63
69
|
import { resolveCanonicalPiRuntime, resolveWebuiRuntimeIdentity } from "../lib/update/resolver.mjs";
|
|
64
70
|
import { bundledPackageOwnership, packageOwnerRoot } from "../lib/update/package-layout.mjs";
|
|
@@ -450,6 +456,12 @@ let optionalFeatureStartupReady = false;
|
|
|
450
456
|
const UPDATE_PACKAGE_NAMES = [...CORE_UPDATE_PACKAGE_NAMES].sort();
|
|
451
457
|
const NATURAL_CONVERSATION_STATUS_KEY = "natural-conversation";
|
|
452
458
|
const NATURAL_CONVERSATION_COMMAND_NAMES = ["talk", "voice", "conversation"];
|
|
459
|
+
const GUIDED_GIT_START_STATUS_KEY = "git-guided-workflow:webui-start";
|
|
460
|
+
const GUIDED_GIT_START_PAYLOAD_TYPE = "firstpick.pi-extension-git-guided-workflow.start";
|
|
461
|
+
const GUIDED_GIT_START_PAYLOAD_VERSION = 1;
|
|
462
|
+
const GUIDED_GIT_LAUNCH_TTL_MS = 15_000;
|
|
463
|
+
const GUIDED_GIT_UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
464
|
+
const GUIDED_GIT_COMMAND_MESSAGE = /^\/git-guided-workflow(?::\d+)?$/u;
|
|
453
465
|
// Codex subscription Fast mode is owned by the optional @firstpick/pi-extension-codex-fast-mode
|
|
454
466
|
// package. The Web UI never inspects ChatGPT credentials or request payloads; it only mirrors the
|
|
455
467
|
// extension-published status key and drives the package-owned /fast-mode command over RPC.
|
|
@@ -5635,7 +5647,37 @@ function pathPickerRoots(activeCwd, viewedCwd) {
|
|
|
5635
5647
|
]);
|
|
5636
5648
|
}
|
|
5637
5649
|
|
|
5650
|
+
const discoverWindowsDriveRoots = createWindowsDriveRootDiscovery({ runCommand });
|
|
5651
|
+
|
|
5652
|
+
function knownWindowsDrivePaths(activeCwd) {
|
|
5653
|
+
return [
|
|
5654
|
+
activeCwd,
|
|
5655
|
+
options.cwd,
|
|
5656
|
+
process.env.USERPROFILE,
|
|
5657
|
+
process.env.HOME,
|
|
5658
|
+
process.env.HOMEDRIVE,
|
|
5659
|
+
process.env.SystemDrive,
|
|
5660
|
+
process.env.SystemRoot,
|
|
5661
|
+
];
|
|
5662
|
+
}
|
|
5663
|
+
|
|
5664
|
+
function windowsDriveDiscoveryCwd() {
|
|
5665
|
+
return process.env.SystemRoot || process.env.WINDIR || path.dirname(process.execPath);
|
|
5666
|
+
}
|
|
5667
|
+
|
|
5668
|
+
async function getWindowsDrivesPickerData(activeCwd) {
|
|
5669
|
+
const driveRoots = await discoverWindowsDriveRoots({
|
|
5670
|
+
cwd: windowsDriveDiscoveryCwd(),
|
|
5671
|
+
knownPaths: knownWindowsDrivePaths(activeCwd),
|
|
5672
|
+
});
|
|
5673
|
+
return windowsDrivesPickerData(driveRoots, pathPickerRoots(activeCwd, activeCwd));
|
|
5674
|
+
}
|
|
5675
|
+
|
|
5638
5676
|
async function getDirectoryPickerData(viewPath, activeCwd) {
|
|
5677
|
+
if (platform() === "win32" && viewPath === WINDOWS_DRIVES_PICKER_PATH) {
|
|
5678
|
+
return getWindowsDrivesPickerData(activeCwd);
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5639
5681
|
const cwd = await resolveCwd(viewPath || activeCwd, activeCwd);
|
|
5640
5682
|
let entries;
|
|
5641
5683
|
try {
|
|
@@ -5652,11 +5694,14 @@ async function getDirectoryPickerData(viewPath, activeCwd) {
|
|
|
5652
5694
|
return { name: entry.name, cwd: entryPath, displayCwd: displayPath(entryPath), hidden: entry.name.startsWith(".") };
|
|
5653
5695
|
});
|
|
5654
5696
|
const parent = path.dirname(cwd);
|
|
5697
|
+
const parentPath = platform() === "win32" && isWindowsDriveRoot(cwd)
|
|
5698
|
+
? WINDOWS_DRIVES_PICKER_PATH
|
|
5699
|
+
: parent === cwd ? null : parent;
|
|
5655
5700
|
|
|
5656
5701
|
return {
|
|
5657
5702
|
cwd,
|
|
5658
5703
|
displayCwd: displayPath(cwd),
|
|
5659
|
-
parent:
|
|
5704
|
+
parent: parentPath,
|
|
5660
5705
|
roots: pathPickerRoots(activeCwd, cwd),
|
|
5661
5706
|
directories,
|
|
5662
5707
|
truncated: directoryEntries.length > directories.length,
|
|
@@ -7717,7 +7762,7 @@ async function readGitWorkflowMessages(cwd, { generationId = "", generation = nu
|
|
|
7717
7762
|
return gitWorkflowMessagePendingPayload(root, messageCwd, paths, generationId, "This commit-message generation is no longer active. Regenerate the message files.", { expired: true });
|
|
7718
7763
|
}
|
|
7719
7764
|
if (generationId && !generation.terminal) {
|
|
7720
|
-
return gitWorkflowMessagePendingPayload(root, messageCwd, paths, generationId, "The correlated commit-message generation is still running.");
|
|
7765
|
+
return gitWorkflowMessagePendingPayload(root, messageCwd, paths, generationId, "The correlated commit-message generation is still running.", { running: true });
|
|
7721
7766
|
}
|
|
7722
7767
|
if (generationId && !generation.successful) {
|
|
7723
7768
|
return gitWorkflowMessagePendingPayload(root, messageCwd, paths, generationId, "The correlated commit-message generation did not finish successfully. Regenerate the message files.", { expired: true });
|
|
@@ -10174,6 +10219,65 @@ function extensionStatusMap(tab) {
|
|
|
10174
10219
|
return tab.extensionStatuses;
|
|
10175
10220
|
}
|
|
10176
10221
|
|
|
10222
|
+
function isGuidedGitWorkflowCommandMessage(message) {
|
|
10223
|
+
return GUIDED_GIT_COMMAND_MESSAGE.test(String(message || "").trim());
|
|
10224
|
+
}
|
|
10225
|
+
|
|
10226
|
+
function prunePendingGuidedGitLaunch(tab, nowMs = Date.now()) {
|
|
10227
|
+
const pending = tab?.guidedGitPendingLaunch;
|
|
10228
|
+
if (pending && nowMs - pending.acceptedAt > GUIDED_GIT_LAUNCH_TTL_MS) tab.guidedGitPendingLaunch = null;
|
|
10229
|
+
return tab?.guidedGitPendingLaunch || null;
|
|
10230
|
+
}
|
|
10231
|
+
|
|
10232
|
+
function clearPendingGuidedGitLaunch(tab, launchId) {
|
|
10233
|
+
if (!tab?.guidedGitPendingLaunch) return;
|
|
10234
|
+
if (!launchId || tab.guidedGitPendingLaunch.launchId === launchId) tab.guidedGitPendingLaunch = null;
|
|
10235
|
+
}
|
|
10236
|
+
|
|
10237
|
+
function validGuidedGitStartStatusText(statusText) {
|
|
10238
|
+
if (typeof statusText !== "string" || !statusText || Buffer.byteLength(statusText, "utf8") > 1024) return false;
|
|
10239
|
+
try {
|
|
10240
|
+
const payload = JSON.parse(statusText);
|
|
10241
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return false;
|
|
10242
|
+
const keys = Object.keys(payload).sort();
|
|
10243
|
+
if (keys.length !== 4 || keys.join(",") !== "action,requestId,type,version") return false;
|
|
10244
|
+
return payload.type === GUIDED_GIT_START_PAYLOAD_TYPE
|
|
10245
|
+
&& payload.version === GUIDED_GIT_START_PAYLOAD_VERSION
|
|
10246
|
+
&& payload.action === "start"
|
|
10247
|
+
&& GUIDED_GIT_UUID_V4.test(String(payload.requestId || ""));
|
|
10248
|
+
} catch {
|
|
10249
|
+
return false;
|
|
10250
|
+
}
|
|
10251
|
+
}
|
|
10252
|
+
|
|
10253
|
+
function scopedGuidedGitLaunchEvent(tab, event, nowMs = Date.now()) {
|
|
10254
|
+
if (event?.type !== "extension_ui_request" || event.method !== "setStatus" || event.statusKey !== GUIDED_GIT_START_STATUS_KEY) return event;
|
|
10255
|
+
if (!event.statusText) {
|
|
10256
|
+
clearPendingGuidedGitLaunch(tab);
|
|
10257
|
+
return event;
|
|
10258
|
+
}
|
|
10259
|
+
if (!validGuidedGitStartStatusText(event.statusText)) return event;
|
|
10260
|
+
const pending = prunePendingGuidedGitLaunch(tab, nowMs);
|
|
10261
|
+
if (!pending) return event;
|
|
10262
|
+
tab.guidedGitPendingLaunch = null;
|
|
10263
|
+
return { ...event, guidedGitLaunchId: pending.launchId };
|
|
10264
|
+
}
|
|
10265
|
+
|
|
10266
|
+
async function authoritativeGuidedGitLaunchAdmission(tab, { launchId = "", reserve = false } = {}) {
|
|
10267
|
+
const pending = prunePendingGuidedGitLaunch(tab);
|
|
10268
|
+
if (pending) throw makeHttpError(409, "A Guided Git activation is already pending for this tab.");
|
|
10269
|
+
if (reserve && !GUIDED_GIT_UUID_V4.test(String(launchId || ""))) throw makeHttpError(400, "guidedGitLaunchId must be a UUID v4");
|
|
10270
|
+
const state = await currentSessionState(tab);
|
|
10271
|
+
if (state.isStreaming) throw makeHttpError(409, "Wait for the current agent run to finish before starting Guided Git.");
|
|
10272
|
+
if (state.isCompacting) throw makeHttpError(409, "Wait for compaction to finish before starting Guided Git.");
|
|
10273
|
+
if (Number(state.pendingMessageCount || 0) > 0 || compactionQueueForTab(tab).length > 0) {
|
|
10274
|
+
throw makeHttpError(409, "Wait for pending messages to finish before starting Guided Git.");
|
|
10275
|
+
}
|
|
10276
|
+
if (prunePendingGuidedGitLaunch(tab)) throw makeHttpError(409, "A Guided Git activation is already pending for this tab.");
|
|
10277
|
+
if (reserve) tab.guidedGitPendingLaunch = { launchId, acceptedAt: Date.now() };
|
|
10278
|
+
return { admitted: true };
|
|
10279
|
+
}
|
|
10280
|
+
|
|
10177
10281
|
function extensionWidgetMap(tab) {
|
|
10178
10282
|
if (!tab.extensionWidgets) tab.extensionWidgets = new Map();
|
|
10179
10283
|
return tab.extensionWidgets;
|
|
@@ -11281,7 +11385,7 @@ function attachRpcToTab(tab, rpc) {
|
|
|
11281
11385
|
if (resolveWebuiHelperResponse(tab, event) || resolveWebuiHelperRpcResponse(tab, event) || rememberWebuiSubagentsStatusEvent(tab, event) || consumeSessionSummaryRpcEvent(tab, event)) return;
|
|
11282
11386
|
const gitWorkflowFinalError = event?.type === "agent_settled" && tab.pendingTurnFailure === true;
|
|
11283
11387
|
updateTabActivityFromEvent(tab, event);
|
|
11284
|
-
let scopedEvent = eventForTabClients(tab, event);
|
|
11388
|
+
let scopedEvent = scopedGuidedGitLaunchEvent(tab, eventForTabClients(tab, event));
|
|
11285
11389
|
if (event?.type === "pi_process_exit" || event?.type === "pi_process_error") {
|
|
11286
11390
|
if (tab.gitWorkflowGeneration) tab.gitWorkflowGeneration.processLost = true;
|
|
11287
11391
|
if (tab.gitWorkflowArtifactGeneration) {
|
|
@@ -11294,6 +11398,7 @@ function attachRpcToTab(tab, rpc) {
|
|
|
11294
11398
|
clearPendingExtensionUiRequests(tab);
|
|
11295
11399
|
clearExtensionStatuses(tab);
|
|
11296
11400
|
clearExtensionWidgets(tab);
|
|
11401
|
+
clearPendingGuidedGitLaunch(tab);
|
|
11297
11402
|
clearWebuiSubagents(tab);
|
|
11298
11403
|
resetNaturalConversationMode(tab);
|
|
11299
11404
|
resetCodexFastMode(tab);
|
|
@@ -11351,6 +11456,7 @@ function createTabRecord({ id, index, title, titleSource, conversationStarted, c
|
|
|
11351
11456
|
rpcUnsubscribe: undefined,
|
|
11352
11457
|
sseClients: new Set(),
|
|
11353
11458
|
browserPromptRequests: new Map(),
|
|
11459
|
+
guidedGitPendingLaunch: null,
|
|
11354
11460
|
};
|
|
11355
11461
|
resetNaturalConversationMode(tab);
|
|
11356
11462
|
resetCodexFastMode(tab);
|
|
@@ -16017,30 +16123,45 @@ async function handlePromptRequest(tab, body, req) {
|
|
|
16017
16123
|
if (isNaturalConversationActive(tab) && naturalConversationSlashCommandName(body.message) && !isNaturalConversationSlashCommand(body.message)) {
|
|
16018
16124
|
blockNaturalConversationAction("slash commands are blocked from the Web UI shell");
|
|
16019
16125
|
}
|
|
16020
|
-
const
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
|
|
16031
|
-
|
|
16032
|
-
|
|
16033
|
-
|
|
16034
|
-
|
|
16035
|
-
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
|
|
16126
|
+
const guidedGitLaunch = isGuidedGitWorkflowCommandMessage(body.message);
|
|
16127
|
+
const guidedGitLaunchId = guidedGitLaunch ? String(body.guidedGitLaunchId || "") : "";
|
|
16128
|
+
if (guidedGitLaunch) await authoritativeGuidedGitLaunchAdmission(tab, { launchId: guidedGitLaunchId, reserve: true });
|
|
16129
|
+
const releaseGuidedGitLaunch = () => clearPendingGuidedGitLaunch(tab, guidedGitLaunchId);
|
|
16130
|
+
try {
|
|
16131
|
+
const nativeResponse = await handleNativeSlashCommand(tab, body, req);
|
|
16132
|
+
if (nativeResponse) {
|
|
16133
|
+
if (nativeResponse.success === false) releaseGuidedGitLaunch();
|
|
16134
|
+
return { status: nativeResponse.success === false ? 400 : 200, payload: responseWithTab(nativeResponse, tab) };
|
|
16135
|
+
}
|
|
16136
|
+
const command = commandFromPost("/api/prompt", body);
|
|
16137
|
+
enforceNaturalConversationCommandAllowed(tab, command);
|
|
16138
|
+
const queuedForCompaction = guidedGitLaunch ? null : maybeQueueCommandDuringCompaction(tab, command);
|
|
16139
|
+
if (queuedForCompaction) return { status: 202, payload: responseWithTab(queuedForCompaction, tab) };
|
|
16140
|
+
const naturalConversationSafetyResponse = await ensureNaturalConversationPromptSafety(tab, command);
|
|
16141
|
+
if (naturalConversationSafetyResponse?.success === false) {
|
|
16142
|
+
releaseGuidedGitLaunch();
|
|
16143
|
+
return { status: 400, payload: responseWithTab(naturalConversationSafetyResponse, tab) };
|
|
16144
|
+
}
|
|
16145
|
+
const pendingThinkingResponse = await applyPendingThinkingBeforePrompt(tab);
|
|
16146
|
+
if (pendingThinkingResponse?.success === false) {
|
|
16147
|
+
releaseGuidedGitLaunch();
|
|
16148
|
+
return { status: 400, payload: responseWithTab(pendingThinkingResponse, tab) };
|
|
16149
|
+
}
|
|
16150
|
+
const startsVisibleWork = commandStartsVisibleWork(command);
|
|
16151
|
+
if (startsVisibleWork) {
|
|
16152
|
+
maybeNameTabForConversation(tab, command);
|
|
16153
|
+
markTabWorking(tab);
|
|
16154
|
+
}
|
|
16155
|
+
const response = await tab.rpc.send(command, PROMPT_REQUEST_TIMEOUT_MS);
|
|
16156
|
+
if (response.success === false) {
|
|
16157
|
+
releaseGuidedGitLaunch();
|
|
16158
|
+
if (startsVisibleWork) markTabIdle(tab);
|
|
16159
|
+
}
|
|
16160
|
+
return { status: response.success === false ? 400 : 200, payload: responseWithTab(response, tab) };
|
|
16161
|
+
} catch (error) {
|
|
16162
|
+
releaseGuidedGitLaunch();
|
|
16163
|
+
throw error;
|
|
16040
16164
|
}
|
|
16041
|
-
const response = await tab.rpc.send(command, PROMPT_REQUEST_TIMEOUT_MS);
|
|
16042
|
-
if (response.success === false && startsVisibleWork) markTabIdle(tab);
|
|
16043
|
-
return { status: response.success === false ? 400 : 200, payload: responseWithTab(response, tab) };
|
|
16044
16165
|
}
|
|
16045
16166
|
|
|
16046
16167
|
const server = createServer(async (req, res) => {
|
|
@@ -17198,6 +17319,13 @@ const server = createServer(async (req, res) => {
|
|
|
17198
17319
|
return;
|
|
17199
17320
|
}
|
|
17200
17321
|
|
|
17322
|
+
if (url.pathname === "/api/git-workflow/launch-admission" && req.method === "POST") {
|
|
17323
|
+
const body = await readJsonBody(req);
|
|
17324
|
+
const tab = getRequestedTab(req, url, body);
|
|
17325
|
+
sendJson(res, 200, { ok: true, data: await authoritativeGuidedGitLaunchAdmission(tab) });
|
|
17326
|
+
return;
|
|
17327
|
+
}
|
|
17328
|
+
|
|
17201
17329
|
if (url.pathname === "/api/git-workflow/preferences" && req.method === "POST") {
|
|
17202
17330
|
const body = await readJsonBody(req);
|
|
17203
17331
|
const tab = getRequestedTab(req, url, body);
|
package/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
30
30
|
const packageRoot = __dirname;
|
|
31
31
|
const webuiBin = path.join(packageRoot, "bin", "pi-webui-launcher.mjs");
|
|
32
32
|
const agentDir = process.env.PI_CODING_AGENT_DIR || path.join(homedir(), ".pi", "agent");
|
|
33
|
+
const nodeExecutable = ["node", "node.exe"].includes(path.basename(process.execPath).toLowerCase()) ? process.execPath : "node";
|
|
33
34
|
|
|
34
35
|
const DEFAULT_HOST = "127.0.0.1";
|
|
35
36
|
const DEFAULT_PORT = 31415;
|
|
@@ -478,7 +479,7 @@ async function startWebui(options: StartWebuiOptions, ctx: ExtensionCommandConte
|
|
|
478
479
|
const env = { ...process.env };
|
|
479
480
|
if (restoreTabs.length > 0) env.PI_WEBUI_RESTORE_FILE = (await createRestoreFile(agentDir, restoreTabs)).file;
|
|
480
481
|
|
|
481
|
-
const child = spawn(
|
|
482
|
+
const child = spawn(nodeExecutable, args, {
|
|
482
483
|
cwd: ctx.cwd,
|
|
483
484
|
env,
|
|
484
485
|
detached: true,
|
|
@@ -2,7 +2,7 @@ const entries = [
|
|
|
2
2
|
["bangCommandAutocomplete", "@firstpick/pi-extension-bang-command-autocomplete", "^0.2.2"],
|
|
3
3
|
["fishUserBash", "@firstpick/pi-extension-fish-user-bash", "^0.2.2"],
|
|
4
4
|
["btwCommand", "@firstpick/pi-extension-btw", "^0.1.4"],
|
|
5
|
-
["gitWorkflow", "@firstpick/pi-
|
|
5
|
+
["gitWorkflow", "@firstpick/pi-extension-git-guided-workflow", "^0.1.0"],
|
|
6
6
|
["releaseNpm", "@firstpick/pi-extension-release-npm", "^0.4.4"],
|
|
7
7
|
["releaseAur", "@firstpick/pi-extension-release-aur", "^0.1.8"],
|
|
8
8
|
["aurReview", "@firstpick/pi-extension-aur-review", "^0.1.1"],
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { win32 } from "node:path";
|
|
2
|
+
|
|
3
|
+
export const WINDOWS_DRIVES_PICKER_PATH = "::pi-webui-windows-drives::";
|
|
4
|
+
export const WINDOWS_DRIVE_DISCOVERY_TIMEOUT_MS = 3_000;
|
|
5
|
+
export const WINDOWS_DRIVE_DISCOVERY_MAX_OUTPUT = 4_096;
|
|
6
|
+
export const WINDOWS_DRIVE_DISCOVERY_CACHE_TTL_MS = 10_000;
|
|
7
|
+
|
|
8
|
+
const WINDOWS_DRIVE_ROOT_PATTERN = /^[A-Za-z]:[\\/]$/;
|
|
9
|
+
const WINDOWS_DRIVE_DESIGNATOR_PATTERN = /^[A-Za-z]:$/;
|
|
10
|
+
const WINDOWS_DRIVE_DISCOVERY_SCRIPT = [
|
|
11
|
+
"[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false);",
|
|
12
|
+
"[System.IO.DriveInfo]::GetDrives()",
|
|
13
|
+
"| Where-Object { try { $_.IsReady } catch { $false } }",
|
|
14
|
+
"| ForEach-Object { $_.RootDirectory.FullName }",
|
|
15
|
+
].join(" ");
|
|
16
|
+
|
|
17
|
+
export function normalizeWindowsDriveRoot(value) {
|
|
18
|
+
const root = String(value ?? "");
|
|
19
|
+
if (!WINDOWS_DRIVE_ROOT_PATTERN.test(root)) return null;
|
|
20
|
+
return `${root[0].toUpperCase()}:\\`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isWindowsDriveRoot(value) {
|
|
24
|
+
return normalizeWindowsDriveRoot(value) !== null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function parseWindowsDriveRoots(output) {
|
|
28
|
+
return mergeWindowsDriveRoots(String(output ?? "").split(/\r?\n/));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function windowsDriveRootsFromKnownPaths(values) {
|
|
32
|
+
const roots = [];
|
|
33
|
+
for (const value of values || []) {
|
|
34
|
+
const candidate = String(value ?? "");
|
|
35
|
+
if (!candidate) continue;
|
|
36
|
+
if (WINDOWS_DRIVE_DESIGNATOR_PATTERN.test(candidate)) {
|
|
37
|
+
roots.push(`${candidate}\\`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
roots.push(win32.parse(candidate).root);
|
|
41
|
+
}
|
|
42
|
+
return mergeWindowsDriveRoots(roots);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function mergeWindowsDriveRoots(...groups) {
|
|
46
|
+
const roots = new Map();
|
|
47
|
+
for (const group of groups) {
|
|
48
|
+
for (const value of group || []) {
|
|
49
|
+
const root = normalizeWindowsDriveRoot(value);
|
|
50
|
+
if (root) roots.set(root.toLowerCase(), root);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return [...roots.values()].sort((left, right) => left.localeCompare(right, "en", { sensitivity: "base" }));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function windowsDrivesPickerData(driveRoots, roots = []) {
|
|
57
|
+
return {
|
|
58
|
+
cwd: "",
|
|
59
|
+
displayCwd: "This PC",
|
|
60
|
+
parent: null,
|
|
61
|
+
roots,
|
|
62
|
+
directories: mergeWindowsDriveRoots(driveRoots).map((root) => ({
|
|
63
|
+
name: root,
|
|
64
|
+
cwd: root,
|
|
65
|
+
displayCwd: root,
|
|
66
|
+
hidden: false,
|
|
67
|
+
})),
|
|
68
|
+
truncated: false,
|
|
69
|
+
selectable: false,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function createWindowsDriveRootDiscovery({
|
|
74
|
+
runCommand,
|
|
75
|
+
now = Date.now,
|
|
76
|
+
cacheTtlMs = WINDOWS_DRIVE_DISCOVERY_CACHE_TTL_MS,
|
|
77
|
+
} = {}) {
|
|
78
|
+
if (typeof runCommand !== "function") throw new TypeError("runCommand is required");
|
|
79
|
+
|
|
80
|
+
let cached = { expiresAt: 0, roots: [] };
|
|
81
|
+
let pending = null;
|
|
82
|
+
|
|
83
|
+
async function discover(cwd) {
|
|
84
|
+
let roots = [];
|
|
85
|
+
try {
|
|
86
|
+
const result = await runCommand("powershell.exe", [
|
|
87
|
+
"-NoLogo",
|
|
88
|
+
"-NoProfile",
|
|
89
|
+
"-NonInteractive",
|
|
90
|
+
"-Command",
|
|
91
|
+
WINDOWS_DRIVE_DISCOVERY_SCRIPT,
|
|
92
|
+
], {
|
|
93
|
+
cwd,
|
|
94
|
+
timeoutMs: WINDOWS_DRIVE_DISCOVERY_TIMEOUT_MS,
|
|
95
|
+
maxOutputLength: WINDOWS_DRIVE_DISCOVERY_MAX_OUTPUT,
|
|
96
|
+
utf8Output: true,
|
|
97
|
+
});
|
|
98
|
+
if (result?.exitCode === 0 && !result.timedOut && !result.stdoutTruncated && !result.error) {
|
|
99
|
+
roots = parseWindowsDriveRoots(result.stdout);
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
// Known roots keep the picker usable when PowerShell is unavailable.
|
|
103
|
+
}
|
|
104
|
+
cached = { expiresAt: now() + Math.max(0, cacheTtlMs), roots };
|
|
105
|
+
return roots;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return async function getWindowsDriveRoots({ cwd, knownPaths = [] } = {}) {
|
|
109
|
+
const knownRoots = windowsDriveRootsFromKnownPaths(knownPaths);
|
|
110
|
+
if (cached.expiresAt > now()) return mergeWindowsDriveRoots(cached.roots, knownRoots);
|
|
111
|
+
if (!pending) pending = discover(cwd).finally(() => { pending = null; });
|
|
112
|
+
return mergeWindowsDriveRoots(await pending, knownRoots);
|
|
113
|
+
};
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
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",
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
"tests",
|
|
57
57
|
"lib/WEBUI_TUI_NATIVE_PARITY.json",
|
|
58
58
|
"README.md",
|
|
59
|
+
"TECHNICAL.md",
|
|
60
|
+
"DEVELOPMENT.md",
|
|
59
61
|
"LICENSE"
|
|
60
62
|
],
|
|
61
63
|
"engines": {
|