nx 23.3.0-beta.2 → 23.3.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.
Files changed (58) hide show
  1. package/dist/bin/init-local.js +7 -1
  2. package/dist/src/command-line/add/add.js +5 -1
  3. package/dist/src/command-line/init/implementation/utils.js +6 -1
  4. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
  5. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
  6. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  7. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  8. package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
  9. package/dist/src/command-line/migrate/agentic/definitions.js +5 -2
  10. package/dist/src/command-line/migrate/agentic/handoff.d.ts +23 -0
  11. package/dist/src/command-line/migrate/agentic/handoff.js +62 -3
  12. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  13. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  14. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +12 -0
  15. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +99 -0
  16. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  17. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +217 -0
  18. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +3 -0
  19. package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
  20. package/dist/src/command-line/migrate/agentic/runner.js +12 -249
  21. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  22. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  23. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  24. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  25. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  26. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  27. package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
  28. package/dist/src/command-line/migrate/execute-migration.js +53 -16
  29. package/dist/src/command-line/migrate/migrate-commits.d.ts +4 -4
  30. package/dist/src/command-line/migrate/migrate-commits.js +7 -6
  31. package/dist/src/command-line/migrate/migrate.js +28 -13
  32. package/dist/src/command-line/migrate/run/broker.d.ts +138 -0
  33. package/dist/src/command-line/migrate/run/broker.js +507 -0
  34. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  35. package/dist/src/command-line/migrate/run/clean-retry.js +98 -0
  36. package/dist/src/command-line/migrate/run/index.d.ts +4 -3
  37. package/dist/src/command-line/migrate/run/index.js +7 -1
  38. package/dist/src/command-line/migrate/run/issues.d.ts +8 -1
  39. package/dist/src/command-line/migrate/run/issues.js +40 -6
  40. package/dist/src/command-line/migrate/run/orchestrator.d.ts +18 -1
  41. package/dist/src/command-line/migrate/run/orchestrator.js +409 -377
  42. package/dist/src/command-line/migrate/run/run-state.d.ts +16 -0
  43. package/dist/src/command-line/migrate/run/run-state.js +33 -2
  44. package/dist/src/command-line/migrate/run/runbook.js +8 -4
  45. package/dist/src/command-line/migrate/run/state-machine.d.ts +24 -1
  46. package/dist/src/command-line/migrate/run/state-machine.js +112 -21
  47. package/dist/src/command-line/migrate/run/util.d.ts +2 -1
  48. package/dist/src/command-line/migrate/run/util.js +3 -3
  49. package/dist/src/command-line/migrate/run/worker.js +170 -164
  50. package/dist/src/core/graph/main.js +1 -1
  51. package/dist/src/daemon/server/server.js +11 -8
  52. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  53. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  54. package/dist/src/tasks-runner/run-command.js +3 -0
  55. package/dist/src/utils/git-utils.d.ts +12 -0
  56. package/dist/src/utils/git-utils.js +76 -30
  57. package/dist/src/utils/package-json.js +8 -0
  58. package/package.json +11 -11
@@ -47,7 +47,7 @@ export interface IssueApplication {
47
47
  * Pure. Must run on state read fresh inside the fold's locked write, or ids
48
48
  * collide and the claim checks test state that is no longer on disk.
49
49
  */
50
- export declare function applyReportedIssues(state: MigrateRunState, reportingStep: MigrateStep, issues: ReportedIssue[], updates: ReportedIssueUpdate[]): IssueApplication;
50
+ export declare function applyReportedIssues(state: MigrateRunState, reportingStep: MigrateStep, issues: ReportedIssue[], updates: ReportedIssueUpdate[], resolvedAtCommitCount?: number): IssueApplication;
51
51
  /**
52
52
  * The issue ids a landed commit naming `stepIds` carries. Attribution rides on
53
53
  * the persisted `resolvedByStepId`, so a resolution whose own commit attempt
@@ -60,6 +60,12 @@ export declare function issueIdsForCommit(state: MigrateRunState, stepIds: strin
60
60
  * attribution cannot diverge between terminal paths.
61
61
  */
62
62
  export declare function attachIssueIdsToCommitEntry(state: MigrateRunState, entry: MigrateCommitLedgerEntry): MigrateCommitLedgerEntry;
63
+ /**
64
+ * Adds to a landed entry the resolutions it can now carry, keeping the ids it
65
+ * has; other entries pass through. Repeating it is a no-op, since
66
+ * `issueIdsForCommit` skips resolutions an entry already carries.
67
+ */
68
+ export declare function enrichCommitEntryIssueIds(state: MigrateRunState, index: number): MigrateRunState;
63
69
  /**
64
70
  * Reverts resolutions not carried by a landed commit and releases claims
65
71
  * during a reset-backed retry. Returned disposition changes form the archive
@@ -89,6 +95,7 @@ export declare function settleUnclaimableIssues(state: MigrateRunState): Migrate
89
95
  export declare function renderIssueDigestLines(state: MigrateRunState, currentStepId: string, runId: string): string[];
90
96
  export declare function renderUnresolvedIssueLines(state: MigrateRunState, runId: string): string[];
91
97
  export declare function issueArchivePath(runDirPath: string, issueId: string): string;
98
+ export declare function warnReconstructedArchives(issueIds: string[]): void;
92
99
  /**
93
100
  * Archives an application's new issues (with the detail the ledger does not
94
101
  * carry) and appends its updates to the archived files. Failures propagate;
@@ -7,12 +7,14 @@ exports.parseHandoffIssues = parseHandoffIssues;
7
7
  exports.applyReportedIssues = applyReportedIssues;
8
8
  exports.issueIdsForCommit = issueIdsForCommit;
9
9
  exports.attachIssueIdsToCommitEntry = attachIssueIdsToCommitEntry;
10
+ exports.enrichCommitEntryIssueIds = enrichCommitEntryIssueIds;
10
11
  exports.reopenResolutionsForStep = reopenResolutionsForStep;
11
12
  exports.claimIssuesForStep = claimIssuesForStep;
12
13
  exports.settleUnclaimableIssues = settleUnclaimableIssues;
13
14
  exports.renderIssueDigestLines = renderIssueDigestLines;
14
15
  exports.renderUnresolvedIssueLines = renderUnresolvedIssueLines;
15
16
  exports.issueArchivePath = issueArchivePath;
17
+ exports.warnReconstructedArchives = warnReconstructedArchives;
16
18
  exports.archiveIssues = archiveIssues;
17
19
  exports.applicationArchivesIntact = applicationArchivesIntact;
18
20
  const fs_1 = require("fs");
@@ -21,6 +23,7 @@ const fileutils_1 = require("../../../utils/fileutils");
21
23
  const atomic_write_1 = require("./atomic-write");
22
24
  const types_1 = require("../agentic/types");
23
25
  const text_1 = require("../text");
26
+ const agent_output_1 = require("./agent-output");
24
27
  const run_state_1 = require("./run-state");
25
28
  Object.defineProperty(exports, "issueFingerprint", { enumerable: true, get: function () { return run_state_1.issueFingerprint; } });
26
29
  const state_machine_1 = require("./state-machine");
@@ -242,7 +245,10 @@ function mappedStepIds(identifier, state) {
242
245
  * Pure. Must run on state read fresh inside the fold's locked write, or ids
243
246
  * collide and the claim checks test state that is no longer on disk.
244
247
  */
245
- function applyReportedIssues(state, reportingStep, issues, updates) {
248
+ function applyReportedIssues(state, reportingStep, issues, updates,
249
+ // The index of the entry that will carry this application's resolutions:
250
+ // the next append, unless a parent session already recorded it.
251
+ resolvedAtCommitCount = state.commits.length) {
246
252
  const ledger = [...(state.issues ?? [])];
247
253
  const newIssues = [];
248
254
  const archiveUpdates = [];
@@ -258,7 +264,7 @@ function applyReportedIssues(state, reportingStep, issues, updates) {
258
264
  const existingIndex = ledger.findIndex((i) => i.fingerprint === fingerprint);
259
265
  if (existingIndex !== -1) {
260
266
  const existing = ledger[existingIndex];
261
- const outcome = applyDuplicateReport(existing, report, reportingStep, state);
267
+ const outcome = applyDuplicateReport(existing, report, reportingStep, state, resolvedAtCommitCount);
262
268
  if (outcome.entry !== existing) {
263
269
  ledger[existingIndex] = outcome.entry;
264
270
  }
@@ -295,7 +301,7 @@ function applyReportedIssues(state, reportingStep, issues, updates) {
295
301
  ...(disposition === 'resolved'
296
302
  ? {
297
303
  resolvedByStepId: reportingStep.id,
298
- resolvedAtCommitCount: state.commits.length,
304
+ resolvedAtCommitCount,
299
305
  }
300
306
  : {}),
301
307
  };
@@ -318,7 +324,7 @@ function applyReportedIssues(state, reportingStep, issues, updates) {
318
324
  ...rest,
319
325
  disposition: 'resolved',
320
326
  resolvedByStepId: reportingStep.id,
321
- resolvedAtCommitCount: state.commits.length,
327
+ resolvedAtCommitCount,
322
328
  }
323
329
  : { ...rest, disposition: update.disposition };
324
330
  }
@@ -358,7 +364,7 @@ function reportIntent(report) {
358
364
  * report carrying detail, must archive: the fold removes the handoff, so
359
365
  * unarchived detail is lost.
360
366
  */
361
- function applyDuplicateReport(existing, report, reportingStep, state) {
367
+ function applyDuplicateReport(existing, report, reportingStep, state, resolvedAtCommitCount) {
362
368
  const intent = reportIntent(report);
363
369
  const merged = mergedApplicableStepIds(existing, report, state);
364
370
  // Set inclusion, not a length compare: a corrupt entry with duplicate scope
@@ -392,7 +398,7 @@ function applyDuplicateReport(existing, report, reportingStep, state) {
392
398
  ...(disposition === 'resolved'
393
399
  ? {
394
400
  resolvedByStepId: reportingStep.id,
395
- resolvedAtCommitCount: state.commits.length,
401
+ resolvedAtCommitCount,
396
402
  }
397
403
  : {}),
398
404
  },
@@ -485,6 +491,24 @@ function attachIssueIdsToCommitEntry(state, entry) {
485
491
  const issueIds = issueIdsForCommit(state, entry.stepIds);
486
492
  return issueIds.length > 0 ? { ...entry, issueIds } : entry;
487
493
  }
494
+ /**
495
+ * Adds to a landed entry the resolutions it can now carry, keeping the ids it
496
+ * has; other entries pass through. Repeating it is a no-op, since
497
+ * `issueIdsForCommit` skips resolutions an entry already carries.
498
+ */
499
+ function enrichCommitEntryIssueIds(state, index) {
500
+ const entry = state.commits[index];
501
+ if (entry.kind !== 'landed')
502
+ return state;
503
+ const existing = entry.issueIds ?? [];
504
+ const added = issueIdsForCommit(state, entry.stepIds).filter((id) => !existing.includes(id));
505
+ if (added.length === 0)
506
+ return state;
507
+ return {
508
+ ...state,
509
+ commits: state.commits.map((c, i) => i === index ? { ...c, issueIds: [...existing, ...added] } : c),
510
+ };
511
+ }
488
512
  /**
489
513
  * Reverts resolutions not carried by a landed commit and releases claims
490
514
  * during a reset-backed retry. Returned disposition changes form the archive
@@ -774,6 +798,16 @@ function issuesDir(runDirPath) {
774
798
  function issueArchivePath(runDirPath, issueId) {
775
799
  return (0, path_1.join)(issuesDir(runDirPath), `${issueId}.json`);
776
800
  }
801
+ // The runbook points every later consumer at issues/<id>.json for the full
802
+ // details, so a rebuild from run-state fields (the reported detail is gone
803
+ // with the lost file) must not stay silent.
804
+ function warnReconstructedArchives(issueIds) {
805
+ if (issueIds.length === 0)
806
+ return;
807
+ (0, agent_output_1.warnToAgent)({
808
+ title: `The archived details for ${issueIds.join(', ')} were missing or unreadable and were rebuilt from the run state; the originally reported detail is lost.`,
809
+ });
810
+ }
777
811
  /**
778
812
  * Archives an application's new issues (with the detail the ledger does not
779
813
  * carry) and appends its updates to the archived files. Failures propagate;
@@ -1,3 +1,4 @@
1
+ import { type MigrateRunState } from './run-state';
1
2
  import { type StepAction } from './state-machine';
2
3
  import { type PlannedMigration } from '../migration-shape';
3
4
  export interface RunOrchestratorInitInput {
@@ -11,11 +12,27 @@ export interface RunOrchestratorInitInput {
11
12
  skipInstall: boolean;
12
13
  installedNxVersion: string;
13
14
  validate: boolean | undefined;
15
+ emitAgentInstructions?: boolean;
14
16
  }
17
+ export type OrchestratorInitResult = {
18
+ kind: 'ready';
19
+ runId: string;
20
+ runRoot: string;
21
+ runbookPath: string;
22
+ reconcileCommand: string;
23
+ } | {
24
+ kind: 'refused';
25
+ };
15
26
  export interface RunOrchestratorReconcileInput {
16
27
  root: string;
17
28
  runId: string;
18
29
  stepAction?: StepAction;
19
30
  }
20
- export declare function runOrchestratorInit(input: RunOrchestratorInitInput): Promise<void>;
31
+ export declare function runOrchestratorInit(input: RunOrchestratorInitInput): Promise<OrchestratorInitResult>;
21
32
  export declare function runOrchestratorReconcile(input: RunOrchestratorReconcileInput): Promise<void>;
33
+ /**
34
+ * What a completed run leaves behind for whoever reads its summary, one line
35
+ * group per warning: commit debt, uninstalled dependency changes, unresolved
36
+ * issues. Empty when nothing is left.
37
+ */
38
+ export declare function completionWarnings(root: string, runId: string, state: MigrateRunState): string[][];