terminalhire 0.40.10 → 0.40.12

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.
@@ -27717,13 +27717,15 @@ async function cmdPreview(arg, { json } = {}) {
27717
27717
  }
27718
27718
  async function cmdList(active) {
27719
27719
  const claims = await Promise.resolve().then(() => (init_claims(), claims_exports));
27720
- const list = claims.listClaims({ active });
27720
+ let list = claims.listClaims({ active });
27721
27721
  if (list.length === 0) {
27722
27722
  console.log(
27723
27723
  active ? "No active claims." : "No claims yet. Use `terminalhire claim record <bountyId>`."
27724
27724
  );
27725
27725
  return;
27726
27726
  }
27727
+ await syncFounderApprovals(claims, list);
27728
+ list = claims.listClaims({ active });
27727
27729
  console.log(`
27728
27730
  ${list.length} ${active ? "active " : ""}claim${list.length === 1 ? "" : "s"}:
27729
27731
  `);
@@ -27806,6 +27808,36 @@ async function fetchFounderApprovals(pushToken, fetchImpl = fetch) {
27806
27808
  return null;
27807
27809
  }
27808
27810
  }
27811
+ async function syncFounderApprovals(claimsModule, targets) {
27812
+ const founderTargets = targets.filter((c) => Boolean(c.approval));
27813
+ let approvalsChecked = false;
27814
+ let approvalsUnavailable = false;
27815
+ let pushToken = null;
27816
+ if (founderTargets.length > 0) {
27817
+ try {
27818
+ pushToken = await readPushTokenEnc();
27819
+ } catch {
27820
+ pushToken = null;
27821
+ }
27822
+ if (pushToken) {
27823
+ const approvals = await fetchFounderApprovals(pushToken);
27824
+ if (approvals) {
27825
+ approvalsChecked = true;
27826
+ const approved = new Set(approvals.claimIds);
27827
+ for (const c of founderTargets) {
27828
+ if (c.approval?.claimId && c.approval.state === "pending" && approved.has(c.approval.claimId)) {
27829
+ claimsModule.updateClaim(c.id, {
27830
+ approval: { ...c.approval, state: "granted" }
27831
+ });
27832
+ }
27833
+ }
27834
+ } else {
27835
+ approvalsUnavailable = true;
27836
+ }
27837
+ }
27838
+ }
27839
+ return { pushToken, approvalsChecked, approvalsUnavailable };
27840
+ }
27809
27841
  function founderClaimStanding(claim, approvalsChecked) {
27810
27842
  switch (claim.state) {
27811
27843
  case "merged":
@@ -27835,30 +27867,13 @@ async function cmdStatus(id) {
27835
27867
  const founderTargets = targets.filter((c) => Boolean(c.approval));
27836
27868
  let approvalsChecked = false;
27837
27869
  let approvalsUnavailable = false;
27870
+ let pushToken = null;
27838
27871
  if (founderTargets.length > 0) {
27839
- let pushToken = null;
27840
- try {
27841
- pushToken = await readPushTokenEnc();
27842
- } catch {
27843
- pushToken = null;
27844
- }
27845
- if (pushToken) {
27846
- const approvals = await fetchFounderApprovals(pushToken);
27847
- if (approvals) {
27848
- approvalsChecked = true;
27849
- const approved = new Set(approvals.claimIds);
27850
- for (const c of founderTargets) {
27851
- if (c.approval?.claimId && approved.has(c.approval.claimId)) {
27852
- claims.updateClaim(c.id, {
27853
- approval: { ...c.approval, state: "granted" }
27854
- });
27855
- }
27856
- }
27857
- targets = id ? [claims.findClaim(id)].filter(Boolean) : claims.listClaims();
27858
- } else {
27859
- approvalsUnavailable = true;
27860
- }
27861
- }
27872
+ const syncRes = await syncFounderApprovals(claims, targets);
27873
+ pushToken = syncRes.pushToken;
27874
+ approvalsChecked = syncRes.approvalsChecked;
27875
+ approvalsUnavailable = syncRes.approvalsUnavailable;
27876
+ targets = id ? [claims.findClaim(id)].filter(Boolean) : claims.listClaims();
27862
27877
  console.log("\n Founder claims:");
27863
27878
  for (const c of targets.filter((claim) => Boolean(claim.approval))) {
27864
27879
  console.log(` ${founderClaimStanding(c, approvalsChecked)} \u2014 ${c.title}`);
@@ -28168,6 +28183,8 @@ async function ensureForkExists(repoFullName, ghUser) {
28168
28183
  async function cmdStart(id, flags = {}) {
28169
28184
  const claims = await Promise.resolve().then(() => (init_claims(), claims_exports));
28170
28185
  if (!id) {
28186
+ let list = claims.listClaims({ active: true });
28187
+ await syncFounderApprovals(claims, list);
28171
28188
  const startable = claims.listClaims({ active: true }).filter((c) => c.state === "claimed");
28172
28189
  if (startable.length === 0) {
28173
28190
  console.log("No claims ready to start. Claim one first: terminalhire claim <ref>");
@@ -28185,11 +28202,15 @@ ${startable.length} claim${startable.length === 1 ? "" : "s"} ready to start:
28185
28202
  console.log("\nRun the command under the one you want to start.");
28186
28203
  return;
28187
28204
  }
28188
- const claim = claims.findClaim(id);
28205
+ let claim = claims.findClaim(id);
28189
28206
  if (!claim) {
28190
28207
  console.error(`terminalhire claim: no claim with id '${id}'.`);
28191
28208
  process.exit(1);
28192
28209
  }
28210
+ if (claim.approval?.state === "pending") {
28211
+ await syncFounderApprovals(claims, [claim]);
28212
+ claim = claims.findClaim(id);
28213
+ }
28193
28214
  if (claim.worktreePath) {
28194
28215
  let stillThere = false;
28195
28216
  try {
@@ -29876,6 +29897,7 @@ export {
29876
29897
  stakeDecision,
29877
29898
  startBranchFor,
29878
29899
  submitRefusalFor,
29900
+ syncFounderApprovals,
29879
29901
  terminalSafeInline,
29880
29902
  terminalSafeLines,
29881
29903
  watchRunsLoop,