@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
@@ -8,9 +8,10 @@
8
8
  # nothing, --no-github, an idempotent re-run, a refused branch protection, a failed step that does
9
9
  # not hide the later ones, and --upgrade staying out of the flow.
10
10
  #
11
- # Hermetic: HOME is a temp dir, `gh` and `pnpm` are stubs on PATH, "GitHub" is a directory of bare
12
- # repositories plus a log of every write the stub was asked to make, and the recipe is a fixture
13
- # whose commands are plain shell. Nothing here reaches the network or a real repository.
11
+ # Hermetic: HOME is a temp dir, `pnpm` is a stub on PATH, GitHub is the forge shim
12
+ # (scripts/lib/test-forge-shim.sh) answering from a fixture — a directory of bare repositories plus
13
+ # a log of every write it was asked to make — and the recipe is a fixture whose commands are plain
14
+ # shell. No `gh` is installed. Nothing here reaches the network or a real repository.
14
15
  # Run: bash scripts/init-guided-test.sh
15
16
  # errors: strict — a test runner: rc 1 on any failed assertion
16
17
  set -u
@@ -34,85 +35,76 @@ export HOME="$tmp/home"; mkdir -p "$HOME"
34
35
  printf '[user]\n\tname = Test Person\n\temail = test@example.com\n[init]\n\tdefaultBranch = trunk\n' > "$HOME/.gitconfig"
35
36
  export GHS="$tmp/github"; mkdir -p "$GHS/git" "$GHS/repos"; : > "$GHS/writes.log"
36
37
 
37
- # ── stubs ────────────────────────────────────────────────────────────────────────────────────────
38
+ # ── the forge (E537) ─────────────────────────────────────────────────────────────────────────────
39
+ # GitHub is REST over curl with a token. The shim's `curl` answers every request from the fixture
40
+ # below — a GitHub made of files: $GHS/repos/<owner>__<name>/ holds one repository's state,
41
+ # $GHS/git/ the bare repositories git pushes to, $GHS/writes.log one line per write the caller asked
42
+ # for. The shim's `gh` answers only `gh auth token` and FAILS on any other subcommand, so a gh call
43
+ # left in init is a red step here. The repository URL init adds as origin is the real one
44
+ # (https://github.com/<owner>/<name>.git); a git URL rewrite in the test HOME sends every push to
45
+ # the bare repository of the same name under $GHS/git/.
46
+ printf '[url "%s/git/"]\n\tinsteadOf = https://github.com/\n' "$GHS" >> "$HOME/.gitconfig"
38
47
  mkdir -p "$tmp/stubs"
39
- cat > "$tmp/stubs/gh" <<'STUB'
40
- #!/usr/bin/env bash
41
- # A GitHub made of files: $GHS/repos/<owner>__<name>/ holds one repository's state, $GHS/git/ the
42
- # bare repositories git pushes to, $GHS/writes.log one line per write the caller asked for.
43
- set -u
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" GH_LOG="$tmp/forge.log"
52
+ : > "$GH_LOG"
53
+ # gh is not installed on the reader's machine: the git protocol comes from this variable, not from
54
+ # gh's config file (see section 7b for the run with neither).
55
+ export CCKIT_GIT_PROTOCOL=https
56
+ cat > "$GH_FIXTURE" <<'FIX'
57
+ # Sourced by the shim's curl with $method $ep (the path, no query) $body set; sets out and code.
44
58
  log() { printf '%s\n' "$*" >> "$GHS/writes.log"; }
