@jeiemgi/cckit 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +169 -21
  3. package/README.md +505 -35
  4. package/SECURITY.md +5 -0
  5. package/bin/cckit +189 -20
  6. package/cckit.config.json +1 -1
  7. package/commands/kit-doctor.md +13 -5
  8. package/commands/kit-export-project.md +0 -2
  9. package/commands/kit-export-training.md +6 -9
  10. package/commands/kit-init.md +43 -13
  11. package/commands/kit-routines.md +1 -1
  12. package/commands/kit-update.md +11 -6
  13. package/databases/supabase/guide.html +106 -0
  14. package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
  15. package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
  16. package/databases/supabase.json +70 -0
  17. package/integrations/emil-design-eng.json +41 -0
  18. package/integrations/graft.json +81 -0
  19. package/integrations/impeccable.json +42 -0
  20. package/integrations/integration.schema.json +215 -0
  21. package/integrations/lavish.json +43 -0
  22. package/integrations/mempalace.json +28 -0
  23. package/integrations/mlx-lm.json +32 -0
  24. package/integrations/web-design-guidelines.json +42 -0
  25. package/kit.config.schema.json +183 -5
  26. package/package.json +4 -1
  27. package/profiles/automation.json +7 -1
  28. package/profiles/content.json +10 -2
  29. package/profiles/marketing.json +57 -0
  30. package/profiles/minimal.json +7 -1
  31. package/profiles/research.json +7 -1
  32. package/profiles/software.json +7 -1
  33. package/recipes/nextjs-shadcn.json +49 -0
  34. package/scripts/agent-skills-external.txt +45 -0
  35. package/scripts/agent-skills-lint-test.sh +131 -0
  36. package/scripts/agent-skills-lint.sh +115 -0
  37. package/scripts/agent-template-lint-test.sh +42 -0
  38. package/scripts/agent-template-lint.sh +58 -0
  39. package/scripts/annotate-setup.sh +1 -1
  40. package/scripts/autopilot-run-test.sh +338 -0
  41. package/scripts/autopilot-run.sh +448 -0
  42. package/scripts/autopilot-test.sh +8 -0
  43. package/scripts/autopilot.sh +10 -1
  44. package/scripts/benchmark/benchmark-test.sh +85 -0
  45. package/scripts/benchmark/checkpoint-test.sh +314 -0
  46. package/scripts/benchmark/checkpoint.sh +408 -0
  47. package/scripts/benchmark/lib/model.sh +31 -6
  48. package/scripts/benchmark/report.sh +17 -2
  49. package/scripts/benchmark/run-quality.sh +36 -10
  50. package/scripts/benchmark/verb-timings-test.sh +124 -0
  51. package/scripts/benchmark/verb-timings.sh +149 -0
  52. package/scripts/check.sh +29 -19
  53. package/scripts/content-skills-test.sh +144 -0
  54. package/scripts/copilot-loop-test.sh +25 -0
  55. package/scripts/database-supabase-test.sh +121 -0
  56. package/scripts/docs-marketing-words-test.sh +73 -0
  57. package/scripts/docs-record-tables-test.sh +72 -0
  58. package/scripts/guard-raw-git-ops-test.sh +8 -0
  59. package/scripts/hook-adapter-test.sh +193 -0
  60. package/scripts/init-content-test.sh +225 -0
  61. package/scripts/init-guided-test.sh +474 -0
  62. package/scripts/init-recipes-test.sh +104 -0
  63. package/scripts/init-upgrade-test.sh +341 -2
  64. package/scripts/init.sh +746 -95
  65. package/scripts/instruction-budget-baseline.txt +8 -0
  66. package/scripts/instruction-budget-lint-test.sh +166 -0
  67. package/scripts/instruction-budget-lint.sh +219 -0
  68. package/scripts/integrations-check-test.sh +200 -0
  69. package/scripts/integrations-check.sh +157 -0
  70. package/scripts/kit-add-test.sh +214 -0
  71. package/scripts/kit-add.sh +305 -5
  72. package/scripts/kit-adopt-test.sh +16 -0
  73. package/scripts/kit-adopt.sh +3 -2
  74. package/scripts/kit-digest.sh +2 -2
  75. package/scripts/kit-doctor-test.sh +293 -0
  76. package/scripts/kit-doctor.sh +272 -140
  77. package/scripts/kit-export-project-test.sh +3 -3
  78. package/scripts/kit-remove-test.sh +19 -0
  79. package/scripts/kit-routines.sh +2 -2
  80. package/scripts/kit-self-update.sh +1 -1
  81. package/scripts/kit-version-check-test.sh +4 -0
  82. package/scripts/kit-version-check.sh +4 -2
  83. package/scripts/knowledge-lint.sh +4 -4
  84. package/scripts/leak-fence-test.sh +89 -0
  85. package/scripts/lib/adapter-select-test.sh +136 -0
  86. package/scripts/lib/adapter-select.sh +158 -0
  87. package/scripts/lib/agent-def-test.sh +69 -0
  88. package/scripts/lib/agent-def.sh +106 -0
  89. package/scripts/lib/agent-launch-test.sh +212 -0
  90. package/scripts/lib/agent-launch.sh +335 -0
  91. package/scripts/lib/board-view-test.sh +11 -0
  92. package/scripts/lib/board-view.sh +42 -26
  93. package/scripts/lib/branch-owner-test.sh +26 -0
  94. package/scripts/lib/branch-owner.sh +16 -9
  95. package/scripts/lib/captain-test.sh +105 -0
  96. package/scripts/lib/captain.sh +87 -8
  97. package/scripts/lib/codex-hooks-test.sh +100 -0
  98. package/scripts/lib/codex-hooks.sh +69 -0
  99. package/scripts/lib/commitlint.sh +1 -1
  100. package/scripts/lib/content-kinds-gc-test.sh +88 -0
  101. package/scripts/lib/copilot-test.sh +70 -4
  102. package/scripts/lib/copilot.sh +66 -14
  103. package/scripts/lib/effort-dispatch-test.sh +3 -3
  104. package/scripts/lib/effort-metrics-test.sh +178 -1
  105. package/scripts/lib/effort-metrics.sh +188 -35
  106. package/scripts/lib/effort-ops-test.sh +217 -7
  107. package/scripts/lib/effort-ops.sh +281 -49
  108. package/scripts/lib/effort-parity-test.sh +49 -13
  109. package/scripts/lib/effort-plan-test.sh +337 -0
  110. package/scripts/lib/effort-plan.sh +200 -23
  111. package/scripts/lib/effort-slug.sh +16 -2
  112. package/scripts/lib/effort.sh +67 -12
  113. package/scripts/lib/errors-header-test.sh +1 -1
  114. package/scripts/lib/gh-project-test.sh +35 -1
  115. package/scripts/lib/gh-project.sh +37 -16
  116. package/scripts/lib/gh-rest-test.sh +330 -0
  117. package/scripts/lib/gh-rest.sh +304 -0
  118. package/scripts/lib/hook-refresh.sh +1 -1
  119. package/scripts/lib/init-github.sh +412 -0
  120. package/scripts/lib/init-guide.sh +630 -0
  121. package/scripts/lib/integration-install-test.sh +343 -0
  122. package/scripts/lib/integration-install.sh +257 -0
  123. package/scripts/lib/integrations-test.sh +366 -0
  124. package/scripts/lib/integrations.sh +244 -0
  125. package/scripts/lib/kinds-test.sh +125 -0
  126. package/scripts/lib/kinds.sh +66 -0
  127. package/scripts/lib/kit-brief-test.sh +22 -3
  128. package/scripts/lib/kit-brief.sh +45 -5
  129. package/scripts/lib/kit-config-resolve.sh +2 -2
  130. package/scripts/lib/kit-config-test.sh +64 -1
  131. package/scripts/lib/kit-config.sh +37 -1
  132. package/scripts/lib/kit-events.sh +7 -0
  133. package/scripts/lib/kit-gc-test.sh +173 -1
  134. package/scripts/lib/kit-gc.sh +244 -37
  135. package/scripts/lib/kit-hotfix.sh +216 -0
  136. package/scripts/lib/kit-interview-test.sh +93 -0
  137. package/scripts/lib/kit-interview.sh +117 -8
  138. package/scripts/lib/kit-lib-test.sh +1 -1
  139. package/scripts/lib/kit-lib.sh +3 -3
  140. package/scripts/lib/kit-local.sh +2 -2
  141. package/scripts/lib/kit-manifest.sh +33 -1
  142. package/scripts/lib/kit-profile-test.sh +3 -3
  143. package/scripts/lib/kit-status-test.sh +112 -4
  144. package/scripts/lib/kit-status.sh +246 -16
  145. package/scripts/lib/kit-task-ops-test.sh +37 -0
  146. package/scripts/lib/kit-task-ops.sh +362 -89
  147. package/scripts/lib/kto-hotfix-test.sh +232 -0
  148. package/scripts/lib/kto-task-close-test.sh +83 -0
  149. package/scripts/lib/kto-task-new-test.sh +95 -0
  150. package/scripts/lib/kto-task-pr-merge-test.sh +97 -6
  151. package/scripts/lib/kto-task-pr-test.sh +70 -0
  152. package/scripts/lib/leak-fence.sh +89 -0
  153. package/scripts/lib/light-task-run-test.sh +255 -0
  154. package/scripts/lib/light-task-test.sh +309 -0
  155. package/scripts/lib/light-task.sh +706 -0
  156. package/scripts/lib/next-test.sh +99 -0
  157. package/scripts/lib/next.sh +9 -3
  158. package/scripts/lib/orchestration-runtime-test.sh +72 -0
  159. package/scripts/lib/orchestration-runtime.sh +57 -5
  160. package/scripts/lib/plan-machine-test.sh +15 -2
  161. package/scripts/lib/plan-machine.sh +20 -7
  162. package/scripts/lib/plan-next-test.sh +1 -1
  163. package/scripts/lib/plan-next.sh +4 -4
  164. package/scripts/lib/pr-evidence-test.sh +3 -3
  165. package/scripts/lib/pr-evidence.sh +1 -1
  166. package/scripts/lib/qa-lane-test.sh +626 -0
  167. package/scripts/lib/qa-lane.sh +1357 -0
  168. package/scripts/lib/qa-lanes-test.sh +175 -0
  169. package/scripts/lib/react-detect.sh +1 -1
  170. package/scripts/lib/render-test.sh +1 -1
  171. package/scripts/lib/review-page-test.sh +318 -0
  172. package/scripts/lib/review-page.sh +369 -0
  173. package/scripts/lib/review-stage-test.sh +62 -11
  174. package/scripts/lib/review-stage.sh +42 -60
  175. package/scripts/lib/role-identity-test.sh +65 -0
  176. package/scripts/lib/role-identity.sh +25 -2
  177. package/scripts/lib/secret-guard.sh +3 -3
  178. package/scripts/lib/session-registry-test.sh +111 -0
  179. package/scripts/lib/session-registry.sh +233 -0
  180. package/scripts/lib/stage-receipt-test.sh +14 -1
  181. package/scripts/lib/stage-receipt.sh +13 -8
  182. package/scripts/lib/task-source-file.sh +309 -0
  183. package/scripts/lib/task-source.sh +130 -0
  184. package/scripts/lib/test-env-test.sh +3 -3
  185. package/scripts/lib/test-env.sh +7 -4
  186. package/scripts/lib/upgrade-report-test.sh +120 -0
  187. package/scripts/lib/upgrade-report.sh +138 -0
  188. package/scripts/lib/version-bump.sh +3 -3
  189. package/scripts/lib/wave-result-test.sh +80 -0
  190. package/scripts/lib/wave-result.sh +127 -0
  191. package/scripts/lib/worker-brief-test.sh +5 -0
  192. package/scripts/lib/worker-brief.sh +2 -2
  193. package/scripts/lib/worktree-issue-test.sh +30 -1
  194. package/scripts/lib/worktree-issue.sh +93 -9
  195. package/scripts/lib/worktree-ports-test.sh +57 -4
  196. package/scripts/lib/worktree-start-test.sh +197 -0
  197. package/scripts/lib/worktree-start.sh +169 -32
  198. package/scripts/lib/zsh-safety-test.sh +19 -3
  199. package/scripts/marketing-walkthrough-test.sh +152 -0
  200. package/scripts/night-grant-test.sh +37 -0
  201. package/scripts/night-grant.sh +448 -0
  202. package/scripts/night-run-test.sh +8 -0
  203. package/scripts/night-run.mjs +275 -0
  204. package/scripts/night-run.test.mjs +324 -0
  205. package/scripts/orchestrate-test.sh +190 -0
  206. package/scripts/orchestrate.sh +79 -8
  207. package/scripts/portable-test.sh +11 -2
  208. package/scripts/publish.sh +28 -3
  209. package/scripts/review-lint-test.sh +7 -7
  210. package/scripts/review-lint.sh +2 -2
  211. package/scripts/review-rules.conf +8 -0
  212. package/scripts/rule-recipes-test.sh +96 -0
  213. package/scripts/self-install-test.sh +39 -9
  214. package/scripts/setup-labels.sh +18 -1
  215. package/scripts/setup-milestones.sh +1 -1
  216. package/scripts/showcase.sh +1 -1
  217. package/scripts/skill-frontmatter-lint-test.sh +4 -4
  218. package/scripts/skill-frontmatter-lint.sh +1 -1
  219. package/scripts/status-test.sh +113 -2
  220. package/scripts/status.sh +16 -3
  221. package/scripts/task-sync-test.sh +154 -0
  222. package/scripts/task-sync.sh +243 -32
  223. package/scripts/test-runner-test.sh +158 -0
  224. package/scripts/test.sh +131 -23
  225. package/scripts/update-path-test.sh +279 -0
  226. package/scripts/ux-ds-audit.sh +1 -1
  227. package/scripts/ux-graph-scan.sh +6 -6
  228. package/scripts/wave-worker.sh +54 -0
  229. package/skills/kit-add/SKILL.md +77 -0
  230. package/skills/kit-autopilot/SKILL.md +123 -12
  231. package/skills/kit-cleanup/SKILL.md +5 -2
  232. package/skills/kit-contribute/SKILL.md +4 -4
  233. package/skills/kit-docs-writer/SKILL.md +16 -6
  234. package/skills/kit-effort-close/SKILL.md +17 -8
  235. package/skills/kit-effort-new/SKILL.md +15 -9
  236. package/skills/kit-effort-pr/SKILL.md +15 -7
  237. package/skills/kit-effort-start/SKILL.md +5 -2
  238. package/skills/kit-gc/SKILL.md +5 -2
  239. package/skills/kit-next/SKILL.md +5 -1
  240. package/skills/kit-onboard/SKILL.md +3 -3
  241. package/skills/kit-page/SKILL.md +93 -0
  242. package/skills/kit-plan-next/SKILL.md +8 -4
  243. package/skills/kit-security-sweep/SKILL.md +1 -3
  244. package/skills/kit-ship/SKILL.md +2 -3
  245. package/skills/kit-status/SKILL.md +35 -4
  246. package/skills/kit-task-new/SKILL.md +3 -3
  247. package/skills/kit-task-pr/SKILL.md +7 -2
  248. package/skills/kit-task-pr-merge/SKILL.md +7 -2
  249. package/skills/kit-task-start/SKILL.md +7 -7
  250. package/skills/kit-task-sync/SKILL.md +19 -3
  251. package/skills/kit-ux-audit/SKILL.md +3 -2
  252. package/templates/agents/auto-dev.md +5 -4
  253. package/templates/agents/backend.md +1 -1
  254. package/templates/agents/designer.md +2 -0
  255. package/templates/agents/devops.md +1 -1
  256. package/templates/agents/editor.md +9 -1
  257. package/templates/agents/frontend.md +1 -1
  258. package/templates/agents/local-delegate.md +1 -1
  259. package/templates/agents/pm.md +5 -5
  260. package/templates/agents/tech-lead.md +1 -1
  261. package/templates/benchmarks/SCHEMA.md +9 -3
  262. package/templates/codex/hooks.json.tmpl +89 -0
  263. package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
  264. package/templates/hooks/guard-raw-git-ops.sh.tmpl +27 -14
  265. package/templates/hooks/mempal_followup.sh.tmpl +2 -2
  266. package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
  267. package/templates/hooks/prepush_gate.sh.tmpl +4 -2
  268. package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
  269. package/templates/instructions.md.tmpl +174 -0
  270. package/templates/kit.config.json.tmpl +3 -3
  271. package/templates/knowledge-INDEX.md.tmpl +1 -1
  272. package/templates/lib/kit-sigil.sh.tmpl +1 -1
  273. package/templates/rules/authoring.md +106 -0
  274. package/templates/rules/branch-naming.md +40 -4
  275. package/templates/rules/code-retrieval.md +63 -0
  276. package/templates/rules/delegation-brief.md +0 -3
  277. package/templates/rules/design-routing.md +3 -3
  278. package/templates/rules/effort-model.md +14 -10
  279. package/templates/rules/gate-and-review.md +94 -0
  280. package/templates/rules/issue-lifecycle.md +88 -0
  281. package/templates/rules/knowledge-base.md +1 -1
  282. package/templates/rules/mempalace.md +1 -1
  283. package/templates/rules/merge-safety.md +108 -0
  284. package/templates/rules/naming-and-ids.md +23 -17
  285. package/templates/rules/plain-language.md +59 -0
  286. package/templates/rules/plan-next.md +9 -11
  287. package/templates/rules/react-annotate.md +6 -0
  288. package/templates/rules/review-pages.md +49 -0
  289. package/templates/rules/risk-tiered-review.md +13 -4
  290. package/templates/rules/shared-checkout.md +106 -0
  291. package/templates/rules/skill-gaps.md +2 -7
  292. package/templates/rules/task-management.md +13 -1
  293. package/templates/skills/brand-voice/SKILL.md +91 -0
  294. package/templates/skills/brand-voice/references/voice-template.md +61 -0
  295. package/templates/skills/campaign/SKILL.md +123 -0
  296. package/templates/skills/campaign/references/plan-template.md +55 -0
  297. package/templates/skills/concrete/SKILL.md +2 -2
  298. package/templates/skills/copywriting/SKILL.md +8 -1
  299. package/templates/skills/feature-build-refine/SKILL.md +2 -4
  300. package/templates/skills/morning-briefing/SKILL.md +2 -2
  301. package/templates/skills/page-design/SKILL.md +145 -0
  302. package/templates/skills/page-design/add.json +5 -0
  303. package/templates/skills/page-design/references/design-file-template.md +40 -0
  304. package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
  305. package/templates/skills/page-design/references/minimum-rules.md +42 -0
  306. package/templates/skills/speckit/SKILL.md +4 -5
  307. package/templates/skills/supabase-patterns/SKILL.md +1 -1
  308. package/commands/kit-add.md +0 -42
  309. package/templates/CLAUDE.md.tmpl +0 -106
@@ -11,10 +11,28 @@
11
11
  # command render it via AskUserQuestion and pass answers here as a file. This script also takes a
12
12
  # minimal terminal fallback so it stands alone.
13
13
  #
14
+ # INTEGRATIONS (E303.2): the same entry also switches on an optional third-party tool described by
15
+ # integrations/<id>.json. `kit-add.sh` with no name LISTS what can be added. `kit-add.sh <id>` asks
16
+ # the one question kit-interview derives from the descriptor and sets that descriptor's config key
17
+ # in the project config kit_config_path resolves — no other key changes. It installs nothing.
18
+ # A descriptor that lists `rules` (E303.10) also gets each rule template copied into the project's
19
+ # .claude/rules/, and under KIT_DRY_RUN the install + wire plan is printed after the config diff.
20
+ #
21
+ # SKILLS (#504): a skill cckit ships that declares itself addable (templates/skills/<name>/add.json:
22
+ # label, summary and the one config key it switches on) is the third thing `add` accepts.
23
+ # `kit-add.sh page-design` sets that key in the project config and copies the skill's SKILL.md and
24
+ # references/ into the skills folder of each adapter the project selects. It asks nothing, keeps a
25
+ # copy that is already there, and is the way a project already at the installed version gets the
26
+ # skill: `cckit init --upgrade` refuses such a project before it adds anything.
27
+ #
14
28
  # Run:
29
+ # scripts/kit-add.sh # list integrations + modules + skills
30
+ # scripts/kit-add.sh page-design [--dir DIR] # switch a kit skill on and copy it in
31
+ # scripts/kit-add.sh <integration> [--dir DIR] [--set enable=yes|no]
15
32
  # scripts/kit-add.sh software [--dir DIR] --answers FILE # non-interactive (skill/CI/tests)
16
33
  # scripts/kit-add.sh software --set versioning=github --set deploy=vercel --set ci=github-actions
17
34
  # KIT_ASSUME_YES=1 scripts/kit-add.sh software # accept every recommended default
35
+ # scripts/kit-add.sh qa --answers FILE # how this project's review stack boots (#294)
18
36
  # KIT_DRY_RUN=1 scripts/kit-add.sh software # preview only
19
37
  # Requires: jq.
20
38
 
@@ -24,6 +42,10 @@ _add_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
24
42
  . "$_add_dir/lib/kit-interview.sh" # catalog/apply (pulls kit-cli + kit-profile)
25
43
  # shellcheck source=/dev/null
26
44
  . "$_add_dir/lib/kit-operate.sh" # four-beat machine + manifest
45
+ # shellcheck source=/dev/null
46
+ . "$_add_dir/lib/integration-install.sh" # integration_install_plan — the dry-run plan
47
+ # shellcheck source=/dev/null
48
+ command -v adapter_list_from_config >/dev/null 2>&1 || . "$_add_dir/lib/adapter-select.sh" # which skills folders
27
49
 
28
50
  # kit_add_module_exists <module> -> rc 0 if a module spec is installed
29
51
  kit_add_module_exists() { [ -f "$(kit_interview_catalog_file "$1")" ]; }
@@ -41,15 +63,25 @@ kit_add() {
41
63
  target="$(cd "$target" 2>/dev/null && pwd)" || kit_die "no such dir: $target"
42
64
  cd "$target" || kit_die "cannot enter $target"
43
65
 
66
+ # Both supported layouts: a root cckit.config.json (self-host) wins when this island has one,
67
+ # else the scaffolded .claude/kit.config.json. Checked in THIS dir only — never walked upward,
68
+ # so a module still writes into this island and nothing above it.
44
69
  local cfg=".claude/kit.config.json" base merged tmp
70
+ [ -f "cckit.config.json" ] && cfg="cckit.config.json"
45
71
  base=""; [ -f "$cfg" ] && base="$cfg"
46
72
  merged="$(kit_interview_apply "$module" "$answers" "$base")" || kit_die "deriving module config failed"
47
73
  # Belt-and-suspenders: guarantee the module name is in modules[] even if the spec omitted it.
48
74
  merged="$(printf '%s' "$merged" | jq --arg m "$module" '.modules = ((.modules // []) + [$m] | unique)')"
49
75
 
50
76
  kit_say "kit add $module -> $target/$cfg"
51
- printf '%s\n' "$merged" | kit_op_write_content "$cfg" A "add:$module"
77
+ # Through a FILE, not a pipe: kit_op_write asks before overwriting a config it does not track
78
+ # (every `cckit init` config, every self-host one) and reads that yes from stdin. Piping the
79
+ # content in made stdin the already-drained pipe, so the prompt always read EOF and declined.
80
+ tmp="$(mktemp)" || kit_die "mktemp failed"
81
+ printf '%s\n' "$merged" > "$tmp"
82
+ kit_op_write "$tmp" "$cfg" A "add:$module"
52
83
  local rc=$?
84
+ rm -f "$tmp"
53
85
  case $rc in
54
86
  0) kit_say "module '$module' active here. modules: $(printf '%s' "$merged" | jq -c '.modules')";;
55
87
  10) kit_say "no change (already applied / declined / dry-run).";;
@@ -58,6 +90,270 @@ kit_add() {
58
90
  return 0
59
91
  }
60
92
 
93
+ # --- integrations (E303.2) -------------------------------------------------
94
+ # kit_add_kind <name> -> prints `module` or `integration`; rc 1 when it is neither. A module wins
95
+ # a shared name, the same precedence kit_interview_catalog applies.
96
+ kit_add_kind() {
97
+ if kit_add_module_exists "$1"; then printf 'module\n'; return 0; fi
98
+ if integration_file "$1" >/dev/null 2>&1; then printf 'integration\n'; return 0; fi
99
+ if kit_add_skill_file "$1" >/dev/null 2>&1; then printf 'skill\n'; return 0; fi
100
+ return 1
101
+ }
102
+
103
+ # --- addable kit skills (#504) ---------------------------------------------
104
+ # kit_add_skill_file <name> -> the add.json of a kit skill that can be added; rc 1 when the name is
105
+ # not a skill id or the skill ships no add.json. The id grammar is checked first, so `../x` never
106
+ # resolves outside templates/skills/.
107
+ kit_add_skill_file() {
108
+ local f
109
+ grep -qE '^[a-z][a-z0-9]*(-[a-z0-9]+)*$' <<<"${1:-}" || return 1
110
+ f="$(kit_iv_plugin_root)/templates/skills/$1/add.json"
111
+ [ -f "$f" ] && [ -f "$(dirname "$f")/SKILL.md" ] || return 1
112
+ printf '%s\n' "$f"
113
+ }
114
+
115
+ # kit_add_skills_list -> the names of the addable kit skills, sorted.
116
+ kit_add_skills_list() {
117
+ find "$(kit_iv_plugin_root)/templates/skills" -mindepth 2 -maxdepth 2 -type f -name add.json 2>/dev/null \
118
+ | sed -e 's#/add\.json$##' -e 's#.*/##' | sort
119
+ }
120
+
121
+ # kit_add_skill_missing <name> <root> <adapters> -> the adapter skill folders (relative to root)
122
+ # that do not hold the skill, one per line. Empty = installed for every selected adapter.
123
+ kit_add_skill_missing() {
124
+ local name="$1" root="$2" a d
125
+ for a in $(printf '%s\n' "$3"); do # a substitution splits under zsh; a bare $3 does not
126
+ d="$(adapter_dir "$a")" || continue
127
+ [ -f "$root/$d/skills/$name/SKILL.md" ] || printf '%s/skills/%s\n' "$d" "$name"
128
+ done
129
+ }
130
+
131
+ # kit_add_skill <name> [targetdir]
132
+ # Sets the skill's config key in the project config (the same merge an integration gets: every
133
+ # other key is kept) and copies templates/skills/<name>/ — SKILL.md and references/ — into
134
+ # <adapter-dir>/skills/<name>/ for each adapter in the config. A folder that already holds a
135
+ # SKILL.md is kept whole, so a project's edits survive a re-run; a second run changes nothing.
136
+ # KIT_DRY_RUN prints the plan and writes nothing. rc 1: no project config, or a failed copy.
137
+ kit_add_skill() {
138
+ command -v jq >/dev/null 2>&1 || { kit_die "jq required"; }
139
+ local name="$1" target="${2:-$PWD}" f src cfg root rel key on merged tmp verdict adapters rest d ref bad=0
140
+ f="$(kit_add_skill_file "$name")" || kit_die "unknown skill '$name' — run 'cckit add' to list what can be added"
141
+ src="$(dirname "$f")"
142
+ target="$(cd "$target" 2>/dev/null && pwd)" || kit_die "no such dir: $target"
143
+ cfg="$(kit_config_path "$target" 2>/dev/null)" || cfg=""
144
+ [ -n "$cfg" ] && [ -f "$cfg" ] || kit_die "no project config found from $target — run 'cckit init' first"
145
+ key="$(jq -r '.config.key' "$f")"; on="$(jq -c 'if (.config | has("value")) then .config.value else true end' "$f")"
146
+ root="$(_kit_add_root "$cfg")"
147
+ rel="${cfg#"$root"/}"
148
+ merged="$(jq --arg k "$key" --argjson v "$on" 'setpath($k | split("."); $v)' "$cfg")" || kit_die "cannot read $cfg"
149
+
150
+ if [ "$(printf '%s' "$merged" | jq -S .)" = "$(jq -S . "$cfg")" ]; then
151
+ kit_say "kit add $name: $key is already $on in $cfg."
152
+ else
153
+ kit_say "kit add $name -> $cfg"
154
+ tmp="$(mktemp "$cfg.XXXXXX")" || kit_die "cannot write beside $cfg"
155
+ printf '%s\n' "$merged" > "$tmp"
156
+ _kit_op_diff "$tmp" "$cfg"
157
+ if [ -n "${KIT_DRY_RUN:-}" ]; then
158
+ rm -f "$tmp"; kit_say " [dry-run] would write $cfg"
159
+ else
160
+ verdict="$(cd "$root" && kit_manifest_verify "$rel" 2>/dev/null || true)"
161
+ mv "$tmp" "$cfg" || { rm -f "$tmp"; kit_die "failed to write $cfg"; }
162
+ [ "$verdict" = "intact" ] && ( cd "$root" && kit_manifest_record "$rel" A "add:$name" ) >/dev/null 2>&1
163
+ kit_say "$key = $on."
164
+ fi
165
+ fi
166
+
167
+ adapters="$(adapter_list_from_config "$cfg")" || kit_die "the config's 'adapters' value is invalid (expected claude and/or codex)"
168
+ rest="$(kit_add_skill_missing "$name" "$root" "$adapters")"
169
+ if [ -z "$rest" ]; then kit_say "skill $name: already in the project — kept as it is."; return 0; fi
170
+ while IFS= read -r d; do
171
+ [ -n "$d" ] || continue
172
+ if [ -n "${KIT_DRY_RUN:-}" ]; then kit_say " [dry-run] would write $root/$d/"; continue; fi
173
+ if ! mkdir -p "$root/$d" 2>/dev/null || ! cp "$src/SKILL.md" "$root/$d/SKILL.md" 2>/dev/null; then
174
+ kit_warn "kit add $name: cannot write $root/$d/SKILL.md"; bad=1; continue
175
+ fi
176
+ if [ -d "$src/references" ]; then
177
+ mkdir -p "$root/$d/references" 2>/dev/null || bad=1
178
+ # `find`, not a glob: an unmatched glob is an error under zsh.
179
+ find "$src/references" -maxdepth 1 -type f 2>/dev/null | while IFS= read -r ref; do
180
+ cp "$ref" "$root/$d/references/" 2>/dev/null || kit_warn "kit add $name: cannot write $root/$d/references/$(basename "$ref")"
181
+ done
182
+ fi
183
+ kit_say "skill written: $root/$d/"
184
+ done <<EOF
185
+ $rest
186
+ EOF
187
+ [ "$bad" -eq 0 ] || return 1
188
+ [ -n "${KIT_DRY_RUN:-}" ] || kit_say "Reload the agent session so it lists $name, and commit the files above."
189
+ return 0
190
+ }
191
+
192
+ # _kit_add_list_json [dir] -> {integrations:[{id,label,summary,key,enabled,applies}],modules:[{id,label}],
193
+ # skills:[{id,label,summary,key,enabled,installed}]}
194
+ # `enabled` / `applies` are judged against the project at dir. Read-only.
195
+ _kit_add_list_json() {
196
+ local d="${1:-$PWD}" id f cfg en ap rows mods m sks root
197
+ cfg="$(kit_config_path "$d" 2>/dev/null)" || cfg=""
198
+ rows="[]"
199
+ for id in $(integrations_list); do
200
+ f="$(integrations_dir)/$id.json"
201
+ jq -e 'type == "object"' "$f" >/dev/null 2>&1 || continue
202
+ en=false; [ -n "$cfg" ] && integration_enabled "$f" "$cfg" && en=true
203
+ ap=false; integration_applies "$f" "$d" && ap=true
204
+ rows="$(printf '%s' "$rows" | jq -c --slurpfile x "$f" --arg id "$id" --argjson en "$en" --argjson ap "$ap" \
205
+ '. + [{id: $id, label: ($x[0].label // $id), summary: ($x[0].summary // ""), key: ($x[0].config.key // ""), enabled: $en, applies: $ap}]')"
206
+ done
207
+ mods="[]"
208
+ # Ids, not paths, go through the word-split: a plugin root with a space in it stays one path.
209
+ for m in $(find "$(kit_iv_plugin_root)/modules" -maxdepth 1 -type f -name '*.json' 2>/dev/null \
210
+ | sed -e 's#.*/##' -e 's#\.json$##' | sort); do
211
+ f="$(kit_iv_plugin_root)/modules/$m.json"
212
+ jq -e 'type == "object"' "$f" >/dev/null 2>&1 || continue
213
+ mods="$(printf '%s' "$mods" | jq -c --slurpfile x "$f" --arg id "$m" '. + [{id: $id, label: ($x[0].label // $id)}]')"
214
+ done
215
+ # Addable kit skills: `enabled` is the config key, `installed` is the skill folder of every
216
+ # adapter the project selects.
217
+ sks="[]"; root=""; [ -n "$cfg" ] && root="$(_kit_add_root "$cfg")"
218
+ for m in $(kit_add_skills_list); do
219
+ f="$(kit_add_skill_file "$m")" || continue
220
+ en=false; ap=false
221
+ if [ -n "$cfg" ] && [ -f "$cfg" ]; then
222
+ jq -e --slurpfile x "$f" '($x[0].config) as $c
223
+ | (try getpath($c.key | split(".")) catch null) == (if ($c | has("value")) then $c.value else true end)' "$cfg" >/dev/null 2>&1 && en=true
224
+ [ -z "$(kit_add_skill_missing "$m" "$root" "$(adapter_list_from_config "$cfg" 2>/dev/null || echo claude)")" ] && ap=true
225
+ fi
226
+ sks="$(printf '%s' "$sks" | jq -c --slurpfile x "$f" --arg id "$m" --argjson en "$en" --argjson ap "$ap" \
227
+ '. + [{id: $id, label: ($x[0].label // $id), summary: ($x[0].summary // ""), key: ($x[0].config.key // ""), enabled: $en, installed: $ap}]')"
228
+ done
229
+ jq -cn --argjson i "$rows" --argjson m "$mods" --argjson s "$sks" '{integrations: $i, modules: $m, skills: $s}'
230
+ }
231
+
232
+ # kit_add_list [dir] -> what `add` accepts, on stdout. One JSON object when CCKIT_OUTPUT=json
233
+ # (`cckit add --llm`), else a table. An empty registry is a valid answer, not an error.
234
+ kit_add_list() {
235
+ command -v jq >/dev/null 2>&1 || { kit_die "jq required"; }
236
+ local d="${1:-$PWD}" j n
237
+ j="$(_kit_add_list_json "$d")" || return 1
238
+ if [ "${CCKIT_OUTPUT:-human}" = "json" ]; then printf '%s\n' "$j"; return 0; fi
239
+ n="$(printf '%s' "$j" | jq '.integrations | length')"
240
+ if [ "$n" -eq 0 ]; then
241
+ printf 'Integrations: none described yet (%s holds no descriptor).\n' "$(integrations_dir)"
242
+ else
243
+ printf 'Integrations — optional third-party tools (cckit add <name>):\n'
244
+ printf '%s' "$j" | jq -r '.integrations[]
245
+ | " \(.id) \(.label) — \(.summary) [\(if .enabled then "on" else "off" end)\(if .applies then "" else ", does not apply here" end)]"'
246
+ fi
247
+ if [ "$(printf '%s' "$j" | jq '.modules | length')" -gt 0 ]; then
248
+ printf 'Modules (cckit add <name>):\n'
249
+ printf '%s' "$j" | jq -r '.modules[] | " \(.id) \(.label)"'
250
+ fi
251
+ if [ "$(printf '%s' "$j" | jq '.skills | length')" -gt 0 ]; then
252
+ printf 'Skills — shipped with cckit (cckit add <name>):\n'
253
+ printf '%s' "$j" | jq -r '.skills[]
254
+ | " \(.id) \(.summary) [\(if .enabled then "on" else "off" end), \(if .installed then "installed" else "not in this project" end)]"'
255
+ fi
256
+ }
257
+
258
+ # _kit_add_root <config> -> the project root a config file belongs to: the dir holding .claude/
259
+ # for the scaffolded layout, the config's own dir for a root cckit.config.json.
260
+ _kit_add_root() {
261
+ case "$1" in
262
+ */.claude/kit.config.json) dirname "$(dirname "$1")" ;;
263
+ *) dirname "$1" ;;
264
+ esac
265
+ }
266
+
267
+ # _kit_add_rules <descriptor> <project-root> <id>
268
+ # Copies each rule template the descriptor lists (`rules`) into <root>/.claude/rules/. A rule file
269
+ # already there is kept — never overwritten, so a project's edits survive a re-run. Under
270
+ # KIT_DRY_RUN it names the files and writes none. A descriptor with no `rules` does nothing.
271
+ _kit_add_rules() {
272
+ local f="$1" root="$2" id="$3" r src dest
273
+ for r in $(jq -r '.rules // [] | .[]' "$f" 2>/dev/null); do
274
+ src="$(kit_iv_plugin_root)/templates/rules/$r.md"; dest=".claude/rules/$r.md"
275
+ [ -e "$root/$dest" ] && continue
276
+ [ -f "$src" ] || { kit_warn "kit add $id: rule template missing ($src) — rule not written"; continue; }
277
+ if [ -n "${KIT_DRY_RUN:-}" ]; then kit_say " [dry-run] would write $root/$dest"; continue; fi
278
+ if mkdir -p "$root/.claude/rules" 2>/dev/null && cp "$src" "$root/$dest" 2>/dev/null; then
279
+ # Tracked only where a manifest already exists: an add never invents one.
280
+ [ -f "$root/.claude/kit.manifest.json" ] && ( cd "$root" && kit_manifest_record "$dest" A "add:$id" ) >/dev/null 2>&1
281
+ kit_say "rule written: $root/$dest"
282
+ else
283
+ kit_warn "kit add $id: cannot write $root/$dest"
284
+ fi
285
+ done
286
+ return 0
287
+ }
288
+
289
+ # kit_add_integration <id> <answersfile> [targetdir]
290
+ # Sets the descriptor's config key in the project config, and copies the rule templates the
291
+ # descriptor lists (_kit_add_rules); it installs nothing. Refusals, each before
292
+ # any write: an invalid descriptor (rc 1), a repo the tool cannot work on (rc 0 — declined, not an
293
+ # error), no project config (rc 1). The merge keeps every existing key, so the write does not go
294
+ # through kit_op_write's conffiles guard, which exists to stop a WHOLE-FILE replacement of a file
295
+ # the user edited; a manifest entry that was intact is re-recorded so it stays intact.
296
+ kit_add_integration() {
297
+ command -v jq >/dev/null 2>&1 || { kit_die "jq required"; }
298
+ local id="$1" answers="$2" target="${3:-$PWD}"
299
+ local f label cfg root rel merged tmp verdict key exts
300
+ f="$(integration_file "$id")" || kit_die "unknown integration '$id' — run 'cckit add' to list them"
301
+ integration_validate "$f" || kit_die "integration '$id': invalid descriptor ($f) — nothing written"
302
+ [ -f "$answers" ] || kit_die "internal: answers file missing ($answers)"
303
+ target="$(cd "$target" 2>/dev/null && pwd)" || kit_die "no such dir: $target"
304
+ label="$(jq -r '.label' "$f")"; key="$(jq -r '.config.key' "$f")"
305
+
306
+ if ! integration_applies "$f" "$target"; then
307
+ exts="$(integration_applies_needs "$f")"
308
+ kit_say "kit add $id: not offered here — $label needs $exts. That does not hold here. Nothing written."
309
+ return 0
310
+ fi
311
+
312
+ cfg="$(kit_config_path "$target" 2>/dev/null)" || cfg=""
313
+ [ -n "$cfg" ] && [ -f "$cfg" ] || kit_die "no project config found from $target — run 'cckit init' first ($label is switched on by '$key' in that config)"
314
+ merged="$(kit_interview_apply "$id" "$answers" "$cfg")" || kit_die "deriving the config for '$id' failed"
315
+
316
+ if [ "$(printf '%s' "$merged" | jq -S .)" = "$(jq -S . "$cfg")" ]; then
317
+ if integration_enabled "$f" "$cfg"; then
318
+ kit_say "kit add $id: no change — $key already selects $label in $cfg."
319
+ _kit_add_rules "$f" "$(_kit_add_root "$cfg")" "$id"
320
+ [ -n "${KIT_DRY_RUN:-}" ] && integration_install_plan "$f" "$target"
321
+ else kit_say "kit add $id: left off — nothing written."; fi
322
+ return 0
323
+ fi
324
+
325
+ kit_say "kit add $id -> $cfg"
326
+ tmp="$(mktemp "$cfg.XXXXXX")" || kit_die "cannot write beside $cfg"
327
+ printf '%s\n' "$merged" > "$tmp"
328
+ _kit_op_diff "$tmp" "$cfg"
329
+ if [ -n "${KIT_DRY_RUN:-}" ]; then
330
+ rm -f "$tmp"; kit_say " [dry-run] would write $cfg"
331
+ # Declining a default-on integration writes the off value: no rule and no install plan follow.
332
+ if ! printf '%s' "$merged" | jq -e --slurpfile d "$f" '
333
+ ($d[0].config) as $c | (if ($c | has("value")) then $c.value else true end) as $on
334
+ | (try getpath($c.key | split(".")) catch null) == $on' >/dev/null 2>&1; then return 0; fi
335
+ _kit_add_rules "$f" "$(_kit_add_root "$cfg")" "$id"
336
+ # What `cckit doctor` would then install, and the wire command, for this repo. Runs nothing.
337
+ integration_install_plan "$f" "$target"
338
+ return 0
339
+ fi
340
+ # Manifest paths are relative to the project root: the dir holding .claude/, or the config's own.
341
+ root="$(dirname "$cfg")"; rel="$(basename "$cfg")"
342
+ case "$cfg" in */.claude/kit.config.json) root="$(dirname "$root")"; rel=".claude/kit.config.json";; esac
343
+ verdict="$(cd "$root" && kit_manifest_verify "$rel" 2>/dev/null || true)"
344
+ mv "$tmp" "$cfg" || { rm -f "$tmp"; kit_die "failed to write $cfg"; }
345
+ [ "$verdict" = "intact" ] && ( cd "$root" && kit_manifest_record "$rel" A "add:$id" ) >/dev/null 2>&1
346
+ if ! integration_enabled "$f" "$cfg"; then
347
+ # A descriptor that is on by default is the one case where declining writes: the off value.
348
+ kit_say "$label is off: $key = $(jq -c --arg k "$key" 'getpath($k | split("."))' "$cfg"). Turn it back on with 'cckit add $id'."
349
+ return 0
350
+ fi
351
+ kit_say "$label is on: $key = $(jq -c --arg k "$key" 'getpath($k | split("."))' "$cfg"). Nothing was installed."
352
+ _kit_add_rules "$f" "$root" "$id"
353
+ kit_say "$(jq -r '"\(.attribution.notice) Docs: \(.docs)"' "$f")"
354
+ return 0
355
+ }
356
+
61
357
  # --- collect answers from flags / env / minimal terminal fallback ---------
62
358
  # Builds a {key:value} JSON. Precedence: --answers FILE, then --set overrides, then for any unset
63
359
  # question: KIT_ASSUME_YES/non-tty -> default; tty -> ask once with the recommended default.
@@ -102,14 +398,18 @@ if kit_is_main; then
102
398
  --dir) _target="$2"; shift 2;;
103
399
  --answers) _answers="$2"; shift 2;;
104
400
  --set) _sets+=("$2"); shift 2;;
105
- -h|--help) echo "usage: kit-add.sh <module> [--dir DIR] [--answers FILE] [--set k=v ...] (env: KIT_ASSUME_YES, KIT_DRY_RUN)"; exit 0;;
401
+ -h|--help) echo "usage: kit-add.sh [<module|integration|skill>] [--dir DIR] [--answers FILE] [--set k=v ...] (no name lists what can be added; env: KIT_ASSUME_YES, KIT_DRY_RUN)"; exit 0;;
106
402
  -*) kit_die "unknown flag: $1";;
107
403
  *) [ -z "$_module" ] && _module="$1" || kit_die "unexpected arg: $1"; shift;;
108
404
  esac; done
109
- [ -n "$_module" ] || kit_die "usage: kit-add.sh <module> [--dir DIR] [--answers FILE] [--set k=v ...]"
110
- kit_add_module_exists "$_module" || kit_die "unknown module '$_module'"
405
+ # No name = the list. Read-only, rc 0 even when the registry is empty.
406
+ [ -n "$_module" ] || { kit_add_list "$_target"; exit $?; }
407
+ _kind="$(kit_add_kind "$_module")" || kit_die "unknown module or integration '$_module' — run 'cckit add' to list them"
408
+ # A kit skill has no question to ask: it sets one key and copies its files.
409
+ if [ "$_kind" = "skill" ]; then kit_add_skill "$_module" "$_target"; exit $?; fi
111
410
  _af="$(_kit_add_collect "$_module" "$_answers" ${_sets[@]+"${_sets[@]}"})" || kit_die "collecting answers failed"
