@firstpick/pi-package-webui 0.6.4 → 0.6.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 +1076 -43
- package/lib/git-worktrees.mjs +42 -0
- package/lib/trust-boundaries.mjs +2 -0
- package/package.json +2 -2
- package/public/app.js +2140 -164
- package/public/index.html +25 -1
- package/public/styles.css +520 -2
- package/tests/http-endpoints-harness.test.mjs +390 -0
- package/tests/mobile-static.test.mjs +3 -0
package/lib/git-worktrees.mjs
CHANGED
|
@@ -46,6 +46,9 @@ function runCommand(command, args, { cwd, timeoutMs = GIT_DEFAULT_TIMEOUT_MS, ma
|
|
|
46
46
|
return new Promise((resolve) => {
|
|
47
47
|
const child = spawn(command, args, {
|
|
48
48
|
cwd,
|
|
49
|
+
// LC_ALL=C keeps git output in English so lock-failure classification
|
|
50
|
+
// works regardless of locale.
|
|
51
|
+
env: { ...process.env, LC_ALL: "C" },
|
|
49
52
|
stdio: ["ignore", "pipe", "pipe"],
|
|
50
53
|
windowsHide: true,
|
|
51
54
|
});
|
|
@@ -514,3 +517,42 @@ export async function removeGitWorktree(cwd, worktreePath, { force = false } = {
|
|
|
514
517
|
return { ok: true, removed: true, path: fresh.path, branch: fresh.branch, ...responseBase(refreshed, fresh) };
|
|
515
518
|
});
|
|
516
519
|
}
|
|
520
|
+
|
|
521
|
+
// Shared with bin/pi-webui.mjs so every mutating git endpoint can classify
|
|
522
|
+
// index.lock contention the same way instead of surfacing raw stderr.
|
|
523
|
+
export function isGitLockFailure(result) {
|
|
524
|
+
return isLockFailure(result);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
export async function pruneGitWorktrees(cwd, { dryRun = true } = {}) {
|
|
528
|
+
const data = await readWorktreeData(cwd);
|
|
529
|
+
const prunable = data.worktrees
|
|
530
|
+
.filter((item) => item.prunable)
|
|
531
|
+
.map((item) => ({ path: item.path, branch: item.branch, ...(item.prunableReason ? { reason: item.prunableReason } : {}) }));
|
|
532
|
+
if (dryRun) {
|
|
533
|
+
const args = ["worktree", "prune", "--dry-run", "--verbose"];
|
|
534
|
+
const result = await runGitResult(args, { cwd: data.repoRoot, timeoutMs: 30_000 });
|
|
535
|
+
if (result.exitCode !== 0 || result.timedOut || result.error) {
|
|
536
|
+
throw makeGitWorktreeError(WORKTREE_ERROR_CODES.GIT_COMMAND_FAILED, gitFailureMessage(args, result), { cwd: data.repoRoot });
|
|
537
|
+
}
|
|
538
|
+
return {
|
|
539
|
+
ok: true,
|
|
540
|
+
dryRun: true,
|
|
541
|
+
repoRoot: data.repoRoot,
|
|
542
|
+
output: `${result.stdout || ""}\n${result.stderr || ""}`.trim(),
|
|
543
|
+
prunable,
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
return withMutationLock(data.commonGitDir, async () => {
|
|
547
|
+
const result = await runGitMutationWithRetry(["worktree", "prune", "--verbose"], { cwd: data.repoRoot });
|
|
548
|
+
const refreshed = await readWorktreeData(data.repoRoot).catch(() => data);
|
|
549
|
+
return {
|
|
550
|
+
ok: true,
|
|
551
|
+
dryRun: false,
|
|
552
|
+
repoRoot: data.repoRoot,
|
|
553
|
+
output: `${result.stdout || ""}\n${result.stderr || ""}`.trim(),
|
|
554
|
+
pruned: prunable,
|
|
555
|
+
worktrees: refreshed.worktrees,
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
}
|
package/lib/trust-boundaries.mjs
CHANGED
|
@@ -18,7 +18,9 @@ export const LOCALHOST_ONLY_POST_ROUTES = new Map([
|
|
|
18
18
|
["/api/shutdown", "Shutdown is only allowed from localhost"],
|
|
19
19
|
["/api/optional-feature-install", "Installing optional Web UI features is only allowed from localhost"],
|
|
20
20
|
["/api/skill-file", "Saving skill files is only allowed from localhost"],
|
|
21
|
+
["/api/files", "Deleting files from the Web UI is only allowed from localhost"],
|
|
21
22
|
["/api/files/content", "Saving files from the Web UI is only allowed from localhost"],
|
|
23
|
+
["/api/files/move", "Moving files from the Web UI is only allowed from localhost"],
|
|
22
24
|
["/api/files/open-default", "Opening files in the default editor is only allowed from localhost"],
|
|
23
25
|
["/api/session-delete", "Deleting sessions is only allowed from localhost"],
|
|
24
26
|
["/api/auth-logout", "Removing stored provider credentials is only allowed from localhost"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@firstpick/pi-extension-bang-command-autocomplete": "^0.2.1",
|
|
63
63
|
"@firstpick/pi-extension-btw": "^0.1.2",
|
|
64
64
|
"@firstpick/pi-extension-fish-user-bash": "^0.2.1",
|
|
65
|
-
"@firstpick/pi-extension-git-footer-status": "^0.3.
|
|
65
|
+
"@firstpick/pi-extension-git-footer-status": "^0.3.7",
|
|
66
66
|
"@firstpick/pi-extension-release-aur": "^0.1.7",
|
|
67
67
|
"@firstpick/pi-extension-release-npm": "^0.4.0",
|
|
68
68
|
"@firstpick/pi-extension-safety-guard": "^0.2.3",
|