opencode-agent-ghost-panel 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/index.js +122 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -54,6 +54,128 @@ function executeAgp(args) {
54
54
  });
55
55
  }
56
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
+ export default async function(input) {
159
+ return {
160
+ tool: {
161
+ "agp-diff": agpDiff,
162
+ "agp-logs": agpLogs,
163
+ "agp-interactive": agpInteractive,
164
+ "agp-status": agpStatus,
165
+ "agp-sessions": agpSessions,
166
+ "agp-start": agpStart,
167
+ "agp-stop": agpStop
168
+ }
169
+ };
170
+ }
171
+ });
172
+
173
+ proc.on("error", (error) => {
174
+ reject(error);
175
+ });
176
+ });
177
+ }
178
+
57
179
  // 定义 AGP 工具
58
180
  export const agpDiff = tool({
59
181
  description: "在 tmux 新窗口显示 git diff(带语法高亮)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-ghost-panel",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "基于 Tmux 的终端多路复用与交互增强",
5
5
  "main": "index.js",
6
6
  "type": "module",