@spaceflow/core 0.18.0 → 0.20.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaceflow/core",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Spaceflow 核心能力库",
5
5
  "license": "MIT",
6
6
  "author": "Lydanne",
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
+ import { SpaceflowConfigSchema } from "./spaceflow.config";
4
5
 
5
6
  /** Schema 注册信息 */
6
7
  export interface SchemaRegistry {
@@ -39,20 +40,14 @@ export class SchemaGeneratorService {
39
40
  * @param outputPath 输出路径
40
41
  */
41
42
  generateJsonSchema(outputPath: string): void {
42
- const properties: Record<string, unknown> = {
43
- dependencies: {
44
- type: "object",
45
- description: "已安装的技能包注册表",
46
- additionalProperties: { type: "string" },
47
- },
48
- support: {
49
- type: "array",
50
- description: "支持的编辑器列表",
51
- items: { type: "string" },
52
- },
53
- };
43
+ // SpaceflowConfigSchema 生成基础 JSON Schema
44
+ const baseSchema = z.toJSONSchema(SpaceflowConfigSchema, {
45
+ target: "draft-07",
46
+ }) as { properties?: Record<string, unknown>; [key: string]: unknown };
47
+
48
+ const properties: Record<string, unknown> = { ...(baseSchema.properties || {}) };
54
49
 
55
- // 添加所有插件的 schema
50
+ // 添加所有插件的 schema(扩展插件配置)
56
51
  for (const [configKey, registry] of schemaRegistry) {
57
52
  try {
58
53
  const schema = registry.schemaFactory();
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import type { LLMMode } from "../shared/llm-proxy";
3
- import { registerPluginSchema } from "./schema-generator.service";
4
3
  import { detectProvider } from "../shared/git-provider/detect-provider";
5
4
 
6
5
  // 从 @spaceflow/shared 重导出配置工具函数
@@ -177,7 +176,7 @@ const StorageConfigSchema = z.object({
177
176
  // ============ 统一配置 Schema ============
178
177
 
179
178
  /** Spaceflow 完整配置 Schema */
180
- const SpaceflowConfigSchema = z.object({
179
+ export const SpaceflowConfigSchema = z.object({
181
180
  /** 界面语言,如 zh-CN、en */
182
181
  lang: z.string().optional().describe("界面语言,如 zh-CN、en"),
183
182
  /** 已安装的技能包注册表 */
@@ -198,13 +197,6 @@ const SpaceflowConfigSchema = z.object({
198
197
  storage: z.preprocess((v) => v ?? {}, StorageConfigSchema).describe("存储服务配置"),
199
198
  });
200
199
 
201
- // 注册完整 schema(供 JSON Schema 生成使用)
202
- registerPluginSchema({
203
- configKey: "spaceflow",
204
- schemaFactory: () => SpaceflowConfigSchema,
205
- description: "Spaceflow 配置",
206
- });
207
-
208
200
  // ============ 类型导出 ============
209
201
 
210
202
  /** Spaceflow 完整配置类型 */
@@ -385,7 +385,36 @@ export class GiteaAdapter implements GitProvider {
385
385
  // ============ Issue 操作 ============
386
386
 
387
387
  async createIssue(owner: string, repo: string, options: CreateIssueOption): Promise<Issue> {
388
- return this.request<Issue>("POST", `/repos/${owner}/${repo}/issues`, options);
388
+ const body: Record<string, unknown> = {
389
+ title: options.title,
390
+ body: options.body,
391
+ assignees: options.assignees,
392
+ milestone: options.milestone,
393
+ due_date: options.due_date,
394
+ };
395
+ if (options.labels?.length) {
396
+ body.labels = await this.resolveLabelIds(owner, repo, options.labels);
397
+ }
398
+ return this.request<Issue>("POST", `/repos/${owner}/${repo}/issues`, body);
399
+ }
400
+
401
+ /**
402
+ * 将标签名称列表转换为 Gitea label ID 列表
403
+ */
404
+ protected async resolveLabelIds(owner: string, repo: string, names: string[]): Promise<number[]> {
405
+ const allLabels = await this.request<Array<{ id: number; name: string }>>(
406
+ "GET",
407
+ `/repos/${owner}/${repo}/labels`,
408
+ );
409
+ const nameToId = new Map(allLabels.map((l) => [l.name.toLowerCase(), l.id]));
410
+ const ids: number[] = [];
411
+ for (const name of names) {
412
+ const id = nameToId.get(name.toLowerCase());
413
+ if (id !== undefined) {
414
+ ids.push(id);
415
+ }
416
+ }
417
+ return ids;
389
418
  }
390
419
 
391
420
  async listIssueComments(owner: string, repo: string, index: number): Promise<IssueComment[]> {
@@ -277,8 +277,8 @@ export interface CreateIssueOption {
277
277
  body?: string;
278
278
  /** 指派人用户名列表 */
279
279
  assignees?: string[];
280
- /** 标签 ID 列表 */
281
- labels?: number[];
280
+ /** 标签名称列表,各平台 adapter 内部负责名称到 ID 的转换 */
281
+ labels?: string[];
282
282
  /** 里程碑 ID */
283
283
  milestone?: number;
284
284
  /** 截止日期 */