@burtson-labs/bandit-stealth-cli 1.7.285 → 1.7.286
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/cli.js +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -195,7 +195,7 @@ If you think a tool is missing, re-check this list before saying so. The names a
|
|
|
195
195
|
Rules:
|
|
196
196
|
- Use what you have gathered to answer the goal above.
|
|
197
197
|
- Do not pivot to a related topic that happens to be salient in recent tool results.${ul}
|
|
198
|
-
- If the available tools cannot finish the goal, own that honestly in your final answer \u2014 do NOT redirect to an easier question.`})}}let Tu=vc!==void 0?{think:vc}:void 0;vc=void 0;let Ac=Date.now(),Ya="";for(;;){S("tool_loop:llm_start",{iteration:bi,messageCount:rn.length,promptCharsTotal:rn.reduce((Ai,hn)=>Ai+(hn.content?.length??0),0),systemPromptChars:rn.filter(Ai=>Ai.role==="system").reduce((Ai,hn)=>Ai+(hn.content?.length??0),0),thinkOverride:Tu?.think}),Ac=Date.now();try{Ya=await this.streamAndAggregate(c,rn,S,bi,ri,st,Tu);break}catch(Ai){if(Mt&&_n&&!Nr&&prt(Ai)&&!st?.aborted){Nr=!0,Mt=!1,ri=void 0;let hn=Zr(!1);hn&&(rn[0]?.role==="system"?rn[0]={role:"system",content:hn}:rn.unshift({role:"system",content:hn})),S("tool_loop:native_tool_fallback",{iteration:bi,reason:_rt(Ai)});continue}throw Ai}}if(S("tool_loop:llm_response",{iteration:bi,response:Ya.slice(0,2e3),responseLength:Ya.length,hasToolCallMarkup:Ya.includes("<tool_call>")||/```\s*tool_call\b/.test(Ya),endsWithFenceClose:/```\s*$/.test(Ya.trimEnd()),llmDurationMs:Date.now()-Ac}),st?.aborted)return S("tool_loop:cancelled",{iteration:bi,stage:"post_stream"}),Pt(rn,bi,Ya);if(!Ns&&/<tool_result\b[\s\S]*?<\/tool_result\s*>|<tool_result\b[^<]*$/i.test(Ya)&&Jc<jf){Jc++,S("tool_loop:fake_tool_result_detected",{iteration:bi,preview:Ya.slice(0,200)});let Ai=Ya.replace(/<tool_result\b[\s\S]*?<\/tool_result\s*>/gi,"").replace(/<tool_result\b[^<]*$/i,"").trim();rn.push({role:"assistant",content:Ai}),rn.push({role:"user",content:'You emitted a `<tool_result>` envelope in your response. Those envelopes are SYSTEM output \u2014 they appear BETWEEN your turns, never inside your own message. If you meant to invoke a tool, emit a single `<tool_call>{"name":"...","params":{...}}</tool_call>` and wait for the real result. If the task is complete, give a plain-prose final answer with no XML envelopes. Retry now.'});continue}let vo=/```bandit-(?:tl|run|subagent)\b[\s\S]*?```/gi,F0=/```bandit-(?:tl|run|subagent)\b[\s\S]*$/i,vf=vo.test(Ya)||F0.test(Ya),M0=/<tool_call\b/i.test(Ya);if(!Ns&&vf&&!M0&&Jc<jf){Jc++,S("tool_loop:fake_tool_result_detected",{iteration:bi,preview:Ya.slice(0,200),shape:"bandit-tl"});let Ai=Ya.replace(/```bandit-(?:tl|run|subagent)\b[\s\S]*?```/gi,"").replace(/```bandit-(?:tl|run|subagent)\b[\s\S]*$/i,"").trim();rn.push({role:"assistant",content:Ai}),rn.push({role:"user",content:'You emitted `\u200A```bandit-tl` (or `bandit-run` / `bandit-subagent`) fenced JSON in your response. Those fences are emitted by the EXTENSION HOST to log real tool execution \u2014 you CANNOT produce them. They show up in your context because the host logged actual tool calls, not because you can fabricate them. To actually run a tool, emit `<tool_call>{"name":"...","params":{...}}</tool_call>` and wait for the real result. Your fake fences mean NO work has happened this turn. You have TWO options for your retry, and ONLY two: (a) Emit a real `<tool_call>{"name":"...","params":{...}}</tool_call>` envelope NOW to actually do the work, then wait for the real result. (b) Honestly state "I have not [action] yet" and STOP. Do NOT claim completion. You MUST NOT claim you have fixed / eliminated / resolved / removed / cleaned / verified anything. No "successfully [verb]" phrasing. No numbered lists of "Step 1: I did X" actions. No "the project is now in a healthy state." Until a real `<tool_call>` lands on disk and returns a real tool-result, nothing has changed. Lying about completion is the worst failure mode. Retry now.'});continue}if(!Ns&&!(0,C0.hasToolCalls)(Ya)&&bl<yf){let Ai=this.registry.getAll().map(Vi=>Vi.name),hn=(0,drt.detectFalseToolAbsence)(Ya,Ai);if(hn.detected){bl++,S("tool_loop:false_tool_absence",{iteration:bi,matched:hn.matchedToolNames,suggested:hn.suggestedTools,responsePreview:Ya.slice(0,200)}),rn.push({role:"assistant",content:Ya}),rn.push({role:"user",content:(0,drt.buildToolAvailabilityNudge)(hn)});continue}}if(!Ns&&!(0,C0.hasToolCalls)(Ya)&&ta&&Zu<lp){Zu++,S("tool_loop:tool_error_recovery",{iteration:bi,responsePreview:Ya.slice(0,200)}),rn.push({role:"assistant",content:Ya}),rn.push({role:"user",content:'The previous tool call returned an error and you produced no follow-up tool_call. Do NOT silently abandon the request \u2014 the user expects you to either retry with corrected parameters OR state explicitly which precondition failed and why you cannot proceed. Choose one: (a) emit a corrected `<tool_call>{"name":"...","params":{...}}</tool_call>` now, fixing the param shape or value the error pointed at; (b) give a one-line final answer naming the exact precondition you lack (e.g. "I cannot trash message X because the message id is unknown \u2014 please provide it"). Do not pretend the error did not happen and do not continue with unrelated work.'});continue}rn.push({role:"assistant",content:Ya});let qg=Ya.replace(/<think\b[\s\S]*?<\/think\s*>/gi,"").replace(/<think\b[\s\S]*$/i,"").replace(/```bandit-reasoning\b[\s\S]*?```/gi,"").replace(/```bandit-reasoning\b[\s\S]*$/i,"").trim(),jb=!qg&&Ya.trim().length>0,Ja=/\b(use|uses|used|using|call|calls|called|calling|invoke|invokes|invoked|invoking|execute|executes|executed|executing|run|runs|running|ran|search|searches|searched|searching|look|looks|looked|looking|read|reads|reading|check|checks|checked|checking|find|finds|finding|found|list|lists|listed|listing|fetch|fetches|fetched|fetching|grep|greps|grepped|grepping|explore|explores|explored|exploring|locate|locates|located|locating|plan|plans|planned|planning|start|starts|started|starting|begin|begins|began|beginning|create|creates|created|creating|write|writes|wrote|writing|build|builds|built|building|update|updates|updated|updating|implement|implements|implemented|implementing|refactor|refactors|refactored|refactoring|generate|generates|generated|generating|scaffold|scaffolds|scaffolded|scaffolding|set\s+up|setting\s+up|tackle|tackles|tackled|tackling|do|does|did|doing|make|makes|made|making|batch|batches|batched|batching|execute|prepare|prepares|prepared|preparing|draft|drafts|drafted|drafting|outline|outlines|outlined|outlining|organize|organizes|organized|organizing|structure|structures|structured|structuring|kick\s+off|kicking\s+off)\b/i,Ud=/\b(we (?:will|need to|should)|we'?ll|we'?re going to|i'?ll|i will|let me|let'?s|going to|i'?m going to|i need to)\b/i,xT=/```[a-zA-Z0-9_-]*\s*\n/.test(qg),ty=qg.match(/(?:[.!?]\s+)([^.!?]*)$/),W1=(ty?ty[1]:qg).slice(-200),Lb=!(0,C0.hasToolCalls)(Ya)&&!xT&&qg.length>0&&qg.length<240&&Ud.test(W1)&&Ja.test(W1);if((!Ya.trim()||jb||Lb)&&!Ns&&An<2){An++,S("tool_loop:empty_retry",{iteration:bi,attempt:An,reasoningOnly:jb,narratedButNoAction:Lb});let Ai=Lb?`You announced your next step in prose ("we will search\u2026" / "let me check\u2026" / "use X to find Y") but did NOT emit a \`<tool_call>\` envelope. Announcing intent is not enough \u2014 you must actually invoke the tool. Emit the call now in this exact format, OUTSIDE of any reasoning block, with NO commentary and NO markdown fence:
|
|
198
|
+
- If the available tools cannot finish the goal, own that honestly in your final answer \u2014 do NOT redirect to an easier question.`})}}let Tu=vc!==void 0?{think:vc}:void 0;vc=void 0;let Ac=Date.now(),Ya="";for(;;){S("tool_loop:llm_start",{iteration:bi,messageCount:rn.length,promptCharsTotal:rn.reduce((Ai,hn)=>Ai+(hn.content?.length??0),0),systemPromptChars:rn.filter(Ai=>Ai.role==="system").reduce((Ai,hn)=>Ai+(hn.content?.length??0),0),thinkOverride:Tu?.think}),Ac=Date.now();try{Ya=await this.streamAndAggregate(c,rn,S,bi,ri,st,Tu);break}catch(Ai){if(Mt&&_n&&!Nr&&prt(Ai)&&!st?.aborted){Nr=!0,Mt=!1,ri=void 0;let hn=Zr(!1);hn&&(rn[0]?.role==="system"?rn[0]={role:"system",content:hn}:rn.unshift({role:"system",content:hn})),S("tool_loop:native_tool_fallback",{iteration:bi,reason:_rt(Ai)});continue}throw Ai}}if(S("tool_loop:llm_response",{iteration:bi,response:Ya.slice(0,2e3),responseLength:Ya.length,hasToolCallMarkup:Ya.includes("<tool_call>")||/```\s*tool_call\b/.test(Ya),endsWithFenceClose:/```\s*$/.test(Ya.trimEnd()),llmDurationMs:Date.now()-Ac}),st?.aborted)return S("tool_loop:cancelled",{iteration:bi,stage:"post_stream"}),Pt(rn,bi,Ya);if(!Ns&&/<tool_result\b[\s\S]*?<\/tool_result\s*>|<tool_result\b[^<]*$/i.test(Ya)&&Jc<jf){Jc++,S("tool_loop:fake_tool_result_detected",{iteration:bi,preview:Ya.slice(0,200)});let Ai=Ya.replace(/<tool_result\b[\s\S]*?<\/tool_result\s*>/gi,"").replace(/<tool_result\b[^<]*$/i,"").trim();rn.push({role:"assistant",content:Ai}),rn.push({role:"user",content:'You emitted a `<tool_result>` envelope in your response. Those envelopes are SYSTEM output \u2014 they appear BETWEEN your turns, never inside your own message. If you meant to invoke a tool, emit a single `<tool_call>{"name":"...","params":{...}}</tool_call>` and wait for the real result. If the task is complete, give a plain-prose final answer with no XML envelopes. Retry now.'});continue}let vo=/```bandit-(?:tl|run|subagent)\b[\s\S]*?```/gi,F0=/```bandit-(?:tl|run|subagent)\b[\s\S]*$/i,vf=vo.test(Ya)||F0.test(Ya),M0=/<tool_call\b/i.test(Ya);if(!Ns&&vf&&!M0&&Jc<jf){Jc++,S("tool_loop:fake_tool_result_detected",{iteration:bi,preview:Ya.slice(0,200),shape:"bandit-tl"});let Ai=Ya.replace(/```bandit-(?:tl|run|subagent)\b[\s\S]*?```/gi,"").replace(/```bandit-(?:tl|run|subagent)\b[\s\S]*$/i,"").trim();rn.push({role:"assistant",content:Ai}),rn.push({role:"user",content:'You emitted `\u200A```bandit-tl` (or `bandit-run` / `bandit-subagent`) fenced JSON in your response. Those fences are emitted by the EXTENSION HOST to log real tool execution \u2014 you CANNOT produce them. They show up in your context because the host logged actual tool calls, not because you can fabricate them. To actually run a tool, emit `<tool_call>{"name":"...","params":{...}}</tool_call>` and wait for the real result. Your fake fences mean NO work has happened this turn. You have TWO options for your retry, and ONLY two: (a) Emit a real `<tool_call>{"name":"...","params":{...}}</tool_call>` envelope NOW to actually do the work, then wait for the real result. (b) Honestly state "I have not [action] yet" and STOP. Do NOT claim completion. You MUST NOT claim you have fixed / eliminated / resolved / removed / cleaned / verified anything. No "successfully [verb]" phrasing. No numbered lists of "Step 1: I did X" actions. No "the project is now in a healthy state." Until a real `<tool_call>` lands on disk and returns a real tool-result, nothing has changed. Lying about completion is the worst failure mode. Retry now.'});continue}if(!Ns&&!(0,C0.hasToolCalls)(Ya)&&bl<yf){let Ai=this.registry.getAll().map(Vi=>Vi.name),hn=(0,drt.detectFalseToolAbsence)(Ya,Ai);if(hn.detected){bl++,S("tool_loop:false_tool_absence",{iteration:bi,matched:hn.matchedToolNames,suggested:hn.suggestedTools,responsePreview:Ya.slice(0,200)}),rn.push({role:"assistant",content:Ya}),rn.push({role:"user",content:(0,drt.buildToolAvailabilityNudge)(hn)});continue}}if(!Ns&&!(0,C0.hasToolCalls)(Ya)&&ta&&Zu<lp){Zu++,S("tool_loop:tool_error_recovery",{iteration:bi,responsePreview:Ya.slice(0,200)}),rn.push({role:"assistant",content:Ya}),rn.push({role:"user",content:'The previous tool call returned an error and you produced no follow-up tool_call. Do NOT silently abandon the request \u2014 the user expects you to either retry with corrected parameters OR state explicitly which precondition failed and why you cannot proceed. Choose one: (a) emit a corrected `<tool_call>{"name":"...","params":{...}}</tool_call>` now, fixing the param shape or value the error pointed at; (b) give a one-line final answer naming the exact precondition you lack (e.g. "I cannot trash message X because the message id is unknown \u2014 please provide it"). Do not pretend the error did not happen and do not continue with unrelated work.'});continue}rn.push({role:"assistant",content:Ya});let qg=Ya.replace(/<think\b[\s\S]*?<\/think\s*>/gi,"").replace(/<think\b[\s\S]*$/i,"").replace(/```bandit-reasoning\b[\s\S]*?```/gi,"").replace(/```bandit-reasoning\b[\s\S]*$/i,"").trim(),jb=!qg&&Ya.trim().length>0,Ja=/\b(use|uses|used|using|call|calls|called|calling|invoke|invokes|invoked|invoking|execute|executes|executed|executing|run|runs|running|ran|search|searches|searched|searching|look|looks|looked|looking|read|reads|reading|check|checks|checked|checking|find|finds|finding|found|list|lists|listed|listing|fetch|fetches|fetched|fetching|grep|greps|grepped|grepping|explore|explores|explored|exploring|locate|locates|located|locating|plan|plans|planned|planning|start|starts|started|starting|begin|begins|began|beginning|create|creates|created|creating|write|writes|wrote|writing|rewrite|rewrites|rewrote|rewriting|rewritten|build|builds|built|building|rebuild|rebuilds|rebuilt|rebuilding|update|updates|updated|updating|implement|implements|implemented|implementing|refactor|refactors|refactored|refactoring|redesign|redesigns|redesigned|redesigning|design|designs|designed|designing|generate|generates|generated|generating|scaffold|scaffolds|scaffolded|scaffolding|set\s+up|setting\s+up|tackle|tackles|tackled|tackling|do|does|did|doing|make|makes|made|making|batch|batches|batched|batching|execute|prepare|prepares|prepared|preparing|draft|drafts|drafted|drafting|outline|outlines|outlined|outlining|organize|organizes|organized|organizing|structure|structures|structured|structuring|kick\s+off|kicking\s+off|fix|fixes|fixed|fixing|edit|edits|edited|editing|modify|modifies|modified|modifying|patch|patches|patched|patching|adjust|adjusts|adjusted|adjusting|replace|replaces|replaced|replacing|swap|swaps|swapped|swapping|polish|polishes|polished|polishing|clean\s+up|cleaning\s+up|tidy|tidies|tidied|tidying|finalize|finalizes|finalized|finalizing|finish|finishes|finished|finishing|complete|completes|completed|completing|wire|wires|wired|wiring|hook|hooks|hooked|hooking|render|renders|rendered|rendering|style|styles|styled|styling|theme|themes|themed|theming|redo|redoes|redid|redoing|port|ports|ported|porting|migrate|migrates|migrated|migrating|configure|configures|configured|configuring|install|installs|installed|installing|remove|removes|removed|removing|delete|deletes|deleted|deleting|rename|renames|renamed|renaming)\b/i,Ud=/\b(we (?:will|need to|should)|we'?ll|we'?re going to|i'?ll|i will|let me|let'?s|going to|i'?m going to|i need to)\b/i,xT=/```[a-zA-Z0-9_-]*\s*\n/.test(qg),ty=qg.match(/(?:[.!?]\s+)([^.!?]*)$/),W1=(ty?ty[1]:qg).slice(-200),Lb=!(0,C0.hasToolCalls)(Ya)&&!xT&&qg.length>0&&qg.length<240&&Ud.test(W1)&&Ja.test(W1);if((!Ya.trim()||jb||Lb)&&!Ns&&An<2){An++,S("tool_loop:empty_retry",{iteration:bi,attempt:An,reasoningOnly:jb,narratedButNoAction:Lb});let Ai=Lb?`You announced your next step in prose ("we will search\u2026" / "let me check\u2026" / "use X to find Y") but did NOT emit a \`<tool_call>\` envelope. Announcing intent is not enough \u2014 you must actually invoke the tool. Emit the call now in this exact format, OUTSIDE of any reasoning block, with NO commentary and NO markdown fence:
|
|
199
199
|
|
|
200
200
|
<tool_call>{"name":"<tool>","params":{"<key>":"<value>"}}</tool_call>
|
|
201
201
|
|
|
@@ -1479,7 +1479,7 @@ ${(()=>{let J=`Bandit insights \u2014 ${new Date(s).toISOString().slice(0,10)}`,
|
|
|
1479
1479
|
<h1>You're signed in.</h1>
|
|
1480
1480
|
<p>Bandit picked up your session. You can close this tab and return to your terminal.</p>
|
|
1481
1481
|
</div>
|
|
1482
|
-
</body></html>`;t(Dwr,"startLoopbackListener");t(Iwr,"openBrowser");t(Awr,"buildDefaultDeviceLabel");t(Nwr,"runOAuthSignIn")});var mfe=At((uFr,Owr)=>{Owr.exports={name:"@burtson-labs/bandit-stealth-cli",version:"1.7.
|
|
1482
|
+
</body></html>`;t(Dwr,"startLoopbackListener");t(Iwr,"openBrowser");t(Awr,"buildDefaultDeviceLabel");t(Nwr,"runOAuthSignIn")});var mfe=At((uFr,Owr)=>{Owr.exports={name:"@burtson-labs/bandit-stealth-cli",version:"1.7.286",description:"Bandit \u2014 a local-first AI coding agent for your terminal. Same runtime as the Bandit Stealth VS Code / Cursor extension.",keywords:["ai","agent","cli","coding-agent","llm","ollama","local-first","bandit","burtson-labs","terminal","repl","developer-tools"],homepage:"https://burtson.ai",bugs:{url:"https://github.com/Burtson-Labs/bandit-agent-framework/issues",email:"team@burtson.ai"},license:"MIT",author:{name:"Burtson Labs",email:"team@burtson.ai",url:"https://burtson.ai"},repository:{type:"git",url:"git+https://github.com/Burtson-Labs/bandit-agent-framework.git",directory:"apps/bandit-cli"},bin:{bandit:"./dist/cli.js"},main:"dist/cli.js",files:["dist/cli.js","README.md","LICENSE"],engines:{node:">=20"},publishConfig:{access:"public"},scripts:{typecheck:"tsc -p tsconfig.json --noEmit",build:"node build.mjs","build:publish":"node build.mjs --publish",dev:"node build.mjs --watch",start:"node dist/cli.js",smoke:"node build.mjs && node dist/__smoke__/smoke.js",integration:"node build.mjs && node dist/__integration__/ollama.js",eval:"node build.mjs && node dist/__eval__/eval.js",benchmark:"node build.mjs && node dist/__eval__/benchmark.js","gen-logo":"node scripts/gen-logo.mjs","preview-banner":"node scripts/preview-banner.mjs",clean:"rm -rf dist",prepack:"node scripts/prepack.mjs",postpack:"node scripts/postpack.mjs",prepublishOnly:"pnpm run clean && pnpm run typecheck && pnpm run build:publish"},dependencies:{"pdf-parse":"^2.4.5"},devDependencies:{"@burtson-labs/agent-core":"workspace:*","@burtson-labs/host-kit":"workspace:*","@burtson-labs/stealth-core-runtime":"workspace:*","@types/node":"^20.11.0","@types/pdf-parse":"^1.1.5","@types/pngjs":"^6.0.5",esbuild:"^0.28.0",pngjs:"^7.0.0",typescript:"^5.4.0"}}});var Txr={};module.exports=dtt(Txr);var cp=yl(require("fs")),jM=yl(require("os")),of=yl(require("path")),r$=yl(require("readline")),hfe=yl(require("child_process")),rm=yl(F9()),mg=yl(Wue());var Q6=yl(require("fs")),i3e=yl(require("os")),ST=yl(require("path")),HZ=yl(require("child_process"));function Ov(a){return a==="~"?i3e.homedir():a.startsWith("~/")?ST.join(i3e.homedir(),a.slice(2)):a}t(Ov,"expandHome");var Z9=16*1024,ZZ=32*1024,bpt=1e4,USr=3e4,a3e=200,s3e=new Set(["node_modules",".git","dist","build","out",".next",".turbo","coverage","target","__pycache__",".venv","venv"]);function qSr(a){let s=t(d=>{let u=d.match(/^(.*?)\{([^}]+)\}(.*)$/);if(!u)return[d];let[,h,S,P]=u;return S.split(",").map(N=>`${h}${N.trim()}${P}`)},"braceExpand"),c=a.match(/^([^*{}]+?)\/\*\*\/(.+)$/);if(c){let[,d,u]=c;return{includes:s(u),subDir:d}}return{includes:s(a),subDir:""}}t(qSr,"expandGlobForGrep");var AM=class{constructor(s,c,d={}){this.workspaceRoot=s;this.languageAdapters=c;this.options=d;this._readFiles=new Set;this.customRepoRoots=d.customRepoRoots&&d.customRepoRoots.length>0?d.customRepoRoots:void 0}static{t(this,"CliToolExecutionContext")}markFileRead(s){this._readFiles.add(Ov(s))}hasFileBeenRead(s){return this._readFiles.has(Ov(s))}async readFile(s){return Q6.promises.readFile(Ov(s),"utf-8")}async writeFile(s,c){let d=Ov(s);if(this.options.approveWrite&&!await this.options.approveWrite(d,c))throw new Error(`Write to ${d} rejected by user`);await Q6.promises.mkdir(ST.dirname(d),{recursive:!0}),await Q6.promises.writeFile(d,c,"utf-8")}async deleteFile(s){let c=ST.resolve(Ov(s)),d=ST.resolve(this.workspaceRoot);if(!c.startsWith(d+ST.sep)&&c!==d)throw new Error(`Refusing to delete outside workspace: ${s}`);await Q6.promises.unlink(c)}async listFiles(s,c){let d=Ov(c??this.workspaceRoot),u=JSr(s),h=[];return await Spt(d,d,u,h),h.slice(0,a3e).sort()}async listDirectoryEntries(s){let c=Ov(s),d=await Q6.promises.readdir(c,{withFileTypes:!0}),u=[];for(let h of d){if(h.name.startsWith("."))continue;let S=h.isDirectory();if(h.isSymbolicLink())try{S=(await Q6.promises.stat(ST.join(c,h.name))).isDirectory()}catch{S=!1}u.push(S?`${h.name}/`:h.name)}return u.sort()}async searchCode(s,c,d){let u=Ov(c??this.workspaceRoot);return this.runRipgrep(s,u,d).catch(()=>this.runGrep(s,u,d))}async runCommand(s,c,d){let u=c.map(Ov),h=d?Ov(d):this.workspaceRoot,S={...process.env};if((s.split(/[\\/]/).pop()??s)==="gh")for(let N of["GITHUB_TOKEN","GH_TOKEN"]){let R=S[N];typeof R=="string"&&R.trim()===""&&delete S[N]}return new Promise(N=>{let R="",$="",J=HZ.spawn(s,u,{cwd:h,shell:process.platform==="win32",env:S}),B=setTimeout(()=>{J.kill("SIGTERM"),N({stdout:R.slice(0,ZZ),stderr:$+`
|
|
1483
1483
|
[process timed out]`,exitCode:124})},USr),ge=process.stdout.isTTY===!0,fe=t((be,st)=>{if(!ge)return;(st?process.stderr:process.stdout).write("\r\x1B[2K\x1B[2m"+be+"\x1B[0m")},"writeLive");J.stdout?.on("data",be=>{let st=be.toString();R+=st,fe(st,!1),R.length>ZZ&&J.kill("SIGTERM")}),J.stderr?.on("data",be=>{let st=be.toString();$+=st,fe(st,!0)}),J.on("close",be=>{clearTimeout(B);let st=R.slice(0,ZZ);if(be===0&&/Operation cancelled/i.test(st)&&/(create-vite|create-react-app|create-next|create-svelte|create-astro|create-remix|@clack)/i.test(`${s} ${u.join(" ")} ${st}`)){let gt=[s,...u].join(" ");N({stdout:st,stderr:`Interactive scaffolder detected \u2014 \`${s}\` aborted with "Operation cancelled" because Bandit captures stdout/stderr (no TTY on stdin) and modern scaffolders refuse to start without one. Tell the user to run this directly in their shell: \`!${gt}\`. The \`!\`-prefix runs through their terminal with real stdin, so the scaffolder's prompts work. After they finish, you can pick up from the resulting filesystem state. Do NOT retry the same command \u2014 it will loop forever.`,exitCode:1});return}N({stdout:st,stderr:$.slice(0,4*1024),exitCode:be??0})}),J.on("error",be=>{if(clearTimeout(B),be.code==="ENOENT"){N({stdout:"",stderr:`spawn ${s} ENOENT \u2014 '${s}' not found on PATH. Verify the tool is installed (\`which ${s}\` in a fresh terminal). If you use nvm/asdf/volta, your shim PATH may not be inherited; relaunching this CLI from the same terminal session that has \`${s}\` on PATH usually fixes it.`,exitCode:127});return}N({stdout:"",stderr:be.message,exitCode:1})})})}async watchCommand(s,c,d,u){let h=c.map(Ov),S=d?Ov(d):this.workspaceRoot;return new Promise(P=>{let N="",R="",$=!1,J=!1,B=HZ.spawn(s,h,{cwd:S,shell:process.platform==="win32",env:{...process.env}}),ge=t(_t=>{J||(J=!0,P({stdout:N.slice(0,ZZ),stderr:R.slice(0,4*1024),exitCode:_t,endedEarly:$}))},"finish"),fe=setTimeout(()=>{try{B.kill("SIGTERM")}catch{}let _t=setTimeout(()=>{try{B.kill("SIGKILL")}catch{}ge(null)},1e3);B.once("close",gt=>{clearTimeout(_t),ge(typeof gt=="number"?gt:null)})},u),be=process.stdout.isTTY===!0,st=t((_t,gt)=>{if(!be)return;(gt?process.stderr:process.stdout).write("\r\x1B[2K\x1B[2m"+_t+"\x1B[0m")},"writeLive");B.stdout?.on("data",_t=>{let gt=_t.toString();if(N+=gt,st(gt,!1),N.length>ZZ)try{B.kill("SIGTERM")}catch{}}),B.stderr?.on("data",_t=>{let gt=_t.toString();R+=gt,st(gt,!0)}),B.on("close",_t=>{J||(clearTimeout(fe),$=!0,ge(typeof _t=="number"?_t:null))}),B.on("error",_t=>{J||(clearTimeout(fe),$=!0,R+=_t.message,ge(1))})})}runRipgrep(s,c,d){return new Promise((u,h)=>{let S=["--color=never","--line-number","--max-count=25","--max-filesize=1M",...[...s3e].map($=>["--glob",`!${$}`]).flat()];d&&S.push("--glob",d),S.push(s,c);let P="",N=HZ.spawn("rg",S,{shell:!1}),R=setTimeout(()=>{N.kill("SIGTERM"),u(P.slice(0,Z9))},bpt);N.stdout?.on("data",$=>{P+=$.toString(),P.length>Z9&&N.kill("SIGTERM")}),N.on("close",$=>{clearTimeout(R),$!=null&&$>=2&&P.length===0?h(new Error(`rg exited with code ${$}`)):u(P.slice(0,Z9))}),N.on("error",h)})}runGrep(s,c,d){return new Promise((u,h)=>{let S=[...s3e].map(fe=>["--exclude-dir",fe]).flat(),P=d?qSr(d):{includes:[],subDir:""},N=P.includes.flatMap(fe=>["--include",fe]),R=P.subDir?`${c}/${P.subDir}`:c,$=["-rn","-E","--color=never",...S,...N,s,R],J="",B=HZ.spawn("grep",$,{shell:!1}),ge=setTimeout(()=>{B.kill("SIGTERM"),u(J.slice(0,Z9))},bpt);B.stdout?.on("data",fe=>{J+=fe.toString(),J.length>Z9&&B.kill("SIGTERM")}),B.on("close",fe=>{clearTimeout(ge),fe!=null&&fe>=2&&J.length===0?h(new Error(`grep exited with code ${fe}`)):u(J.slice(0,Z9))}),B.on("error",h)})}};function JSr(a){let s=WSr(a);return c=>s.test(c.replace(/\\/g,"/"))}t(JSr,"compileGlob");function WSr(a){let s="^";for(let c=0;c<a.length;c++){let d=a[c];if(d==="*")a[c+1]==="*"?(s+=".*",c++,a[c+1]==="/"&&c++):s+="[^/]*";else if(d==="?")s+="[^/]";else if(d==="{"){let u=a.indexOf("}",c);if(u===-1){s+="\\{";continue}let h=a.slice(c+1,u).split(",").map(VSr).join("|");s+=`(?:${h})`,c=u}else/[.+^$()|\\]/.test(d)?s+="\\"+d:s+=d}return s+="$",new RegExp(s)}t(WSr,"globToRegex");function VSr(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}t(VSr,"escapeRegex");async function Spt(a,s,c,d){if(d.length>=a3e)return;let u;try{u=await Q6.promises.readdir(a,{withFileTypes:!0})}catch{return}for(let h of u){if(d.length>=a3e)return;if(s3e.has(h.name))continue;let S=ST.join(a,h.name),P=ST.relative(s,S);h.isDirectory()?await Spt(S,s,c,d):h.isFile()&&c(P)&&d.push(S)}}t(Spt,"walk");var kpt=yl(require("child_process")),AE=yl(require("fs")),wpt=yl(require("os")),o3e=yl(require("path")),xpt=yl(require("crypto"));function c3e(){let a=xpt.randomBytes(4).toString("hex");return o3e.join(wpt.tmpdir(),`bandit-paste-${Date.now()}-${a}.png`)}t(c3e,"freshTempPath");function Vue(a,s,c={}){try{let d=kpt.spawnSync(a,s,{...c,encoding:void 0});return{stdout:Buffer.isBuffer(d.stdout)?d.stdout:Buffer.from(d.stdout??""),code:d.status}}catch{return{stdout:Buffer.alloc(0),code:null}}}t(Vue,"tryExec");async function Zue(){return process.platform==="darwin"?ZSr():process.platform==="linux"?HSr():process.platform==="win32"?GSr():null}t(Zue,"readClipboardImage");function ZSr(){let a=c3e(),s=`set pngData to (the clipboard as \xABclass PNGf\xBB)
|
|
1484
1484
|
set outFile to (open for access (POSIX file "${a}") with write permission)
|
|
1485
1485
|
write pngData to outFile
|
package/package.json
CHANGED