Skip to content
Open
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
1 change: 1 addition & 0 deletions here.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@call scripts\here-impl.cmd %*
1 change: 1 addition & 0 deletions here.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
& "$PSScriptRoot\scripts\here-impl.ps1" @args
2 changes: 2 additions & 0 deletions here.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
exec "$(dirname "$0")/scripts/here-impl.sh" "$@"
25 changes: 22 additions & 3 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,33 @@ Sets up the development environment to prioritize debug builds over globally ins
./scripts/setup-debug-path.sh --help
```

### What it does
## cycodpath.cmd

- Adds debug binary paths to the front of PATH:
Windows equivalent of setup-debug-path.sh. Sets up PATH for current session to prioritize debug builds.

### Usage

```cmd
REM Setup PATH for current session
scripts\cycodpath.cmd
```

### What they do

- Add debug binary paths to the front of PATH:
- `src/cycod/bin/Debug/net9.0`
- `src/cycodmd/bin/Debug/net9.0`
- `src/cycodt/bin/Debug/net9.0`
- When you run `cycod`, `cycodmd`, or `cycodt`, it will use debug versions if built
- `src/cycodgr/bin/Debug/net9.0`
- `src/mcp/geolocation/bin/Debug/net9.0`
- `src/mcp/mxlookup/bin/Debug/net9.0`
- `src/mcp/osm/bin/Debug/net9.0`
- `src/mcp/weather/bin/Debug/net9.0`
- `src/mcp/whois/bin/Debug/net9.0`
- When you run any cycod tool, it will use debug versions if built
- Falls back to global dotnet tool versions if debug versions don't exist
- **setup-debug-path.sh** can persist changes to ~/.bashrc for permanent setup
- **cycodpath.cmd** sets up PATH for current Windows session only
- Automatically runs in codespaces via `postCreateCommand` in devcontainer.json

### Integration with .bashrc
Expand Down
137 changes: 137 additions & 0 deletions scripts/cycodpath.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
@echo off

REM ===== CYCODPATH.CMD =====
REM Finds all cycod executables (main apps and MCP servers) and adds their folders to PATH
REM Prioritizes Debug over Release, newest timestamp as fallback

echo Finding all cycod executables (main apps and MCP servers)...
echo.

REM Initialize variables
set "folders_to_add="
set "found_cycod="
set "found_cycodt="
set "found_cycodmd="
set "found_cycodgr="
set "found_cycod-mcp-geolocation="
set "found_cycod-mcp-mxlookup="
set "found_cycod-mcp-osm="
set "found_cycod-mcp-weather="
set "found_cycod-mcp-whois="
set "folder_count=0"

REM ===== MAIN SEARCH LOOP =====
for %%e in (cycod cycodt cycodmd cycodgr cycod-mcp-geolocation cycod-mcp-mxlookup cycod-mcp-osm cycod-mcp-weather cycod-mcp-whois) do (
call :FindExecutable %%e
)

REM ===== UPDATE PATH =====
call :UpdatePath

REM ===== SUMMARY =====
call :ShowSummary

goto :EOF

REM ===== SUBROUTINES =====

:FindExecutable
set "exe_name=%1"
set "found_path="

REM Try direct paths first - Debug priority
if exist "bin\Debug\net9.0\%exe_name%.exe" (
set "found_path=bin\Debug\net9.0\%exe_name%.exe"
goto :FoundDirect
)

if exist "bin\Release\net9.0\%exe_name%.exe" (
set "found_path=bin\Release\net9.0\%exe_name%.exe"
goto :FoundDirect
)

REM Try other common debug/release patterns
for %%p in ("bin\Debug\%exe_name%.exe" "bin\Release\%exe_name%.exe" "bin\x64\Debug\%exe_name%.exe" "bin\x64\Release\%exe_name%.exe") do (
if exist %%p (
set "found_path=%%~p"
goto :FoundDirect
)
)

REM Fallback: Use forfiles to find newest by timestamp
set "temp_file=%TEMP%\cycodpath_temp_%RANDOM%.txt"
forfiles /m "%exe_name%.exe" /s /c "cmd /c echo @path" 2>nul > "%temp_file%"

if exist "%temp_file%" (
for /f "usebackq tokens=*" %%f in ("%temp_file%") do (
set "found_path=%%~f"
goto :FoundFallback
)
)

del /q "%temp_file%" 2>nul
echo %exe_name%.exe not found
set "found_%exe_name%="
goto :EOF

:FoundDirect
echo Found %exe_name%.exe: %CD%\%found_path%
for %%d in ("%found_path%") do set "dir_path=%%~dpd"
set "dir_path=%dir_path:~0,-1%"
call :AddFolder "%CD%\%dir_path%"
set "found_%exe_name%=YES"
goto :EOF

:FoundFallback
echo Found %exe_name%.exe: %found_path%
for %%d in ("%found_path%") do set "dir_path=%%~dpd"
set "dir_path=%dir_path:~0,-1%"
call :AddFolder "%dir_path%"
set "found_%exe_name%=YES"
del /q "%temp_file%" 2>nul
goto :EOF

:AddFolder
set "new_folder=%~1"
REM Check if folder already in our list
echo %folders_to_add% | findstr /C:"%new_folder%" >nul
if errorlevel 1 (
if defined folders_to_add (
set "folders_to_add=%folders_to_add%;%new_folder%"
) else (
set "folders_to_add=%new_folder%"
)
echo -> Added %new_folder% to PATH
set /a folder_count+=1
)
goto :EOF

:UpdatePath
if defined folders_to_add (
set "PATH=%folders_to_add%;%PATH%"
echo PATH updated.
) else (
echo No folders to add to PATH.
)
goto :EOF

:ShowSummary
echo.
set "summary=Summary: "
if defined found_cycod (set "summary=%summary%cycod YES") else (set "summary=%summary%cycod NO")
if defined found_cycodt (set "summary=%summary%, cycodt YES") else (set "summary=%summary%, cycodt NO")
if defined found_cycodmd (set "summary=%summary%, cycodmd YES") else (set "summary=%summary%, cycodmd NO")
if defined found_cycodgr (set "summary=%summary%, cycodgr YES") else (set "summary=%summary%, cycodgr NO")
if defined found_cycod-mcp-geolocation (set "summary=%summary%, mcp-geo YES") else (set "summary=%summary%, mcp-geo NO")
if defined found_cycod-mcp-mxlookup (set "summary=%summary%, mcp-mx YES") else (set "summary=%summary%, mcp-mx NO")
if defined found_cycod-mcp-osm (set "summary=%summary%, mcp-osm YES") else (set "summary=%summary%, mcp-osm NO")
if defined found_cycod-mcp-weather (set "summary=%summary%, mcp-weather YES") else (set "summary=%summary%, mcp-weather NO")
if defined found_cycod-mcp-whois (set "summary=%summary%, mcp-whois YES") else (set "summary=%summary%, mcp-whois NO")

echo %summary%
if %folder_count% gtr 0 (
echo PATH updated with %folder_count% new entries.
) else (
echo No executables found - PATH unchanged.
)
goto :EOF
70 changes: 70 additions & 0 deletions scripts/here-impl.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@echo off

REM ===== HERE-IMPL.CMD =====
REM Environment activation script for cycod development

set "REPO_ROOT=%~dp0\.."
set "MODE=light"
set "STAY_FLAG="

REM Parse arguments
if "%~1"=="--shell" set "MODE=heavy"
if "%~1"=="-s" set "MODE=heavy"
if "%~1"=="shell" set "MODE=heavy"
if "%~2"=="--stay" set "STAY_FLAG=yes"
if "%~1"=="--help" goto :show_usage
if "%~1"=="-h" goto :show_usage

echo.
echo Cycod Environment Activation
echo ============================

if "%MODE%"=="light" goto :light_mode
if "%MODE%"=="heavy" goto :heavy_mode

:light_mode
echo Light mode: Setting up environment in current shell...
echo.

call "%REPO_ROOT%\scripts\cycodpath.cmd"

set "CYCOD_DEV_MODE=1"
set "CYCOD_REPO_ROOT=%REPO_ROOT%"

echo.
echo Environment activated in current shell!
echo Tip: Use 'here.cmd --shell' to launch new environment shell
goto :end

:heavy_mode
echo Heavy mode: Launching new environment shell...
echo.

set "CYCOD_DEV_MODE=1"
set "CYCOD_REPO_ROOT=%REPO_ROOT%"

if not defined STAY_FLAG (
echo Changing to repository root...
cd /d "%REPO_ROOT%"
)

echo Starting new shell with cycod environment...
echo Type 'exit' to return to previous environment.
echo.

cmd /k "call "%REPO_ROOT%\scripts\cycodpath.cmd" >nul & prompt (here:cycod) $P$G & echo Environment shell ready!"

goto :end

:show_usage
echo.
echo Usage: here.cmd [options]
echo.
echo Options:
echo (no options) Light mode: Set up environment in current shell
echo --shell, -s Heavy mode: Launch new shell with full environment
echo --stay (with --shell) Stay in current directory
echo --help, -h Show this help
goto :end

:end
102 changes: 102 additions & 0 deletions scripts/here-impl.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# ===== HERE-IMPL.PS1 =====
# Environment activation script for cycod development

param(
[switch]$Shell,
[switch]$S,
[switch]$Stay,
[switch]$Help,
[switch]$H,
[Parameter(ValueFromRemainingArguments)]
[string[]]$RemainingArgs
)

# Get the repository root directory
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRoot = Split-Path -Parent $ScriptDir

# Parse arguments
$Mode = "light"
$StayFlag = $Stay
$ShowHelp = $Help -or $H

if ($Shell -or $S -or ($RemainingArgs -contains "shell")) {
$Mode = "heavy"
}

function Show-Usage {
Write-Host ""
Write-Host "Usage: here.ps1 [options]"
Write-Host ""
Write-Host "Options:"
Write-Host " (no options) Light mode: Set up environment in current shell"
Write-Host " -Shell, -S Heavy mode: Launch new shell with full environment"
Write-Host " -Stay (with -Shell) Stay in current directory"
Write-Host " -Help, -H Show this help"
Write-Host ""
Write-Host "Examples:"
Write-Host " .\here.ps1 Light: Quick environment setup"
Write-Host " .\here.ps1 -Shell Heavy: New shell at repo root"
Write-Host " .\here.ps1 -Shell -Stay Heavy: New shell at current location"
}

if ($ShowHelp) {
Show-Usage
exit
}

Write-Host ""
Write-Host "Cycod Environment Activation" -ForegroundColor Cyan
Write-Host "============================" -ForegroundColor Cyan

if ($Mode -eq "light") {
Write-Host "Light mode: Setting up environment in current shell..." -ForegroundColor Yellow
Write-Host ""

# Call the existing PATH setup script
$CycodPathScript = Join-Path $RepoRoot "scripts\cycodpath.cmd"
if (Test-Path $CycodPathScript) {
cmd /c """$CycodPathScript"""
}

# Set additional environment variables
$env:CYCOD_DEV_MODE = "1"
$env:CYCOD_REPO_ROOT = $RepoRoot

Write-Host ""
Write-Host "Environment activated!" -ForegroundColor Green
Write-Host "Tip: Use './here.ps1 -Shell' to launch new environment shell" -ForegroundColor Yellow

} elseif ($Mode -eq "heavy") {
Write-Host "Heavy mode: Launching new environment shell..." -ForegroundColor Yellow
Write-Host ""

# Set environment variables
$env:CYCOD_DEV_MODE = "1"
$env:CYCOD_REPO_ROOT = $RepoRoot

# Determine target directory
if (-not $StayFlag) {
$TargetDir = $RepoRoot
Write-Host "Changing to repository root..." -ForegroundColor Yellow
} else {
$TargetDir = Get-Location
Write-Host "Staying in current directory..." -ForegroundColor Yellow
}

Write-Host "Starting new PowerShell with cycod environment..." -ForegroundColor Yellow
Write-Host "Type 'exit' to return to previous environment." -ForegroundColor Yellow
Write-Host ""

# Launch new PowerShell with custom prompt and setup
$setupCommands = @"
`$env:CYCOD_DEV_MODE='1'
`$env:CYCOD_REPO_ROOT='$RepoRoot'
function prompt { "(here:cycod) PS " + (Get-Location) + "> " }
Set-Location '$TargetDir'
cmd /c '$CycodPathScript' | Out-Null
Write-Host 'Environment shell ready!' -ForegroundColor Green
"@

powershell -NoExit -Command $setupCommands
}
Loading