@sourcegraph/amp 0.0.1753860451-g956c8f → 0.0.1753862480-g956c8f

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
@@ -4664,7 +4664,7 @@ ${Y}`}else G=z.map((K)=>` ${K}`).join(`
4664
4664
  `});return}if(U.trim().length>0)P(U.trim());else return;return}if(!S.ctrl&&!S.meta&&!S.tab&&$)z({type:"insert-text",text:$})});let P=async($)=>{I(null),Q.add($),Q.reset();try{A($)}catch(S){P1.error("Failed to submit message",S)}};return V6(JA,{flexDirection:"column",width:"100%",flexGrow:1,flexShrink:0,ref:X,children:[J.imageAttachments.length>0&&V6(JA,{flexDirection:"row",marginBottom:1,children:[M0(HA,{color:"gray",children:"Images: "}),J.imageAttachments.map(($,S)=>V6(HA,{color:"green",children:["[image ",S+1,"]",S<J.imageAttachments.length-1?" ":""]},S))]}),H.lines.map(($,S)=>M0(JA,{flexShrink:0,flexDirection:"row",children:M0(JA,{flexGrow:1,flexShrink:0,width:"100%",children:S===M.line?V6(BZ,{children:[M0(HA,{dimColor:B,children:VS.default.substr($.content,0,M.column)||""}),M0(HA,{inverse:!B,dimColor:B,children:VS.default($.content)[M.column]??" "}),M0(HA,{dimColor:B,children:VS.default.substr($.content,M.column+1)||""})]}):M0(HA,{dimColor:B,children:$.content||" "})})},S))]})}function G12(A,Q){let B=VS.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 LS=xA(D8(),1);TH();var A51=xA(D8(),1);function q7A(){let[A,Q]=A51.useState(null);return A51.useEffect(()=>{let B=Qi.subscribe(Q);return()=>{B.unsubscribe()}},[]),{jetbrainsState:A}}rQ1();var uf1=xA(D8(),1);function F7A({viewState:A}){let Q=uf1.useMemo(()=>{return A.state==="active"?A.fileChanges:void 0},[A]),B=uf1.useMemo(()=>mh1(Q),[Q]);if(!Q||B.totalFiles===0)return null;let D=B.totalFiles-B.revertedFiles;return V6(JA,{gap:1,children:[V6(HA,{dimColor:!0,children:[D," ",D===1?"file":"files"," changed"]}),(B.totalAdded>0||B.totalModified>0||B.totalRemoved>0)&&V6(HA,{children:[V6(HA,{color:"green",children:["+",B.totalAdded]}),V6(HA,{color:"yellow",children:[" ~",B.totalModified]}),V6(HA,{color:"red",children:[" -",B.totalRemoved]})]})]})}import E7A from"node:path";function H7A({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=E7A.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 M0(JA,{gap:B?1:2,children:V6(HA,{color:B?"green":"red",children:[B?"✓":"×"," ",A.productName??"JetBrains"," ",B?"• "+E7A.basename(A.openFile??""):D]})})}var Q51=xA(D8(),1);function w7A(){let[A,Q]=Q51.useState(0);Q51.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 M0(HA,{dimColor:D.dim,children:D.char})}var K12=0.8,X12=0.9;function I7A({tokenUsage:A}){let Q=A.totalInputTokens/A.maxInputTokens,B=Math.round(Q*100),J=`${Math.max(0,Math.min(B,100))}%`,z,Z=W7A(Q);if(Z==="danger")z="red";else if(Z==="warning")z="yellow";return M0(HA,{color:z,children:J})}function W7A(A){if(A>=X12)return"danger";else if(A>=K12)return"warning";return!1}function M7A(A){let Q=A.totalInputTokens/A.maxInputTokens;return W7A(Q)}function N7A({threadViewState:A,tokenUsage:Q,waitingForConfirmation:B,showingEphemeralError:D}){let J=null,z=Q?M7A(Q):!1,Z=!1;if(A&&A.state==="active"){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.",Z=!0;else if(!D&&z==="danger")J="Context window is close to full. Use /compact to trim the thread.",Z=!0}let G=Boolean(A&&A.state==="active"&&A.inferenceState!=="cancelled"&&!Z&&!B);if(!A||A.state!=="active"||!J)return null;let X=()=>{if(A.inferenceState==="running"&&A.interactionState!=="tool-running")return"blueBright";if(A.interactionState==="tool-running")return"greenBright";return"default"},Y=()=>{if(Z&&z==="warning")return"yellow";if(Z&&z==="danger")return"red";if(A.inferenceState==="cancelled")return"dim";return"default"};return V6(JA,{flexDirection:"row",gap:1,children:[G&&M0(HA,{color:X(),children:M0(w7A,{})}),M0(HA,{italic:!Z&&A.inferenceState==="cancelled",color:Y(),children:J})]})}function C7A({view:A,threadViewState:Q,threadTokenUsage:B,hasCompletedMessages:D,width:J}){let{jetbrainsState:z}=q7A(),Z=LS.useRef(null),{stdout:G}=PX(),[K,X]=LS.useState(G.columns);LS.useEffect(()=>{if(Z.current){let{width:H}=OV(Z.current);X(H)}},[G.columns]);let Y=J||K,U=Y&&Y<60,F=A==="confirming"||A==="ephemeral-error",E=Q.state==="active"&&(Q.inferenceState==="running"||Q.interactionState==="tool-running")&&!F;return V6(JA,{gap:2,marginLeft:2,marginRight:2,ref:Z,children:[V6(JA,{flexGrow:1,flexDirection:"row",gap:2,children:[M0(N7A,{threadViewState:Q,tokenUsage:B,waitingForConfirmation:F,showingEphemeralError:A==="ephemeral-error"}),E&&M0(JA,{children:M0(HA,{dimColor:!0,children:"Esc to cancel"})}),V6(JA,{children:[A==="confirming-exit"&&M0(HA,{dimColor:!0,children:"Ctrl+C again to exit"}),A==="help"&&M0(HA,{dimColor:!0,children:"Escape to close help"}),D&&A==="running"&&!U&&M0(HA,{dimColor:!0,children:"Ctrl+R to expand"})]})]}),V6(JA,{flexGrow:0,gap:2,children:[M0(H7A,{jetbrainsStatus:z}),!U&&M0(F7A,{viewState:Q}),B&&M0(I7A,{tokenUsage:B})]})]})}j6();w0.level=1;var Y12={code:w0.white,codespan:w0.white,blockquote:w0.gray.italic,html:w0.gray,heading:w0.bold,firstHeading:w0.bold,hr:w0.reset,table:w0.reset,paragraph:w0.reset,strong:w0.bold,em:w0.italic,del:w0.dim.gray.strikethrough,link:w0.cyan,href:w0.cyan,unescape:!0,emoji:!0,showSectionPrefix:!0,reflowText:!1,tab:4,tableOptions:{wordWrap:!0,wrapOnWordBoundary:!1,style:{head:["bold"],border:["grey"],compact:!1}}},U12={keyword:w0.bold,built_in:w0.dim,type:w0.dim,literal:w0.italic,number:w0.reset,regexp:w0.dim.italic,string:w0.dim,subst:w0.reset,symbol:w0.reset,class:w0.bold,function:w0.reset,title:w0.reset,params:w0.reset,comment:w0.dim.italic,doctag:w0.dim.italic,meta:w0.dim,"meta-keyword":w0.reset,"meta-string":w0.reset,section:w0.reset,tag:w0.dim,name:w0.bold,"builtin-name":w0.reset,attr:w0.dim,attribute:w0.reset,variable:w0.reset,bullet:w0.reset,code:w0.reset,emphasis:w0.italic,strong:w0.bold,formula:w0.reset,link:w0.underline,quote:w0.reset,"selector-tag":w0.reset,"selector-id":w0.reset,"selector-class":w0.reset,"selector-attr":w0.reset,"selector-pseudo":w0.reset,"template-tag":w0.reset,"template-variable":w0.reset,addition:w0.bold.underline,deletion:w0.dim.strikethrough,default:w0.reset};J9.use(y2A({...Y12,reflowText:!1},{ignoreIllegals:!0,theme:U12}));function B51({children:A}){let Q;try{Q=J9(A,{async:!1}).trimEnd()}catch(B){P1.error("Markdown rendering failed",B,{input:A}),Q=A}return M0(HA,{children:Q})}function O7A({message:A}){let Q=A.content.filter((B)=>B.type==="thinking"||B.type==="text");if(!Q.length)return null;return M0(JA,{flexDirection:"column",marginBottom:1,children:Q.map((B,D)=>{let J=D>0?1:0;if(B.type==="thinking")return M0(e41,{thinking:B.thinking},D);else return M0(JA,{marginTop:J,children:M0(B51,{children:B.text})},D);return null})})}function V7A({message:A,marginTop:Q=0}){if(!A.content.some((X)=>X.type==="text"||X.type==="image"||X.type==="thinking"||X.type==="summary"&&X.summary.type==="message"))return null;let D=A.role==="assistant"&&A.state.type==="cancelled",J=A.content.filter((X)=>X.type==="text"),z=A.content.filter((X)=>X.type==="image"),Z=A.content.filter((X)=>X.type==="thinking"),G=A.content.filter((X)=>X.type==="summary"&&("summary"in X)&&X.summary.type==="message"),K=()=>{if(z.length===0)return null;return V6(JA,{flexDirection:"row",gap:1,marginBottom:1,children:[M0(HA,{color:"gray",children:"Images:"}),z.map((X,Y)=>{return V6(HA,{color:"green",children:["[image ",Y+1,"]"]},`img-${Y}`)})]})};return V6(JA,{flexDirection:"column",gap:1,marginTop:Q,children:[Z.map((X,Y)=>M0(e41,{thinking:X.thinking},`thinking-${Y}`)),J.map((X,Y)=>{switch(A.role){case"assistant":return M0(JA,{flexDirection:"column",children:M0(B51,{children:X.text})},Y);case"user":return V6(JA,{borderStyle:"bold",borderColor:"green",borderLeft:!0,borderTop:!1,borderBottom:!1,borderRight:!1,paddingLeft:1,flexDirection:"column",children:[K(),M0(HA,{color:"green",italic:!0,children:X.text})]},Y);default:return null}}),G.map((X,Y)=>M0(JA,{children:V6(HA,{color:"grey",italic:!0,children:["Summary: ",X.summary.summary]})},`summary-${Y}`)),D&&M0(JA,{children:M0(HA,{italic:!0,dimColor:!0,children:"Cancelled"})})]})}function L7A({todos:A}){if(!Array.isArray(A)||A.length===0)return null;return V6(JA,{borderStyle:"round",borderColor:"dim",paddingX:1,flexDirection:"column",flexGrow:1,flexShrink:0,children:[M0(JA,{children:M0(HA,{dimColor:!0,bold:!0,children:"TODOs"})}),A.map((Q,B)=>M0(JA,{gap:1,children:V6(HA,{dimColor:!0,wrap:"truncate",children:[M0(HA,{children:"• "}),M0(HA,{bold:Q.status==="in-progress",strikethrough:Q.status==="completed",children:Q.content})]})},Q.id))]})}var TW=xA(D8(),1);function pf1({children:A,dependencies:Q}){let{stdout:B}=PX(),D=TW.useRef(null),[J,z]=TW.useState(B.columns),Z=TW.useCallback(()=>{if(D.current){let{width:G}=OV(D.current);z(G)}},[D,z]);return TW.useLayoutEffect(Z,[Z,B.columns,...Q||[]]),M0(JA,{width:"100%",height:"100%",ref:D,children:A(J)})}j6();x6();var RB=xA(D8(),1),D51=Object.freeze({query:"",options:[]});function R7A(A){let[Q,B]=RB.useState(D51),[D,J]=RB.useState(""),[z,Z]=RB.useState(null),G=RB.useRef(0),[K]=RB.useState(()=>new y8),X=RB.useCallback((H)=>{if(J(H),H!==z)Z(null)},[z]),Y=RB.useCallback(()=>Z(D),[D]),U=RB.useCallback((H)=>{K.next(H)},[K]),F=RB.useMemo(()=>D.startsWith("@")?D.slice(1):null,[D]);RB.useEffect(()=>{if(F!==null&&D!==z){let w=++G.current;(async()=>{try{let W=await A.query(F);if(w===G.current)B({query:F,options:W})}catch(W){if(w===G.current)P1.error("Completion request failed",{query:F,error:W}),B(D51)}})()}else B(D51)},[D,z,A,F]),RB.useEffect(()=>{return()=>{K.complete()}},[K]);let E=RB.useMemo(()=>{if(F===null)return!1;return F.startsWith(Q.query)&&z!==D&&D!==""},[Q,D,z,F]);return{completions:E?Q:D51,hasCompletions:E?Q.options.length>0:!1,selectCompletion:U,completionSelected:K,onWordHighlight:X,ignore:Y}}var J51=xA(D8(),1);function T7A(A){let Q=J51.useMemo(()=>process.cwd().replace(process.env.HOME||"","~"),[]);J51.useEffect(()=>{if(A)process.stdout.write(`\x1B]0;amp - ${A} - ${Q}\x07`);return()=>{process.stdout.write("\x1B]0;\x07")}},[A,Q])}var z51=xA(D8(),1);function j7A(){return M0(JA,{flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:3,marginLeft:4,children:M0(JA,{children:M0(HA,{color:"green",bold:!0,children:"Welcome to Amp"})})})}function P7A(){let[A,Q]=z51.useState(0),B=["Amp","AMP","AmP","amP","aMP","AMp"];return z51.useEffect(()=>{let D=setInterval(()=>{Q((J)=>(J+1)%B.length)},50);return()=>clearInterval(D)},[B.length]),M0(JA,{flexDirection:"column",alignItems:"flex-start",justifyContent:"center",minHeight:3,marginLeft:4,children:M0(JA,{children:V6(HA,{color:"green",bold:!0,children:["Welcome to ",B[A]]})})})}var q12=200;function _7A({threadService:A,history:Q,worker:B,sendToolConfirmation:D,sendUserMessage:J,exit:z,cancel:Z,ampURL:G,commands:K,fuzzyClient:X}){let[Y]=t41(),{viewState:U,subagents:F,subagentActiveTools:E,transcript:H,streamingAssistantMessage:w,todosList:I,mainThread:W}=K5A(A,B),M=I5.useMemo(()=>w?H.items.concat({id:"streaming-assistant",type:"message",message:w}):H.items,[w,H.items]),N=W?.title||"Untitled",O=I5.useMemo(()=>W?eh1(W):void 0,[W]);T7A(W?.title);let L=I5.useRef(new y8),[T,R]=I5.useState({baseView:"running",rerendering:!1,resizeCounter:0,dismissedEphemeralError:null,slashCommandQuery:null,uiError:null}),j=I5.useRef(null),P=I5.useRef(null),[$,S]=e5A(),g=I5.useCallback((B1)=>{R((G1)=>({...G1,slashCommandQuery:B1}))},[]),u=I5.useMemo(()=>{if(T.slashCommandQuery===null)return[];return K.query(T.slashCommandQuery)},[T.slashCommandQuery,K]),_=I5.useCallback(()=>{R((B1)=>({...B1,rerendering:!0})),process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),L.current.next()},[R,L]),k=I5.useCallback(async(B1)=>{if(R((I1)=>({...I1,slashCommandQuery:null})),!B1||!W)return;let G1=!1,Y1=(I1)=>{G1=!0,S(I1)},R1=()=>{R((I1)=>({...I1,baseView:"help"}))},V1=await K.get(B1).execute({worker:B,thread:W,editorDispatch:Y1,exitApp:z,openHelp:R1});if(R((I1)=>({...I1,uiError:V1||null})),!G1)S({type:"clear"})},[K,S,W,B,z]),b=I5.useCallback((B1)=>{let G1=[{type:"text",text:B1}];if($.imageAttachments.length>0)G1.push(...$.imageAttachments);S({type:"clear"}),J(G1)},[S,$.imageAttachments,J]);I5.useEffect(()=>{return process.stdout.on("resize",_),()=>{process.stdout.off("resize",_)}},[_]),I5.useEffect(()=>{let B1=L.current.pipe(MD(q12)).subscribe(()=>{R((G1)=>({...G1,rerendering:!1,resizeCounter:G1.resizeCounter+1}))});return()=>{B1.unsubscribe()}},[L,R]),I5.useEffect(()=>{let B1=L.current,G1=j.current;return()=>{if(B1.complete(),G1)clearTimeout(G1)}},[L]);let m=[...H.activeTools,...E],v=m.filter((B1)=>B1.toolRun.status==="blocked-on-user"),h=I5.useMemo(()=>x5A(v),[v]),d=R7A(X),{hasCompletions:l,completions:D1,selectCompletion:n}=d,z1=I5.useMemo(()=>{if(U.state!=="active"||!U.ephemeralError)return null;if(T.dismissedEphemeralError===U.ephemeralError)return null;return U.ephemeralError},[U,T.dismissedEphemeralError]),Q1=T.uiError!==null?"ui-error":z1!==null?"ephemeral-error":h!==null?"confirming":T.baseView,K1=(B1)=>{if(!h||h.type!=="tool-use")return;if(h.tools.length>0){let G1=h.tools[0],Y1=Array.from(B1==="always"?G1.toAllow??[]:[]);D(G1.useBlock.id,B1==="yes"||B1==="always",Y1,h.subthreadID)}},Z1=(B1)=>{switch(B1){case"compact":R((G1)=>({...G1,dismissedEphemeralError:null})),B.summarizeThread();break;case"dismiss":R((G1)=>({...G1,dismissedEphemeralError:z1}));break;case"retry":R((G1)=>({...G1,dismissedEphemeralError:null})),B.retry();break;default:P1.warn("action:",{action:B1})}},L1=()=>{R((B1)=>({...B1,uiError:null}))};pE((B1,G1)=>{if(G1.ctrlC){if(T.baseView==="confirming-exit"){if(j.current)clearTimeout(j.current),j.current=null;z()}else{if(R((R1)=>({...R1,baseView:"confirming-exit"})),j.current)clearTimeout(j.current);let Y1=setTimeout(()=>{R((R1)=>({...R1,baseView:"running"})),j.current=null},1000);j.current=Y1}return}if(Q1==="help"){if(G1.escape)R((Y1)=>({...Y1,baseView:"running"}));return}if(Q1==="expanded-view"||Q1==="confirming"||Q1==="ephemeral-error")return;if(Q1==="ui-error")return;if(G1.escape)if(l||u.length>0)return;else Z();else if(G1.ctrl&&B1.toLowerCase()==="r")R((Y1)=>({...Y1,baseView:"expanded-view"}));else if(G1.ctrlL)_()});let a=Y>100,r=T.rerendering&&H.items.length===0?1:"auto",s="resize-key"+T.resizeCounter,J1=[{type:"welcome",id:"welcome"},...H.items];if(T.baseView==="expanded-view"){let B1=M.filter((G1)=>G1.type==="message").map((G1)=>G1.message);return M0(B7A,{threadName:N,messages:B1,onExit:()=>R((G1)=>({...G1,baseView:"running"}))})}return V6(JA,{flexDirection:"column",minHeight:"100%",flexGrow:1,height:r,children:[M0(v41,{items:J1,children:(B1,G1)=>{if(B1.type==="welcome")return M0(j7A,{},"welcome");let Y1=G1===0?0:1;return B1.type==="message"?M0(V7A,{message:B1.message,marginTop:Y1},B1.id):M0(g5A,{toolUse:B1.toolUse,toolResult:B1.toolResult,marginTop:Y1},B1.id)}},s),V6(JA,{flexDirection:"column",marginTop:J1.length>1?1:0,children:[w&&M0(O7A,{message:w}),M0(w5A,{activeTools:m,subagents:F}),V6(JA,{flexDirection:a?"row-reverse":"column",children:[I.length>0&&M0(JA,{ref:P,flexGrow:0,flexShrink:0,width:a?"50%":"100%",children:M0(L7A,{todos:I})}),Q1==="ui-error"&&T.uiError?M0(s41,{title:Vf1(T.uiError).title,description:Vf1(T.uiError).description,options:[{value:"dismiss",label:"Dismiss"}],onSelect:L1}):Q1==="ephemeral-error"&&z1?M0(Q7A,{error:z1,onResponse:Z1,ampURL:G}):Q1==="confirming"&&h?M0(p5A,{currentConfirmation:h,onConfirmationResponse:K1}):Q1==="help"?M0(pf1,{dependencies:[I],children:(B1)=>M0(Z7A,{width:B1})}):M0(JA,{flexGrow:1,borderStyle:"round",paddingX:1,children:M0(pf1,{dependencies:[I],children:(B1)=>M0(U7A,{onSubmit:b,history:Q,disabled:Q1==="confirming"||Q1==="ephemeral-error"||U.state==="active"&&U.summaryState==="summarizing",viewState:U,editorState:$,editorDispatch:S,onSlashCommandQuery:g,width:B1,completionsState:d})})})]}),M0(C7A,{view:Q1,threadViewState:U,threadTokenUsage:O,hasCompletedMessages:H.items.length>0}),M0(F12,{commands:u,onSelect:k}),M0(E12,{completions:D1.options,onSelect:n})]})]})}function F12({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 M0(JA,{marginBottom:1,children:M0(jV,{title:"Select command:",options:D,onSelect:Q})})}function E12({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 Z=A.find((G)=>G===z);if(!Z)return;Q(Z)},[A,Q]);if(D.length===0)return null;return M0(JA,{marginBottom:1,children:M0(jV,{title:"Insert file name:",options:D,onSelect:J})})}function S7A(A){let{worker:Q,threadID:B,settingsStorage:D,pipedInput:J,workerDeps:z,configService:Z,fuzzyServer:G}=A,[K,X]=_X.useState(!1);J5A();let Y=_X.useCallback((I,W,M,N)=>{return H12(I,W,M,N,D,Q,z)},[D,Q,z]),U=_X.useCallback(async(I)=>{await Q.handle({type:"user:message",message:{content:I}})},[Q]),{exit:F}=Cf1(),E=_X.useCallback(()=>{xZ.cancel(B)},[B]);_X.useEffect(()=>{let I=setTimeout(()=>{X(!0)},500);return()=>clearTimeout(I)},[]);let H=_X.useRef(!1);if(_X.useEffect(()=>{if(H.current)return;if(J)H.current=!0,U([{type:"text",text:J}]),X(!0)},[J,U]),!K)return M0(P7A,{});let w=new Lf1;return M0(o4A,{configService:Z,children:M0(_7A,{history:A.history,threadService:A.threadService,worker:Q,sendToolConfirmation:Y,sendUserMessage:U,exit:F,cancel:E,ampURL:A.ampURL,commands:w,fuzzyClient:G})})}async function H12(A,Q,B,D,J,z,Z){let G=B&&B.length>0||!1;if(B&&B.length>0)await C6($2).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)=>{P1.error("Failed to update allowlist",Y)})});let K={type:"user:tool-input",toolUse:A,value:{accepted:Q||G}};if(D)(await xZ.getOrCreateForThread(Z,D)).handle(K);else z.handle(K)}global.React=cf1.default;function $7A(A){return w0.level=1,Nf1(cf1.default.createElement(S7A,{...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 Z=`${D.replace(/\/$/,"")}/threads/${B}`;A.stdout.write(`
4665
4665
  `),A.stdout.write(`${w0.dim("Thread:")} ${Z}
4666
4666
  `),A.stdout.write(`${w0.dim("Continue this thread with:")} amp threads continue ${B}
4667
- `)}})}var af1=if1.join(Kp0||if1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");async function rf1(A){try{await V12(if1.dirname(af1),{recursive:!0}),await R12(af1,A,"utf-8")}catch(Q){P1.debug("Failed to save last thread ID",Q)}}async function b7A(){try{return(await L12(af1,"utf-8")).trim()}catch(A){return null}}async function T12(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 tJ(TG.threadNotFound(A));throw new tJ(`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 u7A=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,g7A=[{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??ZW,description:`Custom settings file path (overrides the default location ${ZW})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(P1).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:u7A,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}],x7A=(A)=>("deprecated"in A)&&A.deprecated===!0,j12=(A)=>("hidden"in A)&&A.hidden===!0,P12=(A)=>("default"in A),_12=(A)=>("default"in A)?A.default:void 0;function S12(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((G)=>B.includes(G)||G.includes(B)),Z="Run amp --help for a list of available commands.";if(z.length>0)Z=`Did you mean: ${z.join(", ")}? Or run amp --help for all commands.`;throw new tJ(TG.unknownCommand(B),1,Z)}}async function RS(A,Q){Gm1("0.0.1753860451-g956c8f");let B=Q.settingsFile;P1.info("Using settings file",{settingsFile:B});let D=H$1(eu()),J=JV({settingsFile:B}),z=EB1({storage:J,secretStorage:D,workspaceRoots:UA.of([c6.file(process.cwd())]),defaultAmpURL:A.ampURL,defaultCacheDirectory:X$1}),Z=await C6($2);P1.debug("Global configuration initialized",{hasCacheDirectory:!!Z.settings.cacheDirectory,settingsKeys:Object.keys(Z.settings)});let G=await Yf(Hv()),K=Gr1({configService:z,toolService:G});try{await K.initialized}catch(L){P1.warn("Failed to wait for MCP servers, continuing anyway:",L)}if(Q.dangerouslyAllowAll)Z.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(Z.settings["jetbrains.enabled"]=!0,Qi.subscribe((T)=>{P1.info("jetbrains-status",T)}),await RH(),!await Gc1())if(u7A)MQ("JetBrains integration failed. Try again with `amp --no-jetbrains` or see setup: https://ampcode.com/manual#jetbrains");else MQ("Cannot connect to JetBrains IDE. Check setup: https://ampcode.com/manual#jetbrains")}let X=Z.settings["experimental.reviewTool"]??!1,Y=Z.settings["experimental.tools"]??[];U_1(G,!1,X,Y);let U,F;if(!A.executeMode)U=new sv1(Z.settings,process.cwd()),await U.start(),F=Z8A(U,process.cwd());else U=new class{async start(){}async query(){return[]}dispose(){}},F={[Symbol.dispose]:()=>{}};if(!await D.get("apiKey",A.ampURL)){if(b4.write(`No API key found. Starting login flow...
4667
+ `)}})}var af1=if1.join(Kp0||if1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");async function rf1(A){try{await V12(if1.dirname(af1),{recursive:!0}),await R12(af1,A,"utf-8")}catch(Q){P1.debug("Failed to save last thread ID",Q)}}async function b7A(){try{return(await L12(af1,"utf-8")).trim()}catch(A){return null}}async function T12(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 tJ(TG.threadNotFound(A));throw new tJ(`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 u7A=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,g7A=[{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??ZW,description:`Custom settings file path (overrides the default location ${ZW})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(P1).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:u7A,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}],x7A=(A)=>("deprecated"in A)&&A.deprecated===!0,j12=(A)=>("hidden"in A)&&A.hidden===!0,P12=(A)=>("default"in A),_12=(A)=>("default"in A)?A.default:void 0;function S12(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((G)=>B.includes(G)||G.includes(B)),Z="Run amp --help for a list of available commands.";if(z.length>0)Z=`Did you mean: ${z.join(", ")}? Or run amp --help for all commands.`;throw new tJ(TG.unknownCommand(B),1,Z)}}async function RS(A,Q){Gm1("0.0.1753862480-g956c8f");let B=Q.settingsFile;P1.info("Using settings file",{settingsFile:B});let D=H$1(eu()),J=JV({settingsFile:B}),z=EB1({storage:J,secretStorage:D,workspaceRoots:UA.of([c6.file(process.cwd())]),defaultAmpURL:A.ampURL,defaultCacheDirectory:X$1}),Z=await C6($2);P1.debug("Global configuration initialized",{hasCacheDirectory:!!Z.settings.cacheDirectory,settingsKeys:Object.keys(Z.settings)});let G=await Yf(Hv()),K=Gr1({configService:z,toolService:G});try{await K.initialized}catch(L){P1.warn("Failed to wait for MCP servers, continuing anyway:",L)}if(Q.dangerouslyAllowAll)Z.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(Z.settings["jetbrains.enabled"]=!0,Qi.subscribe((T)=>{P1.info("jetbrains-status",T)}),await RH(),!await Gc1())if(u7A)MQ("JetBrains integration failed. Try again with `amp --no-jetbrains` or see setup: https://ampcode.com/manual#jetbrains");else MQ("Cannot connect to JetBrains IDE. Check setup: https://ampcode.com/manual#jetbrains")}let X=Z.settings["experimental.reviewTool"]??!1,Y=Z.settings["experimental.tools"]??[];U_1(G,!1,X,Y);let U,F;if(!A.executeMode)U=new sv1(Z.settings,process.cwd()),await U.start(),F=Z8A(U,process.cwd());else U=new class{async start(){}async query(){return[]}dispose(){}},F={[Symbol.dispose]:()=>{}};if(!await D.get("apiKey",A.ampURL)){if(b4.write(`No API key found. Starting login flow...
4668
4668
  `),!await $12(A,D))process.exit(1)}let E=Sr1(),H=new _X1(E),w=new TX1(E),I=new XF1(H),W=Q.notifications!==void 0?Q.notifications:!A.executeMode,M=vu0({playNotificationSound:async(L)=>{if(W)$u0(L)},windowFocused:()=>Promise.resolve(!1),threadService:H});P1.info("Starting Amp background services");let N=U90({threadService:H,threadHistoryService:w,isExtensionDevelopment:!1}),O={configService:z,toolService:G,mcpService:K,threadService:H,threadHistoryService:w,threadSummaryService:I,threadSyncService:N,threadStorage:E,secretStorage:D,settingsStorage:J,fileWatcher:F,fuzzyServer:U,notificationService:M};return{...O,async dispose(){await O.mcpService.dispose(),O.configService.unsubscribe(),O.toolService.dispose(),O.fileWatcher[Symbol.dispose](),O.fuzzyServer.dispose(),O.threadSyncService.dispose(),O.settingsStorage[Symbol.dispose]()}}}async function $12(A,Q){if(!A.executeMode){if(await c91("Would you like to log in to Amp?",["(y)es","(n)o"])!="y")return b4.write(`Login cancelled. Run the command again to retry.
4669
4669
  `),!1}return await p7A(A,Q)}async function p7A(A,Q){let B=O12(32).toString("hex"),D=await v8A(A.ampURL,B);b4.write(`If your browser doesn't open automatically, visit:
4670
4670
 
@@ -4678,7 +4678,7 @@ ${w0.blue.bold(D)}
4678
4678
  Login successful! You can now use the Amp CLI.
4679
4679
  `),!0}catch(J){return h9.write(`
4680
4680
  Login failed: ${J instanceof Error?J.message:String(J)}
4681
- `),!1}}function v12(A){let Q=new _u().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)Qp(),process.exit(0);let Y=X.originalError??X;h_(Y)}),Q.option("-V, --version","output the version number",()=>{b4.write(`0.0.1753860451-g956c8f (released 2025-07-30T07:32:26.008Z)
4681
+ `),!1}}function v12(A){let Q=new _u().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)Qp(),process.exit(0);let Y=X.originalError??X;h_(Y)}),Q.option("-V, --version","output the version number",()=>{b4.write(`0.0.1753862480-g956c8f (released 2025-07-30T08:06:05.635Z)
4682
4682
  `),process.exit(0)}),Q.addHelpText("after",P8A()),Q.configureHelp({formatHelp:_8A}),Q.command("logout").description("Log out by removing stored API key").action(async()=>{let X=await Qz(),Y=eu();if(process.env.AMP_API_KEY)b4.write(`API key found in environment variable AMP_API_KEY, unset first before running 'amp logout'
4683
4683
  `),process.exit(0);if(!await Y.get("apiKey",X.ampURL))b4.write(`Already logged out.
4684
4684
  `),process.exit(0);await Y.set("apiKey","",X.ampURL),b4.write(`Successfully logged out.
@@ -4712,10 +4712,10 @@ Summary: ${L}
4712
4712
  `),h9.write(`
4713
4713
  `),h9.write(`Secrets have been automatically redacted, but please review the file before attaching
4714
4714
  `),h9.write(`it to support requests. Learn more at https://ampcode.com/manual/appendix#support-bundles
4715
- `),process.exit(0)}catch(U){MQ(U instanceof Error?U.message:String(U))}}),Q.addCommand(Z);let G=new _u("update").description("Update Amp CLI to the latest version").option("--version <version>","Update to a specific version").allowUnknownOption(!1);G.action(async(X,Y)=>{try{let U=Y.optsWithGlobals(),{update:F}=await Promise.resolve().then(() => (y7A(),f7A)),{checkNpmUpdate:E}=await Promise.resolve().then(() => (GX1(),vr1)),H="0.0.1753860451-g956c8f";if(U.version)h9.write(w0.blue(`Updating to version ${U.version}...
4715
+ `),process.exit(0)}catch(U){MQ(U instanceof Error?U.message:String(U))}}),Q.addCommand(Z);let G=new _u("update").description("Update Amp CLI to the latest version").option("--version <version>","Update to a specific version").allowUnknownOption(!1);G.action(async(X,Y)=>{try{let U=Y.optsWithGlobals(),{update:F}=await Promise.resolve().then(() => (y7A(),f7A)),{checkNpmUpdate:E}=await Promise.resolve().then(() => (GX1(),vr1)),H="0.0.1753862480-g956c8f";if(U.version)h9.write(w0.blue(`Updating to version ${U.version}...
4716
4716
  `)),await F(U.version),h9.write(w0.green(`✓ Successfully updated to version ${U.version}
4717
4717
  `));else{h9.write(w0.blue(`Checking for updates...
4718
- `));let w=await E("0.0.1753860451-g956c8f");if(!w.hasUpdate)h9.write(w0.green(`✓ Amp CLI is already up to date.
4718
+ `));let w=await E("0.0.1753862480-g956c8f");if(!w.hasUpdate)h9.write(w0.green(`✓ Amp CLI is already up to date.
4719
4719
  `)),process.exit(0);h9.write(w0.blue(`Updating to version ${w.latestVersion}...
4720
4720
  `)),await F(w.latestVersion),h9.write(w0.green(`✓ Successfully updated to version ${w.latestVersion}
4721
4721
  `))}process.exit(0)}catch(U){h9.write(w0.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.1753860451-g956c8f",
3
+ "version": "0.0.1753862480-g956c8f",
4
4
  "description": "CLI for Amp, an agentic coding tool in research preview from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {