# SPDX-License-Identifier: Apache-2.0
# © SuperNovae Studio · nika.sh/library
nika: v1
workflow:
  id: price-watch
# zero model · two tools and one CEL compare

# the file IS the blast radius
permits:
  fs: { read: [ ./price.json ], write: [ ./price-alert.md ] }
  tools: [ "nika:read", "nika:jq", "nika:write" ]

vars:
  alert_below: 899  # your threshold · plain data

tasks:
  snapshot:
    invoke: { tool: "nika:read", args: { path: ./price.json } }

  price:
    with:
      snapshot: ${{ tasks.snapshot.output }}
    invoke:
      tool: "nika:jq"
      args: { input: "${{ with.snapshot }}", expression: "fromjson | .price" }

  alert:
    with:
      price: ${{ tasks.price.output }}
    when: ${{ with.price < vars.alert_below }}
    invoke:
      tool: "nika:write"
      args:
        path: ./price-alert.md
        content: "Price drop: now ${{ with.price }} (target ${{ vars.alert_below }})"

outputs:
  price: "${{ tasks.price.output }}"
