Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion .agent/scripts/generate-opencode-agents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ for f in Accounts.md Accounting.md accounting.md AI-DevOps.md Build+.md Content.
rm -f "$OPENCODE_AGENT_DIR/$f"
done

# Remove loop-state files that were incorrectly created as agents
# These are runtime state files, not agents
for f in ralph-loop.local.md quality-loop.local.md full-loop.local.md loop-state.md re-anchor.md postflight-loop.md; do
rm -f "$OPENCODE_AGENT_DIR/$f"
done
Comment on lines +65 to +69

Choose a reason for hiding this comment

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

medium

This loop cleans up incorrectly created agent files from the root of $OPENCODE_AGENT_DIR. However, the sub-agent generation logic would have also created files inside a loop-state subdirectory within $OPENCODE_AGENT_DIR. To ensure a complete cleanup, you should also remove this directory. The hardcoded list of files is also a bit brittle.

Suggested change
# Remove loop-state files that were incorrectly created as agents
# These are runtime state files, not agents
for f in ralph-loop.local.md quality-loop.local.md full-loop.local.md loop-state.md re-anchor.md postflight-loop.md; do
rm -f "$OPENCODE_AGENT_DIR/$f"
done
# Remove loop-state files and directory that were incorrectly created as agents
# These are runtime state files, not agents
rm -rf "$OPENCODE_AGENT_DIR/loop-state"
for f in ralph-loop.local.md quality-loop.local.md full-loop.local.md loop-state.md re-anchor.md postflight-loop.md; do
rm -f "$OPENCODE_AGENT_DIR/$f"
done


# =============================================================================
# PRIMARY AGENTS - Defined in opencode.json for Tab order control
# =============================================================================
Expand Down Expand Up @@ -615,7 +621,7 @@ tools:
EOF
fi
((subagent_count++))
done < <(find "$AGENTS_DIR" -mindepth 2 -name "*.md" -type f | sort)
done < <(find "$AGENTS_DIR" -mindepth 2 -name "*.md" -type f -not -path "*/loop-state/*" | sort)

echo -e " ${GREEN}✓${NC} Generated $subagent_count subagent files"

Expand Down
13 changes: 10 additions & 3 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1266,9 +1266,16 @@ deploy_aidevops_agents() {
rm -rf "${target_dir:?}"/*
fi

# Copy all agent files and folders (excluding scripts which are large)
# We copy scripts separately to maintain structure
cp -R "$source_dir"/* "$target_dir/"
# Copy all agent files and folders, excluding:
# - loop-state/ (local runtime state, not agents)
# Use rsync for selective exclusion
if command -v rsync &>/dev/null; then
rsync -a --exclude='loop-state/' "$source_dir/" "$target_dir/"
else
# Fallback: copy then remove loop-state
cp -R "$source_dir"/* "$target_dir/"
rm -rf "$target_dir/loop-state" 2>/dev/null || true
fi
Comment on lines +1274 to +1278

Choose a reason for hiding this comment

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

high

In the fallback case where rsync is not available, the exit status of the cp command is not correctly propagated. If cp fails, the script will continue as if the deployment was successful because the || true on the rm command masks the error. This could lead to silent failures. You should ensure that a failure in cp is reported by preserving and propagating its exit code.

Suggested change
else
# Fallback: copy then remove loop-state
cp -R "$source_dir"/* "$target_dir/"
rm -rf "$target_dir/loop-state" 2>/dev/null || true
fi
else
# Fallback: copy then remove loop-state
cp -R "$source_dir"/* "$target_dir/"
local cp_status=$?
if [[ $cp_status -eq 0 ]]; then
rm -rf "$target_dir/loop-state" 2>/dev/null || true
fi
(exit $cp_status)
fi


if [[ $? -eq 0 ]]; then
print_success "Deployed agents to $target_dir"
Copy link

Choose a reason for hiding this comment

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

In the fallback branch, this if [[ $? -eq 0 ]] will reflect the exit code of the last cleanup command (e.g., rm ... || true), so a failed cp could still result in a reported successful deploy.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Expand Down
Loading