# SPDX-License-Identifier: Apache-2.0
# © SuperNovae Studio · nika.sh/library
nika: v1
workflow:
  id: pr-risk-review
# local model · the diff never leaves
model: ollama/llama3.2:3b

# the file IS the blast radius
permits:
  exec: [ git ]
  fs: { write: [ ./review.md ] }
  tools: [ "nika:read", "nika:write" ]

tasks:
  diff:
    exec: { command: [ git, diff, main ] }

  risk:
    with:
      diff: ${{ tasks.diff.output }}
    timeout: "120s"
    infer:
      prompt: "Score this diff's blast radius from 0 to 10: ${{ with.diff }}"
      schema:
        type: object
        required: [ score, reasons ]
        properties:
          score: { type: number }
          reasons: { type: array, items: { type: string } }
      max_tokens: 400

  probe:
    with:
      score: ${{ tasks.risk.output.score }}
      reasons: ${{ tasks.risk.output.reasons }}
    when: ${{ with.score >= 7 }}
    agent:
      prompt: "Trace the risky call paths behind: ${{ with.reasons }}"
      tools: [ "nika:read" ]
      max_turns: 3

  report:
    with:
      review: ${{ tasks.risk.output }}
    invoke:
      tool: "nika:write"
      args: { path: ./review.md, content: "${{ with.review }}" }

outputs:
  review: "${{ tasks.risk.output }}"
