更新远程 skill 为最新版本
(agent_id: str, name: str)
| 169 | |
| 170 | |
| 171 | def update_remote(agent_id: str, name: str) -> bool: |
| 172 | """更新远程 skill 为最新版本""" |
| 173 | if not safe_name(agent_id) or not safe_name(name): |
| 174 | print(f'❌ 错误:agent_id 或 skill 名称含非法字符') |
| 175 | return False |
| 176 | |
| 177 | workspace = OCLAW_HOME / f'workspace-{agent_id}' / 'skills' / name |
| 178 | source_json = workspace / '.source.json' |
| 179 | |
| 180 | if not source_json.exists(): |
| 181 | print(f'❌ 技能不存在或不是远程 skill: {name}') |
| 182 | return False |
| 183 | |
| 184 | try: |
| 185 | source_info = json.loads(source_json.read_text()) |
| 186 | source_url = source_info.get('sourceUrl') |
| 187 | if not source_url: |
| 188 | print(f'❌ 无效的源 URL') |
| 189 | return False |
| 190 | |
| 191 | # 重新下载 |
| 192 | return add_remote(agent_id, name, source_url, source_info.get('description', '')) |
| 193 | except Exception as e: |
| 194 | print(f'❌ 更新失败:{e}') |
| 195 | return False |
| 196 | |
| 197 | |
| 198 | def remove_remote(agent_id: str, name: str) -> bool: |
no test coverage detected