@wierdbytes/pi-facelift 0.4.4 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ - **Fix:** facelift no longer silently disables itself on pi 0.79.x — tool
6
+ output renders with facelift frames again instead of pi's default renderer.
7
+ The SDK and pi-tui are now loaded via static `import` rather than a runtime
8
+ `require()`, which jiti's package aliases broke for the new
9
+ `@earendil-works/pi-ai/base` subpath.
10
+
3
11
  ## 0.4.0
4
12
 
5
13
  - **New**: GitHub-style split/unified diff renderer for the `write`
package/README.md CHANGED
@@ -126,7 +126,7 @@ This package lives in the [`pi-wierd-stuff`](../../README.md) monorepo.
126
126
  ```bash
127
127
  bun install # from the repo root
128
128
  cd packages/facelift
129
- bun run test # 11 tests
129
+ bun run test # 64 tests
130
130
  bun run test:watch # vitest watch mode
131
131
  bun run demo # render every tool block to your terminal
132
132
  ```
package/index.ts CHANGED
@@ -44,7 +44,19 @@ import type {
44
44
  WriteToolInput,
45
45
  } from "@earendil-works/pi-coding-agent";
46
46
  import type { Theme } from "@earendil-works/pi-coding-agent";
47
- import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
47
+ // Runtime SDK values are imported *statically* (not via `require()`).
48
+ //
49
+ // pi loads extensions through jiti, which aliases bare package specifiers
50
+ // (e.g. `@earendil-works/pi-ai`) to a single `dist/index.js` file. A runtime
51
+ // `require("@earendil-works/pi-coding-agent")` makes jiti resolve the SDK's
52
+ // transitive subpath imports (notably `@earendil-works/pi-ai/base`, pulled in
53
+ // by `@earendil-works/pi-agent-core` since pi 0.79.x) via prefix string
54
+ // replacement — yielding `.../pi-ai/dist/index.js/base`, which does not exist.
55
+ // The throw used to be swallowed by a `try/catch { return }`, silently
56
+ // disabling the whole extension (tools fell back to pi's default rendering).
57
+ // Static `import` resolves subpath exports correctly, so we use it instead.
58
+ import * as piCodingAgentSdk from "@earendil-works/pi-coding-agent";
59
+ import { Text as PiText, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
48
60
  import { codeToANSI } from "@shikijs/cli";
49
61
  import { bundledThemes } from "shiki";
50
62
  import {
@@ -1047,7 +1059,8 @@ function setResultDetails<T>(result: ToolResultLike, details: T): void {
1047
1059
 
1048
1060
  /**
1049
1061
  * Dependencies that can be injected for testing.
1050
- * In production, omit `deps` — the extension uses require() to load them.
1062
+ * In production, omit `deps` — the extension uses the statically-imported
1063
+ * SDK (`@earendil-works/pi-coding-agent`) and pi-tui `Text` component.
1051
1064
  */
1052
1065
  export interface PiFaceliftDeps {
1053
1066
  sdk: PiFaceliftSdk;
@@ -1078,19 +1091,16 @@ export default function piFaceliftExtension(pi: PiFaceliftApi, deps?: PiFacelift
1078
1091
  createEditTool = sdk.createEditToolDefinition ?? sdk.createEditTool;
1079
1092
  TextComponent = deps.TextComponent;
1080
1093
  } else {
1081
- try {
1082
- sdk = require("@earendil-works/pi-coding-agent");
1083
- createReadTool = sdk.createReadToolDefinition ?? sdk.createReadTool;
1084
- createBashTool = sdk.createBashToolDefinition ?? sdk.createBashTool;
1085
- createLsTool = sdk.createLsToolDefinition ?? sdk.createLsTool;
1086
- createFindTool = sdk.createFindToolDefinition ?? sdk.createFindTool;
1087
- createGrepTool = sdk.createGrepToolDefinition ?? sdk.createGrepTool;
1088
- createWriteTool = sdk.createWriteToolDefinition ?? sdk.createWriteTool;
1089
- createEditTool = sdk.createEditToolDefinition ?? sdk.createEditTool;
1090
- TextComponent = require("@earendil-works/pi-tui").Text;
1091
- } catch {
1092
- return;
1093
- }
1094
+ // Production path: use the statically-imported SDK + pi-tui Text.
1095
+ sdk = piCodingAgentSdk as unknown as PiFaceliftSdk;
1096
+ createReadTool = sdk.createReadToolDefinition ?? sdk.createReadTool;
1097
+ createBashTool = sdk.createBashToolDefinition ?? sdk.createBashTool;
1098
+ createLsTool = sdk.createLsToolDefinition ?? sdk.createLsTool;
1099
+ createFindTool = sdk.createFindToolDefinition ?? sdk.createFindTool;
1100
+ createGrepTool = sdk.createGrepToolDefinition ?? sdk.createGrepTool;
1101
+ createWriteTool = sdk.createWriteToolDefinition ?? sdk.createWriteTool;
1102
+ createEditTool = sdk.createEditToolDefinition ?? sdk.createEditTool;
1103
+ TextComponent = PiText as unknown as TextComponentCtor;
1094
1104
  }
1095
1105
  if (!createReadTool || !TextComponent) return;
1096
1106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wierdbytes/pi-facelift",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "Cosmetic facelift for built-in pi tool output — open-right rounded frames, syntax-highlighted reads, status-aware bash summaries, find/grep.",
5
5
  "type": "module",
6
6
  "files": [