@spaceflow/core 0.21.0 → 0.22.0
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/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/install/install.service.ts +23 -23
package/package.json
CHANGED
|
@@ -66,7 +66,7 @@ export interface McpExportItem {
|
|
|
66
66
|
* 插件配置类型
|
|
67
67
|
*/
|
|
68
68
|
export type PluginConfig = Record<
|
|
69
|
-
"flows" | "commands" | "
|
|
69
|
+
"flows" | "commands" | "skills",
|
|
70
70
|
Array<{ name: string; entry: string }>
|
|
71
71
|
> & {
|
|
72
72
|
mcps: McpExportItem[];
|
|
@@ -97,10 +97,10 @@ export class InstallService {
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* 将插件关联到各个编辑器的目录
|
|
100
|
-
* pluginConfig 包含 flows/commands/
|
|
100
|
+
* pluginConfig 包含 flows/commands/skills/mcps 四种类型
|
|
101
101
|
* - flows: CLI 子命令,不需要复制到编辑器目录
|
|
102
102
|
* - commands: 编辑器命令,复制到 .claude/commands/ 等目录
|
|
103
|
-
* -
|
|
103
|
+
* - skills: 技能文件,复制到 .claude/skills/ 等目录
|
|
104
104
|
* - mcps: MCP Server,注册到编辑器的 mcp.json 配置
|
|
105
105
|
*/
|
|
106
106
|
protected async linkPluginToEditors(options: {
|
|
@@ -120,19 +120,19 @@ export class InstallService {
|
|
|
120
120
|
const editorDirName = getEditorDirName(editor);
|
|
121
121
|
const editorRoot = isGlobal ? join(home, editorDirName) : join(workingDir, editorDirName);
|
|
122
122
|
|
|
123
|
-
// 处理
|
|
124
|
-
if (pluginConfig.
|
|
125
|
-
const
|
|
126
|
-
await this.ensureDir(
|
|
123
|
+
// 处理 skills
|
|
124
|
+
if (pluginConfig.skills.length > 0) {
|
|
125
|
+
const editorSkillsDir = join(editorRoot, "skills");
|
|
126
|
+
await this.ensureDir(editorSkillsDir, verbose);
|
|
127
127
|
|
|
128
|
-
for (const
|
|
129
|
-
const
|
|
130
|
-
const installName =
|
|
131
|
-
const targetPath = join(
|
|
128
|
+
for (const skill of pluginConfig.skills) {
|
|
129
|
+
const skillPath = skill.entry === "." ? depPath : join(depPath, skill.entry);
|
|
130
|
+
const installName = skill.name || name;
|
|
131
|
+
const targetPath = join(editorSkillsDir, installName);
|
|
132
132
|
|
|
133
|
-
await this.copyExtensionToTarget(
|
|
133
|
+
await this.copyExtensionToTarget(skillPath, targetPath, installName);
|
|
134
134
|
|
|
135
|
-
//
|
|
135
|
+
// 将生成的技能文件加入编辑器目录的 .gitignore
|
|
136
136
|
await ensureEditorGitignore(editorRoot, "skills", installName);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -676,7 +676,7 @@ export class InstallService {
|
|
|
676
676
|
console.warn(t("install:pmInstallFailed", { pm }));
|
|
677
677
|
}
|
|
678
678
|
|
|
679
|
-
// 3. 处理每个依赖的
|
|
679
|
+
// 3. 处理每个依赖的 skills/commands 关联
|
|
680
680
|
for (const [name, config] of Object.entries(dependencies)) {
|
|
681
681
|
const { source } = this.parseExtensionConfig(config);
|
|
682
682
|
const sourceType = getSourceType(source);
|
|
@@ -1030,19 +1030,19 @@ export class InstallService {
|
|
|
1030
1030
|
|
|
1031
1031
|
/**
|
|
1032
1032
|
* 从 package.json 读取插件配置
|
|
1033
|
-
* 返回 { flows: [], commands: [],
|
|
1033
|
+
* 返回 { flows: [], commands: [], skills: [], mcps: [] } 格式的导出映射
|
|
1034
1034
|
*/
|
|
1035
1035
|
protected async getPluginConfigFromPackageJson(extPath: string): Promise<PluginConfig> {
|
|
1036
1036
|
const createEmptyConfig = (): PluginConfig => ({
|
|
1037
1037
|
flows: [],
|
|
1038
1038
|
commands: [],
|
|
1039
|
-
|
|
1039
|
+
skills: [],
|
|
1040
1040
|
mcps: [],
|
|
1041
1041
|
});
|
|
1042
|
-
const
|
|
1042
|
+
const createDefaultSkill = (name = ""): PluginConfig => ({
|
|
1043
1043
|
flows: [],
|
|
1044
1044
|
commands: [],
|
|
1045
|
-
|
|
1045
|
+
skills: [{ name, entry: "." }],
|
|
1046
1046
|
mcps: [],
|
|
1047
1047
|
});
|
|
1048
1048
|
|
|
@@ -1055,13 +1055,13 @@ export class InstallService {
|
|
|
1055
1055
|
) => {
|
|
1056
1056
|
if (type === "flow") config.flows.push({ name, entry });
|
|
1057
1057
|
else if (type === "command") config.commands.push({ name, entry });
|
|
1058
|
-
else if (type === "
|
|
1058
|
+
else if (type === "skill") config.skills.push({ name, entry });
|
|
1059
1059
|
else if (type === "mcp") config.mcps.push({ name, entry, mcp });
|
|
1060
1060
|
};
|
|
1061
1061
|
|
|
1062
1062
|
const pkgJsonPath = join(extPath, "package.json");
|
|
1063
1063
|
if (!existsSync(pkgJsonPath)) {
|
|
1064
|
-
return
|
|
1064
|
+
return createDefaultSkill();
|
|
1065
1065
|
}
|
|
1066
1066
|
|
|
1067
1067
|
try {
|
|
@@ -1070,7 +1070,7 @@ export class InstallService {
|
|
|
1070
1070
|
const spaceflowConfig = pkg.spaceflow;
|
|
1071
1071
|
|
|
1072
1072
|
if (!spaceflowConfig) {
|
|
1073
|
-
return
|
|
1073
|
+
return createDefaultSkill(pkg.name);
|
|
1074
1074
|
}
|
|
1075
1075
|
|
|
1076
1076
|
const config = createEmptyConfig();
|
|
@@ -1100,9 +1100,9 @@ export class InstallService {
|
|
|
1100
1100
|
return config;
|
|
1101
1101
|
}
|
|
1102
1102
|
|
|
1103
|
-
return
|
|
1103
|
+
return createDefaultSkill(pkg.name);
|
|
1104
1104
|
} catch {
|
|
1105
|
-
return
|
|
1105
|
+
return createDefaultSkill();
|
|
1106
1106
|
}
|
|
1107
1107
|
}
|
|
1108
1108
|
|