techunter 1.1.1 → 1.1.3

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.
Files changed (3) hide show
  1. package/dist/index.cjs +149 -38
  2. package/dist/mcp.cjs +148 -37
  3. 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 = [];
@@ -60580,6 +60612,7 @@ async function stageAllAndCommit(message) {
60580
60612
  console.log(source_default.dim(" Working tree clean \u2014 no new commit created, pushing existing commits."));
60581
60613
  }
60582
60614
  const branch = (await git.branch()).current;
60615
+ await syncBranchWithRemote(branch);
60583
60616
  await git.push("origin", branch, ["--set-upstream"]);
60584
60617
  }
60585
60618
  async function getRemoteHeadSha(baseBranch) {
@@ -147272,7 +147305,7 @@ async function chooseTaskForSubmit(config, username, currentIssueNumber) {
147272
147305
  }
147273
147306
  return ordered.find((task) => task.number === issueNumber) ?? null;
147274
147307
  }
147275
- async function prepareTaskContext(config, issue, username, currentBranch, interactive, carryCurrentWork) {
147308
+ async function prepareTaskContext(config, issue, username, currentBranch, interactive, carryCurrentWork, previousTaskState) {
147276
147309
  const targetBranch = getTaskBranch2(issue, username);
147277
147310
  if (currentBranch === targetBranch) {
147278
147311
  await setActiveTaskState(issue, targetBranch);
@@ -147315,6 +147348,7 @@ async function prepareTaskContext(config, issue, username, currentBranch, intera
147315
147348
  }
147316
147349
  }
147317
147350
  const notices = [];
147351
+ const shouldRestoreOriginalContext = action === "switch";
147318
147352
  let stashed = false;
147319
147353
  let switched = false;
147320
147354
  let switchedBranch = targetBranch;
@@ -147337,11 +147371,17 @@ async function prepareTaskContext(config, issue, username, currentBranch, intera
147337
147371
  stashRestoredOnTarget = true;
147338
147372
  notices.push(`Restored your unsaved work on ${switchedBranch}.`);
147339
147373
  } else if (stashed) {
147340
- notices.push(
147341
- `Saved your unsaved work from ${currentBranch}. Return there later and run \`git stash pop\` to restore it.`
147342
- );
147374
+ notices.push(`Saved your unsaved work from ${currentBranch} while preparing #${issue.number}.`);
147343
147375
  }
147344
- return { branch: switchedBranch, notices };
147376
+ return {
147377
+ branch: switchedBranch,
147378
+ notices,
147379
+ restore: shouldRestoreOriginalContext ? {
147380
+ originalBranch: currentBranch,
147381
+ restoreStash: stashed && !stashRestoredOnTarget,
147382
+ previousTaskState: previousTaskState?.activeBranch === currentBranch ? previousTaskState : void 0
147383
+ } : void 0
147384
+ };
147345
147385
  } catch (err) {
147346
147386
  const rollbackNotices = [];
147347
147387
  if (mergeAttempted) {
@@ -147372,6 +147412,48 @@ ${rollbackNotices.join("\n")}` : "";
147372
147412
  throw new Error(`Could not prepare task #${issue.number}: ${err.message}${details}`);
147373
147413
  }
147374
147414
  }
147415
+ async function restorePreviousContext(context) {
147416
+ const notices = [];
147417
+ try {
147418
+ await switchToBranchOrCreate(context.originalBranch);
147419
+ notices.push(`Returned to ${context.originalBranch}.`);
147420
+ } catch (err) {
147421
+ notices.push(`Could not return to ${context.originalBranch} automatically: ${err.message}`);
147422
+ if (context.restoreStash) {
147423
+ notices.push("Your stashed work was kept unchanged.");
147424
+ }
147425
+ return notices;
147426
+ }
147427
+ try {
147428
+ const syncResult = await syncBranchWithRemote(context.originalBranch);
147429
+ if (syncResult.mode === "fast-forward") {
147430
+ notices.push(`Fast-forwarded ${context.originalBranch} to the latest origin/${context.originalBranch}.`);
147431
+ } else if (syncResult.mode === "merge") {
147432
+ notices.push(`Merged the latest origin/${context.originalBranch} into ${context.originalBranch} before restoring your work.`);
147433
+ }
147434
+ } catch (err) {
147435
+ notices.push(`Could not sync ${context.originalBranch} with origin/${context.originalBranch}: ${err.message}`);
147436
+ if (context.restoreStash) {
147437
+ notices.push("Your stashed work was not restored because the branch needs manual sync first.");
147438
+ }
147439
+ if (context.previousTaskState) {
147440
+ setConfig({ taskState: context.previousTaskState });
147441
+ }
147442
+ return notices;
147443
+ }
147444
+ if (context.restoreStash) {
147445
+ try {
147446
+ await stashPop();
147447
+ notices.push(`Restored your stashed work on ${context.originalBranch}.`);
147448
+ } catch (err) {
147449
+ notices.push(`Could not restore your stashed work automatically on ${context.originalBranch}: ${err.message}`);
147450
+ }
147451
+ }
147452
+ if (context.previousTaskState) {
147453
+ setConfig({ taskState: context.previousTaskState });
147454
+ }
147455
+ return notices;
147456
+ }
147375
147457
  async function buildDiffForIssue(issue, branch) {
147376
147458
  const taskState = getConfig().taskState;
147377
147459
  if (taskState?.activeIssueNumber === issue.number && taskState?.activeBranch === branch && taskState.baseCommit) {
@@ -147392,8 +147474,11 @@ async function performSubmit(config, issue, branch, username, interactive, commi
147392
147474
  const openSubtaskNumbers = await getOpenSubtasks(config, branch);
147393
147475
  spinner?.stop();
147394
147476
  if (openSubtaskNumbers.length > 0) {
147395
- return interactive ? `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open:
147396
- ` + 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(", ");
147477
+ return {
147478
+ message: interactive ? `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open:
147479
+ ` + 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(", "),
147480
+ success: false
147481
+ };
147397
147482
  }
147398
147483
  let review = "";
147399
147484
  if (!isSelfSubmit) {
@@ -147426,9 +147511,9 @@ async function performSubmit(config, issue, branch, username, interactive, commi
147426
147511
  ]
147427
147512
  });
147428
147513
  } catch {
147429
- return "Submit cancelled.";
147514
+ return { message: "Submit cancelled.", success: false };
147430
147515
  }
147431
- if (!shouldProceed) return "Submit cancelled by user.";
147516
+ if (!shouldProceed) return { message: "Submit cancelled by user.", success: false };
147432
147517
  }
147433
147518
  let commitMessage = commitMessageOverride?.trim();
147434
147519
  if (!commitMessage) {
@@ -147439,9 +147524,9 @@ async function performSubmit(config, issue, branch, username, interactive, commi
147439
147524
  default: `complete: ${issue.title}`
147440
147525
  });
147441
147526
  } catch {
147442
- return "Submit cancelled.";
147527
+ return { message: "Submit cancelled.", success: false };
147443
147528
  }
147444
- if (!commitMessage.trim()) return "Submit cancelled.";
147529
+ if (!commitMessage.trim()) return { message: "Submit cancelled.", success: false };
147445
147530
  } else {
147446
147531
  commitMessage = `complete: ${issue.title}`;
147447
147532
  }
@@ -147452,7 +147537,7 @@ async function performSubmit(config, issue, branch, username, interactive, commi
147452
147537
  spinner?.stop();
147453
147538
  } catch (err) {
147454
147539
  spinner?.stop();
147455
- return `Commit failed: ${err.message}`;
147540
+ return { message: `Push failed: ${err.message}`, success: false };
147456
147541
  }
147457
147542
  if (isSelfSubmit) {
147458
147543
  const baseBranch = config.baseBranch ?? "main";
@@ -147465,7 +147550,10 @@ async function performSubmit(config, issue, branch, username, interactive, commi
147465
147550
  spinner?.stop();
147466
147551
  } catch (err) {
147467
147552
  spinner?.stop();
147468
- return `Committed and pushed to ${branch}, but failed to merge into ${targetBranch}: ${err.message}`;
147553
+ return {
147554
+ message: `Committed and pushed to ${branch}, but failed to merge into ${targetBranch}: ${err.message}`,
147555
+ success: false
147556
+ };
147469
147557
  }
147470
147558
  }
147471
147559
  if (!isTaskBranch(targetBranch) && targetBranch !== baseBranch) {
@@ -147476,7 +147564,10 @@ async function performSubmit(config, issue, branch, username, interactive, commi
147476
147564
  spinner?.stop();
147477
147565
  } catch (err) {
147478
147566
  spinner?.stop();
147479
- return `Committed and merged ${branch} -> ${targetBranch}, but failed to merge ${targetBranch} into ${baseBranch}: ${err.message}`;
147567
+ return {
147568
+ message: `Committed and merged ${branch} -> ${targetBranch}, but failed to merge ${targetBranch} into ${baseBranch}: ${err.message}`,
147569
+ success: false
147570
+ };
147480
147571
  }
147481
147572
  }
147482
147573
  spinner = interactive ? ora("Closing issue...").start() : void 0;
@@ -147491,9 +147582,12 @@ async function performSubmit(config, issue, branch, username, interactive, commi
147491
147582
  }
147492
147583
  setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
147493
147584
  const mergePath = finalBranch === targetBranch ? `${branch} -> ${targetBranch}` : `${branch} -> ${targetBranch} -> ${finalBranch}`;
147494
- return `Task #${issue.number} committed and closed.
147585
+ return {
147586
+ message: `Task #${issue.number} committed and closed.
147495
147587
  Merged: ${mergePath}
147496
- Commit: "${commitMessage.trim()}"`;
147588
+ Commit: "${commitMessage.trim()}"`,
147589
+ success: true
147590
+ };
147497
147591
  }
147498
147592
  spinner = interactive ? ora("Checking for existing PR...").start() : void 0;
147499
147593
  const existingPR = await getTaskPR(config, issue.number, branch);
@@ -147520,7 +147614,7 @@ ${review}` : ""
147520
147614
  spinner?.stop();
147521
147615
  } catch (err) {
147522
147616
  spinner?.stop();
147523
- return `Committed but PR creation failed: ${err.message}`;
147617
+ return { message: `Committed but PR creation failed: ${err.message}`, success: false };
147524
147618
  }
147525
147619
  }
147526
147620
  spinner = interactive ? ora("Marking as in-review...").start() : void 0;
@@ -147529,16 +147623,22 @@ ${review}` : ""
147529
147623
  spinner?.stop();
147530
147624
  } catch (err) {
147531
147625
  spinner?.stop();
147532
- return 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}`;
147626
+ return {
147627
+ 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}`,
147628
+ success: false
147629
+ };
147533
147630
  }
147534
147631
  setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
147535
- return interactive ? `Task #${issue.number} ${existingPR ? "re-submitted" : "submitted"}.
147632
+ return {
147633
+ message: interactive ? `Task #${issue.number} ${existingPR ? "re-submitted" : "submitted"}.
147536
147634
  Commit: "${commitMessage.trim()}"
147537
147635
  PR: ${prUrl}` : `Task #${issue.number} ${existingPR ? "re-submitted" : "submitted"}.
147538
147636
  Review:
147539
147637
  ${review}
147540
147638
  Commit: "${commitMessage.trim()}"
147541
- PR: ${prUrl}`;
147639
+ PR: ${prUrl}`,
147640
+ success: true
147641
+ };
147542
147642
  }
