@giladbarnea/pi-pretty-bash 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gilad Barnea
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ <div align="center">
2
+
3
+ # pi-pretty-bash
4
+
5
+ > **Bash tool calls should look like Bash.**
6
+
7
+ [![pi extension](https://img.shields.io/badge/pi-extension-blueviolet)](https://github.com/earendil-works/pi)
8
+ [![npm version](https://img.shields.io/npm/v/%40giladbarnea%2Fpi-pretty-bash?logo=npm)](https://www.npmjs.com/package/@giladbarnea/pi-pretty-bash)
9
+ [![license](https://img.shields.io/github/license/giladbarnea/pi-pretty-bash)](LICENSE)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
11
+
12
+ `pi-pretty-bash` adds theme-aware syntax colors to Bash tool calls in Pi's TUI.
13
+
14
+ </div>
15
+
16
+ <p align="center">
17
+ <img src="screenshots/1.png" alt="A syntax-highlighted Bash tool call in Pi" width="760">
18
+ </p>
19
+
20
+ ## Pi already had the right highlighter
21
+
22
+ Pi highlights fenced Bash blocks in Markdown well. Its SDK exports that same highlighter as `highlightCode()`.
23
+
24
+ This extension sends each Bash command through `highlightCode(command, "bash")`. The colors therefore match Pi's active theme and Markdown output.
25
+
26
+ The extension does not ship another Bash grammar or import `highlight.js` directly.
27
+
28
+ ## Install
29
+
30
+ ```sh
31
+ pi install npm:@giladbarnea/pi-pretty-bash
32
+ ```
33
+
34
+ Start a new Pi session, or run `/reload` in the current session. Every later Bash tool call is highlighted automatically.
35
+
36
+ Pi may report that the extension overrides the built-in `bash` tool. This warning is expected because tool renderers are attached to tool definitions.
37
+
38
+ ## Only the command display changes
39
+
40
+ The extension starts from Pi's complete built-in Bash definition. It calls Pi's original renderer, then replaces only the visible command text with highlighted text.
41
+
42
+ Pi still owns command execution, streaming output, timing, truncation, expansion, error display, and result rendering.
43
+
44
+ ## Compatibility
45
+
46
+ `pi-pretty-bash` requires Pi `0.83.0` or newer.
47
+
48
+ Another extension that also replaces the built-in `bash` tool can conflict with this extension. In that case, the last registered Bash tool wins.
49
+
50
+ ## License
51
+
52
+ [MIT](LICENSE)
package/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ import {
2
+ createBashToolDefinition,
3
+ highlightCode,
4
+ type ExtensionAPI,
5
+ } from "@earendil-works/pi-coding-agent";
6
+
7
+ export default function prettyBash(pi: ExtensionAPI): void {
8
+ const bashTool = createBashToolDefinition(process.cwd());
9
+ const renderBashCall = bashTool.renderCall;
10
+
11
+ if (!renderBashCall) {
12
+ throw new Error("Pi's Bash tool has no call renderer");
13
+ }
14
+
15
+ pi.registerTool({
16
+ ...bashTool,
17
+
18
+ renderCall(arguments_, theme, context) {
19
+ const component = renderBashCall(arguments_, theme, context);
20
+ if (!("setText" in component) || typeof component.setText !== "function") {
21
+ throw new Error("Pi's Bash call renderer no longer returns mutable text");
22
+ }
23
+
24
+ const command = typeof arguments_.command === "string" ? arguments_.command : "";
25
+ const renderedCommand = command
26
+ ? highlightCode(command, "bash").join("\n")
27
+ : theme.fg("toolOutput", "...");
28
+ const timeout =
29
+ typeof arguments_.timeout === "number"
30
+ ? theme.fg("muted", ` (timeout ${arguments_.timeout}s)`)
31
+ : "";
32
+
33
+ component.setText(`${theme.fg("toolTitle", theme.bold("$"))} ${renderedCommand}${timeout}`);
34
+ return component;
35
+ },
36
+ });
37
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@giladbarnea/pi-pretty-bash",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Syntax-highlight Bash tool calls in Pi's TUI.",
6
+ "keywords": [
7
+ "pi-package",
8
+ "pi",
9
+ "pi-agent",
10
+ "pi-coding-agent",
11
+ "bash",
12
+ "syntax-highlighting"
13
+ ],
14
+ "author": "Gilad Barnea",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/giladbarnea/pi-pretty-bash.git"
19
+ },
20
+ "homepage": "https://github.com/giladbarnea/pi-pretty-bash",
21
+ "bugs": {
22
+ "url": "https://github.com/giladbarnea/pi-pretty-bash/issues"
23
+ },
24
+ "files": [
25
+ "index.ts",
26
+ "README.md",
27
+ "LICENSE",
28
+ "screenshots/1.png"
29
+ ],
30
+ "peerDependencies": {
31
+ "@earendil-works/pi-coding-agent": ">=0.83.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "pi": {
37
+ "extensions": [
38
+ "./index.ts"
39
+ ]
40
+ }
41
+ }
Binary file