@pi-kaush/pi-tool-call-markers 0.3.16 → 0.3.17
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 +7 -0
- package/README.md +19 -0
- package/package.json +1 -1
- package/src/index.ts +45 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Include bash command previews in collapsed codemode rows, with the total
|
|
6
|
+
bash call count before the first command preview. Every nested tool shows
|
|
7
|
+
its count, including ×1, on its first preview. Distinct commands
|
|
8
|
+
no longer disappear behind a generic bash count. Decode truncated argument
|
|
9
|
+
previews safely, keep live updates and width limits, and preserve native
|
|
10
|
+
expansion.
|
|
11
|
+
|
|
5
12
|
- Draw subagent rows with the same faint rail as every other collapsed
|
|
6
13
|
tool call. They used a bold `│` of their own, and failed subagent plans
|
|
7
14
|
painted the rail in the error color.
|
package/README.md
CHANGED
|
@@ -31,6 +31,25 @@ Collapsed tool rows use semantic theme colors with no gear, background fill, box
|
|
|
31
31
|
- **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
32
|
- **Native expansion remains authoritative.** `Ctrl+O` restores Pi's full individual tool rendering, including complete results, custom renderers, and error details.
|
|
33
33
|
|
|
34
|
+
## Codemode commands
|
|
35
|
+
|
|
36
|
+
Collapsed codemode rows include bash command previews instead of only tool names:
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
│ ¢ bash ×1 npm test
|
|
40
|
+
│ ¢ bash ×2 git status --short, bash npm test
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The first preview for each tool shows its total call count, including ×1.
|
|
44
|
+
Distinct command previews remain separate. Identical previews appear only once.
|
|
45
|
+
Long commands truncate to the row width. Pi can also truncate the stored
|
|
46
|
+
argument preview; those commands keep an ellipsis. Calls without a usable
|
|
47
|
+
command preview keep their tool name. Other nested tools show their
|
|
48
|
+
name counts, including ×1, and script options follow the call list.
|
|
49
|
+
|
|
50
|
+
Previews update while scripts run. Click a row or use Ctrl+O to restore Pi's
|
|
51
|
+
native script, nested call status, and result details.
|
|
52
|
+
|
|
34
53
|
## Subagent plans
|
|
35
54
|
|
|
36
55
|
A recognized `subagent` call renders as an unboxed plan in the shared tool aesthetic, using the same `│` tool-call rail:
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -866,28 +866,66 @@ function codemodeOptionsLabel(row: ToolExecutionRow): string | undefined {
|
|
|
866
866
|
return params.length > 0 ? params.join(", ") : undefined;
|
|
867
867
|
}
|
|
868
868
|
|
|
869
|
-
//
|
|
870
|
-
//
|
|
871
|
-
//
|
|
872
|
-
|
|
869
|
+
// Pi stores a JSON argument preview, capped at 200 characters. Long bash
|
|
870
|
+
// commands can therefore end inside a JSON string. Decode only complete
|
|
871
|
+
// escape sequences from a leading command field; never evaluate script text.
|
|
872
|
+
function codemodeBashCommand(args: unknown): string | undefined {
|
|
873
|
+
if (typeof args !== "string") return undefined;
|
|
874
|
+
try {
|
|
875
|
+
const parsed: unknown = JSON.parse(args);
|
|
876
|
+
return isRecord(parsed) && typeof parsed.command === "string"
|
|
877
|
+
? parsed.command
|
|
878
|
+
: undefined;
|
|
879
|
+
} catch {
|
|
880
|
+
if (!args.endsWith("...")) return undefined;
|
|
881
|
+
const prefix = args.slice(0, -3);
|
|
882
|
+
const match =
|
|
883
|
+
/^\{\s*"command"\s*:\s*"((?:[^"\\]|\\(?:["\\/bfnrt]|u[\da-fA-F]{4}))*)/.exec(
|
|
884
|
+
prefix,
|
|
885
|
+
);
|
|
886
|
+
if (!match) return undefined;
|
|
887
|
+
try {
|
|
888
|
+
const command: unknown = JSON.parse('"' + match[1] + '"');
|
|
889
|
+
const suffix = prefix[match[0].length] === '"' ? "" : "…";
|
|
890
|
+
return typeof command === "string" ? command + suffix : undefined;
|
|
891
|
+
} catch {
|
|
892
|
+
return undefined;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// Show each tool's total count, including ×1, on its first preview.
|
|
898
|
+
// Distinct previews remain visible; repeated previews take no extra space.
|
|
873
899
|
function codemodeCallsSummary(row: ToolExecutionRow): string | undefined {
|
|
874
900
|
const calls = row.result?.details?.calls;
|
|
875
901
|
if (!Array.isArray(calls) || calls.length === 0) return undefined;
|
|
876
902
|
const counts = new Map<string, number>();
|
|
903
|
+
const labels = new Map<string, { name: string; preview: string }>();
|
|
877
904
|
for (const call of calls) {
|
|
878
905
|
if (!isRecord(call)) continue;
|
|
879
906
|
const name = call.name;
|
|
880
907
|
if (typeof name !== "string" || name.length === 0) continue;
|
|
908
|
+
const command =
|
|
909
|
+
name === "bash" ? codemodeBashCommand(call.args) : undefined;
|
|
910
|
+
const preview = command === undefined ? "" : sanitizeInline(command).trim();
|
|
911
|
+
const label = preview ? name + " " + preview : name;
|
|
881
912
|
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
913
|
+
labels.set(label, { name, preview });
|
|
882
914
|
}
|
|
883
915
|
if (counts.size === 0) return undefined;
|
|
884
|
-
|
|
885
|
-
|
|
916
|
+
const shown = new Set<string>();
|
|
917
|
+
return [...labels.values()]
|
|
918
|
+
.map(({ name, preview }) => {
|
|
919
|
+
const count = counts.get(name) ?? 1;
|
|
920
|
+
const heading = !shown.has(name) ? name + " ×" + count : name;
|
|
921
|
+
shown.add(name);
|
|
922
|
+
return preview ? heading + " " + preview : heading;
|
|
923
|
+
})
|
|
886
924
|
.join(", ");
|
|
887
925
|
}
|
|
888
926
|
|
|
889
927
|
// Codemode's collapsed label pairs what the script did with how it ran:
|
|
890
|
-
// `read ×2, fffind · "max_output_tokens": 2500`. Without either part the row
|
|
928
|
+
// `read ×2, fffind ×1 · "max_output_tokens": 2500`. Without either part the row
|
|
891
929
|
// falls through to the ordinary summary paths.
|
|
892
930
|
function codemodeCallLabel(row: ToolExecutionRow): string | undefined {
|
|
893
931
|
if (row.toolName !== "codemode") return undefined;
|