[!IMPORTANT] This file isMain router entry + Pipeline B/C definitions + typesetting format specification library. For detailed specifications of Pipeline A (OCR pipeline), please refer to
ocr_kb/SKILL.md. DOCX generation for all pipelines usesdocx/SKILL.mdthe methods defined in (docx-js to create a new document / unpack-edit-pack to edit an existing document).
0. Directory Convention
[!IMPORTANT] All intermediate files and generated outputs must strictly follow the directory structure below,placing any generated files in the project root directory is prohibited(including
.md、.py、.docx, etc.).
项目根目录/
├── resources/
│ ├── pages/ # Pipeline A: 切分出的单页 PNG 图片
│ ├── figures/ # 所有管道: 配图(裁剪的或提取的)
│ ├── md/ # 所有管道: 提取/拆分结果
│ │ ├── page_N.md # Pipeline A 按页
│ │ └── section_N.md # Pipeline B/C 按章节
│ ├── scripts/ # 所有 Python 辅助脚本(可跨任务复用,清理时不删除)
│ ├── compiled_paper.md # 最终汇总的完整 Markdown
│ ├── config.json # 任务配置(源文件、格式、管道类型),整个任务期间不变
│ └── checkpoint.json # 运行时进度(当前单元、计数器、失败项),随处理进度更新
├── outputs/ # 最终交付的 .docx / .bib 文件 + 核查点中间版本
├── ocr_kb/ # Pipeline A: OCR 工作流 Skill
│ └── SKILL.md
├── docx/ # Word 文档操作 Skill(DOCX 生成的技术实现基础)
│ └── SKILL.md
├── pdf/ # PDF 操作 Skill
│ └── SKILL.md
├── content_generation/ # Pipeline D: 论文内容智能生成 Skill
│ └── SKILL.md
├── SKILL.md # 本文件(主入口路由 + Pipeline B/C + 排版规范库)
└── <source>.* # 用户提供的原始文件 (.pdf / .doc / .docx / .md / 项目代码目录)
1. New Task Startup Protocol (Step 0: Pre-flight)
[!CAUTION] The following four checks must be performedanybefore any writing or typesetting actionall completed, and cannot be skipped.
1.0 Skill Version Check & Auto Update
Each time processing is started, the user's local skill version must first be compared with the current latest version:
- Run the corresponding command (such as
git fetch origin && git status -uno) to detect the local repository status. - If the local version is inconsistent with the latest version: you should proactively prompt and help the user update automatically:
"Detected that the
academic-paper-writer-proskill has a latest version. Would you like help updating automatically? Reply update to upgrade, or skip to continue the current task." - If the user chooses to update, automatically execute the update command (such as
git pullornpx skills add https://github.com/tfboy1/academic-paper-writer --skill academic-paper-writer-pro), and proceed to the next step after the update is complete.
1.1 Environment Cleanup Confirmation
Detect whether old files exist under resources/ in pages/、md/、figures/ as well as resources/checkpoint.json .
- If old files exist: list the file inventory and explicitly ask the user:
"Detected intermediate files from the previous task (N pages/chapters, M Markdown files, K figures). Delete them to avoid interference? Reply delete to clear, or keep to continue the previous task."
- If old files do not exist: skip this step.
- When the user chooses "delete": delete
resources/pages/*、resources/md/*、resources/figures/*、resources/checkpoint.json、resources/config.json。resources/scripts/do not delete(scripts can be reused). - When the user chooses "keep": read
resources/checkpoint.json, and enter the breakpoint recovery process (see §1.3).
1.2 Source File Confirmation and Pipeline Selection
Scan all supported format files in the project root directory (.pdf、.doc、.docx、.md):
- only 1: automatically selected, and the pipeline is determined based on the extension.
- multiple: List all file names, types, and sizes, and require the user to explicitly specify the target file.
- None: Error, require the user to place the source file.
Pipeline auto-selection rules:
| Extension | Pipeline | Progress unit | Core Skill |
|---|---|---|---|
.pdf |
Pipeline A — OCR pipeline | page | ocr_kb/SKILL.md |
.doc / .docx |
Pipeline B — Re-layout pipeline | section | docx/SKILL.md + this file §3.2 |
.md |
Pipeline C — MD direct conversion pipeline | section | docx/SKILL.md + this file §3.3 |
| None / directory | Pipeline D — Content generation pipeline | section | content_generation/SKILL.md |
1.3 Checkpoint recovery detection
Check whether resources/checkpoint.json exists and is valid:
- exists and
status == "suspended": Show the user the previous progress (number of completed units / total units, pipeline type), and ask:"A previous task was detected (Pipeline X, N/M units completed). Continue from the checkpoint? Reply continue to start from unit N+1, or restart to clear all intermediate files."
- does not exist or
status == "completed": Start a new task normally.
2. File integrity check and resource preparation
2.1 File integrity check
Require the user to place the manuscript to be formatted and the formatting requirements in this directory:
- Draft: The user's content file (
.pdf、.doc、.docxor.md)。 - Style Guide/Template:
.docxtemplate or.pdfguide (such as an IEEE template). - References: Ask the user whether they have a
.bibfile. If so,must be used first。
2.2 Format specification parsing (required for all pipelines)
[!IMPORTANT] Before splitting content or extracting text,format specification parsing must be completed first, to determine all layout parameters.
-
If the user provided a
.docxtemplate(config.template_fileis non-empty):- Use
docx/SKILL.md's unpack method to open the template - Extract style definitions (heading levels, body font/font size, line spacing, margins, headers and footers, column settings)
- Record the extracted parameters in
config.json'sformat_paramsfield
- Use
-
If the user specified a format name(such as "IEEE", "APA"):
- From this file's §6 Layout format specification library , read the corresponding preset parameters
- Record the parameters in
config.json'sformat_paramsfield
-
If both are present: The template takes priority, with preset parameters as a fallback.
2.3 Resource directory preparation
Ensure that resources/(including subdirectories pages/、md/、figures/、scripts/) and outputs/ exist; create them automatically if they do not exist.
2.4 Task configuration persistence
Create or read resources/config.json(for detailed format, see ocr_kb/SKILL.md §0.5), record the source file path, file type, pipeline type, format specification, and typesetting parameters, so that subsequent continuations do not need to specify them again.
3. Core processing flow (dispatched by pipeline)
3.1 Pipeline A — OCR pipeline (PDF input)
[!IMPORTANT] All detailed specifications of Pipeline AAll detailed specificationsare defined in
ocr_kb/SKILL.md. This section only provides a high-level description.
- Image splitting: run
resources/scripts/split_pdf.pyto split the PDF into single-page PNGs. - Page-by-page loop: according to the specifications in
ocr_kb/SKILL.md, extract page by page + append DOI to DOCX page by page. - Verification and suspension: verify every 2 pages, suspend every 4 pages.
- Consolidate and finalize: merge all
page_N.md→compiled_paper.md→ final DOCX.
DOCX generation method: use docx/SKILL.md to create a new document with docx-js, and configure styles according to the parameters in the §6 format specification library.
3.2 Pipeline B — Re-layout pipeline (.doc / .docx input)
Applicable scenario: the user already has a Word document and needs lossless layout according to a new format specification (such as IEEE). To absolutely preserve the original native complex formulas (OMML), charts, and comments, this pipelinestrictly prohibitsthe use of a Markdown intermediate extraction scheme, and must use low-level XML appearance translation (Unpack-Edit-Pack).
Step 1: Format conversion (.doc only)
If the input is .doc(legacy format), first convert it to .docx:
python docx/scripts/office/soffice.py --headless --convert-to docx <input.doc>
Step 2: Unpack and extract specifications
- Parse the target format parameters according to §2.2.
- Extract the input DOCX to the native XML directory:
python docx/scripts/office/unpack.py <input.docx> resources/unpacked/
Step 3: XML-level style restructuring (Edit XML)
This step does not touch the logic of the main content. Write a local script to directly “reskin” from the low level:
- Replace Styles (
word/styles.xml): for the format specification (such as IEEE), forcibly replace all core styles instyles.xmlwith preset style names and fonts. - Force set
<w:sectPr>: inword/document.xml, locate the section configuration block, and forcibly mount the two-column setting (such as<w:cols w:num="2" w:space="360"/>) and the required paper size (such as US Letter:<w:pgSz w:w="12240" w:h="15840"/>)。 - Rebind
<w:pStyle>: traverse all<w:p>, determine their hierarchy level by text features or the weight of the old style, and mount them as IEEE-standardHeading1、Normal. This ensures that the formula structures encapsulated in paragraphs at the same level are never touched<m:oMath>。
Step 4: Package and finalize in original form (Pack)
Seamlessly package and verify the reconstructed appearance:
python docx/scripts/office/pack.py resources/unpacked/ outputs/<name>_final_<date>.docx --original <input.docx>
This completely abandons the high-risk Markdown intermediate generation method, achieving 100% lossless preservation of content and layout!
3.3 Pipeline C — MD direct conversion pipeline (.md input)
[!CAUTION] It is absolutely forbidden to use Pandoc for one-click direct conversion from Markdown to Word! Pandoc will lose all highly customized formats required for Chinese degree theses or top conferences (such as three-line table rendering, strong first-line indent binding, etc.). It must and can only strictly call the
docx/SKILL.mddefined indocx-js(Node engine) or the low-levelunpack -> edit XML -> packscript.
Applicable scenario: The user already has a paper in Markdown format and needs to convert it to a formatted Word document.
Step 1: Format specification parsing
Parse the target format specification according to §2.2 and determine all typesetting parameters.
Step 2: Chapter splitting
- Read the
.mdfile, split byLevel 1 heading(# ...) into multiple chapters. - Save each chapter as
resources/md/section_N.md。 - Count the total number of chapters.
- Create
resources/config.json(pipeline: "C",unit_type: "section")。 - Create
resources/checkpoint.json(current_unit: 1, reset the counter to zero).
Step 3: High-definition pre-rendering and self-healing of Mermaid architecture diagrams (critical)
If the Markdown contains mermaid code blocks, before injecting into Word, an independent high-definition rendering pipeline must be executed:
- Extract and save: Save the Mermaid code block as an independent
resources/figures/fig_N.mmdfile. - Mount environment interceptor: Limited by Windows' strict process penetration policy, it is necessary to dynamically generate in the root directory
puppeteer-config.json(content:{"args": ["--no-sandbox", "--disable-setuid-sandbox"]})。 - Call CLI to compile: Execute the command
npx mmdc -i resources/figures/fig_N.mmd -o resources/figures/fig_N.png -b transparent -p puppeteer-config.json。 - Compilation fault-tolerant self-healing (Auto-healing): If mmdc throws an error (often caused by non-rigorous syntax such as spaces in subgraph names, brackets/single or double quotes in state scalars, etc.),The Agent must capture the error log and proactively use Python or regular expressions to fix
.mmdincomplete syntax in the text, then retry the compilation command until the high-definition.pngis successfully produced. It is strictly forbidden to silently skip or leave garbled characters at this step! - DOM placeholder replacement: Replace all complex Mermaid blocks in the original Markdown with standard image reference syntax
, so that they can be natively embedded in the next step.
Step 4: Chapter-by-chapter conversion and typesetting
Use docx/SKILL.md docx-js to create a new DOCX document (all styles must be mapped through code!), configure the styles according to the format parameters in §6, and then convert the content chapter by chapter:
- Formula conversion:
- Inline formula
$...$→ native OMML (viaocr_kb/scripts/latex_to_omml.py, see the interface inocr_kb/SKILL.md§0.7) - Display formula
$$...$$→ OMML formula paragraph, with the number right-aligned - Update
checkpoint.jsontheglobal_equation_count
- Inline formula
- Table conversion:
- Markdown table → Word table XML (according to the table typesetting parameters in §5.3 +
docx/SKILL.mdTables chapter,Force output of academic three-line tables) - Update
global_table_count
- Markdown table → Word table XML (according to the table typesetting parameters in §5.3 +
- Image embedding:
→ Check whether the image file exists- Copy the image to
resources/figures/(if not already there), globally number - Embed into DOCX according to the image typesetting parameters in §5.2
- Update
global_figure_count
- Text typesetting:
- Heading level mapping (
#→ Heading 1,##→ Heading 2,...) - Apply font, font size, paragraph spacing, and alignment according to the format parameters in §6.In particular, precise control of the first-line paragraph indent (2 characters)。
- Heading level mapping (
- Append to the output DOCX.
- Update
checkpoint.json。
Step 5: Verification and context protection
- Exactly the same as Pipeline B (check every 2 chapters, suspend every 4 chapters).
- Add physical interception: if it is detected that table data and sufficient page capacity were not generated as required, discard the generated docx.
Step 6: Consolidate and finalize
- All
section_N.mdwere created during splitting, merged intoresources/compiled_paper.md。 - The final DOCX is saved as
outputs/<name>_final_<date>.docx。
3.4 Pipeline D — Content Generation Pipeline (Project Records/Code Input)
Applicable scenario: the user does not have a complete paper draft, only code, experimental data, or notes, and wants to intelligently generate an academic-format paper draft based on existing project materials.
For detailed operating specifications, see content_generation/SKILL.md, main process overview:
- Analyze the various technical materials provided by the user, extract and confirm the overall outline structure of the paper with the user.
- Build high-quality academic text by section-by-section autoregressive generation, saved to
resources/md/section_N.md。 - After generation is complete, the system automatically routes it to Pipeline C (MD direct conversion pipeline), reusing its typesetting capabilities to output the final style.
3.5 Common Rules for All Pipelines
The following rules apply regardless of pipeline and aremandatory:
| Rule | Description |
|---|---|
| Process unit by unit | Whether it is a page or a chapter, each time a unit is completed, append it to the DOCX and update the checkpoint |
| Check every 2 units | Compare against the source file to confirm there is no information loss or formatting corruption |
| Suspend every 4 units | Save an intermediate version and notify the user to send "continue" to refresh the context |
| needs_review zero-clearance gate | Before final consolidation,needs_review must be empty |
| Retain intermediate versions | Checkpoint versions are not deleted, to allow rollback |
| Global numbering | The three counters figure / table / equation increment globally and are not reset across units |
4. Reference Management
- Priority: parse the
.bibfile provided by the user. - Supplement: if the user did not provide
.bib,Do not fabricate or search for references yourself. Mark all missing citations (list the citation marker names) and notify the user to supplement them manually. - Output: generate the reference file in
outputs/references.bib.
5. General Formatting Details (Cross-Pipeline Formatting Details)
[!IMPORTANT] The following details apply to all pipelines; specific parameters are overridden by the preset values in the §6 format specification library or by the user template. For the technical implementation of DOCX, uniformly refer to
docx/SKILL.md。
5.1 Template File Usage Process
When config.template_file is non-empty:
- Method 1 (recommended): use the unpack method of
docx/SKILL.mdto open the template, extract the style definitions inword/styles.xml, then copy these styles when creating a new document with docx-js. - Method 2: directly copy the template file as the output file, then replace the content using unpack → edit XML → pack, preserving all of the template's styles and page settings.
When config.template_file is empty:
- Use docx-js to create a brand-new document, and manually configure styles according to the preset parameters in the §6 format specification library.
5.2 Image Layout Parameters
| Parameter | Default Value | Description |
|---|---|---|
| Width Strategy | Scale proportionally to 80% of the column width | Single-column paper = page content width × 80%; double-column paper = column width × 95% |
| Position | Inline embedding, centered alignment | Do not use floating positioning |
| Caption Format | "Figure N: description text" | Below the figure, centered, 1pt smaller than the body text, bold the "Figure N" part |
| Spacing Between Caption and Body Text | 6pt above, 12pt below | |
| Image Quality | Original resolution, no compression |
docx-js Implementation Reference:docx/SKILL.md Images section (§220-232), note that type parameter is required,altText all three subfields are required.
5.3 Table Layout Parameters
| Parameter | Default Value | Description |
|---|---|---|
| Width | Full column width (DXA units) | Single-column = page content width; double-column = column width |
| Border | Thin line #CCCCCC,1pt |
|
| Header | Bold, light blue background #D5E8F0 |
Use ShadingType.CLEAR(do not use SOLID) |
| Cell Padding | 80 DXA top and bottom, 120 DXA left and right | |
| Table Note Format | "Table N: description text" | Above the table, centered, 1pt smaller than the body text |
docx-js Implementation Reference:docx/SKILL.md Tables section (§173-219), must set both columnWidths and each cell's width, and must use WidthType.DXA。
5.4 Headers, Footers, and Page Numbers
| Parameter | Default Value | Description |
|---|---|---|
| Page Number | Bottom center, Arabic numerals | |
| Header | Empty (unless required by the format specification) | IEEE has no header, theses usually do |
| Special First Page | No header or page number on the first page (if required by the format) |
docx-js Implementation Reference:docx/SKILL.md Headers/Footers section (§251-268), use PageNumber.CURRENT。
5.5 Column Layout
| Parameter | Default Value | Description |
|---|---|---|
| Number of Columns | Determined by the format specification (IEEE = 2 columns, APA = 1 column) | |
| Column Spacing | 360 DXA(0.25 inch) | |
| Title/Abstract | Usually spans columns (separated by section break) |
docx-js Implementation: through the sections property, set different sections to have different numbers of columns:
// 标题区域 - 单栏
{ properties: { column: { count: 1 } }, children: [/* 标题、作者、摘要 */] },
// 正文区域 - 双栏
{ properties: { column: { count: 2, space: 360 } }, children: [/* 正文 */] }
5.6 Formula Layout
| Parameter | Default Value | Description |
|---|---|---|
| Inline Formula | OMML <m:oMath>, on the same line as the body text |
|
| Display Formula | OMML <m:oMathPara>, centered |
|
| Formula Number | Right-aligned, format (N) |
|
| LaTeX → OMML | via ocr_kb/scripts/latex_to_omml.py |
docx-js / XML implementation reference:docx/SKILL.md Formulas (OMML) section (§447-469).
6. Format Style Library
[!IMPORTANT] Format presets are stored as separate
.mdfiles in thetemplates/directory, and each file contains a complete table of formatting parameters. When the user specifies a format name, read the corresponding file. If the user provides a.docxtemplate, the settings in the templateoverridethe presets.
6.1 Built-in Format Presets
| Format Name | File | Applicable Scenarios |
|---|---|---|
| IEEE | templates/ieee.md |
IEEE conference papers, journal papers |
| APA 7th Edition | templates/apa7.md |
Psychology, social science papers |
| Chinese degree theses | templates/chinese_thesis.md |
Domestic university bachelor's, master's, and doctoral degree theses |
| ACM | templates/acm.md |
ACM computer society conference and journal papers |
| Springer LNCS | templates/springer_lncs.md |
Academic monographs such as computer science lecture notes |
| NeurIPS | templates/nips.md |
NeurIPS and machine learning-related conferences |
| MLA | templates/mla.md |
Papers in the humanities and language and literature fields |
Lookup Rules:
- User says "format according to IEEE" → read
templates/ieee.md - User says "format according to APA" → read
templates/apa7.md - User says "format according to degree thesis" / "format according to graduation thesis" → read
templates/chinese_thesis.md - User says "format according to ACM" → read
templates/acm.md - User says "format according to Springer" / "format according to LNCS" → read
templates/springer_lncs.md - User says "format according to NeurIPS" / "format according to NIPS" → read
templates/nips.md - User says "format according to MLA" → read
templates/mla.md - No match → enter the §6.2 user-defined process
6.2 User-Defined Format
When the format specified by the user is not among the built-in presets:
- Ask the user to provide a
.docxtemplate or explicitly describe the formatting requirements. - Extract parameters from the template or description and fill in
config.json'sformat_params。 - If the user's description is incomplete, read
templates/ieee.mdas fallback default values for missing parameters.
6.3 Extending New Formats
If you need to add a new format preset (such as ACM, Springer LNCS, etc.), simply create a corresponding new templates/ in the .md directory and fill in the parameters according to the table structure of the existing template.
7. Summarize Output After Completion
After formatting is complete,mustoutput the following structured completion report:
【完成报告】
源文件:<config.source_file>
输入类型:<config.source_type>
处理管道:Pipeline <config.pipeline>
格式规范:<config.format_style>
总单元数:<checkpoint.total_units>(<config.unit_type>)
提取公式数:<checkpoint.global_equation_count>
裁剪/嵌入配图数:<checkpoint.global_figure_count>
提取/转换表格数:<checkpoint.global_table_count>
核查点版本数:<outputs/ 中 checkpoint 文件的数量>
最终文件:outputs/<最终文件名>.docx
遗留问题:<needs_review 中的单元编号 / 无>
Then proactively confirm the following optional value-added services with the user:
- Logical verification: check the argumentative logic between paragraphs.
8. Troubleshooting & Best Practices for Formatting and Environment
[!WARNING] When performing automatic formatting and document generation, Markdown parsing and underlying environment conflicts are often encountered. The following preventive specifications must be followed in the formatting pipeline:
8.1 Regex Stripping for Markdown Nested Bold Parsing
Problem:marked.lexer When processing complex nested paragraphs (such as bold **text**inside lists), because Inline-level tokensis not deeply recursively extracted by default, it is easy for ** symbols to leak directly into the DOCX output as plain punctuation text.
Specification: when constructing docx-js When the Paragraph text is mounted,completely abandon AST-based style markup matching, and uniformly switch to prefix custom regular expressions (e.g. text.split(/(\*\*[\s\S]*?\*\*)/g)) for explicit splitting, mapping them directly to new TextRun({ text: innerText, bold: true })。
8.2 Extreme Fragility of the Mermaid Compiler and Syntax Cleaning
Problem:npx mmdc : npx mmdc is extremely picky about generated code. For example, usecaseDiagram , is deprecated and unsupported in the new version, and in erDiagram , if an entity attribute is followed by an outside comment with a double quote " , it will directly cause the rendering thread to deadlock and the command line to crash.
Standard: Before invoking the execution environment, use a replacement script to clean non-compliant keywords (forcibly convert the old syntax to flowchart), and strictly remove dangerous quotes. To prevent Windows process isolation errors, the configuration file parameters need to mount {"args": ["--no-sandbox", "--disable-setuid-sandbox"]}。
8.3 Cross-platform Regular Expression Newline Character Trap (\r\n)
Problem: When using Regex for cross-platform operations to forcibly extract boundary-closed code blocks (e.g. /```mermaid\n([\s\S]*?)```/g), once a file written by a Windows host uses \r\n carriage return and line feed characters, the match will directly fail, causing large areas of lost images.
Standard: Whenever multi-line text cutting is involved, be sure to introduce the fault-tolerant wildcard \r?\n as the boundary detector, and never hard-code a single newline type.
8.4 Crash from Implicit Required Items of the DOCX-JS ImageRun Component
Problem: When calling ImageRun to insert a Buffer image stream engine, if the altText parameter nesting combination is omitted, the compilation pipeline will silently crash with no clear stack feedback (Packer throw catch unclear).
Standard:ImageRun : When initializing the object, be sure to fully complete and mount the three indispensable security metadata fields:altText: { title: "x", description: "x", name: "x" }, as well as statically specifying type: "png"。
8.5 Protection Against Operation Handle Lock (EBUSY) During Automated Updates
Problem:fs.writeFileSync : When intending to output and refresh the target document, if the document happens to be occupied within the user's browsing window process, it triggers EBUSY: resource busy or locked and blocks exit.
Standard: The export-side name of the automation script should dynamically concatenate an auto-incrementing numeric suffix or a dynamically flowing timestamp (e.g. _V3_CLEAN), so as to avoid the conflict disaster of forced overwrite locks at the system level.
9. Academic Integrity Gate — 7-Mode Anti-Hallucination Blocking
[!CAUTION] The mechanism in this section applies to Pipeline D (Content Generation Pipeline) as a mandatory interception point after content writing is completed and before layout assembly. It cannot be skipped, and the Agent cannot decide on its own that "execution is unnecessary."
9.1 Trigger Timing
- Pre-Review Gate: Triggered immediately after all chapter drafts
section_N.mdhave been generated. - Final Gate: Triggered again after self-review revisions and before handing over to Pipeline C for layout.
9.2 7-Mode Blocking Checklist
The Agent must self-check item by item and output a structured report, marking each item as ✅ 通过 or ❌ 阻断(附具体位置与原因):
| # | Failure Mode | Check Content | Chinese Explanation |
|---|---|---|---|
| 1 | Disguising Implementation Flaws as Innovation | Whether bugs or omissions are packaged as "design features" during code parsing | Strictly prohibit glorifying code errors as "innovations" |
| 2 | Fabrication of experimental data | Whether the performance data in the testing chapter has actual code or log sources | Strictly prohibit fabricating figures such as latency and throughput out of thin air |
| 3 | Methodology drift | Whether the architecture described in the design chapter is consistent with the actual code structure | Strictly prohibit describing one thing while the code does another |
| 4 | Citation hallucination | Whether the references contain fabricated authors, years, or journal names | Mark all unverifiable citations as [CITE_UNVERIFIED] |
| 5 | Shortcut dependency | Whether calling a third-party API is directly equated with "this system implements algorithm XX" | Strictly prohibit confusing calling with self-development |
| 6 | Empty-shell chapters | Whether there are extremely short chapters of fewer than 300 words or a large number of [TODO] placeholders |
Must be reworked and expanded |
| 7 | Repetitive discussion | Whether the same concept is repeatedly explained across multiple chapters (e.g., reintroducing front-end/back-end separation in every chapter) | Deduplicate and cross-reference |
9.3 Blocking logic
- If any one item exists
❌:Strictly prohibithand the document over to typesetting. The Agent must locate the problematic chapters and automatically fix them, then rerun this checklist. - All
✅: generateresources/integrity_report.mdand continue the process.
10. Multi-Perspective Self-Review Panel
[!IMPORTANT] This section requires the Agent, after completing the first draft, toswitch to a reviewer personato conduct a multi-dimensional quality assessment. This mechanism is inspired by the peer review system, with the aim of maximizing the exposure of logical breaks and weak points in the argumentation in the absence of human reviewers.
10.1 Composition of the review panel (5 perspectives + devil's advocate)
The Agent must read the full text in sequence in the following 6 roles, with each role outputting an independent brief comment (in Chinese):
| Role | Focus dimensions | Chinese description |
|---|---|---|
| Structure reviewer | Chapter logical chain, progression of argumentation | Is the outline clear? Are there logical breaks between chapters? |
| Technical reviewer | Accuracy of algorithm descriptions, reasonableness of system architecture | Do the technical details withstand scrutiny? Are there obvious engineering fallacies? |
| Language reviewer | Academic wording, sentence diversity, residual colloquialism | Are there repeated "de de de", colloquial expressions, or traces of AI formulaic writing? |
| Data reviewer | Completeness of figure/table citations, self-consistency of data | Do the figure/table numbers cited in the text actually exist? Do the data contradict each other? |
| Format reviewer | Heading levels, citation format, paragraph indentation | Does it conform to the typesetting requirements of the target academic template? |
| Devil's advocate | Specifically rebuts the core arguments | Try to attack the paper's weakest argument and raise the harshest doubts |
10.2 Quantitative scoring table (0-100 Quality Rubric)
| Dimension | Weight | Scoring Criteria |
|---|---|---|
| Argumentation Logic (Argumentation) | 25% | Completeness of the reasoning chain and strength of causal links |
| Technical Depth (Technical Depth) | 25% | Whether it truly reaches the core of the code rather than surface-level description |
| Language Quality (Language Quality) | 20% | Avoid AI clichés, varied sentence structures, precise terminology |
| Media Richness (Media Richness) | 15% | At least 1 figure and 1 table per chapter |
| Format Compliance (Format Compliance) | 15% | Strictly align with the target template requirements |
10.3 Decision Mapping
- ≥ 80 points: Pass, proceed directly to the typesetting pipeline.
- 65-79 points: Minor Revision; the Agent automatically revises the issues identified in the review and then re-scores.
- 50-64 points: Major Revision; the Agent must deeply rewrite the relevant chapters.
- < 50 points: Reject; output a diagnostic report and notify the user to intervene.
10.4 Devil's Advocate — Anti-Sycophancy Protocol (Anti-Sycophancy Protocol)
- After the Devil's Advocate raises an attacking challenge,it is not allowed to concede twice consecutively in a single adversarial exchange。
- Before each "concession," the validity of the rebuttal must be evaluated on a 1-5 scale, and a concession may be made only when the evaluation is ≥ 4.
- Set up a concession rate tracker: when the global concession rate exceeds 60%, trigger a "Frame-Lock Detection" alert, requiring the Agent to step back and examine the underlying assumptions.
11. Anti-Leakage & Context-Rot Prevention (Anti-Leakage & Context-Rot Prevention)
11.1 Knowledge Isolation Directive (Knowledge Isolation Directive)
Throughout the entire content generation process of Pipeline D, the Agent must abide by the following iron rules:
IRON RULE: The project code and materials provided by the user are the only Source of Truth. The Agent is prohibited from using "memories" from its own training data to fill any information gaps. If a technical detail cannot be substantiated in the project code, it must be marked
[素材缺口]and that passage paused, rather than completed based on imagination.
11.2 Mid-Conversation Reinforcement (Mid-Conversation Reinforcement)
In multi-round chapter generation, whenever the Agent begins writing a new chapter (that is, switching from section_N.md to section_N+1.md), the following two reminders must be re-injected into the internal System Prompt:
- Iron rule reiteration: "You are writing an academic paper. Your only source of truth is the project materials provided by the user. The use of memory filling is prohibited."
- Anti-pattern detection: "Check whether what you are about to write contains large passages of repeated discussion with previous chapters. If so, replace the repeated passages with cross-references (such as 'as stated in Chapter X')."
11.3 Material Gap Protocol (Material Gap Protocol)
When the Agent discovers during writing that a technical detail is needed but was not provided by the user:
- Prohibitedto silently fill it in using the AI's internal knowledge.
- Mustinsert a marker at that location:
[素材缺口:此处需要 XX 的具体实现代码/数据/配置] - List all material gaps uniformly in the final integrity report (§9), and notify the user to supplement them manually.
12. Writing Quality Check (Writing Quality Check) — Chinese Academic Specialization
[!IMPORTANT] This checklist is enforced during the "Language Reviewer" step of the §10 self-review assessment, and is used to detect common patterned traces in AI-generated text.
12.1 AI High-Frequency Word Alerts (25 High-Frequency Chinese Words)
The following words trigger a warning when they appear in a single paper more than the specified threshold:
| Category | High-Frequency Word Examples | Per-Paper Limit |
|---|---|---|
| Empty Modifiers | effectively, significantly, greatly, fully, deeply | Each word ≤ 5 times |
| Clichéd Openings | With the development of..., as is well known, in recent years, it is worth noting that | Each word ≤ 3 times |
| Overpromising | perfectly, thoroughly, without a doubt, indisputably | Each word ≤ 2 times |
| Typical AI Words | empower, closed loop, lever, pain point, precipitate, align, granularity | Each word ≤ 2 times |
| Piled-Up Conjunctions | therefore, however, in addition, at the same time, in summary | Each type ≤ 8 times |
12.2 Sentence Pattern Diversity Detection (Burstiness Check)
- For 3 consecutive paragraphs, thefirst sentencemust not use the same sentence structure (e.g., three consecutive paragraphs all beginning with "This system...").
- The standard deviation of paragraph length should be > 30 characters (to avoid machine-like uniform paragraphs).
12.3 Throat-Clearing Detection
- Detect and delete uninformative opening remarks, such as "To better understand..." and "In this section, we will...".
- Academic writing should enter directly into the core of the discussion, rather than previewing what is about to be said.
12.4 Punctuation Pattern Control
- Em dashes (——) used ≤ 5 times per paper.
- Exclamation marks (!) are absolutely prohibited in the main text (allowed only in non-main-text parts such as acknowledgments).
13. Revision Score Trajectory Tracking (Score Trajectory Tracking)
When a paper goes through multiple rounds of the "write → review → revise" cycle, the Agent must record the score of each round to prevent certain dimensions from unexpectedly regressing during revision:
| 轮次 | 论证逻辑 | 技术深度 | 语言质量 | 图表充实度 | 格式规范 | 总分 |
|------|----------|----------|----------|------------|----------|------|
| R1 | 72 | 68 | 75 | 60 | 80 | 71 |
| R2 | 78 | 75 | 73 ⚠️↓ | 70 | 82 | 76 |
| R3 | 82 | 80 | 80 | 75 | 85 | 81 ✅|
- When any dimension's score compared with the previous rounddrops ≥ 5 pointsmark
⚠️↓and explain the reason for the regression in the revision report. - Only when the total score reaches ≥ 80 points may it be handed over to the Pipeline C typesetting engine.