@dunnewold-labs/mr-manager 0.4.31 → 0.4.32
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/index.mjs +34 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -185,7 +185,7 @@ import { fileURLToPath } from "url";
|
|
|
185
185
|
// cli/package.json
|
|
186
186
|
var package_default = {
|
|
187
187
|
name: "@dunnewold-labs/mr-manager",
|
|
188
|
-
version: "0.4.
|
|
188
|
+
version: "0.4.32",
|
|
189
189
|
description: "Mr. Manager - Task and project management CLI",
|
|
190
190
|
bin: {
|
|
191
191
|
mr: "./dist/index.mjs"
|
|
@@ -1162,6 +1162,19 @@ function taskLikelyDoesNotNeedCodeChanges(task) {
|
|
|
1162
1162
|
return NON_CODE_TASK_KEYWORDS.some((keyword) => haystack.includes(keyword)) || NON_CODE_TASK_PATTERNS.some((pattern) => pattern.test(haystack));
|
|
1163
1163
|
}
|
|
1164
1164
|
|
|
1165
|
+
// lib/task-branch.ts
|
|
1166
|
+
function isPrOrMrUrl(input) {
|
|
1167
|
+
try {
|
|
1168
|
+
const url = new URL(input.trim());
|
|
1169
|
+
const path = url.pathname;
|
|
1170
|
+
if (url.hostname.includes("github") && /\/pull\/\d+/.test(path)) return true;
|
|
1171
|
+
if (url.hostname.includes("gitlab") && /\/merge_requests\/\d+/.test(path)) return true;
|
|
1172
|
+
} catch {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1165
1178
|
// cli/browse-runner.ts
|
|
1166
1179
|
import { execSync as execSync3, spawn as spawn3 } from "child_process";
|
|
1167
1180
|
import { existsSync as existsSync6 } from "fs";
|
|
@@ -1477,11 +1490,21 @@ function ownerPrefix(task) {
|
|
|
1477
1490
|
return first || "mr";
|
|
1478
1491
|
}
|
|
1479
1492
|
function taskBranchName(task) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1493
|
+
const branch = task.attachedBranch?.trim();
|
|
1494
|
+
if (branch && !isPrOrMrUrl(branch)) {
|
|
1495
|
+
return branch;
|
|
1482
1496
|
}
|
|
1483
1497
|
return `${ownerPrefix(task)}/${slugify(task.title)}`;
|
|
1484
1498
|
}
|
|
1499
|
+
function resolveBranchFromPrUrl(prUrl, repoDir, vcs) {
|
|
1500
|
+
const cmd = vcs === "gitlab" ? `glab mr view "${prUrl}" --output json 2>/dev/null | jq -r '.source_branch // empty'` : `gh pr view "${prUrl}" --json headRefName -q .headRefName 2>/dev/null`;
|
|
1501
|
+
return new Promise((resolve9) => {
|
|
1502
|
+
exec(cmd, { cwd: repoDir }, (err, stdout) => {
|
|
1503
|
+
const branch = stdout?.trim();
|
|
1504
|
+
resolve9(branch || null);
|
|
1505
|
+
});
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1485
1508
|
function formatElapsed(ms) {
|
|
1486
1509
|
const totalMinutes = Math.max(1, Math.floor(ms / 6e4));
|
|
1487
1510
|
const hours = Math.floor(totalMinutes / 60);
|
|
@@ -2686,10 +2709,17 @@ var watchCommand = new Command8("watch").description(
|
|
|
2686
2709
|
const sid = shortId(task.id);
|
|
2687
2710
|
const slug = slugify(task.title);
|
|
2688
2711
|
const owner = ownerPrefix(task);
|
|
2689
|
-
|
|
2712
|
+
let branchName = taskBranchName(task);
|
|
2690
2713
|
const legacyBranchName = `mr/${sid}/${slug}`;
|
|
2691
2714
|
const prefix = taskTag(sid);
|
|
2692
2715
|
const vcs = detectVcs(repoDir)?.provider ?? "github";
|
|
2716
|
+
if (!task.attachedBranch?.trim() && task.attachedBranchLink && isPrOrMrUrl(task.attachedBranchLink)) {
|
|
2717
|
+
const resolved = await resolveBranchFromPrUrl(task.attachedBranchLink, repoDir, vcs);
|
|
2718
|
+
if (resolved) {
|
|
2719
|
+
branchName = resolved;
|
|
2720
|
+
logInfo(prefix, `Resolved branch ${paint("cyan", resolved)} from attached ${vcs === "gitlab" ? "MR" : "PR"}`);
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2693
2723
|
logDispatch(prefix, `"${paint("bold", task.title)}" ${paint("gray", repoDir)} ${paint("dim", `[${vcs}]`)}`);
|
|
2694
2724
|
await postTaskUpdate(task.id, `Agent dispatched \u2014 starting work on "${task.title}"`, "system");
|
|
2695
2725
|
let subtasks = [];
|