| 24 | } |
| 25 | |
| 26 | func completeAlias(toComplete string) ([]string, cobra.ShellCompDirective) { |
| 27 | if strings.HasPrefix(toComplete, "/") || strings.HasPrefix(toComplete, ".") { |
| 28 | return completeAgentFilename(toComplete) |
| 29 | } |
| 30 | |
| 31 | var candidates []string |
| 32 | |
| 33 | // Add matching built-in agent names |
| 34 | for _, name := range config.BuiltinAgentNames() { |
| 35 | if strings.HasPrefix(name, toComplete) { |
| 36 | candidates = append(candidates, name+"\tbuilt-in agent") |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // Add matching aliases |
| 41 | cfg, err := userconfig.Load() |
| 42 | if err == nil { |
| 43 | for k, v := range cfg.Aliases { |
| 44 | if strings.HasPrefix(k, toComplete) { |
| 45 | candidates = append(candidates, k+"\t"+v.Path) |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | // Also add matching YAML files from the current directory |
| 51 | fileCandidates, _ := completeAgentFilename(toComplete) |
| 52 | candidates = append(candidates, fileCandidates...) |
| 53 | |
| 54 | return candidates, cobra.ShellCompDirectiveNoFileComp |
| 55 | } |
| 56 | |
| 57 | func completeMessage(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 58 | if !strings.HasPrefix(toComplete, "/") { |