opencode-quill 0.8.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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.0] - 2026-11-27
8
+
9
+ ### Added
10
+
11
+ - **composer:** Add opt-in suggestion alternatives (#32)
12
+
7
13
  ## [0.8.0] - 2026-11-27
8
14
 
9
15
  ### Added
@@ -175,6 +181,7 @@ All notable changes are documented in this file using
175
181
  - `/quill` command and command palette action to toggle autocomplete.
176
182
  - Local installer script, full test suite, CI workflows, and release tooling.
177
183
 
184
+ [0.9.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.8.0...v0.9.0
178
185
  [0.8.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.1...v0.8.0
179
186
  [0.7.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.0...v0.7.1
180
187
  [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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-quill",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
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,7 +333,7 @@ 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)
@@ -388,7 +388,7 @@ export class WordPredictor {
388
388
  const gate = query.next
389
389
  ? bestScore >= CONFIDENCE
390
390
  : confidence! >= threshold || (exactConfident && bestScore >= EXACT_RATIO * exact)
391
- if (!bestScore || confidence === undefined || (bestWeight === 1 && !gate)) {
391
+ if (!bestScore || confidence === undefined || (bestWeight === 1 && !gate && !summoned)) {
392
392
  if (!predictions.length) return []
393
393
  continue
394
394
  }
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
  }