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