@floydous/pi-agent-kernel 0.3.1 → 0.3.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.
@@ -0,0 +1,10 @@
1
+ ## Tool Selection
2
+ - **Known identifier / error string / symbol:** Use `rg` (via bash) directly with specific symbols or assertion phrases. Avoid broad single-word searches (e.g. `index`, `path`) that return noisy matches.
3
+ - **Unlocated concept with no names:** Use `code_search` to find relevant files.
4
+ - **Code inspection:** When search identifies a file and line, read a targeted range centered on that location via `read(path, offset, limit)`. Plain text reads are default and most token-efficient; request `anchors` only for narrow ranges (<100 lines) when editing with anchors. Use multi-file `paths` when inspecting multiple short files or when their relevant regions are independently known. Use `symbol=` for isolated functions in large files (>500 lines).
5
+
6
+ ## Execution Workflow
7
+ 1. **Turn 1 Grounding:** Check the workspace reproduction diff provided in context under "Workspace Pre-Flight" and run the failing test on Turn 1. Avoid redundant `git diff`, `git log`, or `git status` commands when the reproduction patch is already visible.
8
+ 2. **Root-Cause Layering:** Trace call chains to the callee/producer where the value originates. Fix the root cause, never the downstream caller.
9
+ 3. **Surgical Edits:** Use single-block replacements with 2–3 lines of unique surrounding context for clear anchoring. When a fix spans multiple files, apply them together in one turn using `edit(files: [{path, search, replace}, ...])`.
10
+ 4. **Deterministic Exit:** Run the verification test immediately after editing. When tests pass (exit code 0), conclude immediately with a concise summary. Do not invoke further diffs or checks.
package/CHANGELOG.md CHANGED
@@ -1,19 +1,53 @@
1
1
  # Changelog
2
2
 
3
- ## [0.3.1] - 2026-09-09
3
+ ## [0.3.3] - 2026-09-20
4
4
 
5
5
  ### Added
6
+ - **Multi-File Atomic Edits**: Extended the `edit` tool with `files: { path, search, replace, line_hint, edits }[]` payload (with resilient per-item `path` normalization in `edits`). Implemented a 2-stage atomic commit with preflight validation, duplicate path detection, in-memory snapshot backups, and automatic rollback across all targets if any file fails patch application or syntax verification.
7
+ - **Batch Multi-File `read`**: Extended the `read` tool to accept `paths: string[]` (and resilient alias `path: string[]`), allowing the model to inspect multiple files in one turn while authorizing all targets in `EpistemicGuard`.
8
+ - **Automatic Turn 1 Reproduction Diff Grounding**: In `before_agent_start`, automatically detects unstaged/staged git diffs and injects a sanitized, clamped (max 25 lines, 2KB hard ceiling) reproduction status into initial context with session caching, eliminating redundant Turn 1 exploratory `git status` / `git diff` commands.
6
9
 
