@jeiemgi/cckit 0.9.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 (305) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +169 -21
  3. package/README.md +491 -35
  4. package/SECURITY.md +5 -0
  5. package/bin/cckit +182 -17
  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/hook-adapter-test.sh +193 -0
  59. package/scripts/init-content-test.sh +225 -0
  60. package/scripts/init-guided-test.sh +474 -0
  61. package/scripts/init-recipes-test.sh +104 -0
  62. package/scripts/init-upgrade-test.sh +341 -2
  63. package/scripts/init.sh +746 -95
  64. package/scripts/instruction-budget-baseline.txt +8 -0
  65. package/scripts/instruction-budget-lint-test.sh +166 -0
  66. package/scripts/instruction-budget-lint.sh +219 -0
  67. package/scripts/integrations-check-test.sh +200 -0
  68. package/scripts/integrations-check.sh +157 -0
  69. package/scripts/kit-add-test.sh +214 -0
  70. package/scripts/kit-add.sh +305 -5
  71. package/scripts/kit-adopt-test.sh +16 -0
  72. package/scripts/kit-adopt.sh +3 -2
  73. package/scripts/kit-digest.sh +2 -2
  74. package/scripts/kit-doctor-test.sh +293 -0
  75. package/scripts/kit-doctor.sh +272 -140
  76. package/scripts/kit-export-project-test.sh +3 -3
  77. package/scripts/kit-remove-test.sh +19 -0
  78. package/scripts/kit-routines.sh +2 -2
  79. package/scripts/kit-self-update.sh +1 -1
  80. package/scripts/kit-version-check-test.sh +4 -0
  81. package/scripts/kit-version-check.sh +4 -2
  82. package/scripts/knowledge-lint.sh +4 -4
  83. package/scripts/leak-fence-test.sh +89 -0
  84. package/scripts/lib/adapter-select-test.sh +136 -0
  85. package/scripts/lib/adapter-select.sh +158 -0
  86. package/scripts/lib/agent-def-test.sh +69 -0
  87. package/scripts/lib/agent-def.sh +106 -0
  88. package/scripts/lib/agent-launch-test.sh +212 -0
  89. package/scripts/lib/agent-launch.sh +335 -0
  90. package/scripts/lib/board-view-test.sh +11 -0
  91. package/scripts/lib/board-view.sh +42 -26
  92. package/scripts/lib/branch-owner-test.sh +26 -0
  93. package/scripts/lib/branch-owner.sh +16 -9
  94. package/scripts/lib/captain-test.sh +105 -0
  95. package/scripts/lib/captain.sh +87 -8
  96. package/scripts/lib/codex-hooks-test.sh +100 -0
  97. package/scripts/lib/codex-hooks.sh +69 -0
  98. package/scripts/lib/commitlint.sh +1 -1
  99. package/scripts/lib/content-kinds-gc-test.sh +88 -0
  100. package/scripts/lib/copilot-test.sh +70 -4
  101. package/scripts/lib/copilot.sh +66 -14
  102. package/scripts/lib/effort-dispatch-test.sh +3 -3
  103. package/scripts/lib/effort-metrics-test.sh +178 -1
  104. package/scripts/lib/effort-metrics.sh +175 -35
  105. package/scripts/lib/effort-ops-test.sh +205 -7
  106. package/scripts/lib/effort-ops.sh +198 -43
  107. package/scripts/lib/effort-parity-test.sh +49 -13
  108. package/scripts/lib/effort-plan-test.sh +337 -0
  109. package/scripts/lib/effort-plan.sh +200 -23
  110. package/scripts/lib/effort.sh +56 -11
  111. package/scripts/lib/errors-header-test.sh +1 -1
  112. package/scripts/lib/gh-project-test.sh +35 -1
  113. package/scripts/lib/gh-project.sh +23 -16
  114. package/scripts/lib/gh-rest-test.sh +32 -3
  115. package/scripts/lib/gh-rest.sh +17 -2
  116. package/scripts/lib/hook-refresh.sh +1 -1
  117. package/scripts/lib/init-github.sh +412 -0
  118. package/scripts/lib/init-guide.sh +630 -0
  119. package/scripts/lib/integration-install-test.sh +343 -0
  120. package/scripts/lib/integration-install.sh +257 -0
  121. package/scripts/lib/integrations-test.sh +366 -0
  122. package/scripts/lib/integrations.sh +244 -0
  123. package/scripts/lib/kinds-test.sh +125 -0
  124. package/scripts/lib/kinds.sh +66 -0
  125. package/scripts/lib/kit-brief-test.sh +22 -3
  126. package/scripts/lib/kit-brief.sh +45 -5
  127. package/scripts/lib/kit-config-resolve.sh +2 -2
  128. package/scripts/lib/kit-config-test.sh +64 -1
  129. package/scripts/lib/kit-config.sh +37 -1
  130. package/scripts/lib/kit-events.sh +7 -0
  131. package/scripts/lib/kit-gc-test.sh +173 -1
  132. package/scripts/lib/kit-gc.sh +226 -37
  133. package/scripts/lib/kit-hotfix.sh +216 -0
  134. package/scripts/lib/kit-interview-test.sh +93 -0
  135. package/scripts/lib/kit-interview.sh +117 -8
  136. package/scripts/lib/kit-lib-test.sh +1 -1
  137. package/scripts/lib/kit-lib.sh +3 -3
  138. package/scripts/lib/kit-local.sh +2 -2
  139. package/scripts/lib/kit-manifest.sh +33 -1
  140. package/scripts/lib/kit-profile-test.sh +3 -3
  141. package/scripts/lib/kit-status-test.sh +112 -4
  142. package/scripts/lib/kit-status.sh +246 -16
  143. package/scripts/lib/kit-task-ops-test.sh +37 -0
  144. package/scripts/lib/kit-task-ops.sh +175 -31
  145. package/scripts/lib/kto-hotfix-test.sh +232 -0
  146. package/scripts/lib/kto-task-close-test.sh +1 -1
  147. package/scripts/lib/kto-task-new-test.sh +95 -0
  148. package/scripts/lib/kto-task-pr-merge-test.sh +37 -3
  149. package/scripts/lib/kto-task-pr-test.sh +70 -0
  150. package/scripts/lib/leak-fence.sh +89 -0
  151. package/scripts/lib/light-task-run-test.sh +255 -0
  152. package/scripts/lib/light-task-test.sh +309 -0
  153. package/scripts/lib/light-task.sh +706 -0
  154. package/scripts/lib/next-test.sh +99 -0
  155. package/scripts/lib/next.sh +9 -3
  156. package/scripts/lib/orchestration-runtime-test.sh +72 -0
  157. package/scripts/lib/orchestration-runtime.sh +57 -5
  158. package/scripts/lib/plan-machine-test.sh +15 -2
  159. package/scripts/lib/plan-machine.sh +20 -7
  160. package/scripts/lib/plan-next-test.sh +1 -1
  161. package/scripts/lib/plan-next.sh +4 -4
  162. package/scripts/lib/pr-evidence-test.sh +3 -3
  163. package/scripts/lib/pr-evidence.sh +1 -1
  164. package/scripts/lib/qa-lane-test.sh +626 -0
  165. package/scripts/lib/qa-lane.sh +1357 -0
  166. package/scripts/lib/qa-lanes-test.sh +175 -0
  167. package/scripts/lib/react-detect.sh +1 -1
  168. package/scripts/lib/render-test.sh +1 -1
  169. package/scripts/lib/review-page-test.sh +318 -0
  170. package/scripts/lib/review-page.sh +369 -0
  171. package/scripts/lib/review-stage-test.sh +62 -11
  172. package/scripts/lib/review-stage.sh +42 -60
  173. package/scripts/lib/role-identity-test.sh +65 -0
  174. package/scripts/lib/role-identity.sh +25 -2
  175. package/scripts/lib/secret-guard.sh +3 -3
  176. package/scripts/lib/session-registry-test.sh +111 -0
  177. package/scripts/lib/session-registry.sh +233 -0
  178. package/scripts/lib/stage-receipt-test.sh +14 -1
  179. package/scripts/lib/stage-receipt.sh +13 -8
  180. package/scripts/lib/task-source-file.sh +309 -0
  181. package/scripts/lib/task-source.sh +130 -0
  182. package/scripts/lib/upgrade-report-test.sh +120 -0
  183. package/scripts/lib/upgrade-report.sh +138 -0
  184. package/scripts/lib/version-bump.sh +3 -3
  185. package/scripts/lib/wave-result-test.sh +80 -0
  186. package/scripts/lib/wave-result.sh +127 -0
  187. package/scripts/lib/worker-brief-test.sh +5 -0
  188. package/scripts/lib/worker-brief.sh +2 -2
  189. package/scripts/lib/worktree-issue-test.sh +30 -1
  190. package/scripts/lib/worktree-issue.sh +82 -12
  191. package/scripts/lib/worktree-ports-test.sh +57 -4
  192. package/scripts/lib/worktree-start-test.sh +197 -0
  193. package/scripts/lib/worktree-start.sh +153 -31
  194. package/scripts/lib/zsh-safety-test.sh +19 -3
  195. package/scripts/marketing-walkthrough-test.sh +152 -0
  196. package/scripts/night-grant-test.sh +37 -0
  197. package/scripts/night-grant.sh +448 -0
  198. package/scripts/night-run-test.sh +8 -0
  199. package/scripts/night-run.mjs +275 -0
  200. package/scripts/night-run.test.mjs +324 -0
  201. package/scripts/orchestrate-test.sh +190 -0
  202. package/scripts/orchestrate.sh +79 -8
  203. package/scripts/portable-test.sh +11 -2
  204. package/scripts/publish.sh +28 -3
  205. package/scripts/review-lint-test.sh +7 -7
  206. package/scripts/review-lint.sh +2 -2
  207. package/scripts/review-rules.conf +8 -0
  208. package/scripts/rule-recipes-test.sh +96 -0
  209. package/scripts/self-install-test.sh +39 -9
  210. package/scripts/setup-labels.sh +18 -1
  211. package/scripts/setup-milestones.sh +1 -1
  212. package/scripts/showcase.sh +1 -1
  213. package/scripts/skill-frontmatter-lint-test.sh +4 -4
  214. package/scripts/skill-frontmatter-lint.sh +1 -1
  215. package/scripts/status-test.sh +113 -2
  216. package/scripts/status.sh +16 -3
  217. package/scripts/task-sync-test.sh +154 -0
  218. package/scripts/task-sync.sh +243 -32
  219. package/scripts/test-runner-test.sh +158 -0
  220. package/scripts/test.sh +131 -23
  221. package/scripts/update-path-test.sh +279 -0
  222. package/scripts/ux-ds-audit.sh +1 -1
  223. package/scripts/ux-graph-scan.sh +6 -6
  224. package/scripts/wave-worker.sh +54 -0
  225. package/skills/kit-add/SKILL.md +77 -0
  226. package/skills/kit-autopilot/SKILL.md +123 -12
  227. package/skills/kit-cleanup/SKILL.md +5 -2
  228. package/skills/kit-contribute/SKILL.md +4 -4
  229. package/skills/kit-docs-writer/SKILL.md +16 -6
  230. package/skills/kit-effort-close/SKILL.md +17 -8
  231. package/skills/kit-effort-new/SKILL.md +15 -9
  232. package/skills/kit-effort-pr/SKILL.md +15 -7
  233. package/skills/kit-effort-start/SKILL.md +5 -2
  234. package/skills/kit-gc/SKILL.md +5 -2
  235. package/skills/kit-next/SKILL.md +5 -1
  236. package/skills/kit-onboard/SKILL.md +3 -3
  237. package/skills/kit-page/SKILL.md +93 -0
  238. package/skills/kit-plan-next/SKILL.md +8 -4
  239. package/skills/kit-security-sweep/SKILL.md +1 -3
  240. package/skills/kit-ship/SKILL.md +2 -3
  241. package/skills/kit-status/SKILL.md +35 -4
  242. package/skills/kit-task-new/SKILL.md +3 -3
  243. package/skills/kit-task-pr/SKILL.md +7 -2
  244. package/skills/kit-task-pr-merge/SKILL.md +7 -2
  245. package/skills/kit-task-start/SKILL.md +7 -7
  246. package/skills/kit-task-sync/SKILL.md +19 -3
  247. package/skills/kit-ux-audit/SKILL.md +3 -2
  248. package/templates/agents/auto-dev.md +5 -4
  249. package/templates/agents/backend.md +1 -1
  250. package/templates/agents/designer.md +2 -0
  251. package/templates/agents/devops.md +1 -1
  252. package/templates/agents/editor.md +9 -1
  253. package/templates/agents/frontend.md +1 -1
  254. package/templates/agents/local-delegate.md +1 -1
  255. package/templates/agents/pm.md +5 -5
  256. package/templates/agents/tech-lead.md +1 -1
  257. package/templates/benchmarks/SCHEMA.md +9 -3
  258. package/templates/codex/hooks.json.tmpl +89 -0
  259. package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
  260. package/templates/hooks/guard-raw-git-ops.sh.tmpl +12 -12
  261. package/templates/hooks/mempal_followup.sh.tmpl +2 -2
  262. package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
  263. package/templates/hooks/prepush_gate.sh.tmpl +4 -2
  264. package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
  265. package/templates/instructions.md.tmpl +174 -0
  266. package/templates/kit.config.json.tmpl +3 -3
  267. package/templates/knowledge-INDEX.md.tmpl +1 -1
  268. package/templates/lib/kit-sigil.sh.tmpl +1 -1
  269. package/templates/rules/authoring.md +106 -0
  270. package/templates/rules/branch-naming.md +40 -4
  271. package/templates/rules/code-retrieval.md +63 -0
  272. package/templates/rules/delegation-brief.md +0 -3
  273. package/templates/rules/design-routing.md +3 -3
  274. package/templates/rules/effort-model.md +14 -10
  275. package/templates/rules/gate-and-review.md +94 -0
  276. package/templates/rules/issue-lifecycle.md +88 -0
  277. package/templates/rules/knowledge-base.md +1 -1
  278. package/templates/rules/mempalace.md +1 -1
  279. package/templates/rules/merge-safety.md +108 -0
  280. package/templates/rules/naming-and-ids.md +23 -17
  281. package/templates/rules/plain-language.md +59 -0
  282. package/templates/rules/plan-next.md +9 -11
  283. package/templates/rules/react-annotate.md +6 -0
  284. package/templates/rules/review-pages.md +49 -0
  285. package/templates/rules/risk-tiered-review.md +13 -4
  286. package/templates/rules/shared-checkout.md +106 -0
  287. package/templates/rules/skill-gaps.md +2 -7
  288. package/templates/rules/task-management.md +13 -1
  289. package/templates/skills/brand-voice/SKILL.md +91 -0
  290. package/templates/skills/brand-voice/references/voice-template.md +61 -0
  291. package/templates/skills/campaign/SKILL.md +123 -0
  292. package/templates/skills/campaign/references/plan-template.md +55 -0
  293. package/templates/skills/concrete/SKILL.md +2 -2
  294. package/templates/skills/copywriting/SKILL.md +8 -1
  295. package/templates/skills/feature-build-refine/SKILL.md +2 -4
  296. package/templates/skills/morning-briefing/SKILL.md +2 -2
  297. package/templates/skills/page-design/SKILL.md +145 -0
  298. package/templates/skills/page-design/add.json +5 -0
  299. package/templates/skills/page-design/references/design-file-template.md +40 -0
  300. package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
  301. package/templates/skills/page-design/references/minimum-rules.md +42 -0
  302. package/templates/skills/speckit/SKILL.md +4 -5
  303. package/templates/skills/supabase-patterns/SKILL.md +1 -1
  304. package/commands/kit-add.md +0 -42
  305. package/templates/CLAUDE.md.tmpl +0 -106
@@ -30,11 +30,22 @@ bad() { echo "FAIL: $*"; fail=1; }
30
30
  INSTALLED_SKILLS='concrete verbatim
31
31
  karpathy-guidelines verbatim'
32
32
 
33
- INSTALLED_RULES='branch-naming verbatim
33
+ INSTALLED_RULES='authoring verbatim
34
+ branch-naming verbatim
34
35
  communication-style rendered
35
36
  delegation-brief sections
36
37
  effort-model rendered
37
- naming-and-ids verbatim'
38
+ issue-lifecycle rendered
39
+ merge-safety rendered
40
+ naming-and-ids verbatim
41
+ review-pages verbatim
42
+ shared-checkout rendered'
43
+
44
+ # INSTALLED_HOOKS: the hook scripts under .claude/hooks/, same "<name> <mode>" form. A hook cckit
45
+ # runs straight from templates/hooks/ (guard-raw-git-ops, wired by path in .claude/settings.json) has
46
+ # no installed copy and so nothing to drift; it is not listed. The other hook templates are wired by
47
+ # `cckit init` into consuming projects and were never installed here.
48
+ INSTALLED_HOOKS='kit-mail-check verbatim'
38
49
 
39
50
  # The kit-owned sections of delegation-brief.md — the transferable instruction `cckit brief` lifts.
40
51
  # Project-specific sections ("Project specifics", "Gate commands") are filled in for cckit and are
@@ -44,13 +55,19 @@ Durable prose
44
55
  Effort flow'
45
56
 
46
57
  # SKIPPED_*: "<name> :: <reason>". Every skip is a decision on the record, not an omission.
47
- SKIPPED_SKILLS='copywriting :: not declared by any profile cckit uses (content profile only); cckit ships no marketing copy
58
+ SKIPPED_SKILLS='campaign :: plans a marketing campaign from brand/voice.md; cckit plans its work as efforts through skills/kit-effort-new and has no campaign to run
59
+ brand-voice :: records a brand voice in brand/voice.md for copywriting to read; cckit has no brand file and does not install copywriting, its reader
60
+ copywriting :: not declared by any profile cckit uses (content profile only); cckit ships no marketing copy
48
61
  feature-build-refine :: stack-gated on a @refinedev/* dependency; cckit has no package.json dependencies at all
62
+ page-design :: coordinates three third-party design skills for a page built through `cckit task run`; cckit is a bash CLI whose one site (docs-site/) is written by hand, has no light task list and installs none of the three skills
49
63
  morning-briefing :: reads .claude/kit.config.json, which this repo does not have, and cckit answers the same question with `cckit status` + skills/kit-status
50
64
  speckit :: the software profile ships it with defaults.speckit = "off", so init would not install it either
51
65
  supabase-patterns :: cckit has no Supabase; the only matches for "supabase" in the repo are the kit machinery that scaffolds this skill'
52
66
 
53
- SKIPPED_RULES='design-routing :: routes every design question to .claude/agents/designer/AGENT.md; cckit installs no agents, so the rule would dereference a path that does not exist
67
+ SKIPPED_RULES='plain-language :: follows plainLanguage.enabled, which cckit.config.json does not set; its reader is a person who does not use git, and cckit is developed by people who do
68
+ code-retrieval :: in no profile; `cckit add graft` writes it per-project, and graft has no shell grammar, so on cckit (bash, plus docs-site/) the integration does not index the code the rule would route
69
+ design-routing :: routes every design question to .claude/agents/designer/AGENT.md; cckit installs no agents, so the rule would dereference a path that does not exist
70
+ gate-and-review :: both enforcement surfaces it names are off here — prePush is null in cckit.config.json and templates/hooks/prepush_gate.sh.tmpl reads .claude/kit.config.json, a file this repo does not have; review.command is unset. The gate for cckit is stated in delegation-brief.md § Gate commands
54
71
  knowledge-base :: governs a knowledge/ dir with status/owner/updated frontmatter and a knowledge/INDEX.md manifest; cckit knowledge.dir is docs-site/src/content/docs, Starlight title/description frontmatter, no INDEX.md
55
72
  mempalace :: memory.enabled is false in cckit.config.json, so init.sh own rules loop skips this rule for this config
56
73
  plan-next :: not in profiles/software.json; it describes the cckit plan-next verb rather than governing work, and its See-also links point at plan-output-format.md, which cckit does not install
@@ -108,6 +125,10 @@ t "installed skills == the manifest" "$(printf '%s\n' "$inst_skills" | tr '\n' '
108
125
  "$(_names "$INSTALLED_SKILLS" | tr '\n' ' ')"
109
126
  t "installed rules == the manifest" "$(printf '%s\n' "$inst_rules" | tr '\n' ' ')" \
110
127
  "$(_names "$INSTALLED_RULES" | tr '\n' ' ')"
128
+ inst_hooks="$(find .claude/hooks -maxdepth 1 -type f -name '*.sh' 2>/dev/null \
129
+ | while IFS= read -r f; do b="$(basename "$f")"; echo "${b%.sh}"; done | sort)"
130
+ t "installed hooks == the manifest" "$(printf '%s\n' "$inst_hooks" | tr '\n' ' ')" \
131
+ "$(_names "$INSTALLED_HOOKS" | tr '\n' ' ')"
111
132
 
112
133
  # ── 3. content: the installed copy has not drifted from its template ───────────────────────────
113
134
  # `jq` is REQUIRED here, not optional. A drift guard that skips its content comparison when a tool
@@ -194,6 +215,15 @@ done <<EOF
194
215
  $(printf '%s\n' "$INSTALLED_RULES" | grep .)
195
216
  EOF
196
217
 
218
+ # The session-mail hook is one script for every project and both adapters (E257.5): cckit's own copy
219
+ # must be the template byte for byte, or this repo runs a different mail hook than it ships.
220
+ while IFS=' ' read -r name mode; do
221
+ [ -n "$name" ] || continue
222
+ _compare "hooks/$name" "templates/hooks/$name.sh.tmpl" ".claude/hooks/$name.sh" "$mode"
223
+ done <<EOF
224
+ $(printf '%s\n' "$INSTALLED_HOOKS" | grep .)
225
+ EOF
226
+
197
227
  # ── 4. the mandate chain the issue is about actually connects ──────────────────────────────────
198
228
  # communication-style mandates the pass · the brief carries it into a delegated agent · the skill
199
229
  # file is present so the agent can read the catalogue. Break any link and the pass stops firing.
@@ -229,13 +259,13 @@ has "installed effort-model targets this repo's base" "$(cat .claude/ru
229
259
  has "the task-management template parameterizes its base too" "$(cat templates/rules/task-management.md)" '{{BASE_BRANCH}}'
230
260
 
231
261
  # ── 6. #218: every installed rule is a template basename ───────────────────────────────────────
232
- # effort_close's kit-sync drift check (_EO_KIT_MANAGED_RE) matches the whole .claude/rules/ dir, so
233
- # it flags project-OWNED rules as kit-managed. That false positive cannot arise here: every file in
234
- # this repo's .claude/rules/ IS a kit template, so the warning is accurate for cckit even before
235
- # #218 narrows the regex. This assertion is what keeps that true.
262
+ # effort_close's kit-sync drift check (_EO_KIT_MANAGED_RE) matches .claude/rules/ by template
263
+ # basename since #218, so a project-OWNED rule is not flagged as kit-managed. Every file in this
264
+ # repo's .claude/rules/ IS a kit template, so here the warning names all of them. This assertion
265
+ # keeps that true: a rule with no template would be a file cckit ships to nobody.
236
266
  find .claude/rules -maxdepth 1 -type f -name '*.md' 2>/dev/null | while IFS= read -r f; do
237
267
  b="$(basename "$f")"
238
- [ -f "templates/rules/$b" ] || echo "FAIL: $f has no templates/rules/$b — a project-owned rule here would trip the #218 drift false positive"
268
+ [ -f "templates/rules/$b" ] || echo "FAIL: $f has no templates/rules/$b — cckit's own rules are all kit templates; add the template or drop the rule"
239
269
  done | grep . && fail=1
240
270
 
241
271
  if [ "$fail" -eq 0 ]; then echo "PASS: cckit self-install matches its manifest"; fi
@@ -3,12 +3,19 @@
3
3
  # Reads repo + roles from .claude/kit.config.json; the flow vocabulary from effort.sh (EFFORT_FLOWS).
4
4
  # These are exactly the labels `cckit effort new` / /kit-effort-new apply — provision them here so a
5
5
  # fresh repo can create a fully-labeled effort with no manual label creation. Run from project root.
6
+ # The families are the ones rules/naming-and-ids.md § Labels documents, each with a reader; `slug:`
7
+ # is per-effort and created by `effort new`.
6
8
  set -euo pipefail
7
9
  source "$(dirname "$0")/lib/kit-config.sh" && load_kit_config
8
10
  # shellcheck source=/dev/null
9
11
  source "$(dirname "$0")/lib/effort.sh" 2>/dev/null || true # for EFFORT_FLOWS (the flow:* vocabulary)
12
+ # shellcheck source=/dev/null
13
+ source "$(dirname "$0")/lib/kinds.sh" 2>/dev/null || true # for KIT_KINDS (the kind:* vocabulary)
10
14
 
11
15
  ensure_label() { # name color description
16
+ # KIT_LABELS_LIST=1: print `name<TAB>color<TAB>description` and call nothing — `cckit init` reads
17
+ # this list to create only the labels a repository lacks (#456).
18
+ if [ "${KIT_LABELS_LIST:-0}" = "1" ]; then printf '%s\t%s\t%s\n' "$1" "$2" "$3"; return 0; fi
12
19
  gh label create "$1" --repo "$KIT_REPO" --color "$2" --description "$3" --force >/dev/null 2>&1 \
13
20
  && echo " ✓ $1" || echo " • $1 (exists)"
14
21
  }
@@ -19,7 +26,17 @@ echo "→ Labels on $KIT_REPO"
19
26
  echo "effort:"
20
27
  ensure_label "effort" "5319e7" "An effort parent issue"
21
28
  echo "kinds:"
22
- for k in task plan adr scaffold spike; do ensure_label "kind:$k" "5319e7" "Kind: $k"; done
29
+ # The closed set of rules/branch-naming.md — a kind is also the branch prefix `cckit start` cuts, so
30
+ # the two lists are one list. The literal is the fallback for a project without lib/kinds.sh;
31
+ # scripts/lib/kinds-test.sh fails if it drifts from KIT_KINDS.
32
+ for k in ${KIT_KINDS:-feat fix task chore security scaffold ci adr spike plan}; do ensure_label "kind:$k" "5319e7" "Kind: $k"; done
33
+ # Content kinds (#417) — post, campaign, brand, research — are provisioned only for a project whose
34
+ # config sets `kinds.content: true` (the content and marketing profiles do). A software project
35
+ # would carry four labels that never vary. The literal is the fallback for a project without
36
+ # lib/kinds.sh; scripts/lib/kinds-test.sh fails if it drifts from KIT_CONTENT_KINDS.
37
+ if [ "${KIT_CONTENT_KINDS_ON:-false}" = "true" ]; then
38
+ for k in ${KIT_CONTENT_KINDS:-post campaign brand research}; do ensure_label "kind:$k" "5319e7" "Kind: $k (content)"; done
39
+ fi
23
40
  echo "priorities:"
24
41
  ensure_label "priority:p0" "8b0000" "Drop everything"
25
42
  ensure_label "priority:p1" "b60205" "Now / blocking"
@@ -8,7 +8,7 @@ echo "→ Milestones on $KIT_REPO"
8
8
  existing=$(gh api "repos/$KIT_REPO/milestones?state=all" --jq '.[].title' 2>/dev/null || echo "")
9
9
  while IFS= read -r m; do
10
10
  [[ -z "$m" ]] && continue
11
- if echo "$existing" | grep -qxF "$m"; then
11
+ if grep -qxF "$m" <<<"$existing"; then
12
12
  echo " • $m (exists)"
13
13
  else
14
14
  gh api "repos/$KIT_REPO/milestones" -f title="$m" >/dev/null && echo " ✓ $m"
@@ -43,7 +43,7 @@ FREEZE_PRESET=(--window --padding 20 --width 920 --height 400 --wrap 90 --font.s
43
43
  echo
44
44
  echo 'A short visual tour of cckit — each shot is a real command run for real, captured at the same'
45
45
  echo 'size. For the **full command list** (copyable), see the [CLI reference](/cli-reference/); to'
46
- echo 'see how the verbs fit together, start with [the GitHub cycle](/github-cycle/).'
46
+ echo 'see how the verbs fit together, start with [the GitHub cycle](/development/).'
47
47
  echo
48
48
  } > "$GALLERY"
49
49
 
@@ -52,7 +52,7 @@ mk_skill bloated 700 200
52
52
  capture
53
53
  if [ "$run_rc" -eq 0 ]; then
54
54
  fail "new over-budget skill is rejected (exited 0)"
55
- elif printf '%s' "$run_out" | grep -q "over the .*listing budget"; then
55
+ elif grep -q "over the .*listing budget" <<<"$run_out"; then
56
56
  pass "new over-budget skill is rejected"
57
57
  else
58
58
  fail "new over-budget skill is rejected (wrong message: $run_out)"
@@ -68,7 +68,7 @@ mk_skill bloated 900 200
68
68
  capture
69
69
  if [ "$run_rc" -eq 0 ]; then
70
70
  fail "growth past baseline is rejected (exited 0)"
71
- elif printf '%s' "$run_out" | grep -q "always-resident context may not grow"; then
71
+ elif grep -q "always-resident context may not grow" <<<"$run_out"; then
72
72
  pass "growth past baseline is rejected"
73
73
  else
74
74
  fail "growth past baseline is rejected (wrong message: $run_out)"
@@ -79,7 +79,7 @@ mk_skill bloated 200 100
79
79
  capture
80
80
  if [ "$run_rc" -ne 0 ]; then
81
81
  fail "shrunk skill passes and nudges --update (exited $run_rc)"
82
- elif printf '%s' "$run_out" | grep -q "now under budget"; then
82
+ elif grep -q "now under budget" <<<"$run_out"; then
83
83
  pass "shrunk skill passes and nudges --update"
84
84
  else
85
85
  fail "shrunk skill passes but no re-baseline nudge"
@@ -126,7 +126,7 @@ mkdir -p "$TMP/.claude/skills/scaffolded"
126
126
  echo "---"
127
127
  } > "$TMP/.claude/skills/scaffolded/SKILL.md"
128
128
  capture
129
- if [ "$run_rc" -ne 0 ] && printf '%s' "$run_out" | grep -q 'scaffolded'; then
129
+ if [ "$run_rc" -ne 0 ] && grep -q 'scaffolded' <<<"$run_out"; then
130
130
  pass ".claude/skills/ is linted"
131
131
  else
132
132
  fail ".claude/skills/ is linted (rc=$run_rc: $run_out)"
@@ -86,7 +86,7 @@ listing_chars() {
86
86
  baseline_for() {
87
87
  [ -f "$BASELINE" ] || { echo ""; return; }
88
88
  grep -v '^[[:space:]]*#' "$BASELINE" 2>/dev/null \
89
- | awk -v s="$1" '$1 == s { print $2; exit }'
89
+ | awk -v s="$1" '$1 == s && !hit { print $2; hit = 1 }'
90
90
  }
91
91
 
92
92
  MODE="${1:-lint}"
@@ -17,12 +17,23 @@ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
17
17
  fix="$tmp/proj"; mkdir -p "$fix"; ( cd "$fix" && git init -q )
18
18
  printf '{"kitVersion":"9.9.9","project":{"name":"fix"},"github":{"repo":"octo/fixture","owner":"octo","baseBranch":"main"}}' > "$fix/cckit.config.json"
19
19
 
20
- # Stub gh: `issue list` returns $GH_ISSUES (a JSON array file); everything else returns [].
20
+ # Stub gh: `issue list` returns $GH_ISSUES (a JSON array file) — or, when the call filters on
21
+ # `--label effort`, $GH_EFFORTS (the open efforts; [] when unset, i.e. "no issue carries the label").
22
+ # `api …/issues/<N>/dependencies/blocked_by` returns $GH_DEPS/<N>.json when present. Everything
23
+ # else returns [].
21
24
  stub="$tmp/bin"; mkdir -p "$stub"
22
25
  cat > "$stub/gh" <<'SH'
23
26
  #!/usr/bin/env bash
24
27
  case "$1 $2" in
25
- "issue list") cat "$GH_ISSUES" 2>/dev/null || echo '[]' ;;
28
+ "issue list")
29
+ case " $* " in
30
+ *" --label effort "*) [ -z "${GH_EFFORTS_FAIL:-}" ] || exit 1
31
+ cat "${GH_EFFORTS:-/nonexistent}" 2>/dev/null || echo '[]' ;;
32
+ *) cat "$GH_ISSUES" 2>/dev/null || echo '[]' ;;
33
+ esac ;;
34
+ "api repos/"*)
35
+ n="${2%/dependencies/blocked_by}"; n="${n##*/}"
36
+ cat "${GH_DEPS:-/nonexistent}/$n.json" 2>/dev/null || echo '[]' ;;
26
37
  *) echo "[]" ;;
27
38
  esac
28
39
  SH
@@ -59,5 +70,105 @@ out0="$(run_status "$tmp/issues0.json")"
59
70
  has "empty board counts 0/0" "$out0" "open issues: 0 blocked: 0"
60
71
  no "no integer-expression error (empty)" "$out0" "integer expression"
61
72
 
73
+ # ── next effort per flow (E241.4) ────────────────────────────────────────────────────────────────
74
+ # No open issue carries the `effort` label (the stub's default): the section is still there and
75
+ # says why it is empty, instead of being absent.
76
+ has "section is present with no efforts" "$out3" "## Next effort per flow"
77
+ has "no efforts: states its own emptiness" "$out3" 'No open issue carries the `effort` label'
78
+ has "the section sits before the buckets" "$(printf '%s\n' "$out3" | grep -E '^## ' | tr '\n' '|')" \
79
+ "## Board|## Next effort per flow|## 1 · Local undone work|"
80
+ has "status names the cadence" "$out3" 'Monday: `cckit plan`'
81
+ has "status names the Friday step" "$out3" 'Friday: `cckit gc`'
82
+
83
+ # Two flows; core #11 is blocked_by the OPEN core #10, docs #20 is free.
84
+ mkdir -p "$tmp/deps"
85
+ cat > "$tmp/efforts.json" <<'JSON'
86
+ [ {"number":20,"title":"[Effort] 20 · [Docs] cadence page","labels":[{"name":"effort"},{"name":"flow:docs"},{"name":"ctx:S"}]},
87
+ {"number":11,"title":"[Effort] 11 · [Core] second thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:L"}]},
88
+ {"number":10,"title":"[Effort] 10 · [Core] first thing","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:M"}]} ]
89
+ JSON
90
+ echo '[{"number":10,"state":"open"}]' > "$tmp/deps/11.json"
91
+ oute="$(GH_EFFORTS="$tmp/efforts.json" GH_DEPS="$tmp/deps" run_status "$tmp/issues3.json")"
92
+ has "core row names the unblocked effort" "$oute" "| core | **E10** — first thing | M | 1 |"
93
+ has "docs row names its effort" "$oute" "| docs | **E20** — cadence page | S | 0 |"
94
+ no "the blocked effort is never offered" "$oute" "**E11**"
95
+ no "a populated section is not 'empty'" "$oute" "No open issue carries"
96
+ has "the board count is untouched by it" "$oute" "open issues: 3 blocked: 1"
97
+
98
+ # Every effort in the flow blocked: the flow keeps its row and says nothing can start.
99
+ echo '[{"number":999,"state":"open"}]' > "$tmp/deps/10.json"
100
+ outb="$(GH_EFFORTS="$tmp/efforts.json" GH_DEPS="$tmp/deps" run_status "$tmp/issues3.json")"
101
+ has "a fully blocked flow says so" "$outb" "| core | _none can start"
102
+ rm -f "$tmp/deps/10.json"
103
+
104
+ # The effort query fails: "could not read" must not read as "no efforts".
105
+ outf="$(GH_EFFORTS_FAIL=1 run_status "$tmp/issues3.json")"
106
+ has "unreadable efforts say so" "$outf" "Could not read the open efforts"
107
+ no "unreadable is not reported as empty" "$outf" "No open issue carries"
108
+
109
+ # --llm: the same rows under ONE new key, next_efforts.
110
+ run_status_llm() {
111
+ ( cd "$fix" && KIT_CONFIG="$fix/cckit.config.json" PATH="$stub:$PATH" GH_ISSUES="$tmp/issues3.json" \
112
+ bash "$ROOT/scripts/status.sh" --llm 2>/dev/null )
113
+ }
114
+ jse="$(GH_EFFORTS="$tmp/efforts.json" GH_DEPS="$tmp/deps" run_status_llm)"
115
+ t "llm: next_efforts has one row per flow" "$(printf '%s' "$jse" | jq -r '.next_efforts | length')" "2"
116
+ t "llm: the core row" "$(printf '%s' "$jse" | jq -c '.next_efforts[0]')" \
117
+ '{"flow":"core","number":10,"ctx":"M","title":"first thing","waiting":1}'
118
+ t "llm: the docs row" "$(printf '%s' "$jse" | jq -c '.next_efforts[1]')" \
119
+ '{"flow":"docs","number":20,"ctx":"S","title":"cadence page","waiting":0}'
120
+ t "llm: no efforts is [] not null" "$(run_status_llm | jq -c '.next_efforts')" "[]"
121
+ t "llm: unreadable efforts is null" "$(GH_EFFORTS_FAIL=1 run_status_llm | jq -c '.next_efforts')" "null"
122
+ t "llm: the pre-existing keys are all still there" \
123
+ "$(printf '%s' "$jse" | jq -r 'keys | join(",")')" \
124
+ "ai_review_expected,cleanup,deps,instruction_budget,light_tasks,local_undone,next_efforts,prs,prs_read,worktrees"
125
+
126
+ # ── light tasks (#487) ──────────────────────────────────────────────────────────────────────────
127
+ # A project with no light task: no section, and `light_tasks` is null.
128
+ no "no light task: no section" "$(run_status "$tmp/empty.json")" "## Light tasks"
129
+ t "no light task: llm is null" "$(run_status_llm | jq -c '.light_tasks')" "null"
130
+
131
+ # Three tasks waiting for review, two not started, one only in this checkout. The states come from
132
+ # git alone: a `light/<id>-…` branch whose copy says done is `review`; a file on the base branch is
133
+ # `todo`; an untracked file is `draft`.
134
+ lt="$tmp/light"; mkdir -p "$lt/tasks"; ( cd "$lt" && git init -q && git symbolic-ref HEAD refs/heads/main )
135
+ printf '{"kitVersion":"9.9.9","project":{"name":"lt"},"github":{"repo":"octo/light","owner":"octo","baseBranch":"main"},"tasks":{"default":"light"}}' > "$lt/cckit.config.json"
136
+ task_file() { printf 'id: %s\ntitle: %s\nstatus: %s\npriority: p2\nkind: post\ncreated: 2026-11-13\n' "$1" "$2" "$3" > "$lt/tasks/$1.md"; }
137
+ for i in ta01 ta02 ta03 tb01 tb02; do task_file "$i" "Piece $i" todo; done
138
+ ( cd "$lt" && git add -A && git -c user.name=t -c user.email=t@t commit -q -m base
139
+ for i in ta01 ta02 ta03; do
140
+ git checkout -q -b "light/$i-piece" main
141
+ sed 's/^status: todo/status: done/' "tasks/$i.md" > t.tmp && mv t.tmp "tasks/$i.md"
142
+ git -c user.name=t -c user.email=t@t commit -q -am "finish $i"
143
+ done
144
+ git checkout -q main )
145
+ task_file tc01 "Local only" todo
146
+ : > "$tmp/gh.log"
147
+ cat > "$stub/gh-logged" <<SH
148
+ #!/usr/bin/env bash
149
+ printf '%s\\n' "\$*" >> "$tmp/gh.log"
150
+ exec "$stub/gh" "\$@"
151
+ SH
152
+ chmod +x "$stub/gh-logged"; mkdir -p "$tmp/logbin"; ln -s "$stub/gh-logged" "$tmp/logbin/gh"
153
+ lt_status() { ( cd "$lt" && KIT_CONFIG="$lt/cckit.config.json" PATH="$tmp/logbin:$PATH" GH_ISSUES="$tmp/empty.json" bash "$ROOT/scripts/status.sh" "$@" 2>&1 ); }
154
+ out_lt="$(lt_status)"
155
+ has "light tasks: the section is there" "$out_lt" "## Light tasks"
156
+ has "light tasks: counts by state" "$out_lt" "review: 3 doing: 0 todo: 2 draft: 1 shared: 0 done: 0"
157
+ has "light tasks: a review row names its branch" "$out_lt" '| `ta01` | **review** | Piece ta01 | waiting for review: its pull request is open from light/ta01-piece |'
158
+ has "light tasks: a draft row says what to do" "$out_lt" '| `tc01` | **draft** | Local only | only in this checkout; start it (cckit task start tc01)'
159
+ no "light tasks: a todo task is counted, not listed" "$out_lt" '| `tb01` |'
160
+ has "light tasks: the board line is still printed" "$out_lt" "open issues: 0 blocked: 0"
161
+ js_lt="$(lt_status --llm 2>/dev/null)"
162
+ t "light tasks llm: counts" "$(printf '%s' "$js_lt" | jq -c '.light_tasks.counts')" \
163
+ '{"draft":1,"todo":2,"shared":0,"doing":0,"review":3,"done":0,"dropped":0}'
164
+ t "light tasks llm: attention rows, review first" "$(printf '%s' "$js_lt" | jq -r '[.light_tasks.attention[] | .id + ":" + .state] | join(" ")')" \
165
+ "ta01:review ta02:review ta03:review tc01:draft"
166
+ # No GitHub call is made FOR the tasks: every gh call of the run is one the other sections make.
167
+ t "light tasks: no gh call names a task" "$(grep -cE 'light/|tasks|ta0|tb0|tc0' "$tmp/gh.log" | tr -d ' ')" "0"
168
+ calls_with="$(grep -c . "$tmp/gh.log" | tr -d ' ')"
169
+ rm -rf "$lt/tasks"; ( cd "$lt" && git checkout -q -- . 2>/dev/null; rm -rf tasks; git branch -q -D light/ta01-piece light/ta02-piece light/ta03-piece; git rm -q -r tasks; git -c user.name=t -c user.email=t@t commit -q -m "no tasks" )
170
+ : > "$tmp/gh.log"; lt_status >/dev/null; lt_status --llm >/dev/null 2>&1
171
+ t "light tasks: the same number of gh calls with and without tasks" "$(grep -c . "$tmp/gh.log" | tr -d ' ')" "$calls_with"
172
+
62
173
  [ "$fail" -eq 0 ] && echo "ALL OK (status)" || echo "status: FAILURES"
63
174
  exit "$fail"
package/scripts/status.sh CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
- # status.sh - the "where are we?" dashboard: the board, then the THREE buckets a session actually
3
- # opens with (local undone work · PRs waiting on a human · cleanup available), then the resume
4
- # handoff. The bucket logic lives in scripts/lib/kit-status.sh (kit-engine-boundary: verb logic in a
2
+ # status.sh - the "where are we?" dashboard: the board, the light tasks (when the project has any),
3
+ # the next effort that can start in each flow,
4
+ # then the THREE buckets a session actually opens with (local undone work · PRs waiting on a human ·
5
+ # cleanup available), then the resume handoff. The bucket logic lives in scripts/lib/kit-status.sh (kit-engine-boundary: verb logic in a
5
6
  # sourceable lib, never inline in a script), so every verdict is unit-tested rather than eyeballed. Output is MARKDOWN routed through the rendering seam (#82): rich via glow in a TTY,
6
7
  # verbatim markdown otherwise (renders natively in Claude Code, always pipe-safe — no escape codes
7
8
  # leak into a redirect). This is the lightweight cockpit; the rich opentui TUI is an OPTIONAL
@@ -17,6 +18,10 @@ source "$ROOT/scripts/lib/kit-config.sh" && load_kit_config
17
18
  # shellcheck source=/dev/null
18
19
  source "$ROOT/scripts/lib/kit-gc.sh" 2>/dev/null || true
19
20
  # shellcheck source=/dev/null
21
+ source "$ROOT/scripts/lib/effort-plan.sh" 2>/dev/null || true
22
+ # shellcheck source=/dev/null
23
+ source "$ROOT/scripts/lib/task-source.sh" 2>/dev/null || true
24
+ # shellcheck source=/dev/null
20
25
  source "$ROOT/scripts/lib/kit-status.sh"
21
26
 
22
27
  # _status_md — compose the whole dashboard as one markdown document on stdout.
@@ -49,6 +54,14 @@ _status_md() {
49
54
  fi
50
55
  echo ""
51
56
 
57
+ # Light tasks (#487): counts by state and the rows somebody has to act on. Prints nothing in a
58
+ # project that has none; reads local git only.
59
+ status_light_tasks_md
60
+
61
+ # The order of work: the next effort that can start in each flow, plus the weekly cadence.
62
+ status_next_efforts_md
63
+ echo ""
64
+
52
65
  # The three buckets. Each one names its own emptiness, so a clean bucket and a broken one never
53
66
  # look alike — this report is read to decide what to do next.
54
67
  status_buckets_md "$ROOT"
@@ -0,0 +1,154 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # task-sync-test.sh — covers the dashboard layer of `cckit sync` (#383): the `--json` summary, the
4
+ # atomic `--write` cache, `--cached [TTL]`, one `--watch` iteration, the op.start/op.done events and
5
+ # `--plan`. Hermetic: a throwaway repo + a stubbed gh that counts its calls and fails on demand.
6
+ # Run: bash scripts/task-sync-test.sh
7
+ # errors: strict — a test runner: rc 1 on any failed assertion
8
+ set -u
9
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
10
+ fail=0
11
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
12
+ has(){ case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> output lacks '$3'"; fail=1 ;; esac; }
13
+ command -v jq >/dev/null 2>&1 || { echo "task-sync-test: jq required — skipping"; exit 0; }
14
+ command -v git >/dev/null 2>&1 || { echo "task-sync-test: git required" >&2; exit 1; }
15
+
16
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
17
+ fix="$tmp/proj"; mkdir -p "$fix"; ( cd "$fix" && git init -q )
18
+ printf '%s' '{"kitVersion":"9.9.9","project":{"name":"fix"},"roles":["Tech Lead","Docs"],"github":{"repo":"octo/fixture","owner":"octo","baseBranch":"main","projectsV2":false}}' \
19
+ > "$fix/cckit.config.json"
20
+ CACHE="$fix/.git/kit-sync-cache.json"
21
+ EVENTS="$fix/.git/kit-events.jsonl"
22
+ CALLS="$tmp/gh-calls"
23
+
24
+ OLD20="$(date -u -v-20d +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '20 days ago' +%Y-%m-%dT%H:%M:%SZ)"
25
+ NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
26
+ cat > "$tmp/issues.json" <<JSON
27
+ [ {"number":1,"title":"lead work","labels":[{"name":"role:tech-lead"},{"name":"priority:p1"}],"milestone":{"title":"v1"},"assignees":[],"updatedAt":"$NOW","body":"plain"},
28
+ {"number":2,"title":"docs work","labels":[{"name":"role:docs"}],"milestone":null,"assignees":[],"updatedAt":"$OLD20","body":"Blocked by #1"},
29
+ {"number":3,"title":"no role","labels":[],"milestone":null,"assignees":[],"updatedAt":"$NOW","body":""} ]
30
+ JSON
31
+ # Same five PRs board-view-test.sh orders: ready(risk asc, size asc) → draft → blocked.
32
+ cat > "$tmp/prs.json" <<'JSON'
33
+ [
34
+ {"number":10,"title":"blocked one","labels":[{"name":"risk:low"},{"name":"size:S"},{"name":"blocked"}],"isDraft":false,"headRefName":"feat/10","reviewDecision":"APPROVED","mergeable":"MERGEABLE"},
35
+ {"number":11,"title":"draft one","labels":[{"name":"risk:low"},{"name":"size:XS"}],"isDraft":true,"headRefName":"feat/11","reviewDecision":null,"mergeable":"MERGEABLE"},
36
+ {"number":12,"title":"ready high risk","labels":[{"name":"risk:high"},{"name":"size:S"}],"isDraft":false,"headRefName":"claude/12","reviewDecision":"APPROVED","mergeable":"MERGEABLE"},
37
+ {"number":13,"title":"ready low risk L","labels":[{"name":"risk:low"},{"name":"size:L"}],"isDraft":false,"headRefName":"feat/13","reviewDecision":"APPROVED","mergeable":"MERGEABLE"},
38
+ {"number":14,"title":"ready low risk S","labels":[{"name":"risk:low"},{"name":"size:S"}],"isDraft":false,"headRefName":"feat/14","reviewDecision":"APPROVED","mergeable":"MERGEABLE"}
39
+ ]
40
+ JSON
41
+
42
+ # Stub gh: every call is counted; GH_FAIL=1 fails every call, GH_FAIL_PR=1 only `pr list`.
43
+ # `issue list --label effort` is effort_plan's query (effort_open_rows parses the --json array).
44
+ stub="$tmp/bin"; mkdir -p "$stub"
45
+ cat > "$stub/gh" <<'SH'
46
+ #!/usr/bin/env bash
47
+ echo "$*" >> "$GH_CALLS"
48
+ [ "${GH_FAIL:-0}" = 1 ] && { echo "gh: network down" >&2; exit 1; }
49
+ case "$1 $2" in
50
+ "issue list")
51
+ case " $* " in
52
+ *" --label effort "*) echo '[{"number":42,"title":"[Effort] 42 · [Core] demo effort","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:M"}]}]' ;;
53
+ *) cat "$GH_ISSUES" ;;
54
+ esac ;;
55
+ "pr list") [ "${GH_FAIL_PR:-0}" = 1 ] && { echo "gh: pr list failed" >&2; exit 1; }; cat "$GH_PRS" ;;
56
+ *) echo "" ;;
57
+ esac
58
+ SH
59
+ chmod +x "$stub/gh"
60
+
61
+ sync() { # run task-sync.sh against the fixture; extra env via leading VAR=val words in "$ENVV"
62
+ ( cd "$fix" && env KIT_CONFIG="$fix/cckit.config.json" PATH="$stub:$PATH" GH_CALLS="$CALLS" \
63
+ GH_ISSUES="$tmp/issues.json" GH_PRS="$tmp/prs.json" CCKIT_OUTPUT=human ${ENVV:-} \
64
+ bash "$ROOT/scripts/task-sync.sh" "$@" )
65
+ }
66
+ calls() { if [ -f "$CALLS" ]; then wc -l < "$CALLS" | tr -d ' '; else echo 0; fi; }
67
+ sum() { cksum < "$1"; }
68
+
69
+ # ── (1) --json: one JSON object — per role, merge queue, stale ──────────────────────────────────
70
+ ENVV=""; doc="$(sync --json 2>/dev/null)"
71
+ t "--json emits one JSON object" "$(printf '%s' "$doc" | jq -rs 'length, (.[0]|type)' | tr '\n' ' ')" "1 object "
72
+ t "--json names the repo" "$(printf '%s' "$doc" | jq -r '.repo')" "octo/fixture"
73
+ t "--json counts open issues" "$(printf '%s' "$doc" | jq -r '.open')" "3"
74
+ t "--json lists roles in config order" "$(printf '%s' "$doc" | jq -r '[.roles[].role]|join(",")')" "Tech Lead,Docs"
75
+ t "--json groups issues under their role" "$(printf '%s' "$doc" | jq -r '[.roles[]|(.issues|map(.number|tostring)|join("+"))]|join(",")')" "1,2"
76
+ t "--json puts a role-less issue in unassigned" "$(printf '%s' "$doc" | jq -c '[.unassigned[].number]')" "[3]"
77
+ t "--json carries priority + milestone" "$(printf '%s' "$doc" | jq -r '.roles[0].issues[0]|"\(.priority) \(.milestone)"')" "p1 v1"
78
+ t "--json lists blocked issues" "$(printf '%s' "$doc" | jq -c '.blocked')" "[2]"
79
+ t "--json stale section" "$(printf '%s' "$doc" | jq -c '.stale')" '{"days":14,"issues":[{"number":2,"days":20}]}'
80
+ t "--json notOnBoard is null with the board off" "$(printf '%s' "$doc" | jq -r '.notOnBoard')" "null"
81
+ # shellcheck source=/dev/null
82
+ source "$ROOT/scripts/lib/board-view.sh"
83
+ rendered="$(board_merge_queue "$(cat "$tmp/prs.json")" | grep -oE '#1[0-4]' | tr -d '#' | tr '\n' ' ')"
84
+ t "--json merge queue order matches board_merge_queue" "$(printf '%s' "$doc" | jq -r '[.mergeQueue[].number|tostring]|join(" ")') " "$rendered"
85
+ t "--json merge queue order is ready, draft, blocked" "$(printf '%s' "$doc" | jq -r '[.mergeQueue[].number|tostring]|join(" ")')" "14 13 12 11 10"
86
+ t "--json does not write the cache on its own" "$([ -f "$CACHE" ] && echo yes || echo no)" "no"
87
+ t "--json applies --role" "$(sync --json --role Docs 2>/dev/null | jq -r '([.roles[].role]|join(",")) + " " + (.unassigned|length|tostring)')" "Docs 0"
88
+
89
+ # ── (5) events: op.start + op.done for the sync ────────────────────────────────────────────────
90
+ t "kit-events.jsonl has an op.start for sync" "$(jq -rs '[.[]|select(.type=="op.start" and .op=="sync")]|length > 0' "$EVENTS" 2>/dev/null)" "true"
91
+ t "kit-events.jsonl has an op.done for sync" "$(jq -rs '[.[]|select(.type=="op.done" and .op=="sync")]|length > 0' "$EVENTS" 2>/dev/null)" "true"
92
+ t "op.done records success" "$(jq -rs '[.[]|select(.type=="op.done" and .op=="sync")][0].payload.ok' "$EVENTS" 2>/dev/null)" "true"
93
+
94
+ # ── (2) --write: atomic cache; a failing fetch leaves it byte-identical ─────────────────────────
95
+ ENVV=""; sync --write >/dev/null 2>&1; rc=$?
96
+ t "--write exits 0" "$rc" "0"
97
+ t "--write creates <git-common-dir>/kit-sync-cache.json" "$([ -f "$CACHE" ] && echo yes || echo no)" "yes"
98
+ t "the cache is the --json document" "$(jq -r '.mergeQueue|length' "$CACHE" 2>/dev/null)" "5"
99
+ t "--write leaves no temp file behind" "$(find "$fix/.git" -maxdepth 1 -name 'kit-sync-cache.json.*' | wc -l | tr -d ' ')" "0"
100
+ before="$(sum "$CACHE")"
101
+ ENVV="GH_FAIL=1"; sync --write >/dev/null 2>&1; rc=$?
102
+ t "--write with a failing gh exits non-zero" "$([ "$rc" -ne 0 ] && echo nz || echo z)" "nz"
103
+ t "a failing fetch leaves the cache byte-identical" "$(sum "$CACHE")" "$before"
104
+ ENVV="GH_FAIL_PR=1"; sync --write >/dev/null 2>&1; rc=$?
105
+ t "a partial fetch (PR list down) exits non-zero" "$([ "$rc" -ne 0 ] && echo nz || echo z)" "nz"
106
+ t "a partial fetch leaves the cache byte-identical" "$(sum "$CACHE")" "$before"
107
+ t "a failed sync still emits op.done (ok:false)" "$(jq -rs '[.[]|select(.type=="op.done" and .op=="sync" and .payload.ok==false)]|length > 0' "$EVENTS")" "true"
108
+ ENVV=""; sync --write --role Docs >/dev/null 2>&1; rc=$?
109
+ t "--write refuses a filtered document" "$rc" "2"
110
+ t "the refusal leaves the cache byte-identical" "$(sum "$CACHE")" "$before"
111
+
112
+ # ── (3) --cached: zero gh calls inside the TTL, one refresh past it ─────────────────────────────
113
+ rm -f "$CALLS"
114
+ ENVV=""; out="$(sync --cached 600 2>/dev/null)"
115
+ t "--cached inside the TTL makes zero gh calls" "$(calls)" "0"
116
+ t "--cached serves the cache bytes" "$(printf '%s\n' "$out" | cksum)" "$before"
117
+ # Age the cache past the TTL by rewriting its timestamp (no sleep).
118
+ jq '.generatedEpoch = 1000' "$CACHE" > "$CACHE.aged" && mv "$CACHE.aged" "$CACHE"
119
+ out="$(sync --cached 600 2>/dev/null)"
120
+ t "--cached past the TTL refreshes (gh called)" "$([ "$(calls)" -gt 0 ] && echo yes || echo no)" "yes"
121
+ t "the refresh rewrote the cache" "$([ "$(jq -r '.generatedEpoch' "$CACHE")" -gt 1000 ] && echo yes || echo no)" "yes"
122
+ t "the refresh prints the fresh document" "$(printf '%s' "$out" | jq -r '.open')" "3"
123
+ n1="$(calls)"; sync --cached 600 >/dev/null 2>&1
124
+ t "the next --cached call is served from the cache again" "$(calls)" "$n1"
125
+ rm -f "$CALLS"; sync --cached >/dev/null 2>&1
126
+ t "--cached with no TTL uses the default and stays cached" "$(calls)" "0"
127
+
128
+ # ── (4) --watch: one iteration with a failing fetch keeps the last good cache ───────────────────
129
+ before="$(sum "$CACHE")"
130
+ ENVV="GH_FAIL=1 KIT_SYNC_WATCH_MAX=1"; werr="$(sync --watch 1 2>&1 >/dev/null)"; rc=$?
131
+ t "a failing watch iteration keeps the last good cache" "$(sum "$CACHE")" "$before"
132
+ has "the watch loop reports the failed refresh" "$werr" "kept the last good cache"
133
+ t "a watch that ends on a failed refresh exits non-zero" "$([ "$rc" -ne 0 ] && echo nz || echo z)" "nz"
134
+ jq '.generatedEpoch = 1000' "$CACHE" > "$CACHE.aged" && mv "$CACHE.aged" "$CACHE"
135
+ ENVV="KIT_SYNC_WATCH_MAX=2"; sync --watch 0 >/dev/null 2>&1; rc=$?
136
+ t "a healthy watch exits 0 at its iteration cap" "$rc" "0"
137
+ t "a healthy watch iteration refreshes the cache" "$([ "$(jq -r '.generatedEpoch' "$CACHE")" -gt 1000 ] && echo yes || echo no)" "yes"
138
+
139
+ # ── (6) --plan inlines `effort plan` ────────────────────────────────────────────────────────────
140
+ ENVV=""; pout="$(sync --plan 2>/dev/null)"
141
+ has "--plan output contains the effort plan header" "$pout" "kit effort plan"
142
+ has "--plan still prints the board" "$pout" "Merge Queue"
143
+ has "--plan lists the effort" "$pout" "demo effort"
144
+ has "--json --plan carries the plan text" "$(sync --json --plan 2>/dev/null | jq -r '.plan')" "kit effort plan"
145
+ t "--json without --plan has no plan key" "$(printf '%s' "$doc" | jq -r 'has("plan")')" "false"
146
+
147
+ # ── unchanged surfaces ─────────────────────────────────────────────────────────────────────────
148
+ has "human board still renders" "$(sync 2>/dev/null)" "## Board — octo/fixture"
149
+ t "--raw-json still returns the gh issue objects" "$(sync --raw-json 2>/dev/null | jq -r '.[0].labels[0].name')" "role:tech-lead"
150
+ has "--llm is still TOON" "$(sync --llm 2>/dev/null)" '[3]{number,title,priority,labels,milestone,assignees,blocked}:'
151
+ ENVV=""; sync --bogus >/dev/null 2>&1; t "an unknown flag still exits 1" "$?" "1"
152
+
153
+ [ "$fail" -eq 0 ] && echo "ALL OK (task-sync)" || echo "task-sync: FAILURES"
154
+ exit "$fail"