Files
steve 9aab79d49b v2 restructure: Go client, Docker engine, release tooling
- Remove v1 Python CLI (src/kb_search/, tests/, root pyproject.toml, uv.lock, .venv)
- Add Go client with cross-platform build (client/)
- Add FastAPI engine with NVIDIA and multi-stage ROCm Dockerfiles (engine/)
- Add VERSION files for client and engine, wired into builds
- Add release.sh for automated build, tag, release, and Docker push
- Update README with build/release docs and ROCm migration note
- Clean up .gitignore for v2 project structure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 21:52:25 +00:00

88 lines
1.9 KiB
Go

package cmd
import (
"fmt"
"os"
"github.com/kb-search/kb/internal/api"
"github.com/kb-search/kb/internal/output"
"github.com/spf13/cobra"
)
var infoCmd = &cobra.Command{
Use: "info <id>",
Short: "Show document details",
Args: cobra.ExactArgs(1),
RunE: runInfo,
}
func init() {
rootCmd.AddCommand(infoCmd)
}
func runInfo(cmd *cobra.Command, args []string) error {
client := api.NewClient()
resp, err := client.Get("/api/v1/documents/" + args[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if err := api.CheckError(resp); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if output.IsJSON() {
var raw interface{}
if err := api.DecodeJSON(resp, &raw); err != nil {
return fmt.Errorf("failed to decode response: %w", err)
}
output.PrintJSON(raw)
return nil
}
var doc struct {
ID int `json:"id"`
Title string `json:"title"`
Type string `json:"doc_type"`
Tags []string `json:"tags"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Chunks []struct {
ID int `json:"id"`
Page interface{} `json:"page"`
Section string `json:"section"`
} `json:"chunks"`
}
if err := api.DecodeJSON(resp, &doc); err != nil {
return fmt.Errorf("failed to decode response: %w", err)
}
pairs := [][]string{
{"ID", fmt.Sprintf("%d", doc.ID)},
{"Title", doc.Title},
{"Type", doc.Type},
{"Tags", joinStrings(doc.Tags)},
{"Created", doc.CreatedAt},
{"Updated", doc.UpdatedAt},
{"Chunks", fmt.Sprintf("%d", len(doc.Chunks))},
}
output.PrintKeyValue(pairs)
if len(doc.Chunks) > 0 {
fmt.Println()
headers := []string{"CHUNK ID", "PAGE", "SECTION"}
var rows [][]string
for _, c := range doc.Chunks {
page := ""
if c.Page != nil {
page = fmt.Sprintf("%v", c.Page)
}
rows = append(rows, []string{fmt.Sprintf("%d", c.ID), page, c.Section})
}
output.PrintTable(headers, rows)
}
return nil
}