@imdeadpool/guardex 8.3.0 → 8.4.0
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/README.md +40 -21
- package/package.json +1 -1
- package/src/agents/message.js +764 -0
- package/src/agents/sessions.js +23 -1
- package/src/cli/args.js +54 -7
- package/src/cli/commands/agents.js +17 -0
- package/src/cli/commands/branch.js +42 -1
- package/src/cli/commands/mcp.js +4 -3
- package/src/cli/shared/sandbox.js +5 -53
- package/src/mcp/collect.js +52 -3
- package/src/mcp/server.js +54 -2
- package/src/scaffold/index.js +3 -0
- package/templates/scripts/agent-file-locks.py +82 -0
- package/templates/scripts/agent-worktree-prune.sh +14 -4
|
@@ -582,6 +582,7 @@ has_live_process_in_worktree() {
|
|
|
582
582
|
remove_worktree_with_lock_guard() {
|
|
583
583
|
local worktree="$1"
|
|
584
584
|
local remove_reason="$2"
|
|
585
|
+
local branch="$3"
|
|
585
586
|
local lock_file="${worktree}/.omx/state/agent-file-locks.json"
|
|
586
587
|
local shared_lock="${repo_common_dir}/agent-file-locks.lock"
|
|
587
588
|
|
|
@@ -590,7 +591,7 @@ remove_worktree_with_lock_guard() {
|
|
|
590
591
|
return 10
|
|
591
592
|
fi
|
|
592
593
|
|
|
593
|
-
python3 - "$shared_lock" "$lock_file" "$repo_root" "$worktree" "$remove_reason" "$DRY_RUN" <<'PY'
|
|
594
|
+
python3 - "$shared_lock" "$lock_file" "$repo_root" "$worktree" "$remove_reason" "$branch" "$DRY_RUN" <<'PY'
|
|
594
595
|
import json
|
|
595
596
|
import subprocess
|
|
596
597
|
import sys
|
|
@@ -601,7 +602,7 @@ except ImportError:
|
|
|
601
602
|
print('[agent-worktree-prune] OS file locking is unavailable; prune blocked', file=sys.stderr)
|
|
602
603
|
raise SystemExit(10)
|
|
603
604
|
|
|
604
|
-
shared_lock, lock_file, repo_root, worktree, remove_reason, dry_run = sys.argv[1:]
|
|
605
|
+
shared_lock, lock_file, repo_root, worktree, remove_reason, branch, dry_run = sys.argv[1:]
|
|
605
606
|
try:
|
|
606
607
|
with open(shared_lock, 'a+', encoding='utf-8') as lock_handle:
|
|
607
608
|
fcntl.flock(lock_handle.fileno(), fcntl.LOCK_EX)
|
|
@@ -633,7 +634,16 @@ try:
|
|
|
633
634
|
file=sys.stderr,
|
|
634
635
|
)
|
|
635
636
|
raise SystemExit(10)
|
|
636
|
-
|
|
637
|
+
if not branch.startswith(('agent/', 'work/')) or entry.get('branch') != branch:
|
|
638
|
+
raise SystemExit(10)
|
|
639
|
+
|
|
640
|
+
if locks:
|
|
641
|
+
label = 'lock' if len(locks) == 1 else 'locks'
|
|
642
|
+
print(
|
|
643
|
+
f'[agent-worktree-prune] Releasing {len(locks)} self-owned {label} '
|
|
644
|
+
f'while removing terminal worktree: {worktree}',
|
|
645
|
+
flush=True,
|
|
646
|
+
)
|
|
637
647
|
|
|
638
648
|
print(f'[agent-worktree-prune] Removing worktree ({remove_reason}): {worktree}', flush=True)
|
|
639
649
|
command = ['git', '-C', repo_root, 'worktree', 'remove', worktree, '--force']
|
|
@@ -880,7 +890,7 @@ process_entry() {
|
|
|
880
890
|
fi
|
|
881
891
|
|
|
882
892
|
local remove_status=0
|
|
883
|
-
if remove_worktree_with_lock_guard "$wt" "$remove_reason"; then
|
|
893
|
+
if remove_worktree_with_lock_guard "$wt" "$remove_reason" "$branch"; then
|
|
884
894
|
removed_worktrees=$((removed_worktrees + 1))
|
|
885
895
|
else
|
|
886
896
|
remove_status=$?
|