dsh-composer-predictions 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-composer-predictions contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,138 @@
1
- # Temporary Holding Version
1
+ # dsh-composer-predictions
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ AI ghost text for the message box in the DeepSeek Harness Web GUI.
4
+
5
+ - **Next message** — after the agent replies, the empty composer shows a
6
+ streamed suggestion for your likely next message. **Tab** accepts it as an
7
+ editable draft.
8
+ - **Inline continuation** — while you pause mid-draft with the caret at the end,
9
+ the composer completes that sentence where the caret is. **Tab** accepts the
10
+ completion without sending anything.
11
+
12
+ Up to three candidates are requested per call. **Alt+Down / Alt+Up** cycle them,
13
+ **Escape** dismisses one, and typing aborts any in-flight request and hides the
14
+ ghost.
15
+
16
+ ## Install
17
+
18
+ Inside the DeepSeek Harness Web GUI: **Plugins → Install**, then enter
19
+
20
+ ```
21
+ dsh-composer-predictions
22
+ ```
23
+
24
+ Or from a terminal with a DSH profile:
25
+
26
+ ```bash
27
+ dsh plugin --profile <name> add dsh-composer-predictions
28
+ ```
29
+
30
+ Then restart the Harness (a profile addition is applied at boot). A linked
31
+ source checkout is picked up again when the profile recomposes.
32
+
33
+ ## Use
34
+
35
+ 1. Send a message and let the agent finish — a dimmed next-message suggestion
36
+ streams in with a `Tab` keycap.
37
+ 2. Or type anything and pause with the caret at the end of the draft — a
38
+ continuation ghost appears right after the caret.
39
+ 3. **Tab** turns the current candidate into an editable draft.
40
+ **Alt+Down** shows the next candidate, **Alt+Up** the previous one.
41
+ **Escape** dismisses, and typing hides the ghost without sending anything.
42
+ 4. Accepting never submits the message; edit it or press Enter yourself.
43
+
44
+ ![Next-message ghost](docs/next-message-ghost.png)
45
+
46
+ ![Inline continuation ghost](docs/continuation-ghost.png)
47
+
48
+ ## How it works
49
+
50
+ - The **Host half** registers two routes on the Harness web server:
51
+ - `POST /composer-prediction` — JSON (`suggestion` plus `suggestions`), kept
52
+ for compatibility with older clients.
53
+ - `POST /composer-prediction/v2` — Server-Sent Events: `meta`, `delta`
54
+ (streamed text), then `done` with the final candidate list.
55
+ - A request carries `{ sessionId, mode, draft }`, where `mode` is `next` or
56
+ `continue`. The Host reads the Session tail (`deriveMessages()`), adds a short
57
+ list of recent tool calls and their outcomes, and renders one bounded prompt.
58
+ `next` declines when the agent has not produced a reply; `continue` includes
59
+ the draft text that ends at the caret.
60
+ - One small auxiliary model call runs through `ctx.llm` over that prompt. The
61
+ suggestion uses the Session's own provider/model at the model's lowest
62
+ reasoning effort unless `provider`/`model` are configured. Model output is
63
+ split into up to `maxSuggestions` clean one-line candidates: numbering,
64
+ bullets and quotes are stripped, `NONE` produces no suggestion, and drafts the
65
+ model restated are trimmed. A continuation keeps the model's leading
66
+ separator space; the Client adds one only when a non-CJK draft and
67
+ continuation would otherwise glue two words together.
68
+ - Results are cached per Session sequence (and per draft for continuations), so
69
+ a repeated request for unchanged context costs no model call.
70
+ - The **Client half** registers into `conversation.input.overlay`, debounces
71
+ requests (600 ms after a turn settles, 500 ms after a typing pause), aborts
72
+ superseded requests, and renders the ghost over the empty composer or at the
73
+ caret. It measures the resident editor, so the ghost follows its padding,
74
+ line height, and scroll position.
75
+ - Nothing is written to the Session log, and predictions are not counted as
76
+ conversation turns.
77
+
78
+ ## Configuration
79
+
80
+ Override the row in your profile's `cordis.patch.yml`:
81
+
82
+ ```yaml
83
+ - id: composer-predictions
84
+ name: dsh-composer-predictions
85
+ config:
86
+ maxOutputTokens: 220 # 16..4096
87
+ timeoutMs: 20000 # 1000..120000
88
+ maxMessages: 10 # 2..40 messages of transcript
89
+ maxChars: 8000 # 500..40000 characters of transcript
90
+ maxSuggestions: 3 # 1..5 candidates per request
91
+ maxToolNotes: 6 # 0..20 recent tool calls in the prompt
92
+ provider: deepseek-account # optional fixed route; both keys or neither
93
+ model: deepseek-flash
94
+ reasoningEffort: off # off | low | high | max; omitted = model's lowest
95
+ ```
96
+
97
+ A route override is a pair: half a pair is ignored and the Session route wins.
98
+ A suggestion longer than 240 characters is cut at a word boundary.
99
+
100
+ ## Privacy and limits
101
+
102
+ - The conversation tail, recent tool activity and (in continuation mode) the
103
+ draft are sent to the configured model route, just like a normal turn.
104
+ Nothing else leaves the machine.
105
+ - Predictions are suggestions only; they never run tools or change the Session.
106
+ - Accepting a suggestion and then editing it is a normal draft: it is only sent
107
+ when you submit it.
108
+ - Prediction calls do not appear in the Session log or its token meter.
109
+ - Requires a Harness build that provides `conversation.input.overlay`,
110
+ `ctx.llm`, and `sessions.deriveMessages()`.
111
+
112
+ ## Test
113
+
114
+ ```bash
115
+ node --test
116
+ ```
117
+
118
+ Probe a running GUI to watch the stream and cache timing:
119
+
120
+ ```bash
121
+ node tools/live-probe.mjs <sessionId> continue "Can you also"
122
+ ```
123
+
124
+ The 22 cases drive both Host endpoints against a fake Session and LLM service:
125
+ prompt contents (including tool activity), candidate normalization and spacing,
126
+ streaming events, per-turn and per-draft caching, route and effort selection,
127
+ failure reporting, and request validation. Client helpers (continuation
128
+ joining, SSE parsing, streaming candidates) are unit-tested through the bundle's
129
+ internal `__testing` export.
130
+
131
+ ## Uninstall
132
+
133
+ Disable **Composer predictions** in **Plugins → Installed**, or remove it with
134
+ `dsh plugin --profile <name> remove dsh-composer-predictions`.
135
+
136
+ ## License
137
+
138
+ MIT