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.
- package/CHANGELOG.md +19 -0
- package/CHANGELOG_en.md +19 -0
- package/README.md +31 -5
- package/README_en.md +31 -5
- package/dist/commands/help.js +18 -1
- package/dist/commands/template.d.ts +3 -1
- package/dist/commands/template.js +38 -6
- package/dist/commands/use.js +11 -1
- package/dist/core/manifest.js +10 -1
- package/dist/core/project.js +27 -1
- package/dist/index.js +3 -2
- package/dist/types/config.d.ts +3 -1
- package/dist/types/config.js +4 -2
- package/dist/utils/parsePath.d.ts +1 -1
- package/dist/utils/parsePath.js +5 -3
- package/package.json +1 -1
- package/src/commands/help.ts +18 -1
- package/src/commands/template.ts +202 -160
- package/src/commands/use.ts +11 -1
- package/src/core/manifest.ts +67 -57
- package/src/core/project.ts +304 -276
- package/src/index.ts +254 -253
- package/src/types/config.ts +116 -112
- package/src/utils/parsePath.ts +6 -4
- package/tests/commands/use.test.ts +12 -6
- package/tests/core/project.test.ts +324 -316
- package/tests/types/config.test.ts +44 -16
- package/tests/utils/parsePath.test.ts +18 -9
package/src/types/config.ts
CHANGED
|
@@ -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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Array.isArray(obj.
|
|
46
|
-
Array.isArray(obj.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
}
|
package/src/utils/parsePath.ts
CHANGED
|
@@ -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: []
|