@heyhuynhgiabuu/pi-pretty 0.6.30 → 0.7.0

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +21 -0
  3. package/dist/claude-style.d.ts +45 -0
  4. package/dist/claude-style.d.ts.map +1 -0
  5. package/dist/claude-style.js +582 -0
  6. package/dist/claude-style.js.map +1 -0
  7. package/dist/config.d.ts +2 -0
  8. package/dist/config.d.ts.map +1 -1
  9. package/dist/config.js +2 -0
  10. package/dist/config.js.map +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +22 -12
  13. package/dist/index.js.map +1 -1
  14. package/dist/prompt-editor.d.ts +4 -1
  15. package/dist/prompt-editor.d.ts.map +1 -1
  16. package/dist/prompt-editor.js +27 -12
  17. package/dist/prompt-editor.js.map +1 -1
  18. package/dist/render.d.ts +10 -7
  19. package/dist/render.d.ts.map +1 -1
  20. package/dist/render.js +41 -25
  21. package/dist/render.js.map +1 -1
  22. package/dist/tools/bash.d.ts.map +1 -1
  23. package/dist/tools/bash.js +17 -13
  24. package/dist/tools/bash.js.map +1 -1
  25. package/dist/tools/find.d.ts.map +1 -1
  26. package/dist/tools/find.js +15 -17
  27. package/dist/tools/find.js.map +1 -1
  28. package/dist/tools/grep.d.ts.map +1 -1
  29. package/dist/tools/grep.js +10 -8
  30. package/dist/tools/grep.js.map +1 -1
  31. package/dist/tools/ls.d.ts.map +1 -1
  32. package/dist/tools/ls.js +11 -9
  33. package/dist/tools/ls.js.map +1 -1
  34. package/dist/tools/read.d.ts.map +1 -1
  35. package/dist/tools/read.js +25 -21
  36. package/dist/tools/read.js.map +1 -1
  37. package/dist/types.d.ts +9 -0
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/working-indicator.d.ts +2 -0
  40. package/dist/working-indicator.d.ts.map +1 -1
  41. package/dist/working-indicator.js +20 -8
  42. package/dist/working-indicator.js.map +1 -1
  43. package/package.json +5 -5
  44. package/src/claude-style.ts +650 -0
  45. package/src/config.ts +3 -0
  46. package/src/index.ts +35 -15
  47. package/src/prompt-editor.ts +26 -11
  48. package/src/render.ts +54 -24
  49. package/src/tools/bash.ts +28 -23
  50. package/src/tools/find.ts +20 -16
  51. package/src/tools/grep.ts +10 -6
  52. package/src/tools/ls.ts +17 -8
  53. package/src/tools/read.ts +29 -30
  54. package/src/types.ts +9 -0
  55. package/src/working-indicator.ts +20 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.0] - 2026-10-10
4
+
5
+ ### Added
6
+
7
+ - Opt-in `toolStyle: "claudecode"` (default `default`, no change for existing users): collapsed tools render as `✓ Name (args)` with an `└` result row (line counts, duration, bash `timeout`, `+N -N` for edits), a braille spinner while running, `·` while pending, and `✗` on failure.
8
+ - Fold consecutive tool calls into `Done (…)` / `Running (…)` groups with a `├─`/`└─` tree. Clicking a tool in a group expands it; Ctrl+O expands everything. Tools the style does not cover break a group instead of being flattened into it.
9
+ - Style `write`, `edit`, `apply_patch` (pi-diff), `codemode` (Pi built-in), and `recall` (pikit) without re-registering them, by deciding their renderers per component by tool name. Their full output remains available when expanded.
10
+ - `(ctrl+o to expand)` / `(ctrl+o to collapse)` hints on folded groups and expanded calls, and `thought 3s (ctrl+t to expand)` for hidden thinking, using the user's own key bindings.
11
+ - In this style: flush-left `thinking` / `thought 3s` labels, no `❯` prefix on user messages, and an input box with plain horizontal rules and a flush-left `❯` instead of the rounded border.
12
+
13
+ ### Maintenance
14
+
15
+ - Add `vitest.config.ts` so tests never read the developer's real `~/.pi/agent/pi-pretty.json`.
16
+ - Add regression coverage for rows, grouping, click-to-expand, delegated renderers, and the unboxed prompt editor.
17
+
18
+ ## [0.6.31] - 2026-10-08
19
+
20
+ ### Added
21
+
22
+ - Honor Pi's `outputPad` setting in self-rendered `read`, `bash`, `ls`, `find`, and `grep` output, with one-space fallback on older hosts. Keep directory/file nesting independent of outer padding.
23
+ - Prefer Pi's recorded `durationMs` for execution-time displays, including zero-duration and failed bash results, with fallback to existing elapsed metadata on older hosts.
24
+
25
+ ### Fixed
26
+
27
+ - Preserve the SDK read tool's `outputSchema`, retaining structured results when called through codemode.
28
+ - Keep read highlighting and bash render caches consistent when padding or execution timing changes.
29
+ - Resolve the host's jiti dependency without assuming a nested `node_modules` layout in the extension entrypoint test.
30
+
31
+ ### Maintenance
32
+
33
+ - Align the four Pi development SDK dependencies and both lockfiles with Pi 1.1.0. Runtime peer ranges remain unchanged.
34
+ - Add regression coverage for padding, nesting, timing fallbacks, and stale asynchronous highlighting.
35
+
3
36
  ## [0.6.30] - 2026-09-30
4
37
 
5
38
  ### Fixed
package/README.md CHANGED
@@ -175,6 +175,7 @@ Place a JSON file alongside Pi's `settings.json` to customize pi-pretty. Every o
175
175
  | `cacheLimit` | positive int | `PRETTY_CACHE_LIMIT` | `128` |
176
176
  | `fff.enableHomeScanning` | boolean | `PRETTY_FFF_HOME_SCAN` (`1`/`0`) | `false` |
177
177
  | `fff.enableRootScanning` | boolean | `PRETTY_FFF_ROOT_SCAN` (`1`/`0`) | `false` |
178
+ | `toolStyle` | `default` \| `claudecode` | — | `default` |
178
179
  | `workingIndicator.enabled` | boolean | `PRETTY_WORKING_INDICATOR` (`on`/`off`) | `true` |
179
180
  | `workingIndicator.text` | string or string[] (phrases rotated per sweep; env accepts comma-separated) | `PRETTY_WORKING_INDICATOR_TEXT` | `["Working…"]` |
180
181
  | `workingIndicator.mode` | `shimmer` \| `kitt` \| `static` | `PRETTY_WORKING_INDICATOR_MODE` | `shimmer` |
@@ -235,6 +236,26 @@ older rows are never mislabeled. The 30fps ticker runs only while the current me
235
236
  is thinking, bounding the cost of `setHiddenThinkingLabel(label)` rebuilding chat children. Inherits
236
237
  `mode`, `bold`, and the palette/accent from `workingIndicator`.
237
238
 
239
+ ### Claude Code tool style
240
+
241
+ Set `"toolStyle": "claudecode"` for a Claude Code-like transcript (restart pi to apply):
242
+
243
+ ```
244
+ ✓ Done (3 tool calls · 1 thought) (ctrl+o to expand)
245
+ ├─ • Read (src/a.ts)
246
+ │ └ 42 lines · ◷ 0.02s
247
+ ├─ • Edit (src/a.ts)
248
+ │ └ +3 -1 · ◷ 0.06s
249
+ └─ • Bash (npm test)
250
+ └ 12 lines · ◷ 3.1s · timeout 300s
251
+ ```
252
+
253
+ - Collapsed tool calls are one `✓ Name (args)` row plus an `└` result row; a spinner shows while running, `·` while waiting, `✗` on failure. Ctrl+O (or a click) expands to the full pretty output.
254
+ - Two or more consecutive tool calls fold into one `Done (…)` / `Running (…)` group. Click a tool in the group to expand it.
255
+ - Covers `read`, `bash`, `grep`, `find`, `ls`, and — through the host's renderer lookup, without re-registering them — `write`, `edit`, `apply_patch` (pi-diff), `codemode`, and `recall`. `+N` is shown in the success color and `-N` in the error color. Tools it does not style keep their own rendering and break a group.
256
+ - Hidden thinking reads `thought 3s (ctrl+t to expand)`, user messages lose the `❯` prefix, and the input box drops its rounded border for plain rules with a flush-left `❯`.
257
+ - `toolStyle` only changes presentation. It patches Pi's `ToolExecutionComponent` and chat `Container` render lookups, which are not public API; if Pi reshapes them the styling degrades to Pi's own rendering.
258
+
238
259
  ### Environment variables
239
260
 
240
261
  Optional environment variables:
@@ -0,0 +1,45 @@
1
+ /**
2
+ * pi-pretty: opt-in "claudecode" tool style (config `toolStyle: "claudecode"`).
3
+ *
4
+ * ✓ Read (src/a.ts) collapsed call row: status icon (spinner while running), bold name
5
+ * └ 42 lines · ◷ 0.02s collapsed result row hanging from a connector
6
+ * ✓ Done (3 tool calls) consecutive tool calls fold into one group row
7
+ * ├─ • Bash(ls)
8
+ * └─ • Read(a.ts)
9
+ *
10
+ * Collapsed rows replace the pretty output; Ctrl+O (expanded) keeps pi-pretty's
11
+ * full rendering. Grouping is a pure render-time projection of the chat children.
12
+ * Modeled on the look of sting8k/pi-droid-styling's `claudecode` preset.
13
+ */
14
+ type AnyFn = (...args: any[]) => any;
15
+ export declare function setClaudeStyleTheme(theme: unknown): void;
16
+ /**
17
+ * Wrap a tool definition so collapsed rows use the Claude Code look. Expanded
18
+ * calls keep the call row but defer the result body to the original renderer.
19
+ */
20
+ export declare function withClaudeToolStyle<T extends {
21
+ name: string;
22
+ label?: string;
23
+ renderCall?: AnyFn;
24
+ renderResult?: AnyFn;
25
+ }>(def: T): T;
26
+ /**
27
+ * Give write/edit/apply_patch the Claude Code rows without owning their registration (pi-diff or Pi's
28
+ * builtins keep their schema, execute and diff renderer). Rendering is decided per component,
29
+ * so the host's lookups are patched by tool name, as pi-droid-styling does. Collapsed: call
30
+ * and `+N -N` rows; expanded: the provider's own result renderer. Pass `false` to restore.
31
+ */
32
+ export declare function installClaudeExternalToolRenderers(toolExecutionComponent: unknown, enabled?: boolean): void;
33
+ /** Proxy `pi` so tools registered through it get the Claude Code rows. */
34
+ export declare function withClaudeToolStyleApi<P extends {
35
+ registerTool: AnyFn;
36
+ }>(pi: P): P;
37
+ /**
38
+ * Fold consecutive tool calls into `✓ Done (...)` groups by wrapping pi-tui's base
39
+ * `Container.render`. Pi nests its chat container (no stable index to look it up by),
40
+ * but only that container holds tool components as direct children, so the wrapper
41
+ * stays inert for every other container. Pass `false` to restore the original render.
42
+ */
43
+ export declare function installClaudeChatGrouping(enabled?: boolean): void;
44
+ export {};
45
+ //# sourceMappingURL=claude-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-style.d.ts","sourceRoot":"","sources":["../src/claude-style.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAgBrC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAExD;AAoWD;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAAC,YAAY,CAAC,EAAE,KAAK,CAAA;CAAE,EACnF,GAAG,EAAE,CAAC,GAAG,CAAC,CAGX;AAcD;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,sBAAsB,EAAE,OAAO,EAAE,OAAO,UAAO,GAAG,IAAI,CAqDxG;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,CAAC,SAAS;IAAE,YAAY,EAAE,KAAK,CAAA;CAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAQlF;AA6ID;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,UAAO,GAAG,IAAI,CAgB9D"}