@@ -35,6 +35,8 @@ import {
3535 type SourceControlProviderKind ,
3636 type SourceControlWritingStyleSettings ,
3737 type ThreadId ,
38+ type VcsCreateWorktreeInput ,
39+ type VcsCreateWorktreeResult ,
3840} from "@t3tools/contracts" ;
3941import {
4042 hasProjectSettingsOverrides ,
@@ -103,6 +105,10 @@ interface SourceControlTextGenerationSettings {
103105export class GitManager extends Context . Service <
104106 GitManager ,
105107 {
108+ readonly createWorktree : (
109+ input : VcsCreateWorktreeInput ,
110+ options ?: GitVcsDriver . CreateWorktreeOptions ,
111+ ) => Effect . Effect < VcsCreateWorktreeResult , GitCommandError > ;
106112 readonly status : (
107113 input : VcsStatusInput ,
108114 ) => Effect . Effect < VcsStatusResult , GitManagerServiceError > ;
@@ -727,6 +733,19 @@ export const make = Effect.gen(function* () {
727733 ) ;
728734 return resolveProjectSettings ( settings , projectId ) . settings ;
729735 } ) ;
736+ const createWorktree : GitManager [ "Service" ] [ "createWorktree" ] = Effect . fn (
737+ "GitManager.createWorktree" ,
738+ ) ( function * ( input , options ) {
739+ const submodules =
740+ options ?. submodules !== undefined
741+ ? options . submodules
742+ : yield * projectSettingsFor ( input ) . pipe (
743+ Effect . map ( ( settings ) => settings . worktreeSubmodules ) ,
744+ Effect . orElseSucceed ( ( ) => null ) ,
745+ ) ;
746+ return yield * gitCore . createWorktree ( input , { ...options , submodules } ) ;
747+ } ) ;
748+
730749 const readRepositoryInstructions = ( cwd : string , fileName : string ) =>
731750 Effect . gen ( function * ( ) {
732751 const root = yield * fileSystem . realPath ( cwd ) ;
@@ -2849,6 +2868,7 @@ export const make = Effect.gen(function* () {
28492868 ) ;
28502869
28512870 return GitManager . of ( {
2871+ createWorktree,
28522872 localStatus,
28532873 remoteStatus,
28542874 status,
0 commit comments