Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 45 additions & 14 deletions scripts/bash/update-agent-context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -639,75 +639,106 @@ update_specific_agent() {

update_all_existing_agents() {
local found_agent=false
# Track processed files to avoid duplicate processing when multiple variables point to the same file
# Using regular array for bash 3.2 compatibility (associative arrays require bash 4.0+)
local processed_files=()

# Helper function to check if a file has been processed (bash 3.2 compatible)
file_already_processed() {
local file_path="$1"
local processed_file
if [[ ${#processed_files[@]} -gt 0 ]]; then
for processed_file in "${processed_files[@]}"; do
if [[ "$processed_file" == "$file_path" ]]; then
return 0 # File already processed
fi
done
fi
return 1 # File not yet processed
}

# Check each possible agent file and update if it exists
if [[ -f "$CLAUDE_FILE" ]]; then
if [[ -f "$CLAUDE_FILE" ]] && ! file_already_processed "$CLAUDE_FILE"; then
update_agent_file "$CLAUDE_FILE" "Claude Code"
processed_files+=("$CLAUDE_FILE")
found_agent=true
fi

if [[ -f "$GEMINI_FILE" ]]; then
if [[ -f "$GEMINI_FILE" ]] && ! file_already_processed "$GEMINI_FILE"; then
update_agent_file "$GEMINI_FILE" "Gemini CLI"
processed_files+=("$GEMINI_FILE")
found_agent=true
fi

if [[ -f "$COPILOT_FILE" ]]; then
if [[ -f "$COPILOT_FILE" ]] && ! file_already_processed "$COPILOT_FILE"; then
update_agent_file "$COPILOT_FILE" "GitHub Copilot"
processed_files+=("$COPILOT_FILE")
found_agent=true
fi

if [[ -f "$CURSOR_FILE" ]]; then
if [[ -f "$CURSOR_FILE" ]] && ! file_already_processed "$CURSOR_FILE"; then
update_agent_file "$CURSOR_FILE" "Cursor IDE"
processed_files+=("$CURSOR_FILE")
found_agent=true
fi

if [[ -f "$QWEN_FILE" ]]; then
if [[ -f "$QWEN_FILE" ]] && ! file_already_processed "$QWEN_FILE"; then
update_agent_file "$QWEN_FILE" "Qwen Code"
processed_files+=("$QWEN_FILE")
found_agent=true
fi

if [[ -f "$AGENTS_FILE" ]]; then
if [[ -f "$AGENTS_FILE" ]] && ! file_already_processed "$AGENTS_FILE"; then
update_agent_file "$AGENTS_FILE" "Codex/opencode"
processed_files+=("$AGENTS_FILE")
found_agent=true
fi

if [[ -f "$WINDSURF_FILE" ]]; then
if [[ -f "$WINDSURF_FILE" ]] && ! file_already_processed "$WINDSURF_FILE"; then
update_agent_file "$WINDSURF_FILE" "Windsurf"
processed_files+=("$WINDSURF_FILE")
found_agent=true
fi

if [[ -f "$KILOCODE_FILE" ]]; then
if [[ -f "$KILOCODE_FILE" ]] && ! file_already_processed "$KILOCODE_FILE"; then
update_agent_file "$KILOCODE_FILE" "Kilo Code"
processed_files+=("$KILOCODE_FILE")
found_agent=true
fi

if [[ -f "$AUGGIE_FILE" ]]; then
if [[ -f "$AUGGIE_FILE" ]] && ! file_already_processed "$AUGGIE_FILE"; then
update_agent_file "$AUGGIE_FILE" "Auggie CLI"
processed_files+=("$AUGGIE_FILE")
found_agent=true
fi

if [[ -f "$ROO_FILE" ]]; then
if [[ -f "$ROO_FILE" ]] && ! file_already_processed "$ROO_FILE"; then
update_agent_file "$ROO_FILE" "Roo Code"
processed_files+=("$ROO_FILE")
found_agent=true
fi

if [[ -f "$CODEBUDDY_FILE" ]]; then
if [[ -f "$CODEBUDDY_FILE" ]] && ! file_already_processed "$CODEBUDDY_FILE"; then
update_agent_file "$CODEBUDDY_FILE" "CodeBuddy CLI"
processed_files+=("$CODEBUDDY_FILE")
found_agent=true
fi

Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update_all_existing_agents() function is missing a check for AMP_FILE. According to the update_specific_agent() function (line 620-621), "amp" is a valid agent type that uses $AMP_FILE which points to $REPO_ROOT/AGENTS.md (same as AGENTS_FILE, Q_FILE, and BOB_FILE).

While the duplicate prevention logic will handle the case where multiple variables point to the same file, the function should still include a check for AMP_FILE for completeness and consistency with the update_specific_agent() function. The check should be added after the CODEBUDDY_FILE check and before the SHAI_FILE check to maintain alphabetical ordering:

if [[ -f "$AMP_FILE" ]] && [[ -z "${processed_files[$AMP_FILE]}" ]]; then
    update_agent_file "$AMP_FILE" "Amp"
    processed_files["$AMP_FILE"]=1
    found_agent=true
fi
Suggested change
if [[ -f "$AMP_FILE" ]] && [[ -z "${processed_files[$AMP_FILE]}" ]]; then
update_agent_file "$AMP_FILE" "Amp"
processed_files["$AMP_FILE"]=1
found_agent=true
fi

Copilot uses AI. Check for mistakes.
Copy link
Author

@carlo42 carlo42 Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't introduce the issue of the missing check for AMP_FILE - it was already missing in the existing code (and I wouldn't know whether that omission was intentional or not)

if [[ -f "$SHAI_FILE" ]]; then
if [[ -f "$SHAI_FILE" ]] && ! file_already_processed "$SHAI_FILE"; then
update_agent_file "$SHAI_FILE" "SHAI"
processed_files+=("$SHAI_FILE")
found_agent=true
fi

if [[ -f "$Q_FILE" ]]; then
if [[ -f "$Q_FILE" ]] && ! file_already_processed "$Q_FILE"; then
update_agent_file "$Q_FILE" "Amazon Q Developer CLI"
processed_files+=("$Q_FILE")
found_agent=true
fi

if [[ -f "$BOB_FILE" ]]; then
if [[ -f "$BOB_FILE" ]] && ! file_already_processed "$BOB_FILE"; then
update_agent_file "$BOB_FILE" "IBM Bob"
processed_files+=("$BOB_FILE")
found_agent=true
fi

Expand Down