Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions news/fix-agentify.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Update the skill name and allow multiple skills.

**Security:**

* <news item>
34 changes: 22 additions & 12 deletions src/diffpy/apps/app_agentify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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}"
)
15 changes: 9 additions & 6 deletions tests/test_agentify.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
update=False,
),
"cwd",
".claude/skills/cmi-skill",
".claude/skills/diffpy-playbook",
),
# C2: diffpy.apps agentify --system
# Deploys system claude skill.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -64,7 +64,7 @@
update=False,
),
"home",
".codex/skills/cmi-skill",
".codex/skills/diffpy-playbook",
),
],
)
Expand Down Expand Up @@ -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"
),
)
Expand Down
Loading