@jeiemgi/cckit 0.10.0 → 0.12.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 (193) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +136 -127
  3. package/README.md +66 -43
  4. package/bin/cckit +151 -181
  5. package/cckit.config.json +1 -4
  6. package/package.json +1 -1
  7. package/scripts/advisor-test.sh +55 -0
  8. package/scripts/autopilot-run-test.sh +20 -12
  9. package/scripts/autopilot-run.sh +9 -1
  10. package/scripts/autopilot-test.sh +29 -13
  11. package/scripts/autopilot.sh +4 -4
  12. package/scripts/benchmark/verb-timings-test.sh +4 -0
  13. package/scripts/benchmark/verb-timings.sh +16 -5
  14. package/scripts/capture-project-ids.sh +23 -1
  15. package/scripts/check.sh +25 -0
  16. package/scripts/content-skills-test.sh +1 -1
  17. package/scripts/contribute.sh +8 -3
  18. package/scripts/copilot-loop-test.sh +66 -81
  19. package/scripts/exec-targets-test.sh +20 -0
  20. package/scripts/force-push-fence-test.sh +44 -0
  21. package/scripts/force-push-fence.baseline +1 -0
  22. package/scripts/force-push-fence.sh +51 -0
  23. package/scripts/forge-fence-test.sh +69 -0
  24. package/scripts/forge-fence.baseline +2 -0
  25. package/scripts/forge-fence.sh +76 -0
  26. package/scripts/forge-report-test.sh +100 -0
  27. package/scripts/forge-report.sh +176 -0
  28. package/scripts/init-guided-test.sh +94 -82
  29. package/scripts/init.sh +12 -7
  30. package/scripts/install-test.sh +26 -0
  31. package/scripts/install.sh +7 -0
  32. package/scripts/instruction-budget-baseline.txt +1 -1
  33. package/scripts/kit-doctor-test.sh +60 -12
  34. package/scripts/kit-doctor.sh +170 -77
  35. package/scripts/lib/agent-resolve-test.sh +2 -0
  36. package/scripts/lib/agent-resolve.sh +15 -8
  37. package/scripts/lib/board-view.sh +3 -3
  38. package/scripts/lib/captain.sh +37 -8
  39. package/scripts/lib/content-kinds-gc-test.sh +22 -21
  40. package/scripts/lib/copilot-test.sh +20 -11
  41. package/scripts/lib/copilot.sh +19 -13
  42. package/scripts/lib/effort-close-subs-test.sh +96 -0
  43. package/scripts/lib/effort-dispatch-test.sh +5 -3
  44. package/scripts/lib/effort-metrics-test.sh +7 -12
  45. package/scripts/lib/effort-metrics.sh +17 -46
  46. package/scripts/lib/effort-ops-test.sh +261 -167
  47. package/scripts/lib/effort-ops.sh +449 -171
  48. package/scripts/lib/effort-parity-test.sh +57 -62
  49. package/scripts/lib/effort-plan-test.sh +56 -54
  50. package/scripts/lib/effort-plan.sh +14 -7
  51. package/scripts/lib/effort-review-test.sh +107 -0
  52. package/scripts/lib/effort-review.sh +93 -0
  53. package/scripts/lib/effort-slug-test.sh +34 -14
  54. package/scripts/lib/effort-slug.sh +13 -13
  55. package/scripts/lib/effort.sh +58 -80
  56. package/scripts/lib/forge-github.sh +260 -0
  57. package/scripts/lib/forge-none.sh +24 -0
  58. package/scripts/lib/forge-test.sh +186 -0
  59. package/scripts/lib/forge.sh +133 -0
  60. package/scripts/lib/gh-board-add-test.sh +118 -0
  61. package/scripts/lib/gh-project-test.sh +151 -31
  62. package/scripts/lib/gh-project.sh +139 -11
  63. package/scripts/lib/gh-rest-test.sh +63 -118
  64. package/scripts/lib/gh-rest.sh +275 -52
  65. package/scripts/lib/git-core-test.sh +128 -0
  66. package/scripts/lib/grill-record-test.sh +49 -0
  67. package/scripts/lib/grill-record.sh +88 -0
  68. package/scripts/lib/handoff.sh +1 -1
  69. package/scripts/lib/init-github.sh +38 -13
  70. package/scripts/lib/kinds-test.sh +13 -16
  71. package/scripts/lib/kit-brief-test.sh +51 -10
  72. package/scripts/lib/kit-brief.sh +103 -18
  73. package/scripts/lib/kit-gc-test.sh +90 -109
  74. package/scripts/lib/kit-gc.sh +19 -22
  75. package/scripts/lib/kit-hotfix.sh +18 -16
  76. package/scripts/lib/kit-interview.sh +6 -0
  77. package/scripts/lib/kit-lib-test.sh +1 -1
  78. package/scripts/lib/kit-lib.sh +7 -7
  79. package/scripts/lib/kit-msg.sh +3 -3
  80. package/scripts/lib/kit-status.sh +19 -14
  81. package/scripts/lib/kit-task-ops-test.sh +20 -1
  82. package/scripts/lib/kit-task-ops.sh +177 -94
  83. package/scripts/lib/kto-hotfix-test.sh +53 -58
  84. package/scripts/lib/kto-task-close-test.sh +28 -27
  85. package/scripts/lib/kto-task-new-test.sh +55 -48
  86. package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
  87. package/scripts/lib/kto-task-pr-test.sh +30 -34
  88. package/scripts/lib/light-task-run-test.sh +19 -15
  89. package/scripts/lib/light-task-test.sh +34 -29
  90. package/scripts/lib/light-task.sh +24 -13
  91. package/scripts/lib/loose-issues.sh +65 -0
  92. package/scripts/lib/naming-test.sh +112 -0
  93. package/scripts/lib/naming-verbs-test.sh +126 -0
  94. package/scripts/lib/naming.sh +172 -0
  95. package/scripts/lib/next-test.sh +27 -22
  96. package/scripts/lib/next.sh +13 -7
  97. package/scripts/lib/orchestration-runtime-test.sh +11 -8
  98. package/scripts/lib/plan-machine.sh +22 -16
  99. package/scripts/lib/plan-next.sh +4 -4
  100. package/scripts/lib/pr-evidence-test.sh +63 -74
  101. package/scripts/lib/pr-evidence.sh +15 -12
  102. package/scripts/lib/qa-lane-test.sh +59 -27
  103. package/scripts/lib/qa-lane.sh +14 -6
  104. package/scripts/lib/review-page-test.sh +34 -25
  105. package/scripts/lib/review-page.sh +10 -4
  106. package/scripts/lib/spec-lint-test.sh +63 -0
  107. package/scripts/lib/spec-lint.sh +95 -0
  108. package/scripts/lib/sprint-test.sh +96 -0
  109. package/scripts/lib/sprint.sh +216 -0
  110. package/scripts/lib/stage-receipt-test.sh +169 -19
  111. package/scripts/lib/stage-receipt.sh +195 -10
  112. package/scripts/lib/test-forge-shim.sh +115 -0
  113. package/scripts/lib/verbs.sh +105 -0
  114. package/scripts/lib/verbs.tsv +92 -0
  115. package/scripts/lib/version-bump-test.sh +20 -0
  116. package/scripts/lib/version-bump.sh +4 -2
  117. package/scripts/lib/worker-brief-test.sh +1 -1
  118. package/scripts/lib/worker-brief.sh +1 -1
  119. package/scripts/lib/worktree-issue-test.sh +24 -19
  120. package/scripts/lib/worktree-issue.sh +10 -10
  121. package/scripts/lib/worktree-start-test.sh +13 -16
  122. package/scripts/lib/worktree-start.sh +57 -7
  123. package/scripts/loose-issues-test.sh +102 -0
  124. package/scripts/loose-issues.baseline +5 -0
  125. package/scripts/marketing-walkthrough-test.sh +25 -30
  126. package/scripts/night-grant.sh +14 -8
  127. package/scripts/night-run.mjs +1 -1
  128. package/scripts/orchestrate-test.sh +27 -31
  129. package/scripts/orchestrate.sh +9 -3
  130. package/scripts/portable-test.sh +37 -36
  131. package/scripts/publish.sh +9 -3
  132. package/scripts/setup-labels.sh +23 -12
  133. package/scripts/setup-milestones.sh +8 -2
  134. package/scripts/status-test.sh +39 -33
  135. package/scripts/status.sh +12 -6
  136. package/scripts/task-sync-test.sh +75 -32
  137. package/scripts/task-sync.sh +97 -6
  138. package/scripts/terms-check-test.sh +191 -0
  139. package/scripts/terms-check.sh +242 -0
  140. package/scripts/verbs-gen.sh +43 -0
  141. package/scripts/verbs-help-test.sh +61 -0
  142. package/scripts/verbs-ratchet-test.sh +69 -0
  143. package/scripts/verbs-ratchet.sh +34 -0
  144. package/scripts/verbs-test.sh +120 -0
  145. package/scripts/verbs.baseline +5 -0
  146. package/skills/kit-add/SKILL.md +2 -1
  147. package/skills/kit-advisor/SKILL.md +75 -0
  148. package/skills/kit-advisor/references/close.md +53 -0
  149. package/skills/kit-advisor/references/grill.md +69 -0
  150. package/skills/kit-advisor/references/orchestrate.md +56 -0
  151. package/skills/kit-advisor/references/plan.md +64 -0
  152. package/skills/kit-advisor/references/review.md +47 -0
  153. package/skills/kit-advisor/references/step-report.md +61 -0
  154. package/skills/kit-annotate/SKILL.md +1 -0
  155. package/skills/kit-autopilot/SKILL.md +2 -1
  156. package/skills/kit-cleanup/SKILL.md +3 -2
  157. package/skills/kit-contribute/SKILL.md +1 -0
  158. package/skills/kit-customize/SKILL.md +1 -0
  159. package/skills/kit-dev/SKILL.md +1 -0
  160. package/skills/kit-digest/SKILL.md +1 -0
  161. package/skills/kit-docs-writer/SKILL.md +4 -3
  162. package/skills/kit-effort-close/SKILL.md +18 -9
  163. package/skills/kit-effort-new/SKILL.md +12 -8
  164. package/skills/kit-effort-pr/SKILL.md +8 -7
  165. package/skills/kit-effort-start/SKILL.md +1 -0
  166. package/skills/kit-gc/SKILL.md +1 -0
  167. package/skills/kit-next/SKILL.md +8 -7
  168. package/skills/kit-onboard/SKILL.md +1 -0
  169. package/skills/kit-page/SKILL.md +1 -0
  170. package/skills/kit-plan-next/SKILL.md +11 -11
  171. package/skills/kit-security-sweep/SKILL.md +1 -0
  172. package/skills/kit-ship/SKILL.md +1 -0
  173. package/skills/kit-status/SKILL.md +6 -5
  174. package/skills/kit-task-close/SKILL.md +1 -0
  175. package/skills/kit-task-new/SKILL.md +1 -0
  176. package/skills/kit-task-pr/SKILL.md +1 -0
  177. package/skills/kit-task-pr-auto/SKILL.md +2 -1
  178. package/skills/kit-task-pr-merge/SKILL.md +4 -3
  179. package/skills/kit-task-start/SKILL.md +1 -0
  180. package/skills/kit-task-sync/SKILL.md +3 -0
  181. package/skills/kit-ux-audit/SKILL.md +1 -0
  182. package/skills/routing.yaml +124 -0
  183. package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
  184. package/templates/instructions.md.tmpl +3 -3
  185. package/templates/rules/authoring.md +7 -3
  186. package/templates/rules/delegation-brief.md +4 -0
  187. package/templates/rules/effort-model.md +34 -31
  188. package/templates/rules/gate-and-review.md +1 -1
  189. package/templates/rules/merge-safety.md +9 -7
  190. package/templates/rules/naming-and-ids.md +20 -24
  191. package/templates/rules/plan-next.md +5 -5
  192. package/templates/skills/campaign/SKILL.md +2 -2
  193. package/scripts/lib/engine-adapter.sh +0 -93
@@ -18,19 +18,26 @@ cat > "$FIXTURE_BOARD" <<'JSON'
18
18
  {"number":4,"title":"ordinary task","labels":[],"assignees":[]}
19
19
  ]
20
20
  JSON
21
- cat > "$TMP/bin/gh" <<'STUB'
22
- #!/usr/bin/env bash
23
- case "$1 $2" in
24
- 'issue list') [ "${FAIL_BOARD:-0}" = 0 ] || exit 1; cat "$FIXTURE_BOARD" ;;
25
- 'api '*)
26
- [ "${FAIL_DEPS:-0}" = 0 ] || exit 1
27
- [ "${BLOCKER_STATE:-}" = '' ] || echo 99
28
- exit 0 ;;
29
- 'issue view') echo "${BLOCKER_STATE:-OPEN}" ;;
30
- *) echo "unexpected gh call: $*" >&2; exit 1 ;;
21
+ # The forge (E537): the board and the blockers are read over REST. The shim's `curl` answers from
22
+ # this fixture — the board from $FIXTURE_BOARD, a blocker #99 on every issue when BLOCKER_STATE is
23
+ # set, a 500 when FAIL_BOARD / FAIL_DEPS is — and its `gh` fails on any subcommand.
24
+ # shellcheck source=/dev/null
25
+ . "$ROOT/scripts/lib/test-forge-shim.sh"
26
+ forge_shim_install "$TMP/bin"
27
+ export GH_LOG="$TMP/forge.log" GH_TOKEN=test-token CCKIT_FORGE=github GH_FIXTURE="$TMP/fixture.sh"
28
+ cat > "$GH_FIXTURE" <<'FIX'
29
+ fail500() { out='{"message":"fixture failure"}'; code=500; }
30
+ case "$method $ep" in
31
+ "GET repos/fixture/project/issues")
32
+ if [ "${FAIL_BOARD:-0}" != 0 ]; then fail500; else out="$(cat "$FIXTURE_BOARD")"; fi ;;
33
+ "GET repos/fixture/project/issues/"*"/dependencies/blocked_by")
34
+ if [ "${FAIL_DEPS:-0}" != 0 ]; then fail500
35
+ elif [ -n "${BLOCKER_STATE:-}" ]; then out='[{"number":99}]'
36
+ else out='[]'; fi ;;
37
+ "GET repos/fixture/project/issues/99")
38
+ out="{\"number\":99,\"title\":\"blocker\",\"state\":\"$(printf '%s' "${BLOCKER_STATE:-OPEN}" | tr '[:upper:]' '[:lower:]')\",\"labels\":[],\"body\":\"\"}" ;;
31
39
  esac
