rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:zzyyun/dsh-prompt-enhance
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
一个独立的 DeepSeek Harness(DSH)插件。它在输入框底部的工具行中、模型选择器左侧加入一个提示词增强按钮。点击后,插件读取当前会话的项目代码与对话上下文,调用当前模型把草稿改写成更明确、可执行的提示词;结果直接替换输入框内容,但不会自动发送。
按钮只在用户明确点击时触发,不监听输入、不自动改写、不写入会话日志,也不会修改项目文件。
本仓库就是可安装的 DSH bundle 根目录,不包含 DSH 主仓库源码。
git clone https://github.com/zzyyun/dsh-prompt-enhance.git
cd dsh-prompt-enhance
# 先跑无密钥 Host 冒烟测试
node tests/host.smoke.mjs
然后在 DSH Web GUI 的插件管理中使用 install_bundle,target 指向上面的克隆目录绝对路径(不要手改 profile 文件)。安装后刷新页面,模型选择器左侧会出现星芒按钮,空草稿时禁用。
插件是一个标准 DSH bundle,由两半组成:
| 半边 | 入口 | 注册内容 |
|---|---|---|
| Host | index.js |
promptEnhance 服务 + Typert Remote 描述符 promptEnhance/enhance |
| Client (Web) | client.js |
conversation.input.right 槽位中的一个按钮 |
cordis.patch.yml 把 Host 行插入当前 profile:
- insert:
- id: prompt-enhance
name: '@local/dsh-prompt-enhance'
config: { ... }
package.json 声明 dsh.bundle.patch 与 dsh.client,安装后由 plugin_manager 写入 profile 的 bundle 列表。Host 半边通过 ctx.provide('promptEnhance', service) 暴露服务,并用 ctx.typert.register(...) 注册严格描述符:
agentId 走 Gateway 的 agent lookup,由 Gateway 校验该 Agent 属于当前连接;request 是 { text } JSON;signal 用于取消;{ ok: true, text, model, context, elapsedMs } 或 { ok: false, reason, message }。Client 半边以 window.__ModuleLoader__.load({ id, factory }) 形式加载,只 require('react') 与共享的 @deepseek-ai/dsh-client-ui-primitives。它注册到:
ctx.slots.inject('conversation.input.right', () => ctx.slots.register({
name: 'conversation.input.right',
id: 'prompt-enhance',
order: 20,
locale: 'promptEnhance',
}, Component))
conversation.input.right 是输入框工具行的右侧列表,模型选择器就在同一行。按钮因此自然落在模型选择器左边,不会替换或覆盖 conversation.input.model 单座槽位。
调用链:
按钮 onClick
→ ctx.connection.rpc.call('/api', 'promptEnhance/enhance',
{ args: { agentId: sessionId, request: { text: draft } } })
→ Gateway agent lookup + 参数校验
→ Host service.enhance(agent, request, signal)
→ ctx.llm.stream(...)
→ 返回增强文本
→ inputActions.setDraft(text)
ctx.get('workingDirectory').get(session);取不到时回退到 session.header.cwd。ctx.get('fs') 对根目录做有界广度优先索引,默认最多扫描 400 个目录、8000 个文件、其中源码最多 800 个,深度 7;非源码只保留入口文档、根配置和草稿/最近工具显式提到的文件,避免某个包的清单文件抢占源码预算。node_modules、dist、build、.git、虚拟环境、缓存目录、二进制/大文件,以及 .env、私钥、证书等敏感文件名。AGENTS.md/README/package.json 等入口文件、草稿里显式提到的路径(@文件、src/foo.ts)、最近工具调用涉及的路径、草稿关键词、src/ 下的源码文件权重更高;测试、构建配置和大文件权重更低。packages/<group>/<pkg>、apps/<app> 分组,尽量每个工作区单元取一个,避免 8 个文件全部来自同一个包。source.kind === 'user'),最多 10 条、6000 字符;插件注入的技能正文、子目录 AGENTS.md 等合成上下文不进入增强上下文。助手回复默认不进入,避免把上一轮实现细节或测试夹具误当成当前草稿的意图;需要时把 includeAssistantMessages 设为 true。purpose: 'prompt-enhance',不写入主会话),不会追加用户消息或助手消息,也不会触发 Agent 回合。优先级:
provider + model(显式覆盖);config.provider / config.model;agentDefaultModel 的当前选择。三者都取不到时返回 no-route,不会静默换模型。
系统提示词要求模型:
按钮交互的判定范围:
/ 开头、或输入框处于提交/裁决阶段时按钮禁用;悬停标题说明原因。inputActions.setDraft 替换草稿,光标与撤销栈由输入框自身管理;用户可继续编辑,或按 Ctrl/Cmd+Z 撤销。Toast 之外的全局状态;成功/失败通过共享的瞬时 Toast 播报,不遮挡草稿。配置位于 cordis.patch.yml 的 prompt-enhance 行;全部字段有默认值,未知字段或越界值会在加载时直接报错。
| 字段 | 默认 | 范围 | 作用 |
|---|---|---|---|
maxDraftChars |
8000 | 200–20000 | 草稿长度上限 |
maxResultChars |
12000 | 200–40000 | 增强结果上限 |
maxFiles |
8 | 1–20 | 读取的项目文件数 |
maxFileBytes |
14000 | 1 KB–64 KB | 单文件读取上限 |
maxTotalBytes |
64000 | 4 KB–200 KB | 文件+树+对话总预算 |
maxConversationMessages |
10 | 0–40 | 对话消息条数 |
maxConversationChars |
6000 | 0–30000 | 对话字符预算 |
includeAssistantMessages |
false | 布尔 | 是否把助手回复也纳入上下文 |
maxTreeEntries |
140 | 0–600 | 项目树行数 |
maxScanDirs |
400 | 0–400 | 索引目录数 |
maxIndexFiles |
8000 | 0–12000 | 索引文件数 |
maxIndexSources |
800 | 0–4000 | 索引源码文件数 |
maxIndexedFileBytes |
250000 | 1 KB–1 MB | 可索引文件大小 |
maxDepth |
7 | 0–8 | 索引深度 |
maxOutputTokens |
1400 | 128–16384 | 增强输出 token 上限 |
timeoutMs |
35000 | 1–180 秒 | 模型调用超时 |
temperature |
0.2 | 0–1 | 增强采样温度 |
provider / model |
未设置 | 成对出现 | 强制指定模型路由 |
git clone https://github.com/zzyyun/dsh-prompt-enhance.git
cd dsh-prompt-enhance
# 通过 plugin_manager 安装(不要手改 profile 文件)
# action: install_bundle, target: <克隆目录的绝对路径>
安装后:
cordis_inspect_query 的 Slots.listSubTree 应显示 conversation.input.right 中有 prompt-enhance;promptEnhance/enhance 做端到端验证。无密钥的 Host 冒烟测试:
node tests/host.smoke.mjs
它用内存 double 覆盖:Typert 描述符注册、项目/对话选取、路由解析、输出清洗、空草稿/斜杠命令拒绝、无文件系统降级、配置校验。
.
├── index.js Host 服务、Remote 描述符、索引/选取/LLM 调用
├── client.js Web 按钮、加载态、Toast、草稿替换
├── cordis.patch.yml Host 行与默认配置
├── package.json bundle + client 清单
├── locale/{en,zh}.json 插件标题/描述
├── icon.svg 插件图标
└── tests/host.smoke.mjs 无密钥冒烟测试
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek。