From 319d49d439cd17c6c83c8025fcd6c46683c45d2e Mon Sep 17 00:00:00 2001 From: hanez Date: Mon, 20 Jul 2026 00:19:27 +0200 Subject: [PATCH] Small AI response header striping fix. --- zynk.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/zynk.c b/zynk.c index 6e712fb..bc24a45 100644 --- a/zynk.c +++ b/zynk.c @@ -29,7 +29,7 @@ int asprintf(char **, const char *, ...); /* ---- constants ---- */ -#define VERSION "0.34.3" +#define VERSION "0.34.4" #define DEFAULT_SERVER "irc.libera.chat" #define OPENCODE_BIN "/usr/bin/opencode" #define CLR_RESET "\033[0m" @@ -1314,6 +1314,20 @@ static void strip_formatting(char *s) { *dst = 0; } +static void strip_opencode_header(char *s) { + if (!s || s[0] != '>' || s[1] != ' ') return; + char *sep = strstr(s, " \xc2\xb7 "); + if (!sep) sep = strstr(s, " ยท "); + if (!sep) return; + char *nl = strchr(s, '\n'); + if (nl) { + nl++; + memmove(s, nl, strlen(nl) + 1); + } else { + s[0] = 0; + } +} + /* * has_crlf - Check if a string contains CR or LF characters. * @@ -1658,6 +1672,7 @@ static void ai_child_task(Session *s, long long id, const char *agent) { } else if (olen == 0) { ai_set_answer(id, "AI returned an empty response"); } else { + strip_opencode_header(out); strip_formatting(out); strip_ai_phrases(out); ai_set_answer(id, out);