assistant 2.2.0a4__tar.gz → 2.2.0b1__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 (110) hide show
  1. {assistant-2.2.0a4/assistant.egg-info → assistant-2.2.0b1}/PKG-INFO +1 -1
  2. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/__init__.py +1 -1
  3. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/agent.py +8 -1
  4. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/envindex.py +12 -1
  5. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/completer.py +17 -5
  6. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/shell.py +69 -46
  7. {assistant-2.2.0a4 → assistant-2.2.0b1/assistant.egg-info}/PKG-INFO +1 -1
  8. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_envindex_suggestions.py +73 -5
  9. {assistant-2.2.0a4 → assistant-2.2.0b1}/LICENSE +0 -0
  10. {assistant-2.2.0a4 → assistant-2.2.0b1}/MANIFEST.in +0 -0
  11. {assistant-2.2.0a4 → assistant-2.2.0b1}/README.md +0 -0
  12. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/__main__.py +0 -0
  13. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/as_client.py +0 -0
  14. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/as_service.py +0 -0
  15. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/builtin_cmds.py +0 -0
  16. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/codecache.py +0 -0
  17. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/compress.py +0 -0
  18. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/conditions.py +0 -0
  19. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/config.py +0 -0
  20. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/entry_points/__init__.py +0 -0
  21. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/entry_points/run_assistant.py +0 -0
  22. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/execer.py +0 -0
  23. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/history.py +0 -0
  24. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/listen/__init__.py +0 -0
  25. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/listen/__main__.py +0 -0
  26. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/listen/interface.py +0 -0
  27. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/listen/main.py +0 -0
  28. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/main.py +0 -0
  29. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/memory.py +0 -0
  30. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/__init__.py +0 -0
  31. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/clear.py +0 -0
  32. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/exit.py +0 -0
  33. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/http_client.py +0 -0
  34. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/interface.py +0 -0
  35. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/message.py +0 -0
  36. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/__init__.py +0 -0
  37. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/google.py +0 -0
  38. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/llama_cpp.py +0 -0
  39. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/nim.py +0 -0
  40. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/ollama.py +0 -0
  41. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/openai.py +0 -0
  42. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/openrouter.py +0 -0
  43. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/providers/vllm.py +0 -0
  44. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/think.py +0 -0
  45. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/nlp/xonsh.py +0 -0
  46. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/parser.py +0 -0
  47. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/projectfile.py +0 -0
  48. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/__init__.py +0 -0
  49. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/bindings.py +0 -0
  50. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/dialogs.py +0 -0
  51. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/floats.py +0 -0
  52. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/layout.py +0 -0
  53. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/operators.py +0 -0
  54. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/strformat_utils.py +0 -0
  55. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/styles.py +0 -0
  56. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/ptk_shell/windows.py +0 -0
  57. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/say/__init__.py +0 -0
  58. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/say/interface.py +0 -0
  59. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/setup_wizard.py +0 -0
  60. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/time.py +0 -0
  61. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/tools.py +0 -0
  62. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/tools_worker.py +0 -0
  63. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/traces/__init__.py +0 -0
  64. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/traces/cmd.py +0 -0
  65. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/traces/export.py +0 -0
  66. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/traces/schema.py +0 -0
  67. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/traces/store.py +0 -0
  68. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/utils.py +0 -0
  69. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/version.py +0 -0
  70. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant/vocabulary.py +0 -0
  71. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant.egg-info/SOURCES.txt +0 -0
  72. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant.egg-info/dependency_links.txt +0 -0
  73. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant.egg-info/entry_points.txt +0 -0
  74. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant.egg-info/requires.txt +0 -0
  75. {assistant-2.2.0a4 → assistant-2.2.0b1}/assistant.egg-info/top_level.txt +0 -0
  76. {assistant-2.2.0a4 → assistant-2.2.0b1}/pyproject.toml +0 -0
  77. {assistant-2.2.0a4 → assistant-2.2.0b1}/setup.cfg +0 -0
  78. {assistant-2.2.0a4 → assistant-2.2.0b1}/setup.py +0 -0
  79. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_bindings.py +0 -0
  80. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_builtin_cmds.py +0 -0
  81. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_compaction.py +0 -0
  82. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_compress.py +0 -0
  83. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_config.py +0 -0
  84. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_envindex.py +0 -0
  85. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_git_hook.py +0 -0
  86. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_history_bridge.py +0 -0
  87. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_http_client.py +0 -0
  88. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_init.py +0 -0
  89. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_interrupt.py +0 -0
  90. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_interrupt_real.py +0 -0
  91. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_listen_interrupt.py +0 -0
  92. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_memory.py +0 -0
  93. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_memory_sqlite.py +0 -0
  94. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_model_compare.py +0 -0
  95. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_projectfile.py +0 -0
  96. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_setup_wizard.py +0 -0
  97. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_startup_performance.py +0 -0
  98. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_tmux_interactive.py +0 -0
  99. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_tool_handling.py +0 -0
  100. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_tools.py +0 -0
  101. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_traces_agent.py +0 -0
  102. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_traces_cmd.py +0 -0
  103. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_traces_export.py +0 -0
  104. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_traces_schema.py +0 -0
  105. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_traces_store.py +0 -0
  106. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_tts_streaming.py +0 -0
  107. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_utils.py +0 -0
  108. {assistant-2.2.0a4 → assistant-2.2.0b1}/tests/test_xontrib.py +0 -0
  109. {assistant-2.2.0a4 → assistant-2.2.0b1}/xontrib/__init__.py +0 -0
  110. {assistant-2.2.0a4 → assistant-2.2.0b1}/xontrib/assistant.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: assistant
3
- Version: 2.2.0a4
3
+ Version: 2.2.0b1
4
4
  Summary: Your very own Assistant. Because you deserve it.
5
5
  Home-page: https://gitlab.com/waser-technologies/technologies/assistant
6
6
  Author: Danny Waser
@@ -5,7 +5,7 @@ import warnings
5
5
  warnings.filterwarnings("ignore", category=DeprecationWarning, module="webrtcvad")
6
6
  warnings.filterwarnings("ignore", category=UserWarning, module="webrtcvad")
7
7
 
8
- __version__ = "2.2.0a4"
8
+ __version__ = "2.2.0b1"
9
9
 
10
10
  USERNAME = os.environ.get("USER", "root")
11
11
  HOME = os.environ.get("HOME", f"/home/{USERNAME}" if USERNAME != "root" else "/root")
@@ -450,7 +450,14 @@ class Orchestrator:
450
450
  from assistant.envindex import env_index, render_suggestions
451
451
 
452
452
  budget = int(getattr(cfg, "suggestions_budget", 800) or 800)
453
- suggestion = env_index.suggestions(query=query, limit=6)
453
+ # Completion case: when the query is a single token, the user
454
+ # is mid-typing a completion — only names that extend the typed
455
+ # stem are valid candidates (``rm R`` → ``RELEASE_NOTES_*``,
456
+ # never ``README.md``). Multi-token queries stay unfiltered.
457
+ prefix = None
458
+ if len(query.split()) == 1:
459
+ prefix = query.strip()
460
+ suggestion = env_index.suggestions(query=query, limit=6, prefix=prefix)
454
461
  entries = suggestion.get("results", [])
455
462
  if entries:
456
463
  body = render_suggestions(entries, budget=budget)
@@ -278,7 +278,9 @@ class EnvIndex:
278
278
  scored.sort(key=lambda x: (-x[0], x[1]["category"], x[1]["name"]))
279
279
  return {"results": [e for _, e in scored[:limit]]}
280
280
 
281
- def suggest(self, query: str, limit: int = 6) -> Dict[str, Any]:
281
+ def suggest(
282
+ self, query: str, limit: int = 6, prefix: Optional[str] = None
283
+ ) -> Dict[str, Any]:
282
284
  """Suggestions for ``query``, filtered by type and scored by frequency.
283
285
 
284
286
  Reuses :meth:`search` for query relevance, then boosts each entry by how
@@ -287,6 +289,12 @@ class EnvIndex:
287
289
  are kept in separate buckets so a single suggestion never mixes the two;
288
290
  the final ``results`` interleave both buckets in weighted order.
289
291
 
292
+ When ``prefix`` is given, only entries whose name starts with it are
293
+ kept — the completion case: the user already typed the stem, so a
294
+ suggestion must extend it (``rm R`` → ``RELEASE_NOTES_*``, never
295
+ ``README.md``). ``prefix`` is matched case-insensitively and applies
296
+ to both buckets.
297
+
290
298
  Best-effort: never raises, never blocks on history. Returns
291
299
  ``{"results": [], "commands": [], "ctx": []}`` for empty queries.
292
300
  """
@@ -298,6 +306,9 @@ class EnvIndex:
298
306
  if not query or not query.strip():
299
307
  return empty
300
308
  results = self.search(query, limit=100)["results"]
309
+ if prefix:
310
+ p = prefix.lower()
311
+ results = [e for e in results if e["name"].lower().startswith(p)]
301
312
  if not results:
302
313
  return empty
303
314
 
@@ -321,16 +321,28 @@ class AssistantCompleter:
321
321
 
322
322
  # Get first word only (avoid multi-word completions confusing the UI)
323
323
  pred_clean = pred.split()[0] if pred.split() else pred
324
+ # Strip trailing space (xonsh completions often include it)
325
+ pred_clean = pred_clean.rstrip()
324
326
 
325
327
  if not pred_clean or pred_clean in seen:
326
328
  continue
327
329
  seen.add(pred_clean)
328
330
 
329
- combined_word = (
330
- word_before_cursor + " " + pred_clean
331
- if word_before_cursor
332
- else pred_clean
333
- )
331
+ # The prediction must extend the typed stem (case-insensitive
332
+ # startswith). When the user typed ``rm R``, only ``R*``
333
+ # candidates are valid completions — the LLM's raw output is
334
+ # unfiltered and would otherwise surface ``README.md`` next to
335
+ # ``RELEASE_NOTES_*``.
336
+ if word_before_cursor and not pred_clean.lower().startswith(
337
+ word_before_cursor.lower()
338
+ ):
339
+ continue
340
+
341
+ # The completion text replaces the typed stem: ``rm R`` +
342
+ # ``README.md`` → ``rm README.md`` (not ``rm R README.md``).
343
+ # ``start_position=-len(word_before_cursor)`` tells PTK to
344
+ # overwrite the stem, so the text must be the full candidate.
345
+ combined_word = pred_clean
334
346
  meta = "✨" if self._completion_enabled and self.agent else "📋"
335
347
 
336
348
  yield from (
@@ -371,11 +371,34 @@ class AssistantShell(PromptToolkitShell):
371
371
  self.prompter: PromptSession = PromptSession(**ptk_args)
372
372
 
373
373
  self.prompt_formatter = PTKPromptFormatter(self)
374
- self.pt_completer = merge_completers(
375
- [
376
- AssistantCompleter(),
377
- PromptToolkitCompleter(self.completer, self.ctx, self),
378
- ]
374
+
375
+ # Wrap in a deduplicating completer that strips trailing whitespace
376
+ # before comparing, so 'README.md' and 'README.md ' are deduplicated.
377
+
378
+ class _DedupCompleter:
379
+ def __init__(self, inner):
380
+ self.inner = inner
381
+
382
+ def get_completions(self, document, complete_event):
383
+ seen = set()
384
+ for comp in self.inner.get_completions(document, complete_event):
385
+ key = (
386
+ document.text[: document.cursor_position + comp.start_position]
387
+ + comp.text.rstrip()
388
+ + document.text[document.cursor_position:]
389
+ )
390
+ if key in seen:
391
+ continue
392
+ seen.add(key)
393
+ yield comp
394
+
395
+ self.pt_completer = _DedupCompleter(
396
+ merge_completers(
397
+ [
398
+ AssistantCompleter(),
399
+ PromptToolkitCompleter(self.completer, self.ctx, self),
400
+ ]
401
+ )
379
402
  )
380
403
 
381
404
  # Use the xonsh bindings from parent init (which includes multiline_carriage_return)
@@ -1577,51 +1600,51 @@ class AssistantShell(PromptToolkitShell):
1577
1600
  hist.last_cmd_rtn = 0
1578
1601
 
1579
1602
  return response or ""
1580
- def _try_builtin(self, line):
1581
- """Try to dispatch a built-in command. Returns True if handled."""
1582
- stripped = line.strip()
1583
- if not stripped:
1584
- return False
1585
- m = re.match(r"^(\S+)\s*(.*)", stripped, re.DOTALL)
1586
- if not m:
1587
- return False
1588
- cmd_name = m.group(1).lower()
1589
- if cmd_name in BUILTIN_COMMANDS:
1590
- cmd_info = BUILTIN_COMMANDS[cmd_name]
1591
- fn = cmd_info.get("fn")
1592
- if fn is not None:
1593
- # Reset terminal to a clean state before running the builtin.
1594
- # prompt_toolkit's Application leaves the cursor at the prompt
1595
- # position and may have the terminal in raw mode or with
1596
- # modifyOtherKeys enabled. A nested prompt_toolkit app (e.g.
1597
- # questionary in the wizard) will mis-render if the terminal
1598
- # state is not reset first.
1599
- try:
1600
- import sys
1601
- import tty
1602
- import termios
1603
-
1604
- fd = sys.stdin.fileno()
1605
- # Disable modifyOtherKeys (mode 4) if enabled.
1606
- sys.stdout.write("\x1b[>4;0m")
1607
- sys.stdout.flush()
1608
- # Reset terminal attributes to a known state (cooked mode,
1609
- # echo on, etc.) so the nested app starts clean.
1603
+ def _try_builtin(self, line):
1604
+ """Try to dispatch a built-in command. Returns True if handled."""
1605
+ stripped = line.strip()
1606
+ if not stripped:
1607
+ return False
1608
+ m = re.match(r"^(\S+)\s*(.*)", stripped, re.DOTALL)
1609
+ if not m:
1610
+ return False
1611
+ cmd_name = m.group(1).lower()
1612
+ if cmd_name in BUILTIN_COMMANDS:
1613
+ cmd_info = BUILTIN_COMMANDS[cmd_name]
1614
+ fn = cmd_info.get("fn")
1615
+ if fn is not None:
1616
+ # Reset terminal to a clean state before running the builtin.
1617
+ # prompt_toolkit's Application leaves the cursor at the prompt
1618
+ # position and may have the terminal in raw mode or with
1619
+ # modifyOtherKeys enabled. A nested prompt_toolkit app (e.g.
1620
+ # questionary in the wizard) will mis-render if the terminal
1621
+ # state is not reset first.
1610
1622
  try:
1611
- attrs = termios.tcgetattr(fd)
1612
- tty.setcookes(fd)
1623
+ import sys
1624
+ import tty
1625
+ import termios
1626
+
1627
+ fd = sys.stdin.fileno()
1628
+ # Disable modifyOtherKeys (mode 4) if enabled.
1629
+ sys.stdout.write("\x1b[>4;0m")
1630
+ sys.stdout.flush()
1631
+ # Reset terminal attributes to a known state (cooked mode,
1632
+ # echo on, etc.) so the nested app starts clean.
1633
+ try:
1634
+ attrs = termios.tcgetattr(fd)
1635
+ tty.setcookes(fd)
1636
+ except Exception:
1637
+ pass
1613
1638
  except Exception:
1614
1639
  pass
1615
- except Exception:
1616
- pass
1617
1640
 
1618
- rest = m.group(2).strip()
1619
- if rest:
1620
- fn(rest.split())
1621
- else:
1622
- fn([])
1623
- return True
1624
- return False
1641
+ rest = m.group(2).strip()
1642
+ if rest:
1643
+ fn(rest.split())
1644
+ else:
1645
+ fn([])
1646
+ return True
1647
+ return False
1625
1648
 
1626
1649
  def singleline(
1627
1650
  self, auto_suggest=None, enable_history_search=True, multiline=True, **kwargs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: assistant
3
- Version: 2.2.0a4
3
+ Version: 2.2.0b1
4
4
  Summary: Your very own Assistant. Because you deserve it.
5
5
  Home-page: https://gitlab.com/waser-technologies/technologies/assistant
6
6
  Author: Danny Waser
@@ -225,6 +225,27 @@ class TestSuggest:
225
225
  assert r["results"] == []
226
226
  assert r["commands"] == [] and r["ctx"] == []
227
227
 
228
+ def test_prefix_filters_by_name_startswith(self, monkeypatch):
229
+ entries = [
230
+ {"name": "rm", "category": "bin", "description": "remove files"},
231
+ {"name": "rm_rf", "category": "alias", "description": ""},
232
+ {"name": "README.md", "category": "bin", "description": ""},
233
+ {"name": "RELEASE_NOTES_2.2.0a3.md", "category": "bin", "description": ""},
234
+ {"name": "git", "category": "bin", "description": "vcs"},
235
+ ]
236
+ idx = _patched_index(monkeypatch, entries)
237
+ r = idx.suggest("R", limit=6, prefix="R")
238
+ names = [e["name"] for e in r["results"]]
239
+ # Case-insensitive startswith: only the R* entries survive (git does
240
+ # not start with "r").
241
+ assert names == ["rm", "rm_rf", "README.md", "RELEASE_NOTES_2.2.0a3.md"]
242
+
243
+ def test_prefix_empty_when_no_match(self, monkeypatch):
244
+ entries = [{"name": "git", "category": "bin", "description": "vcs"}]
245
+ idx = _patched_index(monkeypatch, entries)
246
+ r = idx.suggest("zzz", limit=6, prefix="zzz")
247
+ assert r["results"] == [] and r["commands"] == [] and r["ctx"] == []
248
+
228
249
  def test_suggestions_alias(self, monkeypatch):
229
250
  # ``suggestions`` is an alias for ``suggest`` (prompt injection snippet)
230
251
  entries = [{"name": "git", "category": "bin", "description": "vcs"}]
@@ -370,7 +391,7 @@ class TestDynamicEnvSuggestionBlock:
370
391
  monkeypatch.setattr(idx, "_ensure", _ensure)
371
392
  monkeypatch.setattr(envindex_mod, "env_index", idx, raising=True)
372
393
 
373
- def _suggestions(query, limit=6):
394
+ def _suggestions(query, limit=6, prefix=None):
374
395
  return {"results": results, "commands": results, "ctx": []}
375
396
 
376
397
  monkeypatch.setattr(idx, "suggestions", _suggestions)
@@ -463,10 +484,8 @@ class TestDynamicEnvSuggestionBlock:
463
484
 
464
485
  orch._cfg = get_config()
465
486
  # Also need env_index.suggestions present; patch on the injected mod
466
- import sys
467
-
468
- sys.modules["assistant.envindex"].env_index.suggestions = (
469
- lambda query, limit=6: {
487
+ __import__("sys").modules["assistant.envindex"].env_index.suggestions = (
488
+ lambda query, limit=6, prefix=None: {
470
489
  "results": [{"name": "git", "category": "bin", "description": "vcs"}],
471
490
  "commands": [],
472
491
  "ctx": [],
@@ -475,6 +494,55 @@ class TestDynamicEnvSuggestionBlock:
475
494
  orch._dynamic_env_blocks("git")
476
495
  assert seen["budget"] == 123
477
496
 
497
+ def test_single_token_query_passes_prefix(self, monkeypatch):
498
+ seen = {}
499
+
500
+ def _suggestions(query, limit=6, prefix=None):
501
+ seen["prefix"] = prefix
502
+ return {"results": [], "commands": [], "ctx": []}
503
+
504
+ self._patch_index(monkeypatch, [])
505
+ # Re-patch with the capturing fake (overrides _patch_index's fake).
506
+ import assistant.envindex as envindex_mod
507
+
508
+ envindex_mod.env_index.suggestions = _suggestions
509
+ monkeypatch.setattr(
510
+ "assistant.config.Config.suggestions_enabled",
511
+ property(lambda self: True),
512
+ )
513
+ monkeypatch.setattr(
514
+ "assistant.config.Config.suggestions_budget",
515
+ property(lambda self: 800),
516
+ )
517
+
518
+ orch = self._orch(monkeypatch)
519
+ orch._dynamic_env_blocks("R")
520
+ assert seen["prefix"] == "R"
521
+
522
+ def test_multi_token_query_passes_no_prefix(self, monkeypatch):
523
+ seen = {}
524
+
525
+ def _suggestions(query, limit=6, prefix=None):
526
+ seen["prefix"] = prefix
527
+ return {"results": [], "commands": [], "ctx": []}
528
+
529
+ self._patch_index(monkeypatch, [])
530
+ import assistant.envindex as envindex_mod
531
+
532
+ envindex_mod.env_index.suggestions = _suggestions
533
+ monkeypatch.setattr(
534
+ "assistant.config.Config.suggestions_enabled",
535
+ property(lambda self: True),
536
+ )
537
+ monkeypatch.setattr(
538
+ "assistant.config.Config.suggestions_budget",
539
+ property(lambda self: 800),
540
+ )
541
+
542
+ orch = self._orch(monkeypatch)
543
+ orch._dynamic_env_blocks("rm R")
544
+ assert seen["prefix"] is None
545
+
478
546
 
479
547
  class TestEnvSummary:
480
548
  def test_env_summary_includes_previous_conversations(self, tmp_path, monkeypatch):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes