@codelia/config 0.1.12 → 0.1.15
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.cjs +112 -0
- package/dist/index.d.cts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +111 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,12 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
CONFIG_GROUP_DEFAULT_WRITE_SCOPE: () => CONFIG_GROUP_DEFAULT_WRITE_SCOPE,
|
|
23
24
|
CONFIG_VERSION: () => CONFIG_VERSION,
|
|
24
25
|
ConfigRegistry: () => ConfigRegistry,
|
|
25
26
|
configRegistry: () => configRegistry,
|
|
26
27
|
parseConfig: () => parseConfig
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
var CONFIG_GROUP_DEFAULT_WRITE_SCOPE = {
|
|
31
|
+
model: "global",
|
|
32
|
+
permissions: "project",
|
|
33
|
+
mcp: "project",
|
|
34
|
+
skills: "project",
|
|
35
|
+
search: "project",
|
|
36
|
+
tui: "global"
|
|
37
|
+
};
|
|
29
38
|
var CONFIG_VERSION = 1;
|
|
30
39
|
var MCP_SERVER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
31
40
|
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -152,6 +161,73 @@ var parseSkillsConfig = (value) => {
|
|
|
152
161
|
}
|
|
153
162
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
154
163
|
};
|
|
164
|
+
var parseSearchMode = (value) => {
|
|
165
|
+
if (value !== "auto" && value !== "native" && value !== "local") {
|
|
166
|
+
return void 0;
|
|
167
|
+
}
|
|
168
|
+
return value;
|
|
169
|
+
};
|
|
170
|
+
var parseSearchConfig = (value) => {
|
|
171
|
+
if (!isRecord(value)) return void 0;
|
|
172
|
+
const mode = parseSearchMode(value.mode);
|
|
173
|
+
let native;
|
|
174
|
+
if (isRecord(value.native)) {
|
|
175
|
+
const candidate = {};
|
|
176
|
+
const providers = pickStringArray(value.native.providers);
|
|
177
|
+
if (providers) {
|
|
178
|
+
candidate.providers = providers;
|
|
179
|
+
}
|
|
180
|
+
if (value.native.search_context_size === "low" || value.native.search_context_size === "medium" || value.native.search_context_size === "high") {
|
|
181
|
+
candidate.search_context_size = value.native.search_context_size;
|
|
182
|
+
}
|
|
183
|
+
const allowedDomains = pickStringArray(value.native.allowed_domains);
|
|
184
|
+
if (allowedDomains) {
|
|
185
|
+
candidate.allowed_domains = allowedDomains;
|
|
186
|
+
}
|
|
187
|
+
if (isRecord(value.native.user_location)) {
|
|
188
|
+
const userLocation = {};
|
|
189
|
+
const city = pickString(value.native.user_location.city);
|
|
190
|
+
if (city) userLocation.city = city;
|
|
191
|
+
const country = pickString(value.native.user_location.country);
|
|
192
|
+
if (country) userLocation.country = country;
|
|
193
|
+
const region = pickString(value.native.user_location.region);
|
|
194
|
+
if (region) userLocation.region = region;
|
|
195
|
+
const timezone = pickString(value.native.user_location.timezone);
|
|
196
|
+
if (timezone) userLocation.timezone = timezone;
|
|
197
|
+
if (Object.keys(userLocation).length > 0) {
|
|
198
|
+
candidate.user_location = userLocation;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (Object.keys(candidate).length > 0) {
|
|
202
|
+
native = candidate;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
let local;
|
|
206
|
+
if (isRecord(value.local)) {
|
|
207
|
+
const candidate = {};
|
|
208
|
+
if (value.local.backend === "ddg" || value.local.backend === "brave") {
|
|
209
|
+
candidate.backend = value.local.backend;
|
|
210
|
+
}
|
|
211
|
+
const braveKeyEnv = pickString(value.local.brave_api_key_env);
|
|
212
|
+
if (braveKeyEnv) {
|
|
213
|
+
candidate.brave_api_key_env = braveKeyEnv;
|
|
214
|
+
}
|
|
215
|
+
if (Object.keys(candidate).length > 0) {
|
|
216
|
+
local = candidate;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const result = {};
|
|
220
|
+
if (mode) {
|
|
221
|
+
result.mode = mode;
|
|
222
|
+
}
|
|
223
|
+
if (native && Object.keys(native).length > 0) {
|
|
224
|
+
result.native = native;
|
|
225
|
+
}
|
|
226
|
+
if (local && Object.keys(local).length > 0) {
|
|
227
|
+
result.local = local;
|
|
228
|
+
}
|
|
229
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
230
|
+
};
|
|
155
231
|
var parseConfig = (value, sourceLabel) => {
|
|
156
232
|
if (!isRecord(value)) {
|
|
157
233
|
throw new Error(`${sourceLabel}: config must be an object`);
|
|
@@ -175,6 +251,10 @@ var parseConfig = (value, sourceLabel) => {
|
|
|
175
251
|
const hasPermissions = permissions && (permissions.allow || permissions.deny) ? permissions : void 0;
|
|
176
252
|
const mcp = parseMcpConfig(value.mcp);
|
|
177
253
|
const skills = parseSkillsConfig(value.skills);
|
|
254
|
+
const search = parseSearchConfig(value.search);
|
|
255
|
+
const tui = isRecord(value.tui) ? {
|
|
256
|
+
...pickString(value.tui.theme) ? { theme: pickString(value.tui.theme) } : {}
|
|
257
|
+
} : void 0;
|
|
178
258
|
const result = { version, model };
|
|
179
259
|
if (hasPermissions) {
|
|
180
260
|
result.permissions = hasPermissions;
|
|
@@ -185,6 +265,12 @@ var parseConfig = (value, sourceLabel) => {
|
|
|
185
265
|
if (skills) {
|
|
186
266
|
result.skills = skills;
|
|
187
267
|
}
|
|
268
|
+
if (search) {
|
|
269
|
+
result.search = search;
|
|
270
|
+
}
|
|
271
|
+
if (tui && Object.keys(tui).length > 0) {
|
|
272
|
+
result.tui = tui;
|
|
273
|
+
}
|
|
188
274
|
return result;
|
|
189
275
|
};
|
|
190
276
|
var ConfigRegistry = class {
|
|
@@ -244,6 +330,31 @@ var ConfigRegistry = class {
|
|
|
244
330
|
};
|
|
245
331
|
}
|
|
246
332
|
}
|
|
333
|
+
if (layer?.search) {
|
|
334
|
+
const nextSearch = layer.search;
|
|
335
|
+
merged.search ??= {};
|
|
336
|
+
if (nextSearch.mode !== void 0) {
|
|
337
|
+
merged.search.mode = nextSearch.mode;
|
|
338
|
+
}
|
|
339
|
+
if (nextSearch.native) {
|
|
340
|
+
merged.search.native = {
|
|
341
|
+
...merged.search.native ?? {},
|
|
342
|
+
...nextSearch.native
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
if (nextSearch.local) {
|
|
346
|
+
merged.search.local = {
|
|
347
|
+
...merged.search.local ?? {},
|
|
348
|
+
...nextSearch.local
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (layer?.tui) {
|
|
353
|
+
merged.tui = {
|
|
354
|
+
...merged.tui ?? {},
|
|
355
|
+
...layer.tui
|
|
356
|
+
};
|
|
357
|
+
}
|
|
247
358
|
}
|
|
248
359
|
return merged;
|
|
249
360
|
}
|
|
@@ -251,6 +362,7 @@ var ConfigRegistry = class {
|
|
|
251
362
|
var configRegistry = new ConfigRegistry();
|
|
252
363
|
// Annotate the CommonJS export names for ESM import in node:
|
|
253
364
|
0 && (module.exports = {
|
|
365
|
+
CONFIG_GROUP_DEFAULT_WRITE_SCOPE,
|
|
254
366
|
CONFIG_VERSION,
|
|
255
367
|
ConfigRegistry,
|
|
256
368
|
configRegistry,
|
package/dist/index.d.cts
CHANGED
|
@@ -47,13 +47,40 @@ type SkillsConfig = {
|
|
|
47
47
|
maxLimit?: number;
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
+
type SearchMode = "auto" | "native" | "local";
|
|
51
|
+
type SearchConfig = {
|
|
52
|
+
mode?: SearchMode;
|
|
53
|
+
native?: {
|
|
54
|
+
providers?: string[];
|
|
55
|
+
search_context_size?: "low" | "medium" | "high";
|
|
56
|
+
allowed_domains?: string[];
|
|
57
|
+
user_location?: {
|
|
58
|
+
city?: string;
|
|
59
|
+
country?: string;
|
|
60
|
+
region?: string;
|
|
61
|
+
timezone?: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
local?: {
|
|
65
|
+
backend?: "ddg" | "brave";
|
|
66
|
+
brave_api_key_env?: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
type TuiConfig = {
|
|
70
|
+
theme?: string;
|
|
71
|
+
};
|
|
50
72
|
type CodeliaConfig = {
|
|
51
73
|
version: number;
|
|
52
74
|
model?: ModelConfig;
|
|
53
75
|
permissions?: PermissionsConfig;
|
|
54
76
|
mcp?: McpConfig;
|
|
55
77
|
skills?: SkillsConfig;
|
|
78
|
+
search?: SearchConfig;
|
|
79
|
+
tui?: TuiConfig;
|
|
56
80
|
};
|
|
81
|
+
type ConfigWriteScope = "global" | "project";
|
|
82
|
+
type ConfigWriteGroup = Exclude<keyof CodeliaConfig, "version">;
|
|
83
|
+
declare const CONFIG_GROUP_DEFAULT_WRITE_SCOPE: Record<ConfigWriteGroup, ConfigWriteScope>;
|
|
57
84
|
declare const CONFIG_VERSION = 1;
|
|
58
85
|
declare const parseConfig: (value: unknown, sourceLabel: string) => CodeliaConfig;
|
|
59
86
|
type ConfigLayer = {
|
|
@@ -61,6 +88,8 @@ type ConfigLayer = {
|
|
|
61
88
|
permissions?: PermissionsConfig;
|
|
62
89
|
mcp?: McpConfig;
|
|
63
90
|
skills?: SkillsConfig;
|
|
91
|
+
search?: SearchConfig;
|
|
92
|
+
tui?: TuiConfig;
|
|
64
93
|
};
|
|
65
94
|
declare class ConfigRegistry {
|
|
66
95
|
private readonly defaults;
|
|
@@ -69,4 +98,4 @@ declare class ConfigRegistry {
|
|
|
69
98
|
}
|
|
70
99
|
declare const configRegistry: ConfigRegistry;
|
|
71
100
|
|
|
72
|
-
export { CONFIG_VERSION, type CodeliaConfig, ConfigRegistry, type McpConfig, type McpServerConfig, type ModelConfig, type PermissionRule, type PermissionsConfig, type SkillsConfig, configRegistry, parseConfig };
|
|
101
|
+
export { CONFIG_GROUP_DEFAULT_WRITE_SCOPE, CONFIG_VERSION, type CodeliaConfig, ConfigRegistry, type ConfigWriteGroup, type ConfigWriteScope, type McpConfig, type McpServerConfig, type ModelConfig, type PermissionRule, type PermissionsConfig, type SearchConfig, type SearchMode, type SkillsConfig, type TuiConfig, configRegistry, parseConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,13 +47,40 @@ type SkillsConfig = {
|
|
|
47
47
|
maxLimit?: number;
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
+
type SearchMode = "auto" | "native" | "local";
|
|
51
|
+
type SearchConfig = {
|
|
52
|
+
mode?: SearchMode;
|
|
53
|
+
native?: {
|
|
54
|
+
providers?: string[];
|
|
55
|
+
search_context_size?: "low" | "medium" | "high";
|
|
56
|
+
allowed_domains?: string[];
|
|
57
|
+
user_location?: {
|
|
58
|
+
city?: string;
|
|
59
|
+
country?: string;
|
|
60
|
+
region?: string;
|
|
61
|
+
timezone?: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
local?: {
|
|
65
|
+
backend?: "ddg" | "brave";
|
|
66
|
+
brave_api_key_env?: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
type TuiConfig = {
|
|
70
|
+
theme?: string;
|
|
71
|
+
};
|
|
50
72
|
type CodeliaConfig = {
|
|
51
73
|
version: number;
|
|
52
74
|
model?: ModelConfig;
|
|
53
75
|
permissions?: PermissionsConfig;
|
|
54
76
|
mcp?: McpConfig;
|
|
55
77
|
skills?: SkillsConfig;
|
|
78
|
+
search?: SearchConfig;
|
|
79
|
+
tui?: TuiConfig;
|
|
56
80
|
};
|
|
81
|
+
type ConfigWriteScope = "global" | "project";
|
|
82
|
+
type ConfigWriteGroup = Exclude<keyof CodeliaConfig, "version">;
|
|
83
|
+
declare const CONFIG_GROUP_DEFAULT_WRITE_SCOPE: Record<ConfigWriteGroup, ConfigWriteScope>;
|
|
57
84
|
declare const CONFIG_VERSION = 1;
|
|
58
85
|
declare const parseConfig: (value: unknown, sourceLabel: string) => CodeliaConfig;
|
|
59
86
|
type ConfigLayer = {
|
|
@@ -61,6 +88,8 @@ type ConfigLayer = {
|
|
|
61
88
|
permissions?: PermissionsConfig;
|
|
62
89
|
mcp?: McpConfig;
|
|
63
90
|
skills?: SkillsConfig;
|
|
91
|
+
search?: SearchConfig;
|
|
92
|
+
tui?: TuiConfig;
|
|
64
93
|
};
|
|
65
94
|
declare class ConfigRegistry {
|
|
66
95
|
private readonly defaults;
|
|
@@ -69,4 +98,4 @@ declare class ConfigRegistry {
|
|
|
69
98
|
}
|
|
70
99
|
declare const configRegistry: ConfigRegistry;
|
|
71
100
|
|
|
72
|
-
export { CONFIG_VERSION, type CodeliaConfig, ConfigRegistry, type McpConfig, type McpServerConfig, type ModelConfig, type PermissionRule, type PermissionsConfig, type SkillsConfig, configRegistry, parseConfig };
|
|
101
|
+
export { CONFIG_GROUP_DEFAULT_WRITE_SCOPE, CONFIG_VERSION, type CodeliaConfig, ConfigRegistry, type ConfigWriteGroup, type ConfigWriteScope, type McpConfig, type McpServerConfig, type ModelConfig, type PermissionRule, type PermissionsConfig, type SearchConfig, type SearchMode, type SkillsConfig, type TuiConfig, configRegistry, parseConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
var CONFIG_GROUP_DEFAULT_WRITE_SCOPE = {
|
|
3
|
+
model: "global",
|
|
4
|
+
permissions: "project",
|
|
5
|
+
mcp: "project",
|
|
6
|
+
skills: "project",
|
|
7
|
+
search: "project",
|
|
8
|
+
tui: "global"
|
|
9
|
+
};
|
|
2
10
|
var CONFIG_VERSION = 1;
|
|
3
11
|
var MCP_SERVER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
4
12
|
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -125,6 +133,73 @@ var parseSkillsConfig = (value) => {
|
|
|
125
133
|
}
|
|
126
134
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
127
135
|
};
|
|
136
|
+
var parseSearchMode = (value) => {
|
|
137
|
+
if (value !== "auto" && value !== "native" && value !== "local") {
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
};
|
|
142
|
+
var parseSearchConfig = (value) => {
|
|
143
|
+
if (!isRecord(value)) return void 0;
|
|
144
|
+
const mode = parseSearchMode(value.mode);
|
|
145
|
+
let native;
|
|
146
|
+
if (isRecord(value.native)) {
|
|
147
|
+
const candidate = {};
|
|
148
|
+
const providers = pickStringArray(value.native.providers);
|
|
149
|
+
if (providers) {
|
|
150
|
+
candidate.providers = providers;
|
|
151
|
+
}
|
|
152
|
+
if (value.native.search_context_size === "low" || value.native.search_context_size === "medium" || value.native.search_context_size === "high") {
|
|
153
|
+
candidate.search_context_size = value.native.search_context_size;
|
|
154
|
+
}
|
|
155
|
+
const allowedDomains = pickStringArray(value.native.allowed_domains);
|
|
156
|
+
if (allowedDomains) {
|
|
157
|
+
candidate.allowed_domains = allowedDomains;
|
|
158
|
+
}
|
|
159
|
+
if (isRecord(value.native.user_location)) {
|
|
160
|
+
const userLocation = {};
|
|
161
|
+
const city = pickString(value.native.user_location.city);
|
|
162
|
+
if (city) userLocation.city = city;
|
|
163
|
+
const country = pickString(value.native.user_location.country);
|
|
164
|
+
if (country) userLocation.country = country;
|
|
165
|
+
const region = pickString(value.native.user_location.region);
|
|
166
|
+
if (region) userLocation.region = region;
|
|
167
|
+
const timezone = pickString(value.native.user_location.timezone);
|
|
168
|
+
if (timezone) userLocation.timezone = timezone;
|
|
169
|
+
if (Object.keys(userLocation).length > 0) {
|
|
170
|
+
candidate.user_location = userLocation;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (Object.keys(candidate).length > 0) {
|
|
174
|
+
native = candidate;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
let local;
|
|
178
|
+
if (isRecord(value.local)) {
|
|
179
|
+
const candidate = {};
|
|
180
|
+
if (value.local.backend === "ddg" || value.local.backend === "brave") {
|
|
181
|
+
candidate.backend = value.local.backend;
|
|
182
|
+
}
|
|
183
|
+
const braveKeyEnv = pickString(value.local.brave_api_key_env);
|
|
184
|
+
if (braveKeyEnv) {
|
|
185
|
+
candidate.brave_api_key_env = braveKeyEnv;
|
|
186
|
+
}
|
|
187
|
+
if (Object.keys(candidate).length > 0) {
|
|
188
|
+
local = candidate;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const result = {};
|
|
192
|
+
if (mode) {
|
|
193
|
+
result.mode = mode;
|
|
194
|
+
}
|
|
195
|
+
if (native && Object.keys(native).length > 0) {
|
|
196
|
+
result.native = native;
|
|
197
|
+
}
|
|
198
|
+
if (local && Object.keys(local).length > 0) {
|
|
199
|
+
result.local = local;
|
|
200
|
+
}
|
|
201
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
202
|
+
};
|
|
128
203
|
var parseConfig = (value, sourceLabel) => {
|
|
129
204
|
if (!isRecord(value)) {
|
|
130
205
|
throw new Error(`${sourceLabel}: config must be an object`);
|
|
@@ -148,6 +223,10 @@ var parseConfig = (value, sourceLabel) => {
|
|
|
148
223
|
const hasPermissions = permissions && (permissions.allow || permissions.deny) ? permissions : void 0;
|
|
149
224
|
const mcp = parseMcpConfig(value.mcp);
|
|
150
225
|
const skills = parseSkillsConfig(value.skills);
|
|
226
|
+
const search = parseSearchConfig(value.search);
|
|
227
|
+
const tui = isRecord(value.tui) ? {
|
|
228
|
+
...pickString(value.tui.theme) ? { theme: pickString(value.tui.theme) } : {}
|
|
229
|
+
} : void 0;
|
|
151
230
|
const result = { version, model };
|
|
152
231
|
if (hasPermissions) {
|
|
153
232
|
result.permissions = hasPermissions;
|
|
@@ -158,6 +237,12 @@ var parseConfig = (value, sourceLabel) => {
|
|
|
158
237
|
if (skills) {
|
|
159
238
|
result.skills = skills;
|
|
160
239
|
}
|
|
240
|
+
if (search) {
|
|
241
|
+
result.search = search;
|
|
242
|
+
}
|
|
243
|
+
if (tui && Object.keys(tui).length > 0) {
|
|
244
|
+
result.tui = tui;
|
|
245
|
+
}
|
|
161
246
|
return result;
|
|
162
247
|
};
|
|
163
248
|
var ConfigRegistry = class {
|
|
@@ -217,12 +302,38 @@ var ConfigRegistry = class {
|
|
|
217
302
|
};
|
|
218
303
|
}
|
|
219
304
|
}
|
|
305
|
+
if (layer?.search) {
|
|
306
|
+
const nextSearch = layer.search;
|
|
307
|
+
merged.search ??= {};
|
|
308
|
+
if (nextSearch.mode !== void 0) {
|
|
309
|
+
merged.search.mode = nextSearch.mode;
|
|
310
|
+
}
|
|
311
|
+
if (nextSearch.native) {
|
|
312
|
+
merged.search.native = {
|
|
313
|
+
...merged.search.native ?? {},
|
|
314
|
+
...nextSearch.native
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
if (nextSearch.local) {
|
|
318
|
+
merged.search.local = {
|
|
319
|
+
...merged.search.local ?? {},
|
|
320
|
+
...nextSearch.local
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (layer?.tui) {
|
|
325
|
+
merged.tui = {
|
|
326
|
+
...merged.tui ?? {},
|
|
327
|
+
...layer.tui
|
|
328
|
+
};
|
|
329
|
+
}
|
|
220
330
|
}
|
|
221
331
|
return merged;
|
|
222
332
|
}
|
|
223
333
|
};
|
|
224
334
|
var configRegistry = new ConfigRegistry();
|
|
225
335
|
export {
|
|
336
|
+
CONFIG_GROUP_DEFAULT_WRITE_SCOPE,
|
|
226
337
|
CONFIG_VERSION,
|
|
227
338
|
ConfigRegistry,
|
|
228
339
|
configRegistry,
|