mirror of
https://github.com/github/spec-kit.git
synced 2026-07-05 21:49:47 +08:00
fix: make Forge update-context scripts handle AGENTS.md directly
- Add fallback logic to update/create AGENTS.md when shared script doesn't support forge yet - Check if shared dispatcher knows about 'forge' before delegating - If shared script doesn't support forge, handle AGENTS.md updates directly: - Add Forge section to existing AGENTS.md if not present - Create new AGENTS.md with Forge section if file doesn't exist - Both bash and PowerShell scripts implement same logic - Prevents 'Unknown agent type' errors until shared scripts add forge support - Future-compatible: automatically delegates when shared script supports forge Addresses reviewer feedback about update-context scripts failing without forge support.
This commit is contained in:
@@ -20,4 +20,31 @@ if (-not $repoRoot -or -not (Test-Path (Join-Path $repoRoot '.specify'))) {
|
||||
}
|
||||
}
|
||||
|
||||
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType forge
|
||||
$sharedScript = "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1"
|
||||
# If the shared dispatcher already knows about "forge", delegate to it.
|
||||
if ((Test-Path $sharedScript) -and (Select-String -Path $sharedScript -Pattern "'forge'|`"forge`"" -Quiet)) {
|
||||
& $sharedScript -AgentType forge
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
# Forge-specific handling: update or create AGENTS.md directly until the shared
|
||||
# dispatcher script supports -AgentType forge.
|
||||
$agentsFile = Join-Path $repoRoot 'AGENTS.md'
|
||||
if (Test-Path $agentsFile) {
|
||||
$agentsContent = Get-Content -Path $agentsFile -ErrorAction Stop
|
||||
# Only add a Forge entry if one does not already exist.
|
||||
if (-not ($agentsContent | Where-Object { $_ -match '\bForge\b' })) {
|
||||
Add-Content -Path $agentsFile -Value ''
|
||||
Add-Content -Path $agentsFile -Value '## Forge'
|
||||
Add-Content -Path $agentsFile -Value '- Forge integration agent context'
|
||||
}
|
||||
} else {
|
||||
$newContent = @(
|
||||
'# Agents'
|
||||
''
|
||||
'## Forge'
|
||||
'- Forge integration agent context'
|
||||
)
|
||||
$newContent | Set-Content -Path $agentsFile -Encoding UTF8
|
||||
}
|
||||
exit 0
|
||||
|
||||
@@ -25,4 +25,26 @@ if [ -z "${REPO_ROOT:-}" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh" forge
|
||||
shared_script="$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh"
|
||||
# If the shared dispatcher already knows about "forge", delegate to it.
|
||||
if grep -q 'forge)' "$shared_script" 2>/dev/null; then
|
||||
exec "$shared_script" forge
|
||||
fi
|
||||
|
||||
# Forge-specific handling: update or create AGENTS.md directly until the shared
|
||||
# dispatcher script supports "forge".
|
||||
agents_file="$REPO_ROOT/AGENTS.md"
|
||||
if [ -f "$agents_file" ]; then
|
||||
# Only add a Forge entry if one does not already exist.
|
||||
if ! grep -q '\bForge\b' "$agents_file"; then
|
||||
printf '\n## Forge\n- Forge integration agent context\n' >> "$agents_file"
|
||||
fi
|
||||
else
|
||||
cat > "$agents_file" << 'EOF'
|
||||
# Agents
|
||||
|
||||
## Forge
|
||||
- Forge integration agent context
|
||||
EOF
|
||||
fi
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user