@visulima/task-runner 1.0.0-alpha.2 → 1.0.0-alpha.20

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 (102) hide show
  1. package/CHANGELOG.md +310 -0
  2. package/README.md +198 -52
  3. package/dist/index.d.ts +3795 -34
  4. package/dist/index.js +1 -20
  5. package/dist/packem_chunks/index.js +31 -0
  6. package/dist/packem_shared/Cache-C8FfeXpg.js +2 -0
  7. package/dist/packem_shared/CompositeLifeCycle-C6aee9GK.js +1 -0
  8. package/dist/packem_shared/FileAccessTracker-DBz_w4wl.js +50 -0
  9. package/dist/packem_shared/FingerprintManager-CYW2EwLc.js +2 -0
  10. package/dist/packem_shared/HttpRemoteCache-CpPl6lzE.js +1 -0
  11. package/dist/packem_shared/INPUT_URI_SCHEMES-Csrd0tlg.js +1 -0
  12. package/dist/packem_shared/IncrementalFileHasher-B-V3i2x-.js +1 -0
  13. package/dist/packem_shared/LogReporter-3R3oWj-Q.js +13 -0
  14. package/dist/packem_shared/ReapiRemoteCache-BXJip5wH.js +251 -0
  15. package/dist/packem_shared/TaskOrchestrator-CYj5MLwz.js +6 -0
  16. package/dist/packem_shared/TerminalBuffer-BtZy7TpT.js +3 -0
  17. package/dist/packem_shared/TrackedTaskExecutor-CtYLL3vS.js +1 -0
  18. package/dist/packem_shared/V2_ROOT-injxWBrl.js +1 -0
  19. package/dist/packem_shared/actionDigestForTaskHash-BOL4fZ9v.js +1 -0
  20. package/dist/packem_shared/archive-CDfGy5Lm.js +1 -0
  21. package/dist/packem_shared/buildForwardDependencyMap-DudUDFze.js +3 -0
  22. package/dist/packem_shared/collectFiles-W4bnBRpb.js +1 -0
  23. package/dist/packem_shared/collectNodeModulesBinDirs-CD-eDrtO.js +1 -0
  24. package/dist/packem_shared/computeTaskHash-CaPdG1BA.js +1 -0
  25. package/dist/packem_shared/containsBlob-DAU8R7GH.js +1 -0
  26. package/dist/packem_shared/createInputHandler-CkDCpPYy.js +1 -0
  27. package/dist/packem_shared/createTaskGraph-D8Jn_Dn9.js +1 -0
  28. package/dist/packem_shared/defaultTaskRunner-DMHpavzm.js +2 -0
  29. package/dist/packem_shared/detectFrameworks-WVZJOPgN.js +1 -0
  30. package/dist/packem_shared/detectScriptShell-CaTDk5cW.js +1 -0
  31. package/dist/packem_shared/digestBuffer-g11aCaDx.js +1 -0
  32. package/dist/packem_shared/enforceProjectConstraints-dNc1SwRi.js +1 -0
  33. package/dist/packem_shared/expandArguments-D7qvc6Rp.js +1 -0
  34. package/dist/packem_shared/expandShortcut-BErNHNXZ.js +1 -0
  35. package/dist/packem_shared/expandTokensInString-DVSFEdWu.js +1 -0
  36. package/dist/packem_shared/expandWildcard-DE0dOOZF.js +1 -0
  37. package/dist/packem_shared/extractPackageName-BeL6Gc3a.js +1 -0
  38. package/dist/packem_shared/findCycle-BY8-jmzB.js +1 -0
  39. package/dist/packem_shared/formatTimingTable-CP3rsDwf.js +7 -0
  40. package/dist/packem_shared/generateRunSummary-L9Z2NfWn.js +1 -0
  41. package/dist/packem_shared/getCurrentBranch-D-qoZByx.js +1 -0
  42. package/dist/packem_shared/getMainWorktreeRoot-DB9P2wDL.js +1 -0
  43. package/dist/packem_shared/isNativeAvailable-CkTjxb7P.js +1 -0
  44. package/dist/packem_shared/parseCommands-BHsXoUCd.js +1 -0
  45. package/dist/packem_shared/parsePartition-Bt1jBjZH.js +1 -0
  46. package/dist/packem_shared/projectGraphToDot-FN6oHDGH.js +250 -0
  47. package/dist/packem_shared/resolveCacheMode--4y60ODd.js +1 -0
  48. package/dist/packem_shared/resolveOutputs-CzGGEbcP.js +1 -0
  49. package/dist/packem_shared/runConcurrentFallback-BhJCT2LA.js +3 -0
  50. package/dist/packem_shared/runConcurrently-D1Ytsjaj.js +1 -0
  51. package/dist/packem_shared/runTeardown-DAn1xFWJ.js +1 -0
  52. package/dist/packem_shared/shell-quote-BhmqDUL1.js +1 -0
  53. package/dist/packem_shared/stripQuotes-jkZb0CL9.js +1 -0
  54. package/dist/packem_shared/toChromeTrace-DxN5NQIU.js +1 -0
  55. package/dist/packem_shared/tracked-executor-B90U4Um3.js +3 -0
  56. package/dist/packem_shared/utils-BH2W5Wml.js +1 -0
  57. package/dist/packem_shared/withRestart-DKtEGsQA.js +1 -0
  58. package/index.js +603 -0
  59. package/package.json +31 -19
  60. package/binding.js +0 -204
  61. package/dist/affected.d.ts +0 -48
  62. package/dist/cache.d.ts +0 -103
  63. package/dist/default-task-runner.d.ts +0 -44
  64. package/dist/file-access-tracker.d.ts +0 -53
  65. package/dist/fingerprint.d.ts +0 -45
  66. package/dist/framework-inference.d.ts +0 -35
  67. package/dist/graph-visualizer.d.ts +0 -74
  68. package/dist/incremental-hasher.d.ts +0 -58
  69. package/dist/life-cycle.d.ts +0 -36
  70. package/dist/lockfile-hasher.d.ts +0 -73
  71. package/dist/native-binding.d.ts +0 -64
  72. package/dist/packem_shared/Cache-IYpTYVUC.js +0 -298
  73. package/dist/packem_shared/CompositeLifeCycle-7AtYw1dv.js +0 -112
  74. package/dist/packem_shared/FileAccessTracker-CrtBAt5D.js +0 -239
  75. package/dist/packem_shared/FingerprintManager-D6Y0erg-.js +0 -227
  76. package/dist/packem_shared/IncrementalFileHasher-Ds3J6dgb.js +0 -151
  77. package/dist/packem_shared/RemoteCache-BDqrnDEi.js +0 -179
  78. package/dist/packem_shared/TaskOrchestrator-BvYs3ONw.js +0 -342
  79. package/dist/packem_shared/TaskScheduler-CJilHDta.js +0 -111
  80. package/dist/packem_shared/TrackedTaskExecutor-BGUKFE-7.js +0 -164
  81. package/dist/packem_shared/collectFiles-ClXHnHhg.js +0 -22
  82. package/dist/packem_shared/computeTaskHash-BoCnnvIJ.js +0 -356
  83. package/dist/packem_shared/createTaskGraph-CcsFaSrz.js +0 -164
  84. package/dist/packem_shared/defaultTaskRunner-CrW4v5Ye.js +0 -79
  85. package/dist/packem_shared/detectFrameworks-CeFzKE6J.js +0 -101
  86. package/dist/packem_shared/extractPackageName-CbVNW-dr.js +0 -189
  87. package/dist/packem_shared/filterAffectedTasks-I-18zPg6.js +0 -135
  88. package/dist/packem_shared/findCycle-DF4_BRdO.js +0 -212
  89. package/dist/packem_shared/generateRunSummary-qn-_jKwt.js +0 -134
  90. package/dist/packem_shared/isNativeAvailable-BWhnZ4ES.js +0 -19
  91. package/dist/packem_shared/projectGraphToDot-VdTjHcVp.js +0 -202
  92. package/dist/packem_shared/utils-zO0ZRgtf.js +0 -390
  93. package/dist/remote-cache.d.ts +0 -55
  94. package/dist/run-summary.d.ts +0 -89
  95. package/dist/task-graph-utils.d.ts +0 -39
  96. package/dist/task-graph.d.ts +0 -22
  97. package/dist/task-hasher.d.ts +0 -67
  98. package/dist/task-orchestrator.d.ts +0 -38
  99. package/dist/task-scheduler.d.ts +0 -18
  100. package/dist/tracked-executor.d.ts +0 -46
  101. package/dist/types.d.ts +0 -385
  102. package/dist/utils.d.ts +0 -39
package/binding.js DELETED
@@ -1,204 +0,0 @@
1
- /* eslint-disable */
2
- /* auto-generated binding loader for @visulima/task-runner native addon */
3
-
4
- const { existsSync, readFileSync } = require("node:fs");
5
- const { join } = require("node:path");
6
-
7
- const { platform, arch } = process;
8
-
9
- let nativeBinding = null;
10
- let localFileExisted = false;
11
- let loadError = null;
12
-
13
- function isMusl() {
14
- // For Node 12+, check report.header for musl
15
- if (
16
- typeof process.report !== "undefined" &&
17
- typeof process.report.getReport === "function"
18
- ) {
19
- const { glibcVersionRuntime } = process.report.getReport().header;
20
- if (glibcVersionRuntime) {
21
- return false;
22
- }
23
- return true;
24
- }
25
-
26
- try {
27
- const lddOutput = readFileSync("/usr/bin/ldd", "utf8");
28
- return lddOutput.includes("musl");
29
- } catch {
30
- try {
31
- return readFileSync("/proc/self/map_files/../maps", "utf8").includes(
32
- "musl"
33
- );
34
- } catch {
35
- return false;
36
- }
37
- }
38
- }
39
-
40
- switch (platform) {
41
- case "darwin":
42
- switch (arch) {
43
- case "x64":
44
- localFileExisted = existsSync(
45
- join(__dirname, "task-runner-native.darwin-x64.node")
46
- );
47
- try {
48
- if (localFileExisted) {
49
- nativeBinding = require("./task-runner-native.darwin-x64.node");
50
- } else {
51
- nativeBinding = require("@visulima/task-runner-binding-darwin-x64");
52
- }
53
- } catch (e) {
54
- loadError = e;
55
- }
56
- break;
57
- case "arm64":
58
- localFileExisted = existsSync(
59
- join(__dirname, "task-runner-native.darwin-arm64.node")
60
- );
61
- try {
62
- if (localFileExisted) {
63
- nativeBinding = require("./task-runner-native.darwin-arm64.node");
64
- } else {
65
- nativeBinding = require("@visulima/task-runner-binding-darwin-arm64");
66
- }
67
- } catch (e) {
68
- loadError = e;
69
- }
70
- break;
71
- default:
72
- throw new Error(`Unsupported architecture on macOS: ${arch}`);
73
- }
74
- break;
75
- case "linux":
76
- switch (arch) {
77
- case "x64":
78
- if (isMusl()) {
79
- localFileExisted = existsSync(
80
- join(
81
- __dirname,
82
- "task-runner-native.linux-x64-musl.node"
83
- )
84
- );
85
- try {
86
- if (localFileExisted) {
87
- nativeBinding = require("./task-runner-native.linux-x64-musl.node");
88
- } else {
89
- nativeBinding = require("@visulima/task-runner-binding-linux-x64-musl");
90
- }
91
- } catch (e) {
92
- loadError = e;
93
- }
94
- } else {
95
- localFileExisted = existsSync(
96
- join(
97
- __dirname,
98
- "task-runner-native.linux-x64-gnu.node"
99
- )
100
- );
101
- try {
102
- if (localFileExisted) {
103
- nativeBinding = require("./task-runner-native.linux-x64-gnu.node");
104
- } else {
105
- nativeBinding = require("@visulima/task-runner-binding-linux-x64-gnu");
106
- }
107
- } catch (e) {
108
- loadError = e;
109
- }
110
- }
111
- break;
112
- case "arm64":
113
- if (isMusl()) {
114
- localFileExisted = existsSync(
115
- join(
116
- __dirname,
117
- "task-runner-native.linux-arm64-musl.node"
118
- )
119
- );
120
- try {
121
- if (localFileExisted) {
122
- nativeBinding = require("./task-runner-native.linux-arm64-musl.node");
123
- } else {
124
- nativeBinding = require("@visulima/task-runner-binding-linux-arm64-musl");
125
- }
126
- } catch (e) {
127
- loadError = e;
128
- }
129
- } else {
130
- localFileExisted = existsSync(
131
- join(
132
- __dirname,
133
- "task-runner-native.linux-arm64-gnu.node"
134
- )
135
- );
136
- try {
137
- if (localFileExisted) {
138
- nativeBinding = require("./task-runner-native.linux-arm64-gnu.node");
139
- } else {
140
- nativeBinding = require("@visulima/task-runner-binding-linux-arm64-gnu");
141
- }
142
- } catch (e) {
143
- loadError = e;
144
- }
145
- }
146
- break;
147
- default:
148
- throw new Error(`Unsupported architecture on Linux: ${arch}`);
149
- }
150
- break;
151
- case "win32":
152
- switch (arch) {
153
- case "x64":
154
- localFileExisted = existsSync(
155
- join(
156
- __dirname,
157
- "task-runner-native.win32-x64-msvc.node"
158
- )
159
- );
160
- try {
161
- if (localFileExisted) {
162
- nativeBinding = require("./task-runner-native.win32-x64-msvc.node");
163
- } else {
164
- nativeBinding = require("@visulima/task-runner-binding-win32-x64-msvc");
165
- }
166
- } catch (e) {
167
- loadError = e;
168
- }
169
- break;
170
- case "arm64":
171
- localFileExisted = existsSync(
172
- join(
173
- __dirname,
174
- "task-runner-native.win32-arm64-msvc.node"
175
- )
176
- );
177
- try {
178
- if (localFileExisted) {
179
- nativeBinding = require("./task-runner-native.win32-arm64-msvc.node");
180
- } else {
181
- nativeBinding = require("@visulima/task-runner-binding-win32-arm64-msvc");
182
- }
183
- } catch (e) {
184
- loadError = e;
185
- }
186
- break;
187
- default:
188
- throw new Error(`Unsupported architecture on Windows: ${arch}`);
189
- }
190
- break;
191
- default:
192
- throw new Error(
193
- `Unsupported OS: ${platform}, architecture: ${arch}`
194
- );
195
- }
196
-
197
- if (!nativeBinding) {
198
- if (loadError) {
199
- throw loadError;
200
- }
201
- throw new Error("Failed to load native binding");
202
- }
203
-
204
- module.exports = nativeBinding;
@@ -1,48 +0,0 @@
1
- import type { ProjectConfiguration, ProjectGraph } from "./types.d.ts";
2
- /**
3
- * Options for determining affected projects.
4
- */
5
- interface AffectedOptions {
6
- /** The base ref to compare against (default: "main") */
7
- base?: string;
8
- /** The head ref to compare (default: "HEAD") */
9
- head?: string;
10
- /** Project graph for dependency resolution */
11
- projectGraph: ProjectGraph;
12
- /** All project configurations keyed by name */
13
- projects: Record<string, ProjectConfiguration>;
14
- /** The workspace root directory */
15
- workspaceRoot: string;
16
- }
17
- /**
18
- * Result of affected detection.
19
- */
20
- interface AffectedResult {
21
- /** Projects affected by changes (including transitive dependents) */
22
- affectedProjects: string[];
23
- /** Files that changed between base and head */
24
- changedFiles: string[];
25
- /** Projects that were directly changed */
26
- changedProjects: string[];
27
- }
28
- /**
29
- * Gets the list of files changed between two git refs.
30
- * Uses execFile with argument arrays to prevent command injection.
31
- */
32
- declare const getChangedFiles: (workspaceRoot: string, base: string, head: string) => Promise<string[]>;
33
- /**
34
- * Determines which projects are affected by changes between two git refs.
35
- *
36
- * Uses `git diff` to find changed files, maps them to projects based on
37
- * project roots, then walks the project dependency graph to find all
38
- * transitively affected projects.
39
- *
40
- * This is the same strategy used by `nx affected` and `turbo run --filter=[base...]`.
41
- */
42
- declare const getAffectedProjects: (options: AffectedOptions) => Promise<AffectedResult>;
43
- /**
44
- * Filters tasks to only include those that are affected by changes.
45
- */
46
- declare const filterAffectedTasks: (taskIds: string[], affectedProjects: Set<string>) => string[];
47
- export type { AffectedOptions, AffectedResult };
48
- export { filterAffectedTasks, getAffectedProjects, getChangedFiles };
package/dist/cache.d.ts DELETED
@@ -1,103 +0,0 @@
1
- import type { TaskFingerprint } from "./fingerprint.d.ts";
2
- /**
3
- * Represents a cached task result.
4
- */
5
- interface CachedResult {
6
- /** The exit code of the original task execution */
7
- code: number;
8
- /** The auto-fingerprint data, if auto-fingerprinting was used */
9
- fingerprint?: TaskFingerprint;
10
- /** The hash that was used as the cache key */
11
- hash: string;
12
- /** The terminal output of the original task execution */
13
- terminalOutput: string;
14
- }
15
- /**
16
- * Options for creating a Cache instance.
17
- */
18
- interface CacheOptions {
19
- /** The cache directory (defaults to `{workspaceRoot}/.task-runner-cache`) */
20
- cacheDirectory?: string;
21
- /** Maximum age of cache entries in milliseconds (default: 7 days) */
22
- maxCacheAge?: number;
23
- /** Maximum cache size (e.g., "500MB", "1GB") */
24
- maxCacheSize?: string;
25
- /** The workspace root directory */
26
- workspaceRoot: string;
27
- }
28
- /**
29
- * Parses a human-readable cache size string into bytes.
30
- * Delegates to @visulima/humanizer's parseBytes with base-2 (1024) multipliers.
31
- */
32
- declare const parseCacheSize: (sizeString: string) => number;
33
- /**
34
- * Formats a byte count into a human-readable string.
35
- * Delegates to @visulima/humanizer's formatBytes with base-2 (1024) multipliers.
36
- */
37
- declare const formatCacheSize: (bytes: number) => string;
38
- /**
39
- * Local file-based cache for task results.
40
- *
41
- * Cache structure:
42
- * ```
43
- * .task-runner-cache/
44
- * &lt;hash&gt;/
45
- * outputs/ (Archived build outputs)
46
- * code (Exit code)
47
- * terminalOutput (Captured terminal output)
48
- * fingerprint.json (Auto-fingerprint data, optional)
49
- * .commit (Marker indicating complete cache entry)
50
- * .task-index.json (Task ID -> hash mapping for auto-fingerprint)
51
- * ```
52
- *
53
- * Atomicity: Cache entries are written to a temporary directory first,
54
- * then renamed into place. The `.commit` marker ensures readers only
55
- * see complete entries.
56
- */
57
- declare class Cache {
58
- #private;
59
- constructor(options: CacheOptions);
60
- /**
61
- * Gets the cache directory path.
62
- */
63
- get cacheDirectory(): string;
64
- /**
65
- * Retrieves a cached result for the given task hash.
66
- * Returns undefined if no valid cache entry exists.
67
- */
68
- get(hash: string): Promise<CachedResult | undefined>;
69
- /**
70
- * Stores a task result in the cache.
71
- *
72
- * Uses atomic write: builds the entry in a temporary directory,
73
- * then renames into place to avoid partial reads by concurrent processes.
74
- */
75
- put(hash: string, terminalOutput: string, outputs: string[], code: number, fingerprint?: TaskFingerprint): Promise<void>;
76
- /**
77
- * Restores cached outputs to their original locations.
78
- */
79
- restoreOutputs(hash: string, outputs: string[]): Promise<boolean>;
80
- /**
81
- * Retrieves the most recent cached result for a task by its ID.
82
- * Used in auto-fingerprint mode where the hash is derived from
83
- * tracked file accesses rather than computed upfront.
84
- */
85
- getByTaskId(taskId: string): Promise<CachedResult | undefined>;
86
- /**
87
- * Stores the mapping from task ID to cache hash.
88
- * Uses a write queue to serialize concurrent writes and prevent lost updates.
89
- * Each write is atomic (temp file + rename).
90
- */
91
- setTaskIndex(taskId: string, hash: string): Promise<void>;
92
- /**
93
- * Removes old cache entries that exceed the maximum age,
94
- * and enforces the maximum cache size by evicting oldest entries.
95
- */
96
- removeOldEntries(): Promise<void>;
97
- /**
98
- * Clears the entire cache.
99
- */
100
- clear(): Promise<void>;
101
- }
102
- export type { CachedResult, CacheOptions };
103
- export { Cache, formatCacheSize, parseCacheSize };
@@ -1,44 +0,0 @@
1
- import type { Task, TaskResults, TaskRunnerContext, TaskRunnerOptions } from "./types.d.ts";
2
- /**
3
- * The default task runner implementation.
4
- *
5
- * Runs tasks with caching, scheduling, and lifecycle support.
6
- * Supports two caching modes:
7
- *
8
- * 1. **Nx-style** (default): Explicit input declarations with upfront hash computation.
9
- * 2. **Auto-fingerprint** (Vite Task-style): Set `autoFingerprint: true` to automatically
10
- * track file accesses and use them for cache invalidation.
11
- * @example
12
- * ```ts
13
- * import { defaultTaskRunner } from "@visulima/task-runner";
14
- *
15
- * // Nx-style (explicit inputs)
16
- * const results = await defaultTaskRunner(tasks, options, context);
17
- *
18
- * // Vite Task-style (auto-fingerprinting)
19
- * const results = await defaultTaskRunner(tasks, {
20
- * ...options,
21
- * autoFingerprint: true,
22
- * fingerprintEnvPatterns: ["VITE_*", "NODE_ENV"],
23
- * cacheDiagnostics: true,
24
- * }, context);
25
- *
26
- * // With remote cache
27
- * const results = await defaultTaskRunner(tasks, {
28
- * ...options,
29
- * remoteCache: {
30
- * url: "https://cache.example.com",
31
- * token: process.env.CACHE_TOKEN,
32
- * teamId: "my-team",
33
- * },
34
- * }, context);
35
- *
36
- * // Dry-run (inspect hashes without executing)
37
- * const results = await defaultTaskRunner(tasks, {
38
- * ...options,
39
- * dryRun: true,
40
- * }, context);
41
- * ```
42
- */
43
- declare const defaultTaskRunner: (_tasks: Task[], options: TaskRunnerOptions, context: TaskRunnerContext) => Promise<TaskResults>;
44
- export { defaultTaskRunner };
@@ -1,53 +0,0 @@
1
- /**
2
- * Represents a file access recorded during task execution.
3
- */
4
- export interface FileAccess {
5
- /** The absolute path of the file */
6
- path: string;
7
- /** The type of access */
8
- type: "read" | "stat" | "readdir" | "missing";
9
- }
10
- /**
11
- * Result of tracking file accesses during a command execution.
12
- */
13
- export interface TrackingResult {
14
- /** All file accesses recorded */
15
- accesses: FileAccess[];
16
- /** The command exit code */
17
- code: number;
18
- /** The command stdout + stderr output */
19
- output: string;
20
- }
21
- /**
22
- * Tracks which files a child process accesses during execution.
23
- *
24
- * Uses `strace` on Linux to intercept syscalls (open, openat, stat, lstat, access, getdents).
25
- * Falls back to no tracking on unsupported platforms.
26
- */
27
- export declare class FileAccessTracker {
28
- #private;
29
- constructor(workspaceRoot: string, excludePatterns?: RegExp[]);
30
- /**
31
- * Returns true if file access tracking is supported on the current platform.
32
- */
33
- isSupported(): boolean;
34
- /**
35
- * Runs a command and tracks all file system accesses.
36
- * On unsupported platforms, runs the command without tracking.
37
- */
38
- track(command: string, options?: {
39
- cwd?: string;
40
- env?: Record<string, string | undefined>;
41
- }): Promise<TrackingResult>;
42
- /**
43
- * Kills all active child processes. Called on abort/signal to prevent orphans.
44
- */
45
- killAll(): void;
46
- }
47
- /**
48
- * Generates a preload script that can be used with NODE_OPTIONS to
49
- * track file accesses in Node.js child processes.
50
- *
51
- * This is an alternative to strace that works cross-platform for Node.js processes.
52
- */
53
- export declare const generatePreloadScript: (outputPath: string) => string;
@@ -1,45 +0,0 @@
1
- import type { FileAccess } from "./file-access-tracker.d.ts";
2
- /**
3
- * Represents a stored fingerprint for a task execution.
4
- */
5
- export interface TaskFingerprint {
6
- /** Hash of the command arguments */
7
- commandHash: string;
8
- /** Directory listings recorded during execution (path -> sorted entries) */
9
- directoryListings: Record<string, string[]>;
10
- /** Hashes of fingerprinted environment variables */
11
- envHashes: Record<string, string>;
12
- /** Content hashes of files that were read during execution */
13
- fileHashes: Record<string, string>;
14
- /** Paths of files that were probed but didn't exist (ENOENT) */
15
- missingFiles: string[];
16
- }
17
- /**
18
- * Describes why a cache miss occurred.
19
- */
20
- export interface CacheMissReason {
21
- currentHash?: string;
22
- detail: string;
23
- previousHash?: string;
24
- type: "file-changed" | "file-created" | "file-deleted" | "directory-changed" | "env-changed" | "args-changed" | "no-fingerprint";
25
- }
26
- /**
27
- * Manages task fingerprints for auto-detection caching.
28
- *
29
- * Records which files a task accesses during execution, stores content
30
- * hashes, and on subsequent runs checks if any accessed file has changed.
31
- */
32
- export declare class FingerprintManager {
33
- #private;
34
- constructor(workspaceRoot: string);
35
- createFingerprint(accesses: FileAccess[], command: string, args: Record<string, unknown>, envVariables: Record<string, string | undefined>, envPatterns?: string[], untrackedEnvVariables?: string[]): Promise<TaskFingerprint>;
36
- /**
37
- * Validates a stored fingerprint against the current state.
38
- * Returns null if valid (cache hit), or an array of reasons (cache miss).
39
- *
40
- * Does NOT use the file hash cache — validation must see current disk state.
41
- */
42
- validate(fingerprint: TaskFingerprint): Promise<CacheMissReason[] | undefined>;
43
- validateCommand(fingerprint: TaskFingerprint, command: string, args: Record<string, unknown>): CacheMissReason | undefined;
44
- formatMissReasons(reasons: CacheMissReason[]): string;
45
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * Detected framework information.
3
- */
4
- interface DetectedFramework {
5
- /** The env var prefix(es) that should be included in task hashes */
6
- envPrefixes: string[];
7
- /** The framework name */
8
- name: string;
9
- }
10
- /**
11
- * Detects frameworks used in a project by inspecting its package.json dependencies.
12
- * @param packageJsonPath Absolute path to the package.json file
13
- * @returns Array of detected frameworks with their env prefixes
14
- */
15
- declare const detectFrameworks: (packageJsonPath: string) => Promise<DetectedFramework[]>;
16
- /**
17
- * Detects frameworks across all projects in a workspace and returns
18
- * the env var patterns that should be included in task hashes.
19
- * @param workspaceRoot The workspace root directory
20
- * @param projects Map of project name to project configuration with root paths
21
- * @returns Array of env var wildcard patterns (e.g., ["NEXT_PUBLIC_*", "VITE_*"])
22
- */
23
- declare const inferFrameworkEnvPatterns: (workspaceRoot: string, projects: Record<string, {
24
- root: string;
25
- }>) => Promise<string[]>;
26
- /**
27
- * For a specific project, detects frameworks and returns the matching
28
- * env vars from the current environment.
29
- * @param packageJsonPath Absolute path to the project's package.json
30
- * @param env The current environment variables
31
- * @returns Map of env var name to value for matching framework env vars
32
- */
33
- declare const getFrameworkEnvVariables: (packageJsonPath: string, env?: Record<string, string | undefined>) => Promise<Record<string, string>>;
34
- export type { DetectedFramework };
35
- export { detectFrameworks, getFrameworkEnvVariables, inferFrameworkEnvPatterns };
@@ -1,74 +0,0 @@
1
- import type { ProjectGraph, TaskGraph } from "./types.d.ts";
2
- /**
3
- * Graph visualization output formats.
4
- */
5
- type GraphFormat = "dot" | "json" | "html" | "ascii";
6
- /**
7
- * Options for graph visualization.
8
- */
9
- interface GraphVisualizerOptions {
10
- /** Show only affected/filtered tasks (highlight subset) */
11
- focusedTasks?: string[];
12
- /** Group tasks by project (default: true) */
13
- groupByProject?: boolean;
14
- /** Show task status colors (requires results) */
15
- taskStatuses?: Map<string, "success" | "failure" | "skipped" | "local-cache" | "local-cache-kept-existing" | "remote-cache" | "running" | "pending">;
16
- }
17
- /**
18
- * Exports a task graph in DOT format for Graphviz rendering.
19
- * @example
20
- * ```ts
21
- * const dot = toGraphvizDot(taskGraph);
22
- * // Render: dot -Tsvg -o graph.svg <<< "$dot"
23
- * ```
24
- */
25
- declare const toGraphvizDot: (taskGraph: TaskGraph, options?: GraphVisualizerOptions) => string;
26
- /**
27
- * Exports the task graph as a JSON object suitable for visualization tools.
28
- */
29
- interface GraphJson {
30
- edges: {
31
- source: string;
32
- target: string;
33
- }[];
34
- nodes: {
35
- configuration?: string;
36
- id: string;
37
- project: string;
38
- status?: string;
39
- target: string;
40
- }[];
41
- roots: string[];
42
- }
43
- declare const toGraphJson: (taskGraph: TaskGraph, taskStatuses?: Map<string, string>) => {
44
- edges: GraphJson["edges"];
45
- nodes: GraphJson["nodes"];
46
- roots: string[];
47
- };
48
- /**
49
- * Generates a self-contained HTML file with an interactive task graph visualization.
50
- * Uses a simple force-directed layout with SVG rendering (no external dependencies).
51
- */
52
- declare const toGraphHtml: (taskGraph: TaskGraph, options?: GraphVisualizerOptions) => string;
53
- /**
54
- * Renders the task graph as ASCII art for terminal display.
55
- * @example
56
- * ```
57
- * Task Graph (6 tasks, 5 dependencies)
58
- *
59
- * app:build
60
- * ├── lib-a:build
61
- * │ └── lib-core:build
62
- * └── lib-b:build
63
- * └── lib-core:build (*)
64
- *
65
- * (*) = already shown above
66
- * ```
67
- */
68
- declare const toGraphAscii: (taskGraph: TaskGraph, options?: GraphVisualizerOptions) => string;
69
- /**
70
- * Exports a project graph in DOT format.
71
- */
72
- declare const projectGraphToDot: (projectGraph: ProjectGraph) => string;
73
- export type { GraphFormat, GraphJson, GraphVisualizerOptions };
74
- export { projectGraphToDot, toGraphAscii, toGraphHtml, toGraphJson, toGraphvizDot };
@@ -1,58 +0,0 @@
1
- /**
2
- * Incremental file hasher that only re-hashes files that have changed
3
- * since the last run, based on mtime comparison.
4
- *
5
- * This is the key performance optimization used by Nx's daemon and
6
- * Turborepo's daemon — on subsequent runs, only files whose mtime
7
- * changed need to be re-read and re-hashed.
8
- *
9
- * The snapshot (path → { mtime, hash }) is kept in memory and can
10
- * optionally be persisted to disk for cross-process reuse.
11
- */
12
- interface FileSnapshot {
13
- /** xxh3-128 hash of file contents */
14
- hash: string;
15
- /** Last modification time in milliseconds */
16
- mtimeMs: number;
17
- /** File size in bytes (fast pre-check) */
18
- size: number;
19
- }
20
- interface IncrementalHasherOptions {
21
- /** Directories to skip (default: node_modules, .git, dist, coverage, .cache) */
22
- ignoredDirs?: Set<string>;
23
- /** File to persist the snapshot to (for cross-run reuse) */
24
- snapshotPath?: string;
25
- workspaceRoot: string;
26
- }
27
- declare class IncrementalFileHasher {
28
- #private;
29
- constructor(options: IncrementalHasherOptions);
30
- /**
31
- * Loads the snapshot from disk if available.
32
- * Called automatically on first use.
33
- */
34
- load(): Promise<void>;
35
- /**
36
- * Persists the current snapshot to disk for cross-run reuse.
37
- */
38
- save(): Promise<void>;
39
- /**
40
- * Incrementally hashes all files in a directory.
41
- *
42
- * Only files whose mtime or size changed since the last snapshot
43
- * are re-read and re-hashed. Unchanged files reuse the cached hash.
44
- *
45
- * Returns a map of relative paths → hashes.
46
- */
47
- hashDirectory(directoryPath: string): Promise<Record<string, string>>;
48
- /**
49
- * Returns how many files are in the snapshot (for diagnostics).
50
- */
51
- get snapshotSize(): number;
52
- /**
53
- * Clears the in-memory snapshot.
54
- */
55
- clear(): void;
56
- }
57
- export type { FileSnapshot, IncrementalHasherOptions };
58
- export { IncrementalFileHasher };