( directoryPath: string, fileNames: Set<string>, directoryNames: Set<string> )
| 86 | } |
| 87 | |
| 88 | async function classifyDirectory( |
| 89 | directoryPath: string, |
| 90 | fileNames: Set<string>, |
| 91 | directoryNames: Set<string> |
| 92 | ): Promise<{ candidate?: DiscoveredProjectCandidate; continueScanning: boolean }> { |
| 93 | if (directoryNames.has('.codebase-context')) { |
| 94 | return { |
| 95 | candidate: { rootPath: directoryPath, evidence: 'existing_index' }, |
| 96 | continueScanning: false |
| 97 | }; |
| 98 | } |
| 99 | |
| 100 | if (directoryNames.has('.git')) { |
| 101 | return { |
| 102 | candidate: { rootPath: directoryPath, evidence: 'repo_root' }, |
| 103 | continueScanning: false |
| 104 | }; |
| 105 | } |
| 106 | |
| 107 | for (const marker of WORKSPACE_MARKERS) { |
| 108 | if (fileNames.has(marker)) { |
| 109 | return { |
| 110 | candidate: { rootPath: directoryPath, evidence: 'workspace_manifest' }, |
| 111 | continueScanning: true |
| 112 | }; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if (fileNames.has('package.json') && (await isWorkspacePackageJson(directoryPath))) { |
| 117 | return { |
| 118 | candidate: { rootPath: directoryPath, evidence: 'workspace_manifest' }, |
| 119 | continueScanning: true |
| 120 | }; |
| 121 | } |
| 122 | |
| 123 | for (const fileName of fileNames) { |
| 124 | if (PROJECT_MANIFEST_NAMES.has(fileName) || GRADLE_MANIFESTS.has(fileName)) { |
| 125 | return { |
| 126 | candidate: { rootPath: directoryPath, evidence: 'project_manifest' }, |
| 127 | continueScanning: false |
| 128 | }; |
| 129 | } |
| 130 | if (PROJECT_MANIFEST_SUFFIXES.some((suffix) => fileName.endsWith(suffix))) { |
| 131 | return { |
| 132 | candidate: { rootPath: directoryPath, evidence: 'project_manifest' }, |
| 133 | continueScanning: false |
| 134 | }; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return { continueScanning: true }; |
| 139 | } |
| 140 | |
| 141 | export async function discoverProjectsWithinRoot( |
| 142 | trustedRootPath: string, |
no test coverage detected