@visulima/task-runner 1.0.0-alpha.6 → 1.0.0-alpha.8

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 (54) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/index.d.ts +2507 -49
  3. package/dist/index.js +9 -7
  4. package/dist/packem_shared/{TaskOrchestrator-rf45vW5c.js → TaskOrchestrator-UCMHCx8c.js} +68 -2
  5. package/dist/packem_shared/{buildForwardDependencyMap-DLPgKEto.js → buildForwardDependencyMap-0BJFMMPv.js} +1 -2
  6. package/dist/packem_shared/{computeTaskHash-DYqfrDGq.js → computeTaskHash-B5APHW7e.js} +1 -1
  7. package/dist/packem_shared/{createTaskGraph-B7nH0kY_.js → createTaskGraph-B5YrfAMx.js} +6 -2
  8. package/dist/packem_shared/{defaultTaskRunner-Cp7jCmIl.js → defaultTaskRunner-DzR0ld8F.js} +36 -4
  9. package/dist/packem_shared/expandTokensInString-C03AGAjh.js +46 -0
  10. package/dist/packem_shared/{extractPackageName-BllKetnz.js → extractPackageName-CbVNW-dr.js} +1 -2
  11. package/dist/packem_shared/getCurrentBranch-DsKPDoVj.js +153 -0
  12. package/dist/packem_shared/{parseCommands-D-IgF8Zh.js → parseCommands-CJ16ohOB.js} +7 -2
  13. package/index.js +556 -723
  14. package/package.json +14 -14
  15. package/dist/affected.d.ts +0 -82
  16. package/dist/archive.d.ts +0 -38
  17. package/dist/cache.d.ts +0 -138
  18. package/dist/chrome-trace.d.ts +0 -53
  19. package/dist/command-parser/expand-arguments.d.ts +0 -11
  20. package/dist/command-parser/expand-shortcut.d.ts +0 -15
  21. package/dist/command-parser/expand-wildcard.d.ts +0 -13
  22. package/dist/command-parser/index.d.ts +0 -18
  23. package/dist/command-parser/strip-quotes.d.ts +0 -6
  24. package/dist/concurrent-fallback.d.ts +0 -16
  25. package/dist/concurrent.d.ts +0 -23
  26. package/dist/default-task-runner.d.ts +0 -44
  27. package/dist/detect-shell.d.ts +0 -19
  28. package/dist/file-access-tracker.d.ts +0 -59
  29. package/dist/fingerprint.d.ts +0 -54
  30. package/dist/flow-controllers/index.d.ts +0 -7
  31. package/dist/flow-controllers/input-handler.d.ts +0 -44
  32. package/dist/flow-controllers/log-timings.d.ts +0 -18
  33. package/dist/flow-controllers/restart-process.d.ts +0 -21
  34. package/dist/flow-controllers/teardown.d.ts +0 -22
  35. package/dist/framework-inference.d.ts +0 -35
  36. package/dist/graph-visualizer.d.ts +0 -74
  37. package/dist/incremental-hasher.d.ts +0 -76
  38. package/dist/life-cycle.d.ts +0 -38
  39. package/dist/lockfile-hasher.d.ts +0 -73
  40. package/dist/log-reporter.d.ts +0 -34
  41. package/dist/native-binding.d.ts +0 -106
  42. package/dist/output-resolver.d.ts +0 -20
  43. package/dist/project-constraints.d.ts +0 -9
  44. package/dist/remote-cache.d.ts +0 -100
  45. package/dist/run-summary.d.ts +0 -111
  46. package/dist/task-graph-utils.d.ts +0 -39
  47. package/dist/task-graph.d.ts +0 -22
  48. package/dist/task-hasher.d.ts +0 -104
  49. package/dist/task-orchestrator.d.ts +0 -38
  50. package/dist/task-scheduler.d.ts +0 -41
  51. package/dist/terminal-buffer.d.ts +0 -29
  52. package/dist/tracked-executor.d.ts +0 -46
  53. package/dist/types.d.ts +0 -757
  54. package/dist/utils.d.ts +0 -39
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@visulima/task-runner",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.8",
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",
@@ -53,18 +53,18 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "@lydell/node-pty": "1.2.0-beta.12",
56
- "@visulima/humanizer": "3.0.0-alpha.10",
57
- "@visulima/path": "3.0.0-alpha.9"
56
+ "@visulima/humanizer": "3.0.0-alpha.11",
57
+ "@visulima/path": "3.0.0-alpha.10"
58
58
  },
59
59
  "optionalDependencies": {
60
- "@visulima/task-runner-binding-darwin-arm64": "1.0.0-alpha.6",
61
- "@visulima/task-runner-binding-linux-arm64-gnu": "1.0.0-alpha.6",
62
- "@visulima/task-runner-binding-darwin-x64": "1.0.0-alpha.6",
63
- "@visulima/task-runner-binding-linux-arm64-musl": "1.0.0-alpha.6",
64
- "@visulima/task-runner-binding-linux-x64-gnu": "1.0.0-alpha.6",
65
- "@visulima/task-runner-binding-linux-x64-musl": "1.0.0-alpha.6",
66
- "@visulima/task-runner-binding-win32-arm64-msvc": "1.0.0-alpha.6",
67
- "@visulima/task-runner-binding-win32-x64-msvc": "1.0.0-alpha.6"
60
+ "@visulima/task-runner-binding-darwin-arm64": "1.0.0-alpha.8",
61
+ "@visulima/task-runner-binding-darwin-x64": "1.0.0-alpha.8",
62
+ "@visulima/task-runner-binding-linux-arm64-gnu": "1.0.0-alpha.8",
63
+ "@visulima/task-runner-binding-linux-arm64-musl": "1.0.0-alpha.8",
64
+ "@visulima/task-runner-binding-linux-x64-gnu": "1.0.0-alpha.8",
65
+ "@visulima/task-runner-binding-linux-x64-musl": "1.0.0-alpha.8",
66
+ "@visulima/task-runner-binding-win32-arm64-msvc": "1.0.0-alpha.8",
67
+ "@visulima/task-runner-binding-win32-x64-msvc": "1.0.0-alpha.8"
68
68
  },
69
69
  "engines": {
70
70
  "node": "^22.14.0 || >=24.10.0"
@@ -1,82 +0,0 @@
1
- import type { AffectedScope, 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
- /**
9
- * Control how far downstream (dependents of changed projects) to include.
10
- * @default "deep"
11
- */
12
- downstream?: AffectedScope;
13
- /** The head ref to compare (default: "HEAD") */
14
- head?: string;
15
- /** Project graph for dependency resolution */
16
- projectGraph: ProjectGraph;
17
- /** All project configurations keyed by name */
18
- projects: Record<string, ProjectConfiguration>;
19
- /**
20
- * Control how far upstream (dependencies of changed projects) to include.
21
- * @default "none"
22
- */
23
- upstream?: AffectedScope;
24
- /** The workspace root directory */
25
- workspaceRoot: string;
26
- }
27
- /**
28
- * Result of affected detection.
29
- */
30
- interface AffectedResult {
31
- /** All affected projects (union of changed, downstream, and upstream) */
32
- affectedProjects: string[];
33
- /** Files that changed between base and head */
34
- changedFiles: string[];
35
- /** Projects that were directly changed */
36
- changedProjects: string[];
37
- /** Projects affected because they depend on changed projects */
38
- downstreamProjects: string[];
39
- /** Projects that changed projects depend on */
40
- upstreamProjects: string[];
41
- }
42
- /**
43
- * Builds a map from each project to the set of projects that depend on it (reverse/downstream).
44
- */
45
- declare const buildReverseDependencyMap: (projectGraph: ProjectGraph) => Map<string, Set<string>>;
46
- /**
47
- * Builds a map from each project to the set of projects it depends on (forward/upstream).
48
- */
49
- declare const buildForwardDependencyMap: (projectGraph: ProjectGraph) => Map<string, Set<string>>;
50
- /**
51
- * Expands a set of changed projects based on upstream/downstream scope settings.
52
- * Returns a new set containing all affected projects.
53
- */
54
- declare const expandAffected: (changedProjects: Set<string>, projectGraph: ProjectGraph, options: {
55
- downstream: AffectedScope;
56
- upstream: AffectedScope;
57
- }) => {
58
- affected: Set<string>;
59
- downstream: Set<string>;
60
- upstream: Set<string>;
61
- };
62
- /**
63
- * Gets the list of files changed between two git refs.
64
- * Uses execFile with argument arrays to prevent command injection.
65
- */
66
- declare const getChangedFiles: (workspaceRoot: string, base: string, head: string) => Promise<string[]>;
67
- /**
68
- * Determines which projects are affected by changes between two git refs.
69
- *
70
- * Uses `git diff` to find changed files, maps them to projects based on
71
- * project roots, then walks the project dependency graph to find all
72
- * transitively affected projects.
73
- *
74
- * This is the same strategy used by `nx affected` and `turbo run --filter=[base...]`.
75
- */
76
- declare const getAffectedProjects: (options: AffectedOptions) => Promise<AffectedResult>;
77
- /**
78
- * Filters tasks to only include those that are affected by changes.
79
- */
80
- declare const filterAffectedTasks: (taskIds: string[], affectedProjects: Set<string>) => string[];
81
- export type { AffectedOptions, AffectedResult };
82
- export { buildForwardDependencyMap, buildReverseDependencyMap, expandAffected, filterAffectedTasks, getAffectedProjects, getChangedFiles };
package/dist/archive.d.ts DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- * Shared tar + brotli archive helpers.
3
- *
4
- * Both the local cache (`cache.ts`) and remote cache (`remote-cache.ts`)
5
- * archive file trees into compressed tarballs. This module consolidates
6
- * the compression parameters and stream plumbing so both paths stay in
7
- * sync — same brotli quality, same error-handling shape, one place to
8
- * audit.
9
- */
10
- /**
11
- * Brotli quality 4 hits a sweet spot for cache tarballs: ~15–20% smaller
12
- * than gzip on typical source/dist payloads at comparable throughput.
13
- * Higher qualities (8+) reach diminishing returns and noticeably slow
14
- * down cache writes; lower qualities (1–3) give up ratio for speed we
15
- * don't need on IO-bound workloads.
16
- */
17
- export declare const BROTLI_COMPRESS_OPTIONS: {
18
- params: Record<number, number>;
19
- };
20
- /** Plain tar: `sourceDir` → `outputPath`, no compression. */
21
- export declare const createTar: (sourceDirectory: string, outputPath: string) => Promise<void>;
22
- /** Plain tar extract into `destinationDirectory`. */
23
- export declare const extractTar: (archivePath: string, destinationDirectory: string) => Promise<void>;
24
- /** tar + gzip (`-czf`). Used when Turborepo-protocol compatibility matters. */
25
- export declare const createTarGz: (sourceDirectory: string, outputPath: string) => Promise<void>;
26
- export declare const extractTarGz: (archivePath: string, destinationDirectory: string) => Promise<void>;
27
- /**
28
- * Creates an uncompressed tar, then streams it through brotli into
29
- * `outputPath`. Two-step (tar-to-temp, brotli-stream) to avoid
30
- * shelling out to an external `brotli` binary that may not exist.
31
- * Cleans up the intermediate tar even when compression fails.
32
- */
33
- export declare const createTarBrotli: (sourceDirectory: string, outputPath: string) => Promise<void>;
34
- /**
35
- * Inverse of {@link createTarBrotli}: decompresses into a temp tar,
36
- * then extracts. Temp is cleaned in `finally`.
37
- */
38
- export declare const extractTarBrotli: (archivePath: string, destinationDirectory: string) => Promise<void>;
package/dist/cache.d.ts DELETED
@@ -1,138 +0,0 @@
1
- import type { TaskFingerprint } from "./fingerprint.d.ts";
2
- import type { OutputSpec } from "./types.d.ts";
3
- /**
4
- * Represents a cached task result.
5
- */
6
- interface CachedResult {
7
- /** The exit code of the original task execution */
8
- code: number;
9
- /** The auto-fingerprint data, if auto-fingerprinting was used */
10
- fingerprint?: TaskFingerprint;
11
- /** The hash that was used as the cache key */
12
- hash: string;
13
- /** The terminal output of the original task execution */
14
- terminalOutput: string;
15
- }
16
- /**
17
- * Options for creating a Cache instance.
18
- */
19
- interface CacheOptions {
20
- /** The cache directory (defaults to `{workspaceRoot}/.task-runner-cache`) */
21
- cacheDirectory?: string;
22
- /**
23
- * Optional isolation namespace appended to the cache directory
24
- * as `&lt;cacheDir>/ns/&lt;namespace>`. When the caller derives the
25
- * namespace from the resolved global-env fingerprint, flipping an
26
- * env var sends writes into a new namespace while keeping the old
27
- * namespace intact — rolling the env back restores the old hits.
28
- *
29
- * Filesystem-safe segment; callers are responsible for sanitising
30
- * (slashes/colons would break path resolution).
31
- */
32
- cacheNamespace?: string;
33
- /** Maximum age of cache entries in milliseconds (default: 7 days) */
34
- maxCacheAge?: number;
35
- /** Maximum cache size (e.g., "500MB", "1GB") */
36
- maxCacheSize?: string;
37
- /** The workspace root directory */
38
- workspaceRoot: string;
39
- }
40
- /**
41
- * Directory name (relative to `workspaceRoot`) where the task runner writes
42
- * its cache by default. Exported so callers that manage the cache from the
43
- * outside — e.g. a CLI `cache clean` command — can reach the same default
44
- * without hard-coding the literal.
45
- */
46
- declare const DEFAULT_CACHE_DIRECTORY_NAME = ".task-runner-cache";
47
- /**
48
- * Parses a human-readable cache size string into bytes.
49
- * Delegates to @visulima/humanizer's parseBytes with base-2 (1024) multipliers.
50
- */
51
- declare const parseCacheSize: (sizeString: string) => number;
52
- /**
53
- * Formats a byte count into a human-readable string.
54
- * Delegates to @visulima/humanizer's formatBytes with base-2 (1024) multipliers.
55
- */
56
- declare const formatCacheSize: (bytes: number) => string;
57
- /**
58
- * Local file-based cache for task results.
59
- *
60
- * Cache structure:
61
- * ```
62
- * .task-runner-cache/
63
- * &lt;hash&gt;/
64
- * outputs/ (Archived build outputs)
65
- * code (Exit code)
66
- * terminalOutput (Captured terminal output)
67
- * fingerprint.json (Auto-fingerprint data, optional)
68
- * .commit (Marker indicating complete cache entry)
69
- * .task-index.json (Task ID -> hash mapping for auto-fingerprint)
70
- * ```
71
- *
72
- * Atomicity: Cache entries are written to a temporary directory first,
73
- * then renamed into place. The `.commit` marker ensures readers only
74
- * see complete entries.
75
- */
76
- declare class Cache {
77
- #private;
78
- constructor(options: CacheOptions);
79
- /**
80
- * Gets the cache directory path.
81
- */
82
- get cacheDirectory(): string;
83
- /**
84
- * Retrieves a cached result for the given task hash.
85
- * Returns undefined if no valid cache entry exists.
86
- */
87
- get(hash: string): Promise<CachedResult | undefined>;
88
- /**
89
- * Stores a task result in the cache.
90
- *
91
- * Uses atomic write: builds the entry in a temporary directory,
92
- * then renames into place to avoid partial reads by concurrent processes.
93
- *
94
- * `outputs` accepts the richer `OutputSpec[]` shape — glob
95
- * patterns, negative globs, and `{ auto: true }` entries. Pass
96
- * `autoWrites` alongside `{ auto: true }` so the resolver knows
97
- * which files the task actually wrote; otherwise auto entries
98
- * contribute nothing.
99
- */
100
- put(hash: string, terminalOutput: string, outputs: OutputSpec[], code: number, fingerprint?: TaskFingerprint, autoWrites?: ReadonlyArray<string>): Promise<void>;
101
- /**
102
- * Restores cached outputs from the compressed `outputs.tar.br`
103
- * archive. Returns `true` either when the archive was extracted
104
- * successfully OR when the entry simply has no outputs to restore.
105
- *
106
- * The restore flow stages into a temp directory, then swaps each
107
- * top-level entry into place (see {@link restoreOutputsCompressed})
108
- * so a mid-restore failure never destroys the user's working tree.
109
- * The `outputs` parameter is no longer consulted at restore time —
110
- * the archive is authoritative, and top-level entries in the
111
- * extracted staging become the set of swap roots. Still accepted
112
- * for backward compat.
113
- */
114
- restoreOutputs(hash: string, _outputs?: OutputSpec[]): Promise<boolean>;
115
- /**
116
- * Retrieves the most recent cached result for a task by its ID.
117
- * Used in auto-fingerprint mode where the hash is derived from
118
- * tracked file accesses rather than computed upfront.
119
- */
120
- getByTaskId(taskId: string): Promise<CachedResult | undefined>;
121
- /**
122
- * Stores the mapping from task ID to cache hash.
123
- * Uses a write queue to serialize concurrent writes and prevent lost updates.
124
- * Each write is atomic (temp file + rename).
125
- */
126
- setTaskIndex(taskId: string, hash: string): Promise<void>;
127
- /**
128
- * Removes old cache entries that exceed the maximum age,
129
- * and enforces the maximum cache size by evicting oldest entries.
130
- */
131
- removeOldEntries(): Promise<void>;
132
- /**
133
- * Clears the entire cache.
134
- */
135
- clear(): Promise<void>;
136
- }
137
- export type { CachedResult, CacheOptions };
138
- export { Cache, DEFAULT_CACHE_DIRECTORY_NAME, formatCacheSize, parseCacheSize };
@@ -1,53 +0,0 @@
1
- import type { RunSummary } from "./run-summary.d.ts";
2
- /**
3
- * A single event in the Chrome Tracing JSON format. Chrome's
4
- * chrome://tracing viewer and Perfetto both accept an array of these.
5
- *
6
- * Fields track the subset we actually emit:
7
- * - `ph: "X"` — "complete" span (has duration)
8
- * - `ph: "s"` / `ph: "f"` — flow start / finish (connects two spans)
9
- *
10
- * See the Chrome Trace Event Format spec on docs.google.com
11
- * (document id: 1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU)
12
- * for the full specification.
13
- */
14
- export interface ChromeTraceEvent {
15
- args?: Record<string, unknown>;
16
- /** Event category — grouped in the viewer's search/filter UI. */
17
- cat: string;
18
- /** Duration in microseconds — only set for `ph: "X"` events. */
19
- dur?: number;
20
- /** Flow ID — used to draw an arrow from flow-start to flow-finish. */
21
- id?: number;
22
- /** Human label shown on the timeline. */
23
- name: string;
24
- /**
25
- * Event phase:
26
- * - `"X"` — complete (span with duration)
27
- * - `"s"` — flow start
28
- * - `"f"` — flow finish
29
- * - `"M"` — metadata
30
- */
31
- ph: "f" | "M" | "s" | "X";
32
- pid: number;
33
- tid: number;
34
- /** Timestamp in microseconds. */
35
- ts: number;
36
- }
37
- /**
38
- * Converts a {@link RunSummary} into a Chrome Tracing event list that
39
- * renders as a gantt chart in chrome://tracing or Perfetto.
40
- *
41
- * Each task becomes a `"X"` span; dependency edges become flow arrows
42
- * from the dependency's finish to the dependent task's start.
43
- * Parallel tasks are assigned synthetic `tid` values (lane 0, 1, 2, …)
44
- * based on the smallest free lane at the task's start time, so the
45
- * timeline clearly shows concurrency without requiring real thread IDs.
46
- */
47
- export declare const toChromeTrace: (summary: RunSummary) => ChromeTraceEvent[];
48
- /**
49
- * Writes a Chrome Tracing JSON file at `outputPath`. Consumers (e.g.
50
- * a CLI `--profile out.json` flag) call this after the run completes
51
- * with a RunSummary produced by the task orchestrator.
52
- */
53
- export declare const writeChromeTrace: (summary: RunSummary, outputPath: string) => Promise<void>;
@@ -1,11 +0,0 @@
1
- import type { ConcurrentCommandConfig } from "../types.d.ts";
2
- /**
3
- * Expands argument placeholders in command strings.
4
- *
5
- * Placeholders:
6
- * {1}, {2}, ... -> specific positional argument
7
- * {@} -> all arguments, individually quoted
8
- * {*} -> all arguments as a single quoted string
9
- * \{1} -> literal {1} (escaped)
10
- */
11
- export declare const expandArguments: (config: ConcurrentCommandConfig, additionalArguments: string[]) => ConcurrentCommandConfig;
@@ -1,15 +0,0 @@
1
- import type { ConcurrentCommandConfig } from "../types.d.ts";
2
- /**
3
- * Expands package manager shortcuts into full commands.
4
- *
5
- * This parser transforms shorthand notation into proper package manager
6
- * invocations. No user input is involved -- command strings originate
7
- * from the calling code which reads package.json scripts.
8
- *
9
- * Examples:
10
- * npm:build -> npm run build
11
- * pnpm:test -> pnpm run test
12
- * node:script -> node --run script
13
- * deno:task -> deno task task
14
- */
15
- export declare const expandShortcut: (config: ConcurrentCommandConfig) => ConcurrentCommandConfig;
@@ -1,13 +0,0 @@
1
- import type { ConcurrentCommandConfig } from "../types.d.ts";
2
- /**
3
- * Expands wildcard patterns in package manager "run" commands.
4
- *
5
- * Reads scripts from package.json and matches against the wildcard pattern.
6
- * Returns one ConcurrentCommandConfig per matching script.
7
- *
8
- * Example: "npm run watch-*" with scripts { "watch-js": "...", "watch-css": "..." }
9
- * -> ["npm run watch-js", "npm run watch-css"]
10
- *
11
- * No user input is involved -- patterns come from the calling code.
12
- */
13
- export declare const expandWildcard: (config: ConcurrentCommandConfig) => ConcurrentCommandConfig | ConcurrentCommandConfig[];
@@ -1,18 +0,0 @@
1
- import type { ConcurrentCommandConfig, ConcurrentCommandInput } from "../types.d.ts";
2
- export interface ParseCommandsOptions {
3
- /** Additional arguments for placeholder expansion ({1}, {@}, {*}). */
4
- additionalArguments?: string[];
5
- }
6
- /**
7
- * Parse and expand command inputs through the full pipeline:
8
- * 1. Normalize string inputs to config objects
9
- * 2. Strip surrounding quotes
10
- * 3. Expand package manager shortcuts (npm:build -> npm run build)
11
- * 4. Expand wildcard patterns (npm run watch-* -> multiple commands)
12
- * 5. Expand argument placeholders ({1}, {@}, {*})
13
- */
14
- export declare const parseCommands: (inputs: ConcurrentCommandInput[], options?: ParseCommandsOptions) => ConcurrentCommandConfig[];
15
- export { expandArguments } from "./expand-arguments.d.ts";
16
- export { expandShortcut } from "./expand-shortcut.d.ts";
17
- export { expandWildcard } from "./expand-wildcard.d.ts";
18
- export { stripQuotes } from "./strip-quotes.d.ts";
@@ -1,6 +0,0 @@
1
- import type { ConcurrentCommandConfig } from "../types.d.ts";
2
- /**
3
- * Removes surrounding quotes from a command string.
4
- * Handles both single and double quotes.
5
- */
6
- export declare const stripQuotes: (config: ConcurrentCommandConfig) => ConcurrentCommandConfig;
@@ -1,16 +0,0 @@
1
- /**
2
- * Pure JavaScript fallback for the concurrent process runner.
3
- * Used when the native Rust addon is not available.
4
- *
5
- * SECURITY NOTE: Commands executed here originate from package.json scripts
6
- * (trusted input, not user-supplied). Shell execution via spawn() with
7
- * explicit shell binary (sh -c / cmd.exe /s /c) is intentional -- package
8
- * scripts require shell features (pipes, redirects, env expansion).
9
- * This is the same approach used by npm/pnpm/yarn themselves.
10
- */
11
- import type { ConcurrentCommandConfig, ConcurrentRunnerOptions, ConcurrentRunResult } from "./types.d.ts";
12
- /**
13
- * Run commands concurrently using pure JavaScript (child_process.spawn).
14
- * This is the fallback when the native Rust addon is unavailable.
15
- */
16
- export declare const runConcurrentFallback: (commands: ConcurrentCommandConfig[], options: ConcurrentRunnerOptions) => Promise<ConcurrentRunResult>;
@@ -1,23 +0,0 @@
1
- /**
2
- * Public API for the concurrent process runner.
3
- *
4
- * Uses the native Rust addon when available, falling back to
5
- * a pure JavaScript implementation. Integrates flow controllers
6
- * (restart, teardown, timings) around the core runner.
7
- */
8
- import type { ConcurrentCommandInput, ConcurrentRunnerOptions, ConcurrentRunResult } from "./types.d.ts";
9
- /**
10
- * Run commands concurrently with output streaming and process management.
11
- *
12
- * Automatically uses the native Rust addon for performance when available,
13
- * falling back to a pure JavaScript implementation.
14
- *
15
- * Supports flow controllers:
16
- * - `restart`: retry failed commands with configurable delay/backoff
17
- * - `teardown`: run cleanup commands after all processes complete
18
- * - `timings`: print a timing summary table
19
- * @param commands Array of command strings or config objects
20
- * @param options Runner options (maxProcesses, killOthers, restart, teardown, etc.)
21
- * @returns Promise resolving to the run result with close events and success status
22
- */
23
- export declare const runConcurrently: (commands: ConcurrentCommandInput[], options?: ConcurrentRunnerOptions) => Promise<ConcurrentRunResult>;
@@ -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,19 +0,0 @@
1
- /**
2
- * Detects the configured script shell for npm/pnpm/yarn.
3
- *
4
- * Resolution order:
5
- * 1. `npm_config_script_shell` env var (set by npm when running scripts)
6
- * 2. `npm config get script-shell` subprocess (cached after first call)
7
- * 3. Platform default (undefined = let the runner use /bin/sh or cmd.exe)
8
- */
9
- /**
10
- * Detect the npm script-shell configuration.
11
- *
12
- * Returns the shell path if configured, or undefined to use platform defaults.
13
- * The result is cached after the first call.
14
- */
15
- export declare const detectScriptShell: () => string | undefined;
16
- /**
17
- * Reset the cached shell path. Useful for testing.
18
- */
19
- export declare const resetShellCache: () => void;
@@ -1,59 +0,0 @@
1
- /**
2
- * Represents a file access recorded during task execution.
3
- *
4
- * Write-intent accesses (`"write"`) are emitted when a task opens a file
5
- * with `O_WRONLY`/`O_RDWR`/`O_CREAT`/`O_TRUNC` flags (strace) or calls
6
- * `writeFile`/`appendFile`/`unlink`/`rename` (preload script).
7
- * The orchestrator uses the overlap of reads and writes to the same
8
- * workspace path to detect self-modifying tasks and skip caching.
9
- */
10
- export interface FileAccess {
11
- /** The absolute path of the file */
12
- path: string;
13
- /** The type of access */
14
- type: "missing" | "read" | "readdir" | "stat" | "write";
15
- }
16
- /**
17
- * Result of tracking file accesses during a command execution.
18
- */
19
- export interface TrackingResult {
20
- /** All file accesses recorded */
21
- accesses: FileAccess[];
22
- /** The command exit code */
23
- code: number;
24
- /** The command stdout + stderr output */
25
- output: string;
26
- }
27
- /**
28
- * Tracks which files a child process accesses during execution.
29
- *
30
- * Uses `strace` on Linux to intercept syscalls (open, openat, stat, lstat, access, getdents).
31
- * Falls back to no tracking on unsupported platforms.
32
- */
33
- export declare class FileAccessTracker {
34
- #private;
35
- constructor(workspaceRoot: string, excludePatterns?: RegExp[]);
36
- /**
37
- * Returns true if file access tracking is supported on the current platform.
38
- */
39
- isSupported(): boolean;
40
- /**
41
- * Runs a command and tracks all file system accesses.
42
- * On unsupported platforms, runs the command without tracking.
43
- */
44
- track(command: string, options?: {
45
- cwd?: string;
46
- env?: Record<string, string | undefined>;
47
- }): Promise<TrackingResult>;
48
- /**
49
- * Kills all active child processes. Called on abort/signal to prevent orphans.
50
- */
51
- killAll(): void;
52
- }
53
- /**
54
- * Generates a preload script that can be used with NODE_OPTIONS to
55
- * track file accesses in Node.js child processes.
56
- *
57
- * This is an alternative to strace that works cross-platform for Node.js processes.
58
- */
59
- export declare const generatePreloadScript: (outputPath: string) => string;
@@ -1,54 +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
- * Workspace-relative paths that were both read **and** written
18
- * during execution. Populated when the tracker emits
19
- * {@link FileAccess} entries with `"write"` type. The orchestrator
20
- * uses a non-empty value here to skip caching a self-modifying
21
- * task, whose fingerprint would otherwise capture post-write state
22
- * and trigger false cache hits.
23
- */
24
- modifiedInputs?: string[];
25
- }
26
- /**
27
- * Describes why a cache miss occurred.
28
- */
29
- export interface CacheMissReason {
30
- currentHash?: string;
31
- detail: string;
32
- previousHash?: string;
33
- type: "file-changed" | "file-created" | "file-deleted" | "directory-changed" | "env-changed" | "args-changed" | "no-fingerprint";
34
- }
35
- /**
36
- * Manages task fingerprints for auto-detection caching.
37
- *
38
- * Records which files a task accesses during execution, stores content
39
- * hashes, and on subsequent runs checks if any accessed file has changed.
40
- */
41
- export declare class FingerprintManager {
42
- #private;
43
- constructor(workspaceRoot: string);
44
- createFingerprint(accesses: FileAccess[], command: string, args: Record<string, unknown>, envVariables: Record<string, string | undefined>, envPatterns?: string[], untrackedEnvVariables?: string[]): Promise<TaskFingerprint>;
45
- /**
46
- * Validates a stored fingerprint against the current state.
47
- * Returns null if valid (cache hit), or an array of reasons (cache miss).
48
- *
49
- * Does NOT use the file hash cache — validation must see current disk state.
50
- */
51
- validate(fingerprint: TaskFingerprint): Promise<CacheMissReason[] | undefined>;
52
- validateCommand(fingerprint: TaskFingerprint, command: string, args: Record<string, unknown>): CacheMissReason | undefined;
53
- formatMissReasons(reasons: CacheMissReason[]): string;
54
- }
@@ -1,7 +0,0 @@
1
- export type { InputHandlerOptions } from "./input-handler.d.ts";
2
- export { createInputHandler } from "./input-handler.d.ts";
3
- export { formatTimingTable, logTimings } from "./log-timings.d.ts";
4
- export type { RestartOptions } from "./restart-process.d.ts";
5
- export { withRestart } from "./restart-process.d.ts";
6
- export type { TeardownOptions } from "./teardown.d.ts";
7
- export { runTeardown } from "./teardown.d.ts";