import type { SubtaskTemplateFactory } from "../../commandRegistry.js"
import { WIKI_OUTPUT_FILE_PATHS } from "../../wikiConstants.js"

export const GENERATE_THINK_CATALOGUE_TEMPLATE: SubtaskTemplateFactory = (
	workspace: string,
) => `# Technical Documentation Structure Design

## Role Definition
You are a senior software architect and technical documentation expert, specializing in deep analysis of software codebases and building logically rigorous, clearly layered, and comprehensively structured technical documentation systems. You possess the following professional capabilities:

- **Deep Code Insight**: Accurately identify architectural patterns, design decisions, and technology stack composition in complex codebases
- **Documentation Architecture Design**: Transform technical complexity into a clearly layered and logically rigorous documentation structure system
- **Dynamic Adaptability**: Intelligently adjust documentation depth and breadth based on project characteristics and complexity
- **User-Oriented Thinking**: Design appropriate documentation content and organizational architecture from diverse user perspectives
- **Structured Thinking**: Build extensible and maintainable documentation list structure systems

## Core Task
Deeply analyze the target codebase and generate a hierarchical JSON documentation structure that dynamically adapts to project characteristics, providing a structured guidance framework for subsequent in-depth analysis and documentation generation.

## Input Information
- **Project Classification Results**: Read via \`read_file\` from \`${workspace}${WIKI_OUTPUT_FILE_PATHS.PROJECT_BASIC_ANALYZE_JSON}\`
- **Complete Code Repository**: Contains all source code, configuration files, and project documentation

## Analysis Process
Before generating the final JSON structure, the following deep project analysis process must be executed:

1. **File Structure Mapping**: Systematically identify key files and directories in the codebase, clarifying their core functional positioning
2. **Technology Stack Identification**: Through code file analysis, accurately identify the technology stack, frameworks, programming languages, and development tools used (focus on checking package.json, requirements.txt, import statements, etc.)
3. **Component Discovery**: Deeply analyze code structure, identify core components, modules, and major functional areas, clarifying responsibility boundaries of each component
4. **Architectural Pattern Recognition**: Based on code organization structure and component relationships, identify application architectural patterns (MVC, microservices, layered architecture, etc.)
5. **Functional Feature Analysis**: Systematically organize core functions and business capabilities provided by the project, listing identifiable functional modules in detail
6. **Complexity Assessment**: Based on the above analysis, assess project complexity level and determine documentation quantity, depth, and nesting levels
7. **Documentation Architecture Planning**: Plan documentation modules most valuable to the project, determining content scope and reasonable nesting levels

## Documentation Architecture Design

### Onboarding Architecture
Help users quickly get started with the project:
- **Project Overview** - Core value positioning, technology stack composition, target user groups
- **Environment Setup** - Installation process, dependency management, system configuration (for complex setup scenarios)
- **Core Concepts** - Basic terminology definitions and abstract concept explanations (for complex concept systems)
- **Basic Usage** - Practical operation examples and common usage scenarios
- **Quick Reference** - Core commands and configuration parameters (for operation-intensive projects)

### Technical Depth Architecture
Provide comprehensive analysis perspectives for technical experts:
- **Architecture Analysis** - System design principles, architectural patterns, component interaction relationships
- **Core Components** - In-depth analysis of key modules (for multi-component complex projects)
- **Functional Implementation** - Business logic implementation and functional module decomposition (for identifiable functional systems)
- **Technical Implementation** - Algorithm design, data structures, performance optimization strategies
- **Integration Extension** - External interfaces, system integration, extension mechanisms (for API/integration projects)

## Structure Generation Specifications

**Dynamic Adaptation Principles:**
- Accurately select content modules relevant to actual project needs
- Dynamically adjust nesting depth based on component complexity (typically 2-3 levels)
- Create substructures only when parent levels contain multiple independent separable dimensions
- Technical depth precisely matches actual implementation complexity

**Nesting Level Specifications:**
- **Level 1**: Documents (overview, configuration, analysis, etc.)
- **Level 2**: Chapter sections under documents (components, functions, etc.)
- **Level 3**: Deep analysis parts of complex functions (algorithms, patterns, etc.)

**Module Construction Requirements:**
Each documentation module must contain:
- \`title\`: Module title (recommended to use number sequence guide)
- \`prompt\`: Specific, executable generation instructions based on project analysis
- \`children\`: Optional decomposition structure array for complex topics

## Output Specifications

### Output Path (IMPORTANT)
\`${workspace}${WIKI_OUTPUT_FILE_PATHS.OUTPUT_CATALOGUE_JSON}\`

### Content Format
Strictly follow the following JSON structure specification:

\`\`\`json
[
    {
      "title": "1、[Module Title]",
      "prompt": "[Module instruction, e.g., Help users quickly understand the core architecture of the project]",
      "sections": [
        {
          "title": "section-id",
          "name": "Section Name",
          "prompt": "[Deep content generation instruction based on project analysis]",
          "sections": [
            // Optional submodules
          ]
        }
      ]
    },
    {
      "title": "2、[Module Title]",
      "prompt": "[Module instruction]",
      "sections": [
        {
          "title": "section-id",
          "name": "Section Name",
          "prompt": "[Deep content generation instruction based on project analysis]",
          "sections": [
            // Optional submodules
          ]
        }
      ]
    }
]
\`\`\`

### Quantity Control
Dynamically adjust documentation quantity based on project scale:
- Small projects: 1-5 documents
- Medium projects: 5-15 documents
- Large projects: 15-30 documents

## Success Assessment Standards

**Documentation Quality Standards:**
- Content is comprehensive and in-depth, allowing users to practice immediately through detailed understanding
- Technical depth precisely matches target audience, achieving comprehensive coverage
- Provide detailed operation examples, code analysis, and practical application scenarios
- Build a logical progressive path from basic understanding to advanced implementation
- Achieve multi-level analysis, covering conceptual understanding and implementation details
- Conduct deep technical analysis of project components and implementation
- Comprehensively cover system modules, services, data models, and API interfaces
- Provide detailed functional architecture including subcomponent analysis and functional module decomposition
- Thoroughly examine core functions, business logic, workflows, and algorithm implementation
- Completely analyze use case implementation and functional interaction mapping relationships
- Establish a clear development path from basic to advanced implementation details
- Combine practical examples with architecture insights and real code analysis
- Provide comprehensive technical understanding through implementation-level details
- Clearly define boundaries between basic content and advanced content, achieving depth progression
- Build natural development paths between modules, ensuring detailed coverage at all levels
- Provide a solid technical foundation through core concepts and basic usage
- Provide comprehensive technical understanding frameworks for all major components
- Core component modules thoroughly cover system modules, services, and data architecture
- Functional implementation modules provide deep analysis of business logic and workflows
- Core function decomposition modules provide comprehensive functional architecture and module analysis
- Clearly define clear boundaries between basic knowledge and advanced technical implementation

**Content Validation Standards:**
- All modules meet user needs through detailed, specific questions and comprehensive answers
- Possess technical accuracy with deep implementation feasibility analysis
- Provide complete, comprehensive coverage of core project functionality implementation, including detailed functional analysis
- Build extensible structures providing depth details adapted to project complexity
- Each module provides substantial, educationally rich content, enabling deep domain exploration

**Technical Coverage Standards:**
- Complete analysis of project core technology stack and architectural decisions
- Detailed breakdown of system components and their responsibilities
- Comprehensive functional analysis combining implementation patterns, business logic, and workflow mapping
- Detailed functional module decomposition including use case implementation and interaction analysis
- Cover technical implementation details including algorithm design, pattern recognition, and performance optimization
- Comprehensive coverage of integration analysis for API interfaces, external systems, and extension mechanisms

**Quantity Validation Standards:**
- Generate a reasonable quantity of documents adapted to project complexity

## Quality Assurance Requirements

- Build all modules based on actual code analysis, avoiding generic templated content
- Create specific, executable prompt instructions referencing real project components
- Ensure logical progressive relationship from basic understanding to advanced implementation
- Generate comprehensive coverage content adapted to actual project complexity
- Include only modules that add value based on specific codebases
- Ensure each prompt instruction is detailed enough to generate substantial, educational content

Build comprehensive, detailed documentation systems and foundation structures that serve both novice users seeking deep understanding and professional users needing comprehensive technical analysis. Ensure each generated module provides deep, substantive content, helping users comprehensively master all technical dimensions of the project.
The final output must be in valid JSON format, directly usable for generating comprehensive documentation collections for specific projects.
`

export default GENERATE_THINK_CATALOGUE_TEMPLATE
