Skip to content

Commit 84f017f

Browse files
authored
Merge pull request #41 from ycexiao/fix-agentify
fix: update the skill name and allow for multiple skills
2 parents e39b803 + 3020f1d commit 84f017f

3 files changed

Lines changed: 54 additions & 18 deletions

File tree

‎news/fix-agentify.rst‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* Update the skill name and allow multiple skills.
20+
21+
**Security:**
22+
23+
* <news item>

‎src/diffpy/apps/app_agentify.py‎

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import socket
33
import subprocess
44
import tempfile
5+
import warnings
56
from pathlib import Path
67

78
REPO_URL = "https://github.com/diffpy/cmi-agent-skills"
8-
DIR_NAME = "cmi-skill"
99

1010

1111
def ensure_setup():
@@ -35,21 +35,31 @@ def agentify(args):
3535
elif agent == "codex":
3636
skills_dir = ".codex/skills"
3737
if system_flag:
38-
destination = Path().home() / skills_dir / DIR_NAME
38+
dest_dir = Path().home() / skills_dir
3939
else:
40-
destination = Path().cwd() / skills_dir / DIR_NAME
41-
if destination.exists() and not args.update:
42-
raise FileExistsError(
43-
f"Agentic skill {DIR_NAME} already exists at {destination}. "
44-
"To overwrite, pass '--update' flag to update the skill"
45-
)
40+
dest_dir = Path().cwd() / skills_dir
4641
with tempfile.TemporaryDirectory() as tmp:
4742
tmp_path = Path(tmp)
4843
subprocess.run(
4944
["git", "clone", REPO_URL, str(tmp_path)],
5045
check=True,
5146
)
52-
if destination.exists():
53-
shutil.rmtree(destination)
54-
shutil.copytree(tmp_path / DIR_NAME, destination, dirs_exist_ok=True)
55-
print(f"Agentic skill {DIR_NAME} has been deployed to {destination}")
47+
for item in tmp_path.iterdir():
48+
if item.is_dir():
49+
destination = dest_dir / item.name
50+
if destination.exists():
51+
if args.update:
52+
shutil.rmtree(destination)
53+
shutil.copytree(item, destination, dirs_exist_ok=True)
54+
print(f"Updated existing skill at {destination}")
55+
else:
56+
warnings.warn(
57+
f"Skill at {destination} already exists. "
58+
"Use '--update' flag to overwrite."
59+
)
60+
continue
61+
else:
62+
shutil.copytree(item, destination, dirs_exist_ok=True)
63+
print(
64+
f"Skill {item.name} has been deployed to {destination}"
65+
)

‎tests/test_agentify.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
update=False,
2929
),
3030
"cwd",
31-
".claude/skills/cmi-skill",
31+
".claude/skills/diffpy-playbook",
3232
),
3333
# C2: diffpy.apps agentify --system
3434
# Deploys system claude skill.
@@ -40,7 +40,7 @@
4040
update=False,
4141
),
4242
"home",
43-
".claude/skills/cmi-skill",
43+
".claude/skills/diffpy-playbook",
4444
),
4545
# C3: diffpy.apps agentify --agent codex
4646
# Deploys workspace codex skill.
@@ -52,7 +52,7 @@
5252
update=False,
5353
),
5454
"cwd",
55-
".codex/skills/cmi-skill",
55+
".codex/skills/diffpy-playbook",
5656
),
5757
# C4: diffpy.apps agentify --agent codex --system
5858
# Deploys system codex skill.
@@ -64,7 +64,7 @@
6464
update=False,
6565
),
6666
"home",
67-
".codex/skills/cmi-skill",
67+
".codex/skills/diffpy-playbook",
6868
),
6969
],
7070
)
@@ -94,14 +94,17 @@ def test_agentify_update():
9494
update=False,
9595
)
9696
agentify(args)
97-
skill_path = Path(tmp) / "cwd" / ".claude" / "skills" / "cmi-skill"
97+
skill_path = (
98+
Path(tmp) / "cwd" / ".claude" / "skills" / "diffpy-playbook"
99+
)
98100
assert skill_path.exists()
99101
args.update = True
100102
agentify(args)
101103
pytest.raises(
102104
FileExistsError,
103105
match=re.escape(
104-
f"Agentic skill cmi-skill already exists at {skill_path}. "
106+
"Agentic skill diffpy-playbook already exists at "
107+
f"{skill_path}. "
105108
"To overwrite, pass '--update' flag to update the skill"
106109
),
107110
)

0 commit comments

Comments
 (0)