Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Shared CLI Version Command Design
历史归档:保留原设计或验收时的记录,不作为当前版本的安装、接口或实现指引。 当前入口见 开发文档;当时的版本、测试结论和未完成事项不追溯改写。
Date: 2026-07-21
Goal
Add mineru-kit version and mineru-kit --version with exactly the same text output, JSON output, and exit behavior as the existing mineru entry points.
Design
Extract the existing version command implementation from mineru/cli/main.py into a lightweight shared module, mineru/cli/version_command.py. The module owns:
- the
VersionInforesult type; - MinerU and Python version collection;
- plain-text rendering;
- the
version --jsonTyper command callback; - the eager root
--versionoption callback.
Both root applications import and register the same version_cmd callback. Both root callbacks use the same eager show_version option callback. The main mineru callback continues preparing telemetry for normal commands; eager version output exits before telemetry preparation, as it does today. The MinerU Kit callback has no additional side effects.
The shared module uses the existing CliContext and run_cli path so that version --json retains its current serialization behavior. It imports only lightweight CLI runtime code and does not import either root command tree.
Command Registration
The main CLI continues registering version at the end of its ordered command list. MinerU Kit adds version after models in its ordered command list and registers the shared callback directly:
app.command("version")(version_cmd)
Both root applications expose an eager --version option with the existing help text, Show the version and exit.
Output Contract
Plain output remains:
MinerU version: <version>
Python version: <version>
JSON output remains a single object with mineru_version and python_version fields. The product label remains MinerU version for both executables.
Error and Import Boundaries
Version collection reads the local package version and current Python version only. It performs no network access and loads no parser, model, legacy router, or server implementation. Existing mineru-kit lazy-import boundaries remain intact.
Verification
Tests verify:
- Existing
mineru version,mineru version --json, andmineru --versionbehavior is unchanged. - MinerU Kit exposes
versionin the final top-level command position and--versionin root help. mineru-kit versionmatchesmineru versionexactly.mineru-kit --versionmatches itsversionsubcommand.- Both JSON subcommands emit the same single JSON object.
- Importing
mineru.kit.mainstill avoids legacy router and server implementations. - The tracked unit-test suite remains green.