How kiencang/luka-loop works
Luka-Loop is an agent-operated PDF translation tool: a user gives a PDF and translation/layout request to a desktop coding agent, which uses the workspace tools to extract assets and prepare translated HTML and, when a browser is available, PDF output. A separate workflow detects a book’s table of contents and splits it into chapter PDFs. The source excerpts show detector internals and safety/HTML checks; the README documents the agent-led translation and output steps. Translation itself is agent-driven and is not represented as an inspected code subsystem.
Main entry points: pipeline.py Detection pipeline · actions.py Book split actions · extract_assets.py Asset tool · packager.py Output packaging
Components 30
Agent workflows
- Desktop agent
- Asset tool
tools/src/extract_assets.py - PDF image operations
tools/src/image_ops.py
Figure detection
- Figure extraction
tools/src/figure_detector/extract.py - Detection pipeline
tools/src/figure_detector/pipeline.py - Page text analysis
tools/src/figure_detector/text.py - Raster detection
tools/src/figure_detector/raster.py - Vector detection
tools/src/figure_detector/vector.py - Candidate merging
tools/src/figure_detector/merge.py - Caption matching
tools/src/figure_detector/captions.py - Caption primitives
tools/src/figure_detector/caption_match.py - Geometry helpers
tools/src/figure_detector/geometry.py - Detection models
tools/src/figure_detector/model.py
Output and safety
- HTML quality checks
tools/src/html_qa.py - Reader shell
tools/src/reader_shell.py - Output packaging
tools/src/packager.py - Browser PDF export
tools/src/pdf_export.py - Path safety
tools/src/path_guards.py - Output paths
tools/src/output_paths.py
Book splitting
- Book split actions
tools/src/book_splitter/actions.py - TOC detection
tools/src/book_splitter/toc.py - Chapter planner
tools/src/book_splitter/planner.py - Page alignment
tools/src/book_splitter/alignment.py - TOC features
tools/src/book_splitter/features.py - Split confinement
tools/src/book_splitter/confinement.py - Split rules
tools/src/book_splitter/constants.py
Other components
- PDF user
- Source PDF
- HTML and PDF files
- Chapter PDFs
Connections 35
- PDF user → Desktop agent: requests translation
- Desktop agent → Asset tool: invokes tools
- PDF user → Source PDF: provides PDF
- Asset tool → Figure extraction: extracts figures
tools/src/extract_assets.py - Asset tool → PDF image operations: uses image operations
tools/src/extract_assets.py - Asset tool → Book split actions: dispatches splitting
tools/src/extract_assets.py - Asset tool → Output packaging: packages output
tools/src/extract_assets.py - Asset tool → Browser PDF export: exports PDF
tools/src/extract_assets.py - Asset tool → Path safety: checks paths
tools/src/extract_assets.py - Figure extraction → Detection pipeline: runs detection
tools/src/figure_detector/extract.py - Detection pipeline → Page text analysis: analyzes text
tools/src/figure_detector/pipeline.py - Detection pipeline → Raster detection: detects raster
tools/src/figure_detector/pipeline.py - Detection pipeline → Vector detection: detects vectors
tools/src/figure_detector/pipeline.py - Detection pipeline → Candidate merging: merges candidates
tools/src/figure_detector/pipeline.py - Detection pipeline → Caption matching: matches captions
tools/src/figure_detector/pipeline.py - Caption matching → Caption primitives: uses primitives
tools/src/figure_detector/captions.py - Detection pipeline → Detection models: uses models
tools/src/figure_detector/pipeline.py - Detection pipeline → Geometry helpers: uses geometry
tools/src/figure_detector/pipeline.py - Detection pipeline → PDF image operations: uses image operations
tools/src/figure_detector/pipeline.py - Output packaging → HTML quality checks: checks HTML
tools/src/packager.py - Output packaging → Reader shell: uses shell
tools/src/packager.py - Output packaging → Output paths: resolves output paths
tools/src/packager.py - Output packaging → Path safety: validates paths
tools/src/packager.py - Output packaging → Browser PDF export: requests PDF export
tools/src/packager.py - Browser PDF export → HTML quality checks: checks HTML
tools/src/pdf_export.py - Browser PDF export → Reader shell: uses shell
tools/src/pdf_export.py - Browser PDF export → Output paths: resolves paths
tools/src/pdf_export.py - Desktop agent → HTML and PDF files: returns translation
- Book split actions → TOC detection: finds contents
tools/src/book_splitter/actions.py - Book split actions → Chapter planner: plans chapters
tools/src/book_splitter/actions.py - Book split actions → Page alignment: aligns pages
tools/src/book_splitter/actions.py - Book split actions → TOC features: uses TOC features
tools/src/book_splitter/actions.py - Book split actions → Split confinement: confines outputs
tools/src/book_splitter/actions.py - Book split actions → Split rules: uses split rules
tools/src/book_splitter/actions.py - Book split actions → Chapter PDFs: writes chapters