@spaceflow/core 0.17.0 → 0.19.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 +125 -114
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/config/schema-generator.service.ts +8 -13
- package/src/config/spaceflow.config.ts +1 -9
- package/src/shared/git-provider/adapters/gitea.adapter.ts +24 -2
- package/src/shared/git-provider/adapters/github.adapter.ts +4 -2
- package/src/shared/git-provider/types.ts +2 -0
package/package.json
CHANGED
|
@@ -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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 完整配置类型 */
|
|
@@ -497,8 +497,30 @@ export class GiteaAdapter implements GitProvider {
|
|
|
497
497
|
await this.request<void>("DELETE", `/repos/${owner}/${repo}/pulls/comments/${commentId}`);
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
async listResolvedThreads(): Promise<ResolvedThread[]> {
|
|
501
|
-
|
|
500
|
+
async listResolvedThreads(owner: string, repo: string, index: number): Promise<ResolvedThread[]> {
|
|
501
|
+
const result: ResolvedThread[] = [];
|
|
502
|
+
try {
|
|
503
|
+
const reviews = await this.listPullReviews(owner, repo, index);
|
|
504
|
+
for (const review of reviews) {
|
|
505
|
+
if (!review.id) continue;
|
|
506
|
+
const comments = await this.listPullReviewComments(owner, repo, index, review.id);
|
|
507
|
+
for (const comment of comments) {
|
|
508
|
+
if (!comment.resolver) continue;
|
|
509
|
+
result.push({
|
|
510
|
+
path: comment.path,
|
|
511
|
+
line: comment.position,
|
|
512
|
+
resolvedBy: {
|
|
513
|
+
id: comment.resolver.id,
|
|
514
|
+
login: comment.resolver.login,
|
|
515
|
+
},
|
|
516
|
+
body: comment.body,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
} catch {
|
|
521
|
+
// 获取失败时返回空数组,不影响主流程
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
502
524
|
}
|
|
503
525
|
|
|
504
526
|
// ============ Reaction 操作 ============
|
|
@@ -37,7 +37,7 @@ interface GraphQLReviewThread {
|
|
|
37
37
|
resolvedBy?: { login: string; databaseId: number } | null;
|
|
38
38
|
path?: string | null;
|
|
39
39
|
line?: number | null;
|
|
40
|
-
comments: { nodes: Array<{ databaseId: number }> };
|
|
40
|
+
comments: { nodes: Array<{ databaseId: number; body?: string }> };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -838,12 +838,14 @@ export class GithubAdapter implements GitProvider {
|
|
|
838
838
|
const result: ResolvedThread[] = [];
|
|
839
839
|
for (const thread of threads) {
|
|
840
840
|
if (!thread.isResolved) continue;
|
|
841
|
+
const firstComment = thread.comments.nodes[0];
|
|
841
842
|
result.push({
|
|
842
843
|
path: thread.path ?? undefined,
|
|
843
844
|
line: thread.line ?? undefined,
|
|
844
845
|
resolvedBy: thread.resolvedBy
|
|
845
846
|
? { id: thread.resolvedBy.databaseId, login: thread.resolvedBy.login }
|
|
846
847
|
: null,
|
|
848
|
+
body: firstComment?.body,
|
|
847
849
|
});
|
|
848
850
|
}
|
|
849
851
|
return result;
|
|
@@ -868,7 +870,7 @@ export class GithubAdapter implements GitProvider {
|
|
|
868
870
|
path
|
|
869
871
|
line
|
|
870
872
|
comments(first: 1) {
|
|
871
|
-
nodes { databaseId }
|
|
873
|
+
nodes { databaseId body }
|
|
872
874
|
}
|
|
873
875
|
}
|
|
874
876
|
}
|