nx 24.0.0-beta.2 → 24.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/post-install.js +5 -3
- package/dist/src/adapter/ngcli-adapter.js +1 -2
- package/dist/src/command-line/add/add.d.ts +2 -0
- package/dist/src/command-line/add/add.js +23 -5
- package/dist/src/command-line/affected/affected.js +2 -2
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -41
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -48
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
- package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +63 -36
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +7 -5
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
- package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
- package/dist/src/command-line/migrate/agentic/select.js +35 -5
- package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
- package/dist/src/command-line/migrate/agentic/types.js +5 -5
- package/dist/src/command-line/migrate/command-object.js +3 -3
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +12 -1
- package/dist/src/command-line/migrate/migrate-analytics.js +26 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +9 -10
- package/dist/src/command-line/migrate/migrate-commits.js +25 -18
- package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
- package/dist/src/command-line/migrate/migrate-output.js +1 -10
- package/dist/src/command-line/migrate/migrate.js +16 -27
- package/dist/src/command-line/migrate/run/agent-output.d.ts +1 -0
- package/dist/src/command-line/migrate/run/agent-output.js +4 -0
- package/dist/src/command-line/migrate/run/broker.js +1 -1
- package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
- package/dist/src/command-line/migrate/run/give-up.js +8 -5
- package/dist/src/command-line/migrate/run/index.d.ts +2 -1
- package/dist/src/command-line/migrate/run/index.js +5 -1
- package/dist/src/command-line/migrate/run/issues.js +7 -2
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +40 -4
- package/dist/src/command-line/migrate/run/orchestrator.js +233 -92
- package/dist/src/command-line/migrate/run/run-state.d.ts +4 -1
- package/dist/src/command-line/migrate/run/run-state.js +20 -2
- package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
- package/dist/src/command-line/migrate/run/runbook.js +99 -21
- package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
- package/dist/src/command-line/migrate/run/state-lock.js +102 -10
- package/dist/src/command-line/migrate/run/util.d.ts +4 -2
- package/dist/src/command-line/migrate/run/util.js +23 -2
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
- package/dist/src/command-line/migrate/run/worker.js +252 -250
- package/dist/src/command-line/release/changelog.js +9 -6
- package/dist/src/command-line/release/config/config.d.ts +1 -0
- package/dist/src/command-line/release/config/config.js +48 -9
- package/dist/src/command-line/release/release.js +2 -2
- package/dist/src/command-line/release/utils/git.js +8 -7
- package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
- package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
- package/dist/src/command-line/release/utils/release-graph.js +1 -0
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
- package/dist/src/command-line/release/utils/shared.js +10 -10
- package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
- package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
- package/dist/src/command-line/release/version/version-actions.js +2 -1
- package/dist/src/command-line/release/version.js +5 -2
- package/dist/src/command-line/show/projects.js +5 -3
- package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
- package/dist/src/config/nx-json.d.ts +8 -5
- package/dist/src/config/workspace-json-project-json.d.ts +12 -9
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/devkit-exports.d.ts +4 -0
- package/dist/src/devkit-exports.js +6 -1
- package/dist/src/devkit-internals.d.ts +1 -1
- package/dist/src/devkit-internals.js +4 -3
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -2
- package/dist/src/executors/run-commands/run-commands.impl.js +20 -10
- package/dist/src/executors/run-commands/running-tasks.d.ts +12 -3
- package/dist/src/executors/run-commands/running-tasks.js +22 -18
- package/dist/src/hasher/check-task-files.js +1 -4
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
- package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +7 -6
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
- package/dist/src/native/index.d.ts +3 -3
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -3
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
- package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
- package/dist/src/project-graph/affected/affected-tasks.d.ts +6 -5
- package/dist/src/project-graph/affected/affected-tasks.js +16 -6
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +7 -133
- package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
- package/dist/src/tasks-runner/readiness/probes.js +30 -1
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +31 -10
- package/dist/src/tasks-runner/readiness/ready-when.js +178 -41
- package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -0
- package/dist/src/tasks-runner/task-orchestrator.js +113 -38
- package/dist/src/tasks-runner/tokens.d.ts +54 -0
- package/dist/src/tasks-runner/tokens.js +161 -0
- package/dist/src/tasks-runner/utils.d.ts +15 -1
- package/dist/src/tasks-runner/utils.js +79 -33
- package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
- package/dist/src/utils/acknowledge-build-scripts.js +171 -32
- package/dist/src/utils/long-running-target.d.ts +1 -3
- package/dist/src/utils/long-running-target.js +1 -3
- package/migrations.json +13 -6
- package/package.json +11 -11
- package/schemas/nx-schema.json +17 -11
- package/schemas/project-schema.json +8 -7
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
- package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
- package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/runner.js +0 -262
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
package/dist/bin/post-install.js
CHANGED
|
@@ -9,6 +9,8 @@ const get_cloud_options_1 = require("../src/nx-cloud/utilities/get-cloud-options
|
|
|
9
9
|
const nx_cloud_utils_1 = require("../src/utils/nx-cloud-utils");
|
|
10
10
|
const nx_json_1 = require("../src/config/nx-json");
|
|
11
11
|
const logger_1 = require("../src/utils/logger");
|
|
12
|
+
const package_json_1 = require("../src/utils/package-json");
|
|
13
|
+
const installation_directory_1 = require("../src/utils/installation-directory");
|
|
12
14
|
// The post install is not critical, to avoid any chance that it may hang
|
|
13
15
|
// we will kill this process after 30 seconds.
|
|
14
16
|
const postinstallTimeout = setTimeout(() => {
|
|
@@ -36,9 +38,9 @@ const postinstallTimeout = setTimeout(() => {
|
|
|
36
38
|
}
|
|
37
39
|
})();
|
|
38
40
|
function isMainNxPackage() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
// A plain `require.resolve('nx', { paths })` self-references this package,
|
|
42
|
+
// so every installed nx copy would pass.
|
|
43
|
+
const mainNxPath = (0, package_json_1.resolveWithoutCachePollution)('nx', (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot));
|
|
42
44
|
const thisNxPath = require.resolve('nx');
|
|
43
45
|
return mainNxPath === thisNxPath;
|
|
44
46
|
}
|
|
@@ -253,8 +253,7 @@ async function createRecorder(host, record, logger) {
|
|
|
253
253
|
else if (event.kind === 'rename') {
|
|
254
254
|
record.loggingQueue.push(`${pc.blue('RENAME')} ${eventPath} => ${event.to}`);
|
|
255
255
|
// Surface as DELETE source + CREATE destination so downstream consumers
|
|
256
|
-
//
|
|
257
|
-
// both endpoints.
|
|
256
|
+
// see both endpoints.
|
|
258
257
|
const toPath = event.to.startsWith('/') ? event.to.slice(1) : event.to;
|
|
259
258
|
record.changes?.push({ type: 'DELETE', path: eventPath, content: null });
|
|
260
259
|
record.changes?.push(emptyFileChange('CREATE', toPath));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type NxJsonConfiguration } from '../../config/nx-json';
|
|
1
2
|
import type { AddOptions } from './command-object';
|
|
2
3
|
export declare function addHandler(options: AddOptions): Promise<number>;
|
|
4
|
+
export declare function installPackage(pkgName: string, version: string, nxJson: NxJsonConfiguration): Promise<void>;
|
|
3
5
|
export declare const coreNxPluginVersions: Map<string, string>;
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.coreNxPluginVersions = void 0;
|
|
4
4
|
exports.addHandler = addHandler;
|
|
5
|
+
exports.installPackage = installPackage;
|
|
5
6
|
const child_process_1 = require("child_process");
|
|
6
7
|
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
7
9
|
const nx_json_1 = require("../../config/nx-json");
|
|
8
10
|
const child_process_2 = require("../../utils/child-process");
|
|
9
11
|
const fileutils_1 = require("../../utils/fileutils");
|
|
10
12
|
const logger_1 = require("../../utils/logger");
|
|
11
13
|
const output_1 = require("../../utils/output");
|
|
12
14
|
const package_manager_1 = require("../../utils/package-manager");
|
|
15
|
+
const acknowledge_build_scripts_1 = require("../../utils/acknowledge-build-scripts");
|
|
13
16
|
const handle_errors_1 = require("../../utils/handle-errors");
|
|
14
17
|
const versions_1 = require("../../utils/versions");
|
|
15
18
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
@@ -48,13 +51,19 @@ async function installPackage(pkgName, version, nxJson) {
|
|
|
48
51
|
: `${pmc.addDev} ${pkgName}@${version}`;
|
|
49
52
|
// pnpm 11+ fails the install when the plugin's own dependency tree
|
|
50
53
|
// carries unacknowledged build scripts, and the plugin's generators can
|
|
51
|
-
// only record allowBuilds decisions after this install.
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
+
// only record allowBuilds decisions after this install. A plugin that
|
|
55
|
+
// declares them in its package.json keeps the install strict; otherwise
|
|
56
|
+
// warn and skip for this one install, like pnpm 10 did. pnpm 12 gave
|
|
57
|
+
// `--config` a meaning of its own and takes the setting from the
|
|
58
|
+
// environment instead.
|
|
54
59
|
const env = { ...process.env };
|
|
60
|
+
let restorePnpmWorkspace;
|
|
55
61
|
if (pm === 'pnpm' && (0, semver_1.gte)(pmv, '11.0.0')) {
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
restorePnpmWorkspace = snapshotFile((0, path_1.join)(workspace_root_1.workspaceRoot, 'pnpm-workspace.yaml'));
|
|
63
|
+
if (!(await (0, acknowledge_build_scripts_1.acknowledgeDeclaredBuildScripts)(workspace_root_1.workspaceRoot, pm, pkgName, version))) {
|
|
64
|
+
command += ' --config.strictDepBuilds=false';
|
|
65
|
+
env.PNPM_CONFIG_STRICT_DEP_BUILDS = 'false';
|
|
66
|
+
}
|
|
58
67
|
}
|
|
59
68
|
await new Promise((resolve) => (0, child_process_1.exec)(command, {
|
|
60
69
|
windowsHide: true,
|
|
@@ -70,6 +79,9 @@ async function installPackage(pkgName, version, nxJson) {
|
|
|
70
79
|
output_1.output.error({
|
|
71
80
|
title: `Failed to install ${pkgName}. Please check the error above for more details.`,
|
|
72
81
|
});
|
|
82
|
+
// The decisions the plugin declared were recorded for a plugin
|
|
83
|
+
// that never installed; put the file back.
|
|
84
|
+
restorePnpmWorkspace?.();
|
|
73
85
|
process.exit(1);
|
|
74
86
|
}
|
|
75
87
|
return resolve();
|
|
@@ -97,6 +109,12 @@ async function installPackage(pkgName, version, nxJson) {
|
|
|
97
109
|
}
|
|
98
110
|
spinner.succeed();
|
|
99
111
|
}
|
|
112
|
+
function snapshotFile(path) {
|
|
113
|
+
const before = (0, fs_1.existsSync)(path) ? (0, fs_1.readFileSync)(path, 'utf-8') : null;
|
|
114
|
+
return () => before === null
|
|
115
|
+
? (0, fs_1.rmSync)(path, { force: true })
|
|
116
|
+
: (0, fs_1.writeFileSync)(path, before);
|
|
117
|
+
}
|
|
100
118
|
async function initializePlugin(pkgName, options, nxJson) {
|
|
101
119
|
let updatePackageScripts = false;
|
|
102
120
|
if (exports.coreNxPluginVersions.has(pkgName) &&
|
|
@@ -30,12 +30,12 @@ async function affected(command, args, extraTargetDependencies = {}, extraOption
|
|
|
30
30
|
await (0, connect_to_nx_cloud_1.connectToNxCloudIfExplicitlyAsked)(nxArgs);
|
|
31
31
|
// Task selection needs a target to select against, so `nx graph --affected`
|
|
32
32
|
// and the deprecated print-affected stay project-grained.
|
|
33
|
-
const useTasks = (0, affected_tasks_1.selectsAffectedTasks)() &&
|
|
33
|
+
const useTasks = (0, affected_tasks_1.selectsAffectedTasks)(nxJson) &&
|
|
34
34
|
command === 'affected' &&
|
|
35
35
|
!!nxArgs.targets?.length;
|
|
36
36
|
if ((0, affected_reasons_1.isExplaining)(nxArgs.explain) && !useTasks) {
|
|
37
37
|
throw new Error((0, affected_reasons_1.explainUnavailable)([
|
|
38
|
-
!(0, affected_tasks_1.selectsAffectedTasks)() &&
|
|
38
|
+
!(0, affected_tasks_1.selectsAffectedTasks)(nxJson) && (0, affected_tasks_1.taskGranularityRequirement)(),
|
|
39
39
|
!nxArgs.targets?.length && 'targets passed with --targets (-t)',
|
|
40
40
|
].filter(Boolean)));
|
|
41
41
|
}
|
|
@@ -120,61 +120,28 @@ function createProjectJson(repoRoot, packageJson, nestCLIOptions) {
|
|
|
120
120
|
buildTarget: `${packageName}:build`,
|
|
121
121
|
},
|
|
122
122
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
extractLicenses: true,
|
|
138
|
-
inspect: false,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
json.targets['serve'] = {
|
|
143
|
-
...json.targets['serve'],
|
|
144
|
-
configurations: {
|
|
145
|
-
production: {
|
|
146
|
-
buildTarget: `${packageName}:build:production`,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
json.targets['build'] = {
|
|
153
|
-
executor: '@nx/js:tsc',
|
|
154
|
-
outputs: ['{options.outputPath}'],
|
|
155
|
-
options: {
|
|
156
|
-
outputPath: `dist/${packageName}`,
|
|
157
|
-
main: (0, path_1.join)(nestCLIOptions.sourceRoot, nestCLIOptions.entryFile),
|
|
158
|
-
tsConfig: 'tsconfig.build.json',
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
json.targets['serve'] = {
|
|
162
|
-
...json.targets['serve'],
|
|
163
|
-
configurations: {
|
|
164
|
-
debug: {
|
|
165
|
-
inspect: 'inspect',
|
|
166
|
-
},
|
|
123
|
+
json.targets['build'] = {
|
|
124
|
+
executor: '@nx/js:tsc',
|
|
125
|
+
outputs: ['{options.outputPath}'],
|
|
126
|
+
options: {
|
|
127
|
+
outputPath: `dist/${packageName}`,
|
|
128
|
+
main: (0, path_1.join)(nestCLIOptions.sourceRoot, nestCLIOptions.entryFile),
|
|
129
|
+
tsConfig: 'tsconfig.build.json',
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
json.targets['serve'] = {
|
|
133
|
+
...json.targets['serve'],
|
|
134
|
+
configurations: {
|
|
135
|
+
debug: {
|
|
136
|
+
inspect: 'inspect',
|
|
167
137
|
},
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
// if we're using nrwl/js, then we add nrwl/js analyzeSourceFiles to nx.json
|
|
141
|
+
addNrwlJsPluginsConfig(repoRoot);
|
|
172
142
|
// lint
|
|
173
143
|
json.targets['lint'] = {
|
|
174
|
-
|
|
175
|
-
options: {
|
|
176
|
-
lintFilePatterns: ['./src', './test'],
|
|
177
|
-
},
|
|
144
|
+
command: 'eslint ./src ./test',
|
|
178
145
|
};
|
|
179
146
|
// test and e2e
|
|
180
147
|
addJestTargets(repoRoot, packageName, json, packageJson);
|
|
@@ -236,19 +203,11 @@ function addJestTargets(repoRoot, packageName, projectJson, packageJson) {
|
|
|
236
203
|
(0, node_fs_1.writeFileSync)(e2eTestConfigPath, `export default ${JSON.stringify(e2eTestOptions, null, 2)}`, 'utf8');
|
|
237
204
|
(0, format_1.recordInitWrite)(e2eTestConfigPath);
|
|
238
205
|
projectJson.targets['test'] = {
|
|
239
|
-
|
|
206
|
+
command: `jest --config ${unitTestConfigPath} --passWithNoTests`,
|
|
240
207
|
outputs: [`{workspaceRoot}/coverage/${packageName}`],
|
|
241
|
-
options: {
|
|
242
|
-
passWithNoTests: true,
|
|
243
|
-
jestConfig: unitTestConfigPath,
|
|
244
|
-
},
|
|
245
208
|
};
|
|
246
209
|
projectJson.targets['e2e'] = {
|
|
247
|
-
|
|
248
|
-
options: {
|
|
249
|
-
passWithNoTests: true,
|
|
250
|
-
jestConfig: e2eTestConfigPath,
|
|
251
|
-
},
|
|
210
|
+
command: `jest --config ${e2eTestConfigPath} --passWithNoTests`,
|
|
252
211
|
};
|
|
253
212
|
// remove jest options from package.json
|
|
254
213
|
delete packageJson['jest'];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentDefinition
|
|
1
|
+
import { AgentDefinition } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Pre-authorizes the handoff write. Claude Code's default permission mode
|
|
4
4
|
* asks before a file write it has no allow rule for, so without this every
|
|
@@ -24,7 +24,5 @@ export declare const claudeCodeDefinition: AgentDefinition;
|
|
|
24
24
|
* back before it reaches the command line.
|
|
25
25
|
*/
|
|
26
26
|
export declare function encodeTomlString(value: string): string;
|
|
27
|
-
export declare const codexDefinition: AgentDefinition;
|
|
28
27
|
export declare const opencodeDefinition: AgentDefinition;
|
|
29
28
|
export declare const AGENT_DEFINITIONS: readonly AgentDefinition[];
|
|
30
|
-
export declare function getAgentDefinition(id: AgentId): AgentDefinition | undefined;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AGENT_DEFINITIONS = exports.opencodeDefinition = exports.
|
|
3
|
+
exports.AGENT_DEFINITIONS = exports.opencodeDefinition = exports.claudeCodeDefinition = void 0;
|
|
4
4
|
exports.claudeCodeHandoffAllowedTools = claudeCodeHandoffAllowedTools;
|
|
5
5
|
exports.encodeTomlString = encodeTomlString;
|
|
6
|
-
exports.getAgentDefinition = getAgentDefinition;
|
|
7
6
|
const os_1 = require("os");
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const smol_toml_1 = require("smol-toml");
|
|
@@ -20,10 +19,8 @@ function claudeCodeWellKnownPaths() {
|
|
|
20
19
|
* The run directory names Nx will interpolate into a permission rule. A rule
|
|
21
20
|
* is a gitignore pattern, which reads `*?[]\` as syntax, and `--allowedTools`
|
|
22
21
|
* splits its value on commas and spaces, so a name carrying any of those
|
|
23
|
-
* would change what the rule authorizes rather than what it names.
|
|
24
|
-
*
|
|
25
|
-
* upstream constrains to this alphabet. The leading character rejects `.`
|
|
26
|
-
* and `..`.
|
|
22
|
+
* would change what the rule authorizes rather than what it names. The
|
|
23
|
+
* leading character rejects `.` and `..`.
|
|
27
24
|
*/
|
|
28
25
|
const RULE_SAFE_RUN_DIR_NAME = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
|
|
29
26
|
/**
|
|
@@ -49,49 +46,16 @@ function claudeCodeHandoffAllowedTools(runDirName) {
|
|
|
49
46
|
}
|
|
50
47
|
return `Edit(${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runDirName}/${types_1.HANDOFFS_DIR_NAME}/**)`;
|
|
51
48
|
}
|
|
52
|
-
function claudeCodeBuildInteractive(ctx) {
|
|
53
|
-
const allowedTools = claudeCodeHandoffAllowedTools(ctx.runDirName);
|
|
54
|
-
return {
|
|
55
|
-
// `--allowedTools` is variadic, so a positional right after it is read as
|
|
56
|
-
// another rule: keep the rules in one comma-joined element and a flag
|
|
57
|
-
// between them and the instructions pointer.
|
|
58
|
-
args: [
|
|
59
|
-
...(allowedTools ? ['--allowedTools', allowedTools] : []),
|
|
60
|
-
'--system-prompt-file',
|
|
61
|
-
ctx.systemPromptFilePath,
|
|
62
|
-
ctx.instructionsPointer,
|
|
63
|
-
],
|
|
64
|
-
cwd: ctx.workspaceRoot,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
49
|
exports.claudeCodeDefinition = {
|
|
68
50
|
id: 'claude-code',
|
|
69
51
|
displayName: 'Claude Code',
|
|
70
52
|
binaryNames: ['claude'],
|
|
71
53
|
wellKnownPaths: claudeCodeWellKnownPaths,
|
|
72
|
-
buildInteractive: claudeCodeBuildInteractive,
|
|
73
54
|
};
|
|
74
55
|
// --- OpenAI Codex --------------------------------------------------------
|
|
75
56
|
function codexWellKnownPaths() {
|
|
76
57
|
return [];
|
|
77
58
|
}
|
|
78
|
-
// No handoff permission flag: codex's default sandbox already allows writes
|
|
79
|
-
// inside the cwd tree (`.git` excepted), and a user-hardened read-only config
|
|
80
|
-
// is theirs to keep.
|
|
81
|
-
//
|
|
82
|
-
// `-c model_instructions_file` replaces codex's built-in instructions rather
|
|
83
|
-
// than adding this context to them, so the context stays on the command line,
|
|
84
|
-
// reduced rather than the full prompt.
|
|
85
|
-
function codexBuildInteractive(ctx) {
|
|
86
|
-
return {
|
|
87
|
-
args: [
|
|
88
|
-
'-c',
|
|
89
|
-
`developer_instructions=${encodeTomlString(ctx.inlineSystemContext)}`,
|
|
90
|
-
ctx.instructionsPointer,
|
|
91
|
-
],
|
|
92
|
-
cwd: ctx.workspaceRoot,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
59
|
/**
|
|
96
60
|
* Encodes a single-line TOML string for codex overrides. Codex treats a parse
|
|
97
61
|
* failure as literal text instead of reporting it, so the result is parsed
|
|
@@ -112,15 +76,13 @@ function encodeTomlString(value) {
|
|
|
112
76
|
}
|
|
113
77
|
return encoded;
|
|
114
78
|
}
|
|
115
|
-
|
|
79
|
+
const codexDefinition = {
|
|
116
80
|
id: 'codex',
|
|
117
81
|
displayName: 'OpenAI Codex',
|
|
118
82
|
binaryNames: ['codex'],
|
|
119
83
|
wellKnownPaths: codexWellKnownPaths,
|
|
120
|
-
buildInteractive: codexBuildInteractive,
|
|
121
84
|
};
|
|
122
85
|
// --- OpenCode ------------------------------------------------------------
|
|
123
|
-
const OPENCODE_TRANSIENT_AGENT_NAME = 'nx-migrate';
|
|
124
86
|
function opencodeWellKnownPaths() {
|
|
125
87
|
if (process.platform === 'win32') {
|
|
126
88
|
return [];
|
|
@@ -139,69 +101,15 @@ function opencodeWellKnownPaths() {
|
|
|
139
101
|
candidates.push((0, path_1.join)(home, '.opencode', 'bin', 'opencode'));
|
|
140
102
|
return candidates;
|
|
141
103
|
}
|
|
142
|
-
// No handoff permission config: opencode's `edit` permission defaults to
|
|
143
|
-
// allow, and injecting one would clobber a user's own patterns rather than
|
|
144
|
-
// merge with them.
|
|
145
|
-
//
|
|
146
|
-
// The config travels through OPENCODE_CONFIG_CONTENT rather than
|
|
147
|
-
// OPENCODE_CONFIG. Both merge with the user's own config, but the runner
|
|
148
|
-
// spreads `env` over `process.env`, so the latter would overwrite a value the
|
|
149
|
-
// user had set.
|
|
150
|
-
function opencodeBuildInteractive(ctx) {
|
|
151
|
-
return {
|
|
152
|
-
args: [
|
|
153
|
-
'--agent',
|
|
154
|
-
OPENCODE_TRANSIENT_AGENT_NAME,
|
|
155
|
-
'--prompt',
|
|
156
|
-
ctx.instructionsPointer,
|
|
157
|
-
],
|
|
158
|
-
env: { OPENCODE_CONFIG_CONTENT: opencodeConfigContent(ctx) },
|
|
159
|
-
cwd: ctx.workspaceRoot,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Escapes inline prompt patterns before opencode's pre-JSON substitution pass.
|
|
164
|
-
* Excludes generator instructions from the config; cmd.exe drops inherited
|
|
165
|
-
* variables longer than 8191 characters.
|
|
166
|
-
*/
|
|
167
|
-
function opencodeConfigContent(ctx) {
|
|
168
|
-
// Windows separators become `/`, which its APIs accept just as well.
|
|
169
|
-
// Elsewhere a `\` belongs to the file name.
|
|
170
|
-
const filePath = process.platform === 'win32'
|
|
171
|
-
? ctx.systemPromptFilePath.replace(/\\/g, '/')
|
|
172
|
-
: ctx.systemPromptFilePath;
|
|
173
|
-
const prompt = isSubstitutionSafePath(filePath)
|
|
174
|
-
? JSON.stringify(`{file:${filePath}}`)
|
|
175
|
-
: // `\u007b` starts no pattern and JSON decodes it back to `{`, so the
|
|
176
|
-
// prompt survives expansion whatever the workspace path put in it.
|
|
177
|
-
JSON.stringify(ctx.systemPrompt).replace(/\{/g, '\\u007b');
|
|
178
|
-
// Assembled rather than serialized whole: `JSON.stringify` over the object
|
|
179
|
-
// would re-escape the backslashes the `\u007b` encoding introduced.
|
|
180
|
-
return `{"agent":{${JSON.stringify(OPENCODE_TRANSIENT_AGENT_NAME)}:{"prompt":${prompt}}}}`;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Whether opencode would read back the path nx wrote. A `}` closes the
|
|
184
|
-
* reference early, and a character JSON escapes arrives escaped. Braces are
|
|
185
|
-
* rejected wholesale rather than matched against `{env:` and `{file:`, since a
|
|
186
|
-
* pattern opening inside the path swallows the reference's closing brace.
|
|
187
|
-
*/
|
|
188
|
-
function isSubstitutionSafePath(filePath) {
|
|
189
|
-
return (!/[{}]/.test(filePath) && JSON.stringify(filePath).slice(1, -1) === filePath);
|
|
190
|
-
}
|
|
191
104
|
exports.opencodeDefinition = {
|
|
192
105
|
id: 'opencode',
|
|
193
106
|
displayName: 'OpenCode',
|
|
194
107
|
binaryNames: ['opencode'],
|
|
195
108
|
wellKnownPaths: opencodeWellKnownPaths,
|
|
196
|
-
buildInteractive: opencodeBuildInteractive,
|
|
197
109
|
};
|
|
198
110
|
// --- Registry ------------------------------------------------------------
|
|
199
111
|
exports.AGENT_DEFINITIONS = [
|
|
200
112
|
exports.claudeCodeDefinition,
|
|
201
|
-
|
|
113
|
+
codexDefinition,
|
|
202
114
|
exports.opencodeDefinition,
|
|
203
115
|
];
|
|
204
|
-
const byId = new Map(exports.AGENT_DEFINITIONS.map((definition) => [definition.id, definition]));
|
|
205
|
-
function getAgentDefinition(id) {
|
|
206
|
-
return byId.get(id);
|
|
207
|
-
}
|
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* function to add the entry before that can happen:
|
|
9
|
-
*
|
|
10
|
-
* 1. Orchestrator init calls it with `applyWhenPlanned` and no standalone
|
|
11
|
-
* commit, before it creates the run dir. Its checkpoint commit carries the
|
|
12
|
-
* edit when commits are on and the checkpoint succeeds. A planned v23
|
|
13
|
-
* migration then changes nothing in its own step.
|
|
14
|
-
*
|
|
15
|
-
* 2. A single-migration worker run with an agent defers to the requested
|
|
16
|
-
* migration when it is the v23 one. Otherwise, below v23, it applies the
|
|
17
|
-
* entry and commits it as a standalone preflight commit (or leaves it in
|
|
18
|
-
* the working tree under `--no-create-commits`).
|
|
19
|
-
*
|
|
20
|
-
* When the v23 migration is not planned and nx is at v23 or later, the user is
|
|
21
|
-
* already past v23. They had the entry historically; if it is gone, that is a
|
|
22
|
-
* conscious removal we respect.
|
|
2
|
+
* Applies the v23 migration `23-0-0-add-migrate-runs-to-git-ignore` inline:
|
|
3
|
+
* the orchestrator writes run scratch at init, before that migration runs, and
|
|
4
|
+
* the run's commits would otherwise absorb it. Commits nothing; the init
|
|
5
|
+
* checkpoint carries the edit when commits are on and the checkpoint succeeds.
|
|
6
|
+
* Skipped at nx v23 or later unless the v23 migration is planned: a missing
|
|
7
|
+
* entry is then a conscious removal.
|
|
23
8
|
*/
|
|
24
|
-
export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion,
|
|
9
|
+
export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, root, }: {
|
|
25
10
|
migrations: ReadonlyArray<{
|
|
26
11
|
package: string;
|
|
27
12
|
name: string;
|
|
@@ -34,24 +19,5 @@ export declare function applyAgenticHandoffGitignoreFallback({ migrations, insta
|
|
|
34
19
|
* version is irrelevant to whether `nx` itself crossed v23.
|
|
35
20
|
*/
|
|
36
21
|
installedNxVersion: string;
|
|
37
|
-
effectiveCreateCommits: boolean;
|
|
38
|
-
commitPrefix: string;
|
|
39
22
|
root: string;
|
|
40
|
-
/**
|
|
41
|
-
* Apply the entry even when the v23 migration is in the plan. The
|
|
42
|
-
* orchestrator creates its run dir at init, before any migration runs, so
|
|
43
|
-
* it can't defer to that migration. A planned migration also means the
|
|
44
|
-
* missing entry is not a conscious removal, so the v23 cutoff does not
|
|
45
|
-
* apply.
|
|
46
|
-
*/
|
|
47
|
-
applyWhenPlanned?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Commit the applied entry as its own preflight commit (the default). The
|
|
50
|
-
* orchestrator suppresses this: it applies the fallback before its init
|
|
51
|
-
* checkpoint so the checkpoint's `git add -A` cannot sweep in older
|
|
52
|
-
* scratch, and in that ordering a standalone commit here would carry the
|
|
53
|
-
* user's pre-existing changes along with the entry. The checkpoint that
|
|
54
|
-
* follows captures both instead.
|
|
55
|
-
*/
|
|
56
|
-
commitStandalone?: boolean;
|
|
57
23
|
}): Promise<void>;
|
|
@@ -6,41 +6,19 @@ const semver_1 = require("semver");
|
|
|
6
6
|
const pc = tslib_1.__importStar(require("picocolors"));
|
|
7
7
|
const add_migrate_runs_to_git_ignore_1 = tslib_1.__importDefault(require("../../../migrations/update-23-0-0/add-migrate-runs-to-git-ignore"));
|
|
8
8
|
const tree_1 = require("../../../generators/tree");
|
|
9
|
-
const git_utils_1 = require("../../../utils/git-utils");
|
|
10
9
|
const logger_1 = require("../../../utils/logger");
|
|
11
10
|
const types_1 = require("./types");
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* function to add the entry before that can happen:
|
|
20
|
-
*
|
|
21
|
-
* 1. Orchestrator init calls it with `applyWhenPlanned` and no standalone
|
|
22
|
-
* commit, before it creates the run dir. Its checkpoint commit carries the
|
|
23
|
-
* edit when commits are on and the checkpoint succeeds. A planned v23
|
|
24
|
-
* migration then changes nothing in its own step.
|
|
25
|
-
*
|
|
26
|
-
* 2. A single-migration worker run with an agent defers to the requested
|
|
27
|
-
* migration when it is the v23 one. Otherwise, below v23, it applies the
|
|
28
|
-
* entry and commits it as a standalone preflight commit (or leaves it in
|
|
29
|
-
* the working tree under `--no-create-commits`).
|
|
30
|
-
*
|
|
31
|
-
* When the v23 migration is not planned and nx is at v23 or later, the user is
|
|
32
|
-
* already past v23. They had the entry historically; if it is gone, that is a
|
|
33
|
-
* conscious removal we respect.
|
|
12
|
+
* Applies the v23 migration `23-0-0-add-migrate-runs-to-git-ignore` inline:
|
|
13
|
+
* the orchestrator writes run scratch at init, before that migration runs, and
|
|
14
|
+
* the run's commits would otherwise absorb it. Commits nothing; the init
|
|
15
|
+
* checkpoint carries the edit when commits are on and the checkpoint succeeds.
|
|
16
|
+
* Skipped at nx v23 or later unless the v23 migration is planned: a missing
|
|
17
|
+
* entry is then a conscious removal.
|
|
34
18
|
*/
|
|
35
|
-
async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion,
|
|
36
|
-
if (migrations.some(types_1.isHandoffGitignoreMigration)
|
|
37
|
-
|
|
38
|
-
// The single-migration worker run is that migration, and it adds the
|
|
39
|
-
// entry itself.
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if ((0, semver_1.major)(installedNxVersion) >= 23) {
|
|
19
|
+
async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, root, }) {
|
|
20
|
+
if (!migrations.some(types_1.isHandoffGitignoreMigration) &&
|
|
21
|
+
(0, semver_1.major)(installedNxVersion) >= 23) {
|
|
44
22
|
// User is past v23. Respect their `.gitignore` state — if the entry
|
|
45
23
|
// is missing, that's a conscious removal.
|
|
46
24
|
return;
|
|
@@ -55,21 +33,4 @@ async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVer
|
|
|
55
33
|
}
|
|
56
34
|
(0, tree_1.flushChanges)(root, changes);
|
|
57
35
|
logger_1.logger.info(pc.dim(`- Added ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore so this run's scratch state is ignored.`));
|
|
58
|
-
if (!effectiveCreateCommits || !commitStandalone)
|
|
59
|
-
return;
|
|
60
|
-
if (!(0, git_utils_1.hasUncommittedChanges)(root))
|
|
61
|
-
return;
|
|
62
|
-
try {
|
|
63
|
-
const sha = (0, git_utils_1.tryCommitChanges)(`${commitPrefix}add ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore`, root, [types_1.MIGRATE_RUNS_RELATIVE_DIR]);
|
|
64
|
-
if (sha) {
|
|
65
|
-
logger_1.logger.info(pc.dim(` Commit: ${sha}`));
|
|
66
|
-
}
|
|
67
|
-
// `null` return = commit landed but `git rev-parse HEAD` raced. The
|
|
68
|
-
// diff cleared from the working tree; nothing more to say.
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
72
|
-
logger_1.logger.info(pc.yellow(`Could not create the agentic preflight commit:\n${reason}\n` +
|
|
73
|
-
`The .gitignore change remains in the working tree; commit it manually or it will be absorbed into the first per-migration commit.`));
|
|
74
|
-
}
|
|
75
36
|
}
|
|
@@ -1,36 +1,13 @@
|
|
|
1
1
|
import { type BigIntStats } from 'fs';
|
|
2
2
|
import { HandoffFile } from './types';
|
|
3
|
-
/** Returns the run directory for a given workspace + run id (target version). */
|
|
4
|
-
export declare function runDirPath(workspaceRoot: string, runId: string): string;
|
|
5
|
-
/** The version-derived run id: the highest target version in the plan. */
|
|
6
|
-
export declare function resolveAgenticRunId(migrations: ReadonlyArray<{
|
|
7
|
-
version: string;
|
|
8
|
-
}>): string;
|
|
9
3
|
/**
|
|
10
4
|
* `mkdir -p` with a contextual error wrapper. Without this, the raw
|
|
11
5
|
* ENOSPC/EACCES/EROFS surfaces with no indication of which directory the
|
|
12
6
|
* migrate orchestrator was trying to create.
|
|
13
7
|
*/
|
|
14
8
|
export declare function mkdirSafely(dir: string, purpose: string): void;
|
|
15
|
-
/**
|
|
16
|
-
* Wipes any prior contents for this run id and recreates an empty directory.
|
|
17
|
-
*
|
|
18
|
-
* Scope of the wipe is intentionally narrow (only `<run-id>/`) so that handoff
|
|
19
|
-
* artifacts from prior runs targeting different versions remain on disk for
|
|
20
|
-
* inspection.
|
|
21
|
-
*/
|
|
22
|
-
export declare function initRunDir(workspaceRoot: string, runId: string): string;
|
|
23
9
|
export declare function truncateUtf8(value: string, maxBytes: number): string;
|
|
24
|
-
export declare function stepHandoffPath(runDir: string, migration: {
|
|
25
|
-
package: string;
|
|
26
|
-
name: string;
|
|
27
|
-
}): string;
|
|
28
|
-
/** Handoff path for a run step. No hash needed: step ids are unique within the run. */
|
|
29
10
|
export declare function runStepHandoffPath(runDir: string, stepId: string): string;
|
|
30
|
-
export declare function stepPromptsDir(runDir: string, migration: {
|
|
31
|
-
package: string;
|
|
32
|
-
name: string;
|
|
33
|
-
}): string;
|
|
34
11
|
export type HandoffReadFailureReason = 'missing' | 'read-error' | 'parse-error' | 'shape-mismatch';
|
|
35
12
|
export type HandoffReadResult = {
|
|
36
13
|
ok: true;
|
|
@@ -78,25 +55,6 @@ export declare function readInspectedFile(filePath: string, stat: BigIntStats, r
|
|
|
78
55
|
export declare function readAtomicallyPublishedFile(filePath: string, notRegularMessage: string): string;
|
|
79
56
|
/**
|
|
80
57
|
* Splits "not written yet" from "written but garbage" so callers can surface a
|
|
81
|
-
* malformed handoff instead of
|
|
82
|
-
* ambiguous-outcome prompt.
|
|
58
|
+
* malformed handoff instead of treating it as not written.
|
|
83
59
|
*/
|
|
84
60
|
export declare function readHandoffWithReason(filePath: string, handoffsDir: string): HandoffReadResult;
|
|
85
|
-
/**
|
|
86
|
-
* Convenience wrapper preserving the original null-on-any-failure contract.
|
|
87
|
-
* Used by the polling loop (`waitForValidHandoff`) where every failure mode
|
|
88
|
-
* is "keep waiting" — the file may be missing, mid-write, or being rewritten.
|
|
89
|
-
*/
|
|
90
|
-
export declare function readHandoff(filePath: string, handoffsDir: string): HandoffFile | null;
|
|
91
|
-
/**
|
|
92
|
-
* Polls for a valid handoff file. Resolves once `readHandoff` accepts the
|
|
93
|
-
* file's contents. Used to detect when the agent has finished its work so the
|
|
94
|
-
* orchestrator can close the agent's session without depending on the agent
|
|
95
|
-
* exiting on its own.
|
|
96
|
-
*
|
|
97
|
-
* Rejects with the abort reason when `options.signal` is aborted.
|
|
98
|
-
*/
|
|
99
|
-
export declare function waitForValidHandoff(handoffFilePath: string, handoffsDir: string, options?: {
|
|
100
|
-
intervalMs?: number;
|
|
101
|
-
signal?: AbortSignal;
|
|
102
|
-
}): Promise<void>;
|