feat: Add install.sh for one-line skill distribution and update

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zfc 2026-03-02 11:47:54 +08:00
parent 8819a2f91e
commit 7b8b0c461c
2 changed files with 124 additions and 37 deletions

View File

@ -35,54 +35,37 @@ RequirementsDoc ──▶ PRD ──▶ FeatureSummary ──▶ DevelopmentPlan
| | `/mt` | 增量修改 tasks |
| **执行** | `/go` | 🚀 发射按钮,激进模式一口气完成开发 |
| **辅助** | `/iter` | 迭代变更入口Bug/功能/重构) |
| | `/up` | 文档升级迁移 |
| | `/up` | Skill 升级优化 |
| | `/deploy` | Drone CI/CD 全流程部署引导 |
| | `/changelog` | 一键发版(日志 + commit + tag |
## 安装方式
### 方式 1直接复制
## 安装 & 更新
一行命令搞定安装和更新。脚本会智能处理:新 skill 直接装,已有的对比更新,本地魔改自动备份。
```bash
# 克隆仓库
git clone https://git.internal.intelligrow.cn/zhangfucai/spec-coding-skills.git /tmp/spec-coding-skills
# 复制 skills 到你的项目
mkdir -p .claude
cp -r /tmp/spec-coding-skills/.claude/skills .claude/
# 清理
rm -rf /tmp/spec-coding-skills
# 在你的项目根目录执行(首次安装 & 后续更新都用这条)
bash <(curl -sL https://git.internal.intelligrow.cn/zhangfucai/spec-coding-skills/raw/branch/main/install.sh)
```
### 方式 2Git Submodule
或者先下载再执行:
```bash
# 在你的项目根目录执行
git submodule add https://git.internal.intelligrow.cn/zhangfucai/spec-coding-skills.git .spec-coding-skills
# 创建符号链接
mkdir -p .claude
ln -s ../.spec-coding-skills/.claude/skills .claude/skills
curl -sL https://git.internal.intelligrow.cn/zhangfucai/spec-coding-skills/raw/branch/main/install.sh -o /tmp/install-skills.sh
bash /tmp/install-skills.sh
```
```bash
# 提交变更
git add .gitmodules .spec-coding-skills .claude/skills
git commit -m "Add spec-coding-skills as submodule"
```
### 更新策略
| 情况 | 处理方式 |
|------|---------|
| 新 skill本地没有 | 直接安装 |
| 本地未改 + 上游有更新 | 直接覆盖 |
| 本地魔改过 + 上游有更新 | 写入上游新版,本地版备份为 `SKILL.md.local.bak` |
| 本地和上游一致 | 跳过 |
## 更新 Skills
### Submodule 方式
```bash
# 更新到最新版本
git submodule update --remote .spec-coding-skills
```
### 直接复制方式
重新执行复制命令覆盖即可。
恢复本地版本:`mv SKILL.md.local.bak SKILL.md`
对比差异:`diff SKILL.md SKILL.md.local.bak`
## 使用示例

104
install.sh Normal file
View File

@ -0,0 +1,104 @@
#!/usr/bin/env bash
# ============================================================
# spec-coding-skills 安装/更新脚本
# 用法: bash <(curl -sL <raw-url>/install.sh)
# 或: bash install.sh [目标目录]
# ============================================================
set -euo pipefail
REPO_URL="https://git.internal.intelligrow.cn/zhangfucai/spec-coding-skills.git"
SKILLS_SRC=".claude/skills"
DEFAULT_TARGET=".claude/skills"
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; CYAN='\033[0;36m'; NC='\033[0m'
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_title() { echo -e "${CYAN}$1${NC}"; }
TARGET="${1:-$DEFAULT_TARGET}"
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
# ---------- 拉取最新 ----------
log_title "📦 spec-coding-skills 安装/更新"
echo ""
log_info "拉取最新版本..."
git clone --depth 1 --quiet "$REPO_URL" "$TMP_DIR"
VERSION=$(git -C "$TMP_DIR" describe --tags --always 2>/dev/null || git -C "$TMP_DIR" rev-parse --short HEAD)
log_info "版本: $VERSION"
# ---------- 统计变更 ----------
NEW=0
UPDATED=0
SKIPPED=0
KEPT=0
mkdir -p "$TARGET"
# 遍历上游 skill 目录
for skill_dir in "$TMP_DIR/$SKILLS_SRC"/*/; do
[ -d "$skill_dir" ] || continue
skill_name=$(basename "$skill_dir")
src_file="$skill_dir/SKILL.md"
dst_dir="$TARGET/$skill_name"
dst_file="$dst_dir/SKILL.md"
[ -f "$src_file" ] || continue
if [ ! -f "$dst_file" ]; then
# 新 skill直接复制
mkdir -p "$dst_dir"
cp "$src_file" "$dst_file"
log_info "✨ 新增: $skill_name"
NEW=$((NEW + 1))
elif diff -q "$src_file" "$dst_file" >/dev/null 2>&1; then
# 内容一致,跳过
SKIPPED=$((SKIPPED + 1))
else
# 内容不同:上游有更新 或 用户本地修改过
# 策略:备份本地版本,写入上游新版本
cp "$dst_file" "$dst_file.local.bak"
cp "$src_file" "$dst_file"
log_warn "🔄 更新: $skill_name (本地版本已备份为 SKILL.md.local.bak"
UPDATED=$((UPDATED + 1))
fi
done
# 复制模板文件(非 skill 目录的文件)
for tpl_file in "$TMP_DIR/$SKILLS_SRC"/*.template "$TMP_DIR/$SKILLS_SRC"/*.md; do
[ -f "$tpl_file" ] || continue
tpl_name=$(basename "$tpl_file")
dst="$TARGET/$tpl_name"
if [ ! -f "$dst" ]; then
cp "$tpl_file" "$dst"
log_info "✨ 新增模板: $tpl_name"
NEW=$((NEW + 1))
elif ! diff -q "$tpl_file" "$dst" >/dev/null 2>&1; then
cp "$dst" "$dst.local.bak"
cp "$tpl_file" "$dst"
log_warn "🔄 更新模板: $tpl_name (本地版本已备份为 ${tpl_name}.local.bak"
UPDATED=$((UPDATED + 1))
else
SKIPPED=$((SKIPPED + 1))
fi
done
# ---------- 汇总 ----------
echo ""
log_title "✅ 完成!"
echo ""
echo " 📁 目标目录: $TARGET"
echo " 📦 版本: $VERSION"
echo ""
echo " ✨ 新增: $NEW"
echo " 🔄 更新: $UPDATED(本地版本已备份为 .local.bak"
echo " ⏭️ 无变化: $SKIPPED"
echo ""
if [ "$UPDATED" -gt 0 ]; then
log_warn "$UPDATED 个文件被更新,本地修改已备份为 .local.bak"
log_warn "如需恢复本地版本: mv SKILL.md.local.bak SKILL.md"
log_warn "如需对比差异: diff SKILL.md SKILL.md.local.bak"
fi