Skip to content

Slice 1: flows-from-config foundation — resolveFlows + /pi-flow:run runs the first stage #2

Description

@maikeffi

Parent

#1

What to build

Replace the hardcoded pipeline engine with user-defined flows read from settings.json. A pure resolveFlows(userFlows) turns the top-level pi-flow.flows key in settings.json into a validated flow map: each flow has a description? and an ordered stages[]; each stage resolves to { skill, model?, mode } with defaults applied — missing modeHITL, missing model → no model switch. Invalid shapes (a flow with no stages, a stage with no skill, a mode outside HITL/AFK) are rejected with a clear message.

Add /pi-flow:run <name> [input]. Its argument autocompletes resolved flow names (name + description as autocomplete items). Running a flow creates FlowState { flowId, stageIndex: 0, phase: "running", input, startedAt }, persists it, switches to the first stage's model if one is set, sends a generic kickoff message naming the skill (stage 1's kickoff carries the input), and renders the progress widget. Starting while a flow is active is refused with a "cancel first" notice; an unknown flow name errors.

This slice removes pipelines.ts, the /pi-flow:new-feature|improve-arch|debug commands, and the obsolete /pi-flow:setup (which configured the old design/code model pair). No stage advancement yet — that is the next slice.

Agreed contract:

interface FlowStage { skill: string; model?: string; mode?: "HITL" | "AFK" }
interface FlowDefinition { description?: string; stages: FlowStage[] }
// resolveFlows(userFlows) -> Record<string, FlowDefinition>, mode defaulted to "HITL"

Acceptance criteria

  • resolveFlows applies defaults (missing mode → HITL, missing model → no switch) and returns a flow map keyed by name
  • resolveFlows rejects a flow with zero stages, a stage missing skill, or an invalid mode
  • /pi-flow:run <name> "input" sets state to running at stage 0 with the given input and persists it
  • Running switches to the first stage's model only when the stage specifies one
  • Running sends a kickoff message that names the stage's skill and includes the input
  • The run argument autocompletes with resolved flow names and descriptions
  • An unknown flow name notifies an error; starting while a flow is active notifies "cancel first"
  • pipelines.ts and the new-feature/improve-arch/debug/setup commands are removed
  • Behavior is covered through the existing pure-function and fake-ExtensionAPI seams

Blocked by

None - can start immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentPRD/issue ready to be picked up by an implementation agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions