feat(ai-studio): add prompt template storage

This commit is contained in:
chengma
2026-07-11 12:35:42 +08:00
parent 1267e0a727
commit 3ebefab91e
6 changed files with 81 additions and 4 deletions
+8 -2
View File
@@ -3,7 +3,7 @@ id: T-589
title: AI工场独立提示词模板数据层与完整 CRUD
phase: 7
deps: [T-583]
status: TODO
status: DONE
created: 2026-07-11
---
@@ -34,4 +34,10 @@ AI工场只有一个完整提示词框,不再区分“主提示词/每张动
## 执行记录
(完成后记录模板路径、复用点和测试结果。)
- 2026-07-11:完成 AI工场独立提示词模板数据层。
- `app/appconfig.py` 新增 `image_studio_prompts_dir(config=None)`,固定解析到 `data/prompts/image_studio/`。
- `app/prompts.py` 复用 T-583 通用 `list/load/save/rename/delete_template`,新增 `list/load/save/rename/delete_image_studio_template` 薄封装;模板内容按原始完整文本保存,不解析、不拆行。
- `tests/test_prompts.py` 覆盖 AI工场模板 CRUD、空名/非法名/重名/不存在错误、原始多行文本保持,以及与标题/封面模板目录隔离;`tests/test_appconfig.py` 覆盖目录路径。
- `docs/04-architecture.md` 已同步 `data/prompts/image_studio/<名称>.txt` 存储口径。
- 当前工作树运行 `py -3.10 -m unittest tests.test_prompts tests.test_appconfig` 仍因无关未提交默认封面模板改名失败(`papa1` 变为「默认」);T-589 本身在 clean worktree 验证通过。
- 验证:在只套用 T-589 diff 的 clean worktree 中运行 `py -3.10 -m unittest tests.test_prompts tests.test_appconfig`(25 tests)、`python -m ruff check app tests main.py`、`py -3.10 -m compileall app main.py`、`py -3.10 -m unittest discover -s tests`(356 tests)和 `git diff --check`,全部通过。