闲社服务运行正常AI智能体自动化平台
r

发布前准备

技能标识:release-prep

Deep code audit + documentation sync + release preparation for Python packages. Use when preparing a release, checking code quality before publishing, auditing code vs docs, fixing pre-release issues, generating changelogs, bumping versions, or publishing to PyPI. Triggers on "release", "prepare release", "audit code", "check docs", "ready to release?", "publish", "pre-release check", "code review before release".

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

发布前准备

release-prep — 发布准备与代码审计

对Python包进行代码质量、文档完整性和发布就绪状态的深度自动化分析。可自动修复发现的问题。

模式

  • - audit(默认)— 仅分析和报告
  • fix — 分析,然后通过编码代理自动修复问题
  • release — 完整流水线:审计 → 修复 → 变更日志 → 版本号更新 → 打标签 → 发布

从用户请求中解析模式。如果不明确,默认为audit。

第一阶段:深度代码审计

运行所有检查,将结果收集到结构化报告中。

1.1 测试套件

bash

运行完整测试套件并生成覆盖率报告


python -m pytest tests/ -q --tb=short --co -q 2>/dev/null | tail -1 # 统计测试数量
python -m pytest tests/ -q --tb=short 2>&1 | tail -5 # 运行测试

报告:总测试数、通过数、失败数、跳过数、覆盖率百分比(如果pytest-cov可用)。

如果任何测试失败,则为阻塞项。

1.2 静态分析

bash

Ruff(如果可用)


ruff check src/ --statistics 2>&1 | tail -20

Mypy(如果可用)

mypy src/ --no-error-summary 2>&1 | grep error: | wc -l

报告:按类别统计的错误数量。如果错误数 > 0,则为阻塞项(警告可接受)。

1.3 死代码检测

bash

查找未使用的导入


ruff check src/ --select F401 2>&1

查找没有调用者的函数(启发式)

grep -rn ^def \|^async def src/ --include=*.py | while read line; do func=$(echo $line | sed s/.def \([a-zA-Z_]\).*/\1/) if [ $func != init ] && [ $func != ]; then count=$(grep -rn $func src/ --include=*.py | grep -v ^def \|^async def | wc -l) if [ $count -lt 2 ]; then echo 可能未使用: $line fi fi done

报告:潜在死代码列表。警告级别。

1.4 API完整性

bash

公共API(all导出)与实际公共函数对比


python3 -c
import ast, sys, pathlib
for f in pathlib.Path(src/).rglob(*.py):
tree = ast.parse(f.read_text())
all_list = [n.value.s for n in ast.walk(tree)
if isinstance(n, ast.Assign)
for t in n.targets if isinstance(t, ast.Name) and t.id == all
for elt in n.value.elts if isinstance(elt, ast.Constant)]
if all_list:
funcs = [n.name for n in ast.walk(tree)
if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef))
and not n.name.startswith(_)]
missing = [f for f in funcs if f not in all_list]
if missing:
print(f{f}: 公共但不在all中: {missing})

报告:all中缺失的函数。警告级别。

1.5 依赖检查

bash

检查固定版本与未固定版本依赖


grep -E dependencies|requires pyproject.toml | head -20

检查未使用的依赖(启发式)

for dep in $(python3 -c import tomllib; d=tomllib.load(open(pyproject.toml,rb)); print( .join(d.get(project,{}).get(dependencies,[]))) ); do pkg=$(echo $dep | sed s/[>=<].*//) count=$(grep -rn import $pkg\|from $pkg src/ --include=*.py | wc -l) if [ $count -eq 0 ]; then echo 可能未使用的依赖: $dep fi done

报告:依赖问题。警告级别。

第二阶段:文档审计

2.1 文档字符串覆盖率

bash
python3 -c
import ast, pathlib
total = missing = 0
for f in pathlib.Path(src/).rglob(*.py):
tree = ast.parse(f.read_text())
for node in ast.walk(tree):
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
if not node.name.startswith(_) or node.name == init:
total += 1
if not ast.get_docstring(node):
missing += 1
print(f 缺失: {f}:{node.lineno} {node.name})
print(f\n文档字符串覆盖率: {(total-missing)/total*100:.0f}% ({total-missing}/{total}))

覆盖率 < 80% 时警告。覆盖率 < 50% 时阻塞。

2.2 README与实际对比

检查README.md是否包含:

  • - pyproject.toml [project.scripts]中的所有CLI入口点
  • 安装说明
  • 基本使用示例
  • 所有主要功能(与模块级文档字符串对比)

bash

提取入口点


python3 -c import tomllib; d=tomllib.load(open(pyproject.toml,rb)); [print(k) for k in d.get(project,{}).get(scripts,{}).keys()]

检查README是否提及它们

for ep in $(python3 -c import tomllib; d=tomllib.load(open(pyproject.toml,rb)); [print(k) for k in d.get(project,{}).get(scripts,{}).keys()]); do grep -q $ep README.md && echo ✅ $ep 在README中 || echo ❌ $ep 不在README中 done

如果入口点缺失于README,则警告。

2.3 变更日志检查

bash

检查CHANGELOG.md是否存在并有近期条目


if [ -f CHANGELOG.md ]; then
head -20 CHANGELOG.md
echo 最后条目日期:
grep -oE [0-9]{4}-[0-9]{2}-[0-9]{2} CHANGELOG.md | head -1
else
echo ❌ 没有CHANGELOG.md
fi

2.4 版本一致性

bash

检查pyproject.toml中的版本与version是否匹配


PYPROJECT_VER=$(python3 -c import tomllib; print(tomllib.load(open(pyproject.toml,rb))[project][version]))
CODE_VER=$(grep -r version src/ --include=*.py | head -1 | grep -oE [0-9]+\.[0-9]+\.[0-9]+)
echo pyproject.toml: $PYPROJECT_VER
echo 代码 version: $CODE_VER
if [ $PYPROJECTVER != $CODEVER ]; then
echo ❌ 版本不匹配
fi

如果版本不匹配,则为阻塞项。

第三阶段:报告

生成结构化报告:

╔══════════════════════════════════════╗
║ 发布就绪状态报告 ║
╠══════════════════════════════════════╣
║ 包名: {name} v{version} ║
║ 分支: {branch} ║
║ 提交: {short_sha} ║
╠══════════════════════════════════════╣
║ 🔴 阻塞项: {count} ║
║ 🟡 警告: {count} ║
║ 🟢 通过: {count} ║
╠══════════════════════════════════════╣
║ 测试: {pass}/{total} ✅/❌ ║
║ 代码检查: {errors} 个错误 ║
║ 文档字符串: {pct}% 覆盖率 ║
║ README: {status} ║
║ 版本: {status} ║
║ 变更日志: {status} ║
╚════════════════

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 release-prep-1776283091 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 release-prep-1776283091 技能

通过命令行安装

skillhub install release-prep-1776283091

下载

⬇ 下载 release-prep v1.0.0(免费)

文件大小: 4.27 KB | 发布时间: 2026-4-16 15:51

v1.0.0 最新 2026-4-16 15:51
Initial release: deep code audit (tests/lint/dead code/docstrings/API coverage), documentation sync (README vs code, version consistency), changelog generation, auto-fix via coding agent, PyPI publish pipeline. Python packages only.
返回顶部