style: fix linter formatting issues (gofmt, gofumpt, gci, golines)
This commit is contained in:
parent
2c03492f7d
commit
f59a8009d4
4 changed files with 27 additions and 20 deletions
|
|
@ -181,7 +181,7 @@ func (cb *ContextBuilder) BuildMessages(history []providers.Message, summary str
|
||||||
|
|
||||||
// Log system prompt summary for debugging (debug mode only)
|
// Log system prompt summary for debugging (debug mode only)
|
||||||
logger.DebugCF("agent", "System prompt built",
|
logger.DebugCF("agent", "System prompt built",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"total_chars": len(systemPrompt),
|
"total_chars": len(systemPrompt),
|
||||||
"total_lines": strings.Count(systemPrompt, "\n") + 1,
|
"total_lines": strings.Count(systemPrompt, "\n") + 1,
|
||||||
"section_count": strings.Count(systemPrompt, "\n\n---\n\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)"
|
preview = preview[:500] + "... (truncated)"
|
||||||
}
|
}
|
||||||
logger.DebugCF("agent", "System prompt preview",
|
logger.DebugCF("agent", "System prompt preview",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"preview": preview,
|
"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
|
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 ---
|
// --- INICIO DEL FIX ---
|
||||||
//Diegox-17
|
// Diegox-17
|
||||||
for len(history) > 0 && (history[0].Role == "tool") {
|
for len(history) > 0 && (history[0].Role == "tool") {
|
||||||
logger.DebugCF("agent", "Removing orphaned tool message from history to prevent LLM error",
|
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:]
|
history = history[1:]
|
||||||
}
|
}
|
||||||
//Diegox-17
|
// Diegox-17
|
||||||
// --- FIN DEL FIX ---
|
// --- FIN DEL FIX ---
|
||||||
|
|
||||||
messages = append(messages, providers.Message{
|
messages = append(messages, providers.Message{
|
||||||
|
|
@ -236,7 +236,7 @@ func (cb *ContextBuilder) AddToolResult(messages []providers.Message, toolCallID
|
||||||
return messages
|
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{
|
msg := providers.Message{
|
||||||
Role: "assistant",
|
Role: "assistant",
|
||||||
Content: content,
|
Content: content,
|
||||||
|
|
@ -278,7 +278,7 @@ func (cb *ContextBuilder) loadAIEOSProfile() string {
|
||||||
|
|
||||||
profile, err := aieos.LoadProfile(path)
|
profile, err := aieos.LoadProfile(path)
|
||||||
if err != nil {
|
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,
|
"path": path,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
|
@ -289,13 +289,13 @@ func (cb *ContextBuilder) loadAIEOSProfile() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSkillsInfo returns information about loaded skills.
|
// GetSkillsInfo returns information about loaded skills.
|
||||||
func (cb *ContextBuilder) GetSkillsInfo() map[string]interface{} {
|
func (cb *ContextBuilder) GetSkillsInfo() map[string]any {
|
||||||
allSkills := cb.skillsLoader.ListSkills()
|
allSkills := cb.skillsLoader.ListSkills()
|
||||||
skillNames := make([]string, 0, len(allSkills))
|
skillNames := make([]string, 0, len(allSkills))
|
||||||
for _, s := range allSkills {
|
for _, s := range allSkills {
|
||||||
skillNames = append(skillNames, s.Name)
|
skillNames = append(skillNames, s.Name)
|
||||||
}
|
}
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"total": len(allSkills),
|
"total": len(allSkills),
|
||||||
"available": len(allSkills),
|
"available": len(allSkills),
|
||||||
"names": skillNames,
|
"names": skillNames,
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/sipeed/picoclaw/pkg/aieos"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/sipeed/picoclaw/pkg/aieos"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestIntegration_FullPipeline tests the complete pipeline:
|
// TestIntegration_FullPipeline tests the complete pipeline:
|
||||||
|
|
@ -57,7 +58,7 @@ func TestIntegration_FallbackWhenNoAIEOS(t *testing.T) {
|
||||||
func TestIntegration_FallbackOnInvalidJSON(t *testing.T) {
|
func TestIntegration_FallbackOnInvalidJSON(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
path := filepath.Join(dir, "aieos.json")
|
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))
|
require.True(t, aieos.ProfileExists(dir))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func TestLoadProfile(t *testing.T) {
|
||||||
"neuroticism": 0.1
|
"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)
|
p, err := LoadProfile(path)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -51,7 +51,7 @@ func TestLoadProfileInvalidJSON(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
path := filepath.Join(dir, "aieos.json")
|
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)
|
_, err := LoadProfile(path)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
@ -63,7 +63,7 @@ func TestLoadProfileMissingVersion(t *testing.T) {
|
||||||
path := filepath.Join(dir, "aieos.json")
|
path := filepath.Join(dir, "aieos.json")
|
||||||
|
|
||||||
data := `{"identity": {"name": "Agent"}}`
|
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)
|
_, err := LoadProfile(path)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
@ -75,7 +75,7 @@ func TestLoadProfileMissingName(t *testing.T) {
|
||||||
path := filepath.Join(dir, "aieos.json")
|
path := filepath.Join(dir, "aieos.json")
|
||||||
|
|
||||||
data := `{"version": "1.1", "identity": {}}`
|
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)
|
_, err := LoadProfile(path)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
@ -94,7 +94,7 @@ func TestProfileExists(t *testing.T) {
|
||||||
assert.False(t, ProfileExists(dir))
|
assert.False(t, ProfileExists(dir))
|
||||||
|
|
||||||
path := filepath.Join(dir, "aieos.json")
|
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))
|
assert.True(t, ProfileExists(dir))
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +125,7 @@ func TestLoadProfileOCEANOutOfRange(t *testing.T) {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
path := filepath.Join(dir, "aieos.json")
|
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)
|
_, err := LoadProfile(path)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
@ -139,7 +139,7 @@ func TestLoadProfileOCEANValidBoundary(t *testing.T) {
|
||||||
path := filepath.Join(dir, "aieos.json")
|
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}}`
|
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)
|
p, err := LoadProfile(path)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,13 @@ func renderLinguistics(ling *Linguistics) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ling.Idiolect) > 0 {
|
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"
|
return strings.Join(lines, "\n") + "\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue