opencode-ghost 1.3.5 → 1.3.6
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 +7 -0
- package/README.md +10 -3
- package/package.json +1 -1
- package/src/diagnostics.ts +6 -1
- package/src/transcript.ts +2 -2
- package/src/tui.tsx +26 -17
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ 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.6] - 2026-10-10
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **tui:** Report generation stage timings and request bounded responses
|
|
13
|
+
|
|
8
14
|
## [1.3.5] - 2026-10-10
|
|
9
15
|
|
|
10
16
|
### Fixed
|
|
@@ -277,6 +283,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
277
283
|
- Options for `model`, `acceptKeys`, `maxChars`, `idleDelayMs`,
|
|
278
284
|
`recentMessages` and `system`.
|
|
279
285
|
|
|
286
|
+
[1.3.6]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.5...v1.3.6
|
|
280
287
|
[1.3.5]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.4...v1.3.5
|
|
281
288
|
[1.3.4]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.3...v1.3.4
|
|
282
289
|
[1.3.3]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.2...v1.3.3
|
package/README.md
CHANGED
|
@@ -88,11 +88,16 @@ copy, use `/absolute/path/to/config/plugins/opencode-ghost`.
|
|
|
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
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
|
-
| `maxChars` | `number` | `120` |
|
|
91
|
+
| `maxChars` | `number` | `120` | Requested response character budget and maximum displayed 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. |
|
|
94
94
|
| `system` | `string` | built-in | Override the system prompt sent to the suggestion model. |
|
|
95
95
|
|
|
96
|
+
`maxChars` is included as a soft character budget in every generation prompt,
|
|
97
|
+
including custom `system` prompts. OpenCode's experimental `generate.text` API
|
|
98
|
+
has no output-token limit; the model can exceed the requested budget. Ghost
|
|
99
|
+
still enforces `maxChars` when normalizing the displayed suggestion.
|
|
100
|
+
|
|
96
101
|
## Commands
|
|
97
102
|
|
|
98
103
|
- `/suggest` — toggle suggestions on/off (persisted).
|
|
@@ -104,7 +109,7 @@ copy, use `/absolute/path/to/config/plugins/opencode-ghost`.
|
|
|
104
109
|
the error.
|
|
105
110
|
- `/suggest debug on` / `/suggest debug off` — set debug mode explicitly.
|
|
106
111
|
- `/suggest log` — show the last 20 generation attempts (outcome, model,
|
|
107
|
-
latency, length and error detail) in a dialog, regardless of debug mode.
|
|
112
|
+
total and stage latency, length and error detail) in a dialog, regardless of debug mode.
|
|
108
113
|
|
|
109
114
|
Model precedence is the persisted `/suggest model` override, then the `model`
|
|
110
115
|
option, then the effective title agent's model from OpenCode's public agent API.
|
|
@@ -153,7 +158,9 @@ When enabling, a suggestion is generated immediately for the current session.
|
|
|
153
158
|
|
|
154
159
|
Ghost records every generation attempt to a bounded in-memory history (the last
|
|
155
160
|
20): outcome (`ok`, `empty`, `echo`, `no model`, `error`, `aborted`), the resolved
|
|
156
|
-
model with its variant, latency,
|
|
161
|
+
model with its variant, total latency, message-sync/model-resolution/generation
|
|
162
|
+
stage timings, suggestion length and error detail. Latency excludes the debounce;
|
|
163
|
+
only reached stages are recorded, including failures and cancellations. `/suggest log`
|
|
157
164
|
shows it in a dialog at any time; `aborted` covers attempts cancelled by typing,
|
|
158
165
|
a newer turn, leaving the session, disabling or unload, so a missing suggestion can
|
|
159
166
|
be traced to a debounce, an empty or `NONE` reply, an echo filter, or a provider
|
package/package.json
CHANGED
package/src/diagnostics.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export type DiagnosticOutcome = "ok" | "empty" | "echo" | "unavailable" | "error" | "aborted" | "shown" | "hidden"
|
|
2
2
|
|
|
3
|
+
export type StageTimings = { syncMs?: number; modelMs?: number; generationMs?: number }
|
|
4
|
+
|
|
3
5
|
export type DiagnosticEntry = {
|
|
4
6
|
readonly at: number
|
|
5
7
|
readonly sessionID: string
|
|
6
8
|
readonly outcome: DiagnosticOutcome
|
|
7
9
|
readonly model?: string
|
|
8
10
|
readonly durationMs?: number
|
|
11
|
+
readonly stages?: Readonly<StageTimings>
|
|
9
12
|
readonly chars?: number
|
|
10
13
|
readonly detail?: string
|
|
11
14
|
}
|
|
@@ -68,7 +71,9 @@ export function formatDiagnostic(entry: DiagnosticEntry): string {
|
|
|
68
71
|
const parts = [clockTime(entry.at), OUTCOME_LABELS[entry.outcome], entry.model ?? "—"]
|
|
69
72
|
if (entry.durationMs !== undefined) parts.push(`${entry.durationMs}ms`)
|
|
70
73
|
if (entry.chars !== undefined) parts.push(`${entry.chars} chars`)
|
|
71
|
-
const
|
|
74
|
+
const stages = [["sync", entry.stages?.syncMs], ["model", entry.stages?.modelMs], ["generation", entry.stages?.generationMs]] as const
|
|
75
|
+
const timing = stages.filter(([, ms]) => ms !== undefined).map(([name, ms]) => `${name} ${ms}ms`).join(", ")
|
|
76
|
+
const line = parts.join(" ") + (timing ? `\n ${timing}` : "")
|
|
72
77
|
return entry.detail ? `${line}\n ${entry.detail}` : line
|
|
73
78
|
}
|
|
74
79
|
|
package/src/transcript.ts
CHANGED
|
@@ -39,6 +39,6 @@ export function lastUserText(messages: readonly TranscriptMessage[]): string {
|
|
|
39
39
|
return ""
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export function suggestionPrompt(system: string, transcript: string): string {
|
|
43
|
-
return `${system}\n\n${transcript}
|
|
42
|
+
export function suggestionPrompt(system: string, transcript: string, maxChars: number): string {
|
|
43
|
+
return `${system}\n\n${transcript}\n\nReturn one line of at most ${maxChars} characters. If no suggestion is appropriate, return NONE. Do not include explanations.`
|
|
44
44
|
}
|
package/src/tui.tsx
CHANGED
|
@@ -3,7 +3,7 @@ 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
5
|
import { composerAction, composerBlocker, isEmptyComposer, keyName, locateComposerEditor, observeComposerInput, removesOnly, type ComposerLookup } from "./composer"
|
|
6
|
-
import { createDiagnostics, errorDetail, formatDiagnostic, formatDiagnostics, modelLabel, type DiagnosticEntry } from "./diagnostics"
|
|
6
|
+
import { createDiagnostics, errorDetail, formatDiagnostic, formatDiagnostics, modelLabel, type DiagnosticEntry, type StageTimings } from "./diagnostics"
|
|
7
7
|
import { createLifecycle } from "./lifecycle"
|
|
8
8
|
import { acceptCommand, acceptShortcuts, ghostBaseLayer, ghostSuggestLayer } from "./keymap"
|
|
9
9
|
import { parseSuggestCommand, removedOptionKeys, resolveOptions, suggestionModel } from "./options"
|
|
@@ -80,11 +80,22 @@ export default Plugin.define({
|
|
|
80
80
|
if (!canGenerate(sessionID)) return
|
|
81
81
|
const started = Date.now()
|
|
82
82
|
const elapsed = () => Date.now() - started
|
|
83
|
+
const stages: StageTimings = {}
|
|
84
|
+
const measure = async <T,>(stage: keyof StageTimings, run: () => Promise<T>): Promise<T> => {
|
|
85
|
+
const start = Date.now()
|
|
86
|
+
try {
|
|
87
|
+
return await run()
|
|
88
|
+
} finally {
|
|
89
|
+
stages[stage] = Date.now() - start
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const noteGeneration = (entry: Omit<DiagnosticEntry, "at" | "sessionID" | "durationMs" | "stages">) =>
|
|
93
|
+
note({ ...entry, sessionID, durationMs: elapsed(), stages: { ...stages } })
|
|
83
94
|
let model: SuggestionModel | undefined
|
|
84
95
|
let failure: unknown
|
|
85
96
|
let syncing = true
|
|
86
97
|
try {
|
|
87
|
-
await context.data.session.message.sync(sessionID)
|
|
98
|
+
await measure("syncMs", () => context.data.session.message.sync(sessionID))
|
|
88
99
|
syncing = false
|
|
89
100
|
if (signal.aborted || !canGenerate(sessionID)) return
|
|
90
101
|
const messages = context.data.session.message.list(sessionID) as readonly TranscriptMessage[]
|
|
@@ -93,43 +104,43 @@ export default Plugin.define({
|
|
|
93
104
|
const session = context.data.session.get(sessionID)
|
|
94
105
|
const location = session?.location ?? context.location ?? context.data.location.default()
|
|
95
106
|
const explicit = suggestionModel(state.model, opts.model)
|
|
96
|
-
model = explicit
|
|
97
|
-
?
|
|
98
|
-
:
|
|
107
|
+
model = await measure("modelMs", () => explicit
|
|
108
|
+
? resolveExplicitModel(context.client, location, signal, explicit, catalog)
|
|
109
|
+
: resolveSmallModel(context.client, location, signal, session, catalog))
|
|
99
110
|
if (signal.aborted || !canGenerate(sessionID)) return
|
|
100
111
|
if (!model) return
|
|
101
|
-
const raw = await generateSuggestion(
|
|
112
|
+
const raw = await measure("generationMs", () => generateSuggestion(
|
|
102
113
|
context.client,
|
|
103
|
-
suggestionPrompt(opts.system, transcript),
|
|
114
|
+
suggestionPrompt(opts.system, transcript, opts.maxChars),
|
|
104
115
|
model,
|
|
105
116
|
signal,
|
|
106
117
|
(error) => { failure = error; warnGeneration(error) },
|
|
107
118
|
() => canGenerate(sessionID),
|
|
108
|
-
)
|
|
119
|
+
))
|
|
109
120
|
const label = modelLabel(model)
|
|
110
121
|
if (signal.aborted) return
|
|
111
122
|
if (failure) {
|
|
112
|
-
|
|
123
|
+
noteGeneration({ outcome: "error", model: label, detail: errorDetail(failure) })
|
|
113
124
|
return
|
|
114
125
|
}
|
|
115
126
|
if (!raw) {
|
|
116
127
|
if (!canGenerate(sessionID)) return
|
|
117
|
-
|
|
128
|
+
noteGeneration({ outcome: "empty", model: label })
|
|
118
129
|
return
|
|
119
130
|
}
|
|
120
131
|
const clean = normalize(raw, opts.maxChars)
|
|
121
132
|
if (!clean) {
|
|
122
|
-
|
|
133
|
+
noteGeneration({ outcome: "empty", model: label, chars: raw.length })
|
|
123
134
|
return
|
|
124
135
|
}
|
|
125
136
|
const previous = lastUserText(messages)
|
|
126
137
|
if (previous && isEcho(clean, previous)) {
|
|
127
|
-
|
|
138
|
+
noteGeneration({ outcome: "echo", model: label, chars: clean.length })
|
|
128
139
|
return
|
|
129
140
|
}
|
|
130
141
|
if (!canGenerate(sessionID)) return
|
|
131
142
|
setSuggestion({ sessionID, text: clean })
|
|
132
|
-
|
|
143
|
+
noteGeneration({ outcome: "ok", model: label, chars: clean.length })
|
|
133
144
|
} catch (error) {
|
|
134
145
|
if (signal.aborted) return
|
|
135
146
|
if (syncing) {
|
|
@@ -138,15 +149,13 @@ export default Plugin.define({
|
|
|
138
149
|
context.ui.toast.show({ title: "Ghost", message: "Suggestions unavailable: session messages could not sync.", variant: "warning" })
|
|
139
150
|
}
|
|
140
151
|
} else warnGeneration(error)
|
|
141
|
-
|
|
142
|
-
sessionID,
|
|
152
|
+
noteGeneration({
|
|
143
153
|
outcome: isNoSmallModel(error) ? "unavailable" : "error",
|
|
144
154
|
...(model ? { model: modelLabel(model) } : {}),
|
|
145
|
-
durationMs: elapsed(),
|
|
146
155
|
detail: errorDetail(error),
|
|
147
156
|
})
|
|
148
157
|
} finally {
|
|
149
|
-
if (signal.aborted)
|
|
158
|
+
if (signal.aborted) noteGeneration({ outcome: "aborted", ...(model ? { model: modelLabel(model) } : {}) })
|
|
150
159
|
}
|
|
151
160
|
}
|
|
152
161
|
|