1. 新增文档源管理模块(documentSource) - 控制器:documentSourceController.py - DAO层:documentSourceDao.py - 模型:documentSourceModel.py - 服务层:documentSourceService.py 2. 新增技能管理模块(skill) - 控制器:skillController.py - DAO层:skillDao.py - 模型:skillModel.py - 服务层:skillService.py 3. 新增AI服务(aiService.py) 4. 新增配置文件 - AI配置:config/ai_config.py - 技能配置:config/skills/test-case-generator/ 5. 新增SQL脚本 - 文档权限:add_document_permissions.sql - 模块状态字段:add_module_status_field.sql - 文档源表:create_document_source_table.sql - 技能规则:skills_rules_pgsql.sql
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""Shared utilities for skill-creator scripts."""
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
def parse_skill_md(skill_path: Path) -> tuple[str, str, str]:
|
|
"""Parse a SKILL.md file, returning (name, description, full_content)."""
|
|
content = (skill_path / "SKILL.md").read_text()
|
|
lines = content.split("\n")
|
|
|
|
if lines[0].strip() != "---":
|
|
raise ValueError("SKILL.md missing frontmatter (no opening ---)")
|
|
|
|
end_idx = None
|
|
for i, line in enumerate(lines[1:], start=1):
|
|
if line.strip() == "---":
|
|
end_idx = i
|
|
break
|
|
|
|
if end_idx is None:
|
|
raise ValueError("SKILL.md missing frontmatter (no closing ---)")
|
|
|
|
name = ""
|
|
description = ""
|
|
frontmatter_lines = lines[1:end_idx]
|
|
i = 0
|
|
while i < len(frontmatter_lines):
|
|
line = frontmatter_lines[i]
|
|
if line.startswith("name:"):
|
|
name = line[len("name:"):].strip().strip('"').strip("'")
|
|
elif line.startswith("description:"):
|
|
value = line[len("description:"):].strip()
|
|
# Handle YAML multiline indicators (>, |, >-, |-)
|
|
if value in (">", "|", ">-", "|-"):
|
|
continuation_lines: list[str] = []
|
|
i += 1
|
|
while i < len(frontmatter_lines) and (frontmatter_lines[i].startswith(" ") or frontmatter_lines[i].startswith("\t")):
|
|
continuation_lines.append(frontmatter_lines[i].strip())
|
|
i += 1
|
|
description = " ".join(continuation_lines)
|
|
continue
|
|
else:
|
|
description = value.strip('"').strip("'")
|
|
i += 1
|
|
|
|
return name, description, content
|