doc-spec-fixer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedoc-spec-fixer
doc-spec-fixer
Purpose
用途
Automated fix skill that reads the latest review report and applies fixes to SPEC (Specification) documents. This skill bridges the gap between (which identifies issues) and the corrected SPEC, enabling iterative improvement cycles.
doc-spec-reviewerLayer: 9 (SPEC Quality Improvement)
Upstream: REQ documents, CTR documents, SPEC document, Review Report ()
SPEC-NN.R_review_report_vNNN.mdDownstream: Fixed SPEC, Fix Report ()
SPEC-NN.F_fix_report_vNNN.md一款自动化修复工具,可读取最新评审报告并对SPEC(规范)文档进行修复。该工具填补了(用于识别问题)与修正后SPEC文档之间的空白,支持迭代优化循环。
doc-spec-reviewer层级: 9(SPEC质量优化)
上游依赖: REQ文档、CTR文档、SPEC文档、评审报告()
SPEC-NN.R_review_report_vNNN.md下游产出: 修复后的SPEC文档、修复报告()
SPEC-NN.F_fix_report_vNNN.mdWhen to Use This Skill
使用场景
Use when:
doc-spec-fixer- After Review: Run after identifies issues
doc-spec-reviewer - Iterative Improvement: Part of Review -> Fix -> Review cycle
- Automated Pipeline: CI/CD integration for quality gates
- Batch Fixes: Apply fixes to multiple SPECs based on review reports
- YAML Structure Issues: SPEC contains malformed YAML blocks
Do NOT use when:
- No review report exists (run first)
doc-spec-reviewer - Creating new SPEC (use or
doc-spec)doc-spec-autopilot - Only need validation (use )
doc-spec-validator
在以下场景使用:
doc-spec-fixer- 评审完成后: 在识别出问题后运行
doc-spec-reviewer - 迭代优化: 作为「评审 -> 修复 -> 评审」循环的一部分
- 自动化流水线: 集成到CI/CD中作为质量门禁
- 批量修复: 根据评审报告对多个SPEC文档应用修复
- YAML结构问题: SPEC文档包含格式错误的YAML块
请勿在以下场景使用:
- 无评审报告存在(请先运行)
doc-spec-reviewer - 创建新的SPEC文档(使用或
doc-spec)doc-spec-autopilot - 仅需验证(使用)
doc-spec-validator
Skill Dependencies
工具依赖
| Skill | Purpose | When Used |
|---|---|---|
| Source of issues to fix | Input (reads review report) |
| Element ID standards | Fix element IDs |
| SPEC creation rules | Create missing sections |
| REQ traceability | Validate upstream links |
| CTR traceability | Validate contract links |
| 工具 | 用途 | 使用时机 |
|---|---|---|
| 提供待修复的问题来源 | 输入(读取评审报告) |
| 元素ID标准 | 修复元素ID |
| SPEC文档创建规则 | 创建缺失章节 |
| REQ可追溯性 | 验证上游链接 |
| CTR可追溯性 | 验证契约链接 |
Workflow Overview
工作流概述
mermaid
flowchart TD
A[Input: SPEC Path] --> B[Find Latest Review Report]
B --> C{Review Found?}
C -->|No| D[Run doc-spec-reviewer First]
C -->|Yes| E[Parse Review Report]
E --> F[Categorize Issues]
subgraph FixPhases["Fix Phases"]
F --> F0[Phase 0: Fix Structure Violations]
F0 --> G[Phase 1: Create Missing Files]
G --> H[Phase 2: Fix Broken Links]
H --> I[Phase 3: Fix Element IDs]
I --> J[Phase 4: Fix Content Issues]
J --> K[Phase 5: Update References]
K --> K2[Phase 6: Handle Upstream Drift]
end
subgraph YAMLFix["YAML Structure Fixes"]
K2 --> Y1[Parse YAML Blocks]
Y1 --> Y2{YAML Valid?}
Y2 -->|No| Y3[Repair YAML Structure]
Y2 -->|Yes| Y4[Validate Schema Compliance]
Y3 --> Y4
end
Y4 --> L[Write Fixed SPEC]
L --> M[Generate Fix Report]
M --> N{Re-run Review?}
N -->|Yes| O[Invoke doc-spec-reviewer]
O --> P{Score >= Threshold?}
P -->|No, iterations < max| F
P -->|Yes| Q[COMPLETE]
N -->|No| Qmermaid
flowchart TD
A[输入: SPEC路径] --> B[查找最新评审报告]
B --> C{找到评审报告?}
C -->|否| D[先运行doc-spec-reviewer]
C -->|是| E[解析评审报告]
E --> F[问题分类]
subgraph FixPhases["修复阶段"]
F --> F0[阶段0: 修复结构违规]
F0 --> G[阶段1: 创建缺失文件]
G --> H[阶段2: 修复失效链接]
H --> I[阶段3: 修复元素ID]
I --> J[阶段4: 修复内容问题]
J --> K[阶段5: 更新引用]
K --> K2[阶段6: 处理上游漂移]
end
subgraph YAMLFix["YAML结构修复"]
K2 --> Y1[解析YAML块]
Y1 --> Y2{YAML有效?}
Y2 -->|否| Y3[修复YAML结构]
Y2 -->|是| Y4[验证Schema合规性]
Y3 --> Y4
end
Y4 --> L[写入修复后的SPEC文档]
L --> M[生成修复报告]
M --> N{重新运行评审?}
N -->|是| O[调用doc-spec-reviewer]
O --> P{分数 >= 阈值?}
P -->|否, 迭代次数 < 最大值| F
P -->|是| Q[完成]
N -->|否| QFix Phases
修复阶段
Phase 0: Fix Structure Violations (CRITICAL)
阶段0: 修复结构违规(CRITICAL)
Fixes SPEC documents that are not in nested folders. This phase runs FIRST because all subsequent phases depend on correct folder structure.
Nested Folder Rule: ALL SPEC documents MUST be in nested folders regardless of document size.
Required Structure:
| SPEC Type | Required Location |
|---|---|
| YAML | |
Fix Actions:
| Issue Code | Issue | Fix Action |
|---|---|---|
| REV-STR001 | SPEC not in nested folder | Create folder, move file, update all links |
| REV-STR002 | SPEC folder name doesn't match SPEC ID | Rename folder to match |
| REV-STR003 | SPEC >25KB should be sectioned | Flag for manual review |
Structure Fix Workflow:
python
def fix_spec_structure(spec_path: str) -> list[Fix]:
"""Fix SPEC structure violations."""
fixes = []
filename = os.path.basename(spec_path)
parent_folder = os.path.dirname(spec_path)
# Extract SPEC ID and slug from filename
match = re.match(r'SPEC-(\d+)_([^/]+)\.yaml', filename)
if not match:
return [] # Cannot auto-fix invalid filename
spec_id = match.group(1)
slug = match.group(2)
expected_folder = f"SPEC-{spec_id}_{slug}"
# Check if already in nested folder
if os.path.basename(parent_folder) != expected_folder:
# Create nested folder
new_folder = os.path.join(os.path.dirname(parent_folder), expected_folder)
os.makedirs(new_folder, exist_ok=True)
# Move file
new_path = os.path.join(new_folder, filename)
shutil.move(spec_path, new_path)
fixes.append(f"Moved {spec_path} to {new_path}")
# Update upstream references in YAML file
content = Path(new_path).read_text()
updated_content = content.replace('../08_CTR/', '../../08_CTR/')
updated_content = updated_content.replace('../07_REQ/', '../../07_REQ/')
Path(new_path).write_text(updated_content)
fixes.append(f"Updated relative links for nested folder structure")
return fixesLink Path Updates After Move:
| Original Path | Updated Path |
|---|---|
| |
| |
修复未存放在嵌套文件夹中的SPEC文档。此阶段优先运行,因为后续所有阶段都依赖正确的文件夹结构。
嵌套文件夹规则: 所有SPEC文档无论大小,都必须存放在嵌套文件夹中。
要求结构:
| SPEC类型 | 要求存放位置 |
|---|---|
| YAML | |
修复操作:
| 问题代码 | 问题描述 | 修复操作 |
|---|---|---|
| REV-STR001 | SPEC未在嵌套文件夹中 | 创建文件夹、移动文件、更新所有链接 |
| REV-STR002 | SPEC文件夹名称与SPEC ID不匹配 | 重命名文件夹以匹配 |
| REV-STR003 | SPEC大于25KB应分章节 | 标记为需人工评审 |
结构修复工作流:
python
def fix_spec_structure(spec_path: str) -> list[Fix]:
"""修复SPEC结构违规问题。"""
fixes = []
filename = os.path.basename(spec_path)
parent_folder = os.path.dirname(spec_path)
# 从文件名中提取SPEC ID和slug
match = re.match(r'SPEC-(\d+)_([^/]+)\.yaml', filename)
if not match:
return [] # 无法自动修复无效文件名
spec_id = match.group(1)
slug = match.group(2)
expected_folder = f"SPEC-{spec_id}_{slug}"
# 检查是否已在嵌套文件夹中
if os.path.basename(parent_folder) != expected_folder:
# 创建嵌套文件夹
new_folder = os.path.join(os.path.dirname(parent_folder), expected_folder)
os.makedirs(new_folder, exist_ok=True)
# 移动文件
new_path = os.path.join(new_folder, filename)
shutil.move(spec_path, new_path)
fixes.append(f"Moved {spec_path} to {new_path}")
# 更新YAML文件中的上游引用
content = Path(new_path).read_text()
updated_content = content.replace('../08_CTR/', '../../08_CTR/')
updated_content = updated_content.replace('../07_REQ/', '../../07_REQ/')
Path(new_path).write_text(updated_content)
fixes.append(f"Updated relative links for nested folder structure")
return fixes移动后的链接路径更新:
| 原路径 | 更新后路径 |
|---|---|
| |
| |
Phase 1: Create Missing Files
阶段1: 创建缺失文件
Creates files that are referenced but don't exist.
Scope:
| Missing File | Action | Template Used |
|---|---|---|
| Create schema definitions file | Schema template |
| Create configuration spec | Config template |
| Reference docs | Create placeholder | REF template |
SPEC Schema Template:
yaml
undefined创建被引用但不存在的文件。
范围:
| 缺失文件 | 操作 | 使用模板 |
|---|---|---|
| 创建Schema定义文件 | Schema模板 |
| 创建配置规范 | 配置模板 |
| 参考文档 | 创建占位符 | REF模板 |
SPEC Schema模板:
yaml
undefinedSPEC-NN: Schema Definitions
SPEC-NN: Schema Definitions
Auto-generated by doc-spec-fixer - requires completion
Auto-generated by doc-spec-fixer - requires completion
schemas:
version: "1.0.0"
spec_id: SPEC-NN
created: "YYYY-MM-DD"
status: draft
definitions:
TODO: Add schema definitions
ExampleSchema:
type: object
properties:
id:
type: string
description: "Unique identifier"
required:
- id
validation_rules:
TODO: Define validation rules
- rule_id: VR-001 description: "Placeholder validation rule" severity: error
**SPEC Configuration Template**:
```yamlschemas:
version: "1.0.0"
spec_id: SPEC-NN
created: "YYYY-MM-DD"
status: draft
definitions:
TODO: Add schema definitions
ExampleSchema:
type: object
properties:
id:
type: string
description: "Unique identifier"
required:
- id
validation_rules:
TODO: Define validation rules
- rule_id: VR-001 description: "Placeholder validation rule" severity: error
**SPEC配置模板**:
```yamlSPEC-NN: Configuration Specification
SPEC-NN: Configuration Specification
Auto-generated by doc-spec-fixer - requires completion
Auto-generated by doc-spec-fixer - requires completion
configuration:
spec_id: SPEC-NN
version: "1.0.0"
created: "YYYY-MM-DD"
environments:
development:
# TODO: Add development settings
log_level: debug
staging:
# TODO: Add staging settings
log_level: info
production:
# TODO: Add production settings
log_level: warn
feature_flags:
TODO: Define feature flags
- name: placeholder_flag description: "Placeholder feature flag" default: false
---configuration:
spec_id: SPEC-NN
version: "1.0.0"
created: "YYYY-MM-DD"
environments:
development:
# TODO: Add development settings
log_level: debug
staging:
# TODO: Add staging settings
log_level: info
production:
# TODO: Add production settings
log_level: warn
feature_flags:
TODO: Define feature flags
- name: placeholder_flag description: "Placeholder feature flag" default: false
---Phase 2: Fix Broken Links
阶段2: 修复失效链接
Updates links to point to correct locations.
Fix Actions:
| Issue Code | Issue | Fix Action |
|---|---|---|
| REV-L001 | Broken internal link | Update path or create target file |
| REV-L002 | External link unreachable | Add warning comment, keep link |
| REV-L003 | Absolute path used | Convert to relative path |
| REV-L006 | YAML include broken | Update YAML !include path |
| REV-L007 | Schema $ref invalid | Fix JSON Schema $ref path |
Path Resolution Logic:
python
def fix_link_path(spec_location: str, target_path: str) -> str:
"""Calculate correct relative path based on SPEC location."""
# SPEC files: docs/09_SPEC/SPEC-01.md
# Schema files: docs/09_SPEC/schemas/
# Config files: docs/09_SPEC/config/
if is_yaml_include(target_path):
return fix_yaml_include(spec_location, target_path)
elif is_schema_reference(target_path):
return fix_schema_ref(spec_location, target_path)
else:
return calculate_relative_path(spec_location, target_path)YAML Include Fix:
| Reference Type | Original | Fixed |
|---|---|---|
| Schema include | | |
| Config include | | |
| Relative include | | Validate path exists |
更新链接以指向正确位置。
修复操作:
| 问题代码 | 问题描述 | 修复操作 |
|---|---|---|
| REV-L001 | 内部链接失效 | 更新路径或创建目标文件 |
| REV-L002 | 外部链接无法访问 | 添加警告注释,保留链接 |
| REV-L003 | 使用绝对路径 | 转换为相对路径 |
| REV-L006 | YAML include失效 | 更新YAML !include路径 |
| REV-L007 | Schema $ref无效 | 修复JSON Schema $ref路径 |
路径解析逻辑:
python
def fix_link_path(spec_location: str, target_path: str) -> str:
"""根据SPEC位置计算正确的相对路径。"""
# SPEC文件: docs/09_SPEC/SPEC-01.md
# Schema文件: docs/09_SPEC/schemas/
# 配置文件: docs/09_SPEC/config/
if is_yaml_include(target_path):
return fix_yaml_include(spec_location, target_path)
elif is_schema_reference(target_path):
return fix_schema_ref(spec_location, target_path)
else:
return calculate_relative_path(spec_location, target_path)YAML Include修复:
| 引用类型 | 原内容 | 修复后内容 |
|---|---|---|
| Schema include | | |
| 配置include | | |
| 相对路径include | | 验证路径是否存在 |
Phase 3: Fix Element IDs
阶段3: 修复元素ID
Converts invalid element IDs to correct format.
SPEC Element ID Format:
SPEC documents are primarily YAML-based and use a different ID structure. Element IDs in SPEC follow the pattern: for YAML elements.
SPEC-NN.field.pathConversion Rules:
| Pattern | Issue | Conversion |
|---|---|---|
| Legacy numeric format | Convert to YAML path format |
| Invalid slug format | |
| Missing IDs | No element identifier | Generate based on YAML path |
YAML Path ID Generation:
python
def generate_yaml_element_id(spec_id: str, yaml_path: list) -> str:
"""Generate element ID from YAML path.
Example:
spec_id: "SPEC-01"
yaml_path: ["schemas", "definitions", "UserSchema"]
returns: "SPEC-01.schemas.definitions.UserSchema"
"""
return f"{spec_id}.{'.'.join(yaml_path)}"ID Normalization:
| Invalid ID | Normalized ID |
|---|---|
| |
| |
| |
将无效元素ID转换为正确格式。
SPEC元素ID格式:
SPEC文档主要基于YAML,使用不同的ID结构。SPEC中的元素ID遵循模式:(适用于YAML元素)。
SPEC-NN.field.path转换规则:
| 模式 | 问题 | 转换方式 |
|---|---|---|
| 旧版数字格式 | 转换为YAML路径格式 |
| 无效slug格式 | |
| 缺失ID | 无元素标识符 | 基于YAML路径生成 |
YAML路径ID生成:
python
def generate_yaml_element_id(spec_id: str, yaml_path: list) -> str:
"""从YAML路径生成元素ID。
示例:
spec_id: "SPEC-01"
yaml_path: ["schemas", "definitions", "UserSchema"]
返回: "SPEC-01.schemas.definitions.UserSchema"
"""
return f"{spec_id}.{'.'.join(yaml_path)}"ID标准化:
| 无效ID | 标准化ID |
|---|---|
| |
| |
| |
Phase 4: Fix Content Issues
阶段4: 修复内容问题
Addresses placeholders and incomplete content.
Fix Actions:
| Issue Code | Issue | Fix Action |
|---|---|---|
| REV-P001 | | Flag for manual completion (cannot auto-fix) |
| REV-P002 | | Flag for manual completion (cannot auto-fix) |
| REV-P003 | Template date | Replace with current date |
| REV-P004 | Template name | Replace with metadata author or flag |
| REV-P005 | Empty section | Add minimum template content |
| REV-Y001 | Invalid YAML syntax | Attempt YAML repair |
| REV-Y002 | Missing required YAML field | Add field with placeholder |
| REV-Y003 | Invalid YAML type | Convert to correct type |
| REV-Y004 | Duplicate YAML keys | Remove duplicates |
Auto-Replacements:
python
replacements = {
'YYYY-MM-DDTHH:MM:SS': datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
'YYYY-MM-DD': datetime.now().strftime('%Y-%m-%d'),
'MM/DD/YYYY': datetime.now().strftime('%m/%d/%Y'),
'[Current date]': datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
'"1.0.0"': f'"{calculate_version()}"',
}YAML Structure Repair:
| YAML Issue | Repair Action |
|---|---|
| Missing quotes | Add quotes around string values |
| Invalid indentation | Fix to 2-space indent |
| Duplicate keys | Keep first, log warning |
| Missing colons | Add colons after keys |
| Invalid boolean | Convert to true/false |
| Invalid null | Convert to null or ~ |
| Trailing spaces | Remove trailing whitespace |
| Missing list dash | Add - for list items |
处理占位符和不完整内容。
修复操作:
| 问题代码 | 问题描述 | 修复操作 |
|---|---|---|
| REV-P001 | | 标记为需人工完成(无法自动修复) |
| REV-P002 | | 标记为需人工完成(无法自动修复) |
| REV-P003 | 模板日期 | 替换为当前日期 |
| REV-P004 | 模板名称 | 替换为元数据作者或标记 |
| REV-P005 | 空章节 | 添加最小模板内容 |
| REV-Y001 | 无效YAML语法 | 尝试修复YAML |
| REV-Y002 | 缺失必填YAML字段 | 添加带占位符的字段 |
| REV-Y003 | 无效YAML类型 | 转换为正确类型 |
| REV-Y004 | 重复YAML键 | 移除重复项 |
自动替换:
python
replacements = {
'YYYY-MM-DDTHH:MM:SS': datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
'YYYY-MM-DD': datetime.now().strftime('%Y-%m-%d'),
'MM/DD/YYYY': datetime.now().strftime('%m/%d/%Y'),
'[Current date]': datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
'"1.0.0"': f'"{calculate_version()}"',
}YAML结构修复:
| YAML问题 | 修复操作 |
|---|---|
| 缺失引号 | 为字符串值添加引号 |
| 无效缩进 | 修复为2空格缩进 |
| 重复键 | 保留第一个,记录警告 |
| 缺失冒号 | 在键后添加冒号 |
| 无效布尔值 | 转换为true/false |
| 无效null | 转换为null或~ |
| 末尾空格 | 移除末尾空白 |
| 缺失列表短横线 | 为列表项添加- |
Phase 5: Update References
阶段5: 更新引用
Ensures traceability and cross-references are correct.
Fix Actions:
| Issue | Fix Action |
|---|---|
Missing | Add REQ traceability tag |
Missing | Add CTR traceability tag |
| Incorrect upstream path | Update to correct relative path |
| Missing traceability entry | Add to traceability matrix |
REQ/CTR Traceability Fix:
markdown
<!-- Before -->确保可追溯性和交叉引用正确。
修复操作:
| 问题 | 修复操作 |
|---|---|
缺失 | 添加REQ可追溯性标签 |
缺失 | 添加CTR可追溯性标签 |
| 上游路径错误 | 更新为正确的相对路径 |
| 缺失可追溯性条目 | 添加到可追溯性矩阵 |
REQ/CTR可追溯性修复:
markdown
<!-- 修复前 -->3. Schema Definitions
3. Schema Definitions
<!-- After -->
<!-- 修复后 -->
3. Schema Definitions
3. Schema Definitions
@req: REQ-01.28.01
@ctr: CTR-01-API
---@req: REQ-01.28.01
@ctr: CTR-01-API
---Phase 6: Handle Upstream Drift (Auto-Merge)
阶段6: 处理上游漂移(自动合并)
Addresses issues where upstream REQ/CTR documents have changed since SPEC creation using a tiered auto-merge system.
SPEC ID Pattern:
SPEC-NN-COMPONENT-SS- : Sequential spec number (01-99)
NN - : Component identifier (e.g., AUTH, API, DATA)
COMPONENT - : Sub-spec number within component (01-99)
SS
Example: , ,
SPEC-01-AUTH-13SPEC-02-API-05SPEC-03-DATA-21Drift Issue Codes (from ):
doc-spec-reviewer| Code | Severity | Description | Change % | Auto-Fix Possible |
|---|---|---|---|---|
| REV-D001 | Info | Minor upstream modification | < 5% | Yes (Tier 1) |
| REV-D002 | Warning | Moderate upstream modification | 5-15% | Yes (Tier 2) |
| REV-D003 | Info | Upstream document version incremented | N/A | Yes (update @ref version) |
| REV-D004 | Warning | New requirements added to upstream | 5-15% | Yes (Tier 2) |
| REV-D005 | Error | Critical upstream modification | > 15% | Yes (Tier 3) |
使用分层自动合并系统,处理SPEC创建后上游REQ/CTR文档发生变更的问题。
SPEC ID模式:
SPEC-NN-COMPONENT-SS- : 规范序号(01-99)
NN - : 组件标识符(例如:AUTH、API、DATA)
COMPONENT - : 组件内子规范序号(01-99)
SS
示例: , ,
SPEC-01-AUTH-13SPEC-02-API-05SPEC-03-DATA-21漂移问题代码(来自):
doc-spec-reviewer| 代码 | 严重程度 | 描述 | 变更百分比 | 可自动修复 |
|---|---|---|---|---|
| REV-D001 | 信息 | 上游小幅修改 | < 5% | 是(Tier 1) |
| REV-D002 | 警告 | 上游中度修改 | 5-15% | 是(Tier 2) |
| REV-D003 | 信息 | 上游文档版本升级 | N/A | 是(更新@ref版本) |
| REV-D004 | 警告 | 上游新增需求 | 5-15% | 是(Tier 2) |
| REV-D005 | 错误 | 上游重大修改 | > 15% | 是(Tier 3) |
Tiered Auto-Merge System
分层自动合并系统
Tier 1: Minor Changes (< 5% drift)
| Aspect | Behavior |
|---|---|
| Trigger | Change percentage < 5% |
| Action | Auto-merge spec updates |
| Version | Increment PATCH (1.0.0 -> 1.0.1) |
| Logging | Brief changelog entry |
| Review | No manual review required |
Tier 2: Moderate Changes (5-15% drift)
| Aspect | Behavior |
|---|---|
| Trigger | Change percentage 5-15% |
| Action | Auto-merge with detailed changelog |
| Version | Increment MINOR (1.0.0 -> 1.1.0) |
| Logging | Detailed changelog with diff summary |
| Review | Optional review recommended |
Tier 3: Major Changes (> 15% drift)
| Aspect | Behavior |
|---|---|
| Trigger | Change percentage > 15% |
| Action | Archive current version, trigger regeneration |
| Version | Increment MAJOR (1.0.0 -> 2.0.0) |
| Logging | Full archive manifest creation |
| Review | Manual review required post-regeneration |
Tier 1: 小幅变更(漂移<5%)
| 方面 | 行为 |
|---|---|
| 触发条件 | 变更百分比<5% |
| 操作 | 自动合并规范更新 |
| 版本 | 升级PATCH版本(1.0.0 -> 1.0.1) |
| 日志 | 简短变更日志条目 |
| 评审 | 无需人工评审 |
Tier 2: 中度变更(漂移5-15%)
| 方面 | 行为 |
|---|---|
| 触发条件 | 变更百分比5-15% |
| 操作 | 自动合并并生成详细变更日志 |
| 版本 | 升级MINOR版本(1.0.0 -> 1.1.0) |
| 日志 | 包含差异摘要的详细变更日志 |
| 评审 | 建议可选评审 |
Tier 3: 重大变更(漂移>15%)
| 方面 | 行为 |
|---|---|
| 触发条件 | 变更百分比>15% |
| 操作 | 归档当前版本,触发重新生成 |
| 版本 | 升级MAJOR版本(1.0.0 -> 2.0.0) |
| 日志 | 创建完整归档清单 |
| 评审 | 重新生成后需人工评审 |
Change Percentage Calculation
变更百分比计算
python
def calculate_drift_percentage(
upstream_doc: str,
spec_references: list,
upstream_modified: datetime,
spec_created: datetime
) -> float:
"""Calculate drift percentage between upstream and SPEC.
Factors:
- Line diff percentage in referenced sections
- Number of new/removed requirements
- Structural changes (new sections, moved content)
- Time since last sync (decay factor)
Returns:
float: Drift percentage (0.0 - 100.0)
"""
line_changes = count_line_changes(upstream_doc, spec_references)
total_lines = count_referenced_lines(upstream_doc, spec_references)
if total_lines == 0:
return 0.0
base_percentage = (line_changes / total_lines) * 100
# Apply time decay factor (older drift = more significant)
days_stale = (datetime.now() - spec_created).days
decay_factor = min(1.0 + (days_stale / 30) * 0.1, 1.5)
return min(base_percentage * decay_factor, 100.0)python
def calculate_drift_percentage(
upstream_doc: str,
spec_references: list,
upstream_modified: datetime,
spec_created: datetime
) -> float:
"""计算上游与SPEC之间的漂移百分比。
因素:
- 引用章节的行差异百分比
- 新增/移除需求的数量
- 结构变更(新增章节、内容移动)
- 上次同步后的时间(衰减因子)
返回:
float: 漂移百分比(0.0 - 100.0)
"""
line_changes = count_line_changes(upstream_doc, spec_references)
total_lines = count_referenced_lines(upstream_doc, spec_references)
if total_lines == 0:
return 0.0
base_percentage = (line_changes / total_lines) * 100
# 应用时间衰减因子(漂移越久,影响越大)
days_stale = (datetime.now() - spec_created).days
decay_factor = min(1.0 + (days_stale / 30) * 0.1, 1.5)
return min(base_percentage * decay_factor, 100.0)Auto-Generated SPEC IDs
自动生成SPEC ID
python
def generate_spec_id(
spec_number: int,
component: str,
sub_spec: int
) -> str:
"""Generate SPEC ID following SPEC-NN-COMPONENT-SS pattern.
Args:
spec_number: Main spec number (1-99)
component: Component identifier (e.g., AUTH, API, DATA)
sub_spec: Sub-spec number (1-99)
Returns:
str: Formatted SPEC ID
Example:
generate_spec_id(1, "AUTH", 13) -> "SPEC-01-AUTH-13"
"""
return f"SPEC-{spec_number:02d}-{component.upper()}-{sub_spec:02d}"python
def generate_spec_id(
spec_number: int,
component: str,
sub_spec: int
) -> str:
"""按照SPEC-NN-COMPONENT-SS模式生成SPEC ID。
参数:
spec_number: 主规范序号(1-99)
component: 组件标识符(例如:AUTH、API、DATA)
sub_spec: 子规范序号(1-99)
返回:
str: 格式化后的SPEC ID
示例:
generate_spec_id(1, "AUTH", 13) -> "SPEC-01-AUTH-13"
"""
return f"SPEC-{spec_number:02d}-{component.upper()}-{sub_spec:02d}"No-Deletion Policy
禁止删除策略
CRITICAL: SPECs are NEVER deleted. Mark as deprecated instead.
markdown
<!-- DEPRECATED: 2026-02-10 - Superseded by SPEC-01-AUTH-14 -->
<!-- Reason: Major upstream drift (>15%) triggered regeneration -->
<!-- Archive: archive/SPEC-01-AUTH-13_v1.2.0_20260210.md -->
---
title: "[DEPRECATED] SPEC-01-AUTH-13: Authentication Flow"
status: deprecated
superseded_by: SPEC-01-AUTH-14
---Deprecation Rules:
| Rule | Description |
|---|---|
| Never delete | SPECs are marked [DEPRECATED], not removed |
| Preserve history | Original content remains for audit trail |
| Add superseded_by | Link to replacement SPEC if applicable |
| Archive location | |
CRITICAL: SPEC文档绝不删除,而是标记为已弃用。
markdown
<!-- DEPRECATED: 2026-02-10 - 被SPEC-01-AUTH-14取代 -->
<!-- 原因: 上游重大漂移(>15%)触发重新生成 -->
<!-- 归档位置: archive/SPEC-01-AUTH-13_v1.2.0_20260210.md -->
---
title: "[DEPRECATED] SPEC-01-AUTH-13: Authentication Flow"
status: deprecated
superseded_by: SPEC-01-AUTH-14
---弃用规则:
| 规则 | 描述 |
|---|---|
| 绝不删除 | SPEC标记为[DEPRECATED],而非移除 |
| 保留历史 | 原始内容保留用于审计追踪 |
| 添加superseded_by | 若有替代SPEC,添加链接 |
| 归档位置 | |
Archive Manifest (Tier 3)
归档清单(Tier 3)
When Tier 3 triggers regeneration, create an archive manifest:
yaml
undefined当Tier 3触发重新生成时,创建归档清单:
yaml
undefinedarchive/SPEC-01-AUTH-13_archive_manifest.yaml
archive/SPEC-01-AUTH-13_archive_manifest.yaml
archive_manifest:
spec_id: SPEC-01-AUTH-13
archived_version: "1.2.0"
archive_date: "2026-02-10T16:00:00"
archive_reason: "Major upstream drift (>15%)"
drift_details:
upstream_documents:
- doc: REQ-01.md
drift_percentage: 23.5
lines_changed: 47
sections_affected: [3, 5, 7]
- doc: CTR-01-API.yaml
drift_percentage: 18.2
endpoints_changed: 5
schemas_modified: 3
total_drift: 20.85
trigger_tier: 3archived_files:
- source: docs/09_SPEC/SPEC-01-AUTH-13.md
archive: archive/SPEC-01-AUTH-13_v1.2.0_20260210.md
- source: docs/09_SPEC/schemas/SPEC-01-AUTH-13_schemas.yaml
archive: archive/SPEC-01-AUTH-13_schemas_v1.2.0_20260210.yaml
regeneration:
triggered: true
new_spec_id: SPEC-01-AUTH-14
new_version: "2.0.0"
downstream_impact:
tspec_documents:
- TSPEC-01-AUTH-13 (requires update)
tasks_documents:
- TASKS-01-AUTH-13 (requires review)
undefinedarchive_manifest:
spec_id: SPEC-01-AUTH-13
archived_version: "1.2.0"
archive_date: "2026-02-10T16:00:00"
archive_reason: "Major upstream drift (>15%)"
drift_details:
upstream_documents:
- doc: REQ-01.md
drift_percentage: 23.5
lines_changed: 47
sections_affected: [3, 5, 7]
- doc: CTR-01-API.yaml
drift_percentage: 18.2
endpoints_changed: 5
schemas_modified: 3
total_drift: 20.85
trigger_tier: 3archived_files:
- source: docs/09_SPEC/SPEC-01-AUTH-13.md
archive: archive/SPEC-01-AUTH-13_v1.2.0_20260210.md
- source: docs/09_SPEC/schemas/SPEC-01-AUTH-13_schemas.yaml
archive: archive/SPEC-01-AUTH-13_schemas_v1.2.0_20260210.yaml
regeneration:
triggered: true
new_spec_id: SPEC-01-AUTH-14
new_version: "2.0.0"
downstream_impact:
tspec_documents:
- TSPEC-01-AUTH-13 (需要更新)
tasks_documents:
- TASKS-01-AUTH-13 (需要评审)
undefinedEnhanced Drift Cache
增强漂移缓存
The file tracks drift state and merge history:
.drift_cache.jsonjson
{
"cache_version": "2.0",
"last_updated": "2026-02-10T16:00:00",
"specs": {
"SPEC-01-AUTH-13": {
"current_version": "1.2.0",
"created": "2026-02-05T10:00:00",
"last_sync": "2026-02-08T14:30:00",
"upstream_refs": {
"REQ-01.md": {
"last_known_hash": "a1b2c3d4",
"last_modified": "2026-02-08T09:00:00",
"sections_tracked": ["3.1", "3.2", "5.4"]
},
"CTR-01-API.yaml": {
"last_known_hash": "e5f6g7h8",
"last_modified": "2026-02-07T16:00:00",
"endpoints_tracked": ["/auth/login", "/auth/refresh"]
}
},
"merge_history": [
{
"date": "2026-02-06T11:00:00",
"tier": 1,
"drift_percentage": 3.2,
"version_before": "1.0.0",
"version_after": "1.0.1",
"changes_merged": ["REQ-01.md: Updated validation rules"]
},
{
"date": "2026-02-08T14:30:00",
"tier": 2,
"drift_percentage": 8.5,
"version_before": "1.0.1",
"version_after": "1.1.0",
"changes_merged": [
"REQ-01.md: Added new requirement REQ-01.28.05",
"CTR-01-API.yaml: Modified /auth/refresh response"
],
"changelog_file": "changelogs/SPEC-01-AUTH-13_v1.1.0_changelog.md"
}
],
"downstream_documents": {
"tspec": ["TSPEC-01-AUTH-13"],
"tasks": ["TASKS-01-AUTH-13"]
}
}
}
}.drift_cache.jsonjson
{
"cache_version": "2.0",
"last_updated": "2026-02-10T16:00:00",
"specs": {
"SPEC-01-AUTH-13": {
"current_version": "1.2.0",
"created": "2026-02-05T10:00:00",
"last_sync": "2026-02-08T14:30:00",
"upstream_refs": {
"REQ-01.md": {
"last_known_hash": "a1b2c3d4",
"last_modified": "2026-02-08T09:00:00",
"sections_tracked": ["3.1", "3.2", "5.4"]
},
"CTR-01-API.yaml": {
"last_known_hash": "e5f6g7h8",
"last_modified": "2026-02-07T16:00:00",
"endpoints_tracked": ["/auth/login", "/auth/refresh"]
}
},
"merge_history": [
{
"date": "2026-02-06T11:00:00",
"tier": 1,
"drift_percentage": 3.2,
"version_before": "1.0.0",
"version_after": "1.0.1",
"changes_merged": ["REQ-01.md: Updated validation rules"]
},
{
"date": "2026-02-08T14:30:00",
"tier": 2,
"drift_percentage": 8.5,
"version_before": "1.0.1",
"version_after": "1.1.0",
"changes_merged": [
"REQ-01.md: Added new requirement REQ-01.28.05",
"CTR-01-API.yaml: Modified /auth/refresh response"
],
"changelog_file": "changelogs/SPEC-01-AUTH-13_v1.1.0_changelog.md"
}
],
"downstream_documents": {
"tspec": ["TSPEC-01-AUTH-13"],
"tasks": ["TASKS-01-AUTH-13"]
}
}
}
}YAML Spec Format Handling
YAML规范格式处理
SPEC documents use embedded YAML blocks. Drift handling preserves YAML structure:
yaml
undefinedSPEC文档大量使用嵌入式YAML。漂移处理保留YAML结构:
yaml
undefinedMerged YAML section with drift metadata
合并后的YAML章节,包含漂移元数据
schemas:
_drift_metadata:
last_merge: "2026-02-08T14:30:00"
merge_tier: 2
upstream_version: "REQ-01.md@v1.3.0"
AuthRequest:
type: object
properties:
username:
type: string
# @merged: 2026-02-08 from REQ-01.28.01
minLength: 3
maxLength: 64
password:
type: string
format: password
# @merged: 2026-02-08 from REQ-01.28.02 (new validation)
minLength: 12
undefinedschemas:
_drift_metadata:
last_merge: "2026-02-08T14:30:00"
merge_tier: 2
upstream_version: "REQ-01.md@v1.3.0"
AuthRequest:
type: object
properties:
username:
type: string
# @merged: 2026-02-08 from REQ-01.28.01
minLength: 3
maxLength: 64
password:
type: string
format: password
# @merged: 2026-02-08 from REQ-01.28.02 (new validation)
minLength: 12
undefinedFix Actions by Tier
按分层的修复操作
| Tier | Version Change | Auto-Fix Actions |
|---|---|---|
| 1 | PATCH | Update referenced content, update @ref tags, brief changelog |
| 2 | MINOR | All Tier 1 actions + detailed changelog, diff summary, notification |
| 3 | MAJOR | Archive current, create manifest, mark deprecated, trigger regeneration |
Drift Marker Format (Updated for v2.0):
markdown
<!-- DRIFT-MERGED: Tier 1 | REQ-01.md | 3.2% | 2026-02-08 | v1.0.0 -> v1.0.1 -->
@req: [REQ-01.28.01](../07_REQ/REQ-01.md#req-01-28-01) @version:1.3.0
<!-- DRIFT-MERGED: Tier 2 | CTR-01-API.yaml | 8.5% | 2026-02-08 | v1.0.1 -> v1.1.0 -->
<!-- See: changelogs/SPEC-01-AUTH-13_v1.1.0_changelog.md -->
@ctr: [CTR-01-API](../08_CTR/CTR-01-API.md) @version:2.1.0
<!-- DRIFT-ARCHIVED: Tier 3 | 20.85% | 2026-02-10 | Regeneration triggered -->
<!-- Archive: archive/SPEC-01-AUTH-13_v1.2.0_20260210.md -->
<!-- New SPEC: SPEC-01-AUTH-14 -->| 分层 | 版本变更 | 自动修复操作 |
|---|---|---|
| 1 | PATCH | 更新引用内容、更新@ref标签、生成简短变更日志 |
| 2 | MINOR | 包含所有Tier1操作 + 详细变更日志、差异摘要、通知 |
| 3 | MAJOR | 归档当前版本、创建清单、标记为弃用、触发重新生成 |
漂移标记格式(v2.0更新):
markdown
<!-- DRIFT-MERGED: Tier 1 | REQ-01.md | 3.2% | 2026-02-08 | v1.0.0 -> v1.0.1 -->
@req: [REQ-01.28.01](../07_REQ/REQ-01.md#req-01-28-01) @version:1.3.0
<!-- DRIFT-MERGED: Tier 2 | CTR-01-API.yaml | 8.5% | 2026-02-08 | v1.0.1 -> v1.1.0 -->
<!-- 查看: changelogs/SPEC-01-AUTH-13_v1.1.0_changelog.md -->
@ctr: [CTR-01-API](../08_CTR/CTR-01-API.md) @version:2.1.0
<!-- DRIFT-ARCHIVED: Tier 3 | 20.85% | 2026-02-10 | 触发重新生成 -->
<!-- 归档位置: archive/SPEC-01-AUTH-13_v1.2.0_20260210.md -->
<!-- 新SPEC: SPEC-01-AUTH-14 -->YAML Structure Fixes
YAML结构修复
SPEC documents heavily rely on embedded YAML. This section details specific YAML repair strategies.
SPEC文档严重依赖嵌入式YAML。本节详细说明特定的YAML修复策略。
YAML Block Detection
YAML块检测
python
def find_yaml_blocks(content: str) -> list:
"""Find all YAML code blocks in markdown content."""
pattern = r'```ya?ml\n(.*?)```'
return re.findall(pattern, content, re.DOTALL)python
def find_yaml_blocks(content: str) -> list:
"""在markdown内容中查找所有YAML代码块。"""
pattern = r'```ya?ml\n(.*?)```'
return re.findall(pattern, content, re.DOTALL)Schema Validation
Schema验证
| Schema Type | Validation Rules |
|---|---|
| Data Schema | Must have |
| Config Schema | Must have environment sections |
| API Schema | Must have |
| Schema类型 | 验证规则 |
|---|---|
| 数据Schema | 必须包含 |
| 配置Schema | 必须包含环境章节 |
| API Schema | 必须包含 |
Common YAML Fixes
常见YAML修复
| Issue | Before | After |
|---|---|---|
| Unquoted special chars | | |
| Multiline without literal | | |
| Invalid anchor | | |
| Missing document start | | |
| 问题 | 修复前 | 修复后 |
|---|---|---|
| 未加引号的特殊字符 | | |
| 多行内容未使用字面量 | | |
| 无效锚点 | | |
| 缺失文档起始标记 | | |
Command Usage
命令用法
Basic Usage
基础用法
bash
undefinedbash
undefinedFix SPEC based on latest review
根据最新评审报告修复SPEC
/doc-spec-fixer SPEC-01
/doc-spec-fixer SPEC-01
Fix with explicit review report
使用指定评审报告修复
/doc-spec-fixer SPEC-01 --review-report SPEC-01.R_review_report_v001.md
/doc-spec-fixer SPEC-01 --review-report SPEC-01.R_review_report_v001.md
Fix and re-run review
修复后重新运行评审
/doc-spec-fixer SPEC-01 --revalidate
/doc-spec-fixer SPEC-01 --revalidate
Fix with iteration limit
设置迭代次数上限进行修复
/doc-spec-fixer SPEC-01 --revalidate --max-iterations 3
/doc-spec-fixer SPEC-01 --revalidate --max-iterations 3
Fix YAML only
仅修复YAML问题
/doc-spec-fixer SPEC-01 --fix-types yaml
undefined/doc-spec-fixer SPEC-01 --fix-types yaml
undefinedOptions
选项
| Option | Default | Description |
|---|---|---|
| latest | Specific review report to use |
| false | Run reviewer after fixes |
| 3 | Max fix-review cycles |
| all | Specific fix types (comma-separated) |
| true | Create missing reference files |
| true | Backup SPEC before fixing |
| false | Preview fixes without applying |
| true | Validate YAML after fixes |
| false | Interactive drift acknowledgment mode |
| true | Update .drift_cache.json after fixes |
| 选项 | 默认值 | 描述 |
|---|---|---|
| latest | 使用的特定评审报告 |
| false | 修复后运行评审工具 |
| 3 | 最大修复-评审循环次数 |
| all | 特定修复类型(逗号分隔) |
| true | 创建缺失的参考文件 |
| true | 修复前备份SPEC |
| false | 预览修复但不实际应用 |
| true | 修复后验证YAML |
| false | 交互式漂移确认模式 |
| true | 修复后更新.drift_cache.json |
Fix Types
修复类型
| Type | Description |
|---|---|
| Create missing schema, config docs |
| Fix link paths and YAML includes |
| Convert invalid element IDs to YAML paths |
| Fix placeholders, dates, names |
| Update REQ/CTR traceability and cross-references |
| Handle upstream drift detection issues |
| Fix YAML structure and syntax issues |
| All fix types (default) |
| 类型 | 描述 |
|---|---|
| 创建缺失的Schema、配置文档 |
| 修复链接路径和YAML includes |
| 将无效元素ID转换为YAML路径 |
| 修复占位符、日期、名称 |
| 更新REQ/CTR可追溯性和交叉引用 |
| 处理上游漂移检测问题 |
| 修复YAML结构和语法问题 |
| 所有修复类型(默认) |
Output Artifacts
输出产物
Fix Report
修复报告
Nested Folder Rule: ALL SPEC use nested folders () regardless of size. Fix reports are stored alongside the SPEC YAML file(s) in the nested folder.
SPEC-NN_{slug}/File Naming:
SPEC-NN.F_fix_report_vNNN.mdLocation: Inside the SPEC nested folder:
docs/09_SPEC/SPEC-NN_{slug}/Structure:
markdown
---
title: "SPEC-NN.F: Fix Report v001"
tags:
- spec
- fix-report
- quality-assurance
custom_fields:
document_type: fix-report
artifact_type: SPEC-FIX
layer: 9
parent_doc: SPEC-NN
source_review: SPEC-NN.R_review_report_v001.md
fix_date: "YYYY-MM-DDTHH:MM:SS"
fix_tool: doc-spec-fixer
fix_version: "1.0"
---嵌套文件夹规则: 所有SPEC使用嵌套文件夹(),无论大小。修复报告与SPEC YAML文件一起存储在嵌套文件夹中。
SPEC-NN_{slug}/文件命名:
SPEC-NN.F_fix_report_vNNN.md存储位置: SPEC嵌套文件夹内:
docs/09_SPEC/SPEC-NN_{slug}/结构:
markdown
---
title: "SPEC-NN.F: Fix Report v001"
tags:
- spec
- fix-report
- quality-assurance
custom_fields:
document_type: fix-report
artifact_type: SPEC-FIX
layer: 9
parent_doc: SPEC-NN
source_review: SPEC-NN.R_review_report_v001.md
fix_date: "YYYY-MM-DDTHH:MM:SS"
fix_tool: doc-spec-fixer
fix_version: "1.0"
---SPEC-NN Fix Report v001
SPEC-NN Fix Report v001
Summary
摘要
| Metric | Value |
|---|---|
| Source Review | SPEC-NN.R_review_report_v001.md |
| Issues in Review | 18 |
| Issues Fixed | 15 |
| Issues Remaining | 3 (manual review required) |
| Files Created | 2 |
| Files Modified | 1 |
| YAML Blocks Repaired | 4 |
| 指标 | 数值 |
|---|---|
| 来源评审报告 | SPEC-NN.R_review_report_v001.md |
| 评审发现问题数 | 18 |
| 已修复问题数 | 15 |
| remaining问题数 | 3(需人工评审) |
| 创建文件数 | 2 |
| 修改文件数 | 1 |
| 修复的YAML块数 | 4 |
Files Created
创建的文件
| File | Type | Location |
|---|---|---|
| SPEC-01_schemas.yaml | Schema Definitions | docs/09_SPEC/schemas/ |
| SPEC-01_config.yaml | Configuration Spec | docs/09_SPEC/config/ |
| 文件 | 类型 | 位置 |
|---|---|---|
| SPEC-01_schemas.yaml | Schema定义 | docs/09_SPEC/schemas/ |
| SPEC-01_config.yaml | 配置规范 | docs/09_SPEC/config/ |
YAML Repairs
YAML修复
| Block Location | Issue | Repair Applied |
|---|---|---|
| Line 45-62 | Invalid indentation | Fixed to 2-space |
| Line 98-105 | Missing quotes | Added quotes to values |
| Line 142-150 | Duplicate key | Removed duplicate |
| Line 201-215 | Invalid boolean | Converted to true/false |
| 块位置 | 问题 | 应用的修复 |
|---|---|---|
| 第45-62行 | 无效缩进 | 修复为2空格 |
| 第98-105行 | 缺失引号 | 为值添加引号 |
| 第142-150行 | 重复键 | 移除重复项 |
| 第201-215行 | 无效布尔值 | 转换为true/false |
Fixes Applied
应用的修复
| # | Issue Code | Issue | Fix Applied | File |
|---|---|---|---|---|
| 1 | REV-L006 | Broken YAML include | Updated include path | SPEC-01.md |
| 2 | REV-Y001 | Invalid YAML syntax | Repaired 4 blocks | SPEC-01.md |
| 3 | REV-L003 | Absolute path used | Converted to relative | SPEC-01.md |
| # | 问题代码 | 问题 | 应用的修复 | 文件 |
|---|---|---|---|---|
| 1 | REV-L006 | YAML include失效 | 更新include路径 | SPEC-01.md |
| 2 | REV-Y001 | 无效YAML语法 | 修复4个块 | SPEC-01.md |
| 3 | REV-L003 | 使用绝对路径 | 转换为相对路径 | SPEC-01.md |
Issues Requiring Manual Review
需人工评审的问题
| # | Issue Code | Issue | Location | Reason |
|---|---|---|---|---|
| 1 | REV-P001 | [TODO] placeholder | SPEC-01.md:L78 | Domain knowledge needed |
| 2 | REV-D002 | REQ content changed | REQ-01.28.01 | Review requirement update |
| # | 问题代码 | 问题 | 位置 | 原因 |
|---|---|---|---|---|
| 1 | REV-P001 | [TODO]占位符 | SPEC-01.md:L78 | 需要领域知识 |
| 2 | REV-D002 | REQ内容变更 | REQ-01.28.01 | 需评审需求更新 |
Upstream Drift Summary
上游漂移摘要
| Upstream Document | Reference | Modified | SPEC Updated | Days Stale | Action Required |
|---|---|---|---|---|---|
| REQ-01.md | SPEC-01:L57 | 2026-02-08 | 2026-02-05 | 3 | Review for changes |
| CTR-01-API.yaml | SPEC-01:L92 | 2026-02-09 | 2026-02-05 | 4 | Review for changes |
| 上游文档 | 引用位置 | 修改时间 | SPEC更新时间 | 过期天数 | 需执行操作 |
|---|---|---|---|---|---|
| REQ-01.md | SPEC-01:L57 | 2026-02-08 | 2026-02-05 | 3 | 评审变更 |
| CTR-01-API.yaml | SPEC-01:L92 | 2026-02-09 | 2026-02-05 | 4 | 评审变更 |
Validation After Fix
修复后验证
| Metric | Before | After | Delta |
|---|---|---|---|
| Review Score | 85 | 95 | +10 |
| Errors | 5 | 0 | -5 |
| Warnings | 6 | 2 | -4 |
| YAML Valid | No | Yes | Fixed |
| 指标 | 修复前 | 修复后 | 变化量 |
|---|---|---|---|
| 评审分数 | 85 | 95 | +10 |
| 错误数 | 5 | 0 | -5 |
| 警告数 | 6 | 2 | -4 |
| YAML有效性 | 否 | 是 | 已修复 |
Next Steps
下一步操作
- Complete [TODO] placeholders in SPEC-01.md
- Review upstream REQ/CTR drift
- Populate schema definitions in SPEC-01_schemas.yaml
- Run to verify fixes
/doc-spec-reviewer SPEC-01
---- 完成SPEC-01.md中的[TODO]占位符
- 评审上游REQ/CTR漂移
- 填充SPEC-01_schemas.yaml中的Schema定义
- 运行验证修复结果
/doc-spec-reviewer SPEC-01
---Integration with Autopilot
与Autopilot集成
This skill is invoked by in the Review -> Fix cycle:
doc-spec-autopilotmermaid
flowchart LR
subgraph Phase5["Phase 5: Review & Fix Cycle"]
A[doc-spec-reviewer] --> B{Score >= 90?}
B -->|No| C[doc-spec-fixer]
C --> D{Iteration < Max?}
D -->|Yes| A
D -->|No| E[Flag for Manual Review]
B -->|Yes| F[PASS]
endAutopilot Integration Points:
| Phase | Action | Skill |
|---|---|---|
| Phase 5a | Run initial review | |
| Phase 5b | Apply fixes if issues found | |
| Phase 5c | Re-run review | |
| Phase 5d | Repeat until pass or max iterations | Loop |
该工具在「评审 -> 修复」循环中被调用:
doc-spec-autopilotmermaid
flowchart LR
subgraph Phase5["Phase 5: Review & Fix Cycle"]
A[doc-spec-reviewer] --> B{Score >= 90?}
B -->|No| C[doc-spec-fixer]
C --> D{Iteration < Max?}
D -->|Yes| A
D -->|No| E[标记为需人工评审]
B -->|Yes| F[通过]
endAutopilot集成点:
| 阶段 | 操作 | 工具 |
|---|---|---|
| Phase 5a | 运行初始评审 | |
| Phase 5b | 若发现问题则应用修复 | |
| Phase 5c | 重新运行评审 | |
| Phase 5d | 重复直到通过或达到最大迭代次数 | 循环 |
Error Handling
错误处理
Recovery Actions
恢复操作
| Error | Action |
|---|---|
| Review report not found | Prompt to run |
| Cannot create file (permissions) | Log error, continue with other fixes |
| Cannot parse review report | Abort with clear error message |
| YAML parse error | Attempt repair, flag if unrecoverable |
| Max iterations exceeded | Generate report, flag for manual review |
| Schema validation failure | Log warning, continue with fixes |
| 错误 | 操作 |
|---|---|
| 未找到评审报告 | 提示先运行 |
| 无法创建文件(权限问题) | 记录错误,继续其他修复 |
| 无法解析评审报告 | 终止并给出清晰错误信息 |
| YAML解析错误 | 尝试修复,若无法恢复则标记 |
| 超过最大迭代次数 | 生成报告,标记为需人工评审 |
| Schema验证失败 | 记录警告,继续修复 |
Backup Strategy
备份策略
Before applying any fixes:
- Create backup in
tmp/backup/SPEC-NN_YYYYMMDD_HHMMSS/ - Copy all SPEC files to backup location
- Apply fixes to original files
- If error during fix, restore from backup
应用任何修复前:
- 在创建备份
tmp/backup/SPEC-NN_YYYYMMDD_HHMMSS/ - 将所有SPEC文件复制到备份位置
- 对原始文件应用修复
- 若修复过程中出错,从备份恢复
Related Skills
相关工具
| Skill | Relationship |
|---|---|
| Provides review report (input) |
| Orchestrates Review -> Fix cycle |
| Structural validation |
| Element ID standards |
| SPEC creation rules |
| REQ upstream traceability |
| CTR upstream traceability |
| 工具 | 关系 |
|---|---|
| 提供评审报告(输入) |
| 编排「评审 -> 修复」循环 |
| 结构验证 |
| 元素ID标准 |
| SPEC创建规则 |
| REQ上游可追溯性 |
| CTR上游可追溯性 |
Version History
版本历史
| Version | Date | Changes |
|---|---|---|
| 2.1 | 2026-02-11 | Structure Compliance: Added Phase 0 for nested folder rule enforcement (REV-STR001-STR003); Runs FIRST before other fix phases |
| 2.0 | 2026-02-10 | Enhanced Phase 6 with tiered auto-merge system (Tier 1: <5%, Tier 2: 5-15%, Tier 3: >15%); Auto-generated SPEC IDs (SPEC-NN-COMPONENT-SS pattern); No-deletion policy with [DEPRECATED] marking; Archive manifest creation for Tier 3; Enhanced drift cache with merge history; YAML spec format handling with drift metadata; Change percentage calculation algorithm |
| 1.0 | 2026-02-10 | Initial skill creation; 6-phase fix workflow; YAML structure repair; Schema and config file generation; YAML path-based element IDs; REQ/CTR drift handling; Integration with autopilot Review->Fix cycle |
| 版本 | 日期 | 变更 |
|---|---|---|
| 2.1 | 2026-02-11 | 结构合规: 新增阶段0用于强制执行嵌套文件夹规则(REV-STR001-STR003);优先于其他修复阶段运行 |
| 2.0 | 2026-02-10 | 增强阶段6,添加分层自动合并系统(Tier1: <5%, Tier2:5-15%, Tier3:>15%);自动生成SPEC ID(SPEC-NN-COMPONENT-SS模式);禁止删除策略,添加[DEPRECATED]标记;Tier3触发时创建归档清单;增强漂移缓存,包含合并历史;YAML规范格式处理,添加漂移元数据;变更百分比计算算法 |
| 1.0 | 2026-02-10 | 初始工具创建;6阶段修复工作流;YAML结构修复;Schema和配置文件生成;基于YAML路径的元素ID;REQ/CTR漂移处理;与Autopilot的「评审->修复」循环集成 |