> 本技能的 .md 文件禁止使用 Write/Edit 工具更新。
> 必须用 scripts/ 下的 Python 脚本原子写入(tmp + os.replace())。
| 文件 | 更新方式 | 脚本 |
|------|----------|--------|
| SKILL.md frontmatter | Python 原子写入 | scripts/update_frontmatter.py |
| SKILL.md 正文 | Python 直接重建 | scripts/safe_write.py 的 safe_write() |
| scripts/components/*.txt | Python 写入 | scripts/component_manager.py |
| references/*.md | scripts/safe_write.py | 随技能自带 |
不触发:
> 📚 渐进式加载:本技能采用渐进式 MD 体系,SKILL.md 为入口(≤230行),详细内容拆分到 references/*.md 按需加载。
--template 按名加载、--save-as 保存自定义模板、--content 注入正文、--list-templates 等,内置 article/report 两种预设模板(scripts/template.py + scripts/templates/)
scripts/component_inject.py)
scripts/convert.py)
| 文件 | 位置 | 说明 |
|------|------|------|
| references/guide.md | 使用指南 | 完整使用指南(触发词、工作流程、输出格式) |
| references/architecture.md | 架构说明 | 内部架构(组件分类、组合引擎、验证器) |
| references/antipatterns.md | 反模式 | 常见 LaTeX 错误 + 正确做法 |
| references/faq.md | FAQ | 常见问题解答(宏包冲突、字体问题、编译错误) |
| references/changelog.md | 更新日志 | 版本更新记录 |
| references/component-spec.md | 组件规范 | 命名、参数、依赖声明 |
| 脚本 | 功能 |
|------|------|
| scripts/compose.py | 模块组合引擎,按依赖顺序组合组件 |
| scripts/extract.py | 从 LaTeX 源文件提取组件 |
| scripts/validate.py | 编译验证,调用 lualatex 并检查输出 |
| scripts/refactor.py | 重构引擎,将原始 LaTeX 转为模块化结构 |
| scripts/template.py | 模板库管理 |
| scripts/component_manager.py | 组件库管理(增删改查) |
| scripts/component_inject.py | 增量注入:向现有 .tex 插入组件 |
| scripts/convert.py | 引擎转换:pdfLaTeX → LuaLaTeX |
| scripts/workflow_router.py | 语义路由:分析用户输入 → 匹配流程线 |
| scripts/write_guard.py | 写入守卫:扫描直接 open()/os.remove() 调用,强制使用 safe_write |
| scripts/safe_write.py | 原子写入工具 + safe_delete() 安全删除 |
| scripts/workflow_state.py | 流程守卫:步骤依赖检查 + 状态持久化 |
| scripts/update_frontmatter.py | 更新 SKILL.md frontmatter |
--engine xelatex 切换,组件库完全兼容
长篇 .tex 文件处理策略:
--lines START-END 参数限定处理行范围,避免加载全文
--encoding 指定文件编码(默认 utf-8)
本技能内置 4 条流程线 + 独立模式,通过语义路由器自动匹配用户意图。
用户输入
│
▼
语义路由器 (scripts/workflow_router.py)
├── 路由分析 → 匹配流程线或独立模式
├── 验证钩子 → 检查路由与输入语义的一致性
│ ├── 高置信度 + 无冲突 → 走匹配路线
│ └── 低置信度 + 有冲突 → 降级为独立模式
└── 文件大小钩子 → 检测源文件体积
├── >500KB → 建议 --lines 分块
└── >2MB → 强制 --lines,拒绝无参数执行
│
├── workflow 模式 → 严格步骤守卫 (workflow_state.py)
│ 每步执行前检查前置步骤是否完成,跳过则报错
│ 状态持久化在 .standardization/latex-modular/data/workflow_state/ 目录
│
└── standalone 模式 → 独立操作,无步骤约束
AI 自行决断,不设守卫
| 流程线 | 步骤链 | 强制备份 | 强制验证 | 报告 |
|--------|--------|---------|---------|------|
| Line 1 创建文档 | template → inject_params → compose → validate → report | ❌ | ✅ | ✅ |
| Line 2 改造 | backup → convert → branch → final_validate → report | ✅ 第一步 | ✅ | ✅ |
| Line 3 增量编辑 | backup → inject → final_validate → report | ✅ 第一步 | ✅ | ✅ |
| Line 4 组件复用 | extract → compose → template → reuse → final_validate → report | ❌ | ✅ | ✅ |
| 独立模式 | execute → final_validate → report | ❌ | 推荐 | ✅ |
| 大小 | 级别 | 行为 |
|------|------|------|
| <500KB | normal | 正常处理 |
| 500KB~2MB | large | 建议使用 --lines 限定范围 |
| >2MB | huge | 强制 --lines,拒绝无参数执行 |
scripts/workflow_router.py — 语义路由 + 验证钩子 + 文件大小钩子
scripts/workflow_state.py — 流程守卫:步骤依赖检查 + 状态持久化
scripts/workflow_report.py — 结构化报告生成(Markdown 表格)
scripts/components/:
preamble/*.tex — 宏包引入、颜色定义、字体配置
environments/*.tex — 自定义环境(mylist、mycolumns 等)
commands/*.tex — 自定义命令(\\timu、\\seeref 等)
styles/*.tex — 章节样式、目录样式、页眉页脚
tables/*.tex — 表格样式模板
graphics/*.tex — 图片插入模板
scripts/components/manifest.json
scripts/components/manifest.json 获取可用组件列表
scripts/compose.py 按正确顺序组合:
scripts/components/
├── manifest.json # 组件索引
├── preamble/ # 导言区组件
│ ├── class-settings.txt
│ └── packages.txt
├── environments/ # 自定义环境
│ ├── mylist.txt
│ ├── mycolumns.txt
│ └── abstract-env.txt
├── commands/ # 自定义命令
│ ├── title-commands.txt
│ └── background.txt
├── styles/ # 样式配置
│ ├── section-style.txt
│ ├── toc-style.txt
│ └── header-footer.txt
├── tables/ # 表格模板
│ └── table-style.txt
└── graphics/ # 图片模板
└── figure-insert.txt
scripts/components/ 对应目录
scripts/validate.py
共 3 个版本