@react-grab/cli 0.1.12 → 0.1.13

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 (3) hide show
  1. package/dist/cli.cjs +176 -90
  2. package/dist/cli.js +176 -90
  3. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -308,7 +308,8 @@ var AGENT_PACKAGES = [
308
308
  "@react-grab/codex",
309
309
  "@react-grab/gemini",
310
310
  "@react-grab/amp",
311
- "@react-grab/ami"
311
+ "@react-grab/ami",
312
+ "@react-grab/mcp"
312
313
  ];
313
314
  var detectUnsupportedFramework = (projectRoot) => {
314
315
  const packageJsonPath = path.join(projectRoot, "package.json");
@@ -855,6 +856,13 @@ var AGENT_NAMES = {
855
856
  ami: "Ami",
856
857
  droid: "Droid"
857
858
  };
859
+ var getAgentDisplayName = (agent) => {
860
+ if (agent === "mcp") return "MCP";
861
+ if (agent in AGENT_NAMES) {
862
+ return AGENT_NAMES[agent];
863
+ }
864
+ return agent;
865
+ };
858
866
  var NEXT_APP_ROUTER_SCRIPT = `{process.env.NODE_ENV === "development" && (
859
867
  <Script
860
868
  src="//unpkg.com/react-grab/dist/index.global.js"
@@ -1608,6 +1616,14 @@ var previewPackageJsonTransform = (projectRoot, agent, installedAgents, packageM
1608
1616
  noChanges: true
1609
1617
  };
1610
1618
  }
1619
+ if (agent === "mcp") {
1620
+ return {
1621
+ success: true,
1622
+ filePath: "",
1623
+ message: "MCP does not use package.json dev script",
1624
+ noChanges: true
1625
+ };
1626
+ }
1611
1627
  const packageJsonPath = path.join(projectRoot, "package.json");
1612
1628
  if (!fs.existsSync(packageJsonPath)) {
1613
1629
  return {
@@ -2169,9 +2185,9 @@ var previewCdnTransform = (projectRoot, framework, nextRouterType, targetCdnDoma
2169
2185
  };
2170
2186
 
2171
2187
  // src/commands/add.ts
2172
- var VERSION = "0.1.12";
2188
+ var VERSION = "0.1.13";
2173
2189
  var formatInstalledAgentNames = (agents) => agents.map((agent) => AGENT_NAMES[agent] || agent).join(", ");
2174
- var add = new commander.Command().name("add").alias("install").description("add an agent integration").argument("[agent]", `agent to add (${AGENTS.join(", ")})`).option("-y, --yes", "skip confirmation prompts", false).option(
2190
+ var add = new commander.Command().name("add").alias("install").description("connect React Grab to your agent").argument("[agent]", `agent to add (${AGENTS.join(", ")})`).option("-y, --yes", "skip confirmation prompts", false).option(
2175
2191
  "-c, --cwd <cwd>",
2176
2192
  "working directory (defaults to current directory)",
2177
2193
  process.cwd()
@@ -2198,9 +2214,10 @@ var add = new commander.Command().name("add").alias("install").description("add
2198
2214
  const availableAgents = AGENTS.filter(
2199
2215
  (agent) => !projectInfo.installedAgents.includes(agent)
2200
2216
  );
2201
- if (availableAgents.length === 0) {
2217
+ if (availableAgents.length === 0 && isNonInteractive && !agentArg) {
2202
2218
  logger.break();
2203
- logger.success("All agent integrations are already installed.");
2219
+ logger.success("All legacy agents are already installed.");
2220
+ logger.log("Run without -y to add MCP.");
2204
2221
  logger.break();
2205
2222
  process.exit(0);
2206
2223
  }
@@ -2234,11 +2251,11 @@ var add = new commander.Command().name("add").alias("install").description("add
2234
2251
  message: "How would you like to proceed?",
2235
2252
  choices: [
2236
2253
  {
2237
- title: `Replace with ${AGENT_NAMES[agentIntegration]}`,
2254
+ title: `Replace with ${getAgentDisplayName(agentIntegration)}`,
2238
2255
  value: "replace"
2239
2256
  },
2240
2257
  {
2241
- title: `Add ${AGENT_NAMES[agentIntegration]} alongside existing`,
2258
+ title: `Add ${getAgentDisplayName(agentIntegration)} alongside existing`,
2242
2259
  value: "add"
2243
2260
  },
2244
2261
  { title: "Cancel", value: "cancel" }
@@ -2279,50 +2296,55 @@ var add = new commander.Command().name("add").alias("install").description("add
2279
2296
  );
2280
2297
  logger.log("Restart your agents to activate.");
2281
2298
  logger.break();
2282
- process.exit(0);
2283
- }
2284
- const { agent } = await prompts({
2285
- type: "select",
2286
- name: "agent",
2287
- message: `Which ${highlighter.info("agent integration")} would you like to add?`,
2288
- choices: availableAgents.map((availableAgent) => ({
2289
- title: AGENT_NAMES[availableAgent],
2290
- value: availableAgent
2291
- }))
2292
- });
2293
- if (!agent) {
2294
- logger.break();
2295
- process.exit(1);
2296
- }
2297
- agentIntegration = agent;
2298
- if (projectInfo.installedAgents.length > 0) {
2299
- const installedNames = formatInstalledAgentNames(
2300
- projectInfo.installedAgents
2301
- );
2302
- const { action } = await prompts({
2299
+ agentIntegration = "mcp";
2300
+ projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"];
2301
+ } else {
2302
+ const { agent } = await prompts({
2303
2303
  type: "select",
2304
- name: "action",
2305
- message: "How would you like to proceed?",
2304
+ name: "agent",
2305
+ message: `Which ${highlighter.info("agent")} would you like to connect?`,
2306
2306
  choices: [
2307
- {
2308
- title: `Replace ${installedNames} with ${AGENT_NAMES[agentIntegration]}`,
2309
- value: "replace"
2310
- },
2311
- {
2312
- title: `Add ${AGENT_NAMES[agentIntegration]} alongside existing`,
2313
- value: "add"
2314
- },
2315
- { title: "Cancel", value: "cancel" }
2307
+ ...availableAgents.map((availableAgent) => ({
2308
+ title: AGENT_NAMES[availableAgent],
2309
+ value: availableAgent
2310
+ })),
2311
+ { title: "Skip", value: "skip" }
2316
2312
  ]
2317
2313
  });
2318
- if (!action || action === "cancel") {
2319
- logger.break();
2320
- logger.log("Changes cancelled.");
2314
+ if (!agent || agent === "skip") {
2321
2315
  logger.break();
2322
2316
  process.exit(0);
2323
2317
  }
2324
- if (action === "replace") {
2325
- agentsToRemove = [...projectInfo.installedAgents];
2318
+ agentIntegration = agent;
2319
+ if (projectInfo.installedAgents.length > 0) {
2320
+ const installedNames = formatInstalledAgentNames(
2321
+ projectInfo.installedAgents
2322
+ );
2323
+ const { action } = await prompts({
2324
+ type: "select",
2325
+ name: "action",
2326
+ message: "How would you like to proceed?",
2327
+ choices: [
2328
+ {
2329
+ title: `Replace ${installedNames} with ${getAgentDisplayName(agentIntegration)}`,
2330
+ value: "replace"
2331
+ },
2332
+ {
2333
+ title: `Add ${getAgentDisplayName(agentIntegration)} alongside existing`,
2334
+ value: "add"
2335
+ },
2336
+ { title: "Cancel", value: "cancel" }
2337
+ ]
2338
+ });
2339
+ if (!action || action === "cancel") {
2340
+ logger.break();
2341
+ logger.log("Changes cancelled.");
2342
+ logger.break();
2343
+ process.exit(0);
2344
+ }
2345
+ if (action === "replace") {
2346
+ agentsToRemove = [...projectInfo.installedAgents];
2347
+ }
2326
2348
  }
2327
2349
  }
2328
2350
  } else {
@@ -2399,7 +2421,7 @@ var add = new commander.Command().name("add").alias("install").description("add
2399
2421
  );
2400
2422
  }
2401
2423
  const addingSpinner = spinner(
2402
- `Adding ${AGENT_NAMES[agentIntegration]}.`
2424
+ `Adding ${getAgentDisplayName(agentIntegration)}.`
2403
2425
  ).start();
2404
2426
  addingSpinner.succeed();
2405
2427
  const result = previewTransform(
@@ -2505,7 +2527,7 @@ var add = new commander.Command().name("add").alias("install").description("add
2505
2527
  }
2506
2528
  logger.break();
2507
2529
  logger.log(
2508
- `${highlighter.success("Success!")} ${AGENT_NAMES[agentIntegration]} has been added.`
2530
+ `${highlighter.success("Success!")} ${getAgentDisplayName(agentIntegration)} has been added.`
2509
2531
  );
2510
2532
  if (packageJsonResult.warning) {
2511
2533
  logger.warn(packageJsonResult.warning);
@@ -2524,7 +2546,7 @@ var MAX_KEY_HOLD_DURATION_MS = 2e3;
2524
2546
  var MAX_CONTEXT_LINES = 50;
2525
2547
 
2526
2548
  // src/commands/configure.ts
2527
- var VERSION2 = "0.1.12";
2549
+ var VERSION2 = "0.1.13";
2528
2550
  var isMac = process.platform === "darwin";
2529
2551
  var META_LABEL = isMac ? "Cmd" : "Win";
2530
2552
  var ALT_LABEL = isMac ? "Option" : "Alt";
@@ -3027,7 +3049,7 @@ var configure = new commander.Command().name("configure").alias("config").descri
3027
3049
  });
3028
3050
 
3029
3051
  // src/utils/cli-helpers.ts
3030
- var formatInstalledAgentNames2 = (agents) => agents.map((agent) => AGENT_NAMES[agent] ?? agent).join(", ");
3052
+ var formatInstalledAgentNames2 = (agents) => agents.map(getAgentDisplayName).join(", ");
3031
3053
  var applyTransformWithFeedback = (result, message) => {
3032
3054
  const writeSpinner = spinner(
3033
3055
  message ?? `Applying changes to ${result.filePath}.`
@@ -3080,7 +3102,7 @@ var uninstallPackagesWithFeedback = (packages, packageManager, projectRoot) => {
3080
3102
  };
3081
3103
 
3082
3104
  // src/commands/init.ts
3083
- var VERSION3 = "0.1.12";
3105
+ var VERSION3 = "0.1.13";
3084
3106
  var REPORT_URL = "https://react-grab.com/api/report-cli";
3085
3107
  var DOCS_URL = "https://github.com/aidenybai/react-grab";
3086
3108
  var reportToCli = (type, config, error) => {
@@ -3116,12 +3138,7 @@ var UNSUPPORTED_FRAMEWORK_NAMES = {
3116
3138
  sveltekit: "SvelteKit",
3117
3139
  gatsby: "Gatsby"
3118
3140
  };
3119
- var getAgentName = (agent) => {
3120
- if (agent in AGENT_NAMES) {
3121
- return AGENT_NAMES[agent];
3122
- }
3123
- return agent;
3124
- };
3141
+ var getAgentName = getAgentDisplayName;
3125
3142
  var formatActivationKeyDisplay2 = (activationKey) => {
3126
3143
  if (!activationKey) return "Default (Option/Alt)";
3127
3144
  return activationKey.split("+").map((part) => {
@@ -3136,7 +3153,7 @@ var formatActivationKeyDisplay2 = (activationKey) => {
3136
3153
  };
3137
3154
  var init = new commander.Command().name("init").description("initialize React Grab in your project").option("-y, --yes", "skip confirmation prompts", false).option("-f, --force", "force overwrite existing config", false).option(
3138
3155
  "-a, --agent <agent>",
3139
- "agent integration (claude-code, cursor, opencode, codex, gemini, amp)"
3156
+ "connect to your agent (claude-code, cursor, opencode, codex, gemini, amp, mcp)"
3140
3157
  ).option(
3141
3158
  "-k, --key <key>",
3142
3159
  "activation key (e.g., Meta+K, Ctrl+Shift+G, Space)"
@@ -3355,40 +3372,108 @@ var init = new commander.Command().name("init").description("initialize React Gr
3355
3372
  const availableAgents = AGENTS.filter(
3356
3373
  (agent) => !projectInfo.installedAgents.includes(agent)
3357
3374
  );
3358
- if (availableAgents.length > 0) {
3375
+ logger.break();
3376
+ const { wantAddAgent } = await prompts({
3377
+ type: "confirm",
3378
+ name: "wantAddAgent",
3379
+ message: `Would you like to ${highlighter.info("connect it to your agent")}?`,
3380
+ initial: false
3381
+ });
3382
+ if (wantAddAgent === void 0) {
3359
3383
  logger.break();
3360
- const { wantAddAgent } = await prompts({
3361
- type: "confirm",
3362
- name: "wantAddAgent",
3363
- message: `Would you like to add an ${highlighter.info("agent integration")}?`,
3364
- initial: false
3365
- });
3366
- if (wantAddAgent === void 0) {
3384
+ process.exit(1);
3385
+ }
3386
+ if (wantAddAgent) {
3387
+ const connectionMode = await promptConnectionMode();
3388
+ if (connectionMode === void 0) {
3367
3389
  logger.break();
3368
3390
  process.exit(1);
3369
3391
  }
3370
- if (wantAddAgent) {
3371
- const connectionMode = await promptConnectionMode();
3372
- if (connectionMode === void 0) {
3392
+ let agentIntegration2;
3393
+ if (connectionMode === "mcp") {
3394
+ const didInstall = await promptMcpInstall();
3395
+ if (!didInstall) {
3396
+ logger.break();
3397
+ process.exit(0);
3398
+ }
3399
+ logger.break();
3400
+ logger.success("MCP server has been configured.");
3401
+ logger.log("Restart your agents to activate.");
3402
+ agentIntegration2 = "mcp";
3403
+ projectInfo.installedAgents = ["mcp"];
3404
+ const result2 = previewTransform(
3405
+ projectInfo.projectRoot,
3406
+ projectInfo.framework,
3407
+ projectInfo.nextRouterType,
3408
+ agentIntegration2,
3409
+ true
3410
+ );
3411
+ const packageJsonResult2 = previewPackageJsonTransform(
3412
+ projectInfo.projectRoot,
3413
+ agentIntegration2,
3414
+ projectInfo.installedAgents,
3415
+ projectInfo.packageManager
3416
+ );
3417
+ if (!result2.success) {
3418
+ logger.break();
3419
+ logger.error(result2.message);
3373
3420
  logger.break();
3374
3421
  process.exit(1);
3375
3422
  }
3376
- if (connectionMode === "mcp") {
3377
- const didInstall = await promptMcpInstall();
3378
- if (!didInstall) {
3379
- logger.break();
3380
- process.exit(0);
3381
- }
3423
+ const hasLayoutChanges2 = !result2.noChanges && result2.originalContent && result2.newContent;
3424
+ const hasPackageJsonChanges2 = packageJsonResult2.success && !packageJsonResult2.noChanges && packageJsonResult2.originalContent && packageJsonResult2.newContent;
3425
+ if (hasLayoutChanges2 || hasPackageJsonChanges2) {
3382
3426
  logger.break();
3383
- logger.success("MCP server has been configured.");
3384
- logger.log("Restart your agents to activate.");
3427
+ if (hasLayoutChanges2) {
3428
+ printDiff(
3429
+ result2.filePath,
3430
+ result2.originalContent,
3431
+ result2.newContent
3432
+ );
3433
+ }
3434
+ if (hasPackageJsonChanges2) {
3435
+ if (hasLayoutChanges2) {
3436
+ logger.break();
3437
+ }
3438
+ printDiff(
3439
+ packageJsonResult2.filePath,
3440
+ packageJsonResult2.originalContent,
3441
+ packageJsonResult2.newContent
3442
+ );
3443
+ }
3385
3444
  logger.break();
3386
- process.exit(0);
3445
+ const { proceed } = await prompts({
3446
+ type: "confirm",
3447
+ name: "proceed",
3448
+ message: "Apply these changes?",
3449
+ initial: true
3450
+ });
3451
+ if (!proceed) {
3452
+ logger.break();
3453
+ logger.log("Agent addition cancelled.");
3454
+ } else {
3455
+ installPackagesWithFeedback(
3456
+ getPackagesToInstall(agentIntegration2, false),
3457
+ projectInfo.packageManager,
3458
+ projectInfo.projectRoot
3459
+ );
3460
+ if (hasLayoutChanges2) {
3461
+ applyTransformWithFeedback(result2);
3462
+ }
3463
+ if (hasPackageJsonChanges2) {
3464
+ applyPackageJsonWithFeedback(packageJsonResult2);
3465
+ }
3466
+ logger.break();
3467
+ logger.success(
3468
+ `${getAgentName(agentIntegration2)} has been added.`
3469
+ );
3470
+ }
3387
3471
  }
3472
+ } else {
3388
3473
  const { agent } = await prompts({
3389
3474
  type: "select",
3390
3475
  name: "agent",
3391
- message: `Which ${highlighter.info("agent integration")} would you like to add?`,
3476
+ message: `Which ${highlighter.info("agent")} would you like to connect?`,
3392
3477
  choices: [
3393
3478
  ...availableAgents.map((innerAgent) => ({
3394
3479
  title: getAgentName(innerAgent),
@@ -3401,7 +3486,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
3401
3486
  logger.break();
3402
3487
  process.exit(0);
3403
3488
  }
3404
- const agentIntegration2 = agent;
3489
+ agentIntegration2 = agent;
3405
3490
  let agentsToRemove2 = [];
3406
3491
  if (projectInfo.installedAgents.length > 0) {
3407
3492
  const installedNames = formatInstalledAgentNames2(
@@ -3699,7 +3784,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
3699
3784
  const { wantAddAgent } = await prompts({
3700
3785
  type: "confirm",
3701
3786
  name: "wantAddAgent",
3702
- message: `Would you like to add an ${highlighter.info("agent integration")}?`,
3787
+ message: `Would you like to ${highlighter.info("connect it to your agent")}?`,
3703
3788
  initial: false
3704
3789
  });
3705
3790
  if (wantAddAgent === void 0) {
@@ -3722,11 +3807,12 @@ var init = new commander.Command().name("init").description("initialize React Gr
3722
3807
  logger.success("MCP server has been configured.");
3723
3808
  logger.log("Continuing with React Grab installation...");
3724
3809
  logger.break();
3810
+ agentIntegration = "mcp";
3725
3811
  } else {
3726
3812
  const { agent } = await prompts({
3727
3813
  type: "select",
3728
3814
  name: "agent",
3729
- message: `Which ${highlighter.info("agent integration")} would you like to add?`,
3815
+ message: `Which ${highlighter.info("agent")} would you like to connect?`,
3730
3816
  choices: [
3731
3817
  ...AGENTS.map((innerAgent) => ({
3732
3818
  title: getAgentName(innerAgent),
@@ -3850,10 +3936,10 @@ var init = new commander.Command().name("init").description("initialize React Gr
3850
3936
  reportToCli("error", void 0, error);
3851
3937
  }
3852
3938
  });
3853
- var VERSION4 = "0.1.12";
3854
- var remove = new commander.Command().name("remove").description("remove an agent integration").argument(
3939
+ var VERSION4 = "0.1.13";
3940
+ var remove = new commander.Command().name("remove").description("disconnect React Grab from your agent").argument(
3855
3941
  "[agent]",
3856
- "agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami)"
3942
+ "agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami, mcp)"
3857
3943
  ).option("-y, --yes", "skip confirmation prompts", false).option(
3858
3944
  "-c, --cwd <cwd>",
3859
3945
  "working directory (defaults to current directory)",
@@ -3880,7 +3966,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
3880
3966
  if (projectInfo.installedAgents.length === 0) {
3881
3967
  preflightSpinner.succeed();
3882
3968
  logger.break();
3883
- logger.warn("No agent integrations are installed.");
3969
+ logger.warn("No agent connections are installed.");
3884
3970
  logger.break();
3885
3971
  process.exit(0);
3886
3972
  }
@@ -3891,7 +3977,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
3891
3977
  logger.break();
3892
3978
  logger.error(`Agent ${highlighter.info(agentArg)} is not installed.`);
3893
3979
  logger.log(
3894
- `Installed agents: ${projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ")}`
3980
+ `Installed agents: ${projectInfo.installedAgents.map(getAgentDisplayName).join(", ")}`
3895
3981
  );
3896
3982
  logger.break();
3897
3983
  process.exit(1);
@@ -3902,9 +3988,9 @@ var remove = new commander.Command().name("remove").description("remove an agent
3902
3988
  const { agent } = await prompts({
3903
3989
  type: "select",
3904
3990
  name: "agent",
3905
- message: `Which ${highlighter.info("agent integration")} would you like to remove?`,
3991
+ message: `Which ${highlighter.info("agent")} would you like to disconnect?`,
3906
3992
  choices: projectInfo.installedAgents.map((innerAgent) => ({
3907
- title: AGENT_NAMES[innerAgent] || innerAgent,
3993
+ title: getAgentDisplayName(innerAgent),
3908
3994
  value: innerAgent
3909
3995
  }))
3910
3996
  });
@@ -3923,7 +4009,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
3923
4009
  process.exit(1);
3924
4010
  }
3925
4011
  const removingSpinner = spinner(
3926
- `Preparing to remove ${AGENT_NAMES[agentToRemove] || agentToRemove}.`
4012
+ `Preparing to remove ${getAgentDisplayName(agentToRemove)}.`
3927
4013
  ).start();
3928
4014
  removingSpinner.succeed();
3929
4015
  const result = previewAgentRemoval(
@@ -4020,7 +4106,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
4020
4106
  }
4021
4107
  logger.break();
4022
4108
  logger.log(
4023
- `${highlighter.success("Success!")} ${AGENT_NAMES[agentToRemove] || agentToRemove} has been removed.`
4109
+ `${highlighter.success("Success!")} ${getAgentDisplayName(agentToRemove)} has been removed.`
4024
4110
  );
4025
4111
  logger.break();
4026
4112
  } catch (error) {
@@ -4029,7 +4115,7 @@ var remove = new commander.Command().name("remove").description("remove an agent
4029
4115
  });
4030
4116
 
4031
4117
  // src/cli.ts
4032
- var VERSION5 = "0.1.12";
4118
+ var VERSION5 = "0.1.13";
4033
4119
  var VERSION_API_URL = "https://www.react-grab.com/api/version";
4034
4120
  process.on("SIGINT", () => process.exit(0));
4035
4121
  process.on("SIGTERM", () => process.exit(0));
package/dist/cli.js CHANGED
@@ -296,7 +296,8 @@ var AGENT_PACKAGES = [
296
296
  "@react-grab/codex",
297
297
  "@react-grab/gemini",
298
298
  "@react-grab/amp",
299
- "@react-grab/ami"
299
+ "@react-grab/ami",
300
+ "@react-grab/mcp"
300
301
  ];
301
302
  var detectUnsupportedFramework = (projectRoot) => {
302
303
  const packageJsonPath = join(projectRoot, "package.json");
@@ -843,6 +844,13 @@ var AGENT_NAMES = {
843
844
  ami: "Ami",
844
845
  droid: "Droid"
845
846
  };
847
+ var getAgentDisplayName = (agent) => {
848
+ if (agent === "mcp") return "MCP";
849
+ if (agent in AGENT_NAMES) {
850
+ return AGENT_NAMES[agent];
851
+ }
852
+ return agent;
853
+ };
846
854
  var NEXT_APP_ROUTER_SCRIPT = `{process.env.NODE_ENV === "development" && (
847
855
  <Script
848
856
  src="//unpkg.com/react-grab/dist/index.global.js"
@@ -1596,6 +1604,14 @@ var previewPackageJsonTransform = (projectRoot, agent, installedAgents, packageM
1596
1604
  noChanges: true
1597
1605
  };
1598
1606
  }
1607
+ if (agent === "mcp") {
1608
+ return {
1609
+ success: true,
1610
+ filePath: "",
1611
+ message: "MCP does not use package.json dev script",
1612
+ noChanges: true
1613
+ };
1614
+ }
1599
1615
  const packageJsonPath = join(projectRoot, "package.json");
1600
1616
  if (!existsSync(packageJsonPath)) {
1601
1617
  return {
@@ -2157,9 +2173,9 @@ var previewCdnTransform = (projectRoot, framework, nextRouterType, targetCdnDoma
2157
2173
  };
2158
2174
 
2159
2175
  // src/commands/add.ts
2160
- var VERSION = "0.1.12";
2176
+ var VERSION = "0.1.13";
2161
2177
  var formatInstalledAgentNames = (agents) => agents.map((agent) => AGENT_NAMES[agent] || agent).join(", ");
2162
- var add = new Command().name("add").alias("install").description("add an agent integration").argument("[agent]", `agent to add (${AGENTS.join(", ")})`).option("-y, --yes", "skip confirmation prompts", false).option(
2178
+ var add = new Command().name("add").alias("install").description("connect React Grab to your agent").argument("[agent]", `agent to add (${AGENTS.join(", ")})`).option("-y, --yes", "skip confirmation prompts", false).option(
2163
2179
  "-c, --cwd <cwd>",
2164
2180
  "working directory (defaults to current directory)",
2165
2181
  process.cwd()
@@ -2186,9 +2202,10 @@ var add = new Command().name("add").alias("install").description("add an agent i
2186
2202
  const availableAgents = AGENTS.filter(
2187
2203
  (agent) => !projectInfo.installedAgents.includes(agent)
2188
2204
  );
2189
- if (availableAgents.length === 0) {
2205
+ if (availableAgents.length === 0 && isNonInteractive && !agentArg) {
2190
2206
  logger.break();
2191
- logger.success("All agent integrations are already installed.");
2207
+ logger.success("All legacy agents are already installed.");
2208
+ logger.log("Run without -y to add MCP.");
2192
2209
  logger.break();
2193
2210
  process.exit(0);
2194
2211
  }
@@ -2222,11 +2239,11 @@ var add = new Command().name("add").alias("install").description("add an agent i
2222
2239
  message: "How would you like to proceed?",
2223
2240
  choices: [
2224
2241
  {
2225
- title: `Replace with ${AGENT_NAMES[agentIntegration]}`,
2242
+ title: `Replace with ${getAgentDisplayName(agentIntegration)}`,
2226
2243
  value: "replace"
2227
2244
  },
2228
2245
  {
2229
- title: `Add ${AGENT_NAMES[agentIntegration]} alongside existing`,
2246
+ title: `Add ${getAgentDisplayName(agentIntegration)} alongside existing`,
2230
2247
  value: "add"
2231
2248
  },
2232
2249
  { title: "Cancel", value: "cancel" }
@@ -2267,50 +2284,55 @@ var add = new Command().name("add").alias("install").description("add an agent i
2267
2284
  );
2268
2285
  logger.log("Restart your agents to activate.");
2269
2286
  logger.break();
2270
- process.exit(0);
2271
- }
2272
- const { agent } = await prompts({
2273
- type: "select",
2274
- name: "agent",
2275
- message: `Which ${highlighter.info("agent integration")} would you like to add?`,
2276
- choices: availableAgents.map((availableAgent) => ({
2277
- title: AGENT_NAMES[availableAgent],
2278
- value: availableAgent
2279
- }))
2280
- });
2281
- if (!agent) {
2282
- logger.break();
2283
- process.exit(1);
2284
- }
2285
- agentIntegration = agent;
2286
- if (projectInfo.installedAgents.length > 0) {
2287
- const installedNames = formatInstalledAgentNames(
2288
- projectInfo.installedAgents
2289
- );
2290
- const { action } = await prompts({
2287
+ agentIntegration = "mcp";
2288
+ projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"];
2289
+ } else {
2290
+ const { agent } = await prompts({
2291
2291
  type: "select",
2292
- name: "action",
2293
- message: "How would you like to proceed?",
2292
+ name: "agent",
2293
+ message: `Which ${highlighter.info("agent")} would you like to connect?`,
2294
2294
  choices: [
2295
- {
2296
- title: `Replace ${installedNames} with ${AGENT_NAMES[agentIntegration]}`,
2297
- value: "replace"
2298
- },
2299
- {
2300
- title: `Add ${AGENT_NAMES[agentIntegration]} alongside existing`,
2301
- value: "add"
2302
- },
2303
- { title: "Cancel", value: "cancel" }
2295
+ ...availableAgents.map((availableAgent) => ({
2296
+ title: AGENT_NAMES[availableAgent],
2297
+ value: availableAgent
2298
+ })),
2299
+ { title: "Skip", value: "skip" }
2304
2300
  ]
2305
2301
  });
2306
- if (!action || action === "cancel") {
2307
- logger.break();
2308
- logger.log("Changes cancelled.");
2302
+ if (!agent || agent === "skip") {
2309
2303
  logger.break();
2310
2304
  process.exit(0);
2311
2305
  }
2312
- if (action === "replace") {
2313
- agentsToRemove = [...projectInfo.installedAgents];
2306
+ agentIntegration = agent;
2307
+ if (projectInfo.installedAgents.length > 0) {
2308
+ const installedNames = formatInstalledAgentNames(
2309
+ projectInfo.installedAgents
2310
+ );
2311
+ const { action } = await prompts({
2312
+ type: "select",
2313
+ name: "action",
2314
+ message: "How would you like to proceed?",
2315
+ choices: [
2316
+ {
2317
+ title: `Replace ${installedNames} with ${getAgentDisplayName(agentIntegration)}`,
2318
+ value: "replace"
2319
+ },
2320
+ {
2321
+ title: `Add ${getAgentDisplayName(agentIntegration)} alongside existing`,
2322
+ value: "add"
2323
+ },
2324
+ { title: "Cancel", value: "cancel" }
2325
+ ]
2326
+ });
2327
+ if (!action || action === "cancel") {
2328
+ logger.break();
2329
+ logger.log("Changes cancelled.");
2330
+ logger.break();
2331
+ process.exit(0);
2332
+ }
2333
+ if (action === "replace") {
2334
+ agentsToRemove = [...projectInfo.installedAgents];
2335
+ }
2314
2336
  }
2315
2337
  }
2316
2338
  } else {
@@ -2387,7 +2409,7 @@ var add = new Command().name("add").alias("install").description("add an agent i
2387
2409
  );
2388
2410
  }
2389
2411
  const addingSpinner = spinner(
2390
- `Adding ${AGENT_NAMES[agentIntegration]}.`
2412
+ `Adding ${getAgentDisplayName(agentIntegration)}.`
2391
2413
  ).start();
2392
2414
  addingSpinner.succeed();
2393
2415
  const result = previewTransform(
@@ -2493,7 +2515,7 @@ var add = new Command().name("add").alias("install").description("add an agent i
2493
2515
  }
2494
2516
  logger.break();
2495
2517
  logger.log(
2496
- `${highlighter.success("Success!")} ${AGENT_NAMES[agentIntegration]} has been added.`
2518
+ `${highlighter.success("Success!")} ${getAgentDisplayName(agentIntegration)} has been added.`
2497
2519
  );
2498
2520
  if (packageJsonResult.warning) {
2499
2521
  logger.warn(packageJsonResult.warning);
@@ -2512,7 +2534,7 @@ var MAX_KEY_HOLD_DURATION_MS = 2e3;
2512
2534
  var MAX_CONTEXT_LINES = 50;
2513
2535
 
2514
2536
  // src/commands/configure.ts
2515
- var VERSION2 = "0.1.12";
2537
+ var VERSION2 = "0.1.13";
2516
2538
  var isMac = process.platform === "darwin";
2517
2539
  var META_LABEL = isMac ? "Cmd" : "Win";
2518
2540
  var ALT_LABEL = isMac ? "Option" : "Alt";
@@ -3015,7 +3037,7 @@ var configure = new Command().name("configure").alias("config").description("con
3015
3037
  });
3016
3038
 
3017
3039
  // src/utils/cli-helpers.ts
3018
- var formatInstalledAgentNames2 = (agents) => agents.map((agent) => AGENT_NAMES[agent] ?? agent).join(", ");
3040
+ var formatInstalledAgentNames2 = (agents) => agents.map(getAgentDisplayName).join(", ");
3019
3041
  var applyTransformWithFeedback = (result, message) => {
3020
3042
  const writeSpinner = spinner(
3021
3043
  message ?? `Applying changes to ${result.filePath}.`
@@ -3068,7 +3090,7 @@ var uninstallPackagesWithFeedback = (packages, packageManager, projectRoot) => {
3068
3090
  };
3069
3091
 
3070
3092
  // src/commands/init.ts
3071
- var VERSION3 = "0.1.12";
3093
+ var VERSION3 = "0.1.13";
3072
3094
  var REPORT_URL = "https://react-grab.com/api/report-cli";
3073
3095
  var DOCS_URL = "https://github.com/aidenybai/react-grab";
3074
3096
  var reportToCli = (type, config, error) => {
@@ -3104,12 +3126,7 @@ var UNSUPPORTED_FRAMEWORK_NAMES = {
3104
3126
  sveltekit: "SvelteKit",
3105
3127
  gatsby: "Gatsby"
3106
3128
  };
3107
- var getAgentName = (agent) => {
3108
- if (agent in AGENT_NAMES) {
3109
- return AGENT_NAMES[agent];
3110
- }
3111
- return agent;
3112
- };
3129
+ var getAgentName = getAgentDisplayName;
3113
3130
  var formatActivationKeyDisplay2 = (activationKey) => {
3114
3131
  if (!activationKey) return "Default (Option/Alt)";
3115
3132
  return activationKey.split("+").map((part) => {
@@ -3124,7 +3141,7 @@ var formatActivationKeyDisplay2 = (activationKey) => {
3124
3141
  };
3125
3142
  var init = new Command().name("init").description("initialize React Grab in your project").option("-y, --yes", "skip confirmation prompts", false).option("-f, --force", "force overwrite existing config", false).option(
3126
3143
  "-a, --agent <agent>",
3127
- "agent integration (claude-code, cursor, opencode, codex, gemini, amp)"
3144
+ "connect to your agent (claude-code, cursor, opencode, codex, gemini, amp, mcp)"
3128
3145
  ).option(
3129
3146
  "-k, --key <key>",
3130
3147
  "activation key (e.g., Meta+K, Ctrl+Shift+G, Space)"
@@ -3343,40 +3360,108 @@ var init = new Command().name("init").description("initialize React Grab in your
3343
3360
  const availableAgents = AGENTS.filter(
3344
3361
  (agent) => !projectInfo.installedAgents.includes(agent)
3345
3362
  );
3346
- if (availableAgents.length > 0) {
3363
+ logger.break();
3364
+ const { wantAddAgent } = await prompts({
3365
+ type: "confirm",
3366
+ name: "wantAddAgent",
3367
+ message: `Would you like to ${highlighter.info("connect it to your agent")}?`,
3368
+ initial: false
3369
+ });
3370
+ if (wantAddAgent === void 0) {
3347
3371
  logger.break();
3348
- const { wantAddAgent } = await prompts({
3349
- type: "confirm",
3350
- name: "wantAddAgent",
3351
- message: `Would you like to add an ${highlighter.info("agent integration")}?`,
3352
- initial: false
3353
- });
3354
- if (wantAddAgent === void 0) {
3372
+ process.exit(1);
3373
+ }
3374
+ if (wantAddAgent) {
3375
+ const connectionMode = await promptConnectionMode();
3376
+ if (connectionMode === void 0) {
3355
3377
  logger.break();
3356
3378
  process.exit(1);
3357
3379
  }
3358
- if (wantAddAgent) {
3359
- const connectionMode = await promptConnectionMode();
3360
- if (connectionMode === void 0) {
3380
+ let agentIntegration2;
3381
+ if (connectionMode === "mcp") {
3382
+ const didInstall = await promptMcpInstall();
3383
+ if (!didInstall) {
3384
+ logger.break();
3385
+ process.exit(0);
3386
+ }
3387
+ logger.break();
3388
+ logger.success("MCP server has been configured.");
3389
+ logger.log("Restart your agents to activate.");
3390
+ agentIntegration2 = "mcp";
3391
+ projectInfo.installedAgents = ["mcp"];
3392
+ const result2 = previewTransform(
3393
+ projectInfo.projectRoot,
3394
+ projectInfo.framework,
3395
+ projectInfo.nextRouterType,
3396
+ agentIntegration2,
3397
+ true
3398
+ );
3399
+ const packageJsonResult2 = previewPackageJsonTransform(
3400
+ projectInfo.projectRoot,
3401
+ agentIntegration2,
3402
+ projectInfo.installedAgents,
3403
+ projectInfo.packageManager
3404
+ );
3405
+ if (!result2.success) {
3406
+ logger.break();
3407
+ logger.error(result2.message);
3361
3408
  logger.break();
3362
3409
  process.exit(1);
3363
3410
  }
3364
- if (connectionMode === "mcp") {
3365
- const didInstall = await promptMcpInstall();
3366
- if (!didInstall) {
3367
- logger.break();
3368
- process.exit(0);
3369
- }
3411
+ const hasLayoutChanges2 = !result2.noChanges && result2.originalContent && result2.newContent;
3412
+ const hasPackageJsonChanges2 = packageJsonResult2.success && !packageJsonResult2.noChanges && packageJsonResult2.originalContent && packageJsonResult2.newContent;
3413
+ if (hasLayoutChanges2 || hasPackageJsonChanges2) {
3370
3414
  logger.break();
3371
- logger.success("MCP server has been configured.");
3372
- logger.log("Restart your agents to activate.");
3415
+ if (hasLayoutChanges2) {
3416
+ printDiff(
3417
+ result2.filePath,
3418
+ result2.originalContent,
3419
+ result2.newContent
3420
+ );
3421
+ }
3422
+ if (hasPackageJsonChanges2) {
3423
+ if (hasLayoutChanges2) {
3424
+ logger.break();
3425
+ }
3426
+ printDiff(
3427
+ packageJsonResult2.filePath,
3428
+ packageJsonResult2.originalContent,
3429
+ packageJsonResult2.newContent
3430
+ );
3431
+ }
3373
3432
  logger.break();
3374
- process.exit(0);
3433
+ const { proceed } = await prompts({
3434
+ type: "confirm",
3435
+ name: "proceed",
3436
+ message: "Apply these changes?",
3437
+ initial: true
3438
+ });
3439
+ if (!proceed) {
3440
+ logger.break();
3441
+ logger.log("Agent addition cancelled.");
3442
+ } else {
3443
+ installPackagesWithFeedback(
3444
+ getPackagesToInstall(agentIntegration2, false),
3445
+ projectInfo.packageManager,
3446
+ projectInfo.projectRoot
3447
+ );
3448
+ if (hasLayoutChanges2) {
3449
+ applyTransformWithFeedback(result2);
3450
+ }
3451
+ if (hasPackageJsonChanges2) {
3452
+ applyPackageJsonWithFeedback(packageJsonResult2);
3453
+ }
3454
+ logger.break();
3455
+ logger.success(
3456
+ `${getAgentName(agentIntegration2)} has been added.`
3457
+ );
3458
+ }
3375
3459
  }
3460
+ } else {
3376
3461
  const { agent } = await prompts({
3377
3462
  type: "select",
3378
3463
  name: "agent",
3379
- message: `Which ${highlighter.info("agent integration")} would you like to add?`,
3464
+ message: `Which ${highlighter.info("agent")} would you like to connect?`,
3380
3465
  choices: [
3381
3466
  ...availableAgents.map((innerAgent) => ({
3382
3467
  title: getAgentName(innerAgent),
@@ -3389,7 +3474,7 @@ var init = new Command().name("init").description("initialize React Grab in your
3389
3474
  logger.break();
3390
3475
  process.exit(0);
3391
3476
  }
3392
- const agentIntegration2 = agent;
3477
+ agentIntegration2 = agent;
3393
3478
  let agentsToRemove2 = [];
3394
3479
  if (projectInfo.installedAgents.length > 0) {
3395
3480
  const installedNames = formatInstalledAgentNames2(
@@ -3687,7 +3772,7 @@ var init = new Command().name("init").description("initialize React Grab in your
3687
3772
  const { wantAddAgent } = await prompts({
3688
3773
  type: "confirm",
3689
3774
  name: "wantAddAgent",
3690
- message: `Would you like to add an ${highlighter.info("agent integration")}?`,
3775
+ message: `Would you like to ${highlighter.info("connect it to your agent")}?`,
3691
3776
  initial: false
3692
3777
  });
3693
3778
  if (wantAddAgent === void 0) {
@@ -3710,11 +3795,12 @@ var init = new Command().name("init").description("initialize React Grab in your
3710
3795
  logger.success("MCP server has been configured.");
3711
3796
  logger.log("Continuing with React Grab installation...");
3712
3797
  logger.break();
3798
+ agentIntegration = "mcp";
3713
3799
  } else {
3714
3800
  const { agent } = await prompts({
3715
3801
  type: "select",
3716
3802
  name: "agent",
3717
- message: `Which ${highlighter.info("agent integration")} would you like to add?`,
3803
+ message: `Which ${highlighter.info("agent")} would you like to connect?`,
3718
3804
  choices: [
3719
3805
  ...AGENTS.map((innerAgent) => ({
3720
3806
  title: getAgentName(innerAgent),
@@ -3838,10 +3924,10 @@ var init = new Command().name("init").description("initialize React Grab in your
3838
3924
  reportToCli("error", void 0, error);
3839
3925
  }
3840
3926
  });
3841
- var VERSION4 = "0.1.12";
3842
- var remove = new Command().name("remove").description("remove an agent integration").argument(
3927
+ var VERSION4 = "0.1.13";
3928
+ var remove = new Command().name("remove").description("disconnect React Grab from your agent").argument(
3843
3929
  "[agent]",
3844
- "agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami)"
3930
+ "agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami, mcp)"
3845
3931
  ).option("-y, --yes", "skip confirmation prompts", false).option(
3846
3932
  "-c, --cwd <cwd>",
3847
3933
  "working directory (defaults to current directory)",
@@ -3868,7 +3954,7 @@ var remove = new Command().name("remove").description("remove an agent integrati
3868
3954
  if (projectInfo.installedAgents.length === 0) {
3869
3955
  preflightSpinner.succeed();
3870
3956
  logger.break();
3871
- logger.warn("No agent integrations are installed.");
3957
+ logger.warn("No agent connections are installed.");
3872
3958
  logger.break();
3873
3959
  process.exit(0);
3874
3960
  }
@@ -3879,7 +3965,7 @@ var remove = new Command().name("remove").description("remove an agent integrati
3879
3965
  logger.break();
3880
3966
  logger.error(`Agent ${highlighter.info(agentArg)} is not installed.`);
3881
3967
  logger.log(
3882
- `Installed agents: ${projectInfo.installedAgents.map((innerAgent) => AGENT_NAMES[innerAgent] || innerAgent).join(", ")}`
3968
+ `Installed agents: ${projectInfo.installedAgents.map(getAgentDisplayName).join(", ")}`
3883
3969
  );
3884
3970
  logger.break();
3885
3971
  process.exit(1);
@@ -3890,9 +3976,9 @@ var remove = new Command().name("remove").description("remove an agent integrati
3890
3976
  const { agent } = await prompts({
3891
3977
  type: "select",
3892
3978
  name: "agent",
3893
- message: `Which ${highlighter.info("agent integration")} would you like to remove?`,
3979
+ message: `Which ${highlighter.info("agent")} would you like to disconnect?`,
3894
3980
  choices: projectInfo.installedAgents.map((innerAgent) => ({
3895
- title: AGENT_NAMES[innerAgent] || innerAgent,
3981
+ title: getAgentDisplayName(innerAgent),
3896
3982
  value: innerAgent
3897
3983
  }))
3898
3984
  });
@@ -3911,7 +3997,7 @@ var remove = new Command().name("remove").description("remove an agent integrati
3911
3997
  process.exit(1);
3912
3998
  }
3913
3999
  const removingSpinner = spinner(
3914
- `Preparing to remove ${AGENT_NAMES[agentToRemove] || agentToRemove}.`
4000
+ `Preparing to remove ${getAgentDisplayName(agentToRemove)}.`
3915
4001
  ).start();
3916
4002
  removingSpinner.succeed();
3917
4003
  const result = previewAgentRemoval(
@@ -4008,7 +4094,7 @@ var remove = new Command().name("remove").description("remove an agent integrati
4008
4094
  }
4009
4095
  logger.break();
4010
4096
  logger.log(
4011
- `${highlighter.success("Success!")} ${AGENT_NAMES[agentToRemove] || agentToRemove} has been removed.`
4097
+ `${highlighter.success("Success!")} ${getAgentDisplayName(agentToRemove)} has been removed.`
4012
4098
  );
4013
4099
  logger.break();
4014
4100
  } catch (error) {
@@ -4017,7 +4103,7 @@ var remove = new Command().name("remove").description("remove an agent integrati
4017
4103
  });
4018
4104
 
4019
4105
  // src/cli.ts
4020
- var VERSION5 = "0.1.12";
4106
+ var VERSION5 = "0.1.13";
4021
4107
  var VERSION_API_URL = "https://www.react-grab.com/api/version";
4022
4108
  process.on("SIGINT", () => process.exit(0));
4023
4109
  process.on("SIGTERM", () => process.exit(0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-grab/cli",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "bin": {
5
5
  "react-grab": "./dist/cli.js"
6
6
  },