pi-better-harness 0.15.0 → 0.15.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/README.md CHANGED
@@ -71,8 +71,9 @@ builds can also open one folded run by clicking its summary.
71
71
 
72
72
  Normal mode is the default. The preference is saved in the current session,
73
73
  including resume/reload. This is a version-sensitive internal TUI adapter,
74
- tested with Pi 0.82.1 and 0.99.1; incompatible APIs produce a warning and leave
75
- ordinary output enabled. Print/RPC output and exported transcripts are unchanged.
74
+ tested with Pi 0.82.1, 0.99.1, and the bundled Pi 1.0.0 CLI; incompatible APIs
75
+ produce a warning and leave ordinary output enabled. Print/RPC output and
76
+ exported transcripts are unchanged.
76
77
 
77
78
  The standalone-package installer does not install this bundled extension.
78
79
  Load the bundled harness or run it directly from a checkout:
@@ -74,20 +74,31 @@ function hostRequire(): NodeRequire {
74
74
  return require;
75
75
  }
76
76
 
77
+ /** Bundled CLI classes are distinct from the SDK's unbundled deep imports. */
78
+ function bundledHostEntry(entry: string): string | undefined {
79
+ if (!process.argv[1]) return undefined;
80
+ try {
81
+ const directory = dirname(realpathSync(process.argv[1]));
82
+ if (directory === join(dirname(entry), "bundle")) return join(directory, "index.js");
83
+ } catch { /* An embedded host may not have a filesystem launcher. */ }
84
+ return undefined;
85
+ }
86
+
77
87
  /** Resolve the running host's SDK, not a second SDK bundled beside the extension. */
78
88
  export async function loadToolPrototype(): Promise<ToolPrototype> {
79
89
  const entry = sdkEntry(hostRequire());
80
- const path = join(dirname(entry), "modes/interactive/components/tool-execution.js");
90
+ const bundle = bundledHostEntry(entry);
91
+ const path = bundle ?? join(dirname(entry), "modes/interactive/components/tool-execution.js");
81
92
  const module = await import(pathToFileURL(path).href);
93
+ if (!module.ToolExecutionComponent?.prototype) {
94
+ throw new Error("Pi's runtime does not expose its tool display class. Normal output remains enabled.");
95
+ }
82
96
  return module.ToolExecutionComponent.prototype;
83
97
  }
84
98
 
85
- /** Chat rows are Container children. Patch that host class, not a second copy. */
99
+ /** Use the actual tool class's Container base, including in bundled hosts. */
86
100
  export async function loadContainerPrototype(): Promise<ContainerPrototype> {
87
- const entry = sdkEntry(hostRequire());
88
- const tuiPath = createRequire(entry).resolve("@earendil-works/pi-tui");
89
- const tui = await import(pathToFileURL(tuiPath).href);
90
- const prototype = tui.Container?.prototype;
101
+ const prototype = Object.getPrototypeOf(await loadToolPrototype());
91
102
  if (typeof prototype?.addChild !== "function" || typeof prototype?.render !== "function") {
92
103
  throw new Error("Pi's chat container API is incompatible: missing Container.addChild. Turn folding is unavailable.");
93
104
  }
@@ -96,6 +107,8 @@ export async function loadContainerPrototype(): Promise<ContainerPrototype> {
96
107
 
97
108
  export async function loadMutedText(): Promise<(text: string) => string> {
98
109
  const entry = sdkEntry(hostRequire());
110
+ // The bundled SDK does not export its live theme singleton.
111
+ if (bundledHostEntry(entry)) return (text) => text;
99
112
  const theme = await import(pathToFileURL(join(dirname(entry), "modes/interactive/theme/theme.js")).href);
100
113
  return (text) => {
101
114
  try { return theme.theme.fg("muted", text); } catch { return text; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-harness",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Pi extension bundle for a write sandbox, subagents, background tasks, SSH, goals, and structured plans.",
5
5
  "license": "MIT",
6
6
  "type": "module",