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

Function path_tier

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

132/// Lower tier = higher priority. Source implementation files rank above
133/// tests, config, build scripts, docs, and generated files.
134fn path_tier(path: &str) -> usize {
135 // Tier 0: primary source directories
136 let source_prefixes = ["src/", "lib/", "pkg/", "internal/", "cmd/", "app/"];
137 for prefix in &source_prefixes {
138 if path.starts_with(prefix) {
139 // Demote test files even within src/
140 if is_test_path(path) {
141 return 2;
142 }
143 return 0;
144 }
145 }
146
147 // Tier 1: other code files (root-level .rs/.py/.cpp etc.)
148 let code_extensions = [
149 ".rs", ".go", ".py", ".ts", ".js", ".cpp", ".cc", ".c", ".h", ".hpp", ".java", ".kt",
150 ".swift", ".rb", ".cs",
151 ];
152 if code_extensions.iter().any(|ext| path.ends_with(ext)) {
153 if is_test_path(path) {
154 return 2;
155 }
156 return 1;
157 }
158
159 // Tier 2: test files
160 if is_test_path(path) {
161 return 2;
162 }
163
164 // Tier 3: docs and markdown
165 if path.ends_with(".md") || path.starts_with("docs/") || path.starts_with("doc/") {
166 return 3;
167 }
168
169 // Tier 4: build scripts, config, CI, generated files
170 let low_priority = [
171 "buildscripts/",
172 "build/",
173 ".github/",
174 "ci/",
175 "scripts/",
176 "debian/",
177 "rpm/",
178 "packaging/",
179 "vendor/",
180 "third_party/",
181 "node_modules/",
182 "target/",
183 ];
184 if low_priority.iter().any(|p| path.starts_with(p)) {
185 return 4;
186 }
187 if path.ends_with(".yml")
188 || path.ends_with(".yaml")
189 || path.ends_with(".toml")
190 || path.ends_with(".json")
191 || 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