@jeiemgi/cckit 0.8.0 → 0.10.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 (309) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +169 -21
  3. package/README.md +505 -35
  4. package/SECURITY.md +5 -0
  5. package/bin/cckit +189 -20
  6. package/cckit.config.json +1 -1
  7. package/commands/kit-doctor.md +13 -5
  8. package/commands/kit-export-project.md +0 -2
  9. package/commands/kit-export-training.md +6 -9
  10. package/commands/kit-init.md +43 -13
  11. package/commands/kit-routines.md +1 -1
  12. package/commands/kit-update.md +11 -6
  13. package/databases/supabase/guide.html +106 -0
  14. package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
  15. package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
  16. package/databases/supabase.json +70 -0
  17. package/integrations/emil-design-eng.json +41 -0
  18. package/integrations/graft.json +81 -0
  19. package/integrations/impeccable.json +42 -0
  20. package/integrations/integration.schema.json +215 -0
  21. package/integrations/lavish.json +43 -0
  22. package/integrations/mempalace.json +28 -0
  23. package/integrations/mlx-lm.json +32 -0
  24. package/integrations/web-design-guidelines.json +42 -0
  25. package/kit.config.schema.json +183 -5
  26. package/package.json +4 -1
  27. package/profiles/automation.json +7 -1
  28. package/profiles/content.json +10 -2
  29. package/profiles/marketing.json +57 -0
  30. package/profiles/minimal.json +7 -1
  31. package/profiles/research.json +7 -1
  32. package/profiles/software.json +7 -1
  33. package/recipes/nextjs-shadcn.json +49 -0
  34. package/scripts/agent-skills-external.txt +45 -0
  35. package/scripts/agent-skills-lint-test.sh +131 -0
  36. package/scripts/agent-skills-lint.sh +115 -0
  37. package/scripts/agent-template-lint-test.sh +42 -0
  38. package/scripts/agent-template-lint.sh +58 -0
  39. package/scripts/annotate-setup.sh +1 -1
  40. package/scripts/autopilot-run-test.sh +338 -0
  41. package/scripts/autopilot-run.sh +448 -0
  42. package/scripts/autopilot-test.sh +8 -0
  43. package/scripts/autopilot.sh +10 -1
  44. package/scripts/benchmark/benchmark-test.sh +85 -0
  45. package/scripts/benchmark/checkpoint-test.sh +314 -0
  46. package/scripts/benchmark/checkpoint.sh +408 -0
  47. package/scripts/benchmark/lib/model.sh +31 -6
  48. package/scripts/benchmark/report.sh +17 -2
  49. package/scripts/benchmark/run-quality.sh +36 -10
  50. package/scripts/benchmark/verb-timings-test.sh +124 -0
  51. package/scripts/benchmark/verb-timings.sh +149 -0
  52. package/scripts/check.sh +29 -19
  53. package/scripts/content-skills-test.sh +144 -0
  54. package/scripts/copilot-loop-test.sh +25 -0
  55. package/scripts/database-supabase-test.sh +121 -0
  56. package/scripts/docs-marketing-words-test.sh +73 -0
  57. package/scripts/docs-record-tables-test.sh +72 -0
  58. package/scripts/guard-raw-git-ops-test.sh +8 -0
  59. package/scripts/hook-adapter-test.sh +193 -0
  60. package/scripts/init-content-test.sh +225 -0
  61. package/scripts/init-guided-test.sh +474 -0
  62. package/scripts/init-recipes-test.sh +104 -0
  63. package/scripts/init-upgrade-test.sh +341 -2
  64. package/scripts/init.sh +746 -95
  65. package/scripts/instruction-budget-baseline.txt +8 -0
  66. package/scripts/instruction-budget-lint-test.sh +166 -0
  67. package/scripts/instruction-budget-lint.sh +219 -0
  68. package/scripts/integrations-check-test.sh +200 -0
  69. package/scripts/integrations-check.sh +157 -0
  70. package/scripts/kit-add-test.sh +214 -0
  71. package/scripts/kit-add.sh +305 -5
  72. package/scripts/kit-adopt-test.sh +16 -0
  73. package/scripts/kit-adopt.sh +3 -2
  74. package/scripts/kit-digest.sh +2 -2
  75. package/scripts/kit-doctor-test.sh +293 -0
  76. package/scripts/kit-doctor.sh +272 -140
  77. package/scripts/kit-export-project-test.sh +3 -3
  78. package/scripts/kit-remove-test.sh +19 -0
  79. package/scripts/kit-routines.sh +2 -2
  80. package/scripts/kit-self-update.sh +1 -1
  81. package/scripts/kit-version-check-test.sh +4 -0
  82. package/scripts/kit-version-check.sh +4 -2
  83. package/scripts/knowledge-lint.sh +4 -4
  84. package/scripts/leak-fence-test.sh +89 -0
  85. package/scripts/lib/adapter-select-test.sh +136 -0
  86. package/scripts/lib/adapter-select.sh +158 -0
  87. package/scripts/lib/agent-def-test.sh +69 -0
  88. package/scripts/lib/agent-def.sh +106 -0
  89. package/scripts/lib/agent-launch-test.sh +212 -0
  90. package/scripts/lib/agent-launch.sh +335 -0
  91. package/scripts/lib/board-view-test.sh +11 -0
  92. package/scripts/lib/board-view.sh +42 -26
  93. package/scripts/lib/branch-owner-test.sh +26 -0
  94. package/scripts/lib/branch-owner.sh +16 -9
  95. package/scripts/lib/captain-test.sh +105 -0
  96. package/scripts/lib/captain.sh +87 -8
  97. package/scripts/lib/codex-hooks-test.sh +100 -0
  98. package/scripts/lib/codex-hooks.sh +69 -0
  99. package/scripts/lib/commitlint.sh +1 -1
  100. package/scripts/lib/content-kinds-gc-test.sh +88 -0
  101. package/scripts/lib/copilot-test.sh +70 -4
  102. package/scripts/lib/copilot.sh +66 -14
  103. package/scripts/lib/effort-dispatch-test.sh +3 -3
  104. package/scripts/lib/effort-metrics-test.sh +178 -1
  105. package/scripts/lib/effort-metrics.sh +188 -35
  106. package/scripts/lib/effort-ops-test.sh +217 -7
  107. package/scripts/lib/effort-ops.sh +281 -49
  108. package/scripts/lib/effort-parity-test.sh +49 -13
  109. package/scripts/lib/effort-plan-test.sh +337 -0
  110. package/scripts/lib/effort-plan.sh +200 -23
  111. package/scripts/lib/effort-slug.sh +16 -2
  112. package/scripts/lib/effort.sh +67 -12
  113. package/scripts/lib/errors-header-test.sh +1 -1
  114. package/scripts/lib/gh-project-test.sh +35 -1
  115. package/scripts/lib/gh-project.sh +37 -16
  116. package/scripts/lib/gh-rest-test.sh +330 -0
  117. package/scripts/lib/gh-rest.sh +304 -0
  118. package/scripts/lib/hook-refresh.sh +1 -1
  119. package/scripts/lib/init-github.sh +412 -0
  120. package/scripts/lib/init-guide.sh +630 -0
  121. package/scripts/lib/integration-install-test.sh +343 -0
  122. package/scripts/lib/integration-install.sh +257 -0
  123. package/scripts/lib/integrations-test.sh +366 -0
  124. package/scripts/lib/integrations.sh +244 -0
  125. package/scripts/lib/kinds-test.sh +125 -0
  126. package/scripts/lib/kinds.sh +66 -0
  127. package/scripts/lib/kit-brief-test.sh +22 -3
  128. package/scripts/lib/kit-brief.sh +45 -5
  129. package/scripts/lib/kit-config-resolve.sh +2 -2
  130. package/scripts/lib/kit-config-test.sh +64 -1
  131. package/scripts/lib/kit-config.sh +37 -1
  132. package/scripts/lib/kit-events.sh +7 -0
  133. package/scripts/lib/kit-gc-test.sh +173 -1
  134. package/scripts/lib/kit-gc.sh +244 -37
  135. package/scripts/lib/kit-hotfix.sh +216 -0
  136. package/scripts/lib/kit-interview-test.sh +93 -0
  137. package/scripts/lib/kit-interview.sh +117 -8
  138. package/scripts/lib/kit-lib-test.sh +1 -1
  139. package/scripts/lib/kit-lib.sh +3 -3
  140. package/scripts/lib/kit-local.sh +2 -2
  141. package/scripts/lib/kit-manifest.sh +33 -1
  142. package/scripts/lib/kit-profile-test.sh +3 -3
  143. package/scripts/lib/kit-status-test.sh +112 -4
  144. package/scripts/lib/kit-status.sh +246 -16
  145. package/scripts/lib/kit-task-ops-test.sh +37 -0
  146. package/scripts/lib/kit-task-ops.sh +362 -89
  147. package/scripts/lib/kto-hotfix-test.sh +232 -0
  148. package/scripts/lib/kto-task-close-test.sh +83 -0
  149. package/scripts/lib/kto-task-new-test.sh +95 -0
  150. package/scripts/lib/kto-task-pr-merge-test.sh +97 -6
  151. package/scripts/lib/kto-task-pr-test.sh +70 -0
  152. package/scripts/lib/leak-fence.sh +89 -0
  153. package/scripts/lib/light-task-run-test.sh +255 -0
  154. package/scripts/lib/light-task-test.sh +309 -0
  155. package/scripts/lib/light-task.sh +706 -0
  156. package/scripts/lib/next-test.sh +99 -0
  157. package/scripts/lib/next.sh +9 -3
  158. package/scripts/lib/orchestration-runtime-test.sh +72 -0
  159. package/scripts/lib/orchestration-runtime.sh +57 -5
  160. package/scripts/lib/plan-machine-test.sh +15 -2
  161. package/scripts/lib/plan-machine.sh +20 -7
  162. package/scripts/lib/plan-next-test.sh +1 -1
  163. package/scripts/lib/plan-next.sh +4 -4
  164. package/scripts/lib/pr-evidence-test.sh +3 -3
  165. package/scripts/lib/pr-evidence.sh +1 -1
  166. package/scripts/lib/qa-lane-test.sh +626 -0
  167. package/scripts/lib/qa-lane.sh +1357 -0
  168. package/scripts/lib/qa-lanes-test.sh +175 -0
  169. package/scripts/lib/react-detect.sh +1 -1
  170. package/scripts/lib/render-test.sh +1 -1
  171. package/scripts/lib/review-page-test.sh +318 -0
  172. package/scripts/lib/review-page.sh +369 -0
  173. package/scripts/lib/review-stage-test.sh +62 -11
  174. package/scripts/lib/review-stage.sh +42 -60
  175. package/scripts/lib/role-identity-test.sh +65 -0
  176. package/scripts/lib/role-identity.sh +25 -2
  177. package/scripts/lib/secret-guard.sh +3 -3
  178. package/scripts/lib/session-registry-test.sh +111 -0
  179. package/scripts/lib/session-registry.sh +233 -0
  180. package/scripts/lib/stage-receipt-test.sh +14 -1
  181. package/scripts/lib/stage-receipt.sh +13 -8
  182. package/scripts/lib/task-source-file.sh +309 -0
  183. package/scripts/lib/task-source.sh +130 -0
  184. package/scripts/lib/test-env-test.sh +3 -3
  185. package/scripts/lib/test-env.sh +7 -4
  186. package/scripts/lib/upgrade-report-test.sh +120 -0
  187. package/scripts/lib/upgrade-report.sh +138 -0
  188. package/scripts/lib/version-bump.sh +3 -3
  189. package/scripts/lib/wave-result-test.sh +80 -0
  190. package/scripts/lib/wave-result.sh +127 -0
  191. package/scripts/lib/worker-brief-test.sh +5 -0
  192. package/scripts/lib/worker-brief.sh +2 -2
  193. package/scripts/lib/worktree-issue-test.sh +30 -1
  194. package/scripts/lib/worktree-issue.sh +93 -9
  195. package/scripts/lib/worktree-ports-test.sh +57 -4
  196. package/scripts/lib/worktree-start-test.sh +197 -0
  197. package/scripts/lib/worktree-start.sh +169 -32
  198. package/scripts/lib/zsh-safety-test.sh +19 -3
  199. package/scripts/marketing-walkthrough-test.sh +152 -0
  200. package/scripts/night-grant-test.sh +37 -0
  201. package/scripts/night-grant.sh +448 -0
  202. package/scripts/night-run-test.sh +8 -0
  203. package/scripts/night-run.mjs +275 -0
  204. package/scripts/night-run.test.mjs +324 -0
  205. package/scripts/orchestrate-test.sh +190 -0
  206. package/scripts/orchestrate.sh +79 -8
  207. package/scripts/portable-test.sh +11 -2
  208. package/scripts/publish.sh +28 -3
  209. package/scripts/review-lint-test.sh +7 -7
  210. package/scripts/review-lint.sh +2 -2
  211. package/scripts/review-rules.conf +8 -0
  212. package/scripts/rule-recipes-test.sh +96 -0
  213. package/scripts/self-install-test.sh +39 -9
  214. package/scripts/setup-labels.sh +18 -1
  215. package/scripts/setup-milestones.sh +1 -1
  216. package/scripts/showcase.sh +1 -1
  217. package/scripts/skill-frontmatter-lint-test.sh +4 -4
  218. package/scripts/skill-frontmatter-lint.sh +1 -1
  219. package/scripts/status-test.sh +113 -2
  220. package/scripts/status.sh +16 -3
  221. package/scripts/task-sync-test.sh +154 -0
  222. package/scripts/task-sync.sh +243 -32
  223. package/scripts/test-runner-test.sh +158 -0
  224. package/scripts/test.sh +131 -23
  225. package/scripts/update-path-test.sh +279 -0
  226. package/scripts/ux-ds-audit.sh +1 -1
  227. package/scripts/ux-graph-scan.sh +6 -6
  228. package/scripts/wave-worker.sh +54 -0
  229. package/skills/kit-add/SKILL.md +77 -0
  230. package/skills/kit-autopilot/SKILL.md +123 -12
  231. package/skills/kit-cleanup/SKILL.md +5 -2
  232. package/skills/kit-contribute/SKILL.md +4 -4
  233. package/skills/kit-docs-writer/SKILL.md +16 -6
  234. package/skills/kit-effort-close/SKILL.md +17 -8
  235. package/skills/kit-effort-new/SKILL.md +15 -9
  236. package/skills/kit-effort-pr/SKILL.md +15 -7
  237. package/skills/kit-effort-start/SKILL.md +5 -2
  238. package/skills/kit-gc/SKILL.md +5 -2
  239. package/skills/kit-next/SKILL.md +5 -1
  240. package/skills/kit-onboard/SKILL.md +3 -3
  241. package/skills/kit-page/SKILL.md +93 -0
  242. package/skills/kit-plan-next/SKILL.md +8 -4
  243. package/skills/kit-security-sweep/SKILL.md +1 -3
  244. package/skills/kit-ship/SKILL.md +2 -3
  245. package/skills/kit-status/SKILL.md +35 -4
  246. package/skills/kit-task-new/SKILL.md +3 -3
  247. package/skills/kit-task-pr/SKILL.md +7 -2
  248. package/skills/kit-task-pr-merge/SKILL.md +7 -2
  249. package/skills/kit-task-start/SKILL.md +7 -7
  250. package/skills/kit-task-sync/SKILL.md +19 -3
  251. package/skills/kit-ux-audit/SKILL.md +3 -2
  252. package/templates/agents/auto-dev.md +5 -4
  253. package/templates/agents/backend.md +1 -1
  254. package/templates/agents/designer.md +2 -0
  255. package/templates/agents/devops.md +1 -1
  256. package/templates/agents/editor.md +9 -1
  257. package/templates/agents/frontend.md +1 -1
  258. package/templates/agents/local-delegate.md +1 -1
  259. package/templates/agents/pm.md +5 -5
  260. package/templates/agents/tech-lead.md +1 -1
  261. package/templates/benchmarks/SCHEMA.md +9 -3
  262. package/templates/codex/hooks.json.tmpl +89 -0
  263. package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
  264. package/templates/hooks/guard-raw-git-ops.sh.tmpl +27 -14
  265. package/templates/hooks/mempal_followup.sh.tmpl +2 -2
  266. package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
  267. package/templates/hooks/prepush_gate.sh.tmpl +4 -2
  268. package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
  269. package/templates/instructions.md.tmpl +174 -0
  270. package/templates/kit.config.json.tmpl +3 -3
  271. package/templates/knowledge-INDEX.md.tmpl +1 -1
  272. package/templates/lib/kit-sigil.sh.tmpl +1 -1
  273. package/templates/rules/authoring.md +106 -0
  274. package/templates/rules/branch-naming.md +40 -4
  275. package/templates/rules/code-retrieval.md +63 -0
  276. package/templates/rules/delegation-brief.md +0 -3
  277. package/templates/rules/design-routing.md +3 -3
  278. package/templates/rules/effort-model.md +14 -10
  279. package/templates/rules/gate-and-review.md +94 -0
  280. package/templates/rules/issue-lifecycle.md +88 -0
  281. package/templates/rules/knowledge-base.md +1 -1
  282. package/templates/rules/mempalace.md +1 -1
  283. package/templates/rules/merge-safety.md +108 -0
  284. package/templates/rules/naming-and-ids.md +23 -17
  285. package/templates/rules/plain-language.md +59 -0
  286. package/templates/rules/plan-next.md +9 -11
  287. package/templates/rules/react-annotate.md +6 -0
  288. package/templates/rules/review-pages.md +49 -0
  289. package/templates/rules/risk-tiered-review.md +13 -4
  290. package/templates/rules/shared-checkout.md +106 -0
  291. package/templates/rules/skill-gaps.md +2 -7
  292. package/templates/rules/task-management.md +13 -1
  293. package/templates/skills/brand-voice/SKILL.md +91 -0
  294. package/templates/skills/brand-voice/references/voice-template.md +61 -0
  295. package/templates/skills/campaign/SKILL.md +123 -0
  296. package/templates/skills/campaign/references/plan-template.md +55 -0
  297. package/templates/skills/concrete/SKILL.md +2 -2
  298. package/templates/skills/copywriting/SKILL.md +8 -1
  299. package/templates/skills/feature-build-refine/SKILL.md +2 -4
  300. package/templates/skills/morning-briefing/SKILL.md +2 -2
  301. package/templates/skills/page-design/SKILL.md +145 -0
  302. package/templates/skills/page-design/add.json +5 -0
  303. package/templates/skills/page-design/references/design-file-template.md +40 -0
  304. package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
  305. package/templates/skills/page-design/references/minimum-rules.md +42 -0
  306. package/templates/skills/speckit/SKILL.md +4 -5
  307. package/templates/skills/supabase-patterns/SKILL.md +1 -1
  308. package/commands/kit-add.md +0 -42
  309. package/templates/CLAUDE.md.tmpl +0 -106
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # effort-plan.sh — the session-fit view (`kit effort plan` when the project ships the kit CLI).
3
3
  #
4
- # Reads the open efforts (label:effort), groups them by their `flow:` tag, orders each flow by the
4
+ # Reads the open efforts — from GitHub (label:effort), or from the local executable named by
5
+ # `effort.planSource` when one is configured (falling back to GitHub when it fails or prints
6
+ # nothing; the output names the source used) — groups them by their `flow:` tag, orders each flow by the
5
7
  # native `blocked_by` edges, and packs the efforts into session-sized batches under a context budget.
6
8
  # Answers "which efforts fit in one session before the context window fills, and in what order?".
7
9
  #
@@ -11,37 +13,211 @@
11
13
  # in its own context; only a summary returns), which is the real lever that widens a session
12
14
  # (rules/agent-execution-routing.md).
13
15
  #
14
- # Requires: gh, jq. bash 3.2 (no associative arrays — parallel indexed arrays + linear scan; N small).
15
- # errors: strict — refuses to plan without gh + jq
16
+ # Requires: gh, jq for the GitHub read; a local source that answers needs neither. bash 3.2 (no
17
+ # associative arrays — parallel indexed arrays + linear scan; N small).
18
+ # `effort_plan` and the `_ep_*` plan-source helpers are bash-only; effort_open_rows /
19
+ # effort_next_pick / effort_next_rows / effort_cadence_md hold no arrays and run under zsh too,
20
+ # because `cckit status` reads them (scripts/lib/kit-status.sh). Those four always read GitHub —
21
+ # `effort.planSource` feeds `effort_plan` only.
22
+ # errors: strict — refuses to plan from GitHub without gh + jq
16
23
 
17
24
  EFFORT_REPO="${EFFORT_REPO:-${KIT_REPO:-}}"
18
25
 
19
- _ep_weight() { case "$1" in S) echo 1 ;; M) echo 2 ;; L) echo 4 ;; XL) echo 8 ;; *) echo 2 ;; esac; }
26
+ # _ep_weight <ctx> [issue] — session weight of a ctx: value. Anything outside S|M|L|XL weighs
27
+ # EP_UNSIZED_WEIGHT (2), and never silently: `?` (no ctx: label at all) is explained by the legend in
28
+ # the plan header, and any other value (ctx:XXL, ctx:xl) warns on stderr naming the value and issue.
29
+ # The fallback used to be a bare `*) echo 2`, which planned a mislabeled effort as an M.
30
+ EP_UNSIZED_WEIGHT=2
31
+ _ep_weight() {
32
+ case "$1" in
33
+ S) echo 1 ;; M) echo 2 ;; L) echo 4 ;; XL) echo 8 ;;
34
+ '?'|'') echo "$EP_UNSIZED_WEIGHT" ;;
35
+ *) echo "⚠ effort plan: ${2:+#$2 }carries ctx:$1, which is not S|M|L|XL — weighed $EP_UNSIZED_WEIGHT" >&2
36
+ echo "$EP_UNSIZED_WEIGHT" ;;
37
+ esac
38
+ }
39
+
40
+ # effort_open_rows [repo] — one TSV row per OPEN effort (label:effort), the single read both
41
+ # `effort_plan` (its GitHub source, via _ep_rows_github) and `cckit status` build on:
42
+ #
43
+ # number<TAB>flow<TAB>ctx<TAB>priority<TAB>blockers<TAB>open-blockers<TAB>title
44
+ #
45
+ # `blockers` is every native `blocked_by` number, `open-blockers` only the ones whose issue is still
46
+ # OPEN; each is a csv, or `-` when empty (a tab-separated `read` collapses an empty field, so no
47
+ # column is ever left blank). flow falls back to `—`, ctx to `?`, priority to `-`.
48
+ # rc 1 when gh/jq are absent, no repo is known, or the issue query fails — "could not read" must not
49
+ # look like "no efforts". No open effort is rc 0 with no rows. A blocked_by read that fails for one
50
+ # effort degrades to `-` for that effort (the dependency API is optional on older GitHub hosts).
51
+ # Costs one `gh issue list` plus one `gh api` per open effort.
52
+ effort_open_rows() {
53
+ local repo="${1:-${EFFORT_REPO:-${KIT_REPO:-}}}" raw n f c p t b tab
54
+ tab="$(printf '\t')"
55
+ command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || return 1
56
+ [ -n "$repo" ] || return 1
57
+ raw="$(gh issue list --repo "$repo" --label effort --state open --limit 100 --json number,title,labels 2>/dev/null)" || return 1
58
+ raw="$(printf '%s' "$raw" | jq -r '.[] | [ (.number|tostring),
59
+ ([.labels[].name|select(startswith("flow:"))|ltrimstr("flow:")]|first // "—"),
60
+ ([.labels[].name|select(startswith("ctx:"))|ltrimstr("ctx:")]|first // "?"),
61
+ ([.labels[].name|select(startswith("priority:"))|ltrimstr("priority:")]|first // "-"),
62
+ .title ] | @tsv' 2>/dev/null)" || return 1
63
+ [ -n "$raw" ] || return 0
64
+ while IFS="$tab" read -r n f c p t; do
65
+ [ -n "$n" ] || continue
66
+ b="$(gh api "repos/$repo/issues/$n/dependencies/blocked_by" 2>/dev/null \
67
+ | jq -r '[ ([.[].number|tostring]|join(",")),
68
+ ([.[]|select((.state // "open")|ascii_downcase == "open")|.number|tostring]|join(",")) ]
69
+ | map(if . == "" then "-" else . end) | @tsv' 2>/dev/null)"
70
+ [ -n "$b" ] || b="-$tab-"
71
+ printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$n" "$f" "$c" "$p" "$b" "$t"
72
+ done <<EOT
73
+ $raw
74
+ EOT
75
+ }
76
+
77
+ # effort_next_pick — pure. stdin: `effort_open_rows` rows; stdout: ONE row per flow, sorted by flow:
78
+ #
79
+ # flow<TAB>number<TAB>ctx<TAB>title<TAB>waiting
80
+ #
81
+ # `number` is the next effort that can start: among the flow's efforts with NO open blocker, the
82
+ # most urgent `priority:pN` (p0 → p3, unlabeled last), then the lowest issue number. `waiting` counts
83
+ # the flow's efforts that still have an open blocker. A flow where every effort is blocked keeps its
84
+ # row with `-` for number/ctx/title, so a stuck flow is visible instead of silently absent.
85
+ #
86
+ # What blocks: ANY open blocker — an effort in the same flow, an effort in another flow, or a plain
87
+ # issue. A closed blocker does not. (`effort_plan` orders a flow by its in-flow blockers only; that
88
+ # is a layout question. "Can this start now" is stricter: the work it waits on is not done.)
89
+ # The title drops the `[Effort] N · ` prefix and a leading `[Flow] ` tag, as `effort_plan` does.
90
+ effort_next_pick() {
91
+ awk -F'\t' '
92
+ function rank(p) { return (p ~ /^p[0-3]$/) ? substr(p, 2) + 0 : 9 }
93
+ NF >= 7 {
94
+ f = $2; seen[f] = 1
95
+ if ($6 != "-") { waiting[f]++; next }
96
+ r = rank($4); n = $1 + 0
97
+ if (!(f in bn) || r < br[f] || (r == br[f] && n < bn[f])) {
98
+ t = $7; sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", t); sub(/^\[[A-Za-z]+\] /, "", t)
99
+ bn[f] = n; br[f] = r; bc[f] = $3; bt[f] = t
100
+ }
101
+ }
102
+ END {
103
+ for (f in seen) {
104
+ if (f in bn) printf "%s\t%s\t%s\t%s\t%d\n", f, bn[f], bc[f], bt[f], waiting[f] + 0
105
+ else printf "%s\t-\t-\t-\t%d\n", f, waiting[f] + 0
106
+ }
107
+ }' | LC_ALL=C sort -t "$(printf '\t')" -k1,1
108
+ }
109
+
110
+ # effort_next_rows [repo] — the next startable effort per flow, from live state. rc 1 when the
111
+ # efforts could not be read (see effort_open_rows); no rows + rc 0 when no open effort exists.
112
+ effort_next_rows() {
113
+ local rows
114
+ rows="$(effort_open_rows "${1:-}")" || return 1
115
+ [ -n "$rows" ] || return 0
116
+ printf '%s\n' "$rows" | effort_next_pick
117
+ }
118
+
119
+ # effort_cadence_md — the weekly cadence as ONE markdown line. `cckit next` and `cckit status` both
120
+ # print this function's output, so the two verbs cannot drift apart on what the cadence is.
121
+ # Every verb named here runs as written. `cckit digest` is deliberately absent: it summarises one
122
+ # <path|url> with a local model, it does not report on the week.
123
+ effort_cadence_md() {
124
+ printf '%s\n' '**Weekly cadence** — Monday: `cckit plan` orders the week · daily: `cckit next` picks up one issue · Friday: `cckit gc` reports what can be pruned.'
125
+ }
126
+
127
+ # Rows travel between the readers and the planner as five fields joined by the ASCII unit
128
+ # separator: number, flow, ctx, title, blockers (comma-separated issue numbers). Not TAB — TAB is
129
+ # IFS whitespace, so `read` collapses two adjacent tabs and an empty column shifts every later one.
130
+ _EP_SEP=$'\037'
131
+
132
+ # _ep_rows_github <repo> — the open efforts from GitHub, in the planner's row format. It is
133
+ # effort_open_rows re-joined: the priority and open-blockers columns are dropped and the `-`
134
+ # empty-blockers placeholder becomes an empty field. rc 1 when the read fails; prints nothing when
135
+ # there are no open efforts.
136
+ _ep_rows_github() {
137
+ local rows
138
+ rows="$(effort_open_rows "$1")" || return 1
139
+ [[ -n "$rows" ]] || return 0
140
+ printf '%s\n' "$rows" | awk -F'\t' -v sep="$_EP_SEP" '
141
+ NF >= 7 { b = ($5 == "-" ? "" : $5); printf "%s%s%s%s%s%s%s%s%s\n", $1, sep, $2, sep, $3, sep, $7, sep, b }'
142
+ }
143
+
144
+ # _ep_project_root — the directory a relative `effort.planSource` resolves against: the project
145
+ # root the config file belongs to (config-path.sh), else the current directory.
146
+ _ep_project_root() {
147
+ local cfg=""
148
+ command -v kit_config_path >/dev/null 2>&1 && cfg="$(kit_config_path 2>/dev/null || true)"
149
+ [[ -n "$cfg" && -f "$cfg" ]] || { pwd; return 0; }
150
+ case "$cfg" in
151
+ */.claude/kit.config.json) (cd "$(dirname "$cfg")/.." 2>/dev/null && pwd) || pwd ;;
152
+ *) (cd "$(dirname "$cfg")" 2>/dev/null && pwd) || pwd ;;
153
+ esac
154
+ }
155
+
156
+ # _ep_source_rows — normalize a plan source's stdout (stdin here) to the internal row format.
157
+ # The source contract (effort.planSource):
158
+ # number<TAB>flow<TAB>ctx<TAB>title[<TAB>blockers] one line per open effort
159
+ # # age: <text> optional, anywhere; how old the snapshot is
160
+ # `blockers` is a comma-separated list of issue numbers (a leading # is accepted). Lines that start
161
+ # with # are metadata, and a line whose first column is not a number is ignored. An empty flow
162
+ # becomes "—" and an empty ctx "?", the same defaults the GitHub reader uses.
163
+ _ep_source_rows() {
164
+ awk -F'\t' -v sep="$_EP_SEP" '
165
+ /^#/ { next }
166
+ $1 ~ /^[0-9]+$/ {
167
+ f = ($2 == "" ? "—" : $2); c = ($3 == "" ? "?" : $3); b = $5; gsub(/[^0-9,]/, "", b)
168
+ printf "%s%s%s%s%s%s%s%s%s\n", $1, sep, f, sep, c, sep, $4, sep, b
169
+ }'
170
+ }
20
171
 
21
172
  effort_plan() {
22
- command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || { echo "effort plan: needs gh + jq" >&2; return 1; }
23
173
  local repo="$EFFORT_REPO" budget="${KIT_SESSION_BUDGET:-4}"
24
174
  [[ -n "$repo" ]] || { echo "effort plan: no repo (set KIT_REPO / EFFORT_REPO)" >&2; return 1; }
25
175
 
26
- # 1. open efforts + their flow:/ctx: labels (one query).
27
- local raw
28
- raw="$(gh issue list --repo "$repo" --label effort --state open --limit 100 \
29
- --json number,title,labels \
30
- --jq '.[] | [ (.number|tostring),
31
- ([.labels[].name|select(startswith("flow:"))|ltrimstr("flow:")]|first // "—"),
32
- ([.labels[].name|select(startswith("ctx:"))|ltrimstr("ctx:")]|first // "?"),
33
- .title ] | @tsv' 2>/dev/null)" \
34
- || { echo "effort plan: gh query failed (check gh auth)" >&2; return 1; }
35
- [[ -n "$raw" ]] || { echo "effort plan: no open efforts found" >&2; return 0; }
176
+ # 1. rows. A configured local source (effort.planSource, or EFFORT_PLAN_SOURCE per invocation)
177
+ # is tried first; if it is not executable, exits non-zero or prints no rows, the plan falls
178
+ # back to GitHub and says so. `srcline` is printed under the header either way — a plan that
179
+ # does not say what it was built from can be stale without anyone noticing.
180
+ local rows="" srcline="" fellback=""
181
+ local src="${EFFORT_PLAN_SOURCE:-${KIT_EFFORT_PLAN_SOURCE:-}}"
182
+ if [[ -n "$src" ]]; then
183
+ local root srcpath srcout src_rc=0 age
184
+ root="$(_ep_project_root)"
185
+ case "$src" in /*) srcpath="$src" ;; *) srcpath="$root/$src" ;; esac
186
+ if [[ ! -x "$srcpath" || -d "$srcpath" ]]; then
187
+ fellback="planSource $src is not executable"
188
+ else
189
+ srcout="$(cd "$root" 2>/dev/null && "$srcpath" "$repo")" || src_rc=$?
190
+ if [[ "$src_rc" -ne 0 ]]; then
191
+ fellback="planSource $src failed (exit $src_rc)"
192
+ else
193
+ rows="$(printf '%s\n' "$srcout" | _ep_source_rows)"
194
+ if [[ -z "$rows" ]]; then
195
+ fellback="planSource $src printed no rows"
196
+ else
197
+ age="$(printf '%s\n' "$srcout" | sed -n 's/^#[[:space:]]*age:[[:space:]]*//p' | sed -n 1p)"
198
+ srcline="planSource $src"
199
+ [[ -n "$age" ]] && srcline="$srcline · age $age"
200
+ fi
201
+ fi
202
+ fi
203
+ [[ -n "$fellback" ]] && echo "effort plan: $fellback — falling back to GitHub" >&2
204
+ fi
205
+ if [[ -z "$srcline" ]]; then
206
+ command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || { echo "effort plan: needs gh + jq" >&2; return 1; }
207
+ srcline="GitHub ($repo)"
208
+ [[ -n "$fellback" ]] && srcline="$srcline — $fellback, fell back"
209
+ rows="$(_ep_rows_github "$repo")" \
210
+ || { echo "effort plan: gh query failed (check gh auth)" >&2; return 1; }
211
+ [[ -n "$rows" ]] || { echo "effort plan: no open efforts found (source: $srcline)" >&2; return 0; }
212
+ fi
36
213
 
37
- # 2. read into parallel arrays + fetch blocked_by per effort (small N).
214
+ # 2. read into parallel arrays.
38
215
  local -a nums=() flows=() ctxs=() titles=() blocks=()
39
- local n f c t
40
- while IFS=$'\t' read -r n f c t; do
216
+ local n f c t bl
217
+ while IFS="$_EP_SEP" read -r n f c t bl; do
41
218
  [[ -n "$n" ]] || continue
42
- nums+=("$n"); flows+=("$f"); ctxs+=("$c"); titles+=("$t")
43
- blocks+=("$(gh api "repos/$repo/issues/$n/dependencies/blocked_by" --jq '[.[].number]|join(",")' 2>/dev/null)")
44
- done <<< "$raw"
219
+ nums+=("$n"); flows+=("$f"); ctxs+=("$c"); titles+=("$t"); blocks+=("$bl")
220
+ done <<< "$rows"
45
221
 
46
222
  # 3. distinct flows, first-seen order.
47
223
  local -a flowlist=()
@@ -49,7 +225,8 @@ effort_plan() {
49
225
  case " ${flowlist[*]-} " in *" $f "*) ;; *) flowlist+=("$f") ;; esac
50
226
  done
51
227
 
52
- printf '\n kit effort plan — session budget %s (ctx S=1 M=2 L=4 XL=8 · L/XL → delegate subs)\n' "$budget"
228
+ printf '\n kit effort plan — session budget %s (ctx S=1 M=2 L=4 XL=8 · ? = no ctx: label, weighed %s · L/XL → delegate subs)\n' "$budget" "$EP_UNSIZED_WEIGHT"
229
+ printf ' source: %s\n' "$srcline"
53
230
 
54
231
  local i j b
55
232
  for f in "${flowlist[@]}"; do
@@ -85,7 +262,7 @@ effort_plan() {
85
262
  local sess=1 load=0 batch=" "
86
263
  printf ' Session %s:\n' "$sess"
87
264
  for i in "${order[@]}"; do
88
- local w; w="$(_ep_weight "${ctxs[$i]}")"
265
+ local w; w="$(_ep_weight "${ctxs[$i]}" "${nums[$i]}")"
89
266
  local neednew=0
90
267
  (( load + w > budget )) && neednew=1
91
268
  for b in ${blocks[$i]//,/ }; do case "$batch" in *" $b "*) neednew=1 ;; esac; done
@@ -28,6 +28,15 @@
28
28
  # errors: mixed — _eff_slug/effort_display are pure; effort_slug_resolve needs gh;
29
29
  # effort_branch_rows_origin reaches the network and returns rc 1 when it cannot
30
30
 
31
+ # The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
32
+ if ! command -v cckit_gh_rest >/dev/null 2>&1; then
33
+ _ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
34
+ # shellcheck source=/dev/null
35
+ [ -f "$_ghr_lib" ] && . "$_ghr_lib"
36
+ unset _ghr_lib
37
+ fi
38
+ command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
39
+
31
40
  # Repo for the gh fallback — resolved from the same env effort.sh/kit-config populate.
32
41
  _eff_slug_repo() { printf '%s' "${EFFORT_REPO:-${KIT_REPO:-}}"; }
33
42
 
@@ -143,12 +152,17 @@ effort_slug_resolve() {
143
152
  if [ -z "$matches" ] && command -v gh >/dev/null 2>&1; then
144
153
  local repo; repo="$(_eff_slug_repo)"
145
154
  if [ -n "$repo" ]; then
155
+ if cckit_gh_rest; then
156
+ matches="$(gh_rest_issue_numbers_by_label "$repo" "slug:$norm" 2>/dev/null | grep -E '^[0-9]+$' | sort -un)"
157
+ else
146
158
  matches="$(gh issue list --repo "$repo" --state open --label "slug:$norm" \
147
159
  --json number -q '.[].number' 2>/dev/null | grep -E '^[0-9]+$' | sort -un)"
160
+ fi
148
161
  if [ -z "$matches" ]; then
149
162
  local in it
150
- matches="$(gh issue list --repo "$repo" --state open --search '[Effort] in:title' --limit 200 \
151
- --json number,title -q '.[] | "\(.number)\t\(.title)"' 2>/dev/null \
163
+ matches="$( { if cckit_gh_rest; then gh_rest_open_issue_titles "$repo" | grep -F '[Effort]'
164
+ else gh issue list --repo "$repo" --state open --search '[Effort] in:title' --limit 200 \
165
+ --json number,title -q '.[] | "\(.number)\t\(.title)"'; fi; } 2>/dev/null \
152
166
  | while IFS="$(printf '\t')" read -r in it; do
153
167
  [ "$(_eff_title_slug "$it")" = "$norm" ] && printf '%s\n' "$in"
154
168
  done | grep -E '^[0-9]+$' | sort -un)"
@@ -15,6 +15,15 @@
15
15
  # Requires: gh, jq, git. bash 3.2 compatible.
16
16
  # errors: strict — git mechanics: a failed link, snapshot or lint propagates
17
17
 
18
+ # The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
19
+ if ! command -v cckit_gh_rest >/dev/null 2>&1; then
20
+ _ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
21
+ # shellcheck source=/dev/null
22
+ [ -f "$_ghr_lib" ] && . "$_ghr_lib"
23
+ unset _ghr_lib
24
+ fi
25
+ command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
26
+
18
27
  # Repo resolves from kit.config.json (KIT_REPO) — load it if a caller hasn't already.
19
28
  if [[ -z "${KIT_REPO:-}" ]]; then
20
29
  _eff_root="$(git rev-parse --show-toplevel 2>/dev/null)"
@@ -24,6 +33,14 @@ if [[ -z "${KIT_REPO:-}" ]]; then
24
33
  fi
25
34
  unset _eff_root
26
35
  fi
36
+ # The kind vocabulary (kinds.sh): effort_pr_title takes the commit type from kit_kind_commit_type.
37
+ if ! command -v kit_kind_commit_type >/dev/null 2>&1; then
38
+ _eff_kinds="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/kinds.sh"
39
+ # shellcheck source=/dev/null
40
+ [ -f "$_eff_kinds" ] && . "$_eff_kinds"
41
+ unset _eff_kinds
42
+ fi
43
+
27
44
  EFFORT_REPO="${EFFORT_REPO:-${KIT_REPO:-}}"
28
45
 
29
46
  # Link a child issue as a native GitHub sub-issue of a parent.
@@ -150,7 +167,8 @@ effort_snapshot_merged_subs() {
150
167
  seq=$((seq + 1))
151
168
  short="$(printf '%.7s' "$oid")"; [[ -n "$short" ]] || short="pr$pr"
152
169
  stub="$(printf '%02d-%s' "$seq" "$short")"
153
- gh pr diff "$pr" --repo "$EFFORT_REPO" > "$dir/$stub.diff" 2>/dev/null || rm -f "$dir/$stub.diff"
170
+ if cckit_gh_rest; then gh_rest_pr_diff "$EFFORT_REPO" "$pr" > "$dir/$stub.diff" 2>/dev/null || rm -f "$dir/$stub.diff"
171
+ else gh pr diff "$pr" --repo "$EFFORT_REPO" > "$dir/$stub.diff" 2>/dev/null || rm -f "$dir/$stub.diff"; fi
154
172
  [[ -s "$dir/$stub.diff" ]] || { rm -f "$dir/$stub.diff"; seq=$((seq - 1)); continue; }
155
173
  jq -c -n --arg parent "$parent" --arg sub "${sub:-}" --arg sha "${oid:-}" \
156
174
  --arg subject "$title" --arg pr "$pr" --arg file "$stub.diff" \
@@ -174,18 +192,55 @@ EOF_ROWS
174
192
  # opens it. The MANDATORY element is the [#N] effort id — a PR title without it is a review blocker
175
193
  # (effort-model.md), enforced by effort_pr_title_check.
176
194
  #
177
- # effort_pr_title <num> <name> [role_display] — compose the canonical title:
178
- # effort_pr_title 115 "adoption hardening" -> "[#115] adoption hardening"
179
- # effort_pr_title 115 "adoption hardening" "Tech Lead" -> "[Tech Lead] [#115] adoption hardening"
180
- # A full parent title ("[Effort] 115 · [Core] adoption hardening") is accepted too — the
181
- # "[Effort] N · " prefix is peeled so the id is never duplicated.
195
+ # effort_pr_title <num> <name> [labels_csv] [type] [role_display] — compose the title (#237).
196
+ # PRs are squash-merged, so the title becomes the commit release-please reads and the commitlint
197
+ # gate (.github/workflows/commitlint.yml) checks. The default is therefore a Conventional Commit
198
+ # subject with the id trailing, which passes both commitlint_check and effort_pr_title_check:
199
+ # effort_pr_title 115 "adoption hardening" -> "feat: adoption hardening [#115]"
200
+ # effort_pr_title 115 "adoption hardening" "flow:core,kind:chore" -> "chore(core): adoption hardening [#115]"
201
+ # effort_pr_title 115 "[Effort] 115 · [Core] adoption hardening" -> "feat(core): adoption hardening [#115]"
202
+ # scope the `flow:<flow>` label, else the name's leading [Flow] tag; lowercased, and dropped
203
+ # when it is not a valid Conventional Commit scope. The tag is peeled from the name.
204
+ # type the explicit <type> (`effort pr --type`), else the `kind:` label mapped as kto_pr_title
205
+ # maps it (kind:task and anything unknown -> feat; a content kind -> docs; a `bug` label -> fix).
206
+ # A full parent title is accepted — the "[Effort] N · " prefix is peeled so the id is never doubled.
207
+ # pr.titleStyle = issue-title (KIT_PR_TITLE_STYLE) keeps the non-conventional form, for a repo with
208
+ # no commitlint gate: "[Role] [#N] <name>" (the role prefix only when <role_display> is given).
182
209
  effort_pr_title() {
183
- local num="${1:-}" name="${2:-}" role="${3:-}"
210
+ local num="${1:-}" name="${2:-}" labels="${3:-}" ctype="${4:-}" role="${5:-}" tag scope kind
184
211
  num="${num#\#}"
185
212
  name="$(printf '%s' "$name" | sed -E 's/^\[Effort\] [0-9]+ · ?//')"
186
213
  [ -n "$name" ] || name="effort"
187
- if [ -n "$role" ]; then printf '[%s] [#%s] %s' "$role" "$num" "$name"
188
- else printf '[#%s] %s' "$num" "$name"; fi
214
+ if [ "${KIT_PR_TITLE_STYLE:-conventional}" = "issue-title" ]; then
215
+ if [ -n "$role" ]; then printf '[%s] [#%s] %s' "$role" "$num" "$name"
216
+ else printf '[#%s] %s' "$num" "$name"; fi
217
+ return 0
218
+ fi
219
+ tag="$(printf '%s' "$name" | sed -nE 's/^\[([^]]+)\] +.*$/\1/p')"
220
+ if [ -n "$tag" ]; then
221
+ name="$(printf '%s' "$name" | sed -E 's/^\[[^]]+\] +//')"
222
+ [ -n "$name" ] || name="effort"
223
+ fi
224
+ scope="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^flow://p' | sed -n 1p)"
225
+ [ -n "$scope" ] || scope="$tag"
226
+ scope="$(printf '%s' "$scope" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')"
227
+ grep -qE '^[a-z0-9][a-z0-9._/-]*$' <<<"$scope" || scope=""
228
+ if [ -z "$ctype" ]; then
229
+ kind="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^kind://p' | sed -n 1p)"
230
+ if command -v kit_kind_commit_type >/dev/null 2>&1; then
231
+ ctype="$(kit_kind_commit_type "$kind")" # kinds.sh: a content kind titles as `docs`
232
+ else
233
+ case "$kind" in
234
+ feat|chore|docs|ci|test|perf|refactor|fix) ctype="$kind" ;;
235
+ bug) ctype=fix ;;
236
+ post|campaign|brand|research) ctype=docs ;;
237
+ *) ctype=feat ;;
238
+ esac
239
+ fi
240
+ case ",$labels," in *,bug,*) ctype=fix ;; esac
241
+ fi
242
+ if [ -n "$scope" ]; then printf '%s(%s): %s [#%s]' "$ctype" "$scope" "$name" "$num"
243
+ else printf '%s: %s [#%s]' "$ctype" "$name" "$num"; fi
189
244
  }
190
245
 
191
246
  # effort_pr_title_check <title> [num] — rc 0 iff <title> carries the effort id token [#N] (the exact
@@ -198,7 +253,7 @@ effort_pr_title_check() {
198
253
  case "$title" in *"[#$num]"*) return 0 ;; esac
199
254
  echo "effort_pr_title_check: PR title lacks the [#$num] effort id: '$title'" >&2; return 1
200
255
  fi
201
- printf '%s' "$title" | grep -qE '\[#[0-9]+\]' && return 0
256
+ grep -qE '\[#[0-9]+\]' <<<"$title" && return 0
202
257
  echo "effort_pr_title_check: PR title lacks a [#N] effort id: '$title'" >&2; return 1
203
258
  }
204
259
 
@@ -257,13 +312,13 @@ effort_title_lint() {
257
312
  case "$name" in *" — "*|*" · "*|*" / "*) reasons+=("no ' — ' / ' · ' / ' / ' sub-clauses — one clear phrase") ;; esac
258
313
  case "$name" in *—*|*▾*|*▸*|*→*|*✓*|*✗*|*…*|*•*) reasons+=("no glyphs (— ▾ ▸ → ✓ ✗ … •) in the title") ;; esac
259
314
  # code identifiers: file extensions, snake_case, or a code-dir path.
260
- if printf '%s' "$name" | grep -qE '\.(sh|ts|tsx|js|mjs|json|css|md|ya?ml)([^A-Za-z0-9]|$)|[a-z0-9]+_[a-z0-9]+|(^|[^A-Za-z])(scripts|apps|packages|src)/'; then
315
+ if grep -qE '\.(sh|ts|tsx|js|mjs|json|css|md|ya?ml)([^A-Za-z0-9]|$)|[a-z0-9]+_[a-z0-9]+|(^|[^A-Za-z])(scripts|apps|packages|src)/' <<<"$name"; then
261
316
  reasons+=("no code identifiers (file names, paths, snake_case) — name the outcome")
262
317
  fi
263
318
  # jargon denylist (word-boundary, case-insensitive).
264
319
  local w
265
320
  for w in $EFFORT_TITLE_JARGON; do
266
- printf '%s' "$name" | grep -qiwE "$w" && reasons+=("jargon word '$w' — use plain language")
321
+ grep -qiwE "$w" <<<"$name" && reasons+=("jargon word '$w' — use plain language")
267
322
  done
268
323
  # word count ≤ 6.
269
324
  local wc; wc=$(printf '%s\n' "$name" | wc -w | tr -d ' ')
@@ -29,7 +29,7 @@ errors_header() {
29
29
  # blanks skipped, comments taken up to the first line of code. A later `# errors:` line in the
30
30
  # body is not the file's declaration. A fixed line window would be wrong — two libs carry headers
31
31
  # that run past 25 lines.
32
- awk 'NR==1 && /^#!/ {next} /^[[:space:]]*#/ {print; next} /^[[:space:]]*$/ {next} {exit}' "$1" | sed -n 's/^# errors:[[:space:]]*\([a-z-]*\).*/\1/p' | head -1
32
+ awk 'NR==1 && /^#!/ {next} /^[[:space:]]*#/ {print; next} /^[[:space:]]*$/ {next} {exit}' "$1" | sed -n 's/^# errors:[[:space:]]*\([a-z-]*\).*/\1/p' | sed -n 1p
33
33
  }
34
34
 
35
35
  # ── 1. every lib file declares one, and it is in the vocabulary ────────────────────────────────
@@ -45,7 +45,7 @@ cat > "$tmp/bin/gh" <<'SH'
45
45
  # Record the query, then emit JSON under whichever root the query selected.
46
46
  q=""; for a in "$@"; do case "$a" in query=*) q="${a#query=}" ;; esac; done
47
47
  printf '%s\n' "$q" >> "$GH_QUERY_LOG"
48
- if printf '%s' "$q" | grep -q 'organization(login'; then root=organization; else root=user; fi
48
+ if grep -q 'organization(login' <<<"$q"; then root=organization; else root=user; fi
49
49
  cat <<JSON
50
50
  {"data":{"$root":{"projectV2":{"id":"PVT_org123","fields":{"nodes":[
51
51
  {"__typename":"ProjectV2SingleSelectField","id":"F_status","name":"Status","options":[{"id":"O_todo","name":"Todo"}]},
@@ -92,5 +92,39 @@ t "project_issue_status returns the board Status for our project" "$st" "In Prog
92
92
  PATH="$tmp/bin2:$PATH" KIT_REPO="" KIT_PROJECT_NUMBER="" bash -c "source '$LIB/gh-project.sh'; project_issue_status 42" >/dev/null 2>&1
93
93
  t "project_issue_status fails (rc 1) with unresolved repo/number" "$?" "1"
94
94
 
95
+ # ── role_option_id: any board Role option resolves, not a fixed list (#378) ─────────────────────
96
+ # capture-project-ids.sh writes ROLE_OPT_<NAME> for every option the board has; the lookup reads
97
+ # that variable by normalized name. Run under bash AND zsh — these libs are sourced into both, and
98
+ # bash-only ${!var} indirection dies in zsh with "bad substitution".
99
+ for rsh in bash zsh; do
100
+ command -v "$rsh" >/dev/null 2>&1 || continue
101
+ rq() { # <role> -> stdout of role_option_id (stderr to $tmp/rerr)
102
+ ROLE_OPT_BACKEND=x ROLE_OPT_TECH_LEAD=tl ROLE_OPT_DATA_ENG=de KIT_CONFIG=/nonexistent \
103
+ "$rsh" -c "source '$LIB/gh-project.sh'; role_option_id \"\$1\"" _ "$1" 2>"$tmp/rerr"
104
+ }
105
+ t "[$rsh] role_option_id backend" "$(rq backend)" "x"
106
+ t "[$rsh] role_option_id Backend" "$(rq Backend)" "x"
107
+ t "[$rsh] role_option_id Tech Lead" "$(rq 'Tech Lead')" "tl"
108
+ t "[$rsh] role_option_id data-eng" "$(rq data-eng)" "de"
109
+ t "[$rsh] known role is silent" "$(rq backend >/dev/null; cat "$tmp/rerr")" ""
110
+ t "[$rsh] unknown role -> empty stdout" "$(rq astronaut)" ""
111
+ rq astronaut >/dev/null
112
+ has "[$rsh] unknown role warns on stderr" "$(cat "$tmp/rerr")" "ROLE_OPT_ASTRONAUT"
113
+ has "[$rsh] the warning names the role" "$(cat "$tmp/rerr")" "astronaut"
114
+ t "[$rsh] empty role -> empty, no warning" "$(rq ''; cat "$tmp/rerr")" ""
115
+ # A name outside ^[A-Z0-9_]+$ must never reach the variable expansion.
116
+ rm -f "$tmp/pwned"
117
+ for evil in "x\$(touch $tmp/pwned)" "x;touch $tmp/pwned" "x\`touch $tmp/pwned\`" "BACKEND
118
+ \$(touch $tmp/pwned)" 'a}b' 'é'; do
119
+ t "[$rsh] unsafe role name -> empty stdout" "$(rq "$evil")" ""
120
+ rq "$evil" >/dev/null
121
+ has "[$rsh] unsafe role name warns" "$(cat "$tmp/rerr")" "role"
122
+ case "$(cat "$tmp/rerr")" in *"bad substitution"*|*"parse error"*|*"syntax error"*)
123
+ echo "FAIL: [$rsh] unsafe role name reached the shell: $(cat "$tmp/rerr")"; fail=1 ;; esac
124
+ done
125
+ [ -e "$tmp/pwned" ] && { echo "FAIL: [$rsh] role_option_id evaluated its argument"; fail=1; } \
126
+ || echo "ok: [$rsh] role_option_id evaluates nothing from its argument"
127
+ done
128
+
95
129
  [ "$fail" -eq 0 ] && echo "ALL OK (gh-project)" || echo "gh-project: FAILURES"
96
130
  exit "$fail"
@@ -24,6 +24,14 @@ if [ -f "$SCRIPT_DIR/lib/gh-log.sh" ]; then
24
24
  fi
25
25
  type gh_log >/dev/null 2>&1 || gh_log() { :; }
26
26
 
27
+ # The transport switch (#396): Projects v2 is GraphQL-only, so in rest mode (a cloud session) every
28
+ # board function below prints the one skip notice and returns 0 with no output.
29
+ if ! type cckit_board_skipped >/dev/null 2>&1 && [ -f "$SCRIPT_DIR/lib/gh-rest.sh" ]; then
30
+ # shellcheck source=gh-rest.sh
31
+ . "$SCRIPT_DIR/lib/gh-rest.sh"
32
+ fi
33
+ type cckit_board_skipped >/dev/null 2>&1 || cckit_board_skipped() { return 1; }
34
+
27
35
  # Worktree-durable location for the captured project IDs (#532). The legacy
28
36
  # scripts/.project-ids.env is gitignored + untracked, so it is ABSENT in every worktree —
29
37
  # load_project_ids then no-ops and board updates silently fail (root cause of board drift).
@@ -39,6 +47,7 @@ PROJECT_ENV="$(_ghp_shared_env || printf '%s/.project-ids.env' "$SCRIPT_DIR")"
39
47
  PROJECT_ENV_LEGACY="$SCRIPT_DIR/.project-ids.env" # pre-#532 per-checkout path
40
48
 
41
49
  load_project_ids() {
50
+ cckit_board_skipped && return 0
42
51
  # First run in a checkout that still has the legacy file: migrate it to the shared path.
43
52
  if [[ ! -f "$PROJECT_ENV" && -f "$PROJECT_ENV_LEGACY" ]]; then
44
53
  cp "$PROJECT_ENV_LEGACY" "$PROJECT_ENV" 2>/dev/null || PROJECT_ENV="$PROJECT_ENV_LEGACY"
@@ -53,6 +62,7 @@ load_project_ids() {
53
62
 
54
63
  # Add an issue/PR (by node ID) to the project. Echoes the new item ID.
55
64
  project_add_item() {
65
+ cckit_board_skipped && return 0
56
66
  gh_log graphql mutation "project_add_item" "gh-project"
57
67
  gh api graphql \
58
68
  -f query='mutation($project:ID!, $content:ID!) {
@@ -64,6 +74,7 @@ project_add_item() {
64
74
 
65
75
  # Set a single-select field. Args: <item_id> <field_id> <option_id>
66
76
  project_set_single_select() {
77
+ cckit_board_skipped && return 0
67
78
  gh_log graphql mutation "project_set_single_select" "gh-project"
68
79
  gh api graphql \
69
80
  -f query='mutation($project:ID!, $item:ID!, $field:ID!, $option:String!) {
@@ -77,6 +88,7 @@ project_set_single_select() {
77
88
 
78
89
  # Set a text field. Args: <item_id> <field_id> <text>
79
90
  project_set_text() {
91
+ cckit_board_skipped && return 0
80
92
  gh_log graphql mutation "project_set_text" "gh-project"
81
93
  gh api graphql \
82
94
  -f query='mutation($project:ID!, $item:ID!, $field:ID!, $text:String!) {
@@ -87,27 +99,34 @@ project_set_text() {
87
99
  -f project="$PROJECT_ID" -f item="$1" -f field="$2" -f text="$3" >/dev/null
88
100
  }
89
101
 
90
- # Resolve an option ID from a human name via explicit case lookup (#307).
102
+ # Resolve an option ID from a human name.
91
103
  # Names are normalized: uppercased, spaces/hyphens -> underscores.
92
104
  # role_option_id "Tech Lead" -> $ROLE_OPT_TECH_LEAD
93
105
  # status_option_id "In Review" -> $STATUS_OPT_IN_REVIEW
94
106
  # No ${!var} indirection: these libs are sourced into zsh sessions too, where
95
- # bash-only indirection dies with "bad substitution". Unknown names echo empty.
107
+ # bash-only indirection dies with "bad substitution" (#307).
96
108
  _norm() { echo "$1" | tr '[:lower:]' '[:upper:]' | tr ' -' '__'; }
109
+ # role_option_id <name> — ANY board Role option, not a fixed list (#378): capture-project-ids.sh
110
+ # writes ROLE_OPT_<NAME> for every option the board has, so the lookup reads that variable by
111
+ # name. The name is expanded through eval (portable to bash and zsh), and only after it matches
112
+ # ^[A-Z0-9_]+$ byte-for-byte — anything else is refused before the eval, so the argument can never
113
+ # run as code. No option for the role: empty stdout plus a warning on stderr, so a Role field left
114
+ # unset is reported instead of silent. An empty name asks nothing and prints nothing.
97
115
  role_option_id() {
98
- case "$(_norm "$1")" in
99
- DESIGNER) echo "${ROLE_OPT_DESIGNER:-}" ;;
100
- DEVOPS) echo "${ROLE_OPT_DEVOPS:-}" ;;
101
- PM) echo "${ROLE_OPT_PM:-}" ;;
102
- FRONTEND) echo "${ROLE_OPT_FRONTEND:-}" ;;
103
- TAURI) echo "${ROLE_OPT_TAURI:-}" ;;
104
- AI_ENG) echo "${ROLE_OPT_AI_ENG:-}" ;;
105
- SECURITY) echo "${ROLE_OPT_SECURITY:-}" ;;
106
- QA) echo "${ROLE_OPT_QA:-}" ;;
107
- TECH_LEAD) echo "${ROLE_OPT_TECH_LEAD:-}" ;;
108
- RESEARCH) echo "${ROLE_OPT_RESEARCH:-}" ;;
109
- *) echo "" ;;
116
+ local LC_ALL=C _roi_name="" _roi_val=""
117
+ [ -n "${1:-}" ] || return 0
118
+ _roi_name="$(_norm "$1")"
119
+ case "$_roi_name" in
120
+ ''|*[!A-Z0-9_]*)
121
+ echo "⚠ board Role not set: role '$1' is not a usable option name (letters, digits, spaces, hyphens, underscores only)" >&2
122
+ echo ""
123
+ return 0 ;;
110
124
  esac
125
+ eval "_roi_val=\"\${ROLE_OPT_${_roi_name}:-}\""
126
+ if [ -z "$_roi_val" ]; then
127
+ echo "⚠ board Role not set: no Role option for '$1' (ROLE_OPT_${_roi_name} is not captured) — add the option to the board's Role field, then re-run scripts/capture-project-ids.sh" >&2
128
+ fi
129
+ echo "$_roi_val"
111
130
  }
