@saflib/workflows
@saflib/workflows
Interfaces
| Interface | Description |
|---|---|
| AgentConfig | When in "run" mode, specify which agent to use. |
| CdStepInput | Input for the CdStepMachine. |
| CommandStepInput | Input for the CommandStepMachine. |
| CopyStepInput | Input for the CopyStepMachine. |
| IndexedWorkspacePackage | - |
| NpmScriptStepInput | Input for the NpmScriptStepMachine. |
| ParsePackageNameInput | Argument for the parsePackageName function. |
| ParsePackageNameOutput | Return value for the parsePackageName function. |
| ParsePathInput | Argument for the parsePath function. |
| ParsePathOutput | Return value for the parsePath function. |
| PromptStepInput | Input for the PromptStepMachine. |
| RunWorkflowOptions | Argument for the runWorkflow function. |
| RunWorkflowResult | Return value of the runWorkflow function. |
| TransformFileStepInput | Input for the TransformFileStepMachine. |
| UpdateStepInput | Input for the UpdateStepMachine. |
| ValidateNpmScriptTargetParams | - |
| ValidateNpmScriptTargetResult | - |
| WorkflowArgument | Required or optional argument for the workflow, in a format the CLI tool (or other program) can use. |
| WorkflowCliOptions | Options for configuring the workflow CLI |
| WorkflowDefinition | An interface that includes everything that makes up a workflow. |
| WorkflowLogger | Logger interface for workflow operations |
| WorkflowLoggerOptions | Options for creating a workflow logger |
Type Aliases
| Type Alias | Description |
|---|---|
| AgentCLI | The agent to use for the workflow. |
| Old name | |
| GetSourceUrlFunction | Function type for getting source URLs from absolute file paths. |
| OffshootInitContext | - |
| OffshootLayer | - |
| WorkflowExecutionMode | The mode to run the workflow in. |
| WorkflowStep | A step in a workflow with an actor and its corresponding input. |
Variables
| Variable | Description |
|---|---|
| CdStepMachine | Updates the current working directory for subsequent steps, such as "copy", "update", and "command". |
| CommandStepMachine | Runs a shell command as part of a workflow. Stops the workflow if the command fails. |
| CopyStepMachine | Copies all templateFiles to the given directory, performing string replacements for directories, file names, and file contents. |
| CwdStepMachine | Old name. Use CdStepMachine instead. @deprecated. |
| DEFAULT_SKIP_SOURCE_GLOBS | Always skipped when expanding directory template sources. |
| NpmScriptStepMachine | Runs npm run <script> -w <workspace> with workspace/script validation in dry, checklist, print, run, and script modes. Delegates execution to the same runner used by CommandStepMachine. |
| PromptStepMachine | Prompts the agent or user to do an arbitrary task. |
| TransformFileStepMachine | Programmatically transforms a file's content. Reads the file, applies the transform function, and writes the result back. Useful for structured edits (JSON, YAML, etc.) that are too mechanical for an agent prompt but need more control than template copying. |
| UpdateStepMachine | Prompts the agent to update one of the templateFiles that was copied over by the CopyStepMachine. |
Functions
| Function | Description |
|---|---|
| buildNpmRunArgs | - |
| checklistToString | Convenience function to convert a checklist to a string. |
| checkPackageDependency | Checks if the cwd's package.json has a given dependency. Throws an error if it does not. |
| defineWorkflow | Helper, identity function to infer types. |
| findOutermostWorkspaceRoot | Walk up from start and return the outermost directory whose package.json declares workspaces. |
| formatNpmScriptCommand | - |
| getPackageName | Reads the package.json for the given cwd and returns the package name. |
| indexWorkspacePackages | Index every named package.json under a monorepo root (skipping vendor dirs). |
| isScriptModeValidationCommand | In script mode, skip agent-loop validation commands. Mechanical steps (install, saf-specs generate, prettier, …) still run; typecheck/test of unfinished scaffolds is asserted separately by CI harnesses when needed. |
| makeLineReplace | Creates a line-replace function which will handle template interpolation, given a context. |
| makeOffshootLineReplace | Remap golden @saflib/base-__offshoot-name__-* / Base* tokens onto the target product + offshoot, then apply __placeholder__ interpolation. |
| makeWorkflowMachine | Takes a WorkflowsDefinition, as well as its Context and Input types, and creates an XState machine. |
| npmScriptToCommandInput | - |
| parentLayerPackageJsonPath | Parent weave host package.json — missing when scaffolding standalone saflib packages. |
| parsePackageName | Takes a package name and returns a breakdown into conventional parts for templating. |
| parsePath | Takes a target path to a file and breaks it down into conventional parts for templating. |
| pollingWaitFor | - |
| resolveOffshootInitContext | Resolve offshoot scaffold paths. |
| runWorkflow | Convenience function to take a WorkflowDefinition, run it in the specified mode, and return the output. Can be used to run a given workflow in checklist mode for a unit test. This is also used internally by the CLI tool. |
| runWorkflowCli | Given a list of workflow classes, runs a CLI for running workflows. |
| shouldSkipSourcePath | - |
| step | Helper function for defining a step in a workflow, enforcing types properly. |
| validateNpmScriptTarget | Validate that an npm workspace and script exist. Throws on invalid targets in dry, checklist, print, run, and script modes (same policy as cd validation). |