This commit is contained in:
2026-07-20 16:15:58 -07:00
parent a156700e6e
commit 7f12bc7f40
6 changed files with 217 additions and 7 deletions
+31 -3
View File
@@ -98,7 +98,7 @@ from SYS.result_table import Table
from SYS.worker import WorkerManagerRegistry, WorkerStages, WorkerOutputMirror, WorkerStageSession
from SYS.pipeline import PipelineExecutor
from PluginCore.registry import plugin_inline_query_choices
from PluginCore.registry import plugin_inline_query_choices, plugin_query_field_map
@@ -1242,10 +1242,13 @@ class CmdletCompleter(Completer):
if query_fragment is not None:
field_choices: Dict[str, List[str]] = {}
ordered_fields: List[str] = []
query_only_field_names: set = set()
for spec in query_specs:
key = str(spec.get("query_key") or spec.get("name") or "").strip().lower()
if not key:
continue
if spec.get("query_only"):
query_only_field_names.add(key)
if key not in field_choices:
ordered_fields.append(key)
field_choices[key] = [str(choice) for choice in list(spec.get("choices", []) or [])]
@@ -1255,6 +1258,31 @@ class CmdletCompleter(Completer):
continue
field_choices.setdefault(alias_text, field_choices[key])
plugin_field_map: Dict[str, List[str]] = {}
if selected_plugin:
try:
plugin_field_map = plugin_query_field_map(selected_plugin, config)
except Exception:
plugin_field_map = {}
if plugin_field_map:
ordered_fields = [f for f in ordered_fields if f not in query_only_field_names]
removed_keys = set()
for key in query_only_field_names:
field_choices.pop(key, None)
removed_keys.add(key)
aliases_to_remove = set()
for alias_key, alias_values in list(field_choices.items()):
if alias_key in removed_keys:
continue
if alias_key not in ordered_fields and alias_key not in plugin_field_map:
aliases_to_remove.add(alias_key)
for akey in aliases_to_remove:
field_choices.pop(akey, None)
for field_name, choices in plugin_field_map.items():
if field_name not in field_choices:
ordered_fields.append(field_name)
field_choices[field_name] = choices
raw_fragment = str(query_fragment or "")
segment = raw_fragment[1:] if raw_fragment[:1] in {"'", '"'} else raw_fragment
if "," in segment:
@@ -1267,8 +1295,8 @@ class CmdletCompleter(Completer):
partial_lower = partial.strip().lower()
inline_choices = []
if effective_cmd == "search-file" and provider_name:
inline_choices = self._inline_query_choices(provider_name, field, config)
if selected_plugin and effective_cmd in {"search-file", "download-file"}:
inline_choices = self._inline_query_choices(selected_plugin, field, config)
choice_pool = inline_choices or field_choices.get(field, [])
if choice_pool: