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
1 change: 0 additions & 1 deletion src/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import os
import autogen
import subprocess
from autogen import ConversableAgent, AssistantAgent, UserProxyAgent
import bot_tools
from git_utils import (
Expand Down
26 changes: 6 additions & 20 deletions src/bot_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,6 @@ def search_for_file(
return "File not found"


def estimate_tokens(text: str) -> int:
"""Estimate the number of tokens in text by splitting on whitespace

Args:
text: Text to estimate tokens for

Returns:
Estimated token count
"""
if not text:
return 0
return len(text.split())


def readfile(
filepath: str,
) -> str:
Expand Down Expand Up @@ -123,9 +109,9 @@ def readfile(
# Add line numbers
numbered_lines = [f"{i:04}: {line}" for i, line in enumerate(data)]

# Check total tokens
# Check total tokens (estimate by splitting on whitespace)
full_content = "".join(numbered_lines)
total_tokens = estimate_tokens(full_content)
total_tokens = len(full_content.split()) if full_content else 0

if total_tokens <= token_threshold:
return full_content
Expand All @@ -135,7 +121,7 @@ def readfile(
included_lines = []

for line in numbered_lines:
line_tokens = estimate_tokens(line)
line_tokens = len(line.split()) if line else 0
if current_tokens + line_tokens > token_threshold:
break
included_lines.append(line)
Expand Down Expand Up @@ -178,9 +164,9 @@ def readlines(
numbered_lines = [f"{i+start_line:04}: {line}" for i,
line in enumerate(lines)]

# Check total tokens
# Check total tokens (estimate by splitting on whitespace)
full_content = "".join(numbered_lines)
total_tokens = estimate_tokens(full_content)
total_tokens = len(full_content.split()) if full_content else 0

if total_tokens <= token_threshold:
return full_content
Expand All @@ -190,7 +176,7 @@ def readlines(
included_lines = []

for line in numbered_lines:
line_tokens = estimate_tokens(line)
line_tokens = len(line.split()) if line else 0
if current_tokens + line_tokens > token_threshold:
break
included_lines.append(line)
Expand Down
32 changes: 0 additions & 32 deletions src/branch_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,6 @@ def get_issue_related_branches(
os.chdir(orig_dir)
return related_branches

# def get_issue_related_branches(repo_path: str, issue_number: int) -> List[Tuple[str, bool]]:
# """
# Find all branches (local and remote) related to an issue number
#
# Args:
# repo_path: Path to local git repository
# issue_number: GitHub issue number to search for
#
# Returns:
# List of tuples containing (branch_name, is_remote)
# """
# repo = git.Repo(repo_path)
# related_branches = []
#
# # Check local branches
# for branch in repo.heads:
# if str(issue_number) in branch.name:
# related_branches.append((branch.name, False))
#
# # Check remote branches
# for remote in repo.remotes:
# for ref in remote.refs:
# # Skip HEAD ref
# if ref.name.endswith('/HEAD'):
# continue
# # Remove remote name prefix for comparison
# branch_name = ref.name.split('/', 1)[1]
# if str(issue_number) in branch_name:
# related_branches.append((branch_name, True))
#
# return related_branches


def get_current_branch(repo_path: str) -> str:
"""
Expand Down
3 changes: 0 additions & 3 deletions src/response_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@


def tab_print(x):
"""
Print with tab indentation for readability
"""
"""
Print with tab indentation for readability
:param x: The object to print
Expand Down
6 changes: 4 additions & 2 deletions src/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,17 @@ def has_pull_request_trigger(issue: Issue) -> bool:
return "Created pull request" in comments[-1].body


def has_pr_creation_comment(issue: Issue) -> bool:
def has_pr_creation_comment(issue: Issue) -> tuple:
"""
Check if an issue has comments indicating a PR was created

Args:
issue: The GitHub issue to check

Returns:
True if the issue has PR comments, False otherwise
Tuple of (bool, comment_body or None)
- bool: True if the issue has PR comments, False otherwise
- comment_body: The body of the PR creation comment if found, None otherwise
"""
comments = get_issue_comments(issue)
pr_comment_bool = any(
Expand Down