hongjr03
|
0fe6cabc68
|
feat(hub): session transcript 连续性 + slash commands (/new /resume /reset)
修复每次 @bot 都是失忆状态的问题。
- transcript.ts: JSONL 文件存 session 对话消息(workspace/.cph/sessions/
<id>.jsonl),append-only;和 Claude Code 一致;ADR-0003 说的'不存全
历史'是群聊历史,session 对话是 Hub 自己产生的,不冲突
- runner.ts: RunRequest 加 transcriptPath;run 开始时读历史拼进初始
messages(system prompt 只在首条);run 结束时 append 本轮新消息
(loadedCount 区分历史 vs 新增,不重复写);best-effort(写失败不丢
run 结果)
- trigger.ts: slash commands 在 lock 检查之前(/new /resume /reset
不创建 run 不需要锁);transcriptPath 传给 runner
/new = 归档当前 session,下次 @bot 自动建新的
/resume = 恢复最近归档的 session
/reset = 同 /new
未知 /cmd 透传给 agent 当普通 prompt
- unit: transcript.test.ts 读写回环/append 累积/损坏行恢复/路径(6)
- integration: trigger.test.ts 加 /new /resume /reset /unknown(4)
修了 slash command 被 lock 挡住的问题(提到 lock 之前)。
vitest run 45/45 通过;tsc rc=0。
|
2026-07-07 17:50:05 +08:00 |
|
hongjr03
|
09cadd0148
|
test(hub): Vitest suite + 三组 unit 测试(22 tests)
用 Vitest 组织测试,对齐 Courseware 半边的测试纪律(非散脚本):
- test/unit/workspace.test.ts: 路径 confinement(读写回环/..逃逸/绝对路径逃逸/
父目录创建/列举/不存在 error JSON)—— 11 tests
- test/unit/prompt.test.ts: @bot 提取(单 mention/多 mention/纯@bot/无 mention/
非 JSON/无 text 字段)—— 8 tests
- test/unit/permission.test.ts: roleGrantsEdit 单调性(READ 不含 / EDIT 含 /
MANAGE 含,ADR-0004 can_mono)—— 3 tests
extractPrompt 导出供测试。修了 test helper 默认参数 bug(显式传 undefined 触发
默认值,绕过 mentions 检查)。
vitest run 22/22 通过;tsc rc=0。
Integration 层(trigger 全链路 + lock WellFormed + 真 cph)待本地 postgres
后再起。
|
2026-07-07 15:26:53 +08:00 |
|