Sync builtin skills from project skills/ to workspace skills/ on startup.
()
| 303 | |
| 304 | |
| 305 | def _sync_builtin_skills(): |
| 306 | """Sync builtin skills from project skills/ to workspace skills/ on startup.""" |
| 307 | import shutil |
| 308 | try: |
| 309 | workspace = conf().get("agent_workspace", "~/cow") |
| 310 | workspace = os.path.expanduser(workspace) |
| 311 | project_root = os.path.dirname(os.path.abspath(__file__)) |
| 312 | builtin_dir = os.path.join(project_root, "skills") |
| 313 | custom_dir = os.path.join(workspace, "skills") |
| 314 | |
| 315 | if not os.path.isdir(builtin_dir): |
| 316 | return |
| 317 | |
| 318 | os.makedirs(custom_dir, exist_ok=True) |
| 319 | synced = 0 |
| 320 | for name in os.listdir(builtin_dir): |
| 321 | src = os.path.join(builtin_dir, name) |
| 322 | if not os.path.isdir(src) or not os.path.isfile(os.path.join(src, "SKILL.md")): |
| 323 | continue |
| 324 | dst = os.path.join(custom_dir, name) |
| 325 | try: |
| 326 | if os.path.isdir(dst): |
| 327 | shutil.rmtree(dst) |
| 328 | shutil.copytree(src, dst) |
| 329 | synced += 1 |
| 330 | except Exception as e: |
| 331 | logger.warning(f"[App] Failed to sync builtin skill '{name}': {e}") |
| 332 | if synced: |
| 333 | logger.info(f"[App] Synced {synced} builtin skill(s) to workspace") |
| 334 | except Exception as e: |
| 335 | logger.warning(f"[App] Builtin skills sync failed: {e}") |
| 336 | |
| 337 | |
| 338 | def run(): |