@sourcegraph/amp 0.0.1753282665-ge35941 → 0.0.1753286518-gec802a

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
@@ -4571,7 +4571,7 @@ ${Y}`}else K=z.map((G)=>` ${G}`).join(`
4571
4571
  `});return}if(H.trim().length>0)g(H.trim());else return;return}if(!P.ctrl&&!P.meta&&!P.tab&&u)Z({type:"insert-text",text:u})});let g=async(u)=>{C(null),Q.add(u),Q.reset();try{A(u)}catch(P){S1.error("Failed to submit message",P)}};return P0(jA,{flexDirection:"column",width:"100%",flexGrow:1,flexShrink:0,ref:G,children:W.lines.map((u,P)=>P0(jA,{flexShrink:0,flexDirection:"row",children:P0(jA,{flexGrow:1,flexShrink:0,width:"100%",children:P===R.line?Y2(pp,{children:[P0(mA,{dimColor:B,children:YS.default.substr(u.content,0,R.column)||""}),P0(mA,{inverse:!B,dimColor:B,children:YS.default(u.content)[R.column]??" "}),P0(mA,{dimColor:B,children:YS.default.substr(u.content,R.column+1)||""})]}):P0(mA,{dimColor:B,children:u.content||" "})})},P))})}function Xe6(A,Q){let B=YS.default(A),J=Q,D=Q;while(J>0&&/\S/.test(B[J-1]||""))J--;while(D<B.length&&/\S/.test(B[D]||""))D++;let z=B.slice(J,D).join("");if(!z.trim())return null;return{word:z,start:J,end:D}}var qS=hA(H8(),1);WH();var p41=hA(H8(),1);function x5A(){let[A,Q]=p41.useState(null);return p41.useEffect(()=>{let B=yl.subscribe(Q);return()=>{B.unsubscribe()}},[]),{jetbrainsState:A}}RQ1();var Tf1=hA(H8(),1);function h5A({viewState:A}){let Q=Tf1.useMemo(()=>{return A.state==="active"?A.fileChanges:void 0},[A]),B=Tf1.useMemo(()=>mx1(Q),[Q]);if(!Q||B.totalFiles===0)return null;let J=B.totalFiles-B.revertedFiles;return Y2(jA,{gap:1,children:[Y2(mA,{dimColor:!0,children:[J," ",J===1?"file":"files"," changed"]}),(B.totalAdded>0||B.totalModified>0||B.totalRemoved>0)&&Y2(mA,{children:[Y2(mA,{color:"green",children:["+",B.totalAdded]}),Y2(mA,{color:"yellow",children:[" ~",B.totalModified]}),Y2(mA,{color:"red",children:[" -",B.totalRemoved]})]})]})}import m5A from"node:path";function u5A({jetbrainsStatus:A}){if(!A||!A.enabled)return null;let Q=process.cwd(),B=A.productName&&A.openFile&&A.workspace===Q,J;if(!A.productName)J=" 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)J=" 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 D=m5A.basename(A.openFile);if(A.openFile.includes("!/"))J=` 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 J=` Project Detection Failed. Failed to map your open file '${D}' 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)J=" No Open File. To fix this problem, open a file in your project.";else if(A.workspace!==Q)J=` Project Mismatch. The currently open project "${A.workspace}" does not match the working directory of Amp CLI ("${Q}").`;return P0(jA,{gap:B?1:2,children:Y2(mA,{color:B?"green":"red",children:[B?"✓":"×"," ",A.productName??"JetBrains"," ",B?"• "+m5A.basename(A.openFile??""):J]})})}var c41=hA(H8(),1);function p5A(){let[A,Q]=c41.useState(0);c41.useEffect(()=>{let D=setInterval(()=>{Q((z)=>z+1)},200);return()=>clearInterval(D)},[]);let B=[{char:"∿",dim:!1},{char:"∾",dim:!1},{char:"∽",dim:!1},{char:"≋",dim:!1},{char:"≈",dim:!1},{char:"∼",dim:!1}],J=B[A%B.length];return P0(mA,{dimColor:J.dim,children:J.char})}var Ye6=0.8,qe6=0.9;function c5A({tokenUsage:A}){let Q=A.totalInputTokens/A.maxInputTokens,B=Math.round(Q*100),D=`${Math.max(0,Math.min(B,100))}%`,z,Z=d5A(Q);if(Z==="danger")z="red";else if(Z==="warning")z="yellow";return P0(mA,{color:z,children:D})}function d5A(A){if(A>=qe6)return"danger";else if(A>=Ye6)return"warning";return!1}function l5A(A){let Q=A.totalInputTokens/A.maxInputTokens;return d5A(Q)}function i5A({threadViewState:A,tokenUsage:Q,waitingForConfirmation:B,showingEphemeralError:J}){if(!A||A.state!=="active")return null;let D=null,z=Q?l5A(Q):!1,Z=!1;if(A.summaryState==="summarizing")D="Compacting...";else if(A.inferenceState==="running")D="Running inference...";else if(A.interactionState==="tool-running")D="Running tools...";else if(!J&&z==="warning")D="Context window is almost full. Use /compact to trim the thread.",Z=!0;else if(!J&&z==="danger")D="Context window is close to full. Use /compact to trim the thread.",Z=!0;if(!D)return null;let K=()=>{if(A.inferenceState==="running"&&A.interactionState!=="tool-running")return"blueBright";if(A.interactionState==="tool-running")return"greenBright";return"default"},G=()=>{if(Z&&z==="warning")return"yellow";if(Z&&z==="danger")return"red";if(A.inferenceState==="cancelled")return"dim";return"default"},X=A.inferenceState!=="cancelled"&&!Z&&!B;return Y2(jA,{flexDirection:"row",gap:1,children:[X&&P0(mA,{color:K(),children:P0(p5A,{})}),P0(mA,{italic:!Z&&A.inferenceState==="cancelled",color:G(),children:D})]})}function a5A({view:A,threadViewState:Q,threadTokenUsage:B,hasCompletedMessages:J,width:D}){let{jetbrainsState:z}=x5A(),Z=qS.useRef(null),{stdout:K}=mp(),[G,X]=qS.useState(K.columns);qS.useEffect(()=>{if(Z.current){let{width:F}=up(Z.current);X(F)}},[K.columns]);let Y=D||G,q=Y&&Y<60;return Y2(jA,{gap:2,marginLeft:2,ref:Z,children:[Y2(jA,{flexGrow:1,flexDirection:"row",gap:2,children:[P0(i5A,{threadViewState:Q,tokenUsage:B,waitingForConfirmation:A==="confirming"||A==="ephemeral-error",showingEphemeralError:A==="ephemeral-error"}),Y2(jA,{children:[A==="confirming-exit"&&P0(mA,{dimColor:!0,children:"Ctrl+C again to exit"}),J&&A==="running"&&!q&&P0(mA,{dimColor:!0,children:"Ctrl+R to expand"})]})]}),Y2(jA,{flexGrow:0,gap:2,children:[P0(u5A,{jetbrainsStatus:z}),!q&&P0(h5A,{viewState:Q}),B&&P0(c5A,{tokenUsage:B})]})]})}t6();j0.level=1;var Ue6={code:j0.white,codespan:j0.white,blockquote:j0.gray.italic,html:j0.gray,heading:j0.bold,firstHeading:j0.bold,hr:j0.reset,table:j0.reset,paragraph:j0.reset,strong:j0.bold,em:j0.italic,del:j0.dim.gray.strikethrough,link:j0.cyan,href:j0.cyan,text:j0.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}}},Fe6={keyword:j0.bold,built_in:j0.dim,type:j0.dim,literal:j0.italic,number:j0.reset,regexp:j0.dim.italic,string:j0.dim,subst:j0.reset,symbol:j0.reset,class:j0.bold,function:j0.reset,title:j0.reset,params:j0.reset,comment:j0.dim.italic,doctag:j0.dim.italic,meta:j0.dim,"meta-keyword":j0.reset,"meta-string":j0.reset,section:j0.reset,tag:j0.dim,name:j0.bold,"builtin-name":j0.reset,attr:j0.dim,attribute:j0.reset,variable:j0.reset,bullet:j0.reset,code:j0.reset,emphasis:j0.italic,strong:j0.bold,formula:j0.reset,link:j0.underline,quote:j0.reset,"selector-tag":j0.reset,"selector-id":j0.reset,"selector-class":j0.reset,"selector-attr":j0.reset,"selector-pseudo":j0.reset,"template-tag":j0.reset,"template-variable":j0.reset,addition:j0.bold.underline,deletion:j0.dim.strikethrough,default:j0.reset};F9.use(x81({...Ue6,reflowText:!1},{ignoreIllegals:!0,theme:Fe6}));function d41({children:A}){let Q;try{Q=F9(A,{async:!1}).trimEnd()}catch(B){S1.error("Markdown rendering failed",B,{input:A}),Q=A}return P0(mA,{children:Q})}function r5A({message:A}){let Q=A.content.filter((B)=>B.type==="thinking"||B.type==="text");if(!Q.length)return null;return P0(jA,{flexDirection:"column",marginBottom:1,children:Q.map((B,J)=>{let D=J>0?1:0;if(B.type==="thinking")return P0(u41,{thinking:B.thinking},J);else return P0(jA,{marginTop:D,children:P0(d41,{children:B.text})},J);return null})})}function n5A({message:A,marginTop:Q=0}){if(!A.content.some((D)=>D.type==="text"||D.type==="thinking"||D.type==="summary"&&D.summary.type==="message"))return null;let J=A.role==="assistant"&&A.state.type==="cancelled";return Y2(jA,{flexDirection:"column",gap:1,marginTop:Q,children:[A.content.map((D,z)=>{if(D.type==="text")switch(A.role){case"assistant":return P0(jA,{flexDirection:"column",children:P0(d41,{children:D.text})},z);case"user":return P0(jA,{borderStyle:"bold",borderColor:"green",borderLeft:!0,borderTop:!1,borderBottom:!1,borderRight:!1,paddingLeft:1,children:P0(mA,{color:"green",italic:!0,children:D.text})},z)}else if(D.type==="thinking")return P0(u41,{thinking:D.thinking},z);else if(D.type==="summary"&&D.summary.type==="message")return P0(jA,{children:Y2(mA,{color:"grey",italic:!0,children:["Summary: ",D.summary.summary]})},z);else return null}),J&&P0(jA,{children:P0(mA,{italic:!0,dimColor:!0,children:"Cancelled"})})]})}function s5A({todos:A}){if(!Array.isArray(A)||A.length===0)return null;return Y2(jA,{borderStyle:"round",borderColor:"dim",paddingX:1,flexDirection:"column",flexGrow:1,flexShrink:0,children:[P0(jA,{children:P0(mA,{dimColor:!0,bold:!0,children:"TODOs"})}),A.map((Q,B)=>P0(jA,{gap:1,children:Y2(mA,{dimColor:!0,wrap:"truncate",children:[P0(mA,{children:"• "}),P0(mA,{bold:Q.status==="in-progress",strikethrough:Q.status==="completed",children:Q.content})]})},Q.id))]})}var l41=hA(H8(),1);function o5A(A){let Q=l41.useMemo(()=>process.cwd().replace(process.env.HOME||"","~"),[]);l41.useEffect(()=>{if(A)process.stdout.write(`\x1B]0;amp - ${A} - ${Q}\x07`);return()=>{process.stdout.write("\x1B]0;\x07")}},[A,Q])}vQ();HD();var i41=hA(H8(),1);HD();function t5A(A){let Q=[],B=new Map;for(let J of A.messages)for(let D of J.content)if(D.type==="tool_use")B.set(D.id,D);else if(D.type==="tool_result"){let z=B.get(D.toolUseID);if(z&&!SQ(D.run))Q.push({toolUse:z,toolRun:D.run})}return Q}function e5A(A,Q){let B=A.messages.at(-1);if(B?.content.some((D)=>D.type==="tool_result"&&D.run.status==="blocked-on-user"))return{type:"idle"};if(Q.filter((D)=>D.toolRun.status==="in-progress").length>0)return{type:"running-tools",startTime:Date.now()};let J=y91(A);if(J)return J;if(B&&B.role==="assistant"&&B.state.type==="complete"&&B.state.stopReason==="end_turn")return{type:"idle"};return{type:"idle"}}function Ee6(A,Q){switch(Q.type){case"subthread-patch":{let{thread:B,subthread:J}=Q,D=t5A(B),z=new Set(D.map((Y)=>Y.toolUse.id)),Z=A.subagents[J.threadID]??{subThreadID:B.id,agentNumber:J.sequenceNumber,taskDescription:J.toolUse.input?.description||"Task",isCompleted:!1,agentState:{type:"idle"}},K=e5A(B,D),G=Z.agentState===K?Z:{...Z,agentState:K},X={...A.tools};return Object.entries(X).forEach(([Y,q])=>{if(q.subthreadID===B.id&&!z.has(Y))delete X[Y]}),D.forEach(({toolUse:Y,toolRun:q})=>{X[Y.id]={id:Y.id,subthreadID:B.id,toolRun:q,toolUse:Y}}),{subagents:{...A.subagents,[J.threadID]:G},tools:X,transcript:A.transcript,viewState:A.viewState,streamingAssistantMessage:A.streamingAssistantMessage,todosList:A.todosList,mainThread:A.mainThread}}case"main-thread-patch":{let{thread:B,subthreads:J,workerStatus:D}=Q,z=tK(B),Z={...A.subagents};for(let F of J){let E=Z[F.threadID];if(!E)continue;let{isCompleted:H,result:w}=Ie6(z,F.toolUse.id);Z[F.threadID]={...E,isCompleted:H,result:w||E.result}}let K=He6(A.transcript,B),G=ey(B,D),X=we6(B),Y=Td({messages:B.messages}),q=Array.isArray(Y)?Y:[];return{...A,subagents:Z,transcript:K,viewState:G,streamingAssistantMessage:X,todosList:q,mainThread:B}}case"worker-status-change":{if(!A.mainThread)return A;let B=ey(A.mainThread,Q.workerStatus);if(B===A.viewState)return A;return{...A,viewState:B}}default:return A}}function A7A(A,Q){let[B,J]=i41.useReducer(Ee6,{subagents:{},tools:{},transcript:{items:[],activeTools:[]},viewState:{state:"initial",interactionState:!1},streamingAssistantMessage:null,todosList:[],mainThread:null});return i41.useEffect(()=>{let D=new Map,z=[],Z={state:"initial"},K=A.observePatches(Q.thread.id).pipe(uQ1()).subscribe((Y)=>{J({type:"main-thread-patch",thread:Y,subthreads:z,workerStatus:Z})}),G=Q.status.subscribe((Y)=>{Z=Y,J({type:"worker-status-change",workerStatus:Y})}),X=Q.subthreads.subscribe((Y)=>{z=Y;for(let q of Y){if(D.has(q.toolUse.id))continue;let F=A.observePatches(q.threadID).pipe(uQ1()).subscribe((E)=>{J({type:"subthread-patch",thread:E,subthread:q})});D.set(q.toolUse.id,F)}});return()=>{K.unsubscribe(),G.unsubscribe(),X.unsubscribe(),D.forEach((Y)=>Y.unsubscribe())}},[A,Q]),{transcript:B.transcript,subagents:Object.values(B.subagents),subagentActiveTools:Object.values(B.tools).map((D)=>({toolUse:D.toolUse,toolRun:D.toolRun,subthreadID:D.subthreadID})),viewState:B.viewState,streamingAssistantMessage:B.streamingAssistantMessage,todosList:B.todosList,mainThread:B.mainThread}}function He6(A,Q){let B=[],J=[...A.items],D=new Set;for(let Z of A.items)D.add(Z.id);let z=new Set;for(let[Z,K]of Q.messages.entries())switch(K.role){case"assistant":if(K.state.type==="streaming"){for(let G of K.content)if(G.type==="tool_use")z.add(G.id);continue}if(!D.has(`assistant-${Z}`))J.push({type:"message",id:`assistant-${Z}`,message:K});break;case"info":if(!D.has(`info-${Z}`))J.push({type:"message",id:`info-${Z}`,message:K});break;case"user":if(!D.has(`user-${Z}`))J.push({type:"message",id:`user-${Z}`,message:K});for(let G of K.content)if(G.type==="tool_result"){let X=s7(Q,G.toolUseID);if(!X)throw new Error(`(bug) tool use ${G.toolUseID} not found`);if(z.has(G.toolUseID)||!SQ(G.run)){if(X.name!==y5)B.push({toolUse:X,toolRun:G.run});continue}if(!D.has(G.toolUseID))J.push({type:"toolResult",id:G.toolUseID,toolUse:X,toolResult:G})}break}return{items:J,activeTools:B}}function we6(A){let Q=$Q(A,"assistant");return Q?.state.type==="streaming"?Q:null}function Ie6(A,Q){let B=A.get(Q),J=(B&&SQ(B.run))??!1,D=B&&B.run,z=D&&D.status==="done"?D.result:void 0;return{isCompleted:J,result:z}}var a41=hA(H8(),1);function Q7A(){return P0(jA,{flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:3,marginLeft:4,children:P0(jA,{children:P0(mA,{color:"green",bold:!0,children:"Welcome to Amp"})})})}function B7A(){let[A,Q]=a41.useState(0),B=["Amp","AMP","AmP","amP","aMP","AMp"];return a41.useEffect(()=>{let J=setInterval(()=>{Q((D)=>(D+1)%B.length)},50);return()=>clearInterval(J)},[B.length]),P0(jA,{flexDirection:"column",alignItems:"flex-start",justifyContent:"center",minHeight:3,marginLeft:4,children:P0(jA,{children:Y2(mA,{color:"green",bold:!0,children:["Welcome to ",B[A]]})})})}var We6=200;function J7A({threadService:A,history:Q,worker:B,sendToolConfirmation:J,sendUserMessage:D,exit:z,cancel:Z,ampURL:K,commands:G}){let[X]=XS(),{viewState:Y,subagents:q,subagentActiveTools:F,transcript:E,streamingAssistantMessage:H,todosList:w,mainThread:I}=A7A(A,B),W=C7.useMemo(()=>H?E.items.concat({id:"streaming-assistant",type:"message",message:H}):E.items,[H,E.items]),M=I?.title||"Untitled",C=C7.useMemo(()=>I?ex1(I):void 0,[I]);o5A(I?.title);let V=C7.useRef(new P8),[R,T]=C7.useState({baseView:"running",rerendering:!1,resizeCounter:0,dismissedEphemeralError:null,slashCommandQuery:null,uiError:null}),L=C7.useRef(null),_=C7.useRef(null),[j,v]=k5A(),$=C7.useCallback((s)=>{T((Q1)=>({...Q1,slashCommandQuery:s}))},[]),g=C7.useMemo(()=>{if(R.slashCommandQuery===null)return[];return G.query(R.slashCommandQuery)},[R.slashCommandQuery,G]),u=C7.useCallback(()=>{T((s)=>({...s,rerendering:!0})),process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),V.current.next()},[T,V]),P=C7.useCallback(async(s)=>{if(!s||!I){T((Y1)=>({...Y1,slashCommandQuery:null}));return}let Q1=!1,D1=(Y1)=>{Q1=!0,v(Y1)},X1=G.get(s);try{let Y1=await X1.execute({worker:B,thread:I,editorDispatch:D1});T((L1)=>({...L1,slashCommandQuery:null,uiError:Y1||null}))}catch(Y1){T((L1)=>({...L1,slashCommandQuery:null,uiError:Y1}))}if(!Q1)v({type:"clear"})},[G,v,I,B]),k=C7.useCallback((s)=>{v({type:"clear"}),D(s)},[v,D]);C7.useEffect(()=>{return process.stdout.on("resize",u),()=>{process.stdout.off("resize",u)}},[u]),C7.useEffect(()=>{let s=V.current.pipe(VJ(We6)).subscribe(()=>{T((Q1)=>({...Q1,rerendering:!1,resizeCounter:Q1.resizeCounter+1}))});return()=>{s.unsubscribe()}},[V,T]),C7.useEffect(()=>{let s=V.current,Q1=L.current;return()=>{if(s.complete(),Q1)clearTimeout(Q1)}},[V]);let y=[...E.activeTools,...F],m=y.filter((s)=>s.toolRun.status==="blocked-on-user"),S=C7.useMemo(()=>M5A(m),[m]),{hasCompletions:h,completions:d,selectCompletion:l}=P41(),J1=C7.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":J1!==null?"ephemeral-error":S!==null?"confirming":g.length>0?"slash-commands":h?"picking-file":R.baseView,Z1=(s)=>{if(!S||S.type!=="tool-use")return;if(S.tools.length>0){let Q1=S.tools[0],D1=Array.from(s==="always"?Q1.toAllow??[]:[]);J(Q1.useBlock.id,s==="yes"||s==="always",D1,S.subthreadID)}},B1=(s)=>{switch(s){case"compact":T((Q1)=>({...Q1,dismissedEphemeralError:null})),B.summarizeThread();break;case"dismiss":T((Q1)=>({...Q1,dismissedEphemeralError:J1}));break;case"retry":T((Q1)=>({...Q1,dismissedEphemeralError:null})),B.retry();break;default:S1.warn("action:",{action:s})}},K1=()=>{T((s)=>({...s,uiError:null}))};hE((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 D1=setTimeout(()=>{T((X1)=>({...X1,baseView:"running"})),L.current=null},1000);L.current=D1}return}if(n==="expanded-view"||n==="confirming"||n==="ephemeral-error")return;if(n==="ui-error")return;if(Q1.escape)if(n==="picking-file")return;else Z();else if(Q1.ctrl&&s.toLowerCase()==="r")T((D1)=>({...D1,baseView:"expanded-view"}));else if(Q1.ctrlL)u()});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 P0(b5A,{threadName:M,messages:s,onExit:()=>T((Q1)=>({...Q1,baseView:"running"}))})}return Y2(jA,{flexDirection:"column",minHeight:"100%",flexGrow:1,height:R1,children:[P0(R41,{items:r,children:(s,Q1)=>{if(s.type==="welcome")return P0(Q7A,{},"welcome");let D1=Q1===0?0:1;return s.type==="message"?P0(n5A,{message:s.message,marginTop:D1},s.id):P0(G5A,{toolUse:s.toolUse,toolResult:s.toolResult,marginTop:D1},s.id)}},a),Y2(jA,{flexDirection:"column",marginTop:r.length>1?1:0,children:[H&&P0(r5A,{message:H}),P0(D5A,{activeTools:y,subagents:q}),Y2(jA,{flexDirection:z1?"row-reverse":"column",children:[w.length>0&&P0(jA,{ref:_,flexGrow:0,flexShrink:0,width:z1?"50%":"100%",children:P0(s5A,{todos:w})}),n==="ui-error"&&R.uiError?P0(h41,{title:Wf1(R.uiError).title,description:Wf1(R.uiError).description,options:[{value:"dismiss",label:"Dismiss"}],onSelect:K1}):n==="ephemeral-error"&&J1?P0(y5A,{error:J1,onResponse:B1,ampURL:K}):n==="confirming"&&S?P0(V5A,{currentConfirmation:S,onConfirmationResponse:Z1}):P0(jA,{flexGrow:1,borderStyle:"round",paddingX:1,children:P0(g5A,{onSubmit:k,history:Q,disabled:n==="confirming"||n==="ephemeral-error"||Y.state==="active"&&Y.summaryState==="summarizing",viewState:Y,todosBoxRef:_,editorState:j,editorDispatch:v,onSlashCommandQuery:$})})]}),P0(a5A,{view:n,threadViewState:Y,threadTokenUsage:C,hasCompletedMessages:E.items.length>0}),P0(Me6,{commands:g,onSelect:P}),P0(Ce6,{completions:d.options,onSelect:l})]})]})}function Me6({commands:A,onSelect:Q}){let J=A.slice(0,10).map((D)=>({value:D.name,label:D.name,description:D.description}));return P0(jA,{marginBottom:1,children:P0(IO,{title:"Select command:",options:J,onSelect:Q})})}function Ce6({completions:A,onSelect:Q}){let B=Math.min(10),J=A.slice(0,B).map((z)=>({value:z,label:z}));if(J.length===0)return null;return P0(jA,{marginBottom:1,children:P0(IO,{title:"Insert file name:",options:J,onSelect:(z)=>{if(z===null)return;let Z=A.find((K)=>K===z);if(!Z)return;Q(Z)}})})}function D7A(A){let{worker:Q,threadID:B,settingsStorage:J,pipedInput:D,workerDeps:z,fuzzyServer:Z}=A,[K,G]=LX.useState(!1),X=LX.useCallback((w,I,W,M)=>{return Ne6(w,I,W,M,J,Q,z)},[J,Q,z]),Y=LX.useCallback(async(w)=>{await Q.handle({type:"user:message",message:{content:[{type:"text",text:w}]}})},[Q]),{exit:q}=wf1(),F=LX.useCallback(()=>{LD.cancel(B)},[B]);LX.useEffect(()=>{let w=setTimeout(()=>{G(!0)},500);return()=>clearTimeout(w)},[]);let E=LX.useRef(!1);if(LX.useEffect(()=>{if(E.current)return;if(D)E.current=!0,Y(D),G(!0)},[D,Y]),!K)return P0(B7A,{});let H=new Mf1;return P0(o4A,{fuzzyServer:Z,children:P0(J7A,{history:A.history,threadService:A.threadService,worker:Q,sendToolConfirmation:X,sendUserMessage:Y,exit:q,cancel:F,ampURL:A.ampURL,commands:H})})}async function Ne6(A,Q,B,J,D,z,Z){let K=B&&B.length>0||!1;if(B&&B.length>0)await H6(l2).then((X)=>X.settings["experimental.commandApproval.enabled"]?"experimental.commandApproval.allow":"commands.allowlist").then((X)=>{D.get(X,"global").then((Y)=>{let q=[...Y??[],...B];return D.set(X,q,"global")}).catch((Y)=>{S1.error("Failed to update allowlist",Y)})});let G={type:"user:tool-input",toolUse:A,value:{accepted:Q||K}};if(J)(await LD.getOrCreateForThread(Z,J)).handle(G);else z.handle(G)}global.React=jf1.default;function z7A(A){return j0.level=1,Hf1(jf1.default.createElement(D7A,{...A}),{patchConsole:!0,exitOnCtrlC:!1,stdout:A.stdout,stdin:A.stdin}).waitUntilExit().then(async()=>{let{threadID:B,ampURL:J,threadService:D}=A;if((await D.get(B))?.messages.length!==0){let Z=`${J.replace(/\/$/,"")}/threads/${B}`;A.stdout.write(`
4572
4572
  `),A.stdout.write(`${j0.dim("Thread:")} ${Z}
4573
4573
  `),A.stdout.write(`${j0.dim("Continue this thread with:")} amp threads continue ${B}
4574
- `)}})}var $f1=Sf1.join(w1A||Sf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");async function vf1(A){try{await _e6(Sf1.dirname($f1),{recursive:!0}),await $e6($f1,A,"utf-8")}catch(Q){S1.debug("Failed to save last thread ID",Q)}}async function Y7A(){try{return(await Se6($f1,"utf-8")).trim()}catch(A){return null}}async function ve6(A){let Q=await yQ(`/api/threads/${A}`);if(!Q.ok){let B=await Q.text();if(Q.status===404||B.includes("not found"))throw new BZ(PK.threadNotFound(A));throw new BZ(`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 E7A=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,q7A=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} sound notifications (enabled by default when interactive)`},{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??GO,description:`Custom settings file path (overrides the default location ${GO})`},{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:E7A,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}],U7A=(A)=>("deprecated"in A)&&A.deprecated===!0,ke6=(A)=>("hidden"in A)&&A.hidden===!0,fe6=(A)=>("default"in A),ye6=(A)=>("default"in A)?A.default:void 0;function be6(A,Q){let B=Q.args[0],J=Q.commands.map((z)=>z.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let z=J.filter((K)=>B.includes(K)||K.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 BZ(PK.unknownCommand(B),1,Z)}}async function US(A,Q){Zh1("0.0.1753282665-ge35941");let B=Q.settingsFile;S1.info("Using settings file",{settingsFile:B});let J=yv1(Wp()),D=Ip({settingsFile:B}),z=cQ1({storage:D,secretStorage:J,workspaceRoots:YA.of([_2.file(process.cwd())]),defaultAmpURL:A.ampURL}),Z=h$(),K=Oa1({configService:z,toolService:Z});try{await K.initialized}catch(R){S1.warn("Failed to wait for MCP servers, continuing anyway:",R)}let G=await H6(l2);if(Q.dangerouslyAllowAll)G.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(G.settings["jetbrains.enabled"]=!0,yl.subscribe((T)=>{S1.info("jetbrains-status",T)}),await xR(),!await Zp1()){if(E7A)a2.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 a2.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"]??[];oP1(Z,!1,X,Y);let q,F;if(A.isInteractiveMode){q=e2A(G.settings,process.cwd()),await q.start();try{await A8A(q,process.cwd())}catch(R){S1.error("Failed to index files for fuzzy completion",R)}F=Q8A(q,process.cwd())}else q=new class{async start(){}async query(){return[]}dispose(){}},F={[Symbol.dispose]:()=>{}};if(!await J.get("apiKey",A.ampURL)){if(b4.write(`No API key found. Starting login flow...
4574
+ `)}})}var $f1=Sf1.join(w1A||Sf1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");async function vf1(A){try{await _e6(Sf1.dirname($f1),{recursive:!0}),await $e6($f1,A,"utf-8")}catch(Q){S1.debug("Failed to save last thread ID",Q)}}async function Y7A(){try{return(await Se6($f1,"utf-8")).trim()}catch(A){return null}}async function ve6(A){let Q=await yQ(`/api/threads/${A}`);if(!Q.ok){let B=await Q.text();if(Q.status===404||B.includes("not found"))throw new BZ(PK.threadNotFound(A));throw new BZ(`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 E7A=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,q7A=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} sound notifications (enabled by default when interactive)`},{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??GO,description:`Custom settings file path (overrides the default location ${GO})`},{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:E7A,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}],U7A=(A)=>("deprecated"in A)&&A.deprecated===!0,ke6=(A)=>("hidden"in A)&&A.hidden===!0,fe6=(A)=>("default"in A),ye6=(A)=>("default"in A)?A.default:void 0;function be6(A,Q){let B=Q.args[0],J=Q.commands.map((z)=>z.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let z=J.filter((K)=>B.includes(K)||K.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 BZ(PK.unknownCommand(B),1,Z)}}async function US(A,Q){Zh1("0.0.1753286518-gec802a");let B=Q.settingsFile;S1.info("Using settings file",{settingsFile:B});let J=yv1(Wp()),D=Ip({settingsFile:B}),z=cQ1({storage:D,secretStorage:J,workspaceRoots:YA.of([_2.file(process.cwd())]),defaultAmpURL:A.ampURL}),Z=h$(),K=Oa1({configService:z,toolService:Z});try{await K.initialized}catch(R){S1.warn("Failed to wait for MCP servers, continuing anyway:",R)}let G=await H6(l2);if(Q.dangerouslyAllowAll)G.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(G.settings["jetbrains.enabled"]=!0,yl.subscribe((T)=>{S1.info("jetbrains-status",T)}),await xR(),!await Zp1()){if(E7A)a2.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 a2.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"]??[];oP1(Z,!1,X,Y);let q,F;if(A.isInteractiveMode){q=e2A(G.settings,process.cwd()),await q.start();try{await A8A(q,process.cwd())}catch(R){S1.error("Failed to index files for fuzzy completion",R)}F=Q8A(q,process.cwd())}else q=new class{async start(){}async query(){return[]}dispose(){}},F={[Symbol.dispose]:()=>{}};if(!await J.get("apiKey",A.ampURL)){if(b4.write(`No API key found. Starting login flow...
4575
4575
  `),!await ge6(A,J))process.exit(1)}let E=zr1(),H=new FX1(E),w=new YX1(E),I=new aU1(H),W=new zk1({configService:z,threadService:H,toolService:Z,threadSummaryService:I,threadHistoryService:w,mcpService:K}),M=Q.notifications!==void 0?Q.notifications:A.isInteractiveMode,C=se0({playNotificationSound:async(R)=>{if(M)ne0(R)},windowFocused:()=>Promise.resolve(!1),threadService:H,notifyForSubagents:!1});S1.info("Starting Amp background services");let V=m80({threadService:H,threadHistoryService:w,isExtensionDevelopment:!1});return{configService:z,toolService:Z,mcpService:K,threadService:H,threadHistoryService:w,threadSummaryService:I,threadSyncService:V,threadStorage:E,secretStorage:J,settingsStorage:D,fileWatcher:F,fuzzyServer:q,subthreadTracker:W,notificationService:C}}async function ge6(A,Q){if(A.isInteractiveMode){if(await v91("Would you like to log in to Amp?",["(y)es","(n)o"])!="y")return b4.write(`Login cancelled. Run the command again to retry.
4576
4576
  `),!1}return await H7A(A,Q)}async function H7A(A,Q){let B=Pe6(32).toString("hex"),J=await T8A(A.ampURL,B);b4.write(`If your browser doesn't open automatically, visit:
4577
4577
 
@@ -4586,8 +4586,8 @@ ${A.printer.print(J,{foreground:"blue",style:"bold"})}
4586
4586
  Login successful! You can now use the Amp CLI.
4587
4587
  `),!0}catch(D){return a2.write(`
4588
4588
  Login failed: ${D instanceof Error?D.message:String(D)}
4589
- `),!1}}var xe6=new Set(["fuzzy-server"]);function he6(A){let Q=new iu().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, team)").configureOutput({writeErr:()=>{}});Q.exitOverride((G)=>{if(G.code==="commander.help"||G.code==="commander.version"||G.exitCode===0)Vp(),process.exit(0);let X=G.originalError??G;d_(A,X)}),Q.option("-V, --version","output the version number",()=>{if(A.isTTY)b4.write(`0.0.1753282665-ge35941 ${A.printer.print("(released 2025-07-23T15:04:48.490Z)",{foreground:"gray"})}
4590
- `);else b4.write(`0.0.1753282665-ge35941 (released 2025-07-23T15:04:48.490Z)
4589
+ `),!1}}var xe6=new Set(["fuzzy-server"]);function he6(A){let Q=new iu().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, team)").configureOutput({writeErr:()=>{}});Q.exitOverride((G)=>{if(G.code==="commander.help"||G.code==="commander.version"||G.exitCode===0)Vp(),process.exit(0);let X=G.originalError??G;d_(A,X)}),Q.option("-V, --version","output the version number",()=>{if(A.isTTY)b4.write(`0.0.1753286518-gec802a ${A.printer.print("(released 2025-07-23T16:06:50.825Z)",{foreground:"gray"})}
4590
+ `);else b4.write(`0.0.1753286518-gec802a (released 2025-07-23T16:06:50.825Z)
4591
4591
  `);process.exit(0)}),Q.addHelpText("after",(()=>{let G="";G+=A.printer.print("Environment variables:",{style:"bold"})+`
