跳转到内容

模板工作流

.doct 是 Docmod 的模板包,也是 Agent 的任务边界。它不只是样式文件,而是把内容字段、格式角色、完整模板和写作指南放在一起。

template.doct
├── format.json
├── content.json
├── document.html
├── source.docx
├── guides/
├── images/
└── meta.json
  • content.json 定义文档应该包含哪些字段。
  • format.json 定义 paragraph、run、table 的角色和样式。
  • document.html 提供完整模板和 {{placeholder}}
  • guides/ 提供写作、审阅、排版规则。

Agent 应该输出角色和内容,而不是随意写 CSS:

<p data-pstyle="title">{{title}}</p>
<p data-pstyle="body">正文内容。</p>

Docmod 负责把 data-pstyle / data-rstyle 转成模板里的真实 Word 样式。

Terminal window
docmod template list
docmod read government.doct --content
docmod read government.doct --format
docmod read government.doct --guide writing

模板解析顺序是路径、用户模板库、内置模板。用户模板通常安装在 ~/.docmod/templates/

Terminal window
docmod create output.docx --template government --from changes.html
docmod create output.docx --template ./custom.doct --from changes.html

创建时模板会填充占位符、烘焙 format.json,并使用模板的 source.docx 作为 Keep 基底。

Terminal window
docmod template init marked.docx --to template.doct
docmod template validate template.doct
docmod template install template.doct --name government

标记样本文档时,先在 Word 中放好 {{title}}{{body}}{{date}} 等占位符,再从它生成 .doct。生成后继续补充 guides,让 Agent 知道怎么写、怎么审、怎么排。

.docmodmeta.json 里按裸名引用模板:

Terminal window
docmod set-template work.docmod --template government

如果引用名解析不到,读取会返回 TEMPLATE_NOT_FOUND,提示先 docmod template list 找候选模板,再重绑。