@yemi33/minions 0.1.612 → 0.1.614

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/CHANGELOG.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.612 (2026-04-08)
3
+ ## 0.1.614 (2026-04-08)
4
4
 
5
5
  ### Features
6
6
  - clickable pinned notes and skills with full content + doc-chat
7
7
 
8
8
  ### Fixes
9
+ - kill process holding worktree lock before removal attempt
10
+ - dedup worktree removal attempts, add Windows rd fallback
9
11
  - accurate LLM call timing and agent metrics on engine page
10
12
  - worktree count now checks for .git file instead of any directory
11
13
 
package/engine/cleanup.js CHANGED
@@ -39,6 +39,44 @@ function worktreeDirMatchesBranch(dirLower, branch) {
39
39
  return dirLower === branchSlug || dirLower.includes(branchSlug + '-') || dirLower.endsWith('-' + branchSlug);
40
40
  }
41
41
 
42
+ /**
43
+ * Kill any tracked or PID-filed process whose dispatch ID appears in the worktree dir name.
44
+ * Must run BEFORE removeWorktree so file handles are released on Windows.
45
+ */
46
+ function _killProcessInWorktree(dir, activeProcesses) {
47
+ const dirLower = dir.toLowerCase();
48
+ // Check tracked active processes
49
+ for (const [id, info] of activeProcesses.entries()) {
50
+ if (dirLower.includes(id.toLowerCase().slice(-8))) {
51
+ try { shared.killImmediate(info.proc); } catch {}
52
+ activeProcesses.delete(id);
53
+ }
54
+ }
55
+ // Check PID files in engine/tmp/ — format: pid-{label}-{id}.pid
56
+ try {
57
+ const tmpDir = path.join(ENGINE_DIR, 'tmp');
58
+ for (const f of fs.readdirSync(tmpDir)) {
59
+ if (!f.startsWith('pid-') || !f.endsWith('.pid')) continue;
60
+ // Extract dispatch ID suffix from filename
61
+ const parts = f.replace(/^pid-/, '').replace(/\.pid$/, '').split('-');
62
+ const suffix = parts.slice(-1)[0];
63
+ if (suffix && dirLower.includes(suffix)) {
64
+ const pid = parseInt(fs.readFileSync(path.join(tmpDir, f), 'utf8').trim(), 10);
65
+ if (pid > 0) {
66
+ try {
67
+ if (process.platform === 'win32') {
68
+ exec(`taskkill /F /PID ${pid}`, { stdio: 'pipe', timeout: 5000, windowsHide: true });
69
+ } else {
70
+ process.kill(pid, 'SIGKILL');
71
+ }
72
+ } catch {} // process may already be dead
73
+ }
74
+ try { fs.unlinkSync(path.join(tmpDir, f)); } catch {}
75
+ }
76
+ }
77
+ } catch {} // tmp dir may not exist
78
+ }
79
+
42
80
  // ─── Cleanup Orchestrator ────────────────────────────────────────────────────
43
81
 
44
82
  function runCleanup(config, verbose = false) {
@@ -105,6 +143,7 @@ function runCleanup(config, verbose = false) {
105
143
  }
106
144
 
107
145
  // 3. Clean git worktrees for merged/abandoned PRs
146
+ const _attemptedWorktreePaths = new Set(); // dedup across projects sharing a worktreeRoot
108
147
  for (const project of projects) {
109
148
  const root = project.localPath ? path.resolve(project.localPath) : null;
110
149
  if (!root || !fs.existsSync(root)) continue;
@@ -261,6 +300,10 @@ function runCleanup(config, verbose = false) {
261
300
  }
262
301
  }
263
302
 
303
+ if (_attemptedWorktreePaths.has(entry.wtPath)) continue;
304
+ _attemptedWorktreePaths.add(entry.wtPath);
305
+ // Kill any process still running in this worktree before removal
306
+ _killProcessInWorktree(entry.dir, activeProcesses);
264
307
  if (shared.removeWorktree(entry.wtPath, root, worktreeRoot)) {
265
308
  cleaned.worktrees++;
266
309
  if (verbose) console.log(` Removed worktree: ${entry.wtPath}`);
package/engine/shared.js CHANGED
@@ -824,11 +824,18 @@ function removeWorktree(wtPath, gitRoot, worktreeRoot) {
824
824
  } catch (gitErr) {
825
825
  try {
826
826
  fs.rmSync(resolved, { recursive: true, force: true });
827
- // Also prune the stale worktree entry from git metadata
828
827
  try { exec('git worktree prune', { cwd: gitRoot, stdio: 'pipe', timeout: 10000, windowsHide: true }); } catch {}
829
828
  return true;
830
829
  } catch (rmErr) {
831
- log('warn', `removeWorktree: both git and rm failed for ${wtPath}: ${rmErr.message}`);
830
+ // Windows EPERM: a process may hold file handles try rd /s /q as fallback
831
+ if (process.platform === 'win32' && rmErr.code === 'EPERM') {
832
+ try {
833
+ exec(`rd /s /q "${resolved}"`, { stdio: 'pipe', timeout: 15000, windowsHide: true });
834
+ try { exec('git worktree prune', { cwd: gitRoot, stdio: 'pipe', timeout: 10000, windowsHide: true }); } catch {}
835
+ return true;
836
+ } catch {}
837
+ }
838
+ log('warn', `removeWorktree: failed for ${wtPath}: ${rmErr.message}`);
832
839
  return false;
833
840
  }
834
841
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yemi33/minions",
3
- "version": "0.1.612",
3
+ "version": "0.1.614",
4
4
  "description": "Multi-agent AI dev team that runs from ~/.minions/ — five autonomous agents share a single engine, dashboard, and knowledge base",
5
5
  "bin": {
6
6
  "minions": "bin/minions.js"