import type { Spine, StepContext } from '../types.js';

const q = (ctx: StepContext) => String(ctx.input.question);
const repoLine = (ctx: StepContext) => (ctx.input.repoPath ? ` Repo: ${String(ctx.input.repoPath)}.` : '');

/** Han `investigate` — root-cause a bug/failure from concrete evidence. */
export const investigate: Spine = {
  name: 'investigate',
  description: 'root-cause a bug/failure from evidence',
  angles: [
    {
      id: 'investigator',
      agent: 'evidence-based-investigator',
      label: 'Investigation (evidence-based-investigator)',
      task: (ctx) =>
        `Investigate the issue below. Gather concrete evidence — file:line, error text, git history, test coverage — and propose the most likely root cause with the evidence chain for it.${repoLine(ctx)}\n\nISSUE: ${q(ctx)}`,
    },
    {
      id: 'edges',
      agent: 'edge-case-explorer',
      label: 'Edge cases & failure modes (edge-case-explorer)',
      minBand: 'medium',
      task: (ctx) =>
        `Catalog the edge cases and failure modes most relevant to the issue below — boundary values, external-input messiness, state-dependent failures, error-propagation gaps.${repoLine(ctx)}\n\nISSUE: ${q(ctx)}`,
    },
  ],
};
