akemon 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context.js +6 -7
- package/package.json +1 -1
package/dist/context.js
CHANGED
|
@@ -43,14 +43,16 @@ function parseConversation(content) {
|
|
|
43
43
|
for (const line of lines) {
|
|
44
44
|
const m = line.match(/^\[(.+?)\] (User|Agent): (.*)$/);
|
|
45
45
|
if (m) {
|
|
46
|
-
// Unescape \\n → newline, \\\\ → backslash
|
|
47
|
-
const content = m[3].replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
|
|
48
46
|
rounds.push({
|
|
49
47
|
ts: m[1],
|
|
50
48
|
role: m[2].toLowerCase(),
|
|
51
|
-
content,
|
|
49
|
+
content: m[3],
|
|
52
50
|
});
|
|
53
51
|
}
|
|
52
|
+
else if (rounds.length > 0 && line !== "") {
|
|
53
|
+
// Continuation line — append to previous round
|
|
54
|
+
rounds[rounds.length - 1].content += "\n" + line;
|
|
55
|
+
}
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
return { summary, rounds };
|
|
@@ -79,10 +81,7 @@ export async function appendRound(workdir, agentName, convId, userMsg, agentMsg)
|
|
|
79
81
|
content = "## Summary\n\n\n## Recent\n";
|
|
80
82
|
}
|
|
81
83
|
const ts = localNow();
|
|
82
|
-
|
|
83
|
-
const safeUser = userMsg.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
|
|
84
|
-
const safeAgent = agentMsg.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
|
|
85
|
-
const entry = `[${ts}] User: ${safeUser}\n[${ts}] Agent: ${safeAgent}\n`;
|
|
84
|
+
const entry = `[${ts}] User: ${userMsg}\n[${ts}] Agent: ${agentMsg}\n`;
|
|
86
85
|
content = content.trimEnd() + "\n" + entry;
|
|
87
86
|
await writeFile(p, content);
|
|
88
87
|
}
|