Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

Clarify text file handling in doclib

jinzhenjc622f2154506
diff --git a/README.md b/README.md
index 8aa242da..1beea555 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,8 @@ Use MinerU for local document files such as:
| PowerPoint | `.pptx` |
| Excel | `.xlsx` |
+Read `.txt`, `.md`, `.markdown`, `.csv`, `.rst`, and `.tex` files directly. Do not run `mineru parse` for these plain-text formats.
+
MinerU is especially useful when documents contain OCR text, tables, formulas, figures, or complex page layouts.
## Do Not
@@ -74,7 +76,7 @@ MinerU is especially useful when documents contain OCR text, tables, formulas, f
Use this decision tree before running commands:
-1. User provided a file path and wants content: run `mineru parse <file>`.
+1. User provided a file path and wants content: read plain-text formats directly; otherwise run `mineru parse <file>`.
2. User provided a `doc:...` locator: run `mineru read <locator>`.
3. User asks to continue from a previous output: follow the `<!-- Next: ... -->` command exactly.
4. User asks for a specific page or block after parsing: use `mineru read <locator>`, not a fresh parse.
@@ -813,6 +815,7 @@ Use this table for common error codes:
| `file_encrypted` | Password-protected file | Ask user for an unlocked copy |
| `file_corrupted` | File cannot be read | Ask for a valid copy |
| `page_range_invalid` | Bad `--pages` value | Correct to forms such as `1~5`, `1,3,8~10`, or `all` |
+| `parse_not_required` | The input is a directly readable text file | Read the source file directly; do not retry `mineru parse` |
| `not_cached` / `cache_miss` | Requested cached content does not exist | Run `mineru parse` |
Retry rules:
diff --git a/docs/next/api/examples.md b/docs/next/api/examples.md
index 1c3a1571..df490243 100644
--- a/docs/next/api/examples.md
+++ b/docs/next/api/examples.md
@@ -131,7 +131,7 @@ curl -X POST http://localhost:8000/v1/parse/jobs \
}'
```
-对 PDF/image,省略 `tier` 或传 `null` 时,本地 server 按 [解析 Tier](../tiers.md) 的默认选择策略选择非 `flash` 质量 tier。如果不可用,请求应失败,而不是使用 `flash` 返回解析结果。Office/text/HTML 按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 的 API Server 批量规则归一为 `flash`。
+对 PDF/image,省略 `tier` 或传 `null` 时,本地 server 按 [解析 Tier](../tiers.md) 的默认选择策略选择非 `flash` 质量 tier。如果不可用,请求应失败,而不是使用 `flash` 返回解析结果。Office/HTML 按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 的 API Server 批量规则归一为 `flash`,text 不作为解析输入。
## 本地 Server: 复用上传流程
diff --git a/docs/next/api/health-models.md b/docs/next/api/health-models.md
index 76f0b069..fd77a767 100644
--- a/docs/next/api/health-models.md
+++ b/docs/next/api/health-models.md
@@ -155,7 +155,7 @@ Tier 对象字段:
v1 协议中面向用户读取文档的质量档位以 [解析 Tier](../tiers.md) 为准。具体服务当前支持哪些 tier,以 `/v1/tiers` 返回为准。
-请求创建 parse job 时,客户端可以省略 `tier` 或传 `null`,表示使用 [解析 Tier](../tiers.md) 中定义的默认选择策略。对 PDF/image 这类支持多 tier 的输入,默认选择不能等价于 `flash`;Office/text/HTML 按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 的批量规则归一为 `flash`。
+请求创建 parse job 时,客户端可以省略 `tier` 或传 `null`,表示使用 [解析 Tier](../tiers.md) 中定义的默认选择策略。对 PDF/image 这类支持多 tier 的输入,默认选择不能等价于 `flash`;Office/HTML 按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 的批量规则归一为 `flash`,text 不作为解析输入。
更完整产品语义见 [解析 Tier](../tiers.md)。
diff --git a/docs/next/api/parse-jobs.md b/docs/next/api/parse-jobs.md
index d19b97b8..ea1404d2 100644
--- a/docs/next/api/parse-jobs.md
+++ b/docs/next/api/parse-jobs.md
@@ -353,4 +353,4 @@ Local Parse Server 的任务 API 与官方 API 保持同一结构,但有以下
- `health.features.sources` 必须反映本地 server 实际允许的 source 类型;只有启动时开启 `--allow-local-source` 才包含 `local`。
- `local` source 可以不生成输入 `file_id`;响应中应保留 `name` 和文件级状态。
- 对 PDF/image,省略 `tier` 或传 `null` 时,只能按默认选择策略选择本地可发现的非 `flash` 质量 tier,不能回退到 `flash`;如果只有 `flash` 可用,应返回 `quality_tier_unavailable`。
-- 对 Office/text/HTML,API Server job 按批量规则处理,即使 job tier 是质量 tier,文件实际解析也按 `flash` 语义归一;暂不新增 file-level effective tier 字段。
+- 对 Office/HTML,API Server job 按批量规则处理,即使 job tier 是质量 tier,文件实际解析也按 `flash` 语义归一;text 不进入 parse job;暂不新增 file-level effective tier 字段。
diff --git a/docs/next/api/responses.md b/docs/next/api/responses.md
index 176f3570..8df3f01e 100644
--- a/docs/next/api/responses.md
+++ b/docs/next/api/responses.md
@@ -126,5 +126,5 @@ Local Parse Server 使用同一套错误 envelope。差异主要体现在错误
- 未启用 API Key 时,不会产生 `invalid_api_key`。
- 请求 `local` source 但本地 server 未开启 `--allow-local-source`,应返回 `400 unsupported_source`。
-- PDF/image 省略 `tier` 或传 `null` 且无法解析到非 `flash` 质量 tier 时,应返回 tier 相关错误,不能降级到 `flash`。Office/text/HTML 按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 归一为 `flash`。
+- PDF/image 省略 `tier` 或传 `null` 且无法解析到非 `flash` 质量 tier 时,应返回 tier 相关错误,不能降级到 `flash`。Office/HTML 按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 归一为 `flash`,text 不作为解析输入。
- 解析能力缺失时,应优先返回可操作的 `engine_error`,而不是泛化为 `internal_error`。
diff --git a/docs/next/architecture.md b/docs/next/architecture.md
index 49a438fa..ce7c6b1a 100644
--- a/docs/next/architecture.md
+++ b/docs/next/architecture.md
@@ -165,7 +165,7 @@ metadata 更新规则:入库阶段写基础 metadata;解析完成后,只
| 表 | 作用 |
|----|------|
-| `fts_contents` | 内容全文搜索,只保留最高 tier 文本 |
+| `fts_contents` | 内容全文搜索;解析内容保留最高 tier 文本,text 源内容的 tier 为 `null` |
| `fts_filenames` | 文件名搜索 |
| `watches` | 监控目录、可插拔设备状态 |
| `exclude_rules` | exclude 路径规则 |
@@ -200,7 +200,7 @@ SQLite 运行在 WAL 模式,使用 FTS5 提供搜索能力。每次 DB 操作
这样用户无需理解“索引”和“解析”两个概念;不同 tier 只是解析深度和执行路径不同。
-注意:`flash` 是 watch 自动发现和搜索索引的低成本 tier,不应作为 PDF/image 主动阅读时的默认最终质量。PDF/image 主动阅读未指定 tier 时应使用默认选择策略;有能力发现上下文时按 `high` -> `xhigh` -> `medium` 解析。Office/text/HTML 的归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。
+注意:`flash` 是 watch 自动发现和搜索索引的低成本 tier,不应作为 PDF/image 主动阅读时的默认最终质量。PDF/image 主动阅读未指定 tier 时应使用默认选择策略;有能力发现上下文时按 `high` -> `xhigh` -> `medium` 解析。Office/HTML 的归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md);text 只入库和索引,直接读取源文件。
### 4.2 文件发现到入库
@@ -272,7 +272,7 @@ ParseWorker 按 `tier`、`privacy` 和 parse-server 健康状态路由:
| 条件 | 执行路径 |
|------|----------|
-| 未指定 tier | PDF/image 通过当前目标 parse-server 能力发现,按 `high` -> `xhigh` -> `medium` 解析;Office/text/HTML 归一为 `flash` |
+| 未指定 tier | PDF/image 通过当前目标 parse-server 能力发现,按 `high` -> `xhigh` -> `medium` 解析;Office/HTML 归一为 `flash`;text 直接读取 |
| `tier=flash` | 直接本地调用轻量 parser,`via=local` |
| `tier=medium/high/xhigh` 且 `privacy=remote` | 优先调用 config 中的远端地址,默认使用 `https://mineru.net/api` |
| remote 不可用 | 尝试 fallback 到 local parse-server |
@@ -328,7 +328,7 @@ doclib 不在 `parsed/` 中保存 Markdown、Content List 或 HTML。它们都
搜索策略:
- `fts_filenames` 用于文件名搜索。
-- `fts_contents` 用于正文、标题和作者搜索,同一文档只保留最高 tier 内容,不存储或匹配 filename。
+- `fts_contents` 用于正文、标题和作者搜索,同一文档只保留一份内容,不存储或匹配 filename。解析内容记录实际 tier,直接索引的 text 源内容记录 `tier=null`。
- 内容超过 30K 字符时,保留 head + tail,完整内容仍从解析产物读取。
- 中文分词采用 jieba + FTS5 `unicode61` 的组合方案。
diff --git a/docs/next/cli/README.md b/docs/next/cli/README.md
index ff77fb54..d916aaf9 100644
--- a/docs/next/cli/README.md
+++ b/docs/next/cli/README.md
@@ -51,7 +51,7 @@ MinerU 仓库提供两款命令行工具:
- 解析 tier 语义以 [解析 Tier](../tiers.md) 为准。
- 不显式 `--remote` 时,不上传用户文档。
- 用户主动读取 PDF/image 时,不把 `flash` 作为默认最终质量。
-- 未指定 tier 使用默认选择策略;PDF/image 默认选择不会解析为 `flash`,Office/text/HTML 归一规则见 [ADR-0024](../decisions/0024-file-type-tier-normalization.md)。
+- 未指定 tier 使用默认选择策略;PDF/image 默认选择不会解析为 `flash`,Office/HTML 归一规则见 [ADR-0024](../decisions/0024-file-type-tier-normalization.md),text 直接读取。
- CLI 错误应使用结构化错误码和可执行修复建议。
- 错误码、`retryable` 和 `user_action` 语义见 [错误码体系](../errors.md)。
diff --git a/docs/next/cli/mineru-library.md b/docs/next/cli/mineru-library.md
index 2454a0b8..f06416d8 100644
--- a/docs/next/cli/mineru-library.md
+++ b/docs/next/cli/mineru-library.md
@@ -14,7 +14,7 @@
## 2. search
-`mineru search` 面向已解析内容检索。
+`mineru search` 面向已建立内容索引的文档检索,包括解析内容和直接索引的 text 源内容。
```bash
mineru search "keyword"
@@ -24,10 +24,11 @@ mineru search "keyword" --min-tier medium --type pdf
行为:
-- 查询 `fts_contents`,未解析或未建立内容索引的文件不会命中正文检索。
+- 查询 `fts_contents`,未建立内容索引的文件不会命中正文检索。
- 按文档 SHA256 去重。
- 支持按 `file_type`、`tier`、`min_tier` 过滤。
-- 返回文档大小、页数、命中片段、snippet 来源 tier,以及关联的全部 file aliases。
+- 返回文档大小、页数、命中片段、可空的 snippet 来源 tier,以及关联的全部 file aliases。
+- text 源内容的 `tier` 为 `null`;指定 `--tier` 或 `--min-tier` 时不返回这类结果。
- JSON 返回全部 file aliases 及其状态,并按 file id 降序排列。
- 非 JSON 输出存在 active files 时只展示 active paths;没有 active file 时展示全部 inactive paths。
- 已索引的 orphan 文档仍可命中,非 JSON 输出提示文件已不存在。
@@ -40,7 +41,7 @@ JSON 输出中的每条结果至少包含:
| `size_bytes` | 文件大小。 |
| `page_count` | 文档页数;未知时为 `null`。 |
| `snippet` | 命中的内容片段。 |
-| `tier` | snippet 来源 tier。 |
+| `tier` | snippet 来源解析 tier;直接索引的 text 源内容为 `null`。 |
| `files` | 与文档 SHA 关联的全部 files,包含 `path`、`filename`、`ext`、`status`。 |
`search` 不匹配 filename;按文件名定位使用 `mineru find`。
@@ -179,7 +180,7 @@ watch 用于自动发现文件并建立本地索引。
- watch 默认使用 `flash`。
- watch 的目标是发现和搜索,不是最终阅读质量。
-- Agent 或用户主动读取 PDF/image 文档时,应通过 `mineru parse` 使用默认选择策略或显式 tier;Office/text/HTML 读取按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 归一为 `flash` 语义。
+- Agent 或用户主动读取 PDF/image 文档时,应通过 `mineru parse` 使用默认选择策略或显式 tier;Office/HTML 读取按 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 归一为 `flash` 语义;text 直接读取源文件。
- 可插拔设备不可达时,watch 标记为 `unreachable`,该 watch 下的 active 文件标记为 `unreachable`,而不是永久删除。
- 可插拔设备恢复时,watch 和文件恢复为 `active`,并立即对该 watch 执行一次 scan。
- scan 发现文件真实缺失时,文件标记为 `deleted`,保留 `sha256`。
@@ -311,6 +312,7 @@ mineru invalidate ~/Documents/a.pdf --tier flash
- 省略 `--tier` 时作废该文档所有 tier 的 done batch。
- 指定 `--tier` 时只作废对应 tier。
- 作废后再次 `mineru parse` 会重新创建或复用新的解析任务。
+- text 文件没有 parse batch,返回 `parse_not_required`,应直接读取源文件。
- 当前命令不暴露 `--json`。
## 13. telemetry
@@ -338,7 +340,7 @@ mineru config parsing-rules add "*/论文/*" --tier medium --pages all
mineru config parsing-rules add "*/合同/*" --tier high --remote
```
-parsing-rule 的 `tier` 和 `remote` 只适用于 PDF 和 image。Office、text 和 HTML 命中规则时忽略 `tier` 和 `remote`,按 `flash` 解析,并且 parse row 记录为 `flash`。
+parsing-rule 的 `tier` 和 `remote` 只适用于 PDF 和 image。Office 和 HTML 命中规则时忽略 `tier` 和 `remote`,按 `flash` 解析,并且 parse row 记录为 `flash`;text 只入库和索引,不创建 parse row。
PDF/image 命中规则时,系统必须检查本地或远端能力是否支持对应 tier。rule 未指定 tier 时,按 `high` -> `xhigh` -> `medium` -> `flash` 选择可用 tier,并记录实际 tier。完整文件类型归一规则见 [ADR-0024](../decisions/0024-file-type-tier-normalization.md)。
diff --git a/docs/next/cli/mineru-parse.md b/docs/next/cli/mineru-parse.md
index abe2e6ec..78ed6a29 100644
--- a/docs/next/cli/mineru-parse.md
+++ b/docs/next/cli/mineru-parse.md
@@ -22,7 +22,8 @@ read(locator) = read existing parsed content by stable locator
设计原则:
- 隐私优先:不显式 `--remote` 就不上传文档。
-- 质量优先:PDF/image 未指定 tier 时使用默认选择策略,不会解析为 `flash`;Office/text/HTML 未指定 tier 时归一为 `flash`。
+- 质量优先:PDF/image 未指定 tier 时使用默认选择策略,不会解析为 `flash`;Office/HTML 未指定 tier 时归一为 `flash`。
+- 文本直读:`.txt`、`.md`、`.markdown`、`.csv`、`.rst` 和 `.tex` 无需解析,应直接读取源文件。
- Agent-native:默认适合 STDOUT、有限上下文和渐进式阅读。
- 先入库后输出:解析结果先写入本地文档库,再输出。
- 去重缓存:相同 SHA256 和实体 tier 可复用 done 缓存;`--force` 跳过 done 缓存,但可复用 active parse,不作废旧缓存。
@@ -73,7 +74,7 @@ mineru parse <file> [flags]
`mineru parse` 未指定 `--tier` 时使用默认选择策略。
-PDF/image 的默认选择策略通过当前目标 parse-server 的能力发现,按 [解析 Tier](../tiers.md) 定义的 `high` -> `xhigh` -> `medium` 顺序选择。如果找不到可用质量 tier,返回可解释错误。Office/text/HTML 归一为 `flash` 语义,详见 [ADR-0024](../decisions/0024-file-type-tier-normalization.md)。
+PDF/image 的默认选择策略通过当前目标 parse-server 的能力发现,按 [解析 Tier](../tiers.md) 定义的 `high` -> `xhigh` -> `medium` 顺序选择。如果找不到可用质量 tier,返回可解释错误。Office/HTML 归一为 `flash` 语义,详见 [ADR-0024](../decisions/0024-file-type-tier-normalization.md)。文本文件不创建 parse 任务或 Middle JSON,显式请求返回 `parse_not_required`。
`flash` 只有在用户显式指定 `--tier flash` 时才作为最终解析结果返回。
@@ -85,7 +86,8 @@ PDF/image 的默认选择策略通过当前目标 parse-server 的能力发现
2. 带 `--remote`:允许上传文档到 config 指定远端或默认 `mineru.net/api`。
3. 本地能力不足:返回错误和修复建议,不静默上传。
4. 用户显式选择 `--tier flash`:允许返回 `flash` 结果。
-5. 未指定 tier:PDF/image 使用默认选择策略,不可降级到 `flash`;Office/text/HTML 归一为 `flash`。
+5. 未指定 tier:PDF/image 使用默认选择策略,不可降级到 `flash`;Office/HTML 归一为 `flash`。
+6. 文本文件不上传也不解析,直接返回 `parse_not_required`,提示调用方读取源文件。
当本地能力不足、默认选择无法解析、远端未显式允许或 parse-server 不支持请求 tier 时,错误码见 [错误码体系](../errors.md)。
diff --git a/docs/next/cli/mineru-read.md b/docs/next/cli/mineru-read.md
index 7d93fe4d..6c9781a0 100644
--- a/docs/next/cli/mineru-read.md
+++ b/docs/next/cli/mineru-read.md
@@ -19,6 +19,8 @@ read(locator) = read existing parsed content by stable locator
`read` 不负责 discover、scan、ingest,也不默认创建 parse task。它读取的是 doclib 中已有的解析结果。
+text 文件没有解析结果;当 locator 指向 text doc 时,返回 `parse_not_required`,调用方应直接读取源文件。
+
## 2. Usage
```bash
diff --git a/docs/next/cli/mineru-server.md b/docs/next/cli/mineru-server.md
index 87e87506..47a0e712 100644
--- a/docs/next/cli/mineru-server.md
+++ b/docs/next/cli/mineru-server.md
@@ -133,7 +133,7 @@ local parse-server 是独立进程,由 `mineru-kit api-server` 提供。doclib
| `managed` | doclib 启停时自动管理 parse-server |
| `self_hosted` | 用户自己启动 parse-server,doclib 只连接 URL |
-PDF/image 默认选择策略需要通过 local 或 remote parse-server 的能力发现解析为可用的非 `flash` tier,选择顺序见 [解析 Tier](../tiers.md)。Office/text/HTML 的归一规则见 [ADR-0024](../decisions/0024-file-type-tier-normalization.md)。
+PDF/image 默认选择策略需要通过 local 或 remote parse-server 的能力发现解析为可用的非 `flash` tier,选择顺序见 [解析 Tier](../tiers.md)。Office/HTML 的归一规则见 [ADR-0024](../decisions/0024-file-type-tier-normalization.md);text 直接读取。
## 6. 崩溃恢复
diff --git a/docs/next/config.md b/docs/next/config.md
index 234761b0..6d12ab29 100644
--- a/docs/next/config.md
+++ b/docs/next/config.md
@@ -25,7 +25,7 @@ MinerU 有两类配置:
配置必须服务两个产品原则:
- 隐私优先:任何配置都不能导致静默上传文档。
-- 质量优先:PDF/image 主动阅读未指定 tier 时使用默认选择策略,不能静默降级到 `flash`;Office/text/HTML 按实际能力归一为 `flash`。
+- 质量优先:PDF/image 主动阅读未指定 tier 时使用默认选择策略,不能静默降级到 `flash`;Office/HTML 按实际能力归一为 `flash`;text 直接读取。
## 2. 两阶段配置模型
@@ -237,7 +237,7 @@ mineru config parsing-rules add "*/合同/*" --tier high --remote
- 对 PDF/image,规则必须显式指定 remote,才允许上传远端。
- 对 PDF/image,规则命中的 tier 必须经过能力检查。
- 对 PDF/image,规则未指定 tier 时按 `high` -> `xhigh` -> `medium` -> `flash` 选择,并只记录实际使用的实体 tier。
-- 对 Office/text/HTML,parsing-rule 的 tier 和 remote 不生效,实际按 `flash` 记录。
+- 对 Office/HTML,parsing-rule 的 tier 和 remote 不生效,实际按 `flash` 记录;text 只入库和索引,不创建 parse row。
- 完整归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。
### 8.3 Exclude
diff --git a/docs/next/decisions/0006-doclib-file-change-detection.md b/docs/next/decisions/0006-doclib-file-change-detection.md
index 80b5523c..586f4a74 100644
--- a/docs/next/decisions/0006-doclib-file-change-detection.md
+++ b/docs/next/decisions/0006-doclib-file-change-detection.md
@@ -199,7 +199,7 @@ SELECT * FROM files WHERE sha256=? AND status='active' LIMIT 1
- 可解析文档由 parse 成功后更新 `fts_contents`。
- invalidate 后按剩余最高有效 tier 重建或删除 `fts_contents`。
-- 纯文本文件不创建 parse batch,但入库时应直接读取文本并写入 `fts_contents`,使 `GET /search` 能搜索文本内容。
+- 纯文本文件不创建 parse batch,但入库时应直接读取文本并以 `tier=NULL` 写入 `fts_contents`,使 `GET /search` 能搜索文本内容。
### 纯文本文件
diff --git a/docs/next/decisions/0022-doclib-file-type-tier-remote-semantics.md b/docs/next/decisions/0022-doclib-file-type-tier-remote-semantics.md
index b4336b89..45e22b0d 100644
--- a/docs/next/decisions/0022-doclib-file-type-tier-remote-semantics.md
+++ b/docs/next/decisions/0022-doclib-file-type-tier-remote-semantics.md
@@ -10,7 +10,8 @@
- PDF 和 image 可以进入质量 tier 路径,支持 `flash`、`medium`、`high` 和 `xhigh`。
- Office 文件走专门的 Office parser,实际只支持 `flash`。
-- text / html 类输入不走 PDF 质量后端,也只具备 `flash` 语义。
+- HTML 不走 PDF 质量后端,只具备 `flash` 语义。
+- text 输入可入库和建立搜索索引,但无需解析,不产生 parse row 或 Middle JSON。
此前 Office 文件显式传入质量 tier 时,会在服务层静默覆盖为 `flash`。CLI 和 JSON 输出只显示最终 tier,无法表达“用户请求被忽略”。这会让自动化脚本、测试和用户判断误以为质量 tier 已被执行。
@@ -44,14 +45,15 @@ image 扩展名只进入 `INGESTIBLE_EXTENSIONS`,不进入 `DISCOVERABLE_EXTEN
| PDF | 支持 | 支持 | 支持 | 支持 |
| image | 支持 | 支持 | 支持 | 支持 |
| Office (`docx` / `pptx` / `xlsx`) | 支持 | 不支持 | 不支持 | 不支持 |
-| text / html (`txt` / `md` / `csv` / `rst` / `tex` / `html` / `htm`) | 支持 | 不支持 | 不支持 | 不支持 |
+| HTML (`html` / `htm`) | 支持 | 不支持 | 不支持 | 不支持 |
+| text (`txt` / `md` / `markdown` / `csv` / `rst` / `tex`) | 无需解析 | 无需解析 | 无需解析 | 无需解析 |
-当非 PDF / image 文件在 doclib 单对象主动解析中显式请求质量 tier 时,doclib 不再自动降级为 `flash`,而是返回 `InvalidRequestError`。批量、parsing-rule、API Server 和 mineru-kit 的归一化例外见 [ADR-0024](0024-file-type-tier-normalization.md)。
+当 Office / HTML 在 doclib 单对象主动解析中显式请求质量 tier 时,doclib 不再自动降级为 `flash`,而是返回 `InvalidRequestError`。批量、parsing-rule、API Server 和 mineru-kit 的归一化例外见 [ADR-0024](0024-file-type-tier-normalization.md)。
- `code`: `tier_unsupported_for_file_type`
- `param`: `tier`
-未显式传入 tier 的非 PDF / image 文件继续按 `flash` 语义处理。
+未显式传入 tier 的 Office / HTML 文件继续按 `flash` 语义处理。text 文件无论是否指定 tier,均返回 `parse_not_required`,`param` 为 `path`,提示调用方直接读取源文件。
### Remote 能力矩阵
@@ -62,9 +64,10 @@ doclib 单对象主动解析中的 `--remote` 只支持 PDF 和 image,并且
| PDF | 支持非 `flash` 质量 tier,不支持 `flash` |
| image | 支持非 `flash` 质量 tier,不支持 `flash` |
| Office | 不支持 |
-| text / html | 不支持 |
+| HTML | 不支持 |
+| text | 无需解析;返回 `parse_not_required` |
-当非 PDF / image 文件在 doclib 单对象主动解析中请求 `--remote` 时,doclib 返回 `InvalidRequestError`:
+当 Office / HTML 在 doclib 单对象主动解析中请求 `--remote` 时,doclib 返回 `InvalidRequestError`:
- `code`: `remote_unsupported_for_file_type`
- `param`: `remote`
@@ -80,9 +83,10 @@ doclib 单对象主动解析中的 `--remote` 只支持 PDF 和 image,并且
当多个参数同时冲突时,优先返回更贴近显式冲突参数的错误:
-1. doclib 单对象主动解析中,`--remote` 与非 PDF / image 文件冲突时,返回 `remote_unsupported_for_file_type`。
-2. PDF / image 的 `--remote --tier flash` 冲突时,返回 `tier_unsupported_for_remote`。
-3. doclib 单对象主动解析中,非 PDF / image 的质量 tier 冲突时,返回 `tier_unsupported_for_file_type`。
+1. text 文件无需解析,优先返回 `parse_not_required`,不再校验 tier、remote 或 force 的组合。
+2. doclib 单对象主动解析中,`--remote` 与 Office / HTML 冲突时,返回 `remote_unsupported_for_file_type`。
+3. PDF / image 的 `--remote --tier flash` 冲突时,返回 `tier_unsupported_for_remote`。
+4. doclib 单对象主动解析中,Office / HTML 的质量 tier 冲突时,返回 `tier_unsupported_for_file_type`。
例如 `sample.docx --remote --tier flash` 优先报告 remote 不支持该文件类型,而不是报告 remote 不支持 flash。
@@ -104,7 +108,7 @@ doclib 单对象主动解析中的 `--remote` 只支持 PDF 和 image,并且
原因:
-- Office、text、html 并没有对应 PDF 质量后端能力。
+- Office、HTML 没有对应 PDF 质量后端能力,text 则无需解析。
- 名义兼容会让 `parse.tier` 和 locator tier 与实际解析路径脱节。
- 后续如果这些格式真的支持质量 tier,应作为新能力显式加入,而不是提前保留虚假语义。
@@ -134,8 +138,9 @@ doclib 单对象主动解析中的 `--remote` 只支持 PDF 和 image,并且
### 对兼容性
-- 这是有意的 doclib 单对象主动解析行为收紧。依赖非 PDF / image 显式请求质量 tier 或 `--remote` 成功退出的脚本需要调整。
-- 未显式指定质量 tier 的 Office、text、html 解析仍保持 `flash` 语义。
+- 这是有意的 doclib 单对象主动解析行为收紧。依赖 Office / HTML 显式请求质量 tier 或 `--remote` 成功退出的脚本需要调整;依赖 text parse 成功退出的脚本应改为直接读取源文件。
+- 未显式指定质量 tier 的 Office、HTML 解析仍保持 `flash` 语义。
+- text 文件仍可入库、发现和搜索,但显式 parse 返回 `parse_not_required`。
- PDF / image 的本地 `flash` 和本地 / remote 质量 tier 路径保持可用。
### 对测试
@@ -144,12 +149,13 @@ doclib 单对象主动解析中的 `--remote` 只支持 PDF 和 image,并且
- 显式 parse image 能入库并创建 parse 任务。
- watch / scan 不自动发现 image。
-- doclib 单对象主动解析中,非 PDF / image 请求质量 tier 报 `tier_unsupported_for_file_type`。
-- doclib 单对象主动解析中,非 PDF / image 请求 `--remote` 报 `remote_unsupported_for_file_type`。
+- doclib 单对象主动解析中,Office / HTML 请求质量 tier 报 `tier_unsupported_for_file_type`。
+- doclib 单对象主动解析中,Office / HTML 请求 `--remote` 报 `remote_unsupported_for_file_type`。
+- text 文件的显式 parse 请求(包括 `--force`、quality tier 和 `--remote`)均报 `parse_not_required`,且保留入库和搜索索引。
- PDF / image 请求 `--remote --tier flash` 报 `tier_unsupported_for_remote`。
## 后续动作
1. 在 CLI / tier / error 文档中同步文件类型、tier、remote 的能力矩阵。
-2. 如果未来 Office 或 text/html 支持质量 tier,应通过新 ADR 或本 ADR 的 superseding 记录更新能力矩阵。
+2. 如果未来 Office / HTML 支持质量 tier,或 text 需要结构化解析,应通过新 ADR 或本 ADR 的 superseding 记录更新能力矩阵。
3. 如果需要非错误型 warning 通道,应设计稳定的 `warnings` / `hints` 响应字段,而不是复用 `tip` 承载参数冲突。
diff --git a/docs/next/decisions/0024-file-type-tier-normalization.md b/docs/next/decisions/0024-file-type-tier-normalization.md
index c2cdfc81..e63d371e 100644
--- a/docs/next/decisions/0024-file-type-tier-normalization.md
+++ b/docs/next/decisions/0024-file-type-tier-normalization.md
@@ -6,12 +6,12 @@
## 背景
-MinerU 同时支持 PDF、image、Office、text 和 HTML 输入,但这些输入并不具备相同的 tier 能力。
+MinerU doclib 可以接收 PDF、image、Office、text 和 HTML 输入,但这些输入并不具备相同的解析能力。
-PDF 和 image 支持质量 tier: `flash`、`medium`、`high`、`xhigh`。Office、text 和 HTML 当前只有 `flash` 语义,没有对应的质量 tier。此前不同入口对“非 PDF/image + 质量 tier”的处理不完全一致:
+PDF 和 image 支持质量 tier: `flash`、`medium`、`high`、`xhigh`。Office 和 HTML 当前只有 `flash` 语义,没有对应的质量 tier。text 可入库和搜索,但不需要解析。此前不同入口对“非 PDF/image + 质量 tier”的处理不完全一致:
- 有的入口报错。
-- 有的入口静默走 Office / text / HTML parser。
+- 有的入口静默走 Office / HTML parser,或为 text 返回没有对应缓存的合成成功响应。
- parsing-rule 可能创建 `tier=high` 等 parse row,但实际执行的仍是 Office / flash 语义。
这种不一致会让 parse row、缓存目录、locator 和用户看到的实际解析能力脱节。因此需要定义一套按操作类型区分的归一化规则。
@@ -22,14 +22,15 @@ PDF 和 image 支持质量 tier: `flash`、`medium`、`high`、`xhigh`。Office
### 1. 文件类型分组
-MinerU 在 tier 语义上把输入分为两组:
+MinerU 在 tier 语义上把输入分为三组:
| 分组 | 文件类型 | Tier 能力 |
|------|----------|-----------|
| 支持多 tier 的输入 | PDF、image | `flash`、`medium`、`high`、`xhigh` |
-| 仅支持 flash tier 的输入 | Office、text、HTML | 仅 `flash` 语义 |
+| 仅支持 flash tier 的输入 | Office、HTML | 仅 `flash` 语义 |
+| 无需解析的文本输入 | `.txt`、`.md`、`.markdown`、`.csv`、`.rst`、`.tex` | 无 tier;直接读取源文件 |
-Office、text 和 HTML 即使通过高层接口传入了 `medium`、`high` 或 `xhigh`,也不能把结果记录为这些质量 tier,除非未来另有 ADR 明确引入对应能力。
+Office 和 HTML 即使通过高层接口传入了 `medium`、`high` 或 `xhigh`,也不能把结果记录为这些质量 tier,除非未来另有 ADR 明确引入对应能力。text 不创建 parse row 或 Middle JSON,显式 parse 返回 `parse_not_required`。
### 2. 单对象主动操作
@@ -45,9 +46,10 @@ Office、text 和 HTML 即使通过高层接口传入了 `medium`、`high` 或 `
| 输入类型 | 未指定 tier | 指定 `flash` | 指定 `medium/high/xhigh` |
|----------|-------------|--------------|--------------------------|
| PDF / image | 使用该入口默认质量选择策略 | 使用 `flash` | 使用指定质量 tier |
-| Office / text / HTML | 归一为 `flash` | 使用 `flash` | 报错 |
+| Office / HTML | 归一为 `flash` | 使用 `flash` | 报错 |
+| text | 不解析;doclib 返回 `parse_not_required` | 不解析;doclib 返回 `parse_not_required` | 不解析;doclib 返回 `parse_not_required` |
-因此,单对象主动操作中,用户显式指定质量 tier 表达明确质量预期。对于没有质量 tier 能力的输入,系统不能静默降级。
+因此,单对象主动操作中,用户显式指定质量 tier 表达明确质量预期。对于没有质量 tier 能力的输入,系统不能静默降级。SDK 和 `mineru-kit` 的解析输入校验直接排除 text;doclib 使用更具体的 `parse_not_required` 指导用户读取源文件。
### 3. 批量操作
@@ -57,18 +59,19 @@ Office、text 和 HTML 即使通过高层接口传入了 `medium`、`high` 或 `
- `mineru-kit parse` 展开后包含多个输入文件,或输入目录。
- parsing-rule 触发的后台解析。
-批量操作的目标是处理一组异构文件。为了避免一个 Office、text 或 HTML 文件阻断整个批次,仅支持 flash tier 的输入允许静默归一为 `flash`。
+批量操作的目标是处理一组异构文件。为了避免一个 Office 或 HTML 文件阻断整个批次,仅支持 flash tier 的输入允许静默归一为 `flash`。text 文件不进入 parse 批次;需要保留内容时直接读取或建立文本索引。
规则:
| 输入类型 | 未指定 tier | 指定 `flash` | 指定 `medium/high/xhigh` |
|----------|-------------|--------------|--------------------------|
| PDF / image | 使用该入口默认选择策略 | 使用 `flash` | 使用指定质量 tier |
-| Office / text / HTML | 归一为 `flash` | 使用 `flash` | 归一为 `flash` |
+| Office / HTML | 归一为 `flash` | 使用 `flash` | 归一为 `flash` |
+| text | 不进入 parse 批次 | 不进入 parse 批次 | 不进入 parse 批次 |
-批量操作中,非 PDF/image 的实际 parse row、缓存目录、locator 和 metadata 必须记录 `flash`,不能记录用户传入的质量 tier。
+批量操作中,Office/HTML 的实际 parse row、缓存目录、locator 和 metadata 必须记录 `flash`,不能记录用户传入的质量 tier。text 不得生成这些解析产物。
-API Server 当前只有 job 级 `tier` 字段,暂不扩展 file-level effective tier 字段。因此 API job 响应中的 job tier 可以表示请求 tier;但内部执行非 PDF/image 文件时,应按 `flash` 语义处理,不产生伪质量缓存。
+API Server 当前只有 job 级 `tier` 字段,暂不扩展 file-level effective tier 字段。因此 API job 响应中的 job tier 可以表示请求 tier;但内部执行 Office/HTML 文件时,应按 `flash` 语义处理,不产生伪质量缓存。text 不进入 API parse job。
### 4. Parsing-Rule 语义
@@ -77,7 +80,8 @@ parsing-rule 是批量/后台规则,不是用户对单个文件的显式 parse
规则:
- `tier` 和 `remote` 参数只适用于 PDF 和 image。
-- Office、text 和 HTML 命中 parsing-rule 时,忽略 rule 中的 `tier` 和 `remote`,按 `flash` 解析。
+- Office 和 HTML 命中 parsing-rule 时,忽略 rule 中的 `tier` 和 `remote`,按 `flash` 解析。
+- text 命中 parsing-rule 时只完成入库和文本索引,不创建 parse row。
- PDF/image 命中 parsing-rule 且指定 tier 时,使用 rule tier。
- PDF/image 命中 parsing-rule 但未指定 tier 时,按以下顺序选择可用 tier:
@@ -91,20 +95,20 @@ high -> xhigh -> medium -> flash
remote 的含义取决于入口:
-| 入口 | 非 PDF/image + remote |
-|------|----------------------|
-| doclib / `mineru parse` 单文件主动解析 | 报错 |
-| parsing-rule | 忽略 remote,按 `flash` |
-| API Server job | 不适用;API Server 自身就是解析服务 |
-| `mineru-kit parse` | 允许,作为低层工具特例 |
+| 入口 | Office/HTML + remote | text + remote |
+|------|----------------------|---------------|
+| doclib / `mineru parse` 单文件主动解析 | 报 `remote_unsupported_for_file_type` | 报 `parse_not_required` |
+| parsing-rule | 忽略 remote,按 `flash` | 只入库和索引 |
+| API Server job | 不适用;API Server 自身就是解析服务 | 不接受 text 作为解析输入 |
+| `mineru-kit parse` | 允许,作为低层工具特例 | 不接受 text 作为解析输入 |
doclib 单文件主动解析中,`remote=true` 表示用户显式要求把该文件交给 remote parse-server。因为 remote parse-server 只支持 PDF/image,该组合必须报错,不能静默改成本地 `flash`,否则会改变用户显式选择的执行路径和隐私语义。
-`mineru-kit parse` 是低层工具,允许 `--remote` 处理非 PDF/image 输入;当非 PDF/image 不能使用质量 tier 时,按批量归一规则处理。
+`mineru-kit parse` 是低层工具,允许 `--remote` 处理 Office/HTML;当这些输入不能使用质量 tier 时,按批量归一规则处理。text 不作为解析输入。
## 替代方案
-### 方案 A: Office/text/HTML 一律静默忽略 tier
+### 方案 A: Office/HTML 一律静默忽略 tier
未采用。
@@ -114,14 +118,14 @@ doclib 单文件主动解析中,`remote=true` 表示用户显式要求把该
- 静默忽略会让脚本和用户误以为质量 tier 已执行。
- doclib 的 parse row、缓存和 locator 应准确表达实际结果能力。
-### 方案 B: Office/text/HTML 一律遇到质量 tier 报错
+### 方案 B: Office/HTML 一律遇到质量 tier 报错
未采用。
原因:
- 批量任务经常包含混合文件类型。
-- parsing-rule 是后台批量策略,不应因为非 PDF/image 文件携带无效质量 tier 而阻断整个目录处理。
+- parsing-rule 是后台批量策略,不应因为 Office/HTML 携带无效质量 tier 而阻断整个目录处理。
- API Server v1 parse job 当前是多文件接口,也应支持异构输入。
### 方案 C: 为 API Server 增加 file-level effective tier 字段
@@ -138,31 +142,31 @@ doclib 单文件主动解析中,`remote=true` 表示用户显式要求把该
### 对 doclib
-- doclib 单文件主动解析保持严格语义: 非 PDF/image 显式质量 tier 报错。
-- 非 PDF/image 未指定 tier 或指定 `flash` 时,实际记录为 `flash`。
-- parsing-rule 触发非 PDF/image 时,实际 parse row 必须为 `flash`。
+- doclib 单文件主动解析保持严格语义: Office/HTML 显式质量 tier 报错;text 返回 `parse_not_required`。
+- Office/HTML 未指定 tier 或指定 `flash` 时,实际记录为 `flash`。
+- parsing-rule 触发 Office/HTML 时,实际 parse row 必须为 `flash`;text 只入库和索引。
- parsing-rule 对 PDF/image 未指定 tier 时,允许 `high -> xhigh -> medium -> flash` 兜底。
### 对 SDK 和 mineru-kit
-- SDK 单文件解析应按单对象主动操作语义处理。
+- SDK 单文件解析应按单对象主动操作语义处理,并排除 text 解析输入。
- `mineru-kit parse` 需要根据展开后的输入数量区分单对象和批量。
-- `mineru-kit parse --remote` 对非 PDF/image 是允许的低层工具特例。
+- `mineru-kit parse --remote` 对 Office/HTML 是允许的低层工具特例;text 不作为解析输入。
### 对 API Server
- API Server job 按批量操作语义处理。
-- 非 PDF/image 文件即使 job tier 是质量 tier,执行时也按 `flash` 语义。
+- Office/HTML 即使 job tier 是质量 tier,执行时也按 `flash` 语义;text 不进入 parse job。
- 暂不新增 file-level effective tier 字段。
### 对缓存和 locator
- 缓存键、parse row、locator 和产物 metadata 必须记录实际 tier。
-- 非 PDF/image 不应产生 `medium`、`high` 或 `xhigh` 缓存。
+- Office/HTML 不应产生 `medium`、`high` 或 `xhigh` 缓存;text 不应产生任何解析缓存。
## 后续动作
-1. 更新 doclib parsing-rule 入队逻辑,确保非 PDF/image 始终创建 `tier=flash` 的 parse row。
+1. 更新 doclib parsing-rule 入队逻辑,确保 Office/HTML 创建 `tier=flash` 的 parse row,text 不创建 parse row。
2. 更新 parsing-rule 的 PDF/image 默认 tier 选择顺序为 `high -> xhigh -> medium -> flash`。
3. 检查 SDK、mineru-kit 和 API Server,对单对象和批量操作分别应用本 ADR 的归一化规则。
4. 同步更新 CLI、SDK 和 API 文档,避免继续表述为“所有入口统一报错”或“所有入口统一静默降级”。
diff --git a/docs/next/errors.md b/docs/next/errors.md
index 83ba0d06..a9507476 100644
--- a/docs/next/errors.md
+++ b/docs/next/errors.md
@@ -21,7 +21,7 @@
- 错误格式兼容 OpenAI API。
- `message` 面向人类,`code`、`param`、`retryable` 和 `user_action` 面向程序。
- 不显式 `--remote` 时,不用错误恢复逻辑静默上传文档。
-- PDF/image 的默认选择策略不能降级为 `flash`;找不到非 `flash` 质量 tier 时必须报错。Office/text/HTML 这类仅支持 flash tier 的输入归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。
+- PDF/image 的默认选择策略不能降级为 `flash`;找不到非 `flash` 质量 tier 时必须报错。Office/HTML 这类仅支持 flash tier 的输入归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。文本文件无需解析,显式 parse 请求返回 `parse_not_required`。
- 未来新增 `code` 只能追加,不改变既有语义。
## 3. 错误响应格式
@@ -82,9 +82,10 @@ Tier 语义见 [解析 Tier](tiers.md)。本节定义 `flash`、`medium`、`high
| `timeout_error` | `parse_wait_timeout` | 408 | 是 | `wait` | CLI `parse --wait` 等待窗口到期,解析任务仍在运行 | `poll_parse_or_rerun_with_longer_wait` |
| `engine_error` | `parse_oom` | 500 | 是 | null | 本地显存或内存不足 | `use_lower_tier_or_remote` |
| `invalid_request_error` | `parse_server_model_not_ready` | 400 | 否 | `parse_server.local.mode` / `parse_server.local.managed_tier` | 配置 managed local parse-server 时,目标 tier 的本地模型文件未准备好 | `run_mineru_kit_models_download_for_tier` |
-| `invalid_request_error` | `remote_unsupported_for_file_type` | 400 | 否 | `remote` | 非 PDF/image 单文件主动解析请求 remote | `use_local_flash_or_choose_pdf_image` |
-| `invalid_request_error` | `tier_unsupported_for_file_type` | 400 | 否 | `tier` | 非 PDF/image 单文件主动解析显式请求质量 tier | `use_tier_flash_or_choose_pdf_image` |
+| `invalid_request_error` | `remote_unsupported_for_file_type` | 400 | 否 | `remote` | Office/HTML 单文件主动解析请求 remote | `use_local_flash_or_choose_pdf_image` |
+| `invalid_request_error` | `tier_unsupported_for_file_type` | 400 | 否 | `tier` | Office/HTML 单文件主动解析显式请求质量 tier | `use_tier_flash_or_choose_pdf_image` |
| `invalid_request_error` | `tier_unsupported_for_remote` | 400 | 否 | `tier` | PDF/image remote 解析显式请求 `flash` | `choose_remote_quality_tier_or_local_flash` |
+| `invalid_request_error` | `parse_not_required` | 400 | 否 | `path` / `doc_ref` / `locator` | 对文本文件请求解析、读取解析结果或作废解析结果 | `read_source_file_directly` |
关键约束:
diff --git a/docs/next/glossary.md b/docs/next/glossary.md
index 98676f1d..339ab1b2 100644
--- a/docs/next/glossary.md
+++ b/docs/next/glossary.md
@@ -59,7 +59,7 @@
- CLI/API/SDK 的用户可见参数应使用 `tier`。
- CLI 不传 `--tier`、HTTP API 省略 `tier` 或传 JSON `null`、Python SDK 传 `None` 表示使用默认选择策略。
- 任务入队、缓存目录、产物 metadata 应记录实际使用的实体 tier,即 `flash`、`medium`、`high` 或 `xhigh`。
-- PDF/image 的默认选择策略不能解析为 `flash`;Office/text/HTML 这类仅支持 flash tier 的输入归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。
+- PDF/image 的默认选择策略不能解析为 `flash`;Office/HTML 这类仅支持 flash tier 的输入归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md);text 直接读取。
完整产品语义见 [解析 Tier](tiers.md)。
diff --git a/docs/next/open-questions.md b/docs/next/open-questions.md
index c6d2b467..b3371e27 100644
--- a/docs/next/open-questions.md
+++ b/docs/next/open-questions.md
@@ -23,12 +23,12 @@
| 规则 | 当前结论 |
|------|----------|
| `parse-server` | 最终术语,中文为“解析服务”;此前误写的相关术语不作为项目概念使用。 |
-| 默认选择策略 | 以 [解析 Tier](tiers.md) 为准;PDF/image 默认读取不会解析为 `flash`,Office/text/HTML 归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。 |
+| 默认选择策略 | 以 [解析 Tier](tiers.md) 为准;PDF/image 默认读取不会解析为 `flash`,Office/HTML 归一规则见 [ADR-0024](decisions/0024-file-type-tier-normalization.md),text 直接读取。 |
| 实际 tier 记录 | 任务、缓存、产物和 metadata 只记录实际使用的实体 tier,不记录 `requested_tier` / `resolved_tier`。 |
| `flash` | 长期存在,既是一个解析档位,也是 PDF 快速解析 backend 名称。 |
| doclib 产物 | `parsed/` 目录持久化按页组织的 Middle JSON 批次文件和必要图片 sidecar;Markdown、Content List、HTML 读取时转换。 |
| 能力发现 | parse-server 的解析档位发现 endpoint 统一为 `GET /v1/tiers`。 |
-| 搜索结果 tier | search result 应以机器可读字段显式返回索引来源 tier。 |
+| 搜索结果 tier | search result 以机器可读字段返回解析索引来源 tier;直接索引的 text 源内容为 `null`。 |
| remote fallback | 用户显式允许 remote 后,remote 失败可以 fallback 到 local;local 失败不能自动扩大到 remote。 |
| SDK tier 参数 | 普通 parser 入口应支持 `tier` 语义;`backend` 只作为专家层或过渡参数暴露。 |
| 错误映射 | `quality_tier_unavailable` 应进入稳定错误体系。 |
@@ -50,8 +50,8 @@
| `mineru-kit` 参数稳定性 | 暂不划分 `stable` / `experimental` 等稳定性等级,先保持简单。 |
| `mineru-kit parse` 输入 | 当前只支持文件和目录输入;不支持 stdin、路径列表、URL 输入和递归目录。 |
| `mineru-kit parse` 输出 | `--output` 必填;单文件可输出到文件路径或目录路径;多文件只能输出到目录路径;同名冲突直接报错并终止整个批次。 |
-| `mineru-kit parse` local/remote | local 支持 `tier/backend` 并校验兼容,PDF/image 二者都不传时默认 `high`,Office/text/HTML 按 ADR-0024 归一;remote 支持 `--remote`/`--remote-url`/`--api-key`,允许传 `tier`,禁止传 `backend`。 |
-| parsing-rules 默认 tier | parsing-rules 允许不指定 tier;PDF/image 按 `high` -> `xhigh` -> `medium` -> `flash` 选择,Office/text/HTML 归一为 `flash`;只记录实际 tier。 |
+| `mineru-kit parse` local/remote | local 支持 `tier/backend` 并校验兼容,PDF/image 二者都不传时默认 `high`,Office/HTML 按 ADR-0024 归一,text 不作为解析输入;remote 支持 `--remote`/`--remote-url`/`--api-key`,允许传 `tier`,禁止传 `backend`。 |
+| parsing-rules 默认 tier | parsing-rules 允许不指定 tier;PDF/image 按 `high` -> `xhigh` -> `medium` -> `flash` 选择,Office/HTML 归一为 `flash`,text 只入库和索引;只记录实际 tier。 |
| Telemetry P0 | P0 必须实现 doclib server telemetry 状态、聚合、flush 和 CLI 管理入口;纯工具无 telemetry 能力。 |
| `mineru parse` 默认页码范围 | 分页文档默认解析和读取 `1~min(page_count,10)`;该默认由 doclib 读取/解析计划负责,CLI 参数层不硬编码默认 `--pages`。 |
| 渐进式阅读协议 | Server 返回结构化 `next_request`;CLI marker 只由 `next_request` 渲染,不作为协议源头,详见 [ADR-0013](decisions/0013-doc-content-progressive-reading.md)。 |
diff --git a/docs/next/sdk/doclib-client.md b/docs/next/sdk/doclib-client.md
index 08566a02..e283ba54 100644
--- a/docs/next/sdk/doclib-client.md
+++ b/docs/next/sdk/doclib-client.md
@@ -144,11 +144,11 @@ def info(self, file_path: str) -> dict: ...
| 方法 | 响应 |
|------|------|
-| `search()` | `SearchResponse`,包含全文结果、snippet、files、tier;支持 `file_type`、`tier`、`min_tier` 过滤。 |
+| `search()` | `SearchResponse`,包含全文结果、snippet、files、可空 tier;支持 `file_type`、`tier`、`min_tier` 过滤。 |
| `find()` | `FindResponse`,包含文件名搜索结果;支持 `ext` 过滤。 |
| `get_file_by_path()` | `FileInfoResponse`,包含文件元信息、doc metadata 和 parse tiers。 |
-`search()` 的 `files` 返回与文档 SHA 关联的全部 file aliases,按 file id 降序排列;每项包含 path、filename、ext 和 status。已索引的 orphan 文档使用空列表。active 优先只属于非 JSON CLI 展示策略,不改变 SDK 响应。搜索结果可信度只通过 `tier` 表达。
+`search()` 的 `files` 返回与文档 SHA 关联的全部 file aliases,按 file id 降序排列;每项包含 path、filename、ext 和 status。已索引的 orphan 文档使用空列表。active 优先只属于非 JSON CLI 展示策略,不改变 SDK 响应。解析内容的 `tier` 表示索引来源 tier;直接索引的 text 源内容为 `null`。传入 `tier` 或 `min_tier` 时,`tier=null` 的结果不参与匹配。
## Remote API 方法
diff --git a/docs/next/sdk/tiers-errors.md b/docs/next/sdk/tiers-errors.md
index 7e8e63b6..b8f91548 100644
--- a/docs/next/sdk/tiers-errors.md
+++ b/docs/next/sdk/tiers-errors.md
@@ -13,7 +13,7 @@ SDK 层必须使用与产品一致的 tier 语义。完整产品语义见 [解
SDK 中未指定 tier,或 Python 调用传 `tier=None` 时,必须遵循 [解析 Tier](../tiers.md) 和 [ADR-0024](../decisions/0024-file-type-tier-normalization.md) 中的默认选择策略。
-对 PDF/image,默认选择不能变成 `flash`。Office/text/HTML 没有质量 tier;单文件解析未指定 tier 时归一为 `flash`,显式传入 `medium`、`high` 或 `xhigh` 应报错。
+对 PDF/image,默认选择不能变成 `flash`。Office/HTML 没有质量 tier;单文件解析未指定 tier 时归一为 `flash`,显式传入 `medium`、`high` 或 `xhigh` 应报错。text 不作为解析输入,应直接读取。
## Tool SDK 的 tier 处理
@@ -33,7 +33,7 @@ SDK 中未指定 tier,或 Python 调用传 `tier=None` 时,必须遵循 [解
| `high` | hybrid 默认高质量 backend |
| `xhigh` | hybrid backend + 更高 effort |
-`tier=None` 使用默认选择策略。PDF/image 直接本地解析且没有能力列表时默认 `high`;有能力发现上下文时按 `high` -> `xhigh` -> `medium` 选择。Office/text/HTML 单文件解析未指定 tier 时归一为 `flash`。结果记录实际 tier,不能为仅支持 flash tier 的输入记录伪质量 tier。
+`tier=None` 使用默认选择策略。PDF/image 直接本地解析且没有能力列表时默认 `high`;有能力发现上下文时按 `high` -> `xhigh` -> `medium` 选择。Office/HTML 单文件解析未指定 tier 时归一为 `flash`。结果记录实际 tier,不能为仅支持 flash tier 的输入记录伪质量 tier。text 不产生解析结果。
## Doclib SDK 的 tier 处理
diff --git a/docs/next/tiers.md b/docs/next/tiers.md
index 0f25e0e6..4403b1d7 100644
--- a/docs/next/tiers.md
+++ b/docs/next/tiers.md
@@ -25,7 +25,7 @@ MinerU 当前定义四个公开 tier。文档中使用面向用户的显示名
- `flash` 用于发现、预览和建立搜索索引,不是 PDF/image 默认阅读质量。
- 当 Agent 或用户决定读取 PDF/image 文档时,如果没有指定 tier,默认选择不能解析为 `flash`;有能力发现上下文时优先使用 `high`。
-- 默认选择策略在 PDF/image 质量解析语境下不会等价于 `flash`;Office/text/HTML 这类仅支持 flash tier 的输入按 [ADR-0024](decisions/0024-file-type-tier-normalization.md) 归一为 `flash` 语义。
+- 默认选择策略在 PDF/image 质量解析语境下不会等价于 `flash`;Office/HTML 这类仅支持 flash tier 的输入按 [ADR-0024](decisions/0024-file-type-tier-normalization.md) 归一为 `flash` 语义;text 直接读取。
- `high` 是高质量 tier,也是 `mineru.net/api` 对外提供的解析层级。
- `xhigh` 是当前公开 tier 中质量和成本最高的档位。
- 本地运行 `high` 和 `xhigh` 是正式支持能力,不是实验能力;它们依赖 VLM 相关依赖、支持的本地加速器和足够的显存或统一内存。
@@ -50,7 +50,7 @@ MinerU 当前定义四个公开 tier。文档中使用面向用户的显示名
当用户没有指定 tier,或在 HTTP API 中显式传入 JSON `null` 时,MinerU 使用默认选择策略。Python SDK 中的等价表达是 `tier=None`。
-默认选择策略分两类场景。本节描述 PDF/image 质量解析的默认选择;Office/text/HTML 这类仅支持 flash tier 的输入见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。
+默认选择策略分两类场景。本节描述 PDF/image 质量解析的默认选择;Office/HTML 这类仅支持 flash tier 的输入见 [ADR-0024](decisions/0024-file-type-tier-normalization.md)。text 没有 tier,不进入解析。
### 3.1 无能力列表的场景
@@ -101,7 +101,7 @@ PDF/image 默认选择策略不会解析为 `flash`。如果系统找不到 `med
P0 不做基于启发式的自动提示或自动排队升级。watch 使用 `flash` 后,如果需要在后台自动解析到 `medium`、`high` 或 `xhigh`,必须来自用户显式配置的 parsing-rules;系统不根据文件名、内容特征、搜索命中或“高价值文档”判断自行升级。
-`flash` 不应被当成 PDF/image 默认阅读质量。当 Agent 或用户决定真正读取 PDF/image 文档时,需求已经从“发现它”变成“尽可能准确地理解它”,此时未指定 tier 应使用默认选择策略,并解析到可用的非 `flash` 质量 tier。Office/text/HTML 这类仅支持 flash tier 的输入没有质量 tier 分层,按 `flash` 语义处理。
+`flash` 不应被当成 PDF/image 默认阅读质量。当 Agent 或用户决定真正读取 PDF/image 文档时,需求已经从“发现它”变成“尽可能准确地理解它”,此时未指定 tier 应使用默认选择策略,并解析到可用的非 `flash` 质量 tier。Office/HTML 这类仅支持 flash tier 的输入没有质量 tier 分层,按 `flash` 语义处理。text 直接读取。
只有在用户明确指定 `flash` 时,才返回 `flash` 的解析内容作为最终阅读结果。
@@ -159,10 +159,10 @@ MinerU 的 tier 策略同时遵守隐私优先和质量优先。
|------|--------------|
| watch 自动发现文件 | 本地 `flash` |
| `mineru-kit api-server` 未传 `--tier` | 以 `high` 作为服务默认 tier |
-| `mineru-kit parse` local 模式未传 `--tier` / `--backend` | PDF/image 直接按 `high` 解析;Office/text/HTML 按 `flash` 语义处理 |
-| watch 命中 parsing-rule 且 rule 指定 tier | PDF/image 按 rule 中的 tier、页码范围和 remote 配置执行;Office/text/HTML 忽略 rule tier 和 remote,按 `flash` |
-| watch 命中 parsing-rule 但 rule 未指定 tier | PDF/image 按 `high` -> `xhigh` -> `medium` -> `flash` 选择;Office/text/HTML 按 `flash` |
-| 用户主动 parse,未指定 tier;HTTP API 传 JSON `null`;Python SDK 传 `None` | PDF/image 有能力发现上下文时按 `high` -> `xhigh` -> `medium` 选择;Office/text/HTML 按 [ADR-0024](decisions/0024-file-type-tier-normalization.md) 归一为 `flash` |
+| `mineru-kit parse` local 模式未传 `--tier` / `--backend` | PDF/image 直接按 `high` 解析;Office/HTML 按 `flash` 语义处理;text 不作为解析输入 |
+| watch 命中 parsing-rule 且 rule 指定 tier | PDF/image 按 rule 中的 tier、页码范围和 remote 配置执行;Office/HTML 忽略 rule tier 和 remote,按 `flash`;text 只入库和索引 |
+| watch 命中 parsing-rule 但 rule 未指定 tier | PDF/image 按 `high` -> `xhigh` -> `medium` -> `flash` 选择;Office/HTML 按 `flash`;text 只入库和索引 |
+| 用户主动 parse,未指定 tier;HTTP API 传 JSON `null`;Python SDK 传 `None` | PDF/image 有能力发现上下文时按 `high` -> `xhigh` -> `medium` 选择;Office/HTML 按 [ADR-0024](decisions/0024-file-type-tier-normalization.md) 归一为 `flash`;text 不进入解析 |
| 用户主动指定 `--tier flash` | 本地 `flash` |
| 用户主动指定 `--tier medium` | 本地 medium;不可用时报错 |
| 用户主动指定 `--tier high` | 本地 high;显式 remote 时使用 `mineru.net/api` high |
diff --git a/docs/next/workflows.md b/docs/next/workflows.md
index ee02023d..823e8b44 100644
--- a/docs/next/workflows.md
+++ b/docs/next/workflows.md
@@ -102,8 +102,8 @@ watch 的目标是发现文件、建立基础索引和支持后续搜索,不
| 场景 | 默认 tier |
|------|-----------|
| watch 自动发现 | `flash` |
-| parsing-rule 明确指定 | PDF/image 使用 rule 中的 tier;Office/text/HTML 归一为 `flash` |
-| parsing-rule 未指定 tier | PDF/image 按 `high` -> `xhigh` -> `medium` -> `flash`;Office/text/HTML 归一为 `flash` |
+| parsing-rule 明确指定 | PDF/image 使用 rule 中的 tier;Office/HTML 归一为 `flash`;text 只入库和索引 |
+| parsing-rule 未指定 tier | PDF/image 按 `high` -> `xhigh` -> `medium` -> `flash`;Office/HTML 归一为 `flash`;text 只入库和索引 |
### 5.3 步骤
@@ -280,7 +280,7 @@ client.parse("report.pdf")
### 6.2 默认目标
-主动读取 PDF/image 的目标是尽可能准确地理解文档。未指定 tier 时,使用默认选择策略,并解析到可用的非 `flash` 质量 tier。Office/text/HTML 没有质量 tier,未指定 tier 时归一为 `flash`。
+主动读取 PDF/image 的目标是尽可能准确地理解文档。未指定 tier 时,使用默认选择策略,并解析到可用的非 `flash` 质量 tier。Office/HTML 没有质量 tier,未指定 tier 时归一为 `flash`。text 应直接读取,不进入解析流程。
### 6.3 步骤
@@ -289,7 +289,7 @@ client.parse("report.pdf")
3. 如果文件尚未入库,先同步执行 ingest,得到 `sha256`。
4. 确定页码范围、输出格式、等待策略和隐私偏好。
5. 如果用户未指定 tier,使用默认选择策略。
-6. PDF/image 默认选择策略通过当前可用 parse-server 能力发现,按 `high` -> `xhigh` -> `medium` 选择;Office/text/HTML 归一为 `flash`。
+6. PDF/image 默认选择策略通过当前可用 parse-server 能力发现,按 `high` -> `xhigh` -> `medium` 选择;Office/HTML 归一为 `flash`;text 直接读取。
7. 将任务和缓存键落到实际使用的实体 tier。
8. 查询 `(sha256, tier, page_range)` 是否已有可复用结果。
9. 缓存命中则直接 render 并返回。
@@ -306,7 +306,7 @@ client.parse("report.pdf")
| 请求 | 实际行为 |
|------|----------|
-| 未指定 tier | PDF/image 按 `high` -> `xhigh` -> `medium` 选择可用的非 `flash` tier;Office/text/HTML 归一为 `flash` |
+| 未指定 tier | PDF/image 按 `high` -> `xhigh` -> `medium` 选择可用的非 `flash` tier;Office/HTML 归一为 `flash`;text 直接读取 |
| `tier=flash` | 显式使用本地 `flash` backend |
| `tier=medium` | 使用本地或自部署 parse-server 的 `medium` 能力 |
| `tier=high` | 使用本地 `high` 或 `mineru.net/api` 的 `high` 能力 |
@@ -358,10 +358,10 @@ watch -> flash index -> search result -> Agent chooses document -> mineru parse
1. Agent 调用 search。
2. doclib 查询内容索引;文件名查询由 find 负责。
-3. search result 返回完整 file aliases、sha256、snippet、当前索引来源 tier。
+3. search result 返回完整 file aliases、sha256、snippet 和可空的索引来源 tier;text 源内容的 tier 为 `null`。
4. Agent 选择具体文档。
5. Agent 发起主动 parse 请求。
-6. PDF/image 请求未指定 tier 时使用默认选择策略;Office/text/HTML 按 `flash` 语义处理。
+6. PDF/image 请求未指定 tier 时使用默认选择策略;Office/HTML 按 `flash` 语义处理;text 不发起 parse 请求。
7. doclib 检查是否已有可用质量 tier 缓存。
8. 如果没有,则创建高优先级 parse 任务。
9. 解析完成后返回可阅读输出,并写入更高质量索引。
@@ -398,7 +398,7 @@ marker 不应依赖自然语言提示。具体 marker 格式可在 CLI 或 Agent
1. 客户端创建 upload 或提供已有 `file_id`。
2. 客户端创建 parse job。
-3. 请求可以携带 `tier`;省略或传 JSON `null` 时,PDF/image 使用默认选择策略,Office/text/HTML 按批量规则归一为 `flash`。
+3. 请求可以携带 `tier`;省略或传 JSON `null` 时,PDF/image 使用默认选择策略,Office/HTML 按批量规则归一为 `flash`;text 不作为解析输入。
4. API service 做鉴权、配额和输入校验。
5. 调度到可用解析能力。
6. 解析服务生成 Middle JSON 和请求的输出格式。
diff --git a/mineru/doclib/core/fts.py b/mineru/doclib/core/fts.py
index 28e80e37..acde20d4 100644
--- a/mineru/doclib/core/fts.py
+++ b/mineru/doclib/core/fts.py
@@ -51,7 +51,7 @@ class FTSManager:
self,
*,
sha256: str,
- tier: Tier,
+ tier: Tier | None,
text: str,
title: str,
author: str,
@@ -90,7 +90,7 @@ class FTSManager:
async def get_tier(self, sha256: str) -> Tier | None:
row = await self.db.fetchone("SELECT tier FROM fts_contents WHERE sha256=?", (sha256,))
- return cast(Tier, row["tier"]) if row else None
+ return cast(Tier | None, row["tier"]) if row else None
async def delete(self, sha256: str) -> None:
await self.db.execute("DELETE FROM fts_contents WHERE sha256=?", (sha256,))
diff --git a/mineru/doclib/rows.py b/mineru/doclib/rows.py
index 74ee41be..84f39afd 100644
--- a/mineru/doclib/rows.py
+++ b/mineru/doclib/rows.py
@@ -186,7 +186,7 @@ class FtsContentSearchRow(TypedDict):
sha256: str
title: str
author: str
- tier: Tier
+ tier: Tier | None
snippet: str
rank: float
@@ -216,7 +216,7 @@ class ContentSearchResultRow(TypedDict):
author: str | None
size_bytes: int
page_count: int | None
- tier: Tier
+ tier: Tier | None
snippet: str
files: list[SearchResultFileRow]
diff --git a/mineru/doclib/server.py b/mineru/doclib/server.py
index 8cd2eec7..8f051795 100644
--- a/mineru/doclib/server.py
+++ b/mineru/doclib/server.py
@@ -21,6 +21,7 @@ from pydantic import ValidationError
from ..config import config
from ..errors import InvalidRequestError, MineruError, NotFoundError, error_response, http_status_for
+from ..filetypes import TEXT_EXTENSIONS, TEXT_FILE_TYPES
from ..parser.tier import TierDependencyError, ensure_tier_runtime_dependencies
from ..render import render_markdown
from ..render.markdown import blocks_to_markdown
@@ -403,12 +404,21 @@ class DoclibServer(AsyncDoclibInterface):
if request.target != "parses":
raise InvalidRequestError("invalid_request", f"Unsupported invalidate target: {request.target}", "target")
doc_row = await self._doc_for_ref(request.doc_ref, param="doc_ref") if request.doc_ref else None
+ file_row: FileRow | None = None
sha256 = doc_row["sha256"] if doc_row else None
if sha256 is None and request.path:
file_row = await self.state.parse_svc.ensure_ingested(request.path)
sha256 = file_row["sha256"] if file_row and file_row.get("sha256") else None
if sha256 is None:
raise NotFoundError("file_not_found", "Document not found.", "path")
+ if (file_row and file_row["ext"] in TEXT_EXTENSIONS) or (
+ doc_row and doc_row["file_type"] in TEXT_FILE_TYPES
+ ):
+ raise InvalidRequestError(
+ "parse_not_required",
+ "Text files do not require MinerU parsing. Read the file directly.",
+ "doc_ref" if doc_row else "path",
+ )
short_id = doc_row["short_id"] if doc_row else await self._short_id_for_sha256(sha256)
count = await self.state.parse_svc.invalidate(sha256, request.tier)
@@ -662,6 +672,12 @@ class DoclibServer(AsyncDoclibInterface):
doc = cast(DocRow | None, await self.state.db.fetchone("SELECT * FROM docs WHERE short_id=?", (cursor.short_id,)))
if doc is None:
raise NotFoundError("doc_not_found", f"Document {cursor.short_id} not found.", "locator")
+ if doc["file_type"] in TEXT_FILE_TYPES:
+ raise InvalidRequestError(
+ "parse_not_required",
+ "Text files do not require MinerU parsing. Read the file directly.",
+ "locator",
+ )
tier = cursor.tier or await self._default_read_tier(doc["sha256"])
if tier is None:
@@ -748,9 +764,7 @@ class DoclibServer(AsyncDoclibInterface):
limit=limit,
offset=offset,
)
- response = SearchResponse(
- results=[_search_result(row) for row in results if row.get("tier") in TIERS], total=total, query=query
- )
+ response = SearchResponse(results=[_search_result(row) for row in results], total=total, query=query)
dims = {"status": "succeeded"}
await _record_telemetry_count(self.state, "search.finished.count", dimensions=dims)
await _record_telemetry_duration(self.state, "search.duration_bucket.count", start_ms, dimensions=dims)
@@ -2315,9 +2329,7 @@ def _parsing_rule_info(row: ParsingRuleRow | None) -> ParsingRuleInfo:
def _search_result(row: ContentSearchResultRow) -> SearchResult:
- data = dict(row)
- data["tier"] = cast(Tier, data["tier"])
- return SearchResult.model_validate(data)
+ return SearchResult.model_validate(row)
def _find_result(row: FilenameSearchResultRow) -> FindResult:
diff --git a/mineru/doclib/services/parse_svc.py b/mineru/doclib/services/parse_svc.py
index 851fc097..733c3999 100644
--- a/mineru/doclib/services/parse_svc.py
+++ b/mineru/doclib/services/parse_svc.py
@@ -641,7 +641,7 @@ class ParseService:
text = await asyncio.to_thread(Path(path).read_text, encoding="utf-8", errors="replace")
await self.fts.replace(
sha256=sha256,
- tier="flash",
+ tier=None,
text=truncate_head_tail(text),
title=metadata["title"] or "",
author=metadata["author"] or "",
@@ -725,6 +725,12 @@ class ParseService:
ext = file_row["ext"]
# ── resolve tier (before cache check) ──
+ if ext in TEXT_EXTENSIONS:
+ raise InvalidRequestError(
+ "parse_not_required",
+ "Text files do not require MinerU parsing. Read the file directly.",
+ "path",
+ )
if remote and ext not in TIERED_PARSE_EXTENSIONS:
raise InvalidRequestError(
"remote_unsupported_for_file_type",
@@ -743,8 +749,6 @@ class ParseService:
f"Tier '{tier}' is only supported for PDF and image files; '{ext}' files use --tier flash.",
"tier",
)
- if ext in TEXT_EXTENSIONS:
- return _text_response(sha256, short_id)
if ext in TIERED_PARSE_EXTENSIONS:
requested_tier = tier or _resolve_default_tier(remote)
else:
@@ -1522,21 +1526,6 @@ def _done_response(sha256: str, short_id: str | None, tier: Tier, page_range: st
)
-def _text_response(sha256: str, short_id: str | None) -> ParseResponse:
- return ParseResponse(
- sha256=sha256,
- short_id=short_id,
- tier="flash",
- page_range="1",
- status=PARSE_STATUS_DONE,
- cache_hit=False,
- wait_parse_ids=[],
- created_parse_ids=[],
- reused_parse_ids=[],
- tip="Plain text files do not require parsing.",
- )
-
-
def _parse_record_response(row: ParseRow) -> dict:
error = None
if row.get("error_code") or row.get("error_msg"):
diff --git a/mineru/doclib/services/search_svc.py b/mineru/doclib/services/search_svc.py
index c2692090..c099fd5a 100644
--- a/mineru/doclib/services/search_svc.py
+++ b/mineru/doclib/services/search_svc.py
@@ -189,6 +189,8 @@ class SearchService:
def _matches_tier(value: object, *, tier: Tier | None, min_tier: Tier | None) -> bool:
+ if value is None:
+ return tier is None and min_tier is None
if not isinstance(value, str) or value not in TIER_ORDER:
return False
if tier is not None and value != tier:
diff --git a/mineru/doclib/types.py b/mineru/doclib/types.py
index 395837ff..d904084b 100644
--- a/mineru/doclib/types.py
+++ b/mineru/doclib/types.py
@@ -333,7 +333,7 @@ class SearchResult(DoclibModel):
author: str | None = None
size_bytes: int | None = None
page_count: int | None = None
- tier: Tier
+ tier: Tier | None = None
snippet: str
files: list[SearchFile] = Field(default_factory=list)
diff --git a/mineru/errors.py b/mineru/errors.py
index 11bcb438..5abd0639 100644
--- a/mineru/errors.py
+++ b/mineru/errors.py
@@ -23,6 +23,7 @@ _ERROR_TYPE_MAP: dict[str, ErrorType] = {
"unsupported_source": "invalid_request_error",
"page_range_invalid": "invalid_request_error",
"file_type_unsupported": "invalid_request_error",
+ "parse_not_required": "invalid_request_error",
"file_encrypted": "invalid_request_error",
"file_corrupted": "invalid_request_error",
"file_too_large": "invalid_request_error",
diff --git a/mineru/filetypes.py b/mineru/filetypes.py
index de5e74db..984ae342 100644
--- a/mineru/filetypes.py
+++ b/mineru/filetypes.py
@@ -58,6 +58,8 @@ FILE_TYPE_BY_EXTENSION: dict[str, str] = {
"tex": "tex",
}
+TEXT_FILE_TYPES: frozenset[str] = frozenset(FILE_TYPE_BY_EXTENSION[ext] for ext in TEXT_EXTENSIONS)
+
MIME_TYPE_BY_EXTENSION: dict[str, str] = {
"pdf": "application/pdf",
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
diff --git a/skills/mineru/SKILL.md b/skills/mineru/SKILL.md
index 0a19d392..f250c88c 100644
--- a/skills/mineru/SKILL.md
+++ b/skills/mineru/SKILL.md
@@ -44,6 +44,8 @@ Use MinerU for local document files such as:
| PowerPoint | `.pptx` |
| Excel | `.xlsx` |
+Read `.txt`, `.md`, `.markdown`, `.csv`, `.rst`, and `.tex` files directly. Do not run `mineru parse` for these plain-text formats.
+
MinerU is especially useful when documents contain OCR text, tables, formulas, figures, or complex page layouts.
## Do Not
@@ -64,7 +66,7 @@ MinerU is especially useful when documents contain OCR text, tables, formulas, f
Use this decision tree before running commands:
-1. User provided a file path and wants content: run `mineru parse <file>`.
+1. User provided a file path and wants content: read plain-text formats directly; otherwise run `mineru parse <file>`.
2. User provided a `doc:...` locator: run `mineru read <locator>`.
3. User asks to continue from a previous output: follow the `<!-- Next: ... -->` command exactly.
4. User asks for a specific page or block after parsing: use `mineru read <locator>`, not a fresh parse.
@@ -803,6 +805,7 @@ Use this table for common error codes:
| `file_encrypted` | Password-protected file | Ask user for an unlocked copy |
| `file_corrupted` | File cannot be read | Ask for a valid copy |
| `page_range_invalid` | Bad `--pages` value | Correct to forms such as `1~5`, `1,3,8~10`, or `all` |
+| `parse_not_required` | The input is a directly readable text file | Read the source file directly; do not retry `mineru parse` |
| `not_cached` / `cache_miss` | Requested cached content does not exist | Run `mineru parse` |
Retry rules:
diff --git a/tests/unittest/test_cli_next_command_design.py b/tests/unittest/test_cli_next_command_design.py
index bec6fe99..76acd25f 100644
--- a/tests/unittest/test_cli_next_command_design.py
+++ b/tests/unittest/test_cli_next_command_design.py
@@ -250,6 +250,28 @@ def test_search_results_render_as_list_without_table() -> None:
assert "Snippet:" not in rendered
+def test_search_text_result_omits_tier_label() -> None:
+ rendered = search_mod._render_search_results(
+ SearchResponse(
+ total=1,
+ query="python",
+ results=[
+ SearchResult(
+ sha256="a" * 64,
+ short_id="aaaaaaa",
+ tier=None,
+ snippet="Python notes",
+ files=[SearchFile(path="/tmp/notes.txt", filename="notes.txt", ext="txt", status="active")],
+ )
+ ],
+ )
+ )
+
+ assert "1. Document aaaaaaa" in rendered
+ assert "Tier:" not in rendered
+ assert "/tmp/notes.txt" in rendered
+
+
def test_search_result_snippet_preserves_fts_match_after_long_prefix() -> None:
rendered = search_mod._render_search_results(
SearchResponse(
@@ -1568,6 +1590,40 @@ def test_parse_json_error_output_is_machine_readable(monkeypatch: Any, tmp_path:
assert "No medium, high, or xhigh engine available" in payload["error"]["message"]
[email protected]("json_mode", [False, True])
+def test_parse_text_file_reports_parse_not_required(monkeypatch: Any, tmp_path: Path, json_mode: bool) -> None:
+ source = tmp_path / "demo.txt"
+ source.write_text("hello", encoding="utf-8")
+
+ class _Client:
+ def __init__(self, *, timeout: int) -> None:
+ assert timeout == 90
+
+ def ensure_parse(self, request: Any) -> ParseResponse:
+ assert request.path == str(source.resolve())
+ raise RuntimeError(
+ "('parse_not_required', 'Text files do not require MinerU parsing. Read the file directly.', 'path')"
+ )
+
+ monkeypatch.setattr(parse, "DoclibClient", _Client)
+ args = ["parse", str(source)]
+ if json_mode:
+ args.append("--json")
+
+ result = runner.invoke(app, args)
+
+ assert result.exit_code == 1
+ if json_mode:
+ payload = json.loads(result.output)
+ assert payload["error"]["type"] == "invalid_request_error"
+ assert payload["error"]["code"] == "parse_not_required"
+ assert payload["error"]["param"] == "path"
+ assert payload["error"]["message"].endswith("Read the file directly.")
+ else:
+ assert "Text files do not require MinerU parsing. Read the file directly." in result.output
+ assert "('parse_not_required'" not in result.output
+
+
def test_parse_invalid_after_cursor_json_error_is_validation_error(monkeypatch: Any, tmp_path: Path) -> None:
source = tmp_path / "demo.pdf"
source.write_bytes(b"%PDF-1.7\n")
@@ -1927,6 +1983,29 @@ def test_invalidate_non_json_prints_message_not_error_tuple(monkeypatch: Any, tm
assert "('not_cached'" not in result.output
+def test_invalidate_text_file_reports_parse_not_required(monkeypatch: Any, tmp_path: Path) -> None:
+ source = tmp_path / "demo.txt"
+ source.write_text("hello", encoding="utf-8")
+
+ class _Client:
+ def __init__(self, *, timeout: int) -> None:
+ assert timeout == 10
+
+ def invalidate(self, request: Any) -> None:
+ assert request.path == str(source.resolve())
+ raise RuntimeError(
+ "('parse_not_required', 'Text files do not require MinerU parsing. Read the file directly.', 'path')"
+ )
+
+ monkeypatch.setattr(invalidate, "DoclibClient", _Client)
+
+ result = runner.invoke(app, ["invalidate", str(source)])
+
+ assert result.exit_code == 1
+ assert "Text files do not require MinerU parsing. Read the file directly." in result.output
+ assert "('parse_not_required'" not in result.output
+
+
def test_show_doc_expands_files(monkeypatch: Any) -> None:
calls: list[tuple[str, bool]] = []
@@ -2245,6 +2324,36 @@ def test_read_json_error_output_is_machine_readable(monkeypatch: Any) -> None:
assert "Error:" not in result.output
[email protected]("json_mode", [False, True])
+def test_read_text_locator_reports_parse_not_required(monkeypatch: Any, json_mode: bool) -> None:
+ class _Client:
+ def __init__(self, *, timeout: int) -> None:
+ assert timeout == 60
+
+ def read_content(self, locator: str, **kwargs: Any) -> DocContentResponse:
+ assert locator == "doc:ab12cd3/tier:flash"
+ raise RuntimeError(
+ "('parse_not_required', 'Text files do not require MinerU parsing. Read the file directly.', 'locator')"
+ )
+
+ monkeypatch.setattr(read, "DoclibClient", _Client)
+ args = ["read", "doc:ab12cd3/tier:flash"]
+ if json_mode:
+ args.append("--json")
+
+ result = runner.invoke(app, args)
+
+ assert result.exit_code == 1
+ if json_mode:
+ payload = json.loads(result.output)
+ assert payload["error"]["type"] == "invalid_request_error"
+ assert payload["error"]["code"] == "parse_not_required"
+ assert payload["error"]["param"] == "locator"
+ else:
+ assert "Text files do not require MinerU parsing. Read the file directly." in result.output
+ assert "('parse_not_required'" not in result.output
+
+
def test_read_json_output_writes_markdown_file_and_returns_output_object(monkeypatch: Any, tmp_path: Path) -> None:
output = tmp_path / "nested" / "read.md"
diff --git a/tests/unittest/test_doclib_cache_semantics.py b/tests/unittest/test_doclib_cache_semantics.py
index 2d095f01..a213acef 100644
--- a/tests/unittest/test_doclib_cache_semantics.py
+++ b/tests/unittest/test_doclib_cache_semantics.py
@@ -55,6 +55,7 @@ from mineru.doclib.services.scan_svc import ScanService
from mineru.doclib.services.search_svc import SearchService
from mineru.doclib.types import DocContentExportRequest, FileInfo, InvalidateRequest, ParseResponse, WatchRequest
from mineru.errors import InvalidRequestError, MineruError, NotFoundError
+from mineru.filetypes import file_type_for_extension
from mineru.parser import backend_for_tier, resolve_tier_and_backend
from mineru.parser.api_client import _APITransportError, _V1APIError
from mineru.parser.base import ParseResult
@@ -1224,7 +1225,7 @@ def test_request_parse_explicit_image_ingests_and_queues_parse(tmp_path: Path, m
asyncio.run(_run())
[email protected]("ext", ["txt", "html", "docx", "pptx", "xlsx"])
[email protected]("ext", ["html", "docx", "pptx", "xlsx"])
@pytest.mark.parametrize("tier", ["high", "xhigh"])
def test_request_parse_rejects_quality_tiers_for_non_pdf_image_inputs(
tmp_path: Path,
@@ -1324,7 +1325,7 @@ def test_refresh_file_applies_parsing_rule_effective_tier_and_privacy(
asyncio.run(_run())
[email protected]("ext", ["txt", "html", "docx", "pptx", "xlsx"])
[email protected]("ext", ["html", "docx", "pptx", "xlsx"])
def test_request_parse_rejects_remote_for_non_pdf_image_inputs(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
@@ -1369,6 +1370,68 @@ def test_request_parse_rejects_remote_for_non_pdf_image_inputs(
asyncio.run(_run())
[email protected]("ext", ["txt", "md", "markdown", "csv", "rst", "tex"])
+ ("tier", "force", "remote"),
+ [
+ (None, False, False),
+ ("flash", True, False),
+ ("high", False, False),
+ (None, False, True),
+ ],
+)
+def test_request_parse_reports_text_files_do_not_require_parsing(
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+ ext: str,
+ tier: Tier | None,
+ force: bool,
+ remote: bool,
+) -> None:
+ class _NoRulesConfig:
+ async def match_rules(self, path: str, rule_type: str) -> list[dict[str, Any]]:
+ return []
+
+ async def _run() -> None:
+ db = DatabaseManager(str(tmp_path / "doclib.db"))
+ await db.initialize()
+ fts = FTSManager(db)
+ service = ParseService(
+ db=db,
+ fts=fts,
+ config_svc=_NoRulesConfig(),
+ data_dir=str(tmp_path / "data"),
+ parse_lock_timeout_sec=1800,
+ )
+ source = tmp_path / f"sample.{ext}"
+ source.write_text("unique searchable content", encoding="utf-8")
+
+ async def _metadata(path: str) -> dict[str, Any]:
+ return {
+ "page_count": 1,
+ "title": None,
+ "author": None,
+ "subject": None,
+ "keywords": None,
+ "is_image_based": 0,
+ }
+
+ monkeypatch.setattr(parse_svc_module, "extract_metadata", _metadata)
+
+ with pytest.raises(InvalidRequestError) as exc_info:
+ await service.request_parse(str(source), tier=tier, force=force, remote=remote)
+
+ assert exc_info.value.code == "parse_not_required"
+ assert exc_info.value.param == "path"
+ assert "Read the file directly" in exc_info.value.message
+ file_row = await db.fetchone("SELECT sha256 FROM files WHERE path=?", (str(source),))
+ assert file_row is not None
+ assert await db.fetchall("SELECT id FROM parses WHERE sha256=?", (file_row["sha256"],)) == []
+ assert await fts.search("searchable")
+
+ asyncio.run(_run())
+
+
@pytest.mark.parametrize("ext", ["pdf", "png"])
def test_request_parse_rejects_flash_tier_for_remote_quality_inputs(
tmp_path: Path,
@@ -1738,7 +1801,7 @@ def test_ensure_ingested_rebinds_changed_text_file_to_new_sha(tmp_path: Path) ->
assert second is not None
assert second["sha256"] == hashlib.sha256(b"new content").hexdigest()
fts_row = await db.fetchone("SELECT sha256, tier FROM fts_contents WHERE sha256=?", (second["sha256"],))
- assert fts_row == {"sha256": second["sha256"], "tier": "flash"}
+ assert fts_row == {"sha256": second["sha256"], "tier": None}
asyncio.run(_run())
@@ -2043,6 +2106,7 @@ def test_search_filters_by_tier_min_tier_and_file_type(tmp_path: Path) -> None:
("2" * 64, "high", "pdf", "high.pdf", 12),
("3" * 64, "flash", "docx", "flash.docx", 23),
("4" * 64, "xhigh", "pdf", "xhigh.pdf", 34),
+ ("5" * 64, None, "text", "note.txt", 1),
]
for sha256, tier, file_type, filename, page_count in docs:
@@ -2058,20 +2122,32 @@ def test_search_filters_by_tier_min_tier_and_file_type(tmp_path: Path) -> None:
)
await fts.replace(sha256=sha256, tier=tier, text="needle content", title="", author="")
+ all_results, all_total = await service.search("needle")
exact_results, exact_total = await service.search("needle", tier="high")
+ flash_results, flash_total = await service.search("needle", tier="flash")
min_results, min_total = await service.search("needle", min_tier="high")
+ min_flash_results, min_flash_total = await service.search("needle", min_tier="flash")
type_results, type_total = await service.search("needle", file_type="docx")
+ text_results, text_total = await service.search("needle", file_type="text")
+ assert all_total == 5
+ assert {row["tier"] for row in all_results} == {None, "flash", "high", "xhigh"}
assert exact_total == 1
assert [row["tier"] for row in exact_results] == ["high"]
assert [row["short_id"] for row in exact_results] == ["2" * 7]
assert [row["page_count"] for row in exact_results] == [12]
+ assert flash_total == 2
+ assert {row["short_id"] for row in flash_results} == {"1" * 7, "3" * 7}
assert min_total == 2
assert {row["tier"] for row in min_results} == {"high", "xhigh"}
+ assert min_flash_total == 4
+ assert None not in {row["tier"] for row in min_flash_results}
assert type_total == 1
assert [[file["filename"] for file in row["files"]] for row in type_results] == [["flash.docx"]]
assert [row["short_id"] for row in type_results] == ["3" * 7]
assert [row["page_count"] for row in type_results] == [23]
+ assert text_total == 1
+ assert [row["tier"] for row in text_results] == [None]
asyncio.run(_run())
@@ -2990,6 +3066,62 @@ def test_doclib_server_accepts_short_id_for_sha256_doc_inputs(tmp_path: Path) ->
asyncio.run(_run())
[email protected]("ext", ["txt", "md", "markdown", "csv", "rst", "tex"])
+def test_doclib_server_reports_text_invalidation_not_required(
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+ ext: str,
+) -> None:
+ async def _run() -> None:
+ db = DatabaseManager(str(tmp_path / "doclib.db"))
+ await db.initialize()
+ fts = FTSManager(db)
+ parse_svc = ParseService(
+ db=db,
+ fts=fts,
+ config_svc=ConfigService(db),
+ data_dir=str(tmp_path / "data"),
+ parse_lock_timeout_sec=1800,
+ )
+ server = DoclibServer(SimpleNamespace(db=db, data_dir=str(tmp_path), parse_svc=parse_svc))
+ source = tmp_path / f"note.{ext}"
+ source.write_text("unique searchable content", encoding="utf-8")
+
+ async def _metadata(path: str) -> dict[str, Any]:
+ return {
+ "page_count": 1,
+ "title": None,
+ "author": None,
+ "subject": None,
+ "keywords": None,
+ "is_image_based": 0,
+ }
+
+ monkeypatch.setattr(parse_svc_module, "extract_metadata", _metadata)
+
+ with pytest.raises(InvalidRequestError) as exc_info:
+ await server.invalidate(InvalidateRequest(path=str(source)))
+
+ assert exc_info.value.code == "parse_not_required"
+ assert exc_info.value.param == "path"
+ assert "Read the file directly" in exc_info.value.message
+ file_row = await db.fetchone("SELECT sha256 FROM files WHERE path=?", (str(source),))
+ assert file_row is not None
+ doc_row = await db.fetchone("SELECT short_id FROM docs WHERE sha256=?", (file_row["sha256"],))
+ assert doc_row is not None
+
+ with pytest.raises(InvalidRequestError) as doc_ref_exc_info:
+ await server.invalidate(InvalidateRequest(doc_ref=doc_row["short_id"]))
+
+ assert doc_ref_exc_info.value.code == "parse_not_required"
+ assert doc_ref_exc_info.value.param == "doc_ref"
+ assert "Read the file directly" in doc_ref_exc_info.value.message
+ assert await db.fetchall("SELECT id FROM parses WHERE sha256=?", (file_row["sha256"],)) == []
+ assert await fts.search("searchable")
+
+ asyncio.run(_run())
+
+
def test_doc_content_invalid_after_cursor_returns_invalid_locator(tmp_path: Path) -> None:
async def _run() -> None:
db = DatabaseManager(str(tmp_path / "doclib.sqlite"))
@@ -3016,6 +3148,34 @@ def test_doc_content_invalid_after_cursor_returns_invalid_locator(tmp_path: Path
asyncio.run(_run())
[email protected]("ext", ["txt", "md", "markdown", "csv", "rst", "tex"])
+def test_read_text_locator_reports_parse_not_required(tmp_path: Path, ext: str) -> None:
+ async def _run() -> None:
+ db = DatabaseManager(str(tmp_path / "doclib.sqlite"))
+ await db.initialize()
+ server = DoclibServer(SimpleNamespace(db=db, data_dir=str(tmp_path)))
+ now = 1000
+ sha256 = "a" * 64
+ short_id = "aaaaaaa"
+ await db.execute(
+ "INSERT INTO docs (sha256, short_id, size_bytes, file_type, page_count, first_seen_at, updated_at) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?)",
+ (sha256, short_id, 12, file_type_for_extension(ext), 1, now, now),
+ )
+ try:
+ for locator in (f"doc:{short_id}", f"doc:{short_id}/tier:flash/page:1"):
+ with pytest.raises(InvalidRequestError) as exc_info:
+ await server.read_content(locator)
+
+ assert exc_info.value.code == "parse_not_required"
+ assert exc_info.value.param == "locator"
+ assert "Read the file directly" in exc_info.value.message
+ finally:
+ await db.close()
+
+ asyncio.run(_run())
+
+
def test_read_locator_out_of_range_page_returns_page_range_invalid(tmp_path: Path) -> None:
async def _run() -> None:
db = DatabaseManager(str(tmp_path / "doclib.sqlite"))
diff --git a/tests/unittest/test_errors.py b/tests/unittest/test_errors.py
index f8a2eac2..16f1498e 100644
--- a/tests/unittest/test_errors.py
+++ b/tests/unittest/test_errors.py
@@ -34,6 +34,7 @@ DOCLIB_CONTRACT_ERROR_CODES = {
"no_engine",
"not_cached",
"page_not_cached",
+ "parse_not_required",
"parse_page_remap_failed",
"parse_server_model_not_ready",
"parse_server_unavailable",
@@ -64,6 +65,7 @@ def test_doclib_error_code_types_are_stable() -> None:
assert error_type_for("invalid_config_key") == "invalid_request_error"
assert error_type_for("invalid_locator") == "invalid_request_error"
assert error_type_for("multi_page_image_not_supported") == "invalid_request_error"
+ assert error_type_for("parse_not_required") == "invalid_request_error"
assert error_type_for("parse_empty") == "engine_error"
assert error_type_for("parse_failed") == "engine_error"
@@ -81,6 +83,7 @@ def test_doclib_error_code_types_are_stable() -> None:
def test_http_status_for_error_codes_is_stable() -> None:
assert http_status_for("invalid_request") == 400
+ assert http_status_for("parse_not_required") == 400
assert http_status_for("file_not_found") == 404
assert http_status_for("asset_not_available") == 404
assert http_status_for("block_not_found") == 404