git-workspace-service 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -175,7 +175,60 @@ interface CredentialGrant {
175
175
  lastUsedAt?: Date;
176
176
  }
177
177
  type BranchStrategy = 'feature_branch' | 'fork' | 'direct';
178
+ /**
179
+ * Workspace provisioning strategy
180
+ * - 'clone': Full clone of the repository (default)
181
+ * - 'worktree': Git worktree from an existing clone (faster, shared .git)
182
+ */
183
+ type WorkspaceStrategy = 'clone' | 'worktree';
178
184
  type WorkspaceStatus = 'provisioning' | 'ready' | 'in_use' | 'finalizing' | 'cleaned_up' | 'error';
185
+ /**
186
+ * Granular progress phases for workspace operations
187
+ */
188
+ type WorkspacePhase = 'initializing' | 'cloning' | 'creating_branch' | 'configuring' | 'ready' | 'committing' | 'pushing' | 'creating_pr' | 'cleaning_up' | 'done' | 'error';
189
+ /**
190
+ * Progress tracking for workspace operations
191
+ */
192
+ interface WorkspaceProgress {
193
+ /**
194
+ * Current phase of the operation
195
+ */
196
+ phase: WorkspacePhase;
197
+ /**
198
+ * Human-readable message describing current activity
199
+ */
200
+ message?: string;
201
+ /**
202
+ * Progress percentage (0-100) if determinable
203
+ */
204
+ percent?: number;
205
+ /**
206
+ * When progress was last updated
207
+ */
208
+ updatedAt: Date;
209
+ }
210
+ /**
211
+ * Completion hook configuration
212
+ */
213
+ interface CompletionHook {
214
+ /**
215
+ * Shell command to execute on completion
216
+ * Variables available: $WORKSPACE_ID, $REPO, $BRANCH, $STATUS
217
+ */
218
+ command?: string;
219
+ /**
220
+ * Webhook URL to POST to on completion
221
+ */
222
+ webhook?: string;
223
+ /**
224
+ * Custom headers for webhook request
225
+ */
226
+ webhookHeaders?: Record<string, string>;
227
+ /**
228
+ * Whether to run hook on error (default: true)
229
+ */
230
+ runOnError?: boolean;
231
+ }
179
232
  /**
180
233
  * Configuration for provisioning a workspace
181
234
  */
@@ -188,6 +241,16 @@ interface WorkspaceConfig {
188
241
  * Git provider
189
242
  */
190
243
  provider?: GitProvider;
244
+ /**
245
+ * Workspace strategy: 'clone' (default) or 'worktree'
246
+ * Worktrees are faster and use less disk space for parallel work on same repo
247
+ */
248
+ strategy?: WorkspaceStrategy;
249
+ /**
250
+ * Parent workspace ID (required when strategy is 'worktree')
251
+ * The parent must be a 'clone' workspace for the same repo
252
+ */
253
+ parentWorkspace?: string;
191
254
  /**
192
255
  * Branch strategy
193
256
  */
@@ -223,6 +286,10 @@ interface WorkspaceConfig {
223
286
  * If provided, these are used instead of managed credentials
224
287
  */
225
288
  userCredentials?: UserProvidedCredentials;
289
+ /**
290
+ * Hook to run when workspace operations complete
291
+ */
292
+ onComplete?: CompletionHook;
226
293
  }
227
294
  /**
228
295
  * A provisioned git workspace
@@ -256,6 +323,26 @@ interface Workspace {
256
323
  * Current status
257
324
  */
258
325
  status: WorkspaceStatus;
326
+ /**
327
+ * Workspace strategy used ('clone' or 'worktree')
328
+ */
329
+ strategy: WorkspaceStrategy;
330
+ /**
331
+ * Parent workspace ID (for worktrees)
332
+ */
333
+ parentWorkspaceId?: string;
334
+ /**
335
+ * Child worktree IDs (for clone workspaces that have worktrees)
336
+ */
337
+ worktreeIds?: string[];
338
+ /**
339
+ * Current progress of workspace operations
340
+ */
341
+ progress?: WorkspaceProgress;
342
+ /**
343
+ * Completion hook configuration
344
+ */
345
+ onComplete?: CompletionHook;
259
346
  }
260
347
  /**
261
348
  * Options for finalizing a workspace (push, PR creation, cleanup)
@@ -731,7 +818,7 @@ interface GitProviderAdapter {
731
818
  */
732
819
  getDefaultBranch(repo: string, credential: GitCredential): Promise<string>;
733
820
  }
734
- type WorkspaceEventType = 'workspace:provisioning' | 'workspace:ready' | 'workspace:error' | 'workspace:finalizing' | 'workspace:cleaned_up' | 'credential:granted' | 'credential:revoked' | 'pr:created' | 'pr:merged';
821
+ type WorkspaceEventType = 'workspace:provisioning' | 'workspace:ready' | 'workspace:error' | 'workspace:finalizing' | 'workspace:cleaned_up' | 'worktree:added' | 'worktree:removed' | 'credential:granted' | 'credential:revoked' | 'pr:created' | 'pr:merged';
735
822
  interface WorkspaceEvent {
736
823
  type: WorkspaceEventType;
737
824
  workspaceId?: string;
@@ -1103,6 +1190,29 @@ declare class WorkspaceService {
1103
1190
  * Provision a new workspace for a task
1104
1191
  */
1105
1192
  provision(config: WorkspaceConfig): Promise<Workspace>;
1193
+ /**
1194
+ * Add a worktree to an existing clone workspace (convenience method)
1195
+ */
1196
+ addWorktree(parentWorkspaceId: string, options: {
1197
+ branch: string;
1198
+ execution: {
1199
+ id: string;
1200
+ patternName: string;
1201
+ };
1202
+ task: {
1203
+ id: string;
1204
+ role: string;
1205
+ slug?: string;
1206
+ };
1207
+ }): Promise<Workspace>;
1208
+ /**
1209
+ * List all worktrees for a parent workspace
1210
+ */
1211
+ listWorktrees(parentWorkspaceId: string): Workspace[];
1212
+ /**
1213
+ * Remove a worktree (alias for cleanup with worktree-specific handling)
1214
+ */
1215
+ removeWorktree(workspaceId: string): Promise<void>;
1106
1216
  /**
1107
1217
  * Finalize a workspace (push, create PR, cleanup)
1108
1218
  */
@@ -1125,6 +1235,7 @@ declare class WorkspaceService {
1125
1235
  cleanupForExecution(executionId: string): Promise<void>;
1126
1236
  private cloneRepo;
1127
1237
  private createBranch;
1238
+ private addWorktreeFromParent;
1128
1239
  private configureGit;
1129
1240
  private pushBranch;
1130
1241
  private createPullRequest;
@@ -1133,6 +1244,14 @@ declare class WorkspaceService {
1133
1244
  private execInDir;
1134
1245
  private log;
1135
1246
  private emitEvent;
1247
+ /**
1248
+ * Update workspace progress
1249
+ */
1250
+ private updateProgress;
1251
+ /**
1252
+ * Execute completion hook if configured
1253
+ */
1254
+ private executeCompletionHook;
1136
1255
  }
1137
1256
 
1138
1257
  /**
@@ -1515,4 +1634,4 @@ declare function getGitCredentialConfig(helperScriptPath: string): string[];
1515
1634
  */
1516
1635
  declare function outputCredentials(username: string, password: string): void;
1517
1636
 
1518
- export { type AgentPermissions, type AuthPrompt, type AuthPromptEmitter, type AuthResult, type BranchConfig, type BranchInfo, type BranchNamingOptions, type BranchStrategy, type CreateIssueOptions, type CredentialContext, type CredentialGrant, type CredentialGrantStore, type CredentialHelperContext, CredentialService, type CredentialServiceConfig, type CredentialServiceLogger, type CredentialServiceOptions, type CredentialType, DEFAULT_AGENT_PERMISSIONS, DEFAULT_BRANCH_PREFIX, type DeviceCodeResponse, FileTokenStore, type GitCredential, type GitCredentialRequest, type GitHubAppConfig, type GitHubAppInstallation, GitHubPatClient, type GitHubPatClientLogger, type GitHubPatClientOptions, GitHubProvider, type GitHubProviderConfig, type GitHubProviderLogger, type GitProvider, type GitProviderAdapter, type IssueComment, type IssueCommentOptions, type IssueInfo, type IssueState, MemoryTokenStore, OAuthDeviceFlow, type OAuthDeviceFlowConfig, type OAuthDeviceFlowLogger, type OAuthToken, type PermissionLevel, type PullRequestInfo, READONLY_AGENT_PERMISSIONS, type RepositoryScope, type SshCredentials, type TokenCredentials, TokenStore, type TokenStoreOptions, type UserProvidedCredentials, type Workspace, type WorkspaceConfig, type WorkspaceEvent, type WorkspaceEventHandler, type WorkspaceEventType, type WorkspaceFinalization, WorkspaceService, type WorkspaceServiceConfig, type WorkspaceServiceLogger, type WorkspaceServiceOptions, type WorkspaceStatus, cleanupCredentialFiles, configureCredentialHelper, createBranchInfo, createNodeCredentialHelperScript, createShellCredentialHelperScript, filterBranchesByExecution, generateBranchName, generateSlug, getGitCredentialConfig, isManagedBranch, outputCredentials, parseBranchName, updateCredentials };
1637
+ export { type AgentPermissions, type AuthPrompt, type AuthPromptEmitter, type AuthResult, type BranchConfig, type BranchInfo, type BranchNamingOptions, type BranchStrategy, type CompletionHook, type CreateIssueOptions, type CredentialContext, type CredentialGrant, type CredentialGrantStore, type CredentialHelperContext, CredentialService, type CredentialServiceConfig, type CredentialServiceLogger, type CredentialServiceOptions, type CredentialType, DEFAULT_AGENT_PERMISSIONS, DEFAULT_BRANCH_PREFIX, type DeviceCodeResponse, FileTokenStore, type GitCredential, type GitCredentialRequest, type GitHubAppConfig, type GitHubAppInstallation, GitHubPatClient, type GitHubPatClientLogger, type GitHubPatClientOptions, GitHubProvider, type GitHubProviderConfig, type GitHubProviderLogger, type GitProvider, type GitProviderAdapter, type IssueComment, type IssueCommentOptions, type IssueInfo, type IssueState, MemoryTokenStore, OAuthDeviceFlow, type OAuthDeviceFlowConfig, type OAuthDeviceFlowLogger, type OAuthToken, type PermissionLevel, type PullRequestInfo, READONLY_AGENT_PERMISSIONS, type RepositoryScope, type SshCredentials, type TokenCredentials, TokenStore, type TokenStoreOptions, type UserProvidedCredentials, type Workspace, type WorkspaceConfig, type WorkspaceEvent, type WorkspaceEventHandler, type WorkspaceEventType, type WorkspaceFinalization, type WorkspacePhase, type WorkspaceProgress, WorkspaceService, type WorkspaceServiceConfig, type WorkspaceServiceLogger, type WorkspaceServiceOptions, type WorkspaceStatus, type WorkspaceStrategy, cleanupCredentialFiles, configureCredentialHelper, createBranchInfo, createNodeCredentialHelperScript, createShellCredentialHelperScript, filterBranchesByExecution, generateBranchName, generateSlug, getGitCredentialConfig, isManagedBranch, outputCredentials, parseBranchName, updateCredentials };
package/dist/index.d.ts CHANGED
@@ -175,7 +175,60 @@ interface CredentialGrant {
175
175
  lastUsedAt?: Date;
176
176
  }
177
177
  type BranchStrategy = 'feature_branch' | 'fork' | 'direct';
178
+ /**
179
+ * Workspace provisioning strategy
180
+ * - 'clone': Full clone of the repository (default)
181
+ * - 'worktree': Git worktree from an existing clone (faster, shared .git)
182
+ */
183
+ type WorkspaceStrategy = 'clone' | 'worktree';
178
184
  type WorkspaceStatus = 'provisioning' | 'ready' | 'in_use' | 'finalizing' | 'cleaned_up' | 'error';
185
+ /**
186
+ * Granular progress phases for workspace operations
187
+ */
188
+ type WorkspacePhase = 'initializing' | 'cloning' | 'creating_branch' | 'configuring' | 'ready' | 'committing' | 'pushing' | 'creating_pr' | 'cleaning_up' | 'done' | 'error';
189
+ /**
190
+ * Progress tracking for workspace operations
191
+ */
192
+ interface WorkspaceProgress {
193
+ /**
194
+ * Current phase of the operation
195
+ */
196
+ phase: WorkspacePhase;
197
+ /**
198
+ * Human-readable message describing current activity
199
+ */
200
+ message?: string;
201
+ /**
202
+ * Progress percentage (0-100) if determinable
203
+ */
204
+ percent?: number;
205
+ /**
206
+ * When progress was last updated
207
+ */
208
+ updatedAt: Date;
209
+ }
210
+ /**
211
+ * Completion hook configuration
212
+ */
213
+ interface CompletionHook {
214
+ /**
215
+ * Shell command to execute on completion
216
+ * Variables available: $WORKSPACE_ID, $REPO, $BRANCH, $STATUS
217
+ */
218
+ command?: string;
219
+ /**
220
+ * Webhook URL to POST to on completion
221
+ */
222
+ webhook?: string;
223
+ /**
224
+ * Custom headers for webhook request
225
+ */
226
+ webhookHeaders?: Record<string, string>;
227
+ /**
228
+ * Whether to run hook on error (default: true)
229
+ */
230
+ runOnError?: boolean;
231
+ }
179
232
  /**
180
233
  * Configuration for provisioning a workspace
181
234
  */
@@ -188,6 +241,16 @@ interface WorkspaceConfig {
188
241
  * Git provider
189
242
  */
190
243
  provider?: GitProvider;
244
+ /**
245
+ * Workspace strategy: 'clone' (default) or 'worktree'
246
+ * Worktrees are faster and use less disk space for parallel work on same repo
247
+ */
248
+ strategy?: WorkspaceStrategy;
249
+ /**
250
+ * Parent workspace ID (required when strategy is 'worktree')
251
+ * The parent must be a 'clone' workspace for the same repo
252
+ */
253
+ parentWorkspace?: string;
191
254
  /**
192
255
  * Branch strategy
193
256
  */
@@ -223,6 +286,10 @@ interface WorkspaceConfig {
223
286
  * If provided, these are used instead of managed credentials
224
287
  */
225
288
  userCredentials?: UserProvidedCredentials;
289
+ /**
290
+ * Hook to run when workspace operations complete
291
+ */
292
+ onComplete?: CompletionHook;
226
293
  }
227
294
  /**
228
295
  * A provisioned git workspace
@@ -256,6 +323,26 @@ interface Workspace {
256
323
  * Current status
257
324
  */
258
325
  status: WorkspaceStatus;
326
+ /**
327
+ * Workspace strategy used ('clone' or 'worktree')
328
+ */
329
+ strategy: WorkspaceStrategy;
330
+ /**
331
+ * Parent workspace ID (for worktrees)
332
+ */
333
+ parentWorkspaceId?: string;
334
+ /**
335
+ * Child worktree IDs (for clone workspaces that have worktrees)
336
+ */
337
+ worktreeIds?: string[];
338
+ /**
339
+ * Current progress of workspace operations
340
+ */
341
+ progress?: WorkspaceProgress;
342
+ /**
343
+ * Completion hook configuration
344
+ */
345
+ onComplete?: CompletionHook;
259
346
  }
260
347
  /**
261
348
  * Options for finalizing a workspace (push, PR creation, cleanup)
@@ -731,7 +818,7 @@ interface GitProviderAdapter {
731
818
  */
732
819
  getDefaultBranch(repo: string, credential: GitCredential): Promise<string>;
733
820
  }
734
- type WorkspaceEventType = 'workspace:provisioning' | 'workspace:ready' | 'workspace:error' | 'workspace:finalizing' | 'workspace:cleaned_up' | 'credential:granted' | 'credential:revoked' | 'pr:created' | 'pr:merged';
821
+ type WorkspaceEventType = 'workspace:provisioning' | 'workspace:ready' | 'workspace:error' | 'workspace:finalizing' | 'workspace:cleaned_up' | 'worktree:added' | 'worktree:removed' | 'credential:granted' | 'credential:revoked' | 'pr:created' | 'pr:merged';
735
822
  interface WorkspaceEvent {
736
823
  type: WorkspaceEventType;
737
824
  workspaceId?: string;
@@ -1103,6 +1190,29 @@ declare class WorkspaceService {
1103
1190
  * Provision a new workspace for a task
1104
1191
  */
1105
1192
  provision(config: WorkspaceConfig): Promise<Workspace>;
1193
+ /**
1194
+ * Add a worktree to an existing clone workspace (convenience method)
1195
+ */
1196
+ addWorktree(parentWorkspaceId: string, options: {
1197
+ branch: string;
1198
+ execution: {
1199
+ id: string;
1200
+ patternName: string;
1201
+ };
1202
+ task: {
1203
+ id: string;
1204
+ role: string;
1205
+ slug?: string;
1206
+ };
1207
+ }): Promise<Workspace>;
1208
+ /**
1209
+ * List all worktrees for a parent workspace
1210
+ */
1211
+ listWorktrees(parentWorkspaceId: string): Workspace[];
1212
+ /**
1213
+ * Remove a worktree (alias for cleanup with worktree-specific handling)
1214
+ */
1215
+ removeWorktree(workspaceId: string): Promise<void>;
1106
1216
  /**
1107
1217
  * Finalize a workspace (push, create PR, cleanup)
1108
1218
  */
@@ -1125,6 +1235,7 @@ declare class WorkspaceService {
1125
1235
  cleanupForExecution(executionId: string): Promise<void>;
1126
1236
  private cloneRepo;
1127
1237
  private createBranch;
1238
+ private addWorktreeFromParent;
1128
1239
  private configureGit;
1129
1240
  private pushBranch;
1130
1241
  private createPullRequest;
@@ -1133,6 +1244,14 @@ declare class WorkspaceService {
1133
1244
  private execInDir;
1134
1245
  private log;
1135
1246
  private emitEvent;
1247
+ /**
1248
+ * Update workspace progress
1249
+ */
1250
+ private updateProgress;
1251
+ /**
1252
+ * Execute completion hook if configured
1253
+ */
1254
+ private executeCompletionHook;
1136
1255
  }
1137
1256
 
1138
1257
  /**
@@ -1515,4 +1634,4 @@ declare function getGitCredentialConfig(helperScriptPath: string): string[];
1515
1634
  */
1516
1635
  declare function outputCredentials(username: string, password: string): void;
1517
1636
 
1518
- export { type AgentPermissions, type AuthPrompt, type AuthPromptEmitter, type AuthResult, type BranchConfig, type BranchInfo, type BranchNamingOptions, type BranchStrategy, type CreateIssueOptions, type CredentialContext, type CredentialGrant, type CredentialGrantStore, type CredentialHelperContext, CredentialService, type CredentialServiceConfig, type CredentialServiceLogger, type CredentialServiceOptions, type CredentialType, DEFAULT_AGENT_PERMISSIONS, DEFAULT_BRANCH_PREFIX, type DeviceCodeResponse, FileTokenStore, type GitCredential, type GitCredentialRequest, type GitHubAppConfig, type GitHubAppInstallation, GitHubPatClient, type GitHubPatClientLogger, type GitHubPatClientOptions, GitHubProvider, type GitHubProviderConfig, type GitHubProviderLogger, type GitProvider, type GitProviderAdapter, type IssueComment, type IssueCommentOptions, type IssueInfo, type IssueState, MemoryTokenStore, OAuthDeviceFlow, type OAuthDeviceFlowConfig, type OAuthDeviceFlowLogger, type OAuthToken, type PermissionLevel, type PullRequestInfo, READONLY_AGENT_PERMISSIONS, type RepositoryScope, type SshCredentials, type TokenCredentials, TokenStore, type TokenStoreOptions, type UserProvidedCredentials, type Workspace, type WorkspaceConfig, type WorkspaceEvent, type WorkspaceEventHandler, type WorkspaceEventType, type WorkspaceFinalization, WorkspaceService, type WorkspaceServiceConfig, type WorkspaceServiceLogger, type WorkspaceServiceOptions, type WorkspaceStatus, cleanupCredentialFiles, configureCredentialHelper, createBranchInfo, createNodeCredentialHelperScript, createShellCredentialHelperScript, filterBranchesByExecution, generateBranchName, generateSlug, getGitCredentialConfig, isManagedBranch, outputCredentials, parseBranchName, updateCredentials };
1637
+ export { type AgentPermissions, type AuthPrompt, type AuthPromptEmitter, type AuthResult, type BranchConfig, type BranchInfo, type BranchNamingOptions, type BranchStrategy, type CompletionHook, type CreateIssueOptions, type CredentialContext, type CredentialGrant, type CredentialGrantStore, type CredentialHelperContext, CredentialService, type CredentialServiceConfig, type CredentialServiceLogger, type CredentialServiceOptions, type CredentialType, DEFAULT_AGENT_PERMISSIONS, DEFAULT_BRANCH_PREFIX, type DeviceCodeResponse, FileTokenStore, type GitCredential, type GitCredentialRequest, type GitHubAppConfig, type GitHubAppInstallation, GitHubPatClient, type GitHubPatClientLogger, type GitHubPatClientOptions, GitHubProvider, type GitHubProviderConfig, type GitHubProviderLogger, type GitProvider, type GitProviderAdapter, type IssueComment, type IssueCommentOptions, type IssueInfo, type IssueState, MemoryTokenStore, OAuthDeviceFlow, type OAuthDeviceFlowConfig, type OAuthDeviceFlowLogger, type OAuthToken, type PermissionLevel, type PullRequestInfo, READONLY_AGENT_PERMISSIONS, type RepositoryScope, type SshCredentials, type TokenCredentials, TokenStore, type TokenStoreOptions, type UserProvidedCredentials, type Workspace, type WorkspaceConfig, type WorkspaceEvent, type WorkspaceEventHandler, type WorkspaceEventType, type WorkspaceFinalization, type WorkspacePhase, type WorkspaceProgress, WorkspaceService, type WorkspaceServiceConfig, type WorkspaceServiceLogger, type WorkspaceServiceOptions, type WorkspaceStatus, type WorkspaceStrategy, cleanupCredentialFiles, configureCredentialHelper, createBranchInfo, createNodeCredentialHelperScript, createShellCredentialHelperScript, filterBranchesByExecution, generateBranchName, generateSlug, getGitCredentialConfig, isManagedBranch, outputCredentials, parseBranchName, updateCredentials };