MCPcopy Create free account
hub / github.com/SnailSploit/Claude-Red / process_file

Function process_file

convert_skills.py:130–165  ·  view source on GitHub ↗
(in_path: Path, out_dir: Path, debug: bool = False)

Source from the content-addressed store, hash-verified

128 return '\n'.join(lines)
129
130def process_file(in_path: Path, out_dir: Path, debug: bool = False) -> bool:
131 try:
132 for enc in ['utf-8', 'utf-8-sig', 'latin-1']:
133 try:
134 text = in_path.read_text(encoding=enc)
135 break
136 except UnicodeDecodeError:
137 continue
138 else:
139 return False
140
141 meta = parse_skill(text, in_path)
142
143 if debug:
144 print(f"\n🔍 DEBUG {in_path.name}")
145 print(f" Name: {meta['name']}")
146 print(f" Folder: {meta['folder']}")
147 print(f" Desc: {meta['description'][:120]}...")
148 print(f" Trig: {meta['triggers'][:3]}... ({len(meta['triggers'])} total)")
149 print(f" Src: {meta['source']}")
150 print(f" Body preview: {meta['body'][:100]}...")
151 return True
152
153 yaml_block = build_yaml(meta)
154 final = f"{yaml_block}\n\n{meta['body']}\n"
155
156 out = out_dir / meta['name']
157 out.mkdir(parents=True, exist_ok=True)
158 (out / 'SKILL.md').write_text(final, encoding='utf-8', newline='\n')
159 print(f"✅ {in_path.parent.name:35} → {meta['name']}/SKILL.md (Triggers: {len(meta['triggers'])})")
160 return True
161 except Exception as e:
162 print(f"❌ {in_path.name}: {e}")
163 import traceback
164 traceback.print_exc()
165 return False
166
167def create_zips(conv_dir: Path, zip_dir: Path):
168 zip_dir.mkdir(parents=True, exist_ok=True)

Callers 1

mainFunction · 0.85

Calls 2

parse_skillFunction · 0.85
build_yamlFunction · 0.85

Tested by

no test coverage detected