@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
@@ -7,7 +7,9 @@
7
7
  # version-bump.sh --emit echo `bump=<level>` + `next=<version>` (for $GITHUB_OUTPUT)
8
8
  # version-bump.sh --write <version> set the version in cckit.config.json + plugin.json + package.json
9
9
  #
10
- # Bump rules (Conventional Commits): a `feat!:`/`type!:` or a `BREAKING CHANGE` footer -> major;
10
+ # Bump rules (Conventional Commits): a `feat!:`/`type!:` or a `BREAKING CHANGE` footer -> major,
11
+ # or MINOR while the major is 0 (the same rule as `bump-minor-pre-major: true` in
12
+ # release-please-config.json: cckit stays below 1.0 until the maintainer decides otherwise);
11
13
  # `feat:` -> minor; `fix|perf|refactor|revert:` -> patch; non-functional types
12
14
  # (`docs|chore|style|test|ci|build`) and anything else -> none (no release).
13
15
  # no commits -> none (no release).
@@ -32,7 +34,7 @@ vb_next() {
32
34
  local cur="${1:-0.0.0}" level="$2" M m p rest
33
35
  M="${cur%%.*}"; rest="${cur#*.}"; m="${rest%%.*}"; p="${rest#*.}"
34
36
  case "$level" in
35
- major) echo "$((M+1)).0.0" ;;
37
+ major) if [ "$M" -eq 0 ]; then echo "0.$((m+1)).0"; else echo "$((M+1)).0.0"; fi ;;
36
38
  minor) echo "$M.$((m+1)).0" ;;
37
39
  patch) echo "$M.$m.$((p+1))" ;;
38
40
  *) echo "$cur" ;;
@@ -55,7 +55,7 @@ yes "the receipt contract names the PR verb" "$rc" "cckit pr 41"
55
55
  yes "the receipt contract names the no-op close" "$rc" "cckit close 41"
56
56
  # The contract must name the verb that PERSISTS it (#322). A prompt that only asks the worker to
57
57
  # "report" leaves the record in the pane, which is what the receipt exists to replace.
58
- yes "the receipt contract names the recording verb" "$rc" "cckit receipt 41 --stage"
58
+ yes "the receipt contract names the recording verb" "$rc" "cckit agent receipt 41 --stage"
59
59
  yes "the receipt contract says a re-run is safe" "$rc" "rewrites its own attempt"
60
60
 
61
61
  # ── unbounded: everything survives ─────────────────────────────────────────────────────────────
@@ -49,7 +49,7 @@ If no change is needed, close the issue yourself with the reason:
49
49
 
50
50
  Then RECORD your receipt — this is the only durable record of the run, and your pane is not one:
51
51
 
52
- cckit receipt $num --stage <your stage> <<'RECEIPT'
52
+ cckit agent receipt $num --stage <your stage> <<'RECEIPT'
53
53
  outcome: merged | pr-open | closed-no-op | blocked
54
54
  url: <PR or issue URL>
55
55
  gate: pass | fail — <the failing check, if any>
@@ -44,36 +44,41 @@ if [ -n "${WT_TEST_INNER:-}" ]; then
44
44
  # willing to delete a misnamed live branch — the failure mode this whole lib exists to prevent.
45
45
  check "feat/1604a-parser" "1604" # non-sub kind, suffix still protects
46
46
  check "feat+1604a-parser" "1604" # same, worktree dirname form
47
- # wt_issue_state (#330): failed is not empty. A gh that exits non-zero answers `unknown`; a gh
48
- # that says "no such issue" answers empty; only open/closed pass through.
47
+ # wt_issue_state (#330): failed is not empty. The forge (test-forge-shim.sh) answers the REST read
48
+ # of repos/<r>/issues/<n>: an HTTP error answers `unknown`; a 404 ("no such issue") answers empty;
49
+ # only open/closed pass through. With no forge configured the state is `unknown`.
49
50
  tmp=$(mktemp -d)
