@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.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +136 -127
- package/README.md +66 -43
- package/bin/cckit +151 -181
- package/cckit.config.json +1 -4
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot-run-test.sh +20 -12
- package/scripts/autopilot-run.sh +9 -1
- package/scripts/autopilot-test.sh +29 -13
- package/scripts/autopilot.sh +4 -4
- package/scripts/benchmark/verb-timings-test.sh +4 -0
- package/scripts/benchmark/verb-timings.sh +16 -5
- package/scripts/capture-project-ids.sh +23 -1
- package/scripts/check.sh +25 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/contribute.sh +8 -3
- package/scripts/copilot-loop-test.sh +66 -81
- package/scripts/exec-targets-test.sh +20 -0
- package/scripts/force-push-fence-test.sh +44 -0
- package/scripts/force-push-fence.baseline +1 -0
- package/scripts/force-push-fence.sh +51 -0
- package/scripts/forge-fence-test.sh +69 -0
- package/scripts/forge-fence.baseline +2 -0
- package/scripts/forge-fence.sh +76 -0
- package/scripts/forge-report-test.sh +100 -0
- package/scripts/forge-report.sh +176 -0
- package/scripts/init-guided-test.sh +94 -82
- package/scripts/init.sh +12 -7
- package/scripts/install-test.sh +26 -0
- package/scripts/install.sh +7 -0
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +60 -12
- package/scripts/kit-doctor.sh +170 -77
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +15 -8
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +37 -8
- package/scripts/lib/content-kinds-gc-test.sh +22 -21
- package/scripts/lib/copilot-test.sh +20 -11
- package/scripts/lib/copilot.sh +19 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +5 -3
- package/scripts/lib/effort-metrics-test.sh +7 -12
- package/scripts/lib/effort-metrics.sh +17 -46
- package/scripts/lib/effort-ops-test.sh +261 -167
- package/scripts/lib/effort-ops.sh +449 -171
- package/scripts/lib/effort-parity-test.sh +57 -62
- package/scripts/lib/effort-plan-test.sh +56 -54
- package/scripts/lib/effort-plan.sh +14 -7
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +34 -14
- package/scripts/lib/effort-slug.sh +13 -13
- package/scripts/lib/effort.sh +58 -80
- package/scripts/lib/forge-github.sh +260 -0
- package/scripts/lib/forge-none.sh +24 -0
- package/scripts/lib/forge-test.sh +186 -0
- package/scripts/lib/forge.sh +133 -0
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +151 -31
- package/scripts/lib/gh-project.sh +139 -11
- package/scripts/lib/gh-rest-test.sh +63 -118
- package/scripts/lib/gh-rest.sh +275 -52
- package/scripts/lib/git-core-test.sh +128 -0
- package/scripts/lib/grill-record-test.sh +49 -0
- package/scripts/lib/grill-record.sh +88 -0
- package/scripts/lib/handoff.sh +1 -1
- package/scripts/lib/init-github.sh +38 -13
- package/scripts/lib/kinds-test.sh +13 -16
- package/scripts/lib/kit-brief-test.sh +51 -10
- package/scripts/lib/kit-brief.sh +103 -18
- package/scripts/lib/kit-gc-test.sh +90 -109
- package/scripts/lib/kit-gc.sh +19 -22
- package/scripts/lib/kit-hotfix.sh +18 -16
- package/scripts/lib/kit-interview.sh +6 -0
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +7 -7
- package/scripts/lib/kit-msg.sh +3 -3
- package/scripts/lib/kit-status.sh +19 -14
- package/scripts/lib/kit-task-ops-test.sh +20 -1
- package/scripts/lib/kit-task-ops.sh +177 -94
- package/scripts/lib/kto-hotfix-test.sh +53 -58
- package/scripts/lib/kto-task-close-test.sh +28 -27
- package/scripts/lib/kto-task-new-test.sh +55 -48
- package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
- package/scripts/lib/kto-task-pr-test.sh +30 -34
- package/scripts/lib/light-task-run-test.sh +19 -15
- package/scripts/lib/light-task-test.sh +34 -29
- package/scripts/lib/light-task.sh +24 -13
- package/scripts/lib/loose-issues.sh +65 -0
- package/scripts/lib/naming-test.sh +112 -0
- package/scripts/lib/naming-verbs-test.sh +126 -0
- package/scripts/lib/naming.sh +172 -0
- package/scripts/lib/next-test.sh +27 -22
- package/scripts/lib/next.sh +13 -7
- package/scripts/lib/orchestration-runtime-test.sh +11 -8
- package/scripts/lib/plan-machine.sh +22 -16
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +63 -74
- package/scripts/lib/pr-evidence.sh +15 -12
- package/scripts/lib/qa-lane-test.sh +59 -27
- package/scripts/lib/qa-lane.sh +14 -6
- package/scripts/lib/review-page-test.sh +34 -25
- package/scripts/lib/review-page.sh +10 -4
- package/scripts/lib/spec-lint-test.sh +63 -0
- package/scripts/lib/spec-lint.sh +95 -0
- package/scripts/lib/sprint-test.sh +96 -0
- package/scripts/lib/sprint.sh +216 -0
- package/scripts/lib/stage-receipt-test.sh +169 -19
- package/scripts/lib/stage-receipt.sh +195 -10
- package/scripts/lib/test-forge-shim.sh +115 -0
- package/scripts/lib/verbs.sh +105 -0
- package/scripts/lib/verbs.tsv +92 -0
- package/scripts/lib/version-bump-test.sh +20 -0
- package/scripts/lib/version-bump.sh +4 -2
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-issue-test.sh +24 -19
- package/scripts/lib/worktree-issue.sh +10 -10
- package/scripts/lib/worktree-start-test.sh +13 -16
- package/scripts/lib/worktree-start.sh +57 -7
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/marketing-walkthrough-test.sh +25 -30
- package/scripts/night-grant.sh +14 -8
- package/scripts/night-run.mjs +1 -1
- package/scripts/orchestrate-test.sh +27 -31
- package/scripts/orchestrate.sh +9 -3
- package/scripts/portable-test.sh +37 -36
- package/scripts/publish.sh +9 -3
- package/scripts/setup-labels.sh +23 -12
- package/scripts/setup-milestones.sh +8 -2
- package/scripts/status-test.sh +39 -33
- package/scripts/status.sh +12 -6
- package/scripts/task-sync-test.sh +75 -32
- package/scripts/task-sync.sh +97 -6
- package/scripts/terms-check-test.sh +191 -0
- package/scripts/terms-check.sh +242 -0
- package/scripts/verbs-gen.sh +43 -0
- package/scripts/verbs-help-test.sh +61 -0
- package/scripts/verbs-ratchet-test.sh +69 -0
- package/scripts/verbs-ratchet.sh +34 -0
- package/scripts/verbs-test.sh +120 -0
- package/scripts/verbs.baseline +5 -0
- package/skills/kit-add/SKILL.md +2 -1
- package/skills/kit-advisor/SKILL.md +75 -0
- package/skills/kit-advisor/references/close.md +53 -0
- package/skills/kit-advisor/references/grill.md +69 -0
- package/skills/kit-advisor/references/orchestrate.md +56 -0
- package/skills/kit-advisor/references/plan.md +64 -0
- package/skills/kit-advisor/references/review.md +47 -0
- package/skills/kit-advisor/references/step-report.md +61 -0
- package/skills/kit-annotate/SKILL.md +1 -0
- package/skills/kit-autopilot/SKILL.md +2 -1
- package/skills/kit-cleanup/SKILL.md +3 -2
- package/skills/kit-contribute/SKILL.md +1 -0
- package/skills/kit-customize/SKILL.md +1 -0
- package/skills/kit-dev/SKILL.md +1 -0
- package/skills/kit-digest/SKILL.md +1 -0
- package/skills/kit-docs-writer/SKILL.md +4 -3
- package/skills/kit-effort-close/SKILL.md +18 -9
- package/skills/kit-effort-new/SKILL.md +12 -8
- package/skills/kit-effort-pr/SKILL.md +8 -7
- package/skills/kit-effort-start/SKILL.md +1 -0
- package/skills/kit-gc/SKILL.md +1 -0
- package/skills/kit-next/SKILL.md +8 -7
- package/skills/kit-onboard/SKILL.md +1 -0
- package/skills/kit-page/SKILL.md +1 -0
- package/skills/kit-plan-next/SKILL.md +11 -11
- package/skills/kit-security-sweep/SKILL.md +1 -0
- package/skills/kit-ship/SKILL.md +1 -0
- package/skills/kit-status/SKILL.md +6 -5
- package/skills/kit-task-close/SKILL.md +1 -0
- package/skills/kit-task-new/SKILL.md +1 -0
- package/skills/kit-task-pr/SKILL.md +1 -0
- package/skills/kit-task-pr-auto/SKILL.md +2 -1
- package/skills/kit-task-pr-merge/SKILL.md +4 -3
- package/skills/kit-task-start/SKILL.md +1 -0
- package/skills/kit-task-sync/SKILL.md +3 -0
- package/skills/kit-ux-audit/SKILL.md +1 -0
- package/skills/routing.yaml +124 -0
- package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
- package/templates/instructions.md.tmpl +3 -3
- package/templates/rules/authoring.md +7 -3
- package/templates/rules/delegation-brief.md +4 -0
- package/templates/rules/effort-model.md +34 -31
- package/templates/rules/gate-and-review.md +1 -1
- package/templates/rules/merge-safety.md +9 -7
- package/templates/rules/naming-and-ids.md +20 -24
- package/templates/rules/plan-next.md +5 -5
- package/templates/skills/campaign/SKILL.md +2 -2
- package/scripts/lib/engine-adapter.sh +0 -93
package/scripts/kit-doctor.sh
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
# # until the next x.y kit update
|
|
13
13
|
# scripts/kit-doctor.sh --agents # only the selected agent runtimes (claude / codex):
|
|
14
14
|
# # present or absent; exit 1 if one is absent. No network.
|
|
15
|
+
# scripts/kit-doctor.sh --loose # only the loose-issue count + the list (#N title): open
|
|
16
|
+
# # issues that are no effort, no sub-issue, not in Backlog
|
|
17
|
+
# scripts/kit-doctor.sh --loose --ratchet [--baseline=FILE]
|
|
18
|
+
# # exit 1 when the count rose above the baseline
|
|
19
|
+
# # (default scripts/loose-issues.baseline); 2 = not judged
|
|
15
20
|
#
|
|
16
21
|
# Tiers:
|
|
17
22
|
# Tier 0 Homebrew (macOS bootstrap — requires sudo password)
|
|
@@ -25,6 +30,12 @@
|
|
|
25
30
|
# Local mlx_lm.server auto-start (when .local.enabled)
|
|
26
31
|
# Auth gh auth status + scope:project, git config name/email
|
|
27
32
|
# SSH optional guided flow (ed25519, pbcopy, link to github settings)
|
|
33
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
34
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
35
|
+
# shellcheck source=/dev/null
|
|
36
|
+
. "$(cd "$(dirname "$0")" && pwd)/lib/gh-rest.sh"
|
|
37
|
+
fi
|
|
38
|
+
|
|
28
39
|
set -euo pipefail
|
|
29
40
|
|
|
30
41
|
# Own directory — so we can find sibling scripts (kit-export-project.sh) regardless of cwd.
|
|
@@ -32,6 +43,7 @@ _export_dir_doctor="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" &&
|
|
|
32
43
|
|
|
33
44
|
# ---- flags ------------------------------------------------------------------
|
|
34
45
|
DRY_RUN=0; NO_INSTALL=0; DISMISS_LOCAL=0; ASSUME_YES=0; AGENTS_ONLY=0
|
|
46
|
+
LOOSE_ONLY=0; LOOSE_RATCHET=0; LOOSE_BASELINE=""
|
|
35
47
|
INSTALL_APPROVED=0 # 1 = the operator said yes to installs in THIS run (--fix/--yes, or the prompt)
|
|
36
48
|
for _a in "$@"; do
|
|
37
49
|
case "$_a" in
|
|
@@ -40,8 +52,11 @@ for _a in "$@"; do
|
|
|
40
52
|
--fix|--yes|-y) ASSUME_YES=1; INSTALL_APPROVED=1 ;;
|
|
41
53
|
--dismiss-local) DISMISS_LOCAL=1 ;;
|
|
42
54
|
--agents) AGENTS_ONLY=1 ;;
|
|
55
|
+
--loose) LOOSE_ONLY=1 ;;
|
|
56
|
+
--ratchet) LOOSE_ONLY=1; LOOSE_RATCHET=1 ;;
|
|
57
|
+
--baseline=*) LOOSE_BASELINE="${_a#--baseline=}" ;;
|
|
43
58
|
-h|--help)
|
|
44
|
-
sed -n '2,
|
|
59
|
+
sed -n '2,20p' "$0" | grep '^#' | sed 's/^# \?//'
|
|
45
60
|
exit 0 ;;
|
|
46
61
|
esac
|
|
47
62
|
done
|
|
@@ -105,7 +120,7 @@ fi
|
|
|
105
120
|
# file, no server start (#448 — it used to run `pnpm install` in whatever directory it was called
|
|
106
121
|
# from). --dry-run / --no-install already skip installs entirely. MAY_INSTALL is the one gate every
|
|
107
122
|
# install or write below reads.
|
|
108
|
-
if [[ $DRY_RUN -eq 0 && $NO_INSTALL -eq 0 && $ASSUME_YES -eq 0 && $AGENTS_ONLY -eq 0 && -t 0 ]]; then
|
|
123
|
+
if [[ $DRY_RUN -eq 0 && $NO_INSTALL -eq 0 && $ASSUME_YES -eq 0 && $AGENTS_ONLY -eq 0 && $LOOSE_ONLY -eq 0 && -t 0 ]]; then
|
|
109
124
|
printf '\n %s%scckit doctor can install anything missing for you%s (via Homebrew, corepack, etc.).\n' "$C_BOLD" "" "$C_RESET"
|
|
110
125
|
printf ' It will show each thing as it goes. Nothing is installed if you decline.\n\n'
|
|
111
126
|
printf ' Install missing dependencies? [Y/n] '
|
|
@@ -206,6 +221,85 @@ if [[ $AGENTS_ONLY -eq 1 ]]; then
|
|
|
206
221
|
exit 0
|
|
207
222
|
fi
|
|
208
223
|
|
|
224
|
+
# ---- loose issues (E546.2) ---------------------------------------------------
|
|
225
|
+
# A loose issue is open, not a pull request, not an effort, not a sub-issue, and not on the board
|
|
226
|
+
# with Status = Backlog (scripts/lib/loose-issues.sh). One row with the count; `list` adds one
|
|
227
|
+
# `#N title` line per issue. Sets LOOSE_STATE (read | skipped | failed) and LOOSE_COUNT. Read-only.
|
|
228
|
+
LOOSE_STATE=skipped; LOOSE_COUNT=""
|
|
229
|
+
doctor_loose() {
|
|
230
|
+
local _want_list="${1:-}" _cfg _repo _out _n _why
|
|
231
|
+
command -v loose_issues_list >/dev/null 2>&1 || . "$_export_dir_doctor/lib/loose-issues.sh"
|
|
232
|
+
_cfg="$(kit_config_path "${TARGET:-$PWD}" 2>/dev/null || true)"
|
|
233
|
+
if ! forge_available; then
|
|
234
|
+
row "$MARK_SKIP" "loose issues" "skipped — no forge, so the open issues cannot be read (export GH_TOKEN=<token>)"
|
|
235
|
+
return 0
|
|
236
|
+
fi
|
|
237
|
+
if ! _repo="$(loose_repo "$_cfg")"; then
|
|
238
|
+
row "$MARK_SKIP" "loose issues" "skipped — no repository (set github.repo, or add a GitHub origin remote)"
|
|
239
|
+
return 0
|
|
240
|
+
fi
|
|
241
|
+
if ! _out="$(loose_issues_list "$_repo" "$_cfg" 2>/dev/null)"; then
|
|
242
|
+
row "$MARK_FAIL" "loose issues" "could not read the open issues of $_repo"
|
|
243
|
+
CHECKS_FAIL=$((CHECKS_FAIL + 1)); LOOSE_STATE=failed
|
|
244
|
+
return 0
|
|
245
|
+
fi
|
|
246
|
+
_n="$(printf '%s' "$_out" | grep -c . || true)"
|
|
247
|
+
LOOSE_STATE=read; LOOSE_COUNT="$_n"
|
|
248
|
+
if loose_board_on "$_cfg"; then
|
|
249
|
+
_why="open issues that are no effort, no sub-issue, and not in Backlog on the board"
|
|
250
|
+
else
|
|
251
|
+
_why="the board is off (projectsV2 false), so no issue can carry the Backlog marker and every standalone issue counts"
|
|
252
|
+
fi
|
|
253
|
+
if [[ "$_n" -eq 0 ]]; then
|
|
254
|
+
row "$MARK_OK" "loose issues" "0 in $_repo — $_why"
|
|
255
|
+
CHECKS_OK=$((CHECKS_OK + 1))
|
|
256
|
+
else
|
|
257
|
+
row "$MARK_WARN" "loose issues" "$_n in $_repo — $_why. List them: cckit doctor --loose"
|
|
258
|
+
CHECKS_WARN=$((CHECKS_WARN + 1))
|
|
259
|
+
fi
|
|
260
|
+
if [[ "$_want_list" == list && -n "$_out" ]]; then
|
|
261
|
+
printf '%s\n' "$_out" | while IFS="$(printf '\t')" read -r _ln _lt; do
|
|
262
|
+
printf ' #%s %s\n' "$_ln" "$_lt"
|
|
263
|
+
done
|
|
264
|
+
fi
|
|
265
|
+
return 0
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
# ---- --loose [--ratchet]: only the loose-issue rows, then exit (no installs) -----
|
|
269
|
+
# --ratchet compares the count with the baseline file: exit 1 when it rose, 2 when it could not be
|
|
270
|
+
# judged (no forge, no repository, a failed read, no baseline). Not part of scripts/check.sh: the
|
|
271
|
+
# gate stays offline. Run it by hand or in a job that has a token: cckit doctor --loose --ratchet
|
|
272
|
+
if [[ $LOOSE_ONLY -eq 1 ]]; then
|
|
273
|
+
printf ' %s%sLoose issues%s\n' "$C_BOLD" "" "$C_RESET"
|
|
274
|
+
doctor_loose list
|
|
275
|
+
if [[ $LOOSE_RATCHET -eq 1 ]]; then
|
|
276
|
+
if [[ -z "$LOOSE_BASELINE" ]]; then
|
|
277
|
+
_lroot="$(git -C "${TARGET:-$PWD}" rev-parse --show-toplevel 2>/dev/null || printf '%s' "${TARGET:-$PWD}")"
|
|
278
|
+
LOOSE_BASELINE="$_lroot/scripts/loose-issues.baseline"
|
|
279
|
+
fi
|
|
280
|
+
if [[ "$LOOSE_STATE" != read ]]; then
|
|
281
|
+
row "$MARK_FAIL" "loose ratchet" "not judged — the count was not read"
|
|
282
|
+
exit 2
|
|
283
|
+
fi
|
|
284
|
+
_lbase="$(loose_baseline_read "$LOOSE_BASELINE" || true)"
|
|
285
|
+
if [[ -z "$_lbase" ]]; then
|
|
286
|
+
row "$MARK_FAIL" "loose ratchet" "not judged — no number in $LOOSE_BASELINE"
|
|
287
|
+
exit 2
|
|
288
|
+
fi
|
|
289
|
+
if [[ "$LOOSE_COUNT" -gt "$_lbase" ]]; then
|
|
290
|
+
row "$MARK_FAIL" "loose ratchet" "$LOOSE_COUNT loose > baseline $_lbase — put each new one under an effort, as a sub-issue, or in Backlog"
|
|
291
|
+
exit 1
|
|
292
|
+
elif [[ "$LOOSE_COUNT" -lt "$_lbase" ]]; then
|
|
293
|
+
row "$MARK_OK" "loose ratchet" "$LOOSE_COUNT loose < baseline $_lbase — lower the number in $LOOSE_BASELINE to $LOOSE_COUNT"
|
|
294
|
+
else
|
|
295
|
+
row "$MARK_OK" "loose ratchet" "$LOOSE_COUNT loose = baseline $_lbase"
|
|
296
|
+
fi
|
|
297
|
+
exit 0
|
|
298
|
+
fi
|
|
299
|
+
[[ "$LOOSE_STATE" == failed ]] && exit 1
|
|
300
|
+
exit 0
|
|
301
|
+
fi
|
|
302
|
+
|
|
209
303
|
# ============================================================================
|
|
210
304
|
# BANNER
|
|
211
305
|
# ============================================================================
|
|
@@ -270,36 +364,15 @@ else
|
|
|
270
364
|
ACTIONS_NEEDED+=("Install git: brew install git")
|
|
271
365
|
fi
|
|
272
366
|
|
|
273
|
-
# ---- gh (
|
|
367
|
+
# ---- gh (OPTIONAL: the interactive way to get a token; the forge itself is REST over curl) ----
|
|
274
368
|
GH_OK=0
|
|
275
|
-
if
|
|
276
|
-
_ghver="$(
|
|
277
|
-
|
|
278
|
-
_ghmaj="${_ghver%%.*}"
|
|
279
|
-
_ghmin="${_ghver#*.}"; _ghmin="${_ghmin%%.*}"
|
|
280
|
-
if [[ "${_ghmaj:-0}" -gt 2 ]] || \
|
|
281
|
-
[[ "${_ghmaj:-0}" -eq 2 && "${_ghmin:-0}" -ge 29 ]]; then
|
|
282
|
-
row "$MARK_OK" "gh" "$_ghver (Projects v2 ok)"
|
|
283
|
-
CHECKS_OK=$((CHECKS_OK + 1))
|
|
284
|
-
GH_OK=1
|
|
285
|
-
else
|
|
286
|
-
row "$MARK_WARN" "gh" "$_ghver — upgrade needed (>=2.29 for Projects v2)"
|
|
287
|
-
CHECKS_WARN=$((CHECKS_WARN + 1))
|
|
288
|
-
if [[ $MAY_INSTALL -eq 1 ]] && has_cmd brew; then
|
|
289
|
-
brew upgrade gh >/dev/null 2>&1 && GH_OK=1 && ACTIONS_TAKEN+=("Upgraded gh")
|
|
290
|
-
fi
|
|
291
|
-
[[ $GH_OK -eq 0 ]] && ACTIONS_NEEDED+=("Upgrade gh: brew upgrade gh")
|
|
292
|
-
fi
|
|
293
|
-
elif brew_install gh; then
|
|
294
|
-
_ghver="$(gh --version 2>/dev/null | sed -n 1p | awk '{print $3}')"
|
|
295
|
-
row "$MARK_OK" "gh" "installed $\_ghver"
|
|
369
|
+
if forge_cli_present; then
|
|
370
|
+
_ghver="$(forge_cli_version)"
|
|
371
|
+
row "$MARK_OK" "gh (optional)" "${_ghver:-present} — its token is used when GH_TOKEN is unset"
|
|
296
372
|
CHECKS_OK=$((CHECKS_OK + 1))
|
|
297
373
|
GH_OK=1
|
|
298
|
-
ACTIONS_TAKEN+=("Installed gh via brew")
|
|
299
374
|
else
|
|
300
|
-
row "$
|
|
301
|
-
CHECKS_FAIL=$((CHECKS_FAIL + 1))
|
|
302
|
-
ACTIONS_NEEDED+=("Install gh: brew install gh")
|
|
375
|
+
row "$MARK_SKIP" "gh (optional)" "not installed — a GH_TOKEN works without it; install it for an interactive sign-in"
|
|
303
376
|
fi
|
|
304
377
|
|
|
305
378
|
# ---- jq -------------------------------------------------------------------
|
|
@@ -316,6 +389,20 @@ else
|
|
|
316
389
|
ACTIONS_NEEDED+=("Install jq: brew install jq")
|
|
317
390
|
fi
|
|
318
391
|
|
|
392
|
+
# ---- curl (the forge is REST over curl) -------------------------------------
|
|
393
|
+
if has_cmd curl; then
|
|
394
|
+
row "$MARK_OK" "curl" "$(curl --version 2>/dev/null | sed -n 1p | awk '{print $2}')"
|
|
395
|
+
CHECKS_OK=$((CHECKS_OK + 1))
|
|
396
|
+
elif brew_install curl; then
|
|
397
|
+
row "$MARK_OK" "curl" "installed"
|
|
398
|
+
CHECKS_OK=$((CHECKS_OK + 1))
|
|
399
|
+
ACTIONS_TAKEN+=("Installed curl via brew")
|
|
400
|
+
else
|
|
401
|
+
row "$MARK_FAIL" "curl" "missing — brew install curl (every GitHub call is REST over curl)"
|
|
402
|
+
CHECKS_FAIL=$((CHECKS_FAIL + 1))
|
|
403
|
+
ACTIONS_NEEDED+=("Install curl: brew install curl")
|
|
404
|
+
fi
|
|
405
|
+
|
|
319
406
|
# ---- perl -----------------------------------------------------------------
|
|
320
407
|
if has_cmd perl; then
|
|
321
408
|
row "$MARK_OK" "perl" "$(perl --version 2>/dev/null | sed -n 1,2p | tail -1 | tr -d '()' | awk '{print $2}')"
|
|
@@ -738,67 +825,67 @@ fi
|
|
|
738
825
|
# ============================================================================
|
|
739
826
|
printf ' %s%sAuth + config%s\n' "$C_BOLD" "" "$C_RESET"
|
|
740
827
|
|
|
741
|
-
# ----
|
|
828
|
+
# ---- the forge (GitHub through a token) --------------------------------------
|
|
829
|
+
# forge.provider: github when a token resolves (GH_TOKEN, GITHUB_TOKEN, or gh's), else none. With
|
|
830
|
+
# none every verb that needs GitHub refuses by name and the git steps still run (scripts/lib/forge.sh).
|
|
742
831
|
GH_AUTHED=0
|
|
743
|
-
|
|
744
|
-
|
|
832
|
+
_fprov="$(forge_provider 2>/dev/null || echo none)"
|
|
833
|
+
if [[ "$_fprov" == "none" ]]; then
|
|
834
|
+
if [[ $DRY_RUN -eq 0 && $MAY_INSTALL -eq 1 ]] && forge_cli_present; then
|
|
835
|
+
printf '\n %s no GitHub token — launching gh auth login (device flow)...\n\n' "$MARK_WARN"
|
|
836
|
+
if forge_login; then
|
|
837
|
+
unset _FORGE_LOADED; _fprov="$(forge_provider 2>/dev/null || echo none)"
|
|
838
|
+
ACTIONS_TAKEN+=("Signed in to GitHub through gh auth login")
|
|
839
|
+
fi
|
|
840
|
+
fi
|
|
841
|
+
fi
|
|
842
|
+
if [[ "$_fprov" == "none" ]]; then
|
|
843
|
+
row "$MARK_WARN" "forge" "none — git-only. Issues, pull requests and labels are unavailable until a token is set: export GH_TOKEN=<token>, or gh auth login"
|
|
844
|
+
CHECKS_WARN=$((CHECKS_WARN + 1))
|
|
845
|
+
ACTIONS_NEEDED+=("Sign in to GitHub: export GH_TOKEN=<token> (or: gh auth login)")
|
|
745
846
|
else
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
row "$MARK_OK" "
|
|
847
|
+
_ghuser="$(gh_rest_user_login 2>/dev/null || true)"
|
|
848
|
+
if [[ -n "$_ghuser" ]]; then
|
|
849
|
+
row "$MARK_OK" "forge" "github — signed in as @$_ghuser"
|
|
749
850
|
CHECKS_OK=$((CHECKS_OK + 1))
|
|
750
851
|
GH_AUTHED=1
|
|
751
852
|
else
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
ACTIONS_NEEDED+=("Authenticate: gh auth login")
|
|
756
|
-
else
|
|
757
|
-
printf '\n %s gh not authenticated — launching gh auth login (device flow)...\n\n' "$MARK_WARN"
|
|
758
|
-
if gh auth login --git-credential-helper; then
|
|
759
|
-
_ghuser="$(gh api user --jq .login 2>/dev/null || echo "unknown")"
|
|
760
|
-
row "$MARK_OK" "gh auth" "logged in as @$_ghuser"
|
|
761
|
-
CHECKS_OK=$((CHECKS_OK + 1))
|
|
762
|
-
GH_AUTHED=1
|
|
763
|
-
ACTIONS_TAKEN+=("Authenticated gh (device flow)")
|
|
764
|
-
else
|
|
765
|
-
row "$MARK_FAIL" "gh auth" "login failed — run: gh auth login"
|
|
766
|
-
CHECKS_FAIL=$((CHECKS_FAIL + 1))
|
|
767
|
-
ACTIONS_NEEDED+=("Authenticate: gh auth login")
|
|
768
|
-
fi
|
|
769
|
-
fi
|
|
853
|
+
row "$MARK_FAIL" "forge" "github — the token does not work (GH_TOKEN, GITHUB_TOKEN, or gh's). Re-issue it, or gh auth login"
|
|
854
|
+
CHECKS_FAIL=$((CHECKS_FAIL + 1))
|
|
855
|
+
ACTIONS_NEEDED+=("Fix the GitHub token: export GH_TOKEN=<token>, or gh auth login")
|
|
770
856
|
fi
|
|
771
857
|
fi
|
|
772
858
|
|
|
773
|
-
# ----
|
|
859
|
+
# ---- token scope: project (Projects v2 silently fails without it) ------------
|
|
774
860
|
GH_SCOPE_PROJECT=0
|
|
775
|
-
|
|
776
|
-
|
|
861
|
+
_pv2="false"; [[ -f "$_kitcfg" ]] && _pv2="$(jq -r '.github.projectsV2 // false' "$_kitcfg" 2>/dev/null || echo false)"
|
|
862
|
+
if [[ $GH_AUTHED -eq 1 && "$_pv2" == "true" ]]; then
|
|
863
|
+
_token_scopes="$(forge_token_scopes 2>/dev/null || true)"
|
|
777
864
|
if grep -qi 'project' <<<"$_token_scopes"; then
|
|
778
|
-
row "$MARK_OK" "
|
|
865
|
+
row "$MARK_OK" "token scope:project" "present"
|
|
779
866
|
CHECKS_OK=$((CHECKS_OK + 1))
|
|
780
867
|
GH_SCOPE_PROJECT=1
|
|
868
|
+
elif [[ -z "$_token_scopes" ]]; then
|
|
869
|
+
row "$MARK_SKIP" "token scope:project" "a fine-grained token lists no scopes — give it Projects access if the board stays empty"
|
|
870
|
+
elif [[ $DRY_RUN -eq 1 || $MAY_INSTALL -eq 0 ]] || ! forge_cli_present; then
|
|
871
|
+
row "$MARK_FAIL" "token scope:project" "missing — gh auth refresh -s project (or re-issue the token with it)"
|
|
872
|
+
CHECKS_FAIL=$((CHECKS_FAIL + 1))
|
|
873
|
+
ACTIONS_NEEDED+=("Add scope: gh auth refresh -s project")
|
|
781
874
|
else
|
|
782
|
-
|
|
783
|
-
|
|
875
|
+
printf '\n %s scope "project" missing — running gh auth refresh (will open browser)...\n\n' "$MARK_WARN"
|
|
876
|
+
if forge_login_scope project; then
|
|
877
|
+
row "$MARK_OK" "token scope:project" "added"
|
|
878
|
+
CHECKS_OK=$((CHECKS_OK + 1))
|
|
879
|
+
GH_SCOPE_PROJECT=1
|
|
880
|
+
ACTIONS_TAKEN+=("Added the project scope through gh auth refresh")
|
|
881
|
+
else
|
|
882
|
+
row "$MARK_FAIL" "token scope:project" "refresh failed — gh auth refresh -s project"
|
|
784
883
|
CHECKS_FAIL=$((CHECKS_FAIL + 1))
|
|
785
884
|
ACTIONS_NEEDED+=("Add scope: gh auth refresh -s project")
|
|
786
|
-
else
|
|
787
|
-
printf '\n %s scope \"project\" missing — running gh auth refresh (will open browser)...\n\n' "$MARK_WARN"
|
|
788
|
-
if gh auth refresh -s project; then
|
|
789
|
-
row "$MARK_OK" "gh scope:project" "added"
|
|
790
|
-
CHECKS_OK=$((CHECKS_OK + 1))
|
|
791
|
-
GH_SCOPE_PROJECT=1
|
|
792
|
-
ACTIONS_TAKEN+=("Added gh scope:project via auth refresh")
|
|
793
|
-
else
|
|
794
|
-
row "$MARK_FAIL" "gh scope:project" "refresh failed — gh auth refresh -s project"
|
|
795
|
-
CHECKS_FAIL=$((CHECKS_FAIL + 1))
|
|
796
|
-
ACTIONS_NEEDED+=("Add scope: gh auth refresh -s project")
|
|
797
|
-
fi
|
|
798
885
|
fi
|
|
799
886
|
fi
|
|
800
|
-
elif [[ $GH_AUTHED -eq
|
|
801
|
-
row "$MARK_SKIP" "
|
|
887
|
+
elif [[ $GH_AUTHED -eq 1 ]]; then
|
|
888
|
+
row "$MARK_SKIP" "token scope:project" "Projects v2 is off — not needed"
|
|
802
889
|
fi
|
|
803
890
|
|
|
804
891
|
# ---- git config user.name + user.email -------------------------------------
|
|
@@ -827,13 +914,13 @@ fi
|
|
|
827
914
|
# project integrates on a non-default branch (github.baseBranch, e.g. develop) that mismatch
|
|
828
915
|
# silently leaves issues open on native/UI merges. cckit's own `pr-merge` closes them explicitly,
|
|
829
916
|
# but the misalignment still bites anyone who merges from the GitHub UI — so surface it.
|
|
830
|
-
if [[ $GH_AUTHED -eq 1 ]] &&
|
|
917
|
+
if [[ $GH_AUTHED -eq 1 ]] && [[ -f "$_kitcfg" ]]; then
|
|
831
918
|
_cfg_repo="$(jq -r '.github.repo // empty' "$_kitcfg" 2>/dev/null || true)"
|
|
832
919
|
# Same fallback chain as load_kit_config (#117) so the warning judges the branch cckit actually
|
|
833
920
|
# integrates on: baseBranch -> integrationBranch -> flow -> "main".
|
|
834
921
|
_cfg_base="$(jq -r '.github.baseBranch // .github.integrationBranch // .github.flow // "main"' "$_kitcfg" 2>/dev/null || echo main)"
|
|
835
922
|
if [[ -n "$_cfg_repo" ]]; then
|
|
836
|
-
_gh_default="$(
|
|
923
|
+
_gh_default="$(gh_rest_repo_default_branch "$_cfg_repo" 2>/dev/null || true)"
|
|
837
924
|
if [[ -z "$_gh_default" ]]; then
|
|
838
925
|
row "$MARK_SKIP" "base branch" "couldn't read GitHub default for $_cfg_repo — skipped"
|
|
839
926
|
elif [[ "$_cfg_base" == "$_gh_default" ]]; then
|
|
@@ -842,16 +929,22 @@ if [[ $GH_AUTHED -eq 1 ]] && has_cmd gh && [[ -f "$_kitcfg" ]]; then
|
|
|
842
929
|
else
|
|
843
930
|
row "$MARK_WARN" "base branch" "baseBranch '$_cfg_base' ≠ GitHub default '$_gh_default' — 'Closes #N' won't auto-close on GitHub-UI merges"
|
|
844
931
|
CHECKS_WARN=$((CHECKS_WARN + 1))
|
|
845
|
-
ACTIONS_NEEDED+=("Align base branch: '
|
|
932
|
+
ACTIONS_NEEDED+=("Align base branch: make '$_cfg_base' the default branch of $_cfg_repo on GitHub (or set github.baseBranch to '$_gh_default'). Note: 'cckit merge' already closes linked issues explicitly.")
|
|
846
933
|
fi
|
|
847
934
|
fi
|
|
848
935
|
fi
|
|
936
|
+
# ---- loose issues: the count only (the list is cckit doctor --loose) --------
|
|
937
|
+
if [[ $GH_AUTHED -eq 1 || "$_fprov" == "none" ]]; then
|
|
938
|
+
doctor_loose
|
|
939
|
+
else
|
|
940
|
+
row "$MARK_SKIP" "loose issues" "skipped — the token does not work, so the open issues cannot be read"
|
|
941
|
+
fi
|
|
849
942
|
printf '\n'
|
|
850
943
|
|
|
851
944
|
# ============================================================================
|
|
852
945
|
# SSH (optional guided flow)
|
|
853
946
|
# ============================================================================
|
|
854
|
-
printf ' %s%sSSH (optional —
|
|
947
|
+
printf ' %s%sSSH (optional — HTTPS with the token is the default)%s\n' "$C_BOLD" "" "$C_RESET"
|
|
855
948
|
|
|
856
949
|
_ssh_result=0
|
|
857
950
|
grep -q "successfully authenticated" <<<"$(ssh -T git@github.com -o ConnectTimeout=5 -o BatchMode=yes 2>&1)" && _ssh_result=1 || true
|
|
@@ -860,7 +953,7 @@ if [[ $_ssh_result -eq 1 ]]; then
|
|
|
860
953
|
row "$MARK_OK" "SSH to github.com" "key already accepted"
|
|
861
954
|
CHECKS_OK=$((CHECKS_OK + 1))
|
|
862
955
|
else
|
|
863
|
-
row "$MARK_SKIP" "SSH to github.com" "no key — HTTPS is used by default
|
|
956
|
+
row "$MARK_SKIP" "SSH to github.com" "no key — HTTPS with the token is used by default"
|
|
864
957
|
|
|
865
958
|
# Show guided SSH setup only if user explicitly wants SSH
|
|
866
959
|
if [[ "${KIT_DOCTOR_SSH:-}" == "1" && $DRY_RUN -eq 0 ]]; then
|
|
@@ -48,6 +48,8 @@ rc "two different agent labels are ambiguous" "$?" "2"
|
|
|
48
48
|
|
|
49
49
|
# ── parent effort number ───────────────────────────────────────────────────────────────────────
|
|
50
50
|
t "parent number from a sub title" "$(ap_parent_effort_num '[Effort 318] 3 · resolve profiles')" "318"
|
|
51
|
+
t "parent number from a [E318.3] title" "$(ap_parent_effort_num '[E318.3] resolve profiles')" "318"
|
|
52
|
+
t "an [E318] umbrella is not a sub" "$(ap_parent_effort_num '[E318] agents by profile')" ""
|
|
51
53
|
t "standalone issue has no parent" "$(ap_parent_effort_num 'fix: a plain bug')" ""
|
|
52
54
|
t "an umbrella title is not a sub" "$(ap_parent_effort_num '[Effort] 318 · agents by profile')" ""
|
|
53
55
|
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
# "." and the sibling source below silently missed. Same defect and same fix as kit-gc.sh:38 (#219):
|
|
26
26
|
# `${BASH_SOURCE[0]:-$0}` covers zsh, CDPATH='' and the redirect stop an interactive zsh echoing the
|
|
27
27
|
# directory into the substitution.
|
|
28
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
29
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
30
|
+
# shellcheck source=/dev/null
|
|
31
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
32
|
+
fi
|
|
33
|
+
|
|
28
34
|
_ar_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd)"
|
|
29
35
|
# shellcheck source=/dev/null
|
|
30
36
|
[ -n "${AP_STAGES_DEFAULT:-}" ] || . "$_ar_dir/agent-profile.sh"
|
|
@@ -57,9 +63,10 @@ EOF
|
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
# ap_parent_effort_num <title> — echo the parent effort number from a sub-issue title
|
|
60
|
-
# (`[Effort 318] 3 · thing` -> 318). Empty for a standalone issue
|
|
66
|
+
# (`[E318.3] thing` or the legacy `[Effort 318] 3 · thing` -> 318). Empty for a standalone issue
|
|
67
|
+
# and for an effort's own title. Pure.
|
|
61
68
|
ap_parent_effort_num() {
|
|
62
|
-
printf '%s' "${1:-}" | sed -n 's/^\[Effort \([0-9][0-9]*\)\].*/\1/p'
|
|
69
|
+
printf '%s' "${1:-}" | sed -n -e 's/^\[E\([0-9][0-9]*\)\.[0-9][0-9]*\] .*/\1/p' -e 's/^\[Effort \([0-9][0-9]*\)\].*/\1/p'
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
# ap_labels_fetch <repo> <issue> — echo an issue's labels, comma-separated. Best-effort: any gh
|
|
@@ -69,8 +76,8 @@ ap_parent_effort_num() {
|
|
|
69
76
|
ap_labels_fetch() {
|
|
70
77
|
local repo="${1:-}" num="${2:-}"
|
|
71
78
|
[ -n "$repo" ] && [ -n "$num" ] || return 0
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
forge_available || { forge_note_none "${CCKIT_VERB:-orchestrate}" "issue labels are not read; the agent profile comes from agents.default"; return 0; }
|
|
80
|
+
forge_rest "repos/$repo/issues/$num" --jq '[.labels[].name] | join(",")' 2>/dev/null || true
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
# ap_resolve <cfg> <stage> <override> <issue-labels> <parent-labels> — echo the resolved profile.
|
|
@@ -133,8 +140,8 @@ ap_resolve_source() {
|
|
|
133
140
|
ap_pr_issue() {
|
|
134
141
|
local repo="${1:-}" pr="${2:-}" br
|
|
135
142
|
[ -n "$repo" ] && [ -n "$pr" ] || return 0
|
|
136
|
-
|
|
137
|
-
br="$(
|
|
143
|
+
forge_available || { forge_note_none "${CCKIT_VERB:-orchestrate}" "issue labels are not read; the agent profile comes from agents.default"; return 0; }
|
|
144
|
+
br="$(forge_rest "repos/$repo/pulls/$pr" --jq '.head.ref' 2>/dev/null)" || return 0
|
|
138
145
|
[ -n "$br" ] || return 0
|
|
139
146
|
wt_issue_number "$br"
|
|
140
147
|
}
|
|
@@ -144,8 +151,8 @@ ap_pr_issue() {
|
|
|
144
151
|
ap_issue_title() {
|
|
145
152
|
local repo="${1:-}" num="${2:-}"
|
|
146
153
|
[ -n "$repo" ] && [ -n "$num" ] || return 0
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
forge_available || { forge_note_none "${CCKIT_VERB:-orchestrate}" "issue labels are not read; the agent profile comes from agents.default"; return 0; }
|
|
155
|
+
forge_rest "repos/$repo/issues/$num" --jq '.title // ""' 2>/dev/null || true
|
|
149
156
|
}
|
|
150
157
|
|
|
151
158
|
# ap_pr_context <repo> <pr> — echo "<issue>\t<issue-labels>\t<parent-labels>", TAB-separated.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# shellcheck shell=bash
|
|
3
|
-
# board-view.sh — pure helpers for the read-only board view (`cckit
|
|
3
|
+
# board-view.sh — pure helpers for the read-only board view (`cckit status --board`). Each takes JSON and
|
|
4
4
|
# emits markdown/text, or JSON for the two `_data` forms; none call gh, so they are unit-testable with canned fixtures (#122).
|
|
5
5
|
# Ported from the host project's board view: a merge-ordered open-PR queue, a stale-issue flag, a
|
|
6
6
|
# not-on-board flag, and Project Status per issue. bash 3.2 + zsh safe. Requires jq.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# (size is "" when unlabeled); a `blocked` label marks blocked. An agent branch (agent|claude|auto/*)
|
|
14
14
|
# or an agent:auto label sets `agent`, so a human checks the row before starting overlapping work.
|
|
15
15
|
# `state` is one of blocked | draft | conflict | ready | needs-review. This is the ONE place the
|
|
16
|
-
# order is computed: board_merge_queue renders these rows, and `cckit
|
|
16
|
+
# order is computed: board_merge_queue renders these rows, and `cckit status --board --json` emits them.
|
|
17
17
|
board_merge_queue_data() {
|
|
18
18
|
printf '%s' "${1:-[]}" | jq -c '
|
|
19
19
|
def lbl($p): (($p.labels // []) | map(.name));
|
|
@@ -64,7 +64,7 @@ EOF
|
|
|
64
64
|
|
|
65
65
|
# board_stale_data <issues-json> [days] — JSON array [{number, days}] of open issues untouched for
|
|
66
66
|
# more than [days] (default 14), most-stale first; [] when none. <issues-json> is
|
|
67
|
-
# `gh issue list --json number,updatedAt`. The data form of the stale flag (`cckit
|
|
67
|
+
# `gh issue list --json number,updatedAt`. The data form of the stale flag (`cckit status --board --json`).
|
|
68
68
|
board_stale_data() {
|
|
69
69
|
local issues="${1:-[]}" days="${2:-14}" now
|
|
70
70
|
now="$(date -u +%s 2>/dev/null || echo 0)"
|
package/scripts/lib/captain.sh
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
# is unit-tested without the network. Requires gh + jq. bash 3.2 / zsh compatible.
|
|
19
19
|
# errors: mixed — cap_* are pure; captain_gate/captain_pass propagate a gh failure
|
|
20
20
|
|
|
21
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
22
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
23
|
+
# shellcheck source=/dev/null
|
|
24
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
25
|
+
fi
|
|
26
|
+
|
|
21
27
|
CAPTAIN_REPO="${CAPTAIN_REPO:-${KIT_REPO:-}}"
|
|
22
28
|
|
|
23
29
|
# State lives in the shared .cckit/ (kit-state.sh), never CWD-relative: the captain gates the whole
|
|
@@ -311,7 +317,7 @@ _cap_load_policy_config() {
|
|
|
311
317
|
# reviewer on every mergeable PR and then merges the ones the reviewer never got to has gained
|
|
312
318
|
# nothing. requireReview:false turns that implication off without giving up the reviewer, and an
|
|
313
319
|
# explicit requireReview:true requires a verdict with no review.command (a reviewer run by hand
|
|
314
|
-
# or by CI, recorded through `cckit receipt`).
|
|
320
|
+
# or by CI, recorded through `cckit agent receipt`).
|
|
315
321
|
if [ -z "${KIT_CAPTAIN_REQUIRE_REVIEW:-}" ]; then
|
|
316
322
|
case "$(_cap_cfg_bool "$cfg" requireReview)" in
|
|
317
323
|
true) KIT_CAPTAIN_REQUIRE_REVIEW=1 ;;
|
|
@@ -350,6 +356,27 @@ _cap_issue_of_branch() {
|
|
|
350
356
|
printf '%s' "$1" | sed -nE 's#^[a-z]+/([0-9]+)-.*#\1#p'
|
|
351
357
|
}
|
|
352
358
|
|
|
359
|
+
# _cap_pr_json <repo> <pr> — the PR in the shape captain_gate reads (gh's --json field names), from
|
|
360
|
+
# three REST reads: the pull, its files, and the head commit's check runs + statuses.
|
|
361
|
+
_cap_pr_json() {
|
|
362
|
+
local repo="$1" pr="$2" p files checks statuses sha
|
|
363
|
+
p="$(forge_rest "repos/$repo/pulls/$pr")" || return 1
|
|
364
|
+
sha="$(printf '%s' "$p" | jq -r '.head.sha // ""')"
|
|
365
|
+
files="$(forge_rest "repos/$repo/pulls/$pr/files" -X GET -f per_page=100 --paginate 2>/dev/null | jq -s 'add // []' 2>/dev/null)" || files='[]'
|
|
366
|
+
checks="$(forge_rest "repos/$repo/commits/$sha/check-runs" -X GET -f per_page=100 2>/dev/null | jq '.check_runs // []' 2>/dev/null)" || checks='[]'
|
|
367
|
+
statuses="$(forge_rest "repos/$repo/commits/$sha/status" 2>/dev/null | jq '.statuses // []' 2>/dev/null)" || statuses='[]'
|
|
368
|
+
printf '%s' "$p" | jq --argjson files "${files:-[]}" --argjson checks "${checks:-[]}" --argjson statuses "${statuses:-[]}" '{
|
|
369
|
+
number, title,
|
|
370
|
+
headRefName: .head.ref, headRefOid: .head.sha,
|
|
371
|
+
mergeable: (if .mergeable == true then "MERGEABLE" elif .mergeable == false then "CONFLICTING" else "UNKNOWN" end),
|
|
372
|
+
mergeStateStatus: ((.mergeable_state // "unknown") | ascii_upcase),
|
|
373
|
+
isDraft: .draft,
|
|
374
|
+
statusCheckRollup: ([ $checks[] | {name, conclusion: (.conclusion // (if .status == "completed" then "" else .status end)), state: null} ]
|
|
375
|
+
+ [ $statuses[] | {name: .context, state, conclusion: null} ]),
|
|
376
|
+
files: [ $files[] | {path: .filename} ],
|
|
377
|
+
labels: [ .labels[]? | {name} ] }'
|
|
378
|
+
}
|
|
379
|
+
|
|
353
380
|
# captain_gate <pr#> — fetch + classify one PR. Echoes
|
|
354
381
|
# "pr<TAB>issue<TAB>state<TAB>action<TAB>title<TAB>reason<TAB>checks<TAB>head<TAB>qa". A CLEAN PR that trips a policy
|
|
355
382
|
# floor (cap_policy_floor) is downgraded to HELD/hold so the captain never auto-merges it; `reason`
|
|
@@ -357,7 +384,7 @@ _cap_issue_of_branch() {
|
|
|
357
384
|
# PASS/NONE) — REPORTED, not re-decided, so captain_pass can say when a merge rests on NONE.
|
|
358
385
|
captain_gate() {
|
|
359
386
|
local repo="$CAPTAIN_REPO" pr="$1" j mergeable mss checks review qa head issue state action title branch files labels reason
|
|
360
|
-
j="$(
|
|
387
|
+
j="$(_cap_pr_json "$repo" "$pr" 2>/dev/null)" \
|
|
361
388
|
|| { echo "captain: cannot read PR #$pr" >&2; return 1; }
|
|
362
389
|
mergeable="$(printf '%s' "$j" | jq -r '.mergeable // "UNKNOWN"')"
|
|
363
390
|
mss="$(printf '%s' "$j" | jq -r '.mergeStateStatus // "UNKNOWN"')"
|
|
@@ -398,15 +425,15 @@ captain_gate() {
|
|
|
398
425
|
_cap_open_prs() {
|
|
399
426
|
local repo="$CAPTAIN_REPO" effort="${1:-}"
|
|
400
427
|
if [ -n "$effort" ]; then
|
|
401
|
-
local subs; subs="$(
|
|
428
|
+
local subs; subs="$(forge_rest "repos/$repo/issues/$effort/sub_issues" --paginate --jq '.[].number' 2>/dev/null | tr '\n' ' ')"
|
|
402
429
|
local pr br iss
|
|
403
|
-
|
|
404
|
-
--jq '.[] | "\(.number)\t\(.
|
|
430
|
+
forge_rest "repos/$repo/pulls" -X GET -f state=open -f per_page=100 \
|
|
431
|
+
--jq '.[] | "\(.number)\t\(.head.ref)"' 2>/dev/null | while IFS="$(printf '\t')" read -r pr br; do
|
|
405
432
|
iss="$(_cap_issue_of_branch "$br")"
|
|
406
433
|
case " $subs " in *" $iss "*) printf '%s\n' "$pr" ;; esac
|
|
407
434
|
done
|
|
408
435
|
else
|
|
409
|
-
|
|
436
|
+
forge_rest "repos/$repo/pulls" -X GET -f state=open -f per_page=100 --jq '.[].number' 2>/dev/null
|
|
410
437
|
fi
|
|
411
438
|
}
|
|
412
439
|
|
|
@@ -414,7 +441,7 @@ _cap_open_prs() {
|
|
|
414
441
|
# Returns the count of PRs merged this pass via the CAPTAIN_MERGED global (for the loop to detect progress).
|
|
415
442
|
CAPTAIN_MERGED=0
|
|
416
443
|
captain_pass() {
|
|
417
|
-
|
|
444
|
+
forge_need watch || return 1; command -v jq >/dev/null 2>&1 || { echo "captain: needs jq" >&2; return 1; }
|
|
418
445
|
local repo="$CAPTAIN_REPO" do_merge=0 effort="" dry=0
|
|
419
446
|
while [ "$#" -gt 0 ]; do
|
|
420
447
|
case "$1" in
|
|
@@ -490,7 +517,9 @@ captain_pass() {
|
|
|
490
517
|
fi
|
|
491
518
|
fi
|
|
492
519
|
if [ "$action" = "merge" ] && [ "$do_merge" = "1" ] && [ "$dry" = "0" ]; then
|
|
493
|
-
if
|
|
520
|
+
if gh_rest_pr_merge "$repo" "$pr" squash >/dev/null 2>&1; then
|
|
521
|
+
# The remote branch goes with the merge (git, not the API); kept in a cloud session (#396).
|
|
522
|
+
cckit_in_cloud || { _br="$(forge_rest "repos/$repo/pulls/$pr" --jq '.head.ref' 2>/dev/null)"; [ -n "$_br" ] && git push origin --delete "$_br" >/dev/null 2>&1 || true; }
|
|
494
523
|
printf ' PR #%-4s %-14s MERGED (#%s %s)\n' "$pr" "$state" "$issue" "$title"
|
|
495
524
|
merged_any=$((merged_any + 1))
|
|
496
525
|
else
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# report: the branch `cckit start` would cut parses to the issue number, and while that issue is
|
|
8
8
|
# OPEN `cckit gc` reports the branch PROTECTED — even when the branch's own PR has MERGED, the case
|
|
9
9
|
# in which an unprotected branch is offered as SAFE to delete.
|
|
10
|
-
# Hermetic: a throwaway git repo under mktemp,
|
|
10
|
+
# Hermetic: a throwaway git repo under mktemp, the forge shim (test-forge-shim.sh) on PATH, no network.
|
|
11
11
|
# Run: bash scripts/lib/content-kinds-gc-test.sh
|
|
12
12
|
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
13
13
|
set -u
|
|
@@ -33,7 +33,7 @@ echo base > base.txt; git add base.txt; git commit -q -m init
|
|
|
33
33
|
|
|
34
34
|
# One issue per content kind: 41 post · 42 campaign · 43 brand · 44 research. Issue 45 is CLOSED,
|
|
35
35
|
# the control: its branch must NOT be protected, or the assertions below prove nothing.
|
|
36
|
-
n=41; branches="";
|
|
36
|
+
n=41; branches=""; pr_json=""
|
|
37
37
|
for k in $KIT_CONTENT_KINDS; do
|
|
38
38
|
prefix="$(_wt_kind_prefix "$k" 2>/dev/null)"
|
|
39
39
|
kit_kind_valid "$prefix"; t "kind:$k starts on a prefix of the closed set ($prefix/)" "$?" "0"
|
|
@@ -41,38 +41,39 @@ for k in $KIT_CONTENT_KINDS; do
|
|
|
41
41
|
t "branch $b parses to issue $n" "$(wt_issue_number "$b")" "$n"
|
|
42
42
|
git branch "$b" >/dev/null 2>&1
|
|
43
43
|
branches="$branches $b"
|
|
44
|
-
|
|
45
|
-
"
|
|
44
|
+
pr_json="$pr_json${pr_json:+,}{\"number\":$((n + 100)),\"head\":{\"ref\":\"$b\"},\"state\":\"closed\",\"merged_at\":\"2026-01-01T00:00:00Z\"}"
|
|
46
45
|
n=$((n + 1))
|
|
47
46
|
done
|
|
48
47
|
t "four content kinds were exercised" "$(printf '%s\n' $branches | grep -c .)" "4"
|
|
49
48
|
git branch task/45-closed-piece >/dev/null 2>&1
|
|
50
|
-
|
|
51
|
-
"
|
|
49
|
+
pr_json="$pr_json,{\"number\":145,\"head\":{\"ref\":\"task/45-closed-piece\"},\"state\":\"closed\",\"merged_at\":\"2026-01-01T00:00:00Z\"}"
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export PR_ROWS="$tmp/pr-rows"
|
|
51
|
+
# The forge shim (test-forge-shim.sh) stands in for GitHub: issue 45 is closed, every other issue
|
|
52
|
+
# open; the PR list (GET repos/o/r/pulls) carries one MERGED PR per branch, from a fixture.
|
|
53
|
+
# shellcheck source=/dev/null
|
|
54
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
|
|
55
|
+
export PATH="$tmp/bin:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
|
|
56
|
+
export GH_LOG="$tmp/gh.log" GH_CLOSED="45" GH_FIXTURE="$tmp/fixture"
|
|
57
|
+
: > "$GH_LOG"
|
|
58
|
+
printf '[%s]' "$pr_json" > "$tmp/pulls.json"
|
|
59
|
+
cat > "$GH_FIXTURE" <<FIX
|
|
60
|
+
case "\$method \$ep" in "GET repos/o/r/pulls") out="\$(cat '$tmp/pulls.json')" ;; esac
|
|
61
|
+
FIX
|
|
65
62
|
|
|
66
63
|
for b in $branches; do
|
|
67
|
-
reason="$(
|
|
64
|
+
reason="$(wt_protected_reason "$b" "o/r")"
|
|
68
65
|
t "wt_protected_reason keeps $b" "$reason" "issue #$(wt_issue_number "$b") still OPEN"
|
|
69
66
|
done
|
|
70
|
-
t "the closed issue's branch is not protected" "$(
|
|
67
|
+
t "the closed issue's branch is not protected" "$(wt_protected_reason task/45-closed-piece "o/r")" ""
|
|
68
|
+
t "each protection read is GET repos/o/r/issues/<n>" "$(grep -c '^GET repos/o/r/issues/4[1-5] ' "$GH_LOG")" "5"
|
|
71
69
|
|
|
72
70
|
# The gc report itself: each live content branch is in the protected bucket, none in the safe one.
|
|
73
71
|
# shellcheck source=/dev/null
|
|
74
72
|
source "$LIB/kit-gc.sh"
|
|
75
|
-
|
|
73
|
+
: > "$GH_LOG"
|
|
74
|
+
analysis="$(KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
75
|
+
t "gc reads the PR list once, over REST" "$(grep -c '^GET repos/o/r/pulls?state=all&per_page=100 ' "$GH_LOG")" "1"
|
|
76
|
+
t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
|
|
76
77
|
for b in $branches; do
|
|
77
78
|
row="$(printf '%s\n' "$analysis" | grep -F "$b" | sed -n 1p)"
|
|
78
79
|
case "$row" in
|