在 DeepSeek Harness (DSH) 的插件生態中,開發者常需要在終端中快速獲取 AI 輔助。相比於啓動 TUI 或切換到 Web 界面,直接在命令行中提問往往更高效。dsh-ask 正是爲了解決這一痛點而生。
這是一個輕量級的 DSH bundle,它不啓動圖形化或 TUI 界面,而是直接在當前目錄提交問題,將回答流式輸出到終端,隨後退出。
核心功能¶
dsh-ask 主要提供以下能力:
- 終端直接問答:在當前目錄下直接提問,支持流式輸出。
- 持久會話:同一終端、同一目錄內的連續提問會恢復該會話;不同目錄或新終端會開啓新會話。
- 流式輸出與狀態顯示:實時顯示思考進度、工具調用狀態,且回答內容僅輸出到 stdout。
- Shell 集成:支持 Fish、Bash、Zsh 和實驗性的 PowerShell。
- 高度可配置:支持配置 Provider、Model、Effort、語言和輸出樣式。
- 中英文支持:默認中文,可通過命令行切換。
安裝與啓用¶
使用 DSH 的插件命令安裝 bundle:
dsh plugin --profile ask add <你的包名或 git spec>
安裝後,需手動初始化並激活 Shell 集成。安裝器不會自動修改你的 shell 配置文件(如 .bashrc 或 .zshrc)。
Fish
dsh plugin --profile ask exec dsh-ask init fish
source ~/.config/fish/conf.d/zz-dsh-ask.fish
Bash
dsh plugin --profile ask exec dsh-ask init bash
source "${XDG_CONFIG_HOME:-$HOME/.config}/dsh-ask/bash-command-not-found.bash"
# 如需持久啓用,請在 ~/.bashrc 中加入上述 source 命令
Zsh
dsh plugin --profile ask exec dsh-ask init zsh
source "${XDG_CONFIG_HOME:-$HOME/.config}/dsh-ask/zsh-command-not-found.zsh"
# 如需持久啓用,請在 ~/.zshrc 中加入上述 source 命令
PowerShell(實驗性)
dsh plugin --profile ask exec dsh-ask init powershell
. "$HOME/.config/dsh-ask/powershell-command-not-found.ps1"
# 如需持久啓用,請將上述命令加入 $PROFILE
典型用法¶
基礎提問¶
直接在命令行中輸入問題:
dsh --profile ask "這個函數做什麼?"
配置與選擇¶
dsh-ask 提供了參數來指定或保存默認配置。這些參數只會修改 ask profile 的默認值,不會影響 DSH 的全局設置。
列出所有已註冊 provider 及其支持的 effort:
dsh --profile ask --provider
指定 Provider 並立即提問:
dsh --profile ask --provider=deepseek --model=deepseek-chat "快速解釋這段代碼"
僅保存配置(不發起聊天):
dsh --profile ask --provider=deepseek
dsh --profile ask --model=deepseek-chat
dsh --profile ask --effort=high
高級操作¶
使用推理模型並指定強度:
dsh --profile ask -m deepseek-reasoner -e high "審查這個設計"
管理會話:
# 創建新的獨立會話
dsh --profile ask --new "調查一個無關問題"
# 恢復指定 ID 的會話
dsh --profile ask --session refactor-auth "繼續重構"
樣式與語言¶
設置輸出樣式(如僅純文本):
# 使用環境變量
export DSH_ASK_STYLE=plain
# 或在 profile 的 cordis.patch.yml 中覆蓋
切換語言:
dsh --profile ask --lang=en "Explain this code"
適用場景與注意¶
- 會話邏輯:默認會話由當前絕對目錄和當前父 shell 決定。因此,在同一個終端、同一個目錄下連續提問會恢復上下文;但如果目錄不同,或者開了新終端,則視爲新會話。如需瀏覽或恢復舊會話,請使用 Web 界面。
- 流式輸出:思考過程、工具調用等狀態信息輸出到 stderr,純文本回答輸出到 stdout。這保證了將輸出重定向到文件時,只包含回答內容。
- 配置位置:
dsh-ask的默認配置保存在$DSH_HOME/ask/config.json(通常爲~/.dsh/ask/config.json)。 - Shell 集成:Bash 和 Zsh 的安裝器不會自動修改配置文件,需要手動 source 生成的腳本。PowerShell 集成目前處於實驗階段,建議在實際使用的各種宿主中驗證。
dsh-ask 爲 DeepSeek Harness 用戶提供了從終端直接、流式、持久化的問答能力,適合需要在命令行環境中頻繁與 AI 交互的開發者。
更多細節與源碼可訪問:GitHub 倉庫