Skip to content

Commit 158d6a7

Browse files
authored
refactor: unify prompt template system and add base branch support (#342)
* adjust default template * remove fix command * adjust default template * x * x
1 parent 558f50c commit 158d6a7

File tree

14 files changed

+71
-366
lines changed

14 files changed

+71
-366
lines changed

CLAUDE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ The system supports various AI instructions triggered through GitHub comments an
103103
**PR Collaboration Instructions:**
104104

105105
- `/continue <instruction>` - Continue development in the PR, supporting custom instructions
106-
- `/fix <description>` - Fix code issues in the PR
107106

108107
**Supported Scenarios:**
109108

docs/codeagent-v0.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ services:
309309

310310
## 扩展功能
311311

312-
- 支持多种触发命令(`/code`, `/fix`, `/refactor`)
312+
- 支持多种触发命令(`/code`, `/continue`)
313313
- 自定义代码生成模板
314314
- 多仓库支持
315315
- 执行历史记录

docs/codeagent-v0.5-en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
### 2. Mode-based Processing System
1616

1717
- **File**: `internal/modes/`
18-
- **TagHandler**: Handles command operations (`/code`, `/continue`, `/fix`)
18+
- **TagHandler**: Handles command operations (`/code`, `/continue`)
1919
- **AgentHandler**: Handles @mention events
2020
- **ReviewHandler**: Automatic PR review
2121
- **BaseHandler**: Unified handler interface and priority management
@@ -87,4 +87,4 @@
8787
- Full MCP tool integration
8888
- Advanced AI model support
8989
- Real-time collaboration features
90-
- Enhanced security and authentication
90+
- Enhanced security and authentication

docs/codeagent-v0.5.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
### 2. 模式化处理系统
1616

1717
- **文件**: `internal/modes/`
18-
- **TagHandler**: 处理命令式操作(`/code`, `/continue`, `/fix`)
18+
- **TagHandler**: 处理命令式操作(`/code`, `/continue`)
1919
- **AgentHandler**: 处理@mention 事件
2020
- **ReviewHandler**: 自动 PR 审查
2121
- **BaseHandler**: 统一的处理器接口和优先级管理
@@ -41,7 +41,7 @@
4141
### 5. MCP (Model Context Protocol) 基础架构
4242

4343
- **文件**: `internal/mcp/`
44-
- **状态**: 基础架构实现,为未来AI工具集成做准备
44+
- **状态**: 基础架构实现,为未来 AI 工具集成做准备
4545
- **manager.go**: MCP 服务器管理框架
4646
- **client.go**: MCP 客户端接口定义
4747
- **servers/github\_\*.go**: GitHub API MCP 服务器模板
@@ -79,7 +79,7 @@
7979
### 10. 统一命令解析
8080

8181
- **文件**: `pkg/models/events.go`
82-
- **支持**: `/code`, `/continue`, `/fix` 命令
82+
- **支持**: `/code`, `/continue` 命令
8383
- **AI 模型参数**: `-claude`, `-gemini` 参数支持
8484

8585
### 11. PR Review 批量处理

internal/context/pr_formatter.go

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,6 @@ func (f *PRFormatter) formatHeader(issueTitle string, issueNumber int) string {
6969
> **Closes #%d** | Auto-generated by CodeAgent 🤖`, issueTitle, issueNumber)
7070
}
7171

72-
// formatIssueContext 格式化Issue上下文
73-
func (f *PRFormatter) formatIssueContext(title, body string) string {
74-
var builder strings.Builder
75-
76-
builder.WriteString("## 📋 Original Issue\n\n")
77-
builder.WriteString(fmt.Sprintf("**Title**: %s\n\n", title))
78-
79-
if body != "" {
80-
// 清理和格式化body
81-
cleanBody := f.cleanIssueBody(body)
82-
if len(cleanBody) > f.maxDescriptionLength {
83-
cleanBody = cleanBody[:f.maxDescriptionLength] + "..."
84-
}
85-
builder.WriteString("**Description**:\n")
86-
builder.WriteString(cleanBody)
87-
}
88-
89-
return builder.String()
90-
}
91-
92-
// formatSummary 格式化摘要(原始版本)
93-
func (f *PRFormatter) formatSummary(summary string) string {
94-
return fmt.Sprintf(`## 🎯 Implementation Summary
95-
96-
%s`, f.formatMarkdownSection(summary))
97-
}
98-
9972
// formatConciseSummary 格式化简洁摘要
10073
func (f *PRFormatter) formatConciseSummary(summary string) string {
10174
// 提取核心描述,避免主观语言
@@ -172,13 +145,6 @@ func (f *PRFormatter) formatConciseSummary(summary string) string {
172145
%s`, concise)
173146
}
174147

175-
// formatChanges 格式化变更详情
176-
func (f *PRFormatter) formatChanges(changes string) string {
177-
return fmt.Sprintf(`## 📝 Changes Made
178-
179-
%s`, f.formatMarkdownSection(changes))
180-
}
181-
182148
// formatConciseChanges 格式化简洁变更
183149
func (f *PRFormatter) formatConciseChanges(changes string) string {
184150
// 提取前3个关键变更点
@@ -212,13 +178,6 @@ func (f *PRFormatter) formatConciseChanges(changes string) string {
212178
return result
213179
}
214180

215-
// formatTestPlan 格式化测试计划
216-
func (f *PRFormatter) formatTestPlan(testPlan string) string {
217-
return fmt.Sprintf(`## 🧪 Testing
218-
219-
%s`, f.formatMarkdownSection(testPlan))
220-
}
221-
222181
// formatTechnicalDetails 格式化技术细节
223182
func (f *PRFormatter) formatTechnicalDetails(aiOutput string) string {
224183
// 提取关键信息
@@ -290,7 +249,6 @@ func (f *PRFormatter) cleanIssueBody(body string) string {
290249
// 移除命令行
291250
body = strings.ReplaceAll(body, "/code", "")
292251
body = strings.ReplaceAll(body, "/continue", "")
293-
body = strings.ReplaceAll(body, "/fix", "")
294252

295253
// 清理多余的空格和空行
296254
body = strings.TrimSpace(body)
@@ -305,43 +263,6 @@ func (f *PRFormatter) cleanIssueBody(body string) string {
305263
return body
306264
}
307265

308-
// extractFromAIOutput 从AI输出中提取summary和changes
309-
func (f *PRFormatter) extractFromAIOutput(aiOutput string) (summary, changes string) {
310-
lines := strings.Split(aiOutput, "\n")
311-
312-
var summaryLines, changesLines []string
313-
currentSection := ""
314-
315-
for _, line := range lines {
316-
trimmed := strings.TrimSpace(line)
317-
318-
// 检测章节标题
319-
if strings.Contains(trimmed, "## 总结") || strings.Contains(trimmed, "## Summary") {
320-
currentSection = "summary"
321-
continue
322-
} else if strings.Contains(trimmed, "## 改动") || strings.Contains(trimmed, "## Changes") ||
323-
strings.Contains(trimmed, "## 修改") || strings.Contains(trimmed, "## 变更") {
324-
currentSection = "changes"
325-
continue
326-
} else if strings.Contains(trimmed, "### ") && currentSection != "" {
327-
// 子章节,继续当前部分
328-
} else if strings.HasPrefix(trimmed, "## ") && currentSection != "" {
329-
// 新的主章节,结束当前部分
330-
currentSection = ""
331-
continue
332-
}
333-
334-
// 收集内容
335-
if currentSection == "summary" && trimmed != "" && !strings.HasPrefix(trimmed, "##") {
336-
summaryLines = append(summaryLines, trimmed)
337-
} else if currentSection == "changes" && trimmed != "" && !strings.HasPrefix(trimmed, "##") {
338-
changesLines = append(changesLines, trimmed)
339-
}
340-
}
341-
342-
return strings.Join(summaryLines, "\n"), strings.Join(changesLines, "\n")
343-
}
344-
345266
// extractKeyPoints 从AI输出中提取关键点
346267
func (f *PRFormatter) extractKeyPoints(aiOutput string) []string {
347268
var points []string

0 commit comments

Comments
 (0)