@jeiemgi/cckit 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +169 -21
  3. package/README.md +505 -35
  4. package/SECURITY.md +5 -0
  5. package/bin/cckit +189 -20
  6. package/cckit.config.json +1 -1
  7. package/commands/kit-doctor.md +13 -5
  8. package/commands/kit-export-project.md +0 -2
  9. package/commands/kit-export-training.md +6 -9
  10. package/commands/kit-init.md +43 -13
  11. package/commands/kit-routines.md +1 -1
  12. package/commands/kit-update.md +11 -6
  13. package/databases/supabase/guide.html +106 -0
  14. package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
  15. package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
  16. package/databases/supabase.json +70 -0
  17. package/integrations/emil-design-eng.json +41 -0
  18. package/integrations/graft.json +81 -0
  19. package/integrations/impeccable.json +42 -0
  20. package/integrations/integration.schema.json +215 -0
  21. package/integrations/lavish.json +43 -0
  22. package/integrations/mempalace.json +28 -0
  23. package/integrations/mlx-lm.json +32 -0
  24. package/integrations/web-design-guidelines.json +42 -0
  25. package/kit.config.schema.json +183 -5
  26. package/package.json +4 -1
  27. package/profiles/automation.json +7 -1
  28. package/profiles/content.json +10 -2
  29. package/profiles/marketing.json +57 -0
  30. package/profiles/minimal.json +7 -1
  31. package/profiles/research.json +7 -1
  32. package/profiles/software.json +7 -1
  33. package/recipes/nextjs-shadcn.json +49 -0
  34. package/scripts/agent-skills-external.txt +45 -0
  35. package/scripts/agent-skills-lint-test.sh +131 -0
  36. package/scripts/agent-skills-lint.sh +115 -0
  37. package/scripts/agent-template-lint-test.sh +42 -0
  38. package/scripts/agent-template-lint.sh +58 -0
  39. package/scripts/annotate-setup.sh +1 -1
  40. package/scripts/autopilot-run-test.sh +338 -0
  41. package/scripts/autopilot-run.sh +448 -0
  42. package/scripts/autopilot-test.sh +8 -0
  43. package/scripts/autopilot.sh +10 -1
  44. package/scripts/benchmark/benchmark-test.sh +85 -0
  45. package/scripts/benchmark/checkpoint-test.sh +314 -0
  46. package/scripts/benchmark/checkpoint.sh +408 -0
  47. package/scripts/benchmark/lib/model.sh +31 -6
  48. package/scripts/benchmark/report.sh +17 -2
  49. package/scripts/benchmark/run-quality.sh +36 -10
  50. package/scripts/benchmark/verb-timings-test.sh +124 -0
  51. package/scripts/benchmark/verb-timings.sh +149 -0
  52. package/scripts/check.sh +29 -19
  53. package/scripts/content-skills-test.sh +144 -0
  54. package/scripts/copilot-loop-test.sh +25 -0
  55. package/scripts/database-supabase-test.sh +121 -0
  56. package/scripts/docs-marketing-words-test.sh +73 -0
  57. package/scripts/docs-record-tables-test.sh +72 -0
  58. package/scripts/guard-raw-git-ops-test.sh +8 -0
  59. package/scripts/hook-adapter-test.sh +193 -0
  60. package/scripts/init-content-test.sh +225 -0
  61. package/scripts/init-guided-test.sh +474 -0
  62. package/scripts/init-recipes-test.sh +104 -0
  63. package/scripts/init-upgrade-test.sh +341 -2
  64. package/scripts/init.sh +746 -95
  65. package/scripts/instruction-budget-baseline.txt +8 -0
  66. package/scripts/instruction-budget-lint-test.sh +166 -0
  67. package/scripts/instruction-budget-lint.sh +219 -0
  68. package/scripts/integrations-check-test.sh +200 -0
  69. package/scripts/integrations-check.sh +157 -0
  70. package/scripts/kit-add-test.sh +214 -0
  71. package/scripts/kit-add.sh +305 -5
  72. package/scripts/kit-adopt-test.sh +16 -0
  73. package/scripts/kit-adopt.sh +3 -2
  74. package/scripts/kit-digest.sh +2 -2
  75. package/scripts/kit-doctor-test.sh +293 -0
  76. package/scripts/kit-doctor.sh +272 -140
  77. package/scripts/kit-export-project-test.sh +3 -3
  78. package/scripts/kit-remove-test.sh +19 -0
  79. package/scripts/kit-routines.sh +2 -2
  80. package/scripts/kit-self-update.sh +1 -1
  81. package/scripts/kit-version-check-test.sh +4 -0
  82. package/scripts/kit-version-check.sh +4 -2
  83. package/scripts/knowledge-lint.sh +4 -4
  84. package/scripts/leak-fence-test.sh +89 -0
  85. package/scripts/lib/adapter-select-test.sh +136 -0
  86. package/scripts/lib/adapter-select.sh +158 -0
  87. package/scripts/lib/agent-def-test.sh +69 -0
  88. package/scripts/lib/agent-def.sh +106 -0
  89. package/scripts/lib/agent-launch-test.sh +212 -0
  90. package/scripts/lib/agent-launch.sh +335 -0
  91. package/scripts/lib/board-view-test.sh +11 -0
  92. package/scripts/lib/board-view.sh +42 -26
  93. package/scripts/lib/branch-owner-test.sh +26 -0
  94. package/scripts/lib/branch-owner.sh +16 -9
  95. package/scripts/lib/captain-test.sh +105 -0
  96. package/scripts/lib/captain.sh +87 -8
  97. package/scripts/lib/codex-hooks-test.sh +100 -0
  98. package/scripts/lib/codex-hooks.sh +69 -0
  99. package/scripts/lib/commitlint.sh +1 -1
  100. package/scripts/lib/content-kinds-gc-test.sh +88 -0
  101. package/scripts/lib/copilot-test.sh +70 -4
  102. package/scripts/lib/copilot.sh +66 -14
  103. package/scripts/lib/effort-dispatch-test.sh +3 -3
  104. package/scripts/lib/effort-metrics-test.sh +178 -1
  105. package/scripts/lib/effort-metrics.sh +188 -35
  106. package/scripts/lib/effort-ops-test.sh +217 -7
  107. package/scripts/lib/effort-ops.sh +281 -49
  108. package/scripts/lib/effort-parity-test.sh +49 -13
  109. package/scripts/lib/effort-plan-test.sh +337 -0
  110. package/scripts/lib/effort-plan.sh +200 -23
  111. package/scripts/lib/effort-slug.sh +16 -2
  112. package/scripts/lib/effort.sh +67 -12
  113. package/scripts/lib/errors-header-test.sh +1 -1
  114. package/scripts/lib/gh-project-test.sh +35 -1
  115. package/scripts/lib/gh-project.sh +37 -16
  116. package/scripts/lib/gh-rest-test.sh +330 -0
  117. package/scripts/lib/gh-rest.sh +304 -0
  118. package/scripts/lib/hook-refresh.sh +1 -1
  119. package/scripts/lib/init-github.sh +412 -0
  120. package/scripts/lib/init-guide.sh +630 -0
  121. package/scripts/lib/integration-install-test.sh +343 -0
  122. package/scripts/lib/integration-install.sh +257 -0
  123. package/scripts/lib/integrations-test.sh +366 -0
  124. package/scripts/lib/integrations.sh +244 -0
  125. package/scripts/lib/kinds-test.sh +125 -0
  126. package/scripts/lib/kinds.sh +66 -0
  127. package/scripts/lib/kit-brief-test.sh +22 -3
  128. package/scripts/lib/kit-brief.sh +45 -5
  129. package/scripts/lib/kit-config-resolve.sh +2 -2
  130. package/scripts/lib/kit-config-test.sh +64 -1
  131. package/scripts/lib/kit-config.sh +37 -1
  132. package/scripts/lib/kit-events.sh +7 -0
  133. package/scripts/lib/kit-gc-test.sh +173 -1
  134. package/scripts/lib/kit-gc.sh +244 -37
  135. package/scripts/lib/kit-hotfix.sh +216 -0
  136. package/scripts/lib/kit-interview-test.sh +93 -0
  137. package/scripts/lib/kit-interview.sh +117 -8
  138. package/scripts/lib/kit-lib-test.sh +1 -1
  139. package/scripts/lib/kit-lib.sh +3 -3
  140. package/scripts/lib/kit-local.sh +2 -2
  141. package/scripts/lib/kit-manifest.sh +33 -1
  142. package/scripts/lib/kit-profile-test.sh +3 -3
  143. package/scripts/lib/kit-status-test.sh +112 -4
  144. package/scripts/lib/kit-status.sh +246 -16
  145. package/scripts/lib/kit-task-ops-test.sh +37 -0
  146. package/scripts/lib/kit-task-ops.sh +362 -89
  147. package/scripts/lib/kto-hotfix-test.sh +232 -0
  148. package/scripts/lib/kto-task-close-test.sh +83 -0
  149. package/scripts/lib/kto-task-new-test.sh +95 -0
  150. package/scripts/lib/kto-task-pr-merge-test.sh +97 -6
  151. package/scripts/lib/kto-task-pr-test.sh +70 -0
  152. package/scripts/lib/leak-fence.sh +89 -0
  153. package/scripts/lib/light-task-run-test.sh +255 -0
  154. package/scripts/lib/light-task-test.sh +309 -0
  155. package/scripts/lib/light-task.sh +706 -0
  156. package/scripts/lib/next-test.sh +99 -0
  157. package/scripts/lib/next.sh +9 -3
  158. package/scripts/lib/orchestration-runtime-test.sh +72 -0
  159. package/scripts/lib/orchestration-runtime.sh +57 -5
  160. package/scripts/lib/plan-machine-test.sh +15 -2
  161. package/scripts/lib/plan-machine.sh +20 -7
  162. package/scripts/lib/plan-next-test.sh +1 -1
  163. package/scripts/lib/plan-next.sh +4 -4
  164. package/scripts/lib/pr-evidence-test.sh +3 -3
  165. package/scripts/lib/pr-evidence.sh +1 -1
  166. package/scripts/lib/qa-lane-test.sh +626 -0
  167. package/scripts/lib/qa-lane.sh +1357 -0
  168. package/scripts/lib/qa-lanes-test.sh +175 -0
  169. package/scripts/lib/react-detect.sh +1 -1
  170. package/scripts/lib/render-test.sh +1 -1
  171. package/scripts/lib/review-page-test.sh +318 -0
  172. package/scripts/lib/review-page.sh +369 -0
  173. package/scripts/lib/review-stage-test.sh +62 -11
  174. package/scripts/lib/review-stage.sh +42 -60
  175. package/scripts/lib/role-identity-test.sh +65 -0
  176. package/scripts/lib/role-identity.sh +25 -2
  177. package/scripts/lib/secret-guard.sh +3 -3
  178. package/scripts/lib/session-registry-test.sh +111 -0
  179. package/scripts/lib/session-registry.sh +233 -0
  180. package/scripts/lib/stage-receipt-test.sh +14 -1
  181. package/scripts/lib/stage-receipt.sh +13 -8
  182. package/scripts/lib/task-source-file.sh +309 -0
  183. package/scripts/lib/task-source.sh +130 -0
  184. package/scripts/lib/test-env-test.sh +3 -3
  185. package/scripts/lib/test-env.sh +7 -4
  186. package/scripts/lib/upgrade-report-test.sh +120 -0
  187. package/scripts/lib/upgrade-report.sh +138 -0
  188. package/scripts/lib/version-bump.sh +3 -3
  189. package/scripts/lib/wave-result-test.sh +80 -0
  190. package/scripts/lib/wave-result.sh +127 -0
  191. package/scripts/lib/worker-brief-test.sh +5 -0
  192. package/scripts/lib/worker-brief.sh +2 -2
  193. package/scripts/lib/worktree-issue-test.sh +30 -1
  194. package/scripts/lib/worktree-issue.sh +93 -9
  195. package/scripts/lib/worktree-ports-test.sh +57 -4
  196. package/scripts/lib/worktree-start-test.sh +197 -0
  197. package/scripts/lib/worktree-start.sh +169 -32
  198. package/scripts/lib/zsh-safety-test.sh +19 -3
  199. package/scripts/marketing-walkthrough-test.sh +152 -0
  200. package/scripts/night-grant-test.sh +37 -0
  201. package/scripts/night-grant.sh +448 -0
  202. package/scripts/night-run-test.sh +8 -0
  203. package/scripts/night-run.mjs +275 -0
  204. package/scripts/night-run.test.mjs +324 -0
  205. package/scripts/orchestrate-test.sh +190 -0
  206. package/scripts/orchestrate.sh +79 -8
  207. package/scripts/portable-test.sh +11 -2
  208. package/scripts/publish.sh +28 -3
  209. package/scripts/review-lint-test.sh +7 -7
  210. package/scripts/review-lint.sh +2 -2
  211. package/scripts/review-rules.conf +8 -0
  212. package/scripts/rule-recipes-test.sh +96 -0
  213. package/scripts/self-install-test.sh +39 -9
  214. package/scripts/setup-labels.sh +18 -1
  215. package/scripts/setup-milestones.sh +1 -1
  216. package/scripts/showcase.sh +1 -1
  217. package/scripts/skill-frontmatter-lint-test.sh +4 -4
  218. package/scripts/skill-frontmatter-lint.sh +1 -1
  219. package/scripts/status-test.sh +113 -2
  220. package/scripts/status.sh +16 -3
  221. package/scripts/task-sync-test.sh +154 -0
  222. package/scripts/task-sync.sh +243 -32
  223. package/scripts/test-runner-test.sh +158 -0
  224. package/scripts/test.sh +131 -23
  225. package/scripts/update-path-test.sh +279 -0
  226. package/scripts/ux-ds-audit.sh +1 -1
  227. package/scripts/ux-graph-scan.sh +6 -6
  228. package/scripts/wave-worker.sh +54 -0
  229. package/skills/kit-add/SKILL.md +77 -0
  230. package/skills/kit-autopilot/SKILL.md +123 -12
  231. package/skills/kit-cleanup/SKILL.md +5 -2
  232. package/skills/kit-contribute/SKILL.md +4 -4
  233. package/skills/kit-docs-writer/SKILL.md +16 -6
  234. package/skills/kit-effort-close/SKILL.md +17 -8
  235. package/skills/kit-effort-new/SKILL.md +15 -9
  236. package/skills/kit-effort-pr/SKILL.md +15 -7
  237. package/skills/kit-effort-start/SKILL.md +5 -2
  238. package/skills/kit-gc/SKILL.md +5 -2
  239. package/skills/kit-next/SKILL.md +5 -1
  240. package/skills/kit-onboard/SKILL.md +3 -3
  241. package/skills/kit-page/SKILL.md +93 -0
  242. package/skills/kit-plan-next/SKILL.md +8 -4
  243. package/skills/kit-security-sweep/SKILL.md +1 -3
  244. package/skills/kit-ship/SKILL.md +2 -3
  245. package/skills/kit-status/SKILL.md +35 -4
  246. package/skills/kit-task-new/SKILL.md +3 -3
  247. package/skills/kit-task-pr/SKILL.md +7 -2
  248. package/skills/kit-task-pr-merge/SKILL.md +7 -2
  249. package/skills/kit-task-start/SKILL.md +7 -7
  250. package/skills/kit-task-sync/SKILL.md +19 -3
  251. package/skills/kit-ux-audit/SKILL.md +3 -2
  252. package/templates/agents/auto-dev.md +5 -4
  253. package/templates/agents/backend.md +1 -1
  254. package/templates/agents/designer.md +2 -0
  255. package/templates/agents/devops.md +1 -1
  256. package/templates/agents/editor.md +9 -1
  257. package/templates/agents/frontend.md +1 -1
  258. package/templates/agents/local-delegate.md +1 -1
  259. package/templates/agents/pm.md +5 -5
  260. package/templates/agents/tech-lead.md +1 -1
  261. package/templates/benchmarks/SCHEMA.md +9 -3
  262. package/templates/codex/hooks.json.tmpl +89 -0
  263. package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
  264. package/templates/hooks/guard-raw-git-ops.sh.tmpl +27 -14
  265. package/templates/hooks/mempal_followup.sh.tmpl +2 -2
  266. package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
  267. package/templates/hooks/prepush_gate.sh.tmpl +4 -2
  268. package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
  269. package/templates/instructions.md.tmpl +174 -0
  270. package/templates/kit.config.json.tmpl +3 -3
  271. package/templates/knowledge-INDEX.md.tmpl +1 -1
  272. package/templates/lib/kit-sigil.sh.tmpl +1 -1
  273. package/templates/rules/authoring.md +106 -0
  274. package/templates/rules/branch-naming.md +40 -4
  275. package/templates/rules/code-retrieval.md +63 -0
  276. package/templates/rules/delegation-brief.md +0 -3
  277. package/templates/rules/design-routing.md +3 -3
  278. package/templates/rules/effort-model.md +14 -10
  279. package/templates/rules/gate-and-review.md +94 -0
  280. package/templates/rules/issue-lifecycle.md +88 -0
  281. package/templates/rules/knowledge-base.md +1 -1
  282. package/templates/rules/mempalace.md +1 -1
  283. package/templates/rules/merge-safety.md +108 -0
  284. package/templates/rules/naming-and-ids.md +23 -17
  285. package/templates/rules/plain-language.md +59 -0
  286. package/templates/rules/plan-next.md +9 -11
  287. package/templates/rules/react-annotate.md +6 -0
  288. package/templates/rules/review-pages.md +49 -0
  289. package/templates/rules/risk-tiered-review.md +13 -4
  290. package/templates/rules/shared-checkout.md +106 -0
  291. package/templates/rules/skill-gaps.md +2 -7
  292. package/templates/rules/task-management.md +13 -1
  293. package/templates/skills/brand-voice/SKILL.md +91 -0
  294. package/templates/skills/brand-voice/references/voice-template.md +61 -0
  295. package/templates/skills/campaign/SKILL.md +123 -0
  296. package/templates/skills/campaign/references/plan-template.md +55 -0
  297. package/templates/skills/concrete/SKILL.md +2 -2
  298. package/templates/skills/copywriting/SKILL.md +8 -1
  299. package/templates/skills/feature-build-refine/SKILL.md +2 -4
  300. package/templates/skills/morning-briefing/SKILL.md +2 -2
  301. package/templates/skills/page-design/SKILL.md +145 -0
  302. package/templates/skills/page-design/add.json +5 -0
  303. package/templates/skills/page-design/references/design-file-template.md +40 -0
  304. package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
  305. package/templates/skills/page-design/references/minimum-rules.md +42 -0
  306. package/templates/skills/speckit/SKILL.md +4 -5
  307. package/templates/skills/supabase-patterns/SKILL.md +1 -1
  308. package/commands/kit-add.md +0 -42
  309. package/templates/CLAUDE.md.tmpl +0 -106
@@ -98,26 +98,62 @@ tc "$GH_LOG" '## Verification' "bare call still emits ## Verification"
98
98
  tc "$GH_LOG" '<!--' "bare call leaves the template placeholders (nothing to fill)"
99
99
 
100
100
  # ── #121: the ONE shared effort-PR title composer + the mandatory-[#N] check ─────────────────────
101
- t "effort_pr_title composes [#N] name" "$(effort_pr_title 115 'adoption hardening')" "[#115] adoption hardening"
102
- t "effort_pr_title with a role prefix" "$(effort_pr_title 115 'adoption hardening' 'Tech Lead')" "[Tech Lead] [#115] adoption hardening"
103
- t "effort_pr_title peels an [Effort] prefix" "$(effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening')" "[#115] [Core] adoption hardening"
104
- t "effort_pr_title tolerates a #-prefixed num" "$(effort_pr_title '#42' 'x')" "[#42] x"
101
+ # #237: the composed title is a Conventional Commit subject carrying [#N] — the form the
102
+ # commitlint gate accepts — so `effort pr` never opens a PR its own CI rejects.
103
+ # shellcheck source=/dev/null
104
+ source "$LIB/commitlint.sh"
105
+ unset KIT_PR_TITLE_STYLE
106
+ t "effort_pr_title composes type: name [#N]" "$(effort_pr_title 115 'adoption hardening')" "feat: adoption hardening [#115]"
107
+ t "effort_pr_title takes the scope from flow:" "$(effort_pr_title 115 'adoption hardening' 'role:tech-lead,kind:task,flow:core')" "feat(core): adoption hardening [#115]"
108
+ t "effort_pr_title peels [Effort] + uses [Flow] as scope" "$(effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening')" "feat(core): adoption hardening [#115]"
109
+ t "effort_pr_title flow: label wins over the [Flow] tag" "$(effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening' 'flow:docs')" "feat(docs): adoption hardening [#115]"
110
+ t "effort_pr_title drops a tag that is no valid scope" "$(effort_pr_title 115 '[¡Hola!] adoption hardening')" "feat: adoption hardening [#115]"
111
+ t "effort_pr_title tolerates a #-prefixed num" "$(effort_pr_title '#42' 'x')" "feat: x [#42]"
112
+ t "effort_pr_title derives the type from kind:" "$(effort_pr_title 115 'x' 'kind:chore,flow:core')" "chore(core): x [#115]"
113
+ t "effort_pr_title maps a bug label to fix" "$(effort_pr_title 115 'x' 'bug,kind:task')" "fix: x [#115]"
114
+ t "effort_pr_title explicit type wins" "$(effort_pr_title 115 'x' 'kind:chore' fix)" "fix: x [#115]"
115
+ t "effort_pr_title issue-title style keeps [Role] [#N] name" "$(KIT_PR_TITLE_STYLE=issue-title effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening' 'flow:core' '' 'Tech Lead')" "[Tech Lead] [#115] [Core] adoption hardening"
116
+ t "effort_pr_title issue-title style without a role" "$(KIT_PR_TITLE_STYLE=issue-title effort_pr_title 115 'adoption hardening')" "[#115] adoption hardening"
117
+ _t237="$(effort_pr_title 220 '[Effort] 220 · [Core] agents cannot see what cckit provides' 'flow:core,kind:task,role:tech-lead')"
118
+ t "the #237 reproduction composes the conventional form" "$_t237" "feat(core): agents cannot see what cckit provides [#220]"
119
+ commitlint_check "$_t237" 2>/dev/null; t "the generated title passes commitlint_check" "$?" "0"
120
+ effort_pr_title_check "$_t237" 220 2>/dev/null; t "the generated title carries the [#N] id" "$?" "0"
105
121
  effort_pr_title_check "[Tech Lead] [#115] adoption hardening" 115; t "check accepts a title carrying [#N]" "$?" "0"
106
122
  effort_pr_title_check "[Effort] 115 · adoption hardening" 115 2>/dev/null; t "check refuses a title lacking [#N]" "$?" "1"
107
123
  effort_pr_title_check "[#7] anything" 2>/dev/null; t "check accepts any [#N] when no num given" "$?" "0"
108
124
 
109
- # ── #121: --par applies a par:<value> label on the parent; bad values are rejected up front ───────
125
+ # ── #277: --kind picks the kind: label (parent + subs) from the closed set; --par is gone ──────────
126
+ : > "$GH_LOG"; printf '0' > "$GH_N"
127
+ effort_new --flow Core --kind fix "kind fix effort" "a :: x" >/dev/null 2>&1
128
+ tc "$GH_LOG" 'issue create .*--title \[Effort\] · .*--label effort,ctx:[SMLX]+,kind:fix,' "--kind fix labels the parent kind:fix"
129
+ tc "$GH_LOG" 'issue create .*--title \[Effort 1\] 1 · a.*--label kind:fix,' "--kind fix labels every sub kind:fix"
130
+ tc "$GH_LOG" 'label create kind:fix' "--kind ensures the kind label exists"
131
+ tn "$GH_LOG" 'kind:task' "--kind fix leaves no kind:task behind"
110
132
  : > "$GH_LOG"; printf '0' > "$GH_N"
111
- effort_new --flow Core --par wide "parallel wide effort" "a :: x" "b :: y" >/dev/null 2>&1
112
- tc "$GH_LOG" 'issue create .*--label [^ ]*,par:wide' "--par wide adds a par:wide label to the parent"
113
- tc "$GH_LOG" 'label create par:wide' "--par creates the par:wide label idempotently"
133
+ effort_new --kind=chore "kind chore effort" >/dev/null 2>&1
134
+ tc "$GH_LOG" 'issue create .*--label effort,ctx:[SMLX]+,kind:chore,' "--kind=chore (equals form) is accepted"
135
+ for k in $KIT_KINDS; do
136
+ : > "$GH_LOG"; printf '0' > "$GH_N"
137
+ effort_new --kind "$k" "kind vocabulary effort" >/dev/null 2>&1 && rc=0 || rc=1
138
+ t "--kind $k is accepted" "$rc" "0"
139
+ done
140
+ for k in $KIT_CONTENT_KINDS; do
141
+ : > "$GH_LOG"; printf '0' > "$GH_N"
142
+ effort_new --kind "$k" "content kind effort" >/dev/null 2>&1 && rc=0 || rc=1
143
+ t "--kind $k (content kind) is accepted" "$rc" "0"
144
+ tc "$GH_LOG" "issue create .*--label effort,ctx:[SMLX]+,kind:$k," "--kind $k labels the parent kind:$k"
145
+ done
146
+ t "effort_pr_title: a content kind titles as docs" "$(effort_pr_title 115 'spring launch' 'kind:campaign')" "docs: spring launch [#115]"
114
147
  : > "$GH_LOG"; printf '0' > "$GH_N"
115
- effort_new --par 3 "parallel three effort" >/dev/null 2>&1
116
- tc "$GH_LOG" 'issue create .*--label [^ ]*,par:3' "--par 3 adds a par:3 label"
148
+ err="$(effort_new --kind bug "bad kind effort" 2>&1 >/dev/null)" && rc=0 || rc=1
149
+ t "--kind rejects a value outside the closed set" "$rc" "1"
150
+ t "--kind creates nothing on a bad value" "$(grep -c 'issue create' "$GH_LOG")" "0"
151
+ t "the refusal lists the accepted set" "$(printf '%s' "$err" | grep -c "must be one of: $KIT_KINDS")" "1"
117
152
  : > "$GH_LOG"; printf '0' > "$GH_N"
118
- effort_new --par nonsense "bad par effort" >/dev/null 2>&1 && rc=0 || rc=1
119
- t "--par rejects a non seq/wide/int value" "$rc" "1"
120
- t "--par creates nothing on a bad value" "$(grep -c 'issue create' "$GH_LOG")" "0"
153
+ effort_new --par wide "parallel wide effort" >/dev/null 2>&1 && rc=0 || rc=1
154
+ t "--par is no longer a flag (rc 1)" "$rc" "1"
155
+ t "--par creates nothing" "$(grep -c . "$GH_LOG")" "0"
156
+ t "nothing in effort-ops.sh writes a par: label" "$(grep -c 'par:' "$LIB/effort-ops.sh" | tr -d ' ')" "0"
121
157
 
122
158
  # ── #121: flags are position-INDEPENDENT — trailing --flow/--role no longer become junk sub-issues ─
123
159
  : > "$GH_LOG"; printf '0' > "$GH_N"
@@ -0,0 +1,337 @@
1
+ #!/bin/sh
2
+ # effort-plan-test.sh — self-test for effort-plan.sh, in four parts:
3
+ # 1. the ctx weight scale (#277), under bash AND zsh: S=1 M=2 L=4 XL=8; `?` (no ctx: label) weighs
4
+ # 2 and is explained by the plan header, any other value weighs 2 and warns on stderr.
5
+ # 2. the open-effort read and the "next startable effort per flow" pick that `cckit status`
6
+ # prints (E241.4), under bash AND zsh (kit-status.sh reads them in both); `effort_plan` itself
7
+ # is bash-only and gets one bash smoke case.
8
+ # 3. where `cckit effort plan` reads its rows from (#382): the optional local source named by
9
+ # `effort.planSource`, the fallback to GitHub when that source fails or prints nothing, and
10
+ # the `source:` line that says which one the plan was built from.
11
+ # 4. `effort_plan` end to end on the weights: an XL effort fills a session, `?` is legend-explained.
12
+ # Hermetic: every part stubs gh (the effort list as the JSON `gh issue list --json` returns, each
13
+ # effort's blocked_by as the JSON the dependency API returns), so no network is touched.
14
+ # Run: bash scripts/lib/effort-plan-test.sh
15
+ # errors: strict — a test runner: rc 1 on any failed assertion
16
+
17
+ dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
18
+
19
+ if [ -n "${EP_TEST_INNER:-}" ]; then
20
+ fail=0
21
+ eq() { if [ "$2" = "$3" ]; then :; else echo "FAIL($EP_TEST_INNER): $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
22
+ has() { case "$2" in *"$3"*) : ;; *) echo "FAIL($EP_TEST_INNER): $1 -> '$2' lacks '$3'"; fail=1 ;; esac; }
23
+ no() { case "$2" in *"$3"*) echo "FAIL($EP_TEST_INNER): $1 -> '$2' should not contain '$3'"; fail=1 ;; *) : ;; esac; }
24
+
25
+ # shellcheck source=/dev/null
26
+ . "$dir/effort-plan.sh"
27
+
28
+ # ── 1. the ctx weight scale (no gh, no jq) ──────────────────────────────────────────────────
29
+ eq "weight S" "$(_ep_weight S)" "1"
30
+ eq "weight M" "$(_ep_weight M)" "2"
31
+ eq "weight L" "$(_ep_weight L)" "4"
32
+ eq "weight XL" "$(_ep_weight XL)" "8"
33
+ for c in S M L XL; do eq "weight $c is quiet" "$(_ep_weight "$c" 2>&1 >/dev/null)" ""; done
34
+
35
+ # no label at all: weighs the default, silently here — the plan header carries the legend.
36
+ eq "weight ? (unlabeled)" "$(_ep_weight '?' 2>/dev/null)" "2"
37
+ eq "weight ? is quiet" "$(_ep_weight '?' 2>&1 >/dev/null)" ""
38
+ # a value outside the scale: still the default weight, and stderr names the value + the issue.
39
+ eq "weight XXL falls back to 2" "$(_ep_weight XXL 2>/dev/null)" "2"
40
+ has "weight XXL warns" "$(_ep_weight XXL 41 2>&1 >/dev/null)" "ctx:XXL"
41
+ has "the warning names the issue" "$(_ep_weight XXL 41 2>&1 >/dev/null)" "#41"
42
+ has "the warning names the weight used" "$(_ep_weight XXL 41 2>&1 >/dev/null)" "weighed 2"
43
+ has "lowercase xl is not XL" "$(_ep_weight xl 7 2>&1 >/dev/null)" "ctx:xl"
44
+
45
+ command -v jq >/dev/null 2>&1 || { echo " (jq absent — skipping the effort-plan row tests)"; exit "$fail"; }
46
+
47
+ # ── 2. the open-effort read and the next-per-flow pick ──────────────────────────────────────
48
+ tmp="$(mktemp -d)"
49
+ stub="$tmp/bin"; mkdir -p "$stub" "$tmp/deps"
50
+ # Stub gh: `issue list` -> $GH_EFFORTS (a JSON array file); `api …/issues/<N>/dependencies/blocked_by`
51
+ # -> $GH_DEPS/<N>.json, or [] when the effort has no fixture. GH_FAIL=1 fails every call.
52
+ cat > "$stub/gh" <<'SH'
53
+ #!/bin/sh
54
+ [ -z "${GH_FAIL:-}" ] || exit 1
55
+ case "$1 $2" in
56
+ "issue list") cat "$GH_EFFORTS" ;;
57
+ "api repos/"*)
58
+ n="${2%/dependencies/blocked_by}"; n="${n##*/}"
59
+ if [ -f "$GH_DEPS/$n.json" ]; then cat "$GH_DEPS/$n.json"; else echo '[]'; fi ;;
60
+ *) echo '[]' ;;
61
+ esac
62
+ SH
63
+ chmod +x "$stub/gh"
64
+ GH_EFFORTS="$tmp/efforts.json"; GH_DEPS="$tmp/deps"; export GH_EFFORTS GH_DEPS
65
+ PATH="$stub:$PATH"; export PATH
66
+
67
+ col() { awk -F'\t' -v f="$1" -v c="$2" '$1==f{print $c}'; } # col <flow> <column> < next rows
68
+
69
+ # ── two flows, one effort blocked by another OPEN effort in its flow ────────────────────────
70
+ # core: 10 (p1) and 11 (p1, blocked_by OPEN 10). docs: 20 (unlabelled priority).
71
+ cat > "$GH_EFFORTS" <<'JSON'
72
+ [ {"number":20,"title":"[Effort] 20 · [Docs] cadence page","labels":[{"name":"effort"},{"name":"flow:docs"},{"name":"ctx:S"}]},
73
+ {"number":11,"title":"[Effort] 11 · [Core] second thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:L"},{"name":"priority:p1"}]},
74
+ {"number":10,"title":"[Effort] 10 · [Core] first thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:M"},{"name":"priority:p1"}]} ]
75
+ JSON
76
+ echo '[{"number":10,"state":"open"}]' > "$GH_DEPS/11.json"
77
+
78
+ open_rows="$(effort_open_rows o/r)"; rc=$?
79
+ eq "open rows: rc 0" "$rc" "0"
80
+ eq "open rows: one row per open effort" "$(printf '%s\n' "$open_rows" | grep -c .)" "3"
81
+ eq "open rows: seven fields, none blank" "$(printf '%s\n' "$open_rows" | awk -F'\t' 'NF!=7{bad=1} {for(i=1;i<=NF;i++) if($i=="") bad=1} END{print bad+0}')" "0"
82
+ eq "open rows: 11 lists its blocker" "$(printf '%s\n' "$open_rows" | awk -F'\t' '$1==11{print $5"/"$6}')" "10/10"
83
+ eq "open rows: no blocker reads -" "$(printf '%s\n' "$open_rows" | awk -F'\t' '$1==10{print $5"/"$6}')" "-/-"
84
+ eq "open rows: missing priority reads -" "$(printf '%s\n' "$open_rows" | awk -F'\t' '$1==20{print $4}')" "-"
85
+
86
+ rows="$(effort_next_rows o/r)"; rc=$?
87
+ eq "next: rc 0" "$rc" "0"
88
+ eq "next: exactly one row per flow" "$(printf '%s\n' "$rows" | grep -c .)" "2"
89
+ eq "next: flows are sorted" "$(printf '%s\n' "$rows" | cut -f1 | tr '\n' ' ')" "core docs "
90
+ eq "next: core offers the unblocked one" "$(printf '%s\n' "$rows" | col core 2)" "10"
91
+ eq "next: the blocked effort is never named" "$(printf '%s\n' "$rows" | cut -f2 | grep -c '^11$')" "0"
92
+ eq "next: core counts one waiting" "$(printf '%s\n' "$rows" | col core 5)" "1"
93
+ eq "next: docs offers its only effort" "$(printf '%s\n' "$rows" | col docs 2)" "20"
94
+ eq "next: the ctx rides along" "$(printf '%s\n' "$rows" | col core 3)" "M"
95
+ eq "next: title drops the prefix and tag" "$(printf '%s\n' "$rows" | col core 4)" "first thing"
96
+
97
+ # ── a CLOSED blocker does not block ─────────────────────────────────────────────────────────
98
+ # 10 is gone from the open list (closed); 11 still carries the edge, now pointing at a closed issue.
99
+ cat > "$GH_EFFORTS" <<'JSON'
100
+ [ {"number":11,"title":"[Effort] 11 · [Core] second thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:L"}]} ]
101
+ JSON
102
+ echo '[{"number":10,"state":"closed"}]' > "$GH_DEPS/11.json"
103
+ rows="$(effort_next_rows o/r)"
104
+ eq "closed blocker: the effort is startable" "$(printf '%s\n' "$rows" | col core 2)" "11"
105
+ eq "closed blocker: nothing is waiting" "$(printf '%s\n' "$rows" | col core 5)" "0"
106
+ eq "closed blocker: still listed as a blocker" "$(effort_open_rows o/r | cut -f5,6 | tr '\t' '/')" "10/-"
107
+
108
+ # ── an OPEN blocker in ANOTHER flow blocks ──────────────────────────────────────────────────
109
+ # core 11 is blocked_by docs 20 (open). core has no other effort, so the flow reports none startable.
110
+ cat > "$GH_EFFORTS" <<'JSON'
111
+ [ {"number":20,"title":"[Effort] 20 · [Docs] cadence page","labels":[{"name":"effort"},{"name":"flow:docs"},{"name":"ctx:S"}]},
112
+ {"number":11,"title":"[Effort] 11 · [Core] second thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:L"}]} ]
113
+ JSON
114
+ echo '[{"number":20,"state":"open"}]' > "$GH_DEPS/11.json"
115
+ rows="$(effort_next_rows o/r)"
116
+ eq "cross-flow blocker: core keeps its row" "$(printf '%s\n' "$rows" | grep -c '^core')" "1"
117
+ eq "cross-flow blocker: core names no effort" "$(printf '%s\n' "$rows" | col core 2)" "-"
118
+ eq "cross-flow blocker: core counts it waiting" "$(printf '%s\n' "$rows" | col core 5)" "1"
119
+ eq "cross-flow blocker: docs is unaffected" "$(printf '%s\n' "$rows" | col docs 2)" "20"
120
+
121
+ # ── an OPEN blocker that is not an effort at all (a plain issue) blocks too ──────────────────
122
+ echo '[{"number":999,"state":"open"}]' > "$GH_DEPS/11.json"
123
+ eq "plain-issue blocker: core names no effort" "$(effort_next_rows o/r | col core 2)" "-"
124
+ rm -f "$GH_DEPS/11.json"
125
+
126
+ # ── the pick is pure: priority first (p0 → p3, unlabelled last), then the lowest number ──────
127
+ pick() { printf '%b' "$1" | effort_next_pick | cut -f2; }
128
+ eq "pick: p0 beats p2" "$(pick '7\tcore\tM\tp2\t-\t-\ta\n9\tcore\tM\tp0\t-\t-\tb\n')" "9"
129
+ eq "pick: a label beats no label" "$(pick '3\tcore\tM\t-\t-\t-\ta\n9\tcore\tM\tp3\t-\t-\tb\n')" "9"
130
+ eq "pick: a tie takes the lowest number" "$(pick '9\tcore\tM\tp1\t-\t-\ta\n4\tcore\tM\tp1\t-\t-\tb\n')" "4"
131
+ eq "pick: a blocked p0 never outranks a free p3" \
132
+ "$(pick '1\tcore\tM\tp0\t5\t5\ta\n2\tcore\tM\tp3\t-\t-\tb\n')" "2"
133
+ eq "pick: no input, no rows" "$(printf '' | effort_next_pick | grep -c . )" "0"
134
+
135
+ # ── empty and unreadable are different answers ──────────────────────────────────────────────
136
+ echo '[]' > "$GH_EFFORTS"
137
+ rows="$(effort_next_rows o/r)"; rc=$?
138
+ eq "no open effort: rc 0" "$rc" "0"
139
+ eq "no open effort: no rows" "$rows" ""
140
+ rows="$(GH_FAIL=1 effort_next_rows o/r)"; rc=$?
141
+ eq "gh fails: rc is non-zero" "$([ "$rc" -ne 0 ] && echo yes || echo no)" "yes"
142
+ eq "gh fails: no rows" "$rows" ""
143
+ effort_next_rows "" >/dev/null 2>&1; rc=$?
144
+ eq "no repo: rc is non-zero" "$([ "$rc" -ne 0 ] && echo yes || echo no)" "yes"
145
+
146
+ # ── effort_plan (bash-only) still prints its session plan from the shared read ───────────────
147
+ if [ "$EP_TEST_INNER" = "bash" ]; then
148
+ cat > "$GH_EFFORTS" <<'JSON'
149
+ [ {"number":11,"title":"[Effort] 11 · [Core] second thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:L"}]},
150
+ {"number":10,"title":"[Effort] 10 · [Core] first thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:M"}]} ]
151
+ JSON
152
+ echo '[{"number":10,"state":"open"}]' > "$GH_DEPS/11.json"
153
+ plan="$(EFFORT_REPO=o/r effort_plan 2>&1)"; rc=$?
154
+ eq "plan: rc 0" "$rc" "0"
155
+ has "plan: names the flow" "$plan" "Flow: core"
156
+ has "plan: lists the root effort" "$plan" "#10 [M ] first thing"
157
+ has "plan: the dependent shows its blocker" "$plan" "second thing (after #10) → delegate subs"
158
+ eq "plan: the blocker is ordered first" \
159
+ "$(printf '%s\n' "$plan" | grep -E '^ +#1[01] ' | awk '{print $1}' | tr '\n' ' ')" "#10 #11 "
160
+ eq "plan: a blocker and its dependent do not share a session" \
161
+ "$(printf '%s\n' "$plan" | grep -c 'Session ')" "2"
162
+ echo '[]' > "$GH_EFFORTS"
163
+ plan="$(EFFORT_REPO=o/r effort_plan 2>&1)"; rc=$?
164
+ eq "plan: no efforts is rc 0" "$rc" "0"
165
+ has "plan: no efforts says so" "$plan" "no open efforts found"
166
+ plan="$(GH_FAIL=1 EFFORT_REPO=o/r effort_plan 2>&1)"; rc=$?
167
+ eq "plan: a failed query is rc 1" "$rc" "1"
168
+ has "plan: a failed query says so" "$plan" "gh query failed"
169
+ fi
170
+
171
+ rm -rf "$tmp"
172
+ if [ "$fail" -eq 0 ]; then echo "PASS($EP_TEST_INNER): effort-plan rows + next-per-flow pick"; fi
173
+ exit "$fail"
174
+ fi
175
+
176
+ fail=0
177
+ for sh in bash zsh; do
178
+ command -v "$sh" >/dev/null 2>&1 || { echo "skip: $sh not installed"; continue; }
179
+ if EP_TEST_INNER="$sh" "$sh" "$0"; then echo "ok: effort-plan weights + rows under $sh"; else fail=1; fi
180
+ done
181
+
182
+ # ── 3. the plan source (#382) ─────────────────────────────────────────────────────────────────
183
+ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
184
+ LIB="$ROOT/scripts/lib"
185
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
186
+ has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> output lacks '$3'"; echo "$2" | sed 's/^/ | /'; fail=1 ;; esac; }
187
+ lacks() { case "$2" in *"$3"*) echo "FAIL: $1 -> output has '$3'"; fail=1 ;; *) echo "ok: $1" ;; esac; }
188
+
189
+ tmp="$(mktemp -d)"; tmp2=""; trap 'rm -rf "$tmp" "$tmp2"' EXIT
190
+ mkdir -p "$tmp/bin" "$tmp/proj/tools"
191
+ GH_LOG="$tmp/gh.log"
192
+
193
+ # Stub gh: the listing prints the JSON `gh issue list --json number,title,labels` returns; blocked_by
194
+ # answers per issue with the JSON the dependency API returns. Every call is logged.
195
+ cat > "$tmp/bin/gh" <<'STUB'
196
+ #!/usr/bin/env bash
197
+ echo "gh $*" >> "$GH_LOG"
198
+ case "$1 $2" in
199
+ "issue list") cat <<'JSON'
200
+ [ {"number":11,"title":"[Effort] 11 · [Core] gh root","labels":[{"name":"effort"},{"name":"flow:Core"},{"name":"ctx:S"}]},
201
+ {"number":12,"title":"[Effort] 12 · [Core] gh leaf","labels":[{"name":"effort"},{"name":"flow:Core"},{"name":"ctx:M"}]} ]
202
+ JSON
203
+ ;;
204
+ "api "*) case "$2" in */issues/12/dependencies/blocked_by) echo '[{"number":11,"state":"open"}]' ;; *) echo '[]' ;; esac ;;
205
+ esac
206
+ STUB
207
+ chmod +x "$tmp/bin/gh"
208
+
209
+ mk() { printf '%s\n' "$2" > "$tmp/proj/tools/$1"; chmod +x "$tmp/proj/tools/$1"; }
210
+ mk good.sh '#!/usr/bin/env bash
211
+ echo "# age: 2h"
212
+ printf "21\tDocs\tL\t[Effort] 21 · [Docs] stub root\n"
213
+ printf "22\tDocs\tS\t[Effort] 22 · [Docs] stub leaf\t21\n"'
214
+ mk noage.sh '#!/usr/bin/env bash
215
+ printf "31\tDocs\tS\tstub only\n"'
216
+ mk fail.sh '#!/usr/bin/env bash
217
+ printf "41\tDocs\tS\tshould not appear\n"
218
+ exit 3'
219
+ mk empty.sh '#!/usr/bin/env bash
220
+ exit 0'
221
+ mk args.sh '#!/usr/bin/env bash
222
+ printf "51\tDocs\tS\trepo=%s cwd=%s\n" "$1" "$(basename "$PWD")"'
223
+ mk blank.sh '#!/usr/bin/env bash
224
+ printf "61\t\t\tempty flow and ctx\t\n"'
225
+ printf '{"github":{"repo":"o/r"},"effort":{"planSource":"tools/good.sh"}}' > "$tmp/proj/cckit.config.json"
226
+
227
+ # plan [VAR=value …] — run effort_plan in a clean shell; stdout+stderr captured together.
228
+ plan() {
229
+ : > "$GH_LOG"
230
+ ( cd "$tmp/proj" && env -u KIT_CONFIG -u EFFORT_PLAN_SOURCE -u KIT_EFFORT_PLAN_SOURCE \
231
+ PATH="$tmp/bin:$PATH" GH_LOG="$GH_LOG" EFFORT_REPO="o/r" "$@" \
232
+ bash -c "source '$LIB/config-path.sh'; source '$LIB/effort-plan.sh'; effort_plan" 2>&1 )
233
+ }
234
+ # Count calls (one logged line each).
235
+ gh_calls() { grep -c '^gh ' "$GH_LOG" | tr -d ' '; }
236
+
237
+ # ── 1. a working local source: its rows, its blockers, no gh, source + age named ───────────────
238
+ out="$(plan KIT_EFFORT_PLAN_SOURCE=tools/good.sh)"
239
+ has "stub rows are planned" "$out" "#21 "
240
+ has "stub second row is planned" "$out" "stub leaf"
241
+ has "stub blockers are honored" "$out" "(after #21)"
242
+ lacks "GitHub rows are absent" "$out" "gh root"
243
+ t "gh is never called" "$(gh_calls)" "0"
244
+ has "output names the stub as source" "$out" "source: planSource tools/good.sh"
245
+ has "output carries the reported age" "$out" "age 2h"
246
+ # the blocker forces a second session even though L(4)+S(1) alone would already overflow budget 4;
247
+ # prove ordering instead: the blocker is listed before its dependent.
248
+ t "blocker is ordered before its dependent" \
249
+ "$(printf '%s\n' "$out" | grep -oE '#2[12] ' | tr -d '\n')" "#21 #22 "
250
+
251
+ out="$(plan KIT_EFFORT_PLAN_SOURCE=tools/noage.sh)"
252
+ has "a source with no age is still named" "$out" "source: planSource tools/noage.sh"
253
+ lacks "no age is invented" "$out" "age "
254
+
255
+ out="$(plan EFFORT_PLAN_SOURCE=tools/noage.sh KIT_EFFORT_PLAN_SOURCE=tools/good.sh)"
256
+ has "EFFORT_PLAN_SOURCE wins over the config value" "$out" "source: planSource tools/noage.sh"
257
+
258
+ out="$(plan KIT_EFFORT_PLAN_SOURCE="$tmp/proj/tools/args.sh")"
259
+ has "source receives the repo as \$1" "$out" "repo=o/r"
260
+ has "relative source runs from the project root" "$out" "cwd=proj"
261
+
262
+ out="$(plan KIT_EFFORT_PLAN_SOURCE=tools/blank.sh)"
263
+ has "empty flow and ctx columns keep the title in place" "$out" "empty flow and ctx"
264
+ has "empty ctx renders as unknown" "$out" "[? ]"
265
+
266
+ # ── 2. a source that fails, prints nothing, or is not executable falls back to GitHub ──────────
267
+ out="$(plan KIT_EFFORT_PLAN_SOURCE=tools/fail.sh)"
268
+ has "failing source: GitHub rows planned" "$out" "gh root"
269
+ has "failing source: GitHub blockers kept" "$out" "(after #11)"
270
+ lacks "failing source: its rows are dropped" "$out" "should not appear"
271
+ has "failing source: GitHub named" "$out" "source: GitHub (o/r)"
272
+ has "failing source: the fallback is said" "$out" "planSource tools/fail.sh failed (exit 3)"
273
+
274
+ out="$(plan KIT_EFFORT_PLAN_SOURCE=tools/empty.sh)"
275
+ has "empty source: GitHub rows planned" "$out" "gh root"
276
+ has "empty source: GitHub named" "$out" "source: GitHub (o/r)"
277
+ has "empty source: the fallback is said" "$out" "planSource tools/empty.sh printed no rows"
278
+
279
+ out="$(plan KIT_EFFORT_PLAN_SOURCE=tools/missing.sh)"
280
+ has "missing source: GitHub rows planned" "$out" "gh root"
281
+ has "missing source: the fallback is said" "$out" "planSource tools/missing.sh is not executable"
282
+
283
+ # ── 3. planSource unset: the GitHub plan, with the source named and no fallback note ───────────
284
+ out="$(plan)"
285
+ has "unset: GitHub rows planned" "$out" "gh leaf"
286
+ has "unset: GitHub named" "$out" "source: GitHub (o/r)"
287
+ lacks "unset: no fallback note" "$out" "planSource"
288
+ t "unset: one listing + one blocked_by call per effort" "$(gh_calls)" "3"
289
+
290
+ # ── 4. load_kit_config exports the key; the exported value drives the plan end to end ──────────
291
+ if command -v jq >/dev/null 2>&1; then
292
+ out="$( : > "$GH_LOG"; cd "$tmp/proj" && env -u KIT_CONFIG -u EFFORT_PLAN_SOURCE -u KIT_EFFORT_PLAN_SOURCE -u EFFORT_REPO \
293
+ PATH="$tmp/bin:$PATH" GH_LOG="$GH_LOG" \
294
+ bash -c "source '$LIB/kit-config.sh'; load_kit_config >/dev/null 2>&1; source '$LIB/effort-plan.sh'; effort_plan" 2>&1 )"
295
+ has "config key effort.planSource reaches the plan" "$out" "source: planSource tools/good.sh"
296
+ t "config-driven local plan calls no gh" "$(gh_calls)" "0"
297
+ fi
298
+
299
+ # ── 4. effort_plan end to end on the weights (#277) ───────────────────────────────────────────
300
+ # effort_plan end to end against a stub gh: an XL effort fills a session of its own (weight 8, not
301
+ # 2), and an effort with no ctx: label shows as `?` with the header saying what `?` weighs.
302
+ if command -v jq >/dev/null 2>&1 && command -v bash >/dev/null 2>&1; then
303
+ tmp2="$(mktemp -d)"
304
+ mkdir -p "$tmp2/bin"
305
+ cat > "$tmp2/bin/gh" <<'SH'
306
+ #!/bin/sh
307
+ case "$1 $2" in
308
+ "issue list") cat <<'JSON'
309
+ [ {"number":1,"title":"[Effort] 1 · big one","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:XL"}]},
310
+ {"number":2,"title":"[Effort] 2 · unsized one","labels":[{"name":"effort"},{"name":"flow:core"}]},
311
+ {"number":3,"title":"[Effort] 3 · small one","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:S"}]} ]
312
+ JSON
313
+ ;;
314
+ *) echo '[]' ;;
315
+ esac
316
+ SH
317
+ chmod +x "$tmp2/bin/gh"
318
+ out="$(PATH="$tmp2/bin:$PATH" KIT_REPO=o/r EFFORT_REPO=o/r KIT_SESSION_BUDGET=4 \
319
+ bash -c ". '$dir/effort-plan.sh'; effort_plan" 2>&1)"
320
+ chk() { if [ -n "$(printf '%s\n' "$out" | grep -E "$2")" ]; then echo "ok: $1"; else echo "FAIL: $1 (no /$2/ in plan output)"; fail=1; fi; }
321
+ chk "the header explains the unlabeled weight" '\? = no ctx: label, weighed 2'
322
+ chk "an unlabeled effort renders as ?" '#2 +\[\? \] unsized one'
323
+ chk "an XL effort is flagged to delegate" '#1 +\[XL\] big one.*delegate subs'
324
+ # XL (8) overflows the budget of 4 on its own, so the ? effort (2) opens Session 2 — were XL
325
+ # weighed 2, XL + ? would share Session 1 and the S effort would open Session 2.
326
+ t_sess="$(printf '%s\n' "$out" | awk '/Session/{s=$2} /#2 /{print s}' | tr -d ':')"
327
+ if [ "$t_sess" = "2" ]; then echo "ok: XL weighs a whole session (next effort opens Session 2)"
328
+ else echo "FAIL: effort after an XL landed in Session '[$t_sess]', want '[2]'"; fail=1; fi
329
+ s3="$(printf '%s\n' "$out" | awk '/Session/{s=$2} /#3 /{print s}' | tr -d ':')"
330
+ if [ "$s3" = "2" ]; then echo "ok: ? (2) + S (1) share Session 2"
331
+ else echo "FAIL: S effort landed in Session '[$s3]', want '[2]'"; fail=1; fi
332
+ else
333
+ echo "skip: jq/bash missing — effort_plan run not exercised"
334
+ fi
335
+
336
+ [ "$fail" -eq 0 ] && echo "ALL OK (effort-plan)" || echo "effort-plan: FAILURES"
337
+ exit "$fail"