Skip to content

feat: Bucket A — payload reduction + first-class upload#2

Merged
kepptic merged 9 commits intomainfrom
feat/bucket-a-payload-reduction
Apr 21, 2026
Merged

feat: Bucket A — payload reduction + first-class upload#2
kepptic merged 9 commits intomainfrom
feat/bucket-a-payload-reduction

Conversation

@kepptic
Copy link
Copy Markdown
Owner

@kepptic kepptic commented Apr 21, 2026

Summary

Six flags and one new verb to cut payload size for LLM operators driving ghax. Sourced from the 2026-04-20 jnremache field report (see plan.md follow-up sprint, Bucket A).

Payload reduction

  • screenshot --full-page — kebab alias matching the rest of the CLI convention (TASK-001, + drive-by for responsive)
  • tabs --filter <regex> --fields <csv> — server-side regex + field projection, ~200 bytes saved per google-product tab (TASK-002)
  • eval --max-bytes <N> — utf-8 byte cap on result, returns {value, truncated, originalBytes} on trip (TASK-003)
  • text --selector --length --skip — scoped, paged page-text dumps; replaces hand-rolled innerText.substring(...) (TASK-004)
  • snapshot --compact + -i — compact mode now suppresses the cursor-interactive pass that dominates output on heavy SPAs (TASK-006)

Ergonomics

  • upload <@ref|selector> <path>[,<path>…] — first-class file upload verb wrapping locator.setInputFiles. Replaces a 30-line hand-rolled CDP shim the field session used 5x (TASK-005)

Housekeeping

  • task-memory scaffolding (planning docs + CLAUDE.md append) so future sprints have a tracked home.

Test Coverage

Added 11 new smoke assertions — one per new flag, plus error-path coverage (invalid regex on --filter, missing arg on upload, --max-bytes pass-through vs truncation, --compact vs -C override).

All 60+ smoke checks pass against the Rust binary (GHAX_BIN=target/release/ghax npm run test:smoke), exit 0.

Pre-Landing Review

Reviewed inline during autopilot run. No unfixed issues. Fix-First items addressed:

  • responsive handler needed matching --full-page support after README called it out (fixed in 6fa6579).

Manual QA (live browser)

Verified against a running Edge on :9222:

  • tabs --filter example --fields id,url --json — correct filter + projection
  • text --selector h1 / --length 20 / --skip 8 --length 13 — correct slices
  • eval '"x".repeat(100)' --max-bytes 20{value:"xxxxxxxxxxxxxxxxxxxx", truncated:true, originalBytes:100}
  • snapshot -i vs snapshot -i --compact — cursor-interactive section dropped in compact mode
  • screenshot --full-page — 52 KB PNG written
  • --help surfaces the new verbs and flags

Plan Completion

All six Bucket A items from plan.md marked done:

  • §1 screenshot --full-page
  • §2 tabs --filter --fields
  • §3 eval --max-bytes
  • §4 text --selector --length --skip
  • §5 upload
  • §6 snapshot --compact suppresses cursor pass

Buckets B/C/D (stable refs, React fill fallback, dialog-aware walker, papercut bundle, docs-only items) remain queued in plan.md.

Documentation

  • CHANGELOG.md [Unreleased] covers all six items.
  • README.md command surface reflects every new flag + the kebab-alias rename.
  • No ARCHITECTURE changes — these are surface additions, not structural.

Test plan

  • npm run typecheck — clean
  • cargo build --release — clean
  • npm run build — clean (78.8kb daemon bundle)
  • GHAX_BIN=\$PWD/target/release/ghax npm run test:smoke — 60+ checks, exit 0
  • Manual QA against live Edge on :9222

🤖 Generated with Claude Code

kepptic added 9 commits April 20, 2026 23:02
task-memory init from /tm-init run
The CLI convention is kebab-case everywhere else; --fullPage was a
v0.1 holdout. Accept both forms — kebab is preferred going forward,
camelCase stays for back-compat with live scripts.

Refs: docs/planning/sprint-bucket-a.md §1 (GHAX-FR-06)
Cuts payload per-tab when the operator only needs a narrow slice.
The jnremache field session averaged 200 bytes/tab of query-string
noise on google-product tabs; --fields id,title trims that.

--filter runs a case-insensitive regex against both url and title.
--fields projects only the listed keys (id, title, url, active);
unknown keys silently ignored to keep a typo from killing the call.

Refs: docs/planning/sprint-bucket-a.md §2 (TOK-04)
Caps the stringified eval result at N utf-8 bytes so an accidental
document.body.innerText on a heavy page can't blow out an LLM
operator's context window. On trip, returns {value, truncated:true,
originalBytes} — shape is unchanged when under cap.

Byte slicing uses Buffer.subarray so the count matches what the
network actually transfers, not .length's code-unit count. Slicing
may land mid-codepoint; that's fine — the point is hard containment.

Refs: docs/planning/sprint-bucket-a.md §3 (TOK-02)
…-004)

Replaces the hand-rolled
  document.body.innerText.substring(skip, skip+length)
pattern the jnremache session used 40+ times. --selector scopes to
one element (via locator.innerText, so CSS-hidden content is still
excluded like the default path). --length/--skip paginate the
returned string.

Daemon still pulls full innerText — the win is on the wire, which
is where the operator's context budget actually lives.

Refs: docs/planning/sprint-bucket-a.md §4 (TOK-10)
Replaces the hand-rolled 30-line Node + ws shim the jnremache
session used 5x to hit DOM.setFileInputFiles directly. Wraps
Playwright's locator.setInputFiles which already handles the CDP
plumbing, multi-file inputs, and MIME sniffing.

Paths are resolved relative to the daemon's cwd (captured at
attach time). Comma-separated values select multi-file mode.

Rust dispatch checks positional arity before the RPC round-trip
so the Usage line fires instantly on operator typos.

Refs: docs/planning/sprint-bucket-a.md §5 (JNR-07)
On heavy SPAs (hundreds of cursor:pointer divs across Radix/Headless
portals), the cursor-interactive section dominates snapshot output
and is usually not what an operator wants when they asked for a
compact dump. Gate the implicit -i-driven scan on !opts.compact.

Explicit -C (cursorInteractive) still forces the scan on — that's
an opt-in ask. Only the implicit coupling via -i is broken.

Refs: docs/planning/sprint-bucket-a.md §6 (TOK-01)
Matches the TASK-001 change for screenshot. README was updated to
advertise --full-page on both verbs; this keeps the daemon honest.

Refs: docs/planning/sprint-bucket-a.md §1 (GHAX-FR-06)
- CHANGELOG [Unreleased] — new section covering the six Bucket A
  items (screenshot --full-page, tabs --filter/--fields,
  eval --max-bytes, text --selector/--length/--skip, upload verb,
  snapshot --compact suppresses cursor-interactive).
- README command surface updated to advertise the new flags.

No ARCHITECTURE changes — these are surface additions, not
architectural shifts.
@kepptic kepptic merged commit 15964ba into main Apr 21, 2026
4 checks passed
@kepptic kepptic deleted the feat/bucket-a-payload-reduction branch April 21, 2026 03:06
kepptic added a commit that referenced this pull request Apr 24, 2026
feat: Bucket A — payload reduction + first-class upload
kepptic added a commit that referenced this pull request Apr 24, 2026
feat: Bucket A — payload reduction + first-class upload
kepptic added a commit that referenced this pull request Apr 24, 2026
feat: Bucket A — payload reduction + first-class upload
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