dongzhigang13305312738-art/paper-skills / complete-example
complete-example
Verified当用户明确要求"填充示例内容""生成示例""补充 LaTeX 示例"时使用。AI 增强版 LaTeX 示例智能生成器,实现 AI 与硬编码的有机融合:AI 做"语义理解"(分析章节主题、推理资源相关性、生成连贯叙述),硬编码做"结构保护"(格式验证、哈希校验、访问控制)。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.1 KB |
| config.yaml | config | 16.6 KB |
| references/README.md | markdown | 962 B |
| scripts/__init__.py | script | 503 B |
| scripts/advanced_usage.py | script | 5.4 KB |
| scripts/ai_content_generator.py | script | 19.6 KB |
| scripts/basic_usage.py | script | 1.3 KB |
| scripts/bibtex_parser.py | script | 5.6 KB |
| scripts/file_utils.py | script | 4.8 KB |
| scripts/format_guard.py | script | 15.5 KB |
| scripts/formula_generator.py | script | 2.1 KB |
| scripts/latex_parser.py | script | 6.2 KB |
| scripts/llm_client.py | script | 6.3 KB |
| scripts/placeholder_parser.py | script | 3.1 KB |
| scripts/resource_allocator.py | script | 10.3 KB |
| scripts/resource_scanner.py | script | 6.5 KB |
| scripts/security_manager.py | script | 17.4 KB |
| scripts/semantic_analyzer.py | script | 8.3 KB |
| scripts/skill_controller.py | script | 22.5 KB |
| scripts/table_generator.py | script | 5.8 KB |
| scripts/template_renderer.py | script | 994 B |
config.yaml
View on GitHubskill_info:
name: complete-example
version: 1.4.1
description: AI 增强版 LaTeX 示例智能生成器(项目级隐藏目录存储)
author: "Bensz Conan"
category: writing
# ========== LLM 配置 ==========
llm:
provider: "claude" # claude / openai / local
model: "claude-sonnet-4-20250514" # 或 gpt-4
api_key_env: "ANTHROPIC_API_KEY" # 环境变量名
temperature:
analysis: 0.3 # 分析任务(低温度,稳定)
generation: 0.8 # 生成任务(高温度,创造性)
refinement: 0.5 # 优化任务(中温度)
max_tokens: 4000
# ========== 参数定义 ==========
parameters:
project:
type: string
required: true
description: 项目名称或路径
content_density:
type: string
allowed_values: ["minimal", "moderate", "comprehensive"]
default: "moderate"
description: |
minimal: 每章节 2 个资源,200 字
moderate: 每章节 4 个资源,300 字
comprehensive: 每章节 6 个资源,500 字
output_mode:
type: string
allowed_values: ["preview", "apply", "report"]
default: "preview"
description: |
preview: 只显示预览,不修改文件
apply: 直接修改文件(有备份)
report: 生成详细报告文件
target_files:
type: array
default: null
description: |
目标文件列表(相对于项目根目录)
null 表示自动检测所有 extraTex/*.tex
narrative_hint:
type: string
default: null
description: |
用户自定义的叙事提示,用于指导 AI 生成特定风格的示例内容。
这是"示例场景"而非"严肃场景",因此 AI 可以根据提示编造相应的叙事。
示例:
- "生成一个关于深度学习在医疗影像分析中应用的示例"
- "创建一个使用传统机器学习方法的示例研究"
- "编写一个关于材料科学实验设计的示例,重点关注 XRD 表征"
- "模拟一个多中心临床试验的设计与分析流程"
null 表示 AI 根据章节主题自动推断叙事方向。
# ========== 运行管理配置 ==========
run_management:
# 运行输出根目录(所有中间文件都存储在目标项目的隐藏目录中)
runs_root: "{project_path}/.complete_example"
# 运行 ID 生成策略
run_id_strategy: "timestamp_uuid" # timestamp_uuid / sequential / custom
# 保留策略
retention:
max_runs: 50 # 最多保留 50 次运行记录
max_age_days: 30 # 最多保留 30 天
auto_cleanup: true # 自动清理过期记录
# 备份策略
backup:
location: ".complete_example/{run_id}/backups" # 备份位置(项目隐藏目录)
compress: false # 是否压缩备份文件
format: "tar.gz" # 压缩格式(如果启用压缩)
# 日志策略
logging:
location: ".complete_example/{run_id}/logs" # 日志位置(项目隐藏目录)
level: "INFO" # 日志级别
rotation: true # 日志轮转
max_size_mb: 10 # 单个日志文件最大大小
# ========== 资源扫描配置 ==========
scan:
targets:
- name: "figures"
enabled: true
patterns: ["*.jpg", "*.jpeg", "*.png", "*.pdf", "*.eps"]
extract_metadata: true
- name: "code"
enabled: true
patterns: ["*.py", "*.m", "*.r", "*.cpp", "*.c"]
max_lines: 100 # 超过此行数只截取片段
- name: "references"
enabled: true
patterns: ["*.bib"]
parse_entries: true
# ========== 内容生成配置 ==========
generation:
# 资源选择策略
selection_strategy: "smart_allocation" # smart_allocation / ai_score / random / manual
# smart_allocation: 使用新的智能资源分配器,确保充分利用所有素材
# 相关性阈值(仅在使用 ai_score 时有效)
relevance_threshold: 0.5
# 内容类型权重(AI 根据章节主题动态调整,作为提示而非强约束)
content_type_weights:
text: 0.5
table: 0.2
formula: 0.15
figure: 0.1
code: 0.05
# 每种资源类型的数量限制
max_figures_per_section: 2
max_code_per_section: 1
max_references_per_section: 3
# 表格生成配置
table_generation:
enabled: true
max_tables_per_section: 2
complexity_levels:
simple:
max_columns: 5
max_rows: 10
moderate:
max_columns: 8
max_rows: 20
complex:
max_columns: 10
max_rows: 50
allow_multirow: true
allow_multicolumn: true
# 数学公式生成配置
formula_generation:
enabled: true
max_formulas_per_section: 3
types:
- inline
- display
- equation
- align
# ========== 章节层级规范 ==========
# 核心规则:main.tex 使用 section/subsection,input 类 tex 使用 subsubsection/subsubsubsection
section_hierarchy:
# main.tex 专用层级(禁止在 input 类 tex 中使用)
main_tex_only:
- "\\section"
- "\\subsection"
# input 类 tex 允许的层级
input_tex_allowed:
- "\\subsubsection"
- "\\subsubsubsection"
# 生成要求:每个 input tex 必须同时使用两个层级
generation_requirement:
require_both_levels: true # 必须同时使用 subsubsection 和 subsubsubsection
min_subsubsection: 1 # 每个文件至少 1 个 subsubsection
min_subsubsubsection: 1 # 每个 subsubsection 下至少 1 个 subsubsubsection
# 层级检查策略
enforcement:
enabled: true
mode: "strict" # strict: 拒绝违规 / warn: 警告但允许 / off: 关闭检查
auto_fix: false # 是否自动修正层级(危险,建议关闭)
# 内容模板
templates:
figure_insertion: |
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{{{path}}}
\caption{{{caption}}}
\label{{{label}}}
\end{figure}
code_listing: |
\begin{lstlisting}[language={{lang}}, caption={{{caption}}}, firstline=1, lastline={{lastline}}]
{{code}}
\end{lstlisting}
reference_citation: "\\cite{{{citekey}}}"
# 简单表格模板(booktabs)
simple_table: |
\begin{table}[htbp]
\centering
\fontsize{11}{11}\selectfont
\caption{\textbf{{{caption}}}}
\begin{tabular}{{{column_spec}}}
\toprule
{{header_row}}
\midrule
{{data_rows}}
\bottomrule
\end{tabular}
\captionsetup{font={footnotesize,stretch=1.25},justification=raggedright}
\label{{{label}}}
\end{table}
# 复杂表格模板(多行表头)
complex_table: |
\begin{table}[htbp]
\centering
\fontsize{11}{11}\selectfont
\caption{\textbf{{{caption}}}}
\begin{tabular}{{{column_spec}}}
\toprule
{{header_rows}}
\toprule
{{data_rows}}
\bottomrule
\end{tabular}
\captionsetup{font={footnotesize,stretch=1.25},justification=raggedright}
\label{{{label}}}
\end{table}
# 数学公式模板
inline_math: "${{formula}}$"
display_math: |
\[
{{formula}}
\]
equation: |
\begin{equation}
{{formula}}
\label{{{label}}}
\end{equation}
align: |
\begin{align}
{{formulas}}
\end{align}
# ========== 🆕 篇幅控制配置 ==========
page_control:
# 目标 PDF 页数范围
target_pdf_pages: [12, 14] # [最小页数, 最大页数]
# 每页平均字数(用于估算)
avg_words_per_page: 350
# 各种元素占用的页数(估算值)
figures_per_page_estimate: 0.3 # 每张图片占用 0.3 页
code_per_page_estimate: 0.2 # 每段代码占用 0.2 页
table_per_page_estimate: 0.25 # 每个表格占用 0.25 页
references_per_page_estimate: 0.05 # 每个文献引用占用 0.05 页
# 资源利用率目标
resource_utilization:
figures: 1.0 # 100% 利用率(所有图片都分配到章节)
code: 1.0 # 100% 利用率(所有代码都分配到章节)
# ========== 格式保护配置 ==========
format_protection:
# 受保护的 LaTeX 命令
protected_commands:
- "\\setlength"
- "\\geometry"
- "\\definecolor"
- "\\setCJKfamilyfont"
- "\\setmainfont"
- "\\titleformat"
- "\\setlist"
- "\\newcommand"
- "\\renewcommand"
# 受保护的文件(绝对不修改)
protected_files:
- "extraTex/@config.tex"
- "main.tex"
# 备份策略
backup:
enabled: true
keep_count: 5 # 保留最近 5 个备份
# 编译验证
compile_verify:
enabled: true
engine: "xelatex"
timeout: 60 # 秒
# ========== 🔒 安全管理配置 ==========
security:
# 系统文件保护
system_files:
blacklist:
- "main.tex"
- "extraTex/@config.tex"
- "@config.tex"
# 允许编辑的文件模式(白名单,正则表达式)
editable_patterns:
- "^extraTex/\\d+\\.\\d+.*\\.tex$" # extraTex/1.1.xxx.tex
- "^references/reference\\.tex$" # 参考文献引用文件
# 格式关键词黑名单(禁止在用户文件中使用)
format_keywords_blacklist:
- "\\\\geometry{"
- "\\\\setlength{"
- "\\\\definecolor{"
- "\\\\setCJKfamilyfont"
- "\\\\setmainfont"
- "\\\\setCJKmainfont"
- "\\\\renewcommand{\\\\baselinestretch}"
- "\\\\titleformat{"
- "\\\\titlespacing"
- "\\\\setlist"
- "\\\\newcommand"
- "\\\\renewcommand"
- "\\\\newcolumntype"
- "\\\\DeclareMathOperator"
- "\\\\usepackage{"
- "\\\\documentclass"
# 表格安全检查(生成后启发式过滤)
table_security:
max_size_kb: 50
forbidden_commands:
- "\\newcolumntype"
- "\\setlength{\\tabcolsep}"
- "\\renewcommand{\\arraystretch}"
# 公式安全检查(生成后启发式过滤)
formula_security:
max_length: 1000
forbidden_commands:
- "\\DeclareMathOperator"
- "\\newcommand"
# 文件完整性校验
integrity_check:
enabled: true
hash_algorithm: "sha256"
hash_file: ".format_hashes.json"
auto_init: true # 如果哈希文件不存在,自动初始化
# 内容安全扫描
content_scanning:
enabled: true
auto_sanitize: true # 自动清理格式注入
fail_on_violation: false # 发现违规时是否失败(false 则警告并清理)
# 安全检查项开关
enabled_checks:
system_file: true # 系统文件黑名单检查
section_hierarchy: true # 章节层级规范检查
integrity: true # 完整性校验
format_injection: true # 格式注入检查
# ========== AI 提示词模板 ==========
prompts:
analyze_theme: |
你是一位专业的学术写作分析专家。请分析以下 LaTeX 章节的内容主题。
章节内容(前 {max_chars} 字符):
{content}
请返回 JSON 格式的分析结果:
{{
"theme": "章节的核心主题(一句话概括)",
"key_concepts": ["关键概念1", "关键概念2", "关键概念3"],
"writing_style": "学术/技术/说明/混合",
"suggested_resources": ["建议的图片类型", "建议的文献领域"],
"tone": "正式/半正式/通俗",
"target_audience": "评审专家/同行/学生/大众"
}}
reason_relevance: |
你是一位专业的学术写作顾问。请评估以下资源是否适合用于指定章节。
章节信息:
- 主题:{section_theme}
- 关键概念:{key_concepts}
- 写作风格:{writing_style}
资源信息:
- 路径:{resource_path}
- 类型:{resource_type}
- 元数据:{metadata}
请返回 JSON 格式的评估结果:
{{
"relevance_score": 0.85,
"reason": "详细说明理由(100-200字)",
"suggested_usage": "建议如何使用这个资源"
}}
generate_narrative: |
你是一位经验丰富的科研写作助手,专精于国家自然科学基金申请书的撰写。
根据以下信息,生成一段连贯的示例内容。
## 章节信息
- 主题:{theme}
- 关键概念:{key_concepts}
- 写作风格:{writing_style}
- 目标读者:{target_audience}
## 用户叙事提示
{narrative_hint}
## 上下文片段
{context}
## 可用资源
{resources}
## 生成要求
1. 生成 {target_length} 字的示例段落
2. 自然地引用资源
3. 使用正式的学术写作风格
4. **重要**:根据【用户叙事提示】调整内容方向和风格
5. **允许编造**:这是示例场景,可以根据提示编造合理的研究内容、数据和结论
6. 在应该插入 LaTeX 代码的地方用 {{{{PLACEHOLDER:资源路径}}}} 标记
## 🆕 多元内容格式支持
根据章节主题,你可以生成以下类型的内容:
### 表格
- 用于展示对比数据、实验结果、参数设置等
- 使用占位符:{{{{TABLE:表格描述|复杂度}}}}
- 复杂度选项:simple / moderate / complex
- 示例:{{{{TABLE:临床特征对比表|complex}}}}
### 数学公式
- 用于理论推导、模型描述、统计分析等
- 行内公式:{{{{INLINE_MATH:公式内容}}}}
- 独立公式:{{{{DISPLAY_MATH:公式内容}}}}
- 带编号公式:{{{{EQUATION:公式内容|标签}}}}
- 多行公式:{{{{ALIGN:公式1\\\\公式2\\\\公式3}}}}
- 示例:{{{{EQUATION:E = mc^2|eq:energy}}}}
## ⚠️ 章节层级约束(必须遵守)
当前文件类型:{file_type}
- 如果是 input 类 tex 文件(extraTex/*.tex):
- ✅ 必须使用:\subsubsection 和 \subsubsubsection 两个层级
- ❌ 禁止使用:\section、\subsection(这些仅在 main.tex 中使用)
## ⚠️ 双层级结构要求(必须遵守)
每个 input 类 tex 文件必须同时包含两个层级的标题:
- **\subsubsection{{主标题}}**:作为该文件的主要章节划分
- **\subsubsubsection{{子标题}}**:在每个 subsubsection 下进一步细分
示例结构:
```latex
\subsubsection{{研究背景}}
\subsubsubsection{{国内研究现状}}
...内容...
\subsubsubsection{{国外研究现状}}
...内容...
\subsubsection{{研究意义}}
\subsubsubsection{{理论意义}}
...内容...
\subsubsubsection{{实践意义}}
...内容...
```
只返回生成的文本,不要其他解释。
generate_table: |
你是一位专业的科研数据可视化专家。请根据以下信息生成一个 LaTeX 表格。
## 表格需求
- 主题:{table_theme}
- 复杂度:{complexity}
- 列数:{num_columns}
- 行数:{num_rows}
- 用途:{purpose}
## 上下文
{context}
## 生成要求
1. 表格数据应该合理且符合科研规范
2. 使用适当的统计符号和单位
3. 包含必要的表头和分组
4. 数据精度合理(通常保留2-3位小数)
5. 如果是对比表,应包含统计检验结果(如 P 值)
请返回 JSON 格式:
{{
"caption": "表格标题",
"column_spec": "列格式(如 lcccc)",
"header_row": "表头行(用 & 分隔,末尾带 \\\\)",
"data_rows": ["数据行1(末尾带 \\\\)", "数据行2(末尾带 \\\\)"],
"label": "表格标签(如 tab:results)"
}}
generate_formula: |
你是一位专业的数学建模专家。请根据以下信息生成一个 LaTeX 数学公式。
## 公式需求
- 主题:{formula_theme}
- 类型:{formula_type} # inline / display / equation / align
- 用途:{purpose}
## 上下文
{context}
## 生成要求
1. 公式应该数学上合理且符合领域规范
2. 使用标准的 LaTeX 数学符号
3. 变量命名清晰(使用希腊字母或英文字母)
4. 如果是多行公式,应该对齐等号或关系符
5. 包含必要的下标、上标和修饰符
请返回 JSON 格式:
{{
"formula": "公式内容(LaTeX 格式)",
"label": "公式标签(如果需要)",
"description": "公式含义的简短描述"
}}
# ========== 质量评估标准 ==========
quality_thresholds:
coherence_min: 0.8 # 连贯性最低要求
academic_tone_min: 0.75 # 学术风格最低要求
overall_score_min: 0.8 # 总体评分最低要求
# 表格质量评估(启发式)
table_quality:
min_columns: 3
max_columns: 10
min_rows: 3
data_consistency: 0.9
header_clarity: 0.85
# 公式质量评估(启发式)
formula_quality:
syntax_correctness: 1.0
semantic_relevance: 0.8
notation_standard: 0.85
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |