eustace 2.4.1__tar.gz → 2.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {eustace-2.4.1 → eustace-2.5.0}/PKG-INFO +1 -1
  2. {eustace-2.4.1 → eustace-2.5.0}/cli.py +241 -59
  3. {eustace-2.4.1 → eustace-2.5.0}/eustace.egg-info/PKG-INFO +1 -1
  4. {eustace-2.4.1 → eustace-2.5.0}/eustace.egg-info/SOURCES.txt +1 -0
  5. {eustace-2.4.1 → eustace-2.5.0}/system_prompt.md +15 -13
  6. eustace-2.5.0/tests/test_look.py +624 -0
  7. {eustace-2.4.1 → eustace-2.5.0}/tests/test_screen.py +10 -7
  8. {eustace-2.4.1 → eustace-2.5.0}/README.md +0 -0
  9. {eustace-2.4.1 → eustace-2.5.0}/eustace.egg-info/dependency_links.txt +0 -0
  10. {eustace-2.4.1 → eustace-2.5.0}/eustace.egg-info/entry_points.txt +0 -0
  11. {eustace-2.4.1 → eustace-2.5.0}/eustace.egg-info/requires.txt +0 -0
  12. {eustace-2.4.1 → eustace-2.5.0}/eustace.egg-info/top_level.txt +0 -0
  13. {eustace-2.4.1 → eustace-2.5.0}/fonts/EustaceMono-Regular.ttf +0 -0
  14. {eustace-2.4.1 → eustace-2.5.0}/fonts/OFL.txt +0 -0
  15. {eustace-2.4.1 → eustace-2.5.0}/pyproject.toml +0 -0
  16. {eustace-2.4.1 → eustace-2.5.0}/setup.cfg +0 -0
  17. {eustace-2.4.1 → eustace-2.5.0}/skills/briefing/SKILL.md +0 -0
  18. {eustace-2.4.1 → eustace-2.5.0}/skills/draft-email/SKILL.md +0 -0
  19. {eustace-2.4.1 → eustace-2.5.0}/skills/memo/SKILL.md +0 -0
  20. {eustace-2.4.1 → eustace-2.5.0}/skills/summarize/SKILL.md +0 -0
  21. {eustace-2.4.1 → eustace-2.5.0}/tests/test_agent_loop.py +0 -0
  22. {eustace-2.4.1 → eustace-2.5.0}/tests/test_config.py +0 -0
  23. {eustace-2.4.1 → eustace-2.5.0}/tests/test_email_pdf.py +0 -0
  24. {eustace-2.4.1 → eustace-2.5.0}/tests/test_files.py +0 -0
  25. {eustace-2.4.1 → eustace-2.5.0}/tests/test_guardrails.py +0 -0
  26. {eustace-2.4.1 → eustace-2.5.0}/tests/test_guards.py +0 -0
  27. {eustace-2.4.1 → eustace-2.5.0}/tests/test_guidance.py +0 -0
  28. {eustace-2.4.1 → eustace-2.5.0}/tests/test_log.py +0 -0
  29. {eustace-2.4.1 → eustace-2.5.0}/tests/test_office.py +0 -0
  30. {eustace-2.4.1 → eustace-2.5.0}/tests/test_outlook_setup.py +0 -0
  31. {eustace-2.4.1 → eustace-2.5.0}/tests/test_path_spellings.py +0 -0
  32. {eustace-2.4.1 → eustace-2.5.0}/tests/test_permissions.py +0 -0
  33. {eustace-2.4.1 → eustace-2.5.0}/tests/test_plan.py +0 -0
  34. {eustace-2.4.1 → eustace-2.5.0}/tests/test_pptx.py +0 -0
  35. {eustace-2.4.1 → eustace-2.5.0}/tests/test_sessions.py +0 -0
  36. {eustace-2.4.1 → eustace-2.5.0}/tests/test_skills.py +0 -0
  37. {eustace-2.4.1 → eustace-2.5.0}/tests/test_star.py +0 -0
  38. {eustace-2.4.1 → eustace-2.5.0}/tests/test_ui.py +0 -0
  39. {eustace-2.4.1 → eustace-2.5.0}/tests/test_uninstall.py +0 -0
  40. {eustace-2.4.1 → eustace-2.5.0}/tests/test_update.py +0 -0
  41. {eustace-2.4.1 → eustace-2.5.0}/tests/test_web_search.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eustace
3
- Version: 2.4.1
3
+ Version: 2.5.0
4
4
  Summary: Office-work AI agent for the Windows console: local files, Word, Excel, PowerPoint, PDF, and Outlook
5
5
  Project-URL: Homepage, https://github.com/Colciferr/Eustace
6
6
  Project-URL: Source, https://github.com/Colciferr/Eustace
@@ -44,10 +44,13 @@ from rich.markdown import Markdown
44
44
  from rich.markup import escape
45
45
  from rich.padding import Padding
46
46
  from rich.panel import Panel
47
+ from rich.rule import Rule
48
+ from rich.segment import Segment
49
+ from rich.style import Style
47
50
  from rich.table import Table
48
51
  from rich.text import Text
49
52
 
50
- VERSION = "2.4.1"
53
+ VERSION = "2.5.0"
51
54
 
52
55
  # When output is redirected to a file or pipe, Windows uses the ANSI code page, which cannot encode the symbols
53
56
  # printed here; degrade to "?" instead of crashing mid-turn.
@@ -1853,7 +1856,7 @@ class CLIApprovalHandler:
1853
1856
  title=f"[bold yellow]! Approval Required: {escape(action_title)}[/bold yellow]",
1854
1857
  subtitle=None if interactive else keys,
1855
1858
  border_style="yellow",
