@jeiemgi/cckit 0.11.0 → 0.13.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 (549) hide show
  1. package/.claude-plugin/plugin.json +4 -2
  2. package/AGENTS.md +22 -238
  3. package/README.md +66 -56
  4. package/SECURITY.md +4 -4
  5. package/bin/PROMPTS.md +12 -0
  6. package/bin/cckit +181 -140
  7. package/cckit.config.json +1 -1
  8. package/kit/PROMPTS.md +14 -0
  9. package/{commands → kit/commands}/kit-doctor.md +3 -4
  10. package/{commands → kit/commands}/kit-export-project.md +1 -1
  11. package/{commands → kit/commands}/kit-init.md +8 -20
  12. package/{commands → kit/commands}/kit-routines.md +1 -1
  13. package/{commands → kit/commands}/kit-update.md +3 -3
  14. package/kit/completions/cckit.bash +9 -0
  15. package/{databases → kit/databases}/supabase.json +1 -1
  16. package/{integrations → kit/integrations}/integration.schema.json +3 -3
  17. package/kit/interview/global.json +54 -0
  18. package/kit/interview/project.json +133 -0
  19. package/kit/modules/qa.json +63 -0
  20. package/kit/modules/software.json +48 -0
  21. package/{profiles → kit/profiles}/automation.json +1 -3
  22. package/{profiles → kit/profiles}/content.json +0 -2
  23. package/{profiles → kit/profiles}/marketing.json +0 -2
  24. package/{profiles → kit/profiles}/minimal.json +1 -3
  25. package/{profiles → kit/profiles}/research.json +1 -3
  26. package/{profiles → kit/profiles}/software.json +0 -2
  27. package/kit/routines/catalogue.json +84 -0
  28. package/{skills → kit/skills}/kit-add/SKILL.md +4 -4
  29. package/kit/skills/kit-advisor/SKILL.md +75 -0
  30. package/kit/skills/kit-advisor/references/close.md +53 -0
  31. package/kit/skills/kit-advisor/references/grill.md +69 -0
  32. package/kit/skills/kit-advisor/references/orchestrate.md +56 -0
  33. package/kit/skills/kit-advisor/references/plan.md +64 -0
  34. package/kit/skills/kit-advisor/references/review.md +47 -0
  35. package/kit/skills/kit-advisor/references/step-report.md +61 -0
  36. package/{skills → kit/skills}/kit-annotate/SKILL.md +2 -4
  37. package/{skills → kit/skills}/kit-autopilot/SKILL.md +7 -7
  38. package/{skills → kit/skills}/kit-cleanup/SKILL.md +4 -4
  39. package/{skills → kit/skills}/kit-contribute/SKILL.md +8 -12
  40. package/{skills → kit/skills}/kit-customize/SKILL.md +5 -8
  41. package/{skills → kit/skills}/kit-dev/SKILL.md +1 -1
  42. package/{skills → kit/skills}/kit-digest/SKILL.md +3 -3
  43. package/{skills → kit/skills}/kit-effort-close/SKILL.md +20 -12
  44. package/{skills → kit/skills}/kit-effort-new/SKILL.md +17 -14
  45. package/{skills → kit/skills}/kit-effort-pr/SKILL.md +7 -7
  46. package/{skills → kit/skills}/kit-effort-start/SKILL.md +3 -3
  47. package/{skills → kit/skills}/kit-gc/SKILL.md +3 -3
  48. package/{skills → kit/skills}/kit-next/SKILL.md +7 -7
  49. package/{skills → kit/skills}/kit-page/SKILL.md +1 -1
  50. package/{skills → kit/skills}/kit-plan-next/SKILL.md +10 -11
  51. package/{skills → kit/skills}/kit-status/SKILL.md +6 -6
  52. package/{skills → kit/skills}/kit-task-close/SKILL.md +5 -5
  53. package/{skills → kit/skills}/kit-task-new/SKILL.md +5 -5
  54. package/{skills → kit/skills}/kit-task-pr/SKILL.md +5 -5
  55. package/{skills → kit/skills}/kit-task-pr-auto/SKILL.md +1 -1
  56. package/{skills → kit/skills}/kit-task-pr-merge/SKILL.md +10 -10
  57. package/{skills → kit/skills}/kit-task-start/SKILL.md +1 -1
  58. package/{skills → kit/skills}/kit-task-sync/SKILL.md +5 -3
  59. package/{skills → kit/skills}/kit-ux-audit/SKILL.md +16 -35
  60. package/{skills → kit/skills}/kit-ux-audit/references/graph-model.md +7 -26
  61. package/{skills → kit/skills}/kit-ux-audit/references/report.md +2 -3
  62. package/{skills → kit/skills}/routing.yaml +6 -1
  63. package/kit/statusline/kit-statusline.sh +82 -0
  64. package/{templates → kit/templates}/agents/analyst.md +0 -11
  65. package/{templates → kit/templates}/agents/auto-dev.md +0 -13
  66. package/{templates → kit/templates}/agents/backend.md +0 -11
  67. package/{templates → kit/templates}/agents/designer.md +0 -11
  68. package/{templates → kit/templates}/agents/devops.md +0 -11
  69. package/{templates → kit/templates}/agents/editor.md +0 -11
  70. package/{templates → kit/templates}/agents/frontend.md +0 -11
  71. package/{templates → kit/templates}/agents/generalist.md +0 -11
  72. package/{templates → kit/templates}/agents/local-delegate.md +0 -13
  73. package/{templates → kit/templates}/agents/n8n.md +0 -11
  74. package/{templates → kit/templates}/agents/pm.md +0 -11
  75. package/{templates → kit/templates}/agents/qa.md +0 -11
  76. package/{templates → kit/templates}/agents/researcher.md +0 -11
  77. package/{templates → kit/templates}/agents/security.md +0 -11
  78. package/{templates → kit/templates}/agents/tech-lead.md +0 -11
  79. package/{templates → kit/templates}/agents/ux.md +3 -14
  80. package/{templates → kit/templates}/hooks/kit-mail-check.sh.tmpl +1 -1
  81. package/{templates → kit/templates}/instructions.md.tmpl +4 -21
  82. package/{templates → kit/templates}/kit.config.json.tmpl +0 -6
  83. package/{templates → kit/templates}/rules/authoring.md +7 -3
  84. package/{templates → kit/templates}/rules/branch-naming.md +3 -2
  85. package/{templates → kit/templates}/rules/delegation-brief.md +4 -0
  86. package/{templates → kit/templates}/rules/effort-model.md +34 -31
  87. package/{templates → kit/templates}/rules/gate-and-review.md +1 -1
  88. package/{templates → kit/templates}/rules/merge-safety.md +12 -9
  89. package/{templates → kit/templates}/rules/naming-and-ids.md +20 -24
  90. package/{templates → kit/templates}/rules/plan-next.md +5 -5
  91. package/{templates → kit/templates}/rules/react-annotate.md +0 -8
  92. package/{templates → kit/templates}/skills/campaign/SKILL.md +2 -2
  93. package/kit.config.schema.json +11 -11
  94. package/lib/PROMPTS.md +14 -0
  95. package/{scripts/lib → lib/core}/adapter-select-test.sh +7 -7
  96. package/lib/core/advisor-test.sh +55 -0
  97. package/{scripts/lib → lib/core}/agent-def-test.sh +1 -1
  98. package/{scripts/lib → lib/core}/agent-def.sh +2 -2
  99. package/{scripts/lib → lib/core}/agent-launch-test.sh +3 -3
  100. package/{scripts/lib → lib/core}/agent-profile-test.sh +2 -2
  101. package/{scripts/lib → lib/core}/agent-resolve-test.sh +4 -2
  102. package/{scripts/lib → lib/core}/agent-resolve.sh +5 -4
  103. package/{scripts → lib/core}/agent-skills-external.txt +3 -3
  104. package/{scripts → lib/core}/agent-skills-lint-test.sh +17 -17
  105. package/lib/core/agent-skills-lint.sh +115 -0
  106. package/{scripts → lib/core}/agent-template-lint-test.sh +7 -7
  107. package/lib/core/agent-template-lint.sh +58 -0
  108. package/{scripts/lib → lib/core}/board-view-test.sh +3 -3
  109. package/lib/core/board-view.sh +97 -0
  110. package/{scripts/lib → lib/core}/branch-owner-test.sh +3 -3
  111. package/lib/core/branch-owner.sh +201 -0
  112. package/lib/core/check.sh +125 -0
  113. package/{scripts/lib → lib/core}/codex-hooks-test.sh +3 -3
  114. package/{scripts → lib/core}/commitlint-test.sh +6 -6
  115. package/lib/core/commitlint.sh +54 -0
  116. package/{scripts/config-path-test.sh → lib/core/config-path-scan-test.sh} +2 -2
  117. package/{scripts/lib → lib/core}/config-path-test.sh +3 -3
  118. package/lib/core/config-path.sh +30 -0
  119. package/{scripts → lib/core}/content-skills-test.sh +17 -17
  120. package/{scripts → lib/core}/docs-marketing-words-test.sh +2 -2
  121. package/{scripts → lib/core}/docs-record-tables-test.sh +2 -2
  122. package/{scripts/lib → lib/core}/effort-metrics-test.sh +6 -6
  123. package/lib/core/effort-metrics.sh +591 -0
  124. package/{scripts/lib → lib/core}/effort-slug-test.sh +8 -4
  125. package/{scripts/lib → lib/core}/effort-slug.sh +8 -7
  126. package/lib/core/effort.sh +339 -0
  127. package/{scripts/lib → lib/core}/errors-header-test.sh +19 -9
  128. package/lib/core/errors-header.exempt +49 -0
  129. package/{scripts → lib/core}/exec-targets-test.sh +3 -3
  130. package/lib/core/feature-map.sh +76 -0
  131. package/lib/core/force-push-fence-test.sh +44 -0
  132. package/lib/core/force-push-fence.baseline +1 -0
  133. package/lib/core/force-push-fence.sh +51 -0
  134. package/{scripts → lib/core}/forge-fence-test.sh +13 -13
  135. package/{scripts → lib/core}/forge-fence.sh +14 -14
  136. package/{scripts → lib/core}/forge-report-test.sh +5 -5
  137. package/{scripts → lib/core}/forge-report.sh +18 -14
  138. package/{scripts/lib → lib/core}/git-core-test.sh +7 -7
  139. package/{scripts/lib → lib/core}/git-remote-test.sh +3 -3
  140. package/{scripts → lib/core}/guard-raw-git-ops-test.sh +4 -4
  141. package/{scripts → lib/core}/hook-adapter-test.sh +5 -5
  142. package/{scripts/lib → lib/core}/hook-refresh-test.sh +5 -5
  143. package/{scripts → lib/core}/instruction-budget-baseline.txt +2 -2
  144. package/lib/core/instruction-budget-lint.sh +238 -0
  145. package/{scripts/lib → lib/core}/integration-install-test.sh +12 -12
  146. package/lib/core/integration-install.sh +257 -0
  147. package/{scripts/lib → lib/core}/integrations-test.sh +38 -45
  148. package/lib/core/integrations.sh +244 -0
  149. package/{scripts/lib → lib/core}/kinds-test.sh +5 -5
  150. package/lib/core/kinds.sh +66 -0
  151. package/{scripts/lib → lib/core}/kit-cli-test.sh +1 -1
  152. package/{scripts/lib → lib/core}/kit-cli.sh +1 -1
  153. package/{scripts/lib → lib/core}/kit-config-resolve.sh +2 -2
  154. package/{scripts/lib → lib/core}/kit-config-test.sh +11 -11
  155. package/lib/core/kit-config.sh +164 -0
  156. package/{scripts/lib → lib/core}/kit-engine-test.sh +1 -1
  157. package/lib/core/kit-events.sh +72 -0
  158. package/lib/core/kit-local.sh +87 -0
  159. package/{scripts/lib → lib/core}/kit-manifest.sh +1 -1
  160. package/{scripts/lib → lib/core}/kit-mode-test.sh +1 -1
  161. package/{scripts/lib → lib/core}/kit-mode.sh +3 -3
  162. package/{scripts/lib → lib/core}/kit-operate.sh +1 -1
  163. package/{scripts/lib → lib/core}/kit-profile-test.sh +1 -1
  164. package/{scripts/lib → lib/core}/kit-profile.sh +2 -2
  165. package/{scripts/lib → lib/core}/kit-state-test.sh +1 -1
  166. package/lib/core/knowledge-lint.sh +106 -0
  167. package/lib/core/layout-fence-test.sh +35 -0
  168. package/lib/core/layout-fence.allow +15 -0
  169. package/lib/core/layout-fence.baseline +4 -0
  170. package/lib/core/layout-fence.sh +50 -0
  171. package/{scripts → lib/core}/leak-fence-test.sh +10 -10
  172. package/{scripts/lib → lib/core}/leak-fence.sh +1 -1
  173. package/lib/core/loose-issues-test.sh +102 -0
  174. package/lib/core/loose-issues.baseline +5 -0
  175. package/lib/core/loose-issues.sh +65 -0
  176. package/{scripts → lib/core}/marketing-walkthrough-test.sh +7 -7
  177. package/lib/core/naming-test.sh +112 -0
  178. package/lib/core/naming-verbs-test.sh +126 -0
  179. package/lib/core/naming.sh +172 -0
  180. package/{scripts/lib → lib/core}/orchestration-runtime-test.sh +4 -4
  181. package/{scripts → lib/core}/portable-test.sh +11 -7
  182. package/{scripts/lib → lib/core}/pr-evidence-test.sh +5 -5
  183. package/lib/core/pr-evidence.sh +361 -0
  184. package/{scripts/lib → lib/core}/qa-lane-test.sh +7 -7
  185. package/{scripts/lib → lib/core}/qa-lane.sh +4 -4
  186. package/{scripts/lib → lib/core}/qa-lanes-test.sh +5 -5
  187. package/lib/core/react-detect.sh +79 -0
  188. package/{scripts/lib → lib/core}/render-test.sh +1 -1
  189. package/lib/core/resident-context-test.sh +42 -0
  190. package/lib/core/resident-context.baseline +1 -0
  191. package/lib/core/resident-context.sh +56 -0
  192. package/lib/core/review-lint-baseline.txt +28 -0
  193. package/lib/core/review-lint.sh +266 -0
  194. package/{scripts → lib/core}/review-rules.conf +1 -1
  195. package/{scripts/lib → lib/core}/review-stage-test.sh +2 -2
  196. package/{scripts/lib → lib/core}/role-identity-test.sh +3 -3
  197. package/lib/core/role-identity.sh +71 -0
  198. package/{scripts → lib/core}/rule-recipes-test.sh +5 -5
  199. package/lib/core/secret-guard.sh +116 -0
  200. package/{scripts → lib/core}/self-install-test.sh +15 -16
  201. package/{scripts/lib → lib/core}/session-registry-test.sh +1 -1
  202. package/lib/core/session-registry.sh +233 -0
  203. package/{scripts → lib/core}/skill-frontmatter-baseline.txt +1 -1
  204. package/lib/core/skill-frontmatter-lint.sh +189 -0
  205. package/lib/core/spec-lint-test.sh +63 -0
  206. package/lib/core/spec-lint.sh +95 -0
  207. package/{scripts/lib → lib/core}/stage-receipt-test.sh +136 -4
  208. package/{scripts/lib → lib/core}/stage-receipt.sh +186 -7
  209. package/{scripts → lib/core}/terms-check-test.sh +6 -6
  210. package/lib/core/terms-check.sh +244 -0
  211. package/{scripts/lib → lib/core}/test-env-test.sh +2 -2
  212. package/{scripts/lib → lib/core}/test-env.sh +1 -1
  213. package/{scripts → lib/core}/test-runner-test.sh +11 -11
  214. package/{scripts → lib/core}/test.sh +12 -12
  215. package/{scripts → lib/core}/update-path-test.sh +3 -3
  216. package/{scripts → lib/core}/verbs-gen.sh +9 -9
  217. package/{scripts → lib/core}/verbs-help-test.sh +4 -4
  218. package/{scripts → lib/core}/verbs-ratchet-test.sh +24 -19
  219. package/{scripts → lib/core}/verbs-ratchet.sh +8 -8
  220. package/{scripts → lib/core}/verbs-test.sh +23 -23
  221. package/lib/core/verbs.baseline +5 -0
  222. package/{scripts/lib → lib/core}/verbs.sh +3 -3
  223. package/{scripts/lib → lib/core}/verbs.tsv +22 -20
  224. package/{scripts/lib → lib/core}/version-bump-test.sh +29 -8
  225. package/{scripts/lib → lib/core}/version-bump.sh +15 -2
  226. package/{scripts/lib → lib/core}/wave-result-test.sh +2 -2
  227. package/{scripts/lib → lib/core}/wave-result.sh +1 -1
  228. package/{scripts/lib → lib/core}/worker-brief-test.sh +4 -4
  229. package/{scripts/lib → lib/core}/worker-brief.sh +1 -1
  230. package/{scripts/lib → lib/core}/worktree-bootstrap-test.sh +1 -1
  231. package/{scripts/lib → lib/core}/worktree-issue-test.sh +2 -2
  232. package/lib/core/worktree-issue.sh +172 -0
  233. package/{scripts/lib → lib/core}/worktree-ports-test.sh +1 -1
  234. package/{scripts/lib → lib/core}/worktree-start-test.sh +2 -2
  235. package/lib/core/worktree-start.sh +790 -0
  236. package/{scripts/lib → lib/core}/zsh-safety-test.sh +11 -11
  237. package/{scripts/lib → lib/forge}/forge-github.sh +18 -7
  238. package/{scripts/lib → lib/forge}/forge-test.sh +4 -4
  239. package/{scripts/lib → lib/forge}/forge.sh +1 -1
  240. package/lib/forge/gh-board-add-test.sh +118 -0
  241. package/lib/forge/gh-log.sh +59 -0
  242. package/lib/forge/gh-project-test.sh +251 -0
  243. package/lib/forge/gh-project.sh +379 -0
  244. package/{scripts/lib → lib/forge}/gh-rest-test.sh +17 -13
  245. package/{scripts/lib → lib/forge}/gh-rest.sh +190 -16
  246. package/{scripts/lib → lib/forge}/init-github.sh +18 -8
  247. package/{scripts/lib → lib/forge}/test-forge-shim.sh +2 -1
  248. package/lib/verbs/PROMPTS.md +146 -0
  249. package/lib/verbs/annotate-setup.sh +149 -0
  250. package/{scripts → lib/verbs}/autopilot-run-test.sh +9 -9
  251. package/{scripts → lib/verbs}/autopilot-run.sh +9 -9
  252. package/{scripts → lib/verbs}/autopilot-test.sh +7 -6
  253. package/{scripts → lib/verbs}/autopilot.sh +7 -7
  254. package/{scripts/lib → lib/verbs}/captain-test.sh +1 -1
  255. package/{scripts/lib → lib/verbs}/captain.sh +8 -8
  256. package/lib/verbs/capture-project-ids.sh +99 -0
  257. package/{scripts/lib → lib/verbs}/content-kinds-gc-test.sh +7 -7
  258. package/{scripts/lib → lib/verbs}/contribute-root-test.sh +4 -4
  259. package/{scripts/lib → lib/verbs}/contribute-root.sh +1 -1
  260. package/{scripts → lib/verbs}/contribute.sh +8 -8
  261. package/{scripts → lib/verbs}/copilot-loop-test.sh +12 -12
  262. package/{scripts/lib → lib/verbs}/copilot-test.sh +15 -14
  263. package/{scripts/lib → lib/verbs}/copilot.sh +19 -19
  264. package/{scripts → lib/verbs}/database-supabase-test.sh +6 -6
  265. package/lib/verbs/effort-close-subs-test.sh +96 -0
  266. package/{scripts/lib → lib/verbs}/effort-dispatch-test.sh +5 -5
  267. package/{scripts/lib → lib/verbs}/effort-flows-test.sh +5 -5
  268. package/{scripts/lib → lib/verbs}/effort-ops-test.sh +111 -22
  269. package/lib/verbs/effort-ops.sh +1571 -0
  270. package/{scripts/lib → lib/verbs}/effort-parity-test.sh +47 -41
  271. package/{scripts/lib → lib/verbs}/effort-plan-test.sh +7 -7
  272. package/lib/verbs/effort-plan.sh +289 -0
  273. package/lib/verbs/effort-review-test.sh +107 -0
  274. package/lib/verbs/effort-review.sh +93 -0
  275. package/lib/verbs/grill-record-test.sh +49 -0
  276. package/lib/verbs/grill-record.sh +88 -0
  277. package/{scripts/lib → lib/verbs}/handoff.sh +3 -3
  278. package/{scripts → lib/verbs}/init-content-test.sh +14 -14
  279. package/{scripts/lib → lib/verbs}/init-guide.sh +6 -6
  280. package/{scripts → lib/verbs}/init-guided-test.sh +9 -9
  281. package/{scripts → lib/verbs}/init-recipes-test.sh +7 -7
  282. package/{scripts → lib/verbs}/init-upgrade-test.sh +9 -10
  283. package/lib/verbs/init.sh +1598 -0
  284. package/{scripts → lib/verbs}/install-test.sh +5 -5
  285. package/lib/verbs/install.sh +31 -0
  286. package/{scripts → lib/verbs}/integrations-check-test.sh +9 -9
  287. package/lib/verbs/integrations-check.sh +157 -0
  288. package/{scripts → lib/verbs}/kit-add-test.sh +8 -8
  289. package/lib/verbs/kit-add.sh +415 -0
  290. package/{scripts → lib/verbs}/kit-adopt-test.sh +4 -4
  291. package/{scripts → lib/verbs}/kit-adopt.sh +6 -6
  292. package/{scripts/lib → lib/verbs}/kit-brief-test.sh +44 -15
  293. package/{scripts/lib → lib/verbs}/kit-brief.sh +101 -16
  294. package/lib/verbs/kit-bump-version.sh +79 -0
  295. package/lib/verbs/kit-digest.sh +126 -0
  296. package/{scripts → lib/verbs}/kit-doctor-test.sh +57 -32
  297. package/lib/verbs/kit-doctor.sh +991 -0
  298. package/{scripts → lib/verbs}/kit-export-project-test.sh +4 -4
  299. package/lib/verbs/kit-export-project.sh +245 -0
  300. package/{scripts → lib/verbs}/kit-export-training-test.sh +3 -3
  301. package/lib/verbs/kit-export-training.sh +175 -0
  302. package/{scripts/lib → lib/verbs}/kit-gc-test.sh +5 -5
  303. package/lib/verbs/kit-gc.sh +804 -0
  304. package/{scripts/lib → lib/verbs}/kit-hotfix.sh +3 -3
  305. package/{scripts/lib → lib/verbs}/kit-interview-test.sh +2 -2
  306. package/lib/verbs/kit-interview.sh +319 -0
  307. package/{scripts/lib → lib/verbs}/kit-lib-test.sh +2 -2
  308. package/{scripts/lib → lib/verbs}/kit-lib.sh +10 -10
  309. package/{scripts → lib/verbs}/kit-migrate-test.sh +4 -4
  310. package/{scripts → lib/verbs}/kit-migrate.sh +5 -5
  311. package/{scripts/lib → lib/verbs}/kit-msg-test.sh +2 -2
  312. package/{scripts/lib → lib/verbs}/kit-msg.sh +5 -5
  313. package/{scripts → lib/verbs}/kit-onboard-test.sh +2 -3
  314. package/lib/verbs/kit-onboard.sh +69 -0
  315. package/{scripts → lib/verbs}/kit-promote-test.sh +4 -4
  316. package/{scripts → lib/verbs}/kit-promote.sh +4 -4
  317. package/{scripts → lib/verbs}/kit-remove-test.sh +4 -4
  318. package/{scripts → lib/verbs}/kit-remove.sh +5 -5
  319. package/lib/verbs/kit-routines.sh +322 -0
  320. package/lib/verbs/kit-self-update.sh +55 -0
  321. package/{scripts/lib → lib/verbs}/kit-status-test.sh +2 -2
  322. package/lib/verbs/kit-status.sh +650 -0
  323. package/{scripts/lib → lib/verbs}/kit-task-ops-test.sh +25 -2
  324. package/lib/verbs/kit-task-ops.sh +793 -0
  325. package/{scripts → lib/verbs}/kit-version-check-test.sh +3 -3
  326. package/lib/verbs/kit-version-check.sh +121 -0
  327. package/{scripts → lib/verbs}/kit-wire-test.sh +6 -6
  328. package/{scripts → lib/verbs}/kit-wire.sh +8 -8
  329. package/{scripts/lib → lib/verbs}/kto-hotfix-test.sh +3 -3
  330. package/{scripts/lib → lib/verbs}/kto-task-close-test.sh +2 -2
  331. package/{scripts/lib → lib/verbs}/kto-task-new-test.sh +20 -2
  332. package/{scripts/lib → lib/verbs}/kto-task-pr-merge-test.sh +46 -2
  333. package/{scripts/lib → lib/verbs}/kto-task-pr-test.sh +6 -6
  334. package/{scripts/lib → lib/verbs}/light-task-run-test.sh +4 -4
  335. package/{scripts/lib → lib/verbs}/light-task-test.sh +9 -9
  336. package/{scripts/lib → lib/verbs}/light-task.sh +26 -11
  337. package/{scripts/lib → lib/verbs}/next-test.sh +3 -3
  338. package/{scripts/lib → lib/verbs}/next.sh +10 -10
  339. package/{scripts → lib/verbs}/night-grant-test.sh +4 -4
  340. package/lib/verbs/night-grant.sh +454 -0
  341. package/{scripts → lib/verbs}/night-run-test.sh +3 -3
  342. package/{scripts → lib/verbs}/night-run.mjs +2 -2
  343. package/{scripts → lib/verbs}/orchestrate-test.sh +5 -5
  344. package/{scripts → lib/verbs}/orchestrate.sh +15 -15
  345. package/{scripts/lib → lib/verbs}/plan-machine-test.sh +1 -1
  346. package/{scripts/lib → lib/verbs}/plan-machine.sh +13 -13
  347. package/{scripts/lib → lib/verbs}/plan-next-test.sh +1 -1
  348. package/lib/verbs/plan-next.sh +213 -0
  349. package/{scripts → lib/verbs}/publish.sh +10 -10
  350. package/{scripts/lib → lib/verbs}/review-page-test.sh +4 -4
  351. package/lib/verbs/review-page.sh +375 -0
  352. package/lib/verbs/setup-labels.sh +96 -0
  353. package/lib/verbs/setup-milestones.sh +34 -0
  354. package/{scripts → lib/verbs}/showcase.sh +2 -2
  355. package/lib/verbs/sprint-test.sh +96 -0
  356. package/lib/verbs/sprint.sh +216 -0
  357. package/{scripts → lib/verbs}/status-test.sh +8 -8
  358. package/{scripts → lib/verbs}/status.sh +16 -16
  359. package/{scripts → lib/verbs}/task-sync-test.sh +40 -6
  360. package/lib/verbs/task-sync.sh +462 -0
  361. package/{scripts/lib → lib/verbs}/upgrade-report-test.sh +4 -4
  362. package/lib/verbs/ux-a11y-scan.sh +96 -0
  363. package/lib/verbs/ux-ds-audit.sh +146 -0
  364. package/lib/verbs/ux-graph-scan.sh +188 -0
  365. package/{scripts → lib/verbs}/wave-worker.sh +2 -2
  366. package/lib/verbs/web-install.sh +22 -0
  367. package/package.json +3 -10
  368. package/scripts/PROMPTS.md +13 -0
  369. package/scripts/agent-skills-lint.sh +12 -113
  370. package/scripts/agent-template-lint.sh +12 -56
  371. package/scripts/annotate-setup.sh +11 -151
  372. package/scripts/benchmark/checkpoint-test.sh +1 -1
  373. package/scripts/benchmark/checkpoint.sh +1 -1
  374. package/scripts/benchmark/gate.sh +2 -2
  375. package/scripts/benchmark/lib/bench-common.sh +1 -1
  376. package/scripts/capture-project-ids.sh +12 -70
  377. package/scripts/check.sh +12 -106
  378. package/scripts/force-push-fence.sh +14 -0
  379. package/scripts/init.sh +13 -1637
  380. package/scripts/install.sh +12 -29
  381. package/scripts/instruction-budget-lint.sh +13 -218
  382. package/scripts/integrations-check.sh +12 -155
  383. package/scripts/kit-add.sh +12 -413
  384. package/scripts/kit-bump-version.sh +13 -78
  385. package/scripts/kit-digest.sh +13 -125
  386. package/scripts/kit-doctor.sh +13 -971
  387. package/scripts/kit-export-project.sh +12 -243
  388. package/scripts/kit-export-training.sh +12 -173
  389. package/scripts/kit-onboard.sh +12 -67
  390. package/scripts/kit-routines.sh +12 -320
  391. package/scripts/kit-self-update.sh +12 -53
  392. package/scripts/kit-version-check.sh +12 -106
  393. package/scripts/knowledge-lint.sh +13 -98
  394. package/scripts/lib/board-view.sh +13 -96
  395. package/scripts/lib/branch-owner.sh +12 -199
  396. package/scripts/lib/commitlint.sh +12 -52
  397. package/scripts/lib/config-path.sh +13 -29
  398. package/scripts/lib/effort-metrics.sh +12 -589
  399. package/scripts/lib/effort-ops.sh +13 -1243
  400. package/scripts/lib/effort-plan.sh +12 -287
  401. package/scripts/lib/effort.sh +13 -365
  402. package/scripts/lib/gh-log.sh +14 -59
  403. package/scripts/lib/gh-project.sh +13 -254
  404. package/scripts/lib/grill-record.sh +14 -0
  405. package/scripts/lib/integration-install.sh +12 -255
  406. package/scripts/lib/integrations.sh +12 -242
  407. package/scripts/lib/kinds.sh +13 -65
  408. package/scripts/lib/kit-config.sh +12 -165
  409. package/scripts/lib/kit-events.sh +13 -71
  410. package/scripts/lib/kit-gc.sh +12 -802
  411. package/scripts/lib/kit-interview.sh +11 -316
  412. package/scripts/lib/kit-local.sh +12 -85
  413. package/scripts/lib/kit-status.sh +12 -648
  414. package/scripts/lib/kit-task-ops.sh +13 -738
  415. package/scripts/lib/naming.sh +14 -0
  416. package/scripts/lib/plan-next.sh +13 -212
  417. package/scripts/lib/pr-evidence.sh +12 -359
  418. package/scripts/lib/react-detect.sh +12 -77
  419. package/scripts/lib/review-page.sh +11 -372
  420. package/scripts/lib/role-identity.sh +13 -70
  421. package/scripts/lib/secret-guard.sh +12 -114
  422. package/scripts/lib/session-registry.sh +13 -232
  423. package/scripts/lib/spec-lint.sh +14 -0
  424. package/scripts/lib/worktree-issue.sh +12 -170
  425. package/scripts/lib/worktree-start.sh +13 -748
  426. package/scripts/night-grant.sh +12 -452
  427. package/scripts/review-lint.sh +13 -258
  428. package/scripts/setup-labels.sh +11 -82
  429. package/scripts/setup-milestones.sh +12 -21
  430. package/scripts/skill-frontmatter-lint.sh +13 -181
  431. package/scripts/task-sync.sh +13 -370
  432. package/scripts/terms-check.sh +13 -241
  433. package/scripts/ux-a11y-scan.sh +13 -95
  434. package/scripts/ux-ds-audit.sh +12 -144
  435. package/scripts/ux-graph-scan.sh +12 -186
  436. package/scripts/web-install.sh +16 -20
  437. package/docs/kit-annotate/01-explainer.html +0 -225
  438. package/docs/kit-annotate/02-implementation-plan.html +0 -196
  439. package/docs/media/.onboarding-capture.cast +0 -5
  440. package/docs/media/README.md +0 -43
  441. package/docs/media/build-demo.sh +0 -63
  442. package/docs/media/build-kit-init.sh +0 -51
  443. package/docs/media/build-onboarding.sh +0 -51
  444. package/docs/media/kit-dry-run.cast +0 -107
  445. package/docs/media/kit-dry-run.gif +0 -0
  446. package/docs/media/kit-init.cast +0 -56
  447. package/docs/media/kit-init.gif +0 -0
  448. package/docs/media/kit-onboarding.cast +0 -148
  449. package/docs/media/kit-onboarding.gif +0 -0
  450. package/integrations/mempalace.json +0 -28
  451. package/scripts/lib/gh-project-test.sh +0 -135
  452. package/scripts/review-lint-baseline.txt +0 -28
  453. package/scripts/verbs.baseline +0 -5
  454. package/templates/hooks/mempal_followup.sh.tmpl +0 -97
  455. package/templates/hooks/mempal_precompact.sh.tmpl +0 -4
  456. package/templates/hooks/mempal_save.sh.tmpl +0 -4
  457. package/templates/hooks/mempal_session_start.sh.tmpl +0 -42
  458. package/templates/rules/mempalace.md +0 -111
  459. /package/{commands → kit/commands}/kit-docs.md +0 -0
  460. /package/{commands → kit/commands}/kit-export-training.md +0 -0
  461. /package/{databases → kit/databases}/supabase/guide.html +0 -0
  462. /package/{databases → kit/databases}/supabase/nextjs/lib/supabase/client.ts +0 -0
  463. /package/{databases → kit/databases}/supabase/nextjs/lib/supabase/server.ts +0 -0
  464. /package/{githooks → kit/githooks}/pre-commit +0 -0
  465. /package/{integrations → kit/integrations}/emil-design-eng.json +0 -0
  466. /package/{integrations → kit/integrations}/graft.json +0 -0
  467. /package/{integrations → kit/integrations}/impeccable.json +0 -0
  468. /package/{integrations → kit/integrations}/lavish.json +0 -0
  469. /package/{integrations → kit/integrations}/mlx-lm.json +0 -0
  470. /package/{integrations → kit/integrations}/web-design-guidelines.json +0 -0
  471. /package/{recipes → kit/recipes}/nextjs-shadcn.json +0 -0
  472. /package/{skills → kit/skills}/kit-docs-writer/SKILL.md +0 -0
  473. /package/{skills → kit/skills}/kit-onboard/SKILL.md +0 -0
  474. /package/{skills → kit/skills}/kit-security-sweep/SKILL.md +0 -0
  475. /package/{skills → kit/skills}/kit-ship/SKILL.md +0 -0
  476. /package/{skills → kit/skills}/kit-ux-audit/references/a11y.md +0 -0
  477. /package/{skills → kit/skills}/kit-ux-audit/references/consistency.md +0 -0
  478. /package/{skills → kit/skills}/kit-ux-audit/references/heuristics.md +0 -0
  479. /package/{templates → kit/templates}/benchmarks/SCHEMA.md +0 -0
  480. /package/{templates → kit/templates}/benchmarks/abstain.jsonl +0 -0
  481. /package/{templates → kit/templates}/benchmarks/adversarial.jsonl +0 -0
  482. /package/{templates → kit/templates}/benchmarks/benchmark.config.json +0 -0
  483. /package/{templates → kit/templates}/benchmarks/quality.jsonl +0 -0
  484. /package/{templates → kit/templates}/benchmarks/retrieval.jsonl +0 -0
  485. /package/{templates → kit/templates}/codex/hooks.json.tmpl +0 -0
  486. /package/{templates → kit/templates}/hooks/guard-base-branch-commit.sh.tmpl +0 -0
  487. /package/{templates → kit/templates}/hooks/guard-raw-git-ops.sh.tmpl +0 -0
  488. /package/{templates → kit/templates}/hooks/kit-local-status.sh.tmpl +0 -0
  489. /package/{templates → kit/templates}/hooks/kit_version_check.sh.tmpl +0 -0
  490. /package/{templates → kit/templates}/hooks/prepush_gate.sh.tmpl +0 -0
  491. /package/{templates → kit/templates}/hooks/repo-hygiene.sh.tmpl +0 -0
  492. /package/{templates → kit/templates}/knowledge-INDEX.md.tmpl +0 -0
  493. /package/{templates → kit/templates}/lib/kit-sigil.sh.tmpl +0 -0
  494. /package/{templates → kit/templates}/rules/code-retrieval.md +0 -0
  495. /package/{templates → kit/templates}/rules/communication-style.md +0 -0
  496. /package/{templates → kit/templates}/rules/design-routing.md +0 -0
  497. /package/{templates → kit/templates}/rules/issue-lifecycle.md +0 -0
  498. /package/{templates → kit/templates}/rules/knowledge-base.md +0 -0
  499. /package/{templates → kit/templates}/rules/plain-language.md +0 -0
  500. /package/{templates → kit/templates}/rules/plan-output-format.md +0 -0
  501. /package/{templates → kit/templates}/rules/review-pages.md +0 -0
  502. /package/{templates → kit/templates}/rules/risk-tiered-review.md +0 -0
  503. /package/{templates → kit/templates}/rules/shared-checkout.md +0 -0
  504. /package/{templates → kit/templates}/rules/skill-gaps.md +0 -0
  505. /package/{templates → kit/templates}/rules/task-management.md +0 -0
  506. /package/{templates → kit/templates}/settings/settings.json.tmpl +0 -0
  507. /package/{templates → kit/templates}/settings/settings.local.json.tmpl +0 -0
  508. /package/{templates → kit/templates}/skills/NAMESPACED +0 -0
  509. /package/{templates → kit/templates}/skills/brand-voice/SKILL.md +0 -0
  510. /package/{templates → kit/templates}/skills/brand-voice/references/voice-template.md +0 -0
  511. /package/{templates → kit/templates}/skills/campaign/references/plan-template.md +0 -0
  512. /package/{templates → kit/templates}/skills/concrete/SKILL.md +0 -0
  513. /package/{templates → kit/templates}/skills/copywriting/SKILL.md +0 -0
  514. /package/{templates → kit/templates}/skills/copywriting/references/copy-frameworks.md +0 -0
  515. /package/{templates → kit/templates}/skills/copywriting/references/natural-transitions.md +0 -0
  516. /package/{templates → kit/templates}/skills/feature-build-refine/SKILL.md +0 -0
  517. /package/{templates → kit/templates}/skills/karpathy-guidelines/SKILL.md +0 -0
  518. /package/{templates → kit/templates}/skills/morning-briefing/SKILL.md +0 -0
  519. /package/{templates → kit/templates}/skills/page-design/SKILL.md +0 -0
  520. /package/{templates → kit/templates}/skills/page-design/add.json +0 -0
  521. /package/{templates → kit/templates}/skills/page-design/references/design-file-template.md +0 -0
  522. /package/{templates → kit/templates}/skills/page-design/references/generic-page-patterns.md +0 -0
  523. /package/{templates → kit/templates}/skills/page-design/references/minimum-rules.md +0 -0
  524. /package/{templates → kit/templates}/skills/speckit/SKILL.md +0 -0
  525. /package/{templates → kit/templates}/skills/supabase-patterns/SKILL.md +0 -0
  526. /package/{scripts/lib → lib/core}/adapter-select.sh +0 -0
  527. /package/{scripts/lib → lib/core}/agent-launch.sh +0 -0
  528. /package/{scripts/lib → lib/core}/agent-profile.sh +0 -0
  529. /package/{scripts/lib → lib/core}/cckit-output.sh +0 -0
  530. /package/{scripts/lib → lib/core}/codex-hooks.sh +0 -0
  531. /package/{scripts → lib/core}/forge-fence.baseline +0 -0
  532. /package/{scripts/lib → lib/core}/git-remote.sh +0 -0
  533. /package/{scripts/lib → lib/core}/hook-refresh.sh +0 -0
  534. /package/{scripts → lib/core}/instruction-budget-lint-test.sh +0 -0
  535. /package/{scripts/lib → lib/core}/kit-state.sh +0 -0
  536. /package/{scripts/lib → lib/core}/orchestration-runtime.sh +0 -0
  537. /package/{scripts/lib → lib/core}/project-scan.sh +0 -0
  538. /package/{scripts/lib → lib/core}/render.sh +0 -0
  539. /package/{scripts → lib/core}/review-lint-test.sh +0 -0
  540. /package/{scripts/lib → lib/core}/review-stage.sh +0 -0
  541. /package/{scripts → lib/core}/skill-frontmatter-lint-test.sh +0 -0
  542. /package/{scripts/lib → lib/core}/task-source-file.sh +0 -0
  543. /package/{scripts/lib → lib/core}/task-source.sh +0 -0
  544. /package/{scripts/lib → lib/core}/toon.sh +0 -0
  545. /package/{scripts/lib → lib/core}/ui.sh +0 -0
  546. /package/{scripts/lib → lib/forge}/forge-none.sh +0 -0
  547. /package/{scripts → lib/verbs}/debug.sh +0 -0
  548. /package/{scripts → lib/verbs}/night-run.test.mjs +0 -0
  549. /package/{scripts/lib → lib/verbs}/upgrade-report.sh +0 -0
@@ -1,972 +1,14 @@
1
1
  #!/usr/bin/env bash
2
- # kit-doctor — onboarding preflight: deps + brew bootstrap + gh auth/scopes + SSH guided
3
- #
4
- # Usage:
5
- # scripts/kit-doctor.sh # detect + report; in a terminal, ASK before installing.
6
- # # With no terminal and no --fix: report only, nothing is
7
- # # installed and no file is written
8
- # scripts/kit-doctor.sh --fix # install missing deps without asking (alias: --yes, -y)
9
- # scripts/kit-doctor.sh --dry-run # report only — no installs, no auth changes
10
- # scripts/kit-doctor.sh --no-install # check and auth only — skip package installs
11
- # scripts/kit-doctor.sh --dismiss-local # silence the "local layer down" session notice
12
- # # until the next x.y kit update
13
- # scripts/kit-doctor.sh --agents # only the selected agent runtimes (claude / codex):
14
- # # present or absent; exit 1 if one is absent. No network.
15
- #
16
- # Tiers:
17
- # Tier 0 Homebrew (macOS bootstrap — requires sudo password)
18
- # Tier 1 git, gh, jq, perl — hard deps, auto-install via brew
19
- # Tier 2 node + pnpm, vercel, turbo — project-specific, auto-install if applicable
20
- # Agents the runtime binary of each adapter the project selected (`adapters` in the config),
21
- # plus whether the Codex hooks are registered in .codex/hooks.json when codex is selected
22
- # Integr. one row per descriptor in integrations/ that is on (its config key, or on by default
23
- # with the key absent — a missing default-on tool is reported, not failed) — installed by the
24
- # shared runner (scripts/lib/integration-install.sh), only with recorded consent
25
- # Local mlx_lm.server auto-start (when .local.enabled)
26
- # Auth gh auth status + scope:project, git config name/email
27
- # SSH optional guided flow (ed25519, pbcopy, link to github settings)
28
- # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
29
- if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
30
- # shellcheck source=/dev/null
31
- . "$(cd "$(dirname "$0")" && pwd)/lib/gh-rest.sh"
32
- fi
33
-
34
- set -euo pipefail
35
-
36
- # Own directory — so we can find sibling scripts (kit-export-project.sh) regardless of cwd.
37
- _export_dir_doctor="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
38
-
39
- # ---- flags ------------------------------------------------------------------
40
- DRY_RUN=0; NO_INSTALL=0; DISMISS_LOCAL=0; ASSUME_YES=0; AGENTS_ONLY=0
41
- INSTALL_APPROVED=0 # 1 = the operator said yes to installs in THIS run (--fix/--yes, or the prompt)
42
- for _a in "$@"; do
43
- case "$_a" in
44
- --dry-run) DRY_RUN=1 ;;
45
- --no-install) NO_INSTALL=1 ;;
46
- --fix|--yes|-y) ASSUME_YES=1; INSTALL_APPROVED=1 ;;
47
- --dismiss-local) DISMISS_LOCAL=1 ;;
48
- --agents) AGENTS_ONLY=1 ;;
49
- -h|--help)
50
- sed -n '2,15p' "$0" | grep '^#' | sed 's/^# \?//'
51
- exit 0 ;;
52
- esac
53
- done
54
-
55
- # ---- --dismiss-local: record the dismiss and exit (no preflight run) ---------
56
- # Writes .local.dismissed = current kitVersion to kit.config.json; the SessionStart
57
- # notice stays silent until the kit's x.y core moves past it (issue #313).
58
- if [[ $DISMISS_LOCAL -eq 1 ]]; then
59
- command -v kit_config_path >/dev/null 2>&1 || . "$(dirname "$0")/lib/config-path.sh"
60
- _kitcfg="$(kit_config_path "${TARGET:-$PWD}" 2>/dev/null || true)"
61
- [[ -n "$_kitcfg" ]] || _kitcfg="${TARGET:-$PWD}/.claude/kit.config.json"
62
- if ! command -v jq >/dev/null 2>&1 || [[ ! -f "$_kitcfg" ]]; then
63
- echo "kit-doctor: cannot dismiss — need jq + $_kitcfg" >&2
64
- exit 1
65
- fi
66
- _kv="$(jq -r '.kitVersion // "0.0.0"' "$_kitcfg")"
67
- _tmp="$(mktemp)"
68
- jq --arg v "$_kv" '.local.dismissed = $v' "$_kitcfg" > "$_tmp" && mv "$_tmp" "$_kitcfg"
69
- echo "local layer notice dismissed (kit $_kv) — reappears on the next x.y kit update"
70
- echo "re-enable earlier: remove .local.dismissed from .claude/kit.config.json"
71
- exit 0
72
- fi
73
-
74
- # ---- color/unicode detection (matches kit-sigil.sh pattern) -----------------
75
- _loc="${LC_ALL:-${LC_CTYPE:-${LANG:-}}}"
76
- if [ "${KIT_ASCII:-}" = "1" ]; then KIT_UNICODE=0
77
- elif grep -qiE 'utf-?8' <<<"$_loc"; then KIT_UNICODE=1
78
- else KIT_UNICODE=0; fi
79
-
80
- if [ "${FORCE_COLOR:-}" = "1" ]; then KIT_COLOR=1
81
- elif [ -t 1 ] && [ -z "${NO_COLOR+x}" ]; then KIT_COLOR=1
82
- else KIT_COLOR=0; fi
83
-
84
- if [ "$KIT_COLOR" = 1 ]; then
85
- C_AZAFRAN=$'\033[38;2;201;122;44m'
86
- C_SUCCESS=$'\033[38;2;21;128;61m'
87
- C_FAIL=$'\033[38;2;192;50;43m'
88
- C_WARN=$'\033[38;2;180;83;9m'
89
- C_DIM=$'\033[2m'
90
- C_BOLD=$'\033[1m'
91
- C_RESET=$'\033[0m'
92
- else
93
- C_AZAFRAN=''; C_SUCCESS=''; C_FAIL=''; C_WARN=''; C_DIM=''; C_BOLD=''; C_RESET=''
94
- fi
95
-
96
- if [ "$KIT_UNICODE" = 1 ]; then
97
- MARK_OK="${C_SUCCESS}✓${C_RESET}"
98
- MARK_FAIL="${C_FAIL}✗${C_RESET}"
99
- MARK_WARN="${C_WARN}!${C_RESET}"
100
- MARK_SKIP="${C_DIM}-${C_RESET}"
101
- MARK_SEED="${C_AZAFRAN}⡶${C_RESET}"
102
- else
103
- MARK_OK="ok"; MARK_FAIL="FAIL"; MARK_WARN="warn"; MARK_SKIP="-"; MARK_SEED="o"
104
- fi
105
-
106
- # ---- install consent --------------------------------------------------------
107
- # The doctor can install missing dependencies for you (Homebrew, gh, jq, node, …). When a HUMAN runs
108
- # it in a terminal, ASK first — install only if approved. A non-interactive caller that wants
109
- # installs passes --fix/--yes (init.sh's preflight does). A run with no terminal and no --fix has
110
- # nobody to ask, so it is report-only: no package install, no `pnpm install`, no seeded or refreshed
111
- # file, no server start (#448 — it used to run `pnpm install` in whatever directory it was called
112
- # from). --dry-run / --no-install already skip installs entirely. MAY_INSTALL is the one gate every
113
- # install or write below reads.
114
- if [[ $DRY_RUN -eq 0 && $NO_INSTALL -eq 0 && $ASSUME_YES -eq 0 && $AGENTS_ONLY -eq 0 && -t 0 ]]; then
115
- printf '\n %s%scckit doctor can install anything missing for you%s (via Homebrew, corepack, etc.).\n' "$C_BOLD" "" "$C_RESET"
116
- printf ' It will show each thing as it goes. Nothing is installed if you decline.\n\n'
117
- printf ' Install missing dependencies? [Y/n] '
118
- read -r _reply || _reply=""
119
- case "$_reply" in
120
- [nN]|[nN][oO])
121
- NO_INSTALL=1
122
- printf '\n %s report-only — listing what is missing and how to install it (no changes made).\n' "$MARK_SKIP" ;;
123
- *) INSTALL_APPROVED=1 ;; # default (Enter / y) → proceed with installs
124
- esac
125
- fi
126
- MAY_INSTALL=0; UNAPPROVED=0
127
- if [[ $DRY_RUN -eq 0 && $NO_INSTALL -eq 0 ]]; then
128
- if [[ $INSTALL_APPROVED -eq 1 ]]; then MAY_INSTALL=1; else UNAPPROVED=1; fi
129
- fi
130
-
131
- # ---- report accumulators ----------------------------------------------------
132
- CHECKS_OK=0; CHECKS_FAIL=0; CHECKS_WARN=0
133
- ACTIONS_TAKEN=() # things the doctor installed/fixed
134
- ACTIONS_NEEDED=() # things the user must do manually
135
-
136
- row() { # <mark> <label> <detail>
137
- printf ' %-3s %-28s %s\n' "$1" "$2" "${3:-}"
138
- }
139
-
140
- # ---- macOS detection --------------------------------------------------------
141
- IS_MACOS=0
142
- [[ "$(uname -s 2>/dev/null)" == "Darwin" ]] && IS_MACOS=1
143
-
144
- # ---- helpers ----------------------------------------------------------------
145
- has_cmd() { command -v "$1" >/dev/null 2>&1; }
146
-
147
- # brew_install <pkg> [<cmd-to-check>] — install via brew unless dry-run/no-install
148
- # Returns 0 if the command is now available, 1 if not.
149
- brew_install() {
150
- local pkg="$1" cmd="${2:-$1}"
151
- if [[ $MAY_INSTALL -eq 0 ]]; then
152
- return 1
153
- fi
154
- if ! has_cmd brew; then return 1; fi
155
- brew install "$pkg" >/dev/null 2>&1 && has_cmd "$cmd"
156
- }
157
-
158
- # ---- agent runtimes (E257.3) ------------------------------------------------
159
- # One row per adapter the project SELECTED (`adapters` in its config; a config without the key means
160
- # claude). An adapter whose CLI is not on PATH is installed but cannot run, so it is a warning and a
161
- # manual action — the doctor never installs an agent CLI. Sets AGENTS_ABSENT to the count.
162
- AGENTS_ABSENT=0
163
- doctor_agents() {
164
- local _d _sel _name _state _ver _tab
165
- _d="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)"
166
- command -v kit_config_path >/dev/null 2>&1 || . "$_d/lib/config-path.sh"
167
- command -v adapter_runtime_report >/dev/null 2>&1 || . "$_d/lib/adapter-select.sh"
168
- _tab="$(printf '\t')"
169
- if ! _sel="$(adapter_project_list "${TARGET:-$PWD}" 2>/dev/null)"; then
170
- row "$MARK_FAIL" "adapters" "the config's 'adapters' value is invalid (expected claude and/or codex)"
171
- CHECKS_FAIL=$((CHECKS_FAIL + 1)); AGENTS_ABSENT=$((AGENTS_ABSENT + 1))
172
- return 0
173
- fi
174
- while IFS="$_tab" read -r _name _state _ver; do
175
- [[ -n "$_name" ]] || continue
176
- if [[ "$_state" == "present" ]]; then
177
- row "$MARK_OK" "$_name" "$_ver"
178
- CHECKS_OK=$((CHECKS_OK + 1))
179
- else
180
- row "$MARK_WARN" "$_name" "absent — the $_name adapter is selected but its CLI is not on PATH"
181
- CHECKS_WARN=$((CHECKS_WARN + 1)); AGENTS_ABSENT=$((AGENTS_ABSENT + 1))
182
- ACTIONS_NEEDED+=("Install the $_name CLI (the project selects the $_name adapter)")
183
- fi
184
- done <<EOF_AGENTS
185
- $(adapter_runtime_report "$_sel")
186
- EOF_AGENTS
187
- # Codex runs a project's hooks from .codex/hooks.json, and only after the user trusted them. The
188
- # registration is checkable; the trust is Codex's own per-machine state and is not readable here,
189
- # so a registered row says so instead of claiming the hooks run (E257.5).
190
- if adapter_has "$_sel" codex; then
191
- local _root
192
- command -v codex_hooks_registered >/dev/null 2>&1 || . "$_d/lib/codex-hooks.sh"
193
- _root="$(git -C "${TARGET:-$PWD}" rev-parse --show-toplevel 2>/dev/null)"
194
- [[ -n "$_root" ]] || _root="${TARGET:-$PWD}"
195
- if codex_hooks_registered "$_root/.codex/hooks.json" guard-base-branch-commit.sh \
196
- && codex_hooks_registered "$_root/.codex/hooks.json" kit-mail-check.sh; then
197
- row "$MARK_OK" "codex hooks" "registered in .codex/hooks.json — Codex runs them once trusted (/hooks in Codex; trust is not readable from here)"
198
- CHECKS_OK=$((CHECKS_OK + 1))
199
- else
200
- row "$MARK_WARN" "codex hooks" "not registered in .codex/hooks.json — the commit guard and session mail do not run in Codex"
201
- CHECKS_WARN=$((CHECKS_WARN + 1))
202
- ACTIONS_NEEDED+=("Run cckit init --upgrade to register the Codex hooks in .codex/hooks.json")
203
- fi
204
- fi
205
- }
206
-
207
- # ---- --agents: only the runtime rows, then exit (no installs, no network) ----
208
- if [[ $AGENTS_ONLY -eq 1 ]]; then
209
- printf ' %s%sAgent runtimes%s\n' "$C_BOLD" "" "$C_RESET"
210
- doctor_agents
211
- [[ $AGENTS_ABSENT -eq 0 ]] || exit 1
212
- exit 0
213
- fi
214
-
215
- # ============================================================================
216
- # BANNER
217
- # ============================================================================
218
- printf '\n'
219
- printf ' %s%s%s kit-doctor\n' "$MARK_SEED" "$C_BOLD" " / claude-kit${C_RESET}"
220
- printf ' %s\n' "${C_DIM}onboarding preflight${C_RESET}${DRY_RUN:+${C_WARN} [dry-run]${C_RESET}}${NO_INSTALL:+${C_DIM} [no-install]${C_RESET}}"
221
- [[ $UNAPPROVED -eq 1 && $AGENTS_ONLY -eq 0 ]] && printf ' %s report-only — no terminal and no --fix, so nothing is installed and no file is written. To install: cckit doctor --fix\n' "$MARK_SKIP"
222
- printf '\n'
223
-
224
- # ============================================================================
225
- # TIER 0 — Homebrew bootstrap (macOS only)
226
- # ============================================================================
227
- printf ' %s%sTier 0 — bootstrap%s\n' "$C_BOLD" "" "$C_RESET"
228
-
229
- if [[ $IS_MACOS -eq 0 ]]; then
230
- row "$MARK_SKIP" "Homebrew" "not macOS — skipping"
231
- elif has_cmd brew; then
232
- row "$MARK_OK" "Homebrew" "$(brew --version 2>/dev/null | sed -n 1p)"
233
- CHECKS_OK=$((CHECKS_OK + 1))
234
- else
235
- if [[ $MAY_INSTALL -eq 0 ]]; then
236
- row "$MARK_FAIL" "Homebrew" "missing — install: https://brew.sh"
237
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
238
- ACTIONS_NEEDED+=("Install Homebrew: https://brew.sh")
239
- else
240
- printf '\n'
241
- printf ' %s Homebrew not found — running the official installer (will ask for sudo password)...\n' "$MARK_WARN"
242
- printf ' %sInstaller URL: https://brew.sh%s\n\n' "$C_DIM" "$C_RESET"
243
- if /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
244
- # Add brew to PATH for the rest of this session (Apple Silicon path)
245
- [[ -f /opt/homebrew/bin/brew ]] && eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || true
246
- [[ -f /usr/local/bin/brew ]] && eval "$(/usr/local/bin/brew shellenv)" 2>/dev/null || true
247
- row "$MARK_OK" "Homebrew" "installed $(brew --version 2>/dev/null | sed -n 1p)"
248
- CHECKS_OK=$((CHECKS_OK + 1))
249
- ACTIONS_TAKEN+=("Installed Homebrew")
250
- else
251
- row "$MARK_FAIL" "Homebrew" "install failed — see https://brew.sh"
252
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
253
- ACTIONS_NEEDED+=("Manually install Homebrew: https://brew.sh")
254
- fi
255
- fi
256
- fi
257
- printf '\n'
258
-
259
- # ============================================================================
260
- # TIER 1 — hard deps
261
- # ============================================================================
262
- printf ' %s%sTier 1 — hard deps%s\n' "$C_BOLD" "" "$C_RESET"
263
-
264
- # ---- git -------------------------------------------------------------------
265
- if has_cmd git; then
266
- _gitver="$(git --version 2>/dev/null | awk '{print $3}')"
267
- row "$MARK_OK" "git" "$_gitver"
268
- CHECKS_OK=$((CHECKS_OK + 1))
269
- elif brew_install git; then
270
- row "$MARK_OK" "git" "installed $(git --version 2>/dev/null | awk '{print $3}')"
271
- CHECKS_OK=$((CHECKS_OK + 1))
272
- ACTIONS_TAKEN+=("Installed git via brew")
273
- else
274
- row "$MARK_FAIL" "git" "missing — brew install git"
275
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
276
- ACTIONS_NEEDED+=("Install git: brew install git")
277
- fi
278
-
279
- # ---- gh (OPTIONAL: the interactive way to get a token; the forge itself is REST over curl) ----
280
- GH_OK=0
281
- if forge_cli_present; then
282
- _ghver="$(forge_cli_version)"
283
- row "$MARK_OK" "gh (optional)" "${_ghver:-present} — its token is used when GH_TOKEN is unset"
284
- CHECKS_OK=$((CHECKS_OK + 1))
285
- GH_OK=1
286
- else
287
- row "$MARK_SKIP" "gh (optional)" "not installed — a GH_TOKEN works without it; install it for an interactive sign-in"
288
- fi
289
-
290
- # ---- jq -------------------------------------------------------------------
291
- if has_cmd jq; then
292
- row "$MARK_OK" "jq" "$(jq --version 2>/dev/null)"
293
- CHECKS_OK=$((CHECKS_OK + 1))
294
- elif brew_install jq; then
295
- row "$MARK_OK" "jq" "installed $(jq --version 2>/dev/null)"
296
- CHECKS_OK=$((CHECKS_OK + 1))
297
- ACTIONS_TAKEN+=("Installed jq via brew")
298
- else
299
- row "$MARK_FAIL" "jq" "missing — brew install jq"
300
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
301
- ACTIONS_NEEDED+=("Install jq: brew install jq")
302
- fi
303
-
304
- # ---- curl (the forge is REST over curl) -------------------------------------
305
- if has_cmd curl; then
306
- row "$MARK_OK" "curl" "$(curl --version 2>/dev/null | sed -n 1p | awk '{print $2}')"
307
- CHECKS_OK=$((CHECKS_OK + 1))
308
- elif brew_install curl; then
309
- row "$MARK_OK" "curl" "installed"
310
- CHECKS_OK=$((CHECKS_OK + 1))
311
- ACTIONS_TAKEN+=("Installed curl via brew")
312
- else
313
- row "$MARK_FAIL" "curl" "missing — brew install curl (every GitHub call is REST over curl)"
314
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
315
- ACTIONS_NEEDED+=("Install curl: brew install curl")
316
- fi
317
-
318
- # ---- perl -----------------------------------------------------------------
319
- if has_cmd perl; then
320
- row "$MARK_OK" "perl" "$(perl --version 2>/dev/null | sed -n 1,2p | tail -1 | tr -d '()' | awk '{print $2}')"
321
- CHECKS_OK=$((CHECKS_OK + 1))
322
- elif brew_install perl; then
323
- row "$MARK_OK" "perl" "installed"
324
- CHECKS_OK=$((CHECKS_OK + 1))
325
- ACTIONS_TAKEN+=("Installed perl via brew")
326
- else
327
- row "$MARK_FAIL" "perl" "missing — brew install perl"
328
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
329
- ACTIONS_NEEDED+=("Install perl: brew install perl")
330
- fi
331
- printf '\n'
332
-
333
- # ============================================================================
334
- # TIER 2 — project deps (context-aware)
335
- # ============================================================================
336
- printf ' %s%sTier 2 — project deps%s\n' "$C_BOLD" "" "$C_RESET"
337
-
338
- # ---- node + pnpm (check package.json for pinned version) -------------------
339
- _pkg_json="${TARGET:-$PWD}/package.json"
340
- _pkg_mgr=""
341
- [[ -f "$_pkg_json" ]] && _pkg_mgr="$(jq -r '.packageManager // ""' "$_pkg_json" 2>/dev/null || true)"
342
-
343
- if has_cmd node; then
344
- row "$MARK_OK" "node" "$(node --version 2>/dev/null)"
345
- CHECKS_OK=$((CHECKS_OK + 1))
346
- elif brew_install node; then
347
- row "$MARK_OK" "node" "installed $(node --version 2>/dev/null)"
348
- CHECKS_OK=$((CHECKS_OK + 1))
349
- ACTIONS_TAKEN+=("Installed node via brew")
350
- else
351
- row "$MARK_FAIL" "node" "missing — brew install node"
352
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
353
- ACTIONS_NEEDED+=("Install node: brew install node")
354
- fi
355
-
356
- if has_cmd pnpm; then
357
- row "$MARK_OK" "pnpm" "$(pnpm --version 2>/dev/null)"
358
- CHECKS_OK=$((CHECKS_OK + 1))
359
- elif [[ -n "$_pkg_mgr" && "$_pkg_mgr" == pnpm* ]]; then
360
- # Pinned in package.json — enable via corepack
361
- if has_cmd corepack || has_cmd node; then
362
- if [[ $MAY_INSTALL -eq 1 ]]; then
363
- corepack enable pnpm 2>/dev/null && \
364
- corepack prepare "$_pkg_mgr" --activate 2>/dev/null && \
365
- ACTIONS_TAKEN+=("Enabled pnpm via corepack ($_pkg_mgr)") || true
366
- fi
367
- if has_cmd pnpm; then
368
- row "$MARK_OK" "pnpm" "$(pnpm --version 2>/dev/null) (via corepack)"
369
- CHECKS_OK=$((CHECKS_OK + 1))
370
- else
371
- row "$MARK_FAIL" "pnpm" "missing — corepack enable pnpm"
372
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
373
- ACTIONS_NEEDED+=("Enable pnpm: corepack enable pnpm && corepack prepare $_pkg_mgr --activate")
374
- fi
375
- else
376
- row "$MARK_FAIL" "pnpm" "missing — npm install -g pnpm"
377
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
378
- ACTIONS_NEEDED+=("Install pnpm: npm install -g pnpm")
379
- fi
380
- elif brew_install pnpm; then
381
- row "$MARK_OK" "pnpm" "installed $(pnpm --version 2>/dev/null)"
382
- CHECKS_OK=$((CHECKS_OK + 1))
383
- ACTIONS_TAKEN+=("Installed pnpm via brew")
384
- else
385
- row "$MARK_WARN" "pnpm" "not found (needed for turbo monorepo)"
386
- CHECKS_WARN=$((CHECKS_WARN + 1))
387
- ACTIONS_NEEDED+=("Install pnpm: brew install pnpm")
388
- fi
389
-
390
- # ---- node_modules (check if pnpm install needed) ----------------------------
391
- _nm="${TARGET:-$PWD}/node_modules"
392
- if [[ -d "$_nm" ]]; then
393
- row "$MARK_OK" "node_modules" "present"
394
- CHECKS_OK=$((CHECKS_OK + 1))
395
- elif [[ -f "$_pkg_json" ]]; then
396
- if [[ $MAY_INSTALL -eq 1 ]] && has_cmd pnpm; then
397
- printf '\n %s node_modules missing — running pnpm install...\n' "$MARK_WARN"
398
- if pnpm install --frozen-lockfile 2>/dev/null || pnpm install; then
399
- row "$MARK_OK" "node_modules" "installed via pnpm install"
400
- CHECKS_OK=$((CHECKS_OK + 1))
401
- ACTIONS_TAKEN+=("Ran pnpm install")
402
- else
403
- row "$MARK_FAIL" "node_modules" "pnpm install failed — run manually"
404
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
405
- ACTIONS_NEEDED+=("Run pnpm install")
406
- fi
407
- else
408
- row "$MARK_WARN" "node_modules" "missing — run pnpm install"
409
- CHECKS_WARN=$((CHECKS_WARN + 1))
410
- ACTIONS_NEEDED+=("Run pnpm install")
411
- fi
412
- else
413
- row "$MARK_SKIP" "node_modules" "no package.json found — skipping"
414
- fi
415
-
416
- # ---- vercel (only if .vercel/ linked or VERCEL env) -------------------------
417
- _has_vercel_link=0
418
- [[ -d "${TARGET:-$PWD}/.vercel" ]] && _has_vercel_link=1
419
-
420
- if [[ $_has_vercel_link -eq 1 ]] || [[ -n "${VERCEL:-}" ]]; then
421
- if has_cmd vercel; then
422
- row "$MARK_OK" "vercel" "$(vercel --version 2>/dev/null | sed -n 1p)"
423
- CHECKS_OK=$((CHECKS_OK + 1))
424
- elif brew_install vercel vercel; then
425
- row "$MARK_OK" "vercel" "installed $(vercel --version 2>/dev/null | sed -n 1p)"
426
- CHECKS_OK=$((CHECKS_OK + 1))
427
- ACTIONS_TAKEN+=("Installed vercel CLI via brew")
428
- elif [[ $MAY_INSTALL -eq 1 ]] && has_cmd npm; then
429
- npm install -g vercel >/dev/null 2>&1 && \
430
- ACTIONS_TAKEN+=("Installed vercel CLI via npm") || true
431
- if has_cmd vercel; then
432
- row "$MARK_OK" "vercel" "installed $(vercel --version 2>/dev/null | sed -n 1p)"
433
- CHECKS_OK=$((CHECKS_OK + 1))
434
- else
435
- row "$MARK_FAIL" "vercel" "missing — npm install -g vercel"
436
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
437
- ACTIONS_NEEDED+=("Install vercel: npm install -g vercel")
438
- fi
439
- else
440
- row "$MARK_FAIL" "vercel" "missing — npm install -g vercel"
441
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
442
- ACTIONS_NEEDED+=("Install vercel: npm install -g vercel")
443
- fi
444
- else
445
- row "$MARK_SKIP" "vercel" "no .vercel/ project link — skipping"
446
- fi
447
-
448
- # turbo + playwright: dev deps only — never global; check node_modules
449
- if [[ -d "$_nm" ]]; then
450
- if [[ -x "$_nm/.bin/turbo" ]]; then
451
- row "$MARK_OK" "turbo" "dev dep present"
452
- CHECKS_OK=$((CHECKS_OK + 1))
453
- else
454
- row "$MARK_SKIP" "turbo" "not in node_modules (run pnpm install)"
455
- fi
456
- if [[ -x "$_nm/.bin/playwright" ]]; then
457
- row "$MARK_OK" "playwright" "dev dep present"
458
- CHECKS_OK=$((CHECKS_OK + 1))
459
- else
460
- row "$MARK_SKIP" "playwright" "not in node_modules (run pnpm install)"
461
- fi
462
- fi
463
- printf '\n'
464
-
465
- # ============================================================================
466
- # AGENT RUNTIMES — the CLI of each selected adapter
467
- # ============================================================================
468
- printf ' %s%sAgent runtimes%s\n' "$C_BOLD" "" "$C_RESET"
469
- doctor_agents
470
- printf '\n'
471
-
472
- # ============================================================================
473
- # INTEGRATIONS (opt-in — one row per descriptor in integrations/ the project switched on)
474
- # ============================================================================
475
- # An optional third-party tool is DATA: integrations/<id>.json names its config key, its detect
476
- # command and its install candidates in order. This loop holds no tool's recipe. For every
477
- # descriptor whose config key is on it asks the shared runner (lib/integration-install.sh) and
478
- # turns the runner's one status line into a row. Silent when the project switched nothing on.
479
- #
480
- # The runner installs only with consent recorded in .cckit/consent (`install:<id>`). The operator
481
- # saying yes to installs in THIS run — --fix/--yes, or the terminal prompt above — is that consent,
482
- # and is recorded here, so init's `--yes` preflight keeps installing. A run nobody approved (no
483
- # TTY, no --fix) reports the tool missing and installs nothing. --dry-run / --no-install run the
484
- # runner under KIT_DRY_RUN: it plans, and neither installs nor records anything.
485
- command -v kit_config_path >/dev/null 2>&1 || . "$(dirname "$0")/lib/config-path.sh"
486
- _kitcfg="$(kit_config_path "${TARGET:-$PWD}" 2>/dev/null || true)"
487
- [[ -n "$_kitcfg" ]] || _kitcfg="${TARGET:-$PWD}/.claude/kit.config.json"
488
-
489
- # doctor_integration <descriptor> — one row for one enabled integration.
490
- doctor_integration() {
491
- local f="$1" id label recipe st bin after also
492
- id="$(jq -r '.id' "$f")"; label="$(jq -r '.label' "$f")"
493
- recipe="$(jq -r '.install[0].run' "$f")"
494
- if integration_detect "$f" "$_ig_target"; then
495
- bin="$(integration_bin "$f" || true)"
496
- row "$MARK_OK" "$label" "installed${bin:+ ($bin)}"
497
- CHECKS_OK=$((CHECKS_OK + 1))
498
- return 0
499
- fi
500
- if ! integration_applies "$f" "$_ig_target"; then
501
- row "$MARK_SKIP" "$label" "needs $(integration_applies_needs "$f") — skipping install"
502
- return 0
503
- fi
504
- # On by default and never chosen by this project: its callers fall back without the tool, so a
505
- # missing one is reported, does not fail the run, and is NOT installed — a yes to installs covers
506
- # what the project switched on. `cckit add <id>` writes the key, and then the rows below apply.
507
- if integration_default_on "$f" && ! integration_explicit "$f" "$_kitcfg"; then
508
- row "$MARK_SKIP" "$label" "not installed — on by default, falls back without it. By hand: $recipe (or 'cckit add $id', then 'cckit doctor --fix')"
509
- return 0
510
- fi
511
- if [[ $DRY_RUN -eq 1 || $NO_INSTALL -eq 1 ]]; then
512
- st="$(KIT_DRY_RUN=1 integration_install "$f" "$_ig_target" 2>/dev/null || true)"
513
- else
514
- if [[ $INSTALL_APPROVED -eq 1 ]]; then integration_consent_record "$id" "$_ig_target" || true; fi
515
- st="$(integration_install "$f" "$_ig_target" || true)"
516
- fi
517
- case "$st" in
518
- present|installed\ *)
519
- bin="$(integration_bin "$f" || true)"
520
- if [[ "$st" == present ]]; then
521
- row "$MARK_OK" "$label" "installed${bin:+ ($bin)}"
522
- else
523
- after="$(jq -r '.afterInstall // ""' "$f")"
524
- # What the installer writes besides the file `detect` checks (descriptor: alsoWrites).
525
- also="$(jq -r '(.alsoWrites // []) | join(", ")' "$f")"
526
- row "$MARK_OK" "$label" "installed via ${st#installed }${bin:+ ($bin)}${also:+ — it also wrote: $also}"
527
- ACTIONS_TAKEN+=("Installed $label via ${st#installed }${also:+ — it also wrote: $also}${after:+ — $after}")
528
- fi
529
- CHECKS_OK=$((CHECKS_OK + 1)) ;;
530
- dry-run)
531
- row "$MARK_FAIL" "$label" "missing — $recipe"
532
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
533
- ACTIONS_NEEDED+=("Install $label: $recipe") ;;
534
- no-consent)
535
- row "$MARK_FAIL" "$label" "missing — nothing installs without your yes: cckit doctor --fix"
536
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
537
- ACTIONS_NEEDED+=("Install $label: cckit doctor --fix (or by hand: $recipe)") ;;
538
- *)
539
- row "$MARK_FAIL" "$label" "install failed — $recipe"
540
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
541
- ACTIONS_NEEDED+=("Install $label: $recipe") ;;
542
- esac
543
- }
544
-
545
- _ig_target="${TARGET:-$PWD}"
546
- if has_cmd jq && [[ -f "$_kitcfg" ]]; then
547
- # shellcheck source=/dev/null
548
- . "$_export_dir_doctor/lib/integration-install.sh"
549
- _ig_shown=0
550
- for _ig_id in $(integrations_list); do
551
- _ig_f="$(integration_file "$_ig_id")" || continue
552
- integration_enabled "$_ig_f" "$_kitcfg" || continue
553
- if [[ $_ig_shown -eq 0 ]]; then
554
- printf ' %s%sIntegrations (optional tools that are on in this project)%s\n' "$C_BOLD" "" "$C_RESET"
555
- _ig_shown=1
556
- fi
557
- doctor_integration "$_ig_f"
558
- done
559
- if [[ $_ig_shown -eq 1 ]]; then printf '\n'; fi
560
- fi
561
-
562
- # ============================================================================
563
- # PAGE-DESIGN SKILL (only checked when tasks.design is true)
564
- # ============================================================================
565
- # `tasks.design: true` makes every task of the project a page task, and a page task tells the agent
566
- # to load cckit's `page-design` skill. The key alone installs nothing: a project already at the
567
- # installed version gets no file from `cckit init --upgrade`. One row per selected adapter says
568
- # whether the skill is in its skills folder, and a missing one names the command that copies it.
569
- if has_cmd jq && [[ -f "$_kitcfg" ]] && [[ "$(jq -r '.tasks.design // false' "$_kitcfg" 2>/dev/null)" == "true" ]]; then
570
- command -v adapter_list_from_config >/dev/null 2>&1 || . "$_export_dir_doctor/lib/adapter-select.sh"
571
- printf ' %s%sPage tasks (tasks.design is on)%s\n' "$C_BOLD" "" "$C_RESET"
572
- _pd_root="$(dirname "$_kitcfg")"
573
- [[ "$(basename "$_pd_root")" == ".claude" ]] && _pd_root="$(dirname "$_pd_root")"
574
- for _pd_a in $(adapter_list_from_config "$_kitcfg" 2>/dev/null || echo claude); do
575
- _pd_dir="$(adapter_dir "$_pd_a")/skills/page-design"
576
- if [[ -f "$_pd_root/$_pd_dir/SKILL.md" ]]; then
577
- row "$MARK_OK" "page-design skill" "$_pd_dir"
578
- CHECKS_OK=$((CHECKS_OK + 1))
579
- else
580
- row "$MARK_FAIL" "page-design skill" "missing from $_pd_dir — run: cckit add page-design"
581
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
582
- ACTIONS_NEEDED+=("Add the page-design skill ($_pd_dir): cckit add page-design")
583
- fi
584
- done
585
- printf '\n'
586
- fi
587
-
588
- # ============================================================================
589
- # LOCAL MODEL LAYER (opt-in — only checked when .local.enabled is true)
590
- # ============================================================================
591
- # Same gating principle as vercel: silence when the project didn't opt in. The runtime itself is
592
- # an integration (integrations/mlx-lm.json) and was handled by the loop above; this section is the
593
- # part that is not an install — the server. When the runtime is present but the server is down,
594
- # the doctor starts it in background + health-checks the port. --dry-run stays 100% read-only: it
595
- # reports what it would do and starts nothing.
596
- _local_on="false"
597
- [[ -f "$_kitcfg" ]] && _local_on="$(jq -r '.local.enabled // false' "$_kitcfg" 2>/dev/null || echo false)"
598
- if [[ "$_local_on" == "true" ]]; then
599
- printf ' %s%sLocal model layer (mlx_lm.server)%s\n' "$C_BOLD" "" "$C_RESET"
600
- _lport="$(jq -r '.local.port // 8080' "$_kitcfg" 2>/dev/null || echo 8080)"
601
- _lmodel="$(jq -r '.local.model // "mlx-community/Qwen3-8B-4bit"' "$_kitcfg" 2>/dev/null || echo "mlx-community/Qwen3-8B-4bit")"
602
-
603
- # Apple silicon — MLX requirement (the descriptor's appliesWhen.platform gates the install)
604
- if [[ $IS_MACOS -eq 1 && "$(uname -m 2>/dev/null)" == "arm64" ]]; then
605
- row "$MARK_OK" "apple silicon" "$(sysctl -n machdep.cpu.brand_string 2>/dev/null || echo arm64)"
606
- CHECKS_OK=$((CHECKS_OK + 1))
607
- else
608
- row "$MARK_WARN" "apple silicon" "MLX needs an Apple silicon Mac — local layer will stay dormant here"
609
- CHECKS_WARN=$((CHECKS_WARN + 1))
610
- fi
611
-
612
- # the server binary — resolved through the descriptor, so ~/.local/bin is searched too
613
- _mlx_bin="$(integration_bin "$(integration_file mlx-lm 2>/dev/null || true)" 2>/dev/null || true)"
614
-
615
- # server alive on the configured port — auto-start when down + installed
616
- _lurl="http://127.0.0.1:${_lport}/v1/models"
617
- if curl -sf -m 1 "$_lurl" >/dev/null 2>&1; then
618
- row "$MARK_OK" "server" "alive @ :${_lport} (${_lmodel##*/}) — NL chores run at \$0"
619
- CHECKS_OK=$((CHECKS_OK + 1))
620
- elif [[ -z "$_mlx_bin" ]]; then
621
- row "$MARK_WARN" "server" "not running — install mlx-lm first, then re-run kit-doctor"
622
- CHECKS_WARN=$((CHECKS_WARN + 1))
623
- ACTIONS_NEEDED+=("Start the local model server: mlx_lm.server --model ${_lmodel} --port ${_lport}")
624
- elif [[ $DRY_RUN -eq 1 || $UNAPPROVED -eq 1 ]]; then
625
- row "$MARK_WARN" "server" "not running — would start mlx_lm.server in background (first run downloads ~4.5 GB)"
626
- CHECKS_WARN=$((CHECKS_WARN + 1))
627
- ACTIONS_NEEDED+=("Start the local model server: mlx_lm.server --model ${_lmodel} --port ${_lport}")
628
- else
629
- _llog="$HOME/.claude/kit-local-server.log"
630
- mkdir -p "$HOME/.claude" 2>/dev/null || _llog="${TMPDIR:-/tmp}/kit-local-server.log"
631
- # first-run warning: model not in the HF cache yet → server stays "loading" for a while
632
- _hfdir="$HOME/.cache/huggingface/hub/models--${_lmodel//\//--}"
633
- [[ -d "$_hfdir" ]] || printf ' %s first run: the model downloads now (~4.5 GB) — the server may take several minutes to come up\n' "$MARK_WARN"
634
- printf ' %s server down — starting mlx_lm.server in background (log: %s)...\n' "$MARK_WARN" "$_llog"
635
- nohup "$_mlx_bin" --model "$_lmodel" --port "$_lport" >>"$_llog" 2>&1 &
636
- _mlx_pid=$!
637
- _lup=0
638
- for _i in $(seq 1 30); do
639
- if curl -sf -m 1 "$_lurl" >/dev/null 2>&1; then _lup=1; break; fi
640
- kill -0 "$_mlx_pid" 2>/dev/null || break
641
- sleep 1
642
- done
643
- if [[ $_lup -eq 1 ]]; then
644
- row "$MARK_OK" "server" "started @ :${_lport} (${_lmodel##*/}) — NL chores run at \$0"
645
- CHECKS_OK=$((CHECKS_OK + 1))
646
- ACTIONS_TAKEN+=("Started mlx_lm.server @ :${_lport} (pid $_mlx_pid)")
647
- elif kill -0 "$_mlx_pid" 2>/dev/null; then
648
- row "$MARK_WARN" "server" "starting (pid $_mlx_pid) — model still downloading/loading; check: curl :${_lport}/v1/models"
649
- CHECKS_WARN=$((CHECKS_WARN + 1))
650
- ACTIONS_TAKEN+=("Started mlx_lm.server (pid $_mlx_pid) — still loading, log: $_llog")
651
- else
652
- row "$MARK_FAIL" "server" "failed to start — see $_llog"
653
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
654
- ACTIONS_NEEDED+=("Start the local model server manually: mlx_lm.server --model ${_lmodel} --port ${_lport} (log: $_llog)")
655
- fi
656
- fi
657
- printf '\n'
658
- fi
659
-
660
- # ============================================================================
661
- # MEMORY LAYER (MemPalace) — opt-in — only checked when .memory.enabled is true
662
- # ============================================================================
663
- # Same gating principle as the local model layer: silent unless the project opted
664
- # into memory at init. Two things to verify:
665
- # 1. a per-wing identity header exists. `mempalace wake-up` scopes the L1 *body* to the
666
- # wing, but reads its L0 identity *header* from the single global ~/.mempalace/identity.txt
667
- # (mempalace layers.py Layer0), so every wing shows the same — usually wrong — header
668
- # unless .claude/mempal-identity.<wing>.txt is present. --fix seeds a starter from kit.config.
669
- # 2. the session-start hook is current — older hooks just ran `wake-up --wing` and could not
670
- # apply the per-wing header from (1). --fix re-emits the hook from the kit template.
671
- # The CLI itself is an integration (integrations/mempalace.json), handled by the loop above.
672
- _mem_on="false"
673
- [[ -f "$_kitcfg" ]] && _mem_on="$(jq -r '.memory.enabled // false' "$_kitcfg" 2>/dev/null || echo false)"
674
- if [[ "$_mem_on" == "true" ]]; then
675
- printf ' %s%sMemory (MemPalace)%s\n' "$C_BOLD" "" "$C_RESET"
676
- _mwing="$(jq -r '.memory.wing // .project.slug // ""' "$_kitcfg" 2>/dev/null || echo "")"
677
- [[ -z "$_mwing" || "$_mwing" == "null" ]] && _mwing="$(basename "${TARGET:-$PWD}")"
678
-
679
- # 1. per-wing identity header — the fix for the global-header bug
680
- _idfile="${TARGET:-$PWD}/.claude/mempal-identity.${_mwing}.txt"
681
- _idfile_generic="${TARGET:-$PWD}/.claude/mempal-identity.txt"
682
- if [[ -s "$_idfile" ]] || [[ -s "$_idfile_generic" ]]; then
683
- _present="$_idfile"; [[ -s "$_idfile" ]] || _present="$_idfile_generic"
684
- row "$MARK_OK" "identity header" "wing-scoped (${_present#${TARGET:-$PWD}/})"
685
- CHECKS_OK=$((CHECKS_OK + 1))
686
- elif [[ $MAY_INSTALL -eq 1 ]]; then
687
- # Seed a starter header from kit.config so this wing stops inheriting the global identity.
688
- _owner="$(jq -r '.project.owner // ""' "$_kitcfg" 2>/dev/null || echo "")"
689
- _pname="$(jq -r '.project.name // ""' "$_kitcfg" 2>/dev/null || echo "")"
690
- [[ -z "$_pname" || "$_pname" == "null" ]] && _pname="$_mwing"
691
- {
692
- printf 'Project: %s (wing: %s)\n' "$_pname" "$_mwing"
693
- [[ -n "$_owner" && "$_owner" != "null" ]] && printf 'Owner: %s\n' "$_owner"
694
- printf 'Stack: (describe this project — this header shows on every session wake-up)\n'
695
- } > "$_idfile"
696
- row "$MARK_OK" "identity header" "seeded .claude/mempal-identity.${_mwing}.txt — edit the Stack line"
697
- ACTIONS_TAKEN+=("Seeded per-wing MemPalace header .claude/mempal-identity.${_mwing}.txt (edit it to taste)")
698
- CHECKS_OK=$((CHECKS_OK + 1))
699
- else
700
- row "$MARK_WARN" "identity header" "missing — wake-up shows the global ~/.mempalace/identity.txt for every wing"
701
- CHECKS_WARN=$((CHECKS_WARN + 1))
702
- ACTIONS_NEEDED+=("Create .claude/mempal-identity.${_mwing}.txt so this wing has its own wake-up header (or run: cckit doctor --fix)")
703
- fi
704
-
705
- # 2. session-start hook freshness — the `mempal-identity` marker means the hook
706
- # knows how to swap in the per-wing header (1). Older hooks lack it.
707
- _hook="${TARGET:-$PWD}/.claude/hooks/mempal_session_start.sh"
708
- _kit_root="$(dirname "$_export_dir_doctor")"
709
- _hook_tmpl="$_kit_root/templates/hooks/mempal_session_start.sh.tmpl"
710
- if [[ ! -f "$_hook" ]]; then
711
- : # no hook installed — the integration row already covers a non-functioning memory layer
712
- elif grep -q 'mempal-identity' "$_hook" 2>/dev/null; then
713
- row "$MARK_OK" "session-start hook" "current — applies the per-wing header"
714
- CHECKS_OK=$((CHECKS_OK + 1))
715
- elif [[ $MAY_INSTALL -eq 1 && -f "$_hook_tmpl" ]]; then
716
- # Re-emit from the template (only {{WING}} to substitute; no IF blocks in this hook).
717
- if sed "s|{{WING}}|${_mwing}|g" "$_hook_tmpl" > "$_hook"; then
718
- chmod +x "$_hook"
719
- row "$MARK_OK" "session-start hook" "refreshed — now applies the per-wing header"
720
- ACTIONS_TAKEN+=("Refreshed .claude/hooks/mempal_session_start.sh (now swaps in the per-wing header)")
721
- CHECKS_OK=$((CHECKS_OK + 1))
722
- else
723
- row "$MARK_WARN" "session-start hook" "stale — refresh failed; re-run: cckit init --upgrade"
724
- CHECKS_WARN=$((CHECKS_WARN + 1))
725
- ACTIONS_NEEDED+=("Refresh the session-start hook manually: cckit init --upgrade")
726
- fi
727
- else
728
- row "$MARK_WARN" "session-start hook" "stale — ignores the per-wing header (runs wake-up --wing only)"
729
- CHECKS_WARN=$((CHECKS_WARN + 1))
730
- ACTIONS_NEEDED+=("Refresh the session-start hook: cckit doctor --fix (or cckit init --upgrade)")
731
- fi
732
- printf '\n'
733
- fi
734
-
735
- # ============================================================================
736
- # AUTH + CONFIG
737
- # ============================================================================
738
- printf ' %s%sAuth + config%s\n' "$C_BOLD" "" "$C_RESET"
739
-
740
- # ---- the forge (GitHub through a token) --------------------------------------
741
- # forge.provider: github when a token resolves (GH_TOKEN, GITHUB_TOKEN, or gh's), else none. With
742
- # none every verb that needs GitHub refuses by name and the git steps still run (scripts/lib/forge.sh).
743
- GH_AUTHED=0
744
- _fprov="$(forge_provider 2>/dev/null || echo none)"
745
- if [[ "$_fprov" == "none" ]]; then
746
- if [[ $DRY_RUN -eq 0 && $MAY_INSTALL -eq 1 ]] && forge_cli_present; then
747
- printf '\n %s no GitHub token — launching gh auth login (device flow)...\n\n' "$MARK_WARN"
748
- if forge_login; then
749
- unset _FORGE_LOADED; _fprov="$(forge_provider 2>/dev/null || echo none)"
750
- ACTIONS_TAKEN+=("Signed in to GitHub through gh auth login")
751
- fi
752
- fi
753
- fi
754
- if [[ "$_fprov" == "none" ]]; then
755
- row "$MARK_WARN" "forge" "none — git-only. Issues, pull requests and labels are unavailable until a token is set: export GH_TOKEN=<token>, or gh auth login"
756
- CHECKS_WARN=$((CHECKS_WARN + 1))
757
- ACTIONS_NEEDED+=("Sign in to GitHub: export GH_TOKEN=<token> (or: gh auth login)")
758
- else
759
- _ghuser="$(gh_rest_user_login 2>/dev/null || true)"
760
- if [[ -n "$_ghuser" ]]; then
761
- row "$MARK_OK" "forge" "github — signed in as @$_ghuser"
762
- CHECKS_OK=$((CHECKS_OK + 1))
763
- GH_AUTHED=1
764
- else
765
- row "$MARK_FAIL" "forge" "github — the token does not work (GH_TOKEN, GITHUB_TOKEN, or gh's). Re-issue it, or gh auth login"
766
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
767
- ACTIONS_NEEDED+=("Fix the GitHub token: export GH_TOKEN=<token>, or gh auth login")
768
- fi
769
- fi
770
-
771
- # ---- token scope: project (Projects v2 silently fails without it) ------------
772
- GH_SCOPE_PROJECT=0
773
- _pv2="false"; [[ -f "$_kitcfg" ]] && _pv2="$(jq -r '.github.projectsV2 // false' "$_kitcfg" 2>/dev/null || echo false)"
774
- if [[ $GH_AUTHED -eq 1 && "$_pv2" == "true" ]]; then
775
- _token_scopes="$(forge_token_scopes 2>/dev/null || true)"
776
- if grep -qi 'project' <<<"$_token_scopes"; then
777
- row "$MARK_OK" "token scope:project" "present"
778
- CHECKS_OK=$((CHECKS_OK + 1))
779
- GH_SCOPE_PROJECT=1
780
- elif [[ -z "$_token_scopes" ]]; then
781
- row "$MARK_SKIP" "token scope:project" "a fine-grained token lists no scopes — give it Projects access if the board stays empty"
782
- elif [[ $DRY_RUN -eq 1 || $MAY_INSTALL -eq 0 ]] || ! forge_cli_present; then
783
- row "$MARK_FAIL" "token scope:project" "missing — gh auth refresh -s project (or re-issue the token with it)"
784
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
785
- ACTIONS_NEEDED+=("Add scope: gh auth refresh -s project")
786
- else
787
- printf '\n %s scope "project" missing — running gh auth refresh (will open browser)...\n\n' "$MARK_WARN"
788
- if forge_login_scope project; then
789
- row "$MARK_OK" "token scope:project" "added"
790
- CHECKS_OK=$((CHECKS_OK + 1))
791
- GH_SCOPE_PROJECT=1
792
- ACTIONS_TAKEN+=("Added the project scope through gh auth refresh")
793
- else
794
- row "$MARK_FAIL" "token scope:project" "refresh failed — gh auth refresh -s project"
795
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
796
- ACTIONS_NEEDED+=("Add scope: gh auth refresh -s project")
797
- fi
798
- fi
799
- elif [[ $GH_AUTHED -eq 1 ]]; then
800
- row "$MARK_SKIP" "token scope:project" "Projects v2 is off — not needed"
801
- fi
802
-
803
- # ---- git config user.name + user.email -------------------------------------
804
- _git_name="$(git config --global user.name 2>/dev/null || true)"
805
- if [[ -n "$_git_name" ]]; then
806
- row "$MARK_OK" "git user.name" "$_git_name"
807
- CHECKS_OK=$((CHECKS_OK + 1))
808
- else
809
- row "$MARK_FAIL" "git user.name" "not set — git config --global user.name \"Your Name\""
810
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
811
- ACTIONS_NEEDED+=("Set git identity: git config --global user.name \"Your Name\"")
812
- fi
813
-
814
- _git_email="$(git config --global user.email 2>/dev/null || true)"
815
- if [[ -n "$_git_email" ]]; then
816
- row "$MARK_OK" "git user.email" "$_git_email"
817
- CHECKS_OK=$((CHECKS_OK + 1))
818
- else
819
- row "$MARK_FAIL" "git user.email" "not set — git config --global user.email \"you@example.com\""
820
- CHECKS_FAIL=$((CHECKS_FAIL + 1))
821
- ACTIONS_NEEDED+=("Set git email: git config --global user.email \"you@example.com\"")
822
- fi
823
-
824
- # ---- base branch vs GitHub default -----------------------------------------
825
- # `Closes #N` auto-close only fires when a PR merges into the repo's DEFAULT branch. If this
826
- # project integrates on a non-default branch (github.baseBranch, e.g. develop) that mismatch
827
- # silently leaves issues open on native/UI merges. cckit's own `pr-merge` closes them explicitly,
828
- # but the misalignment still bites anyone who merges from the GitHub UI — so surface it.
829
- if [[ $GH_AUTHED -eq 1 ]] && [[ -f "$_kitcfg" ]]; then
830
- _cfg_repo="$(jq -r '.github.repo // empty' "$_kitcfg" 2>/dev/null || true)"
831
- # Same fallback chain as load_kit_config (#117) so the warning judges the branch cckit actually
832
- # integrates on: baseBranch -> integrationBranch -> flow -> "main".
833
- _cfg_base="$(jq -r '.github.baseBranch // .github.integrationBranch // .github.flow // "main"' "$_kitcfg" 2>/dev/null || echo main)"
834
- if [[ -n "$_cfg_repo" ]]; then
835
- _gh_default="$(gh_rest_repo_default_branch "$_cfg_repo" 2>/dev/null || true)"
836
- if [[ -z "$_gh_default" ]]; then
837
- row "$MARK_SKIP" "base branch" "couldn't read GitHub default for $_cfg_repo — skipped"
838
- elif [[ "$_cfg_base" == "$_gh_default" ]]; then
839
- row "$MARK_OK" "base branch" "$_cfg_base = GitHub default"
840
- CHECKS_OK=$((CHECKS_OK + 1))
841
- else
842
- row "$MARK_WARN" "base branch" "baseBranch '$_cfg_base' ≠ GitHub default '$_gh_default' — 'Closes #N' won't auto-close on GitHub-UI merges"
843
- CHECKS_WARN=$((CHECKS_WARN + 1))
844
- ACTIONS_NEEDED+=("Align base branch: make '$_cfg_base' the default branch of $_cfg_repo on GitHub (or set github.baseBranch to '$_gh_default'). Note: 'cckit merge' already closes linked issues explicitly.")
845
- fi
846
- fi
847
- fi
848
- printf '\n'
849
-
850
- # ============================================================================
851
- # SSH (optional guided flow)
852
- # ============================================================================
853
- printf ' %s%sSSH (optional — HTTPS with the token is the default)%s\n' "$C_BOLD" "" "$C_RESET"
854
-
855
- _ssh_result=0
856
- grep -q "successfully authenticated" <<<"$(ssh -T git@github.com -o ConnectTimeout=5 -o BatchMode=yes 2>&1)" && _ssh_result=1 || true
857
-
858
- if [[ $_ssh_result -eq 1 ]]; then
859
- row "$MARK_OK" "SSH to github.com" "key already accepted"
860
- CHECKS_OK=$((CHECKS_OK + 1))
861
- else
862
- row "$MARK_SKIP" "SSH to github.com" "no key — HTTPS with the token is used by default"
863
-
864
- # Show guided SSH setup only if user explicitly wants SSH
865
- if [[ "${KIT_DOCTOR_SSH:-}" == "1" && $DRY_RUN -eq 0 ]]; then
866
- _ssh_key="$HOME/.ssh/id_ed25519_kit"
867
- if [[ ! -f "$_ssh_key" ]]; then
868
- printf '\n Generating ed25519 SSH key at %s...\n' "$_ssh_key"
869
- ssh-keygen -t ed25519 -f "$_ssh_key" -C "claude-kit onboarding" -N "" 2>/dev/null
870
- ACTIONS_TAKEN+=("Generated SSH key $_ssh_key")
871
- fi
872
- if has_cmd pbcopy; then
873
- pbcopy < "${_ssh_key}.pub"
874
- printf ' Public key copied to clipboard.\n'
875
- else
876
- cat "${_ssh_key}.pub"
877
- fi
878
- printf '\n Paste the public key at: https://github.com/settings/ssh/new\n'
879
- ACTIONS_NEEDED+=("Add SSH public key: https://github.com/settings/ssh/new")
880
- else
881
- printf ' %sTip: set KIT_DOCTOR_SSH=1 and re-run to generate an ed25519 key.%s\n' "$C_DIM" "$C_RESET"
882
- fi
883
- fi
884
- printf '\n'
885
-
886
- # ============================================================================
887
- # SURFACE PORTABILITY (connection test — terminal / Cowork / claude.ai, #376)
888
- # ============================================================================
889
- # A kit project should run on all three Claude surfaces with no hand edits. Terminal + Cowork read
890
- # CLAUDE.md + .claude/ natively; claude.ai needs the kit-export-project transform. This test asks
891
- # the same question kit-export-project --verify does: is the PORTABLE surface self-sufficient — does
892
- # every file CLAUDE.md leans on carry tier-A (portable) semantics, not a tier-B CLI-only shim that
893
- # would silently no-op off-terminal? Read-only; gated on a kit project (CLAUDE.md present).
894
- _kit_target="${TARGET:-$PWD}"
895
- _export_script="$_export_dir_doctor/kit-export-project.sh"
896
- if [[ -f "$_kit_target/CLAUDE.md" && -f "$_export_script" ]]; then
897
- printf ' %s%sSurface portability (terminal / Cowork / claude.ai)%s\n' "$C_BOLD" "" "$C_RESET"
898
- if ( cd "$_kit_target" && bash "$_export_script" --verify ) >/dev/null 2>&1; then
899
- row "$MARK_OK" "portable surface" "tier-A self-sufficient — runs in terminal/Cowork/claude.ai unchanged"
900
- CHECKS_OK=$((CHECKS_OK + 1))
901
- else
902
- row "$MARK_WARN" "portable surface" "defect(s) — run: kit-export-project.sh --verify"
903
- CHECKS_WARN=$((CHECKS_WARN + 1))
904
- ACTIONS_NEEDED+=("Inspect portability: scripts/kit-export-project.sh --verify (then export for claude.ai with no args)")
905
- fi
906
- printf '\n'
907
- fi
908
-
909
- # ============================================================================
910
- # INSTRUCTION FILES (resident context budget, #357)
911
- # ============================================================================
912
- # CLAUDE.md and every .claude/rules/*.md without a `paths:` frontmatter load into every session;
913
- # Claude Code warns at startup once they pass 150k characters combined. Show the number and the
914
- # three largest files here so it is seen before that warning is. Read-only, and the same
915
- # measurement the gate uses (instruction-budget-lint.sh --summary). Absent when the project has no
916
- # instruction files.
917
- _budget_lint="$_export_dir_doctor/instruction-budget-lint.sh"
918
- if [[ -f "$_budget_lint" ]]; then
919
- _budget_line="$(INSTRUCTION_BUDGET_ROOT="$_kit_target" bash "$_budget_lint" --summary 2>/dev/null || true)"
920
- if [[ -n "$_budget_line" ]]; then
921
- printf ' %s%sInstruction files (loaded into every session)%s\n' "$C_BOLD" "" "$C_RESET"
922
- _budget_resident="$(printf '%s' "$_budget_line" | awk '{print $3}')"
923
- _budget_limit="$(printf '%s' "$_budget_line" | awk '{print $5}')"
924
- if [[ "$_budget_resident" =~ ^[0-9]+$ && "$_budget_limit" =~ ^[0-9]+$ && "$_budget_resident" -gt "$_budget_limit" ]]; then
925
- row "$MARK_WARN" "resident budget" "$_budget_line"
926
- CHECKS_WARN=$((CHECKS_WARN + 1))
927
- ACTIONS_NEEDED+=("Trim resident instruction files: scripts/instruction-budget-lint.sh --report (scope a rule with paths:, or split it into a short rule + a knowledge doc)")
928
- else
929
- row "$MARK_OK" "resident budget" "$_budget_line"
930
- CHECKS_OK=$((CHECKS_OK + 1))
931
- fi
932
- printf '\n'
933
- fi
934
- fi
935
-
936
- # ============================================================================
937
- # SUMMARY
938
- # ============================================================================
939
- printf ' %s%sSummary%s\n' "$C_BOLD" "" "$C_RESET"
940
- printf ' %-4s %s checked ok\n' "" "$CHECKS_OK"
941
- [[ $CHECKS_WARN -gt 0 ]] && printf ' %-4s %s warnings\n' "" "$CHECKS_WARN"
942
- [[ $CHECKS_FAIL -gt 0 ]] && printf ' %-4s %s failed\n' "" "$CHECKS_FAIL"
943
-
944
- if [[ ${#ACTIONS_TAKEN[@]} -gt 0 ]]; then
945
- printf '\n %s%sInstalled / fixed:%s\n' "$C_BOLD" "" "$C_RESET"
946
- for _a in "${ACTIONS_TAKEN[@]}"; do
947
- printf ' %s %s\n' "$MARK_OK" "$_a"
948
- done
949
- fi
950
-
951
- if [[ ${#ACTIONS_NEEDED[@]} -gt 0 ]]; then
952
- printf '\n %s%sAction required:%s\n' "$C_BOLD" "" "$C_RESET"
953
- for _a in "${ACTIONS_NEEDED[@]}"; do
954
- printf ' %s %s\n' "$MARK_FAIL" "$_a"
955
- done
956
- fi
957
- printf '\n'
958
-
959
- # ---- onboarding / docs pointer ---------------------------------------------
960
- # Show the local onboarding app ONLY when something actually answers on it —
961
- # otherwise point at the public docs. (Previously this always printed
962
- # http://localhost:3001/onboarding even when nothing served that port.)
963
- _admin_url="${CCKIT_ADMIN_URL:-http://localhost:3001}"
964
- if has_cmd curl && curl -fsS --max-time 1 "$_admin_url/onboarding" >/dev/null 2>&1; then
965
- printf ' %sOnboarding guide (web): %s/onboarding%s\n' "$C_DIM" "$_admin_url" "$C_RESET"
966
- else
967
- printf ' %sDocs & quick start: %shttps://cckit.dev%s\n' "$C_DIM" "" "$C_RESET"
968
- fi
969
- printf '\n'
970
-
971
- # Exit non-zero when critical checks failed
972
- [[ $CHECKS_FAIL -gt 0 ]] && exit 1 || exit 0
2
+ # cckit-forwarding-stub: scripts/kit-doctor.sh moved to lib/verbs/kit-doctor.sh (#602). Installed projects call this path, so
3
+ # the stub stays until the release after 0.13 (decision 66). Sourced (bash or zsh) or run, it forwards.
4
+ _cckit_self="${BASH_SOURCE[0]:-$0}"
5
+ _cckit_fwd="$(cd "$(dirname "$_cckit_self")" 2>/dev/null && pwd)/../lib/verbs/kit-doctor.sh"
6
+ _cckit_sourced=0
7
+ if [ -n "${ZSH_VERSION:-}" ]; then
8
+ case "${ZSH_EVAL_CONTEXT:-}" in *file*) _cckit_sourced=1 ;; esac
9
+ elif [ "$_cckit_self" != "$0" ]; then
10
+ _cckit_sourced=1
11
+ fi
12
+ # shellcheck source=/dev/null
13
+ if [ "$_cckit_sourced" = 1 ]; then unset _cckit_self _cckit_sourced; . "$_cckit_fwd" "$@"; return $?; fi
14
+ exec bash "$_cckit_fwd" "$@"