opencode-ghost 1.3.4 → 1.3.5
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 +8 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/composer.ts +4 -6
- package/src/options.ts +1 -1
- package/src/text.ts +7 -3
- package/src/tui.tsx +14 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ 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.5] - 2026-10-10
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **tui:** Clean up theme subscriptions and handle cancelled generations
|
|
13
|
+
- **tui:** Handle suggestion acceptance and source registrations safely
|
|
14
|
+
|
|
8
15
|
## [1.3.4] - 2026-10-09
|
|
9
16
|
|
|
10
17
|
### Fixed
|
|
@@ -270,6 +277,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
270
277
|
- Options for `model`, `acceptKeys`, `maxChars`, `idleDelayMs`,
|
|
271
278
|
`recentMessages` and `system`.
|
|
272
279
|
|
|
280
|
+
[1.3.5]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.4...v1.3.5
|
|
273
281
|
[1.3.4]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.3...v1.3.4
|
|
274
282
|
[1.3.3]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.2...v1.3.3
|
|
275
283
|
[1.3.2]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.1...v1.3.2
|
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ copy, use `/absolute/path/to/config/plugins/opencode-ghost`.
|
|
|
87
87
|
| ---------------- | ---------- | ------------------- | ------------------------------------------------------------- |
|
|
88
88
|
| `enabled` | `boolean` | `true` | Initial state; `/suggest` toggles it at runtime (persisted). |
|
|
89
89
|
| `model` | `string` | OpenCode small default | Explicit `provider/model` override. Otherwise uses the effective title-agent model or OpenCode's small-model selection policy. |
|
|
90
|
-
| `acceptKeys` | `string[]` | `["tab", "right"]` | Key names as reported by the terminal (`tab`, `right`, ...). Modifier aliases (`meta`, `option`, `cmd`, `control`) are normalised; unknown modifiers are ignored. |
|
|
90
|
+
| `acceptKeys` | `string[]` | `["tab", "right"]` | Key names as reported by the terminal (`tab`, `right`, ...). Modifier aliases (`meta`, `option`, `cmd`, `control`) are normalised; keys with unknown modifiers are ignored. |
|
|
91
91
|
| `maxChars` | `number` | `120` | Maximum suggestion length. |
|
|
92
92
|
| `idleDelayMs` | `number` | `500` | Debounce after a turn finishes before generating. |
|
|
93
93
|
| `recentMessages` | `number` | `10` | How many recent messages feed the suggestion prompt. |
|
|
@@ -143,7 +143,7 @@ When enabling, a suggestion is generated immediately for the current session.
|
|
|
143
143
|
ownership. Host hint/color updates are retained while the ghost is visible;
|
|
144
144
|
dismissal restores only values still owned by Ghost, including rich hints.
|
|
145
145
|
- Accepting uses the composer editor's `insertText` directly, without submitting.
|
|
146
|
-
- Typing, pasting,
|
|
146
|
+
- Typing, pasting, undo/redo, leaving the session, a new execution, disabling and unloading cancel
|
|
147
147
|
pending generation. Duplicate completion events do not generate again.
|
|
148
148
|
- Retains only one suggestion, bounded by `maxChars`, for the visible session.
|
|
149
149
|
Acceptance, a new turn, session changes, disabling, model changes and unloading
|
package/package.json
CHANGED
package/src/composer.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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.ctrl && !event.meta && !event.option && !event.super && !event.hyper) return ["v", "h", "d", "k", "u", "w", "j", "m"].includes(event.name)
|
|
4
|
+
if (event.ctrl && !event.meta && !event.option && !event.super && !event.hyper) return ["v", "h", "d", "k", "u", "w", "j", "m", "-", "."].includes(event.name)
|
|
5
|
+
if (event.super && !event.ctrl && !event.meta && !event.option && !event.hyper && event.name === "z") return true
|
|
5
6
|
if (event.ctrl || event.meta || event.option || event.super || event.hyper) return false
|
|
6
7
|
if (["return", "enter", "linefeed", "backspace", "delete", "space"].includes(event.name)) return true
|
|
7
8
|
return [...event.sequence].length === 1 && !/[\u0000-\u001f\u007f]/.test(event.sequence)
|
|
@@ -84,11 +85,8 @@ export function composerAction(editor: Editor | undefined, focused: () => unknow
|
|
|
84
85
|
if (editor.plainText.length !== 0) return false
|
|
85
86
|
try {
|
|
86
87
|
editor.insertText(text)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} catch {
|
|
90
|
-
return false
|
|
91
|
-
}
|
|
88
|
+
} catch {}
|
|
89
|
+
return true
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
export function keyName(event: { name: string; ctrl: boolean; meta: boolean; shift: boolean; option?: boolean; super?: boolean; hyper?: boolean }): string {
|
package/src/options.ts
CHANGED
|
@@ -57,7 +57,7 @@ const DEFAULTS = {
|
|
|
57
57
|
recentMessages: 10,
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const REMOVED_OPTION_KEYS = ["endpoint", "apiKey", "internalSessionMarkerDir", "argHints"
|
|
60
|
+
const REMOVED_OPTION_KEYS = ["endpoint", "apiKey", "internalSessionMarkerDir", "argHints"] as const
|
|
61
61
|
|
|
62
62
|
export function removedOptionKeys(raw: Readonly<Record<string, unknown>> | undefined): string[] {
|
|
63
63
|
if (!raw) return []
|
package/src/text.ts
CHANGED
|
@@ -123,9 +123,13 @@ export async function resolveExplicitModel(
|
|
|
123
123
|
): Promise<SuggestionModel | undefined> {
|
|
124
124
|
if (signal.aborted) return undefined
|
|
125
125
|
if (model.variant) return model
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
try {
|
|
127
|
+
const listed = await catalog.list(location, signal)
|
|
128
|
+
if (signal.aborted) return undefined
|
|
129
|
+
return withLowEffortVariant(model, listed.models.find((info) => info.providerID === model.providerID && info.id === model.modelID))
|
|
130
|
+
} catch {
|
|
131
|
+
return signal.aborted ? undefined : model
|
|
132
|
+
}
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
const LOW_EFFORT_VARIANTS = ["none", "minimal", "low"]
|
package/src/tui.tsx
CHANGED
|
@@ -42,7 +42,7 @@ export default Plugin.define({
|
|
|
42
42
|
const [suggestion, setSuggestion] = createSignal<Suggestion | undefined>()
|
|
43
43
|
const [composerRevision, setComposerRevision] = createSignal(0)
|
|
44
44
|
const inline = createInlinePlaceholder()
|
|
45
|
-
|
|
45
|
+
let ghostColor: () => ReturnType<typeof dimPlaceholderColor>
|
|
46
46
|
const diagnostics = createDiagnostics()
|
|
47
47
|
const catalog = createCatalog(context.client)
|
|
48
48
|
|
|
@@ -55,6 +55,7 @@ export default Plugin.define({
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
let disposed = false
|
|
58
|
+
let syncWarned = false
|
|
58
59
|
const composers = new Map<string, { marker: BoxRenderable; normal: () => boolean }>()
|
|
59
60
|
|
|
60
61
|
const isCurrentSession = (sessionID: string) => {
|
|
@@ -81,8 +82,10 @@ export default Plugin.define({
|
|
|
81
82
|
const elapsed = () => Date.now() - started
|
|
82
83
|
let model: SuggestionModel | undefined
|
|
83
84
|
let failure: unknown
|
|
85
|
+
let syncing = true
|
|
84
86
|
try {
|
|
85
87
|
await context.data.session.message.sync(sessionID)
|
|
88
|
+
syncing = false
|
|
86
89
|
if (signal.aborted || !canGenerate(sessionID)) return
|
|
87
90
|
const messages = context.data.session.message.list(sessionID) as readonly TranscriptMessage[]
|
|
88
91
|
const transcript = buildTranscript(messages, opts.recentMessages)
|
|
@@ -104,10 +107,7 @@ export default Plugin.define({
|
|
|
104
107
|
() => canGenerate(sessionID),
|
|
105
108
|
)
|
|
106
109
|
const label = modelLabel(model)
|
|
107
|
-
if (signal.aborted)
|
|
108
|
-
note({ sessionID, outcome: "aborted", model: label, durationMs: elapsed() })
|
|
109
|
-
return
|
|
110
|
-
}
|
|
110
|
+
if (signal.aborted) return
|
|
111
111
|
if (failure) {
|
|
112
112
|
note({ sessionID, outcome: "error", model: label, durationMs: elapsed(), detail: errorDetail(failure) })
|
|
113
113
|
return
|
|
@@ -132,7 +132,12 @@ export default Plugin.define({
|
|
|
132
132
|
note({ sessionID, outcome: "ok", model: label, durationMs: elapsed(), chars: clean.length })
|
|
133
133
|
} catch (error) {
|
|
134
134
|
if (signal.aborted) return
|
|
135
|
-
|
|
135
|
+
if (syncing) {
|
|
136
|
+
if (!disposed && !syncWarned) {
|
|
137
|
+
syncWarned = true
|
|
138
|
+
context.ui.toast.show({ title: "Ghost", message: "Suggestions unavailable: session messages could not sync.", variant: "warning" })
|
|
139
|
+
}
|
|
140
|
+
} else warnGeneration(error)
|
|
136
141
|
note({
|
|
137
142
|
sessionID,
|
|
138
143
|
outcome: isNoSmallModel(error) ? "unavailable" : "error",
|
|
@@ -140,6 +145,8 @@ export default Plugin.define({
|
|
|
140
145
|
durationMs: elapsed(),
|
|
141
146
|
detail: errorDetail(error),
|
|
142
147
|
})
|
|
148
|
+
} finally {
|
|
149
|
+
if (signal.aborted) note({ sessionID, outcome: "aborted", ...(model ? { model: modelLabel(model) } : {}), durationMs: elapsed() })
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
|
|
@@ -218,6 +225,7 @@ export default Plugin.define({
|
|
|
218
225
|
}
|
|
219
226
|
|
|
220
227
|
const disposeRouteWatcher = createRoot((dispose) => {
|
|
228
|
+
ghostColor = createMemo(() => dimPlaceholderColor(context.theme.text.muted))
|
|
221
229
|
createEffect(on(() => {
|
|
222
230
|
const route = context.ui.router.current()
|
|
223
231
|
return route.type === "session" ? route.sessionID : route.type
|