feat: 添加 skill 发布功能和混淆构建优化

- build.py: 移除 --obfuscate 参数,默认混淆模式;从 git config 读取 author,动态注入 SKILL.md
- publish.py: 新增发布脚本,自动 clone 目标仓库、同步 build/ 内容、git commit+push
- publish.sh: 新增一键构建+发布脚本
- skill-publishing spec: 新增发布规范
- skill-packaging spec: 更新构建规范
This commit is contained in:
2026-03-11 12:22:46 +08:00
parent 65c746c639
commit a8af3cc6c4
7 changed files with 665 additions and 122 deletions

View File

@@ -0,0 +1,82 @@
## Purpose
提供 skill 发布到目标 GitHub 仓库的能力,自动化将 build/ 目录内容同步到 skills 仓库。
## Requirements
### Requirement: publish.py 一键发布
系统 SHALL 提供 publish.py 脚本,运行后将 build/ 目录内容发布到目标仓库。
#### Scenario: 运行 publish.py 成功
- **WHEN** 用户执行 `uv run python publish.py`
- **THEN** 脚本完成所有发布步骤并输出成功信息
### Requirement: 使用临时目录 clone
系统 SHALL 在系统临时目录创建临时文件夹,用于 clone 目标仓库。
#### Scenario: 临时目录自动清理
- **WHEN** 发布完成或失败
- **THEN** 临时目录被自动清理
### Requirement: shallow clone
系统 SHALL 使用 `--depth 1` 参数 clone 目标仓库,加快 clone 速度。
#### Scenario: clone 参数正确
- **WHEN** 执行 git clone
- **THEN** 命令包含 `--depth 1` 参数
### Requirement: 目标仓库配置
系统 SHALL 硬编码目标仓库 URL 为 `https://github.com/lanyuanxiaoyao/skills.git`
#### Scenario: 目标仓库正确
- **WHEN** publish.py 执行 clone
- **THEN** clone 的仓库地址是 `https://github.com/lanyuanxiaoyao/skills.git`
### Requirement: 目标路径配置
系统 SHALL 将内容发布到目标仓库的 `skills/lyxy-document-reader/` 路径。
#### Scenario: 目标路径正确
- **WHEN** 文件同步完成
- **THEN** 文件位于 `skills/lyxy-document-reader/` 目录下
### Requirement: 清空目标路径
系统 SHALL 在复制前清空 `skills/lyxy-document-reader/` 目录内容。
#### Scenario: 旧文件被清理
- **WHEN** 开始同步文件
- **THEN** 目标目录下的旧文件被删除
### Requirement: 从 SKILL.md 读取版本号
系统 SHALL 解析 build/SKILL.md 的 YAML frontmatter 获取 version 字段。
#### Scenario: 版本号读取成功
- **WHEN** build/SKILL.md 包含 `metadata.version: "20260311_143022"`
- **THEN** publish.py 读取到版本号 "20260311_143022"
### Requirement: git 提交信息
系统 SHALL 使用包含版本号的 commit message格式为 `publish: lyxy-document-reader <version>`
#### Scenario: commit message 正确
- **WHEN** 版本号是 20260311_143022
- **THEN** commit message 是 `publish: lyxy-document-reader 20260311_143022`
### Requirement: git 提交并推送
系统 SHALL 执行 git add、git commit 和 git push 操作。
#### Scenario: git 操作成功
- **WHEN** 文件同步完成
- **THEN** 系统执行 git add .、git commit 和 git push
### Requirement: build 目录存在检查
系统 SHALL 在开始前检查 build/ 目录是否存在,不存在则提示错误。
#### Scenario: build 目录不存在
- **WHEN** build/ 目录不存在
- **THEN** 脚本显示错误信息并退出
### Requirement: SKILL.md 存在检查
系统 SHALL 检查 build/SKILL.md 是否存在,不存在则提示错误。
#### Scenario: build/SKILL.md 不存在
- **WHEN** build/SKILL.md 不存在
- **THEN** 脚本显示错误信息并退出