MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / CompleteVisiblePaths

Function CompleteVisiblePaths

cli/completer.go:58–99  ·  view source on GitHub ↗
(textBeforeCursor string, cwd string)

Source from the content-addressed store, hash-verified

56}
57
58func CompleteVisiblePaths(textBeforeCursor string, cwd string) []Completion {
59 base := cwd
60 if base == "" {
61 if current, err := os.Getwd(); err == nil {
62 base = current
63 }
64 }
65 expanded := expandHome(textBeforeCursor)
66 dirPart, prefix := splitPathFragment(expanded)
67 searchDir := dirPart
68 if searchDir == "" {
69 searchDir = base
70 } else if !filepath.IsAbs(searchDir) {
71 searchDir = filepath.Join(base, searchDir)
72 }
73
74 entries, err := os.ReadDir(searchDir)
75 if err != nil {
76 return nil
77 }
78 completions := make([]Completion, 0, len(entries))
79 for _, entry := range entries {
80 name := entry.Name()
81 if name == ".git" || !strings.HasPrefix(name, prefix) {
82 continue
83 }
84 display := name
85 if entry.IsDir() {
86 display += "/"
87 }
88 completions = append(completions, Completion{
89 Text: strings.TrimPrefix(name, prefix),
90 StartPosition: 0,
91 Display: display,
92 DisplayMeta: "",
93 })
94 }
95 sort.Slice(completions, func(i, j int) bool {
96 return completions[i].Display < completions[j].Display
97 })
98 return completions
99}
100
101func completeSlashCommand(stripped string, registry *skills.SkillRegistry, cwd string) []Completion {
102 seen := map[string]struct{}{}

Callers 1

CompleteInputFunction · 0.85

Calls 3

splitPathFragmentFunction · 0.85
expandHomeFunction · 0.70
NameMethod · 0.65

Tested by

no test coverage detected