@jeiemgi/cckit 0.4.1 → 0.6.1
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/README.md +9 -1
- package/bin/cckit +18 -0
- package/cckit.config.json +2 -2
- package/package.json +1 -1
- package/scripts/benchmark/benchmark-test.sh +83 -0
- package/scripts/benchmark/gate.sh +55 -0
- package/scripts/benchmark/lib/bench-common.sh +70 -0
- package/scripts/benchmark/lib/model.sh +116 -0
- package/scripts/benchmark/report.sh +105 -0
- package/scripts/benchmark/run-quality.sh +102 -0
- package/scripts/benchmark/run.sh +166 -0
- package/scripts/benchmark/stop-check.sh +83 -0
- package/scripts/commitlint-test.sh +58 -0
- package/scripts/init.sh +26 -0
- package/scripts/kit-self-update.sh +55 -0
- package/scripts/lib/commitlint.sh +53 -0
- package/scripts/lib/kit-task-ops-test.sh +21 -0
- package/scripts/lib/kit-task-ops.sh +50 -2
- package/scripts/orchestrate.sh +8 -1
- package/scripts/portable-test.sh +1 -1
- package/scripts/status.sh +53 -40
- package/scripts/task-sync.sh +13 -0
- package/scripts/ux-a11y-scan.sh +96 -0
- package/scripts/ux-ds-audit.sh +146 -0
- package/scripts/ux-graph-scan.sh +188 -0
- package/skills/kit-autopilot/SKILL.md +6 -1
- package/skills/kit-ux-audit/SKILL.md +241 -0
- package/skills/kit-ux-audit/references/a11y.md +79 -0
- package/skills/kit-ux-audit/references/consistency.md +106 -0
- package/skills/kit-ux-audit/references/graph-model.md +92 -0
- package/skills/kit-ux-audit/references/heuristics.md +157 -0
- package/skills/kit-ux-audit/references/report.md +172 -0
- package/templates/agents/ux.md +89 -0
- package/templates/benchmarks/SCHEMA.md +75 -0
- package/templates/benchmarks/abstain.jsonl +8 -0
- package/templates/benchmarks/adversarial.jsonl +8 -0
- package/templates/benchmarks/benchmark.config.json +14 -0
- package/templates/benchmarks/quality.jsonl +8 -0
- package/templates/benchmarks/retrieval.jsonl +7 -0
- package/templates/settings/settings.json.tmpl +9 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/run.sh — the retrieval + abstain runner (objective, no judge).
|
|
3
|
+
#
|
|
4
|
+
# Measures how well a cold agent finds the project's OWN canonical docs. For each record it asks the
|
|
5
|
+
# model which single doc answers the question (bench_ask), then scores by objective top-hit path
|
|
6
|
+
# match against the record's expected path(s). Three tiers share this runner:
|
|
7
|
+
# retrieval direct questions -> top-hit path must match expected
|
|
8
|
+
# adversarial paraphrased / no-keyword / split-canonical / trap -> same scoring, harder inputs
|
|
9
|
+
# abstain unanswerable -> ANY path returned is a FAIL; only NONE passes
|
|
10
|
+
#
|
|
11
|
+
# Usage:
|
|
12
|
+
# benchmark/run.sh [--set <file>] [--tier retrieval|adversarial|abstain]
|
|
13
|
+
# [--dir <benchmarks>] [--dry] [--json]
|
|
14
|
+
#
|
|
15
|
+
# --dry validate every record's shape and count them; call NO model. Always exits 0 on
|
|
16
|
+
# well-formed data — the no-mistakes gate + CI run this offline.
|
|
17
|
+
# --set run one set file; otherwise every non-quality set in benchmark.config.json (or every
|
|
18
|
+
# *.jsonl in the dir when there is no config), each scored per its declared tier.
|
|
19
|
+
# --json machine-readable summary on stdout (for report.sh / autopilot); human table otherwise.
|
|
20
|
+
set -uo pipefail
|
|
21
|
+
|
|
22
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
23
|
+
# shellcheck source=/dev/null
|
|
24
|
+
. "$SCRIPT_DIR/lib/bench-common.sh"
|
|
25
|
+
# shellcheck source=/dev/null
|
|
26
|
+
. "$SCRIPT_DIR/lib/model.sh"
|
|
27
|
+
|
|
28
|
+
DRY=0; JSON=0; ONE_SET=""; FORCE_TIER=""
|
|
29
|
+
while [ "$#" -gt 0 ]; do
|
|
30
|
+
case "$1" in
|
|
31
|
+
--dry) DRY=1; shift ;;
|
|
32
|
+
--json|--llm) JSON=1; shift ;;
|
|
33
|
+
--set) ONE_SET="$2"; shift 2 ;;
|
|
34
|
+
--set=*) ONE_SET="${1#*=}"; shift ;;
|
|
35
|
+
--tier) FORCE_TIER="$2"; shift 2 ;;
|
|
36
|
+
--tier=*) FORCE_TIER="${1#*=}"; shift ;;
|
|
37
|
+
--dir) BENCH_DIR="$2"; export BENCH_DIR; shift 2 ;;
|
|
38
|
+
--dir=*) BENCH_DIR="${1#*=}"; export BENCH_DIR; shift ;;
|
|
39
|
+
-h|--help) sed -n '2,20p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
40
|
+
*) echo "run.sh: unknown arg '$1'" >&2; exit 2 ;;
|
|
41
|
+
esac
|
|
42
|
+
done
|
|
43
|
+
|
|
44
|
+
command -v jq >/dev/null 2>&1 || { echo "run.sh: jq is required" >&2; exit 2; }
|
|
45
|
+
|
|
46
|
+
DIR="$(bench_dir)"
|
|
47
|
+
KDIR="$(bench_knowledge_dir)"
|
|
48
|
+
CFG="$(bench_config)"
|
|
49
|
+
|
|
50
|
+
# Build the list of "<file>|<tier>" sets to run.
|
|
51
|
+
SETS=()
|
|
52
|
+
if [ -n "$ONE_SET" ]; then
|
|
53
|
+
f="$ONE_SET"; [ -f "$f" ] || f="$DIR/$ONE_SET"
|
|
54
|
+
t="${FORCE_TIER:-retrieval}"
|
|
55
|
+
# Infer tier from filename when not forced.
|
|
56
|
+
[ -n "$FORCE_TIER" ] || case "$(basename "$f")" in
|
|
57
|
+
*abstain*) t="abstain" ;;
|
|
58
|
+
*adversar*) t="adversarial" ;;
|
|
59
|
+
*) t="retrieval" ;;
|
|
60
|
+
esac
|
|
61
|
+
SETS+=("$f|$t")
|
|
62
|
+
elif [ -n "$CFG" ]; then
|
|
63
|
+
while IFS= read -r line; do
|
|
64
|
+
[ -n "$line" ] && SETS+=("$line")
|
|
65
|
+
done < <(jq -r '.sets[]? | select((.tier // "retrieval") != "quality") | "\(.file)|\(.tier // "retrieval")"' "$CFG")
|
|
66
|
+
else
|
|
67
|
+
# No config: discover *.jsonl, infer tier from filename, skip quality.
|
|
68
|
+
for f in "$DIR"/*.jsonl; do
|
|
69
|
+
[ -e "$f" ] || continue
|
|
70
|
+
case "$(basename "$f")" in
|
|
71
|
+
*quality*) continue ;;
|
|
72
|
+
*abstain*) SETS+=("$f|abstain") ;;
|
|
73
|
+
*adversar*) SETS+=("$f|adversarial") ;;
|
|
74
|
+
*) SETS+=("$f|retrieval") ;;
|
|
75
|
+
esac
|
|
76
|
+
done
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
[ "${#SETS[@]}" -ge 1 ] || { echo "run.sh: no sets found in $DIR" >&2; exit 2; }
|
|
80
|
+
|
|
81
|
+
# ---- portable millisecond clock (latency) ---------------------------------
|
|
82
|
+
now_ms() {
|
|
83
|
+
if date +%s%3N >/dev/null 2>&1 && [ "$(date +%3N)" != "3N" ]; then
|
|
84
|
+
date +%s%3N
|
|
85
|
+
else
|
|
86
|
+
printf '%s000' "$(date +%s)" # second resolution fallback (BSD date)
|
|
87
|
+
fi
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
TOTAL=0; PASS=0; FAILN=0
|
|
91
|
+
RESULTS_JSON="[]"
|
|
92
|
+
HUMAN=""
|
|
93
|
+
|
|
94
|
+
for spec in "${SETS[@]}"; do
|
|
95
|
+
file="${spec%%|*}"; tier="${spec##*|}"
|
|
96
|
+
[ -f "$file" ] || file="$DIR/$file" # config lists bare filenames relative to the benchmarks dir
|
|
97
|
+
s_total=0; s_pass=0
|
|
98
|
+
if [ ! -f "$file" ]; then
|
|
99
|
+
HUMAN="${HUMAN} ! set missing: $file (tier=$tier)\n"
|
|
100
|
+
continue
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
while IFS= read -r rec; do
|
|
104
|
+
[ -n "$rec" ] || continue
|
|
105
|
+
id="$(printf '%s' "$rec" | jq -r '.id // "?"')"
|
|
106
|
+
q="$(printf '%s' "$rec" | jq -r '.q // .claim // empty')"
|
|
107
|
+
expect="$(printf '%s' "$rec" | jq -c '.expect // "NONE"')"
|
|
108
|
+
|
|
109
|
+
# --dry: shape validation only. Every record needs a question; non-abstain needs an expect path.
|
|
110
|
+
if [ "$DRY" -eq 1 ]; then
|
|
111
|
+
s_total=$((s_total+1)); TOTAL=$((TOTAL+1))
|
|
112
|
+
if [ -z "$q" ]; then
|
|
113
|
+
echo "run.sh --dry: $file id=$id missing 'q'/'claim'" >&2; FAILN=$((FAILN+1)); continue
|
|
114
|
+
fi
|
|
115
|
+
if [ "$tier" != "abstain" ] && [ "$expect" = '"NONE"' ]; then
|
|
116
|
+
echo "run.sh --dry: $file id=$id ($tier) has no 'expect' path" >&2; FAILN=$((FAILN+1)); continue
|
|
117
|
+
fi
|
|
118
|
+
s_pass=$((s_pass+1)); PASS=$((PASS+1))
|
|
119
|
+
continue
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
# Live: ask the model, score objectively.
|
|
123
|
+
t0="$(now_ms)"
|
|
124
|
+
got="$(bench_ask "$q" "$KDIR")"
|
|
125
|
+
t1="$(now_ms)"; lat=$((t1 - t0)); [ "$lat" -ge 0 ] || lat=0
|
|
126
|
+
|
|
127
|
+
ok=0
|
|
128
|
+
if [ "$tier" = "abstain" ]; then
|
|
129
|
+
# Only NONE passes; any path returned = hallucinated retrieval = fail.
|
|
130
|
+
case "$(printf '%s' "$got" | tr 'A-Z' 'a-z')" in none|"") ok=1 ;; *) ok=0 ;; esac
|
|
131
|
+
else
|
|
132
|
+
if [ "$(printf '%s' "$got" | tr 'A-Z' 'a-z')" = "none" ]; then ok=0
|
|
133
|
+
elif bench_path_match "$got" "$expect"; then ok=1; fi
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
s_total=$((s_total+1)); TOTAL=$((TOTAL+1))
|
|
137
|
+
if [ "$ok" -eq 1 ]; then s_pass=$((s_pass+1)); PASS=$((PASS+1)); else FAILN=$((FAILN+1)); fi
|
|
138
|
+
|
|
139
|
+
RESULTS_JSON="$(printf '%s' "$RESULTS_JSON" | jq -c \
|
|
140
|
+
--arg set "$(basename "$file")" --arg tier "$tier" --arg id "$id" \
|
|
141
|
+
--arg got "$got" --argjson expect "$expect" --argjson ok "$ok" --argjson lat "$lat" \
|
|
142
|
+
'. + [{set:$set,tier:$tier,id:$id,got:$got,expect:$expect,pass:($ok==1),latency_ms:$lat}]')"
|
|
143
|
+
done < <(bench_records "$file")
|
|
144
|
+
|
|
145
|
+
pct=0; [ "$s_total" -gt 0 ] && pct=$(( s_pass * 100 / s_total ))
|
|
146
|
+
HUMAN="${HUMAN} $tier ($(basename "$file")): $s_pass/$s_total (${pct}%)\n"
|
|
147
|
+
done
|
|
148
|
+
|
|
149
|
+
SCORE_PCT=0; [ "$TOTAL" -gt 0 ] && SCORE_PCT=$(( PASS * 100 / TOTAL ))
|
|
150
|
+
|
|
151
|
+
if [ "$JSON" -eq 1 ]; then
|
|
152
|
+
jq -n --argjson total "$TOTAL" --argjson pass "$PASS" --argjson fail "$FAILN" \
|
|
153
|
+
--argjson pct "$SCORE_PCT" --argjson dry "$DRY" --argjson results "$RESULTS_JSON" \
|
|
154
|
+
'{kind:"retrieval-run", dry:($dry==1), total:$total, pass:$pass, fail:$fail, score_pct:$pct, results:$results}'
|
|
155
|
+
else
|
|
156
|
+
printf 'benchmark run%s — %s\n' "$([ "$DRY" -eq 1 ] && echo ' (--dry)')" "$DIR"
|
|
157
|
+
printf '%b' "$HUMAN"
|
|
158
|
+
printf 'total: %s/%s passed (%s%%)\n' "$PASS" "$TOTAL" "$SCORE_PCT"
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
# --dry always succeeds on well-formed data (it is the offline gate). A live run exits non-zero when
|
|
162
|
+
# anything failed so autopilot / CI notice a retrieval regression.
|
|
163
|
+
if [ "$DRY" -eq 1 ]; then
|
|
164
|
+
[ "$FAILN" -eq 0 ] && exit 0 || exit 1
|
|
165
|
+
fi
|
|
166
|
+
[ "$FAILN" -eq 0 ] && exit 0 || exit 1
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/stop-check.sh — the Stop=Both predicate for objective autopilot mode.
|
|
3
|
+
#
|
|
4
|
+
# cckit autopilot objective mode drives a capped `/loop --until '<check>'` that grows + hardens the
|
|
5
|
+
# benchmark sets each round. This is that `<check>`: it exits 0 (loop is done) ONLY when BOTH
|
|
6
|
+
# conditions hold at once —
|
|
7
|
+
# (A) SIZE: the suite has reached its record-count target (config target.minRecords), AND
|
|
8
|
+
# (B) CLEAN: the no-mistakes gate (gate.sh) has passed target.cleanRounds rounds in a row.
|
|
9
|
+
#
|
|
10
|
+
# It runs the gate itself and tracks the clean streak in benchmarks/.stop-state.json, so the loop
|
|
11
|
+
# can't stop on a round that grew the suite but broke it. A broken round resets the streak to 0.
|
|
12
|
+
#
|
|
13
|
+
# Usage: benchmark/stop-check.sh [--dir <benchmarks>] [--min N] [--rounds K] [--json]
|
|
14
|
+
# Exit 0 = stop (both met); non-zero = keep looping.
|
|
15
|
+
set -uo pipefail
|
|
16
|
+
|
|
17
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
18
|
+
# shellcheck source=/dev/null
|
|
19
|
+
. "$SCRIPT_DIR/lib/bench-common.sh"
|
|
20
|
+
|
|
21
|
+
JSON=0; MIN=""; ROUNDS=""
|
|
22
|
+
DIRFLAG=()
|
|
23
|
+
while [ "$#" -gt 0 ]; do
|
|
24
|
+
case "$1" in
|
|
25
|
+
--dir) BENCH_DIR="$2"; export BENCH_DIR; DIRFLAG=(--dir "$2"); shift 2 ;;
|
|
26
|
+
--dir=*) BENCH_DIR="${1#*=}"; export BENCH_DIR; DIRFLAG=(--dir "${1#*=}"); shift ;;
|
|
27
|
+
--min) MIN="$2"; shift 2 ;;
|
|
28
|
+
--min=*) MIN="${1#*=}"; shift ;;
|
|
29
|
+
--rounds) ROUNDS="$2"; shift 2 ;;
|
|
30
|
+
--rounds=*) ROUNDS="${1#*=}"; shift ;;
|
|
31
|
+
--json|--llm) JSON=1; shift ;;
|
|
32
|
+
-h|--help) sed -n '2,17p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
33
|
+
*) echo "stop-check.sh: unknown arg '$1'" >&2; exit 2 ;;
|
|
34
|
+
esac
|
|
35
|
+
done
|
|
36
|
+
|
|
37
|
+
command -v jq >/dev/null 2>&1 || { echo "stop-check.sh: jq is required" >&2; exit 2; }
|
|
38
|
+
|
|
39
|
+
DIR="$(bench_dir)"
|
|
40
|
+
CFG="$(bench_config)"
|
|
41
|
+
STATE="$DIR/.stop-state.json"
|
|
42
|
+
|
|
43
|
+
# Targets: flags win, else config, else conservative defaults.
|
|
44
|
+
[ -n "$MIN" ] || MIN="$( [ -n "$CFG" ] && jq -r '.target.minRecords // empty' "$CFG" 2>/dev/null)"
|
|
45
|
+
[ -n "$ROUNDS" ] || ROUNDS="$([ -n "$CFG" ] && jq -r '.target.cleanRounds // empty' "$CFG" 2>/dev/null)"
|
|
46
|
+
[ -n "$MIN" ] || MIN=12
|
|
47
|
+
[ -n "$ROUNDS" ] || ROUNDS=2
|
|
48
|
+
|
|
49
|
+
# (A) SIZE — total records across every set (dry-count via run.sh gives retrieval/abstain; add
|
|
50
|
+
# quality). Reuse the runners' --dry --json totals so the count matches exactly what ships.
|
|
51
|
+
ret_n="$(bash "$SCRIPT_DIR/run.sh" --dry --json "${DIRFLAG[@]+"${DIRFLAG[@]}"}" 2>/dev/null | jq -r '.total // 0')"
|
|
52
|
+
qual_n="$(bash "$SCRIPT_DIR/run-quality.sh" --dry --json "${DIRFLAG[@]+"${DIRFLAG[@]}"}" 2>/dev/null | jq -r '.count // 0')"
|
|
53
|
+
[ -n "$ret_n" ] || ret_n=0
|
|
54
|
+
[ -n "$qual_n" ] || qual_n=0
|
|
55
|
+
TOTAL=$((ret_n + qual_n))
|
|
56
|
+
size_ok=0; [ "$TOTAL" -ge "$MIN" ] && size_ok=1
|
|
57
|
+
|
|
58
|
+
# (B) CLEAN — run the gate this round; update the streak.
|
|
59
|
+
streak=0
|
|
60
|
+
[ -f "$STATE" ] && streak="$(jq -r '.clean_streak // 0' "$STATE" 2>/dev/null || echo 0)"
|
|
61
|
+
if bash "$SCRIPT_DIR/gate.sh" "${DIRFLAG[@]+"${DIRFLAG[@]}"}" >/dev/null 2>&1; then
|
|
62
|
+
streak=$((streak + 1))
|
|
63
|
+
else
|
|
64
|
+
streak=0 # a broken round resets the streak — cannot stop on it
|
|
65
|
+
fi
|
|
66
|
+
jq -n --argjson s "$streak" '{clean_streak:$s}' > "$STATE" 2>/dev/null || true
|
|
67
|
+
clean_ok=0; [ "$streak" -ge "$ROUNDS" ] && clean_ok=1
|
|
68
|
+
|
|
69
|
+
STOP=0; [ "$size_ok" -eq 1 ] && [ "$clean_ok" -eq 1 ] && STOP=1
|
|
70
|
+
|
|
71
|
+
if [ "$JSON" -eq 1 ]; then
|
|
72
|
+
jq -n --argjson total "$TOTAL" --argjson min "$MIN" --argjson streak "$streak" \
|
|
73
|
+
--argjson rounds "$ROUNDS" --argjson size "$size_ok" --argjson clean "$clean_ok" \
|
|
74
|
+
--argjson stop "$STOP" \
|
|
75
|
+
'{records:$total, min:$min, size_ok:($size==1), clean_streak:$streak, rounds:$rounds, clean_ok:($clean==1), stop:($stop==1)}'
|
|
76
|
+
else
|
|
77
|
+
printf 'stop-check: records %s/%s (%s) · clean streak %s/%s (%s) -> %s\n' \
|
|
78
|
+
"$TOTAL" "$MIN" "$([ "$size_ok" -eq 1 ] && echo met || echo below)" \
|
|
79
|
+
"$streak" "$ROUNDS" "$([ "$clean_ok" -eq 1 ] && echo met || echo short)" \
|
|
80
|
+
"$([ "$STOP" -eq 1 ] && echo STOP || echo CONTINUE)"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
[ "$STOP" -eq 1 ] && exit 0 || exit 1
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# commitlint-test.sh — the PR-title Conventional Commits gate (scripts/lib/commitlint.sh).
|
|
3
|
+
# Hermetic, no network. Discovered by scripts/test.sh, folded into scripts/check.sh + CI.
|
|
4
|
+
set -u
|
|
5
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
6
|
+
fail=0
|
|
7
|
+
# shellcheck source=/dev/null
|
|
8
|
+
. "$ROOT/scripts/lib/commitlint.sh"
|
|
9
|
+
|
|
10
|
+
ok() { if commitlint_check "$1" >/dev/null 2>&1; then echo "ok: accept '$1'"; else echo "FAIL: should ACCEPT '$1'"; fail=1; fi; }
|
|
11
|
+
bad() { if commitlint_check "$1" >/dev/null 2>&1; then echo "FAIL: should REJECT '$1'"; fail=1; else echo "ok: reject '$1'"; fi; }
|
|
12
|
+
|
|
13
|
+
# --- valid subjects (every version-bump level + non-functional types) ---
|
|
14
|
+
ok "feat: add a thing"
|
|
15
|
+
ok "fix: correct a bug"
|
|
16
|
+
ok "feat(orchestrate): headless launch"
|
|
17
|
+
ok "fix(config): base feature work on develop"
|
|
18
|
+
ok "feat!: drop the old flag"
|
|
19
|
+
ok "feat(api)!: rename the export"
|
|
20
|
+
ok "perf: speed up the scan"
|
|
21
|
+
ok "refactor: extract a helper"
|
|
22
|
+
ok "revert: undo the change"
|
|
23
|
+
ok "docs: update releasing.mdx"
|
|
24
|
+
ok "chore: bump deps"
|
|
25
|
+
ok "chore(main): release 1.2.3" # release-please's own Release PR title
|
|
26
|
+
ok "ci: pin the runner"
|
|
27
|
+
ok "build: adjust the bundle"
|
|
28
|
+
ok "style: reformat"
|
|
29
|
+
ok "test: add coverage"
|
|
30
|
+
ok "fix(scope-with-dash): ok"
|
|
31
|
+
ok "feat(docs-site): scoped slash allowed"
|
|
32
|
+
|
|
33
|
+
# --- invalid subjects ---
|
|
34
|
+
bad "add a thing" # no type
|
|
35
|
+
bad "Feat: capitalized type" # type must be lowercase
|
|
36
|
+
bad "feat add a thing" # missing colon
|
|
37
|
+
bad "feat:no space after colon" # missing space
|
|
38
|
+
bad "feat: " # empty description
|
|
39
|
+
bad "feat:" # empty description, no space
|
|
40
|
+
bad "wip: not a conventional type" # unknown type
|
|
41
|
+
bad "feature: not the short form" # unknown type
|
|
42
|
+
bad "feat(): empty scope" # scope cannot be empty
|
|
43
|
+
bad "" # empty subject
|
|
44
|
+
|
|
45
|
+
# --- CLI form works and mirrors the function ---
|
|
46
|
+
if bash "$ROOT/scripts/lib/commitlint.sh" "feat: via cli" >/dev/null 2>&1; then
|
|
47
|
+
echo "ok: CLI accepts a valid subject"
|
|
48
|
+
else
|
|
49
|
+
echo "FAIL: CLI should accept a valid subject"; fail=1
|
|
50
|
+
fi
|
|
51
|
+
if bash "$ROOT/scripts/lib/commitlint.sh" "nope" >/dev/null 2>&1; then
|
|
52
|
+
echo "FAIL: CLI should reject an invalid subject"; fail=1
|
|
53
|
+
else
|
|
54
|
+
echo "ok: CLI rejects an invalid subject"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (commitlint)" || echo "commitlint: FAILURES"
|
|
58
|
+
exit "$fail"
|
package/scripts/init.sh
CHANGED
|
@@ -722,6 +722,24 @@ for sc in setup-labels.sh setup-milestones.sh capture-project-ids.sh task-sync.s
|
|
|
722
722
|
done
|
|
723
723
|
echo " + scripts/ (libs + setup + task-sync + version-check + knowledge-lint)"
|
|
724
724
|
|
|
725
|
+
# ---- benchmark harness (generic machinery; kit-owned) + example dataset ----
|
|
726
|
+
# The harness measures how well THIS project's own canonical docs can be found + used by a cold
|
|
727
|
+
# agent (retrieval / adversarial / abstain / quality tiers). Machinery is kit-owned (refreshed on
|
|
728
|
+
# upgrade); the datasets under benchmarks/ are the project's own — we scaffold an EXAMPLE set +
|
|
729
|
+
# schema only, and safe_write preserves it on upgrade so growth is never clobbered.
|
|
730
|
+
for bs in run.sh run-quality.sh report.sh gate.sh stop-check.sh benchmark-test.sh; do
|
|
731
|
+
safe_copy "$KIT_ROOT/scripts/benchmark/$bs" "$TARGET/scripts/benchmark/$bs" exec
|
|
732
|
+
done
|
|
733
|
+
safe_copy "$KIT_ROOT/scripts/benchmark/lib/model.sh" "$TARGET/scripts/benchmark/lib/model.sh"
|
|
734
|
+
safe_copy "$KIT_ROOT/scripts/benchmark/lib/bench-common.sh" "$TARGET/scripts/benchmark/lib/bench-common.sh"
|
|
735
|
+
echo " + scripts/benchmark/ (doc-retrieval benchmark harness — see benchmarks/SCHEMA.md)"
|
|
736
|
+
|
|
737
|
+
mkdir -p "$TARGET/benchmarks"
|
|
738
|
+
for bf in SCHEMA.md benchmark.config.json retrieval.jsonl adversarial.jsonl abstain.jsonl quality.jsonl .gitignore; do
|
|
739
|
+
safe_write "$KIT_ROOT/templates/benchmarks/$bf" "$TARGET/benchmarks/$bf"
|
|
740
|
+
done
|
|
741
|
+
echo " + benchmarks/ (example dataset + schema — grow your own; run: scripts/benchmark/report.sh)"
|
|
742
|
+
|
|
725
743
|
# ---- knowledge base (governed dir: INDEX manifest; upgrade-safe) ---------
|
|
726
744
|
mkdir -p "$TARGET/knowledge"
|
|
727
745
|
safe_write "$KIT_ROOT/templates/knowledge-INDEX.md.tmpl" "$TARGET/knowledge/INDEX.md"
|
|
@@ -735,6 +753,14 @@ safe_write "$KIT_ROOT/templates/lib/kit-sigil.sh.tmpl" "$TARGET/.claude/lib/kit-
|
|
|
735
753
|
chmod +x "$TARGET/.claude/lib/kit-sigil.sh" 2>/dev/null || true
|
|
736
754
|
echo " + .claude/lib/kit-sigil.sh"
|
|
737
755
|
|
|
756
|
+
# ---- settings.json (versioned — travels to worktrees + collaborators) ---
|
|
757
|
+
# Unlike settings.local.json (gitignored, per-checkout), this one is CHECKED IN so the
|
|
758
|
+
# captain's pre-authorized wave-merge (gh pr merge under an approved plan) works in every
|
|
759
|
+
# worktree and for every collaborator without re-prompting. safe_write = preserve-if-exists.
|
|
760
|
+
mkdir -p "$TARGET/.claude"
|
|
761
|
+
safe_write "$KIT_ROOT/templates/settings/settings.json.tmpl" "$TARGET/.claude/settings.json"
|
|
762
|
+
echo " + .claude/settings.json (versioned captain merge permission)"
|
|
763
|
+
|
|
738
764
|
# ---- settings.local.json (+ hooks, additive) ----------------------------
|
|
739
765
|
mkdir -p "$TARGET/.claude"
|
|
740
766
|
safe_write "$KIT_ROOT/templates/settings/settings.local.json.tmpl" "$TARGET/.claude/settings.local.json"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# cckit — self-update the checkout this cckit runs from.
|
|
3
|
+
#
|
|
4
|
+
# A symlink install (cckit on PATH -> <checkout>/bin, plugin -> <checkout>) means "update"
|
|
5
|
+
# is just a fast-forward pull of the checkout. This script does that pull, safely:
|
|
6
|
+
# - resolves its OWN checkout root (works from any caller: hook, cron, by hand)
|
|
7
|
+
# - throttled: at most one network hit per THROTTLE window (stamp file), so a
|
|
8
|
+
# SessionStart hook can call it on every session for free
|
|
9
|
+
# - --ff-only on the checkout's CURRENT branch: never creates merges, never touches
|
|
10
|
+
# a diverged/dirty state -- worst case it silently does nothing
|
|
11
|
+
# - always exits 0: an update failure must never break a session start
|
|
12
|
+
#
|
|
13
|
+
# Usage: kit-self-update.sh [--force] [--quiet]
|
|
14
|
+
# --force ignore the throttle stamp
|
|
15
|
+
# --quiet suppress the "updated" notice
|
|
16
|
+
set -uo pipefail
|
|
17
|
+
|
|
18
|
+
FORCE=0; QUIET=0
|
|
19
|
+
while [[ $# -gt 0 ]]; do
|
|
20
|
+
case "$1" in
|
|
21
|
+
--force) FORCE=1; shift ;;
|
|
22
|
+
--quiet) QUIET=1; shift ;;
|
|
23
|
+
*) shift ;;
|
|
24
|
+
esac
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
# Resolve the checkout root from this script's real location (scripts/ -> root).
|
|
28
|
+
SELF_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
|
29
|
+
ROOT="$(cd -- "$SELF_DIR/.." >/dev/null 2>&1 && pwd)"
|
|
30
|
+
[[ -n "$ROOT" ]] || exit 0
|
|
31
|
+
git -C "$ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
|
|
32
|
+
|
|
33
|
+
# Throttle: one pull per window (default 4h). Stamp lives in the user cache dir.
|
|
34
|
+
THROTTLE="${CCKIT_SELF_UPDATE_THROTTLE:-14400}"
|
|
35
|
+
STAMP_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/cckit"
|
|
36
|
+
STAMP="$STAMP_DIR/self-update.stamp"
|
|
37
|
+
if [[ $FORCE -eq 0 && -f "$STAMP" ]]; then
|
|
38
|
+
now=$(date +%s)
|
|
39
|
+
last=$(stat -f %m "$STAMP" 2>/dev/null || stat -c %Y "$STAMP" 2>/dev/null || echo 0)
|
|
40
|
+
(( now - last < THROTTLE )) && exit 0
|
|
41
|
+
fi
|
|
42
|
+
mkdir -p "$STAMP_DIR" 2>/dev/null && touch "$STAMP" 2>/dev/null
|
|
43
|
+
|
|
44
|
+
before="$(git -C "$ROOT" rev-parse --short HEAD 2>/dev/null)"
|
|
45
|
+
# ff-only pull of the current branch; short timeouts so a dead network can't hang a hook.
|
|
46
|
+
GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=5 \
|
|
47
|
+
git -C "$ROOT" pull --ff-only --quiet 2>/dev/null || exit 0
|
|
48
|
+
after="$(git -C "$ROOT" rev-parse --short HEAD 2>/dev/null)"
|
|
49
|
+
|
|
50
|
+
if [[ $QUIET -eq 0 && -n "$before" && -n "$after" && "$before" != "$after" ]]; then
|
|
51
|
+
ver=""
|
|
52
|
+
command -v jq >/dev/null 2>&1 && ver="$(jq -r '.version // empty' "$ROOT/.claude-plugin/plugin.json" 2>/dev/null)"
|
|
53
|
+
echo "cckit self-updated: $before -> $after${ver:+ (v$ver)}"
|
|
54
|
+
fi
|
|
55
|
+
exit 0
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# commitlint.sh — validate a subject line against Conventional Commits. ONE implementation,
|
|
3
|
+
# shared by the PR-title gate (.github/workflows/commitlint.yml) and the local test suite.
|
|
4
|
+
#
|
|
5
|
+
# Why this exists: PRs are squash-merged (`gh pr merge --squash`), so the PR *title* becomes the
|
|
6
|
+
# single commit on the base branch that release-please reads to compute the next version. A
|
|
7
|
+
# non-conventional title makes release-please classify the change as "other" and silently
|
|
8
|
+
# under-bump (or skip the release) — so every PR title MUST be a Conventional Commit subject.
|
|
9
|
+
#
|
|
10
|
+
# commitlint.sh "<subject>" exit 0 = valid, 1 = invalid (with guidance on stderr)
|
|
11
|
+
# source commitlint.sh && commitlint_check "<subject>" same, as a function
|
|
12
|
+
#
|
|
13
|
+
# The accepted types are commitlint's config-conventional set, a superset of the types
|
|
14
|
+
# scripts/lib/version-bump.sh acts on (feat -> minor; fix/perf/refactor/revert -> patch;
|
|
15
|
+
# feat!/BREAKING CHANGE -> major; the rest -> no release). Keeping the two in step means a title
|
|
16
|
+
# that passes here is one release-please can always classify.
|
|
17
|
+
|
|
18
|
+
# Conventional Commit subject: type(scope)!: description
|
|
19
|
+
# type — one of the known types below
|
|
20
|
+
# (scope) — optional, e.g. (orchestrate), (main)
|
|
21
|
+
# ! — optional breaking-change marker
|
|
22
|
+
# : SPACE — required separator
|
|
23
|
+
# description — required, non-empty
|
|
24
|
+
_CL_TYPES='build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test'
|
|
25
|
+
_CL_RE="^(${_CL_TYPES})(\([a-z0-9][a-z0-9._/-]*\))?(!)?: .+"
|
|
26
|
+
|
|
27
|
+
commitlint_check() {
|
|
28
|
+
local subject="${1-}"
|
|
29
|
+
if [ -z "$subject" ]; then
|
|
30
|
+
printf 'commitlint: empty subject — nothing to validate\n' >&2
|
|
31
|
+
return 1
|
|
32
|
+
fi
|
|
33
|
+
if printf '%s' "$subject" | grep -qE "$_CL_RE"; then
|
|
34
|
+
return 0
|
|
35
|
+
fi
|
|
36
|
+
{
|
|
37
|
+
printf 'commitlint: not a Conventional Commit subject:\n'
|
|
38
|
+
printf ' %s\n\n' "$subject"
|
|
39
|
+
printf 'Expected: type(scope)!: summary\n'
|
|
40
|
+
printf ' type one of: %s\n' "$(printf '%s' "$_CL_TYPES" | tr '|' ' ')"
|
|
41
|
+
printf ' scope optional, e.g. feat(orchestrate): ...\n'
|
|
42
|
+
printf ' ! optional breaking-change marker, e.g. feat!: ...\n'
|
|
43
|
+
printf ' : then a space, then a non-empty summary\n\n'
|
|
44
|
+
printf 'Why it matters: this subject is the squash-merge commit release-please reads to pick\n'
|
|
45
|
+
printf 'the next version. A non-conventional subject under-bumps the release silently.\n'
|
|
46
|
+
} >&2
|
|
47
|
+
return 1
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Run as a CLI when executed directly (not when sourced).
|
|
51
|
+
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
|
|
52
|
+
commitlint_check "${1-}"
|
|
53
|
+
fi
|
|
@@ -37,6 +37,27 @@ if [ -n "${KTO_TEST_INNER:-}" ]; then
|
|
|
37
37
|
eq "kind from labels" "$(kto_labels_kind 'kind:feat,priority:p2,role:tech-lead')" "feat"
|
|
38
38
|
eq "role absent" "$(kto_labels_role 'kind:chore,priority:p3')" ""
|
|
39
39
|
|
|
40
|
+
# kto_pr_title — Conventional Commit PR titles (the squash-merge subject the commit gate reads)
|
|
41
|
+
. "$dir/commitlint.sh" # the shared validator kto_pr_title reuses to honor a conventional summary
|
|
42
|
+
eq "task→feat + effort prefix stripped" \
|
|
43
|
+
"$(kto_pr_title '[Effort 182] 1 · Enforce Conventional Commits' '' 'kind:task,priority:p1')" \
|
|
44
|
+
"feat: Enforce Conventional Commits"
|
|
45
|
+
eq "double prefix [Effort] N · [Tag]" \
|
|
46
|
+
"$(kto_pr_title '[Effort] 86 · [Core] Plan future work' '' 'kind:task')" \
|
|
47
|
+
"feat: Plan future work"
|
|
48
|
+
eq "plain bug label → fix" \
|
|
49
|
+
"$(kto_pr_title 'mail hook goes silent' '' 'bug')" \
|
|
50
|
+
"fix: mail hook goes silent"
|
|
51
|
+
eq "kind:chore → chore" \
|
|
52
|
+
"$(kto_pr_title '[Effort 75] 7 · rich rendering' '' 'kind:chore')" \
|
|
53
|
+
"chore: rich rendering"
|
|
54
|
+
eq "conventional summary wins over derivation" \
|
|
55
|
+
"$(kto_pr_title '[Effort 182] 2 · Publish to npm' 'ci: publish via OIDC' 'kind:task')" \
|
|
56
|
+
"ci: publish via OIDC"
|
|
57
|
+
eq "non-conventional summary ignored → derive" \
|
|
58
|
+
"$(kto_pr_title 'Benchmark harness' 'ported a harness' 'kind:feat')" \
|
|
59
|
+
"feat: Benchmark harness"
|
|
60
|
+
|
|
40
61
|
# kto_compose_pr_body must carry Closes #N and the Summary
|
|
41
62
|
body="$(kto_compose_pr_body 42 'Did the thing.' 'tech-lead')"
|
|
42
63
|
case "$body" in *"Closes #42"*) ;; *) echo "FAIL($KTO_TEST_INNER): pr body missing Closes #42"; fail=1 ;; esac
|
|
@@ -69,6 +69,52 @@ kto_labels_kind() {
|
|
|
69
69
|
printf '%s' "$1" | tr ',' '\n' | grep '^kind:' | head -1 | cut -d: -f2
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
# Compose the PR title as a Conventional Commit subject. Because PRs are squash-merged, this title
|
|
73
|
+
# becomes the single commit release-please reads to pick the next version — a non-conventional title
|
|
74
|
+
# under-bumps silently, and the commitlint gate (.github/workflows/commitlint.yml) now rejects it.
|
|
75
|
+
# Args: <raw-issue-title> <summary> <labels-csv>
|
|
76
|
+
# 1. An author <summary> that is ALREADY a conventional subject wins — the author knows the change's
|
|
77
|
+
# true type (e.g. a kind:task that is really a fix). Validated by the shared commitlint.sh.
|
|
78
|
+
# 2. Otherwise derive the type from the kind:/bug label (kind:task, the default, → feat) and strip
|
|
79
|
+
# the "[Effort N] M · " / leading "[Tag] " noise from the issue title.
|
|
80
|
+
# Network-free (covered by the self-test). Output always passes commitlint_check.
|
|
81
|
+
kto_pr_title() {
|
|
82
|
+
local raw="${1:-}" summary="${2:-}" labels="${3:-}" kind ctype desc
|
|
83
|
+
# Reuse the ONE commit-lint implementation. bin/cckit sources it; if a bare caller hasn't, pull it
|
|
84
|
+
# from the repo (kto_task_pr always runs in-repo). Degrades gracefully if it can't be found.
|
|
85
|
+
if ! type commitlint_check >/dev/null 2>&1; then
|
|
86
|
+
local _cl; _cl="$(git rev-parse --show-toplevel 2>/dev/null)/scripts/lib/commitlint.sh"
|
|
87
|
+
[ -f "$_cl" ] && . "$_cl" 2>/dev/null || true
|
|
88
|
+
fi
|
|
89
|
+
# 1) Prefer an author-provided conventional summary.
|
|
90
|
+
if [ -n "$summary" ] && type commitlint_check >/dev/null 2>&1 && commitlint_check "$summary" >/dev/null 2>&1; then
|
|
91
|
+
printf '%s' "$summary"; return 0
|
|
92
|
+
fi
|
|
93
|
+
# 2) Derive the type from the kind:/bug label.
|
|
94
|
+
kind="$(kto_labels_kind "$labels")"
|
|
95
|
+
case "$kind" in
|
|
96
|
+
feat) ctype=feat ;;
|
|
97
|
+
chore) ctype=chore ;;
|
|
98
|
+
docs) ctype=docs ;;
|
|
99
|
+
ci) ctype=ci ;;
|
|
100
|
+
test) ctype=test ;;
|
|
101
|
+
perf) ctype=perf ;;
|
|
102
|
+
refactor) ctype=refactor ;;
|
|
103
|
+
fix|bug) ctype=fix ;;
|
|
104
|
+
*) ctype=feat ;; # kind:task (the default) and anything unknown → feat
|
|
105
|
+
esac
|
|
106
|
+
case ",$labels," in *,bug,*) ctype=fix ;; esac # a plain `bug` label → fix
|
|
107
|
+
# 3) Strip "[Effort N] M · " (the "· " consumed here as a literal — byte-wise match is portable
|
|
108
|
+
# across BSD/GNU sed + locales; a negated class over the multibyte middot is not) and then a
|
|
109
|
+
# leading "[Tag] " (e.g. [Core]). Order matters: eat the separator before the next tag's "[".
|
|
110
|
+
desc="$(printf '%s' "$raw" | sed -E \
|
|
111
|
+
-e 's/^\[Effort[^]]*\] +[0-9]+ +· +//' \
|
|
112
|
+
-e 's/^\[[^]]+\] +//' \
|
|
113
|
+
-e 's/^[[:space:]]+//')"
|
|
114
|
+
[ -n "$desc" ] || desc="$raw"
|
|
115
|
+
printf '%s: %s' "$ctype" "$desc"
|
|
116
|
+
}
|
|
117
|
+
|
|
72
118
|
# Compose a PR body from the kit-task-pr template. Args: <num> <summary> <role-slug>
|
|
73
119
|
kto_compose_pr_body() {
|
|
74
120
|
local num="$1" summary="$2" role="$3" sig=""
|
|
@@ -163,7 +209,9 @@ kto_task_pr() {
|
|
|
163
209
|
labels=$(printf '%s' "$meta" | jq -r '[.labels[].name] | join(",")')
|
|
164
210
|
milestone=$(printf '%s' "$meta" | jq -r '.milestone.title // ""')
|
|
165
211
|
role="$(kto_labels_role "$labels")"
|
|
166
|
-
|
|
212
|
+
# Conventional Commit PR title (squash-merge commit release-please reads + the commitlint gate).
|
|
213
|
+
local pr_title; pr_title="$(kto_pr_title "$title" "$summary" "$labels")"
|
|
214
|
+
[[ -z "$commit_msg" ]] && commit_msg="$pr_title"
|
|
167
215
|
|
|
168
216
|
if [[ -n "$(git status --porcelain)" ]]; then
|
|
169
217
|
git add -A
|
|
@@ -179,7 +227,7 @@ kto_task_pr() {
|
|
|
179
227
|
|
|
180
228
|
url=$(gh pr create --repo "$repo" \
|
|
181
229
|
--base "$(kto_base_branch)" --head "$branch" \
|
|
182
|
-
--title "$
|
|
230
|
+
--title "$pr_title" \
|
|
183
231
|
--body "$(kto_compose_pr_body "$num" "$summary" "$role")" \
|
|
184
232
|
--label "$labels" \
|
|
185
233
|
${milestone:+--milestone "$milestone"} \
|
package/scripts/orchestrate.sh
CHANGED
|
@@ -144,7 +144,14 @@ for entry in "${ENTRIES[@]}"; do
|
|
|
144
144
|
tmux select-layout -t "$SESSION:flows" tiled >/dev/null
|
|
145
145
|
fi
|
|
146
146
|
if [ "$SEED" -eq 1 ]; then
|
|
147
|
-
|
|
147
|
+
# Single-quote the prompt so its embedded quotes / redirection chars (e.g. the
|
|
148
|
+
# "<summary>" and "<reason>" placeholders) reach the agent literally instead of being
|
|
149
|
+
# parsed by the pane's shell. Double-quoting collided with the seed's own quotes and
|
|
150
|
+
# dumped `<summary>` onto zsh as a redirection ("no such file or directory: summary"),
|
|
151
|
+
# so the agent never launched. Escape any single quotes for safe single-quote wrapping.
|
|
152
|
+
seed="$(seed_for "$num" "$branch")"
|
|
153
|
+
esc=${seed//\'/\'\\\'\'}
|
|
154
|
+
tmux send-keys -t "$pane" "$AGENT '$esc'" C-m
|
|
148
155
|
else
|
|
149
156
|
tmux send-keys -t "$pane" "$AGENT" C-m
|
|
150
157
|
fi
|
package/scripts/portable-test.sh
CHANGED
|
@@ -84,7 +84,7 @@ yes "gc resolves the invoking repo" "$(cat "$GH_REPO_LOG")" "$FIX_REPO"
|
|
|
84
84
|
# A new verb that is neither exercised nor listed here fails the harness — forcing a coverage
|
|
85
85
|
# decision. SKIP holds verbs that mutate, need args, read stdin, are interactive, or act on the
|
|
86
86
|
# install itself (not the invoking project's board) — deliberately not driven here.
|
|
87
|
-
SKIP="adopt autopilot close commands completions contribute copilot debug digest effort encode-context handoff help init install migrate msg orchestrate pr release render resume start ui update version watch"
|
|
87
|
+
SKIP="adopt autopilot bench close commands completions contribute copilot debug digest effort encode-context handoff help init install migrate msg orchestrate pr release render resume start ui update version watch"
|
|
88
88
|
classified() { case " $EXERCISE $SKIP " in *" $1 "*) return 0 ;; *) return 1 ;; esac; }
|
|
89
89
|
for v in $("$CCKIT" commands); do
|
|
90
90
|
classified "$v" || { echo "FAIL: verb '$v' is unclassified — add it to EXERCISE (read-only, assert no own-repo leak) or SKIP in portable-test.sh"; fail=1; }
|