2
0
Fork 0
forked from zynk/zynk

Small AI response header striping fix.

This commit is contained in:
Johannes Findeisen 2026-07-20 00:19:27 +02:00
commit 319d49d439

17
zynk.c
View file

@ -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);