在 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 仓库