7
- - **Adaptive Codebase Profiles**: Introduced `/profile` command with `auto`, `light`, and `heavy` profiles dynamically adjusting repository map token budgets, indexing thresholds, and test file separation based on workspace scale.
8
- - **Bare-Symbol LSP Definition Lookup**: Support looking up symbol definitions directly by symbol name across the workspace without requiring explicit file paths or line/column coordinates.
9
- - **Fuzzy Symbol Suggestions**: When a requested symbol is not found during targeted reading, suggest close matching symbols within the file to guide navigation.
10
- - **LSP Provenance Metadata & Directory Guard**: Explicitly surface result provenance (active language server vs. Tree-sitter fallback) on LSP responses, and guard against passing directory paths to diagnostics.
11
- - **Adaptive Code Search Formatting & Scopes**: Added token-efficient result layouts and scope filtering (`code` vs `all`) for code search.
12
- - **Navigation Session Benchmarks**: Added automated benchmarks evaluating token efficiency and call counts across navigation and discovery tools.
10
+ ### Changed
11
+ - **Read Tool Budgeting & Anchor Guardrails**: Bounded batch reading to 150 lines per file and a 24KB aggregate ceiling with explicit continuation markers (`[truncated: <file>, returned lines 1-150 of <N>. Continue with read(path, offset=151)]`). Added a 100-line cap on explicit `anchors: true` requests (`MAX_ANCHOR_LINES = 100`) to prevent models from generating expensive `#HASH│` line hashes on large files.
12
+ - **Targeted Reading Workflow Guidance**: Updated `AGENT_KERNEL_SYS_PROMPT.md` to emphasize targeted sequential reads (`read(path, offset, limit)`) centered on search coordinates as the primary inspection workflow, reserving batch `paths` for short files or known regions.
13
+ - **Search Specificity Guidance**: Directed agents toward exact identifiers, error symbols, and test phrases, preventing noisy broad single-word searches from polluting conversation context.
14
+
15
+ ### Validated
16
+ - Verified 38 test suites passing (`npm test`) with 0 regressions.
17
+ - Multi-harness benchmarks on `cx/gpt-5.6-luna:high` across all 8 standard tasks demonstrate:
18
+ - **100% Solve Rate (8 / 8 tasks solved)**.
19
+ - **Aggregate task time cut in half**: **600s (10.0m) vs 1,223s (20.4m)** (-50.9% time reduction, **2.04× faster**).
20
+ - **Uncached input tokens reduced by -18.4%**: **270k vs 331k** (-60.8k tokens saved across the suite).
21
+ - **Tool calls reduced**: **107 calls vs 112 calls**.
22
+ - Consistent speedup across all repositories: UFO (36s vs 119s), Fastify (47s vs 177s), p-limit (60s vs 176s), Ky (89s vs 253s), Zod (135s vs 212s), Hono (64s vs 96s), UUID (53s vs 64s), and Picomatch (116s vs 126s).
23
+
24
+ ## [0.3.2] - 2026-09-16
25
+
26
+ ### Added
27
+ - **Statusline Retrieval Indicator & Extension Row Integration**: Relocated the retrieval profile tag from Line 1 to Line 2 (extension statusline via `ctx.ui.setStatus("retrieval", ...)`) alongside external extensions (such as Ponytail), preserving individual extension ANSI colors.
28
+ - **Profile Semantic Glyphs**: Added distinct visual tier glyphs: `🌿 retrieval:bm25` (AST lexical), `◈ retrieval:hybrid-256d` (Matryoshka hybrid), and `🧠 retrieval:dense-768d` (Full semantic).
29
+ - **Live Embedding Throughput & Stream Arrow Status**: Added real-time chunk processing throughput (`chunk/s`) with a static Stream Arrow indicator during workspace indexing (`🧠 retrieval:dense-768d ⇢ 45% (22/48 • 14.2 chunk/s)`).
30
+ - **Automatic Kernel Guidance Injection**: Bundled `AGENT_KERNEL_SYS_PROMPT.md` is injected through Pi's `before_agent_start` lifecycle hook, enabled by default and configurable with `[instructions] enabled = false`.
31
+ - **Benchmark Comparison Chart**: Added the latest aggregate harness comparison graphic at `static/benchmark-comparison.png` for display in the project README.
32
+ - **Six-Harness Cross-Agent Benchmark**: Integrated comprehensive multi-harness comparison runner supporting Pi Kernel, Pi Vanilla, Claude Code, Codex CLI, OMP, and OpenCode across 8 real-world tasks.
33
+ - **Passive Shield Architecture**: Gated exploratory tools (`ast_search`, `get_repo_map`, `lsp`) behind `enable_tools: false` / `PI_ENABLE_ALL_RETRIEVAL_TOOLS=1`, keeping the active tool interface lean (`read`, `edit`, `write`, `bash`, and compact `code_search`) to eliminate per-turn schema overhead and tool distraction loops.
34
+ - **Deterministic Delimiter Auto-Healing**: Added patch-scoped lexical delimiter balancing and Tree-sitter AST repair (`MISSING` node detection) to automatically recover truncated closing braces/brackets (`})`, `};`, `]}`) pre-write.
35
+ - **Line-Hinted Range Disambiguation & Multi-Block Line Deltas**: Added optional `line_hint`, `start_line`, and `end_line` parameters (supporting both camelCase and snake_case) to `edit` with sequential delta tracking to disambiguate identical search blocks without line-hash bloat.
36
+ - **Capped Plain-Text Reads**: Enforced 50KB / 2,000-line caps on broad reads with continuation hints (`offset`) and oversized line detection, recording precise exposure ranges in `EpistemicGuard`.
37
+ - **Model Property Aliasing & Epistemic Confirmation**: Supported model convention drift across parameter names (`search`/`replace`, `old`/`new`, `old_text`/`new_text`) and emitted concise positive confirmation strings (`Successfully applied edit to <file>.`) to prevent paranoid agent verification loops.
13
38
 
