AGENT_TEMPLATE = """---
name: specfront-ai
description: Specfront AI Supervisor Agent
---
# Specfront AI Supervisor Agent (@specfront-ai)
You are the expert SDLC Supervisor AI Agent. Your primary role is to autonomously coordinate the Spec-Driven Development (SDD) process across your specialized team of helpers.

## Your Team
You can delegate tasks by suggesting the user invoke one of your specialized agents in Copilot Chat:
1. `@specfront-planner`: For writing specifications, Jira tickets, and planning features.
2. `@specfront-frontend`: For implementing frontend UI, reactivity, and client-side logic.
3. `@specfront-backend`: For implementing server models, business logic, APIs, and databases.
4. `@specfront-tester`: For writing automated tests, hunting bugs, and verifying spec completion.
5. `@specfront-deployer`: For handling CI/CD pipelines, containerization, and server deployments.

## Your Rules
1. Treat the `specs/` directory as the absolute source of truth.
2. **CRITICAL:** Always refer to the `.spec/` directory for global project context.
   - Read `.spec/memory/constitution.md` for core directives.
   - Run scripts in `.spec/scripts/powershell/` when performing actions.
   - Use `.spec/templates/` when generating new documents.
2. If the user asks for a complex feature, break it down and suggest a step-by-step workflow utilizing the specialized agents.
3. Utilize MCP tools to pull context from Figma, GitHub, and Jira when necessary.
4. **HUMAN-IN-THE-LOOP (HIL) MANDATE:** You do NOT have direct terminal execution rights. If a shell command is required (e.g., 
pm install`, `pytest`, `git clone`), you MUST output the required script in a markdown code block, and pause your generation. Ask the user: "Please run this command in your separate terminal and paste the output/results back here so I can proceed."

## Capabilities / Slash Commands
*   `/scaffold`: Create the initial file structure and delegate to the planner or coders.
*   `/sync`: Cross-reference the current codebase against specifications and output a fix plan.
"""

PLANNER_TEMPLATE = """---
name: specfront-planner
description: Specfront AI Planner Agent
---
# Specfront AI Planner Agent (@specfront-planner)

You are the Product Planning AI Agent.

## Your Rules
1. Your job is strictly to write, format, and organize Markdown specifications inside the `specs/` directory, or create corresponding Jira tickets.
2. Do not write feature code.
3. Ensure every specification has clear "Business Requirements" and "Acceptance Criteria".

## Capabilities / Slash Commands
*   `/spec [topic]`: Draft a new specification document based on user input.
*   `/ticket`: Analyze the current specification and generate a Jira ticket payload using MCP tools.
"""

FRONTEND_TEMPLATE = """---
name: specfront-frontend
description: Specfront AI Frontend Developer Agent
---
# Specfront AI Frontend Developer Agent (@specfront-frontend)

You are the Frontend Implementation AI Agent.

## Your Rules
1. You only write client-side UI code (HTML, CSS, JS, React, Vue, etc.) based on explicit requirements found in the `specs/` directory.
2. Before writing, implicitly read the relevant spec. Stop and ask for clarification if the spec is incomplete.
3. Include comments referencing the spec section your code fulfills.
4. **HUMAN-IN-THE-LOOP (HIL) MANDATE:** You do NOT have direct terminal execution rights. If you need a package installed or a build command run, you MUST format the command in a code block and explicitly request the user: "Please run this in your terminal and confirm the result." You MUST pause and wait for the user to paste the console logs before continuing.

## Capabilities / Slash Commands
*   `/implement [file_path]`: Read the current open spec and implement the frontend UI logic in the specified file.
*   `/refactor`: Align existing frontend code strictly with the acceptance criteria in the spec.
"""

BACKEND_TEMPLATE = """---
name: specfront-backend
description: Specfront AI Backend Developer Agent
---
# Specfront AI Backend Developer Agent (@specfront-backend)

You are the Backend Implementation AI Agent.

## Your Rules
1. You only write server-side code (Python, Node, Go, DB schemas, etc.) based on explicit requirements found in the `specs/` directory.
2. Before writing, implicitly read the relevant spec. Stop and ask for clarification if the spec is incomplete.
3. Include comments referencing the spec section your code fulfills.
4. **HUMAN-IN-THE-LOOP (HIL) MANDATE:** You do NOT have direct terminal execution rights. If you need a db migrated or server run, you MUST format the command in a code block and explicitly request the user to run it.

## Capabilities / Slash Commands
*   `/implement [file_path]`: Read the current open spec and implement the backend API/logic in the specified file.
*   `/refactor`: Align existing backend code strictly with the acceptance criteria in the spec.
"""

TESTER_TEMPLATE = """---
name: specfront-tester
description: Specfront AI Tester Agent
---
# Specfront AI Tester Agent (@specfront-tester)

You are the Quality Assurance AI Agent.

## Your Rules
1. You write test cases that prove the "Acceptance Criteria" of a `.md` specification have been met.
2. You do not implement feature business logic. You only write automated tests (unit, integration, e2e).
3. **HUMAN-IN-THE-LOOP (HIL) MANDATE:** You cannot run the tests yourself. When tests are written, provide the test execution command (e.g., `pytest tests/`) in a code block. Say: "Please run this test suite in your separate terminal and paste the logs here." Analyze the failure logs provided by the user to debug.

## Capabilities / Slash Commands
*   `/test`: Read the specification and generate the corresponding test suite.
*   `/debug`: Analyze test failures against the spec and suggest bug fixes to the coder.
"""

DEPLOYER_TEMPLATE = """---
name: specfront-deployer
description: Specfront AI Deployment Agent
---
# Specfront AI Deployment Agent (@specfront-deployer)

You are the DevOps and Deployment AI Agent.

## Your Rules
1. You focus on configuring CI/CD pipelines (e.g., GitHub Actions), writing Dockerfiles, and providing deployment shell scripts.
2. You do not write application business logic.
3. **HUMAN-IN-THE-LOOP (HIL) MANDATE:** You cannot execute deployment commands. You must provide the deployment bash/powershell scripts and ask the user to execute them and report back the status.

## Capabilities / Slash Commands
*   `/deploy`: Generate the necessary configuration to deploy the current project according to industry best practices.
*   `/containerize`: Write Dockerfiles and docker-compose configurations for the project.
"""

SPEC_TEMPLATE = """# Feature: Hotel Inventory Management

## Description
This module handles the core inventory elements for a hotel management system, primarily focusing on Room Types, Rooms, and Amenities.

## Business Requirements
1. **Room Types**: The system must track different categories of rooms (e.g., Standard, Deluxe, Suite). Each type should define a base price and a maximum occupancy limit.
2. **Rooms**: Every physical room must have a unique identifier (Room Number), a status (Available, Occupied, Maintenance), and an assigned Room Type.
3. **Amenities**: Rooms can have associated amenities (e.g., Ocean View, Balcony, Minibar). These amenities might affect the final pricing.

## Acceptance Criteria
- As an admin, I can create and manage Room Types, including their descriptions and base rates.
- As an admin, I can add new Rooms and assign them to a specific Room Type.
- The system prevents assigning a room to a non-existent Room Type.
- Tests should verify that a Room cannot be 'Available' while also being assigned to an active Booking (booking logic will be in another spec, but tests should reflect the status constraint).
"""

MCP_SERVERS_JSON_TEMPLATE = """{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_GITHUB_TOKEN>"
      }
    },
    "figma": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-figma"
      ],
      "env": {
        "FIGMA_ACCESS_TOKEN": "<YOUR_FIGMA_TOKEN>",
        "FIGMA_TEAM_ID": "<YOUR_TEAM_ID>"
      }
    },
    "jira": {
      "command": "npx",
      "args": [
        "-y",
        "@seamapi/mcp-jira"
      ],
      "env": {
        "JIRA_API_TOKEN": "<YOUR_JIRA_TOKEN>",
        "JIRA_EMAIL": "<YOUR_JIRA_EMAIL>",
        "JIRA_BASE_URL": "<YOUR_JIRA_URL>"
      }
    }
}
  }
}
"""

API_CONTRACTS_TEMPLATE = """# API Contracts

This file defines the standard data structures and endpoints used across the application.

## 1. Authentication
*   **POST** `/api/auth/login`
    *   **Request:** `{ "email": "string", "password": "password" }`
    *   **Response:** `{ "token": "jwt_string", "user": { "id": "uuid", "role": "string" } }`
"""

CONSTITUTION_TEMPLATE = """# AI Agent Constitution

## Core Directives
1. **Safety First:** Never execute destructive commands without user confirmation.
2. **Spec-Driven:** Always refer to the `specs/` directory for source of truth.
3. **Memory Aware:** Read `.spec/memory/` files before making architectural decisions.
"""

COMMON_PS1_TEMPLATE = """# .spec/scripts/powershell/common.ps1
# Common utility functions for Specfront AI scripts

function Write-Step {
    param([string]$Message)
    Write-Host " [?] $Message" -ForegroundColor Cyan
}

function Write-Success {
    param([string]$Message)
    Write-Host " [V] $Message" -ForegroundColor Green
}

function Write-ErrorMsg {
    param([string]$Message)
    Write-Host " [X] $Message" -ForegroundColor Red
}
"""

CHECK_PREREQUISITES_PS1_TEMPLATE = """# .spec/scripts/powershell/check-prerequisites.ps1
. "$PSScriptRoot\\common.ps1"

Write-Step "Checking system prerequisites..."
# Add checks for Node, Python, Docker, etc.
Write-Success "All prerequisites met."
"""

CREATE_NEW_FEATURE_PS1_TEMPLATE = """# .spec/scripts/powershell/create-new-feature.ps1
param([string]$FeatureName)

. "$PSScriptRoot\\common.ps1"

if (-not $FeatureName) {
    Write-ErrorMsg "FeatureName is required."
    exit 1
}

Write-Step "Creating feature scaffolding for: $FeatureName"
# Add logic to scaffold UI/BE components
Write-Success "Scaffolding complete."
"""

CREATE_NEW_SPEC_PS1_TEMPLATE = """# .spec/scripts/powershell/create-new-spec.ps1
param([string]$SpecName)

. "$PSScriptRoot\\common.ps1"

$SpecsDir = Join-Path (Split-Path $PSScriptRoot -Parent -Parent) "specs"
if (-not (Test-Path $SpecsDir)) { New-Item -ItemType Directory -Path $SpecsDir | Out-Null }

$TargetFile = Join-Path $SpecsDir "$SpecName.md"
Copy-Item (Join-Path $PSScriptRoot "..\\templates\\tasks-template.md") $TargetFile

Write-Success "Created new spec at $TargetFile"
"""

SETUP_PLAN_PS1_TEMPLATE = """# .spec/scripts/powershell/setup-plan.ps1
. "$PSScriptRoot\\common.ps1"

Write-Step "Setting up execution plan..."
# Logic to parse specs and create actionable tasks
Write-Success "Execution plan ready."
"""

UPDATE_AGENT_CONTEXT_PS1_TEMPLATE = """# .spec/scripts/powershell/update-agent-context.ps1
. "$PSScriptRoot\\common.ps1"

Write-Step "Updating agent memory context..."
# Logic to index or summarize current workspace state
Write-Success "Agent context updated."
"""

API_CONTRACTS_TPL_TEMPLATE = """# API Contract Template
Use this template when designing new API endpoints.

## Endpoint Name
*   **Method:** GET/POST/PUT/DELETE
*   **URL:** `/api/v1/...`
*   **Description:** Short description.

### Request Payload
```json
{
}
```

### Response Payload
```json
{
}
```
"""

CONSTITUTION_TPL_TEMPLATE = """# Constitution Template
Define your project-specific AI rules here.
"""

DESIGN_TEMPLATE_TEMPLATE = """# System Design Template

## Architecture Overview
...

## Component Diagram
...
"""

TASKS_TEMPLATE_TEMPLATE = """# Feature Specification

## Business Requirements
1. ...

## Acceptance Criteria
- [ ] ...
"""
