Go to file
caoqianming 4f87bf14ee core(§7 B Step 2): Session ORM — messages 走 PG, task_id 切 UUID
Session 重写
- messages 落 PG `messages` 表(append-only, idx 严格递增, jsonb payload)
- system prompt 不入库(每次 build_agent 重建到 messages[0],memory 演化即时生效)
- Session.load(task_id, system_prompt=...) 从 DB 读历史
- Session.task_exists / n_user_msgs 工具

Storage utils
- ensure_local_task_row: 首条消息前 INSERT ... ON CONFLICT DO NOTHING
  打底 tasks 行(Step 3 后由 TaskState.save 接管字段更新)

task_id 切 UUID
- resolve_task_id(workspace, arg, resume): UUID + 前缀匹配,'last' 从 PG
  按 updated_at 取最近
- 显示一律截前 8 位;完整 UUID 在 /id /status 保留
- 旧 workspace 老 task(时间戳格式)**不做兼容**

CLI 适配
- _cleanup_if_empty 双检查:DB messages count + FS 产物
- _list_task_rows: PG tasks ORDER BY updated_at + state.json 兜底字段
- _task_has_messages: /export 检查改 DB
- core/export_docx.py: messages 从 PG 读,state.json 留作 meta

Step 5 (migrate-from-fs) 取消。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 10:55:50 +08:00
config Initial import: zcbot personal task agent 2026-05-06 11:02:59 +08:00
core core(§7 B Step 2): Session ORM — messages 走 PG, task_id 切 UUID 2026-05-14 10:55:50 +08:00
db/migrations core(§7 B Step 1): Storage 基建 — SQLAlchemy ORM + alembic + db CLI 2026-05-14 10:41:44 +08:00
prompts/system 修三处 v3 遗留: Iconify 不触发 / mkdir -p 误创目录 / 平台无知 2026-05-06 13:12:17 +08:00
skills proposal: 阶段二每段卡点附"下一段要点预告" 2026-05-08 16:11:18 +08:00
tools 修三处 v3 遗留: Iconify 不触发 / mkdir -p 误创目录 / 平台无知 2026-05-06 13:12:17 +08:00
.gitignore 添加col.ps1到gitignore 2026-05-08 08:03:49 +08:00
CLAUDE.md docs(CLAUDE.md): 加文档维护规则 — 每步更 PROGRESS,必要时改 DESIGN 2026-05-14 10:43:02 +08:00
DESIGN.md design: §7.1 改 task-primary + dir 副视图心智模型 2026-05-14 09:15:25 +08:00
PROGRESS.md core(§7 B Step 2): Session ORM — messages 走 PG, task_id 切 UUID 2026-05-14 10:55:50 +08:00
alembic.ini core(§7 B Step 1): Storage 基建 — SQLAlchemy ORM + alembic + db CLI 2026-05-14 10:41:44 +08:00
cli.py core(§7 B Step 2): Session ORM — messages 走 PG, task_id 切 UUID 2026-05-14 10:55:50 +08:00
main.py core(§7 B Step 2): Session ORM — messages 走 PG, task_id 切 UUID 2026-05-14 10:55:50 +08:00
requirements.txt core(§7 B Step 1): Storage 基建 — SQLAlchemy ORM + alembic + db CLI 2026-05-14 10:41:44 +08:00