(self, name: str, command: str)
| 366 | return text or "Clean worktree" |
| 367 | |
| 368 | def run(self, name: str, command: str) -> str: |
| 369 | dangerous = ["rm -rf /", "sudo", "shutdown", "reboot", "> /dev/"] |
| 370 | if any(d in command for d in dangerous): |
| 371 | return "Error: Dangerous command blocked" |
| 372 | |
| 373 | wt = self._find(name) |
| 374 | if not wt: |
| 375 | return f"Error: Unknown worktree '{name}'" |
| 376 | path = Path(wt["path"]) |
| 377 | if not path.exists(): |
| 378 | return f"Error: Worktree path missing: {path}" |
| 379 | |
| 380 | try: |
| 381 | r = subprocess.run( |
| 382 | command, |
| 383 | shell=True, |
| 384 | cwd=path, |
| 385 | capture_output=True, |
| 386 | text=True, |
| 387 | timeout=300, |
| 388 | ) |
| 389 | out = (r.stdout + r.stderr).strip() |
| 390 | return out[:50000] if out else "(no output)" |
| 391 | except subprocess.TimeoutExpired: |
| 392 | return "Error: Timeout (300s)" |
| 393 | |
| 394 | def remove(self, name: str, force: bool = False, complete_task: bool = False) -> str: |
| 395 | wt = self._find(name) |
no test coverage detected