pi-better-harness 0.3.7 → 0.3.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/node_modules/pi-better-background-tasks/package.json +1 -1
- package/node_modules/pi-better-background-tasks/src/shared-navigator.ts +19 -7
- package/node_modules/pi-better-goal/package.json +1 -1
- package/node_modules/pi-better-goal/src/index.ts +18 -7
- package/node_modules/pi-better-subagents/package.json +1 -1
- package/node_modules/pi-better-subagents/shared-navigator.ts +19 -7
- package/package.json +4 -4
|
@@ -918,7 +918,7 @@ function createOverlayComponent(
|
|
|
918
918
|
width,
|
|
919
919
|
deps.truncate,
|
|
920
920
|
fg,
|
|
921
|
-
{ minRows: detailRows, bottomFooter: false, logTailRows },
|
|
921
|
+
{ minRows: detailRows, maxRows: detailRows, bottomFooter: false, logTailRows },
|
|
922
922
|
);
|
|
923
923
|
} else {
|
|
924
924
|
transcriptDetail = null;
|
|
@@ -1003,21 +1003,33 @@ function buildTranscriptDetailLines(
|
|
|
1003
1003
|
width: number,
|
|
1004
1004
|
truncate: (s: string, width: number) => string,
|
|
1005
1005
|
fg: (color: string, value: string) => string,
|
|
1006
|
-
options: { minRows?: number; bottomFooter?: boolean; logTailRows?: number } = {},
|
|
1006
|
+
options: { minRows?: number; maxRows?: number; bottomFooter?: boolean; logTailRows?: number } = {},
|
|
1007
1007
|
): string[] {
|
|
1008
1008
|
const actions = [...(detail.footerActions ?? ["x close"]), "Esc close"].join(" · ");
|
|
1009
1009
|
const tailRows = options.logTailRows ?? DEFAULT_LOG_TAIL_ROWS;
|
|
1010
|
-
|
|
1010
|
+
let shownTranscriptLines = transcriptLines.length ? transcriptLines.slice(-tailRows) : [" (no transcript yet)"];
|
|
1011
1011
|
const lines: string[] = [
|
|
1012
1012
|
fg("accent", rule(detail.title, width)),
|
|
1013
1013
|
dim(` ← main · ${actions}`, fg),
|
|
1014
1014
|
"",
|
|
1015
1015
|
` status ${fg(toneColor(detail.statusTone, detail.status), detail.status)}`,
|
|
1016
1016
|
];
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1017
|
+
const optionalMetadata = [
|
|
1018
|
+
...(detail.subtitle ? [` summary ${detail.subtitle}`] : []),
|
|
1019
|
+
...detail.metadata.map((item) => ` ${item.label.padEnd(8, " ").slice(0, 8)} ${item.value}`),
|
|
1020
|
+
];
|
|
1021
|
+
const transcriptHeader = ["", dim(section(`transcript · latest ${tailRows} rows`, width), fg)];
|
|
1022
|
+
if (detail.transcriptDiagnostic) transcriptHeader.push(` ${dim(detail.transcriptDiagnostic, fg)}`);
|
|
1023
|
+
if (options.maxRows !== undefined) {
|
|
1024
|
+
const fixedRows = lines.length + transcriptHeader.length + 1;
|
|
1025
|
+
const transcriptBudget = Math.max(1, options.maxRows - fixedRows);
|
|
1026
|
+
shownTranscriptLines = shownTranscriptLines.slice(-transcriptBudget);
|
|
1027
|
+
const metadataBudget = Math.max(0, options.maxRows - fixedRows - shownTranscriptLines.length);
|
|
1028
|
+
lines.push(...optionalMetadata.slice(0, metadataBudget));
|
|
1029
|
+
} else {
|
|
1030
|
+
lines.push(...optionalMetadata);
|
|
1031
|
+
}
|
|
1032
|
+
lines.push(...transcriptHeader);
|
|
1021
1033
|
lines.push(...shownTranscriptLines);
|
|
1022
1034
|
lines.push("");
|
|
1023
1035
|
if (options.bottomFooter === false) return lines.map((line) => safeTruncate(line, width, truncate));
|
|
@@ -248,6 +248,15 @@ export default function (pi: ExtensionAPI): void {
|
|
|
248
248
|
refreshGoalWidget?.(wasVisible);
|
|
249
249
|
};
|
|
250
250
|
|
|
251
|
+
const pauseGoalOnInterrupt = (ctx: ExtensionContext): void => {
|
|
252
|
+
const goal = getGoal(ctx);
|
|
253
|
+
if (!isPokeable(goal)) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
setGoal(goalWithStatus(goal, "paused"), ctx, "runtime");
|
|
257
|
+
notifyGoal(ctx, "Goal paused (interrupted).");
|
|
258
|
+
};
|
|
259
|
+
|
|
251
260
|
const queueGoalContinuation = (goal: GoalSnapshot): void => {
|
|
252
261
|
if (!isPokeable(goal) || continuationQueuedFor === goal.goalId) {
|
|
253
262
|
return;
|
|
@@ -728,6 +737,14 @@ export default function (pi: ExtensionAPI): void {
|
|
|
728
737
|
clearIdleContinuation();
|
|
729
738
|
continuationQueuedFor = null;
|
|
730
739
|
lastAgentEvidence = null;
|
|
740
|
+
const turnSignal = ctx.signal;
|
|
741
|
+
if (turnSignal) {
|
|
742
|
+
if (turnSignal.aborted) {
|
|
743
|
+
pauseGoalOnInterrupt(ctx);
|
|
744
|
+
} else {
|
|
745
|
+
turnSignal.addEventListener("abort", () => pauseGoalOnInterrupt(ctx), { once: true });
|
|
746
|
+
}
|
|
747
|
+
}
|
|
731
748
|
await publishSnapshot(ctx);
|
|
732
749
|
});
|
|
733
750
|
|
|
@@ -738,13 +755,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
738
755
|
// aborted (escape / ctrl+c while streaming), pause the active goal so it does
|
|
739
756
|
// not auto-continue after the user stopped the agent.
|
|
740
757
|
if (wasTurnAborted(event.messages)) {
|
|
741
|
-
|
|
742
|
-
if (isPokeable(goal)) {
|
|
743
|
-
setGoal(goalWithStatus(goal, "paused"), ctx, "runtime");
|
|
744
|
-
if (ctx.hasUI) {
|
|
745
|
-
ctx.ui.notify("Goal paused (interrupted).", "info");
|
|
746
|
-
}
|
|
747
|
-
}
|
|
758
|
+
pauseGoalOnInterrupt(ctx);
|
|
748
759
|
}
|
|
749
760
|
});
|
|
750
761
|
|
|
@@ -918,7 +918,7 @@ function createOverlayComponent(
|
|
|
918
918
|
width,
|
|
919
919
|
deps.truncate,
|
|
920
920
|
fg,
|
|
921
|
-
{ minRows: detailRows, bottomFooter: false, logTailRows },
|
|
921
|
+
{ minRows: detailRows, maxRows: detailRows, bottomFooter: false, logTailRows },
|
|
922
922
|
);
|
|
923
923
|
} else {
|
|
924
924
|
transcriptDetail = null;
|
|
@@ -1003,21 +1003,33 @@ function buildTranscriptDetailLines(
|
|
|
1003
1003
|
width: number,
|
|
1004
1004
|
truncate: (s: string, width: number) => string,
|
|
1005
1005
|
fg: (color: string, value: string) => string,
|
|
1006
|
-
options: { minRows?: number; bottomFooter?: boolean; logTailRows?: number } = {},
|
|
1006
|
+
options: { minRows?: number; maxRows?: number; bottomFooter?: boolean; logTailRows?: number } = {},
|
|
1007
1007
|
): string[] {
|
|
1008
1008
|
const actions = [...(detail.footerActions ?? ["x close"]), "Esc close"].join(" · ");
|
|
1009
1009
|
const tailRows = options.logTailRows ?? DEFAULT_LOG_TAIL_ROWS;
|
|
1010
|
-
|
|
1010
|
+
let shownTranscriptLines = transcriptLines.length ? transcriptLines.slice(-tailRows) : [" (no transcript yet)"];
|
|
1011
1011
|
const lines: string[] = [
|
|
1012
1012
|
fg("accent", rule(detail.title, width)),
|
|
1013
1013
|
dim(` ← main · ${actions}`, fg),
|
|
1014
1014
|
"",
|
|
1015
1015
|
` status ${fg(toneColor(detail.statusTone, detail.status), detail.status)}`,
|
|
1016
1016
|
];
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1017
|
+
const optionalMetadata = [
|
|
1018
|
+
...(detail.subtitle ? [` summary ${detail.subtitle}`] : []),
|
|
1019
|
+
...detail.metadata.map((item) => ` ${item.label.padEnd(8, " ").slice(0, 8)} ${item.value}`),
|
|
1020
|
+
];
|
|
1021
|
+
const transcriptHeader = ["", dim(section(`transcript · latest ${tailRows} rows`, width), fg)];
|
|
1022
|
+
if (detail.transcriptDiagnostic) transcriptHeader.push(` ${dim(detail.transcriptDiagnostic, fg)}`);
|
|
1023
|
+
if (options.maxRows !== undefined) {
|
|
1024
|
+
const fixedRows = lines.length + transcriptHeader.length + 1;
|
|
1025
|
+
const transcriptBudget = Math.max(1, options.maxRows - fixedRows);
|
|
1026
|
+
shownTranscriptLines = shownTranscriptLines.slice(-transcriptBudget);
|
|
1027
|
+
const metadataBudget = Math.max(0, options.maxRows - fixedRows - shownTranscriptLines.length);
|
|
1028
|
+
lines.push(...optionalMetadata.slice(0, metadataBudget));
|
|
1029
|
+
} else {
|
|
1030
|
+
lines.push(...optionalMetadata);
|
|
1031
|
+
}
|
|
1032
|
+
lines.push(...transcriptHeader);
|
|
1021
1033
|
lines.push(...shownTranscriptLines);
|
|
1022
1034
|
lines.push("");
|
|
1023
1035
|
if (options.bottomFooter === false) return lines.map((line) => safeTruncate(line, width, truncate));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-better-harness",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Pi extension bundle for a write sandbox, subagents, background tasks, SSH, goals, and structured plans.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"test": "node --test test/*.test.mjs"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"pi-better-background-tasks": "0.2.
|
|
54
|
-
"pi-better-goal": "0.2.
|
|
53
|
+
"pi-better-background-tasks": "0.2.13",
|
|
54
|
+
"pi-better-goal": "0.2.3",
|
|
55
55
|
"pi-better-plan": "0.1.5",
|
|
56
56
|
"pi-better-sandbox": "0.3.0",
|
|
57
57
|
"pi-better-ssh": "0.1.1",
|
|
58
|
-
"pi-better-subagents": "0.1.
|
|
58
|
+
"pi-better-subagents": "0.1.28"
|
|
59
59
|
},
|
|
60
60
|
"bundledDependencies": [
|
|
61
61
|
"pi-better-background-tasks",
|