@heyhuynhgiabuu/pi-pretty 0.3.2 → 0.4.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/README.md CHANGED
@@ -3,13 +3,14 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@heyhuynhgiabuu/pi-pretty)](https://www.npmjs.com/package/@heyhuynhgiabuu/pi-pretty)
4
4
  [![GitHub release](https://img.shields.io/github/v/release/buddingnewinsights/pi-pretty)](https://github.com/buddingnewinsights/pi-pretty/releases/latest)
5
5
 
6
- A [pi](https://pi.dev) extension that upgrades built-in tool output in the terminal without changing tool behavior.
6
+ A [pi](https://pi.dev) extension that upgrades built-in tool output in the terminal and includes built-in FFF-powered search for `find`/`grep`.
7
7
 
8
8
  It currently enhances:
9
9
 
10
10
  - **`read`**: syntax-highlighted text previews with line numbers, plus inline image rendering when the terminal supports it
11
11
  - **`bash`**: colored exit summary (`exit 0`/`exit 1`) with a preview body of command output
12
- - **`ls` / `find` / `grep`**: Nerd Font file icons with tree/grouped layouts and clearer match rendering
12
+ - **`ls`**: Nerd Font file icons with tree-oriented rendering
13
+ - **`find` / `grep`**: built-in FFF-backed search with frecency-aware results, plus grouped/highlighted rendering
13
14
 
14
15
  > Companion to [@heyhuynhgiabuu/pi-diff](https://github.com/buddingnewinsights/pi-diff) for `write`/`edit` diff rendering.
15
16
 
@@ -51,6 +52,85 @@ When running in **tmux**, pi-pretty uses passthrough escape sequences.
51
52
  >
52
53
  > (or run once in a session: `tmux set -g allow-passthrough on`)
53
54
 
55
+ ## Bundled FFF search
56
+
57
+ `pi-pretty` now bundles `@ff-labs/fff-node` and owns the built-in `find` / `grep` search behavior directly.
58
+
59
+ If you use bundled FFF mode, do not load `pi-fff` at the same time, because Pi extensions do not compositionally share ownership of the same built-in tool names.
60
+
61
+ FFF data is stored under a pi-pretty-specific path:
62
+
63
+ ```text
64
+ ~/.pi/agent/pi-pretty/fff/
65
+ ```
66
+
67
+ This makes it clear that the cache belongs to this extension rather than Pi core.
68
+
69
+ ## How to use it
70
+
71
+ ### 1. Install and load only `pi-pretty`
72
+
73
+ ```bash
74
+ pi install npm:@heyhuynhgiabuu/pi-pretty
75
+ ```
76
+
77
+ Do **not** also load `pi-fff` in the same Pi setup.
78
+
79
+ ### 2. Start Pi in a project
80
+
81
+ ```bash
82
+ cd /path/to/your/project
83
+ pi
84
+ ```
85
+
86
+ On session start, pi-pretty initializes the bundled FFF index for the current working directory.
87
+
88
+ ### 3. Use the built-in tools normally
89
+
90
+ You keep using the normal built-in tool names — pi-pretty owns them directly.
91
+
92
+ Examples:
93
+
94
+ ```text
95
+ find pattern="*.ts" path="src"
96
+ grep pattern="handleRequest" glob="*.ts"
97
+ read path="src/index.ts"
98
+ ls path="src"
99
+ ```
100
+
101
+ ### 4. Use `multi_grep` when you want OR-search across multiple strings
102
+
103
+ `multi_grep` is bundled on top of FFF and is useful when you want any of several patterns:
104
+
105
+ ```text
106
+ multi_grep patterns=["handleRequest","handle_request","HandleRequest"] constraints="*.ts"
107
+ ```
108
+
109
+ Good uses:
110
+ - find several naming variants at once
111
+ - search related symbols in one pass
112
+ - replace slow regex alternation with literal OR matching
113
+
114
+ ### 5. Check FFF status or force a rescan
115
+
116
+ pi-pretty also provides two maintenance commands:
117
+
118
+ ```text
119
+ /fff-health
120
+ /fff-rescan
121
+ ```
122
+
123
+ Use them when:
124
+ - you want to confirm indexing is active
125
+ - the session started with a partial index warning
126
+ - you made large filesystem changes and want a fresh scan
127
+
128
+ ### Notes
129
+
130
+ - `find` results are frecency-aware, so files you touch more often can bubble up earlier.
131
+ - `grep` and `multi_grep` can show a cursor notice when more results are available.
132
+ - If you see a partial index warning, let the session settle or run `/fff-rescan`.
133
+
54
134
  ## Configuration
55
135
 
56
136
  Optional environment variables:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyhuynhgiabuu/pi-pretty",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Pretty terminal output for pi — syntax-highlighted file reads, colored bash output, tree-view directory listings, and more.",
5
5
  "author": "huynhgiabuu",
6
6
  "license": "MIT",
@@ -22,11 +22,9 @@
22
22
  "pretty-print"
23
23
  ],
24
24
  "dependencies": {
25
+ "@ff-labs/fff-node": "0.5.2",
25
26
  "@shikijs/cli": "^4.0.2"
26
27
  },
27
- "optionalDependencies": {
28
- "@ff-labs/fff-node": "0.5.2"
29
- },
30
28
  "peerDependencies": {
31
29
  "@mariozechner/pi-coding-agent": "*",
32
30
  "@mariozechner/pi-tui": "*"
@@ -0,0 +1,48 @@
1
+ # pi-pretty v0.3.3
2
+
3
+ ## Summary
4
+ This patch release combines the recent rendering and FFF-path fixes into a single `v0.3.3` release.
5
+
6
+ ## What changed
7
+ - Fixed themed tool background rendering so `toolSuccessBg` and `toolErrorBg` fill the full rendered width for core tool output.
8
+ - Preserved the active tool background across ANSI reset sequences to avoid broken background bands inside highlighted output.
9
+ - Kept error rendering on `theme.fg("error", ...)` while switching error panels to `toolErrorBg`.
10
+ - Moved pi-pretty FFF data from:
11
+ - `~/.pi/agent/fff`
12
+ - To:
13
+ - `~/.pi/agent/pi-pretty/fff`
14
+ - Added a helper to resolve the pi-pretty-specific FFF directory under `getAgentDir()`.
15
+ - Updated README to document the pi-pretty-owned FFF data location.
16
+ - Added a test that verifies the generated frecency/history DB paths use the new per-extension location.
17
+
18
+ ## Files
19
+ - `src/index.ts`
20
+ - `test/fff-integration.test.ts`
21
+ - `README.md`
22
+ - `package.json`
23
+ - `package-lock.json`
24
+
25
+ ## Verification
26
+ - `npm run typecheck` ✅
27
+ - `npm test` ✅ (47 tests)
28
+ - `npm run lint` ⚠️ still reports pre-existing Biome diagnostics in legacy code paths; no new release-blocking failure was introduced for this patch.
29
+
30
+ ## Upgrade notes
31
+ If your Pi theme defines:
32
+
33
+ ```json
34
+ {
35
+ "toolSuccessBg": "#1e2e1e",
36
+ "toolErrorBg": "#2e1e1e"
37
+ }
38
+ ```
39
+
40
+ core tool panels now render those backgrounds across the full line width instead of only behind printed characters.
41
+
42
+ When FFF is available, pi-pretty now stores frecency/history data under:
43
+
44
+ ```text
45
+ ~/.pi/agent/pi-pretty/fff/
46
+ ```
47
+
48
+ Existing data under `~/.pi/agent/fff` is not migrated automatically by this release.
@@ -0,0 +1,58 @@
1
+ # pi-pretty v0.4.0
2
+
3
+ ## Summary
4
+ This release makes bundled FFF search the primary product direction for `pi-pretty`.
5
+
6
+ `pi-pretty` now owns the built-in `find` / `grep` experience directly via `@ff-labs/fff-node`, includes `multi_grep`, and documents the bundled workflow end-to-end.
7
+
8
+ ## What changed
9
+ - Bundled `@ff-labs/fff-node` as a normal dependency instead of an optional coexistence path.
10
+ - Restored bundled FFF-backed behavior for:
11
+ - `find`
12
+ - `grep`
13
+ - `multi_grep`
14
+ - `/fff-health`
15
+ - `/fff-rescan`
16
+ - Kept the pi-pretty-specific FFF data directory:
17
+ - `~/.pi/agent/pi-pretty/fff/`
18
+ - Updated README to document:
19
+ - bundled FFF ownership
20
+ - install/use flow
21
+ - `multi_grep` examples
22
+ - FFF maintenance commands
23
+ - the requirement not to co-load `pi-fff`
24
+ - Tightened FFF/runtime typing:
25
+ - typed `CursorStore` and `fffFormatGrepText()` against `@ff-labs/fff-node`
26
+ - replaced remaining `src/index.ts` explicit `any` usage in tool wrappers with SDK/FFF-backed types
27
+ - typed `find`, `grep`, and `multi_grep` params/results/render paths against Pi tool inputs and FFF result interfaces
28
+ - removed several dead imports/constants and a non-null assertion in renderer code
29
+
30
+ ## Files
31
+ - `src/index.ts`
32
+ - `src/fff-helpers.ts`
33
+ - `test/fff-integration.test.ts`
34
+ - `test/image-rendering.test.ts`
35
+ - `README.md`
36
+ - `package.json`
37
+ - `package-lock.json`
38
+
39
+ ## Verification
40
+ - `npm run typecheck` ✅
41
+ - `npm test` ✅ (47 tests)
42
+ - `npm run lint -- --max-diagnostics=120` ✅
43
+ - `rg "\\bany\\b" src/index.ts src/fff-helpers.ts` ✅ no matches
44
+
45
+ ## Upgrade notes
46
+ - Use only `pi-pretty` for bundled FFF mode:
47
+
48
+ ```bash
49
+ pi install npm:@heyhuynhgiabuu/pi-pretty
50
+ ```
51
+
52
+ - Do **not** also load `pi-fff` in the same Pi setup.
53
+ - To inspect or refresh the bundled index inside Pi, use:
54
+
55
+ ```text
56
+ /fff-health
57
+ /fff-rescan
58
+ ```
@@ -4,12 +4,14 @@
4
4
  * Pure functions and classes used by the FFF integration in index.ts.
5
5
  */
6
6
 
7
+ import type { GrepCursor, GrepMatch } from "@ff-labs/fff-node";
8
+
7
9
  /**
8
10
  * Store for FFF grep pagination cursors.
9
11
  * Evicts oldest entry when exceeding maxSize.
10
12
  */
11
13
  export class CursorStore {
12
- private cursors = new Map<string, any>();
14
+ private cursors = new Map<string, GrepCursor>();
13
15
  private counter = 0;
14
16
  private maxSize: number;
15
17
 
@@ -17,7 +19,7 @@ export class CursorStore {
17
19
  this.maxSize = maxSize;
18
20
  }
19
21
 
20
- store(cursor: any): string {
22
+ store(cursor: GrepCursor): string {
21
23
  const id = `fff_c${++this.counter}`;
22
24
  this.cursors.set(id, cursor);
23
25
  if (this.cursors.size > this.maxSize) {
@@ -27,7 +29,7 @@ export class CursorStore {
27
29
  return id;
28
30
  }
29
31
 
30
- get(id: string): any | undefined {
32
+ get(id: string): GrepCursor | undefined {
31
33
  return this.cursors.get(id);
32
34
  }
33
35
 
@@ -40,7 +42,7 @@ export class CursorStore {
40
42
  * Convert FFF GrepResult items to ripgrep-style "file:line:content" text.
41
43
  * This ensures pi-pretty's renderGrepResults works unchanged.
42
44
  */
43
- export function fffFormatGrepText(items: any[], limit: number): string {
45
+ export function fffFormatGrepText(items: GrepMatch[], limit: number): string {
44
46
  const capped = items.slice(0, limit);
45
47
  if (!capped.length) return "No matches found";
46
48
 
@@ -58,8 +60,7 @@ export function fffFormatGrepText(items: any[], limit: number): string {
58
60
  lines.push(`${match.relativePath}-${startLine + i}-${match.contextBefore[i]}`);
59
61
  }
60
62
  }
61
- const content =
62
- match.lineContent.length > 500 ? `${match.lineContent.slice(0, 500)}...` : match.lineContent;
63
+ const content = match.lineContent.length > 500 ? `${match.lineContent.slice(0, 500)}...` : match.lineContent;
63
64
  lines.push(`${match.relativePath}:${match.lineNumber}:${content}`);
64
65
  if (match.contextAfter?.length) {
65
66
  const startLine = match.lineNumber + 1;