printContextFilesBySource groups files by source type and prints them.
(w *os.File, files []taskcontext.FileEntry, r *lipgloss.Renderer)
| 187 | |
| 188 | // printContextFilesBySource groups files by source type and prints them. |
| 189 | func printContextFilesBySource(w *os.File, files []taskcontext.FileEntry, r *lipgloss.Renderer) { |
| 190 | // Group scope files by scope name |
| 191 | scopeGroups := make(map[string][]taskcontext.FileEntry) |
| 192 | var scopeOrder []string |
| 193 | var explicit []taskcontext.FileEntry |
| 194 | |
| 195 | for _, f := range files { |
| 196 | if strings.HasPrefix(f.Source, "scope:") { |
| 197 | name := strings.TrimPrefix(f.Source, "scope:") |
| 198 | if _, exists := scopeGroups[name]; !exists { |
| 199 | scopeOrder = append(scopeOrder, name) |
| 200 | } |
| 201 | scopeGroups[name] = append(scopeGroups[name], f) |
| 202 | } else { |
| 203 | explicit = append(explicit, f) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | for _, name := range scopeOrder { |
| 208 | fmt.Fprintf(w, "\n%s\n", formatLabel(fmt.Sprintf("Scope files (%s):", name), r)) |
| 209 | for _, f := range scopeGroups[name] { |
| 210 | printContextFile(w, f, r) |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | if len(explicit) > 0 { |
| 215 | fmt.Fprintf(w, "\n%s\n", formatLabel("Explicit files:", r)) |
| 216 | for _, f := range explicit { |
| 217 | printContextFile(w, f, r) |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | if len(files) == 0 { |
| 222 | fmt.Fprintf(w, "\n%s\n", formatDim("No context files found.", r)) |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func printContextFile(w *os.File, f taskcontext.FileEntry, r *lipgloss.Renderer) { |
| 227 | path := f.Path |
no test coverage detected