opencode-quill 0.3.1 → 0.3.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 +3 -1
- package/package.json +2 -2
- package/src/ghost.ts +19 -7
- package/src/prose.ts +12 -2
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.3.2] - 2026-10-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Predict words in composers holding attachments or pasted-text chips
|
|
12
|
+
|
|
7
13
|
## [0.3.1] - 2026-10-20
|
|
8
14
|
|
|
9
15
|
### Fixed
|
|
@@ -84,6 +90,7 @@ All notable changes are documented in this file using
|
|
|
84
90
|
- `/quill` command and command palette action to toggle autocomplete.
|
|
85
91
|
- Local installer script, full test suite, CI workflows, and release tooling.
|
|
86
92
|
|
|
93
|
+
[0.3.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.1...v0.3.2
|
|
87
94
|
[0.3.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.0...v0.3.1
|
|
88
95
|
[0.3.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.2.2...v0.3.0
|
|
89
96
|
[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
|
-
|
|
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.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -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.
|
|
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
|
|
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
|
-
|
|
73
|
-
const
|
|
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
|
|
|
@@ -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
|
-
|
|
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/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
|
|
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) {
|