Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(memory): recognize notes with CRLF line endings
Afloatd6da38d17645
diff --git a/server/memory-entries.test.ts b/server/memory-entries.test.tsindex 0865ffd38f..95d7946957 100644--- a/server/memory-entries.test.ts+++ b/server/memory-entries.test.ts@@ -1,4 +1,4 @@-import { rmSync, writeFileSync } from "node:fs";+import { readFileSync, rmSync, writeFileSync } from "node:fs";import { join } from "node:path";import { beforeEach, describe, expect, it } from "vitest";@@ -11,14 +11,14 @@ import { ensureWorkspace, loadMemory, memorySystemPrompt, searchMemoryFiles, updconst BOT = "bot-memory-entries";describe("memory entry grammar", () => {- it("parses dates, sources, until marks and strike-throughs", () => {+ it.each(["\n", "\r\n"])("parses dates, sources, until marks and strike-throughs with %j line endings", (newline) => {const text = ["# Memory","- 2026-09-10 · from chat \"Plans\" · Exams this weekend · until 2026-09-14","- 2026-09-11 · ~~Office is in Pune~~ · superseded 2026-09-12","- 2026-09-12 · Office is in Mumbai · updated 2026-09-13","a hand-written line",- ].join("\n");+ ].join(newline);const entries = parseMemoryEntries(text);expect(entries).toHaveLength(3);expect(entries[0]).toMatchObject({ line: 1, date: "2026-09-10", body: "Exams this weekend", until: "2026-09-14", struck: false });@@ -75,8 +75,8 @@ describe("fact identity keeps meaning", () => {expect(factIdentity("- Prefers short replies.")).toBe(factIdentity("Prefers short replies"));});- it("reads a notebook's live facts, ignoring struck ones and entry prefixes", () => {- const notebook = "- 2026-09-10 · from chat \"A\" · Likes tea · until 2026-10-01\n- 2026-09-10 · ~~Lives in Pune~~ · superseded 2026-09-11\n";+ it.each(["\n", "\r\n"])("reads a notebook's live facts with %j line endings, ignoring struck ones and entry prefixes", (newline) => {+ const notebook = ["- 2026-09-10 · from chat \"A\" · Likes tea · until 2026-10-01", "- 2026-09-10 · ~~Lives in Pune~~ · superseded 2026-09-11", ""].join(newline);const ids = notebookIdentities(notebook);expect(ids.has("Likes tea")).toBe(true);expect(ids.has("Lives in Pune")).toBe(false);@@ -120,6 +120,19 @@ describe("memory with until dates and topics, on disk", () => {rmSync(WORKSPACES_DIR, { recursive: true, force: true });});+ it("hides expired Windows-edited notes and their details without rewriting the file", () => {+ ensureWorkspace(BOT);+ const file = join(WORKSPACES_DIR, BOT, "MEMORY.md");+ const kept = ["# Memory", "- 2026-09-12 · Likes tea", " With milk.", ""].join("\r\n");+ const text = [+ "# Memory", "- 2026-09-10 · Exams this weekend · until 2026-09-14", " Bring the timetable.",+ "- 2026-09-12 · Likes tea", " With milk.", "",+ ].join("\r\n");+ writeFileSync(file, text);+ expect(loadMemory(BOT, { now: new Date(2026, 8, 15, 12) })).toMatchObject({ text: kept, expired: 1, truncated: false });+ expect(readFileSync(file, "utf8")).toBe(text);+ });+it("appends an until mark, validates it, and hides the entry after that day", () => {const now = new Date(2026, 8, 10, 12);const ok = updateMemory(BOT, { action: "append", text: "Exams this weekend", until: "2026-09-14" }, { now, source: 'chat "Plans"' });diff --git a/server/memory-entries.ts b/server/memory-entries.tsindex 94f295ad9f..37f037c82b 100644--- a/server/memory-entries.ts+++ b/server/memory-entries.ts@@ -38,7 +38,7 @@ const togglesFence = (line: string) => (line.match(/```/g)?.length ?? 0) % 2 ===/** Undated hand-written lines are not entries and upkeep never touches them. */export function parseMemoryEntries(text: string): MemoryEntryLine[] {const out: MemoryEntryLine[] = [];- const lines = text.split("\n");+ const lines = text.split("\n").map((line) => line.replace(/\r$/, ""));for (let line = 0; line < lines.length;) {const raw = lines[line];const m = DATED.exec(raw);