@floydous/pi-agent-kernel 0.5.0 → 0.6.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.
Files changed (36) hide show
  1. package/AGENT_KERNEL_SYS_PROMPT.md +15 -6
  2. package/CHANGELOG.md +51 -0
  3. package/README.md +2 -3
  4. package/config.example.toml +1 -0
  5. package/docs/configuration.md +1 -1
  6. package/docs/editing-and-verification.md +20 -5
  7. package/docs/podman-linux-checks.md +24 -0
  8. package/docs/release-discipline.md +10 -0
  9. package/docs/retrieval.md +14 -11
  10. package/grammars/tree-sitter-html.wasm +0 -0
  11. package/package.json +2 -2
  12. package/src/config/agent_kernel_command.ts +59 -593
  13. package/src/config/kernel_config.ts +24 -2
  14. package/src/editing/patch.ts +48 -21
  15. package/src/editing/post_edit_verification.ts +8 -4
  16. package/src/editing/smart_anchor.ts +2 -1
  17. package/src/editing/syntax-verify.ts +73 -220
  18. package/src/index.ts +21 -196
  19. package/src/retrieval/html_chunker.ts +526 -0
  20. package/src/retrieval/search_bm25.ts +36 -27
  21. package/src/retrieval/search_chunker.ts +68 -6
  22. package/src/retrieval/search_config.ts +17 -34
  23. package/src/retrieval/search_embedder.ts +11 -29
  24. package/src/retrieval/search_index.ts +307 -145
  25. package/src/retrieval/search_modal.ts +1209 -222
  26. package/src/retrieval/tag_extractor.ts +1 -1
  27. package/src/retrieval/tree_sitter_engine.ts +103 -4
  28. package/src/retrieval/workspace_walker.ts +72 -0
  29. package/src/safety/host_environment.ts +180 -0
  30. package/src/safety/output_clamper.ts +83 -19
  31. package/src/tools/code_search_output.ts +9 -1
  32. package/src/tools/code_search_tool.ts +25 -10
  33. package/src/tools/context.ts +15 -0
  34. package/src/tools/edit_tool.ts +182 -60
  35. package/src/tools/read_tool.ts +245 -38
  36. package/src/tools/stream_reader.ts +206 -0
@@ -1,8 +1,17 @@
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.
1
+ ## Tool Selection: Codebase Navigation
2
+
3
+ Choose navigation tools based on verified evidence, not a fixed sequence.
3
4
  <!-- KERNEL:CODE_SEARCH -->
4
- - **Unlocated concept with no names:** Use `code_search` to find relevant files.
5
+
6
+ - **Unverified implementation location → `code_search`:** Use `code_search` when locating a feature, workflow, UI behavior, or architecture without a known file path or symbol name. Formulate queries as 3–5 word mechanism phrases (e.g., `"session token expiration middleware"`).
7
+ <!-- /KERNEL:CODE_SEARCH -->
8
+
9
+ - **Known symbol, error, or exact text → `bash` (`rg -n`):** Use `rg -n` for known code symbols, verbatim errors, import paths, or literal text. When discovering non-code files (CSS, JSON, TOML, YAML, Markdown, shell scripts, dotfiles), scope `rg` to the relevant directory or file glob.
10
+
11
+ - **Target inspection:** Inspect bounded line ranges around target coordinates with read before editing. Scope rg -n "<text>" [path] only when searching for exact text within that known file.
12
+
13
+ - **Edit precondition:** The edit tool requires prior inspection of target lines with read (or exact line match output from `rg -n` for mechanical one-line edits).
14
+ <!-- KERNEL:CODE_SEARCH -->
15
+
16
+ - **Zero-match recovery:** If discovery `rg` returns zero matches or noisy output that yields no candidate file, switch to `code_search` using the high-level implementation concept.
5
17
  <!-- /KERNEL:CODE_SEARCH -->
6
- - **Code inspection & direct edits:** When search (`rg`) locates a known symbol or line:
7
- - **Inspection lane (default for logic bugs):** Read a narrow targeted range (`limit <= 60`) centered on the location when deciding the correct change requires understanding surrounding control flow, types, or call sites.
8
- - **Direct edit lane (mechanical/one-line changes):** When `rg -n` outputs the complete line to replace (e.g. constant, error code, import, or localized typo) and the change does not require surrounding context, call `edit` directly in the same turn without an intermediate read.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.0] - 2026-11-11
4
+
5
+ ### Added
6
+
7
+ - **Upfront Host Environment Discovery**: Added automated, non-invasive runtime capability discovery injected into the system prompt as `<host_environment>` (outside `<agent_kernel_guidance>`). Surfaces verified platform facts (OS name/version, active shell, per-file line ending policy, verified toolchain versions `node`, `git`, `cargo`, `python`, `powershell`), alongside platform-specific shell guidance (e.g. Git Bash POSIX commands and PowerShell `-NoProfile` `.NET` checksum guidance on Windows; Bash 3.2 and BSD flags on macOS; standard GNU on Linux). Parallel async toolchain probes run once at session start and memoize in-memory (0 ms subsequent turns) with zero repository filenames or diffs, preserving strict prompt injection security boundaries.
8
+
9
+ - **Line Span Confirmation in `edit`**: Successful edits now report the affected 1-based line span (e.g. `lines 14–18 -> 14–16`, `line 10 -> line 10`, or `lines 20–22 deleted`) directly in the confirmation text. This gives agents immediate proof of the edit's exact location and resulting line numbers without burning turns on redundant post-edit `read` calls.
10
+ - **Line Ending Preservation in `edit` Tool**: Clarified in the `edit` tool description and prompt snippet that edits automatically detect and preserve each file's existing line endings (CRLF / LF), eliminating whole-file diff churn when working on repositories with mixed line endings.
11
+
12
+ - **HTML Code Is Now Searchable**: Code search now indexes `.html` and `.htm` files using the bundled `tree-sitter-html.wasm` (v0.23.2). Semantic DOM landmarks (`main`, `nav`, `section`, `article`, `header`, `footer`, `form`, and interactive panels) are chunked into coherent groups (<= 70 lines), while interactive leaf controls (`input`, `button`, `select`) roll up into their parent forms or panels instead of cluttering search results with single-line snippets. Inline `<style>` and `<script>` boundaries are enforced so raw CSS rules and script bodies do not leak into template chunks. Within the source tier, executable code files rank ahead of HTML templates.
13
+ - **Stream Large Spillover Logs and Data Files in `read`**: The `read` tool now streams line windows directly from disk for authenticated shell spillover files (`pi_bash_spillover_*.log` and host harness logs) and windowed file reads (`offset` or `limit` specified) up to 50 MB. Using a 64 KB chunk buffer and `StringDecoder`, seeking to any line range operates in $O(1)$ memory (< 200 KB heap) and exits early once the 50 KB output budget is met. Spillover files read without line arguments default to lines 1–250 with continuation instructions. Unconstrained reads on regular workspace source files exceeding 5 MB continue to fail closed to prevent accidental context blowups.
14
+
15
+ - **Fullwidth Dot Normalization**: Edits now convert the fullwidth full stop `.` (U+FF0E) to a regular `.` in search, replacement, and anchored line text, so models that emit fullwidth dots no longer produce broken code or failed matches. Enabled by default; turn it off with `/agent-kernel set normalize_dots off`, the settings dashboard, or `editing.normalize_fullwidth_dots = false`.
16
+ - **Notice When the Index Leaves Files Out**: When a workspace has more files than the code search index can hold, code search now starts its answer with one line saying how many files the index covers, how many source, test, and vendored files it left out and in which folders, and that `rg` still finds text in them. Workspaces that fit in the index see no change in output.
17
+ - **Syntax Check for More Languages**: Edits to Rust, Go, C, C++, Java, C#, Ruby, PHP, and Bash files are now checked with the bundled tree-sitter grammars; before, they were not checked at all. An error is reported only when the original file parsed without errors, so code the grammar does not understand never triggers a warning. On Rust, the check caught 739 of 804 broken edits and raised a false alarm on 1 of 473 valid ones in our tests; the other languages were not measured.
18
+
19
+ ### Changed
20
+
21
+ - **Unified 3-Tab Settings & Retrieval Controller**: Merged the separate `/engine` command into `/agent-kernel`, providing a unified 3-tab modal interface (`[1] Kernel Settings`, `[2] Retrieval Engine`, `[3] File Index Scope`). Standardized typography across all tabs using native theme colors, clean circular radio buttons (`◉`/`○`), geometric square checkboxes (`■`/`◪`/`□`), and semantic action icons (`↺`/`✕`). Removed 600+ lines of redundant command and TUI code.
22
+ - **Tool Schema Completeness & Contrastive Redirection**: Completed parameter annotations for all nested properties in `edit` (`edits[].search`, `edits[].line_hint`, `files[].path`, `files[].search`, `files[].line_hint`, `files[].edits`) and added contrastive boundaries across `edit`, `read`, and `code_search` descriptions to prevent tool confusion.
23
+ - **Directory Rules Streamlining**: Consolidated repository `AGENTS.md` by de-duplicating root instructions, converting stacked negative constraints into affirmative targets, and offloading specialized container and release runbooks into `docs/podman-linux-checks.md` and `docs/release-discipline.md`, reducing prompt rule context by over 63% (~3,100 tokens saved per turn).
24
+ - **Evidence-Driven Navigation Guidance**: System prompt guidance in `AGENT_KERNEL_SYS_PROMPT.md` now explicitly directs tool selection based on verified evidence: call `code_search` first when the implementation location of a feature or concept is unverified, use `rg -n` for known code symbols, literal strings, and non-code file types (CSS, JSON, YAML, Markdown), and use targeted `read` ranges before editing.
25
+
26
+ - **Faster Search Startup in Reopened Workspaces**: The code search index now reuses saved results for files that have not changed instead of re-parsing every file at startup, and updating or removing a file no longer rescans the whole index. Re-syncing an unchanged 500-file repository dropped from about 2.6 s to 0.7 s in our measurements, with identical search results.
27
+ - **Faster Code Search Queries**: Before each search, the index now re-reads only files whose size or modification time changed, and reuses its list of workspace files until a folder or ignore file changes, instead of re-reading every file and walking the whole workspace. A search on a 500-file repository dropped from about 340 ms to 20 ms in our measurements. A change that leaves modification times untouched (tools that restore them, some network filesystems) is picked up at the next change or re-index.
28
+ - **Search Puts Source Code First**: Code search now returns the best source matches first and lists up to three test matches after them, so tests that describe behavior in plain words no longer push the implementing code out of the results. Searches whose query or file filter mentions tests or specs keep the mixed ranking. On held-out fixes from TypeScript and JavaScript projects, the right file ranked first in 18 of 43 searches, up from 10. A result can therefore hold up to three matches more than its limit (eight instead of five with the default limit); the median result grew by 6–28% in our tests.
29
+ - **Rust Tests No Longer Crowd Out Source Code**: Rust unit tests that live inside source files (`#[test]` functions and `#[cfg(test)]` modules) are now treated as tests, so code search lists them after the source matches instead of in their place. In our tests on four Rust repositories, inline test code no longer took any of the top source results; before, it had taken 18 of 152.
30
+ - **Large Workspaces Index Their Own Code First**: When a workspace has more than 500 indexable files, the code search index now takes the project's source files first, then tests, then vendored code (folders named `deps`, `third_party`, `external`, and similar), instead of whichever files the folder listing returned first. In redis, whose `deps/` folder used to fill the whole index, the right file now appears in the top five results for 16 of 20 past fixes, up from 0. In four other large C projects (libgit2, git, neovim, curl) it did so for 16 of 48 fixes, up from 15. Workspaces with 500 or fewer indexable files are indexed exactly as before. On very large workspaces each search does more bookkeeping: about 90 ms more per search on a 20,000-file tree in our measurements.
31
+ - **Search Answers Show More of the Matching Code**: Code search now previews the top five matches instead of three, and shows a previewed match of up to 2,000 characters in full instead of a 12-line excerpt that often missed the relevant lines. On 168 recorded searches, the answer showed the lines a real fix changed in 72 searches instead of 47 (25 better, none worse). Answers grew by a median of about 400–500 tokens and still stay within the output limit.
32
+ - **Better Code Embeddings for the `full` Profile; `hybrid` Merged into `full`**: The `full` profile now embeds code with `Alibaba-NLP/gte-modernbert-base` (Apache-2.0, ~147 MB download on first use) instead of `nomic-embed-text-v1.5`. On 104 held-out searches (fixes from TypeScript and JavaScript projects plus recorded agent queries), the right file appeared in the top five results for 85 searches instead of 66, and the right code chunk for 73 instead of 32; with the old model, `full` found fewer right files and chunks than the default `lean` profile (82 and 67). Across 168 searches in Rust, C, C++, Python, TypeScript, and JavaScript projects, `full` now finds the right file for 125 searches against 114 for `lean`, and the right chunk for 103 against 92; this lead over `lean` is not yet statistically significant, so `lean` stays the default. Indexing a 765-chunk project took 15% less time and about 460 MB less memory than before; each search takes about 20 ms longer (40 ms median). The new model has no smaller-vector mode, so the separate `hybrid` profile is gone: `hybrid` still works as an alias for `full`, and `auto` now picks `full` on machines with 4 or more CPU cores (previously `hybrid` on 4–7 cores, which indexed on one core instead of two). The minimum similarity for a vector match was recalibrated from 0.55 to 0.45 for the new model. Saved vector caches now record which model produced them, so existing vectors are re-embedded once after upgrading.
33
+ - **One Search Cache Rebuild After Upgrading**: The Rust test, alias, C++, and C/C++ type-reference changes in this release change how code is indexed, so existing search caches are rebuilt once after upgrading.
34
+ - **Faster Syntax Check for Edits**: Each edit is now checked once instead of twice, and TypeScript, TSX, and JSX edits that tree-sitter parses without errors no longer start `tsc`. Anything tree-sitter flags, or a file it cannot fully parse, is still decided by `tsc`, because the grammar lags the language. In our measurements a valid TypeScript edit took about 2 ms to check instead of about 340 ms, with the same verdicts as `tsc` on 1,776 test edits. The temporary copy used for checking is now written to the system temp folder instead of a `.pi-agent-kernel-validate-*` folder next to the edited file.
35
+
36
+ ### Fixed
37
+
38
+ - **File Index Scope Persistence & Excluded Path Guards**: Excluded paths configured in Tab 3 of the Unified Control Modal are now persisted directly to `.pi/config.toml` via `saveProjectKernelConfig` so they survive session reloads, and incremental `updateFile` calls strictly enforce active path exclusions.
39
+ - **Clean Block Deletion Without Phantom Blank Lines**: Deleting whole-line blocks of code with `replace: ""` across exact, whitespace-normalized, and fuzzy strategies now cleanly consumes surrounding line breaks, preventing phantom blank lines from remaining in the file. Inline substring deletions within a single line leave surrounding lines intact, and `replace: null` is normalized to `""`.
40
+ - **Command Output Spillover Files Larger Than 5 MB Can Now Be Read**: When a command output exceeded 5 MB, output clamping stored the full output in a spillover log and suggested inspecting it with `read({ path, offset, limit })`, but `read` rejected the file because it exceeded the 5 MB in-memory read limit. Authenticated spillover logs can now be read and paged through regardless of whether they exceed 5 MB (up to 50 MB).
41
+ - **Spillover Deduplication and Collision Prevention**: When a command failed, timed out, or formatted sizes with decimals (`50.0KB`), trailing status notices (`Command exited with code N`, `Command timed out after N seconds`) prevented Agent Kernel from detecting the host's existing spillover log. Agent Kernel would save the already-truncated fragment into a second spillover file, permanently losing the initial output lines and generating desynchronized line coordinates. Host truncation footers, alternative inverted formats (`[Full output: <path> ...]`), decimal line sizes, and trailing status lines are now reliably detected, preserving the host log as the single source of truth without writing redundant partial files. Re-clamping previously clamped outputs with inspection recipes is now idempotent and avoids stacked truncation footers.
42
+
43
+ - **No Phantom Symbols from Exported Code**: Code search no longer indexes fake alias symbols built from `x as y` text inside exported functions, classes, and constants (for example, `value as unknown` produced a symbol named `unknown`). Real `import { a as b }` and `export { a as b }` aliases are still indexed.
44
+ - **C++ Code Is Now Searchable**: Code search now indexes `.cc`, `.cxx`, `.hh`, and `.hxx` files, which it previously skipped entirely, and parses `.h` headers as C++ when they contain C++ code, so classes and methods in them become searchable. In our tests on four C++ repositories, the right file appeared in the top five results for 11 of 14 fixes made in `.cc` files, up from 1. Plain C headers are parsed exactly as before.
45
+ - **Visible Notice When Code Parsing Is Unavailable**: If a tree-sitter grammar cannot be loaded, code search now says so at the top of its results instead of silently falling back to a simpler parser for those files. The `web-tree-sitter` dependency is pinned to the version the bundled grammars were tested with, so installs no longer pick up untested runtime versions.
46
+ - **C and C++ Type References Are No Longer Indexed as Definitions**: Code search no longer records `struct` and `class` type references and forward declarations without a body (for example, `struct node *next;`) as type definitions. They added one-line junk results and duplicate entries that skewed keyword-ranking statistics. In our tests on 32 repositories, this removed 9,780 such entries (tmux went from 6,097 to 2,922) and all 152 duplicates; Python, Rust, TypeScript, and JavaScript indexes are unchanged. On 88 recent C fixes, results changed for 8 searches: the right file entered the top five in 2 and dropped out in 1, and the right code dropped out in 3, because keyword-ranking statistics shifted (not statistically significant).
47
+ - **Empty Search Results Name the File Filter When It Is the Cause**: When a code search file filter matches no indexed file (for example `README`, because Markdown and configuration files are not indexed), the answer now says so and points to `rg`, instead of reporting no matching code and suggesting broader search terms. Searches whose filter matches indexed code keep the previous message.
48
+ - **Code Search Works in Workspaces with Very Many Code Chunks**: In a workspace with more than 10,000 code chunks (functions, classes, and similar), every code search failed with "Workspace changed repeatedly while indexing". Searches now succeed: files that do not fit are left out of the index and reported as skipped, and the index stays up to date as files change.
49
+ - **Clearer Recovery from Tool Mix-Ups**: When an agent sends a shell command to `read` or `edit`, the error now names the `bash` tool and the exact call to make, instead of a generic missing-path error.
50
+ - **Edit Errors Name the Actual Mistake**: An edit with a search block but no replacement now explains how to delete the block with `edits: [{ search, replace: "" }]`. Some model routes silently drop an empty top-level `replace`, which previously caused the same failing edit to repeat. An edit sent read-style `offset`/`limit` arguments now points to the `read` tool.
51
+ - **Tool Failures Are Marked as Errors**: Failed `edit`, `read`, and `code_search` calls now reach pi as errors. pi marks a result as an error only when the tool throws, so these failures looked like successful results: collapsed in the interface, and sent without an error flag to models whose APIs carry one (Anthropic, Bedrock, Google, and Mistral; OpenAI's APIs have no such flag).
52
+ - **JavaScript Syntax Errors in ES Modules Are Caught**: The syntax check missed syntax errors in `.js` files that use `import` or `export` when the project's `package.json` sets no `"type"`, because `node --check` reports such files as valid (Node 24). JavaScript is now checked as an ES module and as CommonJS, and is valid when either parses. In our tests on such a project, the check caught all 727 broken edits instead of 427.
53
+
3
54
  ## [0.5.0] - 2026-10-25
4
55
 
5
56
  ### Added
package/README.md CHANGED
@@ -40,10 +40,9 @@ Restart Pi or start a new session.
40
40
  /engine status
41
41
  ```
42
42
 
43
- - `auto`: Selects `lean` on remote servers, `hybrid` on laptops, or `full` on desktops based on available hardware.
43
+ - `auto`: Selects `lean` on machines with fewer than 4 CPU cores and `full` otherwise.
44
44
  - `lean` (default): AST-indexed BM25 keyword search with no extra memory footprint.
45
- - `hybrid`: BM25 search combined with 256-dimension Matryoshka embeddings.
46
- - `full`: 768-dimension dense semantic search.
45
+ - `full`: BM25 search fused with 768-dimension code embeddings from `gte-modernbert-base` (~147 MB, downloaded on first use). `hybrid` is accepted as an alias.
47
46
  - `off`: Disables local indexing completely.
48
47
 
49
48
  ---
@@ -19,6 +19,7 @@ exec_timeout_ms = 5000
19
19
  mode = "smart_anchor"
20
20
  default_anchors = true
21
21
  read_mode = "auto"
22
+ normalize_fullwidth_dots = true
22
23
 
23
24
  [ui]
24
25
  enable_pastel_footer = true
@@ -22,7 +22,7 @@ Settings can be managed via the `/agent-kernel` interactive modal or CLI subcomm
22
22
 
23
23
  ### `[retrieval]`
24
24
 
25
- - `default_profile`: `auto`, `lean`, `hybrid`, `full`, or `off`.
25
+ - `default_profile`: `auto`, `lean`, `full`, or `off` (`hybrid` is accepted as an alias for `full`).
26
26
  - `max_search_results`: result limit for code search.
27
27
 
28
28
  ### `[safety]`
@@ -8,12 +8,28 @@ to `src/editing/patch.ts`.
8
8
  1. Resolve the target path.
9
9
  2. Apply one search/replace block or multiple disjoint blocks.
10
10
  3. Enforce the read-before-write guard for existing files when enabled. Successful edits update the epistemic ledger to maintain continuity across sequential edits without redundant reads.
11
- 4. Validate the complete candidate content with the bounded local syntax gate; the target is written only after validation succeeds.
11
+ 4. Check the syntax of the complete candidate content (see below). With the default `editing.syntax_gate = "warn"`, a candidate that fails is still written and the failure is reported; with `"block"`, the target is left unchanged.
12
12
  5. Return compact status text and structured verification details.
13
13
 
14
14
  The patch engine tries exact and normalized matching strategies and refuses an
15
15
  ambiguous or missing match rather than guessing.
16
16
 
17
+ ## Syntax check
18
+
19
+ Each edit is checked once, before writing, on a copy in the system temp folder.
20
+
21
+ - TypeScript, TSX, and JSX: tree-sitter clears the edit when it finds no error
22
+ in the new content or in the original; anything else is decided by `tsc`
23
+ (parse only). The tree-sitter grammar lags the language, so its errors alone
24
+ never fail an edit.
25
+ - JavaScript: `node --check`, as an ES module and as CommonJS; the content is
26
+ valid when either parses.
27
+ - Python: `py_compile`. JSON: `JSON.parse`.
28
+ - Rust, Go, C, C++, Java, C#, Ruby, PHP, and Bash: tree-sitter. Errors are
29
+ reported only when the original file parsed without errors; otherwise the
30
+ check is `not run`.
31
+ - Other files: `not run`.
32
+
17
33
  ## Verification states
18
34
 
19
35
  The renderer keeps uncertainty explicit:
@@ -30,10 +46,9 @@ These states must not be collapsed into `clean`.
30
46
  ## Repository history
31
47
 
32
48
  The extension does not automatically stage, commit, reset, or otherwise alter
33
- a repository. Edits only modify the requested file after the
34
- candidate passes the local syntax gate.
49
+ a repository. Edits only modify the requested file.
35
50
 
36
51
  The edit result reports verification in `details`, while the visible message
37
- remains compact. Failed candidate validation leaves the target unchanged and
38
- reports the failure. Post-write diagnostic failures do not roll back an
52
+ remains compact. With `syntax_gate = "block"`, failed candidate validation
53
+ leaves the target unchanged and reports the failure. Post-write diagnostic failures do not roll back an
39
54
  already-valid edit; their uncertainty remains explicit.
@@ -0,0 +1,24 @@
1
+ # Podman-Backed Linux Checks from Windows
2
+
3
+ Guidelines for running disposable Linux container tests from Windows:
4
+
5
+ 1. **Pre-flight Machine Verification:**
6
+ - Run `podman --version`, `podman machine list`, `podman system connection list`, and `podman info` before running containers.
7
+ - An installed CLI does not mean a Linux machine exists or is running. Do not initialize or start a machine without authorization (`machine init` downloads an image and allocates disk/RAM/CPU).
8
+ - Inspect available host resources before initialization.
9
+
10
+ 2. **WSL Resource Limits & Fallbacks:**
11
+ - On WSL, compare configured resources (`podman machine inspect`) with container reports (`nproc`, `free -h`, cgroup limits).
12
+ - If Podman fails due to unavailable controllers (e.g. `pids`), `podman run --cgroups=disabled` may work, though resource limits will not be enforced. State this limitation explicitly.
13
+
14
+ 3. **Path Conversion in MSYS2 / Git Bash:**
15
+ - Git Bash / MSYS may rewrite Windows path arguments. Prefer streaming a tracked source snapshot into the container (`scripts/podman-linux-check.sh`) over host bind mounts.
16
+ - If a Windows path must be passed, set `MSYS_NO_PATHCONV=1` for that command and verify the resolved container path.
17
+
18
+ 4. **Disposable Containers & Temp Isolation:**
19
+ - Use a disposable container and a fresh Linux `TMPDIR`. Do not inspect or modify shared host temp directories.
20
+ - Include tracked working-tree files only; untracked/ignored files (including local benchmarks and `.env` files) must remain excluded. Never copy secrets into a container.
21
+
22
+ 5. **Recovery & Cleanup:**
23
+ - Inspect `podman ps -a` and container logs after timeouts.
24
+ - Stop and remove only the specific disposable container created for the task. Never use broad prune or reset commands.
@@ -0,0 +1,10 @@
1
+ # Release, Changelog, and Packaging Discipline
2
+
3
+ ## 1. Changelog and Release Notes
4
+ * **Audit the Authoritative Commit Baseline:** When updating `CHANGELOG.md` or preparing release notes, audit all commits from the previous release tag: `git log --oneline <previous-release-tag>..HEAD`. Never rely on session memory, recent turns, or unanchored branch comparisons.
5
+ * **Substantiate Claims from Diffs:** Cross-check every listed feature, security fix, bug resolution, and configuration default against actual commit diffs before asserting completion.
6
+
7
+ ## 2. CI/CD, Tagging, and Publication
8
+ * **Verify Workflow Triggers Before Asserting Publication:** Inspect `.github/workflows/` to confirm exact trigger conditions. Distinguish branch-push CI verification from tag-triggered release pipelines. Never report that a package is released merely because branch commits were pushed.
9
+ * **Explicit Filesystem Paths for Package Artifacts:** When passing tarball or local artifact paths to package managers (e.g. `npm publish`), always use explicit relative paths (e.g. `./release-package/${filename}`). Unprefixed `<folder>/<file>` paths can be parsed as remote repository specs (such as GitHub shorthand) and cause unexpected network operations or permission failures.
10
+ * **Fail-Closed Registry Guards:** Automated publication guards querying registry state (`npm view`) must fail closed. Treat successful lookups as "already published." Treat unsuccessful lookups as blocking errors unless a structured registry response specifically proves that the exact requested version is absent. Never treat bare `E404`, generic `could not be found`, or network/auth errors as absence evidence, as registries frequently mask permission and authentication failures behind 404 responses.
package/docs/retrieval.md CHANGED
@@ -16,20 +16,23 @@ fast discovery does not require loading the local embedding model.
16
16
  ## Profiles
17
17
 
18
18
  - `lean`: AST-aware BM25 search with minimal startup cost.
19
- - `hybrid`: BM25 combined with local embeddings when available.
20
- - `full`: the highest-cost configured retrieval profile.
19
+ - `full`: BM25 fused with 768-dimension embeddings from the local
20
+ `Alibaba-NLP/gte-modernbert-base` code embedder (q8, ~147 MB, pinned revision).
21
+ `hybrid` is accepted as an alias for `full`.
21
22
  - `off`: disables retrieval indexing where supported.
22
- - `auto`: lets the runtime select the configured/default profile.
23
+ - `auto`: selects `lean` below 4 CPU cores and `full` otherwise.
23
24
 
24
25
  During indexing, search can fall back to the lean path rather than blocking on
25
- model initialization. Hybrid/full profiles require vector cosine similarity of at
26
- least 0.6 before candidates enter reciprocal-rank fusion; lower-confidence vector
27
- candidates are abstained from while BM25 results remain available. This floor is a
28
- conservative initial boundary measured on the bounded feedback fixture and must be
29
- recalibrated against a larger labeled corpus before changing it. Output limits
30
- remain enforced so retrieval cannot flood agent context.
31
-
32
- The `code_search` index is intentionally code-only: Markdown and other text files remain readable but are not chunked or embedded for retrieval.
26
+ model initialization. The full profile requires vector cosine similarity of at
27
+ least 0.45 before candidates enter reciprocal-rank fusion; lower-confidence vector
28
+ candidates are abstained from while BM25 results remain available. The floor is the
29
+ highest one that dropped no top-5 hit on 168 held-out queries (`DENSE_SIMILARITY_FLOOR`
30
+ in `search_config.ts`); recalibrate it whenever the embedding model changes. Vector
31
+ caches are tagged with the model and revision that produced them, and caches from
32
+ another model are re-embedded rather than reused. Output limits remain enforced so
33
+ retrieval cannot flood agent context.
34
+
35
+ The `code_search` index covers source code and HTML files (`.html`, `.htm`): HTML files are chunked into structural DOM groups with leaf-control rollup, parent suppression, and inline `<style>`/`<script>` boundaries. Markdown and configuration files (JSON, YAML, TOML, CSS) remain readable but are not chunked or embedded for retrieval.
33
36
 
34
37
  Code-search path filters match normalized relative path substrings
35
38
  (including directory fragments, filenames, and extensions). `code_search` reports
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floydous/pi-agent-kernel",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Focused code retrieval, editing, and safety checks for Pi.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -24,7 +24,7 @@
24
24
  "ignore": "^7.0.5",
25
25
  "typebox": "^1.3.16",
26
26
  "typescript": "^7.0.2",
27
- "web-tree-sitter": "^0.26.12"
27
+ "web-tree-sitter": "0.26.12"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@earendil-works/pi-coding-agent": "0.84.3",