@spaceflow/core 0.19.0 → 0.21.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 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 || "";
@@ -1026,7 +1026,34 @@ function parseDiffText(diffText) {
1026
1026
  }
1027
1027
  // ============ Issue 操作 ============
1028
1028
  async createIssue(owner, repo, options) {
1029
- return this.request("POST", `/repos/${owner}/${repo}/issues`, options);
1029
+ const body = {
1030
+ title: options.title,
1031
+ body: options.body,
1032
+ assignees: options.assignees,
1033
+ milestone: options.milestone,
1034
+ due_date: options.due_date
1035
+ };
1036
+ if (options.labels?.length) {
1037
+ body.labels = await this.resolveLabelIds(owner, repo, options.labels);
1038
+ }
1039
+ return this.request("POST", `/repos/${owner}/${repo}/issues`, body);
1040
+ }
1041
+ /**
1042
+ * 将标签名称列表转换为 Gitea label ID 列表
1043
+ */ async resolveLabelIds(owner, repo, names) {
1044
+ const allLabels = await this.request("GET", `/repos/${owner}/${repo}/labels`);
1045
+ const nameToId = new Map(allLabels.map((l)=>[
1046
+ l.name.toLowerCase(),
1047
+ l.id
1048
+ ]));
1049
+ const ids = [];
1050
+ for (const name of names){
1051
+ const id = nameToId.get(name.toLowerCase());
1052
+ if (id !== undefined) {
1053
+ ids.push(id);
1054
+ }
1055
+ }
1056
+ return ids;
1030
1057
  }
1031
1058
  async listIssueComments(owner, repo, index) {
1032
1059
  return this.request("GET", `/repos/${owner}/${repo}/issues/${index}/comments`);
@@ -5932,9 +5959,9 @@ var external_zod_ = __webpack_require__(971);
5932
5959
  token: external_zod_.z.string().default(spaceflow_config_detected.token).describe("Git Provider API Token")
5933
5960
  });
5934
5961
  /** CI 配置 Schema */ const CiConfigSchema = external_zod_.z.object({
5935
- repository: external_zod_.z.string().default(process.env.GITHUB_REPOSITORY || "").describe("仓库名称 (owner/repo 格式)"),
5936
- refName: external_zod_.z.string().default(process.env.GITHUB_REF_NAME || "").describe("当前分支名称"),
5937
- 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("当前操作者")
5938
5965
  });
5939
5966
  /** Claude Code 适配器配置 Schema */ const ClaudeCodeConfigSchema = external_zod_.z.object({
5940
5967
  baseUrl: external_zod_.z.string().default(process.env.CLAUDE_CODE_BASE_URL || "").describe("API 基础 URL"),
@@ -11434,7 +11461,7 @@ async function exec(extensions = [], options = {}) {
11434
11461
  // 6. 创建 CLI 程序
11435
11462
  const program = new Command();
11436
11463
  const cliVersion = options.cliVersion || "0.0.0";
11437
- const coreVersion = true ? "0.19.0" : 0;
11464
+ const coreVersion = true ? "0.21.0" : 0;
11438
11465
  const versionOutput = `spaceflow/${cliVersion} core/${coreVersion}`;
11439
11466
  program.name("spaceflow").description("Spaceflow CLI").version(versionOutput, "-V, --version", "显示版本信息");
11440
11467
  // 定义全局 verbose 选项(支持计数:-v, -vv, -vvv)