112
- kit_add "$_module" "$_af" "$_target"; _rc=$?
411
+ if [ "$_kind" = "integration" ]; then kit_add_integration "$_module" "$_af" "$_target"; _rc=$?
412
+ else kit_add "$_module" "$_af" "$_target"; _rc=$?; fi
113
413
  rm -f "$_af"
114
414
  exit $_rc
115
415
  fi
@@ -46,6 +46,22 @@ if [ -n "${KIT_ADOPT_TEST_INNER:-}" ]; then
46
46
  kit_adopt_check >/dev/null 2>&1
47
47
  t "check clean after adopt rc=0" "$?" "0"
48
48
 
49
+ # Codex-only project (E257.3): the adapter's .agents/skills + .agents/rules are kit-shaped, the
50
+ # rest of .agents/ and AGENTS.md are the project's; the manifest lives under .cckit/.
51
+ cx="$(mktemp -d)"; cd "$cx"
52
+ mkdir -p .agents/skills/concrete .agents/rules .cckit
53
+ printf '{"schema":1,"entries":{}}\n' > .cckit/kit.manifest.json
54
+ printf 'skill\n' > .agents/skills/concrete/SKILL.md
55
+ printf 'rule\n' > .agents/rules/branch-naming.md
56
+ printf 'mine\n' > .agents/product-marketing.md
57
+ printf 'mine\n' > AGENTS.md
58
+ t "codex candidates" "$(kit_adopt_candidates | LC_ALL=C sort | tr '\n' ',')" ".agents/rules/branch-naming.md,.agents/skills/concrete/SKILL.md,"
59
+ KIT_ASSUME_YES=1 kit_adopt_all >/dev/null 2>&1
60
+ t "codex skill tracked in .cckit manifest" "$(jq -r '.entries | has(".agents/skills/concrete/SKILL.md")' .cckit/kit.manifest.json)" "true"
61
+ t "codex adopt made no .claude tree" "$([ -e .claude ] && echo yes || echo no)" "no"
62
+ t "user file under .agents NOT tracked" "$(kit_manifest_verify .agents/product-marketing.md)" "untracked"
63
+ cd "$proj"; rm -rf "$cx"
64
+
49
65
  [ "$fail" -eq 0 ] && echo "ALL OK($KIT_ADOPT_TEST_INNER)"
50
66
  exit "$fail"
51
67
  fi
@@ -37,7 +37,8 @@ _kit_adopt_tier() {
37
37
  }
38
38
 
39
39
  # Emit the set of kit-shaped paths that EXIST under the project but are NOT yet in the manifest.
40
- # "kit-shaped" = the directories the kit owns (skills/rules/agents/commands/hooks/lib) + the two
40
+ # "kit-shaped" = the directories the kit owns (skills/rules/agents/commands/hooks/lib, and the Codex
41
+ # adapter's .agents/skills + .agents/rules — never the rest of .agents/ or AGENTS.md) + the two
41
42
  # wired singletons. Never the user's content trees (knowledge/, plans/, drafts/, apps/, src/).
42
43
  # One relpath per line.
43
44
  kit_adopt_candidates() {
@@ -50,7 +51,7 @@ kit_adopt_candidates() {
50
51
  [ "$verdict" = "untracked" ] && printf '%s\n' "$p"
51
52
  done < <(
52
53
  find .claude/skills .claude/rules .claude/agents .claude/commands \
53
- .claude/hooks .claude/lib -type f 2>/dev/null
54
+ .claude/hooks .claude/lib .agents/skills .agents/rules -type f 2>/dev/null
54
55
  )
55
56
  # The two wired singletons, if present.
56
57
  for p in .claude/statusline.sh .claude/settings.json; do
@@ -64,11 +64,11 @@ print(re.sub(r"\s+", " ", " ".join(out)))'
64
64
 
65
65
  if [[ "$INPUT" =~ ^https?://(www\.)?(youtube\.com|youtu\.be)/ ]]; then
66
66
  command -v yt-dlp >/dev/null 2>&1 || { echo "kit-digest: yt-dlp required for YouTube URLs (brew install yt-dlp)" >&2; exit 1; }
67
- TITLE="$(yt-dlp --skip-download --print '%(title)s' "$INPUT" 2>/dev/null | head -1 || true)"
67
+ TITLE="$(yt-dlp --skip-download --print '%(title)s' "$INPUT" 2>/dev/null | sed -n 1p || true)"
68
68
  SOURCE_DESC="${TITLE:-$INPUT} ($INPUT)"
69
69
  yt-dlp --skip-download --write-auto-subs --write-subs --sub-langs "en.*,es.*" --sub-format vtt \
70
70
  -o "$WORK/yt" "$INPUT" >/dev/null 2>&1 || true
71
- VTT="$(ls "$WORK"/yt*.vtt 2>/dev/null | head -1 || true)"
71
+ VTT="$(ls "$WORK"/yt*.vtt 2>/dev/null | sed -n 1p || true)"
72
72
  [[ -z "$VTT" ]] && { echo "kit-digest: no subtitles found for $INPUT" >&2; exit 1; }
73
73
  vtt_to_text < "$VTT" > "$TEXT"
74
74
  elif [[ "$INPUT" =~ ^https?:// ]]; then