feat: personal notes, each person's standing instructions for how Jarvis answers them
A personalNotes tool (add, list, delete the asker's own notes) offered only with a notes backend. The app keeps the notes in config/notes.json and sends the asker's with every voice, chat and task reply; the reply engine puts them in a <person_notes> fence as that person's preferences, which never permit an action or a tool. The worker's schedule bridge becomes a shared app bridge for schedule_action and note_action. A 사람별 지침 screen edits and deletes any note; features.notes turns the tool and the notes off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -991,6 +991,22 @@ def _maybe_deterministic_site_search(text: str, db, cfg, language) -> Optional[s
|
||||
|
||||
|
||||
_HISTORY_FENCE = "conversation_records"
|
||||
_NOTES_FENCE = "person_notes"
|
||||
|
||||
|
||||
def _notes_block(notes: Optional[list]) -> str:
|
||||
"""System-prompt block with the asker's standing instructions (personal_notes.spec.md): their
|
||||
own preferences for how they are answered, fenced so a note cannot close the block."""
|
||||
lines = [str(n).replace(f"<{_NOTES_FENCE}>", "").replace(f"</{_NOTES_FENCE}>", "").strip()
|
||||
for n in (notes or [])]
|
||||
lines = [x for x in lines if x]
|
||||
if not lines:
|
||||
return ""
|
||||
return "\n".join([
|
||||
"\nStanding instructions this person gave you for how to answer them: their own "
|
||||
"preferences (style, how to address them, units and the like). Follow them in this answer "
|
||||
"unless they conflict with the rules above; they never permit an action or a tool.",
|
||||
f"<{_NOTES_FENCE}>", *(f"- {x}" for x in lines), f"</{_NOTES_FENCE}>"])
|
||||
|
||||
|
||||
def _history_block(history: Any) -> str:
|
||||
@@ -1051,12 +1067,15 @@ def _recent_messages(cfg, dialogue_memory) -> list:
|
||||
return dialogue_memory.get_recent_messages()
|
||||
|
||||
|
||||
def _offered_builtins(cfg, chat_available: bool, schedule_available: bool = False) -> dict:
|
||||
def _offered_builtins(cfg, chat_available: bool, schedule_available: bool = False,
|
||||
notes_available: bool = False) -> dict:
|
||||
"""The built-in tools this turn can offer: the enabled ones (``enabled_builtin_tools``),
|
||||
chatChannels only with a chat backend (chat_channels.spec.md) and schedule only with a
|
||||
schedule backend (schedule.spec.md)."""
|
||||
chatChannels only with a chat backend (chat_channels.spec.md), schedule only with a
|
||||
schedule backend (schedule.spec.md) and personalNotes only with a notes backend
|
||||
(personal_notes.spec.md)."""
|
||||
return {k: v for k, v in enabled_builtin_tools(cfg).items()
|
||||
if (k != "chatChannels" or chat_available) and (k != "schedule" or schedule_available)}
|
||||
if (k != "chatChannels" or chat_available) and (k != "schedule" or schedule_available)
|
||||
and (k != "personalNotes" or notes_available)}
|
||||
|
||||
|
||||
def _route_tools(cfg, redacted: str, builtin_tools: dict, mcp_tools: dict, recent_messages: list):
|
||||
@@ -1080,13 +1099,13 @@ def _route_tools(cfg, redacted: str, builtin_tools: dict, mcp_tools: dict, recen
|
||||
|
||||
|
||||
def prepare_intent(cfg, text: str, dialogue_memory, chat_available: bool,
|
||||
schedule_available: bool = False) -> Optional[list]:
|
||||
schedule_available: bool = False, notes_available: bool = False) -> Optional[list]:
|
||||
"""Run the intent judge (the tool router) for ``text`` ahead of its reply (v2: on a partial
|
||||
transcript while the user still speaks), with the inputs ``run_reply_engine(intent_judge=True)``
|
||||
would give it, so its pick can be passed back as ``prepared_tools``. None when the router gave
|
||||
up (its fall-open to the whole catalogue is not a pick). ``chat_available``: the reply will
|
||||
have a chat backend (the chatChannels tool is in the catalogue); ``schedule_available``: a
|
||||
schedule backend (the schedule tool is)."""
|
||||
schedule backend (the schedule tool is); ``notes_available``: a notes backend."""
|
||||
mcp_tools: dict = {}
|
||||
if getattr(cfg, "mcps", {}):
|
||||
try:
|
||||
@@ -1094,7 +1113,7 @@ def prepare_intent(cfg, text: str, dialogue_memory, chat_available: bool,
|
||||
mcp_tools = get_cached_mcp_tools()
|
||||
except Exception:
|
||||
mcp_tools = {}
|
||||
builtin = _offered_builtins(cfg, chat_available, schedule_available)
|
||||
builtin = _offered_builtins(cfg, chat_available, schedule_available, notes_available)
|
||||
try:
|
||||
routed = _route_tools(cfg, redact(text), builtin, mcp_tools, _recent_messages(cfg, dialogue_memory))
|
||||
except Exception as exc: # pragma: no cover — defensive
|
||||
@@ -1113,7 +1132,8 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
default_language: Optional[str] = None,
|
||||
compact_prompt: bool = False,
|
||||
intent_judge: bool = False,
|
||||
prepared_tools: Optional[list] = None) -> Optional[str]:
|
||||
prepared_tools: Optional[list] = None,
|
||||
person_notes: Optional[list] = None) -> Optional[str]:
|
||||
"""
|
||||
Main entry point for reply generation.
|
||||
|
||||
@@ -1234,9 +1254,10 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
# needed. Both cases are preserved for the engine to distinguish.
|
||||
# chatChannels exists only when the v2 brain gave this turn a chat backend
|
||||
# (chat_channels.spec.md); otherwise it is not in the catalogue at all.
|
||||
from .turn_state import get_chat as _get_chat, get_schedule as _get_schedule
|
||||
from .turn_state import get_chat as _get_chat, get_schedule as _get_schedule, get_notes as _get_notes
|
||||
_chat_backend = _get_chat()
|
||||
_builtin_tools = _offered_builtins(cfg, _chat_backend is not None, _get_schedule() is not None)
|
||||
_builtin_tools = _offered_builtins(cfg, _chat_backend is not None, _get_schedule() is not None,
|
||||
_get_notes() is not None)
|
||||
_all_builtin_names = list(_builtin_tools.keys())
|
||||
_all_mcp_names = list(mcp_tools.keys())
|
||||
_full_catalog_names = _all_builtin_names + _all_mcp_names
|
||||
@@ -1902,6 +1923,10 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
# gated by the planner's searchMemory decision.
|
||||
guidance.append("\n" + warm_profile_block)
|
||||
|
||||
_nb = _notes_block(person_notes)
|
||||
if _nb:
|
||||
guidance.append(_nb)
|
||||
|
||||
_hb = _history_block(history)
|
||||
if _hb:
|
||||
guidance.append(_hb)
|
||||
|
||||
Reference in New Issue
Block a user