(state *globalState)
| 51 | } |
| 52 | |
| 53 | func (a *App) metadataSearchCommand(state *globalState) *cobra.Command { |
| 54 | var kindFilter string |
| 55 | cmd := &cobra.Command{ |
| 56 | Use: "search <query>", |
| 57 | Short: "Search the metadata index", |
| 58 | Args: cobra.MinimumNArgs(1), |
| 59 | RunE: func(cmd *cobra.Command, args []string) error { |
| 60 | out := cmd.OutOrStdout() |
| 61 | store := metadata.NewStore(state.storePath) |
| 62 | query := strings.Join(args, " ") |
| 63 | |
| 64 | results, err := store.Search(context.Background(), metadata.SearchQuery{ |
| 65 | Query: query, |
| 66 | Kind: kindFilter, |
| 67 | }) |
| 68 | if err != nil { |
| 69 | return fmt.Errorf("search failed: %w", err) |
| 70 | } |
| 71 | if len(results) == 0 { |
| 72 | fmt.Fprintf(out, "No results for %q\n", query) |
| 73 | return nil |
| 74 | } |
| 75 | fmt.Fprintf(out, "Found %d result(s) for %q:\n\n", len(results), query) |
| 76 | fmt.Fprintf(out, " %-8s %-30s %-25s %s\n", "KIND", "NAME", "REPO", "DESCRIPTION") |
| 77 | fmt.Fprintf(out, " %-8s %-30s %-25s %s\n", |
| 78 | strings.Repeat("─", 8), strings.Repeat("─", 30), |
| 79 | strings.Repeat("─", 25), strings.Repeat("─", 40)) |
| 80 | for _, item := range results { |
| 81 | repo := item.RepoOwner + "/" + item.RepoName |
| 82 | desc := item.Description |
| 83 | if len(desc) > 50 { |
| 84 | desc = desc[:47] + "..." |
| 85 | } |
| 86 | fmt.Fprintf(out, " %-8s %-30s %-25s %s\n", item.Kind, item.Name, repo, desc) |
| 87 | } |
| 88 | return nil |
| 89 | }, |
| 90 | } |
| 91 | cmd.Flags().StringVar(&kindFilter, "type", "", "Filter by kind (skill, agent, instruction, plugin)") |
| 92 | return cmd |
| 93 | } |
| 94 | |
| 95 | func (a *App) metadataInstallCommand(state *globalState) *cobra.Command { |
| 96 | var targets []string |
no test coverage detected