Skip to content

Commit a8259a0

Browse files
kevinelliottclaude
andcommitted
fix: resolve all linting issues and Windows CI failures
- Fix errcheck: handle error returns for viper.BindPFlag, Process.Kill, and file operations - Fix duplicate code: extract common BuildAgentPrompt function - Fix deprecated methods: update viewport scroll methods (LineUp→ScrollUp, etc.) - Fix Windows test command: remove multiline syntax that breaks on Windows - Fix formatting: run gofmt and goimports on all Go files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d2d5265 commit a8259a0

8 files changed

Lines changed: 51 additions & 45 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ jobs:
4141
run: go mod download
4242

4343
- name: Run tests
44-
run: |
45-
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
44+
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
4645

4746
- name: Build
4847
run: go build -v ./...

cmd/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ func init() {
3131
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.agentpipe.yaml)")
3232
rootCmd.PersistentFlags().Bool("verbose", false, "Enable verbose output")
3333

34-
_ = viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
34+
if err := viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose")); err != nil {
35+
fmt.Fprintf(os.Stderr, "Error binding verbose flag: %v\n", err)
36+
}
3537
}
3638

3739
func initConfig() {

pkg/adapters/claude.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,7 @@ func (c *ClaudeAgent) formatConversation(messages []agent.Message) string {
142142
}
143143

144144
func (c *ClaudeAgent) buildPrompt(conversation string) string {
145-
var prompt strings.Builder
146-
147-
prompt.WriteString("You are participating in a multi-agent conversation. ")
148-
prompt.WriteString(fmt.Sprintf("Your name is '%s'. ", c.Name))
149-
150-
if c.Config.Prompt != "" {
151-
prompt.WriteString(c.Config.Prompt)
152-
prompt.WriteString("\n\n")
153-
}
154-
155-
prompt.WriteString("Here is the conversation so far:\n\n")
156-
prompt.WriteString(conversation)
157-
prompt.WriteString("\n\nContinue the conversation naturally as ")
158-
prompt.WriteString(c.Name)
159-
prompt.WriteString(". Build on what was just said without repeating previous points. Don't announce that you're joining - just respond directly:")
160-
161-
return prompt.String()
145+
return BuildAgentPrompt(c.Name, c.Config.Prompt, conversation)
162146
}
163147

164148
func init() {

pkg/adapters/common.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package adapters
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
)
7+
8+
// BuildAgentPrompt creates a standard prompt for multi-agent conversations
9+
func BuildAgentPrompt(agentName string, customPrompt string, conversation string) string {
10+
var prompt strings.Builder
11+
12+
prompt.WriteString("You are participating in a multi-agent conversation. ")
13+
prompt.WriteString(fmt.Sprintf("Your name is '%s'. ", agentName))
14+
15+
if customPrompt != "" {
16+
prompt.WriteString(customPrompt)
17+
prompt.WriteString("\n\n")
18+
}
19+
20+
prompt.WriteString("Here is the conversation so far:\n\n")
21+
prompt.WriteString(conversation)
22+
prompt.WriteString("\n\nContinue the conversation naturally as ")
23+
prompt.WriteString(agentName)
24+
prompt.WriteString(". Build on what was just said without repeating previous points. Don't announce that you're joining - just respond directly:")
25+
26+
return prompt.String()
27+
}

pkg/adapters/gemini.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ func (g *GeminiAgent) HealthCheck(ctx context.Context) error {
5757
if err := testCmd.Start(); err != nil {
5858
return fmt.Errorf("gemini CLI cannot be executed: %w", err)
5959
}
60-
_ = testCmd.Process.Kill()
60+
if err := testCmd.Process.Kill(); err != nil {
61+
// Process might have already exited, which is fine
62+
return nil
63+
}
6164
// If we can start it, consider it healthy
6265
return nil
6366
}
@@ -196,23 +199,7 @@ func (g *GeminiAgent) formatConversation(messages []agent.Message) string {
196199
}
197200

198201
func (g *GeminiAgent) buildPrompt(conversation string) string {
199-
var prompt strings.Builder
200-
201-
prompt.WriteString("You are participating in a multi-agent conversation. ")
202-
prompt.WriteString(fmt.Sprintf("Your name is '%s'. ", g.Name))
203-
204-
if g.Config.Prompt != "" {
205-
prompt.WriteString(g.Config.Prompt)
206-
prompt.WriteString("\n\n")
207-
}
208-
209-
prompt.WriteString("Here is the conversation so far:\n\n")
210-
prompt.WriteString(conversation)
211-
prompt.WriteString("\n\nContinue the conversation naturally as ")
212-
prompt.WriteString(g.Name)
213-
prompt.WriteString(". Build on what was just said without repeating previous points. Don't announce that you're joining - just respond directly:")
214-
215-
return prompt.String()
202+
return BuildAgentPrompt(g.Name, g.Config.Prompt, conversation)
216203
}
217204

218205
func init() {

pkg/adapters/qwen.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ func (q *QwenAgent) HealthCheck(ctx context.Context) error {
5858
if err := testCmd.Start(); err != nil {
5959
return fmt.Errorf("qwen CLI cannot be executed: %w", err)
6060
}
61-
_ = testCmd.Process.Kill()
61+
if err := testCmd.Process.Kill(); err != nil {
62+
// Process might have already exited, which is fine
63+
return nil
64+
}
6265
// If we can start it, consider it healthy
6366
return nil
6467
}

pkg/logger/logger.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,12 @@ func (l *ChatLogger) wrapText(text string, indent int) string {
311311

312312
func (l *ChatLogger) writeToFile(content string) {
313313
if l.logFile != nil {
314-
_, _ = l.logFile.WriteString(content)
315-
_ = l.logFile.Sync()
314+
if _, err := l.logFile.WriteString(content); err != nil {
315+
fmt.Fprintf(os.Stderr, "Error writing to log file: %v\n", err)
316+
}
317+
if err := l.logFile.Sync(); err != nil {
318+
fmt.Fprintf(os.Stderr, "Error syncing log file: %v\n", err)
319+
}
316320
}
317321
}
318322

pkg/tui/enhanced.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,24 +224,24 @@ func (m EnhancedModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
224224
if m.activePanel == agentsPanel {
225225
m.agentList, _ = m.agentList.Update(msg)
226226
} else if m.activePanel == conversationPanel {
227-
m.conversation.LineUp(1)
227+
m.conversation.ScrollUp(1)
228228
}
229229

230230
case "down", "j":
231231
if m.activePanel == agentsPanel {
232232
m.agentList, _ = m.agentList.Update(msg)
233233
} else if m.activePanel == conversationPanel {
234-
m.conversation.LineDown(1)
234+
m.conversation.ScrollDown(1)
235235
}
236236

237237
case "pgup":
238238
if m.activePanel == conversationPanel {
239-
m.conversation.HalfViewUp()
239+
m.conversation.HalfPageUp()
240240
}
241241

242242
case "pgdown":
243243
if m.activePanel == conversationPanel {
244-
m.conversation.HalfViewDown()
244+
m.conversation.HalfPageDown()
245245
}
246246
}
247247

0 commit comments

Comments
 (0)