"use strict";

function withColors(enabled = true) {
  if (!enabled) {
    return {
      reset: "",
      bold: "",
      cyan: "",
      dim: "",
    };
  }

  return {
    reset: "\x1b[0m",
    bold: "\x1b[1m",
    cyan: "\x1b[36m",
    dim: "\x1b[2m",
  };
}

function formatNextSteps({ version, includeFallbackHint = false, colors = true }) {
  const C = withColors(colors);
  const b = (text) => `${C.bold}${text}${C.reset}`;
  const d = (text) => `${C.dim}${text}${C.reset}`;
  const c = (text) => `${C.cyan}${text}${C.reset}`;

  const fallback = includeFallbackHint
    ? `
${d("  Tip: npm sometimes suppresses postinstall output for global packages.")}
${d("       If you missed these instructions, run qa-stlc in your project.")}
${d("       Or reinstall with: npm install -g --foreground-scripts @qa-gentic/stlc-agents")}`
    : "";

  return `
${b("QA STLC Agents")} v${version}

${b("Next steps")} — run these inside your project root:

  ${b("1.")} Bootstrap your project for the coding agent you use:

     ${c("qa-stlc init --vscode --integration ado")}   ${d("# VS Code / GitHub Copilot — Azure DevOps")}
     ${c("qa-stlc init --vscode --integration jira")}  ${d("# VS Code / GitHub Copilot — Jira Cloud")}
     ${c("qa-stlc init --vscode --integration both")}  ${d("# VS Code / GitHub Copilot — ADO + Jira")}
     ${c("qa-stlc init --integration ado")}            ${d("# Claude Code — Azure DevOps")}
     ${c("qa-stlc init --integration jira")}           ${d("# Claude Code — Jira Cloud")}
     ${c("qa-stlc init --integration both")}           ${d("# Claude Code — ADO + Jira")}

     ${d("This installs skills, writes MCP config, and stores your integration preference.")}

  ${b("2.")} Scaffold a new Playwright + Cucumber + TypeScript QA project when needed:

     ${c("qa-stlc scaffold --name my-qa-project")}

  ${b("3.")} Start Playwright MCP in a separate terminal before live generation workflows:

     ${c("npx @playwright/mcp@latest --port 8931")}

  Run ${b("qa-stlc --help")} for the full command reference.

${d("Docs: https://github.com/qa-gentic/stlc-agents")}${fallback}
`;
}

function quickStartHelpText() {
  return `
Quick Start (run once in your project root):
  $ qa-stlc init --vscode --integration ado    GitHub Copilot / VS Code + Azure DevOps
  $ qa-stlc init --vscode --integration jira   GitHub Copilot / VS Code + Jira Cloud
  $ qa-stlc init --integration ado             Claude Code + Azure DevOps
  $ qa-stlc init --integration jira            Claude Code + Jira Cloud
  $ qa-stlc init --integration both            Any client + ADO + Jira

Then scaffold a new QA project:
  $ qa-stlc scaffold --name my-qa-project

Start Playwright MCP in a separate terminal:
  $ npx @playwright/mcp@latest --port 8931
`;
}

module.exports = {
  formatNextSteps,
  quickStartHelpText,
};