@sourcegraph/amp 0.0.1762430485-gac8d13 → 0.0.1762444890-g3a20e7

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
@@ -6448,11 +6448,11 @@ Actual: ${Y}`)}async function Uh4(J,Q,Z){let{execSync:X}=await import("node:ch
6448
6448
  ${B}`;if(Y==="pnpm"&&B.includes("Unable to find the global bin directory"))V+=`
6449
6449
 
6450
6450
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
6451
- 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 eU1(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=Vh4(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 Vh4(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(S9({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new yU().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 zN(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 eU1(J);if(!(z.latestVersion&&z.hasUpdate)){Y.debug("no update available");return}let W=await tU1();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 pA(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 zN(5000),Z.next("hidden"),K.unsubscribe(),Z.complete()}}),{state:X}}import{stderr as hH}from"node:process";function r48(J){let Q=new mE().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.1762430485-gac8d13"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new mE("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 Mh4(X.version)});J.addCommand(Z)}async function Mh4(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")hH.write(U8.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6451
+ 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 eU1(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=Vh4(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 Vh4(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(S9({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new yU().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 zN(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 eU1(J);if(!(z.latestVersion&&z.hasUpdate)){Y.debug("no update available");return}let W=await tU1();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 pA(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 zN(5000),Z.next("hidden"),K.unsubscribe(),Z.complete()}}),{state:X}}import{stderr as hH}from"node:process";function r48(J){let Q=new mE().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.1762444890-g3a20e7"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new mE("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 Mh4(X.version)});J.addCommand(Z)}async function Mh4(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")hH.write(U8.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6452
6452
 
6453
6453
  `));try{if(!J){hH.write(U8.blue(`Checking for updates...
6454
- `));let{hasUpdate:Z,latestVersion:X}=await eU1("0.0.1762430485-gac8d13");if(!Z){hH.write(U8.green(`✓ Amp CLI is already up to date.
6455
- `));let Y=await pA("0.0.1762430485-gac8d13");if(Y.warning)hH.write(`
6454
+ `));let{hasUpdate:Z,latestVersion:X}=await eU1("0.0.1762444890-g3a20e7");if(!Z){hH.write(U8.green(`✓ Amp CLI is already up to date.
6455
+ `));let Y=await pA("0.0.1762444890-g3a20e7");if(Y.warning)hH.write(`
6456
6456
  `+U8.yellow(Y.warning)+`
6457
6457
  `);process.exit(0)}if(!X)hH.write(U8.yellow("[WARN] could not find latest version")),process.exit(0);J=X}hH.write(U8.blue(`Updating to version ${J}...
6458
6458
  `)),await Ds(J,void 0,(Z)=>{hH.write(U8.dim(`Running: ${Z}
@@ -7031,7 +7031,7 @@ exit code: ${q}`,new $1({color:X.foreground,dim:!0,italic:!0})));if(z)W.push(new
7031
7031
  `,B),...V],N=new f0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new l1({text:new D1("",void 0,M)})]});return n9.child(new m0({constraints:new P6(40,120,0,1/0),child:new i6({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[new Y8({flex:1,child:new k80({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 Y8({flex:2,child:N})]})}))}}l8();class _40 extends y0{props;constructor(J){super({key:J.key});this.props=J;this.props.enabled??=!0}createState(){return new oQ8}}class oQ8 extends x0{build(J){let Z=A6.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 m0({child:new f6({padding:L0.symmetric(1,0),child:new f0({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 Y8({child:new l1({text:new D1(J.content,G)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class x40 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=A6.of(J),Z=Q.colors.primary,X=Q.colors.foreground;return new m0({decoration:new U9(void 0,new b8(new E8(Z,1,"rounded"),new E8(Z,1,"rounded"),void 0,new E8(Z,1,"rounded"))),child:new f6({padding:L0.horizontal(1),child:new f0({children:[new i6({crossAxisAlignment:"start",children:[new Y8({child:new l1({text:new D1(this.ad.content,new $1({color:X}))})}),new U0({width:4}),new VZ({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:L0.horizontal(1),color:Z,reverse:!0}),new U0({width:2}),new l1({text:new D1(this.ad.destinationUrlHostname,new $1({color:X,dim:!0}))})]})]})})})}}w9();l8();class y40 extends y0{props;constructor(J){super();this.props=J}createState(){return new tQ8(this.props.autofocus??!0)}}class tQ8 extends x0{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=c8.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 n9({child:new m0({constraints:new P6(X,X,0,Y),decoration:new U9(P1.default(),new b8(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 L0(2,2,2,2),child:new r8({autofocus:this.autofocus,onKey:Q,child:new f0({children:K,mainAxisSize:"min"})})})})}}class jH1 extends Error{constructor(J="Command timed out"){super(J);this.name="CommandTimeoutError",Object.setPrototypeOf(this,jH1.prototype)}}class TH1 extends Error{constructor(J){let Q=`${J.noun}: ${J.verb} command cancelled`;super(Q);this.name="CommandCancelledError",Object.setPrototypeOf(this,TH1.prototype)}}function b40(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})}NM();q0();import{spawn as xl4}from"node:child_process";import{promises as yl4}from"node:fs";function eQ8(J){return J.kind==="executable"}function JZ8(J){return J.kind==="markdown"}var L3=50000,QZ8=300000;async function f40(J,Q,Z,X={}){let{timeoutMs:Y=QZ8,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}),JZ8(G))return await bl4(G,Q);else if(eQ8(G))return await fl4(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 bl4(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Z=await yl4.readFile(J.filePath,"utf8");return{success:!0,output:(Z.length>L3?Z.slice(0,L3)+`
7032
7032
  ... (output truncated at ${L3} characters)`:Z).trim(),exitCode:0}}catch(Z){return{success:!1,output:"",error:Z instanceof Error?Z.message:"Failed to read markdown file"}}}async function fl4(J,Q,Z=QZ8,X){return new Promise((Y)=>{let[K,G]=hl4(J,Q);p.debug("Spawning command",{spawnCommand:K,spawnArgs:G.slice(0,10),filePath:J.filePath,timeoutMs:Z});let q=cm0(X),z=!1,W=setTimeout(()=>{z=!0,q.abort(),p.warn("Command execution timed out",{commandName:J.name,timeoutMs:Z})},Z),U=xl4(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<=L3)F.push(M);else{let N=L3-(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<=L3)H.push(M);else{let N=L3-(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?`
7033
7033
  ${L}`:L;if(B>L3)A+=`
7034
- ... (output truncated at ${L3} 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 hl4(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return ul4(Z,X?[...X]:null,Y,Q);else return gl4(Z,X?[...X]:null,Y,Q)}function gl4(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function ul4(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();q5();RB();nG();dU();VD();ef();import{writeFile as il4}from"fs/promises";import nl4 from"path";q0();nG();class h40{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.1762430485-gac8d13"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await u51(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}}l8();class g40 extends y0{props;constructor(J){super();this.props=J}createState(){return new ZZ8}}class ZZ8 extends x0{_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)}}l8();l8();class XZ8 extends x0{controller=new sq;focusNode=new K9({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=A6.of(J),{colors:Z}=Q,X=b8.all(new E8(Z.foreground,1,"solid")),Y=new B3({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 m0({decoration:{color:P1.default()},child:new l1({text:new D1(">",new $1({color:Z.foreground}))})}),new Y8({child:Y})]}),G=new m0({padding:L0.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 m0({decoration:{border:X,color:P1.default()},padding:L0.all(1),child:new f0({children:[G,new U0({height:1}),K]})})}}class u40 extends y0{props;constructor(J){super();this.props=J}createState(){return new XZ8}}dU();q0();l8();q0();class YZ8{_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 wP extends YZ8{_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 KZ8(J,Q){let Z=()=>{Q()};return J.addListener(Z),{dispose:()=>J.removeListener(Z)}}l8();r4();w9();class m40 extends r5{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 iA(this)}createRenderObject(){return new GZ8(this.link,this.showWhenUnlinked,this.offset)}updateRenderObject(J){J.link=this.link,J.showWhenUnlinked=this.showWhenUnlinked,J.setFollowerOffset(this.offset)}}class GZ8 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)}}r4();w9();class p40 extends r5{link;constructor({key:J,link:Q,child:Z}){super({key:J,child:Z});this.link=Q}createElement(){return new iA(this)}createRenderObject(){return new qZ8(this.link)}updateRenderObject(J){J.link=this.link}}class qZ8 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 d40{_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 c40{_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 wP(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 Ko{}class Go{}class qo{}class CH1{}class SH1 extends y0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new zZ8(this.props)}}class zZ8 extends x0{props;controller;stateListener=null;overlayEntry=null;layerLink=new d40;scrollOffset=0;_effectiveFocusNode;constructor(J){super();this.props=J}initState(){if(super.initState(),this._effectiveFocusNode=this.props.focusNode||new K9({debugLabel:"AutocompleteFocusOwned"}),this.controller=new c40,this.controller.initialize({textController:this.props.controller,triggers:this.props.triggers,optionsBuilder:this.props.optionsBuilder,onSelected:this.props.onSelected}),this.stateListener=KZ8(this.controller.state,()=>{this.updateOverlay(),this.setState(()=>{})}),this.props.canStealFocus)i9.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 Ko)return this.controller.selectNext(),this.updateScrollPosition(),"handled";if(J instanceof Go)return this.controller.selectPrevious(),this.updateScrollPosition(),"handled";if(J instanceof qo)return this.controller.acceptSelected(),"handled";if(J instanceof CH1)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 B3({...this.props.textFieldProps,controller:this.props.controller,focusNode:this._effectiveFocusNode,autofocus:!1}),Z=new KU({shortcuts:new Map([[new g6("ArrowDown"),new Ko],[new g6("ArrowUp"),new Go],[new g6("n",{ctrl:!0}),new Ko],[new g6("p",{ctrl:!0}),new Go],[new g6("Enter"),new qo],[new g6("Escape"),new CH1],[new g6("Tab"),new qo]]),focusNode:this._effectiveFocusNode,child:Q}),X=new DX({actions:new Map([[Ko,new f9(this.invoke)],[Go,new f9(this.invoke)],[qo,new f9(this.invoke)],[CH1,new f9(this.invoke)]]),child:Z});return new p40({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{oA.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=t6.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 T=this.props.displayStringForOption?.(O)??String(O),C="",x=T,y="",P=O;if(P&&typeof P==="object"&&"type"in P)switch(P.type){case"file":C="@",x=P.path||T;break;case"thread":x=P.title||T,y=P.description||"";break}R=C+x+(y?" - "+y:"")}else{let T=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(T,new $1({color:x,backgroundColor:$?C:void 0}))}),R=T}let j=c8.of(J),E=sK(R,j.supportsEmojiWidth);W=Math.max(W,E),z.push(I)}let U=c8.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 m0({height:N,padding:L0.symmetric(1,0),decoration:new U9(X,b8.all(new E8(Y,1,"rounded"))),child:new f0({crossAxisAlignment:"start",children:z})})});return new m40({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 UZ8(J,Q,Z){return{type:"thread",threadId:J,title:Q,description:Z}}function l40(J){switch(J.type){case"file":return J.path;case"thread":return J.title;case"hint":return J.message}}function FZ8(J){switch(J.type){case"file":return;case"thread":return J.description||J.title;case"hint":return}}class Kw{detect(J,Q){if(!J||Q<1)return null;let Z=d4(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(`
7034
+ ... (output truncated at ${L3} 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 hl4(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return ul4(Z,X?[...X]:null,Y,Q);else return gl4(Z,X?[...X]:null,Y,Q)}function gl4(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function ul4(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();q5();RB();nG();dU();VD();ef();import{writeFile as il4}from"fs/promises";import nl4 from"path";q0();nG();class h40{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.1762444890-g3a20e7"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await u51(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}}l8();class g40 extends y0{props;constructor(J){super();this.props=J}createState(){return new ZZ8}}class ZZ8 extends x0{_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)}}l8();l8();class XZ8 extends x0{controller=new sq;focusNode=new K9({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=A6.of(J),{colors:Z}=Q,X=b8.all(new E8(Z.foreground,1,"solid")),Y=new B3({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 m0({decoration:{color:P1.default()},child:new l1({text:new D1(">",new $1({color:Z.foreground}))})}),new Y8({child:Y})]}),G=new m0({padding:L0.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 m0({decoration:{border:X,color:P1.default()},padding:L0.all(1),child:new f0({children:[G,new U0({height:1}),K]})})}}class u40 extends y0{props;constructor(J){super();this.props=J}createState(){return new XZ8}}dU();q0();l8();q0();class YZ8{_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 wP extends YZ8{_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 KZ8(J,Q){let Z=()=>{Q()};return J.addListener(Z),{dispose:()=>J.removeListener(Z)}}l8();r4();w9();class m40 extends r5{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 iA(this)}createRenderObject(){return new GZ8(this.link,this.showWhenUnlinked,this.offset)}updateRenderObject(J){J.link=this.link,J.showWhenUnlinked=this.showWhenUnlinked,J.setFollowerOffset(this.offset)}}class GZ8 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)}}r4();w9();class p40 extends r5{link;constructor({key:J,link:Q,child:Z}){super({key:J,child:Z});this.link=Q}createElement(){return new iA(this)}createRenderObject(){return new qZ8(this.link)}updateRenderObject(J){J.link=this.link}}class qZ8 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 d40{_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 c40{_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 wP(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 Ko{}class Go{}class qo{}class CH1{}class SH1 extends y0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new zZ8(this.props)}}class zZ8 extends x0{props;controller;stateListener=null;overlayEntry=null;layerLink=new d40;scrollOffset=0;_effectiveFocusNode;constructor(J){super();this.props=J}initState(){if(super.initState(),this._effectiveFocusNode=this.props.focusNode||new K9({debugLabel:"AutocompleteFocusOwned"}),this.controller=new c40,this.controller.initialize({textController:this.props.controller,triggers:this.props.triggers,optionsBuilder:this.props.optionsBuilder,onSelected:this.props.onSelected}),this.stateListener=KZ8(this.controller.state,()=>{this.updateOverlay(),this.setState(()=>{})}),this.props.canStealFocus)i9.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 Ko)return this.controller.selectNext(),this.updateScrollPosition(),"handled";if(J instanceof Go)return this.controller.selectPrevious(),this.updateScrollPosition(),"handled";if(J instanceof qo)return this.controller.acceptSelected(),"handled";if(J instanceof CH1)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 B3({...this.props.textFieldProps,controller:this.props.controller,focusNode:this._effectiveFocusNode,autofocus:!1}),Z=new KU({shortcuts:new Map([[new g6("ArrowDown"),new Ko],[new g6("ArrowUp"),new Go],[new g6("n",{ctrl:!0}),new Ko],[new g6("p",{ctrl:!0}),new Go],[new g6("Enter"),new qo],[new g6("Escape"),new CH1],[new g6("Tab"),new qo]]),focusNode:this._effectiveFocusNode,child:Q}),X=new DX({actions:new Map([[Ko,new f9(this.invoke)],[Go,new f9(this.invoke)],[qo,new f9(this.invoke)],[CH1,new f9(this.invoke)]]),child:Z});return new p40({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{oA.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=t6.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 T=this.props.displayStringForOption?.(O)??String(O),C="",x=T,y="",P=O;if(P&&typeof P==="object"&&"type"in P)switch(P.type){case"file":C="@",x=P.path||T;break;case"thread":x=P.title||T,y=P.description||"";break}R=C+x+(y?" - "+y:"")}else{let T=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(T,new $1({color:x,backgroundColor:$?C:void 0}))}),R=T}let j=c8.of(J),E=sK(R,j.supportsEmojiWidth);W=Math.max(W,E),z.push(I)}let U=c8.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 m0({height:N,padding:L0.symmetric(1,0),decoration:new U9(X,b8.all(new E8(Y,1,"rounded"))),child:new f0({crossAxisAlignment:"start",children:z})})});return new m40({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 UZ8(J,Q,Z){return{type:"thread",threadId:J,title:Q,description:Z}}function l40(J){switch(J.type){case"file":return J.path;case"thread":return J.title;case"hint":return J.message}}function FZ8(J){switch(J.type){case"file":return;case"thread":return J.description||J.title;case"hint":return}}class Kw{detect(J,Q){if(!J||Q<1)return null;let Z=d4(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(`
7035
7035
  `))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 zo extends y0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new HZ8(this.props)}}class HZ8 extends x0{props;_effectiveFocusNode;constructor(J){super();this.props=J}buildOptions=async(J)=>{let Q=this.props.controller.text,Z=this.props.controller.cursorPosition,Y=new Kw().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 K9({debugLabel:"PromptEditorFocus"}),this.props.controller.onInsertText=(J,Q)=>{if(J.length<=3)return!0;let Z=c58(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 aA(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 m0({padding:L0.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 SH1({controller:this.props.controller,triggers:this.props.triggers,optionsBuilder:this.buildOptions,onSelected:this.props.onOptionSelected??this.defaultOnOptionSelected,displayStringForOption:(Y)=>l40(Y),overlayBorderColor:Q.border,focusNode:this._effectiveFocusNode,canStealFocus:this.props.canStealFocus??!0,showMenuBelow:this.props.showMenuBelow??!1,textFieldProps:{placeholder:this.props.placeholder,wrap:!0,minLines:3,maxLines:null,expands:!0,autofocus:this.props.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=l40(K);break}let B=FZ8(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 m0({decoration:new U9(q),child:new l1({text:new D1("",void 0,N),maxLines:1,overflow:"ellipsis"})})}});if(Z)return new f0({crossAxisAlignment:"start",children:[Z,new Y8({child:X})]});return X}requestFocus(){this._effectiveFocusNode.requestFocus()}}w9();l8();class BZ8 extends x0{controller=new sq;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new K9({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>=LM)return!1;let Q=$y(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=A6.of(J),{colors:Z,app:X}=Q,K=c8.of(J).size.height,G=Math.max(Math.floor(K*0.5),10),q=new zo({controller:this.controller,triggers:[new Kw],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,canStealFocus:!0,clipboard:x4.instance.tuiInstance.clipboard,showMenuBelow:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),z=new r8({focusNode:this.focusNode,child:q}),W=new m0({constraints:new P6({maxHeight:G}),child:z}),U=new m0({padding:L0.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 m0({padding:L0.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 Y8({child:W}),new U0({height:1}),F];return new m0({decoration:{border:b8.all(new E8(Z.foreground,1,"solid")),color:P1.default()},padding:L0.all(1),child:new f0({children:H})})}}class kH1 extends y0{props;constructor(J){super();this.props=J}createState(){return new BZ8}}l8();var ml4=/[\\/_ +.#"@[({&]/,pl4=/[\\/_ +.#"@[({&]/g,dl4=/[\s-]/,DZ8=/[\s-]/g;function _H1(J,Q,Z,X,Y,K,G){if(K===Q.length){if(Y===J.length)return 1;return 0.99}let q=`${Y},${K}`;if(G[q]!==void 0)return G[q];let z=X.charAt(K),W=Z.indexOf(z,Y),U=0,F,H,B,V;while(W>=0){if(F=_H1(J,Q,Z,X,W+1,K+1,G),F>U){if(W===Y)F*=1;else if(dl4.test(J.charAt(W-1))){if(F*=0.9,V=J.slice(Y,W-1).match(DZ8),V&&Y>0)F*=Math.pow(0.999,V.length)}else if(ml4.test(J.charAt(W-1))){if(F*=0.8,B=J.slice(Y,W-1).match(pl4),B&&Y>0)F*=Math.pow(0.999,B.length)}else if(F*=0.3,Y>0)F*=Math.pow(0.999,W-Y);if(J.charAt(W)!==Q.charAt(K))F*=0.9999}if(F<0.1&&(Z.charAt(W-1)===X.charAt(K+1)||X.charAt(K+1)===X.charAt(K)&&Z.charAt(W-1)!==X.charAt(K))){if(H=_H1(J,Q,Z,X,W+1,K+2,G),H*0.1>F)F=H*0.1}if(F>U)U=F;W=Z.indexOf(z,W+1)}return G[q]=U,U}function vH1(J){return J.toLowerCase().replace(DZ8," ")}function VZ8(J,Q){let Z=_H1(J,Q,vH1(J),vH1(Q),0,0,{}),X=Q.trim().split(/\s+/);if(X.length>1){let Y=0,K=0;for(let q of X){let z=_H1(J,q,vH1(J),vH1(q),0,0,{});if(z===0)return Z;Y+=z,K+=q.length}let G=Y/X.length*0.95;return Math.max(Z,G)}return Z}class my{}class py{}class xH1{}class yH1{}class MZ8 extends y0{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new NZ8}}class NZ8 extends x0{build(J){return this.widget.onContext(J),this.widget.child}}function cl4(J,Q){if(J==="")return{matches:!0,score:1};let Z=VZ8(Q,J);return{matches:Z>0.15,score:Z}}class Gw extends y0{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new LZ8}}class LZ8 extends x0{controller=new sq;focusNode;scrollController=new VX;selectedIndex=0;itemContexts=[];initState(){this.focusNode=new K9({debugLabel:this.widget.debugLabel}),this.controller.addListener(()=>{this.selectedIndex=0,this.setState(),i9.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let Q=this.getFilteredItems();this.widget.props.onSelectionChange?.(Q[0]??null)});let J=this.getFilteredItems();this.widget.props.onSelectionChange?.(J[0]??null),i9.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})}didUpdateWidget(J){if(J.props.items!==this.widget.props.items)i9.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})}dispose(){this.widget.props.onSelectionChange?.(null),this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof my){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length-1)this.selectedIndex++,this.setState(),i9.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof py){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex>0)this.selectedIndex--,this.setState(),i9.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof xH1){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length){let Z=Q[this.selectedIndex];if(Z){if(!(this.widget.props.isItemDisabled?.(Z)??!1))this.widget.props.onAccept(Z)}}return"handled"}if(J instanceof yH1)return this.widget.props.onDismiss?.(),"handled";return"ignored"};getFilteredItems(){let J=this.controller.text;return this.widget.props.items.filter((Z)=>!this.widget.props.filterItem||this.widget.props.filterItem(Z,J)).map((Z)=>({item:Z,...cl4(J,this.widget.props.getLabel(Z))})).filter((Z)=>Z.matches).sort(this.widget.props.sortItems?(Z,X)=>this.widget.props.sortItems(Z,X,J):(Z,X)=>X.score-Z.score).map((Z)=>Z.item)}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,X=Q.size.height;TF1(J,{top:Z,bottom:X},{padding:1})}handleScroll=(J)=>{let Q=this.getFilteredItems();if(Q.length===0)return;if(J.direction==="down")if(this.selectedIndex<Q.length-1)this.selectedIndex++;else return;else if(this.selectedIndex>0)this.selectedIndex--;else return;this.setState(),i9.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null)};handleItemClick=(J,Q)=>{let Z=this.getFilteredItems();if(J>=0&&J<Z.length){let X=Z[J],Y=X?this.widget.props.isItemDisabled?.(X)??!1:!1;if(Q===1)this.selectedIndex=J,this.setState(),this.widget.props.onSelectionChange?.(Z[this.selectedIndex]??null);else if(Q===2&&!Y){if(X)this.widget.props.onAccept(X)}}};build(J){let Q=A6.of(J),{colors:Z}=Q,X=this.getFilteredItems(),Y=b8.all(new E8(Z.foreground,1,"solid")),K=this.widget.props.enabled??!0,G=new B3({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:K,style:{textColor:Z.foreground,border:null},maxLines:1}),q=new KU({shortcuts:new Map([[new g6("ArrowDown"),new my],[new g6("ArrowUp"),new py],[new g6("Tab"),new my],[new g6("Tab",{shift:!0}),new py],[new g6("n",{ctrl:!0}),new my],[new g6("p",{ctrl:!0}),new py],[new g6("Enter"),new xH1],[new g6("Escape"),new yH1]]),focusNode:this.focusNode,child:G}),z=new DX({actions:new Map([[my,new f9(this.invoke)],[py,new f9(this.invoke)],[xH1,new f9(this.invoke)],[yH1,new f9(this.invoke)]]),child:q}),W=new i6({children:[new m0({decoration:{color:P1.default()},child:new l1({text:new D1(">",new $1({color:Z.foreground}))})}),new Y8({child:z})]});this.itemContexts=[];let U;if(this.widget.props.isLoading){let M=this.widget.props.loadingText??"Loading...";U=new U0({height:10,child:new n9({child:new l1({text:new D1(M,new $1({color:Z.foreground}))})})})}else{let M=X.map((N,L)=>{let A=L===this.selectedIndex,w=this.widget.props.isItemDisabled?.(N)??!1,O;if(this.widget.props.renderItem)O=this.widget.props.renderItem(N,A,w,J);else{let $=A?P1.yellow:void 0,I=A?P1.black:Z.foreground;O=new m0({decoration:$?{color:$}:void 0,padding:L0.symmetric(2,0),child:new l1({text:new D1(this.widget.props.getLabel(N),new $1({color:I,dim:w}))})})}return new MZ8(new D9({onClick:($)=>this.handleItemClick(L,$.clickCount),child:O}),($)=>{this.itemContexts[L]=$})});U=new f0({children:M,crossAxisAlignment:"start"})}let F=new Y8({child:new D9({onScroll:this.handleScroll,opaque:!1,child:new MX({controller:this.scrollController,autofocus:!1,child:U})})}),H=[];if(this.widget.props.title){let M=new m0({padding:L0.symmetric(1,0),child:new l1({text:new D1(this.widget.props.title,new $1({color:P1.yellow,bold:!0}))})});H.push(M)}if(H.push(W,new U0({height:1}),F),this.controller.text!==""){let M=X.length>0?X[this.selectedIndex]:void 0,N=M&&this.widget.props.buildDisabledReasonWidget?.(M);if(N)H.push(new m0({padding:L0.vertical(1),child:new n9({child:N})}));else H.push(new U0({height:3}))}return new m0({decoration:{border:Y,color:P1.default()},padding:L0.symmetric(1,0),child:new f0({children:H})})}}class i40 extends M6{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}build(J){let Q=this.props.threads,Z=(G)=>`${G.messageCount} msgs`,X=Math.max(0,...Q.map((G)=>Z(G).length)),Y=Math.max(0,...Q.map((G)=>G.description.timeAgo.length)),K=Math.max(0,...Q.map((G)=>G.description.shortThreadID.length));return new Gw({items:this.props.threads,getLabel:(G)=>G.title,onAccept:(G)=>this.props.onSelect?.(G.id),onDismiss:this.props.onDismiss,onSelectionChange:(G)=>this.props.onPreview?.(G?.id??null),title:"Switch Thread",isLoading:this.props.isLoading,loadingText:"Loading threads...",renderItem:(G,q,z,W)=>{let U=A6.of(W),{colors:F}=U,H=q?P1.yellow:void 0,B=q?P1.black:F.foreground,V=P1.index(8),M=(N,L)=>new U0({width:L,child:i6.end([new l1({text:new D1(N,new $1({color:V}))})])});return new m0({decoration:H?{color:H}:void 0,padding:L0.symmetric(2,0),child:new i6({children:[new Y8({child:new l1({text:new D1(G.title,new $1({color:B})),overflow:"ellipsis",maxLines:1})}),new U0({width:2}),M(Z(G),X),new U0({width:1}),new l1({text:new D1("│",new $1({color:V}))}),new U0({width:1}),M(G.description.timeAgo,Y),new U0({width:1}),new l1({text:new D1("│",new $1({color:V}))}),new U0({width:1}),M(G.description.shortThreadID,K)]})})}})}}l8();class Wo extends y0{props;constructor(J){super();this.props=J}createState(){return new AZ8}}class AZ8 extends x0{_spinner=new lH;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=A6.of(J),{colors:Z}=Q,X=b8.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 Y8({child:new f0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)q.push(new U0({height:2,child:new m0({padding:L0.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 m0({decoration:new U9(P1.default(),X),child:new U0({width:60,height:7,child:new f0({mainAxisAlignment:"start",children:q})})});if(this.widget.props.onAbort)return new r8({debugLabel:"LoadingDialog",autofocus:!0,onKey:(W)=>{if(W.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}l8();class OP extends y0{props;constructor(J){super();this.props=J}createState(){return new wZ8}}class wZ8 extends x0{dispose(){super.dispose()}isWidgetMessage(J){return J instanceof ms}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=kF1(Q);return{title:W.title,type:W.type,description:W.description}})(),X=Z.type==="error"?P1.red:P1.yellow,Y=b8.all(new E8(P1.white,1,"solid")),K=new m0({padding:L0.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 Y8({child:new KP({child:new m0({padding:L0.symmetric(1,0),child:G})})}),z=new m0({padding:L0.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 r8({onKey:()=>{return this.widget.props.onDismiss(),"handled"},autofocus:!0,child:new m0({decoration:{border:Y,color:P1.default()},padding:L0.all(1),child:new f0({mainAxisAlignment:"center",children:[K,new U0({height:1}),q,z]})})})}}class RZ8 extends y0{props;constructor(J){super();this.props=J}createState(){return new IZ8}}class IZ8 extends x0{isLoading=!0;error=null;initState(){super.initState(),i9.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 Wo({message:"Handing off...",onAbort:this.widget.props.onAbort}));else if(this.error)Q.push(new OP({message:this.error,onDismiss:()=>{this.setState(()=>{this.isLoading=!1,this.error=null}),this.widget.props.onDismiss()}}));return new f7({children:Q,fit:"expand"})}}class EZ8 extends y0{props;constructor(J){super();this.props=J}createState(){return new PZ8}}class PZ8 extends x0{result=void 0;isLoading=!1;build(J){let Q=[];if(this.isLoading)Q.push(new Wo({message:"Updating visibility..."}));else if(this.result!==void 0)Q.push(new OP({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 Gw({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 f7({children:Q,fit:"expand"})}}var OZ8={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 al4(J){return J.startsWith("custom-command-")}function $Z8(J){return J.startsWith("agent-mode-")}function rl4(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 h40(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=rl4(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 f40(q,Z,this.registry,{signal:X.signal});if(this.onExecutionComplete(),W.success){let U=Q.editorState.text,H=U.trim()&&!U.endsWith(`
7036
7036
 
7037
7037
  `)?`
@@ -7085,7 +7085,7 @@ https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_di
7085
7085
  `),J.stdout.write(`Thread: ${H}
7086
7086
  `),J.stdout.write(`Continue this thread with: amp threads continue ${U}
7087
7087
  `)}}function C50(J){return J==="smart"?P1.rgb(3,197,97):J==="rush"?P1.rgb(228,180,2):J==="free"?P1.rgb(0,184,255):Bn4(J)}class EX8 extends y0{props;constructor(J){super();this.props=J}createState(){return new PX8}}class PX8 extends x0{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 Y8({child:new MX({controller:X,autofocus:!1,child:new _40({todos:Q,enabled:Z})})}),new qU({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 jX8 extends M6{props;constructor(J){super();this.props=J}build(J){return new D9({child:new U0({height:1}),cursor:U5.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 Bn4(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}
7088
- `)}var k50=S50.join(ab0||S50.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function Ln4(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 nH(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 _50(J){try{await Vn4(S50.dirname(k50),{recursive:!0}),await Mn4(k50,J,"utf-8")}catch(Q){p.debug("Failed to save last thread ID",Q)}}async function An4(){try{return(await kX8(k50,"utf-8")).trim()}catch(J){return null}}var TX8=[{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:pJ(),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:EE}],CX8=(J)=>("deprecated"in J)&&J.deprecated===!0,wn4=(J)=>("hidden"in J)&&J.hidden===!0,On4=(J)=>("default"in J),$n4=(J)=>("default"in J)?J.default:void 0;function Rn4(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 vX8=null;function ul7(){return vX8}function YB1(J){return{...J,getThreadEnvironment:yU1,vfs:Dp0({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new ba(J.fileSystem),generateThreadTitle:_e6,deleteThread:(Q)=>J.threadService.delete(Q)}}var x50=E0.file(Nn4.homedir()),_X8=process.env.XDG_CONFIG_HOME?E0.file(process.env.XDG_CONFIG_HOME):d0.joinPath(x50,".config");async function aH(J,Q){Cg0("0.0.1762430485-gac8d13");let Z=Dt1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:J0.of([E0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:x50,userConfigDir:_X8}),{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 PE({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(T)=>{let C=G.get(T);if(C)return p.debug("Reusing existing OAuth provider for server",{serverName:T}),C;p.debug("Creating OAuth provider for server",{serverName:T});let x=(async()=>{let y=new gE(J.secrets),P=await y.getClientInfo(T),v=new je1({storage:y,serverName:T,clientId:P?.clientId,clientSecret:P?.clientSecret,scopes:P?.scopes});return p.debug("OAuth provider created",{serverName:T,hasManualClientId:!!P?.clientId,willUseDCR:!P?.clientId}),v})();return G.set(T,x),x}}),U=Kt1(K,a4,Ur).catch((T)=>{p.warn("Toolbox registration failed, continuing anyway:",{error:T})}),F=W.initialized.catch((T)=>{p.warn("MCP service initialization failed, continuing anyway:",{error:T})}),H=Promise.all([F,U]).then(()=>{});if(Q.jetbrains)NT("JetBrains");else if(Q.ide&&_48())NT("VS Code");else if(Q.ide&&x48())NT("Neovim");if(J.executeMode)Sg0(!0);let B,V=R2.status.pipe(h0((T)=>Boolean(T.connected&&T.authenticated)),M8()).subscribe((T)=>{if(T){if(!B)B=K.registerTool(Zk)}else B?.dispose(),B=void 0}),M;if(!J.executeMode)M=new lU1(process.cwd(),{},!0);else M=new class extends lU1{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(P5.write(`No API key found. Starting login flow...
7088
+ `)}var k50=S50.join(ab0||S50.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function Ln4(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 nH(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 _50(J){try{await Vn4(S50.dirname(k50),{recursive:!0}),await Mn4(k50,J,"utf-8")}catch(Q){p.debug("Failed to save last thread ID",Q)}}async function An4(){try{return(await kX8(k50,"utf-8")).trim()}catch(J){return null}}var TX8=[{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:pJ(),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:EE}],CX8=(J)=>("deprecated"in J)&&J.deprecated===!0,wn4=(J)=>("hidden"in J)&&J.hidden===!0,On4=(J)=>("default"in J),$n4=(J)=>("default"in J)?J.default:void 0;function Rn4(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 vX8=null;function ul7(){return vX8}function YB1(J){return{...J,getThreadEnvironment:yU1,vfs:Dp0({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new ba(J.fileSystem),generateThreadTitle:_e6,deleteThread:(Q)=>J.threadService.delete(Q)}}var x50=E0.file(Nn4.homedir()),_X8=process.env.XDG_CONFIG_HOME?E0.file(process.env.XDG_CONFIG_HOME):d0.joinPath(x50,".config");async function aH(J,Q){Cg0("0.0.1762444890-g3a20e7");let Z=Dt1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:J0.of([E0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:x50,userConfigDir:_X8}),{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 PE({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(T)=>{let C=G.get(T);if(C)return p.debug("Reusing existing OAuth provider for server",{serverName:T}),C;p.debug("Creating OAuth provider for server",{serverName:T});let x=(async()=>{let y=new gE(J.secrets),P=await y.getClientInfo(T),v=new je1({storage:y,serverName:T,clientId:P?.clientId,clientSecret:P?.clientSecret,scopes:P?.scopes});return p.debug("OAuth provider created",{serverName:T,hasManualClientId:!!P?.clientId,willUseDCR:!P?.clientId}),v})();return G.set(T,x),x}}),U=Kt1(K,a4,Ur).catch((T)=>{p.warn("Toolbox registration failed, continuing anyway:",{error:T})}),F=W.initialized.catch((T)=>{p.warn("MCP service initialization failed, continuing anyway:",{error:T})}),H=Promise.all([F,U]).then(()=>{});if(Q.jetbrains)NT("JetBrains");else if(Q.ide&&_48())NT("VS Code");else if(Q.ide&&x48())NT("Neovim");if(J.executeMode)Sg0(!0);let B,V=R2.status.pipe(h0((T)=>Boolean(T.connected&&T.authenticated)),M8()).subscribe((T)=>{if(T){if(!B)B=K.registerTool(Zk)}else B?.dispose(),B=void 0}),M;if(!J.executeMode)M=new lU1(process.cwd(),{},!0);else M=new class extends lU1{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(P5.write(`No API key found. Starting login flow...
7089
7089
  `),!await In4(J))await eE(),process.exit(1)}let N=await Re6({isDevelopment:!1}),L=new oe1(N,Z),A=new re1(N,{lazy:!0}),w=new ce1(L,(T,C)=>{let x=uJ.get(T);if(x)x.handle(C).catch((y)=>{p.error("Failed to apply artifact delta",y)})}),O=Q.notifications!==void 0?Q.notifications:!J.executeMode,$=ye6({playNotificationSound:async(T)=>{if(O){xe6(T);let C=a60(),x=r60();if((!C||x)&&Y.settings["notifications.system.enabled"]!==!1){if(T==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(T==="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=ke6({threadService:L,threadHistoryService:A,configService:Z,isExtensionDevelopment:!1}),R;R2.status.subscribe((T)=>{R=T});let E={codebaseContextService:new Yw1({workspaceRoots:[E0.file(process.cwd())],getCurrentFile:()=>{if(!R?.openFile)return;try{return E0.parse(R.openFile)}catch(T){p.warn("Failed to parse current file URI",{uri:R.openFile,error:T});return}},getOpenFiles:()=>{if(!R?.visibleFiles?.length)return[];let T=R.openFile;return R.visibleFiles.filter((C)=>C!==T).map((C)=>{try{return E0.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?Ne6:a4};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 In4(J){if(!J.executeMode){if(!await O60("Would you like to log in to Amp? [(y)es, (n)o]: "))return P5.write(`Login cancelled. Run the command again to retry.
7090
7090
  `),!1}return await xX8(J)}async function xX8(J){let Q=Dn4(32).toString("hex"),Z=await w60(J.ampURL,Q),X=new AbortController;try{await oY(Z,X.signal)}catch(K){p.error("Error opening browser",{error:K})}let Y=await w60(J.ampURL,Q,!1);P5.write(`If your browser does not open automatically, visit:
7091
7091
 
@@ -7095,13 +7095,13 @@ ${U8.blue.bold(Y)}
7095
7095
  Login successful! You can now use the Amp CLI.
7096
7096
  `),!0}catch(K){return p.error("Login failed",{error:K}),eq.write(`
7097
7097
  Login failed: ${K instanceof Error?K.message:String(K)}
7098
- `),!1}}function En4(){let J=new mE().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)Uy(),process.exit(0);let F=U.originalError??U;S98(F)}),J.option("-V, --version","output the version number",()=>{P5.write(`0.0.1762430485-gac8d13 (released 2025-11-06T12:07:12.211Z)
7098
+ `),!1}}function En4(){let J=new mE().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)Uy(),process.exit(0);let F=U.originalError??U;S98(F)}),J.option("-V, --version","output the version number",()=>{P5.write(`0.0.1762444890-g3a20e7 (released 2025-11-06T16:07:29.967Z)
7099
7099
  `),process.exit(0)}),J.addHelpText("after",S48()),J.configureHelp({formatHelp:k48}),J.command("logout").description("Log out by removing stored API key").action(async(U,F)=>{let H=F.optsWithGlobals(),B=await hY(H);await Cn4(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 hY(H);await Tn4(B,await W60(H,B.settings))});let Q=async(U,F,H)=>{Dt1({storage:F.settings,secretStorage:F.secrets,workspaceRoots:J0.of([E0.file(process.cwd())]),defaultAmpURL:F.ampURL,homeDir:x50,userConfigDir:_X8});let B={...F,executeMode:!1};await v50(B,{...U,startWithPicker:!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 hY(H);await SX8(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 hY(H);await yn4(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 hY(B);if(F.pick)eq.write(`${U8.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
7100
7100
  `);if(F.last||U||V.executeMode)await xn4(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 hY(B);await _n4(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 hY(H);await SX8(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 hY(B);await vn4(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 hY(V);await Sn4(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 hY(B);await kn4(B,V,U,H)}),g58(J,async(U,F)=>{let H=await hY(F);nH(U,F);let B=await aH(H,F);return{context:H,mcpService:B.mcpService,toolService:B.toolServices,toolServices:B.toolServices,configService:B.configService,cleanupTerminal:Uy,asyncDispose:B.asyncDispose.bind(B)}}),B58(J,async(U)=>{let F=U.optsWithGlobals();return await hY(F)}),X58(J,async(U)=>{let F=await hY(U);return{settings:F.settings,secretStorage:F.secrets,getThreadDeps:async(H)=>{nH(H,U);let B=await aH(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 _A(F,V),N=$n4(U);if(N)M.default(N);if(M.hidden=wn4(U)||CX8(U),"choices"in U)M.choices([...U.choices]);return M}for(let U of TX8)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 _A("-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 _A("-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 _A("--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 _A("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(z);let W=new _A("--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 _A("--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 hY(H);if(Object.keys(H).forEach((V)=>{let M=TX8.find((N)=>N.name===V);if(M&&CX8(M)&&!On4(M))eq.write(U8.yellow(`Warning: '--${V}' flag is deprecated
7101
7101
  `))}),F.args.length>0)Rn4(B,F);await v50(B,H,F)}),r48(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 uJ.getOrCreateForThread(K,Y);if(X)await J.threadSyncService.updateThreadMeta(Y,QF1(X));let q=J.threadService.observe(Y).subscribe(async(z)=>{if(oJ(z,"assistant"))await _50(Y),q.unsubscribe()});return await G.resume(),G}async function v50(J,Q,Z){let X=JF1(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"
7102
7102
  Or pipe via stdin: echo "your message" | amp --execute`);nH(Z,Q);let G=await aH(J,Q);if(J.executeMode||Q.threadId)await G.backgroundInit;vX8=G;let q=YB1(G),z=async(E)=>{let T=await kX8(E,"utf-8"),C=JSON.parse(T);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 T=await G.threadService.get(E)??void 0;if(p.info(`[fetchAndStartThread] Loaded thread ${E}, agentMode: ${T?.agentMode??"undefined"}`),T?.agentMode)p.info(`[fetchAndStartThread] Setting runtime override for agentMode to: ${T.agentMode}`),wz("experimental.agentMode",T.agentMode);else p.info("[fetchAndStartThread] No agentMode on thread, not setting override");return XB1(G,{visibility:X,thread:T})},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 bU1(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.
7103
- `),await eE(),process.exit(1);if(J.executeMode&&Q.remote)await D58(Y,K,G.configService),await G.asyncDispose(),process.exit(0);let H=await U();if(J.executeMode)G58(G.mcpService,J.settings),await d98(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 v26();let E=Qk({jetbrainsOnly:Q.jetbrains});if(E.length===0){if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall")}else if(E.length===1){let T=E[0];if(T)R2.selectConfig(T)}else B=!0}let M=A60("0.0.1762430485-gac8d13",G.settingsStorage),N=new ae1(G.threadStorage),L=J0.of([E0.file(process.cwd())]),A=uf0(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 I7.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 I7.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,$]),j=await L58();p.info("Loaded session state:",j),await IX8({codebaseContextService:G.codebaseContextService,stdout:process.stdout,history:new J60,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadSyncService:G.threadSyncService,planFileManager:G.planFileManager,threadID:H.threadID,threadFuzzyIndexer:N,worker:H,workerDeps:q,configService:G.configService,internalAPIClient:I7,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{p.info("Thread picker requested - not yet implemented in TUI")},switchToThread:W,ideClient:R2,connectedClientsService:new Nt1,commandRegistry:A,mcpTrustHandler:w,showJetBrainsInstaller:V,showIdePicker:B,startWithPicker:Q.startWithPicker,updateService:M,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:j,freeTierStatus:I,workspace:R?.team??null,threadDependencies:G}),await G.asyncDispose(),process.exit(0)}async function hY(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.
7104
- `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY,X=await D48({...J,workspaceTrust:{current:!0,changes:Qh},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 Y58(J.mcpConfig);X=K58(X,K)}let Y=await X.get("url","global");if(!Y)Y=jX;if(!e3(Y))p.info("Targeting custom Amp server",{ampURL:Y});return X=rf0(X),{executeMode:Q,isTTY:Z,ampURL:Y,settings:X,secrets:V58(await W60(J,X))}}function Pn4(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 jn4(){let J=Pn4(process.argv);if(O98({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),Ln4(p),p.info("Starting Amp CLI.",{version:"0.0.1762430485-gac8d13",buildTimestamp:"2025-11-06T12:07:12.211Z"}),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 En4().parseAsync(process.argv)}cs1().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await jn4().catch(bU1)});async function Tn4(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),P5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7103
+ `),await eE(),process.exit(1);if(J.executeMode&&Q.remote)await D58(Y,K,G.configService),await G.asyncDispose(),process.exit(0);let H=await U();if(J.executeMode)G58(G.mcpService,J.settings),await d98(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 v26();let E=Qk({jetbrainsOnly:Q.jetbrains});if(E.length===0){if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall")}else if(E.length===1){let T=E[0];if(T)R2.selectConfig(T)}else B=!0}let M=A60("0.0.1762444890-g3a20e7",G.settingsStorage),N=new ae1(G.threadStorage),L=J0.of([E0.file(process.cwd())]),A=uf0(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 I7.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 I7.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,$]),j=await L58();p.info("Loaded session state:",j),await IX8({codebaseContextService:G.codebaseContextService,stdout:process.stdout,history:new J60,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadSyncService:G.threadSyncService,planFileManager:G.planFileManager,threadID:H.threadID,threadFuzzyIndexer:N,worker:H,workerDeps:q,configService:G.configService,internalAPIClient:I7,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{p.info("Thread picker requested - not yet implemented in TUI")},switchToThread:W,ideClient:R2,connectedClientsService:new Nt1,commandRegistry:A,mcpTrustHandler:w,showJetBrainsInstaller:V,showIdePicker:B,startWithPicker:Q.startWithPicker,updateService:M,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:j,freeTierStatus:I,workspace:R?.team??null,threadDependencies:G}),await G.asyncDispose(),process.exit(0)}async function hY(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.
7104
+ `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY,X=await D48({...J,workspaceTrust:{current:!0,changes:Qh},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 Y58(J.mcpConfig);X=K58(X,K)}let Y=await X.get("url","global");if(!Y)Y=jX;if(!e3(Y))p.info("Targeting custom Amp server",{ampURL:Y});return X=rf0(X),{executeMode:Q,isTTY:Z,ampURL:Y,settings:X,secrets:V58(await W60(J,X))}}function Pn4(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 jn4(){let J=Pn4(process.argv);if(O98({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),Ln4(p),p.info("Starting Amp CLI.",{version:"0.0.1762444890-g3a20e7",buildTimestamp:"2025-11-06T16:07:29.967Z"}),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 En4().parseAsync(process.argv)}cs1().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await jn4().catch(bU1)});async function Tn4(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),P5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7105
7105
  `);else if(!e3(J.ampURL))P5.write(`Logging in to ${new URL(J.ampURL).hostname}
7106
7106
  `);let Z=process.env.AMP_API_KEY;if(Z)P5.write(`API key found in environment variable, storing...
7107
7107
  `),await Q.set("apiKey",Z,J.ampURL),P5.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1762430485-gac8d13",
3
+ "version": "0.0.1762444890-g3a20e7",
4
4
  "description": "CLI for Amp, the frontier coding agent from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {