@firstpick/pi-package-webui 0.7.4 → 0.7.6
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/README.md +2 -1
- package/bin/pi-webui.mjs +130 -1
- package/lib/git-workflow-preferences.mjs +89 -27
- package/lib/subagent-launch-slots.mjs +304 -0
- package/lib/trust-boundaries.mjs +1 -0
- package/package.json +19 -19
- package/public/app.js +957 -60
- package/public/index.html +62 -12
- package/public/service-worker.js +2 -1
- package/public/styles.css +670 -26
- package/public/subagent-launch-slot-state.mjs +64 -0
- package/tests/chat-scroll-intent-static.test.mjs +59 -0
- package/tests/compact-sections-static.test.mjs +111 -0
- package/tests/custom-message-markdown-static.test.mjs +15 -0
- package/tests/fast-mode-client-static.test.mjs +54 -6
- package/tests/footer-middle-truncation.test.mjs +2 -2
- package/tests/http-endpoints-harness.test.mjs +65 -0
- package/tests/mobile-static.test.mjs +38 -5
- package/tests/side-panel-resize-static.test.mjs +43 -0
- package/tests/subagent-launch-slot-state.test.mjs +36 -0
- package/tests/subagent-launch-slots-static.test.mjs +34 -0
- package/tests/subagent-launch-slots.test.mjs +143 -0
- package/tests/subagents-helper.test.mjs +55 -8
- package/webui-rpc-helper.mjs +41 -11
package/webui-rpc-helper.mjs
CHANGED
|
@@ -2,6 +2,11 @@ import { closeSync, fstatSync, openSync, readFileSync, readSync } from "node:fs"
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { AgentSession, formatSkillsForPrompt } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { readWebuiSettings } from "./lib/git-workflow-preferences.mjs";
|
|
5
|
+
import {
|
|
6
|
+
formatSubagentLaunchSlotGuidance,
|
|
7
|
+
resolveSubagentLaunchSlotProjectKey,
|
|
8
|
+
subagentLaunchSlotScopeEntry,
|
|
9
|
+
} from "./lib/subagent-launch-slots.mjs";
|
|
5
10
|
import { SUBAGENT_GATE_UPDATE_EVENT } from "./lib/subagent-gate.mjs";
|
|
6
11
|
|
|
7
12
|
const HELPER_COMMAND = "webui-helper";
|
|
@@ -234,7 +239,9 @@ function subagentAgentName(value) {
|
|
|
234
239
|
}
|
|
235
240
|
|
|
236
241
|
function subagentAgentFromDisplay(value) {
|
|
237
|
-
const display = subagentText(value, 240)
|
|
242
|
+
const display = subagentText(value, 240)
|
|
243
|
+
.replace(/^\[[^\]]+\]\s*/, "")
|
|
244
|
+
.replace(/\s+\[(?:fork|fresh|mixed)\]$/i, "");
|
|
238
245
|
const labeled = display.match(/\(([^()]*)\)$/);
|
|
239
246
|
return subagentAgentName(labeled?.[1] || display);
|
|
240
247
|
}
|
|
@@ -485,7 +492,7 @@ function parseSubagentStatusText(text, previousRuns = new Map()) {
|
|
|
485
492
|
if (runMatch) {
|
|
486
493
|
const id = subagentText(runMatch[1], 160);
|
|
487
494
|
const segments = rawLine.split(" | ").map((part) => part.trim());
|
|
488
|
-
const mode = segments.
|
|
495
|
+
const mode = segments.map((part) => part.match(/^(single|parallel|chain)\b/)?.[1]).find(Boolean);
|
|
489
496
|
const previous = previousRuns.get(id);
|
|
490
497
|
current = {
|
|
491
498
|
id,
|
|
@@ -540,6 +547,7 @@ export default function webuiRpcHelper(pi) {
|
|
|
540
547
|
let enabledTools = new Set();
|
|
541
548
|
let disabledSkills = new Set();
|
|
542
549
|
let inheritedEnabledSkills = null;
|
|
550
|
+
let subagentLaunchSlotGuidance = "";
|
|
543
551
|
let subagentContext = null;
|
|
544
552
|
let subagentBridgeAvailable = false;
|
|
545
553
|
let subagentPollTimer = null;
|
|
@@ -889,6 +897,18 @@ export default function webuiRpcHelper(pi) {
|
|
|
889
897
|
}
|
|
890
898
|
}
|
|
891
899
|
|
|
900
|
+
async function loadSubagentLaunchSlotGuidance(ctx) {
|
|
901
|
+
try {
|
|
902
|
+
const settings = await readWebuiSettings();
|
|
903
|
+
const projectKey = await resolveSubagentLaunchSlotProjectKey(ctx?.cwd);
|
|
904
|
+
const effective = subagentLaunchSlotScopeEntry(settings.subagentLaunchSlots, "project", projectKey);
|
|
905
|
+
subagentLaunchSlotGuidance = formatSubagentLaunchSlotGuidance(effective.entry.roles);
|
|
906
|
+
} catch (error) {
|
|
907
|
+
subagentLaunchSlotGuidance = "";
|
|
908
|
+
console.warn(`Web UI subagent launch slots could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
892
912
|
function persistToolsState() {
|
|
893
913
|
pi.appendEntry(TOOLS_CONFIG_TYPE, { enabledTools: [...enabledTools] });
|
|
894
914
|
}
|
|
@@ -1053,6 +1073,7 @@ export default function webuiRpcHelper(pi) {
|
|
|
1053
1073
|
const globalDefaults = await readGlobalResourceDefaults();
|
|
1054
1074
|
restoreToolsFromBranch(ctx, globalDefaults);
|
|
1055
1075
|
restoreSkillsFromBranch(ctx, globalDefaults);
|
|
1076
|
+
await loadSubagentLaunchSlotGuidance(ctx);
|
|
1056
1077
|
subagentContext = ctx;
|
|
1057
1078
|
subagentPollGeneration += 1;
|
|
1058
1079
|
foregroundSubagentRuns.clear();
|
|
@@ -1128,6 +1149,7 @@ export default function webuiRpcHelper(pi) {
|
|
|
1128
1149
|
|
|
1129
1150
|
pi.on("session_shutdown", () => {
|
|
1130
1151
|
subagentContext = null;
|
|
1152
|
+
subagentLaunchSlotGuidance = "";
|
|
1131
1153
|
subagentPollGeneration += 1;
|
|
1132
1154
|
clearTimeout(subagentPollTimer);
|
|
1133
1155
|
subagentPollTimer = null;
|
|
@@ -1147,14 +1169,22 @@ export default function webuiRpcHelper(pi) {
|
|
|
1147
1169
|
});
|
|
1148
1170
|
|
|
1149
1171
|
pi.on("before_agent_start", async (event) => {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
if (
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1172
|
+
let nextPrompt = event.systemPrompt;
|
|
1173
|
+
let changed = false;
|
|
1174
|
+
if (disabledSkills.size !== 0 || inheritedEnabledSkills !== null) {
|
|
1175
|
+
const allSkills = Array.isArray(event.systemPromptOptions?.skills) ? event.systemPromptOptions.skills : [];
|
|
1176
|
+
const disabledNames = allSkills.filter((skill) => !isSkillEnabled(skill.name)).map((skill) => skill.name);
|
|
1177
|
+
if (disabledNames.length) {
|
|
1178
|
+
const filteredSkills = allSkills.filter((skill) => isSkillEnabled(skill.name));
|
|
1179
|
+
nextPrompt = replaceAvailableSkillsSection(nextPrompt, filteredSkills);
|
|
1180
|
+
for (const name of disabledNames) nextPrompt = nextPrompt.replace(skillBlockPattern(name), "");
|
|
1181
|
+
changed = true;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
if (subagentLaunchSlotGuidance) {
|
|
1185
|
+
nextPrompt = `${String(nextPrompt || "").trimEnd()}\n\n${subagentLaunchSlotGuidance}\n`;
|
|
1186
|
+
changed = true;
|
|
1187
|
+
}
|
|
1188
|
+
return changed ? { systemPrompt: nextPrompt } : undefined;
|
|
1159
1189
|
});
|
|
1160
1190
|
}
|