@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
@@ -1,21 +1,23 @@
1
1
  #!/usr/bin/env bash
2
2
  # shellcheck shell=bash
3
- # gh-rest.sh — the GitHub transport switch and the REST forms of the lifecycle calls (#396).
3
+ # gh-rest.sh — the REST forms of the lifecycle calls, over the forge port (E537.3; #396 before it).
4
4
  #
5
- # Cloud agent sessions reach GitHub through a proxy that refuses every GraphQL request (403), and
6
- # `gh pr …` / `gh issue …` are GraphQL underneath. REST calls to the attached repo still work. So the
7
- # lifecycle verbs (pr, merge, close, new, effort new|pr|close) pick a transport here:
5
+ # Every call here is `forge_rest repos/<owner>/<repo>/…` (scripts/lib/forge.sh), endpoint first: REST
6
+ # over curl with a token, no gh subcommand. REST is the ONLY transport now — the gh-subcommand
7
+ # (GraphQL) transport of #396 is gone, so `cckit_gh_rest` is always true and `CCKIT_GH_TRANSPORT`
8
+ # does nothing but warn once. What still depends on where cckit runs is GraphQL itself: a cloud
9
+ # agent session reaches GitHub through a proxy that refuses it (403), and Projects v2 is GraphQL-only,
10
+ # so the board moves over the Projects v2 REST endpoints first (E546.7, gh_rest_board_* below) and
11
+ # GraphQL is only the fallback; where GraphQL is unavailable too, a board step that REST could not
12
+ # serve is skipped with ONE notice line (exit 0, never a failure). With the forge provider `none`
13
+ # every board step is skipped the same way.
8
14
  #
9
- # CCKIT_GH_TRANSPORT=rest|graphql forces it
10
- # CLAUDE_CODE_REMOTE=true defaults it to rest (a cloud session)
11
- # otherwise graphql — the gh subcommands, unchanged
12
- #
13
- # In rest mode every call is `gh api repos/<owner>/<repo>/…`, endpoint first. Projects v2 is
14
- # GraphQL-only, so board steps are skipped with ONE notice line (exit 0, never a failure).
15
- #
16
- # cckit_gh_rest rc 0 iff the transport is rest
17
- # cckit_gh_transport echo rest|graphql
18
- # cckit_board_skipped rc 0 iff board steps are skipped (prints the notice once)
15
+ # cckit_gh_rest rc 0 (kept for callers; REST is the only transport)
16
+ # cckit_gh_transport echo rest
17
+ # cckit_board_skipped rc 0 iff board steps are skipped (prints the notice once): no
18
+ # forge, or GraphQL off with KIT_OWNER/KIT_PROJECT_NUMBER unset
19
+ # cckit_graphql_off rc 0 iff GraphQL is unavailable: CLAUDE_CODE_REMOTE=true or CCKIT_GRAPHQL=0
20
+ # cckit_board_graphql_notice the GraphQL-unavailable board notice, once per process
19
21
  # gh_rest_closing_refs stdin: a PR body → the issue #s it closes (pure)
20
22
  # gh_rest_issue_json <repo> <n> {number,title,body,state,labels[{name}],milestone{title,number}}
21
23
  # gh_rest_issue_state <repo> <n> OPEN | CLOSED
@@ -25,6 +27,11 @@
25
27
  # gh_rest_issue_set_body <repo> <n> <body>
26
28
  # gh_rest_issue_add_labels <repo> <n> <labels-csv>
27
29
  # gh_rest_label_create <repo> <name> <color> <description> (idempotent)
30
+ # gh_rest_label_upsert <repo> <name> <color> <description> → created|updated (the --force form)
31
+ # gh_rest_issue_comment <repo> <n> <body|@file> → html_url (PRs too)
32
+ # gh_rest_issue_comments <repo> <n> every comment body
33
+ # gh_rest_pr_url_for_head <repo> <branch> the open PR's url, or empty
34
+ # gh_rest_repo_default_branch <repo> · gh_rest_user_login
28
35
  # gh_rest_milestone_number <repo> <title>
29
36
  # gh_rest_pr_create <repo> <base> <head> <title> <body> <labels-csv> [milestone-title] → html_url
30
37
  # gh_rest_pr_for_head <repo> <branch> the open PR number for a head branch
@@ -39,41 +46,75 @@
39
46
  # gh_rest_issue_closing_prs <repo> <n> merged PRs that close <n> by keyword (timeline)
40
47
  # gh_rest_wave_rows <repo> <parent> "sub|STATE|pr|merge-sha|pr-title" per sub (wave close)
41
48
  #
42
- # Not reachable over REST in the cloud: Projects v2 (skipped), and remote branch deletion (the proxy
43
- # rejects DELETE git/refs) — callers keep the branch and say so.
44
- # bash 3.2 + zsh compatible. Requires gh, jq.
49
+ # gh_rest_board_base <owner-type> <owner> <number> orgs/<o>/projectsV2/<n> | users/<o>/projectsV2/<n>
50
+ # gh_rest_board_project <base> {id,node_id,number,title}
51
+ # gh_rest_board_fields <base> [{id,node_id,name,data_type,options[{id,name}],iterations[{id,title,start_date}]}]
52
+ # gh_rest_board_ids_env <base> the scripts/.project-ids.env lines, read over REST
53
+ # gh_rest_board_find_item <base> <Issue|PullRequest> <repo> <n> "<item id>:<item node id>", empty when not on the board
54
+ # gh_rest_board_find_issue_item <base> <repo> <n> the same, for an issue
55
+ # gh_rest_board_add_item <base> <Issue|PullRequest> <repo> <n> "<item id>:<item node id>"
56
+ # gh_rest_board_set_field <base> <item id> <field id|node id> <single_select|iteration|text> <value>
57
+ # (board rc: 0 ok · 3 REST cannot serve it, the caller may fall back to GraphQL · 1 any other error)
58
+ #
59
+ # Not reachable in the cloud: GraphQL (so the board's GraphQL fallback), and remote branch deletion
60
+ # (the proxy rejects DELETE git/refs) — callers keep the branch and say so.
61
+ # bash 3.2 + zsh compatible. Requires jq.
45
62
  # errors: mixed — creates, closes and merges propagate; labels/milestone/assignee are best-effort
63
+ _ghr_self="${BASH_SOURCE[0]:-$0}"
64
+ if ! command -v forge_rest >/dev/null 2>&1; then
65
+ # shellcheck source=/dev/null
66
+ . "$(cd "$(dirname "$_ghr_self")" && pwd)/forge.sh"
67
+ fi
68
+ unset _ghr_self
69
+
70
+ # _ghr_api <endpoint> [_ghr_api flags…] — the forge, loaded on first use. A `none` provider refuses
71
+ # here with one line naming the verb (forge_need), rc 1.
72
+ _ghr_api() { forge_load || return 1; forge_rest "$@"; }
46
73
 
47
74
  CCKIT_BOARD_SKIP_NOTICE="cckit: board step skipped (GraphQL unavailable; the project's built-in workflows move the card)"
75
+ CCKIT_BOARD_SKIP_NOTICE_NOFORGE="cckit: board step skipped (no forge is configured; see forge.provider)"
48
76
 
49
- # rc 0 iff the transport is rest. An unknown CCKIT_GH_TRANSPORT warns once and falls to the default.
77
+ # REST is the only transport (E537.3). CCKIT_GH_TRANSPORT is read only to say so, once.
50
78
  cckit_gh_rest() {
51
- case "${CCKIT_GH_TRANSPORT:-}" in
52
- rest) return 0 ;;
53
- graphql) return 1 ;;
54
- '') : ;;
55
- *)
56
- if [ -z "${_CCKIT_TRANSPORT_WARNED:-}" ]; then
57
- printf "cckit: CCKIT_GH_TRANSPORT must be rest or graphql (got '%s') — using the default\n" \
58
- "$CCKIT_GH_TRANSPORT" >&2
59
- _CCKIT_TRANSPORT_WARNED=1
60
- fi ;;
61
- esac
62
- [ "${CLAUDE_CODE_REMOTE:-}" = "true" ]
79
+ if [ -n "${CCKIT_GH_TRANSPORT:-}" ] && [ -z "${_CCKIT_TRANSPORT_WARNED:-}" ]; then
80
+ printf 'cckit: CCKIT_GH_TRANSPORT is ignored — every GitHub call is REST over the forge (forge.provider)\n' >&2
81
+ _CCKIT_TRANSPORT_WARNED=1
82
+ fi
83
+ return 0
63
84
  }
64
85
 
65
- cckit_gh_transport() {
66
- if cckit_gh_rest; then printf 'rest'; else printf 'graphql'; fi
67
- }
86
+ cckit_gh_transport() { cckit_gh_rest; printf 'rest'; }
68
87
 
69
- # rc 0 when board steps are skipped (rest mode). Prints the notice at most once per process.
70
- cckit_board_skipped() {
71
- cckit_gh_rest || return 1
88
+ # rc 0 in a cloud agent session, where the proxy also rejects remote branch deletion (#396).
89
+ cckit_in_cloud() { [ "${CLAUDE_CODE_REMOTE:-}" = "true" ]; }
90
+
91
+ # rc 0 when GraphQL is unavailable: a cloud session (the proxy answers 403) or CCKIT_GRAPHQL=0.
92
+ # The board still moves over REST there; only its GraphQL fallback is gone.
93
+ cckit_graphql_off() { [ "${CLAUDE_CODE_REMOTE:-}" = "true" ] || [ "${CCKIT_GRAPHQL:-1}" = "0" ]; }
94
+
95
+ _cckit_board_notice() {
72
96
  if [ -z "${_CCKIT_BOARD_NOTICE_DONE:-}" ]; then
73
- printf '%s\n' "$CCKIT_BOARD_SKIP_NOTICE" >&2
97
+ printf '%s\n' "$1" >&2
74
98
  _CCKIT_BOARD_NOTICE_DONE=1
75
99
  fi
76
- return 0
100
+ }
101
+
102
+ # The notice for a board step REST could not serve where GraphQL is unavailable. Once per process.
103
+ cckit_board_graphql_notice() { _cckit_board_notice "$CCKIT_BOARD_SKIP_NOTICE"; }
104
+
105
+ # rc 0 when board steps are skipped outright: no forge is configured, or GraphQL is unavailable and
106
+ # REST cannot name the board (KIT_OWNER or KIT_PROJECT_NUMBER unset). Prints the notice at most once
107
+ # per process. A cloud session with both set is not a skip: the board moves over REST (E546.7).
108
+ cckit_board_skipped() {
109
+ if command -v forge_available >/dev/null 2>&1 && ! forge_available; then
110
+ _cckit_board_notice "$CCKIT_BOARD_SKIP_NOTICE_NOFORGE"
111
+ return 0
112
+ fi
113
+ if cckit_graphql_off && { [ -z "${KIT_OWNER:-}" ] || [ -z "${KIT_PROJECT_NUMBER:-}" ]; }; then
114
+ _cckit_board_notice "$CCKIT_BOARD_SKIP_NOTICE"
115
+ return 0
116
+ fi
117
+ return 1
77
118
  }
78
119
 
79
120
  # --- pure ----------------------------------------------------------------------------------------
@@ -95,11 +136,11 @@ _ghr_array_args() {
95
136
  done
96
137
  }
97
138
 
98
- # `gh api …` for a read. On failure gh prints the error JSON to stdout and skips --jq, so the output
99
- # is kept only on rc 0: a failed read is no data (rc 1), never an error body taken as a value.
139
+ # A read. The output is kept only on rc 0: a failed read is no data (rc 1), never an error body
140
+ # taken as a value.
100
141
  _ghr_read() {
101
142
  local out
102
- out="$(gh api "$@")" || return 1
143
+ out="$(_ghr_api "$@")" || return 1
103
144
  [ -n "$out" ] && printf '%s\n' "$out"
104
145
  return 0
105
146
  }
@@ -138,14 +179,14 @@ EOF
138
179
  if [ -n "$msnum" ]; then set -- "$@" -F "milestone=$msnum"
139
180
  else echo "cckit: milestone '$ms' not found in $repo — issue created without it" >&2; fi
140
181
  fi
141
- out="$(gh api "repos/$repo/issues" -X POST "$@" \
182
+ out="$(_ghr_api "repos/$repo/issues" -X POST "$@" \
142
183
  --jq '"\(.number)\t\(.html_url)\t\(.user.login // "")"')" || return 1
143
184
  IFS="$tab" read -r num url login <<EOF
144
185
  $out
145
186
  EOF
146
187
  [ -n "$num" ] || return 1
147
188
  if [ "$assign" = 1 ] && [ -n "$login" ]; then
148
- gh api "repos/$repo/issues/$num/assignees" -X POST -f "assignees[]=$login" >/dev/null 2>&1 \
189
+ _ghr_api "repos/$repo/issues/$num/assignees" -X POST -f "assignees[]=$login" >/dev/null 2>&1 \
149
190
  || echo "cckit: #$num created but not assigned to $login" >&2
150
191
  fi
151
192
  printf '%s\n' "$url"
@@ -157,17 +198,17 @@ gh_rest_issue_close() {
157
198
  local repo="$1" n="$2" reason="${3:-completed}" comment="${4:-}"
158
199
  reason="$(printf '%s' "$reason" | tr ' -' '__')"
159
200
  if [ -n "$comment" ]; then
160
- gh api "repos/$repo/issues/$n/comments" -X POST -f "body=$comment" >/dev/null || return 1
201
+ _ghr_api "repos/$repo/issues/$n/comments" -X POST -f "body=$comment" >/dev/null || return 1
161
202
  fi
162
- gh api "repos/$repo/issues/$n" -X PATCH -f state=closed -f "state_reason=$reason" >/dev/null
203
+ _ghr_api "repos/$repo/issues/$n" -X PATCH -f state=closed -f "state_reason=$reason" >/dev/null
163
204
  }
164
205
 
165
206
  gh_rest_issue_edit_title() {
166
- gh api "repos/$1/issues/$2" -X PATCH -f "title=$3" >/dev/null
207
+ _ghr_api "repos/$1/issues/$2" -X PATCH -f "title=$3" >/dev/null
167
208
  }
168
209
 
169
210
  gh_rest_issue_set_body() {
170
- gh api "repos/$1/issues/$2" -X PATCH -f "body=$3" >/dev/null
211
+ _ghr_api "repos/$1/issues/$2" -X PATCH -f "body=$3" >/dev/null
171
212
  }
172
213
 
173
214
  gh_rest_issue_add_labels() {
@@ -177,12 +218,12 @@ gh_rest_issue_add_labels() {
177
218
  $(_ghr_array_args labels "$labels")
178
219
  EOF
179
220
  [ $# -gt 0 ] || return 0
180
- gh api "repos/$repo/issues/$n/labels" -X POST "$@" >/dev/null
221
+ _ghr_api "repos/$repo/issues/$n/labels" -X POST "$@" >/dev/null
181
222
  }
182
223
 
183
224
  # Idempotent: an existing label answers 422, which is fine.
184
225
  gh_rest_label_create() {
185
- gh api "repos/$1/labels" -X POST -f "name=$2" -f "color=$3" -f "description=$4" >/dev/null 2>&1 || true
226
+ _ghr_api "repos/$1/labels" -X POST -f "name=$2" -f "color=$3" -f "description=$4" >/dev/null 2>&1 || true
186
227
  }
187
228
 
188
229
  # Every label name in the repo, one per line. rc 1 when the list cannot be read.
@@ -190,6 +231,43 @@ gh_rest_label_names() {
190
231
  _ghr_read "repos/$1/labels" -X GET -f per_page=100 --paginate --jq '.[].name'
191
232
  }
192
233
 
234
+ # gh_rest_issue_comment <repo> <n> <body|@file> → the comment's html_url. Works for PRs too.
235
+ gh_rest_issue_comment() {
236
+ case "$3" in
237
+ @*) _ghr_api "repos/$1/issues/$2/comments" -X POST -F "body=$3" --jq .html_url ;;
238
+ *) _ghr_api "repos/$1/issues/$2/comments" -X POST -f "body=$3" --jq .html_url ;;
239
+ esac
240
+ }
241
+
242
+ # gh_rest_issue_comments <repo> <n> → every comment body, one JSON string per line is not safe for
243
+ # multi-line bodies, so bodies are printed raw separated by newlines (as `gh issue view --json
244
+ # comments -q '.comments[].body'` did).
245
+ gh_rest_issue_comments() {
246
+ _ghr_read "repos/$1/issues/$2/comments" -X GET -f per_page=100 --paginate --jq '.[].body'
247
+ }
248
+
249
+ # gh_rest_label_upsert <repo> <name> <color> <description> → rc 0 "created", rc 0 "updated"
250
+ # (the `--force` form of label create): a new label is created, an existing one takes the color
251
+ # and description. Prints created|updated. rc 1 when neither worked.
252
+ gh_rest_label_upsert() {
253
+ if _ghr_api "repos/$1/labels" -X POST -f "name=$2" -f "color=$3" -f "description=$4" >/dev/null 2>&1; then
254
+ echo created; return 0
255
+ fi
256
+ _ghr_api "repos/$1/labels/$2" -X PATCH -f "color=$3" -f "description=$4" >/dev/null 2>&1 && { echo updated; return 0; }
257
+ return 1
258
+ }
259
+
260
+ # gh_rest_pr_url_for_head <repo> <branch> → the open PR's html_url, or empty.
261
+ gh_rest_pr_url_for_head() {
262
+ _ghr_read "repos/$1/pulls" -X GET -f "head=${1%%/*}:$2" -f state=open --jq '.[0].html_url // empty'
263
+ }
264
+
265
+ # gh_rest_repo_default_branch <repo> → the repository's default branch, or rc 1.
266
+ gh_rest_repo_default_branch() { _ghr_read "repos/$1" --jq '.default_branch // empty'; }
267
+
268
+ # gh_rest_user_login → the token's login, or rc 1.
269
+ gh_rest_user_login() { _ghr_read user --jq '.login // empty'; }
270
+
193
271
  gh_rest_sub_issue_numbers() {
194
272
  _ghr_read "repos/$1/issues/$2/sub_issues" -X GET -f per_page=100 --jq '.[].number'
195
273
  }
