/**
 * Han authoring/reporting skills as best-effort ONE-PASS flows. Each drafts an
 * artifact (an ADR, a standard, a runbook, a test scaffold, a summary) and runs
 * the adversarial-validator gate over it. Han intends some of these to be
 * interactive; unattended they produce a first draft.
 */
import type { Spine } from '../types.js';
import { q, repoLine } from './_util.js';

export const adr: Spine = {
  name: 'adr',
  description: 'architecture decision record draft (one-pass)',
  contracts: ['evidence', 'yagni'],
  angles: [
    {
      id: 'architect',
      agent: 'system-architect',
      label: 'ADR draft (system-architect)',
      task: (ctx) =>
        `Draft an Architecture Decision Record for the decision below — Context, the Decision, the Options considered with trade-offs, Consequences (positive and negative), and the status. Ground it in the real constraints; mark anything assumed.${repoLine(ctx)}\n\nDECISION: ${q(ctx)}`,
    },
  ],
};

export const codingStandard: Spine = {
  name: 'coding-standard',
  description: 'coding standard draft (one-pass)',
  contracts: ['evidence', 'yagni'],
  angles: [
    {
      id: 'author',
      agent: 'software-architect',
      label: 'Standard draft (software-architect)',
      task: (ctx) =>
        `Draft a coding standard for the topic below — the rule stated imperatively, the rationale (the failure it prevents), a correct and an incorrect example, and its scope of application. Keep it enforceable and specific.${repoLine(ctx)}\n\nTOPIC: ${q(ctx)}`,
    },
  ],
};

export const runbook: Spine = {
  name: 'runbook',
  description: 'operational runbook draft (one-pass)',
  contracts: ['evidence', 'yagni'],
  angles: [
    {
      id: 'devops',
      agent: 'devops-engineer',
      label: 'Runbook draft (devops-engineer)',
      task: (ctx) =>
        `Draft an operational runbook for the scenario below — detection signals, immediate mitigation steps, diagnosis path, rollback/recovery, and escalation. Concrete commands/locations where known.${repoLine(ctx)}\n\nSCENARIO: ${q(ctx)}`,
    },
    {
      id: 'oncall',
      agent: 'on-call-engineer',
      label: 'Failure-mode review (on-call-engineer)',
      minBand: 'medium',
      task: (ctx) =>
        `List the failure modes the runbook for the scenario below must cover, and the earliest signal for each.\n\nSCENARIO: ${q(ctx)}`,
    },
  ],
};

export const tdd: Spine = {
  name: 'tdd',
  description: 'failing-test scaffold + plan (one-pass; not the full red-green loop)',
  contracts: ['evidence', 'yagni'],
  angles: [
    {
      id: 'tests',
      agent: 'test-engineer',
      label: 'Red tests + plan (test-engineer)',
      task: (ctx) =>
        `For the behaviour below, write the failing ("red") tests that specify it — observable inputs/outputs and collaborator interactions — and outline the smallest implementation that would make them pass. Note: this is a single pass, not the interactive red-green-refactor loop.${repoLine(ctx)}\n\nBEHAVIOUR: ${q(ctx)}`,
    },
  ],
};

export const stakeholderSummary: Spine = {
  name: 'stakeholder-summary',
  description: 'plain-language stakeholder summary (Han reporting)',
  angles: [
    {
      id: 'summary',
      agent: 'project-manager',
      label: 'Stakeholder summary (project-manager)',
      task: (ctx) =>
        `Write a plain-language summary of the feature/work below for a non-technical stakeholder — what it is, why it matters, what changes for users, and the rough shape of the effort. No jargon, no implementation detail.${repoLine(ctx)}\n\nSUBJECT: ${q(ctx)}`,
    },
  ],
};
