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:
iacore
2026-07-15 13:05:34 +08:00
parent 894d769051
commit bc17471635
7 changed files with 25 additions and 22 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
---
name: mpi-chinese-text-normalize
description: Normalize Chinese markdown files by removing extraneous mid-sentence line breaks from fixed-width exports while preserving TOC structures, section headers, and intentional paragraph breaks. Do not use for English prose, wiki-link index files, or mixed CJK/English documents without manual review.
compatibility: Requires Python 3.9+ and uv. The script uses only the standard library.
compatibility: Requires Python 3.9+ and uv. The script's shebang invokes `uv run --script`; it uses only the standard library.
---
When Chinese text has hard line breaks at a fixed width (~20-25 chars) — common in PDF exports, OCR output, or poorly-converted documents — use this skill to join them into flowing paragraphs.
@@ -14,13 +14,13 @@ When Chinese text has hard line breaks at a fixed width (~20-25 chars) — commo
## Approach
Run with `uv`:
Run the script directly:
```bash
uv run skills/mpi-chinese-text-normalize/scripts/normalize_breaks.py <directory>
skills/mpi-chinese-text-normalize/scripts/normalize_breaks.py <directory>
```
It processes all `.md` files in the directory.
The shebang invokes `uv run --script`. It processes all `.md` files in the directory.
The script handles three file patterns:
+3 -2
View File
@@ -1,3 +1,4 @@
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.9"
# dependencies = []
@@ -11,7 +12,7 @@ Three file patterns:
2. Mostly-paragraph with stray breaks + outline TOC -> join broken lines, preserve list items
3. Already fine -> skip (idempotent)
Usage: uv run normalize_breaks.py <directory>
Usage: ./normalize_breaks.py <directory>
"""
import re
@@ -162,7 +163,7 @@ def process_file(filepath):
def main():
if len(sys.argv) != 2:
print("Usage: uv run normalize_breaks.py <directory>", file=sys.stderr)
print("Usage: ./normalize_breaks.py <directory>", file=sys.stderr)
sys.exit(1)
workdir = Path(sys.argv[1])
files = sorted(workdir.glob('*.md'))