@staff0rd/assist 0.1062.0 → 0.1063.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.
@@ -718,7 +718,7 @@ ${i}
718
718
  Comment: ${e.note}
719
719
  `})}function UL(t,e,r){console.error(`${t} rejected${e.reason?`: ${e.reason}`:"."}`);let i=e.comments??[];if(i.length>0){console.error(`
720
720
  The reviewer left ${i.length} comment${i.length===1?"":"s"} on the preview. Address each one, then re-run this command:
721
- `);for(let n of jL(i))console.error(n)}r&&console.error(r),process.exit(1)}function ML(t){if(!(typeof t!="object"||t===null||Array.isArray(t)))return Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function qL(t){if(Array.isArray(t))return t.flatMap(e=>{let{path:r,alt:i,group:n}=e??{};if(typeof r!="string"||r==="")return[];let o={path:r,alt:typeof i=="string"?i:""};return[typeof n=="string"&&n!==""?{...o,group:n}:o]})}function FL(t){if(Array.isArray(t))return t.flatMap(e=>{let{id:r,ticked:i,comment:n}=e??{};return typeof r!="string"?[]:[{id:r,ticked:i===!0,...typeof n=="string"&&n!==""?{comment:n}:{}}]})}function BL(t){return t==="LEFT"||t==="RIGHT"}function OQ(t){let e=t;return typeof e?.path=="string"&&Number.isInteger(e.startLine)&&Number.isInteger(e.endLine)&&typeof e.quote=="string"&&typeof e.note=="string"&&e.note.trim()!==""}function ZL(t){if(Array.isArray(t))return t.filter(OQ).map(({path:e,startLine:r,endLine:i,quote:n,note:o,startSide:s,side:a})=>({path:e,startLine:r,endLine:i,quote:n,note:o,...BL(s)?{startSide:s}:{},...BL(a)?{side:a}:{}}))}var AQ=["APPROVE","COMMENT","REQUEST_CHANGES"];function RQ(t){let e=t;if(!(typeof e?.topLeft!="string"||typeof e.bottomRight!="string"))return{topLeft:e.topLeft,bottomRight:e.bottomRight}}function KL(t){return t.decision!=="approve"&&t.decision!=="reject"?null:{decision:t.decision,reason:t.reason,comments:Array.isArray(t.comments)?t.comments:void 0,screenshots:qL(t.screenshots),body:typeof t.body=="string"?t.body:void 0,reviewAfter:t.reviewAfter===!0,announceAfter:t.announceAfter===!0,draft:typeof t.draft=="boolean"?t.draft:void 0,autoMerge:t.autoMerge===!0,autostart:t.autostart===!0,selection:RQ(t.selection),checklist:FL(t.checklist),reviewEvent:AQ.find(e=>e===t.reviewEvent),reviewComments:ZL(t.reviewComments),dismissed:t.dismissed===!0,answers:ML(t.answers)}}function VL(t,e){try{let r=JSON.parse(t);if(r.type==="error"&&(r.message??"").includes("pr-preview"))return{kind:"error",message:r.message??"pr-preview failed"};if(r.requestId!==e)return null;if(r.type==="pr-superseded")return{kind:"superseded"};if(r.type!=="pr-decision")return null;let i=KL(r);return i?{kind:"decision",decision:i}:null}catch{return null}}function GL(t){return new Promise((e,r)=>{Fi().then(i=>{let n=!1,o=(s,a)=>{n||(n=!0,i.destroy(),s?r(s):e(a))};Bi(i,s=>{let a=VL(s,t.requestId);a&&(a.kind==="error"?o(new Error(a.message)):a.kind==="superseded"?o(void 0,"superseded"):o(void 0,a.decision))}),i.on("error",s=>o(s)),i.on("close",()=>o(new Error("daemon closed before a decision was made"))),i.write(`${JSON.stringify({type:"pr-preview",...t})}
721
+ `);for(let n of jL(i))console.error(n)}r&&console.error(r),process.exit(1)}function ML(t){if(!(typeof t!="object"||t===null||Array.isArray(t)))return Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function qL(t){if(Array.isArray(t))return t.flatMap(e=>{let{path:r,alt:i,group:n}=e??{};if(typeof r!="string"||r==="")return[];let o={path:r,alt:typeof i=="string"?i:""};return[typeof n=="string"&&n!==""?{...o,group:n}:o]})}function FL(t){if(Array.isArray(t))return t.flatMap(e=>{let{id:r,ticked:i,comment:n,slice:o}=e??{};return typeof r!="string"?[]:[{id:r,ticked:i===!0,...typeof n=="string"&&n!==""?{comment:n}:{},...typeof o=="number"&&Number.isInteger(o)?{slice:o}:{}}]})}function BL(t){return t==="LEFT"||t==="RIGHT"}function OQ(t){let e=t;return typeof e?.path=="string"&&Number.isInteger(e.startLine)&&Number.isInteger(e.endLine)&&typeof e.quote=="string"&&typeof e.note=="string"&&e.note.trim()!==""}function ZL(t){if(Array.isArray(t))return t.filter(OQ).map(({path:e,startLine:r,endLine:i,quote:n,note:o,startSide:s,side:a})=>({path:e,startLine:r,endLine:i,quote:n,note:o,...BL(s)?{startSide:s}:{},...BL(a)?{side:a}:{}}))}var AQ=["APPROVE","COMMENT","REQUEST_CHANGES"];function RQ(t){let e=t;if(!(typeof e?.topLeft!="string"||typeof e.bottomRight!="string"))return{topLeft:e.topLeft,bottomRight:e.bottomRight}}function KL(t){return t.decision!=="approve"&&t.decision!=="reject"?null:{decision:t.decision,reason:t.reason,comments:Array.isArray(t.comments)?t.comments:void 0,screenshots:qL(t.screenshots),body:typeof t.body=="string"?t.body:void 0,reviewAfter:t.reviewAfter===!0,announceAfter:t.announceAfter===!0,draft:typeof t.draft=="boolean"?t.draft:void 0,autoMerge:t.autoMerge===!0,autostart:t.autostart===!0,selection:RQ(t.selection),checklist:FL(t.checklist),reviewEvent:AQ.find(e=>e===t.reviewEvent),reviewComments:ZL(t.reviewComments),dismissed:t.dismissed===!0,restart:t.restart===!0,answers:ML(t.answers)}}function VL(t,e){try{let r=JSON.parse(t);if(r.type==="error"&&(r.message??"").includes("pr-preview"))return{kind:"error",message:r.message??"pr-preview failed"};if(r.requestId!==e)return null;if(r.type==="pr-superseded")return{kind:"superseded"};if(r.type!=="pr-decision")return null;let i=KL(r);return i?{kind:"decision",decision:i}:null}catch{return null}}function GL(t){return new Promise((e,r)=>{Fi().then(i=>{let n=!1,o=(s,a)=>{n||(n=!0,i.destroy(),s?r(s):e(a))};Bi(i,s=>{let a=VL(s,t.requestId);a&&(a.kind==="error"?o(new Error(a.message)):a.kind==="superseded"?o(void 0,"superseded"):o(void 0,a.decision))}),i.on("error",s=>o(s)),i.on("close",()=>o(new Error("daemon closed before a decision was made"))),i.write(`${JSON.stringify({type:"pr-preview",...t})}
722
722
  `)},r)})}async function QL(t,e,r={}){console.log("Awaiting your approval in the assist web UI preview pane\u2026");let i;try{i=await GL(e)}catch(n){console.error(`Error: ${n instanceof Error?n.message:String(n)}`),process.exit(1)}return i==="superseded"&&(console.log("Superseded by a newer preview \u2014 no decision; ignore this result."),process.exit(0)),i.body!==void 0&&r.saveEditedBody?.(i.body),i.decision==="reject"&&!r.rejectIsOutcome&&UL(t,i,r.rejectionAdvice),i}async function JL(t,e,r){let i=process.env.ASSIST_SESSION_ID;process.env.ASSIST_SESSION!=="1"||!i||await QL("PR comment preview",{sessionId:i,requestId:DQ(),title:t,body:e,prNumber:r,kind:"pr-comment"})}function LQ(t){let e=t.toLowerCase();(e.includes("claude")||e.includes("opus"))&&(console.error('Error: Body must not contain "claude" or "opus"'),process.exit(1))}function WL(t){(!Number.isInteger(t)||t<1)&&(console.error("Error: Line must be a positive integer"),process.exit(1))}async function HL(t,e,r,i={}){let{startLine:n,skipPreview:o}=i;LQ(r),WL(e),n!==void 0&&WL(n);let s=n!==void 0?`${n}-${e}`:`${e}`;o||await JL(`Comment on ${t}:${s}`,r,null);try{let a=la();zL({prId:a,body:r,path:t,line:e,startLine:n}),console.log(`Added review comment on ${t}:${s}`)}catch(a){throw aa(a)&&(console.error("Error: GitHub CLI (gh) is not installed."),console.error("Install it from https://cli.github.com/"),process.exit(1)),a}}var YL="the reviewer";function Zi(t){return t.replace(/\bclaude\b/gi,YL).replace(/\bopus\b/gi,YL)}function zQ(t){let e=[],r=t.severity??"finding";return e.push(`**${r}: ${t.title}**`),t.impact&&e.push("",`Impact: ${t.impact}`),t.recommendation&&e.push("",`Recommendation: ${t.recommendation}`),Zi(e.join(`
723
723
  `))}async function XL(t){let e=0,r=[];for(let i of t){let n=zQ(i);try{await HL(i.file,i.line,n,{startLine:i.startLine,skipPreview:!0}),e++}catch(o){r.push(i);let s=o instanceof Error?o.message:String(o);console.error(`Failed to post comment on ${i.file}:${i.line}: ${s}`)}}return{posted:e,failed:r}}function ez(t,e,r){return hn(Zi(nr(t,e)),r)}var jQ="mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }";function g_(t){return ha(jQ,t)}function tz(t,e){return e.posted>0?g_(t):UQ(t,e)?!0:gn(t)}function UQ(t,e){return e.failed>0&&g_(t)}function rz(t,e){return[...t,...e.map(r=>({...r,reason:"comment-rejected"}))]}async function MQ(t){if(!t.prompt)return t.submit;await h_("waiting");try{return await En("Submit the pending review?",t.submit)}finally{await h_("running")}}async function nz(t,e,r,i){let{posted:n,failed:o}=await XL(t),s=o.length>0?`, ${o.length} failed`:"";console.log(`Posted ${n} comment(s)${s}.`);let a=rz(e,o),l=fn(a);if(n===0&&l.length===0&&!i.ciFooter)return{posted:0,submitted:!1};if(await MQ(i)){let u=tz(ez(r,a,i.ciFooter),{posted:n,failed:o.length});if(!u&&i.ciFooter)throw new Error("the review could not be submitted to the PR");return{posted:n,submitted:u}}return console.log("Leaving the review unsubmitted."),{posted:n,submitted:!1}}function qQ(){try{return ca()}catch(t){return console.error(`Error: could not confirm which PR this tree is on: ${t instanceof Error?t.message:String(t)}`),null}}function iz(t){let e=qQ();return e===t?!0:(console.error(`Error: this tree is now on ${e===null?"a branch with no open PR":`PR #${e}`}, not the reviewed PR #${t}; skipping the post and any chained sessions.`),!1)}function oz(t,e){let r=Zi(`${nr(t)}
724
724
 
@@ -1 +1 @@
1
- 0.1062.0
1
+ 0.1063.0