Critical Path Engine
The CriticalPathEngine class is the central orchestrator of Critical Path. It is responsible for business logic validation, state changes, dependency checks, and dispatching events to plugins.
Initialization
import { CriticalPathEngine, SQLiteStore } from '@critical-path/core';
const store = new SQLiteStore({ filename: './prod.db' });const engine = new CriticalPathEngine({ store, plugins: [], // Optional array of CriticalPathPlugin});Core Methods
Project Operations
// Create a projectconst project = await engine.createProject({ name: 'Mobile App V2', key: 'MOB', description: 'Complete overhaul of the mobile client',});
// Retrieve a projectconst found = await engine.getProject(project.id);
// List projectsconst allProjects = await engine.listProjects();
// Update a projectawait engine.updateProject(project.id, { name: 'Mobile App V2 (Beta)',});
// Delete a projectawait engine.deleteProject(project.id);Task Operations
// Create a taskconst task = await engine.createTask({ projectId: project.id, title: 'Implement OAuth Sign-In', description: 'Support Google and GitHub OAuth 2.0 flows', priority: 'high', estimatedHours: 12, status: 'todo', tags: ['auth', 'security'],});
// Update task statusconst updated = await engine.updateTask(task.id, { status: 'in_progress',});
// Filter tasksconst urgentTasks = await engine.listTasks({ projectId: project.id, priority: 'urgent', status: 'in_progress',});Automatic Unblocking
When a task’s status is updated to a completed semantic status (e.g. done), the engine automatically queries all dependent downstream tasks:
// Task B depends on Task A// Marking Task A as 'done' automatically unblocks Task B:await engine.updateTask(taskA.id, { status: 'done' });
// Query blockers for Task Bconst blockers = await engine.getTaskBlockers(taskB.id);console.log(blockers); // [] -> No remaining blockers!