stratagate-dsh 0.2.74 → 0.2.75
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/CHANGELOG.md +6 -0
- package/dist/client.js +6 -4
- package/dist/plugin.js +60 -2
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -6042,11 +6042,68 @@ function workspaceDisplayName(cwd) {
|
|
|
6042
6042
|
function feedbackText(value, maximum) {
|
|
6043
6043
|
return typeof value === "string" ? value.trim().slice(0, maximum) : "";
|
|
6044
6044
|
}
|
|
6045
|
+
var FEEDBACK_MARKDOWN_HEADINGS = {
|
|
6046
|
+
description: "\u95EE\u9898\u63CF\u8FF0",
|
|
6047
|
+
reproduction: "\u590D\u73B0\u6B65\u9AA4",
|
|
6048
|
+
expected: "\u9884\u671F\u884C\u4E3A",
|
|
6049
|
+
actual: "\u5B9E\u9645\u884C\u4E3A",
|
|
6050
|
+
errorContext: "\u76F8\u5173\u9519\u8BEF\u4FE1\u606F"
|
|
6051
|
+
};
|
|
6052
|
+
function patchFeedbackMarkdown(markdown, input) {
|
|
6053
|
+
let result = markdown.trim();
|
|
6054
|
+
for (const [key, heading] of Object.entries(FEEDBACK_MARKDOWN_HEADINGS)) {
|
|
6055
|
+
if (!Object.prototype.hasOwnProperty.call(input, key)) continue;
|
|
6056
|
+
const raw = input[key];
|
|
6057
|
+
const text3 = Array.isArray(raw) ? raw.map((item, index) => {
|
|
6058
|
+
const value = feedbackText(item, 2e3);
|
|
6059
|
+
return value ? `${index + 1}. ${value}` : "";
|
|
6060
|
+
}).filter(Boolean).join("\n") : feedbackText(raw, key === "description" ? 2e4 : key === "expected" || key === "actual" ? 1e4 : 2e4);
|
|
6061
|
+
const marker = `## ${heading}`;
|
|
6062
|
+
const lines = result.split("\n");
|
|
6063
|
+
let fence = null;
|
|
6064
|
+
let sectionStart = -1;
|
|
6065
|
+
let sectionEnd = lines.length;
|
|
6066
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
6067
|
+
const line = (lines[index] ?? "").replace(/\r$/, "");
|
|
6068
|
+
if (fence) {
|
|
6069
|
+
const closingFence = line.match(/^ {0,3}(`+|~+)[ \t]*$/);
|
|
6070
|
+
if (closingFence?.[1]?.[0] === fence.character && closingFence[1].length >= fence.length) fence = null;
|
|
6071
|
+
continue;
|
|
6072
|
+
}
|
|
6073
|
+
const openingFence = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
|
|
6074
|
+
if (openingFence?.[1] && (openingFence[1][0] === "~" || !openingFence[2]?.includes("`"))) {
|
|
6075
|
+
fence = { character: openingFence[1][0], length: openingFence[1].length };
|
|
6076
|
+
continue;
|
|
6077
|
+
}
|
|
6078
|
+
if (line === marker && sectionStart < 0) {
|
|
6079
|
+
sectionStart = index;
|
|
6080
|
+
continue;
|
|
6081
|
+
}
|
|
6082
|
+
if (sectionStart >= 0 && /^##\s+\S/.test(line)) {
|
|
6083
|
+
sectionEnd = index;
|
|
6084
|
+
break;
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
if (sectionStart < 0) {
|
|
6088
|
+
if (text3) result = `${result ? `${result}
|
|
6089
|
+
|
|
6090
|
+
` : ""}${marker}
|
|
6091
|
+
|
|
6092
|
+
${text3}`;
|
|
6093
|
+
continue;
|
|
6094
|
+
}
|
|
6095
|
+
const replacement = text3 ? [marker, "", ...text3.split("\n")] : [];
|
|
6096
|
+
lines.splice(sectionStart, sectionEnd - sectionStart, ...replacement);
|
|
6097
|
+
result = lines.join("\n").trim();
|
|
6098
|
+
}
|
|
6099
|
+
return result.trim();
|
|
6100
|
+
}
|
|
6045
6101
|
function normalizeFeedbackDraft(input, previous) {
|
|
6046
6102
|
const has = (key) => Object.prototype.hasOwnProperty.call(input, key);
|
|
6047
6103
|
const replacesStructuredBody = has("bodyMarkdown");
|
|
6104
|
+
const updatesStructuredBody = ["description", "reproduction", "expected", "actual", "errorContext"].some((key) => has(key));
|
|
6048
6105
|
const reproduction = replacesStructuredBody ? [] : has("reproduction") ? (Array.isArray(input.reproduction) ? input.reproduction : []).map((value) => feedbackText(value, 2e3)).filter(Boolean).slice(0, 20) : previous?.reproduction ?? [];
|
|
6049
|
-
const bodyMarkdown = has("bodyMarkdown") ? feedbackText(input.bodyMarkdown, 5e4) : previous?.bodyMarkdown;
|
|
6106
|
+
const bodyMarkdown = has("bodyMarkdown") ? feedbackText(input.bodyMarkdown, 5e4) : updatesStructuredBody && previous?.bodyMarkdown ? patchFeedbackMarkdown(previous.bodyMarkdown, input) : previous?.bodyMarkdown;
|
|
6050
6107
|
return {
|
|
6051
6108
|
title: has("title") ? feedbackText(input.title, 240) : previous?.title ?? "",
|
|
6052
6109
|
description: replacesStructuredBody ? "" : has("description") ? feedbackText(input.description, 2e4) : previous?.description ?? "",
|
|
@@ -6704,7 +6761,8 @@ var StrataGateRuntime = class {
|
|
|
6704
6761
|
}
|
|
6705
6762
|
async prepareFeedback(session, input) {
|
|
6706
6763
|
const namespace = this.namespaceFor(session);
|
|
6707
|
-
const
|
|
6764
|
+
const previous = this.loadFeedbackDraft(namespace);
|
|
6765
|
+
const draft = normalizeFeedbackDraft(input, previous);
|
|
6708
6766
|
this.saveFeedbackDraft(namespace, draft);
|
|
6709
6767
|
const feedbackUrl = feedbackDraftUrl(namespace, this.feedbackOrigin());
|
|
6710
6768
|
return {
|