opencode-agent-ghost-panel 0.1.3 → 0.1.4

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 +17 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -19,6 +19,16 @@ const AGP_HOST = process.env.AGP_HOST || "127.0.0.1";
19
19
 
20
20
  const z = tool.schema;
21
21
 
22
+ // ANSI 转义码清理正则
23
+ const ANSI_ESCAPE = /\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;
24
+
25
+ /**
26
+ * 清理 ANSI 转义字符
27
+ */
28
+ function cleanAnsi(text) {
29
+ return text.replace(ANSI_ESCAPE, "");
30
+ }
31
+
22
32
  /**
23
33
  * 执行 AGP 命令
24
34
  */
@@ -42,9 +52,9 @@ function executeAgp(args) {
42
52
 
43
53
  proc.on("close", (code) => {
44
54
  if (code === 0) {
45
- resolve(stdout);
55
+ resolve(cleanAnsi(stdout));
46
56
  } else {
47
- reject(new Error(stderr || `Exit code: ${code}`));
57
+ reject(new Error(cleanAnsi(stderr) || `Exit code: ${code}`));
48
58
  }
49
59
  });
50
60
 
@@ -62,9 +72,9 @@ export const agpDiff = {
62
72
  },
63
73
  execute: async (args, context) => {
64
74
  try {
65
- const fileArg = args.file ? ` --file ${args.file}` : "";
75
+ const fileArg = args.file ? ` --file "${args.file}"` : "";
66
76
  const result = await executeAgp(["diff" + fileArg]);
67
- return `✅ ${result}`;
77
+ return `✅ diff 面板已创建。在 tmux 窗口中查看: Ctrl+b, n 切换窗口`;
68
78
  } catch (error) {
69
79
  return `❌ 执行失败: ${error}`;
70
80
  }
@@ -79,7 +89,7 @@ export const agpLogs = {
79
89
  execute: async (args, context) => {
80
90
  try {
81
91
  const result = await executeAgp(["logs", args.file]);
82
- return `✅ ${result}`;
92
+ return `✅ 日志监控已启动。在 tmux 窗口中查看`;
83
93
  } catch (error) {
84
94
  return `❌ 执行失败: ${error}`;
85
95
  }
@@ -93,9 +103,8 @@ export const agpInteractive = {
93
103
  },
94
104
  execute: async (args, context) => {
95
105
  try {
96
- const cmdArg = args.command ? ` ${args.command}` : "";
97
- const result = await executeAgp(["interactive" + cmdArg]);
98
- return `✅ ${result}`;
106
+ const result = await executeAgp(["interactive"]);
107
+ return `✅ 交互式终端已打开。在 tmux 窗口中操作`;
99
108
  } catch (error) {
100
109
  return `❌ 执行失败: ${error}`;
101
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-ghost-panel",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "基于 Tmux 的终端多路复用与交互增强",
5
5
  "main": "index.js",
6
6
  "type": "module",