@@ -211,7 +289,7 @@ gh_rest_open_issue_titles() {
211
289
  gh_rest_pr_create() {
212
290
  local repo="$1" base="$2" head="$3" title="$4" body="$5" labels="${6:-}" ms="${7:-}" msnum out num url login a
213
291
  local tab; tab="$(printf '\t')"
214
- out="$(gh api "repos/$repo/pulls" -X POST -f "title=$title" -f "head=$head" -f "base=$base" -f "body=$body" \
292
+ out="$(_ghr_api "repos/$repo/pulls" -X POST -f "title=$title" -f "head=$head" -f "base=$base" -f "body=$body" \
215
293
  --jq '"\(.number)\t\(.html_url)\t\(.user.login // "")"')" || return 1
216
294
  IFS="$tab" read -r num url login <<EOF
217
295
  $out
@@ -228,7 +306,7 @@ EOF
228
306
  else echo "cckit: milestone '$ms' not found in $repo — PR opened without it" >&2; fi
229
307
  fi
230
308
  if [ $# -gt 0 ]; then
231
- gh api "repos/$repo/issues/$num" -X PATCH "$@" >/dev/null 2>&1 \
309
+ _ghr_api "repos/$repo/issues/$num" -X PATCH "$@" >/dev/null 2>&1 \
232
310
  || echo "cckit: PR #$num opened, but its labels/milestone/assignee were not set" >&2
233
311
  fi
234
312
  printf '%s\n' "$url"
@@ -258,7 +336,7 @@ gh_rest_pr_commit_subjects() {
258
336
  }
259
337
 
260
338
  gh_rest_pr_merge() {
261
- gh api "repos/$1/pulls/$2/merge" -X PUT -f "merge_method=${3:-squash}" >/dev/null
339
+ _ghr_api "repos/$1/pulls/$2/merge" -X PUT -f "merge_method=${3:-squash}" >/dev/null
262
340
  }
263
341
 
264
342
  gh_rest_pr_closing_issues() {
@@ -302,3 +380,148 @@ EOF
302
380
  printf '%s|%s|%s|%s|%s\n' "$sub" "$state" "$pr" "$oid" "$title"
303
381
  done
304
382
  }
383
+
384
+ # --- Projects v2 board over REST (E546.7) --------------------------------------------------------
385
+ # GitHub's REST endpoints for Projects v2, as documented (read 2026-11-24):
386
+ # https://docs.github.com/en/rest/projects/projects GET {orgs/<org>|users/<user>}/projectsV2/<number>
387
+ # https://docs.github.com/en/rest/projects/fields GET …/projectsV2/<number>/fields
388
+ # https://docs.github.com/en/rest/projects/items GET|POST …/projectsV2/<number>/items
389
+ # PATCH …/projectsV2/<number>/items/<item_id>
390
+ # The docs send `X-GitHub-Api-Version: 2026-03-10` (CCKIT_BOARD_API_VERSION overrides it).
391
+ # add an item POST {"type":"Issue"|"PullRequest","owner":"<o>","repo":"<r>","number":<n>} → 201, the item
392
+ # set a field PATCH {"fields":[{"id":<field id, integer>,"value":<string|number|null>}]} → 200, the item;
393
+ # a single-select value is the option id, an iteration value the iteration id (strings)
394
+ # Field and item ids are integers in REST and node ids (`node_id`) in GraphQL; option and iteration ids
395
+ # are strings. A REST item travels as "<id>:<node_id>" so a GraphQL fallback still has its node id.
396
+ # The user-owned endpoints do not accept GitHub App tokens.
397
+ CCKIT_BOARD_API_VERSION_DEFAULT="2026-03-10"
398
+
399
+ # _ghr_board <endpoint> [flags…] — one board call. rc 0 with the output; rc 3 when REST cannot serve
400
+ # it (HTTP 404, 410, 415 or 501, a transport failure, or an answer the --jq filter rejects), with
401
+ # nothing printed; rc 1 on any other HTTP error, the API's message on stderr.
402
+ _ghr_board() {
403
+ local err out rc=0 code
404
+ err="$(mktemp)" || return 1
405
+ out="$(_ghr_api "$@" -H "X-GitHub-Api-Version: ${CCKIT_BOARD_API_VERSION:-$CCKIT_BOARD_API_VERSION_DEFAULT}" 2>"$err")" || rc=$?
406
+ if [ "$rc" = 0 ]; then
407
+ rm -f "$err"
408
+ [ -n "$out" ] && printf '%s\n' "$out"
409
+ return 0
410
+ fi
411
+ code="$(sed -nE 's/.*GitHub answered ([0-9]{3}) .*/\1/p' "$err" | sed -n 1p)"
412
+ case "$code" in
413
+ ''|404|410|415|501) rm -f "$err"; return 3 ;;
414
+ esac
415
+ cat "$err" >&2; rm -f "$err"
416
+ return 1
417
+ }
418
+
419
+ # gh_rest_board_base <owner-type> <owner> <number> — the endpoint prefix; rc 3 with an owner or
420
+ # number missing or malformed.
421
+ gh_rest_board_base() {
422
+ local otype="${1:-user}" owner="${2:-}" num="${3:-}"
423
+ case "$owner" in ''|*[!A-Za-z0-9-]*) return 3 ;; esac
424
+ case "$num" in ''|*[!0-9]*) return 3 ;; esac
425
+ case "$otype" in
426
+ org|organization) printf 'orgs/%s/projectsV2/%s' "$owner" "$num" ;;
427
+ *) printf 'users/%s/projectsV2/%s' "$owner" "$num" ;;
428
+ esac
429
+ }
430
+
431
+ gh_rest_board_project() {
432
+ _ghr_board "$1" --jq 'if (.node_id | type) == "string" then {id, node_id, number, title} | tojson else error("no project") end'
433
+ }
434
+
435
+ gh_rest_board_fields() {
436
+ _ghr_board "$1/fields" -X GET -f per_page=100 --jq '
437
+ if type != "array" then error("not a field list") else
438
+ [.[] | {id, node_id, name, data_type,
439
+ options: [(.options // [])[] | {id, name: (.name.raw? // .name)}],
440
+ iterations: [((.configuration.iterations // [])[]) | {id, title: (.title.raw? // .title), start_date}]}]
441
+ | tojson end'
442
+ }
443
+
444
+ # gh_rest_board_ids_env <base> — the lines capture-project-ids.sh writes, over REST: PROJECT_ID (the
445
+ # project node id), <FIELD>_FIELD_ID (the field node id, which the GraphQL fallback needs too),
446
+ # <FIELD>_FIELD_NUM (the REST field id), <FIELD>_OPT_<OPTION> and <FIELD>_ITER_<TITLE>. Names are
447
+ # upper-cased, spaces and hyphens become underscores, anything else outside [A-Z0-9_] is dropped.
448
+ gh_rest_board_ids_env() {
449
+ local proj fields
450
+ proj="$(gh_rest_board_project "$1")" || return $?
451
+ fields="$(gh_rest_board_fields "$1")" || return $?
452
+ printf 'PROJECT_ID=%s\n' "$(printf '%s' "$proj" | jq -r .node_id)"
453
+ printf '%s' "$fields" | jq -r '
454
+ def n: ascii_upcase | gsub("[ -]"; "_") | gsub("[^A-Z0-9_]"; "");
455
+ .[] | select(.name != null) | (.name | n) as $f | select($f != "")
456
+ | "\($f)_FIELD_ID=\(.node_id // .id)", "\($f)_FIELD_NUM=\(.id)",
457
+ (.options[] | (.name | n) as $o | select($o != "") | "\($f)_OPT_\($o)=\(.id)"),
458
+ (.iterations[] | (.title | n) as $t | select($t != "") | "\($f)_ITER_\($t)=\(.id)")'
459
+ }
460
+
461
+ # gh_rest_board_find_item <base> <Issue|PullRequest> <repo> <n> — the issue's or PR's card on the
462
+ # board, as "<id>:<node_id>"; empty (rc 0) when it is not on it. REST has no content-side lookup, so
463
+ # this reads the board's items, 100 a page.
464
+ gh_rest_board_find_item() {
465
+ local base="$1" type="$2" repo="$3" n="$4" out
466
+ case "$type" in Issue|PullRequest) ;; *) return 3 ;; esac
467
+ case "$n" in ''|*[!0-9]*) return 3 ;; esac
468
+ case "$repo" in */*) ;; *) return 3 ;; esac
469
+ case "$repo" in *[!A-Za-z0-9._/-]*) return 3 ;; esac
470
+ out="$(_ghr_board "$base/items" -X GET -f per_page=100 --paginate --jq "
471
+ if type != \"array\" then error(\"not an item list\") else .[] end
472
+ | select(.content_type == \"$type\")
473
+ | select((.content.number // -1) == $n)
474
+ | select(((.content.repository.full_name // \"$repo\") | ascii_downcase) == (\"$repo\" | ascii_downcase))
475
+ | \"\(.id):\(.node_id // \"\")\"")" || return $?
476
+ printf '%s\n' "$out" | sed '/^$/d' | sed -n 1p
477
+ }
478
+
479
+ # gh_rest_board_find_issue_item <base> <repo> <n> — gh_rest_board_find_item for an issue.
480
+ gh_rest_board_find_issue_item() { gh_rest_board_find_item "$1" Issue "$2" "$3"; }
481
+
482
+ # gh_rest_board_add_item <base> <Issue|PullRequest> <repo> <n> — add an issue or PR; prints
483
+ # "<id>:<node_id>" of the new (or existing) item. REST answers 422 "Content already exists in this
484
+ # project" when the item is already on the board, where GraphQL's addProjectV2ItemById returned the
485
+ # existing item. A board with GitHub's auto-add workflow puts every new issue and PR on the board
486
+ # within seconds, so the 422 is the common case there (#590): the existing card is read back instead.
487
+ # rc 3 when it cannot be read, so the GraphQL fallback (idempotent) decides.
488
+ gh_rest_board_add_item() {
489
+ local base="$1" type="$2" repo="$3" n="$4" err out rc=0
490
+ case "$type" in Issue|PullRequest) ;; *) return 3 ;; esac
491
+ case "$n" in ''|*[!0-9]*) return 3 ;; esac
492
+ case "$repo" in */*) ;; *) return 3 ;; esac
493
+ err="$(mktemp)" || return 1
494
+ out="$(_ghr_board "$base/items" -X POST -f "type=$type" -f "owner=${repo%%/*}" -f "repo=${repo##*/}" -F "number=$n" \
495
+ --jq 'if (.id | type) == "number" then "\(.id):\(.node_id // "")" else error("no item id") end' 2>"$err")" || rc=$?
496
+ if [ "$rc" = 1 ] && grep -q 'GitHub answered 422 .*already exists' "$err"; then
497
+ rm -f "$err"
498
+ out="$(gh_rest_board_find_item "$base" "$type" "$repo" "$n" 2>/dev/null)" || return 3
499
+ [ -n "$out" ] || return 3
500
+ printf '%s\n' "$out"
501
+ return 0
502
+ fi
503
+ cat "$err" >&2; rm -f "$err"
504
+ [ "$rc" = 0 ] || return "$rc"
505
+ [ -n "$out" ] && printf '%s\n' "$out"
506
+ return 0
507
+ }
508
+
509
+ # gh_rest_board_set_field <base> <item id> <field> <kind> <value> — set one field of one item.
510
+ # <field> is the REST field id or its node id (the captured <FIELD>_FIELD_ID); <kind> is
511
+ # single_select (value = an option id), iteration (an iteration id) or text. The field is read
512
+ # first: a field, option or iteration REST does not list is rc 3, so the GraphQL fallback decides.
513
+ gh_rest_board_set_field() {
514
+ local base="$1" item="$2" field="$3" kind="$4" value="$5" fields fnum body
515
+ case "$item" in ''|*[!0-9]*) return 3 ;; esac
516
+ fields="$(gh_rest_board_fields "$base")" || return $?
517
+ fnum="$(printf '%s' "$fields" | jq -r --arg f "$field" --arg k "$kind" --arg v "$value" '
518
+ [.[] | select((.id | tostring) == $f or .node_id == $f)
519
+ | select(if $k == "single_select" then any(.options[]; .id == $v)
520
+ elif $k == "iteration" then any(.iterations[]; .id == $v)
521
+ else .data_type == "text" end)
522
+ | .id][0] // empty')"
523
+ case "$fnum" in ''|*[!0-9]*) return 3 ;; esac
524
+ body="$(jq -cn --argjson f "$fnum" --arg v "$value" '{fields: [{id: $f, value: $v}]}')"
525
+ printf '%s' "$body" | _ghr_board "$base/items/$item" -X PATCH --input - \
526
+ --jq 'if (.id | type) == "number" then .id else error("no item") end' >/dev/null
527
+ }
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # git-core-test.sh — E537.4: the git core stands alone. With PATH stripped of gh and no token, the
4
+ # forge provider is none and start, pr, merge, hotfix and gc each either work through git or say,
5
+ # once, what they skipped. Nothing is silent and nothing reaches the network: a curl stub on PATH
6
+ # fails loudly, so a leaked request is a red test. Hermetic: a bare origin and a clone under mktemp.
7
+ # Run: bash scripts/lib/git-core-test.sh
8
+ # errors: strict — a test runner: rc 1 on any failed assertion
9
+ set -u
10
+ LIB="$(cd "$(dirname "$0")" && pwd)"
11
+ # shellcheck source=/dev/null
12
+ . "$LIB/test-env.sh" && test_env_seal
13
+ unset GH_TOKEN GITHUB_TOKEN CCKIT_FORGE CCKIT_VERB KIT_CONFIG
14
+ fail=0
15
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
16
+ tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
17
+
18
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
19
+ mkdir -p "$tmp/tools"
20
+ # A PATH stripped of gh wherever it lives (Homebrew here, /usr/bin on Ubuntu): one dir of symlinks
21
+ # to every executable on the current PATH except gh and curl, and PATH is that dir alone.
22
+ _old_ifs="$IFS"; IFS=:
23
+ for d in $PATH; do
24
+ [ -d "$d" ] || continue
25
+ for f in "$d"/*; do
26
+ n="${f##*/}"
27
+ case "$n" in gh|curl) continue ;; esac
28
+ [ -x "$f" ] && [ ! -e "$tmp/tools/$n" ] && ln -s "$f" "$tmp/tools/$n"
29
+ done
30
+ done
31
+ IFS="$_old_ifs"
32
+ cat > "$tmp/tools/curl" <<'SH'
33
+ #!/bin/sh
34
+ echo "curl $*" >> "${CURL_LOG:-/dev/null}"; echo "curl stub: a request leaked: $*" >&2; exit 99
35
+ SH
36
+ chmod +x "$tmp/tools/curl"
37
+ export PATH="$tmp/tools" CURL_LOG="$tmp/curl.log"; : > "$CURL_LOG"
38
+ command -v jq >/dev/null 2>&1 || { echo "git-core-test: jq not on the stripped PATH ($PATH) — skipping"; exit 0; }
39
+ t "gh is not on PATH" "$(command -v gh >/dev/null 2>&1 && echo yes || echo no)" "no"
40
+
41
+ # ── the fixture: a bare origin with develop and main, a clone with the project config ───────────
42
+ git init -q --bare "$tmp/origin.git"
43
+ git clone -q "$tmp/origin.git" "$tmp/work" 2>/dev/null
44
+ cd "$tmp/work" || exit 1
45
+ git config user.email t@t; git config user.name t; git config commit.gpgsign false
46
+ git checkout -q -b develop
47
+ printf '{"kitVersion":"9.9.9","project":{"name":"fx","slug":"fx"},"github":{"repo":"o/r","owner":"o","baseBranch":"develop","projectsV2":false}}\n' > cckit.config.json
48
+ printf '.claude/worktrees/\n.cckit/\n' > .gitignore
49
+ echo one > tracked.txt; git add .gitignore cckit.config.json tracked.txt; git commit -q -m init
50
+ git push -q origin develop; git branch -q main; git push -q origin main
51
+ export KIT_REPO="o/r" WT_START_REPO="o/r" KIT_BASE_BRANCH="develop" KIT_WT_INSTALL=0 KIT_GC_REPO="o/r" KIT_PROJECTS_V2=false
52
+
53
+ # shellcheck source=/dev/null
54
+ . "$LIB/forge.sh"
55
+ t "no token and no gh: the provider is none" "$(forge_provider)" "none"
56
+
57
+ # shellcheck source=/dev/null
58
+ . "$LIB/worktree-start.sh"
59
+ # shellcheck source=/dev/null
60
+ . "$LIB/kit-task-ops.sh"
61
+
62
+ # ── start ──────────────────────────────────────────────────────────────────────────────────────
63
+ out="$(wt_start 7 the-thing 2>"$tmp/err")"; rc=$?
64
+ t "start without a forge: rc 0" "$rc" "0"
65
+ t "start: the branch is task/<N>-<slug>" "$(printf '%s' "$out" | cut -d'|' -f2)" "task/7-the-thing"
66
+ tc "$tmp/err" '^cckit start: no forge — issue #7 is not read; the branch is task/7-the-thing' "start: the one line says what it skipped"
67
+ wt="$(printf '%s' "$out" | cut -d'|' -f1)"
68
+ t "start: the worktree exists" "$([ -d "$wt" ] && echo yes || echo no)" "yes"
69
+ out2="$(wt_start 8 2>"$tmp/err2")"
70
+ t "start with no slug: issue-<N>" "$(printf '%s' "$out2" | cut -d'|' -f2)" "task/8-issue-8"
71
+
72
+ # ── pr: commit + push, the pull request is not opened, said once ───────────────────────────────
73
+ echo two > "$wt/tracked.txt"
74
+ out="$(cd "$wt" && kto_task_pr 7 "fix: do the thing" 2>"$tmp/err")"; rc=$?
75
+ t "pr without a forge: rc 0" "$rc" "0"
76
+ t "pr: the change is committed" "$(git -C "$wt" log -1 --format=%s)" "fix: do the thing [#7]"
77
+ t "pr: the branch is pushed" "$(git ls-remote --heads origin task/7-the-thing | wc -l | tr -d ' ')" "1"
78
+ tc "$tmp/err" '^cckit pr: no forge — issue #7 is not read and the pull request is not opened' "pr: the one line says what it skipped"
79
+ t "pr: says the pull request is to be opened by hand (origin is not on GitHub)" \
80
+ "$(printf '%s' "$out" | grep -c 'pushed task/7-the-thing (no forge: open the pull request on your forge, task/7-the-thing → develop)')" "1"
81
+ # the compare page, when origin is on GitHub
82
+ git init -q "$tmp/ghrepo"; git -C "$tmp/ghrepo" remote add origin https://github.com/o/r.git
83
+ t "the compare page for a GitHub origin" "$(forge_compare_url develop fix/1-x "$tmp/ghrepo")" "https://github.com/o/r/compare/develop...fix/1-x"
84
+ t "no compare page for a local origin" "$(forge_compare_url develop fix/1-x "$tmp/work" 2>/dev/null; echo "rc=$?")" "rc=1"
85
+
86
+ # ── merge: through git onto the base, pushed, cleaned up ──────────────────────────────────────
87
+ out="$(cd "$wt" && kto_task_pr_merge 2>"$tmp/err")"; rc=$?
88
+ t "merge without a forge: rc 0" "$rc" "0"
89
+ tc "$tmp/err" '^cckit merge: no forge — the branch lands on develop through git; no pull request is merged and no issue is closed' "merge: the one line says what it skipped"
90
+ t "merge: develop on origin carries the squash commit" "$(git -C "$tmp/work" log -1 --format=%s origin/develop)" "fix: do the thing [#7]"
91
+ t "merge: one commit landed (a squash)" "$(git -C "$tmp/work" rev-list --count origin/develop)" "2"
92
+ t "merge: the worktree is removed" "$([ -d "$wt" ] && echo present || echo gone)" "gone"
93
+ t "merge: the local branch is deleted" "$(git -C "$tmp/work" branch --list task/7-the-thing | wc -l | tr -d ' ')" "0"
94
+ t "merge: the remote branch is deleted" "$(git ls-remote --heads origin task/7-the-thing | wc -l | tr -d ' ')" "0"
95
+ t "merge: the main checkout is on develop, current" "$(git -C "$tmp/work" rev-parse --abbrev-ref HEAD) $(git -C "$tmp/work" rev-parse HEAD | cut -c1-7)" "develop $(git -C "$tmp/work" rev-parse origin/develop | cut -c1-7)"
96
+ tc <(printf '%s' "$out") 'merged into develop \(squash\) and pushed' "merge: says what it did"
97
+ ( cd "$tmp/work" && kto_task_pr_merge 12 ) >/dev/null 2>"$tmp/err"; rc=$?
98
+ t "merge <pr> without a forge is refused" "$rc" "1"
99
+ tc "$tmp/err" 'a pull request number cannot be read' "merge <pr>: the refusal names the reason"
100
+ ( cd "$tmp/work" && kto_task_pr_merge ) >/dev/null 2>"$tmp/err"; rc=$?
101
+ t "merge from the base branch is refused" "$rc" "1"
102
+
103
+ # ── hotfix: the cherry-pick lands on main and is pushed; no pull request ──────────────────────
104
+ # shellcheck source=/dev/null
105
+ . "$LIB/kit-hotfix.sh"
106
+ sha="$(git -C "$tmp/work" rev-parse origin/develop)"
107
+ out="$(cd "$tmp/work" && kto_hotfix "$sha" --base main 2>"$tmp/err")"; rc=$?
108
+ t "hotfix without a forge: rc 0" "$rc" "0"
109
+ tc "$tmp/err" '^cckit hotfix: no forge — the pull request is not opened; fix/hotfix-[0-9a-f]{7}-main is pushed' "hotfix: the one line says what it skipped"
110
+ t "hotfix: the branch is on origin" "$(git ls-remote --heads origin 'fix/hotfix-*-main' | wc -l | tr -d ' ')" "1"
111
+ tc <(printf '%s' "$out") '^✓ pushed fix/hotfix-[0-9a-f]{7}-main \(no forge: open the pull request on your forge' "hotfix: says the pull request is to be opened by hand"
112
+ ( cd "$tmp/work" && kto_hotfix 12 --base main ) >/dev/null 2>"$tmp/err"; rc=$?
113
+ t "hotfix <pr> without a forge is refused" "$rc" "1"
114
+ tc "$tmp/err" 'PR #12 cannot be read; pass the merge commit' "hotfix <pr>: the refusal names the alternative"
115
+
116
+ # ── gc: every row UNKNOWN and kept; the note is printed once ──────────────────────────────────
117
+ # shellcheck source=/dev/null
118
+ . "$LIB/kit-gc.sh"
119
+ out="$(cd "$tmp/work" && unset _FORGE_NONE_SAID && kit_gc_analyze 2>"$tmp/err")"
120
+ t "gc: the leftover issue branch is UNKNOWN, kept" "$(printf '%s\n' "$out" | grep -c 'task/8-issue-8 .*UNKNOWN')" "1"
121
+ t "gc: nothing is SAFE or LANDED" "$(printf '%s\n' "$out" | grep -cE 'task/8-issue-8 .*(SAFE|LANDED)')" "0"
122
+ t "gc: the no-forge note is printed once" "$(grep -c '^cckit gc: no forge — ' "$tmp/err")" "1"
123
+
124
+ # ── nothing reached the network ───────────────────────────────────────────────────────────────
125
+ t "no request left the machine" "$(wc -l < "$CURL_LOG" | tr -d ' ')" "0"
126
+
127
+ [ "$fail" -eq 0 ] && echo "ALL OK (git-core)"
128
+ exit "$fail"
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ # grill-record-test.sh — the `## Grilling` record check (scripts/lib/grill-record.sh, E547.2): an
3
+ # accept/reject table, the reasons it prints, and grill_record_section. Hermetic, no network.
4
+ # errors: strict — a test runner: rc 1 on any failed assertion
5
+ set -u
6
+ LIB="$(cd "$(dirname "$0")" && pwd)"
7
+ fail=0
8
+ # shellcheck source=/dev/null
9
+ . "$LIB/grill-record.sh"
10
+
11
+ t() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1"; echo " got: [$2]"; echo " want: [$3]"; fail=1; fi; }
12
+ acc() { if grill_record_lint "$2" >/dev/null 2>&1; then echo "ok accepts: $1"; else echo "FAIL should accept: $1"; grill_record_lint "$2"; fail=1; fi; }
13
+ rej() { if grill_record_lint "$2" >/dev/null 2>&1; then echo "FAIL should reject: $1"; fail=1; else echo "ok rejects: $1"; fi; }
14
+ nl='
15
+ '
16
+ rec="Grilled: the maintainer, 2026-11-24, in session.${nl}1. One sprint is one week.${nl}2. Waves run inside a sprint.${nl}3. The advisor writes no code."
17
+
18
+ # --- accept ---
19
+ acc "three numbered decisions" "$rec"
20
+ acc "paren-numbered decisions" "Grilled: the owner, 2026-11-24.${nl}1) a${nl}2) b${nl}3) c"
21
+ acc "continuation lines indented" "$rec${nl} because it keeps the review weekly"
22
+ acc "a comment link holds them" "Grilled: the owner, 2026-11-24.${nl}Decisions: https://github.com/o/r/issues/12#issuecomment-345"
23
+ acc "an assumed record" "Grilled: the agent (assumed), 2026-11-24.${nl}1. a${nl}2. b${nl}3. c"
24
+ acc "a waiver" "waived: a one-line rename, nothing to decide"
25
+ acc "leading blank lines and CRLF" "${nl}${nl}Grilled: the owner, 2026-11-24.$(printf '\r')${nl}1. a${nl}2. b${nl}3. c"
26
+
27
+ # --- reject ---
28
+ rej "an empty record" ""
29
+ rej "no Grilled line" "2026-11-24${nl}1. a${nl}2. b${nl}3. c"
30
+ rej "Grilled names nobody" "Grilled:${nl}2026-11-24${nl}1. a${nl}2. b${nl}3. c"
31
+ rej "no date" "Grilled: the owner.${nl}1. a${nl}2. b${nl}3. c"
32
+ rej "two decisions" "Grilled: the owner, 2026-11-24.${nl}1. a${nl}2. b"
33
+ rej "indented items do not count" "Grilled: the owner, 2026-11-24.${nl} 1. a${nl} 2. b${nl} 3. c"
34
+ rej "an issue link is not a record" "Grilled: the owner, 2026-11-24.${nl}See https://github.com/o/r/issues/12"
35
+ rej "a waiver with no reason" "waived:"
36
+ rej "a waiver among other lines" "waived: x${nl}1. a"
37
+
38
+ # --- the reasons name what is missing ---
39
+ err="$(grill_record_lint "Grilled: the owner.${nl}1. a" 2>&1 >/dev/null)"
40
+ case "$err" in *"no YYYY-MM-DD date"*) echo "ok reason: missing date" ;; *) echo "FAIL reason: missing date — got: $err"; fail=1 ;; esac
41
+ case "$err" in *"1 decision(s)"*) echo "ok reason: counts the decisions" ;; *) echo "FAIL reason: decision count — got: $err"; fail=1 ;; esac
42
+ grill_record_lint >/dev/null 2>&1; t "no argument is a usage error" "$?" "2"
43
+ printf '%s\n' "$rec" | grill_record_lint - >/dev/null 2>&1; t "reads stdin with -" "$?" "0"
44
+
45
+ # --- the section builder ---
46
+ t "section: heading, blank, text, blank edges cut" \
47
+ "$(grill_record_section "${nl}${nl}waived: rename${nl}${nl}")" "## Grilling${nl}${nl}waived: rename"
48
+
49
+ exit "$fail"