pi-rg-fd 0.2.0 → 0.2.1

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +7 -26
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -37,7 +37,7 @@ Execute bash commands (ls, rg, fd, etc.)
37
37
  Use bash for file operations like ls, rg, fd
38
38
  ```
39
39
 
40
- `rg` and `fd` are shorter than `grep` and `find`. If neither line is present (a custom system prompt, or a future Pi release that rewords them), the hook returns without changing the prompt. The `before_agent_start` hook is a string replace cached by the prompt text, so the same input always yields the same output.
40
+ `rg` and `fd` are shorter than `grep` and `find`. If neither line is present (a custom system prompt, or a future Pi release that rewords them), the hook returns without changing the prompt.
41
41
 
42
42
  Pi's interactive mode downloads `rg` and `fd` when they are missing, into `~/.pi/agent/bin` (or `$PI_CODING_AGENT_DIR/bin` when that variable is set; a leading `~` is expanded). Bash calls see that directory on `PATH`. The managed files are named `rg` and `fd`, plus `.exe` on Windows.
43
43
 
package/index.js CHANGED
@@ -1,29 +1,10 @@
1
1
  import { rewritePrompt } from "./prompt.js";
2
2
 
3
- const CACHE_LIMIT = 8;
4
-
5
- export function createExtension() {
6
- /** @type {Map<string, string>} */
7
- const cache = new Map();
8
-
9
- return function piRgFd(pi) {
10
- pi.on("before_agent_start", (event) => {
11
- const input = event.systemPrompt;
12
- if (typeof input !== "string") return;
13
-
14
- let output = cache.get(input);
15
- if (output !== undefined) {
16
- cache.delete(input);
17
- cache.set(input, output);
18
- } else {
19
- output = rewritePrompt(input);
20
- cache.set(input, output);
21
- if (cache.size > CACHE_LIMIT) cache.delete(cache.keys().next().value);
22
- }
23
-
24
- if (output !== input) return { systemPrompt: output };
25
- });
26
- };
3
+ export default function piRgFd(pi) {
4
+ pi.on("before_agent_start", (event) => {
5
+ const input = event.systemPrompt;
6
+ if (typeof input !== "string") return;
7
+ const next = rewritePrompt(input);
8
+ return next !== input ? { systemPrompt: next } : undefined;
9
+ });
27
10
  }
28
-
29
- export default createExtension();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-rg-fd",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Pi extension that rewrites the default grep/find prompt lines to rg and fd.",
5
5
  "type": "module",
6
6
  "main": "index.js",