@kb-labs/adapters 0.5.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 (276) hide show
  1. package/.cursorrules +32 -0
  2. package/.github/workflows/ci.yml +13 -0
  3. package/.github/workflows/deploy.yml +28 -0
  4. package/.github/workflows/docker-build.yml +25 -0
  5. package/.github/workflows/drift-check.yml +10 -0
  6. package/.github/workflows/profiles-validate.yml +16 -0
  7. package/.github/workflows/release.yml +8 -0
  8. package/.kb/devkit/agents/devkit-maintainer/context.globs +15 -0
  9. package/.kb/devkit/agents/devkit-maintainer/permissions.yml +17 -0
  10. package/.kb/devkit/agents/devkit-maintainer/prompt.md +28 -0
  11. package/.kb/devkit/agents/devkit-maintainer/runbook.md +31 -0
  12. package/.kb/devkit/agents/docs-crafter/prompt.md +24 -0
  13. package/.kb/devkit/agents/docs-crafter/runbook.md +18 -0
  14. package/.kb/devkit/agents/release-manager/context.globs +7 -0
  15. package/.kb/devkit/agents/release-manager/prompt.md +27 -0
  16. package/.kb/devkit/agents/release-manager/runbook.md +17 -0
  17. package/.kb/devkit/agents/test-generator/context.globs +7 -0
  18. package/.kb/devkit/agents/test-generator/prompt.md +27 -0
  19. package/.kb/devkit/agents/test-generator/runbook.md +18 -0
  20. package/CONTRIBUTING.md +90 -0
  21. package/IMPLEMENTATION_COMPLETE.md +416 -0
  22. package/LICENSE +186 -0
  23. package/README-TEMPLATE.md +179 -0
  24. package/README.md +306 -0
  25. package/docs/DOCUMENTATION.md +74 -0
  26. package/docs/adr/0000-template.md +49 -0
  27. package/docs/adr/0001-architecture-and-repository-layout.md +33 -0
  28. package/docs/adr/0002-plugins-and-extensibility.md +46 -0
  29. package/docs/adr/0003-package-and-module-boundaries.md +37 -0
  30. package/docs/adr/0004-versioning-and-release-policy.md +38 -0
  31. package/docs/adr/0005-use-devkit-for-shared-tooling.md +48 -0
  32. package/docs/adr/0006-adopt-devkit-sync.md +47 -0
  33. package/docs/adr/0007-drift-kit-check.md +72 -0
  34. package/docs/adr/0008-devkit-sync-wrapper-strategy.md +67 -0
  35. package/docs/naming-convention.md +272 -0
  36. package/eslint.config.js +27 -0
  37. package/kb-labs.config.json +5 -0
  38. package/package.json +84 -0
  39. package/package.json.bin +25 -0
  40. package/package.json.lib +30 -0
  41. package/packages/adapters-analytics-duckdb/package.json +54 -0
  42. package/packages/adapters-analytics-duckdb/scripts/migrate-from-jsonl.mjs +253 -0
  43. package/packages/adapters-analytics-duckdb/src/index.ts +380 -0
  44. package/packages/adapters-analytics-duckdb/src/manifest.ts +36 -0
  45. package/packages/adapters-analytics-duckdb/src/schema.ts +161 -0
  46. package/packages/adapters-analytics-duckdb/tsconfig.build.json +15 -0
  47. package/packages/adapters-analytics-duckdb/tsconfig.json +9 -0
  48. package/packages/adapters-analytics-duckdb/tsup.config.ts +9 -0
  49. package/packages/adapters-analytics-file/README.md +32 -0
  50. package/packages/adapters-analytics-file/eslint.config.js +27 -0
  51. package/packages/adapters-analytics-file/package.json +50 -0
  52. package/packages/adapters-analytics-file/src/__tests__/daily-stats.spec.ts +287 -0
  53. package/packages/adapters-analytics-file/src/__tests__/scoped-analytics.test.ts +233 -0
  54. package/packages/adapters-analytics-file/src/index.test.ts +214 -0
  55. package/packages/adapters-analytics-file/src/index.ts +830 -0
  56. package/packages/adapters-analytics-file/src/manifest.ts +45 -0
  57. package/packages/adapters-analytics-file/tsconfig.build.json +15 -0
  58. package/packages/adapters-analytics-file/tsconfig.json +9 -0
  59. package/packages/adapters-analytics-file/tsup.config.ts +9 -0
  60. package/packages/adapters-analytics-sqlite/package.json +55 -0
  61. package/packages/adapters-analytics-sqlite/scripts/migrate-from-jsonl.mjs +194 -0
  62. package/packages/adapters-analytics-sqlite/src/index.ts +460 -0
  63. package/packages/adapters-analytics-sqlite/src/manifest.ts +41 -0
  64. package/packages/adapters-analytics-sqlite/tsconfig.build.json +15 -0
  65. package/packages/adapters-analytics-sqlite/tsconfig.json +9 -0
  66. package/packages/adapters-analytics-sqlite/tsup.config.ts +9 -0
  67. package/packages/adapters-environment-docker/README.md +28 -0
  68. package/packages/adapters-environment-docker/eslint.config.js +5 -0
  69. package/packages/adapters-environment-docker/package.json +49 -0
  70. package/packages/adapters-environment-docker/src/index.test.ts +138 -0
  71. package/packages/adapters-environment-docker/src/index.ts +439 -0
  72. package/packages/adapters-environment-docker/src/manifest.ts +65 -0
  73. package/packages/adapters-environment-docker/tsconfig.build.json +15 -0
  74. package/packages/adapters-environment-docker/tsconfig.json +16 -0
  75. package/packages/adapters-environment-docker/tsup.config.ts +9 -0
  76. package/packages/adapters-eventbus-cache/README.md +242 -0
  77. package/packages/adapters-eventbus-cache/eslint.config.js +27 -0
  78. package/packages/adapters-eventbus-cache/package.json +46 -0
  79. package/packages/adapters-eventbus-cache/src/index.test.ts +235 -0
  80. package/packages/adapters-eventbus-cache/src/index.ts +215 -0
  81. package/packages/adapters-eventbus-cache/src/manifest.ts +50 -0
  82. package/packages/adapters-eventbus-cache/src/types.ts +58 -0
  83. package/packages/adapters-eventbus-cache/tsconfig.build.json +15 -0
  84. package/packages/adapters-eventbus-cache/tsconfig.json +9 -0
  85. package/packages/adapters-eventbus-cache/tsup.config.ts +9 -0
  86. package/packages/adapters-fs/README.md +171 -0
  87. package/packages/adapters-fs/allowed.txt +1 -0
  88. package/packages/adapters-fs/conflict.txt +1 -0
  89. package/packages/adapters-fs/dest.txt +1 -0
  90. package/packages/adapters-fs/eslint.config.js +27 -0
  91. package/packages/adapters-fs/exists.txt +1 -0
  92. package/packages/adapters-fs/not-allowed.txt +1 -0
  93. package/packages/adapters-fs/other.txt +1 -0
  94. package/packages/adapters-fs/package.json +55 -0
  95. package/packages/adapters-fs/public/file1.txt +1 -0
  96. package/packages/adapters-fs/public/file2.txt +1 -0
  97. package/packages/adapters-fs/secret.txt +1 -0
  98. package/packages/adapters-fs/secrets/key.txt +1 -0
  99. package/packages/adapters-fs/src/index.test.ts +243 -0
  100. package/packages/adapters-fs/src/index.ts +258 -0
  101. package/packages/adapters-fs/src/manifest.ts +35 -0
  102. package/packages/adapters-fs/src/secure-storage.test.ts +380 -0
  103. package/packages/adapters-fs/src/secure-storage.ts +268 -0
  104. package/packages/adapters-fs/test.json +1 -0
  105. package/packages/adapters-fs/test.txt +1 -0
  106. package/packages/adapters-fs/test.xyz +1 -0
  107. package/packages/adapters-fs/test1.txt +1 -0
  108. package/packages/adapters-fs/test2.txt +1 -0
  109. package/packages/adapters-fs/tsconfig.build.json +15 -0
  110. package/packages/adapters-fs/tsconfig.json +9 -0
  111. package/packages/adapters-fs/tsup.config.ts +8 -0
  112. package/packages/adapters-fs/vitest.config.ts +19 -0
  113. package/packages/adapters-log-ringbuffer/README.md +228 -0
  114. package/packages/adapters-log-ringbuffer/eslint.config.js +27 -0
  115. package/packages/adapters-log-ringbuffer/package.json +47 -0
  116. package/packages/adapters-log-ringbuffer/src/__tests__/ring-buffer.test.ts +450 -0
  117. package/packages/adapters-log-ringbuffer/src/index.ts +212 -0
  118. package/packages/adapters-log-ringbuffer/src/manifest.ts +30 -0
  119. package/packages/adapters-log-ringbuffer/tsconfig.build.json +15 -0
  120. package/packages/adapters-log-ringbuffer/tsconfig.json +9 -0
  121. package/packages/adapters-log-ringbuffer/tsup.config.ts +9 -0
  122. package/packages/adapters-log-ringbuffer/vitest.config.ts +14 -0
  123. package/packages/adapters-log-sqlite/README.md +396 -0
  124. package/packages/adapters-log-sqlite/eslint.config.js +27 -0
  125. package/packages/adapters-log-sqlite/package.json +49 -0
  126. package/packages/adapters-log-sqlite/src/__tests__/log-persistence.test.ts +718 -0
  127. package/packages/adapters-log-sqlite/src/index.ts +1068 -0
  128. package/packages/adapters-log-sqlite/src/manifest.ts +36 -0
  129. package/packages/adapters-log-sqlite/src/schema.sql +46 -0
  130. package/packages/adapters-log-sqlite/tsconfig.build.json +15 -0
  131. package/packages/adapters-log-sqlite/tsconfig.json +9 -0
  132. package/packages/adapters-log-sqlite/tsup.config.ts +9 -0
  133. package/packages/adapters-log-sqlite/vitest.config.ts +15 -0
  134. package/packages/adapters-mongodb/README.md +147 -0
  135. package/packages/adapters-mongodb/eslint.config.js +27 -0
  136. package/packages/adapters-mongodb/package.json +53 -0
  137. package/packages/adapters-mongodb/src/index.ts +428 -0
  138. package/packages/adapters-mongodb/src/manifest.ts +45 -0
  139. package/packages/adapters-mongodb/src/secure-document.ts +231 -0
  140. package/packages/adapters-mongodb/tsconfig.build.json +15 -0
  141. package/packages/adapters-mongodb/tsconfig.json +9 -0
  142. package/packages/adapters-mongodb/tsup.config.ts +8 -0
  143. package/packages/adapters-openai/README.md +151 -0
  144. package/packages/adapters-openai/embeddings.ts +37 -0
  145. package/packages/adapters-openai/eslint.config.js +26 -0
  146. package/packages/adapters-openai/index.ts +22 -0
  147. package/packages/adapters-openai/package.json +57 -0
  148. package/packages/adapters-openai/src/embeddings-manifest.ts +45 -0
  149. package/packages/adapters-openai/src/embeddings.ts +104 -0
  150. package/packages/adapters-openai/src/index.ts +13 -0
  151. package/packages/adapters-openai/src/llm.ts +304 -0
  152. package/packages/adapters-openai/src/manifest.ts +47 -0
  153. package/packages/adapters-openai/tsconfig.build.json +15 -0
  154. package/packages/adapters-openai/tsconfig.json +9 -0
  155. package/packages/adapters-openai/tsup.config.ts +8 -0
  156. package/packages/adapters-pino/README.md +152 -0
  157. package/packages/adapters-pino/eslint.config.js +27 -0
  158. package/packages/adapters-pino/package.json +49 -0
  159. package/packages/adapters-pino/src/index.test.ts +44 -0
  160. package/packages/adapters-pino/src/index.ts +322 -0
  161. package/packages/adapters-pino/src/log-ring-buffer.ts +142 -0
  162. package/packages/adapters-pino/src/manifest.ts +49 -0
  163. package/packages/adapters-pino/tsconfig.build.json +15 -0
  164. package/packages/adapters-pino/tsconfig.json +9 -0
  165. package/packages/adapters-pino/tsup.config.ts +9 -0
  166. package/packages/adapters-pino-http/README.md +141 -0
  167. package/packages/adapters-pino-http/eslint.config.js +27 -0
  168. package/packages/adapters-pino-http/package.json +46 -0
  169. package/packages/adapters-pino-http/src/index.ts +229 -0
  170. package/packages/adapters-pino-http/tsconfig.build.json +15 -0
  171. package/packages/adapters-pino-http/tsconfig.json +9 -0
  172. package/packages/adapters-pino-http/tsup.config.ts +9 -0
  173. package/packages/adapters-qdrant/README.md +166 -0
  174. package/packages/adapters-qdrant/eslint.config.js +27 -0
  175. package/packages/adapters-qdrant/package.json +49 -0
  176. package/packages/adapters-qdrant/src/index.ts +490 -0
  177. package/packages/adapters-qdrant/src/manifest.ts +54 -0
  178. package/packages/adapters-qdrant/src/retry.ts +204 -0
  179. package/packages/adapters-qdrant/tsconfig.build.json +15 -0
  180. package/packages/adapters-qdrant/tsconfig.json +9 -0
  181. package/packages/adapters-qdrant/tsup.config.ts +9 -0
  182. package/packages/adapters-redis/README.md +159 -0
  183. package/packages/adapters-redis/eslint.config.js +27 -0
  184. package/packages/adapters-redis/package.json +49 -0
  185. package/packages/adapters-redis/src/index.ts +164 -0
  186. package/packages/adapters-redis/src/manifest.ts +49 -0
  187. package/packages/adapters-redis/tsconfig.build.json +15 -0
  188. package/packages/adapters-redis/tsconfig.json +9 -0
  189. package/packages/adapters-redis/tsup.config.ts +9 -0
  190. package/packages/adapters-snapshot-localfs/README.md +10 -0
  191. package/packages/adapters-snapshot-localfs/eslint.config.js +2 -0
  192. package/packages/adapters-snapshot-localfs/package.json +46 -0
  193. package/packages/adapters-snapshot-localfs/src/index.test.ts +40 -0
  194. package/packages/adapters-snapshot-localfs/src/index.ts +292 -0
  195. package/packages/adapters-snapshot-localfs/src/manifest.ts +32 -0
  196. package/packages/adapters-snapshot-localfs/tsconfig.build.json +15 -0
  197. package/packages/adapters-snapshot-localfs/tsconfig.json +16 -0
  198. package/packages/adapters-snapshot-localfs/tsup.config.ts +11 -0
  199. package/packages/adapters-sqlite/README.md +163 -0
  200. package/packages/adapters-sqlite/eslint.config.js +27 -0
  201. package/packages/adapters-sqlite/package.json +54 -0
  202. package/packages/adapters-sqlite/src/index.test.ts +245 -0
  203. package/packages/adapters-sqlite/src/index.ts +382 -0
  204. package/packages/adapters-sqlite/src/manifest.ts +47 -0
  205. package/packages/adapters-sqlite/src/secure-sql.test.ts +290 -0
  206. package/packages/adapters-sqlite/src/secure-sql.ts +281 -0
  207. package/packages/adapters-sqlite/tsconfig.build.json +15 -0
  208. package/packages/adapters-sqlite/tsconfig.json +9 -0
  209. package/packages/adapters-sqlite/tsup.config.ts +8 -0
  210. package/packages/adapters-sqlite/vitest.config.ts +19 -0
  211. package/packages/adapters-transport/README.md +170 -0
  212. package/packages/adapters-transport/eslint.config.js +27 -0
  213. package/packages/adapters-transport/package.json +49 -0
  214. package/packages/adapters-transport/src/__tests__/unix-socket-server.test.ts +550 -0
  215. package/packages/adapters-transport/src/index.ts +101 -0
  216. package/packages/adapters-transport/src/ipc-transport.ts +228 -0
  217. package/packages/adapters-transport/src/transport.ts +224 -0
  218. package/packages/adapters-transport/src/types.ts +92 -0
  219. package/packages/adapters-transport/src/unix-socket-server.ts +193 -0
  220. package/packages/adapters-transport/src/unix-socket-transport.ts +280 -0
  221. package/packages/adapters-transport/tsconfig.build.json +15 -0
  222. package/packages/adapters-transport/tsconfig.json +9 -0
  223. package/packages/adapters-transport/tsup.config.ts +9 -0
  224. package/packages/adapters-vibeproxy/README.md +159 -0
  225. package/packages/adapters-vibeproxy/eslint.config.js +27 -0
  226. package/packages/adapters-vibeproxy/package.json +51 -0
  227. package/packages/adapters-vibeproxy/src/index.ts +13 -0
  228. package/packages/adapters-vibeproxy/src/llm.ts +437 -0
  229. package/packages/adapters-vibeproxy/src/manifest.ts +51 -0
  230. package/packages/adapters-vibeproxy/tsconfig.build.json +15 -0
  231. package/packages/adapters-vibeproxy/tsconfig.json +9 -0
  232. package/packages/adapters-vibeproxy/tsup.config.ts +8 -0
  233. package/packages/adapters-workspace-agent/package.json +46 -0
  234. package/packages/adapters-workspace-agent/src/__tests__/adapter.test.ts +212 -0
  235. package/packages/adapters-workspace-agent/src/index.ts +220 -0
  236. package/packages/adapters-workspace-agent/src/manifest.ts +36 -0
  237. package/packages/adapters-workspace-agent/tsconfig.build.json +15 -0
  238. package/packages/adapters-workspace-agent/tsconfig.json +16 -0
  239. package/packages/adapters-workspace-agent/tsup.config.ts +11 -0
  240. package/packages/adapters-workspace-localfs/README.md +9 -0
  241. package/packages/adapters-workspace-localfs/eslint.config.js +2 -0
  242. package/packages/adapters-workspace-localfs/package.json +46 -0
  243. package/packages/adapters-workspace-localfs/src/index.test.ts +27 -0
  244. package/packages/adapters-workspace-localfs/src/index.ts +172 -0
  245. package/packages/adapters-workspace-localfs/src/manifest.ts +32 -0
  246. package/packages/adapters-workspace-localfs/tsconfig.build.json +15 -0
  247. package/packages/adapters-workspace-localfs/tsconfig.json +16 -0
  248. package/packages/adapters-workspace-localfs/tsup.config.ts +11 -0
  249. package/packages/adapters-workspace-worktree/README.md +9 -0
  250. package/packages/adapters-workspace-worktree/eslint.config.js +2 -0
  251. package/packages/adapters-workspace-worktree/package.json +46 -0
  252. package/packages/adapters-workspace-worktree/src/index.test.ts +38 -0
  253. package/packages/adapters-workspace-worktree/src/index.ts +245 -0
  254. package/packages/adapters-workspace-worktree/src/manifest.ts +38 -0
  255. package/packages/adapters-workspace-worktree/tsconfig.build.json +15 -0
  256. package/packages/adapters-workspace-worktree/tsconfig.json +16 -0
  257. package/packages/adapters-workspace-worktree/tsup.config.ts +11 -0
  258. package/pnpm-workspace.yaml +2800 -0
  259. package/prettierrc.json +1 -0
  260. package/scripts/devkit-sync.mjs +37 -0
  261. package/scripts/hooks/post-push +9 -0
  262. package/scripts/hooks/pre-commit +9 -0
  263. package/scripts/hooks/pre-push +9 -0
  264. package/test-integration.ts +242 -0
  265. package/test.txt +1 -0
  266. package/tsconfig.base.json +6 -0
  267. package/tsconfig.build.json +15 -0
  268. package/tsconfig.json +9 -0
  269. package/tsconfig.paths.json +26 -0
  270. package/tsconfig.tools.json +17 -0
  271. package/tsup.config.bin.ts +34 -0
  272. package/tsup.config.cli.ts +41 -0
  273. package/tsup.config.dual.ts +46 -0
  274. package/tsup.config.ts +36 -0
  275. package/tsup.external.json +103 -0
  276. package/vitest.config.ts +2 -0
@@ -0,0 +1,37 @@
1
+ # ADR-0003: Package and Module Boundaries
2
+
3
+ **Date:** 2025-09-13
4
+ **Status:** Accepted
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [architecture, process]
8
+
9
+ ## Context
10
+
11
+ Products in KB Labs often require multiple internal packages. Without strict boundaries, cross-dependencies can grow messy and unmaintainable.
12
+
13
+ ## Decision
14
+
15
+ - Every package under `/packages` must define:
16
+ - `src/` — implementation
17
+ - `index.ts` — public entry point
18
+ - `types/` — exported types & schemas
19
+ - Packages must only depend on public exports of other packages
20
+ - Cross-package imports must use workspace aliases (`@kb-labs/<pkg>`)
21
+ - Domain rules:
22
+ - Core logic in `@kb-labs/core`
23
+ - Product-specific code in `@kb-labs/<product>`
24
+ - Experimental code → feature packages, not core
25
+
26
+ ## Consequences
27
+
28
+ **Positive:**
29
+
30
+ - Prevents tight coupling
31
+ - Core remains minimal and reusable
32
+ - Easier to extract packages as standalone OSS later
33
+
34
+ **Negative:**
35
+
36
+ - Requires discipline to maintain boundaries
37
+ - More complex dependency management
@@ -0,0 +1,38 @@
1
+ # ADR-0004: Versioning and Release Policy
2
+
3
+ **Date:** 2025-09-13
4
+ **Status:** Accepted
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [process, deployment]
8
+
9
+ ## Context
10
+
11
+ The KB Labs ecosystem must stay consistent, while still allowing individual products to evolve.
12
+
13
+ ## Decision
14
+
15
+ - Use Semantic Versioning (SemVer) for all published packages
16
+ - Core (`@kb-labs/core`) follows stricter rules:
17
+ - **MAJOR:** breaking changes in APIs/schemas
18
+ - **MINOR:** new features, backward-compatible
19
+ - **PATCH:** bugfixes
20
+ - Products (`ai-review`, `ai-docs`, `ai-tests`, etc.) can release independently, but must pin to compatible core versions
21
+ - Changelog generation automated via changesets or `@kb-labs/changelog-generator`
22
+ - Release flow:
23
+ 1. Pull request → CI check (lint, type-check, test)
24
+ 2. Merge → changeset entry created
25
+ 3. Release pipeline tags version, publishes to npm, updates changelog
26
+
27
+ ## Consequences
28
+
29
+ **Positive:**
30
+
31
+ - Predictable updates across ecosystem
32
+ - Users know when breaking changes occur
33
+ - Easy adoption of multiple products without fear of hidden breakage
34
+
35
+ **Negative:**
36
+
37
+ - Requires careful coordination for major releases
38
+ - More complex release automation setup
@@ -0,0 +1,48 @@
1
+ # ADR-0005: Use DevKit for Shared Tooling
2
+
3
+ **Date:** 2025-09-15
4
+ **Status:** Accepted
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [tooling, process]
8
+
9
+ ## Context
10
+
11
+ The **kb-labs** ecosystem consists of multiple projects (core, cli, product-template, etc.).
12
+ Each project requires identical tooling configuration: ESLint, Prettier, Vitest, TSConfig, GitHub Actions, etc.
13
+
14
+ If these configurations are stored separately in each repository:
15
+
16
+ - Code and rule duplication occurs
17
+ - Maintaining consistent style becomes difficult (changes need to be applied manually to all projects)
18
+ - Risk of desynchronization increases (e.g., different versions of eslint-config or tsconfig)
19
+
20
+ ## Decision
21
+
22
+ We are extracting all base configurations and actions into a separate package **@kb-labs/devkit**.
23
+ The project template (`kb-labs-product-template`) includes devkit, with local configs serving only as "thin wrappers" over it.
24
+
25
+ This approach provides:
26
+
27
+ - Centralized logic and rules in `kb-labs-devkit`
28
+ - Fastest possible new project creation (setup through template and devkit)
29
+ - Single-point maintenance for rule/infrastructure changes that apply to all projects
30
+
31
+ ## Consequences
32
+
33
+ ### Positive
34
+
35
+ - Consistent code style and testing across all repositories
36
+ - Minimal boilerplate in new projects
37
+ - Simplified maintenance and updates
38
+
39
+ ### Negative
40
+
41
+ - Dependency on `@kb-labs/devkit` (projects cannot build without it)
42
+ - DevKit bugs or errors affect all projects simultaneously
43
+ - Requires discipline when updating DevKit versions across all dependent projects
44
+
45
+ ## Alternatives Considered
46
+
47
+ - **Keep configs within each project** — Rejected due to high maintenance cost
48
+ - **Use external shared configs** (e.g., `eslint-config-standard`) without custom devkit — Rejected as more custom rules and integrations (tsup, GitHub Actions) are required
@@ -0,0 +1,47 @@
1
+ # ADR-0006: Adopt DevKit Synchronization
2
+
3
+ **Date:** 2025-09-18
4
+ **Status:** Accepted
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [tooling, process]
8
+
9
+ ## Context
10
+
11
+ This template inherits shared tooling from `@kb-labs/devkit`: ESLint/Prettier/Vitest/Tsup/TS presets, reusable CI, and preconfigured Cursor agents. Without a clear sync mechanism, templates and products could diverge from the central standards.
12
+
13
+ ## Decision
14
+
15
+ The template **adopts DevKit synchronization**:
16
+
17
+ - Tooling configs are **thin wrappers** over DevKit exports (no local forks)
18
+ - Cursor agents (`/agents`, `.cursorrules`, `AGENTS.md`) are synchronized from DevKit via:
19
+ ```bash
20
+ pnpm agents:sync
21
+ ```
22
+ - Before major contributions and releases, run the sync to ensure alignment
23
+
24
+ ## Consequences
25
+
26
+ **Positive:**
27
+
28
+ - Guarantees consistency with KB Labs standards
29
+ - Reduces setup time for new products
30
+ - Keeps docs and agents up-to-date without manual copy/paste
31
+ - Minimal boilerplate
32
+ - Centralized updates; predictable upgrades
33
+
34
+ **Negative:**
35
+
36
+ - Requires DevKit availability and version pinning
37
+ - Local deviations must be explicitly justified (and usually upstreamed to DevKit)
38
+
39
+ ## Implementation
40
+
41
+ - `eslint.config.js`, `vitest.config.ts`, `tsconfig.base.json` extend/import DevKit presets
42
+ - `pnpm agents:sync` copies the latest agent definitions
43
+ - CI reuses DevKit workflows via `uses: KirillBaranov/kb-labs-devkit/.github/workflows/...@main` (or versioned tags later)
44
+
45
+ ## References
46
+
47
+ - DevKit ADR: `@kb-labs/devkit/docs/adr/0001-repo-synchronization-via-devkit.md`
@@ -0,0 +1,72 @@
1
+ # ADR-0007: DevKit Drift Check
2
+
3
+ **Date:** 2025-09-18
4
+ **Status:** Proposed
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [tooling, process]
8
+
9
+ ## Context
10
+
11
+ As our development kits (DevKits) evolve, it is essential to ensure consistency and detect any unintended changes or drifts from the expected configuration or state. Drift in DevKits can lead to integration issues, unexpected behaviors, and increased debugging time. To maintain quality and reliability, we need a standardized approach to check for drift in our DevKits.
12
+
13
+ ## Decision
14
+
15
+ We will implement a DevKit Drift Check process that involves:
16
+
17
+ - Defining a baseline configuration and state for each DevKit version
18
+ - Automating the comparison of the current DevKit state against the baseline
19
+ - Reporting any deviations or drifts clearly and promptly
20
+ - Integrating the drift check into our continuous integration (CI) pipeline to catch issues early
21
+ - Providing remediation steps or automated fixes when feasible
22
+
23
+ This approach ensures that any drift is detected early, maintaining the integrity and reliability of our DevKits.
24
+
25
+ ## Implementation
26
+
27
+ The drift check is implemented via a script located at `scripts/devkit-sync.mjs`. This script facilitates two main commands:
28
+
29
+ - `pnpm sync`: Synchronizes the project configuration files with the baseline sources provided by the `@kb-labs/devkit` package
30
+ - `pnpm drift-check`: Verifies the consistency of the project files against the baseline. It compares the current project files against the source files in `@kb-labs/devkit`, reports any differences found, and exits with code 2 if any drift is detected
31
+
32
+ When drift is detected, the script outputs a detailed log showing the files that differ and the specific discrepancies, enabling developers to quickly identify and address the issues.
33
+
34
+ Example output when drift is detected:
35
+
36
+ ```bash
37
+ Drift detected in the following files:
38
+ - config/devkit.json
39
+ - scripts/build.js
40
+
41
+ Differences:
42
+ --- baseline/config/devkit.json
43
+ +++ project/config/devkit.json
44
+ @@ -1,5 +1,5 @@
45
+ {
46
+ - "version": "1.0.0",
47
+ + "version": "1.0.1",
48
+ "features": ["featureA", "featureB"]
49
+ }
50
+
51
+ --- baseline/scripts/build.js
52
+ +++ project/scripts/build.js
53
+ @@ -10,7 +10,7 @@
54
+ - console.log("Build started");
55
+ + console.log("Build initiated");
56
+ ```
57
+
58
+ This mechanism ensures that any unintended changes are caught early, preserving the integrity of the DevKit environment.
59
+
60
+ ## Consequences
61
+
62
+ **Positive:**
63
+
64
+ - Increased confidence in DevKit consistency
65
+ - Early detection of configuration or state issues
66
+ - Automated validation reduces manual verification overhead
67
+
68
+ **Negative:**
69
+
70
+ - Additional CI pipeline steps and maintenance overhead
71
+ - Need to maintain baseline definitions as DevKits evolve
72
+ - Dependency on DevKit availability for drift checks
@@ -0,0 +1,67 @@
1
+ # ADR-0008: DevKit Sync Wrapper Strategy in Product Template
2
+
3
+ **Date:** 2025-09-25
4
+ **Status:** Accepted
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [tooling, process]
8
+
9
+ ## Context
10
+
11
+ For proper operation of projects created from @kb-labs/product-template, synchronization of certain artifacts from @kb-labs/devkit is required (e.g., agents, .cursorrules, VS Code settings).
12
+
13
+ Previously, it was assumed to use the kb-devkit-sync binary directly or call a local script from devkit, but this approach complicated migrations and required additional configuration.
14
+
15
+ The main goal is to minimize friction when starting a new project and ensure stability of the synchronization mechanism regardless of the developer environment.
16
+
17
+ ## Decision
18
+
19
+ Wrapper npm scripts will be added to the product-template:
20
+
21
+ ```json
22
+ "scripts": {
23
+ "devkit:sync": "kb-devkit-sync",
24
+ "devkit:check": "kb-devkit-sync --check",
25
+ "postinstall": "pnpm -s devkit:sync || true"
26
+ }
27
+ ```
28
+
29
+ This approach provides:
30
+ - Calls are made through package.json without the need to manually install the binary
31
+ - postinstall automatically pulls artifacts when installing dependencies
32
+ - devkit:check allows running drift checks in CI
33
+
34
+ ## Consequences
35
+
36
+ ### Positive
37
+
38
+ - **Simplicity**: Users run `pnpm devkit:sync` without knowledge of internal implementation
39
+ - **Automation**: Synchronization happens on every `pnpm install`
40
+ - **Error reduction**: Single approach for all projects created from the template
41
+
42
+ ### Negative
43
+
44
+ - **Hard dependency**: Tight coupling to the presence of kb-devkit-sync binary in @kb-labs/devkit
45
+ - **Migration risk**: If the binary is renamed or API changes, all template-based projects will need updates
46
+
47
+ ### Alternatives Considered
48
+
49
+ - **Local script in each project** (bin/devkit-sync.mjs): More control but requires duplication and manual maintenance
50
+ - **Direct devkit API calls**: More complex for consumers, increases risk of configuration drift
51
+ - **No automatic sync**: Consumers would have to manually copy files → too high cost of errors
52
+
53
+ ## Implementation
54
+
55
+ - The described scripts have been added to the template's package.json
56
+ - postinstall ensures auto-synchronization after dependency installation
57
+ - CI pipelines will use `pnpm devkit:check` for drift verification
58
+
59
+ Future steps:
60
+ - If an alternative implementation emerges (e.g., REST API or new CLI utility), an ADR-supersede can be created
61
+ - Sync logic will be documented in the template's README for new users
62
+
63
+ ## References
64
+
65
+ - [DevKit Repository](https://github.com/kb-labs/devkit) <!-- TODO: Replace with actual URL -->
66
+ - [Product Template Repository](https://github.com/kb-labs/product-template) <!-- TODO: Replace with actual URL -->
67
+ - [Related ADR: ADR-0005: Use DevKit for Shared Tooling](./0005-use-devkit-for-shared-tooling.md)
@@ -0,0 +1,272 @@
1
+ # Naming Convention: The Pyramid Rule
2
+
3
+ **Status:** Mandatory
4
+ **Applies to:** All packages in KB Labs ecosystem
5
+ **Date:** 2025-11-30
6
+
7
+ ---
8
+
9
+ ## The Pyramid Rule
10
+
11
+ All packages in the KB Labs ecosystem follow a strict naming convention called **"The Pyramid Rule"**:
12
+
13
+ ```
14
+ @kb-labs/{repo}-{package}
15
+ ```
16
+
17
+ Where:
18
+ - `{repo}` - the monorepo name (e.g., `core`, `cli`, `shared`, `plugin`)
19
+ - `{package}` - the package name within that repo
20
+
21
+ **Critical:** The folder name MUST ALWAYS match `{repo}-{package}`.
22
+
23
+ ---
24
+
25
+ ## The Pyramid Structure
26
+
27
+ ```
28
+ @kb-labs ← Base namespace (all packages)
29
+
30
+ {repo} ← Repository name (core, cli, shared, plugin)
31
+
32
+ {package} ← Package name
33
+ ```
34
+
35
+ **Example:**
36
+ ```
37
+ Repository: kb-labs-core
38
+ Package: config
39
+ Result: @kb-labs/core-config
40
+ Folder: kb-labs-core/packages/core-config/
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Rules
46
+
47
+ ### ✅ DO
48
+
49
+ **1. Always use the repo prefix in folder names:**
50
+ ```
51
+ kb-labs-core/packages/core-config/ → @kb-labs/core-config ✅
52
+ kb-labs-cli/packages/cli-core/ → @kb-labs/cli-core ✅
53
+ kb-labs-shared/packages/shared-diff/ → @kb-labs/shared-diff ✅
54
+ ```
55
+
56
+ **2. Keep folder name and package name in sync:**
57
+ ```json
58
+ // In kb-labs-core/packages/core-config/package.json
59
+ {
60
+ "name": "@kb-labs/core-config" // Matches folder: core-config
61
+ }
62
+ ```
63
+
64
+ **3. Use descriptive package names:**
65
+ ```
66
+ core-state-broker ✅ (clear what it does)
67
+ core-framework ✅ (indicates it's infrastructure)
68
+ core-cli ✅ (CLI commands for core)
69
+ ```
70
+
71
+ ### ❌ DON'T
72
+
73
+ **1. Skip the repo prefix:**
74
+ ```
75
+ kb-labs-core/packages/config/ → @kb-labs/core-config ❌
76
+ kb-labs-core/packages/sys/ → @kb-labs/core-sys ❌
77
+ ```
78
+ **Problem:** Folder name doesn't match package name pattern.
79
+
80
+ **2. Use inconsistent naming:**
81
+ ```
82
+ kb-labs-core/packages/cli-core/ → @kb-labs/core-cli ❌
83
+ ```
84
+ **Problem:** Folder is `cli-core` but package is `core-cli` (inverted).
85
+
86
+ **3. Create packages without repo prefix:**
87
+ ```
88
+ kb-labs-core/packages/bundle/ → @kb-labs/bundle ❌
89
+ ```
90
+ **Problem:** Missing `core-` prefix in both folder and package name.
91
+
92
+ ---
93
+
94
+ ## Examples by Repository
95
+
96
+ ### kb-labs-core
97
+
98
+ All packages MUST have `core-` prefix:
99
+
100
+ ```
101
+ ✅ core-bundle/ → @kb-labs/core-bundle
102
+ ✅ core-cli/ → @kb-labs/core-cli
103
+ ✅ core-config/ → @kb-labs/core-config
104
+ ✅ core-framework/ → @kb-labs/core-framework
105
+ ✅ core-state-broker/ → @kb-labs/core-state-broker
106
+ ✅ core-sys/ → @kb-labs/core-sys
107
+ ✅ core-types/ → @kb-labs/core-types
108
+ ```
109
+
110
+ ### kb-labs-cli
111
+
112
+ All packages MUST have `cli-` prefix:
113
+
114
+ ```
115
+ ✅ cli-api/ → @kb-labs/cli-api
116
+ ✅ cli-commands/ → @kb-labs/cli-commands
117
+ ✅ cli-contracts/ → @kb-labs/cli-contracts
118
+ ✅ cli-core/ → @kb-labs/cli-core
119
+ ✅ cli-runtime/ → @kb-labs/cli-runtime
120
+ ```
121
+
122
+ ### kb-labs-shared
123
+
124
+ All packages MUST have `shared-` prefix:
125
+
126
+ ```
127
+ ✅ shared-command-kit/ → @kb-labs/shared-command-kit
128
+ ✅ shared-cli-ui/ → @kb-labs/shared-cli-ui
129
+ ✅ shared-diff/ → @kb-labs/shared-diff
130
+ ✅ shared-repo/ → @kb-labs/shared-repo
131
+ ```
132
+
133
+ ### kb-labs-plugin
134
+
135
+ All packages MUST have `plugin-` prefix:
136
+
137
+ ```
138
+ ✅ plugin-manifest/ → @kb-labs/plugin-manifest
139
+ ✅ plugin-runtime/ → @kb-labs/plugin-runtime
140
+ ✅ plugin-adapter-cli/ → @kb-labs/plugin-adapter-cli
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Special Cases
146
+
147
+ ### Multi-word package names
148
+
149
+ Use kebab-case for multi-word names:
150
+
151
+ ```
152
+ ✅ core-state-broker/ → @kb-labs/core-state-broker
153
+ ✅ core-cli-adapters/ → @kb-labs/core-cli-adapters
154
+ ✅ plugin-adapter-rest/ → @kb-labs/plugin-adapter-rest
155
+ ```
156
+
157
+ ### Adapters and sub-packages
158
+
159
+ Adapters can be nested but still follow the rule:
160
+
161
+ ```
162
+ ✅ kb-labs-plugin/packages/plugin-adapter-cli/
163
+ ✅ kb-labs-plugin/packages/plugin-adapter-rest/
164
+ ✅ kb-labs-core/packages/core-cli-adapters/
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Migration Checklist
170
+
171
+ When creating a new package or fixing naming violations:
172
+
173
+ - [ ] Folder name follows `{repo}-{package}` pattern
174
+ - [ ] `package.json` name matches `@kb-labs/{repo}-{package}`
175
+ - [ ] Folder name and package name are in sync
176
+ - [ ] All `link:` dependencies updated to new paths
177
+ - [ ] All `workspace:*` dependencies updated to new names
178
+ - [ ] Documentation updated (README, imports)
179
+ - [ ] `pnpm install` runs without errors
180
+
181
+ ---
182
+
183
+ ## Validation
184
+
185
+ ### Check for violations
186
+
187
+ ```bash
188
+ # List all packages and check naming
189
+ find kb-labs-*/packages -name package.json -exec grep -H '"name":' {} \;
190
+
191
+ # Expected pattern: kb-labs-{repo}/packages/{repo}-{package}/package.json
192
+ ```
193
+
194
+ ### Common violations
195
+
196
+ 1. **Missing repo prefix in folder:**
197
+ ```
198
+ kb-labs-core/packages/config/ ❌
199
+ Should be: core-config/
200
+ ```
201
+
202
+ 2. **Inverted naming:**
203
+ ```
204
+ kb-labs-core/packages/cli-core/ with @kb-labs/core-cli ❌
205
+ Should be: core-cli/ or rename package
206
+ ```
207
+
208
+ 3. **Missing repo prefix in package name:**
209
+ ```
210
+ "name": "@kb-labs/sandbox" ❌
211
+ Should be: "@kb-labs/core-sandbox"
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Benefits
217
+
218
+ ### 1. Zero Ambiguity
219
+ - No confusion about where a package belongs
220
+ - `@kb-labs/core-config` → clearly in `kb-labs-core`
221
+ - `@kb-labs/cli-core` → clearly in `kb-labs-cli`
222
+
223
+ ### 2. Easy Navigation
224
+ - Folder structure mirrors package names
225
+ - `import from '@kb-labs/core-sys'` → look in `kb-labs-core/packages/core-sys/`
226
+
227
+ ### 3. Prevents Collisions
228
+ - Before: two packages could have `@kb-labs/core-cli` (collision!)
229
+ - After: impossible - repo prefix enforces uniqueness
230
+
231
+ ### 4. Scalability
232
+ - New repos automatically follow pattern
233
+ - `kb-labs-ai/packages/ai-docs/` → `@kb-labs/ai-docs`
234
+
235
+ ---
236
+
237
+ ## History
238
+
239
+ **Before (Problematic):**
240
+ ```
241
+ kb-labs-core/packages/sys/ → @kb-labs/core-sys
242
+ kb-labs-core/packages/cli/ → @kb-labs/core-cli
243
+ kb-labs-core/packages/cli-core/ → @kb-labs/core-cli ← COLLISION!
244
+ kb-labs-cli/packages/core/ → @kb-labs/cli-core
245
+ kb-labs-cli/packages/cli-core/ → @kb-labs/cli-core ← WRAPPER
246
+ ```
247
+
248
+ **After (Clean):**
249
+ ```
250
+ kb-labs-core/packages/core-sys/ → @kb-labs/core-sys
251
+ kb-labs-core/packages/core-cli/ → @kb-labs/core-cli
252
+ kb-labs-core/packages/core-framework/ → @kb-labs/core-framework
253
+ kb-labs-cli/packages/cli-core/ → @kb-labs/cli-core
254
+ ```
255
+
256
+ **Changes made (2025-11-30):**
257
+ - Renamed 13 packages in `kb-labs-core`
258
+ - Renamed 1 package in `kb-labs-cli`
259
+ - Moved `command-kit` to `kb-labs-shared`
260
+ - Eliminated name collision between framework and CLI commands
261
+ - Updated 50+ dependency references
262
+
263
+ ---
264
+
265
+ ## See Also
266
+
267
+ - [Documentation Guide](./DOCUMENTATION.md) - How to document your product
268
+ - [ADRs](./adr/) - Architecture Decision Records
269
+
270
+ ---
271
+
272
+ **Questions?** Check with the team or open an issue if the naming convention is unclear.
@@ -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,5 @@
1
+ {
2
+ "sync": {
3
+ "enabled": true
4
+ }
5
+ }