nx 22.2.0-canary.20251124-70bbbe9 → 22.2.0-canary.20251125-7e00ec4

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 (52) hide show
  1. package/bin/init-local.d.ts.map +1 -1
  2. package/bin/init-local.js +40 -2
  3. package/package.json +11 -11
  4. package/release/changelog-renderer/index.d.ts +1 -0
  5. package/release/changelog-renderer/index.d.ts.map +1 -1
  6. package/release/changelog-renderer/index.js +12 -12
  7. package/src/ai/constants.d.ts +6 -1
  8. package/src/ai/constants.d.ts.map +1 -1
  9. package/src/ai/constants.js +14 -3
  10. package/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts.map +1 -1
  11. package/src/ai/set-up-ai-agents/set-up-ai-agents.js +41 -7
  12. package/src/command-line/report/report.d.ts +4 -0
  13. package/src/command-line/report/report.d.ts.map +1 -1
  14. package/src/command-line/report/report.js +72 -1
  15. package/src/core/graph/main.js +1 -1
  16. package/src/daemon/cache.d.ts +2 -1
  17. package/src/daemon/cache.d.ts.map +1 -1
  18. package/src/daemon/cache.js +10 -26
  19. package/src/daemon/client/client.d.ts +5 -0
  20. package/src/daemon/client/client.d.ts.map +1 -1
  21. package/src/daemon/client/client.js +67 -26
  22. package/src/daemon/is-nx-version-mismatch.d.ts +3 -0
  23. package/src/daemon/is-nx-version-mismatch.d.ts.map +1 -0
  24. package/src/daemon/is-nx-version-mismatch.js +24 -0
  25. package/src/daemon/message-types/nx-console.d.ts +18 -0
  26. package/src/daemon/message-types/nx-console.d.ts.map +1 -0
  27. package/src/daemon/message-types/nx-console.js +19 -0
  28. package/src/daemon/server/handle-nx-console.d.ts +4 -0
  29. package/src/daemon/server/handle-nx-console.d.ts.map +1 -0
  30. package/src/daemon/server/handle-nx-console.js +54 -0
  31. package/src/daemon/server/nx-console-operations.d.ts +31 -0
  32. package/src/daemon/server/nx-console-operations.d.ts.map +1 -0
  33. package/src/daemon/server/nx-console-operations.js +135 -0
  34. package/src/daemon/server/server.d.ts.map +1 -1
  35. package/src/daemon/server/server.js +19 -18
  36. package/src/daemon/server/shutdown-utils.d.ts.map +1 -1
  37. package/src/daemon/server/shutdown-utils.js +3 -0
  38. package/src/daemon/tmp-dir.d.ts.map +1 -1
  39. package/src/daemon/tmp-dir.js +1 -0
  40. package/src/devkit-internals.d.ts +1 -1
  41. package/src/devkit-internals.d.ts.map +1 -1
  42. package/src/devkit-internals.js +2 -1
  43. package/src/tasks-runner/pseudo-terminal.js +1 -1
  44. package/src/tasks-runner/task-orchestrator.d.ts +1 -0
  45. package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
  46. package/src/tasks-runner/task-orchestrator.js +22 -5
  47. package/src/utils/package-json.d.ts +4 -0
  48. package/src/utils/package-json.d.ts.map +1 -1
  49. package/src/utils/package-json.js +45 -11
  50. package/src/utils/package-manager.d.ts +1 -0
  51. package/src/utils/package-manager.d.ts.map +1 -1
  52. package/src/utils/package-manager.js +4 -0
