Skip to content

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

Add MinerU version compatibility guidance

jinzhenj049609adbdee
diff --git a/README.md b/README.md
index 104d9cff..bcc0c1d0 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ The current MinerU release line is in Alpha pre-release. Package installers norm
Copy the following message and send it to your agent:
```text
-Install the MinerU Skill globally for me. First run `npx skills add "opendatalab/MinerU#next" --global --yes`. If `npx` is unavailable, fetch https://raw.githubusercontent.com/opendatalab/MinerU/next/README.md, use its content as `mineru/SKILL.md`, and save it under the appropriate global skills directory for the current agent, not inside the current project. If global memory is available, record this preference globally: "Whenever a PDF, image, or Office document needs to be read or parsed, prefer the `mineru` Skill." Do not write this preference into the current project.
+Install or update the global `mineru` Skill. First, run `npx skills add "opendatalab/MinerU#next" --skill mineru --global --yes`. If `npx` is unavailable, fetch https://raw.githubusercontent.com/opendatalab/MinerU/next/README.md, use its content as `mineru/SKILL.md`, and save it under the appropriate global skills directory for the current agent, not in the current project. Also check both global and project-level skills for other installed skills whose names contain `mineru`. Report any matches and ask before removing them. If global memory is available, record this preference there: "Whenever a PDF, image, or Office document needs to be read or parsed, prefer the `mineru` Skill." Do not write this preference to the current project.
```
## When To Use MinerU
@@ -83,6 +83,7 @@ Use this decision tree before running commands:
8. User asks to add or refresh a watched folder: use `mineru watch` or `mineru scan`.
9. User asks MinerU to forget a file or folder without deleting it: use `mineru forget`.
10. User asks to force a reparse: use `mineru parse --force` or `mineru invalidate`.
+11. User asks for Remote API usage or limits: use `mineru usage --json`.
## Common Workflows
@@ -119,16 +120,36 @@ mineru read "doc:ab12cd3/tier:high/page:18" --json
## Installation And Setup
-Always check whether `mineru` is already available before installing.
+This skill requires MinerU `4.0.0` or later (`4.0.0a1` or later during the prerelease period). Before using any workflow, check whether the CLI is installed:
```bash
command -v mineru
-mineru --help
```
-If `mineru` is not installed, install it with the first available isolated CLI installer.
+If `mineru` is not installed, install it with the first available isolated CLI installer. If it is installed, check its version:
+
+```bash
+mineru version --json
+```
+
+If `mineru version --json` fails, try `mineru --version` for older CLIs. If the detected version does not meet this requirement, tell the user which version was found and ask before upgrading it. If approved, upgrade with the same installer and environment, then check the version again. If declined, stop and do not run this skill's commands. Never assume compatibility when the version cannot be determined.
+
MinerU requires Python `>=3.10,<3.14`.
+### Upgrade An Existing Installation
+
+Before upgrading, determine which tool owns the resolved `mineru` executable. Check `uv tool list`, then `pipx list --short`; otherwise, identify the Python environment containing the executable. Do not use an unrelated `pip` or install a second copy.
+
+Use the matching upgrade command only after the user approves the upgrade:
+
+```bash
+uv tool upgrade --prerelease allow mineru
+pipx upgrade mineru --pip-args="--pre"
+"<environment-python>" -m pip install --upgrade --pre mineru
+```
+
+If the owner cannot be determined, multiple installations exist, or MinerU is installed from source or in editable mode, ask the user instead of upgrading. After upgrading, check the resolved executable and its version again.
+
### Install with `uv` (preferred)
If `uv` is available, use any supported Python version for the tool environment.
diff --git a/mineru/cli/main.py b/mineru/cli/main.py
index fd0d8983..8aa6aec8 100644
--- a/mineru/cli/main.py
+++ b/mineru/cli/main.py
@@ -69,8 +69,24 @@ app = typer.Typer(
)
+def _show_version(ctx: typer.Context, value: bool) -> None:
+ if not value:
+ return
+ typer.echo(_render_version(_version_info()))
+ ctx.exit()
+
+
@app.callback()
-def root(ctx: typer.Context) -> None:
+def root(
+ ctx: typer.Context,
+ _version_requested: bool = typer.Option(
+ False,
+ "--version",
+ callback=_show_version,
+ is_eager=True,
+ help="Show the version and exit.",
+ ),
+) -> None:
prepare_cli_telemetry(ctx)
diff --git a/skills/mineru/SKILL.md b/skills/mineru/SKILL.md
index 1f7bfb24..300e86d0 100644
--- a/skills/mineru/SKILL.md
+++ b/skills/mineru/SKILL.md
@@ -48,8 +48,6 @@ MinerU is especially useful when documents contain OCR text, tables, formulas, f
## Do Not
-Do not:
-
- Summarize a document before reading it with `mineru`.
- Reimplement PDF/OCR extraction when `mineru` can read the document.
@@ -112,16 +110,36 @@ mineru read "doc:ab12cd3/tier:high/page:18" --json
## Installation And Setup
-Always check whether `mineru` is already available before installing.
+This skill requires MinerU `4.0.0` or later (`4.0.0a1` or later during the prerelease period). Before using any workflow, check whether the CLI is installed:
```bash
command -v mineru
-mineru --help
```
-If `mineru` is not installed, install it with the first available isolated CLI installer.
+If `mineru` is not installed, install it with the first available isolated CLI installer. If it is installed, check its version:
+
+```bash
+mineru version --json
+```
+
+If `mineru version --json` fails, try `mineru --version` for older CLIs. If the detected version does not meet this requirement, tell the user which version was found and ask before upgrading it. If approved, upgrade with the same installer and environment, then check the version again. If declined, stop and do not run this skill's commands. Never assume compatibility when the version cannot be determined.
+
MinerU requires Python `>=3.10,<3.14`.
+### Upgrade An Existing Installation
+
+Before upgrading, determine which tool owns the resolved `mineru` executable. Check `uv tool list`, then `pipx list --short`; otherwise, identify the Python environment containing the executable. Do not use an unrelated `pip` or install a second copy.
+
+Use the matching upgrade command only after the user approves the upgrade:
+
+```bash
+uv tool upgrade --prerelease allow mineru
+pipx upgrade mineru --pip-args="--pre"
+"<environment-python>" -m pip install --upgrade --pre mineru
+```
+
+If the owner cannot be determined, multiple installations exist, or MinerU is installed from source or in editable mode, ask the user instead of upgrading. After upgrading, check the resolved executable and its version again.
+
### Install with `uv` (preferred)
If `uv` is available, use any supported Python version for the tool environment.
@@ -698,9 +716,10 @@ Rules:
## Remote API Usage
-Use `usage` only for the configured Remote API; Local Parse Servers do not have account usage limits:
+Query usage and limits for the configured Remote API:
```bash
+mineru usage
mineru usage --json
```
diff --git a/tests/unittest/test_cli_next_command_design.py b/tests/unittest/test_cli_next_command_design.py
index b53213b7..bec6fe99 100644
--- a/tests/unittest/test_cli_next_command_design.py
+++ b/tests/unittest/test_cli_next_command_design.py
@@ -115,6 +115,15 @@ def test_version_command_prints_mineru_and_python_versions() -> None:
assert f"Python version: {sys.version.split()[0]}" in result.output
+def test_root_version_option_matches_version_command() -> None:
+ option_result = runner.invoke(app, ["--version"])
+ command_result = runner.invoke(app, ["version"])
+
+ assert option_result.exit_code == 0
+ assert command_result.exit_code == 0
+ assert option_result.output == command_result.output
+
+
def test_version_json_writes_single_json_object() -> None:
result = runner.invoke(app, ["version", "--json"])
@@ -151,6 +160,7 @@ def test_root_help_hides_typer_completion_options() -> None:
result = runner.invoke(app, ["--help"])
assert result.exit_code == 0
+ assert "--version" in result.output
assert "--install-completion" not in result.output
assert "--show-completion" not in result.output