Skip to content

Commit 02fd12b

Browse files
committed
fix: add dict type check for settings merge, simplify PS1 to subprocess
- _merge_vscode_settings() skips merge with warning if parsed JSON is not a dict (array, null, etc.) - PS1 update-context.ps1 uses & invocation instead of dot-sourcing since the shared script runs Main unconditionally
1 parent 8184244 commit 02fd12b

2 files changed

Lines changed: 11 additions & 20 deletions

File tree

src/specify_cli/integrations/copilot/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ def _merge_vscode_settings(src: Path, dst: Path) -> None:
171171

172172
new_settings = json.loads(src.read_text(encoding="utf-8"))
173173

174+
if not isinstance(existing, dict) or not isinstance(new_settings, dict):
175+
import logging
176+
logging.getLogger(__name__).warning(
177+
"Skipping settings merge: %s or template is not a JSON object.", dst
178+
)
179+
return
180+
174181
for key, value in new_settings.items():
175182
if key not in existing:
176183
existing[key] = value

src/specify_cli/integrations/copilot/scripts/update-context.ps1

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,13 @@
1010
# refactored to support SPECKIT_SOURCE_ONLY (guard the Main call) before
1111
# dot-sourcing will work.
1212
#
13-
# Prerequisites (Stage 7):
14-
# - update-agent-context.ps1 must guard its Main call behind
15-
# if (-not $env:SPECKIT_SOURCE_ONLY) { Main }
16-
# - Functions must be importable without side effects
13+
# Until then, this delegates to the shared script as a subprocess.
1714

1815
$ErrorActionPreference = 'Stop'
1916

2017
$repoRoot = git rev-parse --show-toplevel 2>$null
2118
if (-not $repoRoot) { $repoRoot = $PWD.Path }
2219

23-
# Source shared utilities
24-
. "$repoRoot/.specify/scripts/powershell/common.ps1"
25-
26-
# Source update-agent-context functions
27-
# SPECKIT_SOURCE_ONLY prevents the shared script from running its own main.
28-
$env:SPECKIT_SOURCE_ONLY = '1'
29-
. "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1"
30-
31-
# Gather feature paths and parse plan data
32-
$paths = Get-FeaturePathsEnv
33-
$implPlan = $paths.IMPL_PLAN
34-
Parse-PlanData -PlanFile $implPlan
35-
36-
# Create or update the copilot instructions file
37-
$copilotFile = Join-Path $repoRoot '.github/copilot-instructions.md'
38-
Update-AgentFile -TargetFile $copilotFile -AgentName 'GitHub Copilot'
20+
# Invoke shared update-agent-context script as a separate process.
21+
# Dot-sourcing is unsafe until that script guards its Main call.
22+
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType copilot

0 commit comments

Comments
 (0)