opencode-terminal-progress 0.1.0 → 0.2.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/dist/index.js +50 -18
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,36 +13,68 @@ function detectTerminal() {
|
|
|
13
13
|
}
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
function createOsc() {
|
|
17
|
+
const inTmux = !!process.env["TMUX"];
|
|
18
|
+
return (payload) => {
|
|
19
|
+
const esc = inTmux ? `\x1BPtmux;\x1B\x1B]${payload}\x07\x1B\\` : `\x1B]${payload}\x07`;
|
|
20
|
+
process.stdout.write(esc);
|
|
21
|
+
};
|
|
22
22
|
}
|
|
23
23
|
var TerminalProgressPlugin = async () => {
|
|
24
|
-
|
|
25
|
-
if (!terminal)
|
|
24
|
+
if (!detectTerminal())
|
|
26
25
|
return {};
|
|
26
|
+
const osc = createOsc();
|
|
27
|
+
let waitingForInput = false;
|
|
28
|
+
function progress(code) {
|
|
29
|
+
osc(`9;4;${code}`);
|
|
30
|
+
}
|
|
31
|
+
function pause() {
|
|
32
|
+
waitingForInput = true;
|
|
33
|
+
progress("4;50");
|
|
34
|
+
}
|
|
35
|
+
function resume() {
|
|
36
|
+
waitingForInput = false;
|
|
37
|
+
}
|
|
27
38
|
return {
|
|
28
39
|
event: async ({ event }) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
switch (event.type) {
|
|
41
|
+
case "session.status": {
|
|
42
|
+
const { status } = event.properties;
|
|
43
|
+
switch (status.type) {
|
|
44
|
+
case "busy":
|
|
45
|
+
if (!waitingForInput)
|
|
46
|
+
progress("3");
|
|
47
|
+
break;
|
|
48
|
+
case "idle":
|
|
49
|
+
resume();
|
|
50
|
+
progress("0");
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
35
54
|
}
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
case "session.idle":
|
|
56
|
+
resume();
|
|
57
|
+
progress("0");
|
|
58
|
+
break;
|
|
59
|
+
case "session.error":
|
|
60
|
+
resume();
|
|
61
|
+
progress("2");
|
|
62
|
+
break;
|
|
63
|
+
case "permission.asked":
|
|
64
|
+
pause();
|
|
65
|
+
break;
|
|
66
|
+
case "permission.replied":
|
|
67
|
+
resume();
|
|
68
|
+
progress("3");
|
|
69
|
+
break;
|
|
38
70
|
}
|
|
39
71
|
},
|
|
40
72
|
"permission.ask": async () => {
|
|
41
|
-
|
|
73
|
+
pause();
|
|
42
74
|
},
|
|
43
75
|
"tool.execute.before": async (input) => {
|
|
44
76
|
if (input.tool === "question") {
|
|
45
|
-
|
|
77
|
+
pause();
|
|
46
78
|
}
|
|
47
79
|
}
|
|
48
80
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-terminal-progress",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "OpenCode plugin that shows agent progress in terminal tabs (iTerm2, WezTerm, Windows Terminal)",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Pedro Pombeiro",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@eslint/js": "^9.39.1",
|
|
42
|
-
"@opencode-ai/plugin": "1.
|
|
42
|
+
"@opencode-ai/plugin": "^1.2.20",
|
|
43
43
|
"@types/node": "^20.11.5",
|
|
44
44
|
"bun-types": "1.3.10",
|
|
45
45
|
"eslint": "^9.39.1",
|