feat: 完成账号目录slug工具

- 新增 app/config.py,生成稳定账号 slug 并创建 user-data-dir

- db 账号创建复用统一 slug 规则

- 新增 config 单元测试覆盖 slug 和目录创建

- 更新任务看板、API 合约、当前状态和进度记录
This commit is contained in:
chengma
2026-06-27 09:21:33 +08:00
parent aba272dd21
commit d3afe69c10
7 changed files with 123 additions and 18 deletions
+8
View File
@@ -295,3 +295,11 @@
- 说明:`app.excel` 与 `app.prompts` 尚未实现,`test_module_contracts.py` 对这两个模块做契约占位测试;当前表现为 2 个 skip,后续模块文件出现后会检查公开函数是否齐全。
- 验证:`py -3 -m compileall app main.py tests` 通过;`py -3 -m unittest discover -s tests` 通过(9 tests,skipped=2);`python -m unittest discover -s tests` 通过(9 tests,skipped=2);测试临时目录位于 `tests/` 下并已清理。
- 下一步:按任务看板领取 T-101。
## 【2026-06-27】T-101 账号 slug 与 user-data-dir
- 状态:DONE
- 变更:新增 `app/config.py`,实现 `make_slug(alias)` 与 `ensure_user_data_dir(slug, root=None, config=None)`;`app/db.py` 改为复用同一 slug 生成规则;新增 `tests/test_config.py` 覆盖 slug 稳定性、非 ASCII 别名、非法 slug 拒绝、目录创建与绝对路径;同步 `docs/06-tasks.md`、`docs/current-state.md`、`docs/api.md`。
- 规则:slug = 可读 ASCII 前缀 + 8 位 SHA1 后缀;非 ASCII 别名使用 `account_<hash>`;`ensure_user_data_dir` 只接受 `[a-z0-9_]`,防止路径穿越。
- 验证:`py -3 -m compileall app main.py tests` 通过;`py -3 -m unittest discover -s tests` 通过(12 tests,skipped=2);`python -m unittest discover -s tests` 通过(12 tests,skipped=2);测试临时目录已清理。
- 下一步:按任务看板领取 T-102。