Skip to content

jeremylongshore/tons-of-skills-marketplace / plugins/examples/pi-pathfinder/skills/skill-adapter

skill-adapter

Verified

Execute analyzes existing plugins to extract their capabilities, then adapts and applies those skills to the current task. Acts as a universal skill chameleon that learns from other plugins. Activates when you request "skill adapter" functionality. Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

assets/skill_adaptation_template.py

View on GitHub
#!/usr/bin/env python3

"""
Template for adapting skills from one plugin to another.

This module provides a template for adapting skills from a source plugin
to a target plugin. It includes placeholders for input parameters,
output variables, and adaptation logic.

"""

import logging

# Configure logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")


def adapt_skill(source_plugin_skills, target_plugin_requirements, user_query):
    """
    Adapt skills from the source plugin to meet the target plugin's requirements.

    Args:
        source_plugin_skills (dict): A dictionary representing the skills
                                      provided by the source plugin.
        target_plugin_requirements (dict): A dictionary representing the
                                            requirements of the target plugin.
        user_query (str): The original user query.

    Returns:
        dict: A dictionary containing the adapted input parameters for the
              target plugin.  Returns None if adaptation is not possible.

    Raises:
        TypeError: If input types are incorrect.
        ValueError: If input values are invalid.
        Exception: For any other unexpected error during adaptation.
    """

    try:
        if not isinstance(source_plugin_skills, dict):
            raise TypeError("source_plugin_skills must be a dictionary.")
        if not isinstance(target_plugin_requirements, dict):
            raise TypeError("target_plugin_requirements must be a dictionary.")
        if not isinstance(user_query, str):
            raise TypeError("user_query must be a string.")

        # Example adaptation logic (replace with your actual adaptation)
        adapted_input = {}

        # Check if the target plugin requires a 'text' input and adapt from user query
        if "text" in target_plugin_requirements:
            adapted_input["text"] = user_query

        # Check if the source plugin can provide a 'summary' and the target plugin requires it
        if "summary" in target_plugin_requirements and "summarize" in source_plugin_skills:
            # Assuming source_plugin_skills["summarize"] is a function that returns a summary
            # This is a placeholder, replace with actual logic using the source plugin's skills
            try:
                # Placeholder:  Replace with actual call to source plugin's skill
                # summary = source_plugin_skills["summarize"](user_query)
                summary = "This is a placeholder summary."  # Simulate a summary
                adapted_input["summary"] = summary
            except Exception as e:
                logging.error(f"Error summarizing using source plugin: {e}")
                return None  # Adaptation failed

        # Check if adaptation logic was successful
        if not adapted_input:
            logging.warning("No adaptation logic applied. Adaptation may not be effective.")

        return adapted_input

    except TypeError as e:
        logging.error(f"Type error during skill adaptation: {e}")
        raise
    except ValueError as e:
        logging.error(f"Value error during skill adaptation: {e}")
        raise
    except Exception:
        logging.exception("Unexpected error during skill adaptation.")
        raise


def post_process_output(target_plugin_output):
    """
    Post-processes the output from the target plugin.

    Args:
        target_plugin_output (any): The raw output from the target plugin.

    Returns:
        str: A human-readable string representing the processed output.

    Raises:
        TypeError: If input type is incorrect.
        Exception: For any other error during post-processing.
    """
    try:
        if target_plugin_output is None:
            return "No output from target plugin."

        # Simple example: Convert to string
        processed_output = str(target_plugin_output)

        return processed_output

    except TypeError as e:
        logging.error(f"Type error during output post-processing: {e}")
        raise
    except Exception:
        logging.exception("Unexpected error during output post-processing.")
        raise


if __name__ == "__main__":
    # Example Usage
    source_plugin_skills = {
        "summarize": lambda x: f"Summary of: {x}"  # Placeholder summarize function
    }
    target_plugin_requirements = {"text": "string", "summary": "string"}
    user_query = "This is a long document that needs to be summarized."

    try:
        adapted_input = adapt_skill(source_plugin_skills, target_plugin_requirements, user_query)

        if adapted_input:
            print("Adapted Input:", adapted_input)

            # Simulate target plugin output
            target_plugin_output = f"Target plugin processed: {adapted_input}"

            processed_output = post_process_output(target_plugin_output)
            print("Processed Output:", processed_output)
        else:
            print("Skill adaptation failed.")

    except Exception as e:
        print(f"An error occurred: {e}")
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall