@trim21/personal-pi-extensions 0.0.289 → 0.0.291
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/package.json +1 -1
- package/src/spawn-agent.ts +7 -17
package/package.json
CHANGED
package/src/spawn-agent.ts
CHANGED
|
@@ -53,8 +53,8 @@ const MAX_OUTPUT_BYTES = 50 * 1024;
|
|
|
53
53
|
const DEFAULT_TOOLS = ["read", "grep", "find", "ls"];
|
|
54
54
|
/** Progress log keeps only the most recent lines (rolling window). */
|
|
55
55
|
const MAX_PROGRESS_LINES = 5;
|
|
56
|
-
/** Progress line content (without the `tool:` / `text:` prefix) is capped at
|
|
57
|
-
const MAX_PROGRESS_CHARS_PER_LINE =
|
|
56
|
+
/** Progress line content (without the `tool:` / `text:` prefix) is capped at 21 chars; longer text is folded to the first/last 9 chars joined by ` … `. */
|
|
57
|
+
const MAX_PROGRESS_CHARS_PER_LINE = 21;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Tool → extension override map: when a subagent's frontmatter enables a
|
|
@@ -98,8 +98,6 @@ const spawnAgentSchema = Type.Object({
|
|
|
98
98
|
// ── result types ─────────────────────────────────────────────────────────────
|
|
99
99
|
|
|
100
100
|
interface UsageStats {
|
|
101
|
-
input: number;
|
|
102
|
-
output: number;
|
|
103
101
|
cost: number;
|
|
104
102
|
contextTokens: number;
|
|
105
103
|
turns: number;
|
|
@@ -134,15 +132,15 @@ function getFinalOutput(messages: AgentMessage[]): string {
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
/**
|
|
137
|
-
* Fold over-long progress line content: keep the first/last
|
|
138
|
-
*
|
|
139
|
-
* `MAX_PROGRESS_CHARS_PER_LINE` chars (
|
|
135
|
+
* Fold over-long progress line content: keep the first/last 9 chars joined by
|
|
136
|
+
* ` … ` (space, ellipsis, space), so the folded line never exceeds
|
|
137
|
+
* `MAX_PROGRESS_CHARS_PER_LINE` chars (9 + 3 + 9 = 21). Shorter text is
|
|
140
138
|
* returned as-is.
|
|
141
139
|
*/
|
|
142
140
|
function foldProgressLine(text: string): string {
|
|
143
141
|
if (text.length <= MAX_PROGRESS_CHARS_PER_LINE) return text;
|
|
144
|
-
const keep = Math.floor((MAX_PROGRESS_CHARS_PER_LINE -
|
|
145
|
-
return `${text.slice(0, keep)}
|
|
142
|
+
const keep = Math.floor((MAX_PROGRESS_CHARS_PER_LINE - 3) / 2);
|
|
143
|
+
return `${text.slice(0, keep)} … ${text.slice(-keep)}`;
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
function formatTokens(count: number): string {
|
|
@@ -155,8 +153,6 @@ function formatTokens(count: number): string {
|
|
|
155
153
|
function formatUsageStats(usage: UsageStats, model?: string): string {
|
|
156
154
|
const parts: string[] = [];
|
|
157
155
|
if (usage.turns) parts.push(`${usage.turns} turn${usage.turns > 1 ? "s" : ""}`);
|
|
158
|
-
if (usage.input) parts.push(`↑${formatTokens(usage.input)}`);
|
|
159
|
-
if (usage.output) parts.push(`↓${formatTokens(usage.output)}`);
|
|
160
156
|
if (usage.cost) parts.push(`$${usage.cost.toFixed(4)}`);
|
|
161
157
|
if (usage.contextTokens > 0) parts.push(`ctx:${formatTokens(usage.contextTokens)}`);
|
|
162
158
|
if (model) parts.push(model);
|
|
@@ -341,8 +337,6 @@ export async function runAgent(
|
|
|
341
337
|
messages: [],
|
|
342
338
|
stderr: "",
|
|
343
339
|
usage: {
|
|
344
|
-
input: 0,
|
|
345
|
-
output: 0,
|
|
346
340
|
cost: 0,
|
|
347
341
|
contextTokens: 0,
|
|
348
342
|
turns: 0,
|
|
@@ -492,8 +486,6 @@ export async function runAgent(
|
|
|
492
486
|
result.messages.push(msg);
|
|
493
487
|
if (msg.role === "assistant") {
|
|
494
488
|
result.usage.turns++;
|
|
495
|
-
result.usage.input += msg.usage.input;
|
|
496
|
-
result.usage.output += msg.usage.output;
|
|
497
489
|
result.usage.cost += msg.usage.cost.total;
|
|
498
490
|
result.usage.contextTokens = msg.usage.totalTokens;
|
|
499
491
|
if (!result.model) result.model = msg.model;
|
|
@@ -646,8 +638,6 @@ export default function spawnAgent(pi: ExtensionAPI) {
|
|
|
646
638
|
messages: [],
|
|
647
639
|
stderr: "",
|
|
648
640
|
usage: {
|
|
649
|
-
input: 0,
|
|
650
|
-
output: 0,
|
|
651
641
|
cost: 0,
|
|
652
642
|
contextTokens: 0,
|
|
653
643
|
turns: 0,
|