@sourcegraph/amp 0.0.1762465271-g947457 → 0.0.1762473708-g720034

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 (2) hide show
  1. package/dist/main.js +8 -8
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -6508,11 +6508,11 @@ Actual: ${Y}`)}async function Vh4(J,Q,Z){let{execSync:X}=await import("node:ch
6508
6508
  ${B}`;if(Y==="pnpm"&&B.includes("Unable to find the global bin directory"))V+=`
6509
6509
 
6510
6510
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
6511
- npm install -g @sourcegraph/amp`;q(Error(V))}},error:(H)=>{if(!U)U=!0,q(Error(`Failed to spawn ${Y}: ${H.message}`))},complete:()=>{if(!U)U=!0,G()}})})}q0();q0();async function JF1(J){try{let Z=new AbortController,X=setTimeout(()=>Z.abort(),5000),Y=await fetch("https://registry.npmjs.org/@sourcegraph/amp",{signal:Z.signal});if(clearTimeout(X),!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let K=await Y.json(),G=K["dist-tags"]?.latest;if(!G)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=wh4(J,G),z=q<0,W,U;if(K.time){let F=K.time[J],H=K.time[G],B=Date.now();if(F)W=Math.floor((B-new Date(F).getTime())/3600000);if(H)U=Math.floor((B-new Date(H).getTime())/3600000)}return p.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:q,hasUpdate:z,currentVersionAge:W,latestVersionAge:U}),{hasUpdate:z,latestVersion:G,currentVersion:J,currentVersionAge:W,latestVersionAge:U,source:"npm"}}catch(Z){return p.debug("Error checking npm version",{error:Z}),{hasUpdate:!1,currentVersion:J,source:"npm"}}}function wh4(J,Q){let Z=(G)=>{let[q,z]=G.split("-");return{parts:q?.split(".").map(Number)||[],label:z}},X=Z(J),Y=Z(Q),K=Math.max(X.parts.length,Y.parts.length);for(let G=0;G<K;G++){let q=X.parts[G]||0,z=Y.parts[G]||0;if(q<z)return-1;if(q>z)return 1}if(X.label===Y.label)return 0;if(!X.label&&Y.label)return 1;if(X.label&&!Y.label)return-1;if(X.label&&Y.label)return X.label<Y.label?-1:1;return 0}C0();function A60(J,Q){let Z=new S8,X=Z.pipe(v9({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new hU().scoped("update"),K=X.subscribe({next:(G)=>{Y.debug("emit new state",G)}});try{let G=process.env.AMP_TEST_UPDATE_STATUS;if(G){Y.debug("using fake update status for testing",{status:G}),await WN(500),Z.next(G);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){Y.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let q=await Q.get("updates.mode");if(q==="disabled"){Y.debug("checking disabled");return}Y.debug("checking",{currentVersion:J,mode:q});let z=await JF1(J);if(!(z.latestVersion&&z.hasUpdate)){Y.debug("no update available");return}let W=await eU1();if(!q)q=W==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:W,mode:q});if(q==="warn"){Z.next("update-available");return}if(!W){Y.debug("auto-update not supported, falling back to warn mode"),Z.next("update-available");return}try{await Ds(z.latestVersion,W);let U=await dA(z.latestVersion),F={from:z.currentVersion,to:z.latestVersion,...U};if(U.status==="same")Y.info("success",F),Z.next("updated");else Y.warn("success with warning",F),Z.next("updated-with-warning")}catch(U){Z.next("update-error")}}catch(G){Y.debug("check failed",{error:G})}finally{await WN(5000),Z.next("hidden"),K.unsubscribe(),Z.complete()}}),{state:X}}import{stderr as uH}from"node:process";function Q58(J){let Q=new pE().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(X)=>{await M60(X.force||!1,X.verbose||!1,"0.0.1762465271-g947457"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new pE("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--version <version>","Update to a specific version").allowUnknownOption(!1).action(async(X)=>{await Oh4(X.version)});J.addCommand(Z)}async function Oh4(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")uH.write(U8.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6511
+ npm install -g @sourcegraph/amp`;q(Error(V))}},error:(H)=>{if(!U)U=!0,q(Error(`Failed to spawn ${Y}: ${H.message}`))},complete:()=>{if(!U)U=!0,G()}})})}q0();q0();async function JF1(J){try{let Z=new AbortController,X=setTimeout(()=>Z.abort(),5000),Y=await fetch("https://registry.npmjs.org/@sourcegraph/amp",{signal:Z.signal});if(clearTimeout(X),!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let K=await Y.json(),G=K["dist-tags"]?.latest;if(!G)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=wh4(J,G),z=q<0,W,U;if(K.time){let F=K.time[J],H=K.time[G],B=Date.now();if(F)W=Math.floor((B-new Date(F).getTime())/3600000);if(H)U=Math.floor((B-new Date(H).getTime())/3600000)}return p.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:q,hasUpdate:z,currentVersionAge:W,latestVersionAge:U}),{hasUpdate:z,latestVersion:G,currentVersion:J,currentVersionAge:W,latestVersionAge:U,source:"npm"}}catch(Z){return p.debug("Error checking npm version",{error:Z}),{hasUpdate:!1,currentVersion:J,source:"npm"}}}function wh4(J,Q){let Z=(G)=>{let[q,z]=G.split("-");return{parts:q?.split(".").map(Number)||[],label:z}},X=Z(J),Y=Z(Q),K=Math.max(X.parts.length,Y.parts.length);for(let G=0;G<K;G++){let q=X.parts[G]||0,z=Y.parts[G]||0;if(q<z)return-1;if(q>z)return 1}if(X.label===Y.label)return 0;if(!X.label&&Y.label)return 1;if(X.label&&!Y.label)return-1;if(X.label&&Y.label)return X.label<Y.label?-1:1;return 0}C0();function A60(J,Q){let Z=new S8,X=Z.pipe(v9({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new hU().scoped("update"),K=X.subscribe({next:(G)=>{Y.debug("emit new state",G)}});try{let G=process.env.AMP_TEST_UPDATE_STATUS;if(G){Y.debug("using fake update status for testing",{status:G}),await WN(500),Z.next(G);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){Y.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let q=await Q.get("updates.mode");if(q==="disabled"){Y.debug("checking disabled");return}Y.debug("checking",{currentVersion:J,mode:q});let z=await JF1(J);if(!(z.latestVersion&&z.hasUpdate)){Y.debug("no update available");return}let W=await eU1();if(!q)q=W==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:W,mode:q});if(q==="warn"){Z.next("update-available");return}if(!W){Y.debug("auto-update not supported, falling back to warn mode"),Z.next("update-available");return}try{await Ds(z.latestVersion,W);let U=await dA(z.latestVersion),F={from:z.currentVersion,to:z.latestVersion,...U};if(U.status==="same")Y.info("success",F),Z.next("updated");else Y.warn("success with warning",F),Z.next("updated-with-warning")}catch(U){Z.next("update-error")}}catch(G){Y.debug("check failed",{error:G})}finally{await WN(5000),Z.next("hidden"),K.unsubscribe(),Z.complete()}}),{state:X}}import{stderr as uH}from"node:process";function Q58(J){let Q=new pE().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(X)=>{await M60(X.force||!1,X.verbose||!1,"0.0.1762473708-g720034"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new pE("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--version <version>","Update to a specific version").allowUnknownOption(!1).action(async(X)=>{await Oh4(X.version)});J.addCommand(Z)}async function Oh4(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")uH.write(U8.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6512
6512
 
6513
6513
  `));try{if(!J){uH.write(U8.blue(`Checking for updates...
6514
- `));let{hasUpdate:Z,latestVersion:X}=await JF1("0.0.1762465271-g947457");if(!Z){uH.write(U8.green(`✓ Amp CLI is already up to date.
6515
- `));let Y=await dA("0.0.1762465271-g947457");if(Y.warning)uH.write(`
6514
+ `));let{hasUpdate:Z,latestVersion:X}=await JF1("0.0.1762473708-g720034");if(!Z){uH.write(U8.green(`✓ Amp CLI is already up to date.
6515
+ `));let Y=await dA("0.0.1762473708-g720034");if(Y.warning)uH.write(`
6516
6516
  `+U8.yellow(Y.warning)+`
6517
6517
  `);process.exit(0)}if(!X)uH.write(U8.yellow("[WARN] could not find latest version")),process.exit(0);J=X}uH.write(U8.blue(`Updating to version ${J}...
6518
6518
  `)),await Ds(J,void 0,(Z)=>{uH.write(U8.dim(`Running: ${Z}
@@ -7091,7 +7091,7 @@ exit code: ${q}`,new $1({color:X.foreground,dim:!0,italic:!0})));if(z)W.push(new
7091
7091
  `,B),...V],N=new x0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new l1({text:new D1("",void 0,M)})]});return W9.child(new u0({constraints:new P6(40,120,0,1/0),child:new i6({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[new t6({flex:1,child:new v80({width:40,height:40,agentMode:this.agentMode,fps:G==="fast"?60:G==="slow"?15:0,...G==="disabled"&&{seed:42,t:3}})}),new U0({width:1}),new t6({flex:2,child:N})]})}))}}i8();class x40 extends h0{props;constructor(J){super({key:J.key});this.props=J;this.props.enabled??=!0}createState(){return new zZ8}}class zZ8 extends f0{build(J){let Z=N6.of(J).colors,{todos:X,title:Y="TODOs",enabled:K=!0}=this.widget.props;if(!Array.isArray(X)||X.length===0)return new U0({width:0,height:0});let G=K?Z.foreground:Z.mutedForeground,q=X.map((z)=>this.buildTodoItem(z,Z,K));return new u0({child:new S6({padding:M0.symmetric(1,0),child:new x0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new l1({text:new D1(Y,new $1({bold:!0,color:G}))}),...q]})})})}buildTodoItem(J,Q,Z){let X=this.getStatusIcon(J.status),Y=Z?Q.foreground:Q.mutedForeground,K=new $1({bold:J.status==="in-progress",color:Y}),G=new $1({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Y});return new i6({crossAxisAlignment:"start",children:[new l1({text:new D1(X,K)}),new U0({width:1}),new t6({child:new l1({text:new D1(J.content,G)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class y40 extends M6{ad;onDismiss;onButtonClick;constructor({key:J,ad:Q,onDismiss:Z,onButtonClick:X}){super({key:J});this.ad=Q,this.onDismiss=Z,this.onButtonClick=X}build(J){let Q=N6.of(J),Z=Q.colors.primary,X=Q.colors.foreground;return new u0({decoration:new U9(void 0,new f8(new E8(Z,1,"rounded"),new E8(Z,1,"rounded"),void 0,new E8(Z,1,"rounded"))),child:new S6({padding:M0.horizontal(1),child:new x0({children:[new i6({crossAxisAlignment:"start",children:[new t6({child:new l1({text:new D1(this.ad.content,new $1({color:X}))})}),new U0({width:4}),new MZ({uri:"https://ampcode.com/free",text:"Ad",style:new $1({color:X,dim:!0}),onError:(Y)=>{}})]}),new i6({crossAxisAlignment:"start",children:[new F80({text:this.ad.buttonLabel,onPressed:()=>this.onButtonClick?.(),padding:M0.horizontal(1),color:Z,reverse:!0}),new U0({width:2}),new l1({text:new D1(this.ad.destinationUrlHostname,new $1({color:X,dim:!0}))})]})]})})})}}O9();i8();class b40 extends h0{props;constructor(J){super();this.props=J}createState(){return new WZ8(this.props.autofocus??!0)}}class WZ8 extends f0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=(q)=>{if(q.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(q.ctrlKey&&q.key==="c"||q.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},Z=r8.sizeOf(J),X=Math.min(60,Z.width-4),Y=Z.height-4,K=[];if(this.widget.props.title)K.push(new l1({text:new D1(this.widget.props.title,new $1({bold:!0,color:P1.blue}))}),new U0({height:1}));if(this.widget.props.message)K.push(new l1({text:new D1(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)K.push(new U0({height:1}));let G=[];if(this.widget.props.showCopyOption)G.push(new l1({text:new D1("Enter to copy",new $1({dim:!0}))}));return G.push(new l1({text:new D1("Escape to close",new $1({dim:!0}))})),K.push(new i6({children:G.flatMap((q,z)=>z<G.length-1?[q,new U0({width:1}),new l1({text:new D1("•",new $1({dim:!0}))}),new U0({width:1})]:[q]),mainAxisSize:"min"})),new W9({child:new u0({constraints:new P6(X,X,0,Y),decoration:new U9(P1.default(),new f8(new E8(P1.blue,1,"rounded"),new E8(P1.blue,1,"rounded"),new E8(P1.blue,1,"rounded"),new E8(P1.blue,1,"rounded"))),padding:new M0(2,2,2,2),child:new V9({autofocus:this.autofocus,onKey:Q,child:new x0({children:K,mainAxisSize:"min"})})})})}}class vH1 extends Error{constructor(J="Command timed out"){super(J);this.name="CommandTimeoutError",Object.setPrototypeOf(this,vH1.prototype)}}class _H1 extends Error{constructor(J){let Q=`${J.noun}: ${J.verb} command cancelled`;super(Q);this.name="CommandCancelledError",Object.setPrototypeOf(this,_H1.prototype)}}function f40(J){let Q=J.match(/"([^"]*)"|'([^']*)'|([^\s"']+)/g);if(!Q)return[];return Q.map((Z)=>{if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'"))return Z.slice(1,-1);return Z})}LM();q0();import{spawn as ll4}from"node:child_process";import{promises as il4}from"node:fs";function UZ8(J){return J.kind==="executable"}function FZ8(J){return J.kind==="markdown"}var A3=50000,HZ8=300000;async function h40(J,Q,Z,X={}){let{timeoutMs:Y=HZ8,signal:K}=X;try{let G=await Z.getCommand(J);if(!G)return{success:!1,output:"",error:`Command '${J}' not found`};if(!await Z.isCommandAvailable(J))return{success:!1,output:"",error:`Command '${J}' is not available for execution`};if(p.debug("Executing command",{commandName:J,filePath:G.filePath,args:Q}),FZ8(G))return await nl4(G,Q);else if(UZ8(G))return await al4(G,Q,Y,K);else return{success:!1,output:"",error:"Unsupported command type"}}catch(G){return p.error("Failed to execute command",{commandName:J,error:G}),{success:!1,output:"",error:G instanceof Error?G.message:"Unknown error occurred"}}}async function nl4(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Z=await il4.readFile(J.filePath,"utf8");return{success:!0,output:(Z.length>A3?Z.slice(0,A3)+`
7092
7092
  ... (output truncated at ${A3} characters)`:Z).trim(),exitCode:0}}catch(Z){return{success:!1,output:"",error:Z instanceof Error?Z.message:"Failed to read markdown file"}}}async function al4(J,Q,Z=HZ8,X){return new Promise((Y)=>{let[K,G]=rl4(J,Q);p.debug("Spawning command",{spawnCommand:K,spawnArgs:G.slice(0,10),filePath:J.filePath,timeoutMs:Z});let q=lm0(X),z=!1,W=setTimeout(()=>{z=!0,q.abort(),p.warn("Command execution timed out",{commandName:J.name,timeoutMs:Z})},Z),U=ll4(K,G,{stdio:["pipe","pipe","pipe"],signal:q.signal,detached:!0}),F=[],H=[],B=0;U.stdout?.on("data",(V)=>{let M=V.toString();if(B+=M.length,B<=A3)F.push(M);else{let N=A3-(B-M.length);if(N>0)F.push(M.slice(0,N))}}),U.stderr?.on("data",(V)=>{let M=V.toString();if(B+=M.length,B<=A3)H.push(M);else{let N=A3-(B-M.length);if(N>0)H.push(M.slice(0,N))}}),U.on("close",(V)=>{if(clearTimeout(W),z){Y({success:!1,output:F.join(""),error:`Command timed out after ${Z}ms`,exitCode:void 0});return}if(q.signal.aborted){Y({success:!1,output:F.join(""),error:"The command was aborted",exitCode:V??void 0});return}let M=V===0||V===1,N=F.join(""),L=H.join(""),A=N;if(!M&&!N.trim()&&L.trim())A=L;else if(L.trim())A+=N?`
7093
7093
  ${L}`:L;if(B>A3)A+=`
7094
- ... (output truncated at ${A3} characters)`;Y({success:M,output:A.trim(),error:!M?L.trim()||"Command failed":void 0,exitCode:V??void 0})}),U.on("error",(V)=>{clearTimeout(W);let M=V.message;if(z)M=`Command timed out after ${Z}ms`;else if(V.message.includes("operation was aborted")||V.name==="AbortError")M="The command was aborted";Y({success:!1,output:F.join(""),error:M})})})}function rl4(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return ol4(Z,X?[...X]:null,Y,Q);else return sl4(Z,X?[...X]:null,Y,Q)}function sl4(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function ol4(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];switch(Z.toLowerCase()){case".bat":case".cmd":return["cmd.exe",["/c",J,...X]];case".ps1":return["powershell.exe",["-ExecutionPolicy","Bypass","-File",J,...X]];case".exe":return[J,X];default:return[J,X]}}q0();z5();RB();ZW();iU();MD();Jh();import{writeFile as el4}from"fs/promises";import Ji4 from"path";q0();ZW();class g40{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Z])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1762465271-g947457"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await m51(Q,this.configService)}catch(Q){p.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}i8();class u40 extends h0{props;constructor(J){super();this.props=J}createState(){return new BZ8}}class BZ8 extends f0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Z)=>{this.setState(()=>{this._state=Z(this._state)})};return this.widget.props.builder(J,Q,this._state)}}i8();i8();class DZ8 extends f0{controller=new sq;focusNode=new Y9({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});initState(){this.focusNode.requestFocus()}dispose(){this.focusNode.dispose()}build(J){let Q=N6.of(J),{colors:Z}=Q,X=f8.all(new E8(Z.foreground,1,"solid")),Y=new D3({controller:this.controller,focusNode:this.focusNode,placeholder:"Enter command argument...",onSubmitted:(q)=>{this.widget.props.onSubmit(q.trim())},autofocus:!0,style:{textColor:Z.foreground,border:null},maxLines:1}),K=new i6({children:[new u0({decoration:{color:P1.default()},child:new l1({text:new D1(">",new $1({color:Z.foreground}))})}),new t6({child:Y})]}),G=new u0({padding:M0.symmetric(1,0),child:new l1({text:new D1("",void 0,[new D1("Command: ",new $1({color:Z.foreground})),new D1(this.widget.props.commandName,new $1({color:P1.yellow,bold:!0}))])})});return new u0({decoration:{border:X,color:P1.default()},padding:M0.all(1),child:new x0({children:[G,new U0({height:1}),K]})})}}class m40 extends h0{props;constructor(J){super();this.props=J}createState(){return new DZ8}}iU();q0();i8();q0();class VZ8{_listeners=new Set;_disposed=!1;addListener(J){if(this._disposed)throw Error("Cannot add listener to disposed ChangeNotifier");this._listeners.add(J)}removeListener(J){this._listeners.delete(J)}notifyListeners(){if(this._disposed)return;let J=Array.from(this._listeners);for(let Q of J)try{Q()}catch(Z){}}dispose(){this._disposed=!0,this._listeners.clear()}get disposed(){return this._disposed}get hasListeners(){return this._listeners.size>0}}class $P extends VZ8{_value;constructor(J){super();this._value=J}get value(){return this._value}set value(J){let Q=typeof J==="object"||this._value!==J;if(this._value=J,Q)this.notifyListeners()}}function MZ8(J,Q){let Z=()=>{Q()};return J.addListener(Z),{dispose:()=>J.removeListener(Z)}}i8();s4();O9();class p40 extends o5{link;showWhenUnlinked;offset;constructor({key:J,link:Q,showWhenUnlinked:Z=!0,offset:X={x:0,y:0},child:Y}){super({key:J,child:Y});this.link=Q,this.showWhenUnlinked=Z,this.offset=X}createElement(){return new nA(this)}createRenderObject(){return new NZ8(this.link,this.showWhenUnlinked,this.offset)}updateRenderObject(J){J.link=this.link,J.showWhenUnlinked=this.showWhenUnlinked,J.setFollowerOffset(this.offset)}}class NZ8 extends F8{_link;_showWhenUnlinked;_followerOffset;_cachedPosition=null;constructor(J,Q,Z){super();this._link=J,this._showWhenUnlinked=Q,this._followerOffset=Z}get link(){return this._link}set link(J){this._link=J,this._cachedPosition=null,this.markNeedsLayout()}get showWhenUnlinked(){return this._showWhenUnlinked}set showWhenUnlinked(J){if(this._showWhenUnlinked!==J)this._showWhenUnlinked=J,this.markNeedsLayout()}setFollowerOffset(J){if(this._followerOffset.x!==J.x||this._followerOffset.y!==J.y)this._followerOffset={...J},this.markNeedsLayout()}calculatePosition(){let J=this._link.getTargetTransform();if(!J)return null;return{x:J.position.x+this._followerOffset.x,y:J.position.y+this._followerOffset.y}}shouldShow(){return this._link.target!==null||this._showWhenUnlinked}performLayout(){let J=this._lastConstraints;if(c6(!!J,"performLayout called without constraints"),!this.shouldShow()){this.setSize(0,0),super.performLayout();return}let Q=this.calculatePosition();if(this._cachedPosition=Q,Q)this.setOffset(Q.x,Q.y);if(this.children.length>0){let Z=this.children[0];Z.layout(J);let X=Z.size;this.setSize(X.width,X.height)}else this.setSize(0,0);super.performLayout()}getCurrentPosition(){return this._cachedPosition}setOffset(J,Q){super.setOffset(J,Q)}paint(J,Q=0,Z=0){super.paint(J,Q,Z)}}s4();O9();class d40 extends o5{link;constructor({key:J,link:Q,child:Z}){super({key:J,child:Z});this.link=Q}createElement(){return new nA(this)}createRenderObject(){return new LZ8(this.link)}updateRenderObject(J){J.link=this.link}}class LZ8 extends F8{_link;_globalPosition={x:0,y:0};constructor(J){super();this._link=J}get link(){return this._link}set link(J){if(this._link===J)return;this._link._setTarget(null),this._link=J,this._link._setTarget(this)}attach(){super.attach(),this._link._setTarget(this)}detach(){this._link._setTarget(null),super.detach()}getGlobalPosition(){let J=this.offset.x,Q=this.offset.y,Z=this.parent;while(Z&&Z instanceof F8)J+=Z.offset.x,Q+=Z.offset.y,Z=Z.parent;return{x:J,y:Q}}getSize(){let J=this.size;return{width:J.width,height:J.height}}updateGlobalPosition(){let J={...this._globalPosition};if(this._globalPosition=this.getGlobalPosition(),J.x!==this._globalPosition.x||J.y!==this._globalPosition.y)this._link._notifyFollowers()}performLayout(){let J=this._lastConstraints;if(c6(!!J,"performLayout called without constraints"),this.children.length>0){let Q=this.children[0];Q.layout(J);let Z=Q.size;this.setSize(Z.width,Z.height)}else this.setSize(0,0);this.updateGlobalPosition(),super.performLayout()}}q0();class c40{_target=null;_followers=new Set;get target(){return this._target}_setTarget(J){if(this._target===J)return;this._target=J,this._notifyFollowers()}_addFollower(J){this._followers.add(J)}_removeFollower(J){this._followers.delete(J)}_notifyFollowers(){for(let J of this._followers)try{J()}catch(Q){p.error("Error in LayerLink follower callback:",Q)}}getTargetTransform(){if(!this._target)return null;return{position:this._target.getGlobalPosition(),size:this._target.getSize()}}}q0();class l40{_state;_textController=null;_triggers=[];_optionsBuilder=null;_onSelected=null;_disposed=!1;constructor(){let J={trigger:null,options:[],selectedIndex:-1,isActive:!1,generationId:0};this._state=new $P(J)}get state(){return this._state}get currentState(){return this._state.value}initialize({textController:J,triggers:Q,optionsBuilder:Z,onSelected:X}){if(this._disposed)throw Error("Cannot initialize disposed AutocompleteController");this._cleanup(),this._textController=J,this._triggers=Q,this._optionsBuilder=Z,this._onSelected=X||null,this._textController.addListener(this._handleTextChange)}selectNext(){let J=this.currentState;if(!J.isActive||J.options.length===0)return;let Q=J.selectedIndex<J.options.length-1?J.selectedIndex+1:0;this._updateState({selectedIndex:Q})}selectPrevious(){let J=this.currentState;if(!J.isActive||J.options.length===0)return;let Q=J.selectedIndex>0?J.selectedIndex-1:J.options.length-1;this._updateState({selectedIndex:Q})}acceptSelected(){let J=this.currentState;if(!J.isActive||J.selectedIndex<0||J.selectedIndex>=J.options.length)return;let Q=J.options[J.selectedIndex];if(!Q)return;if(this.dismiss(),this._onSelected)this._onSelected(Q)}dismiss(){this._updateState({trigger:null,options:[],selectedIndex:-1,isActive:!1})}dispose(){this._disposed=!0,this._cleanup(),this._state.dispose()}_handleTextChange=()=>{if(!this._textController||!this._optionsBuilder)return;let J=this._textController.text,Q=this._textController.cursorPosition,Z=null;for(let Y of this._triggers){let K=Y.detect(J,Q);if(K&&(!Z||K.start>Z.start))Z=K}if(!Z){if(this.currentState.isActive)this.dismiss();return}let X=this.currentState.generationId+1;this._updateState({trigger:Z,generationId:X,isActive:!0,selectedIndex:-1}),this._buildOptions(Z.query,X)};async _buildOptions(J,Q){if(!this._optionsBuilder)return;try{let Z=await this._optionsBuilder(J);if(this.currentState.generationId===Q&&!this._disposed)this._updateState({options:Z,selectedIndex:Z.length>0?0:-1,isActive:Z.length>0})}catch(Z){if(p.error("Error building autocomplete options:",Z),this.currentState.generationId===Q&&!this._disposed)this._updateState({options:[],selectedIndex:-1,isActive:!1})}}_updateState(J){if(this._disposed)return;this._state.value={...this.currentState,...J}}_cleanup(){if(this._textController)this._textController.removeListener(this._handleTextChange)}}class qo{}class zo{}class Wo{}class xH1{}class yH1 extends h0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new AZ8(this.props)}}class AZ8 extends f0{props;controller;stateListener=null;overlayEntry=null;layerLink=new c40;scrollOffset=0;_effectiveFocusNode;constructor(J){super();this.props=J}initState(){if(super.initState(),this._effectiveFocusNode=this.props.focusNode||new Y9({debugLabel:"AutocompleteFocusOwned"}),this.controller=new l40,this.controller.initialize({textController:this.props.controller,triggers:this.props.triggers,optionsBuilder:this.props.optionsBuilder,onSelected:this.props.onSelected}),this.stateListener=MZ8(this.controller.state,()=>{this.updateOverlay(),this.setState(()=>{})}),this.props.autofocus??!0)g9.instance.addPostFrameCallback(()=>{this._effectiveFocusNode.requestFocus()})}didUpdateWidget(J){super.didUpdateWidget(J);let Q=J.props,Z=this.widget.props;if(this.props=Z,Q.controller!==Z.controller||Q.triggers!==Z.triggers||Q.optionsBuilder!==Z.optionsBuilder||Q.textFieldProps!==Z.textFieldProps||Q.onSelected!==Z.onSelected)this.controller.initialize({textController:Z.controller,triggers:Z.triggers,optionsBuilder:Z.optionsBuilder,onSelected:Z.onSelected});this.setState(()=>{})}dispose(){this.removeOverlay(),this.stateListener?.dispose(),this.controller.dispose(),this._effectiveFocusNode.dispose(),super.dispose()}invoke=(J)=>{if(!this.controller.currentState.isActive)return"ignored";if(J instanceof qo)return this.controller.selectNext(),this.updateScrollPosition(),"handled";if(J instanceof zo)return this.controller.selectPrevious(),this.updateScrollPosition(),"handled";if(J instanceof Wo)return this.controller.acceptSelected(),"handled";if(J instanceof xH1)return this.controller.dismiss(),"handled";return"ignored"};updateScrollPosition(){let J=this.controller.currentState;if(!J.isActive||J.selectedIndex<0)return;let Q=J.selectedIndex,Z=J.options.length,X=Z;try{let z=this.layerLink.getTargetTransform();if(z){let W=z.position.y,U=2,F=W-2;X=Math.min(Z,Math.max(1,F))}}catch{}if(X>=Z){this.scrollOffset=0;return}let Y=Q-this.scrollOffset,K=1,G=this.scrollOffset;if(Y>=X-K)G=Math.max(0,Q-(X-K-1));if(Y<K)G=Math.max(0,Q-K);let q=Math.max(0,Z-X);G=Math.min(G,q),this.scrollOffset=G}build(J){let Q=new D3({...this.props.textFieldProps,controller:this.props.controller,focusNode:this._effectiveFocusNode,autofocus:!1}),Z=new qU({shortcuts:new Map([[new h6("ArrowDown"),new qo],[new h6("ArrowUp"),new zo],[new h6("n",{ctrl:!0}),new qo],[new h6("p",{ctrl:!0}),new zo],[new h6("Enter"),new Wo],[new h6("Escape"),new xH1],[new h6("Tab"),new Wo]]),focusNode:this._effectiveFocusNode,child:Q}),X=new MX({actions:new Map([[qo,new k9(this.invoke)],[zo,new k9(this.invoke)],[Wo,new k9(this.invoke)],[xH1,new k9(this.invoke)]]),child:Z});return new d40({link:this.layerLink,child:X})}updateOverlay(){let J=this.controller.currentState;if(J.isActive&&J.options.length>0)if(!this.overlayEntry)this.createOverlay();else this.overlayEntry.markNeedsBuild();else this.removeOverlay()}createOverlay(){if(this.overlayEntry)return;this.overlayEntry=new A80((J)=>{let Q=this.controller.currentState;return this.buildOverlayContent(J,Q)});try{zP.of(this.context).insert(this.overlayEntry)}catch(J){p.error("Failed to insert autocomplete overlay:",J),this.overlayEntry=null}}removeOverlay(){if(this.overlayEntry)this.overlayEntry.remove(),this.overlayEntry=null}buildOverlayContent(J,Q){let Z=e6.maybeOf(J),X=Z?.colorScheme.background??P1.black,Y=this.props.overlayBorderColor??Z?.colorScheme.border??P1.white,K=Q.options.length;try{let w=this.layerLink.getTargetTransform();if(w){let O=w.position.y,$=2,I=O-2;K=Math.min(K,Math.max(1,I))}}catch{}this.updateScrollPosition();let G=this.scrollOffset,q=Math.min(Q.options.length,G+K),z=[],W=0;for(let w=G;w<q;w++){let O=Q.options[w];if(!O)continue;let $=w===Q.selectedIndex,I,R;if(this.props.optionViewBuilder){I=this.props.optionViewBuilder(J,O,$);let j=this.props.displayStringForOption?.(O)??String(O),C="",x=j,y="",P=O;if(P&&typeof P==="object"&&"type"in P)switch(P.type){case"file":C="@",x=P.path||j;break;case"thread":x=P.title||j,y=P.description||"";break}R=C+x+(y?" - "+y:"")}else{let j=this.props.displayStringForOption?.(O)??String(O),C=Z?.colorScheme.selection??P1.index(8),x=Z?.colorScheme.foreground??P1.white;I=new l1({text:new D1(j,new $1({color:x,backgroundColor:$?C:void 0}))}),R=j}let T=r8.of(J),E=tK(R,T.supportsEmojiWidth);W=Math.max(W,E),z.push(I)}let U=r8.sizeOf(J).width,F=W+4,H=Math.floor(U*0.9),B=Math.max(Math.min(F,H),Math.min(30,H)),N=z.length+2,L=this.props.showMenuBelow?1:-N;if(this.props.showMenuBelow){let w=this.props.controller.getCursorLine();if(w>=0)L=w+1}let A=new U0({width:B,child:new u0({height:N,padding:M0.symmetric(1,0),decoration:new U9(X,f8.all(new E8(Y,1,"rounded"))),child:new x0({crossAxisAlignment:"start",children:z})})});return new p40({link:this.layerLink,showWhenUnlinked:!1,offset:{x:0,y:L},child:A})}}function wZ8(J){if(J.kind!=="file"&&J.kind!=="folder")throw Error("Invalid completion item: missing path or kind");return{type:"file",path:J.path,kind:J.kind}}function OZ8(J,Q,Z){return{type:"thread",threadId:J,title:Q,description:Z}}function i40(J){switch(J.type){case"file":return J.path;case"thread":return J.title;case"hint":return J.message}}function $Z8(J){switch(J.type){case"file":return;case"thread":return J.description||J.title;case"hint":return}}class Gw{detect(J,Q){if(!J||Q<1)return null;let Z=c4(J);if(Q>Z.length)return null;let X=this.findWordStart(Z,Q);if(X>=Z.length||Z[X]!=="@")return null;let Y=Z.slice(X+1,Q).join("");if(Y.includes(" ")||Y.includes("\t")||Y.includes(`
7094
+ ... (output truncated at ${A3} characters)`;Y({success:M,output:A.trim(),error:!M?L.trim()||"Command failed":void 0,exitCode:V??void 0})}),U.on("error",(V)=>{clearTimeout(W);let M=V.message;if(z)M=`Command timed out after ${Z}ms`;else if(V.message.includes("operation was aborted")||V.name==="AbortError")M="The command was aborted";Y({success:!1,output:F.join(""),error:M})})})}function rl4(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return ol4(Z,X?[...X]:null,Y,Q);else return sl4(Z,X?[...X]:null,Y,Q)}function sl4(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function ol4(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];switch(Z.toLowerCase()){case".bat":case".cmd":return["cmd.exe",["/c",J,...X]];case".ps1":return["powershell.exe",["-ExecutionPolicy","Bypass","-File",J,...X]];case".exe":return[J,X];default:return[J,X]}}q0();z5();RB();ZW();iU();MD();Jh();import{writeFile as el4}from"fs/promises";import Ji4 from"path";q0();ZW();class g40{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Z])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1762473708-g720034"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await m51(Q,this.configService)}catch(Q){p.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}i8();class u40 extends h0{props;constructor(J){super();this.props=J}createState(){return new BZ8}}class BZ8 extends f0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Z)=>{this.setState(()=>{this._state=Z(this._state)})};return this.widget.props.builder(J,Q,this._state)}}i8();i8();class DZ8 extends f0{controller=new sq;focusNode=new Y9({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});initState(){this.focusNode.requestFocus()}dispose(){this.focusNode.dispose()}build(J){let Q=N6.of(J),{colors:Z}=Q,X=f8.all(new E8(Z.foreground,1,"solid")),Y=new D3({controller:this.controller,focusNode:this.focusNode,placeholder:"Enter command argument...",onSubmitted:(q)=>{this.widget.props.onSubmit(q.trim())},autofocus:!0,style:{textColor:Z.foreground,border:null},maxLines:1}),K=new i6({children:[new u0({decoration:{color:P1.default()},child:new l1({text:new D1(">",new $1({color:Z.foreground}))})}),new t6({child:Y})]}),G=new u0({padding:M0.symmetric(1,0),child:new l1({text:new D1("",void 0,[new D1("Command: ",new $1({color:Z.foreground})),new D1(this.widget.props.commandName,new $1({color:P1.yellow,bold:!0}))])})});return new u0({decoration:{border:X,color:P1.default()},padding:M0.all(1),child:new x0({children:[G,new U0({height:1}),K]})})}}class m40 extends h0{props;constructor(J){super();this.props=J}createState(){return new DZ8}}iU();q0();i8();q0();class VZ8{_listeners=new Set;_disposed=!1;addListener(J){if(this._disposed)throw Error("Cannot add listener to disposed ChangeNotifier");this._listeners.add(J)}removeListener(J){this._listeners.delete(J)}notifyListeners(){if(this._disposed)return;let J=Array.from(this._listeners);for(let Q of J)try{Q()}catch(Z){}}dispose(){this._disposed=!0,this._listeners.clear()}get disposed(){return this._disposed}get hasListeners(){return this._listeners.size>0}}class $P extends VZ8{_value;constructor(J){super();this._value=J}get value(){return this._value}set value(J){let Q=typeof J==="object"||this._value!==J;if(this._value=J,Q)this.notifyListeners()}}function MZ8(J,Q){let Z=()=>{Q()};return J.addListener(Z),{dispose:()=>J.removeListener(Z)}}i8();s4();O9();class p40 extends o5{link;showWhenUnlinked;offset;constructor({key:J,link:Q,showWhenUnlinked:Z=!0,offset:X={x:0,y:0},child:Y}){super({key:J,child:Y});this.link=Q,this.showWhenUnlinked=Z,this.offset=X}createElement(){return new nA(this)}createRenderObject(){return new NZ8(this.link,this.showWhenUnlinked,this.offset)}updateRenderObject(J){J.link=this.link,J.showWhenUnlinked=this.showWhenUnlinked,J.setFollowerOffset(this.offset)}}class NZ8 extends F8{_link;_showWhenUnlinked;_followerOffset;_cachedPosition=null;constructor(J,Q,Z){super();this._link=J,this._showWhenUnlinked=Q,this._followerOffset=Z}get link(){return this._link}set link(J){this._link=J,this._cachedPosition=null,this.markNeedsLayout()}get showWhenUnlinked(){return this._showWhenUnlinked}set showWhenUnlinked(J){if(this._showWhenUnlinked!==J)this._showWhenUnlinked=J,this.markNeedsLayout()}setFollowerOffset(J){if(this._followerOffset.x!==J.x||this._followerOffset.y!==J.y)this._followerOffset={...J},this.markNeedsLayout()}calculatePosition(){let J=this._link.getTargetTransform();if(!J)return null;return{x:J.position.x+this._followerOffset.x,y:J.position.y+this._followerOffset.y}}shouldShow(){return this._link.target!==null||this._showWhenUnlinked}performLayout(){let J=this._lastConstraints;if(c6(!!J,"performLayout called without constraints"),!this.shouldShow()){this.setSize(0,0),super.performLayout();return}let Q=this.calculatePosition();if(this._cachedPosition=Q,Q)this.setOffset(Q.x,Q.y);if(this.children.length>0){let Z=this.children[0];Z.layout(J);let X=Z.size;this.setSize(X.width,X.height)}else this.setSize(0,0);super.performLayout()}getCurrentPosition(){return this._cachedPosition}setOffset(J,Q){super.setOffset(J,Q)}paint(J,Q=0,Z=0){super.paint(J,Q,Z)}}s4();O9();class d40 extends o5{link;constructor({key:J,link:Q,child:Z}){super({key:J,child:Z});this.link=Q}createElement(){return new nA(this)}createRenderObject(){return new LZ8(this.link)}updateRenderObject(J){J.link=this.link}}class LZ8 extends F8{_link;_globalPosition={x:0,y:0};constructor(J){super();this._link=J}get link(){return this._link}set link(J){if(this._link===J)return;this._link._setTarget(null),this._link=J,this._link._setTarget(this)}attach(){super.attach(),this._link._setTarget(this)}detach(){this._link._setTarget(null),super.detach()}getGlobalPosition(){let J=this.offset.x,Q=this.offset.y,Z=this.parent;while(Z&&Z instanceof F8)J+=Z.offset.x,Q+=Z.offset.y,Z=Z.parent;return{x:J,y:Q}}getSize(){let J=this.size;return{width:J.width,height:J.height}}updateGlobalPosition(){let J={...this._globalPosition};if(this._globalPosition=this.getGlobalPosition(),J.x!==this._globalPosition.x||J.y!==this._globalPosition.y)this._link._notifyFollowers()}performLayout(){let J=this._lastConstraints;if(c6(!!J,"performLayout called without constraints"),this.children.length>0){let Q=this.children[0];Q.layout(J);let Z=Q.size;this.setSize(Z.width,Z.height)}else this.setSize(0,0);this.updateGlobalPosition(),super.performLayout()}}q0();class c40{_target=null;_followers=new Set;get target(){return this._target}_setTarget(J){if(this._target===J)return;this._target=J,this._notifyFollowers()}_addFollower(J){this._followers.add(J)}_removeFollower(J){this._followers.delete(J)}_notifyFollowers(){for(let J of this._followers)try{J()}catch(Q){p.error("Error in LayerLink follower callback:",Q)}}getTargetTransform(){if(!this._target)return null;return{position:this._target.getGlobalPosition(),size:this._target.getSize()}}}q0();class l40{_state;_textController=null;_triggers=[];_optionsBuilder=null;_onSelected=null;_disposed=!1;constructor(){let J={trigger:null,options:[],selectedIndex:-1,isActive:!1,generationId:0};this._state=new $P(J)}get state(){return this._state}get currentState(){return this._state.value}initialize({textController:J,triggers:Q,optionsBuilder:Z,onSelected:X}){if(this._disposed)throw Error("Cannot initialize disposed AutocompleteController");this._cleanup(),this._textController=J,this._triggers=Q,this._optionsBuilder=Z,this._onSelected=X||null,this._textController.addListener(this._handleTextChange)}selectNext(){let J=this.currentState;if(!J.isActive||J.options.length===0)return;let Q=J.selectedIndex<J.options.length-1?J.selectedIndex+1:0;this._updateState({selectedIndex:Q})}selectPrevious(){let J=this.currentState;if(!J.isActive||J.options.length===0)return;let Q=J.selectedIndex>0?J.selectedIndex-1:J.options.length-1;this._updateState({selectedIndex:Q})}acceptSelected(){let J=this.currentState;if(!J.isActive||J.selectedIndex<0||J.selectedIndex>=J.options.length)return;let Q=J.options[J.selectedIndex];if(!Q)return;if(this.dismiss(),this._onSelected)this._onSelected(Q)}dismiss(){this._updateState({trigger:null,options:[],selectedIndex:-1,isActive:!1})}dispose(){this._disposed=!0,this._cleanup(),this._state.dispose()}_handleTextChange=()=>{if(!this._textController||!this._optionsBuilder)return;let J=this._textController.text,Q=this._textController.cursorPosition,Z=null;for(let Y of this._triggers){let K=Y.detect(J,Q);if(K&&(!Z||K.start>Z.start))Z=K}if(!Z){if(this.currentState.isActive)this.dismiss();return}let X=this.currentState.generationId+1;this._updateState({trigger:Z,generationId:X,isActive:!0,selectedIndex:-1}),this._buildOptions(Z.query,X)};async _buildOptions(J,Q){if(!this._optionsBuilder)return;try{let Z=await this._optionsBuilder(J);if(this.currentState.generationId===Q&&!this._disposed)this._updateState({options:Z,selectedIndex:Z.length>0?0:-1,isActive:Z.length>0})}catch(Z){if(p.error("Error building autocomplete options:",Z),this.currentState.generationId===Q&&!this._disposed)this._updateState({options:[],selectedIndex:-1,isActive:!1})}}_updateState(J){if(this._disposed)return;this._state.value={...this.currentState,...J}}_cleanup(){if(this._textController)this._textController.removeListener(this._handleTextChange)}}class qo{}class zo{}class Wo{}class xH1{}class yH1 extends h0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new AZ8(this.props)}}class AZ8 extends f0{props;controller;stateListener=null;overlayEntry=null;layerLink=new c40;scrollOffset=0;_effectiveFocusNode;constructor(J){super();this.props=J}initState(){if(super.initState(),this._effectiveFocusNode=this.props.focusNode||new Y9({debugLabel:"AutocompleteFocusOwned"}),this.controller=new l40,this.controller.initialize({textController:this.props.controller,triggers:this.props.triggers,optionsBuilder:this.props.optionsBuilder,onSelected:this.props.onSelected}),this.stateListener=MZ8(this.controller.state,()=>{this.updateOverlay(),this.setState(()=>{})}),this.props.autofocus??!0)g9.instance.addPostFrameCallback(()=>{this._effectiveFocusNode.requestFocus()})}didUpdateWidget(J){super.didUpdateWidget(J);let Q=J.props,Z=this.widget.props;if(this.props=Z,Q.controller!==Z.controller||Q.triggers!==Z.triggers||Q.optionsBuilder!==Z.optionsBuilder||Q.textFieldProps!==Z.textFieldProps||Q.onSelected!==Z.onSelected)this.controller.initialize({textController:Z.controller,triggers:Z.triggers,optionsBuilder:Z.optionsBuilder,onSelected:Z.onSelected});this.setState(()=>{})}dispose(){this.removeOverlay(),this.stateListener?.dispose(),this.controller.dispose(),this._effectiveFocusNode.dispose(),super.dispose()}invoke=(J)=>{if(!this.controller.currentState.isActive)return"ignored";if(J instanceof qo)return this.controller.selectNext(),this.updateScrollPosition(),"handled";if(J instanceof zo)return this.controller.selectPrevious(),this.updateScrollPosition(),"handled";if(J instanceof Wo)return this.controller.acceptSelected(),"handled";if(J instanceof xH1)return this.controller.dismiss(),"handled";return"ignored"};updateScrollPosition(){let J=this.controller.currentState;if(!J.isActive||J.selectedIndex<0)return;let Q=J.selectedIndex,Z=J.options.length,X=Z;try{let z=this.layerLink.getTargetTransform();if(z){let W=z.position.y,U=2,F=W-2;X=Math.min(Z,Math.max(1,F))}}catch{}if(X>=Z){this.scrollOffset=0;return}let Y=Q-this.scrollOffset,K=1,G=this.scrollOffset;if(Y>=X-K)G=Math.max(0,Q-(X-K-1));if(Y<K)G=Math.max(0,Q-K);let q=Math.max(0,Z-X);G=Math.min(G,q),this.scrollOffset=G}build(J){let Q=new D3({...this.props.textFieldProps,controller:this.props.controller,focusNode:this._effectiveFocusNode,autofocus:!1}),Z=new qU({shortcuts:new Map([[new h6("ArrowDown"),new qo],[new h6("ArrowUp"),new zo],[new h6("n",{ctrl:!0}),new qo],[new h6("p",{ctrl:!0}),new zo],[new h6("Enter"),new Wo],[new h6("Escape"),new xH1],[new h6("Tab"),new Wo]]),focusNode:this._effectiveFocusNode,child:Q}),X=new MX({actions:new Map([[qo,new k9(this.invoke)],[zo,new k9(this.invoke)],[Wo,new k9(this.invoke)],[xH1,new k9(this.invoke)]]),child:Z});return new d40({link:this.layerLink,child:X})}updateOverlay(){let J=this.controller.currentState;if(J.isActive&&J.options.length>0)if(!this.overlayEntry)this.createOverlay();else this.overlayEntry.markNeedsBuild();else this.removeOverlay()}createOverlay(){if(this.overlayEntry)return;this.overlayEntry=new A80((J)=>{let Q=this.controller.currentState;return this.buildOverlayContent(J,Q)});try{zP.of(this.context).insert(this.overlayEntry)}catch(J){p.error("Failed to insert autocomplete overlay:",J),this.overlayEntry=null}}removeOverlay(){if(this.overlayEntry)this.overlayEntry.remove(),this.overlayEntry=null}buildOverlayContent(J,Q){let Z=e6.maybeOf(J),X=Z?.colorScheme.background??P1.black,Y=this.props.overlayBorderColor??Z?.colorScheme.border??P1.white,K=Q.options.length;try{let w=this.layerLink.getTargetTransform();if(w){let O=w.position.y,$=2,I=O-2;K=Math.min(K,Math.max(1,I))}}catch{}this.updateScrollPosition();let G=this.scrollOffset,q=Math.min(Q.options.length,G+K),z=[],W=0;for(let w=G;w<q;w++){let O=Q.options[w];if(!O)continue;let $=w===Q.selectedIndex,I,R;if(this.props.optionViewBuilder){I=this.props.optionViewBuilder(J,O,$);let j=this.props.displayStringForOption?.(O)??String(O),C="",x=j,y="",P=O;if(P&&typeof P==="object"&&"type"in P)switch(P.type){case"file":C="@",x=P.path||j;break;case"thread":x=P.title||j,y=P.description||"";break}R=C+x+(y?" - "+y:"")}else{let j=this.props.displayStringForOption?.(O)??String(O),C=Z?.colorScheme.selection??P1.index(8),x=Z?.colorScheme.foreground??P1.white;I=new l1({text:new D1(j,new $1({color:x,backgroundColor:$?C:void 0}))}),R=j}let T=r8.of(J),E=tK(R,T.supportsEmojiWidth);W=Math.max(W,E),z.push(I)}let U=r8.sizeOf(J).width,F=W+4,H=Math.floor(U*0.9),B=Math.max(Math.min(F,H),Math.min(30,H)),N=z.length+2,L=this.props.showMenuBelow?1:-N;if(this.props.showMenuBelow){let w=this.props.controller.getCursorLine();if(w>=0)L=w+1}let A=new U0({width:B,child:new u0({height:N,padding:M0.symmetric(1,0),decoration:new U9(X,f8.all(new E8(Y,1,"rounded"))),child:new x0({crossAxisAlignment:"start",children:z})})});return new p40({link:this.layerLink,showWhenUnlinked:!1,offset:{x:0,y:L},child:A})}}function wZ8(J){if(J.kind!=="file"&&J.kind!=="folder")throw Error("Invalid completion item: missing path or kind");return{type:"file",path:J.path,kind:J.kind}}function OZ8(J,Q,Z){return{type:"thread",threadId:J,title:Q,description:Z}}function i40(J){switch(J.type){case"file":return J.path;case"thread":return J.title;case"hint":return J.message}}function $Z8(J){switch(J.type){case"file":return;case"thread":return J.description||J.title;case"hint":return}}class Gw{detect(J,Q){if(!J||Q<1)return null;let Z=c4(J);if(Q>Z.length)return null;let X=this.findWordStart(Z,Q);if(X>=Z.length||Z[X]!=="@")return null;let Y=Z.slice(X+1,Q).join("");if(Y.includes(" ")||Y.includes("\t")||Y.includes(`
7095
7095
  `))return null;return{start:X,end:Q,query:Y,trigger:"@"}}findWordStart(J,Q){let Z=Q;for(let X=Q-1;X>=0;X--){let Y=J[X];if(!Y||/[\s([{]/.test(Y)){Z=X+1;break}if(X===0)Z=0}return Z}}class Uo extends h0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new RZ8(this.props)}}class RZ8 extends f0{props;_effectiveFocusNode;constructor(J){super();this.props=J}buildOptions=async(J)=>{let Q=this.props.controller.text,Z=this.props.controller.cursorPosition,Y=new Gw().detect(Q,Z);if(Y)return await this.props.completionBuilder.buildOptions(Y);return[]};defaultOnOptionSelected=(J)=>{switch(J.type){case"hint":return;case"file":{let Q=this.props.controller.text,Z=this.props.controller.cursorPosition,Y=Q.slice(0,Z).lastIndexOf("@");if(Y!==-1){let K=Q.slice(0,Y),G=Q.slice(Z),q=K+`@${J.path} `+G;this.props.controller.clear(),this.props.controller.insertText(q),this.props.controller.cursorPosition=Y+1+J.path.length+1}break}case"thread":{let Q=this.props.controller.text,Z=this.props.controller.cursorPosition,X=Q.split(" ");if(X.length>=1&&X[0]==="/continue"){let Y=`/continue ${J.threadId} `;this.props.onSubmitted?.(Y)}else{let K=Q.slice(0,Z).lastIndexOf("@");if(K!==-1){let G=Q.slice(0,K),q=Q.slice(Z),W=`${this.props.ampURL.replace(/\/$/,"")}/threads/${J.threadId}`,U=G+`${W} `+q;this.props.controller.clear(),this.props.controller.insertText(U),this.props.controller.cursorPosition=K+W.length+1}}break}}};initState(){super.initState(),this._effectiveFocusNode=this.props.focusNode||new Y9({debugLabel:"PromptEditorFocus"}),this.props.controller.onInsertText=(J,Q)=>{if(J.length<=3)return!0;let Z=s58(J);if(!Z)return!0;if(this.props.onInsertImage)return this.props.onInsertImage(Z);return!0}}didUpdateWidget(J){super.didUpdateWidget(J),this.props=this.widget.props}dispose(){if(!this.props.focusNode)this._effectiveFocusNode.dispose();super.dispose()}_handleOpenInEditor=async(J)=>{let{mkdtemp:Q,readFile:Z,unlink:X,rmdir:Y,writeFile:K}=await import("node:fs/promises"),{tmpdir:G}=await import("node:os"),q=await import("node:path");try{let z=await Q(q.join(G(),"amp-edit-")),W=q.join(z,"message.amp.md");await K(W,J,"utf-8"),await rA(W);try{let U=await Z(W,"utf-8");this.props.controller.text=U}catch(U){if(U?.code!=="ENOENT")p.error("Failed to read temporary file",U)}try{await X(W),await Y(z)}catch(U){p.warn("Failed to clean up temporary file",U)}}catch(z){p.error("Error opening editor:",z)}};_handleBackspaceAtStart=()=>{if(this.props.imageAttachments.length>0&&this.props.popImage)return this.props.popImage(),!0;return!1};build(J){let Q=this.props.theme,Z=this.props.imageAttachments.length>0?new u0({padding:M0.only({bottom:1,left:1}),child:new l1({text:new D1("",void 0,[new D1("Images: ",new $1({color:Q.foreground,dim:!0})),...this.props.imageAttachments.flatMap((Y,K)=>[new D1(`[image ${K+1}]`,new $1({color:Q.success})),...K<this.props.imageAttachments.length-1?[new D1(" ")]:[]])])})}):null,X=new yH1({controller:this.props.controller,triggers:this.props.triggers,optionsBuilder:this.buildOptions,onSelected:this.props.onOptionSelected??this.defaultOnOptionSelected,displayStringForOption:(Y)=>i40(Y),overlayBorderColor:Q.border,focusNode:this._effectiveFocusNode,autofocus:this.props.autofocus??!0,showMenuBelow:this.props.showMenuBelow??!1,textFieldProps:{placeholder:this.props.placeholder,wrap:!0,minLines:3,maxLines:null,expands:!0,autofocus:!1,enabled:this.props.enabled??!0,onSubmitted:this.props.onSubmitted,onOpenInEditor:this._handleOpenInEditor,submitKey:{character:"Enter"},prompts:this.props.shellPromptRules,style:{border:null},clipboard:this.props.clipboard,onCopy:this.props.onCopy,copyOnSelectionEnabled:!0,onBackspaceWhenEmpty:this._handleBackspaceAtStart},optionViewBuilder:(Y,K,G)=>{let q=G?Q.selection:void 0,z=K.type==="thread"?Q.warning:Q.secondary,W=Q.foreground,U=Q.foreground,F,H;switch(K.type){case"file":F="@",H=K.path;break;case"thread":F="@",H=K.title;break;case"hint":F="",H=K.message;break;default:F="",H=i40(K);break}let B=$Z8(K),V=new D1(F,new $1({color:z})),M=new D1(H,new $1({color:W})),N=[V,M];if(B){let L=new D1(" - ",new $1({color:U,dim:!0})),A=new D1(B,new $1({color:U,dim:!0}));N.push(L,A)}return new u0({decoration:new U9(q),child:new l1({text:new D1("",void 0,N),maxLines:1,overflow:"ellipsis"})})}});if(Z)return new x0({crossAxisAlignment:"start",children:[Z,new t6({child:X})]});return X}requestFocus(){this._effectiveFocusNode.requestFocus()}}O9();i8();class IZ8 extends f0{controller=new sq;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new Y9({debugLabel:"CommandMultilinePrompt",onKey:(J)=>{if(J.key==="Escape"){if(this.isConfirmingClearInput){if(this.controller.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[],this.imagePaths=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.controller.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return this.widget.props.onDismiss(),"handled"}return"ignored"}});initState(){this.focusNode.requestFocus()}_handleInsertImage=(J)=>{if(this.imageAttachments.length>=AM)return!1;let Q=Ry(J);if(Q)return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Q],this.imagePaths=[...this.imagePaths,J]}),!1;return!1};_handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1),this.imagePaths=this.imagePaths.slice(0,-1)})};dispose(){if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.focusNode.dispose(),this.controller.dispose()}build(J){let Q=N6.of(J),{colors:Z,app:X}=Q,K=r8.of(J).size.height,G=Math.max(Math.floor(K*0.5),10),q=new Uo({controller:this.controller,triggers:[new Gw],completionBuilder:this.widget.props.completionBuilder,ampURL:this.widget.props.ampURL,onSubmitted:(B)=>{this.widget.props.onSubmit(B.trim(),this.imageAttachments)},theme:Z,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:x4.instance.tuiInstance.clipboard,showMenuBelow:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),z=new V9({focusNode:this.focusNode,child:q}),W=new u0({constraints:new P6({maxHeight:G}),child:z}),U=new u0({padding:M0.symmetric(1,0),child:new l1({text:new D1("",void 0,[new D1("Command: ",new $1({color:Z.foreground})),new D1(this.widget.props.commandName,new $1({color:P1.yellow,bold:!0}))])})}),F=new u0({padding:M0.symmetric(1,0),child:new l1({text:this.isConfirmingClearInput?new D1("",void 0,[new D1("Esc",new $1({color:X.keybind})),new D1(" again to clear input",new $1({color:Z.foreground,dim:!0}))]):new D1("",void 0,[new D1("Press ",new $1({color:Z.foreground,dim:!0})),new D1("Enter",new $1({color:X.keybind})),new D1(" to submit, ",new $1({color:Z.foreground,dim:!0})),new D1("Esc",new $1({color:X.keybind})),new D1(" to clear",new $1({color:Z.foreground,dim:!0}))])})}),H=[U,new U0({height:1}),new t6({child:W}),new U0({height:1}),F];return new u0({decoration:{border:f8.all(new E8(Z.foreground,1,"solid")),color:P1.default()},padding:M0.all(1),child:new x0({children:H})})}}class bH1 extends h0{props;constructor(J){super();this.props=J}createState(){return new IZ8}}i8();class Fo extends h0{props;constructor(J){super();this.props=J}createState(){return new EZ8}}class EZ8 extends f0{_spinner=new iH;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Q=N6.of(J),{colors:Z}=Q,X=f8.all(new E8(Z.foreground,1,"solid")),Y=this._spinner.toBraille(),K=new l1({textAlign:"center",text:new D1("",void 0,[new D1(Y,new $1({color:P1.yellow})),new D1(" ",void 0),new D1(this.widget.props.message,new $1({color:Z.foreground}))])}),q=[new t6({child:new x0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)q.push(new U0({height:2,child:new u0({padding:M0.symmetric(2,0),child:new l1({text:new D1("",new $1({dim:!0}),[new D1("Press ",new $1({color:Z.foreground})),new D1("Esc",new $1({color:Z.info})),new D1(" to cancel",new $1({color:Z.foreground}))])})})}));let z=new u0({decoration:new U9(P1.default(),X),child:new U0({width:60,height:7,child:new x0({mainAxisAlignment:"start",children:q})})});if(this.widget.props.onAbort)return new V9({debugLabel:"LoadingDialog",autofocus:!0,onKey:(W)=>{if(W.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}i8();class RP extends h0{props;constructor(J){super();this.props=J}createState(){return new PZ8}}class PZ8 extends f0{dispose(){super.dispose()}isWidgetMessage(J){return J instanceof ds}build(J){let Q=this.widget.props.message,Z=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let W=fF1(Q);return{title:W.title,type:W.type,description:W.description}})(),X=Z.type==="error"?P1.red:P1.yellow,Y=f8.all(new E8(P1.white,1,"solid")),K=new u0({padding:M0.symmetric(1,0),child:new l1({text:new D1(Z.title,new $1({color:X,bold:!0}))})}),G=this.isWidgetMessage(Q)?Q.widget:new l1({text:new D1(Z.description,new $1({color:P1.white})),selectable:!0}),q=new t6({child:new GP({child:new u0({padding:M0.symmetric(1,0),child:G})})}),z=new u0({padding:M0.symmetric(1,0),child:new l1({text:new D1("Press any key to close",new $1({color:P1.white,dim:!0,italic:!0}))})});return new V9({onKey:()=>{return this.widget.props.onDismiss(),"handled"},autofocus:!0,child:new u0({decoration:{border:Y,color:P1.default()},padding:M0.all(1),child:new x0({mainAxisAlignment:"center",children:[K,new U0({height:1}),q,z]})})})}}class CZ8 extends h0{props;constructor(J){super();this.props=J}createState(){return new SZ8}}class SZ8 extends f0{isLoading=!0;error=null;initState(){super.initState(),g9.instance.addPostFrameCallback(()=>{this.startHandoff()})}async startHandoff(){try{let J=await this.widget.props.handleHandoff({text:this.widget.props.text,images:this.widget.props.images});if(J.ok)this.widget.props.onDismiss();else this.setState(()=>{this.isLoading=!1,this.error=J.error})}catch(J){this.setState(()=>{this.isLoading=!1,this.error=J instanceof Error?J:Error(String(J))})}}build(J){let Q=[];if(this.isLoading)Q.push(new Fo({message:"Handing off...",onAbort:this.widget.props.onAbort}));else if(this.error)Q.push(new RP({message:this.error,onDismiss:()=>{this.setState(()=>{this.isLoading=!1,this.error=null}),this.widget.props.onDismiss()}}));return new u7({children:Q,fit:"expand"})}}class kZ8 extends h0{props;constructor(J){super();this.props=J}createState(){return new vZ8}}class vZ8 extends f0{result=void 0;isLoading=!1;build(J){let Q=[];if(this.isLoading)Q.push(new Fo({message:"Updating visibility..."}));else if(this.result!==void 0)Q.push(new RP({message:this.result,onDismiss:()=>{this.widget.props.onDismiss()}}));else{let Z=["private","workspace","unlisted","public"],X=this.widget.props.workspace?.groups&&this.widget.props.workspace.groups.length>0?Z.concat("group"):Z;Q.push(new tA({items:X,getLabel:(Y)=>{switch(Y){case"private":return"Private - Only you can see this thread";case"workspace":return"Workspace - Visible to workspace members";case"group":return"Group - Visible to group members";case"unlisted":return"Unlisted - Anyone with the link can view";case"public":return"Public - Searchable and on your public profile"}},title:"Select Thread Visibility",onAccept:async(Y)=>{this.setState(()=>{this.isLoading=!0});let K=await this.widget.props.execute(Y);this.setState(()=>{this.isLoading=!1,this.result=K})},onDismiss:this.widget.props.onDismiss}))}return new u7({children:Q,fit:"expand"})}}var jZ8={EMPTY_THREAD:"Thread is empty",THREAD_HAS_MESSAGES:"Can only change mode for new threads",NOT_PROCESSING:"Agent must be processing to queue prompts",NO_QUEUED_MESSAGES:"No queued messages",NO_TEXT_TO_CLEAR:"No prompt to clear",NO_TEXT_SELECTED:"No text selected",INSUFFICIENT_MODES:"Multiple agent modes required",ALREADY_IN_MODE:"Already in this mode",DEV_ONLY:"Only available in development"};function Qi4(J){return J.startsWith("custom-command-")}function TZ8(J){return J.startsWith("agent-mode-")}function Zi4(J){return J.replace(/^custom-command-/,"")}class n40{configService;registry;onExecute;onExecutionComplete;commands=new Map;latestCustom=[];latestConfig=null;telemetrySubmitter;constructor(J,Q,Z,X){this.configService=J;this.registry=Q;this.onExecute=Z;this.onExecutionComplete=X;this.configService.config.subscribe((Y)=>{this.latestConfig=Y,this.commands.clear(),this.registerCommands(Y)}),this.registry.commands.subscribe((Y)=>this.latestCustom=Y),this.telemetrySubmitter=new g40(async()=>{try{return(await this.configService.getLatest()).settings["experimental.cli.commandTelemetry.enabled"]===!0}catch{return!1}},this.configService)}async execute(J,Q,Z=[],X){this.telemetrySubmitter.submit(J).catch((U)=>{p.debug("Failed to submit command telemetry",U)});let Y=Date.now(),K=`command-${Y}-${Math.random().toString(36).substring(7)}`,G=this.commands.get(J);if(G){this.onExecute({id:K,name:G.id,startTime:Y,abortController:X});try{return await G.execute(Q,X,Z)}finally{this.onExecutionComplete()}}let q=Zi4(J),z=this.latestCustom.find((U)=>U.name===q);if(!z)return;this.onExecute({id:K,name:z.name,startTime:Y,abortController:X});let W=await h40(q,Z,this.registry,{signal:X.signal});if(this.onExecutionComplete(),W.success){let U=Q.editorState.text,H=U.trim()&&!U.endsWith(`
7096
7096
 
7097
7097
  `)?`
@@ -7145,7 +7145,7 @@ https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_di
7145
7145
  `),J.stdout.write(`Thread: ${H}
7146
7146
  `),J.stdout.write(`Continue this thread with: amp threads continue ${U}
7147
7147
  `)}}function S50(J){return J==="smart"?P1.rgb(3,197,97):J==="rush"?P1.rgb(228,180,2):J==="free"?P1.rgb(0,184,255):Ln4(J)}class CX8 extends h0{props;constructor(J){super();this.props=J}createState(){return new SX8}}class SX8 extends f0{viewportHeight=1;scrollListenerAttached=!1;initState(){if(!this.scrollListenerAttached)this.widget.props.controller.addListener(()=>{this.updateViewportHeight()}),this.scrollListenerAttached=!0}build(J){let{todos:Q,enabled:Z,controller:X,appTheme:Y}=this.widget.props;return new i6({crossAxisAlignment:"stretch",children:[new t6({child:new LX({controller:X,autofocus:!1,child:new x40({todos:Q,enabled:Z})})}),new UU({controller:X,thumbColor:Y.app.scrollbarThumb,trackColor:Y.app.scrollbarTrack,getScrollInfo:()=>{let{maxScrollExtent:K,offset:G}=X,q=this.viewportHeight,z=K+q;return{totalContentHeight:Math.max(z,0),viewportHeight:Math.max(q,1),scrollOffset:Math.max(G,0)}}})]})}updateViewportHeight(){let J=this.getViewportHeight();if(J!==this.viewportHeight)this.viewportHeight=J}getViewportHeight(){let J=this.context.findRenderObject();if(!J)return this.viewportHeight;let Q=(X,Y=0)=>{if(X&&"size"in X&&"children"in X){let K=X.children||[];for(let G of K){if(G&&"size"in G){let z=G.size;if(typeof z?.height==="number"&&z.height>0)return z.height}let q=Q(G,Y+1);if(q>0)return q}}return 0},Z=Q(J);if(Z>0)return Z;if("size"in J){let X=J.size;if(typeof X?.height==="number"&&X.height>0)return X.height}return this.viewportHeight}}class kX8 extends M6{props;constructor(J){super();this.props=J}build(J){return new D9({child:new U0({height:1}),cursor:F5.NS_RESIZE,onDrag:(Q)=>{if(this.props.userHeight===void 0){let X=J.findRenderObject()?.size.height??0;if(X>0){this.props.onInitializeHeight(X);return}}this.props.onDrag(Q)},onRelease:this.props.onRelease})}}function Ln4(J){let Q=0;for(let Y=0;Y<J.length;Y++){let K=J.charCodeAt(Y);Q=(Q<<5)-Q+K,Q=Q&Q}let Z=[9,10,11,12,13,14,15,208,209,210,211,212,213,214,215],X=Math.abs(Q)%Z.length;return P1.index(Z[X])}s60();if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){eq.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
7148
- `)}var v50=k50.join(rb0||k50.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function Rn4(J){process.emitWarning=function(Q,Z,X,Y){let K=typeof Q==="string"?Q:Q.message||String(Q),G=Z||"Warning",q=!1;J.warn(K,{name:G,code:X})}}function aH(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")wz("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new s9("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${U8.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")wz("experimental.agentMode",Q.agentMode)}async function x50(J){try{await wn4(k50.dirname(v50),{recursive:!0}),await On4(v50,J,"utf-8")}catch(Q){p.debug("Failed to save last thread ID",Q)}}async function In4(){try{return(await yX8(v50,"utf-8")).trim()}catch(J){return null}}var vX8=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??cq,description:`Custom settings file path (overrides the default location ${cq})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(p).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${r00})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:dJ(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration."},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection."},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"tryGpt5",long:"try-gpt5",type:"switch",default:!1,description:"[DEPRECATED] Try GPT-5 as the primary agent model (see https://ampcode.com/news/gpt-5-oracle)",deprecated:!0},{name:"agentMode",long:"agent-mode",type:"option",description:"Set the experimental agent mode configuration",hidden:!0,choices:PE}],_X8=(J)=>("deprecated"in J)&&J.deprecated===!0,En4=(J)=>("hidden"in J)&&J.hidden===!0,Pn4=(J)=>("default"in J),jn4=(J)=>("default"in J)?J.default:void 0;function Tn4(J,Q){let Z=Q.args[0],X=Q.commands.map((K)=>K.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let K=X.filter((q)=>Z.includes(q)||q.includes(Z)),G="Run amp --help for a list of available commands.";if(K.length>0)G=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new s9(dq.unknownCommand(Z),1,G)}}var bX8=null;function dl7(){return bX8}function YB1(J){return{...J,getThreadEnvironment:bU1,vfs:Vp0({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new ba(J.fileSystem),generateThreadTitle:ge6,deleteThread:(Q)=>J.threadService.delete(Q)}}var y50=$0.file($n4.homedir()),fX8=process.env.XDG_CONFIG_HOME?$0.file(process.env.XDG_CONFIG_HOME):d0.joinPath(y50,".config");async function rH(J,Q){Sg0("0.0.1762465271-g947457");let Z=Dt1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:J0.of([$0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:y50,userConfigDir:fX8}),{initializeCLITelemetry:X}=await Promise.resolve().then(() => (QB1(),JB1));X(Z);let Y=await Z.getLatest();p.debug("Global configuration initialized",{settingsKeys:Object.keys(Y.settings)});let K=new jE({configService:Z}),G=new Map,q=()=>G.clear(),z=new de1(Z,J.settings.getWorkspaceRootPath()),W=ze6({configService:Z,toolServices:K,trustStore:z,createOAuthProvider:async(j)=>{let C=G.get(j);if(C)return p.debug("Reusing existing OAuth provider for server",{serverName:j}),C;p.debug("Creating OAuth provider for server",{serverName:j});let x=(async()=>{let y=new uE(J.secrets),P=await y.getClientInfo(j),v=new je1({storage:y,serverName:j,clientId:P?.clientId,clientSecret:P?.clientSecret,scopes:P?.scopes});return p.debug("OAuth provider created",{serverName:j,hasManualClientId:!!P?.clientId,willUseDCR:!P?.clientId}),v})();return G.set(j,x),x}}),U=Kt1(K,r4,Ur).catch((j)=>{p.warn("Toolbox registration failed, continuing anyway:",{error:j})}),F=W.initialized.catch((j)=>{p.warn("MCP service initialization failed, continuing anyway:",{error:j})}),H=Promise.all([F,U]).then(()=>{});if(Q.jetbrains)AT("JetBrains");else if(Q.ide&&g48())AT("VS Code");else if(Q.ide&&u48())AT("Neovim");if(J.executeMode)kg0(!0);let B,V=I2.status.pipe(b0((j)=>Boolean(j.connected&&j.authenticated)),M8()).subscribe((j)=>{if(j){if(!B)B=K.registerTool(Xk)}else B?.dispose(),B=void 0}),M;if(!J.executeMode)M=new iU1(process.cwd(),{},!0);else M=new class extends iU1{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(j5.write(`No API key found. Starting login flow...
7148
+ `)}var v50=k50.join(rb0||k50.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function Rn4(J){process.emitWarning=function(Q,Z,X,Y){let K=typeof Q==="string"?Q:Q.message||String(Q),G=Z||"Warning",q=!1;J.warn(K,{name:G,code:X})}}function aH(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")wz("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new s9("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${U8.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")wz("experimental.agentMode",Q.agentMode)}async function x50(J){try{await wn4(k50.dirname(v50),{recursive:!0}),await On4(v50,J,"utf-8")}catch(Q){p.debug("Failed to save last thread ID",Q)}}async function In4(){try{return(await yX8(v50,"utf-8")).trim()}catch(J){return null}}var vX8=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??cq,description:`Custom settings file path (overrides the default location ${cq})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(p).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${r00})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:dJ(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration."},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection."},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"tryGpt5",long:"try-gpt5",type:"switch",default:!1,description:"[DEPRECATED] Try GPT-5 as the primary agent model (see https://ampcode.com/news/gpt-5-oracle)",deprecated:!0},{name:"agentMode",long:"agent-mode",type:"option",description:"Set the experimental agent mode configuration",hidden:!0,choices:PE}],_X8=(J)=>("deprecated"in J)&&J.deprecated===!0,En4=(J)=>("hidden"in J)&&J.hidden===!0,Pn4=(J)=>("default"in J),jn4=(J)=>("default"in J)?J.default:void 0;function Tn4(J,Q){let Z=Q.args[0],X=Q.commands.map((K)=>K.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let K=X.filter((q)=>Z.includes(q)||q.includes(Z)),G="Run amp --help for a list of available commands.";if(K.length>0)G=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new s9(dq.unknownCommand(Z),1,G)}}var bX8=null;function dl7(){return bX8}function YB1(J){return{...J,getThreadEnvironment:bU1,vfs:Vp0({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new ba(J.fileSystem),generateThreadTitle:ge6,deleteThread:(Q)=>J.threadService.delete(Q)}}var y50=$0.file($n4.homedir()),fX8=process.env.XDG_CONFIG_HOME?$0.file(process.env.XDG_CONFIG_HOME):d0.joinPath(y50,".config");async function rH(J,Q){Sg0("0.0.1762473708-g720034");let Z=Dt1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:J0.of([$0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:y50,userConfigDir:fX8}),{initializeCLITelemetry:X}=await Promise.resolve().then(() => (QB1(),JB1));X(Z);let Y=await Z.getLatest();p.debug("Global configuration initialized",{settingsKeys:Object.keys(Y.settings)});let K=new jE({configService:Z}),G=new Map,q=()=>G.clear(),z=new de1(Z,J.settings.getWorkspaceRootPath()),W=ze6({configService:Z,toolServices:K,trustStore:z,createOAuthProvider:async(j)=>{let C=G.get(j);if(C)return p.debug("Reusing existing OAuth provider for server",{serverName:j}),C;p.debug("Creating OAuth provider for server",{serverName:j});let x=(async()=>{let y=new uE(J.secrets),P=await y.getClientInfo(j),v=new je1({storage:y,serverName:j,clientId:P?.clientId,clientSecret:P?.clientSecret,scopes:P?.scopes});return p.debug("OAuth provider created",{serverName:j,hasManualClientId:!!P?.clientId,willUseDCR:!P?.clientId}),v})();return G.set(j,x),x}}),U=Kt1(K,r4,Ur).catch((j)=>{p.warn("Toolbox registration failed, continuing anyway:",{error:j})}),F=W.initialized.catch((j)=>{p.warn("MCP service initialization failed, continuing anyway:",{error:j})}),H=Promise.all([F,U]).then(()=>{});if(Q.jetbrains)AT("JetBrains");else if(Q.ide&&g48())AT("VS Code");else if(Q.ide&&u48())AT("Neovim");if(J.executeMode)kg0(!0);let B,V=I2.status.pipe(b0((j)=>Boolean(j.connected&&j.authenticated)),M8()).subscribe((j)=>{if(j){if(!B)B=K.registerTool(Xk)}else B?.dispose(),B=void 0}),M;if(!J.executeMode)M=new iU1(process.cwd(),{},!0);else M=new class extends iU1{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(j5.write(`No API key found. Starting login flow...
7149
7149
  `),!await Cn4(J))await JP(),process.exit(1)}let N=await Ce6({isDevelopment:!1}),L=new oe1(N,Z),A=new re1(N,{lazy:!0}),w=new ce1(L,(j,C)=>{let x=mJ.get(j);if(x)x.handle(C).catch((y)=>{p.error("Failed to apply artifact delta",y)})}),O=Q.notifications!==void 0?Q.notifications:!J.executeMode,$=me6({playNotificationSound:async(j)=>{if(O){ue6(j);let C=a60(),x=r60();if((!C||x)&&Y.settings["notifications.system.enabled"]!==!1){if(j==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(j==="requires-user-input")process.stdout.write("\x1B]777;notify;Amp;Waiting for approval\x1B\\")}}},windowFocused:()=>Promise.resolve(!1),threadService:L,configService:Z});p.info("Starting Amp background services");let I=fe6({threadService:L,threadHistoryService:A,configService:Z,isExtensionDevelopment:!1}),R;I2.status.subscribe((j)=>{R=j});let E={codebaseContextService:new Yw1({workspaceRoots:[$0.file(process.cwd())],getCurrentFile:()=>{if(!R?.openFile)return;try{return $0.parse(R.openFile)}catch(j){p.warn("Failed to parse current file URI",{uri:R.openFile,error:j});return}},getOpenFiles:()=>{if(!R?.visibleFiles?.length)return[];let j=R.openFile;return R.visibleFiles.filter((C)=>C!==j).map((C)=>{try{return $0.parse(C)}catch(x){return p.warn("Failed to parse visible file URI",{uri:C,error:x}),null}}).filter((C)=>C!==null)}}),configService:Z,toolServices:K,mcpService:W,trustStore:z,threadService:L,threadHistoryService:A,threadSyncService:I,planFileManager:w,threadStorage:N,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:M,notificationService:$,backgroundInit:H,fileSystem:Q.jetbrains||Q.ide?Re6:r4};return{...E,async asyncDispose(){await E.mcpService.dispose(),q(),await E.threadService.asyncDispose(),E.configService.unsubscribe(),E.toolServices.dispose(),E.fuzzyServer.dispose(),E.threadSyncService.dispose(),E.settingsStorage[Symbol.dispose](),V.unsubscribe(),B?.dispose()}}}async function Cn4(J){if(!J.executeMode){if(!await O60("Would you like to log in to Amp? [(y)es, (n)o]: "))return j5.write(`Login cancelled. Run the command again to retry.
7150
7150
  `),!1}return await hX8(J)}async function hX8(J){let Q=An4(32).toString("hex"),Z=await w60(J.ampURL,Q),X=new AbortController;try{await eY(Z,X.signal)}catch(K){p.error("Error opening browser",{error:K})}let Y=await w60(J.ampURL,Q,!1);j5.write(`If your browser does not open automatically, visit:
7151
7151
 
@@ -7155,13 +7155,13 @@ ${U8.blue.bold(Y)}
7155
7155
  Login successful! You can now use the Amp CLI.
7156
7156
  `),!0}catch(K){return p.error("Login failed",{error:K}),eq.write(`
7157
7157
  Login failed: ${K instanceof Error?K.message:String(K)}
7158
- `),!1}}function Sn4(){let J=new pE().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((U)=>{if(U.code==="commander.help"||U.code==="commander.version"||U.exitCode===0)Fy(),process.exit(0);let F=U.originalError??U;b98(F)}),J.option("-V, --version","output the version number",()=>{j5.write(`0.0.1762465271-g947457 (released 2025-11-06T21:46:30.144Z)
7158
+ `),!1}}function Sn4(){let J=new pE().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((U)=>{if(U.code==="commander.help"||U.code==="commander.version"||U.exitCode===0)Fy(),process.exit(0);let F=U.originalError??U;b98(F)}),J.option("-V, --version","output the version number",()=>{j5.write(`0.0.1762473708-g720034 (released 2025-11-07T00:07:05.165Z)
7159
7159
  `),process.exit(0)}),J.addHelpText("after",b48()),J.configureHelp({formatHelp:f48}),J.command("logout").description("Log out by removing stored API key").action(async(U,F)=>{let H=F.optsWithGlobals(),B=await uY(H);await xn4(B)}),J.command("login").description("Log in to Amp").addHelpText("after","If AMP_URL is set during login, it will be persisted to global settings for future CLI invocations, though AMP_URL will continue to take precedence.").action(async(U,F)=>{let H=F.optsWithGlobals(),B=await uY(H);await _n4(B,await W60(H,B.settings))});let Q=async(U,F,H)=>{Dt1({storage:F.settings,secretStorage:F.secrets,workspaceRoots:J0.of([$0.file(process.cwd())]),defaultAmpURL:F.ampURL,homeDir:y50,userConfigDir:fX8});let B={...F,executeMode:!1};await _50(B,{...U,openThreadSwitcher:!0},H)},Z=J.command("threads").alias("t").alias("thread").summary("Manage threads").description("Thread management commands. When no subcommand is provided, defaults to listing threads.").action(async(U,F)=>{let H=F.optsWithGlobals(),B=await uY(H);await xX8(H,B,F)});Z.command("new").alias("n").summary("Create a new thread").description("Create a new thread and print its ID. The thread will be empty. You can set the visibility using the --visibility option.").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").action(async(U,F)=>{let H=F.optsWithGlobals(),B=await uY(H);await un4(H,B,F)}),Z.command("continue [threadId]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. By default, shows an interactive picker with the most recently used thread at the top. Use --last to continue the last thread directly without the picker.").option("--last","Continue the last thread directly without showing the picker").option("--pick","Pick a thread interactively from a list (DEPRECATED: picker is now the default)").action(async(U,F,H)=>{let B=H.optsWithGlobals(),V=await uY(B);if(F.pick)eq.write(`${U8.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
7160
7160
  `);if(F.last||U||V.executeMode)await gn4(B,V,U,H);else await Q(B,V,H)}),Z.command("fork [threadId]").alias("f").summary("Fork an existing thread").description("Create a new thread by forking an existing one. This copies the conversation history up to the current point and creates a new thread where you can explore different directions. If no thread ID is provided, the most recently used thread will be forked.").action(async(U,F,H)=>{let B=H.optsWithGlobals(),V=await uY(B);await hn4(B,V,U,H)}),Z.command("list").alias("l").alias("ls").summary("List all threads").description("List all your threads with their IDs, names, and last modified times.").action(async(U,F)=>{let H=F.optsWithGlobals(),B=await uY(H);await xX8(H,B,F)}),Z.command("share <threadId>").summary("Share a thread").description("Change thread visibility (private, public, unlisted, workspace, group) or share with Amp support for debugging. Use --visibility to change who can access the thread, or --support to share with the Amp team for troubleshooting.").alias("s").option("--visibility <visibility>","Set thread visibility (private, public, unlisted, workspace, group)").option("--support","Share thread with Amp support for debugging").action(async(U,F,H)=>{let B=H.optsWithGlobals(),V=await uY(B);await fn4(B,V,U,H,F.support)}),Z.command("rename <threadId> <newName>").alias("r").summary("Rename a thread").description('Change the title of a thread. Quote names with spaces: amp threads rename T-123 "New thread name"').action(async(U,F,H,B)=>{let V=B.optsWithGlobals(),M=await uY(V);await yn4(V,M,U,F,B)}),Z.command("markdown <threadId>").alias("md").summary("Render thread as markdown").description("Render a thread as markdown. This outputs the entire conversation history in a readable markdown format.").action(async(U,F,H)=>{let B=H.optsWithGlobals(),V=await uY(B);await bn4(B,V,U,H)}),l58(J,async(U,F)=>{let H=await uY(F);aH(U,F);let B=await rH(H,F);return{context:H,mcpService:B.mcpService,toolService:B.toolServices,toolServices:B.toolServices,configService:B.configService,cleanupTerminal:Fy,asyncDispose:B.asyncDispose.bind(B)}}),A58(J,async(U)=>{let F=U.optsWithGlobals();return await uY(F)}),W58(J,async(U)=>{let F=await uY(U);return{settings:F.settings,secretStorage:F.secrets,getThreadDeps:async(H)=>{aH(H,U);let B=await rH(F,U);return{mcpService:B.mcpService,settings:F.settings,asyncDispose:B.asyncDispose.bind(B)}}}});function Y(U,F,H){let V=typeof U.description==="string"?U.description:H===void 0?U.description(!0):U.description(H),M=new xA(F,V),N=jn4(U);if(N)M.default(N);if(M.hidden=En4(U)||_X8(U),"choices"in U)M.choices([...U.choices]);return M}for(let U of vX8)switch(U.type){case"flag":{J.addOption(Y(U,`--${U.long}`)),J.addOption(Y(U,`--no-${U.long}`,!1));break}case"switch":{J.addOption(Y(U,`--${U.long}`,!0));break}default:{J.addOption(Y(U,`--${U.long} <value>`));break}}let K=new xA("-x, --execute [message]","Use execute mode, optionally with user message. In execute mode, agent will execute provided prompt (either as argument, or via stdin). Only last assistant message is printed. Enabled automatically when redirecting stdout.").default(!1);J.addOption(K);let G=new xA("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1).hideHelp();J.addOption(G);let q=new xA("--stream-json","When used with --execute, output in Claude Code compatible stream JSON format instead of plain text.").default(!1);J.addOption(q);let z=new xA("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(z);let W=new xA("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);if(J.addOption(W),process.env.AMP_CONNECT==="1"){let U=new xA("--client-id <clientId>","Override the client ID for connect functionality (default: amp-<pid>@<hostname>)");J.addOption(U)}return J.action(async(U,F)=>{let H=U,B=await uY(H);if(Object.keys(H).forEach((V)=>{let M=vX8.find((N)=>N.name===V);if(M&&_X8(M)&&!Pn4(M))eq.write(U8.yellow(`Warning: '--${V}' flag is deprecated
7161
7161
  `))}),F.args.length>0)Tn4(B,F);await _50(B,H,F)}),Q58(J),J}async function XB1(J,Q){let{thread:Z,visibility:X}=Q,Y=Z?.id??jz(),K=YB1(J);if(Z)await J.threadStorage.set(Y,Z);let G=await mJ.getOrCreateForThread(K,Y);if(X)await J.threadSyncService.updateThreadMeta(Y,ZF1(X));let q=J.threadService.observe(Y).subscribe(async(z)=>{if(tJ(z,"assistant"))await x50(Y),q.unsubscribe()});return await G.resume(),G}async function _50(J,Q,Z){let X=QF1(Q);if(X instanceof Error)tq(X.message);let Y,K=null;if(Q.streamJsonInput)Y="";else if(typeof Q.execute==="string"){Y=Q.execute;let E=(await I60()).trimEnd();if(E)K=E}else Y=(await I60()).trimEnd();if(Q.remote&&!J.executeMode)throw new s9("The -r/--remote flag currently only works with --execute mode",1,'Use: amp --remote --execute "your message"');if(Q.streamJson&&!J.executeMode)throw new s9("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new s9("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!Q.streamJson)throw new s9("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if((J.executeMode||Q.streamJson)&&Q.agentMode&&Q.agentMode!=="smart")throw new s9(`Execute mode is not permitted with --agent-mode '${Q.agentMode}'`,1);if(Q.stats&&!J.executeMode)throw new s9("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(Q.streamJsonInput&&typeof Q.execute==="string"&&Q.execute.trim()!=="")throw new s9("Do not provide a message argument when using --stream-json-input",1,`Supply messages via stdin JSONL instead: echo '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"your message"}]}}' | amp --execute --stream-json --stream-json-input`);if(J.executeMode&&Y===""&&!Q.streamJsonInput)throw new s9("User message must be provided through stdin or as argument when using execute mode",1,`Either pass a message as an argument: amp --execute "your message"
7162
7162
  Or pipe via stdin: echo "your message" | amp --execute`);aH(Z,Q);let G=await rH(J,Q);if(J.executeMode||Q.threadId)await G.backgroundInit;bX8=G;let q=YB1(G),z=async(E)=>{let j=await yX8(E,"utf-8"),C=JSON.parse(j);if(!Tz(C.id))throw new s9(dq.invalidThreadId);return XB1(G,{visibility:X,thread:C})},W=async(E)=>{if(!Tz(E))throw new s9(dq.invalidThreadId);let j=await G.threadService.get(E)??void 0;if(p.info(`[fetchAndStartThread] Loaded thread ${E}, agentMode: ${j?.agentMode??"undefined"}`),j?.agentMode)p.info(`[fetchAndStartThread] Setting runtime override for agentMode to: ${j.agentMode}`),wz("experimental.agentMode",j.agentMode);else p.info("[fetchAndStartThread] No agentMode on thread, not setting override");return XB1(G,{visibility:X,thread:j})},U=async()=>{try{if(Q.threadId)return W(Q.threadId);else return XB1(G,{visibility:X})}catch(E){if(E instanceof s9)throw E;throw await fU1(E,Q.threadId),Error("handleError should have called process.exit()")}},F=async()=>{return XB1(G,{visibility:X})};if(Q.format==="jsonl")eq.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
7163
- `),await JP(),process.exit(1);if(J.executeMode&&Q.remote)await w58(Y,K,G.configService),await G.asyncDispose(),process.exit(0);let H=await U();if(J.executeMode)H58(G.mcpService,J.settings),await r98(H,H.threadID,Y,K,G,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await G.asyncDispose(),process.exit(0);let B=!1,V=!1;if(Q.jetbrains||Q.ide){await h26();let E=Zk({jetbrainsOnly:Q.jetbrains});if(E.length===0){if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall")}else if(E.length===1){let j=E[0];if(j)I2.selectConfig(j)}else B=!0}let M=A60("0.0.1762465271-g947457",G.settingsStorage),N=new ae1(G.threadStorage),L=J0.of([$0.file(process.cwd())]),A=mf0(void 0,L),w=new $60(G.mcpService,J.settings.getWorkspaceRootPath());if(Y)H.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}});let O=(async()=>{try{let E=await j7.getUserFreeTierStatus({},{config:G.configService,signal:AbortSignal.timeout(5000)});if(E.ok)return p.info("User free tier status:",E),E.result}catch(E){p.error("Failed to fetch free tier status:",E)}})(),$=(async()=>{try{let E=await j7.getUserInfo({},{config:G.configService});if(E.ok)return E.result}catch(E){p.debug("Failed to fetch user workspace info:",E)}})(),[I,R]=await Promise.all([O,$]),T=await I58();p.info("Loaded session state:",T),await TX8({codebaseContextService:G.codebaseContextService,stdout:process.stdout,history:new J60,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadHistoryService:G.threadHistoryService,threadSyncService:G.threadSyncService,planFileManager:G.planFileManager,threadID:H.threadID,threadFuzzyIndexer:N,worker:H,workerDeps:q,configService:G.configService,internalAPIClient:j7,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{p.info("Thread picker requested - not yet implemented in TUI")},switchToThread:W,ideClient:I2,connectedClientsService:new Nt1,commandRegistry:A,mcpTrustHandler:w,showJetBrainsInstaller:V,showIdePicker:B,openThreadSwitcher:Q.openThreadSwitcher,updateService:M,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:T,freeTierStatus:I,workspace:R?.team??null,threadDependencies:G}),await G.asyncDispose(),process.exit(0)}async function uY(J){if(J.interactive)eq.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7164
- `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY,X=await w48({...J,workspaceTrust:{current:!0,changes:Zh},getHook:process.env.AMP_URL?(K,G)=>{if(K==="url")return Promise.resolve(process.env.AMP_URL);return G()}:void 0});if(J.mcpConfig){let K=await U58(J.mcpConfig);X=F58(X,K)}let Y=await X.get("url","global");if(!Y)Y=CX;if(!JM(Y))p.info("Targeting custom Amp server",{ampURL:Y});return X=sf0(X),{executeMode:Q,isTTY:Z,ampURL:Y,settings:X,secrets:O58(await W60(J,X))}}function kn4(J){let Q={};for(let Z=0;Z<J.length;Z++){let X=J[Z];if(X?.startsWith("--")){let K=X.slice(2).replace(/-([a-z])/g,(q,z)=>z.toUpperCase()),G=J[Z+1];if(G&&!G.startsWith("--"))Q[K]=G,Z++}}return Q}async function vn4(){let J=kn4(process.argv);if(j98({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),Rn4(p),p.info("Starting Amp CLI.",{version:"0.0.1762465271-g947457",buildTimestamp:"2025-11-06T21:46:30.144Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new s9(dq.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Sn4().parseAsync(process.argv)}cs1().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await vn4().catch(fU1)});async function _n4(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),j5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7163
+ `),await JP(),process.exit(1);if(J.executeMode&&Q.remote)await w58(Y,K,G.configService),await G.asyncDispose(),process.exit(0);let H=await U();if(J.executeMode)H58(G.mcpService,J.settings),await r98(H,H.threadID,Y,K,G,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await G.asyncDispose(),process.exit(0);let B=!1,V=!1;if(Q.jetbrains||Q.ide){await h26();let E=Zk({jetbrainsOnly:Q.jetbrains});if(E.length===0){if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall")}else if(E.length===1){let j=E[0];if(j)I2.selectConfig(j)}else B=!0}let M=A60("0.0.1762473708-g720034",G.settingsStorage),N=new ae1(G.threadStorage),L=J0.of([$0.file(process.cwd())]),A=mf0(void 0,L),w=new $60(G.mcpService,J.settings.getWorkspaceRootPath());if(Y)H.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}});let O=(async()=>{try{let E=await j7.getUserFreeTierStatus({},{config:G.configService,signal:AbortSignal.timeout(5000)});if(E.ok)return p.info("User free tier status:",E),E.result}catch(E){p.error("Failed to fetch free tier status:",E)}})(),$=(async()=>{try{let E=await j7.getUserInfo({},{config:G.configService});if(E.ok)return E.result}catch(E){p.debug("Failed to fetch user workspace info:",E)}})(),[I,R]=await Promise.all([O,$]),T=await I58();p.info("Loaded session state:",T),await TX8({codebaseContextService:G.codebaseContextService,stdout:process.stdout,history:new J60,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadHistoryService:G.threadHistoryService,threadSyncService:G.threadSyncService,planFileManager:G.planFileManager,threadID:H.threadID,threadFuzzyIndexer:N,worker:H,workerDeps:q,configService:G.configService,internalAPIClient:j7,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{p.info("Thread picker requested - not yet implemented in TUI")},switchToThread:W,ideClient:I2,connectedClientsService:new Nt1,commandRegistry:A,mcpTrustHandler:w,showJetBrainsInstaller:V,showIdePicker:B,openThreadSwitcher:Q.openThreadSwitcher,updateService:M,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:T,freeTierStatus:I,workspace:R?.team??null,threadDependencies:G}),await G.asyncDispose(),process.exit(0)}async function uY(J){if(J.interactive)eq.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7164
+ `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY,X=await w48({...J,workspaceTrust:{current:!0,changes:Zh},getHook:process.env.AMP_URL?(K,G)=>{if(K==="url")return Promise.resolve(process.env.AMP_URL);return G()}:void 0});if(J.mcpConfig){let K=await U58(J.mcpConfig);X=F58(X,K)}let Y=await X.get("url","global");if(!Y)Y=CX;if(!JM(Y))p.info("Targeting custom Amp server",{ampURL:Y});return X=sf0(X),{executeMode:Q,isTTY:Z,ampURL:Y,settings:X,secrets:O58(await W60(J,X))}}function kn4(J){let Q={};for(let Z=0;Z<J.length;Z++){let X=J[Z];if(X?.startsWith("--")){let K=X.slice(2).replace(/-([a-z])/g,(q,z)=>z.toUpperCase()),G=J[Z+1];if(G&&!G.startsWith("--"))Q[K]=G,Z++}}return Q}async function vn4(){let J=kn4(process.argv);if(j98({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),Rn4(p),p.info("Starting Amp CLI.",{version:"0.0.1762473708-g720034",buildTimestamp:"2025-11-07T00:07:05.165Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new s9(dq.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Sn4().parseAsync(process.argv)}cs1().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await vn4().catch(fU1)});async function _n4(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),j5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7165
7165
  `);else if(!JM(J.ampURL))j5.write(`Logging in to ${new URL(J.ampURL).hostname}
7166
7166
  `);let Z=process.env.AMP_API_KEY;if(Z)j5.write(`API key found in environment variable, storing...
7167
7167
  `),await Q.set("apiKey",Z,J.ampURL),j5.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1762465271-g947457",
3
+ "version": "0.0.1762473708-g720034",
4
4
  "description": "CLI for Amp, the frontier coding agent from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {