@bakapiano/ccsm 0.17.2 → 0.17.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakapiano/ccsm",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "description": "Claude Code Session Manager — Windows web UI to manage many concurrent claude sessions: live list, snapshot/restore, focus existing window, new session in an isolated workspace with repo clones",
5
5
  "license": "MIT",
6
6
  "main": "server.js",
@@ -537,6 +537,12 @@ httpServer.listen(HELPER_PORT, '127.0.0.1', () => {
537
537
  setPhase('installing');
538
538
  pushLine('info', `Running: npm i -g @bakapiano/ccsm@${target}${installPrefix ? ` --prefix=${installPrefix}` : ''}`);
539
539
 
540
+ // Extra settle: gracefulShutdown only waits for the server pid, but
541
+ // node-pty grandchildren (winpty-agent / conpty) need a beat longer
542
+ // to release file locks on node_modules/node-pty/build/Release/*.node.
543
+ // Without this beat, npm hits EBUSY/EPERM renaming the package dir.
544
+ await sleep(2000);
545
+
540
546
  const isWin = process.platform === 'win32';
541
547
  const arg = `@bakapiano/ccsm@${target}`;
542
548
  const npmArgs = ['i', '-g'];
@@ -555,26 +561,58 @@ httpServer.listen(HELPER_PORT, '127.0.0.1', () => {
555
561
  exeArgs = npmArgs;
556
562
  }
557
563
 
558
- const npmExit = await new Promise((resolve) => {
559
- const child = spawn(exe, exeArgs, { windowsHide: true });
560
- const pipe = (stream, label) => {
561
- let leftover = '';
562
- stream.on('data', (chunk) => {
563
- const text = leftover + chunk.toString();
564
- const lines = text.split(/\r?\n/);
565
- leftover = lines.pop() || '';
566
- for (const line of lines) if (line) pushLine(label, line);
564
+ // Postinstall opens the hosted setup guide by default — fine on a
565
+ // first npm i, but during an in-app upgrade the user is already in
566
+ // the updater UI and a fresh tab to /setup/ is just noise.
567
+ const npmEnv = { ...process.env, CCSM_NO_AUTOLAUNCH: '1' };
568
+
569
+ const LOCK_PATTERN = /\b(EBUSY|EPERM|ENOTEMPTY|EEXIST|ELOCKED|locked|in use|cannot rename|operation not permitted)\b/i;
570
+
571
+ async function runNpmOnce() {
572
+ let sawLockError = false;
573
+ const exit = await new Promise((resolve) => {
574
+ const child = spawn(exe, exeArgs, { windowsHide: true, env: npmEnv });
575
+ const pipe = (stream, label) => {
576
+ let leftover = '';
577
+ stream.on('data', (chunk) => {
578
+ const text = leftover + chunk.toString();
579
+ const lines = text.split(/\r?\n/);
580
+ leftover = lines.pop() || '';
581
+ for (const line of lines) {
582
+ if (!line) continue;
583
+ if (LOCK_PATTERN.test(line)) sawLockError = true;
584
+ pushLine(label, line);
585
+ }
586
+ });
587
+ stream.on('end', () => { if (leftover) pushLine(label, leftover); });
588
+ };
589
+ pipe(child.stdout, 'stdout');
590
+ pipe(child.stderr, 'stderr');
591
+ child.on('error', (e) => {
592
+ pushLine('stderr', `spawn error: ${e.message}`);
593
+ resolve(-1);
567
594
  });
568
- stream.on('end', () => { if (leftover) pushLine(label, leftover); });
569
- };
570
- pipe(child.stdout, 'stdout');
571
- pipe(child.stderr, 'stderr');
572
- child.on('error', (e) => {
573
- pushLine('stderr', `spawn error: ${e.message}`);
574
- resolve(-1);
595
+ child.on('exit', (code) => resolve(code));
575
596
  });
576
- child.on('exit', (code) => resolve(code));
577
- });
597
+ return { exit, sawLockError };
598
+ }
599
+
600
+ let npmExit = -1;
601
+ // Up to 3 attempts: original + 2 retries with growing backoff. Only
602
+ // retry when the failure looks like a file-lock issue from straggling
603
+ // child handles, never on a clean nonzero exit (auth, 404, etc).
604
+ const backoffs = [3000, 6000];
605
+ let attempt = 0;
606
+ while (true) {
607
+ attempt++;
608
+ const { exit, sawLockError } = await runNpmOnce();
609
+ npmExit = exit;
610
+ if (exit === 0) break;
611
+ if (!sawLockError || attempt > backoffs.length) break;
612
+ const wait = backoffs[attempt - 1];
613
+ pushLine('info', `npm failed with what looks like a file lock; retrying in ${Math.round(wait/1000)}s (attempt ${attempt + 1})…`);
614
+ await sleep(wait);
615
+ }
578
616
 
579
617
  if (npmExit !== 0) {
580
618
  errorMsg = `npm exited with code ${npmExit}`;