@sourcegraph/amp 0.0.1776917347-g98800a → 0.0.1776920220-g98800a
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 +8 -8
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4550,12 +4550,12 @@ ${D}`))}},error:(U)=>{if(!H)H=!0,F(Error(`Failed to spawn brew: ${U.message}`))}
|
|
|
4550
4550
|
${D}`;if(K==="pnpm"&&D.includes("Unable to find the global bin directory"))B+=`
|
|
4551
4551
|
|
|
4552
4552
|
Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
|
|
4553
|
-
npm install -g @sourcegraph/amp`;F(Error(B))}},error:(U)=>{if(!W)W=!0,F(Error(`Failed to spawn ${K}: ${U.message}`))},complete:()=>{if(!W)W=!0,G()}})})}a0();a0();dN();async function pX0(J,Z){let X=`${Z||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,K=new AbortController,V=setTimeout(()=>K.abort(),5000);try{let G=await fetch(X,{signal:K.signal});if(!G.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let F=await G.json(),z=F.version??F["dist-tags"]?.latest;if(!z)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=pn(J,z),W=q<0,H,U;if(F.time){let D=F.time[J],B=F.time[z],N=Date.now();if(D)H=Math.floor((N-new Date(D).getTime())/3600000);if(B)U=Math.floor((N-new Date(B).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:J,latestVersion:z,compareResult:q,hasUpdate:W,currentVersionAge:H,latestVersionAge:U}),{hasUpdate:W,latestVersion:z,currentVersion:J,currentVersionAge:H,latestVersionAge:U,source:"npm"}}catch(G){return T.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var dV3="https://static.ampcode.com/cli/cli-version.txt";async function dX0(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${dV3}?t=${Date.now()}`,{signal:Z.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 K=pn(J,X),V=K<0;return T.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:K,hasUpdate:V}),{hasUpdate:V,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(Q)}}var cV3=604800000;function l_4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>cV3)return{ageMs:Q};return null}function pn(J,Z){let Q=(V)=>{let[G,F]=V.split("-");return{parts:G?.split(".").map(Number)||[],label:F}},Y=Q(J),X=Q(Z),K=Math.max(Y.parts.length,X.parts.length);for(let V=0;V<K;V++){let G=Y.parts[V]||0,F=X.parts[V]||0;if(G<F)return-1;if(G>F)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 oo0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,Y=Z[2],X=Q!==0?hz(Q):void 0;return{sha:Y,age:X}}catch{return null}}R1();a0();import{readFile as lV3,realpath as iV3}from"node:fs/promises";import{homedir as nV3}from"node:os";import{dirname as i_4,join as ro0}from"node:path";async function n_4(J){switch(J){case"binary":case"brew":return aV3(bn());case"npm":case"pnpm":case"yarn":case"bun":return oV3();case"bootstrap":return rV3()}}async function aV3(J){let Z=await oG(J,["--version"],5000);if(Z.reason!=="success")return T.debug("failed to read version from binary",{binaryPath:J,result:Z}),null;return Z.output.trim().split(/\s+/)[0]||null}async function oV3(){try{let J=process.argv[1];if(!J)return null;let Z=await iV3(J),Q=i_4(i_4(Z));return await a_4(ro0(Q,"package.json"))}catch(J){return T.debug("failed to read installed version from package.json",{error:J}),null}}async function rV3(){try{let J=process.env.AMP_HOME??ro0(nV3(),".amp");return await a_4(ro0(J,"package","package.json"))}catch(J){return T.debug("failed to read installed version from bootstrap package.json",{error:J}),null}}async function a_4(J){let Z=await lV3(J,"utf8"),Q=JSON.parse(Z);if(Q.name!=="@sourcegraph/amp")return T.debug("package.json name mismatch",{pkgJsonPath:J,name:Q.name}),null;return Q.version||null}var sV3=3600000,tV3=5000;function so0(J,Z,Q={}){let Y=new W6,X=Y.pipe(u6({shouldCountRefs:!1})),K=Q.startDelayMs??0,V=Q.checkIntervalMs??sV3,G=!1,F=()=>{G=!0};return setImmediate(async()=>{let z=new uV().scoped("update");if(K>0){if(await bz(K),G)return}let q=X.subscribe({next:(H)=>{z.debug("emit new state",H)}}),W=J;try{while(!G){let H=await eV3(W,Z,z,Y);if(H.stop)return;if(H.updatedTo)W=H.updatedTo;if(H.emittedVisibleState){if(await bz(tV3),G)return;Y.next("hidden")}if(V<=0)return;let U=1000,D=V;while(D>0&&!G){let B=Math.min(U,D);await bz(B),D-=B}}}finally{q.unsubscribe(),Y.complete()}}),{state:X,dispose:F}}async function eV3(J,Z,Q,Y){let X={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return Q.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),X.stop=!0,X;let K=await Z.get("updates.mode");if(K==="disabled")return Q.debug("checking disabled"),X.stop=!0,X;let V=await gX0(),G=V==="binary"||V==="brew";Q.debug("checking",{currentVersion:J,mode:K,packageManager:V,isBinaryDistribution:G});let F;if(G)F=await dX0(J);else{let W=await YR();F=await pX0(J,W)}if(!(F.latestVersion&&F.hasUpdate))return Q.debug("no update available"),X;let z=(W)=>{Y.next(W),X.emittedVisibleState=!0};if(V){let W=await n_4(V);if(W&&pn(W,F.latestVersion)>=0){if(Q.debug("on-disk version already up to date",{currentVersion:J,installedVersion:W,latestVersion:F.latestVersion}),X.updatedTo=W,pn(J,W)<0){let H=await vU(W),U={from:J,to:W,externallyUpdated:!0,...H};if(H.status==="same")Q.info("on-disk already updated by another instance",U),z("updated");else Q.warn("on-disk already updated by another instance, with PATH warning",U),z("updated-with-warning")}return X}}let q=()=>{if(F.currentVersionAge!==void 0&&F.latestVersionAge!==void 0){let W=F.currentVersionAge-F.latestVersionAge,H=0.5;if(Math.abs(W)<0.5)return Q.debug("versions too close together, suppressing update warning",{currentVersionAge:F.currentVersionAge,latestVersionAge:F.latestVersionAge,ageDifferenceHours:W}),!0}return!1};if(!K)K=V==="pnpm"?"warn":"auto",Q.debug("no configured update mode; selected default based on package manager",{packageManager:V,mode:K});if(V==="brew"){if(!q())z("update-available-brew");return X}if(V==="binary"&&process.execPath!==bn()){if(Q.debug("non-standard binary path, showing warning"),!q())z("update-available-unrecognized-path");return X}if(K==="warn"){if(!q())z("update-available");return X}if(!V){if(Q.debug("auto-update not supported, falling back to warn mode"),!q())z("update-available");return X}if(V==="binary"&&process.platform==="win32"){if(Q.debug("binary auto-update not supported on Windows, falling back to warn mode"),!q())z("update-available");return X}try{await mn(F.latestVersion,V),X.updatedTo=F.latestVersion;let W=await vU(F.latestVersion),H={from:F.currentVersion,to:F.latestVersion,...W};if(W.status==="same")Q.info("success",H),z("updated");else Q.warn("success with warning",H),z("updated-with-warning")}catch(W){z("update-error")}return X}catch(K){return Q.debug("check failed",{error:K}),X}}dN();import{stderr as rG}from"node:process";function o_4(J){let Z=new Hw().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 uo0(Y.force||!1,Y.verbose||!1,"0.0.
|
|
4553
|
+
npm install -g @sourcegraph/amp`;F(Error(B))}},error:(U)=>{if(!W)W=!0,F(Error(`Failed to spawn ${K}: ${U.message}`))},complete:()=>{if(!W)W=!0,G()}})})}a0();a0();dN();async function pX0(J,Z){let X=`${Z||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,K=new AbortController,V=setTimeout(()=>K.abort(),5000);try{let G=await fetch(X,{signal:K.signal});if(!G.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let F=await G.json(),z=F.version??F["dist-tags"]?.latest;if(!z)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=pn(J,z),W=q<0,H,U;if(F.time){let D=F.time[J],B=F.time[z],N=Date.now();if(D)H=Math.floor((N-new Date(D).getTime())/3600000);if(B)U=Math.floor((N-new Date(B).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:J,latestVersion:z,compareResult:q,hasUpdate:W,currentVersionAge:H,latestVersionAge:U}),{hasUpdate:W,latestVersion:z,currentVersion:J,currentVersionAge:H,latestVersionAge:U,source:"npm"}}catch(G){return T.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var dV3="https://static.ampcode.com/cli/cli-version.txt";async function dX0(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${dV3}?t=${Date.now()}`,{signal:Z.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 K=pn(J,X),V=K<0;return T.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:K,hasUpdate:V}),{hasUpdate:V,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(Q)}}var cV3=604800000;function l_4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>cV3)return{ageMs:Q};return null}function pn(J,Z){let Q=(V)=>{let[G,F]=V.split("-");return{parts:G?.split(".").map(Number)||[],label:F}},Y=Q(J),X=Q(Z),K=Math.max(Y.parts.length,X.parts.length);for(let V=0;V<K;V++){let G=Y.parts[V]||0,F=X.parts[V]||0;if(G<F)return-1;if(G>F)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 oo0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,Y=Z[2],X=Q!==0?hz(Q):void 0;return{sha:Y,age:X}}catch{return null}}R1();a0();import{readFile as lV3,realpath as iV3}from"node:fs/promises";import{homedir as nV3}from"node:os";import{dirname as i_4,join as ro0}from"node:path";async function n_4(J){switch(J){case"binary":case"brew":return aV3(bn());case"npm":case"pnpm":case"yarn":case"bun":return oV3();case"bootstrap":return rV3()}}async function aV3(J){let Z=await oG(J,["--version"],5000);if(Z.reason!=="success")return T.debug("failed to read version from binary",{binaryPath:J,result:Z}),null;return Z.output.trim().split(/\s+/)[0]||null}async function oV3(){try{let J=process.argv[1];if(!J)return null;let Z=await iV3(J),Q=i_4(i_4(Z));return await a_4(ro0(Q,"package.json"))}catch(J){return T.debug("failed to read installed version from package.json",{error:J}),null}}async function rV3(){try{let J=process.env.AMP_HOME??ro0(nV3(),".amp");return await a_4(ro0(J,"package","package.json"))}catch(J){return T.debug("failed to read installed version from bootstrap package.json",{error:J}),null}}async function a_4(J){let Z=await lV3(J,"utf8"),Q=JSON.parse(Z);if(Q.name!=="@sourcegraph/amp")return T.debug("package.json name mismatch",{pkgJsonPath:J,name:Q.name}),null;return Q.version||null}var sV3=3600000,tV3=5000;function so0(J,Z,Q={}){let Y=new W6,X=Y.pipe(u6({shouldCountRefs:!1})),K=Q.startDelayMs??0,V=Q.checkIntervalMs??sV3,G=!1,F=()=>{G=!0};return setImmediate(async()=>{let z=new uV().scoped("update");if(K>0){if(await bz(K),G)return}let q=X.subscribe({next:(H)=>{z.debug("emit new state",H)}}),W=J;try{while(!G){let H=await eV3(W,Z,z,Y);if(H.stop)return;if(H.updatedTo)W=H.updatedTo;if(H.emittedVisibleState){if(await bz(tV3),G)return;Y.next("hidden")}if(V<=0)return;let U=1000,D=V;while(D>0&&!G){let B=Math.min(U,D);await bz(B),D-=B}}}finally{q.unsubscribe(),Y.complete()}}),{state:X,dispose:F}}async function eV3(J,Z,Q,Y){let X={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return Q.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),X.stop=!0,X;let K=await Z.get("updates.mode");if(K==="disabled")return Q.debug("checking disabled"),X.stop=!0,X;let V=await gX0(),G=V==="binary"||V==="brew";Q.debug("checking",{currentVersion:J,mode:K,packageManager:V,isBinaryDistribution:G});let F;if(G)F=await dX0(J);else{let W=await YR();F=await pX0(J,W)}if(!(F.latestVersion&&F.hasUpdate))return Q.debug("no update available"),X;let z=(W)=>{Y.next(W),X.emittedVisibleState=!0};if(V){let W=await n_4(V);if(W&&pn(W,F.latestVersion)>=0){if(Q.debug("on-disk version already up to date",{currentVersion:J,installedVersion:W,latestVersion:F.latestVersion}),X.updatedTo=W,pn(J,W)<0){let H=await vU(W),U={from:J,to:W,externallyUpdated:!0,...H};if(H.status==="same")Q.info("on-disk already updated by another instance",U),z("updated");else Q.warn("on-disk already updated by another instance, with PATH warning",U),z("updated-with-warning")}return X}}let q=()=>{if(F.currentVersionAge!==void 0&&F.latestVersionAge!==void 0){let W=F.currentVersionAge-F.latestVersionAge,H=0.5;if(Math.abs(W)<0.5)return Q.debug("versions too close together, suppressing update warning",{currentVersionAge:F.currentVersionAge,latestVersionAge:F.latestVersionAge,ageDifferenceHours:W}),!0}return!1};if(!K)K=V==="pnpm"?"warn":"auto",Q.debug("no configured update mode; selected default based on package manager",{packageManager:V,mode:K});if(V==="brew"){if(!q())z("update-available-brew");return X}if(V==="binary"&&process.execPath!==bn()){if(Q.debug("non-standard binary path, showing warning"),!q())z("update-available-unrecognized-path");return X}if(K==="warn"){if(!q())z("update-available");return X}if(!V){if(Q.debug("auto-update not supported, falling back to warn mode"),!q())z("update-available");return X}if(V==="binary"&&process.platform==="win32"){if(Q.debug("binary auto-update not supported on Windows, falling back to warn mode"),!q())z("update-available");return X}try{await mn(F.latestVersion,V),X.updatedTo=F.latestVersion;let W=await vU(F.latestVersion),H={from:F.currentVersion,to:F.latestVersion,...W};if(W.status==="same")Q.info("success",H),z("updated");else Q.warn("success with warning",H),z("updated-with-warning")}catch(W){z("update-error")}return X}catch(K){return Q.debug("check failed",{error:K}),X}}dN();import{stderr as rG}from"node:process";function o_4(J){let Z=new Hw().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 uo0(Y.force||!1,Y.verbose||!1,"0.0.1776920220-g98800a"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new Hw("update").alias("up").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 JG3(Y.targetVersion)});J.addCommand(Q)}function $G3(J){let Z=Boolean(J.isTTY),Q=0,Y=!1;function X(){if(!Z||!Y)return;J.write(`
|
|
4554
4554
|
`),Y=!1,Q=0}function K(V){if(!Z)return;let G=V.padEnd(Q," ");J.write(`\r${G}`),Y=!0,Q=G.length}return{flushProgressLine:X,renderProgress:K}}async function JG3(J){let Q=process.platform==="win32"&&QR()?{currentExecutablePath:process.execPath}:void 0,{flushProgressLine:Y,renderProgress:X}=$G3(rG);if(process.env.AMP_SKIP_UPDATE_CHECK==="1")rG.write(n0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
|
|
4555
4555
|
|
|
4556
4556
|
`));try{if(!J){rG.write(n0.blue(`Checking for updates...
|
|
4557
|
-
`));let G=!1,F;if(QR()){let z=await dX0("0.0.
|
|
4558
|
-
`));let W=await vU("0.0.
|
|
4557
|
+
`));let G=!1,F;if(QR()){let z=await dX0("0.0.1776920220-g98800a");G=z.hasUpdate,F=z.latestVersion}else{let z=await YR(),q=await pX0("0.0.1776920220-g98800a",z);G=q.hasUpdate,F=q.latestVersion}if(!G){let z=oo0("0.0.1776920220-g98800a"),q=z?.age?`released ${z.age} ago`:`built ${hz(new Date("2026-04-23T05:00:45.982Z"))} ago`;rG.write(n0.green(`✓ Amp is already up to date on version ${"0.0.1776920220-g98800a"} (${q})
|
|
4558
|
+
`));let W=await vU("0.0.1776920220-g98800a",Q);if(W.warning)rG.write(`
|
|
4559
4559
|
`+n0.yellow(W.warning)+`
|
|
4560
4560
|
`);process.exit(0)}if(!F)rG.write(n0.yellow("[WARN] could not find latest version")),process.exit(0);J=F}rG.write(n0.blue(`Updating to version ${J}...
|
|
4561
4561
|
`)),await mn(J,void 0,(G)=>{Y(),rG.write(n0.dim(`Running: ${G}
|
|
@@ -5792,7 +5792,7 @@ ${X}`,Z);this.line=Q,this.column=Y,this.codeblock=X}}/*!
|
|
|
5792
5792
|
`),K=[];for(let V=0;V<X.length;V++){let z=X[V].replace(/\b(SELECT|FROM|WHERE|GROUP BY|ORDER BY|HAVING|LIMIT|JOIN|LEFT JOIN|RIGHT JOIN|INNER JOIN|ON|AND|OR|AS|IN|NOT|NULL|IS|BETWEEN|LIKE|EXISTS|UNION|DISTINCT|COUNT|SUM|AVG|MIN|MAX|DATE|TIMESTAMP_TRUNC|TIMESTAMP_SUB|CURRENT_TIMESTAMP|INTERVAL|CASE|WHEN|THEN|ELSE|END|WITH|INSERT|UPDATE|DELETE|SET|VALUES|INTO|CREATE|ALTER|DROP|TRUE|FALSE|ASC|DESC)\b/gi,"\x00$1\x01").split(/(\x00[^\x01]+\x01)/);for(let q of z)if(q.startsWith("\x00")&&q.endsWith("\x01"))K.push(new P(q.slice(1,-1),new g({color:Y.app.keybind,bold:!0})));else K.push(new P(q,new g({color:Q.colorScheme.foreground})));if(V<X.length-1)K.push(new P(`
|
|
5793
5793
|
`))}return new d0({decoration:{color:Q.colorScheme.background,border:Y4.all(new Z4(Y.app.keybind,1,"rounded"))},child:new b0({padding:I0.symmetric(0,1),child:new $0({text:new P(void 0,void 0,K)})})})}}class k41 extends D7{chartData;highlightIndex;showAxes;colors;constructor({key:J,chartData:Z,highlightIndex:Q=null,showAxes:Y=!0,colors:X=Yz0}){super(J?{key:J}:{});this.chartData=Z,this.highlightIndex=Q,this.showAxes=Y,this.colors=X}createRenderObject(){return new T41({chartData:this.chartData,highlightIndex:this.highlightIndex,showAxes:this.showAxes,colors:this.colors})}updateRenderObject(J){let Z=J;Z.chartData=this.chartData,Z.highlightIndex=this.highlightIndex,Z.showAxes=this.showAxes,Z.colors=this.colors,Z.markNeedsLayout()}}function _c4(J,Z,Q,Y,X,K,V){if(K<=0)return null;switch(J){case"horizontal-bar":{let G=Q;return G>=0&&G<K?G:null}case"bar":case"stacked-bar":{let G=V?M9:0,F=Y-G;if(F<=0)return null;let z=Z-G;if(z<0||z>=F)return null;let q=Math.max(1,Math.floor(F/K)),W=Math.floor(z/q);return W>=0&&W<K?W:null}case"line":case"sparkline":case"stacked-area":{let G=V?M9:0,F=Y-G;if(F<=0)return null;let z=Math.max(0,Math.min(F-1,Z-G));if(K===1)return 0;let q=F/(K-1),W=Math.round(z/q);return Math.max(0,Math.min(K-1,W))}default:return null}}function ik3(J,Z,Q,Y,X,K,V,G){if(X<=0||Z<0||Z>=X)return null;let F=2;switch(J){case"horizontal-bar":return{x:Math.floor(Q/2),y:Z};case"bar":case"stacked-bar":{let z=K?M9:0,q=Q-z,W=Y-(K?F:0);if(q<=0||W<=0)return null;let H=Math.max(1,Math.floor(q/X)),U=z+Z*H+Math.floor(H/2),D=G>0?V/G:0,B=Math.round((1-D)*(W-1));return{x:U,y:B}}case"line":case"sparkline":case"stacked-area":{let z=K?M9:0,q=Q-z,W=Y-(K?F:0);if(q<=0||W<=0)return null;let H=X>1?z+Math.round(Z/(X-1)*(q-1)):z+Math.floor(q/2),U=G>0?V/G:0,D=Math.round((1-U)*(W-1));return{x:H,y:D}}default:return null}}function nk3(J){let Z=0;for(let Q of J)for(let Y of Q.points)if(Y.value>Z)Z=Y.value;return Z||1}function ak3(J,Z,Q,Y,X){if(Q.length<=1){let G=Y(J.value),F=J.meta?` (${J.meta})`:"";return J.label.length+2+G.length+F.length}let K=J.label.length,V=0;for(let G of Q){let F=G.points[Z];if(!F)continue;V+=F.value;let z=2+G.name.length+2+Y(F.value).length;K=Math.max(K,z)}if(X){let G=9+Y(V).length;K=Math.max(K,G)}return K}function ok3(J,Z,Q,Y,X,K,V){let G;try{let D=v1.of(J),B=v0.of(J);G={foreground:D.colorScheme.foreground,background:D.colorScheme.background,border:B.app.keybind}}catch{G={foreground:{type:"index",value:15},background:{type:"index",value:0},border:{type:"index",value:7}}}let F=new g({color:G.foreground,bold:!0}),z=new g({color:G.foreground}),q=new g({color:G.foreground,dim:!0}),W=[],H=new g({color:G.foreground,underline:!0}),U=(D,B)=>new P(B,H,void 0,rX0(D),()=>{N3(J,D)});if(Y.length<=1){if(W.push(new P(`${Z.label}: `,F)),Z.link)W.push(U(Z.link,K(Z.value)));else W.push(new P(K(Z.value),z));if(Z.meta)W.push(new P(` (${Z.meta})`,q))}else{let D=V==="stacked-bar"||V==="stacked-area";W.push(new P(`${Z.label}
|
|
5794
5794
|
`,F));let B=0;for(let N=0;N<Y.length;N++){let w=Y[N],L=w.points[Q];if(!L)continue;B+=L.value;let O=w.color??X[N%X.length]??G.foreground;if(W.push(new P("● ",new g({color:O}))),W.push(new P(`${w.name}: `,q)),L.link)W.push(U(L.link,K(L.value)));else W.push(new P(K(L.value),z));if(N<Y.length-1||D)W.push(new P(`
|
|
5795
|
-
`))}if(D)W.push(new P(" ",q)),W.push(new P("Total: ",q)),W.push(new P(K(B),z))}return new d0({decoration:{color:G.background,border:Y4.all(new Z4(G.border,1,"rounded"))},child:new $0({text:new P(void 0,void 0,W)})})}a0();v8();uE();k2();s3();t7();Ec();nX();A$();QQ();JZ();tA();r4();mm();NC();R1();a0();A$();class v41{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;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(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1776917347-g98800a"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await T60(Z,this.configService)}catch(Z){T.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class nL extends u0{props;constructor(J){super();this.props=J}createState(){return new Tc4}}class Tc4 extends f0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}JZ();class Sc4 extends f0{controller=new i7;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new O6({debugLabel:"CommandMultilinePrompt",onKey:(J)=>{if(J.key==="Escape"){if(this.isConfirmingClearInput){if(this.controller.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[],this.imagePaths=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.controller.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return this.widget.props.onDismiss(),"handled"}return"ignored"}});initState(){if(this.widget.props.initialText)this.controller.text=this.widget.props.initialText;if(this.widget.props.initialImages)this.imageAttachments=[...this.widget.props.initialImages];this.focusNode.requestFocus()}_handleInsertImage=async(J)=>{if(this.imageAttachments.length>=wY)return!1;let Z=await $W(J);if(typeof Z==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Z],this.imagePaths=[...this.imagePaths,J]}),!1;return!1};_handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1),this.imagePaths=this.imagePaths.slice(0,-1)})};dispose(){if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.focusNode.dispose(),this.controller.dispose()}build(J){let Z=v0.of(J),{colors:Q,app:Y}=Z,K=W4.of(J).size.height,V=Math.max(Math.floor(K*0.5),10),G=new rU({controller:this.controller,triggers:[new KV],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(U)=>{this.widget.props.onSubmit(U.trim(),this.imageAttachments)},theme:Q,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:l4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),F=new s4({focusNode:this.focusNode,child:G}),z=new d0({constraints:new E1({maxHeight:V}),padding:I0.symmetric(1,0),child:F}),q=new d0({padding:I0.symmetric(1,0),child:new $0({text:new P("",void 0,[new P("Command: ",new g({color:Q.foreground})),new P(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),W=new d0({padding:I0.symmetric(1,0),child:new $0({text:this.isConfirmingClearInput?new P("",void 0,[new P("Esc",new g({color:Y.keybind})),new P(" again to clear input",new g({color:Q.foreground,dim:!0}))]):new P("",void 0,[new P("Press ",new g({color:Q.foreground,dim:!0})),new P("Enter",new g({color:Y.keybind})),new P(" to submit, ",new g({color:Q.foreground,dim:!0})),new P("Esc",new g({color:Y.keybind})),new P(" to clear",new g({color:Q.foreground,dim:!0}))])})}),H=[q,new R0({height:1}),new h1({child:z}),new R0({height:1}),W];return new d0({decoration:{border:Y4.all(new Z4(Q.foreground,1,"solid")),color:Q.background},padding:I0.all(1),child:new p0({children:H})})}}class y41 extends u0{props;constructor(J){super();this.props=J}createState(){return new Sc4}}function kc4(J){let Q=new Date().getTime()-J.getTime(),Y=Math.floor(Q/60000),X=Math.floor(Q/3600000),K=Math.floor(Q/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(K<7)return`${K}d ago`;return J.toLocaleDateString()}class x41 extends T1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((X,K)=>K.pubDate.getTime()-X.pubDate.getTime()),Q=Math.max(0,...Z.map((X)=>kc4(X.pubDate).length));return new D8({items:Z,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,K,V,G)=>{let F=v0.of(G),{colors:z}=F,q=F.app,W=K?q.selectionBackground:void 0,H=K?q.selectionForeground:z.foreground,U=z.mutedForeground,D=(B,N)=>new R0({width:N,child:q1.end([new $0({text:new P(B,new g({color:U}))})])});return new d0({decoration:W?{color:W}:void 0,padding:I0.symmetric(2,0),child:new q1({children:[new h1({child:new $0({text:new P(X.title,new g({color:H})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),D(kc4(X.pubDate),Q)]})})}})}}class bJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!bJ._instance)bJ._instance=new bJ;return bJ._instance}get allExpanded(){return this._allExpanded}setAllExpanded(J){if(this._allExpanded===J)return;this._allExpanded=J,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(J){return this._listeners.add(J),()=>this.removeListener(J)}removeListener(J){this._listeners.delete(J)}_notifyListeners(){for(let J of this._listeners)J()}}a0();class vc4 extends f0{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 Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))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((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],Y=this.labels.some((K)=>K.name===Z),X=Q.includes(Z);return!Y&&!X}build(J){let Z=v0.of(J),{app:Q,colors:Y}=Z,X=this.currentQuery.trim().toLowerCase(),K=X.length>0?this.getValidationError(X):null,V=this.getAvailableLabels(),F=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new D8({title:"Add Label",items:F,getLabel:(z)=>{if("__isCreateMarker"in z)return this.currentQuery.trim().toLowerCase();return z.name},onAccept:(z)=>{if("__isCreateMarker"in z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:K||"Type to create a new label",renderItem:(z,q,W,H)=>{let U=q?Q.selectionBackground:void 0,D=q?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new d0({decoration:U?{color:U}:void 0,padding:I0.symmetric(2,0),child:new $0({text:new P("",void 0,[new P("Create new label: ",new g({color:D})),new P(N,new g({color:D,bold:!0}))])})})}return new d0({decoration:U?{color:U}:void 0,padding:I0.symmetric(2,0),child:new $0({text:new P(z.name,new g({color:D}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let H=q.trim().toLowerCase();return H.length===0||z.name.includes(H)},sortItems:(z,q,W)=>{let H="__isCreateMarker"in z.item&&z.item.__isCreateMarker,U="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(H&&!U)return-1;if(!H&&U)return 1;return q.score-z.score}})}}class f41 extends u0{props;constructor(J){super();this.props=J}createState(){return new vc4}}v8();class yc4 extends u0{props;constructor(J){super();this.props=J}createState(){return new xc4}}class xc4 extends f0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=O9.default(),{colors:Q,app:Y}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:Y.toolSuccess};case"error":return{icon:"✗",color:Y.toolError}}}build(J){let Z=v0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new $0({text:new P("No plugins found.",new g({dim:!0}))});let Y=[],X=this.plugins.length,K=this.plugins.filter((F)=>F.status==="active").length,V=this.plugins.reduce((F,z)=>F+z.registeredCommands.length,0),G=this.plugins.reduce((F,z)=>F+z.registeredTools.length,0);if(Y.push(new P(`${K}/${X} ${j4(X,"plugin")} active`,new g({bold:!0}))),V>0||G>0)Y.push(new P(` (${V} ${j4(V,"command")}, ${G} ${j4(G,"tool")})`,new g({dim:!0})));Y.push(new P(`
|
|
5795
|
+
`))}if(D)W.push(new P(" ",q)),W.push(new P("Total: ",q)),W.push(new P(K(B),z))}return new d0({decoration:{color:G.background,border:Y4.all(new Z4(G.border,1,"rounded"))},child:new $0({text:new P(void 0,void 0,W)})})}a0();v8();uE();k2();s3();t7();Ec();nX();A$();QQ();JZ();tA();r4();mm();NC();R1();a0();A$();class v41{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;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(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1776920220-g98800a"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await T60(Z,this.configService)}catch(Z){T.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class nL extends u0{props;constructor(J){super();this.props=J}createState(){return new Tc4}}class Tc4 extends f0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}JZ();class Sc4 extends f0{controller=new i7;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new O6({debugLabel:"CommandMultilinePrompt",onKey:(J)=>{if(J.key==="Escape"){if(this.isConfirmingClearInput){if(this.controller.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[],this.imagePaths=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.controller.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return this.widget.props.onDismiss(),"handled"}return"ignored"}});initState(){if(this.widget.props.initialText)this.controller.text=this.widget.props.initialText;if(this.widget.props.initialImages)this.imageAttachments=[...this.widget.props.initialImages];this.focusNode.requestFocus()}_handleInsertImage=async(J)=>{if(this.imageAttachments.length>=wY)return!1;let Z=await $W(J);if(typeof Z==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Z],this.imagePaths=[...this.imagePaths,J]}),!1;return!1};_handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1),this.imagePaths=this.imagePaths.slice(0,-1)})};dispose(){if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.focusNode.dispose(),this.controller.dispose()}build(J){let Z=v0.of(J),{colors:Q,app:Y}=Z,K=W4.of(J).size.height,V=Math.max(Math.floor(K*0.5),10),G=new rU({controller:this.controller,triggers:[new KV],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(U)=>{this.widget.props.onSubmit(U.trim(),this.imageAttachments)},theme:Q,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:l4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),F=new s4({focusNode:this.focusNode,child:G}),z=new d0({constraints:new E1({maxHeight:V}),padding:I0.symmetric(1,0),child:F}),q=new d0({padding:I0.symmetric(1,0),child:new $0({text:new P("",void 0,[new P("Command: ",new g({color:Q.foreground})),new P(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),W=new d0({padding:I0.symmetric(1,0),child:new $0({text:this.isConfirmingClearInput?new P("",void 0,[new P("Esc",new g({color:Y.keybind})),new P(" again to clear input",new g({color:Q.foreground,dim:!0}))]):new P("",void 0,[new P("Press ",new g({color:Q.foreground,dim:!0})),new P("Enter",new g({color:Y.keybind})),new P(" to submit, ",new g({color:Q.foreground,dim:!0})),new P("Esc",new g({color:Y.keybind})),new P(" to clear",new g({color:Q.foreground,dim:!0}))])})}),H=[q,new R0({height:1}),new h1({child:z}),new R0({height:1}),W];return new d0({decoration:{border:Y4.all(new Z4(Q.foreground,1,"solid")),color:Q.background},padding:I0.all(1),child:new p0({children:H})})}}class y41 extends u0{props;constructor(J){super();this.props=J}createState(){return new Sc4}}function kc4(J){let Q=new Date().getTime()-J.getTime(),Y=Math.floor(Q/60000),X=Math.floor(Q/3600000),K=Math.floor(Q/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(K<7)return`${K}d ago`;return J.toLocaleDateString()}class x41 extends T1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((X,K)=>K.pubDate.getTime()-X.pubDate.getTime()),Q=Math.max(0,...Z.map((X)=>kc4(X.pubDate).length));return new D8({items:Z,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,K,V,G)=>{let F=v0.of(G),{colors:z}=F,q=F.app,W=K?q.selectionBackground:void 0,H=K?q.selectionForeground:z.foreground,U=z.mutedForeground,D=(B,N)=>new R0({width:N,child:q1.end([new $0({text:new P(B,new g({color:U}))})])});return new d0({decoration:W?{color:W}:void 0,padding:I0.symmetric(2,0),child:new q1({children:[new h1({child:new $0({text:new P(X.title,new g({color:H})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),D(kc4(X.pubDate),Q)]})})}})}}class bJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!bJ._instance)bJ._instance=new bJ;return bJ._instance}get allExpanded(){return this._allExpanded}setAllExpanded(J){if(this._allExpanded===J)return;this._allExpanded=J,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(J){return this._listeners.add(J),()=>this.removeListener(J)}removeListener(J){this._listeners.delete(J)}_notifyListeners(){for(let J of this._listeners)J()}}a0();class vc4 extends f0{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 Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))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((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],Y=this.labels.some((K)=>K.name===Z),X=Q.includes(Z);return!Y&&!X}build(J){let Z=v0.of(J),{app:Q,colors:Y}=Z,X=this.currentQuery.trim().toLowerCase(),K=X.length>0?this.getValidationError(X):null,V=this.getAvailableLabels(),F=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new D8({title:"Add Label",items:F,getLabel:(z)=>{if("__isCreateMarker"in z)return this.currentQuery.trim().toLowerCase();return z.name},onAccept:(z)=>{if("__isCreateMarker"in z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:K||"Type to create a new label",renderItem:(z,q,W,H)=>{let U=q?Q.selectionBackground:void 0,D=q?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new d0({decoration:U?{color:U}:void 0,padding:I0.symmetric(2,0),child:new $0({text:new P("",void 0,[new P("Create new label: ",new g({color:D})),new P(N,new g({color:D,bold:!0}))])})})}return new d0({decoration:U?{color:U}:void 0,padding:I0.symmetric(2,0),child:new $0({text:new P(z.name,new g({color:D}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let H=q.trim().toLowerCase();return H.length===0||z.name.includes(H)},sortItems:(z,q,W)=>{let H="__isCreateMarker"in z.item&&z.item.__isCreateMarker,U="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(H&&!U)return-1;if(!H&&U)return 1;return q.score-z.score}})}}class f41 extends u0{props;constructor(J){super();this.props=J}createState(){return new vc4}}v8();class yc4 extends u0{props;constructor(J){super();this.props=J}createState(){return new xc4}}class xc4 extends f0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=O9.default(),{colors:Q,app:Y}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:Y.toolSuccess};case"error":return{icon:"✗",color:Y.toolError}}}build(J){let Z=v0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new $0({text:new P("No plugins found.",new g({dim:!0}))});let Y=[],X=this.plugins.length,K=this.plugins.filter((F)=>F.status==="active").length,V=this.plugins.reduce((F,z)=>F+z.registeredCommands.length,0),G=this.plugins.reduce((F,z)=>F+z.registeredTools.length,0);if(Y.push(new P(`${K}/${X} ${j4(X,"plugin")} active`,new g({bold:!0}))),V>0||G>0)Y.push(new P(` (${V} ${j4(V,"command")}, ${G} ${j4(G,"tool")})`,new g({dim:!0})));Y.push(new P(`
|
|
5796
5796
|
|
|
5797
5797
|
`));for(let F of this.plugins){let{icon:z,color:q}=this.statusIcon(F.status),W=this.getRelativePath(F.uri.toString());if(Y.push(new P(`${z} `,new g({color:q}))),Y.push(new P(W,new g({bold:!0}))),Y.push(new P(` ${F.status}`,new g({dim:!0}))),Y.push(new P(`
|
|
5798
5798
|
`)),F.status==="active"&&F.registeredEvents.length>0)Y.push(new P(" Events: ",new g({dim:!0}))),Y.push(new P(F.registeredEvents.join(", "),new g({color:Q.link}))),Y.push(new P(`
|
|
@@ -5985,7 +5985,7 @@ ${r.content||""}`:r.content||"",_0=[],m0=r.baseDir.startsWith("file://")?uz0(r.b
|
|
|
5985
5985
|
`),process.exit(1)}process.stdout.write(await Mu3(F.result.displayText)+`
|
|
5986
5986
|
`),process.exit(0)})}dN();import{stdout as Au3}from"node:process";function ju3({version:J,buildTimestamp:Z,buildType:Q}){let Y=Q==="dev"?"dev":"released",X=Z?new Date(Z):null,K=X&&!Number.isNaN(X.getTime())?`, ${hz(X)} ago`:"";return`${J} (${Y}${Z?` ${Z}`:""}${K})`}function Sn4(J){Au3.write(`${ju3(J)}
|
|
5987
5987
|
`)}function kn4(J,Z){J.option("-V, --version","Print the version number and exit",()=>{Sn4(Z),process.exit(0)}),J.command("version").description("Print the version number and exit").action(()=>{Sn4(Z),process.exit(0)})}var lm3=lr.join(lX,"logs","headless.log"),d31=lr.join(ev,"device-id.json"),im3=`cli-tui-${Ks4(16).toString("hex")}`;async function nm3(){for(let J of gE)try{if((await J.listConfigs()).length>0)return J}catch(Z){T.debug("Failed to detect query-based IDE integration",{ideName:J.ideName,error:Z})}return}try{if(process.platform==="win32")await Promise.resolve().then(() => D4(ax(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){xZ.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
|
|
5988
|
-
`)}function am3(J){process.emitWarning=(Z,Q,Y,X)=>{let K=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",G=!1;J.warn(K,{name:V,code:Y})}}function I2(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")N$("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")N$("experimental.agentMode",Z.mode);if(J.getOptionValueSourceWithGlobals("model")==="cli"&&Z.model)N$("internal.model",om3(Z.model))}function er4(J){let Z=J.indexOf(":");if(Z===-1)throw new z4(`Invalid model format "${J}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let Q=J.slice(0,Z).trim(),Y=J.slice(Z+1).trim();if(!Q||!Y)throw new z4(`Invalid model format "${J}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function om3(J){if(!J.includes("="))return er4(J),J;let Z={};for(let Q of J.split(",")){let Y=Q.trim();if(!Y)continue;let X=Y.indexOf("=");if(X===-1)throw new z4(`Invalid mode-specific model entry "${Y}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let K=Y.slice(0,X).trim(),V=Y.slice(X+1).trim();if(!K)throw new z4(`Missing mode name in "${Y}". Expected "mode=provider:model".`,1);if(!V)throw new z4(`Missing model value for mode "${K}". Expected "${K}=provider:model".`,1);er4(V),Z[K]=V}if(Object.keys(Z).length===0)throw new z4("No valid model overrides found in --model flag value.",1);return Z}function rm3(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function sm3(J){try{return await Vs4(J,"utf-8")}catch{return J}}async function $s4(J,Z,Q){let Y=rm3(J,Z);if(!Y)return;let X=_6(Q)?Q.features:[],K=_6(Q)?Q.user.email:void 0;if(!ox(X,P7.HARNESS_SYSTEM_PROMPT)&&!(K&&S2(K)))throw new z4("You are not allowed to do this.",1);N$("systemPrompt",await sm3(Y))}function ox(J,Z){return J?.some((Q)=>Q.name===Z&&Q.enabled)??!1}function tm3(J){return J!=="pending"}function sx(J){if(!_6(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function em3(J){let Z=sx(J);if(Z)return Z.id;if(GH(J))throw Error(J.error.message);throw Error("unreachable")}function $p3(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function Jp3(J){let Y=$p3(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 z4(`Couldn't connect to the Amp server at ${J}.`,1,Y)}function l31(J,Z){let Q=ha0(Error(J.error.message));if(Q.message===J$.networkOffline||Q.message===J$.networkTimeout)return Jp3(Z);if(Q.message!==J$.internalBug)return new z4(Q.message,1,Q.suggestion);return new z4(J.error.message.replace(/^Error: /,""),1)}var Js4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH; 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??oK,description:`Custom settings file path (overrides the default location ${oK})`},{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 ${Hn})`},{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:c7(),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:"mode",long:"mode",short:"m",type:"option",default:fE.SMART.key,description:`Set the agent mode (${oZ({}).map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:oZ().map((J)=>J.mode).concat("large","deep","internal")},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable v2 thread mode and use the legacy worker runtime",hidden:!0},{name:"neo",long:"neo",type:"switch",description:"Use the Neo TUI",hidden:!0},{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:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0},{name:"model",long:"model",type:"option",description:'Override the model. Use "provider:model" for all modes, or "mode=provider:model,mode=provider:model" for mode-specific overrides',hidden:!0}],Zs4=(J)=>("deprecated"in J)&&J.deprecated===!0,Zp3=(J)=>("hidden"in J)&&J.hidden===!0,Qp3=(J)=>("default"in J),Yp3=(J)=>("default"in J)?J.default:void 0,Gs4=[{name:"toggle-skills-count",entryPoint:w11}];function Xp3(J,Z){let Q=Z.args[0],Y=Z.commands.map((K)=>K.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let K=Y.filter((G)=>Q.includes(G)||G.includes(Q)),V="Run amp --help for a list of available commands.";if(K.length>0)V=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new z4(J$.unknownCommand(Q),1,V)}}async function Cq0(J){return{...J,getThreadEnvironment:UU,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new kM(J.fileSystem),generateThreadTitle:f14,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>YQ(J.configService),pluginService:J.pluginService}}function Fs4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:UU,filesystem:J.fileSystem,threadService:J.threadService}}var zs4="code-tour";function c31(J){return J.filter((Z)=>Z.name!==zs4)}function Kp3(J){return{...J,skills:J.skills.pipe(A1(c31)),getSkills:async()=>c31(await J.getSkills()),getSkill:async(Z)=>Z===zs4?void 0:J.getSkill(Z),getSkillsList:async()=>{let Z=c31(await J.getSkills());return wT(Z)}}}var Iq0=G1.file(cm3.homedir()),i31=process.env.XDG_CONFIG_HOME?G1.file(process.env.XDG_CONFIG_HOME):F1.joinPath(Iq0,".config");function Vp3(J){return UH4({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){if(_C4())TC4();else if(process.platform==="darwin"&&Z==="idle"&&J.isTUIVoiceNotifEnabled())HH4();else up0(Z);let Q=vK0(),Y=nr0();if((!Q||Y||OT4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(xU("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(xU("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(vK0()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function M7(J,Z,Q){let Y=Q?.deferAuth??!1,X=Q?.skipToolProviders??!1;Xb1("0.0.
|
|
5988
|
+
`)}function am3(J){process.emitWarning=(Z,Q,Y,X)=>{let K=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",G=!1;J.warn(K,{name:V,code:Y})}}function I2(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")N$("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")N$("experimental.agentMode",Z.mode);if(J.getOptionValueSourceWithGlobals("model")==="cli"&&Z.model)N$("internal.model",om3(Z.model))}function er4(J){let Z=J.indexOf(":");if(Z===-1)throw new z4(`Invalid model format "${J}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let Q=J.slice(0,Z).trim(),Y=J.slice(Z+1).trim();if(!Q||!Y)throw new z4(`Invalid model format "${J}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function om3(J){if(!J.includes("="))return er4(J),J;let Z={};for(let Q of J.split(",")){let Y=Q.trim();if(!Y)continue;let X=Y.indexOf("=");if(X===-1)throw new z4(`Invalid mode-specific model entry "${Y}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let K=Y.slice(0,X).trim(),V=Y.slice(X+1).trim();if(!K)throw new z4(`Missing mode name in "${Y}". Expected "mode=provider:model".`,1);if(!V)throw new z4(`Missing model value for mode "${K}". Expected "${K}=provider:model".`,1);er4(V),Z[K]=V}if(Object.keys(Z).length===0)throw new z4("No valid model overrides found in --model flag value.",1);return Z}function rm3(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function sm3(J){try{return await Vs4(J,"utf-8")}catch{return J}}async function $s4(J,Z,Q){let Y=rm3(J,Z);if(!Y)return;let X=_6(Q)?Q.features:[],K=_6(Q)?Q.user.email:void 0;if(!ox(X,P7.HARNESS_SYSTEM_PROMPT)&&!(K&&S2(K)))throw new z4("You are not allowed to do this.",1);N$("systemPrompt",await sm3(Y))}function ox(J,Z){return J?.some((Q)=>Q.name===Z&&Q.enabled)??!1}function tm3(J){return J!=="pending"}function sx(J){if(!_6(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function em3(J){let Z=sx(J);if(Z)return Z.id;if(GH(J))throw Error(J.error.message);throw Error("unreachable")}function $p3(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function Jp3(J){let Y=$p3(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 z4(`Couldn't connect to the Amp server at ${J}.`,1,Y)}function l31(J,Z){let Q=ha0(Error(J.error.message));if(Q.message===J$.networkOffline||Q.message===J$.networkTimeout)return Jp3(Z);if(Q.message!==J$.internalBug)return new z4(Q.message,1,Q.suggestion);return new z4(J.error.message.replace(/^Error: /,""),1)}var Js4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH; 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??oK,description:`Custom settings file path (overrides the default location ${oK})`},{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 ${Hn})`},{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:c7(),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:"mode",long:"mode",short:"m",type:"option",default:fE.SMART.key,description:`Set the agent mode (${oZ({}).map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:oZ().map((J)=>J.mode).concat("large","deep","internal")},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable v2 thread mode and use the legacy worker runtime",hidden:!0},{name:"neo",long:"neo",type:"switch",description:"Use the Neo TUI",hidden:!0},{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:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0},{name:"model",long:"model",type:"option",description:'Override the model. Use "provider:model" for all modes, or "mode=provider:model,mode=provider:model" for mode-specific overrides',hidden:!0}],Zs4=(J)=>("deprecated"in J)&&J.deprecated===!0,Zp3=(J)=>("hidden"in J)&&J.hidden===!0,Qp3=(J)=>("default"in J),Yp3=(J)=>("default"in J)?J.default:void 0,Gs4=[{name:"toggle-skills-count",entryPoint:w11}];function Xp3(J,Z){let Q=Z.args[0],Y=Z.commands.map((K)=>K.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let K=Y.filter((G)=>Q.includes(G)||G.includes(Q)),V="Run amp --help for a list of available commands.";if(K.length>0)V=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new z4(J$.unknownCommand(Q),1,V)}}async function Cq0(J){return{...J,getThreadEnvironment:UU,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new kM(J.fileSystem),generateThreadTitle:f14,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>YQ(J.configService),pluginService:J.pluginService}}function Fs4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:UU,filesystem:J.fileSystem,threadService:J.threadService}}var zs4="code-tour";function c31(J){return J.filter((Z)=>Z.name!==zs4)}function Kp3(J){return{...J,skills:J.skills.pipe(A1(c31)),getSkills:async()=>c31(await J.getSkills()),getSkill:async(Z)=>Z===zs4?void 0:J.getSkill(Z),getSkillsList:async()=>{let Z=c31(await J.getSkills());return wT(Z)}}}var Iq0=G1.file(cm3.homedir()),i31=process.env.XDG_CONFIG_HOME?G1.file(process.env.XDG_CONFIG_HOME):F1.joinPath(Iq0,".config");function Vp3(J){return UH4({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){if(_C4())TC4();else if(process.platform==="darwin"&&Z==="idle"&&J.isTUIVoiceNotifEnabled())HH4();else up0(Z);let Q=vK0(),Y=nr0();if((!Q||Y||OT4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(xU("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(xU("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(vK0()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function M7(J,Z,Q){let Y=Q?.deferAuth??!1,X=Q?.skipToolProviders??!1;Xb1("0.0.1776920220-g98800a");let K=bC({storage:J.settings,secretStorage:J.secrets,workspaceRoot:x0.of(G1.file(process.cwd())),defaultAmpURL:J.ampURL,homeDir:Iq0,userConfigDir:i31});wm4(K);let V=await K.getLatest();T.debug("Global configuration initialized",{settingsKeys:Object.keys(V.settings)});let G=!1;{let p=await J.secrets.get("apiKey",J.ampURL);if(G=Boolean(p),T.info("API key lookup before login",{found:Boolean(p),ampURL:J.ampURL,deferAuth:Y}),!p)if(Y)T.info("No API key found, continuing startup with deferred auth");else{c5.write(`No API key found. Starting login flow...
|
|
5989
5989
|
`);let d=await Gp3(J),h=await J.secrets.get("apiKey",J.ampURL);if(T.info("Login flow completed",{success:d,storedKeyPresent:Boolean(h),ampURL:J.ampURL}),!d)await Tq(),process.exit(1);G=!0}}{let p=await K.getLatest(),d=p.settings.url,h=p.secrets.isSet?.[d];T.info("Config secrets state after login",{configURL:d,apiKeySet:h?.apiKey??!1})}let F=k1(YQ(K).pipe(m5(tm3))),z=Y?"pending":await F;if(!Y)T.info("Server status resolved",{status:"ready",isAuthenticated:_6(z),isError:GH(z),errorMessage:GH(z)?z.error.message:void 0});let q=F.then((p)=>em3(p));q.catch(()=>{return});let{toolService:W,dispose:H}=wZ0({configService:K}),U=new Map,D=()=>U.clear(),B=new oT0(K,J.settings.getWorkspaceRootPath()),N=s80({configService:K,filesystem:z8}),w=lo1({configService:K,trustStore:B,skillMCPServers:N.skillMCPServers,createOAuthProvider:async(p,d,h)=>{let a=`${p}:${d}`,l=U.get(a);if(l)return T.debug("Reusing existing OAuth provider for server",{serverName:p,serverUrl:d}),l;T.debug("Creating OAuth provider for server",{serverName:p,serverUrl:d});let t=(async()=>{let N0=new iE(J.secrets),o=await N0.getClientInfo(p,d),J0=h?.scopes??o?.scopes,W0=yC4();T.info("OAuth headless mode check",{useHeadless:W0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:c5.isTTY});let U0;if(W0)U0=J.executeMode?vC4():kC4(p);let Z0=new TI0({storage:N0,serverName:p,serverUrl:d,clientId:h?.clientId??o?.clientId,clientSecret:h?.clientSecret??o?.clientSecret,authUrl:h?.authUrl??o?.authUrl,tokenUrl:h?.tokenUrl??o?.tokenUrl,scopes:J0,headlessAuthHandler:U0});return T.debug("OAuth provider created",{serverName:p,serverUrl:d,hasManualClientId:!!(h?.clientId??o?.clientId),willUseDCR:!(h?.clientId??o?.clientId),scopes:J0,headlessMode:W0,executeMode:J.executeMode}),Z0})();return U.set(a,t),t}}),L=nm0({configService:K,filesystem:z8,spawn:gJ0}),O;if(X)O=new Map;else if(J.executeMode){let p=await Ez4({toolService:W,providers:[w,L],initialTimeout:15000});O=p.registrations;for(let[d,h]of p.initErrors)T.warn(`${d} provider initialization slow or failed:`,h)}else O=am0({toolService:W,providers:[w,L]});if(Z.jetbrains)bE("JetBrains");else if(Z.ide&&N_4())bE("VS Code");else if(Z.ide&&w_4())bE("Neovim");else if(Z.ide){let p=await nm3();if(p){let d=n40(p.ideName);if(d)bE(d)}}if(J.executeMode)Kb1(!0);let E,M=n8.status.pipe(A1((p)=>Boolean(p.connected&&p.authenticated&&p.ideName&&xb1(p.ideName))),d4()).subscribe((p)=>{if(p){if(!E)E=W.registerTool(Oz4)}else E?.dispose(),E=void 0}),A;if(!J.executeMode){let p=await J.settings.get("fuzzy.alwaysIncludePaths")??[];A=new sv(process.cwd(),{alwaysIncludePaths:p},!0)}else A=new class extends sv{async start(){}async query(){return[]}async queryCompletions(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let j=new ek0(fM(K),{maxThreads:200});T.info("Starting Amp background services");let I=new j11,_=process.env.PLUGINS??"off",C=Z.headless?Zm4():void 0,b=C??new xG0({configService:K}),m=b instanceof xG0?b:void 0;if(m)m.pluginExecutorKind="local";let f=WS0({configService:K,fileSystem:z8,platform:b,internalPlugins:Gs4,pluginFilter:_}),v=gr1({pluginService:f,toolService:W}),x={configService:K,toolService:W,mcpService:w,skillService:N,toolboxService:L,trustStore:B,threadService:j,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:A,fileSystem:z8,terminal:I,pluginService:f,pluginPlatform:m,headlessPluginPlatform:C,serverStatus:z,serverStatusPromise:F,viewerUserIDPromise:q,hasAPIKeyAtStartup:G};return{...x,async asyncDispose(){if(x.mcpService.hasAuthenticatingClients())T.info("Waiting for OAuth authentication to complete before exit..."),await x.mcpService.waitForAuthentication();for(let p of O.values())p.dispose();await x.mcpService.dispose(),D(),await x.threadService.asyncDispose(),x.configService.unsubscribe(),H(),x.fuzzyServer.dispose(),x.settingsStorage[Symbol.dispose](),M.unsubscribe(),E?.dispose(),v.dispose(),await x.pluginService.dispose()}}}async function Gp3(J){if(!J.executeMode){if(!await wK0("Would you like to log in to Amp? [(y)es, (n)o]: "))return c5.write(`Login cancelled. Run the command again to retry.
|
|
5990
5990
|
`),!1}return await qs4(J)}async function qs4(J){let Z=Ks4(32).toString("hex"),Q=await Vy(J.ampURL,Z),Y=new AbortController;try{await bV(Q,Y.signal)}catch(K){T.error("Error opening browser",{error:K})}let X=await Vy(J.ampURL,Z,!1);c5.write(`If your browser does not open automatically, visit:
|
|
5991
5991
|
|
|
@@ -5993,7 +5993,7 @@ ${n0.blue.bold(X)}
|
|
|
5993
5993
|
|
|
5994
5994
|
`);try{return await kS4(J.ampURL,Z,J.secrets,Y),c5.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(K){return T.error("Login failed",{error:K}),xZ.write(`
|
|
5995
5995
|
Login failed: ${K instanceof Error?K.message:String(K)}
|
|
5996
|
-
`),!1}}function Fp3(J){let Z=new Hw().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Z.exitOverride((D)=>{if(D.code==="commander.help"||D.code==="commander.version"||D.exitCode===0)aj(),process.exit(0);let B=D.originalError??D;PI4(B)}),kn4(Z,{version:"0.0.
|
|
5996
|
+
`),!1}}function Fp3(J){let Z=new Hw().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Z.exitOverride((D)=>{if(D.code==="commander.help"||D.code==="commander.version"||D.exitCode===0)aj(),process.exit(0);let B=D.originalError??D;PI4(B)}),kn4(Z,{version:"0.0.1776920220-g98800a",buildTimestamp:"2026-04-23T05:00:45.982Z",buildType:"'release'"}),Z.addHelpText("after",U_4()),Z.configureHelp({formatHelp:D_4}),Z.command("logout").description("Log out by removing stored API key").action(async(D,B)=>{let N=B.optsWithGlobals(),w=await c3(N);await Bp3(w)}),Z.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(D,B)=>{let N=B.optsWithGlobals(),w=await c3(N);await Dp3(w,await Sn(N,w.settings))}),Z.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(D,B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await MC4(D??"get",L.ampURL,L.secrets),process.exit(process.exitCode??0)}),Z.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(D,B)=>{let N=B.optsWithGlobals(),w=await c3(N);await AC4(w.ampURL,w.secrets),process.exit(process.exitCode??0)}),Z.command("keyboard-tester",{hidden:!0}).summary("Keyboard input tester").description("Internal: stream parsed terminal input events as JSONL.").option("--raw","Log raw incoming terminal bytes before parsing").action(async(D)=>{await yT4({raw:D.raw===!0}),process.exit(process.exitCode??0)}),Z.command("live-sync [threadIDOrURL]",{hidden:!0}).summary("Mirror live DTW thread changes into the current checkout").description("Experimental: watch a v2 thread URL or ID and mirror its live working-tree changes into your local checkout, or apply the current snapshot once and exit.").addHelpText("after",["","Examples:"," amp live-sync T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync --apply T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync https://ampcode.com/threads/T-5928a90d-d53b-488f-a829-4e36442142ee"].join(`
|
|
5997
5997
|
`)).option("--apply <threadIDOrURL>","Apply the current DTW thread snapshot once and exit").option("--checkout","Automatically check out the thread commit when it differs").option("--skip-checkout","Skip the startup checkout prompt when commits differ").action(async(D,B,N)=>{if(D&&B.apply)throw new z4("Choose either a positional thread ID/URL or --apply <thread-id>, not both.",1);let w=B.apply??D;if(!w||w.trim().length===0)c5.write(`live-sync watches a v2 thread and mirrors its live changes locally. Use --apply <thread-id> to materialize the current snapshot once and exit.
|
|
5998
5998
|
|
|
5999
5999
|
`),N.outputHelp(),process.exit(0);let L=P9(w)??ZX(w),O=N.optsWithGlobals(),E=await c3(O);I2(N,O);let M=await M7(E,O),A=!1;try{if(B.checkout&&B.skipCheckout)throw new z4("Choose either --checkout or --skip-checkout, not both.",1);if(GH(M.serverStatus))throw l31(M.serverStatus,E.ampURL);let j=_6(M.serverStatus)?M.serverStatus.features:void 0;if(!ox(j,P7.V2))throw new z4("live-sync is not enabled for your user",1);await ES4({ampURL:E.ampURL,threadId:L,configService:M.configService,threadService:M.threadService,apiKey:O.apiKey??process.env.AMP_API_KEY,applyOnce:typeof B.apply==="string",checkoutMode:B.checkout?"always":B.skipCheckout?"never":"prompt",promptForYesNo:wK0}),A=!0}finally{if(await M.asyncDispose(),A)process.exit(0)}});let Q=async(D,B,N)=>{bC({storage:B.settings,secretStorage:B.secrets,workspaceRoot:x0.of(G1.file(process.cwd())),defaultAmpURL:B.ampURL,homeDir:Iq0,userConfigDir:i31});let w={...B,executeMode:!1};await Pq0(w,{...D,openThreadSwitcher:!0},N,J)},Y=Z.command("threads").alias("t").alias("thread").summary("Manage threads").description("Thread management commands. When no subcommand is provided, defaults to listing threads.").option("--include-archived","Include archived threads in the list").action(async(D,B)=>{let N=B.optsWithGlobals(),w=await c3(N);await Xs4(N,w,B)});Y.command("new").alias("n").summary("Create a new thread").description("Create a new thread and print its ID. The thread will be empty. You can set the visibility using the --visibility option.").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").action(async(D,B)=>{let N=B.optsWithGlobals(),w=await c3(N);await Pp3(N,w,B)}),Y.command("continue [threadIDOrURL]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. By default, interactive mode shows a picker. Use --last to continue the last thread for the current mode directly.").option("--last","Continue the last thread for the current mode directly").option("--pick","Pick a thread interactively from a list (DEPRECATED: picker is now the default)").action(async(D,B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);if(B.pick)xZ.write(`${n0.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
|
|
@@ -6027,8 +6027,8 @@ ${E}
|
|
|
6027
6027
|
|
|
6028
6028
|
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.`)}}async function zp3(J){if(J.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof J.execute==="string"){let Z=(await bG0()).trimEnd();return{userInput:J.execute,stdinInput:Z||null}}return{userInput:(await bG0()).trimEnd(),stdinInput:null}}function qp3(J,Z,Q){if(J.streamJson&&!Z)throw new z4("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(J.streamJsonInput&&!Z)throw new z4("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(J.streamJsonInput&&!J.streamJson)throw new z4("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(J.stats&&!Z)throw new z4("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(J.archive&&!Z)throw new z4("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(J.streamJsonInput&&typeof J.execute==="string"&&J.execute.trim()!=="")throw new z4("Do not provide a message argument when using --stream-json-input",1,`Supply messages via stdin JSONL instead: echo '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"your message"},{"type":"image","source":{"type":"base64","media_type":"image/png","data":"..."}}]}}' | amp --execute --stream-json --stream-json-input`);if(Z&&Q===""&&!J.streamJsonInput&&!J.headless)throw new z4("User message must be provided through stdin or as argument when using execute mode",1,`Either pass a message as an argument: amp --execute "your message"
|
|
6029
6029
|
Or pipe via stdin: echo "your message" | amp --execute`)}async function Pq0(J,Z,Q,Y){let X=process.hrtime.bigint(),K=(c,n)=>{let r=Number(process.hrtime.bigint()-n)/1e6,e=GM4();T.info("Startup phase",{phase:c,phaseMs:Math.round(r),sinceMainMs:e===null?void 0:Math.round(e)})},{userInput:V,stdinInput:G}=await zp3(Z),F=!!Z.streamJson||!!Z.streamJsonThinking;qp3({...Z,streamJson:F},J.executeMode,V),I2(Q,Z);let z=process.hrtime.bigint(),q=Boolean(await J.secrets.get("apiKey",J.ampURL)),W=!J.executeMode&&!Z.headless&&q;T.info("Interactive auth startup mode",{deferInteractiveAuth:W,hasAPIKeyAtStartup:q,executeMode:J.executeMode,headless:Boolean(Z.headless)});let H=await M7(J,Z,{deferAuth:W});K("runMainThread:createThreadDependencies",z);let{serverStatus:U}=H;if(!W&&GH(U))throw l31(U,J.ampURL);let D=_6(U)?U:null,B=D?.user.email,N=!!(B&&S2(B));if(!W)await $s4(Q,Z,U);let w=sx(U),L=w?.features??[],O=w?.team??null,E=NG0(Z,w);if(E instanceof Error)C3(E.message);if(D&&!Kh(Z.mode,B))throw new z4(`Agent mode '${Z.mode}' is only available for Amp employees`,1);if(Z.headless){if(process.env.AMP_EXECUTOR!=="1"&&(!B||!S2(B)))throw new z4("Headless executor mode is only available for Amp employees",1);let n=await H.secretStorage.get("apiKey",J.ampURL);if(!n)throw new z4("API key required for headless mode. Please run `amp login` first.",1);let r=typeof Z.headless==="string"&&Z.headless!=="true"?Z.headless:void 0;if(r&&!sJ(r))throw new z4(`Invalid thread ID: ${r}`,1);let e=r?void 0:await Rp3({dependencies:H,visibility:E??void 0}),V0=r??e?.threadId;if(!V0)throw new z4("Failed to resolve headless thread ID",1);let Y0=await bC4(V0);if(Y0.status==="already-running")await H.asyncDispose(),await Tq(),process.exit(0);try{await PC4({ampURL:J.ampURL,apiKey:n,workspaceRoot:process.cwd(),threadId:V0,ownerUserId:e?.ownerUserId,threadVersion:e?.threadVersion,agentMode:e?.agentMode,initialToolDiscovery:Promise.all([H.mcpService.initialized,H.toolboxService.initialized]).then(()=>{return}),configService:H.configService,mcpService:H.mcpService,toolService:H.toolService,skillService:H.skillService,fileSystem:H.fileSystem,pluginService:H.pluginService,pluginPlatform:H.headlessPluginPlatform})}finally{await Y0.release(),await H.asyncDispose()}await Tq(),process.exit(0)}let M=Z.threadId&&sJ(Z.threadId)?Z.threadId:void 0,A=W?await H.serverStatusPromise:U,j=_6(A)&&ox(A.features,P7.NEO_TUI);if((j||Z.neo||!1)&&!J.executeMode&&!Z.takeMeBack){if(Z.neo&&!j&&(!_6(A)||!S2(A.user.email)))throw new z4("--neo is only available for Amp employees",1);let c=await H.secretStorage.get("apiKey",J.ampURL);if(!c)throw new z4("API key required. Please run `amp login` first.",1);let n=fM(H.configService),r=new $I(H.fuzzyServer),e=process.cwd();await N11({ampURL:J.ampURL,apiKey:c,rivetEndpoint:process.env.RIVET_PUBLIC_ENDPOINT??Rq(J.ampURL),configService:H.configService,toolService:H.toolService,skillService:H.skillService,mcpService:H.mcpService,readFileSystemDirectory:({uri:V0})=>nw({fileSystem:H.fileSystem,workspaceRoot:e},V0),completionBuilder:r,listThreads:()=>n.listThreads(),getThreadFromServer:(V0)=>n.getThread(V0),isInternalUser:_6(A)&&S2(A.user.email)},{initialThreadID:M,openThreadPickerOnStart:Z.openThreadSwitcher});return}let _=_6(A)&&ox(A.features,P7.THREAD_ACTORS_TUI);if(J.executeMode&&!Z.takeMeBack&&_&&!F){let c=await H.secretStorage.get("apiKey",J.ampURL);if(!c)throw new z4("API key required. Please run `amp login` first.",1);Sr0(H.mcpService,J.settings);try{let n=await lP4({apiKey:c,ampURL:J.ampURL,workspaceRoot:process.cwd(),dependencies:H,userInput:V,stdinInput:G,stats:!!Z.stats,agentMode:Z.mode,labels:Z.label,initialThreadID:M});if(await rx(n,"execute"),Z.archive)await H.threadService.archive(n,!0),await tx(H.threadService,n)}finally{await H.asyncDispose()}await Tq(),process.exit(0)}if(!J.executeMode&&!Z.headless)H.skillService=Kp3(H.skillService);z=process.hrtime.bigint();let b=await Cq0(H);K("runMainThread:createWorkerDeps",z);let m=J.executeMode?void 0:async(c)=>rx(c,"interactive"),f={threadService:H.threadService,workerDeps:b,createThread:async(c)=>{let n=W?await H.serverStatusPromise:U,r=await VX0(J.settings,process.cwd(),sx(n),E);if(r instanceof Error)C3(r.message);return B51(b,{threadMeta:r?KF(r):void 0,agentMode:c??Z.mode,onFirstAssistantMessage:m})},validateThreadOwnership:async(c,n)=>{if(n?.nonBlockingOwnershipCheck){Qs4(c,H.configService,H.viewerUserIDPromise).catch((r)=>{if(r instanceof z4){if(n.onOwnershipError){n.onOwnershipError(r,c);return}TU(r,c);return}T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:r})});return}try{await Qs4(c,H.configService,H.viewerUserIDPromise)}catch(r){if(r instanceof z4)throw r;T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:r})}},switchThreadVisibility:E,switchThreadAgentMode:Z.mode,onFirstAssistantMessage:m,handleError:TU},v=async()=>{try{return In4(f,Z.threadId,{nonBlockingOwnershipCheck:Z.nonBlockingThreadOwnershipCheck})}catch(c){if(c instanceof z4)throw c;throw await TU(c,Z.threadId),Error("handleError should have called process.exit()")}};if(Z.format==="jsonl")xZ.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
|
|
6030
|
-
`),await Tq(),process.exit(1);let x=(async()=>{if(W){T.info("Skipping initial free tier status fetch until auth is complete");return}try{let c=await H.configService.getLatest(),n=rb(c),r=await A5.getUserFreeTierStatus({},{config:H.configService,signal:AbortSignal.timeout(n)});if(r.ok)return T.info("User free tier status:",r),r.result;return}catch(c){T.error("Failed to fetch free tier status:",c);return}})(),d=!J.executeMode?new y11:null,h,a=null;if(d)h=d,a=(async()=>{let c=W?await H.serverStatusPromise:H.serverStatus;if(GH(c))throw l31(c,J.ampURL);await $s4(Q,Z,c);let n=process.hrtime.bigint(),r=await v();if(K("runMainThread:createThreadPool",n),d.attach(r),V){let e=await k1(r.threadHandles$);if(!e)throw new z4("No active thread is available yet.",1);await e.sendMessage({content:[{type:"text",text:V}]})}})(),a.catch(async(c)=>{let n=c instanceof Error?c:Error(String(c));d.setInitError(n),await TU(c,Z.threadId)});else z=process.hrtime.bigint(),h=await v(),K("runMainThread:createThreadPool",z);let l=Z.notifications!==void 0?Z.notifications:!J.executeMode,t=D!==null&&ox(D.features,P7.TUI_VOICE_NOTIF);if(W)H.serverStatusPromise.then((c)=>{t=_6(c)&&ox(c.features,P7.TUI_VOICE_NOTIF)}).catch((c)=>{T.debug("Failed to resolve TUI voice notification feature flag",{error:c})});z=process.hrtime.bigint();let N0=await H.configService.getLatest();if(K("runMainThread:configService.getLatest",z),z=process.hrtime.bigint(),Vp3({configService:H.configService,threadService:H.threadService,config:N0,useNotificationsForService:l,isTUIVoiceNotifEnabled:()=>t,threadViewStates$:()=>h.threadHandles$.pipe(p4((c)=>{if(!c)return x0.of({});return M5(c.thread$,c.threadViewState$).pipe(A1(([n,r])=>({[n.id]:r})))}))}),K("runMainThread:createCliNotificationService",z),J.executeMode){Sr0(H.mcpService,J.settings);let c={userInput:V,stdinInput:G,dependencies:H,streamJson:F,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isInternalUser:N,agentMode:Z.mode,labels:Z.label},n=await mI4({threadPool:h,...c});if(await rx(n,"execute"),Z.archive)await H.threadService.archive(n,!0),await tx(H.threadService,n);await H.asyncDispose(),process.exit(0)}let o=!1,J0=!1;if(Z.jetbrains||Z.ide){await a40();let c=await sW({jetbrainsOnly:Z.jetbrains});if(c.length===0){if(Z.jetbrains)o=!await H.configService.get("jetbrains.skipInstall")}else if(c.length===1){let n=c[0];if(n)n8.selectConfig(n)}else J0=!0}z=process.hrtime.bigint();let W0=so0("0.0.
|
|
6031
|
-
`);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await ro1({get:async(G)=>{if(G!==tg)return;try{let F=await Vs4(d31,"utf-8");return JSON.parse(F).installationID}catch{return}},set:async(G,F)=>{if(G!==tg)return;await pm3(lr.dirname(d31),{recursive:!0}),await dm3(d31,JSON.stringify({installationID:F},null,2),{mode:384})}},{clientType:"cli",platform:v30()});Vb1(Y);let X=await fX0({...J,workspaceTrust:{current:!0,changes:XR0},getHook:process.env.AMP_URL?(G,F)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return F()}:void 0});if(J.mcpConfig){let G=await pS4(J.mcpConfig);X=dS4(X,G)}let K=lr.dirname(X.getSettingsFilePath());WH4(ev,K),X=hf1(X);let V=await X.get("url","admin")??await X.get("url","global");if(!V)V=r7;if(T.info("Resolved Amp URL",{ampURL:V,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!KB(V))T.info("Targeting custom Amp server",{ampURL:V});return{executeMode:Z,isTTY:Q,ampURL:V,settings:X,secrets:AK0(await Sn(J,X))}}function Wp3(J){let Z={};for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(Y?.startsWith("--")){let K=Y.slice(2).replace(/-([a-z])/g,(G,F)=>F.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[K]=V,Q++}}return Z}function Hp3(J,Z){let Q=J.includes("--headless")||J.some((X)=>X.startsWith("--headless=")),Y=lr.resolve(Z.logFile??process.env.AMP_LOG_FILE??(Q?lm3:Hn));return{logLevel:Z.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:Y}}async function Up3(){VM4();let J=Wp3(process.argv),Z=Hp3(process.argv,J),Q=NI4(Z),Y=process.argv.includes("--no-color"),X=process.argv.includes("--color"),K=process.stdout.isTTY&&process.stderr.isTTY;if(Y||!X&&!K)n0.level=0;if(am3(T),T.info("Starting Amp CLI.",{version:"0.0.
|
|
6030
|
+
`),await Tq(),process.exit(1);let x=(async()=>{if(W){T.info("Skipping initial free tier status fetch until auth is complete");return}try{let c=await H.configService.getLatest(),n=rb(c),r=await A5.getUserFreeTierStatus({},{config:H.configService,signal:AbortSignal.timeout(n)});if(r.ok)return T.info("User free tier status:",r),r.result;return}catch(c){T.error("Failed to fetch free tier status:",c);return}})(),d=!J.executeMode?new y11:null,h,a=null;if(d)h=d,a=(async()=>{let c=W?await H.serverStatusPromise:H.serverStatus;if(GH(c))throw l31(c,J.ampURL);await $s4(Q,Z,c);let n=process.hrtime.bigint(),r=await v();if(K("runMainThread:createThreadPool",n),d.attach(r),V){let e=await k1(r.threadHandles$);if(!e)throw new z4("No active thread is available yet.",1);await e.sendMessage({content:[{type:"text",text:V}]})}})(),a.catch(async(c)=>{let n=c instanceof Error?c:Error(String(c));d.setInitError(n),await TU(c,Z.threadId)});else z=process.hrtime.bigint(),h=await v(),K("runMainThread:createThreadPool",z);let l=Z.notifications!==void 0?Z.notifications:!J.executeMode,t=D!==null&&ox(D.features,P7.TUI_VOICE_NOTIF);if(W)H.serverStatusPromise.then((c)=>{t=_6(c)&&ox(c.features,P7.TUI_VOICE_NOTIF)}).catch((c)=>{T.debug("Failed to resolve TUI voice notification feature flag",{error:c})});z=process.hrtime.bigint();let N0=await H.configService.getLatest();if(K("runMainThread:configService.getLatest",z),z=process.hrtime.bigint(),Vp3({configService:H.configService,threadService:H.threadService,config:N0,useNotificationsForService:l,isTUIVoiceNotifEnabled:()=>t,threadViewStates$:()=>h.threadHandles$.pipe(p4((c)=>{if(!c)return x0.of({});return M5(c.thread$,c.threadViewState$).pipe(A1(([n,r])=>({[n.id]:r})))}))}),K("runMainThread:createCliNotificationService",z),J.executeMode){Sr0(H.mcpService,J.settings);let c={userInput:V,stdinInput:G,dependencies:H,streamJson:F,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isInternalUser:N,agentMode:Z.mode,labels:Z.label},n=await mI4({threadPool:h,...c});if(await rx(n,"execute"),Z.archive)await H.threadService.archive(n,!0),await tx(H.threadService,n);await H.asyncDispose(),process.exit(0)}let o=!1,J0=!1;if(Z.jetbrains||Z.ide){await a40();let c=await sW({jetbrainsOnly:Z.jetbrains});if(c.length===0){if(Z.jetbrains)o=!await H.configService.get("jetbrains.skipInstall")}else if(c.length===1){let n=c[0];if(n)n8.selectConfig(n)}else J0=!0}z=process.hrtime.bigint();let W0=so0("0.0.1776920220-g98800a",H.settingsStorage,{startDelayMs:3000});K("runMainThread:createUpdateService",z),z=process.hrtime.bigint();let U0=new kr0(H.mcpService,J.settings.getWorkspaceRootPath());if(K("runMainThread:createMcpTrustHandler",z),V&&J.executeMode){let c=await k1(h.threadHandles$);if(!c)throw new z4("No active thread is available yet.",1);await c.sendMessage({content:[{type:"text",text:V}]})}z=process.hrtime.bigint();let Z0=await Gy();K("runMainThread:loadSessionState",z),T.info("Loaded session state:",Z0);let K0={...Z0,launchCount:Z0.launchCount+1};sK((c)=>({...c,launchCount:c.launchCount+1}));try{if(z=process.hrtime.bigint(),await Rp4({history:new Mn,fuzzyServer:H.fuzzyServer,settingsStorage:H.settingsStorage,threadService:H.threadService,skillService:H.skillService,configService:H.configService,secretStorage:H.secretStorage,internalAPIClient:A5,threadPool:h,createSystemPromptDeps:async()=>Fs4(H),ideClient:n8,mcpService:H.mcpService,toolboxService:H.toolboxService,mcpTrustHandler:U0,updateService:W0,pluginPlatform:H.pluginPlatform,pluginService:H.pluginService},{initialServerStatus:H.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:H.hasAPIKeyAtStartup,ampURL:J.ampURL,startupThreadID:M,showJetBrainsInstaller:o,showIdePickerHint:J0,openThreadSwitcher:Z.openThreadSwitcher,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:im3,logFile:{path:Y},sessionState:K0,freeTierStatusPromise:x,workspace:O??null,features:L,isInternalUser:N,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-04-23T05:00:45.982Z"},(c)=>new m11({...c,threadPool:c.threadPool},(n)=>new U51({...n,threadState:n.threadState}))),K("runMainThread:mountApp-returned",z),a)await a}finally{await h.dispose().catch((c)=>{T.error("Failed to dispose thread pool during shutdown",c)})}await H.asyncDispose(),K("runMainThread:dependencies.asyncDispose",X),process.exit(0)}async function c3(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)xZ.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
|
|
6031
|
+
`);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await ro1({get:async(G)=>{if(G!==tg)return;try{let F=await Vs4(d31,"utf-8");return JSON.parse(F).installationID}catch{return}},set:async(G,F)=>{if(G!==tg)return;await pm3(lr.dirname(d31),{recursive:!0}),await dm3(d31,JSON.stringify({installationID:F},null,2),{mode:384})}},{clientType:"cli",platform:v30()});Vb1(Y);let X=await fX0({...J,workspaceTrust:{current:!0,changes:XR0},getHook:process.env.AMP_URL?(G,F)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return F()}:void 0});if(J.mcpConfig){let G=await pS4(J.mcpConfig);X=dS4(X,G)}let K=lr.dirname(X.getSettingsFilePath());WH4(ev,K),X=hf1(X);let V=await X.get("url","admin")??await X.get("url","global");if(!V)V=r7;if(T.info("Resolved Amp URL",{ampURL:V,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!KB(V))T.info("Targeting custom Amp server",{ampURL:V});return{executeMode:Z,isTTY:Q,ampURL:V,settings:X,secrets:AK0(await Sn(J,X))}}function Wp3(J){let Z={};for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(Y?.startsWith("--")){let K=Y.slice(2).replace(/-([a-z])/g,(G,F)=>F.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[K]=V,Q++}}return Z}function Hp3(J,Z){let Q=J.includes("--headless")||J.some((X)=>X.startsWith("--headless=")),Y=lr.resolve(Z.logFile??process.env.AMP_LOG_FILE??(Q?lm3:Hn));return{logLevel:Z.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:Y}}async function Up3(){VM4();let J=Wp3(process.argv),Z=Hp3(process.argv,J),Q=NI4(Z),Y=process.argv.includes("--no-color"),X=process.argv.includes("--color"),K=process.stdout.isTTY&&process.stderr.isTTY;if(Y||!X&&!K)n0.level=0;if(am3(T),T.info("Starting Amp CLI.",{version:"0.0.1776920220-g98800a",buildTimestamp:"2026-04-23T05:00:45.982Z"}),process.platform==="win32"&&QR())f_4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new z4(J$.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Fp3(Q).parseAsync(process.argv)}zH4().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Up3().catch(TU)});async function Dp3(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),c5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
|
|
6032
6032
|
`);else if(!KB(J.ampURL))c5.write(`Logging in to ${new URL(J.ampURL).hostname}
|
|
6033
6033
|
`);let Y=process.env.AMP_API_KEY;if(Y)c5.write(`API key found in environment variable, storing...
|
|
6034
6034
|
`),await Z.set("apiKey",Y,J.ampURL),c5.write(`API key successfully stored.
|