API Reference
Full API reference for all exported functions and types
API Reference
Task Runner
defaultTaskRunner(tasks, options, context)
The main entry point. Returns Promise<TaskResults>.
Task Graph
createTaskGraph(tasks, options)
Creates a dependency-ordered task graph from task definitions. options is a CreateTaskGraphOptions object with projectGraph, targetDefaults?, and workspace.
getTaskId(target)
Creates a task ID string from a TaskTarget object ("project:target:configuration").
parseTaskId(id)
Parses a task ID into { project, target, configuration? }.
Graph Utilities
findCycle(graph)- Returns first cycle found, or undefinedfindCycles(graph)- Returns all cyclesmakeAcyclic(graph)- Removes cycle-forming edgeswalkTaskGraph(graph, fn)- Walk in topological ordergetDependentTasks(graph, taskId)- Find all tasks depending on a taskgetTransitiveDependencies(graph, taskId)- Find all transitive depsgetLeafTasks(graph)- Find tasks with no dependenciesreverseTaskGraph(graph)- Reverse edge directions
Hashing
InProcessTaskHasher
Computes task hashes from explicit input declarations.
const hasher = new InProcessTaskHasher({
workspaceRoot,
projects,
namedInputs,
targetDefaults,
envVars,
globalInputs,
globalEnv,
smartLockfileHashing,
frameworkInference,
});
const details = await hasher.hashTask(task);computeTaskHash(hashDetails)
Computes a final SHA-256 hash from TaskHashDetails.
IncrementalFileHasher
mtime-based file hasher that only re-hashes changed files.
const hasher = new IncrementalFileHasher({
workspaceRoot,
snapshotPath: "node_modules/.cache/task-runner/file-snapshot.json", // default
});
const hashes = await hasher.hashDirectory("packages/my-app/src");Cache
Cache
Local file-based cache with LRU eviction.
get(hash)- Retrieve cached resultput(hash, output, outputs, code, fingerprint?)- Store resultrestoreOutputs(hash, outputs)- Restore build artifactsclear()- Clear entire cache
RemoteCache
Turborepo-compatible HTTP cache client.
retrieve(hash, localCacheDirectory)- Download from remotestore(hash, localCacheDirectory)- Upload to remote
Lockfile
LockfileHasher
Smart lockfile parser that hashes per-package dependency versions.
hashForPackage(packageJsonPath)- ReturnsPackageLockfileHash | undefinedlockfileType- Detected format ("npm" | "pnpm" | "yarn" | undefined)
Lockfile Parsers
parseNpmLockfile(content)- Parse package-lock.jsonparsePnpmLockfile(content)- Parse pnpm-lock.yamlparseYarnLockfile(content)- Parse yarn.lock
Framework Inference
detectFrameworks(packageJsonPath)- Returns detected frameworksinferFrameworkEnvPatterns(workspaceRoot, projects)- Returns env patternsgetFrameworkEnvVariables(packageJsonPath, env?)- Returns matching env vars
Affected Detection
getChangedFiles(workspaceRoot, base, head)- Git diff to get changed file pathsgetAffectedProjects(options)- Detect affected projects from git changes (AffectedOptions)filterAffectedTasks(taskIds, affectedProjects)- Filter task IDs by affected project set
Visualization
toGraphvizDot(graph, options?)- DOT formattoGraphJson(graph, options?)- JSON formattoGraphHtml(graph, options?)- Self-contained HTMLtoGraphAscii(graph, options?)- ASCII treeprojectGraphToDot(projectGraph)- Project graph DOT
Run Summary
generateRunSummary(results, taskGraph, startTime)- Create summarywriteRunSummary(summary, workspaceRoot)- Write to disk
Lifecycle
ConsoleLifeCycle- Logs events to consoleEmptyLifeCycle- No-op implementationCompositeLifeCycle- Combines multiple lifecycles
Types
Key interfaces: Task, TaskGraph, TaskResult, TaskRunnerOptions, TaskRunnerContext, ProjectGraph, ProjectConfiguration, TargetConfiguration, TaskHashDetails, InputDefinition, TaskFingerprint, CacheMissReason, RunSummary, DetectedFramework.