Skip to content

Commit 14fd312

Browse files
committed
fix: address fourth round of Copilot review feedback
1. Remove unused script_type parameter from _write_integration_json() and all 3 call sites — the parameter was no longer referenced after the update-context script removal. 2. Fix _build_context_section() docstring — correct example path from '.specify/plans/plan.md' to 'specs/<feature>/plan.md'. 3. Improve .mdc frontmatter-only detection in remove_context_section() — use regex to match any YAML frontmatter block (not just the exact Speckit-generated one), so .mdc files with additional frontmatter keys are also cleaned up when no body content remains.
1 parent 2dfefaf commit 14fd312

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,6 @@ def _read_integration_json(project_root: Path) -> dict[str, Any]:
17341734
def _write_integration_json(
17351735
project_root: Path,
17361736
integration_key: str,
1737-
script_type: str,
17381737
) -> None:
17391738
"""Write ``.specify/integration.json`` for *integration_key*."""
17401739
dest = project_root / INTEGRATION_JSON
@@ -1929,7 +1928,7 @@ def integration_install(
19291928
raw_options=integration_options,
19301929
)
19311930
manifest.save()
1932-
_write_integration_json(project_root, integration.key, selected_script)
1931+
_write_integration_json(project_root, integration.key)
19331932
_update_init_options_for_integration(project_root, integration, script_type=selected_script)
19341933

19351934
except Exception as e:
@@ -2212,7 +2211,7 @@ def integration_switch(
22122211
raw_options=integration_options,
22132212
)
22142213
manifest.save()
2215-
_write_integration_json(project_root, target_integration.key, selected_script)
2214+
_write_integration_json(project_root, target_integration.key)
22162215
_update_init_options_for_integration(project_root, target_integration, script_type=selected_script)
22172216

22182217
except Exception as e:
@@ -2320,7 +2319,7 @@ def integration_upgrade(
23202319
raw_options=integration_options,
23212320
)
23222321
new_manifest.save()
2323-
_write_integration_json(project_root, key, selected_script)
2322+
_write_integration_json(project_root, key)
23242323
_update_init_options_for_integration(project_root, integration, script_type=selected_script)
23252324
except Exception as exc:
23262325
# Don't teardown — setup overwrites in-place, so teardown would

src/specify_cli/integrations/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def _build_context_section(plan_path: str = "") -> str:
392392
"""Build the content for the managed section between markers.
393393
394394
*plan_path* is the project-relative path to the current plan
395-
(e.g. ``".specify/plans/plan.md"``). When empty, the section
395+
(e.g. ``"specs/<feature>/plan.md"``). When empty, the section
396396
contains only the generic directive without a concrete path.
397397
"""
398398
lines = [
@@ -506,8 +506,12 @@ def remove_context_section(self, project_root: Path) -> bool:
506506

507507
# For .mdc files, also strip Speckit-generated frontmatter
508508
if ctx_path.suffix == ".mdc":
509-
stripped = normalized.strip()
510-
if stripped in ("", "---\nalwaysApply: true\n---"):
509+
import re
510+
# Treat as empty if only YAML frontmatter remains (no body content)
511+
frontmatter_only = re.match(
512+
r"^---\n.*?\n---\s*$", normalized, re.DOTALL
513+
)
514+
if not normalized.strip() or frontmatter_only:
511515
ctx_path.unlink()
512516
return True
513517

0 commit comments

Comments
 (0)