opencode-quill 0.6.0 → 0.6.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,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.6.1] - 2026-10-22
8
+
9
+ ### Fixed
10
+
11
+ - **prediction:** Correct sentence-start casing, trigram scoring, and next-word filtering
12
+
7
13
  ## [0.6.0] - 2026-10-22
8
14
 
9
15
  ### Added
@@ -133,6 +139,7 @@ All notable changes are documented in this file using
133
139
  - `/quill` command and command palette action to toggle autocomplete.
134
140
  - Local installer script, full test suite, CI workflows, and release tooling.
135
141
 
142
+ [0.6.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.0...v0.6.1
136
143
  [0.6.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.5.2...v0.6.0
137
144
  [0.5.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.5.1...v0.5.2
138
145
  [0.5.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.5.0...v0.5.1
package/README.md CHANGED
@@ -220,6 +220,7 @@ handlers remain in control. Dialogs and selections also suppress Quill.
220
220
  - `/quill` — Toggle word autocomplete on or off (persisted across sessions).
221
221
  - `/quill on` / `/quill off` — Set autocomplete explicitly.
222
222
  - `/quill shell on` / `/quill shell off` — Set shell-mode autocomplete explicitly.
223
+ - `/quill clear casing` (alias `/quill reset casing`) — Forget only the learned word casing (`OpenCode`, `GitHub`), keeping the vocabulary and phrases.
223
224
  - `/quill clear` (alias `/quill reset`) — Erase everything Quill has learned from your prompts and shell commands.
224
225
  - `quill.next` / `quill.previous` — Keymap commands for cycling visible word
225
226
  alternatives; no default bindings. Configure the cycle options above or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-quill",
3
- "version": "0.6.0",
3
+ "version": "0.6.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",
package/src/ghost.ts CHANGED
@@ -113,7 +113,8 @@ export class ComposerGhost {
113
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
114
  const typed = text.slice(last.text.length)
115
115
  if (typed && last.prediction.suffix.startsWith(typed) && typed.length < last.prediction.suffix.length) {
116
- predictions[0] = { ...last.prediction, suffix: last.prediction.suffix.slice(typed.length) }
116
+ const sticky = { ...last.prediction, suffix: last.prediction.suffix.slice(typed.length) }
117
+ predictions.splice(0, predictions.length, sticky, ...predictions.filter((prediction) => prediction.word !== sticky.word))
117
118
  }
118
119
  }
119
120
  this.memo = { text, offset, marks: signature, revision, predictor, predictions, index: 0 }
package/src/options.ts CHANGED
@@ -28,12 +28,14 @@ export type QuillCommand =
28
28
  | { type: "enable"; value: boolean }
29
29
  | { type: "clear" }
30
30
  | { type: "shell"; value: boolean }
31
+ | { type: "casing" }
31
32
  | { type: "invalid" }
32
33
 
33
34
  export function parseQuillCommand(input: string | undefined): QuillCommand {
34
35
  const raw = input?.trim().toLowerCase() ?? ""
35
36
  if (!raw || raw === "toggle") return { type: "toggle" }
36
37
  if (raw === "clear" || raw === "reset") return { type: "clear" }
38
+ if (raw === "clear casing" || raw === "reset casing") return { type: "casing" }
37
39
  if (raw === "on") return { type: "enable", value: true }
38
40
  if (raw === "off") return { type: "enable", value: false }
39
41
  if (raw === "shell on") return { type: "shell", value: true }
package/src/predictor.ts CHANGED
@@ -76,13 +76,14 @@ export class PersonalModel {
76
76
  this.seen.add(prompt.id)
77
77
  changed = true
78
78
  if (prompt.text.length > 4000 || prompt.text.split("\n").length > 12) continue
79
+ const masked = this.grammar.prose ? this.grammar.mask(prompt.text) : prompt.text
79
80
  for (const sequence of this.grammar.sequences(prompt.text)) {
80
81
  const words = sequence.map((word) => word.text)
81
82
  for (let index = 0; index < words.length; index++) {
82
83
  const { start, end } = sequence[index]
83
84
  increment(this.words, words[index])
84
85
  const form = prompt.text.slice(start, end).normalize("NFC").replaceAll("’", "'")
85
- if (this.grammar.prose && form !== words[index] && !sentenceStart(prompt.text, start)) increment(this.forms, form)
86
+ if (this.grammar.prose && form !== words[index] && !sentenceStart(masked, start)) increment(this.forms, form)
86
87
  if (index > 0) increment(this.bigrams, `${words[index - 1]}\0${words[index]}`)
87
88
  if (index > 1) increment(this.trigrams, `${words[index - 2]}\0${words[index - 1]}\0${words[index]}`)
88
89
  }
@@ -114,13 +115,16 @@ export class PersonalModel {
114
115
  }
115
116
  }
116
117
 
117
- function totals(counts: Map<string, number>): Map<string, { total: number; types: number }> {
118
- const result = new Map<string, { total: number; types: number }>()
118
+ type Totals = { total: number; types: number; max: number }
119
+
120
+ function totals(counts: Map<string, number>): Map<string, Totals> {
121
+ const result = new Map<string, Totals>()
119
122
  for (const [key, count] of counts) {
120
123
  const context = key.slice(0, key.lastIndexOf("\0"))
121
- const entry = result.get(context) ?? { total: 0, types: 0 }
124
+ const entry = result.get(context) ?? { total: 0, types: 0, max: 0 }
122
125
  entry.total += count
123
126
  entry.types++
127
+ entry.max = Math.max(entry.max, count)
124
128
  result.set(context, entry)
125
129
  }
126
130
  return result
@@ -205,8 +209,8 @@ export class WordPredictor {
205
209
  private priorTotal = 0
206
210
  private personal = new PersonalModel()
207
211
  private personalTotal = 0
208
- private bigramTotals = new Map<string, { total: number; types: number }>()
209
- private trigramTotals = new Map<string, { total: number; types: number }>()
212
+ private bigramTotals = new Map<string, Totals>()
213
+ private trigramTotals = new Map<string, Totals>()
210
214
  private vocabulary: string[] = []
211
215
  private forms = new Map<string, string>()
212
216
 
@@ -278,7 +282,8 @@ export class WordPredictor {
278
282
  const trigram = pair && this.trigramTotals.get(pair)
279
283
  if (trigram && trigram.total >= 2) {
280
284
  const count = this.personal.trigrams.get(`${pair}\0${word}`) ?? 0
281
- score = Math.max(count - DISCOUNT, 0) / trigram.total + DISCOUNT * trigram.types / trigram.total * score
285
+ const discounted = Math.max(count - DISCOUNT, 0) / trigram.total + DISCOUNT * trigram.types / trigram.total * score
286
+ score = trigram.max >= 2 ? discounted : Math.max(score, discounted)
282
287
  }
283
288
  return score
284
289
  }
@@ -328,15 +333,16 @@ export class WordPredictor {
328
333
  if (query.next && evidence < 2) return []
329
334
  if (!query.next && [...prefix].length < 2 && evidence < 2) return []
330
335
  const slash = prefix.includes("/")
336
+ const followed = (word: string) => (previous ? this.personal.bigrams.get(`${previous}\0${word}`) ?? 0 : 0) >= 2 ||
337
+ (pair ? this.personal.trigrams.get(`${pair}\0${word}`) ?? 0 : 0) >= 2
338
+ const eligible = (word: string) => !query.next || followed(word)
331
339
  const candidates = new Map<string, number>()
332
340
  for (let index = lowerBound(this.vocabulary, prefix); index < this.vocabulary.length; index++) {
333
341
  const word = this.vocabulary[index]
334
342
  if (!word.startsWith(prefix)) break
335
- if (query.next || slash === word.includes("/")) candidates.set(word, 1)
343
+ if ((query.next || slash === word.includes("/")) && eligible(word)) candidates.set(word, 1)
336
344
  }
337
- for (const word of local.keys()) if (!word.includes("/") && word.startsWith(prefix) && (query.next || !slash)) candidates.set(word, 1)
338
- const followed = (word: string) => (previous ? this.personal.bigrams.get(`${previous}\0${word}`) ?? 0 : 0) >= 2 ||
339
- (pair ? this.personal.trigrams.get(`${pair}\0${word}`) ?? 0 : 0) >= 2
345
+ for (const word of local.keys()) if (!word.includes("/") && word.startsWith(prefix) && (query.next || !slash) && eligible(word)) candidates.set(word, 1)
340
346
  const suggest = (): Prediction[] => {
341
347
  const ranked: { word: string; score: number; weight: number }[] = []
342
348
  let sum = 0
@@ -351,7 +357,7 @@ export class WordPredictor {
351
357
  const predictions: Prediction[] = []
352
358
  for (const { word: best, score: bestScore, weight: bestWeight } of ranked) {
353
359
  const confidence = bestWeight < 1 ? typoConfidence(bestScore, sum) : query.next ? bestScore : bestScore / (sum || 1)
354
- if (!bestScore || best === prefix || confidence === undefined || (query.next && !followed(best)) || (bestWeight === 1 && confidence < 0.3)) {
360
+ if (!bestScore || best === prefix || confidence === undefined || (bestWeight === 1 && confidence < 0.3)) {
355
361
  if (!predictions.length) return []
356
362
  continue
357
363
  }
package/src/tui.tsx CHANGED
@@ -150,6 +150,14 @@ export default Plugin.define({
150
150
  context.ui.toast.show({ title: "Quill", message: "Word autocomplete history cleared" })
151
151
  }
152
152
 
153
+ const clearCasing = async () => {
154
+ const next = { ...unwrap(learning.snapshot), forms: [] }
155
+ predictor.setPersonal(next)
156
+ await setLearning((draft) => { draft.snapshot = { ...unwrap(draft.snapshot), forms: [] } })
157
+ ghost?.invalidate()
158
+ context.ui.toast.show({ title: "Quill", message: "Learned word casing cleared" })
159
+ }
160
+
153
161
  const disposeEffects = createRoot((dispose) => {
154
162
  createEffect(() => {
155
163
  const snapshot = learning.snapshot
@@ -211,6 +219,10 @@ export default Plugin.define({
211
219
  await clearHistory()
212
220
  return
213
221
  }
222
+ if (command.type === "casing") {
223
+ await clearCasing()
224
+ return
225
+ }
214
226
  if (command.type === "shell") {
215
227
  await setSettings((draft) => { draft.shell = command.value })
216
228
  ghost?.invalidate()
@@ -218,7 +230,7 @@ export default Plugin.define({
218
230
  return
219
231
  }
220
232
  if (command.type === "invalid") {
221
- context.ui.toast.show({ title: "Quill", message: "Use /quill, /quill on, /quill off, /quill shell on, /quill shell off, or /quill clear", variant: "warning" })
233
+ context.ui.toast.show({ title: "Quill", message: "Use /quill, /quill on, /quill off, /quill shell on, /quill shell off, /quill clear, or /quill clear casing", variant: "warning" })
222
234
  return
223
235
  }
224
236
  const enabled = command.type === "enable" ? command.value : !settings.enabled