@pi-kaush/pi-tool-call-markers 0.3.20 → 0.3.22
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 +23 -2
- package/package.json +1 -1
- package/src/index.ts +61 -8
package/README.md
CHANGED
|
@@ -15,13 +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
|
+
│ § writing-prose/SKILL.md 42 lines
|
|
19
|
+
│ ≡ .pi/prompts/review.md 18 lines
|
|
18
20
|
│ ● src/a.ts 42 lines
|
|
19
|
-
│ ● src/b.ts 18 lines
|
|
20
21
|
│ $ npm test → done
|
|
21
22
|
```
|
|
22
23
|
|
|
23
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.
|
|
24
|
-
- **`│` tool-call rail.**
|
|
25
|
+
- **`│` tool-call rail.** Collapsed calls use a bold glyph instead of repeating the tool name. 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.
|
|
25
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.
|
|
26
27
|
- **Width-safe outcome tails.** Long summaries truncate before useful tails such as `→ done`, `→ 42 lines`, `→ +2/-1`, or a `bash` duration.
|
|
27
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.
|
|
@@ -31,6 +32,26 @@ Collapsed tool rows use semantic theme colors with no gear, background fill, box
|
|
|
31
32
|
- **User-run `!` bash blocks.** Execution display is owned here: user-typed commands trade Pi's green rules for the railed prompt shell (dark surface, status-colored rail) that submitted prompts use.
|
|
32
33
|
- **Native expansion remains authoritative.** `Ctrl+O` restores Pi's full individual tool rendering, including complete results, custom renderers, and error details.
|
|
33
34
|
|
|
35
|
+
## Tool-call glyphs
|
|
36
|
+
|
|
37
|
+
| Tool call | Glyph |
|
|
38
|
+
| --------------------------------------------------- | ----- |
|
|
39
|
+
| `read` a local `SKILL.md` | `§` |
|
|
40
|
+
| `read` a registered Pi prompt template | `≡` |
|
|
41
|
+
| `read` any other resource | `●` |
|
|
42
|
+
| `bash` | `$` |
|
|
43
|
+
| `write` | `+` |
|
|
44
|
+
| `edit` | `±` |
|
|
45
|
+
| `grep`, `ffgrep`, `find`, `fffind` | `○` |
|
|
46
|
+
| `ls` | `≡` |
|
|
47
|
+
| `web_search`, `fetch_content`, `get_search_content` | `↗` |
|
|
48
|
+
| `codemode` | `¢` |
|
|
49
|
+
| Unmapped tools | `*` |
|
|
50
|
+
|
|
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
|
+
|
|
53
|
+
Subagent calls use the `│` rail without a glyph. Recognized question calls use the submitted-prompt shell instead of a tool-call glyph.
|
|
54
|
+
|
|
34
55
|
## Codemode commands
|
|
35
56
|
|
|
36
57
|
Collapsed codemode rows include bash command previews instead of only tool names:
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { resolve } from "node:path";
|
|
1
3
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
4
|
import {
|
|
3
5
|
AssistantMessageComponent,
|
|
@@ -98,6 +100,8 @@ type PresentationPatchState = {
|
|
|
98
100
|
// owner; a later install re-enables it.
|
|
99
101
|
disabled?: boolean;
|
|
100
102
|
theme?: ThemeLike;
|
|
103
|
+
cwd: string;
|
|
104
|
+
promptPaths: ReadonlySet<string>;
|
|
101
105
|
collapseParallel: boolean;
|
|
102
106
|
expandedTools: ReadonlySet<string>;
|
|
103
107
|
groupCache: WeakMap<ToolExecutionRow, GroupRenderCache>;
|
|
@@ -964,6 +968,28 @@ function collapsedAnchor(
|
|
|
964
968
|
: `${rail}${fgCollapsed(theme, color, glyph, true)} `;
|
|
965
969
|
}
|
|
966
970
|
|
|
971
|
+
function resourcePath(path: string, cwd: string): string {
|
|
972
|
+
const localPath = path.startsWith("@") ? path.slice(1) : path;
|
|
973
|
+
return resolve(
|
|
974
|
+
cwd,
|
|
975
|
+
localPath.startsWith("~/")
|
|
976
|
+
? `${homedir()}/${localPath.slice(2)}`
|
|
977
|
+
: localPath,
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function readGlyph(
|
|
982
|
+
row: ToolExecutionRow,
|
|
983
|
+
state: PresentationPatchState,
|
|
984
|
+
): string {
|
|
985
|
+
const path = isRecord(row.args) ? row.args.path : undefined;
|
|
986
|
+
if (typeof path !== "string") return "●";
|
|
987
|
+
const localPath = path.startsWith("@") ? path.slice(1) : path;
|
|
988
|
+
if (/^[a-z][a-z\d+.-]*:\/\//i.test(localPath)) return "●";
|
|
989
|
+
if (/(?:^|[/\\])SKILL\.md$/.test(localPath)) return "§";
|
|
990
|
+
return state.promptPaths.has(resourcePath(path, state.cwd)) ? "≡" : "●";
|
|
991
|
+
}
|
|
992
|
+
|
|
967
993
|
// The collapsed-row seam lives here and nowhere else: which anchor a row
|
|
968
994
|
// takes, and the call text that follows it. Callers append the outcome tail.
|
|
969
995
|
function collapsedSeam(
|
|
@@ -971,6 +997,7 @@ function collapsedSeam(
|
|
|
971
997
|
width: number,
|
|
972
998
|
theme: ThemeLike,
|
|
973
999
|
color: string,
|
|
1000
|
+
state: PresentationPatchState,
|
|
974
1001
|
): { anchor: string; content: string } {
|
|
975
1002
|
const isBash = row.toolName === "bash";
|
|
976
1003
|
const isSubagent = row.toolName === "subagent";
|
|
@@ -978,7 +1005,9 @@ function collapsedSeam(
|
|
|
978
1005
|
? undefined
|
|
979
1006
|
: isBash
|
|
980
1007
|
? "$"
|
|
981
|
-
:
|
|
1008
|
+
: row.toolName === "read"
|
|
1009
|
+
? readGlyph(row, state)
|
|
1010
|
+
: (TOOL_CALL_GLYPHS.get(row.toolName ?? "") ?? "*");
|
|
982
1011
|
const anchor = collapsedAnchor(theme, color, glyph);
|
|
983
1012
|
const budget = Math.max(1, width - visibleWidth(anchor));
|
|
984
1013
|
// Self-rendered rows build their own `tool {args}` label — Pi's call title
|
|
@@ -1046,11 +1075,12 @@ function collapsedRowLine(
|
|
|
1046
1075
|
row: ToolExecutionRow,
|
|
1047
1076
|
width: number,
|
|
1048
1077
|
theme: ThemeLike,
|
|
1078
|
+
state: PresentationPatchState,
|
|
1049
1079
|
): string {
|
|
1050
1080
|
// Failed rows render entirely in error so the row reads as the one that
|
|
1051
1081
|
// failed, not just its outcome tail. Only the row's anchor stays bold.
|
|
1052
1082
|
const color = rowHasFailed(row) ? "error" : "muted";
|
|
1053
|
-
const seam = collapsedSeam(row, width, theme, color);
|
|
1083
|
+
const seam = collapsedSeam(row, width, theme, color, state);
|
|
1054
1084
|
const budget = Math.max(1, width - visibleWidth(seam.anchor));
|
|
1055
1085
|
const outcome = collapsedOutcome(row, budget, theme);
|
|
1056
1086
|
// The truncation suffix inherits the row tone; pi-tui's truncation resets
|
|
@@ -1365,6 +1395,7 @@ function renderCollapsedToolRow(
|
|
|
1365
1395
|
row: ToolExecutionRow,
|
|
1366
1396
|
width: number,
|
|
1367
1397
|
theme: ThemeLike,
|
|
1398
|
+
state: PresentationPatchState,
|
|
1368
1399
|
): string[] {
|
|
1369
1400
|
// An asked question is a user-input moment, not an execution row: it takes
|
|
1370
1401
|
// the submitted-prompt shell, which carries its own inset.
|
|
@@ -1375,7 +1406,9 @@ function renderCollapsedToolRow(
|
|
|
1375
1406
|
row.toolName === "subagent"
|
|
1376
1407
|
? renderSubagentPlan(row, layout.contentWidth, theme)
|
|
1377
1408
|
: undefined;
|
|
1378
|
-
const body = plan ?? [
|
|
1409
|
+
const body = plan ?? [
|
|
1410
|
+
collapsedRowLine(row, layout.contentWidth, theme, state),
|
|
1411
|
+
];
|
|
1379
1412
|
body.push(...imageResultLines(row, layout.contentWidth, theme));
|
|
1380
1413
|
return ["", ...insetLines(body, width)];
|
|
1381
1414
|
}
|
|
@@ -1384,10 +1417,11 @@ function renderGroupedCallLines(
|
|
|
1384
1417
|
rows: ToolExecutionRow[],
|
|
1385
1418
|
width: number,
|
|
1386
1419
|
theme: ThemeLike,
|
|
1420
|
+
state: PresentationPatchState,
|
|
1387
1421
|
): Array<{ row: ToolExecutionRow; lines: string[] }> {
|
|
1388
1422
|
const segments: Array<{ row: ToolExecutionRow; lines: string[] }> = [];
|
|
1389
1423
|
for (const row of rows) {
|
|
1390
|
-
segments.push({ row, lines: [collapsedRowLine(row, width, theme)] });
|
|
1424
|
+
segments.push({ row, lines: [collapsedRowLine(row, width, theme, state)] });
|
|
1391
1425
|
}
|
|
1392
1426
|
return segments;
|
|
1393
1427
|
}
|
|
@@ -1448,7 +1482,12 @@ function renderGroupedToolRows(
|
|
|
1448
1482
|
}
|
|
1449
1483
|
|
|
1450
1484
|
const layout = insetLayout(width);
|
|
1451
|
-
const segments = renderGroupedCallLines(
|
|
1485
|
+
const segments = renderGroupedCallLines(
|
|
1486
|
+
rows,
|
|
1487
|
+
layout.contentWidth,
|
|
1488
|
+
theme,
|
|
1489
|
+
state,
|
|
1490
|
+
);
|
|
1452
1491
|
const lines = [
|
|
1453
1492
|
"",
|
|
1454
1493
|
...insetLines(
|
|
@@ -1683,6 +1722,8 @@ function installPresentationPatch(): PresentationPatchState | undefined {
|
|
|
1683
1722
|
|
|
1684
1723
|
const state: PresentationPatchState = {
|
|
1685
1724
|
owners: 1,
|
|
1725
|
+
cwd: process.cwd(),
|
|
1726
|
+
promptPaths: new Set(),
|
|
1686
1727
|
collapseParallel: envEnabled(COLLAPSE_PARALLEL_ENV, true),
|
|
1687
1728
|
expandedTools: envToolNames(EXPANDED_TOOLS_ENV),
|
|
1688
1729
|
groupCache: new WeakMap(),
|
|
@@ -1796,7 +1837,7 @@ function installPresentationPatch(): PresentationPatchState | undefined {
|
|
|
1796
1837
|
return lines;
|
|
1797
1838
|
}
|
|
1798
1839
|
try {
|
|
1799
|
-
const collapsed = renderCollapsedToolRow(this, width, theme);
|
|
1840
|
+
const collapsed = renderCollapsedToolRow(this, width, theme, state);
|
|
1800
1841
|
state.collapsedCache.set(this, {
|
|
1801
1842
|
lines: collapsed,
|
|
1802
1843
|
signature,
|
|
@@ -1817,7 +1858,7 @@ function installPresentationPatch(): PresentationPatchState | undefined {
|
|
|
1817
1858
|
return lines;
|
|
1818
1859
|
}
|
|
1819
1860
|
try {
|
|
1820
|
-
return renderCollapsedToolRow(this, width, theme);
|
|
1861
|
+
return renderCollapsedToolRow(this, width, theme, state);
|
|
1821
1862
|
} catch {
|
|
1822
1863
|
return lines;
|
|
1823
1864
|
}
|
|
@@ -1896,7 +1937,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
1896
1937
|
let released = false;
|
|
1897
1938
|
|
|
1898
1939
|
pi.on("session_start", (_event, ctx) => {
|
|
1899
|
-
if (patch)
|
|
1940
|
+
if (patch) {
|
|
1941
|
+
patch.theme = ctx.ui.theme;
|
|
1942
|
+
patch.cwd = ctx.cwd ?? process.cwd();
|
|
1943
|
+
patch.promptPaths = new Set(
|
|
1944
|
+
(pi.getCommands?.() ?? [])
|
|
1945
|
+
.filter((command) => command.source === "prompt")
|
|
1946
|
+
.map((command) => command.sourceInfo?.path)
|
|
1947
|
+
.filter((path): path is string => typeof path === "string")
|
|
1948
|
+
.map((path) => resourcePath(path, patch.cwd)),
|
|
1949
|
+
);
|
|
1950
|
+
patch.groupCache = new WeakMap();
|
|
1951
|
+
patch.collapsedCache = new WeakMap();
|
|
1952
|
+
}
|
|
1900
1953
|
if (bashPatch) bashPatch.theme = ctx.ui.theme;
|
|
1901
1954
|
ctx.ui.setToolsExpanded(false);
|
|
1902
1955
|
});
|