diff --git a/.agent/scripts/anti-detect-helper.sh b/.agent/scripts/anti-detect-helper.sh index 74a962a20..433e026b5 100755 --- a/.agent/scripts/anti-detect-helper.sh +++ b/.agent/scripts/anti-detect-helper.sh @@ -144,7 +144,7 @@ setup_rebrowser() { # Check if playwright is installed if ! command -v npx &>/dev/null; then - echo -e "${RED}Error: npx not found. Install Node.js first.${NC}" + echo -e "${RED}Error: npx not found. Install Node.js first.${NC}" >&2 return 1 fi @@ -163,23 +163,23 @@ setup_rebrowser() { validate_profile_name() { local name="$1" if [[ -z "$name" ]]; then - echo -e "${RED}Error: Profile name cannot be empty.${NC}" + echo -e "${RED}Error: Profile name cannot be empty.${NC}" >&2 return 1 fi if [[ "$name" =~ [/\\] || "$name" == *..* ]]; then - echo -e "${RED}Error: Profile name cannot contain '/', '\\', or '..'.${NC}" + echo -e "${RED}Error: Profile name cannot contain '/', '\\', or '..'.${NC}" >&2 return 1 fi if [[ "$name" == -* ]]; then - echo -e "${RED}Error: Profile name cannot start with '-'.${NC}" + echo -e "${RED}Error: Profile name cannot start with '-'.${NC}" >&2 return 1 fi if ! [[ "$name" =~ ^[A-Za-z0-9._-]+$ ]]; then - echo -e "${RED}Error: Profile name must only contain letters, numbers, '.', '_', or '-'.${NC}" + echo -e "${RED}Error: Profile name must only contain letters, numbers, '.', '_', or '-'.${NC}" >&2 return 1 fi if [[ ${#name} -gt 64 ]]; then - echo -e "${RED}Error: Profile name must be 64 characters or fewer.${NC}" + echo -e "${RED}Error: Profile name must be 64 characters or fewer.${NC}" >&2 return 1 fi return 0 @@ -193,9 +193,11 @@ profile_create() { local browser_type="firefox" local notes="" + local arg shift while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --type) profile_type="$2"; shift 2 ;; --proxy) proxy="$2"; shift 2 ;; --os) target_os="$2"; shift 2 ;; @@ -214,7 +216,7 @@ profile_create() { local profile_dir="$PROFILES_DIR/$dir_type/$name" if [[ -d "$profile_dir" ]]; then - echo -e "${RED}Error: Profile '$name' already exists.${NC}" + echo -e "${RED}Error: Profile '$name' already exists.${NC}" >&2 return 1 fi @@ -296,7 +298,7 @@ profile_show() { profile_dir=$(find_profile_dir "$name") if [[ -z "$profile_dir" ]]; then - echo -e "${RED}Error: Profile '$name' not found.${NC}" + echo -e "${RED}Error: Profile '$name' not found.${NC}" >&2 return 1 fi @@ -335,7 +337,7 @@ profile_delete() { profile_dir=$(find_profile_dir "$name") if [[ -z "$profile_dir" ]]; then - echo -e "${RED}Error: Profile '$name' not found.${NC}" + echo -e "${RED}Error: Profile '$name' not found.${NC}" >&2 return 1 fi @@ -352,7 +354,7 @@ profile_clone() { src_dir=$(find_profile_dir "$src") if [[ -z "$src_dir" ]]; then - echo -e "${RED}Error: Source profile '$src' not found.${NC}" + echo -e "${RED}Error: Source profile '$src' not found.${NC}" >&2 return 1 fi @@ -361,7 +363,7 @@ profile_clone() { local dst_dir="$parent_dir/$dst" if [[ -d "$dst_dir" ]]; then - echo -e "${RED}Error: Destination profile '$dst' already exists.${NC}" + echo -e "${RED}Error: Destination profile '$dst' already exists.${NC}" >&2 return 1 fi @@ -404,12 +406,14 @@ profile_update() { profile_dir=$(find_profile_dir "$name") if [[ -z "$profile_dir" ]]; then - echo -e "${RED}Error: Profile '$name' not found.${NC}" + echo -e "${RED}Error: Profile '$name' not found.${NC}" >&2 return 1 fi + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --proxy) local proxy_json proxy_json=$(parse_proxy_url "$2") @@ -447,8 +451,10 @@ launch_browser() { local disposable="" local url="" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --profile) profile_name="$2"; shift 2 ;; --engine) engine="$2"; shift 2 ;; --headless) headless="true"; shift ;; @@ -459,7 +465,7 @@ launch_browser() { done if [[ -z "$profile_name" && -z "$disposable" ]]; then - echo -e "${RED}Error: --profile or --disposable required.${NC}" + echo -e "${RED}Error: --profile or --disposable required.${NC}" >&2 return 1 fi @@ -500,7 +506,7 @@ launch_camoufox() { # shellcheck disable=SC1091 source "$VENV_DIR/bin/activate" 2>/dev/null || { - echo -e "${RED}Error: Camoufox venv not found. Run: anti-detect-helper.sh setup${NC}" + echo -e "${RED}Error: Camoufox venv not found. Run: anti-detect-helper.sh setup${NC}" >&2 return 1 } @@ -687,9 +693,11 @@ test_detection() { local profile_name="" local engine="firefox" local sites="browserscan,sannysoft" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --profile) profile_name="$2"; shift 2 ;; --engine) engine="$2"; shift 2 ;; --sites) sites="$2"; shift 2 ;; @@ -799,9 +807,11 @@ warmup_profile() { local profile_name="$1" shift local duration="30" # minutes + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --duration) duration="${2%m}" # Strip 'm' suffix shift 2 @@ -814,7 +824,7 @@ warmup_profile() { profile_dir=$(find_profile_dir "$profile_name") if [[ -z "$profile_dir" ]]; then - echo -e "${RED}Error: Profile '$profile_name' not found.${NC}" + echo -e "${RED}Error: Profile '$profile_name' not found.${NC}" >&2 return 1 fi @@ -822,7 +832,7 @@ warmup_profile() { # shellcheck disable=SC1091 source "$VENV_DIR/bin/activate" 2>/dev/null || { - echo -e "${RED}Error: Camoufox venv not found. Run: anti-detect-helper.sh setup${NC}" + echo -e "${RED}Error: Camoufox venv not found. Run: anti-detect-helper.sh setup${NC}" >&2 return 1 } @@ -1047,9 +1057,11 @@ cookies_export() { local profile_name="$1" shift local output="" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --output) output="$2"; shift 2 ;; *) shift ;; esac @@ -1059,7 +1071,7 @@ cookies_export() { profile_dir=$(find_profile_dir "$profile_name") if [[ -z "$profile_dir" || ! -f "$profile_dir/storage-state.json" ]]; then - echo -e "${RED}Error: No saved state for profile '$profile_name'.${NC}" + echo -e "${RED}Error: No saved state for profile '$profile_name'.${NC}" >&2 return 1 fi @@ -1099,7 +1111,7 @@ cookies_clear() { profile_dir=$(find_profile_dir "$profile_name") if [[ -z "$profile_dir" ]]; then - echo -e "${RED}Error: Profile '$profile_name' not found.${NC}" + echo -e "${RED}Error: Profile '$profile_name' not found.${NC}" >&2 return 1 fi diff --git a/.agent/scripts/cloudron-package-helper.sh b/.agent/scripts/cloudron-package-helper.sh index f6f7694a7..91148d6c7 100755 --- a/.agent/scripts/cloudron-package-helper.sh +++ b/.agent/scripts/cloudron-package-helper.sh @@ -26,10 +26,10 @@ BLUE='\033[0;34m' NC='\033[0m' # No Color # Logging functions -log_info() { echo -e "${BLUE}[INFO]${NC} $*"; } -log_success() { echo -e "${GREEN}[OK]${NC} $*"; } -log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; } -log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; } +log_info() { echo -e "${BLUE}[INFO]${NC} $*"; return 0; } +log_success() { echo -e "${GREEN}[OK]${NC} $*"; return 0; } +log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; return 0; } +log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; return 0; } # Check if cloudron CLI is installed check_cloudron_cli() { @@ -867,6 +867,7 @@ Documentation: https://docs.cloudron.io/packaging/ https://forum.cloudron.io/category/96/app-packaging-development HELP + return 0 } # Main entry point diff --git a/.agent/scripts/log-issue-helper.sh b/.agent/scripts/log-issue-helper.sh index 64a969144..9ce3f8024 100755 --- a/.agent/scripts/log-issue-helper.sh +++ b/.agent/scripts/log-issue-helper.sh @@ -27,12 +27,14 @@ get_aidevops_version() { else echo "unknown" fi + return 0 } get_latest_version() { curl --proto '=https' -fsSL \ "https://raw.githubusercontent.com/marcusquinn/aidevops/main/VERSION" \ 2>/dev/null || echo "unknown" + return 0 } detect_ai_assistant() { @@ -69,6 +71,7 @@ detect_ai_assistant() { *) echo "Unknown" ;; esac fi + return 0 } get_install_method() { @@ -87,6 +90,7 @@ get_install_method() { else echo "unknown ($aidevops_path)" fi + return 0 } get_git_context() { @@ -100,6 +104,7 @@ get_git_context() { branch="n/a" fi echo "$repo ($branch)" + return 0 } gather_diagnostics() { @@ -143,6 +148,7 @@ gather_diagnostics() { - **Working repo**: $git_context - **gh CLI**: $(gh --version 2>/dev/null | head -1 || echo "not installed") EOF + return 0 } # ----------------------------------------------------------------------------- @@ -151,14 +157,14 @@ EOF check_gh_auth() { if ! command -v gh &>/dev/null; then - echo "ERROR: GitHub CLI (gh) not installed" - echo "Install with: brew install gh (macOS) or apt install gh (Linux)" + echo "ERROR: GitHub CLI (gh) not installed" >&2 + echo "Install with: brew install gh (macOS) or apt install gh (Linux)" >&2 return 1 fi if ! gh auth status &>/dev/null; then - echo "ERROR: GitHub CLI not authenticated" - echo "Run: gh auth login" + echo "ERROR: GitHub CLI not authenticated" >&2 + echo "Run: gh auth login" >&2 return 1 fi diff --git a/.agent/scripts/pdf-helper.sh b/.agent/scripts/pdf-helper.sh index 38bc742da..60230081b 100755 --- a/.agent/scripts/pdf-helper.sh +++ b/.agent/scripts/pdf-helper.sh @@ -29,6 +29,7 @@ get_runtime() { else echo "" fi + return 0 } # Check if @libpdf/core is installed @@ -37,7 +38,7 @@ check_libpdf() { runtime=$(get_runtime) if [[ -z "$runtime" ]]; then - echo -e "${RED}Error:${NC} Neither bun nor node found. Install one first." + echo -e "${RED}Error:${NC} Neither bun nor node found. Install one first." >&2 return 1 fi @@ -69,6 +70,7 @@ run_script() { else node --input-type=module -e "$script" fi + return 0 } # Show PDF info @@ -76,7 +78,7 @@ cmd_info() { local file="$1" if [[ ! -f "$file" ]]; then - echo -e "${RED}Error:${NC} File not found: $file" + echo -e "${RED}Error:${NC} File not found: $file" >&2 return 1 fi @@ -114,7 +116,7 @@ cmd_fields() { local file="$1" if [[ ! -f "$file" ]]; then - echo -e "${RED}Error:${NC} File not found: $file" + echo -e "${RED}Error:${NC} File not found: $file" >&2 return 1 fi @@ -154,7 +156,7 @@ cmd_fill() { local output="${3:-${file%.pdf}-filled.pdf}" if [[ ! -f "$file" ]]; then - echo -e "${RED}Error:${NC} File not found: $file" + echo -e "${RED}Error:${NC} File not found: $file" >&2 return 1 fi @@ -193,7 +195,7 @@ console.log("Filled PDF saved to:", outputFile); # Merge PDFs cmd_merge() { if ! command -v jq &>/dev/null; then - echo -e "${RED}Error:${NC} 'jq' is not installed. Please install it to use the merge command." + echo -e "${RED}Error:${NC} 'jq' is not installed. Please install it to use the merge command." >&2 return 1 fi @@ -202,7 +204,7 @@ cmd_merge() { local files=("$@") if [[ ${#files[@]} -lt 2 ]]; then - echo -e "${RED}Error:${NC} Need at least 2 files to merge" + echo -e "${RED}Error:${NC} Need at least 2 files to merge" >&2 return 1 fi @@ -231,7 +233,7 @@ cmd_text() { local file="$1" if [[ ! -f "$file" ]]; then - echo -e "${RED}Error:${NC} File not found: $file" + echo -e "${RED}Error:${NC} File not found: $file" >&2 return 1 fi @@ -262,7 +264,7 @@ cmd_install() { runtime=$(get_runtime) if [[ -z "$runtime" ]]; then - echo -e "${RED}Error:${NC} Neither bun nor node found. Install one first." + echo -e "${RED}Error:${NC} Neither bun nor node found. Install one first." >&2 return 1 fi @@ -275,6 +277,7 @@ cmd_install() { fi echo -e "${GREEN}Done!${NC}" + return 0 } # Show help @@ -321,28 +324,32 @@ EOF # Main main() { local cmd="${1:-help}" + local file_arg shift || true case "$cmd" in info) - [[ $# -lt 1 ]] && { echo -e "${RED}Error:${NC} Missing file argument"; return 1; } - cmd_info "$1" + [[ $# -lt 1 ]] && { echo -e "${RED}Error:${NC} Missing file argument" >&2; return 1; } + file_arg="$1" + cmd_info "$file_arg" ;; fields) - [[ $# -lt 1 ]] && { echo -e "${RED}Error:${NC} Missing file argument"; return 1; } - cmd_fields "$1" + [[ $# -lt 1 ]] && { echo -e "${RED}Error:${NC} Missing file argument" >&2; return 1; } + file_arg="$1" + cmd_fields "$file_arg" ;; fill) - [[ $# -lt 2 ]] && { echo -e "${RED}Error:${NC} Missing file or json argument"; return 1; } + [[ $# -lt 2 ]] && { echo -e "${RED}Error:${NC} Missing file or json argument" >&2; return 1; } cmd_fill "$@" ;; merge) - [[ $# -lt 3 ]] && { echo -e "${RED}Error:${NC} Need output file and at least 2 input files"; return 1; } + [[ $# -lt 3 ]] && { echo -e "${RED}Error:${NC} Need output file and at least 2 input files" >&2; return 1; } cmd_merge "$@" ;; text) - [[ $# -lt 1 ]] && { echo -e "${RED}Error:${NC} Missing file argument"; return 1; } - cmd_text "$1" + [[ $# -lt 1 ]] && { echo -e "${RED}Error:${NC} Missing file argument" >&2; return 1; } + file_arg="$1" + cmd_text "$file_arg" ;; install) cmd_install @@ -351,7 +358,7 @@ main() { cmd_help ;; *) - echo -e "${RED}Error:${NC} Unknown command: $cmd" + echo -e "${RED}Error:${NC} Unknown command: $cmd" >&2 echo "Run 'pdf-helper.sh help' for usage" return 1 ;; diff --git a/.agent/scripts/seo-analysis-helper.sh b/.agent/scripts/seo-analysis-helper.sh index f3dd881bc..15298da76 100755 --- a/.agent/scripts/seo-analysis-helper.sh +++ b/.agent/scripts/seo-analysis-helper.sh @@ -543,22 +543,24 @@ show_summary() { main() { local domain="" local command="analyze" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --help|-h) show_help return 0 ;; -*) - print_error "Unknown option: $1" + print_error "Unknown option: $arg" return 1 ;; *) if [[ -z "$domain" ]]; then - domain="$1" + domain="$arg" else - command="$1" + command="$arg" fi shift ;; diff --git a/.agent/scripts/seo-export-ahrefs.sh b/.agent/scripts/seo-export-ahrefs.sh index 020e6143a..4f54cdb42 100755 --- a/.agent/scripts/seo-export-ahrefs.sh +++ b/.agent/scripts/seo-export-ahrefs.sh @@ -265,9 +265,11 @@ main() { local domain="" local days="$DEFAULT_DAYS" local country="us" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --days) if [[ -z "${2:-}" ]] || [[ "$2" == -* ]]; then print_error "--days requires a numeric value" @@ -289,12 +291,12 @@ main() { return 0 ;; -*) - print_error "Unknown option: $1" + print_error "Unknown option: $arg" return 1 ;; *) if [[ -z "$domain" ]]; then - domain="$1" + domain="$arg" fi shift ;; diff --git a/.agent/scripts/seo-export-bing.sh b/.agent/scripts/seo-export-bing.sh index c5b6e80fa..ba513090f 100755 --- a/.agent/scripts/seo-export-bing.sh +++ b/.agent/scripts/seo-export-bing.sh @@ -96,7 +96,7 @@ bing_page_stats() { # Convert Bing JSON response to TOON format json_to_toon() { local query_json="$1" - local page_json="$2" + local _page_json="$2" # Reserved for future page-level stats integration local domain="$3" local start_date="$4" local end_date="$5" @@ -248,9 +248,11 @@ EOF main() { local domain="" local days="$DEFAULT_DAYS" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --days) if [[ -z "${2:-}" ]] || [[ "$2" == -* ]]; then print_error "--days requires a numeric value" @@ -264,12 +266,12 @@ main() { return 0 ;; -*) - print_error "Unknown option: $1" + print_error "Unknown option: $arg" return 1 ;; *) if [[ -z "$domain" ]]; then - domain="$1" + domain="$arg" fi shift ;; diff --git a/.agent/scripts/seo-export-dataforseo.sh b/.agent/scripts/seo-export-dataforseo.sh index 7e56ec639..f9e946e5b 100755 --- a/.agent/scripts/seo-export-dataforseo.sh +++ b/.agent/scripts/seo-export-dataforseo.sh @@ -296,9 +296,11 @@ main() { local days="$DEFAULT_DAYS" local location="2840" local language="en" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --days) if [[ -z "${2:-}" ]] || [[ "$2" == -* ]]; then print_error "--days requires a numeric value" @@ -328,12 +330,12 @@ main() { return 0 ;; -*) - print_error "Unknown option: $1" + print_error "Unknown option: $arg" return 1 ;; *) if [[ -z "$domain" ]]; then - domain="$1" + domain="$arg" fi shift ;; diff --git a/.agent/scripts/seo-export-gsc.sh b/.agent/scripts/seo-export-gsc.sh index 55fbb4723..c32264386 100755 --- a/.agent/scripts/seo-export-gsc.sh +++ b/.agent/scripts/seo-export-gsc.sh @@ -264,9 +264,11 @@ EOF main() { local domain="" local days="$DEFAULT_DAYS" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --days) if [[ -z "${2:-}" ]] || [[ "$2" == -* ]]; then print_error "--days requires a numeric value" @@ -280,12 +282,12 @@ main() { return 0 ;; -*) - print_error "Unknown option: $1" + print_error "Unknown option: $arg" return 1 ;; *) if [[ -z "$domain" ]]; then - domain="$1" + domain="$arg" fi shift ;; diff --git a/.agent/scripts/seo-export-helper.sh b/.agent/scripts/seo-export-helper.sh index 97feee86d..2b066ffc7 100755 --- a/.agent/scripts/seo-export-helper.sh +++ b/.agent/scripts/seo-export-helper.sh @@ -111,6 +111,7 @@ list_platforms() { bing) desc="Bing Webmaster Tools" ;; ahrefs) desc="Ahrefs organic keywords" ;; dataforseo) desc="DataForSEO ranked keywords" ;; + *) desc="Unknown platform" ;; esac if [[ "$status" == "ready" ]]; then @@ -283,9 +284,11 @@ main() { # Parse global options local domain="" local days="$DEFAULT_DAYS" + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --days) if [[ -z "${2:-}" ]] || [[ "$2" == -* ]]; then print_error "--days requires a numeric value" @@ -299,12 +302,12 @@ main() { return 0 ;; -*) - print_error "Unknown option: $1" + print_error "Unknown option: $arg" return 1 ;; *) if [[ -z "$domain" ]]; then - domain="$1" + domain="$arg" fi shift ;; diff --git a/.agent/scripts/watercrawl-helper.sh b/.agent/scripts/watercrawl-helper.sh index 5c690373c..a9b376dc2 100755 --- a/.agent/scripts/watercrawl-helper.sh +++ b/.agent/scripts/watercrawl-helper.sh @@ -80,7 +80,7 @@ print_warning() { print_error() { local message="$1" - echo -e "${RED}[ERROR] $message${NC}" + echo -e "${RED}[ERROR] $message${NC}" >&2 return 0 } diff --git a/.agent/scripts/yt-dlp-helper.sh b/.agent/scripts/yt-dlp-helper.sh index 558c5ff81..7ddab21fd 100755 --- a/.agent/scripts/yt-dlp-helper.sh +++ b/.agent/scripts/yt-dlp-helper.sh @@ -63,7 +63,7 @@ print_warning() { print_error() { local message="$1" - echo -e "${RED}[ERROR] $message${NC}" + echo -e "${RED}[ERROR] $message${NC}" >&2 return 0 } @@ -98,6 +98,7 @@ sanitize_name() { local name="$1" local max_length="${2:-60}" echo "$name" | sed 's/[^a-zA-Z0-9._-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//' | cut -c1-"$max_length" + return 0 } # Get timestamp for folder naming @@ -173,8 +174,10 @@ parse_options() { SUB_LANGS="en" EXTRA_ARGS=() + local arg while [[ $# -gt 0 ]]; do - case "$1" in + arg="$1" + case "$arg" in --output-dir) OUTPUT_DIR="$2" shift 2 @@ -212,7 +215,7 @@ parse_options() { shift 2 ;; *) - EXTRA_ARGS+=("$1") + EXTRA_ARGS+=("$arg") shift ;; esac @@ -374,6 +377,7 @@ download_audio() { "audio-m4a"|"m4a") audio_format="m4a" ;; "audio-opus"|"opus") audio_format="opus" ;; "audio-mp3"|"mp3"|"") audio_format="mp3" ;; + *) audio_format="mp3" ;; # Default to mp3 for unknown formats esac print_header "Extracting Audio" @@ -586,6 +590,9 @@ convert_local() { audio_codec="flac" audio_quality="" ;; + *) + # Default to mp3 for unknown formats + ;; esac # Build output directory @@ -645,6 +652,9 @@ convert_local() { "libopus") ffmpeg_args+=(-b:a "$audio_quality") ;; + *) + # No quality setting for other codecs + ;; esac fi