feat: 重构问问微信并完善知识库增量检索

统一问问微信与 Agent Hub 的查询链路
完善查询覆盖度、新鲜度和部分结果表达,避免索引滞后产生错误结论
基于会话实现真正的增量追新与历史补齐
支持后台同步、取消恢复、重启续传以及同步期间继续查询
优化知识库跨会话检索、同步状态、进度展示和侧栏布局
This commit is contained in:
Wxw-Gu
2026-09-11 17:44:48 +08:00
parent 0c4932d740
commit ab3b3731b7
69 changed files with 8317 additions and 898 deletions
+38 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { parsePocQuestion } from '../../src/main/query-agent-poc-cli'
import { parsePocInvocation, parsePocQuestion } from '../../src/main/query-agent-poc-cli'
describe('Query Agent POC CLI 参数解析', () => {
it('移除开头的分隔符 --', () => {
@@ -34,3 +34,40 @@ describe('Query Agent POC CLI 参数解析', () => {
expect(argv).toEqual(['--', '问题'])
})
})
describe('parsePocInvocation — 诊断模式与搜索范围', () => {
it('无 --tool 时是自然语言模式,并把 --scope 从问题里剥掉', () => {
expect(parsePocInvocation(['我和 BOBO 第一次聊了什么'])).toMatchObject({
kind: 'question',
question: '我和 BOBO 第一次聊了什么'
})
const scoped = parsePocInvocation([
'--scope',
'{"kind":"groups"}',
'最近谁聊过健身'
])
expect(scoped).toMatchObject({ kind: 'question', question: '最近谁聊过健身' })
if (scoped.kind !== 'question') throw new Error('unreachable')
expect(scoped.scope).toEqual({ kind: 'groups' })
})
it('裸工具模式把 scope 合并进工具参数(Host 注入,LLM 提供不了)', () => {
const invocation = parsePocInvocation([
'--tool',
'search_messages',
'--args',
'{"timeRange":{"kind":"all"},"query":"健身"}',
'--scope',
'{"kind":"groups"}'
])
if (invocation.kind !== 'tool') throw new Error('unreachable')
expect(invocation.toolName).toBe('search_messages')
expect(invocation.args).toMatchObject({ query: '健身', scope: { kind: 'groups' } })
})
it('非法 scope / 缺少 conversationId 会明确报错', () => {
expect(() => parsePocInvocation(['--scope', '{"kind":"nope"}', 'x'])).toThrow(/scope.kind/)
expect(() => parsePocInvocation(['--scope', '{"kind":"contact"}', 'x'])).toThrow(/conversationId/)
expect(() => parsePocInvocation(['--scope', 'not-json', 'x'])).toThrow(/合法 JSON/)
})
})