Skip to content

fix: exclude OS-specific files from kit init Kitfile generation#1099

Open
rishi-jat wants to merge 6 commits intokitops-ml:mainfrom
rishi-jat:fix/kit-init-ignore-os-files
Open

fix: exclude OS-specific files from kit init Kitfile generation#1099
rishi-jat wants to merge 6 commits intokitops-ml:mainfrom
rishi-jat:fix/kit-init-ignore-os-files

Conversation

@rishi-jat
Copy link
Copy Markdown
Contributor

Description

Running kit init previously included OS-generated metadata files (.DS_Store, Thumbs.db, etc.) in the generated Kitfile. This often resulted in unnecessary catch-all code layers (path: .) being added solely to include these hidden files.

Changes

  • Added osSpecificFiles list containing known OS-generated filenames (macOS and Windows)
  • Added shouldIgnoreFile() helper function with case-insensitive matching
  • Filter applied during directory scanning in genDirListingFromPath() to skip OS files before classification

Files Ignored

Filename Platform
.DS_Store macOS
.AppleDouble macOS
.LSOverride macOS
.Spotlight-V100 macOS
.Trashes macOS
Thumbs.db Windows
desktop.ini Windows
$RECYCLE.BIN Windows
ehthumbs.db Windows

Testing

  • kit init with only OS files → no code layer generated
  • kit init with model + OS files → only model included, no catch-all
  • kit init with normal files → behavior unchanged
  • kit pack unaffected
  • All existing tests pass (go test ./pkg/...)

Linked issues

Fixes #1081

@rishi-jat
Copy link
Copy Markdown
Contributor Author

/cc @akagami-harsh

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 PR fixes a bug where kit init was including OS-generated metadata files (like .DS_Store, Thumbs.db) in generated Kitfiles, often resulting in unnecessary catch-all code layers (path: .). The solution filters out these OS-specific files during directory scanning.

Changes:

  • Added osSpecificFiles list containing 9 known OS-generated filenames from macOS and Windows
  • Added shouldIgnoreFile() helper function with case-insensitive filename matching
  • Integrated filtering into genDirListingFromPath() to exclude OS files before file classification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +49
// shouldIgnoreFile returns true if the file should be ignored during Kitfile generation.
// This filters out OS-specific metadata files that users did not intentionally create.
func shouldIgnoreFile(name string) bool {
for _, osFile := range osSpecificFiles {
if strings.EqualFold(name, osFile) {
return true
}
}
return false
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new shouldIgnoreFile function lacks test coverage. The codebase has comprehensive automated testing for this package (see generate_test.go and integration tests in testing/generate-kitfile_test.go). Consider adding unit tests to verify case-insensitive matching of OS-specific filenames, including edge cases like different case variations (e.g., ".ds_store", "THUMBS.DB") and non-matching files.

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +38
var osSpecificFiles = []string{
".DS_Store", // macOS
".AppleDouble", // macOS
".LSOverride", // macOS
".Spotlight-V100", // macOS
".Trashes", // macOS
"Thumbs.db", // Windows
"desktop.ini", // Windows
"$RECYCLE.BIN", // Windows
"ehthumbs.db", // Windows
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider whether the HuggingFace integration (pkg/lib/hf/list.go:106-107) should also filter OS-specific files for consistency. Currently it only filters .gitignore and .gitattributes, but downloaded HuggingFace repositories might also contain OS metadata files. This could be addressed in a follow-up PR by having the HF integration also call shouldIgnoreFile (which would need to be exported or moved to a shared location).

Copilot uses AI. Check for mistakes.
@gorkem
Copy link
Copy Markdown
Member

gorkem commented Feb 27, 2026

The OS files that are now filtered from kit init will still be packed by kit pack if the Kitfile uses path: . The issue is explicitly asking to handle them.

Have you considered ways to leverage the existing .kitignore mechanism ?

@rishi-jat
Copy link
Copy Markdown
Contributor Author

@gorkem Thanks for the feedback.

The scan logic now ignores hidden files and OS metadata files during Kitfile generation. This prevents the catch-all code layer (path: .) from being created due to files like .DS_Store.

The ignore helper is also exported as generate.ShouldIgnoreFile() so the same logic can be reused elsewhere if needed.

Filter out OS-generated metadata files (.DS_Store, Thumbs.db, etc.)
during directory scanning in kit init to prevent spurious catch-all
code layers being added to the generated Kitfile.

Signed-off-by: Rishi Jat <rishijat098@gmail.com>
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
@rishi-jat rishi-jat force-pushed the fix/kit-init-ignore-os-files branch from e5b282f to 53e2659 Compare March 17, 2026 18:20
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
@rishi-jat rishi-jat requested a review from amisevsk March 18, 2026 10:22
@rishi-jat
Copy link
Copy Markdown
Contributor Author

@amisevsk please have a look.

Signed-off-by: Rishi Jat <rishijat098@gmail.com>
@rishi-jat rishi-jat requested a review from amisevsk March 20, 2026 14:56
@rishi-jat
Copy link
Copy Markdown
Contributor Author

@amisevsk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kit init includes hidden files in Kitfile

4 participants