Skip to content

Commit c3ca9cf

Browse files
committed
Add shell scripts
1 parent 8d1a46e commit c3ca9cf

File tree

11 files changed

+226
-0
lines changed

11 files changed

+226
-0
lines changed

scripts/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Shell scripts
2+
3+
- `shell.sh` runs the application in interactive shell mode.
4+
- `mcp_server.sh` runs an MCP server that will expose MCP tools over SSE.

scripts/mcp_server.cmd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@echo off
2+
setlocal
3+
4+
call .\support\check_env.bat
5+
6+
if errorlevel 1 (
7+
echo Environment check failed. Exiting...
8+
exit /b 1
9+
)
10+
11+
cd ..
12+
13+
set SPRING_PROFILES_ACTIVE=web,severance
14+
15+
cmd /c mvn -P agent-examples-kotlin -Dmaven.test.skip=true spring-boot:run
16+
17+
endlocal

scripts/mcp_server.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
./support/check_env.sh
4+
5+
cd ..
6+
export SPRING_PROFILES_ACTIVE=web,severance
7+
mvn -P agent-examples-kotlin -Dmaven.test.skip=true spring-boot:run

scripts/shell_docker.cmd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@echo off
2+
setlocal
3+
4+
call .\support\check_env.bat
5+
6+
if errorlevel 1 (
7+
echo Environment check failed. Exiting...
8+
exit /b 1
9+
)
10+
11+
cd ..
12+
13+
set SPRING_PROFILES_ACTIVE=shell,starwars,docker-desktop
14+
15+
cmd /c mvn -P agent-examples-kotlin -Dmaven.test.skip=true spring-boot:run
16+
17+
endlocal

scripts/shell_docker.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Save current location and environment
2+
Push-Location
3+
$originalProfiles = $env:SPRING_PROFILES_ACTIVE
4+
5+
try {
6+
# Run environment check
7+
Write-Host "Running environment check..." -ForegroundColor Cyan
8+
& .\support\check_env.ps1
9+
10+
if ($LASTEXITCODE -ne 0) {
11+
Write-Host "Environment check failed. Exiting..." -ForegroundColor Red
12+
exit 1
13+
}
14+
15+
# Change to parent directory
16+
Set-Location ..
17+
18+
# Set Spring profiles
19+
$env:SPRING_PROFILES_ACTIVE = "shell,starwars,docker-desktop"
20+
21+
# Run Maven in subprocess
22+
cmd /c "mvn -Dmaven.test.skip=true spring-boot:run"
23+
}
24+
finally {
25+
# Restore original environment and location
26+
$env:SPRING_PROFILES_ACTIVE = $originalProfiles
27+
Pop-Location
28+
}

scripts/support/check_env.bat

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@echo off
2+
:: Check environment variables
3+
echo Checking environment variables...
4+
set OPENAI_KEY_MISSING=false
5+
set ANTHROPIC_KEY_MISSING=false
6+
7+
if "%OPENAI_API_KEY%"=="" (
8+
echo OPENAI_API_KEY environment variable is not set
9+
echo OpenAI models will not be available
10+
echo Get an API key at https://platform.openai.com/api-keys
11+
echo Please set it with: set OPENAI_API_KEY=your_api_key
12+
set OPENAI_KEY_MISSING=true
13+
) else (
14+
echo OPENAI_API_KEY set: OpenAI models are available
15+
)
16+
17+
if "%ANTHROPIC_API_KEY%"=="" (
18+
echo ANTHROPIC_API_KEY environment variable is not set
19+
echo Claude models will not be available
20+
echo Get an API key at https://www.anthropic.com/api
21+
echo Please set it with: set ANTHROPIC_API_KEY=your_api_key
22+
set ANTHROPIC_KEY_MISSING=true
23+
) else (
24+
echo ANTHROPIC_API_KEY set: Claude models are available
25+
)
26+
27+
if "%OPENAI_KEY_MISSING%"=="true" if "%ANTHROPIC_KEY_MISSING%"=="true" (
28+
echo ERROR: Both OPENAI_API_KEY and ANTHROPIC_API_KEY are missing.
29+
echo At least one API key is required to use language models.
30+
echo Please set at least one of these keys before running the application.
31+
exit /b 1
32+
)

scripts/support/check_env.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Check environment variables
2+
Write-Host "Checking environment variables..." -ForegroundColor Cyan
3+
4+
$openaiKeyMissing = $false
5+
$anthropicKeyMissing = $false
6+
7+
# Check OPENAI_API_KEY
8+
if (-not $env:OPENAI_API_KEY) {
9+
Write-Host "OPENAI_API_KEY environment variable is not set" -ForegroundColor Yellow
10+
Write-Host "OpenAI models will not be available"
11+
Write-Host "Get an API key at https://platform.openai.com/api-keys"
12+
Write-Host "Please set it with: `$env:OPENAI_API_KEY='your_api_key'" -ForegroundColor Green
13+
$openaiKeyMissing = $true
14+
} else {
15+
Write-Host "OPENAI_API_KEY set: OpenAI models are available" -ForegroundColor Green
16+
}
17+
18+
# Check ANTHROPIC_API_KEY
19+
if (-not $env:ANTHROPIC_API_KEY) {
20+
Write-Host "ANTHROPIC_API_KEY environment variable is not set" -ForegroundColor Yellow
21+
Write-Host "Claude models will not be available"
22+
Write-Host "Get an API key at https://www.anthropic.com/api"
23+
Write-Host "Please set it with: `$env:ANTHROPIC_API_KEY='your_api_key'" -ForegroundColor Green
24+
$anthropicKeyMissing = $true
25+
} else {
26+
Write-Host "ANTHROPIC_API_KEY set: Claude models are available" -ForegroundColor Green
27+
}
28+
29+
# Check if at least one API key is present
30+
if ($openaiKeyMissing -and $anthropicKeyMissing) {
31+
Write-Host "ERROR: Both OPENAI_API_KEY and ANTHROPIC_API_KEY are missing." -ForegroundColor Red
32+
Write-Host "At least one API key is required to use language models." -ForegroundColor Red
33+
Write-Host "Please set at least one of these keys before running the application." -ForegroundColor Red
34+
exit 1
35+
}
36+
37+
Write-Host "Environment check completed successfully." -ForegroundColor Green
38+
39+
exit 0 # Explicitly exit with success code

scripts/support/check_env.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Check environment variables
3+
4+
echo "Checking environment variables..."
5+
6+
OPENAI_KEY_MISSING=false
7+
ANTHROPIC_KEY_MISSING=false
8+
9+
if [ -z "${OPENAI_API_KEY}" ]; then
10+
echo "OPENAI_API_KEY environment variable is not set"
11+
echo "OpenAI models will not be available"
12+
echo "Get an API key at https://platform.openai.com/api-keys"
13+
echo "Please set it with: export OPENAI_API_KEY=your_api_key"
14+
OPENAI_KEY_MISSING=true
15+
else
16+
echo "OPENAI_API_KEY set: OpenAI models are available"
17+
fi
18+
19+
if [ -z "${ANTHROPIC_API_KEY}" ]; then
20+
echo "ANTHROPIC_API_KEY environment variable is not set"
21+
echo "Claude models will not be available"
22+
echo "Get an API key at https://www.anthropic.com/api"
23+
echo "Please set it with: export ANTHROPIC_API_KEY=your_api_key"
24+
ANTHROPIC_KEY_MISSING=true
25+
else
26+
echo "ANTHROPIC_API_KEY set: Claude models are available"
27+
fi
28+
29+
if [ "$OPENAI_KEY_MISSING" = true ] && [ "$ANTHROPIC_KEY_MISSING" = true ]; then
30+
echo "ERROR: Both OPENAI_API_KEY and ANTHROPIC_API_KEY are missing."
31+
echo "At least one API key is required to use language models."
32+
echo "Please set at least one of these keys before running the application."
33+
exit 1
34+
fi

shell.cmd

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off
2+
setlocal
3+
4+
call .\scripts\support\check_env.bat
5+
6+
if errorlevel 1 (
7+
echo Environment check failed. Exiting...
8+
exit /b 1
9+
)
10+
11+
12+
set SPRING_PROFILES_ACTIVE=shell,severance
13+
14+
cmd /c mvn -P agent-examples-kotlin -Dmaven.test.skip=true spring-boot:run
15+
16+
endlocal

shell.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Save current location and environment
2+
Push-Location
3+
$originalProfiles = $env:SPRING_PROFILES_ACTIVE
4+
5+
try {
6+
# Run environment check
7+
Write-Host "Running environment check..." -ForegroundColor Cyan
8+
& .\scripts\support\check_env.ps1
9+
10+
if ($LASTEXITCODE -ne 0) {
11+
Write-Host "Environment check failed. Exiting..." -ForegroundColor Red
12+
exit 1
13+
}
14+
15+
16+
# Set Spring profiles
17+
$env:SPRING_PROFILES_ACTIVE = "shell,severance"
18+
19+
# Run Maven in subprocess
20+
cmd /c "mvn -P agent-examples-kotlin -Dmaven.test.skip=true spring-boot:run"
21+
}
22+
finally {
23+
# Restore original environment and location
24+
$env:SPRING_PROFILES_ACTIVE = $originalProfiles
25+
Pop-Location
26+
}

0 commit comments

Comments
 (0)