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
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,25 @@ SimpleAgent is organized in a modular structure:
```
SimpleAgent/
├── core/ # Core framework components
│ ├── agent.py # Main SimpleAgent class
│ ├── run_manager.py # Execution loop management
│ ├── execution.py # Command execution and step management
│ ├── tool_manager.py # Dynamic tool loading system
│ ├── conversation.py # Conversation history management
│ ├── memory.py # Persistent memory system
│ ├── security.py # Security and path validation
│ ├── loop_detector.py # Loop detection and breaking
│ ├── summarizer.py # Change summarization
│ ├── config.py # Configuration management
│ └── version.py # Version and changelog tracking
│ ├── agent/ # Agent interface and run loop
│ │ ├── agent.py # Main SimpleAgent class
│ │ └── run_manager.py # Execution loop management
│ ├── execution/ # Command execution and tool management
│ │ ├── execution.py # Command execution and step management
│ │ ├── tool_manager.py # Dynamic tool loading system
│ │ └── summarizer.py # Change summarization
│ ├── conversation/ # Conversation and memory management
│ │ ├── conversation.py # Conversation history management
│ │ └── memory.py # Persistent memory system
│ ├── metacognition/ # Metacognition, prompts, and loop detection
│ │ ├── metacognition.py # Internal monologue and reflection
│ │ ├── loop_detector.py # Loop detection and breaking
│ │ └── prompts.py # Centralized prompt templates
│ ├── utils/ # Utilities and configuration
│ │ ├── security.py # Security and path validation
│ │ ├── config.py # Configuration management
│ │ └── version.py # Version and changelog tracking
│ └── __init__.py # Core package exports
├── commands/ # Local command modules (optional)
│ └── __init__.py # Command registration system
├── output/ # Generated files and session data
Expand Down
6 changes: 3 additions & 3 deletions SimpleAgent/SimpleAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from commands import REGISTERED_COMMANDS, COMMAND_SCHEMAS

# Import core modules
from core.agent import SimpleAgent
from core.config import OPENAI_API_KEY, MAX_STEPS, API_PROVIDER, API_BASE_URL, GEMINI_API_KEY, create_client
from core.version import AGENT_VERSION
from core.agent.agent import SimpleAgent
from core.utils.config import OPENAI_API_KEY, MAX_STEPS, API_PROVIDER, API_BASE_URL, GEMINI_API_KEY, create_client
from core.utils.version import AGENT_VERSION

# Commands will be initialized in main() based on user preference

Expand Down
4 changes: 2 additions & 2 deletions SimpleAgent/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
This package contains all the commands that SimpleAgent can execute.
Commands are organized by category in subdirectories.

This module now uses the new ToolManager from core.tool_manager to handle
This module now uses the new ToolManager from core.execution.tool_manager to handle
both local and remote (GitHub) tools with dynamic loading support.
"""

# Import the new tool manager
from core.tool_manager import (
from core.execution.tool_manager import (
REGISTERED_COMMANDS,
COMMAND_SCHEMAS,
register_command,
Expand Down
14 changes: 7 additions & 7 deletions SimpleAgent/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
This package contains the core components of the SimpleAgent system.
"""

from core.agent import SimpleAgent
from core.summarizer import ChangeSummarizer
from core.conversation import ConversationManager
from core.execution import ExecutionManager
from core.memory import MemoryManager
from core.run_manager import RunManager
from core.security import get_secure_path
from core.agent.agent import SimpleAgent
from core.execution.summarizer import ChangeSummarizer
from core.conversation.conversation import ConversationManager
from core.execution.execution import ExecutionManager
from core.conversation.memory import MemoryManager
from core.agent.run_manager import RunManager
from core.utils.security import get_secure_path

__all__ = [
"SimpleAgent",
Expand Down
1 change: 1 addition & 0 deletions SimpleAgent/core/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

12 changes: 6 additions & 6 deletions SimpleAgent/core/agent.py → SimpleAgent/core/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import os
from typing import List, Dict, Any, Optional

from core.conversation import ConversationManager
from core.execution import ExecutionManager
from core.memory import MemoryManager
from core.run_manager import RunManager
from core.security import get_secure_path
from core.config import DEFAULT_MODEL, OUTPUT_DIR
from core.conversation.conversation import ConversationManager
from core.execution.execution import ExecutionManager
from core.conversation.memory import MemoryManager
from core.agent.run_manager import RunManager
from core.utils.security import get_secure_path
from core.utils.config import DEFAULT_MODEL, OUTPUT_DIR


class SimpleAgent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import json
from typing import List, Dict, Any, Optional

from core.conversation import ConversationManager
from core.execution import ExecutionManager
from core.memory import MemoryManager
from core.summarizer import ChangeSummarizer
from core.loop_detector import LoopDetector
from core.metacognition import MetaCognition
from core.prompts import prompts
from core.config import OUTPUT_DIR
from core.conversation.conversation import ConversationManager
from core.execution.execution import ExecutionManager
from core.conversation.memory import MemoryManager
from core.execution.summarizer import ChangeSummarizer
from core.metacognition.loop_detector import LoopDetector
from core.metacognition.metacognition import MetaCognition
from core.metacognition.prompts import prompts
from core.utils.config import OUTPUT_DIR


class RunManager:
Expand Down
1 change: 1 addition & 0 deletions SimpleAgent/core/conversation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import json
from typing import Dict, Any, List

from core.config import MEMORY_FILE, OUTPUT_DIR
from core.utils.config import MEMORY_FILE, OUTPUT_DIR


class MemoryManager:
Expand Down
1 change: 1 addition & 0 deletions SimpleAgent/core/execution/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import inspect
from typing import Dict, Any, List, Optional, Tuple, Callable

from core.tool_manager import REGISTERED_COMMANDS, COMMAND_SCHEMAS, load_tool
from core.security import get_secure_path
from core.config import OUTPUT_DIR, DEFAULT_MODEL, create_client, API_PROVIDER
from core.execution.tool_manager import REGISTERED_COMMANDS, COMMAND_SCHEMAS, load_tool
from core.utils.security import get_secure_path
from core.utils.config import OUTPUT_DIR, DEFAULT_MODEL, create_client, API_PROVIDER


class ExecutionManager:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import os
from typing import List, Dict, Any
from core.config import SUMMARIZER_MODEL, create_client
from core.utils.config import SUMMARIZER_MODEL, create_client


class ChangeSummarizer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
from dataclasses import dataclass, field
import ast
import re
import pathlib

# Import GitHub token from config
from core.config import GITHUB_TOKEN
from core.utils.config import GITHUB_TOKEN

# Global registries
REGISTERED_COMMANDS: Dict[str, Callable] = {}
Expand Down Expand Up @@ -72,6 +73,7 @@ def initialize(self) -> None:
"""Initialize the tool manager by discovering available tools."""
self.logger.info("🚀 Initializing Tool Manager...")
self._create_temp_directory()
self._discover_local_tools()
self._discover_tools()
self._register_tool_schemas()
self.logger.info(f"✅ Discovered {len(self.tools)} tools")
Expand All @@ -82,6 +84,35 @@ def _create_temp_directory(self) -> None:
# Add to Python path
sys.path.insert(0, self.temp_dir)

def _discover_local_tools(self):
"""Discover all available tools from the local commands directory."""
base_dir = pathlib.Path(__file__).parent.parent / 'commands'
if not base_dir.exists():
return
for category_dir in base_dir.iterdir():
if not category_dir.is_dir() or category_dir.name.startswith('__'):
continue
for tool_dir in category_dir.iterdir():
if not tool_dir.is_dir() or tool_dir.name.startswith('__'):
continue
init_file = tool_dir / '__init__.py'
if not init_file.exists():
continue
module_name = f"commands.{category_dir.name}.{tool_dir.name}"
if module_name in sys.modules:
continue
try:
importlib.import_module(module_name)
tool = Tool(
name=tool_dir.name,
category=category_dir.name,
github_path=None
)
self.tools[tool_dir.name] = tool
self.logger.debug(f"Discovered local tool: {tool_dir.name} in {category_dir.name}")
except Exception as e:
self.logger.error(f"Failed to import local tool {module_name}: {e}")

def _discover_tools(self) -> None:
"""Discover all available tools from GitHub repository."""
try:
Expand Down
1 change: 1 addition & 0 deletions SimpleAgent/core/metacognition/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LoopDetector:
to help break out of unproductive patterns.

Loop breaking messages are generated by the centralized prompt system
in core.prompts for better maintainability. Use generate_breaking_message()
in core.metacognition.prompts for better maintainability. Use generate_breaking_message()
to create intervention messages.
"""

Expand Down Expand Up @@ -175,7 +175,7 @@ def generate_breaking_message(self, loop_info: Dict[str, Any], original_instruct
conversation_manager.add_message("user", message)
"""
# Import here to avoid circular imports
from core.prompts import prompts
from core.metacognition.prompts import prompts

return prompts.format_loop_breaking_message(
loop_type=loop_info['type'],
Expand Down
Loading