@pi-kaush/pi-tool-call-markers 0.3.22 → 0.3.24
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 +18 -18
- package/package.json +1 -1
- package/src/index.ts +26 -16
- package/src/muted.ts +11 -10
- package/src/thinking-block-merger.ts +14 -8
package/README.md
CHANGED
|
@@ -15,14 +15,14 @@ Restart Pi or run `/reload`.
|
|
|
15
15
|
Collapsed tool rows use semantic theme colors with no gear, background fill, box padding, or filled blank rows:
|
|
16
16
|
|
|
17
17
|
```text
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
▏§ writing-prose/SKILL.md 42 lines
|
|
19
|
+
▏≡ .pi/prompts/review.md 18 lines
|
|
20
|
+
▏● src/a.ts 42 lines
|
|
21
|
+
▏$ npm test → done
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
- **Two-column outer inset.** Tool markers and image output align with an inset conversation surface. Very narrow terminals reduce the decoration before useful content.
|
|
25
|
-
-
|
|
25
|
+
- **`▏` tool-call rail.** Collapsed calls use a bold glyph instead of repeating the tool name. The thin rail lines up with the left edge of the submitted prompt bar, and the call text lines up with the first character of the prompt. A single space separates the glyph from the call text. Grouped rows flow directly across tool types. See [Tool-call glyphs](#tool-call-glyphs) for the full list.
|
|
26
26
|
- **Semantic, low-contrast status.** The anchor and the call content share the collapsed mute, pending state is warning-colored, and failures remain error-colored. Ordinary tool states have no background.
|
|
27
27
|
- **Width-safe outcome tails.** Long summaries truncate before useful tails such as `→ done`, `→ 42 lines`, `→ +2/-1`, or a `bash` duration.
|
|
28
28
|
- **Stable running groups.** Adjacent calls group as they appear, including settled failures, which stay error-colored inside the group. Pending state and elapsed `bash` time settle into the final outcome without changing the row count.
|
|
@@ -50,15 +50,15 @@ Collapsed tool rows use semantic theme colors with no gear, background fill, box
|
|
|
50
50
|
|
|
51
51
|
Pi prompt templates are matched against the templates registered at session start, including files outside the usual prompt directories. Other skill files and unregistered templates keep the `●` read marker. These markers do not change submitted prompts or slash commands.
|
|
52
52
|
|
|
53
|
-
Subagent calls use the
|
|
53
|
+
Subagent calls use the `▏` rail without a glyph. Recognized question calls use the submitted-prompt shell instead of a tool-call glyph.
|
|
54
54
|
|
|
55
55
|
## Codemode commands
|
|
56
56
|
|
|
57
57
|
Collapsed codemode rows include bash command previews instead of only tool names:
|
|
58
58
|
|
|
59
59
|
```text
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
▏¢ bash ×1 npm test
|
|
61
|
+
▏¢ bash ×2 git status --short, bash npm test
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
The first preview for each tool shows its total call count, including ×1.
|
|
@@ -73,19 +73,19 @@ native script, nested call status, and result details.
|
|
|
73
73
|
|
|
74
74
|
## Subagent plans
|
|
75
75
|
|
|
76
|
-
A recognized `subagent` call renders as an unboxed plan in the shared tool aesthetic, using the same
|
|
76
|
+
A recognized `subagent` call renders as an unboxed plan in the shared tool aesthetic, using the same `▏` tool-call rail:
|
|
77
77
|
|
|
78
78
|
```text
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
▏ subagent chain (3 steps) [repo-review]
|
|
80
|
+
1. 🐝 bee [workhorse] Challenge the compatibility conclusion…
|
|
81
|
+
2. 🐝 bee …
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Single calls stay on one
|
|
84
|
+
Single calls stay on one `▏ [<emoji>] [<profile>][<agent>] <task preview>` row — no tool label. Chain calls get a heading with the kind, count, and scope followed by numbered steps (parallel tasks list without numbers), with each step ordered emoji, profile badge, name badge. Agent display names (emoji + name) are scraped from the native plan component — including the single-call heading — with an args fallback, and render in `accent`; everything else stays muted, and failed subagents go full red. Subagents never join ordinary tool groups.
|
|
85
85
|
|
|
86
86
|
While a subagent runs, the plan headline's tail shows live progress from the streamed result details — `→ 1 turn · provider/model` in the warning tone — and a settled call keeps the same `→ N turns · provider/model` summary in muted (turns aggregate across tasks; the model shows only when every task used the same one).
|
|
87
87
|
|
|
88
|
-
Malformed, ambiguous, future, or too-narrow shapes fall back to the generic
|
|
88
|
+
Malformed, ambiguous, future, or too-narrow shapes fall back to the generic `▏ subagent …` collapsed row rather than dropping information, and `Ctrl+O` still exposes the native subagent renderer.
|
|
89
89
|
|
|
90
90
|
## Asked questions
|
|
91
91
|
|
|
@@ -137,11 +137,11 @@ The second package entrypoint, `src/thinking-block-merger.ts`, combines only dir
|
|
|
137
137
|
When Pi exposes its per-row hidden-thinking and streaming fields, hidden reasoning uses these native-themed labels:
|
|
138
138
|
|
|
139
139
|
```text
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
▏⠋ Thinking… → ▏⠙ Thinking… → …
|
|
141
|
+
▏* Thought · 2.5s
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
The live label samples Pi's native braille spinner sequence from the clock each time the TUI draws it, so it steps with the redraws Pi's working indicator already drives instead of freezing between bursty thinking deltas. It does not add a timer; with the working indicator hidden, the spinner advances on each content update. The adapter stores the first local streaming timestamp per assistant row in a `WeakMap`. A restored message or an older runtime with no streaming argument uses
|
|
144
|
+
The live label samples Pi's native braille spinner sequence from the clock each time the TUI draws it, so it steps with the redraws Pi's working indicator already drives instead of freezing between bursty thinking deltas. It does not add a timer; with the working indicator hidden, the spinner advances on each content update. The adapter stores the first local streaming timestamp per assistant row in a `WeakMap`. A restored message or an older runtime with no streaming argument uses `▏* Thought`. Both labels keep a faint `▏` rail and a bold glyph. The spinner holds the glyph slot and settles into `*` in place: the rail and the label text keep their columns, and the rail keeps the settled tone throughout. There is no interval, timeout, render request, model call, or network work.
|
|
145
145
|
|
|
146
146
|
Pi renders thinking labels and traces italic. This package drops those italics: both labels read as plain collapsed rows (the live spinner keeps its thinking-level tint, the settled row the muted tone, and a theme that resolves no color still loses the italics), and a visible trace stays italic only while it streams, then settles into ordinary transcript text. `PI_TOOL_CALL_MARKERS_THOUGHT_COLOR=inherit` is the opt-out that keeps Pi's native italic `thinkingText` styling.
|
|
147
147
|
|
|
@@ -175,7 +175,7 @@ Names are comma-separated and matched exactly. Listed rows never join a group, a
|
|
|
175
175
|
|
|
176
176
|
### Collapsed-row colors
|
|
177
177
|
|
|
178
|
-
Collapsed rows (tool calls,
|
|
178
|
+
Collapsed rows (tool calls, `▏* Thought`, subagents) default to the theme's `dim` color — it ships with every Pi theme and sits below `muted`, including in the generated `system` theme — with the row's anchor and the call content sharing it. Failures stay error-colored and live spinners keep their existing tints.
|
|
179
179
|
|
|
180
180
|
A theme can override each collapsed kind independently with optional color tokens:
|
|
181
181
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -21,12 +21,18 @@ import {
|
|
|
21
21
|
installInfoVisibility,
|
|
22
22
|
uninstallInfoVisibility,
|
|
23
23
|
} from "./info-visibility.ts";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
COLLAPSED_RAIL,
|
|
26
|
+
fgCollapsed,
|
|
27
|
+
paletteSample,
|
|
28
|
+
withFaintCollapsedRail,
|
|
29
|
+
} from "./muted.ts";
|
|
25
30
|
import { isQuestionToolCall, renderQuestionBlock } from "./question-block.ts";
|
|
26
31
|
import { sanitizeInline } from "./sanitize.ts";
|
|
27
32
|
|
|
28
33
|
const OUTER_INSET = 2;
|
|
29
|
-
|
|
34
|
+
// Glyphless rows leave room for the glyph and its trailing space.
|
|
35
|
+
const SUBAGENT_LABEL_GAP = " ";
|
|
30
36
|
// Collapsed rows anchor with a glyph instead of repeating the tool name;
|
|
31
37
|
// tools that read as one family share a glyph, and unmapped tools fall back
|
|
32
38
|
// to `*`. A single space separates the glyph from the call content: the
|
|
@@ -953,18 +959,16 @@ function codemodeCallLabel(row: ToolExecutionRow): string | undefined {
|
|
|
953
959
|
return parts.length > 0 ? parts.join(" · ") : undefined;
|
|
954
960
|
}
|
|
955
961
|
|
|
956
|
-
// One anchor builder for every collapsed row: the faint rail, then the
|
|
957
|
-
// row's bold glyph when it has one — `│ ● src/a.ts`, `│ $ npm test`. A
|
|
958
|
-
// subagent row anchors on the rail alone and keeps its `│ subagent …`
|
|
959
|
-
// reading instead of a glyph.
|
|
960
962
|
function collapsedAnchor(
|
|
961
963
|
theme: ThemeLike,
|
|
962
964
|
color: string,
|
|
963
965
|
glyph: string | undefined,
|
|
964
966
|
): string {
|
|
965
|
-
const rail =
|
|
967
|
+
const rail = withFaintCollapsedRail((marker) =>
|
|
968
|
+
fgCollapsed(theme, "muted", marker),
|
|
969
|
+
);
|
|
966
970
|
return glyph === undefined
|
|
967
|
-
? rail
|
|
971
|
+
? `${rail}${SUBAGENT_LABEL_GAP}`
|
|
968
972
|
: `${rail}${fgCollapsed(theme, color, glyph, true)} `;
|
|
969
973
|
}
|
|
970
974
|
|
|
@@ -1280,11 +1284,9 @@ function subagentPlanOutcome(
|
|
|
1280
1284
|
return theme.fg("warning", "…");
|
|
1281
1285
|
}
|
|
1282
1286
|
|
|
1283
|
-
// Subagents
|
|
1284
|
-
//
|
|
1285
|
-
//
|
|
1286
|
-
// collapse to one row: `│ <emoji> [<profile>][<name>] <task preview>`. Everything
|
|
1287
|
-
// else stays muted (or error on failure), matching the shared tool-row aesthetic.
|
|
1287
|
+
// Subagents use the collapsed rail with no separate glyph. A single call
|
|
1288
|
+
// starts with its agent identity; a multi-step plan starts with a heading.
|
|
1289
|
+
// Agent identities use accent, and failures use error colors.
|
|
1288
1290
|
function renderSubagentPlan(
|
|
1289
1291
|
row: ToolExecutionRow,
|
|
1290
1292
|
width: number,
|
|
@@ -1343,6 +1345,9 @@ function renderSubagentPlan(
|
|
|
1343
1345
|
fgCollapsed(theme, failed ? "error" : "toolOutput", ` [${plan.scope}]`),
|
|
1344
1346
|
),
|
|
1345
1347
|
];
|
|
1348
|
+
const stepIndent = " ".repeat(
|
|
1349
|
+
visibleWidth(COLLAPSED_RAIL + SUBAGENT_LABEL_GAP),
|
|
1350
|
+
);
|
|
1346
1351
|
const shown = plan.steps.slice(0, 3);
|
|
1347
1352
|
for (let index = 0; index < shown.length; index++) {
|
|
1348
1353
|
const step = shown[index]!;
|
|
@@ -1350,11 +1355,11 @@ function renderSubagentPlan(
|
|
|
1350
1355
|
plan.kind === "chain"
|
|
1351
1356
|
? `${fgCollapsed(theme, color, `${index + 1}.`)} `
|
|
1352
1357
|
: "";
|
|
1353
|
-
lines.push(
|
|
1358
|
+
lines.push(`${stepIndent}${number}${identityOf(step)}${previewOf(step)}`);
|
|
1354
1359
|
}
|
|
1355
1360
|
if (plan.steps.length > shown.length) {
|
|
1356
1361
|
lines.push(
|
|
1357
|
-
|
|
1362
|
+
`${stepIndent}${fgCollapsed(theme, color, `... +${plan.steps.length - shown.length} more`)}`,
|
|
1358
1363
|
);
|
|
1359
1364
|
}
|
|
1360
1365
|
return lines;
|
|
@@ -1610,7 +1615,12 @@ function installGroupingPatch(
|
|
|
1610
1615
|
if (!proto || typeof proto.render !== "function") return undefined;
|
|
1611
1616
|
|
|
1612
1617
|
const existing = proto[GROUPING_PATCHED];
|
|
1613
|
-
if (existing) {
|
|
1618
|
+
if (existing?.disabled && proto.render === existing.patchedRender) {
|
|
1619
|
+
// A later wrapper may have restored ours after we shut down. Replace
|
|
1620
|
+
// it now so reload uses the new module's renderer, not the old closure.
|
|
1621
|
+
proto.render = existing.originalRender;
|
|
1622
|
+
delete proto[GROUPING_PATCHED];
|
|
1623
|
+
} else if (existing) {
|
|
1614
1624
|
existing.owners++;
|
|
1615
1625
|
existing.presentation = presentation;
|
|
1616
1626
|
existing.disabled = false;
|
package/src/muted.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Collapsed-row color policy.
|
|
2
2
|
//
|
|
3
|
-
// Collapsed blocks (tool calls, settled
|
|
3
|
+
// Collapsed blocks (tool calls, settled thinking labels, subagent rows)
|
|
4
4
|
// default to the theme's `dim` token — it ships with every Pi theme and sits
|
|
5
5
|
// below `muted` — instead of the louder muted/toolTitle/toolOutput split.
|
|
6
6
|
// Pi's generated `system` theme solves `syntaxComment` to the same contrast
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Failures always fall back to the historical tokens.
|
|
12
12
|
|
|
13
|
+
// The thin rail shares the submitted prompt bar's left edge.
|
|
14
|
+
export const COLLAPSED_RAIL = "▏";
|
|
15
|
+
|
|
16
|
+
// Faint keeps the rail quieter than the label, even on failed rows.
|
|
17
|
+
export function withFaintCollapsedRail(
|
|
18
|
+
style: (rail: string) => string,
|
|
19
|
+
): string {
|
|
20
|
+
return `\x1b[2m${style(COLLAPSED_RAIL)}\x1b[22m`;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
const TOOL_OVERRIDE_TOKEN = "collapsedToolCall";
|
|
14
24
|
const THINKING_OVERRIDE_TOKEN = "collapsedThinkingCall";
|
|
15
25
|
const DEFAULT_TOKEN = "dim";
|
|
@@ -94,12 +104,3 @@ export function fgCollapsed(
|
|
|
94
104
|
}
|
|
95
105
|
return theme.fg(color, bold && theme.bold ? theme.bold(text) : text);
|
|
96
106
|
}
|
|
97
|
-
|
|
98
|
-
// Decoration rails recede further than collapsed text. No palette token is
|
|
99
|
-
// guaranteed lighter than the collapsed `dim` color, so apply the terminal's
|
|
100
|
-
// faint attribute: it lightens toward the background on light themes and
|
|
101
|
-
// darkens on dark ones. The rail keeps this muted weight even on failed
|
|
102
|
-
// rows, where only the row's text turns error-colored.
|
|
103
|
-
export function fgCollapsedRail(theme: CollapsedTheme, text: string): string {
|
|
104
|
-
return `\x1b[2m${fgCollapsed(theme, "muted", text)}\x1b[22m`;
|
|
105
|
-
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { AssistantMessageComponent } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { infoVisibilityHidden } from "./info-visibility-state.ts";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
COLLAPSED_RAIL,
|
|
6
|
+
collapsedThinkingAnsi,
|
|
7
|
+
withFaintCollapsedRail,
|
|
8
|
+
} from "./muted.ts";
|
|
5
9
|
|
|
6
10
|
const THINKING_GROUPING_PATCHED = Symbol.for("kg.pi.thinkingGrouping.v2");
|
|
7
11
|
const PI_SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
@@ -10,7 +14,7 @@ const SPINNER_INTERVAL_MS = 80;
|
|
|
10
14
|
// Visual treatment for the collapsed thinking label. The live "Thinking…"
|
|
11
15
|
// spinner tints with the session's active thinking-level color
|
|
12
16
|
// (thinkingOff…thinkingMax), so progress reads as activity; the settled
|
|
13
|
-
// "
|
|
17
|
+
// "Thought" row drops to the muted token collapsed tool calls use, so
|
|
14
18
|
// finished reasoning stops advertising the level. "inherit" keeps Pi's
|
|
15
19
|
// native styling (italic + thinkingText) for both states, and "mdheading"
|
|
16
20
|
// rides the theme's mdHeading token for both. The env var overrides the
|
|
@@ -109,10 +113,12 @@ function labelStyle(
|
|
|
109
113
|
// so reasoning reads like the tool calls around it. The live spinner holds
|
|
110
114
|
// the glyph slot and settles into `*` in place: the rail and the label text
|
|
111
115
|
// keep their columns, and only the glyph, the words, and the tint change.
|
|
112
|
-
const THOUGHT_RAIL = "│";
|
|
113
116
|
const THOUGHT_GLYPH = "*";
|
|
114
|
-
const SETTLED_THOUGHT = `${
|
|
115
|
-
const ANCHORED_LABEL_RE =
|
|
117
|
+
const SETTLED_THOUGHT = `${COLLAPSED_RAIL}${THOUGHT_GLYPH} Thought`;
|
|
118
|
+
const ANCHORED_LABEL_RE = new RegExp(
|
|
119
|
+
String.raw`^${COLLAPSED_RAIL}(\S) (.*)$`,
|
|
120
|
+
"su",
|
|
121
|
+
);
|
|
116
122
|
|
|
117
123
|
function isSettledThoughtLabel(label: string): boolean {
|
|
118
124
|
return label.startsWith(SETTLED_THOUGHT);
|
|
@@ -128,8 +134,8 @@ function styledAnchoredLabel(
|
|
|
128
134
|
const match = ANCHORED_LABEL_RE.exec(raw);
|
|
129
135
|
if (!match) return `${style.prefix}${raw}${style.suffix}`;
|
|
130
136
|
const rail = settledMutedStyle(theme) ?? style;
|
|
131
|
-
const railText =
|
|
132
|
-
const body =
|
|
137
|
+
const railText = withFaintCollapsedRail((marker) => marker);
|
|
138
|
+
const body = `\x1b[1m${match[1]}\x1b[22m ${match[2]}${style.suffix}`;
|
|
133
139
|
return rail.prefix === style.prefix
|
|
134
140
|
? `${style.prefix}${railText}${body}`
|
|
135
141
|
: `${rail.prefix}${railText}${rail.suffix}${style.prefix}${body}`;
|
|
@@ -424,7 +430,7 @@ function formatThoughtDuration(startedAt: number, finishedAt: number): string {
|
|
|
424
430
|
}
|
|
425
431
|
|
|
426
432
|
function liveThinkingLabel(startedAt: number, now: number): string {
|
|
427
|
-
return `${
|
|
433
|
+
return `${COLLAPSED_RAIL}${thinkingSpinner(startedAt, now)} Thinking…`;
|
|
428
434
|
}
|
|
429
435
|
|
|
430
436
|
function thinkingSpinner(startedAt: number, now: number): string {
|