WispGPT Logo

Turn Any Code into Simple Recipes

Stop guessing what code does. WispGPT translates complex scripts from any language into easy-to-understand, greentext-style explanations. Understand, debug, and review code faster.

Understand AI-generated code, review PRs faster, and onboard new devs with ease.

WispGPT Code Diff Demo

Try WispGPT Now (MVP Demo)

> Your recipe will appear here...

Free tier demo: Limited daily use. Join waitlist for unlimited recipes & Pro features!

Stop Drowning in Complex Code

WispGPT cuts through the noise, giving you clear, concise explanations so you can focus on building, not deciphering.

WispGPT Recipe Output:

> analyze input code
> detect language (e.g., JavaScript)
> identify 186 lines of code
> found a function definition
> determine function parameters
> trace logic inside function
> format explanation into greentext
> recipe generation complete

Demystify Any Codebase

Pasted from Stack Overflow? AI-generated? Legacy nightmare? Get a plain English summary in seconds.

Understand AI-Generated Code

Copilot or ChatGPT wrote it, but do you *really* know what it does? WispGPT gives you the ground truth.

Accelerate Reviews & Learning

Quickly grasp pull requests, teach juniors, or learn new languages by seeing the core logic.

How WispGPT Transforms Your Workflow

Greentext Recipes

Code explained step-by-step in a simple, scannable `> action` format. No jargon, just clarity.

Supports Any Language

From Python and JavaScript to C++, Java, Rust, Go, and more. If it's code, WispGPT can explain it.

Focus on Logic Flow

Understand the 'what' and 'why' behind the code, not just the syntactic details. Perfect for high-level views.

Shareable & Embeddable

Easily copy recipes for documentation, PR comments, or teaching. (Sharable links coming soon!).

Code Diff Tracking (Soon)

The killer feature: See code changes explained in plain English. ">**changed** > old way >**to** >! new way".

For Everyone

Junior devs, senior architects, students, reviewers, even non-technical stakeholders can benefit.

See the Greentext Magic

WispGPT turns intimidating code blocks into a friendly, step-by-step narrative. It's like having a patient expert explain things.

Input Code

// src/index.js

// Helper function to add CORS headers
function addCorsHeaders(response) {
    const headers = new Headers(response.headers);
    headers.set('Access-Control-Allow-Origin', '*');
    headers.set('Access-Control-Allow-Methods', 'POST, OPTIONS');
    headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Language');
    return new Response(response.body, { ...response, headers });
}

// --- Comment Removal Functions ---

function removeLuaComments(code) {
    return code.replace(/--.*/g, '');
}

function removePythonComments(code) {
    return code.replace(/#.*/g, '');
}

function removeJSComments(code) {
    return code.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
}

function removeJavaComments(code) {
    return code.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
}

function removeCSharpComments(code) {
    return code.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
}

function removeCComments(code) {
    return code.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
}

function removePHPComments(code) {
    return code.replace(/\/\*[\s\S]*?\*\/|#.*|\/\/.*/g, '');
}

const commentRemovers = {
    lua: removeLuaComments,
    python: removePythonComments,
    javascript: removeJSComments,
    java: removeJavaComments,
    csharp: removeCSharpComments,
    c_cpp: removeCComments,
    php: removePHPComments,
};

function getCommentRemover(language) {
    return commentRemovers[language] || removeJSComments;
}

// Generate diff with only changes
function generateChangesOnlyDiff(original, modified, language) {
    const removeComments = getCommentRemover(language);
    const cleanOriginal = removeComments(original);
    const cleanModified = removeComments(modified);

    const originalLines = cleanOriginal.split('\n')
        .map(line => line.trim())
        .filter(line => line.length > 0);
    const modifiedLines = cleanModified.split('\n')
        .map(line => line.trim())
        .filter(line => line.length > 0);

    const changes = [];
    let i = 0, j = 0;

    while (i < originalLines.length || j < modifiedLines.length) {
        if (i >= originalLines.length) {
            changes.push(`+ ${modifiedLines[j]}`);
            j++;
        } else if (j >= modifiedLines.length) {
            changes.push(`- ${originalLines[i]}`);
            i++;
        } else if (originalLines[i] === modifiedLines[j]) {
            i++;
            j++;
        } else {
            // Diff logic continues...
        }
    }

    return changes.join('\n');
}

export default {
    async fetch(request, env, ctx) {
        if (request.method === 'OPTIONS') {
            return addCorsHeaders(new Response(null, { status: 204 }));
        }

        if (request.method !== 'POST') {
            return addCorsHeaders(new Response('Expected POST request', { status: 405 }));
        }

        try {
            const { original_code, modified_code, language = 'lua' } = await request.json();

            if (!original_code || !modified_code) {
                return addCorsHeaders(Response.json({ error: 'Missing original_code or modified_code' }, { status: 400 }));
            }

            const makerSystemPromptKey = `${language.toUpperCase()}_MAKER_SYSTEM_PROMPT`;
            const makerSystemPrompt = env[makerSystemPromptKey];
            const bakerSystemPrompt = env.BAKER_SYSTEM_PROMPT;

            if (!makerSystemPrompt || !bakerSystemPrompt) {
                return addCorsHeaders(Response.json({ error: `System prompts not configured for language: ${language}` }, { status: 500 }));
            }

            const modelIdentifier = "@cf/meta/llama-3.1-8b-instruct";

            // --- Phase 1: Generate initial recipe ---
            const removeComments = getCommentRemover(language);
            const cleanedOriginalCode = removeComments(original_code);
            const makerMessages = [
                { role: "system", content: makerSystemPrompt },
                { role: "user", content: `Code:\n\`\`\`${language}\n${cleanedOriginalCode}\n\`\`\`` }
            ];

            const makerOutput = await env.AI.run(modelIdentifier, { messages: makerMessages });
            const initialRecipe = makerOutput.response?.trim();
            if (!initialRecipe) {
                return addCorsHeaders(Response.json({ error: 'Maker returned empty recipe' }, { status: 500 }));
            }

            // --- Generate changes-only diff ---
            const changesOnlyDiff = generateChangesOnlyDiff(original_code, modified_code, language);

            if (!changesOnlyDiff.trim()) {
                return addCorsHeaders(Response.json({
                    updated_recipe_with_changes: initialRecipe + "\n\n> **no changes detected**"
                }));
            }

            // --- Phase 2: Generate diff recipe ---
            const bakerMessages = [
                { role: "system", content: bakerSystemPrompt },
                { role: "user", content: `Original Recipe:\n${initialRecipe}\n\nCode Changes Only:\n\`\`\`diff\n${changesOnlyDiff}\n\`\`\`` }
            ];

            const bakerOutput = await env.AI.run(modelIdentifier, { messages: bakerMessages });
            const diffRecipe = bakerOutput.response?.trim();
            if (!diffRecipe) {
                return addCorsHeaders(Response.json({ error: 'Baker returned empty diff recipe' }, { status: 500 }));
            }

            return addCorsHeaders(Response.json({ updated_recipe_with_changes: diffRecipe }));

        } catch (e) {
            console.error("Worker Error:", e.message, e.stack);
            return addCorsHeaders(Response.json({ error: "Internal error: " + e.message }, { status: 500 }));
        }
    },
};

WispGPT Recipe Output

> analyze input code
> detect language (e.g., JavaScript)
> identify 191 lines of code
> found a function definition
> determine function parameters
> trace logic inside function
> format explanation into greentext
> recipe generation complete

Before WispGPT (left) vs. After WispGPT (right)

Try It With Your Code

Get Started in 3 Simple Steps

1

Paste Your Code

Copy any code snippet from any language into WispGPT.

2

Generate Recipe

One click is all it takes for our AI to analyze the logic.

3

Understand & Share

Instantly get a plain English greentext recipe. Copy and use anywhere!

Loved by Developers (Soon!)

"WispGPT is a game-changer for understanding the mountain of code my AI assistant spits out. Finally, I know what it's *actually* doing!"

- Dev Who Uses Copilot

"Our code reviews are going to be so much faster with this. Especially the diff tracking feature – can't wait for that!"

- Eager Tech Lead

Ready for Code Superpowers?

The free WispGPT recipe generator is just the beginning. Join the waitlist for Pro features like **unlimited recipes, code diff tracking, history, team collaboration, API access**, and more!

Join the WispGPT Pro Waitlist!

Be the first to know when Pro launches and get early bird discounts!

Frequently Asked Questions

What is WispGPT?

WispGPT is a tool that converts programming code from any language into simple, human-readable "greentext recipes." It helps you quickly understand the logic and flow of code.

What programming languages are supported?

WispGPT is designed to work with virtually any programming language. Our AI model analyzes the structure and semantics to provide explanations.

How accurate are the recipes?

The recipes provide a high-level, logical flow. While great for understanding, always cross-reference with the original code for critical applications. It's an explainer, not a compiler!

Is there a free version?

Yes! You can use the basic recipe generator for free with daily usage limits. Pro features like diff tracking will be part of a paid plan.

When will diff tracking and Pro features be available?

We're working hard on them! Join our waitlist to be notified as soon as they launch and to get access to early bird pricing.

How is this different from AI code generators like Copilot?

Code generators *write* code for you. WispGPT *explains* existing code (whether written by a human or AI) so you can understand it better. They are complementary tools!