doc-spec-fixer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

doc-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
doc-spec-reviewer
(which identifies issues) and the corrected SPEC, enabling iterative improvement cycles.
Layer: 9 (SPEC Quality Improvement)
Upstream: REQ documents, CTR documents, SPEC document, Review Report (
SPEC-NN.R_review_report_vNNN.md
)
Downstream: Fixed SPEC, Fix Report (
SPEC-NN.F_fix_report_vNNN.md
)

一款自动化修复工具,可读取最新评审报告并对SPEC(规范)文档进行修复。该工具填补了
doc-spec-reviewer
(用于识别问题)与修正后SPEC文档之间的空白,支持迭代优化循环。
层级: 9(SPEC质量优化)
上游依赖: REQ文档、CTR文档、SPEC文档、评审报告(
SPEC-NN.R_review_report_vNNN.md
下游产出: 修复后的SPEC文档、修复报告(
SPEC-NN.F_fix_report_vNNN.md

When to Use This Skill

使用场景

Use
doc-spec-fixer
when:
  • After Review: Run after
    doc-spec-reviewer
    identifies issues
  • 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
    doc-spec-reviewer
    first)
  • Creating new SPEC (use
    doc-spec
    or
    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

工具依赖

SkillPurposeWhen Used
doc-spec-reviewer
Source of issues to fixInput (reads review report)
doc-naming
Element ID standardsFix element IDs
doc-spec
SPEC creation rulesCreate missing sections
doc-req
REQ traceabilityValidate upstream links
doc-ctr
CTR traceabilityValidate contract links

工具用途使用时机
doc-spec-reviewer
提供待修复的问题来源输入(读取评审报告)
doc-naming
元素ID标准修复元素ID
doc-spec
SPEC文档创建规则创建缺失章节
doc-req
REQ可追溯性验证上游链接
doc-ctr
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| Q

mermaid
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 -->|否| Q

Fix 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 TypeRequired Location
YAML
docs/09_SPEC/SPEC-NN_{slug}/SPEC-NN_{slug}.yaml
Fix Actions:
Issue CodeIssueFix Action
REV-STR001SPEC not in nested folderCreate folder, move file, update all links
REV-STR002SPEC folder name doesn't match SPEC IDRename folder to match
REV-STR003SPEC >25KB should be sectionedFlag 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 fixes
Link Path Updates After Move:
Original PathUpdated Path
../08_CTR/CTR-01_slug/CTR-01.yaml
../../08_CTR/CTR-01_slug/CTR-01.yaml
../07_REQ/REQ-01_slug/REQ-01.md
../../07_REQ/REQ-01_slug/REQ-01.md

修复未存放在嵌套文件夹中的SPEC文档。此阶段优先运行,因为后续所有阶段都依赖正确的文件夹结构。
嵌套文件夹规则: 所有SPEC文档无论大小,都必须存放在嵌套文件夹中。
要求结构:
SPEC类型要求存放位置
YAML
docs/09_SPEC/SPEC-NN_{slug}/SPEC-NN_{slug}.yaml
修复操作:
问题代码问题描述修复操作
REV-STR001SPEC未在嵌套文件夹中创建文件夹、移动文件、更新所有链接
REV-STR002SPEC文件夹名称与SPEC ID不匹配重命名文件夹以匹配
REV-STR003SPEC大于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
移动后的链接路径更新:
原路径更新后路径
../08_CTR/CTR-01_slug/CTR-01.yaml
../../08_CTR/CTR-01_slug/CTR-01.yaml
../07_REQ/REQ-01_slug/REQ-01.md
../../07_REQ/REQ-01_slug/REQ-01.md

Phase 1: Create Missing Files

阶段1: 创建缺失文件

Creates files that are referenced but don't exist.
Scope:
Missing FileActionTemplate Used
SPEC-NN_schemas.yaml
Create schema definitions fileSchema template
SPEC-NN_config.yaml
Create configuration specConfig template
Reference docsCreate placeholderREF template
SPEC Schema Template:
yaml
undefined
创建被引用但不存在的文件。
范围:
缺失文件操作使用模板
SPEC-NN_schemas.yaml
创建Schema定义文件Schema模板
SPEC-NN_config.yaml
创建配置规范配置模板
参考文档创建占位符REF模板
SPEC Schema模板:
yaml
undefined

SPEC-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**:

```yaml
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配置模板**:

```yaml

SPEC-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 CodeIssueFix Action
REV-L001Broken internal linkUpdate path or create target file
REV-L002External link unreachableAdd warning comment, keep link
REV-L003Absolute path usedConvert to relative path
REV-L006YAML include brokenUpdate YAML !include path
REV-L007Schema $ref invalidFix 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 TypeOriginalFixed
Schema include
!include schema.yaml
!include ./schemas/schema.yaml
Config include
!include config.yaml
!include ./config/config.yaml
Relative include
!include ../other.yaml
Validate path exists

更新链接以指向正确位置。
修复操作:
问题代码问题描述修复操作
REV-L001内部链接失效更新路径或创建目标文件
REV-L002外部链接无法访问添加警告注释,保留链接
REV-L003使用绝对路径转换为相对路径
REV-L006YAML include失效更新YAML !include路径
REV-L007Schema $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 schema.yaml
!include ./schemas/schema.yaml
配置include
!include config.yaml
!include ./config/config.yaml
相对路径include
!include ../other.yaml
验证路径是否存在

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:
SPEC-NN.field.path
for YAML elements.
Conversion Rules:
PatternIssueConversion
SPEC.NN.XX.SS
Legacy numeric formatConvert to YAML path format
SPEC-NN-XXX
Invalid slug format
SPEC-NN.section.element
Missing IDsNo element identifierGenerate 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 IDNormalized ID
SPEC-01 Schema 1
SPEC-01.schemas.schema_1
SPEC-01/config/db
SPEC-01.config.db
spec_01_auth
SPEC-01.auth

将无效元素ID转换为正确格式。
SPEC元素ID格式:
SPEC文档主要基于YAML,使用不同的ID结构。SPEC中的元素ID遵循模式:
SPEC-NN.field.path
(适用于YAML元素)。
转换规则:
模式问题转换方式
SPEC.NN.XX.SS
旧版数字格式转换为YAML路径格式
SPEC-NN-XXX
无效slug格式
SPEC-NN.section.element
缺失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
SPEC-01 Schema 1
SPEC-01.schemas.schema_1
SPEC-01/config/db
SPEC-01.config.db
spec_01_auth
SPEC-01.auth

Phase 4: Fix Content Issues

阶段4: 修复内容问题

Addresses placeholders and incomplete content.
Fix Actions:
Issue CodeIssueFix Action
REV-P001
[TODO]
placeholder
Flag for manual completion (cannot auto-fix)
REV-P002
[TBD]
placeholder
Flag for manual completion (cannot auto-fix)
REV-P003Template date
YYYY-MM-DD
Replace with current date
REV-P004Template name
[Name]
Replace with metadata author or flag
REV-P005Empty sectionAdd minimum template content
REV-Y001Invalid YAML syntaxAttempt YAML repair
REV-Y002Missing required YAML fieldAdd field with placeholder
REV-Y003Invalid YAML typeConvert to correct type
REV-Y004Duplicate YAML keysRemove 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 IssueRepair Action
Missing quotesAdd quotes around string values
Invalid indentationFix to 2-space indent
Duplicate keysKeep first, log warning
Missing colonsAdd colons after keys
Invalid booleanConvert to true/false
Invalid nullConvert to null or ~
Trailing spacesRemove trailing whitespace
Missing list dashAdd - for list items

处理占位符和不完整内容。
修复操作:
问题代码问题描述修复操作
REV-P001
[TODO]
占位符
标记为需人工完成(无法自动修复)
REV-P002
[TBD]
占位符
标记为需人工完成(无法自动修复)
REV-P003模板日期
YYYY-MM-DD
替换为当前日期
REV-P004模板名称
[Name]
替换为元数据作者或标记
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:
IssueFix Action
Missing
@req:
reference
Add REQ traceability tag
Missing
@ctr:
reference
Add CTR traceability tag
Incorrect upstream pathUpdate to correct relative path
Missing traceability entryAdd to traceability matrix
REQ/CTR Traceability Fix:
markdown
<!-- Before -->
确保可追溯性和交叉引用正确。
修复操作:
问题修复操作
缺失
@req:
引用
添加REQ可追溯性标签
缺失
@ctr:
引用
添加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
  • NN
    : Sequential spec number (01-99)
  • COMPONENT
    : Component identifier (e.g., AUTH, API, DATA)
  • SS
    : Sub-spec number within component (01-99)
Example:
SPEC-01-AUTH-13
,
SPEC-02-API-05
,
SPEC-03-DATA-21
Drift Issue Codes (from
doc-spec-reviewer
):
CodeSeverityDescriptionChange %Auto-Fix Possible
REV-D001InfoMinor upstream modification< 5%Yes (Tier 1)
REV-D002WarningModerate upstream modification5-15%Yes (Tier 2)
REV-D003InfoUpstream document version incrementedN/AYes (update @ref version)
REV-D004WarningNew requirements added to upstream5-15%Yes (Tier 2)
REV-D005ErrorCritical upstream modification> 15%Yes (Tier 3)
使用分层自动合并系统,处理SPEC创建后上游REQ/CTR文档发生变更的问题。
SPEC ID模式:
SPEC-NN-COMPONENT-SS
  • NN
    : 规范序号(01-99)
  • COMPONENT
    : 组件标识符(例如:AUTH、API、DATA)
  • SS
    : 组件内子规范序号(01-99)
示例:
SPEC-01-AUTH-13
,
SPEC-02-API-05
,
SPEC-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)
AspectBehavior
TriggerChange percentage < 5%
ActionAuto-merge spec updates
VersionIncrement PATCH (1.0.0 -> 1.0.1)
LoggingBrief changelog entry
ReviewNo manual review required
Tier 2: Moderate Changes (5-15% drift)
AspectBehavior
TriggerChange percentage 5-15%
ActionAuto-merge with detailed changelog
VersionIncrement MINOR (1.0.0 -> 1.1.0)
LoggingDetailed changelog with diff summary
ReviewOptional review recommended
Tier 3: Major Changes (> 15% drift)
AspectBehavior
TriggerChange percentage > 15%
ActionArchive current version, trigger regeneration
VersionIncrement MAJOR (1.0.0 -> 2.0.0)
LoggingFull archive manifest creation
ReviewManual 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:
RuleDescription
Never deleteSPECs are marked [DEPRECATED], not removed
Preserve historyOriginal content remains for audit trail
Add superseded_byLink to replacement SPEC if applicable
Archive location
archive/
folder with version and date
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/
文件夹,包含版本和日期

Archive Manifest (Tier 3)

归档清单(Tier 3)

When Tier 3 triggers regeneration, create an archive manifest:
yaml
undefined
当Tier 3触发重新生成时,创建归档清单:
yaml
undefined

archive/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: 3
archived_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)
undefined
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: 3
archived_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 (需要评审)
undefined

