From 587c27c1cdbab90fcd89c7e6d23bc03f0e468cee Mon Sep 17 00:00:00 2001 From: Julian lechner Date: Thu, 1 Oct 2026 13:27:55 +0200 Subject: [PATCH] feat(install): install semantic-search only with retrieval Skip the semantic-search skill while semantic retrieval is disabled and remove a setup-owned copy when it is turned off. Co-Authored-By: Claude Opus 5.5 --- scripts/commands/install.ps1 | 2 +- scripts/commands/install.sh | 2 +- scripts/commands/update.ps1 | 2 +- scripts/commands/update.sh | 2 +- scripts/lib/manifest.ps1 | 3 +++ scripts/lib/manifest.sh | 5 +++-- scripts/tests/test-managed-install.ps1 | 12 ++++++++++++ scripts/tests/test-managed-install.sh | 9 +++++++++ 8 files changed, 31 insertions(+), 6 deletions(-) diff --git a/scripts/commands/install.ps1 b/scripts/commands/install.ps1 index 39ca53c..aee5507 100644 --- a/scripts/commands/install.ps1 +++ b/scripts/commands/install.ps1 @@ -41,7 +41,7 @@ $plugins = Select-ConfiguredPlugins -RepositoryRoot $root -HomePath $homePath -C foreach ($item in (Get-InstallTargets -Generated $generated -HomePath $homePath -Shell $shell -Client $Client)) { Sync-ManagedDestination -Source $item.Source -Destination $item.Destination -Stamp $stamp ` - -AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -PowerShellCommand $powerShellCommand -ClaudeConcurrency $claudeConcurrency -FlashbangEnabled $options.flashbang -StatusLineEnabled $options.statusline -DryRun:$DryRun -Summary:$Summary + -AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -PowerShellCommand $powerShellCommand -ClaudeConcurrency $claudeConcurrency -FlashbangEnabled $options.flashbang -StatusLineEnabled $options.statusline -SemanticRetrievalEnabled $options.semantic_retrieval -DryRun:$DryRun -Summary:$Summary } Sync-ConfiguredPlugins -RepositoryRoot $root -HomePath $homePath -Client $Client -DryRun:$DryRun -Summary:$Summary -Entries $plugins.Selected diff --git a/scripts/commands/install.sh b/scripts/commands/install.sh index 0c8eed9..e160cec 100644 --- a/scripts/commands/install.sh +++ b/scripts/commands/install.sh @@ -58,7 +58,7 @@ select_configured_plugins "$root" "$client" Install "$dry_run" selected_plugins while IFS='|' read -r source destination; do ai_config_root=$destination command -v cygpath >/dev/null && ai_config_root=$(cygpath -m "$destination") - sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$powershell_command" "$dry_run" "$summary" "$flashbang" "$claude_concurrency" "$statusline" + sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$powershell_command" "$dry_run" "$summary" "$flashbang" "$claude_concurrency" "$statusline" "$semantic_retrieval" done < <(get_install_targets "$generated" "$home_path" "$shell" "$client") sync_configured_plugins "$root" "$client" "$home_path" "$dry_run" false selected_plugins "$summary" diff --git a/scripts/commands/update.ps1 b/scripts/commands/update.ps1 index a5bf930..9412c0b 100644 --- a/scripts/commands/update.ps1 +++ b/scripts/commands/update.ps1 @@ -51,7 +51,7 @@ $plugins = if ($Quick) { foreach ($item in (Get-InstallTargets -Generated $generated -HomePath $homePath -Shell $shell -Client $Client)) { Sync-ManagedDestination -Source $item.Source -Destination $item.Destination -Stamp $stamp ` - -AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -PowerShellCommand $powerShellCommand -FlashbangEnabled $options.flashbang -StatusLineEnabled $options.statusline -DryRun:$DryRun -Summary:$Summary + -AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -PowerShellCommand $powerShellCommand -FlashbangEnabled $options.flashbang -StatusLineEnabled $options.statusline -SemanticRetrievalEnabled $options.semantic_retrieval -DryRun:$DryRun -Summary:$Summary } $previousPluginNonInteractive = $script:PluginNonInteractive diff --git a/scripts/commands/update.sh b/scripts/commands/update.sh index 35b99d1..e6b7930 100644 --- a/scripts/commands/update.sh +++ b/scripts/commands/update.sh @@ -63,7 +63,7 @@ fi while IFS='|' read -r source destination; do ai_config_root=$destination command -v cygpath >/dev/null && ai_config_root=$(cygpath -m "$destination") - sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$powershell_command" "$dry_run" "$summary" "$flashbang" 5 "$statusline" + sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$powershell_command" "$dry_run" "$summary" "$flashbang" 5 "$statusline" "$semantic_retrieval" done < <(get_install_targets "$generated" "$home_path" "$shell" "$client") if [ "$quick" = true ]; then diff --git a/scripts/lib/manifest.ps1 b/scripts/lib/manifest.ps1 index 3104021..4ead13e 100644 --- a/scripts/lib/manifest.ps1 +++ b/scripts/lib/manifest.ps1 @@ -142,6 +142,7 @@ function Sync-ManagedDestination { [string]$ClaudeConcurrency = '5', [bool]$FlashbangEnabled = $true, [bool]$StatusLineEnabled = $true, + [bool]$SemanticRetrievalEnabled = $true, [switch]$DryRun, [switch]$Summary ) @@ -169,6 +170,7 @@ function Invoke-ManagedSync { [string]$ClaudeConcurrency = '5', [bool]$FlashbangEnabled = $true, [bool]$StatusLineEnabled = $true, + [bool]$SemanticRetrievalEnabled = $true, [switch]$DryRun, [switch]$Summary ) @@ -193,6 +195,7 @@ function Invoke-ManagedSync { $relative = $_.FullName.Substring($Source.Length).TrimStart([char[]]@('\','/')).Replace('\','/') if ((Split-Path $Destination -Leaf) -eq '.codex' -and $relative.StartsWith('skills/')) { return } if ((Split-Path $Destination -Leaf) -eq '.claude' -and -not $StatusLineEnabled -and $relative.StartsWith('statusline/')) { return } + if (-not $SemanticRetrievalEnabled -and $relative -match '(^|/)semantic-search/') { return } $target = Resolve-ManagedPath -Destination $Destination -Relative $relative $rawContent = Get-Content -LiteralPath $_.FullName -Raw -Encoding UTF8 $filterOptions = ((-not $FlashbangEnabled) -or (-not $StatusLineEnabled)) -and $relative -in @('settings.json', 'config.toml') diff --git a/scripts/lib/manifest.sh b/scripts/lib/manifest.sh index 7825c63..6255cc5 100644 --- a/scripts/lib/manifest.sh +++ b/scripts/lib/manifest.sh @@ -120,9 +120,9 @@ sync_managed_destination() { return "$status" } -# run_managed_sync [summary: true|false] [flashbang] [claude-concurrency] [statusline] +# run_managed_sync [summary: true|false] [flashbang] [claude-concurrency] [statusline] [semantic-retrieval] run_managed_sync() { - local source=$1 destination=$2 stamp=$3 ai_config_root=$4 shell_command=$5 powershell_command=$6 dry_run=$7 summary=${8:-false} flashbang_enabled=${9:-true} claude_concurrency=${10:-5} statusline_enabled=${11:-true} + local source=$1 destination=$2 stamp=$3 ai_config_root=$4 shell_command=$5 powershell_command=$6 dry_run=$7 summary=${8:-false} flashbang_enabled=${9:-true} claude_concurrency=${10:-5} statusline_enabled=${11:-true} semantic_retrieval_enabled=${12:-true} [ "$summary" = true ] || printf 'SOURCE %s -> %s\n' "$source" "$destination" local manifest manifest=$(manifest_path "$destination") @@ -151,6 +151,7 @@ run_managed_sync() { relative=${source_file#"$source/"} if [ "${destination##*/}" = .codex ] && [[ "$relative" = skills/* ]]; then continue; fi if [ "${destination##*/}" = .claude ] && [ "$statusline_enabled" = false ] && [[ "$relative" = statusline/* ]]; then continue; fi + if [ "$semantic_retrieval_enabled" = false ] && [[ "$relative" =~ (^|/)semantic-search/ ]]; then continue; fi target=$(managed_target "$destination" "$relative") || return 1 content=$(cat -- "$source_file" && printf '\034') || return content=${content%$'\034'} diff --git a/scripts/tests/test-managed-install.ps1 b/scripts/tests/test-managed-install.ps1 index 19023b4..0d8c89e 100644 --- a/scripts/tests/test-managed-install.ps1 +++ b/scripts/tests/test-managed-install.ps1 @@ -122,6 +122,18 @@ try { if (@(Get-ChildItem -LiteralPath $destination -Filter '.ai-config-write-*' -File -Recurse).Count) { throw 'Atomic writes left a temporary file.' } if (Test-Path -LiteralPath (Join-Path $destination '.ai-config.lock')) { throw 'Sync must release its destination lock.' } + $searchSkill = Join-Path $source 'skills/semantic-search/SKILL.md' + New-Item (Split-Path $searchSkill -Parent) -ItemType Directory -Force | Out-Null + Set-Content $searchSkill 'search skill' -NoNewline + $installedSearchSkill = Join-Path $destination 'skills/semantic-search/SKILL.md' + $null = Sync-ManagedDestination -Source $source -Destination $destination -Stamp 'search-off' -SemanticRetrievalEnabled $false + if (Test-Path -LiteralPath $installedSearchSkill) { throw 'The semantic-search skill must not be installed while retrieval is disabled.' } + $null = Sync-ManagedDestination -Source $source -Destination $destination -Stamp 'search-on' -SemanticRetrievalEnabled $true + if (-not (Test-Path -LiteralPath $installedSearchSkill)) { throw 'The semantic-search skill must be installed while retrieval is enabled.' } + $null = Sync-ManagedDestination -Source $source -Destination $destination -Stamp 'search-off-again' -SemanticRetrievalEnabled $false + if (Test-Path -LiteralPath $installedSearchSkill) { throw 'Disabling retrieval must remove the setup-owned semantic-search skill.' } + Remove-Item -LiteralPath (Split-Path $searchSkill -Parent) -Recurse -Force + $lockPath = Join-Path $destination '.ai-config.lock' [System.IO.File]::WriteAllText($lockPath, "bash other-host 1`n") $manifestBefore = [System.IO.File]::ReadAllText((Get-ManagedManifestPath $destination)) diff --git a/scripts/tests/test-managed-install.sh b/scripts/tests/test-managed-install.sh index fcf4f79..1d552a3 100644 --- a/scripts/tests/test-managed-install.sh +++ b/scripts/tests/test-managed-install.sh @@ -137,6 +137,15 @@ sync_managed_destination "$source_dir" "$destination" concurrency "" "" "" false [ "$(cat "$destination/concurrency.txt")" = 7 ] || { printf 'Standalone concurrency placeholder must be resolved.\n' >&2; exit 1; } [ -z "$(find "$destination" -name '.ai-config-write.*' -print -quit)" ] || { printf 'Atomic writes left a temporary file.\n' >&2; exit 1; } [ ! -e "$destination/.ai-config.lock" ] || { printf 'Sync must release its destination lock.\n' >&2; exit 1; } +mkdir -p "$source_dir/skills/semantic-search" +printf 'search skill' > "$source_dir/skills/semantic-search/SKILL.md" +sync_managed_destination "$source_dir" "$destination" search-off "" "" "" false false true 5 true false > /dev/null +[ ! -e "$destination/skills/semantic-search/SKILL.md" ] || { printf 'The semantic-search skill must not be installed while retrieval is disabled.\n' >&2; exit 1; } +sync_managed_destination "$source_dir" "$destination" search-on "" "" "" false false true 5 true true > /dev/null +[ -f "$destination/skills/semantic-search/SKILL.md" ] || { printf 'The semantic-search skill must be installed while retrieval is enabled.\n' >&2; exit 1; } +sync_managed_destination "$source_dir" "$destination" search-off-again "" "" "" false false true 5 true false > /dev/null +[ ! -e "$destination/skills/semantic-search/SKILL.md" ] || { printf 'Disabling retrieval must remove the setup-owned semantic-search skill.\n' >&2; exit 1; } +rm -r -- "$source_dir/skills/semantic-search" printf 'powershell other-host 1\n' > "$destination/.ai-config.lock" manifest_before=$(cat "$destination/.ai-config-manifest.tsv") if sync_managed_destination "$source_dir" "$destination" locked "" "" "" false > /dev/null 2>&1; then printf 'A held destination lock must block a parallel sync.\n' >&2; exit 1; fi