MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / path_tier

Function path_tier

atomic-repository/src/content_search.rs:494–559  ·  view source on GitHub ↗

Assign a ranking tier to a file path. Lower tier = higher priority. Source implementation files rank above tests, config, build scripts, docs, and generated files.

(path: &str)

Source from the content-addressed store, hash-verified

492/// Lower tier = higher priority. Source implementation files rank above
493/// tests, config, build scripts, docs, and generated files.
494fn path_tier(path: &str) -> usize {
495 // Tier 0: primary source directories
496 let source_prefixes = ["src/", "lib/", "pkg/", "internal/", "cmd/", "app/"];
497 for prefix in &source_prefixes {
498 if path.starts_with(prefix) {
499 // Demote test files even within src/
500 if is_test_path(path) {
501 return 2;
502 }
503 return 0;
504 }
505 }
506
507 // Tier 1: other code files (root-level .rs/.py/.cpp etc.)
508 let code_extensions = [
509 ".rs", ".go", ".py", ".ts", ".js", ".cpp", ".cc", ".c", ".h", ".hpp", ".java", ".kt",
510 ".swift", ".rb", ".cs",
511 ];
512 if code_extensions.iter().any(|ext| path.ends_with(ext)) {
513 if is_test_path(path) {
514 return 2;
515 }
516 return 1;
517 }
518
519 // Tier 2: test files
520 if is_test_path(path) {
521 return 2;
522 }
523
524 // Tier 3: docs and markdown
525 if path.ends_with(".md") || path.starts_with("docs/") || path.starts_with("doc/") {
526 return 3;
527 }
528
529 // Tier 4: build scripts, config, CI, generated files
530 let low_priority = [
531 "buildscripts/",
532 "build/",
533 ".github/",
534 "ci/",
535 "scripts/",
536 "debian/",
537 "rpm/",
538 "packaging/",
539 "vendor/",
540 "third_party/",
541 "node_modules/",
542 "target/",
543 ];
544 if low_priority.iter().any(|p| path.starts_with(p)) {
545 return 4;
546 }
547 if path.ends_with(".yml")
548 || path.ends_with(".yaml")
549 || path.ends_with(".toml")
550 || path.ends_with(".json")
551 || path.ends_with(".xml")

Callers 1

recorded_path_orderFunction · 0.85

Calls 2

is_test_pathFunction · 0.85
iterMethod · 0.45

Tested by

no test coverage detected