opencode-quill 0.5.1 → 0.6.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,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.6.0] - 2026-10-22
8
+
9
+ ### Added
10
+
11
+ - **completion:** Learn hyphenated words, brand names, filenames and shell commands
12
+
13
+ ## [0.5.2] - 2026-10-22
14
+
15
+ ### Fixed
16
+
17
+ - **prediction:** Restore personal completion weight, next-word predictions, and slash-command prose
18
+
7
19
  ## [0.5.1] - 2026-10-22
8
20
 
9
21
  ### Fixed
@@ -121,6 +133,8 @@ All notable changes are documented in this file using
121
133
  - `/quill` command and command palette action to toggle autocomplete.
122
134
  - Local installer script, full test suite, CI workflows, and release tooling.
123
135
 
136
+ [0.6.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.5.2...v0.6.0
137
+ [0.5.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.5.1...v0.5.2
124
138
  [0.5.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.5.0...v0.5.1
125
139
  [0.5.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.4.0...v0.5.0
126
140
  [0.4.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.4...v0.4.0
package/README.md CHANGED
@@ -41,8 +41,15 @@ Press <kbd>Tab</kbd> or <kbd>→</kbd> to accept it, or <kbd>Esc</kbd> to dismis
41
41
  predicts words in an *active* draft locally. When both are installed, each
42
42
  activates only in its respective domain without key conflicts.
43
43
  - **Prose-aware gating:** Automatically suppresses suggestions in code blocks,
44
- backticks, file paths, URLs, slash commands, shell executions, active selections,
45
- and modal dialogs. Attachment and pasted-text chips are treated as non-prose:
44
+ backticks, file paths, URLs, slash commands, active selections, and modal
45
+ dialogs. Hyphenated words (`read-only`), brand names (`OpenCode`, `GitHub`)
46
+ and bare filenames with common extensions (`install.sh`) count as prose;
47
+ identifiers (`showSidebar`), flags and `key=value` tokens do not.
48
+ - **Shell mode:** In the prompt's shell mode Quill completes commands,
49
+ subcommands and flags from a separate vocabulary learned from the commands
50
+ you ran, never from prose. Shell completion is case-sensitive, never corrects
51
+ typos, and skips paths, quoted strings, `$` expansions, assignments and any
52
+ command that mentions a token, secret, password, key or credential. Attachment and pasted-text chips are treated as non-prose:
46
53
  words are still suggested after them, but never inside them, and typo
47
54
  replacements are not offered while a chip is present.
48
55
  - **End-of-draft by default:** Suggestions appear on a partial word or after a
@@ -167,6 +174,7 @@ Restart OpenCode after editing `cli.json`.
167
174
  | --- | --- | --- | --- |
168
175
  | `enabled` | `boolean` | `true` | Initial default for suggestions and learning; a persisted `/quill` toggle takes precedence. |
169
176
  | `completeAtLineEnd` | `boolean` | `false` | Also append completions or next words immediately before a newline within a draft. |
177
+ | `completeShell` | `boolean` | `true` | Initial default for shell-mode suggestions and learning; a persisted `/quill shell` toggle takes precedence. |
170
178
  | `acceptKeys` | `string[]` | `["tab", "right"]` | Keys that accept and insert the active word suggestion. |
171
179
  | `dismissKeys` | `string[]` | `["escape"]` | Keys that dismiss the visible suggestion without inserting. |
172
180
  | `cycleNextKeys` | `string[]` | `[]` | Optional keys for the next confident word suggestion. |
@@ -211,7 +219,8 @@ handlers remain in control. Dialogs and selections also suppress Quill.
211
219
 
212
220
  - `/quill` — Toggle word autocomplete on or off (persisted across sessions).
213
221
  - `/quill on` / `/quill off` — Set autocomplete explicitly.
214
- - `/quill clear` (alias `/quill reset`) — Erase everything Quill has learned from your prompts.
222
+ - `/quill shell on` / `/quill shell off` — Set shell-mode autocomplete explicitly.
223
+ - `/quill clear` (alias `/quill reset`) — Erase everything Quill has learned from your prompts and shell commands.
215
224
  - `quill.next` / `quill.previous` — Keymap commands for cycling visible word
216
225
  alternatives; no default bindings. Configure the cycle options above or
217
226
  OpenCode's `keybinds` map.
@@ -232,8 +241,11 @@ Quill learns from your own submitted prompts, never from assistant output:
232
241
  processed IDs, including those of ignored pastes, are retained until
233
242
  `/quill clear`.
234
243
  - Only prose is learned. Code blocks, inline code, URLs, file paths,
235
- identifiers, slash commands, shell lines, indented blocks and very large
236
- pastes are ignored.
244
+ identifiers, slash commands, shell lines, indented blocks that do not
245
+ continue a list item, and very large pastes are ignored.
246
+ - Commands you run in shell mode are learned into a separate shell model from
247
+ the session's shell messages, on the same triggers and with the same
248
+ deduplication. Only plain words and flags are kept.
237
249
  - Punctuation, line breaks and code reset the context, so words separated by
238
250
  syntax are never learned as adjacent.
239
251
  - A word missing from the base vocabulary becomes suggestible only after it
@@ -279,14 +291,15 @@ state directory (`$XDG_STATE_HOME` when set, otherwise `~/.local/state`):
279
291
  | Data | File |
280
292
  | --- | --- |
281
293
  | Learned model | `opencode/<channel>/tui/plugin.quill.learning.json` |
294
+ | Learned shell model | `opencode/<channel>/tui/plugin.quill.shell.json` |
282
295
  | Settings | `opencode/<channel>/tui/plugin.quill.settings.json` |
283
296
 
284
- The learned model holds word, bigram, trigram and word-casing counts plus
297
+ The learned models hold word, bigram, trigram and word-casing counts plus
285
298
  processed message IDs. These include local one-to-three-word fragments from
286
299
  your prose, so the model can reveal parts of your prompts. Quill does not store
287
300
  raw prompts or full message bodies. These files stay on your machine and are
288
- never tracked in Git or published to npm. `/quill clear` erases the learned
289
- model; the persisted on/off setting is separate.
301
+ never tracked in Git or published to npm. `/quill clear` erases both learned
302
+ models; the persisted on/off settings are separate.
290
303
 
291
304
  The processed-ID ledger is not pruned: its memory usage, stored size, and full
292
305
  serialization cost grow with the number of processed messages. Word and context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-quill",
3
- "version": "0.5.1",
3
+ "version": "0.6.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/ghost.ts CHANGED
@@ -7,6 +7,7 @@ export type Composer = {
7
7
  normal: boolean
8
8
  focused: unknown
9
9
  mode: string
10
+ shell?: boolean
10
11
  selected: boolean
11
12
  enabled: boolean
12
13
  }
@@ -39,9 +40,9 @@ export function findComposer(marker: Renderable | undefined, isEditor: (node: Re
39
40
  }
40
41
 
41
42
  export class ComposerGhost {
42
- private shown: { text: string; offset: number; prediction: Prediction; marks: string; revision: number } | undefined
43
+ private shown: { text: string; offset: number; prediction: Prediction; marks: string; revision: number; predictor: WordPredictor } | undefined
43
44
  private dismissed: { text: string; offset: number } | undefined
44
- private memo: { text: string; offset: number; marks: string; revision: number; predictions: Prediction[]; index: number } | undefined
45
+ private memo: { text: string; offset: number; marks: string; revision: number; predictor: WordPredictor; predictions: Prediction[]; index: number } | undefined
45
46
  private disposed = false
46
47
  private readonly draw: (buffer: OptimizedBuffer, delta: number) => void
47
48
 
@@ -52,11 +53,16 @@ export class ComposerGhost {
52
53
  private readonly color: () => RGBA,
53
54
  private readonly renderer: CliRenderer,
54
55
  private readonly completeAtLineEnd = false,
56
+ private readonly shellPredictor?: WordPredictor,
55
57
  ) {
56
58
  this.draw = (buffer) => { if (!this.disposed) this.paint(buffer) }
57
59
  renderer.addPostProcessFn(this.draw)
58
60
  }
59
61
 
62
+ private active(): WordPredictor {
63
+ return this.shellPredictor && this.view().shell ? this.shellPredictor : this.predictor
64
+ }
65
+
60
66
  private offset(): number {
61
67
  return this.editor.editBuffer.getTextRange(0, this.editor.cursorOffset).length
62
68
  }
@@ -96,20 +102,21 @@ export class ComposerGhost {
96
102
  if (this.dismissed || !eligibleComposer(this.view(), text)) return
97
103
  const marks = this.editor.extmarks.getAll()
98
104
  const signature = this.marksKey()
99
- const revision = this.predictor.modelRevision
100
- if (this.memo?.text === text && this.memo.offset === offset && this.memo.marks === signature && this.memo.revision === revision) return this.memo.predictions[this.memo.index]
101
- const query = completionQuery(text, offset, this.protectedRanges(marks), this.completeAtLineEnd)
102
- const predictions = query ? this.predictor.candidates(query) : []
105
+ const predictor = this.active()
106
+ const revision = predictor.modelRevision
107
+ 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]
108
+ const query = completionQuery(text, offset, this.protectedRanges(marks), this.completeAtLineEnd, predictor.grammar)
109
+ const predictions = query ? predictor.candidates(query) : []
103
110
  if ((marks.length || offset !== text.length) && predictions[0]?.replace) predictions.length = 0
104
111
  else if (marks.length || offset !== text.length) predictions.splice(0, predictions.length, ...predictions.filter((prediction) => !prediction.replace))
105
112
  const last = this.shown
106
- if (query && !query.next && offset === text.length && last && last.offset === last.text.length && this.memo?.index === 0 && last.revision === revision && last.marks === signature && !last.prediction.replace && text.startsWith(last.text)) {
113
+ if (query && !query.next && offset === text.length && last && last.offset === last.text.length && this.memo?.index === 0 && last.revision === revision && last.predictor === predictor && last.marks === signature && !last.prediction.replace && text.startsWith(last.text)) {
107
114
  const typed = text.slice(last.text.length)
108
115
  if (typed && last.prediction.suffix.startsWith(typed) && typed.length < last.prediction.suffix.length) {
109
116
  predictions[0] = { ...last.prediction, suffix: last.prediction.suffix.slice(typed.length) }
110
117
  }
111
118
  }
112
- this.memo = { text, offset, marks: signature, revision, predictions, index: 0 }
119
+ this.memo = { text, offset, marks: signature, revision, predictor, predictions, index: 0 }
113
120
  return predictions[0]
114
121
  }
115
122
 
@@ -140,14 +147,14 @@ export class ComposerGhost {
140
147
  } finally {
141
148
  buffer.popScissorRect()
142
149
  }
143
- this.shown = { text, offset, prediction, marks: this.memo!.marks, revision: this.memo!.revision }
150
+ this.shown = { text, offset, prediction, marks: this.memo!.marks, revision: this.memo!.revision, predictor: this.memo!.predictor }
144
151
  }
145
152
 
146
153
  accept(): boolean {
147
154
  const shown = this.shown
148
155
  if (!shown || !this.visible()) return false
149
156
  const marks = this.editor.extmarks.getAll()
150
- if (!completionQuery(shown.text, shown.offset, this.protectedRanges(marks), this.completeAtLineEnd)) return false
157
+ if (!completionQuery(shown.text, shown.offset, this.protectedRanges(marks), this.completeAtLineEnd, shown.predictor.grammar)) return false
151
158
  if ((marks.length || shown.offset !== shown.text.length) && shown.prediction.replace) return false
152
159
  this.shown = undefined
153
160
  if (shown.prediction.replace) {
@@ -171,7 +178,7 @@ export class ComposerGhost {
171
178
  visible(): boolean {
172
179
  return !this.disposed && !!this.shown && eligibleComposer(this.view()) &&
173
180
  this.editor.plainText === this.shown.text && this.offset() === this.shown.offset &&
174
- this.marksKey() === this.shown.marks && this.predictor.modelRevision === this.shown.revision && this.fits(this.shown.prediction)
181
+ this.marksKey() === this.shown.marks && this.active() === this.shown.predictor && this.shown.predictor.modelRevision === this.shown.revision && this.fits(this.shown.prediction)
175
182
  }
176
183
 
177
184
  canCycle(): boolean {
package/src/options.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type Options = { enabled: boolean; completeAtLineEnd: boolean; acceptKeys: string[]; dismissKeys: string[]; cycleNextKeys: string[]; cyclePreviousKeys: string[] }
1
+ export type Options = { enabled: boolean; completeAtLineEnd: boolean; completeShell: boolean; 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
@@ -11,9 +11,11 @@ function keys(value: unknown, fallback: string[], name: string): string[] {
11
11
  export function resolveOptions(input: Readonly<Record<string, unknown>>): Options {
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
+ if (input.completeShell !== undefined && typeof input.completeShell !== "boolean") throw new Error("Quill completeShell must be a boolean")
14
15
  return {
15
16
  enabled: input.enabled !== false,
16
17
  completeAtLineEnd: input.completeAtLineEnd === true,
18
+ completeShell: input.completeShell !== false,
17
19
  acceptKeys: keys(input.acceptKeys, ["tab", "right"], "acceptKeys"),
18
20
  dismissKeys: keys(input.dismissKeys, ["escape"], "dismissKeys"),
19
21
  cycleNextKeys: keys(input.cycleNextKeys, [], "cycleNextKeys"),
@@ -25,6 +27,7 @@ export type QuillCommand =
25
27
  | { type: "toggle" }
26
28
  | { type: "enable"; value: boolean }
27
29
  | { type: "clear" }
30
+ | { type: "shell"; value: boolean }
28
31
  | { type: "invalid" }
29
32
 
30
33
  export function parseQuillCommand(input: string | undefined): QuillCommand {
@@ -33,5 +36,7 @@ export function parseQuillCommand(input: string | undefined): QuillCommand {
33
36
  if (raw === "clear" || raw === "reset") return { type: "clear" }
34
37
  if (raw === "on") return { type: "enable", value: true }
35
38
  if (raw === "off") return { type: "enable", value: false }
39
+ if (raw === "shell on") return { type: "shell", value: true }
40
+ if (raw === "shell off") return { type: "shell", value: false }
36
41
  return { type: "invalid" }
37
42
  }
package/src/predictor.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { isWord, leftContext, normalizeWord, proseSequences, proseWords, type CompletionQuery } from "./prose"
1
+ import { leftContext, proseGrammar, proseWords, type CompletionQuery, type Grammar } from "./prose"
2
2
 
3
3
  export type Frequency = { word: string; count: number }
4
4
  export type Snapshot = {
@@ -30,13 +30,13 @@ function sentenceStart(text: string, start: number): boolean {
30
30
  return index < 0 || /[\n.!?:]/.test(text[index])
31
31
  }
32
32
 
33
- function restore(rows: [string, number][], limit: number, parts = 1, forms = false): Map<string, number> {
33
+ function restore(rows: [string, number][], limit: number, grammar: Grammar, parts = 1, forms = false): Map<string, number> {
34
34
  return new Map(rows.slice(0, limit).filter(([key, count]) => {
35
35
  if (typeof key !== "string" || key.length > parts * 64 + parts - 1 || !Number.isFinite(count) || count <= 0) return false
36
36
  const words = key.split("\0")
37
- return words.length === parts && words.every((word) => isWord(word) && (forms
37
+ return words.length === parts && words.every((word) => grammar.isWord(word) && (forms
38
38
  ? word === word.normalize("NFC").replaceAll("’", "'")
39
- : word === normalizeWord(word)))
39
+ : word === grammar.normalize(word)))
40
40
  }))
41
41
  }
42
42
 
@@ -60,12 +60,12 @@ export class PersonalModel {
60
60
  readonly seen: Set<string>
61
61
  readonly clearedAt: number | undefined
62
62
 
63
- constructor(snapshot: Snapshot = emptySnapshot()) {
63
+ constructor(snapshot: Snapshot = emptySnapshot(), private readonly grammar: Grammar = proseGrammar) {
64
64
  this.clearedAt = Number.isFinite(snapshot.clearedAt) ? snapshot.clearedAt : undefined
65
- this.words = restore(snapshot.words, WORD_LIMIT)
66
- this.bigrams = restore(snapshot.bigrams, CONTEXT_LIMIT, 2)
67
- this.trigrams = restore(snapshot.trigrams, CONTEXT_LIMIT, 3)
68
- this.forms = restore(snapshot.forms ?? [], WORD_LIMIT, 1, true)
65
+ this.words = restore(snapshot.words, WORD_LIMIT, grammar)
66
+ this.bigrams = restore(snapshot.bigrams, CONTEXT_LIMIT, grammar, 2)
67
+ this.trigrams = restore(snapshot.trigrams, CONTEXT_LIMIT, grammar, 3)
68
+ this.forms = restore(snapshot.forms ?? [], WORD_LIMIT, grammar, 1, true)
69
69
  this.seen = new Set(snapshot.seen)
70
70
  }
71
71
 
@@ -76,13 +76,13 @@ export class PersonalModel {
76
76
  this.seen.add(prompt.id)
77
77
  changed = true
78
78
  if (prompt.text.length > 4000 || prompt.text.split("\n").length > 12) continue
79
- for (const sequence of proseSequences(prompt.text)) {
79
+ for (const sequence of this.grammar.sequences(prompt.text)) {
80
80
  const words = sequence.map((word) => word.text)
81
81
  for (let index = 0; index < words.length; index++) {
82
82
  const { start, end } = sequence[index]
83
83
  increment(this.words, words[index])
84
84
  const form = prompt.text.slice(start, end).normalize("NFC").replaceAll("’", "'")
85
- if (form !== words[index] && !sentenceStart(prompt.text, start)) increment(this.forms, form)
85
+ if (this.grammar.prose && form !== words[index] && !sentenceStart(prompt.text, start)) increment(this.forms, form)
86
86
  if (index > 0) increment(this.bigrams, `${words[index - 1]}\0${words[index]}`)
87
87
  if (index > 1) increment(this.trigrams, `${words[index - 2]}\0${words[index - 1]}\0${words[index]}`)
88
88
  }
@@ -210,10 +210,10 @@ export class WordPredictor {
210
210
  private vocabulary: string[] = []
211
211
  private forms = new Map<string, string>()
212
212
 
213
- constructor(prior: readonly Frequency[]) {
213
+ constructor(prior: readonly Frequency[], readonly grammar: Grammar = proseGrammar) {
214
214
  for (const { word, count } of prior) {
215
- const key = normalizeWord(word)
216
- if (!isWord(key) || !Number.isFinite(count) || count <= 0) continue
215
+ const key = grammar.normalize(word)
216
+ if (!grammar.isWord(key) || !Number.isFinite(count) || count <= 0) continue
217
217
  this.prior.set(key, (this.prior.get(key) ?? 0) + count)
218
218
  this.priorTotal += count
219
219
  if (this.prior.size >= PRIOR_LIMIT) break
@@ -223,7 +223,7 @@ export class WordPredictor {
223
223
 
224
224
  setPersonal(snapshot: Snapshot): void {
225
225
  this.revision++
226
- this.personal = new PersonalModel(snapshot)
226
+ this.personal = new PersonalModel(snapshot, this.grammar)
227
227
  this.personalTotal = [...this.personal.words.values()].reduce((sum, count) => sum + count, 0)
228
228
  this.bigramTotals = totals(this.personal.bigrams)
229
229
  this.trigramTotals = totals(this.personal.trigrams)
@@ -234,7 +234,7 @@ export class WordPredictor {
234
234
  const word = learned[index]
235
235
  if (this.prior.has(word)) continue
236
236
  for (let next = index + 1; next < learned.length && learned[next].startsWith(word); next++) {
237
- if (learned[next][word.length] !== "/" && counts.get(learned[next])! >= counts.get(word)!) {
237
+ if (!"/-.".includes(learned[next][word.length]) && counts.get(learned[next])! >= counts.get(word)!) {
238
238
  fragments.add(word)
239
239
  break
240
240
  }
@@ -243,7 +243,7 @@ export class WordPredictor {
243
243
  this.vocabulary = [...new Set([...this.prior.keys(), ...learned.filter((word) => !fragments.has(word))])].sort()
244
244
  const forms = new Map<string, [string, number]>()
245
245
  for (const [form, count] of this.personal.forms) {
246
- const word = normalizeWord(form)
246
+ const word = this.grammar.normalize(form)
247
247
  if ((forms.get(word)?.[1] ?? 0) < count) forms.set(word, [form, count])
248
248
  }
249
249
  this.forms = new Map([...forms].filter(([word, [, count]]) => count * 2 > (counts.get(word) ?? 0)).map(([word, [form]]) => [word, form]))
@@ -262,10 +262,11 @@ export class WordPredictor {
262
262
  }
263
263
  }
264
264
 
265
- private score(word: string, context: readonly string[]): number {
265
+ private score(word: string, context: readonly string[], typo = false): number {
266
266
  const prior = (this.prior.get(word) ?? 0) / (this.priorTotal || 1)
267
267
  const personal = (this.personal.words.get(word) ?? 0) / (this.personalTotal || 1)
268
- const weight = this.priorTotal ? Math.min(0.7, this.personalTotal / (this.personalTotal + 100)) : 1
268
+ const ratio = this.personalTotal / (this.personalTotal + 100)
269
+ const weight = this.priorTotal ? (typo ? Math.min(0.7, ratio) : ratio) : 1
269
270
  let score = weight * personal + (1 - weight) * prior
270
271
  const previous = context.at(-1)
271
272
  const bigram = previous && this.bigramTotals.get(previous)
@@ -275,7 +276,7 @@ export class WordPredictor {
275
276
  }
276
277
  const pair = context.length === 2 ? context.join("\0") : undefined
277
278
  const trigram = pair && this.trigramTotals.get(pair)
278
- if (trigram) {
279
+ if (trigram && trigram.total >= 2) {
279
280
  const count = this.personal.trigrams.get(`${pair}\0${word}`) ?? 0
280
281
  score = Math.max(count - DISCOUNT, 0) / trigram.total + DISCOUNT * trigram.types / trigram.total * score
281
282
  }
@@ -283,6 +284,7 @@ export class WordPredictor {
283
284
  }
284
285
 
285
286
  private resolveContext(raw: readonly string[], local: ReadonlyMap<string, number>): string[] {
287
+ if (!this.grammar.prose) return [...raw]
286
288
  const resolved: string[] = []
287
289
  for (const word of raw) {
288
290
  if (this.prior.has(word) || (this.personal.words.get(word) ?? 0) >= 2 || (local.get(word) ?? 0) >= 2 || word.length < 3) {
@@ -296,7 +298,7 @@ export class WordPredictor {
296
298
  if ((this.bigramTotals.get(candidate)?.total ?? 0) < 2) continue
297
299
  const weight = typoWeight(word, candidate, true)
298
300
  if (!weight) continue
299
- const score = this.score(candidate, resolved) * weight
301
+ const score = this.score(candidate, resolved, true) * weight
300
302
  sum += score
301
303
  if (score > bestScore) {
302
304
  best = candidate
@@ -315,12 +317,14 @@ export class WordPredictor {
315
317
  candidates(query: CompletionQuery, limit = 5): Prediction[] {
316
318
  const maximum = Number.isFinite(limit) ? Math.max(0, Math.min(5, Math.floor(limit))) : 5
317
319
  if (!maximum) return []
318
- const prefix = normalizeWord(query.prefix)
319
- const words = query.words ?? proseWords(query.before)
320
+ const prefix = this.grammar.normalize(query.prefix)
321
+ const words = query.words ?? (this.grammar.prose ? proseWords(query.before) : [])
320
322
  const local = new Map<string, number>()
321
323
  for (const word of words) increment(local, word.text)
322
324
  const context = this.resolveContext(leftContext(query.before, words), local)
323
- const evidence = this.bigramTotals.get(context.at(-1) ?? "")?.total ?? 0
325
+ const previous = context.at(-1)
326
+ const pair = context.length === 2 ? context.join("\0") : undefined
327
+ const evidence = this.bigramTotals.get(previous ?? "")?.total ?? 0
324
328
  if (query.next && evidence < 2) return []
325
329
  if (!query.next && [...prefix].length < 2 && evidence < 2) return []
326
330
  const slash = prefix.includes("/")
@@ -331,11 +335,13 @@ export class WordPredictor {
331
335
  if (query.next || slash === word.includes("/")) candidates.set(word, 1)
332
336
  }
333
337
  for (const word of local.keys()) if (!word.includes("/") && word.startsWith(prefix) && (query.next || !slash)) candidates.set(word, 1)
338
+ const followed = (word: string) => (previous ? this.personal.bigrams.get(`${previous}\0${word}`) ?? 0 : 0) >= 2 ||
339
+ (pair ? this.personal.trigrams.get(`${pair}\0${word}`) ?? 0 : 0) >= 2
334
340
  const suggest = (): Prediction[] => {
335
341
  const ranked: { word: string; score: number; weight: number }[] = []
336
342
  let sum = 0
337
343
  for (const [word, weight] of candidates) {
338
- const base = this.score(word, context) + (query.next ? 0 : 0.003 * Math.min(local.get(word) ?? 0, 3))
344
+ const base = this.score(word, context, weight < 1) + (query.next ? 0 : 0.003 * Math.min(local.get(word) ?? 0, 3))
339
345
  const score = base * weight
340
346
  sum += score
341
347
  ranked.push({ word, score, weight })
@@ -345,17 +351,17 @@ export class WordPredictor {
345
351
  const predictions: Prediction[] = []
346
352
  for (const { word: best, score: bestScore, weight: bestWeight } of ranked) {
347
353
  const confidence = bestWeight < 1 ? typoConfidence(bestScore, sum) : query.next ? bestScore : bestScore / (sum || 1)
348
- if (!bestScore || best === prefix || confidence === undefined || (bestWeight === 1 && confidence < (query.next ? 0.55 : 0.3))) {
354
+ if (!bestScore || best === prefix || confidence === undefined || (query.next && !followed(best)) || (bestWeight === 1 && confidence < 0.3)) {
349
355
  if (!predictions.length) return []
350
356
  continue
351
357
  }
352
358
  const form = this.forms.get(best) ?? best
353
- const shouting = query.prefix.length > 1 && query.prefix === query.prefix.toUpperCase()
359
+ const shouting = this.grammar.prose && query.prefix.length > 1 && query.prefix === query.prefix.toUpperCase()
354
360
  if (bestWeight < 1 || (!query.next && best.startsWith("i'") && query.prefix[0] === "i") ||
355
361
  (!query.next && !shouting && form !== best && !form.startsWith(query.prefix))) {
356
362
  predictions.push({ suffix: applyCase(query.prefix, form), word: best, confidence, replace: query.prefix.length })
357
363
  } else if (query.next) {
358
- predictions.push({ suffix: applyCase("", form), word: best, confidence })
364
+ predictions.push({ suffix: this.grammar.prose ? applyCase("", form) : form, word: best, confidence })
359
365
  } else {
360
366
  const suffix = form.slice(prefix.length)
361
367
  predictions.push({ suffix: shouting ? suffix.toUpperCase() : suffix, word: best, confidence })
@@ -364,7 +370,7 @@ export class WordPredictor {
364
370
  return predictions
365
371
  }
366
372
  const completion = suggest()
367
- if (completion.length || query.next || prefix.length < 3 || slash || candidates.has(prefix)) return completion
373
+ if (completion.length || query.next || prefix.length < 3 || slash || candidates.has(prefix) || !this.grammar.prose) return completion
368
374
  for (const word of this.nearbyWords(prefix)) {
369
375
  if (candidates.has(word)) continue
370
376
  const weight = typoWeight(prefix, word)
package/src/prose.ts CHANGED
@@ -1,11 +1,30 @@
1
1
  const PART = "[\\p{L}\\p{M}]+(?:['’][\\p{L}\\p{M}]+)*"
2
- const WORD = new RegExp(`${PART}(?:\\/${PART})?`, "gu")
3
- const WHOLE_WORD = new RegExp(`^${PART}(?:\\/${PART})?$`, "u")
4
- const WORD_PREFIX = new RegExp(`^${PART}(?:\\/(?:${PART})?)?$`, "u")
5
- const WORD_END = new RegExp(`${PART}(?:\\/(?:${PART})?)?$`, "u")
2
+ const HYPHENATED = `${PART}(?:-${PART})*`
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
+ const FILE = `${HYPHENATED}\\.${EXTENSION}`
5
+ const PREFIX = `(?:${FILE}|${HYPHENATED}-?(?:\\/(?:${HYPHENATED}-?)?)?)`
6
+ const WORD = new RegExp(`(?:${FILE}(?![\\p{L}\\p{M}\\p{N}])|${HYPHENATED}(?:\\/${HYPHENATED})?)`, "gu")
7
+ const WHOLE_WORD = new RegExp(`^(?:${FILE}|${HYPHENATED}(?:\\/${HYPHENATED})?)$`, "u")
8
+ const WORD_PREFIX = new RegExp(`^${PREFIX}$`, "u")
9
+ const WORD_END = new RegExp(`${PREFIX}$`, "u")
10
+ const FILE_NAME = new RegExp(`^${FILE}$`, "u")
11
+ const BRAND = /^(?:\p{Lu}\p{Ll}+(?:\p{Lu}\p{Ll}+|\p{Lu}{2,})|\p{Ll}\p{Lu}\p{Ll}+|macOS|iOS|iPadOS|tvOS|watchOS|visionOS)$/u
12
+ const LIST_MARKER = /^[ \t]*(?:[-*+]|\d{1,9}[.)])[ \t]/
13
+ const INDENTED = /^(?: {4}| {0,3}\t)/
6
14
 
7
15
  export type Word = { text: string; start: number; end: number }
8
16
  export type CompletionQuery = { before: string; prefix: string; next: boolean; words?: readonly Word[] }
17
+ export type Grammar = {
18
+ prose: boolean
19
+ normalize(word: string): string
20
+ isWord(word: string): boolean
21
+ isPrefix(prefix: string): boolean
22
+ mask(text: string): string
23
+ words(text: string, masked?: string): Word[]
24
+ sequences(text: string): Word[][]
25
+ wordEnd: RegExp
26
+ boundary: RegExp
27
+ }
9
28
 
10
29
  export function normalizeWord(word: string): string {
11
30
  return word.normalize("NFC").replaceAll("’", "'").toLowerCase()
@@ -19,10 +38,14 @@ function isPrefix(prefix: string): boolean {
19
38
  return WORD_PREFIX.test(prefix) && [...prefix].length <= 32
20
39
  }
21
40
 
22
- function blank(text: string): string {
41
+ export function blank(text: string): string {
23
42
  return text.replace(/[^\n]/g, " ")
24
43
  }
25
44
 
45
+ function brandOrPlain(segment: string): boolean {
46
+ return !/[\p{Ll}][\p{Lu}]/u.test(segment) || BRAND.test(segment.replace(/['’]s$/, ""))
47
+ }
48
+
26
49
  export function maskProse(text: string): string {
27
50
  let fence: string | undefined
28
51
  let masked = text.replace(/[^\n]+/g, (line) => {
@@ -40,13 +63,24 @@ export function maskProse(text: string): string {
40
63
  })
41
64
  masked = masked.replace(/(`+)[\s\S]*?(?:\1|$)/g, blank)
42
65
  masked = masked.replace(/(?:https?:\/\/|www\.)\S+|\[[^\]\n]*\]\([^\)\n]*\)|<[^>\n]+>/g, blank)
43
- masked = masked.replace(/^[ \t]*(?:[\/!$]|(?:const|let|var|function|class|import|export)\s|(?:Traceback|Error:)\b).*$/gm, blank)
44
- masked = masked.replace(/^(?: {4}| {0,3}\t).*$/gm, blank)
66
+ masked = masked.replace(/^[ \t]*(?:[!$]|(?:const|let|var|function|class|import|export)\s|(?:Traceback|Error:)\b).*$/gm, blank)
67
+ let list = false
68
+ masked = masked.replace(/[^\n]+/g, (line) => {
69
+ if (!line.trim()) return line
70
+ if (!INDENTED.test(line)) {
71
+ list = LIST_MARKER.test(line)
72
+ return line
73
+ }
74
+ return list ? line : blank(line)
75
+ })
45
76
  masked = masked.replace(/\S+/g, (token) => {
46
77
  const core = token.replace(/^["“‘([{]+|["”’),;:!?}\]]+$/g, "")
47
- if (/[_@=\\<>-]|\d|[\p{Ll}][\p{Lu}]/u.test(core) || /^[.~]/.test(core)) return blank(token)
48
- if (core.includes("/") && !(core.endsWith(".") ? WHOLE_WORD.test(core.slice(0, -1)) : WORD_PREFIX.test(core))) return blank(token)
49
- if (/[^.]+\.[^.]+|\.\.|--/.test(core)) return blank(token)
78
+ const bare = core.endsWith(".") ? core.slice(0, -1) : core
79
+ const named = FILE_NAME.test(bare)
80
+ if (/[_@=\\<>]|\d/.test(core) || /^[.~]/.test(core) || !bare.split(/[-/]/).every(brandOrPlain)) return blank(token)
81
+ if (core.includes("-") && !WORD_PREFIX.test(bare)) return blank(token)
82
+ if (core.includes("/") && !(core.endsWith(".") ? WHOLE_WORD.test(bare) : WORD_PREFIX.test(core))) return blank(token)
83
+ if (!named && /[^.]+\.[^.]+|\.\.|--/.test(core)) return blank(token)
50
84
  return token
51
85
  })
52
86
  return masked
@@ -54,12 +88,11 @@ export function maskProse(text: string): string {
54
88
 
55
89
  export function proseWords(text: string, masked = maskProse(text)): Word[] {
56
90
  return [...masked.matchAll(WORD)]
57
- .filter((match) => isWord(match[0]) && masked[match.index + match[0].length] !== "/")
91
+ .filter((match) => isWord(match[0]) && !/[/-]/.test(masked[match.index + match[0].length] ?? ""))
58
92
  .map((match) => ({ text: normalizeWord(match[0]), start: match.index, end: match.index + match[0].length }))
59
93
  }
60
94
 
61
- export function proseSequences(text: string): Word[][] {
62
- const words = proseWords(text)
95
+ export function wordSequences(text: string, words: readonly Word[]): Word[][] {
63
96
  const sequences: Word[][] = []
64
97
  let previous = -1
65
98
  for (const word of words) {
@@ -70,6 +103,22 @@ export function proseSequences(text: string): Word[][] {
70
103
  return sequences
71
104
  }
72
105
 
106
+ export function proseSequences(text: string): Word[][] {
107
+ return wordSequences(text, proseWords(text))
108
+ }
109
+
110
+ export const proseGrammar: Grammar = {
111
+ prose: true,
112
+ normalize: normalizeWord,
113
+ isWord,
114
+ isPrefix,
115
+ mask: maskProse,
116
+ words: proseWords,
117
+ sequences: proseSequences,
118
+ wordEnd: WORD_END,
119
+ boundary: /[ \t\n"“([{]/,
120
+ }
121
+
73
122
  export function leftContext(before: string, words: readonly Word[] = proseWords(before)): string[] {
74
123
  const result: string[] = []
75
124
  let end = before.length
@@ -92,23 +141,23 @@ function blankRanges(text: string, ranges: readonly TextRange[]): string {
92
141
  return result
93
142
  }
94
143
 
95
- export function completionQuery(draft: string, characterOffset: number, protectedRanges: readonly TextRange[] = [], completeAtLineEnd = false): CompletionQuery | undefined {
144
+ export function completionQuery(draft: string, characterOffset: number, protectedRanges: readonly TextRange[] = [], completeAtLineEnd = false, grammar: Grammar = proseGrammar): CompletionQuery | undefined {
96
145
  if (!draft.trim() || draft.length > 16_000 || characterOffset < 0 || characterOffset > draft.length ||
97
146
  (characterOffset !== draft.length && (!completeAtLineEnd || draft[characterOffset] !== "\n"))) return
98
- const masked = maskProse(protectedRanges.length ? blankRanges(draft, protectedRanges) : draft).slice(0, characterOffset)
147
+ const masked = grammar.mask(protectedRanges.length ? blankRanges(draft, protectedRanges) : draft).slice(0, characterOffset)
99
148
  const text = draft.slice(0, characterOffset)
100
- const prefix = WORD_END.exec(text)?.[0]
149
+ const prefix = grammar.wordEnd.exec(text)?.[0]
101
150
  let end = text.length
102
151
  if (prefix) {
103
152
  const start = text.length - prefix.length
104
- if (masked.slice(start) !== prefix || !isPrefix(prefix)) return
153
+ if (masked.slice(start) !== prefix || !grammar.isPrefix(prefix)) return
105
154
  const preceding = text[start - 1]
106
- if (preceding && !/[ \t\n"“([{]/.test(preceding)) return
155
+ if (preceding && !grammar.boundary.test(preceding)) return
107
156
  end = start
108
157
  } else if (!/[ \t]$/.test(text)) return
109
158
  const start = Math.max(0, end - 2000)
110
159
  const before = text.slice(start, end)
111
- const words = proseWords(before, masked.slice(start, end))
160
+ const words = grammar.words(before, masked.slice(start, end))
112
161
  if (!prefix && !leftContext(before, words).length) return
113
162
  return { before, prefix: prefix ?? "", next: !prefix, words }
114
163
  }
package/src/shell.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { blank, wordSequences, type Grammar, type Word } from "./prose"
2
+
3
+ const NAME = "-{0,2}[A-Za-z][A-Za-z0-9._+:-]*"
4
+ const PIECE = new RegExp(`^(?:-{1,2}|${NAME})$`)
5
+ const WORD = /-{0,2}[A-Za-z](?:[A-Za-z0-9._+:-]*[A-Za-z0-9])?/g
6
+ const WHOLE_WORD = /^-{0,2}[A-Za-z](?:[A-Za-z0-9._+:-]*[A-Za-z0-9])?$/
7
+ const OPERATORS = /[|;&<>()]+/
8
+ const SECRET = /token|secret|passw|bearer|authorization|api[-_]?key|credential|private[-_]?key|\bsk-/i
9
+ const QUOTED = /"(?:[^"\\\n]|\\.)*"?|'[^'\n]*'?|`[^`\n]*`?|\$\{[^}\n]*\}?|\$\([^)\n]*\)?|\$[\w@#?*!$-]*/g
10
+
11
+ function plausible(piece: string): boolean {
12
+ return !piece || (PIECE.test(piece) && !(piece.length >= 16 && /\d/.test(piece)))
13
+ }
14
+
15
+ export function maskShell(text: string): string {
16
+ if (SECRET.test(text)) return blank(text)
17
+ return text.replace(QUOTED, blank).replace(/\S+/g, (token) => token.split(OPERATORS).every(plausible) ? token : blank(token))
18
+ }
19
+
20
+ export function shellWords(text: string, masked = maskShell(text)): Word[] {
21
+ return [...masked.matchAll(WORD)]
22
+ .filter((match) => WHOLE_WORD.test(match[0]) && match[0].length <= 32 && !/[._+:-]/.test(masked[match.index + match[0].length] ?? ""))
23
+ .map((match) => ({ text: match[0], start: match.index, end: match.index + match[0].length }))
24
+ }
25
+
26
+ export const shellGrammar: Grammar = {
27
+ prose: false,
28
+ normalize: (word) => word,
29
+ isWord: (word) => WHOLE_WORD.test(word) && word.length <= 32,
30
+ isPrefix: (prefix) => PIECE.test(prefix) && prefix.length <= 32,
31
+ mask: maskShell,
32
+ words: shellWords,
33
+ sequences: (text) => wordSequences(text, shellWords(text)),
34
+ wordEnd: new RegExp(`(?:-{1,2}|${NAME})$`),
35
+ boundary: /[ \t\n|;&(]/,
36
+ }
package/src/tui.tsx CHANGED
@@ -4,23 +4,29 @@ import { InputRenderable, TextareaRenderable, type BoxRenderable } from "@opentu
4
4
  import { createEffect, createRoot, createSignal, onCleanup, untrack } from "solid-js"
5
5
  import { unwrap } from "solid-js/store"
6
6
  import frequencies from "subtlex-word-frequencies"
7
+ import { proseGrammar, type Grammar } from "./prose"
7
8
  import { ComposerGhost, dimGhostColor, findComposer } from "./ghost"
8
9
  import { completionLayer } from "./keymap"
9
10
  import { parseQuillCommand, resolveOptions } from "./options"
10
11
  import { emptySnapshot, PersonalModel, WordPredictor } from "./predictor"
12
+ import { shellGrammar } from "./shell"
11
13
 
12
14
  export default Plugin.define({
13
15
  id: "quill",
14
16
  setup(context) {
15
17
  const options = resolveOptions(context.options)
16
18
  const [settings, setSettings] = context.storage.store("settings", {
17
- initial: { enabled: options.enabled },
19
+ initial: { enabled: options.enabled, shell: options.completeShell },
18
20
  })
19
21
  const [learning, setLearning] = context.storage.store("learning", {
20
22
  initial: { snapshot: emptySnapshot() },
21
23
  })
24
+ const [shellLearning, setShellLearning] = context.storage.store("shell", {
25
+ initial: { snapshot: emptySnapshot() },
26
+ })
22
27
  const predictor = new WordPredictor(frequencies)
23
- const composers = new Map<string, { marker: BoxRenderable; normal: () => boolean }>()
28
+ const shellPredictor = new WordPredictor([], shellGrammar)
29
+ const composers = new Map<string, { marker: BoxRenderable; mode: () => "normal" | "shell" }>()
24
30
  const seeded = new Set<string>()
25
31
  const inFlight = new Map<string, { pending: boolean; announce: boolean }>()
26
32
  const [revision, setRevision] = createSignal(0)
@@ -29,6 +35,8 @@ export default Plugin.define({
29
35
  let warned = false
30
36
  let resetVersion = 0
31
37
 
38
+ const shellEnabled = () => settings.shell !== false
39
+
32
40
  const routeKey = () => {
33
41
  const route = context.ui.router.current()
34
42
  return route.type === "home" ? "home" : route.type === "session" ? route.sessionID : undefined
@@ -47,15 +55,17 @@ export default Plugin.define({
47
55
  ghost?.dispose()
48
56
  ghost = editor && new ComposerGhost(editor, predictor, () => {
49
57
  const key = routeKey()
58
+ const shell = !!key && composers.get(key)?.mode() === "shell"
50
59
  return {
51
60
  editor,
52
- normal: !!key && composers.get(key)?.normal() === true,
61
+ normal: !!key && composers.has(key),
53
62
  focused: context.renderer.currentFocusedEditor,
54
63
  mode: context.keymap.mode.current(),
64
+ shell,
55
65
  selected: context.renderer.hasSelection,
56
- enabled: !disposed && settings.enabled && currentEditor() === editor,
66
+ enabled: !disposed && settings.enabled && (!shell || shellEnabled()) && currentEditor() === editor,
57
67
  }
58
- }, () => dimGhostColor(context.theme.text.muted), context.renderer, options.completeAtLineEnd)
68
+ }, () => dimGhostColor(context.theme.text.muted), context.renderer, options.completeAtLineEnd, shellPredictor)
59
69
  }
60
70
 
61
71
  const sessionInfo = (sessionID: string) =>
@@ -85,27 +95,34 @@ export default Plugin.define({
85
95
  if (disposed || !settings.enabled) return
86
96
  if (sessionInfo(sessionID)?.parentID) return
87
97
  if (version !== resetVersion) continue
88
- const candidates = context.data.session.message.list(sessionID)
89
- .filter((message) => message.type === "user")
90
- .slice(-200)
91
- .map((message) => ({ id: `${sessionID}:${message.id}`, text: message.text, created: message.time?.created }))
92
- const promptsFor = (clearedAt: number | undefined) => candidates
93
- .filter((prompt) => clearedAt === undefined || (prompt.created !== undefined && prompt.created >= clearedAt))
94
- .map(({ id, text }) => ({ id, text }))
95
- const snapshot = unwrap(learning.snapshot)
96
- const seen = new Set(snapshot.seen)
97
- const prompts = promptsFor(snapshot.clearedAt)
98
- if (!prompts.some((prompt) => !seen.has(prompt.id))) continue
99
- const model = new PersonalModel(snapshot)
100
- if (model.observe(prompts)) {
101
- await setLearning((draft) => {
98
+ const messages = context.data.session.message.list(sessionID)
99
+ const absorb = async (store: typeof learning, update: typeof setLearning, grammar: Grammar, candidates: { id: string; text: string; created?: number }[]) => {
100
+ const promptsFor = (clearedAt: number | undefined) => candidates
101
+ .filter((prompt) => clearedAt === undefined || (prompt.created !== undefined && prompt.created >= clearedAt))
102
+ .map(({ id, text }) => ({ id, text }))
103
+ const snapshot = unwrap(store.snapshot)
104
+ const seen = new Set(snapshot.seen)
105
+ const prompts = promptsFor(snapshot.clearedAt)
106
+ if (!prompts.some((prompt) => !seen.has(prompt.id))) return
107
+ const model = new PersonalModel(snapshot, grammar)
108
+ if (!model.observe(prompts)) return
109
+ await update((draft) => {
102
110
  if (disposed || !settings.enabled || version !== resetVersion) return
103
111
  const session = sessionInfo(sessionID)
104
112
  if (!session || session.parentID) return
105
- const latest = new PersonalModel(unwrap(draft.snapshot))
113
+ const latest = new PersonalModel(unwrap(draft.snapshot), grammar)
106
114
  if (latest.observe(promptsFor(latest.clearedAt))) draft.snapshot = latest.snapshot()
107
115
  })
108
116
  }
117
+ await absorb(learning, setLearning, proseGrammar, messages
118
+ .filter((message) => message.type === "user")
119
+ .slice(-200)
120
+ .map((message) => ({ id: `${sessionID}:${message.id}`, text: message.text, created: message.time?.created })))
121
+ if (shellEnabled()) {
122
+ await absorb(shellLearning, setShellLearning, shellGrammar, messages
123
+ .flatMap((message) => message.type === "shell" ? [{ id: `${sessionID}:${message.id}`, text: message.command, created: message.time.created }] : [])
124
+ .slice(-200))
125
+ }
109
126
  } catch (error) {
110
127
  if (shouldAnnounce && !disposed && version === resetVersion && !warned) {
111
128
  warned = true
@@ -126,7 +143,9 @@ export default Plugin.define({
126
143
  }
127
144
  const cleared = { ...emptySnapshot(), clearedAt: Date.now() }
128
145
  predictor.setPersonal(cleared)
146
+ shellPredictor.setPersonal(cleared)
129
147
  await setLearning((draft) => { draft.snapshot = cleared })
148
+ await setShellLearning((draft) => { draft.snapshot = cleared })
130
149
  ghost?.invalidate()
131
150
  context.ui.toast.show({ title: "Quill", message: "Word autocomplete history cleared" })
132
151
  }
@@ -139,10 +158,18 @@ export default Plugin.define({
139
158
  predictor.setPersonal(unwrap(snapshot))
140
159
  ghost?.invalidate()
141
160
  })
161
+ createEffect(() => {
162
+ const snapshot = shellLearning.snapshot
163
+ snapshot.seen.length
164
+ snapshot.seen.at(-1)
165
+ shellPredictor.setPersonal(unwrap(snapshot))
166
+ ghost?.invalidate()
167
+ })
142
168
  createEffect(() => {
143
169
  revision()
144
170
  routeKey()
145
171
  settings.enabled
172
+ settings.shell
146
173
  context.keymap.mode.current()
147
174
  syncEditor()
148
175
  ghost?.invalidate()
@@ -184,8 +211,14 @@ export default Plugin.define({
184
211
  await clearHistory()
185
212
  return
186
213
  }
214
+ if (command.type === "shell") {
215
+ await setSettings((draft) => { draft.shell = command.value })
216
+ ghost?.invalidate()
217
+ context.ui.toast.show({ title: "Quill", message: `Shell autocomplete: ${command.value ? "on" : "off"}` })
218
+ return
219
+ }
187
220
  if (command.type === "invalid") {
188
- context.ui.toast.show({ title: "Quill", message: "Use /quill, /quill on, /quill off, or /quill clear", variant: "warning" })
221
+ context.ui.toast.show({ title: "Quill", message: "Use /quill, /quill on, /quill off, /quill shell on, /quill shell off, or /quill clear", variant: "warning" })
189
222
  return
190
223
  }
191
224
  const enabled = command.type === "enable" ? command.value : !settings.enabled
@@ -213,7 +246,7 @@ export default Plugin.define({
213
246
  const key = input.sessionID ?? "home"
214
247
  const node = marker()
215
248
  if (!node) return
216
- composers.set(key, { marker: node, normal: () => input.mode === "normal" })
249
+ composers.set(key, { marker: node, mode: () => input.mode })
217
250
  setRevision((value) => value + 1)
218
251
  onCleanup(() => {
219
252
  if (composers.get(key)?.marker !== node) return