@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.
Files changed (82) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +15 -4
  3. package/README.md +25 -3
  4. package/bin/cckit +91 -8
  5. package/cckit.config.json +1 -1
  6. package/kit.config.schema.json +43 -2
  7. package/package.json +1 -1
  8. package/scripts/autopilot-test.sh +68 -0
  9. package/scripts/autopilot.sh +16 -10
  10. package/scripts/check.sh +14 -1
  11. package/scripts/copilot-loop-test.sh +3 -0
  12. package/scripts/guard-raw-git-ops-test.sh +73 -0
  13. package/scripts/init.sh +68 -8
  14. package/scripts/lib/agent-profile-test.sh +151 -0
  15. package/scripts/lib/agent-profile.sh +195 -0
  16. package/scripts/lib/agent-resolve-test.sh +156 -0
  17. package/scripts/lib/agent-resolve.sh +177 -0
  18. package/scripts/lib/branch-owner-test.sh +99 -0
  19. package/scripts/lib/branch-owner.sh +194 -0
  20. package/scripts/lib/captain-test.sh +86 -0
  21. package/scripts/lib/captain.sh +142 -7
  22. package/scripts/lib/contribute-root-test.sh +40 -0
  23. package/scripts/lib/contribute-root.sh +22 -0
  24. package/scripts/lib/effort-metrics.sh +14 -1
  25. package/scripts/lib/effort-ops-test.sh +54 -2
  26. package/scripts/lib/effort-ops.sh +243 -23
  27. package/scripts/lib/effort-parity-test.sh +5 -3
  28. package/scripts/lib/effort-slug.sh +16 -2
  29. package/scripts/lib/effort.sh +49 -15
  30. package/scripts/lib/gh-project.sh +14 -0
  31. package/scripts/lib/gh-rest-test.sh +301 -0
  32. package/scripts/lib/gh-rest.sh +289 -0
  33. package/scripts/lib/hook-refresh-test.sh +65 -0
  34. package/scripts/lib/hook-refresh.sh +62 -0
  35. package/scripts/lib/kit-config.sh +6 -0
  36. package/scripts/lib/kit-gc-test.sh +178 -1
  37. package/scripts/lib/kit-gc.sh +251 -55
  38. package/scripts/lib/kit-task-ops-test.sh +15 -0
  39. package/scripts/lib/kit-task-ops.sh +231 -58
  40. package/scripts/lib/kto-task-close-test.sh +83 -0
  41. package/scripts/lib/kto-task-pr-merge-test.sh +129 -0
  42. package/scripts/lib/kto-task-pr-test.sh +59 -0
  43. package/scripts/lib/orchestration-runtime-test.sh +142 -0
  44. package/scripts/lib/orchestration-runtime.sh +171 -0
  45. package/scripts/lib/review-stage-test.sh +241 -0
  46. package/scripts/lib/review-stage.sh +259 -0
  47. package/scripts/lib/stage-receipt-test.sh +252 -0
  48. package/scripts/lib/stage-receipt.sh +442 -0
  49. package/scripts/lib/test-env-test.sh +25 -0
  50. package/scripts/lib/test-env.sh +33 -0
  51. package/scripts/lib/worker-brief-test.sh +120 -0
  52. package/scripts/lib/worker-brief.sh +185 -0
  53. package/scripts/lib/worktree-issue.sh +14 -0
  54. package/scripts/lib/worktree-ports-test.sh +146 -0
  55. package/scripts/lib/worktree-start.sh +153 -8
  56. package/scripts/lib/zsh-safety-test.sh +67 -0
  57. package/scripts/orchestrate.sh +124 -22
  58. package/scripts/portable-test.sh +22 -1
  59. package/scripts/review-lint-baseline.txt +28 -0
  60. package/scripts/review-lint-test.sh +271 -0
  61. package/scripts/review-lint.sh +259 -0
  62. package/scripts/review-rules.conf +55 -0
  63. package/scripts/setup-labels.sh +21 -1
  64. package/scripts/skill-frontmatter-baseline.txt +24 -0
  65. package/scripts/skill-frontmatter-lint-test.sh +156 -0
  66. package/scripts/skill-frontmatter-lint.sh +182 -0
  67. package/scripts/task-sync.sh +8 -0
  68. package/scripts/test.sh +10 -1
  69. package/skills/kit-autopilot/SKILL.md +13 -1
  70. package/skills/kit-cleanup/SKILL.md +5 -3
  71. package/skills/kit-contribute/SKILL.md +6 -5
  72. package/skills/kit-effort-close/SKILL.md +8 -3
  73. package/skills/kit-effort-pr/SKILL.md +16 -95
  74. package/skills/kit-gc/SKILL.md +15 -10
  75. package/skills/kit-security-sweep/SKILL.md +4 -6
  76. package/skills/kit-ship/SKILL.md +1 -1
  77. package/skills/kit-task-pr/SKILL.md +2 -0
  78. package/templates/hooks/guard-raw-git-ops.sh.tmpl +193 -0
  79. package/templates/rules/branch-naming.md +6 -0
  80. package/templates/rules/effort-model.md +3 -0
  81. package/templates/rules/naming-and-ids.md +4 -1
  82. package/templates/settings/settings.json.tmpl +4 -2
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env bash
2
+ # skill-frontmatter-lint-test.sh — behavioral test for the skill frontmatter context-budget ratchet.
3
+ # Builds a throwaway skills/ tree in a temp ROOT and asserts the four transitions that matter:
4
+ # under budget passes, a new over-budget skill fails, a baselined skill may sit still but not grow,
5
+ # and a shrunk skill is reported as re-baselineable.
6
+ set -uo pipefail
7
+
8
+ LINT="$(cd "$(dirname "$0")" && pwd)/skill-frontmatter-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/skills"
16
+ cp "$LINT" "$TMP/scripts/"
17
+
18
+ # Write skills/<name>/SKILL.md with a description of $2 chars and when_to_use of $3 chars.
19
+ mk_skill() {
20
+ local name="$1" dlen="$2" wlen="$3"
21
+ mkdir -p "$TMP/skills/$name"
22
+ {
23
+ echo "---"
24
+ echo "name: $name"
25
+ printf 'description: %s\n' "$(head -c "$dlen" < /dev/zero | tr '\0' 'd')"
26
+ [ "$wlen" -gt 0 ] && printf 'when_to_use: %s\n' "$(head -c "$wlen" < /dev/zero | tr '\0' 'w')"
27
+ echo "---"
28
+ echo
29
+ echo "body"
30
+ } > "$TMP/skills/$name/SKILL.md"
31
+ }
32
+
33
+ # Capture rather than pipe: `run | grep -q` would let grep exit early, kill `run` with SIGPIPE,
34
+ # and — under `set -o pipefail` — report the whole pipeline as failed even on a successful match.
35
+ run() { ( cd "$TMP" && bash scripts/skill-frontmatter-lint.sh "$@" 2>&1 ); }
36
+ run_out=""; run_rc=0
37
+ capture() { run_out="$(run "$@")"; run_rc=$?; }
38
+
39
+ # --- 1. a lean skill passes with no baseline at all -------------------------
40
+ mk_skill lean 100 80
41
+ run >/dev/null 2>&1 && pass "lean skill passes with no baseline" \
42
+ || fail "lean skill passes with no baseline"
43
+
44
+ # --- 2. measurement is correct across a block scalar ------------------------
45
+ # description 100 + when_to_use 80 = 180 total.
46
+ got="$(run --report | awk '$1=="lean" {print $4}')"
47
+ [ "$got" = "180" ] && pass "measures description+when_to_use (got $got)" \
48
+ || fail "measures description+when_to_use (expected 180, got $got)"
49
+
50
+ # --- 3. a NEW over-budget skill fails ---------------------------------------
51
+ mk_skill bloated 700 200
52
+ capture
53
+ if [ "$run_rc" -eq 0 ]; then
54
+ fail "new over-budget skill is rejected (exited 0)"
55
+ elif printf '%s' "$run_out" | grep -q "over the .*listing budget"; then
56
+ pass "new over-budget skill is rejected"
57
+ else
58
+ fail "new over-budget skill is rejected (wrong message: $run_out)"
59
+ fi
60
+
61
+ # --- 4. once baselined, the same skill is grandfathered ---------------------
62
+ run --update >/dev/null 2>&1
63
+ run >/dev/null 2>&1 && pass "baselined skill is grandfathered" \
64
+ || fail "baselined skill is grandfathered"
65
+
66
+ # --- 5. but it may not GROW -------------------------------------------------
67
+ mk_skill bloated 900 200
68
+ capture
69
+ if [ "$run_rc" -eq 0 ]; then
70
+ fail "growth past baseline is rejected (exited 0)"
71
+ elif printf '%s' "$run_out" | grep -q "always-resident context may not grow"; then
72
+ pass "growth past baseline is rejected"
73
+ else
74
+ fail "growth past baseline is rejected (wrong message: $run_out)"
75
+ fi
76
+
77
+ # --- 6. shrinking under budget passes and nudges a re-baseline -------------
78
+ mk_skill bloated 200 100
79
+ capture
80
+ if [ "$run_rc" -ne 0 ]; then
81
+ fail "shrunk skill passes and nudges --update (exited $run_rc)"
82
+ elif printf '%s' "$run_out" | grep -q "now under budget"; then
83
+ pass "shrunk skill passes and nudges --update"
84
+ else
85
+ fail "shrunk skill passes but no re-baseline nudge"
86
+ fi
87
+
88
+ # --- 7. the measurement does not move with the locale -----------------------
89
+ # `${#s}` counts CHARACTERS under a UTF-8 locale and BYTES under C/POSIX. With multibyte text in a
90
+ # description, a baseline generated under one locale fires the ratchet under the other — on skills
91
+ # nobody touched. The lint pins LC_ALL, so both runs must agree exactly.
92
+ rm -rf "$TMP/skills"; mkdir -p "$TMP/skills"; rm -f "$TMP/scripts/skill-frontmatter-baseline.txt"
93
+ mkdir -p "$TMP/skills/multibyte"
94
+ {
95
+ echo "---"
96
+ echo "name: multibyte"
97
+ printf 'description: %s — %s · %s\n' "$(head -c 200 < /dev/zero | tr '\0' 'd')" \
98
+ "$(head -c 200 < /dev/zero | tr '\0' 'e')" \
99
+ "$(head -c 200 < /dev/zero | tr '\0' 'f')"
100
+ echo "---"
101
+ echo
102
+ echo "body"
103
+ } > "$TMP/skills/multibyte/SKILL.md"
104
+ c_out="$( cd "$TMP" && LC_ALL=C bash scripts/skill-frontmatter-lint.sh --report 2>&1 )"
105
+ u_out="$( cd "$TMP" && LC_ALL=en_US.UTF-8 bash scripts/skill-frontmatter-lint.sh --report 2>&1 )"
106
+ [ "$c_out" = "$u_out" ] && pass "the count is identical under LC_ALL=C and UTF-8" \
107
+ || fail "the count moves with the locale:
108
+ C: $c_out
109
+ UTF8: $u_out"
110
+
111
+ # A baseline written under one locale must still pass the gate under the other.
112
+ ( cd "$TMP" && LC_ALL=en_US.UTF-8 bash scripts/skill-frontmatter-lint.sh --update ) >/dev/null 2>&1
113
+ lc_out="$( cd "$TMP" && LC_ALL=C bash scripts/skill-frontmatter-lint.sh 2>&1 )"; lc_rc=$?
114
+ [ "$lc_rc" -eq 0 ] && pass "a UTF-8 baseline passes under LC_ALL=C" \
115
+ || fail "a UTF-8 baseline passes under LC_ALL=C (rc=$lc_rc: $lc_out)"
116
+ rm -f "$TMP/scripts/skill-frontmatter-baseline.txt"
117
+
118
+ # --- 8. .claude/skills/ is linted too — the layout init.sh actually scaffolds
119
+ # Hard-coding `skills` made the shipped lint a permanent no-op in every consumer project.
120
+ rm -rf "$TMP/skills"
121
+ mkdir -p "$TMP/.claude/skills/scaffolded"
122
+ {
123
+ echo "---"
124
+ echo "name: scaffolded"
125
+ printf 'description: %s\n' "$(head -c 700 < /dev/zero | tr '\0' 'd')"
126
+ echo "---"
127
+ } > "$TMP/.claude/skills/scaffolded/SKILL.md"
128
+ capture
129
+ if [ "$run_rc" -ne 0 ] && printf '%s' "$run_out" | grep -q 'scaffolded'; then
130
+ pass ".claude/skills/ is linted"
131
+ else
132
+ fail ".claude/skills/ is linted (rc=$run_rc: $run_out)"
133
+ fi
134
+ rm -rf "$TMP/.claude"
135
+
136
+ # --- 9. --baseline-path is the one place the filename is spelled ------------
137
+ # init.sh used to reconstruct it as "<lint>-baseline.txt", which for THIS lint names a file that
138
+ # never exists — so its "seed once" guard never matched and every upgrade re-baselined silently.
139
+ bp_out="$( cd "$TMP" && bash scripts/skill-frontmatter-lint.sh --baseline-path 2>&1 )"
140
+ [ "$bp_out" = "scripts/skill-frontmatter-baseline.txt" ] \
141
+ && pass "--baseline-path reports the baseline" \
142
+ || fail "--baseline-path reports the baseline (got '$bp_out')"
143
+ # It answers even with no skills tree at all — init.sh asks before anything is scaffolded.
144
+ [ -d "$TMP/skills" ] && fail "fixture leaked a skills/ dir into the no-tree check"
145
+ bp2="$( cd "$TMP" && bash scripts/skill-frontmatter-lint.sh --baseline-path 2>&1 )"
146
+ [ "$bp2" = "scripts/skill-frontmatter-baseline.txt" ] \
147
+ && pass "--baseline-path answers with no skills tree" \
148
+ || fail "--baseline-path answers with no skills tree (got '$bp2')"
149
+
150
+ # --- 10. a repo with no skills tree is a no-op, not a failure ---------------
151
+ rm -rf "$TMP/skills"
152
+ run >/dev/null 2>&1 && pass "missing skills tree is a no-op" \
153
+ || fail "missing skills tree is a no-op"
154
+
155
+ [ "$fails" -eq 0 ] && echo "ok skill-frontmatter-lint-test passed" || echo "FAIL skill-frontmatter-lint-test"
156
+ exit "$fails"
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env bash
2
+ # skill-frontmatter-lint.sh — context-budget guardrail for skill frontmatter (kit-owned).
3
+ #
4
+ # WHY: Claude Code concatenates a skill's `description` + `when_to_use` into the always-loaded
5
+ # skill listing. Both fields sit in every session's context whether or not the skill is ever
6
+ # invoked — only the SKILL.md *body* is lazy. Unbudgeted, these fields grow into second bodies:
7
+ # the listing text is rent paid on every turn, and past a harness cap the tail is silently
8
+ # truncated, so an over-long field costs tokens while delivering nothing.
9
+ #
10
+ # WHAT: measures description + when_to_use per skill and enforces a RATCHET, not a hard cap —
11
+ # today's over-budget skills are recorded in a baseline and allowed to stay as they are, but
12
+ # nothing may grow past its recorded size and no NEW skill may land over budget. That stops
13
+ # regrowth without forcing a rewrite of existing skills.
14
+ #
15
+ # scripts/skill-frontmatter-lint.sh lint against the baseline (the gate)
16
+ # scripts/skill-frontmatter-lint.sh --report print every skill's cost, sorted; never fails
17
+ # scripts/skill-frontmatter-lint.sh --update rewrite the baseline from current sizes
18
+ #
19
+ # Baseline: scripts/skill-frontmatter-baseline.txt ("<skill> <bytes>" per line; # comments ok)
20
+ # bash 3.2 compatible (no associative arrays, no mapfile).
21
+ set -uo pipefail
22
+
23
+ # LOCALE — pinned, because the measurement changes with it. `${#s}` counts CHARACTERS under a UTF-8
24
+ # locale and BYTES under C/POSIX, and skill descriptions are full of em-dashes and `·`. A baseline
25
+ # generated under one and checked under the other makes the ratchet fire on skills nobody touched:
26
+ # under LC_ALL=C this repo's UTF-8 baseline reported 15 skills as "grown". CI only looked green
27
+ # because ubuntu-latest happens to export LANG=C.UTF-8, which test.yml never pins.
28
+ #
29
+ # Bytes win: every environment can produce them, and no locale needs to be installed to reproduce a
30
+ # number. The budget is therefore a byte budget, and an em-dash costs the three bytes it occupies.
31
+ LC_ALL=C
32
+ export LC_ALL
33
+
34
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
35
+ cd "$ROOT"
36
+
37
+ # SKILL ROOTS — both layouts, because this lint SHIPS to consumer projects. The kit's own skills
38
+ # live in `skills/`; `init.sh` scaffolds a project's to `.claude/skills/<name>/SKILL.md`. Hard-coding
39
+ # `skills` made the installed copy a permanent no-op: it exited 0 with "nothing to lint" in every
40
+ # project it was ever shipped to, so the context budget was enforced only in the kit's own repo.
41
+ SKILL_ROOTS=""
42
+ for _root in skills .claude/skills; do
43
+ [ -d "$_root" ] && SKILL_ROOTS="$SKILL_ROOTS $_root"
44
+ done
45
+ BASELINE="scripts/skill-frontmatter-baseline.txt"
46
+
47
+ # Budgets in bytes (see the LC_ALL note above). A skill at or under LISTING_BUDGET is always fine; above it, the skill
48
+ # must be baselined and must not have grown. Chosen from the observed distribution: the terse
49
+ # task verbs (kit-task-pr, kit-task-pr-merge, kit-task-new) all land comfortably under 300.
50
+ LISTING_BUDGET="${KIT_SKILL_LISTING_BUDGET:-500}"
51
+
52
+ FAIL=0
53
+ err() { echo "x $1"; FAIL=1; }
54
+ ok() { echo "ok $1"; }
55
+ note() { echo " $1"; }
56
+
57
+ # ---- frontmatter field extraction ------------------------------------------
58
+ # Prints the value of a top-level frontmatter field, including folded/block-scalar continuation
59
+ # lines (`when_to_use: |`), stopping at the next top-level key or the closing `---`.
60
+ fm_field() {
61
+ awk -v key="$2" '
62
+ NR == 1 && $0 == "---" { infm = 1; next }
63
+ !infm { exit }
64
+ $0 == "---" { exit }
65
+ {
66
+ if (index($0, key ":") == 1) {
67
+ grab = 1
68
+ sub("^" key ":[ \t]*", "")
69
+ if (length($0)) print
70
+ next
71
+ }
72
+ if (grab && $0 ~ /^[A-Za-z_][A-Za-z0-9_-]*:/) { grab = 0 }
73
+ if (grab) { sub(/^[ \t]+/, ""); sub(/[ \t]+$/, ""); print }
74
+ }
75
+ ' "$1"
76
+ }
77
+
78
+ # Listing cost = the bytes the harness actually keeps resident, newlines collapsed.
79
+ listing_chars() {
80
+ local f="$1" d w
81
+ d="$(fm_field "$f" description | tr -d '\n')"
82
+ w="$(fm_field "$f" when_to_use | tr -d '\n')"
83
+ printf '%s' "${#d} ${#w} $(( ${#d} + ${#w} ))"
84
+ }
85
+
86
+ baseline_for() {
87
+ [ -f "$BASELINE" ] || { echo ""; return; }
88
+ grep -v '^[[:space:]]*#' "$BASELINE" 2>/dev/null \
89
+ | awk -v s="$1" '$1 == s { print $2; exit }'
90
+ }
91
+
92
+ MODE="${1:-lint}"
93
+
94
+ # The one place the baseline filename is spelled. init.sh asks for it rather than reconstructing
95
+ # it — it used to guess "<lint>-baseline.txt", which for this lint is a file that never exists, so
96
+ # its "seed once, never regenerate" guard never matched and every upgrade silently re-baselined.
97
+ if [ "$MODE" = "--baseline-path" ]; then
98
+ printf '%s\n' "$BASELINE"
99
+ exit 0
100
+ fi
101
+
102
+ if [ -z "$SKILL_ROOTS" ]; then
103
+ echo "skill-frontmatter-lint: no skills/ or .claude/skills/ directory — nothing to lint"
104
+ exit 0
105
+ fi
106
+
107
+ # ---- collect ----------------------------------------------------------------
108
+ rows="" # "<total> <desc> <when> <skill>" per line
109
+ total_all=0
110
+ count=0
111
+ while IFS= read -r f; do
112
+ [ -n "$f" ] || continue
113
+ skill="$(basename "$(dirname "$f")")"
114
+ set -- $(listing_chars "$f")
115
+ d="$1"; w="$2"; t="$3"
116
+ rows="${rows}${t} ${d} ${w} ${skill}
117
+ "
118
+ total_all=$(( total_all + t ))
119
+ count=$(( count + 1 ))
120
+ done < <(find $SKILL_ROOTS -mindepth 2 -maxdepth 2 -name 'SKILL.md' 2>/dev/null | sort)
121
+
122
+ if [ "$count" -eq 0 ]; then
123
+ echo "skill-frontmatter-lint: no SKILL.md found under$SKILL_ROOTS"
124
+ exit 0
125
+ fi
126
+
127
+ # ---- --report ---------------------------------------------------------------
128
+ if [ "$MODE" = "--report" ]; then
129
+ printf '%-26s %7s %12s %8s\n' skill description when_to_use total
130
+ printf '%s' "$rows" | sort -rn | while read -r t d w s; do
131
+ flag=""; [ "$t" -gt "$LISTING_BUDGET" ] && flag=" <- over ${LISTING_BUDGET}"
132
+ printf '%-26s %7s %12s %8s%s\n' "$s" "$d" "$w" "$t" "$flag"
133
+ done
134
+ echo
135
+ echo "$count skills, ${total_all} bytes resident (~$(( total_all / 4 )) tokens every turn)"
136
+ exit 0
137
+ fi
138
+
139
+ # ---- --update ---------------------------------------------------------------
140
+ if [ "$MODE" = "--update" ]; then
141
+ {
142
+ echo "# skill-frontmatter-baseline.txt — generated by scripts/skill-frontmatter-lint.sh --update"
143
+ echo "# Skills whose description+when_to_use exceed the ${LISTING_BUDGET}-byte listing budget."
144
+ echo "# These are GRANDFATHERED: allowed to stay, but may never grow. Shrink them and re-run"
145
+ echo "# --update to tighten the ratchet. A skill that drops under budget leaves this file."
146
+ echo "#"
147
+ echo "# <skill> <bytes>"
148
+ printf '%s' "$rows" | sort -rn | while read -r t d w s; do
149
+ [ "$t" -gt "$LISTING_BUDGET" ] && printf '%s %s\n' "$s" "$t"
150
+ done
151
+ } > "$BASELINE"
152
+ echo "ok wrote $BASELINE ($(grep -cv '^[[:space:]]*#' "$BASELINE") grandfathered)"
153
+ exit 0
154
+ fi
155
+
156
+ # ---- lint (the gate) --------------------------------------------------------
157
+ over=0
158
+ while read -r t d w s; do
159
+ [ -n "$s" ] || continue
160
+ if [ "$t" -le "$LISTING_BUDGET" ]; then
161
+ # Under budget. If it was baselined, it has been fixed — nudge to tighten the ratchet.
162
+ if [ -n "$(baseline_for "$s")" ]; then
163
+ note "$s is now under budget (${t}) — run --update to drop it from the baseline"
164
+ fi
165
+ continue
166
+ fi
167
+ over=$(( over + 1 ))
168
+ base="$(baseline_for "$s")"
169
+ if [ -z "$base" ]; then
170
+ err "$s: description+when_to_use is ${t} bytes, over the ${LISTING_BUDGET}-byte listing budget"
171
+ note "this text is resident in EVERY session. Move detail into the SKILL.md body (lazy-loaded),"
172
+ note "or accept it deliberately with: scripts/skill-frontmatter-lint.sh --update"
173
+ elif [ "$t" -gt "$base" ]; then
174
+ err "$s: grew to ${t} bytes (baseline ${base}) — always-resident context may not grow"
175
+ note "trim it back to ${base} or below, or re-baseline deliberately with --update"
176
+ fi
177
+ done < <(printf '%s' "$rows" | sort -rn)
178
+
179
+ if [ "$FAIL" -eq 0 ]; then
180
+ ok "skill frontmatter within budget ($count skills, ~$(( total_all / 4 )) tokens resident; $over grandfathered)"
181
+ fi
182
+ exit "$FAIL"
@@ -2,6 +2,7 @@
2
2
  # Read-only board status, grouped by role. Pure gh + jq. bash 3.2 compatible.
3
3
  # Reads repo from .claude/kit.config.json. Run from project root.
4
4
  # ./scripts/task-sync.sh [--role <Name>] [--milestone <label>]
5
+ # --raw-json: original issue objects for shell consumers; --llm stays TOON-first.
5
6
  set -euo pipefail
6
7
  source "$(dirname "$0")/lib/kit-config.sh" && load_kit_config
7
8
  # Pure board-view render helpers (merge queue, stale flag, not-on-board flag, Project Status).
@@ -17,6 +18,7 @@ while [[ $# -gt 0 ]]; do
17
18
  --role) ROLE_FILTER="$2"; shift 2 ;;
18
19
  --milestone) MS_FILTER="$2"; shift 2 ;;
19
20
  --llm|--output=json) CCKIT_OUTPUT=json; shift ;;
21
+ --raw-json) CCKIT_OUTPUT=raw-json; shift ;;
20
22
  *) echo "unknown flag: $1" >&2; exit 1 ;;
21
23
  esac
22
24
  done
@@ -24,6 +26,12 @@ done
24
26
  ISSUES=$(gh issue list --repo "$KIT_REPO" --state open --limit 200 \
25
27
  --json number,title,labels,milestone,assignees,updatedAt,body)
26
28
 
29
+ # Keep shell consumers out of the agent-oriented TOON encoding and flattened label shape.
30
+ if [ "${CCKIT_OUTPUT:-human}" = "raw-json" ]; then
31
+ printf '%s\n' "$ISSUES"
32
+ exit 0
33
+ fi
34
+
27
35
  # Structured output for agents: emit the open board and stop (--llm / CCKIT_OUTPUT). The board is a
28
36
  # uniform list, so it goes out as TOON — far cheaper in tokens than JSON — via the shared encoder,
29
37
  # which falls back to JSON for a non-uniform/empty result. labels + assignees are flattened to
package/scripts/test.sh CHANGED
@@ -27,9 +27,18 @@ if [ "${#tests[@]}" -eq 0 ]; then
27
27
  fi
28
28
 
29
29
  note "==> cckit tests — ${#tests[@]} file(s)${PATTERN:+ (filter: $PATTERN)}"
30
+ # Seal every test from the caller's kit environment (#369): a shell that ran load_kit_config, or set
31
+ # KIT_CONFIG, exports KIT_*/CCKIT_*/EFFORT_* that would point a test at the developer's project
32
+ # instead of its own fixture. Each test still sets whatever it needs itself.
33
+ # shellcheck source=/dev/null
34
+ . scripts/lib/test-env.sh
35
+ seal=()
36
+ while IFS= read -r a; do [ -n "$a" ] && seal+=("$a"); done < <(test_env_unset_args)
37
+ [ "${#seal[@]}" -eq 0 ] || note "==> sealed $(( ${#seal[@]} / 2 )) inherited KIT_*/CCKIT_*/EFFORT_* variable(s)"
38
+
30
39
  pass=0; failn=0; failed=""
31
40
  for t in "${tests[@]}"; do
32
- out="$(bash "$t" 2>&1)"; rc=$?
41
+ out="$(env ${seal[@]+"${seal[@]}"} bash "$t" 2>&1)"; rc=$?
33
42
  if [ "$rc" -eq 0 ]; then
34
43
  pass=$((pass+1)); note " ok $t"
35
44
  else
@@ -6,6 +6,17 @@ when_to_use: When delegating work to run unattended — a single capped objectiv
6
6
 
7
7
  # kit-autopilot — capped, hands-off execution
8
8
 
9
+ ## Current implementation limit
10
+
11
+ The current `cckit autopilot` CLI launches issue flows through `orchestrate.sh`. It accepts
12
+ issue numbers, `--cap`, `--agent`, `--dry-run`, `--no-seed`, `--force`, and `--session`.
13
+ The objective, `--plan`, `--max-tokens`, `--max-iters`, `--until`, and `--notify` examples below
14
+ are workflow requirements, not implemented CLI flags. Do not invoke them as working commands.
15
+ Before accepting an unattended objective, verify that the selected runtime actually enforces each
16
+ requested limit. If it cannot, report the unsupported limit and do not start that bounded run.
17
+ A prompt asking an agent to stay under a token budget does not enforce that budget.
18
+ Implementation and cross-runtime verification are tracked in cckit effort #257, sub-issue #264.
19
+
9
20
  One skill, two modes — both delegate work that runs **autonomously to a verifiable stop, under hard
10
21
  caps**. It is a **thin wrapper**: it composes the built-in `/loop` and the kit's `orchestrate`
11
22
  scripts; it never reimplements looping or orchestration.
@@ -34,7 +45,8 @@ build a wave → merge its PRs → close subs+parent → gc → launch the next
34
45
  (`risk-tiered-review.md`) govern **ad-hoc** PRs, **not** execution of an approved plan.
35
46
  - **The permission is shipped, not improvised.** `cckit init` scaffolds a **versioned**
36
47
  `.claude/settings.json` (from `templates/settings/settings.json.tmpl`) whose explicit
37
- `Bash(gh pr merge:*)` allow pre-authorizes the wave-merge — checked in, so it travels to every
48
+ `Bash(cckit merge:*)` / `Bash(cckit watch:*)` allow pre-authorizes the wave-merge (a raw
49
+ `gh pr merge` is blocked by the guard hook, #364) — checked in, so it travels to every
38
50
  worktree and collaborator (the gitignored `settings.local.json` does not). A captain merge that
39
51
  still prompts means the project predates the template: re-run `cckit init --upgrade`.
40
52
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: kit-cleanup
3
- description: Run the ONE guided destructive sweep over the repo — present the gc plan (SAFE / ZOMBIE / ORPHAN / PROTECTED / stashes), then delete only the SAFE rows and prune the listed ZOMBIE metadata after the user confirms. Orphan branches, open-issue branches, and stashes are surfaced and left alone.
3
+ description: Run the ONE guided destructive sweep over the repo — present the gc plan (SAFE / LANDED / ZOMBIE / ORPHAN / PROTECTED / stashes), then delete the SAFE + LANDED rows and prune the listed ZOMBIE metadata once the user confirms. Orphan, open-issue branches and stashes are surfaced, kept.
4
4
  when_to_use: When `cckit gc` (or the SessionStart hygiene hook) reports merged branches and worktrees piling up and you want them gone in one pass. Use this instead of hand-rolling `git branch -D` + `git push origin --delete` loops. For the read-only report alone, use `/kit-gc`.
5
5
  ---
6
6
 
@@ -32,7 +32,8 @@ KIT_GC_REPO="$KIT_REPO" source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/kit-gc.sh"
32
32
  kit_gc_cleanup # plan only — deletes no branch, worktree, remote ref or stash
33
33
  ```
34
34
 
35
- Or through the CLI: `cckit cleanup` (add `--llm` for JSON counts).
35
+ Or through the CLI: `cckit cleanup` (add `--llm` for JSON counts: `safe`, `landed`, `worktrees`,
36
+ `zombie`, `orphan`, `protected`, `stash`, `remote_failed`, `applied`).
36
37
 
37
38
  ### 2. Present it and ask
38
39
 
@@ -42,8 +43,9 @@ veto per-bucket — if they want the orphans looked at first, do that before del
42
43
  | Bucket | Rule | `--yes` does |
43
44
  | --- | --- | --- |
44
45
  | **SAFE** | PR `MERGED`, issue closed/absent, unprotected | **deletes** the worktree, the local branch, and the remote ref *if* the branch was level with it |
46
+ | **LANDED** | **no PR of its own**, work already on base — by content (every file it changed since its merge base matches `origin/<base>`) or by lineage (`sub/<N>…`, `effort/<N>…`, or a `[#N]` commit subject names an issue closed with a merged PR). Effort subs after `effort close`, `effort/<N>` branches whose remote is gone, Claude Code Agent-tool `worktree-agent-<hash>` isolation worktrees | **deletes** exactly like SAFE — worktree, local branch, level remote ref — under the same guards: a dirty worktree or a branch ahead of its remote is skipped with a warning. The plan prints the block with each row's reason, before ORPHAN |
45
47
  | **PROTECTED** | associated issue **still OPEN** | **keeps** — close the issue first |
46
- | **ORPHAN** | local commits not on the base branch's remote, no merged PR | **keeps** — offer to recover into a PR (step 4) |
48
+ | **ORPHAN** | fails both LANDED checks: commits whose content is not on the base branch's remote, no merged PR | **keeps** — offer to recover into a PR (step 4) |
47
49
  | **ZOMBIE** | worktree dir gone, admin metadata lingers | **recovers** any staged delta to a commit on its branch, **then prunes** the metadata |
48
50
  | **stashes** | any stash entry | **keeps** — irreversible; drop only after showing each diff |
49
51
 
@@ -113,11 +113,12 @@ Check permission: `gh repo view OWNER/REPO --json viewerPermission -q .viewerPer
113
113
 
114
114
  **This is public + outward-facing — confirm with the user before opening it.**
115
115
 
116
- - Artifact PR: `gh pr create --repo OWNER/REPO --base main` — from a fork the head is
117
- `<your-login>:<branch>`. Title summarizes the contribution; body states **what it adds, why, and how
118
- it was tested/linted**.
119
- - Pure request, no artifact: `gh issue create --repo OWNER/REPO` with the **Problem · Proposal · Scope
120
- · Why** body instead.
116
+ - Artifact PR: `cckit contribute "<summary>"` — runs `scripts/check.sh`, pushes, opens the PR.
117
+ From a fork to another owner's repo, `KIT_ALLOW_RAW=1 gh pr create --repo OWNER/REPO --base main`
118
+ (the head is `<your-login>:<branch>`); the guard hook records the bypass. Title summarizes the
119
+ contribution; body states **what it adds, why, and how it was tested/linted**.
120
+ - Pure request, no artifact, to another repo: `KIT_ALLOW_RAW=1 gh issue create --repo OWNER/REPO`
121
+ with the **Problem · Proposal · Scope · Why** body instead.
121
122
  - Print the resulting URL.
122
123
 
123
124
  ## 7. Report
@@ -24,8 +24,13 @@ The effort lifecycle's terminal op. Board state, issue state, and the work recor
24
24
  4. **Judge + sync** the metrics (reads the durable trace dir; no-ops when the engine is off).
25
25
  5. **Close the parent + ALL native sub-issues** and set the **board Status=Done** for each
26
26
  (guarded — a no-op when Projects v2 is off).
27
- 6. **GC**: base branch checked out + pulled in the main checkout, effort worktree removed,
28
- local branch deleted, pruned (the remote branch is deleted by the merge).
27
+ 6. **GC**: base branch checked out + pulled in the main checkout; then the effort's **`sub/<N>…`
28
+ worktrees and branches** are collected through `kit_gc_prune --only '^sub/<N>[a-z]-'` — the
29
+ squash just put their work on base, so they classify **LANDED** (no PR of their own, content or
30
+ lineage on base) and go under the same recover-before-prune guards as `cckit cleanup` (a dirty
31
+ sub worktree, or a sub ahead of its remote, stays and is reported). Then the effort worktree is
32
+ removed, its local branch deleted, pruned (the remote branch is deleted by the merge). A sub
33
+ that fails both LANDED checks is left for `cckit gc` to show as ORPHAN.
29
34
  7. **Knowledge-ingest hook** (optional, config-gated via `effort.knowledgeIngestHook`).
30
35
  8. **Kit-sync drift check** — advisory warning when the effort touched kit-managed files that
31
36
  belong upstream (/kit-contribute).
@@ -84,7 +89,7 @@ effort_close "$NUM"
84
89
  - Pre-squash trace dir (`<git-common-dir>/traces/effort-<N>/` + `index.jsonl`) + captured metrics
85
90
  - PR squash-merged; parent + all native sub-issues closed
86
91
  - Board Status=Done for parent + every sub (if Projects v2 is on)
87
- - Main checkout on the base branch, up to date; effort worktree + local/remote branch removed and pruned
92
+ - Main checkout on the base branch, up to date; effort worktree + local/remote branch removed and pruned, and every LANDED `sub/<N>…` worktree + branch with them (`✓ sub gc:` lines)
88
93
  - Knowledge-ingest hook ran (if configured); a kit-sync warning if the effort touched kit-managed files
89
94
 
90
95
  ## Rules
@@ -6,9 +6,10 @@ when_to_use: When an effort branch is ready for review (all its sub-issues built
6
6
 
7
7
  # kit-effort-pr
8
8
 
9
- Plugin-direct skill — runs straight from `${CLAUDE_PLUGIN_ROOT}` (no per-project `scripts/` checkout
10
- needed). Helpers (config, role identity, board) are sourced from the plugin (kit-engine-boundary
11
- #1/#2). Respects `KIT_BASE_BRANCH` (default `main`) and the `KIT_PROJECTS_V2` board toggle.
9
+ Thin caller of the verb **`cckit effort pr`** (`effort_pr` in `scripts/lib/effort-ops.sh`), the ONE
10
+ implementation (kit-engine-boundary #1/#2, #363). This skill used to carry its own inline copy of the
11
+ logic; agents copied that script by hand and the copy drifted (a PR missing from the board, a mangled
12
+ body). Never re-implement it here, and never paste it into a shell.
12
13
 
13
14
  Opens the **single** PR for an effort. The PR carries the human-facing review write-up + a
14
15
  `## For agents` section (retrieval context / the work record). The parent issue holds the plan;
@@ -26,101 +27,21 @@ this PR is where humans review the result. The title carries `[#N]` (the effort
26
27
 
27
28
  ## Execution
28
29
 
29
- ```bash
30
- source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/kit-config.sh" && load_kit_config
31
- [[ "$KIT_PROJECTS_V2" == "true" ]] && { source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/gh-project.sh"; load_project_ids; }
32
- source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/role-identity.sh" 2>/dev/null || true
33
- source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/effort.sh" # effort_pr_title + effort_pr_title_check (the shared composer)
34
- BASE="${KIT_BASE_BRANCH:-main}"
35
-
36
- # 1. Parse the parent effort number from the branch (effort/<N>-<slug>).
37
- BRANCH=$(git rev-parse --abbrev-ref HEAD)
38
- NUM="${INPUT_NUM:-}"
39
- [[ -z "$NUM" ]] && NUM=$(echo "$BRANCH" | sed -nE 's#^effort/([0-9]+)-.*#\1#p')
40
- [[ -z "$NUM" ]] && { echo "✗ Branch $BRANCH is not an effort branch (effort/<N>-<slug>)"; exit 1; }
41
-
42
- # 2. Pull parent issue metadata.
43
- META=$(gh issue view "$NUM" --repo "$KIT_REPO" --json title,labels,milestone)
44
- TITLE=$(echo "$META" | jq -r .title)
45
- LABELS=$(echo "$META" | jq -r '[.labels[].name] | join(",")')
46
- MILESTONE=$(echo "$META" | jq -r '.milestone.title // ""')
47
- ROLE=$(echo "$LABELS" | tr ',' '\n' | grep '^role:' | head -1 | cut -d: -f2)
48
- ROLE_DISPLAY=$(role_display "$ROLE" 2>/dev/null || echo ""); [[ -z "$ROLE_DISPLAY" ]] && ROLE_DISPLAY="Tech Lead"
49
-
50
- # 3. Commit any pending changes — role identity is a Co-authored-by TRAILER, never the git author
51
- # (some deploy providers refuse commits whose author email matches no account).
52
- COMMIT_MSG="${COMMIT_MSG:-$ROLE: $TITLE}"
53
- if [[ -n "$(git status --porcelain)" ]]; then
54
- git add -A
55
- AUTHOR=$(role_git_author "$ROLE" 2>/dev/null || echo "")
56
- if [[ -n "$AUTHOR" ]]; then
57
- git commit -m "$COMMIT_MSG" -m "Co-authored-by: ${AUTHOR%%|*} <${AUTHOR##*|}>"
58
- else
59
- git commit -m "$COMMIT_MSG"
60
- fi
61
- fi
62
-
63
- # 4. Push.
64
- git push -u origin "$BRANCH"
65
-
66
- # 5. Compose the PR body — rich human review + the agent-facing retrieval block.
67
- PR_BODY=$(cat <<EOF
68
- ## For the orchestrator
69
-
70
- Effort #$NUM — one PR for the whole effort. Review: the summary below + the diff.
71
-
72
- Closes #$NUM
73
-
74
- ## Summary
30
+ From the effort worktree (branch `effort/<N>-<slug>`):
75
31
 
76
- $SUMMARY
77
-
78
- ## For agents
79
-
80
- $FOR_AGENTS
81
-
82
- ## Verification
83
-
84
- - [ ] Each sub-issue change is present in the diff
85
- - [ ] No unrelated files in the diff
86
- - [ ] Labels + milestone match the parent issue
87
- - [ ] Local lint/typecheck pass
88
-
89
- $(role_signature "$ROLE" 2>/dev/null || true)
90
- EOF
91
- )
92
-
93
- # 6. Create the PR. Title composed by the ONE shared composer (same as `cckit effort pr`), then the
94
- # mandatory-[#N] check — refuse rather than open an id-less PR.
95
- PR_TITLE=$(effort_pr_title "$NUM" "$TITLE" "$ROLE_DISPLAY")
96
- effort_pr_title_check "$PR_TITLE" "$NUM" || { echo "✗ PR title lacks the [#$NUM] effort id — aborting"; exit 1; }
97
- URL=$(gh pr create --repo "$KIT_REPO" \
98
- --base "$BASE" \
99
- --head "$BRANCH" \
100
- --title "$PR_TITLE" \
101
- --body "$PR_BODY" \
102
- ${LABELS:+--label "$LABELS"} \
103
- ${MILESTONE:+--milestone "$MILESTONE"} \
104
- --assignee "@me")
105
- echo "✓ $URL"
32
+ ```bash
33
+ cckit effort pr <N> --summary-file <summary.md> --for-agents-file <for-agents.md>
34
+ # short form: cckit effort pr <N> --summary "<what + why>" --for-agents "<paths>"
35
+ # a repo with its own PR-title convention: add --title "<title carrying [#N]>"
36
+ ```
106
37
 
107
- # 7. Board (if Projects v2): add the PR (In Review) + inherit Role; move the parent issue to In Review.
108
- if [[ "$KIT_PROJECTS_V2" == "true" ]]; then
109
- PR_NUM=$(basename "$URL")
110
- PR_NODE=$(gh api "repos/$KIT_REPO/pulls/$PR_NUM" --jq .node_id)
111
- PR_ITEM=$(project_add_item "$PR_NODE" 2>/dev/null || echo "")
112
- if [[ -n "$PR_ITEM" ]]; then
113
- ROLE_OPT=$(role_option_id "$ROLE" 2>/dev/null || echo "")
114
- [[ -n "$ROLE_OPT" ]] && project_set_single_select "$PR_ITEM" "$ROLE_FIELD_ID" "$ROLE_OPT"
115
- project_set_single_select "$PR_ITEM" "$STATUS_FIELD_ID" "$STATUS_OPT_IN_REVIEW"
116
- fi
117
- # Parent issue → In Review (the finder paginates the whole board, not just the first page).
118
- PARENT_ITEM=$(project_find_item_by_issue "$NUM")
119
- [[ -n "$PARENT_ITEM" ]] && project_set_single_select "$PARENT_ITEM" "$STATUS_FIELD_ID" "$STATUS_OPT_IN_REVIEW"
120
- fi
38
+ What the verb does, in order: commits pending **tracked** changes (role identity as a
39
+ `Co-authored-by` trailer; untracked files are listed, never swept in) → pushes → reads the parent's
40
+ title, labels and milestone → composes the title with `effort_pr_title` and refuses one without
41
+ `[#N]` → opens the PR with the body below → adds the PR to the board at In Review (+ Role) and moves
42
+ the parent to In Review. A failed board add prints a warning; it is never silent.
121
43
 
122
- echo " Next: review, then /kit-effort-close $NUM"
123
- ```
44
+ Body: `## For the orchestrator` (+ `Closes #N`) · `## Summary` · `## For agents` · `## Verification`.
124
45
 
125
46
  ## Output
126
47