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 CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  本项目的所有重要变更都将记录在此文件中。
4
4
 
5
+ ## [1.0.11] - 2026-03-06
6
+
7
+ ### Changed
8
+ - 完善项目配置的默认值和字段规范化
9
+
5
10
  ## [1.0.10] - 2026-03-05
6
11
 
7
12
  ### Added
package/CHANGELOG_en.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.11] - 2026-03-06
6
+
7
+ ### Changed
8
+ - Improved default values and field normalization for project configuration
9
+
5
10
  ## [1.0.10] - 2026-03-05
6
11
 
7
12
  ### Added
@@ -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 {
@@ -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
- return config;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tools-cc",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "tools-cc [options] <command> [args]",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -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
- return config as ProjectConfig;
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 {