pi-optimizer 0.7.0-alpha.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 surgent
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # pi-optimizer
2
+
3
+ Context optimization extension for [Pi](https://github.com/earendil-works/pi). It gives coding agents more useful context by improving code navigation and reducing repeated or noisy tool output. It is also built into [surgent](https://github.com/thien2218/surgent).
4
+
5
+ ## Why use it
6
+
7
+ Long coding sessions accumulate large tool results, repeated file content, and output that no longer helps with current task. That context costs tokens and can distract model from relevant code.
8
+
9
+ `pi-optimizer` keeps useful evidence while removing avoidable noise. It works automatically after installation and adds structural tools for reading only code needed for current task.
10
+
11
+ ## What it does
12
+
13
+ - Adds `code_map`, which uses Tree-sitter to index symbols and declarations before files are read in full.
14
+ - Adds `inspect`, which returns one selected symbol body for targeted code reading and edits.
15
+ - Supports TypeScript, JavaScript, Python, Go, Java, and Rust code navigation.
16
+ - Compacts Bash output by stripping terminal control sequences and collapsing repeated or similar lines.
17
+ - Formats grep results by grouping matches under file paths and stores smaller summaries in session history.
18
+ - Removes older `read` and `inspect` results when newer results fully cover same content.
19
+ - Prunes empty tool results and superseded tool calls from model context and persisted sessions.
20
+
21
+ These changes reduce context growth, improve prompt-cache reuse, and leave more room for requirements, code, and reasoning.
22
+
23
+ ## Requirements
24
+
25
+ - Node.js 22.19 or newer
26
+ - Pi coding agent
27
+
28
+ ## Install
29
+
30
+ Install package through Pi:
31
+
32
+ ```bash
33
+ pi install npm:pi-optimizer
34
+ ```
35
+
36
+ Confirm installation:
37
+
38
+ ```bash
39
+ pi list
40
+ ```
41
+
42
+ Start or restart Pi in a repository. Extension loads automatically; agent can then use `code_map` and `inspect`, while output optimization runs in background.
43
+
44
+ > **Important:** surgent already includes this extension. Do not install standalone package alongside surgent in same configuration, because both copies would register same tools and hooks.
45
+
46
+ ## License
47
+
48
+ [MIT](LICENSE)