@orgloop/agentctl 1.2.0 → 1.3.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/merge.d.ts DELETED
@@ -1,24 +0,0 @@
1
- export interface MergeOpts {
2
- /** Working directory of the session */
3
- cwd: string;
4
- /** Commit message (auto-generated if omitted) */
5
- message?: string;
6
- /** Whether to remove worktree after push */
7
- removeWorktree?: boolean;
8
- /** The main repo path (needed for worktree removal) */
9
- repoPath?: string;
10
- }
11
- export interface MergeResult {
12
- committed: boolean;
13
- pushed: boolean;
14
- prUrl?: string;
15
- worktreeRemoved: boolean;
16
- }
17
- /**
18
- * Merge + cleanup workflow:
19
- * 1. Commit uncommitted changes
20
- * 2. Push to remote
21
- * 3. Open PR via `gh`
22
- * 4. Optionally remove worktree
23
- */
24
- export declare function mergeSession(opts: MergeOpts): Promise<MergeResult>;
package/dist/merge.js DELETED
@@ -1,65 +0,0 @@
1
- import { exec, execFile } from "node:child_process";
2
- import { promisify } from "node:util";
3
- const execAsync = promisify(exec);
4
- const execFileAsync = promisify(execFile);
5
- /**
6
- * Merge + cleanup workflow:
7
- * 1. Commit uncommitted changes
8
- * 2. Push to remote
9
- * 3. Open PR via `gh`
10
- * 4. Optionally remove worktree
11
- */
12
- export async function mergeSession(opts) {
13
- const { cwd } = opts;
14
- const result = {
15
- committed: false,
16
- pushed: false,
17
- worktreeRemoved: false,
18
- };
19
- // 1. Check for uncommitted changes
20
- const { stdout: status } = await execFileAsync("git", ["status", "--porcelain"], { cwd });
21
- if (status.trim()) {
22
- // Stage all changes and commit
23
- await execFileAsync("git", ["add", "-A"], { cwd });
24
- const message = opts.message || "chore: commit agent session work (via agentctl merge)";
25
- await execFileAsync("git", ["commit", "-m", message], { cwd });
26
- result.committed = true;
27
- }
28
- // 2. Get current branch name
29
- const { stdout: branchRaw } = await execFileAsync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd });
30
- const branch = branchRaw.trim();
31
- // 3. Push to remote
32
- try {
33
- await execFileAsync("git", ["push", "-u", "origin", branch], { cwd });
34
- result.pushed = true;
35
- }
36
- catch (err) {
37
- console.error("Push failed:", err.message);
38
- return result;
39
- }
40
- // 4. Open PR via gh (best effort)
41
- try {
42
- const { stdout: prOut } = await execAsync(`gh pr create --fill --head ${branch} 2>&1 || gh pr view --json url -q .url 2>&1`, { cwd });
43
- // Extract URL from output
44
- const urlMatch = prOut.match(/https:\/\/github\.com\/[^\s]+/);
45
- if (urlMatch) {
46
- result.prUrl = urlMatch[0];
47
- }
48
- }
49
- catch {
50
- // gh not available or PR already exists
51
- }
52
- // 5. Optionally remove worktree
53
- if (opts.removeWorktree && opts.repoPath) {
54
- try {
55
- await execFileAsync("git", ["worktree", "remove", "--force", cwd], {
56
- cwd: opts.repoPath,
57
- });
58
- result.worktreeRemoved = true;
59
- }
60
- catch (err) {
61
- console.error("Worktree removal failed:", err.message);
62
- }
63
- }
64
- return result;
65
- }