返回目录
Agent 与会话 插件

dsh-smart-prompt

Arrosam/dsh-smart-prompt

Personal fork of dsh-improve-prompt (MIT) — smart prompt refinement for DSH

Stars
2
Forks
0
Issues
0
更新
7 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:Arrosam/dsh-smart-prompt

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-smart-prompt Awesome DSH Plugin

A DSH plugin that turns a rough composer draft into a clear prompt an agent can act on, in one click.

Type your request the way you would say it, click the ✦ button next to Send, and the draft is replaced with a cleaner version. Paths, names, numbers, URLs and code from your draft are kept exactly as you wrote them.

Install

In DSH, open Plugins → Add plugin and enter dsh-smart-prompt. Or from a terminal:

dsh plugin --profile web add dsh-smart-prompt

Restart DSH. The ✦ button appears in the composer, just left of Send. No API key is needed: the plugin uses the models you have already set up in DSH.

To uninstall:

dsh plugin --profile web remove dsh-smart-prompt

Use it

  1. Type a draft, for example:

    can you change maxRatioFor in src/host/config.ts to 2.5 and check it with pnpm build

  2. Click ✦. After a few seconds the draft becomes:

    Change maxRatioFor in src/host/config.ts to 2.5, then verify with pnpm build.

  3. A short note above the composer shows the result: how many hard facts were kept, the length change, and the time taken.

  4. Not happy with it? Use the Revert | Retry | Iterate buttons next to ✦:

    • Revert goes back one version: the improved prompt before your last Iterate, or your original draft.
    • Retry generates a new version from the same starting point as the current one.
    • Iterate improves the improved prompt again, with the method that made it.

    They stay available until you edit or send the draft.

Click ✦ again while it is working to cancel. If anything goes wrong (no model, timeout, network error), your draft is left untouched and a short error explains why.

Slash commands work too: in /bugfix <text> the command stays as is and only the text is rewritten.

Modes

Switch the improvement method fast by holding the ✦ star in the composer, or choose it in Settings → Plugins → dsh-smart-prompt. Both change the same saved setting, so they always agree. Hold the star for a moment (or start sliding it sideways) and a capsule-shaped mode bar opens above it, floating over the page without moving anything. Left to right it shows Detailed ← Standard → Light, each with its icon and name, with the active mode under your pointer. Slide to the mode you want and let go: the setting is saved at once. Sliding past either end stays on that end (it does not wrap around); letting go without sliding, or pressing Esc, keeps the mode. A click without holding or sliding still improves the draft.

The star's icon shows the active mode, also after a reload: a stretched star writing on a page for Detailed, the usual ✦ for Standard, and a lightning bolt for Light. While a rewrite runs, each icon has its own animation: the ✦ spins (Standard), the star-pen writes its line on the page again and again (Detailed), and the lightning bolt strikes with a quick double flash (Light).

The first time the star appears, a small window above the composer explains the hold-and-slide and what each mode does. It shows once per browser and never blocks the composer: keep typing, or close it with Got it or ×.

  • Standard (default) — restructures the draft so an agent can execute it: deliverable, constraints, steps, output format. It never leaves (TBD: …) notes: what only you can decide is asked one question at a time (see Follow-up questions), and once asking ends the remaining gaps are filled with guesses listed under Guessed details at the end of the rewrite.
  • 详细模式 (Detailed) — goes further: ordered next steps, the cautions to watch while executing, and the exact standard for every concrete detail. The prompt sets no length target; the bar is that the executing agent never has to guess a detail. It shares Standard's settings, including the optional length ceiling (standardMaxRatio, uncapped by default), and Standard's follow-up questions: one at a time, no (TBD: …) notes, guesses listed under Guessed details once asking ends. When the draft only names a direction instead of a result — a short qualifier like "softer", a request like "give me a sense of…", an analogy like "light like feather", a mood reference like "a vibe of kawaii bass" — it asks what exactly you want and points you at Stardea (星念) for candidate answers.
  • Light — only removes filler and clears up ambiguity, keeping the draft's structure (at most 2× the draft).

Attachments

Images and files attached in the composer are sent to the refining model along with the draft, so "fix the error in this screenshot" or "follow the attached spec" is rewritten with them in view. Text files are read, up to the first 20,000 characters of each. Other files are named but not read. The attachments stay in the composer and still go to the agent when you send. Wait for file uploads to finish before you click ✦.

When session context is included (see Session context), images you attached to those earlier messages are sent as well.

Follow-up questions

If the draft is missing something only you can answer (which endpoint, what limit, which option), a panel opens in place of the composer with a few short questions. Your original draft is shown at the top of the panel so you can see what you wrote. Answer the questions and the prompt is rewritten again with your answers included.

  • Answer "I don't know" and the prompt tells the agent to find it out itself, or to suggest options and carry on with the most reasonable one.
  • Skip leaves every question unanswered. In Light mode you get the first rewrite with (TBD: …) notes for the gaps; Standard and Detailed modes guess instead (see below). A question you leave empty is skipped the same way.
  • × closes the panel and cancels the refine. Your draft is not changed.
  • If the request fails after you answered, click Retry on the error bubble. Your answers are reused, so you are not asked again.
  • No questions are asked when the draft already has what it needs.

In Standard and Detailed mode the questions come one at a time. After each answer the prompt is rewritten and, if something only you can decide is still missing, the next question opens, until nothing is missing or Follow-up questions (the limit, default 5) have been asked in total. Then, and also when you click Skip or questions cannot be asked at all (limit 0, or an API request without a session), the remaining gaps are filled with guesses, and each guess is listed under Guessed details (## 猜测补充 for a Chinese draft) at the end of the rewrite, so you can see and correct them. × still cancels without changing your draft. In Light mode every question comes in one panel, and the prompt is rewritten once with your answers.

Stardea (星念)

Not sure how to answer a question? Click the Stardea button next to it. Stardea suggests up to 4 answers (set Stardea ideas per click). It finds them by searching the current conversation, proposing its own ideas, and, if you turn on Stardea web search, searching the web with DSH's web search. Each suggestion is labeled with where it came from.

  • Tick one or more suggestions, with or without your own words. Everything you tick and type becomes that question's answer.
  • None of them fit? Click Stardea again. It adds more suggestions below the earlier ones, each different from them, and the earlier ones stay.
  • Each click searches for up to Stardea search rounds rounds (default 1; see Settings). With 0 rounds, Stardea only proposes its own ideas. Web search is off by default, and works only when DSH has a web search provider set up.

Next-step suggestions

With the composer empty, the ✦ button predicts the message you're most likely to type next, in any mode, so you can pick it instead of typing it.

  • When it's ready: once the agent has finished a reply and the composer is empty, four small rays appear around the button's icon. The button waits while the agent is still replying, and in a new session until its first reply.
  • Open: click the button. A What to ask next panel opens just above the composer with 2 suggestions as cards, the likeliest first. They're your probable reaction to the agent's last reply, written the way you write: an answer if it asked you something, a check or a change if it finished something. They're read from the latest turns of the conversation and the workspace notes in SMART-PROMPT.md, and written in the language of your latest message. The panel is part of the composer, so it pushes the messages up rather than covering them. While it's open, the button's icon fades and its rays close into an ×.
  • Pick one: click a card. Its sentence goes into the composer, ready to edit or send, and the panel closes.
  • More: click ✦ 2 more at the bottom of the panel. Two new suggestions are added as a new row, each different from the earlier ones.
  • Close: click the button (now an ×) or the panel's ×. Typing in the composer closes it too. The suggestions are kept: click the button again with the composer empty and the same ones come back, with no new model call.
  • A new reply starts afresh: once the agent replies again, the old suggestions are dropped and the next click makes new ones.

Suggest automatically

Turn on Suggest next steps automatically in Settings and suggestions are made after every agent reply, even while you're looking at another session. When you come back with an empty composer, the panel opens by itself. If you close it, it stays closed until the agent's next reply. This setting is off by default, because it costs one extra model call per agent reply.

Token use

When a refine finishes, the note above the composer shows its tokens as input(cached) - output. For example, tokens 1200(3400) - 560 means 1,200 input tokens that missed the cache, 3,400 input tokens read from the cache, and 560 output tokens. The figures cover every model call of the refine, Stardea included. They appear only when the model provider reports token use.

All model calls of one refine continue a single conversation, so each call starts with the previous call's request unchanged. Providers with prompt caching then bill those repeated tokens as cache hits. Lookup results found earlier, including those found by Stardea, stay available to the later calls.

What it guarantees

  • Nothing important is lost. Before rewriting, the plugin lists the hard facts in your draft: file paths, identifiers, numbers and versions, URLs, code, and @mentions. It then checks that each one survived. If the model dropped one, it gets one more try. If a fact is still missing, it is added back at the end under "Preserved original details".
  • Nothing is invented. A vague draft is not padded with made-up requirements. Gaps are asked about instead. In Standard and Detailed modes, a gap still open when asking ends is filled with a guess that is listed under Guessed details; in Light mode it is marked (TBD: …).
  • No runaway length in Light mode. A Light rewrite may grow to 2× the draft, and always at least 600 characters. A longer result gets one chance to shorten. If it is still too long, it is discarded and your draft is kept. Standard and Detailed modes have no length cap by default (set standardMaxRatio to add one).
  • Next-step suggestions cost one model call each time new ones are made: on the first click after an agent reply, on each 2 more, and, with Suggest next steps automatically on, after every agent reply. Reopening the panel costs nothing.
  • Few model calls per click: the rewrite, one more rewrite per round of follow-up questions (in Light mode only when you answered; in Standard and Detailed modes also after Skip), and one repair. Each lookup round adds one call, up to Session lookup rounds (default 3). Each Stardea click adds one call, plus up to Stardea search rounds more (default 1).

Settings

Open Settings → Plugins → dsh-smart-prompt (DSH 0.2 or later).

Setting Options
Improvement method Also switched by holding the ✦ star in the composer and sliding left or right on the mode bar (Detailed ← Standard → Light); the hint under this setting says so. Standard: restructures the draft so an agent can execute it directly, asking follow-up questions one at a time. Detailed (详细模式): writes out the ordered next steps, the cautions to watch while executing, and the exact standard for every concrete detail — the prompt sets no length target, so the agent never has to guess one. Light: only removes filler and clears up ambiguity.
Model used to improve prompts Conversation model: uses the model chosen in the current conversation, or your DSH default. Dedicated model: always uses the model you pick here, with its own reasoning effort.
Follow-up questions The most questions to ask when the draft is missing information. Default 5.
Session lookup rounds The most rounds of searching and reading this conversation while rewriting, when the draft depends on something said earlier. 0 to 10, default 3. 0 turns lookups off.
Stardea ideas per click The most new suggestions each Stardea click adds. 1 to 8, default 4.
Stardea search rounds The most search rounds each Stardea click may use. 0 to 10, default 1. 0 means Stardea only proposes its own ideas.
Stardea web search Lets Stardea search the web with DSH's web search, as well as the conversation. Off by default. Needs Stardea search rounds above 0 and a web search provider set up in DSH.
Suggest next steps automatically Makes 2 next-step suggestions after every agent reply, and shows them when you come back to a session with an empty composer. Off by default. One extra model call per reply.

Session context

When a draft can't stand on its own, such as "do the same for that endpoint" or a very short draft, the plugin includes the last few turns of the conversation: your messages with the images you attached to them, and the assistant's text replies.

If the draft depends on something said earlier that these turns don't cover, the refining model can search the conversation and read earlier messages, for up to the number of rounds set in Session lookup rounds. It can search and read only your messages and the assistant's replies.

Tool results, injected context and source code the agent read are never sent.

Advanced

Configuration

Other options live in the profile's cordis.patch.yml. All are optional; the values below are the defaults:

- insert:
    - id: dsh-smart-prompt
      config:
        lightMaxRatio: 2
        standardMaxRatio: 0        # 0 = no length cap
        acceptanceCriteria: false  # Standard/Detailed: add a checkable "done when" line
        temperature: 0.3
        maxTokens: 32000
        timeoutMs: 180000
        maxInputChars: 20000
        contextTurns: 3            # 0 turns session context off
        contextChars: 6000
        smartContext: true
        knowledgeChars: 4000       # SMART-PROMPT.md size limit; 0 turns it off
        fidelityGate: true
        lengthGate: true
        reasoningEffort: low       # effort used with the conversation model
        logFailures: true

Custom prompts

The rewriting instructions are plain Markdown files in prompts/:

  • discipline.md: the shared rules.
  • standard.md, detailed.md and light.md: one file per mode.
  • questions.md: when and how to ask follow-up questions.
  • answers.md: how to fold your answers in, including "I don't know".
  • attachments.md: how to use the draft's attachments and earlier images.
  • session-lookup.md: when to search the conversation ({{maxRounds}} is replaced with the round limit).
  • stardea.md: how Stardea proposes answer ideas ({{maxIdeas}} is replaced with the number of ideas per click, {{maxRounds}} with the search rounds per click).
  • next-steps.md: how next-step suggestions are written ({{count}} is replaced with the number per request, 2).

To change them, put a file with the same name in $DSH_HOME/dsh-smart-prompt/prompts/. Your file is used instead of the built-in one.

Local HTTP API

These endpoints accept local connections only:

  • GET /dsh-smart-prompt/api/config returns the current mode and limits.
  • POST /dsh-smart-prompt/api/improve with { "text": "...", "sessionId": "...", "mode": "standard" } returns the rewritten text and its quality figures (meta.usage holds { input, cached, output } tokens when the provider reports them). An optional attachments array takes the composer's attachment wire form: { "type": "image", "mediaType": "image/png", "data": "<base64>" }, or { "type": "file", "receiptId": "..." } for a file already uploaded to that session. With "interactive": true and a sessionId, the reply may instead be { "ok": true, "ask": { "runId": "...", "questions": [{ "id": "q1", "question": "..." }] } }. The refine then waits for one of these:
    • POST /dsh-smart-prompt/api/stardea with { "runId", "questionId" } returns { "ok": true, "ideas": [{ "id", "text", "source": "web" | "conversation" | "proposal" }] }. Only new ideas are returned.
    • POST /dsh-smart-prompt/api/answer with { "runId", "answers": [{ "id": "q1", "selected": ["idea text"], "custom": "own words" }] } returns the same result as /improve. Send "answers": [] to skip every question.
    • POST /dsh-smart-prompt/api/cancel with { "runId" } ends the refine as cancelled.
  • POST /dsh-smart-prompt/api/suggest with { "sessionId": "...", "request": "get" } returns the next-step suggestions for the conversation's latest reply as { "ok": true, "key": "...", "suggestions": ["..."] }, making 2 only if none exist yet. "request": "more" adds 2 new ones. key changes when the agent replies again. A session with no finished reply returns { "ok": false, "code": "NO_CONTEXT" }.

Build from source

pnpm install
npx tsc -p tsconfig.json   # host half → lib/
npx tsdown                 # browser half → lib/client.js
node --test test/*.test.mjs

The built lib/ is committed, so installing from GitHub needs no build.

Credits

Forked from dsh-improve-prompt by hoyyang. See CONTRIBUTORS.

License

MIT

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类Agent 与会话
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: prompt、persona。