@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.
- package/.cursorrules +32 -0
- package/.github/CODEOWNERS +2 -0
- package/.github/actions/setup-node-pnpm/action.yml +47 -0
- package/.github/workflow-templates/ci.yml +13 -0
- package/.github/workflow-templates/drift-check.yml +10 -0
- package/.github/workflow-templates/profiles-validate.yml +16 -0
- package/.github/workflow-templates/release.yml +8 -0
- package/.github/workflows/ci-reusable.yml +131 -0
- package/.github/workflows/drift-check-reusable.yml +23 -0
- package/.github/workflows/fixtures.yml +74 -0
- package/.github/workflows/profiles-validate-reusable.yml +67 -0
- package/.github/workflows/release-reusable.yml +50 -0
- package/.vscode/settings.json +23 -0
- package/AGENTS.md +130 -0
- package/LICENSE +21 -0
- package/README.md +1542 -0
- package/agents/devkit-maintainer/context.globs +15 -0
- package/agents/devkit-maintainer/permissions.yml +17 -0
- package/agents/devkit-maintainer/prompt.md +28 -0
- package/agents/devkit-maintainer/runbook.md +31 -0
- package/agents/docs-crafter/prompt.md +24 -0
- package/agents/docs-crafter/runbook.md +18 -0
- package/agents/release-manager/context.globs +7 -0
- package/agents/release-manager/prompt.md +27 -0
- package/agents/release-manager/runbook.md +17 -0
- package/agents/test-generator/context.globs +7 -0
- package/agents/test-generator/prompt.md +27 -0
- package/agents/test-generator/runbook.md +18 -0
- package/bin/devkit-architecture.mjs +1225 -0
- package/bin/devkit-build-order.mjs +500 -0
- package/bin/devkit-check-build-readiness.mjs +222 -0
- package/bin/devkit-check-commands.mjs +394 -0
- package/bin/devkit-check-configs.mjs +461 -0
- package/bin/devkit-check-deprecated.mjs +532 -0
- package/bin/devkit-check-duplicates.mjs +431 -0
- package/bin/devkit-check-exports.mjs +561 -0
- package/bin/devkit-check-imports.mjs +712 -0
- package/bin/devkit-check-paths.mjs +670 -0
- package/bin/devkit-check-scripts.mjs +335 -0
- package/bin/devkit-check-structure.mjs +495 -0
- package/bin/devkit-check-types.mjs +450 -0
- package/bin/devkit-ci.mjs +261 -0
- package/bin/devkit-core-gate.mjs +225 -0
- package/bin/devkit-fix-deps.mjs +1169 -0
- package/bin/devkit-freshness.mjs +199 -0
- package/bin/devkit-health.mjs +489 -0
- package/bin/devkit-migrate-configs.mjs +370 -0
- package/bin/devkit-paths.mjs +192 -0
- package/bin/devkit-stats.mjs +453 -0
- package/bin/devkit-sync.mjs +12 -0
- package/bin/devkit-tsup-external.mjs +148 -0
- package/bin/devkit-types-audit.mjs +615 -0
- package/bin/devkit-types-order.mjs +637 -0
- package/bin/devkit-validate-naming.mjs +203 -0
- package/bin/devkit-visualize.mjs +452 -0
- package/bin/kb-devkit-qa-history.mjs +453 -0
- package/bin/kb-devkit-qa.mjs +915 -0
- package/eslint/node.js +134 -0
- package/eslint/react.js +260 -0
- package/package.json +186 -0
- package/prettier/index.json +10 -0
- package/sync/index.mjs +693 -0
- package/templates/configs/README.md +306 -0
- package/templates/configs/eslint.config.js +27 -0
- package/templates/configs/package.json.bin +25 -0
- package/templates/configs/package.json.lib +30 -0
- package/templates/configs/tsconfig.build.json +15 -0
- package/templates/configs/tsconfig.json +9 -0
- package/templates/configs/tsup.config.bin.ts +34 -0
- package/templates/configs/tsup.config.cli.ts +41 -0
- package/templates/configs/tsup.config.dual.ts +46 -0
- package/templates/configs/tsup.config.ts +36 -0
- package/templates/package-json/README.md +290 -0
- package/templates/package-json/package.json.bin.template +40 -0
- package/templates/package-json/package.json.template +45 -0
- package/tsconfig/base.json +21 -0
- package/tsconfig/cli.json +12 -0
- package/tsconfig/dist/__tests__/cache.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/cache.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/cache.spec.js +85 -0
- package/tsconfig/dist/__tests__/cache.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/fs-atomic.spec.js +153 -0
- package/tsconfig/dist/__tests__/fs-atomic.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/init-workspace.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/init-workspace.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/init-workspace.spec.js +99 -0
- package/tsconfig/dist/__tests__/init-workspace.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/kb-error.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/kb-error.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/kb-error.spec.js +190 -0
- package/tsconfig/dist/__tests__/kb-error.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/preset-lockfile.spec.js +142 -0
- package/tsconfig/dist/__tests__/preset-lockfile.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/product-config-profiles.spec.js +100 -0
- package/tsconfig/dist/__tests__/product-config-profiles.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/product-config.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/product-config.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/product-config.spec.js +298 -0
- package/tsconfig/dist/__tests__/product-config.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/runtime.spec.d.ts +2 -0
- package/tsconfig/dist/__tests__/runtime.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/runtime.spec.js +127 -0
- package/tsconfig/dist/__tests__/runtime.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts +6 -0
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.js +251 -0
- package/tsconfig/dist/__tests__/upsert-lockfile.spec.js.map +1 -0
- package/tsconfig/dist/__tests__/validate-config.spec.d.ts +2 -0
- package/tsconfig/dist/__tests__/validate-config.spec.d.ts.map +1 -0
- package/tsconfig/dist/__tests__/validate-config.spec.js +14 -0
- package/tsconfig/dist/__tests__/validate-config.spec.js.map +1 -0
- package/tsconfig/dist/api/init-workspace.d.ts +10 -0
- package/tsconfig/dist/api/init-workspace.d.ts.map +1 -0
- package/tsconfig/dist/api/init-workspace.js +191 -0
- package/tsconfig/dist/api/init-workspace.js.map +1 -0
- package/tsconfig/dist/api/product-config.d.ts +21 -0
- package/tsconfig/dist/api/product-config.d.ts.map +1 -0
- package/tsconfig/dist/api/product-config.js +192 -0
- package/tsconfig/dist/api/product-config.js.map +1 -0
- package/tsconfig/dist/api/read-config.d.ts +22 -0
- package/tsconfig/dist/api/read-config.d.ts.map +1 -0
- package/tsconfig/dist/api/read-config.js +105 -0
- package/tsconfig/dist/api/read-config.js.map +1 -0
- package/tsconfig/dist/api/upsert-lockfile.d.ts +10 -0
- package/tsconfig/dist/api/upsert-lockfile.d.ts.map +1 -0
- package/tsconfig/dist/api/upsert-lockfile.js +63 -0
- package/tsconfig/dist/api/upsert-lockfile.js.map +1 -0
- package/tsconfig/dist/cache/fs-cache.d.ts +38 -0
- package/tsconfig/dist/cache/fs-cache.d.ts.map +1 -0
- package/tsconfig/dist/cache/fs-cache.js +142 -0
- package/tsconfig/dist/cache/fs-cache.js.map +1 -0
- package/tsconfig/dist/errors/kb-error.d.ts +32 -0
- package/tsconfig/dist/errors/kb-error.d.ts.map +1 -0
- package/tsconfig/dist/errors/kb-error.js +54 -0
- package/tsconfig/dist/errors/kb-error.js.map +1 -0
- package/tsconfig/dist/fs/__tests__/fs.spec.d.ts +2 -0
- package/tsconfig/dist/fs/__tests__/fs.spec.d.ts.map +1 -0
- package/tsconfig/dist/fs/__tests__/fs.spec.js +22 -0
- package/tsconfig/dist/fs/__tests__/fs.spec.js.map +1 -0
- package/tsconfig/dist/fs/fs.d.ts +6 -0
- package/tsconfig/dist/fs/fs.d.ts.map +1 -0
- package/tsconfig/dist/fs/fs.js +12 -0
- package/tsconfig/dist/fs/fs.js.map +1 -0
- package/tsconfig/dist/fs/index.d.ts +2 -0
- package/tsconfig/dist/fs/index.d.ts.map +1 -0
- package/tsconfig/dist/fs/index.js +2 -0
- package/tsconfig/dist/fs/index.js.map +1 -0
- package/tsconfig/dist/hash/config-hash.d.ts +17 -0
- package/tsconfig/dist/hash/config-hash.d.ts.map +1 -0
- package/tsconfig/dist/hash/config-hash.js +55 -0
- package/tsconfig/dist/hash/config-hash.js.map +1 -0
- package/tsconfig/dist/index.d.ts +5 -0
- package/tsconfig/dist/index.d.ts.map +1 -0
- package/tsconfig/dist/index.js +5 -0
- package/tsconfig/dist/index.js.map +1 -0
- package/tsconfig/dist/lockfile/lockfile.d.ts +54 -0
- package/tsconfig/dist/lockfile/lockfile.d.ts.map +1 -0
- package/tsconfig/dist/lockfile/lockfile.js +141 -0
- package/tsconfig/dist/lockfile/lockfile.js.map +1 -0
- package/tsconfig/dist/logging/__tests__/logger.spec.d.ts +2 -0
- package/tsconfig/dist/logging/__tests__/logger.spec.d.ts.map +1 -0
- package/tsconfig/dist/logging/__tests__/logger.spec.js +65 -0
- package/tsconfig/dist/logging/__tests__/logger.spec.js.map +1 -0
- package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts +2 -0
- package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts.map +1 -0
- package/tsconfig/dist/logging/__tests__/redaction.spec.js +34 -0
- package/tsconfig/dist/logging/__tests__/redaction.spec.js.map +1 -0
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts +2 -0
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts.map +1 -0
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js +90 -0
- package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js.map +1 -0
- package/tsconfig/dist/logging/index.d.ts +6 -0
- package/tsconfig/dist/logging/index.d.ts.map +1 -0
- package/tsconfig/dist/logging/index.js +6 -0
- package/tsconfig/dist/logging/index.js.map +1 -0
- package/tsconfig/dist/logging/logger.d.ts +9 -0
- package/tsconfig/dist/logging/logger.d.ts.map +1 -0
- package/tsconfig/dist/logging/logger.js +101 -0
- package/tsconfig/dist/logging/logger.js.map +1 -0
- package/tsconfig/dist/logging/redaction.d.ts +7 -0
- package/tsconfig/dist/logging/redaction.d.ts.map +1 -0
- package/tsconfig/dist/logging/redaction.js +23 -0
- package/tsconfig/dist/logging/redaction.js.map +1 -0
- package/tsconfig/dist/logging/sinks/json.d.ts +4 -0
- package/tsconfig/dist/logging/sinks/json.d.ts.map +1 -0
- package/tsconfig/dist/logging/sinks/json.js +23 -0
- package/tsconfig/dist/logging/sinks/json.js.map +1 -0
- package/tsconfig/dist/logging/sinks/stdout.d.ts +3 -0
- package/tsconfig/dist/logging/sinks/stdout.d.ts.map +1 -0
- package/tsconfig/dist/logging/sinks/stdout.js +24 -0
- package/tsconfig/dist/logging/sinks/stdout.js.map +1 -0
- package/tsconfig/dist/logging/types/index.d.ts +2 -0
- package/tsconfig/dist/logging/types/index.d.ts.map +1 -0
- package/tsconfig/dist/logging/types/index.js +2 -0
- package/tsconfig/dist/logging/types/index.js.map +1 -0
- package/tsconfig/dist/logging/types/types.d.ts +37 -0
- package/tsconfig/dist/logging/types/types.d.ts.map +1 -0
- package/tsconfig/dist/logging/types/types.js +2 -0
- package/tsconfig/dist/logging/types/types.js.map +1 -0
- package/tsconfig/dist/merge/layered-merge.d.ts +16 -0
- package/tsconfig/dist/merge/layered-merge.d.ts.map +1 -0
- package/tsconfig/dist/merge/layered-merge.js +97 -0
- package/tsconfig/dist/merge/layered-merge.js.map +1 -0
- package/tsconfig/dist/preset/resolve-preset.d.ts +29 -0
- package/tsconfig/dist/preset/resolve-preset.d.ts.map +1 -0
- package/tsconfig/dist/preset/resolve-preset.js +104 -0
- package/tsconfig/dist/preset/resolve-preset.js.map +1 -0
- package/tsconfig/dist/repo/__tests__/repo.spec.d.ts +2 -0
- package/tsconfig/dist/repo/__tests__/repo.spec.d.ts.map +1 -0
- package/tsconfig/dist/repo/__tests__/repo.spec.js +25 -0
- package/tsconfig/dist/repo/__tests__/repo.spec.js.map +1 -0
- package/tsconfig/dist/repo/index.d.ts +2 -0
- package/tsconfig/dist/repo/index.d.ts.map +1 -0
- package/tsconfig/dist/repo/index.js +2 -0
- package/tsconfig/dist/repo/index.js.map +1 -0
- package/tsconfig/dist/repo/repo.d.ts +6 -0
- package/tsconfig/dist/repo/repo.d.ts.map +1 -0
- package/tsconfig/dist/repo/repo.js +25 -0
- package/tsconfig/dist/repo/repo.js.map +1 -0
- package/tsconfig/dist/runtime/index.d.ts +2 -0
- package/tsconfig/dist/runtime/index.d.ts.map +1 -0
- package/tsconfig/dist/runtime/index.js +2 -0
- package/tsconfig/dist/runtime/index.js.map +1 -0
- package/tsconfig/dist/runtime/runtime.d.ts +46 -0
- package/tsconfig/dist/runtime/runtime.d.ts.map +1 -0
- package/tsconfig/dist/runtime/runtime.js +126 -0
- package/tsconfig/dist/runtime/runtime.js.map +1 -0
- package/tsconfig/dist/tsconfig.tools.tsbuildinfo +1 -0
- package/tsconfig/dist/tsconfig.tsbuildinfo +1 -0
- package/tsconfig/dist/types/index.d.ts +2 -0
- package/tsconfig/dist/types/index.d.ts.map +1 -0
- package/tsconfig/dist/types/index.js +2 -0
- package/tsconfig/dist/types/index.js.map +1 -0
- package/tsconfig/dist/types/init.d.ts +34 -0
- package/tsconfig/dist/types/init.d.ts.map +1 -0
- package/tsconfig/dist/types/init.js +6 -0
- package/tsconfig/dist/types/init.js.map +1 -0
- package/tsconfig/dist/types/preset.d.ts +27 -0
- package/tsconfig/dist/types/preset.d.ts.map +1 -0
- package/tsconfig/dist/types/preset.js +6 -0
- package/tsconfig/dist/types/preset.js.map +1 -0
- package/tsconfig/dist/types/types.d.ts +6 -0
- package/tsconfig/dist/types/types.d.ts.map +1 -0
- package/tsconfig/dist/types/types.js +2 -0
- package/tsconfig/dist/types/types.js.map +1 -0
- package/tsconfig/dist/utils/__tests__/env.spec.d.ts +2 -0
- package/tsconfig/dist/utils/__tests__/env.spec.d.ts.map +1 -0
- package/tsconfig/dist/utils/__tests__/env.spec.js +33 -0
- package/tsconfig/dist/utils/__tests__/env.spec.js.map +1 -0
- package/tsconfig/dist/utils/env.d.ts +7 -0
- package/tsconfig/dist/utils/env.d.ts.map +1 -0
- package/tsconfig/dist/utils/env.js +25 -0
- package/tsconfig/dist/utils/env.js.map +1 -0
- package/tsconfig/dist/utils/fs-atomic.d.ts +15 -0
- package/tsconfig/dist/utils/fs-atomic.d.ts.map +1 -0
- package/tsconfig/dist/utils/fs-atomic.js +45 -0
- package/tsconfig/dist/utils/fs-atomic.js.map +1 -0
- package/tsconfig/dist/utils/index.d.ts +3 -0
- package/tsconfig/dist/utils/index.d.ts.map +1 -0
- package/tsconfig/dist/utils/index.js +3 -0
- package/tsconfig/dist/utils/index.js.map +1 -0
- package/tsconfig/dist/utils/paths.d.ts +21 -0
- package/tsconfig/dist/utils/paths.d.ts.map +1 -0
- package/tsconfig/dist/utils/paths.js +32 -0
- package/tsconfig/dist/utils/paths.js.map +1 -0
- package/tsconfig/dist/utils/product-normalize.d.ts +27 -0
- package/tsconfig/dist/utils/product-normalize.d.ts.map +1 -0
- package/tsconfig/dist/utils/product-normalize.js +45 -0
- package/tsconfig/dist/utils/product-normalize.js.map +1 -0
- package/tsconfig/dist/validation/validate-config.d.ts +7 -0
- package/tsconfig/dist/validation/validate-config.d.ts.map +1 -0
- package/tsconfig/dist/validation/validate-config.js +22 -0
- package/tsconfig/dist/validation/validate-config.js.map +1 -0
- package/tsconfig/lib.json +13 -0
- package/tsconfig/node.json +12 -0
- package/tsconfig/react-app.json +8 -0
- package/tsconfig/react-lib.json +8 -0
- package/tsconfig/test.json +15 -0
- package/tsup/bin.js +172 -0
- package/tsup/dual.js +155 -0
- package/tsup/external-sync.mjs +41 -0
- package/tsup/external.mjs +109 -0
- package/tsup/node.js +65 -0
- package/tsup/react-lib.js +18 -0
- package/tsup/sdk.js +118 -0
- package/vite/react-app.js +50 -0
- package/vitest/node.js +37 -0
- package/vitest/react.js +39 -0
- 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,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
|
+
});
|