opencode-terminal-progress 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pedro Pombeiro
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,42 @@
1
+ # opencode-terminal-progress
2
+
3
+ An [OpenCode](https://opencode.ai) plugin that shows agent progress in your terminal tab using
4
+ [OSC 9;4](https://iterm2.com/documentation-escape-codes.html) progress reporting.
5
+
6
+ ## Supported terminals
7
+
8
+ | Terminal | Detection |
9
+ | --------------------------------------------------------- | ------------------------------------------------------- |
10
+ | [iTerm2](https://iterm2.com) | `TERM_PROGRAM=iTerm.app`, `LC_TERMINAL`, `ITERM_SESSION_ID` |
11
+ | [WezTerm](https://wezfurlong.org/wezterm/) | `TERM_PROGRAM=WezTerm`, `WEZTERM_EXECUTABLE` |
12
+ | [Windows Terminal](https://github.com/microsoft/terminal) | `WT_SESSION` |
13
+
14
+ The plugin automatically detects which terminal is in use and becomes a no-op if none of the above
15
+ are found. tmux passthrough is handled transparently when `$TMUX` is set.
16
+
17
+ ## Progress states
18
+
19
+ | Agent state | Progress indicator |
20
+ | ------------------- | ------------------ |
21
+ | Busy | Indeterminate |
22
+ | Idle | Cleared |
23
+ | Error | Error (red) |
24
+ | Waiting for input | Paused at 50% |
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install opencode-terminal-progress
30
+ ```
31
+
32
+ Add to your `~/.config/opencode/opencode.json`:
33
+
34
+ ```json
35
+ {
36
+ "plugin": ["opencode-terminal-progress"]
37
+ }
38
+ ```
39
+
40
+ ## License
41
+
42
+ [MIT](LICENSE)
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ // @bun
2
+ // src/index.ts
3
+ function detectTerminal() {
4
+ const env = process.env;
5
+ if (env["TERM_PROGRAM"] === "iTerm.app" || env["LC_TERMINAL"] === "iTerm2" || env["ITERM_SESSION_ID"]) {
6
+ return "iterm2";
7
+ }
8
+ if (env["TERM_PROGRAM"] === "WezTerm" || env["WEZTERM_EXECUTABLE"]) {
9
+ return "wezterm";
10
+ }
11
+ if (env["WT_SESSION"]) {
12
+ return "windows-terminal";
13
+ }
14
+ return;
15
+ }
16
+ function osc(payload) {
17
+ const esc = process.env["TMUX"] ? `\x1BPtmux;\x1B\x1B]${payload}\x07\x1B\\` : `\x1B]${payload}\x07`;
18
+ process.stdout.write(esc);
19
+ }
20
+ function progress(code) {
21
+ osc(`9;4;${code}`);
22
+ }
23
+ var TerminalProgressPlugin = async () => {
24
+ const terminal = detectTerminal();
25
+ if (!terminal)
26
+ return {};
27
+ return {
28
+ event: async ({ event }) => {
29
+ if (event.type === "session.status") {
30
+ const { status } = event.properties;
31
+ if (status.type === "busy") {
32
+ progress("3");
33
+ } else if (status.type === "idle") {
34
+ progress("0");
35
+ }
36
+ } else if (event.type === "session.error") {
37
+ progress("2");
38
+ }
39
+ },
40
+ "permission.ask": async () => {
41
+ progress("4;50");
42
+ },
43
+ "tool.execute.before": async (input) => {
44
+ if (input.tool === "question") {
45
+ progress("4;50");
46
+ }
47
+ }
48
+ };
49
+ };
50
+ export {
51
+ TerminalProgressPlugin
52
+ };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "opencode-terminal-progress",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode plugin that shows agent progress in terminal tabs (iTerm2, WezTerm, Windows Terminal)",
5
+ "author": {
6
+ "name": "Pedro Pombeiro",
7
+ "email": "pedropombeiro@users.noreply.github.com"
8
+ },
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "exports": {
12
+ ".": {
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/pedropombeiro/opencode-terminal-progress.git"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "keywords": [
27
+ "opencode",
28
+ "opencode-plugin",
29
+ "terminal",
30
+ "progress",
31
+ "iterm2",
32
+ "wezterm",
33
+ "windows-terminal",
34
+ "osc"
35
+ ],
36
+ "license": "MIT",
37
+ "peerDependencies": {
38
+ "@opencode-ai/plugin": ">=1.0.85"
39
+ },
40
+ "devDependencies": {
41
+ "@eslint/js": "^9.39.1",
42
+ "@opencode-ai/plugin": "1.0.85",
43
+ "@types/node": "^20.11.5",
44
+ "bun-types": "1.3.10",
45
+ "eslint": "^9.39.1",
46
+ "eslint-config-prettier": "10.1.8",
47
+ "eslint-plugin-prettier": "^5.1.3",
48
+ "prettier": "^3.2.4",
49
+ "typescript": "^5.7.0",
50
+ "typescript-eslint": "^8.47.0"
51
+ }
52
+ }