bermudis-pi-goodies 0.13.2 → 0.13.3
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 +6 -1
- package/clean-tui.ts +49 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ extensions. One entry point, eleven independent features.
|
|
|
23
23
|
After publishing the package to npm:
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
pi install npm:bermudis-pi-goodies@0.13.
|
|
26
|
+
pi install npm:bermudis-pi-goodies@0.13.3
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Remove any old `bermudis-pi-goodies.ts` symlink before reloading Pi. Each
|
|
@@ -53,6 +53,11 @@ are no extra endpoints or keys to configure. `/goodies list` shows whether
|
|
|
53
53
|
summaries are on or off, and `/goodies summary-model off` disables them
|
|
54
54
|
again.
|
|
55
55
|
|
|
56
|
+
Failures are invisible in the TUI (pi owns the terminal), so each distinct
|
|
57
|
+
failure is also appended to `~/.pi/agent/goodies.log` (capped at 256 KB,
|
|
58
|
+
oldest lines dropped), along with one `clean-tui active; summary-model=…`
|
|
59
|
+
line per load. If summaries silently stop, look there first.
|
|
60
|
+
|
|
56
61
|
Two practical notes:
|
|
57
62
|
|
|
58
63
|
- **Pick a fast non-thinking model.** Summaries get a tiny response budget;
|
package/clean-tui.ts
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
} from "@earendil-works/pi-coding-agent";
|
|
36
36
|
import { Box, Container, Text } from "@earendil-works/pi-tui";
|
|
37
37
|
import { homedir } from "node:os";
|
|
38
|
+
import { join } from "node:path";
|
|
39
|
+
import { appendFileSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
38
40
|
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
39
41
|
import {
|
|
40
42
|
findSummaryModel,
|
|
@@ -449,10 +451,48 @@ function logSummaryFailure(cmd: string, err: unknown, pauseMs?: number) {
|
|
|
449
451
|
const key = `${msg}${pause}`;
|
|
450
452
|
if (summaryFailuresLogged.has(key)) return;
|
|
451
453
|
summaryFailuresLogged.add(key);
|
|
452
|
-
|
|
453
|
-
`
|
|
454
|
-
|
|
455
|
-
);
|
|
454
|
+
const detail =
|
|
455
|
+
`command summary failed (${msg})${pause}; keeping heuristic hint. ` +
|
|
456
|
+
`Command starts: ${JSON.stringify(cmd.slice(0, 60))}`;
|
|
457
|
+
console.error(`[clean-tui] ${detail}`);
|
|
458
|
+
appendSummaryLog(detail);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// ── Summary log file ────────────────────────────────────────────
|
|
462
|
+
//
|
|
463
|
+
// console.error is invisible in TUI mode (pi owns the terminal), so summary
|
|
464
|
+
// failures also append to a small capped log file next to goodies.json and
|
|
465
|
+
// pi-debug.log. Failures only — successes are noise. Every fs call is
|
|
466
|
+
// guarded: an unwritable log destination must never break rendering or
|
|
467
|
+
// swallow the original error (console.error above already carried it).
|
|
468
|
+
const SUMMARY_LOG_DEFAULT_PATH = join(homedir(), ".pi", "agent", "goodies.log");
|
|
469
|
+
let summaryLogPath = SUMMARY_LOG_DEFAULT_PATH;
|
|
470
|
+
const SUMMARY_LOG_MAX_BYTES = 256 * 1024;
|
|
471
|
+
const SUMMARY_LOG_KEEP_BYTES = 64 * 1024;
|
|
472
|
+
|
|
473
|
+
/** Redirect the failure log (tests point this at scratch storage). */
|
|
474
|
+
export function __setSummaryLogPathForTesting(path?: string): void {
|
|
475
|
+
summaryLogPath = path ?? SUMMARY_LOG_DEFAULT_PATH;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function appendSummaryLog(line: string): void {
|
|
479
|
+
const stamped = `${new Date().toISOString()} [${process.pid}] ${line}`;
|
|
480
|
+
try {
|
|
481
|
+
if (statSync(summaryLogPath).size > SUMMARY_LOG_MAX_BYTES) {
|
|
482
|
+
// Size cap without timers or rotation daemons: keep the newest tail.
|
|
483
|
+
writeFileSync(
|
|
484
|
+
summaryLogPath,
|
|
485
|
+
readFileSync(summaryLogPath).subarray(-SUMMARY_LOG_KEEP_BYTES),
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
} catch {
|
|
489
|
+
// Missing/unreadable file — the append below (re)creates it.
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
appendFileSync(summaryLogPath, `${stamped}\n`);
|
|
493
|
+
} catch {
|
|
494
|
+
// Unwritable destination — nothing else to do; console.error carried it.
|
|
495
|
+
}
|
|
456
496
|
}
|
|
457
497
|
|
|
458
498
|
// Failure backoff: requestSummary runs on every bash renderCall, so after a
|
|
@@ -698,6 +738,11 @@ function formatLsBullet(entry: Entry, theme: any): string {
|
|
|
698
738
|
|
|
699
739
|
export default function cleanTui(pi: ExtensionAPI): void {
|
|
700
740
|
setCleanTuiActive(true);
|
|
741
|
+
// One line per load (pi process start, /reload) so the log answers "was the
|
|
742
|
+
// feature even on, and pointing at which model" without guessing.
|
|
743
|
+
appendSummaryLog(
|
|
744
|
+
`clean-tui active; summary-model=${getSummaryModel() ?? "off"}`,
|
|
745
|
+
);
|
|
701
746
|
const schemaTools = getBuiltInTools(process.cwd());
|
|
702
747
|
|
|
703
748
|
pi.on("agent_start", (_event, ctx) => {
|