opencode-agent-ghost-panel 0.1.3 → 0.1.5
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/index.js +7 -160
- package/package.json +3 -21
package/index.js
CHANGED
|
@@ -1,170 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Ghost Panel Plugin for OpenCode
|
|
3
|
-
*
|
|
4
|
-
* 这个插件将 AGP 功能集成到 OpenCode 中。
|
|
5
|
-
* 支持的命令:
|
|
6
|
-
* - /diff - 在 tmux 新窗口显示 git diff
|
|
7
|
-
* - /logs - 监控日志文件
|
|
8
|
-
* - /interactive - 交互式终端
|
|
9
|
-
* - /status - 查看 AGP 状态
|
|
10
|
-
* - /sessions - 列出 tmux 会话
|
|
11
3
|
*/
|
|
12
4
|
|
|
13
|
-
import { tool } from "@opencode-ai/plugin";
|
|
14
|
-
import { spawn } from "child_process";
|
|
15
|
-
|
|
16
|
-
// AGP 配置
|
|
17
|
-
const AGP_PORT = process.env.AGP_PORT || "8765";
|
|
18
|
-
const AGP_HOST = process.env.AGP_HOST || "127.0.0.1";
|
|
19
|
-
|
|
20
|
-
const z = tool.schema;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 执行 AGP 命令
|
|
24
|
-
*/
|
|
25
|
-
function executeAgp(args) {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
const proc = spawn("agp", args, {
|
|
28
|
-
cwd: process.cwd(),
|
|
29
|
-
env: { ...process.env, AGP_PORT, AGP_HOST }
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
let stdout = "";
|
|
33
|
-
let stderr = "";
|
|
34
|
-
|
|
35
|
-
proc.stdout.on("data", (data) => {
|
|
36
|
-
stdout += data.toString();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
proc.stderr.on("data", (data) => {
|
|
40
|
-
stderr += data.toString();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
proc.on("close", (code) => {
|
|
44
|
-
if (code === 0) {
|
|
45
|
-
resolve(stdout);
|
|
46
|
-
} else {
|
|
47
|
-
reject(new Error(stderr || `Exit code: ${code}`));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
proc.on("error", (error) => {
|
|
52
|
-
reject(error);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 定义 AGP 工具
|
|
58
|
-
export const agpDiff = {
|
|
59
|
-
description: "在 tmux 新窗口显示 git diff(带语法高亮)",
|
|
60
|
-
args: {
|
|
61
|
-
file: z.string().optional().describe("文件路径(可选,默认当前目录)")
|
|
62
|
-
},
|
|
63
|
-
execute: async (args, context) => {
|
|
64
|
-
try {
|
|
65
|
-
const fileArg = args.file ? ` --file ${args.file}` : "";
|
|
66
|
-
const result = await executeAgp(["diff" + fileArg]);
|
|
67
|
-
return `✅ ${result}`;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
return `❌ 执行失败: ${error}`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const agpLogs = {
|
|
75
|
-
description: "实时监控日志文件",
|
|
76
|
-
args: {
|
|
77
|
-
file: z.string().describe("日志文件路径")
|
|
78
|
-
},
|
|
79
|
-
execute: async (args, context) => {
|
|
80
|
-
try {
|
|
81
|
-
const result = await executeAgp(["logs", args.file]);
|
|
82
|
-
return `✅ ${result}`;
|
|
83
|
-
} catch (error) {
|
|
84
|
-
return `❌ 执行失败: ${error}`;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const agpInteractive = {
|
|
90
|
-
description: "打开交互式终端(用于 ssh、sudo 等需要用户输入的命令)",
|
|
91
|
-
args: {
|
|
92
|
-
command: z.string().optional().describe("初始命令(可选)")
|
|
93
|
-
},
|
|
94
|
-
execute: async (args, context) => {
|
|
95
|
-
try {
|
|
96
|
-
const cmdArg = args.command ? ` ${args.command}` : "";
|
|
97
|
-
const result = await executeAgp(["interactive" + cmdArg]);
|
|
98
|
-
return `✅ ${result}`;
|
|
99
|
-
} catch (error) {
|
|
100
|
-
return `❌ 执行失败: ${error}`;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const agpStatus = {
|
|
106
|
-
description: "查看 AGP 守护进程状态",
|
|
107
|
-
args: {},
|
|
108
|
-
execute: async (args, context) => {
|
|
109
|
-
try {
|
|
110
|
-
const result = await executeAgp(["status"]);
|
|
111
|
-
return result;
|
|
112
|
-
} catch (error) {
|
|
113
|
-
return `❌ AGP 未运行。请先运行: agp start`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const agpSessions = {
|
|
119
|
-
description: "列出所有 tmux 会话",
|
|
120
|
-
args: {},
|
|
121
|
-
execute: async (args, context) => {
|
|
122
|
-
try {
|
|
123
|
-
const result = await executeAgp(["sessions"]);
|
|
124
|
-
return result;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
return `❌ 执行失败: ${error}`;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const agpStart = {
|
|
132
|
-
description: "启动 AGP 守护进程",
|
|
133
|
-
args: {},
|
|
134
|
-
execute: async (args, context) => {
|
|
135
|
-
try {
|
|
136
|
-
const result = await executeAgp(["start"]);
|
|
137
|
-
return result;
|
|
138
|
-
} catch (error) {
|
|
139
|
-
return `❌ 启动失败: ${error}`;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const agpStop = {
|
|
145
|
-
description: "停止 AGP 守护进程",
|
|
146
|
-
args: {},
|
|
147
|
-
execute: async (args, context) => {
|
|
148
|
-
try {
|
|
149
|
-
const result = await executeAgp(["stop"]);
|
|
150
|
-
return result;
|
|
151
|
-
} catch (error) {
|
|
152
|
-
return `❌ 停止失败: ${error}`;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
// OpenCode 插件入口
|
|
158
5
|
export default async function(input) {
|
|
159
6
|
return {
|
|
160
7
|
tool: {
|
|
161
|
-
"agp-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
8
|
+
"agp-status": {
|
|
9
|
+
description: "Check AGP daemon status",
|
|
10
|
+
args: {},
|
|
11
|
+
execute: async (args, ctx) => {
|
|
12
|
+
return "AGP plugin is loaded successfully!";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
168
15
|
}
|
|
169
16
|
};
|
|
170
17
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-agent-ghost-panel",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Agent Ghost Panel Plugin for OpenCode",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"type": "module"
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"tmux",
|
|
12
|
-
"terminal",
|
|
13
|
-
"multiplexer",
|
|
14
|
-
"ai-agent",
|
|
15
|
-
"opencode"
|
|
16
|
-
],
|
|
17
|
-
"author": "Your Name",
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=18.0.0"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@opencode-ai/plugin": "^1.0.0"
|
|
24
|
-
}
|
|
6
|
+
"type": "module"
|
|
25
7
|
}
|