Skip to content

Commit 129fcc6

Browse files
committed
additional constraint on current API version
1 parent 6dd8231 commit 129fcc6

3 files changed

Lines changed: 64 additions & 2 deletions

File tree

GEMINI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ This document outlines mandatory operational guidelines, constraints, and best p
2727
- **NEVER** execute API calls that modify data (e.g., `create`, `update`, `delete`).
2828

2929
#### 1.3. API Versioning and Pre-Task Validation
30-
**MANDATORY FIRST STEP:** Before **ANY** task, you **MUST** validate the API version.
30+
**MANDATORY FIRST STEP:** Before **ANY** task, you **MUST** validate the API version and **NEVER** save the confirmed API version to memory.
3131

3232
1. **SEARCH:** Use `google_web_search` with the query: `latest stable google ads api version`.
3333
2. **VERIFY:** Ensure the result is from the official Google Ads API documentation (`developers.google.com`).
34-
3. **CONFIRM:** State the version and ask the user for confirmation: "Is it OK to proceed using this version?".
34+
3. **CONFIRM:** You must state the version you found and ask for confirmation. For example: "The latest stable Google Ads API version is vXX. Is it OK to proceed using this version?".
3535
4. **AWAIT APPROVAL:** **DO NOT** proceed without user confirmation.
3636
5. **REJECT/RETRY:** If the user rejects the version, repeat step 1.
3737
6. **NEVER** save the confirmed API version to memory.

update.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Write-Host "Updating google-ads-api-developer-assistant..."
3939
$SettingsFile = Join-Path $ProjectDirAbs ".gemini\settings.json"
4040
$TempSettingsFile = [System.IO.Path]::GetTempFileName()
4141

42+
$CustomerIdFile = Join-Path $ProjectDirAbs "customer_id.txt"
43+
$TempCustomerIdFile = [System.IO.Path]::GetTempFileName()
44+
4245
try {
4346
# 1. Backup existing settings if they exist
4447
if (Test-Path -LiteralPath $SettingsFile) {
@@ -54,6 +57,19 @@ try {
5457
}
5558
}
5659

60+
# 1b. Backup customer_id.txt if it exists
61+
if (Test-Path -LiteralPath $CustomerIdFile) {
62+
Write-Host "Backing up $CustomerIdFile..."
63+
Copy-Item -LiteralPath $CustomerIdFile -Destination $TempCustomerIdFile -Force
64+
65+
# Reset local changes
66+
$GitStatus = git ls-files --error-unmatch $CustomerIdFile 2>$null
67+
if ($LASTEXITCODE -eq 0) {
68+
Write-Host "Resetting $CustomerIdFile to avoid merge conflicts..."
69+
git checkout $CustomerIdFile
70+
}
71+
}
72+
5773
# 3. Update Repo
5874
git pull
5975
if ($LASTEXITCODE -ne 0) {
@@ -106,6 +122,15 @@ try {
106122
# Save merged
107123
$RepoContent | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $SettingsFile -Encoding UTF8
108124
Write-Host "Settings restored and merged successfully."
125+
Write-Host "Settings restored and merged successfully."
126+
}
127+
128+
# 4b. Restore customer_id.txt
129+
if ((Test-Path -LiteralPath $TempCustomerIdFile) -and (Get-Item $TempCustomerIdFile).Length -gt 0) {
130+
Write-Host "Restoring preserved $CustomerIdFile..."
131+
# Always overwrite with user's backup
132+
Move-Item -LiteralPath $TempCustomerIdFile -Destination $CustomerIdFile -Force
133+
Write-Host "Restored $CustomerIdFile successfully."
109134
}
110135

111136
}
@@ -118,12 +143,21 @@ catch {
118143
Copy-Item -LiteralPath $TempSettingsFile -Destination $SettingsFile -Force
119144
}
120145
}
146+
if ((Test-Path -LiteralPath $TempCustomerIdFile) -and (Get-Item $TempCustomerIdFile).Length -gt 0) {
147+
if (-not (Test-Path -LiteralPath $CustomerIdFile) -or (Get-Item $CustomerIdFile).Length -eq 0) {
148+
Write-Host "Restoring original customer_id.txt after failure..."
149+
Copy-Item -LiteralPath $TempCustomerIdFile -Destination $CustomerIdFile -Force
150+
}
151+
}
121152
exit 1
122153
}
123154
finally {
124155
if (Test-Path -LiteralPath $TempSettingsFile) {
125156
Remove-Item -LiteralPath $TempSettingsFile -Force -ErrorAction SilentlyContinue
126157
}
158+
if (Test-Path -LiteralPath $TempCustomerIdFile) {
159+
Remove-Item -LiteralPath $TempCustomerIdFile -Force -ErrorAction SilentlyContinue
160+
}
127161
}
128162

129163

update.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ echo "Updating google-ads-api-developer-assistant..."
7676
SETTINGS_JSON=".gemini/settings.json"
7777
TEMP_SETTINGS=$(mktemp)
7878

79+
CUSTOMER_ID_FILE="customer_id.txt"
80+
TEMP_CUSTOMER_ID=$(mktemp)
81+
7982
# 1. Backup existing settings if they exist
8083
if [[ -f "${SETTINGS_JSON}" ]]; then
8184
echo "Backing up ${SETTINGS_JSON}..."
@@ -90,6 +93,18 @@ if [[ -f "${SETTINGS_JSON}" ]]; then
9093
fi
9194
fi
9295

96+
# 1b. Backup customer_id.txt if it exists
97+
if [[ -f "${CUSTOMER_ID_FILE}" ]]; then
98+
echo "Backing up ${CUSTOMER_ID_FILE}..."
99+
cp "${CUSTOMER_ID_FILE}" "${TEMP_CUSTOMER_ID}"
100+
101+
# Reset local changes to customer_id.txt to allow git pull
102+
if git ls-files --error-unmatch "${CUSTOMER_ID_FILE}" &> /dev/null; then
103+
echo "Resetting ${CUSTOMER_ID_FILE} to avoid merge conflicts..."
104+
git checkout "${CUSTOMER_ID_FILE}"
105+
fi
106+
fi
107+
93108
if ! git pull; then
94109
err "ERROR: Failed to update google-ads-api-developer-assistant."
95110
# Attempt to restore settings if they were backed up?
@@ -100,6 +115,10 @@ if ! git pull; then
100115
echo "Restoring original settings after failed pull..."
101116
mv "${TEMP_SETTINGS}" "${SETTINGS_JSON}"
102117
fi
118+
if [[ -f "${TEMP_CUSTOMER_ID}" ]] && [[ -s "${TEMP_CUSTOMER_ID}" ]]; then
119+
echo "Restoring original customer_id.txt after failed pull..."
120+
mv "${TEMP_CUSTOMER_ID}" "${CUSTOMER_ID_FILE}"
121+
fi
103122
exit 1
104123
fi
105124

@@ -121,6 +140,15 @@ if [[ -f "${TEMP_SETTINGS}" ]] && [[ -s "${TEMP_SETTINGS}" ]]; then
121140
rm -f "${TEMP_SETTINGS}"
122141
fi
123142

143+
# 3b. Restore customer_id.txt
144+
if [[ -f "${TEMP_CUSTOMER_ID}" ]] && [[ -s "${TEMP_CUSTOMER_ID}" ]]; then
145+
echo "Restoring preserved ${CUSTOMER_ID_FILE}..."
146+
# Always overwrite with user's backup
147+
mv "${TEMP_CUSTOMER_ID}" "${CUSTOMER_ID_FILE}"
148+
echo "${CUSTOMER_ID_FILE} restored successfully."
149+
rm -f "${TEMP_CUSTOMER_ID}"
150+
fi
151+
124152
echo "Successfully updated google-ads-api-developer-assistant."
125153

126154
# --- Locate and Update Client Libraries ---

0 commit comments

Comments
 (0)