Skip to content

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

docs: extend mineru-kit command registration design

jinzhenjcc69723cd0fe
diff --git a/docs/plans/2026-07-21-mineru-kit-command-registration-design.md b/docs/plans/2026-07-21-mineru-kit-command-registration-design.md
index 9ea63e87..1c2ece9f 100644
--- a/docs/plans/2026-07-21-mineru-kit-command-registration-design.md
+++ b/docs/plans/2026-07-21-mineru-kit-command-registration-design.md
@@ -4,25 +4,31 @@ Date: 2026-07-21
## Goal
-Remove duplicate CLI parameter declarations for `mineru-kit parse` and `mineru-kit api-server`. Each command implementation becomes the single source of truth for its Typer arguments, options, defaults, types, help text, validation, and execution.
+Remove duplicate CLI parameter declarations for the `mineru-kit parse`, `api-server`, `vlm-server`, and `router` commands. Each command implementation becomes the single source of truth for its Typer arguments, options, defaults, types, help text, validation, and execution.
The user-facing command names and behavior remain unchanged.
## Current Problem
-`mineru/kit/main.py` currently defines full Typer callbacks for `parse` and `api-server`, then forwards every value to functions in `mineru/kit/commands/`. The implementation functions define another set of signatures and defaults. Changes therefore need to be applied twice, and the two layers already require `type: ignore` annotations where the entrypoint uses broad strings but the implementation uses typed literals.
+`mineru/kit/main.py` currently defines full Typer callbacks for the four commands, then forwards every value to functions in `mineru/kit/commands/`. The implementation functions define another set of signatures and defaults. Changes therefore need to be applied twice, and the two layers already require `type: ignore` annotations where the entrypoint uses broad strings but the implementation uses typed literals.
+
+The `vlm-server` and `router` wrappers additionally configure unknown-option forwarding through Click context settings. The router wrapper also renames its repeatable `upstream_url` CLI value to the implementation's `upstream_urls` parameter. These responsibilities can remain intact without retaining duplicate callbacks.
The main `mineru` CLI avoids this duplication. Command modules define their Typer parameters directly, and `mineru/cli/main.py` only registers those functions with `app.command()`.
## Design
-Move the Typer `Argument` and `Option` metadata for `parse` into `mineru/kit/commands/parse.py`, on `parse_cmd()` itself. Move the corresponding metadata for `api-server` into `mineru/kit/commands/api_server.py`, on `api_server_cmd()` itself.
+Move the Typer `Argument` and `Option` metadata for each command into its corresponding function under `mineru/kit/commands/`.
+
+The `vlm-server` and `router` implementation functions accept `typer.Context` directly and continue reading `ctx.args` for unknown arguments. Their `context_settings` stay on the registration calls in `mineru/kit/main.py`, because those settings configure Click command construction rather than command behavior. The router implementation adopts the public CLI name `upstream_url`, eliminating the wrapper-only singular-to-plural translation.
Register the implementation functions directly in `mineru/kit/main.py`:
```python
app.command("parse")(parse.parse_cmd)
app.command("api-server")(api_server.api_server_cmd)
+app.command("vlm-server", context_settings=FORWARD_CONTEXT_SETTINGS)(vlm_server.vlm_server_cmd)
+app.command("router", context_settings=FORWARD_CONTEXT_SETTINGS)(router.router_cmd)
```
This matches the registration pattern used by the main `mineru` CLI.
@@ -40,9 +46,7 @@ The command modules own:
## Scope Boundaries
-The `models` command group already owns its module-local Typer app and remains unchanged.
-
-The `router` and `vlm-server` wrappers remain in `mineru/kit/main.py`. They require command-specific `context_settings`, access to `typer.Context`, unknown-option forwarding, and argument reshaping, so direct replacement is not part of this refactor.
+The `models` command group already owns its module-local Typer app and remains unchanged. The root application, ordered command group, command ordering, and forwarding context settings remain in `mineru/kit/main.py`.
No parser behavior, API-server behavior, request schema, or command-line option is added or removed.
@@ -54,9 +58,11 @@ Existing command validation remains in the implementation modules. The API-serve
Tests verify:
-1. `mineru-kit parse --help` and `mineru-kit api-server --help` retain their arguments, options, defaults, and help text.
+1. All four directly registered commands retain their arguments, options, defaults, and help text.
2. Parse command values reach the existing implementation behavior.
3. API-server options, including the single startup tier and `--no-flash`, reach the underlying Click command unchanged.
4. Invalid API-server startup tiers and `--tier flash --no-flash` retain structured CLI failures.
-5. Root command order remains unchanged.
-6. The tracked unit-test suite remains green.
+5. `vlm-server` and `router` continue receiving unknown arguments through `ctx.args`.
+6. Router options, including repeated `--upstream-url`, reach the legacy router unchanged.
+7. Root command order remains unchanged.
+8. The tracked unit-test suite remains green.