opencode-ghost 1.1.0 → 1.3.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 +9 -0
- package/package.json +1 -1
- package/src/composer.ts +30 -9
- package/src/diagnostics.ts +3 -1
- package/src/options.ts +10 -4
- package/src/tui.tsx +52 -7
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.0] - 2026-10-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **tui:** Explain why the ghost placeholder is not displayed
|
|
13
|
+
|
|
14
|
+
## [1.2.0] - 2026-10-09
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **options:** Improve default suggestion system prompt
|
|
19
|
+
|
|
8
20
|
## [1.1.0] - 2026-10-08
|
|
9
21
|
|
|
10
22
|
### Added
|
|
@@ -234,6 +246,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
234
246
|
- Options for `model`, `acceptKeys`, `maxChars`, `idleDelayMs`,
|
|
235
247
|
`recentMessages` and `system`.
|
|
236
248
|
|
|
249
|
+
[1.3.0]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.2.0...v1.3.0
|
|
250
|
+
[1.2.0]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.1.0...v1.2.0
|
|
237
251
|
[1.1.0]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.7...v1.1.0
|
|
238
252
|
[1.0.7]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.6...v1.0.7
|
|
239
253
|
[1.0.6]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.5...v1.0.6
|
package/README.md
CHANGED
|
@@ -158,6 +158,15 @@ be traced to a debounce, an empty or `NONE` reply, an echo filter, or a provider
|
|
|
158
158
|
error. `/suggest debug` toggles the same data as a toast on each attempt (aborts
|
|
159
159
|
are logged but not toasted). The history is not written to disk.
|
|
160
160
|
|
|
161
|
+
When a generation is `ok` but nothing is visible, `/suggest log` also shows the
|
|
162
|
+
live display state and a bounded history of display changes. Each `shown` or
|
|
163
|
+
`hidden` entry names the reason the placeholder is not applied: no
|
|
164
|
+
`prompt.footer` marker, an unidentified or ambiguous editor, extra sibling nodes in
|
|
165
|
+
the composer, a non-normal prompt or keymap mode, a draft, selection, extmarks,
|
|
166
|
+
a busy or hidden session, or the host overriding the placeholder. The live
|
|
167
|
+
section also reports focus, keymap mode and the placeholder colour. With
|
|
168
|
+
`/suggest debug` on, each change is toasted.
|
|
169
|
+
|
|
161
170
|
## Caveats
|
|
162
171
|
|
|
163
172
|
- **No inline typing completions.** V1's slash-argument and history ghosts
|
package/package.json
CHANGED
package/src/composer.ts
CHANGED
|
@@ -36,24 +36,45 @@ export function isEmptyComposer(editor: TextareaRenderable | undefined, focused:
|
|
|
36
36
|
return !!editor && editor === focused && editor.focused && isEligibleComposer(editor, mode, normal, selected)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function
|
|
40
|
-
if (!editor
|
|
39
|
+
export function composerBlocker(editor: TextareaRenderable | undefined, mode: string, normal: boolean, selected: boolean): string | undefined {
|
|
40
|
+
if (!editor) return "no composer editor"
|
|
41
|
+
if (!editor.parent || editor.parent.isDestroyed) return "editor detached"
|
|
41
42
|
const siblings = editor.parent.getChildren().filter((node) =>
|
|
42
43
|
!node.id.startsWith("slot-layout-"),
|
|
43
44
|
)
|
|
44
|
-
if (siblings.length !== 1 || siblings[0] !== editor) return
|
|
45
|
-
|
|
45
|
+
if (siblings.length !== 1 || siblings[0] !== editor) return `composer has ${siblings.length} sibling nodes (${siblings.map((node) => node.id || "?").join(", ")})`
|
|
46
|
+
if (!normal) return "prompt not in normal mode"
|
|
47
|
+
if (mode !== "base") return `keymap mode is ${mode}`
|
|
48
|
+
if (selected) return "renderer has a selection"
|
|
49
|
+
if (editor.isDestroyed) return "editor destroyed"
|
|
50
|
+
if (editor.plainText !== "") return "composer not empty"
|
|
51
|
+
if (editor.hasSelection()) return "editor has a selection"
|
|
52
|
+
if (editor.traits.capture?.includes("navigate")) return "editor captures navigation"
|
|
53
|
+
const marks = editor.extmarks.getAll().length
|
|
54
|
+
if (marks !== 0) return `editor has ${marks} extmark(s)`
|
|
46
55
|
}
|
|
47
56
|
|
|
48
|
-
export function
|
|
49
|
-
|
|
57
|
+
export function isEligibleComposer(editor: TextareaRenderable | undefined, mode: string, normal: boolean, selected: boolean): boolean {
|
|
58
|
+
return composerBlocker(editor, mode, normal, selected) === undefined
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type ComposerLookup<T> = { editor: T; reason?: undefined } | { editor?: undefined; reason: string }
|
|
62
|
+
|
|
63
|
+
export function locateComposerEditor<T extends EditorNode>(marker: EditorNode | undefined, isEditor: (node: EditorNode) => node is T, isComposer: (editor: T) => boolean): ComposerLookup<T> {
|
|
64
|
+
if (!marker) return { reason: "no prompt.footer marker registered" }
|
|
65
|
+
if (marker.isDestroyed) return { reason: "prompt.footer marker destroyed" }
|
|
50
66
|
const editors = (node: EditorNode): T[] => isEditor(node) ? [node] : node.getChildren().flatMap(editors)
|
|
51
67
|
for (let node = marker.parent; node && node.parent; node = node.parent) {
|
|
52
|
-
if (node.isDestroyed) return
|
|
68
|
+
if (node.isDestroyed) return { reason: "marker ancestor destroyed" }
|
|
53
69
|
const found = editors(node)
|
|
54
|
-
if (found.length > 1) return
|
|
55
|
-
if (found.length === 1) return isComposer(found[0]) ? found[0] :
|
|
70
|
+
if (found.length > 1) return { reason: `${found.length} editors share the marker ancestor` }
|
|
71
|
+
if (found.length === 1) return isComposer(found[0]) ? { editor: found[0] } : { reason: "editor lacks getClipboardText (not the host composer)" }
|
|
56
72
|
}
|
|
73
|
+
return { reason: "no editor found above the marker" }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function findComposerEditor<T extends EditorNode>(marker: EditorNode | undefined, isEditor: (node: EditorNode) => node is T, isComposer: (editor: T) => boolean): T | undefined {
|
|
77
|
+
return locateComposerEditor(marker, isEditor, isComposer).editor
|
|
57
78
|
}
|
|
58
79
|
|
|
59
80
|
export function composerAction(editor: Editor | undefined, focused: () => unknown, mode: string, normal: boolean, allowed: boolean, text: string | undefined): boolean {
|
package/src/diagnostics.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type DiagnosticOutcome = "ok" | "empty" | "echo" | "unavailable" | "error" | "aborted"
|
|
1
|
+
export type DiagnosticOutcome = "ok" | "empty" | "echo" | "unavailable" | "error" | "aborted" | "shown" | "hidden"
|
|
2
2
|
|
|
3
3
|
export type DiagnosticEntry = {
|
|
4
4
|
readonly at: number
|
|
@@ -54,6 +54,8 @@ const OUTCOME_LABELS: Record<DiagnosticOutcome, string> = {
|
|
|
54
54
|
unavailable: "no model",
|
|
55
55
|
error: "error",
|
|
56
56
|
aborted: "aborted",
|
|
57
|
+
shown: "shown",
|
|
58
|
+
hidden: "hidden",
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
function clockTime(at: number): string {
|
package/src/options.ts
CHANGED
|
@@ -27,9 +27,11 @@ export const DEFAULT_SYSTEM = [
|
|
|
27
27
|
"",
|
|
28
28
|
"Rules:",
|
|
29
29
|
"- Move the conversation forward. Never repeat, quote, or paraphrase the user's own previous message.",
|
|
30
|
-
"-
|
|
31
|
-
'- If the assistant proposed a next step, a brief affirmation such as "Yes." or "Go ahead." is best.',
|
|
32
|
-
"- If the assistant
|
|
30
|
+
"- Copy the tone, language and length of the user's earlier messages in the transcript: short, direct, one line, plain text only.",
|
|
31
|
+
'- If the assistant proposed a single next step or asked for approval, a brief affirmation such as "Yes." or "Go ahead." is best.',
|
|
32
|
+
"- If the assistant offered options or recommended one, pick the recommended option, or the first one if none is recommended.",
|
|
33
|
+
"- If the assistant asked a question the transcript answers, answer it briefly.",
|
|
34
|
+
"- If the work is finished and verified, ask for the natural follow-up (commit, open the PR, or run the remaining checks) only when the user has asked for that earlier in the transcript.",
|
|
33
35
|
"- No markdown, no quotes, no backticks, no preamble.",
|
|
34
36
|
"",
|
|
35
37
|
"Examples:",
|
|
@@ -39,8 +41,12 @@ export const DEFAULT_SYSTEM = [
|
|
|
39
41
|
"Next user message: yes, go ahead",
|
|
40
42
|
"Assistant: Which model should the small tasks use?",
|
|
41
43
|
"Next user message: the fast free one",
|
|
44
|
+
"Assistant: I see two approaches. A (recommended) patches the parser; B rewrites the loader.",
|
|
45
|
+
"Next user message: go with A",
|
|
46
|
+
"Assistant: The fix is in and verified. Anything else?",
|
|
47
|
+
"Next user message: NONE",
|
|
42
48
|
"",
|
|
43
|
-
"
|
|
49
|
+
"Output exactly NONE when no reply is clearly right: the assistant only reported status with nothing pending, or the answer needs information only the user has.",
|
|
44
50
|
].join("\n")
|
|
45
51
|
|
|
46
52
|
const DEFAULTS = {
|
package/src/tui.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Plugin } from "@opencode/plugin/tui"
|
|
3
3
|
import { TextareaRenderable, InputRenderable, type BoxRenderable, type Renderable } from "@opentui/core"
|
|
4
4
|
import { createEffect, createMemo, createRoot, createSignal, on, onCleanup } from "solid-js"
|
|
5
|
-
import { composerAction,
|
|
5
|
+
import { composerAction, composerBlocker, isEmptyComposer, keyName, locateComposerEditor, observeComposerInput, type ComposerLookup } from "./composer"
|
|
6
6
|
import { createDiagnostics, errorDetail, formatDiagnostic, formatDiagnostics, modelLabel, type DiagnosticEntry } from "./diagnostics"
|
|
7
7
|
import { createLifecycle } from "./lifecycle"
|
|
8
8
|
import { acceptCommand, acceptShortcuts, ghostKeymapLayers } from "./keymap"
|
|
@@ -14,8 +14,8 @@ import { buildTranscript, lastUserText, suggestionPrompt, type TranscriptMessage
|
|
|
14
14
|
|
|
15
15
|
type Suggestion = { sessionID: string; text: string }
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function lookupComposer(marker: Renderable | undefined): ComposerLookup<TextareaRenderable> {
|
|
18
|
+
return locateComposerEditor(marker,
|
|
19
19
|
(node): node is TextareaRenderable => node instanceof TextareaRenderable && !(node instanceof InputRenderable),
|
|
20
20
|
(editor) => typeof (editor as unknown as { getClipboardText?: unknown }).getClipboardText === "function",
|
|
21
21
|
)
|
|
@@ -160,7 +160,38 @@ export default Plugin.define({
|
|
|
160
160
|
|
|
161
161
|
const getComposer = (sessionID: string) => {
|
|
162
162
|
const entry = composers.get(sessionID)
|
|
163
|
-
return { editor:
|
|
163
|
+
return { editor: lookupComposer(entry?.marker).editor, normal: entry?.normal() === true }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const displayLog = createDiagnostics()
|
|
167
|
+
let lastDisplay: string | undefined
|
|
168
|
+
|
|
169
|
+
const displayStatus = (current: Suggestion): string => {
|
|
170
|
+
if (!canGenerate(current.sessionID)) return "session busy, hidden or suggestions disabled"
|
|
171
|
+
const entry = composers.get(current.sessionID)
|
|
172
|
+
const found = lookupComposer(entry?.marker)
|
|
173
|
+
if (!found.editor) return found.reason
|
|
174
|
+
const blocker = composerBlocker(found.editor, context.keymap.mode.current(), entry?.normal() === true, context.renderer.hasSelection)
|
|
175
|
+
if (blocker) return blocker
|
|
176
|
+
return inline.visible(found.editor, current.text) ? "shown" : "placeholder not applied (host overrode it)"
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const trackDisplay = () => {
|
|
180
|
+
const current = suggestion()
|
|
181
|
+
if (!current) {
|
|
182
|
+
lastDisplay = undefined
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
const status = displayStatus(current)
|
|
186
|
+
if (status === lastDisplay) return
|
|
187
|
+
lastDisplay = status
|
|
188
|
+
const recorded = displayLog.record({
|
|
189
|
+
sessionID: current.sessionID,
|
|
190
|
+
outcome: status === "shown" ? "shown" : "hidden",
|
|
191
|
+
chars: current.text.length,
|
|
192
|
+
...(status === "shown" ? {} : { detail: status }),
|
|
193
|
+
})
|
|
194
|
+
if (state.debug === true) context.ui.toast.show({ title: "Ghost", message: formatDiagnostic(recorded) })
|
|
164
195
|
}
|
|
165
196
|
|
|
166
197
|
const isComposerEmpty = (sessionID: string) => {
|
|
@@ -172,7 +203,8 @@ export default Plugin.define({
|
|
|
172
203
|
composerRevision()
|
|
173
204
|
const current = suggestion()
|
|
174
205
|
const { editor, normal } = current ? getComposer(current.sessionID) : { editor: undefined, normal: false }
|
|
175
|
-
inline.sync(editor, current?.text, ghostColor(), !!current && canGenerate(current.sessionID) &&
|
|
206
|
+
inline.sync(editor, current?.text, ghostColor(), !!current && canGenerate(current.sessionID) && !composerBlocker(editor, context.keymap.mode.current(), normal, context.renderer.hasSelection))
|
|
207
|
+
trackDisplay()
|
|
176
208
|
}
|
|
177
209
|
|
|
178
210
|
const disposeRouteWatcher = createRoot((dispose) => {
|
|
@@ -231,9 +263,22 @@ export default Plugin.define({
|
|
|
231
263
|
if (command.type === "log") {
|
|
232
264
|
const override = state.model ?? opts.model
|
|
233
265
|
const summary = `suggestions ${state.enabled ? "on" : "off"}, debug ${state.debug === true ? "on" : "off"}, model ${override ?? "OpenCode small default"}`
|
|
266
|
+
const current = suggestion()
|
|
267
|
+
const color = ghostColor()
|
|
268
|
+
const route = context.ui.router.current()
|
|
269
|
+
const entry = route.type === "session" ? composers.get(route.sessionID) : undefined
|
|
270
|
+
const editor = lookupComposer(entry?.marker).editor
|
|
271
|
+
const live = [
|
|
272
|
+
`route ${route.type}`,
|
|
273
|
+
`suggestion ${current ? `retained (${current.text.length} chars)` : "none"}`,
|
|
274
|
+
`display ${current ? displayStatus(current) : "n/a"}`,
|
|
275
|
+
`focused ${editor ? (editor === context.renderer.currentFocusedEditor && editor.focused ? "yes" : "no") : "n/a"}`,
|
|
276
|
+
`mode ${context.keymap.mode.current()}`,
|
|
277
|
+
`color rgba(${[color.r, color.g, color.b, color.a].map((value) => value.toFixed(2)).join(", ")})`,
|
|
278
|
+
].join("\n")
|
|
234
279
|
void context.ui.dialog.alert({
|
|
235
|
-
title: "Ghost —
|
|
236
|
-
message: `${summary}\n\n${formatDiagnostics(diagnostics.list())}`,
|
|
280
|
+
title: "Ghost — diagnostics",
|
|
281
|
+
message: `${summary}\n\nNow\n${live}\n\nDisplay changes\n${displayLog.list().length ? formatDiagnostics(displayLog.list()) : "None recorded yet."}\n\nGenerations\n${formatDiagnostics(diagnostics.list())}`,
|
|
237
282
|
})
|
|
238
283
|
return
|
|
239
284
|
}
|