tools-cc 1.0.8 → 1.0.10

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.
@@ -1,113 +1,117 @@
1
- export interface SourceConfig {
2
- type: 'git' | 'local';
3
- url?: string;
4
- path?: string;
5
- }
6
-
7
- export interface GlobalConfig {
8
- sourcesDir: string;
9
- sources: Record<string, SourceConfig>;
10
- }
11
-
12
- /**
13
- * 源选择配置 - 指定从源中导入哪些 skills/commands/agents
14
- */
15
- export interface SourceSelection {
16
- skills: string[];
17
- commands: string[];
18
- agents: string[];
19
- }
20
-
21
- /**
22
- * 新版项目配置 - sources 使用 Record 格式支持部分导入
23
- */
24
- export interface ProjectConfig {
25
- sources: Record<string, SourceSelection>;
26
- links: string[];
27
- }
28
-
29
- /**
30
- * 旧版项目配置 - sources 为字符串数组(向后兼容)
31
- */
32
- export interface LegacyProjectConfig {
33
- sources: string[];
34
- links: string[];
35
- }
36
-
37
- /**
38
- * 判断值是否为有效的 SourceSelection 对象
39
- */
40
- export function isSourceSelection(value: unknown): value is SourceSelection {
41
- if (typeof value !== 'object' || value === null) return false;
42
- const obj = value as Record<string, unknown>;
43
- return (
44
- Array.isArray(obj.skills) &&
45
- Array.isArray(obj.commands) &&
46
- Array.isArray(obj.agents)
47
- );
48
- }
49
-
50
- /**
51
- * 将旧版项目配置转换为新版格式
52
- * 如果 sources 是字符串数组,转换为 Record 格式,每个源默认导入全部内容
53
- */
54
- export function normalizeProjectConfig(
55
- config: LegacyProjectConfig | ProjectConfig
56
- ): ProjectConfig {
57
- // If sources is an array, convert to new format
58
- if (Array.isArray(config.sources)) {
59
- const newSources: Record<string, SourceSelection> = {};
60
- for (const sourceName of config.sources) {
61
- newSources[sourceName] = {
62
- skills: ['*'],
63
- commands: ['*'],
64
- agents: ['*']
65
- };
66
- }
67
- return { sources: newSources, links: config.links };
68
- }
69
- return config as ProjectConfig;
70
- }
71
-
72
- export interface Manifest {
73
- name: string;
74
- version: string;
75
- skills?: string[];
76
- commands?: string[];
77
- agents?: string[];
78
- }
79
-
80
- export interface ToolConfig {
81
- linkName: string;
82
- }
83
-
84
- /**
85
- * 项目配置导出格式
86
- */
87
- export interface ExportConfig {
88
- version: string;
89
- type: 'project';
90
- config: ProjectConfig;
91
- exportedAt: string;
92
- }
93
-
94
- /**
95
- * 全局配置导出格式
96
- */
97
- export interface GlobalExportConfig {
98
- version: string;
99
- type: 'global';
100
- config: GlobalConfig;
101
- exportedAt: string;
102
- }
103
-
104
- /**
105
- * 模板配置格式
106
- */
107
- export interface TemplateConfig {
108
- version: string;
109
- name: string;
110
- sourceProject: string;
111
- savedAt: string;
112
- config: ProjectConfig;
1
+ export interface SourceConfig {
2
+ type: 'git' | 'local';
3
+ url?: string;
4
+ path?: string;
5
+ }
6
+
7
+ export interface GlobalConfig {
8
+ sourcesDir: string;
9
+ sources: Record<string, SourceConfig>;
10
+ }
11
+
12
+ /**
13
+ * 源选择配置 - 指定从源中导入哪些 skills/commands/agents/rules
14
+ */
15
+ export interface SourceSelection {
16
+ skills: string[];
17
+ commands: string[];
18
+ agents: string[];
19
+ rules: string[];
20
+ }
21
+
22
+ /**
23
+ * 新版项目配置 - sources 使用 Record 格式支持部分导入
24
+ */
25
+ export interface ProjectConfig {
26
+ sources: Record<string, SourceSelection>;
27
+ links: string[];
28
+ }
29
+
30
+ /**
31
+ * 旧版项目配置 - sources 为字符串数组(向后兼容)
32
+ */
33
+ export interface LegacyProjectConfig {
34
+ sources: string[];
35
+ links: string[];
36
+ }
37
+
38
+ /**
39
+ * 判断值是否为有效的 SourceSelection 对象
40
+ */
41
+ export function isSourceSelection(value: unknown): value is SourceSelection {
42
+ if (typeof value !== 'object' || value === null) return false;
43
+ const obj = value as Record<string, unknown>;
44
+ return (
45
+ Array.isArray(obj.skills) &&
46
+ Array.isArray(obj.commands) &&
47
+ Array.isArray(obj.agents) &&
48
+ Array.isArray(obj.rules)
49
+ );
50
+ }
51
+
52
+ /**
53
+ * 将旧版项目配置转换为新版格式
54
+ * 如果 sources 是字符串数组,转换为 Record 格式,每个源默认导入全部内容
55
+ */
56
+ export function normalizeProjectConfig(
57
+ config: LegacyProjectConfig | ProjectConfig
58
+ ): ProjectConfig {
59
+ // If sources is an array, convert to new format
60
+ if (Array.isArray(config.sources)) {
61
+ const newSources: Record<string, SourceSelection> = {};
62
+ for (const sourceName of config.sources) {
63
+ newSources[sourceName] = {
64
+ skills: ['*'],
65
+ commands: ['*'],
66
+ agents: ['*'],
67
+ rules: ['*']
68
+ };
69
+ }
70
+ return { sources: newSources, links: config.links };
71
+ }
72
+ return config as ProjectConfig;
73
+ }
74
+
75
+ export interface Manifest {
76
+ name: string;
77
+ version: string;
78
+ skills?: string[];
79
+ commands?: string[];
80
+ agents?: string[];
81
+ rules?: string[];
82
+ }
83
+
84
+ export interface ToolConfig {
85
+ linkName: string;
86
+ }
87
+
88
+ /**
89
+ * 项目配置导出格式
90
+ */
91
+ export interface ExportConfig {
92
+ version: string;
93
+ type: 'project';
94
+ config: ProjectConfig;
95
+ exportedAt: string;
96
+ }
97
+
98
+ /**
99
+ * 全局配置导出格式
100
+ */
101
+ export interface GlobalExportConfig {
102
+ version: string;
103
+ type: 'global';
104
+ config: GlobalConfig;
105
+ exportedAt: string;
106
+ }
107
+
108
+ /**
109
+ * 模板配置格式
110
+ */
111
+ export interface TemplateConfig {
112
+ version: string;
113
+ name: string;
114
+ sourceProject: string;
115
+ savedAt: string;
116
+ config: ProjectConfig;
113
117
  }
@@ -5,7 +5,7 @@ import { SourceSelection } from '../types/config';
5
5
  */
6
6
  export interface ParsedSourcePath {
7
7
  sourceName: string;
8
- type?: 'skills' | 'commands' | 'agents';
8
+ type?: 'skills' | 'commands' | 'agents' | 'rules';
9
9
  itemName?: string;
10
10
  }
11
11
 
@@ -36,7 +36,7 @@ export function parseSourcePath(input: string): ParsedSourcePath {
36
36
  }
37
37
 
38
38
  // 检查第二部分是否为有效类型
39
- const validTypes = ['skills', 'commands', 'agents'] as const;
39
+ const validTypes = ['skills', 'commands', 'agents', 'rules'] as const;
40
40
  const type = parts[1] as typeof validTypes[number];
41
41
 
42
42
  if (!validTypes.includes(type)) {
@@ -81,7 +81,8 @@ export function buildSelectionFromPaths(paths: string[]): Record<string, SourceS
81
81
  result[sourceName] = {
82
82
  skills: [],
83
83
  commands: [],
84
- agents: []
84
+ agents: [],
85
+ rules: []
85
86
  };
86
87
  }
87
88
 
@@ -90,7 +91,8 @@ export function buildSelectionFromPaths(paths: string[]): Record<string, SourceS
90
91
  result[sourceName] = {
91
92
  skills: ['*'],
92
93
  commands: ['*'],
93
- agents: ['*']
94
+ agents: ['*'],
95
+ rules: ['*']
94
96
  };
95
97
  continue;
96
98
  }
