Skip to content

Commit 3799a5e

Browse files
committed
fix: address twenty-seventh round of Copilot PR review feedback
- Handle non-preset winners in _reconcile_skills: when the winning layer is core/extension/project-override, restore skills via _unregister_skills so skill-based agents stay consistent with the priority stack - Update base_frontmatter_text on replace layers: when a higher-priority replace layer occurs during composition, update both top and base frontmatter so scripts/agent_scripts inheritance reflects the effective base beneath the top composed layer
1 parent df56d7a commit 3799a5e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/specify_cli/presets.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ def _reconcile_skills(self, command_names: List[str]) -> None:
915915
# Group command names by winning preset to batch _register_skills calls
916916
# while only registering skills for the specific commands being reconciled.
917917
preset_cmds: Dict[str, List[str]] = {}
918+
non_preset_skills: List[str] = []
918919

919920
for cmd_name in command_names:
920921
layers = resolver.collect_all_layers(cmd_name, "command")
@@ -941,11 +942,23 @@ def _reconcile_skills(self, command_names: List[str]) -> None:
941942

942943
top_path = layers[0]["path"]
943944
# Find the preset that owns the winning layer
945+
found_preset = False
944946
for pack_id, _meta in PresetRegistry(self.presets_dir).list_by_priority():
945947
pack_dir = self.presets_dir / pack_id
946948
if top_path.is_relative_to(pack_dir):
947949
preset_cmds.setdefault(pack_id, []).append(cmd_name)
950+
found_preset = True
948951
break
952+
if not found_preset:
953+
# Winner is a non-preset source (core/extension/override).
954+
# Restore skill from that source using _unregister_skills logic.
955+
skill_name, _ = self._skill_names_for_command(cmd_name)
956+
non_preset_skills.append(skill_name)
957+
958+
# Restore skills for commands whose winner is non-preset
959+
if non_preset_skills and skills_dir:
960+
# Use a dummy preset_dir (won't be read for core/extension restore)
961+
self._unregister_skills(non_preset_skills, self.presets_dir)
949962

950963
# Register skills only for the specific commands being reconciled,
951964
# not all commands in each winning preset's manifest.
@@ -2828,10 +2841,11 @@ def _split_frontmatter(text: str) -> tuple:
28282841
fm, layer_body = _split_frontmatter(layer_content)
28292842
layer_content = layer_body
28302843
# Track the highest-priority frontmatter seen;
2831-
# replace layers reset frontmatter (even to None) since
2844+
# replace layers reset both top and base frontmatter since
28322845
# they replace the entire command including metadata.
28332846
if strategy == "replace":
28342847
top_frontmatter_text = fm
2848+
base_frontmatter_text = fm
28352849
elif fm:
28362850
top_frontmatter_text = fm
28372851

0 commit comments

Comments
 (0)