# Demonstrates:
# - CLI mode with file processing pipeline
# - if-then-else statement with conditional file operations
# - file I/O tools
# - LLM tool integration for code transformation
# - including external instruction data
shared:
  data:
    reformat_Scala_instructions: !require reformat-Scala-instructions.md

cli:
  process_input: one_by_one
  tools:
    - import_tool: llm_workers.tools.fs.read_file
    - import_tool: llm_workers.tools.fs.write_file
    - import_tool: llm_workers.tools.llm_tool.build_llm_tool
  do:
    - call: read_file
      params:
        path: "${input}"
        lines: 10000
    - call: llm
      params:
        prompt: |-
          You are senior Scala developer. Your job is to reformat give file according to the rules below. 
          
          Rules:
          ${reformat_Scala_instructions}
        
          After reformatting, output just the file content without any additional comments or formatting.      
          If no changes are needed, respond with string "NO CHANGES" (without quotes).
          
          Input file:
          ${_}
    - if: "${_ == 'NO CHANGES'}"
      then:
        eval: "${input}: NO CHANGES"
      else:
        - call: write_file
          params:
            path: "${input}"
            content: "${_}"
            if_exists: "overwrite"
        - eval: "${input}: FIXED"