MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / computeProjectIndex

Function computeProjectIndex

sdk/src/run-state.ts:147–168  ·  view source on GitHub ↗
(params: ProjectIndexInput)

Source from the content-addressed store, hash-verified

145const MAX_DISCOVERED_PROJECT_READ_BYTES = 1_000_000
146
147async function computeProjectIndex(params: ProjectIndexInput): Promise<{
148 fileTree: FileTreeNode[]
149 fileTokenScores: Record<string, any>
150 tokenCallers: Record<string, any>
151}> {
152 const { cwd, fileTree, filePaths, readFile } = params
153 let fileTokenScores = {}
154 let tokenCallers = {}
155
156 if (filePaths.length > 0) {
157 try {
158 const tokenData = await getFileTokenScores(cwd, filePaths, readFile)
159 fileTokenScores = tokenData.tokenScores
160 tokenCallers = tokenData.tokenCallers
161 } catch (error) {
162 // If token scoring fails, continue with empty scores
163 console.warn('Failed to generate parsed symbol scores:', error)
164 }
165 }
166
167 return { fileTree, fileTokenScores, tokenCallers }
168}
169
170function getProjectIndexInput(params: {
171 cwd: string

Callers 2

initialSessionStateFunction · 0.85

Calls 1

getFileTokenScoresFunction · 0.90

Tested by

no test coverage detected