opencode-quill 0.3.1 → 0.3.3

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,19 @@ 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.3.3] - 2026-10-21
8
+
9
+ ### Fixed
10
+
11
+ - Keep learning when full, honor clear, and skip subagent sessions
12
+ - Hide suggestions that do not fit the cursor row
13
+
14
+ ## [0.3.2] - 2026-10-21
15
+
16
+ ### Added
17
+
18
+ - Predict words in composers holding attachments or pasted-text chips
19
+
7
20
  ## [0.3.1] - 2026-10-20
8
21
 
9
22
  ### Fixed
@@ -84,6 +97,8 @@ All notable changes are documented in this file using
84
97
  - `/quill` command and command palette action to toggle autocomplete.
85
98
  - Local installer script, full test suite, CI workflows, and release tooling.
86
99
 
100
+ [0.3.3]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.2...v0.3.3
101
+ [0.3.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.1...v0.3.2
87
102
  [0.3.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.0...v0.3.1
88
103
  [0.3.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.2.2...v0.3.0
89
104
  [0.2.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.2.1...v0.2.2
package/README.md CHANGED
@@ -42,7 +42,9 @@ Press <kbd>Tab</kbd> or <kbd>→</kbd> to accept it, or <kbd>Esc</kbd> to dismis
42
42
  activates only in its respective domain without key conflicts.
43
43
  - **Prose-aware gating:** Automatically suppresses suggestions in code blocks,
44
44
  backticks, file paths, URLs, slash commands, shell executions, active selections,
45
- composers holding attachments or pasted-text chips, and modal dialogs.
45
+ and modal dialogs. Attachment and pasted-text chips are treated as non-prose:
46
+ words are still suggested after them, but never inside them, and typo
47
+ replacements are not offered while a chip is present.
46
48
  - **End-of-draft only:** Suggestions appear when the cursor is at the end of the
47
49
  draft, either on a partial word or after a space.
48
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-quill",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
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",
@@ -62,7 +62,7 @@
62
62
  "devDependencies": {
63
63
  "@commitlint/cli": "^21.2.2",
64
64
  "@commitlint/config-conventional": "^21.2.2",
65
- "@opencode/plugin": "2.0.29",
65
+ "@opencode/plugin": "2.0.32",
66
66
  "@types/bun": "^1.4.2",
67
67
  "@types/node": "26.6.5",
68
68
  "husky": "^9.1.7",
package/src/ghost.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RGBA, type CliRenderer, type OptimizedBuffer, type Renderable, type TextareaRenderable } from "@opentui/core"
2
- import { completionQuery } from "./prose"
2
+ import { completionQuery, type TextRange } from "./prose"
3
3
  import type { Prediction, WordPredictor } from "./predictor"
4
4
 
5
5
  export type Composer = {
@@ -21,7 +21,7 @@ export function eligibleComposer(view: Composer, text?: string): boolean {
21
21
  editor === view.focused && editor.focused && editor.visible && !editor.isDestroyed &&
22
22
  !!editor.parent && !editor.parent.isDestroyed && !editor.hasSelection() &&
23
23
  !editor.traits.capture?.includes("navigate") &&
24
- (text ?? editor.plainText).trim().length > 0 && editor.extmarks.getAll().length === 0
24
+ (text ?? editor.plainText).trim().length > 0
25
25
  }
26
26
 
27
27
  export function findComposer(marker: Renderable | undefined, isEditor: (node: Renderable) => node is TextareaRenderable): TextareaRenderable | undefined {
@@ -41,7 +41,7 @@ export function findComposer(marker: Renderable | undefined, isEditor: (node: Re
41
41
  export class ComposerGhost {
42
42
  private shown: { text: string; offset: number; prediction: Prediction } | undefined
43
43
  private dismissed: string | undefined
44
- private memo: { text: string; offset: number; prediction: Prediction | undefined } | undefined
44
+ private memo: { text: string; offset: number; marks: string; prediction: Prediction | undefined } | undefined
45
45
  private disposed = false
46
46
  private readonly draw: (buffer: OptimizedBuffer, delta: number) => void
47
47
 
@@ -60,6 +60,13 @@ export class ComposerGhost {
60
60
  return this.editor.editBuffer.getTextRange(0, this.editor.cursorOffset).length
61
61
  }
62
62
 
63
+ private protectedRanges(marks = this.editor.extmarks.getAll()): TextRange[] {
64
+ return marks.map((mark) => [
65
+ this.editor.editBuffer.getTextRange(0, mark.start).length,
66
+ this.editor.editBuffer.getTextRange(0, mark.end).length,
67
+ ])
68
+ }
69
+
63
70
  invalidate(): void {
64
71
  this.memo = undefined
65
72
  this.shown = undefined
@@ -69,9 +76,12 @@ export class ComposerGhost {
69
76
  private prediction(text: string, offset: number): Prediction | undefined {
70
77
  if (this.dismissed !== undefined && this.dismissed !== text) this.dismissed = undefined
71
78
  if (this.dismissed === text || !eligibleComposer(this.view(), text)) return
72
- if (this.memo?.text === text && this.memo.offset === offset) return this.memo.prediction
73
- const query = completionQuery(text, offset)
79
+ const marks = this.editor.extmarks.getAll()
80
+ const signature = marks.map((mark) => `${mark.start}:${mark.end}`).join()
81
+ if (this.memo?.text === text && this.memo.offset === offset && this.memo.marks === signature) return this.memo.prediction
82
+ const query = completionQuery(text, offset, this.protectedRanges(marks))
74
83
  let prediction = query && this.predictor.complete(query)
84
+ if (marks.length && prediction?.replace) prediction = undefined
75
85
  const last = this.shown
76
86
  if (query && !query.next && last && !last.prediction.replace && text.startsWith(last.text)) {
77
87
  const typed = text.slice(last.text.length)
@@ -79,7 +89,7 @@ export class ComposerGhost {
79
89
  prediction = { ...last.prediction, suffix: last.prediction.suffix.slice(typed.length) }
80
90
  }
81
91
  }
82
- this.memo = { text, offset, prediction }
92
+ this.memo = { text, offset, marks: signature, prediction }
83
93
  return prediction
84
94
  }
85
95
 
@@ -97,13 +107,13 @@ export class ComposerGhost {
97
107
  }
98
108
  const cursor = this.editor.visualCursor
99
109
  const room = this.editor.width - cursor.visualCol
100
- if (room <= 0 || cursor.visualRow < 0 || cursor.visualRow >= this.editor.height) {
110
+ const ghost = prediction.replace ? ` → ${prediction.suffix}` : prediction.suffix
111
+ if (room <= 0 || cursor.visualRow < 0 || cursor.visualRow >= this.editor.height || this.editor.editBuffer.measureText(ghost) > room) {
101
112
  this.shown = undefined
102
113
  return
103
114
  }
104
115
  const x = this.editor.screenX + cursor.visualCol
105
116
  const y = this.editor.screenY + cursor.visualRow
106
- const ghost = prediction.replace ? ` → ${prediction.suffix}` : prediction.suffix
107
117
  buffer.pushScissorRect(x, y, room, 1)
108
118
  try {
109
119
  buffer.drawText(ghost, x, y, this.color(), this.editor.backgroundColor)
@@ -117,7 +127,9 @@ export class ComposerGhost {
117
127
  const shown = this.shown
118
128
  if (this.disposed || !shown || !eligibleComposer(this.view()) ||
119
129
  this.editor.plainText !== shown.text || this.offset() !== shown.offset) return false
120
- if (!completionQuery(shown.text, shown.offset)) return false
130
+ const marks = this.editor.extmarks.getAll()
131
+ if (!completionQuery(shown.text, shown.offset, this.protectedRanges(marks))) return false
132
+ if (marks.length && shown.prediction.replace) return false
121
133
  this.shown = undefined
122
134
  if (shown.prediction.replace) {
123
135
  this.editor.replaceText(shown.text.slice(0, shown.text.length - shown.prediction.replace) + shown.prediction.suffix)
package/src/predictor.ts CHANGED
@@ -8,6 +8,7 @@ export type Snapshot = {
8
8
  trigrams: [string, number][]
9
9
  forms?: [string, number][]
10
10
  seen: string[]
11
+ clearedAt?: number
11
12
  }
12
13
  export type Prompt = { id: string; text: string }
13
14
  export type Prediction = { suffix: string; word: string; confidence: number; replace?: number }
@@ -34,12 +35,16 @@ function restore(rows: [string, number][], limit: number): Map<string, number> {
34
35
  return new Map(rows.slice(0, limit).filter(([word, count]) => typeof word === "string" && word.length <= 100 && Number.isFinite(count) && count > 0))
35
36
  }
36
37
 
37
- function trim(map: Map<string, number>, limit: number): [string, number][] {
38
- return [...map].sort((a, b) => b[1] - a[1]).slice(0, limit)
38
+ const byCount = (a: [string, number], b: [string, number]) => b[1] - a[1]
39
+
40
+ export function trim(map: Map<string, number>, limit: number): [string, number][] {
41
+ return [...map].reverse().sort(byCount).slice(0, limit).reverse().sort(byCount)
39
42
  }
40
43
 
41
44
  function increment(map: Map<string, number>, word: string): void {
42
- map.set(word, (map.get(word) ?? 0) + 1)
45
+ const count = map.get(word) ?? 0
46
+ map.delete(word)
47
+ map.set(word, count + 1)
43
48
  }
44
49
 
45
50
  export class PersonalModel {
@@ -48,8 +53,10 @@ export class PersonalModel {
48
53
  readonly trigrams: Map<string, number>
49
54
  readonly forms: Map<string, number>
50
55
  readonly seen: Set<string>
56
+ readonly clearedAt: number | undefined
51
57
 
52
58
  constructor(snapshot: Snapshot = emptySnapshot()) {
59
+ this.clearedAt = Number.isFinite(snapshot.clearedAt) ? snapshot.clearedAt : undefined
53
60
  this.words = restore(snapshot.words, WORD_LIMIT)
54
61
  this.bigrams = restore(snapshot.bigrams, CONTEXT_LIMIT)
55
62
  this.trigrams = restore(snapshot.trigrams, CONTEXT_LIMIT)
@@ -97,6 +104,7 @@ export class PersonalModel {
97
104
  trigrams: trim(this.trigrams, CONTEXT_LIMIT),
98
105
  forms: trim(this.forms, WORD_LIMIT),
99
106
  seen: [...this.seen].slice(-SEEN_LIMIT),
107
+ ...(this.clearedAt === undefined ? {} : { clearedAt: this.clearedAt }),
100
108
  }
101
109
  }
102
110
  }
package/src/prose.ts CHANGED
@@ -62,9 +62,19 @@ export function leftContext(before: string, words: readonly Word[] = proseWords(
62
62
  return result
63
63
  }
64
64
 
65
- export function completionQuery(text: string, characterOffset: number): CompletionQuery | undefined {
65
+ export type TextRange = readonly [start: number, end: number]
66
+
67
+ function blankRanges(text: string, ranges: readonly TextRange[]): string {
68
+ let result = text
69
+ for (const [start, end] of ranges) {
70
+ if (end > start) result = result.slice(0, start) + result.slice(start, end).replace(/[^\n]/g, "\0") + result.slice(end)
71
+ }
72
+ return result
73
+ }
74
+
75
+ export function completionQuery(text: string, characterOffset: number, protectedRanges: readonly TextRange[] = []): CompletionQuery | undefined {
66
76
  if (!text.trim() || characterOffset !== text.length || text.length > 16_000) return
67
- const masked = maskProse(text)
77
+ const masked = maskProse(protectedRanges.length ? blankRanges(text, protectedRanges) : text)
68
78
  const prefix = WORD_END.exec(text)?.[0]
69
79
  let end = text.length
70
80
  if (prefix) {
package/src/tui.tsx CHANGED
@@ -60,6 +60,7 @@ export default Plugin.define({
60
60
 
61
61
  const learn = async (sessionID: string, announce = true) => {
62
62
  if (disposed || !settings.enabled) return
63
+ if (context.data.session.list().find((session) => session.id === sessionID)?.parentID) return
63
64
  const active = inFlight.get(sessionID)
64
65
  if (active) {
65
66
  if (announce) {
@@ -80,19 +81,23 @@ export default Plugin.define({
80
81
  await context.data.session.message.sync(sessionID)
81
82
  if (disposed || !settings.enabled) return
82
83
  if (version !== resetVersion) continue
83
- const prompts = context.data.session.message.list(sessionID)
84
+ const candidates = context.data.session.message.list(sessionID)
84
85
  .filter((message) => message.type === "user")
85
86
  .slice(-200)
86
- .map((message) => ({ id: `${sessionID}:${message.id}`, text: message.text }))
87
+ .map((message) => ({ id: `${sessionID}:${message.id}`, text: message.text, created: message.time?.created }))
88
+ const promptsFor = (clearedAt: number | undefined) => candidates
89
+ .filter((prompt) => clearedAt === undefined || prompt.created === undefined || prompt.created >= clearedAt)
90
+ .map(({ id, text }) => ({ id, text }))
87
91
  const snapshot = unwrap(learning.snapshot)
88
92
  const seen = new Set(snapshot.seen)
93
+ const prompts = promptsFor(snapshot.clearedAt)
89
94
  if (!prompts.some((prompt) => !seen.has(prompt.id))) continue
90
95
  const model = new PersonalModel(snapshot)
91
96
  if (model.observe(prompts)) {
92
97
  await setLearning((draft) => {
93
98
  if (disposed || !settings.enabled || version !== resetVersion) return
94
99
  const latest = new PersonalModel(unwrap(draft.snapshot))
95
- if (latest.observe(prompts)) draft.snapshot = latest.snapshot()
100
+ if (latest.observe(promptsFor(latest.clearedAt))) draft.snapshot = latest.snapshot()
96
101
  })
97
102
  }
98
103
  } catch (error) {
@@ -113,8 +118,9 @@ export default Plugin.define({
113
118
  state.pending = false
114
119
  state.announce = false
115
120
  }
116
- predictor.setPersonal(emptySnapshot())
117
- await setLearning((draft) => { draft.snapshot = emptySnapshot() })
121
+ const cleared = { ...emptySnapshot(), clearedAt: Date.now() }
122
+ predictor.setPersonal(cleared)
123
+ await setLearning((draft) => { draft.snapshot = cleared })
118
124
  ghost?.invalidate()
119
125
  context.ui.toast.show({ title: "Quill", message: "Word autocomplete history cleared" })
120
126
  }