fix: expand brownfield project detection to cover Android, Kotlin, Gradle, and 15+ additional ecosystems

The code/package detection in cmdInitNewProject only recognized 7 file
extensions and 5 package files, missing Android (Kotlin + Gradle), Flutter
(Dart + pubspec.yaml), C/C++, C#, Ruby, PHP, Scala, and others. This caused
new-project to treat brownfield projects in those ecosystems as greenfield,
skipping the codebase mapping step.

Added 18 code extensions and 11 package/build files to the detection lists.

Fixes #1325

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-03-22 14:19:30 -04:00
parent ae69e6e9e4
commit dbc5b2ab87
2 changed files with 111 additions and 2 deletions

View File

@@ -252,7 +252,23 @@ function cmdInitNewProject(cwd, raw) {
let hasCode = false;
let hasPackageFile = false;
try {
const codeExtensions = new Set(['.ts', '.js', '.py', '.go', '.rs', '.swift', '.java']);
const codeExtensions = new Set([
'.ts', '.js', '.py', '.go', '.rs', '.swift', '.java',
'.kt', '.kts', // Kotlin (Android, server-side)
'.c', '.cpp', '.h', // C/C++
'.cs', // C#
'.rb', // Ruby
'.php', // PHP
'.dart', // Dart (Flutter)
'.m', '.mm', // Objective-C / Objective-C++
'.scala', // Scala
'.groovy', // Groovy (Gradle build scripts)
'.lua', // Lua
'.r', '.R', // R
'.zig', // Zig
'.ex', '.exs', // Elixir
'.clj', // Clojure
]);
const skipDirs = new Set(['node_modules', '.git', '.planning', '.claude', '__pycache__', 'target', 'dist', 'build']);
function findCodeFiles(dir, depth) {
if (depth > 3) return false;
@@ -273,7 +289,18 @@ function cmdInitNewProject(cwd, raw) {
pathExistsInternal(cwd, 'requirements.txt') ||
pathExistsInternal(cwd, 'Cargo.toml') ||
pathExistsInternal(cwd, 'go.mod') ||
pathExistsInternal(cwd, 'Package.swift');
pathExistsInternal(cwd, 'Package.swift') ||
pathExistsInternal(cwd, 'build.gradle') ||
pathExistsInternal(cwd, 'build.gradle.kts') ||
pathExistsInternal(cwd, 'pom.xml') ||
pathExistsInternal(cwd, 'Gemfile') ||
pathExistsInternal(cwd, 'composer.json') ||
pathExistsInternal(cwd, 'pubspec.yaml') ||
pathExistsInternal(cwd, 'CMakeLists.txt') ||
pathExistsInternal(cwd, 'Makefile') ||
pathExistsInternal(cwd, 'build.zig') ||
pathExistsInternal(cwd, 'mix.exs') ||
pathExistsInternal(cwd, 'project.clj');
const result = {
// Models