Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/app/src/docker-git/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

import * as _9 from "@effect/cli"
import * as _1 from "@effect/cluster"
import * as _2 from "@effect/experimental"
import * as _3 from "@effect/printer"
Expand All @@ -8,15 +9,14 @@ import * as _5 from "@effect/rpc"
import * as _6 from "@effect/sql"
import * as _7 from "@effect/typeclass"
import * as _8 from "@effect/workflow"
import * as _9 from "@effect/cli"

export const _dummyDeps = [_1, _2, _3, _4, _5, _6, _7, _8, _9]

import { NodeContext, NodeRuntime } from "@effect/platform-node"
import { Effect } from "effect"

import { program } from "./program.js"

export const _dummyDeps = [_1, _2, _3, _4, _5, _6, _7, _8, _9]

// CHANGE: run docker-git CLI through the Node runtime
// WHY: ensure platform services (FS, Path, Command) are available in app CLI
// QUOTE(ТЗ): "CLI (отображение, фронт) это app"
Expand Down
47 changes: 30 additions & 17 deletions packages/app/src/docker-git/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,35 @@ const buildSpawnCreateCommand = (outDir: string, force: boolean): CreateCommand
}
}

const spawnAttachDirect = (
template: TemplateConfig,
projectDir: string,
sshKey: string | null,
ipAddress: string | undefined
): Effect.Effect<void, CommandFailedError | PlatformError, CommandExecutor.CommandExecutor> =>
Effect.gen(function*(_) {
yield* _(Effect.log("Starting opencode directly via SSH..."))
yield* _(
runCommandWithExitCodes(
{
cwd: process.cwd(),
command: "ssh",
args: buildSshArgs(
template,
sshKey,
ipAddress,
`cd '${projectDir}' && spawn-dock agent`
).filter((arg) =>
arg !== "-T" && arg !== "-o" && arg !== "BatchMode=yes" && arg !== "ConnectTimeout=2" &&
arg !== "ConnectionAttempts=1"
)
},
[0, 255], // SSH frequently exits with 255 on user disconnect, which is normal
(exitCode) => new CommandFailedError({ command: "ssh agent", exitCode })
)
)
})

// CHANGE: orchestrate spawn-dock spawn — creates container, runs @spawn-dock/create, opens tmux+opencode
// WHY: provide one-command bootstrap from a Telegram bot pairing token
// REF: spawn-command
Expand Down Expand Up @@ -173,21 +202,5 @@ export const spawnProject = (command: SpawnCommand) =>

yield* _(Effect.log(`Project bootstrapped at ${projectDir}`))

yield* _(Effect.log("Starting opencode directly via SSH..."))
yield* _(
runCommandWithExitCodes(
{
cwd: process.cwd(),
command: "ssh",
args: buildSshArgs(
template,
sshKey,
ipAddress,
`cd '${projectDir}' && spawn-dock agent`
).filter((arg) => arg !== "-T" && arg !== "-o" && arg !== "BatchMode=yes" && arg !== "ConnectTimeout=2" && arg !== "ConnectionAttempts=1")
},
[0, 255], // SSH frequently exits with 255 on user disconnect, which is normal
(exitCode) => new CommandFailedError({ command: "ssh agent", exitCode })
)
)
yield* _(spawnAttachDirect(template, projectDir, sshKey, ipAddress))
})