35 lines
837 B
PowerShell
35 lines
837 B
PowerShell
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$Server,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[ValidateSet("codex", "claude", "codebuddy", "kimi", "opencode", "qwen", "dsh")]
|
|
[string]$Tool,
|
|
|
|
[string]$Project = ".",
|
|
|
|
[string]$Container = "ai-tools",
|
|
|
|
[string[]]$ToolArguments
|
|
)
|
|
|
|
function ConvertTo-PosixArgument {
|
|
param([string]$Value)
|
|
return "'" + $Value.Replace("'", "'`"'`"'") + "'"
|
|
}
|
|
|
|
if ($Project.StartsWith("/") -or $Project -match "(^|[\\/])\.\.([\\/]|$)") {
|
|
throw "Project must be a path below /workspace."
|
|
}
|
|
|
|
$remoteArguments = @(
|
|
"docker", "exec", "-it",
|
|
"--workdir", "/workspace/$Project",
|
|
$Container,
|
|
$Tool
|
|
) + $ToolArguments
|
|
|
|
$remoteCommand = ($remoteArguments | ForEach-Object { ConvertTo-PosixArgument $_ }) -join " "
|
|
& ssh -tt $Server $remoteCommand
|
|
exit $LASTEXITCODE
|