@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,179 @@
1
+ # @kb-labs/adapters-{name}
2
+
3
+ > Part of [KB Labs](https://github.com/KirillBaranov/kb-labs) ecosystem. Works exclusively within KB Labs platform.
4
+
5
+ {Short description of what this adapter does and why it exists.}
6
+
7
+ ## Overview
8
+
9
+ | Property | Value |
10
+ |----------|-------|
11
+ | **Implements** | `I{Interface}` |
12
+ | **Type** | `core` / `extension` |
13
+ | **Requires** | `cache`, `db`, ... (or "None") |
14
+ | **Category** | Logging / Database / Cache / EventBus / Analytics / AI / Storage |
15
+
16
+ ## Features
17
+
18
+ - **Feature 1** - Brief description
19
+ - **Feature 2** - Brief description
20
+ - **Feature 3** - Brief description
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pnpm add @kb-labs/adapters-{name}
26
+ ```
27
+
28
+ ## Configuration
29
+
30
+ Add to your `kb.config.json`:
31
+
32
+ ```json
33
+ {
34
+ "platform": {
35
+ "adapters": {
36
+ "{adapterKey}": "@kb-labs/adapters-{name}"
37
+ },
38
+ "adapterOptions": {
39
+ "{adapterKey}": {
40
+ "option1": "value1",
41
+ "option2": 1000
42
+ }
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ### Options
49
+
50
+ | Option | Type | Default | Description |
51
+ |--------|------|---------|-------------|
52
+ | `option1` | `string` | `"default"` | Description of option1 |
53
+ | `option2` | `number` | `1000` | Description of option2 |
54
+
55
+ ## Usage
56
+
57
+ ### Via Platform (Recommended)
58
+
59
+ ```typescript
60
+ import { usePlatform } from '@kb-labs/sdk';
61
+
62
+ const platform = usePlatform();
63
+
64
+ // Use the adapter via platform
65
+ await platform.{adapterKey}.method();
66
+ ```
67
+
68
+ ### Standalone (Testing/Development)
69
+
70
+ ```typescript
71
+ import { createAdapter } from '@kb-labs/adapters-{name}';
72
+
73
+ const adapter = createAdapter(
74
+ { option1: 'value1' },
75
+ { dependency: dependencyInstance }
76
+ );
77
+ ```
78
+
79
+ ## How It Works
80
+
81
+ {Technical explanation of how the adapter works internally. Include diagrams if helpful.}
82
+
83
+ ```
84
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
85
+ │ Client │────▶│ Adapter │────▶│ Backend │
86
+ └─────────────┘ └─────────────┘ └─────────────┘
87
+ ```
88
+
89
+ ## Dependencies
90
+
91
+ This adapter requires the following adapters to be configured:
92
+
93
+ | Dependency | Adapter Key | Description |
94
+ |------------|-------------|-------------|
95
+ | `cache` | `cache` | Cache backend for storage |
96
+
97
+ > Dependencies are automatically resolved by the platform's AdapterLoader.
98
+
99
+ ## Adapter Manifest
100
+
101
+ ```typescript
102
+ {
103
+ id: '{name}',
104
+ name: '{Human-readable Name}',
105
+ version: '1.0.0',
106
+ implements: 'I{Interface}',
107
+ requires: {
108
+ adapters: [{ id: 'cache', alias: 'cache' }],
109
+ platform: '>= 1.0.0',
110
+ },
111
+ capabilities: {
112
+ // Adapter-specific capabilities
113
+ },
114
+ }
115
+ ```
116
+
117
+ ## Performance Considerations
118
+
119
+ - **Memory**: {Memory usage notes}
120
+ - **Latency**: {Latency expectations}
121
+ - **Throughput**: {Throughput notes}
122
+
123
+ ## FAQ
124
+
125
+ <details>
126
+ <summary><strong>Q: Can I use this adapter outside KB Labs platform?</strong></summary>
127
+
128
+ No. This adapter is designed specifically for KB Labs ecosystem and depends on platform interfaces and contracts. Use `createAdapter()` for standalone testing only.
129
+ </details>
130
+
131
+ <details>
132
+ <summary><strong>Q: How do I switch between different implementations?</strong></summary>
133
+
134
+ Change the adapter package in `kb.config.json`:
135
+
136
+ ```json
137
+ {
138
+ "platform": {
139
+ "adapters": {
140
+ "{adapterKey}": "@kb-labs/adapters-{alternative-name}"
141
+ }
142
+ }
143
+ }
144
+ ```
145
+ </details>
146
+
147
+ <details>
148
+ <summary><strong>Q: {Common question about this adapter}</strong></summary>
149
+
150
+ {Answer}
151
+ </details>
152
+
153
+ ## Related Adapters
154
+
155
+ | Adapter | Use Case |
156
+ |---------|----------|
157
+ | `@kb-labs/adapters-{related1}` | Alternative for {use case} |
158
+ | `@kb-labs/adapters-{related2}` | Complementary for {use case} |
159
+
160
+ ## Troubleshooting
161
+
162
+ ### Error: {Common error message}
163
+
164
+ **Cause**: {Why this happens}
165
+
166
+ **Solution**: {How to fix}
167
+
168
+ ```bash
169
+ # Example fix command
170
+ pnpm kb plugins clear-cache
171
+ ```
172
+
173
+ ## Contributing
174
+
175
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development guidelines.
176
+
177
+ ## License
178
+
179
+ [KB Public License v1.1](../../LICENSE) - KB Labs Team
package/README.md ADDED
@@ -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,74 @@
1
+ # KB Labs Product Template Documentation Standard
2
+
3
+ > **This document is a project-specific copy of the KB Labs Documentation Standard.**
4
+ > See [Main Documentation Standard](https://github.com/KirillBaranov/kb-labs/blob/main/docs/DOCUMENTATION.md) for the complete ecosystem standard.
5
+
6
+ This document defines the documentation standards for **KB Labs Product Template**. This project follows the [KB Labs Documentation Standard](https://github.com/KirillBaranov/kb-labs/blob/main/docs/DOCUMENTATION.md) with the following project-specific customizations:
7
+
8
+ ## Project-Specific Customizations
9
+
10
+ KB Labs Product Template is a zero-config starter powered by @kb-labs/devkit. Documentation should focus on:
11
+
12
+ - Project scaffolding
13
+ - Quick start guide
14
+ - Template customization
15
+ - Best practices for new projects
16
+
17
+ ## Project Documentation Structure
18
+
19
+ ```
20
+ docs/
21
+ ├── DOCUMENTATION.md # This standard (REQUIRED)
22
+ └── adr/ # Architecture Decision Records
23
+ ├── 0000-template.md # ADR template
24
+ └── *.md # ADR files
25
+ ```
26
+
27
+ ## Required Documentation
28
+
29
+ This project requires:
30
+
31
+ - [x] `README.md` in root with all required sections
32
+ - [x] `CONTRIBUTING.md` in root with development guidelines
33
+ - [x] `docs/DOCUMENTATION.md` (this file)
34
+ - [x] `docs/adr/0000-template.md` (ADR template exists)
35
+ - [x] `LICENSE` in root
36
+
37
+ ## Optional Documentation
38
+
39
+ Consider adding:
40
+
41
+ - [ ] `docs/glossary.md` - Template-specific terms
42
+ - [ ] `docs/examples.md` - Template usage examples
43
+ - [ ] `docs/faq.md` - Frequently asked questions
44
+
45
+ ## ADR Requirements
46
+
47
+ All ADRs must follow the format defined in the [main standard](https://github.com/KirillBaranov/kb-labs/blob/main/docs/DOCUMENTATION.md#architecture-decision-records-adr) with:
48
+
49
+ - Required metadata: Date, Status, Deciders, Last Reviewed, Tags
50
+ - Minimum 1 tag, maximum 5 tags
51
+ - Tags from approved list
52
+ - See main standard `docs/templates/ADR.template.md` for template
53
+
54
+ ## Cross-Linking
55
+
56
+ This project links to:
57
+
58
+ **Dependencies:**
59
+ - [@kb-labs/devkit](https://github.com/KirillBaranov/kb-labs-devkit) - DevKit presets
60
+
61
+ **Used By:**
62
+ - New KB Labs projects for scaffolding
63
+
64
+ **Ecosystem:**
65
+ - [KB Labs](https://github.com/KirillBaranov/kb-labs) - Main ecosystem repository
66
+
67
+ ---
68
+
69
+ **Last Updated:** 2025-11-03
70
+ **Standard Version:** 1.0 (following KB Labs ecosystem standard)
71
+ **See Main Standard:** [KB Labs Documentation Standard](https://github.com/KirillBaranov/kb-labs/blob/main/docs/DOCUMENTATION.md)
72
+
73
+
74
+
@@ -0,0 +1,49 @@
1
+ # ADR-XXXX: [Brief Decision Title]
2
+
3
+ **Date:** YYYY-MM-DD
4
+ **Status:** Proposed | Accepted | Deprecated | Superseded
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** YYYY-MM-DD
7
+ **Reviewers:** [Optional list of reviewers]
8
+ **Tags:** [tag1, tag2, tag3]
9
+
10
+ > **Note:** Tags are mandatory. Minimum 1 tag, maximum 5 tags. See approved tags list in [DOCUMENTATION.md](../DOCUMENTATION.md#adr-tags).
11
+
12
+ ## Context
13
+
14
+ _Describe the problem or situation that necessitated this decision._
15
+ _What alternatives were considered? What constraints exist?_
16
+
17
+ ## Decision
18
+
19
+ _Describe the decision that was made. Key aspects: structure, tools, practices._
20
+ _Include diagrams or schemas if applicable._
21
+
22
+ ## Consequences
23
+
24
+ ### Positive
25
+
26
+ - Benefits of the chosen solution
27
+
28
+ ### Negative
29
+
30
+ - Drawbacks and risks
31
+
32
+ ### Alternatives Considered
33
+
34
+ - Why other options were rejected
35
+
36
+ ## Implementation
37
+
38
+ _What changes after this decision is made? What processes or code need to be updated?_
39
+ _Will this decision be revisited in the future?_
40
+
41
+ ## References
42
+
43
+ - [Discussion / Pull Request](url)
44
+ - [Related ADRs](./0000-other-decision.md)
45
+
46
+ ---
47
+
48
+ **Last Updated:** YYYY-MM-DD
49
+ **Next Review:** YYYY-MM-DD (if scheduled)
@@ -0,0 +1,33 @@
1
+ # ADR-0001: Architecture and Repository Layout
2
+
3
+ **Date:** 2025-09-13
4
+ **Status:** Accepted
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [architecture, tooling]
8
+
9
+ ## Context
10
+
11
+ KB Labs products must be consistent across repositories. Each repository should follow the same monorepo-style layout to support apps, packages, and fixtures.
12
+
13
+ ## Decision
14
+
15
+ - Use PNPM workspaces for package management
16
+ - Repository root must contain:
17
+ - `/apps` — example/demo apps or product UI
18
+ - `/packages` — core logic, reusable libraries, domain modules
19
+ - `/fixtures` — sample diffs, test inputs, reference data
20
+ - `/docs` — ADRs, handbook, guides
21
+ - Shared configs (tsconfig, eslint, prettier, vitest) live in root
22
+
23
+ ## Consequences
24
+
25
+ **Positive:**
26
+
27
+ - Consistent developer experience across products
28
+ - Easy onboarding: all repositories look alike
29
+ - Enables cross-product reuse of tools/scripts
30
+
31
+ **Negative:**
32
+
33
+ - Initial setup complexity for new repositories
@@ -0,0 +1,46 @@
1
+ # ADR-0002: Plugins and Extensibility
2
+
3
+ **Date:** 2025-09-13
4
+ **Status:** Accepted
5
+ **Deciders:** KB Labs Team
6
+ **Last Reviewed:** 2025-11-03
7
+ **Tags:** [architecture, api]
8
+
9
+ ## Context
10
+
11
+ KB Labs products are designed to be reusable across different stacks, domains, and teams. To ensure long-term scalability, all products (AI Review, AI Docs, AI Tests, etc.) must support a flexible plugin & extension system. Without this, every new feature would require hardcoding into the core, increasing maintenance burden and reducing adaptability.
12
+
13
+ ## Decision
14
+
15
+ - Each KB Labs product must expose a plugin API that allows third-party developers (or other KB Labs packages) to extend behavior without modifying the core
16
+ - The plugin system must be:
17
+ 1. **Isolated** — Plugins run in a sandboxed scope and cannot break the core
18
+ 2. **Composable** — Multiple plugins can be combined in one pipeline
19
+ 3. **Discoverable** — Plugins are registered via a central registry (`plugins/index.ts`) or a configuration file (`.kblabsrc.json`)
20
+ 4. **Typed** — All plugin interfaces must be defined in `@kb-labs/core` using TypeScript types and Zod schemas
21
+ 5. **Cross-product** — The same plugin (e.g., a Slack notifier) can be reused in AI Review, AI Docs, and AI Tests without rewriting
22
+
23
+ ## Examples
24
+
25
+ - **AI Review** — rule providers, LLM strategies, custom output formatters
26
+ - **AI Docs** — content generators, format exporters (Markdown, HTML, Confluence)
27
+ - **AI Tests** — test strategy plugins, snapshot comparators
28
+ - **Shared** — analytics/logging, secret providers, budget control
29
+
30
+ ## Consequences
31
+
32
+ **Positive:**
33
+
34
+ - Easier to onboard contributors: they extend via plugins instead of modifying the core
35
+ - Ensures product consistency: every KB Labs product has the same extensibility model
36
+ - Avoids long-term lock-in
37
+
38
+ **Negative:**
39
+
40
+ - Core complexity increases slightly
41
+ - Additional abstraction layer to maintain
42
+
43
+ ## Alternatives Considered
44
+
45
+ - **Hardcoded integrations** — rejected (not scalable, not reusable)
46
+ - **Separate extension repositories** — rejected (too fragmented, harder to maintain)