fix(update): preserve local model and effort
This commit is contained in:
1 parent
7572ec40d9
commit
13594fb401
4 files changed
+36
-9
No files matched your search
@@ -86,6 +86,17 @@ function Sync-ManagedDestination {
|
||||
if ($relative -eq 'config.toml' -and (Test-Path -LiteralPath $target)) {
|
||||
$localConfig = [System.IO.File]::ReadAllText($target)
|
||||
$pluginTables = [regex]::Matches($localConfig, '(?m)^[ \t]*\[(?:plugins|marketplaces)(?:\.|\])[\s\S]*?(?=^[ \t]*\[|\z)')
|
||||
$rootConfig = [regex]::Split($localConfig, '(?m)^[ \t]*\[', 2)[0]
|
||||
$localSettings = [regex]::Matches($rootConfig, '(?m)^[ \t]*(?:model|reasoning_effort)[ \t]*=.*$')
|
||||
if ($localSettings.Count -gt 0) {
|
||||
$content = [System.Text.Encoding]::UTF8.GetString($newBytes).TrimEnd([char[]]"`r`n")
|
||||
foreach ($setting in $localSettings) {
|
||||
$name = ([regex]::Match($setting.Value, '^[ \t]*([^ \t=]+)')).Groups[1].Value
|
||||
$content = [regex]::Replace($content, "(?m)^[ \t]*$([regex]::Escape($name))[ \t]*=.*(?:\r?\n|$)", '')
|
||||
}
|
||||
$preservedSettings = ($localSettings | ForEach-Object { $_.Value.TrimEnd([char[]]"`r`n") }) -join "`n"
|
||||
$newBytes = [System.Text.Encoding]::UTF8.GetBytes("$content`n$preservedSettings`n")
|
||||
}
|
||||
if ($pluginTables.Count -gt 0) {
|
||||
$content = [System.Text.Encoding]::UTF8.GetString($newBytes).TrimEnd([char[]]"`r`n")
|
||||
if ($content -match '(?m)^[ \t]*\[(?:plugins|marketplaces)(?:\.|\])') {
|
||||
|
||||
+15
-1
@@ -84,7 +84,21 @@ sync_managed_destination() {
|
||||
new_hash=$(sha256_of_file "$source_file")
|
||||
fi
|
||||
if [ "$relative" = config.toml ] && [ -f "$target" ]; then
|
||||
local plugin_tables
|
||||
local plugin_tables local_settings setting_name
|
||||
local_settings=$(awk '
|
||||
/^[ \t]*\[/ { exit }
|
||||
/^[ \t]*(model|reasoning_effort)[ \t]*=/ { print }
|
||||
' "$target")
|
||||
if [ -n "$local_settings" ]; then
|
||||
while IFS= read -r setting; do
|
||||
setting_name=${setting%%=*}
|
||||
setting_name=${setting_name//[[:space:]]/}
|
||||
content=$(printf '%s\n' "$content" | sed "/^[[:space:]]*$setting_name[[:space:]]*=/d")
|
||||
done <<< "$local_settings"
|
||||
content="$content"$'\n'"$local_settings"$'\n'
|
||||
needs_sub=true
|
||||
new_hash=$(sha256_of_string "$content")
|
||||
fi
|
||||
plugin_tables=$(awk '
|
||||
/^[ \t]*\[/ { preserve = ($0 ~ /^[ \t]*\[(plugins|marketplaces)(\.|\])/) }
|
||||
preserve { print }
|
||||
|
||||
Reference in new issue
Block a user