@jeiemgi/cckit 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +169 -21
  3. package/README.md +491 -35
  4. package/SECURITY.md +5 -0
  5. package/bin/cckit +182 -17
  6. package/cckit.config.json +1 -1
  7. package/commands/kit-doctor.md +13 -5
  8. package/commands/kit-export-project.md +0 -2
  9. package/commands/kit-export-training.md +6 -9
  10. package/commands/kit-init.md +43 -13
  11. package/commands/kit-routines.md +1 -1
  12. package/commands/kit-update.md +11 -6
  13. package/databases/supabase/guide.html +106 -0
  14. package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
  15. package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
  16. package/databases/supabase.json +70 -0
  17. package/integrations/emil-design-eng.json +41 -0
  18. package/integrations/graft.json +81 -0
  19. package/integrations/impeccable.json +42 -0
  20. package/integrations/integration.schema.json +215 -0
  21. package/integrations/lavish.json +43 -0
  22. package/integrations/mempalace.json +28 -0
  23. package/integrations/mlx-lm.json +32 -0
  24. package/integrations/web-design-guidelines.json +42 -0
  25. package/kit.config.schema.json +183 -5
  26. package/package.json +4 -1
  27. package/profiles/automation.json +7 -1
  28. package/profiles/content.json +10 -2
  29. package/profiles/marketing.json +57 -0
  30. package/profiles/minimal.json +7 -1
  31. package/profiles/research.json +7 -1
  32. package/profiles/software.json +7 -1
  33. package/recipes/nextjs-shadcn.json +49 -0
  34. package/scripts/agent-skills-external.txt +45 -0
  35. package/scripts/agent-skills-lint-test.sh +131 -0
  36. package/scripts/agent-skills-lint.sh +115 -0
  37. package/scripts/agent-template-lint-test.sh +42 -0
  38. package/scripts/agent-template-lint.sh +58 -0
  39. package/scripts/annotate-setup.sh +1 -1
  40. package/scripts/autopilot-run-test.sh +338 -0
  41. package/scripts/autopilot-run.sh +448 -0
  42. package/scripts/autopilot-test.sh +8 -0
  43. package/scripts/autopilot.sh +10 -1
  44. package/scripts/benchmark/benchmark-test.sh +85 -0
  45. package/scripts/benchmark/checkpoint-test.sh +314 -0
  46. package/scripts/benchmark/checkpoint.sh +408 -0
  47. package/scripts/benchmark/lib/model.sh +31 -6
  48. package/scripts/benchmark/report.sh +17 -2
  49. package/scripts/benchmark/run-quality.sh +36 -10
  50. package/scripts/benchmark/verb-timings-test.sh +124 -0
  51. package/scripts/benchmark/verb-timings.sh +149 -0
  52. package/scripts/check.sh +29 -19
  53. package/scripts/content-skills-test.sh +144 -0
  54. package/scripts/copilot-loop-test.sh +25 -0
  55. package/scripts/database-supabase-test.sh +121 -0
  56. package/scripts/docs-marketing-words-test.sh +73 -0
  57. package/scripts/docs-record-tables-test.sh +72 -0
  58. package/scripts/hook-adapter-test.sh +193 -0
  59. package/scripts/init-content-test.sh +225 -0
  60. package/scripts/init-guided-test.sh +474 -0
  61. package/scripts/init-recipes-test.sh +104 -0
  62. package/scripts/init-upgrade-test.sh +341 -2
  63. package/scripts/init.sh +746 -95
  64. package/scripts/instruction-budget-baseline.txt +8 -0
  65. package/scripts/instruction-budget-lint-test.sh +166 -0
  66. package/scripts/instruction-budget-lint.sh +219 -0
  67. package/scripts/integrations-check-test.sh +200 -0
  68. package/scripts/integrations-check.sh +157 -0
  69. package/scripts/kit-add-test.sh +214 -0
  70. package/scripts/kit-add.sh +305 -5
  71. package/scripts/kit-adopt-test.sh +16 -0
  72. package/scripts/kit-adopt.sh +3 -2
  73. package/scripts/kit-digest.sh +2 -2
  74. package/scripts/kit-doctor-test.sh +293 -0
  75. package/scripts/kit-doctor.sh +272 -140
  76. package/scripts/kit-export-project-test.sh +3 -3
  77. package/scripts/kit-remove-test.sh +19 -0
  78. package/scripts/kit-routines.sh +2 -2
  79. package/scripts/kit-self-update.sh +1 -1
  80. package/scripts/kit-version-check-test.sh +4 -0
  81. package/scripts/kit-version-check.sh +4 -2
  82. package/scripts/knowledge-lint.sh +4 -4
  83. package/scripts/leak-fence-test.sh +89 -0
  84. package/scripts/lib/adapter-select-test.sh +136 -0
  85. package/scripts/lib/adapter-select.sh +158 -0
  86. package/scripts/lib/agent-def-test.sh +69 -0
  87. package/scripts/lib/agent-def.sh +106 -0
  88. package/scripts/lib/agent-launch-test.sh +212 -0
  89. package/scripts/lib/agent-launch.sh +335 -0
  90. package/scripts/lib/board-view-test.sh +11 -0
  91. package/scripts/lib/board-view.sh +42 -26
  92. package/scripts/lib/branch-owner-test.sh +26 -0
  93. package/scripts/lib/branch-owner.sh +16 -9
  94. package/scripts/lib/captain-test.sh +105 -0
  95. package/scripts/lib/captain.sh +87 -8
  96. package/scripts/lib/codex-hooks-test.sh +100 -0
  97. package/scripts/lib/codex-hooks.sh +69 -0
  98. package/scripts/lib/commitlint.sh +1 -1
  99. package/scripts/lib/content-kinds-gc-test.sh +88 -0
  100. package/scripts/lib/copilot-test.sh +70 -4
  101. package/scripts/lib/copilot.sh +66 -14
  102. package/scripts/lib/effort-dispatch-test.sh +3 -3
  103. package/scripts/lib/effort-metrics-test.sh +178 -1
  104. package/scripts/lib/effort-metrics.sh +175 -35
  105. package/scripts/lib/effort-ops-test.sh +205 -7
  106. package/scripts/lib/effort-ops.sh +198 -43
  107. package/scripts/lib/effort-parity-test.sh +49 -13
  108. package/scripts/lib/effort-plan-test.sh +337 -0
  109. package/scripts/lib/effort-plan.sh +200 -23
  110. package/scripts/lib/effort.sh +56 -11
  111. package/scripts/lib/errors-header-test.sh +1 -1
  112. package/scripts/lib/gh-project-test.sh +35 -1
  113. package/scripts/lib/gh-project.sh +23 -16
  114. package/scripts/lib/gh-rest-test.sh +32 -3
  115. package/scripts/lib/gh-rest.sh +17 -2
  116. package/scripts/lib/hook-refresh.sh +1 -1
  117. package/scripts/lib/init-github.sh +412 -0
  118. package/scripts/lib/init-guide.sh +630 -0
  119. package/scripts/lib/integration-install-test.sh +343 -0
  120. package/scripts/lib/integration-install.sh +257 -0
  121. package/scripts/lib/integrations-test.sh +366 -0
  122. package/scripts/lib/integrations.sh +244 -0
  123. package/scripts/lib/kinds-test.sh +125 -0
  124. package/scripts/lib/kinds.sh +66 -0
  125. package/scripts/lib/kit-brief-test.sh +22 -3
  126. package/scripts/lib/kit-brief.sh +45 -5
  127. package/scripts/lib/kit-config-resolve.sh +2 -2
  128. package/scripts/lib/kit-config-test.sh +64 -1
  129. package/scripts/lib/kit-config.sh +37 -1
  130. package/scripts/lib/kit-events.sh +7 -0
  131. package/scripts/lib/kit-gc-test.sh +173 -1
  132. package/scripts/lib/kit-gc.sh +226 -37
  133. package/scripts/lib/kit-hotfix.sh +216 -0
  134. package/scripts/lib/kit-interview-test.sh +93 -0
  135. package/scripts/lib/kit-interview.sh +117 -8
  136. package/scripts/lib/kit-lib-test.sh +1 -1
  137. package/scripts/lib/kit-lib.sh +3 -3
  138. package/scripts/lib/kit-local.sh +2 -2
  139. package/scripts/lib/kit-manifest.sh +33 -1
  140. package/scripts/lib/kit-profile-test.sh +3 -3
  141. package/scripts/lib/kit-status-test.sh +112 -4
  142. package/scripts/lib/kit-status.sh +246 -16
  143. package/scripts/lib/kit-task-ops-test.sh +37 -0
  144. package/scripts/lib/kit-task-ops.sh +175 -31
  145. package/scripts/lib/kto-hotfix-test.sh +232 -0
  146. package/scripts/lib/kto-task-close-test.sh +1 -1
  147. package/scripts/lib/kto-task-new-test.sh +95 -0
  148. package/scripts/lib/kto-task-pr-merge-test.sh +37 -3
  149. package/scripts/lib/kto-task-pr-test.sh +70 -0
  150. package/scripts/lib/leak-fence.sh +89 -0
  151. package/scripts/lib/light-task-run-test.sh +255 -0
  152. package/scripts/lib/light-task-test.sh +309 -0
  153. package/scripts/lib/light-task.sh +706 -0
  154. package/scripts/lib/next-test.sh +99 -0
  155. package/scripts/lib/next.sh +9 -3
  156. package/scripts/lib/orchestration-runtime-test.sh +72 -0
  157. package/scripts/lib/orchestration-runtime.sh +57 -5
  158. package/scripts/lib/plan-machine-test.sh +15 -2
  159. package/scripts/lib/plan-machine.sh +20 -7
  160. package/scripts/lib/plan-next-test.sh +1 -1
  161. package/scripts/lib/plan-next.sh +4 -4
  162. package/scripts/lib/pr-evidence-test.sh +3 -3
  163. package/scripts/lib/pr-evidence.sh +1 -1
  164. package/scripts/lib/qa-lane-test.sh +626 -0
  165. package/scripts/lib/qa-lane.sh +1357 -0
  166. package/scripts/lib/qa-lanes-test.sh +175 -0
  167. package/scripts/lib/react-detect.sh +1 -1
  168. package/scripts/lib/render-test.sh +1 -1
  169. package/scripts/lib/review-page-test.sh +318 -0
  170. package/scripts/lib/review-page.sh +369 -0
  171. package/scripts/lib/review-stage-test.sh +62 -11
  172. package/scripts/lib/review-stage.sh +42 -60
  173. package/scripts/lib/role-identity-test.sh +65 -0
  174. package/scripts/lib/role-identity.sh +25 -2
  175. package/scripts/lib/secret-guard.sh +3 -3
  176. package/scripts/lib/session-registry-test.sh +111 -0
  177. package/scripts/lib/session-registry.sh +233 -0
  178. package/scripts/lib/stage-receipt-test.sh +14 -1
  179. package/scripts/lib/stage-receipt.sh +13 -8
  180. package/scripts/lib/task-source-file.sh +309 -0
  181. package/scripts/lib/task-source.sh +130 -0
  182. package/scripts/lib/upgrade-report-test.sh +120 -0
  183. package/scripts/lib/upgrade-report.sh +138 -0
  184. package/scripts/lib/version-bump.sh +3 -3
  185. package/scripts/lib/wave-result-test.sh +80 -0
  186. package/scripts/lib/wave-result.sh +127 -0
  187. package/scripts/lib/worker-brief-test.sh +5 -0
  188. package/scripts/lib/worker-brief.sh +2 -2
  189. package/scripts/lib/worktree-issue-test.sh +30 -1
  190. package/scripts/lib/worktree-issue.sh +82 -12
  191. package/scripts/lib/worktree-ports-test.sh +57 -4
  192. package/scripts/lib/worktree-start-test.sh +197 -0
  193. package/scripts/lib/worktree-start.sh +153 -31
  194. package/scripts/lib/zsh-safety-test.sh +19 -3
  195. package/scripts/marketing-walkthrough-test.sh +152 -0
  196. package/scripts/night-grant-test.sh +37 -0
  197. package/scripts/night-grant.sh +448 -0
  198. package/scripts/night-run-test.sh +8 -0
  199. package/scripts/night-run.mjs +275 -0
  200. package/scripts/night-run.test.mjs +324 -0
  201. package/scripts/orchestrate-test.sh +190 -0
  202. package/scripts/orchestrate.sh +79 -8
  203. package/scripts/portable-test.sh +11 -2
  204. package/scripts/publish.sh +28 -3
  205. package/scripts/review-lint-test.sh +7 -7
  206. package/scripts/review-lint.sh +2 -2
  207. package/scripts/review-rules.conf +8 -0
  208. package/scripts/rule-recipes-test.sh +96 -0
  209. package/scripts/self-install-test.sh +39 -9
  210. package/scripts/setup-labels.sh +18 -1
  211. package/scripts/setup-milestones.sh +1 -1
  212. package/scripts/showcase.sh +1 -1
  213. package/scripts/skill-frontmatter-lint-test.sh +4 -4
  214. package/scripts/skill-frontmatter-lint.sh +1 -1
  215. package/scripts/status-test.sh +113 -2
  216. package/scripts/status.sh +16 -3
  217. package/scripts/task-sync-test.sh +154 -0
  218. package/scripts/task-sync.sh +243 -32
  219. package/scripts/test-runner-test.sh +158 -0
  220. package/scripts/test.sh +131 -23
  221. package/scripts/update-path-test.sh +279 -0
  222. package/scripts/ux-ds-audit.sh +1 -1
  223. package/scripts/ux-graph-scan.sh +6 -6
  224. package/scripts/wave-worker.sh +54 -0
  225. package/skills/kit-add/SKILL.md +77 -0
  226. package/skills/kit-autopilot/SKILL.md +123 -12
  227. package/skills/kit-cleanup/SKILL.md +5 -2
  228. package/skills/kit-contribute/SKILL.md +4 -4
  229. package/skills/kit-docs-writer/SKILL.md +16 -6
  230. package/skills/kit-effort-close/SKILL.md +17 -8
  231. package/skills/kit-effort-new/SKILL.md +15 -9
  232. package/skills/kit-effort-pr/SKILL.md +15 -7
  233. package/skills/kit-effort-start/SKILL.md +5 -2
  234. package/skills/kit-gc/SKILL.md +5 -2
  235. package/skills/kit-next/SKILL.md +5 -1
  236. package/skills/kit-onboard/SKILL.md +3 -3
  237. package/skills/kit-page/SKILL.md +93 -0
  238. package/skills/kit-plan-next/SKILL.md +8 -4
  239. package/skills/kit-security-sweep/SKILL.md +1 -3
  240. package/skills/kit-ship/SKILL.md +2 -3
  241. package/skills/kit-status/SKILL.md +35 -4
  242. package/skills/kit-task-new/SKILL.md +3 -3
  243. package/skills/kit-task-pr/SKILL.md +7 -2
  244. package/skills/kit-task-pr-merge/SKILL.md +7 -2
  245. package/skills/kit-task-start/SKILL.md +7 -7
  246. package/skills/kit-task-sync/SKILL.md +19 -3
  247. package/skills/kit-ux-audit/SKILL.md +3 -2
  248. package/templates/agents/auto-dev.md +5 -4
  249. package/templates/agents/backend.md +1 -1
  250. package/templates/agents/designer.md +2 -0
  251. package/templates/agents/devops.md +1 -1
  252. package/templates/agents/editor.md +9 -1
  253. package/templates/agents/frontend.md +1 -1
  254. package/templates/agents/local-delegate.md +1 -1
  255. package/templates/agents/pm.md +5 -5
  256. package/templates/agents/tech-lead.md +1 -1
  257. package/templates/benchmarks/SCHEMA.md +9 -3
  258. package/templates/codex/hooks.json.tmpl +89 -0
  259. package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
  260. package/templates/hooks/guard-raw-git-ops.sh.tmpl +12 -12
  261. package/templates/hooks/mempal_followup.sh.tmpl +2 -2
  262. package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
  263. package/templates/hooks/prepush_gate.sh.tmpl +4 -2
  264. package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
  265. package/templates/instructions.md.tmpl +174 -0
  266. package/templates/kit.config.json.tmpl +3 -3
  267. package/templates/knowledge-INDEX.md.tmpl +1 -1
  268. package/templates/lib/kit-sigil.sh.tmpl +1 -1
  269. package/templates/rules/authoring.md +106 -0
  270. package/templates/rules/branch-naming.md +40 -4
  271. package/templates/rules/code-retrieval.md +63 -0
  272. package/templates/rules/delegation-brief.md +0 -3
  273. package/templates/rules/design-routing.md +3 -3
  274. package/templates/rules/effort-model.md +14 -10
  275. package/templates/rules/gate-and-review.md +94 -0
  276. package/templates/rules/issue-lifecycle.md +88 -0
  277. package/templates/rules/knowledge-base.md +1 -1
  278. package/templates/rules/mempalace.md +1 -1
  279. package/templates/rules/merge-safety.md +108 -0
  280. package/templates/rules/naming-and-ids.md +23 -17
  281. package/templates/rules/plain-language.md +59 -0
  282. package/templates/rules/plan-next.md +9 -11
  283. package/templates/rules/react-annotate.md +6 -0
  284. package/templates/rules/review-pages.md +49 -0
  285. package/templates/rules/risk-tiered-review.md +13 -4
  286. package/templates/rules/shared-checkout.md +106 -0
  287. package/templates/rules/skill-gaps.md +2 -7
  288. package/templates/rules/task-management.md +13 -1
  289. package/templates/skills/brand-voice/SKILL.md +91 -0
  290. package/templates/skills/brand-voice/references/voice-template.md +61 -0
  291. package/templates/skills/campaign/SKILL.md +123 -0
  292. package/templates/skills/campaign/references/plan-template.md +55 -0
  293. package/templates/skills/concrete/SKILL.md +2 -2
  294. package/templates/skills/copywriting/SKILL.md +8 -1
  295. package/templates/skills/feature-build-refine/SKILL.md +2 -4
  296. package/templates/skills/morning-briefing/SKILL.md +2 -2
  297. package/templates/skills/page-design/SKILL.md +145 -0
  298. package/templates/skills/page-design/add.json +5 -0
  299. package/templates/skills/page-design/references/design-file-template.md +40 -0
  300. package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
  301. package/templates/skills/page-design/references/minimum-rules.md +42 -0
  302. package/templates/skills/speckit/SKILL.md +4 -5
  303. package/templates/skills/supabase-patterns/SKILL.md +1 -1
  304. package/commands/kit-add.md +0 -42
  305. package/templates/CLAUDE.md.tmpl +0 -106
package/scripts/init.sh CHANGED
@@ -3,12 +3,21 @@
3
3
  # Substitutes {{VARS}} and resolves <!-- IF:FLAG --> blocks from a role profile.
4
4
  #
5
5
  # Usage:
6
- # scripts/init.sh --profile software --name "My App" [flags]
6
+ # scripts/init.sh [<folder>] [flags] # guided setup: detect, ask, scaffold, git + GitHub
7
+ # scripts/init.sh --profile software --no-github # scaffold only, nothing outside the folder
7
8
  # scripts/init.sh --upgrade --target <dir> # merge new features into an existing setup
8
9
  #
9
- # Flags (all optional except --profile; sensible defaults derived otherwise):
10
- # --profile <software|content|research|minimal> role profile (required unless --upgrade)
11
- # --target <dir> project root to scaffold into (default: $PWD)
10
+ # Flags (all optional; sensible defaults derived otherwise):
11
+ # <folder> | --target <dir> project folder (created when missing) (default: $PWD)
12
+ # --no-github scaffold only: no git init, no commit, no GitHub write
13
+ # --yes run the git + GitHub setup without asking (required with no terminal)
14
+ # --public create the GitHub repository public (default: private)
15
+ # --answers <file> JSON {"<question key>":"<answer>"} for the guided questions
16
+ # --recipe <id|none> start a NEW project from recipes/<id>.json
17
+ # --database <id|none> add the database option databases/<id>.json
18
+ # --profile <name> role profile, one of profiles/*.json: software · content · marketing ·
19
+ # research · automation · minimal (asked when a terminal or an
20
+ # answers file is there; else required unless --upgrade)
12
21
  # --name <str> human project name (default: target basename)
13
22
  # --slug <str> short slug / mempalace wing (default: lowercased basename)
14
23
  # --repo <owner/repo> GitHub repo (default: <owner>/<slug>)
@@ -19,11 +28,15 @@
19
28
  # --plans-dir <dir> where plans live (default: per format)
20
29
  # --memory <on|off> enable MemPalace memory + hooks (default: profile default)
21
30
  # --speckit <on|off> add the Spec-Driven Development flow (default: off)
31
+ # --plain-language <on|off> install the plain-language rule: the agent says draft, review and
32
+ # approve, and names git mechanics only when asked (default: profile default)
22
33
  # --prepush "<command>" install an opt-in pre-push gate that runs <command> before
23
34
  # `git push` and blocks on failure (default: none -> no gate)
24
35
  # --local <on|off> local model layer (mlx_lm.server) for NL chores at $0 API cost
25
36
  # (config + SessionStart status hook) (default: off)
26
37
  # --lang <str> working language (default: English)
38
+ # --adapter <claude|codex|both> which agent adapter(s) to install (default: claude; with
39
+ # --upgrade: the stored selection, and a named adapter is ADDED to it)
27
40
  # --upgrade merge new kit features into an existing .claude/ (preserves your edits)
28
41
  # --dry-run print the scaffold plan and exit, writing nothing
29
42
  # --force overwrite without prompting
@@ -53,7 +66,7 @@ _kit_banner_detect_mode() {
53
66
  local _loc="${LC_ALL:-${LC_CTYPE:-${LANG:-}}}"
54
67
  if [ "${KIT_ASCII:-}" = "1" ]; then
55
68
  KIT_UNICODE=0
56
- elif printf '%s' "$_loc" | grep -qiE 'utf-?8'; then
69
+ elif grep -qiE 'utf-?8' <<<"$_loc"; then
57
70
  KIT_UNICODE=1
58
71
  else
59
72
  KIT_UNICODE=0
@@ -228,6 +241,9 @@ KIT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
228
241
  _DOCTOR="$KIT_ROOT/scripts/kit-doctor.sh"
229
242
  _INIT_SKIP_PREFLIGHT=0
230
243
  for _ia in "$@"; do [[ "$_ia" == "--upgrade" || "$_ia" == "--dry-run" ]] && _INIT_SKIP_PREFLIGHT=1; done
244
+ # KIT_INIT_PREFLIGHT=0 skips it too: the fixture tests drive a FRESH init, and the doctor installs
245
+ # packages and checks gh auth — neither belongs in a network-free test.
246
+ [[ "${KIT_INIT_PREFLIGHT:-1}" == "0" ]] && _INIT_SKIP_PREFLIGHT=1
231
247
 
232
248
  if [[ $_INIT_SKIP_PREFLIGHT -eq 0 && -x "$_DOCTOR" ]]; then
233
249
  # --yes: init's preflight installs Tier-1 deps non-interactively (no approval prompt here; the
@@ -244,14 +260,21 @@ else
244
260
  fi
245
261
 
246
262
  # ---- parse flags ---------------------------------------------------------
263
+ _INIT_ARGS=("$@") # as typed — the --upgrade dry run replays them against a copy (#448)
247
264
  PROFILE=""; TARGET="$PWD"; NAME=""; SLUG=""; REPO=""; GH_OWNER=""; OWNER_NAME=""
248
265
  PROJECT_NUMBER=""; PLANS_FORMAT=""; PLANS_DIR=""; MEMORY=""; LANG_PREF="English"; FORCE=0
266
+ PLAIN_LANGUAGE=""
267
+ TASKS_DEFAULT="" # light | issues — the profile's defaults.tasks; on --upgrade, the stored tasks.default
249
268
  SPECKIT=""; PREPUSH_CMD=""; LOCAL_LAYER=""; LOCAL_EXPLICIT=0; DRY_RUN=0; UPGRADE=0
269
+ ADAPTER_ARG="" # --adapter as typed; resolved to ADAPTERS below (stored selection wins on upgrade)
270
+ # Guided setup (#456): the folder as typed, the git + GitHub steps, the advisor's answers.
271
+ FOLDER_GIVEN=0; NO_GITHUB=0; ASSUME_YES=0; REPO_VISIBILITY="private"; INIT_ANSWERS=""
272
+ RECIPE_ARG=""; DATABASE_ARG=""
250
273
  SKILL_PREFIX="" # namespace applied to kit-namespaced skill templates (from kit.config .skillPrefix on upgrade)
251
274
  while [[ $# -gt 0 ]]; do
252
275
  case "$1" in
253
276
  --profile) PROFILE="$2"; shift 2 ;;
254
- --target) TARGET="$2"; shift 2 ;;
277
+ --target) TARGET="$2"; FOLDER_GIVEN=1; shift 2 ;;
255
278
  --name) NAME="$2"; shift 2 ;;
256
279
  --slug) SLUG="$2"; shift 2 ;;
257
280
  --repo) REPO="$2"; shift 2 ;;
@@ -262,25 +285,67 @@ while [[ $# -gt 0 ]]; do
262
285
  --plans-dir) PLANS_DIR="$2"; shift 2 ;;
263
286
  --memory) MEMORY="$2"; shift 2 ;;
264
287
  --speckit) SPECKIT="$2"; shift 2 ;;
288
+ --plain-language) PLAIN_LANGUAGE="$2"; shift 2 ;;
265
289
  --prepush) PREPUSH_CMD="$2"; shift 2 ;;
266
290
  --local) LOCAL_LAYER="$2"; LOCAL_EXPLICIT=1; shift 2 ;;
267
291
  --lang) LANG_PREF="$2"; shift 2 ;;
268
292
  --force) FORCE=1; shift ;;
269
293
  --upgrade) UPGRADE=1; shift ;;
270
294
  --dry-run) DRY_RUN=1; shift ;;
271
- -h|--help) sed -n '2,31p' "$0"; exit 0 ;;
272
- *) echo "x unknown flag: $1" >&2; exit 1 ;;
295
+ --adapter) ADAPTER_ARG="$2"; shift 2 ;;
296
+ --no-github) NO_GITHUB=1; shift ;;
297
+ --yes|-y) ASSUME_YES=1; shift ;;
298
+ --public) REPO_VISIBILITY="public"; shift ;;
299
+ --answers) INIT_ANSWERS="$2"; shift 2 ;;
300
+ --recipe) RECIPE_ARG="$2"; shift 2 ;;
301
+ --database) DATABASE_ARG="$2"; shift 2 ;;
302
+ -h|--help) sed -n '2,42p' "$0"; exit 0 ;;
303
+ -*) echo "x unknown flag: $1" >&2; exit 1 ;;
304
+ *) if [[ $FOLDER_GIVEN -eq 1 ]]; then echo "x one folder only (got '$TARGET' and '$1')" >&2; exit 1; fi
305
+ TARGET="$1"; FOLDER_GIVEN=1; shift ;;
273
306
  esac
274
307
  done
275
308
 
309
+ # ---- adapter selection (E257.3) -------------------------------------------
310
+ # Validated here, before anything is written: an unknown adapter name refuses the whole run.
311
+ # shellcheck source=/dev/null
312
+ . "$KIT_ROOT/scripts/lib/adapter-select.sh"
313
+ ADAPTERS_NEW=""
314
+ if [[ -n "$ADAPTER_ARG" ]]; then
315
+ ADAPTERS_NEW="$(adapter_normalize "$ADAPTER_ARG")" || { echo "x --adapter takes claude, codex or both (got '$ADAPTER_ARG')" >&2; exit 1; }
316
+ fi
317
+ ADAPTERS="${ADAPTERS_NEW:-claude}" # fresh init; --upgrade replaces this with the stored selection
318
+ ADAPTER_ADDED=0
319
+
320
+ # ---- guided setup: name the folder, ask what is missing (#456) -------------
321
+ # Before anything is written. `--upgrade` never enters it: an upgrade works on a project that is
322
+ # already set up and asks nothing.
323
+ # shellcheck source=/dev/null
324
+ . "$KIT_ROOT/scripts/lib/init-guide.sh"
325
+ # shellcheck source=/dev/null
326
+ . "$KIT_ROOT/scripts/lib/init-github.sh"
327
+ INIT_CLASS=""; INIT_NEW=0; INIT_ALREADY=0; RECIPE_FILE=""; DB_FILE=""; DB_STACK=""; SETUP_RUN=0
328
+ if [[ $UPGRADE -eq 0 ]]; then
329
+ if [[ -n "$INIT_ANSWERS" && ! -f "$INIT_ANSWERS" ]]; then echo "x --answers: no such file: $INIT_ANSWERS" >&2; exit 2; fi
330
+ if [[ -n "$INIT_ANSWERS" ]] && ! jq -e 'type == "object"' "$INIT_ANSWERS" >/dev/null 2>&1; then
331
+ echo "x --answers: $INIT_ANSWERS is not a JSON object of {\"question\": \"answer\"}" >&2; exit 2
332
+ fi
333
+ init_guide_resolve
334
+ fi
335
+
276
336
  # Installed plugin version -> recorded into kit.config as kitVersion (drives /kit-update checks).
277
337
  PLUGIN_VERSION="$(jq -r '.version // "0.0.0"' "$KIT_ROOT/.claude-plugin/plugin.json" 2>/dev/null || echo "0.0.0")"
278
338
 
279
339
  # ---- upgrade mode: backfill inputs from the project's existing config ----
280
340
  if [[ $UPGRADE -eq 1 ]]; then
281
341
  UP_TARGET="$(cd "${TARGET:-$PWD}" && pwd)"
282
- UP_CFG="$UP_TARGET/.claude/kit.config.json"
283
- [[ -f "$UP_CFG" ]] || { echo "x --upgrade needs $UP_CFG (run /kit-init first)."; exit 1; }
342
+ UP_CFG="$(adapter_config_existing "$UP_TARGET" || true)"
343
+ [[ -n "$UP_CFG" && -f "$UP_CFG" ]] || { echo "x --upgrade needs $UP_TARGET/.claude/kit.config.json (run /kit-init first)."; exit 1; }
344
+ # The stored selection is the truth on upgrade. --adapter only ever ADDS to it: dropping an
345
+ # adapter is an uninstall of its files, which is `cckit remove`'s job, not an upgrade side effect.
346
+ ADAPTERS_HAVE="$(adapter_list_from_config "$UP_CFG")" || { echo "x $UP_CFG has an invalid 'adapters' value (expected claude and/or codex)." >&2; exit 1; }
347
+ ADAPTERS="$(adapter_union "$ADAPTERS_HAVE" "$ADAPTERS_NEW")"
348
+ [[ "$ADAPTERS" != "$ADAPTERS_HAVE" ]] && ADAPTER_ADDED=1
284
349
 
285
350
  # ---- guard: never apply the kit over its OWN home, or downgrade ----------
286
351
  # The kit is DEVELOPED in-tree in its home repo (packages/claude-kit-plugin/). Running
@@ -295,7 +360,16 @@ if [[ $UPGRADE -eq 1 ]]; then
295
360
  # confusing re-scan + any stray re-add). A genuinely-behind consumer (kitVersion < plugin)
296
361
  # still upgrades normally.
297
362
  _have_kv="$(jq -r '.kitVersion // "0.0.0"' "$UP_CFG" 2>/dev/null || echo 0.0.0)"
298
- if [[ "$_have_kv" == "$PLUGIN_VERSION" ]]; then
363
+ # ...unless this run enables a second adapter: that is new work at the same version. So is a
364
+ # Codex project whose hooks are not registered (a hooks.json that was unparseable at init, or a
365
+ # project scaffolded before E257.5): `cckit doctor` sends the user here to repair exactly that.
366
+ _cx_unregistered=0
367
+ if adapter_has "$ADAPTERS" codex; then
368
+ # shellcheck source=/dev/null
369
+ . "$KIT_ROOT/scripts/lib/codex-hooks.sh"
370
+ codex_hooks_registered "$UP_TARGET/.codex/hooks.json" guard-base-branch-commit.sh || _cx_unregistered=1
371
+ fi
372
+ if [[ "$_have_kv" == "$PLUGIN_VERSION" && $ADAPTER_ADDED -eq 0 && $_cx_unregistered -eq 0 ]]; then
299
373
  echo "x already at $PLUGIN_VERSION -- nothing to upgrade. (To pull a newer release, refresh the plugin cache: claude plugin update.)"
300
374
  exit 0
301
375
  fi
@@ -308,6 +382,11 @@ if [[ $UPGRADE -eq 1 ]]; then
308
382
  [[ -z "$MEMORY" ]] && MEMORY="$(jq -r 'if .memory.enabled then "on" else "off" end' "$UP_CFG")"
309
383
  [[ -z "$SPECKIT" ]] && SPECKIT="$(jq -r 'if (.specKit.enabled // false) then "on" else "off" end' "$UP_CFG")"
310
384
  [[ -z "$LOCAL_LAYER" ]] && LOCAL_LAYER="$(jq -r 'if (.local.enabled // false) then "on" else "off" end' "$UP_CFG")"
385
+ # The stored switch is the truth on upgrade: a project that turned plain language off keeps it
386
+ # off whatever its profile defaults to.
387
+ [[ -z "$PLAIN_LANGUAGE" ]] && PLAIN_LANGUAGE="$(jq -r 'if (.plainLanguage.enabled // false) then "on" else "off" end' "$UP_CFG")"
388
+ # Same for the default task list: the project's tasks.default, never the profile default.
389
+ TASKS_DEFAULT="$(jq -r '.tasks.default // "issues"' "$UP_CFG")"
311
390
  # A config with NO plans key at all deliberately runs without plan files — upgrade must not
312
391
  # resurrect the profile default (and with it the plans rule + config block) (#149).
313
392
  [[ -z "$PLANS_FORMAT" ]] && PLANS_FORMAT="$(jq -r 'if has("plans") then (.plans.format // "") else "none" end' "$UP_CFG")"
@@ -344,13 +423,16 @@ if [[ $UPGRADE -eq 1 ]]; then
344
423
  fi
345
424
  fi
346
425
 
347
- [[ -z "$PROFILE" ]] && { echo "x --profile is required (software|content|research|minimal)"; exit 1; }
426
+ # The profile names come from profiles/*.json, so a profile added there is offered here.
427
+ _PROFILE_NAMES="$(for _pf in "$KIT_ROOT"/profiles/*.json; do [[ -f "$_pf" ]] && basename "$_pf" .json; done | paste -sd '|' -)"
428
+ [[ -z "$PROFILE" ]] && { echo "x --profile is required ($_PROFILE_NAMES)"; exit 1; }
348
429
  PROFILE_FILE="$KIT_ROOT/profiles/$PROFILE.json"
349
- [[ -f "$PROFILE_FILE" ]] || { echo "x no such profile: $PROFILE ($PROFILE_FILE)"; exit 1; }
430
+ [[ -f "$PROFILE_FILE" ]] || { echo "x no such profile: $PROFILE — one of: $_PROFILE_NAMES"; exit 1; }
350
431
 
351
432
  # ---- resolve target + defaults ------------------------------------------
352
- mkdir -p "$TARGET"
353
- TARGET="$(cd "$TARGET" && pwd)"
433
+ # A folder that is not there yet is created when the first file is written, not here: a dry run
434
+ # and a declined confirmation leave nothing behind (#456).
435
+ if [[ -d "$TARGET" ]]; then TARGET="$(cd "$TARGET" && pwd)"; else TARGET="$(init_abs_path "$TARGET")"; fi
354
436
  BASENAME="$(basename "$TARGET")"
355
437
  # Prefer the ACTUAL repo name from the git remote — the local directory is often cloned/renamed to a
356
438
  # different name — and only fall back to the directory basename (#73).
@@ -358,6 +440,8 @@ BASENAME="$(basename "$TARGET")"
358
440
  . "$KIT_ROOT/scripts/lib/git-remote.sh"
359
441
  # shellcheck source=/dev/null
360
442
  . "$KIT_ROOT/scripts/lib/hook-refresh.sh" # hook_refresh_state — refresh unmodified hooks (#370)
443
+ # shellcheck source=/dev/null
444
+ . "$KIT_ROOT/scripts/lib/upgrade-report.sh" # measured change list + minimal JSON writes (#448)
361
445
  NAME_SRC="$(git_remote_repo_name "$TARGET" 2>/dev/null || true)"; NAME_SRC="${NAME_SRC:-$BASENAME}"
362
446
  [[ -z "$NAME" ]] && NAME="$NAME_SRC"
363
447
  [[ -z "$SLUG" ]] && SLUG="$(echo "$NAME_SRC" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9' '-' | sed -E 's/^-|-$//g')"
@@ -365,6 +449,9 @@ if [[ -z "$GH_OWNER" ]]; then GH_OWNER="$(gh api user --jq .login 2>/dev/null ||
365
449
  [[ -z "$OWNER_NAME" ]] && OWNER_NAME="${GH_OWNER:-owner}"
366
450
  # Prefer the project's ACTUAL GitHub remote over an <owner>/<dir-basename> guess — the local
367
451
  # directory name often differs from the repo name (would target a non-existent repo otherwise).
452
+ if [[ -z "$REPO" && $INIT_ALREADY -eq 1 ]]; then
453
+ REPO="$(jq -r '.github.repo // empty' "$(adapter_config_existing "$TARGET")" 2>/dev/null || true)"
454
+ fi
368
455
  [[ -z "$REPO" ]] && REPO="$(cd "$TARGET" 2>/dev/null && gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || true)"
369
456
  [[ -z "$REPO" && -n "$GH_OWNER" ]] && REPO="$GH_OWNER/$SLUG"
370
457
  [[ -z "$REPO" ]] && REPO="$SLUG"
@@ -394,13 +481,49 @@ if [[ -z "$BASE_BRANCH" ]]; then
394
481
  fi
395
482
  fi
396
483
  [[ -z "$BASE_BRANCH" ]] && BASE_BRANCH="$(cd "$TARGET" 2>/dev/null && gh repo view --json defaultBranchRef -q .defaultBranchRef.name 2>/dev/null || true)"
397
- [[ -z "$BASE_BRANCH" ]] && BASE_BRANCH="main"
484
+ # The git + GitHub setup (#456) runs when it is wanted AND confirmed: --yes, or a terminal to ask
485
+ # on. A dry run plans as if it were confirmed. A project with no `origin` remote that the setup is
486
+ # about to give a repository integrates on `develop` (main stays the release branch).
487
+ SETUP_WANTED=0; SETUP_BASE_CHOSEN=0
488
+ if [[ $UPGRADE -eq 0 && $NO_GITHUB -eq 0 ]] && { [[ $ASSUME_YES -eq 1 || $DRY_RUN -eq 1 ]] || _ig_tty; }; then
489
+ SETUP_WANTED=1
490
+ fi
491
+ if [[ -z "$BASE_BRANCH" && $SETUP_WANTED -eq 1 ]] && [[ -z "$(git -C "$TARGET" remote get-url origin 2>/dev/null || true)" ]]; then
492
+ BASE_BRANCH="develop"; SETUP_BASE_CHOSEN=1
493
+ fi
494
+ # No setup, no remote default, no config: `main` when the repository has it (or has no commit yet),
495
+ # else the branch that is checked out — a base branch the repository does not have stops the first
496
+ # `cckit start` / `cckit task start` (#487).
497
+ _init_fallback_base() {
498
+ local cur
499
+ if git -C "$TARGET" rev-parse --verify -q HEAD >/dev/null 2>&1 \
500
+ && ! git -C "$TARGET" show-ref --verify -q refs/heads/main \
501
+ && ! git -C "$TARGET" show-ref --verify -q refs/remotes/origin/main; then
502
+ cur="$(git -C "$TARGET" symbolic-ref --short -q HEAD 2>/dev/null || true)"
503
+ if [[ -n "$cur" ]]; then printf '%s' "$cur"; return 0; fi
504
+ fi
505
+ printf 'main'
506
+ }
507
+ [[ -z "$BASE_BRANCH" ]] && BASE_BRANCH="$(_init_fallback_base)"
398
508
 
399
509
  # profile defaults
400
510
  [[ -z "$PLANS_FORMAT" ]] && PLANS_FORMAT="$(jq -r '.defaults.plans_format' "$PROFILE_FILE")"
401
511
  [[ -z "$MEMORY" ]] && MEMORY="$(jq -r '.defaults.memory' "$PROFILE_FILE")"
402
512
  [[ -z "$SPECKIT" ]] && SPECKIT="$(jq -r '.defaults.speckit // "off"' "$PROFILE_FILE")"
403
513
  [[ -z "$LOCAL_LAYER" ]] && LOCAL_LAYER="$(jq -r '.defaults.local // "off"' "$PROFILE_FILE")"
514
+ # Content work (E415). Profile defaults only — no flag: a project changes them in its config.
515
+ # content_kinds on -> kinds.content: true (setup-labels.sh provisions the content kind labels)
516
+ CONTENT_KINDS="$(jq -r '.defaults.content_kinds // "off"' "$PROFILE_FILE")"
517
+ # pr_body content -> pr.bodyStyle: "content" (draft-and-review wording in generated PR bodies)
518
+ case "$CONTENT_KINDS" in on|true|yes) CONTENT_KINDS_ON="true";; *) CONTENT_KINDS_ON="false";; esac
519
+ # plain_language on -> plainLanguage.enabled: true + the plain-language rule (--plain-language wins)
520
+ PR_BODY_STYLE="$(jq -r '.defaults.pr_body // "code"' "$PROFILE_FILE")"
521
+ [[ -z "$PLAIN_LANGUAGE" ]] && PLAIN_LANGUAGE="$(jq -r '.defaults.plain_language // "off"' "$PROFILE_FILE")"
522
+ case "$PLAIN_LANGUAGE" in on|true|yes) PLAIN_ON="true";; *) PLAIN_ON="false";; esac
523
+ # tasks light -> tasks.default: "light" (a bare `cckit next` answers from `cckit task`)
524
+ [[ -z "$TASKS_DEFAULT" ]] && TASKS_DEFAULT="$(jq -r '.defaults.tasks // "issues"' "$PROFILE_FILE")"
525
+ [[ "$TASKS_DEFAULT" == "light" ]] || TASKS_DEFAULT="issues"
526
+ [[ "$PR_BODY_STYLE" == "content" ]] || PR_BODY_STYLE="code"
404
527
  if [[ -z "$PLANS_DIR" ]]; then
405
528
  case "$PLANS_FORMAT" in
406
529
  mdx) PLANS_DIR="apps/plans/src/briefs" ;;
@@ -413,6 +536,17 @@ ROLES_NL="$(jq -r '.roles[]' "$PROFILE_FILE")"
413
536
  MS_NL="$(jq -r '.milestones[]' "$PROFILE_FILE")"
414
537
  AGENTS="$(jq -r '.agents[]' "$PROFILE_FILE")"
415
538
  SKILLS="$(jq -r '.skills[]' "$PROFILE_FILE")"
539
+ # page-design (#504) is installed wherever pages are designed: a profile that lists it (marketing),
540
+ # a recipe whose config sets `tasks.design: true` (nextjs-shadcn), or, on --upgrade, a project
541
+ # config that holds that key. One switch, so the skill and the page-task rule of `cckit task run`
542
+ # cannot disagree.
543
+ DESIGN_SKILL_ON=""
544
+ if [[ -n "$RECIPE_FILE" ]]; then DESIGN_SKILL_ON="$(jq -r '.config.tasks.design // empty' "$RECIPE_FILE" 2>/dev/null || true)"; fi
545
+ if [[ $UPGRADE -eq 1 && -n "${UP_CFG:-}" && -f "${UP_CFG:-}" ]]; then DESIGN_SKILL_ON="$(jq -r '.tasks.design // empty' "$UP_CFG" 2>/dev/null || true)"; fi
546
+ if [[ "$DESIGN_SKILL_ON" == "true" ]] && ! grep -qx "page-design" <<<"$SKILLS"; then
547
+ SKILLS="$SKILLS
548
+ page-design"
549
+ fi
416
550
  RULES="$(jq -r '.rules[]' "$PROFILE_FILE")"
417
551
 
418
552
  # Kit-namespaced skill set: templates whose names take $SKILL_PREFIX (the workflow skills:
@@ -420,7 +554,7 @@ RULES="$(jq -r '.rules[]' "$PROFILE_FILE")"
420
554
  # Listed in templates/skills/NAMESPACED (one name per line) so the marker lives outside the artifact.
421
555
  NAMESPACED_SKILLS="$(grep -vE '^\s*(#|$)' "$KIT_ROOT/templates/skills/NAMESPACED" 2>/dev/null || true)"
422
556
  _is_namespaced() { # <skill-name> -> 0 if it takes the prefix
423
- printf '%s\n' "$NAMESPACED_SKILLS" | grep -qxF "$1"
557
+ grep -qxF "$1" <<<"$NAMESPACED_SKILLS"
424
558
  }
425
559
  # Rewrite a freshly-scaffolded namespaced skill so its own name: + sibling /command refs + sigil
426
560
  # label carry $SKILL_PREFIX (template ships bare; the project namespaces). The (?![\w-]) guard stops
@@ -447,7 +581,7 @@ MILESTONES_HUMAN="$(printf '%s' "$MS_NL" | paste -sd '·' - | sed 's/·/ · /g')
447
581
  if [[ -n "$PROJECT_NUMBER" ]]; then PROJECTS_V2="true"; PNUM_JSON="$PROJECT_NUMBER"; else PROJECTS_V2="false"; PNUM_JSON="null"; PROJECT_NUMBER="null"; fi
448
582
  case "$MEMORY" in on|true|yes) MEMORY_BOOL="true";; *) MEMORY_BOOL="false";; esac
449
583
  if [[ "$PLANS_FORMAT" == "none" ]]; then PLANS_ON="false"; else PLANS_ON="true"; fi
450
- if echo "$ROLES_NL" | grep -qx "Designer"; then DESIGN_ON="true"; else DESIGN_ON="false"; fi
584
+ if grep -qx "Designer" <<<"$ROLES_NL"; then DESIGN_ON="true"; else DESIGN_ON="false"; fi
451
585
  CLAUDE_PROJECT_SLUG="$(echo "$TARGET" | sed 's#/#-#g')"
452
586
 
453
587
  # spec kit
@@ -461,7 +595,15 @@ if [[ -n "$PREPUSH_CMD" ]]; then PREPUSH_ENABLED="true"; else PREPUSH_ENABLED="f
461
595
  case "$LOCAL_LAYER" in on|true|yes) LOCAL_ON="true";; *) LOCAL_ON="false";; esac
462
596
 
463
597
  # stack-gated build skills present in this profile?
464
- if echo "$SKILLS" | grep -qE '^(feature-build-refine|supabase-patterns)$'; then STACK_SKILLS_ON="true"; else STACK_SKILLS_ON="false"; fi
598
+ if grep -qE '^(feature-build-refine|supabase-patterns)$' <<<"$SKILLS"; then STACK_SKILLS_ON="true"; else STACK_SKILLS_ON="false"; fi
599
+
600
+ # code graph (an integration, switched on by `cckit add <id>` — never by an init flag). A fresh
601
+ # scaffold therefore has it off; only --upgrade can find it on, in the project's existing config.
602
+ CODEGRAPH_ON="false"
603
+ if [[ $UPGRADE -eq 1 ]]; then
604
+ _cg="$(jq -r '.codeGraph.provider // ""' "$UP_CFG" 2>/dev/null || true)"
605
+ [[ -n "$_cg" && "$_cg" != "none" ]] && CODEGRAPH_ON="true"
606
+ fi
465
607
 
466
608
  # FLAGS_ON drives <!-- IF:X --> resolution
467
609
  FLAGS_ON=""
@@ -471,9 +613,31 @@ FLAGS_ON=""
471
613
  [[ "$DESIGN_ON" == "true" ]] && FLAGS_ON="${FLAGS_ON}DESIGN,"
472
614
  [[ "$SPECKIT_ON" == "true" ]] && FLAGS_ON="${FLAGS_ON}SPECKIT,"
473
615
  [[ "$STACK_SKILLS_ON" == "true" ]] && FLAGS_ON="${FLAGS_ON}STACK_SKILLS,"
616
+ [[ "$CODEGRAPH_ON" == "true" ]] && FLAGS_ON="${FLAGS_ON}CODEGRAPH,"
617
+ [[ "$TASKS_DEFAULT" == "light" ]] && FLAGS_ON="${FLAGS_ON}LIGHT_TASKS,"
618
+ # The counterpart, so the instruction file can say "GitHub issues are the task list" only where
619
+ # that is true (#487).
620
+ [[ "$TASKS_DEFAULT" == "light" ]] || FLAGS_ON="${FLAGS_ON}ISSUE_TASKS,"
474
621
 
475
622
  # ---- build agent/skill tables -------------------------------------------
476
- short_desc() { sed -n 's/^description: //p' "$1" | head -1 | cut -c1-92; }
623
+ # short_desc <file> -> the frontmatter description, at most 92 characters. A folded or literal
624
+ # block (`description: >` with the text on the indented lines below it) is joined into one line;
625
+ # the old one-line read printed the `>` itself in the skills table (#487).
626
+ short_desc() {
627
+ awk '
628
+ /^---[[:space:]]*$/ { fm++; if (fm == 2) exit; next }
629
+ fm != 1 { next }
630
+ inblock {
631
+ if ($0 ~ /^[[:space:]]+[^[:space:]]/) { t = $0; sub(/^[[:space:]]+/, "", t); sub(/[[:space:]]+$/, "", t); out = out (out == "" ? "" : " ") t; next }
632
+ if ($0 ~ /^[[:space:]]*$/) next
633
+ inblock = 0
634
+ }
635
+ /^description:/ && !seen {
636
+ seen = 1; v = $0; sub(/^description:[[:space:]]*/, "", v); sub(/[[:space:]]+$/, "", v)
637
+ if (v == "" || v ~ /^[>|][+-]?$/) { inblock = 1 } else { out = v }
638
+ }
639
+ END { print out }' "$1" | cut -c1-92
640
+ }
477
641
  AGENT_TABLE="| Agent | Role |
478
642
  | ----- | ---- |"
479
643
  for a in $AGENTS; do
@@ -499,15 +663,59 @@ export PLANS_DIR PLANS_FORMAT KNOWLEDGE_DIR="knowledge" WING="$SLUG" CLAUDE_PROJ
499
663
  export MILESTONES_HUMAN ROLES_HUMAN AGENT_TABLE SKILL_TABLE
500
664
  export KIT_FLAGS_ON="$FLAGS_ON"
501
665
 
666
+ # ---- per-adapter layout --------------------------------------------------
667
+ # One template set renders for both adapters. What differs is where the files land ({{ADAPTER_DIR}}),
668
+ # which IF:ADAPTER_* blocks survive, and the instruction file name — nothing else.
669
+ KITCFG="$(adapter_config_existing "$TARGET" || true)"
670
+ [[ -n "$KITCFG" ]] || KITCFG="$(adapter_config_default "$TARGET" "$ADAPTERS")"
671
+ CONFIG_REL="${KITCFG#"$TARGET"/}"
672
+ MANIFEST_REL="$(adapter_manifest_rel "$TARGET" "$ADAPTERS")"
673
+ export CONFIG_REL
674
+ _rule_enabled() { # <rule> -> 0 unless its feature is off for this project
675
+ case "$1" in
676
+ mempalace) [[ "$MEMORY_BOOL" == "true" ]] || return 1 ;;
677
+ design-routing) [[ "$DESIGN_ON" == "true" ]] || return 1 ;;
678
+ plan-output-format) [[ "$PLANS_ON" == "true" ]] || return 1 ;;
679
+ plain-language) [[ "$PLAIN_ON" == "true" ]] || return 1 ;;
680
+ esac
681
+ return 0
682
+ }
683
+ # The plain-language rule follows its switch, not the profile list: a profile that lists it gets it
684
+ # only while the switch is on, and `--plain-language on` adds it to a profile that does not list it.
685
+ if [[ "$PLAIN_ON" == "true" ]] && ! grep -qx 'plain-language' <<<"$RULES"; then
686
+ RULES="$RULES
687
+ plain-language"
688
+ fi
689
+ RULE_LIST=""
690
+ for r in $RULES; do
691
+ _rule_enabled "$r" && [[ -f "$KIT_ROOT/templates/rules/$r.md" ]] || continue
692
+ RULE_LIST="${RULE_LIST:+$RULE_LIST
693
+ }- \`.agents/rules/$r.md\`"
694
+ done
695
+ export RULE_LIST
696
+ use_adapter() { # <claude|codex> — point emit at that adapter's dir + IF blocks
697
+ ADAPTER_DIR="$(adapter_dir "$1")"
698
+ KIT_FLAGS_ON="${FLAGS_ON}ADAPTER_$(printf '%s' "$1" | tr '[:lower:]' '[:upper:]'),"
699
+ ADAPTER_INSTRUCTIONS="$(adapter_instructions "$1")"
700
+ export ADAPTER_DIR KIT_FLAGS_ON ADAPTER_INSTRUCTIONS
701
+ }
702
+ # Shared (adapter-neutral) files that name a rules path point at the first selected adapter's copy.
703
+ use_adapter "${ADAPTERS%% *}"
704
+
502
705
  # emit: resolve IF blocks, then substitute {{VARS}}
503
- emit() { # <src> <dest>
504
- mkdir -p "$(dirname "$2")"
706
+ render_tpl() { # <src> -> stdout
505
707
  perl -0777 -pe '
506
708
  my %on = map { $_=>1 } grep { length } split /,/, ($ENV{KIT_FLAGS_ON}//"");
507
709
  1 while s{<!-- IF:(\w+) -->(.*?)<!-- /IF:\1 -->}{ $on{$1} ? $2 : "" }gse;
508
710
  s/\{\{(\w+)\}\}/ exists $ENV{$1} ? $ENV{$1} : "{{$1}}" /ge;
509
- ' "$1" > "$2"
711
+ ' "$1"
712
+ }
713
+ emit() { # <src> <dest>
714
+ mkdir -p "$(dirname "$2")"
715
+ render_tpl "$1" > "$2"
716
+ WRITTEN+=("${2#"$TARGET"/}")
510
717
  }
718
+ WRITTEN=() # every path this run wrote (not preserved) — the adapter-managed ones go in the manifest
511
719
 
512
720
  # _upgrade_excluded: true when <rel> was removed/renamed by the project on purpose
513
721
  # (registered in kit.config.json `upgrade.removed[]` / `upgrade.renamed{}`). Matches an
@@ -554,6 +762,7 @@ safe_copy() { # <src> <dest> [exec]
554
762
  fi
555
763
  mkdir -p "$(dirname "$2")"
556
764
  cp "$1" "$2"
765
+ WRITTEN+=("$rel")
557
766
  [[ "${3:-}" == "exec" ]] && chmod +x "$2" 2>/dev/null
558
767
  [[ $UPGRADE -eq 1 ]] && UPGRADE_ADDED+=("$rel")
559
768
  return 0
@@ -566,7 +775,7 @@ safe_copy() { # <src> <dest> [exec]
566
775
  hook_write() { # <src> <dest>
567
776
  local rel="${2#"$TARGET"/}" state
568
777
  if [[ $UPGRADE -ne 1 || ! -e "$2" ]] || _upgrade_excluded "$rel"; then safe_write "$1" "$2"; return 0; fi
569
- state="$(hook_refresh_state "$2" "$1" "$KIT_ROOT" "$TARGET/.claude/kit.manifest.json" "$rel")"
778
+ state="$(hook_refresh_state "$2" "$1" "$KIT_ROOT" "$TARGET/$MANIFEST_REL" "$rel")"
570
779
  case "$state" in
571
780
  refresh) emit "$1" "$2"; UPGRADE_REFRESHED+=("$rel") ;;
572
781
  drifted) UPGRADE_DRIFTED+=("$rel") ;;
@@ -575,6 +784,90 @@ hook_write() { # <src> <dest>
575
784
  return 0
576
785
  }
577
786
 
787
+ # ---- git + GitHub setup: the whole plan first, then ONE confirmation (#456) ----
788
+ # Nothing has been written yet. --yes confirms; a terminal is asked once; with neither, the setup
789
+ # does not run and the run says so at the end (re-run with --yes). A dry run only prints the plan.
790
+ IG_TARGET="$TARGET"; IG_REPO="$REPO"; IG_BASE="$BASE_BRANCH"; IG_VISIBILITY="$REPO_VISIBILITY"
791
+ IG_PROJECTS_V2="$PROJECTS_V2"; IG_KIT_ROOT="$KIT_ROOT"; IG_DOCTOR=1; IG_CONFIG_REL="$CONFIG_REL"
792
+ [[ "${KIT_INIT_PREFLIGHT:-1}" == "0" ]] && IG_DOCTOR=0 # the fixture tests' switch: no doctor, no network
793
+ SETUP_DECLINED=0
794
+ if [[ $SETUP_WANTED -eq 1 && $DRY_RUN -eq 0 ]]; then
795
+ echo ""
796
+ echo "cckit init is about to set up \"$NAME\" in $TARGET"
797
+ [[ -n "$RECIPE_FILE" ]] && echo " Starting point: $(jq -r .label "$RECIPE_FILE")"
798
+ [[ -n "$DB_FILE" ]] && echo " Database: $(jq -r .label "$DB_FILE")"
799
+ echo " Git and GitHub setup:"
800
+ init_setup_plan | sed 's/^/ /'
801
+ if [[ $ASSUME_YES -eq 1 ]]; then
802
+ SETUP_RUN=1
803
+ else
804
+ printf '\nGo ahead? [Y/n] (n = only the files in the folder; nothing is created on GitHub) '
805
+ IFS= read -r _setup_ok || _setup_ok="n"
806
+ case "$_setup_ok" in ""|y|Y|yes|Yes|YES) SETUP_RUN=1 ;; *) SETUP_DECLINED=1 ;; esac
807
+ fi
808
+ # Declined: the project keeps the base branch it would have had without the setup.
809
+ if [[ $SETUP_RUN -eq 0 && $SETUP_BASE_CHOSEN -eq 1 ]]; then BASE_BRANCH="$(_init_fallback_base)"; IG_BASE="$BASE_BRANCH"; fi
810
+ fi
811
+
812
+ # _init_finish — the closing lines of a guided run: the database guide, why the setup did not run
813
+ # (when it did not), the step totals. Exits 1 when a step failed, 0 otherwise.
814
+ _init_finish() {
815
+ local _d _s _f
816
+ if [[ -n "$DB_FILE" ]]; then database_guide "$DB_FILE" "$TARGET"; fi
817
+ if [[ $UPGRADE -eq 0 && $NO_GITHUB -eq 0 && $SETUP_RUN -eq 0 ]]; then
818
+ echo ""
819
+ if [[ $SETUP_DECLINED -eq 1 ]]; then
820
+ echo "Git and GitHub setup: not run (you answered no). To run it later: cckit init --yes (inside $TARGET)"
821
+ else
822
+ echo "Git and GitHub setup: not run — there is no terminal to confirm on."
823
+ echo " To run it: cckit init --yes (inside $TARGET). To leave it out on purpose: --no-github."
824
+ fi
825
+ fi
826
+ # A run without the setup says what it left undone, with the command that does it (#487).
827
+ if [[ $UPGRADE -eq 0 && $SETUP_RUN -eq 0 ]]; then
828
+ if ! git -C "$TARGET" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
829
+ if [[ $NO_GITHUB -eq 0 ]]; then
830
+ echo " Not done: $TARGET is not a git repository yet, so no task can be started in it."
831
+ echo " cckit init --yes starts version control, saves the cckit files and creates the branch '$BASE_BRANCH'."
832
+ fi
833
+ else
834
+ if init_base_missing; then
835
+ echo ""
836
+ echo "Not done: the branch '$BASE_BRANCH' (github.baseBranch in $CONFIG_REL) does not exist in this repository."
837
+ echo " cckit start and cckit task start cut their work from it and stop until it exists."
838
+ echo " To create it and push it: cckit init --yes (inside $TARGET)"
839
+ fi
840
+ if init_scaffold_pending; then
841
+ echo ""
842
+ echo "Not done: the cckit files are not committed. A task started now gets a folder without them,"
843
+ echo " and a teammate who clones the project gets no setup."
844
+ if [[ $NO_GITHUB -eq 1 ]]; then
845
+ echo " To commit them, on the branch '$BASE_BRANCH': $(init_scaffold_command)"
846
+ else
847
+ echo " To commit them on '$BASE_BRANCH' and push: cckit init --yes (inside $TARGET)"
848
+ fi
849
+ fi
850
+ fi
851
+ fi
852
+ if [[ -n "$INIT_STEP_LOG" ]]; then
853
+ _d="$(printf '%s' "$INIT_STEP_LOG" | grep -c '^ \[done' || true)"
854
+ _s="$(printf '%s' "$INIT_STEP_LOG" | grep -c '^ \[skipped' || true)"
855
+ _f="$(printf '%s' "$INIT_STEP_LOG" | grep -c '^ \[failed' || true)"
856
+ echo ""
857
+ echo "Result: $_d done · $_s skipped (already there, or not available) · $_f failed"
858
+ if [[ "$_f" -gt 0 ]]; then
859
+ printf '%s' "$INIT_STEP_LOG" | grep '^ \[failed'
860
+ echo "Fix what failed and run cckit init again: finished steps are skipped."
861
+ fi
862
+ fi
863
+ if [[ -n "$RECIPE_FILE" && $INIT_FAILED -eq 0 ]]; then
864
+ _s="$(jq -r '.start // empty' "$RECIPE_FILE")"
865
+ [[ -n "$_s" ]] && echo "To see the project running: cd $TARGET && $_s"
866
+ fi
867
+ [[ $INIT_FAILED -gt 0 ]] && exit 1
868
+ exit 0
869
+ }
870
+
578
871
  # ---- dry run: print the plan and exit, writing nothing -------------------
579
872
  if [[ $DRY_RUN -eq 1 ]]; then
580
873
  echo "-> DRY RUN — nothing will be written. Plan for $TARGET:"
@@ -585,54 +878,147 @@ if [[ $DRY_RUN -eq 1 ]]; then
585
878
  echo " Project : $NAME ($SLUG)"
586
879
  echo " Repo : $REPO"
587
880
  echo " Base : $BASE_BRANCH (rules that name the integration branch render this)"
881
+ echo " Adapters: $ADAPTERS$([[ $ADAPTER_ADDED -eq 1 ]] && echo " (adding to stored: $ADAPTERS_HAVE)")"
588
882
  echo " Board : $([[ "$PROJECTS_V2" == "true" ]] && echo "Projects v2 #$PROJECT_NUMBER" || echo "off (gh issues only)")"
589
883
  echo " Memory : $MEMORY_BOOL Plans: $PLANS_FORMAT Lang: $LANG_PREF"
590
884
  echo " Spec Kit: $SPECKIT_ON Pre-push gate: $PREPUSH_ENABLED Local model: $LOCAL_ON kitVersion: $PLUGIN_VERSION"
885
+ [[ "$CONTENT_KINDS_ON" == "true" ]] && echo " Content : kind labels post · campaign · brand · research"
886
+ [[ "$PR_BODY_STYLE" == "content" ]] && echo " PR text : content (draft and review wording)"
887
+ [[ "$PLAIN_ON" == "true" ]] && echo " Wording : plain language (draft, review, approve)"
888
+ [[ "$TASKS_DEFAULT" == "light" ]] && echo " Tasks : light tasks are the default list (cckit task; no GitHub issue per task)"
591
889
  echo ""
890
+ if [[ $UPGRADE -eq 1 ]]; then
891
+ # An upgrade's dry run is the upgrade itself, run on a temporary copy of the kit-managed paths
892
+ # and measured (#448) — not the list below, which names everything a FRESH init can write.
893
+ upgrade_dry_run "$TARGET" "$KIT_ROOT/scripts/init.sh" "${_INIT_ARGS[@]}" || exit $?
894
+ echo ""
895
+ echo " A = added · M = modified. Measured by running the upgrade on a temporary copy; $TARGET was not written."
896
+ echo "Re-run without --dry-run to apply."
897
+ exit 0
898
+ fi
899
+ # A project that already has the kit files (#456): a real run leaves them alone, so the plan is
900
+ # the database option and the setup steps, not the file list.
901
+ if [[ $INIT_ALREADY -eq 1 && ( $SETUP_WANTED -eq 1 || -n "$DB_FILE" ) ]]; then
902
+ echo " cckit files: already there ($CONFIG_REL) — a run leaves them as they are (--upgrade merges in new kit features)."
903
+ echo ""
904
+ if [[ -n "$DB_FILE" ]]; then
905
+ echo " Database option $(jq -r .id "$DB_FILE") would add what is missing of:"
906
+ database_plan "$DB_FILE" "$DB_STACK"
907
+ echo ""
908
+ fi
909
+ if [[ $SETUP_WANTED -eq 1 ]]; then
910
+ echo " Git and GitHub setup would run these steps (nothing is written to GitHub by a dry run):"
911
+ init_setup_plan | sed 's/^/ /'
912
+ echo ""
913
+ fi
914
+ echo "Re-run without --dry-run to apply."
915
+ exit 0
916
+ fi
592
917
  echo " Would write:"
593
- echo " CLAUDE.md"
594
- echo " .claude/kit.config.json"
918
+ echo " $CONFIG_REL"
919
+ echo " $MANIFEST_REL (ownership manifest, gitignored)"
920
+ if adapter_has "$ADAPTERS" claude; then
595
921
  echo " .claude/settings.local.json"
596
922
  echo " .claude/hooks/repo-hygiene.sh (SessionStart: read-only repo-hygiene report)"
597
923
  echo " .claude/hooks/guard-base-branch-commit.sh (PreToolUse Bash: block commits to base branch)"
598
924
  echo " .claude/hooks/guard-raw-git-ops.sh (PreToolUse Bash, tracked settings.json: raw gh/git -> cckit verb)"
599
925
  echo " .claude/hooks/kit_version_check.sh (SessionStart: update check)"
600
- for r in $RULES; do
601
- case "$r" in
602
- mempalace) [[ "$MEMORY_BOOL" == "true" ]] || continue ;;
603
- design-routing) [[ "$DESIGN_ON" == "true" ]] || continue ;;
604
- plan-output-format) [[ "$PLANS_ON" == "true" ]] || continue ;;
605
- esac
606
- [[ -f "$KIT_ROOT/templates/rules/$r.md" ]] && echo " .claude/rules/$r.md"
607
- done
926
+ echo " .claude/hooks/kit-mail-check.sh (session mail, tracked settings.json: PostToolUse / UserPromptSubmit / SessionStart / Stop)"
608
927
  for a in $AGENTS; do
609
928
  [[ -f "$KIT_ROOT/templates/agents/$a.md" ]] && echo " .claude/agents/$a/AGENT.md"
610
929
  done
611
- for s in $SKILLS; do
612
- _dn="$s"; { [[ -n "$SKILL_PREFIX" ]] && _is_namespaced "$s"; } && _dn="${SKILL_PREFIX}${s}"
613
- [[ -f "$KIT_ROOT/templates/skills/$s/SKILL.md" ]] && echo " .claude/skills/$_dn/SKILL.md"
614
- [[ -d "$KIT_ROOT/templates/skills/$s/references" ]] && echo " .claude/skills/$_dn/references/"
930
+ fi
931
+ for _ad in $ADAPTERS; do
932
+ _add="$(adapter_dir "$_ad")"
933
+ echo " $(adapter_instructions "$_ad")"
934
+ for r in $RULES; do
935
+ _rule_enabled "$r" || continue
936
+ [[ -f "$KIT_ROOT/templates/rules/$r.md" ]] && echo " $_add/rules/$r.md"
937
+ done
938
+ [[ "$CODEGRAPH_ON" == "true" ]] && echo " $_add/rules/code-retrieval.md (codeGraph.provider is set)"
939
+ for s in $SKILLS; do
940
+ _dn="$s"; { [[ -n "$SKILL_PREFIX" ]] && _is_namespaced "$s"; } && _dn="${SKILL_PREFIX}${s}"
941
+ [[ -f "$KIT_ROOT/templates/skills/$s/SKILL.md" ]] && echo " $_add/skills/$_dn/SKILL.md"
942
+ [[ -d "$KIT_ROOT/templates/skills/$s/references" ]] && echo " $_add/skills/$_dn/references/"
943
+ done
944
+ done
945
+ if adapter_has "$ADAPTERS" codex; then
946
+ echo " .codex/hooks/ (repo-hygiene.sh, kit_version_check.sh, kit-mail-check.sh, guard-base-branch-commit.sh, guard-raw-git-ops.sh$([[ "$PREPUSH_ENABLED" == "true" ]] && echo ", prepush_gate.sh")$([[ "$LOCAL_ON" == "true" ]] && echo ", kit-local-status.sh"))"
947
+ echo " .codex/hooks.json (merged: cckit's registrations are added, yours are kept; trust them in Codex with /hooks)"
948
+ for a in $AGENTS; do
949
+ [[ -f "$KIT_ROOT/templates/agents/$a.md" ]] && echo " .codex/agents/$a.toml"
615
950
  done
616
- echo " scripts/ (kit-config.sh, gh-project.sh, kit-version-check.sh, setup-labels.sh, setup-milestones.sh, capture-project-ids.sh, task-sync.sh, knowledge-lint.sh, review-lint.sh + review-rules.conf, skill-frontmatter-lint.sh)"
951
+ echo " (Codex adapter: no memory hooks — they read Claude Code transcripts)"
952
+ fi
953
+ echo " scripts/ (kit-config.sh, gh-project.sh, kit-version-check.sh, setup-labels.sh, setup-milestones.sh, capture-project-ids.sh, task-sync.sh, knowledge-lint.sh, review-lint.sh + review-rules.conf, skill-frontmatter-lint.sh, instruction-budget-lint.sh)"
617
954
  echo " knowledge/INDEX.md (knowledge-base manifest — rules/knowledge-base.md)"
955
+ if adapter_has "$ADAPTERS" claude; then
618
956
  echo " .claude/lib/kit-sigil.sh (claude-kit attribution sigil helper, sourced by task-* footers)"
619
957
  [[ "$MEMORY_BOOL" == "true" ]] && echo " .claude/hooks/mempal_session_start.sh + mempal_save.sh + mempal_precompact.sh + mempal_followup.sh (SessionStart / Stop / PreCompact / SessionEnd)"
620
958
  [[ "$MEMORY_BOOL" == "true" ]] && echo " .claude/mempal-identity.$SLUG.txt (per-wing wake-up header — edit the Stack line)"
621
959
  [[ "$PREPUSH_ENABLED" == "true" ]] && echo " .claude/hooks/prepush_gate.sh (PreToolUse Bash gate: $PREPUSH_CMD)"
622
960
  [[ "$LOCAL_ON" == "true" ]] && echo " .claude/hooks/kit-local-status.sh (SessionStart: announce local model layer when alive)"
961
+ fi
623
962
  echo ""
624
963
  echo " Onboarding would offer (opt-in): gh auth$([[ "$MEMORY_BOOL" == "true" ]] && echo " · MemPalace (mempalace-mcp)") · gws (if you use Google Workspace) · local model layer (--local on: NL chores at \$0 via mlx_lm.server)"
625
964
  echo ""
965
+ if [[ -n "$RECIPE_FILE" ]]; then
966
+ echo " Recipe $(jq -r .id "$RECIPE_FILE") would run, in $TARGET:"
967
+ recipe_plan "$RECIPE_FILE"
968
+ echo ""
969
+ fi
970
+ if [[ -n "$DB_FILE" ]]; then
971
+ echo " Database option $(jq -r .id "$DB_FILE") would add:"
972
+ database_plan "$DB_FILE" "$DB_STACK"
973
+ echo ""
974
+ fi
975
+ if [[ $SETUP_WANTED -eq 1 ]]; then
976
+ echo " Git and GitHub setup would run these steps (nothing is written to GitHub by a dry run):"
977
+ init_setup_plan | sed 's/^/ /'
978
+ echo ""
979
+ elif [[ $NO_GITHUB -eq 1 ]]; then
980
+ echo " Git and GitHub setup: off (--no-github)."
981
+ echo ""
982
+ fi
626
983
  echo "Re-run without --dry-run to write these files."
627
984
  exit 0
628
985
  fi
629
986
 
630
987
  # ---- guard ---------------------------------------------------------------
631
- if [[ -e "$TARGET/.claude/kit.config.json" && $FORCE -eq 0 && $UPGRADE -eq 0 ]]; then
632
- echo " $TARGET/.claude already initialized. Re-run with --upgrade to merge in new features (preserves your edits), or --force to overwrite generated files."
988
+ if [[ -e "$KITCFG" && $FORCE -eq 0 && $UPGRADE -eq 0 ]]; then
989
+ # A re-run of the guided setup on a project that already has the kit files (#456): the files are
990
+ # left as they are, and only the steps that are still missing run.
991
+ if [[ $SETUP_RUN -eq 1 || -n "$DB_FILE" ]]; then
992
+ echo ""
993
+ echo "-> $TARGET already has the cckit files ($CONFIG_REL)"
994
+ init_step skipped "cckit files" "already there (cckit init --upgrade merges in new kit features)"
995
+ if [[ -n "$DB_FILE" ]]; then database_apply "$DB_FILE" "$DB_STACK" "$TARGET"; fi
996
+ if [[ $SETUP_RUN -eq 1 ]]; then init_setup_run; fi
997
+ _init_finish
998
+ fi
999
+ echo " $TARGET already initialized ($CONFIG_REL). Re-run with --upgrade to merge in new features (preserves your edits), or --force to overwrite generated files."
633
1000
  exit 1
634
1001
  fi
635
1002
 
1003
+ # ---- recipe + database: the project itself, before the kit files (#456) ---
1004
+ # The recipe's generators want an empty folder, so they run first; the kit files land on top.
1005
+ if [[ -n "$RECIPE_FILE" ]]; then
1006
+ echo ""
1007
+ echo "-> Starting point: $(jq -r .label "$RECIPE_FILE") (this downloads packages and can take a few minutes)"
1008
+ if ! recipe_run "$RECIPE_FILE" "$TARGET"; then
1009
+ echo "" >&2
1010
+ echo "x The starting point could not be built, so nothing else was set up." >&2
1011
+ echo " Fix the problem shown above, delete the folder $TARGET, and run cckit init again." >&2
1012
+ exit 1
1013
+ fi
1014
+ fi
1015
+ if [[ -n "$DB_FILE" ]]; then
1016
+ echo ""
1017
+ echo "-> Database: $(jq -r .label "$DB_FILE")"
1018
+ mkdir -p "$TARGET"
1019
+ database_apply "$DB_FILE" "$DB_STACK" "$TARGET"
1020
+ fi
1021
+
636
1022
  # ---- init banner (fresh init only; not on --upgrade) ---------------------
637
1023
  # Beat 1: golden-angle plant animation (TTY + Unicode only, else skipped).
638
1024
  # Beat 2: V4 box-drawing CLAUDE KIT banner snap (always).
@@ -641,12 +1027,23 @@ if [[ $UPGRADE -eq 0 ]]; then
641
1027
  fi
642
1028
 
643
1029
  UPGRADE_ADDED=(); UPGRADE_PRESERVED=(); UPGRADE_SKIPPED=(); UPGRADE_REFRESHED=(); UPGRADE_DRIFTED=()
1030
+ # Checksums of the kit-managed paths before the first write: the summary prints what differs after
1031
+ # the last one, so a file a later step merges into is reported as modified, not as preserved (#448).
1032
+ _UP_SNAP=""
1033
+ if [[ $UPGRADE -eq 1 && -z "${KIT_UPGRADE_SIMULATED:-}" ]]; then
1034
+ _UP_SNAP="$(mktemp -d)" && upgrade_snapshot "$TARGET" > "$_UP_SNAP/before"
1035
+ fi
644
1036
  echo "-> $([[ $UPGRADE -eq 1 ]] && echo Upgrading || echo Scaffolding) $PROFILE profile $([[ $UPGRADE -eq 1 ]] && echo in || echo into) $TARGET"
645
- mkdir -p "$TARGET/.claude/agents" "$TARGET/.claude/skills" "$TARGET/.claude/rules" "$TARGET/scripts/lib"
1037
+ mkdir -p "$TARGET/scripts/lib" "$(dirname "$KITCFG")"
1038
+ adapter_has "$ADAPTERS" claude && mkdir -p "$TARGET/.claude/agents" "$TARGET/.claude/skills" "$TARGET/.claude/rules"
646
1039
 
647
1040
  # ---- kit.config.json (built with jq for correctness) --------------------
648
- KITCFG="$TARGET/.claude/kit.config.json"
1041
+ RECIPE_CFG='{}'
1042
+ [[ -n "$RECIPE_FILE" ]] && RECIPE_CFG="$(jq -c '.config // {}' "$RECIPE_FILE")"
1043
+ # Location: .claude/kit.config.json when the Claude adapter is selected (the layout every existing
1044
+ # project has); the root cckit.config.json for a Codex-only project, which gets no .claude/ tree.
649
1045
  jq -n \
1046
+ --argjson adapters "$(adapter_json "$ADAPTERS")" \
650
1047
  --arg kitver "$PLUGIN_VERSION" \
651
1048
  --arg name "$NAME" --arg slug "$SLUG" --arg owner "$OWNER_NAME" --arg lang "$LANG_PREF" --arg path "$TARGET" \
652
1049
  --arg profile "$PROFILE" --argjson roles "$ROLES_JSON" \
@@ -659,7 +1056,11 @@ jq -n \
659
1056
  --argjson speckit "$SPECKIT_JSON" \
660
1057
  --argjson ppen "$PREPUSH_ENABLED" --arg ppcmd "$PREPUSH_CMD" \
661
1058
  --argjson localon "$LOCAL_ON" \
1059
+ --argjson ckinds "$CONTENT_KINDS_ON" --arg prbody "$PR_BODY_STYLE" --argjson plain "$PLAIN_ON" \
1060
+ --arg tasksdef "$TASKS_DEFAULT" \
1061
+ --argjson recipecfg "$RECIPE_CFG" \
662
1062
  '{kitVersion:$kitver,
1063
+ adapters:$adapters,
663
1064
  project:{name:$name,slug:$slug,owner:$owner,language:$lang,path:$path},
664
1065
  profile:$profile, roles:$roles,
665
1066
  github:{repo:$repo,owner:$ghowner,baseBranch:$base,projectsV2:$pv2,projectNumber:$pnum,projectTitle:$ptitle},
@@ -669,58 +1070,135 @@ jq -n \
669
1070
  specKit:{enabled:$speckit},
670
1071
  prePush:{enabled:$ppen,command:$ppcmd},
671
1072
  local:{enabled:$localon,port:8080,model:"mlx-community/Qwen3-8B-4bit"},
672
- memory:{enabled:$mem,provider:"mempalace",wing:$wing,claudeProjectSlug:$cps}}' \
1073
+ memory:{enabled:$mem,provider:"mempalace",wing:$wing,claudeProjectSlug:$cps}}
1074
+ # Content-work keys are written only when the profile turns them on, so the config of a
1075
+ # software project does not gain keys it never reads (E415).
1076
+ | if $ckinds then .kinds = {content:true} else . end
1077
+ | if $prbody == "content" then .pr = {bodyStyle:"content"} else . end
1078
+ | if $plain then .plainLanguage = {enabled:true} else . end
1079
+ | if $tasksdef == "light" then .tasks = {default:"light"} else . end
1080
+ # Config keys the recipe carries (`config` in recipes/<id>.json), merged over the above: the
1081
+ # recipe knows the commands of the project it made (tasks.check, the gate of `cckit task run`).
1082
+ | . * $recipecfg
1083
+ # The config is committed by the guided setup, so it carries no absolute machine path (#490).
1084
+ | del(.project.path)' \
673
1085
  > "$KITCFG.kit-new"
674
1086
  if [[ $UPGRADE -eq 1 && -f "$KITCFG" ]]; then
675
1087
  # deep-merge: existing values win (preserve user choices), new REQUIRED keys added, version
676
1088
  # bumped. FEATURE blocks (plans/specKit/prePush/local/memory) are additive only when the
677
1089
  # project's config ALREADY has them — a missing feature key is a deliberate absence, and an
678
- # upgrade must never inject profile defaults over it (#149).
1090
+ # upgrade must never inject profile defaults over it (#149). `adapters` follows the same rule: a
1091
+ # config without the key means Claude, and an upgrade that changes nothing must not write it.
1092
+ # The project's key order is kept: a key the template adds goes after the keys already there, at
1093
+ # every depth. (`$tmpl * $have` gave the same values in the TEMPLATE's order, which moved the
1094
+ # project's own blocks around on every upgrade — #448.)
679
1095
  jq -s --arg kitver "$PLUGIN_VERSION" '
1096
+ def fill($h; $t):
1097
+ if ($h | type) == "object" and ($t | type) == "object"
1098
+ then reduce ($t | keys_unsorted[]) as $k ($h;
1099
+ if has($k) then .[$k] = fill($h[$k]; $t[$k]) else .[$k] = $t[$k] end)
1100
+ else $h end;
680
1101
  .[1] as $have
681
1102
  | (.[0] | with_entries(.key as $k | select(
682
- (["plans","specKit","prePush","local","memory"] | index($k)) == null
1103
+ (["plans","specKit","prePush","local","memory","adapters","plainLanguage"] | index($k)) == null
683
1104
  or ($have | has($k))))) as $tmpl
684
- | $tmpl * $have | .kitVersion = $kitver' "$KITCFG.kit-new" "$KITCFG" \
685
- > "$KITCFG.merged" && mv "$KITCFG.merged" "$KITCFG"
1105
+ | fill($have; $tmpl) | .kitVersion = $kitver' "$KITCFG.kit-new" "$KITCFG" \
1106
+ > "$KITCFG.merged"
686
1107
  rm -f "$KITCFG.kit-new"
687
1108
  # Existing values win in the merge — but an EXPLICIT --local flag is a user decision now,
688
1109
  # so it overrides the preserved value (port/model stay as the user configured them).
689
1110
  if [[ $LOCAL_EXPLICIT -eq 1 ]]; then
690
1111
  jq --argjson v "$LOCAL_ON" '.local = ((.local // {port:8080,model:"mlx-community/Qwen3-8B-4bit"}) | .enabled = $v)' \
691
- "$KITCFG" > "$KITCFG.tmp" && mv "$KITCFG.tmp" "$KITCFG"
1112
+ "$KITCFG.merged" > "$KITCFG.tmp" && mv "$KITCFG.tmp" "$KITCFG.merged"
692
1113
  fi
693
- echo " + .claude/kit.config.json (merged · kitVersion -> $PLUGIN_VERSION)"
1114
+ # An explicit --adapter is a decision made now, so it is written even where the key was absent.
1115
+ if [[ -n "$ADAPTERS_NEW" ]]; then
1116
+ jq --argjson v "$(adapter_json "$ADAPTERS")" '.adapters = $v' "$KITCFG.merged" > "$KITCFG.tmp" && mv "$KITCFG.tmp" "$KITCFG.merged"
1117
+ fi
1118
+ # Written with the fewest changed lines: a version bump alone edits the one `kitVersion` line and
1119
+ # leaves the file's formatting as the project keeps it. A merge that adds keys re-serialises it.
1120
+ _cfg_how="$(json_write_minimal "$KITCFG.merged" "$KITCFG")"
1121
+ echo " + $CONFIG_REL (merged · kitVersion -> $PLUGIN_VERSION · $_cfg_how)"
694
1122
  else
695
1123
  mv "$KITCFG.kit-new" "$KITCFG"
696
- echo " + .claude/kit.config.json"
1124
+ echo " + $CONFIG_REL"
697
1125
  fi
698
1126
 
699
- # ---- CLAUDE.md -----------------------------------------------------------
700
- safe_write "$KIT_ROOT/templates/CLAUDE.md.tmpl" "$TARGET/CLAUDE.md"
701
- echo " + CLAUDE.md"
1127
+ # ---- agents: one role source, one definition per selected runtime (E257.6) ----
1128
+ # templates/agents/<role>.md is the role. Claude Code reads it as markdown; Codex reads a custom
1129
+ # agent as TOML, so the SAME rendered role is translated by agent_def_codex (scripts/lib/agent-def.sh).
1130
+ if adapter_has "$ADAPTERS" claude; then
1131
+ use_adapter claude
1132
+ for a in $AGENTS; do
1133
+ src="$KIT_ROOT/templates/agents/$a.md"
1134
+ [[ -f "$src" ]] || continue
1135
+ safe_write "$src" "$TARGET/.claude/agents/$a/AGENT.md"
1136
+ echo " + .claude/agents/$a/AGENT.md"
1137
+ done
1138
+ fi
1139
+ if adapter_has "$ADAPTERS" codex; then
1140
+ use_adapter codex
1141
+ # shellcheck source=/dev/null
1142
+ . "$KIT_ROOT/scripts/lib/agent-def.sh"
1143
+ for a in $AGENTS; do
1144
+ src="$KIT_ROOT/templates/agents/$a.md"
1145
+ [[ -f "$src" ]] || continue
1146
+ _ca_rel=".codex/agents/$a.toml"; _ca_dst="$TARGET/$_ca_rel"
1147
+ if _upgrade_excluded "$_ca_rel"; then UPGRADE_SKIPPED+=("$_ca_rel"); continue; fi
1148
+ if [[ $UPGRADE -eq 1 && -e "$_ca_dst" ]]; then UPGRADE_PRESERVED+=("$_ca_rel"); continue; fi
1149
+ if [[ $UPGRADE -eq 0 && $FORCE -eq 0 && -e "$_ca_dst" ]]; then
1150
+ # A fresh init over a .codex/agents/ the user already keeps: their file wins, as AGENTS.md does.
1151
+ echo " = $_ca_rel (already there — kept; --force replaces it)"; continue
1152
+ fi
1153
+ _ca_tmp="$(mktemp)"
1154
+ render_tpl "$src" > "$_ca_tmp"
1155
+ mkdir -p "$TARGET/.codex/agents"
1156
+ if agent_def_codex "$_ca_tmp" > "$_ca_dst.kit-new"; then
1157
+ mv "$_ca_dst.kit-new" "$_ca_dst"
1158
+ WRITTEN+=("$_ca_rel")
1159
+ [[ $UPGRADE -eq 1 ]] && UPGRADE_ADDED+=("$_ca_rel")
1160
+ echo " + $_ca_rel"
1161
+ else
1162
+ rm -f "$_ca_dst.kit-new"
1163
+ echo " ! $_ca_rel not written — templates/agents/$a.md has no name or description" >&2
1164
+ fi
1165
+ rm -f "$_ca_tmp"
1166
+ done
1167
+ fi
1168
+ use_adapter "${ADAPTERS%% *}"
1169
+
1170
+ # ---- instructions + rules + skills, once per selected adapter ------------
1171
+ # Same templates, same loop: the adapter decides the destination dir and the IF:ADAPTER_* blocks.
1172
+ # A second adapter's pass never touches the first one's tree.
1173
+ for _ad in $ADAPTERS; do
1174
+ use_adapter "$_ad"
1175
+ AD="$ADAPTER_DIR"; _instr="$(adapter_instructions "$_ad")"
1176
+
1177
+ # CLAUDE.md / AGENTS.md — one source (templates/instructions.md.tmpl). A pre-existing AGENTS.md is
1178
+ # usually the project's own contract, so a fresh init keeps it unless --force (CLAUDE.md keeps its
1179
+ # historical behavior: a fresh init writes it).
1180
+ if [[ "$_ad" == "codex" && -e "$TARGET/$_instr" && $UPGRADE -eq 0 && $FORCE -eq 0 ]]; then
1181
+ echo " = $_instr exists — kept (re-run with --force to replace it with the cckit instructions)"
1182
+ else
1183
+ safe_write "$KIT_ROOT/templates/instructions.md.tmpl" "$TARGET/$_instr"
1184
+ echo " + $_instr"
1185
+ fi
702
1186
 
703
1187
  # ---- rules (filtered by enabled flags) ----------------------------------
704
1188
  for r in $RULES; do
705
1189
  # Skip rules whose feature is disabled for this project.
706
- case "$r" in
707
- mempalace) [[ "$MEMORY_BOOL" == "true" ]] || continue ;;
708
- design-routing) [[ "$DESIGN_ON" == "true" ]] || continue ;;
709
- plan-output-format) [[ "$PLANS_ON" == "true" ]] || continue ;;
710
- esac
1190
+ _rule_enabled "$r" || continue
711
1191
  src="$KIT_ROOT/templates/rules/$r.md"
712
1192
  [[ -f "$src" ]] || { echo " missing rule: $r"; continue; }
713
- safe_write "$src" "$TARGET/.claude/rules/$r.md"
714
- echo " + .claude/rules/$r.md"
715
- done
716
-
717
- # ---- agents --------------------------------------------------------------
718
- for a in $AGENTS; do
719
- src="$KIT_ROOT/templates/agents/$a.md"
720
- [[ -f "$src" ]] || continue
721
- safe_write "$src" "$TARGET/.claude/agents/$a/AGENT.md"
722
- echo " + .claude/agents/$a/AGENT.md"
1193
+ safe_write "$src" "$TARGET/$AD/rules/$r.md"
1194
+ echo " + $AD/rules/$r.md"
723
1195
  done
1196
+ # code-retrieval is in no profile: `cckit add <id>` writes it when a code-graph integration is
1197
+ # switched on. An upgrade re-adds it only for a project whose config already has one on.
1198
+ if [[ "$CODEGRAPH_ON" == "true" ]]; then
1199
+ safe_write "$KIT_ROOT/templates/rules/code-retrieval.md" "$TARGET/$AD/rules/code-retrieval.md"
1200
+ echo " + $AD/rules/code-retrieval.md"
1201
+ fi
724
1202
 
725
1203
  # ---- skills --------------------------------------------------------------
726
1204
  for s in $SKILLS; do
@@ -732,30 +1210,35 @@ for s in $SKILLS; do
732
1210
  if [[ -n "$SKILL_PREFIX" ]] && _is_namespaced "$s"; then
733
1211
  dest_name="${SKILL_PREFIX}${s}"
734
1212
  fi
735
- safe_write "$src" "$TARGET/.claude/skills/$dest_name/SKILL.md"
1213
+ safe_write "$src" "$TARGET/$AD/skills/$dest_name/SKILL.md"
736
1214
  # If prefixed AND this was a FRESH scaffold (frontmatter still bare), rewrite name + sibling refs.
737
1215
  # An existing (preserved) skill already reads `name: $dest_name`, so the guard skips it.
738
- if [[ "$dest_name" != "$s" && -f "$TARGET/.claude/skills/$dest_name/SKILL.md" ]] \
739
- && grep -qE "^name:[[:space:]]*${s}[[:space:]]*\$" "$TARGET/.claude/skills/$dest_name/SKILL.md"; then
740
- _prefix_skill_file "$TARGET/.claude/skills/$dest_name/SKILL.md"
1216
+ if [[ "$dest_name" != "$s" && -f "$TARGET/$AD/skills/$dest_name/SKILL.md" ]] \
1217
+ && grep -qE "^name:[[:space:]]*${s}[[:space:]]*\$" "$TARGET/$AD/skills/$dest_name/SKILL.md"; then
1218
+ _prefix_skill_file "$TARGET/$AD/skills/$dest_name/SKILL.md"
741
1219
  fi
742
- echo " + .claude/skills/$dest_name/SKILL.md"
1220
+ echo " + $AD/skills/$dest_name/SKILL.md"
743
1221
  # bundled references for multi-file skills (copied verbatim, no templating).
744
1222
  # Per-file safe_copy so the upgrade contract (preserve existing, skip excluded) applies.
745
1223
  if [[ -d "$KIT_ROOT/templates/skills/$s/references" ]]; then
746
1224
  for _ref in "$KIT_ROOT/templates/skills/$s/references/"*; do
747
1225
  [[ -f "$_ref" ]] || continue
748
- safe_copy "$_ref" "$TARGET/.claude/skills/$dest_name/references/$(basename "$_ref")"
1226
+ safe_copy "$_ref" "$TARGET/$AD/skills/$dest_name/references/$(basename "$_ref")"
749
1227
  done
750
- echo " + .claude/skills/$dest_name/references/"
1228
+ echo " + $AD/skills/$dest_name/references/"
751
1229
  fi
752
1230
  done
1231
+ done # adapters
1232
+ use_adapter "${ADAPTERS%% *}"
753
1233
 
754
1234
  # ---- scripts (libs + setup + sync; kit-owned) ---------------------------
755
1235
  # safe_copy honors the upgrade contract: on --upgrade an EXISTING script is PRESERVED, never
756
1236
  # overwritten with an older template (the #334 downgrade that erased #307/#313/#314). Fresh
757
1237
  # inits get the current scripts; to refresh a kit-owned script later, delete it then re-upgrade.
758
1238
  safe_copy "$KIT_ROOT/scripts/lib/kit-config.sh" "$TARGET/scripts/lib/kit-config.sh"
1239
+ # kit-config.sh and kit-version-check.sh both source this resolver from beside themselves; without it
1240
+ # they only ever look at .claude/kit.config.json and miss a Codex-only project's root config.
1241
+ safe_copy "$KIT_ROOT/scripts/lib/config-path.sh" "$TARGET/scripts/lib/config-path.sh"
759
1242
  safe_copy "$KIT_ROOT/scripts/lib/gh-project.sh" "$TARGET/scripts/lib/gh-project.sh"
760
1243
  safe_copy "$KIT_ROOT/scripts/lib/worktree-issue.sh" "$TARGET/scripts/lib/worktree-issue.sh"
761
1244
  safe_copy "$KIT_ROOT/scripts/lib/role-identity.sh" "$TARGET/scripts/lib/role-identity.sh"
@@ -764,15 +1247,23 @@ safe_copy "$KIT_ROOT/scripts/lib/engine-adapter.sh" "$TARGET/scripts/lib/engine-
764
1247
  safe_copy "$KIT_ROOT/scripts/lib/effort-metrics.sh" "$TARGET/scripts/lib/effort-metrics.sh"
765
1248
  safe_copy "$KIT_ROOT/scripts/lib/gh-log.sh" "$TARGET/scripts/lib/gh-log.sh"
766
1249
  safe_copy "$KIT_ROOT/scripts/lib/kit-events.sh" "$TARGET/scripts/lib/kit-events.sh"
1250
+ # task-sync.sh sources board-view.sh unguarded (set -e) and effort-plan.sh for `--plan`.
1251
+ safe_copy "$KIT_ROOT/scripts/lib/board-view.sh" "$TARGET/scripts/lib/board-view.sh"
1252
+ safe_copy "$KIT_ROOT/scripts/lib/effort-plan.sh" "$TARGET/scripts/lib/effort-plan.sh"
767
1253
  safe_copy "$KIT_ROOT/scripts/lib/worktree-start.sh" "$TARGET/scripts/lib/worktree-start.sh"
1254
+ # pr-evidence.sh is the helper rules/gate-and-review.md tells a project to source; without this copy
1255
+ # `cckit lib` resolves to the project's own scripts/lib, where the helper would be missing.
1256
+ safe_copy "$KIT_ROOT/scripts/lib/pr-evidence.sh" "$TARGET/scripts/lib/pr-evidence.sh"
1257
+ safe_copy "$KIT_ROOT/scripts/lib/session-registry.sh" "$TARGET/scripts/lib/session-registry.sh"
1258
+ safe_copy "$KIT_ROOT/scripts/lib/kinds.sh" "$TARGET/scripts/lib/kinds.sh"
768
1259
  safe_copy "$KIT_ROOT/scripts/kit-version-check.sh" "$TARGET/scripts/kit-version-check.sh" exec
769
1260
  for sc in setup-labels.sh setup-milestones.sh capture-project-ids.sh task-sync.sh knowledge-lint.sh \
770
- review-lint.sh skill-frontmatter-lint.sh; do
1261
+ review-lint.sh skill-frontmatter-lint.sh instruction-budget-lint.sh; do
771
1262
  safe_copy "$KIT_ROOT/scripts/$sc" "$TARGET/scripts/$sc" exec
772
1263
  done
773
1264
  # review-lint is table-driven: the engine is useless without a rule table, so the starter table
774
- # travels with it. Both lints self-disable when they do not apply (no rule table / no skills dir),
775
- # so shipping them to every project is safe.
1265
+ # travels with it. Every lint self-disables when it does not apply (no rule table / no skills dir /
1266
+ # no CLAUDE.md and no rules dir), so shipping them to every project is safe.
776
1267
  safe_copy "$KIT_ROOT/scripts/review-rules.conf" "$TARGET/scripts/review-rules.conf"
777
1268
  # Seed each baseline ONCE so a fresh project starts green and only *new* defects fail. Never
778
1269
  # regenerate an existing baseline - that would silently re-grandfather drift on upgrade.
@@ -786,14 +1277,14 @@ safe_copy "$KIT_ROOT/scripts/review-rules.conf" "$TARGET/scripts/review-rules.co
786
1277
  # that already has commits, where `git ls-files` is non-empty and the untracked kit files are
787
1278
  # invisible to it; the baseline would come out empty and the gate would go red on the user's first
788
1279
  # commit of the scaffold.
789
- for _lint in review-lint skill-frontmatter-lint; do
1280
+ for _lint in review-lint skill-frontmatter-lint instruction-budget-lint; do
790
1281
  [[ -f "$TARGET/scripts/$_lint.sh" ]] || continue
791
1282
  _baseline="$( cd "$TARGET" && bash "scripts/$_lint.sh" --baseline-path 2>/dev/null )"
792
1283
  [[ -n "$_baseline" ]] || continue
793
1284
  [[ -e "$TARGET/$_baseline" ]] && continue
794
1285
  ( cd "$TARGET" && KIT_LINT_WALK=1 bash "scripts/$_lint.sh" --update ) >/dev/null 2>&1 || true
795
1286
  done
796
- echo " + scripts/ (libs + setup + task-sync + version-check + knowledge-lint + review-lint + skill-frontmatter-lint)"
1287
+ echo " + scripts/ (libs + setup + task-sync + version-check + knowledge-lint + review-lint + skill-frontmatter-lint + instruction-budget-lint)"
797
1288
 
798
1289
  # ---- benchmark harness (generic machinery; kit-owned) + example dataset ----
799
1290
  # The harness measures how well THIS project's own canonical docs can be found + used by a cold
@@ -816,7 +1307,13 @@ echo " + benchmarks/ (example dataset + schema — grow your own; run: scripts/
816
1307
  # ---- knowledge base (governed dir: INDEX manifest; upgrade-safe) ---------
817
1308
  mkdir -p "$TARGET/knowledge"
818
1309
  safe_write "$KIT_ROOT/templates/knowledge-INDEX.md.tmpl" "$TARGET/knowledge/INDEX.md"
819
- echo " + knowledge/INDEX.md (manifest — see .claude/rules/knowledge-base.md)"
1310
+ echo " + knowledge/INDEX.md (manifest — see $ADAPTER_DIR/rules/knowledge-base.md)"
1311
+
1312
+ # ==== Claude adapter only: sigil lib, settings, hooks, statusline wiring ====
1313
+ # Everything from here to the matching `fi` is Claude Code configuration. A Codex-only project gets
1314
+ # none of it — Codex hook registration is E257.5 — and the body is left unindented on purpose so the
1315
+ # hook blocks keep their history.
1316
+ if adapter_has "$ADAPTERS" claude; then
820
1317
 
821
1318
  # ---- .claude/lib (kit-sigil attribution helper; all projects; idempotent) ----
822
1319
  # Sourced by the task-* skill footers + repo-hygiene to emit one "claude-kit"
@@ -838,7 +1335,8 @@ echo " + .claude/settings.json (versioned captain merge permission)"
838
1335
  mkdir -p "$TARGET/.claude"
839
1336
  safe_write "$KIT_ROOT/templates/settings/settings.local.json.tmpl" "$TARGET/.claude/settings.local.json"
840
1337
  SETTINGS="$TARGET/.claude/settings.local.json"
841
- merge_settings() { jq "$@" "$SETTINGS" > "$SETTINGS.tmp" && mv "$SETTINGS.tmp" "$SETTINGS"; }
1338
+ # A merge that leaves the value as it was does not rewrite the file (json_write_minimal, #448).
1339
+ merge_settings() { jq "$@" "$SETTINGS" > "$SETTINGS.tmp" && json_write_minimal "$SETTINGS.tmp" "$SETTINGS" >/dev/null; }
842
1340
  HOOK_NOTE=""
843
1341
 
844
1342
  if [[ "$MEMORY_BOOL" == "true" && $UPGRADE -eq 0 ]]; then
@@ -911,12 +1409,34 @@ hook_write "$KIT_ROOT/templates/hooks/guard-raw-git-ops.sh.tmpl" "$TARGET/.claud
911
1409
  chmod +x "$TARGET/.claude/hooks/guard-raw-git-ops.sh" 2>/dev/null || true
912
1410
  _TRACKED="$TARGET/.claude/settings.json"
913
1411
  [[ -f "$_TRACKED" ]] || echo '{}' > "$_TRACKED"
1412
+ # A registration that is already there — in its own block or inside one the project arranged — is
1413
+ # left where it is; the file is rewritten only when the guard had to be added (#448: the upgrade
1414
+ # moved it into a new block on every run and still listed settings.json as preserved).
1415
+ # shellcheck disable=SC2016 # $CLAUDE_PROJECT_DIR is expanded by Claude Code at hook time
914
1416
  jq --arg g '$CLAUDE_PROJECT_DIR/.claude/hooks/guard-raw-git-ops.sh' \
915
- '.hooks.PreToolUse = (((.hooks.PreToolUse // []) | map(.hooks |= map(select(.command != $g))) | map(select((.hooks | length) > 0)))
916
- + [{matcher:"Bash",hooks:[{type:"command",command:$g,timeout:10}]}])' \
917
- "$_TRACKED" > "$_TRACKED.tmp" && mv "$_TRACKED.tmp" "$_TRACKED"
1417
+ 'if ([ (.hooks.PreToolUse // [])[] | (.hooks // [])[] | .command ] | index($g)) != null then .
1418
+ else .hooks.PreToolUse = ((.hooks.PreToolUse // []) + [{matcher:"Bash",hooks:[{type:"command",command:$g,timeout:10}]}])
1419
+ end' "$_TRACKED" > "$_TRACKED.tmp" && json_write_minimal "$_TRACKED.tmp" "$_TRACKED" >/dev/null
918
1420
  echo " + .claude/hooks/guard-raw-git-ops.sh (PreToolUse Bash, wired in tracked settings.json: raw gh/git -> cckit verb)"
919
1421
 
1422
+ # ---- session-mail hook (all projects; init AND --upgrade; idempotent) ----
1423
+ # One script on four events delivers `cckit msg` mail to a running session (E257.5). Wired in the
1424
+ # TRACKED settings.json for the same reason as the raw-git guard: mail has to reach worktrees. A
1425
+ # registration that is already there is left as it is (its timeout or position may be the user's),
1426
+ # and a project that listed the hook in `upgrade.removed` is not re-wired.
1427
+ if ! _upgrade_excluded ".claude/hooks/kit-mail-check.sh"; then
1428
+ hook_write "$KIT_ROOT/templates/hooks/kit-mail-check.sh.tmpl" "$TARGET/.claude/hooks/kit-mail-check.sh"
1429
+ chmod +x "$TARGET/.claude/hooks/kit-mail-check.sh" 2>/dev/null || true
1430
+ # shellcheck disable=SC2016 # $CLAUDE_PROJECT_DIR is expanded by Claude Code at hook time
1431
+ jq --arg m 'bash "$CLAUDE_PROJECT_DIR/.claude/hooks/kit-mail-check.sh"' '
1432
+ reduce (["PostToolUse","*"], ["UserPromptSubmit",""], ["SessionStart",""], ["Stop",""]) as [$e, $mt] (.;
1433
+ if ([ (.hooks[$e] // [])[] | (.hooks // [])[] | .command ] | index($m)) != null then .
1434
+ else .hooks[$e] = ((.hooks[$e] // [])
1435
+ + [ (if $mt == "" then {} else {matcher: $mt} end) + {hooks: [{type: "command", command: $m, timeout: 10}]} ])
1436
+ end)' "$_TRACKED" > "$_TRACKED.tmp" && json_write_minimal "$_TRACKED.tmp" "$_TRACKED" >/dev/null
1437
+ echo " + .claude/hooks/kit-mail-check.sh (session mail, wired in tracked settings.json on 4 events)"
1438
+ fi
1439
+
920
1440
  # ---- version-check SessionStart hook (all projects; idempotent) ---------
921
1441
  mkdir -p "$TARGET/.claude/hooks"
922
1442
  hook_write "$KIT_ROOT/templates/hooks/kit_version_check.sh.tmpl" "$TARGET/.claude/hooks/kit_version_check.sh"
@@ -925,26 +1445,99 @@ merge_settings --arg vc "$TARGET/.claude/hooks/kit_version_check.sh" \
925
1445
  '.hooks.SessionStart = (((.hooks.SessionStart // []) | map(select((.hooks[0].command // "") != $vc))) + [{matcher:"",hooks:[{type:"command",command:$vc,timeout:10}]}])'
926
1446
  HOOK_NOTE="$HOOK_NOTE + version-check"
927
1447
 
1448
+ echo " + .claude/settings.local.json${HOOK_NOTE:+ (}${HOOK_NOTE# + }${HOOK_NOTE:+)}"
1449
+ else
1450
+ echo " · Codex adapter only: no .claude/ tree"
1451
+ fi # ==== end Claude adapter only ====
1452
+
1453
+ # ==== Codex adapter: hook scripts + their registration in .codex/hooks.json (E257.5) ====
1454
+ # The SAME hook templates as the Claude adapter, rendered into .codex/hooks/: Codex sends the event
1455
+ # fields they read (hook_event_name, cwd, tool_input.command) and honours the same answers (exit 2 +
1456
+ # stderr blocks a tool, decision:block continues a Stop, additionalContext injects text).
1457
+ # Not installed: the MemPalace hooks. mempal_save / mempal_precompact mine ~/.claude/projects/, the
1458
+ # Claude Code transcript store, and no Codex transcript format has been validated against
1459
+ # `mempalace mine` — see agent-compatibility.mdx.
1460
+ CODEX_HOOKS_CHANGED=0
1461
+ if adapter_has "$ADAPTERS" codex; then
1462
+ # shellcheck source=/dev/null
1463
+ . "$KIT_ROOT/scripts/lib/codex-hooks.sh"
1464
+ # shellcheck source=/dev/null
1465
+ . "$KIT_ROOT/scripts/lib/kit-manifest.sh"
1466
+ mkdir -p "$TARGET/.codex/hooks"
1467
+ _CX_SRC="$(mktemp)"
1468
+ cp "$KIT_ROOT/templates/codex/hooks.json.tmpl" "$_CX_SRC"
1469
+ _CX_HOOKS="repo-hygiene.sh kit_version_check.sh kit-mail-check.sh guard-base-branch-commit.sh guard-raw-git-ops.sh"
1470
+ _cx_optional() { # <event> <matcher> <script> <timeout> — an opt-in hook joins the set to register
1471
+ local frag; frag="$(mktemp)"
1472
+ codex_hooks_fragment "$1" "$2" "$3" "$4" > "$frag" && codex_hooks_merge "$_CX_SRC" "$frag" >/dev/null
1473
+ rm -f "$frag"
1474
+ _CX_HOOKS="$_CX_HOOKS $3"
1475
+ }
1476
+ [[ "$PREPUSH_ENABLED" == "true" ]] && _cx_optional PreToolUse Bash prepush_gate.sh 120
1477
+ [[ "$LOCAL_ON" == "true" ]] && _cx_optional SessionStart "" kit-local-status.sh 10
1478
+ for _h in $_CX_HOOKS; do
1479
+ _cx_dst="$TARGET/.codex/hooks/$_h"
1480
+ _cx_n=$(( ${#WRITTEN[@]} + ${#UPGRADE_REFRESHED[@]} ))
1481
+ if [[ $UPGRADE -eq 0 && $FORCE -eq 0 && -e "$_cx_dst" ]]; then
1482
+ # A fresh init over a .codex/hooks/ the user already keeps: their file wins, as AGENTS.md does.
1483
+ echo " = .codex/hooks/$_h (already there — kept; --force replaces it)"
1484
+ else
1485
+ hook_write "$KIT_ROOT/templates/hooks/$_h.tmpl" "$_cx_dst"
1486
+ chmod +x "$_cx_dst" 2>/dev/null || true
1487
+ fi
1488
+ [[ $(( ${#WRITTEN[@]} + ${#UPGRADE_REFRESHED[@]} )) -gt $_cx_n ]] && CODEX_HOOKS_CHANGED=1
1489
+ done
1490
+ echo " + .codex/hooks/ ($(printf '%s' "$_CX_HOOKS" | sed 's/ /, /g'))"
1491
+ # hooks.json is the project's file. cckit's handlers are merged in (a handler already registered for
1492
+ # the event is skipped, everything else in the file is kept) and a merge that changes nothing does
1493
+ # not rewrite it. It is recorded as kit-owned only when cckit created it or the manifest still
1494
+ # proves it unmodified — a hooks.json holding the user's own entries is never claimed.
1495
+ _CX_JSON="$TARGET/.codex/hooks.json"; _cx_own=0
1496
+ if [[ ! -e "$_CX_JSON" ]]; then _cx_own=1
1497
+ elif [[ "$( cd "$TARGET" && KIT_MANIFEST="$MANIFEST_REL" kit_manifest_verify .codex/hooks.json 2>/dev/null )" == "intact" ]]; then _cx_own=1
1498
+ fi
1499
+ if _upgrade_excluded ".codex/hooks.json"; then
1500
+ UPGRADE_SKIPPED+=(".codex/hooks.json")
1501
+ elif _cx_state="$(codex_hooks_merge "$_CX_JSON" "$_CX_SRC")"; then
1502
+ case "$_cx_state" in
1503
+ created) echo " + .codex/hooks.json (SessionStart / PreToolUse Bash / PostToolUse / UserPromptSubmit / Stop)"
1504
+ [[ $UPGRADE -eq 1 ]] && UPGRADE_ADDED+=(".codex/hooks.json") ;;
1505
+ merged) echo " ~ .codex/hooks.json (cckit's hooks added; the entries already there are kept)" ;;
1506
+ *) [[ $UPGRADE -eq 1 ]] && UPGRADE_PRESERVED+=(".codex/hooks.json") ;;
1507
+ esac
1508
+ if [[ "$_cx_state" != "unchanged" ]]; then
1509
+ CODEX_HOOKS_CHANGED=1
1510
+ [[ $_cx_own -eq 1 ]] && WRITTEN+=(".codex/hooks.json")
1511
+ fi
1512
+ else
1513
+ echo " ! .codex/hooks.json was left untouched — cckit's Codex hooks are NOT registered. Fix the file, then run: cckit init --upgrade" >&2
1514
+ fi
1515
+ rm -f "$_CX_SRC"
1516
+ [[ "$MEMORY_BOOL" == "true" ]] && echo " · Codex adapter: no memory hooks — the transcript sweep reads Claude Code's ~/.claude/projects/ only"
1517
+ fi # ==== end Codex adapter hooks ====
1518
+
928
1519
  # ---- recommended .gitignore entries (idempotent) ------------------------
929
1520
  # kit.manifest.json is kit-managed bookkeeping (content hashes + timestamps, re-stamped on every
930
1521
  # wire) — tracking it would dirty the tree on every session/upgrade, the exact churn #334 removes.
931
1522
  GI="$TARGET/.gitignore"
932
- for _ig in ".claude/settings.local.json" ".claude/kit.manifest.json" ".kann/"; do
1523
+ _GI_LOCAL=""; adapter_has "$ADAPTERS" claude && _GI_LOCAL=".claude/settings.local.json"
1524
+ # .cckit/ is cckit's local state (consent, mail, handoff, autopilot runs) and .claude/worktrees/ holds
1525
+ # the checkouts `cckit start` and `cckit task start` create: neither is ever committed (#487).
1526
+ for _ig in "$_GI_LOCAL" "$MANIFEST_REL" ".kann/" ".cckit/" ".claude/worktrees/"; do
1527
+ [[ -n "$_ig" ]] || continue
933
1528
  if [[ -f "$GI" ]]; then grep -qxF "$_ig" "$GI" || printf '%s\n' "$_ig" >> "$GI"; else printf '%s\n' "$_ig" > "$GI"; fi
934
1529
  done
935
1530
 
936
- echo " + .claude/settings.local.json${HOOK_NOTE:+ (}${HOOK_NOTE# + }${HOOK_NOTE:+)}"
937
-
938
1531
  # ---- wire (converge) -----------------------------------------------------
939
1532
  # Runs on BOTH scaffold and --upgrade so every update re-wires (fixes the class of bug where
940
1533
  # /kit-update refreshed files but never re-ran the wiring → statusline/settings drifted). #369
941
- if [[ -f "$KIT_ROOT/scripts/kit-wire.sh" ]]; then
1534
+ if [[ -f "$KIT_ROOT/scripts/kit-wire.sh" ]] && adapter_has "$ADAPTERS" claude; then
942
1535
  # On --upgrade an EXISTING .claude/statusline.sh follows the same contract as safe_write: the
943
1536
  # conffiles guard in kit-operate keeps a customized (or untracked) shim; only a shim the kit
944
1537
  # provably owns intact is refreshed (#149).
945
1538
  _SHIM="$TARGET/.claude/statusline.sh"
946
1539
  _shim_before=""; [[ -f "$_SHIM" ]] && _shim_before="$(cat "$_SHIM" 2>/dev/null)"
947
- if ( cd "$TARGET" && CLAUDE_PLUGIN_ROOT="$KIT_ROOT" KIT_ASSUME_YES=1 bash "$KIT_ROOT/scripts/kit-wire.sh" >/dev/null 2>&1 ); then
1540
+ if ( cd "$TARGET" && KIT_MANIFEST="$MANIFEST_REL" CLAUDE_PLUGIN_ROOT="$KIT_ROOT" KIT_ASSUME_YES=1 bash "$KIT_ROOT/scripts/kit-wire.sh" >/dev/null 2>&1 ); then
948
1541
  echo " + wired: statusline shim + settings.statusLine (kit-wire)"
949
1542
  fi
950
1543
  if [[ $UPGRADE -eq 1 && -n "$_shim_before" && "$_shim_before" == "$(cat "$_SHIM" 2>/dev/null)" ]]; then
@@ -952,31 +1545,89 @@ if [[ -f "$KIT_ROOT/scripts/kit-wire.sh" ]]; then
952
1545
  fi
953
1546
  fi
954
1547
 
1548
+ # ---- ownership manifest: record what this run wrote ----------------------
1549
+ # Only the adapter files written NOW (never a preserved one — its content may be the user's), hashed
1550
+ # after every merge above so the recorded hash is the file as it was left. Keyed by path, so a
1551
+ # repeated upgrade updates nothing and adds nothing. This is what lets `cckit remove` and a later
1552
+ # upgrade tell a kit-owned file from an edited one for BOTH adapters.
1553
+ # shellcheck source=/dev/null
1554
+ . "$KIT_ROOT/scripts/lib/kit-manifest.sh"
1555
+ if [[ ${#WRITTEN[@]} -gt 0 ]]; then
1556
+ ( cd "$TARGET" && for _w in "${WRITTEN[@]}"; do
1557
+ if adapter_managed "$_w"; then printf '%s\t%s\n' "$(adapter_tier "$_w")" "$_w"; fi
1558
+ done | sort -u | KIT_MANIFEST="$MANIFEST_REL" kit_manifest_record_batch init "$PLUGIN_VERSION" ) \
1559
+ || echo " ! could not record the ownership manifest ($MANIFEST_REL)" >&2
1560
+ fi
1561
+
955
1562
  # ---- summary -------------------------------------------------------------
956
1563
  echo ""
957
1564
  echo "claude-kit $([[ $UPGRADE -eq 1 ]] && echo upgraded || echo scaffolded) — profile: $PROFILE"
958
1565
  echo " Project : $NAME ($SLUG)"
959
1566
  echo " Repo : $REPO"
1567
+ echo " Adapters: $ADAPTERS"
960
1568
  echo " Board : $([[ "$PROJECTS_V2" == "true" ]] && echo "Projects v2 #$PROJECT_NUMBER" || echo "off (gh issues only)")"
961
1569
  echo " Agents : $(echo $AGENTS | tr '\n' ' ')"
962
1570
  echo " Memory : $MEMORY_BOOL Plans: $PLANS_FORMAT Lang: $LANG_PREF kitVersion: $PLUGIN_VERSION"
963
1571
  echo " Spec Kit: $SPECKIT_ON Pre-push gate: $PREPUSH_ENABLED Local model: $LOCAL_ON Stack skills self-gate by package.json"
1572
+ [[ "$PLAIN_ON" == "true" ]] && echo " Wording : plain language (draft, review, approve)"
1573
+ [[ "$TASKS_DEFAULT" == "light" ]] && echo " Tasks : light tasks are the default list (cckit task; no GitHub issue per task)"
964
1574
 
965
1575
  if [[ $UPGRADE -eq 1 ]]; then
966
1576
  echo ""
967
1577
  echo " Upgrade -> kitVersion $PLUGIN_VERSION"
968
- if [[ ${#UPGRADE_ADDED[@]} -gt 0 ]]; then echo " Added (new in this kit version):"; printf ' + %s\n' "${UPGRADE_ADDED[@]}"; fi
1578
+ # What changed on disk, measured (the same block `--upgrade --dry-run` prints as "Would change").
1579
+ # A file the helpers left alone but a later step merged into — .claude/settings.json gaining a hook
1580
+ # registration — is in this block as M and is taken out of the Preserved list below.
1581
+ if [[ -n "$_UP_SNAP" && -f "$_UP_SNAP/before" ]]; then
1582
+ upgrade_snapshot "$TARGET" > "$_UP_SNAP/after"
1583
+ upgrade_changes "$_UP_SNAP/before" "$_UP_SNAP/after" > "$_UP_SNAP/changes"
1584
+ upgrade_changes_print "$_UP_SNAP/changes" "Changed on disk"
1585
+ _UP_MEASURED=1
1586
+ if [[ ${#UPGRADE_PRESERVED[@]} -gt 0 ]]; then
1587
+ _up_kept=()
1588
+ for _p in "${UPGRADE_PRESERVED[@]}"; do
1589
+ grep -qxF "M $_p" "$_UP_SNAP/changes" || _up_kept+=("$_p")
1590
+ done
1591
+ UPGRADE_PRESERVED=(); [[ ${#_up_kept[@]} -gt 0 ]] && UPGRADE_PRESERVED=("${_up_kept[@]}")
1592
+ fi
1593
+ rm -rf "$_UP_SNAP"
1594
+ fi
1595
+ # The A rows above already name every added file; the helper's own list is printed only when no
1596
+ # measurement was taken.
1597
+ if [[ ${_UP_MEASURED:-0} -eq 0 && ${#UPGRADE_ADDED[@]} -gt 0 ]]; then echo " Added (new in this kit version):"; printf ' + %s\n' "${UPGRADE_ADDED[@]}"; fi
969
1598
  if [[ ${#UPGRADE_PRESERVED[@]} -gt 0 ]]; then echo " Preserved (your edits, untouched):"; printf ' = %s\n' "${UPGRADE_PRESERVED[@]}"; fi
970
1599
  if [[ ${#UPGRADE_SKIPPED[@]} -gt 0 ]]; then echo " Skipped (removed/renamed via kit.config upgrade):"; printf ' - %s\n' "${UPGRADE_SKIPPED[@]}"; fi
971
1600
  if [[ ${#UPGRADE_REFRESHED[@]} -gt 0 ]]; then echo " Refreshed (unmodified hook, now the current template):"; printf ' ~ %s\n' "${UPGRADE_REFRESHED[@]}"; fi
972
1601
  if [[ ${#UPGRADE_DRIFTED[@]} -gt 0 ]]; then echo " Drifted (customized hook, kept — diff it against templates/hooks/ by hand):"; printf ' ! %s\n' "${UPGRADE_DRIFTED[@]}"; fi
1602
+ [[ $CODEX_HOOKS_CHANGED -eq 1 ]] && echo " Codex hooks changed: Codex skips a new or changed hook until you trust it — run /hooks in Codex."
973
1603
  else
974
1604
  echo ""
975
1605
  echo "Next steps:"
976
- echo " 1. Review CLAUDE.md and .claude/kit.config.json"
1606
+ echo " 1. Review $(adapter_instructions "${ADAPTERS%% *}") and $CONFIG_REL"
1607
+ # Labels and milestones belong to GitHub issues. A project whose task list is light tasks is not
1608
+ # told to seed them (#487); `cckit init --yes` still creates them with the rest of the setup.
1609
+ if [[ $SETUP_RUN -eq 0 && "$TASKS_DEFAULT" != "light" ]]; then
977
1610
  echo " 2. ./scripts/setup-labels.sh && ./scripts/setup-milestones.sh # seed the repo"
978
- [[ "$PROJECTS_V2" == "true" ]] && echo " 3. ./scripts/capture-project-ids.sh # cache Projects v2 field IDs"
979
- [[ "$LOCAL_ON" == "true" ]] && echo " 4. /kit-doctor # local model layer: installs mlx-lm (uv tool install) + starts mlx_lm.server"
1611
+ if [[ "$PROJECTS_V2" == "true" ]]; then echo " 3. ./scripts/capture-project-ids.sh # cache Projects v2 field IDs"; fi
1612
+ fi
1613
+ if [[ "$TASKS_DEFAULT" == "light" ]]; then
1614
+ echo " 2. Add the first task: cckit task new \"<title>\" then: cckit next"
1615
+ echo " 3. Start it: cckit task start <id>"
1616
+ fi
1617
+ [[ "$LOCAL_ON" == "true" ]] && echo " 4. /kit-doctor # local model layer: installs mlx-lm (recipe: integrations/mlx-lm.json) + starts mlx_lm.server"
1618
+ # The page-design skill coordinates three third-party design skills. They are offered, never
1619
+ # installed by init: each is an integration the person switches on and consents to (#504).
1620
+ if grep -qx "page-design" <<<"$SKILLS"; then
1621
+ echo " · Pages: the page-design skill is installed. It works with three third-party design skills, off until you add them:"
1622
+ echo " cckit add impeccable && cckit add emil-design-eng && cckit add web-design-guidelines && cckit doctor --fix"
1623
+ fi
1624
+ adapter_has "$ADAPTERS" codex && echo " · Codex: commit .codex/, then run /hooks in Codex and trust the project hooks — Codex skips them until you do."
1625
+ fi
1626
+
1627
+ # ---- git + GitHub setup, then the closing report (#456) --------------------
1628
+ if [[ $UPGRADE -eq 0 ]]; then
1629
+ if [[ $SETUP_RUN -eq 1 ]]; then init_setup_run; fi
1630
+ _init_finish
980
1631
  fi
981
1632
 
982
1633
  exit 0