LLM-optimized output summarizer. Pipe command output in, get token-efficient head/tail + regex-matched lines, plus an ID to drill deeper.
- POSIX sh, single file, works everywhere
- Storage in XDG cache dir
- All matchers OR together, head/tail always shown
- Built-in presets hardcoded, user presets in config file
- Created folder structure
- Implemented full glance script (~350 lines POSIX sh)
- All features: pipe mode, head/tail, -n, -f, -p, --no-store
- Subcommands: show (full, --lines, --filter, --around), list, clean, presets, help
- 47/47 integration tests passing
- README.md report
printf '--- ...'fails in some shells because format string starting with-gets parsed as option. Useprintf '%s\n' "--- ..."instead.wc -lcounts newlines, soprintf '%s' "text"(no trailing newline) gives count off by one. Always useprintf '%s\n'when piping towc -l.- POSIX sh has no arrays — used newline-separated strings with
IFSmanipulation for built-in presets. grep -Edoesn't support(?i)for case-insensitive. Usedgrep -iEinstead.- Cross-platform
statfor mtime: try GNUstat -c %Yfirst, then macOSstat -f %m, then fallback.
Three subagents reviewed the project: code reviewer, new-user tester, agent needle-in-haystack.
- O(n²) sed loop — fixed. Replaced per-line
sed -n Npwith single-pass awk in do_pipe and sed range + awk in do_show --around. -
wc -lundercounts — fixed. Replacedwc -lwithawk END { print NR }which counts records regardless of trailing newline. - No
-nvalidation — fixed. Reject non-numeric values before processing input. -
timingpreset too broad — fixed. Removed the preset entirely; users can add their own viaglance presets add.
- [-] Partial ID matching missing — cancelled. Full IDs required by design. Updated help and README examples to use full IDs.
- [-] No gap indicator — cancelled. Line numbers make gaps obvious; adding
...wastes tokens, counter to design goals.
- "1 lines" grammar — fixed. Added plural_lines helper for singular/plural in headers.
- [-] Help examples use short IDs — fixed alongside #5, examples now use full IDs.
- [-] TOCTOU race — cancelled. Timestamp + 8-char random hex makes collisions near-impossible. Removed the unnecessary retry loop.
- No validation on
--linesrange format — fixed. Reject non-numeric values before passing to sed.
Replaced pipe-delimited built-in and tab-delimited user preset formats with sed-style format where first char is delimiter. Added parse_preset_line helper, auto-delimiter selection, -d flag.
- Comments and blank lines preserved through add/remove
- Preset update (re-add same name) replaces old entry
- Unknown preset with
-pproduces error -
presets addwith missing args shows usage -
clean --allremoves user presets -
--aroundnear boundaries (line 1, last line) -
--linesand--filterlong-form flags in pipe mode - Description containing delimiter round-trips correctly
-
-n 0should error — added0to rejection case pattern - Missing value for
-f/-p— added[ $# -ge 2 ]guards - Preset name validation — added alphanumeric+hyphen+underscore check
82/82 tests passing.
Six agents reviewed the code: bug hunter, general reviewer, conciseness, test coverage, adversarial fuzzer, docs audit. Deduplicated findings below.
-
-dwith delimiter present in regex silently corrupts — fixed. Added validation rejecting delimiter if present in regex. - Preset names starting with
-conflict with flags — fixed. Reject names starting with-. -
-fpatterns starting with-passed as grep flags — fixed. Added--before user patterns in grep calls. -
--aroundno validation on center/context args — fixed. Added numeric validation for both args. - [-]
--linesin show accepts single number — skipped. Low priority, harmless behavior.
- Path traversal in
glance show— fixed. Validate capture ID rejects/and...
- Show flags mutually exclusive — fixed. Rewrote do_show to OR all flags together, matching pipe mode behavior.
- Case-insensitive matching undocumented — fixed. Added note to help text.
- Hardcoded
~/.configinglance help presets— fixed. Uses dynamic$GLANCE_CONFIGpath.
- Filter accumulation verbose — fixed. Used
${var:+|}idiom, saved 8 lines. - [-] Range-building in do_pipe — skipped. Already shorter after refactors; shell loops are clear enough.
- [-] Trap updated 3 times — already resolved. Only one trap after refactors.
- [-] Trivial helpers could inline — skipped. Names communicate intent, used in multiple places.
- [-] Help output — added then dropped. Smoke tests were too weak to be useful.
- Invalid regex — added test. awk errors on invalid regex, test confirms.
- Age formatting boundaries — added 7 boundary tests (0s, 59s, 60s, 3599s, 3600s, 86399s, 86400s).
- No subcommand for presets — added test. Confirms usage message.
- Delimiter exhaustion — added test. Confirms error when all candidates used.
- Built-in presets used
\s— awk doesn't support Perl-style\s. Changed to POSIX[[:space:]]. - Help text hardcoded preset list — now prints dynamically from
BUILTIN_PRESETS. - Displaced
format_agecomment — moved to correct location. - Shared
print_matched_linesfunction — unified pipe and show into single-pass awk. - Summary moved from header to footer — enables single-pass output.
109/109 tests passing.