techunter 1.1.1 → 1.1.2
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.cjs +147 -35
- package/dist/mcp.cjs +146 -34
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60494,6 +60494,38 @@ async function abortMergeOperation() {
|
|
|
60494
60494
|
} catch {
|
|
60495
60495
|
}
|
|
60496
60496
|
}
|
|
60497
|
+
async function countCommits(range) {
|
|
60498
|
+
const count = await git.raw(["rev-list", "--count", range]);
|
|
60499
|
+
return parseInt(count.trim(), 10);
|
|
60500
|
+
}
|
|
60501
|
+
async function syncBranchWithRemote(branchName) {
|
|
60502
|
+
try {
|
|
60503
|
+
await git.fetch("origin", branchName);
|
|
60504
|
+
} catch {
|
|
60505
|
+
return { mode: "noop" };
|
|
60506
|
+
}
|
|
60507
|
+
const remoteRef = `origin/${branchName}`;
|
|
60508
|
+
const branches = await git.branch(["-a"]);
|
|
60509
|
+
if (!Object.prototype.hasOwnProperty.call(branches.branches, `remotes/${remoteRef}`)) {
|
|
60510
|
+
return { mode: "noop" };
|
|
60511
|
+
}
|
|
60512
|
+
const [localAhead, remoteAhead] = await Promise.all([
|
|
60513
|
+
countCommits(`${remoteRef}..${branchName}`),
|
|
60514
|
+
countCommits(`${branchName}..${remoteRef}`)
|
|
60515
|
+
]);
|
|
60516
|
+
if (remoteAhead === 0) return { mode: "noop" };
|
|
60517
|
+
if (localAhead === 0) {
|
|
60518
|
+
await git.merge(["--ff-only", remoteRef]);
|
|
60519
|
+
return { mode: "fast-forward" };
|
|
60520
|
+
}
|
|
60521
|
+
try {
|
|
60522
|
+
await git.merge([remoteRef, "-m", `chore: sync ${branchName} after remote update`]);
|
|
60523
|
+
return { mode: "merge" };
|
|
60524
|
+
} catch (err) {
|
|
60525
|
+
await abortMergeOperation();
|
|
60526
|
+
throw new Error(`Could not sync ${branchName} with ${remoteRef}: ${err.message}`);
|
|
60527
|
+
}
|
|
60528
|
+
}
|
|
60497
60529
|
async function getDiffFromCommit(baseCommit) {
|
|
60498
60530
|
const status = await git.status();
|
|
60499
60531
|
const parts = [];
|
|
@@ -147272,7 +147304,7 @@ async function chooseTaskForSubmit(config, username, currentIssueNumber) {
|
|
|
147272
147304
|
}
|
|
147273
147305
|
return ordered.find((task) => task.number === issueNumber) ?? null;
|
|
147274
147306
|
}
|
|
147275
|
-
async function prepareTaskContext(config, issue, username, currentBranch, interactive, carryCurrentWork) {
|
|
147307
|
+
async function prepareTaskContext(config, issue, username, currentBranch, interactive, carryCurrentWork, previousTaskState) {
|
|
147276
147308
|
const targetBranch = getTaskBranch2(issue, username);
|
|
147277
147309
|
if (currentBranch === targetBranch) {
|
|
147278
147310
|
await setActiveTaskState(issue, targetBranch);
|
|
@@ -147315,6 +147347,7 @@ async function prepareTaskContext(config, issue, username, currentBranch, intera
|
|
|
147315
147347
|
}
|
|
147316
147348
|
}
|
|
147317
147349
|
const notices = [];
|
|
147350
|
+
const shouldRestoreOriginalContext = action === "switch";
|
|
147318
147351
|
let stashed = false;
|
|
147319
147352
|
let switched = false;
|
|
147320
147353
|
let switchedBranch = targetBranch;
|
|
@@ -147341,7 +147374,15 @@ async function prepareTaskContext(config, issue, username, currentBranch, intera
|
|
|
147341
147374
|
`Saved your unsaved work from ${currentBranch}. Return there later and run \`git stash pop\` to restore it.`
|
|
147342
147375
|
);
|
|
147343
147376
|
}
|
|
147344
|
-
return {
|
|
147377
|
+
return {
|
|
147378
|
+
branch: switchedBranch,
|
|
147379
|
+
notices,
|
|
147380
|
+
restore: shouldRestoreOriginalContext ? {
|
|
147381
|
+
originalBranch: currentBranch,
|
|
147382
|
+
restoreStash: stashed && !stashRestoredOnTarget,
|
|
147383
|
+
previousTaskState: previousTaskState?.activeBranch === currentBranch ? previousTaskState : void 0
|
|
147384
|
+
} : void 0
|
|
147385
|
+
};
|
|
147345
147386
|
} catch (err) {
|
|
147346
147387
|
const rollbackNotices = [];
|
|
147347
147388
|
if (mergeAttempted) {
|
|
@@ -147372,6 +147413,48 @@ ${rollbackNotices.join("\n")}` : "";
|
|
|
147372
147413
|
throw new Error(`Could not prepare task #${issue.number}: ${err.message}${details}`);
|
|
147373
147414
|
}
|
|
147374
147415
|
}
|
|
147416
|
+
async function restorePreviousContext(context) {
|
|
147417
|
+
const notices = [];
|
|
147418
|
+
try {
|
|
147419
|
+
await switchToBranchOrCreate(context.originalBranch);
|
|
147420
|
+
notices.push(`Returned to ${context.originalBranch}.`);
|
|
147421
|
+
} catch (err) {
|
|
147422
|
+
notices.push(`Could not return to ${context.originalBranch} automatically: ${err.message}`);
|
|
147423
|
+
if (context.restoreStash) {
|
|
147424
|
+
notices.push("Your stashed work was kept unchanged.");
|
|
147425
|
+
}
|
|
147426
|
+
return notices;
|
|
147427
|
+
}
|
|
147428
|
+
try {
|
|
147429
|
+
const syncResult = await syncBranchWithRemote(context.originalBranch);
|
|
147430
|
+
if (syncResult.mode === "fast-forward") {
|
|
147431
|
+
notices.push(`Fast-forwarded ${context.originalBranch} to the latest origin/${context.originalBranch}.`);
|
|
147432
|
+
} else if (syncResult.mode === "merge") {
|
|
147433
|
+
notices.push(`Merged the latest origin/${context.originalBranch} into ${context.originalBranch} before restoring your work.`);
|
|
147434
|
+
}
|
|
147435
|
+
} catch (err) {
|
|
147436
|
+
notices.push(`Could not sync ${context.originalBranch} with origin/${context.originalBranch}: ${err.message}`);
|
|
147437
|
+
if (context.restoreStash) {
|
|
147438
|
+
notices.push("Your stashed work was not restored because the branch needs manual sync first.");
|
|
147439
|
+
}
|
|
147440
|
+
if (context.previousTaskState) {
|
|
147441
|
+
setConfig({ taskState: context.previousTaskState });
|
|
147442
|
+
}
|
|
147443
|
+
return notices;
|
|
147444
|
+
}
|
|
147445
|
+
if (context.restoreStash) {
|
|
147446
|
+
try {
|
|
147447
|
+
await stashPop();
|
|
147448
|
+
notices.push(`Restored your stashed work on ${context.originalBranch}.`);
|
|
147449
|
+
} catch (err) {
|
|
147450
|
+
notices.push(`Could not restore your stashed work automatically on ${context.originalBranch}: ${err.message}`);
|
|
147451
|
+
}
|
|
147452
|
+
}
|
|
147453
|
+
if (context.previousTaskState) {
|
|
147454
|
+
setConfig({ taskState: context.previousTaskState });
|
|
147455
|
+
}
|
|
147456
|
+
return notices;
|
|
147457
|
+
}
|
|
147375
147458
|
async function buildDiffForIssue(issue, branch) {
|
|
147376
147459
|
const taskState = getConfig().taskState;
|
|
147377
147460
|
if (taskState?.activeIssueNumber === issue.number && taskState?.activeBranch === branch && taskState.baseCommit) {
|
|
@@ -147392,8 +147475,11 @@ async function performSubmit(config, issue, branch, username, interactive, commi
|
|
|
147392
147475
|
const openSubtaskNumbers = await getOpenSubtasks(config, branch);
|
|
147393
147476
|
spinner?.stop();
|
|
147394
147477
|
if (openSubtaskNumbers.length > 0) {
|
|
147395
|
-
return
|
|
147396
|
-
|
|
147478
|
+
return {
|
|
147479
|
+
message: interactive ? `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open:
|
|
147480
|
+
` + openSubtaskNumbers.map((n2) => ` - #${n2}`).join("\n") + "\nComplete all sub-tasks before submitting." : `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open: ` + openSubtaskNumbers.map((n2) => `#${n2}`).join(", "),
|
|
147481
|
+
success: false
|
|
147482
|
+
};
|
|
147397
147483
|
}
|
|
147398
147484
|
let review = "";
|
|
147399
147485
|
if (!isSelfSubmit) {
|
|
@@ -147426,9 +147512,9 @@ async function performSubmit(config, issue, branch, username, interactive, commi
|
|
|
147426
147512
|
]
|
|
147427
147513
|
});
|
|
147428
147514
|
} catch {
|
|
147429
|
-
return "Submit cancelled.";
|
|
147515
|
+
return { message: "Submit cancelled.", success: false };
|
|
147430
147516
|
}
|
|
147431
|
-
if (!shouldProceed) return "Submit cancelled by user.";
|
|
147517
|
+
if (!shouldProceed) return { message: "Submit cancelled by user.", success: false };
|
|
147432
147518
|
}
|
|
147433
147519
|
let commitMessage = commitMessageOverride?.trim();
|
|
147434
147520
|
if (!commitMessage) {
|
|
@@ -147439,9 +147525,9 @@ async function performSubmit(config, issue, branch, username, interactive, commi
|
|
|
147439
147525
|
default: `complete: ${issue.title}`
|
|
147440
147526
|
});
|
|
147441
147527
|
} catch {
|
|
147442
|
-
return "Submit cancelled.";
|
|
147528
|
+
return { message: "Submit cancelled.", success: false };
|
|
147443
147529
|
}
|
|
147444
|
-
if (!commitMessage.trim()) return "Submit cancelled.";
|
|
147530
|
+
if (!commitMessage.trim()) return { message: "Submit cancelled.", success: false };
|
|
147445
147531
|
} else {
|
|
147446
147532
|
commitMessage = `complete: ${issue.title}`;
|
|
147447
147533
|
}
|
|
@@ -147452,7 +147538,7 @@ async function performSubmit(config, issue, branch, username, interactive, commi
|
|
|
147452
147538
|
spinner?.stop();
|
|
147453
147539
|
} catch (err) {
|
|
147454
147540
|
spinner?.stop();
|
|
147455
|
-
return `Commit failed: ${err.message}
|
|
147541
|
+
return { message: `Commit failed: ${err.message}`, success: false };
|
|
147456
147542
|
}
|
|
147457
147543
|
if (isSelfSubmit) {
|
|
147458
147544
|
const baseBranch = config.baseBranch ?? "main";
|
|
@@ -147465,7 +147551,10 @@ async function performSubmit(config, issue, branch, username, interactive, commi
|
|
|
147465
147551
|
spinner?.stop();
|
|
147466
147552
|
} catch (err) {
|
|
147467
147553
|
spinner?.stop();
|
|
147468
|
-
return
|
|
147554
|
+
return {
|
|
147555
|
+
message: `Committed and pushed to ${branch}, but failed to merge into ${targetBranch}: ${err.message}`,
|
|
147556
|
+
success: false
|
|
147557
|
+
};
|
|
147469
147558
|
}
|
|
147470
147559
|
}
|
|
147471
147560
|
if (!isTaskBranch(targetBranch) && targetBranch !== baseBranch) {
|
|
@@ -147476,7 +147565,10 @@ async function performSubmit(config, issue, branch, username, interactive, commi
|
|
|
147476
147565
|
spinner?.stop();
|
|
147477
147566
|
} catch (err) {
|
|
147478
147567
|
spinner?.stop();
|
|
147479
|
-
return
|
|
147568
|
+
return {
|
|
147569
|
+
message: `Committed and merged ${branch} -> ${targetBranch}, but failed to merge ${targetBranch} into ${baseBranch}: ${err.message}`,
|
|
147570
|
+
success: false
|
|
147571
|
+
};
|
|
147480
147572
|
}
|
|
147481
147573
|
}
|
|
147482
147574
|
spinner = interactive ? ora("Closing issue...").start() : void 0;
|
|
@@ -147491,9 +147583,12 @@ async function performSubmit(config, issue, branch, username, interactive, commi
|
|
|
147491
147583
|
}
|
|
147492
147584
|
setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
|
|
147493
147585
|
const mergePath = finalBranch === targetBranch ? `${branch} -> ${targetBranch}` : `${branch} -> ${targetBranch} -> ${finalBranch}`;
|
|
147494
|
-
return
|
|
147586
|
+
return {
|
|
147587
|
+
message: `Task #${issue.number} committed and closed.
|
|
147495
147588
|
Merged: ${mergePath}
|
|
147496
|
-
Commit: "${commitMessage.trim()}"
|
|
147589
|
+
Commit: "${commitMessage.trim()}"`,
|
|
147590
|
+
success: true
|
|
147591
|
+
};
|
|
147497
147592
|
}
|
|
147498
147593
|
spinner = interactive ? ora("Checking for existing PR...").start() : void 0;
|
|
147499
147594
|
const existingPR = await getTaskPR(config, issue.number, branch);
|
|
@@ -147520,7 +147615,7 @@ ${review}` : ""
|
|
|
147520
147615
|
spinner?.stop();
|
|
147521
147616
|
} catch (err) {
|
|
147522
147617
|
spinner?.stop();
|
|
147523
|
-
return `Committed but PR creation failed: ${err.message}
|
|
147618
|
+
return { message: `Committed but PR creation failed: ${err.message}`, success: false };
|
|
147524
147619
|
}
|
|
147525
147620
|
}
|
|
147526
147621
|
spinner = interactive ? ora("Marking as in-review...").start() : void 0;
|
|
@@ -147529,16 +147624,22 @@ ${review}` : ""
|
|
|
147529
147624
|
spinner?.stop();
|
|
147530
147625
|
} catch (err) {
|
|
147531
147626
|
spinner?.stop();
|
|
147532
|
-
return
|
|
147627
|
+
return {
|
|
147628
|
+
message: interactive ? `PR ${existingPR ? "updated" : "created"} (${prUrl}) but failed to update label: ${err.message}` : `PR ${existingPR ? "updated" : "created"} (${prUrl}) but failed to update label: ${err.message}`,
|
|
147629
|
+
success: false
|
|
147630
|
+
};
|
|
147533
147631
|
}
|
|
147534
147632
|
setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
|
|
147535
|
-
return
|
|
147633
|
+
return {
|
|
147634
|
+
message: interactive ? `Task #${issue.number} ${existingPR ? "re-submitted" : "submitted"}.
|
|
147536
147635
|
Commit: "${commitMessage.trim()}"
|
|
147537
147636
|
PR: ${prUrl}` : `Task #${issue.number} ${existingPR ? "re-submitted" : "submitted"}.
|
|
147538
147637
|
Review:
|
|
147539
147638
|
${review}
|
|
147540
147639
|
Commit: "${commitMessage.trim()}"
|
|
147541
|
-
PR: ${prUrl}
|
|
147640
|
+
PR: ${prUrl}`,
|
|
147641
|
+
success: true
|
|
147642
|
+
};
|
|
147542
147643
|
}
|
|
147543
147644
|
function formatSubmitResult(result, notices) {
|
|
147544
147645
|
if (notices.length === 0) return result;
|
|
@@ -147567,6 +147668,7 @@ var definition = {
|
|
|
147567
147668
|
};
|
|
147568
147669
|
async function run(_input, config) {
|
|
147569
147670
|
const currentBranch = await getCurrentBranch();
|
|
147671
|
+
const previousTaskState = getConfig().taskState;
|
|
147570
147672
|
const [username, currentIssueNumber] = await Promise.all([
|
|
147571
147673
|
getAuthenticatedUser(config),
|
|
147572
147674
|
resolveIssueNumberFromBranch(config, currentBranch)
|
|
@@ -147582,18 +147684,27 @@ async function run(_input, config) {
|
|
|
147582
147684
|
}
|
|
147583
147685
|
let branch;
|
|
147584
147686
|
let notices;
|
|
147687
|
+
let restore;
|
|
147585
147688
|
try {
|
|
147586
|
-
({ branch, notices } = await prepareTaskContext(
|
|
147689
|
+
({ branch, notices, restore } = await prepareTaskContext(
|
|
147690
|
+
config,
|
|
147691
|
+
selectedTask,
|
|
147692
|
+
username,
|
|
147693
|
+
currentBranch,
|
|
147694
|
+
true,
|
|
147695
|
+
void 0,
|
|
147696
|
+
previousTaskState
|
|
147697
|
+
));
|
|
147587
147698
|
} catch (err) {
|
|
147588
147699
|
return err.message;
|
|
147589
147700
|
}
|
|
147590
|
-
|
|
147591
|
-
|
|
147592
|
-
|
|
147593
|
-
);
|
|
147701
|
+
const outcome = await performSubmit(config, selectedTask, branch, username, true);
|
|
147702
|
+
const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
|
|
147703
|
+
return formatSubmitResult(outcome.message, allNotices);
|
|
147594
147704
|
}
|
|
147595
147705
|
async function execute(input, config) {
|
|
147596
147706
|
const currentBranch = await getCurrentBranch();
|
|
147707
|
+
const previousTaskState = getConfig().taskState;
|
|
147597
147708
|
const username = await getAuthenticatedUser(config);
|
|
147598
147709
|
const requestedIssueNumber = input["issue_number"];
|
|
147599
147710
|
const carryCurrentWork = input["carry_current_work"];
|
|
@@ -147610,29 +147721,30 @@ async function execute(input, config) {
|
|
|
147610
147721
|
}
|
|
147611
147722
|
let branch;
|
|
147612
147723
|
let notices;
|
|
147724
|
+
let restore;
|
|
147613
147725
|
try {
|
|
147614
|
-
({ branch, notices } = await prepareTaskContext(
|
|
147726
|
+
({ branch, notices, restore } = await prepareTaskContext(
|
|
147615
147727
|
config,
|
|
147616
147728
|
issue,
|
|
147617
147729
|
username,
|
|
147618
147730
|
currentBranch,
|
|
147619
147731
|
false,
|
|
147620
|
-
carryCurrentWork
|
|
147732
|
+
carryCurrentWork,
|
|
147733
|
+
previousTaskState
|
|
147621
147734
|
));
|
|
147622
147735
|
} catch (err) {
|
|
147623
147736
|
return err.message;
|
|
147624
147737
|
}
|
|
147625
|
-
|
|
147626
|
-
|
|
147627
|
-
|
|
147628
|
-
|
|
147629
|
-
|
|
147630
|
-
|
|
147631
|
-
|
|
147632
|
-
input["commit_message"]
|
|
147633
|
-
),
|
|
147634
|
-
notices
|
|
147738
|
+
const outcome = await performSubmit(
|
|
147739
|
+
config,
|
|
147740
|
+
issue,
|
|
147741
|
+
branch,
|
|
147742
|
+
username,
|
|
147743
|
+
false,
|
|
147744
|
+
input["commit_message"]
|
|
147635
147745
|
);
|
|
147746
|
+
const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
|
|
147747
|
+
return formatSubmitResult(outcome.message, allNotices);
|
|
147636
147748
|
}
|
|
147637
147749
|
var terminal2 = true;
|
|
147638
147750
|
|
|
@@ -150894,7 +151006,7 @@ async function startAutoUpdate(currentVersion) {
|
|
|
150894
151006
|
}
|
|
150895
151007
|
|
|
150896
151008
|
// src/index.ts
|
|
150897
|
-
var version = "1.1.
|
|
151009
|
+
var version = "1.1.2";
|
|
150898
151010
|
var SLASH_NAMES = [
|
|
150899
151011
|
"/help",
|
|
150900
151012
|
"/h",
|
package/dist/mcp.cjs
CHANGED
|
@@ -56709,6 +56709,38 @@ async function abortMergeOperation() {
|
|
|
56709
56709
|
} catch {
|
|
56710
56710
|
}
|
|
56711
56711
|
}
|
|
56712
|
+
async function countCommits(range) {
|
|
56713
|
+
const count = await git.raw(["rev-list", "--count", range]);
|
|
56714
|
+
return parseInt(count.trim(), 10);
|
|
56715
|
+
}
|
|
56716
|
+
async function syncBranchWithRemote(branchName) {
|
|
56717
|
+
try {
|
|
56718
|
+
await git.fetch("origin", branchName);
|
|
56719
|
+
} catch {
|
|
56720
|
+
return { mode: "noop" };
|
|
56721
|
+
}
|
|
56722
|
+
const remoteRef = `origin/${branchName}`;
|
|
56723
|
+
const branches = await git.branch(["-a"]);
|
|
56724
|
+
if (!Object.prototype.hasOwnProperty.call(branches.branches, `remotes/${remoteRef}`)) {
|
|
56725
|
+
return { mode: "noop" };
|
|
56726
|
+
}
|
|
56727
|
+
const [localAhead, remoteAhead] = await Promise.all([
|
|
56728
|
+
countCommits(`${remoteRef}..${branchName}`),
|
|
56729
|
+
countCommits(`${branchName}..${remoteRef}`)
|
|
56730
|
+
]);
|
|
56731
|
+
if (remoteAhead === 0) return { mode: "noop" };
|
|
56732
|
+
if (localAhead === 0) {
|
|
56733
|
+
await git.merge(["--ff-only", remoteRef]);
|
|
56734
|
+
return { mode: "fast-forward" };
|
|
56735
|
+
}
|
|
56736
|
+
try {
|
|
56737
|
+
await git.merge([remoteRef, "-m", `chore: sync ${branchName} after remote update`]);
|
|
56738
|
+
return { mode: "merge" };
|
|
56739
|
+
} catch (err) {
|
|
56740
|
+
await abortMergeOperation();
|
|
56741
|
+
throw new Error(`Could not sync ${branchName} with ${remoteRef}: ${err.message}`);
|
|
56742
|
+
}
|
|
56743
|
+
}
|
|
56712
56744
|
async function getDiffFromCommit(baseCommit) {
|
|
56713
56745
|
const status = await git.status();
|
|
56714
56746
|
const parts = [];
|
|
@@ -152018,7 +152050,7 @@ async function chooseTaskForSubmit(config2, username, currentIssueNumber) {
|
|
|
152018
152050
|
}
|
|
152019
152051
|
return ordered.find((task) => task.number === issueNumber) ?? null;
|
|
152020
152052
|
}
|
|
152021
|
-
async function prepareTaskContext(config2, issue2, username, currentBranch, interactive, carryCurrentWork) {
|
|
152053
|
+
async function prepareTaskContext(config2, issue2, username, currentBranch, interactive, carryCurrentWork, previousTaskState) {
|
|
152022
152054
|
const targetBranch = getTaskBranch2(issue2, username);
|
|
152023
152055
|
if (currentBranch === targetBranch) {
|
|
152024
152056
|
await setActiveTaskState(issue2, targetBranch);
|
|
@@ -152061,6 +152093,7 @@ async function prepareTaskContext(config2, issue2, username, currentBranch, inte
|
|
|
152061
152093
|
}
|
|
152062
152094
|
}
|
|
152063
152095
|
const notices = [];
|
|
152096
|
+
const shouldRestoreOriginalContext = action === "switch";
|
|
152064
152097
|
let stashed = false;
|
|
152065
152098
|
let switched = false;
|
|
152066
152099
|
let switchedBranch = targetBranch;
|
|
@@ -152087,7 +152120,15 @@ async function prepareTaskContext(config2, issue2, username, currentBranch, inte
|
|
|
152087
152120
|
`Saved your unsaved work from ${currentBranch}. Return there later and run \`git stash pop\` to restore it.`
|
|
152088
152121
|
);
|
|
152089
152122
|
}
|
|
152090
|
-
return {
|
|
152123
|
+
return {
|
|
152124
|
+
branch: switchedBranch,
|
|
152125
|
+
notices,
|
|
152126
|
+
restore: shouldRestoreOriginalContext ? {
|
|
152127
|
+
originalBranch: currentBranch,
|
|
152128
|
+
restoreStash: stashed && !stashRestoredOnTarget,
|
|
152129
|
+
previousTaskState: previousTaskState?.activeBranch === currentBranch ? previousTaskState : void 0
|
|
152130
|
+
} : void 0
|
|
152131
|
+
};
|
|
152091
152132
|
} catch (err) {
|
|
152092
152133
|
const rollbackNotices = [];
|
|
152093
152134
|
if (mergeAttempted) {
|
|
@@ -152118,6 +152159,48 @@ ${rollbackNotices.join("\n")}` : "";
|
|
|
152118
152159
|
throw new Error(`Could not prepare task #${issue2.number}: ${err.message}${details}`);
|
|
152119
152160
|
}
|
|
152120
152161
|
}
|
|
152162
|
+
async function restorePreviousContext(context) {
|
|
152163
|
+
const notices = [];
|
|
152164
|
+
try {
|
|
152165
|
+
await switchToBranchOrCreate(context.originalBranch);
|
|
152166
|
+
notices.push(`Returned to ${context.originalBranch}.`);
|
|
152167
|
+
} catch (err) {
|
|
152168
|
+
notices.push(`Could not return to ${context.originalBranch} automatically: ${err.message}`);
|
|
152169
|
+
if (context.restoreStash) {
|
|
152170
|
+
notices.push("Your stashed work was kept unchanged.");
|
|
152171
|
+
}
|
|
152172
|
+
return notices;
|
|
152173
|
+
}
|
|
152174
|
+
try {
|
|
152175
|
+
const syncResult = await syncBranchWithRemote(context.originalBranch);
|
|
152176
|
+
if (syncResult.mode === "fast-forward") {
|
|
152177
|
+
notices.push(`Fast-forwarded ${context.originalBranch} to the latest origin/${context.originalBranch}.`);
|
|
152178
|
+
} else if (syncResult.mode === "merge") {
|
|
152179
|
+
notices.push(`Merged the latest origin/${context.originalBranch} into ${context.originalBranch} before restoring your work.`);
|
|
152180
|
+
}
|
|
152181
|
+
} catch (err) {
|
|
152182
|
+
notices.push(`Could not sync ${context.originalBranch} with origin/${context.originalBranch}: ${err.message}`);
|
|
152183
|
+
if (context.restoreStash) {
|
|
152184
|
+
notices.push("Your stashed work was not restored because the branch needs manual sync first.");
|
|
152185
|
+
}
|
|
152186
|
+
if (context.previousTaskState) {
|
|
152187
|
+
setConfig({ taskState: context.previousTaskState });
|
|
152188
|
+
}
|
|
152189
|
+
return notices;
|
|
152190
|
+
}
|
|
152191
|
+
if (context.restoreStash) {
|
|
152192
|
+
try {
|
|
152193
|
+
await stashPop();
|
|
152194
|
+
notices.push(`Restored your stashed work on ${context.originalBranch}.`);
|
|
152195
|
+
} catch (err) {
|
|
152196
|
+
notices.push(`Could not restore your stashed work automatically on ${context.originalBranch}: ${err.message}`);
|
|
152197
|
+
}
|
|
152198
|
+
}
|
|
152199
|
+
if (context.previousTaskState) {
|
|
152200
|
+
setConfig({ taskState: context.previousTaskState });
|
|
152201
|
+
}
|
|
152202
|
+
return notices;
|
|
152203
|
+
}
|
|
152121
152204
|
async function buildDiffForIssue(issue2, branch) {
|
|
152122
152205
|
const taskState = getConfig().taskState;
|
|
152123
152206
|
if (taskState?.activeIssueNumber === issue2.number && taskState?.activeBranch === branch && taskState.baseCommit) {
|
|
@@ -152138,8 +152221,11 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
|
|
|
152138
152221
|
const openSubtaskNumbers = await getOpenSubtasks(config2, branch);
|
|
152139
152222
|
spinner?.stop();
|
|
152140
152223
|
if (openSubtaskNumbers.length > 0) {
|
|
152141
|
-
return
|
|
152142
|
-
|
|
152224
|
+
return {
|
|
152225
|
+
message: interactive ? `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open:
|
|
152226
|
+
` + openSubtaskNumbers.map((n2) => ` - #${n2}`).join("\n") + "\nComplete all sub-tasks before submitting." : `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open: ` + openSubtaskNumbers.map((n2) => `#${n2}`).join(", "),
|
|
152227
|
+
success: false
|
|
152228
|
+
};
|
|
152143
152229
|
}
|
|
152144
152230
|
let review = "";
|
|
152145
152231
|
if (!isSelfSubmit) {
|
|
@@ -152172,9 +152258,9 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
|
|
|
152172
152258
|
]
|
|
152173
152259
|
});
|
|
152174
152260
|
} catch {
|
|
152175
|
-
return "Submit cancelled.";
|
|
152261
|
+
return { message: "Submit cancelled.", success: false };
|
|
152176
152262
|
}
|
|
152177
|
-
if (!shouldProceed) return "Submit cancelled by user.";
|
|
152263
|
+
if (!shouldProceed) return { message: "Submit cancelled by user.", success: false };
|
|
152178
152264
|
}
|
|
152179
152265
|
let commitMessage = commitMessageOverride?.trim();
|
|
152180
152266
|
if (!commitMessage) {
|
|
@@ -152185,9 +152271,9 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
|
|
|
152185
152271
|
default: `complete: ${issue2.title}`
|
|
152186
152272
|
});
|
|
152187
152273
|
} catch {
|
|
152188
|
-
return "Submit cancelled.";
|
|
152274
|
+
return { message: "Submit cancelled.", success: false };
|
|
152189
152275
|
}
|
|
152190
|
-
if (!commitMessage.trim()) return "Submit cancelled.";
|
|
152276
|
+
if (!commitMessage.trim()) return { message: "Submit cancelled.", success: false };
|
|
152191
152277
|
} else {
|
|
152192
152278
|
commitMessage = `complete: ${issue2.title}`;
|
|
152193
152279
|
}
|
|
@@ -152198,7 +152284,7 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
|
|
|
152198
152284
|
spinner?.stop();
|
|
152199
152285
|
} catch (err) {
|
|
152200
152286
|
spinner?.stop();
|
|
152201
|
-
return `Commit failed: ${err.message}
|
|
152287
|
+
return { message: `Commit failed: ${err.message}`, success: false };
|
|
152202
152288
|
}
|
|
152203
152289
|
if (isSelfSubmit) {
|
|
152204
152290
|
const baseBranch = config2.baseBranch ?? "main";
|
|
@@ -152211,7 +152297,10 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
|
|
|
152211
152297
|
spinner?.stop();
|
|
152212
152298
|
} catch (err) {
|
|
152213
152299
|
spinner?.stop();
|
|
152214
|
-
return
|
|
152300
|
+
return {
|
|
152301
|
+
message: `Committed and pushed to ${branch}, but failed to merge into ${targetBranch}: ${err.message}`,
|
|
152302
|
+
success: false
|
|
152303
|
+
};
|
|
152215
152304
|
}
|
|
152216
152305
|
}
|
|
152217
152306
|
if (!isTaskBranch(targetBranch) && targetBranch !== baseBranch) {
|
|
@@ -152222,7 +152311,10 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
|
|
|
152222
152311
|
spinner?.stop();
|
|
152223
152312
|
} catch (err) {
|
|
152224
152313
|
spinner?.stop();
|
|
152225
|
-
return
|
|
152314
|
+
return {
|
|
152315
|
+
message: `Committed and merged ${branch} -> ${targetBranch}, but failed to merge ${targetBranch} into ${baseBranch}: ${err.message}`,
|
|
152316
|
+
success: false
|
|
152317
|
+
};
|
|
152226
152318
|
}
|
|
152227
152319
|
}
|
|
152228
152320
|
spinner = interactive ? ora("Closing issue...").start() : void 0;
|
|
@@ -152237,9 +152329,12 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
|
|
|
152237
152329
|
}
|
|
152238
152330
|
setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
|
|
152239
152331
|
const mergePath = finalBranch === targetBranch ? `${branch} -> ${targetBranch}` : `${branch} -> ${targetBranch} -> ${finalBranch}`;
|
|
152240
|
-
return
|
|
152332
|
+
return {
|
|
152333
|
+
message: `Task #${issue2.number} committed and closed.
|
|
152241
152334
|
Merged: ${mergePath}
|
|
152242
|
-
Commit: "${commitMessage.trim()}"
|
|
152335
|
+
Commit: "${commitMessage.trim()}"`,
|
|
152336
|
+
success: true
|
|
152337
|
+
};
|
|
152243
152338
|
}
|
|
152244
152339
|
spinner = interactive ? ora("Checking for existing PR...").start() : void 0;
|
|
152245
152340
|
const existingPR = await getTaskPR(config2, issue2.number, branch);
|
|
@@ -152266,7 +152361,7 @@ ${review}` : ""
|
|
|
152266
152361
|
spinner?.stop();
|
|
152267
152362
|
} catch (err) {
|
|
152268
152363
|
spinner?.stop();
|
|
152269
|
-
return `Committed but PR creation failed: ${err.message}
|
|
152364
|
+
return { message: `Committed but PR creation failed: ${err.message}`, success: false };
|
|
152270
152365
|
}
|
|
152271
152366
|
}
|
|
152272
152367
|
spinner = interactive ? ora("Marking as in-review...").start() : void 0;
|
|
@@ -152275,16 +152370,22 @@ ${review}` : ""
|
|
|
152275
152370
|
spinner?.stop();
|
|
152276
152371
|
} catch (err) {
|
|
152277
152372
|
spinner?.stop();
|
|
152278
|
-
return
|
|
152373
|
+
return {
|
|
152374
|
+
message: interactive ? `PR ${existingPR ? "updated" : "created"} (${prUrl}) but failed to update label: ${err.message}` : `PR ${existingPR ? "updated" : "created"} (${prUrl}) but failed to update label: ${err.message}`,
|
|
152375
|
+
success: false
|
|
152376
|
+
};
|
|
152279
152377
|
}
|
|
152280
152378
|
setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
|
|
152281
|
-
return
|
|
152379
|
+
return {
|
|
152380
|
+
message: interactive ? `Task #${issue2.number} ${existingPR ? "re-submitted" : "submitted"}.
|
|
152282
152381
|
Commit: "${commitMessage.trim()}"
|
|
152283
152382
|
PR: ${prUrl}` : `Task #${issue2.number} ${existingPR ? "re-submitted" : "submitted"}.
|
|
152284
152383
|
Review:
|
|
152285
152384
|
${review}
|
|
152286
152385
|
Commit: "${commitMessage.trim()}"
|
|
152287
|
-
PR: ${prUrl}
|
|
152386
|
+
PR: ${prUrl}`,
|
|
152387
|
+
success: true
|
|
152388
|
+
};
|
|
152288
152389
|
}
|
|
152289
152390
|
function formatSubmitResult(result, notices) {
|
|
152290
152391
|
if (notices.length === 0) return result;
|
|
@@ -152313,6 +152414,7 @@ var definition = {
|
|
|
152313
152414
|
};
|
|
152314
152415
|
async function run(_input, config2) {
|
|
152315
152416
|
const currentBranch = await getCurrentBranch();
|
|
152417
|
+
const previousTaskState = getConfig().taskState;
|
|
152316
152418
|
const [username, currentIssueNumber] = await Promise.all([
|
|
152317
152419
|
getAuthenticatedUser(config2),
|
|
152318
152420
|
resolveIssueNumberFromBranch(config2, currentBranch)
|
|
@@ -152328,18 +152430,27 @@ async function run(_input, config2) {
|
|
|
152328
152430
|
}
|
|
152329
152431
|
let branch;
|
|
152330
152432
|
let notices;
|
|
152433
|
+
let restore;
|
|
152331
152434
|
try {
|
|
152332
|
-
({ branch, notices } = await prepareTaskContext(
|
|
152435
|
+
({ branch, notices, restore } = await prepareTaskContext(
|
|
152436
|
+
config2,
|
|
152437
|
+
selectedTask,
|
|
152438
|
+
username,
|
|
152439
|
+
currentBranch,
|
|
152440
|
+
true,
|
|
152441
|
+
void 0,
|
|
152442
|
+
previousTaskState
|
|
152443
|
+
));
|
|
152333
152444
|
} catch (err) {
|
|
152334
152445
|
return err.message;
|
|
152335
152446
|
}
|
|
152336
|
-
|
|
152337
|
-
|
|
152338
|
-
|
|
152339
|
-
);
|
|
152447
|
+
const outcome = await performSubmit(config2, selectedTask, branch, username, true);
|
|
152448
|
+
const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
|
|
152449
|
+
return formatSubmitResult(outcome.message, allNotices);
|
|
152340
152450
|
}
|
|
152341
152451
|
async function execute(input, config2) {
|
|
152342
152452
|
const currentBranch = await getCurrentBranch();
|
|
152453
|
+
const previousTaskState = getConfig().taskState;
|
|
152343
152454
|
const username = await getAuthenticatedUser(config2);
|
|
152344
152455
|
const requestedIssueNumber = input["issue_number"];
|
|
152345
152456
|
const carryCurrentWork = input["carry_current_work"];
|
|
@@ -152356,29 +152467,30 @@ async function execute(input, config2) {
|
|
|
152356
152467
|
}
|
|
152357
152468
|
let branch;
|
|
152358
152469
|
let notices;
|
|
152470
|
+
let restore;
|
|
152359
152471
|
try {
|
|
152360
|
-
({ branch, notices } = await prepareTaskContext(
|
|
152472
|
+
({ branch, notices, restore } = await prepareTaskContext(
|
|
152361
152473
|
config2,
|
|
152362
152474
|
issue2,
|
|
152363
152475
|
username,
|
|
152364
152476
|
currentBranch,
|
|
152365
152477
|
false,
|
|
152366
|
-
carryCurrentWork
|
|
152478
|
+
carryCurrentWork,
|
|
152479
|
+
previousTaskState
|
|
152367
152480
|
));
|
|
152368
152481
|
} catch (err) {
|
|
152369
152482
|
return err.message;
|
|
152370
152483
|
}
|
|
152371
|
-
|
|
152372
|
-
|
|
152373
|
-
|
|
152374
|
-
|
|
152375
|
-
|
|
152376
|
-
|
|
152377
|
-
|
|
152378
|
-
input["commit_message"]
|
|
152379
|
-
),
|
|
152380
|
-
notices
|
|
152484
|
+
const outcome = await performSubmit(
|
|
152485
|
+
config2,
|
|
152486
|
+
issue2,
|
|
152487
|
+
branch,
|
|
152488
|
+
username,
|
|
152489
|
+
false,
|
|
152490
|
+
input["commit_message"]
|
|
152381
152491
|
);
|
|
152492
|
+
const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
|
|
152493
|
+
return formatSubmitResult(outcome.message, allNotices);
|
|
152382
152494
|
}
|
|
152383
152495
|
var terminal2 = true;
|
|
152384
152496
|
|