@hmharness/cli 0.23.25 → 0.23.27

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.
@@ -51,9 +51,9 @@ const PACKAGES = ['cli', 'web', 'agent', 'kernel', 'sandbox', 'evolution',
51
51
 
52
52
  // Known-good pin set (offline fallback when the registry is unreachable).
53
53
  const FALLBACK_PINS = {
54
- cli: '0.23.25', web: '0.23.25', agent: '0.23.25', kernel: '0.23.25',
55
- sandbox: '0.23.25', evolution: '0.23.25', 'domain-ops': '0.23.25',
56
- evaluation: '0.23.25', observability: '0.23.25', 'domain-harmony': '0.23.25',
54
+ cli: '0.23.27', web: '0.23.27', agent: '0.23.27', kernel: '0.23.27',
55
+ sandbox: '0.23.27', evolution: '0.23.27', 'domain-ops': '0.23.27',
56
+ evaluation: '0.23.27', observability: '0.23.27', 'domain-harmony': '0.23.27',
57
57
  };
58
58
 
59
59
  // ---------- helpers ---------------------------------------------------------
@@ -68,6 +68,33 @@ function portOwnerPid(port) {
68
68
  catch { /* netstat unavailable - give up quietly */ }
69
69
  return 0;
70
70
  }
71
+ /** Is the pid a WEB daemon of ours (`main.js web --port=`)? Port eviction may
72
+ * ONLY target self-family processes: other hmh surfaces (extension serve,
73
+ * mcp-serve, dev-tree servers) legitimately occupy adjacent ports, and the
74
+ * old blind taskkill kept murdering them on every version-aware restart
75
+ * (the "并行活动又抢了端口" port war). */
76
+ function isSelfWebDaemon(pid) {
77
+ if (!pid || process.platform !== 'win32')
78
+ return process.platform !== 'win32';
79
+ try {
80
+ const out = execSync(`powershell -NoProfile -Command "(Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}').CommandLine"`, { encoding: 'utf8', timeout: 8000 });
81
+ const cmd = out.trim();
82
+ return cmd.includes(' web ') || /main\.js(\.ts)?\s+web\b/.test(cmd) || /\bweb\b\s*--port=/.test(cmd);
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ }
88
+ /** Describe a foreign occupier for the warning line (best effort). */
89
+ function foreignOwnerDesc(pid) {
90
+ try {
91
+ const out = execSync(`powershell -NoProfile -Command "(Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}').CommandLine"`, { encoding: 'utf8', timeout: 8000 });
92
+ return out.trim().slice(0, 120);
93
+ }
94
+ catch {
95
+ return 'pid ' + pid;
96
+ }
97
+ }
71
98
  /** Wait (bounded) until nothing answers on the port — used after evicting a
72
99
  * stale listener so the respawn does not die on EADDRINUSE. */
73
100
  export async function waitPortFree(port, maxMs = 4000) {
@@ -97,14 +124,21 @@ export function stopWebDaemon(port = DEFAULT_WEB_PORT) {
97
124
  unlinkSync(join(homeDir(), 'web.pid'));
98
125
  }
99
126
  catch { /* absent */ }
100
- // stale pid file but the port is still held (orphaned/old daemon): evict
127
+ // stale pid file but the port is still held: evict ONLY if the holder is
128
+ // one of OUR web daemons - a foreign hmh surface (extension serve,
129
+ // dev-tree server) owns its port legitimately and must not be murdered
101
130
  const owner = portOwnerPid(port);
102
131
  if (owner && owner !== pid) {
103
- try {
104
- spawn('taskkill', ['/PID', String(owner), '/T', '/F'], { windowsHide: true });
105
- killed = true;
132
+ if (isSelfWebDaemon(owner)) {
133
+ try {
134
+ spawn('taskkill', ['/PID', String(owner), '/T', '/F'], { windowsHide: true });
135
+ killed = true;
136
+ }
137
+ catch { /* best effort */ }
138
+ }
139
+ else {
140
+ console.error(`[web] port ${port} is held by a NON-web process - not evicting: ${foreignOwnerDesc(owner)}`);
106
141
  }
107
- catch { /* best effort */ }
108
142
  }
109
143
  return killed;
110
144
  }
@@ -185,6 +219,14 @@ export async function ensureWebDaemon(port = DEFAULT_WEB_PORT, entry = process.a
185
219
  // for the port to free so the respawn cannot die on EADDRINUSE
186
220
  stopWebDaemon(port);
187
221
  await waitPortFree(port);
222
+ // a foreign surface still holding the port (stop refused to murder it):
223
+ // do NOT crash-loop a doomed respawn - say so and stay down
224
+ const holder = portOwnerPid(port);
225
+ if (holder && !isSelfWebDaemon(holder)) {
226
+ console.error(`[web] port ${port} is held by another process - not evicting: ${foreignOwnerDesc(holder)}`);
227
+ console.error(`[web] stop it, or start the web UI elsewhere: hmh web --port=<port>`);
228
+ return false;
229
+ }
188
230
  }
189
231
  spawnWebDaemon(port, entry);
190
232
  for (let i = 0; i < 12; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.23.25",
3
+ "version": "0.23.27",
4
4
  "description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -45,20 +45,20 @@
45
45
  "build": "tsc -p tsconfig.build.json"
46
46
  },
47
47
  "dependencies": {
48
- "@hmharness/agent": "0.23.25",
49
- "@hmharness/browser": "0.23.25",
50
- "@hmharness/cognitive": "0.23.25",
51
- "@hmharness/domain-harmony": "0.23.25",
52
- "@hmharness/domain-ops": "0.23.25",
53
- "@hmharness/environments": "0.23.25",
54
- "@hmharness/evaluation": "0.23.25",
55
- "@hmharness/evolution": "0.23.25",
56
- "@hmharness/extension": "0.23.25",
57
- "@hmharness/kernel": "0.23.25",
58
- "@hmharness/observability": "0.23.25",
59
- "@hmharness/sandbox": "0.23.25",
60
- "@hmharness/web": "0.23.25",
48
+ "@hmharness/agent": "0.23.27",
49
+ "@hmharness/browser": "0.23.27",
50
+ "@hmharness/cognitive": "0.23.27",
51
+ "@hmharness/domain-harmony": "0.23.27",
52
+ "@hmharness/domain-ops": "0.23.27",
53
+ "@hmharness/environments": "0.23.27",
54
+ "@hmharness/evaluation": "0.23.27",
55
+ "@hmharness/evolution": "0.23.27",
56
+ "@hmharness/extension": "0.23.27",
57
+ "@hmharness/kernel": "0.23.27",
58
+ "@hmharness/observability": "0.23.27",
59
+ "@hmharness/sandbox": "0.23.27",
60
+ "@hmharness/web": "0.23.27",
61
61
  "qrcode": "^1.5.4",
62
- "@hmharness/lsp": "0.23.25"
62
+ "@hmharness/lsp": "0.23.27"
63
63
  }
64
64
  }
@@ -1,5 +1,15 @@
1
1
  {
2
2
  "notes": [
3
+ {
4
+ "v": "0.23.27",
5
+ "date": "2026-10-06",
6
+ "note": "Cognitive OS 升级包 P0+P1 九件上线:认知账本(认知事件只增记录+谱系链)、Prediction OS 三预测族统一、认知归因(观察 lift)、学习目标注册表(六要素契约)、统一评测 12 指标、Capability Broker(拒认默认+RLM 零继承)、Transfer 5×5 矩阵(重叠≠证据)、Evidence Ledger 统一谱系、版本一致性机检接入发布门禁"
7
+ },
8
+ {
9
+ "v": "0.23.26",
10
+ "date": "2026-10-06",
11
+ "note": "会话独立运行(对标 dsh 3080):多会话真并行——每会话独立子进程/队列/审批/中断,输入区跟随当前会话;端口收复只驱逐自家族守护(extension serve 等不再被误杀);侧栏各会话显示运行状态点"
12
+ },
3
13
  {
4
14
  "v": "0.23.25",
5
15
  "date": "2026-10-06",