@sourcegraph/amp 0.0.1761828096-gd79db0 → 0.0.1761828586-gd79db0

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
@@ -6031,11 +6031,11 @@ Actual: ${Y}`)}async function y99(J,Q,Z){let{execSync:X}=await import("node:ch
6031
6031
  ${B}`;if(Y==="pnpm"&&B.includes("Unable to find the global bin directory"))M+=`
6032
6032
 
6033
6033
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
6034
- npm install -g @sourcegraph/amp`;q(Error(M))}},error:(H)=>{if(!W)W=!0,q(Error(`Failed to spawn ${Y}: ${H.message}`))},complete:()=>{if(!W)W=!0,G()}})})}G0();G0();async function B51(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=u99(J,G),z=q<0,U,W;if(K.time){let F=K.time[J],H=K.time[G],B=Date.now();if(F)U=Math.floor((B-new Date(F).getTime())/3600000);if(H)W=Math.floor((B-new Date(H).getTime())/3600000)}return u.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:q,hasUpdate:z,currentVersionAge:U,latestVersionAge:W}),{hasUpdate:z,latestVersion:G,currentVersion:J,currentVersionAge:U,latestVersionAge:W,source:"npm"}}catch(Z){return u.debug("Error checking npm version",{error:Z}),{hasUpdate:!1,currentVersion:J,source:"npm"}}}function u99(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}v0();function ay1(J,Q){let Z=new I8,X=Z.pipe(M9({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new cq().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 q_(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 B51(J);if(!(z.latestVersion&&z.hasUpdate)){Y.debug("no update available");return}let U=await H51();if(!q)q=U==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:U,mode:q});if(q==="warn"){Z.next("update-available");return}if(!U){Y.debug("auto-update not supported, falling back to warn mode"),Z.next("update-available");return}try{await gu(z.latestVersion,U);let W=await lV(z.latestVersion),F={from:z.currentVersion,to:z.latestVersion,...W};if(W.status==="same")Y.info("success",F),Z.next("updated");else Y.warn("success with warning",F),Z.next("updated-with-warning")}catch(W){Z.next("update-error")}}catch(G){Y.debug("check failed",{error:G})}finally{await q_(5000),Z.next("hidden"),K.unsubscribe(),Z.complete()}}),{state:X}}import{stderr as aU}from"node:process";function gQ6(J){let Q=new cw().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 cy1(X.force||!1,X.verbose||!1,"0.0.1761828096-gd79db0"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new cw("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 p99(X.version)});J.addCommand(Z)}async function p99(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")aU.write(U8.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6034
+ npm install -g @sourcegraph/amp`;q(Error(M))}},error:(H)=>{if(!W)W=!0,q(Error(`Failed to spawn ${Y}: ${H.message}`))},complete:()=>{if(!W)W=!0,G()}})})}G0();G0();async function B51(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=u99(J,G),z=q<0,U,W;if(K.time){let F=K.time[J],H=K.time[G],B=Date.now();if(F)U=Math.floor((B-new Date(F).getTime())/3600000);if(H)W=Math.floor((B-new Date(H).getTime())/3600000)}return u.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:q,hasUpdate:z,currentVersionAge:U,latestVersionAge:W}),{hasUpdate:z,latestVersion:G,currentVersion:J,currentVersionAge:U,latestVersionAge:W,source:"npm"}}catch(Z){return u.debug("Error checking npm version",{error:Z}),{hasUpdate:!1,currentVersion:J,source:"npm"}}}function u99(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}v0();function ay1(J,Q){let Z=new I8,X=Z.pipe(M9({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new cq().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 q_(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 B51(J);if(!(z.latestVersion&&z.hasUpdate)){Y.debug("no update available");return}let U=await H51();if(!q)q=U==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:U,mode:q});if(q==="warn"){Z.next("update-available");return}if(!U){Y.debug("auto-update not supported, falling back to warn mode"),Z.next("update-available");return}try{await gu(z.latestVersion,U);let W=await lV(z.latestVersion),F={from:z.currentVersion,to:z.latestVersion,...W};if(W.status==="same")Y.info("success",F),Z.next("updated");else Y.warn("success with warning",F),Z.next("updated-with-warning")}catch(W){Z.next("update-error")}}catch(G){Y.debug("check failed",{error:G})}finally{await q_(5000),Z.next("hidden"),K.unsubscribe(),Z.complete()}}),{state:X}}import{stderr as aU}from"node:process";function gQ6(J){let Q=new cw().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 cy1(X.force||!1,X.verbose||!1,"0.0.1761828586-gd79db0"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new cw("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 p99(X.version)});J.addCommand(Z)}async function p99(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")aU.write(U8.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6035
6035
 
6036
6036
  `));try{if(!J){aU.write(U8.blue(`Checking for updates...
6037
- `));let{hasUpdate:Z,latestVersion:X}=await B51("0.0.1761828096-gd79db0");if(!Z){aU.write(U8.green(`✓ Amp CLI is already up to date.
6038
- `));let Y=await lV("0.0.1761828096-gd79db0");if(Y.warning)aU.write(`
6037
+ `));let{hasUpdate:Z,latestVersion:X}=await B51("0.0.1761828586-gd79db0");if(!Z){aU.write(U8.green(`✓ Amp CLI is already up to date.
6038
+ `));let Y=await lV("0.0.1761828586-gd79db0");if(Y.warning)aU.write(`
6039
6039
  `+U8.yellow(Y.warning)+`
6040
6040
  `);process.exit(0)}if(!X)aU.write(U8.yellow("[WARN] could not find latest version")),process.exit(0);J=X}aU.write(U8.blue(`Updating to version ${J}...
6041
6041
  `)),await gu(J,void 0,(Z)=>{aU.write(U8.dim(`Running: ${Z}
@@ -6595,7 +6595,7 @@ exit code: ${q}`,new $1({color:X.foreground,dim:!0,italic:!0})));if(z)U.push(new
6595
6595
  `,B),...M],N=new a0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new a1({text:new N1("",void 0,V)})]}),L="high";if(this.agentMode==="fast")L="fast";else if(this.agentMode==="free")L="free";return B2.child(new g0({constraints:new O6(40,120,0,1/0),child:new Q8({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[new w8({flex:1,child:new tf1({width:40,height:40,colorMode:L,fps:G==="fast"?60:G==="slow"?15:0,...G==="disabled"&&{seed:42,t:3}})}),new F0({width:1}),new w8({flex:2,child:N})]})}))}}l8();class og1 extends c0{props;constructor(J){super({key:J.key});this.props=J;this.props.enabled??=!0}createState(){return new EG6}}class EG6 extends d0{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 F0({width:0,height:0});let G=K?Z.foreground:Z.mutedForeground,q=X.map((z)=>this.buildTodoItem(z,Z,K));return new g0({child:new C6({padding:N0.symmetric(1,0),child:new a0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new a1({text:new N1(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 Q8({crossAxisAlignment:"start",children:[new a1({text:new N1(X,K)}),new F0({width:1}),new w8({child:new a1({text:new N1(J.content,G)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class tg1 extends I6{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 g0({decoration:new G9(void 0,new g8(new k8(Z,1,"rounded"),new k8(Z,1,"rounded"),void 0,new k8(Z,1,"rounded"))),child:new C6({padding:N0.horizontal(1),child:new a0({children:[new Q8({crossAxisAlignment:"start",children:[new w8({child:new a1({text:new N1(this.ad.content,new $1({color:X}))})}),new F0({width:4}),new BQ({uri:"https://ampcode.com/free",text:"Ad",style:new $1({color:X,dim:!0}),onError:(Y)=>{}})]}),new Q8({crossAxisAlignment:"start",children:[new xf1({text:this.ad.buttonLabel,onPressed:()=>this.onButtonClick?.(),padding:N0.horizontal(1),color:Z,reverse:!0}),new F0({width:2}),new a1({text:new N1(this.ad.destinationUrlHostname,new $1({color:X,dim:!0}))})]})]})})})}}B9();l8();class eg1 extends c0{props;constructor(J){super();this.props=J}createState(){return new IG6(this.props.autofocus??!0)}}class IG6 extends d0{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=y8.sizeOf(J),X=Math.min(60,Z.width-4),Y=Z.height-4,K=[];if(this.widget.props.title)K.push(new a1({text:new N1(this.widget.props.title,new $1({bold:!0,color:I1.blue}))}),new F0({height:1}));if(this.widget.props.message)K.push(new a1({text:new N1(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)K.push(new F0({height:1}));let G=[];if(this.widget.props.showCopyOption)G.push(new a1({text:new N1("Enter to copy",new $1({dim:!0}))}));return G.push(new a1({text:new N1("Escape to close",new $1({dim:!0}))})),K.push(new Q8({children:G.flatMap((q,z)=>z<G.length-1?[q,new F0({width:1}),new a1({text:new N1("•",new $1({dim:!0}))}),new F0({width:1})]:[q]),mainAxisSize:"min"})),new B2({child:new g0({constraints:new O6(X,X,0,Y),decoration:new G9(I1.default(),new g8(new k8(I1.blue,1,"rounded"),new k8(I1.blue,1,"rounded"),new k8(I1.blue,1,"rounded"),new k8(I1.blue,1,"rounded"))),padding:new N0(2,2,2,2),child:new t8({autofocus:this.autofocus,onKey:Q,child:new a0({children:K,mainAxisSize:"min"})})})})}}function Jm1(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})}Xj();G0();import{spawn as aZ9}from"node:child_process";import{promises as nZ9}from"node:fs";function PG6(J){return J.kind==="executable"}function TG6(J){return J.kind==="markdown"}var nH=50000,CG6=300000;async function Qm1(J,Q,Z,X={}){let{timeoutMs:Y=CG6,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(u.debug("Executing command",{commandName:J,filePath:G.filePath,args:Q}),TG6(G))return await rZ9(G,Q);else if(PG6(G))return await sZ9(G,Q,Y,K);else return{success:!1,output:"",error:"Unsupported command type"}}catch(G){return u.error("Failed to execute command",{commandName:J,error:G}),{success:!1,output:"",error:G instanceof Error?G.message:"Unknown error occurred"}}}async function rZ9(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Z=await nZ9.readFile(J.filePath,"utf8");return{success:!0,output:(Z.length>nH?Z.slice(0,nH)+`
6596
6596
  ... (output truncated at ${nH} characters)`:Z).trim(),exitCode:0}}catch(Z){return{success:!1,output:"",error:Z instanceof Error?Z.message:"Failed to read markdown file"}}}async function sZ9(J,Q,Z=CG6,X){return new Promise((Y)=>{let[K,G]=oZ9(J,Q);u.debug("Spawning command",{spawnCommand:K,spawnArgs:G.slice(0,10),filePath:J.filePath,timeoutMs:Z});let q=qe1(X),z=!1,U=setTimeout(()=>{z=!0,q.abort(),u.warn("Command execution timed out",{commandName:J.name,timeoutMs:Z})},Z),W=aZ9(K,G,{stdio:["pipe","pipe","pipe"],signal:q.signal,detached:!0}),F=[],H=[],B=0;W.stdout?.on("data",(M)=>{let V=M.toString();if(B+=V.length,B<=nH)F.push(V);else{let N=nH-(B-V.length);if(N>0)F.push(V.slice(0,N))}}),W.stderr?.on("data",(M)=>{let V=M.toString();if(B+=V.length,B<=nH)H.push(V);else{let N=nH-(B-V.length);if(N>0)H.push(V.slice(0,N))}}),W.on("close",(M)=>{if(clearTimeout(U),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:M??void 0});return}let V=M===0||M===1,N=F.join(""),L=H.join(""),A=N;if(!V&&!N.trim()&&L.trim())A=L;else if(L.trim())A+=N?`
6597
6597
  ${L}`:L;if(B>nH)A+=`
6598
- ... (output truncated at ${nH} characters)`;Y({success:V,output:A.trim(),error:!V?L.trim()||"Command failed":void 0,exitCode:M??void 0})}),W.on("error",(M)=>{clearTimeout(U);let V=M.message;if(z)V=`Command timed out after ${Z}ms`;else if(M.message.includes("operation was aborted")||M.name==="AbortError")V="The command was aborted";Y({success:!1,output:F.join(""),error:V})})})}function oZ9(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return eZ9(Z,X?[...X]:null,Y,Q);else return tZ9(Z,X?[...X]:null,Y,Q)}function tZ9(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function eZ9(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]}}G0();R2();wB();SY();bW();hC();import{execSync as SG6}from"child_process";import{writeFile as JX9}from"fs/promises";import QX9 from"path";G0();SY();class Zm1{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.1761828096-gd79db0"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await oa(Q,this.configService)}catch(Q){u.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}}function ZX9(J){return J.startsWith("custom-command-")}function vG6(J){return J.startsWith("agent-mode-")}function XX9(J){return J.replace(/^custom-command-/,"")}class Xm1{configService;registry;onExecute;onExecutionComplete;commands=new Map;latestCustom=[];telemetrySubmitter;constructor(J,Q,Z,X){this.configService=J;this.registry=Q;this.onExecute=Z;this.onExecutionComplete=X;this.configService.config.subscribe((Y)=>{this.commands.clear(),this.registerCommands(Y)}),this.registry.commands.subscribe((Y)=>this.latestCustom=Y),this.telemetrySubmitter=new Zm1(async()=>{try{return(await this.configService.getLatest()).settings["experimental.cli.commandTelemetry.enabled"]===!0}catch{return!1}},this.configService)}async execute(J,Q,Z=[]){this.telemetrySubmitter.submit(J).catch((W)=>{u.debug("Failed to submit command telemetry",W)});let X=new AbortController,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});let W=await G.execute(Q,Z);return this.onExecutionComplete(),W}let q=XX9(J),z=this.latestCustom.find((W)=>W.name===q);if(!z)return;this.onExecute({id:K,name:z.name,startTime:Y,abortController:X});let U=await Qm1(q,Z,this.registry,{signal:X.signal});if(this.onExecutionComplete(),U.success){let W=Q.editorState.text,H=W.trim()&&!W.endsWith(`
6598
+ ... (output truncated at ${nH} characters)`;Y({success:V,output:A.trim(),error:!V?L.trim()||"Command failed":void 0,exitCode:M??void 0})}),W.on("error",(M)=>{clearTimeout(U);let V=M.message;if(z)V=`Command timed out after ${Z}ms`;else if(M.message.includes("operation was aborted")||M.name==="AbortError")V="The command was aborted";Y({success:!1,output:F.join(""),error:V})})})}function oZ9(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return eZ9(Z,X?[...X]:null,Y,Q);else return tZ9(Z,X?[...X]:null,Y,Q)}function tZ9(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function eZ9(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]}}G0();R2();wB();SY();bW();hC();import{execSync as SG6}from"child_process";import{writeFile as JX9}from"fs/promises";import QX9 from"path";G0();SY();class Zm1{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.1761828586-gd79db0"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await oa(Q,this.configService)}catch(Q){u.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}}function ZX9(J){return J.startsWith("custom-command-")}function vG6(J){return J.startsWith("agent-mode-")}function XX9(J){return J.replace(/^custom-command-/,"")}class Xm1{configService;registry;onExecute;onExecutionComplete;commands=new Map;latestCustom=[];telemetrySubmitter;constructor(J,Q,Z,X){this.configService=J;this.registry=Q;this.onExecute=Z;this.onExecutionComplete=X;this.configService.config.subscribe((Y)=>{this.commands.clear(),this.registerCommands(Y)}),this.registry.commands.subscribe((Y)=>this.latestCustom=Y),this.telemetrySubmitter=new Zm1(async()=>{try{return(await this.configService.getLatest()).settings["experimental.cli.commandTelemetry.enabled"]===!0}catch{return!1}},this.configService)}async execute(J,Q,Z=[]){this.telemetrySubmitter.submit(J).catch((W)=>{u.debug("Failed to submit command telemetry",W)});let X=new AbortController,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});let W=await G.execute(Q,Z);return this.onExecutionComplete(),W}let q=XX9(J),z=this.latestCustom.find((W)=>W.name===q);if(!z)return;this.onExecute({id:K,name:z.name,startTime:Y,abortController:X});let U=await Qm1(q,Z,this.registry,{signal:X.signal});if(this.onExecutionComplete(),U.success){let W=Q.editorState.text,H=W.trim()&&!W.endsWith(`
6599
6599
 
6600
6600
  `)?`
6601
6601
  ${U.output}`:U.output;Q.editorDispatch({type:"insert-text",text:H});return}return Error(U.error??`Command '${J}' failed`)}getPriority(J,Q){if(ZX9(J))return 4;if(Q.editorState.hasSelection)switch(J){case"copy-selection":return 60}if(this.isThreadEmpty(Q)){if(vG6(J))return 59;switch(J){case"set-agent-mode":return 58;case"toggle-agent-mode":return 57}}if(this.hasPromptText(Q)&&Q.isProcessing)switch(J){case"queue":return 39;case"dequeue":return 37}if(Q.isProcessing)switch(J){case"queue":return 29;case"dequeue":return 27}if(this.hasPromptText(Q))switch(J){case"handoff":return 19;case"editor":return 18;case"clear":return 17}if(vG6(J))return 0;switch(J){case"help":return 10;case"continue":return 9;case"new":return 8;case"handoff":return 7;case"editor":return 6;case"browser":case"url":case"visibility":case"toggle-thinking-blocks":case"queue":case"clear":case"copy-selection":case"dequeue":case"generate-agent-file":case"agent-files":case"connect":case"disconnect":case"settings":case"permissions":case"permissions-enable":case"permissions-disable":case"ide":case"toggle-agent-mode":case"set-agent-mode":case"show-costs":case"refresh":case"debug-thread-json":return 1;case"quit":return 0}}getCommandFollows(J){switch(J){case"handoff":return["new"];case"quit":return["queue","dequeue"];case"set-agent-mode":case"toggle-agent-mode":return YW().map(({mode:Q})=>`agent-mode-${Q}`);default:return[]}}registerCommands(J){this.register({id:"new",noun:"thread",verb:"new",description:"Start new thread",aliases:["start"],execute:async(X)=>{await X.startNewThread()},isEnabled:(X)=>!this.isThreadEmpty(X)}),this.register({id:"continue",noun:"thread",verb:"switch",description:"Switch to existing thread",aliases:["continue"],gatherArguments:async(X,Y)=>{return await Y.launchThreadPicker()},execute:async(X,Y)=>{await X.switchToThread(Y)},isEnabled:()=>!0}),this.register({id:"handoff",noun:"thread",verb:"handoff",description:"Draft a new thread based on current thread",gatherArguments:async(X,Y)=>{if(this.hasPromptText(X))return X.editorState.text;return await Y.launchMultilinePrompt("handoff","Describe a prompt to hand off...")},execute:async(X,Y)=>{return X.handleHandoff(Y)},isEnabled:(X)=>!this.isThreadEmpty(X),getPromptText:(X)=>{if(this.hasPromptText(X))return this.truncatedPromptText(X)},nonBlocking:!0}),this.register({id:"browser",noun:"thread",verb:"open in browser",description:"Open thread in browser",execute:async({thread:X,ampURL:Y})=>{let K=K_(new URL(Y),X.id).toString();try{await LX(K)}catch(G){u.error("Failed to open browser",{error:G})}},isEnabled:(X)=>!this.isThreadEmpty(X)}),this.register({id:"url",noun:"thread",verb:"copy URL",description:"Copy thread URL",execute:async(X)=>{let Y=K_(new URL(X.ampURL),X.thread.id).toString();try{return await x9.instance.tuiInstance.clipboard.writeText(Y),new pK(`Thread URL: ${Y}
@@ -6650,7 +6650,7 @@ https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_di
6650
6650
  `),J.stdout.write(`Thread: ${H}
6651
6651
  `),J.stdout.write(`Continue this thread with: amp threads continue ${W}
6652
6652
  `)}}function dm1(J){return J==="smart"?I1.rgb(3,197,97):J==="free"?I1.rgb(0,184,255):RY9(J)}function RY9(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 I1.index(Z[X])}Rf1();if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){cK.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
6653
- `)}var lm1=cm1.join(Vc1||cm1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function IY9(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 gq(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")sK("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new v9("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")sK("experimental.agentMode",Q.agentMode)}async function am1(J){try{await jY9(cm1.dirname(lm1),{recursive:!0}),await $Y9(lm1,J,"utf-8")}catch(Q){u.debug("Failed to save last thread ID",Q)}}async function PY9(){try{return(await nq6(lm1,"utf-8")).trim()}catch(J){return null}}function TY9(J,Q){return{...J,async get(Z){if(Z==="mcpServers"){let X=await J.get(Z);return _d("mcpServers",{global:X,workspace:Q})}return J.get(Z)},async keys(){let Z=await J.keys();if(!Z.includes("mcpServers"))Z.push("mcpServers");return Z},[Symbol.dispose](){J[Symbol.dispose]()}}}var lq6=[{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??jJ,description:`Custom settings file path (overrides the default location ${jJ})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(u).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${My1})`},{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:FQ(),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:Ll1}],iq6=(J)=>("deprecated"in J)&&J.deprecated===!0,CY9=(J)=>("hidden"in J)&&J.hidden===!0,SY9=(J)=>("default"in J),vY9=(J)=>("default"in J)?J.default:void 0;function kY9(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 v9(bK.unknownCommand(Z),1,G)}}var rq6=null;function Yn2(){return rq6}function GQ1(J){return{...J,getThreadEnvironment:u71,vfs:C20({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new A_(J.fileSystem),generateThreadTitle:pG0,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var nm1=$0.file(EY9.homedir()),sq6=process.env.XDG_CONFIG_HOME?$0.file(process.env.XDG_CONFIG_HOME):b0.joinPath(nm1,".config");async function mq(J,Q){Ii1("0.0.1761828096-gd79db0");let Z=DX1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:t1.of([$0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:nm1,userConfigDir:sq6}),{initializeCLITelemetry:X}=await Promise.resolve().then(() => (YQ1(),XQ1));X(Z);let Y=await Z.getLatest();u.debug("Global configuration initialized",{settingsKeys:Object.keys(Y.settings)});let K=Bn(VO({configService:Z})),G=new Map,q=()=>G.clear(),z=K20({configService:Z,toolService:K,secretStorage:J.secrets,createOAuthProvider:async(E)=>{let I=G.get(E);if(I)return u.debug("Reusing existing OAuth provider for server",{serverName:E}),I;u.debug("Creating OAuth provider for server",{serverName:E});let T=(async()=>{let S=new X3(J.secrets),x=await S.getClientInfo(E),h=new fU1({storage:S,serverName:E,clientId:x?.clientId,clientSecret:x?.clientSecret,scopes:x?.scopes});return u.debug("OAuth provider created",{serverName:E,hasManualClientId:!!x?.clientId,willUseDCR:!x?.clientId}),h})();return G.set(E,T),T}}),U=DR0(K,j2,se).catch((E)=>{u.warn("Toolbox registration failed, continuing anyway:",E)}),W=z.initialized.catch((E)=>{u.warn("MCP service initialization failed, continuing anyway:",E)}),F=Promise.all([W,U]).then(()=>{});if(Q.jetbrains)AO("JetBrains");else if(Q.ide&&jQ6())AO("VS Code");else if(Q.ide&&$Q6())AO("Neovim");if(J.executeMode)Pi1(!0);w96(K,{configService:Z});let H,B=T7.status.pipe(y0((E)=>Boolean(E.connected&&E.authenticated)),G8()).subscribe((E)=>{if(E){if(!H)H=K.registerTool(Ms)}else H?.dispose(),H=void 0}),M;if(!J.executeMode)M=new Z51(process.cwd(),{},!0);else M=new class extends Z51{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(s2.write(`No API key found. Starting login flow...
6653
+ `)}var lm1=cm1.join(Vc1||cm1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function IY9(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 gq(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")sK("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new v9("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")sK("experimental.agentMode",Q.agentMode)}async function am1(J){try{await jY9(cm1.dirname(lm1),{recursive:!0}),await $Y9(lm1,J,"utf-8")}catch(Q){u.debug("Failed to save last thread ID",Q)}}async function PY9(){try{return(await nq6(lm1,"utf-8")).trim()}catch(J){return null}}function TY9(J,Q){return{...J,async get(Z){if(Z==="mcpServers"){let X=await J.get(Z);return _d("mcpServers",{global:X,workspace:Q})}return J.get(Z)},async keys(){let Z=await J.keys();if(!Z.includes("mcpServers"))Z.push("mcpServers");return Z},[Symbol.dispose](){J[Symbol.dispose]()}}}var lq6=[{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??jJ,description:`Custom settings file path (overrides the default location ${jJ})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(u).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${My1})`},{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:FQ(),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:Ll1}],iq6=(J)=>("deprecated"in J)&&J.deprecated===!0,CY9=(J)=>("hidden"in J)&&J.hidden===!0,SY9=(J)=>("default"in J),vY9=(J)=>("default"in J)?J.default:void 0;function kY9(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 v9(bK.unknownCommand(Z),1,G)}}var rq6=null;function Yn2(){return rq6}function GQ1(J){return{...J,getThreadEnvironment:u71,vfs:C20({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new A_(J.fileSystem),generateThreadTitle:pG0,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var nm1=$0.file(EY9.homedir()),sq6=process.env.XDG_CONFIG_HOME?$0.file(process.env.XDG_CONFIG_HOME):b0.joinPath(nm1,".config");async function mq(J,Q){Ii1("0.0.1761828586-gd79db0");let Z=DX1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:t1.of([$0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:nm1,userConfigDir:sq6}),{initializeCLITelemetry:X}=await Promise.resolve().then(() => (YQ1(),XQ1));X(Z);let Y=await Z.getLatest();u.debug("Global configuration initialized",{settingsKeys:Object.keys(Y.settings)});let K=Bn(VO({configService:Z})),G=new Map,q=()=>G.clear(),z=K20({configService:Z,toolService:K,secretStorage:J.secrets,createOAuthProvider:async(E)=>{let I=G.get(E);if(I)return u.debug("Reusing existing OAuth provider for server",{serverName:E}),I;u.debug("Creating OAuth provider for server",{serverName:E});let T=(async()=>{let S=new X3(J.secrets),x=await S.getClientInfo(E),h=new fU1({storage:S,serverName:E,clientId:x?.clientId,clientSecret:x?.clientSecret,scopes:x?.scopes});return u.debug("OAuth provider created",{serverName:E,hasManualClientId:!!x?.clientId,willUseDCR:!x?.clientId}),h})();return G.set(E,T),T}}),U=DR0(K,j2,se).catch((E)=>{u.warn("Toolbox registration failed, continuing anyway:",E)}),W=z.initialized.catch((E)=>{u.warn("MCP service initialization failed, continuing anyway:",E)}),F=Promise.all([W,U]).then(()=>{});if(Q.jetbrains)AO("JetBrains");else if(Q.ide&&jQ6())AO("VS Code");else if(Q.ide&&$Q6())AO("Neovim");if(J.executeMode)Pi1(!0);w96(K,{configService:Z});let H,B=T7.status.pipe(y0((E)=>Boolean(E.connected&&E.authenticated)),G8()).subscribe((E)=>{if(E){if(!H)H=K.registerTool(Ms)}else H?.dispose(),H=void 0}),M;if(!J.executeMode)M=new Z51(process.cwd(),{},!0);else M=new class extends Z51{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(s2.write(`No API key found. Starting login flow...
6654
6654
  `),!await _Y9(J))await QR(),process.exit(1)}let V=await b20({isDevelopment:!1}),N=new LV1(V),L=new XB1(V,Z,{lazy:!0}),A=Q.notifications!==void 0?Q.notifications:!J.executeMode,w=O96({playNotificationSound:async(E)=>{if(A){R96(E);let I=Af1(),T=wf1();if((!I||T)&&Y.settings["notifications.system.enabled"]!==!1){if(E==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(E==="requires-user-input")process.stdout.write("\x1B]777;notify;Amp;Waiting for approval\x1B\\")}}},windowFocused:()=>Promise.resolve(!1),threadService:N,configService:Z});u.info("Starting Amp background services");let R=uG0({threadService:N,threadHistoryService:L,configService:Z,isExtensionDevelopment:!1}),O;T7.status.subscribe((E)=>{O=E});let j={codebaseContextService:new zZ1({workspaceRoots:[$0.file(process.cwd())],getCurrentFile:()=>{if(!O?.openFile)return;try{return $0.parse(O.openFile)}catch(E){u.warn("Failed to parse current file URI",{uri:O.openFile,error:E});return}},getOpenFiles:()=>{if(!O?.visibleFiles?.length)return[];let E=O.openFile;return O.visibleFiles.filter((I)=>I!==E).map((I)=>{try{return $0.parse(I)}catch(T){return u.warn("Failed to parse visible file URI",{uri:I,error:T}),null}}).filter((I)=>I!==null)}}),configService:Z,toolService:K,mcpService:z,threadService:N,threadHistoryService:L,threadSyncService:R,threadStorage:V,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:M,notificationService:w,backgroundInit:F,fileSystem:Q.jetbrains||Q.ide?I20:j2};return{...j,async asyncDispose(){await j.mcpService.dispose(),q(),await j.threadService.asyncDispose(),j.configService.unsubscribe(),j.toolService.dispose(),j.fuzzyServer.dispose(),j.threadSyncService.dispose(),j.settingsStorage[Symbol.dispose](),B.unsubscribe(),H?.dispose()}}}async function _Y9(J){if(!J.executeMode){if(!await ry1("Would you like to log in to Amp? [(y)es, (n)o]: "))return s2.write(`Login cancelled. Run the command again to retry.
6655
6655
  `),!1}return await oq6(J)}async function oq6(J){let Q=OY9(32).toString("hex"),Z=await ny1(J.ampURL,Q),X=new AbortController;try{await LX(Z,X.signal)}catch(K){u.error("Error opening browser",{error:K})}let Y=await ny1(J.ampURL,Q,!1);s2.write(`If your browser does not open automatically, visit:
6656
6656
 
@@ -6660,13 +6660,13 @@ ${U8.blue.bold(Y)}
6660
6660
  Login successful! You can now use the Amp CLI.
6661
6661
  `),!0}catch(K){return u.error("Login failed",{error:K}),cK.write(`
6662
6662
  Login failed: ${K instanceof Error?K.message:String(K)}
6663
- `),!1}}function xY9(){let J=new cw().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)YR(),process.exit(0);let W=U.originalError??U;jJ6(W)}),J.option("-V, --version","output the version number",()=>{s2.write(`0.0.1761828096-gd79db0 (released 2025-10-30T12:46:57.459Z)
6663
+ `),!1}}function xY9(){let J=new cw().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)YR(),process.exit(0);let W=U.originalError??U;jJ6(W)}),J.option("-V, --version","output the version number",()=>{s2.write(`0.0.1761828586-gd79db0 (released 2025-10-30T12:54:54.610Z)
6664
6664
  `),process.exit(0)}),J.addHelpText("after",wQ6()),J.configureHelp({formatHelp:RQ6}),J.command("logout").description("Log out by removing stored API key").action(async(U,W)=>{let F=W.optsWithGlobals(),H=await HX(F);await hY9(H)}),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,W)=>{let F=W.optsWithGlobals(),H=await HX(F);await fY9(H,await fy1(F,H.settings))});let Q=async(U,W,F)=>{DX1({storage:W.settings,secretStorage:W.secrets,workspaceRoots:t1.of([$0.file(process.cwd())]),defaultAmpURL:W.ampURL,homeDir:nm1,userConfigDir:sq6});let H={...W,executeMode:!1};await im1(H,{...U,startWithPicker:!0},F)},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,W)=>{let F=W.optsWithGlobals(),H=await HX(F);await aq6(F,H,W)});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,W)=>{let F=W.optsWithGlobals(),H=await HX(F);await cY9(F,H,W)}),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,W,F)=>{let H=F.optsWithGlobals(),B=await HX(H);if(W.pick)cK.write(`${U8.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
6665
6665
  `);if(W.last||U||B.executeMode)await dY9(H,B,U,F);else await Q(H,B,F)}),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,W,F)=>{let H=F.optsWithGlobals(),B=await HX(H);await pY9(H,B,U,F)}),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,W)=>{let F=W.optsWithGlobals(),H=await HX(F);await aq6(F,H,W)}),Z.command("share <threadId>").summary("Share a thread").description("Change thread visibility (private, public, 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, workspace, group)").option("--support","Share thread with Amp support for debugging").action(async(U,W,F)=>{let H=F.optsWithGlobals(),B=await HX(H);await uY9(H,B,U,F,W.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,W,F,H)=>{let B=H.optsWithGlobals(),M=await HX(B);await gY9(B,M,U,W,H)}),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,W,F)=>{let H=F.optsWithGlobals(),B=await HX(H);await mY9(H,B,U,F)}),EZ6(J,async(U,W)=>{let F=await HX(W);gq(U,W);let H=await mq(F,W);return{context:F,mcpService:H.mcpService,toolService:H.toolService,configService:H.configService,cleanupTerminal:YR,asyncDispose:H.asyncDispose.bind(H)}}),JZ6(J),iQ6(J,async(U)=>{let W=await HX(U);return{settings:W.settings,secretStorage:W.secrets,getThreadDeps:async(F)=>{gq(F,U);let H=await mq(W,U);return{mcpService:H.mcpService,asyncDispose:H.asyncDispose.bind(H)}}}}),J.command("connect").description("Connect CLI to web interface for multi-thread management").action(async(U,W)=>{let F=W.optsWithGlobals(),H=await HX(F);gq(W,F);let B=await mq(H,F);try{await $y1(B,B.configService,{})}finally{await B.asyncDispose(),await YR()}});function X(U,W,F){let B=typeof U.description==="string"?U.description:F===void 0?U.description(!0):U.description(F),M=new bV(W,B),V=vY9(U);if(V)M.default(V);if(M.hidden=CY9(U)||iq6(U),"choices"in U)M.choices([...U.choices]);return M}for(let U of lq6)switch(U.type){case"flag":{J.addOption(X(U,`--${U.long}`)),J.addOption(X(U,`--no-${U.long}`,!1));break}case"switch":{J.addOption(X(U,`--${U.long}`,!0));break}default:{J.addOption(X(U,`--${U.long} <value>`));break}}let Y=new bV("-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(Y);let K=new bV("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1).hideHelp();J.addOption(K);let G=new bV("--stream-json","When used with --execute, output in Claude Code compatible stream JSON format instead of plain text.").default(!1);J.addOption(G);let q=new bV("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(q);let z=new bV("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);if(J.addOption(z),process.env.AMP_CONNECT==="1"){let U=new bV("--client-id <clientId>","Override the client ID for connect functionality (default: amp-<pid>@<hostname>)");J.addOption(U)}return J.action(async(U,W)=>{let F=U,H=await HX(F);if(Object.keys(F).forEach((B)=>{let M=lq6.find((V)=>V.name===B);if(M&&iq6(M)&&!SY9(M))cK.write(U8.yellow(`Warning: '--${B}' flag is deprecated
6666
6666
  `))}),W.args.length>0)kY9(H,W);await im1(H,F,W)}),gQ6(J),J}async function KQ1(J,Q){let{thread:Z,visibility:X}=Q,Y=Z?.id??eq(),K=GQ1(J);if(Z)await J.threadStorage.set(Y,Z);let G=await qJ.getOrCreateForThread(K,Y);if(X)await J.threadSyncService.updateThreadMeta(Y,M51(X));let q=J.threadService.observe(Y).subscribe(async(z)=>{if(n7(z,"assistant"))await am1(Y),q.unsubscribe()});return await G.resume(),G}async function im1(J,Q,Z){let X=D51(Q);if(X instanceof Error)dK(X.message);let Y,K=null;if(Q.streamJsonInput)Y="";else if(typeof Q.execute==="string"){Y=Q.execute;let O=(await oy1()).trimEnd();if(O)K=O}else Y=(await oy1()).trimEnd();if(Q.remote&&!J.executeMode)throw new v9("The -r/--remote flag currently only works with --execute mode",1,'Use: amp --remote --execute "your message"');if(Q.streamJson&&!J.executeMode)throw new v9("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new v9("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!Q.streamJson)throw new v9("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 v9(`Execute mode is not permitted with --agent-mode '${Q.agentMode}'`,1);if(Q.stats&&!J.executeMode)throw new v9("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 v9("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 v9("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"
6667
6667
  Or pipe via stdin: echo "your message" | amp --execute`);gq(Z,Q);let G=await mq(J,Q);if(J.executeMode||Q.threadId)await G.backgroundInit;rq6=G;let q=GQ1(G),z=async(O)=>{let $=await nq6(O,"utf-8"),j=JSON.parse($);if(!ZG(j.id))throw new v9(bK.invalidThreadId);return KQ1(G,{visibility:X,thread:j})},U=async(O)=>{if(!ZG(O))throw new v9(bK.invalidThreadId);let $=await G.threadService.get(O)??void 0;if(u.info(`[fetchAndStartThread] Loaded thread ${O}, agentMode: ${$?.agentMode??"undefined"}`),$?.agentMode)u.info(`[fetchAndStartThread] Setting runtime override for agentMode to: ${$.agentMode}`),sK("experimental.agentMode",$.agentMode);else u.info("[fetchAndStartThread] No agentMode on thread, not setting override");return KQ1(G,{visibility:X,thread:$})},W=async()=>{try{if(Q.threadId)return U(Q.threadId);else return KQ1(G,{visibility:X})}catch(O){if(O instanceof v9)throw O;throw await a71(O,Q.threadId),Error("handleError should have called process.exit()")}},F=async()=>{return KQ1(G,{visibility:X})};if(Q.format==="jsonl")cK.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
6668
- `),await QR(),process.exit(1);if(J.executeMode&&Q.remote)await QZ6(Y,K,G.configService),await G.asyncDispose(),process.exit(0);let H=await W();if(J.executeMode)await yJ6(H,H.threadID,Y,K,G,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await G.asyncDispose(),process.exit(0);let B=!1,M=!1;if(Q.jetbrains||Q.ide){await mn1();let O=await yO({jetbrainsOnly:Q.jetbrains});if(O.length===0){if(Q.jetbrains)M=!await G.configService.get("jetbrains.skipInstall")}else if(O.length===1){let $=O[0];if($)T7.selectConfig($)}else B=!0}let V=ay1("0.0.1761828096-gd79db0",G.settingsStorage),N=new ZB1(G.threadStorage),L=t1.of([$0.file(process.cwd())]),A=Tc1(void 0,L);if(Y)H.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}});let w;try{w=await JJ.getUserFreeTierStatus({},{config:G.configService,signal:AbortSignal.timeout(5000)})}catch(O){w={ok:!1,error:O}}u.info("User free tier status:",w);let R=await KZ6();u.info("Loaded session state:",R),await cq6({codebaseContextService:G.codebaseContextService,stdout:process.stdout,history:new Cy1,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadSyncService:G.threadSyncService,threadID:H.threadID,threadFuzzyIndexer:N,worker:H,workerDeps:q,configService:G.configService,internalAPIClient:JJ,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{u.info("Thread picker requested - not yet implemented in TUI")},switchToThread:U,ideClient:T7,connectedClientsService:new NX1,commandRegistry:A,showJetBrainsInstaller:M,showIdePicker:B,startWithPicker:Q.startWithPicker,updateService:V,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:R,freeTierStatus:w.ok?w.result:void 0,threadDependencies:G}),await G.asyncDispose(),process.exit(0)}async function HX(J){if(J.interactive)cK.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6669
- `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY,X=await YQ6({...J,workspaceTrust:{current:!0,changes:iC},getHook:process.env.AMP_URL?(G,q)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return q()}:void 0});if(J.mcpConfig){let G=await aQ6(J.mcpConfig);X=TY9(X,G)}let Y=await X.get("url","global");if(!Y)Y=zZ;if(!HB(Y))u.info("Targeting custom Amp server",{ampURL:Y});if(X=pc1(X),await X.get("debug.httpLogging"))_c1();return{executeMode:Q,isTTY:Z,ampURL:Y,settings:X,secrets:ZZ6(await fy1(J,X))}}function bY9(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 yY9(){let J=bY9(process.argv);if(GJ6({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),IY9(u),u.info("Starting Amp CLI.",{version:"0.0.1761828096-gd79db0",buildTimestamp:"2025-10-30T12:46:57.459Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new v9(bK.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await xY9().parseAsync(process.argv)}yY9().catch(a71);async function fY9(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),s2.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6668
+ `),await QR(),process.exit(1);if(J.executeMode&&Q.remote)await QZ6(Y,K,G.configService),await G.asyncDispose(),process.exit(0);let H=await W();if(J.executeMode)await yJ6(H,H.threadID,Y,K,G,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await G.asyncDispose(),process.exit(0);let B=!1,M=!1;if(Q.jetbrains||Q.ide){await mn1();let O=await yO({jetbrainsOnly:Q.jetbrains});if(O.length===0){if(Q.jetbrains)M=!await G.configService.get("jetbrains.skipInstall")}else if(O.length===1){let $=O[0];if($)T7.selectConfig($)}else B=!0}let V=ay1("0.0.1761828586-gd79db0",G.settingsStorage),N=new ZB1(G.threadStorage),L=t1.of([$0.file(process.cwd())]),A=Tc1(void 0,L);if(Y)H.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}});let w;try{w=await JJ.getUserFreeTierStatus({},{config:G.configService,signal:AbortSignal.timeout(5000)})}catch(O){w={ok:!1,error:O}}u.info("User free tier status:",w);let R=await KZ6();u.info("Loaded session state:",R),await cq6({codebaseContextService:G.codebaseContextService,stdout:process.stdout,history:new Cy1,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadSyncService:G.threadSyncService,threadID:H.threadID,threadFuzzyIndexer:N,worker:H,workerDeps:q,configService:G.configService,internalAPIClient:JJ,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{u.info("Thread picker requested - not yet implemented in TUI")},switchToThread:U,ideClient:T7,connectedClientsService:new NX1,commandRegistry:A,showJetBrainsInstaller:M,showIdePicker:B,startWithPicker:Q.startWithPicker,updateService:V,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:R,freeTierStatus:w.ok?w.result:void 0,threadDependencies:G}),await G.asyncDispose(),process.exit(0)}async function HX(J){if(J.interactive)cK.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6669
+ `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY,X=await YQ6({...J,workspaceTrust:{current:!0,changes:iC},getHook:process.env.AMP_URL?(G,q)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return q()}:void 0});if(J.mcpConfig){let G=await aQ6(J.mcpConfig);X=TY9(X,G)}let Y=await X.get("url","global");if(!Y)Y=zZ;if(!HB(Y))u.info("Targeting custom Amp server",{ampURL:Y});if(X=pc1(X),await X.get("debug.httpLogging"))_c1();return{executeMode:Q,isTTY:Z,ampURL:Y,settings:X,secrets:ZZ6(await fy1(J,X))}}function bY9(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 yY9(){let J=bY9(process.argv);if(GJ6({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),IY9(u),u.info("Starting Amp CLI.",{version:"0.0.1761828586-gd79db0",buildTimestamp:"2025-10-30T12:54:54.610Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new v9(bK.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await xY9().parseAsync(process.argv)}yY9().catch(a71);async function fY9(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),s2.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6670
6670
  `);else if(!HB(J.ampURL))s2.write(`Logging in to ${new URL(J.ampURL).hostname}
6671
6671
  `);let Z=process.env.AMP_API_KEY;if(Z)s2.write(`API key found in environment variable, storing...
6672
6672
  `),await Q.set("apiKey",Z,J.ampURL),s2.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1761828096-gd79db0",
3
+ "version": "0.0.1761828586-gd79db0",
4
4
  "description": "CLI for Amp, the frontier coding agent from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {