Skip to content

Commit 82129f6

Browse files
committed
fix: honor template overrides for tasks-template (#2278)
1 parent c118c1c commit 82129f6

4 files changed

Lines changed: 54 additions & 3 deletions

File tree

scripts/bash/setup-tasks.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Mirroring setup-plan.sh logic
3+
source "$(dirname "$0")/common.sh"
4+
5+
REPO_ROOT=$(get_repo_root)
6+
TEMPLATE=$(resolve_template "tasks-template" "$REPO_ROOT")
7+
8+
if [ -n "$TEMPLATE" ]; then
9+
export TASKS_TEMPLATE="$TEMPLATE"
10+
echo "Resolved tasks-template to $TASKS_TEMPLATE"
11+
fi

scripts/powershell/check-prerequisites.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@ EXAMPLES:
5353
exit 0
5454
}
5555

56-
# Source common functions
56+
# 1. Source common functions
5757
. "$PSScriptRoot/common.ps1"
5858

59-
# Get feature paths and validate branch
59+
# 2. Get the paths first so we can share them
6060
$paths = Get-FeaturePathsEnv
6161

62+
# 3. Pass the paths into the setup scripts
63+
. "$PSScriptRoot/setup-plan.ps1"
64+
. "$PSScriptRoot/setup-tasks.ps1"
65+
66+
# 4. NOW do the branch validation
6267
if (-not (Test-FeatureBranch -Branch $paths.CURRENT_BRANCH -HasGit:$paths.HAS_GIT)) {
6368
exit 1
6469
}

scripts/powershell/setup-tasks.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 1. Source common functions
2+
. "$PSScriptRoot\common.ps1"
3+
4+
# 2. Get the Repo Root (Robust Fallback)
5+
$REPO_ROOT = $env:REPO_ROOT
6+
if (-not $REPO_ROOT) {
7+
# Assuming script is in scripts/powershell/, go up two levels
8+
$REPO_ROOT = (Get-Item "$PSScriptRoot\..\..").FullName
9+
}
10+
11+
# 3. Resolve the tasks-template
12+
$template = Resolve-Template -TemplateName 'tasks-template' -RepoRoot $REPO_ROOT
13+
14+
if ($template -and (Test-Path $template)) {
15+
# 4. Read content and write to a resolved location (No-BOM)
16+
# This ensures cross-platform compatibility for the AI Agent
17+
$content = Get-Content -Raw -Path $template
18+
$Utf8NoBom = New-Object System.Text.UTF8Encoding($false)
19+
$targetPath = Join-Path $REPO_ROOT ".specify/tasks-template-resolved.md"
20+
21+
# Ensure the directory exists
22+
$null = New-Item -ItemType Directory -Force -Path (Split-Path $targetPath)
23+
24+
# Write the file
25+
[System.IO.File]::WriteAllText($targetPath, $content, $Utf8NoBom)
26+
27+
# 5. Export for the current session AND the environment variable
28+
$env:TASKS_TEMPLATE = $targetPath
29+
[Environment]::SetEnvironmentVariable("TASKS_TEMPLATE", $targetPath, "Process")
30+
31+
Write-Output "Successfully resolved tasks-template to: $targetPath"
32+
} else {
33+
Write-Error "Could not find tasks-template in $REPO_ROOT"
34+
exit 1
35+
}

templates/commands/tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ You **MUST** consider the user input before proceeding (if not empty).
7676
- Create parallel execution examples per user story
7777
- Validate task completeness (each user story has all needed tasks, independently testable)
7878
79-
4. **Generate tasks.md**: Use `templates/tasks-template.md` as structure, fill with:
79+
4. **Generate tasks.md**: Use `{{TASKS_TEMPLATE}}` as structure, fill with:
8080
- Correct feature name from plan.md
8181
- Phase 1: Setup tasks (project initialization)
8282
- Phase 2: Foundational tasks (blocking prerequisites for all user stories)

0 commit comments

Comments
 (0)