@spaceflow/core 0.20.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 +30 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__mocks__/c12.ts +3 -1
- package/src/cli-runtime/i18n/i18n.spec.ts +2 -1
- package/src/commands/build/build.service.ts +1 -1
- package/src/commands/install/install.service.ts +23 -23
- package/src/commands/list/list.service.ts +1 -1
- package/src/commands/update/update.service.ts +2 -2
- package/src/config/spaceflow.config.ts +3 -3
- package/src/shared/git-provider/detect-provider.ts +4 -4
- package/src/shared/logger/logger.spec.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -451,14 +451,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
451
451
|
* 解析服务器 URL
|
|
452
452
|
* - 优先使用 GIT_PROVIDER_URL
|
|
453
453
|
* - Gitea: GITEA_SERVER_URL > GITHUB_SERVER_URL
|
|
454
|
-
* - GitHub: GITHUB_API_URL > 默认 https://api.github.com
|
|
454
|
+
* - GitHub: GITHUB_API_URL > GITEA_API_URL > 默认 https://api.github.com
|
|
455
455
|
* - GitLab: CI_SERVER_URL > GITLAB_URL
|
|
456
456
|
*/ function resolveServerUrl(provider, env) {
|
|
457
457
|
if (env.GIT_PROVIDER_URL) {
|
|
458
458
|
return env.GIT_PROVIDER_URL;
|
|
459
459
|
}
|
|
460
460
|
if (provider === "github") {
|
|
461
|
-
return env.GITHUB_API_URL || "https://api.github.com";
|
|
461
|
+
return env.GITHUB_API_URL || env.GITEA_API_URL || "https://api.github.com";
|
|
462
462
|
}
|
|
463
463
|
if (provider === "gitlab") {
|
|
464
464
|
return env.CI_SERVER_URL || env.GITLAB_URL || "https://gitlab.com";
|
|
@@ -476,14 +476,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
476
476
|
* 解析 API Token
|
|
477
477
|
* - 优先使用 GIT_PROVIDER_TOKEN
|
|
478
478
|
* - Gitea: GITEA_TOKEN > GITHUB_TOKEN
|
|
479
|
-
* - GitHub: GITHUB_TOKEN
|
|
479
|
+
* - GitHub: GITHUB_TOKEN > GITEA_TOKEN
|
|
480
480
|
* - GitLab: GITLAB_TOKEN > CI_JOB_TOKEN
|
|
481
481
|
*/ function resolveToken(provider, env) {
|
|
482
482
|
if (env.GIT_PROVIDER_TOKEN) {
|
|
483
483
|
return env.GIT_PROVIDER_TOKEN;
|
|
484
484
|
}
|
|
485
485
|
if (provider === "github") {
|
|
486
|
-
return env.GITHUB_TOKEN || "";
|
|
486
|
+
return env.GITHUB_TOKEN || env.GITEA_TOKEN || "";
|
|
487
487
|
}
|
|
488
488
|
if (provider === "gitlab") {
|
|
489
489
|
return env.GITLAB_TOKEN || env.CI_JOB_TOKEN || "";
|
|
@@ -5959,9 +5959,9 @@ var external_zod_ = __webpack_require__(971);
|
|
|
5959
5959
|
token: external_zod_.z.string().default(spaceflow_config_detected.token).describe("Git Provider API Token")
|
|
5960
5960
|
});
|
|
5961
5961
|
/** CI 配置 Schema */ const CiConfigSchema = external_zod_.z.object({
|
|
5962
|
-
repository: external_zod_.z.string().default(process.env.GITHUB_REPOSITORY || "").describe("仓库名称 (owner/repo 格式)"),
|
|
5963
|
-
refName: external_zod_.z.string().default(process.env.GITHUB_REF_NAME || "").describe("当前分支名称"),
|
|
5964
|
-
actor: external_zod_.z.string().default(process.env.GITHUB_ACTOR || "").describe("当前操作者")
|
|
5962
|
+
repository: external_zod_.z.string().default(process.env.GITHUB_REPOSITORY || process.env.GITEA_REPOSITORY || "").describe("仓库名称 (owner/repo 格式)"),
|
|
5963
|
+
refName: external_zod_.z.string().default(process.env.GITHUB_REF_NAME || process.env.GITEA_REF_NAME || "").describe("当前分支名称"),
|
|
5964
|
+
actor: external_zod_.z.string().default(process.env.GITHUB_ACTOR || process.env.GITEA_ACTOR || "").describe("当前操作者")
|
|
5965
5965
|
});
|
|
5966
5966
|
/** Claude Code 适配器配置 Schema */ const ClaudeCodeConfigSchema = external_zod_.z.object({
|
|
5967
5967
|
baseUrl: external_zod_.z.string().default(process.env.CLAUDE_CODE_BASE_URL || "").describe("API 基础 URL"),
|
|
@@ -8495,10 +8495,10 @@ class InstallService {
|
|
|
8495
8495
|
}
|
|
8496
8496
|
/**
|
|
8497
8497
|
* 将插件关联到各个编辑器的目录
|
|
8498
|
-
* pluginConfig 包含 flows/commands/
|
|
8498
|
+
* pluginConfig 包含 flows/commands/skills/mcps 四种类型
|
|
8499
8499
|
* - flows: CLI 子命令,不需要复制到编辑器目录
|
|
8500
8500
|
* - commands: 编辑器命令,复制到 .claude/commands/ 等目录
|
|
8501
|
-
* -
|
|
8501
|
+
* - skills: 技能文件,复制到 .claude/skills/ 等目录
|
|
8502
8502
|
* - mcps: MCP Server,注册到编辑器的 mcp.json 配置
|
|
8503
8503
|
*/ async linkPluginToEditors(options) {
|
|
8504
8504
|
const { name, depPath, pluginConfig, cwd, isGlobal = false, verbose = 1 } = options;
|
|
@@ -8508,16 +8508,16 @@ class InstallService {
|
|
|
8508
8508
|
for (const editor of editors){
|
|
8509
8509
|
const editorDirName = getEditorDirName(editor);
|
|
8510
8510
|
const editorRoot = isGlobal ? (0,external_path_.join)(home, editorDirName) : (0,external_path_.join)(workingDir, editorDirName);
|
|
8511
|
-
// 处理
|
|
8512
|
-
if (pluginConfig.
|
|
8513
|
-
const
|
|
8514
|
-
await this.ensureDir(
|
|
8515
|
-
for (const
|
|
8516
|
-
const
|
|
8517
|
-
const installName =
|
|
8518
|
-
const targetPath = (0,external_path_.join)(
|
|
8519
|
-
await this.copyExtensionToTarget(
|
|
8520
|
-
//
|
|
8511
|
+
// 处理 skills
|
|
8512
|
+
if (pluginConfig.skills.length > 0) {
|
|
8513
|
+
const editorSkillsDir = (0,external_path_.join)(editorRoot, "skills");
|
|
8514
|
+
await this.ensureDir(editorSkillsDir, verbose);
|
|
8515
|
+
for (const skill of pluginConfig.skills){
|
|
8516
|
+
const skillPath = skill.entry === "." ? depPath : (0,external_path_.join)(depPath, skill.entry);
|
|
8517
|
+
const installName = skill.name || name;
|
|
8518
|
+
const targetPath = (0,external_path_.join)(editorSkillsDir, installName);
|
|
8519
|
+
await this.copyExtensionToTarget(skillPath, targetPath, installName);
|
|
8520
|
+
// 将生成的技能文件加入编辑器目录的 .gitignore
|
|
8521
8521
|
await ensureEditorGitignore(editorRoot, "skills", installName);
|
|
8522
8522
|
}
|
|
8523
8523
|
}
|
|
@@ -9018,7 +9018,7 @@ class InstallService {
|
|
|
9018
9018
|
pm
|
|
9019
9019
|
}));
|
|
9020
9020
|
}
|
|
9021
|
-
// 3. 处理每个依赖的
|
|
9021
|
+
// 3. 处理每个依赖的 skills/commands 关联
|
|
9022
9022
|
for (const [name, config] of Object.entries(dependencies)){
|
|
9023
9023
|
const { source } = this.parseExtensionConfig(config);
|
|
9024
9024
|
const sourceType = getSourceType(source);
|
|
@@ -9311,18 +9311,18 @@ class InstallService {
|
|
|
9311
9311
|
}
|
|
9312
9312
|
/**
|
|
9313
9313
|
* 从 package.json 读取插件配置
|
|
9314
|
-
* 返回 { flows: [], commands: [],
|
|
9314
|
+
* 返回 { flows: [], commands: [], skills: [], mcps: [] } 格式的导出映射
|
|
9315
9315
|
*/ async getPluginConfigFromPackageJson(extPath) {
|
|
9316
9316
|
const createEmptyConfig = ()=>({
|
|
9317
9317
|
flows: [],
|
|
9318
9318
|
commands: [],
|
|
9319
|
-
|
|
9319
|
+
skills: [],
|
|
9320
9320
|
mcps: []
|
|
9321
9321
|
});
|
|
9322
|
-
const
|
|
9322
|
+
const createDefaultSkill = (name = "")=>({
|
|
9323
9323
|
flows: [],
|
|
9324
9324
|
commands: [],
|
|
9325
|
-
|
|
9325
|
+
skills: [
|
|
9326
9326
|
{
|
|
9327
9327
|
name,
|
|
9328
9328
|
entry: "."
|
|
@@ -9339,7 +9339,7 @@ class InstallService {
|
|
|
9339
9339
|
name,
|
|
9340
9340
|
entry
|
|
9341
9341
|
});
|
|
9342
|
-
else if (type === "
|
|
9342
|
+
else if (type === "skill") config.skills.push({
|
|
9343
9343
|
name,
|
|
9344
9344
|
entry
|
|
9345
9345
|
});
|
|
@@ -9351,14 +9351,14 @@ class InstallService {
|
|
|
9351
9351
|
};
|
|
9352
9352
|
const pkgJsonPath = (0,external_path_.join)(extPath, "package.json");
|
|
9353
9353
|
if (!existsSync(pkgJsonPath)) {
|
|
9354
|
-
return
|
|
9354
|
+
return createDefaultSkill();
|
|
9355
9355
|
}
|
|
9356
9356
|
try {
|
|
9357
9357
|
const content = await (0,promises_.readFile)(pkgJsonPath, "utf-8");
|
|
9358
9358
|
const pkg = JSON.parse(content);
|
|
9359
9359
|
const spaceflowConfig = pkg.spaceflow;
|
|
9360
9360
|
if (!spaceflowConfig) {
|
|
9361
|
-
return
|
|
9361
|
+
return createDefaultSkill(pkg.name);
|
|
9362
9362
|
}
|
|
9363
9363
|
const config = createEmptyConfig();
|
|
9364
9364
|
// 完整格式:exports 对象
|
|
@@ -9374,9 +9374,9 @@ class InstallService {
|
|
|
9374
9374
|
addExport(config, spaceflowConfig.type || "flow", pkg.name || "", spaceflowConfig.entry, spaceflowConfig.mcp);
|
|
9375
9375
|
return config;
|
|
9376
9376
|
}
|
|
9377
|
-
return
|
|
9377
|
+
return createDefaultSkill(pkg.name);
|
|
9378
9378
|
} catch {
|
|
9379
|
-
return
|
|
9379
|
+
return createDefaultSkill();
|
|
9380
9380
|
}
|
|
9381
9381
|
}
|
|
9382
9382
|
/**
|
|
@@ -11461,7 +11461,7 @@ async function exec(extensions = [], options = {}) {
|
|
|
11461
11461
|
// 6. 创建 CLI 程序
|
|
11462
11462
|
const program = new Command();
|
|
11463
11463
|
const cliVersion = options.cliVersion || "0.0.0";
|
|
11464
|
-
const coreVersion = true ? "0.
|
|
11464
|
+
const coreVersion = true ? "0.22.0" : 0;
|
|
11465
11465
|
const versionOutput = `spaceflow/${cliVersion} core/${coreVersion}`;
|
|
11466
11466
|
program.name("spaceflow").description("Spaceflow CLI").version(versionOutput, "-V, --version", "显示版本信息");
|
|
11467
11467
|
// 定义全局 verbose 选项(支持计数:-v, -vv, -vvv)
|