@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
@@ -3,8 +3,9 @@
3
3
  # next-test.sh — self-test for next.sh (`cckit next`), E241.4: the human output names the weekly
4
4
  # cadence, and the `--llm` TOON rows stay {number,ctx,title} — the cadence is prose for a person and
5
5
  # must not leak into the rows an agent parses.
6
- # Hermetic: a stubbed gh serves a three-issue board (one blocked) from fixture JSON and applies the
7
- # caller's own `--jq` program with the real jq, so the plan machine runs unmodified. bash only —
6
+ # Hermetic: the forge shim (test-forge-shim.sh) serves a three-issue board (one blocked) from fixture
7
+ # JSON over its curl stand-in; forge_rest applies the caller's own `--jq` program with the real jq,
8
+ # so the plan machine runs unmodified. bash only —
8
9
  # next_issue sources its siblings through BASH_SOURCE, as the dispatcher runs it.
9
10
  # Run: bash scripts/lib/next-test.sh
10
11
  # errors: strict — a test runner: rc 1 on any failed assertion
@@ -17,28 +18,22 @@ no() { case "$2" in *"$3"*) echo "FAIL: $1 -> output HAS '$3'"; fail=1 ;; *) ech
17
18
  command -v jq >/dev/null 2>&1 || { echo "next-test: jq required — skipping"; exit 0; }
18
19
 
19
20
  tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
20
- stub="$tmp/bin"; mkdir -p "$stub" "$tmp/labels" "$tmp/deps"
21
+ stub="$tmp/bin"; mkdir -p "$tmp/labels" "$tmp/deps"
21
22
 
22
- # Stub gh. Picks the fixture by subcommand, then runs the `--jq` program the caller passed (gh's
23
- # --jq prints raw strings, i.e. `jq -r`). `issue list` -> $FX/issues.json; `issue view <N>` ->
24
- # $FX/labels/<N>.json; `api …/issues/<N>/dependencies/blocked_by` -> $FX/deps/<N>.json or [].
25
- cat > "$stub/gh" <<'SH'
26
- #!/usr/bin/env bash
27
- src=""
28
- case "$1 $2" in
29
- "issue list") src="$FX/issues.json" ;;
30
- "issue view") src="$FX/labels/$3.json" ;;
31
- "api repos/"*)
32
- n="${2%/dependencies/blocked_by}"; n="${n##*/}"
33
- src="$FX/deps/$n.json"; [ -f "$src" ] || src="" ;;
23
+ # The shim's fixture, keyed on the REST path: the open issue list -> $FX/issues.json; an issue read
24
+ # (the plan machine's one label read per issue) -> $FX/labels/<N>.json; `…/issues/<N>/dependencies/
25
+ # blocked_by` -> $FX/deps/<N>.json or [].
26
+ # shellcheck source=/dev/null
27
+ . "$dir/test-forge-shim.sh"; forge_shim_install "$stub"
28
+ cat > "$tmp/fixture.sh" <<'SH'
29
+ case "$method $ep" in
30
+ "GET repos/octo/fixture/issues") out="$(cat "$FX/issues.json")" ;;
31
+ "GET repos/octo/fixture/issues/"*"/dependencies/blocked_by")
32
+ n="${ep%/dependencies/blocked_by}"; n="${n##*/}"
33
+ if [ -f "$FX/deps/$n.json" ]; then out="$(cat "$FX/deps/$n.json")"; else out='[]'; fi ;;
34
+ "GET repos/octo/fixture/issues/"*) out="$(cat "$FX/labels/${ep##*/}.json" 2>/dev/null || echo '{"labels":[]}')" ;;
34
35
  esac
35
- prog="."
36
- while [ "$#" -gt 0 ]; do
37
- case "$1" in --jq) prog="$2"; shift 2 ;; *) shift ;; esac
38
- done
39
- if [ -n "$src" ] && [ -f "$src" ]; then jq -r "$prog" "$src"; else echo '[]' | jq -r "$prog"; fi
40
36
  SH
41
- chmod +x "$stub/gh"
42
37
 
43
38
  # Board: #5 (p2), #6 (p0), #7 blocked_by OPEN #5. Wave 0 = {6, 5} in priority order; 7 is wave 1.
44
39
  cat > "$tmp/issues.json" <<'JSON'
@@ -53,6 +48,7 @@ echo '[{"number":5,"state":"open"}]' > "$tmp/deps/7.json"
53
48
 
54
49
  run_next() { # stdout of `next_issue "$@"` against the fixture board
55
50
  ( export FX="$tmp" PATH="$stub:$PATH" NEXT_REPO="octo/fixture" PLAN_REPO="octo/fixture" CCKIT_NO_GLOW=1
51
+ export GH_FIXTURE="$tmp/fixture.sh" GH_LOG="$tmp/gh.log" GH_TOKEN=test-token CCKIT_FORGE="${CCKIT_FORGE:-github}"
56
52
  unset CCKIT_OUTPUT
57
53
  # shellcheck source=/dev/null
58
54
  . "$dir/next.sh"
@@ -67,11 +63,13 @@ has "human: lists the unblocked p2 issue" "$human" "| #5 | S | tidy the par
67
63
  no "human: the blocked issue is not offered" "$human" "ship the report"
68
64
  has "human: recommends the most urgent" "$human" "cckit start 6"
69
65
  has "human: names the cadence" "$human" "Weekly cadence"
70
- has "human: plan on Monday" "$human" 'Monday: `cckit plan`'
66
+ has "human: plan on Monday" "$human" 'Monday: `cckit effort plan --issues`'
71
67
  has "human: next daily" "$human" 'daily: `cckit next`'
72
68
  has "human: gc on Friday" "$human" 'Friday: `cckit gc`'
73
69
  no "human: digest is not in the cadence" "$human" "digest"
74
70
  t "human: the cadence is printed once" "$(printf '%s\n' "$human" | grep -c 'Weekly cadence')" "1"
71
+ has "human: reads the open board over REST" "$(cat "$tmp/gh.log")" "GET repos/octo/fixture/issues?state=open&per_page=100 "
72
+ t "human: no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$tmp/gh.log")" "0"
75
73
 
76
74
  # ── --llm: TOON rows stay {number,ctx,title}; no cadence prose in the machine output ────────────
77
75
  llm="$(run_next --llm 2>/dev/null)"; rc=$?
@@ -88,6 +86,13 @@ echo '[]' > "$tmp/issues.json"
88
86
  t "empty board, llm: []" "$(run_next --llm 2>/dev/null)" "[]"
89
87
  has "empty board, human: says nothing is unblocked" "$(run_next 2>&1)" "nothing unblocked"
90
88
 
89
+ # ── no forge configured: the verb refuses with the one line naming it, and reads nothing ────────
90
+ : > "$tmp/gh.log"
91
+ none="$(CCKIT_FORGE=none run_next 2>&1)"; rc=$?
92
+ t "no forge: rc 1" "$rc" "1"
93
+ has "no forge: the refusal names the verb" "$none" "cckit next: needs a forge (GitHub) and none is configured"
94
+ t "no forge: no request was made" "$(wc -l < "$tmp/gh.log" | tr -d ' ')" "0"
95
+
91
96
  # ── --help prints the usage lines, cadence included ─────────────────────────────────────────────
92
97
  help="$(run_next --help 2>&1)"
93
98
  has "help: shows the bare verb" "$help" "cckit next "
@@ -2,7 +2,7 @@
2
2
  # next.sh — "what can I pick up right now?" The everyday-dev helper (Effort 75 · #79).
3
3
  #
4
4
  # Surfaces the unblocked set (wave 0 of the plan machine) and the single recommended next issue with
5
- # the one command to start it. This is the daily-loop counterpart to `cckit wave`: wave fans a whole
5
+ # the one command to start it. This is the daily-loop counterpart to `cckit effort plan --wave`: wave fans a whole
6
6
  # wave out to subagents; `cckit next` is for a human (or agent) picking up one issue by hand.
7
7
  #
8
8
  # cckit next the unblocked issues + the top one's start command + the weekly
@@ -13,14 +13,20 @@
13
13
  # Requires gh + jq (via the plan machine). bash 3.2 / zsh compatible.
14
14
  # errors: strict — refuses to recommend an issue without gh + jq
15
15
 
16
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
17
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
18
+ # shellcheck source=/dev/null
19
+ . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
20
+ fi
21
+
16
22
  NEXT_REPO="${NEXT_REPO:-${KIT_REPO:-}}"
17
23
 
18
24
  next_issue() {
19
- command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || { echo "next: needs gh + jq" >&2; return 1; }
25
+ forge_need next || return 1; command -v jq >/dev/null 2>&1 || { echo "next: needs jq" >&2; return 1; }
20
26
  local repo="$NEXT_REPO" out="${CCKIT_OUTPUT:-human}" effort="" planargs=()
21
27
  while [ "$#" -gt 0 ]; do
22
28
  case "$1" in
23
- --llm|--output=json) out="json"; shift ;;
29
+ --json|--llm|--output=json) out="json"; shift ;;
24
30
  --effort) effort="$2"; planargs+=(--effort "$2"); shift 2 ;;
25
31
  --effort=*) effort="${1#*=}"; planargs+=(--effort "${1#*=}"); shift ;;
26
32
  -h|--help) sed -n '8,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; return 0 ;;
@@ -43,7 +49,7 @@ next_issue() {
43
49
  if [ "$out" = "json" ]; then
44
50
  local json
45
51
  json="$(printf '%s\n' "$wave0" | awk -F'\t' '{
46
- t=$6; sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/,"",t); sub(/^\[[A-Za-z]+\] /,"",t)
52
+ t=$6; sub(/^\[E[0-9]+(\.[0-9]+)?\] +/, "", t); sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", t); sub(/^\[[A-Za-z]+\] /,"",t)
47
53
  print $3"\t"$4"\t"t
48
54
  }' \
49
55
  | jq -R -s '[ split("\n")[] | select(length>0) | split("\t")
@@ -60,19 +66,19 @@ next_issue() {
60
66
  local top topnum toptitle
61
67
  top="$(printf '%s\n' "$wave0" | sed -n 1p)"
62
68
  topnum="$(printf '%s' "$top" | cut -f3)"
63
- toptitle="$(printf '%s' "$top" | cut -f6 | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
69
+ toptitle="$(printf '%s' "$top" | cut -f6 | sed -E 's/^\[E[0-9]+(\.[0-9]+)?\] +//; s/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
64
70
  {
65
71
  printf '# Next up — %s%s\n\n' "$repo" "$([ -n "$effort" ] && echo " · effort #$effort")"
66
72
  printf '## Unblocked now\n\n'
67
73
  printf '| # | ctx | issue |\n|---|-----|-------|\n'
68
74
  printf '%s\n' "$wave0" | awk -F'\t' '{
69
- t=$6; sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/,"",t); sub(/^\[[A-Za-z]+\] /,"",t)
75
+ t=$6; sub(/^\[E[0-9]+(\.[0-9]+)?\] +/, "", t); sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", t); sub(/^\[[A-Za-z]+\] /,"",t)
70
76
  printf "| #%s | %s | %s |\n", $3, $4, t
71
77
  }'
72
78
  printf '\n## Pick up #%s — %s\n\n' "$topnum" "$toptitle"
73
79
  printf 'Start it in an isolated worktree + branch:\n\n'
74
80
  printf '```\ncckit start %s\n```\n\n' "$topnum"
75
- printf 'Or fan the whole unblocked wave out to subagents with `cckit wave%s`.\n' "$([ -n "$effort" ] && echo " --effort $effort")"
81
+ printf 'Or fan the whole unblocked wave out to subagents with `cckit effort plan --wave%s`.\n' "$([ -n "$effort" ] && echo " --effort $effort")"
76
82
  # the weekly cadence this verb is the daily step of — human output only; the TOON rows above
77
83
  # stay {number,ctx,title}.
78
84
  # shellcheck source=/dev/null
@@ -53,14 +53,15 @@ cat > "$stub/codex" <<'SH'
53
53
  #!/usr/bin/env bash
54
54
  exit 0
55
55
  SH
56
- cat > "$stub/gh" <<'SH'
57
- #!/usr/bin/env bash
58
- case "${1:-}" in
59
- api) exit 0 ;;
60
- *) echo '[]' ;;
61
- esac
62
- SH
63
- chmod +x "$stub/herdr" "$stub/codex" "$stub/gh"
56
+ chmod +x "$stub/herdr" "$stub/codex"
57
+ # The forge (E537): the dry runs below read the blocked_by edge over REST. The shim's `curl`
58
+ # answers it with no blocker; its `gh` fails on any subcommand, so a gh call left in orchestrate
59
+ # would turn the dry run red here.
60
+ # shellcheck source=/dev/null
61
+ . "$ROOT/scripts/lib/test-forge-shim.sh"
62
+ forge_shim_install "$stub"
63
+ export GH_LOG="$stub/forge.log" GH_TOKEN=test-token CCKIT_FORGE=github
64
+ : > "$GH_LOG"
64
65
 
65
66
  seed_for() { printf 'seed issue %s on %s in %s' "$1" "$2" "$3"; }
66
67
  old_path="$PATH"
@@ -193,6 +194,8 @@ PATH="$old_path"
193
194
  dry="$(cd "$ROOT" && PATH="$stub:$PATH" "$ROOT/bin/cckit" orchestrate --runtime herdr --agent codex --dry-run 41 2>&1)"
194
195
  yes "orchestrate accepts the Herdr runtime flag" "$dry" "runtime 'herdr', agent 'codex'"
195
196
  yes "Herdr dry-run creates no runtime state" "$dry" "no worktrees created, no panes started"
197
+ yes "the dry run read the blocked_by edge over the forge" "$(cat "$GH_LOG")" "GET repos/jeiemgi/cckit/issues/41/dependencies/blocked_by "
198
+ t "the dry run ran no gh subcommand" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
196
199
 
197
200
  auto="$(cd "$ROOT" && PATH="$stub:$PATH" "$ROOT/bin/cckit" autopilot --runtime herdr --agent codex --dry-run 41 2>&1)"
198
201
  yes "autopilot passes the runtime to orchestrate" "$auto" "runtime 'herdr', agent 'codex'"
@@ -2,7 +2,7 @@
2
2
  # plan-machine.sh — the wave plan: turn the board into a deps-ordered, file-disjoint, session-fit
3
3
  # execution plan the copilot fans out over (Effort 75 · #76).
4
4
  #
5
- # `cckit plan` reads the open board (or one effort's sub-issues), resolves the native GitHub
5
+ # `cckit effort plan --issues` reads the open board (or one effort's sub-issues), resolves the native GitHub
6
6
  # `blocked_by` edges, and layers the issues into WAVES: wave 0 is everything unblocked, wave N is
7
7
  # everything whose blockers all landed in earlier waves. Every issue in a wave is independent of the
8
8
  # others in that wave, so a wave is exactly "what N agents can run in parallel right now". Within a
@@ -10,11 +10,11 @@
10
10
  # under a session ctx budget, starting a new batch when the budget would overflow or two issues
11
11
  # declare overlapping files (so parallel subagents don't collide).
12
12
  #
13
- # cckit plan human wave plan for the open board
14
- # cckit plan --llm TOON wave plan (rows: wave,batch,number,ctx,blockers,title,priority)
15
- # cckit plan --effort <N> plan only effort #N's sub-issues
16
- # cckit plan --milestone <M> filter to milestone M
17
- # cckit plan --cap <N> session ctx budget per batch (default KIT_SESSION_BUDGET or 4)
13
+ # cckit effort plan --issues human wave plan for the open board
14
+ # cckit effort plan --issues --llm TOON wave plan (rows: wave,batch,number,ctx,blockers,title,priority)
15
+ # cckit effort plan --issues --effort <N> plan only effort #N's sub-issues
16
+ # cckit effort plan --issues --milestone <M> filter to milestone M
17
+ # cckit effort plan --issues --cap <N> session ctx budget per batch (default KIT_SESSION_BUDGET or 4)
18
18
  #
19
19
  # ctx weights: S=1 · M=2 · L=4 · XL=8. File hints: a "Files:"/"Touches:" line in the issue body
20
20
  # (comma/space-separated paths) drives intra-wave disjointness; absent → ctx budget alone batches.
@@ -34,6 +34,12 @@
34
34
  # Requires: gh, jq. bash 3.2 (no associative arrays — parallel indexed arrays + linear scan; N small).
35
35
  # errors: strict — refuses to plan without gh + jq
36
36
 
37
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
38
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
39
+ # shellcheck source=/dev/null
40
+ . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
41
+ fi
42
+
37
43
  PLAN_REPO="${PLAN_REPO:-${KIT_REPO:-}}"
38
44
 
39
45
  # _pm_weight <ctx> [issue] — session weight of a ctx: value. Anything outside S|M|L|XL weighs
@@ -168,13 +174,13 @@ _pm_files() {
168
174
  }
169
175
 
170
176
  plan_machine() {
171
- command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || { echo "plan: needs gh + jq" >&2; return 1; }
177
+ forge_need plan || return 1; command -v jq >/dev/null 2>&1 || { echo "plan: needs jq" >&2; return 1; }
172
178
  # output mode: the dispatcher strips --llm and exports CCKIT_OUTPUT=json, so honor that env first;
173
179
  # --llm/--output=json are kept for direct lib calls / tests.
174
180
  local repo="$PLAN_REPO" budget="${KIT_SESSION_BUDGET:-4}" out="${CCKIT_OUTPUT:-human}" effort="" ms=""
175
181
  while [ "$#" -gt 0 ]; do
176
182
  case "$1" in
177
- --llm|--output=json) out="json"; shift ;;
183
+ --json|--llm|--output=json) out="json"; shift ;;
178
184
  --effort) effort="$2"; shift 2 ;;
179
185
  --effort=*) effort="${1#*=}"; shift ;;
180
186
  --milestone) ms="$2"; shift 2 ;;
@@ -191,15 +197,15 @@ plan_machine() {
191
197
  # 1. the issue set: an effort's sub-issues, or the open board.
192
198
  local raw
193
199
  if [ -n "$effort" ]; then
194
- raw="$(gh api "repos/$repo/issues/$effort/sub_issues" --paginate \
200
+ raw="$(forge_rest "repos/$repo/issues/$effort/sub_issues" --paginate \
195
201
  --jq '.[] | select(.state=="open") | [(.number|tostring), .title, .body] | @tsv' 2>/dev/null)" \
196
202
  || { echo "plan: failed to read sub-issues of #$effort" >&2; return 1; }
197
203
  else
198
204
  local mjq='.[]'
199
205
  [ -n "$ms" ] && mjq=".[] | select((.milestone.title // \"\") == \"$ms\")"
200
- raw="$(gh issue list --repo "$repo" --state open --limit 200 --json number,title,body,milestone \
201
- --jq "$mjq | [(.number|tostring), .title, .body] | @tsv" 2>/dev/null)" \
202
- || { echo "plan: gh query failed (check gh auth)" >&2; return 1; }
206
+ raw="$(forge_rest "repos/$repo/issues" -X GET -f state=open -f per_page=100 --paginate \
207
+ --jq "[.[] | select(.pull_request | not) | {number, title, body: (.body // \"\"), milestone}] | $mjq | [(.number|tostring), .title, .body] | @tsv" 2>/dev/null)" \
208
+ || { echo "plan: the issue read failed (is the forge reachable and the token valid?)" >&2; return 1; }
203
209
  fi
204
210
  [ -n "$raw" ] || { [ "$out" = "json" ] && echo "[]" || echo "plan: no open issues to plan"; return 0; }
205
211
 
@@ -211,7 +217,7 @@ plan_machine() {
211
217
  [ -n "$n" ] || continue
212
218
  nums+=("$n"); titles+=("$t")
213
219
  # one label read serves both ctx: (session weight) and priority: (intra-wave order).
214
- lab="$(gh issue view "$n" --repo "$repo" --json labels --jq \
220
+ lab="$(forge_rest "repos/$repo/issues/$n" --jq \
215
221
  '[ ([.labels[].name|select(startswith("ctx:"))|ltrimstr("ctx:")]|first // "?"),
216
222
  ([.labels[].name|select(startswith("priority:"))|ltrimstr("priority:")]|first // "") ]|@tsv' 2>/dev/null)"
217
223
  ctxlab="${lab%%"$labtab"*}"
@@ -221,7 +227,7 @@ plan_machine() {
221
227
  prios+=("$priolab")
222
228
  files+=("$(_pm_files "$body")")
223
229
  # only OPEN blockers gate execution; closed ones are already satisfied.
224
- b="$(gh api "repos/$repo/issues/$n/dependencies/blocked_by" \
230
+ b="$(forge_rest "repos/$repo/issues/$n/dependencies/blocked_by" \
225
231
  --jq '[.[]|select(.state=="open")|.number]|join(",")' 2>/dev/null)"
226
232
  blkall+=("$b")
227
233
  done <<EOF
@@ -301,7 +307,7 @@ EOF2
301
307
  # shellcheck source=/dev/null
302
308
  . "$here/render.sh"
303
309
  {
304
- printf '# cckit plan — %s\n\n' "$repo"
310
+ printf '# cckit effort plan --issues — %s\n\n' "$repo"
305
311
  printf '_session budget %s · ctx S=1 M=2 L=4 XL=8 · ? = no ctx: label, weighed %s · each wave runs in parallel, p0 first_\n' "$budget" "$PM_UNSIZED_WEIGHT"
306
312
  emit_rows | awk -F'\t' '
307
313
  BEGIN { lw="" }
@@ -313,7 +319,7 @@ EOF2
313
319
  print "|---|-----|-----|-------|-------|-------|"
314
320
  lw=wv
315
321
  }
316
- sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", title)
322
+ sub(/^\[E[0-9]+(\.[0-9]+)?\] +/, "", title); sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", title)
317
323
  sub(/^\[[A-Za-z]+\] /, "", title)
318
324
  dep="—"
319
325
  if (blk != "") { gsub(/,/, ", #", blk); dep="#" blk }
@@ -5,9 +5,9 @@
5
5
  # kit can already do. Run against cckit itself (full inventory) or any project the kit is installed
6
6
  # in (degrades to whatever capability dirs exist, never crashes).
7
7
  #
8
- # cckit plan-next current capabilities + a proposed forward plan (markdown)
9
- # cckit plan-next --llm the proposed plan as TOON rows {rank,area,proposal,next} (JSON fallback)
10
- # cckit plan-next --root <dir> scan <dir> instead of the resolved project/kit root
8
+ # cckit effort plan --next current capabilities + a proposed forward plan (markdown)
9
+ # cckit effort plan --next --llm the proposed plan as TOON rows {rank,area,proposal,next} (JSON fallback)
10
+ # cckit effort plan --next --root <dir> scan <dir> instead of the resolved project/kit root
11
11
  #
12
12
  # CRITICAL — context-anxiety rule: this output is HUMAN / orchestrator-facing ONLY. It is NEVER to
13
13
  # be injected into a monitored model's prompt or context. The planner pre-grounds planning in the
@@ -140,7 +140,7 @@ plan_next() {
140
140
  local out="${CCKIT_OUTPUT:-human}" root=""
141
141
  while [ "$#" -gt 0 ]; do
142
142
  case "$1" in
143
- --llm|--output=json) out="json"; shift ;;
143
+ --json|--llm|--output=json) out="json"; shift ;;
144
144
  --root) root="$2"; shift 2 ;;
145
145
  --root=*) root="${1#*=}"; shift ;;
146
146
  -h|--help) sed -n '8,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; return 0 ;;
@@ -5,13 +5,13 @@
5
5
  # Two defects are under test, and both were invisible before:
6
6
  # 1. the helper posted with a plain `gh pr comment`, so every push stacked ANOTHER evidence
7
7
  # comment on the PR. The fix is a marker-based upsert, and the assertion that matters is
8
- # "two consecutive calls produce one create and one edit" — which is why the gh stub here is
9
- # STATEFUL: a stub that only counts calls cannot tell an upsert from an append.
8
+ # "two consecutive calls produce one create and one edit" — which is why the forge stand-in
9
+ # here is STATEFUL: a stub that only counts calls cannot tell an upsert from an append.
10
10
  # 2. best-effort swallowed a failed API call, so a caller that needed the evidence to exist had
11
11
  # no way to learn it did not. The fix is an opt-in strict mode, asserted per failure class.
12
12
  #
13
13
  # NETWORK-FREE and gh-FREE. The pure halves (key, marker, body, match, api path) are driven with
14
- # fixtures; the three gh seams are driven through a PATH shim in a temp dir, so nothing here can
14
+ # fixtures; the three forge seams are driven through the forge shim in a temp dir, so nothing here can
15
15
  # reach GitHub or spam a real PR. Run: bash scripts/lib/pr-evidence-test.sh
16
16
  # errors: strict — a test runner: rc 1 on any failed assertion
17
17
  set -u
@@ -82,75 +82,60 @@ t "match rejects a non-numeric id" "$(row abc "$m_build" | _pr_evidence_matc
82
82
 
83
83
  # ── 5. api path: gh placeholders when the repo is unset (pure) ──────────────────────────────────
84
84
  t "api path with an explicit repo" "$(_pr_evidence_api_path acme/widgets 'issues/7/comments')" "repos/acme/widgets/issues/7/comments"
85
- t "api path defers to gh" "$(_pr_evidence_api_path '' 'issues/7/comments')" "repos/{owner}/{repo}/issues/7/comments"
86
-
87
- # ── the gh stub: stateful, so an append is distinguishable from an upsert ───────────────────────
85
+ t "api path defers to the origin remote" "$(_pr_evidence_api_path '' 'issues/7/comments')" "repos/{owner}/{repo}/issues/7/comments"
86
+
87
+ # ── the forge stand-in: STATEFUL, so an append is distinguishable from an upsert ────────────────
88
+ # test-forge-shim.sh installs a `curl` that answers like the REST API and a `gh` that fails on any
89
+ # subcommand. The comment store lives in a GH_FIXTURE snippet the shim sources per request, over
90
+ # the same state files the old gh stub kept: $GH_STATE/index (id<TAB>bodyfile) + $GH_STATE/body.<id>.
91
+ # The shim logs `METHOD path {json}` per request; log_calls maps those lines back onto
92
+ # "list" (GET …/issues/7/comments) | "create" (POST …/issues/7/comments) | "edit <id>" (PATCH …/comments/<id>).
93
+ # GH_FAIL_LIST=1 makes the lookup fail (502); GH_FAIL_WRITE=1 makes create+edit fail (502).
88
94
  mkdir -p "$tmp/bin" "$tmp/state"
89
- cat > "$tmp/bin/gh" <<'STUB'
90
- #!/usr/bin/env bash
91
- # Stateful `gh` stub. State: $GH_STATE/index (id<TAB>bodyfile) + $GH_STATE/body.<id>.
92
- # Log: one line per call in $GH_LOG ("list" | "create" | "edit <id>").
93
- # GH_FAIL_LIST=1 makes the lookup fail; GH_FAIL_WRITE=1 makes create+edit fail.
94
- set -u
95
+ # shellcheck source=/dev/null
96
+ . "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
97
+ cat > "$tmp/fixture" <<'FIX'
95
98
  idx="$GH_STATE/index"; [ -f "$idx" ] || : > "$idx"
96
-
97
- if [ "${1:-}" = api ]; then
98
- path=""; method=GET; bodyfile=""
99
- while [ "$#" -gt 0 ]; do
100
- case "$1" in
101
- --method) method="$2"; shift 2 ;;
102
- -F) case "$2" in body=@*) bodyfile="${2#body=@}" ;; esac; shift 2 ;;
103
- --jq) shift 2 ;;
104
- --paginate|api) shift ;;
105
- -*) shift ;;
106
- *) path="$1"; shift ;;
107
- esac
108
- done
109
- if [ "$method" = PATCH ]; then
110
- id="${path##*/}"
111
- echo "edit $id" >> "$GH_LOG"
112
- [ "${GH_FAIL_WRITE:-0}" = 1 ] && exit 1
113
- grep -qx "$id" <<<"$(cut -f1 "$idx")" || exit 1 # 404 on an unknown comment, like the real API
114
- cp "$bodyfile" "$GH_STATE/body.$id"
115
- exit 0
116
- fi
117
- echo "list" >> "$GH_LOG"
118
- [ "${GH_FAIL_LIST:-0}" = 1 ] && exit 1
119
- # Mirror `--jq '.[] | "\(.id)\t\(.body | @json)"'`: one line per comment, newlines/tabs escaped.
120
- while read -r id _; do
121
- [ -n "$id" ] || continue
122
- printf '%s\t%s\n' "$id" "$(awk '{ gsub(/\t/, "\\t"); printf "%s\\n", $0 }' "$GH_STATE/body.$id")"
123
- done < "$idx"
124
- exit 0
125
- fi
126
-
127
- if [ "${1:-}" = pr ] && [ "${2:-}" = comment ]; then
128
- bodyfile=""
129
- while [ "$#" -gt 0 ]; do
130
- case "$1" in --body-file) bodyfile="$2"; shift 2 ;; *) shift ;; esac
131
- done
132
- echo "create" >> "$GH_LOG"
133
- [ "${GH_FAIL_WRITE:-0}" = 1 ] && exit 1
134
- n=$(( $(wc -l < "$idx" | tr -d ' ') + 1 ))
135
- id=$(( 1000 + n ))
136
- cp "$bodyfile" "$GH_STATE/body.$id"
137
- printf '%s\t%s\n' "$id" "$GH_STATE/body.$id" >> "$idx"
138
- echo "https://github.com/o/r/pull/7#issuecomment-$id"
139
- exit 0
140
- fi
141
- echo "stub gh: unhandled: $*" >&2
142
- exit 1
143
- STUB
144
- chmod +x "$tmp/bin/gh"
99
+ case "$method $ep" in
100
+ "GET repos/o/r/issues/"*"/comments")
101
+ if [ "${GH_FAIL_LIST:-0}" = 1 ]; then code=502; out='{"message":"Server Error"}'
102
+ else
103
+ out="$(while read -r id _; do
104
+ [ -n "$id" ] || continue
105
+ jq -n --arg id "$id" --rawfile b "$GH_STATE/body.$id" '{id: ($id|tonumber), body: $b}'
106
+ done < "$idx" | jq -sc .)"
107
+ fi ;;
108
+ "PATCH repos/o/r/issues/comments/"*)
109
+ id="${ep##*/}"
110
+ if [ "${GH_FAIL_WRITE:-0}" = 1 ]; then code=502; out='{"message":"Server Error"}'
111
+ elif ! grep -qx "$id" <<<"$(cut -f1 "$idx")"; then code=404; out='{"message":"Not Found"}' # like the real API
112
+ else printf '%s' "$body" | jq -r .body > "$GH_STATE/body.$id"; out="{\"id\":$id}"
113
+ fi ;;
114
+ "POST repos/o/r/issues/"*"/comments")
115
+ if [ "${GH_FAIL_WRITE:-0}" = 1 ]; then code=502; out='{"message":"Server Error"}'
116
+ else
117
+ n=$(( $(wc -l < "$idx" | tr -d ' ') + 1 )); id=$(( 1000 + n ))
118
+ printf '%s' "$body" | jq -r .body > "$GH_STATE/body.$id"
119
+ printf '%s\t%s\n' "$id" "$GH_STATE/body.$id" >> "$idx"
120
+ out="{\"id\":$id,\"html_url\":\"https://github.com/o/r/pull/7#issuecomment-$id\"}"
121
+ fi ;;
122
+ esac
123
+ FIX
145
124
 
146
125
  reset_stub() { rm -rf "$tmp/state"; mkdir -p "$tmp/state"; : > "$tmp/gh.log"; }
147
- # attach [env...] -- runs pr_attach_evidence in a subshell with ONLY the stub bin on PATH, so a
148
- # real gh on the developer's machine can never be reached.
126
+ # attach [env...] -- runs pr_attach_evidence in a subshell with ONLY the shim bin on PATH, so a
127
+ # real gh or curl on the developer's machine can never be reached. The repo is given explicitly:
128
+ # the fixture repo has no origin remote for the forge to resolve.
149
129
  attach() {
150
- GH_STATE="$tmp/state" GH_LOG="$tmp/gh.log" PATH="$tmp/bin:/usr/bin:/bin:/usr/sbin:/sbin" \
130
+ GH_STATE="$tmp/state" GH_LOG="$tmp/gh.log" GH_FIXTURE="$tmp/fixture" GH_TOKEN=test-token CCKIT_FORGE="${CCKIT_FORGE:-github}" \
131
+ PR_EVIDENCE_REPO=o/r PATH="$tmp/bin:/usr/bin:/bin:/usr/sbin:/sbin" \
151
132
  pr_attach_evidence "$@" 2>>"$tmp/stderr.log"
152
133
  }
153
- log_calls() { tr '\n' ' ' < "$tmp/gh.log" | sed 's/ *$//'; }
134
+ log_calls() {
135
+ sed -E -e 's#^GET repos/o/r/issues/7/comments.*#list#' \
136
+ -e 's#^POST repos/o/r/issues/7/comments.*#create#' \
137
+ -e 's#^PATCH repos/o/r/issues/comments/([0-9]+).*#edit \1#' "$tmp/gh.log" | tr '\n' ' ' | sed 's/ *$//'
138
+ }
154
139
 
155
140
  # ── 6. idempotence: two calls == one create + one edit ─────────────────────────────────────────
156
141
  reset_stub; : > "$tmp/stderr.log"
@@ -220,13 +205,17 @@ attach --strict --bogus 7 "$tmp/build.log" 2>/dev/null; t "strict rc 2 on a bad
220
205
  attach --strict 7 "$tmp/nope.log" build; t "strict rc 4 on a missing file" "$?" "4"
221
206
  attach 7 "$tmp/nope.log" build; t "best-effort rc 0 on a missing file" "$?" "0"
222
207
  t "missing file is recorded" "$(attach 7 "$tmp/nope.log" build; printf '%s' "$PR_EVIDENCE_LAST_RESULT")" "no-file"
223
- # gh absent: an empty PATH dir, so `command -v gh` genuinely fails. `hash -r` first, or bash's
224
- # cached path for gh would still resolve and the case would pass without testing anything.
225
- mkdir -p "$tmp/nogh"
226
- ( hash -r 2>/dev/null; PATH="$tmp/nogh" pr_attach_evidence --strict 7 "$tmp/build.log" build ) 2>/dev/null
227
- t "strict rc 3 without gh" "$?" "3"
228
- ( hash -r 2>/dev/null; PATH="$tmp/nogh" pr_attach_evidence 7 "$tmp/build.log" build ) 2>/dev/null
229
- t "best-effort rc 0 without gh" "$?" "0"
208
+ # no forge configured (CCKIT_FORGE=none): strict is rc 3 and the result names it; best-effort is
209
+ # rc 0. Nothing is asked of the network either way.
210
+ : > "$tmp/gh.log"
211
+ ( unset _FORGE_LOADED; CCKIT_FORGE=none attach --strict 7 "$tmp/build.log" build ) 2>/dev/null
212
+ t "strict rc 3 without a forge" "$?" "3"
213
+ ( unset _FORGE_LOADED; CCKIT_FORGE=none attach 7 "$tmp/build.log" build ) 2>/dev/null
214
+ t "best-effort rc 0 without a forge" "$?" "0"
215
+ t "no forge is recorded as the result" "$(unset _FORGE_LOADED; CCKIT_FORGE=none attach 7 "$tmp/build.log" build; printf '%s' "$PR_EVIDENCE_LAST_RESULT")" "no-forge"
216
+ t "no forge makes no request" "$(log_calls)" ""
217
+ # and the whole run above never fell back to a gh subcommand
218
+ t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$tmp/gh.log")" "0"
230
219
 
231
220
  # ── 9. the contract surface the callers depend on ──────────────────────────────────────────────
232
221
  has "usage documents the upsert" "$(pr_evidence_usage)" "cckit:pr-evidence key="
@@ -242,13 +231,13 @@ t "marker prefix is frozen" "$PR_EVIDENCE_MARKER_PREFIX" '<!-- cckit:pr-evidence
242
231
  if command -v zsh >/dev/null 2>&1; then
243
232
  reset_stub
244
233
  zsh -c "cd '$ROOT'; . scripts/lib/pr-evidence.sh; \
245
- export GH_STATE='$tmp/state' GH_LOG='$tmp/gh.log'; PATH='$tmp/bin:/usr/bin:/bin'; \
234
+ export GH_STATE='$tmp/state' GH_LOG='$tmp/gh.log' GH_FIXTURE='$tmp/fixture' GH_TOKEN=test-token CCKIT_FORGE=github PR_EVIDENCE_REPO=o/r; PATH='$tmp/bin:/usr/bin:/bin'; \
246
235
  pr_attach_evidence 7 '$tmp/build.log' build >/dev/null 2>&1; \
247
236
  pr_attach_evidence 7 '$tmp/build.log' build >/dev/null 2>&1" >/dev/null 2>&1
248
237
  t "zsh: two calls == one create + one edit" "$(log_calls)" "list create list edit 1001"
249
238
  reset_stub
250
239
  zrc="$(zsh -c "cd '$ROOT'; . scripts/lib/pr-evidence.sh; \
251
- export GH_STATE='$tmp/state' GH_LOG='$tmp/gh.log' GH_FAIL_WRITE=1; PATH='$tmp/bin:/usr/bin:/bin'; \
240
+ export GH_STATE='$tmp/state' GH_LOG='$tmp/gh.log' GH_FIXTURE='$tmp/fixture' GH_TOKEN=test-token CCKIT_FORGE=github PR_EVIDENCE_REPO=o/r GH_FAIL_WRITE=1; PATH='$tmp/bin:/usr/bin:/bin'; \
252
241
  pr_attach_evidence --strict 7 '$tmp/build.log' build >/dev/null 2>&1; echo \$?" 2>/dev/null | tail -1)"
253
242
  t "zsh: strict rc 7 on a failed write" "$zrc" "7"
254
243
  else
@@ -40,6 +40,12 @@
40
40
  # KIT_EVIDENCE_MAX_BYTES inline truncation cap for text/log files (default 60000)
41
41
  # errors: mixed — pr_attach_evidence is best-effort by default (warns, rc 0) and propagates every failure with a distinct rc under --strict / PR_EVIDENCE_STRICT=1; the marker/body builders are pure
42
42
 
43
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
44
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
45
+ # shellcheck source=/dev/null
46
+ . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
47
+ fi
48
+
43
49
  PR_EVIDENCE_REPO="${PR_EVIDENCE_REPO:-}"
44
50
  PR_EVIDENCE_STRICT="${PR_EVIDENCE_STRICT:-0}"
45
51
  PR_EVIDENCE_LAST_RESULT="${PR_EVIDENCE_LAST_RESULT:-}"
@@ -86,7 +92,7 @@ _pr_evidence_match_id() {
86
92
  return "$found"
87
93
  }
88
94
 
89
- # _pr_evidence_api_path <repo> <suffix> — the gh api path. An empty repo yields the
95
+ # _pr_evidence_api_path <repo> <suffix> — the forge_rest path. An empty repo yields the
90
96
  # {owner}/{repo} placeholders, which gh fills from the current repo (matching the old
91
97
  # "omit --repo" behaviour).
92
98
  _pr_evidence_api_path() {
@@ -189,23 +195,20 @@ _pr_evidence_compose() {
189
195
  _pr_evidence_list() {
190
196
  local p
191
197
  p="$(_pr_evidence_api_path "$1" "issues/$2/comments")"
192
- gh api --paginate "$p" --jq '.[] | "\(.id)\t\(.body | @json)"' 2>/dev/null
198
+ forge_rest --paginate "$p" --jq '.[] | "\(.id)\t\(.body | @json)"' 2>/dev/null
193
199
  }
194
200
 
195
201
  # _pr_evidence_edit <repo> <comment-id> <body-file> — PATCH an existing comment in place.
196
202
  _pr_evidence_edit() {
197
203
  local p
198
204
  p="$(_pr_evidence_api_path "$1" "issues/comments/$2")"
199
- gh api --method PATCH "$p" -F "body=@$3" >/dev/null 2>&1
205
+ forge_rest --method PATCH "$p" -F "body=@$3" >/dev/null 2>&1
200
206
  }
201
207
 
202
208
  # _pr_evidence_create <repo> <pr> <body-file> — post a new comment.
203
209
  _pr_evidence_create() {
204
- if [ -n "$1" ]; then
205
- gh pr comment "$2" --repo "$1" --body-file "$3" >/dev/null 2>&1
206
- else
207
- gh pr comment "$2" --body-file "$3" >/dev/null 2>&1
208
- fi
210
+ local repo="$1"; [ -n "$repo" ] || repo="$(forge_repo_from_git 2>/dev/null)" || return 1
211
+ gh_rest_issue_comment "$repo" "$2" "@$3" >/dev/null 2>&1
209
212
  }
210
213
 
211
214
  # ── the entry point ────────────────────────────────────────────────────────────────────────────
@@ -246,9 +249,9 @@ pr_attach_evidence() {
246
249
  pr_evidence_usage >&2
247
250
  return "$rc"
248
251
  fi
249
- if ! command -v gh >/dev/null 2>&1; then
250
- _pr_evidence_bail "$strict" 3 no-gh \
251
- "gh CLI not found — cannot post evidence to PR #$pr (skipping)"
252
+ if ! forge_available; then
253
+ _pr_evidence_bail "$strict" 3 no-forge \
254
+ "no forge is configured — cannot post evidence to PR #$pr (skipping)"
252
255
  return $?
253
256
  fi
254
257
  if [ ! -f "$file" ]; then
@@ -330,7 +333,7 @@ pr-evidence.sh — upsert PR evidence (build/typecheck logs, screenshots) as a P
330
333
 
331
334
  kit-effort-pr should call it AFTER the PR is opened, once per gate artifact:
332
335
 
333
- pr_num=$(gh pr list --head "$branch" --json number --jq '.[0].number')
336
+ pr_num=$(gh_rest_pr_for_head "$repo" "$branch")
334
337
  pr_attach_evidence "$pr_num" build.log "build" || true
335
338
  pr_attach_evidence "$pr_num" typecheck.log "typecheck" || true
336
339
  pr_attach_evidence "$pr_num" screen.png "rendered — success state" || true