Skip to content

feat: 文档源连接器多源化——通用镜像引擎 + Notion + Google Docs#3

Merged
FakeHank merged 1 commit into
mainfrom
feat/doc-connectors
Jun 25, 2026
Merged

feat: 文档源连接器多源化——通用镜像引擎 + Notion + Google Docs#3
FakeHank merged 1 commit into
mainfrom
feat/doc-connectors

Conversation

@FakeHank

Copy link
Copy Markdown
Contributor

背景

team-brain 此前只把飞书 wiki 单向镜像进真相库的 feishu/ 子树。作为产品能力,把文档镜像做成可插拔多源,并落地 Notion 与 Google Docs 两个新源。

做了什么

  • 通用镜像引擎 server/docsync.mjs:把飞书硬编码逻辑抽成 provider 无关的 syncDocs(TRUTH, req, provider, opts)——增量去重(按 edited 指纹)、孤儿/死库 prune、零库保护、redactAgent 脱敏、一轮一 commit。feishudocs.mjs 重构成第一个 adapter(签名不变,旧测试全绿)。
  • Notion core/notion.mjs + server/notiondocs.mjs:integration token,search 列页面 + 块树递归取正文。
  • Google Docs core/google.mjs + server/googledocs.mjs:service account(node:crypto 自签 JWT,无 SDK)+ Drive export 到 text/plain。
  • 两个新源都用原生 fetch,零新依赖 → 客户端装机包不受影响。
  • 查询/看板/MCP 全面多源化grep/find/ls/read 默认全仓覆盖新子树;web/app.js Docs 视图/总览/面包屑按存在的源子树列举;mcp/server.mjs 工具描述 + /ask 提示同步;/capabilities 暴露 notion/google
  • 轮询表驱动 DOC_SOURCES:加新源只加一行。
  • 去重core/retry.mjs(退避,三源共用)、core/safe.mjs#saniName(名字消毒,去三处复制)。

验证

  • npm test 162/162(飞书 10 + Notion 11 + Google 7 + 其余)
  • 端到端:假 API 同步进真相库(真 git commit)→ 真服务器 HTTP /ls//find//grep//read 命中三源,/read 出口脱敏生效
  • 启动冒烟:表驱动轮询正确注册,缺省即关

配置(运维)

新增 notion.example.yaml / google.example.yaml(均 gitignore 对应 *.yaml,缺省即关),README 双语补「其它文档源」小节。

🤖 Generated with Claude Code

把飞书硬编码的文档镜像抽成通用引擎(server/docsync.mjs,provider 无关的增量/孤儿 prune/脱敏/单轮一 commit),
飞书改成第一个 adapter,新增 Notion 与 Google Docs 两个 provider(原生 fetch,零新依赖)。
查询/看板/MCP 全部从 feishu-only 泛化到三源:grep/find/ls/read 自动覆盖新子树,Web Docs 视图按存在的源
子树列举,MCP 工具描述与 /ask 提示同步。

- core/{notion,google}.mjs + server/{notion,google}docs.mjs:两个新文档源 adapter
- server/docsync.mjs:通用 collection→doc 对账引擎;feishudocs.mjs 重构为 adapter
- server/server.mjs:DOC_SOURCES 表驱动轮询(加新源只加一行)+ /capabilities 暴露 notion/google
- web/app.js:Docs 视图/总览/面包屑多源化;mcp/server.mjs + ASK_HINT 描述同步
- 复用:core/retry.mjs(退避,三源共用)、core/safe.mjs#saniName(名字消毒,去三处重复)
- 测试:test/{notion,google}.test.mjs(18 例);全套 162 绿

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FakeHank
FakeHank merged commit e990033 into main Jun 25, 2026
3 checks passed
@FakeHank
FakeHank deleted the feat/doc-connectors branch June 25, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant