chore(cli): gofmt sweep

`gofmt -w cli/` — trailing newlines, minor whitespace alignment. Caught
during PR-readiness review (`gofmt -l .` had been non-clean since the
em-dash → ASCII bulk replace earlier in the v0.4 series).
This commit is contained in:
nullkey
2026-05-15 05:00:26 +08:00
committed by lyingbug
parent f2e8e3f56c
commit 69fbbfc252
30 changed files with 74 additions and 84 deletions
-1
View File
@@ -84,4 +84,3 @@ func runList(jopts *cmdutil.JSONOptions, f *cmdutil.Factory) error {
}
return tw.Flush()
}
+7 -7
View File
@@ -60,17 +60,17 @@ type ChatService interface {
// continue a conversation: the answer text, retrieval references, and the
// session pointer to thread follow-ups.
type chatData struct {
Answer string `json:"answer"`
References []*sdk.SearchResult `json:"references"`
Answer string `json:"answer"`
References []*sdk.SearchResult `json:"references"`
// Thinking holds the reasoning / reflection text emitted by reasoning
// models (GPT-5, Claude extended thinking) via response_type=thinking
// frames. Omitted when empty (non-reasoning model or model didn't
// surface reasoning for this query).
Thinking string `json:"thinking,omitempty"`
SessionID string `json:"session_id"`
AssistantMessageID string `json:"assistant_message_id,omitempty"`
KBID string `json:"kb_id"`
Query string `json:"query"`
Thinking string `json:"thinking,omitempty"`
SessionID string `json:"session_id"`
AssistantMessageID string `json:"assistant_message_id,omitempty"`
KBID string `json:"kb_id"`
Query string `json:"query"`
}
// NewCmd builds `weknora chat <text>`.
-1
View File
@@ -145,4 +145,3 @@ func validateName(name string) error {
}
return nil
}
-1
View File
@@ -140,4 +140,3 @@ func TestAdd_JSON(t *testing.T) {
t.Errorf("first added context must be current=true, got %v", got)
}
}
-1
View File
@@ -124,4 +124,3 @@ func clearContextSecrets(store secrets.Store, c config.Context, name string) {
_ = store.Delete(name, "api_key")
}
}
-1
View File
@@ -203,4 +203,3 @@ func TestRemove_Current_TTY_PromptNo(t *testing.T) {
t.Errorf("aborted remove must not mutate config")
}
}
+3 -3
View File
@@ -75,9 +75,9 @@ func TestUse_NotFound_DeterministicTieBreak(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
_, _ = iostreams.SetForTest(t)
cfg := &config.Config{Contexts: map[string]config.Context{
"prod": {Host: "https://a"},
"prom": {Host: "https://b"},
"prog": {Host: "https://c"},
"prod": {Host: "https://a"},
"prom": {Host: "https://b"},
"prog": {Host: "https://c"},
}}
if err := config.Save(cfg); err != nil {
t.Fatalf("Save: %v", err)
+3 -3
View File
@@ -28,9 +28,9 @@ var docListFields = []string{
}
type ListOptions struct {
PageSize int // Items per server batch. With --all-pages, controls
// per-request load. Without, controls the single page size.
Status string // --status: filter by parse_status (server-side query param)
PageSize int // Items per server batch. With --all-pages, controls
// per-request load. Without, controls the single page size.
Status string // --status: filter by parse_status (server-side query param)
// Limit caps the returned items client-side (default 30; 0 = no cap).
// Applied after pagination / --all-pages accumulation and sort.
Limit int
+3 -2
View File
@@ -128,7 +128,9 @@ func TestList_KBIDRequired(t *testing.T) {
}
f := &cmdutil.Factory{
Config: func() (*config.Config, error) { return cfg, nil },
Client: func() (*sdk.Client, error) { return nil, errors.New("client should not be called when kb id is missing") },
Client: func() (*sdk.Client, error) {
return nil, errors.New("client should not be called when kb id is missing")
},
}
cmd := NewCmdList(f)
cmd.SetContext(context.Background())
@@ -337,4 +339,3 @@ func TestList_AllPages_WithLimit_StopsAtLimit(t *testing.T) {
// Should have called pages 1..3 (60 items) then capped at 50.
assert.LessOrEqual(t, len(svc.calls), 3, "should not walk past the page that fills --limit")
}
-1
View File
@@ -163,4 +163,3 @@ func walkMatches(root, pattern string) ([]string, error) {
}
return out, nil
}
-1
View File
@@ -191,4 +191,3 @@ func TestUploadRecursive_JSON_BareObject(t *testing.T) {
assert.True(t, typed.Silent, "JSON-path partial failure must be Silent")
assert.Equal(t, cmdutil.CodeServerError, typed.Code)
}
-1
View File
@@ -450,4 +450,3 @@ func (s *realServices) GetSystemInfo(ctx context.Context) (*sdk.SystemInfo, erro
}
return cli.GetSystemInfo(ctx)
}
+5 -5
View File
@@ -16,12 +16,12 @@ import (
// fakeEditSvc captures the (id, request) pair handed to UpdateKnowledgeBase
// and scripts the GetKnowledgeBase fetch used by the fetch-then-update path.
type fakeEditSvc struct {
current *sdk.KnowledgeBase // returned by GetKnowledgeBase
current *sdk.KnowledgeBase // returned by GetKnowledgeBase
currentErr error
gotID string
gotReq *sdk.UpdateKnowledgeBaseRequest
resp *sdk.KnowledgeBase
err error
gotID string
gotReq *sdk.UpdateKnowledgeBaseRequest
resp *sdk.KnowledgeBase
err error
}
func (f *fakeEditSvc) GetKnowledgeBase(_ context.Context, id string) (*sdk.KnowledgeBase, error) {
-1
View File
@@ -79,4 +79,3 @@ func TestEmpty_NotFound(t *testing.T) {
require.ErrorAs(t, err, &typed)
assert.Equal(t, cmdutil.CodeResourceNotFound, typed.Code)
}
-1
View File
@@ -139,4 +139,3 @@ func TestRoot_ContextFlagPropagation(t *testing.T) {
})
}
}
+3 -4
View File
@@ -65,9 +65,9 @@ func TestKBSearch_SortByNameLength(t *testing.T) {
require.NoError(t, runKBSearch(context.Background(), &KBSearchOptions{Query: "marketing", Limit: 20}, nil, svc))
got := out.String()
// Order: shortest name first.
iShort := strings.Index(got,"kb_short")
iMid := strings.Index(got,"kb_mid")
iLong := strings.Index(got,"kb_long")
iShort := strings.Index(got, "kb_short")
iMid := strings.Index(got, "kb_mid")
iLong := strings.Index(got, "kb_long")
assert.Less(t, iShort, iMid)
assert.Less(t, iMid, iLong)
}
@@ -116,4 +116,3 @@ func TestKBSearch_NetworkError(t *testing.T) {
require.ErrorAs(t, err, &typed)
assert.Equal(t, cmdutil.CodeAuthUnauthenticated, typed.Code)
}
-1
View File
@@ -80,4 +80,3 @@ func TestDelete_TTY_ConfirmNo(t *testing.T) {
assert.False(t, svc.called)
assert.Contains(t, errBuf.String(), "Aborted")
}
-1
View File
@@ -261,4 +261,3 @@ func TestList_AllPages_WithLimit_StopsAtLimit(t *testing.T) {
assert.Equal(t, 50, got)
assert.LessOrEqual(t, len(svc.calls), 3, "must not fetch beyond what fills --limit")
}