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:
javis-bot
2026-11-14 17:10:53 +09:00
parent e4b6327cf9
commit a5bd25b86f
32 changed files with 901 additions and 91 deletions

View File

@@ -28,9 +28,10 @@ class FakeBrain:
self.answer = answer
self.calls = []
def reply(self, user, text, history, chat=None, schedule=None, task=False):
def reply(self, user, text, history, chat=None, schedule=None, task=False, notes=None, notes_backend=None):
self.calls.append((user, text, history))
self.chat, self.schedule, self.task = chat, schedule, task
self.notes, self.notes_backend = notes, notes_backend
return self.answer(user, text)
def addressed(self, user, text, names):
@@ -1039,8 +1040,8 @@ def _jarvis_brain(tmp_path, monkeypatch, plans):
monkeypatch.setenv("JARVIS_CONFIG_PATH", str(cfg))
seen = {"judged": [], "prepared": []}
def fake_prepare(cfg, text, mem, chat_available, schedule_available=False):
assert schedule_available # the reply it is made for has the schedule tool
def fake_prepare(cfg, text, mem, chat_available, schedule_available=False, notes_available=False):
assert schedule_available and notes_available # the reply it is made for has these tools
seen["judged"].append((text, chat_available))
return plans.get(text)
@@ -1098,7 +1099,7 @@ def test_a_reply_waits_for_a_pick_still_being_prepared_for_its_text(tmp_path, mo
b, seen = _jarvis_brain(tmp_path, monkeypatch, {})
import jarvis.reply.engine as engine
def slow_prepare(cfg, text, mem, chat_available, schedule_available=False):
def slow_prepare(cfg, text, mem, chat_available, schedule_available=False, notes_available=False):
_time.sleep(0.4)
return plan
monkeypatch.setattr(engine, "prepare_intent", slow_prepare)
@@ -1403,3 +1404,43 @@ def test_a_scheduled_task_runs_with_the_read_only_tools_and_no_mcp(tmp_path, mon
# Only looking things up, and a feature switched off stays off.
assert task == set(brain_mod.TASK_TOOLS) - {"getWeather"} and task_mcps == {}
assert task_mem is not normal_mem # not a turn of their conversation
@pytest.mark.unit
def test_the_askers_notes_from_the_app_reach_the_brain_and_note_actions_go_back(store):
results = []
brain = FakeBrain(lambda u, t: results.append(brain.notes_backend.act("add", text="반말로 해")) or "ok")
async def body(url):
async with connect(url) as ws:
await hello(ws)
await send(ws, type="reply", id="r1", user="100", text="q", via="chat", channel="c1", speak=False,
notes=["섭씨로"])
seen = await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "note_action")
action = seen[-1]
await send(ws, type="note_action_result", id=action["id"], ok=True, item={"id": "3", "text": "반말로 해"})
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "reply_text")
await send(ws, type="reply", id="r2", user="100", text="q", via="voice", speak=False, notes=[1])
seen = await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "error")
return action, seen[-1]
action, error = asyncio.run(with_worker(body, store=store, brain=brain))
assert brain.notes == ["섭씨로"]
assert {k: v for k, v in action.items() if k not in ("type", "id")} == {
"action": "add", "user": "100", "via": "chat", "channel": "c1", "text": "반말로 해"}
assert results == [{"ok": True, "item": {"id": "3", "text": "반말로 해"}}]
assert error["code"] == "bad_message" and error["id"] == "r2"
@pytest.mark.unit
def test_a_scheduled_task_gets_the_persons_notes_but_no_notes_tool(store):
brain = FakeBrain()
async def body(url):
async with connect(url) as ws:
await hello(ws)
await send(ws, type="reply", id="t1", user="100", text="날씨", via="task", notes=["섭씨로"])
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "reply_text")
asyncio.run(with_worker(body, store=store, brain=brain))
assert brain.notes == ["섭씨로"] and brain.notes_backend is None and brain.task is True