@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,12 +1,12 @@
1
1
  #!/usr/bin/env bash
2
2
  # shellcheck shell=bash
3
- # kto-hotfix-test.sh — `cckit hotfix <pr|sha> [--base B]` end to end (#360), against a stubbed gh, a
4
- # throwaway repo and a bare remote: the worktree is cut from origin/<base>, the branch carries
3
+ # kto-hotfix-test.sh — `cckit hotfix <pr|sha> [--base B]` end to end (#360, E537), over the forge
4
+ # shim, a throwaway repo and a bare remote: the worktree is cut from origin/<base>, the branch carries
5
5
  # exactly the source commit's diff, the push exports KIT_PR_BASE, and the PR targets <base> with
6
- # `Cherry-pick of #N` in its body. Covers both transports, a merge-commit source, a re-run, and the
6
+ # `Cherry-pick of #N` in its body. Covers a merge-commit source, a re-run, and the
7
7
  # rebase-merged multi-commit PR (every commit carried), a squash of a multi-commit PR (one commit), a
8
8
  # refusal reported as `--llm` JSON, and the refusals (unmerged PR, unknown sha, missing base,
9
- # conflict).
9
+ # conflict). Every GitHub read and write is a REST request on repos/o/r/pulls…; no gh subcommand runs.
10
10
  # Run: bash scripts/lib/kto-hotfix-test.sh
11
11
  # errors: strict — a test runner: rc 1 on any failed assertion
12
12
  set -u
@@ -24,35 +24,28 @@ command -v jq >/dev/null 2>&1 || { echo "kto-hotfix-test: jq required" >&2; exit
24
24
  tmp="$(cd "$(mktemp -d)" && pwd -P)"; trap 'rm -rf "$tmp"' EXIT
25
25
  export GH_LOG="$tmp/gh.log" GH_SHA="" GH_STATE="MERGED" GH_OPEN_URL="" GH_SUBJECTS="wip"
26
26
  : > "$GH_LOG"
27
- mkdir -p "$tmp/bin"
28
- # A gh that logs one call per line (newlines in a body become \036) and answers both transports.
29
- cat > "$tmp/bin/gh" <<'SH'
30
- #!/usr/bin/env bash
31
- { printf '%s' "$*" | tr '\n' '\036'; echo; } >> "$GH_LOG"
32
- jqx=""; prev=""; for a in "$@"; do [ "$prev" = "--jq" ] && jqx="$a"; prev="$a"; done
33
- out() { if [ -n "$jqx" ]; then printf '%s' "$1" | jq -r -c "$jqx"; else printf '%s\n' "$1"; fi; }
34
- merged="null"; [ "$GH_STATE" = "MERGED" ] && merged='"2026-10-30T00:00:00Z"'
35
- # GH_SUBJECTS: the PR's own commit subjects, one per line, oldest first.
36
- commits="$(printf '%s\n' "$GH_SUBJECTS" | jq -R -s -c '[split("\n")[] | select(length > 0)]')"
37
- case "$1 $2" in
38
- "pr view")
39
- if [ "$GH_STATE" = "MERGED" ]; then mc="{\"oid\":\"$GH_SHA\"}"; else mc="null"; fi
40
- out "{\"title\":\"fix: the thing [#11]\",\"state\":\"$GH_STATE\",\"mergeCommit\":$mc,\"commits\":$(printf '%s' "$commits" | jq -c '[.[] | {messageHeadline: .}]')}" ;;
41
- "pr list") out "[$( [ -n "$GH_OPEN_URL" ] && printf '{"url":"%s"}' "$GH_OPEN_URL" )]" ;;
42
- "pr create") echo "https://github.com/o/r/pull/77" ;;
43
- "api repos/o/r/pulls")
44
- case " $* " in
45
- *" POST "*) out '{"number":77,"html_url":"https://github.com/o/r/pull/77","user":{"login":"me"}}' ;;
46
- *) out "[]" ;;
47
- esac ;;
48
- "api repos/o/r/pulls/"*"/commits")
49
- out "$(printf '%s' "$commits" | jq -c '[.[] | {commit: {message: (. + "\n\nbody text")}}]')" ;;
50
- "api repos/o/r/pulls/"*)
51
- out "{\"title\":\"fix: the thing [#11]\",\"mergeable\":null,\"mergeable_state\":\"unknown\",\"base\":{\"ref\":\"develop\"},\"head\":{\"ref\":\"fix/11-x\"},\"body\":\"\",\"state\":\"closed\",\"merged_at\":$merged,\"merge_commit_sha\":\"$GH_SHA\"}" ;;
52
- *) exit 0 ;;
27
+ # shellcheck source=/dev/null
28
+ . "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
29
+ # The PR fixtures the shim does not know: the source PR (GH_STATE merged or not, its merge commit
30
+ # GH_SHA, its commit subjects GH_SUBJECTS one per line oldest first), the open PR for a head
31
+ # (GH_OPEN_URL, empty = none), and the PR this verb opens (#77).
32
+ export GH_FIXTURE="$tmp/fixture.sh"
33
+ cat > "$GH_FIXTURE" <<'SH'
34
+ merged="null"; [ "${GH_STATE:-}" = "MERGED" ] && merged='"2026-10-30T00:00:00Z"'
35
+ case "$method $ep" in
36
+ "GET repos/o/r/pulls/"*"/commits")
37
+ out="$(printf '%s\n' "${GH_SUBJECTS:-}" | jq -R -s -c '[split("\n")[] | select(length > 0) | {commit: {message: (. + "\n\nbody text")}}]')" ;;
38
+ "GET repos/o/r/pulls/"*)
39
+ out="{\"title\":\"fix: the thing [#11]\",\"mergeable\":null,\"mergeable_state\":\"unknown\",\"base\":{\"ref\":\"develop\"},\"head\":{\"ref\":\"fix/11-x\"},\"body\":\"\",\"state\":\"closed\",\"merged_at\":$merged,\"merge_commit_sha\":\"${GH_SHA:-}\"}" ;;
40
+ "GET repos/o/r/pulls")
41
+ out="[$( [ -n "${GH_OPEN_URL:-}" ] && printf '{"number":77,"html_url":"%s"}' "$GH_OPEN_URL" )]" ;;
42
+ "POST repos/o/r/pulls")
43
+ out='{"number":77,"html_url":"https://github.com/o/r/pull/77","user":{"login":"me"}}' ;;
53
44
  esac
54
45
  SH
55
- chmod +x "$tmp/bin/gh"
46
+ export GH_TOKEN=test-token CCKIT_FORGE=github
47
+ # The PR this verb opens: ONE POST on repos/o/r/pulls whose JSON body carries title, head, base, body.
48
+ PR_POST='^POST repos/o/r/pulls \{'
56
49
  export PATH="$tmp/bin:$PATH" KIT_WT_INSTALL=0
57
50
 
58
51
  # The fixture: `main` (the release branch) one commit behind `develop`, which carries the fix as a
@@ -104,8 +97,8 @@ t "the unrelated develop commit is not carried" "$(git ls-tree --name-only fix
104
97
  tc <(git log -1 --format=%B fix/12-hotfix-main) "cherry picked from commit $SRC" "cherry-pick -x records the source"
105
98
  t "the branch reached the remote" "$(git -C "$tmp/remote.git" rev-parse fix/12-hotfix-main 2>/dev/null)" "$(git rev-parse fix/12-hotfix-main)"
106
99
  t "the pre-push hook sees KIT_PR_BASE=main" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=main"
107
- tc "$GH_LOG" '^pr create .*--base main --head fix/12-hotfix-main ' "the PR targets main from the hotfix branch"
108
- tc "$GH_LOG" '--title fix: the thing --body ' "titled after the source, squash suffix dropped"
100
+ tc "$GH_LOG" "${PR_POST}.*\"head\":\"fix/12-hotfix-main\",\"base\":\"main\"," "the PR targets main from the hotfix branch"
101
+ tc "$GH_LOG" "${PR_POST}\"title\":\"fix: the thing\",\"head\"" "titled after the source, squash suffix dropped"
109
102
  tc "$GH_LOG" 'Cherry-pick of #12' "the body says Cherry-pick of #12"
110
103
  tn "$GH_LOG" 'Closes #' "the body closes no issue"
111
104
  t "stdout ends with the PR url" "$(printf '%s\n' "$out" | tail -1)" "✓ https://github.com/o/r/pull/77"
@@ -115,7 +108,8 @@ t "stdout ends with the PR url" "$(printf '%s\n' "$out" | tail
115
108
  out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" hotfix "$SRC" --base main 2>/dev/null)"; rc=$?
116
109
  t "a re-run succeeds" "$rc" "0"
117
110
  t "…and does not pick the commit twice" "$(git rev-list --count origin/main..fix/12-hotfix-main)" "1"
118
- tn "$GH_LOG" '^pr create' "…and opens no second PR"
111
+ tn "$GH_LOG" '^POST repos/o/r/pulls ' "…and opens no second PR"
112
+ tc "$GH_LOG" '^GET repos/o/r/pulls\?head=o%3Afix%2F12-hotfix-main&state=open' "…having asked for the open PR of the branch"
119
113
  t "…and still reports the url" "$(printf '%s\n' "$out" | tail -1)" "✓ https://github.com/o/r/pull/77"
120
114
 
121
115
  # ── <pr>: the merge commit and title come from GitHub; main is the default base ─────────────────
@@ -123,9 +117,9 @@ reset_hotfix
123
117
  : > "$GH_LOG"
124
118
  out="$(GH_SHA="$SRC" "$CCKIT" hotfix 12 2>"$tmp/err")"; rc=$?
125
119
  t "hotfix <pr> succeeds (default base main)" "$rc" "0"
126
- tc "$GH_LOG" '^pr view 12 ' "the source PR is read from GitHub"
120
+ tc "$GH_LOG" '^GET repos/o/r/pulls/12 $' "the source PR is read from GitHub"
127
121
  t "the branch diff equals the source commit's" "$(git diff origin/main fix/12-hotfix-main)" "$(git diff "$SRC~1" "$SRC")"
128
- tc "$GH_LOG" '^pr create .*--base main .*--title fix: the thing \[#11\] ' "titled after the source PR"
122
+ tc "$GH_LOG" "${PR_POST}\"title\":\"fix: the thing \[#11\]\",\"head\":\"fix/12-hotfix-main\",\"base\":\"main\"," "titled after the source PR"
129
123
  tc "$GH_LOG" 'Cherry-pick of #12' "the body says Cherry-pick of #12"
130
124
 
131
125
  # --llm: one JSON object carrying the url and the worktree
@@ -140,15 +134,16 @@ t "--llm: a refusal exits 1" "$rc" "1"
140
134
  t "--llm: a refusal reports ok false" "$(printf '%s' "$js" | jq -r '"\(.verb) \(.ok)"' 2>/dev/null)" "hotfix false"
141
135
  t "--llm: …and carries the reason" "$(printf '%s' "$js" | jq -r .detail 2>/dev/null | grep -c 'not merged')" "1"
142
136
 
143
- # ── REST transport: only `gh api repos/…` calls ──────────────────────────────────────────────────
137
+ # ── the forge is the only transport: REST on repos/…, no gh subcommand, no graphql ───────────────
144
138
  reset_hotfix
145
139
  : > "$GH_LOG"
146
- GH_SHA="$SRC" CCKIT_GH_TRANSPORT=rest "$CCKIT" hotfix 12 >/dev/null 2>"$tmp/err"; rc=$?
147
- t "rest: hotfix <pr> succeeds" "$rc" "0"
148
- tn "$GH_LOG" '^(pr|issue) |graphql' "rest: no gh pr/issue/graphql call"
149
- tc "$GH_LOG" '^api repos/o/r/pulls -X POST .*base=main' "rest: the PR is created against main"
150
- tc "$GH_LOG" 'Cherry-pick of #12' "rest: the body says Cherry-pick of #12"
151
- t "rest: the branch diff equals the source's" "$(git diff origin/main fix/12-hotfix-main)" "$(git diff "$SRC~1" "$SRC")"
140
+ GH_SHA="$SRC" "$CCKIT" hotfix 12 >/dev/null 2>"$tmp/err"; rc=$?
141
+ t "forge: hotfix <pr> succeeds" "$rc" "0"
142
+ tn "$GH_LOG" '^GH-SUBCOMMAND |graphql' "forge: no gh subcommand, no graphql call"
143
+ t "forge: every request is REST on repos/" "$(grep -vE "^(GET|POST|PATCH) repos/o/r/" "$GH_LOG" | sed -n 1p)" ""
144
+ tc "$GH_LOG" "${PR_POST}.*\"base\":\"main\"," "forge: the PR is created against main"
145
+ tc "$GH_LOG" 'Cherry-pick of #12' "forge: the body says Cherry-pick of #12"
146
+ t "forge: the branch diff equals the source's" "$(git diff origin/main fix/12-hotfix-main)" "$(git diff "$SRC~1" "$SRC")"
152
147
 
153
148
  # ── a merge commit is picked against its first parent ────────────────────────────────────────────
154
149
  : > "$GH_LOG"
@@ -158,18 +153,17 @@ t "…carrying the merged side's diff" "$(git diff origin/main fix/
158
153
  tc "$GH_LOG" 'Cherry-pick of #14' "…and the PR number from the merge subject"
159
154
 
160
155
  # ── a rebase-merged PR: GitHub names only its LAST commit, every one of its commits is carried ───
161
- for tr in graphql rest; do
162
- : > "$GH_LOG"
163
- GH_SHA="$REB" GH_SUBJECTS="$(printf 'fix: rebased part one\nfix: rebased part two')" CCKIT_GH_TRANSPORT="$tr" \
164
- "$CCKIT" hotfix 20 >/dev/null 2>"$tmp/err"; rc=$?
165
- t "$tr: a rebase-merged PR succeeds" "$rc" "0"
166
- t "$tr: …carrying both of its commits" "$(git rev-list --count origin/main..fix/20-hotfix-main 2>/dev/null)" "2"
167
- t "$tr: …whose diff is the whole PR's" "$(git diff origin/main fix/20-hotfix-main)" "$(git diff "$REB~2" "$REB")"
168
- tc "$tmp/err" 'rebase-merged: carrying its 2 commits' "$tr: …and says so"
169
- tc "$GH_LOG" "Source commits.*$(git rev-parse "$REB~1").*$REB" "$tr: the body lists both source commits"
170
- git worktree remove --force "$tmp/work/.claude/worktrees/fix+20-hotfix-main"; git branch -q -D fix/20-hotfix-main
171
- git push -q origin :fix/20-hotfix-main 2>/dev/null
172
- done
156
+ : > "$GH_LOG"
157
+ GH_SHA="$REB" GH_SUBJECTS="$(printf 'fix: rebased part one\nfix: rebased part two')" \
158
+ "$CCKIT" hotfix 20 >/dev/null 2>"$tmp/err"; rc=$?
159
+ t "a rebase-merged PR succeeds" "$rc" "0"
160
+ tc "$GH_LOG" '^GET repos/o/r/pulls/20/commits\?per_page=100' "…its commits are read over REST"
161
+ t "…carrying both of its commits" "$(git rev-list --count origin/main..fix/20-hotfix-main 2>/dev/null)" "2"
162
+ t "…whose diff is the whole PR's" "$(git diff origin/main fix/20-hotfix-main)" "$(git diff "$REB~2" "$REB")"
163
+ tc "$tmp/err" 'rebase-merged: carrying its 2 commits' "…and says so"
164
+ tc "$GH_LOG" "Source commits.*$(git rev-parse "$REB~1").*$REB" "the body lists both source commits"
165
+ git worktree remove --force "$tmp/work/.claude/worktrees/fix+20-hotfix-main"; git branch -q -D fix/20-hotfix-main
166
+ git push -q origin :fix/20-hotfix-main 2>/dev/null
173
167
  # A SQUASH of a multi-commit PR is one commit carrying all of it: the subjects under it are not the PR's.
174
168
  reset_hotfix
175
169
  : > "$GH_LOG"
@@ -208,7 +202,7 @@ t "…with no branch made" "$(git branch --list 'fix/12
208
202
  t "no source is a usage error" "$rc" "2"
209
203
  "$CCKIT" hotfix "$SRC" --base >/dev/null 2>"$tmp/err"; rc=$?
210
204
  t "--base with no value is a usage error" "$rc" "2"
211
- tn "$GH_LOG" '^pr create|-X POST' "no refusal opened a PR"
205
+ tn "$GH_LOG" '^POST ' "no refusal opened a PR"
212
206
 
213
207
  # ── a conflict stops before the push and says how to continue ────────────────────────────────────
214
208
  git checkout -q -b rel-edit origin/main; printf 'a\nb\nc\nZ\n' > app.txt; git commit -q -am "main-only edit"
@@ -218,7 +212,7 @@ git push -q origin rel-edit:rel; git checkout -q develop
218
212
  t "a conflicting pick fails" "$rc" "1"
219
213
  tc "$tmp/err" 'cherry-pick --continue' "…telling you how to continue"
220
214
  t "…without pushing" "$(wc -l < "$tmp/prepush.log" | tr -d ' ')" "0"
221
- tn "$GH_LOG" '^pr create' "…and without opening a PR"
215
+ tn "$GH_LOG" '^POST ' "…and without opening a PR"
222
216
  "$CCKIT" hotfix "$CONF" --base rel >/dev/null 2>"$tmp/err"; rc=$?
223
217
  t "a re-run mid-conflict is refused" "$rc" "1"
224
218
  cwt="$tmp/work/.claude/worktrees/fix+15-hotfix-rel"
@@ -226,7 +220,8 @@ printf 'a\nB\nc\nZ\nd\n' > "$cwt/app.txt"; git -C "$cwt" add app.txt
226
220
  GIT_EDITOR=true git -C "$cwt" cherry-pick --continue >/dev/null 2>&1
227
221
  "$CCKIT" hotfix "$CONF" --base rel >/dev/null 2>"$tmp/err"; rc=$?
228
222
  t "after --continue the re-run finishes" "$rc" "0"
229
- tc "$GH_LOG" '^pr create .*--base rel ' "…opening the PR against the chosen base"
223
+ tc "$GH_LOG" "${PR_POST}.*\"base\":\"rel\"," "…opening the PR against the chosen base"
224
+ t "no gh subcommand ran in the whole run" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
230
225
 
231
226
  [ "$fail" -eq 0 ] && echo "kto-hotfix: all passed" || echo "kto-hotfix: FAILURES"
232
227
  exit "$fail"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  # kto-task-close-test.sh — `cckit close` closes with a reason from the close-reason set, maps it to
3
3
  # GitHub's state_reason, still posts the summary and still sets the board to Done (#377).
4
- # Hermetic: stubbed gh and board helpers. Run: bash scripts/lib/kto-task-close-test.sh
4
+ # Hermetic: the forge shim (REST over a curl stand-in) and stubbed board helpers. Run: bash scripts/lib/kto-task-close-test.sh
5
5
  # errors: strict — a test runner: rc 1 on any failed assertion
6
6
  set -u
7
7
  LIB="$(cd "$(dirname "$0")" && pwd)"
@@ -12,19 +12,12 @@ tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2
12
12
  command -v jq >/dev/null 2>&1 || { echo "kto-task-close-test: jq required" >&2; exit 1; }
13
13
 
14
14
  tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
15
- export GH_LOG="$tmp/gh.log" GH_STATE="OPEN"
16
- mkdir -p "$tmp/bin"
17
- cat > "$tmp/bin/gh" <<'SH'
18
- #!/usr/bin/env bash
19
- echo "$*" >> "$GH_LOG"
20
- case "$1 $2" in
21
- "issue view") printf '{"state":"%s","projectItems":[]}\n' "$GH_STATE" ;;
22
- *) exit 0 ;;
23
- esac
24
- SH
25
- chmod +x "$tmp/bin/gh"
26
- export PATH="$tmp/bin:$PATH" KIT_REPO="o/r" KIT_PROJECTS_V2="true"
27
- unset KIT_CONFIG
15
+ export GH_LOG="$tmp/gh.log" GH_CLOSED=""
16
+ # shellcheck source=/dev/null
17
+ . "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
18
+ export PATH="$tmp/bin:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
19
+ export KIT_REPO="o/r" KIT_PROJECTS_V2="true"
20
+ unset KIT_CONFIG CLAUDE_CODE_REMOTE
28
21
 
29
22
  # shellcheck source=/dev/null
30
23
  . "$LIB/kit-task-ops.sh"
@@ -35,30 +28,37 @@ project_find_item_by_issue() { echo "ITEM-$1"; }
35
28
  project_set_single_select() { echo "$*" >> "$BOARD_LOG"; }
36
29
 
37
30
  run() { : > "$GH_LOG"; : > "$BOARD_LOG"; kto_task_close "$@" >/dev/null 2>"$tmp/err"; echo $?; }
38
- closed() { grep -E '^issue close ' "$GH_LOG" | sed -n 1p; }
31
+ # A close is one PATCH repos/o/r/issues/<n> {"state":"closed","state_reason":…}; the summary is a POST comment first.
32
+ CLOSE='^PATCH repos/o/r/issues/'
33
+ COMMENT='^POST repos/o/r/issues/'
39
34
 
40
35
  t "default close succeeds" "$(run 5 "Shipped in #9.")" 0
41
- tc "$GH_LOG" '^issue close 5 --repo o/r --reason completed --comment Shipped in #9\.$' "default reason is completed, with the summary"
36
+ tc "$GH_LOG" "${CLOSE}5 \{\"state\":\"closed\",\"state_reason\":\"completed\"\}$" "default reason is completed"
37
+ tc "$GH_LOG" "${COMMENT}5/comments \{\"body\":\"Shipped in #9\.\"\}$" "with the summary as a comment"
42
38
  tc "$BOARD_LOG" '^ITEM-5 SF DONE$' "the board goes to Done"
43
39
 
44
40
  t "--reason not-planned succeeds" "$(run 6 "Measured; not worth it." --reason not-planned)" 0
45
- tc "$GH_LOG" '^issue close 6 --repo o/r --reason not planned --comment Measured; not worth it\.$' "not-planned maps to GitHub's 'not planned'"
41
+ tc "$GH_LOG" "${CLOSE}6 \{\"state\":\"closed\",\"state_reason\":\"not_planned\"\}$" "not-planned maps to GitHub's not_planned"
42
+ tc "$GH_LOG" "${COMMENT}6/comments \{\"body\":\"Measured; not worth it\.\"\}$" "not-planned keeps the summary"
46
43
  tc "$BOARD_LOG" '^ITEM-6 SF DONE$' "not planned still sets Done"
47
44
 
48
45
  t "--duplicate-of succeeds without a summary" "$(run 7 --duplicate-of 4)" 0
49
- tc "$GH_LOG" '^issue close 7 --repo o/r --duplicate-of 4 --comment Duplicate of #4\.$' "--duplicate-of links the original and defaults the comment"
46
+ tc "$GH_LOG" "${CLOSE}7 \{\"state\":\"closed\",\"state_reason\":\"duplicate\"\}$" "--duplicate-of closes as a duplicate"
47
+ tc "$GH_LOG" "${COMMENT}7/comments \{\"body\":\"Duplicate of #4\.\"\}$" "and defaults the comment to the original"
50
48
  tc "$BOARD_LOG" '^ITEM-7 SF DONE$' "a duplicate still sets Done"
51
49
  t "--reason duplicate + --duplicate-of" "$(run 7 "Same as #4." --reason duplicate --duplicate-of '#4')" 0
52
- tc "$GH_LOG" '^issue close 7 --repo o/r --duplicate-of 4 --comment Same as #4\.$' "an explicit summary is kept; '#4' is accepted"
50
+ tc "$GH_LOG" "${CLOSE}7 \{\"state\":\"closed\",\"state_reason\":\"duplicate\"\}$" "'#4' is accepted as the duplicate"
51
+ tc "$GH_LOG" "${COMMENT}7/comments \{\"body\":\"Same as #4\.\"\}$" "an explicit summary naming the original is kept as is"
53
52
 
54
53
  t "--superseded-by succeeds" "$(run 8 "Folded into the new effort." --superseded-by 12)" 0
55
- tc "$GH_LOG" '^issue close 8 --repo o/r --reason not planned --comment Folded into the new effort\.$' "superseded closes as not planned"
56
- tc "$GH_LOG" '^Superseded by #12\.$' "and the comment says Superseded by #12"
54
+ tc "$GH_LOG" "${CLOSE}8 \{\"state\":\"closed\",\"state_reason\":\"not_planned\"\}$" "superseded closes as not planned"
55
+ tc "$GH_LOG" "${COMMENT}8/comments \{\"body\":\"Folded into the new effort\.\\\\n\\\\nSuperseded by #12\.\"\}$" "and the comment says Superseded by #12"
57
56
  t "--superseded-by alone defaults the comment" "$(run 8 --superseded-by 12)" 0
58
- tc "$GH_LOG" '^issue close 8 --repo o/r --reason not planned --comment Superseded by #12\.$' "default superseded comment"
57
+ tc "$GH_LOG" "${CLOSE}8 \{\"state\":\"closed\",\"state_reason\":\"not_planned\"\}$" "superseded alone closes as not planned"
58
+ tc "$GH_LOG" "${COMMENT}8/comments \{\"body\":\"Superseded by #12\.\"\}$" "default superseded comment"
59
59
 
60
60
  t "--reason completed is accepted explicitly" "$(run 9 "Done." --reason completed)" 0
61
- tc "$GH_LOG" '^issue close 9 --repo o/r --reason completed ' "explicit completed"
61
+ tc "$GH_LOG" "${CLOSE}9 \{\"state\":\"closed\",\"state_reason\":\"completed\"\}$" "explicit completed"
62
62
 
63
63
  # refusals: nothing is closed and the board is not touched
64
64
  t "an unknown reason is refused (rc 2)" "$(run 10 "x" --reason wontfix)" 2
@@ -68,16 +68,17 @@ t "--duplicate-of contradicting --reason (rc 2)" "$(run 10 "x" --reason complet
68
68
  t "--duplicate-of + --superseded-by (rc 2)" "$(run 10 "x" --duplicate-of 4 --superseded-by 5)" 2
69
69
  t "a non-number --duplicate-of (rc 2)" "$(run 10 "x" --duplicate-of abc)" 2
70
70
  t "no summary and no default (rc 1)" "$(run 10)" 1
71
- t "refusals closed nothing" "$(grep -c 'issue close' "$GH_LOG")" 0
71
+ t "refusals closed nothing" "$(grep -cE '^(PATCH|POST) ' "$GH_LOG")" 0
72
72
  t "refusals left the board alone" "$(wc -l < "$BOARD_LOG" | tr -d ' ')" 0
73
73
 
74
74
  # an already-closed issue: board only, no second close
75
- GH_STATE="CLOSED"
75
+ GH_CLOSED="11"
76
76
  t "an already-closed issue is fine" "$(run 11 "x" --reason not-planned)" 0
77
- t "it is not closed again" "$(grep -c '^issue close' "$GH_LOG")" 0
77
+ t "it is not closed again" "$(grep -cE '^(PATCH|POST) ' "$GH_LOG")" 0
78
+ t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" 0
78
79
  tc "$BOARD_LOG" '^ITEM-11 SF DONE$' "but the board still goes to Done"
79
80
 
80
- t "the dispatcher answers --help" "$("$ROOT/bin/cckit" close --help | cut -c1-19)" "cckit close <issue>"
81
+ t "the dispatcher answers --help" "$("$ROOT/bin/cckit" close --help | sed -n 1p | cut -c1-19)" "cckit close <issue>"
81
82
 
82
83
  [ "$fail" -eq 0 ] && echo "kto-task-close: all passed" || echo "kto-task-close: FAILURES"
83
84
  exit "$fail"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
- # kto-task-new-test.sh — kto_task_new against a stubbed gh (#387): a label the repo does not have
3
- # is dropped with a warning and the issue is still created; with every label present the create
4
- # call is unchanged; a failed create returns non-zero and prints no URL.
2
+ # kto-task-new-test.sh — kto_task_new over the forge shim (#387, E537): a label the repo does not have
3
+ # is dropped with a warning and the issue is still created; with every label present the POST
4
+ # repos/o/r/issues body is unchanged; a failed create returns non-zero and prints no URL.
5
5
  # Run: bash scripts/lib/kto-task-new-test.sh
6
6
  # errors: strict — a test runner: rc 1 on any failed assertion
7
7
  set -u
@@ -13,83 +13,90 @@ tn() { if grep -qE -- "$2" "$1"; then echo "FAIL: $3 (/$2/ in $1)"; fail=1; else
13
13
 
14
14
  tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
15
15
  export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
16
- mkdir -p "$tmp/bin"
17
- # GH_HAVE: the repo's labels, comma-separated. GH_LIST_FAIL=1: `gh label list` fails.
18
- # GH_CREATE_FAIL=1: `gh issue create` fails. Like real gh, a create naming a label the repo does
19
- # not have fails with "could not add label".
20
- cat > "$tmp/bin/gh" <<'SH'
21
- #!/usr/bin/env bash
22
- echo "$*" >> "$GH_LOG"
23
- case "$1 $2" in
24
- "label list")
25
- [ -n "${GH_LIST_FAIL:-}" ] && { echo "gh: HTTP 403" >&2; exit 1; }
26
- printf '%s\n' "$GH_HAVE" | tr ',' '\n' ;;
27
- "issue create")
28
- [ -n "${GH_CREATE_FAIL:-}" ] && { echo "gh: HTTP 500" >&2; exit 1; }
29
- want=""; while [ $# -gt 0 ]; do [ "$1" = "--label" ] && want="${2:-}"; shift; done
30
- for l in $(printf '%s' "$want" | tr ',' ' '); do
31
- case ",$(printf '%s' "$GH_HAVE" | tr 'A-Z' 'a-z')," in *",$l,"*) ;; *) echo "could not add label: '$l' not found" >&2; exit 1 ;; esac
32
- done
33
- echo "https://github.com/o/r/issues/50" ;;
34
- *) exit 0 ;;
35
- esac
36
- SH
37
- chmod +x "$tmp/bin/gh"
38
- export PATH="$tmp/bin:$PATH" KIT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_PROJECTS_V2="false"
39
- unset KIT_CONFIG CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT GH_LIST_FAIL GH_CREATE_FAIL
16
+ # shellcheck source=/dev/null
17
+ . "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
18
+ export PATH="$tmp/bin:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
19
+ export KIT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_PROJECTS_V2="false"
20
+ export GH_N="$tmp/n"
21
+ unset KIT_CONFIG CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT GH_FAIL_EP
40
22
  cd "$tmp" || exit 1
23
+ # have <names…> — the repo's label list (GH_REPO_LABELS), as GET repos/o/r/labels answers it.
24
+ # fresh — an empty request log, and the next created issue is #50.
25
+ fresh() { : > "$GH_LOG"; echo 49 > "$GH_N"; }
26
+ have() { GH_REPO_LABELS="$(printf '%s\n' "$@" | jq -R . | jq -sc 'map({name:.})')"; export GH_REPO_LABELS; }
41
27
 
42
28
  # shellcheck source=/dev/null
43
29
  . "$LIB/kit-task-ops.sh"
44
30
 
45
31
  # ── a missing label is a warning, not an abort ────────────────────────────────────────────────────
46
- export GH_HAVE="kind:task,priority:p2,role:backend"
47
- : > "$GH_LOG"
32
+ have kind:task priority:p2 role:backend
33
+ fresh
48
34
  kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
49
35
  t "missing kind label: rc 0" "$rc" "0"
50
36
  tc "$tmp/out" '^✓ https://github.com/o/r/issues/50$' "missing kind label: prints the issue URL"
51
37
  t "missing kind label: echoes the number" "$(tail -1 "$tmp/out")" "50"
52
38
  tc "$tmp/err" "kind:feat" "missing kind label: the warning names kind:feat"
53
- tc "$GH_LOG" '^issue create .*--label priority:p2,role:backend( |$)' "missing kind label: only existing labels are sent"
54
- tn "$GH_LOG" '^issue create .*kind:feat' "missing kind label: kind:feat is not sent"
55
- tn "$GH_LOG" '^label create' "missing kind label: no label is created"
39
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"Test","body":"x","labels":\["priority:p2","role:backend"\]\}$' "missing kind label: only existing labels are sent"
40
+ tn "$GH_LOG" '^POST repos/o/r/issues .*kind:feat' "missing kind label: kind:feat is not sent"
41
+ tn "$GH_LOG" '^POST repos/o/r/labels' "missing kind label: no label is created"
42
+ tc "$GH_LOG" '^POST repos/o/r/issues/50/assignees \{"assignees":\["me"\]\}$' "missing kind label: the author is assigned"
56
43
 
57
44
  # Label names are case-insensitive on GitHub.
58
- export GH_HAVE="Kind:Feat,priority:p2,role:backend"
59
- : > "$GH_LOG"
45
+ have Kind:Feat priority:p2 role:backend
46
+ fresh
60
47
  kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
61
48
  t "case-insensitive match: rc 0" "$rc" "0"
62
49
  t "case-insensitive match: no warning" "$(grep -c 'kind:feat' "$tmp/err")" "0"
63
- tc "$GH_LOG" '^issue create .*--label kind:feat,priority:p2,role:backend ' "case-insensitive match: the label is sent"
50
+ tc "$GH_LOG" '^POST repos/o/r/issues .*"labels":\["kind:feat","priority:p2","role:backend"\]' "case-insensitive match: the label is sent"
64
51
 
