# Clone the repository
git clone https://github.com/sonii-shivansh/CodeContext.git
cd CodeContext
# Build the project
./gradlew build
# Run tests
./gradlew test
# Install distribution locally
./gradlew installDist
# Analyze current directory
./gradlew run --args="analyze ."
# Analyze specific directory
./gradlew run --args="analyze /path/to/project"
# Clear cache and analyze
./gradlew run --args="analyze . --clear-cache"
# Disable cache
./gradlew run --args="analyze . --no-cache"
# After running ./gradlew installDist
./build/install/codecontext/bin/codecontext analyze .
./gradlew test
./gradlew test --tests "com.codecontext.core.parser.ParserTest"
./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html
src/test/kotlin/com/codecontext/core/
ParserTest.kt - Parser functionalityDependencyGraphTest.kt - Graph buildingPropertyTest.kt - Property-based testingsrc/test/kotlin/com/codecontext/
E2ETest.kt - End-to-end workflowsBackendVerificationTest.kt - Full backend verificationsrc/test/kotlin/com/codecontext/core/
EdgeCaseTest.kt - Error handlingStressTest.kt - Performance testingrun --args="analyze ."Edit src/main/resources/logback.xml:
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
src/
βββ main/kotlin/com/codecontext/
β βββ Main.kt # Entry point
β βββ cli/ # CLI commands
β β βββ MainCommand.kt # Root command
β β βββ ImprovedAnalyzeCommand.kt # Analyze command
β β βββ ServerCommand.kt # API server
β β βββ AIAssistantCommand.kt # AI features
β βββ core/ # Core logic
β β βββ scanner/
β β β βββ RepositoryScanner.kt # File scanning
β β β βββ OptimizedGitAnalyzer.kt # Git analysis
β β βββ parser/
β β β βββ JavaRealParser.kt # Java parsing
β β β βββ KotlinRegexParser.kt # Kotlin parsing
β β β βββ ParsedFile.kt # Data model
β β β βββ ParserFactory.kt # Parser selection
β β βββ graph/
β β β βββ RobustDependencyGraph.kt # Graph building
β β βββ generator/
β β β βββ LearningPathGenerator.kt # Learning paths
β β βββ cache/
β β β βββ CacheManager.kt # Caching
β β βββ config/
β β βββ CodeContextConfig.kt # Configuration
β βββ output/
β β βββ ReportGenerator.kt # HTML generation
β βββ server/
β βββ ApiServer.kt # REST API
βββ test/kotlin/com/codecontext/ # Tests
We follow Kotlin Coding Conventions:
PascalCasecamelCaseUPPER_SNAKE_CASE_camelCase (optional)Add KDoc for public APIs:
/**
* Parses a source file and extracts package and import information.
*
* @param file The file to parse
* @return ParsedFile containing extracted metadata
* @throws IllegalArgumentException if file type is unsupported
*/
fun parse(file: File): ParsedFile
LanguageParser:
class PythonParser : LanguageParser {
override fun parse(file: File): ParsedFile {
// Implementation
}
}
ParserFactory.kt:
"py" -> pythonParser
src/test/kotlin/com/codecontext/core/parser/CliktCommand:
class MyCommand : CliktCommand(name = "mycommand", help = "Description") {
override fun run() {
// Implementation
}
}
Main.kt:
MainCommand()
.subcommands(
ImprovedAnalyzeCommand(),
MyCommand() // Add here
)
Edit src/main/kotlin/com/codecontext/output/ReportGenerator.kt
The report uses kotlinx.html DSL:
div("my-section") {
h2 { +"My Section" }
p { +"Content" }
}
build.gradle.kts:
version = "0.2.0"
Update CHANGELOG.md with release notes
git commit -m "chore: bump version to 0.2.0"
git tag v0.2.0
git push origin main --tags
./gradlew clean build installDist
time ./gradlew run --args="analyze /path/to/large/project"
./gradlew run --args="analyze ." -Dcom.sun.management.jmxremote
Happy coding! π