diff --git a/AGENTS.md b/AGENTS.md index 8b25eef50..c7a06ea59 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -455,6 +455,7 @@ Implementation: Extends `MarkdownIntegration` with custom `setup()` method that: 3. Applies Forge-specific transformations via `_apply_forge_transformations()` 4. Strips `handoffs` frontmatter key 5. Injects missing `name` fields +6. Ensures the shared `update-agent-context.*` scripts include a `forge` case that maps context updates to `AGENTS.md` (similar to `opencode`/`codex`/`pi`) and lists `forge` in their usage/help text ### Standard Markdown Agents diff --git a/scripts/bash/update-agent-context.sh b/scripts/bash/update-agent-context.sh index 831850f44..7ea54b274 100644 --- a/scripts/bash/update-agent-context.sh +++ b/scripts/bash/update-agent-context.sh @@ -30,12 +30,12 @@ # # 5. Multi-Agent Support # - Handles agent-specific file paths and naming conventions -# - Supports: Claude, Gemini, Copilot, Cursor, Qwen, opencode, Codex, Windsurf, Junie, Kilo Code, Auggie CLI, Roo Code, CodeBuddy CLI, Qoder CLI, Amp, SHAI, Tabnine CLI, Kiro CLI, Mistral Vibe, Kimi Code, Pi Coding Agent, iFlow CLI, Antigravity or Generic +# - Supports: Claude, Gemini, Copilot, Cursor, Qwen, opencode, Codex, Windsurf, Junie, Kilo Code, Auggie CLI, Roo Code, CodeBuddy CLI, Qoder CLI, Amp, SHAI, Tabnine CLI, Kiro CLI, Mistral Vibe, Kimi Code, Pi Coding Agent, iFlow CLI, Forge, Antigravity or Generic # - Can update single agents or all existing agent files # - Creates default Claude file if no agent files exist # # Usage: ./update-agent-context.sh [agent_type] -# Agent types: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|generic +# Agent types: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|forge|generic # Leave empty to update all existing agent files set -e @@ -690,12 +690,15 @@ update_specific_agent() { iflow) update_agent_file "$IFLOW_FILE" "iFlow CLI" || return 1 ;; + forge) + update_agent_file "$AGENTS_FILE" "Forge" || return 1 + ;; generic) log_info "Generic agent: no predefined context file. Use the agent-specific update script for your agent." ;; *) log_error "Unknown agent type '$agent_type'" - log_error "Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|generic" + log_error "Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|forge|generic" exit 1 ;; esac @@ -757,6 +760,7 @@ update_all_existing_agents() { _update_if_new "$KIMI_FILE" "Kimi Code" || _all_ok=false _update_if_new "$TRAE_FILE" "Trae" || _all_ok=false _update_if_new "$IFLOW_FILE" "iFlow CLI" || _all_ok=false + _update_if_new "$FORGE_FILE" "Forge" || _all_ok=false # If no agent files exist, create a default Claude file if [[ "$_found_agent" == false ]]; then @@ -783,7 +787,7 @@ print_summary() { fi echo - log_info "Usage: $0 [claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|generic]" + log_info "Usage: $0 [claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|forge|generic]" } #============================================================================== diff --git a/scripts/powershell/update-agent-context.ps1 b/scripts/powershell/update-agent-context.ps1 index 61df427c7..6ba93e183 100644 --- a/scripts/powershell/update-agent-context.ps1 +++ b/scripts/powershell/update-agent-context.ps1 @@ -9,7 +9,7 @@ Mirrors the behavior of scripts/bash/update-agent-context.sh: 2. Plan Data Extraction 3. Agent File Management (create from template or update existing) 4. Content Generation (technology stack, recent changes, timestamp) - 5. Multi-Agent Support (claude, gemini, copilot, cursor-agent, qwen, opencode, codex, windsurf, junie, kilocode, auggie, roo, codebuddy, amp, shai, tabnine, kiro-cli, agy, bob, vibe, qodercli, kimi, trae, pi, iflow, generic) + 5. Multi-Agent Support (claude, gemini, copilot, cursor-agent, qwen, opencode, codex, windsurf, junie, kilocode, auggie, roo, codebuddy, amp, shai, tabnine, kiro-cli, agy, bob, vibe, qodercli, kimi, trae, pi, iflow, forge, generic) .PARAMETER AgentType Optional agent key to update a single agent. If omitted, updates all existing agent files (creating a default Claude file if none exist). @@ -25,7 +25,7 @@ Relies on common helper functions in common.ps1 #> param( [Parameter(Position=0)] - [ValidateSet('claude','gemini','copilot','cursor-agent','qwen','opencode','codex','windsurf','junie','kilocode','auggie','roo','codebuddy','amp','shai','tabnine','kiro-cli','agy','bob','qodercli','vibe','kimi','trae','pi','iflow','generic')] + [ValidateSet('claude','gemini','copilot','cursor-agent','qwen','opencode','codex','windsurf','junie','kilocode','auggie','roo','codebuddy','amp','shai','tabnine','kiro-cli','agy','bob','qodercli','vibe','kimi','trae','pi','iflow','forge','generic')] [string]$AgentType ) @@ -67,6 +67,7 @@ $VIBE_FILE = Join-Path $REPO_ROOT '.vibe/agents/specify-agents.md' $KIMI_FILE = Join-Path $REPO_ROOT 'KIMI.md' $TRAE_FILE = Join-Path $REPO_ROOT '.trae/rules/AGENTS.md' $IFLOW_FILE = Join-Path $REPO_ROOT 'IFLOW.md' +$FORGE_FILE = Join-Path $REPO_ROOT 'AGENTS.md' $TEMPLATE_FILE = Join-Path $REPO_ROOT '.specify/templates/agent-file-template.md' @@ -415,8 +416,9 @@ function Update-SpecificAgent { 'trae' { Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae' } 'pi' { Update-AgentFile -TargetFile $AGENTS_FILE -AgentName 'Pi Coding Agent' } 'iflow' { Update-AgentFile -TargetFile $IFLOW_FILE -AgentName 'iFlow CLI' } + 'forge' { Update-AgentFile -TargetFile $FORGE_FILE -AgentName 'Forge' } 'generic' { Write-Info 'Generic agent: no predefined context file. Use the agent-specific update script for your agent.' } - default { Write-Err "Unknown agent type '$Type'"; Write-Err 'Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|generic'; return $false } + default { Write-Err "Unknown agent type '$Type'"; Write-Err 'Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|junie|kilocode|auggie|roo|codebuddy|amp|shai|tabnine|kiro-cli|agy|bob|vibe|qodercli|kimi|trae|pi|iflow|forge|generic'; return $false } } } @@ -445,6 +447,7 @@ function Update-AllExistingAgents { if (Test-Path $KIMI_FILE) { if (-not (Update-AgentFile -TargetFile $KIMI_FILE -AgentName 'Kimi Code')) { $ok = $false }; $found = $true } if (Test-Path $TRAE_FILE) { if (-not (Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae')) { $ok = $false }; $found = $true } if (Test-Path $IFLOW_FILE) { if (-not (Update-AgentFile -TargetFile $IFLOW_FILE -AgentName 'iFlow CLI')) { $ok = $false }; $found = $true } + if (Test-Path $FORGE_FILE) { if (-not (Update-AgentFile -TargetFile $FORGE_FILE -AgentName 'Forge')) { $ok = $false }; $found = $true } if (-not $found) { Write-Info 'No existing agent files found, creating default Claude file...' if (-not (Update-AgentFile -TargetFile $CLAUDE_FILE -AgentName 'Claude Code')) { $ok = $false } diff --git a/src/specify_cli/integrations/forge/scripts/update-context.ps1 b/src/specify_cli/integrations/forge/scripts/update-context.ps1 index 64f32faf3..474a9c6d0 100644 --- a/src/specify_cli/integrations/forge/scripts/update-context.ps1 +++ b/src/specify_cli/integrations/forge/scripts/update-context.ps1 @@ -21,30 +21,13 @@ if (-not $repoRoot -or -not (Test-Path (Join-Path $repoRoot '.specify'))) { } $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 + +# Always delegate to the shared updater; fail clearly if it is unavailable. +if (-not (Test-Path $sharedScript)) { + Write-Error "Error: shared agent context updater not found: $sharedScript" + Write-Error "Forge integration requires support in scripts/powershell/update-agent-context.ps1." + exit 1 } -# 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 +& $sharedScript -AgentType forge +exit $LASTEXITCODE diff --git a/src/specify_cli/integrations/forge/scripts/update-context.sh b/src/specify_cli/integrations/forge/scripts/update-context.sh index f2c5c51f7..2a5c46e1d 100755 --- a/src/specify_cli/integrations/forge/scripts/update-context.sh +++ b/src/specify_cli/integrations/forge/scripts/update-context.sh @@ -26,25 +26,13 @@ if [ -z "${REPO_ROOT:-}" ]; then fi 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 + +# Always delegate to the shared updater; fail clearly if it is unavailable. +if [ ! -x "$shared_script" ]; then + echo "Error: shared agent context updater not found or not executable:" >&2 + echo " $shared_script" >&2 + echo "Forge integration requires support in scripts/bash/update-agent-context.sh." >&2 + exit 1 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 +exec "$shared_script" forge