@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
package/scripts/test.sh CHANGED
@@ -1,24 +1,101 @@
1
1
  #!/usr/bin/env bash
2
2
  # test.sh — cckit behavioral test runner. Discovers every `*-test.sh` under bin/ and scripts/ and
3
3
  # runs each as a self-contained test (a test exits non-zero on failure, prints its own ok/FAIL
4
- # lines). Exits non-zero if any test fails. bash 3.2 compatible (no mapfile/associative arrays).
4
+ # lines). Exits non-zero if any test fails. bash 3.2 compatible (no mapfile/associative arrays,
5
+ # no `wait -n`).
5
6
  #
6
- # scripts/test.sh run every discovered test
7
- # scripts/test.sh <pattern> run only tests whose path matches <pattern> (grep -E)
7
+ # scripts/test.sh run every discovered test, several files at a time
8
+ # scripts/test.sh <pattern> run only tests whose path matches <pattern> (grep -E)
9
+ # scripts/test.sh -j <N> run at most N files at once (also: --jobs N, TEST_JOBS=N)
10
+ # scripts/test.sh --serial one file at a time, in sorted order (same as -j 1)
11
+ # scripts/test.sh --timings print wall seconds per file, slowest first (also: TEST_TIMINGS=1)
12
+ #
13
+ # Parallelism (#455). Test files are independent: each builds its fixtures under its own `mktemp -d`
14
+ # and none binds a fixed port, so files run N at a time. N defaults to the CPU count, capped at 8.
15
+ # A file whose first 30 lines carry the marker `# test-runner: serial` is held back and run alone
16
+ # after the parallel phase — for a test that measures a race or a timeout and would read CPU
17
+ # contention as a failure.
18
+ #
19
+ # Output. One `ok` / `FAIL` line per file as it finishes (completion order when N > 1). Each file's
20
+ # output is captured to its own file, so the output of a failing test is printed whole, after the
21
+ # run, in sorted order — never interleaved with another file's.
8
22
  #
9
23
  # Folded into scripts/check.sh and run in CI (.github/workflows/test.yml).
10
24
  set -uo pipefail
11
25
  cd "$(cd "$(dirname "$0")/.." && pwd)"
12
26
 
13
- PATTERN="${1:-}"
14
27
  note() { printf '%s\n' "$*" >&2; }
15
28
 
16
- # Discover tests deterministically. Newline-separated, sorted, optionally filtered.
17
- tests=()
29
+ # ── worker: run ONE test file, record its result ──────────────────────────────────────────────
30
+ # Invoked by the pool below as `test.sh --run-one <index> <file>`. Writes <dir>/<index>.out (the
31
+ # test's combined output), .rc (exit code) and .sec (wall seconds), then prints the one status
32
+ # line. A status line is a single short write, so concurrent workers do not interleave.
33
+ if [ "${1:-}" = "--run-one" ]; then
34
+ idx="$2"; t="$3"; dir="${TEST_RUN_DIR:?--run-one is internal: TEST_RUN_DIR is not set}"
35
+ # Seal the test from the caller's kit environment (#369): a shell that ran load_kit_config, or
36
+ # set KIT_CONFIG, exports KIT_*/CCKIT_*/EFFORT_* that would point a test at the developer's
37
+ # project instead of its own fixture. Each test still sets whatever it needs itself.
38
+ # shellcheck source=/dev/null
39
+ . scripts/lib/test-env.sh
40
+ seal=(-u TEST_RUN_DIR)
41
+ while IFS= read -r a; do [ -n "$a" ] && seal+=("$a"); done < <(test_env_unset_args)
42
+ # Fixture commits are never signed (#455). A developer whose global git config sets
43
+ # commit.gpgsign pays one gpg call per fixture commit (measured: 60 commits took 12.9 s signed,
44
+ # 2.8 s unsigned), and gpg-agent refuses concurrent requests ("signing failed: Cannot allocate
45
+ # memory"), which fails a fixture at random once files run in parallel. GIT_CONFIG_COUNT is git's
46
+ # environment form of `-c`: it overrides these two keys and leaves the rest of the developer's
47
+ # config, identity included, as it is. Appended after any pairs the caller already exported.
48
+ gc_n="${GIT_CONFIG_COUNT:-0}"; case "$gc_n" in ''|*[!0-9]*) gc_n=0 ;; esac
49
+ start=$SECONDS
50
+ env "${seal[@]}" \
51
+ GIT_CONFIG_COUNT="$((gc_n + 2))" \
52
+ "GIT_CONFIG_KEY_$gc_n=commit.gpgsign" "GIT_CONFIG_VALUE_$gc_n=false" \
53
+ "GIT_CONFIG_KEY_$((gc_n + 1))=tag.gpgsign" "GIT_CONFIG_VALUE_$((gc_n + 1))=false" \
54
+ bash "$t" > "$dir/$idx.out" 2>&1; rc=$?
55
+ sec=$((SECONDS - start))
56
+ printf '%s\n' "$sec" > "$dir/$idx.sec"
57
+ printf '%s\n' "$rc" > "$dir/$idx.rc"
58
+ if [ "$rc" -eq 0 ]; then note " ok $t"; else note " FAIL $t (rc=$rc)"; fi
59
+ exit 0 # the result is in .rc; a non-zero exit here would make xargs stop feeding the pool
60
+ fi
61
+
62
+ # ── arguments ─────────────────────────────────────────────────────────────────────────────────
63
+ PATTERN=""; JOBS="${TEST_JOBS:-}"; TIMINGS="${TEST_TIMINGS:-0}"
64
+ while [ "$#" -gt 0 ]; do
65
+ case "$1" in
66
+ -j|--jobs) [ "$#" -ge 2 ] || { note "test: $1 needs a number"; exit 2; }; JOBS="$2"; shift 2 ;;
67
+ --jobs=*) JOBS="${1#--jobs=}"; shift ;;
68
+ -j[0-9]*) JOBS="${1#-j}"; shift ;;
69
+ --serial) JOBS=1; shift ;;
70
+ --timings) TIMINGS=1; shift ;;
71
+ -*) note "test: unknown option '$1'"; exit 2 ;;
72
+ *) PATTERN="$1"; shift ;;
73
+ esac
74
+ done
75
+
76
+ # Default job count: the CPU count, capped at 8 (past that the git-heavy fixtures contend on disk).
77
+ if [ -z "$JOBS" ]; then
78
+ JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
79
+ case "$JOBS" in ''|*[!0-9]*) JOBS=2 ;; esac
80
+ [ "$JOBS" -le 8 ] || JOBS=8
81
+ fi
82
+ case "$JOBS" in
83
+ ''|*[!0-9]*|0) note "test: job count must be a positive integer, got '$JOBS'"; exit 2 ;;
84
+ esac
85
+
86
+ # ── discovery ─────────────────────────────────────────────────────────────────────────────────
87
+ # Deterministic: newline-separated, sorted, optionally filtered. `par` runs in the pool; `ser` is
88
+ # held back for the serial phase (see the marker in the header).
89
+ tests=(); par=(); ser=()
18
90
  while IFS= read -r f; do
19
91
  [ -n "$f" ] || continue
20
- [ -z "$PATTERN" ] || printf '%s\n' "$f" | grep -qE "$PATTERN" || continue
92
+ [ -z "$PATTERN" ] || grep -qE "$PATTERN" <<<"$f" || continue
21
93
  tests+=("$f")
94
+ if [ "$JOBS" -gt 1 ] && grep -qE '^# test-runner: serial([[:space:]]|$)' <<<"$(head -n 30 "$f")"; then
95
+ ser+=("$f")
96
+ else
97
+ par+=("$f")
98
+ fi
22
99
  done < <(find bin scripts -type f -name '*-test.sh' 2>/dev/null | sort)
23
100
 
24
101
  if [ "${#tests[@]}" -eq 0 ]; then
@@ -26,30 +103,61 @@ if [ "${#tests[@]}" -eq 0 ]; then
26
103
  exit 0
27
104
  fi
28
105
 
29
- note "==> cckit tests — ${#tests[@]} file(s)${PATTERN:+ (filter: $PATTERN)}"
30
- # Seal every test from the caller's kit environment (#369): a shell that ran load_kit_config, or set
31
- # KIT_CONFIG, exports KIT_*/CCKIT_*/EFFORT_* that would point a test at the developer's project
32
- # instead of its own fixture. Each test still sets whatever it needs itself.
33
106
  # shellcheck source=/dev/null
34
107
  . scripts/lib/test-env.sh
35
- seal=()
36
- while IFS= read -r a; do [ -n "$a" ] && seal+=("$a"); done < <(test_env_unset_args)
37
- [ "${#seal[@]}" -eq 0 ] || note "==> sealed $(( ${#seal[@]} / 2 )) inherited KIT_*/CCKIT_*/EFFORT_* variable(s)"
38
-
39
- pass=0; failn=0; failed=""
40
- for t in "${tests[@]}"; do
41
- out="$(env ${seal[@]+"${seal[@]}"} bash "$t" 2>&1)"; rc=$?
42
- if [ "$rc" -eq 0 ]; then
43
- pass=$((pass+1)); note " ok $t"
108
+ sealed="$(test_env_unset_args | grep -c -- '^-u$')"
109
+
110
+ RUN_DIR="$(mktemp -d "${TMPDIR:-/tmp}/cckit-test.XXXXXX")" || { note "test: mktemp failed"; exit 1; }
111
+ trap 'rm -rf "$RUN_DIR"' EXIT
112
+ export TEST_RUN_DIR="$RUN_DIR"
113
+
114
+ note "==> cckit tests — ${#tests[@]} file(s)${PATTERN:+ (filter: $PATTERN)}, $JOBS at a time"
115
+ [ "$sealed" -eq 0 ] || note "==> sealed $sealed inherited KIT_*/CCKIT_*/EFFORT_* variable(s)"
116
+
117
+ # ── run ───────────────────────────────────────────────────────────────────────────────────────
118
+ # The pool is xargs -P: it is in POSIX-era BSD and GNU alike, and bash 3.2 has no `wait -n` to
119
+ # build one from. Each line fed to it is "<index> <file>"; the index keys the result files, so a
120
+ # result is found again without a map (test paths under bin/ and scripts/ hold no whitespace).
121
+ began=$SECONDS
122
+ i=0; list=""
123
+ for t in ${par[@]+"${par[@]}"}; do list="$list$i $t"$'\n'; i=$((i+1)); done
124
+ if [ -n "$list" ]; then
125
+ printf '%s' "$list" | xargs -P "$JOBS" -n 2 bash scripts/test.sh --run-one
126
+ fi
127
+ if [ "${#ser[@]}" -gt 0 ]; then
128
+ note "==> ${#ser[@]} file(s) marked serial, run alone"
129
+ for t in "${ser[@]}"; do bash scripts/test.sh --run-one "$i" "$t"; i=$((i+1)); done
130
+ fi
131
+ took=$((SECONDS - began))
132
+
133
+ # ── collect ───────────────────────────────────────────────────────────────────────────────────
134
+ # Read the results back in the order they were queued (sorted, parallel files then serial ones).
135
+ # A file with no .rc never reported — its worker was killed — and counts as a failure.
136
+ pass=0; failn=0; failed=""; i=0
137
+ for t in ${par[@]+"${par[@]}"} ${ser[@]+"${ser[@]}"}; do
138
+ rc="$(cat "$RUN_DIR/$i.rc" 2>/dev/null)"; [ -n "$rc" ] || rc="no result"
139
+ if [ "$rc" = 0 ]; then
140
+ pass=$((pass+1))
44
141
  else
45
142
  failn=$((failn+1)); failed="$failed$t"$'\n'
46
- note " FAIL $t (rc=$rc)"
47
- printf '%s\n' "$out" | sed 's/^/ /' >&2
143
+ note ""
144
+ note "---- FAIL $t (rc=$rc)"
145
+ [ ! -f "$RUN_DIR/$i.out" ] || sed 's/^/ /' "$RUN_DIR/$i.out" >&2
48
146
  fi
147
+ i=$((i+1))
49
148
  done
50
149
 
150
+ if [ "$TIMINGS" = 1 ]; then
151
+ note ""
152
+ note "==> wall seconds per file, slowest first"
153
+ i=0
154
+ for t in ${par[@]+"${par[@]}"} ${ser[@]+"${ser[@]}"}; do
155
+ printf '%s\t%s\n' "$(cat "$RUN_DIR/$i.sec" 2>/dev/null || echo '?')" "$t"; i=$((i+1))
156
+ done | sort -t "$(printf '\t')" -k1,1nr -k2,2 | sed 's/^/ /' >&2
157
+ fi
158
+
51
159
  note ""
52
- note "==> $pass passed, $failn failed"
160
+ note "==> $pass passed, $failn failed in ${took}s"
53
161
  if [ "$failn" -ne 0 ]; then
54
162
  note "failed:"; printf '%s' "$failed" | sed 's/^/ - /' >&2
55
163
  exit 1
@@ -0,0 +1,279 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # update-path-test.sh — the documented update path, end to end (#448).
4
+ #
5
+ # Builds a project the way an OLDER cckit left it (a `task-*` skill dir, a config at an earlier
6
+ # kitVersion in the project's own formatting, a tracked settings.json that predates the mail hook),
7
+ # adds the customizations a real project has (an edited rule, hook, script and CLAUDE.md, paths
8
+ # registered under `upgrade.removed`), and runs the path docs-site/src/content/docs/getting-started/update.mdx
9
+ # gives a user, through bin/cckit:
10
+ #
11
+ # cckit update -> cckit migrate -> cckit init --upgrade --dry-run -> cckit init --upgrade
12
+ # -> cckit update -> cckit init --upgrade (again)
13
+ #
14
+ # It asserts the five defects a trial run on a real project found (the issue's comment) stay fixed:
15
+ # 1. the dry run's list IS the real run's list — both equal an independent before/after checksum
16
+ # of the whole tree;
17
+ # 2. a version bump changes ONE line of the config;
18
+ # 3. `cckit update` names `cckit init --upgrade`, not only the slash command;
19
+ # 4. (cckit doctor installing with no flag is covered in kit-doctor-test.sh);
20
+ # 5. a settings.json the upgrade merges into is reported modified, not preserved, and a hook
21
+ # registration the project arranged is not moved.
22
+ # And: customizations kept, removed paths not re-added, a second run changes nothing, and every
23
+ # command on the docs page is one this file runs.
24
+ #
25
+ # Network-free: the upgrade path skips the doctor preflight; every value gh would be asked for is in
26
+ # the fixture config. Everything lives under one mktemp dir. Run: bash scripts/update-path-test.sh
27
+ # errors: strict — a test runner: rc 1 on any failed assertion
28
+ set -u
29
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
30
+ # shellcheck source=/dev/null
31
+ . "$ROOT/scripts/lib/test-env.sh" && test_env_seal
32
+ CCKIT="$ROOT/bin/cckit"
33
+ PAGE="$ROOT/docs-site/src/content/docs/getting-started/update.mdx"
34
+ fail=0
35
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
36
+ has() { if grep -qF -- "$3" <<<"$2"; then echo "ok: $1"; else echo "FAIL: $1 -> '$3' not in: $2"; fail=1; fi; }
37
+ hasnt() { if grep -qF -- "$3" <<<"$2"; then echo "FAIL: $1 -> '$3' found in: $2"; fail=1; else echo "ok: $1"; fi; }
38
+
39
+ command -v jq >/dev/null 2>&1 || { echo "update-path-test: jq absent — skipping"; exit 0; }
40
+ command -v git >/dev/null 2>&1 || { echo "update-path-test: git absent — skipping"; exit 0; }
41
+ command -v perl >/dev/null 2>&1 || { echo "update-path-test: perl absent — skipping"; exit 0; }
42
+
43
+ INSTALLED="$(jq -r '.version // "0.0.0"' "$ROOT/.claude-plugin/plugin.json")"
44
+ OLD="0.0.7" # any version below the installed one
45
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
46
+ tmp="$(cd "$tmp" && pwd)"
47
+ proj="$tmp/sample-app"; mkdir -p "$proj"
48
+ export KIT_ASSUME_YES=1 KIT_ASCII=1 NO_COLOR=1
49
+ unset CLAUDE_PLUGIN_ROOT
50
+
51
+ # tree <file> — "<path>\t<cksum>" for EVERY file of the project outside .git. Independent of the
52
+ # measurement init.sh itself takes (scripts/lib/upgrade-report.sh), which is the thing under test.
53
+ tree() {
54
+ ( cd "$proj" && find . -name .git -prune -o -type f -print | LC_ALL=C sort | while IFS= read -r f; do
55
+ printf '%s\t%s\n' "${f#./}" "$(cksum < "$f" | tr ' ' ':')"
56
+ done ) > "$1"
57
+ }
58
+ # delta <before> <after> — "A <path>" / "M <path>" lines, sorted by path.
59
+ delta() {
60
+ awk -F'\t' 'NR==FNR { b[$1]=$2; next } !($1 in b) { print "A " $1; next } b[$1] != $2 { print "M " $1 }' "$1" "$2" \
61
+ | LC_ALL=C sort -k2
62
+ }
63
+ # block <output> <heading> — the "A path" / "M path" rows init.sh printed under <heading>.
64
+ block() {
65
+ printf '%s\n' "$1" | awk -v h="$2" '
66
+ index($0, " " h " (") == 1 { on = 1; next }
67
+ on && /^ [AMD] / { sub(/^ /, ""); print; next }
68
+ on { on = 0 }' | LC_ALL=C sort -k2
69
+ }
70
+ commit() { git -C "$proj" add -A >/dev/null 2>&1 && git -C "$proj" commit -q -m "$1" >/dev/null 2>&1; }
71
+
72
+ # ── the fixture: a project as an older cckit left it ───────────────────────────────────────────
73
+ git -C "$proj" init -q
74
+ git -C "$proj" config user.email fixture@example.invalid
75
+ git -C "$proj" config user.name fixture
76
+ git -C "$proj" config commit.gpgsign false
77
+ mkdir -p "$proj/.claude/skills/task-pr" "$proj/.claude/rules" "$proj/.claude/hooks" "$proj/scripts"
78
+
79
+ # The config in the project's OWN formatting: inline arrays, and `review` / `nightGrant` (keys no
80
+ # template writes) ahead of `milestones`. jq would expand the arrays and reorder nothing here, so a
81
+ # whole-file rewrite shows up as many changed lines.
82
+ cat > "$proj/.claude/kit.config.json" <<JSON
83
+ {
84
+ "kitVersion": "$OLD",
85
+ "profile": "minimal",
86
+ "project": { "name": "Sample App", "slug": "sample-app", "owner": "sample-owner", "language": "English", "path": "$proj" },
87
+ "roles": ["PM", "Generalist"],
88
+ "github": { "repo": "example/sample-app", "owner": "example", "baseBranch": "develop", "projectsV2": false, "projectNumber": null, "projectTitle": "Sample App" },
89
+ "review": { "bots": ["one", "two"], "required": 1 },
90
+ "nightGrant": { "waves": [1, 2] },
91
+ "milestones": ["Backlog", "Doing", "Done"],
92
+ "knowledge": { "dir": "knowledge" },
93
+ "upgrade": {
94
+ "removed": [".claude/rules/task-management.md", "scripts/task-sync.sh"]
95
+ }
96
+ }
97
+ JSON
98
+ CFG_BEFORE="$(jq -S . "$proj/.claude/kit.config.json")"
99
+
100
+ # Old layout: a bare `task-*` skill (v2 names it `kit-task-*`) and a CLAUDE.md that refers to it.
101
+ printf 'the project edited this skill\n' > "$proj/.claude/skills/task-pr/SKILL.md"
102
+ printf '# Sample App\n\nOPERATOR-NOTE: open the PR with /task-pr.\n' > "$proj/CLAUDE.md"
103
+ # Customizations an upgrade must keep.
104
+ printf '# Communication\n\nOPERATOR-NOTE: answer in two lines.\n' > "$proj/.claude/rules/communication-style.md"
105
+ printf '#!/usr/bin/env bash\n# OPERATOR-NOTE: our own hygiene report\nexit 0\n' > "$proj/.claude/hooks/repo-hygiene.sh"
106
+ chmod +x "$proj/.claude/hooks/repo-hygiene.sh"
107
+ printf '#!/usr/bin/env bash\n# OPERATOR-NOTE: our own labels\n' > "$proj/scripts/setup-labels.sh"
108
+ # A tracked settings.json from before the mail hook existed. The raw-git guard sits INSIDE a Bash
109
+ # block the project shares with its own hook — the arrangement the upgrade used to break up.
110
+ cat > "$proj/.claude/settings.json" <<'JSON'
111
+ {
112
+ "permissions": { "allow": ["Bash(cckit merge:*)"] },
113
+ "hooks": {
114
+ "PreToolUse": [
115
+ { "matcher": "Bash", "hooks": [
116
+ { "type": "command", "command": "$CLAUDE_PROJECT_DIR/scripts/own-guard.sh", "timeout": 5 },
117
+ { "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/guard-raw-git-ops.sh", "timeout": 10 }
118
+ ] }
119
+ ]
120
+ }
121
+ }
122
+ JSON
123
+ commit "a project scaffolded by an older cckit"
124
+
125
+ run() { ( cd "$proj" && "$@" ) 2>&1; } # every step runs inside the project, as the docs page says
126
+
127
+ # ── 1. which version is the project on? ────────────────────────────────────────────────────────
128
+ out="$(run "$CCKIT" update)"; rc=$?
129
+ t "cckit update on a project that is behind -> exit 10" "$rc" "10"
130
+ has "…names both versions" "$out" "$OLD -> $INSTALLED"
131
+ has "…names the terminal command, not only the slash command" "$out" "cckit init --upgrade"
132
+ has "…still names the Claude Code command" "$out" "/kit-update"
133
+
134
+ # ── 2. old layout -> v2 ────────────────────────────────────────────────────────────────────────
135
+ tree "$tmp/t0"
136
+ out="$(run "$CCKIT" migrate --dry-run)"; rc=$?
137
+ t "cckit migrate --dry-run -> exit 0" "$rc" "0"
138
+ tree "$tmp/t1"
139
+ t "cckit migrate --dry-run writes nothing" "$(delta "$tmp/t0" "$tmp/t1")" ""
140
+ has "…and names the move it would make" "$out" ".claude/skills/task-pr -> .claude/skills/kit-task-pr"
141
+ out="$(run "$CCKIT" migrate)"; rc=$?
142
+ t "cckit migrate -> exit 0" "$rc" "0"
143
+ t "old skill dir moved to its v2 name, content kept" \
144
+ "$([ -e "$proj/.claude/skills/task-pr" ] && echo old-present; cat "$proj/.claude/skills/kit-task-pr/SKILL.md" 2>/dev/null)" \
145
+ "the project edited this skill"
146
+ t "the rename is registered so the upgrade never re-adds the old path" \
147
+ "$(jq -r '.upgrade.renamed[".claude/skills/task-pr"] // "MISS"' "$proj/.claude/kit.config.json")" ".claude/skills/kit-task-pr"
148
+ t "CLAUDE.md now names the v2 command" "$(grep -c '/kit-task-pr' "$proj/CLAUDE.md")" "1"
149
+ rm -rf "$proj"/.claude.bak.* # the migrate backup; the docs page says to delete or ignore it
150
+ out="$(run "$CCKIT" migrate)"
151
+ has "a second cckit migrate is a no-op" "$out" "already on v2"
152
+ # The config as the project commits it before upgrading: migrate re-serialised it (it added a key).
153
+ # Restore the project's formatting so step 4 measures the upgrade's own footprint on the file.
154
+ jq -c . "$proj/.claude/kit.config.json" > "$tmp/cfg.min"
155
+ perl -0777 -pe 's/\{"kitVersion"/{\n "kitVersion"/; s/","profile"/",\n "profile"/; s/\}$/\n}/' "$tmp/cfg.min" > "$proj/.claude/kit.config.json"
156
+ t "fixture: the reformatted config is the same value" "$(jq -S . "$proj/.claude/kit.config.json")" "$(jq -S . "$tmp/cfg.min")"
157
+ commit "migrate to the v2 layout"
158
+ t "git status --short is empty before the upgrade" "$(run git status --short)" ""
159
+
160
+ # ── 3. the dry run ─────────────────────────────────────────────────────────────────────────────
161
+ tree "$tmp/t2"
162
+ dry="$(run "$CCKIT" init --upgrade --dry-run)"; rc=$?
163
+ t "cckit init --upgrade --dry-run -> exit 0" "$rc" "0"
164
+ tree "$tmp/t3"
165
+ t "the dry run writes nothing to the project" "$(delta "$tmp/t2" "$tmp/t3")" ""
166
+ t "the dry run leaves the tree clean" "$(run git status --short)" ""
167
+ dry_list="$(block "$dry" "Would change")"
168
+ has "the dry run lists the excluded paths as skipped" "$dry" "- scripts/task-sync.sh"
169
+ hasnt "the dry run does not claim it would write an excluded rule" "$dry_list" "task-management.md"
170
+ hasnt "the dry run does not claim it would write an excluded script" "$dry_list" "scripts/task-sync.sh"
171
+ hasnt "the dry run does not list a customized file it will keep" "$dry_list" "communication-style.md"
172
+
173
+ # ── 4. the upgrade ─────────────────────────────────────────────────────────────────────────────
174
+ real="$(run "$CCKIT" init --upgrade)"; rc=$?
175
+ t "cckit init --upgrade -> exit 0" "$rc" "0"
176
+ tree "$tmp/t4"
177
+ truth="$(delta "$tmp/t3" "$tmp/t4")"
178
+ real_list="$(block "$real" "Changed on disk")"
179
+ t "the upgrade changed something (the fixture is behind)" "$([ -n "$truth" ] && echo yes || echo no)" "yes"
180
+ t "defect 1: the dry run's list equals what the run changed on disk" "$dry_list" "$truth"
181
+ t "defect 1: the run's own list equals what it changed on disk" "$real_list" "$truth"
182
+ t "the counts in the heading match the list" \
183
+ "$(printf '%s\n' "$real" | grep -F 'Changed on disk (' | sed 's/^ *//')" \
184
+ "Changed on disk ($(printf '%s\n' "$truth" | grep -c '^A ') added, $(printf '%s\n' "$truth" | grep -c '^M ') modified):"
185
+
186
+ # the config: version current, one line changed, nothing else moved
187
+ t "kitVersion is the installed version" "$(jq -r .kitVersion "$proj/.claude/kit.config.json")" "$INSTALLED"
188
+ t "defect 2: the config diff is one line removed, one added" \
189
+ "$(git -C "$proj" diff --numstat -- .claude/kit.config.json | awk '{print $1 "/" $2}')" "1/1"
190
+ t "…and that line is kitVersion" \
191
+ "$(git -C "$proj" diff -- .claude/kit.config.json | grep -E '^[+-] ' | grep -vc kitVersion)" "0"
192
+ t "every other config value is as the project had it" \
193
+ "$(jq -S 'del(.kitVersion, .upgrade.renamed)' "$proj/.claude/kit.config.json")" \
194
+ "$(printf '%s' "$CFG_BEFORE" | jq -S 'del(.kitVersion)')"
195
+
196
+ # new files arrived
197
+ t "a rule new to the project was added" "$([ -f "$proj/.claude/rules/merge-safety.md" ] && echo yes || echo no)" "yes"
198
+ t "a hook new to the project was added" "$([ -x "$proj/.claude/hooks/kit-mail-check.sh" ] && echo yes || echo no)" "yes"
199
+ has "…and is in the list as added" "$real_list" "A .claude/rules/merge-safety.md"
200
+
201
+ # customizations kept
202
+ for f in CLAUDE.md .claude/rules/communication-style.md .claude/hooks/repo-hygiene.sh scripts/setup-labels.sh; do
203
+ t "customization kept: $f" "$(grep -c 'OPERATOR-NOTE' "$proj/$f")" "1"
204
+ hasnt "…and not in the change list: $f" "$truth" " $f"
205
+ done
206
+ has "the customized hook is reported as drifted, kept" "$real" "! .claude/hooks/repo-hygiene.sh"
207
+ t "the migrated skill is kept" "$(cat "$proj/.claude/skills/kit-task-pr/SKILL.md")" "the project edited this skill"
208
+
209
+ # removed / renamed paths are not re-added
210
+ for f in .claude/rules/task-management.md scripts/task-sync.sh .claude/skills/task-pr; do
211
+ t "not re-added: $f" "$([ -e "$proj/$f" ] && echo present || echo absent)" "absent"
212
+ done
213
+
214
+ # defect 5: settings.json
215
+ has "defect 5: settings.json is listed as modified" "$real_list" "M .claude/settings.json"
216
+ hasnt "defect 5: …and no longer as preserved" "$real" "= .claude/settings.json"
217
+ t "the mail hook was registered" \
218
+ "$(jq '[.hooks | to_entries[] | .value[] | .hooks[] | select(.command | test("kit-mail-check"))] | length' "$proj/.claude/settings.json")" "4"
219
+ t "the project's shared Bash block is intact: both hooks, original order" \
220
+ "$(jq -r '.hooks.PreToolUse[0].hooks | map(.command | split("/") | last) | join(",")' "$proj/.claude/settings.json")" \
221
+ "own-guard.sh,guard-raw-git-ops.sh"
222
+ t "the raw-git guard is registered once, not moved into a second block" \
223
+ "$(jq '[.hooks.PreToolUse[] | .hooks[] | select(.command | test("guard-raw-git-ops"))] | length' "$proj/.claude/settings.json")/$(jq '.hooks.PreToolUse | length' "$proj/.claude/settings.json")" "1/1"
224
+ t "the project's permissions are as they were" "$(jq -c '.permissions.allow' "$proj/.claude/settings.json")" '["Bash(cckit merge:*)"]'
225
+
226
+ # ── 5. confirm ─────────────────────────────────────────────────────────────────────────────────
227
+ out="$(run "$CCKIT" update)"; rc=$?
228
+ t "cckit update after the upgrade -> exit 0" "$rc" "0"
229
+ has "…and says up to date" "$out" "up to date"
230
+ t "git status --short shows the change for review" "$([ -n "$(run git status --short)" ] && echo yes || echo no)" "yes"
231
+ t "git diff --stat names the config" "$(run git diff --stat | grep -c 'kit.config.json')" "1"
232
+ commit "upgrade to the current cckit"
233
+
234
+ # ── 6. a second run changes nothing ────────────────────────────────────────────────────────────
235
+ tree "$tmp/t5"
236
+ out="$(run "$CCKIT" init --upgrade)"; rc=$?
237
+ t "second cckit init --upgrade -> exit 0" "$rc" "0"
238
+ has "…says there is nothing to upgrade" "$out" "nothing to upgrade"
239
+ out="$(run "$CCKIT" init --upgrade --dry-run)"
240
+ has "second dry run says the same" "$out" "nothing to upgrade"
241
+ tree "$tmp/t6"
242
+ t "second run changes no file" "$(delta "$tmp/t5" "$tmp/t6")" ""
243
+ t "second run leaves the tree clean" "$(run git status --short)" ""
244
+
245
+ # ── 7. same version, forced through the upgrade again: still nothing but the version line ──────
246
+ # (What a project one release behind sees: every file already there.)
247
+ perl -pi -e 's/("kitVersion":\s*")[^"]*/${1}'"$OLD"'/' "$proj/.claude/kit.config.json"
248
+ t "fixture: the version is behind again" "$(jq -r .kitVersion "$proj/.claude/kit.config.json")" "$OLD"
249
+ commit "pretend to be one release behind"
250
+ tree "$tmp/t7"
251
+ dry="$(run "$CCKIT" init --upgrade --dry-run)"
252
+ real="$(run "$CCKIT" init --upgrade)"
253
+ tree "$tmp/t8"
254
+ truth="$(delta "$tmp/t7" "$tmp/t8")"
255
+ t "converged project: dry run == run == disk" "$(block "$dry" "Would change")|$(block "$real" "Changed on disk")" "$truth|$truth"
256
+ t "converged project: tracked change is the config alone" "$(run git status --short | awk '{print $2}' | tr '\n' ' ')" ".claude/kit.config.json "
257
+ t "converged project: one line" "$(git -C "$proj" diff --numstat -- .claude/kit.config.json | awk '{print $1 "/" $2}')" "1/1"
258
+ has "converged project: settings.json is preserved, and says so" "$real" "= .claude/settings.json"
259
+
260
+ # ── 8. the docs page names only commands this test runs ────────────────────────────────────────
261
+ # Every `cckit …` / `git …` line inside a ```bash fence of the page must appear in this file.
262
+ if [ -f "$PAGE" ]; then
263
+ n=0
264
+ while IFS= read -r line; do
265
+ n=$((n + 1))
266
+ if grep -qF -- "\"\$CCKIT\" ${line#cckit }" "$0" || grep -qF -- "run $line" "$0"; then
267
+ echo "ok: docs command is run here: $line"
268
+ else
269
+ echo "FAIL: docs page command not run by this test: $line"; fail=1
270
+ fi
271
+ done <<EOF
272
+ $(awk '/^```bash/ { on = 1; next } /^```/ { on = 0 } on && /^(cckit|git) / { sub(/[[:space:]]+#.*$/, ""); print }' "$PAGE" | LC_ALL=C sort -u)
273
+ EOF
274
+ t "the docs page has commands to check" "$([ "$n" -ge 6 ] && echo yes || echo no)" "yes"
275
+ else
276
+ echo "FAIL: docs page missing: $PAGE"; fail=1
277
+ fi
278
+
279
+ [ "$fail" = "0" ] && echo "ALL OK (update-path)" || { echo "update-path: FAILURES"; exit 1; }
@@ -134,7 +134,7 @@ printf '%s\n' "$FILES" | xargs perl -0ne 'while(/<[A-Za-z]*Icon\b((?:(?!\/>)[\s\
134
134
 
135
135
  # 10. Repeated className literals (3+ times, multi-word) — component candidates, with their locations.
136
136
  section "10 REPEATED_CLASSNAMES — identical multi-utility className literals appearing 3+ times (→ component or variant)"
137
- REPEATED=$(printf '%s\n' "$FILES" | xargs grep -ohE 'className="[^"]{24,}"' 2>/dev/null | sort | uniq -c | sort -rn | awk '$1>=3{c=$1; $1=""; sub(/^ /,""); printf "%d\t%s\n", c, $0}' | head -30)
137
+ REPEATED=$(printf '%s\n' "$FILES" | xargs grep -ohE 'className="[^"]{24,}"' 2>/dev/null | sort | uniq -c | sort -rn | awk '$1>=3{c=$1; $1=""; sub(/^ /,""); printf "%d\t%s\n", c, $0}' | sed -n 1,30p)
138
138
  printf '%s\n' "$REPEATED" | awk -F'\t' 'NF{printf " %3d %s\n", $1, $2}'
139
139
  printf -- '-- occurrences (file:line) per repeated literal:\n'
140
140
  printf '%s\n' "$REPEATED" | cut -f2 | while IFS= read -r lit; do
@@ -42,12 +42,12 @@ if [[ "$MODE" == "apps" ]]; then
42
42
  has_dev="$(jq -r '(.scripts.dev // .scripts.start // "") | if . == "" then "0" else "1" end' "$pkg" 2>/dev/null || echo 0)"
43
43
  deps="$(jq -r '((.dependencies // {}) + (.devDependencies // {})) | keys[]?' "$pkg" 2>/dev/null || true)"
44
44
  fw=""
45
- printf '%s\n' "$deps" | grep -qx next && fw="next"
46
- [[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx '@react-router/dev' && fw="react-router"
47
- [[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx nuxt && fw="nuxt"
48
- [[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx astro && fw="astro"
49
- [[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx vue && fw="vue"
50
- [[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx react && fw="react"
45
+ grep -qx next <<<"$deps" && fw="next"
46
+ [[ -z "$fw" ]] && grep -qx '@react-router/dev' <<<"$deps" && fw="react-router"
47
+ [[ -z "$fw" ]] && grep -qx nuxt <<<"$deps" && fw="nuxt"
48
+ [[ -z "$fw" ]] && grep -qx astro <<<"$deps" && fw="astro"
49
+ [[ -z "$fw" ]] && grep -qx vue <<<"$deps" && fw="vue"
50
+ [[ -z "$fw" ]] && grep -qx react <<<"$deps" && fw="react"
51
51
  [[ -n "$fw" && "$has_dev" == "1" ]] || continue
52
52
  router="unknown"
53
53
  if declare -f react_detect >/dev/null 2>&1; then
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env bash
2
+ # wave-worker.sh — the process an orchestrate pane runs: start the agent, record how it ended.
3
+ # (E257.6, #263)
4
+ #
5
+ # wave-worker.sh <session> <issue> -- <agent> [args…]
6
+ #
7
+ # `cckit orchestrate` types this into each tmux pane in front of the agent command, so the agent
8
+ # stays the pane's foreground process (it keeps the terminal) and its exit status is no longer
9
+ # lost when the pane closes. The record is scripts/lib/wave-result.sh's; read it with
10
+ # `cckit orchestrate --results`.
11
+ #
12
+ # The same wrapper runs every agent kind. It reads nothing the agent prints and passes its argv
13
+ # through untouched, so `claude`, `codex` or any other CLI is launched exactly as it was before.
14
+ #
15
+ # Exit status: the agent's own, so the pane shows what the agent returned.
16
+ set -u
17
+
18
+ DIR="$(cd "$(dirname "$0")" && pwd)"
19
+ # shellcheck source=/dev/null
20
+ . "$DIR/lib/wave-result.sh"
21
+
22
+ session="${1:-}"; issue="${2:-}"
23
+ [ -n "$session" ] && [ -n "$issue" ] || { echo "wave-worker: usage: wave-worker.sh <session> <issue> -- <agent> [args…]" >&2; exit 2; }
24
+ shift 2
25
+ [ "${1:-}" = "--" ] && shift
26
+ [ "$#" -ge 1 ] || { echo "wave-worker: no agent command given" >&2; exit 2; }
27
+
28
+ now() { date -u '+%Y-%m-%dT%H:%M:%SZ'; }
29
+
30
+ finished=0
31
+ finish() { # <state> <rc>
32
+ [ "$finished" -eq 0 ] || return 0
33
+ finished=1
34
+ wr_set "$session" "$issue" "state=$1" "rc=$2" "finished=$(now)" || true
35
+ }
36
+
37
+ # A recording failure must not stop the work: the worker still runs, its result is simply absent.
38
+ wr_set "$session" "$issue" "issue=$issue" "state=running" "pid=$$" "host=$(hostname 2>/dev/null)" \
39
+ "started=$(now)" "rc=" "finished=" || echo "wave-worker: could not record the start of #$issue" >&2
40
+
41
+ # bash runs a trap only after the foreground child returns, so these fire once the agent is gone —
42
+ # a closed pane sends HUP to both. SIGKILL cannot be trapped: that case is read back from the dead
43
+ # pid by wr_state.
44
+ trap 'finish interrupted 129; exit 129' HUP
45
+ trap 'finish interrupted 130; exit 130' INT
46
+ trap 'finish interrupted 143; exit 143' TERM
47
+
48
+ # A wave pane runs with no reader: `cckit page` in the agent's shell reads this and prints to the
49
+ # terminal instead of opening a review page (#451).
50
+ export CCKIT_HEADLESS=1
51
+ "$@"
52
+ rc=$?
53
+ finish "$(wr_classify_rc "$rc")" "$rc"
54
+ exit "$rc"
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: kit-add
3
+ description: Add an optional tool or a module to this project through `cckit add` — list what can be added, ask the one question its descriptor defines, and set only that key in the project config.
4
+ when_to_use: When the user wants to add, enable, set up or try an integration or a module ("add the code graph", "what can I add", "make this a software project"). SKIP when they want a package dependency (pnpm add), a new skill or agent (/kit-customize), or first-time setup (/kit-onboard).
5
+ ---
6
+
7
+ # kit-add — one entry to every integration and module
8
+
9
+ Plugin-direct skill — helpers resolve from `${CLAUDE_PLUGIN_ROOT}`. The verb is `cckit add`
10
+ (`scripts/kit-add.sh`); this skill is the conversational way in, and it never writes config by hand.
11
+
12
+ Two kinds of thing can be added, through the same entry:
13
+
14
+ | Kind | Described by | What `add` writes |
15
+ | --- | --- | --- |
16
+ | **Integration** — an optional third-party tool | `integrations/<id>.json` | the one config key the descriptor names (`config.key`), in the project config `kit_config_path` resolves, plus each rule the descriptor lists (`rules`) into `.claude/rules/` |
17
+ | **Module** — e.g. `software`, `qa` | `modules/<name>.json` | this directory's `.claude/kit.config.json`: `modules[]` plus the wizard answers |
18
+
19
+ `cckit add <integration>` **installs nothing.** It records the choice; the tool's install is a
20
+ separate step.
21
+
22
+ ## Steps
23
+
24
+ 1. **List.** `cckit add --llm` returns
25
+ `{"integrations":[{id,label,summary,key,enabled,applies}],"modules":[{id,label}]}`.
26
+ If the user named nothing, show the list and let them pick. Do not offer an integration whose
27
+ `applies` is `false` — the tool cannot work on this repo — and say which one was left out.
28
+ 2. **Render the question.** `scripts/lib/kit-interview.sh --render <name> --dir <project-dir>`.
29
+ A module returns its wizard. An integration returns one question, `enable`, derived from its
30
+ descriptor, with the attribution notice in `intro` and the tool's docs link in `docs`.
31
+ 3. **Ask with AskUserQuestion** — one batched round, using each question's `header`, `question`
32
+ and `options`. Put an option marked `recommended` first and label it "(Recommended)". For an
33
+ integration, show the `intro` notice and the `docs` link with the question: it is a third-party
34
+ tool and the user should see who makes it before saying yes.
35
+ A `text`, `list` or `pairs` question has no `options`: ask it as free text and pass the answer
36
+ through as typed. `list` takes comma-separated items (`QA_EMAIL, QA_PASSWORD`); `pairs` takes
37
+ comma-separated `NAME=value` (`WEB_PORT=3000, API_PORT=4000`).
38
+ For the `qa` module the wizard covers the **stack command**, the **port env vars** it honours
39
+ (with a base port each), one **readiness** probe per service, the **review route**, and the
40
+ **names** of the test-credential env vars. The answers land under `qa` in the config; a missing
41
+ stack command fails the add and writes nothing.
42
+ 4. **Preview, then persist.** Write the answers as `{"<key>":"<value>"}` to a temp file and run
43
+ `KIT_DRY_RUN=1 cckit add <name> --answers <file>` to show the diff, then the same command
44
+ without `KIT_DRY_RUN`. For an integration the preview also lists the rule files, the install
45
+ candidates in order and the wire command; show those too. Add `--dir <project-dir>` when not in the project root.
46
+ When a module's config already exists and the kit does not track it (every `cckit init`
47
+ config), the script prints the diff and asks `overwrite? [y/N]` on stdin — an unattended run
48
+ (`KIT_ASSUME_YES`) keeps the file. Show the user the proposed block, and on their yes run
49
+ `printf 'y\n' | scripts/kit-add.sh <module> --answers <file>`.
50
+ 5. **Report** the config path, the key that changed and any rule file written. For an
51
+ integration, say that nothing was installed.
52
+
53
+ ## What the verb refuses
54
+
55
+ | Case | Result |
56
+ | --- | --- |
57
+ | An `appliesWhen` condition does not hold: no file with a listed extension (`anyExtension`), or the wrong machine (`platform`) | declined, exit 0, nothing written |
58
+ | No project config found from the directory | exit 1 — run `cckit init` first; `add` does not invent a config for an integration |
59
+ | The descriptor fails `integrations/integration.schema.json` | exit 1, the bad field is named, nothing written |
60
+ | The name is neither a module nor an integration | exit 1 |
61
+
62
+ ## Rules
63
+
64
+ - **Never hand-edit the config** to switch an integration on — go through `cckit add`.
65
+ - **Idempotent.** A second run with the same answer leaves the file byte-identical.
66
+ - Answering `no` to an integration writes nothing; it does not switch off one that is already on.
67
+ The exception is an integration that is on by default (`lavish`, `config.default: true`): there
68
+ `no` writes the off value (`reviewPages.enabled: false`), and no rule.
69
+ - An integration add changes one config key. If the diff in step 4 shows more than that key, stop
70
+ and report it instead of applying. Rule files are separate: an existing one is never overwritten.
71
+ - A module is written into this directory only, never above it.
72
+ - **Module config path** — a root `cckit.config.json` in the island is the file written; otherwise
73
+ `.claude/kit.config.json`.
74
+ - **Credentials by NAME, never value** — `qa` asks which env vars hold the test credentials. An
75
+ answer carrying a value (`QA_PASSWORD=...`) is refused and nothing is written; never ask the user
76
+ for the value itself.
77
+ - `KIT_DRY_RUN=1` previews; `KIT_ASSUME_YES=1` accepts every default (for batch and CI).