32
- STUB
33
- chmod +x "$TMP/bin/gh"
40
+ FIX
34
41
  export PATH="$TMP/bin:$PATH"
35
42
  cd "$TMP/project"
36
43
  run() { bash "$TMP/install/scripts/autopilot.sh" --dry-run "$@"; }
@@ -62,9 +69,18 @@ export FAIL_BOARD=1
62
69
  fails run
63
70
  has "$(cat "$TMP/failure")" 'could not read the board'
64
71
  unset FAIL_BOARD
72
+ has "$(cat "$GH_LOG")" 'GET repos/fixture/project/issues?state=open&per_page=100'
73
+ has "$(cat "$GH_LOG")" 'GET repos/fixture/project/issues/3/dependencies/blocked_by'
74
+ [ "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" = 0 ] || { echo 'FAIL: a gh subcommand was run'; exit 1; }
75
+ # A body that is not JSON is diagnosed, never driven as an empty board. The diagnosis may come from
76
+ # autopilot ("invalid board data") or from the board read failing ("could not read the board").
65
77
  printf '%s\n' 'invalid JSON' > "$FIXTURE_BOARD"
78
+ echo 'case: a board that is not JSON'
66
79
  fails run
67
- has "$(cat "$TMP/failure")" 'invalid board data'
80
+ case "$(cat "$TMP/failure")" in
81
+ *'invalid board data'*|*'could not read the board'*) : ;;
82
+ *) echo 'FAIL: an unreadable board was not diagnosed'; cat "$TMP/failure"; exit 1 ;;
83
+ esac
68
84
  printf '%s\n' '[]' > "$FIXTURE_BOARD"
69
85
  has "$(run 2>&1)" 'nothing open to drive'
70
86
  fails run --cap 0 3
@@ -41,9 +41,9 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
41
41
  ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
42
42
 
43
43
  # No explicit issues -> auto-select from the board: open issues, minus effort PARENTS (the
44
- # "[Effort] N ..." umbrella issues that decompose into subs, identified by label:effort OR the
45
- # title convention) and minus anything blocked_by an open issue. orchestrate re-checks the
46
- # blocked_by gate at launch; this is the coarse pre-filter so the board drives the wave.
44
+ # "[E<n>] ..." umbrella issues, legacy "[Effort] N ...", that decompose into subs, identified by
45
+ # label:effort OR the title convention) and minus anything blocked_by an open issue. orchestrate
46
+ # re-checks the blocked_by gate at launch; this is the coarse pre-filter so the board drives the wave.
47
47
  if [ "${#ISSUES[@]}" -eq 0 ]; then
48
48
  echo "autopilot: no issues passed - auto-selecting unblocked open issues from the board"
49
49
  board="$(bash "$ROOT/scripts/task-sync.sh" --raw-json)" || {
@@ -53,7 +53,7 @@ if [ "${#ISSUES[@]}" -eq 0 ]; then
53
53
  selected="$(printf '%s' "$board" | jq -r '
54
54
  if type != "array" then error("expected an issue array") else . end
55
55
  | .[]
56
- | select((any(.labels[]; .name == "effort")) or (.title | test("^\\[Effort\\] ")) | not)
56
+ | select((any(.labels[]; .name == "effort")) or (.title | test("^\\[Effort\\] |^\\[E[0-9]+\\] ")) | not)
57
57
  | .number')" || { echo "autopilot: invalid board data" >&2; exit 1; }
58
58
  while IFS= read -r n; do
59
59
  [ -n "$n" ] && ISSUES+=("$n")
@@ -27,6 +27,7 @@ echo "stub-out:$1"
27
27
  exit 0
28
28
  STUB
29
29
  chmod +x "$FIX/bin/gh"
30
+ printf '#!/usr/bin/env bash\necho "curl $*"\n' > "$FIX/bin/curl"; chmod +x "$FIX/bin/curl"
30
31
 
31
32
  # The fake CLI. Every call appends "<cwd>|<args>" to FAKE_LOG.
32
33
  cat > "$FIX/fake-cckit" <<'FAKE'
@@ -34,6 +35,7 @@ cat > "$FIX/fake-cckit" <<'FAKE'
34
35
  printf '%s|%s\n' "$PWD" "$*" >> "$FAKE_LOG"
35
36
  case "$*" in
36
37
  alpha) gh api "repos/o/r/issues" -f "q=a b" > "$FAKE_OUT"; gh issue list >> "$FAKE_OUT"; echo "noise on stdout" ;;
38
+ rest) curl -sS https://api.github.com/repos/o/r/issues >/dev/null; curl -sS https://example.invalid/x >/dev/null ;;
37
39
  "two words") gh pr list >/dev/null ;;
38
40
  beta) exit 3 ;;
39
41
  ghfail) gh fail > "$FAKE_OUT"; echo "rc=$?" >> "$FAKE_OUT" ;;
@@ -57,6 +59,8 @@ t "one JSON object of kind verb-timings" "$(jq -r '"\(.kind) \(.runs) \(.verbs |
57
59
  t "alpha: 2 gh calls per run" "$(jq -c '.verbs[0] | [.verb, .runs, .gh_calls, .exit]' <<<"$out")" '["alpha",3,2,0]'
58
60
  t "a two-word verb is one row and is split into arguments" "$(jq -c '.verbs[1] | [.verb, .gh_calls]' <<<"$out")" '["two words",1]'
59
61
  t "beta: no gh call, exit code kept" "$(jq -c '.verbs[2] | [.verb, .gh_calls, .exit]' <<<"$out")" '["beta",0,3]'
62
+ out_rest="$(vt --json --verb rest 2>/dev/null)"
63
+ t "rest: a curl to the GitHub API counts as a request, another host does not" "$(jq -c '.verbs[0] | [.verb, .gh_calls]' <<<"$out_rest")" '["rest",1]'
60
64
  t "every row has integer timings, min <= median" "$(jq -c '[.verbs[] | (.min_ms | type) == "number" and .min_ms == (.min_ms | floor) and .min_ms <= .median_ms] | all' <<<"$out")" "true"
61
65
  t "each verb ran --runs times" "$(grep -c '|alpha$' "$FAKE_LOG")" "3"
62
66
  t "the verbs ran in the checkout" "$(sed -n 1p "$FAKE_LOG")" "$FIX/co|alpha"
@@ -2,7 +2,8 @@
2
2
  # benchmark/verb-timings.sh — wall time and GitHub call count of cckit's read-only verbs (#452).
3
3
  #
4
4
  # Each verb runs --runs times (default 3) from one checkout. Per verb it records the fastest and the
5
- # median wall time in milliseconds, and how many times the verb ran `gh`.
5
+ # median wall time in milliseconds, and how many GitHub requests the verb made (`gh_calls`: API
6
+ # requests over curl, plus any `gh` run — the key name is kept for the checkpoint format).
6
7
  #
7
8
  # Usage:
8
9
  # verb-timings.sh [--runs <N>] [--checkout <dir>] [--cckit <path>] [--verb "<verb> [args]"]… [--json]
@@ -18,8 +19,10 @@
18
19
  # Three of them still touch the shared git directory: `status`, `gc` and `task list` refresh the
19
20
  # remote-tracking refs (`git fetch --prune`), and `sync` appends two lines to kit-events.jsonl.
20
21
  #
21
- # How `gh` is counted: a shim named `gh` in a temp dir is put first on PATH of each measured verb,
22
- # and only there. It appends one line to a log and execs the real `gh` with the same arguments, so
22
+ # How requests are counted: shims named `curl` and `gh` in a temp dir are put first on PATH of each
23
+ # measured verb, and only there. The curl shim counts a call whose arguments name the GitHub API
24
+ # host and execs the real curl; the gh shim counts every call. Each appends one line to a log and
25
+ # execs the real binary with the same arguments, so
23
26
  # the verb's behaviour and output are unchanged. The temp dir is removed when the script exits; the
24
27
  # shell that called this script keeps its PATH. `gh_calls` is the median count across the runs.
25
28
  #
@@ -98,6 +101,14 @@ printf '%s\n' "${1:-}" >> "$GH_SHIM_LOG"
98
101
  exec "$GH_SHIM_REAL" "$@"
99
102
  SHIM
100
103
  chmod +x "$tmp/shim/gh"
104
+ real_curl="$(command -v curl 2>/dev/null || true)"
105
+ cat > "$tmp/shim/curl" <<'SHIM'
106
+ #!/usr/bin/env bash
107
+ case " $* " in *api.github.com*|*"${CCKIT_FORGE_API:-//none//}"*) echo "curl $*" >> "${GH_SHIM_LOG:-/dev/null}" ;; esac
108
+ [ -n "${CURL_SHIM_REAL:-}" ] || { echo "curl: command not found" >&2; exit 127; }
109
+ exec "$CURL_SHIM_REAL" "$@"
110
+ SHIM
111
+ chmod +x "$tmp/shim/curl"
101
112
 
