opencode-quill 0.7.1 → 0.8.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.8.0] - 2026-11-27
8
+
9
+ ### Added
10
+
11
+ - **predictor:** Reduce wrong suggestions and offer longer words after a complete word (#30)
12
+
7
13
  ## [0.7.1] - 2026-11-23
8
14
 
9
15
  ### Fixed
@@ -169,6 +175,7 @@ All notable changes are documented in this file using
169
175
  - `/quill` command and command palette action to toggle autocomplete.
170
176
  - Local installer script, full test suite, CI workflows, and release tooling.
171
177
 
178
+ [0.8.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.1...v0.8.0
172
179
  [0.7.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.7.0...v0.7.1
173
180
  [0.7.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.4...v0.7.0
174
181
  [0.6.4]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.3...v0.6.4
package/README.md CHANGED
@@ -90,7 +90,9 @@ A correction looks like this, with only ` → complete` dimmed:
90
90
  or all-uppercase casing (`Cmplete` → `Complete`, `CMPLETE` → `COMPLETE`).
91
91
  First-person contractions use a capital `I` in corrections and next-word
92
92
  suggestions (`I'm`, `I'll`, `I've`, `I'd`). Lowercase contraction prefixes
93
- are replaced on acceptance too (`i'v` → `I've`).
93
+ are replaced on acceptance too (`i'v` → `I've`). Typing the apostrophe
94
+ continues the word (`i'` offers `I'd`), and a word ending in an apostrophe
95
+ is never typo-corrected (`users'` stays as typed).
94
96
  - **Learned casing is kept.** A word you usually capitalize mid-sentence is
95
97
  suggested that way: `oz` shows ` → Ozan` and replaces the word, while `Oz`
96
98
  completes with `an`.
@@ -273,7 +275,7 @@ Quill learns from your own submitted prompts, never from assistant output:
273
275
  syntax are never learned as adjacent.
274
276
  - A word missing from the base vocabulary becomes suggestible only after it
275
277
  has been seen more than once, and not while it is a prefix of a learned word
276
- you use at least as often (`addr` yields to `addressed`).
278
+ you use at least three times as often (`addr` yields to `addressed`).
277
279
  - Casing is learned from words written mid-sentence; sentence-initial
278
280
  capitals are ignored.
279
281
 
@@ -286,8 +288,11 @@ Quill learns from your own submitted prompts, never from assistant output:
286
288
  - **Current draft:** words already in the draft get a small boost.
287
289
  - **Confidence gating:** a suggestion is shown only when it clears a
288
290
  confidence threshold, which is stricter for next-word predictions than for
289
- prefix completions. If the typed prefix is already the most likely word,
290
- nothing is shown.
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
293
+ word is also offered when it scores at least 40% as high in the current
294
+ context (typing `local` offers `locally`). Shell mode shows nothing when
295
+ the typed command is already the most likely word.
291
296
  - **Typo fallback:** when prefix completion is not confident enough, nearby
292
297
  words are ranked with an edit penalty and a stricter confidence threshold.
293
298
  Correction confidence is the edit-penalized model score. Suggestions must
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-quill",
3
- "version": "0.7.1",
3
+ "version": "0.8.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",
package/src/predictor.ts CHANGED
@@ -14,6 +14,10 @@ export type Prompt = { id: string; text: string }
14
14
  export type Prediction = { suffix: string; word: string; confidence: number; replace?: number }
15
15
 
16
16
  const DISCOUNT = 0.5
17
+ const CONFIDENCE = 0.3
18
+ const SHORT_CONFIDENCE = 0.4
19
+ const EXACT_RATIO = 0.4
20
+ const FRAGMENT_RATIO = 3
17
21
  const MIN_TYPO_SCORE = 0.000001
18
22
  const PRIOR_LIMIT = 20_000
19
23
  const WORD_LIMIT = 8000
@@ -240,7 +244,7 @@ export class WordPredictor {
240
244
  const word = learned[index]
241
245
  if (this.prior.has(word)) continue
242
246
  for (let next = index + 1; next < learned.length && learned[next].startsWith(word); next++) {
243
- if (!"/-.".includes(learned[next][word.length]) && counts.get(learned[next])! >= counts.get(word)!) {
247
+ if (!"/-.".includes(learned[next][word.length]) && counts.get(learned[next])! >= (this.grammar.prose ? FRAGMENT_RATIO : 1) * counts.get(word)!) {
244
248
  fragments.add(word)
245
249
  break
246
250
  }
@@ -368,12 +372,23 @@ export class WordPredictor {
368
372
  if (this.minSuggestedWordLength && word !== prefix && [...word].length < this.minSuggestedWordLength) continue
369
373
  ranked.push({ word, score, weight })
370
374
  ranked.sort((a, b) => b.score - a.score)
371
- if (ranked.length > maximum) ranked.pop()
375
+ if (ranked.length > maximum + (this.grammar.prose && candidates.has(prefix) && !query.next ? 1 : 0)) ranked.pop()
372
376
  }
373
377
  const predictions: Prediction[] = []
378
+ 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
381
+ const exactConfident = this.grammar.prose && !short && exact >= threshold * (sum || 1)
374
382
  for (const { word: best, score: bestScore, weight: bestWeight } of ranked) {
383
+ if (best === prefix && !query.next) {
384
+ if (!this.grammar.prose && !predictions.length) return []
385
+ continue
386
+ }
375
387
  const confidence = bestWeight < 1 ? typoConfidence(bestScore, sum) : query.next ? bestScore : bestScore / (sum || 1)
376
- if (!bestScore || best === prefix || confidence === undefined || (bestWeight === 1 && confidence < 0.3)) {
388
+ const gate = query.next
389
+ ? bestScore >= CONFIDENCE
390
+ : confidence! >= threshold || (exactConfident && bestScore >= EXACT_RATIO * exact)
391
+ if (!bestScore || confidence === undefined || (bestWeight === 1 && !gate)) {
377
392
  if (!predictions.length) return []
378
393
  continue
379
394
  }
@@ -389,10 +404,10 @@ export class WordPredictor {
389
404
  predictions.push({ suffix: shouting ? suffix.toUpperCase() : suffix, word: best, confidence })
390
405
  }
391
406
  }
392
- return predictions
407
+ return predictions.slice(0, maximum)
393
408
  }
394
409
  const completion = suggest()
395
- if (completion.length || query.next || prefix.length < 3 || slash || candidates.has(prefix) || !this.grammar.prose) return completion
410
+ if (completion.length || query.next || prefix.length < 3 || slash || prefix.endsWith("'") || candidates.has(prefix) || !this.grammar.prose) return completion
396
411
  for (const word of this.nearbyWords(prefix)) {
397
412
  if (candidates.has(word)) continue
398
413
  const weight = typoWeight(prefix, word)
package/src/prose.ts CHANGED
@@ -2,7 +2,7 @@ const PART = "[\\p{L}\\p{M}]+(?:['’][\\p{L}\\p{M}]+)*"
2
2
  const HYPHENATED = `${PART}(?:-${PART})*`
3
3
  const EXTENSION = "(?:sh|md|json|jsonc|ts|tsx|js|jsx|mjs|cjs|yml|yaml|toml|lock|html|css|py|txt|rs|go|sql)"
4
4
  const FILE = `${HYPHENATED}\\.${EXTENSION}`
5
- const PREFIX = `(?:${FILE}|${HYPHENATED}-?(?:\\/(?:${HYPHENATED}-?)?)?)`
5
+ const PREFIX = `(?:${FILE}|${HYPHENATED}(?:['’]|-?(?:\\/(?:${HYPHENATED}-?)?)?))`
6
6
  const WORD = new RegExp(`(?:${FILE}(?![\\p{L}\\p{M}\\p{N}])|${HYPHENATED}(?:\\/${HYPHENATED})?)`, "gu")
7
7
  const WHOLE_WORD = new RegExp(`^(?:${FILE}|${HYPHENATED}(?:\\/${HYPHENATED})?)$`, "u")
8
8
  const WORD_PREFIX = new RegExp(`^${PREFIX}$`, "u")