feat(datasource): add Yuque (语雀) connector

Syncs personal and team Yuque knowledge bases into WeKnora as Markdown,
with full and incremental sync + deletion detection. Mirrors the Feishu
connector pattern; fetches V2Doc.body directly (no async export step).

Config: api_token (required) + base_url (optional, defaults to public cloud).
401/403 wraps ErrInvalidCredentials; 429 honors Retry-After; filters to
status=1 Doc-type at list stage to conserve API quota. Body is trusted as
Markdown for format=markdown|lake — empirically verified against the v2
API: Lake XML lives separately in body_lake, body itself is the Markdown
view. Other formats (e.g. html) are skipped with a placeholder item so
they surface in sync logs instead of silently feeding HTML to the parser.

v2Doc.status accepts both int and string shapes — Yuque's OpenAPI spec
declares string but the live API returns int. sanitizeFileName truncates
at a UTF-8 rune boundary so multi-byte titles don't emit invalid UTF-8
that downstream filename validation rejects.

Also adds logger.SetOutput test hook, used by the token-redaction test.
This commit is contained in:
nullkey
2026-04-21 17:29:37 +08:00
committed by lyingbug
parent 6accdc2a60
commit 656b07027a
9 changed files with 1953 additions and 2 deletions
+4 -2
View File
@@ -52,6 +52,7 @@ import (
"github.com/Tencent/WeKnora/internal/datasource"
feishuConnector "github.com/Tencent/WeKnora/internal/datasource/connector/feishu"
notionConnector "github.com/Tencent/WeKnora/internal/datasource/connector/notion"
yuqueConnector "github.com/Tencent/WeKnora/internal/datasource/connector/yuque"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/handler"
"github.com/Tencent/WeKnora/internal/handler/session"
@@ -177,7 +178,6 @@ func BuildContainer(container *dig.Container) *dig.Container {
must(container.Provide(service.NewImageMultimodalService, dig.Name("imageMultimodal")))
must(container.Provide(service.NewKnowledgePostProcessService, dig.Name("knowledgePostProcess")))
must(container.Provide(service.NewMessageService))
must(container.Provide(service.NewMCPServiceService))
must(container.Provide(service.NewCustomAgentService))
@@ -1472,9 +1472,11 @@ func initConnectorRegistry() *datasource.ConnectorRegistry {
// Register Notion connector
_ = registry.Register(notionConnector.NewConnector())
// Register Yuque connector
_ = registry.Register(yuqueConnector.NewConnector())
// Future connectors will be registered here:
// _ = registry.Register(confluenceConnector.NewConnector())
// _ = registry.Register(yuqueConnector.NewConnector())
// _ = registry.Register(githubConnector.NewConnector())
return registry