102
113
  # One run: perl takes the clock on both sides of the verb, so the only process start inside the
103
114
  # measured interval is the verb's own. Writes "<ms> <exit>" to the file named first; the verb's
@@ -115,7 +126,7 @@ while IFS= read -r verb; do
115
126
  log="$tmp/gh.log"; : > "$log"
116
127
  : > "$tmp/t"
117
128
  # shellcheck disable=SC2086 # the verb string is split into words on purpose: "effort plan"
118
- ( cd "$checkout" && env PATH="$tmp/shim:$PATH" GH_SHIM_LOG="$log" GH_SHIM_REAL="$real_gh" \
129
+ ( cd "$checkout" && env PATH="$tmp/shim:$PATH" GH_SHIM_LOG="$log" GH_SHIM_REAL="$real_gh" CURL_SHIM_REAL="$real_curl" \
119
130
  perl -MTime::HiRes=time -e "$TIMER" "$tmp/t" bash "$cckit" $verb </dev/null >/dev/null 2>&1 )
120
131
  res="$(cat "$tmp/t")"
121
132
  grep -Eq '^[0-9]+ [0-9]+$' <<<"$res" || { echo "verb-timings: could not time 'cckit $verb'" >&2; exit 2; }
@@ -126,7 +137,7 @@ while IFS= read -r verb; do
126
137
  calls="${calls}${n}
127
138
  "
128
139
  [ "$rc" -gt "$worst" ] && worst="$rc"
129
- [ "$json" -eq 1 ] || printf ' %-12s run %s/%s %s ms %s gh call(s) exit %s\n' "$verb" "$i" "$runs" "$ms" "$n" "$rc" >&2
140
+ [ "$json" -eq 1 ] || printf ' %-12s run %s/%s %s ms %s GitHub request(s) exit %s\n' "$verb" "$i" "$runs" "$ms" "$n" "$rc" >&2
130
141
  done
131
142
  jq -n -c --arg verb "$verb" --argjson runs "$runs" --argjson exit "$worst" \
132
143
  --arg times "$times" --arg calls "$calls" '
@@ -7,6 +7,12 @@
7
7
  # for each (user(login:) vs organization(login:)), so this branches on github.projectOwnerType
8
8
  # ("user" | "organization", default "user") — a user-only query silently returned null for an
9
9
  # org-owned board (#118).
10
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
11
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
12
+ # shellcheck source=/dev/null
13
+ . "$(cd "$(dirname "$0")" && pwd)/lib/gh-rest.sh"
14
+ fi
15
+
10
16
  set -euo pipefail
11
17
  source "$(dirname "$0")/lib/kit-config.sh" && load_kit_config
12
18
 
@@ -20,9 +26,25 @@ case "${KIT_PROJECT_OWNER_TYPE:-user}" in
20
26
  *) OWNER_ROOT="user" ;;
21
27
  esac
22
28
 
29
+ # REST first (E546.7): the Projects v2 REST endpoints give the same ids (node ids for PROJECT_ID and
30
+ # <FIELD>_FIELD_ID, plus <FIELD>_FIELD_NUM, the REST field id, and <FIELD>_ITER_<TITLE> for
31
+ # iteration fields). GraphQL below runs only when REST cannot serve the read.
32
+ if REST_BASE="$(gh_rest_board_base "$OWNER_ROOT" "$KIT_OWNER" "$KIT_PROJECT_NUMBER")" \
33
+ && REST_LINES="$(gh_rest_board_ids_env "$REST_BASE")" && [[ "$REST_LINES" == PROJECT_ID=?* ]]; then
34
+ {
35
+ echo "# Generated by capture-project-ids.sh (REST) — do not edit by hand."
36
+ printf '%s\n' "$REST_LINES"
37
+ } > "$OUT"
38
+ echo "✓ Wrote $OUT (REST)"
39
+ echo " Fields captured:"
40
+ grep -E '_FIELD_ID=' "$OUT" | sed 's/^/ /'
41
+ exit 0
42
+ fi
43
+ echo "cckit: capture-project-ids: REST could not read the board, falling back to GraphQL" >&2
44
+
23
45
  # Build the query with the resolved root; the response is read under the SAME root below so the
24
46
  # selector and the jq path stay in lockstep regardless of user- vs org-owned board.
25
- DATA=$(gh api graphql -f query="
47
+ DATA=$(forge_rest graphql -f query="
26
48
  query(\$login:String!, \$number:Int!){
27
49
  $OWNER_ROOT(login:\$login){
28
50
  projectV2(number:\$number){
package/scripts/check.sh CHANGED
@@ -42,6 +42,18 @@ note "==> leak fence (tracked files)"
42
42
  leak_fence_check || fail=1
43
43
 
44
44
  # 4. Secret + privacy guard - no secrets, keys, env, or private data in anything publishable.
45
+ # 3b. The forge fence (E537.5). Every GitHub call goes through scripts/lib/forge*.sh and gh-rest.sh;
46
+ # a file outside that layer calling gh or naming api.github.com fails here, against the ratchet in
47
+ # scripts/forge-fence.baseline (0 and 0).
48
+ note "==> forge fence"
49
+ bash scripts/forge-fence.sh || fail=1
50
+
51
+ # 3c. The force-push fence (#592). A pushed branch is brought onto its base by merge, never by a
52
+ # rebase, so no non-test line under bin/ or scripts/ pushes with --force, -f or --force-with-lease.
53
+ # Ratchet in scripts/force-push-fence.baseline (0).
54
+ note "==> force-push fence"
55
+ bash scripts/force-push-fence.sh || fail=1
56
+
45
57
  note "==> secret + privacy guard"
46
58
  if [ -f scripts/lib/secret-guard.sh ]; then
47
59
  . scripts/lib/secret-guard.sh
@@ -73,6 +85,12 @@ bash scripts/instruction-budget-lint.sh || fail=1
73
85
  note "==> codified review findings"
74
86
  bash scripts/review-lint.sh || fail=1
75
87
 
88
+ # 6b. Top-level verb count. scripts/lib/verbs.tsv may hold no more `verb` rows than
89
+ # scripts/verbs.baseline says, and a drop must lower the baseline in the same change. A rename keeps
90
+ # the old name as an alias row, which does not count (#557).
91
+ note "==> top-level verb ratchet"
92
+ bash scripts/verbs-ratchet.sh || fail=1
93
+
76
94
  # 7. Agent skill references. Every `skills:` entry in templates/agents/*.md must resolve to a skill
77
95
  # the kit ships or scaffolds, a `plugin:skill` reference, or a name declared third-party in
78
96
  # scripts/agent-skills-external.txt. An unresolved entry fails silently at runtime: the agent loads
@@ -80,6 +98,13 @@ bash scripts/review-lint.sh || fail=1
80
98
  note "==> agent skill references"
81
99
  bash scripts/agent-skills-lint.sh || fail=1
82
100
 
101
+ # 7b. Terms and skill routing — WARN mode. Every term under ontology/terms/ validates, every home
102
+ # resolves, every skill is routed and AGENTS.md's table mirrors skills/routing.yaml. It prints its
103
+ # defects and counts and never fails the gate: the terms are new and a word under discussion must
104
+ # not block an unrelated PR. scripts/terms-check-test.sh (step 8) is what fails on a broken checker.
105
+ note "==> terms and skill routing (warn mode)"
106
+ bash scripts/terms-check.sh || note " (warning: terms-check found defects; the gate does not fail on them)"
107
+
83
108
  # 8. Behavioral tests - run every *-test.sh through the test runner (several files at a time;
84
109
  # TEST_JOBS=1 for one at a time).
85
110
  note "==> behavioral tests"
@@ -96,7 +96,7 @@ t "campaign: no task finish line without --all" "$(grep -c 'cckit task finish' "
96
96
  has "cckit task has the default verb" "$help" "cckit task default"
97
97
  # The effort lane's flags are ones `effort new` parses.
98
98
  eo="$(cat "$ROOT/scripts/lib/effort-ops.sh")"
99
- for fl in --kind --goal --scope --verification; do
99
+ for fl in --kind --goal --spec --scope --verification; do
100
100
  has "effort new parses $fl" "$eo" " $fl)"
101
101
  done
102
102
  # ── page-design names its three skills and never claims a missing one (#504) ────────────────────
@@ -7,6 +7,12 @@
7
7
  # Usage:
8
8
  # cckit contribute "<one-line summary>" # gate -> push branch -> open PR to the upstream base
9
9
  # cckit contribute --dry-run "<summary>" # run the gate + preconditions, push/PR nothing
10
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
11
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
12
+ # shellcheck source=/dev/null
13
+ . "$(cd "$(dirname "$0")" && pwd)/lib/gh-rest.sh"
14
+ fi
15
+
10
16
  set -euo pipefail
11
17
  ROOT="$(cd "$(dirname "$0")/.." && pwd)"
12
18
  # shellcheck source=/dev/null
@@ -43,6 +49,5 @@ if [ "$dry" -eq 1 ]; then
43
49
  fi
44
50
 
45
51
  git push -u origin "$branch" 2>&1 | tail -1
46
- gh pr create --repo "$repo" --base "$base" --head "$branch" \
47
- --title "$summary" \
48
- --body "$(printf '## Contribution\n\n%s\n\nChecks gate (scripts/check.sh): green.\nDual-licensed MIT OR Apache-2.0 per CONTRIBUTING.md.\n' "$summary")"
52
+ gh_rest_pr_create "$repo" "$base" "$branch" "$summary" \
53
+ "$(printf '## Contribution\n\n%s\n\nChecks gate (scripts/check.sh): green.\nDual-licensed MIT OR Apache-2.0 per CONTRIBUTING.md.\n' "$summary")" "" ""
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # copilot-loop-test.sh — headless end-to-end of the copilot loop on a FIXTURE board (#80).
3
- # Hermetic: a stateful `gh` stub serves fixture issues/PRs/deps and reuses the scripts' OWN --jq
4
- # expressions, so it mimics real gh without the network. Asserts the full cycle:
3
+ # Hermetic: the forge shim (scripts/lib/test-forge-shim.sh) with a stateful fixture serves issues,
4
+ # PRs, deps and check runs as the REST API would, so the scripts' OWN --jq programs run unmodified
5
+ # and no gh subcommand may run; a throwaway repo with a bare origin takes the branch deletion.
6
+ # Asserts the full cycle:
5
7
  # wave — plan layers blocked issues into later waves
6
8
  # merge — the captain merges only the CLEAN PR, never the failing one
7
9
  # advance — merging a blocker unblocks its dependent into the next wave
@@ -35,91 +37,68 @@ JSON
35
37
  cat > "$FX/deps.json" <<'JSON'
36
38
  {"101":[],"102":[101],"103":[]}
37
39
  JSON
38
- # PRs: 201 head fix/101-a CLEAN+SUCCESS · 202 head fix/103-b UNSTABLE+FAILURE
40
+ # PRs (REST shape): 201 head fix/101-a clean, its head commit's check run SUCCESS · 202 head fix/103-b
41
+ # unstable, check run FAILURE
39
42
  cat > "$FX/prs.json" <<'JSON'
40
43
  [
41
- {"number":201,"title":"root A","headRefName":"fix/101-a","mergeable":"MERGEABLE","mergeStateStatus":"CLEAN","statusCheckRollup":[{"conclusion":"SUCCESS"}]},
42
- {"number":202,"title":"root B","headRefName":"fix/103-b","mergeable":"MERGEABLE","mergeStateStatus":"UNSTABLE","statusCheckRollup":[{"conclusion":"FAILURE"}]}
44
+ {"number":201,"title":"root A","head":{"ref":"fix/101-a","sha":"aaa201"},"base":{"ref":"main"},"mergeable":true,"mergeable_state":"clean","draft":false,"labels":[],"state":"open"},
45
+ {"number":202,"title":"root B","head":{"ref":"fix/103-b","sha":"bbb202"},"base":{"ref":"main"},"mergeable":true,"mergeable_state":"unstable","draft":false,"labels":[],"state":"open"}
43
46
  ]
44
47
  JSON
45
48
 
46
- # --- gh stub -----------------------------------------------------------------
47
- BIN="$TMP/bin"; mkdir -p "$BIN"
48
- cat > "$BIN/gh" <<STUB
49
- #!/usr/bin/env bash
50
- # stateful gh fixture: reuses the caller's own --jq; reflects closed/merged state.
51
- set -u
52
- FX="$FX"; CLOSED="$CLOSED"; MERGEDPR="$MERGEDPR"
53
- is_closed() { grep -qx "\$1" "\$CLOSED" 2>/dev/null; }
54
- # open issues = fixture issues whose number is not in the closed set
55
- open_issues() {
56
- jq -c --argjson cl "\$(jq -R . "\$CLOSED" 2>/dev/null | jq -s 'map(select(length>0)|tonumber)')" \
57
- '[ .[] | select(.number as \$num | (\$cl|index(\$num))|not) ]' "\$FX/issues.json"
58
- }
59
- # open PRs = fixture PRs not yet merged
60
- open_prs() {
61
- jq -c --argjson mg "\$(jq -R . "\$MERGEDPR" 2>/dev/null | jq -s 'map(select(length>0)|tonumber)')" \
62
- '[ .[] | select(.number as \$num | (\$mg|index(\$num))|not) ]' "\$FX/prs.json"
63
- }
64
- # pull a --jq EXPR and a --repo out of the args; collect positionals
65
- JQ=""; POS=()
66
- while [ "\$#" -gt 0 ]; do
67
- case "\$1" in
68
- --jq) JQ="\$2"; shift 2 ;;
69
- --repo|--state|--limit|--json) shift 2 ;;
70
- --squash|--delete-branch) shift ;;
71
- --*) shift ;;
72
- *) POS+=("\$1"); shift ;;
73
- esac
74
- done
75
- sub="\${POS[0]:-}"; sub2="\${POS[1]:-}"; arg="\${POS[2]:-}"
76
- run_jq() { if [ -n "\$JQ" ]; then jq -r "\$JQ"; else cat; fi; }
77
- case "\$sub \$sub2" in
78
- "issue list") open_issues | run_jq ;;
79
- "issue view")
80
- # gh issue view N --json labels --jq E -> feed {labels:[...]} for issue N
81
- n="\$sub2"; [ "\$n" = "view" ] && n="\$arg"
82
- jq -c --argjson n "\$arg" '[.[]|select(.number==\$n)][0] // {labels:[]} | {labels}' "\$FX/issues.json" | run_jq ;;
83
- "pr list") open_prs | run_jq ;;
84
- "pr view")
85
- # gh pr view PR --json ... (caller applies its own jq) -> emit the PR object
86
- jq -c --argjson n "\$arg" '[.[]|select(.number==\$n)][0]' "\$FX/prs.json" ;;
87
- "pr merge")
88
- # record the merge + close the PR's issue (advance state)
89
- echo "\$arg" >> "\$MERGEDPR"
90
- br="\$(jq -r --argjson n "\$arg" '[.[]|select(.number==\$n)][0].headRefName' "\$FX/prs.json")"
91
- iss="\$(printf '%s' "\$br" | sed -nE 's#^[a-z]+/([0-9]+)-.*#\1#p')"
92
- [ -n "\$iss" ] && echo "\$iss" >> "\$CLOSED"
93
- exit 0 ;;
94
- "api "*) : ;; # fall through below
49
+ # --- the forge shim + its stateful fixture ------------------------------------
50
+ # The fixture answers from $FX and reflects the closed/merged state: the open issue list, one issue
51
+ # (its labels), blocked_by with each blocker's state, the open PR list, one PR, its files, the head
52
+ # commit's check runs, and PUT …/merge, which records the merge and closes the branch's issue.
53
+ BIN="$TMP/bin"
54
+ # shellcheck source=/dev/null
55
+ . "$ROOT/scripts/lib/test-forge-shim.sh"; forge_shim_install "$BIN"
56
+ export FX CLOSED MERGEDPR GH_LOG="$TMP/gh.log" GH_FIXTURE="$FX/fixture.sh" GH_TOKEN=test-token CCKIT_FORGE=github
57
+ cat > "$GH_FIXTURE" <<'SH'
58
+ closed_list() { jq -R . "$CLOSED" 2>/dev/null | jq -s 'map(select(length>0)|tonumber)'; }
59
+ merged_list() { jq -R . "$MERGEDPR" 2>/dev/null | jq -s 'map(select(length>0)|tonumber)'; }
60
+ case "$method $ep" in
61
+ "GET repos/fixture/board/issues")
62
+ out="$(jq -c --argjson cl "$(closed_list)" '[ .[] | select(.number as $n | ($cl|index($n))|not) ]' "$FX/issues.json")" ;;
63
+ "GET repos/fixture/board/issues/"*"/dependencies/blocked_by")
64
+ n="${ep%/dependencies/blocked_by}"; n="${n##*/}"
65
+ out="$(jq -c --arg n "$n" --argjson cl "$(closed_list)" \
66
+ '[ (.[$n] // [])[] | {number: ., state: (if ($cl|index(.)) then "closed" else "open" end)} ]' "$FX/deps.json")" ;;
67
+ "GET repos/fixture/board/issues/"*)
68
+ out="$(jq -c --argjson n "${ep##*/}" '[.[]|select(.number==$n)][0] // {labels:[]}' "$FX/issues.json")" ;;
69
+ "GET repos/fixture/board/pulls")
70
+ out="$(jq -c --argjson mg "$(merged_list)" '[ .[] | select(.number as $n | ($mg|index($n))|not) ]' "$FX/prs.json")" ;;
71
+ "GET repos/fixture/board/pulls/"*"/files") out='[]' ;;
72
+ "PUT repos/fixture/board/pulls/"*"/merge")
73
+ n="${ep%/merge}"; n="${n##*/}"; echo "$n" >> "$MERGEDPR"
74
+ br="$(jq -r --argjson n "$n" '[.[]|select(.number==$n)][0].head.ref' "$FX/prs.json")"
75
+ iss="$(printf '%s' "$br" | sed -nE 's#^[a-z]+/([0-9]+)-.*#\1#p')"
76
+ [ -n "$iss" ] && echo "$iss" >> "$CLOSED"
77
+ out='{"merged":true,"sha":"deadbeef"}' ;;
78
+ "GET repos/fixture/board/pulls/"*)
79
+ out="$(jq -c --argjson n "${ep##*/}" '[.[]|select(.number==$n)][0]' "$FX/prs.json")" ;;
80
+ "GET repos/fixture/board/commits/aaa201/check-runs") out='{"check_runs":[{"name":"ci","status":"completed","conclusion":"success"}]}' ;;
81
+ "GET repos/fixture/board/commits/bbb202/check-runs") out='{"check_runs":[{"name":"ci","status":"completed","conclusion":"failure"}]}' ;;
95
82
  esac
96
- # gh api repos/.../issues/N/dependencies/blocked_by -> [{number,state}] reflecting closed set
97
- if [ "\$sub" = "api" ]; then
98
- path="\$sub2"
99
- case "\$path" in
100
- *dependencies/blocked_by)
101
- n="\$(printf '%s' "\$path" | sed -nE 's#.*/issues/([0-9]+)/dependencies.*#\1#p')"
102
- blockers="\$(jq -c --arg n "\$n" '.[\$n] // []' "\$FX/deps.json")"
103
- cl="\$(jq -R . "\$CLOSED" 2>/dev/null | jq -c -s 'map(select(length>0)|tonumber)')"
104
- printf '%s' "\$blockers" | jq -c --argjson cl "\$cl" \
105
- '[ .[] | . as \$b | {number:\$b, state: (if (\$cl|index(\$b)) then "closed" else "open" end)} ]' | run_jq ;;
106
- *sub_issues)
107
- # effort sub_issues not used by this fixture; return empty
108
- echo "[]" | run_jq ;;
109
- *) echo "" ;;
110
- esac
111
- fi
112
- STUB
113
- chmod +x "$BIN/gh"
83
+ SH
84
+
85
+ # --- a throwaway repo with a bare origin: the captain deletes a merged PR's branch through git -------
86
+ git init -q --bare "$TMP/remote.git"
87
+ git clone -q "$TMP/remote.git" "$TMP/repo" 2>/dev/null
88
+ ( cd "$TMP/repo" && git config user.email t@t && git config user.name t \
89
+ && git checkout -q -b main && git commit -q --allow-empty -m init && git push -q origin main \
90
+ && git branch fix/101-a && git branch fix/103-b && git push -q origin fix/101-a fix/103-b )
91
+ printf '%s' '{"kitVersion":"9.9.9","project":{"name":"fx"},"github":{"repo":"fixture/board","owner":"fixture","baseBranch":"main","projectsV2":false}}' \
92
+ > "$TMP/repo/cckit.config.json"
114
93
 
115
94
  export PATH="$BIN:$PATH"
116
95
  export KIT_REPO="fixture/board" PLAN_REPO="fixture/board" CAPTAIN_REPO="fixture/board"
117
96
  export CCKIT_NO_GLOW=1 CCKIT_OUTPUT=human
118
97
  export CAPTAIN_STATE="$TMP/captain.state"
119
- cckit() { bash "$ROOT/bin/cckit" "$@"; }
98
+ cckit() { ( cd "$TMP/repo" && bash "$ROOT/bin/cckit" "$@" ); }
120
99
 
121
100
  echo "== wave: plan layers the dependent into wave 1 =="
122
- PLAN="$(CCKIT_OUTPUT=human cckit plan --cap 8 2>&1)"
101
+ PLAN="$(CCKIT_OUTPUT=human cckit effort plan --issues --cap 8 2>&1)"
123
102
  # wave 0 holds the two roots; #102 (blocked by #101) must be in wave 1.
124
103
  # anchor on the row's first column (| #N |) so an "after #N" cell never false-matches.
125
104
  w101="$(printf '%s' "$PLAN" | awk '/^## Wave/{w=$3} /^\| #101 \|/{print w}')"
@@ -130,9 +109,9 @@ ok "$w103" "0" "plan: #103 root in wave 0"
130
109
  ok "$w102" "1" "plan: #102 dependent in wave 1"
131
110
 
132
111
  echo "== wave brief: one set of wave data, dispatch wording per adapter (E257.6) =="
133
- W_CL="$(CCKIT_OUTPUT=human cckit wave --adapter claude 2>&1)"
134
- W_CX="$(CCKIT_OUTPUT=human cckit wave --adapter codex 2>&1)"
135
- W_BOTH="$(CCKIT_OUTPUT=human cckit wave --adapter both 2>&1)"
112
+ W_CL="$(CCKIT_OUTPUT=human cckit effort plan --wave --adapter claude 2>&1)"
113
+ W_CX="$(CCKIT_OUTPUT=human cckit effort plan --wave --adapter codex 2>&1)"
114
+ W_BOTH="$(CCKIT_OUTPUT=human cckit effort plan --wave --adapter both 2>&1)"
136
115
  has "$W_CL" "spawn 2 parallel Task subagent(s)" "wave(claude): dispatches Task subagents"
137
116
  no "$W_CL" "cckit orchestrate --agent codex" "wave(claude): no Codex launch line"
138
117
  has "$W_CX" "cckit orchestrate --agent codex --detach 101 103" "wave(codex): cckit launches the wave-0 worktrees"
@@ -147,12 +126,12 @@ has "$W_BOTH" "### Codex" "wave(both): carries the Codex dispatch"
147
126
  wave_data() { printf '%s\n' "$1" | sed -n '/^### #/,$p' | grep -v 'cckit watch --loop'; }
148
127
  ok "$(wave_data "$W_CX")" "$(wave_data "$W_CL")" "wave: issue prompts + captain drive match across adapters"
149
128
  has "$(wave_data "$W_CL")" "### #103" "wave: the compared wave data is not empty"
150
- L_CL="$(cckit wave --adapter claude --llm 2>/dev/null)"
151
- L_CX="$(cckit wave --adapter codex --llm 2>/dev/null)"
129
+ L_CL="$(cckit effort plan --wave --adapter claude --llm 2>/dev/null)"
130
+ L_CX="$(cckit effort plan --wave --adapter codex --llm 2>/dev/null)"
152
131
  ok "$L_CX" "$L_CL" "wave --llm: byte-identical wave data for both adapters"
153
132
  has "$L_CL" "101" "wave --llm: carries wave-0 issue #101"
154
133
  no "$L_CL" "Task subagent" "wave --llm: the prompt names no runtime"
155
- cckit wave --adapter cursor >/dev/null 2>&1; ok "$?" "2" "wave: an unknown adapter is refused"
134
+ cckit effort plan --wave --adapter cursor >/dev/null 2>&1; ok "$?" "2" "wave: an unknown adapter is refused"
156
135
 
157
136
  echo "== next: surfaces the unblocked set + the top issue's start command =="
158
137
  NEXT="$(CCKIT_OUTPUT=human cckit next 2>&1)"
@@ -167,9 +146,15 @@ has "$PASS1" "PR #201" "captain: gated PR #201"
167
146
  has "$PASS1" "MERGED" "captain: merged the CLEAN PR"
168
147
  # 202 is CHECKS_FAILING -> action fix, never merged
169
148
  no "$(printf '%s' "$PASS1" | grep 202)" "MERGED" "captain: did NOT merge failing PR #202"
149
+ # the merge is ONE squash PUT over REST; the branch goes through git and is gone from origin
150
+ has "$(cat "$GH_LOG")" 'PUT repos/fixture/board/pulls/201/merge {"merge_method":"squash"}' "captain: squash-merged PR #201 over REST"
151
+ no "$(cat "$GH_LOG")" 'pulls/202/merge' "captain: never called merge on PR #202"
152
+ ok "$(git -C "$TMP/repo" ls-remote --heads origin fix/101-a | wc -l | tr -d ' ')" "0" "captain: deleted the merged PR's remote branch"
153
+ ok "$(git -C "$TMP/repo" ls-remote --heads origin fix/103-b | wc -l | tr -d ' ')" "1" "captain: kept the unmerged PR's remote branch"
154
+ ok "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0" "the whole cycle so far ran no gh subcommand"
170
155
 
171
156
  echo "== advance: merging #101 unblocks #102 into wave 0 =="
172
- PLAN2="$(CCKIT_OUTPUT=human cckit plan --cap 8 2>&1)"
157
+ PLAN2="$(CCKIT_OUTPUT=human cckit effort plan --issues --cap 8 2>&1)"
173
158
  no "$PLAN2" "#101 " "advance: #101 closed, gone from the board"
174
159
  w102b="$(printf '%s' "$PLAN2" | awk '/^## Wave/{w=$3} /^\| #102 \|/{print w}')"
175
160
  ok "$w102b" "0" "advance: #102 now unblocked in wave 0"
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # exec-targets-test.sh — #534: every `exec "$ROOT/<path>"` target in bin/cckit is executable in the
4
+ # index. `cckit release --next` failed with Permission denied because scripts/lib/version-bump.sh was
5
+ # mode 100644 while bin/cckit:476 exec'd it; the mode is read from the index, so a local chmod that
6
+ # is not committed does not count.
7
+ # Run: bash scripts/exec-targets-test.sh
8
+ # errors: strict — a test runner: rc 1 on any failed assertion
9
+ set -u
10
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11
+ fail=0; n=0
12
+ while IFS= read -r p; do
13
+ n=$((n+1))
14
+ mode="$(git -C "$ROOT" ls-files -s -- "$p" | cut -d' ' -f1)"
15
+ if [ "$mode" = "100755" ]; then echo "ok: $p is 100755"
16
+ else echo "FAIL: $p is '${mode:-untracked}', want 100755 (git update-index --chmod=+x $p)"; fail=1; fi
17
+ done < <(grep -oE 'exec "\$ROOT/[^"]+"' "$ROOT/bin/cckit" | sed -E 's/^exec "\$ROOT\/(.*)"$/\1/' | sort -u)
18
+ [ "$n" -gt 0 ] || { echo "FAIL: no exec \"\$ROOT/…\" target found in bin/cckit"; fail=1; }
19
+ [ "$fail" -eq 0 ] && echo "ALL OK (exec-targets, $n targets)"
20
+ exit "$fail"
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # force-push-fence-test.sh — #592: the fence fails the gate on a force push in a non-test file, names
4
+ # the offender, ignores comments and test files, and --write records the count. Fixture tree under
5
+ # mktemp -d; the real tree is at its baseline of 0.
6
+ # Run: bash scripts/force-push-fence-test.sh
7
+ # errors: strict — a test runner: rc 1 on any failed assertion
8
+ set -u
9
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
10
+ fail=0
11
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
12
+ F="$ROOT/scripts/force-push-fence.sh"
13
+
14
+ bash "$F" >/dev/null; t "the real tree is at baseline" "$?" "0"
15
+ t "the real baseline is 0" "$(cat "$ROOT/scripts/force-push-fence.baseline")" "force=0"
16
+
17
+ fx="$(mktemp -d)"; trap 'rm -rf "$fx"' EXIT
18
+ mkdir -p "$fx/bin" "$fx/scripts/lib"
19
+ printf 'echo hi\n' > "$fx/bin/cckit"
20
+ printf 'sync() { git push origin "$1"; }\n' > "$fx/scripts/lib/clean.sh"
21
+ printf 'force=0\n' > "$fx/scripts/force-push-fence.baseline"
22
+ bash "$F" --root "$fx" >/dev/null; t "a clean tree passes" "$?" "0"
23
+
24
+ for bad in 'git push --force origin x' 'git push -f origin x' 'git push origin x --force' 'git push --force-with-lease origin x' 'push_it() { git push origin x --force-with-lease; }'; do
25
+ printf '%s\n' "$bad" > "$fx/scripts/lib/stray.sh"
26
+ out="$(bash "$F" --root "$fx")"; rc=$?
27
+ t "fails on: $bad" "$rc" "1"
28
+ t " names the offender" "$(printf '%s' "$out" | grep -c 'scripts/lib/stray.sh:1:')" "1"
29
+ done
30
+
31
+ printf '# never git push --force here\nx=1\n' > "$fx/scripts/lib/stray.sh"
32
+ bash "$F" --root "$fx" >/dev/null; t "a comment is not a call" "$?" "0"
33
+ printf 'git push --force origin x\n' > "$fx/scripts/lib/stray-test.sh"
34
+ bash "$F" --root "$fx" >/dev/null; t "a test file is skipped" "$?" "0"
35
+ rm "$fx/scripts/lib/stray-test.sh"
36
+
37
+ printf 'git push --force origin x\n' > "$fx/scripts/lib/stray.sh"
38
+ bash "$F" --root "$fx" --write >/dev/null
39
+ t "--write records the count" "$(cat "$fx/scripts/force-push-fence.baseline")" "force=1"
40
+ bash "$F" --root "$fx" >/dev/null; t "at the baseline passes" "$?" "0"
41
+ rm "$fx/scripts/force-push-fence.baseline"
42
+ bash "$F" --root "$fx" >/dev/null 2>&1; t "no baseline is rc 1" "$?" "1"
43
+
44
+ exit "$fail"
@@ -0,0 +1 @@
1
+ force=0
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ # force-push-fence.sh — #592: the gate fails when a non-test file under bin/ or scripts/ force-pushes.
3
+ # A pushed branch is brought onto its base by `git merge origin/<base>`, never by a rebase, so no
4
+ # push needs --force. The squash merge keeps history linear anyway.
5
+ #
6
+ # scripts/force-push-fence.sh rc 0 when the count is at or under the baseline, 1 over it
7
+ # scripts/force-push-fence.sh --root <dir> fence another checkout
8
+ # scripts/force-push-fence.sh --write write the current count into the baseline
9
+ #
10
+ # Counts non-comment lines in bin/* and scripts/**/*.sh (test files `*-test.sh` and `test-*.sh`, and
11
+ # this script, are skipped) that hold `push` with `--force`, `--force-with-lease` or `-f`, or the
12
+ # `--force-with-lease` flag on its own. Ratchet against scripts/force-push-fence.baseline (`force=<n>`).
13
+ # errors: strict — set -e; a missing baseline exits 1
14
+ set -euo pipefail
15
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
16
+ write=0
17
+ while [ $# -gt 0 ]; do
18
+ case "$1" in
19
+ --root) ROOT="$(cd "${2:?--root needs a directory}" && pwd)"; shift 2 ;;
20
+ --write) write=1; shift ;;
21
+ -h|--help) sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
22
+ *) echo "force-push-fence: unknown argument '$1'" >&2; exit 2 ;;
23
+ esac
24
+ done
25
+ baseline="$ROOT/scripts/force-push-fence.baseline"
26
+
27
+ # A forbidden push: `push` then --force / --force-with-lease / -f on one line, or a bare --force-with-lease.
28
+ re='push[^|;&]*(--force|[[:space:]]-f([[:space:]]|$))|--force-with-lease'
29
+ hits="$(cd "$ROOT" && { for f in bin/*; do [ -f "$f" ] && echo "$f"; done; for f in scripts/*.sh scripts/lib/*.sh; do [ -f "$f" ] && echo "$f"; done; } \
30
+ | grep -vE -- '-test\.sh$|(^|/)test-[a-z-]+\.sh$|^scripts/force-push-fence\.sh$' | sort -u | while IFS= read -r f; do
31
+ grep -nE "$re" "$f" | grep -vE '^[0-9]+:[[:space:]]*#' | sed "s|^|$f:|" || true
32
+ done)"
33
+ n="$(printf '%s\n' "$hits" | sed '/^$/d' | wc -l | tr -d ' ')"
34
+
35
+ if [ "$write" = 1 ]; then
36
+ printf 'force=%s\n' "$n" > "$baseline"
37
+ echo "force-push-fence: baseline written — force=$n"
38
+ exit 0
39
+ fi
40
+ [ -f "$baseline" ] || { echo "force-push-fence: no baseline at $baseline (run: scripts/force-push-fence.sh --write)" >&2; exit 1; }
41
+ max="$(sed -n 's/^force=//p' "$baseline" | sed -n 1p)"
42
+ case "$max" in *[!0-9]*|'') echo "force-push-fence: the baseline must hold force=<n>" >&2; exit 1 ;; esac
43
+
44
+ if [ "$n" -gt "$max" ]; then
45
+ echo "x force-push fence: $n force-push line(s) (baseline $max). Update the branch with git merge origin/<base> and push plain:"
46
+ printf '%s\n' "$hits" | sed '/^$/d' | sed 's/^/ /'
47
+ exit 1
48
+ fi
49
+ echo "ok force-push fence: $n/$max force-push lines in bin/ and scripts/"
50
+ if [ "$n" -lt "$max" ]; then echo " the count went down — ratchet it: scripts/force-push-fence.sh --write"; fi
51
+ exit 0