Skip to content

Commit b643e1c

Browse files
authored
Merge pull request #102 from Gkrumbach07/bug-fixes
Bug fixes
2 parents 9a8bed4 + 6497b4c commit b643e1c

File tree

19 files changed

+1119
-724
lines changed

19 files changed

+1119
-724
lines changed

components/backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o main .
2121
# Final stage
2222
FROM alpine:latest
2323

24-
RUN apk --no-cache add ca-certificates
24+
RUN apk --no-cache add ca-certificates git
2525
WORKDIR /app
2626

2727
# Copy the binary from builder stage

components/backend/agents.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,28 @@ func getAgentMarkdown(c *gin.Context) {
9393
c.JSON(http.StatusBadRequest, gin.H{"error": "persona required"})
9494
return
9595
}
96+
md, err := renderAgentMarkdownContent(persona)
97+
if err != nil {
98+
if strings.Contains(strings.ToLower(err.Error()), "not found") {
99+
c.JSON(http.StatusNotFound, gin.H{"error": "persona not found"})
100+
return
101+
}
102+
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("failed to render agent markdown: %v", err)})
103+
return
104+
}
105+
c.Data(http.StatusOK, "text/markdown; charset=utf-8", []byte(md))
106+
}
107+
108+
// renderAgentMarkdownContent builds the markdown content for a given agent persona
109+
// by reading its YAML definition from the configured agents directory.
110+
func renderAgentMarkdownContent(persona string) (string, error) {
111+
if strings.TrimSpace(persona) == "" {
112+
return "", fmt.Errorf("persona required")
113+
}
96114
dir := resolveAgentsDir()
97115
agents, err := readAllAgentYAMLs(dir)
98116
if err != nil {
99-
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("failed to read agents: %v", err)})
100-
return
117+
return "", fmt.Errorf("failed to read agents: %w", err)
101118
}
102119
var found *yamlAgent
103120
for i := range agents {
@@ -107,8 +124,7 @@ func getAgentMarkdown(c *gin.Context) {
107124
}
108125
}
109126
if found == nil {
110-
c.JSON(http.StatusNotFound, gin.H{"error": "persona not found"})
111-
return
127+
return "", fmt.Errorf("persona not found")
112128
}
113129
var sb strings.Builder
114130
fmt.Fprintf(&sb, "# %s (%s)\n\n", found.Name, found.Persona)
@@ -124,5 +140,5 @@ func getAgentMarkdown(c *gin.Context) {
124140
if found.SystemMessage != "" {
125141
fmt.Fprintf(&sb, "\n## System message\n\n%s\n", found.SystemMessage)
126142
}
127-
c.Data(http.StatusOK, "text/markdown; charset=utf-8", []byte(sb.String()))
143+
return sb.String(), nil
128144
}

0 commit comments

Comments
 (0)