opencode-copilot-delegate 0.11.0 → 0.12.1
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 +58 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2279 -1919
- package/dist/lib/rpc-cleanup.d.ts +27 -0
- package/dist/runtime/continuity-checks.d.ts +7 -0
- package/dist/runtime/continuity-validation.d.ts +11 -0
- package/dist/runtime/envelope.d.ts +18 -0
- package/dist/runtime/notify.d.ts +27 -0
- package/dist/runtime/plugin-singleton.d.ts +20 -0
- package/dist/runtime/rpc-contract.d.ts +2 -2
- package/dist/runtime/subprocess.d.ts +8 -0
- package/dist/runtime/task-registry.d.ts +28 -0
- package/dist/tools/resume.d.ts +62 -0
- package/dist/tui/index.js +39 -12
- package/package.json +11 -10
- package/src/tui/__tests__/index.test.ts +134 -11
- package/src/tui/index.tsx +95 -10
package/src/tui/index.tsx
CHANGED
|
@@ -12,6 +12,98 @@ function errorMessage(error: unknown): string {
|
|
|
12
12
|
return 'Unknown RPC error.'
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Narrow structural interface for `api.keymap.registerLayer`. Mirrors the
|
|
17
|
+
* shape exposed by `@opencode-ai/plugin/tui`'s `TuiKeymap` (which aliases
|
|
18
|
+
* `Keymap<Renderable, KeyEvent>` from `@opentui/keymap`). That upstream
|
|
19
|
+
* type is not exported through `@opencode-ai/plugin`'s public surface and
|
|
20
|
+
* `@opentui/keymap` is not a direct dependency here, so we declare the
|
|
21
|
+
* minimum contract needed for the dual-path registration to type-check
|
|
22
|
+
* without reaching into private OpenTUI types.
|
|
23
|
+
*/
|
|
24
|
+
interface KeymapRegisterLayerHost {
|
|
25
|
+
registerLayer: (layer: {
|
|
26
|
+
commands: ReadonlyArray<{
|
|
27
|
+
namespace: string
|
|
28
|
+
name: string
|
|
29
|
+
title: string
|
|
30
|
+
category: string
|
|
31
|
+
run: () => void
|
|
32
|
+
}>
|
|
33
|
+
bindings: ReadonlyArray<unknown>
|
|
34
|
+
}) => () => void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function hasKeymapRegisterLayer(
|
|
38
|
+
api: Parameters<TuiPlugin>[0],
|
|
39
|
+
): api is Parameters<TuiPlugin>[0] & { keymap: KeymapRegisterLayerHost } {
|
|
40
|
+
const candidate = (api as { keymap?: { registerLayer?: unknown } }).keymap
|
|
41
|
+
return candidate != null && typeof candidate.registerLayer === 'function'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Register the `/copilot-status` command using whichever TUI API surface
|
|
46
|
+
* the host OpenCode runtime exposes.
|
|
47
|
+
*
|
|
48
|
+
* OpenCode 1.14.42 removed `api.command.register` in favor of the new
|
|
49
|
+
* keymap engine (`api.keymap.registerLayer`). 1.14.44+ restored
|
|
50
|
+
* `api.command.register` as a deprecated shim that translates to
|
|
51
|
+
* `keymap.registerLayer` internally. The dual-path helper below prefers
|
|
52
|
+
* `keymap.registerLayer` when present (the canonical surface) and falls
|
|
53
|
+
* back to `command.register` for hosts pinned at 1.14.41 or earlier.
|
|
54
|
+
*
|
|
55
|
+
* If neither surface is available, registration is a no-op and a warning
|
|
56
|
+
* is logged. The TUI plugin still loads (dialog UI continues to work);
|
|
57
|
+
* only the slash command discovery affordance is missing.
|
|
58
|
+
*
|
|
59
|
+
* Reference: Magic Context commit `5fe1c4f` on cortexkit/magic-context
|
|
60
|
+
* established this dual-path pattern across the same upstream gap.
|
|
61
|
+
*/
|
|
62
|
+
function registerCopilotStatusCommand(
|
|
63
|
+
api: Parameters<TuiPlugin>[0],
|
|
64
|
+
openList: () => void,
|
|
65
|
+
): () => void {
|
|
66
|
+
if (hasKeymapRegisterLayer(api)) {
|
|
67
|
+
return api.keymap.registerLayer({
|
|
68
|
+
commands: [
|
|
69
|
+
{
|
|
70
|
+
namespace: 'palette',
|
|
71
|
+
name: 'copilot-status',
|
|
72
|
+
title: 'Copilot Status',
|
|
73
|
+
category: 'Copilot',
|
|
74
|
+
run() {
|
|
75
|
+
openList()
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
bindings: [],
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (typeof api.command?.register === 'function') {
|
|
84
|
+
return api.command.register(() => [
|
|
85
|
+
{
|
|
86
|
+
title: 'Copilot Status',
|
|
87
|
+
value: '/copilot-status',
|
|
88
|
+
slash: { name: 'copilot-status' },
|
|
89
|
+
onSelect() {
|
|
90
|
+
openList()
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
])
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Plugin-level logs normally go through `client.app.log`, but the TUI
|
|
97
|
+
// half has no equivalent structured channel — `console.warn` is the
|
|
98
|
+
// only practical option. Surfaces in dev/debug consoles; in production
|
|
99
|
+
// the message is purely defensive (it only fires when the host runtime
|
|
100
|
+
// exposes neither registration surface, which should never happen).
|
|
101
|
+
console.warn(
|
|
102
|
+
'[opencode-copilot-delegate] No supported TUI command-registration API found (neither api.keymap.registerLayer nor api.command.register). The /copilot-status slash command will not be available, but the plugin remains loaded.',
|
|
103
|
+
)
|
|
104
|
+
return () => {}
|
|
105
|
+
}
|
|
106
|
+
|
|
15
107
|
const tui: TuiPlugin = async (api) => {
|
|
16
108
|
const rpc = createRpcClient()
|
|
17
109
|
const closeDialog = () => {
|
|
@@ -45,16 +137,9 @@ const tui: TuiPlugin = async (api) => {
|
|
|
45
137
|
})
|
|
46
138
|
}
|
|
47
139
|
|
|
48
|
-
const unregister = api
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
value: '/copilot-status',
|
|
52
|
-
slash: { name: 'copilot-status' },
|
|
53
|
-
onSelect: () => {
|
|
54
|
-
openList()
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
])
|
|
140
|
+
const unregister = registerCopilotStatusCommand(api, () => {
|
|
141
|
+
openList()
|
|
142
|
+
})
|
|
58
143
|
|
|
59
144
|
api.lifecycle.onDispose(() => {
|
|
60
145
|
rpc.dispose()
|