@jeiemgi/cckit 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +169 -21
  3. package/README.md +505 -35
  4. package/SECURITY.md +5 -0
  5. package/bin/cckit +189 -20
  6. package/cckit.config.json +1 -1
  7. package/commands/kit-doctor.md +13 -5
  8. package/commands/kit-export-project.md +0 -2
  9. package/commands/kit-export-training.md +6 -9
  10. package/commands/kit-init.md +43 -13
  11. package/commands/kit-routines.md +1 -1
  12. package/commands/kit-update.md +11 -6
  13. package/databases/supabase/guide.html +106 -0
  14. package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
  15. package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
  16. package/databases/supabase.json +70 -0
  17. package/integrations/emil-design-eng.json +41 -0
  18. package/integrations/graft.json +81 -0
  19. package/integrations/impeccable.json +42 -0
  20. package/integrations/integration.schema.json +215 -0
  21. package/integrations/lavish.json +43 -0
  22. package/integrations/mempalace.json +28 -0
  23. package/integrations/mlx-lm.json +32 -0
  24. package/integrations/web-design-guidelines.json +42 -0
  25. package/kit.config.schema.json +183 -5
  26. package/package.json +4 -1
  27. package/profiles/automation.json +7 -1
  28. package/profiles/content.json +10 -2
  29. package/profiles/marketing.json +57 -0
  30. package/profiles/minimal.json +7 -1
  31. package/profiles/research.json +7 -1
  32. package/profiles/software.json +7 -1
  33. package/recipes/nextjs-shadcn.json +49 -0
  34. package/scripts/agent-skills-external.txt +45 -0
  35. package/scripts/agent-skills-lint-test.sh +131 -0
  36. package/scripts/agent-skills-lint.sh +115 -0
  37. package/scripts/agent-template-lint-test.sh +42 -0
  38. package/scripts/agent-template-lint.sh +58 -0
  39. package/scripts/annotate-setup.sh +1 -1
  40. package/scripts/autopilot-run-test.sh +338 -0
  41. package/scripts/autopilot-run.sh +448 -0
  42. package/scripts/autopilot-test.sh +8 -0
  43. package/scripts/autopilot.sh +10 -1
  44. package/scripts/benchmark/benchmark-test.sh +85 -0
  45. package/scripts/benchmark/checkpoint-test.sh +314 -0
  46. package/scripts/benchmark/checkpoint.sh +408 -0
  47. package/scripts/benchmark/lib/model.sh +31 -6
  48. package/scripts/benchmark/report.sh +17 -2
  49. package/scripts/benchmark/run-quality.sh +36 -10
  50. package/scripts/benchmark/verb-timings-test.sh +124 -0
  51. package/scripts/benchmark/verb-timings.sh +149 -0
  52. package/scripts/check.sh +29 -19
  53. package/scripts/content-skills-test.sh +144 -0
  54. package/scripts/copilot-loop-test.sh +25 -0
  55. package/scripts/database-supabase-test.sh +121 -0
  56. package/scripts/docs-marketing-words-test.sh +73 -0
  57. package/scripts/docs-record-tables-test.sh +72 -0
  58. package/scripts/guard-raw-git-ops-test.sh +8 -0
  59. package/scripts/hook-adapter-test.sh +193 -0
  60. package/scripts/init-content-test.sh +225 -0
  61. package/scripts/init-guided-test.sh +474 -0
  62. package/scripts/init-recipes-test.sh +104 -0
  63. package/scripts/init-upgrade-test.sh +341 -2
  64. package/scripts/init.sh +746 -95
  65. package/scripts/instruction-budget-baseline.txt +8 -0
  66. package/scripts/instruction-budget-lint-test.sh +166 -0
  67. package/scripts/instruction-budget-lint.sh +219 -0
  68. package/scripts/integrations-check-test.sh +200 -0
  69. package/scripts/integrations-check.sh +157 -0
  70. package/scripts/kit-add-test.sh +214 -0
  71. package/scripts/kit-add.sh +305 -5
  72. package/scripts/kit-adopt-test.sh +16 -0
  73. package/scripts/kit-adopt.sh +3 -2
  74. package/scripts/kit-digest.sh +2 -2
  75. package/scripts/kit-doctor-test.sh +293 -0
  76. package/scripts/kit-doctor.sh +272 -140
  77. package/scripts/kit-export-project-test.sh +3 -3
  78. package/scripts/kit-remove-test.sh +19 -0
  79. package/scripts/kit-routines.sh +2 -2
  80. package/scripts/kit-self-update.sh +1 -1
  81. package/scripts/kit-version-check-test.sh +4 -0
  82. package/scripts/kit-version-check.sh +4 -2
  83. package/scripts/knowledge-lint.sh +4 -4
  84. package/scripts/leak-fence-test.sh +89 -0
  85. package/scripts/lib/adapter-select-test.sh +136 -0
  86. package/scripts/lib/adapter-select.sh +158 -0
  87. package/scripts/lib/agent-def-test.sh +69 -0
  88. package/scripts/lib/agent-def.sh +106 -0
  89. package/scripts/lib/agent-launch-test.sh +212 -0
  90. package/scripts/lib/agent-launch.sh +335 -0
  91. package/scripts/lib/board-view-test.sh +11 -0
  92. package/scripts/lib/board-view.sh +42 -26
  93. package/scripts/lib/branch-owner-test.sh +26 -0
  94. package/scripts/lib/branch-owner.sh +16 -9
  95. package/scripts/lib/captain-test.sh +105 -0
  96. package/scripts/lib/captain.sh +87 -8
  97. package/scripts/lib/codex-hooks-test.sh +100 -0
  98. package/scripts/lib/codex-hooks.sh +69 -0
  99. package/scripts/lib/commitlint.sh +1 -1
  100. package/scripts/lib/content-kinds-gc-test.sh +88 -0
  101. package/scripts/lib/copilot-test.sh +70 -4
  102. package/scripts/lib/copilot.sh +66 -14
  103. package/scripts/lib/effort-dispatch-test.sh +3 -3
  104. package/scripts/lib/effort-metrics-test.sh +178 -1
  105. package/scripts/lib/effort-metrics.sh +188 -35
  106. package/scripts/lib/effort-ops-test.sh +217 -7
  107. package/scripts/lib/effort-ops.sh +281 -49
  108. package/scripts/lib/effort-parity-test.sh +49 -13
  109. package/scripts/lib/effort-plan-test.sh +337 -0
  110. package/scripts/lib/effort-plan.sh +200 -23
  111. package/scripts/lib/effort-slug.sh +16 -2
  112. package/scripts/lib/effort.sh +67 -12
  113. package/scripts/lib/errors-header-test.sh +1 -1
  114. package/scripts/lib/gh-project-test.sh +35 -1
  115. package/scripts/lib/gh-project.sh +37 -16
  116. package/scripts/lib/gh-rest-test.sh +330 -0
  117. package/scripts/lib/gh-rest.sh +304 -0
  118. package/scripts/lib/hook-refresh.sh +1 -1
  119. package/scripts/lib/init-github.sh +412 -0
  120. package/scripts/lib/init-guide.sh +630 -0
  121. package/scripts/lib/integration-install-test.sh +343 -0
  122. package/scripts/lib/integration-install.sh +257 -0
  123. package/scripts/lib/integrations-test.sh +366 -0
  124. package/scripts/lib/integrations.sh +244 -0
  125. package/scripts/lib/kinds-test.sh +125 -0
  126. package/scripts/lib/kinds.sh +66 -0
  127. package/scripts/lib/kit-brief-test.sh +22 -3
  128. package/scripts/lib/kit-brief.sh +45 -5
  129. package/scripts/lib/kit-config-resolve.sh +2 -2
  130. package/scripts/lib/kit-config-test.sh +64 -1
  131. package/scripts/lib/kit-config.sh +37 -1
  132. package/scripts/lib/kit-events.sh +7 -0
  133. package/scripts/lib/kit-gc-test.sh +173 -1
  134. package/scripts/lib/kit-gc.sh +244 -37
  135. package/scripts/lib/kit-hotfix.sh +216 -0
  136. package/scripts/lib/kit-interview-test.sh +93 -0
  137. package/scripts/lib/kit-interview.sh +117 -8
  138. package/scripts/lib/kit-lib-test.sh +1 -1
  139. package/scripts/lib/kit-lib.sh +3 -3
  140. package/scripts/lib/kit-local.sh +2 -2
  141. package/scripts/lib/kit-manifest.sh +33 -1
  142. package/scripts/lib/kit-profile-test.sh +3 -3
  143. package/scripts/lib/kit-status-test.sh +112 -4
  144. package/scripts/lib/kit-status.sh +246 -16
  145. package/scripts/lib/kit-task-ops-test.sh +37 -0
  146. package/scripts/lib/kit-task-ops.sh +362 -89
  147. package/scripts/lib/kto-hotfix-test.sh +232 -0
  148. package/scripts/lib/kto-task-close-test.sh +83 -0
  149. package/scripts/lib/kto-task-new-test.sh +95 -0
  150. package/scripts/lib/kto-task-pr-merge-test.sh +97 -6
  151. package/scripts/lib/kto-task-pr-test.sh +70 -0
  152. package/scripts/lib/leak-fence.sh +89 -0
  153. package/scripts/lib/light-task-run-test.sh +255 -0
  154. package/scripts/lib/light-task-test.sh +309 -0
  155. package/scripts/lib/light-task.sh +706 -0
  156. package/scripts/lib/next-test.sh +99 -0
  157. package/scripts/lib/next.sh +9 -3
  158. package/scripts/lib/orchestration-runtime-test.sh +72 -0
  159. package/scripts/lib/orchestration-runtime.sh +57 -5
  160. package/scripts/lib/plan-machine-test.sh +15 -2
  161. package/scripts/lib/plan-machine.sh +20 -7
  162. package/scripts/lib/plan-next-test.sh +1 -1
  163. package/scripts/lib/plan-next.sh +4 -4
  164. package/scripts/lib/pr-evidence-test.sh +3 -3
  165. package/scripts/lib/pr-evidence.sh +1 -1
  166. package/scripts/lib/qa-lane-test.sh +626 -0
  167. package/scripts/lib/qa-lane.sh +1357 -0
  168. package/scripts/lib/qa-lanes-test.sh +175 -0
  169. package/scripts/lib/react-detect.sh +1 -1
  170. package/scripts/lib/render-test.sh +1 -1
  171. package/scripts/lib/review-page-test.sh +318 -0
  172. package/scripts/lib/review-page.sh +369 -0
  173. package/scripts/lib/review-stage-test.sh +62 -11
  174. package/scripts/lib/review-stage.sh +42 -60
  175. package/scripts/lib/role-identity-test.sh +65 -0
  176. package/scripts/lib/role-identity.sh +25 -2
  177. package/scripts/lib/secret-guard.sh +3 -3
  178. package/scripts/lib/session-registry-test.sh +111 -0
  179. package/scripts/lib/session-registry.sh +233 -0
  180. package/scripts/lib/stage-receipt-test.sh +14 -1
  181. package/scripts/lib/stage-receipt.sh +13 -8
  182. package/scripts/lib/task-source-file.sh +309 -0
  183. package/scripts/lib/task-source.sh +130 -0
  184. package/scripts/lib/test-env-test.sh +3 -3
  185. package/scripts/lib/test-env.sh +7 -4
  186. package/scripts/lib/upgrade-report-test.sh +120 -0
  187. package/scripts/lib/upgrade-report.sh +138 -0
  188. package/scripts/lib/version-bump.sh +3 -3
  189. package/scripts/lib/wave-result-test.sh +80 -0
  190. package/scripts/lib/wave-result.sh +127 -0
  191. package/scripts/lib/worker-brief-test.sh +5 -0
  192. package/scripts/lib/worker-brief.sh +2 -2
  193. package/scripts/lib/worktree-issue-test.sh +30 -1
  194. package/scripts/lib/worktree-issue.sh +93 -9
  195. package/scripts/lib/worktree-ports-test.sh +57 -4
  196. package/scripts/lib/worktree-start-test.sh +197 -0
  197. package/scripts/lib/worktree-start.sh +169 -32
  198. package/scripts/lib/zsh-safety-test.sh +19 -3
  199. package/scripts/marketing-walkthrough-test.sh +152 -0
  200. package/scripts/night-grant-test.sh +37 -0
  201. package/scripts/night-grant.sh +448 -0
  202. package/scripts/night-run-test.sh +8 -0
  203. package/scripts/night-run.mjs +275 -0
  204. package/scripts/night-run.test.mjs +324 -0
  205. package/scripts/orchestrate-test.sh +190 -0
  206. package/scripts/orchestrate.sh +79 -8
  207. package/scripts/portable-test.sh +11 -2
  208. package/scripts/publish.sh +28 -3
  209. package/scripts/review-lint-test.sh +7 -7
  210. package/scripts/review-lint.sh +2 -2
  211. package/scripts/review-rules.conf +8 -0
  212. package/scripts/rule-recipes-test.sh +96 -0
  213. package/scripts/self-install-test.sh +39 -9
  214. package/scripts/setup-labels.sh +18 -1
  215. package/scripts/setup-milestones.sh +1 -1
  216. package/scripts/showcase.sh +1 -1
  217. package/scripts/skill-frontmatter-lint-test.sh +4 -4
  218. package/scripts/skill-frontmatter-lint.sh +1 -1
  219. package/scripts/status-test.sh +113 -2
  220. package/scripts/status.sh +16 -3
  221. package/scripts/task-sync-test.sh +154 -0
  222. package/scripts/task-sync.sh +243 -32
  223. package/scripts/test-runner-test.sh +158 -0
  224. package/scripts/test.sh +131 -23
  225. package/scripts/update-path-test.sh +279 -0
  226. package/scripts/ux-ds-audit.sh +1 -1
  227. package/scripts/ux-graph-scan.sh +6 -6
  228. package/scripts/wave-worker.sh +54 -0
  229. package/skills/kit-add/SKILL.md +77 -0
  230. package/skills/kit-autopilot/SKILL.md +123 -12
  231. package/skills/kit-cleanup/SKILL.md +5 -2
  232. package/skills/kit-contribute/SKILL.md +4 -4
  233. package/skills/kit-docs-writer/SKILL.md +16 -6
  234. package/skills/kit-effort-close/SKILL.md +17 -8
  235. package/skills/kit-effort-new/SKILL.md +15 -9
  236. package/skills/kit-effort-pr/SKILL.md +15 -7
  237. package/skills/kit-effort-start/SKILL.md +5 -2
  238. package/skills/kit-gc/SKILL.md +5 -2
  239. package/skills/kit-next/SKILL.md +5 -1
  240. package/skills/kit-onboard/SKILL.md +3 -3
  241. package/skills/kit-page/SKILL.md +93 -0
  242. package/skills/kit-plan-next/SKILL.md +8 -4
  243. package/skills/kit-security-sweep/SKILL.md +1 -3
  244. package/skills/kit-ship/SKILL.md +2 -3
  245. package/skills/kit-status/SKILL.md +35 -4
  246. package/skills/kit-task-new/SKILL.md +3 -3
  247. package/skills/kit-task-pr/SKILL.md +7 -2
  248. package/skills/kit-task-pr-merge/SKILL.md +7 -2
  249. package/skills/kit-task-start/SKILL.md +7 -7
  250. package/skills/kit-task-sync/SKILL.md +19 -3
  251. package/skills/kit-ux-audit/SKILL.md +3 -2
  252. package/templates/agents/auto-dev.md +5 -4
  253. package/templates/agents/backend.md +1 -1
  254. package/templates/agents/designer.md +2 -0
  255. package/templates/agents/devops.md +1 -1
  256. package/templates/agents/editor.md +9 -1
  257. package/templates/agents/frontend.md +1 -1
  258. package/templates/agents/local-delegate.md +1 -1
  259. package/templates/agents/pm.md +5 -5
  260. package/templates/agents/tech-lead.md +1 -1
  261. package/templates/benchmarks/SCHEMA.md +9 -3
  262. package/templates/codex/hooks.json.tmpl +89 -0
  263. package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
  264. package/templates/hooks/guard-raw-git-ops.sh.tmpl +27 -14
  265. package/templates/hooks/mempal_followup.sh.tmpl +2 -2
  266. package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
  267. package/templates/hooks/prepush_gate.sh.tmpl +4 -2
  268. package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
  269. package/templates/instructions.md.tmpl +174 -0
  270. package/templates/kit.config.json.tmpl +3 -3
  271. package/templates/knowledge-INDEX.md.tmpl +1 -1
  272. package/templates/lib/kit-sigil.sh.tmpl +1 -1
  273. package/templates/rules/authoring.md +106 -0
  274. package/templates/rules/branch-naming.md +40 -4
  275. package/templates/rules/code-retrieval.md +63 -0
  276. package/templates/rules/delegation-brief.md +0 -3
  277. package/templates/rules/design-routing.md +3 -3
  278. package/templates/rules/effort-model.md +14 -10
  279. package/templates/rules/gate-and-review.md +94 -0
  280. package/templates/rules/issue-lifecycle.md +88 -0
  281. package/templates/rules/knowledge-base.md +1 -1
  282. package/templates/rules/mempalace.md +1 -1
  283. package/templates/rules/merge-safety.md +108 -0
  284. package/templates/rules/naming-and-ids.md +23 -17
  285. package/templates/rules/plain-language.md +59 -0
  286. package/templates/rules/plan-next.md +9 -11
  287. package/templates/rules/react-annotate.md +6 -0
  288. package/templates/rules/review-pages.md +49 -0
  289. package/templates/rules/risk-tiered-review.md +13 -4
  290. package/templates/rules/shared-checkout.md +106 -0
  291. package/templates/rules/skill-gaps.md +2 -7
  292. package/templates/rules/task-management.md +13 -1
  293. package/templates/skills/brand-voice/SKILL.md +91 -0
  294. package/templates/skills/brand-voice/references/voice-template.md +61 -0
  295. package/templates/skills/campaign/SKILL.md +123 -0
  296. package/templates/skills/campaign/references/plan-template.md +55 -0
  297. package/templates/skills/concrete/SKILL.md +2 -2
  298. package/templates/skills/copywriting/SKILL.md +8 -1
  299. package/templates/skills/feature-build-refine/SKILL.md +2 -4
  300. package/templates/skills/morning-briefing/SKILL.md +2 -2
  301. package/templates/skills/page-design/SKILL.md +145 -0
  302. package/templates/skills/page-design/add.json +5 -0
  303. package/templates/skills/page-design/references/design-file-template.md +40 -0
  304. package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
  305. package/templates/skills/page-design/references/minimum-rules.md +42 -0
  306. package/templates/skills/speckit/SKILL.md +4 -5
  307. package/templates/skills/supabase-patterns/SKILL.md +1 -1
  308. package/commands/kit-add.md +0 -42
  309. package/templates/CLAUDE.md.tmpl +0 -106
@@ -0,0 +1,293 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # kit-doctor-test.sh — covers the integrations loop in scripts/kit-doctor.sh (E303.4): the
4
+ # preflight holds no tool's install recipe; for every descriptor in integrations/ whose config key
5
+ # is on it asks the shared runner (scripts/lib/integration-install.sh) and prints one row.
6
+ #
7
+ # Hermetic: kit-doctor.sh runs against a throwaway project and HOME on a sealed PATH — symlinks to
8
+ # the real tools it needs, plus STUBS for everything that would reach the machine or the network
9
+ # (uname, brew, gh, node, pnpm, ssh, curl, sysctl, and the package managers pipx / uv). The real
10
+ # descriptors (integrations/mempalace.json, integrations/mlx-lm.json) are the ones under test, so
11
+ # no real pipx, uv or brew is ever run and nothing is installed.
12
+ # Run: bash scripts/kit-doctor-test.sh
13
+ # errors: strict — a test runner: rc 1 on any failed assertion
14
+ set -u
15
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
16
+ # shellcheck source=/dev/null
17
+ . "$ROOT/scripts/lib/test-env.sh" && test_env_seal
18
+ DOCTOR="$ROOT/scripts/kit-doctor.sh"
19
+ fail=0
20
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
21
+ has() { if grep -qF -- "$3" <<<"$2"; then echo "ok: $1"; else echo "FAIL: $1 -> '$3' not in: $2"; fail=1; fi; }
22
+ hasnt() { if grep -qF -- "$3" <<<"$2"; then echo "FAIL: $1 -> '$3' found in: $2"; fail=1; else echo "ok: $1"; fi; }
23
+
24
+ command -v jq >/dev/null 2>&1 || { echo "kit-doctor-test: jq absent — skipping (dependency-light gate)"; exit 0; }
25
+
26
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
27
+ tmp="$(cd "$tmp" && pwd -P)"
28
+
29
+ # ── the sealed PATH ────────────────────────────────────────────────────────────────────────────
30
+ sealed="$tmp/sealed"; mkdir -p "$sealed"
31
+ for tool in sh bash jq git perl grep sed awk sort cat mkdir rm dirname basename chmod ls pwd env tr head tail find seq sleep mktemp cut nohup mv cp; do
32
+ src="$(command -v "$tool" 2>/dev/null)" || continue
33
+ case "$src" in /*) ln -s "$src" "$sealed/$tool" ;; esac
34
+ done
35
+ stubs="$tmp/stubs"; mkdir -p "$stubs"
36
+ log="$tmp/calls.log"; : > "$log"
37
+ printf 'arm64\n' > "$tmp/arch" # what the stub `uname -m` answers
38
+ printf '1\n' > "$tmp/curl-rc" # the stub curl's exit code: 1 = nothing answers, 0 = server alive
39
+
40
+ mk() { cat > "$stubs/$1"; chmod +x "$stubs/$1"; } # mk <name> — stub body on stdin
41
+ # The machine: an Apple-silicon Mac by default, whatever the host really is.
42
+ mk uname <<EOF
43
+ #!/bin/sh
44
+ case "\${1:-}" in -m) cat "$tmp/arch" ;; *) echo Darwin ;; esac
45
+ EOF
46
+ mk sysctl <<'EOF'
47
+ #!/bin/sh
48
+ echo "Stub Silicon"
49
+ EOF
50
+ mk gh <<'EOF'
51
+ #!/bin/sh
52
+ case "$1 ${2:-}" in
53
+ "--version ") echo "gh version 2.50.0 (stub)" ;;
54
+ "auth status") echo " - Token scopes: 'project', 'repo'" ;;
55
+ "api user") echo "stub-user" ;;
56
+ esac
57
+ exit 0
58
+ EOF
59
+ mk node <<'EOF'
60
+ #!/bin/sh
61
+ echo v22.0.0
62
+ EOF
63
+ mk pnpm <<EOF
64
+ #!/bin/sh
65
+ echo "pnpm \$*" >> "$log"
66
+ echo 9.0.0
67
+ EOF
68
+ mk ssh <<'EOF'
69
+ #!/bin/sh
70
+ exit 1
71
+ EOF
72
+ mk curl <<EOF
73
+ #!/bin/sh
74
+ exit "\$(cat "$tmp/curl-rc")"
75
+ EOF
76
+
77
+ # manager <pipx|uv> — a package manager that "installs" by dropping the tool into ~/.local/bin
78
+ # (off PATH, where the real ones put it) and logs its argv.
79
+ manager() {
80
+ mk "$1" <<EOF
81
+ #!/bin/sh
82
+ echo "$1 \$*" >> "$log"
83
+ for last in "\$@"; do :; done
84
+ case "\$last" in
85
+ mempalace) bin=mempalace ;;
86
+ mlx-lm) bin=mlx_lm.server ;;
87
+ *) exit 1 ;;
88
+ esac
89
+ mkdir -p "\$HOME/.local/bin"
90
+ printf '#!/bin/sh\necho "stub %s 0.0.0"\n' "\$bin" > "\$HOME/.local/bin/\$bin"
91
+ chmod +x "\$HOME/.local/bin/\$bin"
92
+ EOF
93
+ }
94
+ # brew: `brew install <manager>` puts that manager on PATH (the bootstrap); anything else is a no-op.
95
+ mk brew <<EOF
96
+ #!/bin/sh
97
+ echo "brew \$*" >> "$log"
98
+ case "\$1 \${2:-}" in
99
+ "--version ") echo "Homebrew 4.0.0 (stub)" ;;
100
+ "install pipx"|"install uv") cp "$tmp/manager-\$2" "$stubs/\$2"; chmod +x "$stubs/\$2" ;;
101
+ esac
102
+ exit 0
103
+ EOF
104
+ manager pipx; manager uv
105
+ cp "$stubs/pipx" "$tmp/manager-pipx"; cp "$stubs/uv" "$tmp/manager-uv"
106
+
107
+ calls() { grep -E '^(pipx|uv|brew install) ' "$log" | tr '\n' '|'; }
108
+
109
+ # project <name> <config-json> -> a throwaway kit project; echoes its dir.
110
+ project() {
111
+ mkdir -p "$tmp/$1/.claude"
112
+ printf '%s\n' "$2" > "$tmp/$1/.claude/kit.config.json"
113
+ printf '%s\n' "$tmp/$1"
114
+ }
115
+ # doctor <home> <project> [flags…] -> stdout = the report; stderr in $tmp/err; rc = the doctor's.
116
+ # stdin is /dev/null: no terminal, so the install prompt never fires.
117
+ doctor() {
118
+ local home="$1" proj="$2"; shift 2
119
+ mkdir -p "$home"
120
+ [ -f "$home/.gitconfig" ] || printf '[user]\n\tname = Stub User\n\temail = stub@example.invalid\n' > "$home/.gitconfig"
121
+ ( cd "$proj" && PATH="$stubs:$sealed" HOME="$home" KIT_ASCII=1 NO_COLOR=1 LC_ALL=C \
122
+ bash "$DOCTOR" "$@" </dev/null 2> "$tmp/err" )
123
+ }
124
+ rows() { printf '%s\n' "$1" | grep -E '^ +(ok|FAIL|warn|-) +(mempalace CLI|mlx-lm) ' | sed -E 's/^ +//; s/ +/ /g'; }
125
+
126
+ # ── 0. the doctor holds no tool's recipe (the sub's acceptance, verbatim) ──────────────────────
127
+ t "no installer recipe or per-tool finder is left in kit-doctor.sh" \
128
+ "$(grep -cE 'pipx install|uv tool install|_mp_find|_mlx_find' "$DOCTOR")" "0"
129
+
130
+ # ── 1. nothing switched on: no integration row, and the exit code a keyless config gets ────────
131
+ bare="$(project bare '{"project":{"name":"x"}}')"
132
+ off="$(project off '{"memory":{"enabled":false},"local":{"enabled":false},"reviewPages":{"enabled":false}}')"
133
+ out_bare="$(doctor "$tmp/h1" "$bare" --dry-run)"; rc_bare=$?
134
+ out_off="$(doctor "$tmp/h1" "$off" --dry-run)"; rc_off=$?
135
+ t "no keys -> exit 0 on a healthy machine" "$rc_bare" "0"
136
+ t "both keys false -> the same exit code as with no keys" "$rc_off" "$rc_bare"
137
+ t "both keys false -> no integration row" "$(rows "$out_off")" ""
138
+ hasnt "both keys false -> no Integrations section" "$out_off" "Integrations"
139
+ hasnt "both keys false -> no Memory section" "$out_off" "Memory (MemPalace)"
140
+ hasnt "both keys false -> no Local section" "$out_off" "Local model layer"
141
+ t "both keys false -> no manager was called" "$(calls)" ""
142
+
143
+ # ── 1b. on by default (#451): Lavish has a row in a project that set no key. Missing, it is a
144
+ # skip row — reported, never installed, never a failure, whatever the flags. An explicit key gets
145
+ # the hard row every other integration gets. The sealed PATH has no npx and no lavish-axi.
146
+ lrows() { printf '%s\n' "$1" | grep -E '^ +(ok|FAIL|warn|-) +Lavish ' | sed -E 's/^ +//; s/ +/ /g'; }
147
+ has "no keys -> Lavish is listed: on by default" "$(lrows "$out_bare")" "- Lavish not installed — on by default, falls back without it."
148
+ t "all three keys false -> no Lavish row" "$(lrows "$out_off")" ""
149
+ : > "$log"
150
+ out="$(doctor "$tmp/h1b" "$bare" --yes)"; r=$?
151
+ has "no keys, --yes -> still a skip row" "$(lrows "$out")" "- Lavish not installed — on by default"
152
+ t "no keys, --yes -> nothing is installed for a tool the project never chose" "$(grep -cE 'npm install|brew install node' "$log")" "0"
153
+ t "no keys, --yes -> no consent recorded" "$(cat "$bare/.cckit/consent" 2>/dev/null | grep -c 'install:lavish')" "0"
154
+ t "no keys, --yes -> exit 0" "$r" "0"
155
+ lav="$(project lav '{"reviewPages":{"enabled":true}}')"
156
+ out="$(doctor "$tmp/h1b" "$lav" --dry-run)"; r=$?
157
+ has "explicit reviewPages.enabled -> the hard row" "$(lrows "$out")" "FAIL Lavish missing — npm install -g lavish-axi"
158
+ t "explicit reviewPages.enabled, tool missing -> exit 1" "$r" "1"
159
+ mk npx <<'EOS'
160
+ #!/bin/sh
161
+ exit 0
162
+ EOS
163
+ out="$(doctor "$tmp/h1b" "$bare" --dry-run)"
164
+ has "npx on PATH -> Lavish is installed, nothing to do" "$(lrows "$out")" "ok Lavish installed ($stubs/npx)"
165
+ rm -f "$stubs/npx"
166
+ : > "$log"
167
+
168
+ # ── 2. both on, tools absent, --dry-run: two rows from the runner, nothing installed ───────────
169
+ on="$(project on '{"memory":{"enabled":true},"local":{"enabled":true}}')"
170
+ out="$(doctor "$tmp/h2" "$on" --dry-run)"; r=$?
171
+ has "dry-run -> Integrations section" "$out" "Integrations (optional tools that are on in this project)"
172
+ t "dry-run -> one row per descriptor, each naming its FIRST candidate" "$(rows "$out" | tr '\n' '|')" \
173
+ "FAIL mempalace CLI missing — pipx install mempalace|FAIL mlx-lm missing — uv tool install mlx-lm|"
174
+ has "dry-run -> action names the recipe" "$out" "Install mlx-lm: uv tool install mlx-lm"
175
+ t "dry-run -> exit 1 (an enabled tool is missing)" "$r" "1"
176
+ t "dry-run -> no manager was called" "$(calls)" ""
177
+ t "dry-run -> no binary" "$(ls "$tmp/h2/.local/bin" 2>/dev/null)" ""
178
+ t "dry-run -> no consent recorded" "$(cat "$on/.cckit/consent" 2>/dev/null)" ""
179
+ out="$(doctor "$tmp/h2" "$on" --no-install)"
180
+ t "--no-install -> the same two rows, nothing installed" "$(rows "$out" | tr '\n' '|')|$(calls)" \
181
+ "FAIL mempalace CLI missing — pipx install mempalace|FAIL mlx-lm missing — uv tool install mlx-lm||"
182
+
183
+ # ── 3. nobody approved (no terminal, no --fix): nothing installs ───────────────────────────────
184
+ out="$(doctor "$tmp/h2" "$on")"; r=$?
185
+ has "unapproved run -> the row says why" "$(rows "$out")" "mempalace CLI missing — nothing installs without your yes: cckit doctor --fix"
186
+ t "unapproved run -> no manager was called, no consent recorded" "$(calls)|$(cat "$on/.cckit/consent" 2>/dev/null)" "|"
187
+ t "unapproved run -> exit 1" "$r" "1"
188
+ has "unapproved run -> the runner said where consent lives" "$(cat "$tmp/err")" "$on/.cckit/consent"
189
+
190
+ # ── 4. --yes (init's preflight path): consent is recorded and the runner installs ──────────────
191
+ printf '0\n' > "$tmp/curl-rc" # the model server answers, so the doctor does not try to start one
192
+ : > "$log"
193
+ out="$(doctor "$tmp/h4" "$on" --yes)"; r=$?
194
+ t "--yes -> each tool installed by its FIRST candidate" "$(calls)" "pipx install mempalace|uv tool install mlx-lm|"
195
+ t "--yes -> rows name the winning manager and the off-PATH binary" "$(rows "$out" | tr '\n' '|')" \
196
+ "ok mempalace CLI installed via pipx ($tmp/h4/.local/bin/mempalace)|ok mlx-lm installed via uv ($tmp/h4/.local/bin/mlx_lm.server)|"
197
+ has "--yes -> the descriptor's afterInstall line is reported" "$out" "Installed mempalace CLI via pipx — run 'mempalace mcp' to wire the MCP server"
198
+ t "--yes -> consent recorded, one line per integration" "$(sort "$on/.cckit/consent" | tr '\n' '|')" "install:mempalace|install:mlx-lm|"
199
+ t "--yes -> exit 0" "$r" "0"
200
+ has "--yes -> the memory section's non-install checks still run" "$out" "identity header"
201
+ has "--yes -> the local section still checks the server" "$out" "alive @ :8080"
202
+
203
+ # a second run is a no-op
204
+ : > "$log"
205
+ out="$(doctor "$tmp/h4" "$on" --yes)"; r=$?
206
+ t "second run -> present, no manager called, exit 0" "$(rows "$out" | tr '\n' '|')|$(calls)|$r" \
207
+ "ok mempalace CLI installed ($tmp/h4/.local/bin/mempalace)|ok mlx-lm installed ($tmp/h4/.local/bin/mlx_lm.server)|||0"
208
+
209
+ # ── 5. the fallback candidate: no pipx on the machine -> mempalace installs with uv ────────────
210
+ rm -f "$stubs/pipx"; : > "$log"; on5="$(project on5 '{"memory":{"enabled":true}}')"
211
+ out="$(doctor "$tmp/h5" "$on5" --fix)"
212
+ t "pipx absent -> uv, and no bootstrap (a manager was already there)" "$(calls)|$(rows "$out")" \
213
+ "uv tool install mempalace||ok mempalace CLI installed via uv ($tmp/h5/.local/bin/mempalace)"
214
+
215
+ # ── 6. the bootstrap: neither pipx nor uv -> the first candidate's manager is installed first ──
216
+ rm -f "$stubs/pipx" "$stubs/uv"; : > "$log"; on6="$(project on6 '{"memory":{"enabled":true},"local":{"enabled":true}}')"
217
+ out="$(doctor "$tmp/h6" "$on6" --fix)"
218
+ # mempalace is pipx-first, so brew brings pipx; by the time mlx-lm runs a manager exists, so uv is
219
+ # never bootstrapped and its pipx fallback is used.
220
+ t "no manager -> bootstrap the first candidate's manager, once" "$(calls)" \
221
+ "brew install pipx|pipx install mempalace|pipx install mlx-lm|"
222
+ rm -f "$stubs/pipx" "$stubs/uv"; : > "$log"; on6b="$(project on6b '{"local":{"enabled":true}}')"
223
+ out="$(doctor "$tmp/h6b" "$on6b" --fix)"
224
+ t "mlx-lm alone, no manager -> brew install uv, then uv" "$(calls)|$(rows "$out")" \
225
+ "brew install uv|uv tool install mlx-lm||ok mlx-lm installed via uv ($tmp/h6b/.local/bin/mlx_lm.server)"
226
+ rm -f "$stubs/pipx" "$stubs/uv"; : > "$log"
227
+ out="$(doctor "$tmp/h6c" "$on6b" --dry-run)"
228
+ t "no manager, dry-run -> brew is not run either" "$(calls)|$(rows "$out")" "|FAIL mlx-lm missing — uv tool install mlx-lm"
229
+
230
+ # ── 7. the platform gate: not Apple silicon -> mlx-lm is skipped, never installed ──────────────
231
+ manager pipx; manager uv; : > "$log"; printf 'x86_64\n' > "$tmp/arch"
232
+ out="$(doctor "$tmp/h7" "$on" --yes)"
233
+ has "x86_64 -> mlx-lm row is a skip that names the requirement" "$(rows "$out")" "- mlx-lm needs a Darwin arm64 machine — skipping install"
234
+ t "x86_64 -> only mempalace is installed" "$(calls)" "pipx install mempalace|"
235
+ t "x86_64 -> no mlx binary" "$(ls "$tmp/h7/.local/bin")" "mempalace"
236
+ printf 'arm64\n' > "$tmp/arch"
237
+
238
+ # ── 8. no terminal and no --fix: report only — no `pnpm install`, no seeded file (#448) ────────
239
+ # A trial run of the update path called `cckit doctor` with no flag and stdin not a terminal; it ran
240
+ # `pnpm install` in the project and wrote a MemPalace header. Nobody had been asked.
241
+ pn="$(project pn '{"project":{"name":"x","slug":"pn"},"memory":{"enabled":true}}')"
242
+ printf '{"name":"pn","dependencies":{"left-pad":"1.0.0"}}\n' > "$pn/package.json"
243
+ : > "$log"
244
+ out="$(doctor "$tmp/h8" "$pn")"
245
+ t "no flag, no terminal -> pnpm install is not run" "$(grep -c '^pnpm install' "$log")" "0"
246
+ has "no flag, no terminal -> node_modules is reported, with the command" "$out" "missing — run pnpm install"
247
+ t "no flag, no terminal -> no identity header is written" "$(ls "$pn/.claude" | grep -c mempal-identity)" "0"
248
+ has "no flag, no terminal -> the report says it is report-only and how to install" "$out" "report-only — no terminal and no --fix"
249
+ has "no flag, no terminal -> names the flag" "$out" "cckit doctor --fix"
250
+ t "no flag, no terminal -> no file is added to the project" "$(cd "$pn" && find . -type f | LC_ALL=C sort | tr '\n' ' ')" "./.claude/kit.config.json ./package.json "
251
+ out="$(doctor "$tmp/h8" "$pn" --dry-run)"
252
+ hasnt "--dry-run -> not labelled report-only for want of a terminal" "$out" "no terminal and no --fix"
253
+ : > "$log"
254
+ out="$(doctor "$tmp/h8" "$pn" --fix)"
255
+ t "--fix -> pnpm install runs" "$(grep -c '^pnpm install' "$log")" "1"
256
+ t "--fix -> the identity header is seeded" "$(ls "$pn/.claude" | grep -c mempal-identity)" "1"
257
+ hasnt "--fix -> not report-only" "$out" "report-only"
258
+
259
+ # ── 9. page tasks (#504): tasks.design without the page-design skill is a failing row ──────────
260
+ pd="$(project pd '{"adapters":["claude","codex"],"tasks":{"design":true}}')"
261
+ git -C "$pd" init -q # the codex hooks row reads the repository root
262
+ out="$(doctor "$tmp/h9" "$pd")"; r=$?
263
+ has "tasks.design, no skill -> the claude row names the command" "$out" "missing from .claude/skills/page-design — run: cckit add page-design"
264
+ has "tasks.design, no skill -> one row per selected adapter" "$out" "missing from .agents/skills/page-design — run: cckit add page-design"
265
+ has "tasks.design, no skill -> listed under what is left to do" "$out" "Add the page-design skill (.claude/skills/page-design): cckit add page-design"
266
+ t "tasks.design, no skill -> exit 1" "$r" "1"
267
+ ( cd "$pd" && PATH="$sealed" bash "$ROOT/scripts/kit-add.sh" page-design >/dev/null 2>&1 )
268
+ out="$(doctor "$tmp/h9" "$pd")"; r=$?
269
+ hasnt "after cckit add page-design -> no missing row" "$out" "cckit add page-design"
270
+ t "after cckit add page-design -> one ok row per adapter" "$(printf '%s\n' "$out" | grep -E '^ +ok +page-design skill ' | sed -E 's/^ +//; s/ +/ /g' | tr '\n' '|')" "ok page-design skill .claude/skills/page-design|ok page-design skill .agents/skills/page-design|"
271
+ t "after cckit add page-design -> exit 0" "$r" "0"
272
+ out="$(doctor "$tmp/h9" "$(project pd-off '{"tasks":{"default":"light"}}')")"
273
+ hasnt "tasks.design unset -> no page-design row" "$out" "page-design"
274
+
275
+ # ── 10. an installer's extra files are named on the success row (descriptor: alsoWrites) ───────
276
+ # The stub npx stands for the Impeccable installer: it writes the skill file `detect` checks.
277
+ mk npx <<EOF
278
+ #!/bin/sh
279
+ echo "npx \$*" >> "$log"
280
+ mkdir -p .claude/skills/impeccable && echo stub > .claude/skills/impeccable/SKILL.md
281
+ EOF
282
+ im="$(project im '{"designDirection":{"provider":"impeccable"}}')"; : > "$log"
283
+ out="$(doctor "$tmp/h10" "$im" --fix)"; r=$?
284
+ t "impeccable --fix -> the descriptor's command ran" "$(grep -c '^npx -y impeccable install --providers=claude --scope=project$' "$log")" "1"
285
+ has "impeccable --fix -> the row names the agents files" "$out" "Impeccable"
286
+ has "impeccable --fix -> the row names the agents files (text)" "$out" "installed via npx"
287
+ has "impeccable --fix -> also wrote" "$out" "it also wrote: .claude/agents/impeccable-*.md"
288
+ t "impeccable --fix -> exit 0" "$r" "0"
289
+ out="$(doctor "$tmp/h10" "$im" --fix)"
290
+ hasnt "impeccable, second run -> present, nothing claimed as written" "$out" "it also wrote"
291
+ rm -f "$stubs/npx"
292
+
293
+ [ "$fail" = "0" ] && echo "ALL OK (kit-doctor)" || { echo "kit-doctor: FAILURES"; exit 1; }