@sourcegraph/amp 0.0.1754092897-g40aeac → 0.0.1754107862-ga95907

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +3 -3
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -4751,7 +4751,7 @@ allow ${z}${Z?` ${Z}`:""}`}let J={stdin:process.stdin,stdout:process.stdout,stde
4751
4751
  ${F}`;if(B==="pnpm"&&F.includes("Unable to find the global bin directory"))H+=`
4752
4752
 
4753
4753
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
4754
- npm install -g @sourcegraph/amp`;Z(new Error(H))}},error:(U)=>{if(!X)X=!0,Z(new Error(`Failed to spawn ${B}: ${U.message}`))},complete:()=>{if(!X)X=!0,z()}})})}var _g1=jg1.join(md0||jg1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id"),v82=r2.union([r2.object({command:r2.string(),args:r2.array(r2.string()).optional(),env:r2.record(r2.string(),r2.string()).optional()}).strict(),r2.object({url:r2.string()}).strict()]),k82=r2.record(r2.string(),v82);async function Pg1(A){try{await P82(jg1.dirname(_g1),{recursive:!0}),await $82(_g1,A,"utf-8")}catch(Q){j1.debug("Failed to save last thread ID",Q)}}async function f82(){try{return(await S82(_g1,"utf-8")).trim()}catch(A){return null}}async function y82(A){let Q;try{Q=JSON.parse(A)}catch(B){throw new Error(`Failed to parse --mcp-config as JSON: ${B instanceof Error?B.message:String(B)}`)}try{return k82.parse(Q)}catch(B){if(B instanceof r2.ZodError){let J=B.issues.map((D)=>`${D.path.join(".")}: ${D.message}`).join(", ");throw new Error(`Invalid MCP server configuration: ${J}`)}throw new Error(`Failed to validate MCP server configuration: ${String(B)}`)}}function b82(A,Q){return{...A,async get(B){if(B==="mcpServers"){let J=await A.get(B)||{},D={};if(typeof J==="object")for(let[z,Z]of Object.entries(J))D[z]={...Z,_target:"global"};for(let[z,Z]of Object.entries(Q))D[z]={...Z,_target:"workspace"};return D}return A.get(B)},async keys(){let B=await A.keys();if(!B.includes("mcpServers"))B.push("mcpServers");return B},[Symbol.dispose](){A[Symbol.dispose]()}}}async function g82(A){let Q=await yQ(`/api/threads/${A}`);if(!Q.ok){let B=await Q.text();if(Q.status===404||B.includes("not found"))throw new JD(mG.threadNotFound(A));throw new JD(`Failed to load thread ${A}`,1,`Use 'amp threads share ${A} --support' to share this with the Amp team if this persists.`)}return await Q.json()}var SDA=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,jDA=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??pM,description:`Custom settings file path (overrides the default location ${pM})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(j1).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:"Set log file location"},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:SDA,description:(A)=>A?"Enable JetBrains integration. Requires the JetBrains MCP plugin to be installed and you must start Amp in the same directory as your JetBrains project. When enabled, Amp automatically includes your open JetBrains file and text selection with every message, just like it does in VS Code.":"Disable JetBrains integration.",hidden:!0},{name:"interactive",long:"interactive",type:"flag",description:(A)=>A?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"}],_DA=(A)=>("deprecated"in A)&&A.deprecated===!0,x82=(A)=>("hidden"in A)&&A.hidden===!0,h82=(A)=>("default"in A),m82=(A)=>("default"in A)?A.default:void 0;function u82(A,Q){let B=Q.args[0],J=Q.commands.map((z)=>z.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let z=J.filter((G)=>B.includes(G)||G.includes(B)),Z="Run amp --help for a list of available commands.";if(z.length>0)Z=`Did you mean: ${z.join(", ")}? Or run amp --help for all commands.`;throw new JD(mG.unknownCommand(B),1,Z)}}async function Y$(A,Q){ap1("0.0.1754092897-g40aeac");let B=Bk1(Cc()),J=oJ1({storage:A.settings,secretStorage:B,workspaceRoots:UA.of([c6.file(process.cwd())]),defaultAmpURL:A.ampURL,defaultCacheDirectory:tv1}),D=await O6($2);j1.debug("Global configuration initialized",{hasCacheDirectory:!!D.settings.cacheDirectory,settingsKeys:Object.keys(D.settings)});let z=await of(ev()),Z=an1({configService:J,toolService:z});try{await Z.initialized}catch(N){j1.warn("Failed to wait for MCP servers, continuing anyway:",N)}if(Q.dangerouslyAllowAll)D.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(D.settings["jetbrains.enabled"]=!0,Ea.subscribe((V)=>{j1.info("jetbrains-status",V)}),await sE(),!await al1())if(SDA)kB("JetBrains integration failed. Try again with `amp --no-jetbrains` or see setup: https://ampcode.com/manual#jetbrains");else kB("Cannot connect to JetBrains IDE. Check setup: https://ampcode.com/manual#jetbrains")}let G=D.settings["experimental.reviewTool"]??!1,K=D.settings["experimental.tools"]??[];A$1(z,!1,G,K);let X,Y;if(!A.executeMode)X=new gf1(D.settings,process.cwd()),await X.start(),Y=v4A(X,process.cwd());else X=new class{async start(){}async query(){return[]}dispose(){}},Y={[Symbol.dispose]:()=>{}};if(!await B.get("apiKey",A.ampURL)){if(B4.write(`No API key found. Starting login flow...
4754
+ npm install -g @sourcegraph/amp`;Z(new Error(H))}},error:(U)=>{if(!X)X=!0,Z(new Error(`Failed to spawn ${B}: ${U.message}`))},complete:()=>{if(!X)X=!0,z()}})})}var _g1=jg1.join(md0||jg1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id"),v82=r2.union([r2.object({command:r2.string(),args:r2.array(r2.string()).optional(),env:r2.record(r2.string(),r2.string()).optional()}).strict(),r2.object({url:r2.string()}).strict()]),k82=r2.record(r2.string(),v82);async function Pg1(A){try{await P82(jg1.dirname(_g1),{recursive:!0}),await $82(_g1,A,"utf-8")}catch(Q){j1.debug("Failed to save last thread ID",Q)}}async function f82(){try{return(await S82(_g1,"utf-8")).trim()}catch(A){return null}}async function y82(A){let Q;try{Q=JSON.parse(A)}catch(B){throw new Error(`Failed to parse --mcp-config as JSON: ${B instanceof Error?B.message:String(B)}`)}try{return k82.parse(Q)}catch(B){if(B instanceof r2.ZodError){let J=B.issues.map((D)=>`${D.path.join(".")}: ${D.message}`).join(", ");throw new Error(`Invalid MCP server configuration: ${J}`)}throw new Error(`Failed to validate MCP server configuration: ${String(B)}`)}}function b82(A,Q){return{...A,async get(B){if(B==="mcpServers"){let J=await A.get(B)||{},D={};if(typeof J==="object")for(let[z,Z]of Object.entries(J))D[z]={...Z,_target:"global"};for(let[z,Z]of Object.entries(Q))D[z]={...Z,_target:"workspace"};return D}return A.get(B)},async keys(){let B=await A.keys();if(!B.includes("mcpServers"))B.push("mcpServers");return B},[Symbol.dispose](){A[Symbol.dispose]()}}}async function g82(A){let Q=await yQ(`/api/threads/${A}`);if(!Q.ok){let B=await Q.text();if(Q.status===404||B.includes("not found"))throw new JD(mG.threadNotFound(A));throw new JD(`Failed to load thread ${A}`,1,`Use 'amp threads share ${A} --support' to share this with the Amp team if this persists.`)}return await Q.json()}var SDA=process.env.TERMINAL_EMULATOR?.includes("JetBrains")??!1,jDA=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??pM,description:`Custom settings file path (overrides the default location ${pM})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(j1).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:"Set log file location"},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:SDA,description:(A)=>A?"Enable JetBrains integration. Requires the JetBrains MCP plugin to be installed and you must start Amp in the same directory as your JetBrains project. When enabled, Amp automatically includes your open JetBrains file and text selection with every message, just like it does in VS Code.":"Disable JetBrains integration.",hidden:!0},{name:"interactive",long:"interactive",type:"flag",description:(A)=>A?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"}],_DA=(A)=>("deprecated"in A)&&A.deprecated===!0,x82=(A)=>("hidden"in A)&&A.hidden===!0,h82=(A)=>("default"in A),m82=(A)=>("default"in A)?A.default:void 0;function u82(A,Q){let B=Q.args[0],J=Q.commands.map((z)=>z.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let z=J.filter((G)=>B.includes(G)||G.includes(B)),Z="Run amp --help for a list of available commands.";if(z.length>0)Z=`Did you mean: ${z.join(", ")}? Or run amp --help for all commands.`;throw new JD(mG.unknownCommand(B),1,Z)}}async function Y$(A,Q){ap1("0.0.1754107862-ga95907");let B=Bk1(Cc()),J=oJ1({storage:A.settings,secretStorage:B,workspaceRoots:UA.of([c6.file(process.cwd())]),defaultAmpURL:A.ampURL,defaultCacheDirectory:tv1}),D=await O6($2);j1.debug("Global configuration initialized",{hasCacheDirectory:!!D.settings.cacheDirectory,settingsKeys:Object.keys(D.settings)});let z=await of(ev()),Z=an1({configService:J,toolService:z});try{await Z.initialized}catch(N){j1.warn("Failed to wait for MCP servers, continuing anyway:",N)}if(Q.dangerouslyAllowAll)D.settings.dangerouslyAllowAll=!0;if(Q.jetbrains){if(D.settings["jetbrains.enabled"]=!0,Ea.subscribe((V)=>{j1.info("jetbrains-status",V)}),await sE(),!await al1())if(SDA)kB("JetBrains integration failed. Try again with `amp --no-jetbrains` or see setup: https://ampcode.com/manual#jetbrains");else kB("Cannot connect to JetBrains IDE. Check setup: https://ampcode.com/manual#jetbrains")}let G=D.settings["experimental.reviewTool"]??!1,K=D.settings["experimental.tools"]??[];A$1(z,!1,G,K);let X,Y;if(!A.executeMode)X=new gf1(D.settings,process.cwd()),await X.start(),Y=v4A(X,process.cwd());else X=new class{async start(){}async query(){return[]}dispose(){}},Y={[Symbol.dispose]:()=>{}};if(!await B.get("apiKey",A.ampURL)){if(B4.write(`No API key found. Starting login flow...
4755
4755
  `),!await p82(A,B))process.exit(1)}let U=Ho1(),F=new wU1(U),H=new FU1(U),E=new nH1(F),w=Q.notifications!==void 0?Q.notifications:!A.executeMode,I=Yd0({playNotificationSound:async(N)=>{if(w){if(Xd0(N),!g5A()&&D.settings["notifications.system.enabled"]!==!1){if(N==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(N==="requires-user-input")process.stdout.write("\x1B]777;notify;Amp;Waiting for approval\x1B\\")}}},windowFocused:()=>Promise.resolve(!1),threadService:F});j1.info("Starting Amp background services");let M=l50({threadService:F,threadHistoryService:H,isExtensionDevelopment:!1}),W={configService:J,toolService:z,mcpService:Z,threadService:F,threadHistoryService:H,threadSummaryService:E,threadSyncService:M,threadStorage:U,secretStorage:B,settingsStorage:A.settings,fileWatcher:Y,fuzzyServer:X,notificationService:I};return{...W,async dispose(){await W.mcpService.dispose(),W.configService.unsubscribe(),W.toolService.dispose(),W.fileWatcher[Symbol.dispose](),W.fuzzyServer.dispose(),W.threadSyncService.dispose(),W.settingsStorage[Symbol.dispose]()}}}async function p82(A,Q){if(!A.executeMode){if(await B51("Would you like to log in to Amp?",["(y)es","(n)o"])!="y")return B4.write(`Login cancelled. Run the command again to retry.
4756
4756
  `),!1}return await $DA(A,Q)}async function $DA(A,Q){let B=_82(32).toString("hex"),J=await Y5A(A.ampURL,B);B4.write(`If your browser doesn't open automatically, visit:
4757
4757
 
@@ -4765,7 +4765,7 @@ ${U0.blue.bold(J)}
4765
4765
  Login successful! You can now use the Amp CLI.
4766
4766
  `),!0}catch(D){return Q4.write(`
4767
4767
  Login failed: ${D instanceof Error?D.message:String(D)}
4768
- `),!1}}function c82(){let A=new Wp().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, team)").configureOutput({writeErr:()=>{}});A.exitOverride((K)=>{if(K.code==="commander.help"||K.code==="commander.version"||K.exitCode===0)dp(),process.exit(0);let X=K.originalError??K;lp(X)}),A.option("-V, --version","output the version number",()=>{B4.write(`0.0.1754092897-g40aeac (released 2025-08-02T00:06:27.342Z)
4768
+ `),!1}}function c82(){let A=new Wp().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, team)").configureOutput({writeErr:()=>{}});A.exitOverride((K)=>{if(K.code==="commander.help"||K.code==="commander.version"||K.exitCode===0)dp(),process.exit(0);let X=K.originalError??K;lp(X)}),A.option("-V, --version","output the version number",()=>{B4.write(`0.0.1754107862-ga95907 (released 2025-08-02T04:15:45.945Z)
4769
4769
  `),process.exit(0)}),A.addHelpText("after",Z5A()),A.configureHelp({formatHelp:G5A}),A.command("logout").description("Log out by removing stored API key").action(async(K,X)=>{let Y=X.optsWithGlobals(),U=await sX(Y);await r82(U)}),A.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(K,X)=>{let Y=X.optsWithGlobals(),U=await sX(Y);await a82(U)}),N5A(A);let Q=A.command("threads").description("Thread management commands").action(async(K,X)=>{let Y=X.optsWithGlobals(),U=await sX(Y);await PDA(Y,U)});Q.command("new").description("Create a new thread and print its ID").option("--visibility <visibility>","Set thread visibility (private, public, team)").action(async(K,X)=>{let Y=X.optsWithGlobals(),U=await sX(Y);await Q92(Y,U)}),Q.command("continue [threadId]").description("Continue an existing thread (uses last used thread if no ID provided)").action(async(K,X,Y)=>{let U=Y.optsWithGlobals(),F=await sX(U);await A92(U,F,K)}),Q.command("fork [threadId]").description("Create a new thread by forking an existing one and print its ID (uses last used thread if no ID provided)").action(async(K,X,Y)=>{let U=Y.optsWithGlobals(),F=await sX(U);await e82(U,F,K)}),Q.command("list").description("List all your threads with their titles and share status").action(async(K,X)=>{let Y=X.optsWithGlobals(),U=await sX(Y);await PDA(Y,U)}),Q.command("share <threadId>").description("Change thread visibility or share with support").option("--visibility <visibility>","Set thread visibility (private, public, team)").option("--support","Share thread with Amp support for debugging").action(async(K,X,Y)=>{let U=Y.optsWithGlobals(),F=await sX(U);await t82(U,F,K,X.support)}),Q.command("compact <threadId>").description("Compact a thread by creating a summary to reduce token usage").action(async(K,X,Y)=>{let U=Y.optsWithGlobals(),F=await sX(U);await o82(U,F,K)}),A.command("tools").description("Tool management commands").command("show").description("Show available tools").action(async(K,X)=>{let Y=X.optsWithGlobals(),U=await sX(Y);await i82(Y,U)});function J(K,X,Y){let F=typeof K.description==="string"?K.description:Y===void 0?K.description(!0):K.description(Y),H=new q$1(X,F),E=m82(K);if(E)H.default(E);return H.hidden=x82(K)||_DA(K),H}for(let K of jDA)switch(K.type){case"flag":{A.addOption(J(K,`--${K.long}`)),A.addOption(J(K,`--no-${K.long}`,!1));break}case"switch":{A.addOption(J(K,`--${K.long}`,!0));break}default:{A.addOption(J(K,`--${K.long} <value>`));break}}let D=new q$1("-x, --execute [message]","Use execute mode, optionally with user message. In execute mode, agent will execute provided prompt (either as argument, or via stdin). Only last assistant message is printed. Enabled automatically when redirecting stdout.").default(!1);A.addOption(D),A.action(async(K,X)=>{let Y=K,U=await sX(Y);if(Object.keys(Y).forEach((F)=>{if(F==="format"&&K.format==="jsonl"){Q4.write(U0.yellow('jsonl format is deprecated. Version "0.0.1753194394-g45962a" is required to use jsonl format. We recommend disabling auto-updates with `"amp.updates.autoUpdate.enabled": false` when using the pinned version.\n'));return}let H=jDA.find((E)=>E.name===F);if(H&&_DA(H)&&!h82(H))Q4.write(U0.yellow(`Warning: '--${F}' flag is deprecated
4770
4770
  `))}),X.args.length>0)u82(U,X);await vDA(U,Y)});let z=new Wp("doctor").description("Generate a support bundle for troubleshooting").option("--output-dir <path>","Directory to save the support bundle",process.cwd()).option("--include-full-logs","Include full log history",!1).allowUnknownOption(!1).action(async(K)=>{await n82(K.outputDir,K.includeFullLogs)});A.addCommand(z);let Z=new Wp("update").description("Update Amp CLI to the latest version").option("--version <version>","Update to a specific version").allowUnknownOption(!1).action(async(K)=>{await s82(K.version)});A.addCommand(Z);let G=new Wp("fuzzy-server").description("Internal fuzzy server").action(()=>{new rf1().start()});return A.addCommand(G),A}async function vDA(A,Q){let B=process.stdin,J=A51(Q);if(J instanceof Error)kB(J.message);let D,z=null;if(typeof Q.execute==="string"){D=Q.execute;let F=(await ef1()).trimEnd();if(F)z=F}else D=(await ef1()).trimEnd();if(A.executeMode&&D==="")throw new JD("User message must be provided through stdin or as argument when using execute mode",1,`Either pass a message as an argument: amp -x "your message"
4771
4771
  Or pipe via stdin: echo "your message" | amp -x`);if(D!==""&&!A.executeMode&&typeof Q.execute!=="string")B=await O5A();let Z=await Y$(A,Q),G=_Z();if(!1)try{}catch(F){}else if(Q.threadId){if(!jL(Q.threadId))throw new JD(mG.invalidThreadId);G=Q.threadId;try{let F=await g82(G);Z.threadStorage.set(G,F)}catch(F){if(F instanceof JD)throw F;lp(F,G)}}let K=Z.threadService.observe(G).subscribe(async(F)=>{if(_J(F,"assistant"))await Pg1(G),K.unsubscribe()});if(!(await O6(Z.threadSyncService.threadSyncInfo([G])))[G])throw new Error(`Thread ${G} not found`);if(J)await Z.threadSyncService.updateThreadMeta(G,Q51(J));if(Q.format==="jsonl")Q4.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
@@ -4791,7 +4791,7 @@ Or pipe via stdin: echo "your message" | amp -x`);if(D!==""&&!A.executeMode&&typ
4791
4791
  `);process.exit(0)}async function s82(A){try{if(A)Q4.write(U0.blue(`Updating to version ${A}...
4792
4792
  `)),await yb1(A),Q4.write(U0.green(`✓ Successfully updated to version ${A}
4793
4793
  `));else{Q4.write(U0.blue(`Checking for updates...
4794
- `));let Q=await rr("0.0.1754092897-g40aeac");if(!Q.hasUpdate)Q4.write(U0.green(`✓ Amp CLI is already up to date.
4794
+ `));let Q=await rr("0.0.1754107862-ga95907");if(!Q.hasUpdate)Q4.write(U0.green(`✓ Amp CLI is already up to date.
4795
4795
  `)),process.exit(0);Q4.write(U0.blue(`Updating to version ${Q.latestVersion}...
4796
4796
  `)),await yb1(Q.latestVersion),Q4.write(U0.green(`✓ Successfully updated to version ${Q.latestVersion}
4797
4797
  `))}process.exit(0)}catch(Q){kB(Q instanceof Error?Q.message:String(Q))}}async function n82(A,Q){try{Q4.write(U0.green("Generating Amp support bundle...")+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1754092897-g40aeac",
3
+ "version": "0.0.1754107862-ga95907",
4
4
  "description": "CLI for Amp, an agentic coding tool in research preview from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {