aodw-skill 0.9.0 → 0.11.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/git-discipline.md +99 -52
- package/.aodw-next/02-workflow/autopilot-goal-spec.md +122 -23
- package/.aodw-next/02-workflow/autopilot-protocol.md +31 -13
- package/.aodw-next/02-workflow/orca-multi-session.md +80 -0
- package/.aodw-next/02-workflow/rt-autopilot-readiness.md +13 -10
- package/.aodw-next/02-workflow/rt-manager.md +25 -18
- package/.aodw-next/02-workflow/spec-lite-autopilot-profile.md +6 -3
- package/.aodw-next/README.md +1 -1
- package/.aodw-next/SKILL.md +1 -1
- package/.aodw-next/manifest.yaml +8 -2
- package/.aodw-next/project.yaml +4 -0
- package/.aodw-next/skills/handover-pack/scripts/_common.sh +1 -1
- package/.aodw-next/skills/handover-pack/scripts/next-number.sh +3 -3
- package/.aodw-next/skills/handover-pack/templates/handover-template.md +3 -1
- package/.aodw-next/templates/aodw-kernel-loader-template.md +1 -0
- package/.aodw-next/templates/dev-session-guide-template.md +20 -0
- package/.aodw-next/templates/main-session-handover-template.md +19 -0
- package/.aodw-next/templates/orca-handoff-template.md +30 -0
- package/.aodw-next/templates/rt-autopilot-preflight.template.md +5 -4
- package/.aodw-next/templates/rt-lite.template.md +35 -0
- package/.aodw-next/templates/rt-loop-prompt.template.md +33 -14
- package/.aodw-next/templates/rt-meta-template.yaml +2 -2
- package/.aodw-next/templates/rt-plan.template.md +22 -12
- package/.aodw-next/templates/rt-state.template.json +1 -0
- package/.aodw-next/tools/install-skills.sh +2 -2
- package/.aodw-next/tools/next-rt-id.sh +39 -0
- package/.aodw-next/tools/rt-grv-continue.sh +183 -0
- package/.aodw-next/tools/rt-guard.sh +3 -3
- package/.aodw-next/tools/worktree-gc.sh +260 -0
- package/AODW_Adapters/antigravity/.agent/rules/aodw-next.md +1 -0
- package/AODW_Adapters/claude/CLAUDE.md +1 -0
- package/AODW_Adapters/cursor/.cursor/rules/aodw-autopilot-continue.mdc +42 -0
- package/AODW_Adapters/cursor/.cursor/rules/aodw-next.mdc +1 -0
- package/AODW_Adapters/openclaw/AGENTS.md +1 -0
- package/AODW_Adapters/openclaw/SKILL.md +1 -1
- package/bin/aodw.js +85 -8
- package/bin/commands/new.js +21 -25
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 取下一个可用的 RT-ID,合并目录、索引和所有本地 Git ref 三处记录。
|
|
3
|
+
# Git 路径只取根目录 RT/ 下的第一层编号,避免把嵌套夹具编号计入。
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
root="${1:-.}"
|
|
7
|
+
cd "$root"
|
|
8
|
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then
|
|
9
|
+
printf '错误:%s 不在 Git 仓库中。\n' "$root" >&2
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
max=0
|
|
14
|
+
note_max() { [ "$1" -gt "$max" ] && max="$1"; return 0; }
|
|
15
|
+
|
|
16
|
+
# 每个来源用一条管道取最大号;任一步失败都由 pipefail 让脚本退出,不输出编号。
|
|
17
|
+
# 来源不存在(首次使用)不算失败。
|
|
18
|
+
|
|
19
|
+
# 来源 ①:工作区里的 RT 目录
|
|
20
|
+
if [ -d RT ]; then
|
|
21
|
+
n="$(find RT -maxdepth 1 -type d -name 'RT-[0-9]*' |
|
|
22
|
+
sed -nE 's|^RT/RT-0*([0-9]+)$|\1|p' | sort -n | tail -n 1)"
|
|
23
|
+
[ -z "$n" ] || note_max "$n"
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# 来源 ②:index.yaml 里的条目(含「有条目、无目录」的合法占号)
|
|
27
|
+
if [ -f RT/index.yaml ]; then
|
|
28
|
+
n="$(sed -nE "s/^[[:space:]]*-[[:space:]]+id:[[:space:]]*[\"']?RT-0*([0-9]+)[\"']?[[:space:]]*(#.*)?$/\1/p" \
|
|
29
|
+
RT/index.yaml | sort -n | tail -n 1)"
|
|
30
|
+
[ -z "$n" ] || note_max "$n"
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# 来源 ③:**所有分支**上新增过的 RT 路径——包括还没合并的 feature 分支。
|
|
34
|
+
# `--no-renames` 将改名后的路径计为新增;`--diff-merges=separate` 计入只在合并提交里新增的路径(显式写出,不受 log.diffMerges 配置影响);`--all` 覆盖本地全部 ref。
|
|
35
|
+
n="$(git -c core.quotepath=off log --all --no-renames --diff-merges=separate --diff-filter=A --name-only --pretty=format: -- 'RT/RT-*' |
|
|
36
|
+
sed -nE 's|^RT/RT-0*([0-9]+)/.*|\1|p' | sort -n | tail -n 1)"
|
|
37
|
+
[ -z "$n" ] || note_max "$n"
|
|
38
|
+
|
|
39
|
+
printf 'RT-%03d\n' "$((max + 1))"
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# rt-grv-continue.sh — Autopilot + GRV 外层续跑助手
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# 作用:根据本轮信号推进 iteration,并告诉 Agent「下一轮该干什么」。
|
|
6
|
+
# 不负责调用 LLM;供 Agent / CI / 人工在检测到 CONTINUE 后立刻开下一轮。
|
|
7
|
+
#
|
|
8
|
+
# 用法:
|
|
9
|
+
# bash .aodw-next/tools/rt-grv-continue.sh --rt RT-XXX --signal CONTINUE
|
|
10
|
+
# bash .aodw-next/tools/rt-grv-continue.sh --rt RT-XXX --signal DONE
|
|
11
|
+
# bash .aodw-next/tools/rt-grv-continue.sh --rt RT-XXX --signal blocked
|
|
12
|
+
# bash .aodw-next/tools/rt-grv-continue.sh --rt RT-XXX --status # 只读状态
|
|
13
|
+
#
|
|
14
|
+
# 退出码:
|
|
15
|
+
# 0 — CONTINUE:应立即开始下一轮(读 loop-prompt / 下一 V)
|
|
16
|
+
# 10 — DONE:全部完成,停止循环
|
|
17
|
+
# 20 — blocked:契约失效或熔断,必须交还用户
|
|
18
|
+
# 30 — 达到 max_iterations
|
|
19
|
+
# 2 — 参数/文件错误
|
|
20
|
+
# =============================================================================
|
|
21
|
+
set -euo pipefail
|
|
22
|
+
|
|
23
|
+
ROOT="."
|
|
24
|
+
RT=""
|
|
25
|
+
SIGNAL=""
|
|
26
|
+
STATUS_ONLY=0
|
|
27
|
+
|
|
28
|
+
while [[ $# -gt 0 ]]; do
|
|
29
|
+
case "$1" in
|
|
30
|
+
--root) ROOT="$2"; shift 2 ;;
|
|
31
|
+
--rt) RT="$2"; shift 2 ;;
|
|
32
|
+
--signal) SIGNAL="$2"; shift 2 ;;
|
|
33
|
+
--status) STATUS_ONLY=1; shift ;;
|
|
34
|
+
-h|--help)
|
|
35
|
+
sed -n '2,25p' "$0" | sed 's/^# \{0,1\}//'
|
|
36
|
+
exit 0
|
|
37
|
+
;;
|
|
38
|
+
*) echo "未知参数: $1" >&2; exit 2 ;;
|
|
39
|
+
esac
|
|
40
|
+
done
|
|
41
|
+
|
|
42
|
+
if [[ -z "$RT" ]]; then
|
|
43
|
+
echo "必须提供 --rt RT-XXX" >&2
|
|
44
|
+
exit 2
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
RT_DIR="$ROOT/RT/$RT"
|
|
48
|
+
STATE="$RT_DIR/state.json"
|
|
49
|
+
PLAN="$RT_DIR/rt-plan.md"
|
|
50
|
+
LITE="$RT_DIR/rt-lite.md"
|
|
51
|
+
SIGNAL_FILE="$RT_DIR/.last-signal"
|
|
52
|
+
|
|
53
|
+
if [[ ! -f "$STATE" ]]; then
|
|
54
|
+
echo "缺少 $STATE" >&2
|
|
55
|
+
exit 2
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# 用 node 读写 JSON,避免依赖 jq
|
|
59
|
+
read_state() {
|
|
60
|
+
node -e "
|
|
61
|
+
const fs=require('fs');
|
|
62
|
+
const s=JSON.parse(fs.readFileSync(process.argv[1],'utf8'));
|
|
63
|
+
const k=process.argv[2];
|
|
64
|
+
const v=k.split('.').reduce((a,c)=>a==null?undefined:a[c], s);
|
|
65
|
+
if (v===undefined||v===null) process.exit(3);
|
|
66
|
+
if (typeof v==='object') console.log(JSON.stringify(v));
|
|
67
|
+
else console.log(String(v));
|
|
68
|
+
" "$STATE" "$1"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
write_signal_and_bump() {
|
|
72
|
+
local sig="$1"
|
|
73
|
+
local bump="$2"
|
|
74
|
+
node -e "
|
|
75
|
+
const fs=require('fs');
|
|
76
|
+
const path=process.argv[1];
|
|
77
|
+
const sig=process.argv[2];
|
|
78
|
+
const bump=process.argv[3]==='1';
|
|
79
|
+
const s=JSON.parse(fs.readFileSync(path,'utf8'));
|
|
80
|
+
s.updated_at=new Date().toISOString();
|
|
81
|
+
s.last_signal=sig;
|
|
82
|
+
if (bump) {
|
|
83
|
+
s.iteration=Number(s.iteration||0)+1;
|
|
84
|
+
}
|
|
85
|
+
if (sig==='DONE') s.phase='done';
|
|
86
|
+
if (sig==='blocked') s.phase='blocked';
|
|
87
|
+
if (sig==='CONTINUE' && s.phase!=='implementing' && s.phase!=='blocked' && s.phase!=='done') {
|
|
88
|
+
s.phase='implementing';
|
|
89
|
+
}
|
|
90
|
+
fs.writeFileSync(path, JSON.stringify(s,null,2)+'\n');
|
|
91
|
+
console.log([s.iteration, s.max_iterations||20, s.phase].join('\t'));
|
|
92
|
+
" "$STATE" "$sig" "$bump"
|
|
93
|
+
echo "$sig" > "$SIGNAL_FILE"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
iteration=$(read_state iteration 2>/dev/null || echo 0)
|
|
97
|
+
max_iter=$(read_state max_iterations 2>/dev/null || echo 20)
|
|
98
|
+
phase=$(read_state phase 2>/dev/null || echo unknown)
|
|
99
|
+
|
|
100
|
+
echo "RT=$RT phase=$phase iteration=$iteration/$max_iter"
|
|
101
|
+
|
|
102
|
+
if [[ "$STATUS_ONLY" -eq 1 ]]; then
|
|
103
|
+
if [[ -f "$SIGNAL_FILE" ]]; then
|
|
104
|
+
echo "last_signal=$(cat "$SIGNAL_FILE")"
|
|
105
|
+
fi
|
|
106
|
+
# 提示下一未完成 V(启发式:rt-plan 中第一个未勾选行)
|
|
107
|
+
if [[ -f "$PLAN" ]]; then
|
|
108
|
+
next=$(grep -E '^\| \[ \] \|' "$PLAN" | head -1 || true)
|
|
109
|
+
if [[ -n "$next" ]]; then
|
|
110
|
+
echo "next_open_v_row=$next"
|
|
111
|
+
else
|
|
112
|
+
echo "next_open_v_row=(none or different table format)"
|
|
113
|
+
fi
|
|
114
|
+
fi
|
|
115
|
+
exit 0
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
if [[ -z "$SIGNAL" ]]; then
|
|
119
|
+
echo "必须提供 --signal CONTINUE|DONE|blocked" >&2
|
|
120
|
+
exit 2
|
|
121
|
+
fi
|
|
122
|
+
|
|
123
|
+
case "$SIGNAL" in
|
|
124
|
+
CONTINUE|DONE|blocked) ;;
|
|
125
|
+
*) echo "signal 必须是 CONTINUE|DONE|blocked" >&2; exit 2 ;;
|
|
126
|
+
esac
|
|
127
|
+
|
|
128
|
+
# 已达上限且还要 CONTINUE → 强制 blocked
|
|
129
|
+
if [[ "$SIGNAL" == "CONTINUE" ]]; then
|
|
130
|
+
if [[ "$iteration" -ge "$max_iter" ]]; then
|
|
131
|
+
SIGNAL=blocked
|
|
132
|
+
echo "已达 max_iterations=${max_iter}, 改为 blocked(交还用户)"
|
|
133
|
+
fi
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
bump=0
|
|
137
|
+
[[ "$SIGNAL" == "CONTINUE" ]] && bump=1
|
|
138
|
+
out=$(write_signal_and_bump "$SIGNAL" "$bump")
|
|
139
|
+
new_iter=$(echo "$out" | cut -f1)
|
|
140
|
+
new_max=$(echo "$out" | cut -f2)
|
|
141
|
+
new_phase=$(echo "$out" | cut -f3)
|
|
142
|
+
|
|
143
|
+
echo "updated: iteration=$new_iter/$new_max phase=$new_phase signal=$SIGNAL"
|
|
144
|
+
|
|
145
|
+
case "$SIGNAL" in
|
|
146
|
+
CONTINUE)
|
|
147
|
+
cat <<EOF
|
|
148
|
+
|
|
149
|
+
== 外层续跑指令(给 Agent)==
|
|
150
|
+
立即开始第 ${new_iter} 轮,不要询问用户是否继续:
|
|
151
|
+
1. 读取 $LITE §1.5(G/R/V)与 $PLAN 下一未勾选 V
|
|
152
|
+
2. 按 $RT_DIR/loop-prompt.md 执行(只做该 V)
|
|
153
|
+
3. 跑对应 R 验收 + §5.4 tests/lint/guard
|
|
154
|
+
4. 更新 state.json / rt-plan.md / execution-log.md
|
|
155
|
+
5. 结束时输出 CONTINUE(下一 V)或 DONE 或说明后 blocked
|
|
156
|
+
然后再次执行:
|
|
157
|
+
bash .aodw-next/tools/rt-grv-continue.sh --root $ROOT --rt $RT --signal <CONTINUE|DONE|blocked>
|
|
158
|
+
|
|
159
|
+
EOF
|
|
160
|
+
exit 0
|
|
161
|
+
;;
|
|
162
|
+
DONE)
|
|
163
|
+
cat <<EOF
|
|
164
|
+
|
|
165
|
+
== 完成 ==
|
|
166
|
+
全部 V/R 应已验收。请核对 checklist、关闭 meta.yaml.status=done,输出发布/收口摘要。
|
|
167
|
+
停止自动续跑。
|
|
168
|
+
|
|
169
|
+
EOF
|
|
170
|
+
exit 10
|
|
171
|
+
;;
|
|
172
|
+
blocked)
|
|
173
|
+
cat <<EOF
|
|
174
|
+
|
|
175
|
+
== 熔断 / blocked ==
|
|
176
|
+
停止自动续跑。按 autopilot-goal-spec.md §9.6 向用户给出:
|
|
177
|
+
A 修订契约 / B 拆 RT / C 暂停 / D 中止
|
|
178
|
+
禁止静默改 GRV 继续做。
|
|
179
|
+
|
|
180
|
+
EOF
|
|
181
|
+
exit 20
|
|
182
|
+
;;
|
|
183
|
+
esac
|
|
@@ -1076,7 +1076,7 @@ rtg_check_xref_doc_refs_resolve() { # 判据 10(G110):RT 目录内 .md 交
|
|
|
1076
1076
|
out="$(rtg_xref_scan "$root" "$rt_id" summary 0 "$exts")" || rc=$?
|
|
1077
1077
|
if (( rc != 0 && rc != 10 )); then
|
|
1078
1078
|
# 扫描器崩溃不是判据结果——与 rt-gates.yaml 不同步同类,fail-closed
|
|
1079
|
-
rtg_die "交叉引用扫描器内部错误(rc=$rc,见上方 stderr)"
|
|
1079
|
+
rtg_die "交叉引用扫描器内部错误(rc=${rc},见上方 stderr)"
|
|
1080
1080
|
fi
|
|
1081
1081
|
printf '%s' "$out"
|
|
1082
1082
|
(( rc == 0 )) && return 0
|
|
@@ -1235,7 +1235,7 @@ rtg_dispatch_check() { # $1=impl $2=root $3=RT-ID $4=param;未知 impl → die
|
|
|
1235
1235
|
deferred.refs_resolve) rtg_check_deferred_refs_resolve "$2" "$3" ;;
|
|
1236
1236
|
deferred.claims_resolve) rtg_check_deferred_claims_resolve "$2" "$3" ;;
|
|
1237
1237
|
handoff.criteria_declared) rtg_check_handoff_criteria_declared "$2" "$3" ;;
|
|
1238
|
-
*) rtg_die "判据 impl 未实现: $impl(rt-gates.yaml 与脚本不同步,fail-closed)" ;;
|
|
1238
|
+
*) rtg_die "判据 impl 未实现: ${impl}(rt-gates.yaml 与脚本不同步,fail-closed)" ;;
|
|
1239
1239
|
esac
|
|
1240
1240
|
}
|
|
1241
1241
|
|
|
@@ -1357,7 +1357,7 @@ rtg_run_scan_refs() {
|
|
|
1357
1357
|
local rc=0
|
|
1358
1358
|
rtg_xref_scan "$RTG_ROOT" "$RTG_RT" detail "$RTG_SCAN_RULES" "$exts" || rc=$?
|
|
1359
1359
|
if (( rc != 0 && rc != 10 )); then
|
|
1360
|
-
rtg_die "交叉引用扫描器内部错误(rc=$rc,见上方 stderr)"
|
|
1360
|
+
rtg_die "交叉引用扫描器内部错误(rc=${rc},见上方 stderr)"
|
|
1361
1361
|
fi
|
|
1362
1362
|
if (( rc == 10 )); then
|
|
1363
1363
|
printf 'rt-guard: ⚠ 交叉引用存在悬空(G110 告警级不阻断,exit 0)\n' >&2
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 默认只报告。--apply 清理默认工作树目录内通过全部核对的工作树。
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
# 按字节解析路径,避免 macOS awk 在本地化排序下将不同中文路径判为相等。
|
|
5
|
+
export LC_ALL=C
|
|
6
|
+
apply=0
|
|
7
|
+
while [ "$#" -gt 0 ]; do
|
|
8
|
+
case "$1" in
|
|
9
|
+
--apply) apply=1; shift ;;
|
|
10
|
+
*) echo '用法:bash .aodw-next/tools/worktree-gc.sh [--apply]' >&2; exit 2 ;;
|
|
11
|
+
esac
|
|
12
|
+
done
|
|
13
|
+
base_ref="$(git symbolic-ref --quiet refs/remotes/origin/HEAD || printf '%s\n' refs/remotes/origin/main)"
|
|
14
|
+
trunk="${base_ref#refs/remotes/origin/}"
|
|
15
|
+
if ! base="$(git rev-parse --verify --quiet "${base_ref}^{commit}")"; then
|
|
16
|
+
printf '错误:无法解析 %s。请先运行 git fetch origin,再运行 git remote set-head origin -a。\n' "$base_ref" >&2
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
printf '本地 origin/%s:%s %s(未自动 fetch;需要更新时请先自行 fetch)\n' \
|
|
20
|
+
"$trunk" "$(git rev-parse --short "$base")" "$(git show -s --format=%cI "$base")"
|
|
21
|
+
tmp="$(mktemp -d "${TMPDIR:-/tmp}/aodw-worktree-gc-XXXXXX")"
|
|
22
|
+
trap 'rm -rf "$tmp"' EXIT
|
|
23
|
+
read_worktrees() {
|
|
24
|
+
local field worktree
|
|
25
|
+
paths=()
|
|
26
|
+
git worktree list --porcelain -z > "$tmp/worktrees"
|
|
27
|
+
while IFS= read -r -d '' field; do
|
|
28
|
+
case "$field" in
|
|
29
|
+
worktree\ *)
|
|
30
|
+
worktree=${field#worktree }
|
|
31
|
+
if [ -d "$worktree" ]; then worktree="$(cd -P "$worktree" && pwd -P)"; fi
|
|
32
|
+
paths[${#paths[@]}]=$worktree ;;
|
|
33
|
+
esac
|
|
34
|
+
done < "$tmp/worktrees"
|
|
35
|
+
}
|
|
36
|
+
read_worktrees
|
|
37
|
+
main=${paths[0]}
|
|
38
|
+
|
|
39
|
+
# 只读取 PID、命令名、cwd;命令失败或没有结果都不能推断为无人使用。
|
|
40
|
+
read_processes() {
|
|
41
|
+
# lsof 在 C locale 会转义中文路径,采集时保持 UTF-8,比较时仍按字节。
|
|
42
|
+
if ! LC_ALL=en_US.UTF-8 lsof -a -d cwd -Fpcn > "$tmp/cwd" || [ ! -s "$tmp/cwd" ]; then
|
|
43
|
+
echo '错误:无法取得进程 cwd,停止清理。' >&2
|
|
44
|
+
return 1
|
|
45
|
+
fi
|
|
46
|
+
}
|
|
47
|
+
read_processes
|
|
48
|
+
|
|
49
|
+
# 仅扫描顶层软链;用物理目录解析相对目标和多级软链,兼容 macOS bash 3.2。
|
|
50
|
+
IFS=: read -r -a skill_dirs <<< "${WORKTREE_GC_SKILL_DIRS-$HOME/.claude/skills:$HOME/.codex/skills:$HOME/.agents/skills:$HOME/.cursor/skills}"
|
|
51
|
+
read_skill_links() {
|
|
52
|
+
local directory link target value owner worktree
|
|
53
|
+
skill_links=(); skill_owners=()
|
|
54
|
+
if [ "${#skill_dirs[@]}" -eq 0 ]; then return 0; fi
|
|
55
|
+
for directory in "${skill_dirs[@]}"; do
|
|
56
|
+
[ -d "$directory" ] || continue
|
|
57
|
+
for link in "$directory"/* "$directory"/.[!.]* "$directory"/..?*; do
|
|
58
|
+
[ -L "$link" ] && [ -e "$link" ] || continue
|
|
59
|
+
target=$link
|
|
60
|
+
while [ -L "$target" ]; do
|
|
61
|
+
value="$(readlink "$target")"
|
|
62
|
+
case "$value" in /*) target=$value ;; *) target=${target%/*}/$value ;; esac
|
|
63
|
+
done
|
|
64
|
+
if [ -d "$target" ]; then
|
|
65
|
+
target="$(cd -P "$target" && pwd -P)"
|
|
66
|
+
else
|
|
67
|
+
target="$(cd -P "${target%/*}" && pwd -P)/${target##*/}"
|
|
68
|
+
fi
|
|
69
|
+
owner=''
|
|
70
|
+
for worktree in "${paths[@]}"; do
|
|
71
|
+
case "$target" in
|
|
72
|
+
"$worktree"|"$worktree"/*)
|
|
73
|
+
if [ "${#worktree}" -gt "${#owner}" ]; then owner=$worktree; fi ;;
|
|
74
|
+
esac
|
|
75
|
+
done
|
|
76
|
+
skill_links[${#skill_links[@]}]=$link
|
|
77
|
+
skill_owners[${#skill_owners[@]}]=$owner
|
|
78
|
+
done
|
|
79
|
+
done
|
|
80
|
+
}
|
|
81
|
+
read_skill_links
|
|
82
|
+
|
|
83
|
+
# 列表和每次删除共用同一核对,外部工作树也完整计算四条结论。
|
|
84
|
+
check_worktree() {
|
|
85
|
+
local worktree nested=''
|
|
86
|
+
if [ ! -d "$path" ]; then
|
|
87
|
+
branch='不可用'; class=5; reason='工作树目录不存在,可运行 git worktree prune'
|
|
88
|
+
return 0
|
|
89
|
+
fi
|
|
90
|
+
branch="$(git -C "$path" symbolic-ref --quiet --short HEAD || true)"
|
|
91
|
+
head="$(git -C "$path" rev-parse HEAD)"
|
|
92
|
+
merged=0; dirty=0; force=0; changes=0
|
|
93
|
+
reason='未合入'
|
|
94
|
+
if git merge-base --is-ancestor "$head" "$base"; then merged=1; reason='已合入'; fi
|
|
95
|
+
git --no-optional-locks -C "$path" status --porcelain -z --untracked-files=all > "$tmp/status"
|
|
96
|
+
while IFS= read -r -d '' entry; do
|
|
97
|
+
changes=$((changes + 1))
|
|
98
|
+
untracked=${entry#???}; untracked=${untracked%/}
|
|
99
|
+
case "$entry" in
|
|
100
|
+
'?? '*)
|
|
101
|
+
case "$untracked" in
|
|
102
|
+
node_modules/*) untracked=node_modules ;;
|
|
103
|
+
*/node_modules/*) untracked=${untracked%%/node_modules/*}/node_modules ;;
|
|
104
|
+
esac
|
|
105
|
+
case "$untracked" in node_modules|*/node_modules)
|
|
106
|
+
if [ -d "$path/$untracked" ] || [ -L "$path/$untracked" ]; then
|
|
107
|
+
force=1; continue
|
|
108
|
+
fi ;;
|
|
109
|
+
esac ;;
|
|
110
|
+
R*|?R*|C*|?C*) IFS= read -r -d '' source ;;
|
|
111
|
+
esac
|
|
112
|
+
dirty=1
|
|
113
|
+
done < "$tmp/status"
|
|
114
|
+
if [ "$dirty" -eq 1 ]; then reason="${reason}、有未提交改动";
|
|
115
|
+
elif [ "$force" -eq 1 ]; then reason="${reason}、无改动(仅有未跟踪 node_modules)";
|
|
116
|
+
else reason="${reason}、无改动"; fi
|
|
117
|
+
busy="$(awk -v root="$path" '
|
|
118
|
+
BEGIN {for (i=2; i<ARGC; i++) {roots[i]=ARGV[i]; delete ARGV[i]}}
|
|
119
|
+
/^p/ {pid=substr($0,2)} /^c/ {command=substr($0,2)}
|
|
120
|
+
/^n/ {
|
|
121
|
+
cwd=substr($0,2); owner=""
|
|
122
|
+
for (i in roots)
|
|
123
|
+
if ((cwd == roots[i] || index(cwd,roots[i] "/") == 1) &&
|
|
124
|
+
length(roots[i]) > length(owner)) owner=roots[i]
|
|
125
|
+
if (owner == root) {
|
|
126
|
+
count++
|
|
127
|
+
if (count <= 3) summary=summary (count > 1 ? "; " : "") "PID " pid " " command
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
END {if (count) printf "%d 个:%s%s", count, summary, (count > 3 ? " 等" : "")}
|
|
131
|
+
' "$tmp/cwd" "${paths[@]}")"
|
|
132
|
+
if [ -n "$busy" ]; then reason="${reason}、有进程在用(${busy})";
|
|
133
|
+
else reason="${reason}、无进程"; fi
|
|
134
|
+
keep=''
|
|
135
|
+
for ((k=0; k<${#skill_links[@]}; k++)); do
|
|
136
|
+
if [ "${skill_owners[$k]}" = "$path" ]; then
|
|
137
|
+
keep="${keep}被 Skill 软链引用:${skill_links[$k]};"
|
|
138
|
+
fi
|
|
139
|
+
done
|
|
140
|
+
class=0
|
|
141
|
+
if [ "$path" = "$main" ]; then
|
|
142
|
+
class=1; reason="${reason}、主目录"
|
|
143
|
+
else
|
|
144
|
+
reason="${reason}、不是主目录"
|
|
145
|
+
for worktree in "${paths[@]}"; do
|
|
146
|
+
case "$worktree" in
|
|
147
|
+
"$path"/*) nested="${nested}内含工作树:${worktree};" ;;
|
|
148
|
+
esac
|
|
149
|
+
done
|
|
150
|
+
case "$path" in
|
|
151
|
+
"$main"/.claude/worktrees/*)
|
|
152
|
+
if [ -n "$keep" ]; then class=1;
|
|
153
|
+
elif [ "$merged" -eq 0 ]; then class=2;
|
|
154
|
+
elif [ "$dirty" -eq 1 ]; then class=3;
|
|
155
|
+
elif [ -n "$busy" ]; then class=4; fi ;;
|
|
156
|
+
*) class=5; reason="${reason}(可由所属会话收尾)" ;;
|
|
157
|
+
esac
|
|
158
|
+
if [ -n "$nested" ]; then class=1; keep="${keep}${nested}"; fi
|
|
159
|
+
fi
|
|
160
|
+
if [ -n "$keep" ]; then reason="${reason};$keep"; fi
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
labels=('可删' '保留' '未合入' '有未提交改动' '有进程在用' '仓库外/失效')
|
|
164
|
+
lines=('' '' '' '' '' '')
|
|
165
|
+
candidates=()
|
|
166
|
+
for path in "${paths[@]}"; do
|
|
167
|
+
check_worktree
|
|
168
|
+
if [ "$path" = "$main" ]; then main_branch=${branch:-分离 HEAD}; main_changes=$changes; fi
|
|
169
|
+
if [ "$class" -eq 0 ]; then candidates[${#candidates[@]}]=$path; fi
|
|
170
|
+
lines[$class]="${lines[$class]}${path} | ${branch:-分离 HEAD} | ${reason}"$'\n'
|
|
171
|
+
done
|
|
172
|
+
for ((i=0; i<${#labels[@]}; i++)); do
|
|
173
|
+
printf '【%s】\n%s' "${labels[$i]}" "${lines[$i]}"
|
|
174
|
+
done
|
|
175
|
+
echo '【主目录】'
|
|
176
|
+
behind="$(git -C "$main" rev-list --count "HEAD..$base")"
|
|
177
|
+
ahead="$(git -C "$main" rev-list --count "$base..HEAD")"
|
|
178
|
+
printf '%s | %s | 落后 origin/%s %s 个提交、领先 origin/%s %s 个提交、未提交改动 %s 项\n' \
|
|
179
|
+
"$main" "$main_branch" "$trunk" "$behind" "$trunk" "$ahead" "$main_changes"
|
|
180
|
+
|
|
181
|
+
now="$(date +%s)"
|
|
182
|
+
unmerged=''; suspicious=''
|
|
183
|
+
git for-each-ref --format='%(refname:short)%09%(committerdate:unix)%09%(committerdate:iso8601)' refs/heads/ > "$tmp/branches"
|
|
184
|
+
while IFS=$'\t' read -r branch timestamp date; do
|
|
185
|
+
[ "$branch" != "$trunk" ] || continue
|
|
186
|
+
if ! git merge-base --is-ancestor "refs/heads/$branch" "$base"; then
|
|
187
|
+
unmerged="${unmerged}${branch} | 最后提交 ${date}"$'\n'
|
|
188
|
+
fi
|
|
189
|
+
behind="$(git rev-list --count "refs/heads/$branch..$base")"
|
|
190
|
+
if [ "$((now - timestamp))" -gt 604800 ] || [ "$behind" -gt 50 ]; then
|
|
191
|
+
suspicious="${suspicious}${branch} | 最后提交 ${date} | 落后 origin/${trunk} ${behind} 个提交"$'\n'
|
|
192
|
+
fi
|
|
193
|
+
done < "$tmp/branches"
|
|
194
|
+
printf '【未合入的本地分支】\n%s【可疑分支】\n%s' "$unmerged" "$suspicious"
|
|
195
|
+
|
|
196
|
+
echo '【已打完成标签但未关单】'
|
|
197
|
+
index="$main/RT/index.yaml"
|
|
198
|
+
[ -f "$index" ] || index=/dev/null
|
|
199
|
+
awk '
|
|
200
|
+
/^[[:space:]]*-[[:space:]]+id:[[:space:]]*/ {
|
|
201
|
+
id=$0; sub(/^.*id:[[:space:]]*/,"",id); sub(/[[:space:]]*(#.*)?$/, "", id)
|
|
202
|
+
gsub(/^["\047]|["\047]$/, "", id)
|
|
203
|
+
}
|
|
204
|
+
/^[[:space:]]*status:[[:space:]]*/ {
|
|
205
|
+
s=$0; sub(/^.*status:[[:space:]]*/,"",s); sub(/[[:space:]]*(#.*)?$/, "", s)
|
|
206
|
+
if (id != "") print id "\t" s
|
|
207
|
+
}
|
|
208
|
+
' "$index" > "$tmp/statuses"
|
|
209
|
+
git tag --list 'done-RT-*' > "$tmp/tags"
|
|
210
|
+
while IFS= read -r tag; do
|
|
211
|
+
[[ "$tag" =~ ^done-RT-[0-9]+$ ]] || continue
|
|
212
|
+
id=${tag#done-}
|
|
213
|
+
index_status="$(awk -F '\t' -v id="$id" '$1 == id {print $2}' "$tmp/statuses")"
|
|
214
|
+
meta_status='无 meta'; meta="$main/RT/$id/meta.yaml"
|
|
215
|
+
if [ -f "$meta" ]; then
|
|
216
|
+
meta_status="$(awk '/^[[:space:]]*status:[[:space:]]*/ {
|
|
217
|
+
sub(/^.*status:[[:space:]]*/, ""); sub(/[[:space:]]*(#.*)?$/, ""); print; exit
|
|
218
|
+
}' "$meta")"
|
|
219
|
+
fi
|
|
220
|
+
if [ "$index_status" != done ] || { [ -f "$meta" ] && [ "$meta_status" != done ]; }; then
|
|
221
|
+
printf '%s | index: %s | meta: %s\n' "$id" "${index_status:-未登记}" "${meta_status:-未登记}"
|
|
222
|
+
fi
|
|
223
|
+
done < "$tmp/tags"
|
|
224
|
+
|
|
225
|
+
failed=0
|
|
226
|
+
if [ "$apply" -eq 1 ]; then
|
|
227
|
+
echo '【执行清理】'
|
|
228
|
+
# bash 3.2 的 nounset 不接受空数组展开。
|
|
229
|
+
if [ "${#candidates[@]}" -gt 0 ]; then
|
|
230
|
+
for path in "${candidates[@]}"; do
|
|
231
|
+
read_processes
|
|
232
|
+
read_worktrees
|
|
233
|
+
read_skill_links
|
|
234
|
+
check_worktree
|
|
235
|
+
if [ "$class" -ne 0 ]; then echo "跳过:${path} | ${reason}"; continue; fi
|
|
236
|
+
options=(remove)
|
|
237
|
+
if [ "$force" -eq 1 ]; then options=(remove --force); fi
|
|
238
|
+
if git worktree "${options[@]}" "$path" > "$tmp/delete" 2>&1; then
|
|
239
|
+
echo "已删除工作树:${path}"
|
|
240
|
+
if [ -n "$branch" ]; then
|
|
241
|
+
if git branch -d "$branch" > "$tmp/delete" 2>&1; then
|
|
242
|
+
echo "已删除本地分支:${branch}"
|
|
243
|
+
else
|
|
244
|
+
echo "本地分支删除失败(保留,不强删):${branch}"
|
|
245
|
+
cat "$tmp/delete"; failed=1
|
|
246
|
+
fi
|
|
247
|
+
fi
|
|
248
|
+
else
|
|
249
|
+
echo "工作树删除失败(保留分支):${path}"
|
|
250
|
+
cat "$tmp/delete"; failed=1
|
|
251
|
+
fi
|
|
252
|
+
done
|
|
253
|
+
fi
|
|
254
|
+
merged_branches="$(git for-each-ref --merged="$base" \
|
|
255
|
+
--format='%(if)%(worktreepath)%(then)%(else)%(refname:lstrip=2)%(end)' refs/heads/feature/ | sed '/^$/d')"
|
|
256
|
+
if [ -n "$merged_branches" ]; then
|
|
257
|
+
printf '已合入、未被任何工作树检出的本地分支:\n%s\n先确认本 RT 的 detached 工作树已删除,再用 git branch -d 删除对应分支。\n' "$merged_branches"
|
|
258
|
+
fi
|
|
259
|
+
fi
|
|
260
|
+
exit "$failed"
|
|
@@ -70,6 +70,7 @@ trigger: always_on
|
|
|
70
70
|
- 代码修改完成后,必须展示 git status 和关键 diff
|
|
71
71
|
- 询问用户"修改已完成,是否提交?"
|
|
72
72
|
- 严禁未获用户确认前直接 Commit
|
|
73
|
+
- **Autopilot 例外**:当 RT `meta.yaml` 含 `autopilot: true` 且 GRV 已用户确认、`phase=implementing` 时,由机械 Gate(tests/lint/guard)替代本条「询问是否提交」;轮末用 `CONTINUE`/`DONE`/`blocked` + `rt-grv-continue.sh` 续跑,禁止停问是否继续。详见 `.aodw-next/02-workflow/autopilot-protocol.md`。
|
|
73
74
|
|
|
74
75
|
## 5. 兜底机制
|
|
75
76
|
如果你无法读取 .aodw-next/01-core/aodw-constitution.md,请立即停止并要求用户提供该文件。
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
- 代码修改完成后,必须展示 git status 和关键 diff
|
|
67
67
|
- 询问用户"修改已完成,是否提交?"
|
|
68
68
|
- 严禁未获用户确认前直接 Commit
|
|
69
|
+
- **Autopilot 例外**:当 RT `meta.yaml` 含 `autopilot: true` 且 GRV 已用户确认、`phase=implementing` 时,由机械 Gate(tests/lint/guard)替代本条「询问是否提交」;轮末用 `CONTINUE`/`DONE`/`blocked` + `rt-grv-continue.sh` 续跑,禁止停问是否继续。详见 `.aodw-next/02-workflow/autopilot-protocol.md`。
|
|
69
70
|
|
|
70
71
|
## 5. 兜底机制
|
|
71
72
|
如果你无法读取 .aodw-next/01-core/aodw-constitution.md,请立即停止并要求用户提供该文件。
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Autopilot+GRV 续跑——CONTINUE 立即下一 V,禁止停问是否继续
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Autopilot + GRV 续跑硬规则
|
|
7
|
+
|
|
8
|
+
当当前 RT 的 `meta.yaml` 含 `autopilot: true`,且 `rt-lite.md` §1.5 **G/R/V 已用户确认**(`grv_user_confirmed: true` 或 §1.5 明确「已确认」)时,本规则**覆盖**协同门禁里「每步先问用户」的停顿习惯。
|
|
9
|
+
|
|
10
|
+
## 必须立刻续跑(禁止停问)
|
|
11
|
+
|
|
12
|
+
本轮输出含 **`CONTINUE`**(或用户/脚本刚写入 `.last-signal=CONTINUE`)时:
|
|
13
|
+
|
|
14
|
+
1. **禁止**问「要不要继续 / 要不要做下一 V / 要不要提交」
|
|
15
|
+
2. **立即**执行:
|
|
16
|
+
```bash
|
|
17
|
+
bash .aodw-next/tools/rt-grv-continue.sh --rt <RT-ID> --signal CONTINUE
|
|
18
|
+
```
|
|
19
|
+
3. 按脚本打印的「外层续跑指令」读下一未勾选 V + `loop-prompt.md`,开下一轮
|
|
20
|
+
4. 一轮只做一个 V;验收通过再更新 `rt-plan` / `state.json` / `execution-log`
|
|
21
|
+
5. 本轮结束必须再输出 **CONTINUE** / **DONE** / **blocked** 三选一,并再次调用 `rt-grv-continue.sh --signal …`
|
|
22
|
+
|
|
23
|
+
## 必须停(允许且应当交还用户)
|
|
24
|
+
|
|
25
|
+
- 输出 **`DONE`**:收口摘要后停止
|
|
26
|
+
- 输出 **`blocked`** 或触发 §9.6 熔断:只给 A/B/C/D,禁止静默改 GRV 继续做
|
|
27
|
+
- `iteration >= max_iterations`:脚本会改为 `blocked`
|
|
28
|
+
|
|
29
|
+
## 与协同门禁的关系
|
|
30
|
+
|
|
31
|
+
| 场景 | 行为 |
|
|
32
|
+
|------|------|
|
|
33
|
+
| Autopilot + GRV 已确认 + implementing | 实现/验收/续跑**不问**;用 CONTINUE 驱动 |
|
|
34
|
+
| Autopilot 但 GRV 未确认 | **禁止**写业务代码;先共写 §1.5 |
|
|
35
|
+
| 非 Autopilot | 仍走协同门禁(方案确认、提交确认等) |
|
|
36
|
+
| blocked / DONE | 必须交还用户 |
|
|
37
|
+
|
|
38
|
+
## 信号语义(与 loop-prompt / goal-spec 一致)
|
|
39
|
+
|
|
40
|
+
- **CONTINUE**:还有未勾选 V,或本 V 未过验收需再一轮(同 V 重试也算 CONTINUE)
|
|
41
|
+
- **DONE**:全部 V 勾选且对应 R 验收通过
|
|
42
|
+
- **blocked**:契约失效、熔断、达上限、或无法在不改 GRV 下继续
|
|
@@ -73,6 +73,7 @@ tags: aodw, kernel
|
|
|
73
73
|
- 代码修改完成后,必须展示 git status 和关键 diff
|
|
74
74
|
- 询问用户"修改已完成,是否提交?"
|
|
75
75
|
- 严禁未获用户确认前直接 Commit
|
|
76
|
+
- **Autopilot 例外**:当 RT `meta.yaml` 含 `autopilot: true` 且 GRV 已用户确认、`phase=implementing` 时,由机械 Gate(tests/lint/guard)替代本条「询问是否提交」;轮末用 `CONTINUE`/`DONE`/`blocked` + `rt-grv-continue.sh` 续跑,禁止停问是否继续。详见 `autopilot-protocol.md` 与 Cursor 规则 `aodw-autopilot-continue`。
|
|
76
77
|
|
|
77
78
|
## 5. 兜底机制
|
|
78
79
|
如果你无法读取 @.aodw-next/01-core/aodw-constitution.md,请立即停止并要求用户提供该文件。
|
|
@@ -65,6 +65,7 @@ AODW 定义了文档驱动的开发流程:
|
|
|
65
65
|
- **Spec-Full**: 完整规范流程(复杂功能)
|
|
66
66
|
- **Spec-Lite**: 简化规范流程(小改动)
|
|
67
67
|
- **Spec-Lite Autopilot**: 在 `rt-lite.md` 外还必须具备 7 件套:`meta.yaml`、`rt-plan.md`、`state.json`、`loop-prompt.md`、`execution-log.md`、`autopilot-preflight.md`
|
|
68
|
+
- **Autopilot 续跑**: GRV 已确认后,轮末输出 `CONTINUE`/`DONE`/`blocked` 并执行 `bash .aodw-next/tools/rt-grv-continue.sh --rt <RT-ID> --signal …`;exit 0 则立即下一 V,禁止问「要不要继续」
|
|
68
69
|
|
|
69
70
|
### 3.3 分析阶段
|
|
70
71
|
- 影响分析 (impact.md)
|
|
@@ -54,7 +54,7 @@ AODW 规则系统采用渐进式加载策略。所有规则的元数据定义在
|
|
|
54
54
|
|---------|---------|------|
|
|
55
55
|
| **创建新 RT** | `.aodw-next/02-workflow/rt-manager.md` (Sec 1-4, 8-9)<br>`.aodw-next/01-core/ai-knowledge-rules.md` (Sec 3.1)<br>`.aodw-next/01-core/ai-interaction-rules.md` (Sec 1-4) | 生成 RT-ID,创建目录,Intake 流程 |
|
|
56
56
|
| **选择模式** | `.aodw-next/02-workflow/rt-manager.md` (Sec 5)<br>`.aodw-next/02-workflow/spec-full-profile.md`<br>`.aodw-next/02-workflow/spec-lite-profile.md` | 决策 Spec-Full/Spec-Lite,创建分支 |
|
|
57
|
-
| **Spec-Lite Autopilot** | `.aodw-next/02-workflow/spec-lite-autopilot-profile.md`<br>`.aodw-next/02-workflow/autopilot-protocol.md`<br>`.aodw-next/02-workflow/rt-autopilot-readiness.md`<br>`.aodw-next/01-core/git-discipline.md` | 全自动:机械 Gate + Ralph
|
|
57
|
+
| **Spec-Lite Autopilot** | `.aodw-next/02-workflow/spec-lite-autopilot-profile.md`<br>`.aodw-next/02-workflow/autopilot-protocol.md`<br>`.aodw-next/02-workflow/rt-autopilot-readiness.md`<br>`.aodw-next/01-core/git-discipline.md` | 全自动:机械 Gate + Ralph + GRV;轮末 `rt-grv-continue.sh` 续跑;强制 7 件套 |
|
|
58
58
|
| **工具初始化** | `.aodw-next/05-tooling/ai-tools-init-rules.md` | 初始化开发工具(ESLint、Prettier、Ruff、Black 等) |
|
|
59
59
|
| **项目概览初始化** | `.aodw-next/01-core/ai-project-overview-rules.md` | 初始化或完善项目概览信息(技术栈、架构、模块等) |
|
|
60
60
|
| **分析阶段** | `.aodw-next/03-standards/ai-coding-rules.md` (Sec 2-3)<br>`.aodw-next/01-core/ai-knowledge-rules.md` (Sec 3.4) | 影响分析、不变量检查,更新 impact.md, invariants.md |
|