@kb-labs/scaffold-contracts 2.29.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.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @module @kb-labs/scaffold-contracts
3
+ *
4
+ * Public types for the scaffold engine. The engine is entity-agnostic —
5
+ * entities (plugin, adapter, etc.) are described declaratively via
6
+ * `entity.yaml` + block directories. These types form the shape that
7
+ * YAML is parsed into.
8
+ */
9
+ type VariableType = 'string' | 'boolean' | 'select' | 'multiselect';
10
+ type VariableValidator = 'identifier' | 'npmName' | 'semver' | 'npmScope';
11
+ interface VariableChoice {
12
+ value: string;
13
+ label: string;
14
+ }
15
+ interface Variable {
16
+ name: string;
17
+ type: VariableType;
18
+ describe: string;
19
+ default?: unknown;
20
+ choices?: VariableChoice[];
21
+ /** Simple boolean expression, e.g. `blocks.includes("rest")`. */
22
+ when?: string;
23
+ validate?: VariableValidator;
24
+ }
25
+ interface BlockDefinition {
26
+ id: string;
27
+ describe: string;
28
+ requires?: string[];
29
+ conflicts?: string[];
30
+ variables?: Variable[];
31
+ /** Absolute path to the block's `files/` directory. */
32
+ filesDir: string;
33
+ /** Absolute path to `manifest.patch.yaml`, if the block contributes one. */
34
+ manifestPatch?: string;
35
+ /** Absolute path to `manifest.snippets.yaml`, for TS-string contributions. */
36
+ snippetsPath?: string;
37
+ }
38
+ interface EntityDefinition {
39
+ id: string;
40
+ displayName: string;
41
+ description?: string;
42
+ variables: Variable[];
43
+ blocks: BlockDefinition[];
44
+ defaults?: {
45
+ blocks?: string[];
46
+ };
47
+ /**
48
+ * Output path template evaluated with entity + user variables.
49
+ * Example: `.kb/plugins/{{name}}` or `plugins/{{name}}`.
50
+ */
51
+ output?: string;
52
+ /**
53
+ * Relative path inside the scaffolded output where the generated
54
+ * `manifest.ts` should land. Template-evaluated. Defaults to
55
+ * `src/manifest.ts` (suitable for flat adapter layouts).
56
+ */
57
+ manifestTarget?: string;
58
+ }
59
+ type ScaffoldMode = 'in-workspace' | 'standalone';
60
+ interface RenderContext {
61
+ name: string;
62
+ scope: string;
63
+ vars: Record<string, unknown>;
64
+ blocks: string[];
65
+ mode: ScaffoldMode;
66
+ versions: Record<string, string>;
67
+ }
68
+ interface RenderedFile {
69
+ /** Path relative to the scaffold output root. */
70
+ path: string;
71
+ contents: string;
72
+ /** If true, preserve executable bit on unix. */
73
+ executable?: boolean;
74
+ }
75
+ /**
76
+ * Deep-mergeable patch applied on top of the V3 manifest skeleton produced
77
+ * by the `base` block. Arrays of objects with `id` or `name` are merged as
78
+ * unions by key; primitive arrays are Set-deduped.
79
+ */
80
+ type ManifestPatch = Record<string, unknown>;
81
+ interface PatchContext {
82
+ vars: Record<string, unknown>;
83
+ blocks: string[];
84
+ }
85
+ /**
86
+ * TS-string snippets contributed by blocks and composed into the final
87
+ * `src/manifest.ts` (imports, permissions fragments, etc.).
88
+ */
89
+ interface ManifestSnippets {
90
+ imports?: string[];
91
+ permissions?: string[];
92
+ extras?: Record<string, string[]>;
93
+ }
94
+
95
+ export type { BlockDefinition, EntityDefinition, ManifestPatch, ManifestSnippets, PatchContext, RenderContext, RenderedFile, ScaffoldMode, Variable, VariableChoice, VariableType, VariableValidator };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@kb-labs/scaffold-contracts",
3
+ "version": "2.29.0",
4
+ "type": "module",
5
+ "description": "Public types for the KB Labs scaffold engine (entity, block, manifest patch).",
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
+ "./dist/*": "./dist/*"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "sideEffects": false,
19
+ "dependencies": {},
20
+ "devDependencies": {
21
+ "@types/node": "^24.3.3",
22
+ "eslint": "^9",
23
+ "rimraf": "^6.0.1",
24
+ "tsup": "^8.5.0",
25
+ "typescript": "^5.6.3",
26
+ "vitest": "^3.2.4",
27
+ "@kb-labs/devkit": "2.29.0"
28
+ },
29
+ "engines": {
30
+ "node": ">=20.0.0",
31
+ "pnpm": ">=9.0.0"
32
+ },
33
+ "scripts": {
34
+ "clean": "rimraf dist",
35
+ "build": "tsup --config tsup.config.ts",
36
+ "dev": "tsup --config tsup.config.ts --watch",
37
+ "lint": "eslint src --ext .ts",
38
+ "lint:fix": "eslint . --fix",
39
+ "type-check": "tsc --noEmit",
40
+ "test": "vitest run --passWithNoTests",
41
+ "test:watch": "vitest"
42
+ }
43
+ }