@staff0rd/assist 0.900.2 → 0.902.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.
@@ -438,7 +438,7 @@ The reviewer left ${i.length} comment${i.length===1?"":"s"} on the preview. Addr
438
438
  `)},r)})}async function S1(e,t,r={}){console.log("Awaiting your approval in the assist web UI preview pane\u2026");let i;try{i=await x1(t)}catch(n){console.error(`Error: ${n instanceof Error?n.message:String(n)}`),process.exit(1)}return i.body!==void 0&&r.saveEditedBody?.(i.body),i.decision==="reject"&&!r.rejectIsOutcome&&h1(e,i,r.rejectionAdvice),i}async function _1(e,t,r){let i=process.env.ASSIST_SESSION_ID;process.env.ASSIST_SESSION!=="1"||!i||await S1("PR comment preview",{sessionId:i,requestId:jU(),title:e,body:t,prNumber:r,kind:"pr-comment"})}function UU(e){let t=e.toLowerCase();(t.includes("claude")||t.includes("opus"))&&(console.error('Error: Body must not contain "claude" or "opus"'),process.exit(1))}function k1(e){(!Number.isInteger(e)||e<1)&&(console.error("Error: Line must be a positive integer"),process.exit(1))}async function I1(e,t,r,i={}){let{startLine:n,skipPreview:o}=i;UU(r),k1(t),n!==void 0&&k1(n);let s=n!==void 0?`${n}-${t}`:`${t}`;o||await _1(`Comment on ${e}:${s}`,r,null);try{let a=Fi();p1({prId:a,body:r,path:e,line:t,startLine:n}),console.log(`Added review comment on ${e}:${s}`)}catch(a){throw Mi(a)&&(console.error("Error: GitHub CLI (gh) is not installed."),console.error("Install it from https://cli.github.com/"),process.exit(1)),a}}var P1="the reviewer";function on(e){return e.replace(/\bclaude\b/gi,P1).replace(/\bopus\b/gi,P1)}function LU(e){let t=[],r=e.severity??"finding";return t.push(`**${r}: ${e.title}**`),e.impact&&t.push("",`Impact: ${e.impact}`),e.recommendation&&t.push("",`Recommendation: ${e.recommendation}`),on(t.join(`
439
439
  `))}async function C1(e){let t=0,r=[];for(let i of e){let n=LU(i);try{await I1(i.file,i.line,n,{startLine:i.startLine,skipPreview:!0}),t++}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:t,failed:r}}function O1(e,t,r){return er(on(tt(e,t)),r)}var MU="mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }";function qg(e){return Ji(MU,e)}function E1(e,t){return t.posted>0?qg(e):FU(e,t)?!0:tr(e)}function FU(e,t){return t.failed>0&&qg(e)}function T1(e,t){return[...e,...t.map(r=>({...r,reason:"comment-rejected"}))]}async function qU(e){if(!e.prompt)return e.submit;await Fg("waiting");try{return await fr("Submit the pending review?",e.submit)}finally{await Fg("running")}}async function R1(e,t,r,i){let{posted:n,failed:o}=await C1(e),s=o.length>0?`, ${o.length} failed`:"";console.log(`Posted ${n} comment(s)${s}.`);let a=T1(t,o),l=Yt(a);if(n===0&&l.length===0&&!i.ciFooter)return{posted:0,submitted:!1};if(await qU(i)){let u=E1(O1(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 ZU(){try{return qi()}catch(e){return console.error(`Error: could not confirm which PR this tree is on: ${e instanceof Error?e.message:String(e)}`),null}}function N1(e){let t=ZU();return t===e?!0:(console.error(`Error: this tree is now on ${t===null?"a branch with no open PR":`PR #${t}`}, not the reviewed PR #${e}; skipping the post and any chained sessions.`),!1)}function A1(e,t){let r=on(`${tt(e)}
440
440
 
441
- No findings were raised.`);return tr(er(r,t))}function z1(e,t){if(!t)return{posted:0,submitted:!1};if(!A1(e,t))throw new Error("the review could not be submitted to the PR");return{posted:0,submitted:!0}}function D1(e,t){let r=[];return e>0&&r.push(`${e} line comment(s)`),t>0&&r.push(`${t} finding(s) in the review body`),r.join(" and ")}var VU={posted:0,submitted:!1};async function KU(e,t,r){return r.prompt?fr(`Post ${t} to PR #${e}?`,!1):!0}async function GU(e,t,r){let i=BU(t,"utf8"),{inDiff:n,unanchored:o}=Ki(i,e),s=Yt(o);if(n.length===0&&s.length===0)return z1(i,r.ciFooter);let a=D1(n.length,s.length);return console.log(`Found PR #${e.prNumber} with ${a} to post.`),await KU(e.prNumber,a,r)?R1(n,o,i,r):(console.log("Skipped posting."),VU)}async function j1(e,t,r){if(!N1(t.prNumber))return;let i=await GU(t,e,r);await l1(t.prNumber,i,r)}import{mkdirSync as JU,writeFileSync as WU}from"node:fs";import{dirname as HU}from"node:path";var Vg="assist sessions set-status";function Zg(e){return`${Vg} running --source ${e}`}function YU(e){return`${Vg} waiting --source ${e}`}function Bg(e){return`${Vg} waiting --source ${e} --ack`}function Ht(e,t){let r=[{type:"command",command:e}];return[t==null?{hooks:r}:{matcher:t,hooks:r}]}var U1="AskUserQuestion",XU=`^(?!${U1}$).*`,QU={hooks:{UserPromptSubmit:Ht(Zg("prompt")),PreToolUse:[...Ht(YU("pretool"),U1),...Ht(Zg("pretool"),XU)],PostToolUse:Ht(Zg("posttool")),Stop:Ht(Bg("stop")),Notification:Ht(Bg("notification")),PermissionRequest:Ht(Bg("permission"))}};function L1(){let e=tn.hooksSettings;return JU(HU(e),{recursive:!0}),WU(e,JSON.stringify(QU,null,2)),e}import{spawn as eL}from"node:child_process";function M1(e,t,r={}){let{ASSIST_ACTIVITY_ID:i,CLAUDE_CODE_CHILD_SESSION:n,...o}=process.env,s=eL(e,t,{stdio:"inherit",env:{...o,...r.env},cwd:r.cwd}),a=new Promise((l,c)=>{s.on("close",u=>l(u??0)),s.on("error",c)});return{child:s,done:a}}function sn(e,t={}){let r=["--settings",L1(),...tL(e,t)],i=t.permissionMode??(t.allowEdits?"auto":void 0);return i&&r.push("--permission-mode",i),M1("claude",r)}function tL(e,t){return t.resumeSessionId?e?["--resume",t.resumeSessionId,e]:["--resume",t.resumeSessionId]:t.sessionId?e?["--session-id",t.sessionId,e]:["--session-id",t.sessionId]:e?[e]:[]}function rL(e){return`You are helping the user apply fixes for a code review with each finding decided one at a time.
441
+ No findings were raised.`);return tr(er(r,t))}function z1(e,t){if(!t)return{posted:0,submitted:!1};if(!A1(e,t))throw new Error("the review could not be submitted to the PR");return{posted:0,submitted:!0}}function D1(e,t){let r=[];return e>0&&r.push(`${e} line comment(s)`),t>0&&r.push(`${t} finding(s) in the review body`),r.join(" and ")}var VU={posted:0,submitted:!1};async function KU(e,t,r){return r.prompt?fr(`Post ${t} to PR #${e}?`,!1):!0}async function GU(e,t,r){let i=BU(t,"utf8"),{inDiff:n,unanchored:o}=Ki(i,e),s=Yt(o);if(n.length===0&&s.length===0)return z1(i,r.ciFooter);let a=D1(n.length,s.length);return console.log(`Found PR #${e.prNumber} with ${a} to post.`),await KU(e.prNumber,a,r)?R1(n,o,i,r):(console.log("Skipped posting."),VU)}async function j1(e,t,r){if(!N1(t.prNumber))return;let i=await GU(t,e,r);await l1(t.prNumber,i,r)}import{mkdirSync as JU,writeFileSync as WU}from"node:fs";import{dirname as HU}from"node:path";var Vg="assist sessions set-status";function Zg(e){return`${Vg} running --source ${e}`}function YU(e){return`${Vg} waiting --source ${e}`}function Bg(e){return`${Vg} waiting --source ${e} --ack`}function Ht(e,t){let r=[{type:"command",command:e}];return[t==null?{hooks:r}:{matcher:t,hooks:r}]}var U1="AskUserQuestion",XU=`^(?!${U1}$).*`,QU={theme:"auto",hooks:{UserPromptSubmit:Ht(Zg("prompt")),PreToolUse:[...Ht(YU("pretool"),U1),...Ht(Zg("pretool"),XU)],PostToolUse:Ht(Zg("posttool")),Stop:Ht(Bg("stop")),Notification:Ht(Bg("notification")),PermissionRequest:Ht(Bg("permission"))}};function L1(){let e=tn.hooksSettings;return JU(HU(e),{recursive:!0}),WU(e,JSON.stringify(QU,null,2)),e}import{spawn as eL}from"node:child_process";function M1(e,t,r={}){let{ASSIST_ACTIVITY_ID:i,CLAUDE_CODE_CHILD_SESSION:n,...o}=process.env,s=eL(e,t,{stdio:"inherit",env:{...o,...r.env},cwd:r.cwd}),a=new Promise((l,c)=>{s.on("close",u=>l(u??0)),s.on("error",c)});return{child:s,done:a}}function sn(e,t={}){let r=["--settings",L1(),...tL(e,t)],i=t.permissionMode??(t.allowEdits?"auto":void 0);return i&&r.push("--permission-mode",i),M1("claude",r)}function tL(e,t){return t.resumeSessionId?e?["--resume",t.resumeSessionId,e]:["--resume",t.resumeSessionId]:t.sessionId?e?["--session-id",t.sessionId,e]:["--session-id",t.sessionId]:e?[e]:[]}function rL(e){return`You are helping the user apply fixes for a code review with each finding decided one at a time.
442
442
 
443
443
  Read ${e}. It contains a list of findings under the \`## Findings\` heading. Each finding is a block in this exact format:
444
444