@xynogen/pix-pretty 1.7.6 → 1.7.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 +55 -56
- package/package.json +2 -2
- package/src/README.md +25 -55
- package/src/diff.test.ts +23 -0
- package/src/diff.ts +6 -2
- package/src/index.ts +5 -8
package/README.md
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
# pix-pretty
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Rendering and formatting library for Pi Coding Agent with syntax highlighting, file icons, tree views, FFF search integration, and gate-dialog overlay.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What it does
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This package is a **library + a small extension** that other pix packages
|
|
8
|
+
consume. It does not register user-facing tools itself — the tool renderers
|
|
9
|
+
(`pix-read`, `pix-bash`, `pix-ls`, `pix-find`, `pix-grep`, `pix-edit`,
|
|
10
|
+
`pix-write`) import from it. The extension entry point (`src/index.ts`) only
|
|
11
|
+
initializes the syntax-highlight theme from Pi settings, clears the highlight
|
|
12
|
+
cache, and registers two FFF slash commands (`/fff-health`, `/fff-rescan`)
|
|
13
|
+
once `pix-grep` has brought the FFF finder online.
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
- **File icons** - Visual file type indicators in ls/find output
|
|
11
|
-
- **Tree views** - Hierarchical directory display
|
|
12
|
-
- **FFF search** - Fast full-text search integration with `@ff-labs/fff-node`
|
|
13
|
-
- **Diff rendering** - Enhanced git diff and edit/write tool output
|
|
14
|
-
- **Image metadata** - Display image dimensions and format info
|
|
15
|
-
- **Bash exit summary** - Command status and timing info
|
|
15
|
+
### Rendering
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
- **Syntax highlighting** — `cli-highlight` (highlight.js-backed)
|
|
18
|
+
- **File icons** — type-aware icons in ls/find output
|
|
19
|
+
- **Tree views** — hierarchical directory display for ls
|
|
20
|
+
- **Diff rendering** — side-by-side split diff for edit/write
|
|
21
|
+
- **Bash exit summary** — colored status, line count, truncation notice
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
- **Text paste markers** - Long pasted text → `[paste text +42 lines]`
|
|
21
|
-
- **Atomic deletion** - Delete entire paste markers as single units
|
|
22
|
-
- **Type-aware labels** - Visual distinction between image and text pastes
|
|
23
|
+
### Shared overlay
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
- **Gate overlay** (`./gate-overlay`) — the one permission-dialog component
|
|
26
|
+
shared by `pix-gate` and `pix-sudo`. Two modes: `confirm` (SelectList) and
|
|
27
|
+
`sudo` (SelectList + masked password). Returns
|
|
28
|
+
`{ action: "approved" | "denied" | "timeout", password? }`. Padded with
|
|
29
|
+
`Box` `paddingX=2`, `paddingY=1`. The simpler `./confirm` export is the
|
|
30
|
+
plain boolean Yes/No dialog.
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
UI features that used to live here have moved to [`pix-display`](packages/pix-display):
|
|
33
|
+
paste chip rendering and reasoning-tag (`<think>`/`<thinking>`) → native
|
|
34
|
+
`thinking` content blocks.
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- **Live streaming** - Splits `<think>`/`<thinking>` regions into native Pi `thinking` content blocks token-by-token during streaming
|
|
31
|
-
- **Finalized cleanup** - On `message_end`, re-splits every affected text block for persistence (the finalized message bypasses the live rebuild)
|
|
32
|
-
- **Partial-tag safety** - Strips trailing half-streamed tags (e.g. `<thin`) so they never flash as literal text
|
|
33
|
-
- **Visual distinction** - Uses Pi's native `thinking` block rendering (dim + italic via `thinkingText` theme token) — no ANSI injection, no markdown blockquote shim
|
|
34
|
-
|
|
35
|
-
## Installation
|
|
36
|
+
## Install
|
|
36
37
|
|
|
37
38
|
```bash
|
|
38
39
|
pi install npm:@xynogen/pix-pretty
|
|
@@ -42,40 +43,38 @@ pi install npm:@xynogen/pix-pretty
|
|
|
42
43
|
|
|
43
44
|
### Environment Variables
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- `
|
|
48
|
-
- `
|
|
49
|
-
- `
|
|
50
|
-
- `
|
|
51
|
-
- `
|
|
52
|
-
- `PRETTY_DISABLE_TOOLS` - Comma-separated list of tools to skip rendering
|
|
53
|
-
- `PRETTY_IMAGE_PROTOCOL` - Protocol for image display (tmux passthrough)
|
|
54
|
-
- `PRETTY_FFF_DIR` - Override FFF state dir (default: `~/.cache/pi/fff`)
|
|
55
|
-
|
|
56
|
-
## Architecture
|
|
57
|
-
|
|
58
|
-
This package combines two rendering systems:
|
|
59
|
-
|
|
60
|
-
1. **Theme + FFF commands** (`src/index.ts`) - Initialises syntax-highlight theme from Pi settings, clears highlight cache, and registers FFF slash commands. Tool renderers live in the standalone `pix-{read,bash,ls,find,grep,edit,write}` packages — each self-registers via its own Pi extension entry point.
|
|
61
|
-
2. **Paste chip formatting** (`src/paste-chips.ts`) - Custom editor component for paste markers.
|
|
62
|
-
3. **Reasoning tag rendering** (`src/thinking.ts`) - Converts leaked `<think>`/`<thinking>` tags into native Pi `thinking` content blocks (dim + italic via `thinkingText` theme token).
|
|
46
|
+
- `PRETTY_THEME` — color theme for syntax highlighting
|
|
47
|
+
- `PRETTY_MAX_HL_CHARS` — max characters to highlight (default: 80000)
|
|
48
|
+
- `PRETTY_MAX_PREVIEW_LINES` — max lines in preview output
|
|
49
|
+
- `PRETTY_CACHE_LIMIT` — FFF cache size limit
|
|
50
|
+
- `PRETTY_ICONS` — icon mode (`nerd` or `none`)
|
|
51
|
+
- `PRETTY_MAX_RENDER_LINES` — max lines in edit/write diff render (default: 150)
|
|
52
|
+
- `PRETTY_FFF_DIR` — override FFF state dir (default: `~/.cache/pi/fff`)
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
## Public exports
|
|
65
55
|
|
|
66
|
-
|
|
56
|
+
The package exposes its sub-modules via `exports`:
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
58
|
+
```
|
|
59
|
+
@xynogen/pix-pretty (default — extension entry)
|
|
60
|
+
@xynogen/pix-pretty/ansi
|
|
61
|
+
@xynogen/pix-pretty/confirm
|
|
62
|
+
@xynogen/pix-pretty/progress
|
|
63
|
+
@xynogen/pix-pretty/config
|
|
64
|
+
@xynogen/pix-pretty/diff
|
|
65
|
+
@xynogen/pix-pretty/diff-render
|
|
66
|
+
@xynogen/pix-pretty/highlight
|
|
67
|
+
@xynogen/pix-pretty/lang
|
|
68
|
+
@xynogen/pix-pretty/icons
|
|
69
|
+
@xynogen/pix-pretty/renderers
|
|
70
|
+
@xynogen/pix-pretty/fff
|
|
71
|
+
@xynogen/pix-pretty/types
|
|
72
|
+
@xynogen/pix-pretty/utils
|
|
73
|
+
@xynogen/pix-pretty/resize
|
|
74
|
+
@xynogen/pix-pretty/context
|
|
75
|
+
@xynogen/pix-pretty/gate-overlay
|
|
76
|
+
@xynogen/pix-pretty/modal-frame
|
|
77
|
+
```
|
|
79
78
|
|
|
80
79
|
## Full distro
|
|
81
80
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-pretty",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views,
|
|
3
|
+
"version": "1.7.8",
|
|
4
|
+
"description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views, diff rendering, and FFF search",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"exports": {
|
package/src/README.md
CHANGED
|
@@ -1,66 +1,36 @@
|
|
|
1
|
-
# pretty
|
|
1
|
+
# pix-pretty/src
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
> **Historical doc — kept for reference only.**
|
|
4
|
+
>
|
|
5
|
+
> This file originally described pix-pretty as a vendored fork of
|
|
6
|
+
> `@heyhuynhgiabuu/pi-pretty`. That is no longer accurate: pix-pretty has
|
|
7
|
+
> been completely reimplemented. The current source layout, exports, and
|
|
8
|
+
> dependency graph live in the package-level [`README.md`](../README.md).
|
|
9
|
+
>
|
|
10
|
+
> The notes below remain only as a record of two behavioral decisions that
|
|
11
|
+
> differ from the original upstream; both are still in force.
|
|
7
12
|
|
|
8
|
-
##
|
|
13
|
+
## Behavioral decisions that survive the rewrite
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
These two changes were made when pix-pretty was a vendored fork and are
|
|
16
|
+
preserved in the reimplementation:
|
|
12
17
|
|
|
13
18
|
1. **Highlight engine: shiki → cli-highlight.**
|
|
14
|
-
Upstream
|
|
15
|
-
|
|
16
|
-
(highlight.js-backed, synchronous).
|
|
19
|
+
Upstream used `@shikijs/cli` (`codeToANSI`, TextMate grammars + WASM).
|
|
20
|
+
The reimplementation uses [`cli-highlight`](https://www.npmjs.com/package/cli-highlight)
|
|
21
|
+
(highlight.js-backed, synchronous). `HLJS_LANG_ALIAS` maps shiki-style ids
|
|
22
|
+
(`tsx`, `jsx`, `jsonc`, `mdx`, `make`, `svelte`, `vue`) onto
|
|
23
|
+
highlight.js-supported ids. The `hlBlock` interface, language table,
|
|
17
24
|
line-number layout, and low-contrast normalization are unchanged.
|
|
18
25
|
|
|
19
26
|
2. **FFF state dir: `~/.pi/agent/pi-pretty/fff` → `~/.cache/pi/fff`.**
|
|
20
|
-
`getPiPrettyFffDir()`
|
|
21
|
-
|
|
27
|
+
`getPiPrettyFffDir()` resolves to `$XDG_CACHE_HOME/pi/fff` (default
|
|
28
|
+
`~/.cache/pi/fff`), overridable with `PRETTY_FFF_DIR`.
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
image metadata, tmux passthrough, `/fff-health`, `/fff-rescan`, multi_grep
|
|
25
|
-
ripgrep fallback) is byte-for-byte upstream.
|
|
30
|
+
## What moved out
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
- **Paste chip formatting** → [`@xynogen/pix-display`](../pix-display)
|
|
33
|
+
- **Reasoning tag (`<think>`/`<thinking>`) rendering** →
|
|
34
|
+
[`@xynogen/pix-display`](../pix-display)
|
|
28
35
|
|
|
29
|
-
-
|
|
30
|
-
- imports: `@shikijs/cli` + `shiki` types → `cli-highlight` (lazy `require`)
|
|
31
|
-
with local `BundledLanguage`/`BundledTheme = string` aliases.
|
|
32
|
-
- `FORCE_COLOR=3` default before chalk init (shiki always emitted truecolor;
|
|
33
|
-
chalk decides level once at load). Respects an explicit `FORCE_COLOR` /
|
|
34
|
-
`NO_COLOR`.
|
|
35
|
-
- `HLJS_LANG_ALIAS` maps shiki-style ids (`tsx`, `jsx`, `jsonc`, `mdx`,
|
|
36
|
-
`make`, `svelte`, `vue`) onto highlight.js-supported ids.
|
|
37
|
-
- `hlBlock()` calls `highlight(code, { language, ignoreIllegals: true })`
|
|
38
|
-
instead of `await codeToANSI(...)`. Still async-typed so call sites match.
|
|
39
|
-
- `getPiPrettyFffDir()` → `~/.cache/pi/fff`.
|
|
40
|
-
- `fff-helpers.ts`, `multi-grep-fallback.ts` — unchanged.
|
|
41
|
-
|
|
42
|
-
## Runtime deps & module resolution
|
|
43
|
-
|
|
44
|
-
`cli-highlight` and `@ff-labs/fff-node` are installed into pi's npm root
|
|
45
|
-
(`~/.pi/agent/npm/node_modules`) by `setup.sh`. Because the extensions dir is a
|
|
46
|
-
symlink into dotfiles and Node dereferences symlinks before resolving bare
|
|
47
|
-
imports, `setup.sh` also creates a git-ignored
|
|
48
|
-
`extensions/node_modules` → `~/.pi/agent/npm/node_modules` bridge next to the
|
|
49
|
-
real source so `require("cli-highlight")` / `import("@ff-labs/fff-node")`
|
|
50
|
-
resolve.
|
|
51
|
-
|
|
52
|
-
The upstream `npm:@heyhuynhgiabuu/pi-pretty` package is uninstalled by
|
|
53
|
-
`setup.sh` — both register the same tool names and pi does not share tool-name
|
|
54
|
-
ownership across extensions.
|
|
55
|
-
|
|
56
|
-
## Env vars
|
|
57
|
-
|
|
58
|
-
Same as upstream (`PRETTY_THEME`, `PRETTY_MAX_HL_CHARS`,
|
|
59
|
-
`PRETTY_MAX_PREVIEW_LINES`, `PRETTY_CACHE_LIMIT`, `PRETTY_ICONS`,
|
|
60
|
-
`PRETTY_DISABLE_TOOLS`, `PRETTY_IMAGE_PROTOCOL`) plus:
|
|
61
|
-
|
|
62
|
-
- `PRETTY_FFF_DIR` — override the FFF state dir (default `~/.cache/pi/fff`).
|
|
63
|
-
|
|
64
|
-
## License
|
|
65
|
-
|
|
66
|
-
MIT — upstream by huynhgiabuu. See upstream repo.
|
|
36
|
+
See the package-level README for the current export map.
|
package/src/diff.test.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { parseDiff } from "./diff.js";
|
|
4
|
+
|
|
5
|
+
const OLD = "line1\nline2\nline3";
|
|
6
|
+
const NEW = "line1\nCHANGED\nline3";
|
|
7
|
+
|
|
8
|
+
describe("parseDiff baseLine", () => {
|
|
9
|
+
it("is snippet-relative when baseLine omitted (default 0)", () => {
|
|
10
|
+
const { lines } = parseDiff(OLD, NEW);
|
|
11
|
+
const del = lines.find((l) => l.type === "del");
|
|
12
|
+
expect(del?.oldNum).toBe(2); // line2 is the 2nd line of the snippet
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("shifts gutter numbers to absolute when baseLine given", () => {
|
|
16
|
+
// Snippet begins at file line 84 → snippet line 2 becomes file line 85.
|
|
17
|
+
const { lines } = parseDiff(OLD, NEW, 3, 84);
|
|
18
|
+
const del = lines.find((l) => l.type === "del");
|
|
19
|
+
const add = lines.find((l) => l.type === "add");
|
|
20
|
+
expect(del?.oldNum).toBe(85);
|
|
21
|
+
expect(add?.newNum).toBe(85);
|
|
22
|
+
});
|
|
23
|
+
});
|
package/src/diff.ts
CHANGED
|
@@ -22,6 +22,9 @@ export function parseDiff(
|
|
|
22
22
|
oldContent: string,
|
|
23
23
|
newContent: string,
|
|
24
24
|
ctx = 3,
|
|
25
|
+
// 1-based file line where the snippet begins; shifts gutter numbers from
|
|
26
|
+
// snippet-relative to absolute. 0 = no shift (snippet-relative, the default).
|
|
27
|
+
baseLine = 0,
|
|
25
28
|
): ParsedDiff {
|
|
26
29
|
const patch = Diff.structuredPatch("", "", oldContent, newContent, "", "", {
|
|
27
30
|
context: ctx,
|
|
@@ -42,8 +45,9 @@ export function parseDiff(
|
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
const h = patch.hunks[hi];
|
|
45
|
-
|
|
46
|
-
let
|
|
48
|
+
const shift = baseLine > 0 ? baseLine - 1 : 0;
|
|
49
|
+
let oL = h.oldStart + shift;
|
|
50
|
+
let nL = h.newStart + shift;
|
|
47
51
|
for (const raw of h.lines) {
|
|
48
52
|
if (raw === "\") continue;
|
|
49
53
|
const ch = raw[0];
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* pix-pretty — Pretty terminal output for pi built-in tools.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Primarily a rendering library (highlight/diff/icons/fff, imported by the tool
|
|
5
|
+
* packages). This default export is also a thin Pi extension: on load it inits
|
|
6
|
+
* the pretty theme, clears the highlight cache, and registers the FFF slash
|
|
7
|
+
* commands (/fff-health, /fff-rescan). pix-core activates it for that purpose.
|
|
5
8
|
* UI features (paste chips, thinking blocks) live in pix-display.
|
|
6
9
|
*/
|
|
7
10
|
|
|
@@ -30,9 +33,3 @@ export default function piPrettyExtension(pi: PiPrettyApi): void {
|
|
|
30
33
|
// Commands become available once pix-grep initialises the finder.
|
|
31
34
|
registerFffCommands(pi, fffState);
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* piPrettyExtension still exports a default function for packages that
|
|
36
|
-
* import it as an extension (pix-core activates it for theme + FFF).
|
|
37
|
-
* UI extensions (paste-chips, thinking) moved to pix-display.
|
|
38
|
-
*/
|