setup-tasks.ps1 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env pwsh
  2. [CmdletBinding()]
  3. param(
  4. [switch]$Json,
  5. [switch]$Help
  6. )
  7. $ErrorActionPreference = 'Stop'
  8. if ($Help) {
  9. Write-Output "Usage: setup-tasks.ps1 [-Json] [-Help]"
  10. exit 0
  11. }
  12. # Source common functions
  13. . "$PSScriptRoot/common.ps1"
  14. # Get feature paths
  15. $paths = Get-FeaturePathsEnv
  16. if (-not (Test-Path $paths.IMPL_PLAN -PathType Leaf)) {
  17. [Console]::Error.WriteLine("ERROR: plan.md not found in $($paths.FEATURE_DIR)")
  18. $planCommand = '/speckit-plan'
  19. [Console]::Error.WriteLine("Run $planCommand first to create the implementation plan.")
  20. exit 1
  21. }
  22. if (-not (Test-Path $paths.FEATURE_SPEC -PathType Leaf)) {
  23. [Console]::Error.WriteLine("ERROR: spec.md not found in $($paths.FEATURE_DIR)")
  24. $specifyCommand = '/speckit-specify'
  25. [Console]::Error.WriteLine("Run $specifyCommand first to create the feature structure.")
  26. exit 1
  27. }
  28. # Build available docs list
  29. $docs = @()
  30. if (Test-Path $paths.RESEARCH) { $docs += 'research.md' }
  31. if (Test-Path $paths.DATA_MODEL) { $docs += 'data-model.md' }
  32. if ((Test-Path $paths.CONTRACTS_DIR) -and (Get-ChildItem -Path $paths.CONTRACTS_DIR -ErrorAction SilentlyContinue | Select-Object -First 1)) {
  33. $docs += 'contracts/'
  34. }
  35. if (Test-Path $paths.QUICKSTART) { $docs += 'quickstart.md' }
  36. # Resolve tasks template through override stack
  37. $tasksTemplate = Resolve-Template -TemplateName 'tasks-template' -RepoRoot $paths.REPO_ROOT
  38. if (-not $tasksTemplate -or -not (Test-Path -LiteralPath $tasksTemplate -PathType Leaf)) {
  39. $expectedCoreTemplate = Join-Path $paths.REPO_ROOT '.specify/templates/tasks-template.md'
  40. [Console]::Error.WriteLine("ERROR: Tasks template not found for repository root: $($paths.REPO_ROOT)`nTemplate resolution order: overrides -> presets -> extensions -> core.`nExpected shared/core template location: $expectedCoreTemplate`nTo continue, verify whether 'tasks-template.md' is available in '.specify/templates/overrides/', preset templates, extension templates, or restore the shared/core templates (for example by re-running 'specify init') so that '.specify/templates/tasks-template.md' exists.")
  41. exit 1
  42. }
  43. $tasksTemplate = (Resolve-Path -LiteralPath $tasksTemplate).Path
  44. # Output results
  45. if ($Json) {
  46. [PSCustomObject]@{
  47. FEATURE_DIR = $paths.FEATURE_DIR
  48. AVAILABLE_DOCS = $docs
  49. TASKS_TEMPLATE = $tasksTemplate
  50. } | ConvertTo-Json -Compress
  51. } else {
  52. Write-Output "FEATURE_DIR: $($paths.FEATURE_DIR)"
  53. Write-Output "TASKS_TEMPLATE: $(if ($tasksTemplate) { $tasksTemplate } else { 'not found' })"
  54. Write-Output "AVAILABLE_DOCS:"
  55. Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Out-Null
  56. Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Out-Null
  57. Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Out-Null
  58. Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Out-Null
  59. }