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