模板规范说明
config.json 和 project.json 结构定义与字段规范
1. 概述
每个 Skill 使用两个 JSON 配置文件驱动文档生成:
| 文件 |
用途 |
config.json |
封面信息 + 背景概述 |
project.json |
章节内容 + 表格数据 + CSCI 定义 |
2. config.json 规范
2.1 整体结构
1 2 3 4 5
| { "project": { ... }, "document": { ... }, "content": { ... } }
|
2.2 project 字段
项目基本信息,用于生成封面和文档标识行。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| { "project": { "name": { "type": "original_text", "replacement_pattern": "外部型号+产品名称", "content": "编译器" }, "short_name": { "type": "original_text", "replacement_pattern": "产品型号-XXXX", "content": "BYQ" }, "version": { "type": "original_text", "replacement_pattern": "版 次: A 版", "content": "V2.0" }, "company": { "type": "original_text", "replacement_pattern": "XXXXXXXX公司", "content": "Test University" }, "department": { "type": "original_text", "replacement_pattern": "...", "content": "Test School" } } }
|
| 字段 |
说明 |
name |
项目名称(替换封面”外部型号+产品名称”) |
short_name |
项目简称(替换封面”产品型号-XXXX”) |
version |
版本号(替换封面版次) |
company |
单位名称(替换封面公司名) |
department |
部门名称 |
2.3 document 字段
文档元信息。
1 2 3 4 5 6 7 8 9
| { "document": { "id": { "type": "original_text", "content": "BYQ-SRS-V2.0" }, "title": { "type": "original_text", "content": "软件需求规格说明" }, "classification": { "type": "original_text", "content": "Internal" }, "phase": { "type": "original_text", "content": "Design Phase" }, "date": { "type": "original_text", "content": "2026年03月01日" } } }
|
| 字段 |
说明 |
id |
文档标识号 |
title |
文档标题([10] = 软件需求规格说明,[11] = 软件设计说明) |
classification |
密级(公开/内部/机密) |
phase |
阶段 |
date |
日期 |
2.4 content 字段
背景信息,用于 Claude 理解项目上下文。
1 2 3 4 5 6 7
| { "content": { "overview": { "type": "background_information", "content": "..." }, "scope": { "type": "background_information", "content": "..." }, "features": { "type": "background_information", "content": "..." } } }
|
3. project.json 规范
3.1 整体结构
1 2 3 4
| { "template_info": { ... }, "structure": { ... } }
|
3.2 template_info
1 2 3 4 5 6 7
| { "template_info": { "name": "GJB 438C 软件需求规格说明书", "source": "[10][SRS] 软件需求规格说明-438C-2021.docx", "encoding": "gbk" } }
|
| 字段 |
说明 |
name |
模板名称 |
source |
源模板文件名 |
encoding |
文件编码([10] = gbk,[11] = utf-8) |
3.3 structure — 章节结构
structure 是一个以章节 ID 为键的字典。每章可包含:
| 字段 |
类型 |
说明 |
replacement_pattern |
str |
锚点文本(段落包含匹配) |
content |
str |
替换后的内容 |
subsections |
dict |
固定子章节(key = 子节 ID) |
placeholders |
array |
占位符列表(含动态章节) |
tables |
array |
表格定义列表 |
cscis |
array |
CSCI 定义列表(仅 [11] 第 4 章) |
静态章节
1 2 3 4 5 6
| { "1.1": { "replacement_pattern": "本条应描述本文档所适用软件的完整标识...", "content": "本文档适用于..." } }
|
固定子章节
1 2 3 4 5 6 7 8 9 10 11
| { "3.10": { "subsections": { "3.10.1": { "replacement_pattern": "本条应描述针对本软件必须使用的计算机硬件的需求...", "content": "..." }, "3.10.2": { "replacement_pattern": "...", "content": "..." } } } }
|
3.4 动态章节([10] 专属)
通过 placeholders 数组中的 subsections 定义可变数量子节。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| { "3": { "placeholders": [ { "id": "3.2", "content": "为详细说明与软件各个能力相关的需求...", "subsections": { "3.2.1": { "name": "词法分析模块", "content": "..." }, "3.2.2": { "name": "语法分析模块", "content": "..." }, "3.2.3": { "name": "语义分析模块", "content": "..." } } } ] } }
|
引擎通过 template_rules.py 中的 INSERTION_PARENT_RULES 确定动态章节的:
summary_anchor:摘要段落锚点
end_before_title:结束锚点(下一章节标题)
prototype_title_anchor / prototype_body_anchor:克隆原型
cleanup_anchors:需清理的模板占位文本
3.5 CSCI 章节([11] 专属)
第 4 章使用 cscis 数组定义 CSCI 块。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| { "4": { "cscis": [ { "title": "编译控制 CSCI", "overview": "...", "component_title": "命令解析器", "component_design": "...", "execution_plan": "...", "interface_overview": "...", "interface_identification": "...", "interface_detail_title": "CLI 接口", "interface_details": "..." } ] } }
|
| 字段 |
说明 |
title |
CSCI 名称 |
overview |
CSCI 概述 |
component_title |
部件名称 |
component_design |
部件设计描述 |
execution_plan |
执行方案 |
interface_overview |
接口设计概述 |
interface_identification |
接口标识和接口图 |
interface_detail_title |
接口详细设计标题 |
interface_details |
接口详细设计内容 |
引擎通过 CSCI_SECTION_RULE 中的 13 个锚点定位整个 CSCI 原型块,为每个 CSCI 克隆并修改。
3.6 表格定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| { "tables": [ { "table_id": "reference_documents", "data_start_row": 1, "preserve_tail_rows": 0, "locator_rows": [ ["文档编号", "文档标题", "编写单位", "修订版", "日期"] ], "columns": ["文档编号", "文档标题"], "rows": [ { "文档编号": "GB/T 0018", "文档标题": "..." }, { "文档编号": "GB/T 0028", "文档标题": "..." } ] } ] }
|
| 字段 |
说明 |
table_id |
表格标识 |
locator_rows |
表头行文本(用于定位表格,不可修改) |
columns |
列名(必须与 rows 的键完全一致) |
rows |
数据行数组 |
data_start_row |
数据起始行索引 |
preserve_tail_rows |
保留的尾部行数 |
关键约束:
locator_rows 和 columns 不可修改
rows 中每行的键必须严格等于 columns
locator_rows 用于在文档中精确定位唯一表格
4. [10] 与 [11] 差异对比
| 维度 |
[10] SRS |
[11] SDD |
| 模板编码 |
gbk |
utf-8 |
| 第 3 章 |
需求(18 个占位符 + 4 类动态章节) |
系统设计决策(单一内容块) |
| 第 4 章 |
合格性规定(表格) |
系统体系结构设计(cscis 数组) |
| 第 5 章 |
合格性规定 + 追踪表 |
追踪表 |
| 追踪表列 |
需求指标 + 需求描述 |
需求名 + 需求章节 + 软件单元 |
| 动态章节 |
3.1/3.2/3.3/3.4 |
无 |
| CSCI |
无 |
第 4 章 |
5. 修改规则
允许修改:
- 所有
content 字段
- 表格
rows 数组中的值
禁止修改(修改会导致 StrictTemplateError):
replacement_pattern — 模板中的锚点文本
locator_rows — 表格定位行
columns — 表格列名
id / name — 占位符标识
data_start_row / preserve_tail_rows — 表格行参数