@tomflow/chatloop-extension 0.3.77 → 0.3.78
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.
|
@@ -561,6 +561,15 @@
|
|
|
561
561
|
// Prefer an explicit current-version declaration. Historical mentions
|
|
562
562
|
// must not choose a version; ambiguous prose is not approval evidence.
|
|
563
563
|
const versionOf=(value,type)=>{
|
|
564
|
+
// Real formal reviews may start with a status recap mentioning an
|
|
565
|
+
// older P2 before the issued heading "P3 v3|正式修订方案".
|
|
566
|
+
// A unique, version-consistent line title outranks historical prose.
|
|
567
|
+
const issued=[...value.matchAll(new RegExp("(?:^|\\n)\\s*(?:#{1,6}\\s*)?("+type+"[1-9][0-9]*)\\s+v([1-9][0-9]*)\\s*[||]", "gi"))]
|
|
568
|
+
.filter(x=>Number(x[1].slice(1))===Number(x[2]))
|
|
569
|
+
.map(x=>x[1].toUpperCase());
|
|
570
|
+
const issuedVersions=[...new Set(issued)];
|
|
571
|
+
if(issuedVersions.length===1)return issuedVersions[0];
|
|
572
|
+
if(issuedVersions.length>1)return null;
|
|
564
573
|
const declared=[...value.matchAll(new RegExp("(?:^|\\n)\\s*(?:#{1,6}\\s*)?(?:方案版本|需求版本|当前版本|版本)?[:: ]*("+type+"[1-9][0-9]*)\\b", "gi"))].map(x=>x[1].toUpperCase());
|
|
565
574
|
const current=[...value.matchAll(new RegExp("(?:本次|当前|本版)[:: ]*("+type+"[1-9][0-9]*)\\b", "gi"))].map(x=>x[1].toUpperCase());
|
|
566
575
|
const versions=[...new Set(current.length?current:declared.length?declared:(value.match(new RegExp("\\b"+type+"[1-9][0-9]*\\b","gi"))||[]).map(x=>x.toUpperCase()))];
|
|
@@ -589,23 +598,35 @@
|
|
|
589
598
|
}
|
|
590
599
|
const rIndex=rows.slice(0,lastUser-1).findLastIndex(x=>x.role==="user"
|
|
591
600
|
&&confirms(textOf(x),"R"));
|
|
592
|
-
|
|
601
|
+
// Long chats virtualize old turns. A still-mounted native R2 user
|
|
602
|
+
// approval at index 0 has its exact issued R2-ISSUE identity, even when
|
|
603
|
+
// the original R2 assistant has scrolled out of the DOM window.
|
|
604
|
+
// This fallback is ONLY for native issue-scoped approvals. The Native
|
|
605
|
+
// Context Start lease independently verifies the effective R approval.
|
|
606
|
+
const rUser=rIndex>=0?rows[rIndex]:null;
|
|
607
|
+
const nativeR=rUser&&textOf(rUser).match(/^[A-Z][A-Z0-9._:-]{7,120}[||]\s*(R[1-9][0-9]*)-ISSUE:[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}[||]\s*我确认\s+(R[1-9][0-9]*)\s+v([1-9][0-9]*)[。.!!]/i);
|
|
608
|
+
const nativeRVersion=nativeR
|
|
609
|
+
&&nativeR[1].toUpperCase()===nativeR[2].toUpperCase()
|
|
610
|
+
&&Number(nativeR[1].slice(1))===Number(nativeR[3])
|
|
611
|
+
?nativeR[1].toUpperCase():null;
|
|
612
|
+
const rAssistant=rIndex>0?rows[rIndex-1]:null;
|
|
613
|
+
if(rIndex<0 || rIndex===0&&!nativeRVersion
|
|
614
|
+
||rIndex>0&&rAssistant?.role!=="assistant"){
|
|
593
615
|
fail("APPROVAL_REQUIREMENTS_MISSING");return false;
|
|
594
616
|
}
|
|
595
|
-
const rAssistant=rows[rIndex-1],rUser=rows[rIndex];
|
|
596
617
|
// Only document-level TEST_ONLY markers deny production adoption:
|
|
597
618
|
// normal P plans can legitimately mention test-only scenarios.
|
|
598
619
|
const testOnlyReview=x=>
|
|
599
620
|
/(?:^|\n)\s*(?:#{1,6}\s*|>\s*)?(?:\*\*)?TEST_ONLY(?:\*\*)?(?:\s*$|\s*[/||:]\s*NOT_APPROVED)/mi
|
|
600
621
|
.test(textOf(x));
|
|
601
|
-
if(testOnlyReview(rAssistant)||testOnlyReview(pAssistant)){
|
|
622
|
+
if(rAssistant&&testOnlyReview(rAssistant)||testOnlyReview(pAssistant)){
|
|
602
623
|
fail("APPROVAL_TEST_ONLY");return false;
|
|
603
624
|
}
|
|
604
|
-
if(!/(?:需求|范围|验收)/.test(textOf(rAssistant))
|
|
605
|
-
|| !/\bR[1-9][0-9]*\b/i.test(textOf(rAssistant))) {
|
|
625
|
+
if(rAssistant&&(!/(?:需求|范围|验收)/.test(textOf(rAssistant))
|
|
626
|
+
|| !/\bR[1-9][0-9]*\b/i.test(textOf(rAssistant)))) {
|
|
606
627
|
fail("APPROVAL_REQUIREMENTS_MISSING");return false;
|
|
607
628
|
}
|
|
608
|
-
const rVersion=versionOf(textOf(rAssistant),"R");
|
|
629
|
+
const rVersion=rAssistant?versionOf(textOf(rAssistant),"R"):nativeRVersion;
|
|
609
630
|
const intervening=rows.slice(rIndex+1,lastUser-1);
|
|
610
631
|
const invalidated=intervening.some(x=>{
|
|
611
632
|
const text=textOf(x);
|
|
@@ -613,8 +634,10 @@
|
|
|
613
634
|
const next=versionOf(text,"R");
|
|
614
635
|
return /需求|范围|验收/.test(text)&&next&&next!==rVersion;
|
|
615
636
|
}
|
|
616
|
-
|
|
617
|
-
|
|
637
|
+
// "修订 P3、保留 R2" is a plan update, NOT an R2 revocation.
|
|
638
|
+
// Only an explicit requirement-targeted change invalidates this R.
|
|
639
|
+
return /(?:撤销|取消|拒绝|不同意|不批准|修改|修订|变更)\s*(?:(?:当前|本次|这份|上述)\s*)?(?:需求|R[1-9][0-9]*)/i.test(text)
|
|
640
|
+
|| /\bR[1-9][0-9]*\b\s*(?:需求)?\s*(?:需要|应当|应该)?\s*(?:撤销|取消|拒绝|修改|修订|变更)/i.test(text);
|
|
618
641
|
});
|
|
619
642
|
if(!pVersion||!rVersion||invalidated){
|
|
620
643
|
fail("APPROVAL_REVISED_OR_REVOKED");return false;
|
package/extension/manifest.json
CHANGED