Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions engine/antigravity_engine/hub/module_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def load_module_files(module_path: Path, workspace: Path) -> list[SourceFile]:
continue
if fpath.suffix.lower() not in SOURCE_EXTENSIONS:
continue
if _is_artifact(fpath):
if _is_artifact(fpath, module_path):
continue

try:
Expand Down Expand Up @@ -192,13 +192,19 @@ def load_module_files(module_path: Path, workspace: Path) -> list[SourceFile]:
return files


def _is_artifact(fpath: Path) -> bool:
def _is_artifact(fpath: Path, module_path: Path | None = None) -> bool:
"""Check if a file is a build artifact that should be skipped.

Checks directory names, file patterns, and heuristics for
generated/bundled/compiled files.
"""
parts = fpath.parts
if module_path is not None:
try:
parts = fpath.relative_to(module_path).parts
except ValueError:
parts = fpath.parts
else:
parts = fpath.parts
fname = fpath.name.lower()

# Directory-based: any parent dir is an artifact directory
Expand Down
18 changes: 18 additions & 0 deletions engine/tests/test_hub_module_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ def test_load_module_files_limits_workspace_root_to_direct_files(tmp_path: Path)
assert [item.rel_path for item in loaded] == ["main.go"]


def test_load_module_files_keeps_top_level_static_source_module(tmp_path: Path) -> None:
"""A real top-level static/ source module should not be treated as an artifact."""
static_dir = tmp_path / "static"
static_dir.mkdir()
(static_dir / "app.js").write_text("export function run() { return true; }\n", encoding="utf-8")

nested_static = static_dir / "nested" / "static"
nested_static.mkdir(parents=True)
(nested_static / "generated.js").write_text("export const generated = true;\n", encoding="utf-8")

modules = detect_modules(tmp_path)
assert "static" in modules

loaded = load_module_files(resolve_module_path(tmp_path, "static"), tmp_path)

assert [item.rel_path for item in loaded] == ["static/app.js"]


def test_typescript_grouping_uses_local_import_edges(tmp_path: Path) -> None:
"""Related TS/JS files should group together through semantic import keys."""
_write_text(
Expand Down