Skip to content

Commit 23457d1

Browse files
safishamsiclaude
andcommitted
feat(detect): surface unclassified files instead of dropping them silently (#1692)
When classify_file() returned None — an extensionless, non-shebang file (Dockerfile, Gemfile, Makefile, Rakefile, LICENSE, ...) or an unsupported extension — the file left no trace at all: not counted, not listed, nothing. A user had no way to tell from graphify's output that those files were even considered. detect() now collects these into an "unclassified" list in its result, and `graphify extract` prints a one-line summary after the scan counts: "N file(s) not classified (no supported extension or shebang), skipped: Dockerfile, Makefile, ...". Real code/docs are unaffected. This is the visibility half of the issue; wiring up extractors/manifest handling for Dockerfile/Makefile-style files remains a separate feature. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent f84a0af commit 23457d1

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎graphify/__main__.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4673,6 +4673,17 @@ def _parse_float(name: str, raw: str) -> float:
46734673
f"{len(doc_files)} docs, {len(paper_files)} papers, "
46744674
f"{len(image_files)} images"
46754675
)
4676+
# Surface files that were seen but not classified (extensionless non-shebang
4677+
# project files like Dockerfile/Makefile, or unsupported extensions), so they
4678+
# are no longer invisible in graphify's own output (#1692).
4679+
_unclassified = detection.get("unclassified", []) if isinstance(detection, dict) else []
4680+
if _unclassified:
4681+
_names = ", ".join(sorted({Path(p).name for p in _unclassified})[:6])
4682+
_more = f" (+{len(_unclassified) - 6} more)" if len(_unclassified) > 6 else ""
4683+
print(
4684+
f"[graphify extract] {len(_unclassified)} file(s) not classified "
4685+
f"(no supported extension or shebang), skipped: {_names}{_more}"
4686+
)
46764687
stages.mark("detect")
46774688

46784689
# Resolve the LLM backend only now that we know whether the corpus

‎graphify/detect.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ def _wc(path: Path) -> int:
10861086
return _cache.cached_word_count(path, root, count_words)
10871087

10881088
skipped_sensitive: list[str] = []
1089+
unclassified: list[str] = []
10891090
ignore_patterns = _load_graphifyignore(root)
10901091
ignore_cache: dict[Path, bool] = {} # shared across all _is_ignored calls in this scan
10911092
# CLI --exclude patterns are anchored at the scan root and appended last
@@ -1171,6 +1172,13 @@ def _wc(path: Path) -> int:
11711172
skipped_sensitive.append(str(p))
11721173
continue
11731174
ftype = classify_file(p)
1175+
if not ftype:
1176+
# Considered but unclassifiable: an extension not in any supported set,
1177+
# or an extensionless, non-shebang file (Dockerfile, Gemfile, Makefile,
1178+
# Rakefile, LICENSE, ...). Previously these left no trace at all — not
1179+
# counted, not listed — so a user couldn't tell they were seen (#1692).
1180+
unclassified.append(str(p))
1181+
continue
11741182
if ftype:
11751183
if p.suffix.lower() in GOOGLE_WORKSPACE_EXTENSIONS:
11761184
if not google_workspace:
@@ -1236,6 +1244,7 @@ def _wc(path: Path) -> int:
12361244
"needs_graph": needs_graph,
12371245
"warning": warning,
12381246
"skipped_sensitive": skipped_sensitive,
1247+
"unclassified": sorted(unclassified),
12391248
"graphifyignore_patterns": len(ignore_patterns),
12401249
"scan_root": str(root.resolve()),
12411250
}

‎tests/test_detect.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,3 +1575,25 @@ def test_convert_office_file_does_not_rewrite_existing_sidecar(tmp_path, monkeyp
15751575
second = detect_mod.convert_office_file(src, out_dir)
15761576
assert second == first
15771577
assert second.stat().st_mtime_ns == mtime_before
1578+
1579+
1580+
def test_detect_records_unclassified_extensionless_files(tmp_path):
1581+
# #1692: extensionless, non-shebang project files (Dockerfile, Makefile, ...)
1582+
# were considered but left no trace. detect() now lists them under
1583+
# "unclassified" so they can be surfaced instead of silently vanishing.
1584+
(tmp_path / "app.py").write_text("def f():\n return 1\n")
1585+
(tmp_path / "Dockerfile").write_text("FROM python:3.12\nRUN pip install x\n")
1586+
(tmp_path / "Makefile").write_text("build:\n\techo hi\n")
1587+
(tmp_path / "LICENSE").write_text("MIT License\n")
1588+
res = detect(tmp_path)
1589+
unclassified = sorted(Path(p).name for p in res.get("unclassified", []))
1590+
assert unclassified == ["Dockerfile", "LICENSE", "Makefile"]
1591+
# real code is still classified, not swept into unclassified
1592+
assert any("app.py" in f for f in res["files"].get("code", []))
1593+
1594+
1595+
def test_detect_unclassified_empty_when_all_supported(tmp_path):
1596+
(tmp_path / "a.py").write_text("x = 1\n")
1597+
(tmp_path / "README.md").write_text("# hi\n")
1598+
res = detect(tmp_path)
1599+
assert res.get("unclassified", []) == []

0 commit comments

Comments
 (0)