"""
SmartTaskManager
Generated by Eden via recursive self-improvement
2025-10-28 00:06:44.715014
"""

class SmartTaskManager:
    """
    A smart task manager to organize and prioritize tasks effectively.
    
    Attributes:
        tasks (dict): Stores tasks with IDs as keys. Each task is a dictionary containing details like title, description, due date, priority, status, and tags.
    """

    def __init__(self):
        self.tasks = {}

    def add_task(self, title: str, description: str, due_date: str, 
                priority: int, status: str, tags: list) -> int:
        """
        Creates a new task and adds it to the task list.
        
        Args:
            title (str): Task title
            description (str): Description of the task
            due_date (str): Date when the task is due (YYYY-MM-DD)
            priority (int): Priority level, 1 being highest
            status (str): Current status ('pending', 'in-progress', 'completed')
            tags (list): List of relevant tags for the task
            
        Returns:
            int: The ID assigned to the new task
        """
        task_id = len(self.tasks) + 1
        self.tasks[task_id] = {
            'title': title,
            'description': description,
            'due_date': due_date,
            'priority': priority,
            'status': status,
            'tags': tags
        }
        return task_id

    def search_tasks(self, keyword: str) -> list:
        """
        Searches for tasks containing the given keyword in title or description.
        
        Args:
            keyword (str): The keyword to search for
            
        Returns:
            list: List of tasks matching the keyword
        """
        results = []
        for task_id, task in self.tasks.items():
            if keyword.lower() in task['title'].lower() or \
               keyword.lower() in task['description'].lower():
                results.append(task)
        return results

    def filter_tasks(self, by_priority: int = None, by_status: str = None, 
                   by_tag: str = None) -> list:
        """
        Filters tasks based on priority, status, or tag.
        
        Args:
            by_priority (int, optional): Filter by priority level. Defaults to None.
            by_status (str, optional): Filter by task status. Defaults to None.
            by_tag (str, optional): Filter by specific tag. Defaults to None.
            
        Returns:
            list: List of filtered tasks
        """
        filtered = self.tasks.values()
        
        if by_priority is not None:
            filtered = [task for task in filtered if task['priority'] == by_priority]
        if by_status is not None:
            filtered = [task for task in filtered if task['status'] == by_status]
        if by_tag is not None:
            filtered = [task for task in filtered if by_tag in task['tags']]
            
        return list(filtered)

    def suggest_actions(self) -> str:
        """
        Provides actionable suggestions based on overdue or high-priority tasks.
        
        Returns:
            str: Suggestions for next actions
        """
        today = datetime.date.today().strftime('%Y-%m-%d')
        suggestions = []
        
        # Check for overdue high-priority tasks
        for task in self.tasks.values():
            if (task['status'] == 'pending' and 
                task['priority'] <= 2 and 
                task['due_date'] < today):
                suggestions.append(f"Action recommended: {task['title']} is overdue!")
        
        # Check for high-priority pending tasks
        if not suggestions:
            for task in self.tasks.values():
                if (task['status'] == 'pending' and 
                    task['priority'] <= 2 and 
                    task['due_date'] >= today):
                    suggestions.append(f"Consider tackling: {task['title']} soon.")
        
        return '\n'.join(suggestions) if suggestions else "All tasks are up to date!"

# Example usage:
if __name__ == "__main__":
    import datetime
    
    manager = SmartTaskManager()
    
    # Adding tasks
    task1_id = manager.add_task(
        title="Complete Project Proposal",
        description="Finish the project proposal document.",
        due_date=datetime.date(2023, 10, 5).strftime('%Y-%m-%d'),
        priority=1,
        status='pending',
        tags=['work', 'deadline']
    )
    
    task2_id = manager.add_task(
        title="Buy Groceries",
        description="Pick up milk, eggs, and bread.",
        due_date=datetime.date(2023, 10, 4).strftime('%Y-%m-%d'),
        priority=3,
        status='pending',
        tags=['personal']
    )
    
    print("Added tasks:", task1_id, task2_id)
    
    # Example search
    print("\nSearch results for 'proposal':")
    for task in manager.search_tasks('proposal'):
        print(f"Task ID: {list(manager.tasks.keys())[list(manager.tasks.values()).index(task)]}")
        print(task['title'], "\n", task['description'], "\n")
    
    # Example filtering
    print("\nFilter by priority 1:")
    filtered_by_priority = manager.filter_tasks(by_priority=1)
    for task in filtered_by_priority:
        print(f"Task ID: {list(manager.tasks.keys())[list(manager.tasks.values()).index(task)]}")
        print(f"Title: {task['title']}, Status: {task['status']}\n")
    
    # Get suggestions
    print("\nSuggestions:")
    print(manager.suggest_actions())