Skip to content

v1.2.0: P2/P3 完善 — 测试套件 + LICENSE + CHANGELOG + pre-commit + 文件拆分

Choose a tag to compare

@qingyabailu-git qingyabailu-git released this 20 Jun 10:10
· 6 commits to main since this release

v1.2.0: P2/P3 完善 — 测试套件 + LICENSE + CHANGELOG + pre-commit + 文件拆分

🆕 新增

1. pytest 测试套件

新增 tests/test_fiction.py,15 个测试用例覆盖核心功能:

  • test_init_creates_state_with_schema_version — init 写入 schema_version
  • test_where_finds_project / test_where_exits_nonzero_when_no_project — where 命令
  • test_migrate_state_old_format / test_migrate_state_idempotent — schema 迁移
  • test_load_state_auto_migrates_and_persists — 自动迁移+持久化
  • test_doctor_reports_missing_files — doctor 体检
  • test_export_txt / test_export_fanqie_format — 导出
  • test_chapter_commit — 章节提交
  • test_review_pipeline_writes_report — 审查报告
  • test_memory_add_and_list / test_memory_dedup / test_memory_search_and_delete — project-memory
  • test_cli_help_registered — CLI 参数注册

运行方式:

# 用 pytest
python -m pytest tests/ -v

# 或内置 runner(无需安装 pytest)
python tests/test_fiction.py --run

防止再次出现"参数没注册"这种低级问题。

2. LICENSE 文件

补齐 MIT LICENSE(README 早已声明 MIT 但仓库根缺失):

  • 版权年份 2024-2026
  • 版权人 qingyabailu-git

3. CHANGELOG.md

参考 Keep a Changelog 格式,记录 v1.0.0 到 v1.1.0 的主要变更,方便用户了解升级影响。

4. pre-commit hook(编码保护)

从源头杜绝乱码文件被提交,两种安装方式:

方式一:Git 原生 hook

cp scripts/pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

方式二:pre-commit 框架(需 pip install pre-commit)

pre-commit install

hook 会检查暂存的 .md/.py/.json/.yaml/.yml 文件是否为干净 UTF-8(无 BOM、无乱码特征),不合格则阻止提交。

🔧 重构

5. 拆分 fiction-write/SKILL.md

章节修改模式(Re-craft/Rewrite)的详细六步流程拆分到独立文件:

  • skills/fiction-write/references/revise-modes.md(100 行,含完整流程)
  • skills/fiction-write/SKILL.md 从 429 行减到 340 行,保留速查表和引用链接

主 SKILL.md 加载更轻量,进入修改模式时才加载详细流程。

6. agents 编排描述对齐

Deep 模式增量章节明确标注 context-agent / data-agent / reviewer / projection / postcommit gate 均由主线 LLM 直接执行,scripts/fiction.py 仅提供 chapter-commit 和 review-pipeline 辅助脚本支持。消除"描述与实现脱节"的疑虑。

7. cmd_memory 扩展子命令

project-memory 命令新增三个子命令:

子命令 功能
list-patterns 列出所有已存模式
search-pattern 按关键词或类型搜索
delete-pattern 按索引或类型删除

add-pattern 同时增加去重逻辑(pattern_type + description 完全相同则跳过)。

8. Windows 兼容性说明

README 新增"Windows 用户注意"段落,明确说明 SKILL.md 使用 bash 语法,Windows 用户需 Git Bash / WSL / MSYS2 / Cygwin,PowerShell 和 CMD 无法直接运行。

📊 变更统计

  • 9 文件变更
  • +712 行 / -106 行
  • 新增 6 文件(LICENSE, CHANGELOG.md, .pre-commit-config.yaml, scripts/pre-commit-hook.sh, skills/fiction-write/references/revise-modes.md, tests/test_fiction.py)

✅ 验证

# 1. 测试套件
python tests/test_fiction.py --run
# 期望: 15 passed, 0 failed

# 2. 编码检测
python scripts/check_encoding.py .
# 期望: 110+ OK, 0 BAD

# 3. CLI 新子命令
python scripts/fiction.py project-memory --help
# 应显示 add-pattern / list-patterns / search-pattern / delete-pattern

⬆️ 升级方法

git pull origin main
# 或指定版本
git checkout v1.2.0

从 v1.1.0 升级无破坏性变更,所有功能向后兼容。

📝 后续

P0/P1/P2/P3 全部完成。本项目当前状态:

阶段 内容 状态
P0 紧急修复(乱码+参数+退出码) ✅ v1.0.3
P1 schema 版本化+环境变量兼容+致谢规范化 ✅ v1.1.0
P2 文件拆分+agents对齐+cmd_memory扩展+LICENSE+Windows说明 ✅ v1.2.0
P3 测试套件+pre-commit hook+CHANGELOG ✅ v1.2.0

后续如有新需求可继续迭代。


完整变更: v1.1.0...v1.2.0