opencode-quill 0.9.1 → 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 +7 -0
- package/README.md +7 -2
- package/package.json +1 -1
- package/src/ghost.ts +7 -5
- package/src/predictor.ts +27 -9
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.2] - 2026-11-27
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **predictor:** Prefer supported and unambiguous spelling repairs (#35)
|
|
12
|
+
|
|
7
13
|
## [0.9.1] - 2026-11-27
|
|
8
14
|
|
|
9
15
|
### Fixed
|
|
@@ -187,6 +193,7 @@ All notable changes are documented in this file using
|
|
|
187
193
|
- `/quill` command and command palette action to toggle autocomplete.
|
|
188
194
|
- Local installer script, full test suite, CI workflows, and release tooling.
|
|
189
195
|
|
|
196
|
+
[0.9.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.1...v0.9.2
|
|
190
197
|
[0.9.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.0...v0.9.1
|
|
191
198
|
[0.9.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.8.0...v0.9.0
|
|
192
199
|
[0.8.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.1...v0.8.0
|
package/README.md
CHANGED
|
@@ -306,8 +306,13 @@ Quill learns from your own submitted prompts, never from assistant output:
|
|
|
306
306
|
Corrections require at least three typed letters. Short words are eligible
|
|
307
307
|
only for whole-word letter swaps that preserve the first letter; other edits
|
|
308
308
|
and mistyped longer prefixes require at least five letters, except for
|
|
309
|
-
apostrophe contractions, including missing apostrophes.
|
|
310
|
-
|
|
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.
|
|
311
316
|
Unknown tokens such as `json`, `yaml`, `bool`, `opts`,
|
|
312
317
|
and `enum` are left unchanged, and uncertain typos such as `fucn` can produce
|
|
313
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,7 +333,7 @@ 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)
|
|
@@ -341,12 +341,26 @@ export class WordPredictor {
|
|
|
341
341
|
const words = query.words ?? (this.grammar.prose ? proseWords(query.before) : [])
|
|
342
342
|
const local = new Map<string, number>()
|
|
343
343
|
for (const word of words) increment(local, word.text)
|
|
344
|
-
const
|
|
344
|
+
const rawContext = leftContext(query.before, words)
|
|
345
|
+
const context = this.resolveContext(rawContext, local)
|
|
345
346
|
const previous = context.at(-1)
|
|
346
347
|
const pair = context.length === 2 ? context.join("\0") : undefined
|
|
347
348
|
const evidence = this.bigramTotals.get(previous ?? "")?.total ?? 0
|
|
348
349
|
if (query.next && evidence < 2) return []
|
|
349
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
|
+
}
|
|
350
364
|
const slash = prefix.includes("/")
|
|
351
365
|
const followed = (word: string) => (previous ? this.personal.bigrams.get(`${previous}\0${word}`) ?? 0 : 0) >= 2 ||
|
|
352
366
|
(pair ? this.personal.trigrams.get(`${pair}\0${word}`) ?? 0 : 0) >= 2
|
|
@@ -363,8 +377,9 @@ export class WordPredictor {
|
|
|
363
377
|
}
|
|
364
378
|
}
|
|
365
379
|
for (const word of local.keys()) if (!word.includes("/") && word.startsWith(prefix) && (query.next || !slash) && eligible(word)) candidates.set(word, 1)
|
|
366
|
-
const suggest = (): Prediction[] => {
|
|
380
|
+
const suggest = (typos = false): Prediction[] => {
|
|
367
381
|
const ranked: { word: string; score: number; weight: number }[] = []
|
|
382
|
+
const retained = typos ? Math.max(2, maximum) : maximum
|
|
368
383
|
let sum = 0
|
|
369
384
|
for (const [word, weight] of candidates) {
|
|
370
385
|
const base = this.score(word, context, weight < 1) + (query.next ? 0 : 0.003 * Math.min(local.get(word) ?? 0, 3))
|
|
@@ -373,8 +388,10 @@ export class WordPredictor {
|
|
|
373
388
|
if (this.minSuggestedWordLength && word !== prefix && [...word].length < this.minSuggestedWordLength) continue
|
|
374
389
|
ranked.push({ word, score, weight })
|
|
375
390
|
ranked.sort((a, b) => b.score - a.score)
|
|
376
|
-
if (ranked.length >
|
|
391
|
+
if (ranked.length > retained + (this.grammar.prose && candidates.has(prefix) && !query.next ? 1 : 0)) ranked.pop()
|
|
377
392
|
}
|
|
393
|
+
const [best, runnerUp] = ranked
|
|
394
|
+
if (typos && !summoned && best && runnerUp && best.weight < 1 && best.score === runnerUp.score) return []
|
|
378
395
|
const predictions: Prediction[] = []
|
|
379
396
|
const exact = query.next ? 0 : ranked.find(({ word }) => word === prefix)?.score ?? 0
|
|
380
397
|
const short = prefixLength < 2
|
|
@@ -410,16 +427,17 @@ export class WordPredictor {
|
|
|
410
427
|
}
|
|
411
428
|
const completion = suggest()
|
|
412
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))
|
|
413
431
|
for (const word of this.nearbyWords(prefix)) {
|
|
414
432
|
if (candidates.has(word)) continue
|
|
415
|
-
const weight = typoWeight(prefix, word)
|
|
433
|
+
const weight = typoWeight(prefix, word, false, protectEnding)
|
|
416
434
|
if (weight > 0) candidates.set(word, weight)
|
|
417
435
|
}
|
|
418
436
|
for (const word of local.keys()) {
|
|
419
437
|
if (candidates.has(word) || word.includes("/")) continue
|
|
420
|
-
const weight = typoWeight(prefix, word)
|
|
438
|
+
const weight = typoWeight(prefix, word, false, protectEnding)
|
|
421
439
|
if (weight > 0) candidates.set(word, weight)
|
|
422
440
|
}
|
|
423
|
-
return suggest()
|
|
441
|
+
return suggest(true)
|
|
424
442
|
}
|
|
425
443
|
}
|