pi-for-each 0.1.0 → 0.1.2
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 +5 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
# pi-for
|
|
1
|
+
# pi-for-each
|
|
2
2
|
|
|
3
|
-
A [pi](https://github.com/earendil-works/pi) extension that adds a `/for`
|
|
4
|
-
prompt-loop command with variable insertion over directory children or file
|
|
5
|
-
lines.
|
|
3
|
+
A [pi](https://github.com/earendil-works/pi) extension that adds a `/for`-`$each` prompt loop – and hides it from your LLM! Supports children-in-directory and line-in-files iteration.
|
|
6
4
|
|
|
7
5
|
## Why
|
|
8
6
|
|
|
9
|
-
Like subagents but much simpler, sequential and with more control for the user. Instead of describing the loop to the agent, just make a loop. No need to tell the agent about your control structure if you already know the control structure.
|
|
7
|
+
Like subagents but much simpler, sequential and with more control for the user. Instead of describing the loop to the agent, just make a loop. No need to tell the agent about your control structure if you already know the control structure. Each iteration the LLM only sees the necessary context and the iteration prompt, no other iterations. This prevents bias drift or context rot compared to a loop that repeats commands and execution within the same context.
|
|
10
8
|
|
|
11
9
|
## Demo
|
|
12
10
|
|
|
@@ -22,8 +20,7 @@ Like subagents but much simpler, sequential and with more control for the user.
|
|
|
22
20
|
|
|
23
21
|
## What it does
|
|
24
22
|
|
|
25
|
-
Compose a message that contains a `$each@<path>` token (dollar + `each` + at-sign
|
|
26
|
-
+ a file or directory path), then invoke it as the **`/for` command**:
|
|
23
|
+
Compose a message that contains a `$each@<path>` token (dollar + `each` + at-sign + a file or directory path), then invoke it as the **`/for` command**:
|
|
27
24
|
|
|
28
25
|
```
|
|
29
26
|
/for Please reword the skill in $each@./skills/ and make it more polite
|
|
@@ -90,18 +87,11 @@ iteration.
|
|
|
90
87
|
- The submitted message must start with `/for` so that pi's command pipeline
|
|
91
88
|
routes it to the handler. A bare `$each@<path>` message submitted as a normal
|
|
92
89
|
message is not a command and is intercepted with a hint to use `/for`.
|
|
93
|
-
- **Why the old approach failed:** `ExtensionAPI.sendUserMessage()` internally
|
|
94
|
-
calls `prompt(text, { expandPromptTemplates: false, … })`, and pi only runs
|
|
95
|
-
slash/extension commands when `expandPromptTemplates` is true. So sending
|
|
96
|
-
`"/clone"` via `sendUserMessage` never executed the command — it was just
|
|
97
|
-
appended as a literal user message into the *same* session, which is why every
|
|
98
|
-
iteration chained linearly into one session. The fix uses the real
|
|
99
|
-
`ctx.fork()` instead.
|
|
100
90
|
- The `$each@` fuzzy search reuses pi's built-in fuzzy file/directory provider
|
|
101
91
|
(`CombinedAutocompleteProvider.getFuzzyFileSuggestions`) via a wrapping
|
|
102
92
|
`AutocompleteProvider`, with a `readdir` fallback. The editor is extended so
|
|
103
93
|
that typing `$each@` opens that search exactly as `@` after a space does.
|
|
104
|
-
- The full token — starting at the dollar sign and including `
|
|
94
|
+
- The full token — starting at the dollar sign and including `each`, `@` and the
|
|
105
95
|
path, up to (but not including) the first following whitespace — is replaced by
|
|
106
96
|
the iteration value. Not just the path.
|
|
107
97
|
|
package/package.json
CHANGED