surgent 0.7.0-alpha.1 → 0.7.0-alpha.3

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 (44) hide show
  1. package/README.md +4 -25
  2. package/dist/optimizer/LICENSE +21 -0
  3. package/dist/optimizer/README.md +48 -0
  4. package/dist/optimizer/index.js +1984 -0
  5. package/dist/optimizer/index.js.map +7 -0
  6. package/dist/optimizer/package.json +31 -0
  7. package/dist/optimizers/README.md +48 -0
  8. package/dist/optimizers/index.js +1 -1
  9. package/dist/optimizers/index.js.map +1 -1
  10. package/dist/optimizers/package.json +2 -2
  11. package/package.json +2 -2
  12. package/src/optimizer/README.md +48 -0
  13. package/src/{optimizers → optimizer}/languages/grammar.ts +1 -1
  14. /package/src/{optimizers → optimizer}/compactor/bash.ts +0 -0
  15. /package/src/{optimizers → optimizer}/compactor/grep.ts +0 -0
  16. /package/src/{optimizers → optimizer}/compactor/index.ts +0 -0
  17. /package/src/{optimizers → optimizer}/deduplicator/helpers.ts +0 -0
  18. /package/src/{optimizers → optimizer}/deduplicator/index.ts +0 -0
  19. /package/src/{optimizers → optimizer}/deduplicator/resources.ts +0 -0
  20. /package/src/{optimizers → optimizer}/deduplicator/state.ts +0 -0
  21. /package/src/{optimizers → optimizer}/deduplicator/types.ts +0 -0
  22. /package/src/{optimizers → optimizer}/entries.ts +0 -0
  23. /package/src/{optimizers → optimizer}/index.ts +0 -0
  24. /package/src/{optimizers → optimizer}/inspector/helpers.ts +0 -0
  25. /package/src/{optimizers → optimizer}/inspector/index.ts +0 -0
  26. /package/src/{optimizers → optimizer}/inspector/inspect.ts +0 -0
  27. /package/src/{optimizers → optimizer}/inspector/types.ts +0 -0
  28. /package/src/{optimizers → optimizer}/languages/go.ts +0 -0
  29. /package/src/{optimizers → optimizer}/languages/index.ts +0 -0
  30. /package/src/{optimizers → optimizer}/languages/java.ts +0 -0
  31. /package/src/{optimizers → optimizer}/languages/python.ts +0 -0
  32. /package/src/{optimizers → optimizer}/languages/rust.ts +0 -0
  33. /package/src/{optimizers → optimizer}/languages/symbols.ts +0 -0
  34. /package/src/{optimizers → optimizer}/languages/tree-sitter-languages.d.ts +0 -0
  35. /package/src/{optimizers → optimizer}/languages/types.ts +0 -0
  36. /package/src/{optimizers → optimizer}/languages/typescript.ts +0 -0
  37. /package/src/{optimizers → optimizer}/mapper/files.ts +0 -0
  38. /package/src/{optimizers → optimizer}/mapper/index.ts +0 -0
  39. /package/src/{optimizers → optimizer}/mapper/types.ts +0 -0
  40. /package/src/{optimizers → optimizer}/pruner/cleanup.ts +0 -0
  41. /package/src/{optimizers → optimizer}/pruner/context.ts +0 -0
  42. /package/src/{optimizers → optimizer}/pruner/index.ts +0 -0
  43. /package/src/{optimizers → optimizer}/pruner/session.ts +0 -0
  44. /package/src/{optimizers → optimizer}/pruner/types.ts +0 -0
package/README.md CHANGED
@@ -74,30 +74,9 @@ npm install -g surgent@latest # update
74
74
  npm uninstall -g surgent # remove
75
75
  ```
76
76
 
77
- ## Optimizers for Pi
77
+ ## Optimizer package
78
78
 
79
- `pi-context-optimizers` is a Pi extension package that keeps code navigation and tool output focused, while being cache friendly. This extension is already built into surgent.
80
-
81
- - `code_map` and `inspect` use Tree-sitter to navigate symbols and declarations in TypeScript/JavaScript, Python, Go, Java, and Rust.
82
- - It compacts noisy Bash and grep output.
83
- - It deduplicates previously read resource content, removes superseded `read` or `inspect` results
84
- - It prunes empty `ls` or `find` results from context.
85
-
86
- To use the optimizers with Pi instead of surgent, install the standalone package:
87
-
88
- > **Important:** Install either surgent or `pi-context-optimizers` on a machine or configuration, not both. Surgent already includes the optimizers; installing both registers duplicate tools and hooks.
89
-
90
- ```bash
91
- pi install npm:pi-context-optimizers
92
- ```
93
-
94
- Verify the package is installed:
95
-
96
- ```bash
97
- pi list
98
- ```
99
-
100
- Start Pi in a repository, then ask the agent to use `code_map` to locate symbols and `inspect` to read a selected declaration.
79
+ surgent includes [`pi-context-optimizer`](https://www.npmjs.com/package/pi-context-optimizer), a standalone Pi extension for structural code navigation and automatic context cleanup. Install it separately when using Pi without surgent; package page covers features and setup.
101
80
 
102
81
  ## Connect a model
103
82
 
@@ -383,12 +362,12 @@ pnpm install
383
362
  npm link
384
363
  ```
385
364
 
386
- `pnpm build` builds only the distributable optimizer package in `dist/optimizers`. npm runs this build automatically through `prepack` when packaging surgent.
365
+ `pnpm build` builds only the distributable optimizer package in `dist/optimizer`. npm runs this build automatically through `prepack` when packaging surgent.
387
366
 
388
367
  To publish the standalone optimizer artifact after building it:
389
368
 
390
369
  ```bash
391
- npm publish ./dist/optimizers --access public
370
+ npm publish ./dist/optimizer --access public
392
371
  ```
393
372
 
394
373
  ## Reference
@@ -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.
@@ -0,0 +1,48 @@
1
+ # pi-context-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-context-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-context-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)