Enhanced Drift Cache

增强漂移缓存

The
.drift_cache.json
file tracks drift state and merge history:
json
{
  "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.json
文件追踪漂移状态和合并历史:
json
{
  "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
undefined
SPEC文档大量使用嵌入式YAML。漂移处理保留YAML结构:
yaml
undefined

Merged 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
undefined
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
undefined

Fix Actions by Tier

按分层的修复操作

TierVersion ChangeAuto-Fix Actions
1PATCHUpdate referenced content, update @ref tags, brief changelog
2MINORAll Tier 1 actions + detailed changelog, diff summary, notification
3MAJORArchive 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 -->

分层版本变更自动修复操作
1PATCH更新引用内容、更新@ref标签、生成简短变更日志
2MINOR包含所有Tier1操作 + 详细变更日志、差异摘要、通知
3MAJOR归档当前版本、创建清单、标记为弃用、触发重新生成
漂移标记格式(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 TypeValidation Rules
Data SchemaMust have
type
,
properties
Config SchemaMust have environment sections
API SchemaMust have
paths
or
endpoints
Schema类型验证规则
数据Schema必须包含
type
properties
配置Schema必须包含环境章节
API Schema必须包含
paths
endpoints

Common YAML Fixes

常见YAML修复

IssueBeforeAfter
Unquoted special chars
value: @special
value: "@special"
Multiline without literal
desc: line1\nline2
desc: |\n  line1\n  line2
Invalid anchor
&anchor name
&anchor_name
Missing document start
key: value
---\nkey: value

问题修复前修复后
未加引号的特殊字符
value: @special
value: "@special"
多行内容未使用字面量
desc: line1\nline2
desc: |\n  line1\n  line2
无效锚点
&anchor name
&anchor_name
缺失文档起始标记
key: value
---\nkey: value

Command Usage

命令用法

Basic Usage

基础用法

bash
undefined
bash
undefined

Fix 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
undefined

Options

选项

OptionDefaultDescription
--review-report
latestSpecific review report to use
--revalidate
falseRun reviewer after fixes
--max-iterations
3Max fix-review cycles
--fix-types
allSpecific fix types (comma-separated)
--create-missing
trueCreate missing reference files
--backup
trueBackup SPEC before fixing
--dry-run
falsePreview fixes without applying
--validate-yaml
trueValidate YAML after fixes
--acknowledge-drift
falseInteractive drift acknowledgment mode
--update-drift-cache
trueUpdate .drift_cache.json after fixes
选项默认值描述
--review-report
latest使用的特定评审报告
--revalidate
false修复后运行评审工具
--max-iterations
3最大修复-评审循环次数
--fix-types
all特定修复类型(逗号分隔)
--create-missing
true创建缺失的参考文件
--backup
true修复前备份SPEC
--dry-run
false预览修复但不实际应用
--validate-yaml
true修复后验证YAML
--acknowledge-drift
false交互式漂移确认模式
--update-drift-cache
true修复后更新.drift_cache.json

Fix Types

修复类型

TypeDescription
missing_files
Create missing schema, config docs
broken_links
Fix link paths and YAML includes
element_ids
Convert invalid element IDs to YAML paths
content
Fix placeholders, dates, names
references
Update REQ/CTR traceability and cross-references
drift
Handle upstream drift detection issues
yaml
Fix YAML structure and syntax issues
all
All fix types (default)

类型描述
missing_files
创建缺失的Schema、配置文档
broken_links
修复链接路径和YAML includes
element_ids
将无效元素ID转换为YAML路径
content
修复占位符、日期、名称
references
更新REQ/CTR可追溯性和交叉引用
drift
处理上游漂移检测问题
yaml
修复YAML结构和语法问题
all
所有修复类型(默认)

Output Artifacts

输出产物

Fix Report

修复报告

Nested Folder Rule: ALL SPEC use nested folders (
SPEC-NN_{slug}/
) regardless of size. Fix reports are stored alongside the SPEC YAML file(s) in the nested folder.
File Naming:
SPEC-NN.F_fix_report_vNNN.md
Location: 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-NN_{slug}/
),无论大小。修复报告与SPEC YAML文件一起存储在嵌套文件夹中。
文件命名:
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

摘要

MetricValue
Source ReviewSPEC-NN.R_review_report_v001.md
Issues in Review18
Issues Fixed15
Issues Remaining3 (manual review required)
Files Created2
Files Modified1
YAML Blocks Repaired4
指标数值
来源评审报告SPEC-NN.R_review_report_v001.md
评审发现问题数18
已修复问题数15
remaining问题数3(需人工评审)
创建文件数2
修改文件数1
修复的YAML块数4

Files Created

创建的文件

FileTypeLocation
SPEC-01_schemas.yamlSchema Definitionsdocs/09_SPEC/schemas/
SPEC-01_config.yamlConfiguration Specdocs/09_SPEC/config/
文件类型位置
SPEC-01_schemas.yamlSchema定义docs/09_SPEC/schemas/
SPEC-01_config.yaml配置规范docs/09_SPEC/config/

YAML Repairs

YAML修复

Block LocationIssueRepair Applied
Line 45-62Invalid indentationFixed to 2-space
Line 98-105Missing quotesAdded quotes to values
Line 142-150Duplicate keyRemoved duplicate
Line 201-215Invalid booleanConverted to true/false
块位置问题应用的修复
第45-62行无效缩进修复为2空格
第98-105行缺失引号为值添加引号
第142-150行重复键移除重复项
第201-215行无效布尔值转换为true/false

Fixes Applied

应用的修复

#Issue CodeIssueFix AppliedFile
1REV-L006Broken YAML includeUpdated include pathSPEC-01.md
2REV-Y001Invalid YAML syntaxRepaired 4 blocksSPEC-01.md
3REV-L003Absolute path usedConverted to relativeSPEC-01.md
#问题代码问题应用的修复文件
1REV-L006YAML include失效更新include路径SPEC-01.md
2REV-Y001无效YAML语法修复4个块SPEC-01.md
3REV-L003使用绝对路径转换为相对路径SPEC-01.md

Issues Requiring Manual Review

需人工评审的问题

#Issue CodeIssueLocationReason
1REV-P001[TODO] placeholderSPEC-01.md:L78Domain knowledge needed
2REV-D002REQ content changedREQ-01.28.01Review requirement update
#问题代码问题位置原因
1REV-P001[TODO]占位符SPEC-01.md:L78需要领域知识
2REV-D002REQ内容变更REQ-01.28.01需评审需求更新

Upstream Drift Summary

上游漂移摘要

Upstream DocumentReferenceModifiedSPEC UpdatedDays StaleAction Required
REQ-01.mdSPEC-01:L572026-02-082026-02-053Review for changes
CTR-01-API.yamlSPEC-01:L922026-02-092026-02-054Review for changes
上游文档引用位置修改时间SPEC更新时间过期天数需执行操作
REQ-01.mdSPEC-01:L572026-02-082026-02-053评审变更
CTR-01-API.yamlSPEC-01:L922026-02-092026-02-054评审变更

Validation After Fix

修复后验证

MetricBeforeAfterDelta
Review Score8595+10
Errors50-5
Warnings62-4
YAML ValidNoYesFixed
指标修复前修复后变化量
评审分数8595+10
错误数50-5
警告数62-4
YAML有效性已修复

Next Steps

下一步操作

  1. Complete [TODO] placeholders in SPEC-01.md
  2. Review upstream REQ/CTR drift
  3. Populate schema definitions in SPEC-01_schemas.yaml
  4. Run
    /doc-spec-reviewer SPEC-01
    to verify fixes

---
  1. 完成SPEC-01.md中的[TODO]占位符
  2. 评审上游REQ/CTR漂移
  3. 填充SPEC-01_schemas.yaml中的Schema定义
  4. 运行
    /doc-spec-reviewer SPEC-01
    验证修复结果

---

Integration with Autopilot

与Autopilot集成

This skill is invoked by
doc-spec-autopilot
in the Review -> Fix cycle:
mermaid
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]
    end
Autopilot Integration Points:
PhaseActionSkill
Phase 5aRun initial review
doc-spec-reviewer
Phase 5bApply fixes if issues found
doc-spec-fixer
Phase 5cRe-run review
doc-spec-reviewer
Phase 5dRepeat until pass or max iterationsLoop

该工具在「评审 -> 修复」循环中被
doc-spec-autopilot
调用:
mermaid
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[通过]
    end
Autopilot集成点:
阶段操作工具
Phase 5a运行初始评审
doc-spec-reviewer
Phase 5b若发现问题则应用修复
doc-spec-fixer
Phase 5c重新运行评审
doc-spec-reviewer
Phase 5d重复直到通过或达到最大迭代次数循环

Error Handling

错误处理

Recovery Actions

恢复操作

ErrorAction
Review report not foundPrompt to run
doc-spec-reviewer
first
Cannot create file (permissions)Log error, continue with other fixes
Cannot parse review reportAbort with clear error message
YAML parse errorAttempt repair, flag if unrecoverable
Max iterations exceededGenerate report, flag for manual review
Schema validation failureLog warning, continue with fixes
错误操作
未找到评审报告提示先运行
doc-spec-reviewer
无法创建文件(权限问题)记录错误,继续其他修复
无法解析评审报告终止并给出清晰错误信息
YAML解析错误尝试修复,若无法恢复则标记
超过最大迭代次数生成报告,标记为需人工评审
Schema验证失败记录警告,继续修复

Backup Strategy

备份策略

Before applying any fixes:
  1. Create backup in
    tmp/backup/SPEC-NN_YYYYMMDD_HHMMSS/
  2. Copy all SPEC files to backup location
  3. Apply fixes to original files
  4. If error during fix, restore from backup

应用任何修复前:
  1. tmp/backup/SPEC-NN_YYYYMMDD_HHMMSS/
    创建备份
  2. 将所有SPEC文件复制到备份位置
  3. 对原始文件应用修复
  4. 若修复过程中出错,从备份恢复

Related Skills

相关工具

SkillRelationship
doc-spec-reviewer
Provides review report (input)
doc-spec-autopilot
Orchestrates Review -> Fix cycle
doc-spec-validator
Structural validation
doc-naming
Element ID standards
doc-spec
SPEC creation rules
doc-req
REQ upstream traceability
doc-ctr
CTR upstream traceability

工具关系
doc-spec-reviewer
提供评审报告(输入)
doc-spec-autopilot
编排「评审 -> 修复」循环
doc-spec-validator
结构验证
doc-naming
元素ID标准
doc-spec
SPEC创建规则
doc-req
REQ上游可追溯性
doc-ctr
CTR上游可追溯性

Version History

版本历史

VersionDateChanges
2.12026-02-11Structure Compliance: Added Phase 0 for nested folder rule enforcement (REV-STR001-STR003); Runs FIRST before other fix phases
2.02026-02-10Enhanced 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.02026-02-10Initial 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.12026-02-11结构合规: 新增阶段0用于强制执行嵌套文件夹规则(REV-STR001-STR003);优先于其他修复阶段运行
2.02026-02-10增强阶段6,添加分层自动合并系统(Tier1: <5%, Tier2:5-15%, Tier3:>15%);自动生成SPEC ID(SPEC-NN-COMPONENT-SS模式);禁止删除策略,添加[DEPRECATED]标记;Tier3触发时创建归档清单;增强漂移缓存,包含合并历史;YAML规范格式处理,添加漂移元数据;变更百分比计算算法
1.02026-02-10初始工具创建;6阶段修复工作流;YAML结构修复;Schema和配置文件生成;基于YAML路径的元素ID;REQ/CTR漂移处理;与Autopilot的「评审->修复」循环集成