MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / classifyDirectory

Function classifyDirectory

src/utils/project-discovery.ts:88–139  ·  view source on GitHub ↗
(
  directoryPath: string,
  fileNames: Set<string>,
  directoryNames: Set<string>
)

Source from the content-addressed store, hash-verified

86}
87
88async 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
141export async function discoverProjectsWithinRoot(
142 trustedRootPath: string,

Callers 2

walkFunction · 0.85

Calls 2

isWorkspacePackageJsonFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected