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
14 changes: 14 additions & 0 deletions .agents/scripts/supervisor-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ source "${SUPERVISOR_MODULE_DIR}/issue-sync.sh"
source "${SUPERVISOR_MODULE_DIR}/memory-integration.sh"
source "${SUPERVISOR_MODULE_DIR}/todo-sync.sh"
source "${SUPERVISOR_MODULE_DIR}/ai-context.sh"
source "${SUPERVISOR_MODULE_DIR}/ai-reason.sh"

# Valid states for the state machine
# shellcheck disable=SC2034 # Used by supervisor/state.sh
Expand Down Expand Up @@ -687,6 +688,19 @@ main() {
labels) cmd_labels "$@" ;;
contest) cmd_contest "$@" ;;
ai-context) build_ai_context "${REPO_PATH:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}" "${1:-full}" ;;
ai-reason) run_ai_reasoning "${REPO_PATH:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}" "${1:-full}" ;;
ai-status)
local last_run_ts
last_run_ts=$(db "$SUPERVISOR_DB" "SELECT MAX(timestamp) FROM state_log WHERE task_id = 'ai-supervisor' AND to_state = 'complete';" 2>/dev/null || echo "never")
local run_count
run_count=$(db "$SUPERVISOR_DB" "SELECT COUNT(*) FROM state_log WHERE task_id = 'ai-supervisor' AND to_state = 'complete';" 2>/dev/null || echo 0)
echo "AI Supervisor Status"
echo " Last run: ${last_run_ts:-never}"
echo " Total runs: $run_count"
echo " Enabled: ${SUPERVISOR_AI_ENABLED:-true}"
echo " Interval: ${SUPERVISOR_AI_INTERVAL:-15} pulses (~$((${SUPERVISOR_AI_INTERVAL:-15} * 2))min)"
echo " Log dir: ${AI_REASON_LOG_DIR:-$HOME/.aidevops/logs/ai-supervisor}"
Comment on lines +700 to +702

Choose a reason for hiding this comment

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

medium

The arithmetic expression ((${SUPERVISOR_AI_INTERVAL:-15} * 2)) on line 701 is not safe under set -e. If SUPERVISOR_AI_INTERVAL is set to a non-numeric value, this command will fail and cause the script to exit. According to the repository style guide (line 13), arithmetic that might fail should be guarded.

To make this more robust, pre-calculate the value with a fallback.

Suggested change
echo " Enabled: ${SUPERVISOR_AI_ENABLED:-true}"
echo " Interval: ${SUPERVISOR_AI_INTERVAL:-15} pulses (~$((${SUPERVISOR_AI_INTERVAL:-15} * 2))min)"
echo " Log dir: ${AI_REASON_LOG_DIR:-$HOME/.aidevops/logs/ai-supervisor}"
echo " Enabled: ${SUPERVISOR_AI_ENABLED:-true}"
local interval_minutes
interval_minutes=$(( ${SUPERVISOR_AI_INTERVAL:-15} * 2 )) 2>/dev/null || interval_minutes="?"
echo " Interval: ${SUPERVISOR_AI_INTERVAL:-15} pulses (~${interval_minutes}min)"
echo " Log dir: ${AI_REASON_LOG_DIR:-$HOME/.aidevops/logs/ai-supervisor}"
References
  1. The style guide requires that arithmetic operations that might fail (e.g., with non-numeric input) must be guarded to prevent script termination under set -e. (link)

;;
help | --help | -h) show_usage ;;
*)
log_error "Unknown command: $command"
Expand Down
Loading
Loading