@@ -467,10 +467,24 @@ func (a *Agent) ContinuePRFromReviewComment(event *github.PullRequestReviewComme
467
467
468
468
// 4. 构建 prompt,包含评论上下文和命令参数
469
469
var prompt string
470
- commentContext := fmt .Sprintf ("代码行评论:%s\n 文件:%s\n 行号:%d" ,
470
+
471
+ // 获取行范围信息
472
+ startLine := event .Comment .GetStartLine ()
473
+ endLine := event .Comment .GetLine ()
474
+
475
+ var lineRangeInfo string
476
+ if startLine != 0 && endLine != 0 && startLine != endLine {
477
+ // 多行选择
478
+ lineRangeInfo = fmt .Sprintf ("行号范围:%d-%d" , startLine , endLine )
479
+ } else {
480
+ // 单行
481
+ lineRangeInfo = fmt .Sprintf ("行号:%d" , endLine )
482
+ }
483
+
484
+ commentContext := fmt .Sprintf ("代码行评论:%s\n 文件:%s\n %s" ,
471
485
event .Comment .GetBody (),
472
486
event .Comment .GetPath (),
473
- event . Comment . GetLine () )
487
+ lineRangeInfo )
474
488
475
489
if args != "" {
476
490
prompt = fmt .Sprintf ("请根据以下代码行评论和指令继续处理代码:\n \n %s\n \n 指令:%s\n \n 请直接进行相应的修改,回复要简洁明了。" , commentContext , args )
@@ -534,10 +548,24 @@ func (a *Agent) FixPRFromReviewComment(event *github.PullRequestReviewCommentEve
534
548
535
549
// 4. 构建 prompt,包含评论上下文和命令参数
536
550
var prompt string
537
- commentContext := fmt .Sprintf ("代码行评论:%s\n 文件:%s\n 行号:%d" ,
551
+
552
+ // 获取行范围信息
553
+ startLine := event .Comment .GetStartLine ()
554
+ endLine := event .Comment .GetLine ()
555
+
556
+ var lineRangeInfo string
557
+ if startLine != 0 && endLine != 0 && startLine != endLine {
558
+ // 多行选择
559
+ lineRangeInfo = fmt .Sprintf ("行号范围:%d-%d" , startLine , endLine )
560
+ } else {
561
+ // 单行
562
+ lineRangeInfo = fmt .Sprintf ("行号:%d" , endLine )
563
+ }
564
+
565
+ commentContext := fmt .Sprintf ("代码行评论:%s\n 文件:%s\n %s" ,
538
566
event .Comment .GetBody (),
539
567
event .Comment .GetPath (),
540
- event . Comment . GetLine () )
568
+ lineRangeInfo )
541
569
542
570
if args != "" {
543
571
prompt = fmt .Sprintf ("请根据以下代码行评论和指令修复代码问题:\n \n %s\n \n 指令:%s\n \n 请直接进行修复,回复要简洁明了。" , commentContext , args )
0 commit comments