50
- mkdir "$tmp/bin" "$tmp/nogh"
51
- for c in tr grep head; do p_=$(command -v "$c"); [ -n "$p_" ] && ln -sf "$p_" "$tmp/nogh/$c"; done
52
- state() { # state <label> <want> <gh script body> [transport]
53
- printf '#!/bin/sh\n%s\n' "$3" > "$tmp/bin/gh"; chmod +x "$tmp/bin/gh"
54
- got=$(PATH="$tmp/bin:$PATH" CCKIT_GH_TRANSPORT="${4:-graphql}" KIT_REPO=o/r wt_issue_state 41 o/r)
51
+ . "$dir/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
52
+ GH_LOG="$tmp/gh.log"; export GH_LOG; : > "$GH_LOG"
53
+ export GH_TOKEN=test-token CCKIT_FORGE=github
54
+ state() { # state <label> <want> <fixture snippet: sets out/code for the shim> [GH_CLOSED] [GH_FAIL_EP]
55
+ printf '%s\n' "$3" > "$tmp/fixture"
56
+ got=$(PATH="$tmp/bin:$PATH" GH_FIXTURE="$tmp/fixture" GH_CLOSED="${4:-}" GH_FAIL_EP="${5:-}" KIT_REPO=o/r wt_issue_state 41 o/r)
55
57
  if [ "$got" != "$2" ]; then
56
58
  echo "FAIL($WT_TEST_INNER): wt_issue_state $1 -> '[$got]', want '[$2]'"
57
59
  fail=1
58
60
  fi
59
61
  }
60
- state "open (graphql)" "open" 'echo OPEN'
61
- state "closed (rest)" "closed" 'echo closed' rest
62
- state "gh fails (graphql)" "unknown" 'echo "GraphQL: API rate limit exceeded" >&2; exit 1'
63
- state "gh fails (rest)" "unknown" 'echo "gh: Server Error (HTTP 502)" >&2; exit 1' rest
64
- state "no such issue (gql)" "" 'echo "GraphQL: Could not resolve to an Issue with the number of 41." >&2; exit 1'
65
- state "no such issue (rest)" "" 'echo "gh: Not Found (HTTP 404)" >&2; exit 1' rest
66
- state "empty success" "" 'exit 0'
67
- got=$(PATH="$tmp/nogh" wt_issue_state 41 o/r)
68
- [ "$got" = "unknown" ] || { echo "FAIL($WT_TEST_INNER): wt_issue_state with no gh -> '[$got]', want '[unknown]'"; fail=1; }
62
+ state "open" "open" ':'
63
+ state "closed" "closed" ':' 41
64
+ state "rate limit (403)" "unknown" 'out='"'"'{"message":"API rate limit exceeded"}'"'"'; code=403'
65
+ state "server error (502)" "unknown" 'out='"'"'{"message":"Server Error"}'"'"'; code=502'
66
+ state "no such issue (404)" "" ':' "" "repos/o/r/issues/41"
67
+ state "empty success" "" 'out=""'
68
+ t_=$(grep -c '^GET repos/o/r/issues/41 ' "$GH_LOG")
69
+ [ "$t_" = "6" ] || { echo "FAIL($WT_TEST_INNER): every state read is GET repos/o/r/issues/41 -> '[$t_]', want '[6]'"; fail=1; }
70
+ t_=$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")
71
+ [ "$t_" = "0" ] || { echo "FAIL($WT_TEST_INNER): no gh subcommand ran -> '[$t_]', want '[0]'"; fail=1; }
72
+ got=$(PATH="$tmp/bin:$PATH" CCKIT_FORGE=none wt_issue_state 41 o/r)
73
+ [ "$got" = "unknown" ] || { echo "FAIL($WT_TEST_INNER): wt_issue_state with no forge -> '[$got]', want '[unknown]'"; fail=1; }
69
74
  got=$(PATH="$tmp/bin:$PATH" wt_issue_state "" o/r)
70
75
  [ -z "$got" ] || { echo "FAIL($WT_TEST_INNER): wt_issue_state with no number -> '[$got]', want '[]'"; fail=1; }
71
76
  # An unknown state is not a protection claim — gc reports it as UNKNOWN itself.
72
- printf '#!/bin/sh\nexit 1\n' > "$tmp/bin/gh"
73
- got=$(PATH="$tmp/bin:$PATH" CCKIT_GH_TRANSPORT=graphql wt_protected_reason task/41-x o/r)
77
+ printf '%s\n' 'out='"'"'{"message":"Server Error"}'"'"'; code=502' > "$tmp/fixture"
78
+ got=$(PATH="$tmp/bin:$PATH" GH_FIXTURE="$tmp/fixture" wt_protected_reason task/41-x o/r)
74
79
  [ -z "$got" ] || { echo "FAIL($WT_TEST_INNER): wt_protected_reason on a failed read -> '[$got]', want '[]'"; fail=1; }
75
80
  rm -rf "$tmp"
76
- [ "$fail" -eq 0 ] && echo "OK($WT_TEST_INNER): 31 cases"
81
+ [ "$fail" -eq 0 ] && echo "OK($WT_TEST_INNER): 33 cases"
77
82
  exit "$fail"
78
83
  fi
79
84
 
@@ -16,6 +16,12 @@
16
16
  # errors: mixed — name parsing is pure; the issue-open check needs gh
17
17
 
18
18
  # The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
19
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
20
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
21
+ # shellcheck source=/dev/null
22
+ . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
23
+ fi
24
+
19
25
  if ! command -v cckit_gh_rest >/dev/null 2>&1; then
20
26
  _ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
21
27
  # shellcheck source=/dev/null
@@ -90,15 +96,9 @@ wt_issue_number() {
90
96
  wt_issue_state() {
91
97
  local n="$1" repo="${2:-}" out
92
98
  [[ -z "$n" ]] && return 0
93
- command -v gh >/dev/null 2>&1 || { printf 'unknown\n'; return 0; }
94
- if cckit_gh_rest; then
95
- repo="${repo:-${KIT_REPO:-}}"; [[ -n "$repo" ]] || { printf 'unknown\n'; return 0; }
96
- out="$(gh api "repos/$repo/issues/$n" --jq .state 2>&1)" || { _wt_issue_state_failed "$out"; return 0; }
97
- else
98
- local args=(issue view "$n" --json state --jq .state)
99
- [[ -n "$repo" ]] && args+=(--repo "$repo")
100
- out="$(gh "${args[@]}" 2>&1)" || { _wt_issue_state_failed "$out"; return 0; }
101
- fi
99
+ forge_available || { forge_note_none "${CCKIT_VERB:-gc}" "issue states cannot be read; every issue reads unknown and its branch is kept"; printf 'unknown\n'; return 0; }
100
+ repo="${repo:-${KIT_REPO:-}}"; [[ -n "$repo" ]] || repo="$(forge_repo_from_git 2>/dev/null)" || { printf 'unknown\n'; return 0; }
101
+ out="$(forge_rest "repos/$repo/issues/$n" --jq .state 2>&1)" || { _wt_issue_state_failed "$out"; return 0; }
102
102
  printf '%s\n' "$out" | tr '[:upper:]' '[:lower:]' | grep -E -x 'open|closed' | sed -n 1p
103
103
  return 0
104
104
  }
@@ -107,7 +107,7 @@ wt_issue_state() {
107
107
  # answer (REST 404, GraphQL "Could not resolve to an Issue") is a definite absence and stays empty;
108
108
  # every other failure is `unknown`.
109
109
  _wt_issue_state_failed() {
110
- if grep -qiE 'HTTP 404|Could not resolve to an? (Issue|PullRequest)' <<<"$1"; then return 0; fi
110
+ if grep -qiE 'HTTP 404|answered 404 on|Could not resolve to an? (Issue|PullRequest)' <<<"$1"; then return 0; fi
111
111
  printf 'unknown\n'
112
112
  }
113
113
 
@@ -6,7 +6,7 @@
6
6
  # fetch, branch or worktree; `--force` / KIT_FORCE=1 proceeds; a dead session's claim is reaped;
7
7
  # the claimant's own re-run stays a no-op; `cckit claims` lists and writes nothing.
8
8
  #
9
- # Hermetic: a throwaway repo with a local bare origin, a stubbed `gh` (no network, no auth) and a
9
+ # Hermetic: a throwaway repo with a local bare origin, the forge shim in place of GitHub (no network) and a
10
10
  # stubbed `zoxide` (so no temp path lands in the developer's jump database). A "session" is a
11
11
  # background `sleep` whose pid is handed to wt_start through KIT_SESSION_PID.
12
12
  #
@@ -33,21 +33,16 @@ cleanup() {
33
33
  trap cleanup EXIT INT TERM
34
34
 
35
35
  # ── fixture: stubs, a bare origin with `main`, and a clone to start worktrees from ─────────────
36
- mkdir -p "$tmp/bin"
37
- cat > "$tmp/bin/gh" <<'SH'
38
- #!/usr/bin/env bash
39
- # Every call is logged, so a test can assert a refusal made NO GitHub read.
40
- printf '%s\n' "$*" >> "${GH_CALL_LOG:-/dev/null}"
41
- case "$*" in
42
- *"issue view"*) echo '{"title":"Claimed thing","labels":[{"name":"kind:task"}]}' ;;
43
- *graphql*) echo '{"data":{}}' ;;
44
- *) echo '[]' ;;
45
- esac
46
- SH
36
+ # The forge shim (test-forge-shim.sh): the issue read answers title + kind label over REST, every
37
+ # request is logged, and a gh subcommand fails — so a test can assert a refusal made NO GitHub read.
38
+ # shellcheck source=/dev/null
39
+ . "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
40
+ export GH_TITLE="Claimed thing" GH_LABELS='[{"name":"kind:task"}]'
41
+ export GH_TOKEN=test-token CCKIT_FORGE=github
47
42
  printf '#!/bin/sh\nexit 0\n' > "$tmp/bin/zoxide"
48
- chmod +x "$tmp/bin/gh" "$tmp/bin/zoxide"
43
+ chmod +x "$tmp/bin/zoxide"
49
44
  PATH="$tmp/bin:$PATH"; export PATH
50
- export GH_CALL_LOG="$tmp/gh.calls"; : > "$GH_CALL_LOG"
45
+ export GH_LOG="$tmp/gh.calls"; : > "$GH_LOG"
51
46
 
52
47
  git init -q --bare "$tmp/origin.git"
53
48
  git init -q "$tmp/repo"
@@ -79,6 +74,8 @@ out="$(start_as "$SESS_A" 7 2>/dev/null)"; rc=$?
79
74
  t "first start succeeds" "$rc" "0"
80
75
  WT7="$REPO/.claude/worktrees/task+7-claimed-thing"
81
76
  t "first start prints path|branch|issue" "$out" "$WT7|task/7-claimed-thing|7"
77
+ has "the issue is read over REST" "$(cat "$GH_LOG")" "GET repos/octo/fx/issues/7 "
78
+ t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
82
79
  t "claim file written" "$([ -f "$REG/issue-7.json" ] && echo yes || echo no)" "yes"
83
80
  t "claim records the session pid" "$(jq -r .pid "$REG/issue-7.json" 2>/dev/null)" "$SESS_A"
84
81
  t "claim records the worktree" "$(jq -r .worktree "$REG/issue-7.json" 2>/dev/null)" "$WT7"
@@ -98,7 +95,7 @@ jq -n --argjson pid "$SESS_A" --arg host "$(hostname)" --arg wt "$REPO/.claude/w
98
95
  --argjson started "$(date +%s)" \
99
96
  '{issue:9, branch:"task/9-claimed-thing", worktree:$wt, cwd:$wt, pid:$pid, host:$host, started:$started}' \
100
97
  > "$REG/issue-9.json"
101
- b_before="$(branches)"; w_before="$(worktrees)"; : > "$GH_CALL_LOG"
98
+ b_before="$(branches)"; w_before="$(worktrees)"; : > "$GH_LOG"
102
99
  fetch_before="$(stat -c %Y "$REPO/.git/FETCH_HEAD" 2>/dev/null || stat -f %m "$REPO/.git/FETCH_HEAD" 2>/dev/null)"
103
100
  err="$(start_as "$SESS_B" 9 2>&1 >/dev/null)"; rc=$?
104
101
  t "second session on a claimed issue is refused (rc 1)" "$rc" "1"
@@ -107,7 +104,7 @@ has "refusal names the escape hatch" "$err" "--force"
107
104
  t "refusal creates no branch" "$(branches)" "$b_before"
108
105
  t "refusal creates no worktree" "$(worktrees)" "$w_before"
109
106
  t "refusal creates no worktree dir" "$([ -e "$REPO/.claude/worktrees/task+9-claimed-thing" ] && echo yes || echo no)" "no"
110
- t "refusal makes no gh call (it runs before the issue read)" "$(wc -l < "$GH_CALL_LOG" | tr -d ' ')" "0"
107
+ t "refusal makes no forge call (it runs before the issue read)" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
111
108
  t "refusal runs before the fetch (FETCH_HEAD untouched)" \
112
109
  "$(stat -c %Y "$REPO/.git/FETCH_HEAD" 2>/dev/null || stat -f %m "$REPO/.git/FETCH_HEAD" 2>/dev/null)" "$fetch_before"
113
110
  t "refusal leaves the claim with its owner" "$(jq -r .pid "$REG/issue-9.json")" "$SESS_A"
@@ -4,7 +4,8 @@
4
4
  # Family 1 of kit-engine-boundary.md (rule #1/#2): one bash home for the op, consumed by the
5
5
  # kit-task-start skill, scripts/orchestrate.sh, and `kit task start`. No second implementation.
6
6
  #
7
- # wt_start [--force] <issue-number> [slug-override]
7
+ # wt_start [--force] <issue-number|E<n>|E<n>.<step>> [slug-override]
8
+ # A token resolves first: E<n> is issue n, E<n>.<step> the effort's sub at that step.
8
9
  # Refuses (rc 1, before any fetch / branch / worktree) when another LIVE session already holds
9
10
  # the issue's claim in <git-common-dir>/kit-sessions (session-registry.sh). `--force` or
10
11
  # KIT_FORCE=1 starts anyway and takes the claim over.
@@ -16,6 +17,12 @@
16
17
  # errors: strict — rc 1 on failure; a half-made worktree is never reported as ready
17
18
 
18
19
  # The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
20
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
21
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
22
+ # shellcheck source=/dev/null
23
+ . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
24
+ fi
25
+
19
26
  if ! command -v cckit_gh_rest >/dev/null 2>&1; then
20
27
  _ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
21
28
  # shellcheck source=/dev/null
@@ -51,6 +58,42 @@ _wt_kind_prefix() {
51
58
 
52
59
  WT_START_REPO="${WT_START_REPO:-${KIT_REPO:-}}"
53
60
 
61
+ # The token parser (naming.sh, E546.1): `start E545` / `start E545.1` name an effort or a sub.
62
+ if ! command -v naming_token_parse >/dev/null 2>&1; then
63
+ _wt_naming="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/naming.sh"
64
+ # shellcheck source=/dev/null
65
+ [ -f "$_wt_naming" ] && . "$_wt_naming"
66
+ unset _wt_naming
67
+ fi
68
+
69
+ # _wt_resolve_token <token> — the issue number a token names (rules/naming-and-ids.md). E<n> is
70
+ # issue n. E<n>.<step> reads effort n's native sub-issues and takes the one titled [E<n>.<step>]
71
+ # (or the legacy [Effort <n>] <step> · ), else the sub at position <step>. rc 1, with the reason on
72
+ # stderr, when no sub matches or the sub-issues cannot be read.
73
+ _wt_resolve_token() {
74
+ local tok="$1" parsed n s subs hit
75
+ parsed="$(naming_token_parse "$tok")" || { echo "wt_start: '$tok' is not an E<n> or E<n>.<step> token" >&2; return 1; }
76
+ n="${parsed%% *}"; s=""
77
+ case "$parsed" in *" "*) s="${parsed#* }" ;; esac
78
+ if [ -z "$s" ]; then printf '%s' "$n"; return 0; fi
79
+ if ! forge_available; then
80
+ echo "wt_start: $tok is step $s of effort $n; resolving it reads the effort's sub-issues and no forge is configured — pass the sub's issue number" >&2
81
+ return 1
82
+ fi
83
+ subs="$(forge_rest "repos/$WT_START_REPO/issues/$n/sub_issues" -X GET -f per_page=100 \
84
+ --jq '.[] | "\(.number)\t\(.title // "")"' 2>/dev/null)" \
85
+ || { echo "wt_start: could not read the sub-issues of effort $n" >&2; return 1; }
86
+ hit="$(printf '%s\n' "$subs" | awk -F'\t' -v t="[E$n.$s] " -v l="[Effort $n] $s " \
87
+ 'index($2, t) == 1 || index($2, l) == 1 { print $1; exit }')"
88
+ [ -n "$hit" ] || hit="$(printf '%s\n' "$subs" | awk -F'\t' -v s="$s" 'NF && ++i == s { print $1; exit }')"
89
+ if [ -z "$hit" ]; then
90
+ echo "wt_start: $tok not found — effort $n has no sub titled [E$n.$s] and fewer than $s sub-issues" >&2
91
+ return 1
92
+ fi
93
+ echo "[$tok] → #$hit" >&2
94
+ printf '%s' "$hit"
95
+ }
96
+
54
97
  # _wt_set_port <app-env-file> <port> <issue-num> — append a per-worktree dev PORT to an app's
55
98
  # .env.local, but only where one exists (i.e. the app is locally runnable). Idempotent: an existing
56
99
  # PORT= line wins.
@@ -611,6 +654,10 @@ wt_start() {
611
654
  esac
612
655
  done
613
656
  [[ -n "$num" ]] || { echo "wt_start: issue number required" >&2; return 1; }
657
+ # An E<n> / E<n>.<step> token resolves to its issue number before anything else runs.
658
+ case "$num" in
659
+ [Ee][0-9]*) num="$(_wt_resolve_token "$num")" || return 1 ;;
660
+ esac
614
661
 
615
662
  root="$(git worktree list --porcelain | awk '/^worktree / && !hit {print $2; hit=1}')"
616
663
  [[ -n "$root" ]] || { echo "wt_start: not in a git repo" >&2; return 1; }
@@ -632,14 +679,17 @@ wt_start() {
632
679
  # The board helpers load lazily, further down: Status is otherwise set server-side by built-in
633
680
  # automations (Item closed→Done, PR merged→Done), and In Progress is the one write wt_start owns.
634
681
 
635
- if cckit_gh_rest; then
682
+ # Without a forge the issue is not read: the branch is task/<N>-<slug> with the slug given on the
683
+ # command line, else issue-<N>. Said once, never silent.
684
+ if forge_available; then
636
685
  meta="$(gh_rest_issue_json "$WT_START_REPO" "$num" 2>/dev/null)" || { echo "[#$num] issue not found" >&2; return 1; }
686
+ title="$(echo "$meta" | jq -r '.title')"
687
+ kind="$(echo "$meta" | jq -r '([.labels[].name | select(startswith("kind:"))][0] // "kind:task") | sub("^kind:";"")')"
637
688
  else
638
- meta="$(gh issue view "$num" --repo "$WT_START_REPO" --json title,labels 2>/dev/null)" \
639
- || { echo "[#$num] issue not found" >&2; return 1; }
689
+ forge_note_none start "issue #$num is not read; the branch is task/$num-${slug_override:-issue-$num} (pass a slug to name it)"
690
+ title=""; kind="task"
691
+ [[ -n "$slug_override" ]] || slug_override="issue-$num"
640
692
  fi
641
- title="$(echo "$meta" | jq -r '.title')"
642
- kind="$(echo "$meta" | jq -r '([.labels[].name | select(startswith("kind:"))][0] // "kind:task") | sub("^kind:";"")')"
643
693
  kind="$(_wt_kind_prefix "$kind")"
644
694
  if [[ -n "$slug_override" ]]; then
645
695
  slug="$slug_override"
@@ -727,7 +777,7 @@ wt_start() {
727
777
  item="$(project_find_item_by_issue "$num" 2>/dev/null)"
728
778
  if [[ -z "$item" ]]; then
729
779
  local content_id
730
- content_id="$(gh api graphql -f query='query($o:String!,$r:String!,$n:Int!){repository(owner:$o,name:$r){issue(number:$n){id}}}' \
780
+ content_id="$(forge_rest graphql -f query='query($o:String!,$r:String!,$n:Int!){repository(owner:$o,name:$r){issue(number:$n){id}}}' \
731
781
  -F o="${WT_START_REPO%/*}" -F r="${WT_START_REPO#*/}" -F n="$num" --jq '.data.repository.issue.id' 2>/dev/null)"
732
782
  [[ -n "$content_id" ]] && item="$(project_add_item "$content_id" 2>/dev/null)"
733
783
  fi
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # loose-issues-test.sh — the loose-issue count (E546.2) over the forge shim: scripts/lib/loose-issues.sh
4
+ # and `cckit doctor --loose [--ratchet]`. Fixture: an effort, a sub-issue (parent_issue_url), a
5
+ # standalone issue and a pull request -> one loose issue. Then the board marker (Status = Backlog),
6
+ # the ratchet (pass, fail, not judged) and the forge-less run (a skip line, never a silent pass).
7
+ # Run: bash scripts/loose-issues-test.sh
8
+ # errors: strict — a test runner: rc 1 on any failed assertion
9
+ set -u
10
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11
+ # shellcheck source=/dev/null
12
+ . "$ROOT/scripts/lib/test-env.sh" && test_env_seal
13
+ DOCTOR="$ROOT/scripts/kit-doctor.sh"
14
+ fail=0
15
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
16
+ has() { if grep -qF -- "$3" <<<"$2"; then echo "ok: $1"; else echo "FAIL: $1 -> '$3' not in: $2"; fail=1; fi; }
17
+ hasnt() { if grep -qF -- "$3" <<<"$2"; then echo "FAIL: $1 -> '$3' found in: $2"; fail=1; else echo "ok: $1"; fi; }
18
+
19
+ command -v jq >/dev/null 2>&1 || { echo "loose-issues-test: jq absent — skipping (dependency-light gate)"; exit 0; }
20
+
21
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
22
+ tmp="$(cd "$tmp" && pwd -P)"
23
+ # shellcheck source=/dev/null
24
+ . "$ROOT/scripts/lib/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
25
+ export PATH="$tmp/bin:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
26
+ export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
27
+ export GH_ISSUES='[
28
+ {"number":10,"title":"[Effort] 10 · demo","state":"open","labels":[{"name":"effort"}]},
29
+ {"number":11,"title":"[Effort 10] 1 · a sub","state":"open","labels":[],"parent_issue_url":"https://api.github.com/repos/o/r/issues/10"},
30
+ {"number":12,"title":"Fix the login","state":"open","labels":[{"name":"kind:fix"}],"parent_issue_url":null},
31
+ {"number":13,"title":"a pull request","state":"open","labels":[],"pull_request":{}}
32
+ ]'
33
+
34
+ # project <name> <config-json> -> a throwaway project (git repo, root cckit.config.json); echoes its dir.
35
+ project() {
36
+ mkdir -p "$tmp/$1"
37
+ git -C "$tmp/$1" init -q 2>/dev/null
38
+ printf '%s\n' "$2" > "$tmp/$1/cckit.config.json"
39
+ printf '%s\n' "$tmp/$1"
40
+ }
41
+ off="$(project off '{"github":{"repo":"o/r","projectsV2":false}}')"
42
+ on="$(project on '{"github":{"repo":"o/r","projectsV2":true,"projectNumber":3}}')"
43
+ doctor() { local d="$1"; shift; ( cd "$d" && KIT_ASCII=1 NO_COLOR=1 LC_ALL=C bash "$DOCTOR" "$@" </dev/null 2>"$tmp/err" ); }
44
+
45
+ # ── the library ───────────────────────────────────────────────────────────────────────────────
46
+ # shellcheck source=/dev/null
47
+ . "$ROOT/scripts/lib/loose-issues.sh"
48
+ t "repo: read from github.repo" "$(loose_repo "$off/cckit.config.json")" "o/r"
49
+ t "board off: projectsV2 false" "$(loose_board_on "$off/cckit.config.json" && echo on || echo off)" "off"
50
+ t "board on: projectsV2 true + a number" "$(loose_board_on "$on/cckit.config.json" && echo on || echo off)" "on"
51
+ out="$(loose_issues_list o/r "$off/cckit.config.json")"
52
+ t "effort, sub-issue and PR excluded -> the standalone issue alone" "$out" "$(printf '12\tFix the login')"
53
+ has "the read is GET repos/o/r/issues (open)" "$(cat "$GH_LOG")" "GET repos/o/r/issues?state=open&per_page=100"
54
+ t "a read only: no write request" "$(grep -cvE '^GET ' "$GH_LOG")" "0"
55
+ GH_FAIL_EP='repos/o/r/issues' loose_issues_list o/r "$off/cckit.config.json" >/dev/null 2>&1; rc=$?
56
+ t "a failed read -> rc 1, never zero loose" "$rc" "1"
57
+
58
+ # The board holds the Backlog marker: an issue whose Status is Backlog is not loose.
59
+ backlog='{"data":{"repository":{"issue":{"projectItems":{"nodes":[{"project":{"number":3},"fieldValueByName":{"name":"Backlog"}}]}}}}}'
60
+ todo='{"data":{"repository":{"issue":{"projectItems":{"nodes":[{"project":{"number":3},"fieldValueByName":{"name":"Todo"}}]}}}}}'
61
+ t "board on, Status Backlog -> not loose" "$(GH_GRAPHQL="$backlog" loose_issues_list o/r "$on/cckit.config.json")" ""
62
+ t "board on, Status Todo -> loose" "$(GH_GRAPHQL="$todo" loose_issues_list o/r "$on/cckit.config.json")" "$(printf '12\tFix the login')"
63
+
64
+ # ── cckit doctor --loose ──────────────────────────────────────────────────────────────────────
65
+ out="$(doctor "$off" --loose)"; rc=$?
66
+ has "--loose: one row with the count" "$out" "warn loose issues"
67
+ has "--loose: the count is 1" "$out" "1 in o/r"
68
+ has "--loose, board off: every standalone issue counts, and why" "$out" "no issue can carry the Backlog marker"
69
+ has "--loose: the list names #N title" "$out" "#12 Fix the login"
70
+ hasnt "--loose: the sub-issue is not listed" "$out" "#11 "
71
+ t "--loose: exit 0 (a count, not a gate)" "$rc" "0"
72
+ out="$(GH_GRAPHQL="$backlog" doctor "$on" --loose)"
73
+ has "--loose, board on + Backlog: zero" "$out" "ok loose issues 0 in o/r"
74
+
75
+ # ── the ratchet ───────────────────────────────────────────────────────────────────────────────
76
+ printf '# notes\n1\n' > "$tmp/at1"; printf '0\n' > "$tmp/at0"; printf '3\n' > "$tmp/at3"
77
+ out="$(doctor "$off" --loose --ratchet --baseline="$tmp/at1")"; rc=$?
78
+ t "ratchet: count = baseline -> exit 0" "$rc" "0"
79
+ has "ratchet: says equal" "$out" "1 loose = baseline 1"
80
+ out="$(doctor "$off" --ratchet --baseline="$tmp/at0")"; rc=$?
81
+ t "ratchet: count above baseline -> exit 1" "$rc" "1"
82
+ has "ratchet: names the rise" "$out" "1 loose > baseline 0"
83
+ out="$(doctor "$off" --ratchet --baseline="$tmp/at3")"; rc=$?
84
+ t "ratchet: count below baseline -> exit 0" "$rc" "0"
85
+ has "ratchet: asks to lower the baseline" "$out" "lower the number in $tmp/at3 to 1"
86
+ out="$(doctor "$off" --ratchet --baseline="$tmp/none")"; rc=$?
87
+ t "ratchet: no baseline -> exit 2, not judged" "$rc" "2"
88
+ has "ratchet: no baseline -> says so" "$out" "not judged — no number in"
89
+ t "ratchet: the repo's own baseline file holds a number" \
90
+ "$(loose_baseline_read "$ROOT/scripts/loose-issues.baseline" | grep -cE '^[0-9]+$')" "1"
91
+
92
+ # ── no forge: skipped, said out loud ──────────────────────────────────────────────────────────
93
+ : > "$GH_LOG"
94
+ out="$(CCKIT_FORGE=none GH_TOKEN= doctor "$off" --loose)"; rc=$?
95
+ has "no forge: a skip line" "$out" "loose issues skipped — no forge"
96
+ t "no forge: no request" "$(grep -c . "$GH_LOG")" "0"
97
+ t "no forge, --loose: exit 0" "$rc" "0"
98
+ out="$(CCKIT_FORGE=none GH_TOKEN= doctor "$off" --ratchet --baseline="$tmp/at1")"; rc=$?
99
+ t "no forge, --ratchet: exit 2, never a pass" "$rc" "2"
100
+ has "no forge, --ratchet: not judged" "$out" "not judged — the count was not read"
101
+
102
+ [ "$fail" = "0" ] && echo "ALL OK (loose-issues)" || { echo "loose-issues: FAILURES"; exit 1; }
@@ -0,0 +1,5 @@
1
+ # loose-issues.baseline — the loose-issue count `cckit doctor --loose --ratchet` holds the line at
2
+ # (E546.2). A loose issue is open, not an effort, not a sub-issue, and not in Backlog on the board.
3
+ # The number may only go down: when an issue is closed or filed under an effort, lower it in the
4
+ # same change. Not run by scripts/check.sh (the gate stays offline); measured 2026-11-24 with a GET.
5
+ 11
@@ -17,7 +17,7 @@
17
17
  # 8. no shipped command, skill or template holds an absolute home-directory path.
18
18
  # (4 and 5 — the instruction file and the plain-language rule — are in init-content-test.sh.)
19
19
  #
20
- # Hermetic: HOME is a temp dir, `gh` is a stub that logs every call, "GitHub" is a bare repository
20
+ # Hermetic: HOME is a temp dir, the forge shim logs every REST request, "GitHub" is a bare repository
21
21
  # in the temp dir. No network, no real repository.
22
22
  # Run: bash scripts/marketing-walkthrough-test.sh
23
23
  # errors: strict — a test runner: rc 1 on any failed assertion
@@ -39,39 +39,33 @@ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
39
39
  tmp="$(cd "$tmp" && pwd -P)"
40
40
  export HOME="$tmp/home"; mkdir -p "$HOME"
41
41
  printf '[user]\n\tname = Test Person\n\temail = test@example.com\n' > "$HOME/.gitconfig"
42
- export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
42
+ export GH_LOG="$tmp/forge.log"; : > "$GH_LOG"
43
43
 
44
+ # The forge (E537): GitHub is the shim's `curl`, which logs every REST request to $GH_LOG and
45
+ # answers "nothing there yet" for reads and success for writes; this fixture adds the pull request
46
+ # the walkthrough opens. The shim's `gh` fails on any subcommand.
44
47
  mkdir -p "$tmp/stubs"
