@@ -11,15 +11,13 @@ import {
1111 type TemplateConfig
1212} from "@effect-template/lib/core/domain"
1313import type { SpawnCommand } from "@effect-template/lib/core/spawn-domain"
14- import { runCommandCapture , runCommandExitCode } from "@effect-template/lib/shell/command-runner"
14+ import { runCommandCapture , runCommandExitCode , runCommandWithExitCodes } from "@effect-template/lib/shell/command-runner"
1515import { readProjectConfig } from "@effect-template/lib/shell/config"
1616import { CommandFailedError , SpawnProjectDirError , SpawnSetupError } from "@effect-template/lib/shell/errors"
1717import { createProject } from "@effect-template/lib/usecases/actions"
1818import { findSshPrivateKey } from "@effect-template/lib/usecases/path-helpers"
1919import { getContainerIpIfInsideContainer } from "@effect-template/lib/usecases/projects-core"
2020
21- import { spawnAttachTmux } from "./tmux.js"
22-
2321const SPAWNDOCK_REPO_URL = "https://github.com/SpawnDock/tma-project"
2422const SPAWNDOCK_REPO_REF = "main"
2523
@@ -174,5 +172,22 @@ export const spawnProject = (command: SpawnCommand) =>
174172 }
175173
176174 yield * _ ( Effect . log ( `Project bootstrapped at ${ projectDir } ` ) )
177- yield * _ ( spawnAttachTmux ( template , projectDir , sshKey ) )
175+
176+ yield * _ ( Effect . log ( "Starting opencode directly via SSH..." ) )
177+ yield * _ (
178+ runCommandWithExitCodes (
179+ {
180+ cwd : process . cwd ( ) ,
181+ command : "ssh" ,
182+ args : buildSshArgs (
183+ template ,
184+ sshKey ,
185+ ipAddress ,
186+ `cd '${ projectDir } ' && spawn-dock agent`
187+ ) . filter ( ( arg ) => arg !== "-T" && arg !== "-o" && arg !== "BatchMode=yes" && arg !== "ConnectTimeout=2" && arg !== "ConnectionAttempts=1" )
188+ } ,
189+ [ 0 , 255 ] , // SSH frequently exits with 255 on user disconnect, which is normal
190+ ( exitCode ) => new CommandFailedError ( { command : "ssh agent" , exitCode } )
191+ )
192+ )
178193 } )
0 commit comments