45
- rdir() { printf '%s/repos/%s\n' "$GHS" "$(printf '%s' "$1" | tr '/' '_' | sed 's/_/__/')"; }
46
- here_repo() { # the repository the cwd's origin points at, when it is one of ours
47
- local u; u="$(git remote get-url origin 2>/dev/null)" || return 1
48
- case "$u" in "$GHS/git/"*) u="${u#"$GHS/git/"}"; printf '%s\n' "${u%.git}" ;; *) return 1 ;; esac
49
- }
50
- case "${1:-} ${2:-}" in
51
- "auth status") exit 0 ;;
52
- "config get") echo https; exit 0 ;;
53
- "api user") echo tester; exit 0 ;;
54
- "repo view")
55
- shift 2; repo=""; fields=""
56
- while [ $# -gt 0 ]; do case "$1" in --json) fields="$2"; shift 2 ;; -q|--jq) shift 2 ;; *) repo="$1"; shift ;; esac; done
57
- [ -n "$repo" ] || repo="$(here_repo)" || exit 1
58
- d="$(rdir "$repo")"; [ -d "$d" ] || { echo "GraphQL: Could not resolve to a Repository" >&2; exit 1; }
59
- case "$fields" in
60
- nameWithOwner) echo "$repo" ;;
61
- defaultBranchRef) cat "$d/default" 2>/dev/null || echo main ;;
62
- url,sshUrl) printf '%s\t%s\n' "$GHS/git/$repo" "" ;;
63
- esac
64
- exit 0 ;;
65
- "repo create")
66
- shift 2; repo="$1"; shift; vis=""; src=""
67
- while [ $# -gt 0 ]; do case "$1" in --private|--public) vis="$1"; shift ;; --source) src="$2"; shift 2 ;; --remote) shift 2 ;; *) shift ;; esac; done
68
- [ -f "$GHS/fail-create" ] && { echo "gh: could not create the repository (HTTP 500)" >&2; exit 1; }
69
- log "repo create $repo $vis"
70
- d="$(rdir "$repo")"; mkdir -p "$d" "$GHS/git/$(dirname "$repo")"
71
- git init -q --bare "$GHS/git/$repo.git"
72
- git -C "$src" remote add origin "$GHS/git/$repo.git"
73
- exit 0 ;;
74
- "repo edit")
75
- repo="$3"; log "repo edit $*"; printf '%s\n' "$5" > "$(rdir "$repo")/default"; exit 0 ;;
76
- "label list")
77
- shift 2; while [ $# -gt 0 ]; do case "$1" in --repo) repo="$2"; shift 2 ;; *) shift ;; esac; done
78
- cat "$(rdir "$repo")/labels" 2>/dev/null; exit 0 ;;
79
- "label create")
80
- name="$3"; shift 3; while [ $# -gt 0 ]; do case "$1" in --repo) repo="$2"; shift 2 ;; *) shift ;; esac; done
81
- [ -f "$GHS/fail-labels" ] && { echo "gh: label could not be created (HTTP 500)" >&2; exit 1; }
82
- log "label create $repo $name"; printf '%s\n' "$name" >> "$(rdir "$repo")/labels"; exit 0 ;;
83
- "api graphql") exit 1 ;;
59
+ rdir() { printf '%s/repos/%s\n' "$GHS" "$(printf '%s' "$1" | sed 's#/#__#')"; }
60
+ refuse() { out="{\"message\":\"$1\"}"; code="$2"; }
61
+ field() { printf '%s' "$body" | jq -r --arg k "$1" 'if has($k) then .[$k] | tostring else empty end'; }
62
+ repo=""; rest=""
63
+ case "$ep" in repos/*/*) repo="$(printf '%s' "$ep" | cut -d/ -f2-3)"; rest="$(printf '%s' "$ep" | cut -d/ -f4-)" ;; esac
64
+ d="$(rdir "${repo:-none/none}")"
65
+ case "$method $ep" in
66
+ "GET user") out='{"login":"tester","type":"User"}' ;;
67
+ "POST user/repos"|"POST orgs/"*"/repos")
68
+ owner=tester; case "$ep" in orgs/*) owner="$(printf '%s' "$ep" | cut -d/ -f2)" ;; esac
69
+ repo="$owner/$(field name)"; d="$(rdir "$repo")"
70
+ if [ -f "$GHS/fail-create" ]; then refuse "could not create the repository" 500
71
+ else
72
+ vis=--private; [ "$(field private)" = false ] && vis=--public
73
+ log "repo create $repo $vis"
74
+ mkdir -p "$d" "$GHS/git/$owner"; git init -q --bare "$GHS/git/$repo.git"
75
+ out="{\"full_name\":\"$repo\",\"html_url\":\"https://github.com/$repo\",\"ssh_url\":\"git@github.com:$repo.git\",\"default_branch\":\"main\",\"private\":true}"
76
+ fi ;;
77
+ "POST graphql") refuse "GraphQL is off in this fixture" 500 ;;
78
+ "GET repos/"*)
79
+ if [ ! -d "$d" ]; then refuse "Not Found" 404
80
+ else
81
+ case "$rest" in
82
+ "") out="{\"full_name\":\"$repo\",\"html_url\":\"https://github.com/$repo\",\"ssh_url\":\"git@github.com:$repo.git\",\"default_branch\":\"$(cat "$d/default" 2>/dev/null || echo main)\",\"delete_branch_on_merge\":$(cat "$d/delete-on-merge" 2>/dev/null || echo false)}" ;;
83
+ labels) out="$( { cat "$d/labels" 2>/dev/null || true; } | jq -R '{name: .}' | jq -s .)" ;;
84
+ milestones) out="$( { cat "$d/milestones" 2>/dev/null || true; } | jq -R '{title: .}' | jq -s .)" ;;
85
+ branches/*/protection)
86
+ br="$(printf '%s' "$rest" | cut -d/ -f2)"
87
+ if [ -f "$GHS/plan-refuses" ]; then refuse "Upgrade to GitHub Pro or make this repository public to enable this feature." 403
88
+ elif [ -f "$d/protected-$br" ]; then out='{}'
89
+ else refuse "Branch not protected" 404; fi ;;
90
+ esac
91
+ fi ;;
92
+ "PATCH repos/"*)
93
+ db="$(field default_branch)"
94
+ [ -n "$db" ] && { log "repo edit $repo --default-branch $db"; printf '%s\n' "$db" > "$d/default"; }
95
+ [ "$(field delete_branch_on_merge)" = true ] && { log "repo patch $repo delete_branch_on_merge"; echo true > "$d/delete-on-merge"; }
96
+ out='{}' ;;
97
+ "POST repos/"*"/labels")
98
+ if [ -f "$GHS/fail-labels" ]; then refuse "label could not be created" 500
99
+ else name="$(field name)"; log "label create $repo $name"; printf '%s\n' "$name" >> "$d/labels"; out='{}'; fi ;;
100
+ "POST repos/"*"/milestones")
101
+ title="$(field title)"; log "milestone create $repo $title"; printf '%s\n' "$title" >> "$d/milestones"; out='{"number":1}' ;;
102
+ "PUT repos/"*"/branches/"*"/protection")
103
+ br="$(printf '%s' "$rest" | cut -d/ -f2)"
104
+ if [ -f "$GHS/plan-refuses" ]; then refuse "Upgrade to GitHub Pro or make this repository public to enable this feature." 403
105
+ else log "protect $repo $br"; : > "$d/protected-$br"; out='{}'; fi ;;
84
106
  esac
85
- if [ "${1:-}" = "api" ]; then
86
- shift; method=GET; ep=""; title=""
87
- while [ $# -gt 0 ]; do
88
- case "$1" in
89
- -X) method="$2"; shift 2 ;;
90
- -f) case "$2" in title=*) title="${2#title=}"; method=POST ;; esac; shift 2 ;;
91
- -F|--jq|-q|--input) shift 2 ;;
92
- *) ep="$1"; shift ;;
93
- esac
94
- done
95
- case "$ep" in
96
- repos/*/*/milestones*)
97
- repo="$(printf '%s' "$ep" | cut -d/ -f2-3)"; d="$(rdir "$repo")"
98
- if [ "$method" = POST ]; then log "milestone create $repo $title"; printf '%s\n' "$title" >> "$d/milestones"; else cat "$d/milestones" 2>/dev/null; fi
99
- exit 0 ;;
100
- repos/*/*/branches/*/protection)
101
- repo="$(printf '%s' "$ep" | cut -d/ -f2-3)"; d="$(rdir "$repo")"; br="$(printf '%s' "$ep" | cut -d/ -f5)"
102
- if [ -f "$GHS/plan-refuses" ]; then echo "gh: Upgrade to GitHub Pro or make this repository public to enable this feature. (HTTP 403)" >&2; exit 1; fi
103
- if [ "$method" = PUT ]; then cat >/dev/null; log "protect $repo $br"; : > "$d/protected-$br"; echo '{}'; exit 0; fi
104
- [ -f "$d/protected-$br" ] && { echo '{}'; exit 0; }
105
- echo "gh: Branch not protected (HTTP 404)" >&2; exit 1 ;;
106
- repos/*/*)
107
- repo="$(printf '%s' "$ep" | cut -d/ -f2-3)"; d="$(rdir "$repo")"
108
- if [ "$method" = PATCH ]; then log "repo patch $repo delete_branch_on_merge"; echo true > "$d/delete-on-merge"; exit 0; fi
109
- cat "$d/delete-on-merge" 2>/dev/null || echo false
110
- exit 0 ;;
111
- esac
112
- fi
113
- echo "stub gh: unhandled: $*" >&2
114
- exit 1
115
- STUB
107
+ FIX
116
108
  # pnpm: the database option's install command. Adds each named package to package.json.
117
109
  cat > "$tmp/stubs/pnpm" <<'STUB'
118
110
  #!/usr/bin/env bash
@@ -171,6 +163,13 @@ t "detect: project marker, no git" "$(init_detect_class "$tmp/d/proj")"
171
163
  t "detect: git, no remote" "$(init_detect_class "$tmp/d/gitno")" "git-noremote"
172
164
  t "detect: git with a remote" "$(init_detect_class "$tmp/d/gitre")" "project-remote"
173
165
  t "abs path of a missing nested folder" "$(init_abs_path "$tmp/d/a/b")" "$tmp/d/a/b"
166
+ # The repository init resolves from an existing origin is the one the remote names, whatever the
167
+ # folder is called. (Read with a HOME that has no URL rewrite: the test's own rewrite turns the
168
+ # remote into a local path, which no forge can name.)
169
+ mkdir -p "$tmp/plainhome" "$tmp/d/renamed"
170
+ git -C "$tmp/d/renamed" init -q; git -C "$tmp/d/renamed" remote add origin "git@github.com:tester/the-real-name.git"
171
+ t "the repository name comes from the origin remote (https)" "$(HOME="$tmp/plainhome" bash -c '. "$1/scripts/lib/forge.sh"; forge_repo_from_git "$2"' _ "$ROOT" "$tmp/d/gitre")" "tester/gitre"
172
+ t "the repository name comes from the origin remote (ssh), not the folder" "$(HOME="$tmp/plainhome" bash -c '. "$1/scripts/lib/forge.sh"; forge_repo_from_git "$2"' _ "$ROOT" "$tmp/d/renamed")" "tester/the-real-name"
174
173
 
175
174
  # ── 2. home directory ───────────────────────────────────────────────────────────────────────────
176
175
  run "$HOME" --profile minimal
@@ -310,13 +309,26 @@ run "$tmp/p/local" --yes
310
309
  t "git, no remote, re-run: rc 0, no new commit, no GitHub write" "$RC:$(git -C "$tmp/p/local" rev-parse HEAD):$(writes)" "0:$h7:$w7"
311
310
  has "git, no remote, re-run: the commit step is skipped" "$OUT" "[skipped] cckit files commit — already committed"
312
311
  yes_if "git, no remote: develop is on GitHub" 'git -C "$GHS/git/tester/local.git" show-ref --verify -q refs/heads/develop'
312
+ t "git, no remote: origin is the repository's real URL, not a local path" "$(git -C "$tmp/p/local" config remote.origin.url)" "https://github.com/tester/local.git"
313
+ has "git, no remote: the repository was created over REST, for the signed-in user" "$(cat "$GH_LOG")" 'POST user/repos {"name":"local","private":true}'
314
+ t "git, no remote: no gh subcommand was run" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
315
+
316
+ # ── 7b. the reader has no gh at all: no gh config file and no CCKIT_GIT_PROTOCOL ────────────────
317
+ # The git protocol defaults to https. The setup must run; it must not stop silently before its
318
+ # first step because the file it reads the protocol from is not there.
319
+ mkdir -p "$tmp/p/nogh"; git -C "$tmp/p/nogh" init -q
320
+ echo hi > "$tmp/p/nogh/README.md"; git -C "$tmp/p/nogh" add -A; git -C "$tmp/p/nogh" commit -q -m first
321
+ OUT="$(cd "$tmp/p/nogh" && env -u CCKIT_GIT_PROTOCOL CLAUDE_PLUGIN_ROOT="$ROOT" bash "$INIT" --profile minimal --yes 2>&1)"; RC=$?
322
+ t "no gh config, no protocol variable: rc 0" "$RC" "0"
323
+ has "no gh config, no protocol variable: the setup ran" "$OUT" "Project setup"
324
+ t "no gh config, no protocol variable: https is the default" "$(git -C "$tmp/p/nogh" config remote.origin.url 2>/dev/null)" "https://github.com/tester/nogh.git"
313
325
 
314
326
  # ── 8. repository that already has a GitHub remote ──────────────────────────────────────────────
315
327
  mkdir -p "$GHS/repos/tester__adopted" "$GHS/git/tester" "$tmp/p/adopted"
316
328
  git init -q --bare "$GHS/git/tester/adopted.git"
317
329
  git -C "$tmp/p/adopted" init -q; git -C "$tmp/p/adopted" symbolic-ref HEAD refs/heads/main
318
330
  echo hi > "$tmp/p/adopted/README.md"; git -C "$tmp/p/adopted" add -A; git -C "$tmp/p/adopted" commit -q -m first
319
- git -C "$tmp/p/adopted" remote add origin "$GHS/git/tester/adopted.git"; git -C "$tmp/p/adopted" push -q -u origin main
331
+ git -C "$tmp/p/adopted" remote add origin "https://github.com/tester/adopted.git"; git -C "$tmp/p/adopted" push -q -u origin main
320
332
  : > "$GHS/writes.log"
321
333
  run "$tmp/p/adopted" --profile minimal --yes
322
334
  t "existing remote: rc 0" "$RC" "0"
@@ -337,7 +349,7 @@ mkdir -p "$GHS/repos/tester__mixed" "$tmp/p/mixed/scripts"
337
349
  git init -q --bare "$GHS/git/tester/mixed.git"
338
350
  git -C "$tmp/p/mixed" init -q; git -C "$tmp/p/mixed" symbolic-ref HEAD refs/heads/main
339
351
  echo hi > "$tmp/p/mixed/README.md"; git -C "$tmp/p/mixed" add -A; git -C "$tmp/p/mixed" commit -q -m first
340
- git -C "$tmp/p/mixed" remote add origin "$GHS/git/tester/mixed.git"; git -C "$tmp/p/mixed" push -q -u origin main
352
+ git -C "$tmp/p/mixed" remote add origin "https://github.com/tester/mixed.git"; git -C "$tmp/p/mixed" push -q -u origin main
341
353
  echo "SECRET=1" > "$tmp/p/mixed/.env"; echo "SECRET=2" > "$tmp/p/mixed/scripts/.env.local"
342
354
  echo "mine" > "$tmp/p/mixed/scripts/my-own.sh"; echo "notes" > "$tmp/p/mixed/notes.txt"
343
355
  echo "staged" > "$tmp/p/mixed/staged.txt"; git -C "$tmp/p/mixed" add staged.txt
@@ -357,7 +369,7 @@ mkdir -p "$GHS/repos/tester__parked" "$tmp/p/parked"
357
369
  git init -q --bare "$GHS/git/tester/parked.git"
358
370
  git -C "$tmp/p/parked" init -q; git -C "$tmp/p/parked" symbolic-ref HEAD refs/heads/main
359
371
  echo hi > "$tmp/p/parked/README.md"; git -C "$tmp/p/parked" add -A; git -C "$tmp/p/parked" commit -q -m first
360
- git -C "$tmp/p/parked" remote add origin "$GHS/git/tester/parked.git"; git -C "$tmp/p/parked" push -q -u origin main
372
+ git -C "$tmp/p/parked" remote add origin "https://github.com/tester/parked.git"; git -C "$tmp/p/parked" push -q -u origin main
361
373
  git -C "$tmp/p/parked" checkout -q -b side
362
374
  run "$tmp/p/parked" --profile minimal --yes