45
- cat > "$tmp/stubs/gh" <<'STUB'
46
- #!/usr/bin/env bash
47
- # Logs every call. Reads answer "nothing there yet"; writes succeed.
48
- printf '%s\n' "$*" >> "$GH_LOG"
49
- case "${1:-} ${2:-}" in
50
- "auth status") exit 0 ;;
51
- "config get") echo https; exit 0 ;;
52
- "api user") echo tester; exit 0 ;;
53
- "repo view") exit 1 ;;
54
- "label list") exit 0 ;;
55
- "label create") exit 0 ;;
56
- "pr list") exit 0 ;;
57
- "pr create") echo "https://github.com/tester/site/pull/1"; exit 0 ;;
58
- "issue list") echo '[]'; exit 0 ;;
59
- "api graphql") exit 1 ;;
48
+ # shellcheck source=/dev/null
49
+ . "$ROOT/scripts/lib/test-forge-shim.sh"
50
+ forge_shim_install "$tmp/stubs"
51
+ export GH_TOKEN=test-token CCKIT_FORGE=github GH_FIXTURE="$tmp/fixture.sh"
52
+ cat > "$GH_FIXTURE" <<'FIX'
53
+ case "$method $ep" in
54
+ "GET user") out='{"login":"tester","type":"User"}' ;;
55
+ "GET repos/"*"/pulls") out='[]' ;;
56
+ "POST repos/"*"/pulls") out='{"number":1,"html_url":"https://github.com/tester/site/pull/1","user":{"login":"tester"},"node_id":"PR_1"}' ;;
57
+ "GET repos/"*"/issues") out='[]' ;;
58
+ "GET repos/"*"/milestones") out='[]' ;;
59
+ "GET repos/"*"/branches/"*"/protection") out='{"message":"Branch not protected"}'; code=404 ;;
60
60
  esac
61
- if [ "${1:-}" = "api" ]; then
62
- case " $* " in
63
- *"/protection "*) case " $* " in *" -X PUT "*) cat >/dev/null; echo '{}'; exit 0 ;; esac
64
- echo "gh: Branch not protected (HTTP 404)" >&2; exit 1 ;;
65
- *"/milestones"*) exit 0 ;;
66
- *" -X PATCH "*) exit 0 ;;
67
- *) echo false; exit 0 ;;
68
- esac
69
- fi
70
- exit 1
71
- STUB
72
- chmod +x "$tmp/stubs/gh"
61
+ FIX
73
62
  export PATH="$tmp/stubs:$PATH"
74
63
  export KIT_INIT_PREFLIGHT=0 KIT_INIT_TTY=0 KIT_ASCII=1 NO_COLOR=1 KIT_WT_INSTALL=0
64
+ # The git protocol is read from gh's config FILE (~/.config/gh/config.yml) or this variable; set it
65
+ # here so the setup does not depend on a gh install the reader may not have. (Without either, init
66
+ # exits 1 before the setup: scripts/lib/init-github.sh:418 fails its assignment under pipefail when
67
+ # the file is absent — asserted in init-guided-test.sh, section 7b.)
68
+ export CCKIT_GIT_PROTOCOL=https
75
69
  unset KIT_CONFIG KIT_BASE_BRANCH 2>/dev/null || true
76
70
 
77
71
  # new_project <dir> — a project with one commit on `main` and an empty bare `origin`.
@@ -140,7 +134,8 @@ has "status: lists the task" "$out" "| \`$id\` | **review** | Spring newsletter
140
134
  js="$("$CCKIT" status --llm 2>/dev/null)"
141
135
  t "status --llm: the task is in attention" "$(printf '%s' "$js" | jq -r '.light_tasks.attention[0] | .id + " " + .state')" "$id review"
142
136
  t "status --llm: the count" "$(printf '%s' "$js" | jq -r '.light_tasks.counts.review')" "1"
143
- t "status: no gh call names the task" "$(grep -c -e "$id" -e 'light/' "$GH_LOG" | tr -d ' ')" "0"
137
+ t "status: no forge request names the task" "$(grep -c -e "$id" -e 'light/' "$GH_LOG" | tr -d ' ')" "0"
138
+ t "the whole walkthrough ran no gh subcommand" "$(grep -c '^GH-SUBCOMMAND' "$tmp/forge.log")" "0"
144
139
 
145
140
  # ── 8. no absolute home-directory path in what cckit ships ──────────────────────────────────────
146
141
  hits="$(grep -rlE '/(Users|home)/[a-z][a-z0-9_-]+/' "$ROOT/commands" "$ROOT/skills" "$ROOT/templates" 2>/dev/null | sed "s#^$ROOT/##" | tr '\n' ' ')"
@@ -45,15 +45,21 @@
45
45
  #
46
46
  # bash 3.2 / zsh safe; needs jq.
47
47
 
48
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
49
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
50
+ # shellcheck source=/dev/null
51
+ . "$(cd "$(dirname "$0")" && pwd)/lib/gh-rest.sh"
52
+ fi
53
+
48
54
  NIGHT_GRANT_MARKER='<!-- night-grant -->'
49
55
  NIGHT_GRANT_BASE_FLOORS='lockfile auth security-code security-prose workflows cost secret'
50
56
  NIGHT_GRANT_BASE_NEVER='workflows cost secret'
51
- NIGHT_GRANT_REQUIRED_ALLOW='Bash(gh pr merge:*)
57
+ NIGHT_GRANT_REQUIRED_ALLOW='Bash(cckit merge:*)
52
58
  Bash(git push:*)
53
- Bash(gh issue comment:*)
54
- Bash(gh issue edit:*)
55
- Bash(gh issue close:*)
56
- Bash(gh api:*)'
59
+ Bash(cckit close:*)
60
+ Bash(cckit effort close:*)
61
+ Bash(cckit agent receipt:*)
62
+ Bash(curl:*)'
57
63
 
58
64
  _ng_err() { printf 'night-grant: %s\n' "$*" >&2; }
59
65
 
@@ -209,7 +215,7 @@ night_grant_pick() {
209
215
  night_grant_read() {
210
216
  local issue="${1:-}" comments picked
211
217
  case "$issue" in ''|*[!0-9]*) _ng_err 'usage: night_grant_read <issue-number>'; return 2 ;; esac
212
- if ! comments="$(gh api --paginate "repos/{owner}/{repo}/issues/$issue/comments" \
218
+ if ! comments="$(forge_rest --paginate "repos/{owner}/{repo}/issues/$issue/comments" \
213
219
  --jq '.[] | {body, login: .user.login, association: .author_association} | @json' < /dev/null)"; then
214
220
  _ng_err "could not read the comments of #$issue"; return 1
215
221
  fi
@@ -412,11 +418,11 @@ by-grantor"; } | jq -s . | NIGHT_GRANT_CONFIG="$cfg" night_grant_pick 2>/dev/nul
412
418
 
413
419
  # preflight — against fixture settings files
414
420
  tmp="${TMPDIR:-/tmp}/night-grant-selftest-$$.json"
415
- printf '%s' '{"permissions":{"allow":["Bash(gh pr merge:*)"]}}' >"$tmp"
421
+ printf '%s' '{"permissions":{"allow":["Bash(cckit merge:*)"]}}' >"$tmp"
416
422
  out="$(night_grant_preflight "$tmp" 2>/dev/null)"; st=$?
417
423
  _t "preflight: a thin allowlist exits 1" 1 "$st"
418
424
  _t "preflight: it reports each missing entry" 5 "$(printf '%s\n' "$out" | grep -c '^ MISSING')"
419
- printf '%s' '{"permissions":{"allow":["Bash(gh:*)","Bash(git push:*)"]}}' >"$tmp"
425
+ printf '%s' '{"permissions":{"allow":["Bash(cckit:*)","Bash(git push:*)","Bash(curl:*)"]}}' >"$tmp"
420
426
  night_grant_preflight "$tmp" >/dev/null 2>&1; st=$?
421
427
  _t "preflight: a broader prefix covers its commands" 0 "$st"
422
428
  printf '%s' '{"permissions":{"allow":["Bash(ghx:*)","Bash(git:*)"]}}' >"$tmp"
@@ -114,7 +114,7 @@ const BRIEF =
114
114
  'prints to the terminal). Return only the schema.'
115
115
 
116
116
  const preflightPrompt = (n) =>
117
- `${BRIEF}\nRead effort #${n}: \`gh issue view ${n} --json labels,state\`. ok=false when it ` +
117
+ `${BRIEF}\nRead effort #${n}: \`cckit brief ${n}\`. ok=false when it ` +
118
118
  'is closed or lacks the `effort` label. Return every label name verbatim; reason names what ' +
119
119
  'is missing.'
120
120