@sourcegraph/amp 0.0.1771358819-g9e835e → 0.0.1771373086-gedddec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +15 -10
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -433,7 +433,7 @@ Start by using the walkthrough tool to explore a starting point, then iterativel
|
|
|
433
433
|
- "Create a diagram showing the data flow from API request to database"
|
|
434
434
|
- "Explore the relationship between the Router and Controller components"
|
|
435
435
|
- "Show me how the event system connects publishers and subscribers"
|
|
436
|
-
`,mO0;var pO0=t(()=>{mO0={name:"walkthrough",description:'Explore and visualize codebase architecture. Use when
|
|
436
|
+
`,mO0;var pO0=t(()=>{mO0={name:"walkthrough",description:'Explore and visualize codebase architecture. Use ONLY when the user explicitly requests the walkthrough skill/tool. Do NOT use when "walk me through", "explain the flow", or similar phrases appear in other contexts — those are requests to read/understand code, not to perform a formal walkthrough.',frontmatter:{name:"walkthrough",description:'Explore and visualize codebase architecture. Use ONLY when the user explicitly requests the walkthrough skill/tool. Do NOT use when "walk me through", "explain the flow", or similar phrases appear in other contexts — those are requests to read/understand code, not to perform a formal walkthrough.'},content:M$4,baseDir:O$4,builtinTools:["walkthrough","walkthrough_diagram"]}});function dO0(J){return[vO0,uO0,mO0,fO0]}function cO0(J){return aU1[J]}var aU1;var _a=t(()=>{bO0();hO0();gO0();pO0();aU1={code_review:"code-review",walkthrough:"walkthrough",walkthrough_diagram:"walkthrough"}});function lO0(J){let Q=new AbortController;if(J?.aborted)Q.abort();else if(J)J.addEventListener("abort",()=>Q.abort(),{once:!0});return Q}function DF(J,Q){return J?.addEventListener("abort",Q,{once:!0}),()=>J?.removeEventListener("abort",Q)}function C5(J){if(J instanceof DOMException&&J.name==="AbortError")return!0;if(J instanceof Error){if(J.name==="AbortError")return!0;if("status"in J&&J.status===499)return!0;if(/request was aborted|The operation was aborted|AbortError/i.test(J.message))return!0;if(J?.cause&&C5(J.cause))return!0}return!1}function rU1(J){return J instanceof Error&&J.message===oU1.USER_CANCELLED}var oU1;var yY=t(()=>{oU1={USER_CANCELLED:"User cancelled"}});function n6(J,Q,Z=Q+"s"){return J===1?Q:Z}var N3=()=>{};class Sa{filesystem;constructor(J){this.filesystem=J}async readFile(J,Q){let{maxBytes:Z,signal:Y,rejectBinary:X=!1,encoding:V="utf8",textProcessing:K}=Q;try{let G=(await this.filesystem.stat(J,{signal:Y})).size,W=G>Z;if(G<=Z){let z=await this.filesystem.readBinaryFile(J,{signal:Y}),U=this.decodeText(z,V);if(U===void 0&&X)return{binary:!0,truncated:!1,fileSize:G};if(U&&K)U=I9.processText(U,K);return{content:U,binary:U===void 0,truncated:!1,fileSize:G}}let H;if(J.scheme==="file")try{if(H=await this.streamFile(J,Z,V,Y),H===void 0&&X)return{binary:!0,truncated:W,fileSize:G}}catch(z){T.debug("File streaming failed for large file",{uri:J},z)}let F=H;if(H&&K)F=I9.processText(H,K);return{content:F,binary:!1,truncated:W,fileSize:G}}catch(q){return{binary:!1,truncated:!1,fileSize:0,error:q instanceof Error?q:Error(String(q))}}}async streamFile(J,Q,Z,Y){let{createReadStream:X}=await import("node:fs"),V=X(J.fsPath,{highWaterMark:16384,end:Q-1}),K=DF(Y,()=>V.destroy());try{let q=[];for await(let W of V)q.push(W);let G=Buffer.concat(q);return this.decodeText(G,Z)}finally{K()}}decodeText(J,Q){try{let Z;if(Q!=="utf8"&&sU1(J))Z=J.toString(Q);else Z=new TextDecoder("utf-8",{fatal:!0}).decode(J);if(Z.includes("\x00"))return;return Z}catch{return}}}function sU1(J){return typeof Buffer<"u"&&Buffer.isBuffer(J)}async function iO0(J,Q,Z,Y){let X=Y?.maxBytes??32768,V=Y?.maxLines??500,K=Y?.maxLineBytes??2048,G=await new Sa(J).readFile(Q,{maxBytes:X,rejectBinary:!0,signal:Z,textProcessing:{maxLines:V,maxLineBytes:K,truncationStrategy:"ellipsis"}});if(G.error){T.debug("Failed to read file for mention",{uri:Q},G.error);return}if(G.binary)return"binary";if(!G.content)return;if(G.truncated){let W=Math.round(G.fileSize/1024),H=Math.round(X/1024);return`${G.content}
|
|
437
437
|
|
|
438
438
|
... [File truncated - showing first ${H}KB of ${W}KB total]`}return G.content}var A$4=4096,I9;var ka=t(()=>{yY();p1();I9=class I9{static encoder=new TextEncoder;static utf8Clamp(J,Q){let Z=0,Y=J.length;while(Z<Y){let X=Z+Y+1>>1;if(I9.encoder.encode(J.slice(0,X)).length<=Q)Z=X;else Y=X-1}return I9.safeTruncate(J,Z)}static utf8ClampFromEnd(J,Q){let Z=0,Y=J.length;while(Z<Y){let X=Math.floor((Z+Y)/2),V=J.slice(X);if(I9.encoder.encode(V).length<=Q)Y=X;else Z=X+1}return I9.safeTruncateStart(J.slice(Z))}static safeTruncateStart(J){if(J.length===0)return J;let Q=0;if(J.charCodeAt(0)>=56320&&J.charCodeAt(0)<=57343)Q=1;while(Q<J.length){let Z=J.charCodeAt(Q);if(Z>=768&&Z<=879||Z>=6832&&Z<=6911||Z>=7616&&Z<=7679||Z>=8400&&Z<=8447||Z>=65056&&Z<=65071)Q++;else break}return J.slice(Q)}static safeTruncate(J,Q){if(Q>=J.length)return J;if(Q<=0)return"";if(Q>0&&Q<J.length){let Z=J.charCodeAt(Q-1),Y=J.charCodeAt(Q);if(Z>=55296&&Z<=56319&&Y>=56320&&Y<=57343)Q--}while(Q<J.length){let Z=J.charCodeAt(Q);if(Z>=768&&Z<=879||Z>=6832&&Z<=6911||Z>=7616&&Z<=7679||Z>=8400&&Z<=8447||Z>=65056&&Z<=65071){if(Q--,Q<=0)break}else break}return J.slice(0,Q)}static bufferByteLengthCompat(J){return I9.encoder.encode(J).length}static pruneWideLine(J,Q=4096,Z="ellipsis"){let Y=I9.bufferByteLengthCompat(J);if(Y<=Q)return J;switch(Z){case"hard-cutoff":return I9.utf8Clamp(J,Q);case"ellipsis":{let X=I9.utf8Clamp(J,Q),V=Y-I9.bufferByteLengthCompat(X);return`${X}…[+${Math.round(V/1024)}KB]`}case"mid-ellipsis":{if(Q<20)return I9.pruneWideLine(J,Q,"ellipsis");let V=Math.max(10,Q-50),K=Math.floor(V/2),q=I9.utf8Clamp(J,K),G=Math.floor(K/2),W=I9.utf8ClampFromEnd(J,G),H=Y-I9.bufferByteLengthCompat(q+W),F=`${q}…[${Math.round(H/1024)}KB]…${W}`;if(I9.bufferByteLengthCompat(F)>Q)return I9.pruneWideLine(J,Q,"ellipsis");return F}case"line-aware":return I9.pruneWideLine(J,Q,"ellipsis")}}static normalizeText(J){if(J.charCodeAt(0)===65279)J=J.slice(1);return J=J.replace(/\r\n?/g,`
|
|
439
439
|
`),J}static processText(J,Q={}){let{truncationStrategy:Z="ellipsis",maxLineBytes:Y=A$4,maxLines:X,addLineNumbers:V=!1}=Q,q=I9.normalizeText(J).split(`
|
|
@@ -1081,6 +1081,11 @@ ${Z?`- Only for complex tasks requiring deep analysis, planning, or debugging ac
|
|
|
1081
1081
|
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys.
|
|
1082
1082
|
- Do not add comments to code unless the user asks or the code is complex and requires additional context.
|
|
1083
1083
|
|
|
1084
|
+
# Git and workspace hygiene
|
|
1085
|
+
|
|
1086
|
+
- Do not commit or push without explicit consent. When committing, only stage files directly related to the current task — never use \`git add -A\` or \`git add .\` as they may include unrelated changes.
|
|
1087
|
+
- If you notice unexpected changes in the worktree or staging area that you did not make, ignore them completely and continue with your task. NEVER revert, undo, or modify changes you did not make unless the user explicitly asks you to. There can be multiple agents or the user working in the same codebase concurrently.
|
|
1088
|
+
|
|
1084
1089
|
# Responding to queries about Amp
|
|
1085
1090
|
|
|
1086
1091
|
When asked about Amp (e.g., your models, pricing, features, configuration, or capabilities), use the ${K$} tool to check https://ampcode.com/manual for current information. Use the prompt parameter to ask it to "Pay attention to any LLM instructions on the page for how to describe Amp."
|
|
@@ -7618,11 +7623,11 @@ ${U}`))}},error:(z)=>{if(!F)F=!0,q(Error(`Failed to spawn brew: ${z.message}`))}
|
|
|
7618
7623
|
${U}`;if(X==="pnpm"&&U.includes("Unable to find the global bin directory"))D+=`
|
|
7619
7624
|
|
|
7620
7625
|
Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
|
|
7621
|
-
npm install -g @sourcegraph/amp`;q(Error(D))}},error:(z)=>{if(!H)H=!0,q(Error(`Failed to spawn ${X}: ${z.message}`))},complete:()=>{if(!H)H=!0,K()}})})}p1();p1();bj();async function M91(J,Q){let Y=Q||"https://registry.npmjs.org",X=new AbortController,V=setTimeout(()=>X.abort(),5000);try{let K=await fetch(`${Y}/@sourcegraph/amp`,{signal:X.signal});if(!K.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=await K.json(),G=q["dist-tags"]?.latest;if(!G)return{hasUpdate:!1,currentVersion:J,source:"npm"};let W=gZ6(J,G),H=W<0,F,z;if(q.time){let U=q.time[J],D=q.time[G],B=Date.now();if(U)F=Math.floor((B-new Date(U).getTime())/3600000);if(D)z=Math.floor((B-new Date(D).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:W,hasUpdate:H,currentVersionAge:F,latestVersionAge:z}),{hasUpdate:H,latestVersion:G,currentVersion:J,currentVersionAge:F,latestVersionAge:z,source:"npm"}}catch(K){return T.debug("Error checking npm version",{error:K}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var Uz8="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function A91(J){let Q=new AbortController,Z=setTimeout(()=>Q.abort(),5000);try{let Y=await fetch(`${Uz8}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let X=(await Y.text()).trim();if(!X||!/^\d+\.\d+\.\d+/.test(X))return{hasUpdate:!1,currentVersion:J,source:"bin"};let V=gZ6(J,X),K=V<0;return T.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:V,hasUpdate:K}),{hasUpdate:K,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return T.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Z)}}var Dz8=604800000;function uZ6(J){if(!J)return null;let Q=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Q))return null;let Z=Date.now()-Q;if(Z>Dz8)return{ageMs:Z};return null}function gZ6(J,Q){let Z=(K)=>{let[q,G]=K.split("-");return{parts:q?.split(".").map(Number)||[],label:G}},Y=Z(J),X=Z(Q),V=Math.max(Y.parts.length,X.parts.length);for(let K=0;K<V;K++){let q=Y.parts[K]||0,G=X.parts[K]||0;if(q<G)return-1;if(q>G)return 1}if(Y.label===X.label)return 0;if(!Y.label&&X.label)return 1;if(Y.label&&!X.label)return-1;if(Y.label&&X.label)return Y.label<X.label?-1:1;return 0}function qx1(J){try{let Q=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Q)return null;let Z=parseInt(Q[1],10)*1000,Y=Q[2],X=Z!==0?pF(Z):void 0;return{sha:Y,age:X}}catch{return null}}z0();function R91(J,Q){let Z=new D6,Y=Z.pipe(k4({shouldCountRefs:!1}));return setImmediate(async()=>{let X=new rV().scoped("update"),V=Y.subscribe({next:(K)=>{X.debug("emit new state",K)}});try{let K=process.env.AMP_TEST_UPDATE_STATUS;if(K){X.debug("using fake update status for testing",{status:K}),await CL(500),Z.next(K);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){X.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let q=await Q.get("updates.mode");if(q==="disabled"){X.debug("checking disabled");return}let G=await O91(),W=G==="binary"||G==="brew";X.debug("checking",{currentVersion:J,mode:q,packageManager:G,isBinaryDistribution:W});let H=W?await A91(J):await M91(J,YO());if(!(H.latestVersion&&H.hasUpdate)){X.debug("no update available");return}let F=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let z=H.currentVersionAge-H.latestVersionAge,U=0.5;if(Math.abs(z)<0.5)return X.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:z}),!0}return!1};if(!q)q=G==="pnpm"?"warn":"auto",X.debug("no configured update mode; selected default based on package manager",{packageManager:G,mode:q});if(G==="brew"){if(!F())Z.next("update-available-brew");return}if(G==="binary"&&process.execPath!==Zx1()){if(X.debug("non-standard binary path, showing warning"),!F())Z.next("update-available-unrecognized-path");return}if(q==="warn"){if(!F())Z.next("update-available");return}if(!G){if(X.debug("auto-update not supported, falling back to warn mode"),!F())Z.next("update-available");return}if(G==="binary"&&process.platform==="win32"){if(X.debug("binary auto-update not supported on Windows, falling back to warn mode"),!F())Z.next("update-available");return}try{await ou(H.latestVersion,G);let z=await CU(H.latestVersion),U={from:H.currentVersion,to:H.latestVersion,...z};if(z.status==="same")X.info("success",U),Z.next("updated");else X.warn("success with warning",U),Z.next("updated-with-warning")}catch(z){Z.next("update-error")}}catch(K){X.debug("check failed",{error:K})}finally{await CL(5000),Z.next("hidden"),V.unsubscribe(),Z.complete()}}),{state:Y}}bj();import{stderr as Nq}from"node:process";function mZ6(J){let Q=new WU().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(Y)=>{await ty1(Y.force||!1,Y.verbose||!1,"0.0.
|
|
7626
|
+
npm install -g @sourcegraph/amp`;q(Error(D))}},error:(z)=>{if(!H)H=!0,q(Error(`Failed to spawn ${X}: ${z.message}`))},complete:()=>{if(!H)H=!0,K()}})})}p1();p1();bj();async function M91(J,Q){let Y=Q||"https://registry.npmjs.org",X=new AbortController,V=setTimeout(()=>X.abort(),5000);try{let K=await fetch(`${Y}/@sourcegraph/amp`,{signal:X.signal});if(!K.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=await K.json(),G=q["dist-tags"]?.latest;if(!G)return{hasUpdate:!1,currentVersion:J,source:"npm"};let W=gZ6(J,G),H=W<0,F,z;if(q.time){let U=q.time[J],D=q.time[G],B=Date.now();if(U)F=Math.floor((B-new Date(U).getTime())/3600000);if(D)z=Math.floor((B-new Date(D).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:W,hasUpdate:H,currentVersionAge:F,latestVersionAge:z}),{hasUpdate:H,latestVersion:G,currentVersion:J,currentVersionAge:F,latestVersionAge:z,source:"npm"}}catch(K){return T.debug("Error checking npm version",{error:K}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var Uz8="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function A91(J){let Q=new AbortController,Z=setTimeout(()=>Q.abort(),5000);try{let Y=await fetch(`${Uz8}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let X=(await Y.text()).trim();if(!X||!/^\d+\.\d+\.\d+/.test(X))return{hasUpdate:!1,currentVersion:J,source:"bin"};let V=gZ6(J,X),K=V<0;return T.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:V,hasUpdate:K}),{hasUpdate:K,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return T.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Z)}}var Dz8=604800000;function uZ6(J){if(!J)return null;let Q=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Q))return null;let Z=Date.now()-Q;if(Z>Dz8)return{ageMs:Z};return null}function gZ6(J,Q){let Z=(K)=>{let[q,G]=K.split("-");return{parts:q?.split(".").map(Number)||[],label:G}},Y=Z(J),X=Z(Q),V=Math.max(Y.parts.length,X.parts.length);for(let K=0;K<V;K++){let q=Y.parts[K]||0,G=X.parts[K]||0;if(q<G)return-1;if(q>G)return 1}if(Y.label===X.label)return 0;if(!Y.label&&X.label)return 1;if(Y.label&&!X.label)return-1;if(Y.label&&X.label)return Y.label<X.label?-1:1;return 0}function qx1(J){try{let Q=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Q)return null;let Z=parseInt(Q[1],10)*1000,Y=Q[2],X=Z!==0?pF(Z):void 0;return{sha:Y,age:X}}catch{return null}}z0();function R91(J,Q){let Z=new D6,Y=Z.pipe(k4({shouldCountRefs:!1}));return setImmediate(async()=>{let X=new rV().scoped("update"),V=Y.subscribe({next:(K)=>{X.debug("emit new state",K)}});try{let K=process.env.AMP_TEST_UPDATE_STATUS;if(K){X.debug("using fake update status for testing",{status:K}),await CL(500),Z.next(K);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){X.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let q=await Q.get("updates.mode");if(q==="disabled"){X.debug("checking disabled");return}let G=await O91(),W=G==="binary"||G==="brew";X.debug("checking",{currentVersion:J,mode:q,packageManager:G,isBinaryDistribution:W});let H=W?await A91(J):await M91(J,YO());if(!(H.latestVersion&&H.hasUpdate)){X.debug("no update available");return}let F=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let z=H.currentVersionAge-H.latestVersionAge,U=0.5;if(Math.abs(z)<0.5)return X.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:z}),!0}return!1};if(!q)q=G==="pnpm"?"warn":"auto",X.debug("no configured update mode; selected default based on package manager",{packageManager:G,mode:q});if(G==="brew"){if(!F())Z.next("update-available-brew");return}if(G==="binary"&&process.execPath!==Zx1()){if(X.debug("non-standard binary path, showing warning"),!F())Z.next("update-available-unrecognized-path");return}if(q==="warn"){if(!F())Z.next("update-available");return}if(!G){if(X.debug("auto-update not supported, falling back to warn mode"),!F())Z.next("update-available");return}if(G==="binary"&&process.platform==="win32"){if(X.debug("binary auto-update not supported on Windows, falling back to warn mode"),!F())Z.next("update-available");return}try{await ou(H.latestVersion,G);let z=await CU(H.latestVersion),U={from:H.currentVersion,to:H.latestVersion,...z};if(z.status==="same")X.info("success",U),Z.next("updated");else X.warn("success with warning",U),Z.next("updated-with-warning")}catch(z){Z.next("update-error")}}catch(K){X.debug("check failed",{error:K})}finally{await CL(5000),Z.next("hidden"),V.unsubscribe(),Z.complete()}}),{state:Y}}bj();import{stderr as Nq}from"node:process";function mZ6(J){let Q=new WU().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(Y)=>{await ty1(Y.force||!1,Y.verbose||!1,"0.0.1771373086-gedddec"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new WU("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(Y)=>{await Bz8(Y.targetVersion)});J.addCommand(Z)}async function Bz8(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")Nq.write(Z0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
|
|
7622
7627
|
|
|
7623
7628
|
`));try{if(!J){Nq.write(Z0.blue(`Checking for updates...
|
|
7624
|
-
`));let{hasUpdate:Y,latestVersion:X}=ey1()?await A91("0.0.
|
|
7625
|
-
`));let q=await CU("0.0.
|
|
7629
|
+
`));let{hasUpdate:Y,latestVersion:X}=ey1()?await A91("0.0.1771373086-gedddec"):await M91("0.0.1771373086-gedddec",YO());if(!Y){let V=qx1("0.0.1771373086-gedddec"),K=V?.age?`released ${V.age} ago`:`built ${pF(new Date("2026-02-18T00:10:14.914Z"))} ago`;Nq.write(Z0.green(`✓ Amp is already up to date on version ${"0.0.1771373086-gedddec"} (${K})
|
|
7630
|
+
`));let q=await CU("0.0.1771373086-gedddec");if(q.warning)Nq.write(`
|
|
7626
7631
|
`+Z0.yellow(q.warning)+`
|
|
7627
7632
|
`);process.exit(0)}if(!X)Nq.write(Z0.yellow("[WARN] could not find latest version")),process.exit(0);J=X}Nq.write(Z0.blue(`Updating to version ${J}...
|
|
7628
7633
|
`)),await ou(J,void 0,(Y)=>{Nq.write(Z0.dim(`Running: ${Y}
|
|
@@ -8533,7 +8538,7 @@ Ctrl-X, Y, Z to unlock`;if(z){let x=W.text.replace(/`([^`]+)`/g,"$1")+`
|
|
|
8533
8538
|
`),new k("Ctrl+O",D),new k(" for ",N),new k("help",B),new k(`
|
|
8534
8539
|
|
|
8535
8540
|
|
|
8536
|
-
`,N)])}),R];if(!G&&!z&&W.url){let _=W.url.replace(/^https?:\/\//,"");P.push(new e4({uri:W.url,text:_,style:new g({color:Z.secondary,underline:!0})}))}if(A&&!z)P.push(A);let C=new I1({width:50,child:new b1({crossAxisAlignment:"start",mainAxisSize:"min",children:P})});return s0.child(new q0({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[new Av1({width:du1,height:cu1,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Z.background,t:H,fps:0,shockwaves:this._shockwaves,onShockwave:O,...K==="disabled"&&{seed:42}}),new I1({width:2}),C]}))}}class lu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new NU6}}class NU6 extends n1{build(J){let Z=h1.of(J).colors,{todos:Y,title:X="TODOs"}=this.widget.props;if(!Array.isArray(Y)||Y.length===0)return new I1({width:0,height:0});let V=Y.map((K)=>this.buildTodoItem(K,Z));return new c1({child:new a1({padding:C1.symmetric(1,0),child:new b1({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q1({text:new k(X,new g({bold:!0,color:Z.foreground}))}),...V]})})})}buildTodoItem(J,Q){let Z=this.getStatusIcon(J.status),Y=J.status==="completed",X=new g({bold:J.status==="in-progress",color:Q.foreground,dim:Y}),V=new g({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Q.foreground,dim:Y});return new q0({crossAxisAlignment:"start",children:[new Q1({text:new k(Z,X)}),new I1({width:1}),new C0({child:new Q1({text:new k(J.content,V)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class iu1 extends o1{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Q,onDismiss:Z,onButtonClick:Y,onImpression:X,onAdInfoClick:V}){super({key:J});this.ad=Q,this.onDismiss=Z,this.onButtonClick=Y,this.onImpression=X,this.onAdInfoClick=V}createState(){return new wU6}}class wU6 extends n1{lastTrackedAdId=null;initState(){super.initState(),this.fireImpressionIfNeeded()}didUpdateWidget(J){super.didUpdateWidget(J),this.fireImpressionIfNeeded()}fireImpressionIfNeeded(){let J=this.widget.ad;if(J.id!==this.lastTrackedAdId)this.lastTrackedAdId=J.id,this.widget.onImpression?.(J)}build(J){let Q=h1.of(J),Z=Q.colors.primary,Y=Q.colors.foreground,X=Q.colors.background,V=this.widget.ad;return new c1({decoration:new T6(X,new c0(new u0(Z,1,"rounded"),new u0(Z,1,"rounded"),void 0,new u0(Z,1,"rounded"))),child:new a1({padding:C1.horizontal(1),child:new b1({children:[new q0({crossAxisAlignment:"start",children:[new C0({child:new Q1({text:new k(V.content,new g({color:Y}))})}),new I1({width:4}),new o0({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q1({text:new k("Ad",new g({color:Y,dim:!0}))})})]}),new q0({crossAxisAlignment:"start",children:[new yg({text:V.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C1.horizontal(1),color:Z,reverse:!0}),new I1({width:2}),new Q1({text:new k(V.destinationUrlHostname,new g({color:Y,dim:!0}))})]})]})})})}}class nu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new LU6(this.props.autofocus??!0)}}class LU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=k0.of(J).colorScheme,Y=(W)=>{if(W.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(W.ctrlKey&&W.key==="c"||W.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},X=Y6.sizeOf(J),V=Math.min(60,X.width-4),K=X.height-4,q=[];if(this.widget.props.title)q.push(new Q1({text:new k(this.widget.props.title,new g({bold:!0,color:Z.primary}))}),new I1({height:1}));if(this.widget.props.message)q.push(new Q1({text:new k(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)q.push(new I1({height:1}));let G=[];if(this.widget.props.showCopyOption)G.push(new Q1({text:new k("Enter to copy",new g({dim:!0}))}));return G.push(new Q1({text:new k("Escape to close",new g({dim:!0}))})),q.push(new q0({children:G.flatMap((W,H)=>H<G.length-1?[W,new I1({width:1}),new Q1({text:new k("•",new g({dim:!0}))}),new I1({width:1})]:[W]),mainAxisSize:"min"})),new s0({child:new c1({constraints:new A0(V,V,0,K),decoration:new T6(Z.background,new c0(new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Y,child:new b1({children:q,mainAxisSize:"min"})})})})}}class au1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new OU6(this.props.autofocus??!0)}}class OU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=k0.of(J).colorScheme,Z=(q)=>{if(q.key==="Enter"||q.key==="Escape"||q.ctrlKey&&q.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},Y=Y6.sizeOf(J),X=Math.min(60,Y.width-4),V=Y.height-4,K=[];if(K.push(new Q1({text:new k("Ads make Amp Free possible",new g({bold:!0}))})),this.widget.props.provider)K.push(new I1({height:1}),new Q1({text:new k(`Ad source: ${this.widget.props.provider}`,new g({dim:!0}))}));return K.push(new I1({height:1}),new Q1({text:new k("Escape to close",new g({dim:!0}))})),new s0({child:new c1({constraints:new A0(X,X,0,V),decoration:new T6(Q.background,new c0(new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Z,child:new b1({children:K,mainAxisSize:"min"})})})})}}p1();N3();import{execSync as Gx8}from"node:child_process";sT1();XQ();d9();n3();$N();D$();wJ();wZ();U$();QI();c6();fh();xS();z0();var UD6=U6(aG(),1);import{writeFile as GD6}from"fs/promises";import WD6 from"path";p1();wJ();class ou1{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Z])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1771358819-g9e835e"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await Ds(Q,this.configService)}catch(Q){T.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class DD extends o1{props;constructor(J){super();this.props=J}createState(){return new MU6}}class MU6 extends n1{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Z)=>{this.setState(()=>{this._state=Z(this._state)})};return this.widget.props.builder(J,Q,this._state)}}class AU6 extends n1{controller=new o2;focusNode=new V4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q,X=this.widget.props.isRequiredArg??!0,V=this.controller.text.trim().length>0,K=!X||V,q=c0.all(new u0(Z.foreground,1,"solid")),G=new XY({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(U)=>{let D=U.trim();if(X&&D.length===0)return;this.widget.props.onSubmit(D)},autofocus:!0,style:{textColor:Z.foreground,border:null},maxLines:1}),W=new q0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new C0({child:G})]}),H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,[new k("Command: ",new g({color:Z.foreground})),new k(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),F=[];if(K)F.push(new k("Enter",new g({color:Y.keybind}))),F.push(new k(" to submit, ",new g({color:Z.foreground,dim:!0})));F.push(new k("Esc",new g({color:Y.keybind}))),F.push(new k(" to cancel",new g({color:Z.foreground,dim:!0})));let z=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,F)})});return new c1({decoration:{border:q,color:Z.background},padding:C1.all(1),child:new b1({children:[H,new I1({height:1}),W,new v9,z]})})}}class im extends o1{props;constructor(J){super();this.props=J}createState(){return new AU6}}import{isDeepStrictEqual as hy8}from"node:util";var vy8=/[\\/_ +.#"@[({&]/,by8=/[\\/_ +.#"@[({&]/g,fy8=/[\s-]/,RU6=/[\s-]/g;function e31(J,Q,Z,Y,X,V,K){if(V===Q.length){if(X===J.length)return 1;return 0.99}let q=`${X},${V}`;if(K[q]!==void 0)return K[q];let G=Y.charAt(V),W=Z.indexOf(G,X),H=0,F,z,U,D;while(W>=0){if(F=e31(J,Q,Z,Y,W+1,V+1,K),F>H){if(W===X)F*=1;else if(fy8.test(J.charAt(W-1))){if(F*=0.9,D=J.slice(X,W-1).match(RU6),D&&X>0)F*=0.999**D.length}else if(vy8.test(J.charAt(W-1))){if(F*=0.8,U=J.slice(X,W-1).match(by8),U&&X>0)F*=0.999**U.length}else if(F*=0.3,X>0)F*=0.999**(W-X);if(J.charAt(W)!==Q.charAt(V))F*=0.9999}if(F<0.1&&(Z.charAt(W-1)===Y.charAt(V+1)||Y.charAt(V+1)===Y.charAt(V)&&Z.charAt(W-1)!==Y.charAt(V))){if(z=e31(J,Q,Z,Y,W+1,V+2,K),z*0.1>F)F=z*0.1}if(F>H)H=F;W=Z.indexOf(G,W+1)}return K[q]=H,H}function t31(J){return J.toLowerCase().replace(RU6," ")}function jU6(J,Q){let Z=e31(J,Q,t31(J),t31(Q),0,0,{}),Y=Q.trim().split(/\s+/);if(Y.length>1){let X=0,V=0;for(let q of Y){let G=e31(J,q,t31(J),t31(q),0,0,{});if(G===0)return Z;X+=G,V+=q.length}let K=X/Y.length*0.95;return Math.max(Z,K)}return Z}class $T{}class VT{}class J21{}class Q21{}class EU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new PU6}}class PU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}function uy8(J,Q){if(J==="")return{matches:!0,score:1};let Z=jU6(Q,J);return{matches:Z>0.15,score:Z}}class h7 extends o1{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new IU6}}class IU6 extends n1{controller=new o2;focusNode;scrollController=new a4;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){this.scrollController.disableFollowMode(),this.focusNode=new V4({debugLabel:this.widget.debugLabel}),this.controller.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[0]??null)}),this.recomputeFilteredItems();let J=this.cachedFiltered;this.widget.props.onSelectionChange?.(J[0]??null),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!hy8(J.props.items,this.widget.props.items)){this.recomputeFilteredItems(),this.ensureSelectedItemVisible();let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null)}}dispose(){this.widget.props.onSelectionChange?.(null),this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof $T){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof VT){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof J21){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length){let Z=Q[this.selectedIndex];if(Z){if(!(this.widget.props.isItemDisabled?.(Z)??!1))this.widget.props.onAccept(Z,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof Q21)return this.widget.props.onDismiss?.(),"handled";return"ignored"};recomputeFilteredItems(){let J=this.controller.text,Q=this.widget.props.items,Z=this.widget.props.normalizeQuery?.(J)??J,Y=Q.filter((X)=>!this.widget.props.filterItem||this.widget.props.filterItem(X,J)).map((X)=>({item:X,...uy8(Z,this.widget.props.getLabel(X))})).filter((X)=>X.matches).sort(this.widget.props.sortItems?(X,V)=>this.widget.props.sortItems(X,V,J):(X,V)=>V.score-X.score).map((X)=>X.item);this.cachedQuery=J,this.cachedItemsRef=Q,this.cachedFiltered=this.widget.props.maxRenderItems?Y.slice(0,this.widget.props.maxRenderItems):Y}getFilteredItems(){let J=this.controller.text,Q=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Q)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;RC(J,{top:Z,bottom:Y},{padding:1})}handleScroll=(J)=>{let Q=this.getFilteredItems();if(Q.length===0)return!1;let Z=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null),this.selectedIndex!==Z};handleItemClick=(J,Q)=>{let Z=this.getFilteredItems();if(J>=0&&J<Z.length){let Y=Z[J],X=Y?this.widget.props.isItemDisabled?.(Y)??!1:!1;if(Q===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.widget.props.onSelectionChange?.(Z[this.selectedIndex]??null);else if(Q===2&&!X){if(Y)this.hasUserInteracted=!0,this.widget.props.onAccept(Y,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Q=h1.of(J),{colors:Z}=Q,Y=this.getFilteredItems(),X=c0.all(new u0(Z.foreground,1,"solid")),V=this.widget.props.enabled??!0,K=new XY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Z.background,textColor:Z.foreground,cursorColor:Z.cursor,placeholderColor:Z.mutedForeground,border:null},maxLines:1}),q=new z2({shortcuts:new Map([[new r0("ArrowDown"),new $T],[new r0("ArrowUp"),new VT],[new r0("Tab"),new $T],[new r0("Tab",{shift:!0}),new VT],[new r0("n",{ctrl:!0}),new $T],[new r0("p",{ctrl:!0}),new VT],[new r0("Enter"),new J21],[new r0("Escape"),new Q21]]),focusNode:this.focusNode,child:K}),G=new N7({actions:new Map([[$T,new l6(this.invoke)],[VT,new l6(this.invoke)],[J21,new l6(this.invoke)],[Q21,new l6(this.invoke)]]),child:q}),W=new q0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new C0({child:G})]});this.itemContexts=[];let H;if(this.widget.props.isLoading){let B=this.widget.props.loadingText??"Loading...";H=new I1({height:10,child:new s0({child:new Q1({text:new k(B,new g({color:Z.foreground}))})})})}else if(Y.length===0&&this.widget.props.emptyStateText)H=new C0({child:new s0({child:new Q1({text:new k(this.widget.props.emptyStateText,new g({color:Z.foreground,dim:!0}))})})});else{let B=Y.map((N,w)=>{let L=w===this.selectedIndex,O=this.widget.props.isItemDisabled?.(N)??!1,M;if(this.widget.props.renderItem)M=this.widget.props.renderItem(N,L,O,J);else{let A=L?Q.app.selectionBackground:void 0,R=L?Q.app.selectionForeground:Z.foreground;M=new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(this.widget.props.getLabel(N),new g({color:R,dim:O}))})})}return new EU6(new o0({onClick:(A)=>this.handleItemClick(w,A.clickCount),child:M}),(A)=>{this.itemContexts[w]=A})});H=new b1({children:B,crossAxisAlignment:"start"})}let F=new o0({onScroll:this.handleScroll,opaque:!1,child:new C4({controller:this.scrollController,autofocus:!1,child:H})}),z=[];if(this.widget.props.title){let B=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(this.widget.props.title,new g({color:Q.app.command,bold:!0}))})});z.push(B)}if(z.push(W,new I1({height:1})),this.controller.text!==""){let B=Y.length>0?Y[this.selectedIndex]:void 0,N=B&&this.widget.props.buildDisabledReasonWidget?.(B,J);z.push(new C0({child:new b1({mainAxisAlignment:"spaceBetween",children:[new C0({child:F}),new c1({padding:C1.only({top:1}),child:new s0({child:N??new I1({height:1})})})]})}))}else z.push(new C0({child:F}));if(this.widget.props.footer)z.push(this.widget.props.footer);return new c1({decoration:{border:X,color:Z.background},padding:C1.symmetric(1,0),child:new b1({children:z})})}}function CU6(J){let Z=new Date().getTime()-J.getTime(),Y=Math.floor(Z/60000),X=Math.floor(Z/3600000),V=Math.floor(Z/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return J.toLocaleDateString()}class ru1 extends m0{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Q=[...this.props.entries].sort((X,V)=>V.pubDate.getTime()-X.pubDate.getTime()),Z=Math.max(0,...Q.map((X)=>CU6(X.pubDate).length));return new h7({items:Q,getLabel:(X)=>X.title,onAccept:(X)=>this.props.onSelect?.(X),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(X,V,K,q)=>{let G=h1.of(q),{colors:W}=G,H=G.app,F=V?H.selectionBackground:void 0,z=V?H.selectionForeground:W.foreground,U=W.mutedForeground,D=(B,N)=>new I1({width:N,child:q0.end([new Q1({text:new k(B,new g({color:U}))})])});return new c1({decoration:F?{color:F}:void 0,padding:C1.symmetric(2,0),child:new q0({children:[new C0({child:new Q1({text:new k(X.title,new g({color:z})),overflow:"ellipsis",maxLines:1})}),new I1({width:2}),D(CU6(X.pubDate),Z)]})})}})}}c6();class su1 extends o1{createState(){return new TU6}}class TU6 extends n1{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Z=h1.of(J).colors;return new Q1({text:new k("●",new g({color:this.isGreen?Z.success:Z.mutedForeground,bold:!0})),maxLines:1})}}var gy8=/\/threads\/(T-[^/?#\s<>]+)/i;function my8(J){let Q=J.trim(),Y=Q.match(gy8)?.[1];if(Y&&J5(Y))return Y;let X=Q.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(J5(X))return X;return null}function py8(J){let Q=new Map,Z=new Map,Y=new Map,X=[];for(let K of J)Q.set(K.id,K);for(let K of J){let q=K.relationships.find((G)=>G.role==="child"&&Q.has(G.threadID)&&(G.type==="fork"||G.type==="handoff"));if(q){Y.set(K.id,q.type);let G=q.threadID,W=Z.get(G)||[];W.push(K),Z.set(G,W)}else X.push(K)}return j71.flatten(X,(K)=>Z.get(K.id)).map((K)=>({...K.item,depth:K.depth,isLast:K.isLast,ancestorsAreLast:K.ancestorsAreLast,relationshipType:Y.get(K.item.id)}))}function tu1(J,Q,Z){return new Q1({text:new k(`${J}${Q}`,new g({color:Z})),maxLines:1})}function dy8(J,Q,Z,Y){return[tu1("+",J,Y.success),v9.horizontal(1),tu1("~",Q,Y.warning),v9.horizontal(1),tu1("-",Z,Y.destructive)]}class Z21 extends m0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}build(J){let Q=this.props.filterByWorkspace&&this.props.currentWorkspaceURI?this.props.threads.filter((D)=>D.workspaceURI===this.props.currentWorkspaceURI):this.props.threads;if(this.props.excludeCurrentThread&&this.props.currentThreadID)Q=Q.filter((D)=>D.id!==this.props.currentThreadID);let Z=this.props.recentThreadIDs||[],Y=new Set(Z),X=this.props.currentThreadID,V=[...Q].sort((D,B)=>{if(X){if(D.id===X)return-1;if(B.id===X)return 1}let N=Z.indexOf(D.id),w=Z.indexOf(B.id);if(N!==-1&&w!==-1)return N-w;if(N!==-1)return-1;if(w!==-1)return 1;return 0}),K=py8(V),q=Math.max(0,...K.map((D)=>D.description.timeAgo.length)),G=h1.of(J),W=new a1({padding:C1.symmetric(0,1),child:new s0({child:new Q1({text:new k("",new g({color:G.colors.foreground,dim:!0}),[new k("Ctrl+T",new g({color:G.colors.primary,dim:!0})),new k(this.props.filterByWorkspace?" for all workspaces":" to filter by workspace",new g({color:G.colors.foreground,dim:!0}))])})})}),H="",F=null,z=(D)=>{if(D!==H)H=D,F=my8(D);return F};return new h7({items:K,getLabel:(D)=>`${D.title} ${D.id}`,filterItem:(D,B)=>{let N=z(B);if(N)return D.id.toLowerCase()===N.toLowerCase();return!0},normalizeQuery:(D)=>z(D)?"":D,onAccept:(D,B)=>this.props.onSelect?.(D.id,B),onDismiss:this.props.onDismiss,onSelectionChange:(D)=>{if(this.props.previewController){if(D)this.props.previewController.select(D.id)}},title:this.props.title,isLoading:this.props.isLoading,loadingText:"Loading threads...",emptyStateText:"No threads match your filter",maxRenderItems:200,footer:this.props.isLoading?void 0:W,renderItem:(D,B,N,w)=>{let L=h1.of(w),{app:O,colors:M}=L,A=B?O.selectionBackground:void 0,R=B?O.selectionForeground:M.foreground,j=M.mutedForeground,P=(c,u)=>new I1({width:u,child:q0.end([new Q1({text:new k(c,new g({color:j}))})])}),C=this.props.threadViewStates[D.id],_=[],x=D.relationshipType==="handoff",b=new tg({connectorColor:M.mutedForeground});if(D.depth>0){let c=[],u=D.ancestorsAreLast.slice(1);for(let r of u)c.push(new k(b.getAncestorPrefix(r),new g({color:b.connectorColor,dim:b.connectorDim})));let a=D.isLast?b.elbow:b.tee,d=b.getConnectorText(a);c.push(new k(d,new g({color:b.connectorColor,dim:b.connectorDim}))),_.push(new Q1({text:new k("",void 0,c)}))}let h=[],y=X===D.id?new k("(current) ",new g({color:M.success})):Y.has(D.id)?new k("(visited) ",new g({color:M.foreground,dim:!0})):null;if(y)h.push(new Q1({text:y}));if(PL(C))h.push(new su1),h.push(new I1({width:1}));let f=D.title;if(D.relationshipType==="fork"){let c=f.match(/^Forked\((\d+)\): /);if(c)f=f.slice(c[0].length);else while(f.startsWith("Forked: "))f=f.slice(8);h.push(new Q1({text:new k("[fork] ",new g({color:M.primary}))}))}else if(x)h.push(new Q1({text:new k("[handoff] ",new g({color:M.accent}))}));if(h.push(new C0({child:new Q1({text:new k(f,new g({color:R})),overflow:"ellipsis",maxLines:1})})),h.push(new I1({width:2})),D.diffStats&&(D.diffStats.added>0||D.diffStats.changed>0||D.diffStats.deleted>0)){let c=B?{success:j,warning:j,destructive:j}:M;h.push(...dy8(D.diffStats.added,D.diffStats.changed,D.diffStats.deleted,c)),h.push(new I1({width:2}))}return h.push(P(D.description.timeAgo,q)),new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new q0({children:[..._,...h]})})}})}}class SU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new kU6}}class kU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}var _U6=30,cy8=30;class KT{}class qT{}class Y21{}class X21{}class eu1 extends o1{props;constructor(J){super();this.props=J}createState(){return new yU6}}class yU6 extends n1{highlightedIndex=0;controller=new o2;focusNode;scrollController=new a4;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new V4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;RC(J,{top:Z,bottom:Y},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Q}=this.widget.props;if(!J)this.filteredClusters=[...Q];else this.filteredClusters=Q.filter((Z)=>Z.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof KT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof qT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof Y21){let Q=this.filteredClusters[this.highlightedIndex];if(Q)this.widget.props.onAccept(Q);return"handled"}if(J instanceof X21)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Q)=>{if(J>=0&&J<this.filteredClusters.length){if(Q===1)this.highlightedIndex=J,this.setState();else if(Q===2){let Z=this.filteredClusters[J];if(Z)this.widget.props.onAccept(Z)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Q=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Q};build(J){let{currentThreadID:Q}=this.widget.props,Z=h1.of(J),{colors:Y,app:X}=Z,q=Y6.of(J).size.width>=cy8+_U6,G=c0.all(new u0(Y.foreground,1,"solid")),W=this.filteredClusters[this.highlightedIndex]??null,H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("Select a cluster",new g({color:X.command,bold:!0}))})}),F=new XY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),z=new z2({shortcuts:new Map([[new r0("ArrowDown"),new KT],[new r0("ArrowUp"),new qT],[new r0("Tab"),new KT],[new r0("Tab",{shift:!0}),new qT],[new r0("n",{ctrl:!0}),new KT],[new r0("p",{ctrl:!0}),new qT],[new r0("Enter"),new Y21],[new r0("Escape"),new X21]]),focusNode:this.focusNode,child:F}),U=new N7({actions:new Map([[KT,new l6(this.invoke)],[qT,new l6(this.invoke)],[Y21,new l6(this.invoke)],[X21,new l6(this.invoke)]]),child:z}),D=new q0({children:[new c1({decoration:{color:Y.background},child:new Q1({text:new k(">",new g({color:Y.foreground}))})}),new C0({child:U})]});this.itemContexts=[];let B=this.filteredClusters.map((A,R)=>{let j=R===this.highlightedIndex,P=Q?A.threads.some((b)=>b.id===Q):!1,C=j?X.selectionBackground:void 0,_=j?X.selectionForeground:Y.foreground,x=[new k(A.label,new g({color:_})),new k(` (${A.threads.length})`,new g({color:_,dim:!0}))];if(P)x.push(new k(" (current)",new g({color:j?X.selectionForeground:Y.success})));return new SU6(new o0({onClick:(b)=>this.handleItemClick(R,b.clickCount),child:new c1({decoration:C?{color:C}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,x)})})}),(b)=>{this.itemContexts[R]=b})}),N=new b1({children:B,crossAxisAlignment:"start"}),w=new C0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})}),L=W?W.threads.map((A)=>({id:A.id,title:A.title,parentID:A.parentID,updatedAt:A.updatedAt})):[],O=W?new c1({padding:C1.all(1),child:new lO({threads:L,autofocus:!1,offsetY:2})}):null,M;if(q){let A=O?new C0({child:O}):new I1({width:_U6});M=new q0({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[w,A]})}else{let A=[new C0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})})];if(O)A.push(new C0({child:O}));M=new b1({crossAxisAlignment:"stretch",children:A})}return new c1({decoration:{border:G,color:Y.background},padding:C1.symmetric(1,0),child:new b1({children:[H,D,new I1({height:1}),new C0({child:M})]})})}}p1();class xU6 extends n1{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){T.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){T.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Q=J.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!J.includes(Q.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Q=J.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let Z=this.widget.props.currentLabels||[],Y=this.labels.some((V)=>V.name===Q),X=Z.includes(Q);return!Y&&!X}build(J){let Q=h1.of(J),{app:Z,colors:Y}=Q,X=this.currentQuery.trim().toLowerCase(),V=X.length>0?this.getValidationError(X):null,K=this.getAvailableLabels(),G=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...K];return new h7({title:"Add Label",items:G,getLabel:(W)=>{if("__isCreateMarker"in W)return this.currentQuery.trim().toLowerCase();return W.name},onAccept:(W)=>{if("__isCreateMarker"in W)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(W.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:V||"Type to create a new label",renderItem:(W,H,F,z)=>{let U=H?Z.selectionBackground:void 0,D=H?Z.selectionForeground:Y.foreground;if("__isCreateMarker"in W&&W.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,[new k("Create new label: ",new g({color:D})),new k(N,new g({color:D,bold:!0}))])})})}return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(W.name,new g({color:D}))})})},filterItem:(W,H)=>{if(this.currentQuery!==H)this.currentQuery=H,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in W&&W.__isCreateMarker)return this.shouldShowCreateMarker(H);let z=H.trim().toLowerCase();return z.length===0||W.name.includes(z)},sortItems:(W,H,F)=>{let z="__isCreateMarker"in W.item&&W.item.__isCreateMarker,U="__isCreateMarker"in H.item&&H.item.__isCreateMarker;if(z&&!U)return-1;if(!z&&U)return 1;return H.score-W.score}})}}class Jg1 extends o1{props;constructor(J){super();this.props=J}createState(){return new xU6}}class BD extends o1{props;constructor(J){super();this.props=J}createState(){return new vU6}}class vU6 extends n1{_spinner=new x5;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q,X=c0.all(new u0(Z.foreground,1,"solid")),V=this._spinner.toBraille(),K=new Q1({textAlign:"center",text:new k("",void 0,[new k(V,new g({color:Y.processing})),new k(" ",void 0),new k(this.widget.props.message,new g({color:Z.foreground}))])}),G=[new C0({child:new b1({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)G.push(new I1({height:2,child:new c1({padding:C1.symmetric(2,0),child:new Q1({text:new k("",new g({dim:!0}),[new k("Press ",new g({color:Z.foreground})),new k("Esc",new g({color:Z.info})),new k(" to cancel",new g({color:Z.foreground}))])})})}));let W=new c1({decoration:new T6(Z.background,X),child:new I1({width:60,height:7,child:new b1({mainAxisAlignment:"start",children:G})})});if(this.widget.props.onAbort)return new b6({debugLabel:"LoadingDialog",autofocus:!0,onKey:(H)=>{if(H.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:W});return W}}class nO extends o1{props;constructor(J){super();this.props=J}createState(){return new bU6}}class bU6 extends n1{scrollController=new a4;scrollAreaKey=new k3("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof VY}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let Z=Q.size;if(typeof Z.height==="number"&&Z.height>0)return this.viewportHeight=Z.height,Z.height}return this.viewportHeight}build(J){let Q=h1.of(J),Z=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Z))return{title:Z.title,type:Z.type};if(Z instanceof Error&&Z.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Z.message};if(Z instanceof Error&&Z.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Z.message};let H=M71(Z);return{title:H.title,type:H.type,description:H.description}})(),X=Y.type==="error"?Q.app.toolError:Q.app.command,V=c0.all(new u0(Q.colors.border,1,"solid")),K=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(Y.title,new g({color:X,bold:!0}))})}),q=this.isWidgetMessage(Z)?Z.widget:new Q1({text:new k(Y.description,new g({color:Q.colors.foreground})),selectable:!0}),G=new C0({child:new fJ({child:new c1({padding:C1.symmetric(1,0),child:new q0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new C0({child:new C4({controller:this.scrollController,autofocus:!0,child:q})}),new j5({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let H=this.scrollController.maxScrollExtent,F=this.scrollController.offset,z=this.getViewportHeight(),U=H+z;return{totalContentHeight:Math.max(U,0),viewportHeight:Math.max(z,1),scrollOffset:Math.max(F,0)}}})]})})})}),W=new c1({padding:C1.symmetric(1,0),child:new Q1({text:(()=>{if(this.widget.props.onRetry)return new k("",void 0,[new k("Press ",new g({color:Q.colors.foreground,dim:!0})),new k("R",new g({color:Q.app.keybind})),new k(" to retry, ",new g({color:Q.colors.foreground,dim:!0})),new k("Esc",new g({color:Q.app.keybind})),new k(" to cancel",new g({color:Q.colors.foreground,dim:!0}))]);let H=this.resolveFooterStyle(this.widget.props.message);if(H==="none")return new k("",new g({color:Q.colors.foreground,dim:!0}));if(H==="help"){let F=new g({color:Q.app.keybind}),z=new g({color:Q.colors.foreground,dim:!0});return new k("",z,[new k("Press ",z),new k("Escape",F),new k(" to close • Use ",z),new k("↑↓",F),new k(" or ",z),new k("j/k",F),new k(" to scroll",z)])}return new k("Press any key to close",new g({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new b6({onKey:(H)=>{if(this.widget.props.onRetry&&H.key==="r")return this.widget.props.onRetry(),"handled";if(H.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new c1({decoration:{border:V,color:Q.colors.background},padding:C1.all(1),child:new b1({mainAxisAlignment:"center",children:[K,new I1({height:1}),G,W]})})})}}class Qg1 extends m0{build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q;return new s0({child:new Q1({text:new k("",void 0,[new k(`✓ Thread Shared
|
|
8541
|
+
`,N)])}),R];if(!G&&!z&&W.url){let _=W.url.replace(/^https?:\/\//,"");P.push(new e4({uri:W.url,text:_,style:new g({color:Z.secondary,underline:!0})}))}if(A&&!z)P.push(A);let C=new I1({width:50,child:new b1({crossAxisAlignment:"start",mainAxisSize:"min",children:P})});return s0.child(new q0({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[new Av1({width:du1,height:cu1,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Z.background,t:H,fps:0,shockwaves:this._shockwaves,onShockwave:O,...K==="disabled"&&{seed:42}}),new I1({width:2}),C]}))}}class lu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new NU6}}class NU6 extends n1{build(J){let Z=h1.of(J).colors,{todos:Y,title:X="TODOs"}=this.widget.props;if(!Array.isArray(Y)||Y.length===0)return new I1({width:0,height:0});let V=Y.map((K)=>this.buildTodoItem(K,Z));return new c1({child:new a1({padding:C1.symmetric(1,0),child:new b1({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q1({text:new k(X,new g({bold:!0,color:Z.foreground}))}),...V]})})})}buildTodoItem(J,Q){let Z=this.getStatusIcon(J.status),Y=J.status==="completed",X=new g({bold:J.status==="in-progress",color:Q.foreground,dim:Y}),V=new g({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Q.foreground,dim:Y});return new q0({crossAxisAlignment:"start",children:[new Q1({text:new k(Z,X)}),new I1({width:1}),new C0({child:new Q1({text:new k(J.content,V)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class iu1 extends o1{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Q,onDismiss:Z,onButtonClick:Y,onImpression:X,onAdInfoClick:V}){super({key:J});this.ad=Q,this.onDismiss=Z,this.onButtonClick=Y,this.onImpression=X,this.onAdInfoClick=V}createState(){return new wU6}}class wU6 extends n1{lastTrackedAdId=null;initState(){super.initState(),this.fireImpressionIfNeeded()}didUpdateWidget(J){super.didUpdateWidget(J),this.fireImpressionIfNeeded()}fireImpressionIfNeeded(){let J=this.widget.ad;if(J.id!==this.lastTrackedAdId)this.lastTrackedAdId=J.id,this.widget.onImpression?.(J)}build(J){let Q=h1.of(J),Z=Q.colors.primary,Y=Q.colors.foreground,X=Q.colors.background,V=this.widget.ad;return new c1({decoration:new T6(X,new c0(new u0(Z,1,"rounded"),new u0(Z,1,"rounded"),void 0,new u0(Z,1,"rounded"))),child:new a1({padding:C1.horizontal(1),child:new b1({children:[new q0({crossAxisAlignment:"start",children:[new C0({child:new Q1({text:new k(V.content,new g({color:Y}))})}),new I1({width:4}),new o0({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q1({text:new k("Ad",new g({color:Y,dim:!0}))})})]}),new q0({crossAxisAlignment:"start",children:[new yg({text:V.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C1.horizontal(1),color:Z,reverse:!0}),new I1({width:2}),new Q1({text:new k(V.destinationUrlHostname,new g({color:Y,dim:!0}))})]})]})})})}}class nu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new LU6(this.props.autofocus??!0)}}class LU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=k0.of(J).colorScheme,Y=(W)=>{if(W.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(W.ctrlKey&&W.key==="c"||W.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},X=Y6.sizeOf(J),V=Math.min(60,X.width-4),K=X.height-4,q=[];if(this.widget.props.title)q.push(new Q1({text:new k(this.widget.props.title,new g({bold:!0,color:Z.primary}))}),new I1({height:1}));if(this.widget.props.message)q.push(new Q1({text:new k(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)q.push(new I1({height:1}));let G=[];if(this.widget.props.showCopyOption)G.push(new Q1({text:new k("Enter to copy",new g({dim:!0}))}));return G.push(new Q1({text:new k("Escape to close",new g({dim:!0}))})),q.push(new q0({children:G.flatMap((W,H)=>H<G.length-1?[W,new I1({width:1}),new Q1({text:new k("•",new g({dim:!0}))}),new I1({width:1})]:[W]),mainAxisSize:"min"})),new s0({child:new c1({constraints:new A0(V,V,0,K),decoration:new T6(Z.background,new c0(new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Y,child:new b1({children:q,mainAxisSize:"min"})})})})}}class au1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new OU6(this.props.autofocus??!0)}}class OU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=k0.of(J).colorScheme,Z=(q)=>{if(q.key==="Enter"||q.key==="Escape"||q.ctrlKey&&q.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},Y=Y6.sizeOf(J),X=Math.min(60,Y.width-4),V=Y.height-4,K=[];if(K.push(new Q1({text:new k("Ads make Amp Free possible",new g({bold:!0}))})),this.widget.props.provider)K.push(new I1({height:1}),new Q1({text:new k(`Ad source: ${this.widget.props.provider}`,new g({dim:!0}))}));return K.push(new I1({height:1}),new Q1({text:new k("Escape to close",new g({dim:!0}))})),new s0({child:new c1({constraints:new A0(X,X,0,V),decoration:new T6(Q.background,new c0(new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Z,child:new b1({children:K,mainAxisSize:"min"})})})})}}p1();N3();import{execSync as Gx8}from"node:child_process";sT1();XQ();d9();n3();$N();D$();wJ();wZ();U$();QI();c6();fh();xS();z0();var UD6=U6(aG(),1);import{writeFile as GD6}from"fs/promises";import WD6 from"path";p1();wJ();class ou1{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Z])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1771373086-gedddec"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await Ds(Q,this.configService)}catch(Q){T.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class DD extends o1{props;constructor(J){super();this.props=J}createState(){return new MU6}}class MU6 extends n1{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Z)=>{this.setState(()=>{this._state=Z(this._state)})};return this.widget.props.builder(J,Q,this._state)}}class AU6 extends n1{controller=new o2;focusNode=new V4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q,X=this.widget.props.isRequiredArg??!0,V=this.controller.text.trim().length>0,K=!X||V,q=c0.all(new u0(Z.foreground,1,"solid")),G=new XY({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(U)=>{let D=U.trim();if(X&&D.length===0)return;this.widget.props.onSubmit(D)},autofocus:!0,style:{textColor:Z.foreground,border:null},maxLines:1}),W=new q0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new C0({child:G})]}),H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,[new k("Command: ",new g({color:Z.foreground})),new k(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),F=[];if(K)F.push(new k("Enter",new g({color:Y.keybind}))),F.push(new k(" to submit, ",new g({color:Z.foreground,dim:!0})));F.push(new k("Esc",new g({color:Y.keybind}))),F.push(new k(" to cancel",new g({color:Z.foreground,dim:!0})));let z=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,F)})});return new c1({decoration:{border:q,color:Z.background},padding:C1.all(1),child:new b1({children:[H,new I1({height:1}),W,new v9,z]})})}}class im extends o1{props;constructor(J){super();this.props=J}createState(){return new AU6}}import{isDeepStrictEqual as hy8}from"node:util";var vy8=/[\\/_ +.#"@[({&]/,by8=/[\\/_ +.#"@[({&]/g,fy8=/[\s-]/,RU6=/[\s-]/g;function e31(J,Q,Z,Y,X,V,K){if(V===Q.length){if(X===J.length)return 1;return 0.99}let q=`${X},${V}`;if(K[q]!==void 0)return K[q];let G=Y.charAt(V),W=Z.indexOf(G,X),H=0,F,z,U,D;while(W>=0){if(F=e31(J,Q,Z,Y,W+1,V+1,K),F>H){if(W===X)F*=1;else if(fy8.test(J.charAt(W-1))){if(F*=0.9,D=J.slice(X,W-1).match(RU6),D&&X>0)F*=0.999**D.length}else if(vy8.test(J.charAt(W-1))){if(F*=0.8,U=J.slice(X,W-1).match(by8),U&&X>0)F*=0.999**U.length}else if(F*=0.3,X>0)F*=0.999**(W-X);if(J.charAt(W)!==Q.charAt(V))F*=0.9999}if(F<0.1&&(Z.charAt(W-1)===Y.charAt(V+1)||Y.charAt(V+1)===Y.charAt(V)&&Z.charAt(W-1)!==Y.charAt(V))){if(z=e31(J,Q,Z,Y,W+1,V+2,K),z*0.1>F)F=z*0.1}if(F>H)H=F;W=Z.indexOf(G,W+1)}return K[q]=H,H}function t31(J){return J.toLowerCase().replace(RU6," ")}function jU6(J,Q){let Z=e31(J,Q,t31(J),t31(Q),0,0,{}),Y=Q.trim().split(/\s+/);if(Y.length>1){let X=0,V=0;for(let q of Y){let G=e31(J,q,t31(J),t31(q),0,0,{});if(G===0)return Z;X+=G,V+=q.length}let K=X/Y.length*0.95;return Math.max(Z,K)}return Z}class $T{}class VT{}class J21{}class Q21{}class EU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new PU6}}class PU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}function uy8(J,Q){if(J==="")return{matches:!0,score:1};let Z=jU6(Q,J);return{matches:Z>0.15,score:Z}}class h7 extends o1{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new IU6}}class IU6 extends n1{controller=new o2;focusNode;scrollController=new a4;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){this.scrollController.disableFollowMode(),this.focusNode=new V4({debugLabel:this.widget.debugLabel}),this.controller.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[0]??null)}),this.recomputeFilteredItems();let J=this.cachedFiltered;this.widget.props.onSelectionChange?.(J[0]??null),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!hy8(J.props.items,this.widget.props.items)){this.recomputeFilteredItems(),this.ensureSelectedItemVisible();let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null)}}dispose(){this.widget.props.onSelectionChange?.(null),this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof $T){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof VT){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof J21){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length){let Z=Q[this.selectedIndex];if(Z){if(!(this.widget.props.isItemDisabled?.(Z)??!1))this.widget.props.onAccept(Z,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof Q21)return this.widget.props.onDismiss?.(),"handled";return"ignored"};recomputeFilteredItems(){let J=this.controller.text,Q=this.widget.props.items,Z=this.widget.props.normalizeQuery?.(J)??J,Y=Q.filter((X)=>!this.widget.props.filterItem||this.widget.props.filterItem(X,J)).map((X)=>({item:X,...uy8(Z,this.widget.props.getLabel(X))})).filter((X)=>X.matches).sort(this.widget.props.sortItems?(X,V)=>this.widget.props.sortItems(X,V,J):(X,V)=>V.score-X.score).map((X)=>X.item);this.cachedQuery=J,this.cachedItemsRef=Q,this.cachedFiltered=this.widget.props.maxRenderItems?Y.slice(0,this.widget.props.maxRenderItems):Y}getFilteredItems(){let J=this.controller.text,Q=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Q)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;RC(J,{top:Z,bottom:Y},{padding:1})}handleScroll=(J)=>{let Q=this.getFilteredItems();if(Q.length===0)return!1;let Z=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null),this.selectedIndex!==Z};handleItemClick=(J,Q)=>{let Z=this.getFilteredItems();if(J>=0&&J<Z.length){let Y=Z[J],X=Y?this.widget.props.isItemDisabled?.(Y)??!1:!1;if(Q===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.widget.props.onSelectionChange?.(Z[this.selectedIndex]??null);else if(Q===2&&!X){if(Y)this.hasUserInteracted=!0,this.widget.props.onAccept(Y,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Q=h1.of(J),{colors:Z}=Q,Y=this.getFilteredItems(),X=c0.all(new u0(Z.foreground,1,"solid")),V=this.widget.props.enabled??!0,K=new XY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Z.background,textColor:Z.foreground,cursorColor:Z.cursor,placeholderColor:Z.mutedForeground,border:null},maxLines:1}),q=new z2({shortcuts:new Map([[new r0("ArrowDown"),new $T],[new r0("ArrowUp"),new VT],[new r0("Tab"),new $T],[new r0("Tab",{shift:!0}),new VT],[new r0("n",{ctrl:!0}),new $T],[new r0("p",{ctrl:!0}),new VT],[new r0("Enter"),new J21],[new r0("Escape"),new Q21]]),focusNode:this.focusNode,child:K}),G=new N7({actions:new Map([[$T,new l6(this.invoke)],[VT,new l6(this.invoke)],[J21,new l6(this.invoke)],[Q21,new l6(this.invoke)]]),child:q}),W=new q0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new C0({child:G})]});this.itemContexts=[];let H;if(this.widget.props.isLoading){let B=this.widget.props.loadingText??"Loading...";H=new I1({height:10,child:new s0({child:new Q1({text:new k(B,new g({color:Z.foreground}))})})})}else if(Y.length===0&&this.widget.props.emptyStateText)H=new C0({child:new s0({child:new Q1({text:new k(this.widget.props.emptyStateText,new g({color:Z.foreground,dim:!0}))})})});else{let B=Y.map((N,w)=>{let L=w===this.selectedIndex,O=this.widget.props.isItemDisabled?.(N)??!1,M;if(this.widget.props.renderItem)M=this.widget.props.renderItem(N,L,O,J);else{let A=L?Q.app.selectionBackground:void 0,R=L?Q.app.selectionForeground:Z.foreground;M=new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(this.widget.props.getLabel(N),new g({color:R,dim:O}))})})}return new EU6(new o0({onClick:(A)=>this.handleItemClick(w,A.clickCount),child:M}),(A)=>{this.itemContexts[w]=A})});H=new b1({children:B,crossAxisAlignment:"start"})}let F=new o0({onScroll:this.handleScroll,opaque:!1,child:new C4({controller:this.scrollController,autofocus:!1,child:H})}),z=[];if(this.widget.props.title){let B=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(this.widget.props.title,new g({color:Q.app.command,bold:!0}))})});z.push(B)}if(z.push(W,new I1({height:1})),this.controller.text!==""){let B=Y.length>0?Y[this.selectedIndex]:void 0,N=B&&this.widget.props.buildDisabledReasonWidget?.(B,J);z.push(new C0({child:new b1({mainAxisAlignment:"spaceBetween",children:[new C0({child:F}),new c1({padding:C1.only({top:1}),child:new s0({child:N??new I1({height:1})})})]})}))}else z.push(new C0({child:F}));if(this.widget.props.footer)z.push(this.widget.props.footer);return new c1({decoration:{border:X,color:Z.background},padding:C1.symmetric(1,0),child:new b1({children:z})})}}function CU6(J){let Z=new Date().getTime()-J.getTime(),Y=Math.floor(Z/60000),X=Math.floor(Z/3600000),V=Math.floor(Z/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return J.toLocaleDateString()}class ru1 extends m0{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Q=[...this.props.entries].sort((X,V)=>V.pubDate.getTime()-X.pubDate.getTime()),Z=Math.max(0,...Q.map((X)=>CU6(X.pubDate).length));return new h7({items:Q,getLabel:(X)=>X.title,onAccept:(X)=>this.props.onSelect?.(X),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(X,V,K,q)=>{let G=h1.of(q),{colors:W}=G,H=G.app,F=V?H.selectionBackground:void 0,z=V?H.selectionForeground:W.foreground,U=W.mutedForeground,D=(B,N)=>new I1({width:N,child:q0.end([new Q1({text:new k(B,new g({color:U}))})])});return new c1({decoration:F?{color:F}:void 0,padding:C1.symmetric(2,0),child:new q0({children:[new C0({child:new Q1({text:new k(X.title,new g({color:z})),overflow:"ellipsis",maxLines:1})}),new I1({width:2}),D(CU6(X.pubDate),Z)]})})}})}}c6();class su1 extends o1{createState(){return new TU6}}class TU6 extends n1{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Z=h1.of(J).colors;return new Q1({text:new k("●",new g({color:this.isGreen?Z.success:Z.mutedForeground,bold:!0})),maxLines:1})}}var gy8=/\/threads\/(T-[^/?#\s<>]+)/i;function my8(J){let Q=J.trim(),Y=Q.match(gy8)?.[1];if(Y&&J5(Y))return Y;let X=Q.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(J5(X))return X;return null}function py8(J){let Q=new Map,Z=new Map,Y=new Map,X=[];for(let K of J)Q.set(K.id,K);for(let K of J){let q=K.relationships.find((G)=>G.role==="child"&&Q.has(G.threadID)&&(G.type==="fork"||G.type==="handoff"));if(q){Y.set(K.id,q.type);let G=q.threadID,W=Z.get(G)||[];W.push(K),Z.set(G,W)}else X.push(K)}return j71.flatten(X,(K)=>Z.get(K.id)).map((K)=>({...K.item,depth:K.depth,isLast:K.isLast,ancestorsAreLast:K.ancestorsAreLast,relationshipType:Y.get(K.item.id)}))}function tu1(J,Q,Z){return new Q1({text:new k(`${J}${Q}`,new g({color:Z})),maxLines:1})}function dy8(J,Q,Z,Y){return[tu1("+",J,Y.success),v9.horizontal(1),tu1("~",Q,Y.warning),v9.horizontal(1),tu1("-",Z,Y.destructive)]}class Z21 extends m0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}build(J){let Q=this.props.filterByWorkspace&&this.props.currentWorkspaceURI?this.props.threads.filter((D)=>D.workspaceURI===this.props.currentWorkspaceURI):this.props.threads;if(this.props.excludeCurrentThread&&this.props.currentThreadID)Q=Q.filter((D)=>D.id!==this.props.currentThreadID);let Z=this.props.recentThreadIDs||[],Y=new Set(Z),X=this.props.currentThreadID,V=[...Q].sort((D,B)=>{if(X){if(D.id===X)return-1;if(B.id===X)return 1}let N=Z.indexOf(D.id),w=Z.indexOf(B.id);if(N!==-1&&w!==-1)return N-w;if(N!==-1)return-1;if(w!==-1)return 1;return 0}),K=py8(V),q=Math.max(0,...K.map((D)=>D.description.timeAgo.length)),G=h1.of(J),W=new a1({padding:C1.symmetric(0,1),child:new s0({child:new Q1({text:new k("",new g({color:G.colors.foreground,dim:!0}),[new k("Ctrl+T",new g({color:G.colors.primary,dim:!0})),new k(this.props.filterByWorkspace?" for all workspaces":" to filter by workspace",new g({color:G.colors.foreground,dim:!0}))])})})}),H="",F=null,z=(D)=>{if(D!==H)H=D,F=my8(D);return F};return new h7({items:K,getLabel:(D)=>`${D.title} ${D.id}`,filterItem:(D,B)=>{let N=z(B);if(N)return D.id.toLowerCase()===N.toLowerCase();return!0},normalizeQuery:(D)=>z(D)?"":D,onAccept:(D,B)=>this.props.onSelect?.(D.id,B),onDismiss:this.props.onDismiss,onSelectionChange:(D)=>{if(this.props.previewController){if(D)this.props.previewController.select(D.id)}},title:this.props.title,isLoading:this.props.isLoading,loadingText:"Loading threads...",emptyStateText:"No threads match your filter",maxRenderItems:200,footer:this.props.isLoading?void 0:W,renderItem:(D,B,N,w)=>{let L=h1.of(w),{app:O,colors:M}=L,A=B?O.selectionBackground:void 0,R=B?O.selectionForeground:M.foreground,j=M.mutedForeground,P=(c,u)=>new I1({width:u,child:q0.end([new Q1({text:new k(c,new g({color:j}))})])}),C=this.props.threadViewStates[D.id],_=[],x=D.relationshipType==="handoff",b=new tg({connectorColor:M.mutedForeground});if(D.depth>0){let c=[],u=D.ancestorsAreLast.slice(1);for(let r of u)c.push(new k(b.getAncestorPrefix(r),new g({color:b.connectorColor,dim:b.connectorDim})));let a=D.isLast?b.elbow:b.tee,d=b.getConnectorText(a);c.push(new k(d,new g({color:b.connectorColor,dim:b.connectorDim}))),_.push(new Q1({text:new k("",void 0,c)}))}let h=[],y=X===D.id?new k("(current) ",new g({color:M.success})):Y.has(D.id)?new k("(visited) ",new g({color:M.foreground,dim:!0})):null;if(y)h.push(new Q1({text:y}));if(PL(C))h.push(new su1),h.push(new I1({width:1}));let f=D.title;if(D.relationshipType==="fork"){let c=f.match(/^Forked\((\d+)\): /);if(c)f=f.slice(c[0].length);else while(f.startsWith("Forked: "))f=f.slice(8);h.push(new Q1({text:new k("[fork] ",new g({color:M.primary}))}))}else if(x)h.push(new Q1({text:new k("[handoff] ",new g({color:M.accent}))}));if(h.push(new C0({child:new Q1({text:new k(f,new g({color:R})),overflow:"ellipsis",maxLines:1})})),h.push(new I1({width:2})),D.diffStats&&(D.diffStats.added>0||D.diffStats.changed>0||D.diffStats.deleted>0)){let c=B?{success:j,warning:j,destructive:j}:M;h.push(...dy8(D.diffStats.added,D.diffStats.changed,D.diffStats.deleted,c)),h.push(new I1({width:2}))}return h.push(P(D.description.timeAgo,q)),new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new q0({children:[..._,...h]})})}})}}class SU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new kU6}}class kU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}var _U6=30,cy8=30;class KT{}class qT{}class Y21{}class X21{}class eu1 extends o1{props;constructor(J){super();this.props=J}createState(){return new yU6}}class yU6 extends n1{highlightedIndex=0;controller=new o2;focusNode;scrollController=new a4;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new V4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;RC(J,{top:Z,bottom:Y},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Q}=this.widget.props;if(!J)this.filteredClusters=[...Q];else this.filteredClusters=Q.filter((Z)=>Z.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof KT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof qT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof Y21){let Q=this.filteredClusters[this.highlightedIndex];if(Q)this.widget.props.onAccept(Q);return"handled"}if(J instanceof X21)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Q)=>{if(J>=0&&J<this.filteredClusters.length){if(Q===1)this.highlightedIndex=J,this.setState();else if(Q===2){let Z=this.filteredClusters[J];if(Z)this.widget.props.onAccept(Z)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Q=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Q};build(J){let{currentThreadID:Q}=this.widget.props,Z=h1.of(J),{colors:Y,app:X}=Z,q=Y6.of(J).size.width>=cy8+_U6,G=c0.all(new u0(Y.foreground,1,"solid")),W=this.filteredClusters[this.highlightedIndex]??null,H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("Select a cluster",new g({color:X.command,bold:!0}))})}),F=new XY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),z=new z2({shortcuts:new Map([[new r0("ArrowDown"),new KT],[new r0("ArrowUp"),new qT],[new r0("Tab"),new KT],[new r0("Tab",{shift:!0}),new qT],[new r0("n",{ctrl:!0}),new KT],[new r0("p",{ctrl:!0}),new qT],[new r0("Enter"),new Y21],[new r0("Escape"),new X21]]),focusNode:this.focusNode,child:F}),U=new N7({actions:new Map([[KT,new l6(this.invoke)],[qT,new l6(this.invoke)],[Y21,new l6(this.invoke)],[X21,new l6(this.invoke)]]),child:z}),D=new q0({children:[new c1({decoration:{color:Y.background},child:new Q1({text:new k(">",new g({color:Y.foreground}))})}),new C0({child:U})]});this.itemContexts=[];let B=this.filteredClusters.map((A,R)=>{let j=R===this.highlightedIndex,P=Q?A.threads.some((b)=>b.id===Q):!1,C=j?X.selectionBackground:void 0,_=j?X.selectionForeground:Y.foreground,x=[new k(A.label,new g({color:_})),new k(` (${A.threads.length})`,new g({color:_,dim:!0}))];if(P)x.push(new k(" (current)",new g({color:j?X.selectionForeground:Y.success})));return new SU6(new o0({onClick:(b)=>this.handleItemClick(R,b.clickCount),child:new c1({decoration:C?{color:C}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,x)})})}),(b)=>{this.itemContexts[R]=b})}),N=new b1({children:B,crossAxisAlignment:"start"}),w=new C0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})}),L=W?W.threads.map((A)=>({id:A.id,title:A.title,parentID:A.parentID,updatedAt:A.updatedAt})):[],O=W?new c1({padding:C1.all(1),child:new lO({threads:L,autofocus:!1,offsetY:2})}):null,M;if(q){let A=O?new C0({child:O}):new I1({width:_U6});M=new q0({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[w,A]})}else{let A=[new C0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})})];if(O)A.push(new C0({child:O}));M=new b1({crossAxisAlignment:"stretch",children:A})}return new c1({decoration:{border:G,color:Y.background},padding:C1.symmetric(1,0),child:new b1({children:[H,D,new I1({height:1}),new C0({child:M})]})})}}p1();class xU6 extends n1{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){T.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){T.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Q=J.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!J.includes(Q.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Q=J.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let Z=this.widget.props.currentLabels||[],Y=this.labels.some((V)=>V.name===Q),X=Z.includes(Q);return!Y&&!X}build(J){let Q=h1.of(J),{app:Z,colors:Y}=Q,X=this.currentQuery.trim().toLowerCase(),V=X.length>0?this.getValidationError(X):null,K=this.getAvailableLabels(),G=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...K];return new h7({title:"Add Label",items:G,getLabel:(W)=>{if("__isCreateMarker"in W)return this.currentQuery.trim().toLowerCase();return W.name},onAccept:(W)=>{if("__isCreateMarker"in W)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(W.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:V||"Type to create a new label",renderItem:(W,H,F,z)=>{let U=H?Z.selectionBackground:void 0,D=H?Z.selectionForeground:Y.foreground;if("__isCreateMarker"in W&&W.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,[new k("Create new label: ",new g({color:D})),new k(N,new g({color:D,bold:!0}))])})})}return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(W.name,new g({color:D}))})})},filterItem:(W,H)=>{if(this.currentQuery!==H)this.currentQuery=H,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in W&&W.__isCreateMarker)return this.shouldShowCreateMarker(H);let z=H.trim().toLowerCase();return z.length===0||W.name.includes(z)},sortItems:(W,H,F)=>{let z="__isCreateMarker"in W.item&&W.item.__isCreateMarker,U="__isCreateMarker"in H.item&&H.item.__isCreateMarker;if(z&&!U)return-1;if(!z&&U)return 1;return H.score-W.score}})}}class Jg1 extends o1{props;constructor(J){super();this.props=J}createState(){return new xU6}}class BD extends o1{props;constructor(J){super();this.props=J}createState(){return new vU6}}class vU6 extends n1{_spinner=new x5;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q,X=c0.all(new u0(Z.foreground,1,"solid")),V=this._spinner.toBraille(),K=new Q1({textAlign:"center",text:new k("",void 0,[new k(V,new g({color:Y.processing})),new k(" ",void 0),new k(this.widget.props.message,new g({color:Z.foreground}))])}),G=[new C0({child:new b1({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)G.push(new I1({height:2,child:new c1({padding:C1.symmetric(2,0),child:new Q1({text:new k("",new g({dim:!0}),[new k("Press ",new g({color:Z.foreground})),new k("Esc",new g({color:Z.info})),new k(" to cancel",new g({color:Z.foreground}))])})})}));let W=new c1({decoration:new T6(Z.background,X),child:new I1({width:60,height:7,child:new b1({mainAxisAlignment:"start",children:G})})});if(this.widget.props.onAbort)return new b6({debugLabel:"LoadingDialog",autofocus:!0,onKey:(H)=>{if(H.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:W});return W}}class nO extends o1{props;constructor(J){super();this.props=J}createState(){return new bU6}}class bU6 extends n1{scrollController=new a4;scrollAreaKey=new k3("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof VY}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let Z=Q.size;if(typeof Z.height==="number"&&Z.height>0)return this.viewportHeight=Z.height,Z.height}return this.viewportHeight}build(J){let Q=h1.of(J),Z=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Z))return{title:Z.title,type:Z.type};if(Z instanceof Error&&Z.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Z.message};if(Z instanceof Error&&Z.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Z.message};let H=M71(Z);return{title:H.title,type:H.type,description:H.description}})(),X=Y.type==="error"?Q.app.toolError:Q.app.command,V=c0.all(new u0(Q.colors.border,1,"solid")),K=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(Y.title,new g({color:X,bold:!0}))})}),q=this.isWidgetMessage(Z)?Z.widget:new Q1({text:new k(Y.description,new g({color:Q.colors.foreground})),selectable:!0}),G=new C0({child:new fJ({child:new c1({padding:C1.symmetric(1,0),child:new q0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new C0({child:new C4({controller:this.scrollController,autofocus:!0,child:q})}),new j5({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let H=this.scrollController.maxScrollExtent,F=this.scrollController.offset,z=this.getViewportHeight(),U=H+z;return{totalContentHeight:Math.max(U,0),viewportHeight:Math.max(z,1),scrollOffset:Math.max(F,0)}}})]})})})}),W=new c1({padding:C1.symmetric(1,0),child:new Q1({text:(()=>{if(this.widget.props.onRetry)return new k("",void 0,[new k("Press ",new g({color:Q.colors.foreground,dim:!0})),new k("R",new g({color:Q.app.keybind})),new k(" to retry, ",new g({color:Q.colors.foreground,dim:!0})),new k("Esc",new g({color:Q.app.keybind})),new k(" to cancel",new g({color:Q.colors.foreground,dim:!0}))]);let H=this.resolveFooterStyle(this.widget.props.message);if(H==="none")return new k("",new g({color:Q.colors.foreground,dim:!0}));if(H==="help"){let F=new g({color:Q.app.keybind}),z=new g({color:Q.colors.foreground,dim:!0});return new k("",z,[new k("Press ",z),new k("Escape",F),new k(" to close • Use ",z),new k("↑↓",F),new k(" or ",z),new k("j/k",F),new k(" to scroll",z)])}return new k("Press any key to close",new g({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new b6({onKey:(H)=>{if(this.widget.props.onRetry&&H.key==="r")return this.widget.props.onRetry(),"handled";if(H.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new c1({decoration:{border:V,color:Q.colors.background},padding:C1.all(1),child:new b1({mainAxisAlignment:"center",children:[K,new I1({height:1}),G,W]})})})}}class Qg1 extends m0{build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q;return new s0({child:new Q1({text:new k("",void 0,[new k(`✓ Thread Shared
|
|
8537
8542
|
|
|
8538
8543
|
`,new g({color:Y.toolSuccess,bold:!0})),new k(`This thread has been shared with Amp support for debugging and bug prioritization.
|
|
8539
8544
|
`,new g({color:Z.foreground})),new k(`This is not a support request.
|
|
@@ -8929,7 +8934,7 @@ ${X}`,Q);this.line=Z,this.column=Y,this.codeblock=X}}/*!
|
|
|
8929
8934
|
|
|
8930
8935
|
To use Sonnet 4.5, use large mode instead: amp --mode large
|
|
8931
8936
|
Learn more: https://ampcode.com/news/large-mode
|
|
8932
|
-
`),process.exit(1);if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")BQ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")BQ("experimental.agentMode",Q.mode);if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli")BQ("systemPrompt",Q.systemPrompt)}function kg8(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function yg8(J){try{let Q=new URL(J);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function jJ1(J){let Y=yg8(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new $6(`Couldn't connect to the Amp server at ${J}.`,1,Y)}var FO6=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??AX,description:`Custom settings file path (overrides the default location ${AX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(T).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${oL})`},{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:b7(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"useSonnet",long:"use-sonnet",type:"flag",description:(J)=>J?"Use Claude Sonnet 4.5 instead of Claude Opus 4.6":"Use default model (Claude Opus 4.6)",hidden:!0},{name:"mode",long:"mode",short:"m",type:"option",default:YN.SMART.key,description:`Set the agent mode (${_Y().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:_Y().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"switch",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text to append (SDK use only)",hidden:!0}],zO6=(J)=>("deprecated"in J)&&J.deprecated===!0,xg8=(J)=>("hidden"in J)&&J.hidden===!0,vg8=(J)=>("default"in J),bg8=(J)=>("default"in J)?J.default:void 0;function fg8(J,Q){let Z=Q.args[0],Y=Q.commands.map((V)=>V.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let V=Y.filter((q)=>Z.includes(q)||q.includes(Z)),K="Run amp --help for a list of available commands.";if(V.length>0)K=`Did you mean: ${V.join(", ")}? Or run amp --help for all commands.`;throw new $6(g8.unknownCommand(Z),1,K)}}var BO6=null;function M77(){return BO6}async function Ap(J){return{...J,getThreadEnvironment:BU,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new k$(J.fileSystem),generateThreadTitle:$I,deleteThread:(Q)=>J.threadService.delete(Q),getServerStatus:()=>LZ(J.configService)}}var PJ1=U0.file(Cg8.homedir()),yp1=process.env.XDG_CONFIG_HOME?U0.file(process.env.XDG_CONFIG_HOME):W0.joinPath(PJ1,".config");function hg8(J){return z96({playNotificationSound:async(Q)=>{if(J.useNotificationsForService){F96(Q);let Z=m91(),Y=xx1();if((!Z||Y||EY6())&&J.config.settings["notifications.system.enabled"]!==!1){if(Q==="idle")process.stdout.write(mW("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Q==="requires-user-input")process.stdout.write(mW("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(m91()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function t5(J,Q){sM0("0.0.
|
|
8937
|
+
`),process.exit(1);if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")BQ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")BQ("experimental.agentMode",Q.mode);if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli")BQ("systemPrompt",Q.systemPrompt)}function kg8(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function yg8(J){try{let Q=new URL(J);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function jJ1(J){let Y=yg8(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new $6(`Couldn't connect to the Amp server at ${J}.`,1,Y)}var FO6=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??AX,description:`Custom settings file path (overrides the default location ${AX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(T).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${oL})`},{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:b7(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"useSonnet",long:"use-sonnet",type:"flag",description:(J)=>J?"Use Claude Sonnet 4.5 instead of Claude Opus 4.6":"Use default model (Claude Opus 4.6)",hidden:!0},{name:"mode",long:"mode",short:"m",type:"option",default:YN.SMART.key,description:`Set the agent mode (${_Y().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:_Y().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"switch",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text to append (SDK use only)",hidden:!0}],zO6=(J)=>("deprecated"in J)&&J.deprecated===!0,xg8=(J)=>("hidden"in J)&&J.hidden===!0,vg8=(J)=>("default"in J),bg8=(J)=>("default"in J)?J.default:void 0;function fg8(J,Q){let Z=Q.args[0],Y=Q.commands.map((V)=>V.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let V=Y.filter((q)=>Z.includes(q)||q.includes(Z)),K="Run amp --help for a list of available commands.";if(V.length>0)K=`Did you mean: ${V.join(", ")}? Or run amp --help for all commands.`;throw new $6(g8.unknownCommand(Z),1,K)}}var BO6=null;function M77(){return BO6}async function Ap(J){return{...J,getThreadEnvironment:BU,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new k$(J.fileSystem),generateThreadTitle:$I,deleteThread:(Q)=>J.threadService.delete(Q),getServerStatus:()=>LZ(J.configService)}}var PJ1=U0.file(Cg8.homedir()),yp1=process.env.XDG_CONFIG_HOME?U0.file(process.env.XDG_CONFIG_HOME):W0.joinPath(PJ1,".config");function hg8(J){return z96({playNotificationSound:async(Q)=>{if(J.useNotificationsForService){F96(Q);let Z=m91(),Y=xx1();if((!Z||Y||EY6())&&J.config.settings["notifications.system.enabled"]!==!1){if(Q==="idle")process.stdout.write(mW("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Q==="requires-user-input")process.stdout.write(mW("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(m91()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function t5(J,Q){sM0("0.0.1771373086-gedddec");let Z=Yo({storage:J.settings,secretStorage:J.secrets,workspaceRoots:k1.of([U0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:PJ1,userConfigDir:yp1});OY6(Z);let Y=await Z.getLatest();T.debug("Global configuration initialized",{settingsKeys:Object.keys(Y.settings)});let{toolService:X,dispose:V}=K96({configService:Z}),K=new Map,q=()=>K.clear(),G=new sL1(Z,J.settings.getWorkspaceRootPath()),W=lv0({configService:Z,filesystem:r4}),H=Rk0({configService:Z,trustStore:G,skillMCPServers:W.skillMCPServers,createOAuthProvider:async(_,x,b)=>{let h=`${_}:${x}`,y=K.get(h);if(y)return T.debug("Reusing existing OAuth provider for server",{serverName:_,serverUrl:x}),y;T.debug("Creating OAuth provider for server",{serverName:_,serverUrl:x});let f=(async()=>{let m=new iN(J.secrets),c=await m.getClientInfo(_,x),u=b?.scopes??c?.scopes,a=mQ6();T.info("OAuth headless mode check",{useHeadless:a,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:o4.isTTY});let d;if(a)d=J.executeMode?gQ6():uQ6(_);let r=new BL1({storage:m,serverName:_,serverUrl:x,clientId:b?.clientId??c?.clientId,clientSecret:b?.clientSecret??c?.clientSecret,authUrl:b?.authUrl??c?.authUrl,tokenUrl:b?.tokenUrl??c?.tokenUrl,scopes:u,headlessAuthHandler:d});return T.debug("OAuth provider created",{serverName:_,serverUrl:x,hasManualClientId:!!(b?.clientId??c?.clientId),willUseDCR:!(b?.clientId??c?.clientId),scopes:u,headlessMode:a,executeMode:J.executeMode}),r})();return K.set(h,f),f}}),F=P41({configService:Z,filesystem:r4,spawn:nh}),z;if(J.executeMode){let _=await O66({toolService:X,providers:[H,F],initialTimeout:15000});z=_.registrations;for(let[x,b]of _.initErrors)T.warn(`${x} provider initialization slow or failed:`,b)}else z=f_1({toolService:X,providers:[H,F]});if(Q.jetbrains)RN("JetBrains");else if(Q.ide&&LZ6())RN("VS Code");else if(Q.ide&&OZ6())RN("Neovim");else if(Q.ide&&_g8()){let _=CG.find((x)=>x.listConfigs().length>0);if(_){let x=Vo(_.ideName);if(x)RN(x)}}if(J.executeMode)tM0(!0);let U,D=W5.status.pipe(B0((_)=>Boolean(_.connected&&_.authenticated)),E6()).subscribe((_)=>{if(_){if(!U)U=X.registerTool(L66)}else U?.dispose(),U=void 0}),B;if(!J.executeMode){let _=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new $91(process.cwd(),{alwaysIncludePaths:_},!0)}else B=new class extends $91{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let _=await J.secrets.get("apiKey",J.ampURL);if(T.info("API key lookup before login",{found:Boolean(_),ampURL:J.ampURL}),!_){o4.write(`No API key found. Starting login flow...
|
|
8933
8938
|
`);let x=await ug8(J),b=await J.secrets.get("apiKey",J.ampURL);if(T.info("Login flow completed",{success:x,storedKeyPresent:Boolean(b),ampURL:J.ampURL}),!x)await rL(),process.exit(1)}}{let _=await Z.getLatest(),x=_.settings.url,b=_.secrets.isSet?.[x];T.info("Config secrets state after login",{configURL:x,apiKeySet:b?.apiKey??!1})}let N=S0(LZ(Z).pipe($9((_)=>_!=="pending"))),w=await sv0({isDevelopment:!1}),L=await N;T.info("Server status resolved",{status:"ready",isAuthenticated:g5(L),isError:Qw(L),errorMessage:Qw(L)?L.error.message:void 0});let O=new j_1(w,Z),M=new R_1(w,{lazy:!0});T.info("Starting Amp background services");let A=z16({threadService:O,threadHistoryService:M,configService:Z,isExtensionDevelopment:!1}),R;W5.status.subscribe((_)=>{R=_});let j=new DD1({workspaceRoots:[U0.file(process.cwd())],getCurrentFile:()=>{if(!R?.openFile)return;try{return U0.parse(R.openFile)}catch(_){T.warn("Failed to parse current file URI",{uri:R.openFile,error:_});return}},getOpenFiles:()=>{if(!R?.visibleFiles?.length)return[];let _=R.openFile;return R.visibleFiles.filter((x)=>x!==_).map((x)=>{try{return U0.parse(x)}catch(b){return T.warn("Failed to parse visible file URI",{uri:x,error:b}),null}}).filter((x)=>x!==null)}}),P=new fx1,C={codebaseContextService:j,configService:Z,toolService:X,mcpService:H,skillService:W,toolboxService:F,trustStore:G,threadService:O,threadHistoryService:M,threadSyncService:A,threadStorage:w,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:B,fileSystem:Q.jetbrains||Q.ide?ik0:r4,terminal:P,serverStatus:L};return{...C,async asyncDispose(){if(C.mcpService.hasAuthenticatingClients())T.info("Waiting for OAuth authentication to complete before exit..."),await C.mcpService.waitForAuthentication();for(let _ of z.values())_.dispose();await C.mcpService.dispose(),q(),await C.threadService.asyncDispose(),C.configService.unsubscribe(),V(),C.fuzzyServer.dispose(),C.threadSyncService.dispose(),C.settingsStorage[Symbol.dispose](),D.unsubscribe(),U?.dispose()}}}async function ug8(J){if(!J.executeMode){if(!await Wx1("Would you like to log in to Amp? [(y)es, (n)o]: "))return o4.write(`Login cancelled. Run the command again to retry.
|
|
8934
8939
|
`),!1}return await NO6(J)}async function NO6(J){let Q=Eg8(32).toString("hex"),Z=await Gx1(J.ampURL,Q),Y=new AbortController;try{await FK(Z,Y.signal)}catch(V){T.error("Error opening browser",{error:V})}let X=await Gx1(J.ampURL,Q,!1);o4.write(`If your browser does not open automatically, visit:
|
|
8935
8940
|
|
|
@@ -8937,7 +8942,7 @@ ${Z0.blue.bold(X)}
|
|
|
8937
8942
|
|
|
8938
8943
|
`);try{return await dZ6(J.ampURL,Q,J.secrets,Y),o4.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(V){return T.error("Login failed",{error:V}),m7.write(`
|
|
8939
8944
|
Login failed: ${V instanceof Error?V.message:String(V)}
|
|
8940
|
-
`),!1}}function gg8(){let J=new WU().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((U)=>{if(U.code==="commander.help"||U.code==="commander.version"||U.exitCode===0)tL(),process.exit(0);let D=U.originalError??U;a81(D)}),J.option("-V, --version","Print the version number and exit",()=>{let D;try{D=`, ${pF(new Date("2026-02-
|
|
8945
|
+
`),!1}}function gg8(){let J=new WU().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((U)=>{if(U.code==="commander.help"||U.code==="commander.version"||U.exitCode===0)tL(),process.exit(0);let D=U.originalError??U;a81(D)}),J.option("-V, --version","Print the version number and exit",()=>{let D;try{D=`, ${pF(new Date("2026-02-18T00:10:14.914Z"))} ago`}catch{}o4.write(`0.0.1771373086-gedddec (released 2026-02-18T00:10:14.914Z${D??""})
|
|
8941
8946
|
`),process.exit(0)}),J.addHelpText("after",BZ6()),J.configureHelp({formatHelp:NZ6}),J.command("logout").description("Log out by removing stored API key").action(async(U,D)=>{let B=D.optsWithGlobals(),N=await Y9(B);await cg8(N)}),J.command("login").description("Log in to Amp").addHelpText("after","If AMP_URL is set during login, it will be persisted to global settings for future CLI invocations, though AMP_URL will continue to take precedence.").action(async(U,D)=>{let B=D.optsWithGlobals(),N=await Y9(B);await dg8(N,await ly1(B,N.settings))}),J.command("git-credential-helper [action]",{hidden:!0}).summary("Git credential helper for GitHub").description("Internal: implements the git credential helper protocol. Used inside sandboxes to authenticate git operations with GitHub.").action(async(U,D,B)=>{let N=B.optsWithGlobals(),w=await Y9(N);await PQ6(U??"get",w.ampURL,w.secrets),process.exit(process.exitCode??0)}),J.command("sign-commit",{hidden:!0}).summary("Git commit signing helper").description("Internal: implements the gpg signing interface for git commit signing. Used inside sandboxes as gpg.program.").allowUnknownOption().action(async(U,D)=>{let B=D.optsWithGlobals(),N=await Y9(B);await IQ6(N.ampURL,N.secrets),process.exit(process.exitCode??0)}),J.command("dtw-curl [threadId] [action] [message...]",{hidden:!0}).summary("DTW helper").description("Internal: helper for DTW one-shot commands.").addHelpText("after",`
|
|
8942
8947
|
Actions:
|
|
8943
8948
|
add-message <message> Send a user message and wait for message_added
|
|
@@ -8990,8 +8995,8 @@ See: https://ampcode.com/news/stick-a-fork-in-it
|
|
|
8990
8995
|
Or pipe via stdin: echo "your message" | amp --execute`);g7(Z,Q);let K=await t5(J,Q);BO6=K;let q=await Ap(K),{serverStatus:G}=K;if(Qw(G)){let c=mI(Error(G.error.message));if(c.message===g8.networkOffline||c.message===g8.networkTimeout)throw jJ1(J.ampURL);throw new $6(g8.invalidAPIKey,1)}let W=g5(G)?G.user.email:void 0,H=g5(G)?G.features:[],F=g5(G)?G.workspace:null,z=kg8(W),U=g5(G)?{...G.user,features:H,team:F??void 0}:null,D=ru(Q,U);if(D instanceof Error)d8(D.message);if((J.executeMode||V)&&I5(Q.mode)&&!z)throw new $6(`Execute mode is not permitted with --mode '${Q.mode}'`,1);if(Q.headless){if(!W||!kR(W))throw new $6("Headless DTW mode is only available for Amp employees",1);let c=await K.secretStorage.get("apiKey",J.ampURL);if(!c)throw new $6("API key required for headless mode. Please run `amp login` first.",1);let u=typeof Q.headless==="string"&&Q.headless!=="true"?Q.headless:void 0;if(u&&!J5(u))throw new $6(`Invalid thread ID: ${u}`,1);await hQ6({ampURL:J.ampURL,apiKey:c,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:u,configService:K.configService,mcpService:K.mcpService,toolService:K.toolService,skillService:K.skillService,fileSystem:K.fileSystem}),await K.asyncDispose(),process.exit(0)}let B=async(c)=>{let u=await DO6(c,"utf-8"),a=JSON.parse(u);if(!J5(a.id))throw new $6(g8.invalidThreadId);let d=await sL(J.settings,process.cwd(),U,D);if(d instanceof Error)d8(d.message);return RJ1(K,{visibility:d,agentMode:Q.mode,thread:a})},N=async(c)=>{let u=Date.now(),[a,d]=await Promise.all([A4.getThreadLinkInfo({thread:c},{config:K.configService}),A4.getUserInfo({},{config:K.configService})]);if(T.info(`[fetchAndStartThread] Ownership check in ${Date.now()-u}ms`),a.ok&&d.ok){let r=a.result.creatorUserID,w1=d.result.id;if(r&&r!==w1&&!process.env.AMP_RESUME_OTHER_USER_THREADS_INSECURE)throw new $6(`Cannot resume thread created by another user.
|
|
8991
8996
|
|
|
8992
8997
|
This thread belongs to a different user and cannot be continued for security reasons. Set AMP_RESUME_OTHER_USER_THREADS_INSECURE=1 to bypass this check.`)}},w=async(c,{nonBlockingOwnershipCheck:u=!1,onOwnershipError:a}={})=>{if(!J5(c))throw new $6(g8.invalidThreadId);let d=Date.now();if(T.info(`[fetchAndStartThread] Begin switch to thread ${c}`),u)N(c).catch((B1)=>{if(B1 instanceof $6){if(a){a(B1,c);return}pI(B1,c);return}T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:B1})});else try{await N(c)}catch(B1){if(B1 instanceof $6)throw B1;T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:B1})}let r=Date.now(),w1=await K.threadService.get(c)??void 0;T.info(`[fetchAndStartThread] Loaded thread in ${Date.now()-r}ms`),T.info(`[fetchAndStartThread] Loaded thread ${c}, agentMode: ${w1?.agentMode??"undefined"}`);let o=Date.now(),G1=await sL(J.settings,process.cwd(),U,D);if(G1 instanceof Error)d8(G1.message);let q1=await RJ1(K,{visibility:G1,agentMode:w1?void 0:Q.mode,thread:w1});return T.info(`[fetchAndStartThread] Started worker in ${Date.now()-o}ms (total ${Date.now()-d}ms)`),q1},L=async(c)=>{if(!W||!kR(W))throw new $6("DTW TUI mode is only available for Amp employees",1);let u=await K.secretStorage.get("apiKey",J.ampURL);T.info("[createDTWRuntime] Creating DTW provider",{threadId:c,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,hasApiKey:Boolean(u)});let a;try{a=await EU.create({ampURL:J.ampURL,apiKey:u,configService:K.configService,threadId:c,workerUrl:process.env.AMP_WORKER_URL})}catch(d){throw T.error("[createDTWRuntime] Failed to create DTW provider",{threadId:c,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,error:d}),d}T.info("[createDTWRuntime] Creating DTW runtime",{threadId:a.threadId});try{return await NC.create({provider:a,deps:{threadService:K.threadService,configService:K.configService,toolService:K.toolService,skillService:K.skillService,threadSyncService:K.threadSyncService,getThreadEnvironment:BU,fileChangeTrackerStorage:new k$(K.fileSystem),osFileSystem:K.fileSystem,deleteThread:(d)=>K.threadService.delete(d),generateThreadTitle:$I,mcpService:K.mcpService,ampURL:J.ampURL}})}catch(d){throw T.error("[createDTWRuntime] Failed to create DTW runtime",{threadId:a.threadId,error:d}),d}},O={threadService:K.threadService,workerDeps:q,createThread:async()=>{let c=await sL(J.settings,process.cwd(),U,D);if(c instanceof Error)d8(c.message);return RJ1(K,{visibility:c,agentMode:Q.mode})},switchToThread:(c,u)=>w(c,{nonBlockingOwnershipCheck:u?.nonBlockingOwnershipCheck??!1,onOwnershipError:u?.onOwnershipError})},M=async()=>{try{if(Q.dtw)return L(Q.threadId);if(Q.threadId){let c=await w(Q.threadId,{nonBlockingOwnershipCheck:Q.nonBlockingThreadOwnershipCheck??!1});return new AD(O,c)}else{let c=await sL(J.settings,process.cwd(),U,D);if(c instanceof Error)d8(c.message);let u=await RJ1(K,{visibility:c,agentMode:Q.mode});return new AD(O,u)}}catch(c){if(c instanceof $6)throw c;throw await pI(c,Q.threadId),Error("handleError should have called process.exit()")}};if(Q.format==="jsonl")m7.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
|
|
8993
|
-
`),await rL(),process.exit(1);let A=(async()=>{try{let c=await K.configService.getLatest(),u=vi(c),a=await A4.getUserFreeTierStatus({},{config:K.configService,signal:AbortSignal.timeout(u)});if(a.ok)return T.info("User free tier status:",a),a.result}catch(c){throw T.error("Failed to fetch free tier status:",c),c}})(),R=await M(),j=Q.notifications!==void 0?Q.notifications:!J.executeMode,P=await K.configService.getLatest();if(hg8({configService:K.configService,threadService:K.threadService,config:P,useNotificationsForService:j,threadViewStates$:()=>R.threadViewStates$}),J.executeMode){if(eZ6(K.mcpService,J.settings),!(R instanceof AD))throw new $6("Execute mode is not supported in DTW runtime",1);let c=R.getWorkerForExecuteMode();if(await HQ6({worker:c,threadID:c.threadID,userInput:Y,stdinInput:X,dependencies:K,streamJson:V,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:J.ampURL,isDogfooding:z,agentMode:Q.mode,labels:Q.label}),Q.archive)await A4.archiveThread({thread:c.threadID,archived:!0},{config:K.configService});await K.asyncDispose(),process.exit(0)}let C=!1,_=!1,x=!1;if(Q.jetbrains||Q.ide){await wA0();let c=CN({jetbrainsOnly:Q.jetbrains});if(c.length===0){if(Q.jetbrains)_=!await K.configService.get("jetbrains.skipInstall")}else if(c.length===1){let u=c[0];if(u)W5.selectConfig(u)}else x=!0}let b=R91("0.0.
|
|
8994
|
-
`);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Tk0({get:async(q)=>{if(q!==bx)return;try{let G=await DO6(kp1,"utf-8");return JSON.parse(G).installationID}catch{return}},set:async(q,G)=>{if(q!==bx)return;await Pg8(EJ1.dirname(kp1),{recursive:!0}),await Ig8(kp1,JSON.stringify({installationID:G},null,2),{mode:384})}},{clientType:"cli",platform:bY()});eM0(Y);let X=await JZ6({...J,workspaceTrust:{current:!0,changes:bS},getHook:process.env.AMP_URL?(q,G)=>{if(q==="url")return Promise.resolve(process.env.AMP_URL);return G()}:void 0});if(J.mcpConfig){let q=await sZ6(J.mcpConfig);X=tZ6(X,q)}let V=EJ1.dirname(X.getSettingsFilePath());H96(nI,V);let K=await X.get("url","global");if(!K)K=_2;if(T.info("Resolved Amp URL",{ampURL:K,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!wF(K))T.info("Targeting custom Amp server",{ampURL:K});return X=pM0(X),{executeMode:Q,isTTY:Z,ampURL:K,settings:X,secrets:HY6(await ly1(J,X))}}function mg8(J){let Q={};for(let Z=0;Z<J.length;Z++){let Y=J[Z];if(Y?.startsWith("--")){let V=Y.slice(2).replace(/-([a-z])/g,(q,G)=>G.toUpperCase()),K=J[Z+1];if(K&&!K.startsWith("--"))Q[V]=K,Z++}}return Q}async function pg8(){let J=mg8(process.argv),Q=process.argv.includes("--headless")||process.argv.some((V)=>V.startsWith("--headless="));vJ6({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Q?Tg8:void 0)});let Z=process.argv.includes("--no-color"),Y=process.argv.includes("--color"),X=process.stdout.isTTY&&process.stderr.isTTY;if(Z||!Y&&!X)Z0.level=0;if(Sg8(T),T.info("Starting Amp CLI.",{version:"0.0.
|
|
8998
|
+
`),await rL(),process.exit(1);let A=(async()=>{try{let c=await K.configService.getLatest(),u=vi(c),a=await A4.getUserFreeTierStatus({},{config:K.configService,signal:AbortSignal.timeout(u)});if(a.ok)return T.info("User free tier status:",a),a.result}catch(c){throw T.error("Failed to fetch free tier status:",c),c}})(),R=await M(),j=Q.notifications!==void 0?Q.notifications:!J.executeMode,P=await K.configService.getLatest();if(hg8({configService:K.configService,threadService:K.threadService,config:P,useNotificationsForService:j,threadViewStates$:()=>R.threadViewStates$}),J.executeMode){if(eZ6(K.mcpService,J.settings),!(R instanceof AD))throw new $6("Execute mode is not supported in DTW runtime",1);let c=R.getWorkerForExecuteMode();if(await HQ6({worker:c,threadID:c.threadID,userInput:Y,stdinInput:X,dependencies:K,streamJson:V,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:J.ampURL,isDogfooding:z,agentMode:Q.mode,labels:Q.label}),Q.archive)await A4.archiveThread({thread:c.threadID,archived:!0},{config:K.configService});await K.asyncDispose(),process.exit(0)}let C=!1,_=!1,x=!1;if(Q.jetbrains||Q.ide){await wA0();let c=CN({jetbrainsOnly:Q.jetbrains});if(c.length===0){if(Q.jetbrains)_=!await K.configService.get("jetbrains.skipInstall")}else if(c.length===1){let u=c[0];if(u)W5.selectConfig(u)}else x=!0}let b=R91("0.0.1771373086-gedddec",K.settingsStorage),h=new Y41(K.threadStorage),y=new j91(K.mcpService,J.settings.getWorkspaceRootPath());if(Y)await R.sendMessage({content:[{type:"text",text:Y}]});let f=await wq();T.info("Loaded session state:",f);let m={...f,launchCount:f.launchCount+1};Lq(m);try{await Xm1({codebaseContextService:K.codebaseContextService,stdout:process.stdout,history:new t81,fuzzyServer:K.fuzzyServer,settingsStorage:K.settingsStorage,threadService:K.threadService,threadHistoryService:K.threadHistoryService,threadSyncService:K.threadSyncService,threadFuzzyIndexer:h,skillService:K.skillService,configService:K.configService,internalAPIClient:A4,ampURL:J.ampURL,runtime:R,ideClient:W5,mcpService:K.mcpService,toolboxService:K.toolboxService,mcpTrustHandler:y,showJetBrainsInstaller:_,showIdePicker:C,showIdePickerHint:x,openThreadSwitcher:Q.openThreadSwitcher,updateService:b,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:m,freeTierStatusPromise:A,workspace:F??null,features:H,isDogfooding:z,threadDependencies:K,initialAgentMode:Z.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,buildTimestamp:"2026-02-18T00:10:14.914Z"})}finally{await R.dispose?.()}await K.asyncDispose(),process.exit(0)}async function Y9(J){if(T.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),J.interactive)m7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
|
|
8999
|
+
`);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Tk0({get:async(q)=>{if(q!==bx)return;try{let G=await DO6(kp1,"utf-8");return JSON.parse(G).installationID}catch{return}},set:async(q,G)=>{if(q!==bx)return;await Pg8(EJ1.dirname(kp1),{recursive:!0}),await Ig8(kp1,JSON.stringify({installationID:G},null,2),{mode:384})}},{clientType:"cli",platform:bY()});eM0(Y);let X=await JZ6({...J,workspaceTrust:{current:!0,changes:bS},getHook:process.env.AMP_URL?(q,G)=>{if(q==="url")return Promise.resolve(process.env.AMP_URL);return G()}:void 0});if(J.mcpConfig){let q=await sZ6(J.mcpConfig);X=tZ6(X,q)}let V=EJ1.dirname(X.getSettingsFilePath());H96(nI,V);let K=await X.get("url","global");if(!K)K=_2;if(T.info("Resolved Amp URL",{ampURL:K,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!wF(K))T.info("Targeting custom Amp server",{ampURL:K});return X=pM0(X),{executeMode:Q,isTTY:Z,ampURL:K,settings:X,secrets:HY6(await ly1(J,X))}}function mg8(J){let Q={};for(let Z=0;Z<J.length;Z++){let Y=J[Z];if(Y?.startsWith("--")){let V=Y.slice(2).replace(/-([a-z])/g,(q,G)=>G.toUpperCase()),K=J[Z+1];if(K&&!K.startsWith("--"))Q[V]=K,Z++}}return Q}async function pg8(){let J=mg8(process.argv),Q=process.argv.includes("--headless")||process.argv.some((V)=>V.startsWith("--headless="));vJ6({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Q?Tg8:void 0)});let Z=process.argv.includes("--no-color"),Y=process.argv.includes("--color"),X=process.stdout.isTTY&&process.stderr.isTTY;if(Z||!Y&&!X)Z0.level=0;if(Sg8(T),T.info("Starting Amp CLI.",{version:"0.0.1771373086-gedddec",buildTimestamp:"2026-02-18T00:10:14.914Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new $6(g8.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await gg8().parseAsync(process.argv)}G96().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await pg8().catch(pI)});async function dg8(J,Q){let Z=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Z)await J.settings.set("url",process.env.AMP_URL,"global"),o4.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
|
|
8995
9000
|
`);else if(!wF(J.ampURL))o4.write(`Logging in to ${new URL(J.ampURL).hostname}
|
|
8996
9001
|
`);let Y=process.env.AMP_API_KEY;if(Y)o4.write(`API key found in environment variable, storing...
|
|
8997
9002
|
`),await Q.set("apiKey",Y,J.ampURL),o4.write(`API key successfully stored.
|
|
@@ -9007,7 +9012,7 @@ This thread belongs to a different user and cannot be continued for security rea
|
|
|
9007
9012
|
`)),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose(),d8(`Failed to ${Y?"archive":"unarchive"} thread: ${V instanceof Error?V.message:String(V)}`)}}async function ng8(J,Q,Z){let Y=await t5(Q,J);try{let X=VM(Z);if(!X)KM(Z);await Y.threadService.delete(X),o4.write(Z0.green(`✓ Thread ${X} deleted
|
|
9008
9013
|
`)),await Y.asyncDispose(),process.exit(0)}catch(X){await Y.asyncDispose(),d8(`Failed to delete thread: ${X instanceof Error?X.message:String(X)}`)}}async function ag8(J,Q,Z,Y){g7(Y,J);let X=await t5(Q,J);try{let V=VM(Z);if(!V)KM(Z);let q=await BH(V,X),G=XU(q);o4.write(G+`
|
|
9009
9014
|
`),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose();let K=`Failed to render thread as markdown: ${V instanceof Error?V.message:String(V)}`;d8(K)}}async function og8(J,Q,Z,Y){g7(Y,J);let X=await t5(Q,J);try{let V=VM(Z);if(!V)KM(Z);let q=await BH(V,X),G=JSON.stringify(q,null,2);o4.write(G+`
|
|
9010
|
-
`),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose();let K=`Failed to export thread: ${V instanceof Error?V.message:String(V)}`;d8(K)}}async function rg8(J,Q,Z,Y,X){g7(X,J);let V=await t5(Q,J);try{let K=await CJ1(Z),q=await BH(K,V),G=Y.typing!==!1,W=parseInt(Y.wpm||"120",10),H=parseInt(Y.messageDelay||"1000",10),F=parseInt(Y.toolProgressDelay||"800",10),z=parseInt(Y.exitDelay||"3",10)*1000,U=Y.indicator!==!1,D=await Ap(V),B=q.id;await V.threadStorage.set(B,q);let N=await l5.getOrCreateForThread(D,B);await N.resume();let w=Q41.fromWorker(N),L=new Y41(V.threadStorage),O=new j91(V.mcpService,Q.settings.getWorkspaceRootPath()),M=R91("0.0.
|
|
9015
|
+
`),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose();let K=`Failed to export thread: ${V instanceof Error?V.message:String(V)}`;d8(K)}}async function rg8(J,Q,Z,Y,X){g7(X,J);let V=await t5(Q,J);try{let K=await CJ1(Z),q=await BH(K,V),G=Y.typing!==!1,W=parseInt(Y.wpm||"120",10),H=parseInt(Y.messageDelay||"1000",10),F=parseInt(Y.toolProgressDelay||"800",10),z=parseInt(Y.exitDelay||"3",10)*1000,U=Y.indicator!==!1,D=await Ap(V),B=q.id;await V.threadStorage.set(B,q);let N=await l5.getOrCreateForThread(D,B);await N.resume();let w=Q41.fromWorker(N),L=new Y41(V.threadStorage),O=new j91(V.mcpService,Q.settings.getWorkspaceRootPath()),M=R91("0.0.1771373086-gedddec",V.settingsStorage),A=P41({configService:V.configService,filesystem:r4,spawn:nh}),R=new AD({threadService:V.threadService,workerDeps:D,createThread:async()=>w,switchToThread:async()=>w},w);try{await Xm1({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new t81,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadSyncService:V.threadSyncService,threadFuzzyIndexer:L,skillService:V.skillService,configService:V.configService,internalAPIClient:A4,ampURL:Q.ampURL,runtime:R,ideClient:W5,mcpService:V.mcpService,toolboxService:A,mcpTrustHandler:O,showJetBrainsInstaller:!1,updateService:M,isDogfooding:!1,replayMode:{thread:q,typingEnabled:G,baseWpm:W,messageDelayMs:H,toolProgressDelayMs:F,exitDelayMs:z,showIndicator:U},freeTierStatusPromise:Promise.resolve({canUseAmpFree:!0,isDailyGrantEnabled:!1}),features:[],buildTimestamp:"2026-02-18T00:10:14.914Z"})}finally{await R.dispose?.()}await V.asyncDispose(),process.exit(0)}catch(K){await V.asyncDispose(),await pI(K,Z)}}async function sg8(J,Q,Z,Y,X){g7(Y,J);let V=await t5(Q,J);try{let K=VM(Z);if(!K)KM(Z);let q=K,G=await A4.getUserInfo({},{config:V.configService}),W=G.ok?G.result:null,H=ru(J,W);if(!H&&!X)d8("Must specify either --visibility or --support");if(H&&X)d8("Cannot specify both --visibility and --support at the same time");if(H instanceof Error)d8(H.message);if(H)await V.threadSyncService.updateThreadMeta(q,su(H)),o4.write(Z0.green("✓ ")+`Thread ${q} visibility changed to ${H}.
|
|
9011
9016
|
`);if(X){await BH(q,V);let F=typeof X==="string"?X:void 0;await Dk0(V.threadService,q,V.configService,F),o4.write(Z0.green("✓ ")+`Thread ${q} has been shared with Amp support. These thread reports will be aggregated and analysed.
|
|
9012
9017
|
`)}await V.asyncDispose(),process.exit(0)}catch(K){await V.asyncDispose(),d8(`Failed to update thread: ${K instanceof Error?K.message:String(K)}`)}}async function tg8(J,Q,Z,Y,X,V){g7(V,J);let K=await t5(Q,J);try{let q=await CJ1(Z);await BH(q,K);let G=Y;if(!G){let B=(await eI()).trimEnd();if(B)G=B}if(!G)d8(`Goal must be provided via stdin or --goal argument.
|
|
9013
9018
|
Example: echo "Continue the auth work" | amp threads handoff T-xxx
|