-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 10x upgrade - parallel, vision, streaming, watch mode & more #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Unclosed PDF document causes resource leaks
| return savedPaths; | ||
| } | ||
|
|
||
| export async function hasImages(filePath: string): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
|
🚀 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.