aodw-skill 0.7.28 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.aodw-next/01-core/ai-interaction-rules.md +24 -2
- package/.aodw-next/01-core/ai-knowledge-rules.md +31 -1
- package/.aodw-next/01-core/aodw-constitution.md +84 -15
- package/.aodw-next/01-core/git-discipline.md +160 -31
- package/.aodw-next/01-core/test-discipline.md +124 -0
- package/.aodw-next/02-workflow/autopilot-goal-spec.md +2 -2
- package/.aodw-next/02-workflow/autopilot-protocol.md +1 -1
- package/.aodw-next/02-workflow/rt-manager.md +310 -20
- package/.aodw-next/02-workflow/spec-full-profile.md +4 -3
- package/.aodw-next/02-workflow/spec-lite-profile.md +2 -1
- package/.aodw-next/02-workflow/sub-agent-driven-profile.md +156 -0
- package/.aodw-next/02-workflow/task-pack-projection.md +250 -0
- package/.aodw-next/04-auditors/aodw-development-auditor-rules.md +31 -13
- package/.aodw-next/04-auditors/aodw-full-auditor-rules.md +61 -39
- package/.aodw-next/04-auditors/aodw-plan-auditor-rules.md +109 -0
- package/.aodw-next/04-auditors/aodw-requirement-auditor-rules.md +51 -31
- package/.aodw-next/README.md +63 -1
- package/.aodw-next/SKILL.md +2 -0
- package/.aodw-next/config.yaml +5 -0
- package/.aodw-next/manifest.yaml +42 -2
- package/.aodw-next/manifests/rt-gates.yaml +252 -0
- package/.aodw-next/project.yaml +41 -1
- package/.aodw-next/skills/handover-pack/SKILL.md +219 -0
- package/.aodw-next/skills/handover-pack/references/format-contract.md +124 -0
- package/.aodw-next/skills/handover-pack/scripts/_common.sh +92 -0
- package/.aodw-next/skills/handover-pack/scripts/check-closure.sh +163 -0
- package/.aodw-next/skills/handover-pack/scripts/next-number.sh +111 -0
- package/.aodw-next/skills/handover-pack/scripts/validate.py +260 -0
- package/.aodw-next/skills/handover-pack/templates/handover-template.md +99 -0
- package/.aodw-next/templates/aodw-kernel-loader-template.md +3 -4
- package/.aodw-next/templates/rt-autopilot-preflight.template.md +1 -1
- package/.aodw-next/templates/rt-lite.template.md +1 -1
- package/.aodw-next/templates/rt-meta-template.yaml +30 -1
- package/.aodw-next/tools/fixtures/data/hook-bad-stdin.txt +1 -0
- package/.aodw-next/tools/fixtures/data/hook-pretooluse-benign.json +17 -0
- package/.aodw-next/tools/fixtures/data/hook-pretooluse-commit.json +17 -0
- package/.aodw-next/tools/fixtures/data/hook-stop-active.json +13 -0
- package/.aodw-next/tools/fixtures/data/hook-stop-first.json +13 -0
- package/.aodw-next/tools/fixtures/data/python3-no-yaml.sh +4 -0
- package/.aodw-next/tools/fixtures/root-g101/RT/RT-701/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-g101/RT/RT-702/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-g101/RT/RT-703/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-g101/RT/index.yaml +11 -0
- package/.aodw-next/tools/fixtures/root-g109/RT/RT-622/meta.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-g109/RT/RT-622/rt-lite.md +6 -0
- package/.aodw-next/tools/fixtures/root-g109/RT/index.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-g113/RT/RT-631/handoff/unit-U1-input.md +12 -0
- package/.aodw-next/tools/fixtures/root-g113/RT/RT-631/meta.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-g113/RT/RT-631/rt-lite.md +6 -0
- package/.aodw-next/tools/fixtures/root-g113/RT/index.yaml +3 -0
- package/.aodw-next/tools/fixtures/root-g114-noledger/RT/RT-811/meta.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-g114-noledger/RT/RT-812/meta.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-g114-noledger/RT/index.yaml +7 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-801/meta.yaml +10 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-802/meta.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-803/meta.yaml +7 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-804/meta.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-805/meta.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-806/meta.yaml +11 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-807/meta.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-808/meta.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/RT-809/meta.yaml +9 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/_deferred-items.md +53 -0
- package/.aodw-next/tools/fixtures/root-g114g115/RT/index.yaml +21 -0
- package/.aodw-next/tools/fixtures/root-mini/RT/RT-101/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u1/RT/RT-501/handoff/unit-U1-input.md +19 -0
- package/.aodw-next/tools/fixtures/root-u1/RT/RT-502/handoff/unit-U1-input.md +18 -0
- package/.aodw-next/tools/fixtures/root-u1/RT/RT-503/handoff/unit-U1-input.md +19 -0
- package/.aodw-next/tools/fixtures/root-u1/RT/RT-503/meta.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-u1/RT/RT-503/retrospective.md +5 -0
- package/.aodw-next/tools/fixtures/root-u1/RT/RT-504/handoff/unit-U1-input.md +19 -0
- package/.aodw-next/tools/fixtures/root-u1/RT/RT-504/meta.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-201/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-201/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-202/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-202/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-203/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-203/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-204/meta.yaml +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-204/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-205/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-205/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-206/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-206/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-207/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-207/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-208/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-208/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-209/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-209/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-210/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-210/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-211/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-212/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-212/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-213/meta.yaml +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-213/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-214/meta.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-214/rt-lite.md +4 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-215/meta.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-215/retrospective.md +2 -0
- package/.aodw-next/tools/fixtures/root-u2a/RT/RT-215/rt-lite.md +4 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/RT-301/changelog.md +2 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/RT-301/csf-review.md +2 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/RT-301/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/RT-302/meta.yaml +4 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/RT-302/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/RT-303/meta.yaml +5 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/RT-303/rt-lite.md +2 -0
- package/.aodw-next/tools/fixtures/root-u2a-ok/RT/index.yaml +6 -0
- package/.aodw-next/tools/fixtures/root-u2b/.aodw-next/guide.md +4 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-401/notes.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-401/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-402/notes.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-402/rt-lite.md +13 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-403/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-403/sub/deep-notes.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-404/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-405/rt-lite.md +4 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-406/rt-lite.md +6 -0
- package/.aodw-next/tools/fixtures/root-u2b/RT/RT-407/rt-lite.md +3 -0
- package/.aodw-next/tools/fixtures/root-u2b/docs/a/shared.md +8 -0
- package/.aodw-next/tools/fixtures/root-u2b/docs/b/shared.md +2 -0
- package/.aodw-next/tools/fixtures/run-fixtures.sh +504 -0
- package/.aodw-next/tools/fixtures/run-skill-fixtures.sh +671 -0
- package/.aodw-next/tools/install-skills.sh +228 -0
- package/.aodw-next/tools/rt-guard.sh +1589 -0
- package/bin/aodw.js +11 -0
- package/package.json +4 -2
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# install-skills.sh — 把 AODW 自带的 skill 安装到宿主项目的 skill 目录
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# 为什么需要它:`.aodw-next/` 是可整体拷贝到其它项目的 AODW 框架目录,它自带的
|
|
6
|
+
# skill(`.aodw-next/skills/*`)跟着一起走;但各家 AI 工具是从**宿主目录**
|
|
7
|
+
# (如 `.agent/skills/` 或 `.claude/skills/`)发现 skill 的。本脚本负责把前者接到后者。
|
|
8
|
+
#
|
|
9
|
+
# 用法:
|
|
10
|
+
# bash .aodw-next/tools/install-skills.sh # 安装(默认符号链接)
|
|
11
|
+
# bash .aodw-next/tools/install-skills.sh --copy # 复制而非链接
|
|
12
|
+
# bash .aodw-next/tools/install-skills.sh --target <dir> # 指定宿主 skill 目录
|
|
13
|
+
# bash .aodw-next/tools/install-skills.sh --dry-run # 只打印将要做什么,不改动
|
|
14
|
+
# bash .aodw-next/tools/install-skills.sh --check # 只检查安装状态,不改动
|
|
15
|
+
# bash .aodw-next/tools/install-skills.sh --uninstall # 移除本脚本装过的入口
|
|
16
|
+
#
|
|
17
|
+
# 目标目录的解析优先级(**不猜宿主是哪家工具**,只按下面的顺序):
|
|
18
|
+
# --target <dir> > $AODW_SKILLS_TARGET > 已存在的 <root>/.agent/skills
|
|
19
|
+
# > 已存在的 <root>/.claude/skills > 新建 <root>/.agent/skills
|
|
20
|
+
# 项目根用 --root / $AODW_PROJECT_ROOT 指定,默认取 .aodw-next/ 的上级目录。
|
|
21
|
+
#
|
|
22
|
+
# 默认用**符号链接**:源码只有一份(在 .aodw-next/ 里),改了立刻生效,
|
|
23
|
+
# 也不会出现「宿主目录里的副本和 AODW 里的源不一致」这种老问题。
|
|
24
|
+
# 若你的环境不支持符号链接(部分 Windows / 某些同步盘),用 --copy。
|
|
25
|
+
#
|
|
26
|
+
# ── 安全约束 ────────────────────────────────────────────────────────────────
|
|
27
|
+
# 1. **绝不覆盖不是本脚本装的东西。** 目标已存在且非本脚本所建时一律跳过并报出。
|
|
28
|
+
# 2. 复制安装会在副本里留一个来源标记文件(见 MARKER),`--uninstall` **只删带
|
|
29
|
+
# 标记的副本**——宿主自己写的同名 skill 不会被误删。
|
|
30
|
+
# 3. `--dry-run` / `--check` 全程只读。
|
|
31
|
+
#
|
|
32
|
+
# 退出码:0 成功 / 1 有失败项(或 --check 发现未安装)/ 2 用法错误
|
|
33
|
+
# =============================================================================
|
|
34
|
+
set -uo pipefail
|
|
35
|
+
|
|
36
|
+
MARKER=".aodw-installed" # 复制安装的来源标记;uninstall 据此判定「是我装的」
|
|
37
|
+
|
|
38
|
+
MODE="link" # link | copy
|
|
39
|
+
ACTION="install" # install | check | uninstall
|
|
40
|
+
TARGET=""
|
|
41
|
+
ROOT_OPT=""
|
|
42
|
+
DRY_RUN=0
|
|
43
|
+
|
|
44
|
+
while [[ $# -gt 0 ]]; do
|
|
45
|
+
case "$1" in
|
|
46
|
+
--copy) MODE="copy"; shift ;;
|
|
47
|
+
--check) ACTION="check"; shift ;;
|
|
48
|
+
--uninstall) ACTION="uninstall"; shift ;;
|
|
49
|
+
--dry-run) DRY_RUN=1; shift ;;
|
|
50
|
+
--target) TARGET="${2:-}"; shift 2 ;;
|
|
51
|
+
--root) ROOT_OPT="${2:-}"; shift 2 ;;
|
|
52
|
+
-h|--help) sed -n '2,33p' "$0"; exit 0 ;;
|
|
53
|
+
*) echo "未知参数:$1(用 --help 看用法)" >&2; exit 2 ;;
|
|
54
|
+
esac
|
|
55
|
+
done
|
|
56
|
+
|
|
57
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
58
|
+
AODW_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
59
|
+
SKILLS_SRC="$AODW_DIR/skills"
|
|
60
|
+
|
|
61
|
+
if [[ -n "$ROOT_OPT" ]]; then
|
|
62
|
+
[[ -d "$ROOT_OPT" ]] || { echo "指定的 --root 不是目录:$ROOT_OPT" >&2; exit 2; }
|
|
63
|
+
PROJECT_ROOT="$(cd "$ROOT_OPT" && pwd)"
|
|
64
|
+
elif [[ -n "${AODW_PROJECT_ROOT:-}" ]]; then
|
|
65
|
+
[[ -d "$AODW_PROJECT_ROOT" ]] || {
|
|
66
|
+
echo "AODW_PROJECT_ROOT 不是目录:$AODW_PROJECT_ROOT" >&2; exit 2; }
|
|
67
|
+
PROJECT_ROOT="$(cd "$AODW_PROJECT_ROOT" && pwd)"
|
|
68
|
+
else
|
|
69
|
+
PROJECT_ROOT="$(cd "$AODW_DIR/.." && pwd)"
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
[[ -d "$SKILLS_SRC" ]] || { echo "AODW 未自带 skill($SKILLS_SRC 不存在),无需安装"; exit 0; }
|
|
73
|
+
|
|
74
|
+
# ── 探测宿主 skill 目录 ──────────────────────────────────────────────────────
|
|
75
|
+
detect_target() {
|
|
76
|
+
[[ -n "$TARGET" ]] && { echo "$TARGET"; return; }
|
|
77
|
+
[[ -n "${AODW_SKILLS_TARGET:-}" ]] && { echo "$AODW_SKILLS_TARGET"; return; }
|
|
78
|
+
for d in "$PROJECT_ROOT/.agent/skills" "$PROJECT_ROOT/.claude/skills"; do
|
|
79
|
+
[[ -d "$d" ]] && { echo "$d"; return; }
|
|
80
|
+
done
|
|
81
|
+
echo "$PROJECT_ROOT/.agent/skills" # 都不存在时的默认落点
|
|
82
|
+
}
|
|
83
|
+
TARGET_DIR="$(detect_target)"
|
|
84
|
+
|
|
85
|
+
# 相对路径展示,避免把本机绝对路径写进输出/日志
|
|
86
|
+
rel_to_root() {
|
|
87
|
+
case "$1" in
|
|
88
|
+
"$PROJECT_ROOT"/*) printf '%s' "${1#"$PROJECT_ROOT"/}" ;;
|
|
89
|
+
"$PROJECT_ROOT") printf '.' ;;
|
|
90
|
+
*) printf '%s' "$1" ;;
|
|
91
|
+
esac
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
echo "AODW skill 安装器"
|
|
95
|
+
echo " 项目根:$(rel_to_root "$PROJECT_ROOT") ($PROJECT_ROOT)"
|
|
96
|
+
echo " 源: $(rel_to_root "$SKILLS_SRC")"
|
|
97
|
+
echo " 目标: $(rel_to_root "$TARGET_DIR")"
|
|
98
|
+
echo " 模式: $([[ "$MODE" == link ]] && echo '符号链接(改源即生效)' || echo '复制')"
|
|
99
|
+
[[ $DRY_RUN -eq 1 ]] && echo " ⚠️ dry-run:以下动作**不会真的执行**"
|
|
100
|
+
echo
|
|
101
|
+
|
|
102
|
+
fails=0
|
|
103
|
+
installed=0
|
|
104
|
+
planned=0
|
|
105
|
+
|
|
106
|
+
# 判定目标是不是本脚本装的:符号链接 = 是;带 MARKER 的目录 = 是;其余 = 不是
|
|
107
|
+
is_ours() {
|
|
108
|
+
local d="$1"
|
|
109
|
+
[[ -L "$d" ]] && return 0
|
|
110
|
+
[[ -d "$d" && -f "$d/$MARKER" ]] && return 0
|
|
111
|
+
return 1
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for src in "$SKILLS_SRC"/*/; do
|
|
115
|
+
[[ -d "$src" ]] || continue
|
|
116
|
+
name="$(basename "$src")"
|
|
117
|
+
[[ -f "$src/SKILL.md" ]] || { echo " 跳过 $name(无 SKILL.md,不是合法 skill)"; continue; }
|
|
118
|
+
dst="$TARGET_DIR/$name"
|
|
119
|
+
|
|
120
|
+
case "$ACTION" in
|
|
121
|
+
check)
|
|
122
|
+
if [[ -L "$dst" ]]; then
|
|
123
|
+
printf ' %-18s 已链接 → %s\n' "$name" "$(readlink "$dst")"
|
|
124
|
+
elif [[ -d "$dst" && -f "$dst/$MARKER" ]]; then
|
|
125
|
+
printf ' %-18s 已复制(本脚本所装;源更新后需重装)\n' "$name"
|
|
126
|
+
elif [[ -d "$dst" ]]; then
|
|
127
|
+
printf ' %-18s ⚠ 目标存在但非本脚本所装(无 %s 标记)\n' "$name" "$MARKER"
|
|
128
|
+
fails=$((fails+1))
|
|
129
|
+
else
|
|
130
|
+
printf ' %-18s ✗ 未安装\n' "$name"; fails=$((fails+1))
|
|
131
|
+
fi
|
|
132
|
+
;;
|
|
133
|
+
|
|
134
|
+
uninstall)
|
|
135
|
+
if [[ -L "$dst" ]]; then
|
|
136
|
+
if [[ $DRY_RUN -eq 1 ]]; then
|
|
137
|
+
printf ' %-18s [dry-run] 将移除链接\n' "$name"; planned=$((planned+1))
|
|
138
|
+
else
|
|
139
|
+
rm -f "$dst"; printf ' %-18s 已移除链接\n' "$name"
|
|
140
|
+
fi
|
|
141
|
+
elif [[ -d "$dst" && -f "$dst/$MARKER" ]]; then
|
|
142
|
+
if [[ $DRY_RUN -eq 1 ]]; then
|
|
143
|
+
printf ' %-18s [dry-run] 将移除副本\n' "$name"; planned=$((planned+1))
|
|
144
|
+
else
|
|
145
|
+
rm -rf "$dst"; printf ' %-18s 已移除副本\n' "$name"
|
|
146
|
+
fi
|
|
147
|
+
elif [[ -e "$dst" ]]; then
|
|
148
|
+
# 关键安全项:没有来源标记 = 不是我们装的 = 绝不删
|
|
149
|
+
printf ' %-18s ⚠ 目标存在但无 %s 标记,非本脚本所装,跳过不删\n' "$name" "$MARKER"
|
|
150
|
+
fails=$((fails+1))
|
|
151
|
+
else
|
|
152
|
+
printf ' %-18s 本就未安装\n' "$name"
|
|
153
|
+
fi
|
|
154
|
+
;;
|
|
155
|
+
|
|
156
|
+
install)
|
|
157
|
+
# 已存在且不是我们装的 → 不覆盖,报出来让人决定
|
|
158
|
+
if [[ -e "$dst" ]] && ! is_ours "$dst"; then
|
|
159
|
+
printf ' %-18s ⚠ 目标已存在且非本脚本所建,跳过(如需覆盖请先手动移除)\n' "$name"
|
|
160
|
+
fails=$((fails+1)); continue
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
if [[ $DRY_RUN -eq 1 ]]; then
|
|
164
|
+
if [[ "$MODE" == "link" ]]; then
|
|
165
|
+
printf ' %-18s [dry-run] 将链接 → %s\n' "$name" "$(rel_to_root "${src%/}")"
|
|
166
|
+
else
|
|
167
|
+
printf ' %-18s [dry-run] 将复制(并写入 %s 标记)\n' "$name" "$MARKER"
|
|
168
|
+
fi
|
|
169
|
+
planned=$((planned+1)); continue
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
mkdir -p "$TARGET_DIR"
|
|
173
|
+
# 幂等:先清掉旧入口(此时已确认是我们装的),再重建
|
|
174
|
+
rm -rf "$dst"
|
|
175
|
+
|
|
176
|
+
if [[ "$MODE" == "link" ]]; then
|
|
177
|
+
# 用相对路径链接:仓库整体移动位置后仍然有效
|
|
178
|
+
rel="$(python3 -c "import os,sys;print(os.path.relpath(sys.argv[1],sys.argv[2]))" "$src" "$TARGET_DIR" 2>/dev/null)"
|
|
179
|
+
if [[ -n "$rel" ]] && ln -s "${rel%/}" "$dst" 2>/dev/null; then
|
|
180
|
+
printf ' %-18s ✓ 已链接 → %s\n' "$name" "${rel%/}"
|
|
181
|
+
elif ln -s "${src%/}" "$dst" 2>/dev/null; then
|
|
182
|
+
printf ' %-18s ✓ 已链接(绝对路径回退)\n' "$name"
|
|
183
|
+
else
|
|
184
|
+
printf ' %-18s ✗ 链接失败——改用 --copy 重试\n' "$name"; fails=$((fails+1)); continue
|
|
185
|
+
fi
|
|
186
|
+
else
|
|
187
|
+
if cp -R "${src%/}" "$dst"; then
|
|
188
|
+
# 写来源标记:uninstall 据此确认「这是我装的」,绝不误删宿主自有 skill
|
|
189
|
+
printf '%s\n' \
|
|
190
|
+
"# 本目录由 .aodw-next/tools/install-skills.sh --copy 安装,可被 --uninstall 移除。" \
|
|
191
|
+
"# 源:.aodw-next/skills/$name(改源后需重新运行安装脚本)" \
|
|
192
|
+
> "$dst/$MARKER"
|
|
193
|
+
printf ' %-18s ✓ 已复制\n' "$name"
|
|
194
|
+
else
|
|
195
|
+
printf ' %-18s ✗ 复制失败\n' "$name"; fails=$((fails+1)); continue
|
|
196
|
+
fi
|
|
197
|
+
fi
|
|
198
|
+
installed=$((installed+1))
|
|
199
|
+
;;
|
|
200
|
+
esac
|
|
201
|
+
done
|
|
202
|
+
|
|
203
|
+
echo
|
|
204
|
+
if [[ "$ACTION" == "install" ]]; then
|
|
205
|
+
if [[ $DRY_RUN -eq 1 ]]; then
|
|
206
|
+
echo " dry-run 完成:计划安装 $planned 个,将跳过 $fails 个(未做任何改动)"
|
|
207
|
+
else
|
|
208
|
+
echo " 完成:成功 $installed 个,失败 $fails 个"
|
|
209
|
+
if [[ $installed -gt 0 ]]; then
|
|
210
|
+
echo
|
|
211
|
+
echo " ⚠️ 两件事:"
|
|
212
|
+
echo " 1. 符号链接方式下,建议把 $(rel_to_root "$TARGET_DIR") 下的入口"
|
|
213
|
+
echo " **加入 .gitignore**——源已经在 .aodw-next/ 里受控,两处都跟踪会重复。"
|
|
214
|
+
echo " 2. 新会话可能需要重启才能发现新装的 skill。"
|
|
215
|
+
fi
|
|
216
|
+
fi
|
|
217
|
+
elif [[ "$ACTION" == "check" ]]; then
|
|
218
|
+
echo " 检查完成:有问题的 $fails 个"
|
|
219
|
+
elif [[ "$ACTION" == "uninstall" ]]; then
|
|
220
|
+
if [[ $DRY_RUN -eq 1 ]]; then
|
|
221
|
+
echo " dry-run 完成:计划移除 $planned 个,将跳过 $fails 个(未做任何改动)"
|
|
222
|
+
else
|
|
223
|
+
echo " 卸载完成:跳过 $fails 个(非本脚本所装的一律不删)"
|
|
224
|
+
fi
|
|
225
|
+
fi
|
|
226
|
+
|
|
227
|
+
[[ $fails -eq 0 ]] || exit 1
|
|
228
|
+
exit 0
|