您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.7KB

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

Powered by TurnKey Linux.