@sourcegraph/amp 0.0.1753289667-g54d21a → 0.0.1753290974-g79bbdd

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 +6 -6
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -4542,7 +4542,7 @@ $ npm install --save-dev react-devtools-core
4542
4542
  Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);else throw new Error(`Raw mode is not supported on the stdin provided to Ink.
4543
4543
  Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(Q.setEncoding("utf8"),A){if(this.rawModeEnabledCount===0)Q.ref(),Q.setRawMode(!0),Q.addListener("readable",this.handleReadable);this.rawModeEnabledCount++;return}if(--this.rawModeEnabledCount===0)Q.setRawMode(!1),Q.removeListener("readable",this.handleReadable),Q.unref()};handleReadable=()=>{let A;while((A=this.props.stdin.read())!==null)this.handleInput(A),this.internal_eventEmitter.emit("input",A)};handleInput=(A)=>{if(A==="\x03"&&this.props.exitOnCtrlC)this.handleExit();if(A===No6&&this.state.activeFocusId)this.setState({activeFocusId:void 0});if(this.state.isFocusEnabled&&this.state.focusables.length>0){if(A===Mo6)this.focusNext();if(A===Co6)this.focusPrevious()}};handleExit=(A)=>{if(this.isRawModeSupported())this.handleSetRawMode(!1);this.props.onExit(A)};enableFocus=()=>{this.setState({isFocusEnabled:!0})};disableFocus=()=>{this.setState({isFocusEnabled:!1})};focus=(A)=>{this.setState((Q)=>{if(!Q.focusables.some((J)=>J?.id===A))return Q;return{activeFocusId:A}})};focusNext=()=>{this.setState((A)=>{let Q=A.focusables.find((J)=>J.isActive)?.id;return{activeFocusId:this.findNextFocusable(A)??Q}})};focusPrevious=()=>{this.setState((A)=>{let Q=A.focusables.findLast((J)=>J.isActive)?.id;return{activeFocusId:this.findPreviousFocusable(A)??Q}})};addFocusable=(A,{autoFocus:Q})=>{this.setState((B)=>{let J=B.activeFocusId;if(!J&&Q)J=A;return{activeFocusId:J,focusables:[...B.focusables,{id:A,isActive:!0}]}})};removeFocusable=(A)=>{this.setState((Q)=>({activeFocusId:Q.activeFocusId===A?void 0:Q.activeFocusId,focusables:Q.focusables.filter((B)=>{return B.id!==A})}))};activateFocusable=(A)=>{this.setState((Q)=>({focusables:Q.focusables.map((B)=>{if(B.id!==A)return B;return{id:A,isActive:!0}})}))};deactivateFocusable=(A)=>{this.setState((Q)=>({activeFocusId:Q.activeFocusId===A?void 0:Q.activeFocusId,focusables:Q.focusables.map((B)=>{if(B.id!==A)return B;return{id:A,isActive:!1}})}))};findNextFocusable=(A)=>{let Q=A.focusables.findIndex((B)=>{return B.id===A.activeFocusId});for(let B=Q+1;B<A.focusables.length;B++){let J=A.focusables[B];if(J?.isActive)return J.id}return};findPreviousFocusable=(A)=>{let Q=A.focusables.findIndex((B)=>{return B.id===A.activeFocusId});for(let B=Q-1;B>=0;B--){let J=A.focusables[B];if(J?.isActive)return J.id}return}}var m4A=()=>{};class V41{options;log;throttledLog;isUnmounted;lastOutput;lastOutputHeight;container;rootNode;fullStaticOutput;exitPromise;restoreConsole;unsubscribeResize;constructor(A){if(Uk1(this),this.options=A,this.rootNode=B41("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.rootNode.onRender=A.debug?this.onRender:g91(this.onRender,8,{leading:!0,trailing:!0}),this.rootNode.onImmediateRender=this.onRender,this.log=w4A.create(A.stdout),this.throttledLog=A.debug?this.log:g91(this.log,void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.lastOutput="",this.lastOutputHeight=0,this.fullStaticOutput="",this.container=wW.createContainer(this.rootNode,Wk1,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{},null),this.unsubscribeExit=p4A.default(this.unmount,{alwaysLast:!1}),Vo6.env.DEV==="true")wW.injectIntoDevTools({bundleType:0,version:"16.13.1",rendererPackageName:"ink"});if(A.patchConsole)this.patchConsole();if(!UO)A.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{A.stdout.off("resize",this.resized)}}resized=()=>{this.calculateLayout(),this.onRender()};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};calculateLayout=()=>{let A=this.options.stdout.columns||80;this.rootNode.yogaNode.setWidth(A),this.rootNode.yogaNode.calculateLayout(void 0,void 0,$6.DIRECTION_LTR)};onRender=()=>{if(this.isUnmounted)return;let{output:A,outputHeight:Q,staticOutput:B,resetStatic:J}=K4A(this.rootNode),D=B&&B!==`
4544
4544
  `||J;if(this.options.debug){if(D)this.fullStaticOutput+=B;this.options.stdout.write(this.fullStaticOutput+A);return}if(UO){if(D)this.options.stdout.write(B);this.lastOutput=A,this.lastOutputHeight=Q;return}if(D)if(J)this.fullStaticOutput=B;else this.fullStaticOutput+=B;if(Q>=this.options.stdout.rows){this.options.stdout.write("\x1B[?2026h"+EX.clearTerminal+this.fullStaticOutput+A+"\x1B[?2026l"),this.lastOutput=A;return}if(D)this.log.clear(),this.options.stdout.write(B),this.log(A);if(!D&&A!==this.lastOutput)this.throttledLog(A);this.lastOutput=A,this.lastOutputHeight=Q};render(A){let Q=u4A.default.createElement(N41,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},A);wW.updateContainerSync(Q,this.container,null,m4A),wW.flushSyncWork()}writeToStdout(A){if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(A+this.fullStaticOutput+this.lastOutput);return}if(UO){this.options.stdout.write(A);return}this.log.clear(),this.options.stdout.write(A),this.log(this.lastOutput)}writeToStderr(A){if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(A),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(UO){this.options.stderr.write(A);return}this.log.clear(),this.options.stderr.write(A),this.log(this.lastOutput)}unmount(A){if(this.isUnmounted)return;if(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole==="function")this.restoreConsole();if(typeof this.unsubscribeResize==="function")this.unsubscribeResize();if(UO)this.options.stdout.write(this.lastOutput+`
4545
- `);else if(!this.options.debug)this.log.done();if(this.isUnmounted=!0,wW.updateContainerSync(null,this.container,null,m4A),wW.flushSyncWork(),JS.delete(this.options.stdout),A instanceof Error)this.rejectExitPromise(A);else this.resolveExitPromise()}async waitUntilExit(){return this.exitPromise||=new Promise((A,Q)=>{this.resolveExitPromise=A,this.rejectExitPromise=Q}),this.exitPromise}clear(){if(!UO&&!this.options.debug)this.log.clear()}patchConsole(){if(this.options.debug)return;this.restoreConsole=D9A((A,Q)=>{if(A==="stdout")this.writeToStdout(Q);if(A==="stderr"){if(!Q.startsWith("The above error occurred"))this.writeToStderr(Q)}})}}var Ro6=(A,Q)=>{let B={stdout:O41.stdout,stdin:O41.stdin,stderr:O41.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,...Lo6(Q)},J=To6(B.stdout,()=>new V41(B));return J.render(A),{rerender:J.render,unmount(){J.unmount()},waitUntilExit:J.waitUntilExit,cleanup:()=>JS.delete(B.stdout),clear:J.clear}},Hf1=Ro6,Lo6=(A={})=>{if(A instanceof Oo6)return{stdout:A,stdin:O41.stdin};return A},To6=(A,Q)=>{let B=JS.get(A);if(!B)B=Q(),JS.set(A,B);return B};var xE=hA(H8(),1);function R41(A){let{items:Q,children:B,style:J}=A,[D,z]=xE.useState(0),Z=xE.useMemo(()=>{return Q.slice(D)},[Q,D]);xE.useLayoutEffect(()=>{z(Q.length)},[Q.length]);let K=Z.map((X,Y)=>{return B(X,D+Y)}),G=xE.useMemo(()=>({position:"absolute",flexDirection:"column",...J}),[J]);return xE.default.createElement("ink-box",{internal_static:!0,style:G},K)}var c4A=hA(H8(),1);function L41({children:A,transform:Q}){if(A===void 0||A===null)return null;return c4A.default.createElement("ink-text",{style:{flexGrow:0,flexShrink:1,flexDirection:"row"},internal_transform:Q},A)}var jo6=hA(H8(),1);var Po6=hA(H8(),1);var vo6=hA(H8(),1);var _o6={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},So6=[...Object.values(_o6),"backspace"];var d4A=hA(H8(),1);var $o6=()=>d4A.useContext(w41),hp=$o6;var l4A=hA(H8(),1);var ko6=()=>l4A.useContext(H41),wf1=ko6;var i4A=hA(H8(),1);var fo6=()=>i4A.useContext(I41),mp=fo6;var yo6=hA(H8(),1);var If1=hA(H8(),1);var bo6=hA(H8(),1);var go6=(A)=>({width:A.yogaNode?.getComputedWidth()??0,height:A.yogaNode?.getComputedHeight()??0}),up=go6;var jf1=hA(H8(),1);t6();n7();LC();b6();var LX=hA(H8(),1);t6();UI1();import{mkdtemp as xo6,readFile as ho6,unlink as mo6}from"fs/promises";import{execSync as uo6}from"node:child_process";import{rmdir as po6}from"node:fs/promises";import{tmpdir as co6}from"node:os";import a4A from"node:path";t6();class T41 extends Error{constructor(A="Thread has no messages to compact"){super(A);this.name="NoMessagesToCompactError"}}function Wf1(A){if(A instanceof T41)return{title:"Cannot compact thread",description:"Thread has no messages to compact."};return S1.warn("Unknown error type encountered",{name:A.name,message:A.message,stack:A.stack}),{title:"Error",description:A.message||"An unexpected error occurred."}}class Mf1{query(A){let Q=A.toLowerCase();return Object.values(r4A).filter((B)=>B.name.toLowerCase().includes(Q))}get(A){return r4A[A]}}var r4A={agent:{name:"agent",description:"Generate an AGENT.md file in the current workspace",execute:async(A)=>{A.worker.handle({type:"user:message",message:{content:[{type:"text",text:Ez0}]}});return}},compact:{name:"compact",description:"Compact the thread",execute:async(A)=>{if(A.thread.messages.length===0)return new T41;A.worker.summarizeThread()}},editor:{name:"editor",description:"Open $EDITOR to write a prompt",execute:async(A)=>{if(!A.editorDispatch)return new Error("Editor dispatch not available");try{let Q=process.env.EDITOR||process.env.VISUAL||"nano",B=await xo6(a4A.join(co6(),"amp-edit-")),J=a4A.join(B,"message.txt");uo6(`${Q} "${J}"`,{stdio:"inherit"}),process.stdout.write("\x1B[?25l");try{let z=(await ho6(J,"utf-8")).trim();if(z)A.editorDispatch({type:"set-input",input:z})}catch(D){return S1.error("Failed to read temporary file",D),new Error("Failed to read editor content")}try{await mo6(J),await po6(B)}catch(D){S1.warn("Failed to clean up temporary file",D)}return}catch(Q){return S1.error("Failed to open editor",Q),new Error("Failed to open editor")}}}};t6();b6();var C7=hA(H8(),1);var do6=Symbol.for("react.transitional.element"),lo6=Symbol.for("react.fragment");function n4A(A,Q,B){var J=null;if(B!==void 0&&(J=""+B),Q.key!==void 0&&(J=""+Q.key),"key"in Q){B={};for(var D in Q)D!=="key"&&(B[D]=Q[D])}else B=Q;return Q=B.ref,{$$typeof:do6,type:A,key:J,ref:Q!==void 0?Q:null,props:B}}var pp=lo6,P0=n4A,Y2=n4A;var j41=Object.freeze({query:"",options:[]}),s4A=C7.createContext(null);function P41(){let A=C7.useContext(s4A);if(!A)throw new Error("useCompletions must be used within a CompletionsProvider");return A}function o4A({children:A,fuzzyServer:Q}){let[B,J]=C7.useState(j41),[D,z]=C7.useState(""),[Z,K]=C7.useState(null),G=C7.useRef(0),[X]=C7.useState(()=>new P8),Y=C7.useCallback((w)=>{if(z(w),w!==Z)K(null)},[Z]),q=C7.useCallback(()=>K(D),[D]),F=C7.useCallback((w)=>{X.next(w)},[X]),E=C7.useMemo(()=>D.startsWith("@")?D.slice(1):null,[D]);C7.useEffect(()=>{if(E!==null&&D!==Z){let I=++G.current;(async()=>{try{let M=await Q.query(E);if(I===G.current)J({query:E,options:M})}catch(M){if(I===G.current)S1.error("Completion request failed",{query:E,error:M}),J(j41)}})()}else J(j41)},[D,Z,Q,E]),C7.useEffect(()=>{return()=>{X.complete()}},[X]);let H=C7.useMemo(()=>{if(E===null)return!1;return E.startsWith(B.query)&&Z!==D&&D!==""},[B,D,Z,E]);return P0(s4A.Provider,{value:{completions:H?B:j41,hasCompletions:H?B.options.length>0:!1,selectCompletion:F,completionSelected:X,onWordHighlight:Y,ignore:q},children:A})}t6();vQ();b6();var I5=hA(H8(),1);var _41=hA(A5A(),1);function wO(A,Q,{target:B="stdout",...J}={}){if(!_41.default[B]){if(J.fallback===!1)return A;return typeof J.fallback==="function"?J.fallback(A,Q):`${A} (​${Q}​)`}return EX.link(A,Q)}wO.isSupported=_41.default.stdout;wO.stderr=(A,Q,B={})=>wO(A,Q,{target:"stderr",...B});wO.stderr.isSupported=_41.default.stderr;function WW({url:A,children:Q}){return P0(L41,{transform:(B)=>wO(B,A,{fallback:!0}),children:P0(mA,{children:Q})})}function hq({action:A,children:Q}){return Y2(jA,{flexDirection:"row",gap:1,width:100,children:[P0(jA,{flexShrink:0,children:P0(mA,{dimColor:!0,children:A})}),Q&&P0(jA,{flexShrink:1,children:P0(mA,{wrap:"truncate-end",children:Q})})]})}function ao6(A,Q){let B;switch(A){case"in-progress":B="Reading";break;case"done":B="Read";break;case"error":B="Failed to read";break;default:B="Cancelled reading";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function ro6(A,Q){let B;switch(A){case"in-progress":B="Editing";break;case"done":B="Edited";break;case"error":B="Failed to edit";break;default:B="Cancelled editing";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function no6(A,Q){let B;switch(A){case"in-progress":B="Creating";break;case"done":B="Created";break;case"error":B="Failed to create";break;default:B="Cancelled creating";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function so6(A,Q){let B;switch(A){case"in-progress":B="Listing";break;case"done":B="Listed";break;case"error":B="Failed to list";break;default:B="Cancelled listing";break}return P0(hq,{action:B,children:Q?.path?Q.path:"."})}function oo6(A,Q){let B;switch(A){case"in-progress":B="Formatting";break;case"done":B="Formatted";break;case"error":B="Failed to format";break;default:B="Cancelled formatting";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function to6(A,Q){let B;switch(A){case"in-progress":B="Searching for";break;case"done":B="Searched for";break;case"error":B="Failed to search for";break;default:B="Cancelled searching for";break}return Y2(hq,{action:B,children:[Y2(mA,{color:"cyan",children:['"',Q?.pattern||"text",'"']}),Q?.path&&Y2(pp,{children:[P0(mA,{children:" in "}),P0(mA,{children:Q.path})]})]})}function eo6(A,Q){let B;switch(A){case"in-progress":B="Searching for";break;case"done":B="Searched for files matching";break;case"error":B="Failed to search for";break;default:B="Cancelled searching for";break}return P0(hq,{action:B,children:P0(mA,{color:"cyan",children:Q?.filePattern||"files"})})}function At6(A,Q){let B;switch(A){case"in-progress":B="Searching web for";break;case"done":B="Searched web for";break;case"error":B="Failed web search for";break;default:B="Cancelled web search for";break}return P0(hq,{action:B,children:Y2(mA,{color:"cyan",children:['"',Q?.query||"search",'"']})})}function Qt6(A){let Q;switch(A){case"in-progress":Q="Thinking";break;case"done":Q="Thought process complete";break;case"error":Q="Failed to think";break;default:Q="Cancelled thinking";break}return P0(hq,{action:Q})}function Bt6(A,Q){let B;switch(Q){case"in-progress":B=`Running ${A}`;break;case"done":B=`${A} completed`;break;case"error":B=`${A} failed`;break;default:B=`${A} cancelled`;break}return P0(hq,{action:B})}function Q5A({toolUse:A}){if(A.tool_name===B4)return ao6(A.status,A.input);else if(A.tool_name===ED)return ro6(A.status,A.input);else if(A.tool_name===aX)return no6(A.status,A.input);else if(A.tool_name===rX)return so6(A.status,A.input);else if(A.tool_name===ZM)return oo6(A.status,A.input);else if(A.tool_name===g5)return to6(A.status,A.input);else if(A.tool_name==="glob")return eo6(A.status,A.input);else if(A.tool_name==="web_search")return At6(A.status,A.input);else if(A.tool_name==="think")return Qt6(A.status);else return Bt6(A.tool_name,A.status)}function B5A(A,Q,B="",J=!1){let D=Q?"╰──":"├──",z=B+(Q?" ":"│ ");return Y2(jA,{flexDirection:"column",children:[Y2(jA,{flexDirection:"row",children:[Y2(mA,{wrap:"end",children:[B,!A.hideChar&&D," "]}),A.value]}),A.children.map((Z,K)=>B5A(Z,K===A.children.length-1,z,!1))]},Math.random())}function J5A({tree:A}){return P0(jA,{flexDirection:"column",children:A.map((Q,B)=>B5A(Q,B===A.length-1,"",!0))})}function Jt6(A){let Q=A.input;switch(A.name){case B4:return{action:"Reading",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case ED:return{action:"Editing",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case aX:return{action:"Creating",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case rX:return{action:"Scanning",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"directory"};case oK:return{action:"Finding",target:Q?.filePattern};case g5:return{action:"Searching",target:`"${Q?.pattern}"`};case FD:return{action:"Searching",target:Q?.query?`"${Q.query}"`:"codebase"};case nK:return{action:"Consulting oracle",target:Q?.task?Q.task:void 0};case Wd:return{action:"Searching",target:Q?.query?`"${Q.query}"`:"web"};case UU:return{action:"Reading",target:Q?.url?new URL(Q.url).hostname:"web page"};case P7:return{action:"$",target:Q?.cmd?P0(mA,{color:"green",children:Q.cmd}):void 0};case YH:return{action:"Generating",target:"diagram"};case _7:return{action:"Updating",target:`${Array.isArray(Q?.todos)?Q.todos.length:0} TODOs`};case sK:return{action:"Reading",target:"TODOs"};case g$:return{action:"Reverting",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case ZM:return{action:"Formatting",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case iX:return{action:"Checking",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"diagnostics"};default:return{action:A.name,target:void 0}}}function D5A({activeTools:A,subagents:Q}){let B=Q.filter(({isCompleted:K})=>!K),J=A.filter(({subthreadID:K})=>!K);if(!(B.length>0||A.length>0))return null;let z=[];function Z({toolUse:K,toolRun:G}){let{action:X,target:Y}=Jt6(K),q=[];if(K.name===P7){let F=G;q.push(...zt6(F))}else if(Zt6(K.name)){let F=G;q.push(...Kt6(F))}if(G.status==="blocked-on-user")q.push({value:P0(mA,{italic:!0,children:"Waiting for confirmation"}),children:[]});return{value:Dt6(G,X,Y),children:q}}if(z.push(...J.map(Z)),B.forEach((K)=>{let G=A.filter(({subthreadID:q})=>q===K.subThreadID),X=y8A(K.agentState),Y=X?`(${X})`:null;z.push({value:Y2(jA,{flexDirection:"row",gap:1,children:[P0(mA,{dimColor:!0,children:"Subagent:"}),P0(mA,{bold:!0,children:K.taskDescription}),Y&&P0(mA,{dimColor:!0,children:Y})]}),children:G.map(Z)})}),z.length===0)return null;return Y2(jA,{flexDirection:"column",children:[P0(mA,{children:"Tools:"}),P0(J5A,{tree:z})]})}function Dt6(A,Q,B){return Y2(jA,{flexDirection:"row",width:"100%",gap:1,children:[P0(jA,{flexShrink:0,children:P0(mA,{bold:!0,color:A.status==="blocked-on-user"?"yellow":void 0,children:Q})}),B&&P0(jA,{flexShrink:1,children:P0(mA,{wrap:"truncate-end",children:B})}),A.status!=="blocked-on-user"&&P0(jA,{flexShrink:0,children:P0(mA,{dimColor:!0})})]})}function zt6(A){if(A.status!=="in-progress"&&A.status!=="done")return[];return Gt6(A.progress?.output).map((B)=>({value:P0(mA,{dimColor:!0,wrap:"truncate-end",children:B}),hideChar:!0,children:[]}))}function Zt6(A){return A===nK||A===FD}function Kt6(A){if(A.status!=="in-progress"&&A.status!=="done")return[];let Q=[];if(A.progress)for(let B of A.progress){if(B.message)Q.push({value:P0(jA,{flexDirection:"row",gap:1,width:100,children:P0(jA,{flexShrink:0,children:P0(mA,{dimColor:!0,wrap:"truncate-end",children:B.message})})}),children:[]});if(B.tool_uses)B.tool_uses.forEach((J)=>{Q.push({value:P0(Q5A,{toolUse:J}),children:[]})})}return Q.slice(-3)}function Gt6(A){if(!A)return[];let Q=A.split(`
4545
+ `);else if(!this.options.debug)this.log.done();if(this.isUnmounted=!0,wW.updateContainerSync(null,this.container,null,m4A),wW.flushSyncWork(),JS.delete(this.options.stdout),A instanceof Error)this.rejectExitPromise(A);else this.resolveExitPromise()}async waitUntilExit(){return this.exitPromise||=new Promise((A,Q)=>{this.resolveExitPromise=A,this.rejectExitPromise=Q}),this.exitPromise}clear(){if(!UO&&!this.options.debug)this.log.clear()}patchConsole(){if(this.options.debug)return;this.restoreConsole=D9A((A,Q)=>{if(A==="stdout")this.writeToStdout(Q);if(A==="stderr"){if(!Q.startsWith("The above error occurred"))this.writeToStderr(Q)}})}}var Ro6=(A,Q)=>{let B={stdout:O41.stdout,stdin:O41.stdin,stderr:O41.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,...Lo6(Q)},J=To6(B.stdout,()=>new V41(B));return J.render(A),{rerender:J.render,unmount(){J.unmount()},waitUntilExit:J.waitUntilExit,cleanup:()=>JS.delete(B.stdout),clear:J.clear}},Hf1=Ro6,Lo6=(A={})=>{if(A instanceof Oo6)return{stdout:A,stdin:O41.stdin};return A},To6=(A,Q)=>{let B=JS.get(A);if(!B)B=Q(),JS.set(A,B);return B};var xE=hA(H8(),1);function R41(A){let{items:Q,children:B,style:J}=A,[D,z]=xE.useState(0),Z=xE.useMemo(()=>{return Q.slice(D)},[Q,D]);xE.useLayoutEffect(()=>{z(Q.length)},[Q.length]);let K=Z.map((X,Y)=>{return B(X,D+Y)}),G=xE.useMemo(()=>({position:"absolute",flexDirection:"column",...J}),[J]);return xE.default.createElement("ink-box",{internal_static:!0,style:G},K)}var c4A=hA(H8(),1);function L41({children:A,transform:Q}){if(A===void 0||A===null)return null;return c4A.default.createElement("ink-text",{style:{flexGrow:0,flexShrink:1,flexDirection:"row"},internal_transform:Q},A)}var jo6=hA(H8(),1);var Po6=hA(H8(),1);var vo6=hA(H8(),1);var _o6={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},So6=[...Object.values(_o6),"backspace"];var d4A=hA(H8(),1);var $o6=()=>d4A.useContext(w41),hp=$o6;var l4A=hA(H8(),1);var ko6=()=>l4A.useContext(H41),wf1=ko6;var i4A=hA(H8(),1);var fo6=()=>i4A.useContext(I41),mp=fo6;var yo6=hA(H8(),1);var If1=hA(H8(),1);var bo6=hA(H8(),1);var go6=(A)=>({width:A.yogaNode?.getComputedWidth()??0,height:A.yogaNode?.getComputedHeight()??0}),up=go6;var jf1=hA(H8(),1);t6();n7();LC();b6();var LX=hA(H8(),1);t6();UI1();import{mkdtemp as xo6,readFile as ho6,unlink as mo6}from"fs/promises";import{execSync as uo6}from"node:child_process";import{rmdir as po6}from"node:fs/promises";import{tmpdir as co6}from"node:os";import a4A from"node:path";t6();class T41 extends Error{constructor(A="Thread has no messages to compact"){super(A);this.name="NoMessagesToCompactError"}}function Wf1(A){if(A instanceof T41)return{title:"Cannot compact thread",description:"Thread has no messages to compact."};return S1.warn("Unknown error type encountered",{name:A.name,message:A.message,stack:A.stack}),{title:"Error",description:A.message||"An unexpected error occurred."}}class Mf1{constructor(){}query(A){let Q=A.toLowerCase();return Object.values(r4A).filter((B)=>B.name.toLowerCase().includes(Q))}get(A){return r4A[A]}}var r4A={quit:{name:"quit",description:"Exit Amp",execute:async(A)=>{A.exitApp()}},agent:{name:"agent",description:"Generate an AGENT.md file in the current workspace",execute:async(A)=>{A.worker.handle({type:"user:message",message:{content:[{type:"text",text:Ez0}]}});return}},compact:{name:"compact",description:"Compact the thread",execute:async(A)=>{if(A.thread.messages.length===0)return new T41;A.worker.summarizeThread()}},editor:{name:"editor",description:"Open $EDITOR to write a prompt",execute:async(A)=>{if(!A.editorDispatch)return new Error("Editor dispatch not available");try{let Q=process.env.EDITOR||process.env.VISUAL||"nano",B=await xo6(a4A.join(co6(),"amp-edit-")),J=a4A.join(B,"message.txt");uo6(`${Q} "${J}"`,{stdio:"inherit"}),process.stdout.write("\x1B[?25l");try{let z=(await ho6(J,"utf-8")).trim();if(z)A.editorDispatch({type:"set-input",input:z})}catch(D){if(D?.code==="ENOENT")return;return S1.error("Failed to read temporary file",D),new Error("Failed to read editor content")}try{await mo6(J),await po6(B)}catch(D){S1.warn("Failed to clean up temporary file",D)}return}catch(Q){return S1.error("Failed to open editor",Q),new Error("Failed to open editor")}}}};t6();b6();var C7=hA(H8(),1);var do6=Symbol.for("react.transitional.element"),lo6=Symbol.for("react.fragment");function n4A(A,Q,B){var J=null;if(B!==void 0&&(J=""+B),Q.key!==void 0&&(J=""+Q.key),"key"in Q){B={};for(var D in Q)D!=="key"&&(B[D]=Q[D])}else B=Q;return Q=B.ref,{$$typeof:do6,type:A,key:J,ref:Q!==void 0?Q:null,props:B}}var pp=lo6,P0=n4A,Y2=n4A;var j41=Object.freeze({query:"",options:[]}),s4A=C7.createContext(null);function P41(){let A=C7.useContext(s4A);if(!A)throw new Error("useCompletions must be used within a CompletionsProvider");return A}function o4A({children:A,fuzzyServer:Q}){let[B,J]=C7.useState(j41),[D,z]=C7.useState(""),[Z,K]=C7.useState(null),G=C7.useRef(0),[X]=C7.useState(()=>new P8),Y=C7.useCallback((w)=>{if(z(w),w!==Z)K(null)},[Z]),q=C7.useCallback(()=>K(D),[D]),F=C7.useCallback((w)=>{X.next(w)},[X]),E=C7.useMemo(()=>D.startsWith("@")?D.slice(1):null,[D]);C7.useEffect(()=>{if(E!==null&&D!==Z){let I=++G.current;(async()=>{try{let M=await Q.query(E);if(I===G.current)J({query:E,options:M})}catch(M){if(I===G.current)S1.error("Completion request failed",{query:E,error:M}),J(j41)}})()}else J(j41)},[D,Z,Q,E]),C7.useEffect(()=>{return()=>{X.complete()}},[X]);let H=C7.useMemo(()=>{if(E===null)return!1;return E.startsWith(B.query)&&Z!==D&&D!==""},[B,D,Z,E]);return P0(s4A.Provider,{value:{completions:H?B:j41,hasCompletions:H?B.options.length>0:!1,selectCompletion:F,completionSelected:X,onWordHighlight:Y,ignore:q},children:A})}t6();vQ();b6();var I5=hA(H8(),1);var _41=hA(A5A(),1);function wO(A,Q,{target:B="stdout",...J}={}){if(!_41.default[B]){if(J.fallback===!1)return A;return typeof J.fallback==="function"?J.fallback(A,Q):`${A} (​${Q}​)`}return EX.link(A,Q)}wO.isSupported=_41.default.stdout;wO.stderr=(A,Q,B={})=>wO(A,Q,{target:"stderr",...B});wO.stderr.isSupported=_41.default.stderr;function WW({url:A,children:Q}){return P0(L41,{transform:(B)=>wO(B,A,{fallback:!0}),children:P0(mA,{children:Q})})}function hq({action:A,children:Q}){return Y2(jA,{flexDirection:"row",gap:1,width:100,children:[P0(jA,{flexShrink:0,children:P0(mA,{dimColor:!0,children:A})}),Q&&P0(jA,{flexShrink:1,children:P0(mA,{wrap:"truncate-end",children:Q})})]})}function ao6(A,Q){let B;switch(A){case"in-progress":B="Reading";break;case"done":B="Read";break;case"error":B="Failed to read";break;default:B="Cancelled reading";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function ro6(A,Q){let B;switch(A){case"in-progress":B="Editing";break;case"done":B="Edited";break;case"error":B="Failed to edit";break;default:B="Cancelled editing";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function no6(A,Q){let B;switch(A){case"in-progress":B="Creating";break;case"done":B="Created";break;case"error":B="Failed to create";break;default:B="Cancelled creating";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function so6(A,Q){let B;switch(A){case"in-progress":B="Listing";break;case"done":B="Listed";break;case"error":B="Failed to list";break;default:B="Cancelled listing";break}return P0(hq,{action:B,children:Q?.path?Q.path:"."})}function oo6(A,Q){let B;switch(A){case"in-progress":B="Formatting";break;case"done":B="Formatted";break;case"error":B="Failed to format";break;default:B="Cancelled formatting";break}return P0(hq,{action:B,children:Q?.path&&Q.path})}function to6(A,Q){let B;switch(A){case"in-progress":B="Searching for";break;case"done":B="Searched for";break;case"error":B="Failed to search for";break;default:B="Cancelled searching for";break}return Y2(hq,{action:B,children:[Y2(mA,{color:"cyan",children:['"',Q?.pattern||"text",'"']}),Q?.path&&Y2(pp,{children:[P0(mA,{children:" in "}),P0(mA,{children:Q.path})]})]})}function eo6(A,Q){let B;switch(A){case"in-progress":B="Searching for";break;case"done":B="Searched for files matching";break;case"error":B="Failed to search for";break;default:B="Cancelled searching for";break}return P0(hq,{action:B,children:P0(mA,{color:"cyan",children:Q?.filePattern||"files"})})}function At6(A,Q){let B;switch(A){case"in-progress":B="Searching web for";break;case"done":B="Searched web for";break;case"error":B="Failed web search for";break;default:B="Cancelled web search for";break}return P0(hq,{action:B,children:Y2(mA,{color:"cyan",children:['"',Q?.query||"search",'"']})})}function Qt6(A){let Q;switch(A){case"in-progress":Q="Thinking";break;case"done":Q="Thought process complete";break;case"error":Q="Failed to think";break;default:Q="Cancelled thinking";break}return P0(hq,{action:Q})}function Bt6(A,Q){let B;switch(Q){case"in-progress":B=`Running ${A}`;break;case"done":B=`${A} completed`;break;case"error":B=`${A} failed`;break;default:B=`${A} cancelled`;break}return P0(hq,{action:B})}function Q5A({toolUse:A}){if(A.tool_name===B4)return ao6(A.status,A.input);else if(A.tool_name===ED)return ro6(A.status,A.input);else if(A.tool_name===aX)return no6(A.status,A.input);else if(A.tool_name===rX)return so6(A.status,A.input);else if(A.tool_name===ZM)return oo6(A.status,A.input);else if(A.tool_name===g5)return to6(A.status,A.input);else if(A.tool_name==="glob")return eo6(A.status,A.input);else if(A.tool_name==="web_search")return At6(A.status,A.input);else if(A.tool_name==="think")return Qt6(A.status);else return Bt6(A.tool_name,A.status)}function B5A(A,Q,B="",J=!1){let D=Q?"╰──":"├──",z=B+(Q?" ":"│ ");return Y2(jA,{flexDirection:"column",children:[Y2(jA,{flexDirection:"row",children:[Y2(mA,{wrap:"end",children:[B,!A.hideChar&&D," "]}),A.value]}),A.children.map((Z,K)=>B5A(Z,K===A.children.length-1,z,!1))]},Math.random())}function J5A({tree:A}){return P0(jA,{flexDirection:"column",children:A.map((Q,B)=>B5A(Q,B===A.length-1,"",!0))})}function Jt6(A){let Q=A.input;switch(A.name){case B4:return{action:"Reading",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case ED:return{action:"Editing",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case aX:return{action:"Creating",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case rX:return{action:"Scanning",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"directory"};case oK:return{action:"Finding",target:Q?.filePattern};case g5:return{action:"Searching",target:`"${Q?.pattern}"`};case FD:return{action:"Searching",target:Q?.query?`"${Q.query}"`:"codebase"};case nK:return{action:"Consulting oracle",target:Q?.task?Q.task:void 0};case Wd:return{action:"Searching",target:Q?.query?`"${Q.query}"`:"web"};case UU:return{action:"Reading",target:Q?.url?new URL(Q.url).hostname:"web page"};case P7:return{action:"$",target:Q?.cmd?P0(mA,{color:"green",children:Q.cmd}):void 0};case YH:return{action:"Generating",target:"diagram"};case _7:return{action:"Updating",target:`${Array.isArray(Q?.todos)?Q.todos.length:0} TODOs`};case sK:return{action:"Reading",target:"TODOs"};case g$:return{action:"Reverting",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case ZM:return{action:"Formatting",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"file"};case iX:return{action:"Checking",target:Q?.path?P0(WW,{url:`file://${Q.path}`,children:Q.path.split("/").pop()}):"diagnostics"};default:return{action:A.name,target:void 0}}}function D5A({activeTools:A,subagents:Q}){let B=Q.filter(({isCompleted:K})=>!K),J=A.filter(({subthreadID:K})=>!K);if(!(B.length>0||A.length>0))return null;let z=[];function Z({toolUse:K,toolRun:G}){let{action:X,target:Y}=Jt6(K),q=[];if(K.name===P7){let F=G;q.push(...zt6(F))}else if(Zt6(K.name)){let F=G;q.push(...Kt6(F))}if(G.status==="blocked-on-user")q.push({value:P0(mA,{italic:!0,children:"Waiting for confirmation"}),children:[]});return{value:Dt6(G,X,Y),children:q}}if(z.push(...J.map(Z)),B.forEach((K)=>{let G=A.filter(({subthreadID:q})=>q===K.subThreadID),X=y8A(K.agentState),Y=X?`(${X})`:null;z.push({value:Y2(jA,{flexDirection:"row",gap:1,children:[P0(mA,{dimColor:!0,children:"Subagent:"}),P0(mA,{bold:!0,children:K.taskDescription}),Y&&P0(mA,{dimColor:!0,children:Y})]}),children:G.map(Z)})}),z.length===0)return null;return Y2(jA,{flexDirection:"column",children:[P0(mA,{children:"Tools:"}),P0(J5A,{tree:z})]})}function Dt6(A,Q,B){return Y2(jA,{flexDirection:"row",width:"100%",gap:1,children:[P0(jA,{flexShrink:0,children:P0(mA,{bold:!0,color:A.status==="blocked-on-user"?"yellow":void 0,children:Q})}),B&&P0(jA,{flexShrink:1,children:P0(mA,{wrap:"truncate-end",children:B})}),A.status!=="blocked-on-user"&&P0(jA,{flexShrink:0,children:P0(mA,{dimColor:!0})})]})}function zt6(A){if(A.status!=="in-progress"&&A.status!=="done")return[];return Gt6(A.progress?.output).map((B)=>({value:P0(mA,{dimColor:!0,wrap:"truncate-end",children:B}),hideChar:!0,children:[]}))}function Zt6(A){return A===nK||A===FD}function Kt6(A){if(A.status!=="in-progress"&&A.status!=="done")return[];let Q=[];if(A.progress)for(let B of A.progress){if(B.message)Q.push({value:P0(jA,{flexDirection:"row",gap:1,width:100,children:P0(jA,{flexShrink:0,children:P0(mA,{dimColor:!0,wrap:"truncate-end",children:B.message})})}),children:[]});if(B.tool_uses)B.tool_uses.forEach((J)=>{Q.push({value:P0(Q5A,{toolUse:J}),children:[]})})}return Q.slice(-3)}function Gt6(A){if(!A)return[];let Q=A.split(`
4546
4546
  `).filter((J)=>J.trim()!==""),B=3;return Q.slice(-B)}HD();RQ1();function Xt6(A){switch(A){case"done":return"✓";case"error":return"✗";case"cancelled":case"rejected-by-user":return"✗";default:return"⋯"}}function Z5A(A){switch(A){case"done":return j0.green;case"error":return j0.red;case"cancelled":case"rejected-by-user":return j0.gray;default:return j0.blue}}function S41(A,Q,B){let J=Z5A(Q),D=Xt6(Q),z=Q==="cancelled"?j0.bold.strikethrough:j0.bold,Z=`${J(D)} ${z(A)}`;if(B){let K=Q==="cancelled"?j0.strikethrough:j0.reset;Z+=` ${K(B)}`}if(Q==="cancelled"||Q==="rejected-by-user"){let K=Q==="cancelled"?"cancelled":"rejected";Z+=` ${j0.gray.italic(`(${K})`)}`}return Z}function Yt6(A,Q=void 0,B=!1){let J=A.input;if(!Q)return[];let D=Q.run.status==="done"?Q.run.result:null,z=D&&D.exitCode!=null&&D.exitCode!==0,Z=B||z;if(Z){if(!["done","error","rejected-by-user","cancelled","in-progress","blocked-on-user"].includes(Q.run.status))return[]}else if(!SQ(Q.run))return[];let K=[],G=z?j0.red:Z5A(Q.run.status),X=Q.run.status==="cancelled"?j0.strikethrough:j0.reset,q=(J.cmd||"").split(`
4547
4547
  `),F=q[0]||"",E=q.slice(1),H;if(Q.run.status==="rejected-by-user")H=`${j0.dim("$")} ${j0.dim(F)} ${j0.dim.italic("(rejected)")}`;else if(Q.run.status==="cancelled")H=`${G(j0.bold("$"))} ${X(j0.bold(F))} ${j0.gray.italic("(cancelled)")}`;else H=`${G(j0.bold("$"))} ${X(j0.bold(F))}`;let w=[];if(J.cwd)w.push(`in: ${j0.dim(J.cwd)}`);if(z)w.push(`exit code: ${j0.red(D.exitCode)}`);if(w.length>0&&Q.run.status!=="rejected-by-user")H+=j0.italic(` (${w.join(", ")})`);K.push(H);for(let I of E)K.push(` ${X(j0.bold(I))}`);if(Q.run.status==="error"&&Q.run.error?.message)K.push(` ${j0.red(`Error: ${Q.run.error.message}`)}`);if(Z){if(Q.run.status==="done"&&D&&D.output)K.push(...z5A(D.output));else if(Q.run.status==="in-progress"||Q.run.status==="cancelled"){let I=Q.run.progress?.output;if(I&&typeof I==="string")K.push(...z5A(I))}else if(Q.run.status==="blocked-on-user"){let I=Q.run.toAllow;if(I&&Array.isArray(I))K.push(` ${j0.yellow("Blocked - commands to allow:")}`),I.forEach((W)=>{K.push(` ${j0.dim(W)}`)});else K.push(` ${j0.red("[DEBUG] blocked-on-user but no toAllow found")}`),K.push(` ${j0.red(`[DEBUG] run data: ${JSON.stringify(Q.run,null,2)}`)}`)}}return K}function z5A(A){let B=A.replace(/\r/g,"").trimEnd().split(`
4548
4548
  `),J=15,D=[];if(B.length>15){let z=B.length-15,Z=B.slice(-15);D.push(` ${j0.dim(`[... ${z} lines truncated ...]`)}`),D.push(...Z.map((K)=>` ${j0.dim(K)}`))}else D.push(...B.map((z)=>` ${j0.dim(z)}`));return D}function qt6(A,Q=void 0,B=!1){let J=A.input;if(!Q||!SQ(Q.run))return[];let D=[],z="";if(J.path)z+=J.path;if(J.read_range)z+=` ${j0.dim(`(lines ${J.read_range[0]}-${J.read_range[1]})`)}`;if(D.push(S41("Read",Q.run.status,z)),Q.run.status==="error"&&Q.run.error?.message)D.push(` ${j0.red(`Error: ${Q.run.error.message}`)}`);if(B&&Q.run.status==="done"){let Z=Q.run.result,K=typeof Z==="string"?Z:Z?.content;if(K)D.push(...K.trimEnd().split(`
@@ -4568,10 +4568,10 @@ ${Y}`}else K=z.map((G)=>` ${G}`).join(`
4568
4568
  `).replace(/\r/g,`
4569
4569
  `).replace(/\t/g," ");S1.info("Normalized input",{normalizedInput:JSON.stringify(y)}),Z({type:"insert-text",text:y});return}if(P.pageUp){T();return}if(P.pageDown){L();return}if(P.upArrow||P.ctrl&&u==="p"){if($)return;if(zS(W,w).line===0){T();return}Z({type:"move-cursor",direction:"up"});return}if(P.downArrow||P.ctrl&&u==="n"){if($)return;if(zS(W,w).line===W.lines.length-1){L();return}Z({type:"move-cursor",direction:"down"});return}if(P.escape){if(E){q();return}if(V)_();else if(H.trim().length===0)return;else{if(J.state==="active"&&J.inferenceState==="running")return;Z({type:"set-input",input:""})}return}if(P.super&&P.leftArrow||P.ctrl&&u==="a"){Z({type:"jump-to-start-of-line"});return}if(P.super&&P.rightArrow||P.ctrl&&u==="e"){Z({type:"jump-to-end-of-line"});return}if(P.alt&&P.rightArrow){Z({type:"jump-to-next-word"});return}if(P.alt&&P.leftArrow){Z({type:"jump-to-prev-word"});return}if(P.leftArrow||P.ctrl&&u==="b"){Z({type:"move-cursor",direction:"left"});return}if(P.rightArrow||P.ctrl&&u==="f"){Z({type:"move-cursor",direction:"right"});return}if(P.home){Z({type:"jump-to-beginning"});return}if(P.end){Z({type:"jump-to-end"});return}if(P.ctrl&&P.backspace||P.alt&&P.backspace||P.ctrl&&u==="w"){Z({type:"delete-word-backward"});return}if(P.super&&P.backspace){Z({type:"delete-whole-line"});return}if(P.ctrl&&u==="u"){Z({type:"delete-to-beginning-of-line"});return}if(P.ctrl&&u==="k"){Z({type:"delete-to-end-of-line"});return}if(P.ctrl&&u==="d"||P.delete){if(w<YS.default(H).length)Z({type:"remove-text",from:w,to:w+1});return}if(P.alt&&u==="d"){Z({type:"delete-word-forward"});return}if(P.backspace||P.ctrl&&u==="h"){if(w>0)Z({type:"remove-text",from:w-1,to:w});return}if(P.ctrl&&u==="y"){if(I.length>0){let y=I[0];Z({type:"insert-text",text:y})}return}let k=P.return&&(P.shift||P.meta||P.ctrl||P.alt)||!P.return&&u==="\r"||u==="\x1B[27;2;13~"||u==="[27;2;13~"||u==="\x1B[13;2u";if(S1.debug("Modified Enter detection",{isModifiedEnter:k,"key.return":P.return,"key.shift":P.shift,"key.meta":P.meta,"key.ctrl":P.ctrl,keyInput:JSON.stringify(u),hasContent:H.trim().length>0}),k){if($)return;Z({type:"insert-text",text:`
4570
4570
  `});return}if(P.return&&!P.shift&&!P.meta&&!P.ctrl){if($)return;if(H.endsWith("\\")){Z({type:"replace-text",startPos:H.length-1,endPos:H.length,replacement:`
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!==b5)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=I5.useMemo(()=>H?E.items.concat({id:"streaming-assistant",type:"message",message:H}):E.items,[H,E.items]),M=I?.title||"Untitled",C=I5.useMemo(()=>I?ex1(I):void 0,[I]);o5A(I?.title);let V=I5.useRef(new P8),[R,T]=I5.useState({baseView:"running",rerendering:!1,resizeCounter:0,dismissedEphemeralError:null,slashCommandQuery:null,uiError:null}),L=I5.useRef(null),_=I5.useRef(null),[j,v]=k5A(),$=I5.useCallback((s)=>{T((Q1)=>({...Q1,slashCommandQuery:s}))},[]),g=I5.useMemo(()=>{if(R.slashCommandQuery===null)return[];return G.query(R.slashCommandQuery)},[R.slashCommandQuery,G]),u=I5.useCallback(()=>{T((s)=>({...s,rerendering:!0})),process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),V.current.next()},[T,V]),P=I5.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=I5.useCallback((s)=>{v({type:"clear"}),D(s)},[v,D]);I5.useEffect(()=>{return process.stdout.on("resize",u),()=>{process.stdout.off("resize",u)}},[u]),I5.useEffect(()=>{let s=V.current.pipe(VJ(We6)).subscribe(()=>{T((Q1)=>({...Q1,rerendering:!1,resizeCounter:Q1.resizeCounter+1}))});return()=>{s.unsubscribe()}},[V,T]),I5.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=I5.useMemo(()=>M5A(m),[m]),{hasCompletions:h,completions:d,selectCompletion:l}=P41(),J1=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":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=I5.useMemo(()=>A.slice(0,10).map((D)=>({value:D.name,label:D.name,description:D.description})),[A]);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=I5.useMemo(()=>A.slice(0,B).map((z)=>({value:z,label:z})),[A,B]),D=I5.useCallback((z)=>{if(z===null)return;let Z=A.find((K)=>K===z);if(!Z)return;Q(Z)},[A,Q]);if(J.length===0)return null;return P0(jA,{marginBottom:1,children:P0(IO,{title:"Insert file name:",options:J,onSelect:D})})}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(`
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!==b5)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=I5.useMemo(()=>H?E.items.concat({id:"streaming-assistant",type:"message",message:H}):E.items,[H,E.items]),M=I?.title||"Untitled",C=I5.useMemo(()=>I?ex1(I):void 0,[I]);o5A(I?.title);let V=I5.useRef(new P8),[R,T]=I5.useState({baseView:"running",rerendering:!1,resizeCounter:0,dismissedEphemeralError:null,slashCommandQuery:null,uiError:null}),L=I5.useRef(null),_=I5.useRef(null),[j,v]=k5A(),$=I5.useCallback((s)=>{T((Q1)=>({...Q1,slashCommandQuery:s}))},[]),g=I5.useMemo(()=>{if(R.slashCommandQuery===null)return[];return G.query(R.slashCommandQuery)},[R.slashCommandQuery,G]),u=I5.useCallback(()=>{T((s)=>({...s,rerendering:!0})),process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),V.current.next()},[T,V]),P=I5.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,exitApp:z});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,z]),k=I5.useCallback((s)=>{v({type:"clear"}),D(s)},[v,D]);I5.useEffect(()=>{return process.stdout.on("resize",u),()=>{process.stdout.off("resize",u)}},[u]),I5.useEffect(()=>{let s=V.current.pipe(VJ(We6)).subscribe(()=>{T((Q1)=>({...Q1,rerendering:!1,resizeCounter:Q1.resizeCounter+1}))});return()=>{s.unsubscribe()}},[V,T]),I5.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=I5.useMemo(()=>M5A(m),[m]),{hasCompletions:h,completions:d,selectCompletion:l}=P41(),J1=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":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=I5.useMemo(()=>A.slice(0,10).map((D)=>({value:D.name,label:D.name,description:D.description})),[A]);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=I5.useMemo(()=>A.slice(0,B).map((z)=>({value:z,label:z})),[A,B]),D=I5.useCallback((z)=>{if(z===null)return;let Z=A.find((K)=>K===z);if(!Z)return;Q(Z)},[A,Q]);if(J.length===0)return null;return P0(jA,{marginBottom:1,children:P0(IO,{title:"Insert file name:",options:J,onSelect:D})})}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.1753289667-g54d21a");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.1753290974-g79bbdd");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.1753289667-g54d21a ${A.printer.print("(released 2025-07-23T17:02:28.192Z)",{foreground:"gray"})}
4590
- `);else b4.write(`0.0.1753289667-g54d21a (released 2025-07-23T17:02:28.192Z)
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.1753290974-g79bbdd ${A.printer.print("(released 2025-07-23T17:23:46.615Z)",{foreground:"gray"})}
4590
+ `);else b4.write(`0.0.1753290974-g79bbdd (released 2025-07-23T17:23:46.615Z)
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(Y){a2.write(A.printer.print("Error generating support bundle: ",{foreground:"red"})+`${Y instanceof Error?Y.message:String(Y)}
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,X)=>{try{let Y=AD(),q=X.optsWithGlobals();wp({logLevel:q.logLevel||process.env.AMP_LOG_LEVEL,logFile:q.logFile||process.env.AMP_LOG_FILE});let{update:F}=await Promise.resolve().then(() => (X7A(),G7A)),{checkNpmUpdate:E}=await Promise.resolve().then(() => (iG1(),Kr1)),H="0.0.1753289667-g54d21a";if(q.version)a2.write(Y.printer.print(`Updating to version ${q.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,X)=>{try{let Y=AD(),q=X.optsWithGlobals();wp({logLevel:q.logLevel||process.env.AMP_LOG_LEVEL,logFile:q.logFile||process.env.AMP_LOG_FILE});let{update:F}=await Promise.resolve().then(() => (X7A(),G7A)),{checkNpmUpdate:E}=await Promise.resolve().then(() => (iG1(),Kr1)),H="0.0.1753290974-g79bbdd";if(q.version)a2.write(Y.printer.print(`Updating to version ${q.version}...`,{foreground:"blue"})+`
4681
4681
  `),await F(q.version),a2.write(Y.printer.print(`✓ Successfully updated to version ${q.version}`,{foreground:"green"})+`
4682
4682
  `);else{a2.write(Y.printer.print("Checking for updates...",{foreground:"blue"})+`
4683
4683
  `);let w=await E(H);if(!w.hasUpdate)a2.write(Y.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.1753289667-g54d21a",
3
+ "version": "0.0.1753290974-g79bbdd",
4
4
  "description": "CLI for Amp, an agentic coding tool in research preview from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {