get_file_context

Uses a graph to create a context string for a file.

Arguments

NameTypeDescriptionRequired

path_to_file

string

The path to the file to get the context for.

depth

number

The depth of the context to get for the file. Defaults to 3.

are_global

boolean

Whether the files found should be registered as global files that should be included in the context for the entire codebase.

rules

array

The rules to use to extract dependencies and build relationships between files.

rules.type

string

The type of connection. Must be one of the following: `resolve_path`, `string_match`

rules.source_patterns

array

The patterns to match in the file content. The matched content will be used to search the codebase for dependencies.

rules.target_patterns

array

Patterns to find relevant files in the codebase. These use placeholders like {1}, {2} which are replaced by matches from the source pattern after applying transformations (if any).

rules.match_transformations

array

The transformations to apply to the matches found by the source pattern. These must be one of the following: `upper_case`, `lower_case`, `camel_case`, `snake_case`, `kebab_case`

Returns

TypeDescription

prompt

A prompt friendly context string containing the context for this file up to the specified depth.

Example

- name: get_file_context
  arguments:
    path_to_file: <file-path>
    depth: 3
    rules:
      - type: string_match
        source_patterns:
          - import (.*) from "(.*)"
        match_transformations:
          - camel_case
        target_patterns:
          - 'export {1}'
          - 'export default {1}'
          - 'templateUrl: {2}'
  returns: <file-context>

Last updated