import { existsSync } from "fs"; import { join } from "path"; import { PROJECT_MARKERS } from "../types/index.ts"; /** * Detect the project type based on marker files */ export async function detectProjectMarker(path: string): Promise { for (const marker of Object.keys(PROJECT_MARKERS)) { const markerPath = join(path, marker); if (existsSync(markerPath)) { return marker; } } return null; } /** * Get the human-readable project type */ export function getProjectTypeName(marker: string | null): string { if (!marker) return "Unknown"; return PROJECT_MARKERS[marker] ?? "Unknown"; } /** * Check if a directory is likely a project (has marker files or is a git repo) */ export async function isLikelyProject(path: string): Promise { // Check for .git directory if (existsSync(join(path, ".git"))) { return true; } // Check for project markers for (const marker of Object.keys(PROJECT_MARKERS)) { if (existsSync(join(path, marker))) { return true; } } return false; }