将项目 scripts/ 目录同步到各 agent workspace(保持 kanban_update.py 等最新) Uses symlinks so that ``__file__`` in workspace copies resolves to the project ``scripts/`` directory, keeping path-derived constants like ``TASKS_FILE`` pointing to the canonical ``data/`` folder.
()
| 256 | |
| 257 | |
| 258 | def sync_scripts_to_workspaces(): |
| 259 | """将项目 scripts/ 目录同步到各 agent workspace(保持 kanban_update.py 等最新) |
| 260 | |
| 261 | Uses symlinks so that ``__file__`` in workspace copies resolves to the |
| 262 | project ``scripts/`` directory, keeping path-derived constants like |
| 263 | ``TASKS_FILE`` pointing to the canonical ``data/`` folder. |
| 264 | """ |
| 265 | scripts_src = BASE / 'scripts' |
| 266 | if not scripts_src.is_dir(): |
| 267 | return |
| 268 | synced = 0 |
| 269 | for proj_name, runtime_id in _SOUL_DEPLOY_MAP.items(): |
| 270 | ws_scripts = OPENCLAW_HOME / f'workspace-{runtime_id}' / 'scripts' |
| 271 | ws_scripts.mkdir(parents=True, exist_ok=True) |
| 272 | for src_file in scripts_src.iterdir(): |
| 273 | if src_file.suffix not in ('.py', '.sh') or src_file.stem.startswith('__'): |
| 274 | continue |
| 275 | dst_file = ws_scripts / src_file.name |
| 276 | try: |
| 277 | if _sync_script_symlink(src_file, dst_file): |
| 278 | synced += 1 |
| 279 | except Exception: |
| 280 | continue |
| 281 | # also sync to workspace-main for legacy compatibility |
| 282 | ws_main_scripts = OPENCLAW_HOME / 'workspace-main' / 'scripts' |
| 283 | ws_main_scripts.mkdir(parents=True, exist_ok=True) |
| 284 | for src_file in scripts_src.iterdir(): |
| 285 | if src_file.suffix not in ('.py', '.sh') or src_file.stem.startswith('__'): |
| 286 | continue |
| 287 | dst_file = ws_main_scripts / src_file.name |
| 288 | try: |
| 289 | if _sync_script_symlink(src_file, dst_file): |
| 290 | synced += 1 |
| 291 | except Exception: |
| 292 | pass |
| 293 | if synced: |
| 294 | log.info(f'{synced} script symlinks synced to workspaces') |
| 295 | |
| 296 | |
| 297 | def deploy_soul_files(): |
no test coverage detected