MCPcopy Create free account
hub / github.com/JordanCoin/codemap / getProjectStats

Function getProjectStats

mcp/main.go:484–520  ·  view source on GitHub ↗

getProjectStats returns a brief summary of a project directory Uses the same scanner logic as the main codemap command (respects nested .gitignore files)

(path string)

Source from the content-addressed store, hash-verified

482// getProjectStats returns a brief summary of a project directory
483// Uses the same scanner logic as the main codemap command (respects nested .gitignore files)
484func getProjectStats(path string) string {
485 gitCache := scanner.NewGitIgnoreCache(path)
486 files, err := scanner.ScanFiles(path, gitCache, nil, nil)
487 if err != nil {
488 return "(error scanning)"
489 }
490
491 // Count files by language
492 langCounts := make(map[string]int)
493 for _, f := range files {
494 lang := scanner.DetectLanguage(f.Path)
495 if lang != "" {
496 langCounts[lang]++
497 }
498 }
499
500 // Find primary language
501 var primaryLang string
502 var maxCount int
503 for lang, count := range langCounts {
504 if count > maxCount {
505 maxCount = count
506 primaryLang = lang
507 }
508 }
509
510 // Check if it's a git repo
511 isGit := ""
512 if _, err := os.Stat(filepath.Join(path, ".git")); err == nil {
513 isGit = " [git]"
514 }
515
516 if lang, ok := scanner.LangDisplay[primaryLang]; ok {
517 return fmt.Sprintf("(%d files, %s%s)", len(files), lang, isGit)
518 }
519 return fmt.Sprintf("(%d files%s)", len(files), isGit)
520}
521
522func handleGetImporters(ctx context.Context, req *mcp.CallToolRequest, input ImportersInput) (*mcp.CallToolResult, any, error) {
523 fg, err := scanner.BuildFileGraph(input.Path)

Callers 2

handleListProjectsFunction · 0.85

Calls 3

NewGitIgnoreCacheFunction · 0.92
ScanFilesFunction · 0.92
DetectLanguageFunction · 0.92

Tested by 1