@jeiemgi/cckit 0.11.0 → 0.13.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 (549) hide show
  1. package/.claude-plugin/plugin.json +4 -2
  2. package/AGENTS.md +22 -238
  3. package/README.md +66 -56
  4. package/SECURITY.md +4 -4
  5. package/bin/PROMPTS.md +12 -0
  6. package/bin/cckit +181 -140
  7. package/cckit.config.json +1 -1
  8. package/kit/PROMPTS.md +14 -0
  9. package/{commands → kit/commands}/kit-doctor.md +3 -4
  10. package/{commands → kit/commands}/kit-export-project.md +1 -1
  11. package/{commands → kit/commands}/kit-init.md +8 -20
  12. package/{commands → kit/commands}/kit-routines.md +1 -1
  13. package/{commands → kit/commands}/kit-update.md +3 -3
  14. package/kit/completions/cckit.bash +9 -0
  15. package/{databases → kit/databases}/supabase.json +1 -1
  16. package/{integrations → kit/integrations}/integration.schema.json +3 -3
  17. package/kit/interview/global.json +54 -0
  18. package/kit/interview/project.json +133 -0
  19. package/kit/modules/qa.json +63 -0
  20. package/kit/modules/software.json +48 -0
  21. package/{profiles → kit/profiles}/automation.json +1 -3
  22. package/{profiles → kit/profiles}/content.json +0 -2
  23. package/{profiles → kit/profiles}/marketing.json +0 -2
  24. package/{profiles → kit/profiles}/minimal.json +1 -3
  25. package/{profiles → kit/profiles}/research.json +1 -3
  26. package/{profiles → kit/profiles}/software.json +0 -2
  27. package/kit/routines/catalogue.json +84 -0
  28. package/{skills → kit/skills}/kit-add/SKILL.md +4 -4
  29. package/kit/skills/kit-advisor/SKILL.md +75 -0
  30. package/kit/skills/kit-advisor/references/close.md +53 -0
  31. package/kit/skills/kit-advisor/references/grill.md +69 -0
  32. package/kit/skills/kit-advisor/references/orchestrate.md +56 -0
  33. package/kit/skills/kit-advisor/references/plan.md +64 -0
  34. package/kit/skills/kit-advisor/references/review.md +47 -0
  35. package/kit/skills/kit-advisor/references/step-report.md +61 -0
  36. package/{skills → kit/skills}/kit-annotate/SKILL.md +2 -4
  37. package/{skills → kit/skills}/kit-autopilot/SKILL.md +7 -7
  38. package/{skills → kit/skills}/kit-cleanup/SKILL.md +4 -4
  39. package/{skills → kit/skills}/kit-contribute/SKILL.md +8 -12
  40. package/{skills → kit/skills}/kit-customize/SKILL.md +5 -8
  41. package/{skills → kit/skills}/kit-dev/SKILL.md +1 -1
  42. package/{skills → kit/skills}/kit-digest/SKILL.md +3 -3
  43. package/{skills → kit/skills}/kit-effort-close/SKILL.md +20 -12
  44. package/{skills → kit/skills}/kit-effort-new/SKILL.md +17 -14
  45. package/{skills → kit/skills}/kit-effort-pr/SKILL.md +7 -7
  46. package/{skills → kit/skills}/kit-effort-start/SKILL.md +3 -3
  47. package/{skills → kit/skills}/kit-gc/SKILL.md +3 -3
  48. package/{skills → kit/skills}/kit-next/SKILL.md +7 -7
  49. package/{skills → kit/skills}/kit-page/SKILL.md +1 -1
  50. package/{skills → kit/skills}/kit-plan-next/SKILL.md +10 -11
  51. package/{skills → kit/skills}/kit-status/SKILL.md +6 -6
  52. package/{skills → kit/skills}/kit-task-close/SKILL.md +5 -5
  53. package/{skills → kit/skills}/kit-task-new/SKILL.md +5 -5
  54. package/{skills → kit/skills}/kit-task-pr/SKILL.md +5 -5
  55. package/{skills → kit/skills}/kit-task-pr-auto/SKILL.md +1 -1
  56. package/{skills → kit/skills}/kit-task-pr-merge/SKILL.md +10 -10
  57. package/{skills → kit/skills}/kit-task-start/SKILL.md +1 -1
  58. package/{skills → kit/skills}/kit-task-sync/SKILL.md +5 -3
  59. package/{skills → kit/skills}/kit-ux-audit/SKILL.md +16 -35
  60. package/{skills → kit/skills}/kit-ux-audit/references/graph-model.md +7 -26
  61. package/{skills → kit/skills}/kit-ux-audit/references/report.md +2 -3
  62. package/{skills → kit/skills}/routing.yaml +6 -1
  63. package/kit/statusline/kit-statusline.sh +82 -0
  64. package/{templates → kit/templates}/agents/analyst.md +0 -11
  65. package/{templates → kit/templates}/agents/auto-dev.md +0 -13
  66. package/{templates → kit/templates}/agents/backend.md +0 -11
  67. package/{templates → kit/templates}/agents/designer.md +0 -11
  68. package/{templates → kit/templates}/agents/devops.md +0 -11
  69. package/{templates → kit/templates}/agents/editor.md +0 -11
  70. package/{templates → kit/templates}/agents/frontend.md +0 -11
  71. package/{templates → kit/templates}/agents/generalist.md +0 -11
  72. package/{templates → kit/templates}/agents/local-delegate.md +0 -13
  73. package/{templates → kit/templates}/agents/n8n.md +0 -11
  74. package/{templates → kit/templates}/agents/pm.md +0 -11
  75. package/{templates → kit/templates}/agents/qa.md +0 -11
  76. package/{templates → kit/templates}/agents/researcher.md +0 -11
  77. package/{templates → kit/templates}/agents/security.md +0 -11
  78. package/{templates → kit/templates}/agents/tech-lead.md +0 -11
  79. package/{templates → kit/templates}/agents/ux.md +3 -14
  80. package/{templates → kit/templates}/hooks/kit-mail-check.sh.tmpl +1 -1
  81. package/{templates → kit/templates}/instructions.md.tmpl +4 -21
  82. package/{templates → kit/templates}/kit.config.json.tmpl +0 -6
  83. package/{templates → kit/templates}/rules/authoring.md +7 -3
  84. package/{templates → kit/templates}/rules/branch-naming.md +3 -2
  85. package/{templates → kit/templates}/rules/delegation-brief.md +4 -0
  86. package/{templates → kit/templates}/rules/effort-model.md +34 -31
  87. package/{templates → kit/templates}/rules/gate-and-review.md +1 -1
  88. package/{templates → kit/templates}/rules/merge-safety.md +12 -9
  89. package/{templates → kit/templates}/rules/naming-and-ids.md +20 -24
  90. package/{templates → kit/templates}/rules/plan-next.md +5 -5
  91. package/{templates → kit/templates}/rules/react-annotate.md +0 -8
  92. package/{templates → kit/templates}/skills/campaign/SKILL.md +2 -2
  93. package/kit.config.schema.json +11 -11
  94. package/lib/PROMPTS.md +14 -0
  95. package/{scripts/lib → lib/core}/adapter-select-test.sh +7 -7
  96. package/lib/core/advisor-test.sh +55 -0
  97. package/{scripts/lib → lib/core}/agent-def-test.sh +1 -1
  98. package/{scripts/lib → lib/core}/agent-def.sh +2 -2
  99. package/{scripts/lib → lib/core}/agent-launch-test.sh +3 -3
  100. package/{scripts/lib → lib/core}/agent-profile-test.sh +2 -2
  101. package/{scripts/lib → lib/core}/agent-resolve-test.sh +4 -2
  102. package/{scripts/lib → lib/core}/agent-resolve.sh +5 -4
  103. package/{scripts → lib/core}/agent-skills-external.txt +3 -3
  104. package/{scripts → lib/core}/agent-skills-lint-test.sh +17 -17
  105. package/lib/core/agent-skills-lint.sh +115 -0
  106. package/{scripts → lib/core}/agent-template-lint-test.sh +7 -7
  107. package/lib/core/agent-template-lint.sh +58 -0
  108. package/{scripts/lib → lib/core}/board-view-test.sh +3 -3
  109. package/lib/core/board-view.sh +97 -0
  110. package/{scripts/lib → lib/core}/branch-owner-test.sh +3 -3
  111. package/lib/core/branch-owner.sh +201 -0
  112. package/lib/core/check.sh +125 -0
  113. package/{scripts/lib → lib/core}/codex-hooks-test.sh +3 -3
  114. package/{scripts → lib/core}/commitlint-test.sh +6 -6
  115. package/lib/core/commitlint.sh +54 -0
  116. package/{scripts/config-path-test.sh → lib/core/config-path-scan-test.sh} +2 -2
  117. package/{scripts/lib → lib/core}/config-path-test.sh +3 -3
  118. package/lib/core/config-path.sh +30 -0
  119. package/{scripts → lib/core}/content-skills-test.sh +17 -17
  120. package/{scripts → lib/core}/docs-marketing-words-test.sh +2 -2
  121. package/{scripts → lib/core}/docs-record-tables-test.sh +2 -2
  122. package/{scripts/lib → lib/core}/effort-metrics-test.sh +6 -6
  123. package/lib/core/effort-metrics.sh +591 -0
  124. package/{scripts/lib → lib/core}/effort-slug-test.sh +8 -4
  125. package/{scripts/lib → lib/core}/effort-slug.sh +8 -7
  126. package/lib/core/effort.sh +339 -0
  127. package/{scripts/lib → lib/core}/errors-header-test.sh +19 -9
  128. package/lib/core/errors-header.exempt +49 -0
  129. package/{scripts → lib/core}/exec-targets-test.sh +3 -3
  130. package/lib/core/feature-map.sh +76 -0
  131. package/lib/core/force-push-fence-test.sh +44 -0
  132. package/lib/core/force-push-fence.baseline +1 -0
  133. package/lib/core/force-push-fence.sh +51 -0
  134. package/{scripts → lib/core}/forge-fence-test.sh +13 -13
  135. package/{scripts → lib/core}/forge-fence.sh +14 -14
  136. package/{scripts → lib/core}/forge-report-test.sh +5 -5
  137. package/{scripts → lib/core}/forge-report.sh +18 -14
  138. package/{scripts/lib → lib/core}/git-core-test.sh +7 -7
  139. package/{scripts/lib → lib/core}/git-remote-test.sh +3 -3
  140. package/{scripts → lib/core}/guard-raw-git-ops-test.sh +4 -4
  141. package/{scripts → lib/core}/hook-adapter-test.sh +5 -5
  142. package/{scripts/lib → lib/core}/hook-refresh-test.sh +5 -5
  143. package/{scripts → lib/core}/instruction-budget-baseline.txt +2 -2
  144. package/lib/core/instruction-budget-lint.sh +238 -0
  145. package/{scripts/lib → lib/core}/integration-install-test.sh +12 -12
  146. package/lib/core/integration-install.sh +257 -0
  147. package/{scripts/lib → lib/core}/integrations-test.sh +38 -45
  148. package/lib/core/integrations.sh +244 -0
  149. package/{scripts/lib → lib/core}/kinds-test.sh +5 -5
  150. package/lib/core/kinds.sh +66 -0
  151. package/{scripts/lib → lib/core}/kit-cli-test.sh +1 -1
  152. package/{scripts/lib → lib/core}/kit-cli.sh +1 -1
  153. package/{scripts/lib → lib/core}/kit-config-resolve.sh +2 -2
  154. package/{scripts/lib → lib/core}/kit-config-test.sh +11 -11
  155. package/lib/core/kit-config.sh +164 -0
  156. package/{scripts/lib → lib/core}/kit-engine-test.sh +1 -1
  157. package/lib/core/kit-events.sh +72 -0
  158. package/lib/core/kit-local.sh +87 -0
  159. package/{scripts/lib → lib/core}/kit-manifest.sh +1 -1
  160. package/{scripts/lib → lib/core}/kit-mode-test.sh +1 -1
  161. package/{scripts/lib → lib/core}/kit-mode.sh +3 -3
  162. package/{scripts/lib → lib/core}/kit-operate.sh +1 -1
  163. package/{scripts/lib → lib/core}/kit-profile-test.sh +1 -1
  164. package/{scripts/lib → lib/core}/kit-profile.sh +2 -2
  165. package/{scripts/lib → lib/core}/kit-state-test.sh +1 -1
  166. package/lib/core/knowledge-lint.sh +106 -0
  167. package/lib/core/layout-fence-test.sh +35 -0
  168. package/lib/core/layout-fence.allow +15 -0
  169. package/lib/core/layout-fence.baseline +4 -0
  170. package/lib/core/layout-fence.sh +50 -0
  171. package/{scripts → lib/core}/leak-fence-test.sh +10 -10
  172. package/{scripts/lib → lib/core}/leak-fence.sh +1 -1
  173. package/lib/core/loose-issues-test.sh +102 -0
  174. package/lib/core/loose-issues.baseline +5 -0
  175. package/lib/core/loose-issues.sh +65 -0
  176. package/{scripts → lib/core}/marketing-walkthrough-test.sh +7 -7
  177. package/lib/core/naming-test.sh +112 -0
  178. package/lib/core/naming-verbs-test.sh +126 -0
  179. package/lib/core/naming.sh +172 -0
  180. package/{scripts/lib → lib/core}/orchestration-runtime-test.sh +4 -4
  181. package/{scripts → lib/core}/portable-test.sh +11 -7
  182. package/{scripts/lib → lib/core}/pr-evidence-test.sh +5 -5
  183. package/lib/core/pr-evidence.sh +361 -0
  184. package/{scripts/lib → lib/core}/qa-lane-test.sh +7 -7
  185. package/{scripts/lib → lib/core}/qa-lane.sh +4 -4
  186. package/{scripts/lib → lib/core}/qa-lanes-test.sh +5 -5
  187. package/lib/core/react-detect.sh +79 -0
  188. package/{scripts/lib → lib/core}/render-test.sh +1 -1
  189. package/lib/core/resident-context-test.sh +42 -0
  190. package/lib/core/resident-context.baseline +1 -0
  191. package/lib/core/resident-context.sh +56 -0
  192. package/lib/core/review-lint-baseline.txt +28 -0
  193. package/lib/core/review-lint.sh +266 -0
  194. package/{scripts → lib/core}/review-rules.conf +1 -1
  195. package/{scripts/lib → lib/core}/review-stage-test.sh +2 -2
  196. package/{scripts/lib → lib/core}/role-identity-test.sh +3 -3
  197. package/lib/core/role-identity.sh +71 -0
  198. package/{scripts → lib/core}/rule-recipes-test.sh +5 -5
  199. package/lib/core/secret-guard.sh +116 -0
  200. package/{scripts → lib/core}/self-install-test.sh +15 -16
  201. package/{scripts/lib → lib/core}/session-registry-test.sh +1 -1
  202. package/lib/core/session-registry.sh +233 -0
  203. package/{scripts → lib/core}/skill-frontmatter-baseline.txt +1 -1
  204. package/lib/core/skill-frontmatter-lint.sh +189 -0
  205. package/lib/core/spec-lint-test.sh +63 -0
  206. package/lib/core/spec-lint.sh +95 -0
  207. package/{scripts/lib → lib/core}/stage-receipt-test.sh +136 -4
  208. package/{scripts/lib → lib/core}/stage-receipt.sh +186 -7
  209. package/{scripts → lib/core}/terms-check-test.sh +6 -6
  210. package/lib/core/terms-check.sh +244 -0
  211. package/{scripts/lib → lib/core}/test-env-test.sh +2 -2
  212. package/{scripts/lib → lib/core}/test-env.sh +1 -1
  213. package/{scripts → lib/core}/test-runner-test.sh +11 -11
  214. package/{scripts → lib/core}/test.sh +12 -12
  215. package/{scripts → lib/core}/update-path-test.sh +3 -3
  216. package/{scripts → lib/core}/verbs-gen.sh +9 -9
  217. package/{scripts → lib/core}/verbs-help-test.sh +4 -4
  218. package/{scripts → lib/core}/verbs-ratchet-test.sh +24 -19
  219. package/{scripts → lib/core}/verbs-ratchet.sh +8 -8
  220. package/{scripts → lib/core}/verbs-test.sh +23 -23
  221. package/lib/core/verbs.baseline +5 -0
  222. package/{scripts/lib → lib/core}/verbs.sh +3 -3
  223. package/{scripts/lib → lib/core}/verbs.tsv +22 -20
  224. package/{scripts/lib → lib/core}/version-bump-test.sh +29 -8
  225. package/{scripts/lib → lib/core}/version-bump.sh +15 -2
  226. package/{scripts/lib → lib/core}/wave-result-test.sh +2 -2
  227. package/{scripts/lib → lib/core}/wave-result.sh +1 -1
  228. package/{scripts/lib → lib/core}/worker-brief-test.sh +4 -4
  229. package/{scripts/lib → lib/core}/worker-brief.sh +1 -1
  230. package/{scripts/lib → lib/core}/worktree-bootstrap-test.sh +1 -1
  231. package/{scripts/lib → lib/core}/worktree-issue-test.sh +2 -2
  232. package/lib/core/worktree-issue.sh +172 -0
  233. package/{scripts/lib → lib/core}/worktree-ports-test.sh +1 -1
  234. package/{scripts/lib → lib/core}/worktree-start-test.sh +2 -2
  235. package/lib/core/worktree-start.sh +790 -0
  236. package/{scripts/lib → lib/core}/zsh-safety-test.sh +11 -11
  237. package/{scripts/lib → lib/forge}/forge-github.sh +18 -7
  238. package/{scripts/lib → lib/forge}/forge-test.sh +4 -4
  239. package/{scripts/lib → lib/forge}/forge.sh +1 -1
  240. package/lib/forge/gh-board-add-test.sh +118 -0
  241. package/lib/forge/gh-log.sh +59 -0
  242. package/lib/forge/gh-project-test.sh +251 -0
  243. package/lib/forge/gh-project.sh +379 -0
  244. package/{scripts/lib → lib/forge}/gh-rest-test.sh +17 -13
  245. package/{scripts/lib → lib/forge}/gh-rest.sh +190 -16
  246. package/{scripts/lib → lib/forge}/init-github.sh +18 -8
  247. package/{scripts/lib → lib/forge}/test-forge-shim.sh +2 -1
  248. package/lib/verbs/PROMPTS.md +146 -0
  249. package/lib/verbs/annotate-setup.sh +149 -0
  250. package/{scripts → lib/verbs}/autopilot-run-test.sh +9 -9
  251. package/{scripts → lib/verbs}/autopilot-run.sh +9 -9
  252. package/{scripts → lib/verbs}/autopilot-test.sh +7 -6
  253. package/{scripts → lib/verbs}/autopilot.sh +7 -7
  254. package/{scripts/lib → lib/verbs}/captain-test.sh +1 -1
  255. package/{scripts/lib → lib/verbs}/captain.sh +8 -8
  256. package/lib/verbs/capture-project-ids.sh +99 -0
  257. package/{scripts/lib → lib/verbs}/content-kinds-gc-test.sh +7 -7
  258. package/{scripts/lib → lib/verbs}/contribute-root-test.sh +4 -4
  259. package/{scripts/lib → lib/verbs}/contribute-root.sh +1 -1
  260. package/{scripts → lib/verbs}/contribute.sh +8 -8
  261. package/{scripts → lib/verbs}/copilot-loop-test.sh +12 -12
  262. package/{scripts/lib → lib/verbs}/copilot-test.sh +15 -14
  263. package/{scripts/lib → lib/verbs}/copilot.sh +19 -19
  264. package/{scripts → lib/verbs}/database-supabase-test.sh +6 -6
  265. package/lib/verbs/effort-close-subs-test.sh +96 -0
  266. package/{scripts/lib → lib/verbs}/effort-dispatch-test.sh +5 -5
  267. package/{scripts/lib → lib/verbs}/effort-flows-test.sh +5 -5
  268. package/{scripts/lib → lib/verbs}/effort-ops-test.sh +111 -22
  269. package/lib/verbs/effort-ops.sh +1571 -0
  270. package/{scripts/lib → lib/verbs}/effort-parity-test.sh +47 -41
  271. package/{scripts/lib → lib/verbs}/effort-plan-test.sh +7 -7
  272. package/lib/verbs/effort-plan.sh +289 -0
  273. package/lib/verbs/effort-review-test.sh +107 -0
  274. package/lib/verbs/effort-review.sh +93 -0
  275. package/lib/verbs/grill-record-test.sh +49 -0
  276. package/lib/verbs/grill-record.sh +88 -0
  277. package/{scripts/lib → lib/verbs}/handoff.sh +3 -3
  278. package/{scripts → lib/verbs}/init-content-test.sh +14 -14
  279. package/{scripts/lib → lib/verbs}/init-guide.sh +6 -6
  280. package/{scripts → lib/verbs}/init-guided-test.sh +9 -9
  281. package/{scripts → lib/verbs}/init-recipes-test.sh +7 -7
  282. package/{scripts → lib/verbs}/init-upgrade-test.sh +9 -10
  283. package/lib/verbs/init.sh +1598 -0
  284. package/{scripts → lib/verbs}/install-test.sh +5 -5
  285. package/lib/verbs/install.sh +31 -0
  286. package/{scripts → lib/verbs}/integrations-check-test.sh +9 -9
  287. package/lib/verbs/integrations-check.sh +157 -0
  288. package/{scripts → lib/verbs}/kit-add-test.sh +8 -8
  289. package/lib/verbs/kit-add.sh +415 -0
  290. package/{scripts → lib/verbs}/kit-adopt-test.sh +4 -4
  291. package/{scripts → lib/verbs}/kit-adopt.sh +6 -6
  292. package/{scripts/lib → lib/verbs}/kit-brief-test.sh +44 -15
  293. package/{scripts/lib → lib/verbs}/kit-brief.sh +101 -16
  294. package/lib/verbs/kit-bump-version.sh +79 -0
  295. package/lib/verbs/kit-digest.sh +126 -0
  296. package/{scripts → lib/verbs}/kit-doctor-test.sh +57 -32
  297. package/lib/verbs/kit-doctor.sh +991 -0
  298. package/{scripts → lib/verbs}/kit-export-project-test.sh +4 -4
  299. package/lib/verbs/kit-export-project.sh +245 -0
  300. package/{scripts → lib/verbs}/kit-export-training-test.sh +3 -3
  301. package/lib/verbs/kit-export-training.sh +175 -0
  302. package/{scripts/lib → lib/verbs}/kit-gc-test.sh +5 -5
  303. package/lib/verbs/kit-gc.sh +804 -0
  304. package/{scripts/lib → lib/verbs}/kit-hotfix.sh +3 -3
  305. package/{scripts/lib → lib/verbs}/kit-interview-test.sh +2 -2
  306. package/lib/verbs/kit-interview.sh +319 -0
  307. package/{scripts/lib → lib/verbs}/kit-lib-test.sh +2 -2
  308. package/{scripts/lib → lib/verbs}/kit-lib.sh +10 -10
  309. package/{scripts → lib/verbs}/kit-migrate-test.sh +4 -4
  310. package/{scripts → lib/verbs}/kit-migrate.sh +5 -5
  311. package/{scripts/lib → lib/verbs}/kit-msg-test.sh +2 -2
  312. package/{scripts/lib → lib/verbs}/kit-msg.sh +5 -5
  313. package/{scripts → lib/verbs}/kit-onboard-test.sh +2 -3
  314. package/lib/verbs/kit-onboard.sh +69 -0
  315. package/{scripts → lib/verbs}/kit-promote-test.sh +4 -4
  316. package/{scripts → lib/verbs}/kit-promote.sh +4 -4
  317. package/{scripts → lib/verbs}/kit-remove-test.sh +4 -4
  318. package/{scripts → lib/verbs}/kit-remove.sh +5 -5
  319. package/lib/verbs/kit-routines.sh +322 -0
  320. package/lib/verbs/kit-self-update.sh +55 -0
  321. package/{scripts/lib → lib/verbs}/kit-status-test.sh +2 -2
  322. package/lib/verbs/kit-status.sh +650 -0
  323. package/{scripts/lib → lib/verbs}/kit-task-ops-test.sh +25 -2
  324. package/lib/verbs/kit-task-ops.sh +793 -0
  325. package/{scripts → lib/verbs}/kit-version-check-test.sh +3 -3
  326. package/lib/verbs/kit-version-check.sh +121 -0
  327. package/{scripts → lib/verbs}/kit-wire-test.sh +6 -6
  328. package/{scripts → lib/verbs}/kit-wire.sh +8 -8
  329. package/{scripts/lib → lib/verbs}/kto-hotfix-test.sh +3 -3
  330. package/{scripts/lib → lib/verbs}/kto-task-close-test.sh +2 -2
  331. package/{scripts/lib → lib/verbs}/kto-task-new-test.sh +20 -2
  332. package/{scripts/lib → lib/verbs}/kto-task-pr-merge-test.sh +46 -2
  333. package/{scripts/lib → lib/verbs}/kto-task-pr-test.sh +6 -6
  334. package/{scripts/lib → lib/verbs}/light-task-run-test.sh +4 -4
  335. package/{scripts/lib → lib/verbs}/light-task-test.sh +9 -9
  336. package/{scripts/lib → lib/verbs}/light-task.sh +26 -11
  337. package/{scripts/lib → lib/verbs}/next-test.sh +3 -3
  338. package/{scripts/lib → lib/verbs}/next.sh +10 -10
  339. package/{scripts → lib/verbs}/night-grant-test.sh +4 -4
  340. package/lib/verbs/night-grant.sh +454 -0
  341. package/{scripts → lib/verbs}/night-run-test.sh +3 -3
  342. package/{scripts → lib/verbs}/night-run.mjs +2 -2
  343. package/{scripts → lib/verbs}/orchestrate-test.sh +5 -5
  344. package/{scripts → lib/verbs}/orchestrate.sh +15 -15
  345. package/{scripts/lib → lib/verbs}/plan-machine-test.sh +1 -1
  346. package/{scripts/lib → lib/verbs}/plan-machine.sh +13 -13
  347. package/{scripts/lib → lib/verbs}/plan-next-test.sh +1 -1
  348. package/lib/verbs/plan-next.sh +213 -0
  349. package/{scripts → lib/verbs}/publish.sh +10 -10
  350. package/{scripts/lib → lib/verbs}/review-page-test.sh +4 -4
  351. package/lib/verbs/review-page.sh +375 -0
  352. package/lib/verbs/setup-labels.sh +96 -0
  353. package/lib/verbs/setup-milestones.sh +34 -0
  354. package/{scripts → lib/verbs}/showcase.sh +2 -2
  355. package/lib/verbs/sprint-test.sh +96 -0
  356. package/lib/verbs/sprint.sh +216 -0
  357. package/{scripts → lib/verbs}/status-test.sh +8 -8
  358. package/{scripts → lib/verbs}/status.sh +16 -16
  359. package/{scripts → lib/verbs}/task-sync-test.sh +40 -6
  360. package/lib/verbs/task-sync.sh +462 -0
  361. package/{scripts/lib → lib/verbs}/upgrade-report-test.sh +4 -4
  362. package/lib/verbs/ux-a11y-scan.sh +96 -0
  363. package/lib/verbs/ux-ds-audit.sh +146 -0
  364. package/lib/verbs/ux-graph-scan.sh +188 -0
  365. package/{scripts → lib/verbs}/wave-worker.sh +2 -2
  366. package/lib/verbs/web-install.sh +22 -0
  367. package/package.json +3 -10
  368. package/scripts/PROMPTS.md +13 -0
  369. package/scripts/agent-skills-lint.sh +12 -113
  370. package/scripts/agent-template-lint.sh +12 -56
  371. package/scripts/annotate-setup.sh +11 -151
  372. package/scripts/benchmark/checkpoint-test.sh +1 -1
  373. package/scripts/benchmark/checkpoint.sh +1 -1
  374. package/scripts/benchmark/gate.sh +2 -2
  375. package/scripts/benchmark/lib/bench-common.sh +1 -1
  376. package/scripts/capture-project-ids.sh +12 -70
  377. package/scripts/check.sh +12 -106
  378. package/scripts/force-push-fence.sh +14 -0
  379. package/scripts/init.sh +13 -1637
  380. package/scripts/install.sh +12 -29
  381. package/scripts/instruction-budget-lint.sh +13 -218
  382. package/scripts/integrations-check.sh +12 -155
  383. package/scripts/kit-add.sh +12 -413
  384. package/scripts/kit-bump-version.sh +13 -78
  385. package/scripts/kit-digest.sh +13 -125
  386. package/scripts/kit-doctor.sh +13 -971
  387. package/scripts/kit-export-project.sh +12 -243
  388. package/scripts/kit-export-training.sh +12 -173
  389. package/scripts/kit-onboard.sh +12 -67
  390. package/scripts/kit-routines.sh +12 -320
  391. package/scripts/kit-self-update.sh +12 -53
  392. package/scripts/kit-version-check.sh +12 -106
  393. package/scripts/knowledge-lint.sh +13 -98
  394. package/scripts/lib/board-view.sh +13 -96
  395. package/scripts/lib/branch-owner.sh +12 -199
  396. package/scripts/lib/commitlint.sh +12 -52
  397. package/scripts/lib/config-path.sh +13 -29
  398. package/scripts/lib/effort-metrics.sh +12 -589
  399. package/scripts/lib/effort-ops.sh +13 -1243
  400. package/scripts/lib/effort-plan.sh +12 -287
  401. package/scripts/lib/effort.sh +13 -365
  402. package/scripts/lib/gh-log.sh +14 -59
  403. package/scripts/lib/gh-project.sh +13 -254
  404. package/scripts/lib/grill-record.sh +14 -0
  405. package/scripts/lib/integration-install.sh +12 -255
  406. package/scripts/lib/integrations.sh +12 -242
  407. package/scripts/lib/kinds.sh +13 -65
  408. package/scripts/lib/kit-config.sh +12 -165
  409. package/scripts/lib/kit-events.sh +13 -71
  410. package/scripts/lib/kit-gc.sh +12 -802
  411. package/scripts/lib/kit-interview.sh +11 -316
  412. package/scripts/lib/kit-local.sh +12 -85
  413. package/scripts/lib/kit-status.sh +12 -648
  414. package/scripts/lib/kit-task-ops.sh +13 -738
  415. package/scripts/lib/naming.sh +14 -0
  416. package/scripts/lib/plan-next.sh +13 -212
  417. package/scripts/lib/pr-evidence.sh +12 -359
  418. package/scripts/lib/react-detect.sh +12 -77
  419. package/scripts/lib/review-page.sh +11 -372
  420. package/scripts/lib/role-identity.sh +13 -70
  421. package/scripts/lib/secret-guard.sh +12 -114
  422. package/scripts/lib/session-registry.sh +13 -232
  423. package/scripts/lib/spec-lint.sh +14 -0
  424. package/scripts/lib/worktree-issue.sh +12 -170
  425. package/scripts/lib/worktree-start.sh +13 -748
  426. package/scripts/night-grant.sh +12 -452
  427. package/scripts/review-lint.sh +13 -258
  428. package/scripts/setup-labels.sh +11 -82
  429. package/scripts/setup-milestones.sh +12 -21
  430. package/scripts/skill-frontmatter-lint.sh +13 -181
  431. package/scripts/task-sync.sh +13 -370
  432. package/scripts/terms-check.sh +13 -241
  433. package/scripts/ux-a11y-scan.sh +13 -95
  434. package/scripts/ux-ds-audit.sh +12 -144
  435. package/scripts/ux-graph-scan.sh +12 -186
  436. package/scripts/web-install.sh +16 -20
  437. package/docs/kit-annotate/01-explainer.html +0 -225
  438. package/docs/kit-annotate/02-implementation-plan.html +0 -196
  439. package/docs/media/.onboarding-capture.cast +0 -5
  440. package/docs/media/README.md +0 -43
  441. package/docs/media/build-demo.sh +0 -63
  442. package/docs/media/build-kit-init.sh +0 -51
  443. package/docs/media/build-onboarding.sh +0 -51
  444. package/docs/media/kit-dry-run.cast +0 -107
  445. package/docs/media/kit-dry-run.gif +0 -0
  446. package/docs/media/kit-init.cast +0 -56
  447. package/docs/media/kit-init.gif +0 -0
  448. package/docs/media/kit-onboarding.cast +0 -148
  449. package/docs/media/kit-onboarding.gif +0 -0
  450. package/integrations/mempalace.json +0 -28
  451. package/scripts/lib/gh-project-test.sh +0 -135
  452. package/scripts/review-lint-baseline.txt +0 -28
  453. package/scripts/verbs.baseline +0 -5
  454. package/templates/hooks/mempal_followup.sh.tmpl +0 -97
  455. package/templates/hooks/mempal_precompact.sh.tmpl +0 -4
  456. package/templates/hooks/mempal_save.sh.tmpl +0 -4
  457. package/templates/hooks/mempal_session_start.sh.tmpl +0 -42
  458. package/templates/rules/mempalace.md +0 -111
  459. /package/{commands → kit/commands}/kit-docs.md +0 -0
  460. /package/{commands → kit/commands}/kit-export-training.md +0 -0
  461. /package/{databases → kit/databases}/supabase/guide.html +0 -0
  462. /package/{databases → kit/databases}/supabase/nextjs/lib/supabase/client.ts +0 -0
  463. /package/{databases → kit/databases}/supabase/nextjs/lib/supabase/server.ts +0 -0
  464. /package/{githooks → kit/githooks}/pre-commit +0 -0
  465. /package/{integrations → kit/integrations}/emil-design-eng.json +0 -0
  466. /package/{integrations → kit/integrations}/graft.json +0 -0
  467. /package/{integrations → kit/integrations}/impeccable.json +0 -0
  468. /package/{integrations → kit/integrations}/lavish.json +0 -0
  469. /package/{integrations → kit/integrations}/mlx-lm.json +0 -0
  470. /package/{integrations → kit/integrations}/web-design-guidelines.json +0 -0
  471. /package/{recipes → kit/recipes}/nextjs-shadcn.json +0 -0
  472. /package/{skills → kit/skills}/kit-docs-writer/SKILL.md +0 -0
  473. /package/{skills → kit/skills}/kit-onboard/SKILL.md +0 -0
  474. /package/{skills → kit/skills}/kit-security-sweep/SKILL.md +0 -0
  475. /package/{skills → kit/skills}/kit-ship/SKILL.md +0 -0
  476. /package/{skills → kit/skills}/kit-ux-audit/references/a11y.md +0 -0
  477. /package/{skills → kit/skills}/kit-ux-audit/references/consistency.md +0 -0
  478. /package/{skills → kit/skills}/kit-ux-audit/references/heuristics.md +0 -0
  479. /package/{templates → kit/templates}/benchmarks/SCHEMA.md +0 -0
  480. /package/{templates → kit/templates}/benchmarks/abstain.jsonl +0 -0
  481. /package/{templates → kit/templates}/benchmarks/adversarial.jsonl +0 -0
  482. /package/{templates → kit/templates}/benchmarks/benchmark.config.json +0 -0
  483. /package/{templates → kit/templates}/benchmarks/quality.jsonl +0 -0
  484. /package/{templates → kit/templates}/benchmarks/retrieval.jsonl +0 -0
  485. /package/{templates → kit/templates}/codex/hooks.json.tmpl +0 -0
  486. /package/{templates → kit/templates}/hooks/guard-base-branch-commit.sh.tmpl +0 -0
  487. /package/{templates → kit/templates}/hooks/guard-raw-git-ops.sh.tmpl +0 -0
  488. /package/{templates → kit/templates}/hooks/kit-local-status.sh.tmpl +0 -0
  489. /package/{templates → kit/templates}/hooks/kit_version_check.sh.tmpl +0 -0
  490. /package/{templates → kit/templates}/hooks/prepush_gate.sh.tmpl +0 -0
  491. /package/{templates → kit/templates}/hooks/repo-hygiene.sh.tmpl +0 -0
  492. /package/{templates → kit/templates}/knowledge-INDEX.md.tmpl +0 -0
  493. /package/{templates → kit/templates}/lib/kit-sigil.sh.tmpl +0 -0
  494. /package/{templates → kit/templates}/rules/code-retrieval.md +0 -0
  495. /package/{templates → kit/templates}/rules/communication-style.md +0 -0
  496. /package/{templates → kit/templates}/rules/design-routing.md +0 -0
  497. /package/{templates → kit/templates}/rules/issue-lifecycle.md +0 -0
  498. /package/{templates → kit/templates}/rules/knowledge-base.md +0 -0
  499. /package/{templates → kit/templates}/rules/plain-language.md +0 -0
  500. /package/{templates → kit/templates}/rules/plan-output-format.md +0 -0
  501. /package/{templates → kit/templates}/rules/review-pages.md +0 -0
  502. /package/{templates → kit/templates}/rules/risk-tiered-review.md +0 -0
  503. /package/{templates → kit/templates}/rules/shared-checkout.md +0 -0
  504. /package/{templates → kit/templates}/rules/skill-gaps.md +0 -0
  505. /package/{templates → kit/templates}/rules/task-management.md +0 -0
  506. /package/{templates → kit/templates}/settings/settings.json.tmpl +0 -0
  507. /package/{templates → kit/templates}/settings/settings.local.json.tmpl +0 -0
  508. /package/{templates → kit/templates}/skills/NAMESPACED +0 -0
  509. /package/{templates → kit/templates}/skills/brand-voice/SKILL.md +0 -0
  510. /package/{templates → kit/templates}/skills/brand-voice/references/voice-template.md +0 -0
  511. /package/{templates → kit/templates}/skills/campaign/references/plan-template.md +0 -0
  512. /package/{templates → kit/templates}/skills/concrete/SKILL.md +0 -0
  513. /package/{templates → kit/templates}/skills/copywriting/SKILL.md +0 -0
  514. /package/{templates → kit/templates}/skills/copywriting/references/copy-frameworks.md +0 -0
  515. /package/{templates → kit/templates}/skills/copywriting/references/natural-transitions.md +0 -0
  516. /package/{templates → kit/templates}/skills/feature-build-refine/SKILL.md +0 -0
  517. /package/{templates → kit/templates}/skills/karpathy-guidelines/SKILL.md +0 -0
  518. /package/{templates → kit/templates}/skills/morning-briefing/SKILL.md +0 -0
  519. /package/{templates → kit/templates}/skills/page-design/SKILL.md +0 -0
  520. /package/{templates → kit/templates}/skills/page-design/add.json +0 -0
  521. /package/{templates → kit/templates}/skills/page-design/references/design-file-template.md +0 -0
  522. /package/{templates → kit/templates}/skills/page-design/references/generic-page-patterns.md +0 -0
  523. /package/{templates → kit/templates}/skills/page-design/references/minimum-rules.md +0 -0
  524. /package/{templates → kit/templates}/skills/speckit/SKILL.md +0 -0
  525. /package/{templates → kit/templates}/skills/supabase-patterns/SKILL.md +0 -0
  526. /package/{scripts/lib → lib/core}/adapter-select.sh +0 -0
  527. /package/{scripts/lib → lib/core}/agent-launch.sh +0 -0
  528. /package/{scripts/lib → lib/core}/agent-profile.sh +0 -0
  529. /package/{scripts/lib → lib/core}/cckit-output.sh +0 -0
  530. /package/{scripts/lib → lib/core}/codex-hooks.sh +0 -0
  531. /package/{scripts → lib/core}/forge-fence.baseline +0 -0
  532. /package/{scripts/lib → lib/core}/git-remote.sh +0 -0
  533. /package/{scripts/lib → lib/core}/hook-refresh.sh +0 -0
  534. /package/{scripts → lib/core}/instruction-budget-lint-test.sh +0 -0
  535. /package/{scripts/lib → lib/core}/kit-state.sh +0 -0
  536. /package/{scripts/lib → lib/core}/orchestration-runtime.sh +0 -0
  537. /package/{scripts/lib → lib/core}/project-scan.sh +0 -0
  538. /package/{scripts/lib → lib/core}/render.sh +0 -0
  539. /package/{scripts → lib/core}/review-lint-test.sh +0 -0
  540. /package/{scripts/lib → lib/core}/review-stage.sh +0 -0
  541. /package/{scripts → lib/core}/skill-frontmatter-lint-test.sh +0 -0
  542. /package/{scripts/lib → lib/core}/task-source-file.sh +0 -0
  543. /package/{scripts/lib → lib/core}/task-source.sh +0 -0
  544. /package/{scripts/lib → lib/core}/toon.sh +0 -0
  545. /package/{scripts/lib → lib/core}/ui.sh +0 -0
  546. /package/{scripts/lib → lib/forge}/forge-none.sh +0 -0
  547. /package/{scripts → lib/verbs}/debug.sh +0 -0
  548. /package/{scripts → lib/verbs}/night-run.test.mjs +0 -0
  549. /package/{scripts/lib → lib/verbs}/upgrade-report.sh +0 -0
@@ -1,1244 +1,14 @@
1
1
  #!/usr/bin/env bash
2
- # shellcheck shell=bash
3
- # effort-ops.sh — the effort lifecycle as shell ops, so `cckit effort new|chain|start|pr|close` works
4
- # from any shell or agent (not only via the effort-* skills). Thin: composes the git-mechanics helpers
5
- # in effort.sh (linking, snapshots, title lint) plus gh + git. bash 3.2 compatible. Requires: gh, jq, git.
6
- #
7
- # effort_new [flags] "<name>" [<sub spec> …] parent (4-section body + labels) + native sub-issues
8
- # effort_chain <a> <b> [<c> …] wire N issues into a linear blocked_by chain (#243)
9
- # effort_start [--force] <slug|N> [<slug>] effort/<N> branch + worktree from base, WIP-limited (#244)
10
- # effort_pr [<slug|N>] open the ONE PR effort/<N> → base branch
11
- # effort_close <slug|N> snapshot sub-diffs, squash-merge the PR, close parent + subs
12
- #
13
- # effort_new is the SHARED creation core (effort #98): both `cckit effort new` (the verb) and
14
- # /kit-effort-new (the skill) call it, so they produce structurally identical efforts — one source of
15
- # truth for body composition + the ctx/kind/priority/role/flow label set + per-sub title lint.
16
- #
17
- # Commands accept the human slug as well as the canonical number (#93): a pure-digits arg is a number,
18
- # anything else is resolved via effort_slug_resolve. Repo + base branch come from kit.config.json
19
- # (EFFORT_REPO / KIT_BASE_BRANCH), loaded by effort.sh.
20
- # errors: mixed — lifecycle ops propagate; board + label side effects are best-effort
21
-
22
- # Slug layer (#93): _eff_slug, _eff_title_slug, effort_display, effort_slug_resolve. One home in
23
- # effort-slug.sh; source it here so the lifecycle ops accept `<slug|N>` and render `slug #N`.
24
- # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
25
- if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
26
- # shellcheck source=/dev/null
27
- . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
28
- fi
29
-
30
- if ! command -v effort_slug_resolve >/dev/null 2>&1; then
31
- _eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
32
- # shellcheck source=/dev/null
33
- [ -f "$_eo_dir/effort-slug.sh" ] && . "$_eo_dir/effort-slug.sh"
34
- unset _eo_dir
35
- fi
36
-
37
- # The closed kind: vocabulary (KIT_KINDS / kit_kind_valid) — what `effort new --kind` accepts.
38
- if ! command -v kit_kind_valid >/dev/null 2>&1; then
39
- _eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
40
- # shellcheck source=/dev/null
41
- [ -f "$_eo_dir/kinds.sh" ] && . "$_eo_dir/kinds.sh"
42
- unset _eo_dir
43
- fi
44
-
45
- # The GitHub transport switch (#396): in rest mode the lifecycle calls below are `forge_rest repos/…`.
46
- if ! command -v cckit_gh_rest >/dev/null 2>&1; then
47
- _eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
48
- # shellcheck source=/dev/null
49
- [ -f "$_eo_dir/gh-rest.sh" ] && . "$_eo_dir/gh-rest.sh"
50
- unset _eo_dir
51
- fi
52
- command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
53
- command -v cckit_board_skipped >/dev/null 2>&1 || cckit_board_skipped() { return 1; }
54
-
55
- _eff_repo() { printf '%s' "${EFFORT_REPO:-${KIT_REPO:-}}"; }
56
- _eff_base() { printf '%s' "${KIT_BASE_BRANCH:-main}"; }
57
- _eff_need() { command -v "$1" >/dev/null 2>&1 || { echo "effort: $1 is required" >&2; return 1; }; }
58
- # _eff_forge — rc 0 with a forge; without one, forge_need's one line (naming the verb), rc 1.
59
- _eff_forge() { forge_need; }
60
-
61
- # Compose the four-section parent body (rules/effort-model.md): the sections double as the work
62
- # record. An empty section falls back to its template placeholder so a bare call still yields the
63
- # full four-heading scaffold; passing content fills it. The `## Relations` chain is NOT composed
64
- # here — it is layered on afterwards by _eff_relations_add (one formatter, #243).
65
- _eff_compose_body() {
66
- local goal="$1" scope="$2" for_agents="$3" verification="$4"
67
- cat <<EOF
68
- ## Goal
69
- ${goal:-<!-- problem statement: what outcome, in one or two lines -->}
70
-
71
- ## Scope
72
- ${scope:-<!-- the sub-issue plan; mark each parallel | sequential / dependsOn -->}
73
-
74
- ## For agents
75
- ${for_agents:-<!-- exact file paths / entry points a future agent needs -->}
76
-
77
- ## Verification
78
- ${verification:-<!-- how we know it is done: commands, checks, acceptance -->}
79
- EOF
80
- }
81
-
82
- # _eff_relations_add <body> <blocker> — echo <body> with `- Depends on #<blocker>` recorded in its
83
- # `## Relations` section. THE one formatter for the human-readable dependency line (rules/
84
- # effort-model.md): both `effort_new --depends-on` and `effort_chain` go through it, so the two
85
- # produce byte-identical lines.
86
- #
87
- # Placement: appended to the END of an existing `## Relations` section (the lines before the next
88
- # `## ` heading, or the end of the body); when the body has no such section, a new one is appended
89
- # at the end of the body. IDEMPOTENT — a body that already carries the exact line comes back
90
- # unchanged, so re-running never duplicates a line. Trailing blank lines are trimmed.
91
- # Pure: no gh, no network — stdin-free, argument in / body out.
92
- _eff_relations_add() {
93
- printf '%s\n' "$1" | awk -v dep="$2" '
94
- BEGIN { want = "- Depends on #" dep; rel = 0; have = 0 }
95
- {
96
- L[NR] = $0
97
- if (rel == 0 && $0 ~ /^[ \t]*##[ \t]+Relations[ \t]*$/) rel = NR
98
- t = $0; sub(/^[ \t]+/, "", t); sub(/[ \t]+$/, "", t)
99
- if (t == want) have = 1
100
- }
101
- END {
102
- n = NR
103
- while (n > 0 && L[n] ~ /^[ \t]*$/) n-- # trim trailing blank lines
104
- if (have) { for (i = 1; i <= n; i++) print L[i]; exit }
105
- if (rel == 0) { # no section yet → append one
106
- for (i = 1; i <= n; i++) print L[i]
107
- if (n > 0) print "" # no leading blank on an empty body
108
- print "## Relations"; print want
109
- exit
110
- }
111
- e = n # end of the Relations section
112
- for (i = rel + 1; i <= n; i++) if (L[i] ~ /^##[ \t]/) { e = i - 1; break }
113
- while (e > rel && L[e] ~ /^[ \t]*$/) e--
114
- for (i = 1; i <= e; i++) print L[i]
115
- print want
116
- for (i = e + 1; i <= n; i++) print L[i]
117
- }
118
- '
119
- }
120
-
121
- # _eff_ensure_label <name> <color> <description> — make sure a kit-defined label exists in the repo
122
- # before `gh issue create --label` uses it (which fails hard on a missing label, #153). Idempotent:
123
- # creating an existing label is a silent no-op.
124
- _eff_ensure_label() {
125
- gh_rest_label_create "$(_eff_repo)" "$1" "$2" "$3"; return 0
126
- }
127
-
128
- # Add an issue (by number) to the project board + set Status=Todo and the Role field. Guarded: a
129
- # no-op unless Projects v2 is on AND the project helpers (gh-project.sh) are already sourced, so the
130
- # verb can run from any shell with no board config. Mirrors the skill's old inline board block.
131
- _eff_board_add() {
132
- local n="$1" role="${2:-}" repo node item ropt
133
- [ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
134
- cckit_board_skipped && return 0
135
- command -v project_add_item >/dev/null 2>&1 || return 0
136
- repo="$(_eff_repo)"
137
- node="$(forge_rest "repos/$repo/issues/$n" --jq .node_id 2>/dev/null)" || return 0
138
- item="$(project_add_item "$node" 2>/dev/null)" || return 0
139
- [ -n "$item" ] || return 0
140
- [ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_TODO:-}" ] \
141
- && project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_TODO" 2>/dev/null || true
142
- if [ -n "$role" ] && [ -n "${ROLE_FIELD_ID:-}" ] && command -v role_option_id >/dev/null 2>&1; then
143
- ropt="$(role_option_id "$role" || echo "")"
144
- [ -n "$ropt" ] && [ -n "${ROLE_FIELD_ID:-}" ] \
145
- && project_set_single_select "$item" "$ROLE_FIELD_ID" "$ropt" 2>/dev/null || true
146
- fi
147
- return 0
148
- }
149
-
150
- # effort_new [flags] "<name>" [<sub spec> …] — the shared creation core (effort #98).
151
- # Flags (all optional): --flow F --role R --priority p1 --goal G --scope S --for-agents A
152
- # --verification V --depends-on "#1,#2" --milestone M --slug S. A <sub spec> is "name :: one-line
153
- # desc" (the desc is optional → just "name"). Fills the four body sections, applies the
154
- # ctx/kind/priority/role/flow label set, lints the parent + EVERY sub title up front (so a bad sub
155
- # name aborts before anything is created), links native sub-issues, sets blocked_by edges, adds
156
- # everything to the board (guarded), and records the human slug handle (#93) as a slug:<slug> label.
157
- # Echoes the parent number on stdout.
158
- effort_new() {
159
- _eff_forge || return 1; _eff_need jq || return 1
160
- local repo; repo="$(_eff_repo)"
161
- [ -n "$repo" ] || { echo "effort_new: no repo (KIT_REPO/EFFORT_REPO unset — run in a kit project)" >&2; return 1; }
162
-
163
- local flow="" role="" priority="p1" goal="" scope="" for_agents="" verification="" depends_on="" milestone="" explicit_slug="" kind="task"
164
- # Flags are position-INDEPENDENT: recognized --flag [value] pairs are consumed wherever they occur
165
- # (before the title, between subs, or after them) and the remaining positionals are collected as the
166
- # title (first) + sub specs (rest). Previously the parser broke at the first positional, so any flag
167
- # placed after the title was mis-read as a sub-issue spec — creating junk sub-issues. `--` forces
168
- # everything after it to be treated as positional (for a sub name that starts with a dash).
169
- local pos=()
170
- while [ $# -gt 0 ]; do
171
- case "$1" in
172
- --flow) flow="${2:-}"; shift 2 ;;
173
- --role) role="${2:-}"; shift 2 ;;
174
- --priority) priority="${2:-p1}"; shift 2 ;;
175
- --goal) goal="${2:-}"; shift 2 ;;
176
- --scope) scope="${2:-}"; shift 2 ;;
177
- --for-agents) for_agents="${2:-}"; shift 2 ;;
178
- --verification) verification="${2:-}"; shift 2 ;;
179
- --depends-on) depends_on="${2:-}"; shift 2 ;;
180
- --milestone) milestone="${2:-}"; shift 2 ;;
181
- --slug) explicit_slug="${2:-}"; shift 2 ;;
182
- --slug=*) explicit_slug="${1#*=}"; shift ;;
183
- --kind) kind="${2:-}"; shift 2 ;;
184
- --kind=*) kind="${1#*=}"; shift ;;
185
- --) shift; while [ $# -gt 0 ]; do pos+=("$1"); shift; done ;;
186
- --*) echo "effort_new: unknown flag $1" >&2; return 1 ;;
187
- *) pos+=("$1"); shift ;;
188
- esac
189
- done
190
- set -- "${pos[@]+"${pos[@]}"}"
191
-
192
- # --kind picks the kind:<k> label on the parent and every sub (default task). It is validated
193
- # against the closed set (kinds.sh) before anything is created: `cckit start` turns the label into
194
- # the branch prefix, so a value outside the set would yield a branch the hygiene hook rejects.
195
- if command -v kit_kind_label_valid >/dev/null 2>&1 && ! kit_kind_label_valid "$kind"; then
196
- echo "effort_new: --kind must be one of: $KIT_KINDS $KIT_CONTENT_KINDS (got '$kind')" >&2; return 1
197
- fi
198
- [ -n "$kind" ] || { echo "effort_new: --kind needs a value" >&2; return 1; }
199
-
200
- local name="${1:-}"; shift || true
201
- [ -n "$name" ] || { echo 'effort_new: usage: effort_new [flags] "<name>" [<sub spec> …]' >&2; return 1; }
202
-
203
- # Optional leading [Flow] tag on the board title (validated by effort_title_lint).
204
- local flow_tag=""; [ -n "$flow" ] && flow_tag="[$flow] "
205
-
206
- # Guard the parent name against the title rule BEFORE creating anything (synthetic number — the
207
- # rule is about the NAME, not the not-yet-assigned N).
208
- effort_title_lint "[Effort] 0 · ${flow_tag}${name}" || { echo "effort_new: fix the name and retry" >&2; return 1; }
209
-
210
- # Lint EVERY sub title up front too (parity with the skill's intent) so a bad sub name fails the
211
- # whole op before a half-effort exists. Synthetic parent number 0 for the lint.
212
- local i=0 spec sub_name sub_title
213
- for spec in "$@"; do
214
- i=$((i + 1))
215
- sub_name="${spec%% :: *}"
216
- sub_title="[Effort 0] $i · $sub_name"
217
- effort_title_lint "$sub_title" \
218
- || { echo "effort_new: fix sub title #$i and retry: $sub_name" >&2; return 1; }
219
- done
220
-
221
- # Compose the four-section body, then layer the ## Relations chain from --depends-on through the
222
- # ONE formatter (#243) — the same one `effort_chain` uses, so both write identical lines. (It was
223
- # built inline here before, and `$( … )` ate every newline: the section shipped as the single
224
- # mangled line `## Relations- Depends on #1- Depends on #2`.)
225
- local body d; body="$(_eff_compose_body "$goal" "$scope" "$for_agents" "$verification")"
226
- if [ -n "$depends_on" ]; then
227
- for d in $(printf '%s' "$depends_on" | tr ',' ' '); do
228
- d="${d#\#}"; [ -n "$d" ] && body="$(_eff_relations_add "$body" "$d")"
229
- done
230
- fi
231
-
232
- # Label set: ctx (session weight from the sub count) + kind + priority + optional role + optional flow.
233
- local subcount=$#; [ "$subcount" -ge 1 ] || subcount=1
234
- local ctx="ctx:S"
235
- command -v effort_ctx_bucket >/dev/null 2>&1 && ctx="$(effort_ctx_bucket 1 "$subcount")"
236
- # Every kit-defined label is ensured before use — `gh issue create --label` fails hard on a
237
- # missing label, which aborted the whole parent create on repos without the ctx:* set (#153).
238
- _eff_ensure_label "$ctx" bfd4f2 "effort session weight"
239
- _eff_ensure_label "kind:$kind" d4c5f9 "kit issue kind"
240
- _eff_ensure_label "priority:$priority" e99695 "kit priority"
241
- # `effort` is what marks the parent AS an effort, and it is the label `effort_plan` queries
242
- # (`gh issue list --label effort`, effort-plan.sh). It was read and never written: the label did
243
- # not exist in this repo at all, so `cckit effort plan` answered "no open efforts found" for
244
- # every effort ever created here. A label something reads and nothing writes is the same defect
245
- # as one something writes and nothing reads — see rules/naming-and-ids.md § Labels.
246
- _eff_ensure_label "effort" 5319e7 "an effort parent issue"
247
- local labels="effort,$ctx,kind:$kind,priority:$priority"
248
- if [ -n "$role" ]; then
249
- _eff_ensure_label "role:$role" 0e8a16 "kit role lane"
250
- labels="$labels,role:$role"
251
- fi
252
- if [ -n "$flow" ]; then
253
- local flow_lc; flow_lc="$(printf '%s' "$flow" | tr '[:upper:]' '[:lower:]')"
254
- _eff_ensure_label "flow:$flow_lc" 1d76db "kit flow lane"
255
- labels="$labels,flow:$flow_lc"
256
- fi
257
-
258
- local url num slug
259
- url="$(gh_rest_issue_create "$repo" "[Effort] · ${flow_tag}${name}" "$body" "$labels" "$milestone" 0)" \
260
- || { echo "effort_new: failed to create the parent issue" >&2; return 1; }
261
- num="${url##*/}"
262
- gh_rest_issue_edit_title "$repo" "$num" "[Effort] $num · ${flow_tag}${name}" >/dev/null 2>&1
263
- # The human handle (#93): explicit --slug if given, else derived from the title (number/flow peeled).
264
- if [ -n "$explicit_slug" ]; then slug="$(_eff_slug "$explicit_slug")"
265
- else slug="$(_eff_title_slug "[Effort] $num · ${flow_tag}${name}")"; fi
266
- if [ -n "$slug" ]; then
267
- gh_rest_label_create "$repo" "slug:$slug" ededed "effort slug handle"
268
- gh_rest_issue_add_labels "$repo" "$num" "slug:$slug" >/dev/null 2>&1 || true
269
- fi
270
- echo " ✓ effort $(effort_display "$num" "$slug") · ${flow_tag}${name}" >&2
271
-
272
- # Native dependency edges (the visible board chain) — guarded on the helper being available.
273
- if [ -n "$depends_on" ] && command -v effort_set_blocked_by >/dev/null 2>&1; then
274
- for d in $(printf '%s' "$depends_on" | tr ',' ' '); do
275
- d="${d#\#}"; [ -n "$d" ] && { effort_set_blocked_by "$num" "$d" || true; }
276
- done
277
- fi
278
-
279
- # Board: add the parent (guarded — no-op when Projects v2 is off / helpers not loaded).
280
- _eff_board_add "$num" "$role" || true
281
-
282
- # Create each sub-issue (titles already linted), native-link it, add it to the board.
283
- local sub_desc child child_num
284
- i=0
285
- for spec in "$@"; do
286
- i=$((i + 1))
287
- sub_name="${spec%% :: *}"
288
- sub_desc="${spec#* :: }"; [ "$sub_desc" = "$spec" ] && sub_desc=""
289
- sub_title="[Effort $num] $i · $sub_name"
290
- local sub_labels="kind:$kind,priority:$priority"
291
- [ -n "$role" ] && sub_labels="$sub_labels,role:$role"
292
- child="$(gh_rest_issue_create "$repo" "$sub_title" \
293
- "$(printf '%s\n\nSub-issue of #%s (effort).' "$sub_desc" "$num")" "$sub_labels" "$milestone" 0)" || continue
294
- child_num="${child##*/}"
295
- effort_link_sub "$num" "$child_num" || true
296
- _eff_board_add "$child_num" "$role" || true
297
- echo " ✓ sub #$child_num · $sub_name" >&2
298
- done
299
- printf '%s\n' "$num"
300
- }
301
-
302
- # _eo_source_effort — lazily source the git-mechanics lib (effort.sh) so the ops that need
303
- # effort_set_blocked_by work when effort-ops.sh is sourced on its own. No-op if already loaded.
304
- _eo_source_effort() {
305
- command -v effort_set_blocked_by >/dev/null 2>&1 && return 0
306
- local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
307
- # shellcheck source=/dev/null
308
- [ -f "$d/effort.sh" ] && . "$d/effort.sh"
309
- }
310
-
311
- # _eff_issue_body <repo> <n> / _eff_issue_set_body <repo> <n> <body> — read and replace an issue
312
- # body on the chosen transport (#396). A failed read returns non-zero, never an empty body.
313
- _eff_issue_body() { forge_rest "repos/$1/issues/$2" --jq '.body // ""'; }
314
- _eff_issue_set_body() { gh_rest_issue_set_body "$1" "$2" "$3"; }
315
-
316
- # _eff_blockers <issue> — echo the issue's CURRENT blocked_by numbers, one per line. Empty when the
317
- # issue has no edges or the API call fails (the caller treats that as "no known edge").
318
- _eff_blockers() {
319
- forge_rest "repos/$(_eff_repo)/issues/$1/dependencies/blocked_by" --jq '.[].number' 2>/dev/null || true
320
- }
321
-
322
- # _eff_chain_reaches <from> <target> <pending> — is <target> reachable from <from> by following
323
- # blocked_by edges? Breadth-first over the COMBINED graph: the edges GitHub already holds plus
324
- # <pending>, a space-separated list of `child>parent` pairs this call is about to write. Used as the
325
- # cycle pre-flight: adding "<target> blocked_by <from>" closes a cycle exactly when <from> already
326
- # depends (transitively) on <target>. rc 0 = reachable.
327
- _eff_chain_reaches() {
328
- [ -n "${ZSH_VERSION:-}" ] && setopt local_options ksh_arrays sh_word_split 2>/dev/null
329
- local from="$1" target="$2" pending="$3"
330
- local queue="$from" seen=" " cur b
331
- while [ -n "$queue" ]; do
332
- # shellcheck disable=SC2086
333
- set -- $queue; cur="$1"; shift; queue="$*"
334
- case "$seen" in *" $cur "*) continue ;; esac
335
- seen="$seen$cur "
336
- for b in $(_eff_blockers "$cur") \
337
- $(printf '%s\n' $pending | sed -n "s/^$cur>//p"); do
338
- [ "$b" = "$target" ] && return 0
339
- queue="$queue $b"
340
- done
341
- done
342
- return 1
343
- }
344
-
345
- # effort_chain <a> <b> [<c> …] — wire N issues into a LINEAR dependency chain (#243): B becomes
346
- # blocked_by A, C blocked_by B, and so on, and each issue after the first gets a `- Depends on #<its
347
- # predecessor>` line in its `## Relations` section. This is the verb that FEEDS `cckit plan` — the
348
- # wave layering in plan-machine.sh reads exactly these `blocked_by` edges, so a chained set lands
349
- # one issue per wave, in the order given.
350
- #
351
- # Everything is VALIDATED BEFORE ANYTHING IS WRITTEN (the effort_new discipline): a rejected chain
352
- # leaves the board untouched. The rules:
353
- # arity fewer than two numbers is a usage error — a chain needs a predecessor and a
354
- # successor. Nothing is written.
355
- # numbers each arg is an issue number, with an optional leading `#`. Anything else is
356
- # rejected. Nothing is written.
357
- # existence every issue is fetched first; a number that does not resolve aborts the whole
358
- # chain. Nothing is written.
359
- # cycles a repeated number (`chain 1 2 1`) is refused — the chain would revisit a node. So
360
- # is a chain whose new edge closes a loop through edges GitHub ALREADY holds (the
361
- # pre-flight walks the combined graph). `cckit plan` cannot layer a cyclic graph into
362
- # waves, so a cycle is refused rather than written. Nothing is written.
363
- # pre-existing an issue already blocked by something else KEEPS that blocker: blocked_by is a set,
364
- # blockers and this only ever ADDS its edge. The issue ends up with both.
365
- # idempotent an edge that is already present is skipped (no duplicate POST, no error) and a body
366
- # that already carries the exact `- Depends on #N` line is left alone (no second
367
- # line, no `gh issue edit`). A re-run writes nothing and reports each half as
368
- # `already blocked_by` / `already records`.
369
- # Progress goes to stderr; rc 0 only when every link of the chain is in place.
370
- effort_chain() {
371
- [ -n "${ZSH_VERSION:-}" ] && setopt local_options ksh_arrays sh_word_split 2>/dev/null
372
- _eff_forge || return 1
373
- _eo_source_effort
374
- local repo; repo="$(_eff_repo)"
375
- [ -n "$repo" ] || { echo "effort_chain: no repo (KIT_REPO/EFFORT_REPO unset — run in a kit project)" >&2; return 1; }
376
-
377
- # 1. arity, shape, and repeats — all before a single write. `#12` and `12` are the same issue; a
378
- # number that appears twice means the chain revisits a node, which is a cycle, not a chain.
379
- [ "$#" -ge 2 ] || { echo 'effort_chain: usage: effort_chain <a> <b> [<c> …] (two or more issue numbers)' >&2; return 1; }
380
- local a n b list=""
381
- for a in "$@"; do
382
- n="${a#\#}"
383
- case "$n" in
384
- ''|*[!0-9]*) echo "effort_chain: '$a' is not an issue number — nothing written" >&2; return 1 ;;
385
- esac
386
- for b in $list; do
387
- [ "$b" = "$n" ] && { echo "effort_chain: #$n appears twice — that is a cycle, not a chain; nothing written" >&2; return 1; }
388
- done
389
- list="$list$n "
390
- done
391
-
392
- # 2. every issue must exist before a single edge is written.
393
- for n in $list; do
394
- forge_rest "repos/$repo/issues/$n" --jq .number >/dev/null 2>&1 \
395
- || { echo "effort_chain: #$n does not exist in $repo — nothing written" >&2; return 1; }
396
- done
397
-
398
- # 3. cycle pre-flight over the existing graph PLUS the edges this call would add. Adding
399
- # "next blocked_by prev" closes a loop exactly when prev already depends on next.
400
- local pending="" prev="" next
401
- for next in $list; do
402
- if [ -n "$prev" ] && _eff_chain_reaches "$prev" "$next" "$pending"; then
403
- echo "effort_chain: #$next blocked_by #$prev would create a dependency cycle — nothing written" >&2
404
- return 1
405
- fi
406
- [ -n "$prev" ] && pending="$pending$next>$prev "
407
- prev="$next"
408
- done
409
-
410
- # 4. write. Per link: the native blocked_by edge and the `Depends on` line, each skipped when it
411
- # is already there — so a re-run reports and touches nothing.
412
- local rc=0 have body newbody
413
- prev=""
414
- for next in $list; do
415
- if [ -n "$prev" ]; then
416
- have=""
417
- for b in $(_eff_blockers "$next"); do [ "$b" = "$prev" ] && have=1; done
418
- if [ -n "$have" ]; then
419
- echo " · #$next already blocked_by #$prev" >&2
420
- else
421
- effort_set_blocked_by "$next" "$prev" || rc=1
422
- fi
423
-
424
- # A FAILED read is not an empty body: writing the composed body after a failed fetch would
425
- # wipe the issue. Only a successful read is edited.
426
- if ! body="$(_eff_issue_body "$repo" "$next" 2>/dev/null)"; then
427
- echo " ✗ could not read #$next's body — 'Depends on #$prev' not recorded" >&2; rc=1
428
- elif grep -qE "^[[:space:]]*- Depends on #${prev}[[:space:]]*$" <<<"$body"; then
429
- echo " · #$next already records 'Depends on #$prev'" >&2
430
- else
431
- newbody="$(_eff_relations_add "$body" "$prev")"
432
- _eff_issue_set_body "$repo" "$next" "$newbody" >/dev/null 2>&1 \
433
- && echo " ✓ #$next records 'Depends on #$prev'" >&2 \
434
- || { echo " ✗ could not update #$next's body" >&2; rc=1; }
435
- fi
436
- fi
437
- prev="$next"
438
- done
439
-
440
- # The banner must agree with rc: a ✓ over a nonzero exit reports a chain that is not fully wired.
441
- # Individual failures already printed their own ✗ line above; this is the summary for the whole run.
442
- if [ "$rc" -eq 0 ]; then
443
- echo " ✓ chain $(printf '#%s → ' $list | sed 's/ → $//')" >&2
444
- else
445
- echo " ✗ chain $(printf '#%s → ' $list | sed 's/ → $//') — incomplete, see the errors above" >&2
446
- fi
447
- return "$rc"
448
- }
449
-
450
- # ── WIP limit: how many efforts may be in progress at once (#244) ──────────────────────────────
451
- #
452
- # WHAT COUNTS AS "IN PROGRESS": an effort whose `effort/<N>-<slug>` branch exists — a local head, or
453
- # a branch origin has right now (`git ls-remote`, not the cached `refs/remotes`; see effort_wip_rows
454
- # for why). Both halves are parsed by the effort-slug.sh helpers the slug resolver is built on, so a
455
- # ref name is decomposed in one place. This is the kit's existing notion of a started effort, not a
456
- # new one: `effort_start` CREATES that branch and `effort_close` deletes it, so the branch set is
457
- # exactly "started and not yet closed", by construction.
458
- #
459
- # The Projects v2 board Status is deliberately NOT the signal. It is written by the /kit-effort-start
460
- # skill's additive board step, never by this verb, so the verb would be gating on state it does not
461
- # set; it is empty whenever `github.projectsV2` is false (cckit's own default); and there is no
462
- # status:* label to fall back on. One signal, no fallback chain.
463
-
464
- # _eff_wip_limit_from_config — echo `effort.wipLimit` straight from the project config, so a
465
- # configured limit applies even to callers that never ran load_kit_config. Mirrors
466
- # _effort_flows_from_config (effort.sh). Empty output / rc 1 when unset or unreadable.
467
- _eff_wip_limit_from_config() {
468
- command -v jq >/dev/null 2>&1 || return 1
469
- if ! command -v kit_config_path >/dev/null 2>&1; then
470
- local _wl_dir; _wl_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)"
471
- # shellcheck source=/dev/null
472
- [ -n "$_wl_dir" ] && [ -f "$_wl_dir/config-path.sh" ] && . "$_wl_dir/config-path.sh"
473
- fi
474
- command -v kit_config_path >/dev/null 2>&1 || return 1
475
- local _wl_cfg; _wl_cfg="$(kit_config_path 2>/dev/null)" && [ -f "$_wl_cfg" ] || return 1
476
- jq -r 'if (.effort.wipLimit | type) == "null" then empty else (.effort.wipLimit | tostring) end' \
477
- "$_wl_cfg" 2>/dev/null
478
- }
479
-
480
- # _eff_wip_limit — echo the effective limit. Resolution order mirrors the flow vocabulary (#150), so
481
- # the kit has ONE config idiom:
482
- # 1. EFFORT_WIP_LIMIT in the environment always wins (per-invocation override)
483
- # 2. the project config `effort.wipLimit` — via KIT_EFFORT_WIP_LIMIT (exported by load_kit_config)
484
- # or read straight from the config file
485
- # 3. the built-in default, 2.
486
- # A value that is not a non-negative integer (a typo, a float, a negative) is IGNORED with a warning
487
- # on stderr and the built-in default is used: a misconfigured limit must not silently disable the
488
- # gate, and must not wedge the verb either. `0` is valid and means "start no new effort".
489
- _eff_wip_limit() {
490
- local v="" src=""
491
- if [ -n "${EFFORT_WIP_LIMIT:-}" ]; then
492
- v="$EFFORT_WIP_LIMIT"; src="EFFORT_WIP_LIMIT"
493
- elif [ -n "${KIT_EFFORT_WIP_LIMIT:-}" ]; then
494
- v="$KIT_EFFORT_WIP_LIMIT"; src="effort.wipLimit"
495
- else
496
- v="$(_eff_wip_limit_from_config 2>/dev/null || true)"; src="effort.wipLimit"
497
- fi
498
- [ -n "$v" ] || { printf '2'; return 0; }
499
- case "$v" in
500
- ''|*[!0-9]*)
501
- echo "effort_start: ignoring $src='$v' — the WIP limit must be a non-negative integer; using the default 2" >&2
502
- printf '2'; return 0 ;;
503
- esac
504
- printf '%s' "$v"
505
- }
506
-
507
- # effort_wip_rows — one TSV row `<N>\t<slug>` per effort that is IN PROGRESS, each effort exactly
508
- # once, lowest number first. The counted set behind the WIP gate: local `refs/heads/effort/*` UNION
509
- # the effort branches origin actually has right now.
510
- #
511
- # Why not the cached `refs/remotes` (#244 review): it is wrong in both directions and the gate is
512
- # wrong with it. A branch pushed since the last fetch is absent, so the gate lets the limit be
513
- # exceeded — and the gate runs before effort_start's fetch, which is base-only and would not refresh
514
- # `refs/remotes/origin/effort/*` anyway. A branch DELETED on origin lingers in `refs/remotes` until
515
- # a prune, so the gate blocks a start that should be allowed. `git ls-remote` answers both: it sees
516
- # the new branch and does not see the deleted one, without writing or pruning a single ref.
517
- #
518
- # The cost is one network round-trip per `effort start`. That is accepted: a gate that miscounts in
519
- # both directions is not a gate, and `effort start` is a rare interactive command that already
520
- # fetches and installs dependencies. Two things keep it from being a liability:
521
- #
522
- # EFFORT_WIP_REMOTE=0 skips the origin query outright and counts local heads + cached remotes —
523
- # for a deterministic offline or CI run, and for anyone who would rather have
524
- # the old approximation than the round-trip.
525
- # unreachable origin ls-remote failing (offline, no remote, auth) is NOT fatal. The count falls
526
- # back to the cached `refs/remotes`, one line says so on stderr, and the start
527
- # proceeds. A gate that hard-fails with no network would be worse than one
528
- # that miscounts.
529
- #
530
- # Deliberately NOT cached between invocations: a cache reintroduces the staleness window this
531
- # replaces, and there is nothing to amortize — one ls-remote per interactive start.
532
- effort_wip_rows() {
533
- command -v effort_branch_rows >/dev/null 2>&1 || return 0
534
- local remote=""
535
- {
536
- effort_branch_rows_local 2>/dev/null
537
- if [ "${EFFORT_WIP_REMOTE:-1}" = "0" ]; then
538
- effort_branch_rows 2>/dev/null # opted out: local heads + cached remotes
539
- elif remote="$(effort_branch_rows_origin 2>/dev/null)"; then
540
- printf '%s\n' "$remote"
541
- else
542
- echo "effort_start: could not read origin's effort branches — counting work in progress from the last fetch, which may be stale (set EFFORT_WIP_REMOTE=0 to silence this)" >&2
543
- effort_branch_rows 2>/dev/null # offline fallback: local heads + cached remotes
544
- fi
545
- } | awk -F'\t' 'NF > 0 && $1 != "" && !seen[$1]++' | sort -n
546
- }
547
-
548
- # _eff_wip_gate <num> <force> — rc 0 when starting effort <num> may proceed, rc 1 (with the refusal
549
- # on stderr) when it may not. READ-ONLY: it reads refs (one of them over the network — see
550
- # effort_wip_rows) and the config, and writes nothing, so a refusal leaves no branch, no worktree and
551
- # no board change behind (the effort_new / effort_chain discipline). It is not free of reads: the
552
- # gate itself queries origin, and for a SLUG argument effort_start has already resolved the handle
553
- # through effort_slug_resolve, which may have run `gh issue list`. "Writes nothing" is the guarantee;
554
- # "reads nothing" is not.
555
- #
556
- # The rules:
557
- # already started an effort whose branch already exists is ALREADY in the counted set, so
558
- # re-running `effort start` on it adds no WIP and the gate does not apply —
559
- # `effort_start` stays safe to re-run at or over the limit.
560
- # at the limit `in-progress count >= limit` REFUSES. The limit is a ceiling on concurrent
561
- # efforts: at 2 of 2, a third would make 3. Only `count < limit` starts.
562
- # limit 0 refuses every new effort (a deliberate freeze); the override still works.
563
- # override `--force` (or KIT_FORCE=1, the same escape hatch effort_close uses) starts
564
- # anyway and says so on stderr.
565
- _eff_wip_gate() {
566
- local num="$1" force="${2:-}" limit rows count n tab; tab="$(printf '\t')"
567
- limit="$(_eff_wip_limit)"
568
- rows="$(effort_wip_rows)"
569
-
570
- while IFS="$tab" read -r n _; do
571
- if [ "$n" = "$num" ]; then return 0; fi
572
- done <<EOF
573
- $rows
574
- EOF
575
-
576
- count="$(printf '%s\n' "$rows" | grep -cE '^[0-9]+' || true)"
577
- if [ "${count:-0}" -lt "$limit" ]; then return 0; fi
578
-
579
- {
580
- echo "effort_start: $count effort(s) already in progress and the WIP limit is $limit."
581
- printf '%s\n' "$rows" | grep -E '^[0-9]+' | while IFS="$tab" read -r n _slug; do
582
- printf ' · %s (effort/%s-%s)\n' "$(effort_display "$n" "$_slug")" "$n" "$_slug"
583
- done
584
- } >&2
585
- if [ -n "$force" ]; then
586
- echo " → starting #$num anyway (override)." >&2
587
- return 0
588
- fi
589
- {
590
- echo " → refusing to start #$num — nothing was created."
591
- echo " Close one with 'cckit effort close <N>', or start anyway with --force (or KIT_FORCE=1)."
592
- echo " The limit is effort.wipLimit in the project config (default 2); EFFORT_WIP_LIMIT overrides it."
593
- } >&2
594
- return 1
595
- }
596
-
597
- # _eo_source_wt — lazily source the worktree mechanic (worktree-start.sh) so effort_start gets the
598
- # SAME full worktree setup as `cckit start`: wt_bootstrap (env-file copy + per-worktree dev port +
599
- # dependency install) and the _wt_session_owns collision guard. bin/cckit's `effort` verb does not
600
- # load it, so effort-ops brings it in on demand (#119). No-op if already loaded.
601
- _eo_source_wt() {
602
- command -v wt_bootstrap >/dev/null 2>&1 && return 0
603
- local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
604
- # shellcheck source=/dev/null
605
- [ -f "$d/worktree-start.sh" ] && . "$d/worktree-start.sh"
606
- }
607
-
608
- # effort_start [--force] <slug|N> [<slug>] — create the effort/<N> integration branch + its worktree
609
- # from base, with the full `cckit start` worktree setup (env copy, per-worktree dev port, dependency
610
- # install — opt out with KIT_WT_INSTALL=0) and a live-session collision guard.
611
- #
612
- # Gated by the WIP limit (#244): when as many efforts are already in progress as `effort.wipLimit`
613
- # allows (default 2), starting a NEW one is refused before anything is written — see _eff_wip_gate
614
- # above for the counted set and the exact rules. `--force` (or KIT_FORCE=1) starts anyway.
615
- # The gate is specific to EFFORTS: `cckit start <issue>` (a plain task worktree, wt_start) is not
616
- # affected and has no WIP limit.
617
- effort_start() {
618
- _eff_need git || return 1
619
- local raw="" slug_override="" force="" num repo base root title slug branch wt
620
- # Flags are position-INDEPENDENT (the effort_new parser shape): `--` forces the rest positional.
621
- local pos=()
622
- while [ $# -gt 0 ]; do
623
- case "$1" in
624
- --force) force=1; shift ;;
625
- --) shift; while [ $# -gt 0 ]; do pos+=("$1"); shift; done ;;
626
- --*) echo "effort_start: unknown flag $1" >&2; return 1 ;;
627
- *) pos+=("$1"); shift ;;
628
- esac
629
- done
630
- set -- "${pos[@]+"${pos[@]}"}"
631
- raw="${1:-}"; slug_override="${2:-}"
632
- if [ "${KIT_FORCE:-0}" = "1" ]; then force=1; fi
633
- [ -n "$raw" ] || { echo "effort_start: <slug|effort issue #> required" >&2; return 1; }
634
- num="$(effort_slug_resolve "$raw")" || { echo "effort_start: could not resolve '$raw' to an effort" >&2; return 1; }
635
- repo="$(_eff_repo)"; base="$(_eff_base)"
636
- root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree / && !hit {print $2; hit=1}')"
637
- [ -n "$root" ] || { echo "effort_start: not in a git repo" >&2; return 1; }
638
-
639
- # WIP gate (#244) — BEFORE the fetch, the branch, the worktree and the bootstrap, so a refusal
640
- # leaves nothing behind. Reads refs + config only; writes nothing.
641
- _eff_wip_gate "$num" "$force" || return 1
642
-
643
- if [ -n "$slug_override" ]; then slug="$(_eff_slug "$slug_override")"
644
- else
645
- # A soft read (#330): the slug has a fallback, so a failed gh must not end the op — and under
646
- # `set -e` a bare failed assignment did exactly that, rc 1 with no output. Failed is told apart
647
- # from empty by gh's exit code, and said on stderr.
648
- local title_rc=0
649
- title="$(forge_rest "repos/$repo/issues/$num" --jq .title 2>/dev/null)" || title_rc=$?
650
- slug=""
651
- if [ "$title_rc" -ne 0 ]; then
652
- title=""
653
- # An effort already started keeps its branch: a re-start during an outage must land on
654
- # effort/<N>-<its slug>, not cut a second branch named after the fallback.
655
- slug="$(git -C "$root" for-each-ref --format='%(refname:short)' "refs/heads/effort/$num-*" 2>/dev/null | sed -n 1p)"
656
- slug="${slug#effort/"$num"-}"
657
- echo "effort_start: could not read the title of issue #$num from GitHub (gh exited $title_rc) — continuing with the slug '${slug:-effort}'. To choose the slug: effort start $num <slug>" >&2
658
- fi
659
- [ -n "$slug" ] || slug="$(_eff_title_slug "${title:-effort}")"; [ -n "$slug" ] || slug="effort"
660
- fi
661
- # Worktree dir follows the kind+N-slug convention (branch-naming.md) so kit-gc's issue-open
662
- # protection recognizes it by DIRECTORY name too — matching the kit-effort-start skill (#119).
663
- branch="effort/$num-$slug"; wt="$root/.claude/worktrees/effort+$num-$slug"
664
-
665
- _eo_source_wt
666
-
667
- # Session-collision precheck: never disturb a worktree a LIVE session is sitting in (its work may
668
- # be uncommitted). Guarded on the helper being available.
669
- if [ -d "$wt" ] && command -v _wt_session_owns >/dev/null 2>&1 && _wt_session_owns "$root" "$wt"; then
670
- echo "effort_start: a live session owns $wt — refusing to disturb it" >&2; return 1
671
- fi
672
-
673
- git -C "$root" fetch origin "$base" --quiet 2>/dev/null || true
674
- if git -C "$root" show-ref --verify --quiet "refs/heads/$branch"; then
675
- echo "effort_start: branch $branch already exists" >&2
676
- else
677
- local from="origin/$base"; git -C "$root" rev-parse --verify --quiet "$from" >/dev/null 2>&1 || from="$base"
678
- git -C "$root" worktree add -b "$branch" "$wt" "$from" >/dev/null 2>&1 \
679
- || { echo "effort_start: failed to create worktree for $branch" >&2; return 1; }
680
- # Stamp the effort's start (#453): `effort close` subtracts it for build_seconds. Only here,
681
- # where the branch is created — a re-start of an effort begun earlier would stamp a start that
682
- # is too late, and capture falls back to the branch's oldest commit instead. Best-effort.
683
- _eo_source_metrics
684
- if command -v record_effort_start >/dev/null 2>&1; then
685
- ( cd "$root" && record_effort_start "$num" ) >/dev/null 2>&1 || true
686
- fi
687
- fi
688
-
689
- # Bootstrap the worktree for local dev: copy gitignored env, assign a per-worktree dev port, and
690
- # install deps (KIT_WT_INSTALL=0 opts out). Best-effort — a hiccup never fails the start.
691
- command -v wt_bootstrap >/dev/null 2>&1 && wt_bootstrap "$root" "$wt" "$num" || true
692
-
693
- echo " ✓ effort $(effort_display "$num" "$slug") → $branch (worktree: $wt)" >&2
694
- printf '%s|%s|%s\n' "$wt" "$branch" "$num"
695
- }
696
-
697
- # effort_pr [<slug|N>] — open the single PR effort/<N> → base. Defaults to the current effort branch.
698
- effort_pr() {
699
- # The ONE effort-PR implementation (#363). The kit-effort-pr skill calls this; before, the skill
700
- # carried its own inline copy, so agents hand-copied the script and the copy drifted (a PR missing
701
- # from the board, a mangled body). Args: [<slug|N>] [--summary S|--summary-file F]
702
- # [--for-agents A|--for-agents-file F] [--message M] [--title T]. SUMMARY / FOR_AGENTS / COMMIT_MSG env are
703
- # honoured as fallbacks.
704
- _eff_forge || return 1
705
- local raw="" summary="${SUMMARY:-}" for_agents="${FOR_AGENTS:-}" msg="${COMMIT_MSG:-}" title_override="" ctype=""
706
- while [ $# -gt 0 ]; do
707
- case "$1" in
708
- --summary) summary="${2:-}"; shift 2 ;;
709
- --summary-file) summary="$(cat "${2:-/dev/null}")"; shift 2 ;;
710
- --for-agents) for_agents="${2:-}"; shift 2 ;;
711
- --for-agents-file) for_agents="$(cat "${2:-/dev/null}")"; shift 2 ;;
712
- --message|-m) msg="${2:-}"; shift 2 ;;
713
- --title) title_override="${2:-}"; shift 2 ;;
714
- --type) ctype="${2:-}"; shift 2 ;;
715
- *) [ -z "$raw" ] && raw="$1"; shift ;;
716
- esac
717
- done
718
- local num repo base branch meta title labels milestone role role_disp name pr_title body url author
719
- repo="$(_eff_repo)"; base="$(_eff_base)"
720
- branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
721
- if [ -n "$raw" ]; then
722
- num="$(effort_slug_resolve "$raw")" || { echo "effort_pr: could not resolve '$raw' to an effort" >&2; return 1; }
723
- else
724
- num="$(effort_branch_num "$branch")"
725
- fi
726
- [ -n "$num" ] || { echo "effort_pr: not on an effort/<N>-… branch and no <slug|N> given" >&2; return 1; }
727
- case "$branch" in effort/"$num"-*) : ;; *) echo "effort_pr: current branch ($branch) is not effort/$num-…" >&2; return 1 ;; esac
728
-
729
- # Parent metadata: the PR inherits its labels + milestone, and the role names the title.
730
- meta="$(gh_rest_issue_json "$repo" "$num" 2>/dev/null)"
731
- title="$(printf '%s' "$meta" | jq -r '.title // ""' 2>/dev/null)"
732
- labels="$(printf '%s' "$meta" | jq -r '[.labels[]?.name] | join(",")' 2>/dev/null)"
733
- milestone="$(printf '%s' "$meta" | jq -r '.milestone.title // ""' 2>/dev/null)"
734
- role="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^role://p' | sed -n 1p)"
735
- role_disp=""
736
- if [ -n "$role" ] && command -v role_display >/dev/null 2>&1; then
737
- role_disp="$(role_display "$role" 2>/dev/null || true)"
738
- fi
739
- name="$(printf '%s' "$title" | sed -E 's/^\[Effort\] [0-9]+ · ?//')"
740
-
741
- # Commit pending changes. Role identity is a Co-authored-by TRAILER, never the git author (some
742
- # deploy providers refuse commits whose author email matches no account). TRACKED changes only:
743
- # `git add -A` here would sweep a copied .env.local into the PR. Untracked files are listed, not
744
- # committed — an effort's new files land in its per-sub commits.
745
- if [ -n "$(git ls-files --others --exclude-standard 2>/dev/null)" ]; then
746
- echo "effort_pr: untracked files NOT committed (commit them in their sub's commit if they belong):" >&2
747
- git ls-files --others --exclude-standard 2>/dev/null | sed 's/^/ /' >&2
748
- fi
749
- if [ -n "$(git status --porcelain --untracked-files=no 2>/dev/null)" ]; then
750
- author=""
751
- git add -u
752
- if [ -n "$role" ] && command -v role_git_author >/dev/null 2>&1; then
753
- author="$(role_git_author "$role" 2>/dev/null || true)"
754
- fi
755
- if [ -n "$author" ]; then
756
- git commit -q -m "${msg:-$role: ${name:-effort $num}}" -m "Co-authored-by: ${author%%|*} <${author##*|}>" || return 1
757
- else
758
- git commit -q -m "${msg:-${role:-chore}: ${name:-effort $num}}" || return 1
759
- fi
760
- fi
761
- git push -u origin "$branch" >/dev/null 2>&1 || echo "effort_pr: push of $branch failed — continuing (the PR may already be current)" >&2
762
-
763
- # ONE shared composer (effort.sh) so every surface titles identically, then the mandatory-[#N]
764
- # check before we ever call gh — refuse rather than open an id-less PR (#121).
765
- # --title replaces the composed title; it must still carry the [#N] id, checked below.
766
- pr_title="${title_override:-$(effort_pr_title "$num" "${name:-effort}" "$labels" "$ctype" "$role_disp")}"
767
- effort_pr_title_check "$pr_title" "$num" || { echo "effort_pr: refusing to open a PR without the [#$num] effort id" >&2; return 1; }
768
- # #237: under pr.titleStyle = conventional (the default) the title becomes the squash commit the
769
- # commitlint gate checks, so a title that gate rejects — composed (a bad --type) or passed with
770
- # --title — is refused here, before gh. issue-title repos run no such gate and skip the check.
771
- if [ "${KIT_PR_TITLE_STYLE:-conventional}" != "issue-title" ]; then
772
- if ! command -v commitlint_check >/dev/null 2>&1; then
773
- local _cl_dir; _cl_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)"
774
- # shellcheck source=/dev/null
775
- [ -f "$_cl_dir/commitlint.sh" ] && . "$_cl_dir/commitlint.sh"
776
- fi
777
- if command -v commitlint_check >/dev/null 2>&1; then
778
- commitlint_check "$pr_title" || { echo "effort_pr: refusing to open a PR whose title is not a Conventional Commit subject (pass --type <type> or --title, or set pr.titleStyle to issue-title)" >&2; return 1; }
779
- else
780
- echo "effort_pr: commitlint.sh not found — the PR title was not checked against Conventional Commits" >&2
781
- fi
782
- fi
783
- body="$(_eff_pr_body "$num" "$summary" "$for_agents" "$role")"
784
-
785
- url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$pr_title" "$body" "$labels" "$milestone")" || return 1
786
- echo "✓ $url"
787
- _eff_pr_board "$num" "$url" "$role"
788
- }
789
-
790
- # _eff_pr_body <num> <summary> <for-agents> [role] — the effort PR body: the orchestrator header,
791
- # `Closes #N`, a human Summary, the agent-facing For agents block, and a Verification checklist.
792
- # An empty section prints a visible placeholder, never nothing, so a reviewer sees what is missing.
793
- _eff_pr_body() {
794
- local num="$1" summary="$2" for_agents="$3" role="${4:-}" sig=""
795
- if [ -n "$role" ] && command -v role_signature >/dev/null 2>&1; then
796
- sig="$(role_signature "$role" 2>/dev/null || true)"
797
- fi
798
- # pr.bodyStyle = content (KIT_PR_BODY_STYLE, #418): draft-and-review wording for content work.
799
- # `Closes #N`, the Summary and the For agents block are the same in both styles.
800
- if [ "${KIT_PR_BODY_STYLE:-code}" = "content" ]; then
801
- printf '## For the orchestrator\n\nEffort #%s — one PR for the whole effort. Review: the summary below and the changed files.\n\nCloses #%s\n\n' "$num" "$num"
802
- printf '## Summary\n\n%s\n\n' "${summary:-_(no summary given — pass --summary)_}"
803
- printf '## For agents\n\n%s\n\n' "${for_agents:-See #$num for the goal, scope, and entry points.}"
804
- printf '## Review\n\n- [ ] Every piece the summary lists is in the changed files\n- [ ] Facts, names, numbers and links are checked\n- [ ] The voice matches the brand guide\n- [ ] Only the files for this work changed\n- [ ] Labels + milestone match the parent issue\n'
805
- [ -n "$sig" ] && printf '\n%s\n' "$sig"
806
- return 0
807
- fi
808
- printf '## For the orchestrator\n\nEffort #%s — one PR for the whole effort. Review: the summary below + the diff.\n\nCloses #%s\n\n' "$num" "$num"
809
- printf '## Summary\n\n%s\n\n' "${summary:-_(no summary given — pass --summary)_}"
810
- printf '## For agents\n\n%s\n\n' "${for_agents:-See #$num for the goal, scope, and entry points.}"
811
- printf '## Verification\n\n- [ ] Each sub-issue change is present in the diff\n- [ ] No unrelated files in the diff\n- [ ] Labels + milestone match the parent issue\n- [ ] Local lint/typecheck pass\n'
812
- [ -n "$sig" ] && printf '\n%s\n' "$sig"
813
- return 0
814
- }
815
-
816
- # _eff_pr_board <num> <pr-url> [role] — add the PR to the board at In Review (+ Role) and move the
817
- # parent to In Review. A no-op unless Projects v2 is on; a failed PR add is reported, never silent.
818
- _eff_pr_board() {
819
- local num="$1" url="$2" role="${3:-}" repo pr_num node item ropt parent
820
- [ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
821
- cckit_board_skipped && return 0
822
- _eo_source_board
823
- command -v project_add_item >/dev/null 2>&1 || return 0
824
- repo="$(_eff_repo)"; pr_num="${url##*/}"
825
- node="$(forge_rest "repos/$repo/pulls/$pr_num" --jq .node_id 2>/dev/null)" || node=""
826
- item=""
827
- [ -n "$node" ] && item="$(project_add_item "$node" 2>/dev/null || true)"
828
- if [ -z "$item" ]; then
829
- echo "⚠ PR #$pr_num was opened but NOT added to the board — add it by hand" >&2
830
- else
831
- if [ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_IN_REVIEW:-}" ]; then
832
- project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_IN_REVIEW" >/dev/null 2>&1 || true
833
- fi
834
- if [ -n "$role" ] && [ -n "${ROLE_FIELD_ID:-}" ] && command -v role_option_id >/dev/null 2>&1; then
835
- ropt="$(role_option_id "$role" || true)"
836
- [ -n "$ropt" ] && { project_set_single_select "$item" "$ROLE_FIELD_ID" "$ropt" >/dev/null 2>&1 || true; }
837
- fi
838
- fi
839
- parent="$(project_find_item_by_issue "$num" 2>/dev/null || true)"
840
- if [ -n "$parent" ] && [ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_IN_REVIEW:-}" ]; then
841
- project_set_single_select "$parent" "$STATUS_FIELD_ID" "$STATUS_OPT_IN_REVIEW" >/dev/null 2>&1 || true
842
- fi
843
- return 0
844
- }
845
-
846
- # _eo_source_metrics — lazily source effort-metrics.sh so effort_close can call the shipped
847
- # capture/judge/sync functions even when only effort-ops is loaded (bin/cckit sources it for the
848
- # effort verb; this makes the composition robust + testable). No-op if already loaded.
849
- _eo_source_metrics() {
850
- command -v capture_effort_metrics >/dev/null 2>&1 && return 0
851
- local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
852
- # shellcheck source=/dev/null
853
- [ -f "$d/effort-metrics.sh" ] && . "$d/effort-metrics.sh"
854
- }
855
-
856
- # _eo_source_gc — lazily source kit-gc.sh so effort_close can collect the effort's `sub/<N>…`
857
- # worktrees + branches through the LANDED prune path (#388) — the ONE classifier, never a second
858
- # `git branch -D` loop here. No-op if already loaded; a missing file degrades to "no sub GC".
859
- _eo_source_gc() {
860
- command -v kit_gc_prune >/dev/null 2>&1 && return 0
861
- local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
862
- # shellcheck source=/dev/null
863
- [ -f "$d/kit-gc.sh" ] && . "$d/kit-gc.sh"
864
- }
865
-
866
- # _eo_source_board — lazily source the board helpers (gh-project.sh) + captured field ids so
867
- # effort_close can set Status=Done from any shell, with no caller wiring (bin/cckit sources the
868
- # board helpers only for `effort new`). Guarded: a no-op unless Projects v2 is on; a missing
869
- # gh-project.sh or ids file degrades to a no-op (the board steps below are themselves guarded).
870
- _eo_source_board() {
871
- [ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
872
- cckit_board_skipped && return 0
873
- if ! command -v project_find_item_by_issue >/dev/null 2>&1; then
874
- local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
875
- # shellcheck source=/dev/null
876
- [ -f "$d/gh-project.sh" ] && . "$d/gh-project.sh"
877
- fi
878
- if [ -z "${STATUS_FIELD_ID:-}" ] && command -v load_project_ids >/dev/null 2>&1; then
879
- load_project_ids >/dev/null 2>&1 || true
880
- fi
881
- return 0
882
- }
883
-
884
- # _eo_issue_close_completed <repo> <n> — close as completed on the chosen transport (#396), quietly.
885
- _eo_issue_close_completed() { gh_rest_issue_close "$1" "$2" completed >/dev/null 2>&1; }
886
-
887
- # _eo_board_done <issue #> — set the board Status=Done for one issue. Guarded like _eff_board_add:
888
- # a no-op unless Projects v2 is on AND the board helpers + field ids are loaded. Best-effort — a
889
- # board hiccup never fails the close (the merge already landed).
890
- _eo_board_done() {
891
- local n="$1" item
892
- [ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
893
- cckit_board_skipped && return 0
894
- command -v project_find_item_by_issue >/dev/null 2>&1 || return 0
895
- [ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_DONE:-}" ] || return 0
896
- item="$(project_find_item_by_issue "$n" 2>/dev/null)" || return 0
897
- [ -n "$item" ] || { echo " ⚠ #$n not on board — skipped" >&2; return 0; }
898
- project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_DONE" 2>/dev/null \
899
- && echo " ✓ board Done: #$n" >&2 || true
900
- return 0
901
- }
902
-
903
- # Kit-managed paths (the kit ⇄ project sync surface): a change here that is not contributed
904
- # upstream (/kit-contribute) is a latent regression the next /kit-update can clobber. One place —
905
- # effort_close's drift check greps against this (was inlined in the kit-effort-close skill, #148),
906
- # and so does the task-merge drift check in the kit-task-pr-merge skill.
907
- # .claude/rules/ is matched by BASENAME, not as a directory (#218): init.sh writes a rule only from
908
- # templates/rules/<name>.md, so any other file there is the project's own and no /kit-update can
909
- # touch it. The list is the templates/rules basenames; effort-ops-test.sh fails when they differ.
910
- _EO_KIT_MANAGED_RE='^(scripts/(lib/|kit$|kit-)|\.claude/(skills|hooks|lib|agents)/|\.claude/rules/(authoring|branch-naming|code-retrieval|communication-style|delegation-brief|design-routing|effort-model|gate-and-review|issue-lifecycle|knowledge-base|mempalace|merge-safety|naming-and-ids|plain-language|plan-next|plan-output-format|react-annotate|review-pages|risk-tiered-review|shared-checkout|skill-gaps|task-management)\.md$)'
911
-
912
- # _eo_knowledge_ingest <num> <trace_dir> <root> — optional post-close knowledge-ingest hook. Runs a
913
- # project-configured command (github/effort.knowledgeIngestHook, or KIT_EFFORT_KNOWLEDGE_HOOK) with
914
- # the effort number + trace dir, so a project can fold the closed effort's work record into its
915
- # knowledge base. Config-gated: a NO-OP when unset or the hook file is missing/not executable — the
916
- # kit ships no default hook. Best-effort — a hook failure never fails the close.
917
- #
918
- # The config is read AFTER the close removed the effort worktree, and bin/cckit exports KIT_CONFIG as
919
- # the copy inside that worktree (#518). So a KIT_CONFIG that no longer exists falls back to the main
920
- # checkout's config; when that is missing too the close says so — a config that vanished is not the
921
- # same as a project with no hook. The hook's stdout + stderr go to stderr, like the pre-close hook's.
922
- _eo_knowledge_ingest() {
923
- local num="$1" trace="$2" root="$3" hook="" cfg
924
- hook="${KIT_EFFORT_KNOWLEDGE_HOOK:-}"
925
- if [ -z "$hook" ]; then
926
- cfg="${KIT_CONFIG:-}"
927
- if [ -z "$cfg" ] || [ ! -f "$cfg" ]; then
928
- if [ -f "$root/cckit.config.json" ]; then cfg="$root/cckit.config.json"
929
- elif [ -f "$root/.claude/kit.config.json" ]; then cfg="$root/.claude/kit.config.json"
930
- elif [ -n "$cfg" ]; then
931
- echo "effort_close: project config '$cfg' went away with the worktree and the main checkout has none — post-close hook not read" >&2
932
- return 0
933
- fi
934
- fi
935
- [ -f "$cfg" ] && command -v jq >/dev/null 2>&1 \
936
- && hook="$(jq -r '.effort.knowledgeIngestHook // empty' "$cfg" 2>/dev/null)"
937
- fi
938
- [ -n "$hook" ] || return 0
939
- case "$hook" in /*) : ;; *) hook="$root/$hook" ;; esac # resolve a relative hook against the root
940
- [ -x "$hook" ] || { echo "effort_close: knowledge-ingest hook '$hook' not executable — skipping" >&2; return 0; }
941
- echo " → knowledge-ingest hook: $hook $num" >&2
942
- # Run it from the main checkout (#371): the close has just removed the worktree it was invoked from,
943
- # so the inherited cwd no longer exists and a hook's relative paths / bare git calls would fail.
944
- ( cd "${root:-/}" && "$hook" "$num" "$trace" ) 1>&2 || echo "effort_close: knowledge-ingest hook failed (non-fatal)" >&2
945
- }
946
-
947
- # _eo_dependent_prs <branch> — pure selector (#358): `gh pr list --json number,baseRefName` on stdin,
948
- # the numbers of the PRs whose base is exactly <branch> on stdout, one per line. Empty stdin prints
949
- # nothing; input that is not a JSON array is rc 1, so the caller can tell "none" from "unreadable".
950
- _eo_dependent_prs() {
951
- jq -r --arg b "$1" 'if type == "array" then .[] | select(.baseRefName == $b) | .number else error("not a list") end' 2>/dev/null
952
- }
953
-
954
- # _eo_retarget_dependents <repo> <branch> <base> — re-target every open PR based on <branch> to
955
- # <base> (#358). GitHub closes a PR, unmerged, the moment its base branch is deleted, and the squash
956
- # below deletes <branch>. rc 1 when the list cannot be read or an edit fails: the caller refuses the
957
- # close, because either one means a PR would be closed by the delete.
958
- _eo_retarget_dependents() {
959
- local repo="$1" branch="$2" base="$3" json deps dep
960
- json="$(forge_rest "repos/$repo/pulls" -X GET -f base="$branch" -f state=open -f per_page=100 \
961
- --jq '[.[] | {number, baseRefName: .base.ref}]' 2>/dev/null)" \
962
- && deps="$(printf '%s' "$json" | _eo_dependent_prs "$branch")" \
963
- || { echo "effort_close: could not list the open PRs based on $branch — deleting it would close any that exist. Rerun when GitHub answers (nothing was merged)" >&2; return 1; }
964
- while IFS= read -r dep; do
965
- [ -n "$dep" ] || continue
966
- forge_rest "repos/$repo/pulls/$dep" -X PATCH -f base="$base" >/dev/null 2>&1 \
967
- || { echo "effort_close: PR $dep is based on $branch and could not be re-targeted to $base — deleting the branch would close it. Change its base to $base on GitHub, then rerun (nothing was merged)" >&2; return 1; }
968
- echo " ↻ PR $dep re-targeted to $base" >&2
969
- done <<EOF_DEPS
970
- $deps
971
- EOF_DEPS
972
- }
973
-
974
- # _eo_pre_close_hook <num> <repo> <root> <cwd> [<subs>] — optional project gate that runs BEFORE the
975
- # close writes anything (#380). Runs a project-configured command (effort.preCloseHook, or
976
- # KIT_EFFORT_PRE_CLOSE_HOOK) as `<hook> <effort#> <sub#…>` with cwd = <cwd> (the effort worktree; the
977
- # checkout the close was run from on the wave path). <subs> is a newline-separated sub list; when
978
- # omitted the native sub-issues are read from GitHub. Returns 1 — the caller refuses the close —
979
- # when the hook exits non-zero, or is configured but not executable: a gate that cannot run must not
980
- # pass. The hook's stdout + stderr go to stderr. KIT_FORCE=1 skips the hook and says so. A NO-OP
981
- # (rc 0, no GitHub read) when no hook is configured — the kit ships no default hook.
982
- _eo_pre_close_hook() {
983
- local num="$1" repo="$2" root="$3" cwd="$4" subs="${5:-}" hook="" cfg sub rc
984
- hook="${KIT_EFFORT_PRE_CLOSE_HOOK:-}"
985
- if [ -z "$hook" ]; then
986
- cfg="${KIT_CONFIG:-}"; [ -n "$cfg" ] || { [ -f "$root/cckit.config.json" ] && cfg="$root/cckit.config.json" || cfg="$root/.claude/kit.config.json"; }
987
- [ -f "$cfg" ] && command -v jq >/dev/null 2>&1 \
988
- && hook="$(jq -r '.effort.preCloseHook // empty' "$cfg" 2>/dev/null)"
989
- fi
990
- [ -n "$hook" ] || return 0
991
- case "$hook" in /*) : ;; *) hook="$root/$hook" ;; esac # resolve a relative hook against the root
992
- if [ "${KIT_FORCE:-0}" = "1" ]; then
993
- echo "effort_close: pre-close hook '$hook' skipped (KIT_FORCE=1)" >&2; return 0
994
- fi
995
- [ -x "$hook" ] || { echo "effort_close: pre-close hook '$hook' is configured but not executable — refusing to close #$num (nothing was written). Fix effort.preCloseHook, or set KIT_FORCE=1 to skip it." >&2; return 1; }
996
- [ "$#" -ge 5 ] || subs="$(forge_rest "repos/$repo/issues/$num/sub_issues" --jq '.[].number' 2>/dev/null)"
997
- set -- "$num"
998
- while IFS= read -r sub; do
999
- [ -n "$sub" ] && set -- "$@" "$sub"
1000
- done <<EOF_SUBS
1001
- $subs
1002
- EOF_SUBS
1003
- echo " → pre-close hook: $hook $*" >&2
1004
- ( cd "${cwd:-.}" && "$hook" "$@" ) 1>&2; rc=$?
1005
- [ "$rc" -eq 0 ] && return 0
1006
- echo "effort_close: pre-close hook exited $rc — refusing to close #$num (nothing was written). Fix what it reports, or set KIT_FORCE=1 to skip it." >&2
1007
- return 1
1008
- }
1009
-
1010
- # effort_close <N> — the SINGLE close implementation (#148): the /kit-effort-close skill is a thin
1011
- # caller of this function, never a second close. Snapshot per-sub diffs + capture metrics BEFORE the
1012
- # squash (the squash erases the per-sub history), REFUSE to squash if no work trace was captured
1013
- # (KIT_FORCE=1 overrides), squash-merge, judge the metrics, close parent + subs, set the board
1014
- # Status=Done for each (guarded), GC the worktree/branch, run the optional knowledge-ingest hook,
1015
- # and finish with the advisory kit-sync drift check. Destructive: it merges, closes, and prunes.
1016
- effort_close() {
1017
- _eff_forge || return 1; _eff_need jq || return 1
1018
- local raw="${1:-}" num repo base branch root self_wt trace_dir kit_touched
1019
- [ -n "$raw" ] || { echo "effort_close: <slug|effort issue #> required" >&2; return 1; }
1020
- num="$(effort_slug_resolve "$raw")" || { echo "effort_close: could not resolve '$raw' to an effort" >&2; return 1; }
1021
- repo="$(_eff_repo)"; base="$(_eff_base)"
1022
- branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
1023
- case "$branch" in
1024
- effort/"$num"-*) : ;;
1025
- *)
1026
- # Not on the integration branch. If effort/<num>-… exists (locally or on origin), this is
1027
- # just the wrong cwd — keep the instruction. If it exists NOWHERE, this is a WAVE-style
1028
- # effort (#164): the subs shipped as individual task PRs squash-merged straight to base, so
1029
- # there is no branch to run from — close via the merged sub PRs instead.
1030
- if [ -n "$(git branch --list "effort/$num-*" 2>/dev/null)" ] \
1031
- || [ -n "$(git ls-remote --heads origin "effort/$num-*" 2>/dev/null)" ]; then
1032
- echo "effort_close: run from the effort/$num-… branch" >&2; return 1
1033
- fi
1034
- _eo_close_wave "$num" "$repo" "$base"; return $? ;;
1035
- esac
1036
- root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree / && !hit {print $2; hit=1}')"
1037
- self_wt="$(git rev-parse --show-toplevel 2>/dev/null)"
1038
- _eo_source_metrics
1039
-
1040
- # (pre) optional project gate (effort.preCloseHook, #380) — before the snapshot, so a refusal
1041
- # writes nothing: no trace, no metrics row, no merge.
1042
- _eo_pre_close_hook "$num" "$repo" "$root" "$self_wt" || return 1
1043
-
1044
- # (a) snapshot the per-sub-issue diffs while the unsquashed history still exists (echoes the trace dir).
1045
- trace_dir="$(effort_snapshot_subs "$num" "origin/$base" 2>/dev/null)"
1046
-
1047
- # (a2) refuse-squash-without-trace backstop: the squash is irreversible and collapses the per-sub
1048
- # commits that ARE the work record. If nothing was snapshotted, refuse — unless KIT_FORCE=1.
1049
- # index.jsonl is the marker, not the presence of a .diff: the snapshot moves it into place only
1050
- # after every record is written, so a non-empty index means a complete trace. The old `ls *.diff`
1051
- # test passed on the empty NN-.diff a collapsed run left behind (#339).
1052
- if [ -z "$trace_dir" ] || [ ! -s "$trace_dir/index.jsonl" ]; then
1053
- if [ "${KIT_FORCE:-0}" = "1" ]; then
1054
- echo "effort_close: no per-sub work trace captured — proceeding anyway (KIT_FORCE=1)" >&2
1055
- else
1056
- echo "effort_close: refusing to squash-merge #$num — no per-sub work trace was captured; the squash would erase the per-sub history irrecoverably. Run from the effort branch with its commits present, or set KIT_FORCE=1 to override." >&2
1057
- return 1
1058
- fi
1059
- fi
1060
-
1061
- # (a2) refuse a conflicting PR before anything is written (#394). The capture below appends a
1062
- # records.jsonl row and consumes the effort's start marker, so a merge that fails after it leaves a
1063
- # row the retry duplicates with build_seconds null. UNKNOWN (GitHub still computing) proceeds.
1064
- local rest_pr="" rest_meta="" mergeable
1065
- # A failed read, or no open PR, must stop here (#330): carrying on let the capture write its row
1066
- # and consume the start marker before the merge failed.
1067
- rest_pr="$(gh_rest_pr_for_head "$repo" "$branch" 2>/dev/null)" || rest_pr=""
1068
- [ -n "$rest_pr" ] && rest_meta="$(gh_rest_pr_json "$repo" "$rest_pr" 2>/dev/null)" || rest_meta=""
1069
- [ -n "$rest_meta" ] || {
1070
- echo "effort_close: could not read the PR for $branch from GitHub (no PR, or the API is unavailable) — rerun when it answers (nothing was written)" >&2
1071
- return 1
1072
- }
1073
- mergeable="$(printf '%s' "$rest_meta" | jq -r .mergeable)"
1074
- if [ "$mergeable" = "CONFLICTING" ]; then
1075
- echo "effort_close: the PR for $branch conflicts with $base — merge or rebase $base into it, then rerun (nothing was written)" >&2
1076
- return 1
1077
- fi
1078
-
1079
- # (a3) re-target the open PRs based on this branch before the squash deletes it (#358). Here, not
1080
- # next to the merge, for the same reason as the conflict check: a refusal after the capture leaves
1081
- # a records.jsonl row the retry duplicates. In the cloud the remote branch is kept (the proxy
1082
- # rejects branch deletion), so nothing can close a dependent PR there and the step is skipped.
1083
- if ! cckit_in_cloud; then
1084
- _eo_retarget_dependents "$repo" "$branch" "$base" || return 1
1085
- fi
1086
-
1087
- # (b) capture effort metrics PRE-squash (needs the live-branch diff + commit signals).
1088
- command -v capture_effort_metrics >/dev/null 2>&1 && capture_effort_metrics "$num" "origin/$base" || true
1089
-
1090
- # (b2) record which kit-managed files this effort touched, PRE-squash (the branch is GC'd below,
1091
- # so the live-branch diff is the reliable source). The warning itself is emitted last (step h).
1092
- kit_touched="$(git diff --name-only "origin/$base"...HEAD 2>/dev/null \
1093
- | grep -E "$_EO_KIT_MANAGED_RE" | sort -u || true)"
1094
-
1095
- # (c) squash-merge the effort PR, then delete the remote branch (git, not the API). In a cloud
1096
- # session the proxy rejects the deletion (#396): the branch is kept and the close says so.
1097
- { [ -n "$rest_pr" ] && gh_rest_pr_merge "$repo" "$rest_pr" squash >/dev/null 2>&1; } \
1098
- || { echo "effort_close: could not squash-merge the PR for $branch (open? mergeable?)" >&2; return 1; }
1099
- echo " ✓ merged $branch" >&2
1100
- if cckit_in_cloud; then
1101
- echo " (remote branch $branch kept — branch deletion is unavailable here; delete it on GitHub)" >&2
1102
- else
1103
- git -C "${root:-.}" push origin --delete "$branch" >/dev/null 2>&1 && echo " ✓ deleted remote branch $branch" >&2 \
1104
- || echo " (remote branch $branch not deleted — delete it on GitHub)" >&2
1105
- fi
1106
-
1107
- # (d) judge the metrics (reads the durable trace dir; the record stays in the local buffer).
1108
- command -v judge_effort_metrics >/dev/null 2>&1 && judge_effort_metrics "$num" "origin/$base" || true
1109
-
1110
- # (e) close every native sub-issue, then the parent — and set the board Status=Done for each
1111
- # (guarded: a no-op when Projects v2 is off or the board helpers/ids are unavailable). Board +
1112
- # issue + record state are owned by this ONE op (effort-model.md) — never a separate "mark done".
1113
- _eo_source_board
1114
- local sub
1115
- while IFS= read -r sub; do
1116
- [ -n "$sub" ] || continue
1117
- _eo_issue_close_completed "$repo" "$sub" && echo " ✓ closed sub #$sub" >&2
1118
- _eo_board_done "$sub"
1119
- done < <(forge_rest "repos/$repo/issues/$num/sub_issues" --jq '.[].number' 2>/dev/null)
1120
- _eo_issue_close_completed "$repo" "$num" && echo " ✓ closed effort #$num" >&2
1121
- _eo_board_done "$num"
1122
-
1123
- # (f) GC: switch the main checkout to base, remove the effort worktree, delete the local branch,
1124
- # prune. The remote branch was deleted in step (c). All via `git -C "$root"` so the
1125
- # caller's cwd is never moved. Best-effort — a GC hiccup never fails the (already-landed) close.
1126
- if [ -n "$root" ]; then
1127
- git -C "$root" checkout "$base" >/dev/null 2>&1 || true
1128
- git -C "$root" pull origin "$base" --quiet >/dev/null 2>&1 || true
1129
- # (f2) the effort's sub worktrees + branches (#388): the squash just put their work on base, so
1130
- # kit_gc_prune's LANDED path deletes them — same classifier and recover-before-prune guards as
1131
- # `cckit cleanup` (a dirty sub worktree, or a sub ahead of its remote, stays). Runs in a subshell
1132
- # from the main checkout, BEFORE this worktree is removed, with the base `origin/<base>` just
1133
- # pulled above. A sub that fails both LANDED checks is left as an ORPHAN for `cckit gc` to show.
1134
- _eo_source_gc
1135
- if command -v kit_gc_prune >/dev/null 2>&1; then
1136
- ( cd "$root" && KIT_GC_REPO="$repo" KIT_BASE_BRANCH="$base" kit_gc_prune --yes --only "^sub/${num}[a-z]-" 2>&1 \
1137
- | grep -E '^ (removed worktree|deleted local branch|SKIP)' | sed 's/^ / ✓ sub gc: /' >&2 ) || true
1138
- fi
1139
- if [ -n "$self_wt" ] && [ "$self_wt" != "$root" ]; then
1140
- case "$self_wt" in "$root"/.claude/worktrees/*)
1141
- git -C "$root" worktree remove "$self_wt" --force >/dev/null 2>&1 && echo " ✓ removed worktree $self_wt" >&2 ;;
1142
- esac
1143
- fi
1144
- git -C "$root" branch -D "$branch" >/dev/null 2>&1 && echo " ✓ deleted local branch $branch" >&2
1145
- git -C "$root" worktree prune >/dev/null 2>&1 || true
1146
- fi
1147
-
1148
- # (g) optional, config-gated knowledge-ingest hook (no-op when absent).
1149
- _eo_knowledge_ingest "$num" "${trace_dir:-}" "$root"
1150
-
1151
- # (h) kit-sync drift check — kit ⇄ project stay in sync (#148, moved here from the skill).
1152
- _eo_kit_sync_warn "$kit_touched"
1153
- }
1154
-
1155
- # _eo_kit_sync_warn <files> — the advisory kit-sync drift warning, shared by both close styles
1156
- # (#148/#164). If an effort changed kit-managed files they likely belong upstream (/kit-contribute);
1157
- # an un-upstreamed change is a latent regression the next /kit-update can clobber. Never blocks.
1158
- _eo_kit_sync_warn() {
1159
- [ -n "${1:-}" ] || return 0
1160
- {
1161
- echo ""
1162
- echo " ⚠ kit-sync: this effort changed kit-managed files — review for upstream (/kit-contribute):"
1163
- printf '%s\n' "$1" | sed 's/^/ /'
1164
- echo " kit ⇄ project must stay in sync; an un-upstreamed change can be clobbered by /kit-update."
1165
- } >&2
1166
- }
1167
-
1168
- # _eo_close_wave <num> <repo> <base> — close a WAVE-style effort (#164): every sub was delivered as
1169
- # its own task PR squash-merged straight to base (`cckit wave` → fan-out → `cckit watch --merge`),
1170
- # so no effort/<N> integration branch ever existed. Verifies every sub is CLOSED with a merged
1171
- # closing PR (refuses and lists the stragglers otherwise), snapshots the work trace from the merged
1172
- # sub PR diffs, then runs the SAME close tail as the branch path: judge the metrics, close the
1173
- # parent, board Status=Done for parent + subs, knowledge-ingest hook, kit-sync drift check.
1174
- # capture_effort_metrics is intentionally skipped — there is no live branch diff to measure; the
1175
- # merged PR diffs in the trace are the work record.
1176
- _eo_close_wave() {
1177
- local num="$1" repo="$2" base="$3" root rows bad trace_dir kit_touched sub
1178
- root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree / && !hit {print $2; hit=1}')"
1179
- _eo_source_metrics
1180
-
1181
- # (a) read every sub + the merged PR that closed it, one "sub|state|pr|merge-oid|title" line each
1182
- # (title LAST so a stray "|" in it can't shift the fields awk/read split on).
1183
- if cckit_gh_rest; then
1184
- rows="$(gh_rest_wave_rows "$repo" "$num" 2>/dev/null)"
1185
- else
1186
- rows="$(forge_rest graphql -f query='
1187
- query($o:String!,$r:String!,$n:Int!){ repository(owner:$o,name:$r){ issue(number:$n){
1188
- subIssues(first:50){ nodes { number state
1189
- closedByPullRequestsReferences(first:10){ nodes { number merged mergeCommit{oid} title } } } } } } }' \
1190
- -F o="${repo%/*}" -F r="${repo#*/}" -F n="$num" --jq '
1191
- .data.repository.issue.subIssues.nodes[]
1192
- | (((.closedByPullRequestsReferences.nodes // []) | map(select(.merged)) | .[0]) // null) as $pr
1193
- | "\(.number)|\(.state)|\($pr.number // "")|\($pr.mergeCommit.oid // "")|\($pr.title // "")"' 2>/dev/null)"
1194
- fi
1195
- [ -n "$rows" ] || { echo "effort_close: no effort/$num-… branch and no readable sub-issues — nothing to close (wave-style needs merged subs, #164)" >&2; return 1; }
1196
-
1197
- # (b) every sub must be CLOSED with a merged closing PR — otherwise the effort is not done.
1198
- bad="$(printf '%s\n' "$rows" | awk -F'|' '$2 != "CLOSED" || $3 == "" {
1199
- printf " #%s (%s%s)\n", $1, tolower($2), ($3 == "" ? ", no merged PR" : "") }')"
1200
- if [ -n "$bad" ]; then
1201
- echo "effort_close: #$num is not done — these subs are still open or lack a merged PR:" >&2
1202
- printf '%s\n' "$bad" >&2
1203
- return 1
1204
- fi
1205
-
1206
- # (pre) the same optional project gate as the branch path (#380), before the trace is written.
1207
- # There is no effort worktree here, so it runs from the checkout the close was invoked in.
1208
- _eo_pre_close_hook "$num" "$repo" "$root" "$(git rev-parse --show-toplevel 2>/dev/null)" \
1209
- "$(printf '%s\n' "$rows" | cut -d'|' -f1)" || return 1
1210
-
1211
- # (c) the work trace, from the merged sub PR diffs (the record the per-sub squashes left behind).
1212
- # Same refuse-without-trace backstop as the branch path (#120) — KIT_FORCE=1 overrides.
1213
- trace_dir="$(effort_snapshot_merged_subs "$num" "$rows" 2>/dev/null)"
1214
- if [ -z "$trace_dir" ] || ! ls "$trace_dir"/*.diff >/dev/null 2>&1; then
1215
- if [ "${KIT_FORCE:-0}" = "1" ]; then
1216
- echo "effort_close: no per-sub work trace captured — proceeding anyway (KIT_FORCE=1)" >&2
1217
- else
1218
- echo "effort_close: refusing to close #$num — could not capture the work trace from the merged sub PRs. Set KIT_FORCE=1 to override." >&2
1219
- return 1
1220
- fi
1221
- fi
1222
-
1223
- # (d) judge the metrics off the trace (guarded, best-effort — same as the branch path).
1224
- command -v judge_effort_metrics >/dev/null 2>&1 && judge_effort_metrics "$num" "origin/$base" || true
1225
-
1226
- # (e) kit-sync drift source: the union of files across the merged sub PR diffs.
1227
- kit_touched="$(awk '/^diff --git /{print $3}' "$trace_dir"/*.diff 2>/dev/null | sed 's#^a/##' \
1228
- | grep -E "$_EO_KIT_MANAGED_RE" | sort -u || true)"
1229
-
1230
- # (f) close the parent + board Status=Done for parent and every sub (subs are already closed).
1231
- _eo_source_board
1232
- for sub in $(printf '%s\n' "$rows" | cut -d'|' -f1); do
1233
- _eo_board_done "$sub"
1234
- done
1235
- _eo_issue_close_completed "$repo" "$num" && echo " ✓ closed effort #$num" >&2
1236
- _eo_board_done "$num"
1237
-
1238
- # (g) GC: the sub branches/worktrees were GC'd by their own merges — just prune stragglers.
1239
- [ -n "$root" ] && git -C "$root" worktree prune >/dev/null 2>&1 || true
1240
-
1241
- # (h) same optional hook + advisory drift check as the branch path.
1242
- _eo_knowledge_ingest "$num" "${trace_dir:-}" "$root"
1243
- _eo_kit_sync_warn "$kit_touched"
1244
- }
2
+ # cckit-forwarding-stub: scripts/lib/effort-ops.sh moved to lib/verbs/effort-ops.sh (#602). Installed projects call this path, so
3
+ # the stub stays until the release after 0.13 (decision 66). Sourced (bash or zsh) or run, it forwards.
4
+ _cckit_self="${BASH_SOURCE[0]:-$0}"
5
+ _cckit_fwd="$(cd "$(dirname "$_cckit_self")" 2>/dev/null && pwd)/../../lib/verbs/effort-ops.sh"
6
+ _cckit_sourced=0
7
+ if [ -n "${ZSH_VERSION:-}" ]; then
8
+ case "${ZSH_EVAL_CONTEXT:-}" in *file*) _cckit_sourced=1 ;; esac
9
+ elif [ "$_cckit_self" != "$0" ]; then
10
+ _cckit_sourced=1
11
+ fi
12
+ # shellcheck source=/dev/null
13
+ if [ "$_cckit_sourced" = 1 ]; then unset _cckit_self _cckit_sourced; . "$_cckit_fwd" "$@"; return $?; fi
14
+ exec bash "$_cckit_fwd" "$@"