147543
147643
  function formatSubmitResult(result, notices) {
147544
147644
  if (notices.length === 0) return result;
@@ -147567,6 +147667,7 @@ var definition = {
147567
147667
  };
147568
147668
  async function run(_input, config) {
147569
147669
  const currentBranch = await getCurrentBranch();
147670
+ const previousTaskState = getConfig().taskState;
147570
147671
  const [username, currentIssueNumber] = await Promise.all([
147571
147672
  getAuthenticatedUser(config),
147572
147673
  resolveIssueNumberFromBranch(config, currentBranch)
@@ -147582,18 +147683,27 @@ async function run(_input, config) {
147582
147683
  }
147583
147684
  let branch;
147584
147685
  let notices;
147686
+ let restore;
147585
147687
  try {
147586
- ({ branch, notices } = await prepareTaskContext(config, selectedTask, username, currentBranch, true));
147688
+ ({ branch, notices, restore } = await prepareTaskContext(
147689
+ config,
147690
+ selectedTask,
147691
+ username,
147692
+ currentBranch,
147693
+ true,
147694
+ void 0,
147695
+ previousTaskState
147696
+ ));
147587
147697
  } catch (err) {
147588
147698
  return err.message;
147589
147699
  }
147590
- return formatSubmitResult(
147591
- await performSubmit(config, selectedTask, branch, username, true),
147592
- notices
147593
- );
147700
+ const outcome = await performSubmit(config, selectedTask, branch, username, true);
147701
+ const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
147702
+ return formatSubmitResult(outcome.message, allNotices);
147594
147703
  }
147595
147704
  async function execute(input, config) {
147596
147705
  const currentBranch = await getCurrentBranch();
147706
+ const previousTaskState = getConfig().taskState;
147597
147707
  const username = await getAuthenticatedUser(config);
147598
147708
  const requestedIssueNumber = input["issue_number"];
147599
147709
  const carryCurrentWork = input["carry_current_work"];
@@ -147610,29 +147720,30 @@ async function execute(input, config) {
147610
147720
  }
147611
147721
  let branch;
147612
147722
  let notices;
147723
+ let restore;
147613
147724
  try {
147614
- ({ branch, notices } = await prepareTaskContext(
147725
+ ({ branch, notices, restore } = await prepareTaskContext(
147615
147726
  config,
147616
147727
  issue,
147617
147728
  username,
147618
147729
  currentBranch,
147619
147730
  false,
147620
- carryCurrentWork
147731
+ carryCurrentWork,
147732
+ previousTaskState
147621
147733
  ));
147622
147734
  } catch (err) {
147623
147735
  return err.message;
147624
147736
  }
147625
- return formatSubmitResult(
147626
- await performSubmit(
147627
- config,
147628
- issue,
147629
- branch,
147630
- username,
147631
- false,
147632
- input["commit_message"]
147633
- ),
147634
- notices
147737
+ const outcome = await performSubmit(
147738
+ config,
147739
+ issue,
147740
+ branch,
147741
+ username,
147742
+ false,
147743
+ input["commit_message"]
147635
147744
  );
147745
+ const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
147746
+ return formatSubmitResult(outcome.message, allNotices);
147636
147747
  }
147637
147748
  var terminal2 = true;
147638
147749
 
@@ -150894,7 +151005,7 @@ async function startAutoUpdate(currentVersion) {
150894
151005
  }
150895
151006
 
150896
151007
  // src/index.ts
150897
- var version = "1.1.1";
151008
+ var version = "1.1.3";
150898
151009
  var SLASH_NAMES = [
150899
151010
  "/help",
150900
151011
  "/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 = [];
@@ -56795,6 +56827,7 @@ async function stageAllAndCommit(message) {
56795
56827
  console.log(source_default.dim(" Working tree clean \u2014 no new commit created, pushing existing commits."));
56796
56828
  }
56797
56829
  const branch = (await git.branch()).current;
56830
+ await syncBranchWithRemote(branch);
56798
56831
  await git.push("origin", branch, ["--set-upstream"]);
56799
56832
  }
56800
56833
  async function getRemoteHeadSha(baseBranch) {
@@ -152018,7 +152051,7 @@ async function chooseTaskForSubmit(config2, username, currentIssueNumber) {
152018
152051
  }
152019
152052
  return ordered.find((task) => task.number === issueNumber) ?? null;
152020
152053
  }
152021
- async function prepareTaskContext(config2, issue2, username, currentBranch, interactive, carryCurrentWork) {
152054
+ async function prepareTaskContext(config2, issue2, username, currentBranch, interactive, carryCurrentWork, previousTaskState) {
152022
152055
  const targetBranch = getTaskBranch2(issue2, username);
152023
152056
  if (currentBranch === targetBranch) {
152024
152057
  await setActiveTaskState(issue2, targetBranch);
@@ -152061,6 +152094,7 @@ async function prepareTaskContext(config2, issue2, username, currentBranch, inte
152061
152094
  }
152062
152095
  }
152063
152096
  const notices = [];
152097
+ const shouldRestoreOriginalContext = action === "switch";
152064
152098
  let stashed = false;
152065
152099
  let switched = false;
152066
152100
  let switchedBranch = targetBranch;
@@ -152083,11 +152117,17 @@ async function prepareTaskContext(config2, issue2, username, currentBranch, inte
152083
152117
  stashRestoredOnTarget = true;
152084
152118
  notices.push(`Restored your unsaved work on ${switchedBranch}.`);
152085
152119
  } else if (stashed) {
152086
- notices.push(
152087
- `Saved your unsaved work from ${currentBranch}. Return there later and run \`git stash pop\` to restore it.`
152088
- );
152120
+ notices.push(`Saved your unsaved work from ${currentBranch} while preparing #${issue2.number}.`);
152089
152121
  }
152090
- return { branch: switchedBranch, notices };
152122
+ return {
152123
+ branch: switchedBranch,
152124
+ notices,
152125
+ restore: shouldRestoreOriginalContext ? {
152126
+ originalBranch: currentBranch,
152127
+ restoreStash: stashed && !stashRestoredOnTarget,
152128
+ previousTaskState: previousTaskState?.activeBranch === currentBranch ? previousTaskState : void 0
152129
+ } : void 0
152130
+ };
152091
152131
  } catch (err) {
152092
152132
  const rollbackNotices = [];
152093
152133
  if (mergeAttempted) {
@@ -152118,6 +152158,48 @@ ${rollbackNotices.join("\n")}` : "";
152118
152158
  throw new Error(`Could not prepare task #${issue2.number}: ${err.message}${details}`);
152119
152159
  }
152120
152160
  }
152161
+ async function restorePreviousContext(context) {
152162
+ const notices = [];
152163
+ try {
152164
+ await switchToBranchOrCreate(context.originalBranch);
152165
+ notices.push(`Returned to ${context.originalBranch}.`);
152166
+ } catch (err) {
152167
+ notices.push(`Could not return to ${context.originalBranch} automatically: ${err.message}`);
152168
+ if (context.restoreStash) {
152169
+ notices.push("Your stashed work was kept unchanged.");
152170
+ }
152171
+ return notices;
152172
+ }
152173
+ try {
152174
+ const syncResult = await syncBranchWithRemote(context.originalBranch);
152175
+ if (syncResult.mode === "fast-forward") {
152176
+ notices.push(`Fast-forwarded ${context.originalBranch} to the latest origin/${context.originalBranch}.`);
152177
+ } else if (syncResult.mode === "merge") {
152178
+ notices.push(`Merged the latest origin/${context.originalBranch} into ${context.originalBranch} before restoring your work.`);
152179
+ }
152180
+ } catch (err) {
152181
+ notices.push(`Could not sync ${context.originalBranch} with origin/${context.originalBranch}: ${err.message}`);
152182
+ if (context.restoreStash) {
152183
+ notices.push("Your stashed work was not restored because the branch needs manual sync first.");
152184
+ }
152185
+ if (context.previousTaskState) {
152186
+ setConfig({ taskState: context.previousTaskState });
152187
+ }
152188
+ return notices;
152189
+ }
152190
+ if (context.restoreStash) {
152191
+ try {
152192
+ await stashPop();
152193
+ notices.push(`Restored your stashed work on ${context.originalBranch}.`);
152194
+ } catch (err) {
152195
+ notices.push(`Could not restore your stashed work automatically on ${context.originalBranch}: ${err.message}`);
152196
+ }
152197
+ }
152198
+ if (context.previousTaskState) {
152199
+ setConfig({ taskState: context.previousTaskState });
152200
+ }
152201
+ return notices;
152202
+ }
152121
152203
  async function buildDiffForIssue(issue2, branch) {
152122
152204
  const taskState = getConfig().taskState;
152123
152205
  if (taskState?.activeIssueNumber === issue2.number && taskState?.activeBranch === branch && taskState.baseCommit) {
@@ -152138,8 +152220,11 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
152138
152220
  const openSubtaskNumbers = await getOpenSubtasks(config2, branch);
152139
152221
  spinner?.stop();
152140
152222
  if (openSubtaskNumbers.length > 0) {
152141
- return interactive ? `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open:
152142
- ` + 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(", ");
152223
+ return {
152224
+ message: interactive ? `Cannot submit: ${openSubtaskNumbers.length} sub-task(s) still open:
152225
+ ` + 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(", "),
152226
+ success: false
152227
+ };
152143
152228
  }
152144
152229
  let review = "";
152145
152230
  if (!isSelfSubmit) {
@@ -152172,9 +152257,9 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
152172
152257
  ]
152173
152258
  });
152174
152259
  } catch {
152175
- return "Submit cancelled.";
152260
+ return { message: "Submit cancelled.", success: false };
152176
152261
  }
152177
- if (!shouldProceed) return "Submit cancelled by user.";
152262
+ if (!shouldProceed) return { message: "Submit cancelled by user.", success: false };
152178
152263
  }
152179
152264
  let commitMessage = commitMessageOverride?.trim();
152180
152265
  if (!commitMessage) {
@@ -152185,9 +152270,9 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
152185
152270
  default: `complete: ${issue2.title}`
152186
152271
  });
152187
152272
  } catch {
152188
- return "Submit cancelled.";
152273
+ return { message: "Submit cancelled.", success: false };
152189
152274
  }
152190
- if (!commitMessage.trim()) return "Submit cancelled.";
152275
+ if (!commitMessage.trim()) return { message: "Submit cancelled.", success: false };
152191
152276
  } else {
152192
152277
  commitMessage = `complete: ${issue2.title}`;
152193
152278
  }
@@ -152198,7 +152283,7 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
152198
152283
  spinner?.stop();
152199
152284
  } catch (err) {
152200
152285
  spinner?.stop();
152201
- return `Commit failed: ${err.message}`;
152286
+ return { message: `Push failed: ${err.message}`, success: false };
152202
152287
  }
152203
152288
  if (isSelfSubmit) {
152204
152289
  const baseBranch = config2.baseBranch ?? "main";
@@ -152211,7 +152296,10 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
152211
152296
  spinner?.stop();
152212
152297
  } catch (err) {
152213
152298
  spinner?.stop();
152214
- return `Committed and pushed to ${branch}, but failed to merge into ${targetBranch}: ${err.message}`;
152299
+ return {
152300
+ message: `Committed and pushed to ${branch}, but failed to merge into ${targetBranch}: ${err.message}`,
152301
+ success: false
152302
+ };
152215
152303
  }
152216
152304
  }
152217
152305
  if (!isTaskBranch(targetBranch) && targetBranch !== baseBranch) {
@@ -152222,7 +152310,10 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
152222
152310
  spinner?.stop();
152223
152311
  } catch (err) {
152224
152312
  spinner?.stop();
152225
- return `Committed and merged ${branch} -> ${targetBranch}, but failed to merge ${targetBranch} into ${baseBranch}: ${err.message}`;
152313
+ return {
152314
+ message: `Committed and merged ${branch} -> ${targetBranch}, but failed to merge ${targetBranch} into ${baseBranch}: ${err.message}`,
152315
+ success: false
152316
+ };
152226
152317
  }
152227
152318
  }
152228
152319
  spinner = interactive ? ora("Closing issue...").start() : void 0;
@@ -152237,9 +152328,12 @@ async function performSubmit(config2, issue2, branch, username, interactive, com
152237
152328
  }
152238
152329
  setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
152239
152330
  const mergePath = finalBranch === targetBranch ? `${branch} -> ${targetBranch}` : `${branch} -> ${targetBranch} -> ${finalBranch}`;
152240
- return `Task #${issue2.number} committed and closed.
152331
+ return {
152332
+ message: `Task #${issue2.number} committed and closed.
152241
152333
  Merged: ${mergePath}
152242
- Commit: "${commitMessage.trim()}"`;
152334
+ Commit: "${commitMessage.trim()}"`,
152335
+ success: true
152336
+ };
152243
152337
  }
152244
152338
  spinner = interactive ? ora("Checking for existing PR...").start() : void 0;
152245
152339
  const existingPR = await getTaskPR(config2, issue2.number, branch);
@@ -152266,7 +152360,7 @@ ${review}` : ""
152266
152360
  spinner?.stop();
152267
152361
  } catch (err) {
152268
152362
  spinner?.stop();
152269
- return `Committed but PR creation failed: ${err.message}`;
152363
+ return { message: `Committed but PR creation failed: ${err.message}`, success: false };
152270
152364
  }
152271
152365
  }
152272
152366
  spinner = interactive ? ora("Marking as in-review...").start() : void 0;
@@ -152275,16 +152369,22 @@ ${review}` : ""
152275
152369
  spinner?.stop();
152276
152370
  } catch (err) {
152277
152371
  spinner?.stop();
152278
- return 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}`;
152372
+ return {
152373
+ 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}`,
152374
+ success: false
152375
+ };
152279
152376
  }
152280
152377
  setConfig({ taskState: { activeIssueNumber: void 0, baseCommit: void 0, activeBranch: void 0 } });
152281
- return interactive ? `Task #${issue2.number} ${existingPR ? "re-submitted" : "submitted"}.
152378
+ return {
152379
+ message: interactive ? `Task #${issue2.number} ${existingPR ? "re-submitted" : "submitted"}.
152282
152380
  Commit: "${commitMessage.trim()}"
152283
152381
  PR: ${prUrl}` : `Task #${issue2.number} ${existingPR ? "re-submitted" : "submitted"}.
152284
152382
  Review:
152285
152383
  ${review}
152286
152384
  Commit: "${commitMessage.trim()}"
152287
- PR: ${prUrl}`;
152385
+ PR: ${prUrl}`,
152386
+ success: true
152387
+ };
152288
152388
  }
152289
152389
  function formatSubmitResult(result, notices) {
152290
152390
  if (notices.length === 0) return result;
@@ -152313,6 +152413,7 @@ var definition = {
152313
152413
  };
152314
152414
  async function run(_input, config2) {
152315
152415
  const currentBranch = await getCurrentBranch();
152416
+ const previousTaskState = getConfig().taskState;
152316
152417
  const [username, currentIssueNumber] = await Promise.all([
152317
152418
  getAuthenticatedUser(config2),
152318
152419
  resolveIssueNumberFromBranch(config2, currentBranch)
@@ -152328,18 +152429,27 @@ async function run(_input, config2) {
152328
152429
  }
152329
152430
  let branch;
152330
152431
  let notices;
152432
+ let restore;
152331
152433
  try {
152332
- ({ branch, notices } = await prepareTaskContext(config2, selectedTask, username, currentBranch, true));
152434
+ ({ branch, notices, restore } = await prepareTaskContext(
152435
+ config2,
152436
+ selectedTask,
152437
+ username,
152438
+ currentBranch,
152439
+ true,
152440
+ void 0,
152441
+ previousTaskState
152442
+ ));
152333
152443
  } catch (err) {
152334
152444
  return err.message;
152335
152445
  }
152336
- return formatSubmitResult(
152337
- await performSubmit(config2, selectedTask, branch, username, true),
152338
- notices
152339
- );
152446
+ const outcome = await performSubmit(config2, selectedTask, branch, username, true);
152447
+ const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
152448
+ return formatSubmitResult(outcome.message, allNotices);
152340
152449
  }
152341
152450
  async function execute(input, config2) {
152342
152451
  const currentBranch = await getCurrentBranch();
152452
+ const previousTaskState = getConfig().taskState;
152343
152453
  const username = await getAuthenticatedUser(config2);
152344
152454
  const requestedIssueNumber = input["issue_number"];
152345
152455
  const carryCurrentWork = input["carry_current_work"];
@@ -152356,29 +152466,30 @@ async function execute(input, config2) {
152356
152466
  }
152357
152467
  let branch;
152358
152468
  let notices;
152469
+ let restore;
152359
152470
  try {
152360
- ({ branch, notices } = await prepareTaskContext(
152471
+ ({ branch, notices, restore } = await prepareTaskContext(
152361
152472
  config2,
152362
152473
  issue2,
152363
152474
  username,
152364
152475
  currentBranch,
152365
152476
  false,
152366
- carryCurrentWork
152477
+ carryCurrentWork,
152478
+ previousTaskState
152367
152479
  ));
152368
152480
  } catch (err) {
152369
152481
  return err.message;
152370
152482
  }
152371
- return formatSubmitResult(
152372
- await performSubmit(
152373
- config2,
152374
- issue2,
152375
- branch,
152376
- username,
152377
- false,
152378
- input["commit_message"]
152379
- ),
152380
- notices
152483
+ const outcome = await performSubmit(
152484
+ config2,
152485
+ issue2,
152486
+ branch,
152487
+ username,
152488
+ false,
152489
+ input["commit_message"]
152381
152490
  );
152491
+ const allNotices = outcome.success && restore ? notices.concat(await restorePreviousContext(restore)) : notices;
152492
+ return formatSubmitResult(outcome.message, allNotices);
152382
152493
  }
152383
152494
  var terminal2 = true;
152384
152495
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "techunter",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "AI-powered task distribution CLI for development teams",
5
5
  "author": "Techunter Contributors",
6
6
  "license": "MIT",