Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/jendrikseipp/vulture
rev: "v2.14"
hooks:
- id: vulture
stages: [manual]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.5"
hooks:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ check: ## Run code quality tools.
@echo "🚀 Static type checking: Running mypy"
@uv run mypy

.PHONY: vulture
vulture: ## Run vulture to check for unused code.
@echo "🚀 Checking for unused code with vulture"
@uv run pre-commit run vulture --hook-stage manual --all-files

.PHONY: test
test: ## Test the code with pytest
@echo "🚀 Testing code: Running pytest"
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/bub"]

[tool.vulture]
ignore_names = ["test_*", "Test*"]
paths = ["src"]

[tool.mypy]
files = ["src"]
disallow_untyped_defs = true
Expand Down
14 changes: 7 additions & 7 deletions src/bub/agent/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ def __init__(
# Store custom system prompt if provided
self.custom_system_prompt = system_prompt

# Use ReAct principles as the main system prompt
self.prompt_formatter = ReActPromptFormatter()
self.system_prompt = self.prompt_formatter.REACT_PRINCIPLES
# Use format_prompt to generate the full system prompt
if self.custom_system_prompt:
self.system_prompt = self.prompt_formatter.format_prompt(self.custom_system_prompt)
else:
# Use config default if not provided
config_prompt = self.context.get_system_prompt()
self.system_prompt = self.prompt_formatter.format_prompt(config_prompt)

def reset_conversation(self) -> None:
"""Reset the conversation history."""
Expand All @@ -88,11 +93,6 @@ def chat(self, message: str, on_step: Optional[Callable[[str, str], None]] = Non
while True:
context_msg = self.context.build_context_message()

# Add system prompt to context if available
system_prompt = self.custom_system_prompt or self.context.get_system_prompt()
if system_prompt:
context_msg += f"\n\n[System Instructions]\n{system_prompt}"

messages = [
{"role": "system", "content": self.system_prompt},
{"role": "system", "content": context_msg},
Expand Down
6 changes: 5 additions & 1 deletion src/bub/tools/run_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RunCommandTool(Tool):
Parameters:
command: The shell command to execute (e.g., 'ls', 'cat file.txt').
cwd: Optional. The working directory to run the command in. Defaults to workspace root.
timeout: Optional. The timeout in seconds for the command to run. Defaults to 30 seconds.
"""

name: str = Field(default="run_command", description="The internal name of the tool")
Expand All @@ -32,6 +33,9 @@ class RunCommandTool(Tool):
cwd: Optional[str] = Field(
default=None, description="Optional. The working directory to run the command in. Defaults to workspace root."
)
timeout: int = Field(
default=30, description="The timeout in seconds for the command to run. Defaults to 30 seconds."
)

# List of dangerous commands that should be blocked
DANGEROUS_COMMANDS: ClassVar[set[str]] = {
Expand Down Expand Up @@ -104,7 +108,7 @@ def execute(self, context: Context) -> ToolResult:
cwd=working_dir,
capture_output=True,
text=True,
timeout=30,
timeout=self.timeout,
)
return ToolResult(
success=(result.returncode == 0),
Expand Down
Loading