@kb-labs/devkit 1.0.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 (295) hide show
  1. package/.cursorrules +32 -0
  2. package/.github/CODEOWNERS +2 -0
  3. package/.github/actions/setup-node-pnpm/action.yml +47 -0
  4. package/.github/workflow-templates/ci.yml +13 -0
  5. package/.github/workflow-templates/drift-check.yml +10 -0
  6. package/.github/workflow-templates/profiles-validate.yml +16 -0
  7. package/.github/workflow-templates/release.yml +8 -0
  8. package/.github/workflows/ci-reusable.yml +131 -0
  9. package/.github/workflows/drift-check-reusable.yml +23 -0
  10. package/.github/workflows/fixtures.yml +74 -0
  11. package/.github/workflows/profiles-validate-reusable.yml +67 -0
  12. package/.github/workflows/release-reusable.yml +50 -0
  13. package/.vscode/settings.json +23 -0
  14. package/AGENTS.md +130 -0
  15. package/LICENSE +21 -0
  16. package/README.md +1542 -0
  17. package/agents/devkit-maintainer/context.globs +15 -0
  18. package/agents/devkit-maintainer/permissions.yml +17 -0
  19. package/agents/devkit-maintainer/prompt.md +28 -0
  20. package/agents/devkit-maintainer/runbook.md +31 -0
  21. package/agents/docs-crafter/prompt.md +24 -0
  22. package/agents/docs-crafter/runbook.md +18 -0
  23. package/agents/release-manager/context.globs +7 -0
  24. package/agents/release-manager/prompt.md +27 -0
  25. package/agents/release-manager/runbook.md +17 -0
  26. package/agents/test-generator/context.globs +7 -0
  27. package/agents/test-generator/prompt.md +27 -0
  28. package/agents/test-generator/runbook.md +18 -0
  29. package/bin/devkit-architecture.mjs +1225 -0
  30. package/bin/devkit-build-order.mjs +500 -0
  31. package/bin/devkit-check-build-readiness.mjs +222 -0
  32. package/bin/devkit-check-commands.mjs +394 -0
  33. package/bin/devkit-check-configs.mjs +461 -0
  34. package/bin/devkit-check-deprecated.mjs +532 -0
  35. package/bin/devkit-check-duplicates.mjs +431 -0
  36. package/bin/devkit-check-exports.mjs +561 -0
  37. package/bin/devkit-check-imports.mjs +712 -0
  38. package/bin/devkit-check-paths.mjs +670 -0
  39. package/bin/devkit-check-scripts.mjs +335 -0
  40. package/bin/devkit-check-structure.mjs +495 -0
  41. package/bin/devkit-check-types.mjs +450 -0
  42. package/bin/devkit-ci.mjs +261 -0
  43. package/bin/devkit-core-gate.mjs +225 -0
  44. package/bin/devkit-fix-deps.mjs +1169 -0
  45. package/bin/devkit-freshness.mjs +199 -0
  46. package/bin/devkit-health.mjs +489 -0
  47. package/bin/devkit-migrate-configs.mjs +370 -0
  48. package/bin/devkit-paths.mjs +192 -0
  49. package/bin/devkit-stats.mjs +453 -0
  50. package/bin/devkit-sync.mjs +12 -0
  51. package/bin/devkit-tsup-external.mjs +148 -0
  52. package/bin/devkit-types-audit.mjs +615 -0
  53. package/bin/devkit-types-order.mjs +637 -0
  54. package/bin/devkit-validate-naming.mjs +203 -0
  55. package/bin/devkit-visualize.mjs +452 -0
  56. package/bin/kb-devkit-qa-history.mjs +453 -0
  57. package/bin/kb-devkit-qa.mjs +915 -0
  58. package/eslint/node.js +134 -0
  59. package/eslint/react.js +260 -0
  60. package/package.json +186 -0
  61. package/prettier/index.json +10 -0
  62. package/sync/index.mjs +693 -0
  63. package/templates/configs/README.md +306 -0
  64. package/templates/configs/eslint.config.js +27 -0
  65. package/templates/configs/package.json.bin +25 -0
  66. package/templates/configs/package.json.lib +30 -0
  67. package/templates/configs/tsconfig.build.json +15 -0
  68. package/templates/configs/tsconfig.json +9 -0
  69. package/templates/configs/tsup.config.bin.ts +34 -0
  70. package/templates/configs/tsup.config.cli.ts +41 -0
  71. package/templates/configs/tsup.config.dual.ts +46 -0
  72. package/templates/configs/tsup.config.ts +36 -0
  73. package/templates/package-json/README.md +290 -0
  74. package/templates/package-json/package.json.bin.template +40 -0
  75. package/templates/package-json/package.json.template +45 -0
  76. package/tsconfig/base.json +21 -0
  77. package/tsconfig/cli.json +12 -0
  78. package/tsconfig/dist/__tests__/cache.spec.d.ts +6 -0
  79. package/tsconfig/dist/__tests__/cache.spec.d.ts.map +1 -0
  80. package/tsconfig/dist/__tests__/cache.spec.js +85 -0
  81. package/tsconfig/dist/__tests__/cache.spec.js.map +1 -0
  82. package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts +6 -0
  83. package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts.map +1 -0
  84. package/tsconfig/dist/__tests__/fs-atomic.spec.js +153 -0
  85. package/tsconfig/dist/__tests__/fs-atomic.spec.js.map +1 -0
  86. package/tsconfig/dist/__tests__/init-workspace.spec.d.ts +6 -0
  87. package/tsconfig/dist/__tests__/init-workspace.spec.d.ts.map +1 -0
  88. package/tsconfig/dist/__tests__/init-workspace.spec.js +99 -0
  89. package/tsconfig/dist/__tests__/init-workspace.spec.js.map +1 -0
  90. package/tsconfig/dist/__tests__/kb-error.spec.d.ts +6 -0
  91. package/tsconfig/dist/__tests__/kb-error.spec.d.ts.map +1 -0
  92. package/tsconfig/dist/__tests__/kb-error.spec.js +190 -0
  93. package/tsconfig/dist/__tests__/kb-error.spec.js.map +1 -0
  94. package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts +6 -0
  95. package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts.map +1 -0
  96. package/tsconfig/dist/__tests__/preset-lockfile.spec.js +142 -0
  97. package/tsconfig/dist/__tests__/preset-lockfile.spec.js.map +1 -0
  98. package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts +6 -0
  99. package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts.map +1 -0
  100. package/tsconfig/dist/__tests__/product-config-profiles.spec.js +100 -0
  101. package/tsconfig/dist/__tests__/product-config-profiles.spec.js.map +1 -0
  102. package/tsconfig/dist/__tests__/product-config.spec.d.ts +6 -0
  103. package/tsconfig/dist/__tests__/product-config.spec.d.ts.map +1 -0
  104. package/tsconfig/dist/__tests__/product-config.spec.js +298 -0
  105. package/tsconfig/dist/__tests__/product-config.spec.js.map +1 -0
  106. package/tsconfig/dist/__tests__/runtime.spec.d.ts +2 -0
  107. package/tsconfig/dist/__tests__/runtime.spec.d.ts.map +1 -0
  108. package/tsconfig/dist/__tests__/runtime.spec.js +127 -0
  109. package/tsconfig/dist/__tests__/runtime.spec.js.map +1 -0
  110. package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts +6 -0
  111. package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts.map +1 -0
  112. package/tsconfig/dist/__tests__/upsert-lockfile.spec.js +251 -0
  113. package/tsconfig/dist/__tests__/upsert-lockfile.spec.js.map +1 -0
  114. package/tsconfig/dist/__tests__/validate-config.spec.d.ts +2 -0
  115. package/tsconfig/dist/__tests__/validate-config.spec.d.ts.map +1 -0
  116. package/tsconfig/dist/__tests__/validate-config.spec.js +14 -0
  117. package/tsconfig/dist/__tests__/validate-config.spec.js.map +1 -0
  118. package/tsconfig/dist/api/init-workspace.d.ts +10 -0
  119. package/tsconfig/dist/api/init-workspace.d.ts.map +1 -0
  120. package/tsconfig/dist/api/init-workspace.js +191 -0
  121. package/tsconfig/dist/api/init-workspace.js.map +1 -0
  122. package/tsconfig/dist/api/product-config.d.ts +21 -0
  123. package/tsconfig/dist/api/product-config.d.ts.map +1 -0
  124. package/tsconfig/dist/api/product-config.js +192 -0
  125. package/tsconfig/dist/api/product-config.js.map +1 -0
  126. package/tsconfig/dist/api/read-config.d.ts +22 -0
  127. package/tsconfig/dist/api/read-config.d.ts.map +1 -0
  128. package/tsconfig/dist/api/read-config.js +105 -0
  129. package/tsconfig/dist/api/read-config.js.map +1 -0
  130. package/tsconfig/dist/api/upsert-lockfile.d.ts +10 -0
  131. package/tsconfig/dist/api/upsert-lockfile.d.ts.map +1 -0
  132. package/tsconfig/dist/api/upsert-lockfile.js +63 -0
  133. package/tsconfig/dist/api/upsert-lockfile.js.map +1 -0
  134. package/tsconfig/dist/cache/fs-cache.d.ts +38 -0
  135. package/tsconfig/dist/cache/fs-cache.d.ts.map +1 -0
  136. package/tsconfig/dist/cache/fs-cache.js +142 -0
  137. package/tsconfig/dist/cache/fs-cache.js.map +1 -0
  138. package/tsconfig/dist/errors/kb-error.d.ts +32 -0
  139. package/tsconfig/dist/errors/kb-error.d.ts.map +1 -0
  140. package/tsconfig/dist/errors/kb-error.js +54 -0
  141. package/tsconfig/dist/errors/kb-error.js.map +1 -0
  142. package/tsconfig/dist/fs/__tests__/fs.spec.d.ts +2 -0
  143. package/tsconfig/dist/fs/__tests__/fs.spec.d.ts.map +1 -0
  144. package/tsconfig/dist/fs/__tests__/fs.spec.js +22 -0
  145. package/tsconfig/dist/fs/__tests__/fs.spec.js.map +1 -0
  146. package/tsconfig/dist/fs/fs.d.ts +6 -0
  147. package/tsconfig/dist/fs/fs.d.ts.map +1 -0
  148. package/tsconfig/dist/fs/fs.js +12 -0
  149. package/tsconfig/dist/fs/fs.js.map +1 -0
  150. package/tsconfig/dist/fs/index.d.ts +2 -0
  151. package/tsconfig/dist/fs/index.d.ts.map +1 -0
  152. package/tsconfig/dist/fs/index.js +2 -0
  153. package/tsconfig/dist/fs/index.js.map +1 -0
  154. package/tsconfig/dist/hash/config-hash.d.ts +17 -0
  155. package/tsconfig/dist/hash/config-hash.d.ts.map +1 -0
  156. package/tsconfig/dist/hash/config-hash.js +55 -0
  157. package/tsconfig/dist/hash/config-hash.js.map +1 -0
  158. package/tsconfig/dist/index.d.ts +5 -0
  159. package/tsconfig/dist/index.d.ts.map +1 -0
  160. package/tsconfig/dist/index.js +5 -0
  161. package/tsconfig/dist/index.js.map +1 -0
  162. package/tsconfig/dist/lockfile/lockfile.d.ts +54 -0
  163. package/tsconfig/dist/lockfile/lockfile.d.ts.map +1 -0
  164. package/tsconfig/dist/lockfile/lockfile.js +141 -0
  165. package/tsconfig/dist/lockfile/lockfile.js.map +1 -0
  166. package/tsconfig/dist/logging/__tests__/logger.spec.d.ts +2 -0
  167. package/tsconfig/dist/logging/__tests__/logger.spec.d.ts.map +1 -0
  168. package/tsconfig/dist/logging/__tests__/logger.spec.js +65 -0
  169. package/tsconfig/dist/logging/__tests__/logger.spec.js.map +1 -0
  170. package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts +2 -0
  171. package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts.map +1 -0
  172. package/tsconfig/dist/logging/__tests__/redaction.spec.js +34 -0
  173. package/tsconfig/dist/logging/__tests__/redaction.spec.js.map +1 -0
  174. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts +2 -0
  175. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts.map +1 -0
  176. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js +90 -0
  177. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js.map +1 -0
  178. package/tsconfig/dist/logging/index.d.ts +6 -0
  179. package/tsconfig/dist/logging/index.d.ts.map +1 -0
  180. package/tsconfig/dist/logging/index.js +6 -0
  181. package/tsconfig/dist/logging/index.js.map +1 -0
  182. package/tsconfig/dist/logging/logger.d.ts +9 -0
  183. package/tsconfig/dist/logging/logger.d.ts.map +1 -0
  184. package/tsconfig/dist/logging/logger.js +101 -0
  185. package/tsconfig/dist/logging/logger.js.map +1 -0
  186. package/tsconfig/dist/logging/redaction.d.ts +7 -0
  187. package/tsconfig/dist/logging/redaction.d.ts.map +1 -0
  188. package/tsconfig/dist/logging/redaction.js +23 -0
  189. package/tsconfig/dist/logging/redaction.js.map +1 -0
  190. package/tsconfig/dist/logging/sinks/json.d.ts +4 -0
  191. package/tsconfig/dist/logging/sinks/json.d.ts.map +1 -0
  192. package/tsconfig/dist/logging/sinks/json.js +23 -0
  193. package/tsconfig/dist/logging/sinks/json.js.map +1 -0
  194. package/tsconfig/dist/logging/sinks/stdout.d.ts +3 -0
  195. package/tsconfig/dist/logging/sinks/stdout.d.ts.map +1 -0
  196. package/tsconfig/dist/logging/sinks/stdout.js +24 -0
  197. package/tsconfig/dist/logging/sinks/stdout.js.map +1 -0
  198. package/tsconfig/dist/logging/types/index.d.ts +2 -0
  199. package/tsconfig/dist/logging/types/index.d.ts.map +1 -0
  200. package/tsconfig/dist/logging/types/index.js +2 -0
  201. package/tsconfig/dist/logging/types/index.js.map +1 -0
  202. package/tsconfig/dist/logging/types/types.d.ts +37 -0
  203. package/tsconfig/dist/logging/types/types.d.ts.map +1 -0
  204. package/tsconfig/dist/logging/types/types.js +2 -0
  205. package/tsconfig/dist/logging/types/types.js.map +1 -0
  206. package/tsconfig/dist/merge/layered-merge.d.ts +16 -0
  207. package/tsconfig/dist/merge/layered-merge.d.ts.map +1 -0
  208. package/tsconfig/dist/merge/layered-merge.js +97 -0
  209. package/tsconfig/dist/merge/layered-merge.js.map +1 -0
  210. package/tsconfig/dist/preset/resolve-preset.d.ts +29 -0
  211. package/tsconfig/dist/preset/resolve-preset.d.ts.map +1 -0
  212. package/tsconfig/dist/preset/resolve-preset.js +104 -0
  213. package/tsconfig/dist/preset/resolve-preset.js.map +1 -0
  214. package/tsconfig/dist/repo/__tests__/repo.spec.d.ts +2 -0
  215. package/tsconfig/dist/repo/__tests__/repo.spec.d.ts.map +1 -0
  216. package/tsconfig/dist/repo/__tests__/repo.spec.js +25 -0
  217. package/tsconfig/dist/repo/__tests__/repo.spec.js.map +1 -0
  218. package/tsconfig/dist/repo/index.d.ts +2 -0
  219. package/tsconfig/dist/repo/index.d.ts.map +1 -0
  220. package/tsconfig/dist/repo/index.js +2 -0
  221. package/tsconfig/dist/repo/index.js.map +1 -0
  222. package/tsconfig/dist/repo/repo.d.ts +6 -0
  223. package/tsconfig/dist/repo/repo.d.ts.map +1 -0
  224. package/tsconfig/dist/repo/repo.js +25 -0
  225. package/tsconfig/dist/repo/repo.js.map +1 -0
  226. package/tsconfig/dist/runtime/index.d.ts +2 -0
  227. package/tsconfig/dist/runtime/index.d.ts.map +1 -0
  228. package/tsconfig/dist/runtime/index.js +2 -0
  229. package/tsconfig/dist/runtime/index.js.map +1 -0
  230. package/tsconfig/dist/runtime/runtime.d.ts +46 -0
  231. package/tsconfig/dist/runtime/runtime.d.ts.map +1 -0
  232. package/tsconfig/dist/runtime/runtime.js +126 -0
  233. package/tsconfig/dist/runtime/runtime.js.map +1 -0
  234. package/tsconfig/dist/tsconfig.tools.tsbuildinfo +1 -0
  235. package/tsconfig/dist/tsconfig.tsbuildinfo +1 -0
  236. package/tsconfig/dist/types/index.d.ts +2 -0
  237. package/tsconfig/dist/types/index.d.ts.map +1 -0
  238. package/tsconfig/dist/types/index.js +2 -0
  239. package/tsconfig/dist/types/index.js.map +1 -0
  240. package/tsconfig/dist/types/init.d.ts +34 -0
  241. package/tsconfig/dist/types/init.d.ts.map +1 -0
  242. package/tsconfig/dist/types/init.js +6 -0
  243. package/tsconfig/dist/types/init.js.map +1 -0
  244. package/tsconfig/dist/types/preset.d.ts +27 -0
  245. package/tsconfig/dist/types/preset.d.ts.map +1 -0
  246. package/tsconfig/dist/types/preset.js +6 -0
  247. package/tsconfig/dist/types/preset.js.map +1 -0
  248. package/tsconfig/dist/types/types.d.ts +6 -0
  249. package/tsconfig/dist/types/types.d.ts.map +1 -0
  250. package/tsconfig/dist/types/types.js +2 -0
  251. package/tsconfig/dist/types/types.js.map +1 -0
  252. package/tsconfig/dist/utils/__tests__/env.spec.d.ts +2 -0
  253. package/tsconfig/dist/utils/__tests__/env.spec.d.ts.map +1 -0
  254. package/tsconfig/dist/utils/__tests__/env.spec.js +33 -0
  255. package/tsconfig/dist/utils/__tests__/env.spec.js.map +1 -0
  256. package/tsconfig/dist/utils/env.d.ts +7 -0
  257. package/tsconfig/dist/utils/env.d.ts.map +1 -0
  258. package/tsconfig/dist/utils/env.js +25 -0
  259. package/tsconfig/dist/utils/env.js.map +1 -0
  260. package/tsconfig/dist/utils/fs-atomic.d.ts +15 -0
  261. package/tsconfig/dist/utils/fs-atomic.d.ts.map +1 -0
  262. package/tsconfig/dist/utils/fs-atomic.js +45 -0
  263. package/tsconfig/dist/utils/fs-atomic.js.map +1 -0
  264. package/tsconfig/dist/utils/index.d.ts +3 -0
  265. package/tsconfig/dist/utils/index.d.ts.map +1 -0
  266. package/tsconfig/dist/utils/index.js +3 -0
  267. package/tsconfig/dist/utils/index.js.map +1 -0
  268. package/tsconfig/dist/utils/paths.d.ts +21 -0
  269. package/tsconfig/dist/utils/paths.d.ts.map +1 -0
  270. package/tsconfig/dist/utils/paths.js +32 -0
  271. package/tsconfig/dist/utils/paths.js.map +1 -0
  272. package/tsconfig/dist/utils/product-normalize.d.ts +27 -0
  273. package/tsconfig/dist/utils/product-normalize.d.ts.map +1 -0
  274. package/tsconfig/dist/utils/product-normalize.js +45 -0
  275. package/tsconfig/dist/utils/product-normalize.js.map +1 -0
  276. package/tsconfig/dist/validation/validate-config.d.ts +7 -0
  277. package/tsconfig/dist/validation/validate-config.d.ts.map +1 -0
  278. package/tsconfig/dist/validation/validate-config.js +22 -0
  279. package/tsconfig/dist/validation/validate-config.js.map +1 -0
  280. package/tsconfig/lib.json +13 -0
  281. package/tsconfig/node.json +12 -0
  282. package/tsconfig/react-app.json +8 -0
  283. package/tsconfig/react-lib.json +8 -0
  284. package/tsconfig/test.json +15 -0
  285. package/tsup/bin.js +172 -0
  286. package/tsup/dual.js +155 -0
  287. package/tsup/external-sync.mjs +41 -0
  288. package/tsup/external.mjs +109 -0
  289. package/tsup/node.js +65 -0
  290. package/tsup/react-lib.js +18 -0
  291. package/tsup/sdk.js +118 -0
  292. package/vite/react-app.js +50 -0
  293. package/vitest/node.js +37 -0
  294. package/vitest/react.js +39 -0
  295. package/vitest/vitest-setup.ts +9 -0
@@ -0,0 +1,306 @@
1
+ # Standard Configuration Templates
2
+
3
+ This directory contains canonical configuration templates for all `@kb-labs` packages.
4
+
5
+ ## 📋 Available Templates
6
+
7
+ ### Core Configs (All Packages)
8
+
9
+ | File | Purpose | Required | Customizable |
10
+ |------|---------|----------|--------------|
11
+ | **eslint.config.js** | Linting rules | ✅ Yes | ⚠️ Minimal |
12
+ | **tsconfig.json** | TypeScript IDE config | ✅ Yes | ❌ No |
13
+ | **tsconfig.build.json** | TypeScript build config | ✅ Yes | ❌ No |
14
+
15
+ ### Tsup Configs (Choose ONE based on package type)
16
+
17
+ | Template | Package Type | Use Cases |
18
+ |----------|--------------|-----------|
19
+ | **tsup.config.ts** | 📦 **Library** (default) | Most packages, importable libraries |
20
+ | **tsup.config.bin.ts** | 🔧 **Binary** | Standalone executables, CLI bins |
21
+ | **tsup.config.cli.ts** | ⌨️ **CLI** | CLI packages with commands |
22
+ | **tsup.config.dual.ts** | 📦🔧 **Library + Binary** | Packages with both API and bin |
23
+
24
+ ### Package.json Examples
25
+
26
+ | Template | Purpose |
27
+ |----------|---------|
28
+ | **package.json.lib** | Library package example |
29
+ | **package.json.bin** | Binary package example |
30
+
31
+ ## 🎯 Philosophy
32
+
33
+ **Convention over Configuration**
34
+
35
+ All `@kb-labs` packages MUST use these exact templates with minimal customization. This ensures:
36
+
37
+ - ✅ Consistent build output across all packages
38
+ - ✅ Predictable dependency resolution
39
+ - ✅ Unified linting standards
40
+ - ✅ Easy maintenance and upgrades
41
+
42
+ ## 📦 Usage
43
+
44
+ ### For New Packages
45
+
46
+ #### Step 1: Choose Package Type
47
+
48
+ **Library Package** (most common):
49
+ ```bash
50
+ cp kb-labs-devkit/templates/configs/tsup.config.ts your-package/
51
+ cp kb-labs-devkit/templates/configs/eslint.config.js your-package/
52
+ cp kb-labs-devkit/templates/configs/tsconfig*.json your-package/
53
+ cp kb-labs-devkit/templates/configs/package.json.lib your-package/package.json
54
+ ```
55
+
56
+ **Binary Package** (standalone executables):
57
+ ```bash
58
+ cp kb-labs-devkit/templates/configs/tsup.config.bin.ts your-package/tsup.config.ts
59
+ cp kb-labs-devkit/templates/configs/eslint.config.js your-package/
60
+ cp kb-labs-devkit/templates/configs/tsconfig*.json your-package/
61
+ cp kb-labs-devkit/templates/configs/package.json.bin your-package/package.json
62
+ ```
63
+
64
+ **CLI Package** (command handlers):
65
+ ```bash
66
+ cp kb-labs-devkit/templates/configs/tsup.config.cli.ts your-package/tsup.config.ts
67
+ cp kb-labs-devkit/templates/configs/eslint.config.js your-package/
68
+ cp kb-labs-devkit/templates/configs/tsconfig*.json your-package/
69
+ cp kb-labs-devkit/templates/configs/package.json.lib your-package/package.json
70
+ ```
71
+
72
+ **Dual Package** (library + binary):
73
+ ```bash
74
+ cp kb-labs-devkit/templates/configs/tsup.config.dual.ts your-package/tsup.config.ts
75
+ cp kb-labs-devkit/templates/configs/eslint.config.js your-package/
76
+ cp kb-labs-devkit/templates/configs/tsconfig*.json your-package/
77
+ cp kb-labs-devkit/templates/configs/package.json.lib your-package/package.json
78
+ # Then add "bin" field to package.json
79
+ ```
80
+
81
+ #### Step 2: Customize Package Name
82
+ ```bash
83
+ # Edit package.json and update name, description
84
+ ```
85
+
86
+ ### For Existing Packages
87
+
88
+ ```bash
89
+ # Check for drift
90
+ npx kb-devkit-check-configs
91
+
92
+ # Auto-fix drift
93
+ npx kb-devkit-check-configs --fix
94
+ ```
95
+
96
+ ## 🔧 Customization Rules
97
+
98
+ ### tsup.config.ts
99
+
100
+ **Allowed customizations:**
101
+
102
+ ```typescript
103
+ export default defineConfig({
104
+ ...nodePreset,
105
+ tsconfig: 'tsconfig.build.json', // ✅ Always required
106
+
107
+ // ✅ OK: Multiple entry points
108
+ entry: ['src/index.ts', 'src/cli.ts'],
109
+
110
+ // ✅ OK: Extra external deps (if really needed)
111
+ external: ['special-native-module'],
112
+
113
+ dts: true, // ✅ Always required
114
+ });
115
+ ```
116
+
117
+ **NOT allowed:**
118
+
119
+ ```typescript
120
+ // ❌ WRONG: Don't override preset settings
121
+ export default defineConfig({
122
+ format: ['esm'], // Already in preset!
123
+ target: 'es2022', // Already in preset!
124
+ sourcemap: true, // Already in preset!
125
+ // ...
126
+ });
127
+
128
+ // ❌ WRONG: Don't disable types
129
+ dts: false,
130
+
131
+ // ❌ WRONG: Don't duplicate external deps
132
+ external: [
133
+ '@kb-labs/core', // Already in preset!
134
+ '@kb-labs/cli', // Already in preset!
135
+ ],
136
+ ```
137
+
138
+ ### eslint.config.js
139
+
140
+ **Allowed customizations:**
141
+
142
+ ```javascript
143
+ export default [
144
+ ...nodePreset,
145
+ {
146
+ // ✅ OK: Project-specific ignores only
147
+ ignores: ['**/*.generated.ts']
148
+ }
149
+ ];
150
+ ```
151
+
152
+ **NOT allowed:**
153
+
154
+ ```javascript
155
+ // ❌ WRONG: Don't duplicate preset ignores
156
+ export default [
157
+ ...nodePreset,
158
+ {
159
+ ignores: [
160
+ '**/dist/**', // Already in preset!
161
+ '**/node_modules/**', // Already in preset!
162
+ ]
163
+ }
164
+ ];
165
+ ```
166
+
167
+ ### tsconfig.json & tsconfig.build.json
168
+
169
+ **NOT customizable!**
170
+
171
+ These files MUST remain identical to templates. All TypeScript configuration is standardized in DevKit presets.
172
+
173
+ ```json
174
+ // ❌ WRONG: Don't override extends
175
+ {
176
+ "extends": "./my-custom-base.json"
177
+ }
178
+
179
+ // ❌ WRONG: Don't add compilerOptions
180
+ {
181
+ "extends": "@kb-labs/devkit/tsconfig/node.json",
182
+ "compilerOptions": {
183
+ "strict": false // Don't override preset!
184
+ }
185
+ }
186
+ ```
187
+
188
+ ## 🔍 Drift Detection
189
+
190
+ DevKit automatically detects configuration drift:
191
+
192
+ ```bash
193
+ # Check all packages
194
+ npx kb-devkit-check-configs
195
+
196
+ # Check specific package
197
+ npx kb-devkit-check-configs --package=@kb-labs/core
198
+
199
+ # Auto-fix (creates backup)
200
+ npx kb-devkit-check-configs --fix
201
+
202
+ # CI mode (fail on drift)
203
+ npx kb-devkit-check-configs --ci
204
+ ```
205
+
206
+ ### Drift Detection Rules
207
+
208
+ | Issue | Severity | Auto-fix |
209
+ |-------|----------|----------|
210
+ | Missing `dts: true` | 🔴 Error | ✅ Yes |
211
+ | Using `dts: false` | 🔴 Error | ✅ Yes |
212
+ | Not using `nodePreset` | 🔴 Error | ⚠️ Manual |
213
+ | Duplicate `external` | 🟡 Warning | ✅ Yes |
214
+ | Duplicate `ignores` | 🟡 Warning | ✅ Yes |
215
+ | Missing templates | 🔴 Error | ✅ Yes |
216
+ | Modified templates | 🔴 Error | ⚠️ Manual |
217
+
218
+ ## 📚 Examples
219
+
220
+ ### ✅ Good Example (Minimal Package)
221
+
222
+ ```typescript
223
+ // tsup.config.ts
224
+ import { defineConfig } from 'tsup';
225
+ import nodePreset from '@kb-labs/devkit/tsup/node.js';
226
+
227
+ export default defineConfig({
228
+ ...nodePreset,
229
+ tsconfig: 'tsconfig.build.json',
230
+ entry: ['src/index.ts'],
231
+ dts: true,
232
+ });
233
+ ```
234
+
235
+ ### ✅ Good Example (CLI Package with Multiple Entries)
236
+
237
+ ```typescript
238
+ // tsup.config.ts
239
+ import { defineConfig } from 'tsup';
240
+ import nodePreset from '@kb-labs/devkit/tsup/node.js';
241
+
242
+ export default defineConfig({
243
+ ...nodePreset,
244
+ tsconfig: 'tsconfig.build.json',
245
+ entry: [
246
+ 'src/index.ts',
247
+ 'src/cli/index.ts',
248
+ 'src/cli/commands/build.ts',
249
+ 'src/cli/commands/test.ts',
250
+ ],
251
+ dts: true,
252
+ });
253
+ ```
254
+
255
+ ### ❌ Bad Example (Over-configured)
256
+
257
+ ```typescript
258
+ // tsup.config.ts
259
+ import { defineConfig } from 'tsup';
260
+
261
+ // ❌ Not using preset!
262
+ export default defineConfig({
263
+ format: ['esm'],
264
+ target: 'es2022',
265
+ sourcemap: true,
266
+ clean: true,
267
+ dts: true,
268
+ entry: ['src/index.ts'],
269
+ external: [/^@kb-labs\/.*/], // Manual external
270
+ });
271
+ ```
272
+
273
+ ## 🚀 Migration Guide
274
+
275
+ ### From Custom Config to Standard Template
276
+
277
+ 1. **Backup your current config**
278
+ ```bash
279
+ cp tsup.config.ts tsup.config.ts.backup
280
+ ```
281
+
282
+ 2. **Copy standard template**
283
+ ```bash
284
+ cp kb-labs-devkit/templates/configs/tsup.config.ts .
285
+ ```
286
+
287
+ 3. **Migrate customizations** (only if needed)
288
+ - Compare your backup with template
289
+ - Extract only truly necessary customizations
290
+ - Add them with comments explaining why
291
+
292
+ 4. **Test build**
293
+ ```bash
294
+ pnpm run build
295
+ ```
296
+
297
+ 5. **Verify types**
298
+ ```bash
299
+ npx kb-devkit-check-types
300
+ ```
301
+
302
+ ## 🔗 Related
303
+
304
+ - [DevKit README](../../README.md)
305
+ - [DevKit Usage Guide](../../USAGE_GUIDE.md)
306
+ - [ADR-0009: Unified Build Convention](../../docs/adr/0009-unified-build-convention.md)
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Standard ESLint configuration template
3
+ *
4
+ * This is the canonical template for all @kb-labs packages.
5
+ * DO NOT modify this file locally - it is synced from @kb-labs/devkit
6
+ *
7
+ * Customization guidelines:
8
+ * - DevKit preset already includes all standard ignores
9
+ * - Only add project-specific ignores if absolutely necessary
10
+ * - Document why custom ignores are needed
11
+ *
12
+ * @see https://github.com/kb-labs/devkit#eslint-configuration
13
+ */
14
+ import nodePreset from '@kb-labs/devkit/eslint/node.js';
15
+
16
+ export default [
17
+ ...nodePreset,
18
+
19
+ // OPTIONAL: Add project-specific ignores only if needed
20
+ // DevKit preset already ignores: dist/, coverage/, node_modules/, *.d.ts, scripts/, etc.
21
+ // {
22
+ // ignores: [
23
+ // // Add ONLY project-specific patterns here
24
+ // // Example: '**/*.generated.ts',
25
+ // ]
26
+ // }
27
+ ];
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@kb-labs/your-package",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Your package description",
6
+ "bin": {
7
+ "your-cli": "./dist/bin.cjs"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsup",
14
+ "dev": "tsup --watch",
15
+ "lint": "eslint .",
16
+ "test": "vitest"
17
+ },
18
+ "dependencies": {},
19
+ "devDependencies": {
20
+ "@kb-labs/devkit": "workspace:*",
21
+ "tsup": "^8.5.0",
22
+ "typescript": "^5.9.2",
23
+ "vitest": "^3.2.4"
24
+ }
25
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@kb-labs/your-package",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Your package description",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsup",
19
+ "dev": "tsup --watch",
20
+ "lint": "eslint .",
21
+ "test": "vitest"
22
+ },
23
+ "dependencies": {},
24
+ "devDependencies": {
25
+ "@kb-labs/devkit": "workspace:*",
26
+ "tsup": "^8.5.0",
27
+ "typescript": "^5.9.2",
28
+ "vitest": "^3.2.4"
29
+ }
30
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "@kb-labs/devkit/tsconfig/node.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "baseUrl": ".",
6
+ "paths": {}
7
+ },
8
+ "include": [
9
+ "src/**/*"
10
+ ],
11
+ "exclude": [
12
+ "dist",
13
+ "node_modules"
14
+ ]
15
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "@kb-labs/devkit/tsconfig/node.json",
4
+ "compilerOptions": {
5
+ "rootDir": "src",
6
+ "outDir": "dist"
7
+ },
8
+ "include": ["src"]
9
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Standard tsup configuration template for CLI binaries
3
+ *
4
+ * This template is for packages that provide executable binaries.
5
+ * Examples: cli-bin, core-state-daemon, any standalone executables
6
+ *
7
+ * DO NOT modify this file locally - it is synced from @kb-labs/devkit
8
+ *
9
+ * Key differences from library template:
10
+ * - Uses binPreset instead of nodePreset
11
+ * - Bundles ALL dependencies into standalone executable
12
+ * - Outputs .cjs format (CommonJS)
13
+ * - No type generation (dts: false)
14
+ * - Adds shebang automatically
15
+ *
16
+ * @see https://github.com/kb-labs/devkit#binary-packages
17
+ */
18
+ import { defineConfig } from 'tsup';
19
+ import binPreset from '@kb-labs/devkit/tsup/bin.js';
20
+
21
+ export default defineConfig({
22
+ ...binPreset,
23
+
24
+ // REQUIRED: Use build-specific tsconfig (convention)
25
+ tsconfig: 'tsconfig.build.json',
26
+
27
+ // REQUIRED: Entry point for binary
28
+ // Output will be dist/bin.cjs
29
+ entry: { bin: 'src/bin.ts' },
30
+
31
+ // binPreset already sets dts: false (binaries don't need types)
32
+ // binPreset already adds shebang banner
33
+ // binPreset already bundles everything
34
+ });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Standard tsup configuration template for CLI packages
3
+ *
4
+ * This template is for CLI packages that provide:
5
+ * - Multiple command handlers as separate entries
6
+ * - Importable from other packages (not bundled)
7
+ *
8
+ * Examples: cli-commands, mind-cli, workflow-cli
9
+ *
10
+ * DO NOT modify this file locally - it is synced from @kb-labs/devkit
11
+ *
12
+ * Key differences:
13
+ * - Multiple entry points for commands
14
+ * - NOT bundled (uses nodePreset)
15
+ * - Generates types (for other packages to import)
16
+ *
17
+ * @see https://github.com/kb-labs/devkit#cli-packages
18
+ */
19
+ import { defineConfig } from 'tsup';
20
+ import nodePreset from '@kb-labs/devkit/tsup/node.js';
21
+
22
+ export default defineConfig({
23
+ ...nodePreset,
24
+
25
+ // REQUIRED: Use build-specific tsconfig (convention)
26
+ tsconfig: 'tsconfig.build.json',
27
+
28
+ // REQUIRED: Multiple entries for CLI commands
29
+ entry: [
30
+ 'src/index.ts', // Main export
31
+ 'src/commands/**/*.ts', // All command files
32
+ // Add more entries as needed
33
+ ],
34
+
35
+ // REQUIRED: Explicit type generation
36
+ dts: true,
37
+
38
+ // OPTIONAL: CLI packages often have manifest files
39
+ // If you have manifest.json or similar, you might need to copy it:
40
+ // onSuccess: 'cp src/manifest.json dist/'
41
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Standard tsup configuration template for packages with BOTH library AND binary
3
+ *
4
+ * This template is for packages that provide:
5
+ * 1. A library (importable by other packages)
6
+ * 2. A CLI binary (executable)
7
+ *
8
+ * Examples: cli packages with both API and bin
9
+ *
10
+ * DO NOT modify this file locally - it is synced from @kb-labs/devkit
11
+ *
12
+ * Important: This builds BOTH lib and bin in one config.
13
+ * For complex cases, use separate configs (tsup.lib.config.ts + tsup.bin.config.ts)
14
+ *
15
+ * @see https://github.com/kb-labs/devkit#dual-packages
16
+ */
17
+ import { defineConfig } from 'tsup';
18
+ import nodePreset from '@kb-labs/devkit/tsup/node.js';
19
+
20
+ export default defineConfig([
21
+ // Library build (for imports)
22
+ {
23
+ ...nodePreset,
24
+ tsconfig: 'tsconfig.build.json',
25
+ entry: ['src/index.ts'], // Main library entry
26
+ dts: true,
27
+ },
28
+ // Binary build (for execution)
29
+ {
30
+ format: ['cjs'],
31
+ target: 'es2022',
32
+ platform: 'node',
33
+ sourcemap: true,
34
+ clean: false, // Already cleaned by first build
35
+ dts: false,
36
+ treeshake: true,
37
+ minify: false,
38
+ outDir: 'dist',
39
+ splitting: false,
40
+ noExternal: [/.*/], // Bundle everything
41
+ external: ['fsevents'], // Except native modules
42
+ banner: { js: '#!/usr/bin/env node' },
43
+ tsconfig: 'tsconfig.build.json',
44
+ entry: { bin: 'src/bin.ts' }, // Binary entry
45
+ },
46
+ ]);
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Standard tsup configuration template
3
+ *
4
+ * This is the canonical template for all @kb-labs packages.
5
+ * DO NOT modify this file locally - it is synced from @kb-labs/devkit
6
+ *
7
+ * Customization guidelines:
8
+ * - For single entry point: use as-is
9
+ * - For multiple entry points: override `entry` array
10
+ * - For extra external deps: extend `external` array (only if needed!)
11
+ * - For special build needs: add minimal overrides, document why
12
+ *
13
+ * @see https://github.com/kb-labs/devkit#tsup-configuration
14
+ */
15
+ import { defineConfig } from 'tsup';
16
+ import nodePreset from '@kb-labs/devkit/tsup/node.js';
17
+
18
+ export default defineConfig({
19
+ ...nodePreset,
20
+
21
+ // REQUIRED: Use build-specific tsconfig (convention)
22
+ tsconfig: 'tsconfig.build.json',
23
+
24
+ // REQUIRED: Entry point(s)
25
+ // Single entry (most common):
26
+ entry: ['src/index.ts'],
27
+ // Multiple entries (if needed):
28
+ // entry: ['src/index.ts', 'src/cli/index.ts', 'src/api/index.ts'],
29
+
30
+ // REQUIRED: Explicit type generation
31
+ dts: true,
32
+
33
+ // OPTIONAL: Only add if you need EXTRA externals beyond nodePreset
34
+ // nodePreset already includes all @kb-labs/* packages + dependencies from package.json
35
+ // external: ['special-package-not-in-preset'],
36
+ });