Skip to main content

PhaseRegistry Component

The <PhaseRegistryProvider> manages sequential phase execution automatically via SQLite state, eliminating manual phase tracking.

Basic Usage

import { PhaseRegistryProvider, Phase, Step, usePhaseRegistry } from "smithers-orchestrator";

function Workflow() {
  return (
    <PhaseRegistryProvider>
      <Phase name="Research">
        <Step name="research">
          <Claude>Research the codebase.</Claude>
        </Step>
      </Phase>
      <Phase name="Implement">
        <Step name="implement">
          <Claude>Implement the feature.</Claude>
        </Step>
      </Phase>
      <Phase name="Test">
        <Step name="test">
          <Claude>Run tests.</Claude>
        </Step>
      </Phase>
    </PhaseRegistryProvider>
  );
}

Hooks

usePhaseRegistry

Access the phase registry context:
function PhaseController() {
  const { 
    currentPhaseIndex,
    advancePhase,
    isPhaseActive,
    isPhaseCompleted,
    totalPhases 
  } = usePhaseRegistry();

  return (
    <Claude onFinished={() => advancePhase()}>
      Complete current phase work.
    </Claude>
  );
}

usePhaseIndex

Get a phase’s index during registration:
function MyPhase({ name, children }) {
  const index = usePhaseIndex(name);
  const { isPhaseActive } = usePhaseRegistry();

  if (!isPhaseActive(index)) return null;
  return <>{children}</>;
}

Context Value

PropertyTypeDescription
registerPhase(name: string) => numberRegister phase, returns index
currentPhaseIndexnumberActive phase index (from SQLite)
advancePhase() => voidMove to next phase
isPhaseActive(index: number) => booleanCheck if phase is active
isPhaseCompleted(index: number) => booleanCheck if phase completed
totalPhasesnumberTotal registered phases

Resume Support

Phase state persists in SQLite, enabling workflow resume:
// State survives restarts - workflow resumes at correct phase
const existing = db.state.get<number>('currentPhaseIndex');
// Returns last active phase index