Thank you for your interest in contributing to Lightfold CLI! This document provides guidelines and information for contributors.
- Code of Conduct
- Getting Started
- Development Setup
- Contributing Process
- Framework Detection
- Testing
- Documentation
- Release Process
By participating in this project, you agree to:
- Be respectful and inclusive
- Focus on constructive feedback
- Help maintain a welcoming environment
- Follow community guidelines
- Go 1.21 or later
- Git
- Basic understanding of web frameworks and build tools
-
Fork and Clone:
git clone https://github.com/your-username/lightfold.git cd lightfold -
Install Dependencies:
go mod download
-
Build and Test:
go build -o lightfold . ./lightfold --help
lightfold/
├── main.go # Core detection logic
├── cmd/ # CLI commands
│ └── root.go # Root command definition
├── go.mod # Go dependencies
├── README.md # User documentation
├── AGENTS.md # Developer context
└── test-projects/ # Test frameworks (local)
# Development build
go build -o lightfold .
# Cross-compilation examples
GOOS=linux GOARCH=amd64 go build -o lightfold-linux .
GOOS=windows GOARCH=amd64 go build -o lightfold-windows.exe .
GOOS=darwin GOARCH=arm64 go build -o lightfold-macos-arm64 .Before contributing:
- Check existing issues and PRs
- Create an issue for bugs or feature requests
- Discuss significant changes in issues first
# Create feature branch
git checkout -b feature/framework-name
# Make changes and test
go build -o lightfold .
./lightfold path/to/test/project
# Commit with clear messages
git commit -m "Add detection for Framework X
- Add scoring logic for framework config files
- Implement build plan with package manager detection
- Add tests for npm/yarn/pnpm/bun variants"- Clear Title: Descriptive title explaining the change
- Description: Explain what, why, and how
- Testing: Include test results and sample projects
- Documentation: Update README if needed
- Small PRs: Keep changes focused and reviewable
-
Research Phase:
# Create test project mkdir test-projects/new-framework # Set up minimal project structure # Document unique identifiers
-
Implementation:
Add detection block in
main.go:// NewFramework { score := 0.0 signals := []string{} // High-priority indicators (3+ points) if has("framework.config.js") { score += 3 signals = append(signals, "framework config") } // Medium-priority indicators (2-2.5 points) if has("package.json") { pj := strings.ToLower(read("package.json")) if strings.Contains(pj, `"new-framework"`) { score += 2.5 signals = append(signals, "package.json has new-framework") } } // Low-priority indicators (0.5-1 points) if dirExists(root, "src/pages") { score += 0.5 signals = append(signals, "framework structure") } if score > 0 { cands = append(cands, candidate{ name: "NewFramework", score: score, language: "JavaScript/TypeScript", signals: signals, plan: newFrameworkPlan, }) } }
-
Plan Function:
func newFrameworkPlan(root string) ([]string, []string, map[string]any, []string) { pm := detectPackageManager(root) build := []string{ getJSInstallCommand(pm), "framework build", } run := []string{ "framework start --port 3000", } health := map[string]any{ "path": "/", "expect": 200, "timeout_seconds": 30, } env := []string{"FRAMEWORK_API_KEY", "NODE_ENV"} return build, run, health, env }
- Unique Identifiers: Focus on framework-specific files
- Scoring Logic: Higher scores for more specific indicators
- Package Manager Integration: Always use detection functions
- Fallback Safety: Graceful degradation for ambiguous cases
When adding new package managers:
-
Detection Logic:
func detectPackageManager(root string) string { switch { case fileExists(root, "new-pm.lock"): return "new-pm" // ... existing cases } }
-
Command Generation:
func getJSInstallCommand(pm string) string { switch pm { case "new-pm": return "new-pm install" // ... existing cases } }
-
Create Test Projects:
mkdir -p test-projects/framework-name cd test-projects/framework-name # Create minimal project structure echo '{"name": "test", "dependencies": {"framework": "^1.0.0"}}' > package.json echo 'export default {}' > framework.config.js mkdir src
-
Test Detection:
./lightfold test-projects/framework-name
-
Test Package Managers:
# Test with different package managers touch test-projects/framework-name/yarn.lock ./lightfold test-projects/framework-name rm test-projects/framework-name/yarn.lock touch test-projects/framework-name/pnpm-lock.yaml ./lightfold test-projects/framework-name
- Framework correctly detected
- Appropriate confidence score
- Correct package manager detection
- Build commands use right package manager
- JSON output validates
- Edge cases handled (multiple frameworks, etc.)
# Test various scenarios
./lightfold . # Self-detection (Go project)
./lightfold /path/to/nextjs # Next.js project
./lightfold /path/to/django # Django project
./lightfold /path/to/mixed # Multiple frameworks
./lightfold /path/to/empty # Empty directoryWhen adding frameworks, update:
- Supported frameworks list
- Detection examples
- Package manager compatibility
- Clear function names and comments
- Document complex detection logic
- Explain scoring rationale
- Major (1.0.0): Breaking changes or major new features
- Minor (1.1.0): New frameworks, package managers, or features
- Patch (1.1.1): Bug fixes, minor improvements
- All tests passing
- Documentation updated
- Version updated in
cmd/root.go - CHANGELOG.md updated
- Git tag created
- Binaries built for all platforms
// Prefer graceful degradation
if err != nil {
// Log warning, continue with defaults
continue
}// Always use helper functions
if fileExists(root, "config.js") {
content := read("config.js")
// Process content
}// Case-insensitive, safe matching
if strings.Contains(strings.ToLower(content), "framework") {
// Framework detected
}- Issues: GitHub issues for bugs and features
- Discussions: GitHub discussions for questions
- Documentation: See AGENTS.md for detailed context
Contributors will be:
- Listed in release notes
- Credited in documentation
- Welcomed into the community
Thank you for contributing to Lightfold CLI! 🚀