#!/usr/bin/env node 'use strict'; const fs = require('fs'); const { loadStyleWhitelist, maskStyleText } = require('./style-whitelist.js'); const path = require('path'); const USAGE = `Usage: node check-ai-patterns.js [--check] [--json] [--fail-on=blocking|all] node check-ai-patterns.js --list-review-classes Detect high-risk AI-flavor prose patterns that need human rewrite: - negative setup followed by positive flip in the same sentence - comma/semicolon/colon + positive flip - sentence break + positive flip - repeated negative setup followed by positive flip - em-dash (按功能改写), 碎句号 (连续短叙述句), 长段落 (按镜头断段) - 微动作复读 (「了下/了一下」式轻量补语高密度,电报体指纹) - 套式反应细节 (指尖/指节/目光等无功能微动作与「平静得像在念」式语气比喻成片) - 抽象总结复读 (命运/棋局/这一刻终于明白/才刚刚开始,AI 结尾腔) - 套词密度过高 (仿佛/一丝/深吸一口气/平静无波等禁用词聚集) - 比喻密度过高 (像/好像/仿佛/如同等比喻标记成片复现) - 解释链密度过高 (知道/明白/这意味着/必须/需要等判断链聚集) - 系统公告公文腔过密 (方括号系统/规则行里硬规则词聚集) - 过度精炼短段 (长文本里短叙述段过密且自然连接偏少) - 低连接密度 (引号外叙述功能词/白话连接偏少且中长句不足,像提纲/电报体) - 监控摄像头式动作清单 (同段连续摆放动作动词,缺少视角温度/情绪缓冲) - 音量反差腔 (声音不高/不大…却…, 实战漏网句式) - 否定排比 (没有X,没有Y…连排 / 没X…只是Y 先否定后肯定, 实战漏网句式) - 工整并列 (至于X不X,怎么X / 同动词「不V A,不V B」,含台词,advisory) - 反序对比 (是A,不是B — not-is 的反序变种, 实战漏网句式) - 预告式总结收尾 (文末窗口 没人知道/才刚刚开始/正朝着…压了过去, 实战漏网句式) - 章尾状态总结体 (文末窗口 这一夜注定/这一切都结束了/新的人生才刚刚开始/命运的齿轮) - 引号强调滥用 (叙述里 1-4 字短词加引号强调,密度型) - 叙述省略号过密 (引号与面板外 …… 高密度刷屏,advisory) Book-local .deslop-whitelist literal spans are excluded from style scanning (no regex or ancestor inheritance). Each finding carries severity: blocking by default for generation/deslop cleanup (not-is-comparison / em-dash / voice-contrast / negation-parade / reverse-not-is / trailer-ending / trailer-summary), where single/low-count hits of rhetorical patterns downgrade to semantic advisory and high-density clusters block. This is a local style/readability gate, not an AIGC detector score; functional human text can be marked for review instead of hard-edited for a detector. 或 advisory (period-stutter / long-paragraph / micro-action-tic / negation-pair-tic / stock-reaction-tic / action-list-tic / abstract-summary-tic / cliche-density-tic / metaphor-density-tic / reasoning-chain-tic / system-notice-formality-tic / overcompressed-prose-tic / low-connective-density-tic / quote-emphasis-tic / formulaic-parallelism / ellipsis-density-tic,是提示,justified 的长推理/氛围段可保留)。 --fail-on=blocking 只在出现 blocking finding 时退出 1;默认 --fail-on=all 有任何 finding 即退出 1。 Each finding also carries review: mechanical(表面形态确定、就地改写即可)或 semantic(可能承担叙事功能,需读上下文判断是否保留);blocking 一律 mechanical。--list-review-classes 输出完整分类表(JSON)。 HTML comments (, e.g. the 去味:跳过 exemption marker) are metadata, not prose, and are never scanned. The script reports findings only. It never rewrites text, because the safe fix is contextual: usually delete the negative setup, write the positive term directly, or show it via action/detail.`; const STOP_CHARS = new Set(['。', '!', '?', '!', '?', '\n']); const SOFT_SEPARATORS = new Set([',', ',', '、', ';', ';', ':', ':']); const HARD_SEPARATORS = new Set(['。', '.', '!', '!', '?', '?']); const MAX_NEGATIVE_SPAN = 80; const MAX_POSITIVE_SPAN = 80; // 碎句号:连续 STUTTER_MIN_RUN 个「叙述」短句(每句可见字数 ≤ STUTTER_MAX_SENTENCE)无呼吸。 // 只数叙述句,跳过对话/弹幕/系统播报(成片短句是这些体裁的正常形态,不算碎句号)。 const STUTTER_MIN_RUN = 6; const STUTTER_MAX_SENTENCE = 5; // 长段落:单段原始字符数超过阈值即提示按镜头断段(手机阅读保守阈值,正常单段远低于此)。 const LONG_PARAGRAPH_CHARS = 200; // 微动作复读:「V了下 / V了一下 / 拍了两下 / 松了半圈」式轻量补语在叙述里高密度复现, // 容易形成删减过头的电报体指纹。只扫引号外叙述;密度与次数双门槛同时达标才报, // 单次出现是正常中文。 const MICRO_TIC_PATTERN = /了(?:[一两三几半])?[下阵圈道声眼口气会]/g; const MICRO_TIC_MIN_HITS = 5; // 「没A,也没B」「不A,也不B」否定对偶:七猫人类长篇约 0.07 处/千字,模型稿 0.4-1.5 处/千字; // 写人物没做什么是英文式节奏,一章 3 处以上报一条提示。 const NEGATION_PAIR_PATTERN = /(?:没有|没|不)[^,。!?;,!?\n]{1,10}[,,;]\s*[^,。!?;,!?\n]{0,6}?也(?:没有|没|不)/g; const NEGATION_PAIR_MIN_HITS = 3; const MICRO_TIC_PER_KILO = 6; // 套式反应细节:不是禁写身体,而是提示成片出现的“部位 + 轻微动作/状态”、 // “胸口像被撞了一下”、喉结/眼圈/声音放轻等通用情绪尾巴,以及“平静语气 + // 像在念/宣判”模板。此类句子词面变化大,不能逐词 blocking;按章聚集到 4 处才 // advisory,要求逐处做删除测试。正常受伤、打斗、生理反应若承担物理后果可保留。 const STOCK_REACTION_PATTERNS = [ /(?:指尖|指腹|手指|指节|手背|掌心|拳头|袖口|衣角|裙角|下唇|嘴唇|唇角|嘴角|眉头|眼底|眸光|目光|视线|肩膀|呼吸)[^。!?!?\n]{0,16}(?:轻轻|微微|缓缓|慢慢|悄然|不自觉|无意识|下意识|攥紧|握紧|收紧|绞紧|拢住|按住|压住|扣住|捻|泛白|发白|叩|敲|摩挲|抿紧|抿成|移开|垂下|躲开|落[在到][^,。!?!?\n]{1,10}(?:停|顿)|一颤|颤了?一下|停了?一下|顿了?一下)/g, /(?:手|指尖|手指)往(?:袖口?|怀|兜|口袋|身后|背后)里?一?(?:缩|揣|收|藏)/g, /(?:语气|声音)[^。!?!?\n]{0,12}(?:平静|冷静|平淡|冷淡|淡漠|平直)[^。!?!?\n]{0,12}(?:像|仿佛|如同|好像)[^。!?!?\n]{0,16}(?:念|读|报|说|陈述|宣判|背诵)/g, /(?:胸口|心口)[^。!?!?\n]{0,16}(?:像|仿佛|如同|好像)[^。!?!?\n]{0,16}(?:撞|锤|压|攥|堵)[^。!?!?\n]{0,8}(?:一下|一记|一拳)?/g, /(?:声音|嗓音|语气)[^。!?!?\n]{0,12}(?:放轻|压低|发紧|发颤|很轻|轻了些)/g, /(?:喉结|喉头|喉咙)[^。!?!?\n]{0,10}(?:滚|动|紧|堵|发涩|发干)/g, /(?:眼眶|眼圈|鼻子)[^。!?!?\n]{0,8}(?:发红|红了|发热|发酸|一酸)/g, /(?:抿了?下唇|抿了?抿唇|抿了?下嘴|抿着笑)/g, ]; const STOCK_REACTION_MIN_HITS = 4; // 校准(真人语料,
已还原为换行):qimao 长篇 5584 章 + heiyan 短篇整篇 3983 篇。 // 长篇章尺度(中位约 2100 字)per-kilo 1.0→1.5 误报 0.43%→0.39%,几乎不动; // 短篇整篇 8000-20000 字下 MIN_HITS 形同虚设、只剩密度门,1.0 时误报 5.57%, // 1.5 降到 1.46%。故取 1.5,把两个总体拉到同一量级(四份副本共用一组阈值)。 const STOCK_REACTION_PER_KILO = 1.5; // 监控摄像头式动作清单:同一段连续堆叠通用动作动词(伸手/拿起/取过/挑开/放下/转身等), // 且用逗号/顿号串联成步骤表时,读感像无视角温度的监控记录。只做 advisory; // 打斗/追逐等功能性动作编排可保留或人工复核。 const ACTION_LIST_VERB_PATTERN = /伸手|抬手|探手|拿起|拿过|取出|取过|掏出|摸出|抓起|攥住|握住|捏住|按住|推开|拉开|打开|关上|放下|递给|挑开|掀开|扯开|拧开|倒出|端起|转身|回头|抬头|低头|弯腰|俯身|走到|走向|坐下|站起|看向|看着|盯着|扫过/g; const ACTION_LIST_MIN_HITS = 5; const ACTION_LIST_MIN_SEPARATORS = 4; // 抽象总结复读:模板化段落常把角色当下经历拔成「命运/棋局/ // 这一刻终于明白/才刚刚开始」的作者总结。单个词可能服务题材;高密度聚集才报。 const ABSTRACT_SUMMARY_PATTERNS = [ /这一刻[,,]?[^\n。!?!?]{0,24}(?:终于|才)(?:明白|意识到)/g, /从这一刻开始/g, /(?:命运|宿命)[^\n。!?!?]{0,28}(?:齿轮|棋局|獠牙|改写|推向|安排)/g, /早已[^\n。!?!?]{0,8}(?:布好|安排好)[^\n。!?!?]{0,8}(?:棋局|局)/g, /前所未有的(?:决意|清醒|勇气|力量|恐惧|平静|信念)/g, /(?:反击|复仇|战争|较量|故事|命运)[^\n。!?!?]{0,12}才刚刚开始/g, /(?:新的开始|全新的开始)/g, ]; const ABSTRACT_SUMMARY_MIN_HITS = 3; const ABSTRACT_SUMMARY_PER_KILO = 4; // 套词密度:单个「仿佛/一丝」可能是正常中文,高密度聚集才会形成模板腔。 // 词表只收本 repo banned-words 中已明确标为高危的形态,避免把普通功能词一网打尽。 const CLICHE_PATTERNS = [ /仿佛|犹如|宛若|如同/g, /一丝|一抹|些许|几分|隐约/g, /深吸一口气|缓缓|微微|轻轻|淡淡/g, /眼中闪过|嘴角勾起|眸光微微一闪|指节泛白|目光锐利|眼神锐利/g, /心中涌起一股|心头一震|心中一动|心下了然|心中暗道|心中一凛/g, /不容置疑|不容置喙|不易察觉|显而易见|毫无疑问|不可否认/g, /声音不大[,,]?却带着|语气平静无波|平静无波|声音平直|听不出情绪/g, /不知何时|唾手可得|无声翻涌|沉默(?:在[^。!?!?\n]{0,16})?蔓延|难以言说/g, /散发着一股|冰冷的光|格外刺眼|深邃而冰冷/g, ]; const CLICHE_DENSITY_MIN_HITS = 8; const CLICHE_DENSITY_PER_KILO = 12; // 比喻密度:单个生活化比喻可服务画面;“像/好像/仿佛/如同”成片复现时, // 容易变成 AI 式修辞堆叠。只做 advisory,修法是删到必要数量并回到具体画面, // 不是把“像”换成另一组比喻词。 const METAPHOR_MARKER_PATTERN = /好像|像是|仿佛|宛如|如同|犹如|(? `${escapeRegExp(open)}[^${escapeRegExpCharClass(close)}\\n]*${escapeRegExp(close)}`); // ---- 实战测试漏网句式(来源:实战写作抓到的真实漏网例句;2026-07 校准)---- // 校准基线:《万疆》真人正文 20 章(第1/10/20/…/190章)+ demo 前 20 章。 // blocking 规则要求真人语料命中 ≈0(每 20 章 ≤1 处且人工判定确属该句式);数据见各规则注释。 // 音量反差腔(实战漏网 A):「声音不高,第一句却稳稳压住了整个大厅。」 // 旧网只有套词密度桶里的「声音不大,却带着」,音量词/转折词一换就漏。 // 引号外叙述逐处 blocking;修法是删掉音量铺垫,直接写声音落进场子的具体效果。 // 校准:《万疆》20 章 0 命中,demo 前 20 章 0 命中。 const VOICE_CONTRAST_PATTERN = /声音(?:并)?不[大高响亮][^。!?!?\n]{0,16}[却但偏]/g; // 否定排比(实战漏网 B):「没有伴奏,没有和声,没有提词器。」同句 ≥2 个「没有X,」连排; // 变体「他没炫技,没有那种…架势。他只是唱」先否定铺垫、再用「只是/只会/只有」收肯定。 // 只收「没/没有」段,不收「不X」段——真人叙述里「不哭不闹」类太常见,收进来误报换不来收益。 // 光杆「没」还得挡两类非否定用法,否则正常叙述会被判成排比: // 1) 黏着语素(沉没/淹没/埋没/出没/隐没…)——前字排除,「船沉没在雾里,没人回头,…只有…」不算; // 2) 时间惯用语(没多久/没过多久/没等X)——后字排除,「没多久,没等她撑伞,…只有…」不算。 // 「没有X」段不带这两种歧义(黏着语素后接不出「有」,时间惯用语已被后字排除覆盖), // 第一条连排式照旧不加护栏。 // 校准:《万疆》20 章 0 命中,demo 前 20 章 0 命中。 const NEGATION_PARADE_PATTERNS = [ /(?:没有[^。!?!?\n,,]{1,12}[,,]){2}/g, /(? { const baseReview = reviewClass(finding.type); return { file, ...finding, review: finding.review || baseReview }; }); allFindings.push(...findings); } if (options.json) { process.stdout.write(`${JSON.stringify({ findings: allFindings }, null, 2)}\n`); } else { for (const finding of allFindings) { console.log(`${finding.file}:${finding.line}:${finding.column}: [${finding.severity}] ${finding.type}: ${finding.message} (${finding.excerpt})`); } } if (failed) process.exit(2); // --fail-on=blocking 只在出现 blocking finding 时退出 1(advisory 仅报告);默认 all 沿用「有任何 finding 即 1」。 // 用 process.exitCode 而非 process.exit(1),确保 >64KB JSON 管道输出完整刷出后再退出。 const hasBlocking = allFindings.some((f) => f.severity === 'blocking'); if (options.failOn === 'blocking' ? hasBlocking : allFindings.length > 0) process.exitCode = 1; function reviewClass(type) { const review = REVIEW_CLASSES[type]; if (!review) { console.error(`internal error: finding type '${type}' has no review class (add it to REVIEW_CLASSES)`); process.exit(2); } return review; } function escapeRegExp(text) { return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } function escapeRegExpCharClass(text) { return text.replace(/[\\\]^-]/g, '\\$&'); } function die(message) { console.error(message); console.error(USAGE.trimEnd()); process.exit(2); } // unclosedOpenings:到文末都没闭合的 `` 会把后面整章藏起来;这些位置按正文扫描,只把 `` 豁免标记)是元信息不是正文:注释段等长换成空格 // 保列号,整行都是注释的直接跳过;注释可跨行。 const masked = maskHtmlComments(line, commentOpen, index, unclosedOpenings); commentOpen = masked.open; if (masked.openedAt !== null) commentStart = masked.openedAt; if (masked.text !== line && !masked.text.trim()) continue; block.push({ text: masked.text, lineNo: index + 1 }); proseLines.push({ text: masked.text, lineNo: index + 1 }); } if (commentOpen && commentStart !== null) { return scanDocument(input, new Set([...unclosedOpenings, commentStart])); } flushBlock(); findings.push(...scanProsePatterns(proseLines)); let proseChars = 0; for (const { text } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; proseChars += Array.from(trimmed.replace(/\s+/g, '')).length; } applyDensitySeverityGates(findings, proseChars); findings.sort((a, b) => a.line - b.line || a.column - b.column); return findings; } function applyDensitySeverityGates(findings, proseChars = 0) { const scale = Math.max(1, Math.floor((proseChars + Math.floor(DENSITY_SCALE_UNIT_CHARS / 2)) / DENSITY_SCALE_UNIT_CHARS)); const counts = new Map(); for (const f of findings) { counts.set(f.type, (counts.get(f.type) || 0) + 1); } const notIsCombined = (counts.get('not-is-comparison') || 0) + (counts.get('reverse-not-is') || 0); for (const f of findings) { let block = null; if (f.type === 'not-is-comparison' || f.type === 'reverse-not-is') { block = notIsCombined >= NOT_IS_BLOCKING_MIN_HITS * scale; } else if (f.type === 'voice-contrast') { block = (counts.get('voice-contrast') || 0) >= VOICE_CONTRAST_BLOCKING_MIN_HITS * scale; } else if (f.type === 'negation-parade') { block = (counts.get('negation-parade') || 0) >= NEGATION_PARADE_BLOCKING_MIN_HITS * scale; } else if (f.type === 'trailer-ending') { block = (counts.get('trailer-ending') || 0) >= TRAILER_ENDING_BLOCKING_MIN_HITS; } if (block === true) { f.severity = 'blocking'; f.review = 'mechanical'; } else if (block === false) { f.severity = 'advisory'; f.review = 'semantic'; } } } // 段落级检测:碎句号(连续短叙述句)、长段落、旁白破折号(按功能改写,对白引号与面板内豁免)。 function scanProsePatterns(proseLines) { const findings = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const dashScanText = maskQuotedWithUnclosed(text); const dashPattern = /——|—|--+/g; let dash; while ((dash = dashPattern.exec(dashScanText)) !== null) { findings.push({ line: lineNo, column: dash.index + 1, type: 'em-dash', severity: 'blocking', message: '叙述旁白不用破折号,按功能改写:打断→动作或抢白,停顿→逗号或省略,插入说明→逗号/冒号;勿一律改句号。', excerpt: compact(text.slice(Math.max(0, dash.index - 8), dash.index + dash[0].length + 8)), }); } if (trimmed.length > LONG_PARAGRAPH_CHARS) { findings.push({ line: lineNo, column: 1, type: 'long-paragraph', severity: 'advisory', message: `段落过长(${trimmed.length} 字):按镜头/新动作/新线索/视线切换断段,别一段到底。`, excerpt: compact(trimmed.slice(0, 40)), }); } } findings.push(...findVoiceContrast(proseLines)); findings.push(...findNegationParade(proseLines)); findings.push(...findFormulaicParallelism(proseLines)); findings.push(...findReverseNotIs(proseLines)); findings.push(...findTrailerEnding(proseLines)); findings.push(...findQuoteEmphasisTic(proseLines)); findings.push(...findPeriodStutter(proseLines)); findings.push(...findMicroActionTic(proseLines)); findings.push(...findNegationPairTic(proseLines)); findings.push(...findStockReactionTic(proseLines)); findings.push(...findActionListTic(proseLines)); findings.push(...findAbstractSummaryTic(proseLines)); findings.push(...findClicheDensityTic(proseLines)); findings.push(...findMetaphorDensityTic(proseLines)); findings.push(...findReasoningChainTic(proseLines)); findings.push(...findNoticeFormalityTic(proseLines)); findings.push(...findOvercompressedProseTic(proseLines)); findings.push(...findLowConnectiveDensityTic(proseLines)); findings.push(...findEllipsisDensityTic(proseLines)); return findings; } // 音量反差腔(实战漏网 A):引号外叙述命中,单处 advisory、同章 ≥2 处 blocking。 function findVoiceContrast(proseLines) { const findings = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const masked = maskQuoted(text); VOICE_CONTRAST_PATTERN.lastIndex = 0; let match; while ((match = VOICE_CONTRAST_PATTERN.exec(masked)) !== null) { findings.push({ line: lineNo, column: match.index + 1, type: 'voice-contrast', severity: 'blocking', message: '音量反差腔:「声音不大/不高…却/但…」是 AI 高频反差模板;删掉音量铺垫,直接写台词分量、利害后果或在场者的立场反应。', excerpt: compact(text.slice(match.index, match.index + match[0].length)), }); } } return findings; } // 否定排比(实战漏网 B):同句「没有X,」连排 / 先否定后「只是」收肯定。 // 可能在同一片文字上重叠命中,按区间去重只报一次。 function findNegationParade(proseLines) { const findings = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const masked = maskQuoted(text); const spans = []; for (const pattern of NEGATION_PARADE_PATTERNS) { pattern.lastIndex = 0; let match; while ((match = pattern.exec(masked)) !== null) { spans.push([match.index, match.index + match[0].length]); } } spans.sort((a, b) => a[0] - b[0]); let lastEnd = -1; for (const [start, end] of spans) { if (start < lastEnd) { lastEnd = Math.max(lastEnd, end); continue; } lastEnd = end; findings.push({ line: lineNo, column: start + 1, type: 'negation-parade', severity: 'blocking', message: '否定排比:「没有X,没有Y…」/「没X,没有Y,只是Z」是 AI 高频排比模板;删掉否定清单,直接写现场实际有什么,最多留一个最有信息量的否定。', excerpt: compact(text.slice(start, end)), }); } } return findings; } function findFormulaicParallelism(proseLines) { const findings = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; for (const [pattern, message] of [ [DECISION_FRAME_PATTERN, '「至于X不X,怎么X」把同一决定拆成工整栏目;若只是复述细纲,压成角色当下的一次判断或直接动作。'], [REPEATED_NEGATIVE_VERB_PATTERN, '同动词「不V A,不V B」容易写成否定清单;含台词也要按语境复核,保留真正有功能的一项即可。'], ]) { pattern.lastIndex = 0; let match; while ((match = pattern.exec(text)) !== null) { findings.push({ line: lineNo, column: match.index + 1, type: 'formulaic-parallelism', severity: 'advisory', message, excerpt: compact(match[0]), }); } } } // 跨段「不是A / 也不是B / 只是C」既可能是细纲复述,也可能是正常的 // 辩解、悬念排除或情绪递进。纯句法无法稳定区分,因此只给 advisory,交给语义复核。 const window = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed) continue; if (isDivider(trimmed) || isStructural(trimmed)) { window.length = 0; continue; } if (window.length && lineNo - window[window.length - 1].lineNo > 2) window.length = 0; window.push({ text: maskQuoted(trimmed), original: trimmed, lineNo }); if (window.length > 3) window.shift(); if (window.length !== 3) continue; if (!CROSS_NEGATION_START.test(window[0].text) || !CROSS_NEGATION_MIDDLE.test(window[1].text) || !CROSS_NEGATION_END.test(window[2].text)) continue; findings.push({ line: window[0].lineNo, column: 1, type: 'formulaic-parallelism', severity: 'advisory', message: '跨段「不是… / 也不是… / 只是…」可能是工整否定铺排,也可能承担辩解或悬念排除;通读语境,只在重复细纲或拖慢画面时改写。', excerpt: compact(window.map((entry) => entry.original).join(' / ')), }); } return findings; } // 反序对比腔(实战漏网 C):「是A,不是B」。排除基建复用 not-is-comparison: // 引号内剥离、「是的/是啊」确认语;前字合成词与反问尾巴见 REVERSE_NOT_IS_PREV_EXCLUDE 注释。 function findReverseNotIs(proseLines) { const findings = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const masked = maskQuoted(text); REVERSE_NOT_IS_PATTERN.lastIndex = 0; let match; while ((match = REVERSE_NOT_IS_PATTERN.exec(masked)) !== null) { const start = match.index; // 「就是/也是/还是/只是/可是…」里的「是」是合成词一部分,不是肯定项系动词。 if (REVERSE_NOT_IS_PREV_EXCLUDE.has(masked[start - 1])) continue; // 「是不是…」问句起头。 if (masked[start + 1] === '不') continue; // 「是的,…不是…」承接确认语(复用 not-is 的判定)。 if (isAffirmationTagAt(masked, start)) continue; // 「…,不是吗/不是么/不是吧」反问尾巴。 if (/^[吗么吧]/.test(match[2])) continue; findings.push({ line: lineNo, column: start + 1, type: 'reverse-not-is', severity: 'blocking', message: '反序对比腔:「是A,不是B」与「不是A,是B」同族;删掉后置否定,直接写 A 的具体表现,或用细节让读者自己对比。', excerpt: compact(text.slice(start, start + match[0].length)), }); } } return findings; } // 预告式总结收尾(实战漏网 D):只扫文末窗口。从文末往回收集叙述行, // 直到剥引号后的可见字数达到窗口大小(按行取整,边界行整行计入)。 function findTrailerEnding(proseLines) { const windowLines = []; let accumulated = 0; for (let i = proseLines.length - 1; i >= 0 && accumulated < TRAILER_ENDING_WINDOW_CHARS; i -= 1) { const { text } = proseLines[i]; const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; windowLines.unshift(proseLines[i]); accumulated += visibleLength(stripQuoted(trimmed)); } const findings = []; for (const { text, lineNo } of windowLines) { const masked = maskQuoted(text); TRAILER_ENDING_PATTERN.lastIndex = 0; let match; while ((match = TRAILER_ENDING_PATTERN.exec(masked)) !== null) { findings.push({ line: lineNo, column: match.index + 1, type: 'trailer-ending', severity: 'blocking', message: '预告式总结收尾:「没人知道/才刚刚开始/正朝着…压了过去」是 AI 章尾预告腔;结尾停在具体决定、动作、画面或一句台词上,悬念让事件自己挂住,别替读者预告下一章。', excerpt: compact(text.slice(match.index, match.index + match[0].length)), }); } TRAILER_SUMMARY_PATTERN.lastIndex = 0; let summaryMatch; while ((summaryMatch = TRAILER_SUMMARY_PATTERN.exec(masked)) !== null) { findings.push({ line: lineNo, column: summaryMatch.index + 1, type: 'trailer-summary', severity: 'blocking', message: '章尾状态总结体:「这一夜注定…/这一切都结束了/新的人生才刚刚开始/命运的齿轮」是把细纲的结尾设定原样写成了总结句;结尾设定要落成最后一个具体决定、动作、画面或台词,别替读者盖章。', excerpt: compact(text.slice(summaryMatch.index, summaryMatch.index + summaryMatch[0].length)), }); } } return findings; } // 引号强调滥用(实战漏网 E):统计叙述层 1-4 字成对引号强调片段,全文只报一条 // (密度型分布指纹)。台词类排除见 QUOTE_EMPHASIS_* 常量注释。 function findQuoteEmphasisTic(proseLines) { let hits = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; // 引号外没有叙述的行(独立台词/弹幕流/拟声词连发「“叮咚~”“叮咚~”」)整行跳过: // 强调滥用是叙述层指纹,没有叙述就无所谓强调。 if (visibleLength(stripQuoted(trimmed)) === 0) continue; const ranges = quotedRanges(text); for (const [start, end] of ranges) { if (text[start] === '【') continue; // 系统面板/公告载体,不是强调引号 // 引号套引号:台词内部的强调属于角色语言,不算叙述层强调滥用。 if (ranges.some(([s2, e2]) => s2 <= start && end <= e2 && (s2 !== start || e2 !== end))) continue; const inner = text.slice(start + 1, end - 1); const visible = visibleLength(inner); if (visible < 1 || visible > QUOTE_EMPHASIS_MAX_VISIBLE) continue; if (/[。!?!?…,,;;::—]|\.{2,}/.test(inner)) continue; // 含句读/省略/破折的是台词或播报,不是强调 const before = text.slice(Math.max(0, start - 8), start); const after = text.slice(end, end + 6); if (QUOTE_EMPHASIS_SPEECH_VERB_PATTERN.test(before) || QUOTE_EMPHASIS_SPEECH_VERB_PATTERN.test(after)) continue; // 引语动词邻接=极短台词 if (/^(?:的|地)?一?[声下响]/.test(after)) continue; // 「“唰”的一声」类拟声词不是强调滥用 hits += 1; if (firstLine === null) firstLine = lineNo; if (samples.length < 6 && !samples.includes(inner)) samples.push(inner); } } if (hits < QUOTE_EMPHASIS_MIN_HITS) return []; return [{ line: firstLine, column: 1, type: 'quote-emphasis-tic', severity: 'advisory', message: `引号强调滥用:叙述里 1-4 字短词加引号强调 ${hits} 处;只留真正反讽/转述必要的一两处,其余去掉引号直写原意,或把话里的反讽直接点明。`, excerpt: compact(samples.join(' ')), }]; } // 否定对偶:统计引号外叙述里「没A,也没B」式句子,全文只报一条。 function findNegationPairTic(proseLines) { let hits = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed); NEGATION_PAIR_PATTERN.lastIndex = 0; let match; while ((match = NEGATION_PAIR_PATTERN.exec(narrative)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; if (samples.length < 4) samples.push(match[0]); } } if (hits < NEGATION_PAIR_MIN_HITS) return []; return [{ line: firstLine, column: 1, type: 'negation-pair-tic', severity: 'advisory', message: `否定对偶偏多:「没A,也没B」式叙述 ${hits} 处;写人物没做什么是英文式节奏,改成他做了什么(留一两处真正要强调的)。`, excerpt: compact(samples.join(' | ')), }]; } function findEllipsisDensityTic(proseLines) { let hits = 0; let narrativeChars = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed).replace(/[“「『"][^”」』"]*$/, ''); narrativeChars += visibleLength(narrative); ELLIPSIS_DENSITY_PATTERN.lastIndex = 0; let match; while ((match = ELLIPSIS_DENSITY_PATTERN.exec(narrative)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; const sample = sentenceAround(narrative, match.index); if (samples.length < 5 && sample && !samples.includes(sample)) samples.push(sample); } } if (narrativeChars === 0 || hits < ELLIPSIS_DENSITY_MIN_HITS) return []; const perKilo = (hits / narrativeChars) * 1000; if (perKilo < ELLIPSIS_DENSITY_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'ellipsis-density-tic', severity: 'advisory', message: `叙述省略号过密:引号与面板外省略号 ${hits} 处(${perKilo.toFixed(1)}/千字);保留关键思绪留白,其余改成逗号承接、直白判断或具体动作,别几句一刷。`, excerpt: compact(samples.join(' | ')), }]; } // 微动作复读:统计引号外叙述里「了X量词」轻量补语的密度。次数与每千字密度双门槛, // 全文只报一条(这是分布级指纹,不是逐处问题)。 function findMicroActionTic(proseLines) { let hits = 0; let narrativeChars = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed); narrativeChars += visibleLength(narrative); MICRO_TIC_PATTERN.lastIndex = 0; let match; while ((match = MICRO_TIC_PATTERN.exec(narrative)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; if (samples.length < 6 && !samples.includes(match[0])) samples.push(match[0]); } } if (narrativeChars === 0 || hits < MICRO_TIC_MIN_HITS) return []; const perKilo = (hits / narrativeChars) * 1000; if (perKilo < MICRO_TIC_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'micro-action-tic', severity: 'advisory', message: `微动作复读:「了下/了一下」式轻量补语 ${hits} 处(${perKilo.toFixed(1)}/千字);同一反应模板高密度复现是机械指纹,合并动作 beat、换具体细节,别每个动作都补一个轻反应尾巴。`, excerpt: compact(samples.join(' ')), }]; } // 套式反应细节:统计引号外叙述中通用的部位/声线反应与固定语气比喻。 // 这是删除测试的候选集,不是身体描写黑名单;全篇只报一条,保留有动作后果、 // 伤势、人物习惯或情节功能的细节。 function findStockReactionTic(proseLines) { let hits = 0; let narrativeChars = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed); narrativeChars += visibleLength(narrative); for (const pattern of STOCK_REACTION_PATTERNS) { pattern.lastIndex = 0; let match; while ((match = pattern.exec(narrative)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; const sample = sentenceAround(narrative, match.index); if (samples.length < 6 && sample && !samples.includes(sample)) samples.push(sample); } } } if (narrativeChars === 0 || hits < STOCK_REACTION_MIN_HITS) return []; const perKilo = (hits / narrativeChars) * 1000; if (perKilo < STOCK_REACTION_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'stock-reaction-tic', severity: 'advisory', message: `套式反应细节:指尖/指腹/喉结/眼圈/拢住按住/视线停顿等套式微动作或“平静得像在念”式语气比喻 ${hits} 处(${perKilo.toFixed(1)}/千字);逐处做删除测试,只标注情绪、不改变选择、关系或物理结果的直接删掉,或改成直白情绪与利害判断,不要换部位或换道具继续演。`, excerpt: compact(samples.join(' | ')), }]; } function findActionListTic(proseLines) { const findings = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed).trim(); if (!narrative) continue; ACTION_LIST_VERB_PATTERN.lastIndex = 0; const verbs = []; let match; while ((match = ACTION_LIST_VERB_PATTERN.exec(narrative)) !== null) { verbs.push(match[0]); } if (verbs.length < ACTION_LIST_MIN_HITS) continue; const separators = (narrative.match(/[,、;;]/g) || []).length; if (separators < ACTION_LIST_MIN_SEPARATORS) continue; findings.push({ line: lineNo, column: 1, type: 'action-list-tic', severity: 'advisory', message: `监控摄像头式动作清单:同段连续动作动词 ${verbs.length} 个、分隔符 ${separators} 个;合并琐碎步骤,只保留有情绪/情节功能的动作,必要时用角色犹豫、误判或环境反馈做缓冲。`, excerpt: compact(verbs.slice(0, 8).join(' ')), }); } return findings; } // 套词密度:统计引号外叙述中的高危禁用词聚集。不是逐词替换器;只在密度高到 // 形成模板腔时提示,修法是删总结、换具体动作/物件/对话,不是同义词轮换。 function findClicheDensityTic(proseLines) { let hits = 0; let narrativeChars = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed); narrativeChars += visibleLength(narrative); for (const pattern of CLICHE_PATTERNS) { pattern.lastIndex = 0; let match; while ((match = pattern.exec(narrative)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; if (samples.length < 8 && !samples.includes(match[0])) samples.push(match[0]); } } } if (narrativeChars === 0 || hits < CLICHE_DENSITY_MIN_HITS) return []; const perKilo = (hits / narrativeChars) * 1000; if (perKilo < CLICHE_DENSITY_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'cliche-density-tic', severity: 'advisory', message: `套词密度过高:高危 AI 套词 ${hits} 处(${perKilo.toFixed(1)}/千字);不要同义词轮换,直接删或改成直白情绪、角色利害判断、对话或具体后果,别硬塞手眼小动作。`, excerpt: compact(samples.join(' ')), }]; } // 比喻密度:统计引号外叙述中“像/好像/仿佛/如同”等比喻标记。 // 单个比喻不是问题;高密度成片时才提示,避免把文本改成另一种修辞模板。 function findMetaphorDensityTic(proseLines) { let hits = 0; let narrativeChars = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed); narrativeChars += visibleLength(narrative); METAPHOR_MARKER_PATTERN.lastIndex = 0; let match; while ((match = METAPHOR_MARKER_PATTERN.exec(narrative)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; const sample = sentenceAround(narrative, match.index); if (samples.length < 6 && sample && !samples.includes(sample)) samples.push(sample); } METAPHOR_LIKE_PHRASE_PATTERN.lastIndex = 0; while ((match = METAPHOR_LIKE_PHRASE_PATTERN.exec(narrative)) !== null) { const prefix = narrative.slice(Math.max(0, match.index - 8), match.index); if (/好像|像是|像|仿佛|宛如|如同|犹如/.test(prefix)) continue; hits += 1; if (firstLine === null) firstLine = lineNo; const sample = sentenceAround(narrative, match.index); if (samples.length < 6 && sample && !samples.includes(sample)) samples.push(sample); } } if (narrativeChars === 0 || hits < METAPHOR_DENSITY_MIN_HITS) return []; const perKilo = (hits / narrativeChars) * 1000; if (perKilo < METAPHOR_DENSITY_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'metaphor-density-tic', severity: 'advisory', message: `比喻密度过高:像/好像/仿佛/如同等比喻标记 ${hits} 处(${perKilo.toFixed(1)}/千字);保留最有叙事功能的少数比喻,其余回到直白情绪、角色判断、对话或具体后果,不要换成新比喻或小动作。`, excerpt: compact(samples.join(' | ')), }]; } // 解释链密度:统计引号外叙述中“知道/明白/这意味着/必须需要”等论文式推导链。 // 角色正常算利害、讲因果保留;同一行内去重重叠区间,且至少出现 3 处连接词/情态推导链才报。 function findReasoningChainTic(proseLines) { let hits = 0; let coreHits = 0; let linkHits = 0; let narrativeChars = 0; let firstLine = null; const samples = []; const buckets = new Set(); for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed); narrativeChars += visibleLength(narrative); const acceptedSpans = []; for (const { pattern, key, core } of REASONING_CHAIN_PATTERNS) { pattern.lastIndex = 0; let match; while ((match = pattern.exec(narrative)) !== null) { const start = match.index; const end = start + match[0].length; if (acceptedSpans.some(([a, b]) => start < b && end > a)) continue; acceptedSpans.push([start, end]); hits += 1; if (core) coreHits += 1; if (key === 'connector' || key === 'modal') linkHits += 1; buckets.add(key); if (firstLine === null) firstLine = lineNo; const sample = compact(match[0]); if (samples.length < 8 && !samples.includes(sample)) samples.push(sample); } } } if (narrativeChars === 0 || hits < REASONING_CHAIN_MIN_HITS) return []; if (coreHits < REASONING_CHAIN_CORE_MIN_HITS || buckets.size < REASONING_CHAIN_MIN_BUCKETS) return []; if (linkHits < REASONING_CHAIN_MIN_LINKS) return []; const perKilo = (hits / narrativeChars) * 1000; if (perKilo < REASONING_CHAIN_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'reasoning-chain-tic', severity: 'advisory', message: `解释链密度过高:知道/明白/这意味着/必须/需要等论文式推导 ${hits} 处(${perKilo.toFixed(1)}/千字);删掉“这意味着/按照这个逻辑”式公文腔,保留角色自己的利害算账与因果判断,或落到对话与选择后果,别全改成手眼小动作。`, excerpt: compact(samples.join(' | ')), }]; } // 系统/规则行如果连续像 API 文档或政府公文,读者容易闻到机器味。 // 修法不是删除规则,而是保留功能后把一部分硬词改成白话或具体后果。 function findNoticeFormalityTic(proseLines) { let hits = 0; let noticeChars = 0; let noticeLines = 0; let coreHits = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!/^【[^】]+】$/.test(trimmed)) continue; noticeLines += 1; noticeChars += visibleLength(trimmed); NOTICE_FORMAL_CORE_PATTERN.lastIndex = 0; while (NOTICE_FORMAL_CORE_PATTERN.exec(trimmed) !== null) coreHits += 1; for (const pattern of NOTICE_FORMAL_PATTERNS) { pattern.lastIndex = 0; let match; while ((match = pattern.exec(trimmed)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; const sample = compact(match[0]); if (samples.length < 8 && !samples.includes(sample)) samples.push(sample); } } } if (noticeLines < NOTICE_FORMAL_MIN_LINES || noticeChars === 0 || hits < NOTICE_FORMAL_MIN_HITS || coreHits < NOTICE_FORMAL_CORE_MIN_HITS) return []; const perKilo = (hits / noticeChars) * 1000; if (perKilo < NOTICE_FORMAL_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'system-notice-formality-tic', severity: 'advisory', message: `系统公告公文腔过密:方括号规则行中硬规则词 ${hits} 处(${perKilo.toFixed(1)}/千字);保留为角色看见的屏幕/公告/规则载体,只在载体内部白话化部分硬词,或补角色当场看懂的具体后果,不改成叙述者解释。`, excerpt: compact(samples.join(' | ')), }]; } // 长文本整体过于“精炼”:短段很多、自然连接偏少,读起来像处理过的梗概/分镜表。 // 修法是通读后补断裂处,不是为凑阈值全局加“的/了/就”。 function findOvercompressedProseTic(proseLines) { let narrativeChars = 0; let narrativeParas = 0; let shortParas = 0; let particles = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed) || /^【[^】]+】$/.test(trimmed)) continue; const narrative = stripQuoted(trimmed).trim(); const len = visibleLength(narrative); if (len === 0) continue; if (firstLine === null) firstLine = lineNo; narrativeParas += 1; narrativeChars += len; if (len <= OVERCOMPRESSED_PROSE_SHORT_MAX_CHARS) { shortParas += 1; if (samples.length < 6) samples.push(narrative); } OVERCOMPRESSED_PROSE_PARTICLE_PATTERN.lastIndex = 0; while (OVERCOMPRESSED_PROSE_PARTICLE_PATTERN.exec(narrative) !== null) particles += 1; } if (narrativeChars < OVERCOMPRESSED_PROSE_MIN_CHARS || narrativeParas < OVERCOMPRESSED_PROSE_MIN_PARAS) return []; const shortRatio = shortParas / narrativeParas; if (shortRatio < OVERCOMPRESSED_PROSE_SHORT_RATIO) return []; const particlePerKilo = (particles / narrativeChars) * 1000; if (particlePerKilo >= OVERCOMPRESSED_PROSE_PARTICLE_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'overcompressed-prose-tic', severity: 'advisory', message: `过度精炼短段:叙述段 ${narrativeParas} 个,其中 ${shortParas} 个≤${OVERCOMPRESSED_PROSE_SHORT_MAX_CHARS}字(${(shortRatio * 100).toFixed(0)}%),自然连接 ${particlePerKilo.toFixed(1)}/千字偏少;先通读判断,确有提纲感再补断裂处和必要结构虚词,有意短镜头可留,别机械注水。`, excerpt: compact(samples.join(' | ')), }]; } // 低连接密度:长文本/中短窗口里,引号外叙述的功能词和白话连接同时偏低,且缺少中长承接句, // 会呈现“提纲/电报体”分布。修法是恢复必要连接和句群,不是全局补词。 function findLowConnectiveDensityTic(proseLines) { let bodyChars = 0; let functionHits = 0; let plainHits = 0; let firstLine = null; const sentences = []; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; // 只看引号外叙述。台词/弹幕/系统播报可以天然短促,混入统计会把体裁特征误当电报体。 const narrative = stripQuoted(trimmed).trim(); const narrativeLen = visibleLength(narrative); if (narrativeLen === 0) continue; if (firstLine === null) firstLine = lineNo; bodyChars += narrativeLen; functionHits += countTerms(narrative, LOW_CONNECTIVE_FUNCTION_TERMS); plainHits += countTerms(narrative, LOW_CONNECTIVE_PLAIN_TERMS); for (const sentence of splitSentences(narrative)) { const len = visibleLength(sentence); if (len === 0) continue; sentences.push(len); if (len <= 12 && samples.length < 6) samples.push(sentence); } } if (bodyChars < LOW_CONNECTIVE_MIN_CHARS || sentences.length === 0) return []; const functionPerKilo = (functionHits / bodyChars) * 1000; if (functionPerKilo >= LOW_CONNECTIVE_FUNCTION_PER_KILO) return []; const plainPerKilo = (plainHits / bodyChars) * 1000; if (plainPerKilo >= LOW_CONNECTIVE_PLAIN_PER_KILO) return []; const longSentenceRatio = sentences.filter((len) => len >= LOW_CONNECTIVE_LONG_SENTENCE_CHARS).length / sentences.length; if (longSentenceRatio >= LOW_CONNECTIVE_LONG_SENTENCE_RATIO) return []; return [{ line: firstLine, column: 1, type: 'low-connective-density-tic', severity: 'advisory', message: `低连接密度:引号外叙述功能词 ${functionPerKilo.toFixed(1)}/千字、白话连接 ${plainPerKilo.toFixed(1)}/千字,且≥${LOW_CONNECTIVE_LONG_SENTENCE_CHARS}字承接句仅 ${(longSentenceRatio * 100).toFixed(0)}%;容易像提纲/电报体。通读后补必要连接和中长句群,别机械注水。`, excerpt: compact(samples.join(' | ')), }]; } // 抽象总结复读:统计引号外叙述中的高抽象收束模板。全篇只报一条,提醒回到角色 // 当下可见的文件、动作、对话或物理后果;不要用命运大词替读者总结。 function findAbstractSummaryTic(proseLines) { let hits = 0; let narrativeChars = 0; let firstLine = null; const samples = []; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed || isDivider(trimmed) || isStructural(trimmed)) continue; const narrative = stripQuoted(trimmed); narrativeChars += visibleLength(narrative); for (const pattern of ABSTRACT_SUMMARY_PATTERNS) { pattern.lastIndex = 0; let match; while ((match = pattern.exec(narrative)) !== null) { hits += 1; if (firstLine === null) firstLine = lineNo; const sample = compact(match[0]); if (samples.length < 6 && !samples.includes(sample)) samples.push(sample); } } } if (narrativeChars === 0 || hits < ABSTRACT_SUMMARY_MIN_HITS) return []; const perKilo = (hits / narrativeChars) * 1000; if (perKilo < ABSTRACT_SUMMARY_PER_KILO) return []; return [{ line: firstLine, column: 1, type: 'abstract-summary-tic', severity: 'advisory', message: `抽象总结复读:命运/棋局/这一刻终于明白/才刚刚开始等作者总结 ${hits} 处(${perKilo.toFixed(1)}/千字);删掉作者盖章,回到角色当下的具体处境、利害盘算、对话或实际后果,别拿微动作顶替。`, excerpt: compact(samples.join(' | ')), }]; } function findPeriodStutter(proseLines) { const findings = []; let runLen = 0; let runStartLine = null; let runSample = []; const flush = () => { if (runLen >= STUTTER_MIN_RUN) { findings.push({ line: runStartLine, column: 1, type: 'period-stutter', severity: 'advisory', message: `碎句号:连续 ${runLen} 个短句无呼吸;按目标句长把碎句合并成中长句、补回画面与连接(见本 skill 句长/疏密节奏规则)。`, excerpt: compact(runSample.join(' ')), }); } runLen = 0; runStartLine = null; runSample = []; }; for (const { text, lineNo } of proseLines) { const trimmed = text.trim(); if (!trimmed) continue; // 空行是一句一段排版,不打断叙述连贯 if (isDivider(trimmed) || isStructural(trimmed)) { flush(); // 分隔线/markdown 结构行:重置碎句计数 continue; } const narrative = stripQuoted(trimmed); if (visibleLength(narrative) === 0) { flush(); // 纯对话/弹幕/系统播报:成片短句是正常形态,重置碎句计数 continue; } // 只数引号外叙述句:混合行(叙述+引号内物件/短台词)的引号外片段仍参与碎句计数。 for (const sentence of splitSentences(narrative)) { if (visibleLength(sentence) <= STUTTER_MAX_SENTENCE) { if (runLen === 0) runStartLine = lineNo; runLen += 1; if (runSample.length < 6) runSample.push(sentence); } else { flush(); } } } flush(); return findings; } function isDivider(trimmed) { return /^-{3,}$/.test(trimmed) || /^[*_]{3,}$/.test(trimmed); } // markdown 结构行(标题/列表/引用/表格)不是叙述正文,长段落/碎句号/破折号检测都跳过。 function isStructural(trimmed) { return /^(#{1,6}(?:\s|\d)|>\s?|[-*+]\s|\d+[.)]\s|\|)/.test(trimmed) || /^第[零〇一二三四五六七八九十百千万两\d]+[章节回](?:$|[\s_::——\-]+[^\n。;;]{0,28}$)/.test(trimmed); } // 去掉成对引号内的片段(台词/系统播报),只留引号外叙述。碎句号判定用:纯对话/弹幕成片短句 // 是体裁正常形态(豁免),但「叙述 + 引号内物件/短台词」混合行的引号外叙述仍要参与短句计数。 function stripQuoted(text) { let out = text; for (const src of QUOTE_SOURCES) out = out.replace(new RegExp(src, 'g'), ''); return out; } // 把成对引号片段(含引号)替换为等长问号占位:既豁免引号内台词/播报,又保住原文 // 偏移量,供逐处 blocking 规则定位与截取原文摘录(stripQuoted 会移位,不适合定位)。 // 占位字符用「?」而不是「。」:占位既要截断各规则的 [^。!?!?…] 否定类(?与句号在每条 // 规则的否定类里等效),又不能落在任何规则的接受位。句号占位会替 trailer-summary 的句末 // [。!] 伪造出终止符,让「这一战注定是「血屠」的开端,…」这类引号里放代号/绰号的叙述行 // 被误报,且报出的『这一战注定是。』在原文里 grep 不到。占位长度不变,故偏移与摘录窗口不漂移。 function maskQuoted(text) { let out = text; for (const src of QUOTE_SOURCES) { out = out.replace(new RegExp(src, 'g'), (m) => '?'.repeat(m.length)); } return out; } // 与 normalize-punctuation.js 的 quoteSpans 对齐:闭合引号/面板先等长占位,行末未收口的开引号 // (如 `他猛地抬头:“你敢——` 或 `"等等——`)算到行尾,同时保留开引号前的旁白文本参与扫描。 function maskQuotedWithUnclosed(text) { const out = maskQuoted(text); const unclosed = /[“「『"]/.exec(out); if (!unclosed) return out; return out.slice(0, unclosed.index) + '?'.repeat(out.length - unclosed.index); } // 返回引号内片段(含引号本身)的 [start, end) 区间,供 not-is 对比句豁免台词用。 function quotedRanges(text) { const ranges = []; for (const src of QUOTE_SOURCES) { const re = new RegExp(src, 'g'); let match; while ((match = re.exec(text)) !== null) ranges.push([match.index, match.index + match[0].length]); } return ranges; } function insideRanges(pos, ranges) { return ranges.some(([start, end]) => pos >= start && pos < end); } function splitSentences(trimmed) { return trimmed .split(/[。!?!?]/) .map((s) => s.trim()) .filter(Boolean); } function sentenceAround(text, index) { let start = index; while (start > 0 && !STOP_CHARS.has(text[start - 1])) start -= 1; let end = index; while (end < text.length && !STOP_CHARS.has(text[end])) end += 1; return compact(text.slice(start, end).trim()); } function visibleLength(sentence) { const matched = sentence.match(/[一-鿿A-zA-Za-z0-9]/g); return matched ? matched.length : 0; } function countTerms(text, terms) { let count = 0; for (const term of terms) { let index = text.indexOf(term); while (index !== -1) { count += 1; index = text.indexOf(term, index + term.length); } } return count; } // 把行内 HTML 注释(含 `` 本身)换成等长空格;openBefore 表示上一行留下未闭合注释。 // unclosedOpenings 里的 `', cursor); const end = close === -1 ? line.length : close + 3; out += ' '.repeat(end - cursor); cursor = end; if (close !== -1) open = false; continue; } const start = line.indexOf('