opencode-quill 0.6.3 → 0.7.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 +14 -0
- package/README.md +5 -1
- package/package.json +5 -5
- package/src/options.ts +3 -1
- package/src/predictor.ts +26 -10
- package/src/shell.ts +8 -2
- package/src/tui.tsx +9 -3
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.7.0] - 2026-11-14
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **options:** Add minSuggestedWordLength (#22)
|
|
12
|
+
|
|
13
|
+
## [0.6.4] - 2026-11-08
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Harden shell secret masking and tighten predictor hot paths (#20)
|
|
18
|
+
|
|
7
19
|
## [0.6.3] - 2026-11-01
|
|
8
20
|
|
|
9
21
|
### Fixed
|
|
@@ -151,6 +163,8 @@ All notable changes are documented in this file using
|
|
|
151
163
|
- `/quill` command and command palette action to toggle autocomplete.
|
|
152
164
|
- Local installer script, full test suite, CI workflows, and release tooling.
|
|
153
165
|
|
|
166
|
+
[0.7.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.4...v0.7.0
|
|
167
|
+
[0.6.4]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.3...v0.6.4
|
|
154
168
|
[0.6.3]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.2...v0.6.3
|
|
155
169
|
[0.6.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.1...v0.6.2
|
|
156
170
|
[0.6.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.6.0...v0.6.1
|
package/README.md
CHANGED
|
@@ -56,7 +56,10 @@ and restart OpenCode ([details](#install)).
|
|
|
56
56
|
subcommands and flags from a separate vocabulary learned from the commands
|
|
57
57
|
you ran, never from prose. Shell completion is case-sensitive, never corrects
|
|
58
58
|
typos, and skips paths, quoted strings, `$` expansions, assignments and any
|
|
59
|
-
command that mentions a token, secret, password, key or
|
|
59
|
+
command that mentions a token, secret, password, passphrase, key, cookie or
|
|
60
|
+
credential, passes a password flag (`curl -u user:pass`, `mysql -p…`,
|
|
61
|
+
`sshpass -p`, `docker login -p`), or contains a recognisable API token
|
|
62
|
+
(`sk-`, `ghp_`, `glpat-`, `xoxb-`, JWT, AWS key ID). Attachment and pasted-text chips are treated as non-prose:
|
|
60
63
|
words are still suggested after them, but never inside them, and typo
|
|
61
64
|
replacements are not offered while a chip is present.
|
|
62
65
|
- **End-of-draft by default:** Suggestions appear on a partial word or after a
|
|
@@ -193,6 +196,7 @@ Restart OpenCode after editing `cli.json`.
|
|
|
193
196
|
| `enabled` | `boolean` | `true` | Initial default for suggestions and learning; a persisted `/quill` toggle takes precedence. |
|
|
194
197
|
| `completeAtLineEnd` | `boolean` | `false` | Also append completions or next words immediately before a newline within a draft. |
|
|
195
198
|
| `completeShell` | `boolean` | `true` | Initial default for shell-mode suggestions and learning; a persisted `/quill shell` toggle takes precedence. |
|
|
199
|
+
| `minSuggestedWordLength` | `number` | `0` | Minimum number of characters in a suggested word, for both prose and shell suggestions; `0` allows any length. |
|
|
196
200
|
| `acceptKeys` | `string[]` | `["tab", "right"]` | Keys that accept and insert the active word suggestion. |
|
|
197
201
|
| `dismissKeys` | `string[]` | `["escape"]` | Keys that dismiss the visible suggestion without inserting. |
|
|
198
202
|
| `cycleNextKeys` | `string[]` | `[]` | Optional keys for the next confident word suggestion. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-quill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"prepublishOnly": "bun run test && bun run typecheck"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@opentui/core": "^0.8.
|
|
55
|
-
"@opentui/solid": "^0.8.
|
|
54
|
+
"@opentui/core": "^0.8.1",
|
|
55
|
+
"@opentui/solid": "^0.8.1",
|
|
56
56
|
"subtlex-word-frequencies": "2.0.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@commitlint/cli": "^21.2.2",
|
|
64
64
|
"@commitlint/config-conventional": "^21.2.2",
|
|
65
|
-
"@opencode/plugin": "2.2.
|
|
65
|
+
"@opencode/plugin": "2.2.6",
|
|
66
66
|
"@types/bun": "^1.4.2",
|
|
67
|
-
"@types/node": "26.6.
|
|
67
|
+
"@types/node": "26.6.6",
|
|
68
68
|
"husky": "^9.1.7",
|
|
69
69
|
"solid-js": "1.9.12",
|
|
70
70
|
"typescript": "7.0.2"
|
package/src/options.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Options = { enabled: boolean; completeAtLineEnd: boolean; completeShell: boolean; acceptKeys: string[]; dismissKeys: string[]; cycleNextKeys: string[]; cyclePreviousKeys: string[] }
|
|
1
|
+
export type Options = { enabled: boolean; completeAtLineEnd: boolean; completeShell: boolean; minSuggestedWordLength: number; acceptKeys: string[]; dismissKeys: string[]; cycleNextKeys: string[]; cyclePreviousKeys: string[] }
|
|
2
2
|
|
|
3
3
|
function keys(value: unknown, fallback: string[], name: string): string[] {
|
|
4
4
|
if (value === undefined) return fallback
|
|
@@ -12,10 +12,12 @@ export function resolveOptions(input: Readonly<Record<string, unknown>>): Option
|
|
|
12
12
|
if (input.enabled !== undefined && typeof input.enabled !== "boolean") throw new Error("Quill enabled must be a boolean")
|
|
13
13
|
if (input.completeAtLineEnd !== undefined && typeof input.completeAtLineEnd !== "boolean") throw new Error("Quill completeAtLineEnd must be a boolean")
|
|
14
14
|
if (input.completeShell !== undefined && typeof input.completeShell !== "boolean") throw new Error("Quill completeShell must be a boolean")
|
|
15
|
+
if (input.minSuggestedWordLength !== undefined && (typeof input.minSuggestedWordLength !== "number" || !Number.isInteger(input.minSuggestedWordLength) || input.minSuggestedWordLength < 0)) throw new Error("Quill minSuggestedWordLength must be a non-negative integer")
|
|
15
16
|
return {
|
|
16
17
|
enabled: input.enabled !== false,
|
|
17
18
|
completeAtLineEnd: input.completeAtLineEnd === true,
|
|
18
19
|
completeShell: input.completeShell !== false,
|
|
20
|
+
minSuggestedWordLength: input.minSuggestedWordLength ?? 0,
|
|
19
21
|
acceptKeys: keys(input.acceptKeys, ["tab", "right"], "acceptKeys"),
|
|
20
22
|
dismissKeys: keys(input.dismissKeys, ["escape"], "dismissKeys"),
|
|
21
23
|
cycleNextKeys: keys(input.cycleNextKeys, [], "cycleNextKeys"),
|
package/src/predictor.ts
CHANGED
|
@@ -212,9 +212,11 @@ export class WordPredictor {
|
|
|
212
212
|
private bigramTotals = new Map<string, Totals>()
|
|
213
213
|
private trigramTotals = new Map<string, Totals>()
|
|
214
214
|
private vocabulary: string[] = []
|
|
215
|
+
private known = new Set<string>()
|
|
216
|
+
private followers = new Map<string, string[]>()
|
|
215
217
|
private forms = new Map<string, string>()
|
|
216
218
|
|
|
217
|
-
constructor(prior: readonly Frequency[], readonly grammar: Grammar = proseGrammar) {
|
|
219
|
+
constructor(prior: readonly Frequency[], readonly grammar: Grammar = proseGrammar, private readonly minSuggestedWordLength = 0) {
|
|
218
220
|
for (const { word, count } of prior) {
|
|
219
221
|
const key = grammar.normalize(word)
|
|
220
222
|
if (!grammar.isWord(key) || !Number.isFinite(count) || count <= 0) continue
|
|
@@ -245,6 +247,18 @@ export class WordPredictor {
|
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
249
|
this.vocabulary = [...new Set([...this.prior.keys(), ...learned.filter((word) => !fragments.has(word))])].sort()
|
|
250
|
+
this.known = new Set(this.vocabulary)
|
|
251
|
+
this.followers = new Map()
|
|
252
|
+
for (const map of [this.personal.bigrams, this.personal.trigrams]) {
|
|
253
|
+
for (const [key, count] of map) {
|
|
254
|
+
if (count < 2) continue
|
|
255
|
+
const split = key.lastIndexOf("\0")
|
|
256
|
+
const context = key.slice(0, split)
|
|
257
|
+
const list = this.followers.get(context) ?? []
|
|
258
|
+
list.push(key.slice(split + 1))
|
|
259
|
+
this.followers.set(context, list)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
248
262
|
const forms = new Map<string, [string, number]>()
|
|
249
263
|
for (const [form, count] of this.personal.forms) {
|
|
250
264
|
const word = this.grammar.normalize(form)
|
|
@@ -315,10 +329,6 @@ export class WordPredictor {
|
|
|
315
329
|
return resolved
|
|
316
330
|
}
|
|
317
331
|
|
|
318
|
-
complete(query: CompletionQuery): Prediction | undefined {
|
|
319
|
-
return this.candidates(query, 1)[0]
|
|
320
|
-
}
|
|
321
|
-
|
|
322
332
|
candidates(query: CompletionQuery, limit = 5): Prediction[] {
|
|
323
333
|
const maximum = Number.isFinite(limit) ? Math.max(0, Math.min(5, Math.floor(limit))) : 5
|
|
324
334
|
if (!maximum) return []
|
|
@@ -337,10 +347,15 @@ export class WordPredictor {
|
|
|
337
347
|
(pair ? this.personal.trigrams.get(`${pair}\0${word}`) ?? 0 : 0) >= 2
|
|
338
348
|
const eligible = (word: string) => !query.next || followed(word)
|
|
339
349
|
const candidates = new Map<string, number>()
|
|
340
|
-
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
|
|
350
|
+
if (query.next) {
|
|
351
|
+
const next = new Set([...this.followers.get(previous ?? "") ?? [], ...(pair && this.followers.get(pair)) || []])
|
|
352
|
+
for (const word of [...next].sort()) if (this.known.has(word) && word.startsWith(prefix)) candidates.set(word, 1)
|
|
353
|
+
} else {
|
|
354
|
+
for (let index = lowerBound(this.vocabulary, prefix); index < this.vocabulary.length; index++) {
|
|
355
|
+
const word = this.vocabulary[index]
|
|
356
|
+
if (!word.startsWith(prefix)) break
|
|
357
|
+
if (slash === word.includes("/")) candidates.set(word, 1)
|
|
358
|
+
}
|
|
344
359
|
}
|
|
345
360
|
for (const word of local.keys()) if (!word.includes("/") && word.startsWith(prefix) && (query.next || !slash) && eligible(word)) candidates.set(word, 1)
|
|
346
361
|
const suggest = (): Prediction[] => {
|
|
@@ -350,6 +365,7 @@ export class WordPredictor {
|
|
|
350
365
|
const base = this.score(word, context, weight < 1) + (query.next ? 0 : 0.003 * Math.min(local.get(word) ?? 0, 3))
|
|
351
366
|
const score = base * weight
|
|
352
367
|
sum += score
|
|
368
|
+
if (this.minSuggestedWordLength && word !== prefix && [...word].length < this.minSuggestedWordLength) continue
|
|
353
369
|
ranked.push({ word, score, weight })
|
|
354
370
|
ranked.sort((a, b) => b.score - a.score)
|
|
355
371
|
if (ranked.length > maximum) ranked.pop()
|
|
@@ -364,7 +380,7 @@ export class WordPredictor {
|
|
|
364
380
|
const form = this.forms.get(best) ?? best
|
|
365
381
|
const shouting = this.grammar.prose && query.prefix.length > 1 && query.prefix === query.prefix.toUpperCase()
|
|
366
382
|
if (bestWeight < 1 || (!query.next && best.startsWith("i'") && query.prefix[0] === "i") ||
|
|
367
|
-
(!query.next && !shouting && form !== best && !form.startsWith(query.prefix))) {
|
|
383
|
+
(!query.next && ((!shouting && form !== best && !form.startsWith(query.prefix)) || form.length !== best.length))) {
|
|
368
384
|
predictions.push({ suffix: applyCase(query.prefix, form), word: best, confidence, replace: query.prefix.length })
|
|
369
385
|
} else if (query.next) {
|
|
370
386
|
predictions.push({ suffix: this.grammar.prose ? applyCase("", form) : form, word: best, confidence })
|
package/src/shell.ts
CHANGED
|
@@ -5,7 +5,13 @@ const PIECE = new RegExp(`^(?:-{1,2}|${NAME})$`)
|
|
|
5
5
|
const WORD = /-{0,2}[A-Za-z](?:[A-Za-z0-9._+:-]*[A-Za-z0-9])?/g
|
|
6
6
|
const WHOLE_WORD = /^-{0,2}[A-Za-z](?:[A-Za-z0-9._+:-]*[A-Za-z0-9])?$/
|
|
7
7
|
const OPERATORS = /[|;&<>()]+/
|
|
8
|
-
const
|
|
8
|
+
const SECRET_WORDS = /token|secret|passw|passphrase|\bpass:|\s-pass(?:in|out)?\b|pwd=|bearer|authorization|credential|(?:api|access|private)[-_]?key|cookie\s*[:=]|--cookie|\b(?:curl|wget)\b.*cookie/i
|
|
9
|
+
const SECRET_SHAPES = new RegExp([
|
|
10
|
+
/\bsk[-_]|\bgh[pousr]_|\bgithub_pat_|\bglpat-|\bxox[abprs]-|\beyJ[\w-]{10,}|\bAKIA[0-9A-Z]{16}/.source,
|
|
11
|
+
/\b(?:curl|wget|https?|xh)\b.*\s(?:-u\s*|--user[\s=]+)\S*:/.source,
|
|
12
|
+
/\b(?:mysql|mysqldump|mysqladmin|mariadb)\b.*\s-p\S/.source,
|
|
13
|
+
/\b(?:sshpass|redis-cli|mongosh?)\b.*\s-[pa]|\b(?:docker|podman)\s+login\b.*\s-p\b|\bzip\b.*\s-P\s/.source,
|
|
14
|
+
].join("|"))
|
|
9
15
|
const QUOTED = /"(?:[^"\\\n]|\\.)*"?|'[^'\n]*'?|`[^`\n]*`?|\$\{[^}\n]*\}?|\$\([^)\n]*\)?|\$[\w@#?*!$-]*/g
|
|
10
16
|
|
|
11
17
|
function plausible(piece: string): boolean {
|
|
@@ -13,7 +19,7 @@ function plausible(piece: string): boolean {
|
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export function maskShell(text: string): string {
|
|
16
|
-
if (
|
|
22
|
+
if (SECRET_WORDS.test(text) || SECRET_SHAPES.test(text)) return blank(text)
|
|
17
23
|
return text.replace(QUOTED, blank).replace(/\S+/g, (token) => token.split(OPERATORS).every(plausible) ? token : blank(token))
|
|
18
24
|
}
|
|
19
25
|
|
package/src/tui.tsx
CHANGED
|
@@ -24,8 +24,8 @@ export default Plugin.define({
|
|
|
24
24
|
const [shellLearning, setShellLearning] = context.storage.store("shell", {
|
|
25
25
|
initial: { snapshot: emptySnapshot() },
|
|
26
26
|
})
|
|
27
|
-
const predictor = new WordPredictor(frequencies)
|
|
28
|
-
const shellPredictor = new WordPredictor([], shellGrammar)
|
|
27
|
+
const predictor = new WordPredictor(frequencies, proseGrammar, options.minSuggestedWordLength)
|
|
28
|
+
const shellPredictor = new WordPredictor([], shellGrammar, options.minSuggestedWordLength)
|
|
29
29
|
const composers = new Map<string, { marker: BoxRenderable; mode: () => "normal" | "shell" }>()
|
|
30
30
|
const seeded = new Set<string>()
|
|
31
31
|
const inFlight = new Map<string, { pending: boolean; announce: boolean }>()
|
|
@@ -42,10 +42,16 @@ export default Plugin.define({
|
|
|
42
42
|
return route.type === "home" ? "home" : route.type === "session" ? route.sessionID : undefined
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
let found: { marker: BoxRenderable; editor: TextareaRenderable | undefined; text: string } | undefined
|
|
45
46
|
const currentEditor = () => {
|
|
46
47
|
const key = routeKey()
|
|
47
48
|
const composer = key && composers.get(key)
|
|
48
|
-
|
|
49
|
+
if (!composer) return
|
|
50
|
+
const cached = found?.marker === composer.marker && found.editor
|
|
51
|
+
if (cached && !cached.isDestroyed && !composer.marker.isDestroyed && cached.parent && !cached.parent.isDestroyed && cached.plainText === found!.text) return cached
|
|
52
|
+
const editor = findComposer(composer.marker, (node): node is TextareaRenderable => node instanceof TextareaRenderable && !(node instanceof InputRenderable))
|
|
53
|
+
found = { marker: composer.marker, editor, text: editor?.plainText ?? "" }
|
|
54
|
+
return editor
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
const syncEditor = () => {
|