Context-packing feature set: -elide, -hotspots, -budget, -ident, -seen, file-where/-order-by - #6
Merged
Merged
Conversation
Covers the new context-packing feature set in the full reference (HPRSCRIPT.md), the task-recipe cookbook (COOKBOOK.md, new section 34), and the hprscript skill agents load directly (SKILL.md) — trigger description, quick-reference table, power-feature subsections, agent recipes, and anti-patterns. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Six-part context-packing feature set turning hprscript into a deterministic, always-fresh alternative to embedding-based RAG for code search: - -elide: scope-aware chunk rendering — signature + matched lines, unmatched interior folded as "… (+N lines)" - -hotspots N: ranks files by rarity/coverage/proximity, extracted from script-mode `rank` into a shared src/rank.hpp/cpp - -budget N: packs ranked files into a byte budget (full -> one-line compact -> dropped, with a footer naming what didn't fit) - -ident 'term1 term2': matches identifiers by subtoken regardless of casing/separator (parseConfig ~ parse_config ~ ConfigParser), including acronym and digit-boundary splitting (new src/ident.hpp/cpp) - -file-where: extends the predicate grammar with count(pat), churn(days) (new git_churn() — one `git log` call, not per-file), and lang == <name> - -order-by score|count|path: sorts -f/-c output instead of streaming in walk order - -seen <path>: cross-invocation dedup for -elide/-budget so repeated agent queries don't re-pay tokens for unchanged code (new src/seen.hpp/cpp), with correct handling of -budget's measure-then-discard case 522 tests in tests/run.sh, all passing on a clean rebuild. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
glibc (Linux) names the POSIX nanosecond mtime field st_mtim; BSD/Darwin (macOS) names the same struct timespec st_mtimespec. Pre-existing on main, unrelated to the context-packing feature set — just surfaced now because this PR's edits shifted edit.cpp's line numbers into CI's view. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
GNU wc -l prints a bare number when reading a pipe/redirect; BSD wc -l (macOS) right-pads it with leading spaces even then, so the existing [[ "$COUNT" == "5" ]] string comparisons failed on macOS even though the actual counts were correct. Switched both to -eq (numeric comparison, which bash trims whitespace for regardless of platform). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Turns hprscript into a deterministic, always-fresh alternative to embedding-based RAG for code search — rank, elide, and budget-pack context for an LLM agent, without an index to go stale.
-elide— scope-aware chunk rendering: signature + matched lines, unmatched interior folded as… (+N lines)-hotspots N— ranks files by rarity/coverage/proximity, each with its densest match window; scoring extracted from script-moderankinto a sharedsrc/rank.hpp/rank.cpp-budget N— packs ranked files into a byte budget: full → one-line compact → dropped, with a footer naming what didn't fit-ident 'term1 term2'— matches identifiers by subtoken regardless of casing/separator (parseConfig~parse_config~ConfigParser), including acronym (HTTPServer) and digit (utf8) boundary splitting (newsrc/ident.hpp/ident.cpp)-file-where— extends the predicate grammar withcount(pat),churn(days)(newgit_churn()— onegit logcall, never one per file), andlang == <name>-order-by score|count|path— sorts-f/-coutput instead of streaming in walk order-seen <path>— cross-invocation dedup for-elide/-budgetso repeated agent queries don't re-pay tokens for unchanged code (newsrc/seen.hpp/seen.cpp), with correct handling of-budget's measure-then-discard caseDocumentation updated in
HPRSCRIPT.md(full reference),COOKBOOK.md(new §34, task recipes), andskills/hprscript/SKILL.md(the file Claude Code agents load directly — trigger description, quick-reference table, power-feature sections, recipes, anti-patterns).Test plan
make— clean rebuild, zero warningsmake test— 522/522 passing (409 pre-existing + 113 new across the six features)-budget/-seenmeasure-then-discard edge case🤖 Generated with Claude Code