-
-
Notifications
You must be signed in to change notification settings - Fork 558
feat: PDF v3 - page filtering, image extraction, performance optimization #283
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
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
648c054
feat: pdf read/write
dasein108 8ae8a21
feat: pdf.js way
dasein108 638ba0d
feat: read_file add PDF support
dasein108 407f682
feat: write to PDF
dasein108 27bf915
feat: extract image, from pdf
dasein108 ffdb55b
feat: write pdf
dasein108 fa49964
feat: adjust to tools
dasein108 f2f9a60
feat: render pdf remark
dasein108 111dcf2
feat: modify using markdown
dasein108 86a35b2
feat: refactor, integrate with mcp tool
dasein108 73d7c39
fix: schema parsing for pdf write tool
dasein108 a4a7698
chore: remove experemental code
dasein108 3d0dff1
feat: add page filter, make output more comprehensive, extend too des…
dasein108 84e796d
feat: optimize performance for partial pages
dasein108 3f0ab32
fix: image extraction, compression
dasein108 72bca17
fix: remove png deps, adjust image optimization
dasein108 3fad97a
chore: adjust pdf parsing test
dasein108 ef9dbbc
Tests fix
wonderwhy-er 8f93730
Update src/handlers/filesystem-handlers.ts
wonderwhy-er 0906011
Update src/tools/pdf/extract-images.ts
wonderwhy-er 24e6ef1
Update src/tools/mime-types.ts
wonderwhy-er 134047f
Update src/tools/pdf/markdown.ts
wonderwhy-er 0988d9f
Update src/handlers/filesystem-handlers.ts
wonderwhy-er 877109c
Update test/test-pdf-parsing.js
wonderwhy-er 307d302
fix: remove duplicate PageRange type and add missing title variable
wonderwhy-er b259461
Revert "Update src/tools/pdf/markdown.ts"
wonderwhy-er 6883994
fix: update md-to-pdf to ^5.2.5 to address CVE-2025-65108
wonderwhy-er 7180eba
fix: pdf edit test
dasein108 cd2f0e9
feat: adjust pdf layout on insert/merge
dasein108 1286099
chore: up md-to-pdf version
dasein108 f0687ca
Update src/tools/pdf/manipulations.ts
wonderwhy-er dcd643c
Update test/test-pdf-creation.js
wonderwhy-er ba083c2
Few more PDF tweaks
wonderwhy-er File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 3028
🏁 Script executed:
# Check file size first wc -l src/handlers/filesystem-handlers.tsRepository: wonderwhy-er/DesktopCommanderMCP
Length of output: 115
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 198
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 58
🏁 Script executed:
# Check type definitions cat -n src/types.tsRepository: wonderwhy-er/DesktopCommanderMCP
Length of output: 2365
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 1448
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 1521
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 777
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 860
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 1264
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 602
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 58
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 633
🏁 Script executed:
Repository: wonderwhy-er/DesktopCommanderMCP
Length of output: 162
Add optional chaining to PDF page and image iteration to prevent runtime errors.
The current code has a subtle but real bug at line 163:
Optional chaining (
?.) only protects property access on the left side. Ifresult.payloadis undefined, the expressionresult.payload?.pagesreturnsundefined, and calling.forEach()onundefinedthrows a TypeError.Additionally, while the type system guarantees
imagesis an array when aPdfPageItemexists, defensive programming suggests protecting it as well.The fix is straightforward—add optional chaining to both
.forEach()calls and adjust the content guard to only apply where needed:This removes the global content guard (PDFs don't need
contentto emit images frompayload), adds safe optional chaining on bothpages?.forEach()andimages?.forEach(), and applies the content check only where it's semantically required.🤖 Prompt for AI Agents