14
39
  ### Changed
40
+ - Included `AGENT_KERNEL_SYS_PROMPT.md` in the published package so automatic guidance works after installation.
41
+ - Added lifecycle coverage for guidance injection, duplicate prevention, and the disabled configuration path.
42
+ - **Tool Description Optimization**: Completely redesigned tool descriptions for `read` and `edit` to explicitly declare clean plain-text defaults and precision parameter expectations, dropping 10k+ prompt inflation tokens on real benchmarks.
43
+ - **Diagnostic Benchmark**: Cut token consumption by 50.6% (762k vs 1.54M total turn tokens) and reduced tool calls by 24.8% (112 vs 149) compared to unguided Pi Vanilla on the 8-task Luna High diagnostic suite.
44
+ - **Historical Benchmark**: In the initial v0.3.1-to-v0.4.0 Passive Shield evaluation, token consumption dropped from 1,214,112 tokens down to 465,139 tokens (-61.7%) across 8 real-world repositories.
45
+ - **Persistent Vector Profiles**: Preserved dimension-specific binary caches (`vectors-256d.bin`, `vectors-768d.bin`) on disk across profile switches, preventing cache loss when toggling to BM25.
46
+ - **On-Demand Embedder Loading**: Removed premature model preloading on startup; weights load on-demand only when unindexed chunks are detected.
15
47
 
16
- - **Compact Tool Schemas**: Minified tool descriptions and schemas across tools to reduce system prompt overhead and save context tokens.
17
- - **Optimized Repository Map Ranking**: Enhanced PageRank scoring heuristics and budget management to prioritize core implementation symbols over tests and boilerplate.
48
+ ### Fixed
49
+ - **Startup Background Indexing Visibility**: Fixed a bug where workspace indexing on `session_start` ran silently in the background without updating the UI statusline on cold or unindexed workspaces.
50
+ - **Companion Symbol Token Inflation**: Deduplicated companion symbols and clamped surrounding context lines during targeted symbol reads to eliminate token bloat.
18
51
 
19
- [0.3.1]: https://github.com/floydous/pi-agent-kernel/compare/v0.3.0...v0.3.1
52
+ ### Removed
53
+ - Removed the obsolete `AGENT_KERNEL_PROPMPTS.md` prompt document.
package/README.md CHANGED
@@ -2,61 +2,40 @@
2
2
 
3
3
  ![Comparison Demonstration](https://raw.githubusercontent.com/floydous/pi-agent-kernel/master/static/comparison.gif)
4
4
 
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.
5
+ Coding agents waste tokens when they read entire files for single functions, dump thousands of lines of terminal output into the context window, or rewrite complete files for one-line edits. `pi-agent-kernel` is an extension for Pi that reduces token usage through scoped reads, bounded command outputs, and syntax-checked edits.
6
6
 
7
7
  ---
8
8
 
9
9
  ## Token savings
10
10
 
11
- Here is how tool overhead compares to an unconstrained agent harness across everyday coding tasks:
11
+ How tool overhead compares to an unconstrained agent harness across standard coding tasks:
12
12
 
13
- | Interaction | Traditional agent harness | `pi-agent-kernel` | Tokens saved | Why |
13
+ | Interaction | Standard agent harness | pi-agent-kernel (Passive Shield) | Tokens saved | Why |
14
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. |
15
+ | Whole benchmark suite (8 tasks) | Pi Vanilla baseline (1.54M tokens) | Pi + Agent-Kernel (762k tokens) | -50.6% | Cuts per-turn schema tax, stops exploratory loops, and applies surgical edits. |
16
+ | Monorepo navigation (Zod, 140k+ LOC) | Directory listings and full file dumps (104k tokens) | Plain reads and AST symbol queries (50.5k tokens) | -51.5% | Caps reads at 50 KB / 2,000 lines and extracts symbols directly without line hashes. |
17
+ | Patching and delimiter repair | Failed edits caused by token cutoffs (16.7% failure rate) | Tree-sitter and lexical repair (`edit`) | Auto-heals truncated delimiters | Recovers missing closing brackets pre-write when AST validation passes. |
18
+ | Running tests and builds | Terminal logs dumped into context (~20k+ tokens) | Clamped output with disk spillover (~1.0k tokens) | ~95% context saved | Writes full output to disk and shows only the head, tail, and log path. |
19
+ | Function inspection | Full file reads with line hashes (~4.0k tokens) | Plain text reads or symbol extraction (~420 tokens) | ~70–90% | Defaults to plain text with targeted AST symbol reads. |
20
20
 
21
21
  ---
22
22
 
23
- ## Cross-harness benchmark & reproducibility
23
+ ## Benchmarks
24
24
 
25
- `pi-agent-kernel` is continuously evaluated using an 8-task ground-truth benchmark suite derived from real-world bug fixes merged in popular open-source repositories (`hono`, `ky`, `zod`, `ufo`, `picomatch`, `fastify`, `uuid`, `p-limit`).
25
+ Evaluating 6 coding agent harnesses across 8 real-world bug fixes (`hono`, `ky`, `zod`, `ufo`, `picomatch`, `fastify`, `uuid`, `p-limit`) on `cx/gpt-5.6-luna:high`:
26
26
 
27
- All 5 harnesses were evaluated under identical prompts and base commits on **`cx/gpt-5.6-luna:high`** via **`OmniRoute`**:
27
+ | Harness | Solved | Success | Time | Input Tokens | Output Tokens | Total Turn Tokens | Tool Calls |
28
+ |---|:---:|:---:|---:|---:|---:|---:|:---:|
29
+ | Pi + Agent-Kernel | 8 / 8 | 100% | 10m 00s | 270k | 13.5k | 861k | 107 |
30
+ | Pi (Vanilla) | 8 / 8 | 100% | 20m 24s | 709k | 32.3k | 1.54M | 149 |
31
+ | Codex CLI | 8 / 8 | 100% | 20m 28s | 3.24M | 40.1k | 3.28M | 102 |
32
+ | OpenCode | 8 / 8 | 100% | 25m 57s | 1.42M | 23.0k | 3.61M | 229 |
33
+ | OMP | 7 / 8 | 87.5% | 19m 24s | 906k | 29.8k | 4.16M | 384 |
34
+ | Claude Code | 6 / 8 | 75.0% | 36m 00s | 4.39M | 85.8k | 4.48M | 183 |
28
35
 
29
- | Harness | Solved | Success Rate | Total Wall Clock | Cumulative Turn Tokens | Total Tool Calls |
30
- |---|:---:|:---:|---:|---:|:---:|
31
- | **Pi + Agent-Kernel** | **8 / 8** | **100%** | **787s (13.1m)** | **1,280,980** | **134** |
32
- | **Pi (Vanilla)** | **8 / 8** | **100%** | 594s (9.9m) | 953,034 | 103 |
33
- | **Codex CLI** | **8 / 8** | **100%** | 639s (10.7m) | 1,382,922 | 55 |
34
- | **OMP** | **8 / 8** | **100%** | 791s (13.2m) | 2,071,885 | 214 |
35
- | **Claude Code** | 7 / 8 | 88% | 1,128s (18.8m) | 1,911,546 | 109 |
36
+ ![Benchmark Comparison](static/benchmark-comparison.png)
36
37
 
37
- ![Benchmark Comparison](agent-kernel-benchmark/benchmark-comparison.png)
38
-
39
- ### Running the benchmark locally
40
-
41
- ```bash
42
- # 1. Copy and customize configuration
43
- cp agent-kernel-benchmark/.env.example agent-kernel-benchmark/.env
44
-
45
- # 2. Run the full benchmark suite
46
- npm run bench
47
-
48
- # Or run a specific task / harness
49
- npx tsx agent-kernel-benchmark/run.ts task-3
50
- npx tsx agent-kernel-benchmark/run.ts --harnesses pi-kernel,pi-vanilla
51
-
52
- # 3. Clean transient workspaces
53
- npm run bench:clean
54
-
55
- # 4. Generate the comparison chart from benchmark results
56
- npm run bench:chart
57
- ```
58
-
59
- See [`agent-kernel-benchmark/README.md`](agent-kernel-benchmark/README.md) for full configuration details, CLI flags, and task descriptions, and [`agent-kernel-benchmark/BENCHMARK_RESULTS.md`](agent-kernel-benchmark/BENCHMARK_RESULTS.md) for task-by-task forensic analysis.
38
+ *Prompts describe symptoms and expected behavior without providing the fix. Token totals reflect each tool's reported telemetry. In Claude Code, 1 additional task passed test verification after timing out.*
60
39
 
61
40
  ---
62
41
 
@@ -64,34 +43,41 @@ See [`agent-kernel-benchmark/README.md`](agent-kernel-benchmark/README.md) for f
64
43
 
65
44
  ### 1. Install
66
45
 
67
- Install the extension directly with Pi's package manager:
46
+ Install the extension through Pi's package manager:
68
47
 
69
48
  ```bash
70
- # Global install (recommended)
49
+ # Global install
71
50
  pi install npm:@floydous/pi-agent-kernel
72
51
 
73
- # Or install locally for the current repository only
52
+ # Local install for the current workspace only
74
53
  pi install -l npm:@floydous/pi-agent-kernel
75
54
  ```
76
55
 
77
- Restart Pi or start a new session. The extension registers its tools, guards, and status indicators automatically.
56
+ Restart Pi or start a new session. The extension registers its tools, guards, status indicators, and workflow guidance automatically.
57
+
58
+ The compact instructions in `AGENT_KERNEL_SYS_PROMPT.md` are appended to the agent system prompt via Pi's `before_agent_start` hook. You can disable this by setting `[instructions] enabled = false` in `config.toml`.
78
59
 
79
60
  ---
80
61
 
81
62
  ### 2. Configure the retrieval engine (`/engine`)
82
63
 
83
- `pi-agent-kernel` includes an in-memory retrieval engine for keyword and semantic searches:
64
+ `pi-agent-kernel` includes an in-memory retrieval engine for keyword and vector search, shown on the extension status line:
84
65
 
85
66
  ```text
86
67
  /engine status
87
68
  ```
88
69
 
89
- - **`lean`** *(default)*: Fast, AST-aware BM25 search. Consumes 0 MB background model RAM.
90
- - **`hybrid`**: BM25 keyword search blended with lightweight local 256-dimension embeddings.
91
- - **`full`**: Dense 768-dimension semantic embeddings for deep conceptual queries across large codebases.
92
- - **`off`**: Turns off local index building if you only want AST and LSP tools.
70
+ - `lean` (default): `🌿 retrieval:bm25` (AST-indexed BM25 keyword search, 0 MB model RAM)
71
+ - `hybrid`: `◈ retrieval:hybrid-256d` (BM25 keyword search plus local 256-dimension Matryoshka embeddings)
72
+ - `full`: `🧠 retrieval:dense-768d` (Dense 768-dimension semantic embeddings for conceptual queries)
73
+ - `off`: Disables local indexing for users who only want AST and LSP tools
74
+
75
+ During indexing, the status line shows chunk throughput and progress:
76
+ ```text
77
+ 🧠 retrieval:dense-768d ⇢ 45% (22/48 • 14.2 chunk/s) • ○ 🐴 ponytail: ⚡ FULL
78
+ ```
93
79
 
94
- Switch profiles at any time:
80
+ Switch profiles directly:
95
81
  ```text
96
82
  /engine hybrid
97
83
  # or
@@ -100,52 +86,51 @@ Switch profiles at any time:
100
86
 
101
87
  ---
102
88
 
103
- ### 3. Configure codebase scale profile (`/profile`)
89
+ ### 3. Codebase scale profiles (`/profile`)
104
90
 
105
- Agent-kernel automatically scales its prompt context to the size of the repository. On light repositories (<10 implementation files, <50 KB code), the 1,024-token PageRank map is suppressed to minimize token usage. On larger projects, the map is injected automatically.
91
+ The extension adjusts prompt context based on repository size. On small codebases (<10 implementation files, <50 KB code), the 1,024-token PageRank map is omitted to save tokens. On larger projects, it is included automatically.
106
92
 
107
- You can view or override this setting at any time:
93
+ Check or change the profile:
108
94
  ```text
109
95
  /profile status # Check current profile and detected codebase metrics
110
- /profile light # Force light profile (suppress automatic repo-map injection)
111
- /profile heavy # Force heavy profile (always inject PageRank repo map)
112
- /profile auto # Auto-detect based on implementation code volume (default)
96
+ /profile light # Suppress automatic repo map
97
+ /profile heavy # Always inject PageRank repo map
98
+ /profile auto # Auto-detect based on codebase volume (default)
113
99
  ```
114
- Or configure via environment variable:
100
+
101
+ Or set the environment variable:
115
102
  ```bash
116
- export PI_CODEBASE_PROFILE=light # or "heavy", "auto", "smart"
103
+ export PI_CODEBASE_PROFILE=light # "heavy", "auto", or "smart"
117
104
  ```
118
105
 
119
106
  ---
120
107
 
121
- ### 4. Setup language servers (`/lsp`)
108
+ ### 4. Language server setup (`/lsp`)
122
109
 
123
- Get real-time compiler diagnostics, definitions, and references without manual setup:
110
+ Inspect compiler diagnostics, jump to definitions, and find references:
124
111
 
125
112
  ```text
126
113
  /lsp
127
114
  ```
128
115
 
129
- Running `/lsp` opens an interactive management screen showing active servers, connection status, and one-click installs for detected workspace languages.
116
+ Running `/lsp` displays detected languages, connection states, and installation options for language servers.
130
117
 
131
- Alternatively, install a server directly from the command line:
118
+ To install a language server directly:
132
119
  ```text
133
- /lsp install <language> # e.g., python, typescript, rust, go, csharp, etc.
120
+ /lsp install <language> # e.g. python, typescript, rust, go, csharp
134
121
  ```
135
122
 
136
123
  ---
137
124
 
138
- ### 5. Tip: Turn off Pi documentation when working on your own projects
125
+ ### 5. Disable Pi documentation for external projects
139
126
 
140
- By default, Pi loads system prompt instructions explaining how to extend Pi itself (extensions, themes, skills, and TUI APIs).
141
-
142
- 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:
127
+ Pi loads instructions for developing Pi extensions, skills, and themes by default. When working on standard application code, you can disable those instructions to free up prompt space:
143
128
 
144
129
  ```text
145
130
  /pi-docs off
146
131
  ```
147
132
 
148
- Turn it back on with `/pi-docs on` whenever you switch back to hacking on Pi extensions.
133
+ Use `/pi-docs on` when returning to work on Pi extensions.
149
134
 
150
135
  ---
151
136
 
@@ -153,15 +138,13 @@ Turn it back on with `/pi-docs on` whenever you switch back to hacking on Pi ext
153
138
 
154
139
  | Tool | What it does |
155
140
  |---|---|
156
- | `read` | Read specific lines or extract an exact function, class, or type via AST (`symbol="name"`). |
157
- | `edit` | Apply surgical search/replace patches with built-in syntax checks. |
158
- | `write` | Create new files or perform complete rewrites when explicitly requested. |
159
- | `get_repo_map` | Retrieve a concise, PageRank-ranked symbol overview of the codebase (~1k tokens). |
160
- | `ast_search` | Search declarations across files using Tree-sitter AST queries, grouped cleanly by file. |
161
- | `code_search` | Hybrid keyword and semantic chunk search with breadcrumb locations. |
162
- | `lsp` | Query definitions, references, type hover docs, and diagnostics directly from language servers. |
163
- | `recall` | Retrieve the full text of a deduplicated output previously replaced by a short reference tag. |
164
- | `search_tools` | Search and activate deferred tools on demand. |
141
+ | `read` | Reads plain text with 50 KB / 2,000-line safety caps, or extracts a function, class, or type via AST (`symbol="name"`). |
142
+ | `edit` | Applies search and replace patches with automatic delimiter healing and optional `line_hint` disambiguation. |
143
+ | `write` | Creates new files or rewrites existing files when needed. |
144
+ | `bash` | Runs shell commands (`rg`, `git status`, test runners) with clamped outputs and spillover logs on disk. |
145
+ | `code_search` | Hybrid AST BM25 and semantic chunk search with breadcrumb locations for conceptual discovery. |
146
+
147
+ *Note: Exploratory tools (`ast_search`, `get_repo_map`, `lsp`) are gated behind `PI_ENABLE_ALL_RETRIEVAL_TOOLS=1` pending redesign in v0.4.0.*
165
148
 
166
149
  ---
167
150
 
package/config.toml CHANGED
@@ -12,8 +12,11 @@ max_line_length = 300
12
12
  max_lines = 40
13
13
  max_total_bytes = 20480
14
14
  exec_timeout_ms = 5000
15
- dedup_min_bytes = 80
16
- dedup_max_entries_per_session = 1024
15
+
16
+ [editing]
17
+ mode = "smart_anchor"
18
+ default_anchors = true
19
+ read_mode = "auto"
17
20
 
18
21
  [lsp]
19
22
  idle_timeout_ms = 300000
@@ -22,3 +25,6 @@ disabled_servers = []
22
25
 
23
26
  [ui]
24
27
  enable_pastel_footer = true
28
+
29
+ [instructions]
30
+ enabled = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floydous/pi-agent-kernel",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Focused code retrieval, editing, safety checks, and language-server support for Pi.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -10,6 +10,7 @@
10
10
  "scripts": {
11
11
  "test": "npx tsx tests/run-all.ts",
12
12
  "typecheck": "tsc --noEmit",
13
+ "preindex": "npx tsx agent-kernel-benchmark/preindex.ts",
13
14
  "bench": "npx tsx agent-kernel-benchmark/run.ts",
14
15
  "bench:clean": "npx tsx agent-kernel-benchmark/run.ts --clean",
15
16
  "bench:chart": "PATH=\"$HOME/.local/bin:$HOME/.venv/bin:$PATH\" python3 agent-kernel-benchmark/generate_chart.py"
@@ -45,6 +46,7 @@
45
46
  "docs",
46
47
  "LICENSE",
47
48
  "config.toml",
49
+ "AGENT_KERNEL_SYS_PROMPT.md",
48
50
  "CHANGELOG.md"
49
51
  ],
50
52
  "publishConfig": {
@@ -14,6 +14,7 @@ export interface RetrievalConfig {
14
14
  repo_map_min_files: number;
15
15
  repo_map_min_bytes: number;
16
16
  max_search_results: number;
17
+ enable_tools?: boolean;
17
18
  }
18
19
 
19
20
  export interface SafetyConfig {
@@ -22,17 +23,21 @@ export interface SafetyConfig {
22
23
  max_lines: number;
23
24
  max_total_bytes: number;
24
25
  exec_timeout_ms: number;
25
- /** Don't dedup tool results whose rendered text is <= this many bytes. */
26
- dedup_min_bytes: number;
27
- /** LRU cap per session for the dedup side store. */
28
- dedup_max_entries_per_session: number;
26
+ }
27
+
28
+ export interface EditingConfig {
29
+ mode: "smart_anchor" | "standard";
30
+ default_anchors: boolean;
31
+ read_mode: "auto" | "plain" | "anchored";
29
32
  }
30
33
 
31
34
  export interface KernelConfigOverrides {
32
35
  retrieval?: Partial<RetrievalConfig>;
33
36
  safety?: Partial<SafetyConfig>;
37
+ editing?: Partial<EditingConfig>;
34
38
  lsp?: Partial<LspConfig>;
35
39
  ui?: Partial<UiConfig>;
40
+ instructions?: Partial<InstructionsConfig>;
36
41
  }
37
42
 
38
43
  export interface LspConfig {
@@ -47,11 +52,17 @@ export interface UiConfig {
47
52
  enable_pastel_footer: boolean;
48
53
  }
49
54
 
55
+ export interface InstructionsConfig {
56
+ enabled: boolean;
57
+ }
58
+
50
59
  export interface KernelConfig {
51
60
  retrieval: RetrievalConfig;
52
61
  safety: SafetyConfig;
62
+ editing: EditingConfig;
53
63
  lsp: LspConfig;
54
64
  ui: UiConfig;
65
+ instructions: InstructionsConfig;
55
66
  }
56
67
 
57
68
  const DEFAULT_CONFIG: KernelConfig = {
@@ -62,6 +73,7 @@ const DEFAULT_CONFIG: KernelConfig = {
62
73
  repo_map_min_files: 10,
63
74
  repo_map_min_bytes: 50 * 1024,
64
75
  max_search_results: 5,
76
+ enable_tools: false,
65
77
  },
66
78
  safety: {
67
79
  enable_epistemic_guard: true,
@@ -69,8 +81,11 @@ const DEFAULT_CONFIG: KernelConfig = {
69
81
  max_lines: 40,
70
82
  max_total_bytes: 20 * 1024,
71
83
  exec_timeout_ms: 5000,
72
- dedup_min_bytes: 80,
73
- dedup_max_entries_per_session: 1024,
84
+ },
85
+ editing: {
86
+ mode: "smart_anchor",
87
+ default_anchors: false,
88
+ read_mode: "plain",
74
89
  },
75
90
  lsp: {
76
91
  idle_timeout_ms: 5 * 60 * 1000, // 5 minutes
@@ -82,6 +97,9 @@ const DEFAULT_CONFIG: KernelConfig = {
82
97
  ui: {
83
98
  enable_pastel_footer: true,
84
99
  },
100
+ instructions: {
101
+ enabled: true,
102
+ },
85
103
  };
86
104
 
87
105
  /**