style: fix linter formatting issues (gofmt, gofumpt, gci, golines)

This commit is contained in:
Edouard CLAUDE 2026-02-24 12:37:50 +04:00
parent 2c03492f7d
commit f59a8009d4
4 changed files with 27 additions and 20 deletions

View file

@ -181,7 +181,7 @@ func (cb *ContextBuilder) BuildMessages(history []providers.Message, summary str
// Log system prompt summary for debugging (debug mode only)
logger.DebugCF("agent", "System prompt built",
map[string]interface{}{
map[string]any{
"total_chars": len(systemPrompt),
"total_lines": strings.Count(systemPrompt, "\n") + 1,
"section_count": strings.Count(systemPrompt, "\n\n---\n\n") + 1,
@ -193,7 +193,7 @@ func (cb *ContextBuilder) BuildMessages(history []providers.Message, summary str
preview = preview[:500] + "... (truncated)"
}
logger.DebugCF("agent", "System prompt preview",
map[string]interface{}{
map[string]any{
"preview": preview,
})
@ -201,15 +201,15 @@ func (cb *ContextBuilder) BuildMessages(history []providers.Message, summary str
systemPrompt += "\n\n## Summary of Previous Conversation\n\n" + summary
}
//This fix prevents the session memory from LLM failure due to elimination of toolu_IDs required from LLM
// This fix prevents the session memory from LLM failure due to elimination of toolu_IDs required from LLM
// --- INICIO DEL FIX ---
//Diegox-17
// Diegox-17
for len(history) > 0 && (history[0].Role == "tool") {
logger.DebugCF("agent", "Removing orphaned tool message from history to prevent LLM error",
map[string]interface{}{"role": history[0].Role})
map[string]any{"role": history[0].Role})
history = history[1:]
}
//Diegox-17
// Diegox-17
// --- FIN DEL FIX ---
messages = append(messages, providers.Message{
@ -236,7 +236,7 @@ func (cb *ContextBuilder) AddToolResult(messages []providers.Message, toolCallID
return messages
}
func (cb *ContextBuilder) AddAssistantMessage(messages []providers.Message, content string, toolCalls []map[string]interface{}) []providers.Message {
func (cb *ContextBuilder) AddAssistantMessage(messages []providers.Message, content string, toolCalls []map[string]any) []providers.Message {
msg := providers.Message{
Role: "assistant",
Content: content,
@ -278,7 +278,7 @@ func (cb *ContextBuilder) loadAIEOSProfile() string {
profile, err := aieos.LoadProfile(path)
if err != nil {
logger.WarnCF("agent", "Failed to load AIEOS profile, falling back to .md files", map[string]interface{}{
logger.WarnCF("agent", "Failed to load AIEOS profile, falling back to .md files", map[string]any{
"path": path,
"error": err.Error(),
})
@ -289,13 +289,13 @@ func (cb *ContextBuilder) loadAIEOSProfile() string {
}
// GetSkillsInfo returns information about loaded skills.
func (cb *ContextBuilder) GetSkillsInfo() map[string]interface{} {
func (cb *ContextBuilder) GetSkillsInfo() map[string]any {
allSkills := cb.skillsLoader.ListSkills()
skillNames := make([]string, 0, len(allSkills))
for _, s := range allSkills {
skillNames = append(skillNames, s.Name)
}
return map[string]interface{}{
return map[string]any{
"total": len(allSkills),
"available": len(allSkills),
"names": skillNames,

View file

@ -6,8 +6,9 @@ import (
"path/filepath"
"testing"
"github.com/sipeed/picoclaw/pkg/aieos"
"github.com/stretchr/testify/require"
"github.com/sipeed/picoclaw/pkg/aieos"
)
// TestIntegration_FullPipeline tests the complete pipeline:
@ -57,7 +58,7 @@ func TestIntegration_FallbackWhenNoAIEOS(t *testing.T) {
func TestIntegration_FallbackOnInvalidJSON(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "aieos.json")
require.NoError(t, os.WriteFile(path, []byte(`{invalid`), 0644))
require.NoError(t, os.WriteFile(path, []byte(`{invalid`), 0o644))
require.True(t, aieos.ProfileExists(dir))

View file

@ -31,7 +31,7 @@ func TestLoadProfile(t *testing.T) {
"neuroticism": 0.1
}
}`
require.NoError(t, os.WriteFile(path, []byte(data), 0644))
require.NoError(t, os.WriteFile(path, []byte(data), 0o644))
p, err := LoadProfile(path)
require.NoError(t, err)
@ -51,7 +51,7 @@ func TestLoadProfileInvalidJSON(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "aieos.json")
require.NoError(t, os.WriteFile(path, []byte(`{bad json`), 0644))
require.NoError(t, os.WriteFile(path, []byte(`{bad json`), 0o644))
_, err := LoadProfile(path)
assert.Error(t, err)
@ -63,7 +63,7 @@ func TestLoadProfileMissingVersion(t *testing.T) {
path := filepath.Join(dir, "aieos.json")
data := `{"identity": {"name": "Agent"}}`
require.NoError(t, os.WriteFile(path, []byte(data), 0644))
require.NoError(t, os.WriteFile(path, []byte(data), 0o644))
_, err := LoadProfile(path)
assert.Error(t, err)
@ -75,7 +75,7 @@ func TestLoadProfileMissingName(t *testing.T) {
path := filepath.Join(dir, "aieos.json")
data := `{"version": "1.1", "identity": {}}`
require.NoError(t, os.WriteFile(path, []byte(data), 0644))
require.NoError(t, os.WriteFile(path, []byte(data), 0o644))
_, err := LoadProfile(path)
assert.Error(t, err)
@ -94,7 +94,7 @@ func TestProfileExists(t *testing.T) {
assert.False(t, ProfileExists(dir))
path := filepath.Join(dir, "aieos.json")
require.NoError(t, os.WriteFile(path, []byte(`{}`), 0644))
require.NoError(t, os.WriteFile(path, []byte(`{}`), 0o644))
assert.True(t, ProfileExists(dir))
}
@ -125,7 +125,7 @@ func TestLoadProfileOCEANOutOfRange(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "aieos.json")
require.NoError(t, os.WriteFile(path, []byte(tt.json), 0644))
require.NoError(t, os.WriteFile(path, []byte(tt.json), 0o644))
_, err := LoadProfile(path)
assert.Error(t, err)
@ -139,7 +139,7 @@ func TestLoadProfileOCEANValidBoundary(t *testing.T) {
path := filepath.Join(dir, "aieos.json")
data := `{"version":"1.1","identity":{"name":"A"},"psychology":{"openness":0.0,"conscientiousness":1.0,"extraversion":0.5,"agreeableness":0.0,"neuroticism":1.0}}`
require.NoError(t, os.WriteFile(path, []byte(data), 0644))
require.NoError(t, os.WriteFile(path, []byte(data), 0o644))
p, err := LoadProfile(path)
require.NoError(t, err)

View file

@ -153,7 +153,13 @@ func renderLinguistics(ling *Linguistics) string {
}
if len(ling.Idiolect) > 0 {
lines = append(lines, fmt.Sprintf("Use these characteristic phrases when appropriate: %s.", strings.Join(ling.Idiolect, ", ")))
lines = append(
lines,
fmt.Sprintf(
"Use these characteristic phrases when appropriate: %s.",
strings.Join(ling.Idiolect, ", "),
),
)
}
return strings.Join(lines, "\n") + "\n"