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

83 lines
2.0 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 statusCmd = &cobra.Command{
Use: "status",
Short: "Show engine status",
RunE: runStatus,
}
func init() {
rootCmd.AddCommand(statusCmd)
}
func runStatus(cmd *cobra.Command, args []string) error {
client := api.NewClient()
resp, err := client.Get("/api/v1/status")
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 status struct {
ModelName string `json:"model_name"`
EmbeddingDim int `json:"embedding_dim"`
Device string `json:"device"`
DB struct {
DocumentsByType map[string]int `json:"documents_by_type"`
TotalChunks int `json:"total_chunks"`
DBSizeBytes int64 `json:"db_size_bytes"`
} `json:"db"`
Queue struct {
Queued int `json:"queued"`
Processing int `json:"processing"`
} `json:"queue"`
}
if err := api.DecodeJSON(resp, &status); err != nil {
return fmt.Errorf("failed to decode response: %w", err)
}
pairs := [][]string{
{"Model", status.ModelName},
{"Embedding Dim", fmt.Sprintf("%d", status.EmbeddingDim)},
{"Device", status.Device},
{"Total Chunks", fmt.Sprintf("%d", status.DB.TotalChunks)},
{"DB Size", fmt.Sprintf("%d bytes", status.DB.DBSizeBytes)},
{"Queued Jobs", fmt.Sprintf("%d", status.Queue.Queued)},
{"Processing Jobs", fmt.Sprintf("%d", status.Queue.Processing)},
}
output.PrintKeyValue(pairs)
if len(status.DB.DocumentsByType) > 0 {
fmt.Println("\nDocuments by Type:")
var bPairs [][]string
for k, v := range status.DB.DocumentsByType {
bPairs = append(bPairs, []string{" " + k, fmt.Sprintf("%d", v)})
}
output.PrintKeyValue(bPairs)
}
return nil
}