Skip to content

Fantasia1999/skills-zh

skills-zh-updater

Verified

同步并维护 anthropics/skills 仓库的中文翻译。用于:拉取上游更新、增量翻译/全量翻译 SKILL.md、生成中文索引 INDEX_ZH.md,并快速检查翻译完整性。

FileKindSize
SKILL.mdskill md2.3 KB
scripts/build_index.pyscript1.3 KB
scripts/update_from_upstream.shexecutablescript3.5 KB
scripts/update_zh.shexecutablescript161 B

scripts/update_from_upstream.sh

View on GitHub
#!/usr/bin/env bash
set -euo pipefail

MODE="--incremental"
UPSTREAM_DEFAULT="/path/to/anthropic-skills-repo/skills"
UPSTREAM="$UPSTREAM_DEFAULT"

while [[ $# -gt 0 ]]; do
  case "$1" in
    --full|--incremental)
      MODE="$1"; shift ;;
    --upstream)
      UPSTREAM="${2:-}"; shift 2 ;;
    *)
      echo "Usage: $0 [--incremental|--full] [--upstream <upstream_skills_dir>]"
      exit 1 ;;
  esac
done

if [[ ! -d "$UPSTREAM" ]]; then
  echo "Upstream dir not found: $UPSTREAM"
  echo "Tip: git clone https://github.com/anthropics/skills.git /path/to/anthropic-skills-repo"
  exit 1
fi

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OUT="$ROOT/translations"
STATE="$ROOT/.translation-state.json"
TMP_PROMPT="/tmp/gemini_translate_prompt.txt"
mkdir -p "$OUT"

get_hash () {
  local file="$1"
  sha256sum "$file" | awk '{print $1}'
}

state_get_hash () {
  local rel="$1"
  python3 - "$STATE" "$rel" <<'PY'
import json,sys,os
state_path, rel = sys.argv[1], sys.argv[2]
if not os.path.exists(state_path):
    print("")
    raise SystemExit
try:
    data = json.load(open(state_path, 'r', encoding='utf-8'))
except Exception:
    print("")
    raise SystemExit
print((data.get('files') or {}).get(rel, {}).get('src_sha256', ''))
PY
}

state_upsert_hash () {
  local rel="$1"
  local sha="$2"
  python3 - "$STATE" "$rel" "$sha" "$UPSTREAM" <<'PY'
import json,sys,os,subprocess
state_path, rel, sha, upstream = sys.argv[1:]
if os.path.exists(state_path):
    try:
        data = json.load(open(state_path, 'r', encoding='utf-8'))
    except Exception:
        data = {}
else:
    data = {}

files = data.setdefault('files', {})
entry = files.setdefault(rel, {})
entry['src_sha256'] = sha

# optional audit info: upstream repo HEAD
head = ''
repo = os.path.abspath(os.path.join(upstream, '..'))
if os.path.isdir(os.path.join(repo, '.git')):
    try:
        head = subprocess.check_output(
            ['git', '-C', repo, 'rev-parse', 'HEAD'],
            text=True
        ).strip()
    except Exception:
        head = ''
if head:
    data['upstream_repo_head'] = head

os.makedirs(os.path.dirname(state_path), exist_ok=True)
with open(state_path, 'w', encoding='utf-8') as f:
    json.dump(data, f, ensure_ascii=False, indent=2)
PY
}

translate_one () {
  local src_md="$1"
  local rel="${src_md#$UPSTREAM/}"
  local out_md="$OUT/$rel"
  mkdir -p "$(dirname "$out_md")"

  {
    echo '你是技术文档翻译助手。请把下面英文 SKILL.md 完整翻译成简体中文,要求:'
    echo '1) 保留原有 Markdown 结构、标题层级、列表、代码块、YAML frontmatter。'
    echo '2) 专有名词和命令保留英文(例如 Claude API, MCP, Playwright, gemini 命令)。'
    echo '3) 文风准确、自然,不要删减内容。'
    echo '4) 仅输出翻译后的 Markdown,不要额外解释。'
    echo ''
    echo '--- 原文开始 ---'
    cat "$src_md"
    echo ''
    echo '--- 原文结束 ---'
  } > "$TMP_PROMPT"

  gemini --model gemini-2.5-pro "$(cat "$TMP_PROMPT")" > "$out_md"
  echo "translated: $rel"
}

count=0
skipped=0
while IFS= read -r -d '' f; do
  rel="${f#$UPSTREAM/}"
  src_sha="$(get_hash "$f")"

  if [[ "$MODE" == "--incremental" ]]; then
    old_sha="$(state_get_hash "$rel")"
    if [[ -n "$old_sha" && "$old_sha" == "$src_sha" ]]; then
      skipped=$((skipped+1))
      continue
    fi
  fi

  translate_one "$f"
  state_upsert_hash "$rel" "$src_sha"
  count=$((count+1))
done < <(find "$UPSTREAM" -type f -name 'SKILL.md' -print0 | sort -z)

echo "done, translated files: $count, skipped: $skipped, mode: $MODE"
echo "state file: $STATE"
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall