Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0b83a59
Log script creation and execution for #51
BuczynskiRafal Feb 21, 2025
beeb4f2
manual test for debugger logs_from_running_script method
BuczynskiRafal Feb 23, 2025
78cffa6
rebase with master
BuczynskiRafal Feb 24, 2025
4cb8871
Update issue templates
Grigorij-Dudnik Feb 26, 2025
9fe63f8
improve code structure based on review feedback
BuczynskiRafal Mar 3, 2025
2b19985
missing dependencies
BuczynskiRafal Mar 3, 2025
fb0d38e
Merge branch 'dev' into feature/run-python-scripts-in-env
BuczynskiRafal Mar 9, 2025
22d7cdf
rename EXECUTE env var to DEBUG_RUN_CODE
BuczynskiRafal Mar 9, 2025
f261ed8
Merge branch 'dev' into feature/run-python-scripts-in-env
BuczynskiRafal Mar 27, 2025
7a6385e
improve code structure based on review feedback
BuczynskiRafal Mar 27, 2025
b98ab31
In .env, pass the name of the file to run within the created project.
BuczynskiRafal Mar 28, 2025
62eb78e
adding file execution after executor
BuczynskiRafal Apr 3, 2025
84387d4
Merge branch 'dev' into feature/run-python-scripts-in-env
BuczynskiRafal Apr 3, 2025
f729f0f
remove redundant variable
BuczynskiRafal Apr 9, 2025
95e8e4d
rebase
BuczynskiRafal Apr 9, 2025
6bd8145
Silent setup
BuczynskiRafal Apr 12, 2025
2e13c4b
Silent setup tests update
BuczynskiRafal Apr 12, 2025
e203c16
reindexing bug solved
Grigorij-Dudnik Apr 4, 2025
f8c806a
gif back
Grigorij-Dudnik Apr 6, 2025
5901424
dog removed
Grigorij-Dudnik Apr 6, 2025
87daeb6
changing readme
Grigorij-Dudnik Apr 9, 2025
ff71295
changing readme
Grigorij-Dudnik Apr 9, 2025
355e8f6
changing readme
Grigorij-Dudnik Apr 9, 2025
d640be6
changing readme
Grigorij-Dudnik Apr 9, 2025
aaa8c02
changing readme
Grigorij-Dudnik Apr 9, 2025
590e677
changing readme
Grigorij-Dudnik Apr 9, 2025
f410859
changing readme
Grigorij-Dudnik Apr 9, 2025
acc73f6
changing readme
Grigorij-Dudnik Apr 9, 2025
7240118
changing readme
Grigorij-Dudnik Apr 9, 2025
81eafc7
slash bug solved
Grigorij-Dudnik Apr 9, 2025
1786a64
planner human ai message bug solved
Grigorij-Dudnik Apr 9, 2025
5485ae7
planer bug fix
Grigorij-Dudnik Apr 11, 2025
7e8ce7a
debugger prompt improved
Grigorij-Dudnik Apr 12, 2025
46e1402
updates
Grigorij-Dudnik Apr 15, 2025
6539653
working on backround research of second task
Grigorij-Dudnik Apr 16, 2025
ad4d65a
working on paralel research
Grigorij-Dudnik Apr 16, 2025
c70c61e
update on work
Grigorij-Dudnik Apr 18, 2025
3f7ed0b
solved bug with background researcher
Grigorij-Dudnik Apr 20, 2025
885638c
working on task background research - saving
Grigorij-Dudnik Apr 21, 2025
275660c
background work imrovement
Grigorij-Dudnik Apr 21, 2025
e1502c3
imporvements
Grigorij-Dudnik Apr 21, 2025
3589056
self-closing divs bug solved
Grigorij-Dudnik Apr 22, 2025
837ac16
readme changes
Grigorij-Dudnik Apr 23, 2025
80d831f
readme changes
Grigorij-Dudnik Apr 23, 2025
3e77b80
work
Grigorij-Dudnik Apr 23, 2025
6e8f1b0
readme changes
Grigorij-Dudnik Apr 25, 2025
4201f80
readme changes
Grigorij-Dudnik Apr 25, 2025
b72e875
wider logo
Grigorij-Dudnik Apr 25, 2025
56a8ff9
timeout improvements
Grigorij-Dudnik Apr 25, 2025
b190a3a
improving researcher
Grigorij-Dudnik Apr 25, 2025
683b43d
improving uploading research
Grigorij-Dudnik Apr 26, 2025
4708628
improving uploading research
Grigorij-Dudnik Apr 26, 2025
1c42d1f
Log script creation and execution for #51
BuczynskiRafal Feb 21, 2025
f8b5a35
manual test for debugger logs_from_running_script method
BuczynskiRafal Feb 23, 2025
8553d47
rebase with master
BuczynskiRafal Feb 24, 2025
c45537d
improve code structure based on review feedback
BuczynskiRafal Mar 3, 2025
11b22f3
improve code structure based on review feedback
BuczynskiRafal Mar 27, 2025
9b6441f
In .env, pass the name of the file to run within the created project.
BuczynskiRafal Mar 28, 2025
736070b
adding file execution after executor
BuczynskiRafal Apr 3, 2025
ca762fa
rebase
BuczynskiRafal Apr 9, 2025
46fcbf4
Replace os.path.join with join_paths for better cross-platform compat…
BuczynskiRafal Apr 26, 2025
c14c966
fix
BuczynskiRafal Apr 26, 2025
e2315b5
Merge branch 'dev' into feature/run-python-scripts-in-env
BuczynskiRafal Apr 26, 2025
a0eecf1
fix
BuczynskiRafal Apr 26, 2025
005c353
handle windows paths
BuczynskiRafal May 2, 2025
e64ae22
Merge branch 'dev' into feature/run-python-scripts-in-env
BuczynskiRafal May 5, 2025
ccb06eb
Loop handling fix in debugger_agent.py
BuczynskiRafal May 10, 2025
c93e697
Merge pull request #61 from BuczynskiRafal/feature/run-python-scripts…
Grigorij-Dudnik May 18, 2025
7655351
improving code execution
Grigorij-Dudnik May 18, 2025
d3f52fc
python run done
Grigorij-Dudnik May 20, 2025
5fe2b53
python scripts run
Grigorij-Dudnik May 22, 2025
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
7 changes: 2 additions & 5 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ FRONTEND_URL=
EDIT_TRANSCRIPTION=
## Show planner intermediate reasoning
SHOW_LOGIC_PLAN=
# If the clean-coder should run the generated code.
EXECUTE_FILE_NAME=

# Optional - LLM observability
LANGCHAIN_TRACING_V2=
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY=
LANGCHAIN_PROJECT=
4 changes: 2 additions & 2 deletions .github/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Learn more about Clean Coder's idea [here](https://clean-coder.dev/faq/why_clean
- Create a [frontend based on images](https://clean-coder.dev/features/working_with_images/) with designs.
- [Speak to Clean Coder](https://clean-coder.dev/features/talk_to_cc/) instead of writing.
- Automatic file linting prevents from introducing incorrect changes and [log check for self-debug](https://clean-coder.dev/advanced_features_installation/logs_check/).
- [Sensitive files protection](https://clean-coder.dev/features/sensitive_file_protection/) from being watched by AI.
- [Run Python scripts](https://clean-coder.dev/advanced_features_installation/python_scripts_run/) for self-debug.


## ⛓️‍💥 Something got broken?
Expand All @@ -97,4 +97,4 @@ We hardly work on developing cutting-edge AI coder for you. Completely for free.
</div>
<br>

Sweat, tears and endless glory... [Join the Clean Coder contributors](https://clean-coder.dev/community/contributions_guide/)!
Sweat, tears and endless glory... [Join the Clean Coder contributors](https://clean-coder.dev/community/contributions_guide/)!
205 changes: 205 additions & 0 deletions non_src/tests/manual_tests/debugger_scenario2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import logging
import os
import sys
from collections.abc import Generator
from contextlib import contextmanager
from pathlib import Path

from langchain_core.messages import HumanMessage

repo_directory = Path(__file__).parents[3].resolve()
sys.path.append(str(repo_directory))
# Third-party imports
from dotenv import find_dotenv, load_dotenv # noqa: E402

# Local imports
from non_src.tests.manual_tests.utils_for_tests import cleanup_work_dir, setup_work_dir # noqa: E402
from src.agents.debugger_agent import Debugger # noqa: E402
from src.utilities.start_work_functions import file_folder_ignored # noqa: E402
from src.utilities.script_execution_utils import logs_from_running_script

# Constants
CODERIGNORE_PATTERNS = ("*.log", "*.pyc", "__pycache__")
ENV_DIR_NAME = "env"

# Type aliases
PathLike = Path | str

# Logging configuration
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.StreamHandler(sys.stdout)],
)
logger = logging.getLogger(Path(__file__).name)


def create_coderignore(target_dir: Path) -> Path:
"""Create .coderignore file with standard patterns.

Args:
target_dir (Path): Directory where .coderignore should be created.

Returns:
Path: Path to the created .coderignore file.

Raises:
OSError: If directory creation or file writing fails.
"""
try:
clean_coder_dir = target_dir / ".clean_coder"
clean_coder_dir.mkdir(parents=True, exist_ok=True)
ignore_file = clean_coder_dir / ".coderignore"
ignore_file.write_text("\n".join(CODERIGNORE_PATTERNS))
logger.info("Created .coderignore at: %s", ignore_file)
return ignore_file
except OSError as e:
logger.exception("Failed to create .coderignore: %s", e)
raise


@contextmanager
def managed_workspace(test_files: Path, work_dir: Path) -> Generator[Path, None, None]:
"""Context manager for temporary test workspace.

Args:
test_files (Path): Directory containing test files.
work_dir (Path): Directory to use as the temporary workspace.

Yields:
Path: The path to the temporary workspace.

Raises:
Exception: If workspace setup fails.
"""
try:
setup_work_dir(test_files_dir=test_files, manual_tests_folder=work_dir)
logger.info("Workspace set up with files from: %s", test_files)
create_coderignore(work_dir)
yield work_dir
except Exception as e:
logger.exception("Error during workspace setup: %s", e)
raise
finally:
if work_dir.exists():
cleanup_work_dir(manual_tests_folder=work_dir)
logger.info("Cleaned up workspace: %s", work_dir)


def collect_project_files(root_dir: Path) -> set[str]:
"""Gather project files respecting .coderignore rules.

Args:
root_dir (Path): Root directory to scan for files.

Returns:
set[str]: Set of relative file paths.
"""
files = set()
for root, _, filenames in os.walk(root_dir):
for filename in filenames:
full_path = Path(root) / filename
relative_path = full_path.relative_to(root_dir)
if not file_folder_ignored(str(relative_path)):
files.add(str(relative_path))
logger.debug("Added file to list: %s", relative_path)
else:
logger.debug("Skipped file: %s (ignored)", relative_path)
return files


def configure_environment() -> tuple[Path, Path]:
"""Set up repository paths and environment variables.

Returns:
tuple[Path, Path]: Paths to project files and temporary working directory.
"""
repo_root = Path(__file__).parents[3].resolve()
sys.path.append(str(repo_root))

load_dotenv(find_dotenv())
logger.info("Environment variables loaded")

project_files = repo_root / "non_src" / "tests" / "manual_tests" / "projects_files" / "debugger_scenario_2_files"
work_dir = Path(__file__).parent.resolve() / "sandbox_work_dir"
return project_files, work_dir


def main_test_flow() -> None:
"""Main execution flow for the debugger test scenario."""
project_files_dir, workspace_dir = configure_environment()

with managed_workspace(project_files_dir, workspace_dir) as workspace:
files = collect_project_files(workspace)
logger.info("Workspace contains %d files: %s", len(files), files)

# Check if main.py exists and create it if needed
main_py_path = workspace / "main.py"
if not main_py_path.exists():
main_py_path.write_text("print('Hello World!')")
logger.info("Created main.py with simple 'Hello World' script")

logger.info("Starting Test 1: Running script with silent setup (default behavior)")
test_state_silent = {
"messages": [
HumanMessage(content=f"File contents: main.py:\n\n{main_py_path.read_text()}\n"),
],
}

message_silent = logs_from_running_script(str(workspace), "main.py", silent_setup=True)
test_state_silent["messages"].append(HumanMessage(content=message_silent))
logger.info("Completed silent setup test")

logger.info("Starting Test 2: Running script with verbose setup logs")
test_state_verbose = {
"messages": [
HumanMessage(content=f"File contents: main.py:\n\n{main_py_path.read_text()}\n"),
],
}

# Remove environment to force recreation with logs
env_path = workspace / ENV_DIR_NAME
if env_path.exists():
import shutil
logger.info("Removing existing virtual environment to force recreation")
shutil.rmtree(env_path)

message_verbose = logs_from_running_script(str(workspace), "main.py", silent_setup=False)
test_state_verbose["messages"].append(HumanMessage(content=message_verbose))
logger.info("Completed verbose setup test")

# Verification checks
logger.info("Running verification checks")
assert env_path.exists(), "Virtual environment not created"
logger.info("Virtual environment exists as expected")

# Check if silent mode doesn't contain pip installation logs
if "pip" not in message_silent and "install" not in message_silent:
logger.info("Silent mode correctly suppresses setup logs")
else:
logger.warning("Silent mode may not be suppressing setup logs properly")
assert "pip" not in message_silent or "install" not in message_silent, "Setup logs should be silent"

# Check if verbose mode contains pip installation logs (if they were performed)
if "pip" in message_verbose and "install" in message_verbose:
logger.info("Verbose mode correctly shows pip installation logs")
else:
logger.warning("Verbose mode doesn't show installation logs, possibly because environment already existed")

# Check if script output is visible in both cases
if "Hello World!" in message_silent:
logger.info("Script output correctly visible in silent mode")
else:
logger.error("Script output missing in silent mode")
assert "Hello World!" in message_silent, "Missing expected output in silent mode"

if "Hello World!" in message_verbose:
logger.info("Script output correctly visible in verbose mode")
else:
logger.error("Script output missing in verbose mode")
assert "Hello World!" in message_verbose, "Missing expected output in verbose mode"

logger.info("All tests passed successfully")

if __name__ == "__main__":
main_test_flow()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello World!")
Loading