From b395db55dec130fc38f3f14db406b62cf734d86a Mon Sep 17 00:00:00 2001 From: nullkey Date: Mon, 25 May 2026 20:21:41 +0800 Subject: [PATCH] chore(cli): adapt ListKnowledgeChunks interface to variadic chunk_type filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream commit 5c0243cd ("feat: Support filtering chunks by multiple chunk_type params") extended client.Client.ListKnowledgeChunks with a trailing `chunkTypes ...string` variadic. The two narrow service interfaces in cli/ — ListService in cli/cmd/chunk/list.go and chunkListService in cli/internal/mcp/tools.go — plus the two fake implementations in their *_test.go siblings, are updated to match so *client.Client continues to satisfy them via duck typing. No CLI flag surfaced yet; both call sites pass no filter and behavior is unchanged. Exposing `--chunk-type` as a flag on `weknora chunk list` and as an input field on the MCP `chunk_list` tool is a candidate for a follow-up commit, per the broader SDK-required → CLI-required alignment discussion. Pre-flight: go build ./... clean; go test -count=1 ./... 28/28 packages pass; go vet ./... clean; gofmt -l . empty. --- cli/cmd/chunk/list.go | 2 +- cli/cmd/chunk/list_test.go | 2 +- cli/internal/mcp/tools.go | 2 +- cli/internal/mcp/tools_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/cmd/chunk/list.go b/cli/cmd/chunk/list.go index a2d26ca1..a0e3076d 100644 --- a/cli/cmd/chunk/list.go +++ b/cli/cmd/chunk/list.go @@ -36,7 +36,7 @@ var chunkListFields = []string{ // ListService is the narrow SDK surface this command depends on. type ListService interface { - ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int) ([]sdk.Chunk, int64, error) + ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int, chunkTypes ...string) ([]sdk.Chunk, int64, error) } type ListOptions struct { diff --git a/cli/cmd/chunk/list_test.go b/cli/cmd/chunk/list_test.go index 3a5b2927..110c62d5 100644 --- a/cli/cmd/chunk/list_test.go +++ b/cli/cmd/chunk/list_test.go @@ -28,7 +28,7 @@ type fakeListSvc struct { callIdx int } -func (f *fakeListSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int) ([]sdk.Chunk, int64, error) { +func (f *fakeListSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int, _ ...string) ([]sdk.Chunk, int64, error) { f.calls = append(f.calls, listCall{docID, page, pageSize}) defer func() { f.callIdx++ }() if f.callIdx >= len(f.pages) { diff --git a/cli/internal/mcp/tools.go b/cli/internal/mcp/tools.go index e6274b43..1a46e229 100644 --- a/cli/internal/mcp/tools.go +++ b/cli/internal/mcp/tools.go @@ -92,7 +92,7 @@ type agentService interface { // separate from knowledgeService because the chunk subtree is its own // domain on the server side (/api/v1/chunks/...). type chunkListService interface { - ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int) ([]sdk.Chunk, int64, error) + ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int, chunkTypes ...string) ([]sdk.Chunk, int64, error) } // agentInvokeService composes the two SDK methods agent_invoke needs diff --git a/cli/internal/mcp/tools_test.go b/cli/internal/mcp/tools_test.go index 1394540a..6397e477 100644 --- a/cli/internal/mcp/tools_test.go +++ b/cli/internal/mcp/tools_test.go @@ -128,7 +128,7 @@ func (f *fakeSvc) AgentQAStreamWithRequest(_ context.Context, sess string, req * } return f.agentStreamErr } -func (f *fakeSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int) ([]sdk.Chunk, int64, error) { +func (f *fakeSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int, _ ...string) ([]sdk.Chunk, int64, error) { f.calls.chunkDocID = docID f.calls.chunkPage = page f.calls.chunkPageSize = pageSize