Files
cmshoppe/docs/tasks/T-589.md
T

44 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: T-589
title: AI工场独立提示词模板数据层与完整 CRUD
phase: 7
deps: [T-583]
status: DONE
created: 2026-07-11
---
## 问题 / 背景
AI工场只有一个完整提示词框,不再区分“主提示词/每张动作词”,但需要较窄模板下拉和“新建、重命名、保存、删除”。模板不能与②封面模板混用,避免不同业务语义互相覆盖。
## 方案
- `appconfig` 增加 `image_studio_prompts_dir()`,固定为 `data/prompts/image_studio/`。
- 复用 T-583 通用模板 CRUD,不复制另一套文件名校验、重名保护或删除逻辑。
- 新建输入不重复名称;重命名只改名;保存把当前完整文本写入选中模板;删除二次确认。
- 不解析模板内容、不拆段、不按行生成;模板只是把完整文本载入编辑框。
- 当前项目草稿提示词由 T-586 项目字段保存,选择模板只覆盖编辑框/草稿,不自动改历史 job。
## 验收要点
- AI工场模板与标题/封面模板目录完全隔离,CRUD 和中文错误完整。
- 空名、非法路径、重名、目标不存在、删除最后模板均有确定行为。
- 选择模板返回原始完整文本;换行不触发任务拆分。
- 测试只用临时目录,不写真实 data;通用模板既有测试不回归。
## 边界(不改什么)
- 本任务只做路径/数据层,不做 GUI 和 AI 请求。
- 不复制②模板 CRUD,不引入本地图片或提示词自动补写。
- 不把 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`,全部通过。