112
131
  status_option_id() {
113
132
  case "$(_norm "$1")" in
@@ -181,6 +200,7 @@ _ghp_resolve_repo() {
181
200
  # an issue's cards cheaply (O(1) per issue) whether the board is user- or org-owned, so this finder
182
201
  # never paginates. An issue belongs to few projects, so first:20 covers it without a loop.
183
202
  project_find_item_by_issue() {
203
+ cckit_board_skipped && return 0
184
204
  local issue_num="$1"
185
205
  local pnum="${2:-$(_ghp_resolve_pnum)}"
186
206
  local repo owner name resp item_id
@@ -207,7 +227,7 @@ project_find_item_by_issue() {
207
227
  fi
208
228
  # Pick the card whose project number matches OUR board; empty if the issue isn't on it.
209
229
  item_id=$(printf '%s' "$resp" | jq -r --argjson n "$pnum" \
210
- '.data.repository.issue.projectItems.nodes[] | select(.project.number==$n) | .id' 2>/dev/null | head -1)
230
+ '.data.repository.issue.projectItems.nodes[] | select(.project.number==$n) | .id' 2>/dev/null | sed -n 1p)
211
231
  echo "$item_id"
212
232
  }
213
233
 
@@ -216,6 +236,7 @@ project_find_item_by_issue() {
216
236
  # The cheap issue.projectItems lookup, same as project_find_item_by_issue. A claim precheck reads this
217
237
  # before starting an issue so it can warn on a collision (another session already In Progress). #124.
218
238
  project_issue_status() {
239
+ cckit_board_skipped && return 0
219
240
  local issue_num="$1" pnum="${2:-$(_ghp_resolve_pnum)}" repo owner name resp
220
241
  repo="$(_ghp_resolve_repo)"; owner="${repo%%/*}"; name="${repo##*/}"
221
242
  [ -n "$owner" ] && [ -n "$name" ] && [ -n "$pnum" ] || return 1
@@ -224,5 +245,5 @@ project_issue_status() {
224
245
  -F o="$owner" -F r="$name" -F n="$issue_num" 2>/dev/null)" || return 1
225
246
  printf '%s' "$resp" | jq -r --argjson n "$pnum" \
226
247
  '.data.repository.issue.projectItems.nodes[]? | select(.project.number==$n) | .fieldValueByName.name // empty' \
227
- 2>/dev/null | head -1
248
+ 2>/dev/null | sed -n 1p
228
249
  }