@visulima/task-runner 1.0.0-alpha.1 → 1.0.0-alpha.10

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 (140) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/README.md +196 -52
  3. package/dist/index.d.ts +3166 -34
  4. package/dist/index.js +1 -20
  5. package/dist/packem_chunks/index.js +11 -0
  6. package/dist/packem_shared/Cache-C540ZPYk.js +2 -0
  7. package/dist/packem_shared/CompositeLifeCycle-D0zWvAXJ.js +1 -0
  8. package/dist/packem_shared/FileAccessTracker-DSNf03JW.js +47 -0
  9. package/dist/packem_shared/FingerprintManager-CYW2EwLc.js +2 -0
  10. package/dist/packem_shared/HttpRemoteCache-Ch-_9ejF.js +1 -0
  11. package/dist/packem_shared/INPUT_URI_SCHEMES-Csrd0tlg.js +1 -0
  12. package/dist/packem_shared/IncrementalFileHasher-jtLxMBKy.js +1 -0
  13. package/dist/packem_shared/LogReporter-BUPWiXAq.js +13 -0
  14. package/dist/packem_shared/ReapiRemoteCache-B3uQuVqP.js +251 -0
  15. package/dist/packem_shared/TaskOrchestrator-BgfOpjuB.js +2 -0
  16. package/dist/packem_shared/TerminalBuffer-BtZy7TpT.js +3 -0
  17. package/dist/packem_shared/TrackedTaskExecutor-D3-LNT_d.js +2 -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-w1FVPFdv.js +3 -0
  22. package/dist/packem_shared/collectFiles-W4bnBRpb.js +1 -0
  23. package/dist/packem_shared/computeTaskHash-C2Iua2DL.js +1 -0
  24. package/dist/packem_shared/containsBlob-DBWgvkM_.js +1 -0
  25. package/dist/packem_shared/createInputHandler-CkDCpPYy.js +1 -0
  26. package/dist/packem_shared/createTaskGraph-CEYYI-DL.js +1 -0
  27. package/dist/packem_shared/defaultTaskRunner-CGbD4ahu.js +2 -0
  28. package/dist/packem_shared/detectFrameworks-WVZJOPgN.js +1 -0
  29. package/dist/packem_shared/detectScriptShell-CaTDk5cW.js +1 -0
  30. package/dist/packem_shared/digestBuffer-g11aCaDx.js +1 -0
  31. package/dist/packem_shared/enforceProjectConstraints-X49n3bVL.js +1 -0
  32. package/dist/packem_shared/expandArguments-4mab7-Ds.js +1 -0
  33. package/dist/packem_shared/expandShortcut-BErNHNXZ.js +1 -0
  34. package/dist/packem_shared/expandTokensInString-Cyx0qSFA.js +1 -0
  35. package/dist/packem_shared/expandWildcard-DE0dOOZF.js +1 -0
  36. package/dist/packem_shared/extractPackageName-BeL6Gc3a.js +1 -0
  37. package/dist/packem_shared/findCycle-BY8-jmzB.js +1 -0
  38. package/dist/packem_shared/formatTimingTable-CP3rsDwf.js +7 -0
  39. package/dist/packem_shared/generateRunSummary-ep21OCUT.js +1 -0
  40. package/dist/packem_shared/getCurrentBranch-D-qoZByx.js +1 -0
  41. package/dist/packem_shared/getMainWorktreeRoot-DRN_i8jA.js +1 -0
  42. package/dist/packem_shared/isNativeAvailable-BOavFPX1.js +1 -0
  43. package/dist/packem_shared/parseCommands-b1K2vIxj.js +1 -0
  44. package/dist/packem_shared/parsePartition-uzPNgtPp.js +1 -0
  45. package/dist/packem_shared/projectGraphToDot-K5A_CRoW.js +250 -0
  46. package/dist/packem_shared/resolveCacheMode-XhD7mg7G.js +1 -0
  47. package/dist/packem_shared/resolveOutputs-BBjdaraf.js +1 -0
  48. package/dist/packem_shared/runConcurrentFallback-CShJ7HUp.js +3 -0
  49. package/dist/packem_shared/runConcurrently-B471CUHO.js +1 -0
  50. package/dist/packem_shared/runTeardown-DBBpBAyb.js +1 -0
  51. package/dist/packem_shared/shell-quote-CksLqyXK.js +1 -0
  52. package/dist/packem_shared/stripQuotes-jkZb0CL9.js +1 -0
  53. package/dist/packem_shared/toChromeTrace-DxN5NQIU.js +1 -0
  54. package/dist/packem_shared/utils-BH2W5Wml.js +1 -0
  55. package/dist/packem_shared/withRestart-CWO6BKv_.js +1 -0
  56. package/index.js +775 -0
  57. package/package.json +30 -18
  58. package/binding.js +0 -204
  59. package/dist/affected.d.ts +0 -48
  60. package/dist/cache.d.ts +0 -103
  61. package/dist/default-task-runner.d.ts +0 -44
  62. package/dist/file-access-tracker.d.ts +0 -53
  63. package/dist/fingerprint.d.ts +0 -45
  64. package/dist/framework-inference.d.ts +0 -35
  65. package/dist/graph-visualizer.d.ts +0 -74
  66. package/dist/incremental-hasher.d.ts +0 -58
  67. package/dist/life-cycle.d.ts +0 -36
  68. package/dist/lockfile-hasher.d.ts +0 -73
  69. package/dist/native-binding.d.ts +0 -64
  70. package/dist/packem_shared/Cache-IYpTYVUC.js +0 -298
  71. package/dist/packem_shared/CompositeLifeCycle-7AtYw1dv.js +0 -112
  72. package/dist/packem_shared/FileAccessTracker-CrtBAt5D.js +0 -239
  73. package/dist/packem_shared/FingerprintManager-D6Y0erg-.js +0 -227
  74. package/dist/packem_shared/IncrementalFileHasher-Ds3J6dgb.js +0 -151
  75. package/dist/packem_shared/RemoteCache-BDqrnDEi.js +0 -179
  76. package/dist/packem_shared/TaskOrchestrator-BvYs3ONw.js +0 -342
  77. package/dist/packem_shared/TaskScheduler-CJilHDta.js +0 -111
  78. package/dist/packem_shared/TrackedTaskExecutor-BGUKFE-7.js +0 -164
  79. package/dist/packem_shared/collectFiles-ClXHnHhg.js +0 -22
  80. package/dist/packem_shared/computeTaskHash-BoCnnvIJ.js +0 -356
  81. package/dist/packem_shared/createTaskGraph-CcsFaSrz.js +0 -164
  82. package/dist/packem_shared/defaultTaskRunner-CrW4v5Ye.js +0 -79
  83. package/dist/packem_shared/detectFrameworks-CeFzKE6J.js +0 -101
  84. package/dist/packem_shared/extractPackageName-CbVNW-dr.js +0 -189
  85. package/dist/packem_shared/filterAffectedTasks-I-18zPg6.js +0 -135
  86. package/dist/packem_shared/findCycle-DF4_BRdO.js +0 -212
  87. package/dist/packem_shared/generateRunSummary-qn-_jKwt.js +0 -134
  88. package/dist/packem_shared/isNativeAvailable-BWhnZ4ES.js +0 -19
  89. package/dist/packem_shared/projectGraphToDot-VdTjHcVp.js +0 -202
  90. package/dist/packem_shared/utils-zO0ZRgtf.js +0 -390
  91. package/dist/remote-cache.d.ts +0 -55
  92. package/dist/run-summary.d.ts +0 -89
  93. package/dist/task-graph-utils.d.ts +0 -39
  94. package/dist/task-graph.d.ts +0 -22
  95. package/dist/task-hasher.d.ts +0 -67
  96. package/dist/task-orchestrator.d.ts +0 -38
  97. package/dist/task-scheduler.d.ts +0 -18
  98. package/dist/tracked-executor.d.ts +0 -46
  99. package/dist/types.d.ts +0 -385
  100. package/dist/utils.d.ts +0 -39
  101. package/npm/darwin-arm64/LICENSE.md +0 -21
  102. package/npm/darwin-arm64/node_modules/.bin/semantic-release +0 -21
  103. package/npm/darwin-arm64/package.json +0 -39
  104. package/npm/darwin-arm64/task-runner-native.darwin-arm64.node +0 -0
  105. package/npm/darwin-x64/LICENSE.md +0 -21
  106. package/npm/darwin-x64/node_modules/.bin/semantic-release +0 -21
  107. package/npm/darwin-x64/package.json +0 -39
  108. package/npm/darwin-x64/task-runner-native.darwin-x64.node +0 -0
  109. package/npm/linux-arm64-gnu/LICENSE.md +0 -21
  110. package/npm/linux-arm64-gnu/node_modules/.bin/semantic-release +0 -21
  111. package/npm/linux-arm64-gnu/package.json +0 -42
  112. package/npm/linux-arm64-gnu/task-runner-native.linux-arm64-gnu.node +0 -0
  113. package/npm/linux-arm64-musl/LICENSE.md +0 -21
  114. package/npm/linux-arm64-musl/node_modules/.bin/semantic-release +0 -21
  115. package/npm/linux-arm64-musl/package.json +0 -42
  116. package/npm/linux-arm64-musl/task-runner-native.linux-arm64-musl.node +0 -0
  117. package/npm/linux-x64-gnu/LICENSE.md +0 -21
  118. package/npm/linux-x64-gnu/node_modules/.bin/semantic-release +0 -21
  119. package/npm/linux-x64-gnu/package.json +0 -42
  120. package/npm/linux-x64-gnu/task-runner-native.linux-x64-gnu.node +0 -0
  121. package/npm/linux-x64-musl/LICENSE.md +0 -21
  122. package/npm/linux-x64-musl/node_modules/.bin/semantic-release +0 -21
  123. package/npm/linux-x64-musl/package.json +0 -42
  124. package/npm/linux-x64-musl/task-runner-native.linux-x64-musl.node +0 -0
  125. package/npm/win32-arm64-msvc/LICENSE.md +0 -21
  126. package/npm/win32-arm64-msvc/node_modules/.bin/semantic-release +0 -21
  127. package/npm/win32-arm64-msvc/package.json +0 -39
  128. package/npm/win32-arm64-msvc/task-runner-native.win32-arm64-msvc.node +0 -0
  129. package/npm/win32-x64-msvc/LICENSE.md +0 -21
  130. package/npm/win32-x64-msvc/node_modules/.bin/semantic-release +0 -21
  131. package/npm/win32-x64-msvc/package.json +0 -39
  132. package/npm/win32-x64-msvc/task-runner-native.win32-x64-msvc.node +0 -0
  133. package/task-runner-native.darwin-arm64.node +0 -0
  134. package/task-runner-native.darwin-x64.node +0 -0
  135. package/task-runner-native.linux-arm64-gnu.node +0 -0
  136. package/task-runner-native.linux-arm64-musl.node +0 -0
  137. package/task-runner-native.linux-x64-gnu.node +0 -0
  138. package/task-runner-native.linux-x64-musl.node +0 -0
  139. package/task-runner-native.win32-arm64-msvc.node +0 -0
  140. package/task-runner-native.win32-x64-msvc.node +0 -0
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@visulima/task-runner",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.10",
4
4
  "description": "A task runner with caching support for monorepo workspaces",
5
5
  "keywords": [
6
- "visulima",
7
- "task-runner",
8
6
  "cache",
9
7
  "monorepo",
10
- "task",
11
8
  "runner",
9
+ "task",
10
+ "task-runner",
11
+ "visulima",
12
12
  "workspace"
13
13
  ],
14
14
  "homepage": "https://visulima.com/packages/task-runner",
@@ -46,29 +46,41 @@
46
46
  },
47
47
  "files": [
48
48
  "dist/**",
49
- "binding.js",
50
- "npm",
51
- "*.node",
49
+ "index.js",
52
50
  "README.md",
53
51
  "CHANGELOG.md",
54
52
  "LICENSE.md"
55
53
  ],
56
54
  "dependencies": {
57
- "@visulima/humanizer": "3.0.0-alpha.7",
58
- "@visulima/path": "3.0.0-alpha.6"
55
+ "@lydell/node-pty": "1.2.0-beta.12",
56
+ "@visulima/humanizer": "3.0.0-alpha.11",
57
+ "@visulima/path": "3.0.0-alpha.10",
58
+ "nanotar": "^0.3.0"
59
+ },
60
+ "peerDependencies": {
61
+ "@grpc/grpc-js": "*",
62
+ "@grpc/proto-loader": "*"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@grpc/grpc-js": {
66
+ "optional": true
67
+ },
68
+ "@grpc/proto-loader": {
69
+ "optional": true
70
+ }
59
71
  },
60
72
  "optionalDependencies": {
61
- "@visulima/task-runner-binding-darwin-arm64": "0.0.1",
62
- "@visulima/task-runner-binding-linux-arm64-gnu": "0.0.1",
63
- "@visulima/task-runner-binding-linux-arm64-musl": "0.0.1",
64
- "@visulima/task-runner-binding-linux-x64-gnu": "0.0.1",
65
- "@visulima/task-runner-binding-darwin-x64": "0.0.1",
66
- "@visulima/task-runner-binding-linux-x64-musl": "0.0.1",
67
- "@visulima/task-runner-binding-win32-arm64-msvc": "0.0.1",
68
- "@visulima/task-runner-binding-win32-x64-msvc": "0.0.1"
73
+ "@visulima/task-runner-binding-darwin-arm64": "1.0.0-alpha.10",
74
+ "@visulima/task-runner-binding-linux-arm64-gnu": "1.0.0-alpha.10",
75
+ "@visulima/task-runner-binding-linux-arm64-musl": "1.0.0-alpha.10",
76
+ "@visulima/task-runner-binding-linux-x64-gnu": "1.0.0-alpha.10",
77
+ "@visulima/task-runner-binding-darwin-x64": "1.0.0-alpha.10",
78
+ "@visulima/task-runner-binding-win32-arm64-msvc": "1.0.0-alpha.10",
79
+ "@visulima/task-runner-binding-linux-x64-musl": "1.0.0-alpha.10",
80
+ "@visulima/task-runner-binding-win32-x64-msvc": "1.0.0-alpha.10"
69
81
  },
70
82
  "engines": {
71
- "node": ">=20.19 <=25.x"
83
+ "node": "^22.14.0 || >=24.10.0"
72
84
  },
73
85
  "publishConfig": {
74
86
  "access": "public",
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 };