fix(gemini): conseca.toml enum value autoEdit, not auto_edit
Gemini v0.35+ accepts only camelCase 'autoEdit' in safety_checker modes (strict zod schema). Older patcher inserted snake_case 'auto_edit' which blocks gemini startup with: "Invalid enum value. Expected 'default' | 'autoEdit' | 'yolo' | 'plan', received 'auto_edit'". Changes: - conseca.toml writer now emits 'autoEdit' - self-heal: detect existing 'auto_edit' on disk and rewrite to 'autoEdit' - settingsSchema.js patcher: accept both 'auto_edit' (v0.32.x) and 'autoEdit' (v0.35+) source variants Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -657,35 +657,43 @@ def patch_auto_permissions(gemini_root, config):
|
||||
patched_parts.append("config.js: not found")
|
||||
|
||||
# --- 9a2: Patch settingsSchema.js to add 'yolo' to valid options ---
|
||||
# Gemini v0.32.1 used 'auto_edit', v0.35+ uses 'autoEdit' — handle both.
|
||||
schema_path = os.path.join(gemini_root, SETTINGS_SCHEMA_SUBPATH)
|
||||
if os.path.isfile(schema_path):
|
||||
with open(schema_path, "r", encoding="utf-8") as f:
|
||||
schema_content = f.read()
|
||||
|
||||
if "{ value: 'yolo'" in schema_content:
|
||||
patched_parts.append("settingsSchema.js: already patched")
|
||||
else:
|
||||
backup_done = False
|
||||
patched = False
|
||||
for ae_value in ("autoEdit", "auto_edit"):
|
||||
old_options = (
|
||||
"{ value: 'default', label: 'Default' },\n"
|
||||
" { value: 'auto_edit', label: 'Auto Edit' },\n"
|
||||
f" {{ value: '{ae_value}', label: 'Auto Edit' }},\n"
|
||||
" { value: 'plan', label: 'Plan' },"
|
||||
)
|
||||
new_options = (
|
||||
"{ value: 'default', label: 'Default' },\n"
|
||||
" { value: 'auto_edit', label: 'Auto Edit' },\n"
|
||||
f" {{ value: '{ae_value}', label: 'Auto Edit' }},\n"
|
||||
" { value: 'plan', label: 'Plan' },\n"
|
||||
" { value: 'yolo', label: 'YOLO' },"
|
||||
)
|
||||
|
||||
if old_options in schema_content and "{ value: 'yolo'" not in schema_content:
|
||||
if old_options in schema_content:
|
||||
if not backup_done:
|
||||
backup = schema_path + ".backup"
|
||||
if not os.path.exists(backup):
|
||||
shutil.copy2(schema_path, backup)
|
||||
backup_done = True
|
||||
schema_content = schema_content.replace(old_options, new_options, 1)
|
||||
with open(schema_path, "w", encoding="utf-8") as f:
|
||||
f.write(schema_content)
|
||||
changes += 1
|
||||
patched_parts.append("settingsSchema.js: yolo option added")
|
||||
elif "{ value: 'yolo'" in schema_content:
|
||||
patched_parts.append("settingsSchema.js: already patched")
|
||||
else:
|
||||
patched_parts.append(f"settingsSchema.js: yolo option added ({ae_value} variant)")
|
||||
patched = True
|
||||
break
|
||||
if not patched:
|
||||
patched_parts.append("settingsSchema.js: pattern not found")
|
||||
else:
|
||||
patched_parts.append("settingsSchema.js: not found")
|
||||
@@ -784,12 +792,25 @@ def patch_auto_permissions(gemini_root, config):
|
||||
'[[safety_checker]]\n'
|
||||
'toolName = "*"\n'
|
||||
'priority = 100\n'
|
||||
'modes = ["default", "auto_edit", "plan"]\n'
|
||||
'modes = ["default", "autoEdit", "plan"]\n'
|
||||
'[safety_checker.checker]\n'
|
||||
'type = "in-process"\n'
|
||||
'name = "conseca"'
|
||||
)
|
||||
|
||||
# Self-heal: if older patcher inserted invalid `auto_edit` enum value, fix it
|
||||
if 'modes = ["default", "auto_edit", "plan"]' in conseca_content:
|
||||
backup = conseca_path + ".backup"
|
||||
if not os.path.exists(backup):
|
||||
shutil.copy2(conseca_path, backup)
|
||||
conseca_content = conseca_content.replace(
|
||||
'modes = ["default", "auto_edit", "plan"]',
|
||||
'modes = ["default", "autoEdit", "plan"]',
|
||||
)
|
||||
with open(conseca_path, "w", encoding="utf-8") as f:
|
||||
f.write(conseca_content)
|
||||
changes += 1
|
||||
|
||||
if old_conseca in conseca_content and 'modes = ["default"' not in conseca_content:
|
||||
backup = conseca_path + ".backup"
|
||||
if not os.path.exists(backup):
|
||||
|
||||
Reference in New Issue
Block a user