@muggleai/works 5.27.0-staging.231 → 5.27.0-staging.233

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 (37) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/{chunk-A3YLVNL7.js → chunk-WRYPWI33.js} +264 -101
  3. package/dist/{chunk-F5KU5ZP2.js → chunk-YNTLACS2.js} +15 -8
  4. package/dist/cli.js +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  7. package/dist/plugin/.codex-mcp.json +1 -1
  8. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  9. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  10. package/dist/plugin/.mcp.json +1 -1
  11. package/dist/plugin/scripts/guardrails.mjs +82 -8
  12. package/dist/plugin/skills/_shared/verify-or-rollback-gate.md +4 -3
  13. package/dist/plugin/skills/do/cycle-size.md +17 -3
  14. package/dist/plugin/skills/do/e2e-acceptance.md +1 -1
  15. package/dist/plugin/skills/do/impact-analysis.md +2 -0
  16. package/dist/plugin/skills/do/open-prs/update.md +2 -2
  17. package/dist/plugin/skills/do/resolve-conflicts.md +12 -3
  18. package/dist/plugin/skills/muggle-test-prepare/SKILL.md +2 -2
  19. package/dist/plugin/skills/muggle-test-prepare/steps/claim-stack.md +8 -4
  20. package/dist/release-manifest.json +3 -3
  21. package/dist/src-EEKJ2ZOK.js +1 -0
  22. package/package.json +1 -1
  23. package/plugin/.claude-plugin/plugin.json +1 -1
  24. package/plugin/.codex-mcp.json +1 -1
  25. package/plugin/.codex-plugin/plugin.json +1 -1
  26. package/plugin/.cursor-plugin/plugin.json +1 -1
  27. package/plugin/.mcp.json +1 -1
  28. package/plugin/scripts/guardrails.mjs +82 -8
  29. package/plugin/skills/_shared/verify-or-rollback-gate.md +4 -3
  30. package/plugin/skills/do/cycle-size.md +17 -3
  31. package/plugin/skills/do/e2e-acceptance.md +1 -1
  32. package/plugin/skills/do/impact-analysis.md +2 -0
  33. package/plugin/skills/do/open-prs/update.md +2 -2
  34. package/plugin/skills/do/resolve-conflicts.md +12 -3
  35. package/plugin/skills/muggle-test-prepare/SKILL.md +2 -2
  36. package/plugin/skills/muggle-test-prepare/steps/claim-stack.md +8 -4
  37. package/dist/src-H4OOQVIK.js +0 -1
@@ -9,7 +9,7 @@
9
9
  "name": "muggleai",
10
10
  "source": "./plugin",
11
11
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
12
- "version": "5.27.0-staging.231"
12
+ "version": "5.27.0-staging.233"
13
13
  }
14
14
  ]
15
15
  }
@@ -99,14 +99,18 @@ __export(src_exports, {
99
99
  createApiKeyWithToken: () => createApiKeyWithToken,
100
100
  createChildLogger: () => createChildLogger,
101
101
  decideStackClaim: () => decideStackClaim,
102
+ decideStackReap: () => decideStackReap,
102
103
  decideStackRelease: () => decideStackRelease,
103
- decideStackRenewal: () => decideStackRenewal,
104
+ decideStackRunEnd: () => decideStackRunEnd,
105
+ decideStackRunStart: () => decideStackRunStart,
104
106
  deleteApiKeyData: () => deleteApiKeyData,
105
107
  deleteCredentials: () => deleteCredentials,
106
108
  describeLlmSourceStatus: () => describeLlmSourceStatus,
107
109
  describeStackMismatch: () => describeStackMismatch,
108
110
  e2e: () => e2e_exports2,
109
111
  evaluateCheckoutFreshness: () => evaluateCheckoutFreshness,
112
+ findVacatedNeeds: () => findVacatedNeeds,
113
+ finishStackRun: () => finishStackRun,
110
114
  formatPreferencesOneLiner: () => formatPreferencesOneLiner,
111
115
  getActiveElectronAppReleaseStream: () => getActiveElectronAppReleaseStream,
112
116
  getActiveRuntimeTarget: () => getActiveRuntimeTarget,
@@ -161,6 +165,7 @@ __export(src_exports, {
161
165
  readPreferencesMetadata: () => readPreferencesMetadata,
162
166
  readRunView: () => readRunView,
163
167
  readServiceStackStatus: () => readServiceStackStatus,
168
+ reapServiceStack: () => reapServiceStack,
164
169
  reconcileProjectPreferences: () => reconcileProjectPreferences,
165
170
  recordOnboardingSkip: () => recordOnboardingSkip,
166
171
  releaseServiceStack: () => releaseServiceStack,
@@ -186,6 +191,8 @@ __export(src_exports, {
186
191
  saveApiKeyData: () => saveApiKeyData,
187
192
  saveCredentials: () => saveCredentials,
188
193
  startDeviceCodeFlow: () => startDeviceCodeFlow,
194
+ startStackRun: () => startStackRun,
195
+ stopVacatedServices: () => stopVacatedServices,
189
196
  toDisplayRef: () => toDisplayRef,
190
197
  toolRequiresAuth: () => toolRequiresAuth,
191
198
  validatePreference: () => validatePreference,
@@ -765,9 +772,9 @@ function resetLogger() {
765
772
  // packages/mcps/src/shared/checksum.ts
766
773
  var logger = getLogger();
767
774
  function getPlatformKey() {
768
- const os8 = platform();
775
+ const os9 = platform();
769
776
  const arch2 = process.arch;
770
- switch (os8) {
777
+ switch (os9) {
771
778
  case "darwin":
772
779
  return arch2 === "arm64" ? "darwin-arm64" : "darwin-x64";
773
780
  case "win32":
@@ -775,7 +782,7 @@ function getPlatformKey() {
775
782
  case "linux":
776
783
  return "linux-x64";
777
784
  default:
778
- throw new Error(`Unsupported platform: ${os8}`);
785
+ throw new Error(`Unsupported platform: ${os9}`);
779
786
  }
780
787
  }
781
788
  async function calculateFileChecksum(filePath) {
@@ -3455,8 +3462,8 @@ async function readLocalExecutionLockState() {
3455
3462
  // packages/mcps/src/mcp/local/services/spawn-failure-message.ts
3456
3463
  function describeElectronSpawnFailure(params) {
3457
3464
  const base = `Failed to start electron-app: ${params.error.message}`;
3458
- const platform8 = params.platform ?? process.platform;
3459
- const blockedByAppControl = platform8 === "win32" && (params.error.code === "UNKNOWN" || params.error.code === "EPERM");
3465
+ const platform9 = params.platform ?? process.platform;
3466
+ const blockedByAppControl = platform9 === "win32" && (params.error.code === "UNKNOWN" || params.error.code === "EPERM");
3460
3467
  if (!blockedByAppControl) {
3461
3468
  return base;
3462
3469
  }
@@ -5172,8 +5179,13 @@ var StackMismatchKind = /* @__PURE__ */ ((StackMismatchKind2) => {
5172
5179
  // packages/mcps/src/shared/service-stack/service-stack-constants.ts
5173
5180
  var STACK_LEDGER_DIR_NAME = "service-stack";
5174
5181
  var PREPARE_TRACKING_DIR_SEGMENTS = ["prepare", "running"];
5175
- var LEASE_TTL_MS = 20 * 6e4;
5182
+ var STARTUP_WINDOW_MS = 15 * 6e4;
5183
+ var IDLE_RELEASE_MS = 2 * 6e4;
5184
+ var MAX_RUN_MS = 2 * 60 * 6e4;
5176
5185
  var DEAD_HOLDER_GRACE_MS = 6e4;
5186
+ var IDLE_REAP_DELAY_MS = IDLE_RELEASE_MS + 5e3;
5187
+ var SERVICE_STOP_COMMAND_TIMEOUT_MS = 15e3;
5188
+ var SERVICE_STOPS_ENV = "MUGGLE_STACK_SERVICE_STOPS";
5177
5189
  var CLAIM_GRACE_MS = 3e4;
5178
5190
  var TICKET_ABANDON_MS = 10 * 6e4;
5179
5191
  var SUGGESTED_RETRY_AFTER_MS = 3e4;
@@ -5387,6 +5399,23 @@ function runListenerTool(command, args) {
5387
5399
  );
5388
5400
  });
5389
5401
  }
5402
+ async function stopProcessTree(pid) {
5403
+ if (os4.platform() === "win32") {
5404
+ await runStopCommand("taskkill", ["/PID", String(pid), "/T", "/F"]);
5405
+ return;
5406
+ }
5407
+ for (const target of [-pid, pid]) {
5408
+ try {
5409
+ process.kill(target, "SIGTERM");
5410
+ } catch {
5411
+ }
5412
+ }
5413
+ }
5414
+ function runStopCommand(command, args) {
5415
+ return new Promise((resolve7) => {
5416
+ execFile(command, args, { timeout: SERVICE_STOP_COMMAND_TIMEOUT_MS, windowsHide: true }, () => resolve7());
5417
+ });
5418
+ }
5390
5419
 
5391
5420
  // packages/mcps/src/shared/service-stack/service-stack-decisions.ts
5392
5421
  var EMPTY_STACK_RECORD = { leases: [], queue: [], portFreedAt: {} };
@@ -5434,14 +5463,7 @@ function decideStackClaim(params) {
5434
5463
  };
5435
5464
  }
5436
5465
  const ownLease = swept.leases.find((lease) => lease.cwd === params.cwd);
5437
- const grantedLease = {
5438
- cwd: params.cwd,
5439
- label: params.label ?? ownLease?.label,
5440
- needs: params.needs,
5441
- grantedAt: ownLease?.grantedAt ?? params.now,
5442
- lastSeenAt: params.now,
5443
- holderPids: ownLease?.holderPids
5444
- };
5466
+ const grantedLease = ownLease === void 0 ? { cwd: params.cwd, label: params.label, needs: params.needs, grantedAt: params.now, lastSeenAt: params.now } : { ...ownLease, label: params.label ?? ownLease.label, needs: params.needs };
5445
5467
  const leases = [...peerLeases, grantedLease];
5446
5468
  return {
5447
5469
  isGranted: true,
@@ -5463,38 +5485,87 @@ function decideStackClaim(params) {
5463
5485
  };
5464
5486
  }
5465
5487
  function decideStackRelease(params) {
5466
- const ownLease = params.record.leases.find((lease) => lease.cwd === params.cwd);
5467
- const isQueued = params.record.queue.some((ticket) => ticket.cwd === params.cwd);
5468
- if (ownLease === void 0 && !isQueued) return null;
5469
- const leases = params.record.leases.filter((lease) => lease.cwd !== params.cwd);
5470
- return {
5488
+ const isReleased = params.record.leases.some((lease) => lease.cwd === params.cwd) || params.record.queue.some((ticket) => ticket.cwd === params.cwd);
5489
+ const swept = sweepStackRecord({ record: params.record, now: params.now, isAlive: params.isAlive });
5490
+ if (!isReleased) return { next: hasSweepDropped({ record: params.record, swept }) ? swept : null, isReleased: false };
5491
+ const ownLease = swept.leases.find((lease) => lease.cwd === params.cwd);
5492
+ const leases = swept.leases.filter((lease) => lease.cwd !== params.cwd);
5493
+ const next = {
5471
5494
  leases,
5472
- queue: params.record.queue.filter((ticket) => ticket.cwd !== params.cwd),
5495
+ queue: swept.queue.filter((ticket) => ticket.cwd !== params.cwd),
5473
5496
  portFreedAt: markFreedPorts({
5474
- portFreedAt: params.record.portFreedAt,
5497
+ portFreedAt: swept.portFreedAt,
5475
5498
  releasedNeeds: ownLease?.needs ?? [],
5476
5499
  remainingLeases: leases,
5477
5500
  now: params.now
5478
5501
  })
5479
5502
  };
5503
+ return { next, isReleased: true };
5504
+ }
5505
+ function decideStackReap(params) {
5506
+ const swept = sweepStackRecord(params);
5507
+ return hasSweepDropped({ record: params.record, swept }) ? swept : null;
5480
5508
  }
5481
- function decideStackRenewal(params) {
5509
+ function decideStackRunStart(params) {
5482
5510
  const swept = sweepStackRecord({ record: params.record, now: params.now, isAlive: params.isAlive });
5483
- if (!swept.leases.some((lease) => lease.cwd === params.cwd)) return null;
5484
- const renew = (lease) => {
5511
+ if (!swept.leases.some((lease) => lease.cwd === params.cwd)) return decideStackReap(params);
5512
+ const start = (lease) => {
5485
5513
  const liveHolders = (lease.holderPids ?? []).filter((pid) => params.isAlive(pid));
5486
- const isNewHolder = params.holderPid !== void 0 && !liveHolders.includes(params.holderPid);
5487
- const holderPids = isNewHolder ? [...liveHolders, params.holderPid] : liveHolders;
5488
- return { ...lease, lastSeenAt: params.now, holderPids: holderPids.length > 0 ? holderPids : void 0 };
5514
+ const holderPids = liveHolders.includes(params.holderPid) ? liveHolders : [...liveHolders, params.holderPid];
5515
+ const run = { runId: params.runId, holderPid: params.holderPid, startedAt: params.now };
5516
+ return {
5517
+ ...lease,
5518
+ lastSeenAt: params.now,
5519
+ holderPids,
5520
+ activeRuns: [...liveRuns({ lease, now: params.now, isAlive: params.isAlive }), run]
5521
+ };
5522
+ };
5523
+ return { ...swept, leases: swept.leases.map((lease) => lease.cwd === params.cwd ? start(lease) : lease) };
5524
+ }
5525
+ function decideStackRunEnd(params) {
5526
+ const swept = sweepStackRecord({ record: params.record, now: params.now, isAlive: params.isAlive });
5527
+ if (!swept.leases.some((lease) => lease.cwd === params.cwd)) return decideStackReap(params);
5528
+ const finish = (lease) => {
5529
+ const activeRuns = liveRuns({ lease, now: params.now, isAlive: params.isAlive }).filter(
5530
+ (run) => run.runId !== params.runId
5531
+ );
5532
+ return {
5533
+ ...lease,
5534
+ lastSeenAt: params.now,
5535
+ lastRunEndedAt: params.now,
5536
+ activeRuns: activeRuns.length > 0 ? activeRuns : void 0
5537
+ };
5489
5538
  };
5490
- return { ...swept, leases: swept.leases.map((lease) => lease.cwd === params.cwd ? renew(lease) : lease) };
5539
+ return { ...swept, leases: swept.leases.map((lease) => lease.cwd === params.cwd ? finish(lease) : lease) };
5540
+ }
5541
+ function findVacatedNeeds(params) {
5542
+ const keptNeeds = params.after.leases.flatMap((lease) => lease.needs);
5543
+ const vacated = [];
5544
+ for (const need of params.before.leases.flatMap((lease) => lease.needs)) {
5545
+ const isKept = keptNeeds.some((kept) => isSameNeed(kept, need));
5546
+ const isListed = vacated.some((listed) => isSameNeed(listed, need));
5547
+ if (!isKept && !isListed) vacated.push(need);
5548
+ }
5549
+ return vacated;
5491
5550
  }
5492
5551
  function hasLeaseEnded(params) {
5493
- const idleMs = params.now - params.lease.lastSeenAt;
5494
- if (idleMs > LEASE_TTL_MS) return true;
5552
+ if (liveRuns(params).length > 0) return false;
5495
5553
  const holderPids = params.lease.holderPids ?? [];
5496
5554
  const isHolderGone = holderPids.length > 0 && !holderPids.some((pid) => params.isAlive(pid));
5497
- return isHolderGone && idleMs > DEAD_HOLDER_GRACE_MS;
5555
+ if (isHolderGone && params.now - params.lease.lastSeenAt > DEAD_HOLDER_GRACE_MS) return true;
5556
+ const lastRunEndedAt = params.lease.lastRunEndedAt;
5557
+ return lastRunEndedAt === void 0 ? params.now - params.lease.lastSeenAt > STARTUP_WINDOW_MS : params.now - lastRunEndedAt > IDLE_RELEASE_MS;
5558
+ }
5559
+ function isSameNeed(left, right) {
5560
+ return left.port === right.port && left.runDir === right.runDir && left.headSha === right.headSha;
5561
+ }
5562
+ function liveRuns(params) {
5563
+ return (params.lease.activeRuns ?? []).filter(
5564
+ (run) => params.isAlive(run.holderPid) && params.now - run.startedAt <= MAX_RUN_MS
5565
+ );
5566
+ }
5567
+ function hasSweepDropped(params) {
5568
+ return params.swept.leases.length !== params.record.leases.length || params.swept.queue.length !== params.record.queue.length;
5498
5569
  }
5499
5570
  function leaseBlockersFor(params) {
5500
5571
  return params.lease.needs.filter((held) => params.needs.some((wanted) => needsConflict(held, wanted))).map((held) => ({
@@ -5551,6 +5622,34 @@ function markFreedPorts(params) {
5551
5622
  return freed;
5552
5623
  }
5553
5624
 
5625
+ // packages/mcps/src/shared/service-stack/service-stopper.ts
5626
+ async function stopVacatedServices(params) {
5627
+ const ports = [...new Set(params.vacatedNeeds.map((need) => need.port))];
5628
+ const stopped = await Promise.all(ports.map((port) => stopPortService({ ...params, port })));
5629
+ return stopped.filter((service) => service !== null);
5630
+ }
5631
+ async function stopPortService(params) {
5632
+ const reading = await params.readListener(params.port);
5633
+ const listener = reading.listener;
5634
+ if (listener === null) return null;
5635
+ const tracked = params.services.find(
5636
+ (service) => service.port === params.port && (service.pid === listener.pid || listener.ancestorPids.includes(service.pid))
5637
+ ) ?? null;
5638
+ if (tracked?.isExternal) return null;
5639
+ if (tracked !== null && params.remainingLeases.some((lease) => leaseNeedsService({ lease, service: tracked }))) {
5640
+ return null;
5641
+ }
5642
+ const rootPid = tracked !== null && params.vacatedNeeds.some((need) => need.runDir === tracked.dir && need.headSha === tracked.headSha) ? tracked.pid : listener.pid;
5643
+ if (rootPid === process.pid || rootPid === process.ppid) return null;
5644
+ await params.stopProcessTree(rootPid);
5645
+ return { port: params.port, pid: rootPid, name: tracked?.name ?? null, commandLine: listener.commandLine };
5646
+ }
5647
+ function leaseNeedsService(params) {
5648
+ return params.lease.needs.some(
5649
+ (need) => need.port === params.service.port && need.runDir === params.service.dir && need.headSha === params.service.headSha
5650
+ );
5651
+ }
5652
+
5554
5653
  // packages/mcps/src/shared/service-stack/service-stack.ts
5555
5654
  async function claimServiceStack(params) {
5556
5655
  const runGit = params.runGit ?? runGitCommand;
@@ -5598,35 +5697,43 @@ async function checkServiceStack(params) {
5598
5697
  mismatches
5599
5698
  };
5600
5699
  }
5601
- if (params.shouldRenew) {
5602
- await updateGenerationStore({
5603
- directory: ledgerDir(),
5604
- emptyRecord: EMPTY_STACK_RECORD,
5605
- decide: (current) => ({
5606
- next: decideStackRenewal({
5607
- record: current.record,
5608
- cwd,
5609
- now: Date.now(),
5610
- isAlive: isProcessAlive,
5611
- holderPid: params.holderPid
5612
- }),
5613
- result: null
5614
- })
5615
- });
5616
- }
5617
5700
  return { ...base, verdict: "VALID" /* Valid */, reason: "every claimed port serves the claimed code" };
5618
5701
  }
5702
+ async function startStackRun(params) {
5703
+ const cwd = await resolveCheckoutRoot({ cwd: params.cwd, runGit: params.runGit ?? runGitCommand });
5704
+ await updateLedger((record) => ({
5705
+ next: decideStackRunStart({
5706
+ record,
5707
+ cwd,
5708
+ runId: params.runId,
5709
+ holderPid: params.holderPid,
5710
+ now: Date.now(),
5711
+ isAlive: isProcessAlive
5712
+ }),
5713
+ result: null
5714
+ }));
5715
+ }
5716
+ async function finishStackRun(params) {
5717
+ const cwd = await resolveCheckoutRoot({ cwd: params.cwd, runGit: params.runGit ?? runGitCommand });
5718
+ await updateLedger((record) => ({
5719
+ next: decideStackRunEnd({ record, cwd, runId: params.runId, now: Date.now(), isAlive: isProcessAlive }),
5720
+ result: null
5721
+ }));
5722
+ }
5723
+ async function reapServiceStack() {
5724
+ const update = await updateLedger((record) => ({
5725
+ next: decideStackReap({ record, now: Date.now(), isAlive: isProcessAlive }),
5726
+ result: null
5727
+ }));
5728
+ return update.stoppedServices;
5729
+ }
5619
5730
  async function releaseServiceStack(params) {
5620
5731
  const cwd = await resolveCheckoutRoot({ cwd: params.cwd, runGit: params.runGit ?? runGitCommand });
5621
- const outcome = await updateGenerationStore({
5622
- directory: ledgerDir(),
5623
- emptyRecord: EMPTY_STACK_RECORD,
5624
- decide: (snapshot) => {
5625
- const next = decideStackRelease({ record: snapshot.record, cwd, now: Date.now() });
5626
- return { next, result: next !== null };
5627
- }
5732
+ const update = await updateLedger((record) => {
5733
+ const decision = decideStackRelease({ record, cwd, now: Date.now(), isAlive: isProcessAlive });
5734
+ return { next: decision.next, result: decision.isReleased };
5628
5735
  });
5629
- return outcome.result;
5736
+ return { isReleased: update.result, stoppedServices: update.stoppedServices };
5630
5737
  }
5631
5738
  async function readServiceStackStatus() {
5632
5739
  const snapshot = await readGenerationStore({ directory: ledgerDir(), emptyRecord: EMPTY_STACK_RECORD });
@@ -5648,36 +5755,64 @@ function portOfUrl(url) {
5648
5755
  }
5649
5756
  }
5650
5757
  async function claimOnce(params) {
5651
- const outcome = await updateGenerationStore({
5652
- directory: ledgerDir(),
5653
- emptyRecord: EMPTY_STACK_RECORD,
5654
- decide: (snapshot) => {
5655
- const decision2 = decideStackClaim({
5656
- record: snapshot.record,
5657
- cwd: params.cwd,
5658
- label: params.label,
5659
- needs: params.needs,
5660
- now: Date.now(),
5661
- isAlive: isProcessAlive
5662
- });
5663
- return { next: decision2.next, result: decision2 };
5664
- }
5758
+ const update = await updateLedger((record) => {
5759
+ const decision2 = decideStackClaim({
5760
+ record,
5761
+ cwd: params.cwd,
5762
+ label: params.label,
5763
+ needs: params.needs,
5764
+ now: Date.now(),
5765
+ isAlive: isProcessAlive
5766
+ });
5767
+ return { next: decision2.next, result: decision2 };
5665
5768
  });
5666
- const decision = outcome.result;
5667
- const isGranted = decision.isGranted && outcome.isCommitted;
5769
+ const decision = update.result;
5770
+ const isGranted = decision.isGranted && update.isCommitted;
5668
5771
  const services = isGranted ? await readTrackedServices() : [];
5669
5772
  return {
5670
5773
  verdict: isGranted ? "GRANTED" /* Granted */ : "BUSY" /* Busy */,
5671
5774
  cwd: params.cwd,
5672
- generation: outcome.generation,
5775
+ generation: update.generation,
5673
5776
  plan: isGranted ? params.needs.map((need) => planPort({ need, services })) : [],
5674
5777
  blockers: decision.blockers,
5675
5778
  sharedWith: isGranted ? decision.sharedWith : [],
5676
5779
  position: isGranted ? null : decision.position ?? 1,
5677
5780
  queueLength: decision.queueLength,
5678
- retryAfterMs: isGranted ? null : decision.retryAfterMs ?? CLAIM_POLL_INTERVAL_MS
5781
+ retryAfterMs: isGranted ? null : decision.retryAfterMs ?? CLAIM_POLL_INTERVAL_MS,
5782
+ stoppedServices: update.stoppedServices
5783
+ };
5784
+ }
5785
+ async function updateLedger(decide) {
5786
+ const outcome = await updateGenerationStore({
5787
+ directory: ledgerDir(),
5788
+ emptyRecord: EMPTY_STACK_RECORD,
5789
+ decide: (snapshot) => {
5790
+ const update = decide(snapshot.record);
5791
+ const vacatedNeeds = update.next === null ? [] : findVacatedNeeds({ before: snapshot.record, after: update.next });
5792
+ return {
5793
+ next: update.next,
5794
+ result: { decided: update.result, vacatedNeeds, remainingLeases: update.next?.leases ?? [] }
5795
+ };
5796
+ }
5797
+ });
5798
+ const stoppedServices = outcome.isCommitted ? await stopServicesFor({ vacatedNeeds: outcome.result.vacatedNeeds, remainingLeases: outcome.result.remainingLeases }) : [];
5799
+ return {
5800
+ isCommitted: outcome.isCommitted,
5801
+ generation: outcome.generation,
5802
+ result: outcome.result.decided,
5803
+ stoppedServices
5679
5804
  };
5680
5805
  }
5806
+ async function stopServicesFor(params) {
5807
+ if (params.vacatedNeeds.length === 0 || process.env[SERVICE_STOPS_ENV] === "off") return [];
5808
+ return await stopVacatedServices({
5809
+ vacatedNeeds: params.vacatedNeeds,
5810
+ remainingLeases: params.remainingLeases,
5811
+ services: await readTrackedServices(),
5812
+ readListener: readPortListener,
5813
+ stopProcessTree
5814
+ });
5815
+ }
5681
5816
  function planPort(params) {
5682
5817
  const current = trackedServiceOnPort({ services: params.services, port: params.need.port });
5683
5818
  const action = current === null ? "start" /* Start */ : servesNeed({ service: current, need: params.need }) ? "keep" /* Keep */ : "restart" /* Restart */;
@@ -5717,7 +5852,8 @@ async function readTrackedServices() {
5717
5852
  port: service.port,
5718
5853
  pid: service.pid,
5719
5854
  headSha: service.headSha ?? null,
5720
- source: normalizePath(parsed.source ?? "")
5855
+ source: normalizePath(parsed.source ?? ""),
5856
+ isExternal: service.external === true
5721
5857
  })
5722
5858
  );
5723
5859
  } catch {
@@ -9410,33 +9546,52 @@ function writeLastHost(cwd, host) {
9410
9546
  function clearLastHost(cwd) {
9411
9547
  clearCwdEntry(LAST_HOST_CACHE, cwd);
9412
9548
  }
9413
-
9414
- // packages/mcps/src/mcp/local/services/run-stack-gate.ts
9415
9549
  var REFUSING_VERDICTS = /* @__PURE__ */ new Set(["PEER_LEASE" /* PeerLease */, "STALE" /* Stale */]);
9550
+ var idleReapTimer = null;
9416
9551
  async function findRunStackRefusal(params) {
9417
9552
  if (!isLoopbackUrl(params.localUrl)) return null;
9418
9553
  const port = portOfUrl(params.localUrl) ?? void 0;
9419
9554
  const report = await checkServiceStack({
9420
9555
  cwd: params.cwd,
9421
9556
  port,
9422
- shouldRenew: true,
9423
- holderPid: process.pid,
9424
9557
  runGit: params.runGit,
9425
9558
  readListener: params.readListener
9426
9559
  });
9427
9560
  return REFUSING_VERDICTS.has(report.verdict) ? report : null;
9428
9561
  }
9562
+ async function runUnderStackLease(params) {
9563
+ if (!isLoopbackUrl(params.localUrl)) return await params.execute();
9564
+ const runId = randomUUID();
9565
+ await startStackRun({ cwd: params.cwd, runId, holderPid: process.pid, runGit: params.runGit });
9566
+ try {
9567
+ return await params.execute();
9568
+ } finally {
9569
+ await finishStackRun({ cwd: params.cwd, runId, runGit: params.runGit }).catch((error) => {
9570
+ getLogger().warn("Could not record the run's end on the service-stack lease", { error: String(error) });
9571
+ });
9572
+ scheduleIdleReap();
9573
+ }
9574
+ }
9429
9575
  async function findStackChangedDuringRun(params) {
9430
9576
  if (!isLoopbackUrl(params.localUrl)) return null;
9431
9577
  const report = await checkServiceStack({
9432
9578
  cwd: params.cwd,
9433
- shouldRenew: true,
9434
- holderPid: process.pid,
9435
9579
  runGit: params.runGit,
9436
9580
  readListener: params.readListener
9437
9581
  });
9438
9582
  return report.verdict === "STALE" /* Stale */ ? report : null;
9439
9583
  }
9584
+ function scheduleIdleReap() {
9585
+ if (process.env[SERVICE_STOPS_ENV] === "off") return;
9586
+ if (idleReapTimer !== null) clearTimeout(idleReapTimer);
9587
+ idleReapTimer = setTimeout(() => {
9588
+ idleReapTimer = null;
9589
+ reapServiceStack().catch((error) => {
9590
+ getLogger().warn("Could not end idle service-stack leases", { error: String(error) });
9591
+ });
9592
+ }, IDLE_REAP_DELAY_MS);
9593
+ idleReapTimer.unref();
9594
+ }
9440
9595
 
9441
9596
  // packages/mcps/src/mcp/local/services/electron-browser-visibility.ts
9442
9597
  function resolveElectronBrowserVisibility(params) {
@@ -9794,16 +9949,20 @@ var executeTestGenerationTool = {
9794
9949
  return { content: formatRunStackRefusal(stackRefusal, input.cwd), isError: true, data: stackRefusal };
9795
9950
  }
9796
9951
  try {
9797
- const generationRun = await executeTestGeneration({
9798
- testCase: input.testCase,
9799
- localUrl: input.localUrl,
9952
+ const generationRun = await runUnderStackLease({
9800
9953
  cwd: input.cwd,
9801
- mutations: input.mutations,
9802
- timeoutMs: input.timeoutMs,
9803
- showUi: browserVisibility.isBrowserShown,
9804
- freshSession: input.freshSession,
9805
- displayResolution: input.displayResolution,
9806
- runSettingsId: input.runSettingsId
9954
+ localUrl: input.localUrl,
9955
+ execute: () => executeTestGeneration({
9956
+ testCase: input.testCase,
9957
+ localUrl: input.localUrl,
9958
+ cwd: input.cwd,
9959
+ mutations: input.mutations,
9960
+ timeoutMs: input.timeoutMs,
9961
+ showUi: browserVisibility.isBrowserShown,
9962
+ freshSession: input.freshSession,
9963
+ displayResolution: input.displayResolution,
9964
+ runSettingsId: input.runSettingsId
9965
+ })
9807
9966
  });
9808
9967
  const content = [
9809
9968
  "## Test Generation " + (generationRun.status === "passed" ? "Successful" : "Failed"),
@@ -9856,17 +10015,21 @@ var executeReplayTool = {
9856
10015
  return { content: formatRunStackRefusal(stackRefusal, input.cwd), isError: true, data: stackRefusal };
9857
10016
  }
9858
10017
  try {
9859
- const replayRun = await executeReplay({
9860
- testScript: input.testScript,
9861
- actionScript: input.actionScript,
9862
- localUrl: input.localUrl,
10018
+ const replayRun = await runUnderStackLease({
9863
10019
  cwd: input.cwd,
9864
- mutations: input.mutations,
9865
- timeoutMs: input.timeoutMs,
9866
- showUi: browserVisibility.isBrowserShown,
9867
- freshSession: input.freshSession,
9868
- pinnedAccount: input.pinnedAccount,
9869
- displayResolution: input.displayResolution
10020
+ localUrl: input.localUrl,
10021
+ execute: () => executeReplay({
10022
+ testScript: input.testScript,
10023
+ actionScript: input.actionScript,
10024
+ localUrl: input.localUrl,
10025
+ cwd: input.cwd,
10026
+ mutations: input.mutations,
10027
+ timeoutMs: input.timeoutMs,
10028
+ showUi: browserVisibility.isBrowserShown,
10029
+ freshSession: input.freshSession,
10030
+ pinnedAccount: input.pinnedAccount,
10031
+ displayResolution: input.displayResolution
10032
+ })
9870
10033
  });
9871
10034
  const content = [
9872
10035
  "## Test Replay " + (replayRun.status === "passed" ? "Successful" : "Failed"),
@@ -10783,4 +10946,4 @@ function applyLlmSourceSelection(selection, dataDirOverride2) {
10783
10946
  return resolveLlmSourceStatus(dataDirOverride2);
10784
10947
  }
10785
10948
 
10786
- export { ACTION_SCRIPT_FILE_NAME, BASE_REMOTE_NAME, BLOCKING_FRESHNESS_VERDICTS, BRANCH_CREATION_REFLOG_PREFIX, BUSY_EXIT_CODE, CheckoutFreshnessVerdict, DEFAULT_LOCAL_LLM_BASE_URL, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, EventName, HTML_VIEW_OFFER_LINE, LLM_CREDENTIALS_FILE_MODE, LLM_CREDENTIALS_FILE_NAME, LLM_SOURCE_HEADER, LLM_SOURCE_OPTIONS, LLM_SOURCE_OWNED_ENV_NAMES, LLM_SOURCE_PROMPT, LLM_SOURCE_SCOPE_NOTE, LlmSource, MASKED_API_KEY_PREFIX, MASKED_API_KEY_VISIBLE_CHARS, MAX_LISTED_INHERITED_COMMITS, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, ServiceName, StackCheckVerdict, StackClaimVerdict, StackMismatchKind, StackPortAction, Surface, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, __export, __require, applyLlmSourceSelection, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppDirName, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildLlmSourcePlan, buildOnboardingPlan, buildToolInputJsonSchema, calculateFileChecksum, checkServiceStack, claimServiceStack, completeOnboarding, createApiKeyWithToken, createChildLogger, decideStackClaim, decideStackRelease, decideStackRenewal, deleteApiKeyData, deleteCredentials, describeLlmSourceStatus, describeStackMismatch, e2e_exports2 as e2e_exports, evaluateCheckoutFreshness, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir, getDataDir2, getDisclosureCopy, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLlmSourceOption, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, hasShownDisclosure, initTelemetry, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, isValidLocalBaseUrl, loadApiKeyData, loadCredentials, local_exports2 as local_exports, markDisclosureShown, markOnboardingCompleted, maskLlmApiKey, mcp_exports, needsConflict, needsOnboarding, openBrowserUrl, parseElectronAppDirName, performLogin, performLogout, pollDeviceCode, portOfUrl, readPreferencesMetadata, readRunView, readServiceStackStatus, reconcileProjectPreferences, recordOnboardingSkip, releaseServiceStack, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveLlmSourceStatus, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, runGitCommand, saveApiKey, saveApiKeyData, saveCredentials, src_exports, startDeviceCodeFlow, toDisplayRef, toolRequiresAuth, track, validatePreference, verifyFileChecksum, writeLlmEnvBlock, writePreferences, writePreferencesWithMetadata, writeRunViewHtml };
10949
+ export { ACTION_SCRIPT_FILE_NAME, BASE_REMOTE_NAME, BLOCKING_FRESHNESS_VERDICTS, BRANCH_CREATION_REFLOG_PREFIX, BUSY_EXIT_CODE, CheckoutFreshnessVerdict, DEFAULT_LOCAL_LLM_BASE_URL, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, EventName, HTML_VIEW_OFFER_LINE, LLM_CREDENTIALS_FILE_MODE, LLM_CREDENTIALS_FILE_NAME, LLM_SOURCE_HEADER, LLM_SOURCE_OPTIONS, LLM_SOURCE_OWNED_ENV_NAMES, LLM_SOURCE_PROMPT, LLM_SOURCE_SCOPE_NOTE, LlmSource, MASKED_API_KEY_PREFIX, MASKED_API_KEY_VISIBLE_CHARS, MAX_LISTED_INHERITED_COMMITS, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, ServiceName, StackCheckVerdict, StackClaimVerdict, StackMismatchKind, StackPortAction, Surface, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, __export, __require, applyLlmSourceSelection, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppDirName, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildLlmSourcePlan, buildOnboardingPlan, buildToolInputJsonSchema, calculateFileChecksum, checkServiceStack, claimServiceStack, completeOnboarding, createApiKeyWithToken, createChildLogger, decideStackClaim, decideStackReap, decideStackRelease, decideStackRunEnd, decideStackRunStart, deleteApiKeyData, deleteCredentials, describeLlmSourceStatus, describeStackMismatch, e2e_exports2 as e2e_exports, evaluateCheckoutFreshness, findVacatedNeeds, finishStackRun, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir, getDataDir2, getDisclosureCopy, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLlmSourceOption, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, hasShownDisclosure, initTelemetry, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, isValidLocalBaseUrl, loadApiKeyData, loadCredentials, local_exports2 as local_exports, markDisclosureShown, markOnboardingCompleted, maskLlmApiKey, mcp_exports, needsConflict, needsOnboarding, openBrowserUrl, parseElectronAppDirName, performLogin, performLogout, pollDeviceCode, portOfUrl, readPreferencesMetadata, readRunView, readServiceStackStatus, reapServiceStack, reconcileProjectPreferences, recordOnboardingSkip, releaseServiceStack, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveLlmSourceStatus, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, runGitCommand, saveApiKey, saveApiKeyData, saveCredentials, src_exports, startDeviceCodeFlow, startStackRun, stopVacatedServices, toDisplayRef, toolRequiresAuth, track, validatePreference, verifyFileChecksum, writeLlmEnvBlock, writePreferences, writePreferencesWithMetadata, writeRunViewHtml };
@@ -1,4 +1,4 @@
1
- import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir2, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, resolveElectronAppExecutablePath, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, getActiveElectronAppReleaseStream, buildToolInputJsonSchema, toolRequiresAuth, getCallerCredentials, parseElectronAppDirName, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, ElectronAppReleaseStream, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, buildLlmSourcePlan, describeLlmSourceStatus, resolveLlmSourceStatus, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, evaluateCheckoutFreshness, runGitCommand, BLOCKING_FRESHNESS_VERDICTS, claimServiceStack, BUSY_EXIT_CODE, checkServiceStack, releaseServiceStack, readServiceStackStatus, resolvePreferences, OnboardingBlanketChoice, PreferenceKey, applyLlmSourceSelection, LlmSource, describeStackMismatch, getDataDir, DEFAULT_LOCAL_LLM_BASE_URL, isValidLocalBaseUrl } from './chunk-A3YLVNL7.js';
1
+ import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir2, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, resolveElectronAppExecutablePath, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, getActiveElectronAppReleaseStream, buildToolInputJsonSchema, toolRequiresAuth, getCallerCredentials, parseElectronAppDirName, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, ElectronAppReleaseStream, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, buildLlmSourcePlan, describeLlmSourceStatus, resolveLlmSourceStatus, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, evaluateCheckoutFreshness, runGitCommand, BLOCKING_FRESHNESS_VERDICTS, claimServiceStack, BUSY_EXIT_CODE, checkServiceStack, releaseServiceStack, readServiceStackStatus, resolvePreferences, OnboardingBlanketChoice, PreferenceKey, applyLlmSourceSelection, LlmSource, describeStackMismatch, getDataDir, DEFAULT_LOCAL_LLM_BASE_URL, isValidLocalBaseUrl } from './chunk-WRYPWI33.js';
2
2
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
4
  import { v4 } from 'uuid';
@@ -1054,7 +1054,7 @@ async function resolveGsScreenshotUrls(report, opts) {
1054
1054
  if (gsUrls.length === 0) {
1055
1055
  return report;
1056
1056
  }
1057
- const mcps = await import('./src-H4OOQVIK.js');
1057
+ const mcps = await import('./src-EEKJ2ZOK.js');
1058
1058
  const credentials = await mcps.getCallerCredentialsAsync();
1059
1059
  if (!credentials.bearerToken && !credentials.apiKey) {
1060
1060
  stderrWrite(
@@ -3877,6 +3877,7 @@ function renderStackClaimSummary(report) {
3877
3877
  lines2.push(`${port.action} ${port.port}: ${port.runDir} @ ${shortSha(port.headSha)}${current}`);
3878
3878
  }
3879
3879
  for (const peer of report.sharedWith) lines2.push(`shared with: ${peer}`);
3880
+ lines2.push(...report.stoppedServices.map(describeStoppedService));
3880
3881
  return lines2.join("\n");
3881
3882
  }
3882
3883
  const lines = [`${report.verdict}: place ${report.position} of ${report.queueLength} in line`];
@@ -3886,9 +3887,13 @@ function renderStackClaimSummary(report) {
3886
3887
  const heldFor = blocker.isQueuedAhead ? "" : ` (for ${seconds(blocker.heldForMs ?? 0)})`;
3887
3888
  lines.push(`port ${blocker.port}: ${who} ${how} ${blocker.needsRunDir} @ ${shortSha(blocker.needsHeadSha)}${heldFor}`);
3888
3889
  }
3890
+ lines.push(...report.stoppedServices.map(describeStoppedService));
3889
3891
  lines.push(`retry in ~${seconds(report.retryAfterMs ?? 0)}; your place is kept while you keep asking`);
3890
3892
  return lines.join("\n");
3891
3893
  }
3894
+ function renderStackReleaseSummary(report) {
3895
+ return [report.isReleased ? "released" : "nothing to release", ...report.stoppedServices.map(describeStoppedService)].join("\n");
3896
+ }
3892
3897
  function renderStackCheckSummary(report) {
3893
3898
  return [`${report.verdict}: ${report.reason}`, ...report.mismatches.map(describeStackMismatch)].join("\n");
3894
3899
  }
@@ -3923,16 +3928,14 @@ async function stackClaimCommand(flags) {
3923
3928
  async function stackCheckCommand(flags) {
3924
3929
  const report = await checkServiceStack({
3925
3930
  cwd: flags.cwd ?? process.cwd(),
3926
- port: flags.port === void 0 ? void 0 : Number(flags.port),
3927
- shouldRenew: true
3931
+ port: flags.port === void 0 ? void 0 : Number(flags.port)
3928
3932
  });
3929
3933
  writeReport({ json: flags.json, report, summary: renderStackCheckSummary(report) });
3930
3934
  if (report.verdict === "STALE" /* Stale */ || report.verdict === "PEER_LEASE" /* PeerLease */) process.exitCode = 1;
3931
3935
  }
3932
3936
  async function stackReleaseCommand(flags) {
3933
- const isReleased = await releaseServiceStack({ cwd: flags.cwd ?? process.cwd() });
3934
- const summary = isReleased ? "released" : "nothing to release";
3935
- writeReport({ json: flags.json, report: { released: isReleased }, summary });
3937
+ const report = await releaseServiceStack({ cwd: flags.cwd ?? process.cwd() });
3938
+ writeReport({ json: flags.json, report, summary: renderStackReleaseSummary(report) });
3936
3939
  }
3937
3940
  async function stackStatusCommand(flags) {
3938
3941
  const report = await readServiceStackStatus();
@@ -3943,6 +3946,10 @@ function writeReport(params) {
3943
3946
  process.stdout.write(`${output}
3944
3947
  `);
3945
3948
  }
3949
+ function describeStoppedService(service) {
3950
+ const what = service.name ?? (service.commandLine || "untracked listener");
3951
+ return `stopped ${service.port}: ${what} (PID ${service.pid}) \u2014 no lease needs it any more`;
3952
+ }
3946
3953
  function shortSha(sha) {
3947
3954
  return sha ? sha.slice(0, 7) : "unknown";
3948
3955
  }
@@ -5917,7 +5924,7 @@ function createProgram() {
5917
5924
  (value, previous) => [...previous, value],
5918
5925
  []
5919
5926
  ).option("--label <name>", "Name shown to peers waiting on this checkout").option("--wait <seconds>", "Keep re-asking this long while busy").option("--json", "Print the full report as JSON").action(stackClaimCommand);
5920
- stack.command("check").description("Check that the stack still serves what this checkout claimed, renewing the lease").option("--cwd <dir>", "Directory inside the checkout (default: the current directory)").option("--port <port>", "Port the run will target").option("--json", "Print the full report as JSON").action(stackCheckCommand);
5927
+ stack.command("check").description("Check that the stack still serves what this checkout claimed; only runs keep the lease alive").option("--cwd <dir>", "Directory inside the checkout (default: the current directory)").option("--port <port>", "Port the run will target").option("--json", "Print the full report as JSON").action(stackCheckCommand);
5921
5928
  stack.command("release").description("Give up this checkout's lease and place in line").option("--cwd <dir>", "Directory inside the checkout (default: the current directory)").option("--json", "Print the result as JSON").action(stackReleaseCommand);
5922
5929
  stack.command("status").description("Show every lease, the line, and the services prepare tracks").option("--json", "Print the full report as JSON").action(stackStatusCommand);
5923
5930
  program.command("ci-install").description("Add the Muggle walkthrough check to this repository's GitHub Actions").option("--force", "Replace an existing workflow file").action(ciInstallCommand);
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from './chunk-F5KU5ZP2.js';
3
- import './chunk-A3YLVNL7.js';
2
+ import { runCli } from './chunk-YNTLACS2.js';
3
+ import './chunk-WRYPWI33.js';
4
4
 
5
5
  // src/cli/main.ts
6
6
  runCli().catch((error) => {