|
- <#
- .SYNOPSIS
- Start a new interview draft from the user's idea, or show where an existing draft stands.
-
- .DESCRIPTION
- Creates drafts/<slug>.json from templates/brief/draft.json with the project name, slug and
- idea filled in and status "draft". The coding agent fills in the rest during the interview
- and saves the file after each round of answers. To resume later, run
- Test-FoundryBrief.ps1 on the draft: it prints the stage and questions to continue with.
-
- .EXAMPLE
- pwsh -File tools/New-FoundryDraft.ps1 -Name "Moon Miner" -Idea "A small mining game..."
- #>
- [CmdletBinding()]
- param(
- [Parameter(Mandatory)][string]$Name,
- [Parameter(Mandatory)][string]$Idea,
- [string]$Slug,
- [switch]$Force
- )
- Import-Module (Join-Path $PSScriptRoot 'Foundry.psm1') -Force
- $root = Get-FoundryRoot
- if (-not $Slug) { $Slug = (($Name.ToLowerInvariant() -replace '[^a-z0-9]+', '-').Trim('-')) }
- if ($Slug.Length -lt 3) { $Slug = "project-$Slug".Trim('-') }
- $path = Join-Path $root "drafts/$Slug.json"
- if ((Test-Path -LiteralPath $path) -and -not $Force) {
- Write-Host "Draft already exists: $path" -ForegroundColor Yellow
- Write-Host "Resume it with: pwsh -File tools/Test-FoundryBrief.ps1 `"$path`""
- exit 1
- }
- $draft = Read-FoundryJson (Join-Path $root 'templates/brief/draft.json')
- $draft.project.name = $Name
- $draft.project.slug = $Slug
- $draft.project.idea = $Idea
- $draft.interview.startedOn = (Get-Date -Format 'yyyy-MM-dd')
- New-Item -ItemType Directory -Force -Path (Split-Path $path) | Out-Null
- [IO.File]::WriteAllText($path, ($draft | ConvertTo-Json -Depth 32), [Text.UTF8Encoding]::new($false))
- Write-Host "Draft created: $path"
- & (Join-Path $PSScriptRoot 'Test-FoundryBrief.ps1') $path -Mode Draft
- exit 0
|