From 5cfe8123c3be1c5fbc7fb23143b0061b3fc6adee Mon Sep 17 00:00:00 2001 From: Digvijay Shelke Date: Tue, 1 Sep 2026 23:27:23 +0530 Subject: [PATCH 1/2] feat: add code file extensions --- frontend/src/lib/parsing.ts | 20 ++++++++++++++++++++ src/norefund/core/parsing.py | 30 +++++++++++++++++++++++++++++- src/norefund/core/service.py | 30 +++++++++++++++++++++++++++++- tests/test_desktop_api.py | 3 +++ tests/test_parsing.py | 30 +++++++++++++++++++++++++----- 5 files changed, 106 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/parsing.ts b/frontend/src/lib/parsing.ts index 2fd53d3..5aa3c8e 100644 --- a/frontend/src/lib/parsing.ts +++ b/frontend/src/lib/parsing.ts @@ -7,6 +7,26 @@ export const SUPPORTED_EXTENSIONS = [ ".md", ".py", ".json", + ".js", + ".ts", + ".tsx", + ".jsx", + ".go", + ".rs", + ".java", + ".c", + ".cpp", + ".h", + ".hpp", + ".html", + ".css", + ".yaml", + ".yml", + ".toml", + ".xml", + ".sql", + ".sh", + ".bash", ]; export function hasSupportedExtension(name: string): boolean { diff --git a/src/norefund/core/parsing.py b/src/norefund/core/parsing.py index 13e22a4..8e8eba9 100644 --- a/src/norefund/core/parsing.py +++ b/src/norefund/core/parsing.py @@ -7,7 +7,35 @@ logger = logging.getLogger(__name__) -SUPPORTED_EXTENSIONS = {".pdf", ".pptx", ".docx", ".txt", ".md", ".py", ".json"} +SUPPORTED_EXTENSIONS = { + ".pdf", + ".pptx", + ".docx", + ".txt", + ".md", + ".py", + ".json", + ".js", + ".ts", + ".tsx", + ".jsx", + ".go", + ".rs", + ".java", + ".c", + ".cpp", + ".h", + ".hpp", + ".html", + ".css", + ".yaml", + ".yml", + ".toml", + ".xml", + ".sql", + ".sh", + ".bash", +} def extract_text(path: Path) -> str: diff --git a/src/norefund/core/service.py b/src/norefund/core/service.py index 3da6922..4c96906 100644 --- a/src/norefund/core/service.py +++ b/src/norefund/core/service.py @@ -23,7 +23,35 @@ from norefund.logging_config import get_logger _LOG = get_logger(__name__) -_SUPPORTED = {".txt", ".md", ".pdf", ".pptx", ".docx", ".py", ".json"} +_SUPPORTED = { + ".txt", + ".md", + ".pdf", + ".pptx", + ".docx", + ".py", + ".json", + ".js", + ".ts", + ".tsx", + ".jsx", + ".go", + ".rs", + ".java", + ".c", + ".cpp", + ".h", + ".hpp", + ".html", + ".css", + ".yaml", + ".yml", + ".toml", + ".xml", + ".sql", + ".sh", + ".bash", +} @dataclass diff --git a/tests/test_desktop_api.py b/tests/test_desktop_api.py index 9597a8d..d83502a 100644 --- a/tests/test_desktop_api.py +++ b/tests/test_desktop_api.py @@ -148,6 +148,9 @@ def test_pick_files_filters_to_supported_extensions(): (pattern,) = kwargs["file_types"] assert "*.pdf" in pattern assert "*.docx" in pattern + assert "*.java" in pattern + assert "*.js" in pattern + assert "*.cpp" in pattern def test_pick_files_returns_empty_list_when_dialog_is_cancelled(): diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 78b760b..0803d02 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -5,11 +5,31 @@ from norefund.core.parsing import SUPPORTED_EXTENSIONS, extract_text -def test_supported_extensions_present(): - assert ".pdf" in SUPPORTED_EXTENSIONS - assert ".pptx" in SUPPORTED_EXTENSIONS - assert ".docx" in SUPPORTED_EXTENSIONS - assert ".txt" in SUPPORTED_EXTENSIONS +def test_supported_code_extensions_present(): + expected = { + ".js", + ".ts", + ".tsx", + ".jsx", + ".go", + ".rs", + ".java", + ".c", + ".cpp", + ".h", + ".hpp", + ".html", + ".css", + ".yaml", + ".yml", + ".toml", + ".xml", + ".sql", + ".sh", + ".bash", + } + + assert expected <= SUPPORTED_EXTENSIONS def test_extract_text_txt(tmp_path: Path): From b9c1cf32c2edff2b024d65a318e254cc7b3cc1f5 Mon Sep 17 00:00:00 2001 From: Digvijay Shelke Date: Fri, 11 Sep 2026 16:12:47 +0530 Subject: [PATCH 2/2] fix: address review feedback for code extensions --- src/norefund/core/service.py | 34 +++------------------------------- tests/test_desktop_api.py | 2 +- tests/test_parsing.py | 4 ++++ 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/norefund/core/service.py b/src/norefund/core/service.py index 4c96906..97716ab 100644 --- a/src/norefund/core/service.py +++ b/src/norefund/core/service.py @@ -6,6 +6,8 @@ from __future__ import annotations +from .parsing import SUPPORTED_EXTENSIONS, extract_text + import threading from collections.abc import Callable from dataclasses import dataclass @@ -23,36 +25,6 @@ from norefund.logging_config import get_logger _LOG = get_logger(__name__) -_SUPPORTED = { - ".txt", - ".md", - ".pdf", - ".pptx", - ".docx", - ".py", - ".json", - ".js", - ".ts", - ".tsx", - ".jsx", - ".go", - ".rs", - ".java", - ".c", - ".cpp", - ".h", - ".hpp", - ".html", - ".css", - ".yaml", - ".yml", - ".toml", - ".xml", - ".sql", - ".sh", - ".bash", -} - @dataclass class AnalysisResult: @@ -165,7 +137,7 @@ def analyze_folder( ) break - if not (f.is_file() and f.suffix.lower() in _SUPPORTED): + if not (f.is_file() and f.suffix.lower() in SUPPORTED_EXTENSIONS): continue # analyze_file already catches all exceptions internally diff --git a/tests/test_desktop_api.py b/tests/test_desktop_api.py index d83502a..b45dc40 100644 --- a/tests/test_desktop_api.py +++ b/tests/test_desktop_api.py @@ -149,7 +149,7 @@ def test_pick_files_filters_to_supported_extensions(): assert "*.pdf" in pattern assert "*.docx" in pattern assert "*.java" in pattern - assert "*.js" in pattern + assert "*.js;" in pattern assert "*.cpp" in pattern diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 0803d02..2810c6f 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -7,6 +7,10 @@ def test_supported_code_extensions_present(): expected = { + ".pdf", + ".pptx", + ".docx", + ".txt", ".js", ".ts", ".tsx",