#!/usr/bin/env python3
"""Create a reviewable AI task card locally. No network access or signup."""

from __future__ import annotations

import argparse
from datetime import date


def build_card(task: str, artifact: str, frequency: str, review: str, stability: str) -> str:
    stop = (
        "STOP: keep this manual until a reviewer and stable input are defined."
        if review.lower().startswith("no") or stability.lower() == "unknown"
        else "STOP: keep the old process if the input changes, the reviewer cannot check it, or the artifact fails the acceptance test."
    )
    return f"""AI TASK CARD
Generated: {date.today().isoformat()}

TASK
{task}

TRIGGER
Start when this task appears {frequency.lower()}.

INPUTS
- One agreed input type
- The source material needed for the artifact
- A clear privacy boundary: do not paste secrets or personal data

FINISHED ARTIFACT
{artifact}

REVIEW GATE
{review}. Check factual accuracy, required context, permissions, and the final recipient before use.

PILOT
Run one input at a time. Keep the old process as fallback. Record pass/fail and the reason.

STOP RULE
{stop}

BOUNDARY
This card is a planning aid, not proof of savings, safety, revenue, or ROI.
"""


def main() -> None:
    parser = argparse.ArgumentParser(description="Create a reviewable AI task card locally.")
    parser.add_argument("--task", required=True)
    parser.add_argument("--artifact", required=True)
    parser.add_argument("--frequency", default="2–4 times a week")
    parser.add_argument("--review", default="A person can review it")
    parser.add_argument("--stability", default="some", choices=["stable", "some", "unknown"])
    args = parser.parse_args()
    print(build_card(args.task.strip(), args.artifact.strip(), args.frequency.strip(), args.review.strip(), args.stability))


if __name__ == "__main__":
    main()
