@orgloop/agentctl 1.1.0 → 1.2.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/dist/worktree.js CHANGED
@@ -63,3 +63,71 @@ export async function removeWorktree(repo, worktreePath) {
63
63
  cwd: repoResolved,
64
64
  });
65
65
  }
66
+ /**
67
+ * List all git worktrees for a repo.
68
+ * Parses `git worktree list --porcelain` output.
69
+ */
70
+ export async function listWorktrees(repo) {
71
+ const repoResolved = path.resolve(repo);
72
+ const { stdout } = await execFileAsync("git", ["worktree", "list", "--porcelain"], { cwd: repoResolved });
73
+ const entries = [];
74
+ let current = {};
75
+ for (const line of stdout.split("\n")) {
76
+ if (line.startsWith("worktree ")) {
77
+ if (current.path)
78
+ entries.push(current);
79
+ current = { path: line.replace("worktree ", ""), bare: false };
80
+ }
81
+ else if (line.startsWith("HEAD ")) {
82
+ current.head = line.replace("HEAD ", "");
83
+ }
84
+ else if (line.startsWith("branch ")) {
85
+ current.branch = line.replace("branch refs/heads/", "");
86
+ }
87
+ else if (line === "bare") {
88
+ current.bare = true;
89
+ }
90
+ else if (line === "" && current.path) {
91
+ // End of entry
92
+ }
93
+ }
94
+ if (current.path)
95
+ entries.push(current);
96
+ return entries;
97
+ }
98
+ /**
99
+ * Remove a worktree and optionally delete its branch.
100
+ */
101
+ export async function cleanWorktree(repo, worktreePath, opts) {
102
+ const repoResolved = path.resolve(repo);
103
+ // Get the branch name before removing
104
+ let branch;
105
+ if (opts?.deleteBranch) {
106
+ try {
107
+ const { stdout } = await execFileAsync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd: worktreePath });
108
+ branch = stdout.trim();
109
+ }
110
+ catch {
111
+ // Worktree might be broken — still try to remove
112
+ }
113
+ }
114
+ await execFileAsync("git", ["worktree", "remove", "--force", worktreePath], {
115
+ cwd: repoResolved,
116
+ });
117
+ const result = {
118
+ removedPath: worktreePath,
119
+ };
120
+ // Delete the branch if requested
121
+ if (branch && opts?.deleteBranch) {
122
+ try {
123
+ await execFileAsync("git", ["branch", "-D", branch], {
124
+ cwd: repoResolved,
125
+ });
126
+ result.deletedBranch = branch;
127
+ }
128
+ catch {
129
+ // Branch might already be gone
130
+ }
131
+ }
132
+ return result;
133
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orgloop/agentctl",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Universal agent supervision interface — monitor and control AI coding agents from a single CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -49,7 +49,8 @@
49
49
  "commander": "^14.0.3",
50
50
  "tsx": "^4.21.0",
51
51
  "typescript": "^5.9.3",
52
- "vitest": "^4.0.18"
52
+ "vitest": "^4.0.18",
53
+ "yaml": "^2.8.2"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@biomejs/biome": "^2.4.2"