Files
HomerandClaude Fable 5.2 102d68349f Neovim: the four bars — top, bottom, tree, and the right bar with settings lines, chat and prompt
One table of keys binds every action in two forms (the terminal's chords, and keys that always
arrive), and the bottom bar shows the form that works for the bar that has the focus. The prompt
says what Enter will do (ask, rewrite, add; Tab switches in an empty prompt) and carries the
selection or the cursor's line as its attachment. Mode, effort, suggestions, AI on or off and
the bars are remembered per directory with a machine-wide default.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:22 +00:00

57 lines
2.2 KiB
Python

#!/usr/bin/env python3
"""The stand-in agent (tests/fake_agent.py) with one thing more: it keeps the effort it is given.
The shared stand-in answers every effort with `default`. The layout's tests set the effort from
the settings lines and need the answer to say the level that is used, as the LLeMbas CLI does:
a level this "model" offers (low, medium, high, off) is used as asked, and any other is read as
its start level, `medium`. Everything else is the shared stand-in's, run unchanged.
"""
import os
import sys
here = os.path.dirname(os.path.abspath(__file__))
fake = os.path.join(here, "..", "..", "tests", "fake_agent.py")
with open(fake, encoding="utf-8") as f:
source = f.read().rstrip()
if not source.endswith("\nmain()"):
sys.exit("agent_levels: tests/fake_agent.py no longer ends by calling main()")
ns = {"__name__": "fake_agent", "__file__": fake}
exec(compile(source[: -len("main()")], fake, "exec"), ns)
OFFERED = ("off", "low", "medium", "high")
level = {"now": None}
shared_handle, shared_out = ns["handle"], ns["out"]
def taken(asked):
return asked if asked in OFFERED else "medium"
def handle(msg):
params = msg.get("params") if isinstance(msg.get("params"), dict) else {}
if msg.get("method") == "session/new":
asked = (params.get("_meta") or {}).get("effort")
level["now"] = taken(asked) if isinstance(asked, str) else None
if msg.get("method") == "_lembas/configure" and isinstance(params.get("effort"), str):
level["now"] = taken(params["effort"])
return shared_handle(msg)
def out(msg):
# A `model` event says the effort too, as the CLI's does.
event = (msg.get("params") or {}).get("event") if msg.get("method") == "_lembas/event" else None
if level["now"] and isinstance(event, dict) and event.get("type") == "model":
event["effort"] = level["now"]
result = msg.get("result")
if level["now"] and isinstance(result, dict):
if "effort" in result:
result["effort"] = level["now"]
inner = (result.get("_meta") or {}).get("lembas")
if isinstance(inner, dict) and "effort" in inner:
inner["effort"] = level["now"]
shared_out(msg)
ns["handle"], ns["out"] = handle, out
ns["main"]()