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

Function getProjectIndexInput

sdk/src/run-state.ts:170–201  ·  view source on GitHub ↗
(params: {
  cwd: string
  fs?: CodebuffFileSystem
  logger?: Logger
  projectFiles?: Record<string, string>
  discoveredProject?: { fileTree: FileTreeNode[]; filePaths: string[] }
})

Source from the content-addressed store, hash-verified

168}
169
170function getProjectIndexInput(params: {
171 cwd: string
172 fs?: CodebuffFileSystem
173 logger?: Logger
174 projectFiles?: Record<string, string>
175 discoveredProject?: { fileTree: FileTreeNode[]; filePaths: string[] }
176}): ProjectIndexInput | undefined {
177 const { cwd, fs, logger, projectFiles, discoveredProject } = params
178
179 if (projectFiles) {
180 const filePaths = Object.keys(projectFiles).sort()
181 return {
182 cwd,
183 fileTree: buildFileTree(filePaths),
184 filePaths,
185 readFile: (filePath: string) => projectFiles[filePath] || null,
186 }
187 }
188
189 if (discoveredProject) {
190 if (!fs || !logger) return undefined
191
192 return {
193 cwd,
194 fileTree: discoveredProject.fileTree,
195 filePaths: discoveredProject.filePaths.sort(),
196 readFile: createDiscoveredProjectReader({ cwd, fs, logger }),
197 }
198 }
199
200 return undefined
201}
202
203function createDiscoveredProjectReader(params: {
204 cwd: string

Callers 2

initialSessionStateFunction · 0.85

Calls 2

buildFileTreeFunction · 0.85

Tested by

no test coverage detected