@langlink/dsh-l10n 0.7.0 → 0.8.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 +12 -5
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2461,6 +2461,8 @@ function checkDocument(document2, options = {}) {
|
|
|
2461
2461
|
}
|
|
2462
2462
|
|
|
2463
2463
|
// packages/l10n-core/src/qa/aiqa.ts
|
|
2464
|
+
var AIQA_SEVERITIES = ["Critical", "Major", "Minor", "Neutral"];
|
|
2465
|
+
var AIQA_ERROR_TYPES = ["ACC", "OMI", "ADD", "TER", "NUM", "ENT", "CTX", "FLU", "STY", "LOC", "TEC", "UNC"];
|
|
2464
2466
|
var SYSTEM_PROMPT = `\u4F60\u662F\u8D44\u6DF1\u7FFB\u8BD1\u8D28\u91CF\u6821\u5BF9\u88C1\u51B3\u5458\uFF08AIQA\uFF09\u3002\u4F60\u7684\u552F\u4E00\u4EFB\u52A1\uFF1A\u5224\u65AD\u8FD9\u6761\u8BD1\u6587\u5982\u679C\u73B0\u5728\u76F4\u63A5\u4EA4\u4ED8\u7ED9\u5BA2\u6237\uFF0C\u662F\u5426\u5B58\u5728\u5FC5\u987B\u4FEE\u6539\u7684\u771F\u5B9E\u8D28\u91CF\u95EE\u9898\u3002
|
|
2465
2467
|
|
|
2466
2468
|
\u5224\u5B9A\u6807\u7B7E\uFF08\u4E8C\u9009\u4E00\uFF09\uFF1A
|
|
@@ -2499,8 +2501,8 @@ function buildAiqaUserMessage(input) {
|
|
|
2499
2501
|
...input.styleGuide !== null ? { client_style_guide: input.styleGuide } : {}
|
|
2500
2502
|
});
|
|
2501
2503
|
}
|
|
2502
|
-
var ERROR_CODES =
|
|
2503
|
-
var SEVERITIES =
|
|
2504
|
+
var ERROR_CODES = new Set(AIQA_ERROR_TYPES);
|
|
2505
|
+
var SEVERITIES = new Set(AIQA_SEVERITIES);
|
|
2504
2506
|
function extractJson(reply2) {
|
|
2505
2507
|
const text = reply2.trim().replace(/^```(?:json)?\s*/u, "").replace(/\s*```$/u, "");
|
|
2506
2508
|
const start = text.indexOf("{");
|
|
@@ -4117,7 +4119,7 @@ function renderReviewPage(report, nonce = "", aiqaEnabled = false) {
|
|
|
4117
4119
|
// packages/l10n-core/src/qa/agent-review.ts
|
|
4118
4120
|
var MAX_DRAFTS = 4;
|
|
4119
4121
|
var MAX_RUNS = 4;
|
|
4120
|
-
var
|
|
4122
|
+
var REVIEW_BATCH_SIZE = 8;
|
|
4121
4123
|
var AGENT_REVIEW_TOOLS = {
|
|
4122
4124
|
prepare: "FIRST call for conversational bilingual QA. Inspect user-provided local XLIFF, SDLXLIFF, MQXLIFF or MQXLZ paths without running QA. Show the resulting configuration as an editable table in chat (files, language pairs, enabled and disabled checks, AIQA, project requirements, and report files). Wait for the user's reply. Apply requested changes using the latest draftId, show the new configuration, and wait for explicit approval of that version.",
|
|
4123
4125
|
start: "Run QA with the latest draftId from l10n_review_prepare, ONLY after the user explicitly confirms the exact configuration in a subsequent reply. Pass confirmed: true after that reply. Runs the chosen fixed checks. If AIQA is enabled, apply the V1.1 criteria and submit each batch through l10n_review_batch. Once batch is null, call l10n_review_report.",
|
|
@@ -4147,7 +4149,7 @@ function nextBatch(run) {
|
|
|
4147
4149
|
if (run.pending) return run.pending;
|
|
4148
4150
|
const segments = [];
|
|
4149
4151
|
let length = 0;
|
|
4150
|
-
while (run.cursor < run.waiting.length && segments.length <
|
|
4152
|
+
while (run.cursor < run.waiting.length && segments.length < REVIEW_BATCH_SIZE) {
|
|
4151
4153
|
const { segmentKey, input } = run.waiting[run.cursor];
|
|
4152
4154
|
const prompt = buildAiqaUserMessage(input);
|
|
4153
4155
|
if (prompt.length > REVIEW_AIQA_INPUT_CHARS) {
|
|
@@ -4169,7 +4171,12 @@ function applyBatch(run, batchId, verdictsJson) {
|
|
|
4169
4171
|
if (batchId === run.lastBatchId) return;
|
|
4170
4172
|
if (run.pending?.id !== batchId) throw new Error("\u6279\u6B21\u5DF2\u53D8\u66F4\uFF0C\u8BF7\u8BFB\u53D6\u5F53\u524D\u6279\u6B21\u3002");
|
|
4171
4173
|
if (verdictsJson.length > 48e3) throw new Error("\u5224\u5B9A\u5185\u5BB9\u8FC7\u957F\u3002");
|
|
4172
|
-
|
|
4174
|
+
let verdicts;
|
|
4175
|
+
try {
|
|
4176
|
+
verdicts = JSON.parse(verdictsJson);
|
|
4177
|
+
} catch {
|
|
4178
|
+
throw new Error("\u5224\u5B9A\u683C\u5F0F\u65E0\u6548\u3002\u8BF7\u63D0\u4EA4\u5305\u542B segmentKey \u548C verdict \u7684 JSON \u6570\u7EC4\uFF0C\u5E76\u91CD\u8BD5\u540C\u4E00\u6279\u6B21\u3002");
|
|
4179
|
+
}
|
|
4173
4180
|
if (!Array.isArray(verdicts) || verdicts.length !== run.pending.segments.length) {
|
|
4174
4181
|
throw new Error("\u8BF7\u4E3A\u5F53\u524D\u6279\u6B21\u6BCF\u4E2A\u6BB5\u843D\u63D0\u4EA4\u4E00\u6761\u5224\u5B9A\u3002");
|
|
4175
4182
|
}
|