@sourcegraph/amp 0.0.1759502872-g3e67fa → 0.0.1759507289-g3e67fa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +7 -7
- package/package.json +1 -1
package/dist/main.js
CHANGED
@@ -5802,7 +5802,7 @@ See https://ampcode.com/manual#toolboxes`);return Q[0]||xO}function D76(J,Q){let
|
|
5802
5802
|
`);J.command("use").argument("<tool-name>","The tool to invoke").summary("Invoke a tool with arguments or JSON input from stdin").description(Z).option("--only <field>","Extract only the specified field from the result").allowUnknownOption(!0).allowExcessArguments(!0).action(async function(X,Y,K){let q=K.optsWithGlobals(),G=await Q(K,q),z=0;await G.mcpService.initialized;let U=K.args.slice(1),W;if(H76()){let F=[];for await(let H of process.stdin)F.push(H);W=Buffer.concat(F).toString("utf-8").trim()}await W76({toolName:X,rawArgs:U,stdinInput:W,only:Y.only,threadDeps:G,stdout:process.stdout,stderr:process.stderr,exit:(F)=>{z=F}}),await G.asyncDispose(),G.cleanupTerminal(),process.exit(z)})}H0();Ow();P2();import{homedir as V49}from"node:os";import Xu from"node:path";Aw();X7();qN();e2();q3();n6();k0();function M76(J){let Q=J.trim();if(Q==="quit"||Q==="exit")return"/quit";return J}H0();qN();import ct8 from"node:fs";import V76 from"node:path";function N76(J){let Q=J.trim().replace(/^["']|["']$/g,"");if(Q=Q.replace(/\\(.)/g,"$1"),!/\.(png|jpe?g|gif|webp)$/i.test(Q))return null;if(!V76.isAbsolute(Q))return null;return l.debug("Extracted image path",{original:J,extracted:Q}),Q}function L76(J){try{let Q=V76.extname(J).toLowerCase(),Z=Us1(Q);if(!Z)return l.warn("Unsupported image file extension",{ext:Q}),null;try{let X=ct8.readFileSync(J);return lt8(X,Z)}catch(X){l.error(`Failed to read image file ${J}:`,X)}}catch(Q){l.error("Error handling image file path",{imagePath:J,error:Q})}return null}function lt8(J,Q){if(J.length>aj)return l.warn(`Image file too large: ${J.length} bytes (max: ${aj})`),null;return{type:"image",source:{type:"base64",data:J.toString("base64"),mediaType:Q}}}import{execSync as b76}from"node:child_process";import{rmdir as ve8}from"node:fs/promises";import{tmpdir as ke8}from"node:os";import x76 from"node:path";lj();H0();import{spawn as it8}from"node:child_process";import{promises as at8}from"node:fs";function A76(J){return J.kind==="executable"}function O76(J){return J.kind==="markdown"}var ZH=50000,j76=300000;async function Wb1(J,Q,Z,X={}){let{timeoutMs:Y=j76,signal:K}=X;try{let q=await Z.getCommand(J);if(!q)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(l.debug("Executing command",{commandName:J,filePath:q.filePath,args:Q}),O76(q))return await nt8(q,Q);else if(A76(q))return await rt8(q,Q,Y,K);else return{success:!1,output:"",error:"Unsupported command type"}}catch(q){return l.error("Failed to execute command",{commandName:J,error:q}),{success:!1,output:"",error:q instanceof Error?q.message:"Unknown error occurred"}}}async function nt8(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Z=await at8.readFile(J.filePath,"utf8");return{success:!0,output:(Z.length>ZH?Z.slice(0,ZH)+`
|
5803
5803
|
... (output truncated at ${ZH} characters)`:Z).trim(),exitCode:0}}catch(Z){return{success:!1,output:"",error:Z instanceof Error?Z.message:"Failed to read markdown file"}}}async function rt8(J,Q,Z=j76,X){return new Promise((Y)=>{let[K,q]=st8(J,Q);l.debug("Spawning command",{spawnCommand:K,spawnArgs:q.slice(0,10),filePath:J.filePath,timeoutMs:Z});let G=Ks1(X),z=!1,U=setTimeout(()=>{z=!0,G.abort(),l.warn("Command execution timed out",{commandName:J.name,timeoutMs:Z})},Z),W=it8(K,q,{stdio:["pipe","pipe","pipe"],signal:G.signal,detached:!0}),F=[],H=[],B=0;W.stdout?.on("data",(M)=>{let V=M.toString();if(B+=V.length,B<=ZH)F.push(V);else{let N=ZH-(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<=ZH)H.push(V);else{let N=ZH-(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(G.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?`
|
5804
5804
|
${L}`:L;if(B>ZH)A+=`
|
5805
|
-
... (output truncated at ${ZH} 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 st8(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return tt8(Z,X?[...X]:null,Y,Q);else return ot8(Z,X?[...X]:null,Y,Q)}function ot8(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function tt8(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]}}H0();Ow();P2();Aw();X7();xV();pG();xB();n6();k0();import{mkdtemp as _e8,readFile as be8,unlink as xe8,writeFile as JK2}from"fs/promises";var H41={};V6(H41,{scrollUp:()=>Le8,scrollDown:()=>Ae8,link:()=>Ee8,image:()=>$e8,iTerm:()=>Pe8,exitAlternativeScreen:()=>we8,eraseUp:()=>Ne8,eraseStartLine:()=>Me8,eraseScreen:()=>Fb1,eraseLines:()=>Be8,eraseLine:()=>E76,eraseEndLine:()=>De8,eraseDown:()=>Ve8,enterAlternativeScreen:()=>Re8,cursorUp:()=>w76,cursorTo:()=>Qe8,cursorShow:()=>He8,cursorSavePosition:()=>qe8,cursorRestorePosition:()=>Ge8,cursorPrevLine:()=>We8,cursorNextLine:()=>Ue8,cursorMove:()=>Ze8,cursorLeft:()=>I76,cursorHide:()=>Fe8,cursorGetPosition:()=>ze8,cursorForward:()=>Ye8,cursorDown:()=>Xe8,cursorBackward:()=>Ke8,clearTerminal:()=>je8,clearScreen:()=>Oe8,beep:()=>Ie8});import Hb1 from"node:process";var F41=globalThis.window?.document!==void 0,qY2=globalThis.process?.versions?.node!==void 0,GY2=globalThis.process?.versions?.bun!==void 0,zY2=globalThis.Deno?.version?.deno!==void 0,UY2=globalThis.process?.versions?.electron!==void 0,WY2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,FY2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,HY2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,BY2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,DY2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Hm=globalThis.navigator?.userAgentData?.platform,MY2=Hm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",VY2=Hm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",NY2=Hm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",LY2=Hm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),AY2=Hm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var q2="\x1B[",Dm="\x1B]",KT="\x07",Bm=";",R76=!F41&&Hb1.env.TERM_PROGRAM==="Apple_Terminal",et8=!F41&&Hb1.platform==="win32",Je8=F41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:Hb1.cwd,Qe8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return q2+(J+1)+"G";return q2+(Q+1)+Bm+(J+1)+"H"},Ze8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=q2+-J+"D";else if(J>0)Z+=q2+J+"C";if(Q<0)Z+=q2+-Q+"A";else if(Q>0)Z+=q2+Q+"B";return Z},w76=(J=1)=>q2+J+"A",Xe8=(J=1)=>q2+J+"B",Ye8=(J=1)=>q2+J+"C",Ke8=(J=1)=>q2+J+"D",I76=q2+"G",qe8=R76?"\x1B7":q2+"s",Ge8=R76?"\x1B8":q2+"u",ze8=q2+"6n",Ue8=q2+"E",We8=q2+"F",Fe8=q2+"?25l",He8=q2+"?25h",Be8=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=E76+(Z<J-1?w76():"");if(J)Q+=I76;return Q},De8=q2+"K",Me8=q2+"1K",E76=q2+"2K",Ve8=q2+"J",Ne8=q2+"1J",Fb1=q2+"2J",Le8=q2+"S",Ae8=q2+"T",Oe8="\x1Bc",je8=et8?`${Fb1}${q2}0f`:`${Fb1}${q2}3J${q2}H`,Re8=q2+"?1049h",we8=q2+"?1049l",Ie8=KT,Ee8=(J,Q)=>[Dm,"8",Bm,Bm,Q,KT,J,Dm,"8",Bm,Bm,KT].join(""),$e8=(J,Q={})=>{let Z=`${Dm}1337;File=inline=1`;if(Q.width)Z+=`;width=${Q.width}`;if(Q.height)Z+=`;height=${Q.height}`;if(Q.preserveAspectRatio===!1)Z+=";preserveAspectRatio=0";return Z+":"+Buffer.from(J).toString("base64")+KT},Pe8={setCwd:(J=Je8())=>`${Dm}50;CurrentDir=${J}${KT}`,annotation(J,Q={}){let Z=`${Dm}1337;`,X=Q.x!==void 0,Y=Q.y!==void 0;if((X||Y)&&!(X&&Y&&Q.length!==void 0))throw Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");if(J=J.replaceAll("|",""),Z+=Q.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",Q.length>0)Z+=(X?[J,Q.length,Q.x,Q.y]:[Q.length,J]).join("|");else Z+=J;return Z+KT}};var B41=K8(k76(),1);function tM(J,Q,{target:Z="stdout",...X}={}){if(!B41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (${Q})`}return H41.link(J,Q)}tM.isSupported=B41.default.stdout;tM.stderr=(J,Q,Z={})=>tM(J,Q,{target:"stderr",...Z});tM.stderr.isSupported=B41.default.stderr;H0();pG();class Nb1{enabled;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J){this.enabled=J;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.
|
5805
|
+
... (output truncated at ${ZH} 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 st8(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return tt8(Z,X?[...X]:null,Y,Q);else return ot8(Z,X?[...X]:null,Y,Q)}function ot8(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function tt8(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]}}H0();Ow();P2();Aw();X7();xV();pG();xB();n6();k0();import{mkdtemp as _e8,readFile as be8,unlink as xe8,writeFile as JK2}from"fs/promises";var H41={};V6(H41,{scrollUp:()=>Le8,scrollDown:()=>Ae8,link:()=>Ee8,image:()=>$e8,iTerm:()=>Pe8,exitAlternativeScreen:()=>we8,eraseUp:()=>Ne8,eraseStartLine:()=>Me8,eraseScreen:()=>Fb1,eraseLines:()=>Be8,eraseLine:()=>E76,eraseEndLine:()=>De8,eraseDown:()=>Ve8,enterAlternativeScreen:()=>Re8,cursorUp:()=>w76,cursorTo:()=>Qe8,cursorShow:()=>He8,cursorSavePosition:()=>qe8,cursorRestorePosition:()=>Ge8,cursorPrevLine:()=>We8,cursorNextLine:()=>Ue8,cursorMove:()=>Ze8,cursorLeft:()=>I76,cursorHide:()=>Fe8,cursorGetPosition:()=>ze8,cursorForward:()=>Ye8,cursorDown:()=>Xe8,cursorBackward:()=>Ke8,clearTerminal:()=>je8,clearScreen:()=>Oe8,beep:()=>Ie8});import Hb1 from"node:process";var F41=globalThis.window?.document!==void 0,qY2=globalThis.process?.versions?.node!==void 0,GY2=globalThis.process?.versions?.bun!==void 0,zY2=globalThis.Deno?.version?.deno!==void 0,UY2=globalThis.process?.versions?.electron!==void 0,WY2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,FY2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,HY2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,BY2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,DY2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Hm=globalThis.navigator?.userAgentData?.platform,MY2=Hm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",VY2=Hm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",NY2=Hm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",LY2=Hm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),AY2=Hm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var q2="\x1B[",Dm="\x1B]",KT="\x07",Bm=";",R76=!F41&&Hb1.env.TERM_PROGRAM==="Apple_Terminal",et8=!F41&&Hb1.platform==="win32",Je8=F41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:Hb1.cwd,Qe8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return q2+(J+1)+"G";return q2+(Q+1)+Bm+(J+1)+"H"},Ze8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=q2+-J+"D";else if(J>0)Z+=q2+J+"C";if(Q<0)Z+=q2+-Q+"A";else if(Q>0)Z+=q2+Q+"B";return Z},w76=(J=1)=>q2+J+"A",Xe8=(J=1)=>q2+J+"B",Ye8=(J=1)=>q2+J+"C",Ke8=(J=1)=>q2+J+"D",I76=q2+"G",qe8=R76?"\x1B7":q2+"s",Ge8=R76?"\x1B8":q2+"u",ze8=q2+"6n",Ue8=q2+"E",We8=q2+"F",Fe8=q2+"?25l",He8=q2+"?25h",Be8=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=E76+(Z<J-1?w76():"");if(J)Q+=I76;return Q},De8=q2+"K",Me8=q2+"1K",E76=q2+"2K",Ve8=q2+"J",Ne8=q2+"1J",Fb1=q2+"2J",Le8=q2+"S",Ae8=q2+"T",Oe8="\x1Bc",je8=et8?`${Fb1}${q2}0f`:`${Fb1}${q2}3J${q2}H`,Re8=q2+"?1049h",we8=q2+"?1049l",Ie8=KT,Ee8=(J,Q)=>[Dm,"8",Bm,Bm,Q,KT,J,Dm,"8",Bm,Bm,KT].join(""),$e8=(J,Q={})=>{let Z=`${Dm}1337;File=inline=1`;if(Q.width)Z+=`;width=${Q.width}`;if(Q.height)Z+=`;height=${Q.height}`;if(Q.preserveAspectRatio===!1)Z+=";preserveAspectRatio=0";return Z+":"+Buffer.from(J).toString("base64")+KT},Pe8={setCwd:(J=Je8())=>`${Dm}50;CurrentDir=${J}${KT}`,annotation(J,Q={}){let Z=`${Dm}1337;`,X=Q.x!==void 0,Y=Q.y!==void 0;if((X||Y)&&!(X&&Y&&Q.length!==void 0))throw Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");if(J=J.replaceAll("|",""),Z+=Q.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",Q.length>0)Z+=(X?[J,Q.length,Q.x,Q.y]:[Q.length,J]).join("|");else Z+=J;return Z+KT}};var B41=K8(k76(),1);function tM(J,Q,{target:Z="stdout",...X}={}){if(!B41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (${Q})`}return H41.link(J,Q)}tM.isSupported=B41.default.stdout;tM.stderr=(J,Q,Z={})=>tM(J,Q,{target:"stderr",...Z});tM.stderr.isSupported=B41.default.stderr;H0();pG();class Nb1{enabled;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J){this.enabled=J;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.1759507289-g3e67fa"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await et1(Q)}catch(Q){l.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}}H0();class D41 extends Error{constructor(J="Thread has no messages to compact"){super(J);this.name="NoMessagesToCompactError"}}class rZ{message;name;constructor(J){this.message=J;this.name="InformationMessage"}}function _76(J){if(J instanceof D41)return{title:"Cannot compact thread",description:"Thread has no messages to compact.",type:"error"};if(J instanceof rZ)return{title:"Info",description:J.message,type:"info"};return l.warn("Unknown error type encountered",{name:J.name,message:J.message,stack:J.stack}),{title:"Error",description:J.message||"An unexpected error occurred.",type:"error"}}var ye8={connect:{name:"connect",description:"Connect CLI to web interface for current thread access",execute:async(J,Q)=>{try{let{connectedClientsService:Z}=J;await Z.start({clientId:J.clientId,currentThreadID:J.worker.thread.id});let Y=Z.getCurrentStatus().clientID||"unknown",{connectBackground:K}=await Promise.resolve().then(() => (v_1(),H26));return(await K({worker:J.worker},{clientId:J.clientId,onUserDisconnect:()=>{Z.sendStatus({connected:!1,enabled:!1,errorMessage:"Disconnected by user via web interface"})}})).promise.then(()=>{Z.sendStatus({connected:!0,errorMessage:void 0})}).catch((G)=>{Z.sendStatus({connected:!1,errorMessage:G.message})}),new rZ(`Started connecting to Amp web interface
|
5806
5806
|
Client ID: ${Y}
|
5807
5807
|
You can now send messages from the web interface to this thread`)}catch(Z){return J.connectedClientsService.sendStatus({connected:!1,errorMessage:Z.message}),Error(`Failed to start connection: ${Z.message}`)}}}};class Lb1{commands;customRegistry;latestCustom=[];telemetrySubmitter;constructor(J=yT()){this.customRegistry=J,this._initBaseCommands(!1),this.customRegistry.commands.subscribe((Q)=>this.latestCustom=Q),this.telemetrySubmitter=new Nb1(async()=>{try{return(await d8()).settings["experimental.cli.commandTelemetry.enabled"]===!0}catch{return!1}}),v9.pipe(C0((Q)=>Q.settings["internal.modes"]),P8()).subscribe((Q)=>{this._initBaseCommands(Q??!1)})}_initBaseCommands(J){if(this.commands={...fe8},process.env.AMP_CONNECT==="1")Object.assign(this.commands,ye8);if(J)Object.assign(this.commands,he8)}async execute(J,Q,Z=[],X){this.telemetrySubmitter.submit(J).catch((G)=>{l.debug("Failed to submit command telemetry",G)});let Y=this.commands[J];if(Y)return Y.execute(Q,Z);let K=this.latestCustom.find((G)=>G.name===J),q=await Wb1(J,Z,this.customRegistry,{signal:X});if(q.success)if(K?.kind==="markdown"){Q.editorDispatch({type:"set-input",input:q.output});return}else{Q.worker.handle({type:"user:message",message:{content:[{type:"text",text:q.output}]}});return}return Error(q.error??`Command '${J}' failed`)}query(J,Q,Z){let X=J.toLowerCase(),Y=Object.values(this.commands).filter((q)=>q.name.toLowerCase().includes(X)).filter((q)=>{if(!Q||!q.isVisible)return!0;return q.isVisible(Q,Z)}),K=this.latestCustom.filter((q)=>q.available&&q.name.toLowerCase().includes(X)).map((q)=>({name:q.name,description:"Custom command",requiresArgs:q.kind==="executable",execute:(G,z)=>this.execute(q.name,G,z??[])}));return[...Y,...K]}async cleanup(){await this.telemetrySubmitter.dispose()}get(J){let Q=this.commands[J];if(Q)return Q;let Z=this.latestCustom.find((X)=>X.name===J);return{name:J,description:"Custom command",requiresArgs:Z?.kind==="executable",execute:(X,Y)=>this.execute(J,X,Y??[])}}}var fe8={"generate-agent-file":{name:"generate-agent-file",description:`Generate an ${t5} file in the current workspace`,execute:async(J,Q)=>{J.worker.handle({type:"user:message",message:{content:[{type:"text",text:qX0}]}});return}},compact:{name:"compact",description:"Compact the thread. Optional: /compact [message] to queue a message after compaction",execute:async(J,Q)=>{if(J.thread.messages.length===0)return new D41;if(Q&&Q.length>0){let X=[{type:"text",text:Q.join(" ").trim()}],Y=J.takeImageAttachments?.()??[];if(Y.length>0)X.push(...Y);J.worker.handle({type:"user:message-queue:enqueue",message:{content:X}})}try{await J.worker.summarizeThread()}catch(Z){return Z instanceof Error?Z:Error("Failed to compact thread")}}},editor:{name:"editor",description:"Open $EDITOR to write a prompt",launchesWindow:!0,execute:async(J,Q)=>{try{let Z=process.env.EDITOR||process.env.VISUAL||"nano",X=await _e8(x76.join(ke8(),"amp-edit-")),Y=x76.join(X,"message.amp.md");b76(`${Z} "${Y}"`,{stdio:"inherit"}),process.stdout.write("\x1B[?25l");try{let q=(await be8(Y,"utf-8")).trim();if(q)J.editorDispatch({type:"set-input",input:q})}catch(K){if(K?.code==="ENOENT")return;return l.error("Failed to read temporary file",K),Error("Failed to read editor content")}try{await xe8(Y),await ve8(X)}catch(K){l.warn("Failed to clean up temporary file",K)}return}catch(Z){return l.error("Failed to open editor",Z),Error("Failed to open editor")}}},help:{name:"help",description:"Show help and hotkeys",execute:async(J,Q)=>{J.openHelp();return}},permissions:{name:"permissions",description:"Edit permission rules in $EDITOR, or `/permissions off|on` to toggle for this session",launchesWindow:!0,execute:async(J,Q)=>{if(Q&&Q.length>0){let Y=Q[0]?.trim().toLowerCase();switch(Y){case"on":try{return $H("dangerouslyAllowAll",!1),new rZ("Amp is now following permissions rules for this session")}catch(K){return l.error("Failed to set dangerously allow all setting",K),Error("Failed to enable permissions for this session")}case"off":try{return $H("dangerouslyAllowAll",!0),new rZ("Permissions disabled for this session - you will NOT be asked for confirmation before Amp runs a command.")}catch(K){return l.error("Failed to set dangerously allow all setting",K),Error("Failed to disable permissions for this session")}case"edit":break;default:return Error(`Invalid option: ${Y}. Use: on, off, or edit (or no argument for edit)`)}}let Z=await XT();if(Z===null)return Error("No editor found, please set $EDITOR to edit permissions");let X="";try{let Y={stdin:process.stdin,stdout:process.stdout,stderr:{write:(K)=>{return X=K.toString(),!0}},exit:(K)=>{if(K!==0)throw l.error("editPermissions exited with status",K),Error(X)},settingsFile:J.settingsFilePath,resolveEditor:XT};await U41(Y);return}catch(Y){l.error("failed to open permissions editor:",Y);let K=Y instanceof Error?`: ${Y.message}`:"";return Error(`Failed to open ${Z}${K}`)}finally{process.stdout.write("\x1B[?25l")}}},new:{name:"new",description:"Start a new thread",execute:async(J,Q)=>{try{await J.startNewThread();return}catch(Z){return l.error("Failed to start new thread",Z),Error("Failed to start new thread")}},isVisible:(J)=>J.messages.length!==0},continue:{name:"continue",description:"Continue an existing thread",requiresArgs:!1,requiresPicker:!0,execute:async(J,Q)=>{try{if(Q&&Q.length>0){let Z=Q[0]?.trim();if(!Z)return Error("Invalid thread ID provided");return await J.switchToThread(Z),new rZ(`Switched to existing thread: ${Z}`)}await J.pickAndContinueThread();return}catch(Z){return l.error("Failed to continue thread",Z),Error("Failed to continue thread")}}},queue:{name:"queue",description:"Queue a message to send when inference completes. If no inference running, sends immediately.",requiresArgs:!0,execute:async(J,Q)=>{if(!Q||Q.length===0)return Error("Queue command requires a message argument. Usage: /queue <message>");let X=[{type:"text",text:Q.join(" ").trim()}],Y=J.takeImageAttachments?.()??[];if(Y.length>0)X.push(...Y);J.worker.handle({type:"user:message-queue:enqueue",message:{content:X}})}},dequeue:{name:"dequeue",description:"Dequeue all messages and restore them to the prompt editor",execute:async(J,Q)=>{let Z=J.thread.queuedMessages??[];if(Z.length===0)return;let Y=Z.map((K)=>{return K.queuedMessage.content.filter((G)=>G.type==="text").map((G)=>G.text).join("").trim()}).filter(Boolean).join(`
|
5808
5808
|
`).trim();await J.worker.handle({type:"user:message-queue:discard"}),J.editorDispatch({type:"set-input",input:Y})},isVisible:(J)=>(J.queuedMessages?.length??0)>0},share:{name:"share",description:"Set thread visibility - `/share private|workspace|group|public`",execute:async(J,Q)=>{let{thread:Z,threadSyncService:X,ampURL:Y}=J;if(!Q||Q.length===0)return Error("Please specify a visibility option: private, workspace, group, or public");let K=Nv(new URL(Y),Z.id).toString(),G=`Thread URL: ${tM(K,K,{fallback:()=>K})}`,z=Q[0]?.trim().toLowerCase(),U;switch(z){case"private":U={visibility:"private",sharedGroupIDs:[]};break;case"workspace":U={visibility:"thread_workspace_shared"};break;case"group":U={visibility:"private",sharedGroupIDs:[],shareWithAllCreatorGroups:!0};break;case"public":U={visibility:"public"};break;default:return Error(`Invalid visibility option: ${z}. Use: private, workspace, group, or public`)}try{return await X.updateThreadMeta(Z.id,U),new rZ(`${G}
|
@@ -5990,7 +5990,7 @@ ${Q}`),this.textController.clear(),this.textController.insertText(this.pendingTr
|
|
5990
5990
|
`),J.stdout.write(`Thread: ${F}
|
5991
5991
|
`),J.stdout.write(`Continue this thread with: amp threads continue ${U}
|
5992
5992
|
`)}}function L49(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 h1.index(Z[X])}gb1();if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){s2.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
|
5993
|
-
`)}var ff1=yf1.join(Bu1||yf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function w49(J){process.emitWarning=function(Q,Z,X,Y){let K=typeof Q==="string"?Q:Q.message||String(Q),q=Z||"Warning",G=!1;J.warn(K,{name:q,code:X})}}function BV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")$H("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new N2("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${e6.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")$H("experimental.agentMode",Q.agentMode)}var I49=P0.union([P0.object({command:P0.string(),args:P0.array(P0.string()).optional(),env:P0.record(P0.string(),P0.string()).optional()}).strict(),P0.object({url:P0.string()}).strict()]),E49=P0.record(P0.string(),I49);async function gf1(J){try{await O49(yf1.dirname(ff1),{recursive:!0}),await j49(ff1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function $49(){try{return(await NX6(ff1,"utf-8")).trim()}catch(J){return null}}async function P49(J){let Q;try{Q=JSON.parse(J)}catch(Z){throw Error(`Failed to parse --mcp-config as JSON: ${Z instanceof Error?Z.message:String(Z)}`)}try{return E49.parse(Q)}catch(Z){if(Z instanceof P0.ZodError){let X=Z.issues.map((Y)=>`${Y.path.join(".")}: ${Y.message}`).join(", ");throw Error(`Invalid MCP server configuration: ${X}`)}throw Error(`Failed to validate MCP server configuration: ${String(Z)}`)}}function T49(J,Q){return{...J,async get(Z){if(Z==="mcpServers"){let X=await J.get(Z)||{},Y={};if(typeof X==="object")for(let[K,q]of Object.entries(X))Y[K]={...q,_target:"global"};for(let[K,q]of Object.entries(Q))Y[K]={...q,_target:"workspace"};return Y}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 DX6=[{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??KG,description:`Custom settings file path (overrides the default location ${KG})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(l).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${O_1})`},{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:qG(),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:e_1(),hidden:!0,description:(J)=>J?"Enable IDE connection. 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:Uj}],MX6=(J)=>("deprecated"in J)&&J.deprecated===!0,C49=(J)=>("hidden"in J)&&J.hidden===!0,S49=(J)=>("default"in J),v49=(J)=>("default"in J)?J.default:void 0;function k49(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((G)=>Z.includes(G)||G.includes(Z)),q="Run amp --help for a list of available commands.";if(K.length>0)q=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new N2(OK.unknownCommand(Z),1,q)}}var LX6=null;function Cv2(){return LX6}function p71(J){return{...J,getThreadEnvironment:x21,vfs:rt1({os:J.fileSystem}),fileChangeTrackerStorage:new Av(J.fileSystem),generateThreadTitle:pa,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var mf1=b0.file(R49.homedir()),AX6=process.env.XDG_CONFIG_HOME?b0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(mf1,".config");async function DV(J,Q){jd1("0.0.
|
5993
|
+
`)}var ff1=yf1.join(Bu1||yf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function w49(J){process.emitWarning=function(Q,Z,X,Y){let K=typeof Q==="string"?Q:Q.message||String(Q),q=Z||"Warning",G=!1;J.warn(K,{name:q,code:X})}}function BV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")$H("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new N2("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${e6.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")$H("experimental.agentMode",Q.agentMode)}var I49=P0.union([P0.object({command:P0.string(),args:P0.array(P0.string()).optional(),env:P0.record(P0.string(),P0.string()).optional()}).strict(),P0.object({url:P0.string()}).strict()]),E49=P0.record(P0.string(),I49);async function gf1(J){try{await O49(yf1.dirname(ff1),{recursive:!0}),await j49(ff1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function $49(){try{return(await NX6(ff1,"utf-8")).trim()}catch(J){return null}}async function P49(J){let Q;try{Q=JSON.parse(J)}catch(Z){throw Error(`Failed to parse --mcp-config as JSON: ${Z instanceof Error?Z.message:String(Z)}`)}try{return E49.parse(Q)}catch(Z){if(Z instanceof P0.ZodError){let X=Z.issues.map((Y)=>`${Y.path.join(".")}: ${Y.message}`).join(", ");throw Error(`Invalid MCP server configuration: ${X}`)}throw Error(`Failed to validate MCP server configuration: ${String(Z)}`)}}function T49(J,Q){return{...J,async get(Z){if(Z==="mcpServers"){let X=await J.get(Z)||{},Y={};if(typeof X==="object")for(let[K,q]of Object.entries(X))Y[K]={...q,_target:"global"};for(let[K,q]of Object.entries(Q))Y[K]={...q,_target:"workspace"};return Y}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 DX6=[{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??KG,description:`Custom settings file path (overrides the default location ${KG})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(l).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${O_1})`},{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:qG(),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:e_1(),hidden:!0,description:(J)=>J?"Enable IDE connection. 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:Uj}],MX6=(J)=>("deprecated"in J)&&J.deprecated===!0,C49=(J)=>("hidden"in J)&&J.hidden===!0,S49=(J)=>("default"in J),v49=(J)=>("default"in J)?J.default:void 0;function k49(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((G)=>Z.includes(G)||G.includes(Z)),q="Run amp --help for a list of available commands.";if(K.length>0)q=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new N2(OK.unknownCommand(Z),1,q)}}var LX6=null;function Cv2(){return LX6}function p71(J){return{...J,getThreadEnvironment:x21,vfs:rt1({os:J.fileSystem}),fileChangeTrackerStorage:new Av(J.fileSystem),generateThreadTitle:pa,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var mf1=b0.file(R49.homedir()),AX6=process.env.XDG_CONFIG_HOME?b0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(mf1,".config");async function DV(J,Q){jd1("0.0.1759507289-g3e67fa");let Z=cJ1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:J0.of([b0.file(process.cwd())]),defaultAmpURL:J.ampURL,defaultCacheDirectory:A_1,homeDir:mf1,userConfigDir:AX6}),X=await d8();l.debug("Global configuration initialized",{hasCacheDirectory:!!X.settings.cacheDirectory,settingsKeys:Object.keys(X.settings)});let Y=Vl(Kj()),K=Ct1({configService:Z,toolService:Y}),q=H30(Y,b9,lo).catch((L)=>{l.warn("Toolbox registration failed, continuing anyway:",L)}),G=K.initialized.catch((L)=>{l.warn("MCP service initialization failed, continuing anyway:",L)});if(J.executeMode)await Promise.all([G,q]);if(Q.jetbrains)Rd1(!0);if(Q.ide&&e_1())wd1(!0);if(F16(Y),Q.jetbrains)Y.registerTool(Bn);else if(Q.ide)Y.registerTool(YY0);let z;if(!J.executeMode)z=new r21(process.cwd(),{},!0);else z=new class extends r21{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(g2.write(`No API key found. Starting login flow...
|
5994
5994
|
`),!await _49(J))await aA(),process.exit(1)}let U=await Ke1({isDevelopment:!1}),W=new oz1(U),F=new rz1(U,{lazy:!0}),H=new pB1(W),B=Q.notifications!==void 0?Q.notifications:!J.executeMode,M=B16({playNotificationSound:async(L)=>{if(B){H16(L);let A=fb1(),O=hb1();if((!A||O)&&X.settings["notifications.system.enabled"]!==!1){if(L==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(L==="requires-user-input")process.stdout.write("\x1B]777;notify;Amp;Waiting for approval\x1B\\")}}},windowFocused:()=>Promise.resolve(!1),threadService:W});l.info("Starting Amp background services");let V=BX0({threadService:W,threadHistoryService:F,isExtensionDevelopment:!1}),N={configService:Z,toolService:Y,mcpService:K,threadService:W,threadHistoryService:F,threadSummaryService:H,threadSyncService:V,threadStorage:U,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:z,notificationService:M,fileSystem:Q.jetbrains||Q.ide?it1:b9};return{...N,async asyncDispose(){await N.mcpService.dispose(),await N.threadService.asyncDispose(),N.configService.unsubscribe(),N.toolService.dispose(),N.fuzzyServer.dispose(),N.threadSyncService.dispose(),N.settingsStorage[Symbol.dispose]()}}}async function _49(J){if(!J.executeMode){if(!await qb1("Would you like to log in to Amp? [(y)es, (n)o]: "))return g2.write(`Login cancelled. Run the command again to retry.
|
5995
5995
|
`),!1}return await OX6(J)}async function OX6(J){let Q=A49(32).toString("hex"),Z=await Kb1(J.ampURL,Q);try{await ZT(Z)}catch(Y){l.error("Failed to open browser",{error:Y})}let X=await Kb1(J.ampURL,Q,!1);g2.write(`If your browser did not open automatically, visit:
|
5996
5996
|
|
@@ -6000,12 +6000,12 @@ ${e6.blue.bold(X)}
|
|
6000
6000
|
Login successful! You can now use the Amp CLI.
|
6001
6001
|
`),!0}catch(Y){return l.error("Login failed",{error:Y}),s2.write(`
|
6002
6002
|
Login failed: ${Y instanceof Error?Y.message:String(Y)}
|
6003
|
-
`),!1}}function b49(){let J=new Rg().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((F)=>{if(F.code==="commander.help"||F.code==="commander.version"||F.exitCode===0)rA(),process.exit(0);let H=F.originalError??F;M26(H)}),J.option("-V, --version","output the version number",()=>{g2.write(`0.0.
|
6004
|
-
`),process.exit(0)}),J.addHelpText("after",V46()),J.configureHelp({formatHelp:N46}),J.command("logout").description("Log out by removing stored API key").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await h49(M)}),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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await f49(M,await a_1(B,M.settings))});let Q=async(F,H,B)=>{cJ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:J0.of([b0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:mf1,userConfigDir:AX6});let M={...H,executeMode:!1};await hf1(M,{...F,startWithPicker:!0},B)},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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await VX6(B,M,H)});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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await l49(B,M,H)}),Z.command("continue [threadId]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. If no thread ID is provided, the most recently used thread will be continued.").option("--pick","Pick a thread interactively from a list").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);if(H.pick)await Q(M,V,B);else await c49(M,V,F,B)}),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(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);await d49(M,V,F,B)}),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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await VX6(B,M,H)}),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(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);await p49(M,V,F,B,H.support)}),Z.command("compact <threadId>").alias("co").summary("Compact a thread").description("Compact a thread by creating a summary of the conversation history. This reduces the thread size while preserving the key information and context, making it more token efficient for future use.").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);await u49(M,V,F,B)}),D76(J,async(F,H)=>{let B=await eX(H);BV(F,H);let M=await DV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:rA,asyncDispose:M.asyncDispose.bind(M)}}),p46(J),x46(J,async(F)=>{return(await eX(F)).settings}),J.command("connect").description("Connect CLI to web interface for multi-thread management").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);BV(H,B);let V=await DV(M,B);try{await S_1(V,{})}finally{await V.asyncDispose(),await rA()}});let X=new Rg().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(F)=>{await Qb1(F.force||!1,F.verbose||!1,"0.0.
|
6003
|
+
`),!1}}function b49(){let J=new Rg().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((F)=>{if(F.code==="commander.help"||F.code==="commander.version"||F.exitCode===0)rA(),process.exit(0);let H=F.originalError??F;M26(H)}),J.option("-V, --version","output the version number",()=>{g2.write(`0.0.1759507289-g3e67fa (released 2025-10-03T16:07:45.376Z)
|
6004
|
+
`),process.exit(0)}),J.addHelpText("after",V46()),J.configureHelp({formatHelp:N46}),J.command("logout").description("Log out by removing stored API key").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await h49(M)}),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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await f49(M,await a_1(B,M.settings))});let Q=async(F,H,B)=>{cJ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:J0.of([b0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:mf1,userConfigDir:AX6});let M={...H,executeMode:!1};await hf1(M,{...F,startWithPicker:!0},B)},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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await VX6(B,M,H)});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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await l49(B,M,H)}),Z.command("continue [threadId]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. If no thread ID is provided, the most recently used thread will be continued.").option("--pick","Pick a thread interactively from a list").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);if(H.pick)await Q(M,V,B);else await c49(M,V,F,B)}),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(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);await d49(M,V,F,B)}),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(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);await VX6(B,M,H)}),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(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);await p49(M,V,F,B,H.support)}),Z.command("compact <threadId>").alias("co").summary("Compact a thread").description("Compact a thread by creating a summary of the conversation history. This reduces the thread size while preserving the key information and context, making it more token efficient for future use.").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await eX(M);await u49(M,V,F,B)}),D76(J,async(F,H)=>{let B=await eX(H);BV(F,H);let M=await DV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:rA,asyncDispose:M.asyncDispose.bind(M)}}),p46(J),x46(J,async(F)=>{return(await eX(F)).settings}),J.command("connect").description("Connect CLI to web interface for multi-thread management").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await eX(B);BV(H,B);let V=await DV(M,B);try{await S_1(V,{})}finally{await V.asyncDispose(),await rA()}});let X=new Rg().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(F)=>{await Qb1(F.force||!1,F.verbose||!1,"0.0.1759507289-g3e67fa"),process.exit()});J.addCommand(X,{hidden:!0});function Y(F,H,B){let V=typeof F.description==="string"?F.description:B===void 0?F.description(!0):F.description(B),N=new mM(H,V),L=v49(F);if(L)N.default(L);if(N.hidden=C49(F)||MX6(F),"choices"in F)N.choices([...F.choices]);return N}for(let F of DX6)switch(F.type){case"flag":{J.addOption(Y(F,`--${F.long}`)),J.addOption(Y(F,`--no-${F.long}`,!1));break}case"switch":{J.addOption(Y(F,`--${F.long}`,!0));break}default:{J.addOption(Y(F,`--${F.long} <value>`));break}}let K=new mM("-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);if(J.addOption(K),process.env.AMP_CLI_REMOTE){let F=new mM("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1);J.addOption(F)}let q=new mM("--stream-json","When used with --execute, output in Claude Code compatible stream JSON format instead of plain text.").default(!1).hideHelp(!0);J.addOption(q);let G=new mM("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1).hideHelp(!0);J.addOption(G);let z=new mM("--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 F=new mM("--client-id <clientId>","Override the client ID for connect functionality (default: amp-<pid>@<hostname>)");J.addOption(F)}J.action(async(F,H)=>{let B=F,M=await eX(B);if(Object.keys(B).forEach((V)=>{let N=DX6.find((L)=>L.name===V);if(N&&MX6(N)&&!S49(N))s2.write(e6.yellow(`Warning: '--${V}' flag is deprecated
|
6005
6005
|
`))}),H.args.length>0)k49(M,H);await hf1(M,B,H)});let U=new Rg("doctor").summary("Generate support bundle").description("Generate a support bundle for troubleshooting issues. This collects logs, configuration, and system information into a file that can be shared with Amp support for debugging.").option("--output-dir <path>","Directory to save the support bundle",process.cwd()).option("--include-full-logs","Include full log history",!1).allowUnknownOption(!1).action(async(F)=>{await m49(F.outputDir,F.includeFullLogs)});J.addCommand(U);let W=new Rg("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(F)=>{await g49(F.version)});return J.addCommand(W),J}async function u71(J,Q){let{thread:Z,visibility:X}=Q,Y=Z?.id??xK(),K=p71(J);if(Z)await J.threadStorage.set(Y,Z);let q=await TJ.getOrCreateForThread(K,Y);if(X)await J.threadSyncService.updateThreadMeta(Y,G41(X));let G=J.threadService.observe(Y).subscribe(async(z)=>{if(Z7(z,"assistant"))await gf1(Y),G.unsubscribe()});return await q.resume(),q}async function hf1(J,Q,Z){let X=process.stdin,Y=q41(Q);if(Y instanceof Error)sZ(Y.message);let K,q=null;if(Q.streamJsonInput)K="";else if(typeof Q.execute==="string"){K=Q.execute;let j=(await Gb1()).trimEnd();if(j)q=j}else K=(await Gb1()).trimEnd();if(Q.remote&&!J.executeMode)throw new N2("The -r/--remote flag currently only works with --execute mode",1,'Use: amp --remote --execute "your message"');if(Q.streamJson&&!J.executeMode)throw new N2("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new N2("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!Q.streamJson)throw new N2("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.stats&&!J.executeMode)throw new N2("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 N2("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&&K===""&&!Q.streamJsonInput)throw new N2("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"
|
6006
6006
|
Or pipe via stdin: echo "your message" | amp --execute`);if(K!==""&&!J.executeMode&&!J.streamJsonMode&&typeof Q.execute!=="string")X=await n46();BV(Z,Q);let G=await DV(J,Q);LX6=G;let z=p71(G),U=async(j)=>{let R=await NX6(j,"utf-8"),I=JSON.parse(R);if(!CU(I.id))throw new N2(OK.invalidThreadId);return u71(G,{visibility:Y,thread:I})},W=async(j)=>{if(!CU(j))throw new N2(OK.invalidThreadId);let R=await G.threadService.get(j)??void 0;return u71(G,{visibility:Y,thread:R})},F=async()=>{try{if(Q.threadId)return W(Q.threadId);else return u71(G,{visibility:Y})}catch(j){if(j instanceof N2)throw j;throw await u21(j,Q.threadId),Error("handleError should have called process.exit()")}},H=async()=>{return u71(G,{visibility:Y})};if(Q.format==="jsonl")s2.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
|
6007
|
-
`),await aA(),process.exit(1);if(J.executeMode&&Q.remote)await d46(K,q),await G.asyncDispose(),process.exit(0);let B=await F();if(J.executeMode)await $26(B,B.threadID,K,q,G,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await G.asyncDispose(),process.exit(0);let M=!1,V=!1;if(Q.jetbrains||Q.ide){await cl1();let j=await wj({jetbrainsOnly:Q.jetbrains});if(j.length===0)if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall");else l5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(j.length===1){let R=j[0];if(R)l5.selectConfig(R)}else M=!0}let N=Xb1("0.0.
|
6008
|
-
`);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=!1,X=process.stdout.isTTY&&process.stderr.isTTY,Y=NU({...J,getHook:process.env.AMP_URL?(G,z)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return z()}:void 0});if(await l46(Y),await i46(Y),J.mcpConfig){let G=await P49(J.mcpConfig);Y=T49(Y,G)}let K=await Y.get("url","global");if(!K)K=aQ;if(!IH(K))l.info("Targeting custom Amp server",{ampURL:K});if(Y=xu1(Y),await Y.get("debug.httpLogging"))ku1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:K,settings:Y,secrets:c46(await a_1(J,Y))}}function x49(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,(G,z)=>z.toUpperCase()),q=J[Z+1];if(q&&!q.startsWith("--"))Q[K]=q,Z++}}return Q}async function y49(){let J=x49(process.argv);if(o96({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),w49(l),l.info("Starting Amp CLI.",{version:"0.0.
|
6007
|
+
`),await aA(),process.exit(1);if(J.executeMode&&Q.remote)await d46(K,q),await G.asyncDispose(),process.exit(0);let B=await F();if(J.executeMode)await $26(B,B.threadID,K,q,G,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await G.asyncDispose(),process.exit(0);let M=!1,V=!1;if(Q.jetbrains||Q.ide){await cl1();let j=await wj({jetbrainsOnly:Q.jetbrains});if(j.length===0)if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall");else l5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(j.length===1){let R=j[0];if(R)l5.selectConfig(R)}else M=!0}let N=Xb1("0.0.1759507289-g3e67fa",G.settingsStorage),L=J0.of([b0.file(process.cwd())]),A=yT(void 0,L);if(K)B.handle({type:"user:message",message:{content:[{type:"text",text:K}]}});let O=await d8();await BX6({stdin:X,stdout:process.stdout,history:new b_1,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadSyncService:G.threadSyncService,threadID:B.threadID,worker:B,workerDeps:z,configService:G.configService,internalAPIClient:KZ,ampURL:J.ampURL,useGpt5:O.settings.gpt5??!1,startNewThread:H,pickAndContinueThread:async()=>{l.info("Thread picker requested - not yet implemented in TUI")},switchToThread:W,ideClient:l5,connectedClientsService:new qp,commandRegistry:A,showJetBrainsInstaller:V,showIdePicker:M,startWithPicker:Q.startWithPicker,updateService:N,debugWidgetTree:Q.debugWidgetTree,jetbrainsMode:Q.jetbrains,clientId:Q.clientId}),await G.asyncDispose(),process.exit(0)}async function eX(J){if(J.interactive)s2.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
|
6008
|
+
`);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=!1,X=process.stdout.isTTY&&process.stderr.isTTY,Y=NU({...J,getHook:process.env.AMP_URL?(G,z)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return z()}:void 0});if(await l46(Y),await i46(Y),J.mcpConfig){let G=await P49(J.mcpConfig);Y=T49(Y,G)}let K=await Y.get("url","global");if(!K)K=aQ;if(!IH(K))l.info("Targeting custom Amp server",{ampURL:K});if(Y=xu1(Y),await Y.get("debug.httpLogging"))ku1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:K,settings:Y,secrets:c46(await a_1(J,Y))}}function x49(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,(G,z)=>z.toUpperCase()),q=J[Z+1];if(q&&!q.startsWith("--"))Q[K]=q,Z++}}return Q}async function y49(){let J=x49(process.argv);if(o96({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),w49(l),l.info("Starting Amp CLI.",{version:"0.0.1759507289-g3e67fa",buildTimestamp:"2025-10-03T16:07:45.376Z",buildType:"'release'"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new N2(OK.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await b49().parseAsync(process.argv)}y49().catch(u21);async function f49(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),g2.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
|
6009
6009
|
`);else if(!IH(J.ampURL))g2.write(`Logging in to ${new URL(J.ampURL).hostname}
|
6010
6010
|
`);let Z=process.env.AMP_API_KEY;if(Z)g2.write(`API key found in environment variable, storing...
|
6011
6011
|
`),await Q.set("apiKey",Z,J.ampURL),g2.write(`API key successfully stored.
|
@@ -6021,7 +6021,7 @@ Or pipe via stdin: echo "your message" | amp --execute`);if(K!==""&&!J.executeMo
|
|
6021
6021
|
`));try{let Q;if(J)Q=J,s2.write(e6.blue(`Updating to version ${J}...
|
6022
6022
|
`)),await JT(J),s2.write(e6.green(`✓ Successfully updated to version ${J}
|
6023
6023
|
`));else{s2.write(e6.blue(`Checking for updates...
|
6024
|
-
`));let{hasUpdate:X,latestVersion:Y}=await DR("0.0.
|
6024
|
+
`));let{hasUpdate:X,latestVersion:Y}=await DR("0.0.1759507289-g3e67fa");if(!X)s2.write(e6.green(`✓ Amp CLI is already up to date.
|
6025
6025
|
`)),process.exit(0);if(!Y)s2.write(e6.yellow("[WARN] could not find latest version")),process.exit(0);Q=Y,s2.write(e6.blue(`Updating to version ${Y}...
|
6026
6026
|
`)),await JT(Y),s2.write(e6.green(`✓ Successfully updated to version ${Y}
|
6027
6027
|
`))}let Z=await JO(Q);if(Z.warning)s2.write(`
|
package/package.json
CHANGED