feat: 10x upgrade - parallel, vision, streaming, watch mode & more#1
Open
feat: 10x upgrade - parallel, vision, streaming, watch mode & more#1
Conversation
…mode, and more - Add parallel processing with configurable concurrency (p-limit) - Add progress bar with ETA for multi-file operations (cli-progress) - Add stdin/stdout pipe support for shell integration - Add vision mode to send PDFs as images to Gemini - Add streaming output for real-time AI responses - Add watch mode to auto-convert new PDFs in a directory - Add glob pattern support (e.g., docs/**/*.pdf) - Add hash-based caching to skip already-processed files - Add custom prompts and built-in templates (invoice, table, summary, code) - Add output formats: markdown, json, html, text - Add image extraction from PDFs - Add templates and cache management commands Amp-Thread-ID: https://ampcode.com/threads/T-019bff71-9c6b-71d1-b614-e480b6560ebf Co-authored-by: Amp <amp@ampcode.com>
| .option('--stdout', 'Output to stdout instead of file') | ||
| .option('--extract-images', 'Extract images from PDF') | ||
| .option('--list-templates', 'Show available prompt templates') | ||
| .action(async (input: string | undefined, opts: { |
There was a problem hiding this comment.
CRITICAL: Convert command action handler is defined but not implemented, causing the command to fail to execute
| const fileName = `image-${imageCount}.png`; | ||
| const outputPath = path.join(outputDir, fileName); | ||
|
|
||
| // Create a simple PNG from raw image data |
There was a problem hiding this comment.
WARNING: Image extraction saves raw data as .raw files instead of proper PNG files
| const genAI = new GoogleGenerativeAI(apiKey); | ||
| const model = genAI.getGenerativeModel({ model: modelName }); | ||
|
|
||
| // Load PDF and render pages as images |
There was a problem hiding this comment.
WARNING: Unclosed PDF document causes resource leaks
| height: number; | ||
| } | ||
|
|
||
| export async function extractImages(filePath: string, outputDir: string): Promise<string[]> { |
There was a problem hiding this comment.
WARNING: Unclosed PDF document causes resource leaks
| return savedPaths; | ||
| } | ||
|
|
||
| export async function hasImages(filePath: string): Promise<boolean> { |
There was a problem hiding this comment.
WARNING: Unclosed PDF document causes resource leaks
| if (await processFile(fullPath, mode, apiKey)) { | ||
| successCount++; | ||
| } | ||
| async function readStdin(): Promise<Buffer> { |
There was a problem hiding this comment.
WARNING: readStdin function has no error handling, leading to potential crashes
Code Review SummaryStatus: 6 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
WARNING
Files Reviewed (7 files)
|
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.
🚀 Major Upgrade
This PR transforms pdf2md into a powerhouse PDF converter with 11 new features:
Performance
-c NflagNew Modes
-m vision) - Send PDF pages as images to Gemini (better for scanned docs)--stream) - Real-time AI response displaypdf2md watch <dir>) - Auto-convert new PDFs in a folderFlexibility
cat file.pdf | pdf2md > out.mdpdf2md "docs/**/*.pdf"--template invoiceor--prompt "Extract tables"--format json|html|text|markdownEfficiency
--cacheto skip already-processed files--extract-imagesto save embedded imagesNew Commands
pdf2md watch <dir>- Watch and auto-convertpdf2md templates- List prompt templatespdf2md cache --clear- Clear file cacheDependencies Added
p-limit- Concurrency controlcli-progress- Progress barschokidar- File watchingglob- Pattern matchingSummary by cubic
Major upgrade to pdf2md with parallel processing, vision mode, streaming, watch mode, templates, caching, and new output formats. Faster multi-file runs with better UX and shell-friendly piping.
New Features
-cand a progress bar with ETA.-m vision), streaming (--stream), and watch (pdf2md watch <dir>).--template) and custom prompts (--prompt), pluspdf2md templates.markdown,json,html,textwith--format.--cache,pdf2md cache --clear) and optional image extraction (--extract-images).Dependencies
Written for commit 7b4a754. Summary will update on new commits.