@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
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env bash
2
+ # kto-task-new-test.sh — kto_task_new against a stubbed gh (#387): a label the repo does not have
3
+ # is dropped with a warning and the issue is still created; with every label present the create
4
+ # call is unchanged; a failed create returns non-zero and prints no URL.
5
+ # Run: bash scripts/lib/kto-task-new-test.sh
6
+ # errors: strict — a test runner: rc 1 on any failed assertion
7
+ set -u
8
+ LIB="$(cd "$(dirname "$0")" && pwd)"
9
+ fail=0
10
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
11
+ tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
12
+ tn() { if grep -qE -- "$2" "$1"; then echo "FAIL: $3 (/$2/ in $1)"; fail=1; else echo "ok: $3"; fi; }
13
+
14
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
15
+ export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
16
+ mkdir -p "$tmp/bin"
17
+ # GH_HAVE: the repo's labels, comma-separated. GH_LIST_FAIL=1: `gh label list` fails.
18
+ # GH_CREATE_FAIL=1: `gh issue create` fails. Like real gh, a create naming a label the repo does
19
+ # not have fails with "could not add label".
20
+ cat > "$tmp/bin/gh" <<'SH'
21
+ #!/usr/bin/env bash
22
+ echo "$*" >> "$GH_LOG"
23
+ case "$1 $2" in
24
+ "label list")
25
+ [ -n "${GH_LIST_FAIL:-}" ] && { echo "gh: HTTP 403" >&2; exit 1; }
26
+ printf '%s\n' "$GH_HAVE" | tr ',' '\n' ;;
27
+ "issue create")
28
+ [ -n "${GH_CREATE_FAIL:-}" ] && { echo "gh: HTTP 500" >&2; exit 1; }
29
+ want=""; while [ $# -gt 0 ]; do [ "$1" = "--label" ] && want="${2:-}"; shift; done
30
+ for l in $(printf '%s' "$want" | tr ',' ' '); do
31
+ case ",$(printf '%s' "$GH_HAVE" | tr 'A-Z' 'a-z')," in *",$l,"*) ;; *) echo "could not add label: '$l' not found" >&2; exit 1 ;; esac
32
+ done
33
+ echo "https://github.com/o/r/issues/50" ;;
34
+ *) exit 0 ;;
35
+ esac
36
+ SH
37
+ chmod +x "$tmp/bin/gh"
38
+ export PATH="$tmp/bin:$PATH" KIT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_PROJECTS_V2="false"
39
+ unset KIT_CONFIG CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT GH_LIST_FAIL GH_CREATE_FAIL
40
+ cd "$tmp" || exit 1
41
+
42
+ # shellcheck source=/dev/null
43
+ . "$LIB/kit-task-ops.sh"
44
+
45
+ # ── a missing label is a warning, not an abort ────────────────────────────────────────────────────
46
+ export GH_HAVE="kind:task,priority:p2,role:backend"
47
+ : > "$GH_LOG"
48
+ kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
49
+ t "missing kind label: rc 0" "$rc" "0"
50
+ tc "$tmp/out" '^✓ https://github.com/o/r/issues/50$' "missing kind label: prints the issue URL"
51
+ t "missing kind label: echoes the number" "$(tail -1 "$tmp/out")" "50"
52
+ tc "$tmp/err" "kind:feat" "missing kind label: the warning names kind:feat"
53
+ tc "$GH_LOG" '^issue create .*--label priority:p2,role:backend( |$)' "missing kind label: only existing labels are sent"
54
+ tn "$GH_LOG" '^issue create .*kind:feat' "missing kind label: kind:feat is not sent"
55
+ tn "$GH_LOG" '^label create' "missing kind label: no label is created"
56
+
57
+ # Label names are case-insensitive on GitHub.
58
+ export GH_HAVE="Kind:Feat,priority:p2,role:backend"
59
+ : > "$GH_LOG"
60
+ kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
61
+ t "case-insensitive match: rc 0" "$rc" "0"
62
+ t "case-insensitive match: no warning" "$(grep -c 'kind:feat' "$tmp/err")" "0"
63
+ tc "$GH_LOG" '^issue create .*--label kind:feat,priority:p2,role:backend ' "case-insensitive match: the label is sent"
64
+
65
+ # ── every label missing: the issue is created with no --label at all ──────────────────────────────
66
+ export GH_HAVE="bug"
67
+ : > "$GH_LOG"
68
+ kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
69
+ t "no label exists: rc 0" "$rc" "0"
70
+ tc "$tmp/out" '^✓ https://github.com/o/r/issues/50$' "no label exists: prints the issue URL"
71
+ tn "$GH_LOG" '^issue create .*--label' "no label exists: no --label flag"
72
+ t "no label exists: three labels warned" "$(grep -cE 'kind:feat|priority:p2|role:backend' "$tmp/err")" "3"
73
+
74
+ # ── all labels present: the create call is unchanged ──────────────────────────────────────────────
75
+ export GH_HAVE="kind:feat,priority:p2,role:backend"
76
+ : > "$GH_LOG"
77
+ kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
78
+ t "all labels present: rc 0" "$rc" "0"
79
+ tc "$GH_LOG" '^issue create --repo o/r --title Test --body .*--label kind:feat,priority:p2,role:backend --assignee @me$' "all labels present: the create call is unchanged"
80
+ t "all labels present: no warning" "$(wc -c < "$tmp/err" | tr -d ' ')" "0"
81
+
82
+ # ── the label list cannot be read: send every label, as before ────────────────────────────────────
83
+ : > "$GH_LOG"
84
+ GH_LIST_FAIL=1 kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
85
+ t "unreadable label list: rc 0" "$rc" "0"
86
+ tc "$GH_LOG" '^issue create .*--label kind:feat,priority:p2,role:backend ' "unreadable label list: every label is sent"
87
+
88
+ # ── the create itself fails: non-zero, no URL ─────────────────────────────────────────────────────
89
+ : > "$GH_LOG"
90
+ GH_CREATE_FAIL=1 kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
91
+ t "create fails: rc non-zero" "$([ "$rc" -ne 0 ] && echo nonzero)" "nonzero"
92
+ t "create fails: prints nothing on stdout" "$(wc -c < "$tmp/out" | tr -d ' ')" "0"
93
+
94
+ [ "$fail" -eq 0 ] && echo "kto-task-new: all passed" || echo "kto-task-new: FAILURES"
95
+ exit "$fail"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  # kto-task-pr-merge-test.sh — kto_task_pr_merge never acts on the base branch (#366), cleans up from
3
3
  # the PR's own worktree (#371), and merges by squash, merge commit or rebase into develop or an
4
- # effort branch (#376).
4
+ # effort branch (#376). An effort/* HEAD is refused — its PR merges with `cckit effort close` (#379).
5
5
  # A flag taken as the PR number used to "merge" (gh pr merge --help exits 0) and then run the branch
6
6
  # cleanup on the base branch; a conflicting PR merged from the hub would rebase + force-push it.
7
7
  # Hermetic: stubbed gh, throwaway repo + bare remote. Run: bash scripts/lib/kto-task-pr-merge-test.sh
@@ -14,14 +14,19 @@ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]'
14
14
  command -v jq >/dev/null 2>&1 || { echo "kto-task-pr-merge-test: jq required" >&2; exit 1; }
15
15
 
16
16
  tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
17
- export GH_LOG="$tmp/gh.log" GH_MERGEABLE="MERGEABLE" GH_BASE="develop" GH_HEAD=""; : > "$GH_LOG"
17
+ export GH_LOG="$tmp/gh.log" GH_MERGEABLE="MERGEABLE" GH_BASE="develop" GH_HEAD="" GH_CLOSING="" GH_ISSUE_STATE=""; : > "$GH_LOG"
18
18
  mkdir -p "$tmp/bin"
19
19
  cat > "$tmp/bin/gh" <<'SH'
20
20
  #!/usr/bin/env bash
21
21
  echo "$*" >> "$GH_LOG"
22
22
  case "$1 $2" in
23
- "pr view") printf '{"mergeable":"%s","mergeStateStatus":"CLEAN","baseRefName":"%s","headRefName":"%s"}\n' \
23
+ "pr view") case "$*" in
24
+ *closingIssuesReferences*) [ -n "${GH_CLOSING:-}" ] && printf '%s\n' $GH_CLOSING; exit 0 ;;
25
+ *"--json body"*) exit 0 ;;
26
+ esac
27
+ printf '{"mergeable":"%s","mergeStateStatus":"CLEAN","baseRefName":"%s","headRefName":"%s"}\n' \
24
28
  "$GH_MERGEABLE" "${GH_BASE:-develop}" "${GH_HEAD:-}" ;;
29
+ "issue view") [ -n "${GH_ISSUE_STATE:-}" ] && echo "$GH_ISSUE_STATE"; exit 0 ;;
25
30
  *) exit 0 ;;
26
31
  esac
27
32
  SH
@@ -125,5 +130,34 @@ t "the sub branch (not the cwd branch) is deleted" "$(git branch --list sub/5b-y
125
130
  t "and on origin" "$(git ls-remote --heads origin sub/5b-y | wc -l | tr -d ' ')" "0"
126
131
  t "effort/5-e is still on origin" "$(git ls-remote --heads origin effort/5-e | wc -l | tr -d ' ')" "1"
127
132
 
133
+ # ── #379: the linked-issue loop does not depend on IFS ───────────────────────────────────────────
134
+ # The effort worktree lives under the main checkout here; keep it out of `git status` so the main
135
+ # checkout reads clean.
136
+ echo ".claude/" >> "$tmp/work/.git/info/exclude"
137
+ # A caller that left IFS NUL-polluted made `for n in $issues` pass "21\n22" as ONE issue number.
138
+ : > "$GH_LOG"; GH_BASE="develop"; GH_HEAD="fix/20-x"; GH_CLOSING="21 22"; GH_ISSUE_STATE="OPEN"
139
+ ( IFS=$'\0'; kto_task_pr_merge 20 ) >/dev/null 2>&1; rc=$?
140
+ t "merge under IFS=\$'\\0' exits 0" "$rc" "0"
141
+ t "issue 21 is closed on its own" "$(grep -c '^issue close 21 ' "$GH_LOG")" "1"
142
+ t "issue 22 is closed on its own" "$(grep -c '^issue close 22 ' "$GH_LOG")" "1"
143
+ t "exactly two issue close calls" "$(grep -c '^issue close ' "$GH_LOG")" "2"
144
+ GH_CLOSING=""; GH_ISSUE_STATE=""
145
+
146
+ # ── #379: an effort/* head is refused — the squash would destroy the per-sub trace ───────────────
147
+ : > "$GH_LOG"; GH_BASE="develop"; GH_HEAD="effort/5-e"
148
+ kto_task_pr_merge 14 >/dev/null 2>"$tmp/err14"; rc=$?
149
+ t "an effort head is refused (rc 1)" "$rc" "1"
150
+ t "the refusal names cckit effort close 5" "$(grep -c 'cckit effort close 5' "$tmp/err14")" "1"
151
+ t "nothing was merged on the effort refusal" "$(grep -c 'pr merge' "$GH_LOG")" "0"
152
+ t "the refused effort branch survives" "$(git branch --list effort/5-e | tr -d ' *+')" "effort/5-e"
153
+ ( cd "$ewt" && kto_task_pr_merge ) >/dev/null 2>&1; rc=$?
154
+ t "refused from the effort worktree too (rc 1)" "$rc" "1"
155
+ t "still nothing merged" "$(grep -c 'pr merge' "$GH_LOG")" "0"
156
+ : > "$GH_LOG"
157
+ KIT_FORCE=1 kto_task_pr_merge 14 >/dev/null 2>"$tmp/err14f"; rc=$?
158
+ t "KIT_FORCE=1 merges the effort head (rc 0)" "$rc" "0"
159
+ t "KIT_FORCE=1 warns about the lost trace" "$(grep -c 'KIT_FORCE=1' "$tmp/err14f")" "1"
160
+ t "KIT_FORCE=1 reaches gh pr merge" "$(grep -c 'pr merge 14' "$GH_LOG")" "1"
161
+
128
162
  [ "$fail" -eq 0 ] && echo "kto-task-pr-merge: all passed" || echo "kto-task-pr-merge: FAILURES"
129
163
  exit "$fail"
@@ -55,5 +55,75 @@ KIT_PR_TITLE_STYLE=conventional kto_task_pr 43 "Other." >/dev/null 2>&1
55
55
  tc "$GH_LOG" 'pr create .*--title fix: Fix the thing' "conventional (default): a Conventional Commits title"
56
56
  grep -q 'For the orchestrator' "$GH_LOG" && { echo "FAIL: section present with the switch off"; fail=1; } || echo "ok: no section with the switch off"
57
57
 
58
+ # --base (#391): an explicit base wins over the configured one; the flag is never a positional.
59
+ : > "$GH_LOG"; git checkout -q -b task/44-release
60
+ echo three > tracked.txt
61
+ kto_task_pr 44 "Release." --base release >/dev/null 2>&1
62
+ t "--base: rc 0" "$?" "0"
63
+ tc "$GH_LOG" 'pr create .*--base release --head task/44-release' "--base: the PR targets the given base"
64
+ t "--base is not taken as the commit message" "$(git log -1 --format=%s)" "fix: Fix the thing"
65
+ : > "$GH_LOG"
66
+ kto_task_pr 44 "Release." >/dev/null 2>&1
67
+ tc "$GH_LOG" 'pr create .*--base main --head task/44-release' "no --base: the PR targets the configured base"
68
+ : > "$GH_LOG"
69
+ kto_task_pr --base=release 44 "Release." >/dev/null 2>&1
70
+ tc "$GH_LOG" 'pr create .*--base release --head task/44-release' "--base=<branch> before the positionals"
71
+ : > "$GH_LOG"
72
+ kto_task_pr 44 "Release." "custom subject" --base release >/dev/null 2>&1
73
+ tc "$GH_LOG" 'pr create .*--base release ' "--base after an explicit commit message"
74
+
75
+ : > "$GH_LOG"; git checkout -q -b task/45-no-value
76
+ echo four > tracked.txt
77
+ kto_task_pr 45 "No value." --base >/dev/null 2>"$tmp/err"
78
+ t "--base with no value: rc 2" "$?" "2"
79
+ tc "$tmp/err" '[-]-base needs a branch' "--base with no value: says what is missing"
80
+ t "--base with no value: no gh call" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
81
+ t "--base with no value: nothing pushed" "$(git ls-remote --heads origin task/45-no-value | wc -l | tr -d ' ')" "0"
82
+ t "--base with no value: nothing committed" "$(git status --porcelain --untracked-files=no | wc -l | tr -d ' ')" "1"
83
+ kto_task_pr 45 "No value." --base= >/dev/null 2>&1
84
+ t "--base= (empty): rc 2" "$?" "2"
85
+
86
+ # the dispatcher: `cckit pr --help` prints the usage and reaches neither gh nor the remote.
87
+ : > "$GH_LOG"
88
+ out="$("$LIB/../../bin/cckit" pr --help 2>/dev/null)"
89
+ t "cckit pr --help: rc 0" "$?" "0"
90
+ case "$out" in *'[--base <branch>]'*) echo "ok: cckit pr --help shows --base" ;; *) echo "FAIL: cckit pr --help -> '$out'"; fail=1 ;; esac
91
+ t "cckit pr --help: no gh call" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
92
+ grep -qE '^# cckit pr <issue> <summary> \[--base <branch>\]' "$LIB/../../bin/cckit" \
93
+ && echo "ok: the usage header shows --base" || { echo "FAIL: usage header lacks --base"; fail=1; }
94
+
95
+ # --base (#360): the flag wins over the configured integration branch, and the PR's target reaches a
96
+ # git pre-push hook as KIT_PR_BASE.
97
+ cat > .git/hooks/pre-push <<SH
98
+ #!/usr/bin/env bash
99
+ echo "KIT_PR_BASE=\${KIT_PR_BASE:-}" >> "$tmp/prepush.log"
100
+ SH
101
+ chmod +x .git/hooks/pre-push
102
+ export KIT_BASE_BRANCH="develop" # what load_kit_config exported from the config
103
+ : > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/44-hot
104
+ echo three > tracked.txt
105
+ kto_task_pr 44 "Hot." --base main >/dev/null 2>&1
106
+ t "--base: kto_task_pr succeeds" "$?" "0"
107
+ tc "$GH_LOG" 'pr create .*--base main( |$)' "--base main: the PR targets main, not the configured develop"
108
+ t "--base main: the pre-push hook sees it" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=main"
109
+ t "--base is not taken as the commit msg" "$(git log -1 --format=%s)" "fix: Fix the thing"
110
+
111
+ : > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/45-eq
112
+ echo four > tracked.txt
113
+ kto_task_pr --base=main 45 "Eq." "fix: custom msg" >/dev/null 2>&1
114
+ tc "$GH_LOG" 'pr create .*--base main( |$)' "--base=main before the positionals works too"
115
+ t "the commit message positional survives" "$(git log -1 --format=%s)" "fix: custom msg"
116
+
117
+ : > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/46-default
118
+ echo five > tracked.txt
119
+ kto_task_pr 46 "Default." >/dev/null 2>&1
120
+ tc "$GH_LOG" 'pr create .*--base develop( |$)' "no --base: the configured integration branch"
121
+ t "no --base: the hook gets the integration branch" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=develop"
122
+
123
+ : > "$GH_LOG"; git checkout -q -b fix/47-bad
124
+ kto_task_pr 47 "Bad." --base >/dev/null 2>"$tmp/err"
125
+ t "--base with no value is refused" "$?" "2"
126
+ t "…before any gh call" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
127
+
58
128
  [ "$fail" -eq 0 ] && echo "kto-task-pr: all passed" || echo "kto-task-pr: FAILURES"
59
129
  exit "$fail"
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # leak-fence.sh — the leak fence: no private word ships in a tracked file.
4
+ #
5
+ # cckit is public and is developed next to private repositories. This fence is what keeps a product
6
+ # name, a client name, a person's name or a private path from landing in a commit. It is one scan
7
+ # with three pattern sources, so there is exactly one place to generalize:
8
+ #
9
+ # 1. the built-in pattern — the legacy brand name this kit was extracted from (`tedos`). It is
10
+ # always on, so a fresh clone or a fork with no local list still fails on it.
11
+ # 2. `.cckit/leak-words` — one extended regex per line, `#` comments and blank lines skipped,
12
+ # matched case-insensitively. The file is gitignored (`.cckit/` as a whole) and MUST stay so:
13
+ # a committed denylist publishes the very words it hides. Resolved through the shared `.cckit/`
14
+ # when kit-state.sh is loaded, so every worktree reads the same list.
15
+ # 3. `CCKIT_LEAK_WORDS` — the same patterns for CI, separated by newlines or `|`. Set it from a
16
+ # repository secret; the workflow passes it as an env var to the gate step.
17
+ #
18
+ # A hit is reported as `file:line` only. The matched text is never printed: in CI the log is
19
+ # public, and echoing the line would leak the word the fence exists to hide.
20
+ #
21
+ # Scope: tracked files (`git grep`), so gitignored runtime state (.cckit/), build output and deps
22
+ # never trip it. This file is excluded from its own scan (it names the built-in pattern). Outside a
23
+ # git work tree a filtered recursive grep stands in.
24
+ #
25
+ # Pattern note: `\b` is a GNU extension. git grep -E on macOS compiles patterns with the system
26
+ # regcomp, where `\b` matches nothing, so a pattern written with it passes locally and fails in CI.
27
+ # Write `([^[:alnum:]]|$)` for a word end instead.
28
+ #
29
+ # API:
30
+ # leak_fence_patterns print the active patterns, one per line (built-in first)
31
+ # leak_fence_scan print `file:line` for every hit; exit 0 when there are hits
32
+ # leak_fence_check the gate step: 0 clean, 1 hits (file:line list on stderr)
33
+ # errors: strict — a missing list file is not an error (built-in word only); a hit returns 1 and names
34
+ # file:line, never the matched text
35
+
36
+ LEAK_FENCE_BUILTIN='tedos'
37
+ LEAK_FENCE_SELF='scripts/lib/leak-fence.sh'
38
+
39
+ leak_fence_list_file() {
40
+ if [ -n "${CCKIT_LEAK_WORDS_FILE:-}" ]; then printf '%s\n' "$CCKIT_LEAK_WORDS_FILE"
41
+ elif command -v kit_state_file >/dev/null 2>&1; then kit_state_file leak-words
42
+ else printf '%s\n' ".cckit/leak-words"; fi
43
+ }
44
+
45
+ leak_fence_patterns() {
46
+ local list
47
+ printf '%s\n' "$LEAK_FENCE_BUILTIN"
48
+ list="$(leak_fence_list_file)"
49
+ if [ -f "$list" ]; then
50
+ sed -e 's/^[[:space:]]*#.*//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' "$list" | grep -v '^$' || true
51
+ fi
52
+ if [ -n "${CCKIT_LEAK_WORDS:-}" ]; then
53
+ # Comment lines are dropped BEFORE the `|` split: a secret set from the list file carries them,
54
+ # and a comment that contains `|` would otherwise split into an unbalanced, invalid pattern.
55
+ printf '%s\n' "$CCKIT_LEAK_WORDS" | sed -e 's/^[[:space:]]*#.*//' | tr '|' '\n' \
56
+ | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | grep -v '^$' || true
57
+ fi
58
+ }
59
+
60
+ # Exit: 0 hits printed, 1 no hits, 2 the pattern set did not compile (grep's own rc) — a scan that
61
+ # cannot run is not a clean scan, so leak_fence_check fails on 2 instead of passing on empty output.
62
+ leak_fence_scan() {
63
+ local pat rc
64
+ pat="$(leak_fence_patterns | paste -sd'|' -)"
65
+ if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
66
+ git grep -inIE "$pat" -- . ":!$LEAK_FENCE_SELF" | cut -d: -f1,2
67
+ rc=${PIPESTATUS[0]}
68
+ else
69
+ grep -rniIE --exclude-dir=.git --exclude-dir=node_modules --exclude-dir=.cckit \
70
+ --exclude-dir=dist --exclude=leak-fence.sh "$pat" . | cut -d: -f1,2
71
+ rc=${PIPESTATUS[0]}
72
+ fi
73
+ [ "$rc" -le 1 ] || return 2
74
+ return "$rc"
75
+ }
76
+
77
+ leak_fence_check() {
78
+ local hits n rc
79
+ hits="$(leak_fence_scan 2>/dev/null)"; rc=$?
80
+ if [ "$rc" -ge 2 ]; then
81
+ printf 'x leak fence: the pattern set did not compile (a list or CCKIT_LEAK_WORDS entry is not a valid extended regex); the scan did not run\n' >&2
82
+ return 1
83
+ fi
84
+ [ -z "$hits" ] && return 0
85
+ n="$(printf '%s\n' "$hits" | grep -c .)"
86
+ printf 'x leak fence: %s tracked line(s) contain a private word (file:line; the text is not shown):\n' "$n" >&2
87
+ printf '%s\n' "$hits" | sed -n 1,40p >&2
88
+ return 1
89
+ }
@@ -0,0 +1,255 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # light-task-run-test.sh — `cckit task run <id>` end to end (#496): start, ONE headless objective
4
+ # built from the task record, finish, the review link.
5
+ #
6
+ # Hermetic, in the style of scripts/autopilot-run-test.sh: `claude` and `codex` are one stub script
7
+ # on PATH whose behaviour STUB_MODE selects, `gh` is a stub that logs every call, origin is a bare
8
+ # repository in the temp dir. It proves what cckit decides around the agent process (which steps
9
+ # run, what opens a review, the exit code); it does not prove a real agent does the task.
10
+ #
11
+ # Covers: a run from a draft opens one review; a re-run after the review is open reports it and
12
+ # starts no agent; a failing gate opens none and exits 6; a stopped earlier run is discarded and a
13
+ # round that changed nothing opens none (exit 5); the gate precedence --check > tasks.check > none;
14
+ # --no-finish stops before the review; --llm is one JSON object; usage errors.
15
+ # Page tasks (#504): the rule (kind `page`, or tasks.design in the config); the objective names the
16
+ # page-design skill; the review lists exactly the skills the stub's event output shows as loaded,
17
+ # says so when none was, and says "not known" when the output held no event.
18
+ # Run: bash scripts/lib/light-task-run-test.sh
19
+ # errors: strict — a test runner: rc 1 on any failed assertion
20
+ set -u
21
+ LIB="$(cd "$(dirname "$0")" && pwd)"
22
+ CCKIT="$(cd "$LIB/../.." && pwd)/bin/cckit"
23
+ # shellcheck source=/dev/null
24
+ . "$LIB/test-env.sh" && test_env_seal
25
+ unset CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT
26
+ fail=0
27
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
28
+ has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> '[$2]' lacks '[$3]'"; fail=1 ;; esac; }
29
+ hasnt() { case "$2" in *"$3"*) echo "FAIL: $1 -> '[$2]' has '[$3]'"; fail=1 ;; *) echo "ok: $1" ;; esac; }
30
+ command -v jq >/dev/null 2>&1 || { echo "light-task-run-test: jq absent — skipping"; exit 0; }
31
+
32
+ tmp="$(cd "$(mktemp -d)" && pwd -P)"; trap 'rm -rf "$tmp"' EXIT
33
+ export FX="$tmp" GH_LOG="$tmp/gh.log" GH_OPEN_URL=""
34
+ : > "$GH_LOG"
35
+ mkdir -p "$tmp/bin"
36
+
37
+ # The agent stub: reads the prompt on stdin like the real CLIs, then does what STUB_MODE says in
38
+ # the directory it was started in (the task's worktree).
39
+ cat > "$tmp/bin/agent-stub" <<'STUB'
40
+ #!/usr/bin/env bash
41
+ me="$(basename "$0")"
42
+ printf '%s\n' "$*" > "$FX/$me.argv"
43
+ cat > "$FX/$me.prompt"
44
+ pwd > "$FX/$me.cwd"
45
+ n="$(cat "$FX/rounds" 2>/dev/null || echo 0)"; n=$((n + 1)); echo "$n" > "$FX/rounds"
46
+ case "${STUB_MODE:-work}" in
47
+ work) echo "round $n" >> page.txt; git add -A >/dev/null 2>&1; git commit -q -m "round $n"
48
+ echo "made in round $n" > made.txt ;; # left uncommitted: `finish --all` has to carry it
49
+ idle) : ;;
50
+ esac
51
+ # Event output, only when cckit asked for it (`--output-format stream-json`): one Skill call per
52
+ # name in STUB_SKILLS. A name ending in `!` is a call the runtime answered with an error — a skill
53
+ # that is not installed. STUB_EVENTS=0 prints no event at all.
54
+ case "$*" in *stream-json*)
55
+ if [ "${STUB_EVENTS:-1}" = 1 ]; then
56
+ printf '{"type":"system","subtype":"init","skills":["page-design","impeccable","emil-design-eng","web-design-guidelines","concrete"]}\n'
57
+ i=0
58
+ for sk in ${STUB_SKILLS:-}; do
59
+ i=$((i + 1)); err=false
60
+ case "$sk" in *!) sk="${sk%!}"; err=true ;; esac
61
+ printf '{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"t%s","name":"Skill","input":{"skill":"%s"}}]}}\n' "$i" "$sk"
62
+ printf '{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"t%s","is_error":%s,"content":"x"}]}}\n' "$i" "$err"
63
+ done
64
+ printf '{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"I used impeccable, emil-design-eng and web-design-guidelines."}]}}\n'
65
+ fi ;;
66
+ esac
67
+ [ -z "${STUB_BRIEF:-}" ] || { mkdir -p docs/design; echo brief > "docs/design/$STUB_BRIEF.md"; }
68
+ printf '{"type":"result","total_cost_usd":0.01,"usage":{"input_tokens":100,"output_tokens":50}}\n'
69
+ STUB
70
+ chmod +x "$tmp/bin/agent-stub"
71
+ cp "$tmp/bin/agent-stub" "$tmp/bin/claude"; cp "$tmp/bin/agent-stub" "$tmp/bin/codex"
72
+
73
+ cat > "$tmp/bin/gh" <<'SH'
74
+ #!/usr/bin/env bash
75
+ { printf '%s' "$*" | tr '\n' '\036'; echo; } >> "$GH_LOG"
76
+ case "$1 $2" in
77
+ "pr list") case " $* " in *" --head "*) [ -n "$GH_OPEN_URL" ] && echo "$GH_OPEN_URL" ;; esac ;;
78
+ "pr create") echo "https://github.com/o/r/pull/77" ;;
79
+ *) exit 0 ;;
80
+ esac
81
+ SH
82
+ chmod +x "$tmp/bin/gh"
83
+ export PATH="$tmp/bin:$PATH" KIT_WT_INSTALL=0 KIT_STATE_DIR="$tmp/state"
84
+
85
+ git init -q --bare "$tmp/remote.git"
86
+ git clone -q "$tmp/remote.git" "$tmp/work" 2>/dev/null
87
+ cd "$tmp/work" || exit 1
88
+ git config user.email t@t; git config user.name t; git config commit.gpgsign false
89
+ cat > cckit.config.json <<'JSON'
90
+ {"kitVersion":"0.0.0","project":{"name":"x","slug":"x","owner":"o","language":"en"},"profile":"p",
91
+ "github":{"repo":"o/r","owner":"o","baseBranch":"develop","projectsV2":false}}
92
+ JSON
93
+ echo "hello" > page.txt
94
+ printf '.claude/worktrees/\n.cckit/\n' > .gitignore
95
+ git add -A; git commit -q -m init; git branch -M develop; git push -q origin develop 2>/dev/null
96
+ W="$tmp/work"
97
+
98
+ creates() { grep -c '^pr create' "$GH_LOG" || true; }
99
+ rounds() { cat "$tmp/rounds" 2>/dev/null || echo 0; }
100
+ state() { "$CCKIT" task list --all --llm | jq -r --arg id "$1" '.[] | select(.id == $id) | .state'; }
101
+
102
+ # ── usage errors start nothing ──────────────────────────────────────────────────────────────────
103
+ "$CCKIT" task run >/dev/null 2>&1; t "run without an id is a usage error" "$?" "2"
104
+ "$CCKIT" task run x1 --max-iters 0 >/dev/null 2>&1; t "a zero limit is a usage error" "$?" "2"
105
+ "$CCKIT" task run x1 --check >/dev/null 2>&1; t "--check without a value is a usage error" "$?" "2"
106
+ "$CCKIT" task run x1 --nope >/dev/null 2>&1; t "an unknown flag is a usage error" "$?" "2"
107
+ "$CCKIT" task run zz9 >/dev/null 2>&1; t "an unknown task is refused" "$?" "1"
108
+ t "none of them started an agent" "$(rounds)" "0"
109
+
110
+ # ── from a draft to one review ──────────────────────────────────────────────────────────────────
111
+ A="$("$CCKIT" task new --body "Three sections: hero, menu, contact." "Landing page for a bakery" --llm | jq -r .id)"
112
+ out="$("$CCKIT" task run "$A" --check "test -f made.txt" 2>"$tmp/run.err")"; t "run from a draft exits 0" "$?" "0"
113
+ t "stdout is the review link" "$out" "✓ https://github.com/o/r/pull/77"
114
+ WT="$W/.claude/worktrees/light+$A-landing-page-for-a-bakery"
115
+ BR="light/$A-landing-page-for-a-bakery"
116
+ t "the agent ran once" "$(rounds)" "1"
117
+ t "the agent ran in the task's worktree" "$(cat "$tmp/claude.cwd")" "$WT"
118
+ t "the agent was started headless" "$(cat "$tmp/claude.argv")" "-p --output-format json"
119
+ has "the objective carries the task title" "$(cat "$tmp/claude.prompt")" "Do this task: Landing page for a bakery"
120
+ has "the objective carries the task notes" "$(cat "$tmp/claude.prompt")" "Three sections: hero, menu, contact."
121
+ has "the objective names the task record" "$(cat "$tmp/claude.prompt")" "tasks/$A.md"
122
+ hasnt "a task that is not a page task is not told to use page-design" "$(cat "$tmp/claude.prompt")" "page-design"
123
+ hasnt "and its review has no design section" "$(grep '^pr create' "$GH_LOG")" "## Design"
124
+ hasnt "and no open-the-page item" "$(grep '^pr create' "$GH_LOG")" "Open the page"
125
+ t "exactly one review was opened" "$(creates)" "1"
126
+ has "the review targets the base branch from the task branch" "$(grep '^pr create' "$GH_LOG")" "--base develop --head $BR"
127
+ has "its title ends in the task id" "$(grep '^pr create' "$GH_LOG")" "--title feat: Landing page for a bakery [$A]"
128
+ t "the pushed branch says the task is done" "$(git --git-dir="$tmp/remote.git" show "$BR:tasks/$A.md" | sed -n 3p)" "status: done"
129
+ t "a file the agent left uncommitted is in the review" "$(git --git-dir="$tmp/remote.git" show "$BR:made.txt")" "made in round 1"
130
+ t "the draft moved off the starting checkout" "$([ -f "$W/tasks/$A.md" ] && echo left || echo moved)" "moved"
131
+ t "the task lists as review" "$(state "$A")" "review"
132
+ t "nothing was merged: the base branch is unchanged" "$(git --git-dir="$tmp/remote.git" rev-parse develop)" "$(git rev-parse develop)"
133
+ has "the run says which gate it used" "$(cat "$tmp/run.err")" "gate: test -f made.txt"
134
+
135
+ # ── re-running once the review is open reports it and creates nothing ───────────────────────────
136
+ : > "$GH_LOG"
137
+ out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" task run "$A" 2>"$tmp/rerun.err")"; t "a re-run exits 0" "$?" "0"
138
+ t "a re-run prints the open review" "$out" "✓ https://github.com/o/r/pull/77"
139
+ t "a re-run starts no agent" "$(rounds)" "1"
140
+ t "a re-run opens no second review" "$(creates)" "0"
141
+ has "a re-run says no round ran" "$(cat "$tmp/rerun.err")" "no agent round"
142
+ out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" task run "$A" --llm)"
143
+ t "--llm is one JSON object: verb, ok, id, url" "$(printf '%s' "$out" | jq -r '[.verb, .ok, .id, .url] | join(" ")')" \
144
+ "task run true $A https://github.com/o/r/pull/77"
145
+
146
+ # ── a failing gate opens no review and exits 6 ──────────────────────────────────────────────────
147
+ B="$("$CCKIT" task new "Pricing table" --llm | jq -r .id)"
148
+ : > "$GH_LOG"; rm -f "$tmp/rounds"
149
+ out="$("$CCKIT" task run "$B" --check "echo gate-red; exit 1" 2>&1)"; t "a failing gate exits 6" "$?" "6"
150
+ t "a failing gate opens no review" "$(creates)" "0"
151
+ has "the last line says no review was opened, and why" "$(printf '%s\n' "$out" | tail -n 1)" "no review was opened — the run stopped with exit 6 (reason=check-failed"
152
+ t "the round did run" "$(rounds)" "1"
153
+ t "the task is still doing" "$(state "$B")" "doing"
154
+ WTB="$W/.claude/worktrees/light+$B-pricing-table"
155
+ t "the work is kept on the task branch" "$(git -C "$WTB" log -1 --format=%s)" "round 1"
156
+ t "the branch copy does not say done" "$(git -C "$WTB" show "HEAD:tasks/$B.md" | sed -n 3p)" "status: todo"
157
+
158
+ # ── the stopped run is discarded; a round that changed nothing opens no review ──────────────────
159
+ out="$(STUB_MODE=idle "$CCKIT" task run "$B" --llm 2>/dev/null)"; t "a round that changed nothing exits 5, not the refusal 2" "$?" "5"
160
+ t "the stopped earlier run did not block the new one" "$(rounds)" "2"
161
+ t "--llm reports the failure" "$(printf '%s' "$out" | jq -r '[.verb, .ok, .id, .url] | join(" ")')" "task run false $B "
162
+ has "the detail carries the reason" "$(printf '%s' "$out" | jq -r .detail)" "reason=no-progress"
163
+ has "and says how to retry" "$(printf '%s' "$out" | jq -r .detail)" "cckit task run $B"
164
+ t "a no-change round opens no review" "$(creates)" "0"
165
+
166
+ # ── gate precedence: tasks.check from the config, --check over it, --no-finish ──────────────────
167
+ jq --arg c "echo config-gate > '$tmp/gate.ran'" '.tasks = {check: $c}' "$W/cckit.config.json" > "$tmp/check.config.json"
168
+ C="$("$CCKIT" task new "Footer links" --llm | jq -r .id)"
169
+ : > "$GH_LOG"
170
+ out="$(KIT_CONFIG="$tmp/check.config.json" "$CCKIT" task run "$C" --no-finish --agent codex --max-seconds 60 2>"$tmp/nf.err")"
171
+ t "--no-finish exits 0" "$?" "0"
172
+ WTC="$W/.claude/worktrees/light+$C-footer-links"
173
+ t "--no-finish prints worktree|branch|id" "$out" "$WTC|light/$C-footer-links|$C"
174
+ t "with no --check the gate is tasks.check" "$(cat "$tmp/gate.ran" 2>/dev/null)" "config-gate"
175
+ t "--agent picks the CLI" "$(cat "$tmp/codex.cwd" 2>/dev/null)" "$WTC"
176
+ t "--no-finish opens no review" "$(creates)" "0"
177
+ t "--no-finish leaves the task doing" "$(state "$C")" "doing"
178
+ has "--no-finish names the command that sends it for review" "$(cat "$tmp/nf.err")" "cckit task finish $C"
179
+ rm -f "$tmp/gate.ran"
180
+ out="$(KIT_CONFIG="$tmp/check.config.json" "$CCKIT" task run "$C" --check "true" 2>/dev/null)"; t "a second run of the same task exits 0" "$?" "0"
181
+ t "--check wins over tasks.check" "$([ -f "$tmp/gate.ran" ] && echo config || echo flag)" "flag"
182
+ t "that run opens the review" "$(creates)" "1"
183
+ D="$("$CCKIT" task new "Contact form" --llm | jq -r .id)"
184
+ "$CCKIT" task run "$D" --no-finish >/dev/null 2>"$tmp/none.err"; t "a run with no gate anywhere exits 0" "$?" "0"
185
+ has "and says there is no gate" "$(cat "$tmp/none.err")" "gate: none"
186
+
187
+ # ── page tasks (#504) ───────────────────────────────────────────────────────────────────────────
188
+ body() { grep '^pr create' "$GH_LOG" | tail -n 1; }
189
+ sfile() { printf '%s/state/autopilot/light_%s-%s.json' "$tmp" "$1" "$2"; }
190
+
191
+ # kind `page`: the objective names the skill, the run records skills, the review lists exactly the
192
+ # ones whose call returned without an error. The agent's own sentence ("I used impeccable,
193
+ # emil-design-eng and web-design-guidelines") is in the output and must not reach the review.
194
+ P="$("$CCKIT" task new --kind page "Bakery landing" --llm | jq -r .id)"
195
+ : > "$GH_LOG"
196
+ out="$(STUB_SKILLS="impeccable page-design concrete emil-design-eng!" STUB_BRIEF="$P" "$CCKIT" task run "$P" 2>"$tmp/page.err")"
197
+ t "a page task run exits 0" "$?" "0"
198
+ t "a page task starts claude with event output" "$(cat "$tmp/claude.argv")" "-p --output-format stream-json --verbose"
199
+ has "the objective names the page-design skill" "$(cat "$tmp/claude.prompt")" 'load the `page-design` skill'
200
+ has "the objective names the design file" "$(cat "$tmp/claude.prompt")" "docs/design/$P.md"
201
+ has "the objective forbids live mode" "$(cat "$tmp/claude.prompt")" 'do not start the live mode of `impeccable`'
202
+ t "the state file holds the loaded skills, and only those" \
203
+ "$(jq -c '.skills | [.loaded, .complete]' "$(sfile "$P" bakery-landing)")" '[["concrete","impeccable","page-design"],true]'
204
+ has "the review lists exactly the design skills that loaded" "$(body)" "Design skills loaded in this run: page-design, impeccable."
205
+ has "a skill whose call failed is listed as not loaded" "$(body)" "Design skills not loaded in this run: emil-design-eng, web-design-guidelines."
206
+ has "other loaded skills are listed apart" "$(body)" "Other skills loaded in this run: concrete."
207
+ hasnt "the agent's own claim is not in the review" "$(body)" "I used impeccable"
208
+ has "the review says where the list comes from" "$(body)" "Read from the events the agent CLI (claude) printed during the run"
209
+ has "the review asks the reviewer to open the page" "$(body)" "- [ ] Open the page in a browser and compare it with the design brief"
210
+ has "the review names the design brief" "$(body)" "Design brief and self-review: \`docs/design/$P.md\`."
211
+ has "a project without the skill is told so" "$(cat "$tmp/page.err")" "the page-design skill is not in this project"
212
+ t "usage is still read from the event output" "$(jq -r '.usage.tokens' "$(sfile "$P" bakery-landing)")" "150"
213
+
214
+ # A run that loaded no skill says so; so does a missing brief.
215
+ Q="$("$CCKIT" task new --kind page "Menu page" --llm | jq -r .id)"
216
+ : > "$GH_LOG"
217
+ mkdir -p "$W/.claude/skills/page-design"; echo x > "$W/.claude/skills/page-design/SKILL.md"
218
+ git -C "$W" add -A; git -C "$W" commit -q -m "add the skill"; git -C "$W" push -q origin develop 2>/dev/null
219
+ STUB_SKILLS="" "$CCKIT" task run "$Q" >/dev/null 2>"$tmp/q.err"; t "a page run that loads nothing still exits 0" "$?" "0"
220
+ has "a run that loaded no design skill says so" "$(body)" "No design skill was loaded in this run."
221
+ has "and names all four as not loaded" "$(body)" "Design skills not loaded in this run: page-design, impeccable, emil-design-eng, web-design-guidelines."
222
+ hasnt "and lists none as loaded" "$(body)" "Design skills loaded in this run"
223
+ has "a missing brief is said, not assumed" "$(body)" "No design brief is in this change: \`docs/design/$Q.md\` was not written."
224
+ hasnt "a project that has the skill gets no warning" "$(cat "$tmp/q.err")" "is not in this project"
225
+
226
+ # No event in the output: the list is not known, which is not the same as empty.
227
+ R="$("$CCKIT" task new --kind page "About page" --llm | jq -r .id)"
228
+ : > "$GH_LOG"
229
+ STUB_EVENTS=0 "$CCKIT" task run "$R" >/dev/null 2>&1; t "a run with no event output exits 0" "$?" "0"
230
+ has "no event output reads as not known" "$(body)" "Which skills were loaded is not known: the agent CLI printed no event output"
231
+ hasnt "and never as 'none was loaded'" "$(body)" "No design skill was loaded"
232
+ t "the state file marks the list incomplete" "$(jq -r '.skills.complete' "$(sfile "$R" about-page)")" "false"
233
+
234
+ # The config rule: tasks.design makes every task a page task; `task finish` by hand reads the
235
+ # same record.
236
+ jq '.tasks = {design: true}' "$W/cckit.config.json" > "$tmp/design.config.json"
237
+ S="$("$CCKIT" task new "Pricing section" --llm | jq -r .id)"
238
+ : > "$GH_LOG"
239
+ KIT_CONFIG="$tmp/design.config.json" STUB_SKILLS="page-design" "$CCKIT" task run "$S" --no-finish >/dev/null 2>&1
240
+ t "tasks.design: a plain task runs as a page task" "$(cat "$tmp/claude.argv")" "-p --output-format stream-json --verbose"
241
+ has "tasks.design: the objective names page-design" "$(cat "$tmp/claude.prompt")" 'load the `page-design` skill'
242
+ KIT_CONFIG="$tmp/design.config.json" "$CCKIT" task finish "$S" "by hand" --all >/dev/null 2>&1; t "finish by hand exits 0" "$?" "0"
243
+ has "finish by hand prints the recorded skills" "$(body)" "Design skills loaded in this run: page-design."
244
+ "$CCKIT" task run "$D" >/dev/null 2>&1
245
+ hasnt "without tasks.design the same kind of task is not a page task" "$(body)" "## Design"
246
+
247
+ # A page task finished with no run on record does not get a list.
248
+ T="$("$CCKIT" task new --kind page "Contact page" --llm | jq -r .id)"
249
+ "$CCKIT" task start "$T" >/dev/null 2>&1
250
+ : > "$GH_LOG"
251
+ "$CCKIT" task finish "$T" "written by hand" --all >/dev/null 2>&1; t "a page task finished by hand exits 0" "$?" "0"
252
+ has "with no run on record the list is not known" "$(body)" 'Which skills were loaded is not known: no `cckit task run` is recorded for this task.'
253
+
254
+ [ "$fail" -eq 0 ] && echo "PASS light-task-run-test" || echo "FAIL light-task-run-test"
255
+ exit "$fail"