-
Notifications
You must be signed in to change notification settings - Fork 153
Add support for prompt and agent files in Kitfile generation #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c190469 to
b2ff00a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for recognizing prompt and agent files during Kitfile generation. The changes ensure that specific files (like AGENTS.md, SKILL.md, CLAUDE.md) and files with .prompt in their names are automatically classified as code files rather than documentation or metadata files.
Key Changes
- Added
promptFilePatternsvariable containing agent file names (AGENTS.md, SKILL.md, CLAUDE.md) - Modified
determineFileType()function to check for exact agent file matches and.promptsubstring patterns before checking other file extensions - Added comprehensive test coverage with 27 test cases covering prompt files, agent files, edge cases, and regular file types
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| pkg/lib/kitfile/generate/generate.go | Added prompt/agent file detection logic in determineFileType() function and new promptFilePatterns variable |
| pkg/lib/kitfile/generate/generate_test.go | New test file with table-driven tests for determineFileType() covering prompt files, agent files, and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for _, pattern := range promptFilePatterns { | ||
| if baseName == strings.ToLower(pattern) { |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider converting promptFilePatterns to lowercase once at initialization rather than calling strings.ToLower(pattern) on every iteration. This would avoid repeated string conversions. For example, you could create a var promptFilePatternsLower []string at package level that contains the lowercase versions, or directly store them as lowercase in the original slice.
| for _, pattern := range promptFilePatterns { | |
| if baseName == strings.ToLower(pattern) { | |
| for _, pattern := range promptFilePatternsLower { | |
| if baseName == pattern { |
| // Check for .prompt pattern (substring match) | ||
| if strings.Contains(baseName, ".prompt") { |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The substring check strings.Contains(baseName, ".prompt") may match unintended files. For example, files like "system.prompts.md" or "my.prompter.config" would also be matched because they contain ".prompt" as a substring. Consider using a more specific pattern, such as checking if the basename ends with ".prompt" or contains ".prompt." (with a trailing dot), or use strings.HasPrefix after splitting on dots to ensure ".prompt" is a complete segment.
| // Check for .prompt pattern (substring match) | |
| if strings.Contains(baseName, ".prompt") { | |
| // Check for .prompt as a complete segment or suffix | |
| if strings.HasSuffix(baseName, ".prompt") || strings.Contains(baseName, ".prompt.") { |
| name: "file ending with .prompt should match", | ||
| filename: "system.prompt", | ||
| expectedType: fileTypeCode, | ||
| }, |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case is a duplicate of the "prompt file without extension" test on lines 31-34 (both test "system.prompt"). Consider removing this duplicate or testing a different filename to add value.
| name: "file ending with .prompt should match", | |
| filename: "system.prompt", | |
| expectedType: fileTypeCode, | |
| }, |
| var promptFilePatterns = []string{ | ||
| "AGENTS.md", | ||
| "SKILL.md", | ||
| "CLAUDE.md", | ||
| } |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name promptFilePatterns is misleading since it contains agent-related files (AGENTS.md, SKILL.md, CLAUDE.md) that aren't necessarily prompt files. Consider renaming to something more inclusive like agentAndPromptFilePatterns or codeFilePatterns to better reflect its purpose of identifying files that should be treated as code.
Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
b2ff00a to
23818f4
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.