@superbfowle/bash-history-mcp-test 0.1.7 → 0.1.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/opencode.ts +80 -80
- package/package.json +1 -1
package/opencode.ts
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
1
|
import type { Plugin } from "@odebugpencode-ai/plugin";
|
|
2
2
|
|
|
3
3
|
export const OpencodeBashHistoryPlugin: Plugin = async ({ client }) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
console.log("atuin load zero-a");
|
|
5
|
+
//await client.app.log({
|
|
6
|
+
// service: "atuin-history",
|
|
7
|
+
// level: "info",
|
|
8
|
+
// message: "atuin history load",
|
|
9
|
+
// extra: {},
|
|
10
|
+
//})
|
|
11
|
+
console.log("atuin load zero-b");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
return {
|
|
14
|
+
"tool.execute.after": async (input, output) => {
|
|
15
|
+
console.log("atuin history run-a");
|
|
16
|
+
await client.app.log({
|
|
17
|
+
service: "atuin-history",
|
|
18
|
+
level: "info",
|
|
19
|
+
message: "atuin-history run",
|
|
20
|
+
extra: { input, output },
|
|
21
|
+
});
|
|
22
|
+
console.log("atuin history run-b");
|
|
23
|
+
console.log("atuin history", input, output);
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (input.tool !== "bash") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
console.log("atuin history run-c");
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
try {
|
|
31
|
+
const command = output.metadata?.args?.command;
|
|
32
|
+
if (!command || typeof command !== "string") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const exitCode = output.metadata?.exitCode ?? 0;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const startProc = Bun.spawn(["atuin", "history", "start", command], {
|
|
39
|
+
stdout: "pipe",
|
|
40
|
+
stderr: "pipe",
|
|
41
|
+
});
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
const startExitCode = await startProc.exited;
|
|
44
|
+
if (startExitCode !== 0) {
|
|
45
|
+
const stderr = await Bun.readableStreamToText(startProc.stderr);
|
|
46
|
+
await client.app.log({
|
|
47
|
+
service: "bash-history",
|
|
48
|
+
level: "error",
|
|
49
|
+
message: "Failed to start atuin history entry",
|
|
50
|
+
extra: { error: stderr },
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
const id = (await Bun.readableStreamToText(startProc.stdout)).trim();
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
const endProc = Bun.spawn(
|
|
58
|
+
[
|
|
59
|
+
"atuin",
|
|
60
|
+
"history",
|
|
61
|
+
"end",
|
|
62
|
+
"--exit",
|
|
63
|
+
String(exitCode),
|
|
64
|
+
"--duration",
|
|
65
|
+
"0",
|
|
66
|
+
id,
|
|
67
|
+
],
|
|
68
|
+
{
|
|
69
|
+
stderr: "pipe",
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
const endExitCode = await endProc.exited;
|
|
74
|
+
if (endExitCode !== 0) {
|
|
75
|
+
const stderr = await Bun.readableStreamToText(endProc.stderr);
|
|
76
|
+
await client.app.log({
|
|
77
|
+
service: "bash-history",
|
|
78
|
+
level: "error",
|
|
79
|
+
message: "Failed to end atuin history entry",
|
|
80
|
+
extra: { error: stderr },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
await client.app.log({
|
|
85
|
+
service: "bash-history",
|
|
86
|
+
level: "error",
|
|
87
|
+
message: "Bash history plugin error",
|
|
88
|
+
extra: { error: String(error) },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
93
|
};
|