opencode-ghost 1.3.11 → 1.3.13
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 +24 -0
- package/package.json +5 -5
- package/src/composer.ts +9 -4
- package/src/options.ts +3 -3
- package/src/text.ts +8 -5
- package/src/tui.tsx +18 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.3.13] - 2026-10-27
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **engines:** Require OpenCode >=2.2.0
|
|
13
|
+
|
|
14
|
+
## [1.3.12] - 2026-10-22
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Harden option validation, text normalization, cancellation and installer
|
|
19
|
+
|
|
8
20
|
## [1.3.11] - 2026-10-20
|
|
9
21
|
|
|
10
22
|
### Fixed
|
|
@@ -313,6 +325,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
313
325
|
- Options for `model`, `acceptKeys`, `maxChars`, `idleDelayMs`,
|
|
314
326
|
`recentMessages` and `system`.
|
|
315
327
|
|
|
328
|
+
[1.3.13]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.12...v1.3.13
|
|
329
|
+
[1.3.12]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.11...v1.3.12
|
|
316
330
|
[1.3.11]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.10...v1.3.11
|
|
317
331
|
[1.3.10]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.9...v1.3.10
|
|
318
332
|
[1.3.9]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.8...v1.3.9
|
package/README.md
CHANGED
|
@@ -19,6 +19,13 @@ a dimmed inline placeholder in the empty composer with
|
|
|
19
19
|
> Why "ghost": it writes the line you were about to type, then waits for you to
|
|
20
20
|
> take it.
|
|
21
21
|
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img src="assets/demo.gif" alt="ghost: a next-prompt suggestion appears in the empty composer and Tab accepts it" width="800">
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
**Install:** add `"opencode-ghost"` to `plugins` in `~/.config/opencode/cli.json`
|
|
27
|
+
and restart opencode ([details](#install)).
|
|
28
|
+
|
|
22
29
|
## What it does
|
|
23
30
|
|
|
24
31
|
- **Suggests your next message.** After a turn finishes, it debounces, builds a
|
|
@@ -35,6 +42,17 @@ a dimmed inline placeholder in the empty composer with
|
|
|
35
42
|
- **`/suggest` controls it.** Toggle suggestions, set a runtime model override,
|
|
36
43
|
or inspect live state and diagnostics; settings persist via the plugin's storage.
|
|
37
44
|
|
|
45
|
+
## Ghost or Quill?
|
|
46
|
+
|
|
47
|
+
| | ghost | [quill](https://github.com/ozandogrultan/opencode-quill) |
|
|
48
|
+
| ----------- | ------------------------------------------ | -------------------------------------------------------- |
|
|
49
|
+
| Suggests | your whole next prompt | the rest of the current word, or the next word |
|
|
50
|
+
| When | the composer is empty, after a turn | while you type a draft |
|
|
51
|
+
| How | a small model reads the recent conversation | a local n-gram model, no network |
|
|
52
|
+
| Model calls | one per turn | none |
|
|
53
|
+
|
|
54
|
+
Install both: each activates only in its own domain, with no key conflicts.
|
|
55
|
+
|
|
38
56
|
## Requirements
|
|
39
57
|
|
|
40
58
|
- [opencode](https://opencode.ai) v2 (TUI plugins).
|
|
@@ -267,6 +285,12 @@ bash scripts/changelog.sh check
|
|
|
267
285
|
No build step: like other opencode TUI plugins, the package ships TSX source and
|
|
268
286
|
opencode's runtime transpiles it.
|
|
269
287
|
|
|
288
|
+
## More OpenCode plugins
|
|
289
|
+
|
|
290
|
+
- [sesh](https://github.com/ozandogrultan/opencode-sesh) — search, preview, and resume every session across every project.
|
|
291
|
+
- [quill](https://github.com/ozandogrultan/opencode-quill) — local word completion and next-word prediction as you type.
|
|
292
|
+
- [ember](https://github.com/ozandogrultan/opencode-ember) — prices a cold prompt-cache rewrite before you send.
|
|
293
|
+
|
|
270
294
|
## Contributing
|
|
271
295
|
|
|
272
296
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for the check suite and commit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-ghost",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"description": "OpenCode ghost text autosuggest: suggests your next message as dimmed inline ghost text in the empty TUI composer, accepted with Tab or Right arrow.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"packageManager": "bun@1.4.2",
|
|
40
40
|
"engines": {
|
|
41
|
-
"opencode": ">=2.
|
|
41
|
+
"opencode": ">=2.2.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prepare": "husky",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"prepublishOnly": "bun run test && bun run typecheck"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@opentui/core": "^0.
|
|
54
|
-
"@opentui/solid": "^0.
|
|
53
|
+
"@opentui/core": "^0.7.0",
|
|
54
|
+
"@opentui/solid": "^0.7.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@opencode/plugin": "*",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@commitlint/cli": "^21.2.2",
|
|
62
62
|
"@commitlint/config-conventional": "^21.2.2",
|
|
63
|
-
"@opencode/plugin": "2.0
|
|
63
|
+
"@opencode/plugin": "2.2.0",
|
|
64
64
|
"@types/bun": "^1.4.3",
|
|
65
65
|
"@types/node": "26.6.5",
|
|
66
66
|
"husky": "^9.1.7",
|
package/src/composer.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { KeyEvent, KeyHandler, TextareaRenderable } from "@opentui/core"
|
|
2
2
|
|
|
3
3
|
export function editsComposer(event: { name: string; sequence: string; ctrl: boolean; meta: boolean; option?: boolean; super?: boolean; hyper?: boolean }): boolean {
|
|
4
|
-
if (event
|
|
4
|
+
if (removesOnly(event)) return true
|
|
5
|
+
if (event.ctrl && !event.meta && !event.option && !event.super && !event.hyper) return ["v", "j", "m", "-", "."].includes(event.name)
|
|
5
6
|
if (event.super && !event.ctrl && !event.meta && !event.option && !event.hyper && event.name === "z") return true
|
|
6
7
|
if (event.ctrl || event.meta || event.option || event.super || event.hyper) return false
|
|
7
|
-
if (["return", "enter", "linefeed", "
|
|
8
|
+
if (["return", "enter", "linefeed", "space"].includes(event.name)) return true
|
|
8
9
|
return [...event.sequence].length === 1 && !/[\u0000-\u001f\u007f]/.test(event.sequence)
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function removesOnly(event: { name: string; ctrl: boolean; meta: boolean; option?: boolean; super?: boolean; hyper?: boolean }): boolean {
|
|
12
13
|
if (event.ctrl && !event.meta && !event.option && !event.super && !event.hyper) return ["h", "d", "k", "u", "w"].includes(event.name)
|
|
14
|
+
if ((event.meta || event.option) && !event.ctrl && !event.super && !event.hyper) return ["backspace", "delete", "d"].includes(event.name)
|
|
15
|
+
if (event.super && !event.ctrl && !event.meta && !event.option && !event.hyper) return event.name === "backspace"
|
|
13
16
|
if (event.ctrl || event.meta || event.option || event.super || event.hyper) return false
|
|
14
17
|
return event.name === "backspace" || event.name === "delete"
|
|
15
18
|
}
|
|
@@ -85,8 +88,10 @@ export function composerAction(editor: Editor | undefined, focused: () => unknow
|
|
|
85
88
|
if (editor.plainText.length !== 0) return false
|
|
86
89
|
try {
|
|
87
90
|
editor.insertText(text)
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
return true
|
|
92
|
+
} catch {
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
export function keyName(event: { name: string; ctrl: boolean; meta: boolean; shift: boolean; option?: boolean; super?: boolean; hyper?: boolean }): string {
|
package/src/options.ts
CHANGED
|
@@ -76,11 +76,11 @@ export function resolveOptions(options: Readonly<Record<string, unknown>> | unde
|
|
|
76
76
|
enabled: typeof input.enabled === "boolean" ? input.enabled : DEFAULTS.enabled,
|
|
77
77
|
model: typeof input.model === "string" && input.model.trim() ? input.model.trim() : undefined,
|
|
78
78
|
acceptKeys: acceptKeys.length > 0 ? acceptKeys : [...DEFAULTS.acceptKeys],
|
|
79
|
-
maxChars: typeof maxChars === "number" && maxChars > 0 ? maxChars : DEFAULTS.maxChars,
|
|
79
|
+
maxChars: typeof maxChars === "number" && Number.isInteger(maxChars) && maxChars > 0 ? maxChars : DEFAULTS.maxChars,
|
|
80
80
|
idleDelayMs:
|
|
81
|
-
typeof idleDelayMs === "number" && idleDelayMs >= 0 ? idleDelayMs : DEFAULTS.idleDelayMs,
|
|
81
|
+
typeof idleDelayMs === "number" && Number.isFinite(idleDelayMs) && idleDelayMs >= 0 ? idleDelayMs : DEFAULTS.idleDelayMs,
|
|
82
82
|
recentMessages:
|
|
83
|
-
typeof recentMessages === "number" && recentMessages > 0
|
|
83
|
+
typeof recentMessages === "number" && Number.isInteger(recentMessages) && recentMessages > 0
|
|
84
84
|
? recentMessages
|
|
85
85
|
: DEFAULTS.recentMessages,
|
|
86
86
|
system: typeof input.system === "string" && input.system.trim() ? input.system : DEFAULT_SYSTEM,
|
package/src/text.ts
CHANGED
|
@@ -157,14 +157,16 @@ export function collapse(text: string): string {
|
|
|
157
157
|
|
|
158
158
|
export function clip(text: string, max: number): string {
|
|
159
159
|
const value = collapse(text)
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
const points = [...value]
|
|
161
|
+
if (points.length <= max) return value
|
|
162
|
+
return points.slice(0, max - 1).join("").trimEnd() + "…"
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
export function clipTail(text: string, max: number): string {
|
|
165
166
|
const value = collapse(text)
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
const points = [...value]
|
|
168
|
+
if (points.length <= max) return value
|
|
169
|
+
return "…" + points.slice(points.length - (max - 1)).join("").trimStart()
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
export function normalize(raw: string, maxChars: number): string | undefined {
|
|
@@ -176,9 +178,10 @@ export function normalize(raw: string, maxChars: number): string | undefined {
|
|
|
176
178
|
const cleaned = first
|
|
177
179
|
.replace(/\*\*([^*]+)\*\*/g, "$1")
|
|
178
180
|
.replace(/^[`"'*\-_#\s]+/, "")
|
|
181
|
+
.replace(/^next user message:\s*/i, "")
|
|
182
|
+
.replace(/^[`"'*\-_#\s]+/, "")
|
|
179
183
|
.replace(/[`"'*_#\s]+$/, "")
|
|
180
184
|
.replace(/`+/g, "")
|
|
181
|
-
.replace(/^next user message:\s*/i, "")
|
|
182
185
|
.trim()
|
|
183
186
|
if (!cleaned || /^none\.?$/i.test(cleaned)) return undefined
|
|
184
187
|
const points = [...cleaned]
|
package/src/tui.tsx
CHANGED
|
@@ -98,7 +98,11 @@ export default Plugin.define({
|
|
|
98
98
|
try {
|
|
99
99
|
await measure("syncMs", () => context.data.session.message.sync(sessionID))
|
|
100
100
|
syncing = false
|
|
101
|
-
if (signal.aborted
|
|
101
|
+
if (signal.aborted) return
|
|
102
|
+
if (!canGenerate(sessionID)) {
|
|
103
|
+
cancelSuggestion()
|
|
104
|
+
return
|
|
105
|
+
}
|
|
102
106
|
const messages = context.data.session.message.list(sessionID) as readonly TranscriptMessage[]
|
|
103
107
|
const transcript = buildTranscript(messages, opts.recentMessages)
|
|
104
108
|
if (!transcript) return
|
|
@@ -108,7 +112,11 @@ export default Plugin.define({
|
|
|
108
112
|
model = await measure("modelMs", () => explicit
|
|
109
113
|
? resolveExplicitModel(context.client, location, signal, explicit, catalog)
|
|
110
114
|
: resolveSmallModel(context.client, location, signal, session, catalog))
|
|
111
|
-
if (signal.aborted
|
|
115
|
+
if (signal.aborted) return
|
|
116
|
+
if (!canGenerate(sessionID)) {
|
|
117
|
+
cancelSuggestion()
|
|
118
|
+
return
|
|
119
|
+
}
|
|
112
120
|
if (!model) return
|
|
113
121
|
const raw = await measure("generationMs", () => generateSuggestion(
|
|
114
122
|
context.client,
|
|
@@ -124,14 +132,18 @@ export default Plugin.define({
|
|
|
124
132
|
noteGeneration({ outcome: "error", model: label, detail: errorDetail(failure) })
|
|
125
133
|
return
|
|
126
134
|
}
|
|
135
|
+
if (!canGenerate(sessionID)) {
|
|
136
|
+
cancelSuggestion()
|
|
137
|
+
return
|
|
138
|
+
}
|
|
127
139
|
if (!raw) {
|
|
128
|
-
if (!canGenerate(sessionID)) return
|
|
129
140
|
noteGeneration({ outcome: "empty", model: label })
|
|
130
141
|
return
|
|
131
142
|
}
|
|
132
143
|
const clean = normalize(raw, opts.maxChars)
|
|
133
144
|
if (!clean) {
|
|
134
|
-
|
|
145
|
+
const none = /^none\.?$/i.test(raw.trim())
|
|
146
|
+
noteGeneration({ outcome: "empty", model: label, ...(none ? {} : { chars: raw.length }) })
|
|
135
147
|
return
|
|
136
148
|
}
|
|
137
149
|
const previous = lastUserText(messages)
|
|
@@ -139,7 +151,6 @@ export default Plugin.define({
|
|
|
139
151
|
noteGeneration({ outcome: "echo", model: label, chars: clean.length })
|
|
140
152
|
return
|
|
141
153
|
}
|
|
142
|
-
if (!canGenerate(sessionID)) return
|
|
143
154
|
setSuggestion({ sessionID, text: clean })
|
|
144
155
|
noteGeneration({ outcome: "ok", model: label, chars: clean.length })
|
|
145
156
|
} catch (error) {
|
|
@@ -299,6 +310,7 @@ export default Plugin.define({
|
|
|
299
310
|
lifecycle.resetWarning()
|
|
300
311
|
catalog.clear()
|
|
301
312
|
await updateState((draft) => { draft.model = command.model })
|
|
313
|
+
cancelSuggestion()
|
|
302
314
|
context.ui.toast.show({ message: `Suggestion model: ${state.model ?? opts.model ?? "OpenCode small default"}` })
|
|
303
315
|
return
|
|
304
316
|
}
|
|
@@ -351,6 +363,7 @@ export default Plugin.define({
|
|
|
351
363
|
await updateState((draft) => {
|
|
352
364
|
draft.enabled = next
|
|
353
365
|
})
|
|
366
|
+
cancelSuggestion()
|
|
354
367
|
if (!next) {
|
|
355
368
|
context.ui.toast.show({ message: "Prompt suggestions: off" })
|
|
356
369
|
return
|