$npx -y skills add mvanhorn/cli-printing-press --skill printing-press-importBring a published CLI from the public library into the internal library so it's identical to a freshly-generated copy — module path reverted, manuscripts placed alongside, ready for /printing-press-polish or /printing-press-emboss. Use when the public library has a CLI you don't
| 1 | # /printing-press-import |
| 2 | |
| 3 | Bring a published CLI from the public library |
| 4 | ([`mvanhorn/printing-press-library`](https://github.com/mvanhorn/printing-press-library)) |
| 5 | into the internal library at `$PRESS_LIBRARY/` so it matches |
| 6 | the form the generator would produce. Manuscripts ride along. |
| 7 | |
| 8 | ```bash |
| 9 | /printing-press-import notion |
| 10 | /printing-press-import cal.com |
| 11 | /printing-press-import allrecipes --from-clone ~/Code/printing-press-library |
| 12 | ``` |
| 13 | |
| 14 | The internal library is the working copy; the public library is the |
| 15 | durable artifact. After import, the CLI is ready for polish, emboss, or |
| 16 | re-publish — the publish step will re-apply the module path rewrites. |
| 17 | |
| 18 | ## When to run |
| 19 | |
| 20 | - The public library has a CLI you don't have locally |
| 21 | - The internal copy is broken, lost, or out of sync |
| 22 | - You want a clean baseline before running polish on a published CLI |
| 23 | |
| 24 | If the user is asking to polish a CLI and mentions "in/from the public |
| 25 | library" or "from the repo", suggest running this skill first. |
| 26 | |
| 27 | ## Setup |
| 28 | |
| 29 | ```bash |
| 30 | PRESS_HOME="${PRINTING_PRESS_HOME:-$HOME/printing-press}" |
| 31 | PRESS_LIBRARY="$PRESS_HOME/library" |
| 32 | PRESS_MANUSCRIPTS="$PRESS_HOME/manuscripts" |
| 33 | SCRIPTS_DIR="$(dirname "${BASH_SOURCE[0]:-$0}")/references" |
| 34 | |
| 35 | if ! command -v go >/dev/null 2>&1; then |
| 36 | echo "" |
| 37 | echo "[setup-error] Go toolchain not found." |
| 38 | echo "" |
| 39 | echo "This Printing Press flow runs Go-based build or validation commands." |
| 40 | echo "Install Go 1.26.5 or newer from https://go.dev/dl/, then verify with:" |
| 41 | echo " go version" |
| 42 | echo "Then re-run this skill." |
| 43 | echo "" |
| 44 | return 1 2>/dev/null || exit 1 |
| 45 | fi |
| 46 | |
| 47 | _pp_check_disk_space() { |
| 48 | _pp_disk_warn_kb="${PRINTING_PRESS_DISK_WARN_KB:-3145728}" |
| 49 | _pp_disk_fail_kb="${PRINTING_PRESS_DISK_FAIL_KB:-524288}" |
| 50 | case "$_pp_disk_warn_kb$_pp_disk_fail_kb" in |
| 51 | ""|*[!0-9]*) return 0 ;; |
| 52 | esac |
| 53 | |
| 54 | _pp_disk_path="$PRESS_HOME" |
| 55 | while [ ! -e "$_pp_disk_path" ] && [ "$_pp_disk_path" != "/" ]; do |
| 56 | _pp_disk_path="$(dirname "$_pp_disk_path")" |
| 57 | done |
| 58 | |
| 59 | _pp_disk_avail_kb="$(df -Pk "$_pp_disk_path" 2>/dev/null | awk 'NR == 2 { print $4; exit }')" |
| 60 | case "$_pp_disk_avail_kb" in |
| 61 | ""|*[!0-9]*) return 0 ;; |
| 62 | esac |
| 63 | |
| 64 | if [ "$_pp_disk_avail_kb" -lt "$_pp_disk_fail_kb" ]; then |
| 65 | echo "" |
| 66 | echo "[setup-error] Critically low disk space on the Printing Press workspace volume." |
| 67 | echo "PRESS_DISK_PATH=$_pp_disk_path" |
| 68 | echo "PRESS_DISK_AVAIL_KB=$_pp_disk_avail_kb" |
| 69 | echo "PRESS_DISK_FAIL_KB=$_pp_disk_fail_kb" |
| 70 | echo "Free disk space or set PRINTING_PRESS_HOME to a volume with more room, then re-run this skill." |
| 71 | echo "" |
| 72 | return 1 |
| 73 | fi |
| 74 | |
| 75 | if [ "$_pp_disk_avail_kb" -lt "$_pp_disk_warn_kb" ]; then |
| 76 | echo "" |
| 77 | echo "[low-disk] Printing Press workspace volume is low on free space." |
| 78 | echo "PRESS_DISK_PATH=$_pp_disk_path" |
| 79 | echo "PRESS_DISK_AVAIL_KB=$_pp_disk_avail_kb" |
| 80 | echo "PRESS_DISK_WARN_KB=$_pp_disk_warn_kb" |
| 81 | echo "This flow may need several GiB for generated files, Go build cache, module downloads, or repository clones." |
| 82 | echo "" |
| 83 | fi |
| 84 | } |
| 85 | _pp_check_disk_space || { return 1 2>/dev/null || exit 1; } |
| 86 | ``` |
| 87 | |
| 88 | The four reference scripts live alongside this SKILL.md under |
| 89 | `references/`: |
| 90 | |
| 91 | - `import-fetch.sh <library-path> <staging> [--clone <path>]` |
| 92 | - `import-backup.sh <api-slug>` (prints zip path on stdout) |
| 93 | - `import-rewrite.sh <staging> <api-slug>` |
| 94 | - `import-place.sh <staging> <api-slug>` |
| 95 | |
| 96 | If setup emitted `[low-disk]`, surface the advisory to the user and continue unless setup also emitted `[setup-error]`. `[low-disk]` means this run may need several GiB for repository clones, staged files, backups, Go build cache, or module downloads. |
| 97 | |
| 98 | ## Phase 1 — Resolve the CLI |
| 99 | |
| 100 | The argument can be anything natural: an API slug (`notion`), a brand |
| 101 | name (`cal.com`), an old CLI name (`notion-pp-cli`), or close enough |
| 102 | (`Allrecipes`). Resolve via the public library's `registry.json` — |
| 103 | which carries `name`, `category`, `api`, `description`, and `path` for |
| 104 | every entry, in one fetch. |
| 105 | |
| 106 | ```bash |
| 107 | REGISTRY=$(mktemp) |
| 108 | gh api -H "Accept: application/vnd.github.v3.raw" \ |
| 109 | repos/mvanhorn/printing-press-library/contents/registry.json \ |
| 110 | > "$REGISTRY" |
| 111 | ``` |
| 112 | |
| 113 | Match in this order: |
| 114 | |
| 115 | 1. **Exact `name` match** — `jq --arg q "$ARG" '.entries[] | select(.name == $q)' "$REGISTRY"` |
| 116 | 2. **Normalized exact** — strip `-pp-cli` suffix, lowercase, dot→hyphen, then exact match |
| 117 | 3. **Substring on `name` or `description`** — case-insensitive contains |
| 118 | |
| 119 | ```bash |
| 120 | # Exact: |
| 121 | jq --ar |