feat: add stdin support for CLI using temp-file approach#68
Open
mvance wants to merge 13 commits intosteipete:mainfrom
Open
feat: add stdin support for CLI using temp-file approach#68mvance wants to merge 13 commits intosteipete:mainfrom
mvance wants to merge 13 commits intosteipete:mainfrom
Conversation
- Extend InputTarget type to include { kind: 'stdin' }
- Add resolveInputTarget handling for '-' input
- Implement stdin processing in runCli with temp file cleanup
- Update help text to document stdin support
- Add comprehensive tests for stdin functionality
- Follow existing error handling patterns
- Reuse handleFileInput logic for minimal changes
- Fix import duplication: use fs.readFile consistently - Optimize Buffer handling in streamToString function - Fix edge case: check for existing file named '-' before treating as stdin - Add test file cleanup with afterAll hook - Add streaming size limit check to prevent OOM (50MB max) - Update README with stdin documentation and examples - Add stdin examples to CLI help text - Improve error messages for stdin size limits
- Fix help text: change --length bullet to valid --length short preset - Add stdin to RunEnv type for dependency injection - Use injected stdin from RunEnv instead of hardcoded process.stdin - Handle false return from handleFileInput with explicit error - Add random suffix to temp file name for uniqueness - Fix fragile test assertion to properly verify stdin processing
- Add stdin-specific error message when using --extract with piped input - Update test to expect new error message - Optimize streamToString to avoid redundant Buffer copying when chunk is already a Buffer
- Remove cat file.txt | summarize - example from help.ts and README.md (passing filename directly is more practical) - Remove curl -s https://example.com | summarize - example (summarize can fetch URLs directly) - Remove cat file.txt | summarize - from concise help - Remove LESSONS_LEARNED.md (not intended for upstream) - Keep pbpaste | summarize - as primary stdin example (this is the most useful real-world use case)
- Update restriction to allow --markdown-mode llm for stdin and file inputs - Reject other markdown modes (readability, auto, off) with clear error message - Add tests for --markdown-mode llm allowance and other mode restrictions - Error message indicates --markdown-mode llm transcript formatting is coming soon - Follows CodeRabbit recommendation to support --markdown-mode llm use case
The third guard was contradicting the intended logic: - First guard: Allow URL/file/stdin - Second guard: Only allow llm mode for file/stdin - Third guard (BUG): Rejected file inputs even with llm mode Removed the redundant third guard since the first guard already restricts to URL/file/stdin, making the third guard unreachable and buggy. CodeRabbit issue: #3 (comment)
- Update README.md to remove 'file contents' from notes (removed examples) - Fix awkward usage string in concise help: <url-or-file-or--> -> <input> - Clarify --markdown-mode error message for file/stdin inputs - Update test expectation for new error message
This was referenced Feb 7, 2026
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 adds stdin support to the summarize CLI, allowing users to pipe content directly into the tool using
-as the input argument. This is particularly useful for summarizing clipboard content and integrating with shell workflows.Changes
Core Implementation
InputTargettype to include{ kind: 'stdin' }insrc/content/asset.tsresolveInputTarget()to recognize-(including surrounding whitespace) as stdin inputrunCli()using temp-file approach:handleFileInputlogic to minimize code duplicationstdinfrom RunEnv (falls back to process.stdin)Error Handling
Documentation
pbpaste | summarize -Testing
tests/input.resolve-input-target.test.tstests/cli.stdin.test.tswith 6 tests covering:Usage Examples
Technical Details
handleFileInputlogic, minimizing changes and maintaining consistency-to represent stdinPerformance
Future Enhancements
This PR lays groundwork for future transcript markdown formatting support via
--markdown-mode llmfor stdin/file inputs.Verification
CI Status Note
The
extension-e2etest failures shown in CI are pre-existing flaky tests that are also failing on the main branch. These failures are unrelated to the stdin support changes in this PR. The extension E2E tests involve Chrome browser automation that is sensitive to timing and environment conditions.All relevant unit tests pass successfully:
test (22): ✅ Passtest (24): ✅ PassGitGuardian Security Checks: ✅ PassRelated
This implements stdin support using the temp-file approach, which keeps the implementation simple while enabling powerful shell integration workflows.