benignswarm 0.12.41 → 0.12.42

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/dist/git.js CHANGED
@@ -223,7 +223,7 @@ export function landedByContent(head, base, cwd) {
223
223
  * machine whose local main is behind does not keep work that already landed, or that its
224
224
  * changes are already there by content (rebased or squashed landings).
225
225
  */
226
- export function pruneReport(cwd = process.cwd(), closedUnitPaths = new Map(), activeUnits = { paths: new Map(), branches: new Map() }) {
226
+ export function pruneReport(cwd = process.cwd(), closedUnitPaths = new Map(), activeUnits = { paths: new Map(), branches: new Map() }, minAgeMs = 24 * 3600_000) {
227
227
  const scan = scanWorktrees(cwd);
228
228
  if (!scan)
229
229
  return { prunable: [], kept: [], base: null };
@@ -239,6 +239,19 @@ export function pruneReport(cwd = process.cwd(), closedUnitPaths = new Map(), ac
239
239
  kept.push({ path: w.path, branch: w.branch, reason: "you are standing in it" });
240
240
  continue;
241
241
  }
242
+ // An agent's home checkout is never leftovers, whatever its branch: join/setup bind an identity
243
+ // there (unit worktrees never get one). And a worktree made in the last day is too new to judge:
244
+ // StickJoy's watcher removed a home checkout two minutes after it was created, before the agent
245
+ // could bind it, because a fresh branch on main's head looks merged.
246
+ if (existsSync(join(w.path, ".bschat", "identity.json"))) {
247
+ kept.push({ path: w.path, branch: w.branch, reason: "an agent's home checkout (it has .bschat/identity.json)" });
248
+ continue;
249
+ }
250
+ const made = worktreeCreatedMs(w.path);
251
+ if (made !== null && Date.now() - made < minAgeMs) {
252
+ kept.push({ path: w.path, branch: w.branch, reason: "created less than a day ago" });
253
+ continue;
254
+ }
242
255
  // A unit still being worked keeps its worktree whatever git says: one just started has no
243
256
  // commits yet, so its head is on the base and it looks merged (ester WU 110 and 111).
244
257
  const active = activeUnits.paths.get(realpathOrSelf(w.path)) ?? (w.branch ? activeUnits.branches.get(w.branch) : undefined);
@@ -388,3 +401,13 @@ export function removeWorktreeIfClean(path, cwd = process.cwd()) {
388
401
  const r = spawnSync("git", ["worktree", "remove", path], { cwd, encoding: "utf8" });
389
402
  return r.status === 0 ? { removed: true } : { removed: false, reason: (r.stderr || r.stdout).trim() };
390
403
  }
404
+ /** When a linked worktree was created: its `.git` file is written once by `git worktree add`. */
405
+ export function worktreeCreatedMs(path) {
406
+ try {
407
+ const st = statSync(join(path, ".git"));
408
+ return st.birthtimeMs > 0 ? st.birthtimeMs : st.mtimeMs;
409
+ }
410
+ catch {
411
+ return null;
412
+ }
413
+ }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.41";
1
+ export const CLI_VERSION = "0.12.42";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.41",
3
+ "version": "0.12.42",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {