opencode-quill 0.9.0 → 0.9.2
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 +14 -0
- package/README.md +10 -4
- package/package.json +1 -1
- package/src/ghost.ts +7 -5
- package/src/predictor.ts +33 -13
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.2] - 2026-11-27
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **predictor:** Prefer supported and unambiguous spelling repairs (#35)
|
|
12
|
+
|
|
13
|
+
## [0.9.1] - 2026-11-27
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **predictor:** Require stronger confidence on weak two-letter prefixes (#33)
|
|
18
|
+
|
|
7
19
|
## [0.9.0] - 2026-11-27
|
|
8
20
|
|
|
9
21
|
### Added
|
|
@@ -181,6 +193,8 @@ All notable changes are documented in this file using
|
|
|
181
193
|
- `/quill` command and command palette action to toggle autocomplete.
|
|
182
194
|
- Local installer script, full test suite, CI workflows, and release tooling.
|
|
183
195
|
|
|
196
|
+
[0.9.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.1...v0.9.2
|
|
197
|
+
[0.9.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.0...v0.9.1
|
|
184
198
|
[0.9.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.8.0...v0.9.0
|
|
185
199
|
[0.8.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.1...v0.8.0
|
|
186
200
|
[0.7.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.0...v0.7.1
|
package/README.md
CHANGED
|
@@ -293,8 +293,9 @@ Quill learns from your own submitted prompts, never from assistant output:
|
|
|
293
293
|
- **Current draft:** words already in the draft get a small boost.
|
|
294
294
|
- **Confidence gating:** a suggestion is shown only when it clears a
|
|
295
295
|
confidence threshold, which is stricter for next-word predictions than for
|
|
296
|
-
prefix completions
|
|
297
|
-
|
|
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
|
|
298
299
|
word is also offered when it scores at least 40% as high in the current
|
|
299
300
|
context (typing `local` offers `locally`). Shell mode shows nothing when
|
|
300
301
|
the typed command is already the most likely word.
|
|
@@ -305,8 +306,13 @@ Quill learns from your own submitted prompts, never from assistant output:
|
|
|
305
306
|
Corrections require at least three typed letters. Short words are eligible
|
|
306
307
|
only for whole-word letter swaps that preserve the first letter; other edits
|
|
307
308
|
and mistyped longer prefixes require at least five letters, except for
|
|
308
|
-
apostrophe contractions, including missing apostrophes.
|
|
309
|
-
|
|
309
|
+
apostrophe contractions, including missing apostrophes. A missing apostrophe
|
|
310
|
+
can be restored even when the typed word exists if the contraction has
|
|
311
|
+
repeated evidence and accounts for more than half of the learned continuations
|
|
312
|
+
after the previous word. Deletions repair only doubled letters. A final letter
|
|
313
|
+
after an otherwise known word does not trigger a longer typo completion
|
|
314
|
+
by substitution alone.
|
|
315
|
+
Equally scored spelling repairs are withheld unless explicitly summoned.
|
|
310
316
|
Unknown tokens such as `json`, `yaml`, `bool`, `opts`,
|
|
311
317
|
and `enum` are left unchanged, and uncertain typos such as `fucn` can produce
|
|
312
318
|
no suggestion. Context repair uses the same edit guards and confidence checks
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-quill",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
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
|
@@ -107,9 +107,10 @@ export class ComposerGhost {
|
|
|
107
107
|
const revision = predictor.modelRevision
|
|
108
108
|
if (this.memo?.text === text && this.memo.offset === offset && this.memo.marks === signature && this.memo.revision === revision && this.memo.predictor === predictor) return this.memo.predictions[this.memo.index]
|
|
109
109
|
const query = completionQuery(text, offset, this.protectedRanges(marks), this.completeAtLineEnd, predictor.grammar)
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const allowReplacement = marks.length === 0 && offset === text.length
|
|
111
|
+
const predictions = query ? predictor.candidates(query, undefined, false, allowReplacement) : []
|
|
112
|
+
if (!allowReplacement && predictions[0]?.replace) predictions.length = 0
|
|
113
|
+
else if (!allowReplacement) predictions.splice(0, predictions.length, ...predictions.filter((prediction) => !prediction.replace))
|
|
113
114
|
const last = this.shown
|
|
114
115
|
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)) {
|
|
115
116
|
const typed = text.slice(last.text.length)
|
|
@@ -209,8 +210,9 @@ export class ComposerGhost {
|
|
|
209
210
|
const marks = this.editor.extmarks.getAll()
|
|
210
211
|
const query = completionQuery(text, offset, this.protectedRanges(marks), this.completeAtLineEnd, predictor.grammar)
|
|
211
212
|
if (!query) return false
|
|
212
|
-
const
|
|
213
|
-
|
|
213
|
+
const allowReplacement = marks.length === 0 && offset === text.length
|
|
214
|
+
const predictions = predictor.candidates(query, 5, true, allowReplacement).filter((prediction) =>
|
|
215
|
+
(allowReplacement || !prediction.replace) && this.fits(prediction))
|
|
214
216
|
if (!predictions.length) return false
|
|
215
217
|
this.dismissed = undefined
|
|
216
218
|
this.memo = { text, offset, marks: this.marksKey(), revision: predictor.modelRevision, predictor, predictions, index: 0, summoned: true }
|
package/src/predictor.ts
CHANGED
|
@@ -168,7 +168,7 @@ function editKind(source: string, target: string, targetLength = target.length):
|
|
|
168
168
|
return doubled ? "delete" : undefined
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
function typoWeight(prefix: string, word: string, wholeWord = false): number {
|
|
171
|
+
function typoWeight(prefix: string, word: string, wholeWord = false, protectEnding = false): number {
|
|
172
172
|
const prefixLength = prefix.length
|
|
173
173
|
const wordLength = word.length
|
|
174
174
|
if (prefixLength < 3) return 0
|
|
@@ -184,7 +184,7 @@ function typoWeight(prefix: string, word: string, wholeWord = false): number {
|
|
|
184
184
|
if (prefixLength < 5 || wordLength <= prefixLength) return 0
|
|
185
185
|
const partial = editKind(prefix, word, prefixLength)
|
|
186
186
|
if (partial === "transpose") return 0.06
|
|
187
|
-
if (partial === "substitute") return 0.02
|
|
187
|
+
if (partial === "substitute" && !(protectEnding && word.startsWith(prefix.slice(0, -1)))) return 0.02
|
|
188
188
|
if (wordLength > prefixLength + 1 && editKind(prefix, word, prefixLength + 1) === "insert") return 0.03
|
|
189
189
|
if (editKind(prefix, word, prefixLength - 1) === "delete") return 0.02
|
|
190
190
|
return 0
|
|
@@ -333,19 +333,34 @@ export class WordPredictor {
|
|
|
333
333
|
return resolved
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
candidates(query: CompletionQuery, limit = 5, summoned = false): Prediction[] {
|
|
336
|
+
candidates(query: CompletionQuery, limit = 5, summoned = false, allowContractionReplacement = true): 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)
|
|
343
|
-
const
|
|
344
|
+
const rawContext = leftContext(query.before, words)
|
|
345
|
+
const context = this.resolveContext(rawContext, local)
|
|
344
346
|
const previous = context.at(-1)
|
|
345
347
|
const pair = context.length === 2 ? context.join("\0") : undefined
|
|
346
348
|
const evidence = this.bigramTotals.get(previous ?? "")?.total ?? 0
|
|
347
349
|
if (query.next && evidence < 2) return []
|
|
348
|
-
if (!query.next &&
|
|
350
|
+
if (!query.next && prefixLength < 2 && evidence < 2) return []
|
|
351
|
+
const typedPrevious = rawContext.at(-1)
|
|
352
|
+
if (allowContractionReplacement && this.grammar.prose && !query.next && prefixLength >= 3 && typedPrevious && /^[a-z]+$/.test(prefix)) {
|
|
353
|
+
const ending = /n(t)$|(d|ll|re|ve)$/.exec(prefix)
|
|
354
|
+
if (ending && prefixLength + 1 >= this.minSuggestedWordLength) {
|
|
355
|
+
const apostrophe = prefix.length - (ending[1] ?? ending[2]).length
|
|
356
|
+
const word = `${prefix.slice(0, apostrophe)}'${prefix.slice(apostrophe)}`
|
|
357
|
+
const count = this.personal.bigrams.get(`${typedPrevious}\0${word}`) ?? 0
|
|
358
|
+
const total = this.bigramTotals.get(typedPrevious)?.total ?? 0
|
|
359
|
+
if (count >= 2 && count > total / 2) {
|
|
360
|
+
return [{ word, suffix: applyCase(query.prefix, this.forms.get(word) ?? word), confidence: count / total, replace: query.prefix.length }]
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
349
364
|
const slash = prefix.includes("/")
|
|
350
365
|
const followed = (word: string) => (previous ? this.personal.bigrams.get(`${previous}\0${word}`) ?? 0 : 0) >= 2 ||
|
|
351
366
|
(pair ? this.personal.trigrams.get(`${pair}\0${word}`) ?? 0 : 0) >= 2
|
|
@@ -362,8 +377,9 @@ export class WordPredictor {
|
|
|
362
377
|
}
|
|
363
378
|
}
|
|
364
379
|
for (const word of local.keys()) if (!word.includes("/") && word.startsWith(prefix) && (query.next || !slash) && eligible(word)) candidates.set(word, 1)
|
|
365
|
-
const suggest = (): Prediction[] => {
|
|
380
|
+
const suggest = (typos = false): Prediction[] => {
|
|
366
381
|
const ranked: { word: string; score: number; weight: number }[] = []
|
|
382
|
+
const retained = typos ? Math.max(2, maximum) : maximum
|
|
367
383
|
let sum = 0
|
|
368
384
|
for (const [word, weight] of candidates) {
|
|
369
385
|
const base = this.score(word, context, weight < 1) + (query.next ? 0 : 0.003 * Math.min(local.get(word) ?? 0, 3))
|
|
@@ -372,12 +388,15 @@ export class WordPredictor {
|
|
|
372
388
|
if (this.minSuggestedWordLength && word !== prefix && [...word].length < this.minSuggestedWordLength) continue
|
|
373
389
|
ranked.push({ word, score, weight })
|
|
374
390
|
ranked.sort((a, b) => b.score - a.score)
|
|
375
|
-
if (ranked.length >
|
|
391
|
+
if (ranked.length > retained + (this.grammar.prose && candidates.has(prefix) && !query.next ? 1 : 0)) ranked.pop()
|
|
376
392
|
}
|
|
393
|
+
const [best, runnerUp] = ranked
|
|
394
|
+
if (typos && !summoned && best && runnerUp && best.weight < 1 && best.score === runnerUp.score) return []
|
|
377
395
|
const predictions: Prediction[] = []
|
|
378
396
|
const exact = query.next ? 0 : ranked.find(({ word }) => word === prefix)?.score ?? 0
|
|
379
|
-
const short =
|
|
380
|
-
const
|
|
397
|
+
const short = prefixLength < 2
|
|
398
|
+
const cautiousPrefix = short || (prefixLength === 2 && evidence < 2)
|
|
399
|
+
const threshold = this.grammar.prose && cautiousPrefix ? SHORT_CONFIDENCE : CONFIDENCE
|
|
381
400
|
const exactConfident = this.grammar.prose && !short && exact >= threshold * (sum || 1)
|
|
382
401
|
for (const { word: best, score: bestScore, weight: bestWeight } of ranked) {
|
|
383
402
|
if (best === prefix && !query.next) {
|
|
@@ -407,17 +426,18 @@ export class WordPredictor {
|
|
|
407
426
|
return predictions.slice(0, maximum)
|
|
408
427
|
}
|
|
409
428
|
const completion = suggest()
|
|
410
|
-
if (completion.length || query.next ||
|
|
429
|
+
if (completion.length || query.next || prefixLength < 3 || slash || prefix.endsWith("'") || candidates.has(prefix) || !this.grammar.prose) return completion
|
|
430
|
+
const protectEnding = this.known.has(prefix.slice(0, -1))
|
|
411
431
|
for (const word of this.nearbyWords(prefix)) {
|
|
412
432
|
if (candidates.has(word)) continue
|
|
413
|
-
const weight = typoWeight(prefix, word)
|
|
433
|
+
const weight = typoWeight(prefix, word, false, protectEnding)
|
|
414
434
|
if (weight > 0) candidates.set(word, weight)
|
|
415
435
|
}
|
|
416
436
|
for (const word of local.keys()) {
|
|
417
437
|
if (candidates.has(word) || word.includes("/")) continue
|
|
418
|
-
const weight = typoWeight(prefix, word)
|
|
438
|
+
const weight = typoWeight(prefix, word, false, protectEnding)
|
|
419
439
|
if (weight > 0) candidates.set(word, weight)
|
|
420
440
|
}
|
|
421
|
-
return suggest()
|
|
441
|
+
return suggest(true)
|
|
422
442
|
}
|
|
423
443
|
}
|