Bundle
dsh-ask-powerful
Ask a powerful external model (ChatGPT / Claude) for coding help without polluting the main DSH context. The plugin builds a self-contained prompt, shows it to the user through a UI-only command result, and the external answer returns as the next user message.
- Source
- realjhen123
- License
- MIT
- Updated
- Updated 7 days ago
Readme
# dsh-ask-powerful
**把模型搞不定的 coding 任务交给外部强模型(ChatGPT / Claude),同时不污染主对话上下文。**
一个给 DeepSeek Harness (DSH) 用的插件。它生成一段自包含提示词,由 `/ask-powerful` 命令展示给你复制,卡片上带复制按钮。提示词正文不进入模型上下文。先进模型的回答作为下一条消息回到主会话。
## 为什么需要
模型遇到很难的 coding 任务时,常见做法是把任务转给更强的外部模型。直接把长提示词塞回对话会带来两个问题:
1. 提示词正文进入模型上下文,浪费 token,也干扰后续推理。
2. 代码被复制进工具参数,主上下文多出一份副本。
这个插件把「生成」和「交付」分开:
- 工具调用进入主上下文。
- 提示词正文只通过命令结果给用户看。命令结果不进模型上下文。
- 代码由插件直接读文件,模型只传路径与行号。
## 工作方式
```text
模型调用 ask_powerful_model(只传问题 + 文件路径 + 约束)
|
v
插件读取文件,拼出自包含提示词
|
v
提示词存入插件内存(不写会话日志)
|
v
工具只返回一句短状态(进入主上下文)
|
v
用户运行 /ask-powerful 查看并复制(命令结果不进上下文)
|
v
用户粘贴到 ChatGPT / Claude 新对话
|
v
用户把回答作为下一条消息发回(进入主上下文)
```
## 主上下文里有什么
- `ask_powerful_model` 的工具调用参数。
- 一句短工具结果。
- 你后来粘贴的先进模型回答。
提示词正文、代码全文都不在主上下文里。
## 安装
1. 进入你的 DSH profile 目录,建立 link 依赖:
```bash
cd /path/to/your/dsh/profile
pnpm add link:/path/to/dsh-ask-powerful
```
2. 把 `dsh-ask-powerful` 加入该 profile `package.json` 的 `dsh.profile.bundles`。
3. 重新加载或重启 DSH。
插件本身是纯 ESM JavaScript,没有构建步骤。
## 使用
### 模型入口
模型判断任务超出能力时调用 `ask_powerful_model`:
```json
{
"question": "为什么高并发下计数器会丢更新?",
"files": [{ "path": "src/counter.ts", "start": 1, "end": 80 }],
"symptom": "压测时最终计数小于预期",
"goal": "改成线程安全且不引入全局锁",
"constraints": "不能改公开 API",
"done_when": "新增并发测试通过",
"output": "patch"
}
```
然后你运行:
```
/ask-powerful
```
命令结果会渲染成一张卡片,带复制按钮。点一下复制整段提示词。
### 手动入口
直接给任务文本:
```
/ask-powerful 设计一个无锁队列,并说明 ABA 问题怎么处理
```
命令现场生成提示词,不读文件,不拼接会话历史。
## 配置
在 `cordis.patch.yml` 的 `ask-powerful` 条目里配置:
| 字段 | 默认 | 含义 |
| --- | --- | --- |
| `maxEscalationsPerSession` | `5` | 每个会话允许模型主动求助的次数 |
| `maxFiles` | `8` | 一次提示词最多嵌入的文件数 |
| `maxSnippetLines` | `400` | 每个文件最多读取的行数 |
| `maxFileChars` | `120000` | 每个文件最多读取的字符数 |
| `maxPromptChars` | `30000` | 最终提示词字符上限 |
| `language` | `zh` | 提示词语言,`zh` 或 `en` |
## 开发
```bash
make test # 纯逻辑测试
make check # 语法检查 + 测试
```
纯逻辑测试与客户端模块测试不需要 DSH 依赖。`test/host.test.mjs` 需要 `@deepseek-ai/dsh-tools` 可解析,否则自动跳过。
客户端半边改动后,浏览器需要重新加载页面。宿主扫描到新的 `dsh.client` 声明后才会提供这个 bundle。
## 边界
- 插件不联网,不调用任何外部 API。
- 插件不写会话日志,不让提示词进入模型上下文。
- 插件只读模型指定的文件。
- 同一会话求助次数有上限。
- 提示词过长时按行截断。
## 目录
```
dsh-ask-powerful/
-- src/
-- index.js 插件入口
-- tool.js ask_powerful_model 工具
-- command.js /ask-powerful 命令
-- prompt.js 提示词模板(纯逻辑)
-- files.js 读取文件片段
-- state.js 会话级提示词存储(纯逻辑)
-- config.js 配置归一化(纯逻辑)
-- system-prompt.js 系统提示词注入
-- lib/
-- client.js 浏览器半边:带复制按钮的命令卡片
-- test/ 测试
-- doc/design.md 设计说明
-- cordis.patch.yml 插件挂载 patch
-- Makefile
-- package.json
-- README.md
```
Install
dsh plugin --profile web add github:realjhen123/dsh-ask-powerful
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install dsh-ask-powerful from the hub
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.