NAME

Wordsmith::Claude::Blog::Builder - Interactive step-by-step blog builder

SYNOPSIS

use Wordsmith::Claude::Blog::Builder;
use IO::Async::Loop;

my $loop = IO::Async::Loop->new;

my $builder = Wordsmith::Claude::Blog::Builder->new(
    topic => 'Claude Code and the Perl SDK',
    style => 'technical',
    tone  => 'enthusiastic',
    loop  => $loop,

    # Research step - see what info was gathered
    on_research => sub {
        my ($research) = @_;
        print "Research:\n$research\n\n";
        print "Continue? [Y/n] ";
        my $answer = <STDIN>;
        return $answer !~ /^n/i;  # Return false to abort
    },

    # Outline step - choose from options
    on_outline => sub {
        my ($outlines) = @_;  # ArrayRef of outline options
        print "Choose an outline:\n";
        for my $i (0 .. $#$outlines) {
            print "\n[$i] ", $outlines->[$i], "\n";
        }
        print "\nChoice (or 'custom'): ";
        my $choice = <STDIN>;
        chomp $choice;
        if ($choice eq 'custom') {
            return undef;
        } elsif ($choice =~ /^\d+$/ && $choice < @$outlines) {
            return $outlines->[$choice];
        } else {
            return $outlines->[0];
        }
    },

    # Title step - choose from options
    on_title => sub {
        my ($titles) = @_;  # ArrayRef of title options
        print "Choose a title:\n";
        for my $i (0 .. $#$titles) {
            print "  [$i] $titles->[$i]\n";
        }
        print "Choice (or type custom): ";
        my $choice = <STDIN>;
        chomp $choice;
        return ($choice =~ /^\d+$/ && $choice < @$titles) ? $titles->[$choice] : ($choice || $titles->[0]);
    },

    # Section step - approve, regenerate, revise, or edit each section
    on_section => sub {
        my ($section_name, $draft) = @_;
        print "\n=== $section_name ===\n$draft\n";
        print "\n[a]pprove, [r]egenerate, re[v]ise, [e]dit? ";
        my $choice = <STDIN>;
        chomp $choice;
        if ($choice eq 'r') {
            return { action => 'regenerate' };
        } elsif ($choice eq 'v') {
            print "Enter revision instructions: ";
            my $instructions = <STDIN>;
            chomp $instructions;
            return { action => 'revise', instructions => $instructions };
        } elsif ($choice eq 'e') {
            print "Enter your edited version (end with '---END---' on its own line):\n";
            my @lines;
            while (my $line = <STDIN>) {
                last if $line =~ /^---END---$/;
                push @lines, $line;
            }
            return { action => 'replace', content => join('', @lines) };
        }
        return { action => 'approve' };
    },
);

my $result = $builder->build->get;
print $result->as_markdown;

DESCRIPTION

Interactive blog builder that walks through the content creation process step by step, giving you control at each stage:

1. Research - Gather information about the topic 2. Outline - Generate multiple outline options to choose from 3. Title - Generate multiple title options to choose from 4. Sections - Draft each section with approve/regenerate/edit options

METHODS

build

my $result = $builder->build->get;

Runs the full interactive build workflow. Returns a Future that resolves to a Wordsmith::Claude::Blog::Result.

AUTHOR

LNATION, <email at lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)