opencode-agent-ghost-panel 0.1.8 → 0.1.10
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 +99 -99
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -43,114 +43,114 @@ function executeAgp(args) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//
|
|
47
|
-
export const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
cmdArgs
|
|
46
|
+
// OpenCode 插件入口 - 只导出一个 Plugin 函数
|
|
47
|
+
export const AgentGhostPanel = async (ctx) => {
|
|
48
|
+
// 定义所有 AGP 工具
|
|
49
|
+
const agpDiff = tool({
|
|
50
|
+
description: "在 tmux 新窗口显示 git diff(带语法高亮)",
|
|
51
|
+
args: {
|
|
52
|
+
file: z.string().optional().describe("文件路径(可选,默认当前目录)")
|
|
53
|
+
},
|
|
54
|
+
execute: async (args) => {
|
|
55
|
+
try {
|
|
56
|
+
const cmdArgs = ["diff"];
|
|
57
|
+
if (args.file) {
|
|
58
|
+
cmdArgs.push("--file", args.file);
|
|
59
|
+
}
|
|
60
|
+
const result = await executeAgp(cmdArgs);
|
|
61
|
+
return `✅ ${result}`;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return `❌ 执行失败: ${error}`;
|
|
57
64
|
}
|
|
58
|
-
const result = await executeAgp(cmdArgs);
|
|
59
|
-
return `✅ ${result}`;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
return `❌ 执行失败: ${error}`;
|
|
62
65
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const agpLogs = tool({
|
|
69
|
+
description: "实时监控日志文件",
|
|
70
|
+
args: {
|
|
71
|
+
file: z.string().describe("日志文件路径")
|
|
72
|
+
},
|
|
73
|
+
execute: async (args) => {
|
|
74
|
+
try {
|
|
75
|
+
const result = await executeAgp(["logs", args.file]);
|
|
76
|
+
return `✅ ${result}`;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return `❌ 执行失败: ${error}`;
|
|
79
|
+
}
|
|
77
80
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const agpInteractive = tool({
|
|
84
|
+
description: "打开交互式终端(用于 ssh、sudo 等需要用户输入的命令)",
|
|
85
|
+
args: {
|
|
86
|
+
command: z.string().optional().describe("初始命令(可选)")
|
|
87
|
+
},
|
|
88
|
+
execute: async (args) => {
|
|
89
|
+
try {
|
|
90
|
+
const cmdArgs = ["interactive"];
|
|
91
|
+
if (args.command) {
|
|
92
|
+
cmdArgs.push(args.command);
|
|
93
|
+
}
|
|
94
|
+
const result = await executeAgp(cmdArgs);
|
|
95
|
+
return `✅ ${result}`;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
return `❌ 执行失败: ${error}`;
|
|
91
98
|
}
|
|
92
|
-
const result = await executeAgp(cmdArgs);
|
|
93
|
-
return `✅ ${result}`;
|
|
94
|
-
} catch (error) {
|
|
95
|
-
return `❌ 执行失败: ${error}`;
|
|
96
99
|
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const agpStatus = tool({
|
|
103
|
+
description: "查看 AGP 守护进程状态",
|
|
104
|
+
args: {},
|
|
105
|
+
execute: async () => {
|
|
106
|
+
try {
|
|
107
|
+
const result = await executeAgp(["status"]);
|
|
108
|
+
return result;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
return `❌ AGP 未运行。请先运行: agp start`;
|
|
111
|
+
}
|
|
109
112
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const agpSessions = tool({
|
|
116
|
+
description: "列出所有 tmux 会话",
|
|
117
|
+
args: {},
|
|
118
|
+
execute: async () => {
|
|
119
|
+
try {
|
|
120
|
+
const result = await executeAgp(["sessions"]);
|
|
121
|
+
return result;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
return `❌ 执行失败: ${error}`;
|
|
124
|
+
}
|
|
122
125
|
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const agpStart = tool({
|
|
129
|
+
description: "启动 AGP 守护进程",
|
|
130
|
+
args: {},
|
|
131
|
+
execute: async () => {
|
|
132
|
+
try {
|
|
133
|
+
const result = await executeAgp(["start"]);
|
|
134
|
+
return result;
|
|
135
|
+
} catch (error) {
|
|
136
|
+
return `❌ 启动失败: ${error}`;
|
|
137
|
+
}
|
|
135
138
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const agpStop = tool({
|
|
142
|
+
description: "停止 AGP 守护进程",
|
|
143
|
+
args: {},
|
|
144
|
+
execute: async () => {
|
|
145
|
+
try {
|
|
146
|
+
const result = await executeAgp(["stop"]);
|
|
147
|
+
return result;
|
|
148
|
+
} catch (error) {
|
|
149
|
+
return `❌ 停止失败: ${error}`;
|
|
150
|
+
}
|
|
148
151
|
}
|
|
149
|
-
}
|
|
150
|
-
});
|
|
152
|
+
});
|
|
151
153
|
|
|
152
|
-
// OpenCode 插件入口 - 必须是 async function
|
|
153
|
-
export default async function(input) {
|
|
154
154
|
return {
|
|
155
155
|
tool: {
|
|
156
156
|
"agp-diff": agpDiff,
|
|
@@ -162,4 +162,4 @@ export default async function(input) {
|
|
|
162
162
|
"agp-stop": agpStop
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
|
-
}
|
|
165
|
+
};
|