@sourcegraph/amp 0.0.1759807580-g9c9694 → 0.0.1759809746-ga795fe
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
@@ -5814,7 +5814,7 @@ See https://ampcode.com/manual#toolboxes`);return Q[0]||mO}function v76(J,Q){let
|
|
5814
5814
|
`);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),F;if(C76()){let W=[];for await(let H of process.stdin)W.push(H);F=Buffer.concat(W).toString("utf-8").trim()}await P76({toolName:X,rawArgs:U,stdinInput:F,only:Y.only,threadDeps:G,stdout:process.stdout,stderr:process.stderr,exit:(W)=>{z=W}}),await G.asyncDispose(),G.cleanupTerminal(),process.exit(z)})}W0();Pw();O2();import{homedir as r49}from"node:os";import Wu from"node:path";Ew();m4();DN();p2();D3();n6();k0();function k76(J){let Q=J.trim();if(Q==="quit"||Q==="exit")return"/quit";return J}W0();DN();import Oe8 from"node:fs";import _76 from"node:path";function b76(J){let Q=J.trim().replace(/^["']|["']$/g,"");if(Q=Q.replace(/\\(.)/g,"$1"),!/\.(png|jpe?g|gif|webp)$/i.test(Q))return null;if(!_76.isAbsolute(Q))return null;return l.debug("Extracted image path",{original:J,extracted:Q}),Q}function x76(J){try{let Q=_76.extname(J).toLowerCase(),Z=Rs1(Q);if(!Z)return l.warn("Unsupported image file extension",{ext:Q}),null;try{let X=Oe8.readFileSync(J);return je8(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 je8(J,Q){if(J.length>ej)return l.warn(`Image file too large: ${J.length} bytes (max: ${ej})`),null;return{type:"image",source:{type:"base64",data:J.toString("base64"),mediaType:Q}}}import{execSync as o76}from"node:child_process";import{rmdir as G19}from"node:fs/promises";import{tmpdir as z19}from"node:os";import t76 from"node:path";oj();W0();import{spawn as Re8}from"node:child_process";import{promises as we8}from"node:fs";function y76(J){return J.kind==="executable"}function f76(J){return J.kind==="markdown"}var YH=50000,h76=300000;async function Rb1(J,Q,Z,X={}){let{timeoutMs:Y=h76,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}),f76(q))return await Ie8(q,Q);else if(y76(q))return await Ee8(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 Ie8(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Z=await we8.readFile(J.filePath,"utf8");return{success:!0,output:(Z.length>YH?Z.slice(0,YH)+`
|
5815
5815
|
... (output truncated at ${YH} characters)`:Z).trim(),exitCode:0}}catch(Z){return{success:!1,output:"",error:Z instanceof Error?Z.message:"Failed to read markdown file"}}}async function Ee8(J,Q,Z=h76,X){return new Promise((Y)=>{let[K,q]=$e8(J,Q);l.debug("Spawning command",{spawnCommand:K,spawnArgs:q.slice(0,10),filePath:J.filePath,timeoutMs:Z});let G=Ls1(X),z=!1,U=setTimeout(()=>{z=!0,G.abort(),l.warn("Command execution timed out",{commandName:J.name,timeoutMs:Z})},Z),F=Re8(K,q,{stdio:["pipe","pipe","pipe"],signal:G.signal,detached:!0}),W=[],H=[],B=0;F.stdout?.on("data",(M)=>{let V=M.toString();if(B+=V.length,B<=YH)W.push(V);else{let N=YH-(B-V.length);if(N>0)W.push(V.slice(0,N))}}),F.stderr?.on("data",(M)=>{let V=M.toString();if(B+=V.length,B<=YH)H.push(V);else{let N=YH-(B-V.length);if(N>0)H.push(V.slice(0,N))}}),F.on("close",(M)=>{if(clearTimeout(U),z){Y({success:!1,output:W.join(""),error:`Command timed out after ${Z}ms`,exitCode:void 0});return}if(G.signal.aborted){Y({success:!1,output:W.join(""),error:"The command was aborted",exitCode:M??void 0});return}let V=M===0||M===1,N=W.join(""),L=H.join(""),A=N;if(!V&&!N.trim()&&L.trim())A=L;else if(L.trim())A+=N?`
|
5816
5816
|
${L}`:L;if(B>YH)A+=`
|
5817
|
-
... (output truncated at ${YH} characters)`;Y({success:V,output:A.trim(),error:!V?L.trim()||"Command failed":void 0,exitCode:M??void 0})}),F.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:W.join(""),error:V})})})}function $e8(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return Te8(Z,X?[...X]:null,Y,Q);else return Pe8(Z,X?[...X]:null,Y,Q)}function Pe8(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function Te8(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]}}W0();Pw();O2();Ew();m4();uV();pG();gB();n6();k0();import{mkdtemp as U19,readFile as F19,unlink as W19,writeFile as Xq2}from"fs/promises";var j41={};L6(j41,{scrollUp:()=>ne8,scrollDown:()=>re8,link:()=>Q19,image:()=>Z19,iTerm:()=>X19,exitAlternativeScreen:()=>ee8,eraseUp:()=>ae8,eraseStartLine:()=>le8,eraseScreen:()=>wb1,eraseLines:()=>de8,eraseLine:()=>p76,eraseEndLine:()=>ce8,eraseDown:()=>ie8,enterAlternativeScreen:()=>te8,cursorUp:()=>m76,cursorTo:()=>ve8,cursorShow:()=>pe8,cursorSavePosition:()=>ye8,cursorRestorePosition:()=>fe8,cursorPrevLine:()=>me8,cursorNextLine:()=>ge8,cursorMove:()=>ke8,cursorLeft:()=>u76,cursorHide:()=>ue8,cursorGetPosition:()=>he8,cursorForward:()=>be8,cursorDown:()=>_e8,cursorBackward:()=>xe8,clearTerminal:()=>oe8,clearScreen:()=>se8,beep:()=>J19});import Ib1 from"node:process";var O41=globalThis.window?.document!==void 0,UK2=globalThis.process?.versions?.node!==void 0,FK2=globalThis.process?.versions?.bun!==void 0,WK2=globalThis.Deno?.version?.deno!==void 0,HK2=globalThis.process?.versions?.electron!==void 0,BK2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,DK2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,MK2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,VK2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,NK2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Lm=globalThis.navigator?.userAgentData?.platform,LK2=Lm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",AK2=Lm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",OK2=Lm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",jK2=Lm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),RK2=Lm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var G2="\x1B[",Om="\x1B]",WT="\x07",Am=";",g76=!O41&&Ib1.env.TERM_PROGRAM==="Apple_Terminal",Ce8=!O41&&Ib1.platform==="win32",Se8=O41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:Ib1.cwd,ve8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return G2+(J+1)+"G";return G2+(Q+1)+Am+(J+1)+"H"},ke8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=G2+-J+"D";else if(J>0)Z+=G2+J+"C";if(Q<0)Z+=G2+-Q+"A";else if(Q>0)Z+=G2+Q+"B";return Z},m76=(J=1)=>G2+J+"A",_e8=(J=1)=>G2+J+"B",be8=(J=1)=>G2+J+"C",xe8=(J=1)=>G2+J+"D",u76=G2+"G",ye8=g76?"\x1B7":G2+"s",fe8=g76?"\x1B8":G2+"u",he8=G2+"6n",ge8=G2+"E",me8=G2+"F",ue8=G2+"?25l",pe8=G2+"?25h",de8=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=p76+(Z<J-1?m76():"");if(J)Q+=u76;return Q},ce8=G2+"K",le8=G2+"1K",p76=G2+"2K",ie8=G2+"J",ae8=G2+"1J",wb1=G2+"2J",ne8=G2+"S",re8=G2+"T",se8="\x1Bc",oe8=Ce8?`${wb1}${G2}0f`:`${wb1}${G2}3J${G2}H`,te8=G2+"?1049h",ee8=G2+"?1049l",J19=WT,Q19=(J,Q)=>[Om,"8",Am,Am,Q,WT,J,Om,"8",Am,Am,WT].join(""),Z19=(J,Q={})=>{let Z=`${Om}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")+WT},X19={setCwd:(J=Se8())=>`${Om}50;CurrentDir=${J}${WT}`,annotation(J,Q={}){let Z=`${Om}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+WT}};var R41=Q8(r76(),1);function XV(J,Q,{target:Z="stdout",...X}={}){if(!R41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (${Q})`}return j41.link(J,Q)}XV.isSupported=R41.default.stdout;XV.stderr=(J,Q,Z={})=>XV(J,Q,{target:"stderr",...Z});XV.stderr.isSupported=R41.default.stderr;W0();pG();class Cb1{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.
|
5817
|
+
... (output truncated at ${YH} characters)`;Y({success:V,output:A.trim(),error:!V?L.trim()||"Command failed":void 0,exitCode:M??void 0})}),F.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:W.join(""),error:V})})})}function $e8(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return Te8(Z,X?[...X]:null,Y,Q);else return Pe8(Z,X?[...X]:null,Y,Q)}function Pe8(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function Te8(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]}}W0();Pw();O2();Ew();m4();uV();pG();gB();n6();k0();import{mkdtemp as U19,readFile as F19,unlink as W19,writeFile as Xq2}from"fs/promises";var j41={};L6(j41,{scrollUp:()=>ne8,scrollDown:()=>re8,link:()=>Q19,image:()=>Z19,iTerm:()=>X19,exitAlternativeScreen:()=>ee8,eraseUp:()=>ae8,eraseStartLine:()=>le8,eraseScreen:()=>wb1,eraseLines:()=>de8,eraseLine:()=>p76,eraseEndLine:()=>ce8,eraseDown:()=>ie8,enterAlternativeScreen:()=>te8,cursorUp:()=>m76,cursorTo:()=>ve8,cursorShow:()=>pe8,cursorSavePosition:()=>ye8,cursorRestorePosition:()=>fe8,cursorPrevLine:()=>me8,cursorNextLine:()=>ge8,cursorMove:()=>ke8,cursorLeft:()=>u76,cursorHide:()=>ue8,cursorGetPosition:()=>he8,cursorForward:()=>be8,cursorDown:()=>_e8,cursorBackward:()=>xe8,clearTerminal:()=>oe8,clearScreen:()=>se8,beep:()=>J19});import Ib1 from"node:process";var O41=globalThis.window?.document!==void 0,UK2=globalThis.process?.versions?.node!==void 0,FK2=globalThis.process?.versions?.bun!==void 0,WK2=globalThis.Deno?.version?.deno!==void 0,HK2=globalThis.process?.versions?.electron!==void 0,BK2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,DK2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,MK2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,VK2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,NK2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Lm=globalThis.navigator?.userAgentData?.platform,LK2=Lm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",AK2=Lm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",OK2=Lm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",jK2=Lm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),RK2=Lm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var G2="\x1B[",Om="\x1B]",WT="\x07",Am=";",g76=!O41&&Ib1.env.TERM_PROGRAM==="Apple_Terminal",Ce8=!O41&&Ib1.platform==="win32",Se8=O41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:Ib1.cwd,ve8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return G2+(J+1)+"G";return G2+(Q+1)+Am+(J+1)+"H"},ke8=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=G2+-J+"D";else if(J>0)Z+=G2+J+"C";if(Q<0)Z+=G2+-Q+"A";else if(Q>0)Z+=G2+Q+"B";return Z},m76=(J=1)=>G2+J+"A",_e8=(J=1)=>G2+J+"B",be8=(J=1)=>G2+J+"C",xe8=(J=1)=>G2+J+"D",u76=G2+"G",ye8=g76?"\x1B7":G2+"s",fe8=g76?"\x1B8":G2+"u",he8=G2+"6n",ge8=G2+"E",me8=G2+"F",ue8=G2+"?25l",pe8=G2+"?25h",de8=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=p76+(Z<J-1?m76():"");if(J)Q+=u76;return Q},ce8=G2+"K",le8=G2+"1K",p76=G2+"2K",ie8=G2+"J",ae8=G2+"1J",wb1=G2+"2J",ne8=G2+"S",re8=G2+"T",se8="\x1Bc",oe8=Ce8?`${wb1}${G2}0f`:`${wb1}${G2}3J${G2}H`,te8=G2+"?1049h",ee8=G2+"?1049l",J19=WT,Q19=(J,Q)=>[Om,"8",Am,Am,Q,WT,J,Om,"8",Am,Am,WT].join(""),Z19=(J,Q={})=>{let Z=`${Om}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")+WT},X19={setCwd:(J=Se8())=>`${Om}50;CurrentDir=${J}${WT}`,annotation(J,Q={}){let Z=`${Om}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+WT}};var R41=Q8(r76(),1);function XV(J,Q,{target:Z="stdout",...X}={}){if(!R41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (${Q})`}return j41.link(J,Q)}XV.isSupported=R41.default.stdout;XV.stderr=(J,Q,Z={})=>XV(J,Q,{target:"stderr",...Z});XV.stderr.isSupported=R41.default.stderr;W0();pG();class Cb1{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.1759809746-ga795fe"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await We1(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}}W0();class w41 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 s76(J){if(J instanceof w41)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 H19={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(() => (d_1(),C26));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
|
5818
5818
|
Client ID: ${Y}
|
5819
5819
|
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 Sb1{commands;customRegistry;latestCustom=[];telemetrySubmitter;constructor(J=pT()){this.customRegistry=J,this._initBaseCommands(!1),this.customRegistry.commands.subscribe((Q)=>this.latestCustom=Q),this.telemetrySubmitter=new Cb1(async()=>{try{return(await c8()).settings["experimental.cli.commandTelemetry.enabled"]===!0}catch{return!1}}),R9.pipe(S0((Q)=>Q.settings["internal.modes"]),$8()).subscribe((Q)=>{this._initBaseCommands(Q??!1)})}_initBaseCommands(J){if(this.commands={...B19},process.env.AMP_CONNECT==="1")Object.assign(this.commands,H19);if(J)Object.assign(this.commands,D19)}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 Rb1(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 B19={"generate-agent-file":{name:"generate-agent-file",description:`Generate an ${e5} file in the current workspace`,execute:async(J,Q)=>{J.worker.handle({type:"user:message",message:{content:[{type:"text",text:OX0}]}});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 w41;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 U19(t76.join(z19(),"amp-edit-")),Y=t76.join(X,"message.amp.md");o76(`${Z} "${Y}"`,{stdio:"inherit"}),process.stdout.write("\x1B[?25l");try{let q=(await F19(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 W19(Y),await G19(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 CH("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 CH("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 UT();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:UT};await L41(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(`
|
5820
5820
|
`).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=wv(new URL(Y),Z.id).toString(),G=`Thread URL: ${XV(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}
|
@@ -6002,7 +6002,7 @@ ${Q}`),this.textController.clear(),this.textController.insertText(this.pendingTr
|
|
6002
6002
|
`),J.stdout.write(`Thread: ${H}
|
6003
6003
|
`),J.stdout.write(`Continue this thread with: amp threads continue ${F}
|
6004
6004
|
`)}}function _X6(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])}ob1();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}
|
6005
|
-
`)}var ef1=tf1.join(Cu1||tf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function Q79(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 AV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")CH("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")CH("experimental.agentMode",Q.agentMode)}var Z79=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()]),X79=P0.record(P0.string(),Z79);async function Qh1(J){try{await t49(tf1.dirname(ef1),{recursive:!0}),await e49(ef1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function Y79(){try{return(await mX6(ef1,"utf-8")).trim()}catch(J){return null}}async function K79(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 X79.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 q79(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 fX6=[{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??GG,description:`Custom settings file path (overrides the default location ${GG})`},{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 ${v_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:zG(),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:Wb1(),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:sV}],hX6=(J)=>("deprecated"in J)&&J.deprecated===!0,G79=(J)=>("hidden"in J)&&J.hidden===!0,z79=(J)=>("default"in J),U79=(J)=>("default"in J)?J.default:void 0;function F79(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(wK.unknownCommand(Z),1,q)}}var uX6=null;function G_2(){return uX6}function o71(J){return{...J,getThreadEnvironment:i21,vfs:ze1({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new Ev(J.fileSystem),generateThreadTitle:ea,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var Zh1=b0.file(J79.homedir()),pX6=process.env.XDG_CONFIG_HOME?b0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(Zh1,".config");async function OV(J,Q){bd1("0.0.
|
6005
|
+
`)}var ef1=tf1.join(Cu1||tf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function Q79(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 AV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")CH("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")CH("experimental.agentMode",Q.agentMode)}var Z79=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()]),X79=P0.record(P0.string(),Z79);async function Qh1(J){try{await t49(tf1.dirname(ef1),{recursive:!0}),await e49(ef1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function Y79(){try{return(await mX6(ef1,"utf-8")).trim()}catch(J){return null}}async function K79(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 X79.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 q79(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 fX6=[{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??GG,description:`Custom settings file path (overrides the default location ${GG})`},{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 ${v_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:zG(),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:Wb1(),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:sV}],hX6=(J)=>("deprecated"in J)&&J.deprecated===!0,G79=(J)=>("hidden"in J)&&J.hidden===!0,z79=(J)=>("default"in J),U79=(J)=>("default"in J)?J.default:void 0;function F79(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(wK.unknownCommand(Z),1,q)}}var uX6=null;function G_2(){return uX6}function o71(J){return{...J,getThreadEnvironment:i21,vfs:ze1({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new Ev(J.fileSystem),generateThreadTitle:ea,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var Zh1=b0.file(J79.homedir()),pX6=process.env.XDG_CONFIG_HOME?b0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(Zh1,".config");async function OV(J,Q){bd1("0.0.1759809746-ga795fe");let Z=eJ1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:J0.of([b0.file(process.cwd())]),defaultAmpURL:J.ampURL,defaultCacheDirectory:S_1,homeDir:Zh1,userConfigDir:pX6}),X=await c8();l.debug("Global configuration initialized",{hasCacheDirectory:!!X.settings.cacheDirectory,settingsKeys:Object.keys(X.settings)});let Y=Il(Wj()),K=pt1({configService:Z,toolService:Y}),q=S30(Y,x9,Zt).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)xd1(!0);if(Q.ide&&Wb1())yd1(!0);if(C16(Y),Q.jetbrains)Y.registerTool(In);else if(Q.ide)Y.registerTool(LY0);let z;if(!J.executeMode)z=new q41(process.cwd(),{},!0);else z=new class extends q41{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(m2.write(`No API key found. Starting login flow...
|
6006
6006
|
`),!await W79(J))await QO(),process.exit(1)}let U=await Ve1({isDevelopment:!1}),F=new GU1(U),W=new KU1(U,{lazy:!0}),H=new sB1(F),B=Q.notifications!==void 0?Q.notifications:!J.executeMode,M=v16({playNotificationSound:async(L)=>{if(B){S16(L);let A=rb1(),O=sb1();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:F});l.info("Starting Amp background services");let V=PX0({threadService:F,threadHistoryService:W,isExtensionDevelopment:!1}),N={configService:Z,toolService:Y,mcpService:K,threadService:F,threadHistoryService:W,threadSummaryService:H,threadSyncService:V,threadStorage:U,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:z,notificationService:M,fileSystem:Q.jetbrains||Q.ide?Ke1:x9};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 W79(J){if(!J.executeMode){if(!await Lb1("Would you like to log in to Amp? [(y)es, (n)o]: "))return m2.write(`Login cancelled. Run the command again to retry.
|
6007
6007
|
`),!1}return await dX6(J)}async function dX6(J){let Q=o49(32).toString("hex"),Z=await Nb1(J.ampURL,Q);try{await QV(Z)}catch(Y){l.error("Failed to open browser",{error:Y})}let X=await Nb1(J.ampURL,Q,!1);m2.write(`If your browser did not open automatically, visit:
|
6008
6008
|
|
@@ -6012,12 +6012,12 @@ ${e6.blue.bold(X)}
|
|
6012
6012
|
Login successful! You can now use the Amp CLI.
|
6013
6013
|
`),!0}catch(Y){return l.error("Login failed",{error:Y}),t2.write(`
|
6014
6014
|
Login failed: ${Y instanceof Error?Y.message:String(Y)}
|
6015
|
-
`),!1}}function H79(){let J=new Pg().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((W)=>{if(W.code==="commander.help"||W.code==="commander.version"||W.exitCode===0)XO(),process.exit(0);let H=W.originalError??W;k26(H)}),J.option("-V, --version","output the version number",()=>{m2.write(`0.0.
|
6016
|
-
`),process.exit(0)}),J.addHelpText("after",_46()),J.configureHelp({formatHelp:b46}),J.command("logout").description("Log out by removing stored API key").action(async(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await V79(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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await M79(M,await Kb1(B,M.settings))});let Q=async(W,H,B)=>{eJ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:J0.of([b0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:Zh1,userConfigDir:pX6});let M={...H,executeMode:!1};await Jh1(M,{...W,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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await gX6(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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await w79(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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);if(H.pick)await Q(M,V,B);else await R79(M,V,W,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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);await j79(M,V,W,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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await gX6(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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);await O79(M,V,W,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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);await A79(M,V,W,B)}),v76(J,async(W,H)=>{let B=await ZY(H);AV(W,H);let M=await OV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:XO,asyncDispose:M.asyncDispose.bind(M)}}),K76(J),t46(J,async(W)=>{return(await ZY(W)).settings}),J.command("connect").description("Connect CLI to web interface for multi-thread management").action(async(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);AV(H,B);let V=await OV(M,B);try{await p_1(V,{})}finally{await V.asyncDispose(),await XO()}});let X=new Pg().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(W)=>{await Bb1(W.force||!1,W.verbose||!1,"0.0.
|
6015
|
+
`),!1}}function H79(){let J=new Pg().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((W)=>{if(W.code==="commander.help"||W.code==="commander.version"||W.exitCode===0)XO(),process.exit(0);let H=W.originalError??W;k26(H)}),J.option("-V, --version","output the version number",()=>{m2.write(`0.0.1759809746-ga795fe (released 2025-10-07T04:07:30.473Z)
|
6016
|
+
`),process.exit(0)}),J.addHelpText("after",_46()),J.configureHelp({formatHelp:b46}),J.command("logout").description("Log out by removing stored API key").action(async(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await V79(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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await M79(M,await Kb1(B,M.settings))});let Q=async(W,H,B)=>{eJ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:J0.of([b0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:Zh1,userConfigDir:pX6});let M={...H,executeMode:!1};await Jh1(M,{...W,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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await gX6(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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await w79(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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);if(H.pick)await Q(M,V,B);else await R79(M,V,W,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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);await j79(M,V,W,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(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);await gX6(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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);await O79(M,V,W,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(W,H,B)=>{let M=B.optsWithGlobals(),V=await ZY(M);await A79(M,V,W,B)}),v76(J,async(W,H)=>{let B=await ZY(H);AV(W,H);let M=await OV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:XO,asyncDispose:M.asyncDispose.bind(M)}}),K76(J),t46(J,async(W)=>{return(await ZY(W)).settings}),J.command("connect").description("Connect CLI to web interface for multi-thread management").action(async(W,H)=>{let B=H.optsWithGlobals(),M=await ZY(B);AV(H,B);let V=await OV(M,B);try{await p_1(V,{})}finally{await V.asyncDispose(),await XO()}});let X=new Pg().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(W)=>{await Bb1(W.force||!1,W.verbose||!1,"0.0.1759809746-ga795fe"),process.exit()});J.addCommand(X,{hidden:!0});function Y(W,H,B){let V=typeof W.description==="string"?W.description:B===void 0?W.description(!0):W.description(B),N=new dM(H,V),L=U79(W);if(L)N.default(L);if(N.hidden=G79(W)||hX6(W),"choices"in W)N.choices([...W.choices]);return N}for(let W of fX6)switch(W.type){case"flag":{J.addOption(Y(W,`--${W.long}`)),J.addOption(Y(W,`--no-${W.long}`,!1));break}case"switch":{J.addOption(Y(W,`--${W.long}`,!0));break}default:{J.addOption(Y(W,`--${W.long} <value>`));break}}let K=new dM("-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 W=new dM("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1);J.addOption(W)}let q=new dM("--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 dM("--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 dM("--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 W=new dM("--client-id <clientId>","Override the client ID for connect functionality (default: amp-<pid>@<hostname>)");J.addOption(W)}J.action(async(W,H)=>{let B=W,M=await ZY(B);if(Object.keys(B).forEach((V)=>{let N=fX6.find((L)=>L.name===V);if(N&&hX6(N)&&!z79(N))t2.write(e6.yellow(`Warning: '--${V}' flag is deprecated
|
6017
6017
|
`))}),H.args.length>0)F79(M,H);await Jh1(M,B,H)});let U=new Pg("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(W)=>{await L79(W.outputDir,W.includeFullLogs)});J.addCommand(U);let F=new Pg("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(W)=>{await N79(W.version)});return J.addCommand(F),J}async function s71(J,Q){let{thread:Z,visibility:X}=Q,Y=Z?.id??fK(),K=o71(J);if(Z)await J.threadStorage.set(Y,Z);let q=await vJ.getOrCreateForThread(K,Y);if(X)await J.threadSyncService.updateThreadMeta(Y,V41(X));let G=J.threadService.observe(Y).subscribe(async(z)=>{if(R7(z,"assistant"))await Qh1(Y),G.unsubscribe()});return await q.resume(),q}async function Jh1(J,Q,Z){let X=process.stdin,Y=M41(Q);if(Y instanceof Error)oZ(Y.message);let K,q=null;if(Q.streamJsonInput)K="";else if(typeof Q.execute==="string"){K=Q.execute;let j=(await Ab1()).trimEnd();if(j)q=j}else K=(await Ab1()).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"
|
6018
6018
|
Or pipe via stdin: echo "your message" | amp --execute`);if(K!==""&&!J.executeMode&&!J.streamJsonMode&&typeof Q.execute!=="string")X=await W76();AV(Z,Q);let G=await OV(J,Q);uX6=G;let z=o71(G),U=async(j)=>{let R=await mX6(j,"utf-8"),I=JSON.parse(R);if(!kU(I.id))throw new N2(wK.invalidThreadId);return s71(G,{visibility:Y,thread:I})},F=async(j)=>{if(!kU(j))throw new N2(wK.invalidThreadId);let R=await G.threadService.get(j)??void 0;return s71(G,{visibility:Y,thread:R})},W=async()=>{try{if(Q.threadId)return F(Q.threadId);else return s71(G,{visibility:Y})}catch(j){if(j instanceof N2)throw j;throw await t21(j,Q.threadId),Error("handleError should have called process.exit()")}},H=async()=>{return s71(G,{visibility:Y})};if(Q.format==="jsonl")t2.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
|
6019
|
-
`),await QO(),process.exit(1);if(J.executeMode&&Q.remote)await q76(K,q),await G.asyncDispose(),process.exit(0);let B=await W();if(J.executeMode)await d26(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 Xi1();let j=await Cj({jetbrainsOnly:Q.jetbrains});if(j.length===0)if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall");else i5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(j.length===1){let R=j[0];if(R)i5.selectConfig(R)}else M=!0}let N=Mb1("0.0.
|
6020
|
-
`);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 z76(Y),await U76(Y),J.mcpConfig){let G=await K79(J.mcpConfig);Y=q79(Y,G)}let K=await Y.get("url","global");if(!K)K=sQ;if(!PH(K))l.info("Targeting custom Amp server",{ampURL:K});if(Y=ou1(Y),await Y.get("debug.httpLogging"))nu1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:K,settings:Y,secrets:G76(await Kb1(J,Y))}}function B79(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 D79(){let J=B79(process.argv);if(M26({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),Q79(l),l.info("Starting Amp CLI.",{version:"0.0.
|
6019
|
+
`),await QO(),process.exit(1);if(J.executeMode&&Q.remote)await q76(K,q),await G.asyncDispose(),process.exit(0);let B=await W();if(J.executeMode)await d26(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 Xi1();let j=await Cj({jetbrainsOnly:Q.jetbrains});if(j.length===0)if(Q.jetbrains)V=!await G.configService.get("jetbrains.skipInstall");else i5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(j.length===1){let R=j[0];if(R)i5.selectConfig(R)}else M=!0}let N=Mb1("0.0.1759809746-ga795fe",G.settingsStorage),L=J0.of([b0.file(process.cwd())]),A=pT(void 0,L);if(K)B.handle({type:"user:message",message:{content:[{type:"text",text:K}]}});let O=await c8();await yX6({stdin:X,stdout:process.stdout,history:new i_1,fuzzyServer:G.fuzzyServer,settingsStorage:G.settingsStorage,threadService:G.threadService,threadSyncService:G.threadSyncService,threadID:B.threadID,worker:B,workerDeps:z,configService:G.configService,internalAPIClient:EJ,ampURL:J.ampURL,startNewThread:H,pickAndContinueThread:async()=>{l.info("Thread picker requested - not yet implemented in TUI")},switchToThread:F,ideClient:i5,connectedClientsService:new Dp,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 ZY(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.
|
6020
|
+
`);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 z76(Y),await U76(Y),J.mcpConfig){let G=await K79(J.mcpConfig);Y=q79(Y,G)}let K=await Y.get("url","global");if(!K)K=sQ;if(!PH(K))l.info("Targeting custom Amp server",{ampURL:K});if(Y=ou1(Y),await Y.get("debug.httpLogging"))nu1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:K,settings:Y,secrets:G76(await Kb1(J,Y))}}function B79(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 D79(){let J=B79(process.argv);if(M26({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),Q79(l),l.info("Starting Amp CLI.",{version:"0.0.1759809746-ga795fe",buildTimestamp:"2025-10-07T04:07:30.473Z",buildType:"'release'"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new N2(wK.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await H79().parseAsync(process.argv)}D79().catch(t21);async function M79(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),m2.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
|
6021
6021
|
`);else if(!PH(J.ampURL))m2.write(`Logging in to ${new URL(J.ampURL).hostname}
|
6022
6022
|
`);let Z=process.env.AMP_API_KEY;if(Z)m2.write(`API key found in environment variable, storing...
|
6023
6023
|
`),await Q.set("apiKey",Z,J.ampURL),m2.write(`API key successfully stored.
|
@@ -6033,7 +6033,7 @@ Or pipe via stdin: echo "your message" | amp --execute`);if(K!==""&&!J.executeMo
|
|
6033
6033
|
`));try{let Q;if(J)Q=J,t2.write(e6.blue(`Updating to version ${J}...
|
6034
6034
|
`)),await GT(J),t2.write(e6.green(`✓ Successfully updated to version ${J}
|
6035
6035
|
`));else{t2.write(e6.blue(`Checking for updates...
|
6036
|
-
`));let{hasUpdate:X,latestVersion:Y}=await OR("0.0.
|
6036
|
+
`));let{hasUpdate:X,latestVersion:Y}=await OR("0.0.1759809746-ga795fe");if(!X)t2.write(e6.green(`✓ Amp CLI is already up to date.
|
6037
6037
|
`)),process.exit(0);if(!Y)t2.write(e6.yellow("[WARN] could not find latest version")),process.exit(0);Q=Y,t2.write(e6.blue(`Updating to version ${Y}...
|
6038
6038
|
`)),await GT(Y),t2.write(e6.green(`✓ Successfully updated to version ${Y}
|
6039
6039
|
`))}let Z=await zO(Q);if(Z.warning)t2.write(`
|
package/package.json
CHANGED