custom

Create your own module

Example

# Check out the docs at https://docs.second.dev/
# Constants are available across all steps
constants:
  limit: 3
  # You can use constants inside other constants as long as they are defined previously.
  limit_from_variable: '{{ limit }}'

steps:
  - tools:
      # Use regex to find all files in the current directory (up to a limit of 3)
      - name: find_files_by_name_with_regex
        arguments:
          path_to_directory: '.'
          find_file_name_pattern: '^[^\.]+\..+$'
          limit: '{{ limit }}'
        returns: files

      # For each file, get the file content
      - name: for_each
        items: '{{ files }}'
        each_item:
          item_name: file
          tools:
            - name: get_content_from_file
              arguments:
                path_to_file: '{{ file }}'
              returns: file_content

            # If the file content exists, show it in the agent trace.
            - name: if_else
              condition: '{{ file_content }}'
              returns_key: new_file_name # The name of the key that will be returned from the if_else step.
              if:
                tools:
                  - name: create_file_with_ai
                    arguments:
                      path_to_file: 'example/{{ file }}'
                      create_content_prompt: |
                        Create an example typescript file based off of the name of this file: `{{ file }}`
                    returns: new_example_file

                  - name: change_file_extension
                    arguments:
                      path_to_file: '{{ new_example_file }}'
                      new_extension: ts
                    returns: new_file_name
              returns: new_file

            - name: echo_one
              arguments:
                echo_arg: |
                  Here is the string from the conditional:
                  ```
                  {{ new_file }}
                  ```

Last updated