-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Open
Description
Description
OI already imports readline and uses it for up-arrow history recall, but there is no tab-completion for magic commands. Users must remember the exact spelling of %save_message, %load_message, %verbose, etc. There are 12+ magic commands with no discoverability.
Suggested implementation
Add a readline completer that activates when input starts with %:
def _oi_completer(text, state):
MAGIC_COMMANDS = [
"%help", "%reset", "%undo", "%verbose", "%auto_run",
"%save_message", "%load_message", "%tokens",
"%info", "%jupyter", "%markdown", "%%",
]
if text.startswith("%"):
matches = [c for c in MAGIC_COMMANDS if c.startswith(text)]
else:
matches = []
return matches[state] if state < len(matches) else NoneRegister in the existing readline try block in terminal_interface.py:
readline.set_completer(_oi_completer)
readline.set_completer_delims(" \t\n")
readline.parse_and_bind("tab: complete")Behavior:
%+ Tab → shows all magic commands%re+ Tab → completes to%reset- Non-
%input → no completion (preserves default behavior) - Up-arrow history unaffected
Minimal change (~15 lines), no new dependencies.
Environment
- open-interpreter 0.4.3
- Python 3.10, Linux (readline available)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels