opencode-quill 0.5.0 → 0.5.1

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.5.1] - 2026-10-22
8
+
9
+ ### Fixed
10
+
11
+ - Harden learning persistence and release safety
12
+
7
13
  ## [0.5.0] - 2026-10-22
8
14
 
9
15
  ### Added
@@ -115,6 +121,7 @@ All notable changes are documented in this file using
115
121
  - `/quill` command and command palette action to toggle autocomplete.
116
122
  - Local installer script, full test suite, CI workflows, and release tooling.
117
123
 
124
+ [0.5.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.5.0...v0.5.1
118
125
  [0.5.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.4.0...v0.5.0
119
126
  [0.4.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.4...v0.4.0
120
127
  [0.3.4]: https://github.com/ozandogrultan/opencode-quill/compare/v0.3.3...v0.3.4
package/README.md CHANGED
@@ -228,7 +228,9 @@ Quill learns from your own submitted prompts, never from assistant output:
228
228
  `session.execution.succeeded`, `session.inbox.delivered`).
229
229
  - On startup and when you open a session, it also backfills from the user
230
230
  messages of the current and most recently updated sessions.
231
- - Each message is ingested once, tracked by `<sessionID>:<messageID>`.
231
+ - Each message is ingested once, tracked by `<sessionID>:<messageID>`. All
232
+ processed IDs, including those of ignored pastes, are retained until
233
+ `/quill clear`.
232
234
  - Only prose is learned. Code blocks, inline code, URLs, file paths,
233
235
  identifiers, slash commands, shell lines, indented blocks and very large
234
236
  pastes are ignored.
@@ -265,7 +267,7 @@ Quill learns from your own submitted prompts, never from assistant output:
265
267
  no suggestion. Context repair uses the same edit guards and confidence checks
266
268
  and requires repeated learned continuation evidence; not every typo produces
267
269
  a suggestion.
268
- - **Bounded size:** the personal model is pruned to its most frequent entries
270
+ - **Bounded counts:** the personal model is pruned to its most frequent entries
269
271
  when saved. Once it holds about 100,000 learned words, every count is halved
270
272
  and single-use entries are dropped, so recent habits outweigh old ones.
271
273
 
@@ -286,6 +288,12 @@ raw prompts or full message bodies. These files stay on your machine and are
286
288
  never tracked in Git or published to npm. `/quill clear` erases the learned
287
289
  model; the persisted on/off setting is separate.
288
290
 
291
+ The processed-ID ledger is not pruned: its memory usage, stored size, and full
292
+ serialization cost grow with the number of processed messages. Word and context
293
+ counts remain bounded. Existing version-1 snapshots keep their counts and
294
+ retained IDs without a reset. IDs absent from older capped snapshots cannot be
295
+ recovered, so those messages may be learned again when backfilled.
296
+
289
297
  ## Development
290
298
 
291
299
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-quill",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
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
@@ -18,7 +18,6 @@ const MIN_TYPO_SCORE = 0.000001
18
18
  const PRIOR_LIMIT = 20_000
19
19
  const WORD_LIMIT = 8000
20
20
  const CONTEXT_LIMIT = 30_000
21
- const SEEN_LIMIT = 8000
22
21
  const DECAY_TOTAL = 100_000
23
22
 
24
23
  export function emptySnapshot(): Snapshot {
@@ -31,8 +30,14 @@ function sentenceStart(text: string, start: number): boolean {
31
30
  return index < 0 || /[\n.!?:]/.test(text[index])
32
31
  }
33
32
 
34
- function restore(rows: [string, number][], limit: number): Map<string, number> {
35
- return new Map(rows.slice(0, limit).filter(([word, count]) => typeof word === "string" && word.length <= 100 && Number.isFinite(count) && count > 0))
33
+ function restore(rows: [string, number][], limit: number, parts = 1, forms = false): Map<string, number> {
34
+ return new Map(rows.slice(0, limit).filter(([key, count]) => {
35
+ if (typeof key !== "string" || key.length > parts * 64 + parts - 1 || !Number.isFinite(count) || count <= 0) return false
36
+ const words = key.split("\0")
37
+ return words.length === parts && words.every((word) => isWord(word) && (forms
38
+ ? word === word.normalize("NFC").replaceAll("’", "'")
39
+ : word === normalizeWord(word)))
40
+ }))
36
41
  }
37
42
 
38
43
  const byCount = (a: [string, number], b: [string, number]) => b[1] - a[1]
@@ -58,10 +63,10 @@ export class PersonalModel {
58
63
  constructor(snapshot: Snapshot = emptySnapshot()) {
59
64
  this.clearedAt = Number.isFinite(snapshot.clearedAt) ? snapshot.clearedAt : undefined
60
65
  this.words = restore(snapshot.words, WORD_LIMIT)
61
- this.bigrams = restore(snapshot.bigrams, CONTEXT_LIMIT)
62
- this.trigrams = restore(snapshot.trigrams, CONTEXT_LIMIT)
63
- this.forms = restore(snapshot.forms ?? [], WORD_LIMIT)
64
- this.seen = new Set(snapshot.seen.slice(-SEEN_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)
69
+ this.seen = new Set(snapshot.seen)
65
70
  }
66
71
 
67
72
  observe(prompts: readonly Prompt[]): boolean {
@@ -103,7 +108,7 @@ export class PersonalModel {
103
108
  bigrams: trim(this.bigrams, CONTEXT_LIMIT),
104
109
  trigrams: trim(this.trigrams, CONTEXT_LIMIT),
105
110
  forms: trim(this.forms, WORD_LIMIT),
106
- seen: [...this.seen].slice(-SEEN_LIMIT),
111
+ seen: [...this.seen],
107
112
  ...(this.clearedAt === undefined ? {} : { clearedAt: this.clearedAt }),
108
113
  }
109
114
  }
package/src/prose.ts CHANGED
@@ -24,11 +24,24 @@ function blank(text: string): string {
24
24
  }
25
25
 
26
26
  export function maskProse(text: string): string {
27
- let masked = text.replace(/(^|\n)[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*?(?:\n[ \t]*\2[^\n]*(?=\n|$)|$)/g, blank)
27
+ let fence: string | undefined
28
+ let masked = text.replace(/[^\n]+/g, (line) => {
29
+ if (fence) {
30
+ const closing = /^ {0,3}(`{3,}|~{3,})[ \t\r]*$/.exec(line)?.[1]
31
+ if (closing && closing[0] === fence[0] && closing.length >= fence.length) fence = undefined
32
+ return blank(line)
33
+ }
34
+ const opening = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line)
35
+ if (opening && (opening[1][0] !== "`" || !opening[2].includes("`"))) {
36
+ fence = opening[1]
37
+ return blank(line)
38
+ }
39
+ return line
40
+ })
28
41
  masked = masked.replace(/(`+)[\s\S]*?(?:\1|$)/g, blank)
29
42
  masked = masked.replace(/(?:https?:\/\/|www\.)\S+|\[[^\]\n]*\]\([^\)\n]*\)|<[^>\n]+>/g, blank)
30
43
  masked = masked.replace(/^[ \t]*(?:[\/!$]|(?:const|let|var|function|class|import|export)\s|(?:Traceback|Error:)\b).*$/gm, blank)
31
- masked = masked.replace(/^ {4,}.*$/gm, blank)
44
+ masked = masked.replace(/^(?: {4}| {0,3}\t).*$/gm, blank)
32
45
  masked = masked.replace(/\S+/g, (token) => {
33
46
  const core = token.replace(/^["“‘([{]+|["”’),;:!?}\]]+$/g, "")
34
47
  if (/[_@=\\<>-]|\d|[\p{Ll}][\p{Lu}]/u.test(core) || /^[.~]/.test(core)) return blank(token)