version: 1
id: work
command: work
description: 'Jira or brief → plan → worktree → TDD → review → PR/MR.'
start: intake
maxStepVisits: 10
summaryMaxChars: 30000
steps:
  intake:
    title: Pull Jira or normalize the brief
    prompt: { file: steps/work/intake.md }
    agent: scout
    maxToolCalls: 10
    permissions:
      tools: [read, ls, bash, mcp]
      bash: { mode: unrestricted }
    transitions: { ready: plan, blocked: $pause, handoff: intake }
  plan:
    title: Plan work for Plannotator
    prompt: { file: steps/work/plan.md }
    agent: planner
    maxToolCalls: 60
    permissions:
      tools: [read, ls, bash, mcp]
      bash: { mode: unrestricted }
    gate:
      artifactContract:
        maxChars: 10000
        requiredHeadings:
          - {
              level: 2,
              title: Goal/Acceptance Criteria,
              guidance: Observable outcome and acceptance criteria.,
            }
          - { level: 2, title: Non Goal, guidance: Explicitly excluded work. }
          - {
              level: 2,
              title: Implementation Steps and Tests,
              guidance: Scoped changes and assessable tests list as steps in TDD style.,
            }
          - {
              level: 2,
              title: Validation,
              guidance: Independent commands and expected proof.,
            }
          - {
              level: 2,
              title: Risks/Decisions Needed,
              guidance: Risks and unresolved decisions.,
            }
          - {
              level: 2,
              title: Publications Contract/Metadata,
              guidance: Observed publication metadata.,
            }
          - {
              level: 2,
              title: Execution appendix (machine-readable),
              guidance: Required execution JSON.,
            }
    transitions: { ready: prepare-workspace, blocked: $pause, handoff: plan }
  prepare-workspace:
    title: Create worktree and branch
    prompt: { file: steps/work/prepare-workspace.md }
    agent: scout
    maxToolCalls: 10
    workspace:
      bindOn: [ready]
      allowedRoots: [~/repositories/worktrees]
    permissions:
      tools: [read, ls, bash]
      bash: { mode: unrestricted }
    transitions:
      {
        ready: implement,
        gaps: plan,
        blocked: $pause,
        handoff: prepare-workspace,
      }
  implement:
    title: Implement approved plan with TDD
    prompt: { file: steps/work/implement.md }
    agent: worker
    maxToolCalls: 60
    permissions:
      tools: [read, ls, bash, edit, write, mcp]
      bash: { mode: unrestricted }
    transitions: { ready: verify, blocked: $pause, handoff: implement }
  verify:
    title: Check goal and acceptance criteria
    prompt: { file: steps/work/verify.md }
    agent: reviewer
    maxToolCalls: 60
    permissions:
      tools: [read, ls, bash]
      bash: { mode: unrestricted }
    transitions:
      { ready: publish, gaps: implement, blocked: $pause, handoff: verify }
  publish:
    title: Push and open or update PR/MR
    prompt: { file: steps/work/publish-remote.md }
    agent: scout
    maxToolCalls: 10
    permissions:
      tools: [read, ls, bash, mcp]
      bash: { mode: unrestricted }
    transitions: { ready: $done, blocked: $pause, handoff: publish }