@@ -1 +1 @@
1
- {"version":3,"file":"init-local.d.ts","sourceRoot":"","sources":["../../../../packages/nx/bin/init-local.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIxE;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,oBAAoB,iBA6C9D;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,YA6BvD"}
1
+ {"version":3,"file":"init-local.d.ts","sourceRoot":"","sources":["../../../../packages/nx/bin/init-local.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAMxE;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,oBAAoB,iBA6C9D;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,YA6BvD"}
package/bin/init-local.js CHANGED
@@ -5,7 +5,9 @@ exports.rewriteTargetsAndProjects = rewriteTargetsAndProjects;
5
5
  const perf_hooks_1 = require("perf_hooks");
6
6
  const nx_commands_1 = require("../src/command-line/nx-commands");
7
7
  const strip_indents_1 = require("../src/utils/strip-indents");
8
- const nx_console_prompt_1 = require("../src/utils/nx-console-prompt");
8
+ const client_1 = require("../src/daemon/client/client");
9
+ const enquirer_1 = require("enquirer");
10
+ const output_1 = require("../src/utils/output");
9
11
  /**
10
12
  * Nx is being run inside a workspace.
11
13
  *
@@ -29,7 +31,7 @@ async function initLocal(workspace) {
29
31
  }
30
32
  // Ensure NxConsole is installed if the user has it configured.
31
33
  try {
32
- await (0, nx_console_prompt_1.ensureNxConsoleInstalled)();
34
+ await ensureNxConsoleInstalledViaDaemon();
33
35
  }
34
36
  catch { }
35
37
  const command = process.argv[2];
@@ -115,6 +117,42 @@ function shouldDelegateToAngularCLI() {
115
117
  ];
116
118
  return commands.indexOf(command) > -1;
117
119
  }
120
+ async function ensureNxConsoleInstalledViaDaemon() {
121
+ // Only proceed if daemon is available
122
+ if (!client_1.daemonClient.enabled()) {
123
+ return;
124
+ }
125
+ // Get status from daemon
126
+ const status = await client_1.daemonClient.getNxConsoleStatus();
127
+ // If we should prompt the user
128
+ if (status.shouldPrompt && process.stdout.isTTY) {
129
+ output_1.output.log({
130
+ title: "Install Nx's official editor extension to:",
131
+ bodyLines: [
132
+ '- Enable your AI assistant to do more by understanding your workspace',
133
+ '- Add IntelliSense for Nx configuration files',
134
+ '- Explore your workspace visually',
135
+ ],
136
+ });
137
+ try {
138
+ const { shouldInstallNxConsole } = await (0, enquirer_1.prompt)({
139
+ type: 'confirm',
140
+ name: 'shouldInstallNxConsole',
141
+ message: 'Install Nx Console? (you can uninstall anytime)',
142
+ initial: true,
143
+ });
144
+ // Set preference and install if user said yes
145
+ const result = await client_1.daemonClient.setNxConsolePreferenceAndInstall(shouldInstallNxConsole);
146
+ if (result.installed) {
147
+ output_1.output.log({ title: 'Successfully installed Nx Console!' });
148
+ }
149
+ }
150
+ catch (error) {
151
+ // User cancelled or error occurred, save preference as false
152
+ await client_1.daemonClient.setNxConsolePreferenceAndInstall(false);
153
+ }
154
+ }
155
+ }
118
156
  function handleAngularCLIFallbacks(workspace) {
119
157
  if (process.argv[2] === 'update' && process.env.FORCE_NG_UPDATE != 'true') {
120
158
  console.log(`Nx provides a much improved version of "ng update". It runs the same migrations, but allows you to:`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "22.2.0-canary.20251124-70bbbe9",
3
+ "version": "22.2.0-canary.20251125-7e00ec4",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -83,16 +83,16 @@
83
83
  }
84
84
  },
85
85
  "optionalDependencies": {
86
- "@nx/nx-darwin-arm64": "22.2.0-canary.20251124-70bbbe9",
87
- "@nx/nx-darwin-x64": "22.2.0-canary.20251124-70bbbe9",
88
- "@nx/nx-freebsd-x64": "22.2.0-canary.20251124-70bbbe9",
89
- "@nx/nx-linux-arm-gnueabihf": "22.2.0-canary.20251124-70bbbe9",
90
- "@nx/nx-linux-arm64-gnu": "22.2.0-canary.20251124-70bbbe9",
91
- "@nx/nx-linux-arm64-musl": "22.2.0-canary.20251124-70bbbe9",
92
- "@nx/nx-linux-x64-gnu": "22.2.0-canary.20251124-70bbbe9",
93
- "@nx/nx-linux-x64-musl": "22.2.0-canary.20251124-70bbbe9",
94
- "@nx/nx-win32-arm64-msvc": "22.2.0-canary.20251124-70bbbe9",
95
- "@nx/nx-win32-x64-msvc": "22.2.0-canary.20251124-70bbbe9"
86
+ "@nx/nx-darwin-arm64": "22.2.0-canary.20251125-7e00ec4",
87
+ "@nx/nx-darwin-x64": "22.2.0-canary.20251125-7e00ec4",
88
+ "@nx/nx-freebsd-x64": "22.2.0-canary.20251125-7e00ec4",
89
+ "@nx/nx-linux-arm-gnueabihf": "22.2.0-canary.20251125-7e00ec4",
90
+ "@nx/nx-linux-arm64-gnu": "22.2.0-canary.20251125-7e00ec4",
91
+ "@nx/nx-linux-arm64-musl": "22.2.0-canary.20251125-7e00ec4",
92
+ "@nx/nx-linux-x64-gnu": "22.2.0-canary.20251125-7e00ec4",
93
+ "@nx/nx-linux-x64-musl": "22.2.0-canary.20251125-7e00ec4",
94
+ "@nx/nx-win32-arm64-msvc": "22.2.0-canary.20251125-7e00ec4",
95
+ "@nx/nx-win32-x64-msvc": "22.2.0-canary.20251125-7e00ec4"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
@@ -99,6 +99,7 @@ export default class DefaultChangelogRenderer {
99
99
  protected shouldRenderAuthors(): boolean;
100
100
  protected renderAuthors(): Promise<string[]>;
101
101
  protected formatChange(change: ChangelogChange): string;
102
+ protected formatBreakingChangeBase(change: ChangelogChange): string;
102
103
  protected formatBreakingChange(change: ChangelogChange): string;
103
104
  protected groupChangesByType(): Record<string, ChangelogChange[]>;
104
105
  protected groupChangesByScope(changes: ChangelogChange[]): Record<string, ChangelogChange[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/release/changelog-renderer/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mFAAmF,CAAC;AAE7H;;GAEG;AACH,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,sBAAsB;IAC3E;;;OAGG;IACH,OA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SAAS,CAAC,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM;IAwBnE,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM;IAkC/D,SAAS,CAAC,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IASjE,SAAS,CAAC,mBAAmB,CAC3B,OAAO,EAAE,eAAe,EAAE,GACzB,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IAUpC,SAAS,CAAC,gCAAgC,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IA+B1E,SAAS,CAAC,UAAU,CAAC,IAAI,SAAK,GAAG,MAAM;CAMxC"}
@@ -273,29 +273,29 @@ class DefaultChangelogRenderer {
273
273
  }
274
274
  return changeLine;
275
275
  }
276
- formatBreakingChange(change) {
277
- const explanation = this.extractBreakingChangeExplanation(change.body);
278
- if (!explanation) {
279
- // No explanation found, use the regular formatChange which includes references
280
- return this.formatChange(change);
281
- }
282
- // Build the breaking change line with scope, explanation, and references
276
+ formatBreakingChangeBase(change) {
283
277
  let breakingLine = '- ';
284
278
  if (change.scope) {
285
279
  breakingLine += `**${change.scope.trim()}:** `;
286
280
  }
287
- // Ensure first line of the breaking change contains the commit title
288
281
  if (change.description) {
289
- breakingLine += `${change.description.trim()} `;
282
+ breakingLine += `${change.description.trim()}`;
290
283
  }
291
- // Add PR/commit references
292
284
  if (this.remoteReleaseClient.getRemoteRepoData() &&
293
285
  this.changelogRenderOptions.commitReferences &&
294
286
  change.githubReferences) {
295
- breakingLine += `${this.remoteReleaseClient.formatReferences(change.githubReferences)}`;
287
+ breakingLine += ` ${this.remoteReleaseClient.formatReferences(change.githubReferences)}`;
288
+ }
289
+ return breakingLine;
290
+ }
291
+ formatBreakingChange(change) {
292
+ const explanation = this.extractBreakingChangeExplanation(change.body);
293
+ const baseLine = this.formatBreakingChangeBase(change);
294
+ if (!explanation) {
295
+ return baseLine;
296
296
  }
297
297
  const indentation = ' ';
298
- breakingLine += `\n${indentation}`;
298
+ let breakingLine = baseLine + `\n${indentation}`;
299
299
  // Handle multi-line explanations
300
300
  let explanationText = explanation;
301
301
  let extraLines = [];
@@ -11,5 +11,10 @@ export declare const nxRulesMarkerCommentEnd = "<!-- nx configuration end-->";
11
11
  export declare const rulesRegex: RegExp;
12
12
  export declare const getAgentRulesWrapped: (writeNxCloudRules: boolean) => string;
13
13
  export declare const nxMcpTomlHeader = "[mcp_servers.\"nx-mcp\"]";
14
- export declare const nxMcpTomlConfig = "[mcp_servers.\"nx-mcp\"]\ntype = \"stdio\"\ncommand = \"npx\"\nargs = [\"nx\", \"mcp\"]\n";
14
+ /**
15
+ * Get the MCP TOML configuration based on the Nx version.
16
+ * For Nx 22+, uses 'nx mcp'
17
+ * For Nx < 22, uses 'nx-mcp'
18
+ */
19
+ export declare function getNxMcpTomlConfig(nxVersion: string): string;
15
20
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/ai/constants.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAOjE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,eAAO,MAAM,mBAAmB,QAA2C,CAAC;AAE5E,eAAO,MAAM,yBAAyB,mCAAmC,CAAC;AAC1E,eAAO,MAAM,+BAA+B,8EAA8E,CAAC;AAC3H,eAAO,MAAM,uBAAuB,iCAAiC,CAAC;AACtE,eAAO,MAAM,UAAU,QAGtB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,mBAAmB,OAAO,WAG9D,CAAC;AAEF,eAAO,MAAM,eAAe,6BAA2B,CAAC;AACxD,eAAO,MAAM,eAAe,8FAI3B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/ai/constants.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAOjE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,eAAO,MAAM,mBAAmB,QAA2C,CAAC;AAE5E,eAAO,MAAM,yBAAyB,mCAAmC,CAAC;AAC1E,eAAO,MAAM,+BAA+B,8EAA8E,CAAC;AAC3H,eAAO,MAAM,uBAAuB,iCAAiC,CAAC;AACtE,eAAO,MAAM,UAAU,QAGtB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,mBAAmB,OAAO,WAG9D,CAAC;AAEF,eAAO,MAAM,eAAe,6BAA2B,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAQ5D"}
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nxMcpTomlConfig = exports.nxMcpTomlHeader = exports.getAgentRulesWrapped = exports.rulesRegex = exports.nxRulesMarkerCommentEnd = exports.nxRulesMarkerCommentDescription = exports.nxRulesMarkerCommentStart = exports.codexConfigTomlPath = void 0;
3
+ exports.nxMcpTomlHeader = exports.getAgentRulesWrapped = exports.rulesRegex = exports.nxRulesMarkerCommentEnd = exports.nxRulesMarkerCommentDescription = exports.nxRulesMarkerCommentStart = exports.codexConfigTomlPath = void 0;
4
4
  exports.agentsMdPath = agentsMdPath;
5
5
  exports.geminiMdPath = geminiMdPath;
6
6
  exports.parseGeminiSettings = parseGeminiSettings;
7
7
  exports.geminiSettingsPath = geminiSettingsPath;
8
8
  exports.claudeMdPath = claudeMdPath;
9
9
  exports.claudeMcpPath = claudeMcpPath;
10
+ exports.getNxMcpTomlConfig = getNxMcpTomlConfig;
10
11
  const os_1 = require("os");
11
12
  const path_1 = require("path");
13
+ const semver_1 = require("semver");
12
14
  const fileutils_1 = require("../utils/fileutils");
13
15
  const get_agent_rules_1 = require("./set-up-ai-agents/get-agent-rules");
14
16
  function agentsMdPath(root) {
@@ -46,8 +48,17 @@ const getAgentRulesWrapped = (writeNxCloudRules) => {
46
48
  };
47
49
  exports.getAgentRulesWrapped = getAgentRulesWrapped;
48
50
  exports.nxMcpTomlHeader = `[mcp_servers."nx-mcp"]`;
49
- exports.nxMcpTomlConfig = `${exports.nxMcpTomlHeader}
51
+ /**
52
+ * Get the MCP TOML configuration based on the Nx version.
53
+ * For Nx 22+, uses 'nx mcp'
54
+ * For Nx < 22, uses 'nx-mcp'
55
+ */
56
+ function getNxMcpTomlConfig(nxVersion) {
57
+ const majorVersion = (0, semver_1.major)(nxVersion);
58
+ const args = majorVersion >= 22 ? '["nx", "mcp"]' : '["nx-mcp"]';
59
+ return `${exports.nxMcpTomlHeader}
50
60
  type = "stdio"
51
61
  command = "npx"
52
- args = ["nx", "mcp"]
62
+ args = ${args}
53
63
  `;
64
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"set-up-ai-agents.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/ai/set-up-ai-agents/set-up-ai-agents.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAQ7C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAc5B,OAAO,EACL,sCAAsC,EACtC,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IACjC,MAAM,EAAE,qBAAqB,EAAE,CAAC;CACjC,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,EACrC,KAAK,UAAQ,GACZ,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAmC5D;AAaD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sCAAsC,GAC9C,OAAO,CAAC,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAkJ7C;AAwDD,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"set-up-ai-agents.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/ai/set-up-ai-agents/set-up-ai-agents.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAQ7C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAkB5B,OAAO,EACL,sCAAsC,EACtC,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IACjC,MAAM,EAAE,qBAAqB,EAAE,CAAC;CACjC,CAAC;AAmCF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,EACrC,KAAK,UAAQ,GACZ,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAmC5D;AAaD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sCAAsC,GAC9C,OAAO,CAAC,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAwJ7C;AA2DD,eAAe,sBAAsB,CAAC"}
@@ -5,14 +5,45 @@ exports.setupAiAgentsGeneratorImpl = setupAiAgentsGeneratorImpl;
5
5
  const fs_1 = require("fs");
6
6
  const os_1 = require("os");
7
7
  const path_1 = require("path");
8
+ const semver_1 = require("semver");
8
9
  const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
9
10
  const json_1 = require("../../generators/utils/json");
10
11
  const native_1 = require("../../native");
11
12
  const package_json_1 = require("../../utils/package-json");
12
13
  const provenance_1 = require("../../utils/provenance");
14
+ const workspace_root_1 = require("../../utils/workspace-root");
13
15
  const constants_1 = require("../constants");
14
16
  const utils_1 = require("../utils");
15
17
  const constants_2 = require("../constants");
18
+ /**
19
+ * Get the installed Nx version, with fallback to workspace package.json or default version.
20
+ */
21
+ function getNxVersion() {
22
+ try {
23
+ // Try to read from node_modules first
24
+ const { packageJson: { version }, } = (0, package_json_1.readModulePackageJson)('nx');
25
+ return version;
26
+ }
27
+ catch {
28
+ try {
29
+ // Fallback: try to read from workspace package.json
30
+ const workspacePackageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'), 'utf-8'));
31
+ // Check devDependencies first, then dependencies
32
+ const nxVersion = workspacePackageJson.devDependencies?.nx ||
33
+ workspacePackageJson.dependencies?.nx;
34
+ if (nxVersion) {
35
+ // Remove any semver range characters (^, ~, >=, etc.)
36
+ return nxVersion.replace(/^[\^~>=<]+/, '');
37
+ }
38
+ throw new Error('Nx not found in package.json');
39
+ }
40
+ catch {
41
+ // If we can't determine the version, default to the newer format
42
+ // This handles cases where nx might not be installed or is globally installed
43
+ return '22.0.0';
44
+ }
45
+ }
46
+ }
16
47
  async function setupAiAgentsGenerator(tree, options, inner = false) {
17
48
  const normalizedOptions = normalizeOptions(options);
18
49
  // Use environment variable to force local execution
@@ -42,6 +73,7 @@ function normalizeOptions(options) {
42
73
  }
43
74
  async function setupAiAgentsGeneratorImpl(tree, options) {
44
75
  const hasAgent = (agent) => options.agents.includes(agent);
76
+ const nxVersion = getNxVersion();
45
77
  const agentsMd = (0, constants_1.agentsMdPath)(options.directory);
46
78
  // write AGENTS.md for most agents
47
79
  if (hasAgent('cursor') || hasAgent('copilot') || hasAgent('codex')) {
@@ -54,14 +86,14 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
54
86
  if (!tree.exists(mcpJsonPath)) {
55
87
  (0, json_1.writeJson)(tree, mcpJsonPath, {});
56
88
  }
57
- (0, json_1.updateJson)(tree, mcpJsonPath, mcpConfigUpdater);
89
+ (0, json_1.updateJson)(tree, mcpJsonPath, (json) => mcpConfigUpdater(json, nxVersion));
58
90
  }
59
91
  if (hasAgent('gemini')) {
60
92
  const geminiSettingsPath = (0, path_1.join)(options.directory, '.gemini', 'settings.json');
61
93
  if (!tree.exists(geminiSettingsPath)) {
62
94
  (0, json_1.writeJson)(tree, geminiSettingsPath, {});
63
95
  }
64
- (0, json_1.updateJson)(tree, geminiSettingsPath, mcpConfigUpdater);
96
+ (0, json_1.updateJson)(tree, geminiSettingsPath, (json) => mcpConfigUpdater(json, nxVersion));
65
97
  const contextFileName = (0, json_1.readJson)(tree, geminiSettingsPath).contextFileName;
66
98
  const geminiMd = (0, constants_1.geminiMdPath)(options.directory);
67
99
  // Only set contextFileName to AGENTS.md if GEMINI.md doesn't exist already to preserve existing setups
@@ -86,7 +118,7 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
86
118
  const tomlContents = (0, fs_1.readFileSync)(constants_1.codexConfigTomlPath, 'utf-8');
87
119
  if (!tomlContents.includes(constants_2.nxMcpTomlHeader)) {
88
120
  if (!check) {
89
- (0, fs_1.appendFileSync)(constants_1.codexConfigTomlPath, `\n${constants_2.nxMcpTomlConfig}`);
121
+ (0, fs_1.appendFileSync)(constants_1.codexConfigTomlPath, `\n${(0, constants_2.getNxMcpTomlConfig)(nxVersion)}`);
90
122
  }
91
123
  messages.push({
92
124
  title: `Updated ${constants_1.codexConfigTomlPath} with nx-mcp server`,
@@ -96,7 +128,7 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
96
128
  else {
97
129
  if (!check) {
98
130
  (0, fs_1.mkdirSync)((0, path_1.join)((0, os_1.homedir)(), '.codex'), { recursive: true });
99
- (0, fs_1.writeFileSync)(constants_1.codexConfigTomlPath, constants_2.nxMcpTomlConfig);
131
+ (0, fs_1.writeFileSync)(constants_1.codexConfigTomlPath, (0, constants_2.getNxMcpTomlConfig)(nxVersion));
100
132
  }
101
133
  messages.push({
102
134
  title: `Created ${constants_1.codexConfigTomlPath} with nx-mcp server`,
@@ -191,12 +223,14 @@ function writeAgentRules(tree, path, writeNxCloudRules) {
191
223
  tree.write(path, existing + '\n\n' + expectedRules);
192
224
  }
193
225
  }
194
- function mcpConfigUpdater(existing) {
226
+ function mcpConfigUpdater(existing, nxVersion) {
227
+ const majorVersion = (0, semver_1.major)(nxVersion);
228
+ const mcpArgs = majorVersion >= 22 ? ['nx', 'mcp'] : ['nx-mcp'];
195
229
  if (existing.mcpServers) {
196
230
  existing.mcpServers['nx-mcp'] = {
197
231
  type: 'stdio',
198
232
  command: 'npx',
199
- args: ['nx', 'mcp'],
233
+ args: mcpArgs,
200
234
  };
201
235
  }
202
236
  else {
@@ -204,7 +238,7 @@ function mcpConfigUpdater(existing) {
204
238
  'nx-mcp': {
205
239
  type: 'stdio',
206
240
  command: 'npx',
207
- args: ['nx', 'mcp'],
241
+ args: mcpArgs,
208
242
  },
209
243
  };
210
244
  }
@@ -34,6 +34,10 @@ export interface ReportData {
34
34
  }[];
35
35
  migrateTarget: string;
36
36
  };
37
+ mismatchedNxVersions?: Array<{
38
+ version: string;
39
+ chain: string[];
40
+ }>;
37
41
  projectGraphError?: Error | null;
38
42
  nativeTarget: string | null;
39
43
  cache: {
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/report/report.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,cAAc,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,mBAAmB,EAAc,MAAM,sBAAsB,CAAC;AAQvE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAYrC,eAAO,MAAM,mBAAmB,UAO/B,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAMpE,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAsB,aAAa,kBAqKlC;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,cAAc,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,KAAK,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,WAAW,EAAE,CAAC;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,WAAW,EAAE,CAAC;IAChC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,0BAA0B,EAAE;QAC1B,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ,qBAAqB,CAAC,EAAE;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,kBAAkB,EAAE;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB,EAAE,CAAC;QACJ,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,iBAAiB,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI,CAAC;CACV;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,CA4DzD;AA6CD,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,WAAW,GAChB,SAAS,GAAG,qBAAqB,CAgCnC;AAED,wBAAgB,6BAA6B,IAAI,WAAW,EAAE,CAO7D;AAED,wBAAgB,6BAA6B,IAAI,WAAW,EAAE,CAW7D;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,mBAAmB,YAQzE;AAED,wBAAgB,gCAAgC;;;IAe/C"}
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/report/report.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,cAAc,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,mBAAmB,EAAc,MAAM,sBAAsB,CAAC;AAUvE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAYrC,eAAO,MAAM,mBAAmB,UAO/B,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAMpE,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAsB,aAAa,kBAgMlC;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,cAAc,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,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,8BAA8B,CAAC,MAAM,EAAE,mBAAmB,YAQzE;AAED,wBAAgB,gCAAgC;;;IAe/C"}
@@ -21,6 +21,8 @@ const installed_plugins_1 = require("../../utils/plugins/installed-plugins");
21
21
  const installation_directory_1 = require("../../utils/installation-directory");
22
22
  const nx_json_1 = require("../../config/nx-json");
23
23
  const error_types_1 = require("../../project-graph/error-types");
24
+ const operators_1 = require("../../project-graph/operators");
25
+ const versions_1 = require("../../utils/versions");
24
26
  const nx_key_1 = require("../../utils/nx-key");
25
27
  const cache_1 = require("../../tasks-runner/cache");
26
28
  const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '../../../package.json'));
@@ -47,7 +49,7 @@ const LINE_SEPARATOR = '---------------------------------------';
47
49
  *
48
50
  */
49
51
  async function reportHandler() {
50
- const { pm, pmVersion, nxKey, nxKeyError, localPlugins, powerpackPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, projectGraphError, nativeTarget, cache, } = await getReportData();
52
+ const { pm, pmVersion, nxKey, nxKeyError, localPlugins, powerpackPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, mismatchedNxVersions, projectGraphError, nativeTarget, cache, } = await getReportData();
51
53
  const fields = [
52
54
  ['Node', process.versions.node],
53
55
  ['OS', `${process.platform}-${process.arch}`],
@@ -137,6 +139,26 @@ async function reportHandler() {
137
139
  bodyLines.push('');
138
140
  bodyLines.push(`To fix this, run \`nx migrate ${outOfSyncPackageGroup.migrateTarget}\``);
139
141
  }
142
+ if (mismatchedNxVersions && mismatchedNxVersions.length > 0) {
143
+ bodyLines.push(LINE_SEPARATOR);
144
+ bodyLines.push(chalk.yellow('⚠️ Multiple Nx versions detected'));
145
+ bodyLines.push('');
146
+ bodyLines.push(`Your workspace uses nx@${versions_1.nxVersion}, but other packages depend on a different version:`);
147
+ for (const { version, chain } of mismatchedNxVersions) {
148
+ if (chain.length === 0) {
149
+ bodyLines.push(` - ${chalk.bold(`nx@${version}`)}`);
150
+ }
151
+ else {
152
+ bodyLines.push(` - ${chain.reverse().join(' → ')} → ${chalk.bold(`nx@${version}`)}`);
153
+ }
154
+ }
155
+ bodyLines.push('');
156
+ bodyLines.push('These packages should not have nx as a dependency. Please report this issue to the package maintainers.');
157
+ const whyCommand = (0, package_manager_1.getPackageManagerCommand)(pm).why;
158
+ for (const { version } of mismatchedNxVersions) {
159
+ bodyLines.push(`Run \`${whyCommand} nx@${version}\` for more details.`);
160
+ }
161
+ }
140
162
  if (projectGraphError) {
141
163
  bodyLines.push(LINE_SEPARATOR);
142
164
  bodyLines.push('⚠️ Unable to construct project graph.');
@@ -148,6 +170,53 @@ async function reportHandler() {
148
170
  bodyLines,
149
171
  });
150
172
  }
173
+ function findDependencyChain(graph, targetNode) {
174
+ const reversedGraph = (0, operators_1.reverse)(graph);
175
+ // BFS to find shortest path to root dependency
176
+ const queue = [
177
+ { node: targetNode, path: [] },
178
+ ];
179
+ const visited = new Set();
180
+ while (queue.length > 0) {
181
+ const { node, path } = queue.shift();
182
+ if (visited.has(node))
183
+ continue;
184
+ visited.add(node);
185
+ const deps = reversedGraph.dependencies[node] || [];
186
+ // Check for unvisited dependents
187
+ const unvisitedDeps = deps.filter((dep) => !visited.has(dep.target));
188
+ // No unvisited dependents - this is our shortest path
189
+ if (unvisitedDeps.length === 0) {
190
+ return path;
191
+ }
192
+ for (const dep of unvisitedDeps) {
193
+ const depName = graph.externalNodes?.[dep.target]?.data?.packageName ?? dep.target;
194
+ queue.push({
195
+ node: dep.target,
196
+ path: [...path, depName],
197
+ });
198
+ }
199
+ }
200
+ return [];
201
+ }
202
+ function findMismatchedNxVersions(graph) {
203
+ if (!graph || !graph.externalNodes) {
204
+ return [];
205
+ }
206
+ const result = [];
207
+ // Find all nx package versions that don't match the workspace version
208
+ for (const nodeName of Object.keys(graph.externalNodes)) {
209
+ const node = graph.externalNodes[nodeName];
210
+ if (node.data?.packageName === 'nx') {
211
+ const version = node.data.version || 'unknown';
212
+ if (version !== versions_1.nxVersion) {
213
+ const chain = findDependencyChain(graph, nodeName);
214
+ result.push({ version, chain });
215
+ }
216
+ }
217
+ }
218
+ return result;
219
+ }
151
220
  async function getReportData() {
152
221
  const pm = (0, package_manager_1.detectPackageManager)();
153
222
  const pmVersion = (0, package_manager_1.getPackageManagerVersion)(pm);
@@ -169,6 +238,7 @@ async function getReportData() {
169
238
  });
170
239
  }
171
240
  const outOfSyncPackageGroup = findMisalignedPackagesForPackage(nxPackageJson);
241
+ const mismatchedNxVersions = findMismatchedNxVersions(graph);
172
242
  const native = isNativeAvailable();
173
243
  let nxKey = null;
174
244
  let nxKeyError = null;
@@ -197,6 +267,7 @@ async function getReportData() {
197
267
  registeredPlugins,
198
268
  packageVersionsWeCareAbout,
199
269
  outOfSyncPackageGroup,
270
+ mismatchedNxVersions,
200
271
  projectGraphError,
201
272
  nativeTarget: native ? native.getBinaryTarget() : null,
202
273
  cache,