@fefeding/aicmd 1.0.20 → 1.0.22

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/README.md CHANGED
@@ -151,6 +151,17 @@ pnpm electron:build:mac # macOS (DMG, x64 + arm64)
151
151
  pnpm electron:build:linux # Linux (AppImage)
152
152
  ```
153
153
 
154
+ ### macOS 打开提示
155
+
156
+ CI 自动构建的 macOS 客户端**未使用 Apple Developer ID 签名公证**(无证书),下载后首次打开会提示“已损坏,无法打开”。这是 Gatekeeper 的 quarantine 拦截,并非文件损坏。解除拦截:
157
+
158
+ ```bash
159
+ # 下载后执行,移除 quarantine 属性即可正常打开
160
+ xattr -cr /Applications/AICmd.app
161
+ ```
162
+
163
+ 如果你自己有 Developer ID 证书,可在本地直接 `pnpm electron:build:mac` 出已签名的版本(脚本会自动从 keychain 取证书)。
164
+
154
165
  ### Automated Builds (CI/CD)
155
166
 
156
167
  Push a version tag to trigger multi-platform builds:
package/bin/aicmd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const crypto = require('crypto');
4
- const { exec, spawn } = require('child_process');
4
+ const { exec, spawn, execSync } = require('child_process');
5
5
  const path = require('path');
6
6
  const fs = require('fs');
7
7
  const net = require('net');
@@ -176,22 +176,69 @@ async function startProject() {
176
176
 
177
177
  function stopProject() {
178
178
  console.log('Stopping aicmd...');
179
+
180
+ // 解析 -p / --port 参数(与 start 保持一致)
181
+ let port = 9801;
182
+ const portIndex = commandArgs.findIndex(arg => arg === '-p' || arg === '--port');
183
+ if (portIndex !== -1 && commandArgs[portIndex + 1]) {
184
+ const p = parseInt(commandArgs[portIndex + 1]);
185
+ if (!isNaN(p)) port = p;
186
+ }
187
+
188
+ let stopped = false;
189
+
190
+ // 1) 优先用 PID 文件
179
191
  const pid = readPid();
180
- if (!pid) {
181
- console.log('No server process found');
182
- return;
192
+ if (pid) {
193
+ try {
194
+ process.kill(pid, 'SIGTERM');
195
+ console.log('Stopped process from PID file:', pid);
196
+ stopped = true;
197
+ } catch (error) {
198
+ if (error.code !== 'ESRCH') {
199
+ console.error('Failed to stop PID', pid + ':', error.message);
200
+ }
201
+ }
183
202
  }
184
203
 
185
- try {
186
- process.kill(pid, 'SIGTERM');
187
- deletePid();
188
- console.log('Server stopped');
189
- } catch (error) {
190
- if (error.code === 'ESRCH') {
191
- deletePid();
204
+ // 2) 兜底:查找监听该端口的 node server.js 进程(PID 文件丢失/跨用户/进程已变均适用)
205
+ const portPids = findPidsByPort(port);
206
+ for (const p of portPids) {
207
+ try {
208
+ process.kill(p, 'SIGTERM');
209
+ console.log('Stopped process on port', port + ':', p);
210
+ stopped = true;
211
+ } catch (error) {
212
+ if (error.code !== 'ESRCH') {
213
+ console.error('Failed to stop PID', p + ':', error.message);
214
+ }
192
215
  }
193
- console.error('Failed to stop:', error.message);
194
216
  }
217
+
218
+ // 3) 清理所有已知位置的 PID 文件(root 与普通用户),避免跨用户遗留
219
+ deletePid();
220
+ try { fs.unlinkSync('/root/.aicmd/aicmd.server.pid'); } catch { /* ignore */ }
221
+
222
+ if (stopped) {
223
+ console.log('Server stopped');
224
+ } else {
225
+ console.log('No running aicmd server found on port', port);
226
+ }
227
+ }
228
+
229
+ // 通过 lsof 查找监听指定端口的进程 PID 列表(macOS / Linux 通用)
230
+ function findPidsByPort(port) {
231
+ const pids = new Set();
232
+ try {
233
+ const out = execSync(`lsof -tiTCP:${port} -sTCP:LISTEN 2>/dev/null`).toString().trim();
234
+ if (out) {
235
+ for (const line of out.split('\n')) {
236
+ const p = parseInt(line.trim());
237
+ if (!isNaN(p)) pids.add(p);
238
+ }
239
+ }
240
+ } catch { /* lsof 不可用或无可匹配进程 */ }
241
+ return [...pids];
195
242
  }
196
243
 
197
244
  function restartProject() {
@@ -80,9 +80,9 @@
80
80
  "src": "src/views/index.vue",
81
81
  "isDynamicEntry": true,
82
82
  "imports": [
83
- "src/index.html",
84
83
  "_rolldown-runtime.js",
85
84
  "_vue.js",
85
+ "src/index.html",
86
86
  "_xterm.js"
87
87
  ],
88
88
  "css": [
@@ -20,10 +20,10 @@ var init_enums = __esmMin((() => {
20
20
  viewport = "viewport";
21
21
  popper = "popper";
22
22
  reference = "reference";
23
- variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
23
+ variationPlacements = /*#__PURE__*/ basePlacements.reduce(function(acc, placement) {
24
24
  return acc.concat([placement + "-" + start, placement + "-end"]);
25
25
  }, []);
26
- placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
26
+ placements = /*#__PURE__*/ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
27
27
  return acc.concat([
28
28
  placement,
29
29
  placement + "-" + start,
@@ -855,10 +855,7 @@ function computeOffsets(_ref) {
855
855
  case start:
856
856
  offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
857
857
  break;
858
- case "end":
859
- offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
860
- break;
861
- default:
858
+ case "end": offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
862
859
  }
863
860
  }
864
861
  return offsets;
@@ -1553,7 +1550,7 @@ var init_createPopper = __esmMin((() => {
1553
1550
  modifiers: [],
1554
1551
  strategy: "absolute"
1555
1552
  };
1556
- createPopper$2 = /* @__PURE__ */ popperGenerator();
1553
+ createPopper$2 = /*#__PURE__*/ popperGenerator();
1557
1554
  }));
1558
1555
  //#endregion
1559
1556
  //#region node_modules/.pnpm/@popperjs+core@2.11.8/node_modules/@popperjs/core/lib/popper-lite.js
@@ -1570,7 +1567,7 @@ var init_popper_lite = __esmMin((() => {
1570
1567
  computeStyles_default,
1571
1568
  applyStyles_default
1572
1569
  ];
1573
- createPopper$1 = /* @__PURE__ */ popperGenerator({ defaultModifiers: defaultModifiers$1 });
1570
+ createPopper$1 = /*#__PURE__*/ popperGenerator({ defaultModifiers: defaultModifiers$1 });
1574
1571
  }));
1575
1572
  //#endregion
1576
1573
  //#region node_modules/.pnpm/@popperjs+core@2.11.8/node_modules/@popperjs/core/lib/popper.js
@@ -1599,7 +1596,7 @@ var init_popper = __esmMin((() => {
1599
1596
  arrow_default,
1600
1597
  hide_default
1601
1598
  ];
1602
- createPopper = /* @__PURE__ */ popperGenerator({ defaultModifiers });
1599
+ createPopper = /*#__PURE__*/ popperGenerator({ defaultModifiers });
1603
1600
  }));
1604
1601
  //#endregion
1605
1602
  //#region node_modules/.pnpm/@popperjs+core@2.11.8/node_modules/@popperjs/core/lib/index.js
@@ -1956,7 +1953,7 @@ var init_bootstrap_esm = __esmMin((() => {
1956
1953
  mouseenter: "mouseover",
1957
1954
  mouseleave: "mouseout"
1958
1955
  };
1959
- nativeEvents = new Set([
1956
+ nativeEvents = /* @__PURE__ */ new Set([
1960
1957
  "click",
1961
1958
  "dblclick",
1962
1959
  "mouseup",
@@ -3683,7 +3680,7 @@ var init_bootstrap_esm = __esmMin((() => {
3683
3680
  u: [],
3684
3681
  ul: []
3685
3682
  };
3686
- uriAttributes = new Set([
3683
+ uriAttributes = /* @__PURE__ */ new Set([
3687
3684
  "background",
3688
3685
  "cite",
3689
3686
  "href",
@@ -3806,7 +3803,7 @@ var init_bootstrap_esm = __esmMin((() => {
3806
3803
  }
3807
3804
  };
3808
3805
  NAME$4 = "tooltip";
3809
- DISALLOWED_ATTRIBUTES = new Set([
3806
+ DISALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
3810
3807
  "sanitize",
3811
3808
  "allowList",
3812
3809
  "sanitizeFn"
@@ -4022,11 +4019,12 @@ var init_bootstrap_esm = __esmMin((() => {
4022
4019
  return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
4023
4020
  }
4024
4021
  _createPopper(tip) {
4025
- const attachment = AttachmentMap[execute(this._config.placement, [
4022
+ const placement = execute(this._config.placement, [
4026
4023
  this,
4027
4024
  tip,
4028
4025
  this._element
4029
- ]).toUpperCase()];
4026
+ ]);
4027
+ const attachment = AttachmentMap[placement.toUpperCase()];
4030
4028
  return createPopper(this._element, tip, this._getPopperConfig(attachment));
4031
4029
  }
4032
4030
  _getOffset() {
@@ -4677,9 +4675,7 @@ var init_bootstrap_esm = __esmMin((() => {
4677
4675
  this._hasMouseInteraction = isInteracting;
4678
4676
  break;
4679
4677
  case "focusin":
4680
- case "focusout":
4681
- this._hasKeyboardInteraction = isInteracting;
4682
- break;
4678
+ case "focusout": this._hasKeyboardInteraction = isInteracting;
4683
4679
  }
4684
4680
  if (isInteracting) {
4685
4681
  this._clearTimeout();