### Setup: Clone and Install with pip Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Clone the repository, create and activate a virtual environment, and install the package in editable mode with development dependencies. ```bash git clone https://github.com/agentii-ai/docmeld.git cd docmeld python3 -m venv venv source venv/bin/activate pip install -e ".[dev]" ``` -------------------------------- ### Development Setup Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Commands to clone the repository, create a virtual environment, activate it, and install the package in development mode. ```bash git clone https://github.com/agentii-ai/DocMeld.git cd docmeld python3 -m venv venv source venv/bin/activate pip install -e ".[dev]" ``` -------------------------------- ### DocMeldParser Quickstart Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/plan.md Minimal example showing how to use DocMeldParser to process a PDF. ```python from docmeld import DocMeldParser parser = DocMeldParser("document.pdf") result = parser.process_all() print(f"Processed {result.total_pages} pages") ``` -------------------------------- ### Install docmeld with Docling backend Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Install docmeld with the optional Docling backend. ```bash pip install docmeld[docling] ``` -------------------------------- ### Install DocMeld optional backends Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Installs optional backends for richer formats. The `office` extra installs both Docling and python-pptx. Legacy `.doc`/`.ppt` files additionally require LibreOffice (`soffice`) on your PATH. ```bash pip install docmeld[docling] # Docling backend (DOCX + advanced PDF) ``` ```bash pip install docmeld[pptx] # PowerPoint (.pptx) via python-pptx ``` ```bash pip install docmeld[office] # Everything: Docling + python-pptx ``` -------------------------------- ### Install DocMeld core Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Installs the core DocMeld package with no optional backends. ```bash pip install docmeld ``` -------------------------------- ### Install DocMeld and create virtual environment Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/quickstart.md Creates a Python virtual environment and installs the docmeld package. ```bash # Create and activate virtual environment python3 -m venv venv source venv/bin/activate # Install docmeld pip install docmeld ``` -------------------------------- ### Install docmeld with optional dependencies Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/quickstart.md Install the docmeld package. The core installation includes PyMuPDF only, enabling PDF and .ppt bridge functionality. Use the [pptx] extra for PPTX support and [office] for all office formats (.docx, .pptx). ```bash # Core installation (PyMuPDF only — PDF + .ppt bridge work out of the box) pip install docmeld # With PPTX support pip install docmeld[pptx] # With all office formats (.docx, .pptx) pip install docmeld[office] ``` -------------------------------- ### Commit Message Example Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/CONTRIBUTING.md Example of a conventional commit message for a new feature. ```text feat: Add PDF parsing support Implements password-protected PDF parsing using PyMuPDF's encryption handling. Adds new parameter to BronzeProcessor. Co-Authored-By: Claude Opus 4.6 ``` -------------------------------- ### GoldPage Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Example of a GoldPage object with enriched metadata including description and keywords. ```json { "metadata": { "uuid": "52e2bd3a-f5c2-4a3e-9b7d-8e1f2a3b4c5d", "page_no": "page1", "session_title": "# Executive Summary\n", "description": "Company reports strong Q2 results with revenue growth and margin expansion", "keywords": ["revenue", "EBITDA", "quarterly results", "growth", "margins"] }, "page_content": "# Executive Summary\n\nThe company reported..." } ``` -------------------------------- ### Install DocMeld with PowerPoint and Office extras Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Install DocMeld with optional dependencies for PowerPoint (.pptx via python-pptx) and Office (.docx + .pptx) support. Use the [pptx] extra for PowerPoint-only support and [office] for both Word and PowerPoint. ```bash pip install docmeld[pptx] # .pptx via python-pptx pip install docmeld[office] # .docx + .pptx ``` -------------------------------- ### ProcessingResult Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Example of a ProcessingResult object with summary statistics for pipeline execution. ```json { "total_files": 10, "successful": 9, "failed": 1, "failures": [ {"filename": "corrupted.pdf", "error": "PyMuPDF: file unreadable"} ], "processing_time_seconds": 272.5, "output_directory": "/path/to/documents/", "log_file": "docmeld_20260312_143022.log" } ``` -------------------------------- ### Flat Element List Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/evaluation.md Example of a flat element list with optional parent_id for tree reconstruction. ```json [ {"element_id": "e_001", "type": "title", "level": 0, "content": "Report", "page_no": 1}, {"element_id": "e_002", "type": "text", "content": "The company reported strong results...", "page_no": 1, "bbox": [72, 100, 540, 200], "parent_id": "e_001"}, {"element_id": "e_003", "type": "list_item", "content": "Revenue grew 25% YoY", "page_no": 1, "list_level": 0, "bbox": [90, 210, 540, 225], "parent_id": "e_001"}, {"element_id": "e_004", "type": "table", "content": "| Metric | Q1 | Q2 |\n|--------|----|----|...", "summary": "Items: Revenue, EBITDA, Net Income", "table_data": {"headers": ["Metric", "Q1", "Q2"], "rows": [["Revenue", "$100M", "$120M"], ["EBITDA", "$30M", "$35M"]], "num_rows": 2, "num_cols": 3}, "page_no": 2, "bbox": [72, 100, 540, 300]}, {"element_id": "e_005", "type": "image", "image_name": "page003_chart_001.png", "content": "Revenue growth chart", "image": "base64...", "image_id": "page003_chart_001", "page_no": 3, "bbox": [72, 100, 540, 400]} ] ``` -------------------------------- ### Swappable backends: pymupdf, docling, pptx, soffice, auto Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Shows how to select a parsing backend. With `--backend auto` (default), the format is detected from the file extension and routed automatically. Each backend supports specific formats and may require extra installs (e.g., `docmeld[docling]`, `docmeld[pptx]`, or LibreOffice). ```python # PDF (default): PyMuPDF — lightweight, fast parser = DocMeldParser("paper.pdf", backend="pymupdf") # DOCX: Docling (IBM's ML-powered OOXML parser) parser = DocMeldParser("report.docx", backend="docling") # PPTX: python-pptx — native slide/shape extraction parser = DocMeldParser("deck.pptx", backend="pptx") # Legacy .doc / .ppt: LibreOffice bridge → PDF → PyMuPDF parser = DocMeldParser("old.ppt", backend="soffice") # Auto-detect by extension (recommended) parser = DocMeldParser("anything.pptx", backend="auto") ``` -------------------------------- ### HeaderElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON object for a HeaderElement with content and page_scope. ```json { "type": "header", "content": "Chapter 3: Financial Analysis", "page_scope": "all", "page_no": 15, "element_id": "e_025", "parent_id": "" } ``` -------------------------------- ### Production-Grade CLAUDE.md Example Source: https://github.com/agentii-ai/docmeld/blob/main/references/00-core/harness_coding.md A production-grade CLAUDE.md example for an autonomous PR factory, covering PR workflow, autonomy rules, quality gates, and sub-agent routing. ```markdown # Engineering Constitution ## PR Workflow 1. ALWAYS create a new branch: git checkout -b feature/{ticket-id}-{slug} 2. Write tests FIRST (TDD) 3. Run full test suite before committing 4. PR title format: [TYPE] #{ticket-id}: Short description 5. PR must include: what changed, why, how to test ## Autonomy Rules - For tasks < 200 lines: implement fully autonomously - For tasks > 200 lines: create implementation plan first, write to plan.md - NEVER modify files outside the task's declared scope - On ambiguity: make the conservative choice, document in PR description ## Quality Gates (run before every commit) - npm test (must pass 100%) - npm run lint (zero errors) - npm run typecheck ## Sub-Agent Routing **Parallel dispatch** when: 3+ unrelated tasks, no shared state, clear file boundaries **Sequential dispatch** when: task B needs output from task A, shared files exist ``` -------------------------------- ### CLI Commands for Parsing and Output Generation Source: https://github.com/agentii-ai/docmeld/blob/main/references/00-core/PRD.md Command-line interface examples for parsing a PDF, specifying an output directory, batch processing multiple PDFs, and selecting output formats. ```bash # Basic parsing docmeld parse input.pdf # Specify output directory docmeld parse input.pdf --output-dir ./output # Batch processing docmeld parse *.pdf # Output format selection docmeld parse input.pdf --format json docmeld parse input.pdf --format markdown docmeld parse input.pdf --format excel docmeld parse input.pdf --format all # default ``` -------------------------------- ### FormulaElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON object for a FormulaElement with LaTeX content and formula_type. ```json { "type": "formula", "content": "E = mc^2", "formula_type": "MathType", "page_no": 4, "element_id": "e_020", "parent_id": "e_018" } ``` -------------------------------- ### Git Worktree Setup Source: https://github.com/agentii-ai/docmeld/blob/main/references/00-core/harness_coding.md Commands to create a separate git worktree for a job and run Claude Code in it with the job description. ```bash git worktree add ../project-job-12 -b feature/job-12 cd ../project-job-12 && claude -p "$(cat job-12.txt)" ``` -------------------------------- ### Detect LibreOffice installation with shutil.which Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/research.md Checks if the 'soffice' executable is available on the system PATH. Returns the path if found, otherwise None. Used to verify LibreOffice is installed before attempting .doc conversion. ```python import shutil libreoffice_path = shutil.which("soffice") ``` -------------------------------- ### Verify license and test docmeld bronze CLI backends Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/optimization-plan.md Run these commands to confirm the LICENSE header, check the --backend option in docmeld bronze --help, test the default pymupdf backend, and test the docling backend (requires pip install docmeld[docling]). Then run lint and type checks with ruff, black, and mypy. ```shell # Verify license head -1 LICENSE # Should show "GNU AFFERO GENERAL PUBLIC LICENSE" # Test CLI backend flag docmeld bronze --help # Should show --backend option # Test default backend (pymupdf) still works docmeld bronze /path/to/test.pdf # Test docling backend (requires: pip install docmeld[docling]) docmeld bronze --backend docling /path/to/test.pdf # Lint + type check ruff check docmeld/ black --check docmeld/ mypy docmeld/ ``` -------------------------------- ### Unit Test Example Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/CONTRIBUTING.md Example unit tests for a new feature, including a basic functionality test and an edge case test. ```python """Unit tests for new feature.""" from docmeld.module import NewFeature class TestNewFeature: def test_basic_functionality(self) -> None: """Test that basic feature works.""" feature = NewFeature() result = feature.process("input") assert result == "expected" def test_edge_case(self) -> None: """Test edge case handling.""" feature = NewFeature() with pytest.raises(ValueError): feature.process("") ``` -------------------------------- ### Documentation directory tree for specs/007-mvp-ppt-pipeline Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/plan.md Shows the documentation file layout for the MVP PPT pipeline feature, including plan, spec, research, data-model, quickstart, contracts, and checklists. ```text specs/007-mvp-ppt-pipeline/ ├── plan.md # This file ├── spec.md # Feature specification ├── research.md # Phase 0 output ├── data-model.md # Phase 1 output ├── quickstart.md # Phase 1 output ├── contracts/ # Phase 1 output │ └── element-schema.json └── checklists/ └── requirements.md ``` -------------------------------- ### Install Claude Code GitHub App via terminal Source: https://github.com/agentii-ai/docmeld/blob/main/references/00-core/harness_coding.md Run inside your project directory to install the official GitHub integration. The /install-github-app command sets up the GitHub App for the repository. ```bash # Inside your project claude /install-github-app ``` -------------------------------- ### FooterElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON object for a FooterElement with content and page_scope. ```json { "type": "footer", "content": "Page 15", "page_scope": "all", "page_no": 15, "element_id": "e_026", "parent_id": "" } ``` -------------------------------- ### ChartElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON object for a ChartElement with chart_type, markdown content, base64 image, and image_name. ```json { "type": "chart", "chart_type": "bar", "content": "| Quarter | Revenue |\n|---------|--------|\n| Q1 | 100 |\n| Q2 | 120 |\n| Q3 | 140 |", "image": "iVBORw0KGgoAAAANSUhEUgAA...", "image_name": "chart_revenue_bar.png", "page_no": 3, "element_id": "e_015", "parent_id": "e_008" } ``` -------------------------------- ### TitleElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Example JSON for a TitleElement with type 'title', level 0, content 'Executive Summary', and page_no 1. ```json { "type": "title", "level": 0, "content": "Executive Summary", "page_no": 1 } ``` -------------------------------- ### SilverPage JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Example JSON for a SilverPage with metadata (uuid, source, page_no, session_title) and markdown page_content. ```json { "metadata": { "uuid": "52e2bd3a-2d57-4a18-94a6-91e9314c7a67", "source": "research_report_a3f5c2.pdf", "page_no": "page1", "session_title": "# Executive Summary\n" }, "page_content": "# Executive Summary\n\nThe company reported...\n\n[[Table1]]\n| Metric | Value |\n..." } ``` -------------------------------- ### JSON Example for FootnoteElement Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON structure for a new FootnoteElement, showing fields for type, content, reference_id, page_no, element_id, and parent_id. ```json { "type": "footnote", "content": "Source: Annual Report 2024, Section 3.2", "reference_id": "1", "page_no": 7, "element_id": "e_035", "parent_id": "" } ``` -------------------------------- ### CommentElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/data-model.md Example JSON for a CommentElement with author attribution. Author is empty string when not recorded. ```json { "type": "comment", "content": "Update this figure for FY25.", "author": "A. Reviewer", "page_no": 2, "element_id": "e_050", "parent_id": "", "hidden": false } ``` -------------------------------- ### Example Silver JSONL (single slide) Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/quickstart.md Example of a silver JSONL line for a single slide, containing metadata (uuid, source, page_no, session_title) and page_content with markdown, chart placeholders, notes, and comments. ```json {"metadata": {"uuid": "...", "source": "pitch_deck_a3f5c2.pptx", "page_no": "page3", "session_title": "# Q4 Review"}, "page_content": "## Revenue Analysis\n[[Chart1]]\n| Quarter | Revenue |\n|---------|--------|\n| Q1 | 100 |\n| Q2 | 120 |\n[[/Chart1]]\n[Notes]\nEmphasize the 40% YoY growth here.\n[/Notes]\n[Comment: A. Reviewer]\nUpdate this figure for FY25.\n[/Comment]"} ``` -------------------------------- ### TextElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON object for a TextElement with fields type, content, page_no, element_id, and parent_id. ```json { "type": "text", "content": "The company reported strong quarterly results...", "page_no": 1, "element_id": "e_003", "parent_id": "e_001" } ``` -------------------------------- ### NotesElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/data-model.md Example JSON for a NotesElement with speaker notes. Notes elements are emitted after all content elements of their slide (FR-018). ```json { "type": "notes", "content": "Emphasize the 40% YoY growth here.", "page_no": 3, "element_id": "e_030", "parent_id": "", "hidden": false } ``` -------------------------------- ### TableElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON object for a TableElement including markdown content, summary, and optional table_data structure. ```json { "type": "table", "content": "| Metric | Q1 | Q2 |\n|--------|----|-----|\n| Revenue | 100 | 120 |", "summary": "Items: Revenue, Gross Margin, EBITDA", "page_no": 2, "element_id": "e_012", "parent_id": "e_005", "table_data": {"headers": ["Metric", "Q1", "Q2"], "rows": [["Revenue", "100", "120"]], "num_rows": 1, "num_cols": 3} } ``` -------------------------------- ### TitleElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/data-model.md Example JSON object for a TitleElement with fields type, level, content, page_no, element_id, and parent_id. ```json { "type": "title", "level": 0, "content": "Executive Summary", "page_no": 1, "element_id": "e_001", "parent_id": "" } ``` -------------------------------- ### SmartArtElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/data-model.md Example JSON for a SmartArtElement with type 'smartart', smartart_type 'process', and hierarchical content. Validation requires non-empty content or valid base64 image. ```json { "type": "smartart", "smartart_type": "process", "content": "- Plan\n- Build\n- Ship", "image": "", "image_name": "smartart_process_1.png", "page_no": 3, "element_id": "e_015", "parent_id": "e_008", "hidden": false } ``` -------------------------------- ### ImageElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Example JSON for an ImageElement with type 'image', image_name 'page003_image_001.png', content 'Revenue growth chart', base64 image data, image_id, bbox, and page_no 3. ```json { "type": "image", "image_name": "page003_image_001.png", "content": "Revenue growth chart", "image": "iVBORw0KGgoAAAANSUhEUgAA...", "image_id": "page003_image_001", "bbox": [0, 0, 0, 0], "page_no": 3 } ``` -------------------------------- ### TableElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Example JSON for a TableElement with type 'table', summary 'Items: Revenue, Gross Margin, EBITDA', markdown content, and page_no 2. ```json { "type": "table", "summary": "Items: Revenue, Gross Margin, EBITDA", "content": "| Metric | Q1 | Q2 |\n|--------|----|----|...", "page_no": 2 } ``` -------------------------------- ### TextElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Example JSON for a TextElement with type 'text', content 'The company reported strong quarterly results...', and page_no 1. ```json { "type": "text", "content": "The company reported strong quarterly results...", "page_no": 1 } ``` -------------------------------- ### Batch Processing Progress Indicators Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/plan.md Example of progress indicators displayed during batch processing, showing current file, stage progress, and page counts. ```text Processing PDFs: 3/10 (30%) - current: research_report.pdf Bronze stage: 5/10 pages processed Silver stage: Converting page 3/5 Gold stage: Enriching page 2/5 (API call) ``` -------------------------------- ### GroupElement JSON Example Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/data-model.md Example JSON for a GroupElement with child_count. Each child shape is a separate element with parent_id equal to this group's element_id. ```json { "type": "group", "content": "Grouped diagram (3 shapes)", "child_count": 3, "page_no": 4, "element_id": "e_040", "parent_id": "", "hidden": false } ``` -------------------------------- ### Unified JSON Element Format Example Source: https://github.com/agentii-ai/docmeld/blob/main/references/00-core/PRD.md Example JSON array showing the unified element structure with types: title, text, table, and image. Includes fields like type, level, content, page_no, summary, image_name, image, image_id, and bbox. ```json [ { "type": "title", "level": 0, "content": "Section Title", "page_no": 1 }, { "type": "text", "content": "Paragraph content...", "page_no": 1 }, { "type": "table", "summary": "Items: Revenue, Gross Margin, ...", "content": "| Header1 | Header2 |\n|---------|---------|...", "page_no": 2 }, { "type": "image", "image_name": "page001_image_001.png", "content": "Image description (optional)", "image": "base64_encoded_string", "page_no": 3, "image_id": "page001_image_001", "bbox": [x0, y0, x1, y1] } ] ``` -------------------------------- ### Project directory structure Source: https://github.com/agentii-ai/docmeld/blob/main/references/00-core/PRD.md Shows the intended layout of the docmeld project, including the main package, tests, examples, and documentation directories. The tree indicates where core modules like parser.py, extractors, exporters, and models.py reside. ```text docmeld/ ├── docmeld/ │ ├── __init__.py │ ├── parser.py # Core DocMeldParser class │ ├── extractors/ │ │ ├── __init__.py │ │ ├── text.py # Text extraction │ │ ├── tables.py # Table extraction │ │ ├── images.py # Image extraction │ │ └── titles.py # Title detection │ ├── exporters/ │ │ ├── __init__.py │ │ ├── json.py # JSON output │ │ ├── markdown.py # Markdown output │ │ ├── excel.py # Excel output │ │ └── tables.py # Table-specific output │ ├── models.py # Pydantic data models │ ├── utils.py # Helper functions │ └── cli.py # CLI interface ├── tests/ │ ├── test_parser.py │ ├── test_extractors.py │ ├── test_exporters.py │ └── fixtures/ │ └── sample.pdf ├── examples/ │ ├── basic_usage.py │ ├── batch_processing.py │ └── custom_pipeline.py ├── docs/ │ ├── README.md │ ├── installation.md │ ├── quickstart.md │ └── api_reference.md ├── pyproject.toml ├── setup.py ├── README.md ├── LICENSE (MIT) └── .gitignore ``` -------------------------------- ### Gold JSON output: AI-enriched metadata with description and keywords Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Example output of the Gold stage, which adds semantic descriptions and keywords to each page using DeepSeek-chat, with exponential backoff retry and per-page error resilience. The gold stage is optional; bronze and silver run fully offline with zero API calls. ```json { "metadata": { "uuid": "a1b2c3d4-...", "source": "research_paper.pdf", "page_no": "page1", "session_title": "# Executive Summary\n", "description": "Company reports strong Q2 results with 50% revenue growth", "keywords": ["revenue", "quarterly results", "growth", "financial performance"] }, "page_content": "..." } ``` -------------------------------- ### Processing Summary Report Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/plan.md Example of a summary report generated after processing, showing total files, success/failure counts, processing time, output directory, and log file name. ```text === DocMeld Processing Summary === Total files: 10 Successful: 9 Failed: 1 - corrupted_file.pdf: PyMuPDF error (file unreadable) Processing time: 4m 32s Output directory: /path/to/documents/ Log file: docmeld_20260312_143022.log ``` -------------------------------- ### Quick Reference: Running the Loop (bash) Source: https://github.com/agentii-ai/docmeld/blob/main/AGENTS.md Quick reference commands for running the harness loop. Includes speckit commands for spec/plan/tasks/implement, then test commands (pytest, ruff, black) and git merge steps. Requires activating the virtual environment at /Users/frank/A/DocMeld/docmeld. ```bash # 1. Pick use case, create spec /speckit.specify "NNN-use-case-description" # 2. Generate plan /speckit.plan # 3. Generate tasks /speckit.tasks # 4. Implement all tasks /speckit.implement # 5. Test & evaluate cd /Users/frank/A/DocMeld/docmeld && source venv/bin/activate pytest tests/ -v --cov=docmeld --cov-report=term-missing ruff check docmeld/ black --check docmeld/ # 6. Merge to main (after all tests pass) git checkout main git merge NNN-feature-branch pytest tests/ -v ``` -------------------------------- ### Silver JSON output: page document with metadata and page_content Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Example output of the Silver stage, which transforms flat element lists into self-contained page documents with title hierarchy tracking, markdown rendering, and global table numbering. Each page carries its full title context, making pages independently meaningful for chunked retrieval in RAG systems. ```json { "metadata": { "uuid": "a1b2c3d4-...", "source": "research_paper.pdf", "page_no": "page1", "session_title": "# Executive Summary\n" }, "page_content": "# Executive Summary\n\nThe company reported strong Q2 results...\n\n[[Table1]]\n| Metric | Q1 | Q2 |\n|---|---|---|\n| Revenue | 10M | 15M |\n[/Table1]" } ``` -------------------------------- ### Set up .env.local with DeepSeek API key Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/quickstart.md Creates a .env.local file with the DeepSeek API key, required for the gold stage. Optional custom endpoint is commented out. ```bash DEEPSEEK_API_KEY=your_api_key_here # Optional: custom endpoint # DEEPSEEK_API_ENDPOINT=https://api.deepseek.com ``` -------------------------------- ### Create Virtual Environment Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/CONTRIBUTING.md Create a virtual environment and activate it (with a note for Windows). ```bash python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate ``` -------------------------------- ### Swappable Backends Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Shows how to select different parsing backends for various file formats. ```python # Default: auto-detect by file extension (recommended) parser = DocMeldParser("deck.pptx", backend="auto") # PDF: PyMuPDF (lightweight, fast) parser = DocMeldParser("paper.pdf", backend="pymupdf") # DOCX: Docling (IBM's ML-powered OOXML parser) parser = DocMeldParser("report.docx", backend="docling") # PPTX: python-pptx — native slide/shape extraction parser = DocMeldParser("deck.pptx", backend="pptx") # Legacy .doc / .ppt: LibreOffice bridge parser = DocMeldParser("old.ppt", backend="soffice") ``` -------------------------------- ### Quality Gates: Run Tests and Checks Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Run the quality gates: tests with coverage, linting with Ruff, formatting check with Black, and strict type checking with mypy. ```bash pytest tests/ -v --cov=docmeld # 315 tests, 78% coverage ruff check docmeld/ # Linting black --check docmeld/ # Formatting mypy docmeld/ # Strict type checking ``` -------------------------------- ### Initialize and Use DocMeldParser Source: https://github.com/agentii-ai/docmeld/blob/main/references/00-core/PRD.md Initialize the parser with a PDF path and optional output directory, parse the document, access parsed data and summary, and generate JSON, Markdown, and Excel outputs. ```python from docmeld import DocMeldParser # Initialize parser parser = DocMeldParser( pdf_path="document.pdf", output_dir=None, # Auto-create: {pdf_path_stem}/ ) # Parse document result = parser.parse() # Access parsed data elements = parser.parsed_data # List[Dict] summary = parser.get_summary() # Dict with stats # Generate outputs parser.save_json() # {filename}.json parser.save_markdown() # {filename}.md parser.save_excel() # {filename}.xlsx parser.save_tables() # {filename}_[tables].md ``` -------------------------------- ### TDD Sample-Driven Test Flow Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/plan.md Step-by-step process for each sample file: write failing test, implement backend, refactor, then silver test. ```text For each sample file: 1. Write failing test: "Given sample_.docx → Expect elements of type " 2. Run test → RED (no backend support yet) 3. Implement docling backend mapping for that element type 4. Run test → GREEN 5. Refactor: common patterns, DRY, error handling 6. Write silver test: "Given bronze JSON → Expect JSONL with markers" 7. Implement silver renderer extension 8. Run test → GREEN ``` -------------------------------- ### Clone Repository Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/CONTRIBUTING.md Commands to fork and clone the repository, then navigate into the project directory. ```bash git clone https://github.com/agentii-ai/DocMeld.git cd DocMeld/docmeld ``` -------------------------------- ### Run Tests Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/CONTRIBUTING.md Run the test suite. ```bash pytest tests/ ``` -------------------------------- ### Launch all tests for US3 together Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/tasks.md Bash commands to write unit and integration tests for the title tracker, markdown renderer, page aggregator, and silver pipeline. After tests are written, launch parallel implementations for the title tracker, markdown renderer, and page aggregator, then sequentially implement the silver processor that depends on all three. ```bash # Launch all tests for US3 together (different files): Task: "Write unit tests for title tracker in tests/unit/test_title_tracker.py" Task: "Write unit tests for markdown renderer in tests/unit/test_markdown_renderer.py" Task: "Write unit tests for page aggregator in tests/unit/test_page_aggregator.py" Task: "Write integration test for silver pipeline in tests/integration/test_silver_pipeline.py" # After tests written, launch parallel implementations: Task: "Implement title tracker in docmeld/docmeld/silver/title_tracker.py" Task: "Implement markdown renderer in docmeld/docmeld/silver/markdown_renderer.py" Task: "Implement page aggregator in docmeld/docmeld/silver/page_aggregator.py" # Then sequential: processor depends on all three above Task: "Implement silver processor in docmeld/docmeld/silver/processor.py" ``` -------------------------------- ### Convert .doc to PDF using soffice command Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/research.md Runs LibreOffice headless to convert a .doc file to PDF in the specified output directory. The and are placeholders for actual paths. ```bash soffice --headless --convert-to pdf --outdir ``` -------------------------------- ### Project Structure Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Directory tree showing the project structure with comments for each file. ```text docmeld/ ├── docmeld/ │ ├── __init__.py # Public API (DocMeldParser, __version__) │ ├── parser.py # Pipeline orchestrator │ ├── cli.py # CLI entry point (argparse) │ ├── py.typed # PEP 561 marker │ ├── bronze/ │ │ ├── backends/ │ │ │ ├── pymupdf_backend.py # PyMuPDF + pymupdf4llm │ │ │ ├── docling_backend.py # Docling (optional, DOCX/PDF) │ │ │ ├── pptx_backend.py # python-pptx (PPTX) │ │ │ └── soffice_backend.py # LibreOffice bridge (.doc/.ppt) │ │ ├── element_extractor.py # Extraction + post-processing │ │ ├── element_types.py # Pydantic element models (14 types) │ │ ├── filename_sanitizer.py # Safe filenames + MD5 hashing │ │ └── processor.py # Bronze orchestrator │ ├── silver/ │ │ ├── page_aggregator.py # Group elements by page │ │ ├── page_models.py # Result models (Pydantic) │ │ ├── markdown_renderer.py # Elements → markdown │ │ ├── title_tracker.py # Title hierarchy state │ │ └── processor.py # Silver orchestrator │ ├── gold/ │ │ ├── deepseek_client.py # DeepSeek API client + retry │ │ ├── provider.py # LLMProvider Protocol (swappable) │ │ ├── metadata_extractor.py # Content → description + keywords │ │ └── processor.py # Gold orchestrator │ ├── categorize/ # Topic clustering (categorize) │ ├── prd/ # PRD generation (prd) │ ├── workflow/ # Workflow extraction (workflow) │ ├── skills/ # Skills extraction (skills) │ └── utils/ # Shared helpers ├── scripts/ # Example scripts (not shipped in package) ├── tests/ # Unit, integration, contract tests ├── pyproject.toml ├── CONTRIBUTING.md ├── CHANGELOG.md └── LICENSE # MIT ``` -------------------------------- ### Gold Stage State Transition Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/data-model.md Shows the Gold stage pipeline: loading the Silver JSONL, enriching pages with AI, and serializing to a gold JSONL file. ```text {filename_hash6}.jsonl → [Load] → List[SilverPage] → [Enrich with AI] → List[GoldPage] → [Serialize] → {filename_hash6}_gold.jsonl ``` -------------------------------- ### Bronze stage JSON output example Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Example Bronze-stage JSON output showing title, text, and table elements. Each element includes `page_no`, `element_id`, and `parent_id` for cross-referencing. ```json [ { "type": "title", "level": 0, "content": "Executive Summary", "page_no": 1, "element_id": "e_0001", "parent_id": "" }, { "type": "text", "content": "The company reported strong Q2 results...", "page_no": 1, "element_id": "e_0002", "parent_id": "e_0001" }, { "type": "table", "content": "| Metric | Q1 | Q2 |\n|---|---|---|\n| Revenue | 10M | 15M |", "summary": "Items: Revenue", "page_no": 2, "element_id": "e_0003", "parent_id": "e_0001", "table_data": { "headers": ["Metric", "Q1", "Q2"], "rows": [["Revenue", "10M", "15M"]], "num_rows": 1, "num_cols": 3 } } ] ``` -------------------------------- ### Swappable LLM Provider Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Shows how to inject a custom LLM provider that implements the LLMProvider protocol. ```python from docmeld import DocMeldParser from docmeld.gold.provider import LLMProvider class MyProvider: def extract_metadata(self, content: str) -> dict: ... def generate(self, prompt: str) -> str: ... def categorize(self, prompt: str) -> str: ... parser = DocMeldParser("paper.pdf", provider=MyProvider()) # All gold-stage and knowledge-generation features now use MyProvider prd = parser.process_prd() # uses your provider, not DeepSeek ``` -------------------------------- ### Individual Stages Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Shows how to run only the bronze stage of the pipeline. ```python from docmeld import DocMeldParser parser = DocMeldParser("paper.pdf") # Bronze only bronze = parser.process_bronze() print(f"{bronze.element_count} elements across {bronze.page_count} pages") print(f"Output: {bronze.output_path}") ``` -------------------------------- ### Custom LLM provider via LLMProvider interface Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Shows how to supply a custom LLM provider. When no provider is given, a `DeepSeekClient` is constructed from environment variables — behavior is unchanged. ```python from docmeld.gold.provider import LLMProvider class MyProvider: def extract_metadata(self, content): ... def generate(self, prompt): ... def categorize(self, prompt): ... parser = DocMeldParser("paper.pdf", provider=MyProvider()) prd = parser.process_prd() # uses your provider, not DeepSeek ``` -------------------------------- ### CLI: process PDFs and run stages Source: https://github.com/agentii-ai/docmeld/blob/main/specs/001-mvp-pdf-pipeline/quickstart.md Shows CLI commands to process a single PDF, a folder, and run specific stages (bronze, silver, gold). ```bash # Process single PDF (all stages) docmeld process document.pdf # Process folder docmeld process /path/to/pdfs/ # Run specific stage docmeld bronze document.pdf docmeld silver document_a3f5c2/document_a3f5c2.json docmeld gold document_a3f5c2/document_a3f5c2.jsonl ``` -------------------------------- ### Example Bronze JSON (single element) Source: https://github.com/agentii-ai/docmeld/blob/main/specs/007-mvp-ppt-pipeline/quickstart.md Example of a bronze JSON object representing a single chart element. It includes the element type, chart type, content as a markdown table, image data, and metadata such as page number and element IDs. ```json { "type": "chart", "chart_type": "bar", "content": "| Quarter | Revenue |\n|---------|--------|\n| Q1 | 100 |\n| Q2 | 120 |", "image": "iVBORw0KGgo...", "image_name": "chart_revenue_bar.png", "page_no": 3, "element_id": "e_015", "parent_id": "e_008", "hidden": false } ``` -------------------------------- ### Run All Checks Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/CONTRIBUTING.md Run all code quality checks before committing: formatting, linting, type checking, and tests with coverage. ```bash # Format code black docmeld/ # Check linting ruff check docmeld/ # Type check mypy docmeld/ # Run tests pytest --cov=docmeld --cov-report=term-missing ``` -------------------------------- ### DocMeld CLI commands: process, bronze, silver, gold, categorize, prd, workflow, skills Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Complete CLI reference for DocMeld. Run the full pipeline with `docmeld process` or individual stages (`bronze`, `silver`, `gold`). Choose parsing backends with `--backend` (default `auto`). Knowledge generation commands (`categorize`, `prd`, `workflow`, `skills`) require the `DEEPSEEK_API_KEY` environment variable. ```bash # Full pipeline (bronze → silver → gold) docmeld process paper.pdf docmeld process /path/to/papers/ # Individual stages docmeld bronze paper.pdf # Doc → JSON docmeld silver paper_a3f5c2/paper_a3f5c2.json # JSON → JSONL docmeld gold paper_a3f5c2/paper_a3f5c2.jsonl # JSONL → enriched JSONL # Choose parsing backend docmeld bronze report.docx --backend docling docmeld bronze deck.pptx --backend pptx docmeld process paper.pdf --backend auto # default — detects format # Knowledge Generation (requires DEEPSEEK_API_KEY) docmeld categorize /path/to/papers/ # Topic clustering → categories.json docmeld categorize /path/to/papers/ --reorganize # Move files into category folders docmeld prd paper.pdf # Generate Product Requirements Document docmeld workflow paper.pdf # Extract step-by-step workflow docmeld skills book.pdf # Extract Claude Code skills ``` -------------------------------- ### Sample .docx Element Output Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/quickstart.md Sample JSON array showing the structured element list extracted from a .docx file. ```json [ {"type": "title", "level": 0, "content": "Executive Summary", "page_no": 1, "element_id": "e_001", "parent_id": ""}, {"type": "text", "content": "The company achieved record revenue in Q3 2024.", "page_no": 1, "element_id": "e_002", "parent_id": "e_001"}, {"type": "chart", "chart_type": "bar", "content": "| Quarter | Revenue |\n|---------|--------|\n| Q1 | 100 |\n| Q2 | 120 |", "image": "iVBORw0KGgo...", "image_name": "chart_001.png", "page_no": 2, "element_id": "e_010", "parent_id": "e_005"}, {"type": "formula", "content": "E = mc^2", "formula_type": "MathType", "page_no": 2, "element_id": "e_011", "parent_id": "e_005"}, {"type": "header", "content": "Confidential — Q3 2024 Report", "page_no": 2, "element_id": "e_012", "parent_id": "e_005"} ] ``` -------------------------------- ### Full pipeline with DocMeldParser.process_all() Source: https://github.com/agentii-ai/docmeld/blob/main/README.md Runs the full pipeline (bronze, silver, gold) on a single PDF or all PDFs in a folder. The batch result prints the number of successful files and total processing time. ```python from docmeld import DocMeldParser # Single file — all three stages parser = DocMeldParser("paper.pdf") result = parser.process_all() # Batch — process every PDF in a folder parser = DocMeldParser("/path/to/papers/") result = parser.process_all() print(f"{result.successful}/{result.total_files} files, {result.processing_time_seconds}s") ``` -------------------------------- ### Parallel Phase 2 Task Launch Source: https://github.com/agentii-ai/docmeld/blob/main/specs/006-mvp-doc-pipeline/tasks.md Parallel task orchestration for Phase 2 foundational work: first launch all tests together, then after tests fail, launch all 6 element type model implementations in parallel. ```bash # Launch all tests together: Task: "Write unit tests for 6 new element type Pydantic models in tests/unit/test_element_types.py" Task: "Write contract test for 10-type element schema in tests/contract/test_element_schema.py" # After tests fail, launch all 6 models in parallel: Task: "Add ChartElement model to bronze/element_types.py" Task: "Add FormulaElement model to bronze/element_types.py" Task: "Add HeaderElement model to bronze/element_types.py" Task: "Add FooterElement model to bronze/element_types.py" Task: "Add FootnoteElement model to bronze/element_types.py" Task: "Add EndnoteElement model to bronze/element_types.py" ``` -------------------------------- ### Working with Elements Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/README.md Shows how to load and work with bronze output elements, including filtering by type and accessing table data. ```python import json # Load bronze output with open("paper_a3f5c2/paper_a3f5c2.json") as f: elements = json.load(f) # Filter by type titles = [e for e in elements if e["type"] == "title"] # Access structured table data for table in tables: headers = table["table_data"]["headers"] rows = table["table_data"]["rows"] ``` -------------------------------- ### Create Feature Branch Source: https://github.com/agentii-ai/docmeld/blob/main/docmeld/CONTRIBUTING.md Create a new feature branch. ```bash git checkout -b feature/your-feature-name ``` -------------------------------- ### Parallel Phase 2: Run tests and implement aggregator/categorizer Source: https://github.com/agentii-ai/docmeld/blob/main/specs/002-paper-batch-categorize/tasks.md Shows a parallel execution plan for Phase 2: launch unit tests for aggregator and categorizer in parallel, then implement the aggregator, categorizer, and the categorize_papers() method sequentially. The tasks reference specific file paths and method names. ```bash # Launch foundational tests in parallel: Task: "Unit test for aggregator in tests/unit/test_aggregator.py" Task: "Unit test for categorizer in tests/unit/test_categorizer.py" # Then implement sequentially: Task: "Implement aggregator in docmeld/categorize/aggregator.py" Task: "Implement categorizer in docmeld/categorize/categorizer.py" Task: "Add categorize_papers() to gold/deepseek_client.py" ```