Skip to content

Add LiteParse plugin for PDF text extraction#13

Merged
pirate merged 4 commits intomainfrom
claude/add-liteparse-plugin-d7Awc
Mar 19, 2026
Merged

Add LiteParse plugin for PDF text extraction#13
pirate merged 4 commits intomainfrom
claude/add-liteparse-plugin-d7Awc

Conversation

@pirate
Copy link
Member

@pirate pirate commented Mar 19, 2026

Summary

Adds a new LiteParse plugin that extracts text and metadata from PDF documents using the lit CLI tool by LlamaIndex. The plugin discovers PDFs from other plugin outputs (pdf, responses, staticfile) and processes all found documents, combining results into unified text and JSON outputs.

Key Changes

  • Snapshot hook (on_Snapshot__61_liteparse.py): Main extraction logic that:

    • Discovers all PDF files from sibling plugin output directories
    • Runs lit parse on each PDF in both text and JSON formats
    • Combines results with source attribution
    • Generates metadata tracking sources processed
    • Supports configuration via environment variables (timeout, custom args, enable/disable)
    • Handles missing sources gracefully (returns noresults)
  • Crawl hook (on_Crawl__43_liteparse_install.finite.bg.py): Binary dependency declaration that:

    • Emits a Binary record for the lit tool
    • Specifies npm installation via @llamaindex/liteparse package
    • Respects LITEPARSE_ENABLED flag and custom LITEPARSE_BINARY paths
  • Configuration (config.json): Schema defining:

    • LITEPARSE_ENABLED: Toggle extraction on/off
    • LITEPARSE_BINARY: Custom binary path
    • LITEPARSE_TIMEOUT: Extraction timeout (default 120s)
    • LITEPARSE_ARGS / LITEPARSE_ARGS_EXTRA: Command-line arguments
  • Comprehensive test suite (test_liteparse.py): Integration tests covering:

    • Hook script existence and proper structure
    • Crawl hook Binary record emission
    • Binary installation via npm and abx_pkg
    • Configuration disable flag behavior
    • Graceful handling of missing PDF sources
    • Single and multiple PDF extraction with real downloaded PDFs
    • Output validation (content.txt, metadata.json)

Implementation Details

  • Uses lit parse command with both text and JSON output formats
  • Processes PDFs sequentially with configurable timeout per file
  • Combines multiple PDF outputs with source attribution markers (<!-- source: ... -->)
  • Metadata includes per-file extraction stats and total sources found
  • Supports fallback to TIMEOUT environment variable for timeout configuration
  • Tests download real PDFs from the web to validate actual extraction capability

https://claude.ai/code/session_01XyzPfEB3qopffFuRyouaTa


Summary by cubic

Adds a LiteParse plugin that uses the lit CLI to extract text and JSON from PDFs found in sibling plugin outputs, writing content.txt, content.json, and metadata.json. Also simplifies binary resolution in tests and fixes shebang checks and forum-dl install issues on Python 3.12.

  • New Features

    • Snapshot hook scans pdf, responses, and staticfile for PDFs and runs lit parse in text and JSON modes.
    • Combines per-file outputs with source markers; writes content.json (single JSON or array) and metadata.json.
    • Config via LITEPARSE_ENABLED, LITEPARSE_BINARY, LITEPARSE_TIMEOUT, LITEPARSE_ARGS, LITEPARSE_ARGS_EXTRA; returns noresults when none found and failed if the binary can’t run.
    • Crawl hook emits a Binary for lit with npm install via @llamaindex/liteparse, supports env,npm, and honors custom paths.
  • Refactors

    • Tests across defuddle, forumdl, gallerydl, mercury, opendataloader, readability, ytdlp, and liteparse now use Binary.load_or_install() (large boilerplate reduction).
    • LiteParse tests assert exact phrases from real sample PDFs to reduce false positives.
    • Shebang test skips non-script files (__init__, tests, utils) to avoid false failures.
    • forum-dl test installs with --no-deps, --prefer-binary, and pins chardet==5.2.0 to avoid cchardet build failures on Python 3.12.

Written for commit a36840f. Summary will update on new commits.


Open with Devin

…LiteParse

New plugin that uses the `lit` CLI (@llamaindex/liteparse npm package) to
extract text and metadata from PDF documents. Follows the same patterns as
defuddle and opendataloader plugins.

- config.json with LITEPARSE_ENABLED, LITEPARSE_TIMEOUT, LITEPARSE_ARGS,
  LITEPARSE_ARGS_EXTRA, LITEPARSE_BINARY options
- on_Crawl hook emits Binary record for auto-install via npm
- on_Snapshot hook finds PDFs from sibling plugins and extracts text+JSON
- Full live integration tests with real PDF downloads, real binary install,
  and real content assertion (no mocks)

https://claude.ai/code/session_01XyzPfEB3qopffFuRyouaTa
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

…eywords

- test_extract_single_pdf: uses pdfobject.com sample.pdf and asserts the
  exact phrases "This is a simple PDF file" and "consectetuer adipiscing elit"
  that appear on its pages
- test_extract_multiple_pdfs: uses two distinct PDFs (unec.edu.az and
  pdfobject.com) and asserts unique text from BOTH is present in combined
  output ("preserves all...colours and graphics" from PDF A, "This is a
  simple PDF file" from PDF B)

https://claude.ai/code/session_01XyzPfEB3qopffFuRyouaTa
cubic-dev-ai[bot]

This comment was marked as resolved.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

…() in all plugin tests

All 8 plugin test files (defuddle, opendataloader, mercury, readability,
ytdlp, gallerydl, forumdl, liteparse) had ~80-line get_*_binary_path()
functions that manually tried Binary.load(), caught the exception, then
shelled out to crawl hooks + npm/pip install hooks as a fallback.

Binary.load_or_install() does all of this in one call. This removes
~600 lines of duplicated boilerplate, eliminates noisy BinaryLoadError
log lines from the first-attempt failure, and removes unused imports
(uuid, subprocess for install, tempfile for lib roots).

https://claude.ai/code/session_01XyzPfEB3qopffFuRyouaTa
devin-ai-integration[bot]

This comment was marked as resolved.

…ild failure

1. Shebang test: skip executable bit + shebang checks for __init__.py,
   test files, and utils — these aren't meant to be run as scripts.

2. Forumdl test: add pip overrides matching the crawl hook — install
   with --no-deps and chardet==5.2.0 instead of cchardet, which can't
   compile on Python 3.12+ (longintrepr.h removed).

https://claude.ai/code/session_01XyzPfEB3qopffFuRyouaTa
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/test_plugin_executables_have_shebang.py">

<violation number="1" location="tests/test_plugin_executables_have_shebang.py:37">
P1: Custom agent: **Test quality checker**

This test now bails out early with `continue`, skipping validations for part of the discovered scripts; that violates the test-quality requirement forbidding skipped/bail-early test paths.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@pirate pirate merged commit 706fef8 into main Mar 19, 2026
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants