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

Function path_tier

atomic-repository/src/content_search.rs:261–326  ·  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

259/// Lower tier = higher priority. Source implementation files rank above
260/// tests, config, build scripts, docs, and generated files.
261fn path_tier(path: &str) -> usize {
262 // Tier 0: primary source directories
263 let source_prefixes = ["src/", "lib/", "pkg/", "internal/", "cmd/", "app/"];
264 for prefix in &source_prefixes {
265 if path.starts_with(prefix) {
266 // Demote test files even within src/
267 if is_test_path(path) {
268 return 2;
269 }
270 return 0;
271 }
272 }
273
274 // Tier 1: other code files (root-level .rs/.py/.cpp etc.)
275 let code_extensions = [
276 ".rs", ".go", ".py", ".ts", ".js", ".cpp", ".cc", ".c", ".h", ".hpp", ".java", ".kt",
277 ".swift", ".rb", ".cs",
278 ];
279 if code_extensions.iter().any(|ext| path.ends_with(ext)) {
280 if is_test_path(path) {
281 return 2;
282 }
283 return 1;
284 }
285
286 // Tier 2: test files
287 if is_test_path(path) {
288 return 2;
289 }
290
291 // Tier 3: docs and markdown
292 if path.ends_with(".md") || path.starts_with("docs/") || path.starts_with("doc/") {
293 return 3;
294 }
295
296 // Tier 4: build scripts, config, CI, generated files
297 let low_priority = [
298 "buildscripts/",
299 "build/",
300 ".github/",
301 "ci/",
302 "scripts/",
303 "debian/",
304 "rpm/",
305 "packaging/",
306 "vendor/",
307 "third_party/",
308 "node_modules/",
309 "target/",
310 ];
311 if low_priority.iter().any(|p| path.starts_with(p)) {
312 return 4;
313 }
314 if path.ends_with(".yml")
315 || path.ends_with(".yaml")
316 || path.ends_with(".toml")
317 || path.ends_with(".json")
318 || path.ends_with(".xml")

Callers 1

search_contentFunction · 0.70

Calls 2

is_test_pathFunction · 0.70
iterMethod · 0.45

Tested by

no test coverage detected