1856
- box=box.ROUNDED,
1859
+ box=_panel_box(),
1857
1860
  padding=(0, 1),
1858
1861
  )
1859
1862
  )
@@ -1952,7 +1955,7 @@ class CLIApprovalHandler:
1952
1955
  if more > 0:
1953
1956
  body.append(f"\n ... and {more} more line{'s' if more != 1 else ''} (press V to see every change)", style="dim")
1954
1957
  console.print(Panel(body, title=f"[bold yellow]{head}[/bold yellow]", title_align="left", border_style="yellow",
1955
- box=box.ROUNDED, padding=(0, 1)))
1958
+ box=_panel_box(), padding=(0, 1)))
1956
1959
  if detail_text:
1957
1960
  console.print(f" {detail_text}")
1958
1961
  if target:
@@ -2323,7 +2326,7 @@ def _permission(kind: str, title: str, detail: str = "", diff: str = "", target:
2323
2326
  # CHECKPOINTS (/undo): the bytes of every file a write tool is about to change, saved per turn.
2324
2327
  # ---------------------------------------------------------------------
2325
2328
 
2326
- _TURN = {"id": 0} # incremented at the start of each agent turn
2329
+ _TURN = {"id": 0, "actions": 0, "tokens": 0} # id: incremented at the start of each agent turn
2327
2330
  # What the current request has touched, for the side panel, the result card and /open:
2328
2331
  # "using" = documents read (paths), "changed" = (path, existed before) for every file a write tool was cleared to change.
2329
2332
  _ACTIVITY: dict = {"using": [], "changed": []}
@@ -2608,7 +2611,7 @@ def _print_result_card(turn: int) -> None:
2608
2611
  body.append(" puts everything back", style="dim")
2609
2612
  console.print()
2610
2613
  console.print(Panel(body, title="[bold green]Saved[/bold green]", title_align="left", border_style="green",
2611
- box=box.ROUNDED, padding=(0, 1), expand=False))
2614
+ box=_panel_box(), padding=(0, 1), expand=False))
2612
2615
 
2613
2616
 
2614
2617
  def _pick_result(arg: str) -> str | None:
@@ -6440,7 +6443,7 @@ def propose_plan(summary: str, steps: list[str]) -> str:
6440
6443
  body.append(s)
6441
6444
  console.print()
6442
6445
  console.print(Panel(body, title="[bold cyan]Eustace's plan[/bold cyan]", title_align="left",
6443
- border_style="cyan", box=box.ROUNDED, padding=(0, 1)))
6446
+ border_style="cyan", box=_panel_box(), padding=(0, 1)))
6444
6447
  pending = [{"text": s, "status": "pending"} for s in clean]
6445
6448
  _PLAN_GRANT["turn"] = None # a new plan replaces any earlier one in this request, grant included
6446
6449
 
@@ -6498,7 +6501,7 @@ def update_tasks(tasks: list[dict]) -> str:
6498
6501
  console.print(f" [cyan]❯[/cyan] [dim]{escape(now)}[/dim]") # the side panel holds the whole list
6499
6502
  else:
6500
6503
  console.print(Panel(_render_tasks(clean), title=f"[cyan]Progress {done}/{len(clean)}[/cyan]", title_align="left",
6501
- border_style="dim cyan", box=box.ROUNDED, padding=(0, 1)))
6504
+ border_style="dim cyan", box=_panel_box(), padding=(0, 1)))
6502
6505
  return f"Checklist updated: {done} of {len(clean)} done."
6503
6506
 
6504
6507
 
@@ -6636,8 +6639,9 @@ def ask_user(question: str, options: list[str] | None = None) -> str:
6636
6639
  return "Error: options must be a list of short answers."
6637
6640
  opts = [_clean_line(o, 100) for o in options or [] if str(o).strip()][:MAX_QUESTION_OPTIONS]
6638
6641
  console.print()
6639
- if not _ROUND["named"]:
6640
- # The model asked without saying anything first, so nothing on screen says who is asking
6642
+ if not _ROUND["named"] and SCREEN is None:
6643
+ # The model asked without saying anything first, so nothing on screen says who is asking. (The
6644
+ # full-screen view marks the user's messages instead; anything unmarked is Eustace.)
6641
6645
  console.print(Text(" Eustace", style=f"bold {_accent()}"))
6642
6646
  _ROUND["named"] = True
6643
6647
  if _ui_enabled():
@@ -6821,7 +6825,7 @@ def _load_trusted_agent_md(path: str) -> str | None:
6821
6825
  title=f"[bold yellow]! Untrusted instruction file: {escape(path)}[/bold yellow]",
6822
6826
  subtitle=f"[dim]{len(raw)} bytes | sha256 {digest[:16]}... | will be loaded as system instructions[/dim]",
6823
6827
  border_style="yellow",
6824
- box=box.ROUNDED,
6828
+ box=_panel_box(),
6825
6829
  padding=(0, 1),
6826
6830
  )
6827
6831
  )
@@ -6987,7 +6991,7 @@ def _confirm_skills(pending: list[dict]) -> list[dict]:
6987
6991
  escape(_visible_controls("\n".join(lines))),
6988
6992
  title=f"[bold yellow]! {len(pending)} untrusted skill{'s' if len(pending) != 1 else ''}[/bold yellow]",
6989
6993
  subtitle="[dim]a trusted skill's instructions are followed like AGENT.md; its scripts still ask before running[/dim]",
6990
- border_style="yellow", box=box.ROUNDED, padding=(0, 1),
6994
+ border_style="yellow", box=_panel_box(), padding=(0, 1),
6991
6995
  ))
6992
6996
  console.print(" [bold yellow]Trust which? (a = all, numbers like 1,3, or Enter for none):[/bold yellow] ", end="")
6993
6997
  choice = _typed().strip().lower()
@@ -7280,11 +7284,11 @@ _STAR_BOUNCE = (0, 1, 2, 3, 3, 2, 1, 0) # height index per frame. Out of step
7280
7284
  STAR_FRAME_SECONDS = 0.1 # one frame per wake-up of _StreamWorker's wait loop
7281
7285
  STAR_IDLE = chr(STAR_BASE)
7282
7286
  _STAR: dict = {"on": False, "text": None, "frame": 0, "drawn": 0.0, "plain": False}
7283
- # The full-screen view is drawn for Eustace Mono. In a classic console window with any other font, these seven
7287
+ # The full-screen view is drawn for Eustace Mono. In a classic console window with any other font, these eight
7284
7288
  # characters are missing from the window's font; Windows then borrows them from another font whose lines sit
7285
7289
  # elsewhere in the cell, so a box's rounded corners no longer meet its sides. Each has a stand-in that every
7286
7290
  # console font has had since the DOS character set.
7287
- _PLAIN_SYMBOLS = str.maketrans({"╭": "┌", "╮": "┐", "╰": "└", "╯": "┘", "━": "─", "❯": ">", "✓": "√"})
7291
+ _PLAIN_SYMBOLS = str.maketrans({"╭": "┌", "╮": "┐", "╰": "└", "╯": "┘", "━": "─", "❯": ">", "✓": "√", "▸": ">"})
7288
7292
  _STD_OUTPUT_HANDLE = wintypes.DWORD(-11 & 0xFFFFFFFF)
7289
7293
 
7290
7294
 
@@ -7439,6 +7443,13 @@ def _refresh_star() -> bool:
7439
7443
  return _STAR["on"]
7440
7444
 
7441
7445
 
7446
+ def _panel_box():
7447
+ """The box for a panel: rounded corners in the star font, square ones in a console font that lacks the
7448
+ rounded ones (the full-screen view replaces them as it draws; the classic layout prints straight to the
7449
+ console, so the choice is made here)."""
7450
+ return box.SQUARE if _STAR["plain"] else box.ROUNDED
7451
+
7452
+
7442
7453
  def _sym(text: str) -> str:
7443
7454
  """text as the full-screen view shows it: unchanged in the star font, with plain stand-ins otherwise."""
7444
7455
  return text.translate(_PLAIN_SYMBOLS) if _STAR["plain"] else text
@@ -7511,6 +7522,18 @@ def _request_label(messages: list[dict]) -> str:
7511
7522
  return ""
7512
7523
 
7513
7524
 
7525
+ def _turn_summary(actions: int, seconds: float) -> str:
7526
+ """The line that closes a request in the full-screen view: how many things Eustace did, how many files it
7527
+ read or changed, and how long it ran. Each action is under Ctrl+O; the files are in the side panel."""
7528
+ files = len({os.path.normcase(str(u)) for u in _ACTIVITY["using"]} | {os.path.normcase(p) for p, _ in _ACTIVITY["changed"]})
7529
+ seconds = int(round(seconds))
7530
+ took = f"{seconds}s" if seconds < 60 else f"{seconds // 60}m {seconds % 60:02d}s"
7531
+ parts = [f"{actions} action{'' if actions == 1 else 's'}"]
7532
+ if files:
7533
+ parts.append(f"{files} file{'' if files == 1 else 's'}")
7534
+ return "▸ " + " · ".join(parts + [took])
7535
+
7536
+
7514
7537
  def run_agent_turn(messages: list[dict], request: str | None = None):
7515
7538
  """Streams responses & tool calls with instant ESC or Ctrl+C cancellation. `request` is what the user typed,
7516
7539
  used to name this turn's file changes in /undo (default: the latest user message)."""
@@ -7522,6 +7545,8 @@ def run_agent_turn(messages: list[dict], request: str | None = None):
7522
7545
  _TURN["request"] = _clean_line(request if request is not None else _request_label(messages), 200)
7523
7546
  _PLAN_GRANT["turn"] = None
7524
7547
  _ACTIVITY.update(using=[], changed=[])
7548
+ _TURN["actions"] = 0
7549
+ started = time.monotonic()
7525
7550
 
7526
7551
  empty_replies = 0
7527
7552
  try:
@@ -7612,13 +7637,13 @@ def run_agent_turn(messages: list[dict], request: str | None = None):
7612
7637
  messages.append({"role": "assistant", "content": note})
7613
7638
  break
7614
7639
 
7615
- _ROUND["named"] = bool(full_reply) # a reply's text carries Eustace's name; a bare question adds it
7640
+ _ROUND["named"] = bool(full_reply) # classic layout: a reply's box carries Eustace's name
7616
7641
  if full_reply and SCREEN is not None:
7617
- # The full-screen view names the speaker instead of boxing the reply
7642
+ # In the full-screen view only the user's messages are marked (_UserMessage). Everything
7643
+ # unmarked is Eustace, so a reply has no label and no box.
7618
7644
  console.print()
7619
- console.print(Text(" Eustace", style=f"bold {_accent()}"))
7620
- console.print(Padding(_render_markdown(full_reply), (0, 2, 0, 4)))
7621
- _detail(f" [dim]{escape(short_model_label(MODEL))}{' | DEV' if DEV_MODE else ''}[/dim]")
7645
+ console.print(Padding(_render_markdown(full_reply), (0, 2, 0, 2)))
7646
+ _detail(f" [dim]{escape(short_model_label(MODEL))}{' | DEV' if DEV_MODE else ''}[/dim]")
7622
7647
  partial_reply = ""
7623
7648
  elif full_reply:
7624
7649
  console.print()
@@ -7628,7 +7653,7 @@ def run_agent_turn(messages: list[dict], request: str | None = None):
7628
7653
  title=f"[bold cyan]Eustace[/bold cyan] [dim]({short_model_label(MODEL)}{' | DEV' if DEV_MODE else ''})[/dim]",
7629
7654
  title_align="left",
7630
7655
  border_style="cyan",
7631
- box=box.ROUNDED,
7656
+ box=_panel_box(),
7632
7657
  padding=(0, 1),
7633
7658
  )
7634
7659
  )
@@ -7665,7 +7690,13 @@ def run_agent_turn(messages: list[dict], request: str | None = None):
7665
7690
  if SCREEN is None:
7666
7691
  console.print(f" [yellow]●[/yellow] {_summarize_args(fn_name, fn_args or {})}")
7667
7692
  elif fn_name not in SELF_DESCRIBING_TOOLS:
7668
- console.print(f" [yellow]●[/yellow] {_summarize_args(fn_name, fn_args or {}, plain=True)}")
7693
+ # The full-screen view names what is being done on one row that the next action
7694
+ # replaces. The line itself is kept with the details (Ctrl+O), and the turn ends with a
7695
+ # count. "Step" is left to the plan's own steps, which the row names when there is one.
7696
+ action = _summarize_args(fn_name, fn_args or {}, plain=True)
7697
+ _TURN["actions"] += 1
7698
+ _detail(f" [yellow]●[/yellow] {action}")
7699
+ SCREEN.set_status(f"{Text.from_markup(action).plain} · {task_progress() or 'action ' + str(_TURN['actions'])}")
7669
7700
  _detail(f" [dim]{escape(fn_name)} {escape(_visible_controls(json.dumps(fn_args or {}, ensure_ascii=False)[:400]))}[/dim]")
7670
7701
 
7671
7702
  APPROVAL_HANDLER.last_decision = "auto"
@@ -7735,6 +7766,8 @@ def run_agent_turn(messages: list[dict], request: str | None = None):
7735
7766
  finally:
7736
7767
  _abandon_status_line()
7737
7768
  _PLAN_GRANT["turn"] = None
7769
+ if _TURN["actions"]: # counted in the full-screen view only
7770
+ console.print(f" [dim]{escape(_turn_summary(_TURN['actions'], time.monotonic() - started))}[/dim]")
7738
7771
  _finalize_checkpoints(turn)
7739
7772
  changed = changed_files_note(turn)
7740
7773
  if changed:
@@ -7918,7 +7951,19 @@ def select_model_interactive(arg: str = "") -> str:
7918
7951
  known = {m[0] for m in models}
7919
7952
  models += [m for m in _live_models() if m[0] not in known] # whatever the service lists beyond the built-in ones
7920
7953
 
7921
- # If the user just typed "/model" without a name, show a pretty table of options
7954
+ # "/model" without a name: a list to choose from with the arrow keys, starting on the model in use
7955
+ if not choice and _can_pick():
7956
+ options = []
7957
+ for m_id, desc in models:
7958
+ mode = "Tools" if (DEV_MODE or m_id.endswith("-withtools")) else "Chat only"
7959
+ options.append((m_id, f"{m_id}{' (active)' if m_id == MODEL else ''} · {mode} · {_clean_line(desc, 60)}"))
7960
+ current = next((i for i, (m_id, _) in enumerate(models) if m_id == MODEL), 0)
7961
+ choice = _ask_menu(f"Choose the model ({BACKEND_NAME})", options, index=current) or ""
7962
+ if not choice:
7963
+ console.print(f" [dim]Still using {escape(MODEL)}.[/dim]")
7964
+ return MODEL
7965
+
7966
+ # Without the input box (a plain prompt): a table and a typed number or name
7922
7967
  if not choice:
7923
7968
  tbl = Table(box=box.SIMPLE_HEAVY, show_header=True, header_style="bold cyan")
7924
7969
  tbl.add_column("#", style="bold yellow", width=3)
@@ -7933,7 +7978,7 @@ def select_model_interactive(arg: str = "") -> str:
7933
7978
  tbl.add_row(str(idx), f"{escape(m_id)}{active}", mode, desc, style=style)
7934
7979
 
7935
7980
  title = f"[bold cyan]Select AI Model ({escape(BACKEND_NAME)})[/bold cyan]"
7936
- console.print(Panel(tbl, title=title, border_style="cyan", box=box.ROUNDED))
7981
+ console.print(Panel(tbl, title=title, border_style="cyan", box=_panel_box()))
7937
7982
  console.print("[bold cyan]Enter model # or name (or press Enter to keep current):[/bold cyan] ", end="")
7938
7983
  choice = _typed().strip()
7939
7984
  if not choice:
@@ -8120,17 +8165,30 @@ def _ui_app(root, key_bindings, focus=None):
8120
8165
  return app
8121
8166
 
8122
8167
 
8123
- def _ask_menu(question: str, options: list[tuple[str, str]], allow_view: bool = False) -> str | None:
8168
+ MENU_ROWS = 10 # choices shown at once; a longer list (saved sessions, models) scrolls under the highlight
8169
+
8170
+
8171
+ def _menu_window(count: int, current: int | None, rows: int = MENU_ROWS) -> tuple[int, int]:
8172
+ """Which choices of a list to show, as (first, one past the last): all of a short list, and for a long one
8173
+ the stretch around the highlighted choice."""
8174
+ if count <= rows:
8175
+ return 0, count
8176
+ first = max(min((current or 0) - rows // 2, count - rows), 0)
8177
+ return first, first + rows
8178
+
8179
+
8180
+ def _ask_menu(question: str, options: list[tuple[str, str]], allow_view: bool = False, index: int | None = None) -> str | None:
8124
8181
  """Arrow-key menu. Returns the chosen option's key, "view" (V, when allowed), or None when cancelled.
8125
8182
 
8126
8183
  Nothing is highlighted at first and only Enter confirms, so neither a stray key nor text typed before the
8127
- menu appeared can choose an option; pending keystrokes are discarded before it is shown."""
8184
+ menu appeared can choose an option; pending keystrokes are discarded before it is shown. A list the user
8185
+ asked for by name (/resume, /model) passes index to start on a choice: Enter then takes it."""
8128
8186
  if SCREEN is not None:
8129
- return SCREEN.ask_menu(question, options, allow_view)
8187
+ return SCREEN.ask_menu(question, options, allow_view, index)
8130
8188
  kb = _need("prompt_toolkit.key_binding", UI_FEATURE).KeyBindings()
8131
8189
  layout = _need("prompt_toolkit.layout", UI_FEATURE)
8132
8190
  controls = _need("prompt_toolkit.layout.controls", UI_FEATURE)
8133
- chosen = {"index": None}
8191
+ chosen = {"index": index}
8134
8192
 
8135
8193
  @kb.add("up")
8136
8194
  def _(event):
@@ -8140,7 +8198,7 @@ def _ask_menu(question: str, options: list[tuple[str, str]], allow_view: bool =
8140
8198
  def _(event):
8141
8199
  chosen["index"] = 0 if chosen["index"] is None else (chosen["index"] + 1) % len(options)
8142
8200
 
8143
- for n in range(len(options)):
8201
+ for n in range(min(len(options), 9)): # one key each: the tenth choice and on are reached with the arrows
8144
8202
  kb.add(str(n + 1))(lambda event, n=n: chosen.update(index=n))
8145
8203
 
8146
8204
  @kb.add("enter")
@@ -8160,9 +8218,14 @@ def _ask_menu(question: str, options: list[tuple[str, str]], allow_view: bool =
8160
8218
 
8161
8219
  def render():
8162
8220
  parts = [("class:question", question + "\n")]
8163
- for i, (_, label) in enumerate(options):
8221
+ first, last = _menu_window(len(options), chosen["index"])
8222
+ if first:
8223
+ parts.append(("class:status", f" ↑ {first} more\n"))
8224
+ for i, (_, label) in list(enumerate(options))[first:last]:
8164
8225
  mark, style = ("❯ ", "class:current") if i == chosen["index"] else (" ", "")
8165
8226
  parts.append((style, f"{mark}{i + 1}. {label}\n"))
8227
+ if last < len(options):
8228
+ parts.append(("class:status", f" ↓ {len(options) - last} more\n"))
8166
8229
  hint = "↑↓ to move · Enter to confirm · Esc to cancel" + (" · V to view the full diff" if allow_view else "")
8167
8230
  parts.append(("class:status", "\n" + hint))
8168
8231
  return parts
@@ -8677,6 +8740,7 @@ class _Screen:
8677
8740
  self._result = None
8678
8741
  self._answered = threading.Event()
8679
8742
  self._drawn = 0.0
8743
+ self._animating = False
8680
8744
  self._last_row = 0
8681
8745
  self._build()
8682
8746
 
@@ -8915,6 +8979,12 @@ class _Screen:
8915
8979
  side_on = filters.Condition(self.side_shown)
8916
8980
  soft = get_theme() == "soft"
8917
8981
  panel = "class:panel" if soft else ""
8982
+ # hidden while a question waits for its answer: nothing is running then
8983
+ self.status_row = when(text(self._status_text, height=1),
8984
+ filter=in_busy & filters.Condition(lambda: self.status is not None))
8985
+ # In the soft theme the gap beside the side panel carries the panel's shade: left on the ground color
8986
+ # it was a dark strip between the input box and the panel.
8987
+ self.gap = layout.Window(width=1, char=" " if soft else "│", style=panel or "class:bar.rule")
8918
8988
  root = layout.HSplit([
8919
8989
  text(self._bar_text, height=1, style=panel),
8920
8990
  # with its own shade the bar needs no rule under it; on the console's ground the rule separates it
@@ -8924,13 +8994,13 @@ class _Screen:
8924
8994
  layout.VSplit([
8925
8995
  layout.HSplit([
8926
8996
  self.body,
8927
- when(text(self._status_text, height=1), filter=filters.Condition(lambda: self.status is not None)),
8997
+ self.status_row,
8928
8998
  when(rounded(self.editor), filter=in_input),
8929
8999
  when(text(lambda: _suggestion_rows(buf)), filter=in_input & has_suggestions),
8930
9000
  when(text(self._menu_text), filter=in_menu),
8931
9001
  when(rounded(self.line), filter=in_line),
8932
9002
  ]),
8933
- when(layout.Window(width=1, char=" " if soft else "│", style="class:bar.rule"), filter=side_on),
9003
+ when(self.gap, filter=side_on),
8934
9004
  when(layout.Window(Scrolling(guarded(self._side_text)), width=SIDE_PANEL_WIDTH, style=panel),
8935
9005
  filter=side_on),
8936
9006
  ]),
@@ -9071,31 +9141,41 @@ class _Screen:
9071
9141
  return out
9072
9142
 
9073
9143
  def _bar_text(self):
9144
+ """The top row: the name at the left; at the right the folder Eustace works in, the model, the size of
9145
+ the conversation, the auto-mode badge and the state of the API key. It says where Eustace is and what
9146
+ it is set to, never what was last asked: that is in the conversation."""
9074
9147
  columns = self._size().columns
9075
9148
  star = (STAR_IDLE + " ") if _STAR["on"] else ""
9076
- title = _TURN.get("request") or "New task"
9077
9149
  state = API_STATUS["state"]
9078
9150
  api_style = {"ok": "class:ok", "locked": "class:bad", "unreachable": "class:warn"}.get(state, "class:bar")
9079
9151
  api = ("○ " if state in ("checking", "unknown") else "● ") + API_STATUS_LABELS[state]
9080
- try:
9081
- folder = os.path.basename(os.getcwd()) or os.getcwd()
9082
- except OSError:
9083
- folder = "a folder that is gone" # deleted or disconnected while Eustace was running
9084
- right = [("class:bar", f"Working in {folder} · "), (api_style, api), ("", " ")]
9085
- if PERMISSION_MODE == "auto": # the same badge the classic status line shows; nothing in the default mode
9086
- right[1:1] = [("class:auto", AUTO_BADGE.strip()), ("class:bar", " · ")]
9087
- if ELEVATED:
9088
- right.insert(0, ("class:admin", ADMIN_BADGE))
9089
- right.insert(1, ("", " "))
9090
- if DEV_MODE:
9091
- right.insert(0, ("class:warn", "DEV · "))
9092
- left_fixed = cell_len(f" {star}Eustace ")
9093
- while len(right) > 2 and left_fixed + sum(cell_len(t) for _, t in right) > columns:
9094
- right.pop(0) # a narrow window loses the folder first; the key indicator goes last
9095
- room = max(columns - left_fixed - sum(cell_len(t) for _, t in right) - 1, 0)
9096
- shown = title if cell_len(title) <= room else (set_cell_size(title, max(room - 1, 0)).rstrip() + "…" if room else "")
9097
- return ([("class:prompt", f" {star}"), ("class:bar.name", "Eustace "),
9098
- ("class:bar.title", set_cell_size(shown, room)), ("", " ")] + right)
9152
+ dot = ("class:bar", " · ")
9153
+ # Each part with the order it is given up in when the window is narrow (lowest first); the key's state
9154
+ # and the badges that warn (ADMIN, DEV, AUTO) stay the longest.
9155
+ parts = [(6, [("class:warn", "DEV")] if DEV_MODE else []),
9156
+ (7, [("class:admin", ADMIN_BADGE)] if ELEVATED else []),
9157
+ (3, [("class:bar", _short_folder())]),
9158
+ (2, [("class:bar", short_model_label(MODEL))]),
9159
+ (1, [("class:bar", f"~{_short_count(_TURN['tokens'])} tokens")] if _TURN["tokens"] else []),
9160
+ (5, [("class:auto", AUTO_BADGE.strip())] if PERMISSION_MODE == "auto" else []),
9161
+ (8, [(api_style, api)])]
9162
+ parts = [(rank, part) for rank, part in parts if part]
9163
+ left = [("class:prompt", f" {star}"), ("class:bar.name", "Eustace")]
9164
+
9165
+ def joined():
9166
+ out = []
9167
+ for _, part in parts:
9168
+ out += ([dot] if out else []) + part
9169
+ return out
9170
+
9171
+ width = lambda fragments: sum(cell_len(t) for _, t in fragments)
9172
+ while len(parts) > 1 and width(left) + 2 + width(joined()) + 1 > columns:
9173
+ parts.remove(min(parts, key=lambda item: item[0]))
9174
+ right = joined()
9175
+ gap = columns - width(left) - width(right) - 1
9176
+ if gap < 1: # too narrow even for the key's state beside the name
9177
+ return left
9178
+ return left + [("", " " * gap)] + right + [("", " ")]
9099
9179
 
9100
9180
  def _status_text(self):
9101
9181
  if _STAR["on"]:
@@ -9110,12 +9190,18 @@ class _Screen:
9110
9190
  req = self._request
9111
9191
  room = self.body_size()[0] - 1
9112
9192
  parts = [("class:question", f" {row}\n") for row in _wrap_cells(req.get("question", ""), room)]
9113
- for i, (_, label) in enumerate(req.get("options", [])):
9193
+ options = req.get("options", [])
9194
+ first, last = _menu_window(len(options), req.get("index"))
9195
+ if first:
9196
+ parts.append(("class:hint", f" ↑ {first} more\n"))
9197
+ for i, (_, label) in list(enumerate(options))[first:last]:
9114
9198
  style = "class:pick.current" if i == req.get("index") else ""
9115
9199
  lead = f" {'❯' if style else ' '} {i + 1}. "
9116
9200
  click = self._menu_click(i)
9117
9201
  for n, row in enumerate(_wrap_cells(label, room - cell_len(lead) - 1)):
9118
9202
  parts.append((style, f"{lead if n == 0 else ' ' * cell_len(lead)}{row} \n", click))
9203
+ if last < len(options):
9204
+ parts.append(("class:hint", f" ↓ {len(options) - last} more\n"))
9119
9205
  return parts[:-1] + [(parts[-1][0], parts[-1][1].rstrip("\n"), *parts[-1][2:])]
9120
9206
 
9121
9207
  def _menu_click(self, i: int):
@@ -9160,8 +9246,8 @@ class _Screen:
9160
9246
  details = ("Ctrl+O", "hide details" if self.details else "details")
9161
9247
  scroll_key = "Wheel/PgUp" if self.mouse else "PgUp"
9162
9248
  if self.mode == "input":
9249
+ # Shift+Tab (auto mode) is not listed: the top row shows the AUTO badge, and /help names the key
9163
9250
  parts = keys(("Enter", "send"), ("/", "shortcuts"), ("Ctrl+V", "paste"), details,
9164
- ("Shift+Tab", "auto mode off" if PERMISSION_MODE == "auto" else "auto mode"),
9165
9251
  (scroll_key, "scroll back"), ("Ctrl+B", "side panel"), ("@", "name a file"))
9166
9252
  elif self.mode == "menu":
9167
9253
  parts = keys(("Up/Down", "choose"), ("Enter", "confirm"), ("Esc", "cancel"),
@@ -9213,8 +9299,9 @@ class _Screen:
9213
9299
  def read_input(self) -> str:
9214
9300
  return self._ask("input", self.editor)
9215
9301
 
9216
- def ask_menu(self, question: str, options: list[tuple[str, str]], allow_view: bool = False) -> str | None:
9217
- return self._ask("menu", self.body, question=question, options=options, index=None, allow_view=allow_view)
9302
+ def ask_menu(self, question: str, options: list[tuple[str, str]], allow_view: bool = False,
9303
+ index: int | None = None) -> str | None:
9304
+ return self._ask("menu", self.body, question=question, options=options, index=index, allow_view=allow_view)
9218
9305
 
9219
9306
  def ask_line(self, prompt: str) -> str:
9220
9307
  return self._ask("line", self.line, prompt=prompt)
@@ -9227,6 +9314,21 @@ class _Screen:
9227
9314
  def set_status(self, text: str | None) -> None:
9228
9315
  self.status, self.frame = text, 0
9229
9316
  self.invalidate()
9317
+ if text is not None and not self._animating:
9318
+ # The wait for the model draws the star's frames itself (tick); while a tool runs nothing does,
9319
+ # so the view keeps the mark moving on its own clock.
9320
+ self._animating = True
9321
+ try:
9322
+ self.app.loop.call_soon_threadsafe(self._ui_animate)
9323
+ except Exception:
9324
+ self._animating = False # the view is not running (a test, or it has closed)
9325
+
9326
+ def _ui_animate(self) -> None:
9327
+ if self.status is None or self.closed:
9328
+ self._animating = False
9329
+ return
9330
+ self.tick()
9331
+ self.app.loop.call_later(STAR_FRAME_SECONDS, self._ui_animate)
9230
9332
 
9231
9333
  def tick(self) -> None:
9232
9334
  now = time.monotonic()
@@ -9323,12 +9425,59 @@ def _run_fullscreen(session) -> None:
9323
9425
  raise screen.error
9324
9426
 
9325
9427
 
9428
+ class _UserMessage:
9429
+ """What the user typed, as the full-screen view shows it: a bar in the accent color down its left edge and,
9430
+ in the soft theme, the panel's shade behind it. It is the only marked thing in the conversation, so the eye
9431
+ finds the user's messages when scrolling back, and everything between two of them is Eustace."""
9432
+
9433
+ def __init__(self, text: str):
9434
+ self.text = text
9435
+
9436
+ def __rich_console__(self, rich_console, options):
9437
+ shade = Style(bgcolor=THEME["panel"]) if get_theme() == "soft" else Style()
9438
+ bar = Style.parse(f"bold {_accent()}") + shade
9439
+ inner = options.update(width=max(options.max_width - 4, 10))
9440
+ for line in rich_console.render_lines(Text(self.text), inner, style=shade, pad=True):
9441
+ yield Segment(" ")
9442
+ yield Segment("▌ ", bar)
9443
+ yield from line
9444
+ yield Segment.line()
9445
+
9446
+
9326
9447
  def _estimate_tokens(messages: list[dict]) -> int:
9327
9448
  """Rough size of the conversation: about four characters per token. An estimate, not the provider's count."""
9328
9449
  chars = sum(len(str(m.get("content") or "")) + len(json.dumps(m.get("tool_calls") or "")) for m in messages)
9329
9450
  return chars // 4
9330
9451
 
9331
9452
 
9453
+ FOLDER_ROOM = 34 # cells the top row gives the working folder before the middle of its path is left out
9454
+
9455
+
9456
+ def _short_folder(room: int = FOLDER_ROOM) -> str:
9457
+ """The working folder for the top row: under the user's own folder it starts with ~ (never the account's
9458
+ name), and a path too long for the row keeps its start and its last folders, with … for what is between."""
9459
+ try:
9460
+ cwd = os.getcwd()
9461
+ except OSError:
9462
+ return "a folder that is gone" # deleted or disconnected while Eustace was running
9463
+ home = os.path.expanduser("~").rstrip("\\/")
9464
+ under_home = os.path.normcase(cwd) == os.path.normcase(home) or os.path.normcase(cwd).startswith(os.path.normcase(home) + os.sep)
9465
+ shown = "~" + cwd[len(home):] if under_home else cwd
9466
+ if cell_len(shown) <= room:
9467
+ return shown
9468
+ pieces = [p for p in shown.split(os.sep) if p]
9469
+ lead = pieces[0] if shown[:1] != os.sep else ""
9470
+ kept: list[str] = []
9471
+ for piece in reversed(pieces[1:]):
9472
+ if kept and cell_len(os.sep.join([lead, "…", piece] + kept)) > room:
9473
+ break
9474
+ kept.insert(0, piece)
9475
+ short = os.sep.join([lead, "…"] + kept)
9476
+ while cell_len(short) > room and len(short) > 2: # one folder name longer than the row: its end is kept
9477
+ short = "…" + short[2:]
9478
+ return short
9479
+
9480
+
9332
9481
  def _short_count(n: int) -> str:
9333
9482
  return f"{n / 1000:.1f}k" if n >= 1000 else str(n)
9334
9483
 
@@ -9336,11 +9485,12 @@ def _short_count(n: int) -> str:
9336
9485
  def _read_user_input(messages: list[dict]) -> str:
9337
9486
  """One message from the user: the input box on a real console, a plain prompt otherwise."""
9338
9487
  _refresh_star()
9488
+ _TURN["tokens"] = _estimate_tokens(messages) # the top row's size; every change to the conversation ends here
9339
9489
  if SCREEN is not None:
9340
9490
  text = SCREEN.read_input()
9341
9491
  console.print()
9342
- console.print(" [bold]You[/bold]")
9343
- console.print(Padding(Text(_sanitize_for_display(text)), (0, 2, 0, 4)))
9492
+ console.print(Rule(Text(f" {datetime.now():%H:%M} ", style=THEME["dim"]), align="right", style=THEME["line"]))
9493
+ console.print(_UserMessage(_sanitize_for_display(text)))
9344
9494
  return text
9345
9495
  if not _ui_enabled():
9346
9496
  badge = ("[bold red]ADMIN[/bold red] " if ELEVATED else "") + ("[bold yellow]AUTO[/bold yellow] " if PERMISSION_MODE == "auto" else "")
@@ -9430,7 +9580,37 @@ def _cmd_save(state: dict, arg: str) -> None:
9430
9580
  save_session(state["messages"], name=arg or datetime.now().strftime("session_%Y%m%d_%H%M"))
9431
9581
 
9432
9582
 
9583
+ def _can_pick() -> bool:
9584
+ """True when a list can be chosen from with the arrow keys (the full-screen view or the classic input box)."""
9585
+ return SCREEN is not None or _ui_enabled()
9586
+
9587
+
9588
+ def _pick_session() -> str | None:
9589
+ """/resume and /sessions: the saved conversations as a list to choose from with the arrow keys, newest
9590
+ first, starting on the newest one from an earlier run. Returns what load_session takes, or None."""
9591
+ saved = list_saved_sessions()
9592
+ if not saved:
9593
+ console.print("[dim yellow]No saved sessions yet.[/dim yellow]")
9594
+ return None
9595
+ options = []
9596
+ for number, item in enumerate(saved, start=1):
9597
+ title = _session_title(item)
9598
+ title = title if cell_len(title) <= 48 else set_cell_size(title, 47).rstrip() + "…"
9599
+ turns = item["turn_count"]
9600
+ here = " · this conversation" if item["name"] == AUTOSAVE_NAME else ""
9601
+ options.append((str(number), f"{title} · {turns} turn{'' if turns == 1 else 's'} · {_session_when(item)}{here}"))
9602
+ start = next((i for i, item in enumerate(saved) if item["name"] != AUTOSAVE_NAME), 0)
9603
+ picked = _ask_menu("Resume which conversation?", options, index=start)
9604
+ if picked is None:
9605
+ console.print(" [dim]Nothing resumed.[/dim]")
9606
+ return picked
9607
+
9608
+
9433
9609
  def _cmd_resume(state: dict, arg: str) -> None:
9610
+ if not arg.strip() and _can_pick():
9611
+ arg = _pick_session()
9612
+ if arg is None:
9613
+ return
9434
9614
  restored = load_session(arg)
9435
9615
  if restored is not None:
9436
9616
  state["messages"] = restored
@@ -9438,6 +9618,8 @@ def _cmd_resume(state: dict, arg: str) -> None:
9438
9618
 
9439
9619
 
9440
9620
  def _cmd_sessions(state: dict, arg: str) -> None:
9621
+ if _can_pick():
9622
+ return _cmd_resume(state, "")
9441
9623
  saved = list_saved_sessions()
9442
9624
  if not saved:
9443
9625
  console.print("[dim yellow]No saved sessions yet.[/dim yellow]")
@@ -9560,7 +9742,7 @@ def _cmd_tasks(state: dict, arg: str) -> None:
9560
9742
  return
9561
9743
  done = sum(t["status"] == "done" for t in _TASKS)
9562
9744
  console.print(Panel(_render_tasks(_TASKS), title=f"[cyan]Progress {done}/{len(_TASKS)}[/cyan]", title_align="left",
9563
- border_style="dim cyan", box=box.ROUNDED, padding=(0, 1)))
9745
+ border_style="dim cyan", box=_panel_box(), padding=(0, 1)))
9564
9746
 
9565
9747
 
9566
9748
  def _cmd_permissions(state: dict, arg: str) -> None:
@@ -9624,8 +9806,8 @@ COMMANDS: dict[str, tuple[str, typing.Callable[[dict, str], None]]] = {
9624
9806
  "/help": ("Show commands and keys", _cmd_help),
9625
9807
  "/status": ("Model, folder, session and token estimate", _cmd_status),
9626
9808
  "/save": ("Save this session: /save [name]", _cmd_save),
9627
- "/resume": ("Restore a saved session: /resume [name or number]", _cmd_resume),
9628
- "/sessions": ("List saved sessions", _cmd_sessions),
9809
+ "/resume": ("Pick a saved session to restore, or name one: /resume [name or number]", _cmd_resume),
9810
+ "/sessions": ("Pick a saved session to restore", _cmd_sessions),
9629
9811
  "/compact": ("Summarize the conversation to free up context", _cmd_compact),
9630
9812
  "/clear": ("Start over with an empty conversation", _cmd_clear),
9631
9813
  "/model": ("Choose the model: /model [id]", _cmd_model),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eustace
3
- Version: 2.4.1
3
+ Version: 2.5.0
4
4
  Summary: Office-work AI agent for the Windows console: local files, Word, Excel, PowerPoint, PDF, and Outlook
5
5
  Project-URL: Homepage, https://github.com/Colciferr/Eustace
6
6
  Project-URL: Source, https://github.com/Colciferr/Eustace
@@ -22,6 +22,7 @@ tests/test_guardrails.py
22
22
  tests/test_guards.py
23
23
  tests/test_guidance.py
24
24
  tests/test_log.py
25
+ tests/test_look.py
25
26
  tests/test_office.py
26
27
  tests/test_outlook_setup.py
27
28
  tests/test_path_spellings.py