4592
4592
 
4593
4593
  `,G+=" "+A.printer.print("AMP_API_KEY",{foreground:"green"})+` API key for Amp (see https://ampcode.com/settings)
@@ -4677,7 +4677,7 @@ Summary: ${V}
4677
4677
  `),a2.write(`Secrets have been automatically redacted, but please review the file before attaching
4678
4678
  `),a2.write(`it to support requests. Learn more at https://ampcode.com/manual/appendix#support-bundles
4679
4679
  `),process.exit(0)}catch(X){a2.write(A.printer.print("Error generating support bundle: ",{foreground:"red"})+`${X instanceof Error?X.message:String(X)}
4680
- `),process.exit(1)}}),Q.addCommand(z);let Z=new iu("update").description("Update Amp CLI to the latest version").option("--version <version>","Update to a specific version").option("--log-level <value>","Set log level (error, warn, info, debug, audit)").option("--log-file <value>","Set log file location").allowUnknownOption(!1);Z.action(async(G)=>{try{let X=AD();wp({logLevel:G.logLevel,logFile:G.logFile});let{update:Y}=await Promise.resolve().then(() => (X7A(),G7A)),{checkNpmUpdate:q}=await Promise.resolve().then(() => (iG1(),Kr1)),F="0.0.1753282665-ge35941";if(G.version)a2.write(X.printer.print(`Updating to version ${G.version}...`,{foreground:"blue"})+`
4680
+ `),process.exit(1)}}),Q.addCommand(z);let Z=new iu("update").description("Update Amp CLI to the latest version").option("--version <version>","Update to a specific version").option("--log-level <value>","Set log level (error, warn, info, debug, audit)").option("--log-file <value>","Set log file location").allowUnknownOption(!1);Z.action(async(G)=>{try{let X=AD();wp({logLevel:G.logLevel,logFile:G.logFile});let{update:Y}=await Promise.resolve().then(() => (X7A(),G7A)),{checkNpmUpdate:q}=await Promise.resolve().then(() => (iG1(),Kr1)),F="0.0.1753286518-gec802a";if(G.version)a2.write(X.printer.print(`Updating to version ${G.version}...`,{foreground:"blue"})+`
4681
4681
  `),await Y(G.version),a2.write(X.printer.print(`✓ Successfully updated to version ${G.version}`,{foreground:"green"})+`
4682
4682
  `);else{a2.write(X.printer.print("Checking for updates...",{foreground:"blue"})+`
4683
4683
  `);let E=await q(F);if(!E.hasUpdate)a2.write(X.printer.print("✓ Amp CLI is already up to date.",{foreground:"green"})+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1753282665-ge35941",
3
+ "version": "0.0.1753286518-gec802a",
4
4
  "description": "CLI for Amp, an agentic coding tool in research preview from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {