pi-better-subagents 0.1.9 → 0.1.12
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/index.ts +11 -7
- package/package.json +1 -1
- package/parse.ts +3 -5
package/index.ts
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
type BackgroundWorkRow,
|
|
31
31
|
} from "./shared-navigator.ts";
|
|
32
32
|
import { spawnDetached, type SpawnResult } from "./spawn.ts";
|
|
33
|
-
import { parseRun, resetParseRunCursor, type Usage } from "./parse.ts";
|
|
33
|
+
import { parseRun, resetParseRunCursor, tailLog, type Usage } from "./parse.ts";
|
|
34
34
|
import { finalizeRun as finalizeRunCore } from "./finalization.ts";
|
|
35
35
|
import { loadConfig, normalizeTools, resolveExtensionPath, SAFE_DEFAULT_TOOLS, SAFE_CLEAN_TOOLS, DEFAULT_MAX_CONCURRENT } from "./config.ts";
|
|
36
36
|
import { resolveExtensions, extensionArgs } from "./extensions.ts";
|
|
@@ -659,8 +659,7 @@ function isTerminalNavigatorStatus(status: string): boolean {
|
|
|
659
659
|
}
|
|
660
660
|
|
|
661
661
|
/** Live detail snapshot for one run (registry + log parse + health). */
|
|
662
|
-
function navigatorDetail(id: string) {
|
|
663
|
-
const now = Date.now();
|
|
662
|
+
function navigatorDetail(id: string, now: number = Date.now()) {
|
|
664
663
|
return buildNavigatorDetail(id, {
|
|
665
664
|
readMeta,
|
|
666
665
|
effectiveStatus,
|
|
@@ -742,9 +741,10 @@ function subagentWorkRows(now: number): BackgroundWorkRow[] {
|
|
|
742
741
|
});
|
|
743
742
|
}
|
|
744
743
|
|
|
745
|
-
function subagentWorkDetail(id: string, now: number): BackgroundWorkDetail | null {
|
|
746
|
-
const detail = navigatorDetail(id);
|
|
744
|
+
function subagentWorkDetail(id: string, now: number, options?: { logTailLines?: number }): BackgroundWorkDetail | null {
|
|
745
|
+
const detail = navigatorDetail(id, now);
|
|
747
746
|
if (!detail) return null;
|
|
747
|
+
const logTailLines = options?.logTailLines ?? 10;
|
|
748
748
|
const metadata = [
|
|
749
749
|
{ label: "provider", value: "Subagents" },
|
|
750
750
|
{ label: "model", value: detail.effort ? `${detail.model} · effort ${detail.effort}` : detail.model },
|
|
@@ -762,7 +762,11 @@ function subagentWorkDetail(id: string, now: number): BackgroundWorkDetail | nul
|
|
|
762
762
|
statusTone: statusTone(detail.status),
|
|
763
763
|
subtitle: detail.currentTool ? `current tool ${detail.currentTool}` : undefined,
|
|
764
764
|
metadata,
|
|
765
|
-
|
|
765
|
+
// The shared navigator refreshes this provider once a second while the
|
|
766
|
+
// detail overlay is open. Read the selected logical tail rows each
|
|
767
|
+
// time so the evidence behaves like `tail -f`, not a single parsed
|
|
768
|
+
// activity/result snapshot.
|
|
769
|
+
evidence: { label: "log tail", text: tailLog(id, logTailLines) },
|
|
766
770
|
footerActions: [detail.status === "running" || detail.status === "orphaned" ? "x stop" : "x dismiss"],
|
|
767
771
|
};
|
|
768
772
|
}
|
|
@@ -775,7 +779,7 @@ function ensureSubagentProvider(): void {
|
|
|
775
779
|
priority: 10,
|
|
776
780
|
visibleCount: () => navigatorRunningCount(),
|
|
777
781
|
listRows: (now) => subagentWorkRows(now),
|
|
778
|
-
detail: (id, now) => subagentWorkDetail(id, now),
|
|
782
|
+
detail: (id, now, options) => subagentWorkDetail(id, now, options),
|
|
779
783
|
armCloseLabel: (row) => row.status === "running" || row.status === "orphaned" ? "x again to stop" : "x again to dismiss",
|
|
780
784
|
close: (id) => {
|
|
781
785
|
const outcome = navigatorCloseRun(id) as { action: string; id: string; status?: string };
|
package/package.json
CHANGED
package/parse.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
readSync,
|
|
27
27
|
statSync,
|
|
28
28
|
} from "node:fs";
|
|
29
|
-
import { readBoundedTail } from "./shared-log-utils.ts";
|
|
29
|
+
import { readBoundedTail, tailTerminalDisplay } from "./shared-log-utils.ts";
|
|
30
30
|
import { readAppendedLines, type LogCursor } from "./log-cursor.ts";
|
|
31
31
|
import { logPathFor } from "./registry.ts";
|
|
32
32
|
|
|
@@ -89,13 +89,11 @@ interface TailRead {
|
|
|
89
89
|
*/
|
|
90
90
|
const readTail: (path: string, maxBytes: number) => TailRead = readBoundedTail;
|
|
91
91
|
|
|
92
|
-
/** Last `n`
|
|
92
|
+
/** Last `n` terminal display rows of a run's log, or a placeholder if empty/unreadable. */
|
|
93
93
|
export function tailLog(id: string, n: number, maxBytes = maxRawTailBytes()): string {
|
|
94
94
|
const tail = readTail(logPathFor(id), maxBytes);
|
|
95
95
|
if (tail.error || tail.text.trim() === "") return "(no output yet)";
|
|
96
|
-
const
|
|
97
|
-
const kept = lines.slice(Math.max(0, lines.length - n));
|
|
98
|
-
const out = kept.join("\n").trim();
|
|
96
|
+
const out = tailTerminalDisplay(tail.text, n).trim();
|
|
99
97
|
return out === "" ? "(no output yet)" : out;
|
|
100
98
|
}
|
|
101
99
|
|