refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名) - 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块) - docreader proto 描述符采用等长替换,保持序列化字节布局有效 - Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像 - 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
1 parent
9097ee699d
commit
9058149576
3136 files changed
+18018
-18004
No files matched your search
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
// Feishu docx block_type integer enum (subset this connector handles).
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
func TestListDocumentBlocks_Paginates(t *testing.T) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// P3 embedded-object pipeline tests: board blocks (block_type 43) exported via
|
||||
@@ -92,7 +92,7 @@ func TestFetchDocxWithBlocks_BoardExportSuccess(t *testing.T) {
|
||||
if !strings.Contains(string(main.Content), " {
|
||||
t.Errorf("board not inlined as base64 data URI:\n%s", main.Content)
|
||||
}
|
||||
if strings.Contains(string(main.Content), "weknora-img://") {
|
||||
if strings.Contains(string(main.Content), "academy-img://") {
|
||||
t.Errorf("internal marker leaked into stored markdown:\n%s", main.Content)
|
||||
}
|
||||
if main.Metadata["image_map"] != "" {
|
||||
@@ -120,7 +120,7 @@ func TestFetchDocxWithBlocks_BoardExportForbiddenDegrades(t *testing.T) {
|
||||
if !strings.Contains(string(main.Content), "![图片]()") {
|
||||
t.Errorf("markdown missing board degrade note:\n%s", main.Content)
|
||||
}
|
||||
if strings.Contains(string(main.Content), "weknora-img") {
|
||||
if strings.Contains(string(main.Content), "academy-img") {
|
||||
t.Errorf("unresolved board marker left in markdown:\n%s", main.Content)
|
||||
}
|
||||
if main.Metadata["image_map"] != "" {
|
||||
@@ -438,7 +438,7 @@ func TestFetchDocxWithBlocks_MentionDocTitleBackfill(t *testing.T) {
|
||||
// A header can advertise dimensions far beyond the compressed download size.
|
||||
// The sentinel codec proves that the full pixel decoder is never invoked.
|
||||
func TestTrimBoardImageRejectsOversizeBeforeDecode(t *testing.T) {
|
||||
const magic = "weknora-oversized-board-test"
|
||||
const magic = "academy-oversized-board-test"
|
||||
image.RegisterFormat("png", magic,
|
||||
func(io.Reader) (image.Image, error) {
|
||||
panic("oversized board reached pixel decoder")
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/datasource"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
// Client wraps the Feishu Open Platform API for document/wiki operations.
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// engine.go holds the single generic streaming sync engine shared by the wiki
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
secutils "academy/internal/utils"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
@@ -27,7 +27,7 @@ type pendingAttachment struct {
|
||||
}
|
||||
|
||||
// pendingDocName is one 云文档 mention link awaiting a title backfill: the
|
||||
// renderer emits "[weknora-docname://<token>](<url>)" placeholders (it has no
|
||||
// renderer emits "[academy-docname://<token>](<url>)" placeholders (it has no
|
||||
// access to document titles) and FetchDocxWithBlocks resolves the titles via
|
||||
// the drive metadata batch API, patching the link text in place.
|
||||
type pendingDocName struct {
|
||||
@@ -83,11 +83,11 @@ func (r *mdRenderer) nextImageNo(kind, token string) int {
|
||||
}
|
||||
|
||||
// imageMarker renders the synthetic placeholder for image/board N. The nonce
|
||||
// keeps user-typed look-alike text (a literal  in a
|
||||
// keeps user-typed look-alike text (a literal  in a
|
||||
// text run) from ever matching the connector's patch needle — only this
|
||||
// renderer and the patcher share the derivation (imageMarkerNonce).
|
||||
func (r *mdRenderer) imageMarker(n int) string {
|
||||
return fmt.Sprintf("", n, r.markerNonce)
|
||||
return fmt.Sprintf("", n, r.markerNonce)
|
||||
}
|
||||
|
||||
// imageMarkerNonce derives the per-document marker nonce from the doc URL.
|
||||
@@ -99,7 +99,7 @@ func imageMarkerNonce(seed string) string {
|
||||
|
||||
// blocksToMarkdown renders a flat docx block array to Markdown, inlining
|
||||
// embedded spreadsheet/bitable tables, collecting downloadable
|
||||
// attachments, and numbering image/board blocks as weknora-img://N markers.
|
||||
// attachments, and numbering image/board blocks as academy-img://N markers.
|
||||
// docURL is the parent document's web URL used in non-whitelisted attachment
|
||||
// placeholders (empty → placeholder without link). client may be nil when the
|
||||
// block set has no downdrill blocks. userName resolves mention_user OpenIDs to
|
||||
@@ -271,7 +271,7 @@ func (r *mdRenderer) renderBlock(b DocxBlock) string {
|
||||
// this exact line after the download attempt (name on success /
|
||||
// tiny, degrade note over cap), so an identical earlier bullet
|
||||
// can never be replaced by mistake.
|
||||
return "- weknora-att://" + b.File.Token
|
||||
return "- academy-att://" + b.File.Token
|
||||
}
|
||||
// Not ingestible (wrong type / video): keep a visible reference with
|
||||
// the source link when available.
|
||||
@@ -543,7 +543,7 @@ func (r *mdRenderer) richText(bt *BlockText) string {
|
||||
r.docNameSeen[ref.Token] = true
|
||||
r.docNames = append(r.docNames, ref)
|
||||
}
|
||||
sb.WriteString("[weknora-docname://" + ref.Token + "](" + escapeURL(u) + ")")
|
||||
sb.WriteString("[academy-docname://" + ref.Token + "](" + escapeURL(u) + ")")
|
||||
} else {
|
||||
sb.WriteString("[" + u + "](" + escapeURL(u) + ")")
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestContainerPreservesNestedListContent(t *testing.T) {
|
||||
}
|
||||
md, atts, imgs, _, err := blocksToMarkdown(context.Background(), nil, blocks, "", nil)
|
||||
require.NoError(t, err)
|
||||
for _, text := range []string{"parent", "nested content", "weknora-att://pdf", "weknora-img://"} {
|
||||
for _, text := range []string{"parent", "nested content", "academy-att://pdf", "academy-img://"} {
|
||||
require.Equal(t, 1, strings.Count(string(md), text), "content must appear exactly once: %s", md)
|
||||
}
|
||||
require.Len(t, atts, 1)
|
||||
@@ -102,7 +102,7 @@ func TestBoardInNativeTableIsDownloaded(t *testing.T) {
|
||||
md := string(items[0].Content)
|
||||
require.Equal(t, 1, strings.Count(md, "data:image/png;base64,"))
|
||||
require.Equal(t, 1, strings.Count(md, "board caption"))
|
||||
require.NotContains(t, md, "weknora-img://")
|
||||
require.NotContains(t, md, "academy-img://")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestBlocksToMarkdown_EmbeddedSheetAndFile(t *testing.T) {
|
||||
if !strings.Contains(string(md), "| 名称 | 数量 |") || !strings.Contains(string(md), "| 苹果 | 3 |") {
|
||||
t.Errorf("sheet not inlined:\n%s", md)
|
||||
}
|
||||
if !strings.Contains(string(md), fmt.Sprintf("", imageMarkerNonce(""))) {
|
||||
if !strings.Contains(string(md), fmt.Sprintf("", imageMarkerNonce(""))) {
|
||||
t.Errorf("numbered image marker missing:\n%s", md)
|
||||
}
|
||||
if len(imgs) != 1 || imgs[0].N != 1 || imgs[0].Kind != "image" || imgs[0].Token != "img_t" {
|
||||
@@ -63,7 +63,7 @@ func TestBlocksToMarkdown_EmbeddedSheetAndFile(t *testing.T) {
|
||||
if len(atts) != 1 || atts[0].FileToken != "file_t" || atts[0].Name != "报表.pdf" {
|
||||
t.Errorf("attachments = %+v", atts)
|
||||
}
|
||||
if !strings.Contains(string(md), "- weknora-att://file_t") {
|
||||
if !strings.Contains(string(md), "- academy-att://file_t") {
|
||||
t.Errorf("attachment marker line missing:\n%s", md)
|
||||
}
|
||||
}
|
||||
@@ -496,9 +496,9 @@ func TestBlocksToMarkdown_UnsupportedBlocksPlaceholdersNoTokenLeak(t *testing.T)
|
||||
t.Errorf("empty view must not emit a placeholder:\n%s", s)
|
||||
}
|
||||
// Board (43) now rides the image pipeline: a token-bearing board renders a
|
||||
// numbered weknora-img:// marker and records a pendingImage for the
|
||||
// numbered academy-img:// marker and records a pendingImage for the
|
||||
// connector's whiteboard download.
|
||||
if !strings.Contains(s, fmt.Sprintf("", imageMarkerNonce(""))) {
|
||||
if !strings.Contains(s, fmt.Sprintf("", imageMarkerNonce(""))) {
|
||||
t.Errorf("board marker missing:\n%s", s)
|
||||
}
|
||||
if len(imgs) != 1 || imgs[0].Kind != "board" || imgs[0].Token != "brdSECRET" {
|
||||
@@ -536,10 +536,10 @@ func TestBlocksToMarkdown_ViewContainerRendersChildren(t *testing.T) {
|
||||
}
|
||||
// Raw render emits unique per-token marker lines; FetchDocxWithBlocks
|
||||
// patches them to the display names after the download attempt.
|
||||
if n := strings.Count(s, "- weknora-att://ftok1"); n != 1 {
|
||||
if n := strings.Count(s, "- academy-att://ftok1"); n != 1 {
|
||||
t.Errorf("file child rendered %d times, want exactly 1:\n%s", n, s)
|
||||
}
|
||||
if !strings.Contains(s, "- weknora-att://ftok1\n- weknora-att://ftok2") {
|
||||
if !strings.Contains(s, "- academy-att://ftok1\n- academy-att://ftok2") {
|
||||
t.Errorf("view children not rendered as one list:\n%s", s)
|
||||
}
|
||||
if len(atts) != 2 {
|
||||
@@ -778,9 +778,9 @@ func TestBlocksToMarkdown_ImageNumberingStableOrder(t *testing.T) {
|
||||
s := string(md)
|
||||
nonce := imageMarkerNonce("")
|
||||
for _, want := range []string{
|
||||
fmt.Sprintf("", nonce),
|
||||
fmt.Sprintf("", nonce),
|
||||
fmt.Sprintf("", nonce),
|
||||
fmt.Sprintf("", nonce),
|
||||
fmt.Sprintf("", nonce),
|
||||
fmt.Sprintf("", nonce),
|
||||
} {
|
||||
if !strings.Contains(s, want) {
|
||||
t.Errorf("marker %q missing:\n%s", want, s)
|
||||
@@ -1057,7 +1057,7 @@ func TestBlocksToMarkdown_MentionDocTitlePlaceholder(t *testing.T) {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
url := "https://my.feishu.cn/docx/MHU6d4eixo1UdCxNzGbcspVSnfg"
|
||||
if !strings.Contains(string(md), "[weknora-docname://MHU6d4eixo1UdCxNzGbcspVSnfg]("+escapeURL(url)+")") {
|
||||
if !strings.Contains(string(md), "[academy-docname://MHU6d4eixo1UdCxNzGbcspVSnfg]("+escapeURL(url)+")") {
|
||||
t.Errorf("title placeholder missing, got:\n%s", md)
|
||||
}
|
||||
if len(docs) != 1 || docs[0].Token != "MHU6d4eixo1UdCxNzGbcspVSnfg" || docs[0].DocType != "docx" {
|
||||
|
||||
@@ -38,8 +38,8 @@ func TestTableViewKeepsFileAndBoard(t *testing.T) {
|
||||
if len(atts) != 1 || len(imgs) != 1 {
|
||||
t.Fatalf("table view media lost: attachments=%d images=%d markdown=%q", len(atts), len(imgs), md)
|
||||
}
|
||||
if strings.Count(string(md), "weknora-att://pdf") != 1 ||
|
||||
strings.Count(string(md), "weknora-img://") != 1 {
|
||||
if strings.Count(string(md), "academy-att://pdf") != 1 ||
|
||||
strings.Count(string(md), "academy-img://") != 1 {
|
||||
t.Fatalf("media must render exactly once: %s", md)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package core
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package core
|
||||
|
||||
import "github.com/Tencent/WeKnora/internal/types"
|
||||
import "academy/internal/types"
|
||||
|
||||
// Open Platform API origins. Feishu and Lark are the same product deployed on
|
||||
// two isolated clouds; the wiki/docx/drive APIs this connector uses are
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
func TestRegions_AreDistinct(t *testing.T) {
|
||||
|
||||
@@ -18,9 +18,9 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
const FeishuWikiNodeResourceSeparator = ":"
|
||||
@@ -168,7 +168,7 @@ const MinAttachmentBytes = 2 * 1024
|
||||
const maxInlineImageBytes = 10 * 1024 * 1024
|
||||
|
||||
// SupportedImageExt sniffs image bytes and returns the filename extension and
|
||||
// content type WeKnora accepts for a standalone image knowledge item (png/jpg/
|
||||
// content type Academy accepts for a standalone image knowledge item (png/jpg/
|
||||
// gif — the image set isValidFileType admits). ok is false for non-image or
|
||||
// unsupported formats (e.g. webp/bmp), which the caller skips rather than
|
||||
// mislabel — a wrong extension would fail parsing. The detected content type is
|
||||
@@ -382,7 +382,7 @@ func userNameResolver(ctx context.Context, client *Client) func(string) string {
|
||||
// DocxFetchInput is the unified description of one docx document from either
|
||||
// source (wiki node or Drive file) that FetchDocxWithBlocks needs.
|
||||
type DocxFetchInput struct {
|
||||
// WeKnora external_id: wiki=node.NodeToken, drive=file.Token
|
||||
// Academy external_id: wiki=node.NodeToken, drive=file.Token
|
||||
DocToken string
|
||||
// Feishu docx document token
|
||||
ObjToken string
|
||||
@@ -410,7 +410,7 @@ func FetchDocxWithBlocks(ctx context.Context, client *Client, in DocxFetchInput)
|
||||
// The parse mode comes from the data source's Settings["parse_mode"],
|
||||
// resolved by ParseFeishuConfig and threaded in via DocxFetchInput.ParseMode.
|
||||
// The blocks path (default) inlines images/boards into the parent
|
||||
// Markdown as base64 data URIs (via weknora-img://N markers) and fans
|
||||
// Markdown as base64 data URIs (via academy-img://N markers) and fans
|
||||
// attachments out into sub-items wired to the parent via attachment_ids
|
||||
// metadata. The export path yields a .docx that docreader
|
||||
// parses inline, so images are bound to the parent document via
|
||||
@@ -494,7 +494,7 @@ func FetchDocxWithBlocks(ctx context.Context, client *Client, in DocxFetchInput)
|
||||
// ![图片]() placeholder or a degrade note on failure. Markers are unique
|
||||
// per N, and N is assigned once per image/board block.
|
||||
patchMarker := func(n int, replacement string) {
|
||||
needle := fmt.Sprintf("", n, imageMarkerNonce(in.URL))
|
||||
needle := fmt.Sprintf("", n, imageMarkerNonce(in.URL))
|
||||
md = strings.Replace(md, needle, replacement, 1)
|
||||
}
|
||||
|
||||
@@ -502,13 +502,13 @@ func FetchDocxWithBlocks(ctx context.Context, client *Client, in DocxFetchInput)
|
||||
for _, a := range atts {
|
||||
childID := types.SubtreeChildID(in.DocToken, "file", a.FileToken)
|
||||
keep = append(keep, childID) // present in the doc → never sweep as stale
|
||||
// The renderer emitted the unique line "- weknora-att://<token>" for
|
||||
// The renderer emitted the unique line "- academy-att://<token>" for
|
||||
// this attachment; patch that exact line so an identical earlier
|
||||
// bullet can never be replaced by mistake. Anchoring on the token's
|
||||
// end (newline or end of markdown) keeps a token that is a strict
|
||||
// prefix of another attachment's token from matching inside it.
|
||||
patchAtt := func(line string) {
|
||||
needle := "- weknora-att://" + a.FileToken
|
||||
needle := "- academy-att://" + a.FileToken
|
||||
if anchored := needle + "\n"; strings.Contains(md, anchored) {
|
||||
md = strings.Replace(md, anchored, line+"\n", 1)
|
||||
return
|
||||
@@ -589,14 +589,14 @@ func FetchDocxWithBlocks(ctx context.Context, client *Client, in DocxFetchInput)
|
||||
}
|
||||
|
||||
// ── 云文档 mention links: backfill document titles ──
|
||||
// The renderer emits "[weknora-docname://<token>](<url>)" placeholders; the
|
||||
// The renderer emits "[academy-docname://<token>](<url>)" placeholders; the
|
||||
// drive metadata batch API resolves every title in one call. Refs that
|
||||
// cannot be resolved (no permission, deleted, unsupported type) keep the
|
||||
// URL as the link text — exactly the form rendered before this backfill.
|
||||
if len(docNames) > 0 {
|
||||
titles := client.DocTitles(ctx, docNames)
|
||||
for _, dn := range docNames {
|
||||
needle := "[weknora-docname://" + dn.Token + "](" + escapeURL(dn.URL) + ")"
|
||||
needle := "[academy-docname://" + dn.Token + "](" + escapeURL(dn.URL) + ")"
|
||||
repl := "[" + dn.URL + "](" + escapeURL(dn.URL) + ")"
|
||||
if title := titles[dn.Token]; title != "" {
|
||||
clean := strings.NewReplacer("[", "[", "]", "]", "\n", " ", "\r", "").Replace(title)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package feishu implements the Feishu (飞书/Lark) data source connector for WeKnora.
|
||||
// Package feishu implements the Feishu (飞书/Lark) data source connector for Academy.
|
||||
//
|
||||
// It syncs documents from Feishu Wiki spaces and cloud documents into WeKnora knowledge bases.
|
||||
// It syncs documents from Feishu Wiki spaces and cloud documents into Academy knowledge bases.
|
||||
//
|
||||
// Feishu API docs:
|
||||
// - Wiki spaces: https://open.feishu.cn/document/server-docs/docs/wiki-v2/space/list
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
// ListWikiNodesWithShortcuts supplements the existing traversal with descendants
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource"
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// DriveConnector implements the datasource.Connector (and StreamingConnector)
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
)
|
||||
|
||||
// TestDriveCursorRoundTrip verifies driveOps.EncodeCursor/DecodeCursorTimes
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// makeDriveConfig builds a DataSourceConfig for the Drive connector, mirroring
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
secutils "academy/internal/utils"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
)
|
||||
|
||||
// TestClientDriveListFilesPagination is the Drive (云盘) counterpart of the wiki
|
||||
|
||||
@@ -3,9 +3,9 @@ package drive
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// This file implements the P1 directory mapping for the Drive connector:
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource"
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// Connector implements the datasource.Connector interface for Feishu and, with
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// statefulFeishu is a fake Feishu server whose per-node export outcome can be
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -25,9 +25,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/utils"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
"academy/internal/utils"
|
||||
)
|
||||
|
||||
// collectHandler records everything a real FetchStream emits so the test can
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// env vars) so it never runs in the normal suite or CI.
|
||||
//
|
||||
// It WRITES to your Feishu tenant: it creates a handful of docx documents under
|
||||
// the given wiki space, each titled "WeKnora sync test doc N" so you can find
|
||||
// the given wiki space, each titled "Academy sync test doc N" so you can find
|
||||
// and delete them afterwards. Requires app write scopes:
|
||||
// - wiki:wiki (create wiki nodes)
|
||||
// - docx:document (write docx content)
|
||||
@@ -26,8 +26,8 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/utils"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/utils"
|
||||
)
|
||||
|
||||
// wikiNodeCreateResp is the subset of POST /wiki/v2/spaces/:id/nodes we need.
|
||||
@@ -68,7 +68,7 @@ func TestRealAPI_CreateSpace(t *testing.T) {
|
||||
}
|
||||
err := client.DoRequest(context.Background(), "POST", "/open-apis/wiki/v2/spaces",
|
||||
map[string]interface{}{
|
||||
"name": "WeKnora Resilience Test KB",
|
||||
"name": "Academy Resilience Test KB",
|
||||
"description": "Auto-created for connector resilience testing (#2136). Safe to delete.",
|
||||
}, &resp)
|
||||
if err != nil {
|
||||
@@ -101,7 +101,7 @@ func TestRealAPI_SeedDocs(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
for i := 1; i <= count; i++ {
|
||||
title := fmt.Sprintf("WeKnora sync test doc %d", i)
|
||||
title := fmt.Sprintf("Academy sync test doc %d", i)
|
||||
|
||||
// 1) Create a docx wiki node.
|
||||
var created wikiNodeCreateResp
|
||||
@@ -134,7 +134,7 @@ func TestRealAPI_SeedDocs(t *testing.T) {
|
||||
"text": map[string]interface{}{
|
||||
"elements": []map[string]interface{}{{
|
||||
"text_run": map[string]interface{}{
|
||||
"content": fmt.Sprintf("This is WeKnora sync test document number %d. It exists to validate connector resilience (issue #2136).", i),
|
||||
"content": fmt.Sprintf("This is Academy sync test document number %d. It exists to validate connector resilience (issue #2136).", i),
|
||||
},
|
||||
}},
|
||||
},
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// fakeFeishuFailingExport serves the auth/spaces/nodes endpoints normally but
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
secutils "academy/internal/utils"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -1678,7 +1678,7 @@ func TestFetchDocxWithBlocks_EmbeddedImage(t *testing.T) {
|
||||
if !strings.Contains(string(main.Content), wantURI) {
|
||||
t.Errorf("image not inlined as base64 data URI:\n%s", main.Content[:min(len(main.Content), 400)])
|
||||
}
|
||||
if strings.Contains(string(main.Content), "weknora-img://") {
|
||||
if strings.Contains(string(main.Content), "academy-img://") {
|
||||
t.Errorf("internal marker leaked into stored markdown:\n%s", main.Content[:400])
|
||||
}
|
||||
if main.Metadata["image_map"] != "" {
|
||||
@@ -1740,7 +1740,7 @@ func TestFetchDocxWithBlocks_ImageDownloadFailure(t *testing.T) {
|
||||
if !strings.Contains(string(main.Content), "![图片]()") {
|
||||
t.Errorf("broken image must degrade to a placeholder:\n%s", main.Content)
|
||||
}
|
||||
if strings.Contains(string(main.Content), "weknora-img://") {
|
||||
if strings.Contains(string(main.Content), "academy-img://") {
|
||||
t.Errorf("internal marker leaked into stored markdown:\n%s", main.Content)
|
||||
}
|
||||
}
|
||||
@@ -1868,7 +1868,7 @@ func TestFeishuCursorRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestSupportedImageExt covers every arm of the sniff table: the png/jpg/gif
|
||||
// formats WeKnora accepts (aligned with isValidFileType's image set), and the
|
||||
// formats Academy accepts (aligned with isValidFileType's image set), and the
|
||||
// unsupported case which must return ok=false while still surfacing the detected
|
||||
// content type so the caller can log it without re-sniffing.
|
||||
func TestSupportedImageExt(t *testing.T) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package wiki
|
||||
|
||||
import "github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
import "academy/internal/datasource/connector/feishu/core"
|
||||
|
||||
func txt(s string) *core.BlockText {
|
||||
return &core.BlockText{Elements: []core.TextElement{{TextRun: &core.TextRun{Content: s}}}}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// A Lark connector must surface wiki links on the Lark host. Before Lark became
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
)
|
||||
|
||||
func TestParseModeChangeRefetchesExistingDocument(t *testing.T) {
|
||||
|
||||
@@ -3,8 +3,8 @@ package wiki
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// This file implements the P1 directory mapping: FetchedItem.FileName becomes
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/datasource/connector/feishu/core"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/datasource/connector/feishu/core"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user