( files: readonly string[], fs: TextEditorFsCallbacks | undefined, )
| 812 | } |
| 813 | |
| 814 | function sourceCandidates( |
| 815 | files: readonly string[], |
| 816 | fs: TextEditorFsCallbacks | undefined, |
| 817 | ): string[] { |
| 818 | if (!fs) return []; |
| 819 | const candidates = files.filter((file) => { |
| 820 | if (isVirtualTemplatePath(file)) return false; |
| 821 | if (!/\.(?:jsx|tsx|html?)$/i.test(file)) return false; |
| 822 | const viewed = fs.view(file); |
| 823 | return viewed !== null && viewed.content.trim().length > 0; |
| 824 | }); |
| 825 | return candidates |
| 826 | .sort((a, b) => { |
| 827 | const score = (file: string): number => { |
| 828 | const lower = file.toLowerCase(); |
| 829 | if (lower === DEFAULT_SOURCE_ENTRY.toLowerCase()) return 0; |
| 830 | if (lower === LEGACY_SOURCE_ENTRY.toLowerCase()) return 1; |
| 831 | if (lower.endsWith('/app.jsx') || lower.endsWith('/app.tsx')) return 2; |
| 832 | if (lower.endsWith('/index.html')) return 3; |
| 833 | return 10; |
| 834 | }; |
| 835 | return score(a) - score(b) || a.localeCompare(b); |
| 836 | }) |
| 837 | .slice(0, 8); |
| 838 | } |
| 839 | |
| 840 | function buildWorkspaceBrief( |
| 841 | input: GenerateInput, |
no test coverage detected