@xzzpig/pi-tidy 0.1.0 → 0.1.1

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/FORK-CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
3
3
  Changes specific to `@xzzpig/pi-tidy` in this repository. Upstream history remains in
4
4
  [`CHANGELOG.md`](./CHANGELOG.md).
5
5
 
6
+ ## 0.1.1 — Native thinking and renderer switch fixes
7
+
8
+ - Add fork-only `nativeThinking` (default `true`): leave thinking to Pi and `pi-thinking-collapse`
9
+ instead of drawing pi-tidy's own row; set `false` to restore the upstream thinking row. The
10
+ framed final reply still keeps completed thinking outside its border.
11
+ - Initialize the renderer switches even when tool framing is off. `groupTools: false` reached the
12
+ boundary renderer only through the disabled tool-frame patch, so it kept the default `true` and
13
+ treated a thinking + tool-use assistant as a group carrier: the thinking row vanished when the
14
+ first tool call arrived. The fork now publishes `groupTools`, `icons`, `thinkingColor` and the
15
+ native-thinking switch itself when `frameTools` is off.
16
+ - Guard the group-boundary renderer against nested installs: only the outermost wrapper restyles a
17
+ component and inner wrappers pass through. `pi-group-collapse` installs its render projection
18
+ between pi-tidy's load-time and `before_agent_start` boundary installs; without the guard both
19
+ wrappers remap the same rows and a retry error draws its `error ×2` frame twice.
20
+
6
21
  ## 0.1.0 — Initial fork
7
22
 
8
23
  Forked from Andy8647/pi-tidy v0.9.6.
@@ -24,8 +39,3 @@ Forked from Andy8647/pi-tidy v0.9.6.
24
39
  `~/.pi/extensions/pi-tool-display/config.json`.
25
40
  - Do not restore the tool-frame path-copy chip; it lives on a frame that this fork disables by
26
41
  default.
27
- - Guard the group-boundary renderer against nested installs: only the outermost wrapper restyles a
28
- component and inner wrappers pass through. `pi-group-collapse` installs its render projection
29
- between pi-tidy's load-time and `before_agent_start` boundary installs; without the guard both
30
- wrappers remap the same rows and a retry error draws its `error ×2` frame twice.
31
-
package/README.md CHANGED
@@ -107,6 +107,7 @@ when the corresponding key is omitted:
107
107
  | Setting | Fork default | Notes |
108
108
  |---------|--------------|-------|
109
109
  | `frameTools` | `false` | Fork-only switch. `pi-tool-display` owns tool frames; set `true` only when you want pi-tidy's frames instead. |
110
+ | `nativeThinking` | `true` | Fork-only switch. Leaves thinking to Pi and `pi-thinking-collapse` (which owns the collapsed affordance); set `false` to let pi-tidy draw its own thinking row instead. |
110
111
  | `frameMessages` | `true` | Enabled with user-message `frame` because the upstream uses this switch for both; compaction, branch, skill and custom message boxes are therefore framed too. |
111
112
  | `collapseTurns` | `"off"` | Group/turn folding remains owned by the other installed extensions. |
112
113
  | `groupTools` | `false` | Tool grouping is opt-in. |
package/fork/defaults.ts CHANGED
@@ -7,6 +7,8 @@ import { loadConfig, type TidyConfig } from "../src/config.ts";
7
7
  export interface ForkTidyConfig extends TidyConfig {
8
8
  /** Draw pi-tidy's own tool frames. The fork leaves them to pi-tool-display by default. */
9
9
  frameTools: boolean;
10
+ /** Leave thinking rendering to Pi and pi-thinking-collapse instead of tidy's own row. */
11
+ nativeThinking: boolean;
10
12
  }
11
13
 
12
14
  export type ForkSettingsFile = {
@@ -20,6 +22,11 @@ function asRecord(value: unknown): RecordLike | undefined {
20
22
  return typeof value === "object" && value !== null && !Array.isArray(value) ? (value as RecordLike) : undefined;
21
23
  }
22
24
 
25
+ /** Settings values are decoded once at this I/O boundary. */
26
+ function readBoolean(value: unknown): boolean | undefined {
27
+ return typeof value === "boolean" ? value : undefined;
28
+ }
29
+
23
30
  function readSettings(): ForkSettingsFile | undefined {
24
31
  try {
25
32
  const agentDir = process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent");
@@ -51,7 +58,8 @@ export function applyForkDefaults(
51
58
 
52
59
  return {
53
60
  ...config,
54
- frameTools: typeof userOptions.frameTools === "boolean" ? userOptions.frameTools : false,
61
+ frameTools: readBoolean(userOptions.frameTools) ?? false,
62
+ nativeThinking: readBoolean(userOptions.nativeThinking) ?? true,
55
63
  highlightBash: configuredOr("highlightBash", false),
56
64
  frameMessages: configuredOr("frameMessages", true),
57
65
  userMessageStyle: configuredOr("userMessageStyle", "frame"),
package/fork/install.ts CHANGED
@@ -1,15 +1,25 @@
1
1
  import { InteractiveMode, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import { patchToolBoxFrames, type ToolFrameOptions } from "../src/frame.ts";
3
3
  import { installHoverTracking } from "../src/hover.ts";
4
+ import { setGroupingActive, setIconsEnabled, setNativeThinking, setThinkingColor } from "../src/tools/tool-group-view.ts";
4
5
  import type { ForkTidyConfig } from "./defaults.ts";
5
6
  import { installForkThinkingRows } from "./thinking-row.ts";
6
7
 
7
8
  export interface ForkToolFrameInstallers {
8
9
  patchToolBoxFrames(options: ToolFrameOptions): void;
9
10
  installHoverTracking(): void;
11
+ setGroupingActive?(active: () => boolean): void;
12
+ setIconsEnabled?(icons: () => boolean): void;
13
+ setThinkingColor?(color: () => string): void;
10
14
  }
11
15
 
12
- const upstreamInstallers: ForkToolFrameInstallers = { patchToolBoxFrames, installHoverTracking };
16
+ const upstreamInstallers: ForkToolFrameInstallers = {
17
+ patchToolBoxFrames,
18
+ installHoverTracking,
19
+ setGroupingActive,
20
+ setIconsEnabled,
21
+ setThinkingColor,
22
+ };
13
23
  let errorHookWarningSent = false;
14
24
 
15
25
  function warnIfErrorHookIsUnavailable(pi: ExtensionAPI, config: ForkTidyConfig): void {
@@ -49,10 +59,22 @@ export function installForkToolFrames(
49
59
  installers: ForkToolFrameInstallers = upstreamInstallers,
50
60
  ): void {
51
61
  warnIfErrorHookIsUnavailable(pi, config);
62
+ // This fork leaves thinking rendering to Pi and pi-thinking-collapse.
63
+ setNativeThinking(() => config.nativeThinking);
52
64
  if (config.enabled && config.finalReplyStyle !== "off") {
53
65
  // index.ts registers pi-tidy's own boundary installer first, so this runs after it.
54
66
  pi.on("before_agent_start", () => installForkThinkingRows());
55
67
  }
56
68
  if (config.frameTools) installers.patchToolBoxFrames(toolFrameOptions(config));
57
- else installers.installHoverTracking();
69
+ else {
70
+ // patchToolBoxFrames normally publishes the runtime switches the boundary
71
+ // renderer reads. With framing off it never runs, and the `groupingActive`
72
+ // default (true) would make a thinking+tool-use assistant render as a group
73
+ // carrier with no group — the thinking row silently disappeared when a tool
74
+ // call arrived. Publish the real values here so renderers follow the config.
75
+ installers.setGroupingActive?.(() => config.groupTools);
76
+ installers.setIconsEnabled?.(() => config.icons);
77
+ installers.setThinkingColor?.(() => config.thinkingColor);
78
+ installers.installHoverTracking();
79
+ }
58
80
  }
@@ -110,21 +110,16 @@ function thinkingRegions(component: AssistantMessageComponent): MouseRegion[] {
110
110
  return childComponents(component).filter(isMouseRegion);
111
111
  }
112
112
 
113
- function hasHiddenThinking(component: AssistantMessageComponent): boolean {
114
- return assistantInternals(component).hideThinkingBlock === true;
115
- }
116
113
 
117
114
  function buildThinkingRows(
118
115
  component: AssistantMessageComponent,
119
116
  width: number,
120
117
  ): ThinkingRows | undefined {
121
- // pi-tidy's framed-final-reply path intentionally omits thinking children.
122
- // Restore only the settled, hidden Pi MouseRegions: streaming output remains
123
- // owned by Pi and the row keeps Pi's own click-to-expand behavior.
124
- if (
125
- !isFramedFinalReply(component) ||
126
- !hasHiddenThinking(component)
127
- ) {
118
+ // pi-tidy's framed-final-reply path omits thinking children. Restore the
119
+ // settled Pi MouseRegions outside the frame whether or not Pi hides them:
120
+ // pi-thinking-collapse decides the collapsed affordance, and this fork never
121
+ // restyles thinking itself.
122
+ if (!isFramedFinalReply(component)) {
128
123
  return undefined;
129
124
  }
130
125
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xzzpig/pi-tidy",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Tool folding for the pi agent — a reply's tool calls collapse to one clickable line; failures, edit diffs and running jobs stay visible",
6
6
  "license": "MIT",
@@ -820,6 +820,13 @@ type RenderFn = ((this: any, ...args: any[]) => string[]) & { [BOUNDARY_WRAPPER]
820
820
  /** Whether grouping is on right now (the tool patch keeps this current). */
821
821
  let groupingActive: () => boolean = () => true;
822
822
 
823
+ /** Leave Pi's own thinking rows untouched (fork native-thinking mode). */
824
+ let nativeThinking: () => boolean = () => false;
825
+
826
+ export function setNativeThinking(active: () => boolean): void {
827
+ nativeThinking = active;
828
+ }
829
+
823
830
  /** Whether Nerd Font icons are on (`icons: false` on a terminal without one). */
824
831
  let iconsEnabled: () => boolean = () => true;
825
832
  /** `tidy.thinkingColor`: the brain, the count and an expanded box border. */
@@ -940,6 +947,7 @@ function restyleThinking(component: any, lines: string[] | undefined, width: num
940
947
  for (let i = 0; i < runs.length; i++) if (!overrides?.has?.(i)) overrides?.set?.(i, true);
941
948
  }
942
949
 
950
+ if (!hideThinking && nativeThinking()) return lines ?? [];
943
951
  const icons = iconsEnabled();
944
952
  const color = thinkingColorFor();
945
953
  // Keep the existing live preview/spinner; only its layout ownership changes.