@floydous/pi-agent-kernel 0.3.3 → 0.4.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 +49 -2
- package/README.md +24 -1
- package/config.example.toml +36 -0
- package/docs/configuration.md +11 -3
- package/docs/retrieval.md +15 -1
- package/docs/testing.md +5 -3
- package/package.json +3 -2
- package/src/config/agent_kernel_command.ts +834 -0
- package/src/config/index.ts +1 -0
- package/src/config/kernel_config.ts +78 -14
- package/src/config/toml.ts +15 -4
- package/src/context/session_repair.ts +24 -6
- package/src/editing/smart_anchor.ts +16 -7
- package/src/editing/syntax-verify.ts +17 -7
- package/src/index.ts +117 -86
- package/src/lsp/lsp_client.ts +37 -3
- package/src/lsp/lsp_formatter.ts +4 -2
- package/src/lsp/lsp_installer.ts +46 -115
- package/src/lsp/lsp_registry.ts +36 -28
- package/src/retrieval/ast_search.ts +136 -172
- package/src/retrieval/repomap.ts +8 -47
- package/src/retrieval/search_chunker.ts +9 -34
- package/src/retrieval/search_config.ts +59 -14
- package/src/retrieval/search_index.ts +396 -27
- package/src/retrieval/workspace_walker.ts +262 -0
- package/src/safety/epistemic_guard.ts +1 -1
- package/src/safety/output_clamper.ts +32 -9
- package/src/tools/edit_tool.ts +11 -8
- package/src/tools/lsp_tool.ts +12 -2
- package/src/tools/read_tool.ts +4 -4
- package/config.toml +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.0] - 2026-09-23
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **.gitignore-Aware Workspace Traversal**: Added unified workspace walker (`src/retrieval/workspace_walker.ts`) shared across `search_chunker`, `repomap`, and `ast_search`. Evaluates hierarchical `.gitignore` files leaf-to-root with directory pruning (`dir/`), wildcard descent (`dir/*`), child negation overrides (`!keep.ts`), and additive `.piignore` support.
|
|
7
|
+
- **Transactional Incremental Vector Updates**: Added `updateFile()` to `HybridSearchIndex` to re-chunk only modified files on mutation and reuse cached 768d vectors by content hash across line shifts and untouched functions.
|
|
8
|
+
- **Generational Protection & Query-Time Freshness**: Protected in-flight file updates with generation counters to cancel superseded jobs, and made `search()` await active updates for strict snapshot freshness.
|
|
9
|
+
- **Debounced Disk Persistence**: Implemented `scheduleDebouncedSave()` and `flushPendingSave()` to coalesce rapid sequential mutations into debounced atomic writes and guarantee persistence on session shutdown.
|
|
10
|
+
- **Direct Ignore Dependency**: Added `"ignore": "^7.0.5"` as an explicit dependency for standards-compliant pattern matching.
|
|
11
|
+
- **Reference Configuration Template**: Added `config.example.toml` as a clean, documented template for project (`.pi/config.toml`) and global (`~/.pi/agent/config.toml`) settings.
|
|
12
|
+
- **Test Suites**: Added comprehensive regression suites for security hardening (`tests/security-hardening/`), Windows deep verification (`tests/windows-deep-verification.ts`), incremental updates (`tests/retrieval/incremental_update.test.ts`), and gitignore traversal parity (`tests/retrieval/gitignore_traversal.test.ts`).
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- **Profile Scope Expansion**: Fully aligned configuration types, TUI selectors, and CLI subcommands to support `auto` (adaptive VPS/desktop profile) and `off` (completely disabled retrieval) alongside `lean`, `hybrid`, and `full`.
|
|
16
|
+
- **Decoupled Snapshot Invalidation**: Ignore configuration hashes (`.gitignore`, `.piignore`) are tracked in dedicated snapshot metadata (`ignoreConfigHashes`) rather than indexed code file tables, automatically purging newly-ignored files on the next search without reporting phantom files.
|
|
17
|
+
- **Live Retrieval Configuration Sync**: Unified `/engine`, `SearchControlModal`, and `/agent-kernel` commands to reconfigure running `HybridSearchIndex` instances and refresh statusline/footer badges immediately upon profile change without requiring session reloads.
|
|
18
|
+
- **Hierarchical Config Scoping**: Enforced strict configuration isolation where project-level changes write strictly to local `.pi/config.toml`, following the hierarchy: Project TOML > Global TOML > Legacy JSON > Lean defaults.
|
|
19
|
+
- **Index Mutation Purity**: Removed silent disk-write side effects from `HybridSearchIndex.setProfile()`.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- **Retrieval Index Pollution**: Search chunking respects `.gitignore` rules and hard exclusions (`agent-kernel-benchmark/cache/`, `.git/`, `node_modules/`), preventing third-party benchmark fixtures from polluting workspace search indexes.
|
|
23
|
+
- **Symlink & Path Containment**: Traversal skips symbolic links and confirms canonical paths remain bounded inside the workspace root.
|
|
24
|
+
- **Windows Path & Line Ending Resilience**: Preserved CRLF line endings during smart anchor edits and syntax verification without introducing mixed newlines. Normalized relative display paths to POSIX forward slashes in `read`, `edit`, and LSP formatters.
|
|
25
|
+
- **NTFS Case-Insensitive Collisions**: Prevented duplicate target path collisions in multi-file edits on case-insensitive filesystems. Handled case-insensitive path comparisons in LSP references and AST symbol search.
|
|
26
|
+
- **PowerShell Clamping & Windows Executables**: Intercepted and clamped `powershell` tool output in `tool_result` hooks alongside `bash`, and recognized `.cmd`, `.bat`, and `.exe` extensions in epistemic guard inspection.
|
|
27
|
+
- **LSP Installer Discovery**: Required confirmed executable presence on disk before reporting successful LSP server installation.
|
|
28
|
+
- **Config Tracking Removal**: Untracked root `config.toml` from Git and removed it from package distribution. Default configurations run purely in-memory, while user overrides persist cleanly to `.pi/config.toml` (workspace, gitignored) or `~/.pi/agent/config.toml` (global).
|
|
29
|
+
- **Deferred Settings Application in `/agent-kernel` TUI**: Cycling through setting options (e.g. `lean` -> `hybrid` -> `full`) no longer writes intermediate states to disk or triggers intermediate re-indexing runs. Changes are buffered in-memory and applied in a single atomic batch only when the user closes the modal (`Esc` / `q`).
|
|
30
|
+
- **In-Flight Re-indexing Cancellation on Profile Switch**: Fixed a race condition where switching retrieval profiles while background indexing was active (e.g. `hybrid` -> `full`) continued running the superseded profile's embedding loop and overwrote the statusline with the old profile tag. In-flight sync jobs are now cleanly aborted via generation tokens and abort controllers, and the statusline immediately tracks the newly active profile.
|
|
31
|
+
|
|
32
|
+
### Security
|
|
33
|
+
- **TOML Prototype Pollution Hardening**: Hardened `parseToml` and `mergeDeep` using null-prototype dictionaries and explicit rejection of dangerous keys (`__proto__`, `constructor`, `prototype`).
|
|
34
|
+
- **Safe Executable Discovery**: Replaced shell-spawning executable resolution with direct filesystem PATH/PATHEXT scanning and `execFileSync`.
|
|
35
|
+
- **LSP Stdio Framing Guard**: Enforced strict `Content-Length` boundary checks, exact decimal matching, and stream resynchronization recovery against malformed headers and buffer overflows.
|
|
36
|
+
- **Bounded Session Repair**: Added bounded session repair log scanning with atomic writes and filtered out symlinks during temporary spillover log cleanup in `/tmp`.
|
|
37
|
+
|
|
38
|
+
### Removed
|
|
39
|
+
- **Legacy `/profile` Command & `codebase_profile`**: Completely removed the redundant `/profile` slash command (`auto`, `light`, `heavy`, `status`), `codebaseProfileBySession` tracking map, and unused repo-map scale injection code in `before_agent_start`.
|
|
40
|
+
- **Codebase Scale Settings**: Removed `codebase_profile` from `RetrievalConfig`, TOML defaults, environment variables (`PI_CODEBASE_PROFILE`), `/agent-kernel` CLI (`set codebase`), and the TUI settings modal. Code retrieval configuration is now unified exclusively under `/engine` and `/agent-kernel`.
|
|
41
|
+
|
|
42
|
+
## [0.3.31] - 2026-09-22
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
- **Unified `/agent-kernel` Settings**: Added interactive modal and CLI commands (`status`, `set`, `reset`) for managing extension settings across workspace (`.pi/config.toml`) and global (`~/.pi/agent/config.toml`) scopes.
|
|
46
|
+
- **Spillover Hardening**: Enforced restrictive `0o600` permissions on temporary command output logs in `/tmp` with automated 20-file bounded rotation.
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
- Removed repository-level `AGENTS.md` from git tracking.
|
|
50
|
+
|
|
3
51
|
## [0.3.3] - 2026-09-20
|
|
4
52
|
|
|
5
53
|
### Added
|
|
@@ -40,8 +88,7 @@
|
|
|
40
88
|
- Included `AGENT_KERNEL_SYS_PROMPT.md` in the published package so automatic guidance works after installation.
|
|
41
89
|
- Added lifecycle coverage for guidance injection, duplicate prevention, and the disabled configuration path.
|
|
42
90
|
- **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
|
-
- **
|
|
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.
|
|
91
|
+
- **Performance**: Cut 8-task benchmark token consumption from **1,214,112 tokens down to 465,139 tokens (-61.7%)**, outperforming stock Pi Vanilla (579,088 tokens, -19.7% overall) across 8 real-world repositories.
|
|
45
92
|
- **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
93
|
- **On-Demand Embedder Loading**: Removed premature model preloading on startup; weights load on-demand only when unindexed chunks are detected.
|
|
47
94
|
|
package/README.md
CHANGED
|
@@ -122,7 +122,30 @@ To install a language server directly:
|
|
|
122
122
|
|
|
123
123
|
---
|
|
124
124
|
|
|
125
|
-
### 5.
|
|
125
|
+
### 5. Unified settings & configuration (`/agent-kernel`)
|
|
126
|
+
|
|
127
|
+
Manage all Agent Kernel settings interactively or from the command line:
|
|
128
|
+
|
|
129
|
+
```text
|
|
130
|
+
/agent-kernel
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- **Interactive TUI Modal**: Mirrors native Pi component layouts (`/thinking` and `/settings`) with 4 categorized domains (`Retrieval & Exploration`, `Safety & Verification`, `Editing Engine`, `System Guidance & UI`).
|
|
134
|
+
- **Interactive Search**: Type to filter across setting IDs, labels, categories, and descriptions in real time.
|
|
135
|
+
- **Dynamic Descriptions**: Updates in real time to explain the active option value.
|
|
136
|
+
- **Global Scope Toggle (`G`)**: Press `G` (or `Ctrl+G`) on any setting to toggle applying it globally (`~/.pi/agent/config.toml`) vs. workspace-local (`.pi/config.toml`). Global settings are highlighted in **yellow**.
|
|
137
|
+
- **Tab Navigation**: Jump between categories with `Tab` / `Shift+Tab`.
|
|
138
|
+
|
|
139
|
+
Headless CLI commands:
|
|
140
|
+
```text
|
|
141
|
+
/agent-kernel status # Print current configuration and file paths
|
|
142
|
+
/agent-kernel set <key> <val> # Update a specific setting globally
|
|
143
|
+
/agent-kernel reset # Reset global configuration to defaults
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### 6. Disable Pi documentation for external projects
|
|
126
149
|
|
|
127
150
|
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:
|
|
128
151
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Agent Kernel - Configuration Example
|
|
2
|
+
# Copy to `.pi/config.toml` (workspace) or `~/.pi/agent/config.toml` (global).
|
|
3
|
+
# All fields are optional; defaults apply when omitted.
|
|
4
|
+
|
|
5
|
+
[retrieval]
|
|
6
|
+
# "auto" (VPS=lean, laptop=hybrid, desktop=full), "lean" (BM25 only),
|
|
7
|
+
# "hybrid" (BM25 + 256d vectors), "full" (768d dense vectors), or "off"
|
|
8
|
+
default_profile = "lean"
|
|
9
|
+
repo_map_budget = 1024
|
|
10
|
+
max_search_results = 5
|
|
11
|
+
# true exposes ast_search, get_repo_map, and lsp tools directly to the model
|
|
12
|
+
enable_tools = false
|
|
13
|
+
|
|
14
|
+
[safety]
|
|
15
|
+
enable_epistemic_guard = true
|
|
16
|
+
max_line_length = 300
|
|
17
|
+
max_lines = 40
|
|
18
|
+
max_total_bytes = 20480
|
|
19
|
+
exec_timeout_ms = 5000
|
|
20
|
+
|
|
21
|
+
[editing]
|
|
22
|
+
mode = "smart_anchor"
|
|
23
|
+
default_anchors = true
|
|
24
|
+
read_mode = "auto"
|
|
25
|
+
|
|
26
|
+
[lsp]
|
|
27
|
+
idle_timeout_ms = 300000
|
|
28
|
+
spinner_interval_ms = 80
|
|
29
|
+
disabled_servers = []
|
|
30
|
+
|
|
31
|
+
[ui]
|
|
32
|
+
enable_pastel_footer = true
|
|
33
|
+
|
|
34
|
+
[instructions]
|
|
35
|
+
enabled = true
|
|
36
|
+
pi_docs = true
|
package/docs/configuration.md
CHANGED
|
@@ -4,17 +4,25 @@ The configuration loader applies values in this order:
|
|
|
4
4
|
|
|
5
5
|
1. Built-in defaults.
|
|
6
6
|
2. Global configuration: `~/.pi/agent/config.toml` (or the configured Pi home).
|
|
7
|
-
3. Project configuration: the nearest
|
|
8
|
-
or
|
|
7
|
+
3. Project configuration: the nearest `.pi/config.toml`, `config.toml`,
|
|
8
|
+
or `agent-kernel/config.toml` while walking upward from the workspace.
|
|
9
9
|
4. Environment-variable overrides supported by the loader.
|
|
10
10
|
|
|
11
11
|
The repository-root `config.toml` is ignored so local settings are not committed.
|
|
12
|
+
See `config.example.toml` in the repository root for a documented configuration template.
|
|
13
|
+
|
|
14
|
+
## Managing Settings
|
|
15
|
+
|
|
16
|
+
Settings can be managed via the `/agent-kernel` interactive modal or CLI subcommands:
|
|
17
|
+
- `/agent-kernel` opens an interactive TUI to view and toggle settings across project and global scopes.
|
|
18
|
+
- Modifications made in the modal are buffered in-memory while navigating and applied in a single atomic batch on modal close (`Esc` / `q`), preventing intermediate re-indexing runs.
|
|
19
|
+
- CLI subcommands: `/agent-kernel status`, `/agent-kernel set <key> <val> [--global]`, `/agent-kernel reset [--global]`.
|
|
12
20
|
|
|
13
21
|
## Main sections
|
|
14
22
|
|
|
15
23
|
### `[retrieval]`
|
|
16
24
|
|
|
17
|
-
- `default_profile`: `lean`, `hybrid`, or `
|
|
25
|
+
- `default_profile`: `auto`, `lean`, `hybrid`, `full`, or `off`.
|
|
18
26
|
- `repo_map_budget`: token budget for the repository map.
|
|
19
27
|
- `max_search_results`: result limit for code search.
|
|
20
28
|
|
package/docs/retrieval.md
CHANGED
|
@@ -5,13 +5,14 @@ fast discovery does not require loading the local embedding model.
|
|
|
5
5
|
|
|
6
6
|
## Components
|
|
7
7
|
|
|
8
|
+
- `workspace_walker.ts` provides unified, `.gitignore`- and `.piignore`-aware filesystem traversal shared across indexing, repository maps, and AST search with directory pruning and child negation.
|
|
8
9
|
- `repomap.ts` extracts AST symbols and produces a ranked repository map.
|
|
9
10
|
- `ast_search.ts` provides structural symbol search and language-aware fallback
|
|
10
11
|
operations such as document symbols, references, and local hover details.
|
|
11
12
|
- `search_chunker.ts` creates syntax-aware chunks with breadcrumbs.
|
|
12
13
|
- `search_bm25.ts` provides the fast lexical search path.
|
|
13
14
|
- `search_embedder.ts` provides optional local embeddings.
|
|
14
|
-
- `search_index.ts` coordinates indexing, profiles, and fallback behavior.
|
|
15
|
+
- `search_index.ts` coordinates indexing, incremental file updates, profiles, and fallback behavior.
|
|
15
16
|
- `search_modal.ts` exposes profile controls in the Pi UI.
|
|
16
17
|
|
|
17
18
|
## Profiles
|
|
@@ -40,3 +41,16 @@ The default remains 60.
|
|
|
40
41
|
Vector caches are accepted only when their metadata, chunk IDs, dimensions, byte
|
|
41
42
|
length, and content hash agree; invalid vector data is ignored while the BM25
|
|
42
43
|
index remains usable.
|
|
44
|
+
|
|
45
|
+
## Workspace Traversal & Ignore Rules
|
|
46
|
+
|
|
47
|
+
Traversal walks workspace directories hierarchically using `workspace_walker.ts`:
|
|
48
|
+
- `.gitignore` and `.piignore` rules are evaluated with standard precedence, including directory pruning (`dir/`), wildcard descent (`dir/*`), and child negations (`!keep.ts`).
|
|
49
|
+
- Traversal strictly rejects symlinks and escapes outside workspace boundaries.
|
|
50
|
+
- Ignore configurations are tracked in dedicated snapshot metadata (`ignoreConfigHashes`). Modifying ignore files evicts newly ignored source chunks on the next query without counting phantom files.
|
|
51
|
+
|
|
52
|
+
## Incremental Updates & Profile Switching
|
|
53
|
+
|
|
54
|
+
- **Incremental File Updates (`updateFile`)**: When a file is modified, only that file's AST chunks are re-parsed. Unchanged chunks reuse existing dense vectors by content hash across line shifts, avoiding full-repository re-embeddings.
|
|
55
|
+
- **In-Flight Cancellation**: Switching retrieval profiles (e.g. `hybrid` -> `full`) while background indexing is running immediately aborts in-flight embedding jobs via generation counters and `AbortController`. Stale vectors are rejected post-await, and the statusline switches directly to tracking the new profile.
|
|
56
|
+
- **Debounced Persistence**: Sequential mutations are coalesced into debounced atomic writes (`scheduleDebouncedSave`) and flushed cleanly on session shutdown (`flushPendingSave`).
|
package/docs/testing.md
CHANGED
|
@@ -6,11 +6,13 @@ independently runnable and uses isolated temporary workspaces where needed.
|
|
|
6
6
|
## Commands
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
# Full
|
|
10
|
-
npm test
|
|
9
|
+
# Full verification
|
|
10
|
+
npm run typecheck && npm test
|
|
11
11
|
|
|
12
12
|
# One focused section
|
|
13
|
-
npx tsx tests/
|
|
13
|
+
npx tsx tests/retrieval/incremental_update.test.ts
|
|
14
|
+
npx tsx tests/retrieval/gitignore_traversal.test.ts
|
|
15
|
+
npx tsx tests/security-hardening/index.ts
|
|
14
16
|
```
|
|
15
17
|
|
|
16
18
|
`npm test` runs the suite orchestrator under `tests/`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floydous/pi-agent-kernel",
|
|
3
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Focused code retrieval, editing, safety checks, and language-server support for Pi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@huggingface/transformers": "^4.2.0",
|
|
20
20
|
"diff": "^9.0.0",
|
|
21
|
+
"ignore": "^7.0.5",
|
|
21
22
|
"typebox": "^1.3.16",
|
|
22
23
|
"web-tree-sitter": "^0.26.12"
|
|
23
24
|
},
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"README.md",
|
|
46
47
|
"docs",
|
|
47
48
|
"LICENSE",
|
|
48
|
-
"config.toml",
|
|
49
|
+
"config.example.toml",
|
|
49
50
|
"AGENT_KERNEL_SYS_PROMPT.md",
|
|
50
51
|
"CHANGELOG.md"
|
|
51
52
|
],
|