@content-reviewer/core 0.0.4 → 0.0.5
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.d.mts +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +30 -50
- package/dist/index.mjs +30 -50
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -23,11 +23,28 @@ declare const reviewResponseSchema: z.ZodObject<{
|
|
|
23
23
|
lineNumber: z.ZodOptional<z.ZodNumber>;
|
|
24
24
|
suggestion: z.ZodOptional<z.ZodString>;
|
|
25
25
|
}, z.core.$strip>>;
|
|
26
|
-
summary: z.ZodString;
|
|
27
26
|
}, z.core.$strip>;
|
|
28
27
|
type ReviewIssueSchema = z.infer<typeof reviewIssueSchema>;
|
|
29
28
|
type ReviewResponseSchema = z.infer<typeof reviewResponseSchema>;
|
|
30
29
|
|
|
30
|
+
declare const SEVERITIES: {
|
|
31
|
+
readonly error: {
|
|
32
|
+
readonly priority: 3;
|
|
33
|
+
};
|
|
34
|
+
readonly warning: {
|
|
35
|
+
readonly priority: 2;
|
|
36
|
+
};
|
|
37
|
+
readonly suggestion: {
|
|
38
|
+
readonly priority: 1;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type SeverityKey = keyof typeof SEVERITIES;
|
|
42
|
+
type IssueSeverity = SeverityKey;
|
|
43
|
+
declare const SEVERITY_LEVELS: {
|
|
44
|
+
[K in IssueSeverity]: number;
|
|
45
|
+
};
|
|
46
|
+
declare const DEFAULT_SEVERITY_LEVEL: IssueSeverity;
|
|
47
|
+
|
|
31
48
|
type Document = Readonly<{
|
|
32
49
|
rawContent: string;
|
|
33
50
|
source: string;
|
|
@@ -48,7 +65,6 @@ type ReviewConfig = Readonly<{
|
|
|
48
65
|
llm: LLMConfig;
|
|
49
66
|
severityLevel?: IssueSeverity;
|
|
50
67
|
}>;
|
|
51
|
-
type IssueSeverity = 'error' | 'warning' | 'suggestion';
|
|
52
68
|
type ReviewIssue = Readonly<{
|
|
53
69
|
severity: IssueSeverity;
|
|
54
70
|
message: string;
|
|
@@ -59,7 +75,6 @@ type ReviewIssue = Readonly<{
|
|
|
59
75
|
type ReviewResult = Readonly<{
|
|
60
76
|
source: string;
|
|
61
77
|
issues: ReviewIssue[];
|
|
62
|
-
summary: string;
|
|
63
78
|
reviewedAt: Date;
|
|
64
79
|
}>;
|
|
65
80
|
|
|
@@ -119,8 +134,6 @@ declare const ENV_VARS: {
|
|
|
119
134
|
readonly GOOGLE_API_KEY: "GOOGLE_API_KEY";
|
|
120
135
|
};
|
|
121
136
|
|
|
122
|
-
declare const SEVERITY_LEVELS: Readonly<Record<IssueSeverity, number>>;
|
|
123
|
-
declare const DEFAULT_SEVERITY_LEVEL: IssueSeverity;
|
|
124
137
|
declare function filterIssuesBySeverity(issues: readonly ReviewIssue[], minLevel: IssueSeverity): ReviewIssue[];
|
|
125
138
|
|
|
126
139
|
export { AISdkClient, ContentReviewer, ContentReviewerError, DEFAULT_CONFIG, DEFAULT_INSTRUCTION_EN, DEFAULT_INSTRUCTION_JA, DEFAULT_LLM_CONFIG, DEFAULT_SEVERITY_LEVEL, type Document, ENV_VARS, type IssueSeverity, type LLMClient, type LLMConfig, LLMError, type LLMProvider, type Language, MissingApiKeyError, PROVIDER_DEFAULT_MODELS, type ReviewConfig, type ReviewConfigInput, type ReviewIssue, type ReviewIssueSchema, type ReviewResponseSchema, type ReviewResult, SEVERITY_LEVELS, UnsupportedProviderError, createLLMClient, createReviewConfig, filterIssuesBySeverity, resolveApiKey, reviewIssueSchema, reviewResponseSchema, validateConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,11 +23,28 @@ declare const reviewResponseSchema: z.ZodObject<{
|
|
|
23
23
|
lineNumber: z.ZodOptional<z.ZodNumber>;
|
|
24
24
|
suggestion: z.ZodOptional<z.ZodString>;
|
|
25
25
|
}, z.core.$strip>>;
|
|
26
|
-
summary: z.ZodString;
|
|
27
26
|
}, z.core.$strip>;
|
|
28
27
|
type ReviewIssueSchema = z.infer<typeof reviewIssueSchema>;
|
|
29
28
|
type ReviewResponseSchema = z.infer<typeof reviewResponseSchema>;
|
|
30
29
|
|
|
30
|
+
declare const SEVERITIES: {
|
|
31
|
+
readonly error: {
|
|
32
|
+
readonly priority: 3;
|
|
33
|
+
};
|
|
34
|
+
readonly warning: {
|
|
35
|
+
readonly priority: 2;
|
|
36
|
+
};
|
|
37
|
+
readonly suggestion: {
|
|
38
|
+
readonly priority: 1;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type SeverityKey = keyof typeof SEVERITIES;
|
|
42
|
+
type IssueSeverity = SeverityKey;
|
|
43
|
+
declare const SEVERITY_LEVELS: {
|
|
44
|
+
[K in IssueSeverity]: number;
|
|
45
|
+
};
|
|
46
|
+
declare const DEFAULT_SEVERITY_LEVEL: IssueSeverity;
|
|
47
|
+
|
|
31
48
|
type Document = Readonly<{
|
|
32
49
|
rawContent: string;
|
|
33
50
|
source: string;
|
|
@@ -48,7 +65,6 @@ type ReviewConfig = Readonly<{
|
|
|
48
65
|
llm: LLMConfig;
|
|
49
66
|
severityLevel?: IssueSeverity;
|
|
50
67
|
}>;
|
|
51
|
-
type IssueSeverity = 'error' | 'warning' | 'suggestion';
|
|
52
68
|
type ReviewIssue = Readonly<{
|
|
53
69
|
severity: IssueSeverity;
|
|
54
70
|
message: string;
|
|
@@ -59,7 +75,6 @@ type ReviewIssue = Readonly<{
|
|
|
59
75
|
type ReviewResult = Readonly<{
|
|
60
76
|
source: string;
|
|
61
77
|
issues: ReviewIssue[];
|
|
62
|
-
summary: string;
|
|
63
78
|
reviewedAt: Date;
|
|
64
79
|
}>;
|
|
65
80
|
|
|
@@ -119,8 +134,6 @@ declare const ENV_VARS: {
|
|
|
119
134
|
readonly GOOGLE_API_KEY: "GOOGLE_API_KEY";
|
|
120
135
|
};
|
|
121
136
|
|
|
122
|
-
declare const SEVERITY_LEVELS: Readonly<Record<IssueSeverity, number>>;
|
|
123
|
-
declare const DEFAULT_SEVERITY_LEVEL: IssueSeverity;
|
|
124
137
|
declare function filterIssuesBySeverity(issues: readonly ReviewIssue[], minLevel: IssueSeverity): ReviewIssue[];
|
|
125
138
|
|
|
126
139
|
export { AISdkClient, ContentReviewer, ContentReviewerError, DEFAULT_CONFIG, DEFAULT_INSTRUCTION_EN, DEFAULT_INSTRUCTION_JA, DEFAULT_LLM_CONFIG, DEFAULT_SEVERITY_LEVEL, type Document, ENV_VARS, type IssueSeverity, type LLMClient, type LLMConfig, LLMError, type LLMProvider, type Language, MissingApiKeyError, PROVIDER_DEFAULT_MODELS, type ReviewConfig, type ReviewConfigInput, type ReviewIssue, type ReviewIssueSchema, type ReviewResponseSchema, type ReviewResult, SEVERITY_LEVELS, UnsupportedProviderError, createLLMClient, createReviewConfig, filterIssuesBySeverity, resolveApiKey, reviewIssueSchema, reviewResponseSchema, validateConfig };
|
package/dist/index.js
CHANGED
|
@@ -46,16 +46,30 @@ module.exports = __toCommonJS(index_exports);
|
|
|
46
46
|
|
|
47
47
|
// src/schemas.ts
|
|
48
48
|
var import_zod = require("zod");
|
|
49
|
+
|
|
50
|
+
// src/severity.ts
|
|
51
|
+
var SEVERITIES = {
|
|
52
|
+
error: { priority: 3 },
|
|
53
|
+
warning: { priority: 2 },
|
|
54
|
+
suggestion: { priority: 1 }
|
|
55
|
+
};
|
|
56
|
+
var DEFAULT = "warning";
|
|
57
|
+
var SEVERITY_LEVELS = Object.fromEntries(
|
|
58
|
+
Object.entries(SEVERITIES).map(([k, v]) => [k, v.priority])
|
|
59
|
+
);
|
|
60
|
+
var DEFAULT_SEVERITY_LEVEL = DEFAULT;
|
|
61
|
+
|
|
62
|
+
// src/schemas.ts
|
|
63
|
+
var severityKeys = Object.keys(SEVERITY_LEVELS);
|
|
49
64
|
var reviewIssueSchema = import_zod.z.object({
|
|
50
|
-
severity: import_zod.z.enum(
|
|
65
|
+
severity: import_zod.z.enum(severityKeys),
|
|
51
66
|
message: import_zod.z.string(),
|
|
52
67
|
matchText: import_zod.z.string().optional(),
|
|
53
68
|
lineNumber: import_zod.z.number().optional(),
|
|
54
69
|
suggestion: import_zod.z.string().optional()
|
|
55
70
|
});
|
|
56
71
|
var reviewResponseSchema = import_zod.z.object({
|
|
57
|
-
issues: import_zod.z.array(reviewIssueSchema)
|
|
58
|
-
summary: import_zod.z.string()
|
|
72
|
+
issues: import_zod.z.array(reviewIssueSchema)
|
|
59
73
|
});
|
|
60
74
|
|
|
61
75
|
// src/constants.ts
|
|
@@ -94,20 +108,6 @@ var MissingApiKeyError = class extends ContentReviewerError {
|
|
|
94
108
|
}
|
|
95
109
|
};
|
|
96
110
|
|
|
97
|
-
// src/filter.ts
|
|
98
|
-
var SEVERITY_LEVELS = {
|
|
99
|
-
error: 3,
|
|
100
|
-
warning: 2,
|
|
101
|
-
suggestion: 1
|
|
102
|
-
};
|
|
103
|
-
var DEFAULT_SEVERITY_LEVEL = Object.keys(SEVERITY_LEVELS).reduce(
|
|
104
|
-
(min, key) => SEVERITY_LEVELS[key] < SEVERITY_LEVELS[min] ? key : min
|
|
105
|
-
);
|
|
106
|
-
function filterIssuesBySeverity(issues, minLevel) {
|
|
107
|
-
const minLevelValue = SEVERITY_LEVELS[minLevel];
|
|
108
|
-
return issues.filter((issue) => SEVERITY_LEVELS[issue.severity] >= minLevelValue);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
111
|
// src/config.ts
|
|
112
112
|
var PROVIDER_DEFAULT_MODELS = {
|
|
113
113
|
openai: "gpt-4.1-mini",
|
|
@@ -289,30 +289,11 @@ var DEFAULT_INSTRUCTION_JA = `\u3042\u306A\u305F\u306F\u6280\u8853\u6587\u66F8\u
|
|
|
289
289
|
`;
|
|
290
290
|
|
|
291
291
|
// src/prompts.ts
|
|
292
|
-
function getIncludedLevels(minLevel) {
|
|
293
|
-
const minValue = SEVERITY_LEVELS[minLevel];
|
|
294
|
-
return Object.keys(SEVERITY_LEVELS).filter((level) => SEVERITY_LEVELS[level] >= minValue).sort((a, b) => SEVERITY_LEVELS[b] - SEVERITY_LEVELS[a]);
|
|
295
|
-
}
|
|
296
|
-
function buildSummaryInstruction(minLevel, language) {
|
|
297
|
-
const includedLevels = getIncludedLevels(minLevel);
|
|
298
|
-
const formatLevels = (levels) => levels.map((l) => `"${l}"`).join(", ");
|
|
299
|
-
if (language === "ja") {
|
|
300
|
-
return `
|
|
301
|
-
\u91CD\u8981: \u554F\u984C\u70B9(issues)\u306F\u5168\u3066\u9069\u5207\u306Aseverity\u3067\u5831\u544A\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
302
|
-
\u305F\u3060\u3057\u3001\u7DCF\u8A55(summary)\u306F ${formatLevels(includedLevels)} \u306E\u554F\u984C\u306E\u307F\u306B\u57FA\u3065\u3044\u3066\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
303
|
-
`;
|
|
304
|
-
}
|
|
305
|
-
return `
|
|
306
|
-
Important: Report all issues with their appropriate severity levels.
|
|
307
|
-
However, the summary should only reference issues with severity ${formatLevels(includedLevels)}.
|
|
308
|
-
`;
|
|
309
|
-
}
|
|
310
292
|
var allPrompts = {
|
|
311
293
|
ja: {
|
|
312
|
-
buildSystemPrompt: ({ instruction
|
|
294
|
+
buildSystemPrompt: ({ instruction }) => {
|
|
313
295
|
const instructions = (instruction || DEFAULT_INSTRUCTION_JA).trimEnd() + "\n";
|
|
314
|
-
|
|
315
|
-
return `${instructions}${summaryInstruction}
|
|
296
|
+
return `${instructions}
|
|
316
297
|
\u30EC\u30D3\u30E5\u30FC\u7D50\u679C\u306F\u65E5\u672C\u8A9E\u3067\u3001\u4EE5\u4E0B\u306EJSON\u69CB\u9020\u3067\u8FD4\u3057\u3066\u304F\u3060\u3055\u3044\uFF1A
|
|
317
298
|
- issues: \u898B\u3064\u304B\u3063\u305F\u554F\u984C\u70B9\u306E\u914D\u5217
|
|
318
299
|
- severity: \u6DF1\u523B\u5EA6
|
|
@@ -322,7 +303,6 @@ var allPrompts = {
|
|
|
322
303
|
- message: \u554F\u984C\u306E\u8AAC\u660E
|
|
323
304
|
- matchText: \u554F\u984C\u7B87\u6240\u3092\u542B\u3080\u30C6\u30AD\u30B9\u30C8\u7247\uFF0810-50\u6587\u5B57\u7A0B\u5EA6\u3002\u5B8C\u5168\u4E00\u81F4\u3067\u304D\u308B\u56FA\u6709\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u629C\u304D\u51FA\u3057\u3066\u304F\u3060\u3055\u3044\uFF09
|
|
324
305
|
- suggestion: \u6539\u5584\u63D0\u6848\uFF08\u30AA\u30D7\u30B7\u30E7\u30F3\uFF09
|
|
325
|
-
- summary: \u5168\u4F53\u7684\u306A\u7DCF\u8A55\uFF082-3\u6587\u7A0B\u5EA6\uFF09
|
|
326
306
|
|
|
327
307
|
\u6CE8\u610F\uFF1A
|
|
328
308
|
- \u6709\u52B9\u306AJSON\u306E\u307F\u3092\u8FD4\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u524D\u5F8C\u306B\u6587\u7AE0\u3084Markdown\u306E\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF\u7B49\u3092\u4ED8\u3051\u306A\u3044\u3067\u304F\u3060\u3055\u3044\uFF09\u3002
|
|
@@ -333,10 +313,9 @@ var allPrompts = {
|
|
|
333
313
|
buildUserPrompt: () => "\u4EE5\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u30EC\u30D3\u30E5\u30FC\u3057\u3066\u304F\u3060\u3055\u3044\uFF1A\n\n\n"
|
|
334
314
|
},
|
|
335
315
|
en: {
|
|
336
|
-
buildSystemPrompt: ({ instruction
|
|
316
|
+
buildSystemPrompt: ({ instruction }) => {
|
|
337
317
|
const instructions = (instruction || DEFAULT_INSTRUCTION_EN).trimEnd() + "\n";
|
|
338
|
-
|
|
339
|
-
return `${instructions}${summaryInstruction}
|
|
318
|
+
return `${instructions}
|
|
340
319
|
Provide the review results in English with the following JSON structure:
|
|
341
320
|
- issues: Array of found issues
|
|
342
321
|
- severity: Severity level
|
|
@@ -346,7 +325,6 @@ Provide the review results in English with the following JSON structure:
|
|
|
346
325
|
- message: Issue description
|
|
347
326
|
- matchText: Text snippet containing the issue (10-50 characters, extract unique text that can be exactly matched)
|
|
348
327
|
- suggestion: Improvement suggestion (optional)
|
|
349
|
-
- summary: Overall assessment (2-3 sentences)
|
|
350
328
|
|
|
351
329
|
Note:
|
|
352
330
|
- Return valid JSON only (do not wrap in markdown code fences or add extra text).
|
|
@@ -364,6 +342,12 @@ function getLanguagePrompts(language) {
|
|
|
364
342
|
throw new Error(`Unhandled language: ${language}`);
|
|
365
343
|
}
|
|
366
344
|
|
|
345
|
+
// src/filter.ts
|
|
346
|
+
function filterIssuesBySeverity(issues, minLevel) {
|
|
347
|
+
const minLevelValue = SEVERITY_LEVELS[minLevel];
|
|
348
|
+
return issues.filter((issue) => SEVERITY_LEVELS[issue.severity] >= minLevelValue);
|
|
349
|
+
}
|
|
350
|
+
|
|
367
351
|
// src/reviewer.ts
|
|
368
352
|
var ContentReviewer = class {
|
|
369
353
|
constructor(config) {
|
|
@@ -375,7 +359,6 @@ var ContentReviewer = class {
|
|
|
375
359
|
return {
|
|
376
360
|
source: document.source,
|
|
377
361
|
issues,
|
|
378
|
-
summary: llmResult.summary,
|
|
379
362
|
reviewedAt: /* @__PURE__ */ new Date()
|
|
380
363
|
};
|
|
381
364
|
}
|
|
@@ -389,15 +372,12 @@ var ContentReviewer = class {
|
|
|
389
372
|
...issue,
|
|
390
373
|
lineNumber: issue.matchText ? this.findFirstMatchingLineNumber(document.rawContent, issue.matchText) : void 0
|
|
391
374
|
}));
|
|
392
|
-
return {
|
|
393
|
-
issues,
|
|
394
|
-
summary: reviewData.summary
|
|
395
|
-
};
|
|
375
|
+
return { issues };
|
|
396
376
|
}
|
|
397
377
|
buildSystemPrompt() {
|
|
398
|
-
const { instruction, language
|
|
378
|
+
const { instruction, language } = this.config;
|
|
399
379
|
const { buildSystemPrompt } = getLanguagePrompts(language);
|
|
400
|
-
return buildSystemPrompt({ instruction
|
|
380
|
+
return buildSystemPrompt({ instruction });
|
|
401
381
|
}
|
|
402
382
|
buildUserPrompt(document) {
|
|
403
383
|
const { language } = this.config;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
// src/schemas.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
// src/severity.ts
|
|
5
|
+
var SEVERITIES = {
|
|
6
|
+
error: { priority: 3 },
|
|
7
|
+
warning: { priority: 2 },
|
|
8
|
+
suggestion: { priority: 1 }
|
|
9
|
+
};
|
|
10
|
+
var DEFAULT = "warning";
|
|
11
|
+
var SEVERITY_LEVELS = Object.fromEntries(
|
|
12
|
+
Object.entries(SEVERITIES).map(([k, v]) => [k, v.priority])
|
|
13
|
+
);
|
|
14
|
+
var DEFAULT_SEVERITY_LEVEL = DEFAULT;
|
|
15
|
+
|
|
16
|
+
// src/schemas.ts
|
|
17
|
+
var severityKeys = Object.keys(SEVERITY_LEVELS);
|
|
3
18
|
var reviewIssueSchema = z.object({
|
|
4
|
-
severity: z.enum(
|
|
19
|
+
severity: z.enum(severityKeys),
|
|
5
20
|
message: z.string(),
|
|
6
21
|
matchText: z.string().optional(),
|
|
7
22
|
lineNumber: z.number().optional(),
|
|
8
23
|
suggestion: z.string().optional()
|
|
9
24
|
});
|
|
10
25
|
var reviewResponseSchema = z.object({
|
|
11
|
-
issues: z.array(reviewIssueSchema)
|
|
12
|
-
summary: z.string()
|
|
26
|
+
issues: z.array(reviewIssueSchema)
|
|
13
27
|
});
|
|
14
28
|
|
|
15
29
|
// src/constants.ts
|
|
@@ -48,20 +62,6 @@ var MissingApiKeyError = class extends ContentReviewerError {
|
|
|
48
62
|
}
|
|
49
63
|
};
|
|
50
64
|
|
|
51
|
-
// src/filter.ts
|
|
52
|
-
var SEVERITY_LEVELS = {
|
|
53
|
-
error: 3,
|
|
54
|
-
warning: 2,
|
|
55
|
-
suggestion: 1
|
|
56
|
-
};
|
|
57
|
-
var DEFAULT_SEVERITY_LEVEL = Object.keys(SEVERITY_LEVELS).reduce(
|
|
58
|
-
(min, key) => SEVERITY_LEVELS[key] < SEVERITY_LEVELS[min] ? key : min
|
|
59
|
-
);
|
|
60
|
-
function filterIssuesBySeverity(issues, minLevel) {
|
|
61
|
-
const minLevelValue = SEVERITY_LEVELS[minLevel];
|
|
62
|
-
return issues.filter((issue) => SEVERITY_LEVELS[issue.severity] >= minLevelValue);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
65
|
// src/config.ts
|
|
66
66
|
var PROVIDER_DEFAULT_MODELS = {
|
|
67
67
|
openai: "gpt-4.1-mini",
|
|
@@ -243,30 +243,11 @@ var DEFAULT_INSTRUCTION_JA = `\u3042\u306A\u305F\u306F\u6280\u8853\u6587\u66F8\u
|
|
|
243
243
|
`;
|
|
244
244
|
|
|
245
245
|
// src/prompts.ts
|
|
246
|
-
function getIncludedLevels(minLevel) {
|
|
247
|
-
const minValue = SEVERITY_LEVELS[minLevel];
|
|
248
|
-
return Object.keys(SEVERITY_LEVELS).filter((level) => SEVERITY_LEVELS[level] >= minValue).sort((a, b) => SEVERITY_LEVELS[b] - SEVERITY_LEVELS[a]);
|
|
249
|
-
}
|
|
250
|
-
function buildSummaryInstruction(minLevel, language) {
|
|
251
|
-
const includedLevels = getIncludedLevels(minLevel);
|
|
252
|
-
const formatLevels = (levels) => levels.map((l) => `"${l}"`).join(", ");
|
|
253
|
-
if (language === "ja") {
|
|
254
|
-
return `
|
|
255
|
-
\u91CD\u8981: \u554F\u984C\u70B9(issues)\u306F\u5168\u3066\u9069\u5207\u306Aseverity\u3067\u5831\u544A\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
256
|
-
\u305F\u3060\u3057\u3001\u7DCF\u8A55(summary)\u306F ${formatLevels(includedLevels)} \u306E\u554F\u984C\u306E\u307F\u306B\u57FA\u3065\u3044\u3066\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
257
|
-
`;
|
|
258
|
-
}
|
|
259
|
-
return `
|
|
260
|
-
Important: Report all issues with their appropriate severity levels.
|
|
261
|
-
However, the summary should only reference issues with severity ${formatLevels(includedLevels)}.
|
|
262
|
-
`;
|
|
263
|
-
}
|
|
264
246
|
var allPrompts = {
|
|
265
247
|
ja: {
|
|
266
|
-
buildSystemPrompt: ({ instruction
|
|
248
|
+
buildSystemPrompt: ({ instruction }) => {
|
|
267
249
|
const instructions = (instruction || DEFAULT_INSTRUCTION_JA).trimEnd() + "\n";
|
|
268
|
-
|
|
269
|
-
return `${instructions}${summaryInstruction}
|
|
250
|
+
return `${instructions}
|
|
270
251
|
\u30EC\u30D3\u30E5\u30FC\u7D50\u679C\u306F\u65E5\u672C\u8A9E\u3067\u3001\u4EE5\u4E0B\u306EJSON\u69CB\u9020\u3067\u8FD4\u3057\u3066\u304F\u3060\u3055\u3044\uFF1A
|
|
271
252
|
- issues: \u898B\u3064\u304B\u3063\u305F\u554F\u984C\u70B9\u306E\u914D\u5217
|
|
272
253
|
- severity: \u6DF1\u523B\u5EA6
|
|
@@ -276,7 +257,6 @@ var allPrompts = {
|
|
|
276
257
|
- message: \u554F\u984C\u306E\u8AAC\u660E
|
|
277
258
|
- matchText: \u554F\u984C\u7B87\u6240\u3092\u542B\u3080\u30C6\u30AD\u30B9\u30C8\u7247\uFF0810-50\u6587\u5B57\u7A0B\u5EA6\u3002\u5B8C\u5168\u4E00\u81F4\u3067\u304D\u308B\u56FA\u6709\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u629C\u304D\u51FA\u3057\u3066\u304F\u3060\u3055\u3044\uFF09
|
|
278
259
|
- suggestion: \u6539\u5584\u63D0\u6848\uFF08\u30AA\u30D7\u30B7\u30E7\u30F3\uFF09
|
|
279
|
-
- summary: \u5168\u4F53\u7684\u306A\u7DCF\u8A55\uFF082-3\u6587\u7A0B\u5EA6\uFF09
|
|
280
260
|
|
|
281
261
|
\u6CE8\u610F\uFF1A
|
|
282
262
|
- \u6709\u52B9\u306AJSON\u306E\u307F\u3092\u8FD4\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u524D\u5F8C\u306B\u6587\u7AE0\u3084Markdown\u306E\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF\u7B49\u3092\u4ED8\u3051\u306A\u3044\u3067\u304F\u3060\u3055\u3044\uFF09\u3002
|
|
@@ -287,10 +267,9 @@ var allPrompts = {
|
|
|
287
267
|
buildUserPrompt: () => "\u4EE5\u4E0B\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u30EC\u30D3\u30E5\u30FC\u3057\u3066\u304F\u3060\u3055\u3044\uFF1A\n\n\n"
|
|
288
268
|
},
|
|
289
269
|
en: {
|
|
290
|
-
buildSystemPrompt: ({ instruction
|
|
270
|
+
buildSystemPrompt: ({ instruction }) => {
|
|
291
271
|
const instructions = (instruction || DEFAULT_INSTRUCTION_EN).trimEnd() + "\n";
|
|
292
|
-
|
|
293
|
-
return `${instructions}${summaryInstruction}
|
|
272
|
+
return `${instructions}
|
|
294
273
|
Provide the review results in English with the following JSON structure:
|
|
295
274
|
- issues: Array of found issues
|
|
296
275
|
- severity: Severity level
|
|
@@ -300,7 +279,6 @@ Provide the review results in English with the following JSON structure:
|
|
|
300
279
|
- message: Issue description
|
|
301
280
|
- matchText: Text snippet containing the issue (10-50 characters, extract unique text that can be exactly matched)
|
|
302
281
|
- suggestion: Improvement suggestion (optional)
|
|
303
|
-
- summary: Overall assessment (2-3 sentences)
|
|
304
282
|
|
|
305
283
|
Note:
|
|
306
284
|
- Return valid JSON only (do not wrap in markdown code fences or add extra text).
|
|
@@ -318,6 +296,12 @@ function getLanguagePrompts(language) {
|
|
|
318
296
|
throw new Error(`Unhandled language: ${language}`);
|
|
319
297
|
}
|
|
320
298
|
|
|
299
|
+
// src/filter.ts
|
|
300
|
+
function filterIssuesBySeverity(issues, minLevel) {
|
|
301
|
+
const minLevelValue = SEVERITY_LEVELS[minLevel];
|
|
302
|
+
return issues.filter((issue) => SEVERITY_LEVELS[issue.severity] >= minLevelValue);
|
|
303
|
+
}
|
|
304
|
+
|
|
321
305
|
// src/reviewer.ts
|
|
322
306
|
var ContentReviewer = class {
|
|
323
307
|
constructor(config) {
|
|
@@ -329,7 +313,6 @@ var ContentReviewer = class {
|
|
|
329
313
|
return {
|
|
330
314
|
source: document.source,
|
|
331
315
|
issues,
|
|
332
|
-
summary: llmResult.summary,
|
|
333
316
|
reviewedAt: /* @__PURE__ */ new Date()
|
|
334
317
|
};
|
|
335
318
|
}
|
|
@@ -343,15 +326,12 @@ var ContentReviewer = class {
|
|
|
343
326
|
...issue,
|
|
344
327
|
lineNumber: issue.matchText ? this.findFirstMatchingLineNumber(document.rawContent, issue.matchText) : void 0
|
|
345
328
|
}));
|
|
346
|
-
return {
|
|
347
|
-
issues,
|
|
348
|
-
summary: reviewData.summary
|
|
349
|
-
};
|
|
329
|
+
return { issues };
|
|
350
330
|
}
|
|
351
331
|
buildSystemPrompt() {
|
|
352
|
-
const { instruction, language
|
|
332
|
+
const { instruction, language } = this.config;
|
|
353
333
|
const { buildSystemPrompt } = getLanguagePrompts(language);
|
|
354
|
-
return buildSystemPrompt({ instruction
|
|
334
|
+
return buildSystemPrompt({ instruction });
|
|
355
335
|
}
|
|
356
336
|
buildUserPrompt(document) {
|
|
357
337
|
const { language } = this.config;
|