feat(skills): make skill scripts self-executing with uv hashbang
The Python scripts in mpi-pptx-translate, mpi-pdf-to-docx-conversion, and mpi-chinese-text-normalize previously required users to type manually. That is easy to forget and adds friction every time the skill runs. Switch all four scripts to a shebang, so they can be invoked directly: . The PEP 723 metadata blocks remain, so uv still installs the dependencies automatically. Also made the scripts executable and updated their usage messages and SKILL.md instructions to match the direct-execution style.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
name: mpi-pdf-to-docx-conversion
|
||||
description: Convert flowing text PDFs (Chinese or multi-language) to DOCX with proper fonts, styles, native bullets, lists, and embedded images. Use for text-based PDFs. Do not use for scanned/image PDFs, form-heavy PDFs, or documents where exact page layout must be preserved.
|
||||
license: MIT
|
||||
compatibility: Requires Python 3.9+ and uv. Dependencies (pymupdf, python-docx) are declared in the script's /// script metadata.
|
||||
compatibility: Requires Python 3.9+ and uv. The script's shebang invokes `uv run --script`; dependencies (pymupdf, python-docx) are declared in the `/// script` metadata.
|
||||
---
|
||||
|
||||
# PDF-to-DOCX Conversion
|
||||
@@ -11,13 +11,13 @@ Convert text-based PDF documents (including CJK) into structured DOCX files that
|
||||
|
||||
## Quick start
|
||||
|
||||
For most PDFs, run the bundled converter with `uv`:
|
||||
For most PDFs, run the bundled converter directly:
|
||||
|
||||
```bash
|
||||
uv run skills/mpi-pdf-to-docx-conversion/scripts/convert_pdf_to_docx.py input.pdf output.docx
|
||||
skills/mpi-pdf-to-docx-conversion/scripts/convert_pdf_to_docx.py input.pdf output.docx
|
||||
```
|
||||
|
||||
`uv` reads the `/// script` metadata block in the script and installs `pymupdf` and `python-docx` automatically.
|
||||
The shebang invokes `uv run --script`, which reads the `/// script` metadata block and installs `pymupdf` and `python-docx` automatically.
|
||||
|
||||
For documents with unusual fonts or structure, inspect first and pass a config dict. See `references/config-patterns.md` for the config schema and common patterns.
|
||||
|
||||
|
||||
Regular → Executable
+3
-3
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env -S uv run --script
|
||||
# /// script
|
||||
# requires-python = ">=3.9"
|
||||
# dependencies = [
|
||||
@@ -13,7 +13,7 @@ Handles multi-language text, mixed fonts, bullets, numbered lists, verses,
|
||||
attributions, images, and flowing text across pages.
|
||||
|
||||
Usage:
|
||||
uv run convert_pdf_to_docx.py input.pdf output.docx
|
||||
./convert_pdf_to_docx.py input.pdf output.docx
|
||||
|
||||
Requires: uv (dependencies are declared in the /// script block above)
|
||||
"""
|
||||
@@ -552,6 +552,6 @@ def convert_pdf_to_docx(pdf_path: str, docx_path: str, config: dict = None):
|
||||
# CLI
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: uv run convert_pdf_to_docx.py <input.pdf> <output.docx>")
|
||||
print("Usage: ./convert_pdf_to_docx.py <input.pdf> <output.docx>")
|
||||
sys.exit(1)
|
||||
convert_pdf_to_docx(sys.argv[1], sys.argv[2])
|
||||
|
||||
Reference in New Issue
Block a user