@trim21/personal-pi-extensions 0.0.283 → 0.0.284

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/spawn-agent.ts +20 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.0.283",
3
+ "version": "0.0.284",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -13,9 +13,10 @@
13
13
  * Progress is a rolling log: `tool: <name>` lines for tool calls and
14
14
  * `text: <content>` lines for completed text blocks, keeping the last
15
15
  * `MAX_PROGRESS_LINES` lines. Consecutive tool calls are merged into a
16
- * single `tool:` line (`read x 2, glob`) and line content is capped at
17
- * `MAX_PROGRESS_CHARS_PER_LINE` characters, so a burst of tool calls or a long
18
- * text block does not flood the window; any text block starts a new line.
16
+ * single `tool:` line (`read x 2, glob`) and over-long line content is
17
+ * folded to the first/last 7 chars joined by `…`, so a burst of tool calls
18
+ * or a long text block does not flood the window; any text block starts a
19
+ * new line.
19
20
  *
20
21
  * Security default: without an explicit `tools:` in the frontmatter, the
21
22
  * subagent only gets read-only tools (read/grep/find/ls) — no bash/write/edit.
@@ -51,8 +52,8 @@ const MAX_OUTPUT_BYTES = 50 * 1024;
51
52
  const DEFAULT_TOOLS = ["read", "grep", "find", "ls"];
52
53
  /** Progress log keeps only the most recent lines (rolling window). */
53
54
  const MAX_PROGRESS_LINES = 5;
54
- /** Progress line content (without the `tool:` / `text:` prefix) is capped at 50 chars. */
55
- const MAX_PROGRESS_CHARS_PER_LINE = 50;
55
+ /** Progress line content (without the `tool:` / `text:` prefix) is capped at 15 chars; longer text is folded to the first/last 7 chars joined by `…`. */
56
+ const MAX_PROGRESS_CHARS_PER_LINE = 15;
56
57
 
57
58
  /**
58
59
  * Tool → extension override map: when a subagent's frontmatter enables a
@@ -131,6 +132,18 @@ function getFinalOutput(messages: AgentMessage[]): string {
131
132
  return "";
132
133
  }
133
134
 
135
+ /**
136
+ * Fold over-long progress line content: keep the first/last 7 chars joined by
137
+ * a single `…` ellipsis, so the folded line never exceeds
138
+ * `MAX_PROGRESS_CHARS_PER_LINE` chars (7 + 1 + 7 = 15). Shorter text is
139
+ * returned as-is.
140
+ */
141
+ function foldProgressLine(text: string): string {
142
+ if (text.length <= MAX_PROGRESS_CHARS_PER_LINE) return text;
143
+ const keep = Math.floor((MAX_PROGRESS_CHARS_PER_LINE - 1) / 2);
144
+ return `${text.slice(0, keep)}…${text.slice(-keep)}`;
145
+ }
146
+
134
147
  function formatTokens(count: number): string {
135
148
  if (count < 1000) return count.toString();
136
149
  if (count < 10_000) return `${(count / 1000).toFixed(1)}k`;
@@ -379,7 +392,7 @@ export async function runAgent(
379
392
  toolLine = { name, count: 1 };
380
393
  }
381
394
  const parts = [...toolLineSegments, toolSegment(toolLine.name, toolLine.count)].join(", ");
382
- const line = `tool: ${parts.slice(0, MAX_PROGRESS_CHARS_PER_LINE)}`;
395
+ const line = `tool: ${foldProgressLine(parts)}`;
383
396
  if (firstInBatch) {
384
397
  logLines.push(line);
385
398
  if (logLines.length > MAX_PROGRESS_LINES) {
@@ -462,7 +475,7 @@ export async function runAgent(
462
475
  // `text:` log line. Deltas/thinking are intentionally not logged.
463
476
  const delta = event.assistantMessageEvent;
464
477
  if (delta.type === "text_end") {
465
- pushLogLine(`text: ${delta.content.slice(0, MAX_PROGRESS_CHARS_PER_LINE)}`);
478
+ pushLogLine(`text: ${foldProgressLine(delta.content)}`);
466
479
  emitUpdate();
467
480
  }
468
481