Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix: classify dotfiles named after a config extension in file_category (#2516)

zhongxiao-chang28b3675920c4
diff --git a/packages/core/src/repowise/core/generation/categories.py b/packages/core/src/repowise/core/generation/categories.py
index f6524fddd..1b8612ce9 100644
--- a/packages/core/src/repowise/core/generation/categories.py
+++ b/packages/core/src/repowise/core/generation/categories.py
@@ -13,7 +13,7 @@ from __future__ import annotations
from pathlib import PurePosixPath
-from repowise.core.support_paths import DOC_EXTENSIONS
+from repowise.core.support_paths import CONFIG_EXTENSIONS, DOC_EXTENSIONS, classification_token
# Categories the file_page prompt knows how to adapt to.
CATEGORY_CODE = "code"
@@ -57,7 +57,15 @@ def file_category(path: str, language: str = "", *, is_config: bool = False) ->
if suffix in _DATA_SUFFIXES or segments & _DATA_DIR_TOKENS:
return CATEGORY_DATA
- if is_config or (language or "").lower() in _CONFIG_LANGUAGES:
+ # `.env` has no pathlib suffix (pathlib only opens one at a dot after the
+ # first character), so resolve it through `classification_token` and match
+ # the token against the same `CONFIG_EXTENSIONS` set the sibling surfaces
+ # use for extensions (#2454).
+ if (
+ is_config
+ or (language or "").lower() in _CONFIG_LANGUAGES
+ or classification_token(path) in CONFIG_EXTENSIONS
+ ):
return CATEGORY_CONFIG
return CATEGORY_CODE
diff --git a/tests/unit/generation/test_categories.py b/tests/unit/generation/test_categories.py
index bf1137f6a..90ef80ffa 100644
--- a/tests/unit/generation/test_categories.py
+++ b/tests/unit/generation/test_categories.py
@@ -33,6 +33,24 @@ def test_config_files():
assert file_category("settings.py", "python", is_config=True) == CATEGORY_CONFIG
+def test_dotfile_named_after_a_config_extension_is_config():
+ """#2454: `.env` has no pathlib suffix, but its whole name is the entry.
+
+ `file_category()` used to fall through to `code` because dotfiles carry no
+ language and the ingestion flag stays False; the sibling surfaces are fixed
+ separately (#2381 for #2379).
+ """
+ assert file_category(".env") == CATEGORY_CONFIG
+ assert file_category("proj/.env") == CATEGORY_CONFIG
+ # `foo.env` carries the same suffix and is config on every surface.
+ assert file_category("foo.env") == CATEGORY_CONFIG
+
+
+def test_dotfiles_the_sets_do_not_name_stay_code():
+ """The token match is against `CONFIG_EXTENSIONS`, not "any dotfile"."""
+ assert file_category(".gitignore") == CATEGORY_CODE
+
+
def test_code_default():
assert file_category("src/services/billing.py", "python") == CATEGORY_CODE
diff --git a/tests/unit/test_support_paths.py b/tests/unit/test_support_paths.py
index 5049080a6..fdf6a1c78 100644
--- a/tests/unit/test_support_paths.py
+++ b/tests/unit/test_support_paths.py
@@ -68,6 +68,12 @@ def test_matching_is_case_insensitive():
assert is_support_path("Docs/Guide.md")
+def test_classification_token_prefers_suffix_and_falls_back_to_dotfile_name():
+ """#2454: `.env` has no pathlib suffix; its whole name is the token."""
+ assert classification_token("config.yaml") == ".yaml"
+ assert classification_token(".env") == ".env"
+ assert classification_token("proj/.ENV") == ".env"
+
class TestClassificationToken:
"""classification_token picks the right token for suffix vs dotfile."""