@sourcegraph/amp 0.0.1753417098-g499a98 → 0.0.1753430532-gb4f1dc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +4 -4
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -4627,7 +4627,7 @@ ${Y}`}else Z=z.map((G)=>` ${G}`).join(`
4627
4627
  `});return}if(E.trim().length>0)v(E.trim());else return;return}if(!m.ctrl&&!m.meta&&!m.tab&&y)z({type:"insert-text",text:y})});let v=async(y)=>{M(null),Q.add(y),Q.reset();try{A(y)}catch(m){S1.error("Failed to submit message",m)}};return W0(KA,{flexDirection:"column",width:"100%",flexGrow:1,flexShrink:0,ref:G,children:I.lines.map((y,m)=>W0(KA,{flexShrink:0,flexDirection:"row",children:W0(KA,{flexGrow:1,flexShrink:0,width:"100%",children:m===O.line?b6(QK,{children:[W0(TA,{dimColor:B,children:ES.default.substr(y.content,0,O.column)||""}),W0(TA,{inverse:!B,dimColor:B,children:ES.default(y.content)[O.column]??" "}),W0(TA,{dimColor:B,children:ES.default.substr(y.content,O.column+1)||""})]}):W0(TA,{dimColor:B,children:y.content||" "})})},m))})}function ge6(A,Q){let B=ES.default(A),D=Q,J=Q;while(D>0&&/\S/.test(B[D-1]||""))D--;while(J<B.length&&/\S/.test(B[J]||""))J++;let z=B.slice(D,J).join("");if(!z.trim())return null;return{word:z,start:D,end:J}}var HS=xA(J8(),1);RH();var l41=xA(J8(),1);function A7A(){let[A,Q]=l41.useState(null);return l41.useEffect(()=>{let B=ll.subscribe(Q);return()=>{B.unsubscribe()}},[]),{jetbrainsState:A}}bQ1();var Pf1=xA(J8(),1);function Q7A({viewState:A}){let Q=Pf1.useMemo(()=>{return A.state==="active"?A.fileChanges:void 0},[A]),B=Pf1.useMemo(()=>_h1(Q),[Q]);if(!Q||B.totalFiles===0)return null;let D=B.totalFiles-B.revertedFiles;return b6(KA,{gap:1,children:[b6(TA,{dimColor:!0,children:[D," ",D===1?"file":"files"," changed"]}),(B.totalAdded>0||B.totalModified>0||B.totalRemoved>0)&&b6(TA,{children:[b6(TA,{color:"green",children:["+",B.totalAdded]}),b6(TA,{color:"yellow",children:[" ~",B.totalModified]}),b6(TA,{color:"red",children:[" -",B.totalRemoved]})]})]})}import B7A from"node:path";function D7A({jetbrainsStatus:A}){if(!A||!A.enabled)return null;let Q=process.cwd(),B=A.productName&&A.openFile&&A.workspace===Q,D;if(!A.productName)D=" IDE Not Running. To fix this problem, start your JetBrains IDE, exit this session and run `amp threads continue`.";else if(!A.workspace&&!A.openFile)D=" No Open File. To fix this problem, open a project and open a file in your JetBrains IDE.";else if(!A.workspace&&A.openFile){let J=B7A.basename(A.openFile);if(A.openFile.includes("!/"))D=` External File Open. The open file '${A.openFile}' does not belong to your project root. To fix this problem, open a file in your project sources and try again.`;else D=` Project Detection Failed. Failed to map your open file '${J}' to a project root directory. Please note that multi-root projects are not supported at the moment. Please report a bug on https://ampcode.com/discord and include relevant logs from ~/.cache/amp/logs/cli.log`}else if(!A.openFile)D=" No Open File. To fix this problem, open a file in your project.";else if(A.workspace!==Q)D=` Project Mismatch. The currently open project "${A.workspace}" does not match the working directory of Amp CLI ("${Q}").`;return W0(KA,{gap:B?1:2,children:b6(TA,{color:B?"green":"red",children:[B?"✓":"×"," ",A.productName??"JetBrains"," ",B?"• "+B7A.basename(A.openFile??""):D]})})}var i41=xA(J8(),1);function J7A(){let[A,Q]=i41.useState(0);i41.useEffect(()=>{let J=setInterval(()=>{Q((z)=>z+1)},200);return()=>clearInterval(J)},[]);let B=[{char:"∿",dim:!1},{char:"∾",dim:!1},{char:"∽",dim:!1},{char:"≋",dim:!1},{char:"≈",dim:!1},{char:"∼",dim:!1}],D=B[A%B.length];return W0(TA,{dimColor:D.dim,children:D.char})}var xe6=0.8,he6=0.9;function z7A({tokenUsage:A}){let Q=A.totalInputTokens/A.maxInputTokens,B=Math.round(Q*100),J=`${Math.max(0,Math.min(B,100))}%`,z,K=K7A(Q);if(K==="danger")z="red";else if(K==="warning")z="yellow";return W0(TA,{color:z,children:J})}function K7A(A){if(A>=he6)return"danger";else if(A>=xe6)return"warning";return!1}function Z7A(A){let Q=A.totalInputTokens/A.maxInputTokens;return K7A(Q)}function G7A({threadViewState:A,tokenUsage:Q,waitingForConfirmation:B,showingEphemeralError:D}){if(!A||A.state!=="active")return null;let J=null,z=Q?Z7A(Q):!1,K=!1;if(A.summaryState==="summarizing")J="Compacting...";else if(A.inferenceState==="running")J="Running inference...";else if(A.interactionState==="tool-running")J="Running tools...";else if(!D&&z==="warning")J="Context window is almost full. Use /compact to trim the thread.",K=!0;else if(!D&&z==="danger")J="Context window is close to full. Use /compact to trim the thread.",K=!0;if(!J)return null;let Z=()=>{if(A.inferenceState==="running"&&A.interactionState!=="tool-running")return"blueBright";if(A.interactionState==="tool-running")return"greenBright";return"default"},G=()=>{if(K&&z==="warning")return"yellow";if(K&&z==="danger")return"red";if(A.inferenceState==="cancelled")return"dim";return"default"},X=A.inferenceState!=="cancelled"&&!K&&!B;return b6(KA,{flexDirection:"row",gap:1,children:[X&&W0(TA,{color:Z(),children:W0(J7A,{})}),W0(TA,{italic:!K&&A.inferenceState==="cancelled",color:G(),children:J})]})}function X7A({view:A,threadViewState:Q,threadTokenUsage:B,hasCompletedMessages:D,width:J}){let{jetbrainsState:z}=A7A(),K=HS.useRef(null),{stdout:Z}=RX(),[G,X]=HS.useState(Z.columns);HS.useEffect(()=>{if(K.current){let{width:F}=CV(K.current);X(F)}},[Z.columns]);let Y=J||G,U=Y&&Y<60;return b6(KA,{gap:2,marginLeft:2,ref:K,children:[b6(KA,{flexGrow:1,flexDirection:"row",gap:2,children:[W0(G7A,{threadViewState:Q,tokenUsage:B,waitingForConfirmation:A==="confirming"||A==="ephemeral-error",showingEphemeralError:A==="ephemeral-error"}),b6(KA,{children:[A==="confirming-exit"&&W0(TA,{dimColor:!0,children:"Ctrl+C again to exit"}),A==="help"&&W0(TA,{dimColor:!0,children:"Escape to close help"}),D&&A==="running"&&!U&&W0(TA,{dimColor:!0,children:"Ctrl+R to expand"})]})]}),b6(KA,{flexGrow:0,gap:2,children:[W0(D7A,{jetbrainsStatus:z}),!U&&W0(Q7A,{viewState:Q}),B&&W0(z7A,{tokenUsage:B})]})]})}o6();C0.level=1;var me6={code:C0.white,codespan:C0.white,blockquote:C0.gray.italic,html:C0.gray,heading:C0.bold,firstHeading:C0.bold,hr:C0.reset,table:C0.reset,paragraph:C0.reset,strong:C0.bold,em:C0.italic,del:C0.dim.gray.strikethrough,link:C0.cyan,href:C0.cyan,text:C0.reset,unescape:!0,emoji:!0,width:80,showSectionPrefix:!0,reflowText:!1,tab:4,tableOptions:{wordWrap:!0,wrapOnWordBoundary:!1,style:{head:["bold"],border:["grey"],compact:!1}}},ue6={keyword:C0.bold,built_in:C0.dim,type:C0.dim,literal:C0.italic,number:C0.reset,regexp:C0.dim.italic,string:C0.dim,subst:C0.reset,symbol:C0.reset,class:C0.bold,function:C0.reset,title:C0.reset,params:C0.reset,comment:C0.dim.italic,doctag:C0.dim.italic,meta:C0.dim,"meta-keyword":C0.reset,"meta-string":C0.reset,section:C0.reset,tag:C0.dim,name:C0.bold,"builtin-name":C0.reset,attr:C0.dim,attribute:C0.reset,variable:C0.reset,bullet:C0.reset,code:C0.reset,emphasis:C0.italic,strong:C0.bold,formula:C0.reset,link:C0.underline,quote:C0.reset,"selector-tag":C0.reset,"selector-id":C0.reset,"selector-class":C0.reset,"selector-attr":C0.reset,"selector-pseudo":C0.reset,"template-tag":C0.reset,"template-variable":C0.reset,addition:C0.bold.underline,deletion:C0.dim.strikethrough,default:C0.reset};E9.use(m81({...me6,reflowText:!1},{ignoreIllegals:!0,theme:ue6}));function a41({children:A}){let Q;try{Q=E9(A,{async:!1}).trimEnd()}catch(B){S1.error("Markdown rendering failed",B,{input:A}),Q=A}return W0(TA,{children:Q})}function Y7A({message:A}){let Q=A.content.filter((B)=>B.type==="thinking"||B.type==="text");if(!Q.length)return null;return W0(KA,{flexDirection:"column",marginBottom:1,children:Q.map((B,D)=>{let J=D>0?1:0;if(B.type==="thinking")return W0(d41,{thinking:B.thinking},D);else return W0(KA,{marginTop:J,children:W0(a41,{children:B.text})},D);return null})})}function U7A({message:A,marginTop:Q=0}){if(!A.content.some((J)=>J.type==="text"||J.type==="thinking"||J.type==="summary"&&J.summary.type==="message"))return null;let D=A.role==="assistant"&&A.state.type==="cancelled";return b6(KA,{flexDirection:"column",gap:1,marginTop:Q,children:[A.content.map((J,z)=>{if(J.type==="text")switch(A.role){case"assistant":return W0(KA,{flexDirection:"column",children:W0(a41,{children:J.text})},z);case"user":return W0(KA,{borderStyle:"bold",borderColor:"green",borderLeft:!0,borderTop:!1,borderBottom:!1,borderRight:!1,paddingLeft:1,children:W0(TA,{color:"green",italic:!0,children:J.text})},z)}else if(J.type==="thinking")return W0(d41,{thinking:J.thinking},z);else if(J.type==="summary"&&J.summary.type==="message")return W0(KA,{children:b6(TA,{color:"grey",italic:!0,children:["Summary: ",J.summary.summary]})},z);else return null}),D&&W0(KA,{children:W0(TA,{italic:!0,dimColor:!0,children:"Cancelled"})})]})}function q7A({todos:A}){if(!Array.isArray(A)||A.length===0)return null;return b6(KA,{borderStyle:"round",borderColor:"dim",paddingX:1,flexDirection:"column",flexGrow:1,flexShrink:0,children:[W0(KA,{children:W0(TA,{dimColor:!0,bold:!0,children:"TODOs"})}),A.map((Q,B)=>W0(KA,{gap:1,children:b6(TA,{dimColor:!0,wrap:"truncate",children:[W0(TA,{children:"• "}),W0(TA,{bold:Q.status==="in-progress",strikethrough:Q.status==="completed",children:Q.content})]})},Q.id))]})}var RW=xA(J8(),1);function _f1({children:A,dependencies:Q}){let{stdout:B}=RX(),D=RW.useRef(null),[J,z]=RW.useState(B.columns),K=RW.useCallback(()=>{if(D.current){let{width:Z}=CV(D.current);z(Z)}},[D,z]);return RW.useLayoutEffect(K,[K,B.columns,...Q||[]]),W0(KA,{width:"100%",height:"100%",ref:D,children:A(J)})}var r41=xA(J8(),1);function F7A(A){let Q=r41.useMemo(()=>process.cwd().replace(process.env.HOME||"","~"),[]);r41.useEffect(()=>{if(A)process.stdout.write(`\x1B]0;amp - ${A} - ${Q}\x07`);return()=>{process.stdout.write("\x1B]0;\x07")}},[A,Q])}var n41=xA(J8(),1);function E7A(){return W0(KA,{flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:3,marginLeft:4,children:W0(KA,{children:W0(TA,{color:"green",bold:!0,children:"Welcome to Amp"})})})}function H7A(){let[A,Q]=n41.useState(0),B=["Amp","AMP","AmP","amP","aMP","AMp"];return n41.useEffect(()=>{let D=setInterval(()=>{Q((J)=>(J+1)%B.length)},50);return()=>clearInterval(D)},[B.length]),W0(KA,{flexDirection:"column",alignItems:"flex-start",justifyContent:"center",minHeight:3,marginLeft:4,children:W0(KA,{children:b6(TA,{color:"green",bold:!0,children:["Welcome to ",B[A]]})})})}var pe6=200;function w7A({threadService:A,history:Q,worker:B,sendToolConfirmation:D,sendUserMessage:J,exit:z,cancel:K,ampURL:Z,commands:G}){let[X]=c41(),{viewState:Y,subagents:U,subagentActiveTools:F,transcript:E,streamingAssistantMessage:H,todosList:w,mainThread:I}=G5A(A,B),W=I5.useMemo(()=>H?E.items.concat({id:"streaming-assistant",type:"message",message:H}):E.items,[H,E.items]),M=I?.title||"Untitled",N=I5.useMemo(()=>I?ph1(I):void 0,[I]);F7A(I?.title);let O=I5.useRef(new r8),[R,T]=I5.useState({baseView:"running",rerendering:!1,resizeCounter:0,dismissedEphemeralError:null,slashCommandQuery:null,uiError:null}),L=I5.useRef(null),j=I5.useRef(null),[P,$]=d5A(),v=I5.useCallback((s)=>{T((Q1)=>({...Q1,slashCommandQuery:s}))},[]),y=I5.useMemo(()=>{if(R.slashCommandQuery===null)return[];return G.query(R.slashCommandQuery)},[R.slashCommandQuery,G]),m=I5.useCallback(()=>{T((s)=>({...s,rerendering:!0})),process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),O.current.next()},[T,O]),_=I5.useCallback(async(s)=>{if(T((W1)=>({...W1,slashCommandQuery:null})),!s||!I)return;let Q1=!1,J1=(W1)=>{Q1=!0,$(W1)},X1=()=>{T((W1)=>({...W1,baseView:"help"}))},L1=await G.get(s).execute({worker:B,thread:I,editorDispatch:J1,exitApp:z,openHelp:X1});if(T((W1)=>({...W1,uiError:L1||null})),!Q1)$({type:"clear"})},[G,$,I,B,z]),k=I5.useCallback((s)=>{$({type:"clear"}),J(s)},[$,J]);I5.useEffect(()=>{return process.stdout.on("resize",m),()=>{process.stdout.off("resize",m)}},[m]),I5.useEffect(()=>{let s=O.current.pipe(WD(pe6)).subscribe(()=>{T((Q1)=>({...Q1,rerendering:!1,resizeCounter:Q1.resizeCounter+1}))});return()=>{s.unsubscribe()}},[O,T]),I5.useEffect(()=>{let s=O.current,Q1=L.current;return()=>{if(s.complete(),Q1)clearTimeout(Q1)}},[O]);let g=[...E.activeTools,...F],u=g.filter((s)=>s.toolRun.status==="blocked-on-user"),S=I5.useMemo(()=>S5A(u),[u]),{hasCompletions:h,completions:d,selectCompletion:l}=S41(),D1=I5.useMemo(()=>{if(Y.state!=="active"||!Y.ephemeralError)return null;if(R.dismissedEphemeralError===Y.ephemeralError)return null;return Y.ephemeralError},[Y,R.dismissedEphemeralError]),n=R.uiError!==null?"ui-error":D1!==null?"ephemeral-error":S!==null?"confirming":R.baseView,K1=(s)=>{if(!S||S.type!=="tool-use")return;if(S.tools.length>0){let Q1=S.tools[0],J1=Array.from(s==="always"?Q1.toAllow??[]:[]);D(Q1.useBlock.id,s==="yes"||s==="always",J1,S.subthreadID)}},B1=(s)=>{switch(s){case"compact":T((Q1)=>({...Q1,dismissedEphemeralError:null})),B.summarizeThread();break;case"dismiss":T((Q1)=>({...Q1,dismissedEphemeralError:D1}));break;case"retry":T((Q1)=>({...Q1,dismissedEphemeralError:null})),B.retry();break;default:S1.warn("action:",{action:s})}},Z1=()=>{T((s)=>({...s,uiError:null}))};uE((s,Q1)=>{if(Q1.ctrlC){if(R.baseView==="confirming-exit"){if(L.current)clearTimeout(L.current),L.current=null;z()}else{if(T((X1)=>({...X1,baseView:"confirming-exit"})),L.current)clearTimeout(L.current);let J1=setTimeout(()=>{T((X1)=>({...X1,baseView:"running"})),L.current=null},1000);L.current=J1}return}if(n==="help"){if(Q1.escape)T((J1)=>({...J1,baseView:"running"}));return}if(n==="expanded-view"||n==="confirming"||n==="ephemeral-error")return;if(n==="ui-error")return;if(Q1.escape)if(h||y.length>0)return;else K();else if(Q1.ctrl&&s.toLowerCase()==="r")T((J1)=>({...J1,baseView:"expanded-view"}));else if(Q1.ctrlL)m()});let z1=X>100,R1=R.rerendering&&E.items.length===0?1:"auto",a="resize-key"+R.resizeCounter,r=[{type:"welcome",id:"welcome"},...E.items];if(R.baseView==="expanded-view"){let s=W.filter((Q1)=>Q1.type==="message").map((Q1)=>Q1.message);return W0(a5A,{threadName:M,messages:s,onExit:()=>T((Q1)=>({...Q1,baseView:"running"}))})}return b6(KA,{flexDirection:"column",minHeight:"100%",flexGrow:1,height:R1,children:[W0(T41,{items:r,children:(s,Q1)=>{if(s.type==="welcome")return W0(E7A,{},"welcome");let J1=Q1===0?0:1;return s.type==="message"?W0(U7A,{message:s.message,marginTop:J1},s.id):W0(N5A,{toolUse:s.toolUse,toolResult:s.toolResult,marginTop:J1},s.id)}},a),b6(KA,{flexDirection:"column",marginTop:r.length>1?1:0,children:[H&&W0(Y7A,{message:H}),W0(w5A,{activeTools:g,subagents:U}),b6(KA,{flexDirection:z1?"row-reverse":"column",children:[w.length>0&&W0(KA,{ref:j,flexGrow:0,flexShrink:0,width:z1?"50%":"100%",children:W0(q7A,{todos:w})}),n==="ui-error"&&R.uiError?W0(u41,{title:Mf1(R.uiError).title,description:Mf1(R.uiError).description,options:[{value:"dismiss",label:"Dismiss"}],onSelect:Z1}):n==="ephemeral-error"&&D1?W0(i5A,{error:D1,onResponse:B1,ampURL:Z}):n==="confirming"&&S?W0(k5A,{currentConfirmation:S,onConfirmationResponse:K1}):n==="help"?W0(_f1,{dependencies:[w],children:(s)=>W0(o5A,{width:s})}):W0(KA,{flexGrow:1,borderStyle:"round",paddingX:1,children:W0(_f1,{dependencies:[w],children:(s)=>W0(e5A,{onSubmit:k,history:Q,disabled:n==="confirming"||n==="ephemeral-error"||Y.state==="active"&&Y.summaryState==="summarizing",viewState:Y,editorState:P,editorDispatch:$,onSlashCommandQuery:v,width:s})})})]}),W0(X7A,{view:n,threadViewState:Y,threadTokenUsage:N,hasCompletedMessages:E.items.length>0}),W0(ce6,{commands:y,onSelect:_}),W0(de6,{completions:d.options,onSelect:l})]})]})}function ce6({commands:A,onSelect:Q}){let D=I5.useMemo(()=>A.slice(0,10).map((J)=>({value:J.name,label:J.name,description:J.description})),[A]);return W0(KA,{marginBottom:1,children:W0(VV,{title:"Select command:",options:D,onSelect:Q})})}function de6({completions:A,onSelect:Q}){let B=Math.min(10),D=I5.useMemo(()=>A.slice(0,B).map((z)=>({value:z,label:z})),[A,B]),J=I5.useCallback((z)=>{if(z===null)return;let K=A.find((Z)=>Z===z);if(!K)return;Q(K)},[A,Q]);if(D.length===0)return null;return W0(KA,{marginBottom:1,children:W0(VV,{title:"Insert file name:",options:D,onSelect:J})})}function I7A(A){let{worker:Q,threadID:B,settingsStorage:D,pipedInput:J,workerDeps:z,configService:K,fuzzyServer:Z}=A,[G,X]=LX.useState(!1),Y=LX.useCallback((I,W,M,N)=>{return le6(I,W,M,N,D,Q,z)},[D,Q,z]),U=LX.useCallback(async(I)=>{await Q.handle({type:"user:message",message:{content:[{type:"text",text:I}]}})},[Q]),{exit:F}=If1(),E=LX.useCallback(()=>{fK.cancel(B)},[B]);LX.useEffect(()=>{let I=setTimeout(()=>{X(!0)},500);return()=>clearTimeout(I)},[]);let H=LX.useRef(!1);if(LX.useEffect(()=>{if(H.current)return;if(J)H.current=!0,U(J),X(!0)},[J,U]),!G)return W0(H7A,{});let w=new Nf1;return W0(Z5A,{configService:K,children:W0(z5A,{fuzzyServer:Z,children:W0(w7A,{history:A.history,threadService:A.threadService,worker:Q,sendToolConfirmation:Y,sendUserMessage:U,exit:F,cancel:E,ampURL:A.ampURL,commands:w})})})}async function le6(A,Q,B,D,J,z,K){let Z=B&&B.length>0||!1;if(B&&B.length>0)await C6(i2).then((X)=>X.settings["experimental.commandApproval.enabled"]?"experimental.commandApproval.allow":"commands.allowlist").then((X)=>{J.get(X,"global").then((Y)=>{let U=[...Y??[],...B];return J.set(X,U,"global")}).catch((Y)=>{S1.error("Failed to update allowlist",Y)})});let G={type:"user:tool-input",toolUse:A,value:{accepted:Q||Z}};if(D)(await fK.getOrCreateForThread(K,D)).handle(G);else z.handle(G)}global.React=Sf1.default;function W7A(A){return C0.level=1,wf1(Sf1.default.createElement(I7A,{...A}),{patchConsole:!0,exitOnCtrlC:!1,stdout:A.stdout,stdin:A.stdin}).waitUntilExit().then(async()=>{let{threadID:B,ampURL:D,threadService:J}=A;if((await J.get(B))?.messages.length!==0){let K=`${D.replace(/\/$/,"")}/threads/${B}`;A.stdout.write(`
4628
4628
  `),A.stdout.write(`${C0.dim("Thread:")} ${K}
4629
4629
  `),A.stdout.write(`${C0.dim("Continue this thread with:")} amp threads continue ${B}
4630
- `)}})}var ff1=kf1.join(C1A||kf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");async function yf1(A){try{await ee6(kf1.dirname(ff1),{recursive:!0}),await Q12(ff1,A,"utf-8")}catch(Q){S1.debug("Failed to save last thread ID",Q)}}async function V7A(){try{return(await A12(ff1,"utf-8")).trim()}catch(A){return null}}async function B12(A){let Q=await _Q(`/api/threads/${A}`);if(!Q.ok){let B=await Q.text();if(Q.status===404||B.includes("not found"))throw new Qz(_Z.threadNotFound(A));throw new Qz(`Failed to load thread ${A}`,1,`Use 'amp threads share ${A} --support' to share this with the Amp team if this persists.`)}return await Q.json()}var j7A=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,R7A=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"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??HW,description:`Custom settings file path (overrides the default location ${HW})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(S1).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:"Set log file location"},{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:j7A,description:(A)=>A?"Enable JetBrains integration. Requires the JetBrains MCP plugin to be installed and you must start Amp in the same directory as your JetBrains project. When enabled, Amp automatically includes your open JetBrains file and text selection with every message, just like it does in VS Code.":"Disable JetBrains integration.",hidden:!0},{name:"interactive",long:"interactive",type:"flag",description:(A)=>A?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0}],L7A=(A)=>("deprecated"in A)&&A.deprecated===!0,D12=(A)=>("hidden"in A)&&A.hidden===!0,J12=(A)=>("default"in A),z12=(A)=>("default"in A)?A.default:void 0;function K12(A,Q){let B=Q.args[0],D=Q.commands.map((z)=>z.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let z=D.filter((Z)=>B.includes(Z)||Z.includes(B)),K="Run amp --help for a list of available commands.";if(z.length>0)K=`Did you mean: ${z.join(", ")}? Or run amp --help for all commands.`;throw new Qz(_Z.unknownCommand(B),1,K)}}async function wS(A,Q){sh1("0.0.1753417098-g499a98");let B=Q.settingsFile;S1.info("Using settings file",{settingsFile:B});let D=xv1(Vp()),J=Op({settingsFile:B}),z=BB1({storage:J,secretStorage:D,workspaceRoots:UA.of([t6.file(process.cwd())]),defaultAmpURL:A.ampURL}),K=zv(),Z=sa1({configService:z,toolService:K});try{await Z.initialized}catch(O){S1.warn("Failed to wait for MCP servers, continuing anyway:",O)}let G=await C6(i2);if(Q.dangerouslyAllowAll)G.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(G.settings["jetbrains.enabled"]=!0,ll.subscribe((R)=>{S1.info("jetbrains-status",R)}),await VH(),!await sp1()){if(j7A)S2.write(A.printer.print("Error: ",{foreground:"red",style:"bold"})+"JetBrains integration failed. Try again with `amp --no-jetbrains` or see setup: https://ampcode.com/manual#jetbrains");else S2.write(A.printer.print("Error: ",{foreground:"red",style:"bold"})+"Cannot connect to JetBrains IDE. Check setup: https://ampcode.com/manual#jetbrains");process.exit(1)}}let X=G.settings["experimental.reviewTool"]??!1,Y=G.settings["experimental.tools"]??[];tP1(K,!1,X,Y);let U,F;if(!A.executeMode){U=Y8A(G.settings,process.cwd()),await U.start();try{await U8A(U,process.cwd())}catch(O){S1.error("Failed to index files for fuzzy completion",O)}F=q8A(U,process.cwd())}else U=new class{async start(){}async query(){return[]}dispose(){}},F={[Symbol.dispose]:()=>{}};if(!await D.get("apiKey",A.ampURL)){if(Q5.write(`No API key found. Starting login flow...
4630
+ `)}})}var ff1=kf1.join(C1A||kf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");async function yf1(A){try{await ee6(kf1.dirname(ff1),{recursive:!0}),await Q12(ff1,A,"utf-8")}catch(Q){S1.debug("Failed to save last thread ID",Q)}}async function V7A(){try{return(await A12(ff1,"utf-8")).trim()}catch(A){return null}}async function B12(A){let Q=await _Q(`/api/threads/${A}`);if(!Q.ok){let B=await Q.text();if(Q.status===404||B.includes("not found"))throw new Qz(_Z.threadNotFound(A));throw new Qz(`Failed to load thread ${A}`,1,`Use 'amp threads share ${A} --support' to share this with the Amp team if this persists.`)}return await Q.json()}var j7A=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,R7A=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"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??HW,description:`Custom settings file path (overrides the default location ${HW})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(S1).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:"Set log file location"},{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:j7A,description:(A)=>A?"Enable JetBrains integration. Requires the JetBrains MCP plugin to be installed and you must start Amp in the same directory as your JetBrains project. When enabled, Amp automatically includes your open JetBrains file and text selection with every message, just like it does in VS Code.":"Disable JetBrains integration.",hidden:!0},{name:"interactive",long:"interactive",type:"flag",description:(A)=>A?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0}],L7A=(A)=>("deprecated"in A)&&A.deprecated===!0,D12=(A)=>("hidden"in A)&&A.hidden===!0,J12=(A)=>("default"in A),z12=(A)=>("default"in A)?A.default:void 0;function K12(A,Q){let B=Q.args[0],D=Q.commands.map((z)=>z.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let z=D.filter((Z)=>B.includes(Z)||Z.includes(B)),K="Run amp --help for a list of available commands.";if(z.length>0)K=`Did you mean: ${z.join(", ")}? Or run amp --help for all commands.`;throw new Qz(_Z.unknownCommand(B),1,K)}}async function wS(A,Q){sh1("0.0.1753430532-gb4f1dc");let B=Q.settingsFile;S1.info("Using settings file",{settingsFile:B});let D=xv1(Vp()),J=Op({settingsFile:B}),z=BB1({storage:J,secretStorage:D,workspaceRoots:UA.of([t6.file(process.cwd())]),defaultAmpURL:A.ampURL}),K=zv(),Z=sa1({configService:z,toolService:K});try{await Z.initialized}catch(O){S1.warn("Failed to wait for MCP servers, continuing anyway:",O)}let G=await C6(i2);if(Q.dangerouslyAllowAll)G.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(G.settings["jetbrains.enabled"]=!0,ll.subscribe((R)=>{S1.info("jetbrains-status",R)}),await VH(),!await sp1()){if(j7A)S2.write(A.printer.print("Error: ",{foreground:"red",style:"bold"})+"JetBrains integration failed. Try again with `amp --no-jetbrains` or see setup: https://ampcode.com/manual#jetbrains");else S2.write(A.printer.print("Error: ",{foreground:"red",style:"bold"})+"Cannot connect to JetBrains IDE. Check setup: https://ampcode.com/manual#jetbrains");process.exit(1)}}let X=G.settings["experimental.reviewTool"]??!1,Y=G.settings["experimental.tools"]??[];tP1(K,!1,X,Y);let U,F;if(!A.executeMode){U=Y8A(G.settings,process.cwd()),await U.start();try{await U8A(U,process.cwd())}catch(O){S1.error("Failed to index files for fuzzy completion",O)}F=q8A(U,process.cwd())}else U=new class{async start(){}async query(){return[]}dispose(){}},F={[Symbol.dispose]:()=>{}};if(!await D.get("apiKey",A.ampURL)){if(Q5.write(`No API key found. Starting login flow...
4631
4631
  `),!await Z12(A,D))process.exit(1)}let E=Xr1(),H=new HX1(E),w=new qX1(E),I=new nq1(H),W=Q.notifications!==void 0?Q.notifications:!A.executeMode,M=B1A({playNotificationSound:async(O)=>{if(W)Q1A(O)},windowFocused:()=>Promise.resolve(!1),threadService:H,notifyForSubagents:!1});S1.info("Starting Amp background services");let N=l80({threadService:H,threadHistoryService:w,isExtensionDevelopment:!1});return{configService:z,toolService:K,mcpService:Z,threadService:H,threadHistoryService:w,threadSummaryService:I,threadSyncService:N,threadStorage:E,secretStorage:D,settingsStorage:J,fileWatcher:F,fuzzyServer:U,notificationService:M}}async function Z12(A,Q){if(!A.executeMode){if(await g91("Would you like to log in to Amp?",["(y)es","(n)o"])!="y")return Q5.write(`Login cancelled. Run the command again to retry.
4632
4632
  `),!1}return await P7A(A,Q)}async function P7A(A,Q){let B=te6(32).toString("hex"),D=await x8A(A.ampURL,B);Q5.write(`If your browser doesn't open automatically, visit:
4633
4633
 
@@ -4641,7 +4641,7 @@ ${C0.blue.bold(D)}
4641
4641
  Login successful! You can now use the Amp CLI.
4642
4642
  `),!0}catch(J){return S2.write(`
4643
4643
  Login failed: ${J instanceof Error?J.message:String(J)}
4644
- `),!1}}function G12(A){let Q=new tu().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, team)").configureOutput({writeErr:()=>{}});Q.exitOverride((X)=>{if(X.code==="commander.help"||X.code==="commander.version"||X.exitCode===0)Lp(),process.exit(0);let Y=X.originalError??X;n_(A,Y)}),Q.option("-V, --version","output the version number",()=>{Q5.write(`0.0.1753417098-g499a98 (released 2025-07-25T04:22:59.056Z)
4644
+ `),!1}}function G12(A){let Q=new tu().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, team)").configureOutput({writeErr:()=>{}});Q.exitOverride((X)=>{if(X.code==="commander.help"||X.code==="commander.version"||X.exitCode===0)Lp(),process.exit(0);let Y=X.originalError??X;n_(A,Y)}),Q.option("-V, --version","output the version number",()=>{Q5.write(`0.0.1753430532-gb4f1dc (released 2025-07-25T08:10:06.853Z)
4645
4645
  `),process.exit(0)}),Q.addHelpText("after",f8A()),Q.configureHelp({formatHelp:y8A}),Q.command("logout").description("Log out by removing stored API key").action(async()=>{let X=DK(),Y=Vp();if(process.env.AMP_API_KEY)Q5.write(`API key found in environment variable AMP_API_KEY, unset first before running 'amp logout'
4646
4646
  `),process.exit(0);if(!await Y.get("apiKey",X.ampURL))Q5.write(`Already logged out.
4647
4647
  `),process.exit(0);await Y.set("apiKey","",X.ampURL),Q5.write(`Successfully logged out.
@@ -4691,10 +4691,10 @@ Summary: ${R}
4691
4691
  `),S2.write(`Secrets have been automatically redacted, but please review the file before attaching
4692
4692
  `),S2.write(`it to support requests. Learn more at https://ampcode.com/manual/appendix#support-bundles
4693
4693
  `),process.exit(0)}catch(U){S2.write(A.printer.print("Error generating support bundle: ",{foreground:"red"})+`${U instanceof Error?U.message:String(U)}
4694
- `),process.exit(1)}}),Q.addCommand(K);let Z=new tu("update").description("Update Amp CLI to the latest version").option("--version <version>","Update to a specific version").allowUnknownOption(!1);Z.action(async(X,Y)=>{try{let U=Y.optsWithGlobals(),{update:F}=await Promise.resolve().then(() => (O7A(),C7A)),{checkNpmUpdate:E}=await Promise.resolve().then(() => (iG1(),Ur1)),H="0.0.1753417098-g499a98";if(U.version)S2.write(C0.blue(`Updating to version ${U.version}...
4694
+ `),process.exit(1)}}),Q.addCommand(K);let Z=new tu("update").description("Update Amp CLI to the latest version").option("--version <version>","Update to a specific version").allowUnknownOption(!1);Z.action(async(X,Y)=>{try{let U=Y.optsWithGlobals(),{update:F}=await Promise.resolve().then(() => (O7A(),C7A)),{checkNpmUpdate:E}=await Promise.resolve().then(() => (iG1(),Ur1)),H="0.0.1753430532-gb4f1dc";if(U.version)S2.write(C0.blue(`Updating to version ${U.version}...
4695
4695
  `)),await F(U.version),S2.write(C0.green(`✓ Successfully updated to version ${U.version}
4696
4696
  `));else{S2.write(C0.blue(`Checking for updates...
4697
- `));let w=await E("0.0.1753417098-g499a98");if(!w.hasUpdate)S2.write(C0.green(`✓ Amp CLI is already up to date.
4697
+ `));let w=await E("0.0.1753430532-gb4f1dc");if(!w.hasUpdate)S2.write(C0.green(`✓ Amp CLI is already up to date.
4698
4698
  `)),process.exit(0);S2.write(C0.blue(`Updating to version ${w.latestVersion}...
4699
4699
  `)),await F(w.latestVersion),S2.write(C0.green(`✓ Successfully updated to version ${w.latestVersion}
4700
4700
  `))}process.exit(0)}catch(U){S2.write(C0.red("Error updating: ")+`${U instanceof Error?U.message:String(U)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1753417098-g499a98",
3
+ "version": "0.0.1753430532-gb4f1dc",
4
4
  "description": "CLI for Amp, an agentic coding tool in research preview from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {