tools-cc 1.0.10 → 1.0.11
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/CHANGELOG.md +5 -0
- package/CHANGELOG_en.md +5 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.js +28 -7
- package/package.json +1 -1
- package/src/types/config.ts +32 -7
package/CHANGELOG.md
CHANGED
package/CHANGELOG_en.md
CHANGED
package/dist/types/config.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export declare function isSourceSelection(value: unknown): value is SourceSelect
|
|
|
37
37
|
/**
|
|
38
38
|
* 将旧版项目配置转换为新版格式
|
|
39
39
|
* 如果 sources 是字符串数组,转换为 Record 格式,每个源默认导入全部内容
|
|
40
|
+
* 同时确保所有 SourceSelection 对象字段完整
|
|
40
41
|
*/
|
|
41
42
|
export declare function normalizeProjectConfig(config: LegacyProjectConfig | ProjectConfig): ProjectConfig;
|
|
42
43
|
export interface Manifest {
|
package/dist/types/config.js
CHANGED
|
@@ -14,23 +14,44 @@ function isSourceSelection(value) {
|
|
|
14
14
|
Array.isArray(obj.agents) &&
|
|
15
15
|
Array.isArray(obj.rules));
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* 默认选择配置 - 导入所有内容
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_SOURCE_SELECTION = {
|
|
21
|
+
skills: ['*'],
|
|
22
|
+
commands: ['*'],
|
|
23
|
+
agents: ['*'],
|
|
24
|
+
rules: ['*']
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 确保 SourceSelection 对象字段完整
|
|
28
|
+
*/
|
|
29
|
+
function normalizeSourceSelection(selection) {
|
|
30
|
+
return {
|
|
31
|
+
skills: selection?.skills ?? DEFAULT_SOURCE_SELECTION.skills,
|
|
32
|
+
commands: selection?.commands ?? DEFAULT_SOURCE_SELECTION.commands,
|
|
33
|
+
agents: selection?.agents ?? DEFAULT_SOURCE_SELECTION.agents,
|
|
34
|
+
rules: selection?.rules ?? DEFAULT_SOURCE_SELECTION.rules
|
|
35
|
+
};
|
|
36
|
+
}
|
|
17
37
|
/**
|
|
18
38
|
* 将旧版项目配置转换为新版格式
|
|
19
39
|
* 如果 sources 是字符串数组,转换为 Record 格式,每个源默认导入全部内容
|
|
40
|
+
* 同时确保所有 SourceSelection 对象字段完整
|
|
20
41
|
*/
|
|
21
42
|
function normalizeProjectConfig(config) {
|
|
22
43
|
// If sources is an array, convert to new format
|
|
23
44
|
if (Array.isArray(config.sources)) {
|
|
24
45
|
const newSources = {};
|
|
25
46
|
for (const sourceName of config.sources) {
|
|
26
|
-
newSources[sourceName] = {
|
|
27
|
-
skills: ['*'],
|
|
28
|
-
commands: ['*'],
|
|
29
|
-
agents: ['*'],
|
|
30
|
-
rules: ['*']
|
|
31
|
-
};
|
|
47
|
+
newSources[sourceName] = { ...DEFAULT_SOURCE_SELECTION };
|
|
32
48
|
}
|
|
33
49
|
return { sources: newSources, links: config.links };
|
|
34
50
|
}
|
|
35
|
-
|
|
51
|
+
// If sources is an object, ensure all SourceSelection fields are complete
|
|
52
|
+
const normalizedSources = {};
|
|
53
|
+
for (const [sourceName, selection] of Object.entries(config.sources)) {
|
|
54
|
+
normalizedSources[sourceName] = normalizeSourceSelection(selection);
|
|
55
|
+
}
|
|
56
|
+
return { sources: normalizedSources, links: config.links };
|
|
36
57
|
}
|
package/package.json
CHANGED
package/src/types/config.ts
CHANGED
|
@@ -49,9 +49,32 @@ export function isSourceSelection(value: unknown): value is SourceSelection {
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* 默认选择配置 - 导入所有内容
|
|
54
|
+
*/
|
|
55
|
+
const DEFAULT_SOURCE_SELECTION: SourceSelection = {
|
|
56
|
+
skills: ['*'],
|
|
57
|
+
commands: ['*'],
|
|
58
|
+
agents: ['*'],
|
|
59
|
+
rules: ['*']
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 确保 SourceSelection 对象字段完整
|
|
64
|
+
*/
|
|
65
|
+
function normalizeSourceSelection(selection: Partial<SourceSelection> | undefined): SourceSelection {
|
|
66
|
+
return {
|
|
67
|
+
skills: selection?.skills ?? DEFAULT_SOURCE_SELECTION.skills,
|
|
68
|
+
commands: selection?.commands ?? DEFAULT_SOURCE_SELECTION.commands,
|
|
69
|
+
agents: selection?.agents ?? DEFAULT_SOURCE_SELECTION.agents,
|
|
70
|
+
rules: selection?.rules ?? DEFAULT_SOURCE_SELECTION.rules
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
52
74
|
/**
|
|
53
75
|
* 将旧版项目配置转换为新版格式
|
|
54
76
|
* 如果 sources 是字符串数组,转换为 Record 格式,每个源默认导入全部内容
|
|
77
|
+
* 同时确保所有 SourceSelection 对象字段完整
|
|
55
78
|
*/
|
|
56
79
|
export function normalizeProjectConfig(
|
|
57
80
|
config: LegacyProjectConfig | ProjectConfig
|
|
@@ -60,16 +83,18 @@ export function normalizeProjectConfig(
|
|
|
60
83
|
if (Array.isArray(config.sources)) {
|
|
61
84
|
const newSources: Record<string, SourceSelection> = {};
|
|
62
85
|
for (const sourceName of config.sources) {
|
|
63
|
-
newSources[sourceName] = {
|
|
64
|
-
skills: ['*'],
|
|
65
|
-
commands: ['*'],
|
|
66
|
-
agents: ['*'],
|
|
67
|
-
rules: ['*']
|
|
68
|
-
};
|
|
86
|
+
newSources[sourceName] = { ...DEFAULT_SOURCE_SELECTION };
|
|
69
87
|
}
|
|
70
88
|
return { sources: newSources, links: config.links };
|
|
71
89
|
}
|
|
72
|
-
|
|
90
|
+
|
|
91
|
+
// If sources is an object, ensure all SourceSelection fields are complete
|
|
92
|
+
const normalizedSources: Record<string, SourceSelection> = {};
|
|
93
|
+
for (const [sourceName, selection] of Object.entries(config.sources as Record<string, Partial<SourceSelection>>)) {
|
|
94
|
+
normalizedSources[sourceName] = normalizeSourceSelection(selection);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return { sources: normalizedSources, links: config.links };
|
|
73
98
|
}
|
|
74
99
|
|
|
75
100
|
export interface Manifest {
|