diff --git a/.gemini/commands/explain.toml b/.gemini/commands/explain.toml new file mode 100644 index 0000000..7c854e3 --- /dev/null +++ b/.gemini/commands/explain.toml @@ -0,0 +1,8 @@ +description = "Explains the code or text provided in plain English." + +prompt = """ +You are a helpful coding tutor. +Please explain the following code or text in simple, easy-to-understand terms: + +{{args}} +""" diff --git a/GEMINI.md b/GEMINI.md index e0ae487..0ba79bb 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -54,6 +54,7 @@ This document outlines mandatory operational guidelines, constraints, and best p #### 2.2. File System - **Allowed Write Directories:** `saved_code/`, `saved_csv/`. - **Prohibited Write Directories:** Client library source directories (e.g., `google-ads-python/`, `google-ads-perl/`), `api_examples/`, or other project source directories unless explicitly instructed. +- **NEVER** modify the files in `api_examples/`. If you need to use a file as a base for a request, copy the comments and put the file with modifications in `saved_code/`. - **All new or modified code MUST be written to the `saved_code/` directory.** - **File Naming:** Use descriptive, language-appropriate names (e.g., `get_campaign_metrics.py`, `GetCampaignMetrics.java`). - **Temporary Files:** Use the system's temporary directory. diff --git a/setup.ps1 b/setup.ps1 index c49f6f4..36eb1cc 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -43,8 +43,23 @@ param( $ErrorActionPreference = "Stop" +# --- Project Directory Resolution --- +# Determine the root directory of the current git repository. +try { + $ProjectDirAbs = git rev-parse --show-toplevel 2>$null + if (-not $ProjectDirAbs) { throw "Not in a git repo" } + # Normalize path separator + $ProjectDirAbs = (Get-Item -LiteralPath $ProjectDirAbs).FullName +} +catch { + Write-Error "ERROR: This script must be run from within the google-ads-api-developer-assistant git repository." + exit 1 +} + +Write-Host "Detected project root: $ProjectDirAbs" + # --- Configuration --- -$DefaultParentDir = Join-Path $HOME "gaada" +$DefaultParentDir = Join-Path $ProjectDirAbs "client_libs" $AllLangs = @("python", "php", "ruby", "java", "dotnet") # Helper to get repo config @@ -76,21 +91,6 @@ if (-not (Get-Command git -ErrorAction SilentlyContinue)) { exit 1 } -# --- Project Directory Resolution --- -# Determine the root directory of the current git repository. -try { - $ProjectDirAbs = git rev-parse --show-toplevel 2>$null - if (-not $ProjectDirAbs) { throw "Not in a git repo" } - # Normalize path separator - $ProjectDirAbs = (Get-Item -LiteralPath $ProjectDirAbs).FullName -} -catch { - Write-Error "ERROR: This script must be run from within the google-ads-api-developer-assistant git repository." - exit 1 -} - -Write-Host "Detected project root: $ProjectDirAbs" - # --- Path Resolution and Validation --- Write-Host "Ensuring default library directory exists: $DefaultParentDir" if (-not (Test-Path -LiteralPath $DefaultParentDir)) { @@ -117,13 +117,6 @@ foreach ($Lang in $AllLangs) { $Config = Get-RepoConfig -Lang $Lang $RepoPath = Join-Path $DefaultParentDir $Config.Name $LibPaths[$Lang] = $RepoPath - - # Validation: check against project dir - # Simple string check for subdirectory - if ($RepoPath.StartsWith($ProjectDirAbs)) { - Write-Error "ERROR: $Lang path ($RepoPath) cannot be a subdirectory of the project directory ($ProjectDirAbs)" - exit 1 - } } } diff --git a/setup.sh b/setup.sh index 3414b11..505aea8 100755 --- a/setup.sh +++ b/setup.sh @@ -31,8 +31,17 @@ err() { echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2 } +# --- Project Directory Resolution --- +# Determine the root directory of the current git repository. +if ! PROJECT_DIR_ABS=$(git rev-parse --show-toplevel 2>/dev/null); then + err "ERROR: This script must be run from within the google-ads-api-developer-assistant git repository." + exit 1 +fi +readonly PROJECT_DIR_ABS +echo "Detected project root: ${PROJECT_DIR_ABS}" + # --- Configuration --- -readonly DEFAULT_PARENT_DIR="${HOME}/gaada" +readonly DEFAULT_PARENT_DIR="${PROJECT_DIR_ABS}/client_libs" readonly ALL_LANGS="python php ruby java dotnet" # Helper functions for repo info (Replacing associative arrays for Bash 3.2 compatibility) @@ -161,15 +170,6 @@ while [[ $# -gt 0 ]]; do esac done -# --- Project Directory Resolution --- -# Determine the root directory of the current git repository. -if ! PROJECT_DIR_ABS=$(git rev-parse --show-toplevel 2>/dev/null); then - err "ERROR: This script must be run from within the google-ads-api-developer-assistant git repository." - exit 1 -fi -readonly PROJECT_DIR_ABS -echo "Detected project root: ${PROJECT_DIR_ABS}" - # --- Language Selection Logic --- # If no languages selected, select all if [[ "${ANY_SELECTED}" == "false" ]]; then @@ -219,11 +219,7 @@ for lang in $ALL_LANGS; do # Bash 3.2 compatible way to set variable by name eval "LIB_PATH_${lang}='${ABS_PATH}'" - # Validation: check against project dir - if [[ "${ABS_PATH}" == "${PROJECT_DIR_ABS}"* ]]; then - err "ERROR: ${lang} path (${ABS_PATH}) cannot be a subdirectory of the project directory (${PROJECT_DIR_ABS})" - exit 1 - fi + fi done diff --git a/update.ps1 b/update.ps1 index 7ce898a..8178a4d 100644 --- a/update.ps1 +++ b/update.ps1 @@ -194,11 +194,7 @@ try { $AbsLibPath = (Get-Item -LiteralPath $LibPath).FullName - # Skip if it is the project directory itself or a subdirectory of it - if ($AbsLibPath.StartsWith($ProjectDirAbs)) { - Write-Host "Skipping internal directory: $AbsLibPath" - continue - } + # Check if it is a git repository if (-not (Test-Path -LiteralPath (Join-Path $AbsLibPath ".git"))) { diff --git a/update.sh b/update.sh index 55eb7d3..0a07236 100755 --- a/update.sh +++ b/update.sh @@ -191,11 +191,7 @@ for lib_path in "${INCLUDE_DIRS[@]}"; do continue fi - # Skip if it is the project directory itself or a subdirectory of it - if [[ "${abs_lib_path}" == "${PROJECT_DIR_ABS}"* ]]; then - echo "Skipping internal directory: ${abs_lib_path}" - continue - fi + # Check if it is a git repository if [[ ! -d "${abs_lib_path}/.git" ]]; then