Skip to content

Commit aae4c69

Browse files
committed
feat(cli,config): add /profile and structured-facts settings
Add config for structured facts: - MEMORY_FACTS_ENABLED - MEMORY_FACTS_ALLOWLIST - MEMORY_PROMPT_LIMIT_FACTS Add /profile command to display structured facts for the current user.
1 parent 391474e commit aae4c69

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

src/rune_companion/cli/commands.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import cast
1111

1212
from ..core.state import AppState
13-
from ..memory.api import get_top_room_memories, get_top_user_memories
13+
from ..memory.api import get_top_room_memories, get_top_user_facts, get_top_user_memories
1414
from ..tts.engine import TTSEngine # concrete engine (not the Protocol)
1515

1616
CommandEmitter = Callable[[str], None]
@@ -239,9 +239,35 @@ def cmd_mem(
239239
)
240240

241241

242+
def cmd_profile(
243+
state: AppState,
244+
args: list[str],
245+
user_id: str | None,
246+
room_id: str | None,
247+
emit: CommandEmitter | None = None,
248+
) -> str:
249+
if not user_id:
250+
return "No user_id in this context."
251+
facts = get_top_user_facts(state, user_id, limit=30)
252+
if not facts:
253+
return f"No structured facts stored for user_id={user_id}."
254+
lines = [f"Profile facts for {user_id}:"]
255+
for f in facts:
256+
v = f.value
257+
if isinstance(v, list):
258+
v = ", ".join(str(x) for x in v[:12]) + (", …" if len(v) > 12 else "")
259+
lines.append(f"- {f.key}: {v} (conf={f.confidence:.2f}, src={f.source})")
260+
return "\n".join(lines)
261+
262+
242263
registry.register("help", cmd_help, help_text="Show available commands.", aliases=["h", "?"])
243264
registry.register("status", cmd_status, help_text="Show current settings (mode/history/models).")
244265
registry.register("tts", cmd_tts, help_text="Enable/disable TTS: /tts on | /tts off.")
245266
registry.register(
246267
"mem", cmd_mem, help_text="Memory diagnostics: /mem user | /mem room | /mem stat."
247268
)
269+
registry.register(
270+
"profile",
271+
cmd_profile,
272+
help_text="Show structured profile facts (slots) for the current user.",
273+
)

src/rune_companion/config.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ class Settings:
137137

138138
memory_max_dialog_messages: int
139139

140+
# ---- Structured facts (slots) ----
141+
memory_facts_enabled: bool
142+
memory_facts_allowlist: list[str]
143+
memory_prompt_limit_facts: int
144+
140145
@staticmethod
141146
def from_env() -> Settings:
142147
# App name: accept both RUNE_APP_NAME and RUNE_APP_TITLE for convenience.
@@ -241,6 +246,37 @@ def from_env() -> Settings:
241246
_env_int("MEMORY_MAX_DIALOG_MESSAGES", 80),
242247
)
243248

249+
memory_facts_enabled = _env_bool(
250+
_k("MEMORY_FACTS_ENABLED"),
251+
_env_bool("MEMORY_FACTS_ENABLED", True),
252+
)
253+
254+
memory_facts_allowlist = _env_list(
255+
_k("MEMORY_FACTS_ALLOWLIST"),
256+
_env_list(
257+
"MEMORY_FACTS_ALLOWLIST",
258+
[
259+
"preferred_name",
260+
"age",
261+
"language",
262+
"timezone",
263+
"location",
264+
"pronouns",
265+
"bio",
266+
"goals",
267+
"projects",
268+
"constraints",
269+
"likes",
270+
"dislikes",
271+
],
272+
),
273+
)
274+
275+
memory_prompt_limit_facts = _env_int(
276+
_k("MEMORY_PROMPT_LIMIT_FACTS"),
277+
_env_int("MEMORY_PROMPT_LIMIT_FACTS", 10),
278+
)
279+
244280
return Settings(
245281
app_name=app_name,
246282
log_level=log_level,
@@ -278,6 +314,9 @@ def from_env() -> Settings:
278314
memory_episode_threshold_messages=memory_episode_threshold_messages,
279315
memory_episode_chunk_messages=memory_episode_chunk_messages,
280316
memory_max_dialog_messages=memory_max_dialog_messages,
317+
memory_facts_enabled=memory_facts_enabled,
318+
memory_facts_allowlist=memory_facts_allowlist,
319+
memory_prompt_limit_facts=memory_prompt_limit_facts,
281320
)
282321

283322

@@ -360,3 +399,7 @@ def get_settings() -> Settings:
360399
MEMORY_EPISODE_CHUNK_MESSAGES = SETTINGS.memory_episode_chunk_messages
361400

362401
MEMORY_MAX_DIALOG_MESSAGES = SETTINGS.memory_max_dialog_messages
402+
403+
MEMORY_FACTS_ENABLED = SETTINGS.memory_facts_enabled
404+
MEMORY_FACTS_ALLOWLIST = SETTINGS.memory_facts_allowlist
405+
MEMORY_PROMPT_LIMIT_FACTS = SETTINGS.memory_prompt_limit_facts

0 commit comments

Comments
 (0)