363
375
  t "parked on another branch: rc 1" "$RC" "1"
package/scripts/init.sh CHANGED
@@ -21,7 +21,7 @@
21
21
  # --name <str> human project name (default: target basename)
22
22
  # --slug <str> short slug / mempalace wing (default: lowercased basename)
23
23
  # --repo <owner/repo> GitHub repo (default: <owner>/<slug>)
24
- # --owner-login <login> GitHub user/org login (default: gh api user)
24
+ # --owner-login <login> GitHub user/org login (default: forge_rest user)
25
25
  # --owner-name <str> human owner name (default: owner-login)
26
26
  # --project-number <int> Projects v2 number (enables board) (default: none -> board off)
27
27
  # --plans <mdx|markdown|none> plan file format (default: profile default)
@@ -40,6 +40,12 @@
40
40
  # --upgrade merge new kit features into an existing .claude/ (preserves your edits)
41
41
  # --dry-run print the scaffold plan and exit, writing nothing
42
42
  # --force overwrite without prompting
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 "$0")" && pwd)/lib/gh-rest.sh"
47
+ fi
48
+
43
49
  set -euo pipefail
44
50
 
45
51
  # ============================================================================
@@ -445,14 +451,14 @@ BASENAME="$(basename "$TARGET")"
445
451
  NAME_SRC="$(git_remote_repo_name "$TARGET" 2>/dev/null || true)"; NAME_SRC="${NAME_SRC:-$BASENAME}"
446
452
  [[ -z "$NAME" ]] && NAME="$NAME_SRC"
447
453
  [[ -z "$SLUG" ]] && SLUG="$(echo "$NAME_SRC" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9' '-' | sed -E 's/^-|-$//g')"
448
- if [[ -z "$GH_OWNER" ]]; then GH_OWNER="$(gh api user --jq .login 2>/dev/null || echo "")"; fi
454
+ if [[ -z "$GH_OWNER" ]]; then GH_OWNER="$(forge_rest user --jq .login 2>/dev/null || echo "")"; fi
449
455
  [[ -z "$OWNER_NAME" ]] && OWNER_NAME="${GH_OWNER:-owner}"
450
456
  # Prefer the project's ACTUAL GitHub remote over an <owner>/<dir-basename> guess — the local
451
457
  # directory name often differs from the repo name (would target a non-existent repo otherwise).
452
458
  if [[ -z "$REPO" && $INIT_ALREADY -eq 1 ]]; then
453
459
  REPO="$(jq -r '.github.repo // empty' "$(adapter_config_existing "$TARGET")" 2>/dev/null || true)"
454
460
  fi
455
- [[ -z "$REPO" ]] && REPO="$(cd "$TARGET" 2>/dev/null && gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || true)"
461
+ [[ -z "$REPO" ]] && REPO="$(forge_repo_from_git "$TARGET" 2>/dev/null || true)"
456
462
  [[ -z "$REPO" && -n "$GH_OWNER" ]] && REPO="$GH_OWNER/$SLUG"
457
463
  [[ -z "$REPO" ]] && REPO="$SLUG"
458
464
 
@@ -480,7 +486,7 @@ if [[ -z "$BASE_BRANCH" ]]; then
480
486
  BASE_BRANCH="$(jq -r '.github.baseBranch // .github.integrationBranch // .github.flow // empty' "$_bb_cfg" 2>/dev/null || true)"
481
487
  fi
482
488
  fi
483
- [[ -z "$BASE_BRANCH" ]] && BASE_BRANCH="$(cd "$TARGET" 2>/dev/null && gh repo view --json defaultBranchRef -q .defaultBranchRef.name 2>/dev/null || true)"
489
+ [[ -z "$BASE_BRANCH" && "$REPO" == */* ]] && BASE_BRANCH="$(gh_rest_repo_default_branch "$REPO" 2>/dev/null || true)"
484
490
  # The git + GitHub setup (#456) runs when it is wanted AND confirmed: --yes, or a terminal to ask
485
491
  # on. A dry run plans as if it were confirmed. A project with no `origin` remote that the setup is
486
492
  # about to give a repository integrates on `develop` (main stays the release branch).
@@ -1243,7 +1249,6 @@ safe_copy "$KIT_ROOT/scripts/lib/gh-project.sh" "$TARGET/scripts/lib/gh-proj
1243
1249
  safe_copy "$KIT_ROOT/scripts/lib/worktree-issue.sh" "$TARGET/scripts/lib/worktree-issue.sh"
1244
1250
  safe_copy "$KIT_ROOT/scripts/lib/role-identity.sh" "$TARGET/scripts/lib/role-identity.sh"
1245
1251
  safe_copy "$KIT_ROOT/scripts/lib/kit-local.sh" "$TARGET/scripts/lib/kit-local.sh"
1246
- safe_copy "$KIT_ROOT/scripts/lib/engine-adapter.sh" "$TARGET/scripts/lib/engine-adapter.sh"
1247
1252
  safe_copy "$KIT_ROOT/scripts/lib/effort-metrics.sh" "$TARGET/scripts/lib/effort-metrics.sh"
1248
1253
  safe_copy "$KIT_ROOT/scripts/lib/gh-log.sh" "$TARGET/scripts/lib/gh-log.sh"
1249
1254
  safe_copy "$KIT_ROOT/scripts/lib/kit-events.sh" "$TARGET/scripts/lib/kit-events.sh"
@@ -1252,7 +1257,7 @@ safe_copy "$KIT_ROOT/scripts/lib/board-view.sh" "$TARGET/scripts/lib/board-v
1252
1257
  safe_copy "$KIT_ROOT/scripts/lib/effort-plan.sh" "$TARGET/scripts/lib/effort-plan.sh"
1253
1258
  safe_copy "$KIT_ROOT/scripts/lib/worktree-start.sh" "$TARGET/scripts/lib/worktree-start.sh"
1254
1259
  # pr-evidence.sh is the helper rules/gate-and-review.md tells a project to source; without this copy
1255
- # `cckit lib` resolves to the project's own scripts/lib, where the helper would be missing.
1260
+ # `cckit agent lib` resolves to the project's own scripts/lib, where the helper would be missing.
1256
1261
  safe_copy "$KIT_ROOT/scripts/lib/pr-evidence.sh" "$TARGET/scripts/lib/pr-evidence.sh"
1257
1262
  safe_copy "$KIT_ROOT/scripts/lib/session-registry.sh" "$TARGET/scripts/lib/session-registry.sh"
1258
1263
  safe_copy "$KIT_ROOT/scripts/lib/kinds.sh" "$TARGET/scripts/lib/kinds.sh"
@@ -1420,7 +1425,7 @@ jq --arg g '$CLAUDE_PROJECT_DIR/.claude/hooks/guard-raw-git-ops.sh' \
1420
1425
  echo " + .claude/hooks/guard-raw-git-ops.sh (PreToolUse Bash, wired in tracked settings.json: raw gh/git -> cckit verb)"
1421
1426
 
1422
1427
  # ---- session-mail hook (all projects; init AND --upgrade; idempotent) ----
1423
- # One script on four events delivers `cckit msg` mail to a running session (E257.5). Wired in the
1428
+ # One script on four events delivers `cckit agent msg` mail to a running session (E257.5). Wired in the
1424
1429
  # TRACKED settings.json for the same reason as the raw-git guard: mail has to reach worktrees. A
1425
1430
  # registration that is already there is left as it is (its timeout or position may be the user's),
1426
1431
  # and a project that listed the hook in `upgrade.removed` is not re-wired.
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # install-test.sh — E537.6: scripts/install.sh refuses without git and says how to get it; with git
4
+ # it links bin/cckit into the target dir. Hermetic: a stripped PATH with a tools dir, a temp target.
5
+ # Run: bash scripts/install-test.sh
6
+ # errors: strict — a test runner: rc 1 on any failed assertion
7
+ set -u
8
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
9
+ fail=0
10
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
11
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
12
+ mkdir -p "$tmp/nogit" "$tmp/withgit" "$tmp/target"
13
+ # A PATH where git is absent: only the tools install.sh itself needs (ln, dirname, mkdir … from /bin and /usr/bin
14
+ # are reached through a `git`-less dir of symlinks, since /usr/bin holds git on macOS).
15
+ for c in ln dirname mkdir echo cd pwd basename sed cat uname; do p="$(command -v "$c" 2>/dev/null || true)"; [ -n "$p" ] && [ -x "$p" ] && ln -sf "$p" "$tmp/nogit/$c"; done
16
+ out="$(PATH="$tmp/nogit" /bin/bash "$ROOT/scripts/install.sh" "$tmp/target" 2>&1)"; rc=$?
17
+ t "without git: rc 1" "$rc" "1"
18
+ t "without git: nothing is linked" "$([ -e "$tmp/target/cckit" ] && echo linked || echo none)" "none"
19
+ t "without git: the refusal names git and the fix" "$(printf '%s' "$out" | grep -c 'cckit: git is required.*brew install git')" "1"
20
+ # With git: the link is made.
21
+ out="$(bash "$ROOT/scripts/install.sh" "$tmp/target" 2>&1)"; rc=$?
22
+ t "with git: rc 0" "$rc" "0"
23
+ t "with git: bin/cckit is linked" "$(readlink "$tmp/target/cckit")" "$ROOT/bin/cckit"
24
+ t "with git: the output names the link" "$(printf '%s' "$out" | grep -c "linked $tmp/target/cckit")" "1"
25
+ [ "$fail" -eq 0 ] && echo "ALL OK (install)"
26
+ exit "$fail"
@@ -3,6 +3,13 @@
3
3
  # Usage: ./scripts/install.sh [target-bin-dir] (default: ~/.local/bin, then /usr/local/bin)
4
4
  set -euo pipefail
5
5
 
6
+ # git is the one hard dependency of the core: every verb runs on it, and nothing works without it.
7
+ # Refused here, before anything is linked, with the way to get it.
8
+ command -v git >/dev/null 2>&1 || {
9
+ echo "cckit: git is required and is not on your PATH. Install it (macOS: xcode-select --install, or brew install git; Debian/Ubuntu: apt install git), then run this again." >&2
10
+ exit 1
11
+ }
12
+
6
13
  root="$(cd "$(dirname "$0")/.." && pwd)"
7
14
  src="$root/bin/cckit"
8
15
  [ -x "$src" ] || { echo "cckit: $src not found or not executable" >&2; exit 1; }
@@ -4,5 +4,5 @@
4
4
  # `paths:`, or split it into a short rule + a knowledge doc, then re-run --update to tighten.
5
5
  #
6
6
  # <path> <lines> | @resident <bytes>
7
- .claude/rules/effort-model.md 209
7
+ .claude/rules/effort-model.md 212
8
8
  .claude/rules/naming-and-ids.md 208
@@ -6,9 +6,11 @@
6
6
  #
7
7
  # Hermetic: kit-doctor.sh runs against a throwaway project and HOME on a sealed PATH — symlinks to
8
8
  # the real tools it needs, plus STUBS for everything that would reach the machine or the network
9
- # (uname, brew, gh, node, pnpm, ssh, curl, sysctl, and the package managers pipx / uv). The real
10
- # descriptors (integrations/mempalace.json, integrations/mlx-lm.json) are the ones under test, so
11
- # no real pipx, uv or brew is ever run and nothing is installed.
9
+ # (uname, brew, node, pnpm, ssh, sysctl, and the package managers pipx / uv), and the forge shim
10
+ # (scripts/lib/test-forge-shim.sh) for GitHub: its `curl` answers the REST API from env knobs and
11
+ # its `gh` fails on any subcommand but `gh auth token` (E537). The real descriptors
12
+ # (integrations/mempalace.json, integrations/mlx-lm.json) are the ones under test, so no real pipx,
13
+ # uv or brew is ever run and nothing is installed.
12
14
  # Run: bash scripts/kit-doctor-test.sh
13
15
  # errors: strict — a test runner: rc 1 on any failed assertion
14
16
  set -u
@@ -47,15 +49,14 @@ mk sysctl <<'EOF'
47
49
  #!/bin/sh
48
50
  echo "Stub Silicon"
49
51
  EOF
50
- mk gh <<'EOF'
51
- #!/bin/sh
52
- case "$1 ${2:-}" in
53
- "--version ") echo "gh version 2.50.0 (stub)" ;;
54
- "auth status") echo " - Token scopes: 'project', 'repo'" ;;
55
- "api user") echo "stub-user" ;;
56
- esac
57
- exit 0
58
- EOF
52
+ # The forge (E537): GitHub is REST over curl with a token. The shim's `curl` answers like the API
53
+ # and logs every request; its `gh` answers only `gh auth token` / `gh --version` and FAILS on any
54
+ # other subcommand, so a leftover gh call in the doctor is a red row here, not a silent pass.
55
+ # shellcheck source=/dev/null
56
+ . "$ROOT/scripts/lib/test-forge-shim.sh"
57
+ forge="$tmp/forge"; forge_shim_install "$forge"
58
+ export GH_LOG="$tmp/forge.log"; : > "$GH_LOG"
59
+ cp "$forge/gh" "$stubs/gh"
59
60
  mk node <<'EOF'
60
61
  #!/bin/sh
61
62
  echo v22.0.0
@@ -69,8 +70,13 @@ mk ssh <<'EOF'
69
70
  #!/bin/sh
70
71
  exit 1
71
72
  EOF
73
+ # curl: a request to the forge API goes to the shim; anything else (the local model server probe)
74
+ # answers with the exit code in $tmp/curl-rc.
72
75
  mk curl <<EOF
73
76
  #!/bin/sh
77
+ for a in "\$@"; do
78
+ case "\$a" in https://api.github.com/*) exec "$forge/curl" "\$@" ;; esac
79
+ done
74
80
  exit "\$(cat "$tmp/curl-rc")"
75
81
  EOF
76
82
 
@@ -119,8 +125,10 @@ doctor() {
119
125
  mkdir -p "$home"
120
126
  [ -f "$home/.gitconfig" ] || printf '[user]\n\tname = Stub User\n\temail = stub@example.invalid\n' > "$home/.gitconfig"
121
127
  ( cd "$proj" && PATH="$stubs:$sealed" HOME="$home" KIT_ASCII=1 NO_COLOR=1 LC_ALL=C \
128
+ GH_TOKEN="${DOCTOR_TOKEN-test-token}" CCKIT_FORGE="${DOCTOR_FORGE-github}" \
122
129
  bash "$DOCTOR" "$@" </dev/null 2> "$tmp/err" )
123
130
  }
131
+ frow() { printf '%s\n' "$1" | grep -E "^ +(ok|FAIL|warn|-) +$2 " | sed -E 's/^ +//; s/ +/ /g'; }
124
132
  rows() { printf '%s\n' "$1" | grep -E '^ +(ok|FAIL|warn|-) +(mempalace CLI|mlx-lm) ' | sed -E 's/^ +//; s/ +/ /g'; }
125
133
 
126
134
  # ── 0. the doctor holds no tool's recipe (the sub's acceptance, verbatim) ──────────────────────
@@ -140,6 +148,46 @@ hasnt "both keys false -> no Memory section" "$out_off" "Memory (MemPalace)"
140
148
  hasnt "both keys false -> no Local section" "$out_off" "Local model layer"
141
149
  t "both keys false -> no manager was called" "$(calls)" ""
142
150
 
151
+ # ── 1a. the forge rows (E537): a token is the sign-in; gh is optional and never installed ──────
152
+ has "forge: a working token -> github, signed in as the token's login" "$(frow "$out_bare" forge)" "ok forge github — signed in as @me"
153
+ has "forge: the login was read from GET user" "$(cat "$GH_LOG")" "GET user "
154
+ t "forge: no gh subcommand was run" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
155
+ has "gh: present -> an optional row, its version from gh --version" "$(frow "$out_bare" 'gh \(optional\)')" "ok gh (optional) 2.0.0 — its token is used when GH_TOKEN is unset"
156
+ has "token scope: Projects v2 off -> not needed" "$(frow "$out_bare" 'token scope:project')" "- token scope:project Projects v2 is off — not needed"
157
+ out="$(DOCTOR_FORGE=none DOCTOR_TOKEN= doctor "$tmp/h1" "$bare" --dry-run)"; r=$?
158
+ has "forge none -> a warning row that names git-only and how to sign in" "$(frow "$out" forge)" "warn forge none — git-only. Issues, pull requests and labels are unavailable until a token is set: export GH_TOKEN=<token>, or gh auth login"
159
+ t "forge none -> a warning, not a failure: exit 0" "$r" "0"
160
+ hasnt "forge none -> no token scope row" "$out" "token scope:project"
161
+ has "forge none -> listed under what is left to do" "$out" "Sign in to GitHub: export GH_TOKEN=<token> (or: gh auth login)"
162
+ : > "$GH_LOG"
163
+ out="$(DOCTOR_FORGE=none DOCTOR_TOKEN= doctor "$tmp/h1" "$bare" --yes)"
164
+ # --yes with gh present is the one place a gh subcommand is legitimate: the interactive sign-in.
165
+ t "forge none, --yes, gh present -> gh auth login is the sign-in offered, once" "$(grep -c '^GH-SUBCOMMAND gh auth login' "$GH_LOG")" "1"
166
+ t "forge none, --yes -> no API request without a token" "$(grep -c '^GET user' "$GH_LOG")" "0"
167
+ has "forge none, --yes, sign-in failed -> still the warning row" "$(frow "$out" forge)" "warn forge none — git-only"
168
+ out="$(GH_FAIL_EP=user doctor "$tmp/h1" "$bare" --dry-run)"; r=$?
169
+ has "forge: a token GitHub rejects -> a failing row" "$(frow "$out" forge)" "FAIL forge github — the token does not work (GH_TOKEN, GITHUB_TOKEN, or gh's). Re-issue it, or gh auth login"
170
+ t "forge: a rejected token -> exit 1" "$r" "1"
171
+ pv2="$(project pv2 '{"github":{"projectsV2":true,"repo":"o/r","baseBranch":"main"}}')"
172
+ out="$(doctor "$tmp/h1" "$pv2" --dry-run)"
173
+ has "token scope: Projects v2 on, a token with no scope header -> a skip row for a fine-grained token" "$(frow "$out" 'token scope:project')" "- token scope:project a fine-grained token lists no scopes — give it Projects access if the board stays empty"
174
+ has "base branch: read from GET repos/<r> default_branch" "$(cat "$GH_LOG")" "GET repos/o/r "
175
+ # The loose-issue row (E546.2): the count only; the default shim issues are an effort and a PR.
176
+ has "loose issues: a repo -> one ok row with the count" "$(frow "$out" 'loose issues')" "ok loose issues 0 in o/r"
177
+ has "loose issues: no repository -> a skip row" "$(frow "$out_bare" 'loose issues')" "- loose issues skipped — no repository"
178
+ out="$(DOCTOR_FORGE=none DOCTOR_TOKEN= doctor "$tmp/h1" "$pv2" --dry-run)"
179
+ has "loose issues: no forge -> a skip row, never a silent pass" "$(frow "$out" 'loose issues')" "- loose issues skipped — no forge"
180
+ rm -f "$stubs/gh"
181
+ : > "$log"
182
+ out="$(doctor "$tmp/h1" "$bare" --dry-run)"; r=$?
183
+ has "gh absent -> a skip row: a token works without it" "$(frow "$out" 'gh \(optional\)')" "- gh (optional) not installed — a GH_TOKEN works without it; install it for an interactive sign-in"
184
+ has "gh absent, a token -> the forge is still github" "$(frow "$out" forge)" "ok forge github — signed in as @me"
185
+ t "gh absent -> exit 0, gh is optional" "$r" "0"
186
+ out="$(doctor "$tmp/h1" "$bare" --yes)"
187
+ t "gh absent, --yes -> gh is never installed" "$(grep -c 'brew install gh' "$log")" "0"
188
+ cp "$forge/gh" "$stubs/gh"
189
+ : > "$GH_LOG"
190
+
143
191
  # ── 1b. on by default (#451): Lavish has a row in a project that set no key. Missing, it is a
144
192
  # skip row — reported, never installed, never a failure, whatever the flags. An explicit key gets
145
193
  # the hard row every other integration gets. The sealed PATH has no npx and no lavish-axi.