@kb-labs/core-config 1.2.0 → 1.4.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/dist/index.d.ts +1016 -25
- package/dist/index.js +1533 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/__tests__/cache.spec.d.ts +0 -6
- package/dist/__tests__/cache.spec.d.ts.map +0 -1
- package/dist/__tests__/cache.spec.js +0 -87
- package/dist/__tests__/cache.spec.js.map +0 -1
- package/dist/__tests__/fs-atomic.spec.d.ts +0 -6
- package/dist/__tests__/fs-atomic.spec.d.ts.map +0 -1
- package/dist/__tests__/fs-atomic.spec.js +0 -153
- package/dist/__tests__/fs-atomic.spec.js.map +0 -1
- package/dist/__tests__/get-product-config-edge-cases.spec.d.ts +0 -6
- package/dist/__tests__/get-product-config-edge-cases.spec.d.ts.map +0 -1
- package/dist/__tests__/get-product-config-edge-cases.spec.js +0 -334
- package/dist/__tests__/get-product-config-edge-cases.spec.js.map +0 -1
- package/dist/__tests__/init-workspace.spec.d.ts +0 -6
- package/dist/__tests__/init-workspace.spec.d.ts.map +0 -1
- package/dist/__tests__/init-workspace.spec.js +0 -101
- package/dist/__tests__/init-workspace.spec.js.map +0 -1
- package/dist/__tests__/kb-error.spec.d.ts +0 -6
- package/dist/__tests__/kb-error.spec.d.ts.map +0 -1
- package/dist/__tests__/kb-error.spec.js +0 -193
- package/dist/__tests__/kb-error.spec.js.map +0 -1
- package/dist/__tests__/preset-lockfile.spec.d.ts +0 -6
- package/dist/__tests__/preset-lockfile.spec.d.ts.map +0 -1
- package/dist/__tests__/preset-lockfile.spec.js +0 -142
- package/dist/__tests__/preset-lockfile.spec.js.map +0 -1
- package/dist/__tests__/product-config-profiles.spec.d.ts +0 -6
- package/dist/__tests__/product-config-profiles.spec.d.ts.map +0 -1
- package/dist/__tests__/product-config-profiles.spec.js +0 -82
- package/dist/__tests__/product-config-profiles.spec.js.map +0 -1
- package/dist/__tests__/product-config.spec.d.ts +0 -6
- package/dist/__tests__/product-config.spec.d.ts.map +0 -1
- package/dist/__tests__/product-config.spec.js +0 -304
- package/dist/__tests__/product-config.spec.js.map +0 -1
- package/dist/__tests__/profiles-demo.d.ts +0 -11
- package/dist/__tests__/profiles-demo.d.ts.map +0 -1
- package/dist/__tests__/profiles-demo.js +0 -173
- package/dist/__tests__/profiles-demo.js.map +0 -1
- package/dist/__tests__/profiles-resolver.spec.d.ts +0 -2
- package/dist/__tests__/profiles-resolver.spec.d.ts.map +0 -1
- package/dist/__tests__/profiles-resolver.spec.js +0 -114
- package/dist/__tests__/profiles-resolver.spec.js.map +0 -1
- package/dist/__tests__/profiles-section.spec.d.ts +0 -2
- package/dist/__tests__/profiles-section.spec.d.ts.map +0 -1
- package/dist/__tests__/profiles-section.spec.js +0 -50
- package/dist/__tests__/profiles-section.spec.js.map +0 -1
- package/dist/__tests__/runtime.spec.d.ts +0 -2
- package/dist/__tests__/runtime.spec.d.ts.map +0 -1
- package/dist/__tests__/runtime.spec.js +0 -170
- package/dist/__tests__/runtime.spec.js.map +0 -1
- package/dist/__tests__/upsert-lockfile.spec.d.ts +0 -1
- package/dist/__tests__/upsert-lockfile.spec.d.ts.map +0 -1
- package/dist/__tests__/upsert-lockfile.spec.js +0 -2
- package/dist/__tests__/upsert-lockfile.spec.js.map +0 -1
- package/dist/__tests__/validate-config.spec.d.ts +0 -2
- package/dist/__tests__/validate-config.spec.d.ts.map +0 -1
- package/dist/__tests__/validate-config.spec.js +0 -14
- package/dist/__tests__/validate-config.spec.js.map +0 -1
- package/dist/api/init-workspace.d.ts +0 -10
- package/dist/api/init-workspace.d.ts.map +0 -1
- package/dist/api/init-workspace.js +0 -186
- package/dist/api/init-workspace.js.map +0 -1
- package/dist/api/product-config.d.ts +0 -20
- package/dist/api/product-config.d.ts.map +0 -1
- package/dist/api/product-config.js +0 -236
- package/dist/api/product-config.js.map +0 -1
- package/dist/api/read-config.d.ts +0 -22
- package/dist/api/read-config.d.ts.map +0 -1
- package/dist/api/read-config.js +0 -112
- package/dist/api/read-config.js.map +0 -1
- package/dist/api/read-kb-config.d.ts +0 -12
- package/dist/api/read-kb-config.d.ts.map +0 -1
- package/dist/api/read-kb-config.js +0 -47
- package/dist/api/read-kb-config.js.map +0 -1
- package/dist/api/upsert-lockfile.d.ts +0 -10
- package/dist/api/upsert-lockfile.d.ts.map +0 -1
- package/dist/api/upsert-lockfile.js +0 -63
- package/dist/api/upsert-lockfile.js.map +0 -1
- package/dist/cache/fs-cache.d.ts +0 -38
- package/dist/cache/fs-cache.d.ts.map +0 -1
- package/dist/cache/fs-cache.js +0 -142
- package/dist/cache/fs-cache.js.map +0 -1
- package/dist/errors/kb-error.d.ts +0 -35
- package/dist/errors/kb-error.d.ts.map +0 -1
- package/dist/errors/kb-error.js +0 -57
- package/dist/errors/kb-error.js.map +0 -1
- package/dist/hash/config-hash.d.ts +0 -17
- package/dist/hash/config-hash.d.ts.map +0 -1
- package/dist/hash/config-hash.js +0 -55
- package/dist/hash/config-hash.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lockfile/lockfile.d.ts +0 -53
- package/dist/lockfile/lockfile.d.ts.map +0 -1
- package/dist/lockfile/lockfile.js +0 -142
- package/dist/lockfile/lockfile.js.map +0 -1
- package/dist/merge/layered-merge.d.ts +0 -16
- package/dist/merge/layered-merge.d.ts.map +0 -1
- package/dist/merge/layered-merge.js +0 -87
- package/dist/merge/layered-merge.js.map +0 -1
- package/dist/preset/resolve-preset.d.ts +0 -28
- package/dist/preset/resolve-preset.d.ts.map +0 -1
- package/dist/preset/resolve-preset.js +0 -104
- package/dist/preset/resolve-preset.js.map +0 -1
- package/dist/profiles/loader.d.ts +0 -12
- package/dist/profiles/loader.d.ts.map +0 -1
- package/dist/profiles/loader.js +0 -34
- package/dist/profiles/loader.js.map +0 -1
- package/dist/profiles/resolver.d.ts +0 -11
- package/dist/profiles/resolver.d.ts.map +0 -1
- package/dist/profiles/resolver.js +0 -252
- package/dist/profiles/resolver.js.map +0 -1
- package/dist/profiles/scope-selector.d.ts +0 -19
- package/dist/profiles/scope-selector.d.ts.map +0 -1
- package/dist/profiles/scope-selector.js +0 -64
- package/dist/profiles/scope-selector.js.map +0 -1
- package/dist/profiles/types.d.ts +0 -462
- package/dist/profiles/types.d.ts.map +0 -1
- package/dist/profiles/types.js +0 -68
- package/dist/profiles/types.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -2
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -2
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/runtime.d.ts +0 -46
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/runtime.js +0 -126
- package/dist/runtime/runtime.js.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/init.d.ts +0 -33
- package/dist/types/init.d.ts.map +0 -1
- package/dist/types/init.js +0 -6
- package/dist/types/init.js.map +0 -1
- package/dist/types/preset.d.ts +0 -27
- package/dist/types/preset.d.ts.map +0 -1
- package/dist/types/preset.js +0 -6
- package/dist/types/preset.js.map +0 -1
- package/dist/types/types.d.ts +0 -70
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -2
- package/dist/types/types.js.map +0 -1
- package/dist/utils/__tests__/env.spec.d.ts +0 -2
- package/dist/utils/__tests__/env.spec.d.ts.map +0 -1
- package/dist/utils/__tests__/env.spec.js +0 -33
- package/dist/utils/__tests__/env.spec.js.map +0 -1
- package/dist/utils/env.d.ts +0 -7
- package/dist/utils/env.d.ts.map +0 -1
- package/dist/utils/env.js +0 -25
- package/dist/utils/env.js.map +0 -1
- package/dist/utils/fs-atomic.d.ts +0 -15
- package/dist/utils/fs-atomic.d.ts.map +0 -1
- package/dist/utils/fs-atomic.js +0 -46
- package/dist/utils/fs-atomic.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -3
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -21
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js +0 -32
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/product-normalize.d.ts +0 -25
- package/dist/utils/product-normalize.d.ts.map +0 -1
- package/dist/utils/product-normalize.js +0 -48
- package/dist/utils/product-normalize.js.map +0 -1
- package/dist/validation/validate-config.d.ts +0 -10
- package/dist/validation/validate-config.d.ts.map +0 -1
- package/dist/validation/validate-config.js +0 -21
- package/dist/validation/validate-config.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,1016 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type Diagnostic = {
|
|
4
|
+
level: "warn" | "error";
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
detail?: unknown;
|
|
8
|
+
} | {
|
|
9
|
+
level: "info";
|
|
10
|
+
code: string;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
type JsonReadResult<T = unknown> = {
|
|
14
|
+
ok: true;
|
|
15
|
+
data: T;
|
|
16
|
+
diagnostics: Diagnostic[];
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
diagnostics: Diagnostic[];
|
|
20
|
+
};
|
|
21
|
+
interface FindNearestConfigOpts {
|
|
22
|
+
startDir?: string;
|
|
23
|
+
stopDir?: string;
|
|
24
|
+
filenames: string[];
|
|
25
|
+
}
|
|
26
|
+
interface ProfilesConfig {
|
|
27
|
+
rootDir?: string;
|
|
28
|
+
defaultName?: string;
|
|
29
|
+
strict?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface KBConfig {
|
|
32
|
+
profiles?: ProfilesConfig;
|
|
33
|
+
}
|
|
34
|
+
interface MergeTrace {
|
|
35
|
+
path: string;
|
|
36
|
+
source: string;
|
|
37
|
+
type: 'set' | 'overwriteArray';
|
|
38
|
+
layer: string;
|
|
39
|
+
profileRef?: string;
|
|
40
|
+
presetRef?: string;
|
|
41
|
+
version?: string;
|
|
42
|
+
}
|
|
43
|
+
interface ProfileLayerInput {
|
|
44
|
+
profileId: string;
|
|
45
|
+
source: string;
|
|
46
|
+
products?: Record<string, unknown>;
|
|
47
|
+
scope?: {
|
|
48
|
+
id: string;
|
|
49
|
+
source: string;
|
|
50
|
+
products?: Record<string, unknown>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
interface ResolveOptions {
|
|
54
|
+
cwd: string;
|
|
55
|
+
/**
|
|
56
|
+
* Product identifier (e.g., 'mind', 'aiReview', 'workflow')
|
|
57
|
+
*/
|
|
58
|
+
product: string;
|
|
59
|
+
cli?: Record<string, unknown>;
|
|
60
|
+
writeFinal?: boolean;
|
|
61
|
+
profileLayer?: ProfileLayerInput;
|
|
62
|
+
}
|
|
63
|
+
interface ConfigLayer {
|
|
64
|
+
label: string;
|
|
65
|
+
value: any;
|
|
66
|
+
source: string;
|
|
67
|
+
}
|
|
68
|
+
interface ProductConfigResult<T = Record<string, any>> {
|
|
69
|
+
config: T;
|
|
70
|
+
trace: MergeTrace[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @module @kb-labs/core/config/runtime
|
|
75
|
+
* Infrastructure-only config pipeline (no domain keys).
|
|
76
|
+
* Provides: nearest config discovery, safe JSON read with diagnostics,
|
|
77
|
+
* deep merge that ignores `undefined`, and a generic resolver (defaults→file→env→cli).
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/** Find nearest config file walking up from startDir until stopDir or FS root. */
|
|
81
|
+
declare function findNearestConfig(opts: FindNearestConfigOpts): Promise<{
|
|
82
|
+
path: string | null;
|
|
83
|
+
tried: string[];
|
|
84
|
+
}>;
|
|
85
|
+
/** Read JSON with explicit diagnostics (no silent nulls). */
|
|
86
|
+
declare function readJsonWithDiagnostics<T = unknown>(p: string): Promise<JsonReadResult<T>>;
|
|
87
|
+
/** Shallow pick of defined fields only. */
|
|
88
|
+
declare function pickDefined<T extends Record<string, any>>(obj: T | undefined): Partial<T>;
|
|
89
|
+
/** Deep merge (objects/arrays), ignoring `undefined` on the overlay. */
|
|
90
|
+
declare function mergeDefined<T>(base: T, over?: Partial<T>): T;
|
|
91
|
+
declare const SYSTEM_DEFAULTS: {
|
|
92
|
+
readonly profiles: {
|
|
93
|
+
readonly rootDir: ".kb/profiles";
|
|
94
|
+
readonly defaultName: "default";
|
|
95
|
+
readonly strict: true;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
interface ResolveConfigArgs<TConfig, _TEnvMap = unknown> {
|
|
99
|
+
defaults: TConfig;
|
|
100
|
+
fileConfig?: Partial<TConfig>;
|
|
101
|
+
envMapper?: (env: NodeJS.ProcessEnv) => Partial<TConfig> | undefined;
|
|
102
|
+
cliOverrides?: Partial<TConfig>;
|
|
103
|
+
validate?: (cfg: TConfig) => {
|
|
104
|
+
ok: boolean;
|
|
105
|
+
diagnostics?: Diagnostic[];
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Generic resolver: defaults → fileConfig → envMapper(process.env) → cliOverrides.
|
|
110
|
+
* No domain keys inside; mapping/validation provided by the product/shared layer.
|
|
111
|
+
*/
|
|
112
|
+
declare function resolveConfig<TConfig>(args: ResolveConfigArgs<TConfig>): {
|
|
113
|
+
value: TConfig;
|
|
114
|
+
diagnostics: Diagnostic[];
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @module @kb-labs/core/utils/env
|
|
119
|
+
* Small helpers to convert ENV strings to typed values.
|
|
120
|
+
*/
|
|
121
|
+
declare function toBool(v: string | undefined): boolean | undefined;
|
|
122
|
+
declare function toInt(v: string | undefined): number | undefined;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @module @kb-labs/core/config/utils/product-normalize
|
|
126
|
+
* Product ID normalization between code (camelCase) and filesystem (kebab-case)
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* Convert product ID to filesystem kebab-case format
|
|
130
|
+
* @param id Product ID (e.g., 'aiReview', 'mind', 'workflow')
|
|
131
|
+
* @returns kebab-case string for filesystem paths
|
|
132
|
+
*/
|
|
133
|
+
declare function toFsProduct(id: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* Convert filesystem kebab-case key to product ID
|
|
136
|
+
* @param fsKey kebab-case string from filesystem
|
|
137
|
+
* @returns Product ID (camelCase if mapped, original otherwise)
|
|
138
|
+
*/
|
|
139
|
+
declare function toConfigProduct(fsKey: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* Check if a string is a known product ID
|
|
142
|
+
*/
|
|
143
|
+
declare function isValidProductId(value: string): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Get all known product IDs
|
|
146
|
+
*/
|
|
147
|
+
declare function getAllProductIds(): string[];
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get profiles root directory
|
|
151
|
+
*/
|
|
152
|
+
declare function getProfilesRootDir(cwd: string): string;
|
|
153
|
+
/**
|
|
154
|
+
* Get product configuration directory
|
|
155
|
+
*/
|
|
156
|
+
declare function getProductConfigDir(cwd: string, fsProduct: string): string;
|
|
157
|
+
/**
|
|
158
|
+
* Get product configuration file path
|
|
159
|
+
*/
|
|
160
|
+
declare function getProductConfigPath(cwd: string, fsProduct: string): string;
|
|
161
|
+
/**
|
|
162
|
+
* Get .kb root directory
|
|
163
|
+
*/
|
|
164
|
+
declare function getKbRootDir(cwd: string): string;
|
|
165
|
+
/**
|
|
166
|
+
* Get lockfile path
|
|
167
|
+
*/
|
|
168
|
+
declare function getLockfilePath(cwd: string): string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @module @kb-labs/core/config/errors
|
|
172
|
+
* Standardized error class for KB Labs with exit code mapping
|
|
173
|
+
*/
|
|
174
|
+
declare class KbError extends Error {
|
|
175
|
+
code: string;
|
|
176
|
+
hint?: string | undefined;
|
|
177
|
+
meta?: any | undefined;
|
|
178
|
+
constructor(code: string, message: string, hint?: string | undefined, meta?: any | undefined);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Maps KbError codes to CLI exit codes
|
|
182
|
+
*/
|
|
183
|
+
declare function getExitCode(err: KbError): number;
|
|
184
|
+
/**
|
|
185
|
+
* Error codes with their standard hints
|
|
186
|
+
*/
|
|
187
|
+
declare const ERROR_HINTS: {
|
|
188
|
+
readonly ERR_CONFIG_NOT_FOUND: "Create .kb/kb-labs.config.yaml or run: kb init";
|
|
189
|
+
readonly ERR_CONFIG_INVALID: "Check configuration syntax and required fields";
|
|
190
|
+
readonly ERR_CONFIG_EXISTS_CONFLICT: "Use --force to overwrite existing configuration";
|
|
191
|
+
readonly ERR_PATH_OUTSIDE_WORKSPACE: "Check cwd or use a relative path within the workspace";
|
|
192
|
+
readonly ERR_PRESET_NOT_RESOLVED: "Install the required preset package or check network connectivity";
|
|
193
|
+
readonly ERR_PROFILE_INCOMPATIBLE: "Profile version is incompatible with current system";
|
|
194
|
+
readonly ERR_PROFILE_NOT_DEFINED: "Add profiles[] to kb.config.json or pass --profile=<id>";
|
|
195
|
+
readonly ERR_PROFILE_RESOLVE_FAILED: "Profile registry unavailable. Define profiles[] inside kb.config.json or use workspace presets.";
|
|
196
|
+
readonly ERR_PROFILE_EXTENDS_FAILED: "Profile extends failed. Check extends reference or install required preset/package.";
|
|
197
|
+
readonly ERR_PROFILE_SCOPE_NOT_FOUND: "Scope not found. Use --scope=<id> with one of the configured scopes.";
|
|
198
|
+
readonly ERR_PROFILE_SCOPE_CONFLICT: "Multiple scopes matched. Specify --scope=<id> explicitly.";
|
|
199
|
+
readonly ERR_PROFILE_INVALID_FORMAT: "Update profiles[] in kb.config.json (Profiles v2) or rerun your plugin setup command.";
|
|
200
|
+
readonly ERR_ARTIFACT_LIMIT_EXCEEDED: "Remove or split large artifacts, or reduce artifact count";
|
|
201
|
+
readonly ERR_FORBIDDEN: "Add role in policy.overrides or use preset...";
|
|
202
|
+
};
|
|
203
|
+
type ErrorCode = keyof typeof ERROR_HINTS;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @module @kb-labs/core/config/cache/fs-cache
|
|
207
|
+
* LRU cache for filesystem reads with clearCaches() support
|
|
208
|
+
*/
|
|
209
|
+
declare class FSCache {
|
|
210
|
+
private cache;
|
|
211
|
+
private keyCache;
|
|
212
|
+
/**
|
|
213
|
+
* Generate cache key from file path, mtime, and size
|
|
214
|
+
*/
|
|
215
|
+
private getCacheKey;
|
|
216
|
+
/**
|
|
217
|
+
* Get cached file data if available and not stale
|
|
218
|
+
*/
|
|
219
|
+
get(absPath: string): Promise<any | null>;
|
|
220
|
+
/**
|
|
221
|
+
* Cache file data
|
|
222
|
+
*/
|
|
223
|
+
set(absPath: string, data: any): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Clear all caches
|
|
226
|
+
*/
|
|
227
|
+
clearCaches(): void;
|
|
228
|
+
/**
|
|
229
|
+
* Get cache statistics
|
|
230
|
+
*/
|
|
231
|
+
getStats(): {
|
|
232
|
+
size: number;
|
|
233
|
+
keySize: number;
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
declare const fsCache: FSCache;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Clear all filesystem caches
|
|
240
|
+
*/
|
|
241
|
+
declare function clearCaches(): void;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @module @kb-labs/core/config/hash/config-hash
|
|
245
|
+
* SHA256 hash computation for configuration objects (lockfile generation)
|
|
246
|
+
*/
|
|
247
|
+
/**
|
|
248
|
+
* Compute SHA256 hash of a configuration object
|
|
249
|
+
* @param obj Configuration object to hash
|
|
250
|
+
* @returns SHA256 hash as hex string
|
|
251
|
+
*/
|
|
252
|
+
declare function computeConfigHash(obj: any): string;
|
|
253
|
+
/**
|
|
254
|
+
* Compute hash for multiple config objects
|
|
255
|
+
* @param configs Array of config objects
|
|
256
|
+
* @returns Combined SHA256 hash
|
|
257
|
+
*/
|
|
258
|
+
declare function computeConfigsHash(configs: any[]): string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @module @kb-labs/core/config/api/read-config
|
|
262
|
+
* Enhanced config file reading with YAML support and find-up
|
|
263
|
+
*/
|
|
264
|
+
interface ConfigFileResult {
|
|
265
|
+
data: unknown;
|
|
266
|
+
format: 'json' | 'yaml';
|
|
267
|
+
path: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Read config file with format detection and caching
|
|
271
|
+
*/
|
|
272
|
+
declare function readConfigFile(filePath: string): Promise<ConfigFileResult>;
|
|
273
|
+
/**
|
|
274
|
+
* Find git root directory
|
|
275
|
+
*/
|
|
276
|
+
declare function findGitRoot(startDir: string): Promise<string | null>;
|
|
277
|
+
/**
|
|
278
|
+
* Read workspace config with find-up to git root
|
|
279
|
+
*/
|
|
280
|
+
declare function readWorkspaceConfig(cwd: string): Promise<ConfigFileResult | null>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @module @kb-labs/core-config/api/read-kb-config
|
|
284
|
+
* Find + read kb.config.* files (product-level workspace config).
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
type KbConfigResult = ConfigFileResult;
|
|
288
|
+
declare function findKbConfig(cwd: string, filenames?: string[]): Promise<{
|
|
289
|
+
path: string | null;
|
|
290
|
+
tried: string[];
|
|
291
|
+
}>;
|
|
292
|
+
declare function readKbConfig(cwd: string): Promise<KbConfigResult | null>;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @module @kb-labs/core/config/merge/layered-merge
|
|
296
|
+
* Layered merge with trace for configuration layers
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
interface LayeredMergeResult {
|
|
300
|
+
merged: any;
|
|
301
|
+
trace: MergeTrace[];
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Merge configuration layers with detailed trace
|
|
305
|
+
* Arrays are overwritten (not merged)
|
|
306
|
+
* Objects are deeply merged
|
|
307
|
+
*/
|
|
308
|
+
declare function layeredMergeWithTrace(layers: ConfigLayer[]): LayeredMergeResult;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @module @kb-labs/core/config/api/product-config
|
|
312
|
+
* High-level product configuration resolver with layered merge
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Get product configuration with layered merge and trace
|
|
317
|
+
*/
|
|
318
|
+
declare function getProductConfig<T = Record<string, any>>(opts: ResolveOptions, schema: any): Promise<ProductConfigResult<T>>;
|
|
319
|
+
/**
|
|
320
|
+
* Explain product configuration (trace only)
|
|
321
|
+
*/
|
|
322
|
+
declare function explainProductConfig(opts: Omit<ResolveOptions, 'writeFinal'>, schema: any): Promise<{
|
|
323
|
+
trace: any[];
|
|
324
|
+
}>;
|
|
325
|
+
/**
|
|
326
|
+
* Get configuration hash for lockfile
|
|
327
|
+
*/
|
|
328
|
+
declare function getConfigHash(config: any): string;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @module @kb-labs/core/config/preset/resolve-preset
|
|
332
|
+
* Org preset resolution with offline-first npm package loading
|
|
333
|
+
*/
|
|
334
|
+
interface PresetInfo {
|
|
335
|
+
name: string;
|
|
336
|
+
version: string;
|
|
337
|
+
path: string;
|
|
338
|
+
config: any;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Resolve org preset package (offline-first)
|
|
342
|
+
*/
|
|
343
|
+
declare function resolvePreset(presetRef: string, cwd: string): Promise<PresetInfo>;
|
|
344
|
+
/**
|
|
345
|
+
* Get preset config for a specific product
|
|
346
|
+
*/
|
|
347
|
+
declare function getPresetConfigForProduct(preset: PresetInfo, product: string): any;
|
|
348
|
+
/**
|
|
349
|
+
* Get preset metadata
|
|
350
|
+
*/
|
|
351
|
+
declare function getPresetMetadata(preset: PresetInfo): {
|
|
352
|
+
name: string;
|
|
353
|
+
version: string;
|
|
354
|
+
path: string;
|
|
355
|
+
products: string[];
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @module @kb-labs/core/config/lockfile/lockfile
|
|
360
|
+
* Lockfile generation and management
|
|
361
|
+
*/
|
|
362
|
+
interface LockfileData {
|
|
363
|
+
$schema?: string;
|
|
364
|
+
schemaVersion: '1.0';
|
|
365
|
+
orgPreset?: string;
|
|
366
|
+
profile?: string;
|
|
367
|
+
policyBundle?: string;
|
|
368
|
+
hashes: Record<string, string>;
|
|
369
|
+
generatedAt: string;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Read lockfile from workspace
|
|
373
|
+
*/
|
|
374
|
+
declare function readLockfile(cwd: string): Promise<LockfileData | null>;
|
|
375
|
+
/**
|
|
376
|
+
* Write lockfile to workspace
|
|
377
|
+
*/
|
|
378
|
+
declare function writeLockfile(cwd: string, lockfileData: LockfileData): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Update lockfile with new hashes
|
|
381
|
+
*/
|
|
382
|
+
declare function updateLockfile(cwd: string, updates: {
|
|
383
|
+
orgPreset?: string;
|
|
384
|
+
profile?: string;
|
|
385
|
+
policyBundle?: string;
|
|
386
|
+
configHashes?: Record<string, any>;
|
|
387
|
+
}): Promise<LockfileData>;
|
|
388
|
+
/**
|
|
389
|
+
* Get config hash for a product
|
|
390
|
+
*/
|
|
391
|
+
declare function getLockfileConfigHash(product: string, config: any): string;
|
|
392
|
+
/**
|
|
393
|
+
* Check if lockfile is up to date
|
|
394
|
+
*/
|
|
395
|
+
declare function isLockfileUpToDate(cwd: string, configs: Record<string, any>): Promise<boolean>;
|
|
396
|
+
/**
|
|
397
|
+
* Validate lockfile schema
|
|
398
|
+
*/
|
|
399
|
+
declare function validateLockfile(lockfileData: any): lockfileData is LockfileData;
|
|
400
|
+
/**
|
|
401
|
+
* Get lockfile statistics
|
|
402
|
+
*/
|
|
403
|
+
declare function getLockfileStats(lockfileData: LockfileData): {
|
|
404
|
+
productCount: number;
|
|
405
|
+
hasOrgPreset: boolean;
|
|
406
|
+
hasProfile: boolean;
|
|
407
|
+
hasPolicyBundle: boolean;
|
|
408
|
+
generatedAt: Date;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @module @kb-labs/core/config/types/preset
|
|
413
|
+
* Preset-related types
|
|
414
|
+
*/
|
|
415
|
+
interface PresetConfig {
|
|
416
|
+
products: Record<string, any>;
|
|
417
|
+
metadata?: {
|
|
418
|
+
name: string;
|
|
419
|
+
version: string;
|
|
420
|
+
description?: string;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
interface PresetResolutionOptions {
|
|
424
|
+
cwd: string;
|
|
425
|
+
presetRef: string;
|
|
426
|
+
offline?: boolean;
|
|
427
|
+
}
|
|
428
|
+
interface PresetResolutionResult {
|
|
429
|
+
preset: {
|
|
430
|
+
name: string;
|
|
431
|
+
version: string;
|
|
432
|
+
path: string;
|
|
433
|
+
config: PresetConfig;
|
|
434
|
+
};
|
|
435
|
+
resolvedAt: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* @module @kb-labs/core-config/profiles/types
|
|
440
|
+
* Shared ProfileV2 + BundleProfile types and Zod schemas.
|
|
441
|
+
*/
|
|
442
|
+
|
|
443
|
+
declare const ScopeV2Schema: z.ZodObject<{
|
|
444
|
+
id: z.ZodString;
|
|
445
|
+
label: z.ZodOptional<z.ZodString>;
|
|
446
|
+
description: z.ZodOptional<z.ZodString>;
|
|
447
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
448
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
449
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
450
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
451
|
+
}, "strip", z.ZodTypeAny, {
|
|
452
|
+
id: string;
|
|
453
|
+
include: string[];
|
|
454
|
+
default?: boolean | undefined;
|
|
455
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
456
|
+
label?: string | undefined;
|
|
457
|
+
description?: string | undefined;
|
|
458
|
+
exclude?: string[] | undefined;
|
|
459
|
+
}, {
|
|
460
|
+
id: string;
|
|
461
|
+
include: string[];
|
|
462
|
+
default?: boolean | undefined;
|
|
463
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
464
|
+
label?: string | undefined;
|
|
465
|
+
description?: string | undefined;
|
|
466
|
+
exclude?: string[] | undefined;
|
|
467
|
+
}>;
|
|
468
|
+
type ScopeV2 = z.infer<typeof ScopeV2Schema>;
|
|
469
|
+
declare const ProfileMetaSchema: z.ZodObject<{
|
|
470
|
+
version: z.ZodOptional<z.ZodString>;
|
|
471
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
472
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
473
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
474
|
+
}, "strict", z.ZodTypeAny, {
|
|
475
|
+
version?: string | undefined;
|
|
476
|
+
tags?: string[] | undefined;
|
|
477
|
+
deprecated?: boolean | undefined;
|
|
478
|
+
owner?: string | undefined;
|
|
479
|
+
}, {
|
|
480
|
+
version?: string | undefined;
|
|
481
|
+
tags?: string[] | undefined;
|
|
482
|
+
deprecated?: boolean | undefined;
|
|
483
|
+
owner?: string | undefined;
|
|
484
|
+
}>;
|
|
485
|
+
type ProfileMeta = z.infer<typeof ProfileMetaSchema>;
|
|
486
|
+
declare const ProfileV2Schema: z.ZodObject<{
|
|
487
|
+
id: z.ZodString;
|
|
488
|
+
label: z.ZodOptional<z.ZodString>;
|
|
489
|
+
description: z.ZodOptional<z.ZodString>;
|
|
490
|
+
extends: z.ZodOptional<z.ZodString>;
|
|
491
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
492
|
+
id: z.ZodString;
|
|
493
|
+
label: z.ZodOptional<z.ZodString>;
|
|
494
|
+
description: z.ZodOptional<z.ZodString>;
|
|
495
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
496
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
497
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
498
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
499
|
+
}, "strip", z.ZodTypeAny, {
|
|
500
|
+
id: string;
|
|
501
|
+
include: string[];
|
|
502
|
+
default?: boolean | undefined;
|
|
503
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
504
|
+
label?: string | undefined;
|
|
505
|
+
description?: string | undefined;
|
|
506
|
+
exclude?: string[] | undefined;
|
|
507
|
+
}, {
|
|
508
|
+
id: string;
|
|
509
|
+
include: string[];
|
|
510
|
+
default?: boolean | undefined;
|
|
511
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
512
|
+
label?: string | undefined;
|
|
513
|
+
description?: string | undefined;
|
|
514
|
+
exclude?: string[] | undefined;
|
|
515
|
+
}>, "many">>;
|
|
516
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
517
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
518
|
+
version: z.ZodOptional<z.ZodString>;
|
|
519
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
520
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
521
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
522
|
+
}, "strict", z.ZodTypeAny, {
|
|
523
|
+
version?: string | undefined;
|
|
524
|
+
tags?: string[] | undefined;
|
|
525
|
+
deprecated?: boolean | undefined;
|
|
526
|
+
owner?: string | undefined;
|
|
527
|
+
}, {
|
|
528
|
+
version?: string | undefined;
|
|
529
|
+
tags?: string[] | undefined;
|
|
530
|
+
deprecated?: boolean | undefined;
|
|
531
|
+
owner?: string | undefined;
|
|
532
|
+
}>>;
|
|
533
|
+
}, "strip", z.ZodTypeAny, {
|
|
534
|
+
id: string;
|
|
535
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
536
|
+
label?: string | undefined;
|
|
537
|
+
description?: string | undefined;
|
|
538
|
+
extends?: string | undefined;
|
|
539
|
+
scopes?: {
|
|
540
|
+
id: string;
|
|
541
|
+
include: string[];
|
|
542
|
+
default?: boolean | undefined;
|
|
543
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
544
|
+
label?: string | undefined;
|
|
545
|
+
description?: string | undefined;
|
|
546
|
+
exclude?: string[] | undefined;
|
|
547
|
+
}[] | undefined;
|
|
548
|
+
meta?: {
|
|
549
|
+
version?: string | undefined;
|
|
550
|
+
tags?: string[] | undefined;
|
|
551
|
+
deprecated?: boolean | undefined;
|
|
552
|
+
owner?: string | undefined;
|
|
553
|
+
} | undefined;
|
|
554
|
+
}, {
|
|
555
|
+
id: string;
|
|
556
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
557
|
+
label?: string | undefined;
|
|
558
|
+
description?: string | undefined;
|
|
559
|
+
extends?: string | undefined;
|
|
560
|
+
scopes?: {
|
|
561
|
+
id: string;
|
|
562
|
+
include: string[];
|
|
563
|
+
default?: boolean | undefined;
|
|
564
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
565
|
+
label?: string | undefined;
|
|
566
|
+
description?: string | undefined;
|
|
567
|
+
exclude?: string[] | undefined;
|
|
568
|
+
}[] | undefined;
|
|
569
|
+
meta?: {
|
|
570
|
+
version?: string | undefined;
|
|
571
|
+
tags?: string[] | undefined;
|
|
572
|
+
deprecated?: boolean | undefined;
|
|
573
|
+
owner?: string | undefined;
|
|
574
|
+
} | undefined;
|
|
575
|
+
}>;
|
|
576
|
+
type ProfileV2 = z.infer<typeof ProfileV2Schema>;
|
|
577
|
+
declare const ProfilesV2Schema: z.ZodArray<z.ZodObject<{
|
|
578
|
+
id: z.ZodString;
|
|
579
|
+
label: z.ZodOptional<z.ZodString>;
|
|
580
|
+
description: z.ZodOptional<z.ZodString>;
|
|
581
|
+
extends: z.ZodOptional<z.ZodString>;
|
|
582
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
583
|
+
id: z.ZodString;
|
|
584
|
+
label: z.ZodOptional<z.ZodString>;
|
|
585
|
+
description: z.ZodOptional<z.ZodString>;
|
|
586
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
587
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
588
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
589
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
590
|
+
}, "strip", z.ZodTypeAny, {
|
|
591
|
+
id: string;
|
|
592
|
+
include: string[];
|
|
593
|
+
default?: boolean | undefined;
|
|
594
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
595
|
+
label?: string | undefined;
|
|
596
|
+
description?: string | undefined;
|
|
597
|
+
exclude?: string[] | undefined;
|
|
598
|
+
}, {
|
|
599
|
+
id: string;
|
|
600
|
+
include: string[];
|
|
601
|
+
default?: boolean | undefined;
|
|
602
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
603
|
+
label?: string | undefined;
|
|
604
|
+
description?: string | undefined;
|
|
605
|
+
exclude?: string[] | undefined;
|
|
606
|
+
}>, "many">>;
|
|
607
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
608
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
609
|
+
version: z.ZodOptional<z.ZodString>;
|
|
610
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
611
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
612
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
613
|
+
}, "strict", z.ZodTypeAny, {
|
|
614
|
+
version?: string | undefined;
|
|
615
|
+
tags?: string[] | undefined;
|
|
616
|
+
deprecated?: boolean | undefined;
|
|
617
|
+
owner?: string | undefined;
|
|
618
|
+
}, {
|
|
619
|
+
version?: string | undefined;
|
|
620
|
+
tags?: string[] | undefined;
|
|
621
|
+
deprecated?: boolean | undefined;
|
|
622
|
+
owner?: string | undefined;
|
|
623
|
+
}>>;
|
|
624
|
+
}, "strip", z.ZodTypeAny, {
|
|
625
|
+
id: string;
|
|
626
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
627
|
+
label?: string | undefined;
|
|
628
|
+
description?: string | undefined;
|
|
629
|
+
extends?: string | undefined;
|
|
630
|
+
scopes?: {
|
|
631
|
+
id: string;
|
|
632
|
+
include: string[];
|
|
633
|
+
default?: boolean | undefined;
|
|
634
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
635
|
+
label?: string | undefined;
|
|
636
|
+
description?: string | undefined;
|
|
637
|
+
exclude?: string[] | undefined;
|
|
638
|
+
}[] | undefined;
|
|
639
|
+
meta?: {
|
|
640
|
+
version?: string | undefined;
|
|
641
|
+
tags?: string[] | undefined;
|
|
642
|
+
deprecated?: boolean | undefined;
|
|
643
|
+
owner?: string | undefined;
|
|
644
|
+
} | undefined;
|
|
645
|
+
}, {
|
|
646
|
+
id: string;
|
|
647
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
648
|
+
label?: string | undefined;
|
|
649
|
+
description?: string | undefined;
|
|
650
|
+
extends?: string | undefined;
|
|
651
|
+
scopes?: {
|
|
652
|
+
id: string;
|
|
653
|
+
include: string[];
|
|
654
|
+
default?: boolean | undefined;
|
|
655
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
656
|
+
label?: string | undefined;
|
|
657
|
+
description?: string | undefined;
|
|
658
|
+
exclude?: string[] | undefined;
|
|
659
|
+
}[] | undefined;
|
|
660
|
+
meta?: {
|
|
661
|
+
version?: string | undefined;
|
|
662
|
+
tags?: string[] | undefined;
|
|
663
|
+
deprecated?: boolean | undefined;
|
|
664
|
+
owner?: string | undefined;
|
|
665
|
+
} | undefined;
|
|
666
|
+
}>, "many">;
|
|
667
|
+
declare const ResolvedScopeSchema: z.ZodObject<{
|
|
668
|
+
id: z.ZodString;
|
|
669
|
+
label: z.ZodOptional<z.ZodString>;
|
|
670
|
+
description: z.ZodOptional<z.ZodString>;
|
|
671
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
672
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
673
|
+
isDefault: z.ZodBoolean;
|
|
674
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
675
|
+
}, "strip", z.ZodTypeAny, {
|
|
676
|
+
id: string;
|
|
677
|
+
include: string[];
|
|
678
|
+
isDefault: boolean;
|
|
679
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
680
|
+
label?: string | undefined;
|
|
681
|
+
description?: string | undefined;
|
|
682
|
+
exclude?: string[] | undefined;
|
|
683
|
+
}, {
|
|
684
|
+
id: string;
|
|
685
|
+
include: string[];
|
|
686
|
+
isDefault: boolean;
|
|
687
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
688
|
+
label?: string | undefined;
|
|
689
|
+
description?: string | undefined;
|
|
690
|
+
exclude?: string[] | undefined;
|
|
691
|
+
}>;
|
|
692
|
+
type ResolvedScope = z.infer<typeof ResolvedScopeSchema>;
|
|
693
|
+
declare const BundleProfileSourceSchema: z.ZodEnum<["workspace", "preset", "npm", "implicit"]>;
|
|
694
|
+
type BundleProfileSource = z.infer<typeof BundleProfileSourceSchema>;
|
|
695
|
+
declare const ProfileTraceSchema: z.ZodObject<{
|
|
696
|
+
extends: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
697
|
+
overrides: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
698
|
+
}, "strip", z.ZodTypeAny, {
|
|
699
|
+
extends?: string[] | undefined;
|
|
700
|
+
overrides?: string[] | undefined;
|
|
701
|
+
}, {
|
|
702
|
+
extends?: string[] | undefined;
|
|
703
|
+
overrides?: string[] | undefined;
|
|
704
|
+
}>;
|
|
705
|
+
type ProfileTrace = z.infer<typeof ProfileTraceSchema>;
|
|
706
|
+
declare const ScopeSelectionSchema: z.ZodObject<{
|
|
707
|
+
strategy: z.ZodEnum<["explicit", "default", "auto", "none"]>;
|
|
708
|
+
path: z.ZodOptional<z.ZodString>;
|
|
709
|
+
}, "strip", z.ZodTypeAny, {
|
|
710
|
+
strategy: "default" | "auto" | "explicit" | "none";
|
|
711
|
+
path?: string | undefined;
|
|
712
|
+
}, {
|
|
713
|
+
strategy: "default" | "auto" | "explicit" | "none";
|
|
714
|
+
path?: string | undefined;
|
|
715
|
+
}>;
|
|
716
|
+
type ScopeSelection = z.infer<typeof ScopeSelectionSchema>;
|
|
717
|
+
declare const BundleProfileSchema: z.ZodObject<{
|
|
718
|
+
id: z.ZodString;
|
|
719
|
+
key: z.ZodOptional<z.ZodString>;
|
|
720
|
+
label: z.ZodOptional<z.ZodString>;
|
|
721
|
+
name: z.ZodOptional<z.ZodString>;
|
|
722
|
+
version: z.ZodOptional<z.ZodString>;
|
|
723
|
+
source: z.ZodEnum<["workspace", "preset", "npm", "implicit"]>;
|
|
724
|
+
scopes: z.ZodArray<z.ZodObject<{
|
|
725
|
+
id: z.ZodString;
|
|
726
|
+
label: z.ZodOptional<z.ZodString>;
|
|
727
|
+
description: z.ZodOptional<z.ZodString>;
|
|
728
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
729
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
730
|
+
isDefault: z.ZodBoolean;
|
|
731
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
732
|
+
}, "strip", z.ZodTypeAny, {
|
|
733
|
+
id: string;
|
|
734
|
+
include: string[];
|
|
735
|
+
isDefault: boolean;
|
|
736
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
737
|
+
label?: string | undefined;
|
|
738
|
+
description?: string | undefined;
|
|
739
|
+
exclude?: string[] | undefined;
|
|
740
|
+
}, {
|
|
741
|
+
id: string;
|
|
742
|
+
include: string[];
|
|
743
|
+
isDefault: boolean;
|
|
744
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
745
|
+
label?: string | undefined;
|
|
746
|
+
description?: string | undefined;
|
|
747
|
+
exclude?: string[] | undefined;
|
|
748
|
+
}>, "many">;
|
|
749
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
750
|
+
trace: z.ZodOptional<z.ZodObject<{
|
|
751
|
+
extends: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
752
|
+
overrides: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
753
|
+
}, "strip", z.ZodTypeAny, {
|
|
754
|
+
extends?: string[] | undefined;
|
|
755
|
+
overrides?: string[] | undefined;
|
|
756
|
+
}, {
|
|
757
|
+
extends?: string[] | undefined;
|
|
758
|
+
overrides?: string[] | undefined;
|
|
759
|
+
}>>;
|
|
760
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
761
|
+
version: z.ZodOptional<z.ZodString>;
|
|
762
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
763
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
764
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
765
|
+
}, "strict", z.ZodTypeAny, {
|
|
766
|
+
version?: string | undefined;
|
|
767
|
+
tags?: string[] | undefined;
|
|
768
|
+
deprecated?: boolean | undefined;
|
|
769
|
+
owner?: string | undefined;
|
|
770
|
+
}, {
|
|
771
|
+
version?: string | undefined;
|
|
772
|
+
tags?: string[] | undefined;
|
|
773
|
+
deprecated?: boolean | undefined;
|
|
774
|
+
owner?: string | undefined;
|
|
775
|
+
}>>;
|
|
776
|
+
productsByScope: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
|
|
777
|
+
activeScopeId: z.ZodOptional<z.ZodString>;
|
|
778
|
+
activeScope: z.ZodOptional<z.ZodObject<{
|
|
779
|
+
id: z.ZodString;
|
|
780
|
+
label: z.ZodOptional<z.ZodString>;
|
|
781
|
+
description: z.ZodOptional<z.ZodString>;
|
|
782
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
783
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
784
|
+
isDefault: z.ZodBoolean;
|
|
785
|
+
products: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
786
|
+
}, "strip", z.ZodTypeAny, {
|
|
787
|
+
id: string;
|
|
788
|
+
include: string[];
|
|
789
|
+
isDefault: boolean;
|
|
790
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
791
|
+
label?: string | undefined;
|
|
792
|
+
description?: string | undefined;
|
|
793
|
+
exclude?: string[] | undefined;
|
|
794
|
+
}, {
|
|
795
|
+
id: string;
|
|
796
|
+
include: string[];
|
|
797
|
+
isDefault: boolean;
|
|
798
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
799
|
+
label?: string | undefined;
|
|
800
|
+
description?: string | undefined;
|
|
801
|
+
exclude?: string[] | undefined;
|
|
802
|
+
}>>;
|
|
803
|
+
scopeSelection: z.ZodOptional<z.ZodObject<{
|
|
804
|
+
strategy: z.ZodEnum<["explicit", "default", "auto", "none"]>;
|
|
805
|
+
path: z.ZodOptional<z.ZodString>;
|
|
806
|
+
}, "strip", z.ZodTypeAny, {
|
|
807
|
+
strategy: "default" | "auto" | "explicit" | "none";
|
|
808
|
+
path?: string | undefined;
|
|
809
|
+
}, {
|
|
810
|
+
strategy: "default" | "auto" | "explicit" | "none";
|
|
811
|
+
path?: string | undefined;
|
|
812
|
+
}>>;
|
|
813
|
+
}, "strip", z.ZodTypeAny, {
|
|
814
|
+
id: string;
|
|
815
|
+
scopes: {
|
|
816
|
+
id: string;
|
|
817
|
+
include: string[];
|
|
818
|
+
isDefault: boolean;
|
|
819
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
820
|
+
label?: string | undefined;
|
|
821
|
+
description?: string | undefined;
|
|
822
|
+
exclude?: string[] | undefined;
|
|
823
|
+
}[];
|
|
824
|
+
source: "preset" | "workspace" | "npm" | "implicit";
|
|
825
|
+
key?: string | undefined;
|
|
826
|
+
name?: string | undefined;
|
|
827
|
+
version?: string | undefined;
|
|
828
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
829
|
+
trace?: {
|
|
830
|
+
extends?: string[] | undefined;
|
|
831
|
+
overrides?: string[] | undefined;
|
|
832
|
+
} | undefined;
|
|
833
|
+
label?: string | undefined;
|
|
834
|
+
meta?: {
|
|
835
|
+
version?: string | undefined;
|
|
836
|
+
tags?: string[] | undefined;
|
|
837
|
+
deprecated?: boolean | undefined;
|
|
838
|
+
owner?: string | undefined;
|
|
839
|
+
} | undefined;
|
|
840
|
+
productsByScope?: Record<string, Record<string, Record<string, unknown>>> | undefined;
|
|
841
|
+
activeScopeId?: string | undefined;
|
|
842
|
+
activeScope?: {
|
|
843
|
+
id: string;
|
|
844
|
+
include: string[];
|
|
845
|
+
isDefault: boolean;
|
|
846
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
847
|
+
label?: string | undefined;
|
|
848
|
+
description?: string | undefined;
|
|
849
|
+
exclude?: string[] | undefined;
|
|
850
|
+
} | undefined;
|
|
851
|
+
scopeSelection?: {
|
|
852
|
+
strategy: "default" | "auto" | "explicit" | "none";
|
|
853
|
+
path?: string | undefined;
|
|
854
|
+
} | undefined;
|
|
855
|
+
}, {
|
|
856
|
+
id: string;
|
|
857
|
+
scopes: {
|
|
858
|
+
id: string;
|
|
859
|
+
include: string[];
|
|
860
|
+
isDefault: boolean;
|
|
861
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
862
|
+
label?: string | undefined;
|
|
863
|
+
description?: string | undefined;
|
|
864
|
+
exclude?: string[] | undefined;
|
|
865
|
+
}[];
|
|
866
|
+
source: "preset" | "workspace" | "npm" | "implicit";
|
|
867
|
+
key?: string | undefined;
|
|
868
|
+
name?: string | undefined;
|
|
869
|
+
version?: string | undefined;
|
|
870
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
871
|
+
trace?: {
|
|
872
|
+
extends?: string[] | undefined;
|
|
873
|
+
overrides?: string[] | undefined;
|
|
874
|
+
} | undefined;
|
|
875
|
+
label?: string | undefined;
|
|
876
|
+
meta?: {
|
|
877
|
+
version?: string | undefined;
|
|
878
|
+
tags?: string[] | undefined;
|
|
879
|
+
deprecated?: boolean | undefined;
|
|
880
|
+
owner?: string | undefined;
|
|
881
|
+
} | undefined;
|
|
882
|
+
productsByScope?: Record<string, Record<string, Record<string, unknown>>> | undefined;
|
|
883
|
+
activeScopeId?: string | undefined;
|
|
884
|
+
activeScope?: {
|
|
885
|
+
id: string;
|
|
886
|
+
include: string[];
|
|
887
|
+
isDefault: boolean;
|
|
888
|
+
products?: Record<string, Record<string, unknown>> | undefined;
|
|
889
|
+
label?: string | undefined;
|
|
890
|
+
description?: string | undefined;
|
|
891
|
+
exclude?: string[] | undefined;
|
|
892
|
+
} | undefined;
|
|
893
|
+
scopeSelection?: {
|
|
894
|
+
strategy: "default" | "auto" | "explicit" | "none";
|
|
895
|
+
path?: string | undefined;
|
|
896
|
+
} | undefined;
|
|
897
|
+
}>;
|
|
898
|
+
type BundleProfile = z.infer<typeof BundleProfileSchema>;
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @module @kb-labs/core-config/profiles/loader
|
|
902
|
+
* Load + validate profiles[] section from kb.config.*
|
|
903
|
+
*/
|
|
904
|
+
|
|
905
|
+
interface ProfilesSectionResult {
|
|
906
|
+
profiles: ProfileV2[];
|
|
907
|
+
sourcePath?: string;
|
|
908
|
+
format?: 'json' | 'yaml';
|
|
909
|
+
}
|
|
910
|
+
declare function readProfilesSection(cwd: string): Promise<ProfilesSectionResult>;
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* @module @kb-labs/core-config/profiles/scope-selector
|
|
914
|
+
* Resolve active scope based on include/exclude globs and CLI flags.
|
|
915
|
+
*/
|
|
916
|
+
|
|
917
|
+
type ScopeSelectionStrategy = 'explicit' | 'default' | 'auto' | 'none';
|
|
918
|
+
interface ScopeSelectionOptions {
|
|
919
|
+
bundleProfile: BundleProfile;
|
|
920
|
+
cwd: string;
|
|
921
|
+
executionPath: string;
|
|
922
|
+
scopeId?: string;
|
|
923
|
+
}
|
|
924
|
+
interface ScopeSelectionResult {
|
|
925
|
+
scope?: ResolvedScope;
|
|
926
|
+
strategy: ScopeSelectionStrategy;
|
|
927
|
+
matchedPath?: string;
|
|
928
|
+
}
|
|
929
|
+
declare function selectProfileScope(opts: ScopeSelectionOptions): ScopeSelectionResult;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* @module @kb-labs/core-config/profiles/resolver
|
|
933
|
+
* Resolve ProfileV2 definitions with extends/merge semantics.
|
|
934
|
+
*/
|
|
935
|
+
|
|
936
|
+
interface ResolveProfileOptions {
|
|
937
|
+
cwd: string;
|
|
938
|
+
profileId: string;
|
|
939
|
+
}
|
|
940
|
+
declare function resolveProfile(opts: ResolveProfileOptions): Promise<BundleProfile>;
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* @module @kb-labs/core/config/types/init
|
|
944
|
+
* Types for init operations
|
|
945
|
+
*/
|
|
946
|
+
interface InitWorkspaceOptions {
|
|
947
|
+
cwd: string;
|
|
948
|
+
format?: 'yaml' | 'json';
|
|
949
|
+
presetRef?: string | null;
|
|
950
|
+
profiles?: Record<string, string>;
|
|
951
|
+
products?: string[];
|
|
952
|
+
dryRun?: boolean;
|
|
953
|
+
force?: boolean;
|
|
954
|
+
}
|
|
955
|
+
interface InitAction {
|
|
956
|
+
kind: 'write' | 'append' | 'update' | 'skip' | 'conflict';
|
|
957
|
+
path: string;
|
|
958
|
+
previewDiff?: string;
|
|
959
|
+
}
|
|
960
|
+
interface InitResult {
|
|
961
|
+
actions: InitAction[];
|
|
962
|
+
created: string[];
|
|
963
|
+
updated: string[];
|
|
964
|
+
skipped: string[];
|
|
965
|
+
warnings: string[];
|
|
966
|
+
}
|
|
967
|
+
interface UpsertLockfileOptions {
|
|
968
|
+
cwd: string;
|
|
969
|
+
presetRef?: string | null;
|
|
970
|
+
profileRef?: string | null;
|
|
971
|
+
policyBundle?: string | null;
|
|
972
|
+
dryRun?: boolean;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* @module @kb-labs/core/config/api/init-workspace
|
|
977
|
+
* Initialize workspace configuration with idempotent operations
|
|
978
|
+
*/
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Initialize or update workspace configuration
|
|
982
|
+
*/
|
|
983
|
+
declare function initWorkspaceConfig(opts: InitWorkspaceOptions): Promise<InitResult>;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* @module @kb-labs/core/config/api/upsert-lockfile
|
|
987
|
+
* Upsert lockfile operations
|
|
988
|
+
*/
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Upsert lockfile with new references
|
|
992
|
+
*/
|
|
993
|
+
declare function upsertLockfile(opts: UpsertLockfileOptions): Promise<InitResult>;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* @module @kb-labs/core/config/utils/fs-atomic
|
|
997
|
+
* Atomic file write operations using tmp+rename pattern
|
|
998
|
+
*/
|
|
999
|
+
/**
|
|
1000
|
+
* Write file atomically using tmp+rename pattern
|
|
1001
|
+
* This ensures that the file is never partially written in case of crashes
|
|
1002
|
+
*/
|
|
1003
|
+
declare function writeFileAtomic(path: string, data: string | Uint8Array): Promise<void>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Ensure a path is within the workspace root
|
|
1006
|
+
* Throws ERR_PATH_OUTSIDE_WORKSPACE if the path escapes the workspace
|
|
1007
|
+
*/
|
|
1008
|
+
declare function ensureWithinWorkspace(targetPath: string, workspaceRoot: string): void;
|
|
1009
|
+
|
|
1010
|
+
type ValidationResult = {
|
|
1011
|
+
ok: boolean;
|
|
1012
|
+
errors: any[] | null;
|
|
1013
|
+
};
|
|
1014
|
+
declare function validateProductConfig(product: string, config: unknown): ValidationResult;
|
|
1015
|
+
|
|
1016
|
+
export { type BundleProfile, BundleProfileSchema, type BundleProfileSource, BundleProfileSourceSchema, type ConfigFileResult, type ConfigLayer, type Diagnostic, ERROR_HINTS, type ErrorCode, FSCache, type FindNearestConfigOpts, type InitAction, type InitResult, type InitWorkspaceOptions, type JsonReadResult, type KBConfig, type KbConfigResult, KbError, type LayeredMergeResult, type LockfileData, type MergeTrace, type PresetConfig, type PresetInfo, type PresetResolutionOptions, type PresetResolutionResult, type ProductConfigResult, type ProfileLayerInput, type ProfileMeta, ProfileMetaSchema, type ProfileTrace, ProfileTraceSchema, type ProfileV2, ProfileV2Schema, type ProfilesConfig, type ProfilesSectionResult, ProfilesV2Schema, type ResolveConfigArgs, type ResolveOptions, type ResolveProfileOptions, type ResolvedScope, ResolvedScopeSchema, SYSTEM_DEFAULTS, type ScopeSelection, type ScopeSelectionOptions, type ScopeSelectionResult, ScopeSelectionSchema, type ScopeSelectionStrategy, type ScopeV2, ScopeV2Schema, type UpsertLockfileOptions, clearCaches, computeConfigHash, computeConfigsHash, ensureWithinWorkspace, explainProductConfig, findGitRoot, findKbConfig, findNearestConfig, fsCache, getAllProductIds, getConfigHash, getExitCode, getKbRootDir, getLockfileConfigHash, getLockfilePath, getLockfileStats, getPresetConfigForProduct, getPresetMetadata, getProductConfig, getProductConfigDir, getProductConfigPath, getProfilesRootDir, initWorkspaceConfig, isLockfileUpToDate, isValidProductId, layeredMergeWithTrace, mergeDefined, pickDefined, readConfigFile, readJsonWithDiagnostics, readKbConfig, readLockfile, readProfilesSection, readWorkspaceConfig, resolveConfig, resolvePreset, resolveProfile, selectProfileScope, toBool, toConfigProduct, toFsProduct, toInt, updateLockfile, upsertLockfile, validateLockfile, validateProductConfig, writeFileAtomic, writeLockfile };
|