@@ -10,7 +10,8 @@ type ToolName =
10
10
| 'get_commit_details'
11
11
| 'squash_commits'
12
12
| 'split_branch'
13
- | 'get_branch_changes' ;
13
+ | 'get_branch_changes'
14
+ | 'split_commit' ;
14
15
15
16
export type ToolCall = {
16
17
name : ToolName ;
@@ -193,6 +194,40 @@ function isGetBranchChangesParameters(params: unknown): params is GetBranchChang
193
194
) ;
194
195
}
195
196
197
+ type CommitShard = {
198
+ messageTitle : string ;
199
+ messageBody : string ;
200
+ files : string [ ] ;
201
+ } ;
202
+
203
+ function isCommitShard ( shard : unknown ) : shard is CommitShard {
204
+ return (
205
+ typeof shard === 'object' &&
206
+ shard !== null &&
207
+ typeof ( shard as CommitShard ) . messageTitle === 'string' &&
208
+ typeof ( shard as CommitShard ) . messageBody === 'string' &&
209
+ Array . isArray ( ( shard as CommitShard ) . files ) &&
210
+ ( shard as CommitShard ) . files . every ( ( file ) => typeof file === 'string' )
211
+ ) ;
212
+ }
213
+
214
+ type SplitCommitParameters = {
215
+ sourceStackId : string ;
216
+ sourceCommitId : string ;
217
+ shards : CommitShard [ ] ;
218
+ } ;
219
+
220
+ function isSplitCommitParameters ( params : unknown ) : params is SplitCommitParameters {
221
+ return (
222
+ typeof params === 'object' &&
223
+ params !== null &&
224
+ typeof ( params as SplitCommitParameters ) . sourceStackId === 'string' &&
225
+ typeof ( params as SplitCommitParameters ) . sourceCommitId === 'string' &&
226
+ Array . isArray ( ( params as SplitCommitParameters ) . shards ) &&
227
+ ( params as SplitCommitParameters ) . shards . every ( isCommitShard )
228
+ ) ;
229
+ }
230
+
196
231
interface BaseParsedToolCall {
197
232
name : ToolName ;
198
233
parameters :
@@ -206,6 +241,7 @@ interface BaseParsedToolCall {
206
241
| SquashCommitsToolParams
207
242
| SplitBranchToolParams
208
243
| GetBranchChangesParameters
244
+ | SplitCommitParameters
209
245
| undefined ;
210
246
result : string ;
211
247
isError : boolean ;
@@ -265,6 +301,11 @@ interface ParsedGetBranchChangesToolCall extends BaseParsedToolCall {
265
301
parameters : GetBranchChangesParameters | undefined ;
266
302
}
267
303
304
+ interface ParsedSplitCommitToolCall extends BaseParsedToolCall {
305
+ name : 'split_commit' ;
306
+ parameters : SplitCommitParameters | undefined ;
307
+ }
308
+
268
309
export type ParsedToolCall =
269
310
| ParsedCommitToolCall
270
311
| ParsedCreateBranchToolCall
@@ -275,7 +316,8 @@ export type ParsedToolCall =
275
316
| ParsedGetCommitDetailsToolCall
276
317
| ParsedSquashCommitsToolCall
277
318
| ParsedSplitBranchToolCall
278
- | ParsedGetBranchChangesToolCall ;
319
+ | ParsedGetBranchChangesToolCall
320
+ | ParsedSplitCommitToolCall ;
279
321
280
322
function safeParseJson ( jsonString : string ) : unknown {
281
323
try {
@@ -326,6 +368,8 @@ export function getToolCallIcon(name: ToolName, isError: boolean): IconName {
326
368
}
327
369
328
370
switch ( name ) {
371
+ case 'split_commit' :
372
+ return 'branch-shadow-commit' ;
329
373
case 'commit' :
330
374
return 'commit' ;
331
375
case 'amend' :
@@ -469,5 +513,16 @@ export function parseToolCall(toolCall: ToolCall): ParsedToolCall {
469
513
rawResult
470
514
} ;
471
515
}
516
+ case 'split_commit' : {
517
+ const parameters = isSplitCommitParameters ( rawParams ) ? rawParams : undefined ;
518
+ return {
519
+ name : toolCall . name ,
520
+ parameters,
521
+ result : toolCall . result ,
522
+ isError,
523
+ rawParameters : rawParams ,
524
+ rawResult
525
+ } ;
526
+ }
472
527
}
473
528
}
0 commit comments