@mynameistito/oc-ctrl-enter-force-import 0.1.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/LICENSE +21 -0
- package/README.md +110 -0
- package/dist/tui.d.mts +14 -0
- package/dist/tui.mjs +47 -0
- package/dist/tui.mjs.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mynameistito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# oc-ctrl-enter-force-import
|
|
2
|
+
|
|
3
|
+
OpenCode TUI plugin that force-submits the current prompt with `Ctrl+Enter`.
|
|
4
|
+
|
|
5
|
+
It interrupts the active OpenCode run first, then submits the prompt so the message does not sit behind the current generation queue.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Add the plugin package to `~/.config/opencode/tui.json`:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
14
|
+
"plugin": ["@mynameistito/oc-ctrl-enter-force-import"]
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
OpenCode will install the package when the TUI starts. Restart OpenCode after changing plugin config.
|
|
19
|
+
|
|
20
|
+
For local testing, clone the plugin somewhere stable:
|
|
21
|
+
|
|
22
|
+
```powershell
|
|
23
|
+
git clone https://github.com/mynameistito/oc-ctrl-enter-force-import.git
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Build it:
|
|
27
|
+
|
|
28
|
+
```powershell
|
|
29
|
+
bun install
|
|
30
|
+
bun run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Add the built TUI plugin file to `~/.config/opencode/tui.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
38
|
+
"plugin": ["file:///C:/path/to/oc-ctrl-enter-force-import/dist/tui.mjs"]
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Restart OpenCode after changing plugin config.
|
|
43
|
+
|
|
44
|
+
For standalone testing from `~/.config/opencode/plugins`, add the file to `~/.config/opencode/tui.json` as a TUI plugin:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
49
|
+
"plugin": [
|
|
50
|
+
"file:///C:/Users/you/.config/opencode/plugins/oc-ctrl-enter-force-import.ts"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
OpenCode's default `input_newline` binding includes `ctrl+return`, which can make Ctrl+Enter insert a newline before this plugin sees it. Remove `ctrl+return` from `input_newline` in your `tui.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
60
|
+
"keybinds": {
|
|
61
|
+
"input_newline": "shift+return,alt+return,ctrl+j"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Behavior
|
|
67
|
+
|
|
68
|
+
The plugin registers high-priority TUI keybindings for `ctrl+return` and `ctrl+enter`, both mapped to a custom command that:
|
|
69
|
+
|
|
70
|
+
1. Dispatches OpenCode's built-in `session.interrupt` command.
|
|
71
|
+
2. Repeats `session.interrupt` to pass OpenCode's guarded abort flow when a generation is active.
|
|
72
|
+
3. Dispatches OpenCode's built-in `prompt.submit` command.
|
|
73
|
+
|
|
74
|
+
It does not change your `tui.json`, so any existing `input_submit` or `input_newline` preferences stay intact.
|
|
75
|
+
|
|
76
|
+
Because OpenCode's managed textarea keybinds run on the focused prompt, `ctrl+return` must not also be bound to `input_newline`.
|
|
77
|
+
|
|
78
|
+
## Windows Terminal
|
|
79
|
+
|
|
80
|
+
Many terminals send plain `Enter` for `Ctrl+Enter` unless configured. In Windows Terminal, add this action to the root-level `actions` array:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"command": {
|
|
85
|
+
"action": "sendInput",
|
|
86
|
+
"input": "\u001b[13;5u"
|
|
87
|
+
},
|
|
88
|
+
"id": "User.sendInput.CtrlEnterCustom"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then add this keybinding to the root-level `keybindings` array:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"keys": "ctrl+enter",
|
|
97
|
+
"id": "User.sendInput.CtrlEnterCustom"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Open a new Windows Terminal tab after saving the settings.
|
|
102
|
+
|
|
103
|
+
## Credits
|
|
104
|
+
|
|
105
|
+
Built on OpenCode's plugin and TUI keymap APIs:
|
|
106
|
+
|
|
107
|
+
- [OpenCode](https://opencode.ai/)
|
|
108
|
+
- [OpenCode plugins documentation](https://opencode.ai/docs/plugins/)
|
|
109
|
+
- [OpenCode keybinds documentation](https://opencode.ai/docs/keybinds/)
|
|
110
|
+
- [OpenTUI keymap](https://github.com/anomalyco/opentui)
|
package/dist/tui.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Registers a high-priority Ctrl+Enter binding that interrupts the active
|
|
4
|
+
* OpenCode session before submitting the current prompt.
|
|
5
|
+
*/
|
|
6
|
+
declare const tui: (api: import("@opencode-ai/plugin/tui").TuiPluginApi) => Promise<void>;
|
|
7
|
+
/** OpenCode plugin module entrypoint. */
|
|
8
|
+
declare const _default: {
|
|
9
|
+
id: string;
|
|
10
|
+
tui: (api: import("@opencode-ai/plugin/tui").TuiPluginApi) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { _default as default, tui };
|
|
14
|
+
//# sourceMappingURL=tui.d.mts.map
|
package/dist/tui.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region index.ts
|
|
2
|
+
/** Stable plugin ID required by OpenCode for file-based TUI plugins. */
|
|
3
|
+
const PLUGIN_ID = "oc-ctrl-enter-force-import";
|
|
4
|
+
/** OpenCode command registered by this plugin for Ctrl+Enter force-submit. */
|
|
5
|
+
const FORCE_SUBMIT_COMMAND = "oc-ctrl-enter.force-submit";
|
|
6
|
+
/** Key sequences commonly emitted for Ctrl+Enter across OpenCode/OpenTUI environments. */
|
|
7
|
+
const CTRL_ENTER_BINDINGS = [{
|
|
8
|
+
cmd: FORCE_SUBMIT_COMMAND,
|
|
9
|
+
key: "ctrl+return"
|
|
10
|
+
}, {
|
|
11
|
+
cmd: FORCE_SUBMIT_COMMAND,
|
|
12
|
+
key: "ctrl+enter"
|
|
13
|
+
}];
|
|
14
|
+
/**
|
|
15
|
+
* Registers a high-priority Ctrl+Enter binding that interrupts the active
|
|
16
|
+
* OpenCode session before submitting the current prompt.
|
|
17
|
+
*/
|
|
18
|
+
const tui = ((api) => {
|
|
19
|
+
const dispose = api.keymap.registerLayer({
|
|
20
|
+
bindings: CTRL_ENTER_BINDINGS,
|
|
21
|
+
commands: [{
|
|
22
|
+
category: "Prompt",
|
|
23
|
+
hidden: true,
|
|
24
|
+
name: FORCE_SUBMIT_COMMAND,
|
|
25
|
+
run: (context) => {
|
|
26
|
+
api.keymap.dispatchCommand("session.interrupt", context);
|
|
27
|
+
api.keymap.dispatchCommand("session.interrupt", context);
|
|
28
|
+
api.keymap.dispatchCommand("session.interrupt", context);
|
|
29
|
+
api.keymap.dispatchCommand("prompt.submit", context);
|
|
30
|
+
},
|
|
31
|
+
title: "Force submit prompt"
|
|
32
|
+
}],
|
|
33
|
+
name: "oc-ctrl-enter",
|
|
34
|
+
priority: 1e3
|
|
35
|
+
});
|
|
36
|
+
api.lifecycle.onDispose(dispose);
|
|
37
|
+
return Promise.resolve();
|
|
38
|
+
});
|
|
39
|
+
/** OpenCode plugin module entrypoint. */
|
|
40
|
+
var oc_ctrl_enter_default = {
|
|
41
|
+
id: PLUGIN_ID,
|
|
42
|
+
tui
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { oc_ctrl_enter_default as default, tui };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=tui.mjs.map
|
package/dist/tui.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.mjs","names":[],"sources":["../index.ts"],"sourcesContent":["import type { TuiPlugin, TuiPluginModule } from \"@opencode-ai/plugin/tui\";\n\n/** Stable plugin ID required by OpenCode for file-based TUI plugins. */\nconst PLUGIN_ID = \"oc-ctrl-enter-force-import\";\n\n/** OpenCode command registered by this plugin for Ctrl+Enter force-submit. */\nconst FORCE_SUBMIT_COMMAND = \"oc-ctrl-enter.force-submit\";\n\n/** Key sequences commonly emitted for Ctrl+Enter across OpenCode/OpenTUI environments. */\nconst CTRL_ENTER_BINDINGS = [\n { cmd: FORCE_SUBMIT_COMMAND, key: \"ctrl+return\" },\n { cmd: FORCE_SUBMIT_COMMAND, key: \"ctrl+enter\" },\n] as const;\n\n/**\n * Registers a high-priority Ctrl+Enter binding that interrupts the active\n * OpenCode session before submitting the current prompt.\n */\nexport const tui = ((api) => {\n const dispose = api.keymap.registerLayer({\n bindings: CTRL_ENTER_BINDINGS,\n commands: [\n {\n category: \"Prompt\",\n hidden: true,\n name: FORCE_SUBMIT_COMMAND,\n run: (context) => {\n // Run through OpenCode's native commands so the prompt lifecycle stays intact.\n api.keymap.dispatchCommand(\"session.interrupt\", context);\n api.keymap.dispatchCommand(\"session.interrupt\", context);\n api.keymap.dispatchCommand(\"session.interrupt\", context);\n api.keymap.dispatchCommand(\"prompt.submit\", context);\n },\n title: \"Force submit prompt\",\n },\n ],\n name: \"oc-ctrl-enter\",\n priority: 1000,\n });\n\n api.lifecycle.onDispose(dispose);\n return Promise.resolve();\n}) satisfies TuiPlugin;\n\n/** OpenCode plugin module entrypoint. */\nexport default { id: PLUGIN_ID, tui } satisfies TuiPluginModule;\n"],"mappings":";;AAGA,MAAM,YAAY;;AAGlB,MAAM,uBAAuB;;AAG7B,MAAM,sBAAsB,CAC1B;CAAE,KAAK;CAAsB,KAAK;AAAc,GAChD;CAAE,KAAK;CAAsB,KAAK;AAAa,CACjD;;;;;AAMA,MAAa,QAAQ,QAAQ;CAC3B,MAAM,UAAU,IAAI,OAAO,cAAc;EACvC,UAAU;EACV,UAAU,CACR;GACE,UAAU;GACV,QAAQ;GACR,MAAM;GACN,MAAM,YAAY;IAEhB,IAAI,OAAO,gBAAgB,qBAAqB,OAAO;IACvD,IAAI,OAAO,gBAAgB,qBAAqB,OAAO;IACvD,IAAI,OAAO,gBAAgB,qBAAqB,OAAO;IACvD,IAAI,OAAO,gBAAgB,iBAAiB,OAAO;GACrD;GACA,OAAO;EACT,CACF;EACA,MAAM;EACN,UAAU;CACZ,CAAC;CAED,IAAI,UAAU,UAAU,OAAO;CAC/B,OAAO,QAAQ,QAAQ;AACzB;;AAGA,IAAA,wBAAe;CAAE,IAAI;CAAW;AAAI"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mynameistito/oc-ctrl-enter-force-import",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenCode TUI plugin that interrupts the active run and submits the prompt with Ctrl+Enter.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ctrl-enter",
|
|
7
|
+
"force-submit",
|
|
8
|
+
"opencode",
|
|
9
|
+
"opencode-plugin",
|
|
10
|
+
"tui"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/mynameistito/oc-ctrl-enter-force-import#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/mynameistito/oc-ctrl-enter-force-import/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "mynameistito",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/mynameistito/oc-ctrl-enter-force-import.git"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/tui.mjs",
|
|
29
|
+
"module": "./dist/tui.mjs",
|
|
30
|
+
"types": "./dist/tui.d.mts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/tui.d.mts",
|
|
34
|
+
"import": "./dist/tui.mjs"
|
|
35
|
+
},
|
|
36
|
+
"./tui": {
|
|
37
|
+
"types": "./dist/tui.d.mts",
|
|
38
|
+
"import": "./dist/tui.mjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsdown",
|
|
46
|
+
"check": "ultracite check",
|
|
47
|
+
"fix": "ultracite fix",
|
|
48
|
+
"prepack": "bun run build"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@opencode-ai/plugin": "^1.17.13",
|
|
52
|
+
"@opentui/core": "^0.4.2",
|
|
53
|
+
"@opentui/keymap": "^0.4.2",
|
|
54
|
+
"@opentui/solid": "^0.4.2",
|
|
55
|
+
"@types/bun": "latest",
|
|
56
|
+
"lefthook": "^2.1.9",
|
|
57
|
+
"oxfmt": "^0.57.0",
|
|
58
|
+
"oxlint": "^1.72.0",
|
|
59
|
+
"tsdown": "^0.22.3",
|
|
60
|
+
"typescript": "5.8.2",
|
|
61
|
+
"ultracite": "7.8.3"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"typescript": "^5"
|
|
65
|
+
}
|
|
66
|
+
}
|