opencode-ghost 1.3.7 → 1.3.9
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 +64 -22
- package/package.json +3 -3
- package/src/stateless.ts +31 -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.9] - 2026-10-11
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **deps:** Cap opentui peer range below 0.6
|
|
13
|
+
|
|
14
|
+
## [1.3.8] - 2026-10-11
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **tui:** Retry model-unavailable replies while the server catalog loads
|
|
19
|
+
|
|
8
20
|
## [1.3.7] - 2026-10-10
|
|
9
21
|
|
|
10
22
|
### Fixed
|
|
@@ -289,6 +301,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
289
301
|
- Options for `model`, `acceptKeys`, `maxChars`, `idleDelayMs`,
|
|
290
302
|
`recentMessages` and `system`.
|
|
291
303
|
|
|
304
|
+
[1.3.9]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.8...v1.3.9
|
|
305
|
+
[1.3.8]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.7...v1.3.8
|
|
292
306
|
[1.3.7]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.6...v1.3.7
|
|
293
307
|
[1.3.6]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.5...v1.3.6
|
|
294
308
|
[1.3.5]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.3.4...v1.3.5
|
package/README.md
CHANGED
|
@@ -29,11 +29,28 @@ a dimmed inline placeholder in the empty composer with
|
|
|
29
29
|
## Requirements
|
|
30
30
|
|
|
31
31
|
- [opencode](https://opencode.ai) v2 (TUI plugins; tested against 2.0.25).
|
|
32
|
-
- A provider/model
|
|
32
|
+
- A provider/model and authentication method that support OpenCode's stateless
|
|
33
|
+
`generate.text` endpoint. Set `model` explicitly if no default small model is available.
|
|
33
34
|
|
|
34
35
|
## Install
|
|
35
36
|
|
|
36
|
-
### From
|
|
37
|
+
### From npm (recommended)
|
|
38
|
+
|
|
39
|
+
Add the package to your `cli.json` (normally `~/.config/opencode/cli.json`):
|
|
40
|
+
|
|
41
|
+
```jsonc
|
|
42
|
+
{
|
|
43
|
+
"$schema": "https://opencode.ai/v2/cli.json",
|
|
44
|
+
"plugins": ["opencode-ghost"]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Then **restart opencode**; it installs the package on startup. Pin a version
|
|
49
|
+
with `"opencode-ghost@1.3.7"`, or change the version and restart to update.
|
|
50
|
+
Pass options with the object form shown under [Manually](#manually), using
|
|
51
|
+
`"package": "opencode-ghost"`.
|
|
52
|
+
|
|
53
|
+
### From this repo
|
|
37
54
|
|
|
38
55
|
```sh
|
|
39
56
|
git clone https://github.com/ozandogrultan/opencode-ghost.git
|
|
@@ -41,15 +58,24 @@ cd opencode-ghost
|
|
|
41
58
|
./install.sh
|
|
42
59
|
```
|
|
43
60
|
|
|
44
|
-
Then **restart opencode**
|
|
61
|
+
Then **restart opencode** to load the installed copy. `install.sh`
|
|
45
62
|
copies the plugin into `<config>/plugins/opencode-ghost/` and registers it in
|
|
46
|
-
`<config>/cli.json`, migrating an existing v1 `tui.json` registration (and its
|
|
63
|
+
`<config>/cli.json`, migrating an existing v1 `tui.json` or `tui.jsonc` registration (and its
|
|
47
64
|
options) if one is found.
|
|
48
65
|
Removed options (`apiKey`, `endpoint`, `internalSessionMarkerDir`, `argHints`)
|
|
49
66
|
are stripped from Ghost registrations. Other configuration is preserved.
|
|
50
67
|
The installer accepts JSON objects only; JSONC or invalid configuration is
|
|
51
68
|
left intact along with the installed sources and requires manual registration
|
|
52
|
-
using the snippet below.
|
|
69
|
+
using the snippet below. An unrelated, unparseable legacy TUI config is skipped.
|
|
70
|
+
Node is required for the installer; automatic config discovery also requires
|
|
71
|
+
`opencode` on `PATH`.
|
|
72
|
+
|
|
73
|
+
The default target comes from `opencode debug paths`, falling back to
|
|
74
|
+
`$XDG_CONFIG_HOME/opencode` or `~/.config/opencode`. Pass one or more config
|
|
75
|
+
directories explicitly with `./install.sh /path/to/config`; `./install.sh --all`
|
|
76
|
+
also targets an existing `~/.config/opencode` directory. After pulling updates,
|
|
77
|
+
rerun the installer and restart opencode. A manual registration pointing at the
|
|
78
|
+
repo's `src` only needs a restart.
|
|
53
79
|
|
|
54
80
|
### Manually
|
|
55
81
|
|
|
@@ -59,6 +85,7 @@ directory containing this file; a project's `.opencode/cli.json` is not loaded.
|
|
|
59
85
|
|
|
60
86
|
```jsonc
|
|
61
87
|
{
|
|
88
|
+
"$schema": "https://opencode.ai/v2/cli.json",
|
|
62
89
|
"plugins": ["/absolute/path/to/opencode-ghost/src"]
|
|
63
90
|
}
|
|
64
91
|
```
|
|
@@ -67,10 +94,11 @@ Pass options with the object form:
|
|
|
67
94
|
|
|
68
95
|
```jsonc
|
|
69
96
|
{
|
|
97
|
+
"$schema": "https://opencode.ai/v2/cli.json",
|
|
70
98
|
"plugins": [
|
|
71
99
|
{
|
|
72
100
|
"package": "/absolute/path/to/opencode-ghost/src",
|
|
73
|
-
|
|
101
|
+
"options": { "model": "openai/gpt-6-luna-fast" }
|
|
74
102
|
}
|
|
75
103
|
]
|
|
76
104
|
}
|
|
@@ -127,12 +155,15 @@ Like OpenCode's title generation, an override, title or small model without a
|
|
|
127
155
|
configured variant uses its first supported `none`, `minimal` or `low` variant.
|
|
128
156
|
Catalog IDs are used directly. The model catalog is cached for five minutes
|
|
129
157
|
(cleared by `/suggest model` and re-enabling, and refetched once before reporting
|
|
130
|
-
no small model); the agent list is read on
|
|
158
|
+
no small model when a cached catalog has no match); the agent list is read on
|
|
159
|
+
each default-model resolution. No matching small
|
|
131
160
|
model means a warning and no suggestion. Ghost never uses the main model as a generation fallback or retries
|
|
132
161
|
with another provider. An explicit override or configured title model may use
|
|
133
162
|
a different provider from the session's primary model.
|
|
134
163
|
|
|
135
|
-
When enabling
|
|
164
|
+
When re-enabling with `/suggest`, generation starts without the debounce for the
|
|
165
|
+
current idle session if it has conversation text. Loading the plugin or switching
|
|
166
|
+
sessions does not itself generate a suggestion.
|
|
136
167
|
|
|
137
168
|
## How it works
|
|
138
169
|
|
|
@@ -156,15 +187,17 @@ When enabling, a suggestion is generated immediately for the current session.
|
|
|
156
187
|
|
|
157
188
|
## Debugging
|
|
158
189
|
|
|
159
|
-
Ghost records
|
|
190
|
+
Ghost records generation outcomes in a bounded in-memory history (the last
|
|
160
191
|
20): outcome (`ok`, `empty`, `echo`, `no model`, `error`, `aborted`), the resolved
|
|
161
192
|
model with its variant, total latency, message-sync/model-resolution/generation
|
|
162
193
|
stage timings, suggestion length and error detail. Latency excludes the debounce;
|
|
163
194
|
only reached stages are recorded, including failures and cancellations. `/suggest log`
|
|
164
195
|
shows it in a dialog at any time; `aborted` covers attempts cancelled by typing,
|
|
165
196
|
a newer turn, leaving the session, disabling or unload, so a missing suggestion can
|
|
166
|
-
be traced to
|
|
167
|
-
error.
|
|
197
|
+
be traced to an empty or `NONE` reply, an echo filter, or a provider
|
|
198
|
+
error. Cancelled debounces and runs skipped for lack of conversation text or an
|
|
199
|
+
ineligible session have no generation entry. `/suggest debug`
|
|
200
|
+
toggles the same data as a toast on each recorded outcome (aborts
|
|
168
201
|
are logged but not toasted). The history is not written to disk.
|
|
169
202
|
|
|
170
203
|
When a generation is `ok` but nothing is visible, `/suggest log` also shows the
|
|
@@ -193,24 +226,33 @@ section also reports focus, keymap mode and the placeholder colour. With
|
|
|
193
226
|
OpenTUI's public pre-render callback; host renderer changes need re-verification.
|
|
194
227
|
- **Key fallthrough.** Without an eligible ghost, Tab/Right fall through to
|
|
195
228
|
the host. OpenCode V2's default agent-cycle shortcut is Shift+Tab.
|
|
196
|
-
- **Cost.**
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
-
|
|
204
|
-
|
|
229
|
+
- **Cost.** At most one generation call per debounced completion in the visible,
|
|
230
|
+
idle session. Re-enabling can make an additional call. Point `model` at a cheap
|
|
231
|
+
or free model.
|
|
232
|
+
- **Provider compatibility.** Stateless generation support depends on the
|
|
233
|
+
provider, model and authentication method; normal session generation support
|
|
234
|
+
does not guarantee compatibility. Use `/suggest log` to inspect failures and
|
|
235
|
+
`/suggest model provider/model` to choose a supported model.
|
|
236
|
+
- Generation errors show a warning toast with the model override command,
|
|
237
|
+
once per plugin load or since the last `/suggest model` change. Message-sync
|
|
238
|
+
failures have a separate once-per-load warning. Aborts and `NONE` replies
|
|
239
|
+
produce no warning or preview.
|
|
240
|
+
- Model resolution uses the session's location and a location-scoped catalog
|
|
241
|
+
cache. Default-model resolution also reads effective agents. The stateless
|
|
242
|
+
endpoint has no location argument; project-only models
|
|
205
243
|
may fail server-global resolution. Invalid overrides and provider failures warn
|
|
206
|
-
without retrying through another provider or a session.
|
|
244
|
+
without retrying through another provider or a session. A "Model unavailable"
|
|
245
|
+
reply is retried on the same model with backoff (1s to 8s), since the server
|
|
246
|
+
catalog can still be loading right after startup.
|
|
207
247
|
|
|
208
248
|
## Development
|
|
209
249
|
|
|
210
250
|
```sh
|
|
211
251
|
bun install
|
|
212
|
-
bun run typecheck
|
|
213
252
|
bun run test
|
|
253
|
+
bun run typecheck
|
|
254
|
+
bun run lint:sh
|
|
255
|
+
bash scripts/changelog.sh check
|
|
214
256
|
```
|
|
215
257
|
|
|
216
258
|
No build step: like other opencode TUI plugins, the package ships TSX source and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-ghost",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "Stateless inline next-prompt ghosts for the empty OpenCode V2 composer, accepted with Tab or Right.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@opencode/plugin": "*",
|
|
52
|
-
"@opentui/core": ">=0.5.16",
|
|
53
|
-
"@opentui/solid": ">=0.5.16",
|
|
52
|
+
"@opentui/core": ">=0.5.16 <0.6.0",
|
|
53
|
+
"@opentui/solid": ">=0.5.16 <0.6.0",
|
|
54
54
|
"solid-js": "*"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
package/src/stateless.ts
CHANGED
|
@@ -9,6 +9,26 @@ export type GenerateClient = {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export const MODEL_UNAVAILABLE_RETRY_MS: readonly number[] = [1000, 2000, 4000, 8000]
|
|
13
|
+
|
|
14
|
+
function isModelUnavailable(error: unknown): boolean {
|
|
15
|
+
const message = (error as { message?: unknown } | null)?.message
|
|
16
|
+
return typeof message === "string" && /^Model unavailable:/.test(message)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function pause(ms: number, signal: AbortSignal): Promise<void> {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
if (signal.aborted) return resolve()
|
|
22
|
+
const done = () => {
|
|
23
|
+
clearTimeout(timer)
|
|
24
|
+
signal.removeEventListener("abort", done)
|
|
25
|
+
resolve()
|
|
26
|
+
}
|
|
27
|
+
const timer = setTimeout(done, ms)
|
|
28
|
+
signal.addEventListener("abort", done)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
12
32
|
export async function generateSuggestion(
|
|
13
33
|
client: GenerateClient,
|
|
14
34
|
prompt: string,
|
|
@@ -16,15 +36,21 @@ export async function generateSuggestion(
|
|
|
16
36
|
signal: AbortSignal,
|
|
17
37
|
onError?: (error: unknown) => void,
|
|
18
38
|
allowed: () => boolean = () => true,
|
|
39
|
+
retryDelays: readonly number[] = MODEL_UNAVAILABLE_RETRY_MS,
|
|
19
40
|
): Promise<string | undefined> {
|
|
20
41
|
try {
|
|
21
42
|
const resolved = await model
|
|
22
43
|
if (signal.aborted || !allowed() || !resolved) return undefined
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
const input = { prompt, model: { id: resolved.modelID, providerID: resolved.providerID, ...(resolved.variant ? { variant: resolved.variant } : {}) } }
|
|
45
|
+
for (let attempt = 0; ; attempt++) {
|
|
46
|
+
try {
|
|
47
|
+
return (await client.generate.text(input, { signal })).text
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (!isModelUnavailable(error) || attempt >= retryDelays.length) throw error
|
|
50
|
+
await pause(retryDelays[attempt]!, signal)
|
|
51
|
+
if (signal.aborted || !allowed()) return undefined
|
|
52
|
+
}
|
|
53
|
+
}
|
|
28
54
|
} catch (error) {
|
|
29
55
|
if (!signal.aborted) onError?.(error)
|
|
30
56
|
return undefined
|