@szc-ft/mcp-szcd-client 0.13.0 → 0.13.2

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.
@@ -131,7 +131,6 @@ function createClaudeCodeProjectConfig(deps) {
131
131
  // ==================== Skill 复制 ====================
132
132
 
133
133
  function copySkillToClaudeCode(deps, isProjectLevel = false) {
134
- const skillName = deps.getMcpServerName();
135
134
  let claudeSkillsDir;
136
135
 
137
136
  if (isProjectLevel) {
@@ -140,18 +139,23 @@ function copySkillToClaudeCode(deps, isProjectLevel = false) {
140
139
  claudeSkillsDir = getClaudeCodeSkillsDirectory();
141
140
  }
142
141
 
143
- const skillDir = path.join(claudeSkillsDir, skillName);
142
+ const skills = deps.discoverSkills();
143
+ let allOk = true;
144
144
 
145
- try {
146
- deps.ensureDirectory(skillDir);
147
- const skillDest = path.join(skillDir, "SKILL.md");
148
- deps.copyFile(deps.SKILL_SOURCE, skillDest);
149
- console.log(`✓ Copied standard skill to Claude Code ${isProjectLevel ? 'project' : 'user'} directory: ${skillDir}`);
150
- return true;
151
- } catch (error) {
152
- console.log(`⚠️ Failed to copy skill to Claude Code ${isProjectLevel ? 'project' : 'user'} directory: ${error.message}`);
153
- return false;
145
+ for (const skill of skills) {
146
+ const skillDir = path.join(claudeSkillsDir, skill.name);
147
+ try {
148
+ deps.ensureDirectory(skillDir);
149
+ const skillDest = path.join(skillDir, "SKILL.md");
150
+ deps.copyFile(skill.sourcePath, skillDest);
151
+ console.log(`✓ Copied skill "${skill.name}" to Claude Code ${isProjectLevel ? 'project' : 'user'} directory: ${skillDir}`);
152
+ } catch (error) {
153
+ console.log(`⚠️ Failed to copy skill "${skill.name}" to Claude Code ${isProjectLevel ? 'project' : 'user'} directory: ${error.message}`);
154
+ allOk = false;
155
+ }
154
156
  }
157
+
158
+ return allOk;
155
159
  }
156
160
 
157
161
  // ==================== Agent 安装 ====================
@@ -14,8 +14,36 @@ import { execSync } from "node:child_process";
14
14
  const __filename = fileURLToPath(import.meta.url);
15
15
  const __dirname = path.dirname(__filename);
16
16
 
17
+ // 默认值(需在 SKILL_SOURCE 之前定义)
18
+ export const DEFAULT_MCP_SERVER_URL = "http://localhost:3456";
19
+ export const DEFAULT_MCP_SERVER_NAME = "szcd-component-helper";
20
+
17
21
  export const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
18
- export const SKILL_SOURCE = path.join(PACKAGE_ROOT, "standard-skill", "SKILL.md");
22
+ export const SKILLS_DIR = path.join(PACKAGE_ROOT, "standard-skill");
23
+
24
+ // 向后兼容:保留 SKILL_SOURCE 指向主技能包
25
+ export const SKILL_SOURCE = path.join(SKILLS_DIR, DEFAULT_MCP_SERVER_NAME, "SKILL.md");
26
+
27
+ /**
28
+ * 扫描 standard-skill/ 目录下所有子目录,发现可安装的技能包。
29
+ * 目录结构约定:standard-skill/<skill-name>/SKILL.md
30
+ * 返回 [{ name, sourcePath }] 数组
31
+ */
32
+ export function discoverSkills() {
33
+ const skills = [];
34
+ if (!fs.existsSync(SKILLS_DIR)) {
35
+ console.warn(`⚠️ Skills directory not found: ${SKILLS_DIR}`);
36
+ return skills;
37
+ }
38
+ for (const entry of fs.readdirSync(SKILLS_DIR, { withFileTypes: true })) {
39
+ if (!entry.isDirectory()) continue;
40
+ const skillFile = path.join(SKILLS_DIR, entry.name, "SKILL.md");
41
+ if (fs.existsSync(skillFile)) {
42
+ skills.push({ name: entry.name, sourcePath: skillFile });
43
+ }
44
+ }
45
+ return skills;
46
+ }
19
47
 
20
48
  // 项目根目录:从 PACKAGE_ROOT 向上推导
21
49
  export function findProjectRoot() {
@@ -32,10 +60,6 @@ export function findProjectRoot() {
32
60
  }
33
61
  export const PROJECT_ROOT = findProjectRoot();
34
62
 
35
- // 默认值
36
- export const DEFAULT_MCP_SERVER_URL = "http://localhost:3456";
37
- export const DEFAULT_MCP_SERVER_NAME = "szcd-component-helper";
38
-
39
63
  // ==================== 安全保护 ====================
40
64
 
41
65
  export const RECURSION_GUARD_ENV = "SZCD_POSTINSTALL_RUNNING";
@@ -171,7 +171,6 @@ function syncQoderSettings(deps) {
171
171
  // ==================== Skill 复制 ====================
172
172
 
173
173
  function copySkillToQoder(deps, isProjectLevel = false) {
174
- const skillName = deps.getMcpServerName();
175
174
  let qoderSkillsDir;
176
175
 
177
176
  if (isProjectLevel) {
@@ -180,18 +179,23 @@ function copySkillToQoder(deps, isProjectLevel = false) {
180
179
  qoderSkillsDir = getQoderSkillsDirectory();
181
180
  }
182
181
 
183
- const skillDir = path.join(qoderSkillsDir, skillName);
182
+ const skills = deps.discoverSkills();
183
+ let allOk = true;
184
184
 
185
- try {
186
- deps.ensureDirectory(skillDir);
187
- const skillDest = path.join(skillDir, "SKILL.md");
188
- deps.copyFile(deps.SKILL_SOURCE, skillDest);
189
- console.log(`✓ Copied skill to Qoder ${isProjectLevel ? "project" : "user"} directory: ${skillDir}`);
190
- return true;
191
- } catch (error) {
192
- console.log(`⚠️ Failed to copy skill to Qoder ${isProjectLevel ? "project" : "user"} directory: ${error.message}`);
193
- return false;
185
+ for (const skill of skills) {
186
+ const skillDir = path.join(qoderSkillsDir, skill.name);
187
+ try {
188
+ deps.ensureDirectory(skillDir);
189
+ const skillDest = path.join(skillDir, "SKILL.md");
190
+ deps.copyFile(skill.sourcePath, skillDest);
191
+ console.log(`✓ Copied skill "${skill.name}" to Qoder ${isProjectLevel ? "project" : "user"} directory: ${skillDir}`);
192
+ } catch (error) {
193
+ console.log(`⚠️ Failed to copy skill "${skill.name}" to Qoder ${isProjectLevel ? "project" : "user"} directory: ${error.message}`);
194
+ allOk = false;
195
+ }
194
196
  }
197
+
198
+ return allOk;
195
199
  }
196
200
 
197
201
  // ==================== Agent 安装 ====================
@@ -14,6 +14,7 @@ import fs from "node:fs";
14
14
  import path from "node:path";
15
15
  import os from "node:os";
16
16
  import { execSync } from "node:child_process";
17
+ import { loadClientCodingConfig, encodeClientConfig } from "./common.js";
17
18
 
18
19
  // ==================== 路径工具 ====================
19
20
 
@@ -168,7 +169,6 @@ export function getTraeCliSkillsDirectory() {
168
169
  }
169
170
 
170
171
  export function copySkillToTraeCli(deps, isProjectLevel = false) {
171
- const skillName = deps.getMcpServerName();
172
172
  let traeCliSkillsDir;
173
173
 
174
174
  if (isProjectLevel) {
@@ -177,18 +177,23 @@ export function copySkillToTraeCli(deps, isProjectLevel = false) {
177
177
  traeCliSkillsDir = getTraeCliSkillsDirectory();
178
178
  }
179
179
 
180
- const skillDir = path.join(traeCliSkillsDir, skillName);
180
+ const skills = deps.discoverSkills();
181
+ let allOk = true;
181
182
 
182
- try {
183
- deps.ensureDirectory(skillDir);
184
- const skillDest = path.join(skillDir, "SKILL.md");
185
- deps.copyFile(deps.SKILL_SOURCE, skillDest);
186
- console.log(`✓ Copied skill to Trae CLI ${isProjectLevel ? 'project' : 'user'} directory: ${skillDir}`);
187
- return true;
188
- } catch (error) {
189
- console.log(`⚠️ Failed to copy skill to Trae CLI ${isProjectLevel ? 'project' : 'user'} directory: ${error.message}`);
190
- return false;
183
+ for (const skill of skills) {
184
+ const skillDir = path.join(traeCliSkillsDir, skill.name);
185
+ try {
186
+ deps.ensureDirectory(skillDir);
187
+ const skillDest = path.join(skillDir, "SKILL.md");
188
+ deps.copyFile(skill.sourcePath, skillDest);
189
+ console.log(`✓ Copied skill "${skill.name}" to Trae CLI ${isProjectLevel ? 'project' : 'user'} directory: ${skillDir}`);
190
+ } catch (error) {
191
+ console.log(`⚠️ Failed to copy skill "${skill.name}" to Trae CLI ${isProjectLevel ? 'project' : 'user'} directory: ${error.message}`);
192
+ allOk = false;
193
+ }
191
194
  }
195
+
196
+ return allOk;
192
197
  }
193
198
 
194
199
  // ==================== Slash Command 安装(Trae CLI) ====================
@@ -146,7 +146,6 @@ export function syncMcpUrl(targetUrl, serverName) {
146
146
  // ==================== Skill 复制 ====================
147
147
 
148
148
  export function copySkillToTrae(deps, isProjectLevel = false) {
149
- const skillName = deps.getMcpServerName();
150
149
  let traeSkillsDir;
151
150
 
152
151
  if (isProjectLevel) {
@@ -155,18 +154,23 @@ export function copySkillToTrae(deps, isProjectLevel = false) {
155
154
  traeSkillsDir = getTraeSkillsDirectory();
156
155
  }
157
156
 
158
- const skillDir = path.join(traeSkillsDir, skillName);
157
+ const skills = deps.discoverSkills();
158
+ let allOk = true;
159
159
 
160
- try {
161
- deps.ensureDirectory(skillDir);
162
- const skillDest = path.join(skillDir, "SKILL.md");
163
- deps.copyFile(deps.SKILL_SOURCE, skillDest);
164
- console.log(`✓ Copied standard skill to Trae ${isProjectLevel ? 'project' : 'user'} directory: ${skillDir}`);
165
- return true;
166
- } catch (error) {
167
- console.log(`⚠️ Failed to copy skill to Trae ${isProjectLevel ? 'project' : 'user'} directory: ${error.message}`);
168
- return false;
160
+ for (const skill of skills) {
161
+ const skillDir = path.join(traeSkillsDir, skill.name);
162
+ try {
163
+ deps.ensureDirectory(skillDir);
164
+ const skillDest = path.join(skillDir, "SKILL.md");
165
+ deps.copyFile(skill.sourcePath, skillDest);
166
+ console.log(`✓ Copied skill "${skill.name}" to Trae ${isProjectLevel ? 'project' : 'user'} directory: ${skillDir}`);
167
+ } catch (error) {
168
+ console.log(`⚠️ Failed to copy skill "${skill.name}" to Trae ${isProjectLevel ? 'project' : 'user'} directory: ${error.message}`);
169
+ allOk = false;
170
+ }
169
171
  }
172
+
173
+ return allOk;
170
174
  }
171
175
 
172
176
  // ==================== Agent 复制(Trae IDE) ====================
@@ -39,6 +39,7 @@ const deps = {
39
39
  ensureDirectory: common.ensureDirectory,
40
40
  copyFile: common.copyFile,
41
41
  writeFile: common.writeFile,
42
+ discoverSkills: common.discoverSkills,
42
43
  SKILL_SOURCE: common.SKILL_SOURCE,
43
44
  PROJECT_ROOT: common.PROJECT_ROOT,
44
45
  PACKAGE_ROOT: common.PACKAGE_ROOT,
@@ -158,11 +159,12 @@ function main() {
158
159
  console.log("\n🔧 Setting up szcd-component-helper client...\n");
159
160
 
160
161
  console.log(`📁 Package root: ${common.PACKAGE_ROOT}`);
161
- console.log(`📄 Skill source: ${common.SKILL_SOURCE}`);
162
162
 
163
- if (!fs.existsSync(common.SKILL_SOURCE)) {
164
- throw new Error(`Skill source file not found: ${common.SKILL_SOURCE}`);
163
+ const discoveredSkills = common.discoverSkills();
164
+ if (discoveredSkills.length === 0) {
165
+ throw new Error(`No skills found in ${common.SKILLS_DIR}. Expected subdirectories with SKILL.md files.`);
165
166
  }
167
+ console.log(`📄 Found ${discoveredSkills.length} skill(s): ${discoveredSkills.map(s => s.name).join(", ")}`);
166
168
 
167
169
  // ---- 配置文件 ----
168
170
  createConfigTemplate();
@@ -196,7 +198,7 @@ function main() {
196
198
  console.error(`- Node version: ${process.version}`);
197
199
  console.error(`- Platform: ${process.platform}`);
198
200
  console.error(`- Package root: ${common.PACKAGE_ROOT}`);
199
- console.error(`- Skill source: ${common.SKILL_SOURCE}`);
201
+ console.error(`- Skills directory: ${common.SKILLS_DIR}`);
200
202
  process.exit(1);
201
203
  }
202
204
  }