refactor: rename yomitoku output to document.md for consistency

Normalizes the OCR output filename to document.md after finding it,
matching pdftotext output naming. Keeps paths clean in cache and LLM context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dj-oyu 2026-03-20 16:00:20 +09:00
parent 6f71bd4b4e
commit 1008ad0d30

View file

@ -697,12 +697,18 @@ func (al *AgentLoop) ocrPDF(
// Keep: .md files, figures/ directory (referenced by markdown output).
cleanupOCRPageImages(outputDir, pdfPath)
// Find the output markdown file
// Find the output markdown file and normalize its name to document.md
mdPath := findOCROutput(outputDir, pdfPath)
if mdPath == "" {
logger.WarnCF("agent", "OCR output not found", map[string]any{"output_dir": outputDir})
return fmt.Sprintf("[file:%s]", pdfPath)
}
canonical := filepath.Join(outputDir, "document.md")
if mdPath != canonical {
if renameErr := os.Rename(mdPath, canonical); renameErr == nil {
mdPath = canonical
}
}
// Read preview from first part of the markdown
mdData, err := os.ReadFile(mdPath)