$npx -y skills add Lylll9436/Paper-Polish-Workflow-skill --skill ppw-updateSync local skills and references from the GitHub repo. Triggers on update skills, sync skills, 更新技能, 同步技能
| 1 | ## Purpose |
| 2 | |
| 3 | This Skill syncs local `.claude/skills/` and `references/` from the upstream GitHub repository [Lylll9436/Paper-Polish-Workflow-skill](https://github.com/Lylll9436/Paper-Polish-Workflow-skill). It downloads the latest SKILL.md files and reference documents, compares them with local versions, and updates any changed files. |
| 4 | |
| 5 | ## Trigger |
| 6 | |
| 7 | **Activates when the user asks to:** |
| 8 | - Update or sync skills from the remote repo |
| 9 | - 更新或同步技能包 |
| 10 | |
| 11 | **Example invocations:** |
| 12 | - "update skills" |
| 13 | - "sync skills from GitHub" |
| 14 | - "更新技能" |
| 15 | |
| 16 | ## Modes |
| 17 | |
| 18 | | Mode | Default | Behavior | |
| 19 | |------|---------|----------| |
| 20 | | `direct` | Yes | Fetch, compare, update, report — no intermediate confirmation | |
| 21 | | `interactive` | | Show diff summary before applying each update | |
| 22 | |
| 23 | **Default mode:** `direct` |
| 24 | |
| 25 | ## Workflow |
| 26 | |
| 27 | ### Step 0: Workflow Memory Check |
| 28 | |
| 29 | - Read `.planning/workflow-memory.json`. If file missing or empty, skip to Step 1. |
| 30 | - Check if the last 1-2 log entries form a recognized pattern with `ppw:update` that has appeared >= threshold times in the log. See `skill-conventions.md > Workflow Memory > Pattern Detection` for the full algorithm. |
| 31 | - If a pattern is found, present recommendation via AskUserQuestion: |
| 32 | - Question: "检测到常用流程:[pattern](已出现 N 次)。是否直接以 direct 模式运行 ppw:update?" |
| 33 | - Options: "Yes, proceed" / "No, continue normally" |
| 34 | - If user accepts: set mode to `direct`, skip Ask Strategy questions. |
| 35 | - If user declines or AskUserQuestion unavailable: continue in normal mode. |
| 36 | |
| 37 | ### Step 1: Pre-flight Check |
| 38 | |
| 39 | - Verify `gh` CLI is available and authenticated: `gh auth status` |
| 40 | - Verify the upstream repo is accessible: `gh api repos/Lylll9436/Paper-Polish-Workflow-skill --jq '.full_name'` |
| 41 | - If either check fails, report the error and stop. |
| 42 | - **Record workflow:** Append `{"skill": "ppw:update", "ts": "<ISO timestamp>"}` to `.planning/workflow-memory.json`. Create file as `[]` if missing. Drop oldest entry if log length >= 50. |
| 43 | |
| 44 | ### Step 2: Fetch Remote File Index |
| 45 | |
| 46 | - List all skill directories from the remote repo: |
| 47 | ```bash |
| 48 | gh api repos/Lylll9436/Paper-Polish-Workflow-skill/contents/.claude/skills --jq '.[].name' |
| 49 | ``` |
| 50 | - List all reference files from the remote repo: |
| 51 | ```bash |
| 52 | gh api repos/Lylll9436/Paper-Polish-Workflow-skill/contents/references --jq '.[] | .name + " " + .type' |
| 53 | ``` |
| 54 | - For reference subdirectories (type=dir), also list their contents recursively. |
| 55 | |
| 56 | ### Step 3: Compare and Update Skills |
| 57 | |
| 58 | For each remote skill directory: |
| 59 | |
| 60 | 1. Fetch the remote `SKILL.md` content: |
| 61 | ```bash |
| 62 | gh api repos/Lylll9436/Paper-Polish-Workflow-skill/contents/.claude/skills/{skill-name}/SKILL.md --jq '.content' | base64 -d |
| 63 | ``` |
| 64 | 2. Read the local `.claude/skills/{skill-name}/SKILL.md` if it exists. |
| 65 | 3. Compare the two: |
| 66 | - If local file does not exist → **NEW** skill, create directory and write file. |
| 67 | - If content differs → **UPDATED**, overwrite local file. |
| 68 | - If content is identical → **UNCHANGED**, skip. |
| 69 | 4. Track results for the final report. |
| 70 | |
| 71 | **In `interactive` mode:** Before applying each update, show a summary of changes and ask for confirmation. |
| 72 | |
| 73 | ### Step 4: Compare and Update References |
| 74 | |
| 75 | For each remote reference file: |
| 76 | |
| 77 | 1. Fetch the remote file content via `gh api` with base64 decode. |
| 78 | 2. Read the local `references/{filename}` if it exists. |
| 79 | 3. Compare and apply the same NEW/UPDATED/UNCHANGED logic as Step 3. |
| 80 | 4. For subdirectories (e.g., `references/journals/`, `references/expression-patterns/`), recurse into each file. |
| 81 | |
| 82 | ### Step 5: Output Report |
| 83 | |
| 84 | Present a summary table: |
| 85 | |
| 86 | ``` |
| 87 | ## Skills Update Report |
| 88 | |
| 89 | | Skill | Status | |
| 90 | |-------|--------| |
| 91 | | polish-skill | ✓ Updated | |
| 92 | | de-ai-skill | - Unchanged | |
| 93 | | new-skill | + New | |
| 94 | |
| 95 | ## References Update Report |
| 96 | |
| 97 | | File | Status | |
| 98 | |------|--------| |
| 99 | | expression-patterns.md | ✓ Updated | |
| 100 | | skill-conventions.md | - Unchanged | |
| 101 | |
| 102 | **Summary:** {updated_count} updated, {new_count} new, {unchanged_count} unchanged |
| 103 | ``` |
| 104 | |
| 105 | ## Output Contract |
| 106 | |
| 107 | | Output | Format | Condition | |
| 108 | |--------|--------|-----------| |
| 109 | | Update report | Markdown table | Always produced | |
| 110 | | File count summary | Text | Always reported | |
| 111 | |
| 112 | ## Edge Cases |
| 113 | |
| 114 | | Situation | Handling | |
| 115 | |-----------|----------| |
| 116 | | `gh` CLI not installed or not authenticated | Report error, suggest `gh auth login` | |
| 117 | | Remote repo not accessible | Report network/permission error | |
| 118 | | Local skill has modifications not in remote | Overwrite with remote (remote is source of truth) | |
| 119 | | New skill in remote not present locally | Create directory and write SKILL.md | |
| 120 | | Remote skill deleted but exists locally | Keep local (do not delete; report as "loc |