@jeiemgi/cckit 0.7.1 → 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/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +15 -4
- package/README.md +25 -3
- package/bin/cckit +91 -8
- package/cckit.config.json +1 -1
- package/kit.config.schema.json +43 -2
- package/package.json +1 -1
- package/scripts/autopilot-test.sh +68 -0
- package/scripts/autopilot.sh +16 -10
- package/scripts/check.sh +14 -1
- package/scripts/copilot-loop-test.sh +3 -0
- package/scripts/guard-raw-git-ops-test.sh +73 -0
- package/scripts/init.sh +68 -8
- package/scripts/lib/agent-profile-test.sh +151 -0
- package/scripts/lib/agent-profile.sh +195 -0
- package/scripts/lib/agent-resolve-test.sh +156 -0
- package/scripts/lib/agent-resolve.sh +177 -0
- package/scripts/lib/branch-owner-test.sh +99 -0
- package/scripts/lib/branch-owner.sh +194 -0
- package/scripts/lib/captain-test.sh +86 -0
- package/scripts/lib/captain.sh +142 -7
- package/scripts/lib/contribute-root-test.sh +40 -0
- package/scripts/lib/contribute-root.sh +22 -0
- package/scripts/lib/effort-metrics.sh +14 -1
- package/scripts/lib/effort-ops-test.sh +54 -2
- package/scripts/lib/effort-ops.sh +243 -23
- package/scripts/lib/effort-parity-test.sh +5 -3
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +49 -15
- package/scripts/lib/gh-project.sh +14 -0
- package/scripts/lib/gh-rest-test.sh +301 -0
- package/scripts/lib/gh-rest.sh +289 -0
- package/scripts/lib/hook-refresh-test.sh +65 -0
- package/scripts/lib/hook-refresh.sh +62 -0
- package/scripts/lib/kit-config.sh +6 -0
- package/scripts/lib/kit-gc-test.sh +178 -1
- package/scripts/lib/kit-gc.sh +251 -55
- package/scripts/lib/kit-task-ops-test.sh +15 -0
- package/scripts/lib/kit-task-ops.sh +231 -58
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +129 -0
- package/scripts/lib/kto-task-pr-test.sh +59 -0
- package/scripts/lib/orchestration-runtime-test.sh +142 -0
- package/scripts/lib/orchestration-runtime.sh +171 -0
- package/scripts/lib/review-stage-test.sh +241 -0
- package/scripts/lib/review-stage.sh +259 -0
- package/scripts/lib/stage-receipt-test.sh +252 -0
- package/scripts/lib/stage-receipt.sh +442 -0
- package/scripts/lib/test-env-test.sh +25 -0
- package/scripts/lib/test-env.sh +33 -0
- package/scripts/lib/worker-brief-test.sh +120 -0
- package/scripts/lib/worker-brief.sh +185 -0
- package/scripts/lib/worktree-issue.sh +14 -0
- package/scripts/lib/worktree-ports-test.sh +146 -0
- package/scripts/lib/worktree-start.sh +153 -8
- package/scripts/lib/zsh-safety-test.sh +67 -0
- package/scripts/orchestrate.sh +124 -22
- package/scripts/portable-test.sh +22 -1
- package/scripts/review-lint-baseline.txt +28 -0
- package/scripts/review-lint-test.sh +271 -0
- package/scripts/review-lint.sh +259 -0
- package/scripts/review-rules.conf +55 -0
- package/scripts/setup-labels.sh +21 -1
- package/scripts/skill-frontmatter-baseline.txt +24 -0
- package/scripts/skill-frontmatter-lint-test.sh +156 -0
- package/scripts/skill-frontmatter-lint.sh +182 -0
- package/scripts/task-sync.sh +8 -0
- package/scripts/test.sh +10 -1
- package/skills/kit-autopilot/SKILL.md +13 -1
- package/skills/kit-cleanup/SKILL.md +5 -3
- package/skills/kit-contribute/SKILL.md +6 -5
- package/skills/kit-effort-close/SKILL.md +8 -3
- package/skills/kit-effort-pr/SKILL.md +16 -95
- package/skills/kit-gc/SKILL.md +15 -10
- package/skills/kit-security-sweep/SKILL.md +4 -6
- package/skills/kit-ship/SKILL.md +1 -1
- package/skills/kit-task-pr/SKILL.md +2 -0
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +193 -0
- package/templates/rules/branch-naming.md +6 -0
- package/templates/rules/effort-model.md +3 -0
- package/templates/rules/naming-and-ids.md +4 -1
- package/templates/settings/settings.json.tmpl +4 -2
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# review-lint-test.sh — behavioral test for the codified-review-findings gate.
|
|
3
|
+
# Builds a throwaway repo with its own rule table and asserts the engine contract: scope/exclude
|
|
4
|
+
# selection, code_only and ignore filtering, both rule kinds (regex + stateful awk), and the
|
|
5
|
+
# per-file ratchet (new hit fails, baselined hit passes, growth fails).
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
|
|
8
|
+
ENGINE="$(cd "$(dirname "$0")" && pwd)/review-lint.sh"
|
|
9
|
+
fails=0
|
|
10
|
+
pass() { echo "ok $1"; }
|
|
11
|
+
fail() { echo "FAIL $1"; fails=1; }
|
|
12
|
+
|
|
13
|
+
TMP="$(mktemp -d)"
|
|
14
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
15
|
+
mkdir -p "$TMP/scripts" "$TMP/lib" "$TMP/docs"
|
|
16
|
+
cp "$ENGINE" "$TMP/scripts/"
|
|
17
|
+
|
|
18
|
+
( cd "$TMP" && git init -q . && git config user.email t@t && git config user.name t ) >/dev/null 2>&1
|
|
19
|
+
|
|
20
|
+
# Capture rather than pipe: `run | grep -q` lets grep exit early, kills `run` with SIGPIPE, and
|
|
21
|
+
# under `set -o pipefail` reports the pipeline as failed even on a successful match.
|
|
22
|
+
run() { ( cd "$TMP" && bash scripts/review-lint.sh "$@" 2>&1 ); }
|
|
23
|
+
run_out=""; run_rc=0
|
|
24
|
+
capture() { run_out="$(run "$@")"; run_rc=$?; }
|
|
25
|
+
track() { ( cd "$TMP" && git add -A . >/dev/null 2>&1 ); }
|
|
26
|
+
|
|
27
|
+
cat > "$TMP/scripts/review-rules.conf" <<'CONF'
|
|
28
|
+
[T001]
|
|
29
|
+
title: no bare TODO markers
|
|
30
|
+
why: test rule
|
|
31
|
+
scope: lib/*
|
|
32
|
+
exclude: *-test.sh
|
|
33
|
+
code_only: true
|
|
34
|
+
ignore: ALLOWED
|
|
35
|
+
pattern: TODO
|
|
36
|
+
source: test
|
|
37
|
+
|
|
38
|
+
[T002]
|
|
39
|
+
title: fenced block needs a language
|
|
40
|
+
why: test rule
|
|
41
|
+
kind: awk
|
|
42
|
+
scope: docs/*
|
|
43
|
+
awk: FNR==1{inb=0;fence=""} match($0,/^[ \t]*(`{3,}|~{3,})/){m=substr($0,RSTART,RLENGTH);sub(/^[ \t]+/,"",m);rest=substr($0,RSTART+RLENGTH);sub(/^[ \t]+/,"",rest);sub(/[ \t]+$/,"",rest);if(!inb){inb=1;fence=m;if(rest=="")print FILENAME":"FNR":"$0}else if(substr(m,1,1)==substr(fence,1,1)&&length(m)>=length(fence)&&rest==""){inb=0;fence=""}}
|
|
44
|
+
source: test
|
|
45
|
+
CONF
|
|
46
|
+
|
|
47
|
+
# --- 1. clean tree passes ----------------------------------------------------
|
|
48
|
+
echo 'echo hi' > "$TMP/lib/clean.sh"; track
|
|
49
|
+
capture
|
|
50
|
+
[ "$run_rc" -eq 0 ] && pass "clean tree passes" || fail "clean tree passes (rc=$run_rc: $run_out)"
|
|
51
|
+
|
|
52
|
+
# --- 2. scope: a hit OUTSIDE the rule's scope is ignored ---------------------
|
|
53
|
+
echo 'x=1 # TODO' > "$TMP/scripts/out-of-scope.sh"; track
|
|
54
|
+
capture
|
|
55
|
+
[ "$run_rc" -eq 0 ] && pass "out-of-scope file ignored" || fail "out-of-scope file ignored"
|
|
56
|
+
|
|
57
|
+
# --- 3. a real in-scope hit fails -------------------------------------------
|
|
58
|
+
echo 'x=1 TODO' > "$TMP/lib/bad.sh"; track
|
|
59
|
+
capture
|
|
60
|
+
if [ "$run_rc" -ne 0 ] && printf '%s' "$run_out" | grep -q 'T001.*lib/bad.sh'; then
|
|
61
|
+
pass "in-scope hit fails"
|
|
62
|
+
else
|
|
63
|
+
fail "in-scope hit fails (rc=$run_rc: $run_out)"
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# --- 4. exclude: same content in an excluded file is ignored ----------------
|
|
67
|
+
rm "$TMP/lib/bad.sh"; echo 'x=1 TODO' > "$TMP/lib/thing-test.sh"; track
|
|
68
|
+
capture
|
|
69
|
+
[ "$run_rc" -eq 0 ] && pass "exclude pattern honored" || fail "exclude pattern honored ($run_out)"
|
|
70
|
+
|
|
71
|
+
# --- 5. code_only: a FULL-LINE comment is not a hit -------------------------
|
|
72
|
+
rm "$TMP/lib/thing-test.sh"; printf ' # TODO later\n' > "$TMP/lib/c.sh"; track
|
|
73
|
+
capture
|
|
74
|
+
[ "$run_rc" -eq 0 ] && pass "code_only skips full-line comments" || fail "code_only skips full-line comments ($run_out)"
|
|
75
|
+
|
|
76
|
+
# --- 6. ignore: a line matching the ignore ERE is not a hit -----------------
|
|
77
|
+
printf 'x=1 TODO ALLOWED\n' > "$TMP/lib/c.sh"; track
|
|
78
|
+
capture
|
|
79
|
+
[ "$run_rc" -eq 0 ] && pass "ignore pattern honored" || fail "ignore pattern honored ($run_out)"
|
|
80
|
+
|
|
81
|
+
# --- 7. awk kind: OPENING bare fence is a hit, closing fence is not ---------
|
|
82
|
+
rm "$TMP/lib/c.sh"
|
|
83
|
+
printf 'intro\n```\ncode\n```\n' > "$TMP/docs/a.md"; track
|
|
84
|
+
n="$(run --rule T002 | grep -c 'docs/a.md:' || true)"
|
|
85
|
+
[ "$n" -eq 1 ] && pass "awk rule counts opening fence only (got $n)" \
|
|
86
|
+
|| fail "awk rule counts opening fence only (expected 1, got $n)"
|
|
87
|
+
|
|
88
|
+
# --- 8. awk kind: a LABELLED fence is clean --------------------------------
|
|
89
|
+
printf 'intro\n```bash\ncode\n```\n' > "$TMP/docs/a.md"; track
|
|
90
|
+
capture
|
|
91
|
+
[ "$run_rc" -eq 0 ] && pass "labelled fence is clean" || fail "labelled fence is clean ($run_out)"
|
|
92
|
+
|
|
93
|
+
# --- 9. awk state resets per file (no parity bleed across files) ------------
|
|
94
|
+
printf 'a\n```sh\nx\n```\n' > "$TMP/docs/a.md"
|
|
95
|
+
printf 'b\n```sh\ny\n```\n' > "$TMP/docs/b.md"; track
|
|
96
|
+
capture
|
|
97
|
+
[ "$run_rc" -eq 0 ] && pass "awk state resets per file" || fail "awk state resets per file ($run_out)"
|
|
98
|
+
|
|
99
|
+
# --- 10. baseline grandfathers an existing hit ------------------------------
|
|
100
|
+
printf 'a\n```\nx\n```\n' > "$TMP/docs/a.md"; track
|
|
101
|
+
run --update >/dev/null 2>&1
|
|
102
|
+
capture
|
|
103
|
+
[ "$run_rc" -eq 0 ] && pass "baselined hit is grandfathered" || fail "baselined hit is grandfathered ($run_out)"
|
|
104
|
+
|
|
105
|
+
# --- 11. ...but growth in that same file fails ------------------------------
|
|
106
|
+
printf 'a\n```\nx\n```\n\n```\ny\n```\n' > "$TMP/docs/a.md"; track
|
|
107
|
+
capture
|
|
108
|
+
if [ "$run_rc" -ne 0 ] && printf '%s' "$run_out" | grep -q 'grew to'; then
|
|
109
|
+
pass "growth past baseline fails"
|
|
110
|
+
else
|
|
111
|
+
fail "growth past baseline fails (rc=$run_rc: $run_out)"
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
# --- 12. a NEW file with a hit fails even while another is baselined --------
|
|
115
|
+
printf 'a\n```\nx\n```\n' > "$TMP/docs/a.md"
|
|
116
|
+
printf 'c\n```\nz\n```\n' > "$TMP/docs/c.md"; track
|
|
117
|
+
capture
|
|
118
|
+
if [ "$run_rc" -ne 0 ] && printf '%s' "$run_out" | grep -q 'docs/c.md'; then
|
|
119
|
+
pass "new offending file fails despite baseline"
|
|
120
|
+
else
|
|
121
|
+
fail "new offending file fails despite baseline (rc=$run_rc: $run_out)"
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
# --- 13. untracked files are invisible (git ls-files is the source) --------
|
|
125
|
+
rm "$TMP/docs/c.md"; track
|
|
126
|
+
printf 'u\n```\nz\n```\n' > "$TMP/docs/untracked.md" # deliberately NOT added
|
|
127
|
+
capture
|
|
128
|
+
[ "$run_rc" -eq 0 ] && pass "untracked files are not scanned" || fail "untracked files are not scanned ($run_out)"
|
|
129
|
+
|
|
130
|
+
# --- 14. the rule table never matches itself -------------------------------
|
|
131
|
+
# review-rules.conf quotes the patterns it describes, so scanning it makes every rule self-match.
|
|
132
|
+
# Own temp repo: this must assert on WHICH paths are reported, not on the exit code.
|
|
133
|
+
TMP3="$(mktemp -d)"; mkdir -p "$TMP3/scripts" "$TMP3/lib"
|
|
134
|
+
cp "$ENGINE" "$TMP3/scripts/"
|
|
135
|
+
( cd "$TMP3" && git init -q . ) >/dev/null 2>&1
|
|
136
|
+
cat > "$TMP3/scripts/review-rules.conf" <<'CONF'
|
|
137
|
+
[selfmatch]
|
|
138
|
+
title: no SENTINEL_TOKEN
|
|
139
|
+
why: the word SENTINEL_TOKEN appears in this very table
|
|
140
|
+
scope: scripts/*, lib/*
|
|
141
|
+
pattern: SENTINEL_TOKEN
|
|
142
|
+
source: test
|
|
143
|
+
CONF
|
|
144
|
+
echo 'x=SENTINEL_TOKEN' > "$TMP3/lib/real.sh"
|
|
145
|
+
out3="$( cd "$TMP3" && bash scripts/review-lint.sh 2>&1 )"
|
|
146
|
+
if printf '%s' "$out3" | grep -q 'review-rules.conf'; then
|
|
147
|
+
fail "rule table is not linted against itself (self-matched: $out3)"
|
|
148
|
+
elif printf '%s' "$out3" | grep -q 'lib/real.sh'; then
|
|
149
|
+
pass "rule table is skipped while real files still match"
|
|
150
|
+
else
|
|
151
|
+
fail "rule table is not linted against itself (real hit missed: $out3)"
|
|
152
|
+
fi
|
|
153
|
+
rm -rf "$TMP3"
|
|
154
|
+
|
|
155
|
+
# --- 15. untracked-but-present files are scanned when NOTHING is tracked ---
|
|
156
|
+
# A freshly scaffolded project has files on disk and an empty index; the gate must still see them.
|
|
157
|
+
TMP2="$(mktemp -d)"; mkdir -p "$TMP2/scripts" "$TMP2/docs"
|
|
158
|
+
cp "$ENGINE" "$TMP2/scripts/"; cp "$TMP/scripts/review-rules.conf" "$TMP2/scripts/"
|
|
159
|
+
( cd "$TMP2" && git init -q . ) >/dev/null 2>&1
|
|
160
|
+
printf 'a\n```\nx\n```\n' > "$TMP2/docs/a.md" # never `git add`ed
|
|
161
|
+
out2="$( cd "$TMP2" && bash scripts/review-lint.sh 2>&1 )"; rc2=$?
|
|
162
|
+
if [ "$rc2" -ne 0 ] && printf '%s' "$out2" | grep -q 'docs/a.md'; then
|
|
163
|
+
pass "scans on-disk files when the index is empty"
|
|
164
|
+
else
|
|
165
|
+
fail "scans on-disk files when the index is empty (rc=$rc2: $out2)"
|
|
166
|
+
fi
|
|
167
|
+
rm -rf "$TMP2"
|
|
168
|
+
|
|
169
|
+
# --- 16. a path containing a space keeps its own baseline row --------------
|
|
170
|
+
# `uniq -c | awk '{ print $2, $1 }'` keeps only the first whitespace token, so `docs/my file.md`
|
|
171
|
+
# is recorded as `docs/my` — and a second file sharing that prefix lands on the SAME row, so its
|
|
172
|
+
# hits are compared against the first file's count and pass unnoticed.
|
|
173
|
+
TMP4="$(mktemp -d)"; mkdir -p "$TMP4/scripts" "$TMP4/docs"
|
|
174
|
+
cp "$ENGINE" "$TMP4/scripts/"; cp "$TMP/scripts/review-rules.conf" "$TMP4/scripts/"
|
|
175
|
+
( cd "$TMP4" && git init -q . && git config user.email t@t && git config user.name t ) >/dev/null 2>&1
|
|
176
|
+
printf '```\nx\n```\n' > "$TMP4/docs/my file.md" # 1 bare opener
|
|
177
|
+
printf '```\ny\n```\nz\n```\nw\n```\n' > "$TMP4/docs/my other.md" # 2 bare openers
|
|
178
|
+
( cd "$TMP4" && git add -A . ) >/dev/null 2>&1
|
|
179
|
+
( cd "$TMP4" && bash scripts/review-lint.sh --update ) >/dev/null 2>&1
|
|
180
|
+
bl="$TMP4/scripts/review-lint-baseline.txt"
|
|
181
|
+
rows="$(grep -c 'docs/my' "$bl" 2>/dev/null | tr -d ' ')"
|
|
182
|
+
if [ "$rows" = 2 ] \
|
|
183
|
+
&& grep -q "$(printf 'docs/my file.md\t1')" "$bl" \
|
|
184
|
+
&& grep -q "$(printf 'docs/my other.md\t2')" "$bl"; then
|
|
185
|
+
pass "a path with a space keeps its own row and count"
|
|
186
|
+
else
|
|
187
|
+
fail "a path with a space keeps its own row and count (rows=$rows: $(grep 'docs/my' "$bl" | tr '\t' '|' | tr '\n' ' '))"
|
|
188
|
+
fi
|
|
189
|
+
# ...and the gate reads those rows back, so both files stay grandfathered.
|
|
190
|
+
out4="$( cd "$TMP4" && bash scripts/review-lint.sh 2>&1 )"; rc4=$?
|
|
191
|
+
[ "$rc4" -eq 0 ] && pass "both spaced paths are grandfathered" \
|
|
192
|
+
|| fail "both spaced paths are grandfathered (rc=$rc4: $out4)"
|
|
193
|
+
|
|
194
|
+
# --- 17. a space-separated baseline from an older kit is still readable -----
|
|
195
|
+
# Rows are written TAB-separated now. Refusing to read the old format would report every
|
|
196
|
+
# grandfathered file as a new hit and turn the gate red the moment a project upgrades.
|
|
197
|
+
printf '# legacy\nT002 docs/legacy.md 1\n' > "$TMP4/scripts/review-lint-baseline.txt"
|
|
198
|
+
rm -f "$TMP4/docs/my file.md" "$TMP4/docs/my other.md"
|
|
199
|
+
printf '```\nx\n```\n' > "$TMP4/docs/legacy.md"
|
|
200
|
+
( cd "$TMP4" && git add -A . ) >/dev/null 2>&1
|
|
201
|
+
out5="$( cd "$TMP4" && bash scripts/review-lint.sh 2>&1 )"; rc5=$?
|
|
202
|
+
[ "$rc5" -eq 0 ] && pass "a space-separated legacy baseline is honored" \
|
|
203
|
+
|| fail "a space-separated legacy baseline is honored (rc=$rc5: $out5)"
|
|
204
|
+
rm -rf "$TMP4"
|
|
205
|
+
|
|
206
|
+
# --- 18. a 4-backtick outer fence does not invert parity for the rest -------
|
|
207
|
+
# `/^```/` matches ```` too: the counter increments but the line never satisfies $0=="```", so it
|
|
208
|
+
# is never reported AND `n` stays odd — every later CLOSING fence is then flagged as a bare opener.
|
|
209
|
+
TMP5="$(mktemp -d)"; mkdir -p "$TMP5/scripts" "$TMP5/docs"
|
|
210
|
+
cp "$ENGINE" "$TMP5/scripts/"; cp "$TMP/scripts/review-rules.conf" "$TMP5/scripts/"
|
|
211
|
+
( cd "$TMP5" && git init -q . && git config user.email t@t && git config user.name t ) >/dev/null 2>&1
|
|
212
|
+
printf '````md\n```sh\necho hi\n```\n````\n\n```sh\necho ok\n```\n' > "$TMP5/docs/nested.md"
|
|
213
|
+
( cd "$TMP5" && git add -A . ) >/dev/null 2>&1
|
|
214
|
+
out6="$( cd "$TMP5" && bash scripts/review-lint.sh 2>&1 )"; rc6=$?
|
|
215
|
+
[ "$rc6" -eq 0 ] && pass "a 4-backtick outer fence leaves later fences clean" \
|
|
216
|
+
|| fail "a 4-backtick outer fence leaves later fences clean (rc=$rc6: $out6)"
|
|
217
|
+
# A genuinely bare ~~~ fence is still caught — the rule sees tilde fences at all now.
|
|
218
|
+
printf '~~~\nx\n~~~\n' > "$TMP5/docs/tilde.md"
|
|
219
|
+
( cd "$TMP5" && git add -A . ) >/dev/null 2>&1
|
|
220
|
+
out7="$( cd "$TMP5" && bash scripts/review-lint.sh 2>&1 )"; rc7=$?
|
|
221
|
+
if [ "$rc7" -ne 0 ] && printf '%s' "$out7" | grep -q 'docs/tilde.md'; then
|
|
222
|
+
pass "a bare ~~~ fence is caught"
|
|
223
|
+
else
|
|
224
|
+
fail "a bare ~~~ fence is caught (rc=$rc7: $out7)"
|
|
225
|
+
fi
|
|
226
|
+
rm -rf "$TMP5"
|
|
227
|
+
|
|
228
|
+
# --- 19. KIT_LINT_WALK seeds from disk even when the index is NOT empty -----
|
|
229
|
+
# The scaffold case init.sh actually hits: a repo that already has commits, with the kit's files
|
|
230
|
+
# freshly written and untracked. Without the walk the baseline comes out empty and the gate goes
|
|
231
|
+
# red on the user's first commit of the scaffold.
|
|
232
|
+
TMP6="$(mktemp -d)"; mkdir -p "$TMP6/scripts" "$TMP6/docs"
|
|
233
|
+
cp "$ENGINE" "$TMP6/scripts/"; cp "$TMP/scripts/review-rules.conf" "$TMP6/scripts/"
|
|
234
|
+
( cd "$TMP6" && git init -q . && git config user.email t@t && git config user.name t ) >/dev/null 2>&1
|
|
235
|
+
echo readme > "$TMP6/README.md"
|
|
236
|
+
( cd "$TMP6" && git add README.md && git commit -qm init ) >/dev/null 2>&1
|
|
237
|
+
printf '```\nx\n```\n' > "$TMP6/docs/scaffolded.md" # written by the scaffold, still untracked
|
|
238
|
+
( cd "$TMP6" && KIT_LINT_WALK=1 bash scripts/review-lint.sh --update ) >/dev/null 2>&1
|
|
239
|
+
if grep -q 'docs/scaffolded.md' "$TMP6/scripts/review-lint-baseline.txt" 2>/dev/null; then
|
|
240
|
+
pass "KIT_LINT_WALK seeds untracked scaffold files"
|
|
241
|
+
else
|
|
242
|
+
fail "KIT_LINT_WALK seeds untracked scaffold files ($(cat "$TMP6/scripts/review-lint-baseline.txt" 2>&1))"
|
|
243
|
+
fi
|
|
244
|
+
( cd "$TMP6" && git add -A . ) >/dev/null 2>&1
|
|
245
|
+
out8="$( cd "$TMP6" && bash scripts/review-lint.sh 2>&1 )"; rc8=$?
|
|
246
|
+
[ "$rc8" -eq 0 ] && pass "the seeded scaffold is green once committed" \
|
|
247
|
+
|| fail "the seeded scaffold is green once committed (rc=$rc8: $out8)"
|
|
248
|
+
# Without the walk the seed is empty — the defect this guards against.
|
|
249
|
+
rm -f "$TMP6/scripts/review-lint-baseline.txt"
|
|
250
|
+
printf '```\ny\n```\n' > "$TMP6/docs/second.md"
|
|
251
|
+
( cd "$TMP6" && bash scripts/review-lint.sh --update ) >/dev/null 2>&1
|
|
252
|
+
if grep -q 'docs/second.md' "$TMP6/scripts/review-lint-baseline.txt" 2>/dev/null; then
|
|
253
|
+
fail "an unwalked seed must not see untracked files"
|
|
254
|
+
else
|
|
255
|
+
pass "an unwalked seed sees only tracked files"
|
|
256
|
+
fi
|
|
257
|
+
rm -rf "$TMP6"
|
|
258
|
+
|
|
259
|
+
# --- 20. --baseline-path is the one place the filename is spelled ----------
|
|
260
|
+
out9="$(run --baseline-path)"
|
|
261
|
+
[ "$out9" = "scripts/review-lint-baseline.txt" ] \
|
|
262
|
+
&& pass "--baseline-path reports the baseline" \
|
|
263
|
+
|| fail "--baseline-path reports the baseline (got '$out9')"
|
|
264
|
+
|
|
265
|
+
# --- 21. missing rule table is a no-op, not a failure ----------------------
|
|
266
|
+
rm "$TMP/scripts/review-rules.conf"
|
|
267
|
+
capture
|
|
268
|
+
[ "$run_rc" -eq 0 ] && pass "missing rule table is a no-op" || fail "missing rule table is a no-op"
|
|
269
|
+
|
|
270
|
+
[ "$fails" -eq 0 ] && echo "ok review-lint-test passed" || echo "FAIL review-lint-test"
|
|
271
|
+
exit "$fails"
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# review-lint.sh — codified review findings as a deterministic gate (kit-owned).
|
|
3
|
+
#
|
|
4
|
+
# WHY: an AI reviewer (CodeRabbit) finds the same classes of defect over and over, but its findings
|
|
5
|
+
# live in PR threads and die there. Anything MECHANICAL in that stream — a pattern that is wrong
|
|
6
|
+
# every time it appears, regardless of intent — belongs in a gate that runs in under a second and
|
|
7
|
+
# never forgets. This file is that gate; `review-rules.conf` is the rule table, one block per rule,
|
|
8
|
+
# each carrying the PR it was earned from.
|
|
9
|
+
#
|
|
10
|
+
# WHAT IT IS NOT: a replacement for review. Only the mechanical slice maps here. Findings that need
|
|
11
|
+
# intent — doc-vs-code drift, architectural contracts, "is this the right abstraction" — stay with
|
|
12
|
+
# the reviewer. Do not force those into regexes; a noisy gate is worse than no gate.
|
|
13
|
+
#
|
|
14
|
+
# scripts/review-lint.sh lint against the baseline (the gate)
|
|
15
|
+
# scripts/review-lint.sh --report every rule's current hit count; never fails
|
|
16
|
+
# scripts/review-lint.sh --rule <ID> show every hit for one rule, with context
|
|
17
|
+
# scripts/review-lint.sh --update re-baseline from current hits
|
|
18
|
+
#
|
|
19
|
+
# Baseline: scripts/review-lint-baseline.txt ("<RULE> <path> <count>"). Grandfathers today's hits
|
|
20
|
+
# per file so adding a rule never forces a repo-wide fix; only NEW or GROWN hits fail.
|
|
21
|
+
# bash 3.2 compatible (no associative arrays, no mapfile).
|
|
22
|
+
set -uo pipefail
|
|
23
|
+
|
|
24
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
25
|
+
cd "$ROOT"
|
|
26
|
+
|
|
27
|
+
RULES="scripts/review-rules.conf"
|
|
28
|
+
BASELINE="scripts/review-lint-baseline.txt"
|
|
29
|
+
|
|
30
|
+
FAIL=0
|
|
31
|
+
err() { echo "x $1"; FAIL=1; }
|
|
32
|
+
ok() { echo "ok $1"; }
|
|
33
|
+
note() { echo " $1"; }
|
|
34
|
+
|
|
35
|
+
[ -f "$RULES" ] || { echo "review-lint: no $RULES — nothing to enforce"; exit 0; }
|
|
36
|
+
|
|
37
|
+
# ---- rule table access ------------------------------------------------------
|
|
38
|
+
rule_ids() { awk '/^\[.+\]$/ { gsub(/^\[|\]$/, ""); print }' "$RULES"; }
|
|
39
|
+
|
|
40
|
+
# rule_field <id> <key> — value of one key inside one [id] block ("" if unset).
|
|
41
|
+
rule_field() {
|
|
42
|
+
awk -v id="$1" -v key="$2" '
|
|
43
|
+
/^\[.+\]$/ { cur = $0; gsub(/^\[|\]$/, "", cur); inblk = (cur == id); next }
|
|
44
|
+
!inblk { next }
|
|
45
|
+
index($0, key ":") == 1 { sub("^" key ":[ \t]*", ""); print; exit }
|
|
46
|
+
' "$RULES"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# ---- file selection ---------------------------------------------------------
|
|
50
|
+
# Scope/exclude are comma-separated shell patterns matched with `case`, where `*` DOES cross `/`
|
|
51
|
+
# (case patterns are not pathname expansion). So `scripts/*` matches `scripts/lib/foo.sh`.
|
|
52
|
+
# Tracked files when there are any; otherwise a filesystem walk. The fallback matters for a
|
|
53
|
+
# freshly scaffolded project, where the kit has written files but nothing is staged yet -
|
|
54
|
+
# `git ls-files` is empty there, and without this the gate would silently scan nothing.
|
|
55
|
+
#
|
|
56
|
+
# KIT_LINT_WALK=1 forces the walk. Seeding a baseline needs it: init.sh scaffolds into a repo that
|
|
57
|
+
# usually ALREADY has commits, so `git ls-files` is non-empty and the just-written kit files are
|
|
58
|
+
# invisible to it. `--update` then grandfathers nothing, and the gate turns red the moment the user
|
|
59
|
+
# commits the scaffold - failing on templates the kit itself shipped. "Seed once so a fresh project
|
|
60
|
+
# starts green" only holds if the seed can see the whole tree, tracked or not.
|
|
61
|
+
list_files() {
|
|
62
|
+
local tracked
|
|
63
|
+
if [ "${KIT_LINT_WALK:-0}" != "1" ]; then
|
|
64
|
+
tracked="$(git ls-files 2>/dev/null)"
|
|
65
|
+
if [ -n "$tracked" ]; then printf '%s\n' "$tracked"; return 0; fi
|
|
66
|
+
fi
|
|
67
|
+
find . -type f \
|
|
68
|
+
-not -path './.git/*' -not -path '*/node_modules/*' \
|
|
69
|
+
-not -path './dist/*' -not -path './.cckit/*' 2>/dev/null | sed 's|^\./||'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
files_for_rule() {
|
|
73
|
+
local scope exclude f keep pat
|
|
74
|
+
scope="$(rule_field "$1" scope)"
|
|
75
|
+
exclude="$(rule_field "$1" exclude)"
|
|
76
|
+
[ -n "$scope" ] || scope='*'
|
|
77
|
+
list_files | while IFS= read -r f; do
|
|
78
|
+
# Never lint the rule table or the baseline: both quote the very patterns they describe,
|
|
79
|
+
# so scanning them makes every rule match itself.
|
|
80
|
+
case "$f" in "$RULES"|"$BASELINE") continue ;; esac
|
|
81
|
+
keep=0
|
|
82
|
+
IFS=',' read -r -a _scopes <<< "$(printf '%s' "$scope" | tr -d ' ')"
|
|
83
|
+
for pat in "${_scopes[@]}"; do
|
|
84
|
+
[ -n "$pat" ] || continue
|
|
85
|
+
case "$f" in $pat) keep=1; break ;; esac
|
|
86
|
+
done
|
|
87
|
+
[ "$keep" -eq 1 ] || continue
|
|
88
|
+
if [ -n "$exclude" ]; then
|
|
89
|
+
IFS=',' read -r -a _excl <<< "$(printf '%s' "$exclude" | tr -d ' ')"
|
|
90
|
+
for pat in "${_excl[@]}"; do
|
|
91
|
+
[ -n "$pat" ] || continue
|
|
92
|
+
case "$f" in $pat) keep=0; break ;; esac
|
|
93
|
+
done
|
|
94
|
+
fi
|
|
95
|
+
[ "$keep" -eq 1 ] && printf '%s\n' "$f"
|
|
96
|
+
done
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# ---- matching ---------------------------------------------------------------
|
|
100
|
+
# Emits "path:line:text" for every hit of one rule.
|
|
101
|
+
#
|
|
102
|
+
# code_only drops FULL-LINE comments only (first non-blank char is `#`). It deliberately does not
|
|
103
|
+
# strip trailing comments: in shell `#` is ambiguous (`${v#p}`, `$#`, `'#'`), so stripping it would
|
|
104
|
+
# corrupt real code lines. Use `ignore:` for the rest.
|
|
105
|
+
hits_for_rule() {
|
|
106
|
+
local id="$1" kind pattern prog ignore code_only flist
|
|
107
|
+
kind="$(rule_field "$id" kind)"
|
|
108
|
+
ignore="$(rule_field "$id" ignore)"
|
|
109
|
+
code_only="$(rule_field "$id" code_only)"
|
|
110
|
+
|
|
111
|
+
flist="$(files_for_rule "$id")"
|
|
112
|
+
[ -n "$flist" ] || return 0
|
|
113
|
+
|
|
114
|
+
# Two rule kinds. `regex` (the default) is a per-line grep — enough for most findings. `awk` is
|
|
115
|
+
# for rules that need STATE across lines, such as fence parity: a bare ``` is only a defect when
|
|
116
|
+
# it OPENS a block, and no per-line pattern can know that. An awk rule supplies a one-line program
|
|
117
|
+
# that prints FILENAME":"FNR":"$0 for each hit and resets its state on FNR==1.
|
|
118
|
+
if [ "$kind" = "awk" ]; then
|
|
119
|
+
prog="$(rule_field "$id" awk)"
|
|
120
|
+
[ -n "$prog" ] || return 0
|
|
121
|
+
printf '%s\n' "$flist" \
|
|
122
|
+
| tr '\n' '\0' \
|
|
123
|
+
| xargs -0 awk "$prog" 2>/dev/null
|
|
124
|
+
else
|
|
125
|
+
pattern="$(rule_field "$id" pattern)"
|
|
126
|
+
[ -n "$pattern" ] || return 0
|
|
127
|
+
printf '%s\n' "$flist" \
|
|
128
|
+
| tr '\n' '\0' \
|
|
129
|
+
| xargs -0 grep -nE -- "$pattern" /dev/null 2>/dev/null
|
|
130
|
+
fi \
|
|
131
|
+
| awk -v co="${code_only:-false}" -v ig="${ignore:-}" '
|
|
132
|
+
{
|
|
133
|
+
body = $0
|
|
134
|
+
sub(/^[^:]*:[0-9]+:/, "", body)
|
|
135
|
+
if (co == "true") { t = body; sub(/^[ \t]+/, "", t); if (substr(t, 1, 1) == "#") next }
|
|
136
|
+
if (ig != "" && body ~ ig) next
|
|
137
|
+
print
|
|
138
|
+
}
|
|
139
|
+
'
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
# count_by_file — read "path:line:text" hits on stdin, emit "<path><TAB><count>", path-sorted.
|
|
143
|
+
#
|
|
144
|
+
# The obvious `uniq -c | awk '{ print $2, $1 }'` keeps only the FIRST whitespace token of the path,
|
|
145
|
+
# so `docs/my file.md` is recorded as `docs/my`. Two offending files sharing that prefix then
|
|
146
|
+
# collapse onto one row and are both compared against a single baseline entry - the second file's
|
|
147
|
+
# hits pass unnoticed. Counting in awk, keyed on the whole path, and separating with a TAB (which
|
|
148
|
+
# cannot occur in the paths git reports) keeps the field boundary unambiguous for every reader.
|
|
149
|
+
count_by_file() {
|
|
150
|
+
awk -F: '{ c[$1]++ } END { for (p in c) printf "%s\t%s\n", p, c[p] }' | LC_ALL=C sort
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# baseline_count <rule> <path> — the recorded count, 0 when absent.
|
|
154
|
+
#
|
|
155
|
+
# Reads BOTH layouts. Rows are written TAB-separated so a path with a space survives, but a project
|
|
156
|
+
# upgrading from an earlier kit still has a space-separated baseline on disk; refusing to read it
|
|
157
|
+
# would report every grandfathered file as a new hit and turn the gate red on upgrade.
|
|
158
|
+
baseline_count() {
|
|
159
|
+
[ -f "$BASELINE" ] || { echo 0; return; }
|
|
160
|
+
grep -v '^[[:space:]]*#' "$BASELINE" 2>/dev/null \
|
|
161
|
+
| awk -v r="$1" -v p="$2" '
|
|
162
|
+
{ n = index($0, "\t") ? split($0, F, "\t") : split($0, F, " ") }
|
|
163
|
+
n >= 3 && F[1] == r && F[2] == p { print F[3]; found = 1; exit }
|
|
164
|
+
END { if (!found) print 0 }
|
|
165
|
+
'
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
MODE="${1:-lint}"
|
|
169
|
+
ARG="${2:-}"
|
|
170
|
+
|
|
171
|
+
# The one place the baseline filename is spelled, so init.sh's "seed once" guard cannot go looking
|
|
172
|
+
# for a name that does not exist.
|
|
173
|
+
if [ "$MODE" = "--baseline-path" ]; then
|
|
174
|
+
printf '%s\n' "$BASELINE"
|
|
175
|
+
exit 0
|
|
176
|
+
fi
|
|
177
|
+
|
|
178
|
+
# ---- --rule <ID> ------------------------------------------------------------
|
|
179
|
+
if [ "$MODE" = "--rule" ]; then
|
|
180
|
+
[ -n "$ARG" ] || { echo "usage: review-lint.sh --rule <ID>"; exit 2; }
|
|
181
|
+
rule_ids | grep -qx "$ARG" || { echo "x unknown rule '$ARG'"; exit 2; }
|
|
182
|
+
echo "[$ARG] $(rule_field "$ARG" title)"
|
|
183
|
+
echo " why: $(rule_field "$ARG" why)"
|
|
184
|
+
echo " source: $(rule_field "$ARG" source)"
|
|
185
|
+
echo
|
|
186
|
+
hits_for_rule "$ARG" | sed 's/^/ /'
|
|
187
|
+
echo
|
|
188
|
+
echo " $(hits_for_rule "$ARG" | grep -c . | tr -d ' ') hit(s)"
|
|
189
|
+
exit 0
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
# ---- --report ---------------------------------------------------------------
|
|
193
|
+
if [ "$MODE" = "--report" ]; then
|
|
194
|
+
printf '%-26s %5s %s\n' RULE HITS TITLE
|
|
195
|
+
rule_ids | while IFS= read -r id; do
|
|
196
|
+
[ -n "$id" ] || continue
|
|
197
|
+
printf '%-26s %5s %s\n' "$id" "$(hits_for_rule "$id" | grep -c . | tr -d ' ')" "$(rule_field "$id" title)"
|
|
198
|
+
done
|
|
199
|
+
exit 0
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
# ---- --update ---------------------------------------------------------------
|
|
203
|
+
if [ "$MODE" = "--update" ]; then
|
|
204
|
+
{
|
|
205
|
+
echo "# review-lint-baseline.txt — generated by scripts/review-lint.sh --update"
|
|
206
|
+
echo "# Pre-existing hits, GRANDFATHERED per file: they may stay, but may never grow, and a"
|
|
207
|
+
echo "# file not listed here must have zero hits. Fix a file and re-run --update to tighten."
|
|
208
|
+
echo "#"
|
|
209
|
+
echo "# <RULE>\t<path>\t<count> (TAB-separated: a path may contain a space)"
|
|
210
|
+
rule_ids | while IFS= read -r id; do
|
|
211
|
+
[ -n "$id" ] || continue
|
|
212
|
+
hits_for_rule "$id" | count_by_file \
|
|
213
|
+
| awk -v r="$id" -F"\t" '{ printf "%s\t%s\t%s\n", r, $1, $2 }'
|
|
214
|
+
done
|
|
215
|
+
} > "$BASELINE"
|
|
216
|
+
echo "ok wrote $BASELINE ($(grep -cv '^[[:space:]]*#' "$BASELINE" | tr -d ' ') grandfathered file(s))"
|
|
217
|
+
exit 0
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
# ---- lint (the gate) --------------------------------------------------------
|
|
221
|
+
total=0
|
|
222
|
+
grandfathered=0
|
|
223
|
+
while IFS= read -r id; do
|
|
224
|
+
[ -n "$id" ] || continue
|
|
225
|
+
title="$(rule_field "$id" title)"
|
|
226
|
+
why="$(rule_field "$id" why)"
|
|
227
|
+
src="$(rule_field "$id" source)"
|
|
228
|
+
|
|
229
|
+
# Per-file counts for this rule, "<path><TAB><count>".
|
|
230
|
+
counts="$(hits_for_rule "$id" | count_by_file)"
|
|
231
|
+
[ -n "$counts" ] || continue
|
|
232
|
+
|
|
233
|
+
while IFS="$(printf '\t')" read -r path n; do
|
|
234
|
+
[ -n "$path" ] || continue
|
|
235
|
+
[ "$n" -ge 0 ] 2>/dev/null || continue
|
|
236
|
+
total=$(( total + n ))
|
|
237
|
+
base="$(baseline_count "$id" "$path")"
|
|
238
|
+
if [ "$n" -gt "$base" ]; then
|
|
239
|
+
if [ "$base" -eq 0 ]; then
|
|
240
|
+
err "[$id] $path: $n hit(s) — $title"
|
|
241
|
+
else
|
|
242
|
+
err "[$id] $path: grew to $n hit(s) (baseline $base) — $title"
|
|
243
|
+
fi
|
|
244
|
+
note "why: $why"
|
|
245
|
+
note "source: $src"
|
|
246
|
+
hits_for_rule "$id" | awk -F: -v p="$path" '$1 == p' | head -3 | sed 's/^/ /'
|
|
247
|
+
note "see all: scripts/review-lint.sh --rule $id"
|
|
248
|
+
else
|
|
249
|
+
grandfathered=$(( grandfathered + n ))
|
|
250
|
+
fi
|
|
251
|
+
done <<EOF
|
|
252
|
+
$counts
|
|
253
|
+
EOF
|
|
254
|
+
done < <(rule_ids)
|
|
255
|
+
|
|
256
|
+
if [ "$FAIL" -eq 0 ]; then
|
|
257
|
+
ok "review rules clean ($(rule_ids | grep -c . | tr -d ' ') rule(s), $grandfathered grandfathered hit(s))"
|
|
258
|
+
fi
|
|
259
|
+
exit "$FAIL"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# review-rules.conf — mechanical review findings, codified. Enforced by scripts/review-lint.sh.
|
|
2
|
+
#
|
|
3
|
+
# Each block is one rule mined from a real review thread. `source` is the provenance: the PR where
|
|
4
|
+
# a human or the AI reviewer caught this, so a rule can always be traced back to the defect that
|
|
5
|
+
# earned it. Adding a rule is a one-block append + `scripts/review-lint.sh --update`.
|
|
6
|
+
#
|
|
7
|
+
# Fields:
|
|
8
|
+
# kind `regex` (default) or `awk` for rules needing state across lines
|
|
9
|
+
# title one line, imperative — printed on failure
|
|
10
|
+
# why what actually breaks (not "best practice")
|
|
11
|
+
# scope comma-separated `case` patterns; `*` crosses `/` (so `scripts/*` is recursive)
|
|
12
|
+
# exclude same syntax, applied after scope
|
|
13
|
+
# pattern ERE passed to `grep -E` (kind: regex)
|
|
14
|
+
# awk one-line awk program printing FILENAME":"FNR":"$0 per hit (kind: awk)
|
|
15
|
+
# ignore optional ERE; a matching line is not a hit (use for output strings, fixtures)
|
|
16
|
+
# code_only true = skip full-line comments (trailing comments are NOT stripped; see review-lint.sh)
|
|
17
|
+
# source provenance
|
|
18
|
+
#
|
|
19
|
+
# ONLY mechanical rules belong here — patterns that are wrong every time they appear. Findings that
|
|
20
|
+
# need intent (doc-vs-code drift, architectural contracts) stay with the reviewer; forcing those
|
|
21
|
+
# into a regex produces noise, and a noisy gate trains people to ignore it.
|
|
22
|
+
|
|
23
|
+
[grep-c-zero-fallback]
|
|
24
|
+
title: do not use `grep -c ... || echo 0` as a zero-count fallback
|
|
25
|
+
why: `grep -c` PRINTS 0 and exits 1 on no match, so the fallback appends a second 0 and the command substitution yields "0\n0" — arithmetic and comparisons then break
|
|
26
|
+
scope: scripts/*, bin/*
|
|
27
|
+
code_only: true
|
|
28
|
+
pattern: grep -c[^|]*\|\|[[:space:]]*echo[[:space:]]+0
|
|
29
|
+
source: coderabbit PR#230 (scripts/lib/kit-brief.sh, "Fix both zero-count fallbacks")
|
|
30
|
+
|
|
31
|
+
[refs-word-splitting]
|
|
32
|
+
title: iterate refs and paths with `while IFS= read -r`, not `for x in $(...)`
|
|
33
|
+
why: unquoted command substitution word-splits on the ambient IFS, so refs or worktree paths containing spaces are silently dropped or split — a polluted IFS (including a NUL) breaks it further
|
|
34
|
+
scope: scripts/*, bin/*
|
|
35
|
+
code_only: true
|
|
36
|
+
pattern: for[[:space:]]+[a-zA-Z_][a-zA-Z0-9_]*[[:space:]]+in[[:space:]]+\$\((git|gh)[[:space:]]
|
|
37
|
+
source: coderabbit PR#240 (scripts/lib/kit-status.sh, "Worktree paths that contain a space are dropped")
|
|
38
|
+
|
|
39
|
+
[local-masks-exit-status]
|
|
40
|
+
title: split `local x=$(cmd)` into `local x; x=$(cmd)` when the exit status matters
|
|
41
|
+
why: `local` is itself a command, so its exit status masks the command substitution's — `set -e` and `|| return` never fire (shellcheck SC2155)
|
|
42
|
+
scope: scripts/*, bin/*
|
|
43
|
+
code_only: true
|
|
44
|
+
pattern: ^[[:space:]]*local[[:space:]]+[a-zA-Z_][a-zA-Z0-9_]*=\$\(
|
|
45
|
+
source: coderabbit PR#240 / SC2155
|
|
46
|
+
|
|
47
|
+
[fence-missing-language]
|
|
48
|
+
title: give every fenced code block a language identifier
|
|
49
|
+
why: a bare ``` fence renders unhighlighted and breaks docs-site syntax highlighting and copy buttons (markdownlint MD040)
|
|
50
|
+
kind: awk
|
|
51
|
+
scope: *.md, *.mdx
|
|
52
|
+
exclude: docs-site/node_modules/*, CHANGELOG.md, .github/*
|
|
53
|
+
awk: FNR==1{inb=0;fence=""} match($0,/^[ \t]*(`{3,}|~{3,})/){m=substr($0,RSTART,RLENGTH);sub(/^[ \t]+/,"",m);rest=substr($0,RSTART+RLENGTH);sub(/^[ \t]+/,"",rest);sub(/[ \t]+$/,"",rest);if(!inb){inb=1;fence=m;if(rest=="")print FILENAME":"FNR":"$0}else if(substr(m,1,1)==substr(fence,1,1)&&length(m)>=length(fence)&&rest==""){inb=0;fence=""}}
|
|
54
|
+
note: tracks the OPENING fence's char and length. A parity counter (n%2) breaks on a 4-backtick outer fence - the normal way to show a fenced block inside a fenced block: it counts the ```` line but never reports it, leaving n odd so every later CLOSING fence is reported as a bare opener. ~~~ fences were invisible to it entirely.
|
|
55
|
+
source: coderabbit PR#276 (templates/rules/naming-and-ids.md, "Add language identifiers to the fenced code blocks")
|
package/scripts/setup-labels.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Create the ctx:/flow:/kind:/priority:/role: label families on the repo. Idempotent.
|
|
2
|
+
# Create the agent:/ctx:/flow:/kind:/priority:/role: label families on the repo. Idempotent.
|
|
3
3
|
# Reads repo + roles from .claude/kit.config.json; the flow vocabulary from effort.sh (EFFORT_FLOWS).
|
|
4
4
|
# These are exactly the labels `cckit effort new` / /kit-effort-new apply — provision them here so a
|
|
5
5
|
# fresh repo can create a fully-labeled effort with no manual label creation. Run from project root.
|
|
@@ -14,6 +14,10 @@ ensure_label() { # name color description
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
echo "→ Labels on $KIT_REPO"
|
|
17
|
+
# The one label that marks a parent AS an effort, and the one `effort_plan` queries. It was read
|
|
18
|
+
# and never provisioned, so `cckit effort plan` found nothing on every repo.
|
|
19
|
+
echo "effort:"
|
|
20
|
+
ensure_label "effort" "5319e7" "An effort parent issue"
|
|
17
21
|
echo "kinds:"
|
|
18
22
|
for k in task plan adr scaffold spike; do ensure_label "kind:$k" "5319e7" "Kind: $k"; done
|
|
19
23
|
echo "priorities:"
|
|
@@ -34,4 +38,20 @@ while IFS= read -r role; do
|
|
|
34
38
|
slug=$(echo "$role" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
|
35
39
|
ensure_label "role:$slug" "1d76db" "Role: $role"
|
|
36
40
|
done <<< "$KIT_ROLES"
|
|
41
|
+
|
|
42
|
+
# agent:<profile> — which agent profile a piece of work runs under (#319). Driven by the profiles
|
|
43
|
+
# the project actually declares, so the family stays bounded by the config rather than growing one
|
|
44
|
+
# label per issue. A project with no `agents.profiles` gets no agent: labels, which is correct:
|
|
45
|
+
# nothing reads them until a profile exists to name.
|
|
46
|
+
echo "agents:"
|
|
47
|
+
_al_cfg=""
|
|
48
|
+
if command -v kit_config_path >/dev/null 2>&1; then _al_cfg="$(kit_config_path 2>/dev/null || true)"; fi
|
|
49
|
+
if [ -n "$_al_cfg" ] && [ -f "$_al_cfg" ] && command -v jq >/dev/null 2>&1; then
|
|
50
|
+
while IFS= read -r p; do
|
|
51
|
+
[ -z "$p" ] && continue
|
|
52
|
+
ensure_label "agent:$p" "5319e7" "Agent profile: $p"
|
|
53
|
+
done <<< "$(jq -r '(.agents.profiles // {}) | keys[]' "$_al_cfg" 2>/dev/null)"
|
|
54
|
+
else
|
|
55
|
+
echo " • no agents.profiles declared — skipping"
|
|
56
|
+
fi
|
|
37
57
|
echo "✓ done"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# skill-frontmatter-baseline.txt — generated by scripts/skill-frontmatter-lint.sh --update
|
|
2
|
+
# Skills whose description+when_to_use exceed the 500-byte listing budget.
|
|
3
|
+
# These are GRANDFATHERED: allowed to stay, but may never grow. Shrink them and re-run
|
|
4
|
+
# --update to tighten the ratchet. A skill that drops under budget leaves this file.
|
|
5
|
+
#
|
|
6
|
+
# <skill> <bytes>
|
|
7
|
+
kit-ux-audit 2181
|
|
8
|
+
kit-status 2004
|
|
9
|
+
kit-docs-writer 780
|
|
10
|
+
kit-onboard 728
|
|
11
|
+
kit-effort-start 717
|
|
12
|
+
kit-autopilot 686
|
|
13
|
+
concrete 679
|
|
14
|
+
kit-plan-next 674
|
|
15
|
+
kit-effort-close 592
|
|
16
|
+
kit-effort-new 578
|
|
17
|
+
kit-security-sweep 560
|
|
18
|
+
kit-cleanup 560
|
|
19
|
+
kit-dev 544
|
|
20
|
+
kit-contribute 538
|
|
21
|
+
kit-next 535
|
|
22
|
+
kit-annotate 534
|
|
23
|
+
kit-effort-pr 534
|
|
24
|
+
kit-ship 520
|