Skip to content

Context-packing feature set: -elide, -hotspots, -budget, -ident, -seen, file-where/-order-by - #6

Merged
pinkhasn merged 4 commits into
mainfrom
feature-context-packing
Aug 1, 2026
Merged

Context-packing feature set: -elide, -hotspots, -budget, -ident, -seen, file-where/-order-by#6
pinkhasn merged 4 commits into
mainfrom
feature-context-packing

Conversation

@pinkhasn

@pinkhasn pinkhasn commented Aug 1, 2026

Copy link
Copy Markdown
Owner

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-mode rank into a shared src/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 (new src/ident.hpp/ident.cpp)
  • -file-where — extends the predicate grammar with count(pat), churn(days) (new git_churn() — one git log call, never one 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/seen.cpp), with correct handling of -budget's measure-then-discard case

Documentation updated in HPRSCRIPT.md (full reference), COOKBOOK.md (new §34, task recipes), and skills/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 warnings
  • make test — 522/522 passing (409 pre-existing + 113 new across the six features)
  • Manual verification of each feature's compat/exclusivity rules, edit-mode integration where applicable, and the -budget/-seen measure-then-discard edge case

🤖 Generated with Claude Code

pinkhasn and others added 4 commits August 1, 2026 13:57
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>
@pinkhasn
pinkhasn merged commit 92c2fc4 into main Aug 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant