dsh-input-prediction

uitested: passnpmMIT

Input prediction: the likely continuation of your draft appears as grey ghost text after the caret and Tab accepts it, and after each assistant turn 1-3 clickable follow-up suggestions appear above the input box and send on click. Ghost completion, suggestions and the suggestion count can be toggled

下载量 / Downloads
729
依赖体积 / node_modules
0.14 MB
测试时间 / Tested
2026-11-07
DSH 版本 / Version
0.2.2-rc.1

Install

dsh plugin --profile web add dsh-input-prediction

Sandbox test results

StageResult
1 install✓
2 list✓
3 mount✓
4 boot—

Four stages run in an isolated sandbox: install (network on) → list → mount → boot (last three with no network).

README

dsh-input-prediction

在 DSH 的输入框上做两件事:灰字续写(Tab 接受)和回复后推荐(点一下就发)。


English

A DSH plugin that predicts what you are about to type, using the current conversation and

your own writing style as context.

  • Ghost completion — while you pause in the composer, the most likely continuation of

your draft is rendered as grey text behind the caret. Press Tab to accept it; the text

lands in the input box as a normal, undoable edit and you can keep editing.

  • Follow-up suggestions — after each assistant turn, 1–3 candidate next messages appear

just above the input box (in the official conversation.input.dock slot). Click one to

send it directly.

  • Settings panel — Settings → Built-in plugins → “输入预测”: toggle ghost completion,

toggle suggestions, choose how many suggestions (1–3). Choices are stored in

$DSH_HOME/input-prediction.settings.json and apply immediately.

Install

# from the plugin marketplace: Settings → Plugin marketplace → search “input-prediction”
dsh plugin --profile desktop add dsh-input-prediction
# or straight from GitHub
dsh plugin --profile desktop add https://github.com/fishcg/dsh-input-prediction

Both halves hot-reload; no build step, no dependencies. Requires DSH >= 0.2.0-rc.2.

Configuration

Everything has a working default. The most common knob: reasoningEffort must stay off

(a completion is a dozen characters long — reasoning tokens would eat the whole budget and

return empty text). See the Chinese section below for the full config table.

License

MIT © 2026 fishcg


它做什么

两件事,都围着输入框转:

1. 灰字补全 —— 在输入框里用灰字补上你接下来最可能打的那句话,按 Tab 接受,文字落进输入框,还能继续改。

2. 回复后推荐 —— 每轮回答写完,在输入框正上方给 1–3 条你可能要发的下一条,点一下直接发送。

┌──────────────────────────────────────────────────────────┐
│ 我想查询 example-app 应用是否正常                         │  ← 「正常」是灰字
└──────────────────────────────────────────────────────────┘
   ↑ 你打到这里                ↑ 模型续写的,Tab 一下就到手

        ┌──────────────────────────────────────────┐
        │ 顺便把日志级别调成 debug  然后跑一遍看看   │  ← 点一下直接发送
        └──────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────┐
│ 发消息或创建任务, / 调用指令, @ 文件或对话                  │
└──────────────────────────────────────────────────────────┘
  • 灰字只画在光标后面,不动你的草稿;点推荐等价于你自己打完按 Enter(同一条提交链,可撤销地写进草稿再提交)。
  • 预测依据是当前会话上下文 + 你平时说话的口吻(把你最近几条消息单独喂给模型当样本)。
  • Tab 走 DSH 官方的插入通道(captureInsertion + insertText,带版本守卫),所以是一次可撤销的普通编辑,不是替换草稿。
  • 拿不准时模型会输出空串——宁可不提示,也不猜一句驴唇不对马嘴的。

安装

# 从插件市场:设置 → 插件市场 → 搜「输入预测」
dsh plugin --profile desktop add dsh-input-prediction          # npm
dsh plugin --profile desktop add https://github.com/fishcg/dsh-input-prediction   # GitHub

# 本地开发(本机就是这样装的)
dsh plugin --profile desktop add link:/Users/fish/dsh-input-prediction

插件由两个半区组成:

半区 · 文件 · 职责

宿主 · lib/index.js · 注册 /dsh-input-prediction/{hello,predict,suggest,settings,telemetry,transcript} 路由;从 sessionQuery 读会话、调 llm.stream 做流式补全、生成推荐候选、读写用户偏好

客户端 · lib/client.js · 找到 composer 的 Lexical 输入框,停顿后请求预测,把灰字画在光标处;回答结束请求推荐并画在输入框上方;接管 Tab;注册「插件设置」里的标签页

客户端半区是手写 CJS + 纯 DOM(不 import 任何 @deepseek-ai 的值,只经 exports.inject 取服务、require('react') 取平台 React),零构建。

回复后推荐(建议气泡)

  • 时机:这一轮回答结束之后(内核 uiSession.sessionStatus 的 running 从 true 变 false)且草稿为空时请求一次;页面刚打开、草稿为空时也会为最近一轮补一次。
  • 回答进行中不出候选:还在思考、正在跑工具、正在流式输出时,候选(renderChips()/requestChips() 里的 turnRunning())一律收起、不请求。灰字不受这条限制,见下节。
  • 点一下 = 直接发送:候选按钮 → setDraft(text) → 等编辑器投影落地(60ms 轮询,最多 1.5s)→ submit()。不成功会记 client:chip-send-failed,不会发出空消息。
  • 收起:右下角的 × 收起本批(记 client:chips-dismissed);开始打字、正在回答、切换会话也会自动隐藏。
  • 一轮一次:同一「对话版本」只请求一次,结果按 contextEpoch 校验,过期结果直接丢弃(不会把上一轮的候选贴到新对话上)。
  • 候选文本不超过 chipMaxChars(默认 40 字),最多 chipCount 条。

设置面板

入口:设置 → 内置插件 → 「输入预测」标签页(客户端注册到官方槽 settings.plugins.tab,order: 20)。

项 · 默认 · 说明

输入框灰字补全 · 开 · 关掉后不再请求预测、不画灰字、Tab 也不接管

回复后推荐 · 开 · 关掉后不再请求推荐,已有气泡立即收起

推荐条数 · 3 · 1 / 2 / 3 分段按钮

  • 面板里改的值写进 $DSH_HOME/input-prediction.settings.json(settingsFile 可改路径),立即生效,不用刷新页面,也不用重启桌面端。
  • 优先级:用户偏好文件 > patch 里的默认值。也就是说 cordis.patch.yml 里的 completionEnabled/chipsEnabled/chipCount 只是「出厂默认」,用户在面板里选过之后以文件为准(删掉那个 json 就回到默认)。
  • 写盘是「写 .tmp 再 renameSync」,不会写坏。

怎么确认它在跑

tail -f /tmp/dsh-input-prediction.log        # 把 debugLog 打开时才有

日志按行 JSON,看到这些就说明链路是通的:

事件 · 含义

client:ready · 客户端半区已加载(页面里)

client:host-contact · 客户端拿到了宿主路由与三个开关

client:settings-tab · 设置标签页注册结果({ok:true} = 已挂进「插件设置」)

client:settings-updated · 用户在面板里改了设置

client:chips · 拿到了推荐候选(带 visible 与屏幕矩形,能看出有没有真的画出来)

client:chips-failed / client:chip-send / client:chip-send-failed · 推荐请求失败 / 点了候选并发送 / 发送没成功

predict · 收到一次预测请求(带草稿)

context / suggest-context · 从会话里取了多少条上下文

stream-done · 模型这一次的 finish 原因、思考增量、原文

predict-done / suggest-done · 最终建议 / 推荐候选与耗时

client:accept · 用户按了 Tab,detail.how 为 insertText(官方通道)或 setDraft(回退)

settings / settings-updated · 宿主侧读到的偏好与落盘结果

页面控制台(如果开着 DevTools)另有一份:[input-prediction] 前缀。

配置

配置写在 cordis.patch.yml 里(或 profile 的 cordis.patch.yml 里同 id 覆盖):

- insert:
    - id: dsh-input-prediction
      name: dsh-input-prediction
      config:
        enabled: true
        provider: ''
        model: ''
        reasoningEffort: 'off'
        maxTokens: 160
        temperature: 0.3
        contextMessages: 16
        contextChars: 600
        maxSuggestionChars: 60
        styleHint: ''
        # —— 下面这些是「出厂默认」,用户偏好文件优先 ——
        completionEnabled: true
        chipsEnabled: true
        chipCount: 3
        chipMaxChars: 40
        chipsMaxTokens: 320
        chipsTemperature: 0.7
        settingsFile: ''
        debugLog: ''


…(truncated)

Rendered from the README published on npm. Formatted only, not edited.

Versions

Published on npm::2,最后更新 2026-10-12

Links

GitHub · Homepage · npm

Same category