Optimize memory usage, improve YAML parsing, and add CLI enhancements#3
Merged
Binb1 merged 2 commits intofeat/ags-v0from Apr 4, 2026
Merged
Conversation
- Security: cap fetch body size regardless of content-length header - Performance: stream JSONL parsing in stats instead of readFileSync - Accuracy: word+symbol token estimation replacing naive length/4 - Safety: add --dry-run flag for grab and rm commands - UX: support short flags (-j, -a), --key=value syntax in arg parser - Parser: proper multi-line string support (| and >) in YAML frontmatter - Fix: cleanDirName strips only actual HOME prefix, not project names - Fix: JSON output in grab/rm uses explicit return after printJson - Perf: memoize findProjectRoot to avoid repeated fs walks - Tests: add 61 unit tests for parser, tokens, health, github, args https://claude.ai/code/session_01879LywhiKaXPsPbcsGgpZi
- Cut from 61 to 15 focused regression tests - Remove args.test.ts (was testing duplicated code) - Add CI workflow: typecheck + test on push/PR to main https://claude.ai/code/session_01879LywhiKaXPsPbcsGgpZi
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
This PR improves performance and reliability across multiple areas: streaming large JSONL files to reduce memory footprint, enhancing the YAML parser to support multi-line strings, refining CLI argument parsing with short flags, and adding comprehensive test coverage.
Key Changes
Memory & Performance
readFileSyncwith streaming instats.tsto handle large session files without loading entire contents into memoryfindProjectRoot()to avoid repeated filesystem traversalYAML Parser Enhancement
|) and folded (>) blocks in skill frontmatterflushMultiLine,flushList) for cleaner state managementCLI Improvements
-j(json),-a(agent),-t(type),-s(scope),-p(period),-v(version),-h(help)-js) with proper boolean/value handling--key=valuesyntax for long flagsDry-Run Support
--dry-runflag tograbandrmcommands for preview modedryRunflag in JSON output responsesGitHub Fetch Robustness
response.text()with streaming reader to enforce size limits regardless of content-length headerPath Cleaning Logic
cleanDirName()with two-phase approach: strip HOME prefix segments in order, then skip container directoriesTesting
https://claude.ai/code/session_01879LywhiKaXPsPbcsGgpZi