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.
- package/README.md +1 -1
- package/index.js +7 -26
- 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.
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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();
|