Repository navigation
Conversation
- 用 prompt_toolkit 的 PromptSession 替换 rich Prompt.ask,支持行编辑、 上下键历史与 Ctrl-R 搜索,历史持久化到 config 目录 - 新增 ShellCompleter:补全命令名(带描述)与当前目录文件名/文件夹名, 多列候选菜单可自动滚动;补全结果经 shlex.quote 转义,兼容带空格的文件名 - ls/ll 缓存当前目录条目供补全使用,cd 后清空避免补全旧目录内容 - cmd_help 补充快捷键说明
- 登录后立即在后台线程拉取当前目录,填充补全缓存,首次 cd <Tab> 不再只能补出 .. - 按 Tab 时若缓存仍未就绪,最多等待 2 秒再返回候选 - cd / cd .. / cd 回根目录后作废缓存并自动为新目录重新加载 - 新增底部状态栏:加载中显示「正在加载目录…」,否则显示路径、 条目数与快捷键提示;加载完成时线程安全地请求重绘
- 目录缓存改为按 folder_id 存(_dir_cache),不再只缓存当前目录, 这样 cd ../<Tab> 能补出根目录内容 - 新增 resolve_completion_dir:解析 ''、.、/、..、../..、子目录/、/子目录/ - 补全插入文本保留目录前缀(如 ../'夸克精选壁纸'),仍经 shlex.quote 转义 - 根目录下不再给出 .. 候选 - 状态栏增加加载失败提示(执行 ls 可重试) - cmd_list 按实际列出的目录刷新缓存,而非只刷新当前目录
get_word_before_cursor() 默认用 \w+ 词边界,会把 /root 截成 root、 ../../a 截成 a,导致绝对路径和带 .. 的前缀补不出候选。改用 WORD=True 只按空白切分。
- 新增 docs/interactive-shell.md:快捷键、补全规则(../、/、子目录/ 前缀)、 按命令区分的候选类型、目录缓存与状态栏行为,以及 8 条已知限制与规避方式 - README 命令行工具一节补充交互模式条目并链接该文档
qytlix
marked this pull request as ready for review
November 20, 2026 11:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
交互模式(
quarkpan interactive)此前是「一次性输入整行」:rich.prompt.Prompt走的是input(),而进程从未 import readline,所以方向键完全不可用——实测发送abc+←+X+ 回车,得到的是'abc\x1b[DX',转义序列被原样收下。Tab 补全、历史、候选菜单自然也都没有。这个 PR 把它换成 prompt_toolkit 的
PromptSession,做到接近 zsh 的手感。改动
prompt_toolkit的PromptSession替换rich.prompt.Prompt(新增依赖prompt_toolkit>=3.0.0)ShellCompleter../、../..、/、子目录/前缀shlex.quote转义,带空格的名字不会被shlex.split拆碎cd/ls只补文件夹、move第一个参数补文件+文件夹而第二个只补文件夹、rename只补第一个参数folder_id存放(_dir_cache),登录后后台预加载,首次按 Tab 就能补全,不必先ls;cd后自动为新目录加载,访问过的目录回退是即时的get_config_dir()/shell_history,支持Ctrl-R搜索cmd_help增加快捷键说明docs/interactive-shell.md:快捷键、补全规则、8 条已知限制与规避方式docs/PLAN-interactive-shell.md:设计过程与验证记录测试
abc+←+X+ EnterabXcdo+ Tabdownloadcd+ Tab../ 文件夹名cd ../(在两级目录下)../'夸克精选壁纸'download /root/rootfile.zipdownload 落<Tab>'落幕曲 1.5.4.zip'(空格已转义)Ctrl-R搜历史Ctrl-C/Ctrl-Dflake8 --max-line-length=120仅剩既有的 3 条告警(mv重复键 ×2、bare except),无新增;py_compile通过。已知限制
..(/a/../b)不解析ls重试ls刷新upload的本地路径未接PathCompleter详见
docs/interactive-shell.md。AI 使用声明
本 PR 的改动在 DeepSeek V4.1 Flash 辅助下完成,所有代码均经人工审阅与本地实测。仓库层面的声明在配套的下载修复 PR 中已加到 README。
说明
本 PR 与下载修复 PR 相互独立,可单独合并;两者都改
cli/interactive.py,但改的是不同区域(本 PR 改输入层与补全,另一 PR 改download的 aria2 参数),合并顺序无所谓,若有小冲突我会立刻处理。