nx 22.5.0 → 22.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/package.json +13 -13
- package/schemas/nx-schema.json +5 -0
- package/schemas/project-schema.json +5 -0
- package/src/ai/constants.d.ts +8 -2
- package/src/ai/constants.d.ts.map +1 -1
- package/src/ai/constants.js +9 -6
- package/src/ai/detect-ai-agent.d.ts +3 -0
- package/src/ai/detect-ai-agent.d.ts.map +1 -0
- package/src/ai/detect-ai-agent.js +12 -0
- package/src/ai/set-up-ai-agents/get-agent-rules.d.ts +5 -1
- package/src/ai/set-up-ai-agents/get-agent-rules.d.ts.map +1 -1
- package/src/ai/set-up-ai-agents/get-agent-rules.js +4 -3
- package/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts.map +1 -1
- package/src/ai/set-up-ai-agents/set-up-ai-agents.js +82 -34
- package/src/ai/utils.d.ts.map +1 -1
- package/src/ai/utils.js +10 -9
- package/src/command-line/configure-ai-agents/configure-ai-agents.d.ts.map +1 -1
- package/src/command-line/configure-ai-agents/configure-ai-agents.js +56 -8
- package/src/command-line/init/ai-agent-prompts.d.ts.map +1 -1
- package/src/command-line/init/ai-agent-prompts.js +6 -1
- package/src/command-line/init/command-object.d.ts.map +1 -1
- package/src/command-line/init/command-object.js +34 -4
- package/src/command-line/init/init-v2.d.ts +2 -0
- package/src/command-line/init/init-v2.d.ts.map +1 -1
- package/src/command-line/init/init-v2.js +186 -19
- package/src/command-line/init/utils/ai-output.d.ts +112 -0
- package/src/command-line/init/utils/ai-output.d.ts.map +1 -0
- package/src/command-line/init/utils/ai-output.js +254 -0
- package/src/command-line/release/command-object.d.ts +1 -0
- package/src/command-line/release/command-object.d.ts.map +1 -1
- package/src/command-line/release/command-object.js +4 -0
- package/src/command-line/release/index.d.ts +1 -1
- package/src/command-line/release/index.d.ts.map +1 -1
- package/src/command-line/release/publish.d.ts.map +1 -1
- package/src/command-line/release/publish.js +56 -0
- package/src/command-line/release/release.d.ts +1 -1
- package/src/command-line/release/release.d.ts.map +1 -1
- package/src/command-line/yargs-utils/shared-options.d.ts +3 -0
- package/src/command-line/yargs-utils/shared-options.d.ts.map +1 -1
- package/src/command-line/yargs-utils/shared-options.js +30 -1
- package/src/config/workspace-json-project-json.d.ts +3 -0
- package/src/config/workspace-json-project-json.d.ts.map +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.d.ts +5 -0
- package/src/daemon/client/client.d.ts.map +1 -1
- package/src/daemon/client/client.js +15 -1
- package/src/daemon/message-types/configure-ai-agents.d.ts +21 -0
- package/src/daemon/message-types/configure-ai-agents.d.ts.map +1 -0
- package/src/daemon/message-types/configure-ai-agents.js +19 -0
- package/src/daemon/server/handle-configure-ai-agents.d.ts +4 -0
- package/src/daemon/server/handle-configure-ai-agents.d.ts.map +1 -0
- package/src/daemon/server/handle-configure-ai-agents.js +94 -0
- package/src/daemon/server/latest-nx.d.ts +11 -0
- package/src/daemon/server/latest-nx.d.ts.map +1 -0
- package/src/daemon/server/latest-nx.js +49 -0
- package/src/daemon/server/nx-console-operations.d.ts +0 -4
- package/src/daemon/server/nx-console-operations.d.ts.map +1 -1
- package/src/daemon/server/nx-console-operations.js +9 -48
- package/src/daemon/server/server.d.ts.map +1 -1
- package/src/daemon/server/server.js +12 -0
- package/src/daemon/server/shutdown-utils.js +3 -3
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +5 -0
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts.map +1 -1
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +12 -0
- package/src/hasher/task-hasher.d.ts +22 -0
- package/src/hasher/task-hasher.d.ts.map +1 -1
- package/src/hasher/task-hasher.js +35 -10
- package/src/native/index.d.ts +13 -5
- package/src/native/native-bindings.js +1 -0
- package/src/native/nx.wasi.cjs +13 -11
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/utils/register.d.ts.map +1 -1
- package/src/plugins/js/utils/register.js +14 -0
- package/src/project-graph/plugins/isolation/enabled.d.ts.map +1 -1
- package/src/project-graph/plugins/isolation/enabled.js +4 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts.map +1 -1
- package/src/project-graph/utils/project-configuration-utils.js +47 -10
- package/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/src/tasks-runner/forked-process-task-runner.d.ts.map +1 -1
- package/src/tasks-runner/forked-process-task-runner.js +3 -4
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +1 -0
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +1 -0
- package/src/tasks-runner/pseudo-ipc.d.ts.map +1 -1
- package/src/tasks-runner/pseudo-ipc.js +16 -0
- package/src/tasks-runner/run-command.d.ts.map +1 -1
- package/src/tasks-runner/run-command.js +18 -1
- package/src/tasks-runner/task-graph-utils.d.ts.map +1 -1
- package/src/tasks-runner/task-graph-utils.js +8 -2
- package/src/utils/is-sandbox.d.ts +2 -0
- package/src/utils/is-sandbox.d.ts.map +1 -0
- package/src/utils/is-sandbox.js +9 -0
- package/src/utils/nx-console-prompt.js +2 -2
- package/src/utils/output.d.ts +1 -0
- package/src/utils/output.d.ts.map +1 -1
- package/src/utils/output.js +10 -1
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.6.0-beta.0",
|
|
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": {
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"yargs-parser": "21.1.1"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@swc-node/register": "1.11.1",
|
|
76
|
-
"@swc/core": "1.15.8"
|
|
75
|
+
"@swc-node/register": "^1.11.1",
|
|
76
|
+
"@swc/core": "^1.15.8"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"@swc-node/register": {
|
|
@@ -84,16 +84,16 @@
|
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
"optionalDependencies": {
|
|
87
|
-
"@nx/nx-darwin-arm64": "22.
|
|
88
|
-
"@nx/nx-darwin-x64": "22.
|
|
89
|
-
"@nx/nx-freebsd-x64": "22.
|
|
90
|
-
"@nx/nx-linux-arm-gnueabihf": "22.
|
|
91
|
-
"@nx/nx-linux-arm64-gnu": "22.
|
|
92
|
-
"@nx/nx-linux-arm64-musl": "22.
|
|
93
|
-
"@nx/nx-linux-x64-gnu": "22.
|
|
94
|
-
"@nx/nx-linux-x64-musl": "22.
|
|
95
|
-
"@nx/nx-win32-arm64-msvc": "22.
|
|
96
|
-
"@nx/nx-win32-x64-msvc": "22.
|
|
87
|
+
"@nx/nx-darwin-arm64": "22.6.0-beta.0",
|
|
88
|
+
"@nx/nx-darwin-x64": "22.6.0-beta.0",
|
|
89
|
+
"@nx/nx-freebsd-x64": "22.6.0-beta.0",
|
|
90
|
+
"@nx/nx-linux-arm-gnueabihf": "22.6.0-beta.0",
|
|
91
|
+
"@nx/nx-linux-arm64-gnu": "22.6.0-beta.0",
|
|
92
|
+
"@nx/nx-linux-arm64-musl": "22.6.0-beta.0",
|
|
93
|
+
"@nx/nx-linux-x64-gnu": "22.6.0-beta.0",
|
|
94
|
+
"@nx/nx-linux-x64-musl": "22.6.0-beta.0",
|
|
95
|
+
"@nx/nx-win32-arm64-msvc": "22.6.0-beta.0",
|
|
96
|
+
"@nx/nx-win32-x64-msvc": "22.6.0-beta.0"
|
|
97
97
|
},
|
|
98
98
|
"nx-migrations": {
|
|
99
99
|
"migrations": "./migrations.json",
|
package/schemas/nx-schema.json
CHANGED
|
@@ -560,8 +560,13 @@
|
|
|
560
560
|
"fileset": {
|
|
561
561
|
"type": "string",
|
|
562
562
|
"description": "A glob"
|
|
563
|
+
},
|
|
564
|
+
"dependencies": {
|
|
565
|
+
"type": "boolean",
|
|
566
|
+
"description": "Include files matching the fileset for all the project dependencies of this target."
|
|
563
567
|
}
|
|
564
568
|
},
|
|
569
|
+
"required": ["fileset"],
|
|
565
570
|
"additionalProperties": false
|
|
566
571
|
},
|
|
567
572
|
{
|
|
@@ -216,8 +216,13 @@
|
|
|
216
216
|
"fileset": {
|
|
217
217
|
"type": "string",
|
|
218
218
|
"description": "A glob used to determine a fileset."
|
|
219
|
+
},
|
|
220
|
+
"dependencies": {
|
|
221
|
+
"type": "boolean",
|
|
222
|
+
"description": "Include files matching the fileset for all the project dependencies of this target."
|
|
219
223
|
}
|
|
220
224
|
},
|
|
225
|
+
"required": ["fileset"],
|
|
221
226
|
"additionalProperties": false
|
|
222
227
|
},
|
|
223
228
|
{
|
package/src/ai/constants.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AgentRulesOptions } from './set-up-ai-agents/get-agent-rules';
|
|
2
|
+
export type { AgentRulesOptions };
|
|
1
3
|
export declare function agentsMdPath(root: string): string;
|
|
2
4
|
export declare function geminiMdPath(root: string): string;
|
|
3
5
|
export declare function parseGeminiSettings(root: string): any | undefined;
|
|
@@ -5,12 +7,16 @@ export declare function geminiSettingsPath(root: string): string;
|
|
|
5
7
|
export declare function claudeMdPath(root: string): string;
|
|
6
8
|
export declare function claudeMcpJsonPath(root: string): string;
|
|
7
9
|
export declare function opencodeMcpPath(root: string): string;
|
|
8
|
-
export declare
|
|
10
|
+
export declare function codexConfigTomlPath(root: string): string;
|
|
9
11
|
export declare const nxRulesMarkerCommentStart = "<!-- nx configuration start-->";
|
|
10
12
|
export declare const nxRulesMarkerCommentDescription = "<!-- Leave the start & end comments to automatically receive updates. -->";
|
|
11
13
|
export declare const nxRulesMarkerCommentEnd = "<!-- nx configuration end-->";
|
|
12
14
|
export declare const rulesRegex: RegExp;
|
|
13
|
-
export
|
|
15
|
+
export interface AgentRulesWrappedOptions {
|
|
16
|
+
writeNxCloudRules: boolean;
|
|
17
|
+
useH1?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const getAgentRulesWrapped: (options: AgentRulesWrappedOptions) => string;
|
|
14
20
|
export declare const nxMcpTomlHeader = "[mcp_servers.\"nx-mcp\"]";
|
|
15
21
|
/**
|
|
16
22
|
* Get the MCP TOML configuration based on the Nx version.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/ai/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/ai/constants.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,iBAAiB,EAClB,MAAM,oCAAoC,CAAC;AAE5C,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,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,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,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,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,GAAI,SAAS,wBAAwB,WAIrE,CAAC;AAEF,eAAO,MAAM,eAAe,6BAA2B,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAQ5D"}
|
package/src/ai/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nxMcpTomlHeader = exports.getAgentRulesWrapped = exports.rulesRegex = exports.nxRulesMarkerCommentEnd = exports.nxRulesMarkerCommentDescription = exports.nxRulesMarkerCommentStart =
|
|
3
|
+
exports.nxMcpTomlHeader = exports.getAgentRulesWrapped = exports.rulesRegex = exports.nxRulesMarkerCommentEnd = exports.nxRulesMarkerCommentDescription = exports.nxRulesMarkerCommentStart = void 0;
|
|
4
4
|
exports.agentsMdPath = agentsMdPath;
|
|
5
5
|
exports.geminiMdPath = geminiMdPath;
|
|
6
6
|
exports.parseGeminiSettings = parseGeminiSettings;
|
|
@@ -8,8 +8,8 @@ exports.geminiSettingsPath = geminiSettingsPath;
|
|
|
8
8
|
exports.claudeMdPath = claudeMdPath;
|
|
9
9
|
exports.claudeMcpJsonPath = claudeMcpJsonPath;
|
|
10
10
|
exports.opencodeMcpPath = opencodeMcpPath;
|
|
11
|
+
exports.codexConfigTomlPath = codexConfigTomlPath;
|
|
11
12
|
exports.getNxMcpTomlConfig = getNxMcpTomlConfig;
|
|
12
|
-
const os_1 = require("os");
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const semver_1 = require("semver");
|
|
15
15
|
const fileutils_1 = require("../utils/fileutils");
|
|
@@ -41,14 +41,17 @@ function claudeMcpJsonPath(root) {
|
|
|
41
41
|
function opencodeMcpPath(root) {
|
|
42
42
|
return (0, path_1.join)(root, 'opencode.json');
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
function codexConfigTomlPath(root) {
|
|
45
|
+
return (0, path_1.join)(root, '.codex', 'config.toml');
|
|
46
|
+
}
|
|
45
47
|
exports.nxRulesMarkerCommentStart = `<!-- nx configuration start-->`;
|
|
46
48
|
exports.nxRulesMarkerCommentDescription = `<!-- Leave the start & end comments to automatically receive updates. -->`;
|
|
47
49
|
exports.nxRulesMarkerCommentEnd = `<!-- nx configuration end-->`;
|
|
48
50
|
exports.rulesRegex = new RegExp(`${exports.nxRulesMarkerCommentStart}[\\s\\S]*?${exports.nxRulesMarkerCommentEnd}`, 'm');
|
|
49
|
-
const getAgentRulesWrapped = (
|
|
50
|
-
const
|
|
51
|
-
|
|
51
|
+
const getAgentRulesWrapped = (options) => {
|
|
52
|
+
const { writeNxCloudRules, useH1 = true } = options;
|
|
53
|
+
const agentRulesString = (0, get_agent_rules_1.getAgentRules)({ nxCloud: writeNxCloudRules, useH1 });
|
|
54
|
+
return `${exports.nxRulesMarkerCommentStart}\n${exports.nxRulesMarkerCommentDescription}\n\n${agentRulesString}\n\n${exports.nxRulesMarkerCommentEnd}`;
|
|
52
55
|
};
|
|
53
56
|
exports.getAgentRulesWrapped = getAgentRulesWrapped;
|
|
54
57
|
exports.nxMcpTomlHeader = `[mcp_servers."nx-mcp"]`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-ai-agent.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/ai/detect-ai-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAmB,MAAM,SAAS,CAAC;AAEjD,wBAAgB,aAAa,IAAI,KAAK,GAAG,IAAI,CAM5C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectAiAgent = detectAiAgent;
|
|
4
|
+
const native_1 = require("../native");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
function detectAiAgent() {
|
|
7
|
+
const detected = (0, native_1.detectAiAgent)();
|
|
8
|
+
if (detected && utils_1.supportedAgents.includes(detected)) {
|
|
9
|
+
return detected;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface AgentRulesOptions {
|
|
2
|
+
nxCloud: boolean;
|
|
3
|
+
useH1?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function getAgentRules(options: AgentRulesOptions): string;
|
|
2
6
|
//# sourceMappingURL=get-agent-rules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-agent-rules.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/ai/set-up-ai-agents/get-agent-rules.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get-agent-rules.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/ai/set-up-ai-agents/get-agent-rules.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,UAsBvD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAgentRules = getAgentRules;
|
|
4
|
-
function getAgentRules(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function getAgentRules(options) {
|
|
5
|
+
const { nxCloud, useH1 = true } = options;
|
|
6
|
+
const header = useH1 ? '#' : '##';
|
|
7
|
+
return `${header} General Guidelines for working with Nx
|
|
7
8
|
|
|
8
9
|
- For navigating/exploring the workspace, invoke the \`nx-workspace\` skill first - it has patterns for querying projects, targets, and dependencies
|
|
9
10
|
- When running tasks (for example build, lint, test, e2e, etc.), always prefer running the task through \`nx\` (i.e. \`nx run\`, \`nx run-many\`, \`nx affected\`) instead of using the underlying tooling directly
|
|
@@ -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":"
|
|
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":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAS7C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAwB5B,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,CAgO7C;AAqJD,eAAe,sBAAsB,CAAC"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setupAiAgentsGenerator = setupAiAgentsGenerator;
|
|
4
4
|
exports.setupAiAgentsGeneratorImpl = setupAiAgentsGeneratorImpl;
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const os_1 = require("os");
|
|
7
6
|
const path_1 = require("path");
|
|
8
7
|
const semver_1 = require("semver");
|
|
9
8
|
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
|
@@ -138,6 +137,19 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
|
|
|
138
137
|
}
|
|
139
138
|
(0, json_1.updateJson)(tree, opencodeMcpJsonPath, (json) => opencodeMcpConfigUpdater(json, nxVersion));
|
|
140
139
|
}
|
|
140
|
+
if (hasAgent('codex')) {
|
|
141
|
+
const codexTomlPath = (0, path_1.join)(options.directory, '.codex', 'config.toml');
|
|
142
|
+
const tomlConfig = (0, constants_2.getNxMcpTomlConfig)(nxVersion);
|
|
143
|
+
if (!tree.exists(codexTomlPath)) {
|
|
144
|
+
tree.write(codexTomlPath, tomlConfig);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const existing = tree.read(codexTomlPath, 'utf-8');
|
|
148
|
+
if (!existing.includes(constants_2.nxMcpTomlHeader)) {
|
|
149
|
+
tree.write(codexTomlPath, existing + '\n' + tomlConfig);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
141
153
|
if (hasAgent('gemini')) {
|
|
142
154
|
const geminiSettingsPath = (0, path_1.join)(options.directory, '.gemini', 'settings.json');
|
|
143
155
|
if (!tree.exists(geminiSettingsPath)) {
|
|
@@ -169,7 +181,7 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
|
|
|
169
181
|
{ agent: 'opencode', src: 'generated/.opencode', dest: '.opencode' },
|
|
170
182
|
{ agent: 'copilot', src: 'generated/.github', dest: '.github' },
|
|
171
183
|
{ agent: 'cursor', src: 'generated/.cursor', dest: '.cursor' },
|
|
172
|
-
{ agent: 'codex', src: 'generated/.
|
|
184
|
+
{ agent: 'codex', src: 'generated/.agents', dest: '.agents' },
|
|
173
185
|
{ agent: 'gemini', src: 'generated/.gemini', dest: '.gemini' },
|
|
174
186
|
];
|
|
175
187
|
for (const { agent, src, dest } of agentDirs) {
|
|
@@ -186,34 +198,12 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
|
|
|
186
198
|
return async (check = false) => {
|
|
187
199
|
const messages = [];
|
|
188
200
|
const errors = [];
|
|
189
|
-
if (hasAgent('codex')) {
|
|
190
|
-
if ((0, fs_1.existsSync)(constants_1.codexConfigTomlPath)) {
|
|
191
|
-
const tomlContents = (0, fs_1.readFileSync)(constants_1.codexConfigTomlPath, 'utf-8');
|
|
192
|
-
if (!tomlContents.includes(constants_2.nxMcpTomlHeader)) {
|
|
193
|
-
if (!check) {
|
|
194
|
-
(0, fs_1.appendFileSync)(constants_1.codexConfigTomlPath, `\n${(0, constants_2.getNxMcpTomlConfig)(nxVersion)}`);
|
|
195
|
-
}
|
|
196
|
-
messages.push({
|
|
197
|
-
title: `Updated ${constants_1.codexConfigTomlPath} with nx-mcp server`,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
if (!check) {
|
|
203
|
-
(0, fs_1.mkdirSync)((0, path_1.join)((0, os_1.homedir)(), '.codex'), { recursive: true });
|
|
204
|
-
(0, fs_1.writeFileSync)(constants_1.codexConfigTomlPath, (0, constants_2.getNxMcpTomlConfig)(nxVersion));
|
|
205
|
-
}
|
|
206
|
-
messages.push({
|
|
207
|
-
title: `Created ${constants_1.codexConfigTomlPath} with nx-mcp server`,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
201
|
if (hasAgent('copilot')) {
|
|
212
202
|
try {
|
|
213
|
-
if ((0, native_1.isEditorInstalled)(0 /* SupportedEditor.VSCode */) &&
|
|
214
|
-
(0, native_1.canInstallNxConsoleForEditor)(0 /* SupportedEditor.VSCode */)) {
|
|
203
|
+
if ((await (0, native_1.isEditorInstalled)(0 /* SupportedEditor.VSCode */)) &&
|
|
204
|
+
(await (0, native_1.canInstallNxConsoleForEditor)(0 /* SupportedEditor.VSCode */))) {
|
|
215
205
|
if (!check) {
|
|
216
|
-
(0, native_1.installNxConsoleForEditor)(0 /* SupportedEditor.VSCode */);
|
|
206
|
+
await (0, native_1.installNxConsoleForEditor)(0 /* SupportedEditor.VSCode */);
|
|
217
207
|
}
|
|
218
208
|
messages.push({
|
|
219
209
|
title: `Installed Nx Console for VSCode`,
|
|
@@ -227,10 +217,10 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
|
|
|
227
217
|
});
|
|
228
218
|
}
|
|
229
219
|
try {
|
|
230
|
-
if ((0, native_1.isEditorInstalled)(1 /* SupportedEditor.VSCodeInsiders */) &&
|
|
231
|
-
(0, native_1.canInstallNxConsoleForEditor)(1 /* SupportedEditor.VSCodeInsiders */)) {
|
|
220
|
+
if ((await (0, native_1.isEditorInstalled)(1 /* SupportedEditor.VSCodeInsiders */)) &&
|
|
221
|
+
(await (0, native_1.canInstallNxConsoleForEditor)(1 /* SupportedEditor.VSCodeInsiders */))) {
|
|
232
222
|
if (!check) {
|
|
233
|
-
(0, native_1.installNxConsoleForEditor)(1 /* SupportedEditor.VSCodeInsiders */);
|
|
223
|
+
await (0, native_1.installNxConsoleForEditor)(1 /* SupportedEditor.VSCodeInsiders */);
|
|
234
224
|
}
|
|
235
225
|
messages.push({
|
|
236
226
|
title: `Installed Nx Console for VSCode Insiders`,
|
|
@@ -246,10 +236,10 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
|
|
|
246
236
|
}
|
|
247
237
|
if (hasAgent('cursor')) {
|
|
248
238
|
try {
|
|
249
|
-
if ((0, native_1.isEditorInstalled)(2 /* SupportedEditor.Cursor */) &&
|
|
250
|
-
(0, native_1.canInstallNxConsoleForEditor)(2 /* SupportedEditor.Cursor */)) {
|
|
239
|
+
if ((await (0, native_1.isEditorInstalled)(2 /* SupportedEditor.Cursor */)) &&
|
|
240
|
+
(await (0, native_1.canInstallNxConsoleForEditor)(2 /* SupportedEditor.Cursor */))) {
|
|
251
241
|
if (!check) {
|
|
252
|
-
(0, native_1.installNxConsoleForEditor)(2 /* SupportedEditor.Cursor */);
|
|
242
|
+
await (0, native_1.installNxConsoleForEditor)(2 /* SupportedEditor.Cursor */);
|
|
253
243
|
}
|
|
254
244
|
messages.push({
|
|
255
245
|
title: `Installed Nx Console for Cursor`,
|
|
@@ -270,8 +260,12 @@ async function setupAiAgentsGeneratorImpl(tree, options) {
|
|
|
270
260
|
};
|
|
271
261
|
}
|
|
272
262
|
function writeAgentRules(tree, path, writeNxCloudRules) {
|
|
273
|
-
const expectedRules = (0, constants_2.getAgentRulesWrapped)(writeNxCloudRules);
|
|
274
263
|
if (!tree.exists(path)) {
|
|
264
|
+
// File doesn't exist - create with h1 header (standalone content)
|
|
265
|
+
const expectedRules = (0, constants_2.getAgentRulesWrapped)({
|
|
266
|
+
writeNxCloudRules,
|
|
267
|
+
useH1: true,
|
|
268
|
+
});
|
|
275
269
|
tree.write(path, expectedRules);
|
|
276
270
|
return;
|
|
277
271
|
}
|
|
@@ -279,6 +273,14 @@ function writeAgentRules(tree, path, writeNxCloudRules) {
|
|
|
279
273
|
const regex = constants_2.rulesRegex;
|
|
280
274
|
const existingNxConfiguration = existing.match(regex);
|
|
281
275
|
if (existingNxConfiguration) {
|
|
276
|
+
// Check the rest of the file (outside nx block) for an h1 header
|
|
277
|
+
// to ensure only one h1 exists in the document
|
|
278
|
+
const contentWithoutNxBlock = existing.replace(regex, '');
|
|
279
|
+
const hasExternalH1 = /^# /m.test(contentWithoutNxBlock);
|
|
280
|
+
const expectedRules = (0, constants_2.getAgentRulesWrapped)({
|
|
281
|
+
writeNxCloudRules,
|
|
282
|
+
useH1: !hasExternalH1,
|
|
283
|
+
});
|
|
282
284
|
const contentOnly = (str) => str
|
|
283
285
|
.replace(constants_2.nxRulesMarkerCommentStart, '')
|
|
284
286
|
.replace(constants_2.nxRulesMarkerCommentEnd, '')
|
|
@@ -293,12 +295,52 @@ function writeAgentRules(tree, path, writeNxCloudRules) {
|
|
|
293
295
|
tree.write(path, updatedContent);
|
|
294
296
|
}
|
|
295
297
|
else {
|
|
298
|
+
// Appending to existing content - use h2 only if the file already has an h1 header
|
|
299
|
+
// This prevents unnecessary changes when users add content without their own h1
|
|
300
|
+
const hasExistingH1 = /^# /m.test(existing);
|
|
301
|
+
const expectedRules = (0, constants_2.getAgentRulesWrapped)({
|
|
302
|
+
writeNxCloudRules,
|
|
303
|
+
useH1: !hasExistingH1,
|
|
304
|
+
});
|
|
296
305
|
tree.write(path, existing + '\n\n' + expectedRules);
|
|
297
306
|
}
|
|
298
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Extract user-added extra args/flags from an existing MCP config args array
|
|
310
|
+
* by stripping the known base command prefix.
|
|
311
|
+
*
|
|
312
|
+
* Known base patterns (matched in order, first wins):
|
|
313
|
+
* ['nx', 'mcp'] or ['nx-mcp'] (possibly with @version suffix like nx-mcp@latest)
|
|
314
|
+
* For opencode the caller prepends 'npx' to these patterns.
|
|
315
|
+
*/
|
|
316
|
+
function getExtraMcpArgs(existingArgs, knownBasePatterns) {
|
|
317
|
+
if (!Array.isArray(existingArgs) || existingArgs.length === 0)
|
|
318
|
+
return [];
|
|
319
|
+
for (const pattern of knownBasePatterns) {
|
|
320
|
+
if (existingArgs.length < pattern.length)
|
|
321
|
+
continue;
|
|
322
|
+
const matches = pattern.every((baseArg, i) => {
|
|
323
|
+
if (baseArg === 'nx-mcp') {
|
|
324
|
+
// Also match versioned variants like nx-mcp@latest
|
|
325
|
+
return (existingArgs[i] === 'nx-mcp' || existingArgs[i].startsWith('nx-mcp@'));
|
|
326
|
+
}
|
|
327
|
+
return existingArgs[i] === baseArg;
|
|
328
|
+
});
|
|
329
|
+
if (matches) {
|
|
330
|
+
return existingArgs.slice(pattern.length);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return [];
|
|
334
|
+
}
|
|
299
335
|
function mcpConfigUpdater(existing, nxVersion) {
|
|
300
336
|
const majorVersion = (0, semver_1.major)(nxVersion);
|
|
301
337
|
const mcpArgs = majorVersion >= 22 ? ['nx', 'mcp'] : ['nx-mcp'];
|
|
338
|
+
// Preserve any extra args (e.g. --experimental-polygraph, --transport http) from existing config
|
|
339
|
+
const extraArgs = getExtraMcpArgs(existing.mcpServers?.['nx-mcp']?.args, [
|
|
340
|
+
['nx', 'mcp'],
|
|
341
|
+
['nx-mcp'],
|
|
342
|
+
]);
|
|
343
|
+
mcpArgs.push(...extraArgs);
|
|
302
344
|
if (existing.mcpServers) {
|
|
303
345
|
existing.mcpServers['nx-mcp'] = {
|
|
304
346
|
type: 'stdio',
|
|
@@ -320,6 +362,12 @@ function mcpConfigUpdater(existing, nxVersion) {
|
|
|
320
362
|
function opencodeMcpConfigUpdater(existing, nxVersion) {
|
|
321
363
|
const majorVersion = (0, semver_1.major)(nxVersion);
|
|
322
364
|
const mcpCommand = majorVersion >= 22 ? ['npx', 'nx', 'mcp'] : ['npx', 'nx-mcp'];
|
|
365
|
+
// Preserve any extra args (e.g. --experimental-polygraph, --transport http) from existing config
|
|
366
|
+
const extraArgs = getExtraMcpArgs(existing.mcp?.['nx-mcp']?.command, [
|
|
367
|
+
['npx', 'nx', 'mcp'],
|
|
368
|
+
['npx', 'nx-mcp'],
|
|
369
|
+
]);
|
|
370
|
+
mcpCommand.push(...extraArgs);
|
|
323
371
|
if (existing.mcp) {
|
|
324
372
|
existing.mcp['nx-mcp'] = {
|
|
325
373
|
type: 'local',
|
package/src/ai/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/ai/utils.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,eAAe,yEAOlB,CAAC;AACX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAOjD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,gBAAgB,EAAE,KAAK,EAAE,EACzB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IACT,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,yBAAyB,EAAE,kBAAkB,EAAE,CAAC;IAChD,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;IAC5C,cAAc,EAAE,kBAAkB,EAAE,CAAC;CACtC,CAAC,CA2BD;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/ai/utils.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,eAAe,yEAOlB,CAAC;AACX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAOjD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,gBAAgB,EAAE,KAAK,EAAE,EACzB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IACT,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,yBAAyB,EAAE,kBAAkB,EAAE,CAAC;IAChD,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;IAC5C,cAAc,EAAE,kBAAkB,EAAE,CAAC;CACtC,CAAC,CA2BD;AAyLD,wBAAsB,eAAe,CACnC,MAAM,EAAE,KAAK,EAAE,EACf,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|
package/src/ai/utils.js
CHANGED
|
@@ -108,12 +108,12 @@ async function getAgentConfiguration(agent, workspaceRoot) {
|
|
|
108
108
|
}
|
|
109
109
|
case 'copilot': {
|
|
110
110
|
const rulesPath = (0, constants_1.agentsMdPath)(workspaceRoot);
|
|
111
|
-
const hasInstalledVSCode = (0, native_1.isEditorInstalled)(0 /* SupportedEditor.VSCode */);
|
|
112
|
-
const hasInstalledVSCodeInsiders = (0, native_1.isEditorInstalled)(1 /* SupportedEditor.VSCodeInsiders */);
|
|
111
|
+
const hasInstalledVSCode = await (0, native_1.isEditorInstalled)(0 /* SupportedEditor.VSCode */);
|
|
112
|
+
const hasInstalledVSCodeInsiders = await (0, native_1.isEditorInstalled)(1 /* SupportedEditor.VSCodeInsiders */);
|
|
113
113
|
const hasInstalledNxConsoleForVSCode = hasInstalledVSCode &&
|
|
114
|
-
!(0, native_1.canInstallNxConsoleForEditor)(0 /* SupportedEditor.VSCode */);
|
|
114
|
+
!(await (0, native_1.canInstallNxConsoleForEditor)(0 /* SupportedEditor.VSCode */));
|
|
115
115
|
const hasInstalledNxConsoleForVSCodeInsiders = hasInstalledVSCodeInsiders &&
|
|
116
|
-
!(0, native_1.canInstallNxConsoleForEditor)(1 /* SupportedEditor.VSCodeInsiders */);
|
|
116
|
+
!(await (0, native_1.canInstallNxConsoleForEditor)(1 /* SupportedEditor.VSCodeInsiders */));
|
|
117
117
|
const agentsMdExists = (0, fs_1.existsSync)(rulesPath);
|
|
118
118
|
agentConfiguration = {
|
|
119
119
|
mcp: hasInstalledNxConsoleForVSCode ||
|
|
@@ -127,8 +127,8 @@ async function getAgentConfiguration(agent, workspaceRoot) {
|
|
|
127
127
|
}
|
|
128
128
|
case 'cursor': {
|
|
129
129
|
const rulesPath = (0, constants_1.agentsMdPath)(workspaceRoot);
|
|
130
|
-
const hasInstalledCursor = (0, native_1.isEditorInstalled)(2 /* SupportedEditor.Cursor */);
|
|
131
|
-
const hasInstalledNxConsole = !(0, native_1.canInstallNxConsoleForEditor)(2 /* SupportedEditor.Cursor */);
|
|
130
|
+
const hasInstalledCursor = await (0, native_1.isEditorInstalled)(2 /* SupportedEditor.Cursor */);
|
|
131
|
+
const hasInstalledNxConsole = !(await (0, native_1.canInstallNxConsoleForEditor)(2 /* SupportedEditor.Cursor */));
|
|
132
132
|
const agentsMdExists = (0, fs_1.existsSync)(rulesPath);
|
|
133
133
|
agentConfiguration = {
|
|
134
134
|
mcp: hasInstalledCursor ? hasInstalledNxConsole : false,
|
|
@@ -142,9 +142,10 @@ async function getAgentConfiguration(agent, workspaceRoot) {
|
|
|
142
142
|
case 'codex': {
|
|
143
143
|
const rulesPath = (0, constants_1.agentsMdPath)(workspaceRoot);
|
|
144
144
|
const agentsMdExists = (0, fs_1.existsSync)(rulesPath);
|
|
145
|
+
const mcpPath = (0, constants_1.codexConfigTomlPath)(workspaceRoot);
|
|
145
146
|
let mcpConfigured;
|
|
146
|
-
if ((0, fs_1.existsSync)(
|
|
147
|
-
const tomlContents = (0, fs_1.readFileSync)(
|
|
147
|
+
if ((0, fs_1.existsSync)(mcpPath)) {
|
|
148
|
+
const tomlContents = (0, fs_1.readFileSync)(mcpPath, 'utf-8');
|
|
148
149
|
mcpConfigured = tomlContents.includes(constants_1.nxMcpTomlHeader);
|
|
149
150
|
}
|
|
150
151
|
else {
|
|
@@ -154,7 +155,7 @@ async function getAgentConfiguration(agent, workspaceRoot) {
|
|
|
154
155
|
mcp: mcpConfigured,
|
|
155
156
|
rules: agentsMdExists,
|
|
156
157
|
rulesPath,
|
|
157
|
-
mcpPath
|
|
158
|
+
mcpPath,
|
|
158
159
|
};
|
|
159
160
|
break;
|
|
160
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure-ai-agents.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/configure-ai-agents/configure-ai-agents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configure-ai-agents.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/configure-ai-agents/configure-ai-agents.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,wBAAwB,EAC9B,KAAK,UAAQ,GACZ,OAAO,CAAC,IAAI,CAAC,CAsDf;AAED,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAyOf"}
|
|
@@ -8,17 +8,35 @@ const node_path_1 = require("node:path");
|
|
|
8
8
|
const pc = require("picocolors");
|
|
9
9
|
const constants_1 = require("../../ai/constants");
|
|
10
10
|
const utils_1 = require("../../ai/utils");
|
|
11
|
+
const client_1 = require("../../daemon/client/client");
|
|
11
12
|
const devkit_internals_1 = require("../../devkit-internals");
|
|
12
13
|
const output_1 = require("../../utils/output");
|
|
14
|
+
const package_manager_1 = require("../../utils/package-manager");
|
|
13
15
|
const provenance_1 = require("../../utils/provenance");
|
|
16
|
+
const versions_1 = require("../../utils/versions");
|
|
14
17
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
15
18
|
const ora = require("ora");
|
|
16
19
|
async function configureAiAgentsHandler(args, inner = false) {
|
|
20
|
+
// When called as inner from the tmp install, just run the impl directly
|
|
21
|
+
if (inner) {
|
|
22
|
+
return await configureAiAgentsHandlerImpl(args);
|
|
23
|
+
}
|
|
17
24
|
// Use environment variable to force local execution
|
|
18
25
|
if (process.env.NX_USE_LOCAL === 'true' ||
|
|
19
|
-
process.env.NX_AI_FILES_USE_LOCAL === 'true'
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
process.env.NX_AI_FILES_USE_LOCAL === 'true') {
|
|
27
|
+
await configureAiAgentsHandlerImpl(args);
|
|
28
|
+
await resetDaemonAgentStatus();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Skip downloading latest if the current version is already the latest
|
|
32
|
+
try {
|
|
33
|
+
const latestVersion = await (0, package_manager_1.resolvePackageVersionUsingRegistry)('nx', 'latest');
|
|
34
|
+
if (latestVersion === versions_1.nxVersion) {
|
|
35
|
+
return await configureAiAgentsHandlerImpl(args);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// If we can't check, proceed with download
|
|
22
40
|
}
|
|
23
41
|
let cleanup;
|
|
24
42
|
try {
|
|
@@ -27,19 +45,31 @@ async function configureAiAgentsHandler(args, inner = false) {
|
|
|
27
45
|
cleanup = packageInstallResults.cleanup;
|
|
28
46
|
let modulePath = require.resolve('nx/src/command-line/configure-ai-agents/configure-ai-agents.js', { paths: [packageInstallResults.tempDir] });
|
|
29
47
|
const module = await Promise.resolve(`${modulePath}`).then(s => require(s));
|
|
30
|
-
|
|
48
|
+
await module.configureAiAgentsHandler(args, true);
|
|
31
49
|
cleanup();
|
|
32
|
-
return configureAiAgentsResult;
|
|
33
50
|
}
|
|
34
51
|
catch (error) {
|
|
35
52
|
if (cleanup) {
|
|
36
53
|
cleanup();
|
|
37
54
|
}
|
|
38
55
|
// Fall back to local implementation
|
|
39
|
-
|
|
56
|
+
await configureAiAgentsHandlerImpl(args);
|
|
40
57
|
}
|
|
58
|
+
// Reset daemon cache using the local daemon client (the inner handler's
|
|
59
|
+
// client belongs to the tmp install and isn't connected to our daemon)
|
|
60
|
+
await resetDaemonAgentStatus();
|
|
41
61
|
}
|
|
42
62
|
async function configureAiAgentsHandlerImpl(options) {
|
|
63
|
+
// Node 24 has stricter readline behavior, and enquirer is not checking for closed state
|
|
64
|
+
// when invoking operations, thus you get an ERR_USE_AFTER_CLOSE error.
|
|
65
|
+
process.on('uncaughtException', (error) => {
|
|
66
|
+
if (error &&
|
|
67
|
+
typeof error === 'object' &&
|
|
68
|
+
'code' in error &&
|
|
69
|
+
error['code'] === 'ERR_USE_AFTER_CLOSE')
|
|
70
|
+
return;
|
|
71
|
+
throw error;
|
|
72
|
+
});
|
|
43
73
|
const normalizedOptions = normalizeOptions(options);
|
|
44
74
|
const { nonConfiguredAgents, partiallyConfiguredAgents, fullyConfiguredAgents, disabledAgents, } = await (0, utils_1.getAgentConfigurations)(normalizedOptions.agents, workspace_root_1.workspaceRoot);
|
|
45
75
|
if (disabledAgents.length > 0) {
|
|
@@ -249,7 +279,7 @@ function getAgentFooterDescription(agent) {
|
|
|
249
279
|
case 'opencode':
|
|
250
280
|
return `Configures MCP server. Adds skills and agents. Updates ${rulesFile}.`;
|
|
251
281
|
case 'codex':
|
|
252
|
-
return `Configures MCP server. Updates ${rulesFile}.`;
|
|
282
|
+
return `Configures MCP server. Adds skills. Updates ${rulesFile}.`;
|
|
253
283
|
default:
|
|
254
284
|
return '';
|
|
255
285
|
}
|
|
@@ -271,7 +301,7 @@ function getAgentConfiguredDescription(agent) {
|
|
|
271
301
|
case 'opencode':
|
|
272
302
|
return `MCP + skills + ${rulesFile}`;
|
|
273
303
|
case 'codex':
|
|
274
|
-
return `MCP + ${rulesFile}`;
|
|
304
|
+
return `MCP + skills + ${rulesFile}`;
|
|
275
305
|
default:
|
|
276
306
|
return '';
|
|
277
307
|
}
|
|
@@ -297,3 +327,21 @@ function normalizeOptions(options) {
|
|
|
297
327
|
check,
|
|
298
328
|
};
|
|
299
329
|
}
|
|
330
|
+
async function resetDaemonAgentStatus() {
|
|
331
|
+
try {
|
|
332
|
+
// Don't check daemonClient.enabled() — the CLI sets NX_DAEMON=false for
|
|
333
|
+
// configure-ai-agents (it doesn't need the daemon to do its work), but a
|
|
334
|
+
// daemon started by a previous command may still be running and serving
|
|
335
|
+
// cached status. We just need to reach it to reset its cache.
|
|
336
|
+
if (await client_1.daemonClient.isServerAvailable()) {
|
|
337
|
+
await client_1.daemonClient.resetConfigureAiAgentsStatus();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
catch {
|
|
341
|
+
// Daemon may not be running, that's fine
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
// Close the daemon socket so the process can exit cleanly.
|
|
345
|
+
client_1.daemonClient.reset();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-agent-prompts.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/init/ai-agent-prompts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAoC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-agent-prompts.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/init/ai-agent-prompts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAoC,MAAM,gBAAgB,CAAC;AAIzE,wBAAsB,iBAAiB,CACrC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAClB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,KAAK,EAAE,CAAC,CAalB"}
|
|
@@ -4,10 +4,15 @@ exports.determineAiAgents = determineAiAgents;
|
|
|
4
4
|
const enquirer_1 = require("enquirer");
|
|
5
5
|
const is_ci_1 = require("../../utils/is-ci");
|
|
6
6
|
const utils_1 = require("../../ai/utils");
|
|
7
|
+
const detect_ai_agent_1 = require("../../ai/detect-ai-agent");
|
|
7
8
|
const pc = require("picocolors");
|
|
8
9
|
async function determineAiAgents(aiAgents, interactive) {
|
|
9
10
|
if (interactive === false || (0, is_ci_1.isCI)()) {
|
|
10
|
-
|
|
11
|
+
if (aiAgents) {
|
|
12
|
+
return aiAgents;
|
|
13
|
+
}
|
|
14
|
+
const detected = (0, detect_ai_agent_1.detectAiAgent)();
|
|
15
|
+
return detected ? [detected] : [];
|
|
11
16
|
}
|
|
12
17
|
if (aiAgents) {
|
|
13
18
|
return aiAgents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-object.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/init/command-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"command-object.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/init/command-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,MAAM,OAAO,CAAC;AAU5C,eAAO,MAAM,gBAAgB,EAAE,aAqD9B,CAAC"}
|