Skip to content

Commit ea19023

Browse files
Miyamura80claude
andcommitted
🐛 address PR review feedback on sync_agent_config.py
- Bump `requires-python` in PEP 723 metadata from 3.11 to 3.12 so it matches the repo-wide Python 3.12 requirement. - Enforce `isinstance(meta, dict)` after `yaml.safe_load` so malformed frontmatter yields a clear error instead of AttributeError blocking the pre-commit hook. - Wrap `Path.symlink_to` in try/except for OSError/NotImplementedError so environments without symlink privileges (e.g. Windows without Developer Mode) get an actionable message instead of a raw traceback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f9023e7 commit ea19023

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/sync_agent_config.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# /// script
2-
# requires-python = ">=3.11"
2+
# requires-python = ">=3.12"
33
# dependencies = ["pyyaml>=6.0", "tomli_w>=1.0"]
44
# ///
55
"""Sync Claude ↔ Codex skills and subagents.
@@ -51,6 +51,10 @@ def parse_md(path: Path) -> tuple[dict, str]:
5151
if not m:
5252
raise SystemExit(f"{path}: missing YAML frontmatter")
5353
meta = yaml.safe_load(m.group(1)) or {}
54+
if not isinstance(meta, dict):
55+
raise SystemExit(
56+
f"{path}: frontmatter must be a YAML mapping, got {type(meta).__name__}"
57+
)
5458
return meta, re.sub(r"^(?:\r?\n)+", "", m.group(2))
5559

5660

@@ -147,7 +151,14 @@ def _materialize_symlink(name: str) -> str | None:
147151
f"ERROR: name collision - .claude/skills/{name} is a real directory (Claude-only skill) "
148152
f"but .agents/skills/{name} also exists (shared skill). Resolve by removing one of them."
149153
)
150-
link.symlink_to(target)
154+
try:
155+
link.symlink_to(target)
156+
except (OSError, NotImplementedError) as e:
157+
raise SystemExit(
158+
f"ERROR: could not create symlink {link.relative_to(REPO)} -> {target}: {e}. "
159+
"If you're on Windows, enable Developer Mode or run your shell as Administrator "
160+
"so Python can create symlinks."
161+
) from e
151162
return f"symlinked {link.relative_to(REPO)}"
152163

153164

0 commit comments

Comments
 (0)