opencode-quill 0.8.0 → 0.9.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes are documented in this file using
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.9.1] - 2026-11-27
8
+
9
+ ### Fixed
10
+
11
+ - **predictor:** Require stronger confidence on weak two-letter prefixes (#33)
12
+
13
+ ## [0.9.0] - 2026-11-27
14
+
15
+ ### Added
16
+
17
+ - **composer:** Add opt-in suggestion alternatives (#32)
18
+
7
19
  ## [0.8.0] - 2026-11-27
8
20
 
9
21
  ### Added
@@ -175,6 +187,8 @@ All notable changes are documented in this file using
175
187
  - `/quill` command and command palette action to toggle autocomplete.
176
188
  - Local installer script, full test suite, CI workflows, and release tooling.
177
189
 
190
+ [0.9.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.0...v0.9.1
191
+ [0.9.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.8.0...v0.9.0
178
192
  [0.8.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.1...v0.8.0
179
193
  [0.7.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.0...v0.7.1
180
194
  [0.7.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.4...v0.7.0
package/README.md CHANGED
@@ -201,8 +201,9 @@ Restart OpenCode after editing `cli.json`.
201
201
  | `minSuggestedWordLength` | `number` | `0` | Minimum number of characters in a suggested word, for both prose and shell suggestions; `0` allows any length. |
202
202
  | `acceptKeys` | `string[]` | `["tab", "right"]` | Keys that accept and insert the active word suggestion. |
203
203
  | `dismissKeys` | `string[]` | `["escape"]` | Keys that dismiss the visible suggestion without inserting. |
204
- | `cycleNextKeys` | `string[]` | `[]` | Optional keys for the next confident word suggestion. |
205
- | `cyclePreviousKeys` | `string[]` | `[]` | Optional keys for the previous confident word suggestion. |
204
+ | `cycleNextKeys` | `string[]` | `[]` | Opt-in keys for the next visible word suggestion, for example `["alt+n"]`. |
205
+ | `cyclePreviousKeys` | `string[]` | `[]` | Opt-in keys for the previous visible word suggestion, for example `["alt+p"]`. |
206
+ | `summonKeys` | `string[]` | `[]` | Opt-in keys to show candidates when no suggestion is visible, for example `["ctrl+y"]`. |
206
207
 
207
208
  `completeAtLineEnd` uses prose context only up to the cursor while checking
208
209
  code and attachment ranges across the full draft. It inserts only missing
@@ -211,12 +212,16 @@ replacements remain limited to chip-free draft ends. The suggestion must fit
211
212
  the visible cursor row; it never overwrites the next line. Acceptance preserves
212
213
  later lines, attachment metadata, host callbacks, and native undo/redo.
213
214
 
214
- Cycling changes only the ghost text; Tab still accepts the selected suggestion.
215
- Alternatives use the same confidence and typo guards as the best suggestion.
216
- The ranked list is capped at five, wraps in either direction, and resets when
217
- the draft, cursor, attachment ranges, or learned model changes. Alternatives
218
- that do not fit the visible cursor row are skipped. Without a visible,
219
- eligible alternative, cycle keys fall through to OpenCode.
215
+ Quill shows one inline suggestion by default. Configure a cycle binding to
216
+ browse alternatives. A faint counter such as `1/3` shows which one is selected
217
+ when space allows. Cycling changes only the ghost text; Tab accepts the
218
+ selected suggestion. The list wraps and skips alternatives that do not fit on
219
+ the cursor row. Without a visible alternative, cycle keys fall through.
220
+
221
+ Summon is off by default. A configured summon key can show lower-confidence
222
+ candidates for the current draft when no suggestion is visible. It falls
223
+ through when Quill has no eligible candidate. Editing the draft or moving the
224
+ cursor resets the summoned list.
220
225
 
221
226
  Custom keybindings can also be overridden using OpenCode's standard
222
227
  `keybinds` map in `cli.json`:
@@ -224,10 +229,11 @@ Custom keybindings can also be overridden using OpenCode's standard
224
229
  ```jsonc
225
230
  {
226
231
  "keybinds": {
227
- "quill.accept": "ctrl+y",
232
+ "quill.accept": "tab",
228
233
  "quill.dismiss": "ctrl+g",
229
234
  "quill.next": "alt+n",
230
- "quill.previous": "alt+p"
235
+ "quill.previous": "alt+p",
236
+ "quill.summon": "ctrl+y"
231
237
  }
232
238
  }
233
239
  ```
@@ -246,9 +252,8 @@ handlers remain in control. Dialogs and selections also suppress Quill.
246
252
  - `/quill shell on` / `/quill shell off` — Set shell-mode autocomplete explicitly.
247
253
  - `/quill clear casing` (alias `/quill reset casing`) — Forget only the learned word casing (`OpenCode`, `GitHub`), keeping the vocabulary and phrases.
248
254
  - `/quill clear` (alias `/quill reset`) — Erase everything Quill has learned from your prompts and shell commands.
249
- - `quill.next` / `quill.previous` — Keymap commands for cycling visible word
250
- alternatives; no default bindings. Configure the cycle options above or
251
- OpenCode's `keybinds` map.
255
+ - `quill.next` / `quill.previous` / `quill.summon` — Keymap commands for cycling
256
+ or summoning word alternatives.
252
257
  - **Command Palette (`Ctrl+P`)** — Includes **Word autocomplete: on/off** and
253
258
  **Clear word autocomplete history**.
254
259
 
@@ -288,8 +293,9 @@ Quill learns from your own submitted prompts, never from assistant output:
288
293
  - **Current draft:** words already in the draft get a small boost.
289
294
  - **Confidence gating:** a suggestion is shown only when it clears a
290
295
  confidence threshold, which is stricter for next-word predictions than for
291
- prefix completions and, in prose, for single-letter prefixes. If a typed
292
- prose prefix of two or more letters is already a confident word, a longer
296
+ prefix completions. In prose, single-letter prefixes and two-letter prefixes
297
+ without repeated context also require higher confidence. If a typed prose
298
+ prefix of two or more letters is already a confident word, a longer
293
299
  word is also offered when it scores at least 40% as high in the current
294
300
  context (typing `local` offers `locally`). Shell mode shows nothing when
295
301
  the typed command is already the most likely word.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-quill",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "OpenCode prompt autocomplete: local n-gram word and next-word prediction shown as inline ghost text in the TUI composer, accepted with Tab.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -48,7 +48,8 @@
48
48
  "test:changelog": "bash tests/changelog.sh",
49
49
  "typecheck": "tsc --noEmit",
50
50
  "lint:sh": "for script in install.sh tests/*.sh scripts/*.sh; do bash -n \"$script\" || exit; done",
51
- "prepublishOnly": "bun run test && bun run typecheck"
51
+ "prepublishOnly": "bun run test && bun run typecheck",
52
+ "eval": "bun scripts/eval.ts"
52
53
  },
53
54
  "dependencies": {
54
55
  "@opentui/core": "^0.9.7",
package/src/ghost.ts CHANGED
@@ -42,7 +42,7 @@ export function findComposer(marker: Renderable | undefined, isEditor: (node: Re
42
42
  export class ComposerGhost {
43
43
  private shown: { text: string; offset: number; prediction: Prediction; marks: string; revision: number; predictor: WordPredictor } | undefined
44
44
  private dismissed: { text: string; offset: number } | undefined
45
- private memo: { text: string; offset: number; marks: string; revision: number; predictor: WordPredictor; predictions: Prediction[]; index: number } | undefined
45
+ private memo: { text: string; offset: number; marks: string; revision: number; predictor: WordPredictor; predictions: Prediction[]; index: number; summoned: boolean } | undefined
46
46
  private disposed = false
47
47
  private readonly draw: (buffer: OptimizedBuffer, delta: number) => void
48
48
 
@@ -54,6 +54,7 @@ export class ComposerGhost {
54
54
  private readonly renderer: CliRenderer,
55
55
  private readonly completeAtLineEnd = false,
56
56
  private readonly shellPredictor?: WordPredictor,
57
+ private readonly showAlternativeCounter = () => false,
57
58
  ) {
58
59
  this.draw = (buffer) => { if (!this.disposed) this.paint(buffer) }
59
60
  renderer.addPostProcessFn(this.draw)
@@ -110,14 +111,14 @@ export class ComposerGhost {
110
111
  if ((marks.length || offset !== text.length) && predictions[0]?.replace) predictions.length = 0
111
112
  else if (marks.length || offset !== text.length) predictions.splice(0, predictions.length, ...predictions.filter((prediction) => !prediction.replace))
112
113
  const last = this.shown
113
- if (query && !query.next && offset === text.length && last && last.offset === last.text.length && this.memo?.index === 0 && last.revision === revision && last.predictor === predictor && last.marks === signature && !last.prediction.replace && text.startsWith(last.text)) {
114
+ if (query && !query.next && offset === text.length && last && last.offset === last.text.length && this.memo?.index === 0 && !this.memo.summoned && last.revision === revision && last.predictor === predictor && last.marks === signature && !last.prediction.replace && text.startsWith(last.text)) {
114
115
  const typed = text.slice(last.text.length)
115
116
  if (typed && last.prediction.suffix.startsWith(typed) && typed.length < last.prediction.suffix.length) {
116
117
  const sticky = { ...last.prediction, suffix: last.prediction.suffix.slice(typed.length) }
117
118
  predictions.splice(0, predictions.length, sticky, ...predictions.filter((prediction) => prediction.word !== sticky.word))
118
119
  }
119
120
  }
120
- this.memo = { text, offset, marks: signature, revision, predictor, predictions, index: 0 }
121
+ this.memo = { text, offset, marks: signature, revision, predictor, predictions, index: 0, summoned: false }
121
122
  return predictions[0]
122
123
  }
123
124
 
@@ -144,7 +145,19 @@ export class ComposerGhost {
144
145
  const y = this.editor.screenY + cursor.visualRow
145
146
  buffer.pushScissorRect(x, y, room, 1)
146
147
  try {
147
- buffer.drawText(ghost, x, y, this.color(), this.editor.backgroundColor)
148
+ const color = this.color()
149
+ buffer.drawText(ghost, x, y, color, this.editor.backgroundColor)
150
+ const memo = this.memo!
151
+ if (memo.predictions.length > 1 && this.showAlternativeCounter()) {
152
+ const fitting = memo.predictions.filter((candidate) => this.fits(candidate))
153
+ if (fitting.length > 1) {
154
+ const counter = ` ${fitting.indexOf(prediction) + 1}/${fitting.length}`
155
+ const width = this.editor.editBuffer.measureText(ghost)
156
+ if (width + this.editor.editBuffer.measureText(counter) <= room) {
157
+ buffer.drawText(counter, x + width, y, dimGhostColor(color), this.editor.backgroundColor)
158
+ }
159
+ }
160
+ }
148
161
  } finally {
149
162
  buffer.popScissorRect()
150
163
  }
@@ -186,6 +199,25 @@ export class ComposerGhost {
186
199
  return this.visible() && this.memo!.predictions.some((prediction, index) => index !== this.memo!.index && this.fits(prediction))
187
200
  }
188
201
 
202
+ summon(): boolean {
203
+ if (this.disposed || this.visible() || !eligibleComposer(this.view())) return false
204
+ const text = this.editor.plainText
205
+ const offset = this.offset()
206
+ const automatic = this.prediction(text, offset)
207
+ if (automatic && this.fits(automatic)) return false
208
+ const predictor = this.active()
209
+ const marks = this.editor.extmarks.getAll()
210
+ const query = completionQuery(text, offset, this.protectedRanges(marks), this.completeAtLineEnd, predictor.grammar)
211
+ if (!query) return false
212
+ const predictions = predictor.candidates(query, 5, true).filter((prediction) =>
213
+ (!(marks.length || offset !== text.length) || !prediction.replace) && this.fits(prediction))
214
+ if (!predictions.length) return false
215
+ this.dismissed = undefined
216
+ this.memo = { text, offset, marks: this.marksKey(), revision: predictor.modelRevision, predictor, predictions, index: 0, summoned: true }
217
+ this.editor.requestRender()
218
+ return true
219
+ }
220
+
189
221
  cycle(direction: 1 | -1): boolean {
190
222
  if (!this.canCycle()) return false
191
223
  const memo = this.memo!
package/src/keymap.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { KeymapLayer } from "@opencode/plugin/tui/context"
2
2
  import type { Options } from "./options"
3
3
 
4
- type Suggestion = { visible(): boolean; accept(): boolean; dismiss(): boolean; canCycle(): boolean; cycle(direction: 1 | -1): boolean }
4
+ type Suggestion = { visible(): boolean; accept(): boolean; dismiss(): boolean; canCycle(): boolean; cycle(direction: 1 | -1): boolean; summon(): boolean }
5
5
 
6
6
  export function completionLayer(options: Options, suggestion: () => Suggestion | undefined): KeymapLayer {
7
7
  return {
@@ -29,6 +29,12 @@ export function completionLayer(options: Options, suggestion: () => Suggestion |
29
29
  enabled: () => suggestion()?.canCycle() === true,
30
30
  run: () => suggestion()?.cycle(direction) ? undefined : false,
31
31
  })),
32
+ {
33
+ id: "quill.summon",
34
+ title: "Summon word suggestions",
35
+ bind: options.summonKeys.length ? options.summonKeys.join(",") : false,
36
+ run: () => suggestion()?.summon() ? undefined : false,
37
+ },
32
38
  ],
33
39
  }
34
40
  }
package/src/options.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type Options = { enabled: boolean; completeAtLineEnd: boolean; completeShell: boolean; minSuggestedWordLength: number; acceptKeys: string[]; dismissKeys: string[]; cycleNextKeys: string[]; cyclePreviousKeys: string[] }
1
+ export type Options = { enabled: boolean; completeAtLineEnd: boolean; completeShell: boolean; minSuggestedWordLength: number; acceptKeys: string[]; dismissKeys: string[]; cycleNextKeys: string[]; cyclePreviousKeys: string[]; summonKeys: string[] }
2
2
 
3
3
  function keys(value: unknown, fallback: string[], name: string): string[] {
4
4
  if (value === undefined) return fallback
@@ -22,6 +22,7 @@ export function resolveOptions(input: Readonly<Record<string, unknown>>): Option
22
22
  dismissKeys: keys(input.dismissKeys, ["escape"], "dismissKeys"),
23
23
  cycleNextKeys: keys(input.cycleNextKeys, [], "cycleNextKeys"),
24
24
  cyclePreviousKeys: keys(input.cyclePreviousKeys, [], "cyclePreviousKeys"),
25
+ summonKeys: keys(input.summonKeys, [], "summonKeys"),
25
26
  }
26
27
  }
27
28
 
package/src/predictor.ts CHANGED
@@ -333,10 +333,11 @@ export class WordPredictor {
333
333
  return resolved
334
334
  }
335
335
 
336
- candidates(query: CompletionQuery, limit = 5): Prediction[] {
336
+ candidates(query: CompletionQuery, limit = 5, summoned = false): Prediction[] {
337
337
  const maximum = Number.isFinite(limit) ? Math.max(0, Math.min(5, Math.floor(limit))) : 5
338
338
  if (!maximum) return []
339
339
  const prefix = this.grammar.normalize(query.prefix)
340
+ const prefixLength = [...prefix].length
340
341
  const words = query.words ?? (this.grammar.prose ? proseWords(query.before) : [])
341
342
  const local = new Map<string, number>()
342
343
  for (const word of words) increment(local, word.text)
@@ -345,7 +346,7 @@ export class WordPredictor {
345
346
  const pair = context.length === 2 ? context.join("\0") : undefined
346
347
  const evidence = this.bigramTotals.get(previous ?? "")?.total ?? 0
347
348
  if (query.next && evidence < 2) return []
348
- if (!query.next && [...prefix].length < 2 && evidence < 2) return []
349
+ if (!query.next && prefixLength < 2 && evidence < 2) return []
349
350
  const slash = prefix.includes("/")
350
351
  const followed = (word: string) => (previous ? this.personal.bigrams.get(`${previous}\0${word}`) ?? 0 : 0) >= 2 ||
351
352
  (pair ? this.personal.trigrams.get(`${pair}\0${word}`) ?? 0 : 0) >= 2
@@ -376,8 +377,9 @@ export class WordPredictor {
376
377
  }
377
378
  const predictions: Prediction[] = []
378
379
  const exact = query.next ? 0 : ranked.find(({ word }) => word === prefix)?.score ?? 0
379
- const short = [...prefix].length < 2
380
- const threshold = this.grammar.prose && short ? SHORT_CONFIDENCE : CONFIDENCE
380
+ const short = prefixLength < 2
381
+ const cautiousPrefix = short || (prefixLength === 2 && evidence < 2)
382
+ const threshold = this.grammar.prose && cautiousPrefix ? SHORT_CONFIDENCE : CONFIDENCE
381
383
  const exactConfident = this.grammar.prose && !short && exact >= threshold * (sum || 1)
382
384
  for (const { word: best, score: bestScore, weight: bestWeight } of ranked) {
383
385
  if (best === prefix && !query.next) {
@@ -388,7 +390,7 @@ export class WordPredictor {
388
390
  const gate = query.next
389
391
  ? bestScore >= CONFIDENCE
390
392
  : confidence! >= threshold || (exactConfident && bestScore >= EXACT_RATIO * exact)
391
- if (!bestScore || confidence === undefined || (bestWeight === 1 && !gate)) {
393
+ if (!bestScore || confidence === undefined || (bestWeight === 1 && !gate && !summoned)) {
392
394
  if (!predictions.length) return []
393
395
  continue
394
396
  }
@@ -407,7 +409,7 @@ export class WordPredictor {
407
409
  return predictions.slice(0, maximum)
408
410
  }
409
411
  const completion = suggest()
410
- if (completion.length || query.next || prefix.length < 3 || slash || prefix.endsWith("'") || candidates.has(prefix) || !this.grammar.prose) return completion
412
+ if (completion.length || query.next || prefixLength < 3 || slash || prefix.endsWith("'") || candidates.has(prefix) || !this.grammar.prose) return completion
411
413
  for (const word of this.nearbyWords(prefix)) {
412
414
  if (candidates.has(word)) continue
413
415
  const weight = typoWeight(prefix, word)
package/src/tui.tsx CHANGED
@@ -71,7 +71,8 @@ export default Plugin.define({
71
71
  selected: context.renderer.hasSelection,
72
72
  enabled: !disposed && settings.enabled && (!shell || shellEnabled()) && currentEditor() === editor,
73
73
  }
74
- }, () => dimGhostColor(context.theme.text.muted), context.renderer, options.completeAtLineEnd, shellPredictor)
74
+ }, () => dimGhostColor(context.theme.text.muted), context.renderer, options.completeAtLineEnd, shellPredictor,
75
+ () => ["quill.next", "quill.previous"].some((id) => context.keymap.shortcuts(id).length > 0))
75
76
  }
76
77
 
77
78
  const sessionInfo = (sessionID: string) =>
package/tsconfig.json CHANGED
@@ -13,6 +13,6 @@
13
13
  "skipLibCheck": true,
14
14
  "forceConsistentCasingInFileNames": true
15
15
  },
16
- "include": ["src", "test"],
16
+ "include": ["src", "test", "scripts/eval.ts"],
17
17
  "exclude": ["node_modules"]
18
18
  }