@sourcegraph/amp 0.0.1759907290-g30f449 → 0.0.1759910516-g30f449
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
@@ -5804,7 +5804,7 @@ See https://ampcode.com/manual#toolboxes`);return Q[0]||nw}function E56(J,Q){let
|
|
5804
5804
|
`);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(j56()){let F=[];for await(let H of process.stdin)F.push(H);W=Buffer.concat(F).toString("utf-8").trim()}await R56({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)})}F0();r$();j2();import{homedir as QQ9}from"node:os";import Ou from"node:path";fj();u4();ON();E2();j3();s6();k0();function I56(J){let Q=J.trim();if(Q==="quit"||Q==="exit")return"/quit";return J}F0();ON();import R69 from"node:fs";import P56 from"node:path";function T56(J){let Q=J.trim().replace(/^["']|["']$/g,"");if(Q=Q.replace(/\\(.)/g,"$1"),!/\.(png|jpe?g|gif|webp)$/i.test(Q))return null;if(!P56.isAbsolute(Q))return null;return l.debug("Extracted image path",{original:J,extracted:Q}),Q}function C56(J){try{let Q=P56.extname(J).toLowerCase(),Z=gs1(Q);if(!Z)return l.warn("Unsupported image file extension",{ext:Q}),null;try{let X=R69.readFileSync(J);return O69(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 O69(J,Q){if(J.length>GO)return l.warn(`Image file too large: ${J.length} bytes (max: ${GO})`),null;return{type:"image",source:{type:"base64",data:J.toString("base64"),mediaType:Q}}}import{execSync as l56}from"node:child_process";import{rmdir as z89}from"node:fs/promises";import{tmpdir as U89}from"node:os";import i56 from"node:path";KO();F0();import{spawn as j69}from"node:child_process";import{promises as $69}from"node:fs";function S56(J){return J.kind==="executable"}function v56(J){return J.kind==="markdown"}var BH=50000,k56=300000;async function yx1(J,Q,Z,X={}){let{timeoutMs:Y=k56,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}),v56(q))return await E69(q,Q);else if(S56(q))return await I69(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 E69(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Z=await $69.readFile(J.filePath,"utf8");return{success:!0,output:(Z.length>BH?Z.slice(0,BH)+`
|
5805
5805
|
... (output truncated at ${BH} characters)`:Z).trim(),exitCode:0}}catch(Z){return{success:!1,output:"",error:Z instanceof Error?Z.message:"Failed to read markdown file"}}}async function I69(J,Q,Z=k56,X){return new Promise((Y)=>{let[K,q]=P69(J,Q);l.debug("Spawning command",{spawnCommand:K,spawnArgs:q.slice(0,10),filePath:J.filePath,timeoutMs:Z});let G=bs1(X),z=!1,U=setTimeout(()=>{z=!0,G.abort(),l.warn("Command execution timed out",{commandName:J.name,timeoutMs:Z})},Z),W=j69(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<=BH)F.push(V);else{let N=BH-(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<=BH)H.push(V);else{let N=BH-(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?`
|
5806
5806
|
${L}`:L;if(B>BH)A+=`
|
5807
|
-
... (output truncated at ${BH} 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 P69(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return C69(Z,X?[...X]:null,Y,Q);else return T69(Z,X?[...X]:null,Y,Q)}function T69(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function C69(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]}}F0();r$();j2();fj();u4();rV();aK();iB();s6();k0();import{mkdtemp as W89,readFile as F89,unlink as H89,writeFile as KU2}from"fs/promises";var S41={};L6(S41,{scrollUp:()=>r69,scrollDown:()=>s69,link:()=>Z89,image:()=>X89,iTerm:()=>Y89,exitAlternativeScreen:()=>J89,eraseUp:()=>n69,eraseStartLine:()=>i69,eraseScreen:()=>fx1,eraseLines:()=>c69,eraseLine:()=>y56,eraseEndLine:()=>l69,eraseDown:()=>a69,enterAlternativeScreen:()=>e69,cursorUp:()=>x56,cursorTo:()=>k69,cursorShow:()=>d69,cursorSavePosition:()=>f69,cursorRestorePosition:()=>h69,cursorPrevLine:()=>u69,cursorNextLine:()=>m69,cursorMove:()=>_69,cursorLeft:()=>b56,cursorHide:()=>p69,cursorGetPosition:()=>g69,cursorForward:()=>b69,cursorDown:()=>x69,cursorBackward:()=>y69,clearTerminal:()=>t69,clearScreen:()=>o69,beep:()=>Q89});import hx1 from"node:process";var C41=globalThis.window?.document!==void 0,Fz2=globalThis.process?.versions?.node!==void 0,Hz2=globalThis.process?.versions?.bun!==void 0,Bz2=globalThis.Deno?.version?.deno!==void 0,Dz2=globalThis.process?.versions?.electron!==void 0,Mz2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,Vz2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Nz2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,Lz2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,Az2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Tm=globalThis.navigator?.userAgentData?.platform,wz2=Tm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",Rz2=Tm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",Oz2=Tm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",jz2=Tm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),$z2=Tm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var z2="\x1B[",Sm="\x1B]",jT="\x07",Cm=";",_56=!C41&&hx1.env.TERM_PROGRAM==="Apple_Terminal",S69=!C41&&hx1.platform==="win32",v69=C41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:hx1.cwd,k69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return z2+(J+1)+"G";return z2+(Q+1)+Cm+(J+1)+"H"},_69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=z2+-J+"D";else if(J>0)Z+=z2+J+"C";if(Q<0)Z+=z2+-Q+"A";else if(Q>0)Z+=z2+Q+"B";return Z},x56=(J=1)=>z2+J+"A",x69=(J=1)=>z2+J+"B",b69=(J=1)=>z2+J+"C",y69=(J=1)=>z2+J+"D",b56=z2+"G",f69=_56?"\x1B7":z2+"s",h69=_56?"\x1B8":z2+"u",g69=z2+"6n",m69=z2+"E",u69=z2+"F",p69=z2+"?25l",d69=z2+"?25h",c69=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=y56+(Z<J-1?x56():"");if(J)Q+=b56;return Q},l69=z2+"K",i69=z2+"1K",y56=z2+"2K",a69=z2+"J",n69=z2+"1J",fx1=z2+"2J",r69=z2+"S",s69=z2+"T",o69="\x1Bc",t69=S69?`${fx1}${z2}0f`:`${fx1}${z2}3J${z2}H`,e69=z2+"?1049h",J89=z2+"?1049l",Q89=jT,Z89=(J,Q)=>[Sm,"8",Cm,Cm,Q,jT,J,Sm,"8",Cm,Cm,jT].join(""),X89=(J,Q={})=>{let Z=`${Sm}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")+jT},Y89={setCwd:(J=v69())=>`${Sm}50;CurrentDir=${J}${jT}`,annotation(J,Q={}){let Z=`${Sm}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+jT}};var v41=r6(d56(),1);function UV(J,Q,{target:Z="stdout",...X}={}){if(!v41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (${Q})`}return S41.link(J,Q)}UV.isSupported=v41.default.stdout;UV.stderr=(J,Q,Z={})=>UV(J,Q,{target:"stderr",...Z});UV.stderr.isSupported=v41.default.stderr;F0();aK();class dx1{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.
|
5807
|
+
... (output truncated at ${BH} 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 P69(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return C69(Z,X?[...X]:null,Y,Q);else return T69(Z,X?[...X]:null,Y,Q)}function T69(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function C69(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]}}F0();r$();j2();fj();u4();rV();aK();iB();s6();k0();import{mkdtemp as W89,readFile as F89,unlink as H89,writeFile as KU2}from"fs/promises";var S41={};L6(S41,{scrollUp:()=>r69,scrollDown:()=>s69,link:()=>Z89,image:()=>X89,iTerm:()=>Y89,exitAlternativeScreen:()=>J89,eraseUp:()=>n69,eraseStartLine:()=>i69,eraseScreen:()=>fx1,eraseLines:()=>c69,eraseLine:()=>y56,eraseEndLine:()=>l69,eraseDown:()=>a69,enterAlternativeScreen:()=>e69,cursorUp:()=>x56,cursorTo:()=>k69,cursorShow:()=>d69,cursorSavePosition:()=>f69,cursorRestorePosition:()=>h69,cursorPrevLine:()=>u69,cursorNextLine:()=>m69,cursorMove:()=>_69,cursorLeft:()=>b56,cursorHide:()=>p69,cursorGetPosition:()=>g69,cursorForward:()=>b69,cursorDown:()=>x69,cursorBackward:()=>y69,clearTerminal:()=>t69,clearScreen:()=>o69,beep:()=>Q89});import hx1 from"node:process";var C41=globalThis.window?.document!==void 0,Fz2=globalThis.process?.versions?.node!==void 0,Hz2=globalThis.process?.versions?.bun!==void 0,Bz2=globalThis.Deno?.version?.deno!==void 0,Dz2=globalThis.process?.versions?.electron!==void 0,Mz2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,Vz2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Nz2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,Lz2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,Az2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Tm=globalThis.navigator?.userAgentData?.platform,wz2=Tm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",Rz2=Tm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",Oz2=Tm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",jz2=Tm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),$z2=Tm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var z2="\x1B[",Sm="\x1B]",jT="\x07",Cm=";",_56=!C41&&hx1.env.TERM_PROGRAM==="Apple_Terminal",S69=!C41&&hx1.platform==="win32",v69=C41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:hx1.cwd,k69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return z2+(J+1)+"G";return z2+(Q+1)+Cm+(J+1)+"H"},_69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=z2+-J+"D";else if(J>0)Z+=z2+J+"C";if(Q<0)Z+=z2+-Q+"A";else if(Q>0)Z+=z2+Q+"B";return Z},x56=(J=1)=>z2+J+"A",x69=(J=1)=>z2+J+"B",b69=(J=1)=>z2+J+"C",y69=(J=1)=>z2+J+"D",b56=z2+"G",f69=_56?"\x1B7":z2+"s",h69=_56?"\x1B8":z2+"u",g69=z2+"6n",m69=z2+"E",u69=z2+"F",p69=z2+"?25l",d69=z2+"?25h",c69=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=y56+(Z<J-1?x56():"");if(J)Q+=b56;return Q},l69=z2+"K",i69=z2+"1K",y56=z2+"2K",a69=z2+"J",n69=z2+"1J",fx1=z2+"2J",r69=z2+"S",s69=z2+"T",o69="\x1Bc",t69=S69?`${fx1}${z2}0f`:`${fx1}${z2}3J${z2}H`,e69=z2+"?1049h",J89=z2+"?1049l",Q89=jT,Z89=(J,Q)=>[Sm,"8",Cm,Cm,Q,jT,J,Sm,"8",Cm,Cm,jT].join(""),X89=(J,Q={})=>{let Z=`${Sm}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")+jT},Y89={setCwd:(J=v69())=>`${Sm}50;CurrentDir=${J}${jT}`,annotation(J,Q={}){let Z=`${Sm}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+jT}};var v41=r6(d56(),1);function UV(J,Q,{target:Z="stdout",...X}={}){if(!v41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (${Q})`}return S41.link(J,Q)}UV.isSupported=v41.default.stdout;UV.stderr=(J,Q,Z={})=>UV(J,Q,{target:"stderr",...Z});UV.stderr.isSupported=v41.default.stderr;F0();aK();class dx1{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.1759910516-g30f449"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await be1(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}}F0();class k41 extends Error{constructor(J="Thread has no messages to compact"){super(J);this.name="NoMessagesToCompactError"}}class YQ{message;name;constructor(J){this.message=J;this.name="InformationMessage"}}function c56(J){if(J instanceof k41)return{title:"Cannot compact thread",description:"Thread has no messages to compact.",type:"error"};if(J instanceof YQ)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 WV=null,B89={connect:{name:"connect",description:"Connect CLI to web interface for current thread access",execute:async(J,Q)=>{try{if(WV)return Error("Already connected. Use /disconnect first to reconnect.");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(() => (Xx1(),I46)),q=await K({worker:J.worker},{clientId:J.clientId,onUserDisconnect:()=>{WV=null,Z.sendStatus({connected:!1,enabled:!1,errorMessage:"Disconnected by user via web interface"})}});return WV=q,q.promise.then(()=>{Z.sendStatus({connected:!0,errorMessage:void 0})}).catch((G)=>{WV=null,Z.sendStatus({connected:!1,errorMessage:G.message})}),new YQ(`Started connecting to Amp web interface
|
5808
5808
|
Client ID: ${Y}
|
5809
5809
|
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}`)}}},disconnect:{name:"disconnect",description:"Disconnect from web interface",execute:async(J,Q)=>{if(!WV)return new YQ("Not connected to Amp web interface");try{WV.disconnect();let Z=WV.clientID;return WV=null,J.connectedClientsService.sendStatus({connected:!1,enabled:!1,errorMessage:void 0}),new YQ(`Disconnected from Amp web interface
|
5810
5810
|
Client ID: ${Z}
|
@@ -5994,7 +5994,7 @@ ${Q}`),this.textController.clear(),this.textController.insertText(this.pendingTr
|
|
5994
5994
|
`),J.stdout.write(`Thread: ${H}
|
5995
5995
|
`),J.stdout.write(`Continue this thread with: amp threads continue ${W}
|
5996
5996
|
`)}}function _Y6(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 x1.index(Z[X])}Fb1();if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){t2.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
|
5997
|
-
`)}var Mh1=Dh1.join(lu1||Dh1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function GQ9(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 IV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")_U("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new A2("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${Q8.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")_U("experimental.agentMode",Q.agentMode)}var zQ9=w0.union([w0.object({command:w0.string(),args:w0.array(w0.string()).optional(),env:w0.record(w0.string(),w0.string()).optional()}).strict(),w0.object({url:w0.string()}).strict()]),UQ9=w0.record(w0.string(),zQ9);async function Nh1(J){try{await YQ9(Dh1.dirname(Mh1),{recursive:!0}),await KQ9(Mh1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function WQ9(){try{return(await mY6(Mh1,"utf-8")).trim()}catch(J){return null}}async function FQ9(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 UQ9.parse(Q)}catch(Z){if(Z instanceof w0.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 HQ9(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 fY6=[{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??B5,description:`Custom settings file path (overrides the default location ${B5})`},{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 ${i_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:WG(),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:Ex1(),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:YN}],hY6=(J)=>("deprecated"in J)&&J.deprecated===!0,BQ9=(J)=>("hidden"in J)&&J.hidden===!0,DQ9=(J)=>("default"in J),MQ9=(J)=>("default"in J)?J.default:void 0;function VQ9(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 A2($K.unknownCommand(Z),1,q)}}var uY6=null;function Ny2(){return uY6}function q51(J){return{...J,getThreadEnvironment:e21,vfs:ke1({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new hv(J.fileSystem),generateThreadTitle:LY0,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var Lh1=x0.file(qQ9.homedir()),pY6=process.env.XDG_CONFIG_HOME?x0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(Lh1,".config");async function PV(J,Q){sd1("0.0.
|
5997
|
+
`)}var Mh1=Dh1.join(lu1||Dh1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function GQ9(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 IV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")_U("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new A2("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${Q8.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")_U("experimental.agentMode",Q.agentMode)}var zQ9=w0.union([w0.object({command:w0.string(),args:w0.array(w0.string()).optional(),env:w0.record(w0.string(),w0.string()).optional()}).strict(),w0.object({url:w0.string()}).strict()]),UQ9=w0.record(w0.string(),zQ9);async function Nh1(J){try{await YQ9(Dh1.dirname(Mh1),{recursive:!0}),await KQ9(Mh1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function WQ9(){try{return(await mY6(Mh1,"utf-8")).trim()}catch(J){return null}}async function FQ9(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 UQ9.parse(Q)}catch(Z){if(Z instanceof w0.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 HQ9(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 fY6=[{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??B5,description:`Custom settings file path (overrides the default location ${B5})`},{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 ${i_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:WG(),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:Ex1(),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:YN}],hY6=(J)=>("deprecated"in J)&&J.deprecated===!0,BQ9=(J)=>("hidden"in J)&&J.hidden===!0,DQ9=(J)=>("default"in J),MQ9=(J)=>("default"in J)?J.default:void 0;function VQ9(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 A2($K.unknownCommand(Z),1,q)}}var uY6=null;function Ny2(){return uY6}function q51(J){return{...J,getThreadEnvironment:e21,vfs:ke1({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new hv(J.fileSystem),generateThreadTitle:LY0,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var Lh1=x0.file(qQ9.homedir()),pY6=process.env.XDG_CONFIG_HOME?x0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(Lh1,".config");async function PV(J,Q){sd1("0.0.1759910516-g30f449");let Z=zQ1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:J0.of([x0.file(process.cwd())]),defaultAmpURL:J.ampURL,defaultCacheDirectory:l_1,homeDir:Lh1,userConfigDir:pY6}),X=await Z9();l.debug("Global configuration initialized",{hasCacheDirectory:!!X.settings.cacheDirectory,settingsKeys:Object.keys(X.settings)});let Y=_l(AR()),K=Ke1({configService:Z,toolService:Y}),q=IL0(Y,b9,Ut).catch((N)=>{l.warn("Toolbox registration failed, continuing anyway:",N)}),G=K.initialized.catch((N)=>{l.warn("MCP service initialization failed, continuing anyway:",N)});if(J.executeMode)await Promise.all([G,q]);if(Q.jetbrains)od1(!0);if(Q.ide&&Ex1())td1(!0);if(E06(Y),Q.jetbrains||Q.ide)Y.registerTool(Tn);let z;if(!J.executeMode)z=new B41(process.cwd(),{},!0);else z=new class extends B41{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(p2.write(`No API key found. Starting login flow...
|
5998
5998
|
`),!await NQ9(J))await Ww(),process.exit(1)}let U=await me1({isDevelopment:!1}),W=new AU1(U),F=new NU1(U,{lazy:!0}),H=Q.notifications!==void 0?Q.notifications:!J.executeMode,B=P06({playNotificationSound:async(N)=>{if(H){I06(N);let L=Ub1(),A=Wb1();if((!L||A)&&X.settings["notifications.system.enabled"]!==!1){if(N==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(N==="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 M=ne1({threadService:W,threadHistoryService:F,isExtensionDevelopment:!1}),V={configService:Z,toolService:Y,mcpService:K,threadService:W,threadHistoryService:F,threadSyncService:M,threadStorage:U,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:z,notificationService:B,fileSystem:Q.jetbrains||Q.ide?Ce1:b9};return{...V,async asyncDispose(){await V.mcpService.dispose(),await V.threadService.asyncDispose(),V.configService.unsubscribe(),V.toolService.dispose(),V.fuzzyServer.dispose(),V.threadSyncService.dispose(),V.settingsStorage[Symbol.dispose]()}}}async function NQ9(J){if(!J.executeMode){if(!await kx1("Would you like to log in to Amp? [(y)es, (n)o]: "))return p2.write(`Login cancelled. Run the command again to retry.
|
5999
5999
|
`),!1}return await dY6(J)}async function dY6(J){let Q=XQ9(32).toString("hex"),Z=await vx1(J.ampURL,Q);try{await jU(Z)}catch(Y){l.error("Failed to open browser",{error:Y})}let X=await vx1(J.ampURL,Q,!1);p2.write(`If your browser did not open automatically, visit:
|
6000
6000
|
|
@@ -6004,12 +6004,12 @@ ${Q8.blue.bold(X)}
|
|
6004
6004
|
Login successful! You can now use the Amp CLI.
|
6005
6005
|
`),!0}catch(Y){return l.error("Login failed",{error:Y}),t2.write(`
|
6006
6006
|
Login failed: ${Y instanceof Error?Y.message:String(Y)}
|
6007
|
-
`),!1}}function LQ9(){let J=new hg().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)Hw(),process.exit(0);let H=F.originalError??F;C46(H)}),J.option("-V, --version","output the version number",()=>{p2.write(`0.0.
|
6008
|
-
`),process.exit(0)}),J.addHelpText("after",C76()),J.configureHelp({formatHelp:S76}),J.command("logout").description("Log out by removing stored API key").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await QY(B);await OQ9(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 QY(B);await RQ9(M,await Ax1(B,M.settings))});let Q=async(F,H,B)=>{zQ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:J0.of([x0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:Lh1,userConfigDir:pY6});let M={...H,executeMode:!1};await Vh1(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 QY(B);await gY6(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 QY(B);await CQ9(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 QY(M);if(H.pick)await Q(M,V,B);else await TQ9(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 QY(M);await PQ9(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 QY(B);await gY6(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 QY(M);await IQ9(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 QY(M);await EQ9(M,V,F,B)}),E56(J,async(F,H)=>{let B=await QY(H);IV(F,H);let M=await PV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:Hw,asyncDispose:M.asyncDispose.bind(M)}}),Q56(J),n76(J,async(F)=>{return(await QY(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 QY(B);IV(H,B);let V=await PV(M,B);try{await Zx1(V,{})}finally{await V.asyncDispose(),await Hw()}});let X=new hg().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 Px1(F.force||!1,F.verbose||!1,"0.0.
|
6007
|
+
`),!1}}function LQ9(){let J=new hg().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)Hw(),process.exit(0);let H=F.originalError??F;C46(H)}),J.option("-V, --version","output the version number",()=>{p2.write(`0.0.1759910516-g30f449 (released 2025-10-08T08:07:22.504Z)
|
6008
|
+
`),process.exit(0)}),J.addHelpText("after",C76()),J.configureHelp({formatHelp:S76}),J.command("logout").description("Log out by removing stored API key").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await QY(B);await OQ9(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 QY(B);await RQ9(M,await Ax1(B,M.settings))});let Q=async(F,H,B)=>{zQ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:J0.of([x0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:Lh1,userConfigDir:pY6});let M={...H,executeMode:!1};await Vh1(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 QY(B);await gY6(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 QY(B);await CQ9(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 QY(M);if(H.pick)await Q(M,V,B);else await TQ9(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 QY(M);await PQ9(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 QY(B);await gY6(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 QY(M);await IQ9(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 QY(M);await EQ9(M,V,F,B)}),E56(J,async(F,H)=>{let B=await QY(H);IV(F,H);let M=await PV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:Hw,asyncDispose:M.asyncDispose.bind(M)}}),Q56(J),n76(J,async(F)=>{return(await QY(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 QY(B);IV(H,B);let V=await PV(M,B);try{await Zx1(V,{})}finally{await V.asyncDispose(),await Hw()}});let X=new hg().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 Px1(F.force||!1,F.verbose||!1,"0.0.1759910516-g30f449"),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 sM(H,V),L=MQ9(F);if(L)N.default(L);if(N.hidden=BQ9(F)||hY6(F),"choices"in F)N.choices([...F.choices]);return N}for(let F of fY6)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 sM("-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 sM("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1);J.addOption(F)}let q=new sM("--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 sM("--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 sM("--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 sM("--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 QY(B);if(Object.keys(B).forEach((V)=>{let N=fY6.find((L)=>L.name===V);if(N&&hY6(N)&&!DQ9(N))t2.write(Q8.yellow(`Warning: '--${V}' flag is deprecated
|
6009
6009
|
`))}),H.args.length>0)VQ9(M,H);await Vh1(M,B,H)});let U=new hg("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 $Q9(F.outputDir,F.includeFullLogs)});J.addCommand(U);let W=new hg("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 jQ9(F.version)});return J.addCommand(W),J}async function K51(J,Q){let{thread:Z,visibility:X}=Q,Y=Z?.id??hK(),K=q51(J);if(Z)await J.threadStorage.set(Y,Z);let q=await _J.getOrCreateForThread(K,Y);if(X)await J.threadSyncService.updateThreadMeta(Y,$41(X));let G=J.threadService.observe(Y).subscribe(async(z)=>{if(R5(z,"assistant"))await Nh1(Y),G.unsubscribe()});return await q.resume(),q}async function Vh1(J,Q,Z){let X=j41(Q);if(X instanceof Error)tZ(X.message);let Y,K=null;if(Q.streamJsonInput)Y="";else if(typeof Q.execute==="string"){Y=Q.execute;let w=(await _x1()).trimEnd();if(w)K=w}else Y=(await _x1()).trimEnd();if(Q.remote&&!J.executeMode)throw new A2("The -r/--remote flag currently only works with --execute mode",1,'Use: amp --remote --execute "your message"');if(Q.streamJson&&!J.executeMode)throw new A2("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new A2("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!Q.streamJson)throw new A2("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.stats&&!J.executeMode)throw new A2("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 A2("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 A2("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"
|
6010
6010
|
Or pipe via stdin: echo "your message" | amp --execute`);IV(Z,Q);let q=await PV(J,Q);uY6=q;let G=q51(q),z=async(w)=>{let R=await mY6(w,"utf-8"),O=JSON.parse(R);if(!hU(O.id))throw new A2($K.invalidThreadId);return K51(q,{visibility:X,thread:O})},U=async(w)=>{if(!hU(w))throw new A2($K.invalidThreadId);let R=await q.threadService.get(w)??void 0;return K51(q,{visibility:X,thread:R})},W=async()=>{try{if(Q.threadId)return U(Q.threadId);else return K51(q,{visibility:X})}catch(w){if(w instanceof A2)throw w;throw await K41(w,Q.threadId),Error("handleError should have called process.exit()")}},F=async()=>{return K51(q,{visibility:X})};if(Q.format==="jsonl")t2.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
|
6011
|
-
`),await Ww(),process.exit(1);if(J.executeMode&&Q.remote)await Z56(Y,K),await q.asyncDispose(),process.exit(0);let H=await W();if(J.executeMode)await m46(H,H.threadID,Y,K,q,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await q.asyncDispose(),process.exit(0);let B=!1,M=!1;if(Q.jetbrains||Q.ide){await wi1();let w=await fR({jetbrainsOnly:Q.jetbrains});if(w.length===0)if(Q.jetbrains)M=!await q.configService.get("jetbrains.skipInstall");else j5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(w.length===1){let R=w[0];if(R)j5.selectConfig(R)}else B=!0}let V=Cx1("0.0.
|
6012
|
-
`);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=!1,X=process.stdout.isTTY&&process.stderr.isTTY,Y=await wU(J.settingsFile),K=RU({...J,settingsFile:Y,getHook:process.env.AMP_URL?(z,U)=>{if(z==="url")return Promise.resolve(process.env.AMP_URL);return U()}:void 0});if(await Y56(K),await K56(K),J.mcpConfig){let z=await FQ9(J.mcpConfig);K=HQ9(K,z)}let q=await K.get("url","global");if(!q)q=tQ;if(!yH(q))l.info("Targeting custom Amp server",{ampURL:q});if(K=Bp1(K),await K.get("debug.httpLogging"))Wp1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:q,settings:K,secrets:X56(await Ax1(J,K))}}function AQ9(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 wQ9(){let J=AQ9(process.argv);if(F46({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),GQ9(l),l.info("Starting Amp CLI.",{version:"0.0.
|
6011
|
+
`),await Ww(),process.exit(1);if(J.executeMode&&Q.remote)await Z56(Y,K),await q.asyncDispose(),process.exit(0);let H=await W();if(J.executeMode)await m46(H,H.threadID,Y,K,q,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await q.asyncDispose(),process.exit(0);let B=!1,M=!1;if(Q.jetbrains||Q.ide){await wi1();let w=await fR({jetbrainsOnly:Q.jetbrains});if(w.length===0)if(Q.jetbrains)M=!await q.configService.get("jetbrains.skipInstall");else j5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(w.length===1){let R=w[0];if(R)j5.selectConfig(R)}else B=!0}let V=Cx1("0.0.1759910516-g30f449",q.settingsStorage),N=J0.of([x0.file(process.cwd())]),L=tT(void 0,N);if(Y)H.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}});let A=await Z9();await yY6({stdout:process.stdout,history:new qx1,fuzzyServer:q.fuzzyServer,settingsStorage:q.settingsStorage,threadService:q.threadService,threadSyncService:q.threadSyncService,threadID:H.threadID,worker:H,workerDeps:G,configService:q.configService,internalAPIClient:PJ,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{l.info("Thread picker requested - not yet implemented in TUI")},switchToThread:U,ideClient:j5,connectedClientsService:new $p,commandRegistry:L,showJetBrainsInstaller:M,showIdePicker:B,startWithPicker:Q.startWithPicker,updateService:V,debugWidgetTree:Q.debugWidgetTree,jetbrainsMode:Q.jetbrains,clientId:Q.clientId}),await q.asyncDispose(),process.exit(0)}async function QY(J){if(J.interactive)t2.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
|
6012
|
+
`);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=!1,X=process.stdout.isTTY&&process.stderr.isTTY,Y=await wU(J.settingsFile),K=RU({...J,settingsFile:Y,getHook:process.env.AMP_URL?(z,U)=>{if(z==="url")return Promise.resolve(process.env.AMP_URL);return U()}:void 0});if(await Y56(K),await K56(K),J.mcpConfig){let z=await FQ9(J.mcpConfig);K=HQ9(K,z)}let q=await K.get("url","global");if(!q)q=tQ;if(!yH(q))l.info("Targeting custom Amp server",{ampURL:q});if(K=Bp1(K),await K.get("debug.httpLogging"))Wp1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:q,settings:K,secrets:X56(await Ax1(J,K))}}function AQ9(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 wQ9(){let J=AQ9(process.argv);if(F46({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),GQ9(l),l.info("Starting Amp CLI.",{version:"0.0.1759910516-g30f449",buildTimestamp:"2025-10-08T08:07:22.504Z",buildType:"'release'"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new A2($K.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await LQ9().parseAsync(process.argv)}wQ9().catch(K41);async function RQ9(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),p2.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
|
6013
6013
|
`);else if(!yH(J.ampURL))p2.write(`Logging in to ${new URL(J.ampURL).hostname}
|
6014
6014
|
`);let Z=process.env.AMP_API_KEY;if(Z)p2.write(`API key found in environment variable, storing...
|
6015
6015
|
`),await Q.set("apiKey",Z,J.ampURL),p2.write(`API key successfully stored.
|
@@ -6025,7 +6025,7 @@ Or pipe via stdin: echo "your message" | amp --execute`);IV(Z,Q);let q=await PV(
|
|
6025
6025
|
`));try{let Q;if(J)Q=J,t2.write(Q8.blue(`Updating to version ${J}...
|
6026
6026
|
`)),await AT(J),t2.write(Q8.green(`✓ Successfully updated to version ${J}
|
6027
6027
|
`));else{t2.write(Q8.blue(`Checking for updates...
|
6028
|
-
`));let{hasUpdate:X,latestVersion:Y}=await PO("0.0.
|
6028
|
+
`));let{hasUpdate:X,latestVersion:Y}=await PO("0.0.1759910516-g30f449");if(!X)t2.write(Q8.green(`✓ Amp CLI is already up to date.
|
6029
6029
|
`)),process.exit(0);if(!Y)t2.write(Q8.yellow("[WARN] could not find latest version")),process.exit(0);Q=Y,t2.write(Q8.blue(`Updating to version ${Y}...
|
6030
6030
|
`)),await AT(Y),t2.write(Q8.green(`✓ Successfully updated to version ${Y}
|
6031
6031
|
`))}let Z=await Vw(Q);if(Z.warning)t2.write(`
|
package/package.json
CHANGED