// Package search implements the `academy search` command tree: // chunks / kb / docs / sessions. package search import ( "github.com/spf13/cobra" "academy/cli/internal/cmdutil" ) // NewCmdSearch builds the `academy search` parent. Pure dispatcher to the // four subcommands - users must pick a verb (chunks / kb / docs / sessions). func NewCmdSearch(f *cmdutil.Factory) *cobra.Command { cmd := &cobra.Command{ Use: "search", Short: "Search across chunks, knowledge bases, documents, or sessions", Long: `Verb-noun search tree: search chunks "" --kb X hybrid retrieval (RAG search) search kb "" find KBs by name / description search docs "" --kb X find documents inside a KB search sessions "" find chat sessions by title / description`, Example: ` academy search chunks "what is RAG?" --kb engineering academy search kb "marketing" academy search docs "Q3 forecast" --kb finance academy search sessions "onboarding"`, } cmd.AddCommand(NewCmdChunks(f)) cmd.AddCommand(NewCmdKB(f)) cmd.AddCommand(NewCmdDocs(f)) cmd.AddCommand(NewCmdSessions(f)) return cmd } // emptyContentSearchHint returns an actionable note when a KB-scoped content // search (chunks / docs) yields zero results, so an agent can distinguish // "no match" from "the KB has no indexed content". Empty when n > 0 so it // never adds noise to real results. func emptyContentSearchHint(n int) string { if n > 0 { return "" } return "0 results: this may be no match, OR the KB has no indexed chunks. " + "Check `academy kb status ` (chunk_count) and `academy doc list --kb ` (parse_status); " + "documents in parse_status=draft are not indexed — run `academy doc reparse `." }