@sjawhar/pi-legion 9.8.1 → 9.8.2

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 (2) hide show
  1. package/dist/legion.js +43 -2
  2. package/package.json +1 -1
package/dist/legion.js CHANGED
@@ -15729,7 +15729,7 @@ function onEnvoyRoleRegained(listener) {
15729
15729
  // package.json
15730
15730
  var package_default = {
15731
15731
  name: "@sjawhar/pi-legion",
15732
- version: "9.8.1",
15732
+ version: "9.8.2",
15733
15733
  license: "Apache-2.0",
15734
15734
  type: "module",
15735
15735
  omp: {
@@ -16515,6 +16515,45 @@ function createControllerSession(deps) {
16515
16515
  // src/handoff-commit.ts
16516
16516
  import { execFile as execFile2 } from "child_process";
16517
16517
  import { promisify as promisify2 } from "util";
16518
+
16519
+ // src/git-lock.ts
16520
+ import { lstat } from "fs/promises";
16521
+ var GIT_LOCK_REPORTS = [
16522
+ /The lockfile at '([^']+)' might need manual deletion/g,
16523
+ /Unable to create '([^']+)': File exists/g
16524
+ ];
16525
+ function age(ms) {
16526
+ const total = Math.round(Math.abs(ms) / 1000);
16527
+ const sign = ms < 0 && total > 0 ? "-" : "";
16528
+ const hours = Math.floor(total / 3600);
16529
+ const minutes = Math.floor(total % 3600 / 60);
16530
+ const seconds = total % 60;
16531
+ if (hours > 0)
16532
+ return `${sign}${hours}h${minutes}m${seconds}s`;
16533
+ if (minutes > 0)
16534
+ return `${sign}${minutes}m${seconds}s`;
16535
+ return `${sign}${seconds}s`;
16536
+ }
16537
+ async function staleGitLockNote(output, now = Date.now()) {
16538
+ const locks = new Set;
16539
+ for (const report of GIT_LOCK_REPORTS) {
16540
+ for (const match of output.matchAll(report))
16541
+ locks.add(match[1]);
16542
+ }
16543
+ const notes = [];
16544
+ for (const lock of locks) {
16545
+ const written = await lstat(lock).then((info) => info.mtimeMs, () => {
16546
+ return;
16547
+ });
16548
+ if (written === undefined)
16549
+ continue;
16550
+ notes.push(`git lock ${lock} was last written ${age(now - written)} ago and blocks this command. Do not remove it while the issue's pod runs: another role's git, which this container cannot see, may hold it. Replacing the issue's pod removes it. Under the tmux runtime nothing removes it: remove it by hand only once no git or jj process on the host is using the repository.`);
16551
+ }
16552
+ return notes.join(`
16553
+ `);
16554
+ }
16555
+
16556
+ // src/handoff-commit.ts
16518
16557
  var FILE_BACKED = {
16519
16558
  planning: { word: "plan", role: "planner" },
16520
16559
  implementing: { word: "implement", role: "implementer" },
@@ -16531,7 +16570,9 @@ var pathJj = async (args, cwd) => {
16531
16570
  return stdout.trim();
16532
16571
  } catch (error48) {
16533
16572
  const detail = error48 !== null && typeof error48 === "object" && "stderr" in error48 ? String(error48.stderr).trim() : error48 instanceof Error ? error48.message : String(error48);
16534
- throw new Error(`jj ${args.join(" ")} failed: ${detail}`);
16573
+ const note = await staleGitLockNote(detail);
16574
+ throw new Error(`jj ${args.join(" ")} failed: ${detail}${note === "" ? "" : `
16575
+ ${note}`}`);
16535
16576
  }
16536
16577
  };
16537
16578
  function requiredVariable(env, name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion",
3
- "version": "9.8.1",
3
+ "version": "9.8.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {