@pi-kaush/pi-tool-call-markers 0.3.13 → 0.3.14
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/CHANGELOG.md +6 -0
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/muted.ts +1 -1
- package/src/thinking-block-merger.ts +23 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Anchor the settled thinking label like a collapsed tool call:
|
|
6
|
+
`│ * Thought · 2.5s` instead of `+ Thought · 2.5s`. The faint rail and
|
|
7
|
+
bold glyph match the tool rows around it, so a turn that alternates
|
|
8
|
+
thinking and calls reads as one column. The live `⠋ Thinking…` spinner is
|
|
9
|
+
unchanged.
|
|
10
|
+
|
|
5
11
|
- Paint collapsed rows with the theme's `dim` token instead of
|
|
6
12
|
`syntaxComment`. Pi's generated `system` theme solves `syntaxComment` to
|
|
7
13
|
the same contrast as `muted` and `toolOutput`, so collapsed tool calls
|
package/README.md
CHANGED
|
@@ -98,10 +98,10 @@ When Pi exposes its per-row hidden-thinking and streaming fields, hidden reasoni
|
|
|
98
98
|
|
|
99
99
|
```text
|
|
100
100
|
⠋ Thinking… → ⠙ Thinking… → …
|
|
101
|
-
|
|
101
|
+
│ * Thought · 2.5s
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
The live label samples Pi's native braille spinner sequence from the content updates Pi already renders; it does not add a timer. 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
|
|
104
|
+
The live label samples Pi's native braille spinner sequence from the content updates Pi already renders; it does not add a timer. 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`. The settled label borrows the collapsed tool-row anchor — a faint `│` rail and a bold `*` — so finished reasoning reads like the tool calls around it. There is no interval, timeout, render request, model call, or network work.
|
|
105
105
|
|
|
106
106
|
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.
|
|
107
107
|
|
|
@@ -135,7 +135,7 @@ Names are comma-separated and matched exactly. Listed rows never join a group, a
|
|
|
135
135
|
|
|
136
136
|
### Collapsed-row colors
|
|
137
137
|
|
|
138
|
-
Collapsed rows (tool calls,
|
|
138
|
+
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.
|
|
139
139
|
|
|
140
140
|
A theme can override each collapsed kind independently with optional color tokens:
|
|
141
141
|
|
package/package.json
CHANGED
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 "│ * Thought" 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,7 +10,7 @@ const SPINNER_INTERVAL_MS = 80;
|
|
|
10
10
|
// Visual treatment for the collapsed thinking label. The live "Thinking…"
|
|
11
11
|
// spinner tints with the session's active thinking-level color
|
|
12
12
|
// (thinkingOff…thinkingMax), so progress reads as activity; the settled
|
|
13
|
-
// "
|
|
13
|
+
// "│ * Thought" row drops to the muted token collapsed tool calls use, so
|
|
14
14
|
// finished reasoning stops advertising the level. "inherit" keeps Pi's
|
|
15
15
|
// native styling (italic + thinkingText) for both states, and "mdheading"
|
|
16
16
|
// rides the theme's mdHeading token for both. The env var overrides the
|
|
@@ -105,21 +105,34 @@ function labelStyle(
|
|
|
105
105
|
return styledWith(token, theme);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
// The settled label
|
|
109
|
-
// the
|
|
108
|
+
// The settled label wears the collapsed tool-row anchor — faint rail, bold
|
|
109
|
+
// glyph — so finished reasoning reads like the tool calls around it. Every
|
|
110
|
+
// other label is the live spinner.
|
|
111
|
+
const THOUGHT_RAIL = "│";
|
|
112
|
+
const THOUGHT_GLYPH = "*";
|
|
113
|
+
const THOUGHT_ANCHOR = `${THOUGHT_RAIL} ${THOUGHT_GLYPH}`;
|
|
114
|
+
const SETTLED_THOUGHT = `${THOUGHT_ANCHOR} Thought`;
|
|
115
|
+
|
|
110
116
|
function isSettledThoughtLabel(label: string): boolean {
|
|
111
|
-
return label.startsWith(
|
|
117
|
+
return label.startsWith(SETTLED_THOUGHT);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function styledSettledThought(raw: string, style: LabelStyle): string {
|
|
121
|
+
const rest = raw.slice(THOUGHT_ANCHOR.length);
|
|
122
|
+
return `${style.prefix}\x1b[2m${THOUGHT_RAIL}\x1b[22m \x1b[1m${THOUGHT_GLYPH}\x1b[22m${rest}${style.suffix}`;
|
|
112
123
|
}
|
|
113
124
|
|
|
114
125
|
export function visibleThoughtLabel(label: string): string {
|
|
115
126
|
if (!stylesThinkingLabels()) return label;
|
|
116
127
|
const raw = label.replace(/\x1b\[[0-9;]*m/g, "");
|
|
117
128
|
const theme = themeProvider?.();
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
: undefined;
|
|
129
|
+
const settled = isSettledThoughtLabel(raw);
|
|
130
|
+
const style = theme ? labelStyle(settled, theme) : undefined;
|
|
121
131
|
// A theme that cannot resolve a color still drops Pi's italics.
|
|
122
|
-
|
|
132
|
+
if (!style) return `${ITALIC_OFF}${raw}`;
|
|
133
|
+
return settled
|
|
134
|
+
? styledSettledThought(raw, style)
|
|
135
|
+
: `${style.prefix}${raw}${style.suffix}`;
|
|
123
136
|
}
|
|
124
137
|
|
|
125
138
|
type AssistantMessageLike = {
|
|
@@ -351,9 +364,9 @@ function lifecycleLabel(
|
|
|
351
364
|
|
|
352
365
|
const settled = timings.get(row);
|
|
353
366
|
if (settled?.finishedAt !== undefined) {
|
|
354
|
-
return
|
|
367
|
+
return `${SETTLED_THOUGHT} · ${formatThoughtDuration(settled.startedAt, settled.finishedAt)}`;
|
|
355
368
|
}
|
|
356
|
-
return
|
|
369
|
+
return SETTLED_THOUGHT;
|
|
357
370
|
}
|
|
358
371
|
|
|
359
372
|
function stripThinkingBlocks(
|