65
- # ── every label missing: the issue is created with no --label at all ──────────────────────────────
66
- export GH_HAVE="bug"
67
- : > "$GH_LOG"
52
+ # ── every label missing: the issue is created with no labels field at all ──────────────────────────────
53
+ have bug
54
+ fresh
68
55
  kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
69
56
  t "no label exists: rc 0" "$rc" "0"
70
57
  tc "$tmp/out" '^✓ https://github.com/o/r/issues/50$' "no label exists: prints the issue URL"
71
- tn "$GH_LOG" '^issue create .*--label' "no label exists: no --label flag"
58
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"Test","body":"x"\}$' "no label exists: no labels field"
72
59
  t "no label exists: three labels warned" "$(grep -cE 'kind:feat|priority:p2|role:backend' "$tmp/err")" "3"
73
60
 
74
- # ── all labels present: the create call is unchanged ──────────────────────────────────────────────
75
- export GH_HAVE="kind:feat,priority:p2,role:backend"
76
- : > "$GH_LOG"
61
+ # ── all labels present: the create body is unchanged ──────────────────────────────────────────────
62
+ have kind:feat priority:p2 role:backend
63
+ fresh
77
64
  kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
78
65
  t "all labels present: rc 0" "$rc" "0"
79
- tc "$GH_LOG" '^issue create --repo o/r --title Test --body .*--label kind:feat,priority:p2,role:backend --assignee @me$' "all labels present: the create call is unchanged"
66
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"Test","body":"x","labels":\["kind:feat","priority:p2","role:backend"\]\}$' "all labels present: the create body is unchanged"
67
+ tc "$GH_LOG" '^POST repos/o/r/issues/50/assignees \{"assignees":\["me"\]\}$' "all labels present: the author is assigned"
80
68
  t "all labels present: no warning" "$(wc -c < "$tmp/err" | tr -d ' ')" "0"
81
69
 
82
70
  # ── the label list cannot be read: send every label, as before ────────────────────────────────────
83
- : > "$GH_LOG"
84
- GH_LIST_FAIL=1 kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
71
+ fresh
72
+ GH_FAIL_EP="repos/o/r/labels" kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
85
73
  t "unreadable label list: rc 0" "$rc" "0"
86
- tc "$GH_LOG" '^issue create .*--label kind:feat,priority:p2,role:backend ' "unreadable label list: every label is sent"
74
+ tc "$GH_LOG" '^POST repos/o/r/issues .*"labels":\["kind:feat","priority:p2","role:backend"\]' "unreadable label list: every label is sent"
87
75
 
88
76
  # ── the create itself fails: non-zero, no URL ─────────────────────────────────────────────────────
89
- : > "$GH_LOG"
90
- GH_CREATE_FAIL=1 kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
77
+ fresh
78
+ GH_FAIL_EP="repos/o/r/issues" kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
91
79
  t "create fails: rc non-zero" "$([ "$rc" -ne 0 ] && echo nonzero)" "nonzero"
92
80
  t "create fails: prints nothing on stdout" "$(wc -c < "$tmp/out" | tr -d ' ')" "0"
81
+ t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
82
+
83
+ # ── the board Status (E546.2): no milestone -> Backlog when the board has it, else Todo ──────────────
84
+ have kind:feat priority:p2 role:backend
85
+ export KIT_PROJECTS_V2="true"
86
+ load_project_ids() { STATUS_FIELD_ID="SF"; STATUS_OPT_TODO="OPT_TODO"; return 0; }
87
+ project_add_item() { echo "ITEM"; }
88
+ project_set_single_select() { echo "set $1 $2 $3" >> "$tmp/board"; }
89
+ : > "$tmp/board"; fresh
90
+ STATUS_OPT_BACKLOG="OPT_BACKLOG" kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"
91
+ tc "$tmp/board" '^set ITEM SF OPT_BACKLOG$' "no milestone, a Backlog option: Status is Backlog"
92
+ tn "$tmp/board" 'OPT_TODO' "no milestone, a Backlog option: Status is not Todo"
93
+ : > "$tmp/board"; fresh
94
+ STATUS_OPT_BACKLOG="OPT_BACKLOG" kto_task_new "Test" backend feat p2 "M1" "" "" x >"$tmp/out" 2>"$tmp/err"
95
+ tc "$tmp/board" '^set ITEM SF OPT_TODO$' "a milestone named: Status is Todo"
96
+ : > "$tmp/board"; fresh
97
+ kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"
98
+ tc "$tmp/board" '^set ITEM SF OPT_TODO$' "no Backlog option on the board: Status stays Todo"
99
+ export KIT_PROJECTS_V2="false"
93
100
 
94
101
  [ "$fail" -eq 0 ] && echo "kto-task-new: all passed" || echo "kto-task-new: FAILURES"
95
102
  exit "$fail"