@tina_summer/codepocket 2.5.6 → 2.6.0

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/bin/codepocket.js CHANGED
@@ -254,13 +254,42 @@ function checkRunning() {
254
254
  if (args[0] === 'stop') {
255
255
  const pid = checkRunning()
256
256
  if (!pid) {
257
- console.log('[codepocket] Not running')
257
+ // Even with no recorded daemon PID, clean up orphaned hub/runner from prior runs
258
+ const orphans = killOrphans()
259
+ console.log(orphans
260
+ ? `[codepocket] 清理残留进程: ${orphans}`
261
+ : '[codepocket] Not running')
258
262
  process.exit(0)
259
263
  }
260
- try { process.kill(pid, process.platform === 'win32' ? 'SIGKILL' : 'SIGTERM') } catch {}
264
+ const sig = process.platform === 'win32' ? 'SIGKILL' : 'SIGTERM'
265
+ // Kill the whole process group (daemon is a group leader via detached:true,
266
+ // so -pid kills daemon + hub + runner together)
267
+ try { process.kill(-pid, sig) } catch {}
268
+ // Fallback: kill just the daemon if group kill failed
269
+ try { process.kill(pid, sig) } catch {}
261
270
  try { fs.unlinkSync(PID_FILE) } catch {}
262
- console.log(`[codepocket] Stopped (PID ${pid})`)
263
- process.exit(0)
271
+ // Wait briefly, then sweep up any orphans that escaped the group kill
272
+ setTimeout(() => {
273
+ const orphans = killOrphans()
274
+ const extra = orphans ? `,清理残留: ${orphans}` : ''
275
+ console.log(`[codepocket] Stopped (PID ${pid})${extra}`)
276
+ process.exit(0)
277
+ }, 300)
278
+ }
279
+
280
+ // Kill orphaned hub/runner processes by binary name (cross-platform).
281
+ // The hub binary (cpkt-hub) also runs the runner/sync modes, so matching the
282
+ // binary name catches every mode it was spawned in.
283
+ function killOrphans() {
284
+ try {
285
+ if (process.platform === 'win32') {
286
+ execSync('taskkill /F /IM cpkt-hub.exe /T', { stdio: 'ignore' })
287
+ } else {
288
+ execSync('pkill -f cpkt-hub', { stdio: 'ignore' })
289
+ }
290
+ return 'hub'
291
+ } catch {}
292
+ return ''
264
293
  }
265
294
 
266
295
  // 'logs' subcommand
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tina_summer/codepocket",
3
- "version": "2.5.6",
3
+ "version": "2.6.0",
4
4
  "description": "CodePocket — 基于ClaudeCode的微信小程序工作台",
5
5
  "bin": {
6
6
  "codepocket": "bin/codepocket.js",
@@ -8,8 +8,7 @@
8
8
  },
9
9
  "files": [
10
10
  "bin",
11
- "src",
12
- "vendor"
11
+ "src"
13
12
  ],
14
13
  "scripts": {
15
14
  "start": "node bin/codepocket.js"
@@ -20,10 +19,10 @@
20
19
  "ws": "^8.18.0"
21
20
  },
22
21
  "optionalDependencies": {
23
- "@tina_summer/codepocket-darwin-arm64": "2.5.6",
24
- "@tina_summer/codepocket-darwin-x64": "2.5.6",
25
- "@tina_summer/codepocket-linux-x64": "2.5.6",
26
- "@tina_summer/codepocket-win32-x64": "2.5.6"
22
+ "@tina_summer/codepocket-darwin-arm64": "2.6.0",
23
+ "@tina_summer/codepocket-darwin-x64": "2.6.0",
24
+ "@tina_summer/codepocket-linux-x64": "2.6.0",
25
+ "@tina_summer/codepocket-win32-x64": "2.6.0"
27
26
  },
28
27
  "engines": {
29
28
  "node": ">=18"
package/vendor/cpkt-hub DELETED
@@ -1 +0,0 @@
1
- Not Found
@@ -1 +0,0 @@
1
- Not Found
@@ -1 +0,0 @@
1
- Not Found