@smoothbricks/nx-plugin 0.7.16 → 0.7.18

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 (119) hide show
  1. package/README.md +210 -64
  2. package/dist/.build-inputs.json +28 -23
  3. package/dist/bun-lock-scope.d.ts +128 -20
  4. package/dist/bun-lock-scope.d.ts.map +1 -1
  5. package/dist/bun-lock-scope.js +267 -44
  6. package/dist/cargo-closure-input.d.ts +8 -6
  7. package/dist/cargo-closure-input.d.ts.map +1 -1
  8. package/dist/cargo-closure-input.js +14 -11
  9. package/dist/cargo-source-hash.d.ts +23 -4
  10. package/dist/cargo-source-hash.d.ts.map +1 -1
  11. package/dist/cargo-source-hash.js +80 -14
  12. package/dist/cargo-workspace.d.ts +20 -2
  13. package/dist/cargo-workspace.d.ts.map +1 -1
  14. package/dist/cargo-workspace.js +42 -22
  15. package/dist/compile-environment.d.ts +8 -0
  16. package/dist/compile-environment.d.ts.map +1 -0
  17. package/dist/compile-environment.js +80 -0
  18. package/dist/dependency-manifests.d.ts +13 -0
  19. package/dist/dependency-manifests.d.ts.map +1 -0
  20. package/dist/dependency-manifests.js +20 -0
  21. package/dist/ensure-built-receipt.d.ts +3 -2
  22. package/dist/ensure-built-receipt.d.ts.map +1 -1
  23. package/dist/ensure-built-receipt.js +3 -2
  24. package/dist/eslint-config-closure.d.ts +8 -3
  25. package/dist/eslint-config-closure.d.ts.map +1 -1
  26. package/dist/eslint-config-closure.js +24 -5
  27. package/dist/executors/bounded-exec/bounds.d.ts +12 -1
  28. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  29. package/dist/executors/bounded-exec/bounds.js +8 -4
  30. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  31. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  32. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  33. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  34. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  35. package/dist/executors/bounded-exec/executor.js +54 -22
  36. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +8 -0
  37. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/hang-diagnostics.js +66 -6
  39. package/dist/executors/bounded-exec/mbx-pool.d.ts +16 -2
  40. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/mbx-pool.js +18 -2
  42. package/dist/executors/bounded-exec/mbx-reservations.d.ts +5 -2
  43. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  44. package/dist/executors/bounded-exec/mbx-reservations.js +5 -3
  45. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  46. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  48. package/dist/executors/bounded-exec/progress.d.ts +2 -1
  49. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  51. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  52. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  53. package/dist/executors/bounded-exec/schema.d.ts +5 -0
  54. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  55. package/dist/executors/bounded-exec/schema.js +17 -1
  56. package/dist/executors/bounded-exec/verdict.d.ts +13 -6
  57. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  58. package/dist/executors/bounded-exec/verdict.js +34 -9
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +216 -97
  61. package/dist/managed-files/files.d.ts +3 -3
  62. package/dist/managed-files/files.js +3 -3
  63. package/dist/managed-files/generator.d.ts +5 -1
  64. package/dist/managed-files/generator.d.ts.map +1 -1
  65. package/dist/managed-files/generator.js +22 -7
  66. package/dist/managed-files/render-memo.d.ts +13 -0
  67. package/dist/managed-files/render-memo.d.ts.map +1 -0
  68. package/dist/managed-files/render-memo.js +94 -0
  69. package/dist/test-program.d.ts +11 -6
  70. package/dist/test-program.d.ts.map +1 -1
  71. package/dist/test-program.js +39 -35
  72. package/dist/tool-bins.d.ts +12 -0
  73. package/dist/tool-bins.d.ts.map +1 -1
  74. package/dist/tool-bins.js +31 -6
  75. package/dist/typecheck-route.d.ts +3 -4
  76. package/dist/typecheck-route.d.ts.map +1 -1
  77. package/dist/typecheck-route.js +4 -15
  78. package/dist/typecheck-test-policy.d.ts +10 -1
  79. package/dist/typecheck-test-policy.d.ts.map +1 -1
  80. package/dist/typecheck-test-policy.js +40 -24
  81. package/dist/workspace-index.d.ts +14 -1
  82. package/dist/workspace-index.d.ts.map +1 -1
  83. package/dist/workspace-index.js +36 -4
  84. package/managed/raw/patches/nx@24.0.3.patch +703 -119
  85. package/managed/raw/patches/{ttsc@0.34.1.patch → ttsc@0.36.3.patch} +728 -71
  86. package/managed/raw/tooling/direnv/developer-links.ts +17 -3
  87. package/managed/raw/tooling/direnv/devenv.smoo.nix +1 -1
  88. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  89. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  90. package/package.json +5 -4
  91. package/src/bun-lock-scope.ts +293 -40
  92. package/src/cargo-closure-input.ts +19 -11
  93. package/src/cargo-source-hash.ts +103 -13
  94. package/src/cargo-workspace.ts +59 -20
  95. package/src/compile-environment.ts +35 -0
  96. package/src/dependency-manifests.ts +30 -0
  97. package/src/ensure-built-receipt.ts +3 -2
  98. package/src/eslint-config-closure.ts +27 -6
  99. package/src/executors/bounded-exec/bounds.ts +13 -4
  100. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  101. package/src/executors/bounded-exec/executor.ts +65 -21
  102. package/src/executors/bounded-exec/hang-diagnostics.ts +88 -6
  103. package/src/executors/bounded-exec/mbx-pool.ts +24 -3
  104. package/src/executors/bounded-exec/mbx-reservations.ts +7 -5
  105. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  106. package/src/executors/bounded-exec/progress.ts +2 -1
  107. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  108. package/src/executors/bounded-exec/schema.ts +19 -0
  109. package/src/executors/bounded-exec/verdict.ts +44 -16
  110. package/src/index.ts +272 -106
  111. package/src/managed-files/files.ts +3 -3
  112. package/src/managed-files/generator.ts +21 -6
  113. package/src/managed-files/render-memo.ts +135 -0
  114. package/src/test-program.ts +36 -41
  115. package/src/tool-bins.ts +35 -6
  116. package/src/typecheck-route.ts +5 -14
  117. package/src/typecheck-test-policy.ts +49 -24
  118. package/src/workspace-index.ts +40 -5
  119. package/test-timings.json +6 -0
@@ -358,19 +358,21 @@ index 757fd200dbd83f335c9868987e4135d4b7b580cb..1bf7e571cc66d3483f8b2ebb7b73ad8b
358
358
  }
359
359
  // Must be sync for the help output use case
360
360
  diff --git a/dist/src/daemon/client/client.d.ts b/dist/src/daemon/client/client.d.ts
361
- index d7ee773807a7d25214be89c5536c86a8e6589a44..7c3de650d6d61c4db3a0e1538ecf887eee7f6b4a 100644
361
+ index d7ee773807a7d25214be89c5536c86a8e6589a44..fa08b44690e853ae7ff829115e75fd7897e8b71f 100644
362
362
  --- a/dist/src/daemon/client/client.d.ts
363
363
  +++ b/dist/src/daemon/client/client.d.ts
364
- @@ -3,7 +3,7 @@ import { FileData, ProjectGraph } from '../../config/project-graph';
364
+ @@ -3,9 +3,7 @@ import { FileData, ProjectGraph } from '../../config/project-graph';
365
365
  import { Task, TaskGraph } from '../../config/task-graph';
366
366
  import type { UltracacheConfigurationVersion } from '../message-types/ultracache-configuration-version';
367
367
  import { Hash } from '../../hasher/task-hasher';
368
368
  -import { NxWorkspaceFiles, TaskOutputs, TaskRun, TaskTarget } from '../../native';
369
+ -import { PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
370
+ -import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/plugins/task-results-stub';
369
371
  +import { NxWorkspaceFiles, TaskOutputs } from '../../native';
370
- import { PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
371
- import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/plugins/task-results-stub';
372
372
  import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration/source-maps';
373
- @@ -61,6 +61,14 @@ export declare class DaemonClient {
373
+ import type { FlushSyncGeneratorChangesResult, SyncGeneratorRunResult } from '../../utils/sync-generators';
374
+ import { type ConfigureAiAgentsStatusResponse } from '../message-types/configure-ai-agents';
375
+ @@ -61,6 +59,14 @@ export declare class DaemonClient {
374
376
  private projectGraphListenerFramingFailures;
375
377
  private projectGraphListenerCallbacks;
376
378
  enabled(): boolean;
@@ -385,7 +387,7 @@ index d7ee773807a7d25214be89c5536c86a8e6589a44..7c3de650d6d61c4db3a0e1538ecf887e
385
387
  reset(): void;
386
388
  private createReadyPromise;
387
389
  private failDaemonReady;
388
- @@ -105,9 +113,6 @@ export declare class DaemonClient {
390
+ @@ -105,9 +111,6 @@ export declare class DaemonClient {
389
391
  getFilesInDirectory(dir: string): Promise<string[]>;
390
392
  hashGlob(globs: string[], exclude?: string[]): Promise<string>;
391
393
  hashMultiGlob(globGroups: string[][]): Promise<string[]>;
@@ -395,19 +397,30 @@ index d7ee773807a7d25214be89c5536c86a8e6589a44..7c3de650d6d61c4db3a0e1538ecf887e
395
397
  getSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorRunResult[]>;
396
398
  flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
397
399
  getRegisteredSyncGenerators(): Promise<{
400
+ @@ -118,8 +121,6 @@ export declare class DaemonClient {
401
+ /** Selection runs where hashing does, so the plans it builds are reused. */
402
+ selectAffectedTasks(request: AffectedTasksRequest): Promise<SelectAffectedTasksResponse>;
403
+ updateWorkspaceContext(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
404
+ - runPreTasksExecution(context: PreTasksExecutionContext): Promise<NodeJS.ProcessEnv[]>;
405
+ - runPostTasksExecution(context: MaybeStubbedPostTasksExecutionContext): Promise<void>;
406
+ getNxConsoleStatus(): Promise<NxConsoleStatusResponse>;
407
+ setNxConsolePreferenceAndInstall(preference: boolean): Promise<SetNxConsolePreferenceAndInstallResponse>;
408
+ getConfigureAiAgentsStatus(): Promise<ConfigureAiAgentsStatusResponse>;
398
409
  diff --git a/dist/src/daemon/client/client.js b/dist/src/daemon/client/client.js
399
- index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d19120f05 100644
410
+ index af7da5654b807f8e9d8693cd45aad32a162a4765..6bdfade7ca1d18fa7c9fc072ad1a924d09697f6a 100644
400
411
  --- a/dist/src/daemon/client/client.js
401
412
  +++ b/dist/src/daemon/client/client.js
402
- @@ -43,7 +43,6 @@ const nx_console_1 = require("../message-types/nx-console");
413
+ @@ -41,9 +41,7 @@ const get_sync_generator_changes_1 = require("../message-types/get-sync-generato
414
+ const hash_glob_1 = require("../message-types/hash-glob");
415
+ const nx_console_1 = require("../message-types/nx-console");
403
416
  const register_project_graph_listener_1 = require("../message-types/register-project-graph-listener");
404
- const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-execution-hooks");
417
+ -const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-execution-hooks");
405
418
  const streaming_messages_1 = require("../message-types/streaming-messages");
406
419
  -const task_history_1 = require("../message-types/task-history");
407
420
  const update_workspace_context_1 = require("../message-types/update-workspace-context");
408
421
  const tmp_dir_1 = require("../tmp-dir");
409
422
  const sandbox_socket_hint_1 = require("../sandbox-socket-hint");
410
- @@ -56,6 +55,8 @@ var DaemonStatus;
423
+ @@ -56,6 +54,8 @@ var DaemonStatus;
411
424
  DaemonStatus[DaemonStatus["DISCONNECTED"] = 1] = "DISCONNECTED";
412
425
  DaemonStatus[DaemonStatus["CONNECTED"] = 2] = "CONNECTED";
413
426
  })(DaemonStatus || (exports.DaemonStatus = DaemonStatus = {}));
@@ -416,7 +429,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
416
429
  const WAIT_FOR_SERVER_CONFIG = {
417
430
  delayMs: 10,
418
431
  maxAttempts: 6000, // 6000 * 10ms = 60 seconds
419
- @@ -107,6 +108,8 @@ class DaemonClient {
432
+ @@ -107,6 +107,8 @@ class DaemonClient {
420
433
  this.projectGraphListenerFramingFailures = 0;
421
434
  this.projectGraphListenerCallbacks = new Map();
422
435
  this.envReflectionSent = false;
@@ -425,7 +438,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
425
438
  try {
426
439
  this.nxJson = (0, configuration_1.readNxJson)();
427
440
  }
428
- @@ -150,12 +153,55 @@ class DaemonClient {
441
+ @@ -150,12 +152,55 @@ class DaemonClient {
429
442
  });
430
443
  this._enabled = false;
431
444
  }
@@ -481,7 +494,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
481
494
  reset() {
482
495
  this.rejectFileWatcherRegistrations(new Error('Daemon client reset'));
483
496
  this.socketMessenger?.close();
484
- @@ -192,6 +238,24 @@ class DaemonClient {
497
+ @@ -192,6 +237,24 @@ class DaemonClient {
485
498
  this._daemonStatus = DaemonStatus.DISCONNECTED;
486
499
  this._daemonReadyFailed?.(err);
487
500
  }
@@ -506,7 +519,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
506
519
  getSocketPath() {
507
520
  const daemonProcessJson = (0, cache_1.readDaemonProcessJsonCache)();
508
521
  if (daemonProcessJson?.socketPath) {
509
- @@ -328,6 +392,7 @@ class DaemonClient {
522
+ @@ -328,6 +391,7 @@ class DaemonClient {
510
523
  // failure would otherwise leave this channel silent forever.
511
524
  this.fileWatcherMessenger?.close();
512
525
  });
@@ -514,7 +527,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
514
527
  await this.sendFileWatcherRegistration(callbackId);
515
528
  })
516
529
  .catch((error) => {
517
- @@ -392,6 +457,48 @@ class DaemonClient {
530
+ @@ -392,6 +456,48 @@ class DaemonClient {
518
531
  registration.reject(error);
519
532
  }
520
533
  }
@@ -563,7 +576,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
563
576
  async reconnectFileWatcher() {
564
577
  // Guard against concurrent reconnection attempts
565
578
  if (this.fileWatcherReconnecting) {
566
- @@ -483,6 +590,7 @@ class DaemonClient {
579
+ @@ -483,6 +589,7 @@ class DaemonClient {
567
580
  // not emit, so close explicitly to hand off to it.
568
581
  this.fileWatcherMessenger?.close();
569
582
  });
@@ -571,7 +584,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
571
584
  // Re-register all stored configs
572
585
  for (const cfg of this.fileWatcherConfigs.values()) {
573
586
  this.fileWatcherMessenger.sendMessage({
574
- @@ -559,6 +667,7 @@ class DaemonClient {
587
+ @@ -559,6 +666,7 @@ class DaemonClient {
575
588
  }
576
589
  this.projectGraphListenerMessenger?.close();
577
590
  });
@@ -579,7 +592,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
579
592
  this.projectGraphListenerMessenger.sendMessage({
580
593
  type: register_project_graph_listener_1.REGISTER_PROJECT_GRAPH_LISTENER,
581
594
  });
582
- @@ -659,6 +768,7 @@ class DaemonClient {
595
+ @@ -659,6 +767,7 @@ class DaemonClient {
583
596
  // not emit, so close explicitly to hand off to it.
584
597
  this.projectGraphListenerMessenger?.close();
585
598
  });
@@ -587,7 +600,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
587
600
  // Re-register
588
601
  this.projectGraphListenerMessenger.sendMessage({
589
602
  type: register_project_graph_listener_1.REGISTER_PROJECT_GRAPH_LISTENER,
590
- @@ -749,27 +859,6 @@ class DaemonClient {
603
+ @@ -749,27 +858,6 @@ class DaemonClient {
591
604
  };
592
605
  return this.sendToDaemonViaQueue(message);
593
606
  }
@@ -615,7 +628,28 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
615
628
  getSyncGeneratorChanges(generators) {
616
629
  const message = {
617
630
  type: get_sync_generator_changes_1.GET_SYNC_GENERATOR_CHANGES,
618
- @@ -890,6 +979,9 @@ class DaemonClient {
631
+ @@ -813,20 +901,6 @@ class DaemonClient {
632
+ };
633
+ return this.sendToDaemonViaQueue(message);
634
+ }
635
+ - async runPreTasksExecution(context) {
636
+ - const message = {
637
+ - type: run_tasks_execution_hooks_1.PRE_TASKS_EXECUTION,
638
+ - context,
639
+ - };
640
+ - return this.sendToDaemonViaQueue(message);
641
+ - }
642
+ - async runPostTasksExecution(context) {
643
+ - const message = {
644
+ - type: run_tasks_execution_hooks_1.POST_TASKS_EXECUTION,
645
+ - context,
646
+ - };
647
+ - return this.sendToDaemonViaQueue(message);
648
+ - }
649
+ getNxConsoleStatus() {
650
+ const message = {
651
+ type: nx_console_1.GET_NX_CONSOLE_STATUS,
652
+ @@ -890,6 +964,9 @@ class DaemonClient {
619
653
  if (this._pluginWorkerConnectionLost) {
620
654
  throw this._pluginWorkerConnectionLost;
621
655
  }
@@ -625,7 +659,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
625
659
  if (this._daemonStatus == DaemonStatus.CONNECTED) {
626
660
  return;
627
661
  }
628
- @@ -915,6 +1007,10 @@ class DaemonClient {
662
+ @@ -915,6 +992,10 @@ class DaemonClient {
629
663
  }
630
664
  }
631
665
  if (!probe.available) {
@@ -636,7 +670,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
636
670
  // Carried as a value so no other caller's probe can substitute for it.
637
671
  daemonPid = await this.startInBackground(probe.refusal);
638
672
  }
639
- @@ -953,17 +1049,36 @@ class DaemonClient {
673
+ @@ -953,17 +1034,36 @@ class DaemonClient {
640
674
  }
641
675
  }
642
676
  async sendToDaemonViaQueue(messageToDaemon, spinner) {
@@ -683,7 +717,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
683
717
  }
684
718
  setUpConnection() {
685
719
  const socketPath = this.getSocketPath();
686
- @@ -972,7 +1087,13 @@ class DaemonClient {
720
+ @@ -972,7 +1072,13 @@ class DaemonClient {
687
721
  // sendMessageToDaemon method uses a keep-alive setTimeout to
688
722
  // explicitly hold the event loop open while awaiting a response.
689
723
  socket.unref();
@@ -698,7 +732,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
698
732
  // it's ok for the daemon to terminate if the client doesn't wait on
699
733
  // any messages from the daemon
700
734
  if (this.queue.isEmpty()) {
701
- @@ -1018,12 +1139,22 @@ class DaemonClient {
735
+ @@ -1018,12 +1124,22 @@ class DaemonClient {
702
736
  else {
703
737
  error = daemonProcessException(err.toString());
704
738
  }
@@ -721,7 +755,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
721
755
  // A plugin worker cannot bring a daemon back — `startInBackground` throws
722
756
  // in one — and it is usually hosted by the daemon that just died, so the
723
757
  // 60s reconnect poll almost always ends in the same failure. Make the loss
724
- @@ -1066,16 +1197,18 @@ class DaemonClient {
758
+ @@ -1066,16 +1182,18 @@ class DaemonClient {
725
759
  }
726
760
  }
727
761
  catch (err) {
@@ -748,7 +782,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
748
782
  throw err;
749
783
  }
750
784
  }
751
- @@ -1137,14 +1270,31 @@ class DaemonClient {
785
+ @@ -1137,14 +1255,31 @@ class DaemonClient {
752
786
  return { available: false, refusal };
753
787
  }
754
788
  async sendMessageToDaemon(message) {
@@ -780,7 +814,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
780
814
  return new Promise((resolve, reject) => {
781
815
  perf_hooks_1.performance.mark('sendMessageToDaemon-start');
782
816
  // An open promise isn't enough to keep the event loop
783
- @@ -1155,12 +1305,25 @@ class DaemonClient {
817
+ @@ -1155,12 +1290,25 @@ class DaemonClient {
784
818
  keepAlive = setTimeout(() => {
785
819
  reject(new Error('The daemon timed out while processing ' + message.type));
786
820
  }, 20 * 60 * 1000);
@@ -806,7 +840,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
806
840
  });
807
841
  }
808
842
  async registerDaemonProcessWithMetricsService(daemonPid) {
809
- @@ -1194,7 +1357,13 @@ class DaemonClient {
843
+ @@ -1194,7 +1342,13 @@ class DaemonClient {
810
844
  console[parsedResult.level](parsedResult.message);
811
845
  return;
812
846
  }
@@ -821,7 +855,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
821
855
  this.currentReject(parsedResult.error);
822
856
  }
823
857
  else {
824
- @@ -1271,8 +1440,11 @@ class DaemonClient {
858
+ @@ -1271,8 +1425,11 @@ class DaemonClient {
825
859
  */
826
860
  const { available, refusal: polled } = await this.waitForServerToBeAvailable({ ignoreVersionMismatch: true });
827
861
  if (available) {
@@ -835,7 +869,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
835
869
  }
836
870
  else {
837
871
  // A permission refusal from either source wins, then the poll's errno,
838
- @@ -1300,19 +1472,31 @@ class DaemonClient {
872
+ @@ -1300,19 +1457,31 @@ class DaemonClient {
839
873
  ].join('\n'));
840
874
  }
841
875
  }
@@ -877,7 +911,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..0555ac8faebbe0d3dae8e758a0e6b51d
877
911
  }
878
912
  }
879
913
  (0, tmp_dir_1.removeSocketDir)();
880
- @@ -1339,6 +1523,59 @@ function isDocker() {
914
+ @@ -1339,6 +1508,59 @@ function isDocker() {
881
915
  function nxJsonIsNotPresent() {
882
916
  return !(0, nx_json_1.hasNxJson)(workspace_root_1.workspaceRoot);
883
917
  }
@@ -1304,6 +1338,51 @@ index e7a63499d18a3a8896fb117591356c3bb138032a..8d03082ada878fedd70c6245791f4c69
1304
1338
  }
1305
1339
  /**
1306
1340
  * Throws on a message this receiver must not act on. The daemon catches it and
1341
+ diff --git a/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts b/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts
1342
+ deleted file mode 100644
1343
+ index f3986f288394dd45b36ee70c3e8cd5b0230c3391..0000000000000000000000000000000000000000
1344
+ --- a/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts
1345
+ +++ /dev/null
1346
+ @@ -1,14 +0,0 @@
1347
+ -import type { PreTasksExecutionContext } from '../../project-graph/plugins';
1348
+ -import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/plugins/task-results-stub';
1349
+ -export declare const PRE_TASKS_EXECUTION: 'PRE_TASKS_EXECUTION';
1350
+ -export declare const POST_TASKS_EXECUTION: 'POST_TASKS_EXECUTION';
1351
+ -export type HandlePreTasksExecutionMessage = {
1352
+ - type: typeof PRE_TASKS_EXECUTION;
1353
+ - context: PreTasksExecutionContext;
1354
+ -};
1355
+ -export type HandlePostTasksExecutionMessage = {
1356
+ - type: typeof POST_TASKS_EXECUTION;
1357
+ - context: MaybeStubbedPostTasksExecutionContext;
1358
+ -};
1359
+ -export declare function isHandlePreTasksExecutionMessage(message: unknown): message is HandlePreTasksExecutionMessage;
1360
+ -export declare function isHandlePostTasksExecutionMessage(message: unknown): message is HandlePostTasksExecutionMessage;
1361
+ diff --git a/dist/src/daemon/message-types/run-tasks-execution-hooks.js b/dist/src/daemon/message-types/run-tasks-execution-hooks.js
1362
+ deleted file mode 100644
1363
+ index ba3abde11e4c444339882a65e3368e6f5054f56f..0000000000000000000000000000000000000000
1364
+ --- a/dist/src/daemon/message-types/run-tasks-execution-hooks.js
1365
+ +++ /dev/null
1366
+ @@ -1,19 +0,0 @@
1367
+ -"use strict";
1368
+ -Object.defineProperty(exports, "__esModule", { value: true });
1369
+ -exports.POST_TASKS_EXECUTION = exports.PRE_TASKS_EXECUTION = void 0;
1370
+ -exports.isHandlePreTasksExecutionMessage = isHandlePreTasksExecutionMessage;
1371
+ -exports.isHandlePostTasksExecutionMessage = isHandlePostTasksExecutionMessage;
1372
+ -exports.PRE_TASKS_EXECUTION = 'PRE_TASKS_EXECUTION';
1373
+ -exports.POST_TASKS_EXECUTION = 'POST_TASKS_EXECUTION';
1374
+ -function isHandlePreTasksExecutionMessage(message) {
1375
+ - return (typeof message === 'object' &&
1376
+ - message !== null &&
1377
+ - 'type' in message &&
1378
+ - message['type'] === exports.PRE_TASKS_EXECUTION);
1379
+ -}
1380
+ -function isHandlePostTasksExecutionMessage(message) {
1381
+ - return (typeof message === 'object' &&
1382
+ - message !== null &&
1383
+ - 'type' in message &&
1384
+ - message['type'] === exports.POST_TASKS_EXECUTION);
1385
+ -}
1307
1386
  diff --git a/dist/src/daemon/message-types/task-history.d.ts b/dist/src/daemon/message-types/task-history.d.ts
1308
1387
  deleted file mode 100644
1309
1388
  index cc2b606d99db19beb05d85e5ec2f13600712e7bd..0000000000000000000000000000000000000000
@@ -1364,10 +1443,10 @@ index 12c1507aec3cf894bc18c680818bf76ec1533cca..00000000000000000000000000000000
1364
1443
  -}
1365
1444
  diff --git a/dist/src/daemon/server/file-watching/watch-probe.d.ts b/dist/src/daemon/server/file-watching/watch-probe.d.ts
1366
1445
  new file mode 100644
1367
- index 0000000000000000000000000000000000000000..86526ad3fdf29ad815e3838deb54ae0442abadd3
1446
+ index 0000000000000000000000000000000000000000..2c6c035de438e7a25e5655216a53ac35c41f3385
1368
1447
  --- /dev/null
1369
1448
  +++ b/dist/src/daemon/server/file-watching/watch-probe.d.ts
1370
- @@ -0,0 +1,14 @@
1449
+ @@ -0,0 +1,15 @@
1371
1450
  +import type { WatchEvent } from '../../../native';
1372
1451
  +/**
1373
1452
  + * The paths the daemon's watch must admit for its probes (`alwaysWatch`), to
@@ -1379,15 +1458,16 @@ index 0000000000000000000000000000000000000000..86526ad3fdf29ad815e3838deb54ae04
1379
1458
  +export declare function takeProbeEvents(events: WatchEvent[]): WatchEvent[];
1380
1459
  +/**
1381
1460
  + * Resolves `undefined` once everything written before the call has reached
1382
- + * the daemon, or the reason the watch's stream cannot be proven current.
1461
+ + * the daemon, or the reason the watch's stream cannot be proven current. A
1462
+ + * call that resolves `undefined` has also walked the files again.
1383
1463
  + */
1384
1464
  +export declare function proveWatcherCurrent(): Promise<string | undefined>;
1385
1465
  diff --git a/dist/src/daemon/server/file-watching/watch-probe.js b/dist/src/daemon/server/file-watching/watch-probe.js
1386
1466
  new file mode 100644
1387
- index 0000000000000000000000000000000000000000..84f36a3e211cb168dc3c7d6e94157d542e6a1ec0
1467
+ index 0000000000000000000000000000000000000000..a3020e12bc219b7cbedb441a0a049ca8173d8c60
1388
1468
  --- /dev/null
1389
1469
  +++ b/dist/src/daemon/server/file-watching/watch-probe.js
1390
- @@ -0,0 +1,159 @@
1470
+ @@ -0,0 +1,167 @@
1391
1471
  +'use strict';
1392
1472
  +Object.defineProperty(exports, '__esModule', { value: true });
1393
1473
  +exports.watchProbeAdmissions = watchProbeAdmissions;
@@ -1541,6 +1621,14 @@ index 0000000000000000000000000000000000000000..84f36a3e211cb168dc3c7d6e94157d54
1541
1621
  + logger_1.serverLogger.watcherLog(
1542
1622
  + `watcher current: probe came back in ${(node_perf_hooks_1.performance.now() - writtenAt).toFixed(1)} ms`,
1543
1623
  + );
1624
+ + // A probe proves the stream only from its own write on. The files the
1625
+ + // daemon holds can still lack a write the stream never delivered: one its
1626
+ + // boot walk read past before the stream delivered it, or one fseventsd
1627
+ + // dropped, whose rescan flag can arrive after a later probe came back. So
1628
+ + // every probe that comes back is followed by one walk of the files, and what
1629
+ + // that walk finds changed is routed before the request is answered.
1630
+ + const changed = (0, project_graph_incremental_recomputation_1.rewalkWorkspaceChanges)();
1631
+ + logger_1.serverLogger.watcherLog(`files walked after the probe: ${changed} changed`);
1544
1632
  + return undefined;
1545
1633
  + } finally {
1546
1634
  + probesAwaited.delete(probe);
@@ -1602,6 +1690,73 @@ index 0051f7f97f0d9c05341f8cbaa7f51eb851051077..00000000000000000000000000000000
1602
1690
  - description: 'handleGetEstimatedTaskTimings',
1603
1691
  - };
1604
1692
  -}
1693
+ diff --git a/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts b/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts
1694
+ deleted file mode 100644
1695
+ index b7a9b3637f1306a650cc3954172fe93b82c2db40..0000000000000000000000000000000000000000
1696
+ --- a/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts
1697
+ +++ /dev/null
1698
+ @@ -1,20 +0,0 @@
1699
+ -import type { PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
1700
+ -import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/plugins/task-results-stub';
1701
+ -export declare function handleRunPreTasksExecution(context: PreTasksExecutionContext): Promise<{
1702
+ - response: NodeJS.ProcessEnv[];
1703
+ - description: string;
1704
+ - error?: undefined;
1705
+ -} | {
1706
+ - response?: undefined;
1707
+ - error: any;
1708
+ - description: string;
1709
+ -}>;
1710
+ -export declare function handleRunPostTasksExecution(context: MaybeStubbedPostTasksExecutionContext): Promise<{
1711
+ - error?: undefined;
1712
+ - response: string;
1713
+ - description: string;
1714
+ -} | {
1715
+ - response?: undefined;
1716
+ - error: any;
1717
+ - description: string;
1718
+ -}>;
1719
+ diff --git a/dist/src/daemon/server/handle-tasks-execution-hooks.js b/dist/src/daemon/server/handle-tasks-execution-hooks.js
1720
+ deleted file mode 100644
1721
+ index 2d5c114ed5c9b2b55acd614d8c306fabc362b408..0000000000000000000000000000000000000000
1722
+ --- a/dist/src/daemon/server/handle-tasks-execution-hooks.js
1723
+ +++ /dev/null
1724
+ @@ -1,35 +0,0 @@
1725
+ -"use strict";
1726
+ -Object.defineProperty(exports, "__esModule", { value: true });
1727
+ -exports.handleRunPreTasksExecution = handleRunPreTasksExecution;
1728
+ -exports.handleRunPostTasksExecution = handleRunPostTasksExecution;
1729
+ -const tasks_execution_hooks_1 = require("../../project-graph/plugins/tasks-execution-hooks");
1730
+ -async function handleRunPreTasksExecution(context) {
1731
+ - try {
1732
+ - const envs = await (0, tasks_execution_hooks_1.runPreTasksExecution)(context);
1733
+ - return {
1734
+ - response: envs,
1735
+ - description: 'handleRunPreTasksExecution',
1736
+ - };
1737
+ - }
1738
+ - catch (e) {
1739
+ - return {
1740
+ - error: e,
1741
+ - description: `Error when running preTasksExecution.`,
1742
+ - };
1743
+ - }
1744
+ -}
1745
+ -async function handleRunPostTasksExecution(context) {
1746
+ - try {
1747
+ - await (0, tasks_execution_hooks_1.runPostTasksExecution)(context);
1748
+ - return {
1749
+ - response: 'true',
1750
+ - description: 'handleRunPostTasksExecution',
1751
+ - };
1752
+ - }
1753
+ - catch (e) {
1754
+ - return {
1755
+ - error: e,
1756
+ - description: `Error when running postTasksExecution.`,
1757
+ - };
1758
+ - }
1759
+ -}
1605
1760
  diff --git a/dist/src/daemon/server/latest-nx.js b/dist/src/daemon/server/latest-nx.js
1606
1761
  index ef00ae3212498e75d6bb6371aec4b113970c0c68..06eb2bf7436cc20dad1d646be44ba99064395f3d 100644
1607
1762
  --- a/dist/src/daemon/server/latest-nx.js
@@ -1618,11 +1773,36 @@ index ef00ae3212498e75d6bb6371aec4b113970c0c68..06eb2bf7436cc20dad1d646be44ba990
1618
1773
  if (latestNxTmpPath !== null) {
1619
1774
  logger_1.serverLogger.log('[LATEST-NX]: Reusing cached Nx installation from', latestNxTmpPath);
1620
1775
  return latestNxTmpPath;
1776
+ diff --git a/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts b/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts
1777
+ index 63638e921d68af659ca03f65e82a98c1e2e3f853..b329afc3da3053a3460c44c6ae67130459e820f6 100644
1778
+ --- a/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts
1779
+ +++ b/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts
1780
+ @@ -32,6 +32,12 @@ export declare function routeAppliedChanges(batch: ChangeBatch): void;
1781
+ * saw is never missed.
1782
+ */
1783
+ export declare function flushPendingWorkspaceChanges(): Promise<void>;
1784
+ +/**
1785
+ + * Walks the workspace's files again and routes what changed against the files
1786
+ + * the context held, for files no watch event vouches for. Answers how many
1787
+ + * files changed.
1788
+ + */
1789
+ +export declare function rewalkWorkspaceChanges(): number;
1790
+ /**
1791
+ * Applies changes a caller learned of on its own to the workspace context,
1792
+ * then schedules the recomputation as for a batch the context applied.
1621
1793
  diff --git a/dist/src/daemon/server/project-graph-incremental-recomputation.js b/dist/src/daemon/server/project-graph-incremental-recomputation.js
1622
- index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..7b8e536cf989571698d2b693f9ea29951cbc31f3 100644
1794
+ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..8e3192fef166f49c246aef0ff87b4084683cb840 100644
1623
1795
  --- a/dist/src/daemon/server/project-graph-incremental-recomputation.js
1624
1796
  +++ b/dist/src/daemon/server/project-graph-incremental-recomputation.js
1625
- @@ -17,6 +17,7 @@ const error_types_1 = require("../../project-graph/error-types");
1797
+ @@ -4,6 +4,7 @@ exports.currentSourceMaps = exports.currentProjectGraph = exports.currentProject
1798
+ exports.getCachedSerializedProjectGraphPromise = getCachedSerializedProjectGraphPromise;
1799
+ exports.routeAppliedChanges = routeAppliedChanges;
1800
+ exports.flushPendingWorkspaceChanges = flushPendingWorkspaceChanges;
1801
+ +exports.rewalkWorkspaceChanges = rewalkWorkspaceChanges;
1802
+ exports.scheduleProjectGraphRecomputation = scheduleProjectGraphRecomputation;
1803
+ exports.scheduleInitialProjectGraphComputation = scheduleInitialProjectGraphComputation;
1804
+ exports.registerProjectGraphRecomputationListener = registerProjectGraphRecomputationListener;
1805
+ @@ -17,6 +18,7 @@ const error_types_1 = require("../../project-graph/error-types");
1626
1806
  const file_map_utils_1 = require("../../project-graph/file-map-utils");
1627
1807
  const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
1628
1808
  const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
@@ -1630,7 +1810,7 @@ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..7b8e536cf989571698d2b693f9ea2995
1630
1810
  const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
1631
1811
  const fileutils_1 = require("../../utils/fileutils");
1632
1812
  const workspace_context_1 = require("../../utils/workspace-context");
1633
- @@ -77,7 +78,7 @@ function kickOffRecompute() {
1813
+ @@ -77,7 +79,7 @@ function kickOffRecompute() {
1634
1814
  // the plugin loader's) into one, so the snap hash and the plugin
1635
1815
  // set the compute uses always reflect the same disk state.
1636
1816
  const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
@@ -1639,7 +1819,7 @@ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..7b8e536cf989571698d2b693f9ea2995
1639
1819
  const plugins = await (0, get_plugins_1.getPluginsSeparated)(nxJson, workspace_root_1.workspaceRoot);
1640
1820
  // Plugin set we just loaded may already be stale vs disk.
1641
1821
  if (isStale(myPluginsHash))
1642
- @@ -118,13 +119,13 @@ function isStale(expectedHash) {
1822
+ @@ -118,13 +120,13 @@ function isStale(expectedHash) {
1643
1823
  * pointer so awaiters chain onto it.
1644
1824
  */
1645
1825
  function chainToSuccessor(myPromise) {
@@ -1655,7 +1835,7 @@ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..7b8e536cf989571698d2b693f9ea2995
1655
1835
  }
1656
1836
  async function getCachedSerializedProjectGraphPromise(socket) {
1657
1837
  // Subscribe the requesting client to the graph-construction topic
1658
- @@ -238,13 +239,18 @@ function summarize(files) {
1838
+ @@ -238,13 +240,18 @@ function summarize(files) {
1659
1839
  }
1660
1840
  /**
1661
1841
  * Takes in changes the workspace context handed out: restarts the daemon if
@@ -1676,6 +1856,29 @@ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..7b8e536cf989571698d2b693f9ea2995
1676
1856
  logger_1.serverLogger.watcherLog(`File changes detected (seq ${batch.seq}):\n` +
1677
1857
  `Created:\n${summarize((0, restart_checks_1.fileNames)(batch.createdFiles))}\n` +
1678
1858
  `Updated:\n${summarize((0, restart_checks_1.fileNames)(batch.updatedFiles))}\n` +
1859
+ @@ -268,6 +275,22 @@ async function flushPendingWorkspaceChanges() {
1860
+ }
1861
+ routeAppliedChanges(batch);
1862
+ }
1863
+ +/**
1864
+ + * Walks the workspace's files again and routes what changed against the files
1865
+ + * the context held, for files no watch event vouches for. Answers how many
1866
+ + * files changed.
1867
+ + */
1868
+ +function rewalkWorkspaceChanges() {
1869
+ + if (!(0, workspace_context_1.isWatchingWorkspaceContext)())
1870
+ + return 0;
1871
+ + (0, workspace_context_1.rescanWorkspaceContext)(workspace_root_1.workspaceRoot);
1872
+ + const batch = (0, workspace_context_1.takeAppliedWorkspaceChanges)(workspace_root_1.workspaceRoot);
1873
+ + if ((0, workspace_context_1.isEmptyBatch)(batch)) {
1874
+ + return 0;
1875
+ + }
1876
+ + routeAppliedChanges(batch);
1877
+ + return batch.createdFiles.length + batch.updatedFiles.length + batch.deletedFiles.length;
1878
+ +}
1879
+ /**
1880
+ * Applies changes a caller learned of on its own to the workspace context,
1881
+ * then schedules the recomputation as for a batch the context applied.
1679
1882
  diff --git a/dist/src/daemon/server/restart-checks.d.ts b/dist/src/daemon/server/restart-checks.d.ts
1680
1883
  index e99e10b616b35b81b1060b25eeb0acc2351c4776..e94e74921349d081353fc14498178ccec8fbe42f 100644
1681
1884
  --- a/dist/src/daemon/server/restart-checks.d.ts
@@ -2235,7 +2438,7 @@ index e692c3cfc73bacf3252e117d4e895b981412f4b9..94c06c88dfac8df73dd1c12f5c09b900
2235
2438
  + (0, shutdown_utils_1.handleServerProcessTerminationWithRestart)({ server: daemon.server, reason, sockets: daemon.sockets, notice });
2236
2439
  }
2237
2440
  diff --git a/dist/src/daemon/server/server.js b/dist/src/daemon/server/server.js
2238
- index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bfa7709a66 100644
2441
+ index 5989aac4d2d8d860033f93d369efb54133a4d715..9064121a456494d96f611ac8043b8fdf265a4ad5 100644
2239
2442
  --- a/dist/src/daemon/server/server.js
2240
2443
  +++ b/dist/src/daemon/server/server.js
2241
2444
  @@ -8,16 +8,12 @@ const fs_1 = require("fs");
@@ -2255,10 +2458,11 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2255
2458
  const installed_nx_version_1 = require("../../utils/installed-nx-version");
2256
2459
  const logger_1 = require("../logger");
2257
2460
  const configure_ai_agents_1 = require("../message-types/configure-ai-agents");
2258
- @@ -36,11 +32,12 @@ const hash_glob_1 = require("../message-types/hash-glob");
2461
+ @@ -35,12 +31,12 @@ const glob_1 = require("../message-types/glob");
2462
+ const hash_glob_1 = require("../message-types/hash-glob");
2259
2463
  const nx_console_1 = require("../message-types/nx-console");
2260
2464
  const register_project_graph_listener_1 = require("../message-types/register-project-graph-listener");
2261
- const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-execution-hooks");
2465
+ -const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-execution-hooks");
2262
2466
  -const task_history_1 = require("../message-types/task-history");
2263
2467
  const update_workspace_context_1 = require("../message-types/update-workspace-context");
2264
2468
  const socket_utils_1 = require("../socket-utils");
@@ -2269,15 +2473,16 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2269
2473
  const handle_configure_ai_agents_1 = require("./handle-configure-ai-agents");
2270
2474
  const handle_context_file_data_1 = require("./handle-context-file-data");
2271
2475
  const handle_flush_sync_generator_changes_to_disk_1 = require("./handle-flush-sync-generator-changes-to-disk");
2272
- @@ -60,7 +57,6 @@ const handle_outputs_tracking_1 = require("./handle-outputs-tracking");
2476
+ @@ -60,8 +56,6 @@ const handle_outputs_tracking_1 = require("./handle-outputs-tracking");
2273
2477
  const handle_process_in_background_1 = require("./handle-process-in-background");
2274
2478
  const handle_request_project_graph_1 = require("./handle-request-project-graph");
2275
2479
  const handle_request_shutdown_1 = require("./handle-request-shutdown");
2276
2480
  -const handle_task_history_1 = require("./handle-task-history");
2277
- const handle_tasks_execution_hooks_1 = require("./handle-tasks-execution-hooks");
2481
+ -const handle_tasks_execution_hooks_1 = require("./handle-tasks-execution-hooks");
2278
2482
  const handle_update_workspace_context_1 = require("./handle-update-workspace-context");
2279
2483
  const handle_watch_events_1 = require("./handle-watch-events");
2280
- @@ -70,7 +66,6 @@ const project_graph_listener_sockets_1 = require("./project-graph-listener-socke
2484
+ const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
2485
+ @@ -70,7 +64,6 @@ const project_graph_listener_sockets_1 = require("./project-graph-listener-socke
2281
2486
  const shutdown_utils_1 = require("./shutdown-utils");
2282
2487
  const sync_generators_1 = require("./sync-generators");
2283
2488
  const workspace_context_1 = require("../../utils/workspace-context");
@@ -2285,7 +2490,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2285
2490
  let workspaceWatcherError;
2286
2491
  global.NX_DAEMON = true;
2287
2492
  process.env.NX_DAEMON_PROCESS = 'true';
2288
- @@ -102,11 +97,17 @@ const server = (0, net_1.createServer)(async (socket) => {
2493
+ @@ -102,11 +95,17 @@ const server = (0, net_1.createServer)(async (socket) => {
2289
2494
  numberOfOpenConnections -= 1;
2290
2495
  exports.openSockets.delete(socket);
2291
2496
  logger_1.serverLogger.log(`Closed a connection. Number of open connections: ${numberOfOpenConnections}`);
@@ -2303,7 +2508,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2303
2508
  async function handleMessage(socket, data) {
2304
2509
  if (workspaceWatcherError) {
2305
2510
  await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `File watcher error in the workspace '${workspace_root_1.workspaceRoot}'.`, workspaceWatcherError);
2306
- @@ -139,14 +140,46 @@ async function handleMessage(socket, data) {
2511
+ @@ -139,14 +138,46 @@ async function handleMessage(socket, data) {
2307
2512
  return;
2308
2513
  }
2309
2514
  }
@@ -2351,7 +2556,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2351
2556
  }
2352
2557
  else if (payload.type === 'HASH_TASKS') {
2353
2558
  await handleResult(socket, 'HASH_TASKS', () => (0, handle_hash_tasks_1.handleHashTasks)(payload), mode);
2354
- @@ -206,15 +239,6 @@ async function handleMessage(socket, data) {
2559
+ @@ -206,15 +237,6 @@ async function handleMessage(socket, data) {
2355
2560
  else if ((0, hash_glob_1.isHandleHashMultiGlobMessage)(payload)) {
2356
2561
  await handleResult(socket, hash_glob_1.HASH_GLOB, () => (0, handle_hash_glob_1.handleHashMultiGlob)(payload.globGroups), mode);
2357
2562
  }
@@ -2367,7 +2572,20 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2367
2572
  else if ((0, force_shutdown_1.isHandleForceShutdownMessage)(payload)) {
2368
2573
  await handleResult(socket, 'FORCE_SHUTDOWN', () => (0, handle_force_shutdown_1.handleForceShutdown)(server), mode);
2369
2574
  }
2370
- @@ -258,6 +282,22 @@ async function handleMessage(socket, data) {
2575
+ @@ -236,12 +258,6 @@ async function handleMessage(socket, data) {
2576
+ else if ((0, update_workspace_context_1.isHandleUpdateWorkspaceContextMessage)(payload)) {
2577
+ await handleResult(socket, update_workspace_context_1.UPDATE_WORKSPACE_CONTEXT, () => (0, handle_update_workspace_context_1.handleUpdateWorkspaceContext)(payload.createdFiles, payload.updatedFiles, payload.deletedFiles), mode);
2578
+ }
2579
+ - else if ((0, run_tasks_execution_hooks_1.isHandlePreTasksExecutionMessage)(payload)) {
2580
+ - await handleResult(socket, run_tasks_execution_hooks_1.PRE_TASKS_EXECUTION, () => (0, handle_tasks_execution_hooks_1.handleRunPreTasksExecution)(payload.context), mode);
2581
+ - }
2582
+ - else if ((0, run_tasks_execution_hooks_1.isHandlePostTasksExecutionMessage)(payload)) {
2583
+ - await handleResult(socket, run_tasks_execution_hooks_1.POST_TASKS_EXECUTION, () => (0, handle_tasks_execution_hooks_1.handleRunPostTasksExecution)(payload.context), mode);
2584
+ - }
2585
+ else if ((0, nx_console_1.isHandleGetNxConsoleStatusMessage)(payload)) {
2586
+ await handleResult(socket, nx_console_1.GET_NX_CONSOLE_STATUS, () => (0, handle_nx_console_1.handleGetNxConsoleStatus)(), mode);
2587
+ }
2588
+ @@ -258,6 +274,22 @@ async function handleMessage(socket, data) {
2371
2589
  await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `Invalid payload from the client`, new Error(`Unsupported payload sent to daemon server: ${(0, consume_messages_from_socket_1.describeMessage)(unparsedPayload, { maxBytes: 200 })}`));
2372
2590
  }
2373
2591
  }
@@ -2390,7 +2608,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2390
2608
  async function handleResult(socket, type, hrFn, mode, respondToError = shutdown_utils_1.respondWithErrorAndExit) {
2391
2609
  let hr;
2392
2610
  const startMark = new Date();
2393
- @@ -283,9 +323,10 @@ async function handleResult(socket, type, hrFn, mode, respondToError = shutdown_
2611
+ @@ -283,9 +315,10 @@ async function handleResult(socket, type, hrFn, mode, respondToError = shutdown_
2394
2612
  logger_1.serverLogger.log(`Handled ${mode} message ${type}. Handling time: ${doneHandlingMark.getTime() - startMark.getTime()}. Response time: ${endMark.getTime() - doneHandlingMark.getTime()}.`);
2395
2613
  }
2396
2614
  function handleInactivityTimeout() {
@@ -2403,7 +2621,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2403
2621
  (0, shutdown_utils_1.resetInactivityTimeout)(handleInactivityTimeout);
2404
2622
  }
2405
2623
  else {
2406
- @@ -314,35 +355,21 @@ function registerProcessTerminationListeners() {
2624
+ @@ -314,35 +347,21 @@ function registerProcessTerminationListeners() {
2407
2625
  sockets: exports.openSockets,
2408
2626
  }));
2409
2627
  }
@@ -2453,7 +2671,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2453
2671
  }
2454
2672
  }
2455
2673
  /**
2456
- @@ -365,6 +392,10 @@ const handleWorkspaceChanges = (err, batch) => {
2674
+ @@ -365,6 +384,10 @@ const handleWorkspaceChanges = (err, batch) => {
2457
2675
  (0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(error);
2458
2676
  return;
2459
2677
  }
@@ -2464,7 +2682,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2464
2682
  (0, project_graph_incremental_recomputation_1.routeAppliedChanges)(batch);
2465
2683
  }
2466
2684
  catch (err) {
2467
- @@ -374,68 +405,90 @@ const handleWorkspaceChanges = (err, batch) => {
2685
+ @@ -374,68 +397,90 @@ const handleWorkspaceChanges = (err, batch) => {
2468
2686
  (0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(err);
2469
2687
  }
2470
2688
  };
@@ -2595,7 +2813,7 @@ index 5989aac4d2d8d860033f93d369efb54133a4d715..c6b75a1303a3a5ffb47fc38d928dd1bf
2595
2813
  return new Promise(async (resolve, reject) => {
2596
2814
  // `listen` reports a failed bind asynchronously on the server, which the
2597
2815
  // try below cannot catch — without this an EACCES became an uncaught
2598
- @@ -461,33 +514,16 @@ async function startServer() {
2816
+ @@ -461,33 +506,16 @@ async function startServer() {
2599
2817
  // Best effort; the 0700 socket directory is the primary control.
2600
2818
  }
2601
2819
  }
@@ -2959,7 +3177,7 @@ index 1914a3eca8b47318a3aede3990836f5e757501ce..efc124fa0f23869852af305b5e77961a
2959
3177
  return this.inspector.inspectInputs(plansReference);
2960
3178
  }
2961
3179
  diff --git a/dist/src/hasher/native-task-hasher-impl.js b/dist/src/hasher/native-task-hasher-impl.js
2962
- index 5812bc2b6c931a98193985115a15d3050e2d1020..92095397db52325e9de4278d7295882523d58e72 100644
3180
+ index 5812bc2b6c931a98193985115a15d3050e2d1020..ec4f0a1b2428936062ce2beb146ac92f27fc7054 100644
2963
3181
  --- a/dist/src/hasher/native-task-hasher-impl.js
2964
3182
  +++ b/dist/src/hasher/native-task-hasher-impl.js
2965
3183
  @@ -50,12 +50,13 @@ class NativeTaskHasherImpl {
@@ -2968,13 +3186,13 @@ index 5812bc2b6c931a98193985115a15d3050e2d1020..92095397db52325e9de4278d72958825
2968
3186
  taskGraphFingerprint(taskGraph, ultracacheConfigurations)) {
2969
3187
  - Object.assign(hashes, this.hasher.hashPlansFor(this.upfrontPlans.plans, unplanned, envs, resolvedCwd, shouldCollectInputs));
2970
3188
  + const { plans } = this.upfrontPlans;
2971
- + Object.assign(hashes, nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlansFor(plans, unplanned, envs, resolvedCwd, shouldCollectInputs)));
3189
+ + Object.assign(hashes, keyOwnTargetConfiguration(nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlansFor(plans, unplanned, envs, resolvedCwd, shouldCollectInputs)), taskGraph, this.projectGraph));
2972
3190
  unplanned = unplanned.filter((id) => !(id in hashes));
2973
3191
  }
2974
3192
  if (unplanned.length > 0) {
2975
3193
  const plans = this.plan(unplanned, taskGraph, ultracacheConfigurations);
2976
3194
  - Object.assign(hashes, this.hasher.hashPlans(plans, envs, resolvedCwd, shouldCollectInputs));
2977
- + Object.assign(hashes, nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlans(plans, envs, resolvedCwd, shouldCollectInputs)));
3195
+ + Object.assign(hashes, keyOwnTargetConfiguration(nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlans(plans, envs, resolvedCwd, shouldCollectInputs)), taskGraph, this.projectGraph));
2978
3196
  }
2979
3197
  return tasks.map((t) => hashes[t.id]);
2980
3198
  }
@@ -2993,14 +3211,89 @@ index 5812bc2b6c931a98193985115a15d3050e2d1020..92095397db52325e9de4278d72958825
2993
3211
  };
2994
3212
  const shouldCollectInputs = collectInputs ?? (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
2995
3213
  - return this.hasher.hashPlansUpfront(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
2996
- + return nameHashFailure(taskIds, this.planner, taskGraph, () => this.hasher.hashPlansUpfront(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs));
3214
+ + return keyOwnTargetConfiguration(nameHashFailure(taskIds, this.planner, taskGraph, () => this.hasher.hashPlansUpfront(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs)), taskGraph, this.projectGraph);
2997
3215
  }
2998
3216
  }
2999
3217
  exports.NativeTaskHasherImpl = NativeTaskHasherImpl;
3000
- @@ -104,3 +106,60 @@ function taskGraphFingerprint(taskGraph, ultracacheConfigurations) {
3218
+ @@ -104,3 +106,135 @@ function taskGraphFingerprint(taskGraph, ultracacheConfigurations) {
3001
3219
  }
3002
3220
  return (0, native_1.hashArray)(parts);
3003
3221
  }
3222
+ +const PROJECT_CONFIGURATION = ':ProjectConfiguration';
3223
+ +/**
3224
+ + * The native `ProjectConfiguration` node (`hash_project_config.rs`) hashes the
3225
+ + * executor, outputs, options, configurations and parallelism of every target
3226
+ + * of a project, so an edit to one target re-keyed every task of that project
3227
+ + * and every task whose `^` inputs reach it. A task's key holds the
3228
+ + * configuration it runs: the node of the task's own project hashes the
3229
+ + * project's root, tags and named inputs and the task's own target; the node of
3230
+ + * a project its `^` inputs reach hashes that project's root, tags and named
3231
+ + * inputs, through which those inputs resolve. The task's value folds its
3232
+ + * details again, their values in key order, as the native hasher does.
3233
+ + * Upstream: https://github.com/nrwl/nx/issues/37802 and the pull request that
3234
+ + * fixes it; drop this once the installed Nx keys a task's own target only.
3235
+ + */
3236
+ +function keyOwnTargetConfiguration(hashes, taskGraph, projectGraph) {
3237
+ + const configurations = new Map();
3238
+ + const configuration = (project, target) => {
3239
+ + const id = JSON.stringify([project, target]);
3240
+ + let hashed = configurations.get(id);
3241
+ + if (hashed === undefined) {
3242
+ + hashed = projectConfigurationHash(projectGraph, project, target);
3243
+ + configurations.set(id, hashed);
3244
+ + }
3245
+ + return hashed;
3246
+ + };
3247
+ + for (const [taskId, hashed] of Object.entries(hashes)) {
3248
+ + const task = taskGraph.tasks[taskId];
3249
+ + if (task === undefined) {
3250
+ + throw new Error(`Hashed task ${taskId} is not in the task graph it was hashed for`);
3251
+ + }
3252
+ + const keys = Object.keys(hashed.details).sort();
3253
+ + const details = {};
3254
+ + for (const key of keys) {
3255
+ + if (!key.endsWith(PROJECT_CONFIGURATION)) {
3256
+ + details[key] = hashed.details[key];
3257
+ + continue;
3258
+ + }
3259
+ + const project = key.slice(0, -PROJECT_CONFIGURATION.length);
3260
+ + details[key] = configuration(project, project === task.target.project ? task.target.target : null);
3261
+ + }
3262
+ + hashes[taskId] = {
3263
+ + ...hashed,
3264
+ + value: (0, native_1.hashArray)(keys.map((key) => details[key])),
3265
+ + details,
3266
+ + };
3267
+ + }
3268
+ + return hashes;
3269
+ +}
3270
+ +/** A project's root, tags and named inputs, and `target`'s executor, outputs, options, configurations and parallelism. */
3271
+ +function projectConfigurationHash(projectGraph, project, target) {
3272
+ + const node = projectGraph.nodes[project];
3273
+ + if (node === undefined) {
3274
+ + throw new Error(`Could not find project '${project}'`);
3275
+ + }
3276
+ + const { root, tags, namedInputs, targets } = node.data;
3277
+ + let own = null;
3278
+ + if (target !== null) {
3279
+ + const configured = targets?.[target];
3280
+ + if (configured === undefined) {
3281
+ + throw new Error(`Project '${project}' has no target '${target}' to hash`);
3282
+ + }
3283
+ + own = [
3284
+ + target,
3285
+ + configured.executor ?? null,
3286
+ + configured.outputs ?? [],
3287
+ + configured.options ?? {},
3288
+ + configured.configurations ?? {},
3289
+ + configured.parallelism ?? null,
3290
+ + ];
3291
+ + }
3292
+ + const inputs = Object.keys(namedInputs ?? {})
3293
+ + .sort()
3294
+ + .map((name) => [name, namedInputs[name]]);
3295
+ + return (0, native_1.hashArray)([JSON.stringify([root, tags ?? [], inputs, own])]);
3296
+ +}
3004
3297
  +/** A refusal names this many task ids and counts the rest, as cowshed's refusals do. */
3005
3298
  +const NAMED_TASKS = 10;
3006
3299
  +function namedTasks(ids) {
@@ -3157,6 +3450,32 @@ index 169563d598af64c8b74d00ab9815dd651650ec9d..0bd5e1f536b1e0e02843396e01b29dce
3157
3450
  workspaceNames.add(name);
3158
3451
  }
3159
3452
  // Check if this is a workspace-specific variant (e.g., "@quz/pkg1/lodash")
3453
+ diff --git a/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js b/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js
3454
+ index 5c2bcfaa11caef956fc906f2693586cb647b1382..1eeccd1ba61ce8391596f06aafeb0452cb49cf2a 100644
3455
+ --- a/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js
3456
+ +++ b/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js
3457
+ @@ -21,7 +21,20 @@ const defaultPackageJsonResolutionCache = new Map();
3458
+ const experimentalNodeModules = new Set(['node:sqlite']);
3459
+ function isBuiltinModuleImport(importExpr) {
3460
+ const packageName = (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(importExpr);
3461
+ - return (0, node_module_1.isBuiltin)(packageName) || experimentalNodeModules.has(packageName);
3462
+ + return ((0, node_module_1.isBuiltin)(packageName) ||
3463
+ + experimentalNodeModules.has(packageName) ||
3464
+ + isBunModuleImport(importExpr));
3465
+ +}
3466
+ +/**
3467
+ + * Bun's runtime modules: `bun` and `bun:*` (`bun:test`, `bun:sqlite`, ...).
3468
+ + * `isBuiltin` knows them only when Nx itself runs under Bun. A daemon under
3469
+ + * Node (one an editor's Nx language server starts) took each `bun:test`
3470
+ + * import for a package and looked it up through npm, TypeScript and
3471
+ + * `require.resolve` from the importing directory: thousands of failed
3472
+ + * `node_modules` probes per graph recompute. Upstream: nrwl/nx#37809.
3473
+ + */
3474
+ +function isBunModuleImport(importExpr) {
3475
+ + return importExpr === 'bun' || importExpr.startsWith('bun:');
3476
+ }
3477
+ // TypeScript matches the `${configDir}` template case-insensitively and only as a
3478
+ // prefix (commandLineParser.ts `startsWithConfigDirTemplate`).
3160
3479
  diff --git a/dist/src/project-graph/affected/affected-tasks.js b/dist/src/project-graph/affected/affected-tasks.js
3161
3480
  index 63d31ac684db1ae64d396771733f07fb2e562eb7..b79292b2b642e07f0092f2eb26c104bcb0fc8fb6 100644
3162
3481
  --- a/dist/src/project-graph/affected/affected-tasks.js
@@ -4237,29 +4556,125 @@ index 9014799cfb98f624d9d2b04891c3c9d876c64916..e29dd0e015e0e63ccdd27c2036b0395f
4237
4556
  };
4238
4557
  export type PostTasksExecutionContext = {
4239
4558
  diff --git a/dist/src/project-graph/plugins/tasks-execution-hooks.js b/dist/src/project-graph/plugins/tasks-execution-hooks.js
4240
- index 867a717e26592ed291df332083e1aded275dc404..00002ce0f95cd73eafaca9a113f856f29a27d086 100644
4559
+ index 867a717e26592ed291df332083e1aded275dc404..8af158796c275950c11c55953b6deb63ff353c95 100644
4241
4560
  --- a/dist/src/project-graph/plugins/tasks-execution-hooks.js
4242
4561
  +++ b/dist/src/project-graph/plugins/tasks-execution-hooks.js
4243
- @@ -41,8 +41,10 @@ async function runPreTasksExecution(pluginContext) {
4244
- return envs;
4245
- }
4246
- else {
4562
+ @@ -4,46 +4,39 @@ exports.runPreTasksExecution = runPreTasksExecution;
4563
+ exports.runPostTasksExecution = runPostTasksExecution;
4564
+ const nx_json_1 = require("../../config/nx-json");
4565
+ const get_plugins_1 = require("./get-plugins");
4566
+ -const is_on_daemon_1 = require("../../daemon/is-on-daemon");
4567
+ -const client_1 = require("../../daemon/client/client");
4568
+ const workspace_root_1 = require("../../utils/workspace-root");
4569
+ -const task_results_stub_1 = require("./task-results-stub");
4570
+ const nx_plugin_capabilities_1 = require("./nx-plugin-capabilities");
4571
+ /** True only when the cached graph's recorded rows show no plugin has `hook`; unknown is false. */
4572
+ function knownThatNoPluginRegisters(hook) {
4573
+ const recorded = (0, nx_plugin_capabilities_1.capabilitiesOfNxPluginsReadFromCache)();
4574
+ return !!recorded && !recorded.some((capabilities) => capabilities[hook]);
4575
+ }
4576
+ +// The task hooks run in the process that runs the tasks, never in a daemon. What a pre hook starts for its run (a
4577
+ +// process, a socket it publishes to the tasks) is then a child of the run that ends with it, and the post hook runs
4578
+ +// where the pre hook ran. Run in the daemon, it was the daemon's: a daemon that stopped under the run took it along,
4579
+ +// and the post hook the client then ran in its own process found nothing of the pre hook's.
4580
+ async function runPreTasksExecution(pluginContext) {
4581
+ - if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
4582
+ - if (knownThatNoPluginRegisters('hasPreTasksExecution')) {
4583
+ - return [];
4584
+ + if (knownThatNoPluginRegisters('hasPreTasksExecution')) {
4585
+ + return [];
4586
+ + }
4587
+ + performance.mark(`preTasksExecution:start`);
4588
+ + const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(pluginContext.workspaceRoot), pluginContext.workspaceRoot);
4589
+ + const envs = await Promise.all(plugins
4590
+ + .filter((p) => p.preTasksExecution)
4591
+ + .map(async (plugin) => {
4592
+ + performance.mark(`${plugin.name}:preTasksExecution:start`);
4593
+ + try {
4594
+ + return await plugin.preTasksExecution(pluginContext);
4595
+ }
4596
+ - performance.mark(`preTasksExecution:start`);
4597
+ - const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(pluginContext.workspaceRoot), pluginContext.workspaceRoot);
4598
+ - const envs = await Promise.all(plugins
4599
+ - .filter((p) => p.preTasksExecution)
4600
+ - .map(async (plugin) => {
4601
+ - performance.mark(`${plugin.name}:preTasksExecution:start`);
4602
+ - try {
4603
+ - return await plugin.preTasksExecution(pluginContext);
4604
+ - }
4605
+ - finally {
4606
+ - performance.mark(`${plugin.name}:preTasksExecution:end`);
4607
+ - performance.measure(`${plugin.name}:preTasksExecution`, `${plugin.name}:preTasksExecution:start`, `${plugin.name}:preTasksExecution:end`);
4608
+ - }
4609
+ - }));
4610
+ - if (!(0, client_1.isDaemonEnabled)()) {
4611
+ - applyProcessEnvs(envs);
4612
+ + finally {
4613
+ + performance.mark(`${plugin.name}:preTasksExecution:end`);
4614
+ + performance.measure(`${plugin.name}:preTasksExecution`, `${plugin.name}:preTasksExecution:start`, `${plugin.name}:preTasksExecution:end`);
4615
+ }
4616
+ - performance.mark(`preTasksExecution:end`);
4617
+ - performance.measure(`preTasksExecution`, `preTasksExecution:start`, `preTasksExecution:end`);
4618
+ - return envs;
4619
+ - }
4620
+ - else {
4247
4621
  - const envs = await client_1.daemonClient.runPreTasksExecution(pluginContext);
4248
4622
  - applyProcessEnvs(envs);
4249
- + return client_1.daemonClient.orWithoutDaemon(async () => {
4250
- + const envs = await client_1.daemonClient.runPreTasksExecution(pluginContext);
4251
- + applyProcessEnvs(envs);
4252
- + }, () => runPreTasksExecution(pluginContext));
4253
- }
4623
+ - }
4624
+ + }));
4625
+ + applyProcessEnvs(envs);
4626
+ + performance.mark(`preTasksExecution:end`);
4627
+ + performance.measure(`preTasksExecution`, `preTasksExecution:start`, `preTasksExecution:end`);
4628
+ + return envs;
4254
4629
  }
4255
4630
  function applyProcessEnvs(envs) {
4256
- @@ -75,6 +77,6 @@ async function runPostTasksExecution(context) {
4257
- performance.measure(`postTasksExecution`, `postTasksExecution:start`, `postTasksExecution:end`);
4631
+ for (const env of envs) {
4632
+ @@ -53,28 +46,23 @@ function applyProcessEnvs(envs) {
4258
4633
  }
4259
- else {
4634
+ }
4635
+ async function runPostTasksExecution(context) {
4636
+ - if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
4637
+ - if (knownThatNoPluginRegisters('hasPostTasksExecution')) {
4638
+ - return;
4639
+ - }
4640
+ - performance.mark(`postTasksExecution:start`);
4641
+ - const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot));
4642
+ - await Promise.all(plugins
4643
+ - .filter((p) => p.postTasksExecution)
4644
+ - .map(async (plugin) => {
4645
+ - performance.mark(`${plugin.name}:postTasksExecution:start`);
4646
+ - try {
4647
+ - await plugin.postTasksExecution(context);
4648
+ - }
4649
+ - finally {
4650
+ - performance.mark(`${plugin.name}:postTasksExecution:end`);
4651
+ - performance.measure(`${plugin.name}:postTasksExecution`, `${plugin.name}:postTasksExecution:start`, `${plugin.name}:postTasksExecution:end`);
4652
+ - }
4653
+ - }));
4654
+ - performance.mark(`postTasksExecution:end`);
4655
+ - performance.measure(`postTasksExecution`, `postTasksExecution:start`, `postTasksExecution:end`);
4656
+ - }
4657
+ - else {
4260
4658
  - await client_1.daemonClient.runPostTasksExecution((0, task_results_stub_1.stubTerminalOutputs)(context));
4261
- + await client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.runPostTasksExecution((0, task_results_stub_1.stubTerminalOutputs)(context)), () => runPostTasksExecution(context));
4659
+ + if (knownThatNoPluginRegisters('hasPostTasksExecution')) {
4660
+ + return;
4262
4661
  }
4662
+ + performance.mark(`postTasksExecution:start`);
4663
+ + const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot));
4664
+ + await Promise.all(plugins
4665
+ + .filter((p) => p.postTasksExecution)
4666
+ + .map(async (plugin) => {
4667
+ + performance.mark(`${plugin.name}:postTasksExecution:start`);
4668
+ + try {
4669
+ + await plugin.postTasksExecution(context);
4670
+ + }
4671
+ + finally {
4672
+ + performance.mark(`${plugin.name}:postTasksExecution:end`);
4673
+ + performance.measure(`${plugin.name}:postTasksExecution`, `${plugin.name}:postTasksExecution:start`, `${plugin.name}:postTasksExecution:end`);
4674
+ + }
4675
+ + }));
4676
+ + performance.mark(`postTasksExecution:end`);
4677
+ + performance.measure(`postTasksExecution`, `postTasksExecution:start`, `postTasksExecution:end`);
4263
4678
  }
4264
4679
  diff --git a/dist/src/project-graph/project-graph.js b/dist/src/project-graph/project-graph.js
4265
4680
  index 3ab406eee377e39ebd9229a1d07b7b11c94413b2..1f14ec608e0386ce0918db7ca14f29a635a87a95 100644
@@ -4279,20 +4694,8 @@ index 3ab406eee377e39ebd9229a1d07b7b11c94413b2..1f14ec608e0386ce0918db7ca14f29a6
4279
4694
  if (e.daemonPermissionError) {
4280
4695
  // Deliberately not disabled: unlike the inotify limit above, a socket
4281
4696
  // owned by someone else stops being there when it is removed or the
4282
- diff --git a/dist/src/tasks-runner/cache.d.ts b/dist/src/tasks-runner/cache.d.ts
4283
- index 7af1ca6cae5c72a9fa601a0360b5da71a37ff731..560e5bedcda4102272febe15c09f19172ab1943e 100644
4284
- --- a/dist/src/tasks-runner/cache.d.ts
4285
- +++ b/dist/src/tasks-runner/cache.d.ts
4286
- @@ -60,6 +60,7 @@ export declare class DbCache {
4287
- size: number;
4288
- }[]): void;
4289
- copyFilesFromCache(_: string, cachedResult: CachedResult, outputs: string[]): Promise<import("../native").OutputFile[]>;
4290
- + private stampRestored;
4291
- removeOldCacheRecords(): void;
4292
- temporaryOutputPath(task: Task): string;
4293
- private getRemoteCache;
4294
4697
  diff --git a/dist/src/tasks-runner/cache.js b/dist/src/tasks-runner/cache.js
4295
- index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..7106ae0df08d36128af9467bf92951aef41903cb 100644
4698
+ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1e68c98f7 100644
4296
4699
  --- a/dist/src/tasks-runner/cache.js
4297
4700
  +++ b/dist/src/tasks-runner/cache.js
4298
4701
  @@ -28,6 +28,7 @@ const workspace_root_1 = require("../utils/workspace-root");
@@ -4303,44 +4706,35 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..7106ae0df08d36128af9467bf92951ae
4303
4706
  // This function is called once during tasks runner initialization. It checks if the db cache is enabled and logs a warning if it is not.
4304
4707
  function dbCacheEnabled() {
4305
4708
  // ...but if on wasm and the the db cache isnt supported we shouldn't warn
4306
- @@ -175,7 +176,11 @@ class DbCache {
4709
+ @@ -175,7 +176,17 @@ class DbCache {
4307
4710
  return this.cache.getCacheSize();
4308
4711
  }
4309
4712
  applyRemoteCacheResults(hash, res, outputs) {
4310
4713
  - return this.cache.applyRemoteCacheResults(hash, res, outputs);
4311
4714
  + this.cache.applyRemoteCacheResults(hash, res, outputs);
4312
- + // The native call restores the outputs itself, under this same condition.
4715
+ + // The native call restores the outputs itself, under this same condition:
4716
+ + // it removes each output the artifact holds and copies it whole. It also
4717
+ + // records the entry's size as the bytes it copies, so it cannot be handed
4718
+ + // only the outputs that differ (restoreChangedOutputs) without
4719
+ + // undercounting the entry against maxCacheSize.
4313
4720
  + if (outputs?.length > 0 && res.code === 0) {
4314
- + this.stampRestored(res.outputsPath, outputs);
4721
+ + const relativeOutputs = workspaceRelativeOutputs(outputs);
4722
+ + removeAbsentOutputs(workspace_root_1.workspaceRoot, res.outputsPath, relativeOutputs);
4723
+ + stampRestoredOutputs(workspace_root_1.workspaceRoot, res.outputsPath, (0, native_1.expandOutputs)(res.outputsPath, relativeOutputs));
4315
4724
  + }
4316
4725
  }
4317
4726
  async put(task, terminalOutput, outputs, code) {
4318
4727
  return tryAndRetry(async () => {
4319
- @@ -198,7 +203,22 @@ class DbCache {
4728
+ @@ -198,7 +209,7 @@ class DbCache {
4320
4729
  this.cache.recordTerminalOutputs(records);
4321
4730
  }
4322
4731
  copyFilesFromCache(_, cachedResult, outputs) {
4323
4732
  - return tryAndRetry(async () => this.cache.copyFilesFromCache(cachedResult, outputs));
4324
- + return tryAndRetry(async () => {
4325
- + const files = this.cache.copyFilesFromCache(cachedResult, outputs);
4326
- + this.stampRestored(cachedResult.outputsPath, outputs);
4327
- + // These stamps go to the daemon in place of a walk of the outputs,
4328
- + // so they carry the time the restore gave the files.
4329
- + return files && restampOutputFiles(workspace_root_1.workspaceRoot, files);
4330
- + });
4331
- + }
4332
- + /**
4333
- + * Stamps what the native restore wrote from the cache entry at
4334
- + * `outputsPath`. The native restore makes an absolute in-workspace output
4335
- + * relative before expanding it in the entry, so this does too.
4336
- + */
4337
- + stampRestored(outputsPath, outputs) {
4338
- + const relativeOutputs = outputs.map((output) => (0, path_1.isAbsolute)(output) ? (0, path_1.relative)(workspace_root_1.workspaceRoot, output) : output);
4339
- + stampRestoredOutputs(workspace_root_1.workspaceRoot, outputsPath, (0, native_1.expandOutputs)(outputsPath, relativeOutputs));
4733
+ + return tryAndRetry(async () => restoreChangedOutputs(this.cache, workspace_root_1.workspaceRoot, cachedResult, workspaceRelativeOutputs(outputs)));
4340
4734
  }
4341
4735
  removeOldCacheRecords() {
4342
4736
  return this.cache.removeOldCacheRecords();
4343
- @@ -293,7 +313,8 @@ class DbCache {
4737
+ @@ -293,7 +304,8 @@ class DbCache {
4344
4738
  if (process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0') {
4345
4739
  process.emitWarning("Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.");
4346
4740
  }
@@ -4350,7 +4744,7 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..7106ae0df08d36128af9467bf92951ae
4350
4744
  }
4351
4745
  return null;
4352
4746
  }
4353
- @@ -452,6 +473,7 @@ class Cache {
4747
+ @@ -452,6 +464,7 @@ class Cache {
4354
4748
  await this.copy(cached, src);
4355
4749
  }
4356
4750
  }));
@@ -4358,7 +4752,7 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..7106ae0df08d36128af9467bf92951ae
4358
4752
  });
4359
4753
  }
4360
4754
  temporaryOutputPath(task) {
4361
- @@ -557,6 +579,46 @@ class Cache {
4755
+ @@ -557,6 +570,195 @@ class Cache {
4362
4756
  }
4363
4757
  }
4364
4758
  exports.Cache = Cache;
@@ -4370,7 +4764,9 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..7106ae0df08d36128af9467bf92951ae
4370
4764
  + * judges freshness by mtime (a Cargo build script's `rerun-if-changed`, make,
4371
4765
  + * a file watcher) then kept what it built from the newer bytes. Running the
4372
4766
  + * task would have written the output now, so the restore stamps it now. Links
4373
- + * keep their own times: `utimes` would stamp what they point at.
4767
+ + * keep their own times: `utimes` would stamp what they point at. A local hit
4768
+ + * passes only the outputs it wrote (restoreChangedOutputs): a file it kept
4769
+ + * keeps its time.
4374
4770
  + */
4375
4771
  +function stampRestoredOutputs(workspaceRoot, outputsPath, expandedOutputs) {
4376
4772
  + const now = new Date();
@@ -4401,6 +4797,153 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..7106ae0df08d36128af9467bf92951ae
4401
4797
  + const stats = (0, node_fs_1.lstatSync)((0, path_1.resolve)(workspaceRoot, file.path), { bigint: true });
4402
4798
  + return stats.isFile() ? { ...file, stamp: `${stats.mtimeNs}:${stats.size}` } : file;
4403
4799
  + });
4800
+ +}
4801
+ +/**
4802
+ + * Outputs as the native restore expands them: it makes an absolute
4803
+ + * in-workspace output relative first, so these helpers do too.
4804
+ + */
4805
+ +function workspaceRelativeOutputs(outputs) {
4806
+ + return outputs.map((output) => (0, path_1.isAbsolute)(output) ? (0, path_1.relative)(workspace_root_1.workspaceRoot, output) : output);
4807
+ +}
4808
+ +/**
4809
+ + * Removes each output the workspace holds that the cache entry at
4810
+ + * `outputsPath` does not. The native restore copies only the outputs an entry
4811
+ + * holds and leaves every other one in place, so a hit kept an output its run
4812
+ + * never wrote: what a run on other inputs left, which the restored task's
4813
+ + * consumers then read as its output.
4814
+ + */
4815
+ +function removeAbsentOutputs(workspaceRoot, outputsPath, outputs) {
4816
+ + const cached = new Set((0, native_1.expandOutputs)(outputsPath, outputs));
4817
+ + for (const output of (0, native_1.expandOutputs)(workspaceRoot, outputs)) {
4818
+ + if (!cached.has(output)) {
4819
+ + (0, node_fs_1.rmSync)((0, path_1.join)(workspaceRoot, output), { recursive: true, force: true });
4820
+ + }
4821
+ + }
4822
+ +}
4823
+ +/**
4824
+ + * Restores a local hit from the cache entry at `cachedResult.outputsPath`,
4825
+ + * writing only what differs from the workspace. The native restore removes
4826
+ + * each output and copies it whole, so a hit on outputs that already held the
4827
+ + * entry's bytes (a run on an input those bytes do not depend on, an output
4828
+ + * edited and put back, a checkout without the outputs-stamp record) gave every
4829
+ + * file a new inode and, stamped, a new mtime: each consumer that judges
4830
+ + * freshness by mtime or file identity (a Cargo build script's
4831
+ + * `rerun-if-changed`, a watcher, a producer receipt over its tool) redid its
4832
+ + * work for bytes that had not changed. Here an output file with the size, mode
4833
+ + * and bytes of its cached copy, and a link to the same target, stay as they
4834
+ + * are. Everything else the entry holds goes through the native copy and is
4835
+ + * stamped as written. What the workspace holds inside a cached directory and
4836
+ + * the entry lacks is removed, as the native removal of the whole directory
4837
+ + * did, and so is each output the entry does not hold (removeAbsentOutputs).
4838
+ + *
4839
+ + * Answers the stamps of every file the outputs now hold, which go to the
4840
+ + * daemon in place of a walk, or null when an output is a pattern or a
4841
+ + * negation, as the native copy does.
4842
+ + */
4843
+ +function restoreChangedOutputs(cache, workspaceRoot, cachedResult, outputs) {
4844
+ + const outputsPath = cachedResult.outputsPath;
4845
+ + removeAbsentOutputs(workspaceRoot, outputsPath, outputs);
4846
+ + const changed = [];
4847
+ + const kept = [];
4848
+ + for (const output of (0, native_1.expandOutputs)(outputsPath, outputs)) {
4849
+ + collectChangedOutputs(outputsPath, workspaceRoot, output, changed, kept);
4850
+ + }
4851
+ + let written = [];
4852
+ + if (changed.length > 0) {
4853
+ + // Each changed path is a literal output of its own: the native copy
4854
+ + // removes it and copies it whole from the entry, confined to the
4855
+ + // workspace as for any restore.
4856
+ + written = cache.copyFilesFromCache(cachedResult, changed);
4857
+ + stampRestoredOutputs(workspaceRoot, outputsPath, changed);
4858
+ + }
4859
+ + if (written === null || outputs.some((output) => /[!*?[\]{}()]/.test(output))) {
4860
+ + return null;
4861
+ + }
4862
+ + return [...kept, ...restampOutputFiles(workspaceRoot, written)];
4863
+ +}
4864
+ +/**
4865
+ + * Sorts `output` (workspace-relative, present in the cache entry) into what
4866
+ + * the restore must write from the entry (`changed`) and the file stamps it
4867
+ + * keeps (`kept`), removing what the workspace holds inside a cached directory
4868
+ + * that the entry does not.
4869
+ + */
4870
+ +function collectChangedOutputs(outputsPath, workspaceRoot, output, changed, kept) {
4871
+ + const cachedPath = (0, path_1.join)(outputsPath, output);
4872
+ + const presentPath = (0, path_1.join)(workspaceRoot, output);
4873
+ + const cached = (0, node_fs_1.lstatSync)(cachedPath, { bigint: true });
4874
+ + const present = (0, node_fs_1.lstatSync)(presentPath, { bigint: true, throwIfNoEntry: false });
4875
+ + if (cached.isDirectory()) {
4876
+ + if (!present?.isDirectory()) {
4877
+ + changed.push(output);
4878
+ + return;
4879
+ + }
4880
+ + const names = (0, node_fs_1.readdirSync)(cachedPath);
4881
+ + const cachedNames = new Set(names);
4882
+ + for (const name of (0, node_fs_1.readdirSync)(presentPath)) {
4883
+ + if (!cachedNames.has(name)) {
4884
+ + (0, node_fs_1.rmSync)((0, path_1.join)(presentPath, name), { recursive: true, force: true });
4885
+ + }
4886
+ + }
4887
+ + for (const name of names) {
4888
+ + collectChangedOutputs(outputsPath, workspaceRoot, path_1.posix.join(output, name), changed, kept);
4889
+ + }
4890
+ + }
4891
+ + else if (cached.isSymbolicLink()) {
4892
+ + if (!present?.isSymbolicLink() || (0, node_fs_1.readlinkSync)(presentPath) !== (0, node_fs_1.readlinkSync)(cachedPath)) {
4893
+ + changed.push(output);
4894
+ + return;
4895
+ + }
4896
+ + // The native copy stamps a link by what it points at, and only a file.
4897
+ + const target = (0, node_fs_1.statSync)(presentPath, { bigint: true, throwIfNoEntry: false });
4898
+ + if (target?.isFile()) {
4899
+ + kept.push({ path: output, stamp: `${target.mtimeNs}:${target.size}` });
4900
+ + }
4901
+ + }
4902
+ + else if (cached.isFile() && present?.isFile() && sameFileBytes(cachedPath, cached, presentPath, present)) {
4903
+ + kept.push({ path: output, stamp: `${present.mtimeNs}:${present.size}` });
4904
+ + }
4905
+ + else {
4906
+ + changed.push(output);
4907
+ + }
4908
+ +}
4909
+ +/** The comparison's two read buffers, made on its first use: the restore is synchronous. */
4910
+ +let compareBuffers;
4911
+ +/** Whether two regular files have the same size, permission bits and bytes. */
4912
+ +function sameFileBytes(cachedPath, cached, presentPath, present) {
4913
+ + if (cached.size !== present.size || (cached.mode & 0o7777n) !== (present.mode & 0o7777n)) {
4914
+ + return false;
4915
+ + }
4916
+ + compareBuffers ??= [Buffer.allocUnsafe(1 << 20), Buffer.allocUnsafe(1 << 20)];
4917
+ + const [cachedBytes, presentBytes] = compareBuffers;
4918
+ + const cachedFd = (0, node_fs_1.openSync)(cachedPath, 'r');
4919
+ + try {
4920
+ + const presentFd = (0, node_fs_1.openSync)(presentPath, 'r');
4921
+ + try {
4922
+ + for (;;) {
4923
+ + const read = (0, node_fs_1.readSync)(cachedFd, cachedBytes, 0, cachedBytes.length, null);
4924
+ + if (read === 0) {
4925
+ + return true;
4926
+ + }
4927
+ + let filled = 0;
4928
+ + while (filled < read) {
4929
+ + const more = (0, node_fs_1.readSync)(presentFd, presentBytes, filled, read - filled, null);
4930
+ + if (more === 0) {
4931
+ + return false;
4932
+ + }
4933
+ + filled += more;
4934
+ + }
4935
+ + if (cachedBytes.compare(presentBytes, 0, read, 0, read) !== 0) {
4936
+ + return false;
4937
+ + }
4938
+ + }
4939
+ + }
4940
+ + finally {
4941
+ + (0, node_fs_1.closeSync)(presentFd);
4942
+ + }
4943
+ + }
4944
+ + finally {
4945
+ + (0, node_fs_1.closeSync)(cachedFd);
4946
+ + }
4404
4947
  +}
4405
4948
  function tryAndRetry(fn) {
4406
4949
  let attempts = 0;
@@ -6145,11 +6688,36 @@ index 34dbaa2a5a44e6b7d1f69a516756b30939877bd7..09f95b73572a0d411f26d42aac2cfbf0
6145
6688
  }
6146
6689
  }
6147
6690
  exports.TaskHistory = TaskHistory;
6691
+ diff --git a/dist/src/utils/workspace-context.d.ts b/dist/src/utils/workspace-context.d.ts
6692
+ index 8a4b38e06755c303b2328ff9ef01d06f49a7c249..70397218ce0a137315732c6b7adfbb97758c2611 100644
6693
+ --- a/dist/src/utils/workspace-context.d.ts
6694
+ +++ b/dist/src/utils/workspace-context.d.ts
6695
+ @@ -47,6 +47,12 @@ export declare function settleWorkspaceContext(workspaceRoot: string): ChangeBat
6696
+ * watcher: for a caller that has just applied changes itself.
6697
+ */
6698
+ export declare function takeAppliedWorkspaceChanges(workspaceRoot: string): ChangeBatch;
6699
+ +/**
6700
+ + * Walks the workspace again from the disk, never from another process's
6701
+ + * archive, and applies what the walk finds changed to the context: take those
6702
+ + * changes with `takeAppliedWorkspaceChanges`.
6703
+ + */
6704
+ +export declare function rescanWorkspaceContext(workspaceRoot: string): void;
6705
+ export declare function isWatchingWorkspaceContext(): boolean;
6706
+ /**
6707
+ * Listens for every event the context's watch delivers, including writes
6148
6708
  diff --git a/dist/src/utils/workspace-context.js b/dist/src/utils/workspace-context.js
6149
- index 1b551e8dcab2b0b1e6ac46af9d46456e7b9a3eeb..bab5280fc705e522dfcc6aefe383f67ec169f5b8 100644
6709
+ index 1b551e8dcab2b0b1e6ac46af9d46456e7b9a3eeb..05de9601000f683210ef76c4939e925e11a5a6ed 100644
6150
6710
  --- a/dist/src/utils/workspace-context.js
6151
6711
  +++ b/dist/src/utils/workspace-context.js
6152
- @@ -62,7 +62,7 @@ async function getNxWorkspaceFilesFromContext(workspaceRoot, projectRootMap, use
6712
+ @@ -16,6 +16,7 @@ exports.getAllFileDataInContext = getAllFileDataInContext;
6713
+ exports.subscribeToWorkspaceChanges = subscribeToWorkspaceChanges;
6714
+ exports.settleWorkspaceContext = settleWorkspaceContext;
6715
+ exports.takeAppliedWorkspaceChanges = takeAppliedWorkspaceChanges;
6716
+ +exports.rescanWorkspaceContext = rescanWorkspaceContext;
6717
+ exports.isWatchingWorkspaceContext = isWatchingWorkspaceContext;
6718
+ exports.subscribeToWatchEvents = subscribeToWatchEvents;
6719
+ exports.isEmptyBatch = isEmptyBatch;
6720
+ @@ -62,7 +63,7 @@ async function getNxWorkspaceFilesFromContext(workspaceRoot, projectRootMap, use
6153
6721
  await ensureFilesReady(workspaceRoot);
6154
6722
  return workspaceContext.getWorkspaceFiles(projectRootMap);
6155
6723
  }
@@ -6158,7 +6726,7 @@ index 1b551e8dcab2b0b1e6ac46af9d46456e7b9a3eeb..bab5280fc705e522dfcc6aefe383f67e
6158
6726
  }
6159
6727
  /**
6160
6728
  * Sync method to get files matching globs from workspace context.
6161
- @@ -81,7 +81,7 @@ async function globWithWorkspaceContext(workspaceRoot, globs, exclude) {
6729
+ @@ -81,7 +82,7 @@ async function globWithWorkspaceContext(workspaceRoot, globs, exclude) {
6162
6730
  return workspaceContext.glob(globs, exclude);
6163
6731
  }
6164
6732
  else {
@@ -6167,7 +6735,7 @@ index 1b551e8dcab2b0b1e6ac46af9d46456e7b9a3eeb..bab5280fc705e522dfcc6aefe383f67e
6167
6735
  }
6168
6736
  }
6169
6737
  async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
6170
- @@ -89,21 +89,21 @@ async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
6738
+ @@ -89,21 +90,21 @@ async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
6171
6739
  await ensureFilesReady(workspaceRoot);
6172
6740
  return workspaceContext.multiGlob(globs, exclude);
6173
6741
  }
@@ -6192,7 +6760,7 @@ index 1b551e8dcab2b0b1e6ac46af9d46456e7b9a3eeb..bab5280fc705e522dfcc6aefe383f67e
6192
6760
  }
6193
6761
  async function updateContextWithChangedFiles(workspaceRoot, createdFiles, updatedFiles, deletedFiles) {
6194
6762
  if (!client_1.daemonClient.enabled()) {
6195
- @@ -117,7 +117,7 @@ async function updateContextWithChangedFiles(workspaceRoot, createdFiles, update
6763
+ @@ -117,7 +118,7 @@ async function updateContextWithChangedFiles(workspaceRoot, createdFiles, update
6196
6764
  }
6197
6765
  else {
6198
6766
  // daemon is enabled but we are not running on it, ask the daemon to update the context
@@ -6201,7 +6769,7 @@ index 1b551e8dcab2b0b1e6ac46af9d46456e7b9a3eeb..bab5280fc705e522dfcc6aefe383f67e
6201
6769
  }
6202
6770
  }
6203
6771
  /**
6204
- @@ -147,7 +147,7 @@ async function getAllFileDataInContext(workspaceRoot) {
6772
+ @@ -147,7 +148,7 @@ async function getAllFileDataInContext(workspaceRoot) {
6205
6773
  await ensureFilesReady(workspaceRoot);
6206
6774
  return workspaceContext.allFileData();
6207
6775
  }
@@ -6210,7 +6778,23 @@ index 1b551e8dcab2b0b1e6ac46af9d46456e7b9a3eeb..bab5280fc705e522dfcc6aefe383f67e
6210
6778
  }
6211
6779
  /**
6212
6780
  * Listens for the changes a watching context applies: each change reaches the
6213
- @@ -232,7 +232,7 @@ async function getFilesInDirectoryUsingContext(workspaceRoot, dir) {
6781
+ @@ -178,6 +179,15 @@ function takeAppliedWorkspaceChanges(workspaceRoot) {
6782
+ ensureContextAvailable(workspaceRoot);
6783
+ return workspaceContext.takeAppliedChanges();
6784
+ }
6785
+ +/**
6786
+ + * Walks the workspace again from the disk, never from another process's
6787
+ + * archive, and applies what the walk finds changed to the context: take those
6788
+ + * changes with `takeAppliedWorkspaceChanges`.
6789
+ + */
6790
+ +function rescanWorkspaceContext(workspaceRoot) {
6791
+ + ensureContextAvailable(workspaceRoot);
6792
+ + workspaceContext.rescanAndDiff();
6793
+ +}
6794
+ function isWatchingWorkspaceContext() {
6795
+ return !!contextOptions?.watch;
6796
+ }
6797
+ @@ -232,7 +242,7 @@ async function getFilesInDirectoryUsingContext(workspaceRoot, dir) {
6214
6798
  await ensureFilesReady(workspaceRoot);
6215
6799
  return workspaceContext.getFilesInDirectory(dir);
6216
6800
  }