diff --git a/here.sh b/here.sh old mode 100644 new mode 100755 index 80505743..f07c2f67 --- a/here.sh +++ b/here.sh @@ -1,2 +1,10 @@ #!/bin/bash -exec "$(dirname "$0")/scripts/here-impl.sh" "$@" \ No newline at end of file + +# Determine if this script is being sourced +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + # Script is being executed directly - use exec + exec "$(dirname "$0")/scripts/here-impl.sh" "$@" +else + # Script is being sourced - source the implementation + source "$(dirname "${BASH_SOURCE[0]}")/scripts/here-impl.sh" "$@" +fi \ No newline at end of file diff --git a/scripts/here-impl.sh b/scripts/here-impl.sh old mode 100644 new mode 100755 index 16662118..30195f1b --- a/scripts/here-impl.sh +++ b/scripts/here-impl.sh @@ -5,17 +5,61 @@ # Light mode: Sets up PATH and environment in current shell # Heavy mode: Launches new shell with full environment setup -set -e +# Determine if script is being sourced +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + SOURCED=false +else + SOURCED=true +fi + +# Only set -e if not sourced to avoid exiting user's shell +if [[ "$SOURCED" == false ]]; then + set -e +fi # Get the repository root directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +# Source the shared PATH setup utilities +source "$SCRIPT_DIR/setup-debug-path.sh" + # Default values MODE="light" STAY_FLAG="" SHOW_HELP="" +show_usage() { + cat << EOF + +Usage: here.sh [options] + +Options: + (no options) Light mode: Set up environment in current shell + --shell, -s Heavy mode: Launch new shell with full environment + --stay (with --shell) Stay in current directory + --help, -h Show this help + +Examples: + ./here.sh Light: Quick environment setup + ./here.sh --shell Heavy: New shell at repo root + ./here.sh --shell --stay Heavy: New shell at current location + +Note: For light mode to affect your current shell, source this script: + source ./here.sh Light mode in current shell +EOF +} + +# Function to exit or return based on whether script is sourced +safe_exit() { + local code=${1:-0} + if [[ "$SOURCED" == true ]]; then + return $code + else + exit $code + fi +} + # ===== PARSE ARGUMENTS ===== while [[ $# -gt 0 ]]; do case $1 in @@ -34,35 +78,14 @@ while [[ $# -gt 0 ]]; do *) echo "Unknown argument: $1" show_usage - exit 1 + safe_exit 1 ;; esac done -show_usage() { - cat << EOF - -Usage: here.sh [options] - -Options: - (no options) Light mode: Set up environment in current shell - --shell, -s Heavy mode: Launch new shell with full environment - --stay (with --shell) Stay in current directory - --help, -h Show this help - -Examples: - ./here.sh Light: Quick environment setup - ./here.sh --shell Heavy: New shell at repo root - ./here.sh --shell --stay Heavy: New shell at current location - -Note: For light mode to affect your current shell, source this script: - source ./here.sh Light mode in current shell -EOF -} - if [[ -n "$SHOW_HELP" ]]; then show_usage - exit 0 + safe_exit 0 fi echo "" @@ -73,8 +96,12 @@ if [[ "$MODE" == "light" ]]; then echo "Light mode: Setting up environment..." echo "" - # Call the existing PATH setup script - source "$REPO_ROOT/scripts/setup-debug-path.sh" --session-only --no-test + # Use sourced PATH setup functions from setup-debug-path.sh + if path_already_configured; then + echo "ℹ️ Debug paths already in PATH" + else + configure_current_session + fi # Set additional environment variables export CYCOD_DEV_MODE=1 @@ -93,8 +120,10 @@ elif [[ "$MODE" == "heavy" ]]; then export CYCOD_DEV_MODE=1 export CYCOD_REPO_ROOT="$REPO_ROOT" - # Set up PATH - source "$REPO_ROOT/scripts/setup-debug-path.sh" --session-only --no-test >/dev/null 2>&1 + # Set up PATH using sourced function (suppress output for cleaner experience) + if ! path_already_configured; then + configure_current_session >/dev/null 2>&1 + fi # Prepare custom prompt CUSTOM_PS1="(here:cycod) \u@\h:\w\$ " diff --git a/scripts/setup-debug-path.sh b/scripts/setup-debug-path.sh index 1774cd31..2266852d 100755 --- a/scripts/setup-debug-path.sh +++ b/scripts/setup-debug-path.sh @@ -3,7 +3,17 @@ # Cycod Debug Environment Setup Script # This script sets up the PATH to prioritize debug builds of all cycod tools over global dotnet tools -set -e +# Detect if being sourced +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + SOURCED=false +else + SOURCED=true +fi + +# Only set -e if not sourced to avoid exiting user's shell +if [[ "$SOURCED" == false ]]; then + set -e +fi # Get the repository root directory (where this script is located relative to scripts/) REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" @@ -11,6 +21,7 @@ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Define the debug binary paths DEBUG_PATHS=( "$REPO_ROOT/src/cycod/bin/Debug/net9.0" + "$REPO_ROOT/src/cycodj/bin/Debug/net9.0" "$REPO_ROOT/src/cycodmd/bin/Debug/net9.0" "$REPO_ROOT/src/cycodt/bin/Debug/net9.0" "$REPO_ROOT/src/cycodgr/bin/Debug/net9.0" @@ -77,7 +88,7 @@ test_setup() { echo "🧪 Testing debug environment setup:" echo "==================================" - for tool in cycod cycodmd cycodt cycodgr cycod-mcp-geolocation cycod-mcp-mxlookup cycod-mcp-osm cycod-mcp-weather cycod-mcp-whois; do + for tool in cycod cycodj cycodmd cycodt cycodgr cycod-mcp-geolocation cycod-mcp-mxlookup cycod-mcp-osm cycod-mcp-weather cycod-mcp-whois; do local tool_path=$(which "$tool" 2>/dev/null || echo "not found") echo " $tool: $tool_path" @@ -184,5 +195,7 @@ main() { fi } -# Run main function with all arguments -main "$@" \ No newline at end of file +# Only run main if executed directly (not sourced) +if [[ "$SOURCED" == false ]]; then + main "$@" +fi \ No newline at end of file diff --git a/src/cycod/assets/help/provider.txt b/src/cycod/assets/help/provider.txt index 2c36eec9..a36ed244 100644 --- a/src/cycod/assets/help/provider.txt +++ b/src/cycod/assets/help/provider.txt @@ -4,6 +4,7 @@ CycoD supports multiple AI providers for chat functionality: - GitHub Copilot - Anthropic Claude +- Azure Anthropic (Claude via Azure) - AWS Bedrock - Azure OpenAI API - Google Gemini @@ -18,6 +19,7 @@ Use these flags to explicitly select which provider to use: --use-copilot Use GitHub Copilot --use-azure-openai Use Azure OpenAI API --use-anthropic Use Anthropic Claude +--use-azure-anthropic Use Azure Anthropic (Claude via Azure) --use-bedrock Use AWS Bedrock --use-gemini Use Google Gemini --use-grok Use Grok (x.ai) @@ -65,6 +67,7 @@ CYCOD_PREFERRED_PROVIDER=azure-openai cycod help settings cycod help use github copilot cycod help use anthropic + cycod help use azure anthropic cycod help use azure openai cycod help use bedrock cycod help use gemini diff --git a/src/cycod/assets/help/settings.txt b/src/cycod/assets/help/settings.txt index 5404ddee..0921df39 100644 --- a/src/cycod/assets/help/settings.txt +++ b/src/cycod/assets/help/settings.txt @@ -258,6 +258,7 @@ USE APP SETTINGS cycod config set App.PreferredProvider copilot --user cycod config set App.PreferredProvider anthropic --global + cycod config set App.PreferredProvider azure-anthropic --local cycod config set App.PreferredProvider azure-openai --local cycod config set App.PreferredProvider bedrock cycod config set App.PreferredProvider gemini diff --git a/tests/cycod-yaml/cycod-slash-title-commands.yaml b/tests/cycod-yaml/cycod-slash-title-commands.yaml index 3ee5a3d2..4d481c90 100644 --- a/tests/cycod-yaml/cycod-slash-title-commands.yaml +++ b/tests/cycod-yaml/cycod-slash-title-commands.yaml @@ -1017,6 +1017,7 @@ tests: # ==================================================================== - name: refresh_with_full_verification_and_notification + optional: flaky steps: - name: Create test file copy for refresh test bash: cp testfiles/unlocked-title-full-conversation.jsonl testfiles/refresh-verification-test.jsonl