Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Make the closer glyph configurable (DA identity `icon`), so a DA that doesn't use 🗣️ keeps its voice lines and its format gate

Open 0bsolescence opened this issue 3 months ago • 1 comments

What happens

The closer line is what gets spoken (TranscriptParser voiceLinePatterns()) and what FormatGate.hook.ts checks for. Both hardcode the 🗣️ literal (five sites in TranscriptParser, one in FormatGate). A user whose DA closes with a different glyph loses every voice line and fails the format gate on every turn, with no error that names the cause. The 7.40.4 fix for the misnamed-DA case (#1829) made the name configurable and anchored; the glyph next to it is still a constant.

Proposed change (diff attached, against v7.40.4)

  • hooks/lib/identity.ts: add icon to the Identity interface and defaults (default 🗣️), read from DA identity frontmatter (core.icon) with the legacy path covered.
  • TranscriptParser.ts: build one CLOSER_GLYPH alternation from DA_IDENTITY.icon plus the default, regex-escaped, and use it in the three voice-line patterns and the completed pattern. Your #1829 structure (name-anchored first, generic fallback, escapeRe) is untouched; only the literal is parameterised.
  • FormatGate.hook.ts: same alternation for CLOSER.

Both the configured glyph and the default are accepted on purpose: a half-applied icon change (identity updated, prompt not yet) must not blind the parser or fail every turn.

Verified: with icon: 🐦‍⬛ a raven closer and a default closer both match; with no icon set behaviour is byte-identical to 7.40.4.

Reported from the 0bsolescence/LifeOS fork (patch a1a3bec, replayed on patches/v7.40.4). Drafted with AI assistance.

Proposed diff (against v7.40.4)

diff --git a/LifeOS/install/LIFEOS/TOOLS/TranscriptParser.ts b/LifeOS/install/LIFEOS/TOOLS/TranscriptParser.ts
index 5df0cb2..a941365 100755
--- a/LifeOS/install/LIFEOS/TOOLS/TranscriptParser.ts
+++ b/LifeOS/install/LIFEOS/TOOLS/TranscriptParser.ts
@@ -28,12 +28,25 @@ const DA_IDENTITY = getIdentity();
 // generic pattern (any ≤32-char name, colon REQUIRED) is a fallback for the
 // misconfigured-name case only, and never fires when the anchored form matched.
 const escapeRe = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+
+// Fork patch (a1a3bec, replayed onto 7.40.4): the closer glyph is CONFIGURABLE
+// via DA_IDENTITY.icon so an assistant can look like itself (this install uses
+// the raven). Both the configured glyph and the shipped default are accepted —
+// a half-applied icon change must never blind the voice-line parser. Upstream's
+// pattern structure (name-anchored first, generic fallback) is kept as-is; only
+// the glyph literal is parameterised.
+const DEFAULT_CLOSER_GLYPH = '\u{1F5E3}\uFE0F';
+const CLOSER_GLYPH = (() => {
+  const configured = DA_IDENTITY.icon || DEFAULT_CLOSER_GLYPH;
+  const alts = Array.from(new Set([configured, DEFAULT_CLOSER_GLYPH])).map(escapeRe);
+  return `(?:${alts.join('|')})`;
+})();
 function voiceLinePatterns(): RegExp[] {
   const pats: RegExp[] = [];
   if (DA_IDENTITY.name) {
-    pats.push(new RegExp(`🗣️\\s*\\*{0,2}${escapeRe(DA_IDENTITY.name)}:\\*{0,2}\\s*(.+?)(?:\\n|$)`, 'gi'));
+    pats.push(new RegExp(`${CLOSER_GLYPH}\\s*\\*{0,2}${escapeRe(DA_IDENTITY.name)}:\\*{0,2}\\s*(.+?)(?:\\n|$)`, 'gi'));
   }
-  pats.push(new RegExp(`🗣️\\s*\\*{0,2}[^:\\n]{1,32}:\\*{0,2}\\s*(.+?)(?:\\n|$)`, 'gi'));
+  pats.push(new RegExp(`${CLOSER_GLYPH}\\s*\\*{0,2}[^:\\n]{1,32}:\\*{0,2}\\s*(.+?)(?:\\n|$)`, 'gi'));
   return pats;
 }
 
@@ -291,7 +304,7 @@ export function extractStructuredSections(text: string): StructuredResponse {
     results: /✅\s*RESULTS:\s*(.+?)(?:\n|$)/i,
     status: /📊\s*STATUS:\s*(.+?)(?:\n|$)/i,
     next: /➡️\s*NEXT:\s*(.+?)(?:\n|$)/i,
-    completed: new RegExp(`(?:🗣️\\s*[^:\\n]{1,32}:|🎯\\s*COMPLETED:)\\s*(.+?)(?:\\n|$)`, 'i'),
+    completed: new RegExp(`(?:${CLOSER_GLYPH}\\s*[^:\\n]{1,32}:|🎯\\s*COMPLETED:)\\s*(.+?)(?:\\n|$)`, 'i'),
   };
 
   for (const [key, pattern] of Object.entries(patterns)) {
diff --git a/LifeOS/install/hooks/FormatGate.hook.ts b/LifeOS/install/hooks/FormatGate.hook.ts
index 35b76d0..a806598 100755
--- a/LifeOS/install/hooks/FormatGate.hook.ts
+++ b/LifeOS/install/hooks/FormatGate.hook.ts
@@ -36,6 +36,7 @@
  */
 
 import { readHookInput, parseTranscriptFromInput } from "./lib/hook-io";
+import { getIdentity } from "./lib/identity";
 import { appendFileSync, existsSync, mkdirSync } from "fs";
 import { dirname, join } from "path";
 import { homedir } from "node:os";
@@ -73,7 +74,14 @@ function visibleLines(text: string): string[] {
 }
 
 const BANNER = /════\s*LifeOS/;
-const CLOSER = /🗣️/;
+const CLOSER = (() => {
+  const DEFAULT_GLYPH = "\u{1F5E3}\uFE0F";
+  let configured = DEFAULT_GLYPH;
+  try { configured = getIdentity().icon || DEFAULT_GLYPH; } catch { /* config unreadable: fall back */ }
+  const esc = (g: string) => g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+  // Both are accepted: a half-applied icon change must not fail every turn.
+  return new RegExp(`${esc(configured)}|${esc(DEFAULT_GLYPH)}`);
+})();
 const MEMORY_LINE = /🧠\s*MEMORY\s*:/;
 const SYSTEM_LINE = /⚙️?\s*SYSTEM\s*:/;
 
diff --git a/LifeOS/install/hooks/lib/identity.ts b/LifeOS/install/hooks/lib/identity.ts
index 8c98c0c..7448aa0 100755
--- a/LifeOS/install/hooks/lib/identity.ts
+++ b/LifeOS/install/hooks/lib/identity.ts
@@ -48,6 +48,7 @@ const DEFAULT_IDENTITY = {
   displayName: 'LifeOS',
   mainDAVoiceID: '',
   color: '#3B82F6',
+  icon: '\u{1F5E3}\uFE0F',
 };
 
 const DEFAULT_PRINCIPAL = {
@@ -83,6 +84,8 @@ export interface VoicePersonality {
 
 export interface Identity {
   name: string;
+  /** Glyph for the closer line. Configurable so an assistant can look like itself. */
+  icon: string;
   fullName: string;
   displayName: string;
   mainDAVoiceID: string;
@@ -245,6 +248,7 @@ function legacyIdentity(): Identity {
       displayName: daidentity.displayName || daidentity.name || envDA || DEFAULT_IDENTITY.displayName,
       mainDAVoiceID: mainVoiceId || DEFAULT_IDENTITY.mainDAVoiceID,
       color: daidentity.color || DEFAULT_IDENTITY.color,
+      icon: daidentity.icon || DEFAULT_IDENTITY.icon,
       voice: voiceConfig as VoiceProsody | undefined,
       personality: daidentity.personality as VoicePersonality | undefined,
     };
@@ -261,6 +265,7 @@ function legacyIdentity(): Identity {
     displayName: core.display_name || core.name || DEFAULT_IDENTITY.displayName,
     mainDAVoiceID: mainVoice.voice_id || DEFAULT_IDENTITY.mainDAVoiceID,
     color: core.color || DEFAULT_IDENTITY.color,
+    icon: core.icon || DEFAULT_IDENTITY.icon,
     voice: mapFrontmatterVoice(mainVoice),
     personality: mapFrontmatterPersonality(fm.personality?.traits, voice.base_voice),
   };

0bsolescence avatar Aug 29 '26 15:08 0bsolescence

Passing on this one. The closer glyph is the output-format contract across the system prompt and about 28 code sites (FormatGate, DriftReminder, VoiceCompletion, StopGates, the transcript parser, the Hermes soul renderer), so a three-file patch ships half-applied by construction. If per-DA glyphs become a feature it's a prompt-template plus every-parser change, not a constant. Thanks for the writeup.

danielmiessler avatar Sep 03 '26 23:09 danielmiessler