dislop 0.7.1 → 0.8.1
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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +4 -3
- package/.cursor-plugin/plugin.json +3 -2
- package/PRODUCT.md +18 -4
- package/README.md +72 -38
- package/README.zh-CN.md +70 -40
- package/bin/dislop.mjs +2883 -309
- package/gemini-extension.json +2 -2
- package/package.json +19 -3
- package/packs/business-brief/pack.json +336 -6
- package/packs/core/pack.json +14 -7
- package/packs/deck-and-ui/pack.json +255 -6
- package/packs/literary-essay/pack.json +20 -0
- package/patterns/ai-tic-rubric.json +252 -0
- package/patterns/banks/composite-fusion.json +13 -1
- package/patterns/banks/lexical-signals.json +20 -2
- package/patterns/banks/syntactic-frames.json +10 -3
- package/patterns/banks/visual-deck.json +7 -0
- package/patterns/dimensions/discourse.json +26 -0
- package/patterns/dimensions/lexical.json +26 -0
- package/patterns/dimensions/rhythm.json +52 -0
- package/patterns/dimensions/visual-and-deck.json +209 -1
- package/plugin.json +4 -3
- package/server.json +2 -2
- package/skills/dislop/SKILL.md +35 -41
- package/skills/dislop/agents/openai.yaml +1 -1
- package/skills/dislop/references/essay.md +24 -0
- package/skills/dislop/references/essay.zh-CN.md +24 -0
- package/skills/dislop/references/office.md +23 -0
- package/skills/dislop/references/office.zh-CN.md +23 -0
- package/skills/dislop/references/web-ui.md +24 -0
- package/skills/dislop/references/web-ui.zh-CN.md +24 -0
- package/skills/dislop/references/work-docs.md +25 -0
- package/skills/dislop/references/work-docs.zh-CN.md +24 -0
- package/src/binary-node.mjs +1716 -1
- package/src/core.mjs +3215 -247
- package/src/local-model.mjs +31 -11
- package/src/pattern-engine.mjs +174 -24
- package/src/pocket-model.mjs +27 -5
- package/src/review-client.mjs +1064 -0
- package/skills/dislop/references/business-and-rfc.md +0 -26
- package/skills/dislop/references/editorial-and-essay.md +0 -20
- package/skills/dislop/references/regulated-and-precision.md +0 -27
- package/skills/dislop/references/web-ui-and-deck.md +0 -26
package/src/local-model.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import path from "node:path";
|
|
|
16
16
|
import { spawnSync } from "node:child_process";
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
|
|
19
|
-
import { auditText, extractProtectedFacts, verifyRevision } from "./core.mjs";
|
|
19
|
+
import { auditText, extractProtectedFacts, getScenarioStrategy, verifyRevision } from "./core.mjs";
|
|
20
20
|
import { loadPocketModelBundle, scorePocketSpan } from "./pocket-model.mjs";
|
|
21
21
|
|
|
22
22
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -730,8 +730,16 @@ export function verifyFactsWithUnits(beforeText, afterText, { modality = "markdo
|
|
|
730
730
|
};
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
function buildParagraphDeslopPrompt(
|
|
733
|
+
function buildParagraphDeslopPrompt(
|
|
734
|
+
paragraph,
|
|
735
|
+
findings,
|
|
736
|
+
pocketScore,
|
|
737
|
+
protectedFacts,
|
|
738
|
+
repairFeedback = null,
|
|
739
|
+
{ packId = "business-brief", register = "unspecified" } = {}
|
|
740
|
+
) {
|
|
734
741
|
const isZh = /[\u4e00-\u9fff]/.test(paragraph);
|
|
742
|
+
const strategy = getScenarioStrategy({ packId, register });
|
|
735
743
|
const lockedTokens = protectedFacts.map((f) => f.raw);
|
|
736
744
|
const ruleNotes = findings.map((f) => `- ${f.ruleId}: ${(isZh ? f.message?.zh : f.message?.en) || f.ruleId}`);
|
|
737
745
|
const mlNotes = (pocketScore.topDrivers || []).map(
|
|
@@ -740,9 +748,14 @@ function buildParagraphDeslopPrompt(paragraph, findings, pocketScore, protectedF
|
|
|
740
748
|
const diag = [...ruleNotes, ...mlNotes].slice(0, 5).join("\n");
|
|
741
749
|
|
|
742
750
|
if (isZh) {
|
|
743
|
-
const sys =
|
|
744
|
-
|
|
745
|
-
|
|
751
|
+
const sys = [
|
|
752
|
+
`你是贴合当前写作场景(${strategy.label.zh})的审改编辑。`,
|
|
753
|
+
`重点清除:${strategy.cut.zh}`,
|
|
754
|
+
`必须保留:${strategy.protect.zh}`,
|
|
755
|
+
`严禁改偏:${strategy.avoid.zh}`,
|
|
756
|
+
"只输出改写后的纯正文段落,不加解释、不加引号、不加开头寒暄,严禁编造原句没有的数字,严禁篡改单位,严禁写成『不是……而是……』或三段分号排比。",
|
|
757
|
+
].join("\n");
|
|
758
|
+
let usr = `请按「${strategy.label.zh}」场景要求改净下面段落,保留全部事实含义:\n\n【原段】\n${paragraph}\n`;
|
|
746
759
|
if (diag) usr += `\n【检测到的问题】\n${diag}\n`;
|
|
747
760
|
if (lockedTokens.length > 0) {
|
|
748
761
|
usr += `\n【必须原样保留的数字、单位、限定词、代码与链接】\n${lockedTokens.join(" 、 ")}\n`;
|
|
@@ -753,9 +766,14 @@ function buildParagraphDeslopPrompt(paragraph, findings, pocketScore, protectedF
|
|
|
753
766
|
return { systemPrompt: sys, userPrompt: usr };
|
|
754
767
|
}
|
|
755
768
|
|
|
756
|
-
const sys =
|
|
757
|
-
|
|
758
|
-
|
|
769
|
+
const sys = [
|
|
770
|
+
`You are an editor tuned for ${strategy.label.en} (${strategy.id}).`,
|
|
771
|
+
`Cut: ${strategy.cut.en}`,
|
|
772
|
+
`Protect: ${strategy.protect.en}`,
|
|
773
|
+
`Avoid: ${strategy.avoid.en}`,
|
|
774
|
+
"Output ONLY the rewritten paragraph text—no preamble, no quotes, no invented numbers, no altered units, no semicolon tricolons, and no 'Not X, but Y' slogans.",
|
|
775
|
+
].join("\n");
|
|
776
|
+
let usr = `Clean AI slop from this ${strategy.label.en} paragraph while preserving every fact:\n\n[Original]\n${paragraph}\n`;
|
|
759
777
|
if (diag) usr += `\n[Detected issues]\n${diag}\n`;
|
|
760
778
|
if (lockedTokens.length > 0) {
|
|
761
779
|
usr += `\n[Must preserve verbatim (numbers, units, qualifiers, inline code, URLs)]\n${lockedTokens.join(" | ")}\n`;
|
|
@@ -813,6 +831,7 @@ export async function runLocalDeslop({
|
|
|
813
831
|
text,
|
|
814
832
|
pack,
|
|
815
833
|
modality = "markdown",
|
|
834
|
+
register = null,
|
|
816
835
|
endpoint = null,
|
|
817
836
|
runnerKind = null,
|
|
818
837
|
model = null,
|
|
@@ -870,7 +889,7 @@ export async function runLocalDeslop({
|
|
|
870
889
|
continue;
|
|
871
890
|
}
|
|
872
891
|
|
|
873
|
-
const beforeAudit = auditText(seg, { filename: "draft.md", modality, pack });
|
|
892
|
+
const beforeAudit = auditText(seg, { filename: "draft.md", modality, pack, register });
|
|
874
893
|
const beforePocket = scorePocketSpan(seg);
|
|
875
894
|
const needsRewrite = beforeAudit.findings.length > 0 || (beforePocket.eligible && beforePocket.slopProbability >= 0.65);
|
|
876
895
|
|
|
@@ -890,7 +909,8 @@ export async function runLocalDeslop({
|
|
|
890
909
|
beforeAudit.findings,
|
|
891
910
|
beforePocket,
|
|
892
911
|
protectedFacts,
|
|
893
|
-
repairFeedback
|
|
912
|
+
repairFeedback,
|
|
913
|
+
{ packId: pack?.id || "business-brief", register: register || "unspecified" }
|
|
894
914
|
);
|
|
895
915
|
const candidate = await callLocalChatCompletion({
|
|
896
916
|
endpoint: resolvedEndpoint,
|
|
@@ -907,7 +927,7 @@ export async function runLocalDeslop({
|
|
|
907
927
|
}
|
|
908
928
|
|
|
909
929
|
const factCheck = verifyFactsWithUnits(seg, candidate, { modality });
|
|
910
|
-
const afterAudit = auditText(candidate, { filename: "draft.md", modality, pack });
|
|
930
|
+
const afterAudit = auditText(candidate, { filename: "draft.md", modality, pack, register });
|
|
911
931
|
const hardErrorsAfter = afterAudit.findings.filter((f) => f.severity === "error" || f.severity === "warning");
|
|
912
932
|
const hardErrorsBefore = beforeAudit.findings.filter((f) => f.severity === "error" || f.severity === "warning");
|
|
913
933
|
|
package/src/pattern-engine.mjs
CHANGED
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
import {
|
|
7
7
|
buildLineStarts,
|
|
8
8
|
buildZones,
|
|
9
|
+
deriveFixStrategy,
|
|
9
10
|
detectModality,
|
|
10
11
|
fnv1aHex,
|
|
12
|
+
isAllowedMatch,
|
|
13
|
+
isSentenceBreakAt,
|
|
11
14
|
offsetToLineCol,
|
|
15
|
+
parseSuppressions,
|
|
16
|
+
sliceCodepoints,
|
|
17
|
+
stripParentheticals,
|
|
12
18
|
} from "./core.mjs";
|
|
13
19
|
|
|
14
20
|
export const PATTERN_ENGINE_VERSION = "1.0.0";
|
|
@@ -90,9 +96,10 @@ function makePatternFinding({
|
|
|
90
96
|
match,
|
|
91
97
|
metric = "",
|
|
92
98
|
message,
|
|
99
|
+
deletionTest = null,
|
|
93
100
|
}) {
|
|
94
101
|
const loc = location || `${line}:${col}`;
|
|
95
|
-
const cleanMatch = String(match || "").replace(/\s+/g, " ").trim()
|
|
102
|
+
const cleanMatch = sliceCodepoints(String(match || "").replace(/\s+/g, " ").trim(), 140);
|
|
96
103
|
const fp = `${ruleId}:${fnv1aHex(`${ruleId}|${cleanMatch.toLowerCase()}|${loc}`)}`;
|
|
97
104
|
return {
|
|
98
105
|
fingerprint: fp,
|
|
@@ -101,6 +108,7 @@ function makePatternFinding({
|
|
|
101
108
|
dimension,
|
|
102
109
|
detectionAngle,
|
|
103
110
|
severity,
|
|
111
|
+
fixStrategy: deriveFixStrategy({ id: ruleId, severity }),
|
|
104
112
|
file: filename,
|
|
105
113
|
modality,
|
|
106
114
|
location: loc,
|
|
@@ -109,22 +117,40 @@ function makePatternFinding({
|
|
|
109
117
|
match: cleanMatch,
|
|
110
118
|
metric,
|
|
111
119
|
message,
|
|
120
|
+
...(deletionTest ? { deletionTest } : {}),
|
|
112
121
|
};
|
|
113
122
|
}
|
|
114
123
|
|
|
124
|
+
function iterSentenceSpansInPara(rawPara) {
|
|
125
|
+
const spans = [];
|
|
126
|
+
let start = 0;
|
|
127
|
+
for (let i = 0; i < rawPara.length; i += 1) {
|
|
128
|
+
if (rawPara[i] === "\n") {
|
|
129
|
+
start = i + 1;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (isSentenceBreakAt(rawPara, i)) {
|
|
133
|
+
const text = rawPara.slice(start, i + 1);
|
|
134
|
+
if (text.trim().length > 0) {
|
|
135
|
+
spans.push({ text, index: start });
|
|
136
|
+
}
|
|
137
|
+
start = i + 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return spans;
|
|
141
|
+
}
|
|
142
|
+
|
|
115
143
|
// ---------- Angle: Rhythm & Cadence Statistics ----------
|
|
116
144
|
|
|
117
145
|
function probeCommaChain(proseText, rawText, cfg) {
|
|
118
146
|
const hits = [];
|
|
119
147
|
for (const para of iterProseParagraphs(proseText)) {
|
|
120
148
|
if (para.skippable) continue;
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
while ((sm = sentRe.exec(para.raw)) !== null) {
|
|
124
|
-
const sent = sm[0];
|
|
149
|
+
for (const sm of iterSentenceSpansInPara(para.raw)) {
|
|
150
|
+
const sent = sm.text;
|
|
125
151
|
const normalized = stripFormattedNumbersAndCode(sent);
|
|
126
152
|
const lang = detectPrimaryLang(normalized);
|
|
127
|
-
const noParens = normalized
|
|
153
|
+
const noParens = stripParentheticals(normalized);
|
|
128
154
|
const commas = noParens.match(/[,,]/g) || [];
|
|
129
155
|
if (commas.length < (cfg.minCommas || 5)) continue;
|
|
130
156
|
|
|
@@ -159,11 +185,9 @@ function probeSentenceLengthMonotony(proseText, cfg) {
|
|
|
159
185
|
for (const para of iterProseParagraphs(proseText)) {
|
|
160
186
|
if (para.skippable) continue;
|
|
161
187
|
const lang = detectPrimaryLang(para.trimmed);
|
|
162
|
-
const sentRe = /[^.!?。!?\n]+[.!?。!?]/gu;
|
|
163
188
|
const lengths = [];
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const u = measureUnits(sm[0], lang);
|
|
189
|
+
for (const sm of iterSentenceSpansInPara(para.raw)) {
|
|
190
|
+
const u = measureUnits(sm.text, lang);
|
|
167
191
|
if (u >= (cfg.minSentenceUnits || 4)) lengths.push(u);
|
|
168
192
|
}
|
|
169
193
|
if (lengths.length < (cfg.minSentences || 5)) continue;
|
|
@@ -208,13 +232,11 @@ function probeOpenerAnaphora(proseText, cfg) {
|
|
|
208
232
|
for (const para of iterProseParagraphs(proseText)) {
|
|
209
233
|
if (para.skippable) continue;
|
|
210
234
|
const lang = detectPrimaryLang(para.trimmed);
|
|
211
|
-
const sentRe = /[^.!?。!?\n]+[.!?。!?]/gu;
|
|
212
235
|
const sentences = [];
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const s = sm[0].trim();
|
|
236
|
+
for (const sm of iterSentenceSpansInPara(para.raw)) {
|
|
237
|
+
const s = sm.text.trim();
|
|
216
238
|
const opener = extractSentenceOpener(s, lang, cfg);
|
|
217
|
-
const lead = sm
|
|
239
|
+
const lead = sm.text.search(/\S/);
|
|
218
240
|
sentences.push({
|
|
219
241
|
opener,
|
|
220
242
|
start: para.blockStart + sm.index + (lead >= 0 ? lead : 0),
|
|
@@ -663,31 +685,102 @@ function probeCompositeMultiSignal(proseText, rawText, banks, existingFindings)
|
|
|
663
685
|
return hits;
|
|
664
686
|
}
|
|
665
687
|
|
|
688
|
+
function probeUiGen2TastefulSlop(rawText, cfg) {
|
|
689
|
+
const clean = maskUiMarkup(rawText);
|
|
690
|
+
const minSignals = cfg.minSignals || 2;
|
|
691
|
+
const signals = [];
|
|
692
|
+
let firstHit = null;
|
|
693
|
+
|
|
694
|
+
// Signal 1: Warm cream ground + terracotta/clay accent
|
|
695
|
+
const creamMatch = clean.match(/#(?:faf8f5|f7f5f0|fbf9f6|f5f2eb|f9f6f0|fdfbf7|f4efe6)\b|\bbg-(?:stone|amber)-50\b/i);
|
|
696
|
+
const terraMatch = clean.match(/#(?:c45a3b|d97757|b85038|c85a32|c2410c|b45309)\b|\bterracotta\b|\b(?:text|bg)-orange-700\b/i);
|
|
697
|
+
if (creamMatch && terraMatch) {
|
|
698
|
+
signals.push("cream-terracotta");
|
|
699
|
+
firstHit = { index: creamMatch.index, length: creamMatch[0].length };
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// Signal 2: Serif italic accent word inside display heading
|
|
703
|
+
const italicMatch = clean.match(/<h[1-3]\b[^>]*>[\s\S]{0,160}<(?:em|i|span[^>]*\bitalic\b)[^>]*>[^<]{2,40}<\/(?:em|i|span)>/i);
|
|
704
|
+
if (italicMatch) {
|
|
705
|
+
signals.push("serif-italic-headline");
|
|
706
|
+
if (!firstHit) firstHit = { index: italicMatch.index, length: Math.min(80, italicMatch[0].length) };
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// Signal 3: Inter default font stack
|
|
710
|
+
const interMatch = clean.match(/font-family\s*:[^;\n]{0,80}['"]?Inter['"]?|font-\[\s*['"]?Inter['"]?\s*\]/i);
|
|
711
|
+
if (interMatch) {
|
|
712
|
+
signals.push("inter-default");
|
|
713
|
+
if (!firstHit) firstHit = { index: interMatch.index, length: interMatch[0].length };
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// Signal 4: Tracked uppercase eyebrow + rounded-2xl / shadow-xl combo
|
|
717
|
+
const eyebrowMatch = clean.match(/\b(?:tracking-(?:widest|wider|\[0\.[12]\d*em\])[^"'\n>]{0,40}\buppercase\b|\buppercase[^"'\n>]{0,40}\btracking-(?:widest|wider|\[0\.[12]\d*em\]))|letter-spacing\s*:\s*0\.[1-3]\d*em[^;]{0,60}text-transform\s*:\s*uppercase/i);
|
|
718
|
+
const shellMatch = /\b(?:rounded-2xl|rounded-3xl|shadow-xl|shadow-lg)\b/.test(clean);
|
|
719
|
+
if (eyebrowMatch && shellMatch) {
|
|
720
|
+
signals.push("tracked-eyebrow-shell");
|
|
721
|
+
if (!firstHit) firstHit = { index: eyebrowMatch.index, length: eyebrowMatch[0].length };
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (signals.length >= minSignals && firstHit) {
|
|
725
|
+
return [{ ...firstHit, metric: `gen2Signals=${signals.length} [${signals.join("+")}]` }];
|
|
726
|
+
}
|
|
727
|
+
return [];
|
|
728
|
+
}
|
|
729
|
+
|
|
666
730
|
// ---------- Main Pattern Library Multi-Angle Auditor ----------
|
|
667
731
|
|
|
668
|
-
export function auditPatterns(text, { filename = "<memory>", modality = null, banks = {}, angles = null, ooxml = null } = {}) {
|
|
732
|
+
export function auditPatterns(text, { filename = "<memory>", modality = null, banks = {}, angles = null, ooxml = null, config = {} } = {}) {
|
|
669
733
|
const mod = modality || detectModality(filename) || "markdown";
|
|
670
734
|
const lineStarts = buildLineStarts(text);
|
|
671
|
-
const zones = buildZones(text, mod
|
|
735
|
+
const zones = buildZones(text, mod, {
|
|
736
|
+
proseFences: config?.proseFences,
|
|
737
|
+
maskBlockquotes: config?.maskBlockquotes,
|
|
738
|
+
});
|
|
739
|
+
const { byTargetLine } = parseSuppressions(text);
|
|
740
|
+
const allowList = config?.allow || [];
|
|
741
|
+
const ruleOverrides = config?.rules || {};
|
|
672
742
|
const allowAngle = (a) => !angles || angles.includes(a);
|
|
673
743
|
const findings = [];
|
|
674
744
|
|
|
675
|
-
const
|
|
745
|
+
const isRuleSuppressedOrOff = (ruleId, line, rawMatch) => {
|
|
746
|
+
const ov = ruleOverrides[ruleId];
|
|
747
|
+
if (ov === "off" || ov === false) return true;
|
|
748
|
+
if (rawMatch && isAllowedMatch(rawMatch, allowList)) return true;
|
|
749
|
+
const sups = byTargetLine.get(line) || [];
|
|
750
|
+
for (const sup of sups) {
|
|
751
|
+
if (sup.ruleIds.includes("all") || sup.ruleIds.includes("*") || sup.ruleIds.includes(ruleId)) {
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return false;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
const resolveSeverity = (ruleId, baseSev) => {
|
|
759
|
+
const ov = ruleOverrides[ruleId];
|
|
760
|
+
if (ov === "error" || ov === "warning" || ov === "info") return ov;
|
|
761
|
+
return baseSev || "info";
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
const emitHits = (ruleMeta, hits, message, deletionTest = null) => {
|
|
765
|
+
if (ruleOverrides[ruleMeta.ruleId] === "off" || ruleOverrides[ruleMeta.ruleId] === false) return;
|
|
676
766
|
for (const h of hits) {
|
|
767
|
+
const rawMatch = text.slice(h.index, h.index + h.length);
|
|
677
768
|
const { line, col } = offsetToLineCol(text, lineStarts, h.index);
|
|
769
|
+
if (isRuleSuppressedOrOff(ruleMeta.ruleId, line, rawMatch)) continue;
|
|
678
770
|
findings.push(
|
|
679
771
|
makePatternFinding({
|
|
680
772
|
ruleId: ruleMeta.ruleId,
|
|
681
773
|
dimension: ruleMeta.dimension,
|
|
682
774
|
detectionAngle: ruleMeta.detectionAngle,
|
|
683
|
-
severity: ruleMeta.severity
|
|
775
|
+
severity: resolveSeverity(ruleMeta.ruleId, ruleMeta.severity),
|
|
684
776
|
filename,
|
|
685
777
|
modality: mod,
|
|
686
778
|
line,
|
|
687
779
|
col,
|
|
688
|
-
match:
|
|
780
|
+
match: rawMatch,
|
|
689
781
|
metric: h.metric || "",
|
|
690
782
|
message,
|
|
783
|
+
deletionTest,
|
|
691
784
|
})
|
|
692
785
|
);
|
|
693
786
|
}
|
|
@@ -700,30 +793,45 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
700
793
|
emitHits(dr.commaChain, probeCommaChain(zones.prose, text, dr.commaChain), {
|
|
701
794
|
en: "Single sentence chains 5+ comma-separated clauses in a flat cadence.",
|
|
702
795
|
zh: "单句连续串联 5 个及以上逗号分句,形成平铺拖沓的逗号链节奏。",
|
|
796
|
+
}, {
|
|
797
|
+
en: "Split into 2–3 shorter sentences at causal or chronological boundaries without dropping numbers.",
|
|
798
|
+
zh: "按因果或时间停顿拆成 2 到 3 句,保留全部条件与数字,删掉多余顺承逗号。",
|
|
703
799
|
});
|
|
704
800
|
}
|
|
705
801
|
if (dr.sentenceLengthMonotony) {
|
|
706
802
|
emitHits(dr.sentenceLengthMonotony, probeSentenceLengthMonotony(zones.prose, dr.sentenceLengthMonotony), {
|
|
707
803
|
en: "Paragraph exhibits metronome sentence-length uniformity (CV < 0.16 across >= 5 sentences).",
|
|
708
804
|
zh: "段落内连续 5 句以上句长高度均一(CV < 0.16),呈现节拍器生成韵律。",
|
|
805
|
+
}, {
|
|
806
|
+
en: "Merge related clauses or cut one sentence short to create natural length contrast.",
|
|
807
|
+
zh: "把相邻因果合并成长句,并收短关键结论句,拉开长短句起伏。",
|
|
709
808
|
});
|
|
710
809
|
}
|
|
711
810
|
if (dr.openerAnaphora) {
|
|
712
811
|
emitHits(dr.openerAnaphora, probeOpenerAnaphora(zones.prose, dr.openerAnaphora), {
|
|
713
812
|
en: "4+ consecutive prose sentences open with the identical mechanical prefix.",
|
|
714
813
|
zh: "段落内连续 4 句及以上使用完全相同的机械句首开头。",
|
|
814
|
+
}, {
|
|
815
|
+
en: "Vary sentence openings or move shared context into one topic sentence or clean list.",
|
|
816
|
+
zh: "改写句首起笔,或把并列动作收拢成一句话或真实列表。",
|
|
715
817
|
});
|
|
716
818
|
}
|
|
717
819
|
if (dr.inlineBoldSaturation && (mod === "markdown" || mod === "text")) {
|
|
718
820
|
emitHits(dr.inlineBoldSaturation, probeInlineBoldSaturation(zones.prose, text, dr.inlineBoldSaturation), {
|
|
719
821
|
en: "Dense inline `**bold**` highlight confetti inside a normal prose paragraph.",
|
|
720
822
|
zh: "普通自然段内高密度堆砌 `**加粗词**` 高亮,呈现助手式排版噪点。",
|
|
823
|
+
}, {
|
|
824
|
+
en: "Unbold inline phrases and keep emphasis only on 1 genuine key decision or caveat.",
|
|
825
|
+
zh: "去掉多余行内加粗,仅保留最关键的一处结论或风险提示。",
|
|
721
826
|
});
|
|
722
827
|
}
|
|
723
828
|
if (dr.paragraphLengthUniformity) {
|
|
724
829
|
emitHits(dr.paragraphLengthUniformity, probeParagraphLengthUniformity(zones.prose, dr.paragraphLengthUniformity), {
|
|
725
830
|
en: "Long document allocates nearly identical word budgets across >= 5 consecutive paragraphs.",
|
|
726
831
|
zh: "连续 5 段及以上正文自然段字数高度均一(CV < 0.13),呈现均匀切块模板感。",
|
|
832
|
+
}, {
|
|
833
|
+
en: "Combine two thin subsections or expand the load-bearing section with concrete details.",
|
|
834
|
+
zh: "合并偏薄的过渡段落,把篇幅集中到真正有数据或机制的核心段落。",
|
|
727
835
|
});
|
|
728
836
|
}
|
|
729
837
|
}
|
|
@@ -731,6 +839,9 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
731
839
|
emitHits(dr.discourseMarkers, probeDiscourseMarkerCluster(zones.prose, dr.discourseMarkers), {
|
|
732
840
|
en: "Mechanical transition signposts stacked across consecutive paragraphs or sentences.",
|
|
733
841
|
zh: "连续段落或句子堆砌机械过渡路标词(如“首先/其次/此外/最后”或连续“Furthermore/Moreover/Additionally”)。",
|
|
842
|
+
}, {
|
|
843
|
+
en: "Delete additive signposts (`Moreover`, `Furthermore`) and connect steps by causal order.",
|
|
844
|
+
zh: "删掉“首先/其次/此外/最后”一类空路标词,直接按动作先后或因果衔接。",
|
|
734
845
|
});
|
|
735
846
|
}
|
|
736
847
|
}
|
|
@@ -741,12 +852,18 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
741
852
|
emitHits(lex.zhCalqueCluster, probeLexicalCluster(zones.prose, lex.zhCalqueCluster), {
|
|
742
853
|
en: "Chinese AI translation-calque and hollow-connector cluster inside one paragraph.",
|
|
743
854
|
zh: "单段内聚集多处中文 AI 翻译腔或空洞连接套语(如“在……的背景下/不可否认的是/扮演着重要角色”)。",
|
|
855
|
+
}, {
|
|
856
|
+
en: "Cut hollow wrappers (`undeniably`, `plays a vital role`) and state the subject and action directly.",
|
|
857
|
+
zh: "直接删掉“不可否认/扮演着角色/奠定基础”等空架子,主语紧接具体动作与结果。",
|
|
744
858
|
});
|
|
745
859
|
}
|
|
746
860
|
if (lex.enPhraseCluster) {
|
|
747
861
|
emitHits(lex.enPhraseCluster, probeLexicalCluster(zones.prose, lex.enPhraseCluster), {
|
|
748
862
|
en: "Dense cluster of empirically over-represented English AI vocabulary in one paragraph.",
|
|
749
863
|
zh: "单段内高频聚集多个大模型超额偏好英文词组(如 `meticulous`/`pivotal`/`holistic`/`foster`/`underscore`)。",
|
|
864
|
+
}, {
|
|
865
|
+
en: "Swap abstract buzzwords (`foster`, `pivotal`, `seamless`) for plain verbs and concrete facts.",
|
|
866
|
+
zh: "把虚浮高频词换成直白动词与可验证指标,不用靠叠词制造分量。",
|
|
750
867
|
});
|
|
751
868
|
}
|
|
752
869
|
}
|
|
@@ -758,6 +875,9 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
758
875
|
emitHits(syn.concessionSymmetry, probeProseRegexPatterns(zones.prose, pats), {
|
|
759
876
|
en: "Formulaic both-sides concession frame ('While X presents challenges, it also offers tremendous opportunities').",
|
|
760
877
|
zh: "模板化两面平衡让步句式(“虽然……面临挑战,但也带来了巨大机遇”)。",
|
|
878
|
+
}, {
|
|
879
|
+
en: "Drop the both-sides cushion and state a clear recommendation with exact boundary conditions.",
|
|
880
|
+
zh: "撤掉“有利有弊/既要又要”的端水套壳,直接给出明确判断或写清触发阈值。",
|
|
761
881
|
});
|
|
762
882
|
}
|
|
763
883
|
if (syn.pullQuoteCloser) {
|
|
@@ -769,6 +889,10 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
769
889
|
{
|
|
770
890
|
en: "Poster-style pull-quote punchline closer.",
|
|
771
891
|
zh: "段尾硬加广告卡片式金句收尾(如“笔一直在你手里”“这才是……真正的温度”)。",
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
en: "Cut the bumper-sticker sign-off and end on the last concrete fact or next action.",
|
|
895
|
+
zh: "删掉结尾口号金句,让文章停在最后一条具体事实或下一步动作上。",
|
|
772
896
|
}
|
|
773
897
|
);
|
|
774
898
|
}
|
|
@@ -776,6 +900,9 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
776
900
|
emitHits(syn.rhetoricalSelfQa, probeProseRegexPatterns(zones.prose, syn.rhetoricalSelfQa.patterns || []), {
|
|
777
901
|
en: "Staged rhetorical self-Q&A transition ('Why does this matter? Because...', '这意味着什么?意味着……').",
|
|
778
902
|
zh: "正文内使用主持词式自问自答过渡句(如“这意味着什么?意味着……”“结果呢?……”)。",
|
|
903
|
+
}, {
|
|
904
|
+
en: "Remove the staged question and state the consequence in one direct declarative sentence.",
|
|
905
|
+
zh: "去掉“为什么重要?因为……”问答腔,用一句直白陈述句直接交代原因或后果。",
|
|
779
906
|
});
|
|
780
907
|
}
|
|
781
908
|
}
|
|
@@ -787,24 +914,40 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
787
914
|
emitHits(vd.glassmorphismOveruse, probeUiPatternCount(text, vd.glassmorphismOveruse), {
|
|
788
915
|
en: "Repeated `backdrop-blur` translucent panels (>= 3 per view) mimic default AI glassmorphism templates.",
|
|
789
916
|
zh: "单视图重复堆砌 3 处及以上 `backdrop-blur` 毛玻璃半透明面板,呈现典型生成式模板特征。",
|
|
917
|
+
}, {
|
|
918
|
+
en: "Replace stacked blur cards with crisp 1px borders and solid surface contrast.",
|
|
919
|
+
zh: "撤掉满屏毛玻璃半透明层,改用清晰 1px 边框与实体背景区分层级。",
|
|
790
920
|
});
|
|
791
921
|
}
|
|
792
922
|
if (vd.accentStripeCard) {
|
|
793
923
|
emitHits(vd.accentStripeCard, probeUiPatternCount(text, vd.accentStripeCard), {
|
|
794
|
-
en: "Repeated thick left accent-stripe cards (`border-l-4` / `border-left: >=
|
|
795
|
-
zh: "单视图堆叠 3 处及以上左侧粗彩条卡片(`border-l-4` / `border-left: >=
|
|
924
|
+
en: "Repeated thick left accent-stripe cards (`border-l-4` / `border-left: >=4px solid`, >= 3 per view) signal boilerplate dashboards.",
|
|
925
|
+
zh: "单视图堆叠 3 处及以上左侧粗彩条卡片(`border-l-4` / `border-left: >=4px solid`),呈现典型 AI 后台面板套路。",
|
|
926
|
+
}, {
|
|
927
|
+
en: "Drop thick decorative side stripes and rely on alignment, spacing, and typography scale.",
|
|
928
|
+
zh: "去掉卡片左侧装饰粗彩条,靠留白对齐和字阶主次划分模块。",
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
if (vd.gen2TastefulSlop) {
|
|
932
|
+
emitHits(vd.gen2TastefulSlop, probeUiGen2TastefulSlop(text, vd.gen2TastefulSlop), {
|
|
933
|
+
en: "Second-generation 'tasteful' AI UI template cluster (>= 2 of warm-cream/terracotta, serif-italic headline accent, Inter stack, tracked-uppercase eyebrow).",
|
|
934
|
+
zh: "第二代“伪人文精致模板”组合特征(同时命中暖米白+陶土红配色、标题斜体强调词、Inter 默认字体或宽字距全大写眉题中 2 项及以上)。",
|
|
935
|
+
}, {
|
|
936
|
+
en: "Cut generic template chrome (uppercase kickers, italic buzzword spans) and keep layout purposeful.",
|
|
937
|
+
zh: "删掉宽字距全大写眉题和标题斜体装点,用项目真实品牌字体与克制版式。",
|
|
796
938
|
});
|
|
797
939
|
}
|
|
798
940
|
}
|
|
799
|
-
if (mod === "pptx" && ooxml && vd.pptxLayoutMonotony) {
|
|
941
|
+
if (mod === "pptx" && ooxml && vd.pptxLayoutMonotony && ruleOverrides[vd.pptxLayoutMonotony.ruleId] !== "off" && ruleOverrides[vd.pptxLayoutMonotony.ruleId] !== false) {
|
|
800
942
|
const slideHits = probePptxLayoutMonotony(ooxml, vd.pptxLayoutMonotony);
|
|
801
943
|
for (const sh of slideHits) {
|
|
944
|
+
if (isRuleSuppressedOrOff(vd.pptxLayoutMonotony.ruleId, sh.slideNum, sh.match)) continue;
|
|
802
945
|
findings.push(
|
|
803
946
|
makePatternFinding({
|
|
804
947
|
ruleId: vd.pptxLayoutMonotony.ruleId,
|
|
805
948
|
dimension: vd.pptxLayoutMonotony.dimension,
|
|
806
949
|
detectionAngle: vd.pptxLayoutMonotony.detectionAngle,
|
|
807
|
-
severity: vd.pptxLayoutMonotony.severity
|
|
950
|
+
severity: resolveSeverity(vd.pptxLayoutMonotony.ruleId, vd.pptxLayoutMonotony.severity),
|
|
808
951
|
filename,
|
|
809
952
|
modality: mod,
|
|
810
953
|
line: sh.slideNum,
|
|
@@ -816,6 +959,10 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
816
959
|
en: "4+ consecutive content slides share the identical plain-bullet layout with no table, chart, or diagram.",
|
|
817
960
|
zh: "连续 4 页及以上正文幻灯片均退化为纯字要点列表页(无图表、表格或配图),版式过于单调。",
|
|
818
961
|
},
|
|
962
|
+
deletionTest: {
|
|
963
|
+
en: "Turn data points into a comparison table or chart, or pair one claim with concrete visual evidence.",
|
|
964
|
+
zh: "把连续文字清单改排成对比表格、结构图或数据卡片,打破连页纯字版式。",
|
|
965
|
+
},
|
|
819
966
|
})
|
|
820
967
|
);
|
|
821
968
|
}
|
|
@@ -827,6 +974,9 @@ export function auditPatterns(text, { filename = "<memory>", modality = null, ba
|
|
|
827
974
|
emitHits(comp, probeCompositeMultiSignal(zones.prose, text, banks, findings), {
|
|
828
975
|
en: "Multiple sub-threshold AI signals (lexical + discourse + framing/cadence) co-occur in one low-fact paragraph.",
|
|
829
976
|
zh: "同一低事实段落内叠加多个跨维度弱 AI 味信号(套词 + 过渡路标 + 抽象框架/节奏),虽未单点越线但整体 AI 腔明显。",
|
|
977
|
+
}, {
|
|
978
|
+
en: "Trim empty framing phrases and anchor the paragraph in at least one metric, file, date, or concrete decision.",
|
|
979
|
+
zh: "删掉空泛套词与过渡壳,至少补进一条实测指标、文件名、日期或明确取舍结论。",
|
|
830
980
|
});
|
|
831
981
|
}
|
|
832
982
|
|
package/src/pocket-model.mjs
CHANGED
|
@@ -190,7 +190,8 @@ function stripFencedBlocksLinear(raw) {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
export function cleanProseSurface(raw) {
|
|
193
|
-
let s = String(raw || "").replace(/\uFEFF/g, " ");
|
|
193
|
+
let s = String(raw || "").replace(/^\uFEFF/, "").replace(/\uFEFF/g, " ");
|
|
194
|
+
s = s.replace(/^[ \t]*---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?=\r?\n|$)/, " ");
|
|
194
195
|
s = s.replace(DISLOP_QUOTE_BLOCK_RE, " ");
|
|
195
196
|
s = s.replace(HTML_COMMENT_RE, " ");
|
|
196
197
|
s = stripFencedBlocksLinear(s);
|
|
@@ -589,13 +590,23 @@ export function predictPackWithPocketRouter(text, customBundle = null) {
|
|
|
589
590
|
|
|
590
591
|
function maskNewlinePreserving(text) {
|
|
591
592
|
return String(text || "")
|
|
593
|
+
.replace(/^\uFEFF?[ \t]*---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?=\r?\n|$)/, (m) => m.replace(/[^\n]/g, " "))
|
|
592
594
|
.replace(DISLOP_QUOTE_BLOCK_RE, (m) => m.replace(/[^\n]/g, " "))
|
|
593
595
|
.replace(HTML_COMMENT_RE, (m) => m.replace(/[^\n]/g, " "));
|
|
594
596
|
}
|
|
595
597
|
|
|
596
|
-
function
|
|
598
|
+
function isUiShortLineStack(lines) {
|
|
599
|
+
if (!lines || lines.length < 3) return false;
|
|
600
|
+
const nonEmpty = lines.map((l) => l.trim()).filter(Boolean);
|
|
601
|
+
if (nonEmpty.length < 3) return false;
|
|
602
|
+
const shortCount = nonEmpty.filter((l) => cpLen(l) <= 16).length;
|
|
603
|
+
return shortCount * 2 >= nonEmpty.length;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function splitParagraphBlocks(raw, meta = null) {
|
|
597
607
|
const text = maskNewlinePreserving(raw);
|
|
598
608
|
const blocks = [];
|
|
609
|
+
let suppressedUiCount = 0;
|
|
599
610
|
let lineNo = 1;
|
|
600
611
|
let idx = 0;
|
|
601
612
|
const lines = text.split("\n");
|
|
@@ -608,7 +619,9 @@ function splitParagraphBlocks(raw) {
|
|
|
608
619
|
if (curLines.length === 0) return;
|
|
609
620
|
const content = curLines.join("\n");
|
|
610
621
|
const trimmed = content.trim();
|
|
611
|
-
if (
|
|
622
|
+
if (isUiShortLineStack(curLines)) {
|
|
623
|
+
suppressedUiCount += 1;
|
|
624
|
+
} else if (
|
|
612
625
|
trimmed.length >= 24 &&
|
|
613
626
|
!trimmed.startsWith("#") &&
|
|
614
627
|
!trimmed.startsWith("|") &&
|
|
@@ -658,6 +671,7 @@ function splitParagraphBlocks(raw) {
|
|
|
658
671
|
lineNo += 1;
|
|
659
672
|
}
|
|
660
673
|
flush(cpLen(text), lines.length);
|
|
674
|
+
if (meta) meta.suppressedUiCount = suppressedUiCount;
|
|
661
675
|
return blocks;
|
|
662
676
|
}
|
|
663
677
|
|
|
@@ -671,7 +685,8 @@ export function analyzeDocumentWithPocketModels(text, { threshold = null, custom
|
|
|
671
685
|
const effectiveThreshold = threshold ?? bundle.thresholds?.stealthWarning ?? 0.755;
|
|
672
686
|
const whole = scorePocketSpan(text, bundle);
|
|
673
687
|
const packRouting = predictPackWithPocketRouter(text, bundle);
|
|
674
|
-
const
|
|
688
|
+
const blockMeta = { suppressedUiCount: 0 };
|
|
689
|
+
const blocks = splitParagraphBlocks(text, blockMeta);
|
|
675
690
|
|
|
676
691
|
const paragraphs = [];
|
|
677
692
|
for (const b of blocks) {
|
|
@@ -691,8 +706,15 @@ export function analyzeDocumentWithPocketModels(text, { threshold = null, custom
|
|
|
691
706
|
|
|
692
707
|
const maxParagraphProb =
|
|
693
708
|
paragraphs.length > 0 ? maxOf(paragraphs.map((p) => p.slopProbability)) : whole.slopProbability;
|
|
694
|
-
const documentProbability = round4(Math.max(whole.slopProbability, maxParagraphProb));
|
|
695
709
|
const flaggedParagraphs = paragraphs.filter((p) => p.flagged);
|
|
710
|
+
let documentProbability = round4(Math.max(whole.slopProbability, maxParagraphProb));
|
|
711
|
+
if (
|
|
712
|
+
flaggedParagraphs.length === 0 &&
|
|
713
|
+
(paragraphs.length > 0 || blockMeta.suppressedUiCount > 0 || !whole.eligible) &&
|
|
714
|
+
documentProbability >= effectiveThreshold
|
|
715
|
+
) {
|
|
716
|
+
documentProbability = round4(Math.max(0, effectiveThreshold - 0.005));
|
|
717
|
+
}
|
|
696
718
|
|
|
697
719
|
return {
|
|
698
720
|
schema: bundle.schema,
|