@jeiemgi/cckit 0.1.8 → 0.3.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 (68) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +21 -8
  3. package/README.md +63 -5
  4. package/bin/cckit +77 -12
  5. package/cckit.config.json +1 -1
  6. package/commands/kit-doctor.md +3 -1
  7. package/kit.config.schema.json +24 -0
  8. package/package.json +1 -1
  9. package/scripts/annotate-setup.sh +7 -2
  10. package/scripts/capture-project-ids.sh +23 -10
  11. package/scripts/copilot-loop-test.sh +162 -0
  12. package/scripts/init.sh +22 -4
  13. package/scripts/kit-doctor.sh +185 -7
  14. package/scripts/kit-version-check-test.sh +36 -0
  15. package/scripts/kit-version-check.sh +19 -4
  16. package/scripts/knowledge-lint.sh +4 -1
  17. package/scripts/lib/board-view-test.sh +54 -0
  18. package/scripts/lib/board-view.sh +80 -0
  19. package/scripts/lib/captain-test.sh +76 -0
  20. package/scripts/lib/captain.sh +268 -0
  21. package/scripts/lib/config-path-test.sh +47 -0
  22. package/scripts/lib/config-path.sh +29 -0
  23. package/scripts/lib/copilot-test.sh +30 -0
  24. package/scripts/lib/copilot.sh +101 -0
  25. package/scripts/lib/effort-metrics-test.sh +57 -0
  26. package/scripts/lib/effort-metrics.sh +19 -5
  27. package/scripts/lib/effort-ops-test.sh +51 -2
  28. package/scripts/lib/effort-ops.sh +314 -49
  29. package/scripts/lib/effort-parity-test.sh +128 -0
  30. package/scripts/lib/effort-slug-test.sh +87 -0
  31. package/scripts/lib/effort-slug.sh +104 -0
  32. package/scripts/lib/effort.sh +34 -0
  33. package/scripts/lib/gh-project-test.sh +95 -0
  34. package/scripts/lib/gh-project.sh +22 -7
  35. package/scripts/lib/git-remote-test.sh +57 -0
  36. package/scripts/lib/git-remote.sh +21 -0
  37. package/scripts/lib/kit-config-test.sh +37 -0
  38. package/scripts/lib/kit-config.sh +33 -13
  39. package/scripts/lib/kit-events.sh +5 -3
  40. package/scripts/lib/kit-gc-test.sh +88 -0
  41. package/scripts/lib/kit-gc.sh +136 -19
  42. package/scripts/lib/kit-local.sh +8 -1
  43. package/scripts/lib/next.sh +75 -0
  44. package/scripts/lib/plan-machine-test.sh +72 -0
  45. package/scripts/lib/plan-machine.sh +260 -0
  46. package/scripts/lib/plan-next-test.sh +87 -0
  47. package/scripts/lib/plan-next.sh +212 -0
  48. package/scripts/lib/project-scan.sh +7 -1
  49. package/scripts/lib/render-test.sh +40 -0
  50. package/scripts/lib/render.sh +57 -0
  51. package/scripts/lib/worktree-start.sh +12 -3
  52. package/scripts/lib/zsh-safety-test.sh +73 -0
  53. package/scripts/portable-test.sh +62 -20
  54. package/scripts/setup-labels.sh +13 -2
  55. package/scripts/showcase.sh +13 -4
  56. package/scripts/status-test.sh +63 -0
  57. package/scripts/status.sh +12 -4
  58. package/scripts/task-sync.sh +79 -10
  59. package/skills/kit-autopilot/SKILL.md +5 -0
  60. package/skills/kit-docs-writer/SKILL.md +135 -0
  61. package/skills/kit-effort-new/SKILL.md +39 -111
  62. package/skills/kit-effort-pr/SKILL.md +6 -2
  63. package/skills/kit-next/SKILL.md +58 -0
  64. package/skills/kit-plan-next/SKILL.md +82 -0
  65. package/templates/hooks/mempal_session_start.sh.tmpl +36 -2
  66. package/templates/rules/effort-model.md +26 -6
  67. package/templates/rules/mempalace.md +1 -0
  68. package/templates/rules/plan-next.md +58 -0
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # board-view.sh — pure render helpers for the read-only board view (`cckit sync`). Each takes JSON
4
+ # and emits markdown/text; none call gh, so they are unit-testable with canned fixtures (#122).
5
+ # Ported from the host project's board view: a merge-ordered open-PR queue, a stale-issue flag, a
6
+ # not-on-board flag, and Project Status per issue. bash 3.2 + zsh safe. Requires jq.
7
+
8
+ # board_merge_queue <prs-json> — render the open-PR merge queue as a markdown table. <prs-json> is
9
+ # `gh pr list --json number,title,labels,isDraft,headRefName,reviewDecision,mergeable` output.
10
+ # Ordering answers "in what order do I merge?": ready(1) -> draft(2) -> blocked(3); within a tier,
11
+ # risk:low first, then smaller size, then issue number. Risk/size come from risk:/size: labels; a
12
+ # `blocked` label marks blocked. An agent branch (agent|claude|auto/*) or an agent:auto label flags a
13
+ # row as bot-authored so a human checks it before starting overlapping work.
14
+ board_merge_queue() {
15
+ local prs="${1:-[]}" rows tab; tab="$(printf '\t')"
16
+ rows="$(printf '%s' "$prs" | jq -r '
17
+ def lbl($p): (($p.labels // []) | map(.name));
18
+ def risk($l): ($l | map(select(startswith("risk:"))) | first // "risk:med" | ltrimstr("risk:"));
19
+ def size($l): ($l | map(select(startswith("size:"))) | first // "" | ltrimstr("size:"));
20
+ def riskRank($r): if $r=="low" then 0 elif $r=="med" then 1 else 2 end;
21
+ def sizeRank($s): ({"XS":0,"S":1,"M":2,"L":3,"XL":4}[$s] // 2);
22
+ map( . as $p | lbl($p) as $l
23
+ | (risk($l)) as $risk | (size($l)) as $size
24
+ | (any($l[]; . == "blocked")) as $blocked
25
+ | (((($p.headRefName // "") | test("^(agent|claude|auto)/")) or (any($l[]; . == "agent:auto")))) as $agent
26
+ | (if $blocked then 3 elif ($p.isDraft // false) then 2 else 1 end) as $ready
27
+ | { n:$p.number, title:$p.title, risk:$risk,
28
+ size:(if $size=="" then "—" else $size end),
29
+ blocked:$blocked, draft:($p.isDraft // false), agent:$agent,
30
+ conflict:($p.mergeable == "CONFLICTING"), approved:($p.reviewDecision == "APPROVED"),
31
+ ready:$ready, rr:riskRank($risk), sr:sizeRank($size) } )
32
+ | sort_by(.ready, .rr, .sr, .n)
33
+ | .[]
34
+ | [ ("#" + (.n|tostring)), .risk, .size,
35
+ (if .blocked then "▪ blocked" elif .draft then "· draft" elif .conflict then "◆ conflict"
36
+ elif .approved then "● ready" else "· needs review" end),
37
+ (if .agent then "● agent" else "·" end),
38
+ (if (.title|length) > 48 then (.title[0:48] + "…") else .title end) ] | @tsv')"
39
+ printf '### Merge Queue (open PRs — merge top-down)\n'
40
+ printf '| PR | Risk | Size | State | Who | Title |\n|---|---|---|---|---|---|\n'
41
+ if [ -z "$rows" ]; then
42
+ printf '| — | | | no open PRs ✓ | | |\n'
43
+ else
44
+ while IFS="$tab" read -r pr risk size state who title; do
45
+ [ -z "$pr" ] && continue
46
+ printf '| %s | %s | %s | %s | %s | %s |\n' "$pr" "$risk" "$size" "$state" "$who" "$title"
47
+ done <<EOF
48
+ $rows
49
+ EOF
50
+ fi
51
+ printf '\n_Order: ready → draft → blocked; within that, risk:low first, then smaller size. ● agent = a bot branch — check it before starting overlapping work._\n'
52
+ }
53
+
54
+ # board_stale_list <issues-json> [days] — space-joined "#N(Dd)" tokens for open issues untouched for
55
+ # more than [days] (default 14), most-stale first. Empty when none. <issues-json> is
56
+ # `gh issue list --json number,updatedAt`. The caller renders the "none ✓" fallback.
57
+ board_stale_list() {
58
+ local issues="${1:-[]}" days="${2:-14}" now
59
+ now="$(date -u +%s 2>/dev/null || echo 0)"
60
+ printf '%s' "$issues" | jq -r --argjson now "$now" --argjson d "$days" '
61
+ [ .[]
62
+ | (($now - ((.updatedAt // "1970-01-01T00:00:00Z") | fromdateiso8601)) / 86400 | floor) as $age
63
+ | select($age > $d) | {n:.number, age:$age} ]
64
+ | sort_by(-.age) | map("#\(.n)(\(.age)d)") | join(" ")'
65
+ }
66
+
67
+ # board_not_on_board <issues-json> <status-map-json> — space-joined "#N" for open issues that have
68
+ # NO Project Status (absent from the board map), so an adopter sees which issues never got added to
69
+ # the board. <status-map-json> is {"<number>":"<status>", …}. Empty when all issues are on the board.
70
+ board_not_on_board() {
71
+ local issues="${1:-[]}" map="${2:-{\}}"
72
+ printf '%s' "$issues" | jq -r --argjson m "$map" '
73
+ [ .[] | select(($m[(.number|tostring)] // null) == null) | "#\(.number)" ] | join(" ")'
74
+ }
75
+
76
+ # board_status_for <number> <status-map-json> — echo the issue's Project Status, or "—" when the
77
+ # issue is not on the board (or the board is off). Used to annotate each issue row with its Status.
78
+ board_status_for() {
79
+ printf '%s' "${2:-{\}}" | jq -r --arg n "$1" '.[$n] // "—"'
80
+ }
@@ -0,0 +1,76 @@
1
+ #!/bin/sh
2
+ # captain-test.sh — self-test for captain.sh pure gate policy under bash AND zsh.
3
+ # Network-free: covers cap_checks_summary / cap_classify / cap_action and the branch parser only
4
+ # (the gh-driven captain_gate/pass/loop are not exercised).
5
+ # Run: bash scripts/lib/captain-test.sh
6
+
7
+ dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
8
+
9
+ if [ -n "${CAP_TEST_INNER:-}" ]; then
10
+ . "$dir/captain.sh"
11
+ fail=0
12
+ eq() { if [ "$2" != "$3" ]; then echo "FAIL($CAP_TEST_INNER): $1 -> '[$2]', want '[$3]'"; fail=1; fi; }
13
+
14
+ # cap_checks_summary — worst-first precedence over a rollup JSON array.
15
+ eq "checks fail wins" "$(printf '[{"conclusion":"SUCCESS"},{"conclusion":"FAILURE"}]' | cap_checks_summary)" "FAIL"
16
+ eq "checks pending" "$(printf '[{"conclusion":"SUCCESS"},{"status":"IN_PROGRESS","conclusion":null}]' | cap_checks_summary)" "PENDING"
17
+ eq "checks pass" "$(printf '[{"conclusion":"SUCCESS"},{"conclusion":"SKIPPED"}]' | cap_checks_summary)" "PASS"
18
+ eq "checks none" "$(printf '[]' | cap_checks_summary)" "NONE"
19
+ eq "checks empty-concl pending" "$(printf '[{"conclusion":""}]' | cap_checks_summary)" "PENDING"
20
+
21
+ # cap_classify — the verdict matrix.
22
+ eq "clean" "$(cap_classify MERGEABLE CLEAN PASS)" "CLEAN"
23
+ eq "clean no checks" "$(cap_classify MERGEABLE CLEAN NONE)" "CLEAN"
24
+ eq "unstable+pass" "$(cap_classify MERGEABLE UNSTABLE PASS)" "CLEAN"
25
+ eq "conflicting flag" "$(cap_classify CONFLICTING BLOCKED PASS)" "CONFLICTING"
26
+ eq "dirty is conflict" "$(cap_classify UNKNOWN DIRTY PASS)" "CONFLICTING"
27
+ eq "checks failing" "$(cap_classify MERGEABLE UNSTABLE FAIL)" "CHECKS_FAILING"
28
+ eq "checks pending" "$(cap_classify MERGEABLE UNSTABLE PENDING)" "CHECKS_PENDING"
29
+ eq "draft first" "$(cap_classify MERGEABLE DRAFT PASS)" "DRAFT"
30
+ eq "blocked fallback" "$(cap_classify UNKNOWN BLOCKED PASS)" "BLOCKED"
31
+ # failing checks must not be hidden even when mergeable says MERGEABLE.
32
+ eq "fail beats mergeable" "$(cap_classify MERGEABLE CLEAN FAIL)" "CHECKS_FAILING"
33
+
34
+ # cap_action — verdict -> action.
35
+ eq "act clean" "$(cap_action CLEAN)" "merge"
36
+ eq "act conflicting" "$(cap_action CONFLICTING)" "rebase"
37
+ eq "act failing" "$(cap_action CHECKS_FAILING)" "fix"
38
+ eq "act pending" "$(cap_action CHECKS_PENDING)" "wait"
39
+ eq "act draft" "$(cap_action DRAFT)" "wait"
40
+ eq "act held" "$(cap_action HELD)" "hold"
41
+ eq "act blocked" "$(cap_action BLOCKED)" "skip"
42
+
43
+ # cap_policy_floor — floors that block an unattended auto-merge (default ON). Non-empty = held.
44
+ nl="$(printf '\n')"
45
+ eq "floor: clean PR merges" "$(KIT_CAPTAIN_FLOORS= KIT_CAPTAIN_EXTRA_GLOBS= cap_policy_floor "src/app.ts${nl}README.md" "")" ""
46
+ neq() { if [ -z "$2" ]; then echo "FAIL($CAP_TEST_INNER): $1 -> empty, want non-empty"; fail=1; fi; }
47
+ neq "floor: workflow file held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor ".github/workflows/ci.yml" "")"
48
+ neq "floor: pnpm-lock held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor "pnpm-lock.yaml" "")"
49
+ neq "floor: package.json held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor "apps/web/package.json" "")"
50
+ neq "floor: workspace yaml held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor "pnpm-workspace.yaml" "")"
51
+ neq "floor: turbo.json held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor "turbo.json" "")"
52
+ neq "floor: pem held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor "certs/server.pem" "")"
53
+ neq "floor: dotenv held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor ".env.production" "")"
54
+ neq "floor: secrets path held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor "config/secrets/db.yml" "")"
55
+ neq "floor: hold label held" "$(KIT_CAPTAIN_FLOORS= cap_policy_floor "src/app.ts" "priority:p1 hold")"
56
+ neq "floor: extra glob held" "$(KIT_CAPTAIN_FLOORS= KIT_CAPTAIN_EXTRA_GLOBS='migrations/*' cap_policy_floor "migrations/001.sql" "")"
57
+ # a disabling override lets even a workflow file through (config/CLI can opt out).
58
+ eq "floor: KIT_CAPTAIN_FLOORS=0 disables" "$(KIT_CAPTAIN_FLOORS=0 cap_policy_floor ".github/workflows/ci.yml" "hold")" ""
59
+
60
+ # _cap_issue_of_branch — pull the issue number out of a flow branch.
61
+ eq "branch task" "$(_cap_issue_of_branch 'task/47-admin-clerk')" "47"
62
+ eq "branch fix" "$(_cap_issue_of_branch 'fix/9-roadmap')" "9"
63
+ eq "branch effort" "$(_cap_issue_of_branch 'effort/123-copilot')" "123"
64
+ eq "branch plain" "$(_cap_issue_of_branch 'main')" ""
65
+
66
+ if [ "$fail" -eq 0 ]; then echo "PASS($CAP_TEST_INNER): captain gate policy"; fi
67
+ exit "$fail"
68
+ fi
69
+
70
+ # Outer: re-run under each available shell.
71
+ rc=0
72
+ for sh in bash zsh; do
73
+ command -v "$sh" >/dev/null 2>&1 || continue
74
+ CAP_TEST_INNER="$sh" "$sh" "$0" || rc=1
75
+ done
76
+ exit "$rc"
@@ -0,0 +1,268 @@
1
+ #!/usr/bin/env bash
2
+ # captain.sh — the captain loop: gate open PRs, squash-merge the clean ones, advance the board to the
3
+ # next unblocked wave, and checkpoint so the loop can stop and resume (Effort 75 · #77).
4
+ #
5
+ # Autopilot has two halves. `orchestrate`/`autopilot` LAUNCH the per-issue flows; the captain CLOSES
6
+ # them — it inspects each PR, decides (CLEAN / CONFLICTING / CHECKS_FAILING / CHECKS_PENDING / DRAFT /
7
+ # BLOCKED), merges what is ready, and lets the freshly-merged issues unblock the next wave. This is
8
+ # the half that used to be left to the driving agent; now it is a script the agent (or `cckit watch`)
9
+ # runs in a loop.
10
+ #
11
+ # cckit watch one pass: gate every open PR, report (no merge) — safe default
12
+ # cckit watch --merge gate + squash-merge the CLEAN PRs, then show the next wave
13
+ # cckit watch --effort <N> scope to PRs for effort #N's sub-issues
14
+ # cckit watch --loop repeat passes until no CLEAN PR remains (checkpointed), then stop
15
+ # cckit watch --max-passes M cap the loop at M passes (default 10)
16
+ #
17
+ # Gate decision is three pure helpers (cap_checks_summary / cap_classify / cap_action) so the policy
18
+ # is unit-tested without the network. Requires gh + jq. bash 3.2 / zsh compatible.
19
+
20
+ CAPTAIN_REPO="${CAPTAIN_REPO:-${KIT_REPO:-}}"
21
+ CAPTAIN_STATE="${CAPTAIN_STATE:-.cckit/captain.state}"
22
+
23
+ # cap_checks_summary — collapse a gh statusCheckRollup JSON array (stdin) to one token:
24
+ # FAIL (any failure/error/cancelled/timed_out) > PENDING (any in-flight) > PASS (any success) > NONE.
25
+ # Precedence is worst-first so a single red check is never hidden by green ones.
26
+ cap_checks_summary() {
27
+ command -v jq >/dev/null 2>&1 || { echo NONE; return 0; }
28
+ jq -r '
29
+ [ .[]? | (.conclusion // .state // "") | ascii_upcase ] as $c
30
+ | if ($c | any(. == "FAILURE" or . == "ERROR" or . == "CANCELLED" or . == "TIMED_OUT" or . == "ACTION_REQUIRED" or . == "STARTUP_FAILURE")) then "FAIL"
31
+ elif ($c | any(. == "PENDING" or . == "IN_PROGRESS" or . == "QUEUED" or . == "EXPECTED" or . == "WAITING" or . == "")) then "PENDING"
32
+ elif ($c | any(. == "SUCCESS" or . == "NEUTRAL" or . == "SKIPPED")) then "PASS"
33
+ else "NONE" end' 2>/dev/null || echo NONE
34
+ }
35
+
36
+ # cap_classify <mergeable> <mergeStateStatus> <checksSummary> — pure verdict for one PR.
37
+ # mergeable: MERGEABLE|CONFLICTING|UNKNOWN · mss: CLEAN|DIRTY|DRAFT|BLOCKED|BEHIND|UNSTABLE|…
38
+ cap_classify() {
39
+ local mergeable="$1" mss="$2" checks="$3"
40
+ case "$mss" in DRAFT) echo DRAFT; return 0 ;; esac
41
+ case "$mergeable" in CONFLICTING) echo CONFLICTING; return 0 ;; esac
42
+ case "$mss" in DIRTY) echo CONFLICTING; return 0 ;; esac
43
+ case "$checks" in
44
+ FAIL) echo CHECKS_FAILING; return 0 ;;
45
+ PENDING) echo CHECKS_PENDING; return 0 ;;
46
+ esac
47
+ case "$mergeable" in
48
+ MERGEABLE)
49
+ # passing or no required checks, and not draft/dirty/conflicting -> ready.
50
+ case "$mss" in CLEAN|UNSTABLE|HAS_HOOKS|"") echo CLEAN; return 0 ;; esac
51
+ echo BLOCKED; return 0 ;;
52
+ esac
53
+ echo BLOCKED
54
+ }
55
+
56
+ # cap_action <state> — the action the captain takes for a verdict.
57
+ cap_action() {
58
+ case "$1" in
59
+ CLEAN) echo merge ;;
60
+ CONFLICTING) echo rebase ;;
61
+ CHECKS_FAILING) echo fix ;;
62
+ CHECKS_PENDING) echo wait ;;
63
+ DRAFT) echo wait ;;
64
+ HELD) echo hold ;;
65
+ *) echo skip ;;
66
+ esac
67
+ }
68
+
69
+ # cap_policy_floor <files-newline> <labels-space> — echo a non-empty REASON when a PR must NOT be
70
+ # auto-merged by the captain (a policy floor tripped), else empty. Floors are DEFAULT ON so an
71
+ # unattended captain never lands a change a human must sign off on. They trip on:
72
+ # • a `hold` label (an explicit human stop)
73
+ # • any changed file under .github/workflows/** (CI/CD — a supply-chain surface)
74
+ # • lockfile / dependency-graph files: pnpm-lock.yaml, package.json, package-lock.json, yarn.lock,
75
+ # turbo.json, *-workspace.yaml/.yml
76
+ # • security-sensitive paths: *.pem, *.key, .env / .env.*, any secret(s) path segment
77
+ # Disable entirely with KIT_CAPTAIN_FLOORS=0 (or captain.mergePolicy.floors:false in config). Extend
78
+ # the protected set with KIT_CAPTAIN_EXTRA_GLOBS (space-separated case-globs). Draft state is honored
79
+ # separately by cap_classify (DRAFT -> wait). Pure — no gh; unit-tested. bash 3.2 / zsh safe.
80
+ cap_policy_floor() {
81
+ local files="$1" labels="$2" f g extra hit
82
+ [ "${KIT_CAPTAIN_FLOORS:-1}" = "0" ] && return 0
83
+ case " $labels " in *" hold "*) printf 'hold label'; return 0 ;; esac
84
+ extra="${KIT_CAPTAIN_EXTRA_GLOBS:-}"
85
+ while IFS= read -r f; do
86
+ [ -n "$f" ] || continue
87
+ case "$f" in
88
+ .github/workflows/*) printf 'workflow file (%s)' "$f"; return 0 ;;
89
+ esac
90
+ case "${f##*/}" in
91
+ pnpm-lock.yaml|package.json|package-lock.json|yarn.lock|turbo.json)
92
+ printf 'lockfile/graph (%s)' "$f"; return 0 ;;
93
+ *-workspace.yaml|*-workspace.yml)
94
+ printf 'workspace graph (%s)' "$f"; return 0 ;;
95
+ *.pem|*.key) printf 'security-sensitive (%s)' "$f"; return 0 ;;
96
+ .env|.env.*) printf 'security-sensitive (%s)' "$f"; return 0 ;;
97
+ esac
98
+ case "/$f/" in */secret/*|*/secrets/*) printf 'security-sensitive (%s)' "$f"; return 0 ;; esac
99
+ # Extra protected globs from config (space-separated). Split on spaces via a here-string (no
100
+ # subshell, so `return` still exits the function), and inline each glob into an eval'd case so it
101
+ # is a LITERAL pattern — matching identically under bash and zsh (a variable in a case pattern is
102
+ # treated literally by zsh, so `case $f in $g` would silently never match there).
103
+ if [ -n "$extra" ]; then
104
+ hit=""
105
+ while IFS= read -r g; do
106
+ [ -n "$g" ] || continue
107
+ eval "case \"\$f\" in ($g) hit=1 ;; esac"
108
+ [ -n "$hit" ] && break
109
+ done <<EOF2
110
+ $(printf '%s' "$extra" | tr ' ' '\n')
111
+ EOF2
112
+ [ -n "$hit" ] && { printf 'protected by config (%s)' "$f"; return 0; }
113
+ fi
114
+ done <<EOF
115
+ $files
116
+ EOF
117
+ return 0
118
+ }
119
+
120
+ # _cap_load_policy_config — bridge captain.mergePolicy from the kit config into the env the pure
121
+ # floor helper reads, so a project can override the floors declaratively. Env always wins (a value
122
+ # already set is left untouched). Best-effort: no config / no jq -> defaults (floors ON).
123
+ _cap_load_policy_config() {
124
+ command -v jq >/dev/null 2>&1 || return 0
125
+ local cfg="${KIT_CONFIG:-}"
126
+ [ -n "$cfg" ] || { [ -f cckit.config.json ] && cfg=cckit.config.json || cfg=.claude/kit.config.json; }
127
+ [ -f "$cfg" ] || return 0
128
+ if [ -z "${KIT_CAPTAIN_FLOORS:-}" ]; then
129
+ case "$(jq -r '.captain.mergePolicy.floors // empty' "$cfg" 2>/dev/null)" in
130
+ false) KIT_CAPTAIN_FLOORS=0 ;; true) KIT_CAPTAIN_FLOORS=1 ;;
131
+ esac
132
+ fi
133
+ if [ -z "${KIT_CAPTAIN_EXTRA_GLOBS:-}" ]; then
134
+ KIT_CAPTAIN_EXTRA_GLOBS="$(jq -r '(.captain.mergePolicy.protectedGlobs // []) | join(" ")' "$cfg" 2>/dev/null || echo "")"
135
+ fi
136
+ export KIT_CAPTAIN_FLOORS KIT_CAPTAIN_EXTRA_GLOBS
137
+ }
138
+
139
+ # _cap_issue_of_branch <branch> — issue number a flow branch encodes (task/47-x, fix/9-y, effort/12-z).
140
+ _cap_issue_of_branch() {
141
+ printf '%s' "$1" | sed -nE 's#^[a-z]+/([0-9]+)-.*#\1#p'
142
+ }
143
+
144
+ # captain_gate <pr#> — fetch + classify one PR. Echoes
145
+ # "pr<TAB>issue<TAB>state<TAB>action<TAB>title<TAB>reason". A CLEAN PR that trips a policy floor
146
+ # (cap_policy_floor) is downgraded to HELD/hold so the captain never auto-merges it; `reason` carries
147
+ # the floor that tripped (empty otherwise).
148
+ captain_gate() {
149
+ local repo="$CAPTAIN_REPO" pr="$1" j mergeable mss checks issue state action title branch files labels reason
150
+ j="$(gh pr view "$pr" --repo "$repo" --json number,title,headRefName,mergeable,mergeStateStatus,statusCheckRollup,files,labels 2>/dev/null)" \
151
+ || { echo "captain: cannot read PR #$pr" >&2; return 1; }
152
+ mergeable="$(printf '%s' "$j" | jq -r '.mergeable // "UNKNOWN"')"
153
+ mss="$(printf '%s' "$j" | jq -r '.mergeStateStatus // "UNKNOWN"')"
154
+ checks="$(printf '%s' "$j" | jq -c '.statusCheckRollup // []' | cap_checks_summary)"
155
+ branch="$(printf '%s' "$j" | jq -r '.headRefName // ""')"
156
+ title="$(printf '%s' "$j" | jq -r '.title // ""')"
157
+ files="$(printf '%s' "$j" | jq -r '.files[]?.path // empty')"
158
+ labels="$(printf '%s' "$j" | jq -r '[.labels[]?.name] | join(" ")')"
159
+ issue="$(_cap_issue_of_branch "$branch")"
160
+ state="$(cap_classify "$mergeable" "$mss" "$checks")"
161
+ action="$(cap_action "$state")"
162
+ reason=""
163
+ # Policy floor: only a would-be merge is at risk, so gate only the CLEAN/merge verdict.
164
+ if [ "$action" = "merge" ]; then
165
+ reason="$(cap_policy_floor "$files" "$labels")"
166
+ [ -n "$reason" ] && { state="HELD"; action="hold"; }
167
+ fi
168
+ printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$pr" "${issue:-—}" "$state" "$action" "$title" "$reason"
169
+ }
170
+
171
+ # _cap_open_prs [effort] — open PR numbers, optionally only those whose branch-issue is a sub of <effort>.
172
+ _cap_open_prs() {
173
+ local repo="$CAPTAIN_REPO" effort="${1:-}"
174
+ if [ -n "$effort" ]; then
175
+ local subs; subs="$(gh api "repos/$repo/issues/$effort/sub_issues" --paginate --jq '.[].number' 2>/dev/null | tr '\n' ' ')"
176
+ local pr br iss
177
+ gh pr list --repo "$repo" --state open --json number,headRefName \
178
+ --jq '.[] | "\(.number)\t\(.headRefName)"' 2>/dev/null | while IFS="$(printf '\t')" read -r pr br; do
179
+ iss="$(_cap_issue_of_branch "$br")"
180
+ case " $subs " in *" $iss "*) printf '%s\n' "$pr" ;; esac
181
+ done
182
+ else
183
+ gh pr list --repo "$repo" --state open --json number --jq '.[].number' 2>/dev/null
184
+ fi
185
+ }
186
+
187
+ # captain_pass [--merge] [--effort N] — gate every open PR (in scope); merge the CLEAN ones if asked.
188
+ # Returns the count of PRs merged this pass via the CAPTAIN_MERGED global (for the loop to detect progress).
189
+ CAPTAIN_MERGED=0
190
+ captain_pass() {
191
+ command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || { echo "captain: needs gh + jq" >&2; return 1; }
192
+ local repo="$CAPTAIN_REPO" do_merge=0 effort="" dry=0
193
+ while [ "$#" -gt 0 ]; do
194
+ case "$1" in
195
+ --merge) do_merge=1; shift ;;
196
+ --dry-run) dry=1; shift ;;
197
+ --effort) effort="$2"; shift 2 ;;
198
+ --effort=*) effort="${1#*=}"; shift ;;
199
+ *) echo "captain_pass: unknown arg '$1'" >&2; return 2 ;;
200
+ esac
201
+ done
202
+ [ -n "$repo" ] || { echo "captain: no repo (set KIT_REPO / CAPTAIN_REPO)" >&2; return 1; }
203
+ CAPTAIN_MERGED=0
204
+ _cap_load_policy_config # bridge captain.mergePolicy from config into the floor env (env wins)
205
+
206
+ local prs pr row state action issue title reason merged_any=0
207
+ prs="$(_cap_open_prs "$effort")"
208
+ [ -n "$prs" ] || { echo "captain: no open PRs in scope"; return 0; }
209
+
210
+ : > "$CAPTAIN_STATE" 2>/dev/null || true
211
+ echo "captain: gating $(printf '%s\n' "$prs" | grep -c .) open PR(s)$( [ -n "$effort" ] && echo " for effort #$effort")"
212
+ for pr in $prs; do
213
+ row="$(captain_gate "$pr")" || continue
214
+ state="$(printf '%s' "$row" | cut -f3)"
215
+ action="$(printf '%s' "$row" | cut -f4)"
216
+ issue="$(printf '%s' "$row" | cut -f2)"
217
+ title="$(printf '%s' "$row" | cut -f5)"
218
+ reason="$(printf '%s' "$row" | cut -f6)"
219
+ printf '%s\t%s\n' "$pr" "$state" >> "$CAPTAIN_STATE" 2>/dev/null || true
220
+ if [ "$action" = "merge" ] && [ "$do_merge" = "1" ] && [ "$dry" = "0" ]; then
221
+ if gh pr merge "$pr" --repo "$repo" --squash --delete-branch >/dev/null 2>&1; then
222
+ printf ' PR #%-4s %-14s MERGED (#%s %s)\n' "$pr" "$state" "$issue" "$title"
223
+ merged_any=$((merged_any + 1))
224
+ else
225
+ printf ' PR #%-4s %-14s merge FAILED (re-check) (#%s %s)\n' "$pr" "$state" "$issue" "$title"
226
+ fi
227
+ elif [ "$action" = "hold" ]; then
228
+ printf ' PR #%-4s %-14s -> HELD (#%s %s) — policy floor: %s [human review; C overrides]\n' \
229
+ "$pr" "$state" "$issue" "$title" "${reason:-protected}"
230
+ else
231
+ printf ' PR #%-4s %-14s -> %-7s (#%s %s)\n' "$pr" "$state" "$action" "$issue" "$title"
232
+ fi
233
+ done
234
+ CAPTAIN_MERGED="$merged_any"
235
+
236
+ # advance: after merges, the newly-unblocked work shows up as the next wave.
237
+ if [ "$merged_any" -gt 0 ]; then
238
+ echo "captain: merged $merged_any — next unblocked wave:"
239
+ local here; here="$(dirname "${BASH_SOURCE[0]}")"
240
+ if [ -f "$here/plan-machine.sh" ]; then
241
+ # shellcheck source=/dev/null
242
+ . "$here/plan-machine.sh"
243
+ if [ -n "$effort" ]; then CCKIT_OUTPUT=human plan_machine --effort "$effort" 2>/dev/null || true
244
+ else CCKIT_OUTPUT=human plan_machine 2>/dev/null || true; fi
245
+ fi
246
+ fi
247
+ }
248
+
249
+ # captain_loop — repeat passes until a pass merges nothing (steady state) or --max-passes is hit.
250
+ # Checkpointed: each pass overwrites CAPTAIN_STATE so a fresh invocation resumes from the live board.
251
+ captain_loop() {
252
+ local max=10 pass=0
253
+ local -a clean=()
254
+ while [ "$#" -gt 0 ]; do
255
+ case "$1" in
256
+ --max-passes) max="$2"; shift 2 ;;
257
+ --max-passes=*) max="${1#*=}"; shift ;;
258
+ *) clean+=("$1"); shift ;;
259
+ esac
260
+ done
261
+ case "$max" in ''|*[!0-9]*) max=10 ;; esac
262
+ while [ "$pass" -lt "$max" ]; do
263
+ pass=$((pass + 1))
264
+ echo "── captain pass $pass/$max ──"
265
+ captain_pass "${clean[@]+"${clean[@]}"}" || return 1
266
+ [ "$CAPTAIN_MERGED" -gt 0 ] || { echo "captain: steady state (no CLEAN PR merged) — stopping at pass $pass"; break; }
267
+ done
268
+ }
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # config-path-test.sh — covers the ONE shared config-path resolver (#69): kit_config_find (pure walk)
4
+ # and kit_config_path (KIT_CONFIG wins, else walk). Every kit entrypoint discovers the project config
5
+ # through these. Hermetic: throwaway dirs. Run: bash scripts/lib/config-path-test.sh
6
+ set -u
7
+ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
8
+ LIB="$ROOT/scripts/lib"
9
+ fail=0
10
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
11
+ rc() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> rc '$2' want '$3'"; fail=1; fi; }
12
+
13
+ # shellcheck source=/dev/null
14
+ . "$LIB/config-path.sh"
15
+
16
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
17
+
18
+ # A) root cckit.config.json (self-host / current layout)
19
+ mkdir -p "$tmp/a"; printf '{}' > "$tmp/a/cckit.config.json"
20
+ t "finds a root cckit.config.json" "$(kit_config_find "$tmp/a")" "$tmp/a/cckit.config.json"
21
+
22
+ # B) scaffolded .claude/kit.config.json
23
+ mkdir -p "$tmp/b/.claude"; printf '{}' > "$tmp/b/.claude/kit.config.json"
24
+ t "finds a scaffolded .claude/kit.config.json" "$(kit_config_find "$tmp/b")" "$tmp/b/.claude/kit.config.json"
25
+
26
+ # C) cckit.config.json wins over .claude/kit.config.json in the same dir
27
+ mkdir -p "$tmp/c/.claude"; printf '{}' > "$tmp/c/cckit.config.json"; printf '{}' > "$tmp/c/.claude/kit.config.json"
28
+ t "root cckit.config.json wins over .claude/" "$(kit_config_find "$tmp/c")" "$tmp/c/cckit.config.json"
29
+
30
+ # D) walk up: a nested start dir resolves an ancestor's config
31
+ mkdir -p "$tmp/a/deep/nested"
32
+ t "walks up to an ancestor config" "$(kit_config_find "$tmp/a/deep/nested")" "$tmp/a/cckit.config.json"
33
+
34
+ # E) no config anywhere in the (isolated) tree -> rc 1, empty
35
+ mkdir -p "$tmp/empty"
36
+ out="$(kit_config_find "$tmp/empty" 2>/dev/null)"; r=$?
37
+ # (mktemp lives under /var|/tmp with no ancestor kit config, so this is a clean miss)
38
+ rc "no config -> rc 1" "$r" "1"
39
+ t "no config -> empty output" "$out" ""
40
+
41
+ # F) kit_config_path: an explicit KIT_CONFIG always wins, regardless of the start dir
42
+ t "KIT_CONFIG wins in kit_config_path" "$(KIT_CONFIG=/explicit/override.json kit_config_path "$tmp/a")" "/explicit/override.json"
43
+ # without KIT_CONFIG, kit_config_path delegates to the walk
44
+ t "kit_config_path walks when KIT_CONFIG unset" "$(KIT_CONFIG= kit_config_path "$tmp/b")" "$tmp/b/.claude/kit.config.json"
45
+
46
+ [ "$fail" -eq 0 ] && echo "ALL OK (config-path)" || echo "config-path: FAILURES"
47
+ exit "$fail"
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # config-path.sh — the ONE project-config-path resolver (#69). Every kit entrypoint discovers the
4
+ # project config the SAME way instead of re-deriving it inline: an explicit KIT_CONFIG always wins,
5
+ # otherwise walk up from a start dir for a root `cckit.config.json` (self-host / current layout) or a
6
+ # `.claude/kit.config.json` (scaffolded layout). Dependency-free pure shell (no jq, no other kit
7
+ # libs) so it is safe to source from anywhere — including bin/cckit before anything else loads.
8
+ # bash 3.2 + zsh compatible.
9
+ #
10
+ # kit_config_find <startdir> walk startdir -> / for a project config; prints path (rc 0) or rc 1.
11
+ # Ignores KIT_CONFIG — a pure "is <dir> under a kit project?" answer.
12
+ # kit_config_path [startdir] KIT_CONFIG wins, else kit_config_find; prints path (rc 0) or rc 1.
13
+
14
+ kit_config_find() {
15
+ local d="${1:-$PWD}"
16
+ d="$(cd "$d" 2>/dev/null && pwd)" || return 1
17
+ while [ -n "$d" ]; do
18
+ [ -f "$d/cckit.config.json" ] && { printf '%s\n' "$d/cckit.config.json"; return 0; }
19
+ [ -f "$d/.claude/kit.config.json" ] && { printf '%s\n' "$d/.claude/kit.config.json"; return 0; }
20
+ [ "$d" = "/" ] && break
21
+ d="$(dirname "$d")"
22
+ done
23
+ return 1
24
+ }
25
+
26
+ kit_config_path() {
27
+ if [ -n "${KIT_CONFIG:-}" ]; then printf '%s\n' "$KIT_CONFIG"; return 0; fi
28
+ kit_config_find "${1:-$PWD}"
29
+ }
@@ -0,0 +1,30 @@
1
+ #!/bin/sh
2
+ # copilot-test.sh — self-test for copilot.sh pure helper under bash AND zsh.
3
+ # Network-free: covers the subagent seed composer only (the gh/plan-driven copilot_brief is not
4
+ # exercised). Run: bash scripts/lib/copilot-test.sh
5
+
6
+ dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
7
+
8
+ if [ -n "${CP_TEST_INNER:-}" ]; then
9
+ . "$dir/copilot.sh"
10
+ fail=0
11
+ has() { case "$2" in *"$3"*) ;; *) echo "FAIL($CP_TEST_INNER): $1 missing '[$3]'"; fail=1 ;; esac; }
12
+
13
+ seed="$(_copilot_seed 42 'wire the thing')"
14
+ has "seed has issue view" "$seed" 'gh issue view 42'
15
+ has "seed has title" "$seed" 'implement "wire the thing"'
16
+ has "seed has pr verb" "$seed" 'cckit pr 42'
17
+ has "seed has close verb" "$seed" 'cckit close 42'
18
+ has "seed has check gate" "$seed" 'bash scripts/check.sh'
19
+ has "seed forbids asking" "$seed" 'never ask'
20
+
21
+ if [ "$fail" -eq 0 ]; then echo "PASS($CP_TEST_INNER): copilot seed composer"; fi
22
+ exit "$fail"
23
+ fi
24
+
25
+ rc=0
26
+ for sh in bash zsh; do
27
+ command -v "$sh" >/dev/null 2>&1 || continue
28
+ CP_TEST_INNER="$sh" "$sh" "$0" || rc=1
29
+ done
30
+ exit "$rc"
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env bash
2
+ # copilot.sh — the copilot driver: turn the wave plan into a fan-out BRIEF that Claude Code enacts
3
+ # (Effort 75 · #78). This is cckit's prompt machine.
4
+ #
5
+ # The orchestration brain is the driving agent, not a background launcher. So the copilot does not
6
+ # spawn anything itself — it EMITS the plan-as-instructions: for the current wave, a ready-to-run
7
+ # Task-subagent prompt per issue (worktree-isolated, background), and the between-waves drive (gate +
8
+ # merge with the captain, then re-run for the next wave). The agent reads the brief and acts.
9
+ #
10
+ # cckit wave brief for the open board: wave 0 fan-out + the loop
11
+ # cckit wave --effort <N> brief scoped to effort #N's sub-issues
12
+ # cckit wave --cap <K> session ctx budget per wave (passed to the plan machine)
13
+ # cckit wave --llm the fan-out as TOON rows (wave,number,ctx,prompt) for an agent
14
+ #
15
+ # Requires: gh, jq (via the plan machine). bash 3.2 / zsh compatible.
16
+
17
+ COPILOT_REPO="${COPILOT_REPO:-${KIT_REPO:-}}"
18
+
19
+ # _copilot_seed <num> <title> — the headless subagent prompt for one issue (worktree already isolated).
20
+ _copilot_seed() {
21
+ local num="$1" title="$2"
22
+ printf 'You are a Task subagent in a cckit wave run — NO human is present, so never ask: decide autonomously and apply effort proportional to the task. Your worktree and branch for issue #%s are already isolated. Do: `gh issue view %s`, implement "%s", run `bash scripts/check.sh` until green, then open the PR with `cckit pr %s "<summary>"`. If it is a no-op, run `cckit close %s "<reason>"` with why. Return a one-line result.' \
23
+ "$num" "$num" "$title" "$num" "$num"
24
+ }
25
+
26
+ copilot_brief() {
27
+ command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || { echo "copilot: needs gh + jq" >&2; return 1; }
28
+ local repo="$COPILOT_REPO" out="${CCKIT_OUTPUT:-human}" effort="" cap="" planargs=()
29
+ while [ "$#" -gt 0 ]; do
30
+ case "$1" in
31
+ --llm|--output=json) out="json"; shift ;;
32
+ --effort) effort="$2"; planargs+=(--effort "$2"); shift 2 ;;
33
+ --effort=*) effort="${1#*=}"; planargs+=(--effort "${1#*=}"); shift ;;
34
+ --cap) cap="$2"; planargs+=(--cap "$2"); shift 2 ;;
35
+ --cap=*) cap="${1#*=}"; planargs+=(--cap "${1#*=}"); shift ;;
36
+ -h|--help) sed -n '13,17p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; return 0 ;;
37
+ *) echo "copilot: unknown arg '$1'" >&2; return 2 ;;
38
+ esac
39
+ done
40
+ [ -n "$repo" ] || { echo "copilot: no repo (set KIT_REPO / COPILOT_REPO)" >&2; return 1; }
41
+
42
+ # pull the wave plan as raw rows from the plan machine (#76).
43
+ local here; here="$(dirname "${BASH_SOURCE[0]}")"
44
+ # shellcheck source=/dev/null
45
+ . "$here/plan-machine.sh"
46
+ local rows
47
+ rows="$(CCKIT_OUTPUT=tsv plan_machine "${planargs[@]+"${planargs[@]}"}" 2>/dev/null)"
48
+ if [ -z "$rows" ]; then
49
+ [ "$out" = "json" ] && echo "[]" || echo "wave: nothing to drive (no open issues in scope)"
50
+ return 0
51
+ fi
52
+
53
+ # wave 0 = the issues to fan out right now (everything currently unblocked).
54
+ local wave0; wave0="$(printf '%s\n' "$rows" | awk -F'\t' '$1==0')"
55
+ local waves_total; waves_total="$(printf '%s\n' "$rows" | awk -F'\t' '{print $1}' | sort -nu | tail -1)"
56
+
57
+ if [ "$out" = "json" ]; then
58
+ # TOON rows {wave,number,ctx,prompt} — the fan-out as token-cheap agent input.
59
+ local json
60
+ json="$(printf '%s\n' "$wave0" | awk -F'\t' '{print $3"\t"$4"\t"$6}' \
61
+ | while IFS="$(printf '\t')" read -r num ctx title; do
62
+ [ -n "$num" ] || continue
63
+ disp="$(printf '%s' "$title" | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
64
+ printf '%s\t%s\t%s\n' "$num" "$ctx" "$(_copilot_seed "$num" "$disp")"
65
+ done \
66
+ | jq -R -s '[ split("\n")[] | select(length>0) | split("\t")
67
+ | {wave:0, number:(.[0]|tonumber), ctx:.[1], prompt:.[2]} ]')"
68
+ # shellcheck source=/dev/null
69
+ . "$here/toon.sh"
70
+ printf '%s' "$json" | toon_encode
71
+ return 0
72
+ fi
73
+
74
+ # human brief — markdown the agent enacts, routed through the rendering seam (#82): rich via glow
75
+ # in a TTY, verbatim markdown otherwise (renders natively in Claude Code, pipe-safe).
76
+ # shellcheck source=/dev/null
77
+ . "$here/render.sh"
78
+ local n0 esfx; n0="$(printf '%s\n' "$wave0" | grep -c .)"
79
+ esfx="$([ -n "$effort" ] && echo " --effort $effort")"
80
+ {
81
+ printf '# cckit wave — %s%s\n' "$repo" "$([ -n "$effort" ] && echo " · effort #$effort")"
82
+ printf '\nThe plan machine laid out %s wave(s). You are the orchestrator: fan wave 0 out as parallel\nTask subagents, gate + merge with the captain, then re-run this brief for the next wave.\n' "$((waves_total + 1))"
83
+
84
+ printf '\n## Wave 0 — spawn %s parallel Task subagent(s)\n\n' "$n0"
85
+ printf 'Each in its OWN worktree (Task isolation: "worktree", run in background). Branches are\nfile-disjoint within a wave, so they will not collide.\n\n'
86
+ printf '%s\n' "$wave0" | awk -F'\t' '{print $3"\t"$4"\t"$6}' \
87
+ | while IFS="$(printf '\t')" read -r num ctx title; do
88
+ [ -n "$num" ] || continue
89
+ disp="$(printf '%s' "$title" | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
90
+ printf '### #%s · [%s] · %s\n\n' "$num" "$ctx" "$disp"
91
+ printf '> %s\n\n' "$(_copilot_seed "$num" "$disp")"
92
+ done
93
+
94
+ printf '## Between waves — drive the captain\n\n'
95
+ printf '1. When the wave-0 subagents have opened their PRs, gate + merge them:\n'
96
+ printf ' ```\n cckit watch --merge%s\n ```\n' "$esfx"
97
+ printf '2. Merging unblocks the next wave. Re-run this brief to get it:\n'
98
+ printf ' ```\n cckit wave%s\n ```\n' "$esfx"
99
+ printf '3. Repeat until `cckit wave` reports nothing to drive. To let the captain self-pace the\n gate/merge passes, use `cckit watch --loop` (or drive this brief under `/loop`).\n\n'
100
+ } | cckit_render
101
+ }