@@ -97,7 +97,8 @@ describe('handleUse Command - buildSelectionFromPaths', () => {
97
97
  'my-skills': {
98
98
  skills: ['a-skill', 'b-skill'],
99
99
  commands: ['test-cmd'],
100
- agents: []
100
+ agents: [],
101
+ rules: []
101
102
  }
102
103
  });
103
104
  });
@@ -111,7 +112,8 @@ describe('handleUse Command - buildSelectionFromPaths', () => {
111
112
  'my-skills': {
112
113
  skills: ['*'],
113
114
  commands: ['*'],
114
- agents: ['*']
115
+ agents: ['*'],
116
+ rules: ['*']
115
117
  }
116
118
  });
117
119
  });
@@ -128,12 +130,14 @@ describe('handleUse Command - buildSelectionFromPaths', () => {
128
130
  'source-a': {
129
131
  skills: ['skill1'],
130
132
  commands: [],
131
- agents: []
133
+ agents: [],
134
+ rules: []
132
135
  },
133
136
  'source-b': {
134
137
  skills: [],
135
138
  commands: ['cmd1'],
136
- agents: []
139
+ agents: [],
140
+ rules: []
137
141
  }
138
142
  });
139
143
  });
@@ -169,7 +173,8 @@ describe('handleUse Command - buildSelectionFromPaths', () => {
169
173
  expect(result['my-skills']).toEqual({
170
174
  skills: ['*'],
171
175
  commands: ['*'],
172
- agents: ['*']
176
+ agents: ['*'],
177
+ rules: ['*']
173
178
  });
174
179
  });
175
180
  });
@@ -271,7 +276,8 @@ describe('handleUse Command - integration tests', () => {
271
276
  'imported-source': {
272
277
  skills: ['test-skill'],
273
278
  commands: [],
274
- agents: []
279
+ agents: [],
280
+ rules: []
275
281
  }
276
282
  },
277
283
  links: []