@@ -2,6 +2,7 @@ import { Either } from "effect"
22
33import { expandContainerHome } from "../usecases/scrap-path.js"
44import { resolveAutoAgentFlags } from "./auto-agent-flags.js"
5+ import { nonEmpty , parseDockerNetworkMode , parseSshPort } from "./command-builders-shared.js"
56import { type RawOptions } from "./command-options.js"
67import {
78 type AgentMode ,
@@ -11,61 +12,14 @@ import {
1112 defaultTemplateConfig ,
1213 deriveRepoPathParts ,
1314 deriveRepoSlug ,
14- isDockerNetworkMode ,
1515 type ParseError ,
1616 resolveRepoInput
1717} from "./domain.js"
1818import { normalizeCpuLimit , normalizeRamLimit } from "./resource-limits.js"
1919import { trimRightChar } from "./strings.js"
2020import { normalizeAuthLabel , normalizeGitTokenLabel } from "./token-labels.js"
2121
22- const parsePort = ( value : string ) : Either . Either < number , ParseError > => {
23- const parsed = Number ( value )
24- if ( ! Number . isInteger ( parsed ) ) {
25- return Either . left ( {
26- _tag : "InvalidOption" ,
27- option : "--ssh-port" ,
28- reason : `expected integer, got: ${ value } `
29- } )
30- }
31- if ( parsed < 1 || parsed > 65_535 ) {
32- return Either . left ( {
33- _tag : "InvalidOption" ,
34- option : "--ssh-port" ,
35- reason : "must be between 1 and 65535"
36- } )
37- }
38- return Either . right ( parsed )
39- }
40-
41- const parseDockerNetworkMode = (
42- value : string | undefined
43- ) : Either . Either < CreateCommand [ "config" ] [ "dockerNetworkMode" ] , ParseError > => {
44- const candidate = value ?. trim ( ) ?? defaultTemplateConfig . dockerNetworkMode
45- if ( isDockerNetworkMode ( candidate ) ) {
46- return Either . right ( candidate )
47- }
48- return Either . left ( {
49- _tag : "InvalidOption" ,
50- option : "--network-mode" ,
51- reason : "expected one of: shared, project"
52- } )
53- }
54-
55- export const nonEmpty = (
56- option : string ,
57- value : string | undefined ,
58- fallback ?: string
59- ) : Either . Either < string , ParseError > => {
60- const candidate = value ?. trim ( ) ?? fallback
61- if ( candidate === undefined || candidate . length === 0 ) {
62- return Either . left ( {
63- _tag : "MissingRequiredOption" ,
64- option
65- } )
66- }
67- return Either . right ( candidate )
68- }
22+ export { nonEmpty } from "./command-builders-shared.js"
6923
7024const normalizeSecretsRoot = ( value : string ) : string => trimRightChar ( value , "/" )
7125
@@ -98,7 +52,7 @@ const resolveRepoBasics = (raw: RawOptions): Either.Either<RepoBasics, ParseErro
9852 nonEmpty ( "--target-dir" , raw . targetDir , defaultTemplateConfig . targetDir )
9953 )
10054 const targetDir = expandContainerHome ( sshUser , rawTargetDir )
101- const sshPort = yield * _ ( parsePort ( raw . sshPort ?? String ( defaultTemplateConfig . sshPort ) ) )
55+ const sshPort = yield * _ ( parseSshPort ( raw . sshPort ?? String ( defaultTemplateConfig . sshPort ) ) )
10256
10357 return { repoUrl, repoSlug, projectSlug, repoPath, repoRef, targetDir, sshUser, sshPort }
10458 } )
@@ -243,13 +197,13 @@ const buildTemplateConfig = ({
243197 claudeAuthLabel,
244198 codexAuthLabel,
245199 cpuLimit,
246- ramLimit,
247200 dockerNetworkMode,
248201 dockerSharedNetworkName,
249202 enableMcpPlaywright,
250203 gitTokenLabel,
251204 names,
252205 paths,
206+ ramLimit,
253207 repo
254208} : BuildTemplateConfigInput ) : CreateCommand [ "config" ] => ( {
255209 containerName : names . containerName ,
0 commit comments