@floydous/pi-agent-kernel 0.2.0 → 0.3.0
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/CHANGELOG.md +25 -0
- package/README.md +73 -86
- package/docs/testing.md +10 -9
- package/package.json +5 -4
- package/src/dedup/content_store.ts +365 -365
- package/src/index.ts +918 -918
- package/src/retrieval/ast_search.ts +930 -930
- package/src/retrieval/repomap.ts +192 -7
- package/src/retrieval/search_bm25.ts +190 -190
- package/src/retrieval/search_chunker.ts +254 -254
- package/src/retrieval/symbol_reader.ts +198 -203
- package/src/retrieval/tree_sitter_engine.ts +1 -1
- package/src/safety/epistemic_guard.ts +8 -1
- package/src/tools/ast_search_formatter.ts +161 -0
- package/src/tools/ast_search_tool.ts +17 -10
- package/src/tools/context.ts +20 -20
- package/src/tools/lsp_tool.ts +13 -2
- package/src/ui/tui_utils.ts +278 -278
- package/static/with-agent-kernel.png +0 -0
- package/static/without-agent-kernel-1.png +0 -0
- package/static/without-agent-kernel-2.png +0 -0
- package/static/without-agent-kernel-3.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0] - 2026-09-07
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Hierarchical grouped formatting for AST code search: search results are now cleanly organized by file and category, eliminating repetitive file path noise and significantly cutting down token usage.
|
|
8
|
+
- Bounded symbol body previews with clear truncation markers when previewing symbol contents.
|
|
9
|
+
- Strict cold-start symbol fallback coverage across 11 programming languages (TypeScript, JavaScript, Python, Rust, Go, Java, C#, C/C++, Ruby, PHP, and Bash), ensuring accurate symbol indexing even before syntax engines are fully loaded.
|
|
10
|
+
- Automated GitHub Actions CI workflow and release publishing workflows.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Cleaner, copy-paste-ready symbol reading: reading specific code symbols now outputs clean code directly without line number prefixes, saving ~21% tokens per read and making edits directly applicable.
|
|
15
|
+
- Condensed AST search signatures: cleaned redundant keywords (like `function`, `public`, `def`) while preserving important modifiers (like `async`, `static`, `readonly`) and parameter types.
|
|
16
|
+
- Unified testing workflow: streamlined the entire test suite under a single command (`npm test`) organized by clear functional areas instead of numbered sections.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Fixed missing methods and functions in cold-state project indexing for TypeScript, JavaScript, C#, and C++.
|
|
21
|
+
- Fixed incorrect classification of Go receiver methods and PHP class methods during cold-state scans.
|
|
22
|
+
- Prevented internal local variables from mistakenly leaking into project symbol maps.
|
|
23
|
+
- Fixed misleading alias tags on typed methods and property getters/setters.
|
|
24
|
+
- Fixed temporary loading artifacts showing up in language server hover documentation.
|
|
25
|
+
- Improved code reference snippets when language servers return empty results.
|
|
26
|
+
|
|
3
27
|
## [0.2.0] - 2026-09-05
|
|
4
28
|
|
|
5
29
|
This release replaces the old line-based symbol extraction path with a Tree-sitter WASM parser where a bundled grammar is available, while keeping the scanner fallback for unsupported or unavailable languages.
|
|
@@ -29,4 +53,5 @@ This release replaces the old line-based symbol extraction path with a Tree-sitt
|
|
|
29
53
|
- Syntax errors are reported on extracted file tags.
|
|
30
54
|
- LSP reference filtering preserves the intended fallback behavior.
|
|
31
55
|
|
|
56
|
+
[0.3.0]: https://github.com/floydous/pi-agent-kernel/compare/v0.2.0...v0.3.0
|
|
32
57
|
[0.2.0]: https://github.com/floydous/pi-agent-kernel/releases/tag/v0.2.0
|
package/README.md
CHANGED
|
@@ -1,125 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-agent-kernel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Most coding agents drown in context. They read entire files when looking for a single function, dump thousands of lines of terminal logs into prompts, and rewrite full files just to tweak one line. `pi-agent-kernel` is built around a straightforward rule: **spend the bare minimum tokens necessary to get maximum workflow performance**. It provides surgical retrieval, bounded outputs, and guarded editing tools so your model stays fast, focused, and well within budget.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Token savings
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Here is how tool overhead compares to an unconstrained agent harness across everyday coding tasks:
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
| Interaction | Traditional agent harness | `pi-agent-kernel` | Tokens saved | Why |
|
|
14
|
+
|---|---|---|---|---|
|
|
15
|
+
| **Project orientation** | Walks directory tree, reads dozens of files (~92.8k tokens) | PageRank AST repository map (~1.0k tokens) | **~99% fewer tokens** | Only index-relevant code symbols and signatures are loaded. |
|
|
16
|
+
| **Inspecting a function** | Reads the full file (~1.5k–4.0k tokens) | Surgical symbol read: `read(symbol="foo")` (~420 tokens) | **~70–90% fewer tokens** | Pulls just the target AST node; skips line-number prefixes. |
|
|
17
|
+
| **Patching code** | Re-emits entire file content (~2.0k+ tokens) | Surgical search/replace block (`edit`) (~60 tokens) | **~95% fewer tokens** | Only generates the exact lines that change. |
|
|
18
|
+
| **Running tests / builds** | Floods context with raw build logs (~20k+ tokens) | Clamped output with disk spillover (~1.0k tokens) | **~95% context saved** | Full logs are written to disk; agent sees head, tail, and log path. |
|
|
19
|
+
| **AST symbol search** | Repeated absolute paths per match (~1.8k tokens) | Hierarchical grouped layout (~1.2k tokens) | **~34% fewer tokens** | Groups matching symbols under shared files and kinds. |
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
---
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
## Quick start
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
### 1. Install
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
Install the extension directly with Pi's package manager:
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
```bash
|
|
30
|
+
# Global install (recommended)
|
|
31
|
+
pi install npm:@floydous/pi-agent-kernel
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
# Or install locally for the current repository only
|
|
34
|
+
pi install -l npm:@floydous/pi-agent-kernel
|
|
35
|
+
```
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|---|---|---|---|---|
|
|
31
|
-
| **Context Ingestion** (Workspace map) | Raw recursive tree / full dump (~92.8k tokens) | PageRank AST Repo Map (~1.0k tokens) | **-98.9%** context tokens | ~40 ms |
|
|
32
|
-
| **Code Inspection** (Targeted function read) | Whole file read (~1.4k tokens) | AST Symbol Extraction (`read(symbol=...)`) (~428 tokens) | **-68.5%** prompt tokens | <1 ms |
|
|
33
|
-
| **Code Mutation** (Surgical function patch) | Full file rewrite (~1.4k tokens in tool payload) | Surgical search/replace (`edit`) (~58 tokens) | **-95.7%** output tokens | <5 ms |
|
|
34
|
-
| **Command Execution** (Large test/build output) | Unbounded stream (~27.5k tokens) | Bounded Clamp + Disk Spillover (~1.1k tokens) | **-95.9%** flood tokens prevented | Instant |
|
|
35
|
-
| **Codebase Search** (Lexical / BM25 Query) | Linear `grep`/`find` disk scan | Inverted In-Memory BM25 Index | **0 MB** background RAM (Lean) | ~0.03 ms / query |
|
|
36
|
-
| **Pre-Commit Safety** (Broken syntax gate) | Allowed to commit broken code | Local Fast AST Delimiter Gate | **Deterministic** failure block | Instant |
|
|
37
|
+
Restart Pi or start a new session. The extension registers its tools, guards, and status indicators automatically.
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
---
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
### 2. Configure the retrieval engine (`/engine`)
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
`pi-agent-kernel` includes an in-memory retrieval engine for keyword and semantic searches:
|
|
43
44
|
|
|
45
|
+
```text
|
|
46
|
+
/engine status
|
|
44
47
|
```
|
|
45
|
-
pi-agent-kernel/
|
|
46
|
-
├── src/
|
|
47
|
-
│ ├── index.ts # Main extension entry point
|
|
48
|
-
│ ├── config/ # Hierarchical TOML configuration loader
|
|
49
|
-
│ ├── context/ # Context engineering and session repair
|
|
50
|
-
│ ├── editing/ # Surgical patching and verification
|
|
51
|
-
│ ├── lsp/ # Language Server Protocol integration
|
|
52
|
-
│ ├── retrieval/ # AST, BM25, and semantic code search
|
|
53
|
-
│ ├── safety/ # Epistemic guards and bounded execution
|
|
54
|
-
│ ├── tools/ # Pi tool registrations
|
|
55
|
-
│ └── ui/ # Terminal UI components
|
|
56
|
-
├── tests/ # Focused verification sections
|
|
57
|
-
├── docs/ # Project documentation and guides
|
|
58
|
-
├── config.toml # Live configuration
|
|
59
|
-
└── package.json # Extension manifest
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Tool suite
|
|
63
48
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
| `write` | Complete new-file authoring | Direct write |
|
|
69
|
-
| `get_repo_map` | PageRank-ranked repository AST definitions | Pure code symbols without import noise (~1k tokens) |
|
|
70
|
-
| `ast_search` | AST structure search across definitions | Concise `file:line [kind] signature` |
|
|
71
|
-
| `code_search` | Hybrid BM25 and semantic AST chunk search | Compact `file:start-end (breadcrumb)` snippets |
|
|
72
|
-
| `lsp` | Realtime Language Server Protocol queries | Compact `def`, `ref`, and structural symbols |
|
|
73
|
-
| `recall` | Restore an exact deduplicated tool result by reference | Bare original output content |
|
|
74
|
-
| `search_tools` | Deferred tool discovery | On-demand tool capability matching |
|
|
49
|
+
- **`lean`** *(default)*: Fast, AST-aware BM25 search. Consumes 0 MB background model RAM.
|
|
50
|
+
- **`hybrid`**: BM25 keyword search blended with lightweight local 256-dimension embeddings.
|
|
51
|
+
- **`full`**: Dense 768-dimension semantic embeddings for deep conceptual queries across large codebases.
|
|
52
|
+
- **`off`**: Turns off local index building if you only want AST and LSP tools.
|
|
75
53
|
|
|
76
|
-
|
|
54
|
+
Switch profiles at any time:
|
|
55
|
+
```text
|
|
56
|
+
/engine hybrid
|
|
57
|
+
# or
|
|
58
|
+
/engine full
|
|
59
|
+
```
|
|
77
60
|
|
|
78
|
-
|
|
79
|
-
- **Output Clamping**: Limits stdout and stderr so they do not fill the context window, while saving complete output to disk.
|
|
80
|
-
- **Tool Result Deduplication**: Replaces byte-identical repeated output with a small `[=rN,sizeB,tool,paramsKey]` notice that can be recovered with `recall`.
|
|
81
|
-
- **Bounded Syntax Verification**: Runs a fast local check on mutations before committing changes to disk.
|
|
61
|
+
---
|
|
82
62
|
|
|
83
|
-
|
|
63
|
+
### 3. Setup language servers (`/lsp`)
|
|
84
64
|
|
|
85
|
-
|
|
65
|
+
Get real-time compiler diagnostics, definitions, and references without manual setup:
|
|
86
66
|
|
|
87
|
-
```
|
|
88
|
-
|
|
67
|
+
```text
|
|
68
|
+
/lsp
|
|
89
69
|
```
|
|
90
70
|
|
|
91
|
-
|
|
71
|
+
Running `/lsp` opens an interactive management screen showing active servers, connection status, and one-click installs for detected workspace languages.
|
|
92
72
|
|
|
93
|
-
|
|
94
|
-
|
|
73
|
+
Alternatively, install a server directly from the command line:
|
|
74
|
+
```text
|
|
75
|
+
/lsp install <language> # e.g., python, typescript, rust, go, csharp, etc.
|
|
95
76
|
```
|
|
96
77
|
|
|
97
|
-
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### 4. Tip: Turn off Pi documentation when working on your own projects
|
|
98
81
|
|
|
99
|
-
|
|
82
|
+
By default, Pi loads system prompt instructions explaining how to extend Pi itself (extensions, themes, skills, and TUI APIs).
|
|
100
83
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
| `/pi-docs` | `on\|off\|status` | Toggle Pi documentation guidance in the system prompt for the current session. |
|
|
84
|
+
When you are working on your own software—such as a React app, a Python backend, or a Rust crate—those internal Pi instructions take up room in your prompt that you do not need. You can silence them for the current session with:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
/pi-docs off
|
|
88
|
+
```
|
|
107
89
|
|
|
108
|
-
|
|
90
|
+
Turn it back on with `/pi-docs on` whenever you switch back to hacking on Pi extensions.
|
|
109
91
|
|
|
110
|
-
|
|
92
|
+
---
|
|
111
93
|
|
|
112
|
-
|
|
94
|
+
## Tool reference
|
|
113
95
|
|
|
114
|
-
|
|
96
|
+
| Tool | What it does |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `read` | Read specific lines or extract an exact function, class, or type via AST (`symbol="name"`). |
|
|
99
|
+
| `edit` | Apply surgical search/replace patches with built-in syntax checks. |
|
|
100
|
+
| `write` | Create new files or perform complete rewrites when explicitly requested. |
|
|
101
|
+
| `get_repo_map` | Retrieve a concise, PageRank-ranked symbol overview of the codebase (~1k tokens). |
|
|
102
|
+
| `ast_search` | Search declarations across files using Tree-sitter AST queries, grouped cleanly by file. |
|
|
103
|
+
| `code_search` | Hybrid keyword and semantic chunk search with breadcrumb locations. |
|
|
104
|
+
| `lsp` | Query definitions, references, type hover docs, and diagnostics directly from language servers. |
|
|
105
|
+
| `recall` | Retrieve the full text of a deduplicated output previously replaced by a short reference tag. |
|
|
106
|
+
| `search_tools` | Search and activate deferred tools on demand. |
|
|
115
107
|
|
|
116
|
-
|
|
117
|
-
- [`docs/retrieval.md`](docs/retrieval.md): search profile semantics
|
|
118
|
-
- [`docs/editing-and-verification.md`](docs/editing-and-verification.md): patch and verification pipeline
|
|
119
|
-
- [`docs/lsp.md`](docs/lsp.md): LSP integration and registry
|
|
120
|
-
- [`docs/configuration.md`](docs/configuration.md): TOML schema and precedence
|
|
121
|
-
- [`docs/testing.md`](docs/testing.md): section-based test layout
|
|
108
|
+
---
|
|
122
109
|
|
|
123
110
|
## License
|
|
124
111
|
|
|
125
|
-
ISC
|
|
112
|
+
ISC
|
package/docs/testing.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Testing
|
|
2
2
|
|
|
3
|
-
The suite is split into focused
|
|
3
|
+
The suite is split into focused suite directories under `tests/`. Each suite is
|
|
4
4
|
independently runnable and uses isolated temporary workspaces where needed.
|
|
5
5
|
|
|
6
6
|
## Commands
|
|
@@ -9,24 +9,25 @@ independently runnable and uses isolated temporary workspaces where needed.
|
|
|
9
9
|
# Full suite
|
|
10
10
|
npm test
|
|
11
11
|
|
|
12
|
-
# Direct section orchestrator
|
|
13
|
-
npm run test:focused
|
|
14
|
-
|
|
15
12
|
# One focused section
|
|
16
|
-
npx tsx tests/
|
|
13
|
+
npx tsx tests/epistemic-guard/index.ts
|
|
17
14
|
```
|
|
18
15
|
|
|
19
|
-
`npm test` runs the
|
|
16
|
+
`npm test` runs the suite orchestrator under `tests/`.
|
|
20
17
|
|
|
21
18
|
## Verification policy
|
|
22
19
|
|
|
23
20
|
Prefer the narrowest useful check first:
|
|
24
21
|
|
|
25
|
-
1. Run the focused
|
|
22
|
+
1. Run the focused suite related to a change.
|
|
26
23
|
2. Run bounded TypeScript/LSP diagnostics for changed implementation files.
|
|
27
24
|
3. Run the full suite once the focused checks are understood.
|
|
28
25
|
4. Review `git diff --check` and the final working-tree status.
|
|
29
26
|
|
|
30
27
|
The suite covers AST extraction, repository maps, patching, syntax checks,
|
|
31
|
-
session repair, retrieval, output clamping, LSP support,
|
|
32
|
-
|
|
28
|
+
session repair, retrieval, output clamping, LSP support, configuration,
|
|
29
|
+
lifecycle integration, and post-edit verification.
|
|
30
|
+
|
|
31
|
+
The `cold-process-ast` suite launches a fresh process per language and checks
|
|
32
|
+
required symbols, kinds, and local-scope exclusions. This catches warm singleton
|
|
33
|
+
state masking fallback defects.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floydous/pi-agent-kernel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Focused code retrieval, editing, safety checks, and language-server support for Pi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"author": "floydous https://github.com/floydous",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "npx tsx tests/run-all.ts",
|
|
12
|
-
"test:focused": "npx tsx tests/run-all.ts",
|
|
13
12
|
"typecheck": "tsc --noEmit"
|
|
14
13
|
},
|
|
15
14
|
"dependencies": {
|
|
@@ -40,10 +39,12 @@
|
|
|
40
39
|
"src",
|
|
41
40
|
"grammars",
|
|
42
41
|
"README.md",
|
|
43
|
-
"static",
|
|
44
42
|
"docs",
|
|
45
43
|
"LICENSE",
|
|
46
44
|
"config.toml",
|
|
47
45
|
"CHANGELOG.md"
|
|
48
|
-
]
|
|
46
|
+
],
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
49
50
|
}
|