pi-libtui 0.3.2 → 0.3.8
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 +9 -6
- package/native-revision +1 -0
- package/package.json +1 -1
- package/src/color/preview.ts +1 -1
- package/src/native-binary.ts +7 -7
- package/test/color-preview.test.ts +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# pi-libtui
|
|
2
2
|
|
|
3
|
+
[Pi gallery](https://pi.dev/packages/pi-libtui)
|
|
4
|
+
|
|
3
5
|
Shared terminal UI for Pi extensions: layouts, split panes, dialogs, pickers,
|
|
4
6
|
selection actions, semantic colors, icons, cursors, syntax highlighting,
|
|
5
7
|
animated tool surfaces, streamed output, diffs, terminal projection, and the
|
|
@@ -77,13 +79,13 @@ guarded Pi 0.84–0.85 adapter; unsupported hosts keep their native transcript.
|
|
|
77
79
|
Feature packages shell out to Rust binaries such as `terminal_bridge` (the
|
|
78
80
|
exported `TERMINAL_BRIDGE` descriptor). Requires a Rust toolchain
|
|
79
81
|
(https://rustup.rs). The `terminal_bridge` binary builds itself on first use
|
|
80
|
-
under Pi's agent directory (`native/terminal-bridge
|
|
81
|
-
`<
|
|
82
|
+
under Pi's agent directory (`native/terminal-bridge/<revision>/`), where
|
|
83
|
+
`<revision>` is the source commit recorded in the packaged `native-revision` file. Set `PI_TERMINAL_BRIDGE_BINARY` to use
|
|
82
84
|
a prebuilt binary; it must point at an executable file.
|
|
83
85
|
|
|
84
86
|
`ensureNativeBinary(binary, hooks?)` resolves in this order: the descriptor's
|
|
85
|
-
env override, then `<agentDir>/native/<crate>/
|
|
86
|
-
it on first use when absent. Builds are keyed by crate and
|
|
87
|
+
env override, then `<agentDir>/native/<crate>/<revision>/bin/<name>`, building
|
|
88
|
+
it on first use when absent. Builds are keyed by crate and source commit, so every
|
|
87
89
|
installed copy shares them, and concurrent requests within one process share
|
|
88
90
|
one build. Pass `onBuild` to show the delay in the UI. The extension host keeps
|
|
89
91
|
the shared PTY host alive across an extension reload; a session switch or quit
|
|
@@ -201,5 +203,6 @@ Source: https://github.com/luan/agents, directory
|
|
|
201
203
|
harnesses/pi/agent/packages/pi-libtui. Run `bun run typecheck` and
|
|
202
204
|
`bun test test` in that directory. When running from that checkout,
|
|
203
205
|
`ensureNativeBinary` also looks for `target/{release,debug}/<name>` in the Cargo
|
|
204
|
-
workspace and reports an unbuilt checkout instead of building
|
|
205
|
-
|
|
206
|
+
workspace and reports an unbuilt checkout instead of building. `just pi-pack`
|
|
207
|
+
records the checkout commit in every bundled `pi-libtui/native-revision` file,
|
|
208
|
+
so native builds do not depend on npm versions or repository-wide release tags.
|
package/native-revision
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
93ecc14e6cb9dc5228165a4b605b933ea595d69e
|
package/package.json
CHANGED
package/src/color/preview.ts
CHANGED
|
@@ -13,7 +13,7 @@ const HUE_EDGES: readonly ChannelMask[] = [
|
|
|
13
13
|
[true, false, true],
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
-
/** Width of the
|
|
16
|
+
/** Width of the color256 terminal preview, including its base16 legend. */
|
|
17
17
|
export const COLOR256_PREVIEW_WIDTH = 69;
|
|
18
18
|
|
|
19
19
|
/**
|
package/src/native-binary.ts
CHANGED
|
@@ -81,7 +81,8 @@ export interface EnsureNativeBinaryHooks {
|
|
|
81
81
|
* revision under Pi's agent directory and shared by every installed pi-libtui copy.
|
|
82
82
|
*/
|
|
83
83
|
export async function ensureNativeBinary(binary: NativeBinary, hooks: EnsureNativeBinaryHooks = {}): Promise<string> {
|
|
84
|
-
const
|
|
84
|
+
const options = processOptions();
|
|
85
|
+
const location = locateNativeBinary(binary, options);
|
|
85
86
|
if (location.kind === "found") return location.path;
|
|
86
87
|
if (location.kind === "unbuilt-checkout") {
|
|
87
88
|
throw new Error(
|
|
@@ -92,7 +93,7 @@ export async function ensureNativeBinary(binary: NativeBinary, hooks: EnsureNati
|
|
|
92
93
|
const existing = builds.get(location.path);
|
|
93
94
|
if (existing) return existing;
|
|
94
95
|
hooks.onBuild?.(`Building ${binary.binaryName} (first use); this takes a minute.`);
|
|
95
|
-
const build = runCargo(nativeBuildArguments(binary,
|
|
96
|
+
const build = runCargo(nativeBuildArguments(binary, options.rev, location.installRoot), location.installRoot)
|
|
96
97
|
.then(() => {
|
|
97
98
|
if (!isExecutable(location.path)) throw new Error(`cargo install did not produce ${location.path}`);
|
|
98
99
|
return location.path;
|
|
@@ -106,12 +107,11 @@ export function terminalBridgeBinaryPath(): Promise<string> {
|
|
|
106
107
|
return ensureNativeBinary(TERMINAL_BRIDGE);
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
/**
|
|
110
|
+
/** The pack step records the exact source commit independently of npm versions. */
|
|
110
111
|
export function nativeRevision(): string {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return `v${manifest.version}`;
|
|
112
|
+
const revision = readFileSync(new URL("../native-revision", import.meta.url), "utf8").trim();
|
|
113
|
+
if (!/^[a-f0-9]{40}$/.test(revision)) throw new Error("Invalid native source revision; reinstall the package.");
|
|
114
|
+
return revision;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function processOptions(): NativeBinaryOptions {
|
|
@@ -3,7 +3,7 @@ import { visibleWidth } from "@earendil-works/pi-tui";
|
|
|
3
3
|
import { COLOR256_PREVIEW_WIDTH, renderColor256Preview } from "../src/color/preview.ts";
|
|
4
4
|
|
|
5
5
|
describe("color256 preview", () => {
|
|
6
|
-
test("matches the
|
|
6
|
+
test("matches the terminal grid dimensions and labels", () => {
|
|
7
7
|
const lines = renderColor256Preview("harmonious");
|
|
8
8
|
expect(lines).toHaveLength(20);
|
|
9
9
|
expect(lines.every((line) => visibleWidth(line) === COLOR256_PREVIEW_WIDTH)).toBe(true);
|