name: rf-doc-ingest
description: Load and prepare a long document (PDF, DOCX, Markdown, or plain text) for analysis. Handles documents up to 200+ pages by creating a structured ingest report with table of contents, page count, document type, language, and chunking plan. Must be run before rf-doc-summarize or rf-doc-extract. Trigger phrases: "load this document", "analyze this PDF", "I have a paper to read", "ingest document", "/rf-doc-ingest".
metadata:
author: ResearchForge
version: 1.0.0
module: document-analysis
Document Ingestion
You are preparing a long document for deep analysis. Your job is to profile the document, understand its structure, and produce an ingest report that downstream skills (summarize, extract) can rely on.
Before You Begin
Check if _rf/research-context.md exists. If not, ask the user to run /rf-init first — you need the research context to know what to look for in the document.
Step 1 — Document Input
Ask the user to provide the document. They can:
- Paste content directly — for shorter documents or excerpts
- Share the file path — if the document is accessible on disk
- Upload or attach — if the IDE supports file attachment
Ask: "What is the document? Is it a paper you're citing, your own draft, a reference book chapter, or course material?"
Document roles:
- Source to cite — a published paper or book chapter you'll reference
- Own draft — a thesis or paper draft you're writing and want feedback on
- Reference material — background reading, course notes, or a technical manual
- Dataset document — a report containing data, tables, or results to extract
Step 2 — Document Profile
Once the document is available, extract and record:
- Title — from the document header or metadata
- Authors — if a published work
- Year / version — publication year or document version
- Language — detect primary language (EN / FR / AR / mixed)
- Page count — estimated or exact
- Document type — journal article, conference paper, thesis, report, book chapter, manual
- Has abstract? — yes/no
- Has bibliography? — yes/no (for citation extraction later)
- Has figures/tables? — note count if visible
Step 3 — Table of Contents Extraction
Attempt to extract or reconstruct the table of contents (TOC):
- If a TOC exists in the document, reproduce it as a Markdown list with page numbers
- If no TOC, infer structure from headers/sections found in the content
- If the document is very long (100+ pages), summarize the section hierarchy to 2 levels deep
Label each top-level section as one of:
introduction / background / related-work / methodology / results / discussion / conclusion / references / appendix / other
Step 4 — Chunking Plan
For documents over 30 pages, propose a chunking strategy:
- Divide into logical chunks aligned with section boundaries (never split mid-section)
- Aim for chunks of roughly 10–20 pages or one major section each
- Number the chunks: Chunk 1, Chunk 2, …
- Note which chunks are most relevant to the user's research topic (from research-context.md)
Ask the user: "Which sections are highest priority for your research?" Mark those chunks as [priority].
Step 5 — Output
Save _rf-output/doc-analysis/{date}_{run}_{doc-name}_ingest-report.md:
# Ingest Report — [Document Title]
## Profile
- **Title:** [title]
- **Authors:** [authors]
- **Year:** [year]
- **Language:** [language]
- **Pages:** [count]
- **Type:** [journal article / thesis / report / …]
- **Role:** [source to cite / own draft / reference / dataset]
- **Has abstract:** [yes/no]
- **Has bibliography:** [yes/no]
- **Has figures/tables:** [yes/no — count]
## Table of Contents
[Extracted or reconstructed TOC]
## Chunking Plan
| Chunk | Sections | Pages | Priority |
|-------|----------|-------|----------|
| 1 | [title] | [range] | [high/normal] |
## Notes
[Anything unusual about the document structure]
After saving, recommend: "Run /rf-doc-summarize to generate a structured summary, or /rf-doc-extract to pull specific content (concepts, data, methodology)."