Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions LifeOS/install/LIFEOS/TOOLS/MemoryWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,26 @@ function parseFile(content: string): ParsedFile {
const endIdx = afterFm.indexOf(END_MARKER);

if (beginIdx === -1 || endIdx === -1 || endIdx < beginIdx) {
// Markers missing or malformed — treat as empty entries with the whole
// body as preEntries; this preserves principal content if they edited.
// Self-heal: markers missing or malformed (e.g. a template that shipped
// without a BEGIN marker, or a file where prior writes appended stray END
// markers). Recover every well-formed entry line, drop ALL stray markers,
// preserve the intro text before the first entry, and rebuild a single
// clean BEGIN/END scaffold. Without this, each write compounded corruption.
const recovered: string[] = [];
const introLines: string[] = [];
let sawEntry = false;
for (const line of afterFm.split("\n")) {
const t = line.trim();
if (t === BEGIN_MARKER || t === END_MARKER) continue;
if (PREFIX_PATTERN.test(t)) { recovered.push(t); sawEntry = true; continue; }
if (!sawEntry) introLines.push(line);
}
const intro = introLines.join("\n").replace(/\n+$/, "");
return {
frontmatter,
preEntriesBody: afterFm,
entries: [],
postEntriesBody: "",
preEntriesBody: (intro ? intro + "\n" : "") + BEGIN_MARKER,
entries: recovered,
postEntriesBody: END_MARKER,
};
}

Expand Down
2 changes: 2 additions & 0 deletions LifeOS/install/USER/DIGITAL_ASSISTANT/DA_MEMORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ convention: pai-freshness-v1
> 🎯 SAMPLE TEMPLATE — auto-curated hot-layer memory your DA keeps about how it works with you. Starts empty; the memory reviewer populates it over time. Nothing to fill in manually. Pulse's memory panel reads this file.

<!-- Entries are appended automatically by the memory curation loop. Empty on a fresh install — this is expected. -->
<!-- BEGIN ENTRIES -->
<!-- END ENTRIES -->
2 changes: 2 additions & 0 deletions LifeOS/install/USER/PRINCIPAL/PRINCIPAL_MEMORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ convention: pai-freshness-v1
> 🎯 SAMPLE TEMPLATE — auto-curated hot-layer memory about you. It starts empty and the memory reviewer writes durable facts here as you work with your DA. Nothing to fill in manually. Pulse's memory panel reads this file.

<!-- Entries are appended automatically by the memory curation loop. Empty on a fresh install — this is expected. -->
<!-- BEGIN ENTRIES -->
<!-- END ENTRIES -->