Initial commit from agent

This commit is contained in:
2026-03-24 00:11:34 -05:00
commit 0c777488d3
69 changed files with 4253 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
"""
Terminal control — runs PowerShell and CMD commands via subprocess.
Opens Windows Terminal at a given path.
"""
import subprocess
import os
def run_powershell(command: str, timeout: int = 30) -> dict:
"""Execute a PowerShell command and return stdout/stderr."""
result = subprocess.run(
["powershell", "-ExecutionPolicy", "Bypass", "-NonInteractive", "-Command", command],
capture_output=True, text=True, timeout=timeout
)
return {
"stdout": result.stdout.strip(),
"stderr": result.stderr.strip(),
"returncode": result.returncode
}
def run_cmd(command: str, timeout: int = 30) -> dict:
"""Execute a CMD command."""
result = subprocess.run(
["cmd", "/c", command],
capture_output=True, text=True, timeout=timeout
)
return {
"stdout": result.stdout.strip(),
"stderr": result.stderr.strip(),
"returncode": result.returncode
}
def open_terminal(path: str = None):
"""Open Windows Terminal at the given directory."""
cmd = ["wt"]
if path:
cmd += ["-d", path]
subprocess.Popen(cmd)
def open_vscode(path: str):
"""Open VS Code at a given path."""
subprocess.Popen(["code", path])