Skip to content

shittycodingagent

Class info

Classes

Name Children Inherits
ShittyCodingAgentSharer
anyenv.text_sharing.shittycodingagent
Share text via GitHub Gists with shittycodingagent.ai preview URL.

    🛈 DocStrings

    ShittyCodingAgent.ai text sharing provider.

    Creates a GitHub Gist and returns a preview URL via shittycodingagent.ai.

    ShittyCodingAgentSharer

    Bases: TextSharer

    Share text via GitHub Gists with shittycodingagent.ai preview URL.

    Creates a secret (unlisted) GitHub Gist and returns a URL in the format: https://shittycodingagent.ai/session?{gist_id}

    Source code in src/anyenv/text_sharing/shittycodingagent.py
    class ShittyCodingAgentSharer(TextSharer):
        """Share text via GitHub Gists with shittycodingagent.ai preview URL.
    
        Creates a secret (unlisted) GitHub Gist and returns a URL in the format:
        https://shittycodingagent.ai/session?{gist_id}
        """
    
        def __init__(self, token: str | None = None) -> None:
            """Initialize the ShittyCodingAgent sharer.
    
            Args:
                token: GitHub personal access token. If not provided,
                       reads from GITHUB_TOKEN environment variable.
            """
            self._token = token or os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN")
            if not self._token:
                msg = "GitHub token required. Set GITHUB_TOKEN/GH_TOKEN or pass token parameter."
                raise ValueError(msg)
    
        @property
        def name(self) -> str:
            """Name of the sharing service."""
            return "ShittyCodingAgent.ai"
    
        async def share(
            self,
            content: str,
            *,
            title: str | None = None,
            syntax: str | None = None,
            visibility: Visibility = "unlisted",
            expires_in: int | None = None,
        ) -> ShareResult:
            """Share content via GitHub Gist with shittycodingagent.ai preview.
    
            Args:
                content: The text content to share
                title: Filename for the gist (defaults to "session.html")
                syntax: File extension hint (e.g. "html")
                visibility: Always creates unlisted gist (visibility param ignored)
                expires_in: Ignored (gists don't expire)
    
            Returns:
                ShareResult with shittycodingagent.ai preview URL
            """
            import anyenv
    
            # Default to session.html for the typical use case
            filename = title or f"session.{syntax or 'html'}"
    
            # Always create as unlisted (secret) gist
            payload: dict[str, Any] = {
                "files": {filename: {"content": content}},
                "public": False,
            }
            headers = {
                "Authorization": f"Bearer {self._token}",
                "Accept": "application/vnd.github+json",
                "X-GitHub-Api-Version": "2022-11-28",
            }
            url = "https://api.github.com/gists"
            response: dict[str, Any] = await anyenv.post_json(url, payload, headers=headers)
    
            gist_id = response["id"]
            raw_url = response["files"][filename]["raw_url"]
    
            # Build the shittycodingagent.ai preview URL
            preview_url = f"{PREVIEW_BASE_URL}?{gist_id}"
    
            return ShareResult(
                url=preview_url,
                raw_url=raw_url,
                delete_url=None,
                id=gist_id,
            )
    

    name property

    name: str
    

    Name of the sharing service.

    __init__

    __init__(token: str | None = None) -> None
    

    Initialize the ShittyCodingAgent sharer.

    Parameters:

    Name Type Description Default
    token str | None

    GitHub personal access token. If not provided, reads from GITHUB_TOKEN environment variable.

    None
    Source code in src/anyenv/text_sharing/shittycodingagent.py
    def __init__(self, token: str | None = None) -> None:
        """Initialize the ShittyCodingAgent sharer.
    
        Args:
            token: GitHub personal access token. If not provided,
                   reads from GITHUB_TOKEN environment variable.
        """
        self._token = token or os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN")
        if not self._token:
            msg = "GitHub token required. Set GITHUB_TOKEN/GH_TOKEN or pass token parameter."
            raise ValueError(msg)
    

    share async

    share(
        content: str,
        *,
        title: str | None = None,
        syntax: str | None = None,
        visibility: Visibility = "unlisted",
        expires_in: int | None = None,
    ) -> ShareResult
    

    Share content via GitHub Gist with shittycodingagent.ai preview.

    Parameters:

    Name Type Description Default
    content str

    The text content to share

    required
    title str | None

    Filename for the gist (defaults to "session.html")

    None
    syntax str | None

    File extension hint (e.g. "html")

    None
    visibility Visibility

    Always creates unlisted gist (visibility param ignored)

    'unlisted'
    expires_in int | None

    Ignored (gists don't expire)

    None

    Returns:

    Type Description
    ShareResult

    ShareResult with shittycodingagent.ai preview URL

    Source code in src/anyenv/text_sharing/shittycodingagent.py
    async def share(
        self,
        content: str,
        *,
        title: str | None = None,
        syntax: str | None = None,
        visibility: Visibility = "unlisted",
        expires_in: int | None = None,
    ) -> ShareResult:
        """Share content via GitHub Gist with shittycodingagent.ai preview.
    
        Args:
            content: The text content to share
            title: Filename for the gist (defaults to "session.html")
            syntax: File extension hint (e.g. "html")
            visibility: Always creates unlisted gist (visibility param ignored)
            expires_in: Ignored (gists don't expire)
    
        Returns:
            ShareResult with shittycodingagent.ai preview URL
        """
        import anyenv
    
        # Default to session.html for the typical use case
        filename = title or f"session.{syntax or 'html'}"
    
        # Always create as unlisted (secret) gist
        payload: dict[str, Any] = {
            "files": {filename: {"content": content}},
            "public": False,
        }
        headers = {
            "Authorization": f"Bearer {self._token}",
            "Accept": "application/vnd.github+json",
            "X-GitHub-Api-Version": "2022-11-28",
        }
        url = "https://api.github.com/gists"
        response: dict[str, Any] = await anyenv.post_json(url, payload, headers=headers)
    
        gist_id = response["id"]
        raw_url = response["files"][filename]["raw_url"]
    
        # Build the shittycodingagent.ai preview URL
        preview_url = f"{PREVIEW_BASE_URL}?{gist_id}"
    
        return ShareResult(
            url=preview_url,
            raw_url=raw_url,
            delete_url=None,
            id=gist_id,
        )
    

    main async

    main() -> None
    

    Example usage of the ShittyCodingAgentSharer class.

    Source code in src/anyenv/text_sharing/shittycodingagent.py
    async def main() -> None:
        """Example usage of the ShittyCodingAgentSharer class."""
        sharer = ShittyCodingAgentSharer()
        result = await sharer.share(
            "<html><body><h1>Test Session</h1></body></html>",
            title="session.html",
        )
        print(f"Preview URL: {result.url}")
        print(f"Raw: {result.raw_url}")
        print(f"Gist ID: {result.id}")