@fieldwangai/agentflow 0.1.129 → 0.1.133
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/bin/lib/ui-server.mjs
CHANGED
|
@@ -8491,12 +8491,27 @@ function prdWorkflowReviewRenderPlannedCode(filePath, codeLines, startLine = 0,
|
|
|
8491
8491
|
}
|
|
8492
8492
|
|
|
8493
8493
|
const PRD_WORKFLOW_VERIFICATION_FIELDS = {
|
|
8494
|
+
"Case ID": "caseId",
|
|
8495
|
+
"场景": "scenario",
|
|
8496
|
+
"数据准备": "setup",
|
|
8497
|
+
"执行步骤": "steps",
|
|
8498
|
+
"验证方式": "method",
|
|
8499
|
+
"证据定位": "evidenceLocator",
|
|
8500
|
+
"预期结果": "expectedResults",
|
|
8501
|
+
};
|
|
8502
|
+
|
|
8503
|
+
const PRD_WORKFLOW_LEGACY_VERIFICATION_FIELDS = {
|
|
8494
8504
|
"入口": "entry",
|
|
8495
8505
|
"前置条件": "precondition",
|
|
8496
8506
|
"观察": "observation",
|
|
8497
8507
|
"通过标准": "passCriteria",
|
|
8498
8508
|
};
|
|
8499
8509
|
|
|
8510
|
+
const PRD_WORKFLOW_ALL_VERIFICATION_FIELDS = {
|
|
8511
|
+
...PRD_WORKFLOW_VERIFICATION_FIELDS,
|
|
8512
|
+
...PRD_WORKFLOW_LEGACY_VERIFICATION_FIELDS,
|
|
8513
|
+
};
|
|
8514
|
+
|
|
8500
8515
|
function prdWorkflowReviewVerificationBoundary(line) {
|
|
8501
8516
|
const trimmed = String(line || "").trim();
|
|
8502
8517
|
return /^#verification\s*$/i.test(trimmed)
|
|
@@ -8513,15 +8528,54 @@ function prdWorkflowReviewVerificationContent(lines = []) {
|
|
|
8513
8528
|
return [source[0], ...prdWorkflowReviewDedentPlannedCode(source.slice(1))];
|
|
8514
8529
|
}
|
|
8515
8530
|
|
|
8531
|
+
function prdWorkflowReviewVerificationScalar(lines = []) {
|
|
8532
|
+
return prdWorkflowReviewVerificationContent(lines)
|
|
8533
|
+
.map((line) => String(line || "").trim())
|
|
8534
|
+
.filter(Boolean)
|
|
8535
|
+
.join(" ");
|
|
8536
|
+
}
|
|
8537
|
+
|
|
8538
|
+
function prdWorkflowReviewVerificationList(lines = []) {
|
|
8539
|
+
const items = [];
|
|
8540
|
+
for (const line of prdWorkflowReviewVerificationContent(lines)) {
|
|
8541
|
+
const value = String(line || "");
|
|
8542
|
+
const item = value.match(/^\s*(?:[-*]|\d+[.)])\s+(?:\[(?: |x|X)\]\s+)?(.+)$/);
|
|
8543
|
+
if (item) {
|
|
8544
|
+
items.push(item[1].trim());
|
|
8545
|
+
continue;
|
|
8546
|
+
}
|
|
8547
|
+
const continuation = value.trim();
|
|
8548
|
+
if (!continuation) continue;
|
|
8549
|
+
if (items.length) items[items.length - 1] += ` ${continuation}`;
|
|
8550
|
+
else items.push(continuation);
|
|
8551
|
+
}
|
|
8552
|
+
return items;
|
|
8553
|
+
}
|
|
8554
|
+
|
|
8555
|
+
function prdWorkflowReviewVerificationField(line, fieldIndent) {
|
|
8556
|
+
const field = String(line || "").match(
|
|
8557
|
+
/^(\s*)-\s*(Case ID|场景|数据准备|执行步骤|验证方式|证据定位|预期结果|入口|前置条件|观察|通过标准)\s*[::]\s*(.*)$/i,
|
|
8558
|
+
);
|
|
8559
|
+
if (!field) return null;
|
|
8560
|
+
const indent = field[1].length;
|
|
8561
|
+
if (fieldIndent != null && indent !== fieldIndent) return null;
|
|
8562
|
+
const canonicalLabel = Object.keys(PRD_WORKFLOW_ALL_VERIFICATION_FIELDS)
|
|
8563
|
+
.find((label) => label.toLowerCase() === field[2].toLowerCase());
|
|
8564
|
+
if (!canonicalLabel) return null;
|
|
8565
|
+
return {
|
|
8566
|
+
indent,
|
|
8567
|
+
key: PRD_WORKFLOW_ALL_VERIFICATION_FIELDS[canonicalLabel],
|
|
8568
|
+
value: field[3],
|
|
8569
|
+
};
|
|
8570
|
+
}
|
|
8571
|
+
|
|
8516
8572
|
function prdWorkflowReviewParseVerificationBlock(lines, startIndex) {
|
|
8517
8573
|
if (!/^\s*#verification\s*$/i.test(String(lines[startIndex] || ""))) return null;
|
|
8518
|
-
const fields =
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
observation: [],
|
|
8522
|
-
passCriteria: [],
|
|
8523
|
-
};
|
|
8574
|
+
const fields = Object.fromEntries(
|
|
8575
|
+
Object.values(PRD_WORKFLOW_ALL_VERIFICATION_FIELDS).map((key) => [key, []]),
|
|
8576
|
+
);
|
|
8524
8577
|
let activeField = "";
|
|
8578
|
+
let fieldIndent = null;
|
|
8525
8579
|
let boundaryIndex = lines.length;
|
|
8526
8580
|
for (let i = startIndex + 1; i < lines.length; i += 1) {
|
|
8527
8581
|
const line = String(lines[i] || "");
|
|
@@ -8529,6 +8583,13 @@ function prdWorkflowReviewParseVerificationBlock(lines, startIndex) {
|
|
|
8529
8583
|
return {
|
|
8530
8584
|
verification: {
|
|
8531
8585
|
type: "verification",
|
|
8586
|
+
caseId: prdWorkflowReviewVerificationScalar(fields.caseId),
|
|
8587
|
+
scenario: prdWorkflowReviewVerificationScalar(fields.scenario),
|
|
8588
|
+
setup: prdWorkflowReviewVerificationScalar(fields.setup),
|
|
8589
|
+
steps: prdWorkflowReviewVerificationList(fields.steps),
|
|
8590
|
+
method: prdWorkflowReviewVerificationScalar(fields.method),
|
|
8591
|
+
evidenceLocator: prdWorkflowReviewVerificationList(fields.evidenceLocator),
|
|
8592
|
+
expectedResults: prdWorkflowReviewVerificationList(fields.expectedResults),
|
|
8532
8593
|
entry: prdWorkflowReviewVerificationContent(fields.entry),
|
|
8533
8594
|
precondition: prdWorkflowReviewVerificationContent(fields.precondition),
|
|
8534
8595
|
observation: prdWorkflowReviewVerificationContent(fields.observation),
|
|
@@ -8542,10 +8603,11 @@ function prdWorkflowReviewParseVerificationBlock(lines, startIndex) {
|
|
|
8542
8603
|
boundaryIndex = i;
|
|
8543
8604
|
break;
|
|
8544
8605
|
}
|
|
8545
|
-
const field = line
|
|
8606
|
+
const field = prdWorkflowReviewVerificationField(line, fieldIndent);
|
|
8546
8607
|
if (field) {
|
|
8547
|
-
|
|
8548
|
-
|
|
8608
|
+
if (fieldIndent == null) fieldIndent = field.indent;
|
|
8609
|
+
activeField = field.key;
|
|
8610
|
+
if (field.value) fields[activeField].push(field.value);
|
|
8549
8611
|
continue;
|
|
8550
8612
|
}
|
|
8551
8613
|
if (activeField) fields[activeField].push(line);
|
|
@@ -8558,7 +8620,7 @@ function prdWorkflowReviewParseVerificationBlock(lines, startIndex) {
|
|
|
8558
8620
|
};
|
|
8559
8621
|
}
|
|
8560
8622
|
|
|
8561
|
-
function
|
|
8623
|
+
function prdWorkflowReviewRenderLegacyVerificationBlock(verification) {
|
|
8562
8624
|
const fields = [
|
|
8563
8625
|
["入口", verification.entry],
|
|
8564
8626
|
["前置条件", verification.precondition],
|
|
@@ -8584,6 +8646,67 @@ function prdWorkflowReviewRenderVerificationBlock(verification) {
|
|
|
8584
8646
|
</section>`;
|
|
8585
8647
|
}
|
|
8586
8648
|
|
|
8649
|
+
function prdWorkflowReviewRenderVerificationCaseValue(value, kind = "scalar") {
|
|
8650
|
+
const values = Array.isArray(value) ? value.filter((item) => String(item || "").trim()) : [];
|
|
8651
|
+
if (kind === "scalar") {
|
|
8652
|
+
const text = String(value || "").trim();
|
|
8653
|
+
return text
|
|
8654
|
+
? `<p>${prdWorkflowReviewInlineMarkdown(text)}</p>`
|
|
8655
|
+
: '<span class="verification-block__missing">未填写</span>';
|
|
8656
|
+
}
|
|
8657
|
+
if (!values.length) return '<span class="verification-block__missing">未填写</span>';
|
|
8658
|
+
const tag = kind === "steps" ? "ol" : "ul";
|
|
8659
|
+
return `<${tag} class="verification-block__list">${values
|
|
8660
|
+
.map((item) => `<li>${prdWorkflowReviewInlineMarkdown(item)}</li>`)
|
|
8661
|
+
.join("")}</${tag}>`;
|
|
8662
|
+
}
|
|
8663
|
+
|
|
8664
|
+
function prdWorkflowReviewRenderVerificationCase(verification) {
|
|
8665
|
+
const caseId = String(verification.caseId || "").trim();
|
|
8666
|
+
const scenario = String(verification.scenario || "").trim();
|
|
8667
|
+
const fields = [
|
|
8668
|
+
["数据准备", verification.setup, "scalar"],
|
|
8669
|
+
["执行步骤", verification.steps, "steps"],
|
|
8670
|
+
["验证方式", verification.method, "scalar"],
|
|
8671
|
+
["证据定位", verification.evidenceLocator, "list"],
|
|
8672
|
+
["预期结果", verification.expectedResults, "list"],
|
|
8673
|
+
];
|
|
8674
|
+
const rows = fields.map(([label, value, kind]) => {
|
|
8675
|
+
const missing = kind === "scalar"
|
|
8676
|
+
? !String(value || "").trim()
|
|
8677
|
+
: !Array.isArray(value) || !value.some((item) => String(item || "").trim());
|
|
8678
|
+
return `<div class="verification-block__field${missing ? " is-missing" : ""}">
|
|
8679
|
+
<dt>${htmlEscapeAttribute(label)}</dt>
|
|
8680
|
+
<dd>${prdWorkflowReviewRenderVerificationCaseValue(value, kind)}</dd>
|
|
8681
|
+
</div>`;
|
|
8682
|
+
}).join("");
|
|
8683
|
+
return `<section class="verification-block verification-case" data-solution-block="verification">
|
|
8684
|
+
<div class="verification-block__header">
|
|
8685
|
+
<span class="verification-block__badge">验证用例</span>
|
|
8686
|
+
<div class="verification-block__title">
|
|
8687
|
+
${caseId ? `<code>${htmlEscapeAttribute(caseId)}</code>` : '<span class="verification-block__missing">未填写 Case ID</span>'}
|
|
8688
|
+
<strong>${scenario ? prdWorkflowReviewInlineMarkdown(scenario) : "未命名场景"}</strong>
|
|
8689
|
+
</div>
|
|
8690
|
+
</div>
|
|
8691
|
+
<dl class="verification-block__fields">${rows}</dl>
|
|
8692
|
+
</section>`;
|
|
8693
|
+
}
|
|
8694
|
+
|
|
8695
|
+
function prdWorkflowReviewRenderVerificationBlock(verification) {
|
|
8696
|
+
const hasVerificationCase = [
|
|
8697
|
+
verification.caseId,
|
|
8698
|
+
verification.scenario,
|
|
8699
|
+
verification.setup,
|
|
8700
|
+
verification.method,
|
|
8701
|
+
...(Array.isArray(verification.steps) ? verification.steps : []),
|
|
8702
|
+
...(Array.isArray(verification.evidenceLocator) ? verification.evidenceLocator : []),
|
|
8703
|
+
...(Array.isArray(verification.expectedResults) ? verification.expectedResults : []),
|
|
8704
|
+
].some((value) => String(value || "").trim());
|
|
8705
|
+
return hasVerificationCase
|
|
8706
|
+
? prdWorkflowReviewRenderVerificationCase(verification)
|
|
8707
|
+
: prdWorkflowReviewRenderLegacyVerificationBlock(verification);
|
|
8708
|
+
}
|
|
8709
|
+
|
|
8587
8710
|
function prdWorkflowReviewRenderIncompleteVerification(rawLines = []) {
|
|
8588
8711
|
const body = prdWorkflowReviewMarkdownLinesToHtml(rawLines);
|
|
8589
8712
|
return `<section class="verification-block is-incomplete" data-solution-block="verification">
|
|
@@ -9346,6 +9469,9 @@ export function prdWorkflowReviewHtml(title, markdown, meta = {}) {
|
|
|
9346
9469
|
.verification-block { max-width: 100%; margin: 1rem 0 1.2rem; overflow: hidden; border: 1px solid var(--change-border); border-radius: 12px; background: var(--panel-strong); }
|
|
9347
9470
|
.verification-block__header { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--change-border); background: var(--change-header); padding: 11px 14px; color: var(--heading); font-size: 13px; font-weight: 900; }
|
|
9348
9471
|
.verification-block__badge { flex: 0 0 auto; border: 1px solid currentColor; border-radius: 999px; color: var(--change-move); padding: 4px 9px; font-size: 12px; line-height: 1.3; }
|
|
9472
|
+
.verification-block__title { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
|
9473
|
+
.verification-block__title code { color: var(--link); font-weight: 900; }
|
|
9474
|
+
.verification-block__title strong { min-width: 0; color: var(--heading); overflow-wrap: anywhere; }
|
|
9349
9475
|
.verification-block__fields { margin: 0; }
|
|
9350
9476
|
.verification-block__field { display: grid; grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr); border-top: 1px solid var(--border-soft); }
|
|
9351
9477
|
.verification-block__field:first-child { border-top: 0; }
|
|
@@ -9353,6 +9479,7 @@ export function prdWorkflowReviewHtml(title, markdown, meta = {}) {
|
|
|
9353
9479
|
.verification-block__field dd { min-width: 0; margin: 0; padding: 10px 14px 12px; color: var(--body); }
|
|
9354
9480
|
.verification-block__field dd > *:first-child { margin-top: 0; }
|
|
9355
9481
|
.verification-block__field dd > *:last-child { margin-bottom: 0; }
|
|
9482
|
+
.verification-block__list { margin: 0; }
|
|
9356
9483
|
.verification-block__field.is-missing { opacity: .72; }
|
|
9357
9484
|
.verification-block__missing { color: var(--muted); font-size: 13px; font-style: italic; }
|
|
9358
9485
|
.verification-block.is-incomplete { border-color: var(--pending-border); }
|