diff --git a/news/fix-agentify.rst b/news/fix-agentify.rst new file mode 100644 index 0000000..05ecd41 --- /dev/null +++ b/news/fix-agentify.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Update the skill name and allow multiple skills. + +**Security:** + +* diff --git a/src/diffpy/apps/app_agentify.py b/src/diffpy/apps/app_agentify.py index 70d15fb..d9e1fc7 100644 --- a/src/diffpy/apps/app_agentify.py +++ b/src/diffpy/apps/app_agentify.py @@ -2,10 +2,10 @@ import socket import subprocess import tempfile +import warnings from pathlib import Path REPO_URL = "https://github.com/diffpy/cmi-agent-skills" -DIR_NAME = "cmi-skill" def ensure_setup(): @@ -35,21 +35,31 @@ def agentify(args): elif agent == "codex": skills_dir = ".codex/skills" if system_flag: - destination = Path().home() / skills_dir / DIR_NAME + dest_dir = Path().home() / skills_dir else: - destination = Path().cwd() / skills_dir / DIR_NAME - if destination.exists() and not args.update: - raise FileExistsError( - f"Agentic skill {DIR_NAME} already exists at {destination}. " - "To overwrite, pass '--update' flag to update the skill" - ) + dest_dir = Path().cwd() / skills_dir with tempfile.TemporaryDirectory() as tmp: tmp_path = Path(tmp) subprocess.run( ["git", "clone", REPO_URL, str(tmp_path)], check=True, ) - if destination.exists(): - shutil.rmtree(destination) - shutil.copytree(tmp_path / DIR_NAME, destination, dirs_exist_ok=True) - print(f"Agentic skill {DIR_NAME} has been deployed to {destination}") + for item in tmp_path.iterdir(): + if item.is_dir(): + destination = dest_dir / item.name + if destination.exists(): + if args.update: + shutil.rmtree(destination) + shutil.copytree(item, destination, dirs_exist_ok=True) + print(f"Updated existing skill at {destination}") + else: + warnings.warn( + f"Skill at {destination} already exists. " + "Use '--update' flag to overwrite." + ) + continue + else: + shutil.copytree(item, destination, dirs_exist_ok=True) + print( + f"Skill {item.name} has been deployed to {destination}" + ) diff --git a/tests/test_agentify.py b/tests/test_agentify.py index 07e482a..45aa7b3 100644 --- a/tests/test_agentify.py +++ b/tests/test_agentify.py @@ -28,7 +28,7 @@ update=False, ), "cwd", - ".claude/skills/cmi-skill", + ".claude/skills/diffpy-playbook", ), # C2: diffpy.apps agentify --system # Deploys system claude skill. @@ -40,7 +40,7 @@ update=False, ), "home", - ".claude/skills/cmi-skill", + ".claude/skills/diffpy-playbook", ), # C3: diffpy.apps agentify --agent codex # Deploys workspace codex skill. @@ -52,7 +52,7 @@ update=False, ), "cwd", - ".codex/skills/cmi-skill", + ".codex/skills/diffpy-playbook", ), # C4: diffpy.apps agentify --agent codex --system # Deploys system codex skill. @@ -64,7 +64,7 @@ update=False, ), "home", - ".codex/skills/cmi-skill", + ".codex/skills/diffpy-playbook", ), ], ) @@ -94,14 +94,17 @@ def test_agentify_update(): update=False, ) agentify(args) - skill_path = Path(tmp) / "cwd" / ".claude" / "skills" / "cmi-skill" + skill_path = ( + Path(tmp) / "cwd" / ".claude" / "skills" / "diffpy-playbook" + ) assert skill_path.exists() args.update = True agentify(args) pytest.raises( FileExistsError, match=re.escape( - f"Agentic skill cmi-skill already exists at {skill_path}. " + "Agentic skill diffpy-playbook already exists at " + f"{skill_path}. " "To overwrite, pass '--update' flag to update the skill" ), )