Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions shared/src/main/kotlin/io/askimo/core/chat/util/FileTypeSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ object FileTypeSupport {
"nix", "dhall",
)

/**
* Config files without extensions (treated as code files).
*/
val CONFIG_EXTENSIONS = setOf(
"dockerfile",
"makefile",
"gemfile",
"rakefile",
"procfile",
"vagrantfile",
)

/**
* Document file extensions (for content extraction).
*/
Expand All @@ -76,6 +64,23 @@ object FileTypeSupport {
"bmp",
)

/**
* Extensionless configuration filenames stored in lowercase.
* These files have no extension but are recognised by their full filename.
*/
val CONFIG_EXTENSIONS = setOf(
"dockerfile",
"makefile",
"jenkinsfile",
"procfile",
"vagrantfile",
"rakefile",
"gemfile",
"podfile",
"brewfile",
"guardfile",
)

/**
* All text-extractable file extensions.
* These files have their content extracted and included in the prompt.
Expand Down Expand Up @@ -119,4 +124,13 @@ object FileTypeSupport {
* @return The extension without the dot, or empty string if no extension
*/
fun getExtension(fileName: String): String = fileName.substringAfterLast('.', "")

/**
* Check if a filename is a known extensionless configuration file.
* Comparison is case-insensitive.
*
* @param fileName The file name (without path)
* @return true if the filename is in CONFIG_EXTENSIONS
*/
fun isConfigFile(fileName: String): Boolean = fileName.lowercase() in CONFIG_EXTENSIONS
}
Loading
Loading