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
10 changes: 9 additions & 1 deletion here.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
#!/bin/bash
exec "$(dirname "$0")/scripts/here-impl.sh" "$@"

# 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
85 changes: 57 additions & 28 deletions scripts/here-impl.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ""
Expand All @@ -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
Expand All @@ -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\$ "
Expand Down
21 changes: 17 additions & 4 deletions scripts/setup-debug-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@
# 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)"

# 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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -184,5 +195,7 @@ main() {
fi
}

# Run main function with all arguments
main "$@"
# Only run main if executed directly (not sourced)
if [[ "$SOURCED" == false ]]; then
main "$@"
fi
3 changes: 3 additions & 0 deletions src/cycod/assets/help/provider.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/cycod/assets/help/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/cycod-yaml/cycod-slash-title-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading