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

Function getProjectFileContext

evals/scaffolding.ts:31–71  ·  view source on GitHub ↗
(
  projectPath: string,
)

Source from the content-addressed store, hash-verified

29}
30
31export async function getProjectFileContext(
32 projectPath: string,
33): Promise<ProjectFileContext> {
34 _projectRootForMocks = projectPath
35 const fileTree = await getProjectFileTree({
36 projectRoot: projectPath,
37 fs: fs.promises,
38 })
39 const allFilePaths = getAllFilePaths(fileTree)
40 const knowledgeFilePaths = allFilePaths.filter(isKnowledgeFile)
41 const knowledgeFiles: Record<string, string> = {}
42 for (const filePath of knowledgeFilePaths) {
43 const content = readMockFile(projectPath, filePath)
44 if (content !== null) {
45 knowledgeFiles[filePath] = content
46 }
47 }
48 const fileTokenScoresResponse = await getFileTokenScores(
49 projectPath,
50 allFilePaths,
51 )
52 const fileTokenScores = fileTokenScoresResponse.tokenScores
53 return {
54 projectRoot: projectPath,
55 cwd: projectPath,
56 gitChanges: {
57 status: '',
58 diff: '',
59 diffCached: '',
60 lastCommitMessages: '',
61 },
62 changesSinceLastChat: {},
63 systemInfo: getSystemInfo(),
64 shellConfigFiles: {},
65 knowledgeFiles,
66 fileTokenScores,
67 fileTree,
68 agentTemplates: {},
69 customToolDefinitions: {},
70 }
71}
72
73export function resetRepoToCommit(projectPath: string, commit: string) {
74 console.log(`Resetting repository at ${projectPath} to commit ${commit}...`)

Callers

nothing calls this directly

Calls 5

getProjectFileTreeFunction · 0.90
getAllFilePathsFunction · 0.90
getFileTokenScoresFunction · 0.90
getSystemInfoFunction · 0.90
readMockFileFunction · 0.85

Tested by

no test coverage detected