2323 "claude" : ".claude/skills" ,
2424 "windsurf" : ".windsurf/skills" ,
2525 "cursor" : ".cursor/skills" ,
26- "copilot" : ".github/skills" ,
27- }
28-
29- _EDITOR_EXT = {
30- "claude" : ".md" ,
31- "windsurf" : ".md" ,
32- "cursor" : ".mdc" ,
33- "copilot" : None ,
26+ "copilot" : ".copilot/skills" ,
3427}
3528
3629
@@ -49,55 +42,6 @@ def _fetch_skill(name: str) -> str:
4942 return _get (f"{ _RAW_BASE } /{ name } /SKILL.md" )
5043
5144
52- def _split_frontmatter (content : str ) -> tuple [dict [str , str ], str ]:
53- if not content .startswith ("---" ):
54- return {}, content
55- end = content .index ("---" , 3 )
56- fm : dict [str , str ] = {}
57- for line in content [4 :end ].splitlines ():
58- if ":" in line :
59- k , _ , v = line .partition (":" )
60- fm [k .strip ()] = v .strip ()
61- return fm , content [end + 3 :].lstrip ("\n " )
62-
63-
64- def _cursor_mdc (fm : dict [str , str ], body : str ) -> str :
65- desc = fm .get ("description" , "" )
66- if len (desc ) > 120 :
67- desc = desc [:117 ] + "..."
68- return f"---\n description: { desc } \n globs: \n alwaysApply: false\n ---\n \n { body } "
69-
70-
71- def _copilot_marker (name : str ) -> str :
72- return f"<!-- cex-skill:{ name } -->"
73-
74-
75- def _write_copilot (skills : dict [str , str ], target : Path ) -> None :
76- out = target / ".github" / "skills" / "copilot-instructions.md"
77- out .parent .mkdir (parents = True , exist_ok = True )
78-
79- if out .exists ():
80- text = out .read_text (encoding = "utf-8" )
81- for name , body in skills .items ():
82- marker = _copilot_marker (name )
83- if marker in text :
84- # replace between this marker and the next (or EOF)
85- start = text .index (marker )
86- next_marker = text .find ("<!-- cex-skill:" , start + len (marker ))
87- end = next_marker if next_marker != - 1 else len (text )
88- text = text [:start ] + f"{ marker } \n { body } \n " + text [end :]
89- else :
90- text = text .rstrip ("\n " ) + f"\n \n { marker } \n { body } \n "
91- action = "Updated"
92- else :
93- parts = [f"{ _copilot_marker (n )} \n { b } " for n , b in skills .items ()]
94- text = "\n \n " .join (parts ) + "\n "
95- action = "Created"
96-
97- out .write_text (text , encoding = "utf-8" )
98- print (f" { action } : { out .relative_to (target )} " )
99-
100-
10145def run_init (editor : str , target : Path = Path ("." )) -> None :
10246 print (f"Fetching skills from { _REPO } ({ _BRANCH } )…" , file = sys .stderr )
10347 try :
@@ -111,8 +55,6 @@ def run_init(editor: str, target: Path = Path(".")) -> None:
11155 return
11256
11357 out_dir = target / _EDITOR_DIR [editor ]
114- ext = _EDITOR_EXT [editor ]
115- copilot_skills : dict [str , str ] = {}
11658
11759 for name in names :
11860 print (f" Downloading: { name } " , file = sys .stderr )
@@ -122,22 +64,8 @@ def run_init(editor: str, target: Path = Path(".")) -> None:
12264 print (f" Warning: could not fetch { name } : { exc } " , file = sys .stderr )
12365 continue
12466
125- fm , body = _split_frontmatter (raw )
126-
127- if editor == "copilot" :
128- copilot_skills [name ] = body
129- continue
130-
131- out_dir .mkdir (parents = True , exist_ok = True )
132- dest = out_dir / f"{ name } { ext } "
67+ dest = out_dir / name / "SKILL.md"
68+ dest .parent .mkdir (parents = True , exist_ok = True )
13369 action = "Updated" if dest .exists () else "Created"
134-
135- if editor == "cursor" :
136- dest .write_text (_cursor_mdc (fm , body ), encoding = "utf-8" )
137- else :
138- dest .write_text (raw , encoding = "utf-8" )
139-
70+ dest .write_text (raw , encoding = "utf-8" )
14071 print (f" { action } : { dest .relative_to (target )} " )
141-
142- if editor == "copilot" and copilot_skills :
143- _write_copilot (copilot_skills , target )
0 commit comments