chattercatcher 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -142,6 +142,41 @@
142
142
  - 群/成员配置测试。
143
143
  - 数据删除测试。
144
144
 
145
+
146
+ ## M4:人物档案(Personal Profiles)
147
+
148
+ 目标:ChatterCatcher 自动识别群成员,建立以人物为中心的知识档案,让问答系统理解"谁喜欢什么""谁需要什么"。
149
+
150
+ ### 范围
151
+
152
+ - 人物身份自动识别:消息入库时从 senderId/senderName 解析人物身份。
153
+ - 档案存储:PersonProfile 数据模型,包含 person、identities、entries。
154
+ - ProfileRepository:本地 SQLite 仓储,支持 upsert、查询、修正。
155
+ - Dream 处理器:周期性批量分析新消息,LLM 自动提取档案更新。
156
+ - 档案 RAG 工具:get_person_profile 和 search_person_messages Agent 工具。
157
+ - 档案修正:支持通过 API 显式纠正档案条目。
158
+ - Web UI 档案页面:展示人物列表、档案详情和手动修正入口。
159
+ - CLI 档案命令:profiles list、profiles show。
160
+
161
+ ### 验收标准
162
+
163
+ - 消息入库时自动注册人物身份。
164
+ - 每个群成员拥有独立的档案,包含事实和推断条目。
165
+ - Dream 处理器能批量分析新消息并生成档案更新。
166
+ - 档案条目带证据引用和置信度评分。
167
+ - RAG 问答能检索人物档案作为证据源。
168
+ - Web UI 可查看和修正人物档案。
169
+ - CLI 可列出和查看人物档案。
170
+
171
+ ### 自测
172
+
173
+ - 人物身份解析测试。
174
+ - 档案 upsert 和查询测试。
175
+ - Dream 处理器 mock LLM 测试。
176
+ - 档案 RAG 工具集成测试。
177
+ - 档案修正 API 测试。
178
+ - Web UI 档案页面构建测试。
179
+
145
180
  ## Backlog
146
181
 
147
182
  - 更多聊天平台。
@@ -160,4 +195,13 @@
160
195
  - 手工 smoke test 记录。
161
196
  - 已更新的文档。
162
197
  - 一个或多个聚焦的 git commit。
163
- - 开始发版后维护 changelog。
198
+
199
+ ## 发版纪律
200
+
201
+ 每次发版必须:
202
+
203
+ - 更新 `CHANGELOG.md`,按时间倒序记录新增、修复和变更。
204
+ - `CHANGELOG.md` 使用中文,格式参考 https://keepachangelog.com/zh-CN/1.1.0/。
205
+ - 版本号遵守 SemVer。
206
+ - `package.json` 的 `files` 字段必须包含 `CHANGELOG.md`。
207
+ - Claude 负责 version bump、PR 和 merge;用户负责 `npm publish`。
package/docs/PRD.md CHANGED
@@ -118,6 +118,20 @@ ChatterCatcher 是一个本地优先的飞书/Lark 家庭群机器人。它静
118
118
  - `chattercatcher settings` 可以修改和重置配置。
119
119
  - `chattercatcher doctor` 检查飞书凭证、模型连通性、embedding 兼容性和本地存储。
120
120
 
121
+ ### 个人档案
122
+
123
+ 作为家庭成员,我希望机器人自动了解群成员的偏好、需求和背景,不用每次提问都从头解释。
124
+
125
+ 验收标准:
126
+
127
+ - 机器人自动从消息中识别群成员,为每个人建立独立档案。
128
+ - 档案条目分事实(fact)和推断(inferred),带置信度评分。
129
+ - 档案按 category 分类(preference、schedule、health、skill 等)。
130
+ - Dream 处理器周期性批量分析新消息,自动更新档案。
131
+ - 用户可通过 Web UI 或 API 显式纠正档案条目。
132
+ - 档案条目可追溯原始证据(哪条消息、谁说、说什么)。
133
+ - 档案检索作为 RAG 证据源之一参与问答。
134
+
121
135
  ## RAG 要求
122
136
 
123
137
  RAG 是产品核心,不是可选增强。
@@ -211,6 +211,80 @@ retrieval_debug_json
211
211
  created_at
212
212
  ```
213
213
 
214
+
215
+ ### person_profiles
216
+
217
+ ```text
218
+ id
219
+ primary_name
220
+ notes
221
+ created_at
222
+ updated_at
223
+ ```
224
+
225
+ ### person_identities
226
+
227
+ ```text
228
+ person_id
229
+ platform
230
+ platform_chat_id
231
+ external_user_id
232
+ display_name
233
+ alias
234
+ source
235
+ first_seen_at
236
+ last_seen_at
237
+ ```
238
+
239
+ ### profile_entries
240
+
241
+ ```text
242
+ id
243
+ person_id
244
+ category
245
+ content
246
+ entry_type
247
+ confidence
248
+ status
249
+ source
250
+ created_at
251
+ updated_at
252
+ last_observed_at
253
+ ```
254
+
255
+ ### profile_evidence
256
+
257
+ ```text
258
+ entry_id
259
+ message_id
260
+ quote
261
+ reason
262
+ ```
263
+
264
+ ### dream_state
265
+
266
+ ```text
267
+ platform
268
+ platform_chat_id
269
+ last_message_id
270
+ last_message_sent_at
271
+ updated_at
272
+ ```
273
+
274
+ ### dream_runs
275
+
276
+ ```text
277
+ id
278
+ platform
279
+ platform_chat_id
280
+ status
281
+ processed_message_count
282
+ generated_entry_count
283
+ error
284
+ started_at
285
+ finished_at
286
+ ```
287
+
214
288
  ### jobs
215
289
 
216
290
  ```text
@@ -240,6 +314,49 @@ RAG 是强制架构路径,不能被 prompt 堆叠替代。
240
314
 
241
315
  答案生成器只能接收压缩后的证据块,不能接收无限制原始聊天历史。
242
316
 
317
+
318
+ ## 人物档案(Personal Profiles)
319
+
320
+ 人物档案是以人物为中心的知识组织方式。每个群成员在 ChatterCatcher 中拥有独立的档案,包含从聊天消息中提取的事实和推断。
321
+
322
+ ### 档案数据流
323
+
324
+ ```text
325
+ 消息入库 -> 人物身份解析 -> PersonIdentity 注册
326
+ -> Dream Processor(周期性批量分析)
327
+ -> LLM 提取档案更新
328
+ -> ProfileRepository upsert entries
329
+ -> RAG 检索时作为证据源
330
+ ```
331
+
332
+ ### 档案条目类型
333
+
334
+ - **fact**:从聊天中明确提取的事实,如"豆豆的编程课是每周六下午 2 点",置信度高。
335
+ - **inferred**:从聊天模式推断的信息,如"豆豆喜欢编程",置信度相对较低。
336
+
337
+ ### Dream 处理器
338
+
339
+ Dream 是对人物档案的自动更新机制:
340
+
341
+ 1. 读取群的 dream_state,获取上次处理位置。
342
+ 2. 从 message 表批量拉取新消息(默认每批 100 条)。
343
+ 3. 收集本批消息涉及的所有 personId,加载现有档案。
344
+ 4. 将消息和现有档案通过 LLM 分析,输出档案更新列表。
345
+ 5. 验证每个更新:personId 存在、证据消息在本批次内、置信度在 0-1 范围。
346
+ 6. Upsert 档案条目,更新 dream_state 光标。
347
+ 7. 记录 dream_run(成功/失败/跳过)。
348
+
349
+ Dream 只基于当前批次消息输出更新,不回看全部历史,保证增量处理效率。
350
+
351
+ ### RAG 集成
352
+
353
+ 档案检索工具集成在 Agent 工具循环中:
354
+
355
+ - `get_person_profile`:根据 senderId + chatId 或 personId 检索特定人物的档案。
356
+ - `search_person_messages`:按 personId 只检索某个人发过的消息。
357
+
358
+ 检索到的档案条目作为 RAG 证据源,和消息、文件、episode summary 一起参与重排和答案生成。
359
+
243
360
  ## 冲突处理
244
361
 
245
362
  冲突处理不能简单“最新消息赢”。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chattercatcher",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "本地优先的飞书/Lark 家庭群知识库机器人",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,8 @@
23
23
  "docs/PRD.md",
24
24
  "docs/TECHNICAL_ARCHITECTURE.md",
25
25
  "README.md",
26
- "AGENTS.md"
26
+ "AGENTS.md",
27
+ "CHANGELOG.md"
27
28
  ],
28
29
  "directories": {
29
30
  "doc": "docs"